!(function(){var Fq=Object.defineProperty,Bq=Object.defineProperties;var Uq=Object.getOwnPropertyDescriptors;var p3=Object.getOwnPropertySymbols,kq=Object.getPrototypeOf,zq=Object.prototype.hasOwnProperty,Vq=Object.prototype.propertyIsEnumerable,Gq=Reflect.get;var Kf=Math.pow,eE=(ae,ne,b)=>ne in ae?Fq(ae,ne,{enumerable:!0,configurable:!0,writable:!0,value:b}):ae[ne]=b,qs=(ae,ne)=>{for(var b in ne||(ne={}))zq.call(ne,b)&&eE(ae,b,ne[b]);if(p3)for(var b of p3(ne))Vq.call(ne,b)&&eE(ae,b,ne[b]);return ae},ac=(ae,ne)=>Bq(ae,Uq(ne));var aa=(ae,ne,b)=>eE(ae,typeof ne!="symbol"?ne+"":ne,b);var m3=(ae,ne,b)=>Gq(kq(ae),b,ne);var hr=(ae,ne,b)=>new Promise((w,k)=>{var O=R=>{try{S(b.next(R))}catch(x){k(x)}},A=R=>{try{S(b.throw(R))}catch(x){k(x)}},S=R=>R.done?w(R.value):Promise.resolve(R.value).then(O,A);S((b=b.apply(ae,ne)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[93616],{17663:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return x}});var w=b(87462),k=b(67294),O={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"question-circle",theme:"outlined"},A=O,S=b(84089),R=function(N,L){return k.createElement(S.Z,(0,w.Z)({},N,{ref:L,icon:A}))},x=k.forwardRef(R)},73686:function(ae,ne,b){"use strict";b.d(ne,{ni:function(){return lh},EF:function(){return oi}});var w=function($,Z){var le=$.nodes,we=$.edges,Re=[],Ge={};if(!le)throw new Error("invalid nodes data!");return le&&le.forEach(function(wt,Tt){Ge[wt.id]=Tt;var Lt=[];Re.push(Lt)}),we&&we.forEach(function(wt){var Tt=wt.source,Lt=wt.target,Gt=Ge[Tt],$t=Ge[Lt];!Gt&&Gt!==0||!$t&&$t!==0||(Re[Gt][$t]=1,Z||(Re[$t][Gt]=1))}),Re},k=w,O=function($,Z){return $===Z},A=function(){function se($,Z){Z===void 0&&(Z=null),this.value=$,this.next=Z}return se.prototype.toString=function($){return $?$(this.value):"".concat(this.value)},se}(),S=function(){function se($){$===void 0&&($=O),this.head=null,this.tail=null,this.compare=$}return se.prototype.prepend=function($){var Z=new A($,this.head);return this.head=Z,this.tail||(this.tail=Z),this},se.prototype.append=function($){var Z=new A($);return this.head?(this.tail.next=Z,this.tail=Z,this):(this.head=Z,this.tail=Z,this)},se.prototype.delete=function($){if(!this.head)return null;for(var Z=null;this.head&&this.compare(this.head.value,$);)Z=this.head,this.head=this.head.next;var le=this.head;if(le!==null)for(;le.next;)this.compare(le.next.value,$)?(Z=le.next,le.next=le.next.next):le=le.next;return this.compare(this.tail.value,$)&&(this.tail=le),Z},se.prototype.find=function($){var Z=$.value,le=Z===void 0?void 0:Z,we=$.callback,Re=we===void 0?void 0:we;if(!this.head)return null;for(var Ge=this.head;Ge;){if(Re&&Re(Ge.value)||le!==void 0&&this.compare(Ge.value,le))return Ge;Ge=Ge.next}return null},se.prototype.deleteTail=function(){var $=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,$;for(var Z=this.head;Z.next;)Z.next.next?Z=Z.next:Z.next=null;return this.tail=Z,$},se.prototype.deleteHead=function(){if(!this.head)return null;var $=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),$},se.prototype.fromArray=function($){var Z=this;return $.forEach(function(le){return Z.append(le)}),this},se.prototype.toArray=function(){for(var $=[],Z=this.head;Z;)$.push(Z),Z=Z.next;return $},se.prototype.reverse=function(){for(var $=this.head,Z=null,le=null;$;)le=$.next,$.next=Z,Z=$,$=le;this.tail=this.head,this.head=Z},se.prototype.toString=function($){return $===void 0&&($=void 0),this.toArray().map(function(Z){return Z.toString($)}).toString()},se}(),R=S,x=function(){function se(){this.linkedList=new R}return se.prototype.isEmpty=function(){return!this.linkedList.head},se.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},se.prototype.enqueue=function($){this.linkedList.append($)},se.prototype.dequeue=function(){var $=this.linkedList.deleteHead();return $?$.value:null},se.prototype.toString=function($){return this.linkedList.toString($)},se}(),E=x,N=function($,Z,le){Z===void 0&&(Z=[]);var we=Z.filter(function(Tt){return Tt.source===$||Tt.target===$});if(le==="target"){var Re=function(Lt){return Lt.source===$};return we.filter(Re).map(function(Tt){return Tt.target})}if(le==="source"){var Ge=function(Lt){return Lt.target===$};return we.filter(Ge).map(function(Tt){return Tt.source})}var wt=function(Lt){return Lt.source===$?Lt.target:Lt.source};return we.map(wt)},L=function($,Z){return Z.filter(function(le){return le.source===$})},P=function($,Z){return Z.filter(function(le){return le.source===$||le.target===$})},W=function($){$===void 0&&($=0);var Z="".concat(Math.random()).split(".")[1].substr(0,5),le="".concat(Math.random()).split(".")[1].substr(0,5);return"".concat($,"-").concat(Z).concat(le)};function K(se){se===void 0&&(se={});var $=se,Z=function(){},le=function(){var we={};return function(Re){var Ge=Re.next,wt=Ge;return we[wt]?!1:(we[wt]=!0,!0)}}();return $.allowTraversal=se.allowTraversal||le,$.enter=se.enter||Z,$.leave=se.leave||Z,$}var re=function($,Z,le,we){we===void 0&&(we=!0);var Re=K(le),Ge=new E,wt=$.edges,Tt=wt===void 0?[]:wt;Ge.enqueue(Z);for(var Lt="",Gt=function(){var hn=Ge.dequeue();Re.enter({current:hn,previous:Lt}),N(hn,Tt,we?"target":void 0).forEach(function(Ft){Re.allowTraversal({previous:Lt,current:hn,next:Ft})&&Ge.enqueue(Ft)}),Re.leave({current:hn,previous:Lt}),Lt=hn};!Ge.isEmpty();)Gt()},ye=re,ge=function($){for(var Z=$.nodes,le=Z===void 0?[]:Z,we=$.edges,Re=we===void 0?[]:we,Ge=[],wt={},Tt=[],Lt=function Ft(_n){Tt.push(_n),wt[_n.id]=!0;for(var Nn=N(_n.id,Re),Pn=function(On){var di=Nn[On];if(!wt[di]){var Ri=le.filter(function(ji){return ji.id===di});Ri.length>0&&Ft(Ri[0])}},ei=0;ei0;)hn.push(Tt.pop());Ge.push(hn)}}return Ge},ce=function($){for(var Z=$.nodes,le=Z===void 0?[]:Z,we=$.edges,Re=we===void 0?[]:we,Ge=[],wt={},Tt={},Lt={},Gt=[],$t=0,hn=function Pn(ei){Tt[ei.id]=$t,Lt[ei.id]=$t,$t+=1,Ge.push(ei),wt[ei.id]=!0;for(var ai=N(ei.id,Re,"target").filter(function(Qi){return le.map(function(er){return er.id}).indexOf(Qi)>-1}),On=function(er){var gr=ai[er];if(!Tt[gr]&&Tt[gr]!==0){var yr=le.filter(function(Nr){return Nr.id===gr});yr.length>0&&Pn(yr[0]),Lt[ei.id]=Math.min(Lt[ei.id],Lt[gr])}else wt[gr]&&(Lt[ei.id]=Math.min(Lt[ei.id],Tt[gr]))},di=0;di0;){var ji=Ge.pop();if(wt[ji.id]=!1,Ri.push(ji),ji===ei)break}Ri.length>0&&Gt.push(Ri)}},Ft=0,_n=le;Ft<_n.length;Ft++){var Nn=_n[Ft];!Tt[Nn.id]&&Tt[Nn.id]!==0&&hn(Nn)}return Gt};function xe(se,$){return $?ce(se):ge(se)}var fe=function($){var Z={},le=$.nodes,we=le===void 0?[]:le,Re=$.edges,Ge=Re===void 0?[]:Re;return we.forEach(function(wt){Z[wt.id]={degree:0,inDegree:0,outDegree:0}}),Ge.forEach(function(wt){Z[wt.source].degree++,Z[wt.source].outDegree++,Z[wt.target].degree++,Z[wt.target].inDegree++}),Z},Ne=fe,Ae=function($,Z){var le=fe($);return le[Z]?fe($)[Z].inDegree:0},be=function($,Z){var le=fe($);return le[Z]?fe($)[Z].outDegree:0};function Ye(se){se===void 0&&(se={});var $=se,Z=function(){},le=function(){var we={};return function(Re){var Ge=Re.next;return we[Ge]?!1:(we[Ge]=!0,!0)}}();return $.allowTraversal=se.allowTraversal||le,$.enter=se.enter||Z,$.leave=se.leave||Z,$}function Ee(se,$,Z,le,we){we===void 0&&(we=!0),le.enter({current:$,previous:Z});var Re=se.edges,Ge=Re===void 0?[]:Re;N($,Ge,we?"target":void 0).forEach(function(wt){le.allowTraversal({previous:Z,current:$,next:wt})&&Ee(se,wt,$,le,we)}),le.leave({current:$,previous:Z})}function We(se,$,Z,le){le===void 0&&(le=!0),Ee(se,$,"",Ye(Z),le)}var je=function($){var Z=null,le=$.nodes,we=le===void 0?[]:le,Re={},Ge={},wt={},Tt={};we.forEach(function($t){Ge[$t.id]=$t});for(var Lt={enter:function(hn){var Ft=hn.current,_n=hn.previous;if(wt[Ft]){Z={};for(var Nn=Ft,Pn=_n;Pn!==Ft;)Z[Nn]=Pn,Nn=Pn,Pn=Re[Pn];Z[Nn]=Pn}else wt[Ft]=Ft,delete Ge[Ft],Re[Ft]=_n},leave:function(hn){var Ft=hn.current;Tt[Ft]=Ft,delete wt[Ft]},allowTraversal:function(hn){var Ft=hn.next;return Z?!1:!Tt[Ft]}};Object.keys(Ge).length;){var Gt=Object.keys(Ge)[0];We($,Gt,Lt)}return Z},_t=function($,Z,le){var we,Re;le===void 0&&(le=!0);for(var Ge=[],wt=xe($,!1),Tt=0,Lt=wt;Tt0;)for(var Pn=Ft.pop(),ei=Pn.id,ai=N(ei,$.edges),On=function(ji){var Qi,er=ai[ji],gr=$.nodes.find(function(Es){return Es.id===er});if(er===ei)Ge.push((Qi={},Qi[er]=Pn,Qi));else if(!(er in Nn))_n[er]=Pn,Ft.push(gr),Nn[er]=new Set([Pn]);else if(!Nn[ei].has(gr)){for(var yr=!0,Nr=[gr,Pn],Ji=_n[ei];Nn[er].size&&!Nn[er].has(Ji)&&(Nr.push(Ji),Ji!==_n[Ji.id]);)Ji=_n[Ji.id];if(Nr.push(Ji),Z&&le?(yr=!1,Nr.findIndex(function(Es){return Z.indexOf(Es.id)>-1})>-1&&(yr=!0)):Z&&!le&&Nr.findIndex(function(Es){return Z.indexOf(Es.id)>-1})>-1&&(yr=!1),yr){for(var cs={},ds=1;ds0;){var ds=cs.pop();Re.has(ds)&&(Re.delete(ds),Ge[ds.id].forEach(function(Es){cs.push(Es)}),Ge[ds.id].clear())}},$t=function Nr(Ji,cs,ds){var Es=!1;if(Z&&le===!1&&Z.indexOf(Ji.id)>-1)return Es;we.push(Ji),Re.add(Ji);for(var Gs=ds[Ji.id],As=0;As-1});Dr-1)?wt.push((cs={},cs[kr.id]=kr,cs)):Br[kr.id].push(Lt[Ls])}}return{component:Xi,adjList:Br,minIdx:Es}},On=0;On=On}),Ri=ce({nodes:di,edges:$.edges}).filter(function(Nr){return Nr.length>1});if(Ri.length===0)break;var ji=ai(Ri),Qi=ji.minIdx,er=ji.adjList,gr=ji.component;if(gr.length>1){gr.forEach(function(Nr){Ge[Nr.id]=new Set});var yr=Tt[Qi];if(Z&&le&&Z.indexOf(yr.id)===-1)return wt;$t(yr,yr,er),On=Qi+1}else break}return wt},kt=function($,Z,le,we){return we===void 0&&(we=!0),Z?It($,le,we):_t($,le,we)},Ut=je,At=function(se,$){return At=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Z,le){Z.__proto__=le}||function(Z,le){for(var we in le)Object.prototype.hasOwnProperty.call(le,we)&&(Z[we]=le[we])},At(se,$)};function at(se,$){if(typeof $!="function"&&$!==null)throw new TypeError("Class extends value "+String($)+" is not a constructor or null");At(se,$);function Z(){this.constructor=se}se.prototype=$===null?Object.create($):(Z.prototype=$.prototype,new Z)}var Ot=function(){return Ot=Object.assign||function($){for(var Z,le=1,we=arguments.length;le=0;wt--)(Ge=se[wt])&&(Re=(we<3?Ge(Re):we>3?Ge($,Z,Re):Ge($,Z))||Re);return we>3&&Re&&Object.defineProperty($,Z,Re),Re}function vt(se,$){return function(Z,le){$(Z,le,se)}}function Jt(se,$,Z,le,we,Re){function Ge(ei){if(ei!==void 0&&typeof ei!="function")throw new TypeError("Function expected");return ei}for(var wt=le.kind,Tt=wt==="getter"?"get":wt==="setter"?"set":"value",Lt=!$&&se?le.static?se:se.prototype:null,Gt=$||(Lt?Object.getOwnPropertyDescriptor(Lt,le.name):{}),$t,hn=!1,Ft=Z.length-1;Ft>=0;Ft--){var _n={};for(var Nn in le)_n[Nn]=Nn==="access"?{}:le[Nn];for(var Nn in le.access)_n.access[Nn]=le.access[Nn];_n.addInitializer=function(ei){if(hn)throw new TypeError("Cannot add initializers after decoration has completed");Re.push(Ge(ei||null))};var Pn=(0,Z[Ft])(wt==="accessor"?{get:Gt.get,set:Gt.set}:Gt[Tt],_n);if(wt==="accessor"){if(Pn===void 0)continue;if(Pn===null||typeof Pn!="object")throw new TypeError("Object expected");($t=Ge(Pn.get))&&(Gt.get=$t),($t=Ge(Pn.set))&&(Gt.set=$t),($t=Ge(Pn.init))&&we.push($t)}else($t=Ge(Pn))&&(wt==="field"?we.push($t):Gt[Tt]=$t)}Lt&&Object.defineProperty(Lt,le.name,Gt),hn=!0}function Qe(se,$,Z){for(var le=arguments.length>2,we=0;we<$.length;we++)Z=le?$[we].call(se,Z):$[we].call(se);return le?Z:void 0}function rt(se){return typeof se=="symbol"?se:"".concat(se)}function bt(se,$,Z){return typeof $=="symbol"&&($=$.description?"[".concat($.description,"]"):""),Object.defineProperty(se,"name",{configurable:!0,value:Z?"".concat(Z," ",$):$})}function ze(se,$){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(se,$)}function Ze(se,$,Z,le){function we(Re){return Re instanceof Z?Re:new Z(function(Ge){Ge(Re)})}return new(Z||(Z=Promise))(function(Re,Ge){function wt(Gt){try{Lt(le.next(Gt))}catch($t){Ge($t)}}function Tt(Gt){try{Lt(le.throw(Gt))}catch($t){Ge($t)}}function Lt(Gt){Gt.done?Re(Gt.value):we(Gt.value).then(wt,Tt)}Lt((le=le.apply(se,$||[])).next())})}function q(se,$){var Z={label:0,sent:function(){if(Re[0]&1)throw Re[1];return Re[1]},trys:[],ops:[]},le,we,Re,Ge;return Ge={next:wt(0),throw:wt(1),return:wt(2)},typeof Symbol=="function"&&(Ge[Symbol.iterator]=function(){return this}),Ge;function wt(Lt){return function(Gt){return Tt([Lt,Gt])}}function Tt(Lt){if(le)throw new TypeError("Generator is already executing.");for(;Ge&&(Ge=0,Lt[0]&&(Z=0)),Z;)try{if(le=1,we&&(Re=Lt[0]&2?we.return:Lt[0]?we.throw||((Re=we.return)&&Re.call(we),0):we.next)&&!(Re=Re.call(we,Lt[1])).done)return Re;switch(we=0,Re&&(Lt=[Lt[0]&2,Re.value]),Lt[0]){case 0:case 1:Re=Lt;break;case 4:return Z.label++,{value:Lt[1],done:!1};case 5:Z.label++,we=Lt[1],Lt=[0];continue;case 7:Lt=Z.ops.pop(),Z.trys.pop();continue;default:if(Re=Z.trys,!(Re=Re.length>0&&Re[Re.length-1])&&(Lt[0]===6||Lt[0]===2)){Z=0;continue}if(Lt[0]===3&&(!Re||Lt[1]>Re[0]&&Lt[1]=se.length&&(se=void 0),{value:se&&se[le++],done:!se}}};throw new TypeError($?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(se,$){var Z=typeof Symbol=="function"&&se[Symbol.iterator];if(!Z)return se;var le=Z.call(se),we,Re=[],Ge;try{for(;($===void 0||$-- >0)&&!(we=le.next()).done;)Re.push(we.value)}catch(wt){Ge={error:wt}}finally{try{we&&!we.done&&(Z=le.return)&&Z.call(le)}finally{if(Ge)throw Ge.error}}return Re}function $e(){for(var se=[],$=0;$1||wt(hn,Ft)})})}function wt(hn,Ft){try{Tt(le[hn](Ft))}catch(_n){$t(Re[0][3],_n)}}function Tt(hn){hn.value instanceof et?Promise.resolve(hn.value.v).then(Lt,Gt):$t(Re[0][2],hn)}function Lt(hn){wt("next",hn)}function Gt(hn){wt("throw",hn)}function $t(hn,Ft){hn(Ft),Re.shift(),Re.length&&wt(Re[0][0],Re[0][1])}}function B(se){var $,Z;return $={},le("next"),le("throw",function(we){throw we}),le("return"),$[Symbol.iterator]=function(){return this},$;function le(we,Re){$[we]=se[we]?function(Ge){return(Z=!Z)?{value:et(se[we](Ge)),done:!1}:Re?Re(Ge):Ge}:Re}}function ie(se){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var $=se[Symbol.asyncIterator],Z;return $?$.call(se):(se=typeof Je=="function"?Je(se):se[Symbol.iterator](),Z={},le("next"),le("throw"),le("return"),Z[Symbol.asyncIterator]=function(){return this},Z);function le(Re){Z[Re]=se[Re]&&function(Ge){return new Promise(function(wt,Tt){Ge=se[Re](Ge),we(wt,Tt,Ge.done,Ge.value)})}}function we(Re,Ge,wt,Tt){Promise.resolve(Tt).then(function(Lt){Re({value:Lt,done:wt})},Ge)}}function ct(se,$){return Object.defineProperty?Object.defineProperty(se,"raw",{value:$}):se.raw=$,se}var Mt=Object.create?function(se,$){Object.defineProperty(se,"default",{enumerable:!0,value:$})}:function(se,$){se.default=$};function ht(se){if(se&&se.__esModule)return se;var $={};if(se!=null)for(var Z in se)Z!=="default"&&Object.prototype.hasOwnProperty.call(se,Z)&&Y($,se,Z);return Mt($,se),$}function Yt(se){return se&&se.__esModule?se:{default:se}}function en(se,$,Z,le){if(Z==="a"&&!le)throw new TypeError("Private accessor was defined without a getter");if(typeof $=="function"?se!==$||!le:!$.has(se))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?le:Z==="a"?le.call(se):le?le.value:$.get(se)}function nn(se,$,Z,le,we){if(le==="m")throw new TypeError("Private method is not writable");if(le==="a"&&!we)throw new TypeError("Private accessor was defined without a setter");if(typeof $=="function"?se!==$||!we:!$.has(se))throw new TypeError("Cannot write private member to an object whose class did not declare it");return le==="a"?we.call(se,Z):we?we.value=Z:$.set(se,Z),Z}function Me(se,$){if($===null||typeof $!="object"&&typeof $!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof se=="function"?$===se:se.has($)}var te={}.toString,Fe=function(se,$){return te.call(se)==="[object "+$+"]"},Xe=Fe,Pe=function(se){return Xe(se,"Function")},Ie=function(se){return Array.isArray?Array.isArray(se):Xe(se,"Array")},Ke=function(se){var $=typeof se;return se!==null&&$==="object"||$==="function"};function lt(se,$){if(se){var Z;if(Ie(se))for(var le=0,we=se.length;le-1;)Xl.call(se,Re,1);return se},Dl=null,nu=Array.prototype.splice,Du=function($,Z){if(!isArrayLike($))return[];for(var le=$?Z.length:0,we=le-1;le--;){var Re=void 0,Ge=Z[le];(le===we||Ge!==Re)&&(Re=Ge,nu.call($,Ge,1))}return $},Le=null,D=function(se,$,Z){if(!isArray(se)&&!isPlainObject(se))return se;var le=Z;return each(se,function(we,Re){le=$(le,we,Re)}),le},U=null,_=function(se,$){var Z=[];if(!isArrayLike(se))return Z;for(var le=-1,we=[],Re=se.length;++leRe[wt])return 1;if(we[wt]0},So=null,To=function(se,$){if(isArray(se)){for(var Z,le=-1/0,we=0;wele&&(Z=Re,le=Ge)}return Z}},Gr=function(se,$){if(isArray(se)){for(var Z,le=1/0,we=0;wewt&&Gt>wt);)if(Tt.push(Lt),wt-=Gt,Ge=Ge.substr(we),!Ge)return Tt.join("");for(;Lt=Ge.substr(0,1),Gt=measureTextWidth(Lt,Z),!(Gt+Re>wt);)if(Tt.push(Lt),wt-=Gt,Ge=Ge.substr(1),!Ge)return Tt.join("");return""+Tt.join("")+le},oE=function(){function se(){this.map={}}return se.prototype.has=function($){return this.map[$]!==void 0},se.prototype.get=function($,Z){var le=this.map[$];return le===void 0?Z:le},se.prototype.set=function($,Z){this.map[$]=Z},se.prototype.clear=function(){this.map={}},se.prototype.delete=function($){delete this.map[$]},se.prototype.size=function(){return Object.keys(this.map).length},se}(),aE=null,s1=function($,Z,le){for(var we=1/0,Re,Ge=0;Ge$t[Ri.id]+Ji?($t[Nr]=$t[Ri.id]+Ji,hn[Nr]=[Ri.id]):$t[Nr]===$t[Ri.id]+Ji&&hn[Nr].push(Ri.id)})},Nn=0;Nn0&&Gt.length>0;){var Ft=Gt[Gt.length-1];if(Ft.length){var _n=Ft.shift();_n&&(Tt.push(_n),Lt[_n]=!0,hn=we?N(_n,wt,"target"):N(_n,wt),Gt.push(hn.filter(function(ei){return!Lt[ei]})))}else{var Nn=Tt.pop();Lt[Nn]=!1,Gt.pop();continue}if(Tt[Tt.length-1]===le){var Pn=Tt.map(function(ai){return ai});$t.push(Pn);var Nn=Tt.pop();Lt[Nn]=!1,Gt.pop()}}return $t},a1=function($,Z){for(var le=k($,Z),we=[],Re=le.length,Ge=0;Gewe[Ge][Tt]+we[Tt][wt]&&(we[Ge][wt]=we[Ge][Tt]+we[Tt][wt]);return we},Ol=a1,Xa=function($,Z,le,we){Z===void 0&&(Z=!1),le===void 0&&(le="weight"),we===void 0&&(we=1e3);var Re=$.nodes,Ge=Re===void 0?[]:Re,wt=$.edges,Tt=wt===void 0?[]:wt,Lt={},Gt={};Ge.forEach(function(di,Ri){var ji=W();di.clusterId=ji,Lt[ji]={id:ji,nodes:[di]},Gt[di.id]={node:di,idx:Ri}});var $t=k($,Z),hn=[],Ft={};$t.forEach(function(di,Ri){var ji=0,Qi=Ge[Ri].id;Ft[Qi]={},di.forEach(function(er,gr){if(er){ji+=er;var yr=Ge[gr].id;Ft[Qi][yr]=er}}),hn.push(ji)});for(var _n=0,Nn=function(){var Ri=!1;if(Ge.forEach(function(ji){var Qi={};Object.keys(Ft[ji.id]).forEach(function(Es){var Gs=Ft[ji.id][Es],As=Gt[Es].node,us=As.clusterId;Qi[us]||(Qi[us]=0),Qi[us]+=Gs});var er=-1/0,gr=[];if(Object.keys(Qi).forEach(function(Es){er=0&&gr.splice(yr,1),gr&&gr.length){Ri=!0;var Nr=Lt[ji.clusterId],Ji=Nr.nodes.indexOf(ji);Nr.nodes.splice(Ji,1);var cs=Math.floor(Math.random()*gr.length),ds=Lt[gr[cs]];ds.nodes.push(ji),ji.clusterId=ds.id}}}),!Ri)return"break";_n++};_n0&&er>gr&&er-grgr&&(Nr=$t.map(function(Mi){return{node:Mi,clusterId:Mi.clusterId}}),Ji=Xd(ai),gr=er),cs||yr>100)break;yr++,Object.keys(ai).forEach(function(Mi){var Xi=0;Ft.forEach(function(Br){var kr=Br.source,Dr=Br.target,Jr=On[kr].node.clusterId,Ls=On[Dr].node.clusterId;(Jr===Mi&&Ls!==Mi||Ls===Mi&&Jr!==Mi)&&(Xi=Xi+(Br[le]||1))}),ai[Mi].sumTot=Xi}),$t.forEach(function(Mi,Xi){var Br=ai[Mi.clusterId],kr=0,Dr,Jr=Ri[Xi]/(2*Qi),Ls=0,Lo=Br.nodes;Lo.forEach(function(Ho){var wa=On[Ho.id].idx;Ls+=di[Xi][wa]||0});var Ka=Ls-Br.sumTot*Jr,oo=Lo.filter(function(Ho){return Ho.id!==Mi.id}),al=[];oo.forEach(function(Ho,wa){al[wa]=_n[Ho.originIndex]});var xs=Uu(oo,_n)*Lt,da=ji[Mi.id];if(Object.keys(da).forEach(function(Ho){var wa=On[Ho].node,na=wa.clusterId;if(na!==Mi.clusterId){var ll=ai[na],ia=ll.nodes;if(!(!ia||!ia.length)){var is=0;ia.forEach(function(Wr){var vs=On[Wr.id].idx;is+=di[Xi][vs]||0});var Bs=is-ll.sumTot*Jr,jn=ia.concat([Mi]),br=[];jn.forEach(function(Wr,vs){br[vs]=_n[Wr.originIndex]});var Do=Uu(jn,_n)*Lt,Ei=Bs-Ka;Re&&(Ei=Bs+Do-(Ka+xs)),Ei>kr&&(kr=Ei,Dr=ll)}}}),kr>0){Dr.nodes.push(Mi);var Ys=Mi.clusterId;Mi.clusterId=Dr.id;var Oc=Br.nodes.indexOf(Mi);Br.nodes.splice(Oc,1);var Co=0,Ul=0;Ft.forEach(function(Ho){var wa=Ho.source,na=Ho.target,ll=On[wa].node.clusterId,ia=On[na].node.clusterId;(ll===Dr.id&&ia!==Dr.id||ia===Dr.id&&ll!==Dr.id)&&(Co=Co+(Ho[le]||1)),(ll===Ys&&ia!==Ys||ia===Ys&&ll!==Ys)&&(Ul=Ul+(Ho[le]||1))}),Dr.sumTot=Co,Br.sumTot=Ul}})}var ds={},Es=0;Object.keys(Ji).forEach(function(Mi){var Xi=Ji[Mi];if(!Xi.nodes||!Xi.nodes.length){delete Ji[Mi];return}var Br=String(Es+1);Br!==Mi&&(Xi.id=Br,Xi.nodes=Xi.nodes.map(function(kr){return{id:kr.id,clusterId:Br}}),Ji[Br]=Xi,ds[Mi]=Br,delete Ji[Mi],Es++)}),Nr.forEach(function(Mi){var Xi=Mi.node,Br=Mi.clusterId;Xi&&(Xi.clusterId=Br,Xi.clusterId&&ds[Xi.clusterId]&&(Xi.clusterId=ds[Xi.clusterId]))});var Gs=[],As={};Ft.forEach(function(Mi){var Xi=Mi.source,Br=Mi.target,kr=Mi[le]||1,Dr=On[Xi].node.clusterId,Jr=On[Br].node.clusterId;if(!(!Dr||!Jr)){var Ls="".concat(Dr,"---").concat(Jr);if(As[Ls])As[Ls].weight+=kr,As[Ls].count++;else{var Lo={source:Dr,target:Jr,weight:kr,count:1};As[Ls]=Lo,Gs.push(Lo)}}});var us=[];return Object.keys(Ji).forEach(function(Mi){us.push(Ji[Mi])}),{clusters:us,clusterEdges:Gs}},Fr=Sl,np=function($,Z,le,we,Re,Ge,wt,Tt){return Z===void 0&&(Z=!1),le===void 0&&(le="weight"),we===void 0&&(we=1e-4),Re===void 0&&(Re=void 0),Ge===void 0&&(Ge=[]),wt===void 0&&(wt=["id"]),Tt===void 0&&(Tt=1),Fr($,Z,le,we,!0,Re,Ge,wt,Tt)},E0=np,A0=function($,Z){var le;Z===void 0&&(Z=1);for(var we=Xd($),Re=we.nodes,Ge=Re===void 0?[]:Re,wt=we.edges,Tt=wt===void 0?[]:wt,Lt=function(){var hn=Ne({nodes:Ge,edges:Tt}),Ft=Object.keys(hn);Ft.sort(function(Pn,ei){var ai,On;return((ai=hn[Pn])===null||ai===void 0?void 0:ai.degree)-((On=hn[ei])===null||On===void 0?void 0:On.degree)});var _n=Ft[0];if(!Ge.length||((le=hn[_n])===null||le===void 0?void 0:le.degree)>=Z)return"break";var Nn=Ge.findIndex(function(Pn){return Pn.id===_n});Ge.splice(Nn,1),Tt=Tt.filter(function(Pn){return!(Pn.source===_n||Pn.target===_n)})};;){var Gt=Lt();if(Gt==="break")break}return{nodes:Ge,edges:Tt}},qh=A0,qa=function($,Z,le){var we=[];switch($){case Fl.EuclideanDistance:we=Z[le];break;default:we=[];break}return we},ls=function($,Z,le,we,Re,Ge){Z===void 0&&(Z=3),le===void 0&&(le=void 0),we===void 0&&(we=[]),Re===void 0&&(Re=["id"]),Ge===void 0&&(Ge=Fl.EuclideanDistance);var wt=$.nodes,Tt=wt===void 0?[]:wt,Lt=$.edges,Gt=Lt===void 0?[]:Lt,$t={clusters:[{id:"0",nodes:Tt}],clusterEdges:[]};if(Ge===Fl.EuclideanDistance&&!Tt.every(function(Br){return Br.hasOwnProperty(le)}))return $t;var hn=[],Ft=[];if(Ge===Fl.EuclideanDistance&&(hn=_r(Tt,le),Ft=Bu(hn,we,Re)),!Ft.length)return $t;for(var _n=it(Ft.map(function(Br){return Br.join("")})),Nn=Math.min(Z,Tt.length,_n.length),Pn=0;PnRi&&!ei.find(function(oo){return ep(oo,qa(Ge,Ft,Tt[Dr].originIndex))})&&(Ri=Ka,ji=Dr)}},er=0;er=0;ds--)On[Number(Tt[Pn].clusterId)][ds].id===Tt[Pn].id&&On[Number(Tt[Pn].clusterId)].splice(ds,1);Tt[Pn].clusterId=String(yr),On[yr].push(Tt[Pn])}}for(var Es=!1,Pn=0;Pn=1e3)break}var Mi=[],Xi={};return Gt.forEach(function(Br){var kr,Dr,Jr=Br.source,Ls=Br.target,Lo=(kr=Tt.find(function(xs){return xs.id===Jr}))===null||kr===void 0?void 0:kr.clusterId,Ka=(Dr=Tt.find(function(xs){return xs.id===Ls}))===null||Dr===void 0?void 0:Dr.clusterId,oo="".concat(Lo,"---").concat(Ka);if(Xi[oo])Xi[oo].count++;else{var al={source:Lo,target:Ka,count:1};Xi[oo]=al,Mi.push(al)}}),{clusters:On,clusterEdges:Mi}},Yh=ls,yn=function($,Z){var le=new Fa(Z),we=le.norm2(),Re=new Fa($),Ge=Re.norm2(),wt=le.dot(Re),Tt=we*Ge,Lt=Tt?wt/Tt:0;return Lt},ea=yn,ot=function($,Z,le,we,Re){$===void 0&&($=[]),le===void 0&&(le=void 0),we===void 0&&(we=[]),Re===void 0&&(Re=[]);var Ge=Xd($.filter(function(hn){return hn.id!==Z.id})),wt=$.findIndex(function(hn){return hn.id===Z.id}),Tt=_r($,le),Lt=Bu(Tt,we,Re),Gt=Lt[wt],$t=[];return Ge.forEach(function(hn,Ft){if(hn.id!==Z.id){var _n=Lt[Ft],Nn=ea(_n,Gt);$t.push(Nn),hn.cosineSimilarity=Nn}}),Ge.sort(function(hn,Ft){return Ft.cosineSimilarity-hn.cosineSimilarity}),{allCosineSimilarity:$t,similarNodes:Ge}},ip=ot,Um=function(){function se($){this.count=$.length,this.parent={};for(var Z=0,le=$;Z0&&(this.list[0]=Z,this.moveDown(0)),$},se.prototype.insert=function($){if($!==null){this.list.push($);var Z=this.list.length-1;return this.moveUp(Z),!0}return!1},se.prototype.moveUp=function($){for(var Z=this.getParent($);$&&$>0&&this.compareFn(this.list[Z],this.list[$])>0;){var le=this.list[Z];this.list[Z]=this.list[$],this.list[$]=le,$=Z,Z=this.getParent($)}},se.prototype.moveDown=function($){var Z,le=$,we=this.getLeft($),Re=this.getRight($),Ge=this.list.length;we!==null&&we0?le=we:Re!==null&&Re0&&(le=Re),$!==le&&(Z=[this.list[le],this.list[$]],this.list[$]=Z[0],this.list[le]=Z[1],this.moveDown(le))},se}(),C0=sp,ch=function($,Z){var le=[],we=$.nodes,Re=we===void 0?[]:we,Ge=$.edges,wt=Ge===void 0?[]:Ge;if(Re.length===0)return le;var Tt=Re[0],Lt=new Set;Lt.add(Tt);var Gt=function(Pn,ei){return Z?Pn.weight-ei.weight:0},$t=new C0(Gt);for(P(Tt.id,wt).forEach(function(Nn){$t.insert(Nn)});!$t.isEmpty();){var hn=$t.delMin(),Ft=hn.source,_n=hn.target;Lt.has(Ft)&&Lt.has(_n)||(le.push(hn),Lt.has(Ft)||(Lt.add(Ft),P(Ft,wt).forEach(function(Nn){$t.insert(Nn)})),Lt.has(_n)||(Lt.add(_n),P(_n,wt).forEach(function(Nn){$t.insert(Nn)})))}return le},uh=function($,Z){var le=[],we=$.nodes,Re=we===void 0?[]:we,Ge=$.edges,wt=Ge===void 0?[]:Ge;if(Re.length===0)return le;var Tt=wt.map(function(Ft){return Ft});Z&&Tt.sort(function(Ft,_n){return Ft.weight-_n.weight});for(var Lt=new $r(Re.map(function(Ft){return Ft.id}));Tt.length>0;){var Gt=Tt.shift(),$t=Gt.source,hn=Gt.target;Lt.connected($t,hn)||(le.push(Gt),Lt.union($t,hn))}return le},Ya=function($,Z,le){var we={prim:ch,kruskal:uh};return le?we[le]($,Z):uh($,Z)},ns=Ya,ol=function($,Z,le){typeof Z!="number"&&(Z=1e-6),typeof le!="number"&&(le=.85);for(var we=1,Re=0,Ge=1e3,wt=$.nodes,Tt=wt===void 0?[]:wt,Lt=$.edges,Gt=Lt===void 0?[]:Lt,$t=Tt.length,hn,Ft={},_n={},Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;Ft[ei]=1/$t,_n[ei]=1/$t}for(var ai=Ne($);Ge>0&&we>Z;){Re=0;for(var Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;if(hn=0,ai[Pn.id].inDegree===0)Ft[ei]=0;else{for(var On=N(ei,Gt,"source"),di=0;di0&&(hn+=_n[Ri]/ji)}Ft[ei]=le*hn,Re+=Ft[ei]}}Re=(1-Re)/$t,we=0;for(var Nn=0;Nn<$t;++Nn){var Pn=Tt[Nn],ei=Pn.id;hn=Ft[ei]+Re,we+=Math.abs(hn-_n[ei]),_n[ei]=hn}Ge-=1}return _n},oi=ol,vl=-1,Rt=-1,Kd="-1",Ki="-1",ua=-1,ku="-1",su=function(){function se($,Z,le,we){$===void 0&&($=vl),Z===void 0&&(Z=Rt),le===void 0&&(le=Rt),we===void 0&&(we=Kd),this.id=$,this.from=Z,this.to=le,this.label=we}return se}(),km=function(){function se($,Z){$===void 0&&($=Rt),Z===void 0&&(Z=Ki),this.id=$,this.label=Z,this.edges=[],this.edgeMap={}}return se.prototype.addEdge=function($){this.edges.push($),this.edgeMap[$.id]=$},se}(),zm=function(){function se($,Z,le){$===void 0&&($=Rt),Z===void 0&&(Z=!0),le===void 0&&(le=!1),this.id=$,this.edgeIdAutoIncrease=Z,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=le}return se.prototype.getNodeNum=function(){return this.nodes.length},se.prototype.addNode=function($,Z){if(!this.nodeMap[$]){var le=new km($,Z);this.nodes.push(le),this.nodeMap[$]=le,this.nodeLabelMap[Z]||(this.nodeLabelMap[Z]=[]),this.nodeLabelMap[Z].push($)}},se.prototype.addEdge=function($,Z,le,we){if((this.edgeIdAutoIncrease||$===void 0)&&($=this.counter++),!(this.nodeMap[Z]&&this.nodeMap[le]&&this.nodeMap[le].edgeMap[$])){var Re=new su($,Z,le,we);if(this.edges.push(Re),this.edgeMap[$]=Re,this.nodeMap[Z].addEdge(Re),this.edgeLabelMap[we]||(this.edgeLabelMap[we]=[]),this.edgeLabelMap[we].push(Re),!this.directed){var Ge=new su($,le,Z,we);this.nodeMap[le].addEdge(Ge),this.edgeLabelMap[we].push(Ge)}}},se}(),wo=function(){function se($,Z,le,we,Re){this.fromNode=$,this.toNode=Z,this.nodeEdgeNodeLabel={nodeLabel1:le||Ki,edgeLabel:we||Kd,nodeLabel2:Re||Ki}}return se.prototype.equalTo=function($){return this.fromNode===$.formNode&&this.toNode===$.toNode&&this.nodeEdgeNodeLabel===$.nodeEdgeNodeLabel},se.prototype.notEqualTo=function($){return!this.equalTo($)},se}(),Bl=function(){function se(){this.rmpath=[],this.dfsEdgeList=[]}return se.prototype.equalTo=function($){var Z=this.dfsEdgeList.length,le=$.length;if(Z!==le)return!1;for(var we=0;we=0;le--){var we=this.dfsEdgeList[le],Re=we.fromNode,Ge=we.toNode;ReFt||we.hasNode(Ge[hn.to])||(Z.labelOn;Ri--){var ji=di(Ri);if(ji==="break")break}if(ei){var Qi=$.findMinLabel(Pn);Ge.dfsEdgeList.push(new wo(Nn,ai,Ki,Qi.edgeLabel,Ki));var er=Ge.dfsEdgeList.length-1;return $.dfsCode.dfsEdgeList[er]!==Ge.dfsEdgeList[er]?!1:$t(Pn[Qi.edgeLabel].projected)}var gr={};ei=!1;var yr=0;hn.forEach(function(Gs){var As=new Ic(Gs),us=$.findForwardPureEdges(we,As.edges[Ft[0]],_n,As);us.length>0&&(ei=!0,yr=Nn,us.forEach(function(Mi){var Xi="".concat(Mi.label,"-").concat(Re[Mi.to].label);gr[Xi]||(gr[Xi]={projected:[],edgeLabel:Mi.label,nodeLabel2:Re[Mi.to].label}),gr[Xi].projected.push({graphId:we.id,edge:Mi,preNode:Gs})}))});for(var Nr=Ft.length,Ji=function(As){if(ei)return"break";var us=Ft[As];hn.forEach(function(Mi){var Xi=new Ic(Mi),Br=$.findForwardRmpathEdges(we,Xi.edges[us],_n,Xi);Br.length>0&&(ei=!0,yr=Ge.dfsEdgeList[us].fromNode,Br.forEach(function(kr){var Dr="".concat(kr.label,"-").concat(Re[kr.to].label);gr[Dr]||(gr[Dr]={projected:[],edgeLabel:kr.label,nodeLabel2:Re[kr.to].label}),gr[Dr].projected.push({graphId:we.id,edge:kr,preNode:Mi})}))})},Ri=0;Ri=0;_n--){var Nn=Z.findBackwardEdge($t,Ft.edges[Re[_n]],Ft.edges[Re[0]],Ft);if(Nn){var Pn="".concat(Z.dfsCode.dfsEdgeList[Re[_n]].fromNode,"-").concat(Nn.label);Lt[Pn]||(Lt[Pn]={projected:[],toNodeId:Z.dfsCode.dfsEdgeList[Re[_n]].fromNode,edgeLabel:Nn.label}),Lt[Pn].projected.push({graphId:Gt.graphId,edge:Nn,preNode:Gt})}}if(!(we>=Z.maxNodeNum)){var ei=Z.findForwardPureEdges($t,Ft.edges[Re[0]],wt,Ft);ei.forEach(function(On){var di="".concat(Ge,"-").concat(On.label,"-").concat(hn[On.to].label);Tt[di]||(Tt[di]={projected:[],fromNodeId:Ge,edgeLabel:On.label,nodeLabel2:hn[On.to].label}),Tt[di].projected.push({graphId:Gt.graphId,edge:On,preNode:Gt})});for(var ai=function(di){var Ri=Z.findForwardRmpathEdges($t,Ft.edges[Re[di]],wt,Ft);Ri.forEach(function(ji){var Qi="".concat(Z.dfsCode.dfsEdgeList[Re[di]].fromNode,"-").concat(ji.label,"-").concat(hn[ji.to].label);Tt[Qi]||(Tt[Qi]={projected:[],fromNodeId:Z.dfsCode.dfsEdgeList[Re[di]].fromNode,edgeLabel:ji.label,nodeLabel2:hn[ji.to].label}),Tt[Qi].projected.push({graphId:Gt.graphId,edge:ji,preNode:Gt})})},_n=0;_nOn){var di=On;On=ai,ai=di}var Ri=ei.label,ji="".concat(Lt,"-").concat(ai,"-").concat(Ri,"-").concat(On),Qi="".concat(ai,"-").concat(Ri,"-").concat(On);if(!Ge[Qi]){var er=Ge[Qi]||0;er++,Ge[Qi]=er}Tt[ji]={graphId:Lt,nodeLabel1:ai,edgeLabel:Ri,nodeLabel2:On}})})}),Object.keys(Re).forEach(function(Lt){var Gt=Re[Lt];if(!(Gt2*Z)););if(Pn<2*Z&&(wt["".concat(Gt,"-").concat(Nn)]={start:Gt,end:Nn,distance:Re[Gt][Nn]},$t++,Tt++,Tt>=le))return wt;if(hn++,hn>2*Z)break}if($thn&&(Tt=hn);var Ft=le[$t.id].inDegree;Lt>Ft&&(Lt=Ft);var _n=le[$t.id].outDegree;Gt>_n&&(Gt=_n)}),$[Z]={degree:Tt,inDegree:Lt,outDegree:Gt}),{minPatternNodeLabelDegree:Tt,minPatternNodeLabelInDegree:Lt,minPatternNodeLabelOutDegree:Gt}},ba=function($,Z,le,we,Re,Ge,wt){var Tt;if(le===void 0&&(le=!1),Ge===void 0&&(Ge="cluster"),wt===void 0&&(wt="cluster"),!(!$||!$.nodes)){var Lt=$.nodes.length;if(Lt){var Gt=Ol($,le),$t=Ol(Z,le),hn=hh($.nodes,Gt,le),Ft=hh(Z.nodes,$t,le),_n=Qd($.nodes,Ge),Nn=_n.nodeMap,Pn=_n.nodeLabelMap,ei=Qd(Z.nodes,Ge),ai=ei.nodeMap,On=ei.nodeLabelMap;au($.edges,wt,Nn);var di=au(Z.edges,wt,ai).edgeLabelMap,Ri=[];$t==null||$t.forEach(function(is){Ri=Ri.concat(is)}),Re||(Re=Math.max.apply(Math,ke(ke([],Ri,!1),[2],!1))),we||(we=Re);var ji=op($,Gt,Ge,we),Qi=op(Z,$t,Ge,we),er=Math.min(100,Lt*(Lt-1)/2),gr=Ba(we,Lt,er,ji,Gt),yr=ha(gr,ji,$),Nr=10,Ji=1,cs=1,ds=4,Es={graphs:yr,nodeLabelProp:Ge,edgeLabelProp:wt,minSupport:Ji,minNodeNum:cs,maxNodeNum:ds,directed:le},Gs=Jd(Es).slice(0,Nr),As=Gs.length,us=[];Gs.forEach(function(is,Bs){us[Bs]={},Object.keys(yr).forEach(function(jn){var br=yr[jn],Do=Zl(br,is,Ge,wt);us[Bs][jn]=Do})});var Mi=Kl(us,As,Gs),Xi=Mi.structure,Br=Mi.structureCountMap,kr=Z.nodes[0],Dr=[],Jr=(Tt=Z.nodes[0])===null||Tt===void 0?void 0:Tt[Ge],Ls=-1/0;Z.nodes.forEach(function(is){var Bs=is[Ge],jn=Pn[Bs];(jn==null?void 0:jn.length)>Ls&&(Ls=jn.length,Dr=jn,Jr=Bs,kr=is)});var Lo={},Ka={},oo={},al={},xs={},da={};Object.keys(On).forEach(function(is,Bs){xs[is]=[],le&&(da[is]=[]);var jn=-1/0,br=On[is],Do={};br.forEach(function(vr){var Cs=Ft["".concat(kr.id,"-").concat(vr.id)];if(Cs&&xs[is].push(Cs),jnxs[is][Ma]){Qr=!0;break}if(Qr)return Dr.splice(Cs,1),"continue";var dc={};Ms.neighbors.forEach(function(ka){var yo=hn["".concat(Ro.id,"-").concat(ka.id)];dc["".concat(Ro.id,"-").concat(ka.id)]={start:Nn[Ro.id].idx,end:Nn[ka.id].idx,distance:yo}}),yr=ha(dc,ji,$,yr);var ao=[];Object.keys(dc).forEach(function(ka){if(Br[ka]){ao.push(Br[ka]);return}var yo=yr[ka];Br[ka]=Zl(yo,Xi,Ge,wt),ao.push(Br[ka])}),ao=ao.sort(function(ka,yo){return yo-ka});for(var fc=!1,Ma=0;Ma=0;ar--)vs(ar)});var Ys=[];Dr==null||Dr.forEach(function(is){for(var Bs=Nn[is.id].idx,jn=xl($.nodes,Gt[Bs],Bs,Ge,Re),br=jn.neighbors,Do=br.length,Ei=!1,Wr=Do-1;Wr>=0;Wr--){if(br.length+1Ms){br.splice(Wr,1);continue}if(le){var Ws="".concat(vs.id,"-").concat(is.id),dh=hn[Ws];Ro=da[ar].length-1;var Qr=da[ar][Ro];if(dh>Qr){br.splice(Wr,1);continue}}var Ma=Br[vr]?Br[vr]:ta($,is,vs,Nn,Cs,ji,Xi,Ge,wt,Br,yr),dc="".concat(kr.id,"-").concat(ar),ao=al[dc][al[dc].length-1];if(Ma=0;Cs--){var Qr=dh(Cs);if(Qr==="break")break}if(Ws)return Ys.splice(Bs,1),"continue";jn.edges=Wr;var Ma=so(jn,jn.nodes[0].id,!1).length;if(Object.keys(Ma).reverse().forEach(function(fs){if(!(fs===jn.nodes[0].id||Ws)){if(Ma[fs]===1/0){var Ta=Ei[fs].node[Ge];if(Do[Ta]--,Do[Ta]Co[Or][Co[Or].length-1]){var Ta=Ei[fs].node[Ge];if(Do[Ta]--,Do[Ta]=0;yo--){var pc=jn.nodes[yo],Vm=Ei[pc.id].degree,Zi=Ei[pc.id].inDegree,sx=Ei[pc.id].outDegree,kl=pc[Ge],ef=Ua(Lo,kl,ai,On),zu=ef.minPatternNodeLabelDegree,zl=ef.minPatternNodeLabelInDegree,qi=ef.minPatternNodeLabelOutDegree,Sa=le?Vm=0;xr--){var Vl=Wr[xr];if(!Ei[Vl.source]||!Ei[Vl.target]){Wr.splice(xr,1);var cl=Vl[wt];if(vs[cl]--,Ei[Vl.source]&&(Ei[Vl.source].degree--,Ei[Vl.source].outDegree--),Ei[Vl.target]&&(Ei[Vl.target].degree--,Ei[Vl.target].inDegree--),di[cl]&&vs[cl]=0;wa--){var na=Ho(wa);if(na==="break")break}for(var ll=Ys.length,ia=function(Bs){var jn=Ys[Bs],br={};jn.edges.forEach(function(Wr){var vs="".concat(Wr.source,"-").concat(Wr.target,"-").concat(Wr.label);br[vs]?br[vs]++:br[vs]=1});for(var Do=function(vs){var ar=Ys[vs],vr={};ar.edges.forEach(function(Ro){var Ms="".concat(Ro.source,"-").concat(Ro.target,"-").concat(Ro.label);vr[Ms]?vr[Ms]++:vr[Ms]=1});var Cs=!0;Object.keys(vr).length!==Object.keys(br).length?Cs=!1:Object.keys(br).forEach(function(Ro){vr[Ro]!==br[Ro]&&(Cs=!1)}),Cs&&Ys.splice(vs,1)},Ei=ll-1;Ei>Bs;Ei--)Do(Ei);ll=Ys.length},wa=0;wa<=ll-1;wa++)ia(wa);return Ys}}},uc=ba,hc=function(){function se($){$===void 0&&($=10),this.linkedList=new R,this.maxStep=$}return Object.defineProperty(se.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),se.prototype.isEmpty=function(){return!this.linkedList.head},se.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},se.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},se.prototype.push=function($){this.linkedList.prepend($),this.length>this.maxStep&&this.linkedList.deleteTail()},se.prototype.pop=function(){var $=this.linkedList.deleteHead();return $?$.value:null},se.prototype.toArray=function(){return this.linkedList.toArray().map(function($){return $.value})},se.prototype.clear=function(){for(;!this.isEmpty();)this.pop()},se}(),Lc=hc,Dc=Ut,Tl={getAdjMatrix:k,breadthFirstSearch:ye,connectedComponent:xe,getDegree:Ne,getInDegree:Ae,getOutDegree:be,detectCycle:Ut,detectDirectedCycle:Dc,detectAllCycles:kt,detectAllDirectedCycle:It,detectAllUndirectedCycle:_t,depthFirstSearch:We,dijkstra:so,findAllPath:o1,findShortestPath:lh,floydWarshall:Ol,labelPropagation:Fu,louvain:Fr,iLouvain:E0,kCore:qh,kMeans:Yh,cosineSimilarity:ea,nodesCosineSimilarity:ip,minimumSpanningTree:ns,pageRank:oi,getNeighbors:N,Stack:Lc,GADDI:uc}},90494:function(ae,ne){"use strict";var b="*",w=function(){function k(){this._events={}}return k.prototype.on=function(O,A,S){return this._events[O]||(this._events[O]=[]),this._events[O].push({callback:A,once:!!S}),this},k.prototype.once=function(O,A){return this.on(O,A,!0)},k.prototype.emit=function(O){for(var A=this,S=[],R=1;R0?Ke:Ke*-1}function E(Pe,Ie,Ke,lt,qe,pt){var Ct=Ke,Xt=lt;if(Ct===0||Xt===0)return{x:Pe,y:Ie};for(var Qt=qe-Pe,pn=pt-Ie,Wn=Math.abs(Qt),Rn=Math.abs(pn),bi=Ct*Ct,Lr=Xt*Xt,Qn=Math.PI/4,Vi=0,Oi=0,Gi=0;Gi<4;Gi++){Vi=Ct*Math.cos(Qn),Oi=Xt*Math.sin(Qn);var ir=(bi-Lr)*Math.pow(Math.cos(Qn),3)/Ct,ms=(Lr-bi)*Math.pow(Math.sin(Qn),3)/Xt,Is=Vi-ir,as=Oi-ms,gs=Wn-ir,Vs=Rn-ms,Xl=Math.hypot(as,Is),ql=Math.hypot(Vs,gs),Da=Xl*Math.asin((Is*Vs-as*gs)/(Xl*ql)),Dl=Da/Math.sqrt(bi+Lr-Vi*Vi-Oi*Oi);Qn+=Dl,Qn=Math.min(Math.PI/2,Math.max(0,Qn))}return{x:Pe+x(Vi,Qt),y:Ie+x(Oi,pn)}}function N(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return-1*Ke*Math.cos(qe)*Math.sin(Xt)-lt*Math.sin(qe)*Math.cos(Xt)}function L(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return-1*Ke*Math.sin(qe)*Math.sin(Xt)+lt*Math.cos(qe)*Math.cos(Xt)}function P(Pe,Ie,Ke){return Math.atan(-Ie/Pe*Math.tan(Ke))}function W(Pe,Ie,Ke){return Math.atan(Ie/(Pe*Math.tan(Ke)))}function K(Pe,Ie,Ke,lt,qe,pt){return Ke*Math.cos(qe)*Math.cos(pt)-lt*Math.sin(qe)*Math.sin(pt)+Pe}function re(Pe,Ie,Ke,lt,qe,pt){return Ke*Math.sin(qe)*Math.cos(pt)+lt*Math.cos(qe)*Math.sin(pt)+Ie}function ye(Pe,Ie,Ke,lt){var qe=Math.atan2(lt*Pe,Ke*Ie);return(qe+Math.PI*2)%(Math.PI*2)}function ge(Pe,Ie,Ke){return{x:Pe*Math.cos(Ke),y:Ie*Math.sin(Ke)}}function ce(Pe,Ie,Ke){var lt=Math.cos(Ke),qe=Math.sin(Ke);return[Pe*lt-Ie*qe,Pe*qe+Ie*lt]}function xe(Pe,Ie,Ke,lt,qe,pt,Ct){for(var Xt=P(Ke,lt,qe),Qt=1/0,pn=-1/0,Wn=[pt,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var bi=Xt+Rn;ptpn&&(pn=Lr)}for(var Qn=W(Ke,lt,qe),Vi=1/0,Oi=-1/0,Gi=[pt,Ct],Rn=-Math.PI*2;Rn<=Math.PI*2;Rn+=Math.PI){var ir=Qn+Rn;ptOi&&(Oi=ms)}return{x:Qt,y:Vi,width:pn-Qt,height:Oi-Vi}}function fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){var pn=ce(Xt-Pe,Qt-Ie,-qe),Wn=__read(pn,2),Rn=Wn[0],bi=Wn[1],Lr=E(0,0,Ke,lt,Rn,bi),Qn=ye(Ke,lt,Lr.x,Lr.y);QnCt&&(Lr=ge(Ke,lt,Ct));var Vi=ce(Lr.x,Lr.y,qe);return{x:Vi[0]+Pe,y:Vi[1]+Ie}}function Ne(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){var Qt=(Ct-pt)*Xt+pt,pn=N(Pe,Ie,Ke,lt,qe,pt,Ct,Qt),Wn=L(Pe,Ie,Ke,lt,qe,pt,Ct,Qt);return R(Math.atan2(Wn,pn))}var Ae=1e-4;function be(Pe,Ie,Ke,lt,qe,pt){var Ct=-1,Xt=1/0,Qt=[Ke,lt],pn=20;pt&&pt>200&&(pn=pt/10);for(var Wn=1/pn,Rn=Wn/10,bi=0;bi<=pn;bi++){var Lr=bi*Wn,Qn=[qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Pe.concat([Lr])),!1)),qe.apply(void 0,(0,w.ev)([],(0,w.CR)(Ie.concat([Lr])),!1))],Vi=A(Qt[0],Qt[1],Qn[0],Qn[1]);Vi=0&&ViXt?A(Ke,lt,qe,pt):It(Pe,Ie,Ke,lt,qe,pt)}function It(Pe,Ie,Ke,lt,qe,pt){var Ct=[Ke-Pe,lt-Ie];if(O.I6(Ct,[0,0]))return Math.sqrt((qe-Pe)*(qe-Pe)+(pt-Ie)*(pt-Ie));var Xt=[-Ct[1],Ct[0]];O.Fv(Xt,Xt);var Qt=[qe-Pe,pt-Ie];return Math.abs(O.AK(Qt,Xt))}function kt(Pe,Ie,Ke,lt){return Math.atan2(lt-Ie,Ke-Pe)}function Ut(Pe,Ie,Ke,lt,qe){var pt=1-qe;return pt*pt*pt*Pe+3*Ie*qe*pt*pt+3*Ke*qe*qe*pt+lt*qe*qe*qe}function At(Pe,Ie,Ke,lt,qe){var pt=1-qe;return 3*(pt*pt*(Ie-Pe)+2*pt*qe*(Ke-Ie)+qe*qe*(lt-Ke))}function at(Pe,Ie,Ke,lt){var qe=-3*Pe+9*Ie-9*Ke+3*lt,pt=6*Pe-12*Ie+6*Ke,Ct=3*Ie-3*Pe,Xt=[],Qt,pn,Wn;if((0,k.Z)(qe,0))(0,k.Z)(pt,0)||(Qt=-Ct/pt,Qt>=0&&Qt<=1&&Xt.push(Qt));else{var Rn=pt*pt-4*qe*Ct;(0,k.Z)(Rn,0)?Xt.push(-pt/(2*qe)):Rn>0&&(Wn=Math.sqrt(Rn),Qt=(-pt+Wn)/(2*qe),pn=(-pt-Wn)/(2*qe),Qt>=0&&Qt<=1&&Xt.push(Qt),pn>=0&&pn<=1&&Xt.push(pn))}return Xt}function Ot(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){var pn=Ut(Pe,Ke,qe,Ct,Qt),Wn=Ut(Ie,lt,pt,Xt,Qt),Rn=je(Pe,Ie,Ke,lt,Qt),bi=je(Ke,lt,qe,pt,Qt),Lr=je(qe,pt,Ct,Xt,Qt),Qn=je(Rn.x,Rn.y,bi.x,bi.y,Qt),Vi=je(bi.x,bi.y,Lr.x,Lr.y,Qt);return[[Pe,Ie,Rn.x,Rn.y,Qn.x,Qn.y,pn,Wn],[pn,Wn,Vi.x,Vi.y,Lr.x,Lr.y,Ct,Xt]]}function ue(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,Qt){if(Qt===0)return Ye([Pe,Ke,qe,Ct],[Ie,lt,pt,Xt]);var pn=Ot(Pe,Ie,Ke,lt,qe,pt,Ct,Xt,.5),Wn=__spreadArray(__spreadArray([],__read(pn[0]),!1),[Qt-1],!1),Rn=__spreadArray(__spreadArray([],__read(pn[1]),!1),[Qt-1],!1);return ue.apply(void 0,__spreadArray([],__read(Wn),!1))+ue.apply(void 0,__spreadArray([],__read(Rn),!1))}function Ue(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){for(var Qt=[Pe,Ct],pn=[Ie,Xt],Wn=at(Pe,Ke,qe,Ct),Rn=at(Ie,lt,pt,Xt),bi=0;bi1||Ie<0||Pe.length<2)return null;var Ke=ze(Pe),lt=Ke.segments,qe=Ke.totalLength;if(qe===0)return{x:Pe[0][0],y:Pe[0][1]};for(var pt=0,Ct=null,Xt=0;Xt=pt&&Ie<=pt+Rn){var bi=(Ie-pt)/Rn;Ct=je(pn[0],pn[1],Wn[0],Wn[1],bi);break}pt+=Rn}return Ct}function Y(Pe,Ie){if(Ie>1||Ie<0||Pe.length<2)return 0;for(var Ke=ze(Pe),lt=Ke.segments,qe=Ke.totalLength,pt=0,Ct=0,Xt=0;Xt=pt&&Ie<=pt+Rn){Ct=Math.atan2(Wn[1]-pn[1],Wn[0]-pn[0]);break}pt+=Rn}return Ct}function de(Pe,Ie,Ke){for(var lt=1/0,qe=0;qe=0?[qe]:[]}function en(Pe,Ie,Ke,lt,qe,pt,Ct){var Xt=ht(Pe,Ke,qe,Ct),Qt=ht(Ie,lt,pt,Ct),pn=je(Pe,Ie,Ke,lt,Ct),Wn=je(Ke,lt,qe,pt,Ct);return[[Pe,Ie,pn.x,pn.y,Xt,Qt],[Xt,Qt,Wn.x,Wn.y,qe,pt]]}function nn(Pe,Ie,Ke,lt,qe,pt,Ct){if(Ct===0)return(A(Pe,Ie,Ke,lt)+A(Ke,lt,qe,pt)+A(Pe,Ie,qe,pt))/2;var Xt=en(Pe,Ie,Ke,lt,qe,pt,.5),Qt=Xt[0],pn=Xt[1];return Qt.push(Ct-1),pn.push(Ct-1),nn.apply(void 0,__spreadArray([],__read(Qt),!1))+nn.apply(void 0,__spreadArray([],__read(pn),!1))}function Me(Pe,Ie,Ke,lt,qe,pt){var Ct=Yt(Pe,Ke,qe)[0],Xt=Yt(Ie,lt,pt)[0],Qt=[Pe,qe],pn=[Ie,pt];return Ct!==void 0&&Qt.push(ht(Pe,Ke,qe,Ct)),Xt!==void 0&&pn.push(ht(Ie,lt,pt,Xt)),S(Qt,pn)}function te(Pe,Ie,Ke,lt,qe,pt){return nn(Pe,Ie,Ke,lt,qe,pt,3)}function Fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){return be([Pe,Ke,qe],[Ie,lt,pt],Ct,Xt,ht)}function Xe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt){var Qt=Fe(Pe,Ie,Ke,lt,qe,pt,Ct,Xt);return A(Qt.x,Qt.y,Ct,Xt)}},44326:function(ae,ne,b){"use strict";b.d(ne,{k:function(){return A}});var w=b(90494),k=b(69991),O=b(35105);class A extends w.Z{constructor(x){super();aa(this,"nodeMap",new Map);aa(this,"edgeMap",new Map);aa(this,"inEdgesMap",new Map);aa(this,"outEdgesMap",new Map);aa(this,"bothEdgesMap",new Map);aa(this,"treeIndices",new Map);aa(this,"changes",[]);aa(this,"batchCount",0);aa(this,"onChanged",()=>{});aa(this,"batch",x=>{this.batchCount+=1,x(),this.batchCount-=1,this.batchCount||this.commit()});x&&(x.nodes&&this.addNodes(x.nodes),x.edges&&this.addEdges(x.edges),x.tree&&this.addTree(x.tree),x.onChanged&&(this.onChanged=x.onChanged))}commit(){const x=this.changes;this.changes=[];const E={graph:this,changes:x};this.emit("changed",E),this.onChanged(E)}reduceChanges(x){let E=[];return x.forEach(N=>{switch(N.type){case"NodeRemoved":{let L=!1;E=E.filter(P=>{if(P.type==="NodeAdded"){const W=P.value.id===N.value.id;return W&&(L=!0),!W}else{if(P.type==="NodeDataUpdated")return P.id!==N.value.id;if(P.type==="TreeStructureChanged")return P.nodeId!==N.value.id}return!0}),L||E.push(N);break}case"EdgeRemoved":{let L=!1;E=E.filter(P=>{if(P.type==="EdgeAdded"){const W=P.value.id===N.value.id;return W&&(L=!0),!W}else if(P.type==="EdgeDataUpdated"||P.type==="EdgeUpdated")return P.id!==N.value.id;return!0}),L||E.push(N);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const L=E.findIndex(W=>W.type===N.type&&W.id===N.id&&(N.propertyName===void 0||W.propertyName===N.propertyName)),P=E[L];P?N.propertyName!==void 0?P.newValue=N.newValue:(E.splice(L,1),E.push(N)):E.push(N);break}case"TreeStructureDetached":{E=E.filter(L=>L.type==="TreeStructureAttached"||L.type==="TreeStructureChanged"?L.treeKey!==N.treeKey:!0),E.push(N);break}case"TreeStructureChanged":{const L=E.find(P=>P.type==="TreeStructureChanged"&&P.treeKey===N.treeKey&&P.nodeId===N.nodeId);L?L.newParentId=N.newParentId:E.push(N);break}default:E.push(N);break}}),E}checkNodeExistence(x){this.getNode(x)}hasNode(x){return this.nodeMap.has(x)}areNeighbors(x,E){return this.getNeighbors(E).some(N=>N.id===x)}getNode(x){const E=this.nodeMap.get(x);if(!E)throw new Error("Node not found for id: "+x);return E}getRelatedEdges(x,E){if(this.checkNodeExistence(x),E==="in"){const N=this.inEdgesMap.get(x);return Array.from(N)}else if(E==="out"){const N=this.outEdgesMap.get(x);return Array.from(N)}else{const N=this.bothEdgesMap.get(x);return Array.from(N)}}getDegree(x,E){return this.getRelatedEdges(x,E).length}getSuccessors(x){const N=this.getRelatedEdges(x,"out").map(L=>this.getNode(L.target));return Array.from(new Set(N))}getPredecessors(x){const N=this.getRelatedEdges(x,"in").map(L=>this.getNode(L.source));return Array.from(new Set(N))}getNeighbors(x){const E=this.getPredecessors(x),N=this.getSuccessors(x);return Array.from(new Set([...E,...N]))}doAddNode(x){if(this.hasNode(x.id))throw new Error("Node already exists: "+x.id);this.nodeMap.set(x.id,x),this.inEdgesMap.set(x.id,new Set),this.outEdgesMap.set(x.id,new Set),this.bothEdgesMap.set(x.id,new Set),this.treeIndices.forEach(E=>{E.childrenMap.set(x.id,new Set)}),this.changes.push({type:"NodeAdded",value:x})}addNodes(x){this.batch(()=>{for(const E of x)this.doAddNode(E)})}addNode(x){this.addNodes([x])}doRemoveNode(x){const E=this.getNode(x),N=this.bothEdgesMap.get(x);N==null||N.forEach(L=>this.doRemoveEdge(L.id)),this.nodeMap.delete(x),this.treeIndices.forEach(L=>{var W,K;(W=L.childrenMap.get(x))==null||W.forEach(re=>{L.parentMap.delete(re.id)});const P=L.parentMap.get(x);P&&((K=L.childrenMap.get(P.id))==null||K.delete(E)),L.parentMap.delete(x),L.childrenMap.delete(x)}),this.bothEdgesMap.delete(x),this.inEdgesMap.delete(x),this.outEdgesMap.delete(x),this.changes.push({type:"NodeRemoved",value:E})}removeNodes(x){this.batch(()=>{x.forEach(E=>this.doRemoveNode(E))})}removeNode(x){this.removeNodes([x])}updateNodeDataProperty(x,E,N){const L=this.getNode(x);this.batch(()=>{const P=L.data[E],W=N;L.data[E]=W,this.changes.push({type:"NodeDataUpdated",id:x,propertyName:E,oldValue:P,newValue:W})})}mergeNodeData(x,E){this.batch(()=>{Object.entries(E).forEach(([N,L])=>{this.updateNodeDataProperty(x,N,L)})})}updateNodeData(...x){const E=x[0],N=this.getNode(E);if(typeof x[1]=="string"){this.updateNodeDataProperty(E,x[1],x[2]);return}let L;if(typeof x[1]=="function"){const P=x[1];L=P(N.data)}else typeof x[1]=="object"&&(L=x[1]);this.batch(()=>{const P=N.data,W=L;N.data=L,this.changes.push({type:"NodeDataUpdated",id:E,oldValue:P,newValue:W})})}checkEdgeExistence(x){if(!this.hasEdge(x))throw new Error("Edge not found for id: "+x)}hasEdge(x){return this.edgeMap.has(x)}getEdge(x){return this.checkEdgeExistence(x),this.edgeMap.get(x)}getEdgeDetail(x){const E=this.getEdge(x);return{edge:E,source:this.getNode(E.source),target:this.getNode(E.target)}}doAddEdge(x){if(this.hasEdge(x.id))throw new Error("Edge already exists: "+x.id);this.checkNodeExistence(x.source),this.checkNodeExistence(x.target),this.edgeMap.set(x.id,x);const E=this.inEdgesMap.get(x.target),N=this.outEdgesMap.get(x.source),L=this.bothEdgesMap.get(x.source),P=this.bothEdgesMap.get(x.target);E.add(x),N.add(x),L.add(x),P.add(x),this.changes.push({type:"EdgeAdded",value:x})}addEdges(x){this.batch(()=>{for(const E of x)this.doAddEdge(E)})}addEdge(x){this.addEdges([x])}doRemoveEdge(x){const E=this.getEdge(x),N=this.outEdgesMap.get(E.source),L=this.inEdgesMap.get(E.target),P=this.bothEdgesMap.get(E.source),W=this.bothEdgesMap.get(E.target);N.delete(E),L.delete(E),P.delete(E),W.delete(E),this.edgeMap.delete(x),this.changes.push({type:"EdgeRemoved",value:E})}removeEdges(x){this.batch(()=>{x.forEach(E=>this.doRemoveEdge(E))})}removeEdge(x){this.removeEdges([x])}updateEdgeSource(x,E){const N=this.getEdge(x);this.checkNodeExistence(E);const L=N.source,P=E;this.outEdgesMap.get(L).delete(N),this.bothEdgesMap.get(L).delete(N),this.outEdgesMap.get(P).add(N),this.bothEdgesMap.get(P).add(N),N.source=E,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:x,propertyName:"source",oldValue:L,newValue:P})})}updateEdgeTarget(x,E){const N=this.getEdge(x);this.checkNodeExistence(E);const L=N.target,P=E;this.inEdgesMap.get(L).delete(N),this.bothEdgesMap.get(L).delete(N),this.inEdgesMap.get(P).add(N),this.bothEdgesMap.get(P).add(N),N.target=E,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:x,propertyName:"target",oldValue:L,newValue:P})})}updateEdgeDataProperty(x,E,N){const L=this.getEdge(x);this.batch(()=>{const P=L.data[E],W=N;L.data[E]=W,this.changes.push({type:"EdgeDataUpdated",id:x,propertyName:E,oldValue:P,newValue:W})})}updateEdgeData(...x){const E=x[0],N=this.getEdge(E);if(typeof x[1]=="string"){this.updateEdgeDataProperty(E,x[1],x[2]);return}let L;if(typeof x[1]=="function"){const P=x[1];L=P(N.data)}else typeof x[1]=="object"&&(L=x[1]);this.batch(()=>{const P=N.data,W=L;N.data=L,this.changes.push({type:"EdgeDataUpdated",id:E,oldValue:P,newValue:W})})}mergeEdgeData(x,E){this.batch(()=>{Object.entries(E).forEach(([N,L])=>{this.updateEdgeDataProperty(x,N,L)})})}checkTreeExistence(x){if(!this.hasTreeStructure(x))throw new Error("Tree structure not found for treeKey: "+x)}hasTreeStructure(x){return this.treeIndices.has(x)}attachTreeStructure(x){this.treeIndices.has(x)||(this.treeIndices.set(x,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:x})}))}detachTreeStructure(x){this.checkTreeExistence(x),this.treeIndices.delete(x),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:x})})}addTree(x,E){this.batch(()=>{this.attachTreeStructure(E);const N=[],L=Array.isArray(x)?x:[x];for(;L.length;){const P=L.shift();N.push(P),P.children&&L.push(...P.children)}this.addNodes(N),N.forEach(P=>{var W;(W=P.children)==null||W.forEach(K=>{this.setParent(K.id,P.id,E)})})})}getRoots(x){return this.checkTreeExistence(x),this.getAllNodes().filter(E=>!this.getParent(E.id,x))}getChildren(x,E){this.checkNodeExistence(x),this.checkTreeExistence(E);const L=this.treeIndices.get(E).childrenMap.get(x);return Array.from(L||[])}getParent(x,E){return this.checkNodeExistence(x),this.checkTreeExistence(E),this.treeIndices.get(E).parentMap.get(x)||null}getAncestors(x,E){const N=[];let L=this.getNode(x),P;for(;P=this.getParent(L.id,E);)N.push(P),L=P;return N}setParent(x,E,N){var ye,ge;this.checkTreeExistence(N);const L=this.treeIndices.get(N),P=this.getNode(x),W=L.parentMap.get(x);if((W==null?void 0:W.id)===E)return;if(E===void 0){W&&((ye=L.childrenMap.get(W.id))==null||ye.delete(P)),L.parentMap.delete(x);return}const K=this.getNode(E);L.parentMap.set(x,K),W&&((ge=L.childrenMap.get(W.id))==null||ge.delete(P));let re=L.childrenMap.get(K.id);re||(re=new Set,L.childrenMap.set(K.id,re)),re.add(P),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:N,nodeId:x,oldParentId:W==null?void 0:W.id,newParentId:K.id})})}dfsTree(x,E,N){const L=P=>this.getChildren(P,N);return(0,O.I)(this.getNode(x),new Set,E,L)}bfsTree(x,E,N){const L=P=>this.getChildren(P,N);return(0,O.O)([this.getNode(x)],new Set,E,L)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(x,E,N="out"){const L={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[N];return(0,O.O)([this.getNode(x)],new Set,E,L)}dfs(x,E,N="out"){const L={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[N];return(0,O.I)(this.getNode(x),new Set,E,L)}clone(){const x=this.getAllNodes().map(L=>ac(qs({},L),{data:qs({},L.data)})),E=this.getAllEdges().map(L=>ac(qs({},L),{data:qs({},L.data)})),N=new A({nodes:x,edges:E});return this.treeIndices.forEach(({parentMap:L,childrenMap:P},W)=>{const K=new Map;L.forEach((ye,ge)=>{K.set(ge,N.getNode(ye.id))});const re=new Map;P.forEach((ye,ge)=>{re.set(ge,new Set(Array.from(ye).map(ce=>N.getNode(ce.id))))}),N.treeIndices.set(W,{parentMap:K,childrenMap:re})}),N}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(x){return new k.t(qs({graph:this},x))}}},69991:function(ae,ne,b){"use strict";b.d(ne,{t:function(){return O}});var w=b(35105);const k=()=>!0;class O{constructor(S){aa(this,"graph");aa(this,"nodeFilter");aa(this,"edgeFilter");aa(this,"cacheEnabled");aa(this,"inEdgesMap",new Map);aa(this,"outEdgesMap",new Map);aa(this,"bothEdgesMap",new Map);aa(this,"allNodesMap",new Map);aa(this,"allEdgesMap",new Map);aa(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});aa(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(S=>S.id))});aa(this,"updateCache",S=>{const R=new Set;S.forEach(x=>{const E=this.bothEdgesMap.get(x);if(E&&E.forEach(N=>R.add(N.id)),!this.hasNode(x))this.inEdgesMap.delete(x),this.outEdgesMap.delete(x),this.bothEdgesMap.delete(x),this.allNodesMap.delete(x);else{const N=this.graph.getRelatedEdges(x,"in").filter(this.edgeFilter),L=this.graph.getRelatedEdges(x,"out").filter(this.edgeFilter),P=Array.from(new Set([...N,...L]));P.forEach(W=>R.add(W.id)),this.inEdgesMap.set(x,N),this.outEdgesMap.set(x,L),this.bothEdgesMap.set(x,P),this.allNodesMap.set(x,this.graph.getNode(x))}}),R.forEach(x=>{this.hasEdge(x)?this.allEdgesMap.set(x,this.graph.getEdge(x)):this.allEdgesMap.delete(x)})});aa(this,"handleGraphChanged",S=>{const R=new Set;S.changes.forEach(x=>{switch(x.type){case"NodeAdded":R.add(x.value.id);break;case"NodeDataUpdated":R.add(x.id);break;case"EdgeAdded":R.add(x.value.source),R.add(x.value.target);break;case"EdgeUpdated":(x.propertyName==="source"||x.propertyName==="target")&&(R.add(x.oldValue),R.add(x.newValue));break;case"EdgeDataUpdated":if(S.graph.hasEdge(x.id)){const E=S.graph.getEdge(x.id);R.add(E.source),R.add(E.target)}break;case"EdgeRemoved":R.add(x.value.source),R.add(x.value.target);break;case"NodeRemoved":R.add(x.value.id);break;default:break}}),this.updateCache(R)});this.graph=S.graph;const R=S.nodeFilter||k,x=S.edgeFilter||k;this.nodeFilter=R,this.edgeFilter=E=>{const{source:N,target:L}=this.graph.getEdgeDetail(E.id);return!R(N)||!R(L)?!1:x(E,N,L)},S.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):S.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(S){this.getNode(S)}hasNode(S){if(!this.graph.hasNode(S))return!1;const R=this.graph.getNode(S);return this.nodeFilter(R)}areNeighbors(S,R){return this.checkNodeExistence(S),this.getNeighbors(R).some(x=>x.id===S)}getNode(S){const R=this.graph.getNode(S);if(!this.nodeFilter(R))throw new Error("Node not found for id: "+S);return R}getRelatedEdges(S,R){return this.checkNodeExistence(S),this.cacheEnabled?R==="in"?this.inEdgesMap.get(S):R==="out"?this.outEdgesMap.get(S):this.bothEdgesMap.get(S):this.graph.getRelatedEdges(S,R).filter(this.edgeFilter)}getDegree(S,R){return this.getRelatedEdges(S,R).length}getSuccessors(S){const x=this.getRelatedEdges(S,"out").map(E=>this.getNode(E.target));return Array.from(new Set(x))}getPredecessors(S){const x=this.getRelatedEdges(S,"in").map(E=>this.getNode(E.source));return Array.from(new Set(x))}getNeighbors(S){const R=this.getPredecessors(S),x=this.getSuccessors(S);return Array.from(new Set([...R,...x]))}hasEdge(S){if(!this.graph.hasEdge(S))return!1;const R=this.graph.getEdge(S);return this.edgeFilter(R)}getEdge(S){const R=this.graph.getEdge(S);if(!this.edgeFilter(R))throw new Error("Edge not found for id: "+S);return R}getEdgeDetail(S){const R=this.getEdge(S);return{edge:R,source:this.getNode(R.source),target:this.getNode(R.target)}}hasTreeStructure(S){return this.graph.hasTreeStructure(S)}getRoots(S){return this.graph.getRoots(S).filter(this.nodeFilter)}getChildren(S,R){return this.checkNodeExistence(S),this.graph.getChildren(S,R).filter(this.nodeFilter)}getParent(S,R){this.checkNodeExistence(S);const x=this.graph.getParent(S,R);return!x||!this.nodeFilter(x)?null:x}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(S,R,x="out"){const E={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[x];(0,w.O)([this.getNode(S)],new Set,R,E)}dfs(S,R,x="out"){const E={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[x];(0,w.I)(this.getNode(S),new Set,R,E)}}},35105:function(ae,ne,b){"use strict";b.d(ne,{I:function(){return k},O:function(){return w}});function w(O,A,S,R){for(;O.length;){const x=O.shift();if(S(x))return!0;A.add(x.id),R(x.id).forEach(N=>{A.has(N.id)||(A.add(N.id),O.push(N))})}return!1}function k(O,A,S,R){if(S(O))return!0;A.add(O.id);for(const E of R(O.id))if(!A.has(E.id)&&k(E,A,S,R))return!0;return!1}},81746:function(ae){(function(b,w){ae.exports=w()})(typeof self!="undefined"?self:this,function(){return function(ne){var b={};function w(k){if(b[k])return b[k].exports;var O=b[k]={i:k,l:!1,exports:{}};return ne[k].call(O.exports,O,O.exports,w),O.l=!0,O.exports}return w.m=ne,w.c=b,w.d=function(k,O,A){w.o(k,O)||Object.defineProperty(k,O,{configurable:!1,enumerable:!0,get:A})},w.n=function(k){var O=k&&k.__esModule?function(){return k.default}:function(){return k};return w.d(O,"a",O),O},w.o=function(k,O){return Object.prototype.hasOwnProperty.call(k,O)},w.p="",w(w.s=5)}([function(ne,b){function w(k,O,A,S){return S===void 0&&(S="height"),A==="center"?(k[S]+O[S])/2:k.height}ne.exports={assign:Object.assign,getHeight:w}},function(ne,b,w){var k=w(3),O=function(){function A(R,x){x===void 0&&(x={});var E=this;E.options=x,E.rootNode=k(R,x)}var S=A.prototype;return S.execute=function(){throw new Error("please override this method")},A}();ne.exports=O},function(ne,b,w){var k=w(4),O=["LR","RL","TB","BT","H","V"],A=["LR","RL","H"],S=function(N){return A.indexOf(N)>-1},R=O[0];ne.exports=function(E,N,L){var P=N.direction||R;if(N.isHorizontal=S(P),P&&O.indexOf(P)===-1)throw new TypeError("Invalid direction: "+P);if(P===O[0])L(E,N);else if(P===O[1])L(E,N),E.right2left();else if(P===O[2])L(E,N);else if(P===O[3])L(E,N),E.bottom2top();else if(P===O[4]||P===O[5]){var W=k(E,N),K=W.left,re=W.right;L(K,N),L(re,N),N.isHorizontal?K.right2left():K.bottom2top(),re.translate(K.x-re.x,K.y-re.y),E.x=K.x,E.y=re.y;var ye=E.getBoundingBox();N.isHorizontal?ye.top<0&&E.translate(0,-ye.top):ye.left<0&&E.translate(-ye.left,0)}var ge=N.fixedRoot;return ge===void 0&&(ge=!0),ge&&E.translate(-(E.x+E.width/2+E.hgap),-(E.y+E.height/2+E.vgap)),x(E,N),E};function x(E,N){if(N.radial){var L=N.isHorizontal?["x","y"]:["y","x"],P=L[0],W=L[1],K={x:1/0,y:1/0},re={x:-1/0,y:-1/0},ye=0;E.DFTraverse(function(xe){ye++;var fe=xe.x,Ne=xe.y;K.x=Math.min(K.x,fe),K.y=Math.min(K.y,Ne),re.x=Math.max(re.x,fe),re.y=Math.max(re.y,Ne)});var ge=re[W]-K[W];if(ge===0)return;var ce=Math.PI*2/ye;E.DFTraverse(function(xe){var fe=(xe[W]-K[W])/ge*(Math.PI*2-ce)+ce,Ne=xe[P]-E[P];xe.x=Math.cos(fe)*Ne,xe.y=Math.sin(fe)*Ne})}}},function(ne,b,w){var k=w(0),O=18,A=O*2,S=O,R={getId:function(L){return L.id||L.name},getPreH:function(L){return L.preH||0},getPreV:function(L){return L.preV||0},getHGap:function(L){return L.hgap||S},getVGap:function(L){return L.vgap||S},getChildren:function(L){return L.children},getHeight:function(L){return L.height||A},getWidth:function(L){var P=L.label||" ";return L.width||P.split("").length*O}};function x(N,L){var P=this;if(P.vgap=P.hgap=0,N instanceof x)return N;P.data=N;var W=L.getHGap(N),K=L.getVGap(N);return P.preH=L.getPreH(N),P.preV=L.getPreV(N),P.width=L.getWidth(N),P.height=L.getHeight(N),P.width+=P.preH,P.height+=P.preV,P.id=L.getId(N),P.x=P.y=0,P.depth=0,P.children||(P.children=[]),P.addGap(W,K),P}k.assign(x.prototype,{isRoot:function(){return this.depth===0},isLeaf:function(){return this.children.length===0},addGap:function(L,P){var W=this;W.hgap+=L,W.vgap+=P,W.width+=2*L,W.height+=2*P},eachNode:function(L){for(var P=this,W=[P],K;K=W.shift();)L(K),W=K.children.concat(W)},DFTraverse:function(L){this.eachNode(L)},BFTraverse:function(L){for(var P=this,W=[P],K;K=W.shift();)L(K),W=W.concat(K.children)},getBoundingBox:function(){var L={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(function(P){L.left=Math.min(L.left,P.x),L.top=Math.min(L.top,P.y),L.width=Math.max(L.width,P.x+P.width),L.height=Math.max(L.height,P.y+P.height)}),L},translate:function(L,P){L===void 0&&(L=0),P===void 0&&(P=0),this.eachNode(function(W){W.x+=L,W.y+=P,W.x+=W.preH,W.y+=W.preV})},right2left:function(){var L=this,P=L.getBoundingBox();L.eachNode(function(W){W.x=W.x-(W.x-P.left)*2-W.width}),L.translate(P.width,0)},bottom2top:function(){var L=this,P=L.getBoundingBox();L.eachNode(function(W){W.y=W.y-(W.y-P.top)*2-W.height}),L.translate(0,P.height)}});function E(N,L,P){L===void 0&&(L={}),L=k.assign({},R,L);var W=new x(N,L),K=[W],re;if(!P&&!N.collapsed){for(;re=K.shift();)if(!re.data.collapsed){var ye=L.getChildren(re.data),ge=ye?ye.length:0;if(re.children=new Array(ge),ye&&ge)for(var ce=0;ce_t.low&&(_t=_t.nxt);var at=kt+It.prelim+It.w-(At+Ut.prelim);at>0&&(At+=at,K(We,je,_t.index,at));var Ot=ge(It),ue=ge(Ut);Ot<=ue&&(It=ye(It),It!==null&&(kt+=It.mod)),Ot>=ue&&(Ut=re(Ut),Ut!==null&&(At+=Ut.mod))}!It&&Ut?ce(We,je,Ut,At):It&&!Ut&&xe(We,je,It,kt)}function K(We,je,_t,It){We.c[je].mod+=It,We.c[je].msel+=It,We.c[je].mser+=It,Ae(We,je,_t,It)}function re(We){return We.cs===0?We.tl:We.c[0]}function ye(We){return We.cs===0?We.tr:We.c[We.cs-1]}function ge(We){return We.y+We.h}function ce(We,je,_t,It){var kt=We.c[0].el;kt.tl=_t;var Ut=It-_t.mod-We.c[0].msel;kt.mod+=Ut,kt.prelim-=Ut,We.c[0].el=We.c[je].el,We.c[0].msel=We.c[je].msel}function xe(We,je,_t,It){var kt=We.c[je].er;kt.tr=_t;var Ut=It-_t.mod-We.c[je].mser;kt.mod+=Ut,kt.prelim-=Ut,We.c[je].er=We.c[je-1].er,We.c[je].mser=We.c[je-1].mser}function fe(We){We.prelim=(We.c[0].prelim+We.c[0].mod+We.c[We.cs-1].mod+We.c[We.cs-1].prelim+We.c[We.cs-1].w)/2-We.w/2}function Ne(We,je){je+=We.mod,We.x=We.prelim+je,be(We);for(var _t=0;_t=_t.low;)_t=_t.nxt;return{low:We,index:je,nxt:_t}}R(x,N);var Ee=w.fromNode(x,N);return L(Ee),Ne(Ee,0),S(Ee,x,N),A(x,N),x}},function(ne,b,w){function k(P,W){P.prototype=Object.create(W.prototype),P.prototype.constructor=P,O(P,W)}function O(P,W){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(K,re){return K.__proto__=re,K},O(P,W)}var A=w(1),S=w(9),R=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var K=W.prototype;return K.execute=function(){var ye=this;return ye.rootNode.width=0,R(ye.rootNode,ye.options,S)},W}(A),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ne.exports=L},function(ne,b,w){var k=w(0);function O(R,x){R===void 0&&(R=0),x===void 0&&(x=[]);var E=this;E.x=E.y=0,E.leftChild=E.rightChild=null,E.height=0,E.children=x}var A={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function S(R,x,E){E?(x.x=R.x,x.y=R.y):(x.x=R.y,x.y=R.x),R.children.forEach(function(N,L){S(N,x.children[L],E)})}ne.exports=function(R,x){x===void 0&&(x={}),x=k.assign({},A,x);var E=0;function N(re){if(!re)return null;re.width=0,re.depth&&re.depth>E&&(E=re.depth);var ye=re.children,ge=ye.length,ce=new O(re.height,[]);return ye.forEach(function(xe,fe){var Ne=N(xe);ce.children.push(Ne),fe===0&&(ce.leftChild=Ne),fe===ge-1&&(ce.rightChild=Ne)}),ce.originNode=re,ce.isLeaf=re.isLeaf(),ce}function L(re){if(re.isLeaf||re.children.length===0)re.drawingDepth=E;else{var ye=re.children.map(function(ce){return L(ce)}),ge=Math.min.apply(null,ye);re.drawingDepth=ge-1}return re.drawingDepth}var P;function W(re){re.x=re.drawingDepth*x.rankSep,re.isLeaf?(re.y=0,P&&(re.y=P.y+P.height+x.nodeSep,re.originNode.parent!==P.originNode.parent&&(re.y+=x.subTreeSep)),P=re):(re.children.forEach(function(ye){W(ye)}),re.y=(re.leftChild.y+re.rightChild.y)/2)}var K=N(R);return L(K),W(K),S(K,R,x.isHorizontal),R}},function(ne,b,w){function k(K,re){K.prototype=Object.create(re.prototype),K.prototype.constructor=K,O(K,re)}function O(K,re){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ye,ge){return ye.__proto__=ge,ye},O(K,re)}var A=w(1),S=w(11),R=w(4),x=w(0),E=["LR","RL","H"],N=E[0],L=function(K){function re(){return K.apply(this,arguments)||this}k(re,K);var ye=re.prototype;return ye.execute=function(){var ce=this,xe=ce.options,fe=ce.rootNode;xe.isHorizontal=!0;var Ne=xe.indent,Ae=Ne===void 0?20:Ne,be=xe.dropCap,Ye=be===void 0?!0:be,Ee=xe.direction,We=Ee===void 0?N:Ee,je=xe.align;if(We&&E.indexOf(We)===-1)throw new TypeError("Invalid direction: "+We);if(We===E[0])S(fe,Ae,Ye,je);else if(We===E[1])S(fe,Ae,Ye,je),fe.right2left();else if(We===E[2]){var _t=R(fe,xe),It=_t.left,kt=_t.right;S(It,Ae,Ye,je),It.right2left(),S(kt,Ae,Ye,je);var Ut=It.getBoundingBox();kt.translate(Ut.width,0),fe.x=kt.x-fe.width/2}return fe},re}(A),P={};function W(K,re){return re=x.assign({},P,re),new L(K,re).execute()}ne.exports=W},function(ne,b,w){var k=w(0);function O(A,S,R,x,E){var N=(typeof R=="function"?R(A):R)*A.depth;if(!x)try{if(A.id===A.parent.children[0].id){A.x+=N,A.y=S?S.y:0;return}}catch(W){}if(A.x+=N,S){if(A.y=S.y+k.getHeight(S,A,E),S.parent&&A.parent.id!==S.parent.id){var L=S.parent,P=L.y+k.getHeight(L,A,E);A.y=P>A.y?P:A.y}}else A.y=0}ne.exports=function(A,S,R,x){var E=null;A.eachNode(function(N){O(N,E,S,R,x),E=N})}},function(ne,b,w){function k(P,W){P.prototype=Object.create(W.prototype),P.prototype.constructor=P,O(P,W)}function O(P,W){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(K,re){return K.__proto__=re,K},O(P,W)}var A=w(1),S=w(13),R=w(2),x=w(0),E=function(P){function W(){return P.apply(this,arguments)||this}k(W,P);var K=W.prototype;return K.execute=function(){var ye=this;return R(ye.rootNode,ye.options,S)},W}(A),N={};function L(P,W){return W=x.assign({},N,W),new E(P,W).execute()}ne.exports=L},function(ne,b,w){var k=w(0);function O(R,x){var E=0;return R.children.length?R.children.forEach(function(N){E+=O(N,x)}):E=R.height,R._subTreeSep=x.getSubTreeSep(R.data),R.totalHeight=Math.max(R.height,E)+2*R._subTreeSep,R.totalHeight}function A(R){var x=R.children,E=x.length;if(E){x.forEach(function(re){A(re)});var N=x[0],L=x[E-1],P=L.y-N.y+L.height,W=0;if(x.forEach(function(re){W+=re.totalHeight}),P>R.height)R.y=N.y+P/2-R.height/2;else if(x.length!==1||R.height>W){var K=R.y+(R.height-P)/2-N.y;x.forEach(function(re){re.translate(0,K)})}else R.y=(N.y+N.height/2+L.y+L.height/2)/2-R.height/2}}var S={getSubTreeSep:function(){return 0}};ne.exports=function(R,x){x===void 0&&(x={}),x=k.assign({},S,x),R.parent={x:0,width:0,height:0,y:0},R.BFTraverse(function(E){E.x=E.parent.x+E.parent.width}),R.parent=null,O(R,x),R.startY=0,R.y=R.totalHeight/2-R.height/2,R.eachNode(function(E){var N=E.children,L=N.length;if(L){var P=N[0];if(P.startY=E.startY+E._subTreeSep,L===1)P.y=E.y+E.height/2-P.height/2;else{P.y=P.startY+P.totalHeight/2-P.height/2;for(var W=1;W`${fe}`:typeof xe=="object"?fe=>JSON.stringify(fe):fe=>fe}class P extends R.X{getDefaultOptions(){return{domain:[],range:[],unknown:x}}constructor(fe){super(fe)}map(fe){return this.domainIndexMap.size===0&&E(this.domainIndexMap,this.getDomain(),this.domainKey),N({value:this.domainKey(fe),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(fe){return this.rangeIndexMap.size===0&&E(this.rangeIndexMap,this.getRange(),this.rangeKey),N({value:this.rangeKey(fe),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(fe){const[Ne]=this.options.domain,[Ae]=this.options.range;if(this.domainKey=L(Ne),this.rangeKey=L(Ae),!this.rangeIndexMap){this.rangeIndexMap=new Map,this.domainIndexMap=new Map;return}(!fe||fe.range)&&this.rangeIndexMap.clear(),(!fe||fe.domain||fe.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new P(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:fe,compare:Ne}=this.options;return this.sortedDomain=Ne?[...fe].sort(Ne):fe,this.sortedDomain}}function W(xe){const fe=Math.min(...xe);return xe.map(Ne=>Ne/fe)}function K(xe,fe){const Ne=xe.length,Ae=fe-Ne;return Ae>0?[...xe,...new Array(Ae).fill(1)]:Ae<0?xe.slice(0,fe):xe}function re(xe){return Math.round(xe*1e12)/1e12}function ye(xe){const{domain:fe,range:Ne,paddingOuter:Ae,paddingInner:be,flex:Ye,round:Ee,align:We}=xe,je=fe.length,_t=K(Ye,je),[It,kt]=Ne,Ut=kt-It,At=2/je*Ae+1-1/je*be,at=Ut/At,Ot=at*be/je,ue=at-je*Ot,Ue=W(_t),vt=Ue.reduce((Je,Te)=>Je+Te),Jt=ue/vt,Qe=new S(fe.map((Je,Te)=>{const $e=Ue[Te]*Jt;return[Je,Ee?Math.floor($e):$e]})),rt=new S(fe.map((Je,Te)=>{const xt=Ue[Te]*Jt+Ot;return[Je,Ee?Math.floor(xt):xt]})),bt=Array.from(rt.values()).reduce((Je,Te)=>Je+Te),Ze=(Ut-(bt-bt/je*be))*We,q=It+Ze;let Y=Ee?Math.round(q):q;const de=new Array(je);for(let Je=0;JeUt+Jt*It);return{valueStep:It,valueBandWidth:kt,adjustedRange:Ue}}class ce extends P{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:x,flex:[]}}constructor(fe){super(fe)}clone(){return new ce(this.options)}getStep(fe){return this.valueStep===void 0?1:typeof this.valueStep=="number"?this.valueStep:fe===void 0?Array.from(this.valueStep.values())[0]:this.valueStep.get(fe)}getBandWidth(fe){return this.valueBandWidth===void 0?1:typeof this.valueBandWidth=="number"?this.valueBandWidth:fe===void 0?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(fe)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:fe,paddingInner:Ne}=this.options;return fe>0?fe:Ne}getPaddingOuter(){const{padding:fe,paddingOuter:Ne}=this.options;return fe>0?fe:Ne}rescale(){super.rescale();const{align:fe,domain:Ne,range:Ae,round:be,flex:Ye}=this.options,{adjustedRange:Ee,valueBandWidth:We,valueStep:je}=ge({align:fe,range:Ae,round:be,flex:Ye,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:Ne});this.valueStep=je,this.valueBandWidth=We,this.adjustedRange=Ee}}},74271:function(ae,ne,b){"use strict";b.d(ne,{X:function(){return k}});var w=b(83787);class k{constructor(A){this.options=(0,w.Z)({},this.getDefaultOptions()),this.update(A)}getOptions(){return this.options}update(A={}){this.options=(0,w.Z)({},this.options,A),this.rescale(A)}rescale(A){}}},53715:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return Ut}});var w=function(At){return At},k=b(74271);function O(At,at){return at-At?Ot=>(Ot-At)/(at-At):Ot=>.5}function A(At,...at){return at.reduce((Ot,ue)=>Ue=>Ot(ue(Ue)),At)}function S(At,at,Ot,ue,Ue){let vt=Ot||0,Jt=ue||At.length;const Qe=Ue||(rt=>rt);for(;vtat?Jt=rt:vt=rt+1}return vt}var R=b(19818),x=b.n(R);function E(At,at,Ot){let ue=Ot;return ue<0&&(ue+=1),ue>1&&(ue-=1),ue<1/6?At+(at-At)*6*ue:ue<1/2?at:ue<2/3?At+(at-At)*(2/3-ue)*6:At}function N(At){const at=At[0]/360,Ot=At[1]/100,ue=At[2]/100,Ue=At[3];if(Ot===0)return[ue*255,ue*255,ue*255,Ue];const vt=ue<.5?ue*(1+Ot):ue+Ot-ue*Ot,Jt=2*ue-vt,Qe=E(Jt,vt,at+1/3),rt=E(Jt,vt,at),bt=E(Jt,vt,at-1/3);return[Qe*255,rt*255,bt*255,Ue]}function L(At){const at=x().get(At);if(!at)return null;const{model:Ot,value:ue}=at;return Ot==="rgb"?ue:Ot==="hsl"?N(ue):null}const P=(At,at)=>Ot=>At*(1-Ot)+at*Ot,W=(At,at)=>{const Ot=L(At),ue=L(at);return Ot===null||ue===null?Ot?()=>At:()=>at:Ue=>{const vt=new Array(4);for(let ze=0;ze<4;ze+=1){const Ze=Ot[ze],q=ue[ze];vt[ze]=Ze*(1-Ue)+q*Ue}const[Jt,Qe,rt,bt]=vt;return`rgba(${Math.round(Jt)}, ${Math.round(Qe)}, ${Math.round(rt)}, ${bt})`}},K=(At,at)=>typeof At=="number"&&typeof at=="number"?P(At,at):typeof At=="string"&&typeof at=="string"?W(At,at):()=>At,re=(At,at)=>{const Ot=P(At,at);return ue=>Math.round(Ot(ue))};var ye=b(71154);function ge(At){return At===null}function ce(At){return!(0,ye.Z)(At)&&!ge(At)&&!Number.isNaN(At)}const xe=Math.sqrt(50),fe=Math.sqrt(10),Ne=Math.sqrt(2);function Ae(At,at,Ot){const ue=(at-At)/Math.max(0,Ot),Ue=Math.floor(Math.log(ue)/Math.LN10),vt=ue/Kf(10,Ue);return Ue>=0?(vt>=xe?10:vt>=fe?5:vt>=Ne?2:1)*Kf(10,Ue):-Kf(10,-Ue)/(vt>=xe?10:vt>=fe?5:vt>=Ne?2:1)}function be(At,at,Ot){const ue=Math.abs(at-At)/Math.max(0,Ot);let Ue=Kf(10,Math.floor(Math.log(ue)/Math.LN10));const vt=ue/Ue;return vt>=xe?Ue*=10:vt>=fe?Ue*=5:vt>=Ne&&(Ue*=2),at{const ue=[At,at];let Ue=0,vt=ue.length-1,Jt=ue[Ue],Qe=ue[vt],rt;return Qe0?(Jt=Math.floor(Jt/rt)*rt,Qe=Math.ceil(Qe/rt)*rt,rt=Ae(Jt,Qe,Ot)):rt<0&&(Jt=Math.ceil(Jt*rt)/rt,Qe=Math.floor(Qe*rt)/rt,rt=Ae(Jt,Qe,Ot)),rt>0?(ue[Ue]=Math.floor(Jt/rt)*rt,ue[vt]=Math.ceil(Qe/rt)*rt):rt<0&&(ue[Ue]=Math.ceil(Jt*rt)/rt,ue[vt]=Math.floor(Qe*rt)/rt),ue};function Ee(At,at){const Ot=atat?At:at;return Ue=>Math.min(Math.max(Ot,Ue),ue)}const We=(At,at,Ot)=>{const[ue,Ue]=At,[vt,Jt]=at;let Qe,rt;return ue{const ue=Math.min(At.length,at.length)-1,Ue=new Array(ue),vt=new Array(ue),Jt=At[0]>At[ue],Qe=Jt?[...At].reverse():At,rt=Jt?[...at].reverse():at;for(let bt=0;bt{const ze=S(At,bt,1,ue)-1,Ze=Ue[ze],q=vt[ze];return A(q,Ze)(bt)}},_t=(At,at,Ot,ue)=>(Math.min(At.length,at.length)>2?je:We)(At,at,ue?re:Ot);class It extends k.X{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:P,tickCount:5}}map(at){return ce(at)?this.output(at):this.options.unknown}invert(at){return ce(at)?this.input(at):this.options.unknown}nice(){if(!this.options.nice)return;const[at,Ot,ue,...Ue]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(at,Ot,ue,...Ue)}getTicks(){const{tickMethod:at}=this.options,[Ot,ue,Ue,...vt]=this.getTickMethodOptions();return at(Ot,ue,Ue,...vt)}getTickMethodOptions(){const{domain:at,tickCount:Ot}=this.options,ue=at[0],Ue=at[at.length-1];return[ue,Ue,Ot]}chooseNice(){return Ye}rescale(){this.nice();const[at,Ot]=this.chooseTransforms();this.composeOutput(at,this.chooseClamp(at)),this.composeInput(at,Ot,this.chooseClamp(Ot))}chooseClamp(at){const{clamp:Ot,range:ue}=this.options,Ue=this.options.domain.map(at),vt=Math.min(Ue.length,ue.length);return Ot?Ee(Ue[0],Ue[vt-1]):w}composeOutput(at,Ot){const{domain:ue,range:Ue,round:vt,interpolate:Jt}=this.options,Qe=_t(ue.map(at),Ue,Jt,vt);this.output=A(Qe,Ot,at)}composeInput(at,Ot,ue){const{domain:Ue,range:vt}=this.options,Jt=_t(vt,Ue.map(at),P);this.input=A(Ot,ue,Jt)}}const kt=(At,at,Ot)=>{let ue,Ue,vt=At,Jt=at;if(vt===Jt&&Ot>0)return[vt];let Qe=Ae(vt,Jt,Ot);if(Qe===0||!Number.isFinite(Qe))return[];if(Qe>0){vt=Math.ceil(vt/Qe),Jt=Math.floor(Jt/Qe),Ue=new Array(ue=Math.ceil(Jt-vt+1));for(let rt=0;rtO?O:w};ne.Z=b},83207:function(ae,ne,b){"use strict";var w=b(44978),k=function(O){if(typeof O!="object"||O===null)return O;var A;if((0,w.Z)(O)){A=[];for(var S=0,R=O.length;S-1:!1},S=A,R=function(E,N){return N===void 0&&(N=[]),O(E,function(L){return!S(N,L)})},x=R},15255:function(ae,ne,b){"use strict";var w=b(44978),k=b(4637);function O(A,S){if(A){var R;if((0,w.Z)(A))for(var x=0,E=A.length;xR&&(S=E,R=N)}return S}}},13882:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k){if(!Array.isArray(k))return-1/0;var O=k.length;if(!O)return-1/0;for(var A=k[0],S=1;SE&&(x=R,L(1),++S),R[P]=W}function L(P){S=0,R=Object.create(null),P||(x=Object.create(null))}return L(),{clear:L,has:function(P){return R[P]!==void 0||x[P]!==void 0},get:function(P){var W=R[P];if(W!==void 0)return W;if((W=x[P])!==void 0)return N(P,W),W},set:function(P,W){R[P]!==void 0?R[P]=W:N(P,W)}}}var k=new Map;function O(A,S,R){R===void 0&&(R=128);var x=function(){for(var E=[],N=0;Nw?(O&&(clearTimeout(O),O=null),x=L,R=b.apply(A,S),O||(A=S=null)):!O&&k.trailing!==!1&&(O=setTimeout(E,P)),R};return N.cancel=function(){clearTimeout(O),x=0,O=A=S=null},N}},92123:function(ae,ne,b){"use strict";var w=b(95147);ne.Z=function(k){return(0,w.Z)(k)?"":k.toString()}},58029:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O){O===void 0&&(O=new Map);var A=[];if(Array.isArray(k))for(var S=0,R=k.length;S7){K[ye].shift();for(var ge=K[ye],ce=ye;ge.length;)re[ye]="A",K.splice(ce+=1,0,["C"].concat(ge.splice(0,6)));K.splice(ye,1)}}var A=b(4848),S=b(11013);function R(K){return(0,S.y)(K)&&K.every(function(re){var ye=re[0];return"MC".includes(ye)})}var x=b(74873);function E(K,re,ye,ge,ce,xe){var fe=.3333333333333333,Ne=2/3;return[fe*K+Ne*ye,fe*re+Ne*ge,fe*ce+Ne*ye,fe*xe+Ne*ge,ce,xe]}var N=b(17570),L=function(K,re,ye,ge){var ce=.5,xe=(0,N.k)([K,re],[ye,ge],ce);return(0,w.ev)((0,w.ev)([],xe,!0),[ye,ge,ye,ge],!1)};function P(K,re){var ye=K[0],ge=K.slice(1).map(Number),ce=ge[0],xe=ge[1],fe,Ne=re.x1,Ae=re.y1,be=re.x,Ye=re.y;switch("TQ".includes(ye)||(re.qx=null,re.qy=null),ye){case"M":return re.x=ce,re.y=xe,K;case"A":return fe=[Ne,Ae].concat(ge),["C"].concat((0,x.W)(fe[0],fe[1],fe[2],fe[3],fe[4],fe[5],fe[6],fe[7],fe[8],fe[9]));case"Q":return re.qx=ce,re.qy=xe,fe=[Ne,Ae].concat(ge),["C"].concat(E(fe[0],fe[1],fe[2],fe[3],fe[4],fe[5]));case"L":return["C"].concat(L(Ne,Ae,ce,xe));case"Z":return Ne===be&&Ae===Ye?["C",Ne,Ae,be,Ye,be,Ye]:["C"].concat(L(Ne,Ae,be,Ye));default:}return K}function W(K,re){if(re===void 0&&(re=!1),R(K)){var ye=[].concat(K);return re?[ye,[]]:ye}for(var ge=(0,A.A)(K),ce=(0,w.pi)({},k.z),xe=[],fe="",Ne=ge.length,Ae,be,Ye=[],Ee=0;Ee1&&(kt=Math.sqrt(kt),ye*=kt,ge*=kt);var Ut=ye*ye,At=ge*ge,at=(E===N?-1:1)*Math.sqrt(Math.abs((Ut*At-Ut*It*It-At*_t*_t)/(Ut*It*It+At*_t*_t)));We=at*ye*It/ge+(K+ce)/2,je=at*-ge*_t/ye+(re+xe)/2,Ye=Math.asin(((re-je)/ge*Math.pow(10,9)>>0)/Math.pow(10,9)),Ee=Math.asin(((xe-je)/ge*Math.pow(10,9)>>0)/Math.pow(10,9)),Ye=KEe&&(Ye-=Math.PI*2),!N&&Ee>Ye&&(Ee-=Math.PI*2)}var Ot=Ee-Ye;if(Math.abs(Ot)>fe){var ue=Ee,Ue=ce,vt=xe;Ee=Ye+fe*(N&&Ee>Ye?1:-1),ce=We+ye*Math.cos(Ee),xe=je+ge*Math.sin(Ee),Ae=k(ce,xe,ye,ge,x,0,N,Ue,vt,[Ee,ue,We,je])}Ot=Ee-Ye;var Jt=Math.cos(Ye),Qe=Math.sin(Ye),rt=Math.cos(Ee),bt=Math.sin(Ee),ze=Math.tan(Ot/4),Ze=4/3*ye*ze,q=4/3*ge*ze,Y=[K,re],de=[K+Ze*Qe,re-q*Jt],Je=[ce+Ze*bt,xe-q*rt],Te=[ce,xe];if(de[0]=2*Y[0]-de[0],de[1]=2*Y[1]-de[1],W)return de.concat(Je,Te,Ae);Ae=de.concat(Je,Te,Ae);for(var $e=[],xt=0,ke=Ae.length;xt=R.R[Ee]&&(Ee==="m"&&We.length>2?(be.segments.push([Ye].concat(We.splice(0,2))),Ee="l",Ye=Ye==="m"?"l":"L"):be.segments.push([Ye].concat(We.splice(0,R.R[Ee]))),!!R.R[Ee]););}function E(be){var Ye=be.index,Ee=be.pathValue,We=Ee.charCodeAt(Ye);if(We===48){be.param=0,be.index+=1;return}if(We===49){be.param=1,be.index+=1;return}be.err='[path-util]: invalid Arc flag "'.concat(Ee[Ye],'", expecting 0 or 1 at index ').concat(Ye)}function N(be){return be>=48&&be<=57||be===43||be===45||be===46}function L(be){return be>=48&&be<=57}function P(be){var Ye=be.max,Ee=be.pathValue,We=be.index,je=We,_t=!1,It=!1,kt=!1,Ut=!1,At;if(je>=Ye){be.err="[path-util]: Invalid path value at index ".concat(je,', "pathValue" is missing param');return}if(At=Ee.charCodeAt(je),(At===43||At===45)&&(je+=1,At=Ee.charCodeAt(je)),!L(At)&&At!==46){be.err="[path-util]: Invalid path value at index ".concat(je,', "').concat(Ee[je],'" is not a number');return}if(At!==46){if(_t=At===48,je+=1,At=Ee.charCodeAt(je),_t&&je=5760&&Ye.includes(be)}function K(be){for(var Ye=be.pathValue,Ee=be.max;be.index0;It-=1){if(ye(je)&&(It===3||It===4)?E(be):P(be),be.err.length)return;be.data.push(be.param),K(be),be.index=be.max||!N(Ee.charCodeAt(be.index)))break}x(be)}var ce=function(){function be(Ye){this.pathValue=Ye,this.segments=[],this.max=Ye.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}return be}();function xe(be){if((0,S.n)(be))return[].concat(be);var Ye=new ce(be);for(K(Ye);Ye.index=xe[Ye],fe[Ye]-=Ne?1:0,Ne?Ee.ss:[Ee.s]}).flat()});return Ae[0].length===Ae[1].length?Ae:S(Ae[0],Ae[1],ce)}},92455:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return A}});var w=b(75839);function k(S,R,x,E,N,L,P,W){return 3*((W-R)*(x+N)-(P-S)*(E+L)+E*(S-N)-x*(R-L)+W*(N+S/3)-P*(L+R/3))/20}function O(S){var R=0,x=0,E=0;return(0,w.Y)(S).map(function(N){var L;switch(N[0]){case"M":return R=N[1],x=N[2],0;default:var P=N.slice(1),W=P[0],K=P[1],re=P[2],ye=P[3],ge=P[4],ce=P[5];return E=k(R,x,W,K,re,ye,ge,ce),L=N.slice(-2),R=L[0],x=L[1],E}}).reduce(function(N,L){return N+L},0)}function A(S){return O(S)>=0}},84329:function(ae,ne,b){"use strict";b.d(ne,{r:function(){return O}});var w=b(97582),k=b(32262);function O(A,S,R){return(0,k.s)(A,S,(0,w.pi)((0,w.pi)({},R),{bbox:!1,length:!0})).point}},83555:function(ae,ne,b){"use strict";b.d(ne,{g:function(){return O}});var w=b(44078);function k(A){var S=A.length,R=S-1;return A.map(function(x,E){return A.map(function(N,L){var P=E+L,W;return L===0||A[P]&&A[P][0]==="M"?(W=A[P],["M"].concat(W.slice(-2))):(P>=S&&(P-=R),A[P])})})}function O(A,S){var R=A.length-1,x=[],E=0,N=0,L=k(A);return L.forEach(function(P,W){A.slice(1).forEach(function(K,re){N+=(0,w.y)(A[(W+re)%R].slice(-2),S[re%R].slice(-2))}),x[W]=N,N=0}),E=x.indexOf(Math.min.apply(null,x)),L[E]}},69877:function(ae,ne,b){"use strict";b.d(ne,{D:function(){return O}});var w=b(97582),k=b(32262);function O(A,S){return(0,k.s)(A,void 0,(0,w.pi)((0,w.pi)({},S),{bbox:!1,length:!0})).length}},41010:function(ae,ne,b){"use strict";b.d(ne,{b:function(){return k}});var w=b(56346);function k(O){return(0,w.n)(O)&&O.every(function(A){var S=A[0];return S===S.toUpperCase()})}},11013:function(ae,ne,b){"use strict";b.d(ne,{y:function(){return k}});var w=b(41010);function k(O){return(0,w.b)(O)&&O.every(function(A){var S=A[0];return"ACLMQZ".includes(S)})}},56346:function(ae,ne,b){"use strict";b.d(ne,{n:function(){return k}});var w=b(18323);function k(O){return Array.isArray(O)&&O.every(function(A){var S=A[0].toLowerCase();return w.R[S]===A.length-1&&"achlmqstvz".includes(S)})}},17570:function(ae,ne,b){"use strict";b.d(ne,{k:function(){return w}});function w(k,O,A){var S=k[0],R=k[1],x=O[0],E=O[1];return[S+(x-S)*A,R+(E-R)*A]}},32262:function(ae,ne,b){"use strict";b.d(ne,{s:function(){return P}});var w=b(4848),k=b(17570),O=b(44078);function A(W,K,re,ye,ge){var ce=(0,O.y)([W,K],[re,ye]),xe={x:0,y:0};if(typeof ge=="number")if(ge<=0)xe={x:W,y:K};else if(ge>=ce)xe={x:re,y:ye};else{var fe=(0,k.k)([W,K],[re,ye],ge/ce),Ne=fe[0],Ae=fe[1];xe={x:Ne,y:Ae}}return{length:ce,point:xe,min:{x:Math.min(W,re),y:Math.min(K,ye)},max:{x:Math.max(W,re),y:Math.max(K,ye)}}}function S(W,K){var re=W.x,ye=W.y,ge=K.x,ce=K.y,xe=re*ge+ye*ce,fe=Math.sqrt((Math.pow(re,2)+Math.pow(ye,2))*(Math.pow(ge,2)+Math.pow(ce,2))),Ne=re*ce-ye*ge<0?-1:1,Ae=Ne*Math.acos(xe/fe);return Ae}function R(W,K,re,ye,ge,ce,xe,fe,Ne,Ae){var be=Math.abs,Ye=Math.sin,Ee=Math.cos,We=Math.sqrt,je=Math.PI,_t=be(re),It=be(ye),kt=(ge%360+360)%360,Ut=kt*(je/180);if(W===fe&&K===Ne)return{x:W,y:K};if(_t===0||It===0)return A(W,K,fe,Ne,Ae).point;var At=(W-fe)/2,at=(K-Ne)/2,Ot={x:Ee(Ut)*At+Ye(Ut)*at,y:-Ye(Ut)*At+Ee(Ut)*at},ue=Math.pow(Ot.x,2)/Math.pow(_t,2)+Math.pow(Ot.y,2)/Math.pow(It,2);ue>1&&(_t*=We(ue),It*=We(ue));var Ue=Math.pow(_t,2)*Math.pow(It,2)-Math.pow(_t,2)*Math.pow(Ot.y,2)-Math.pow(It,2)*Math.pow(Ot.x,2),vt=Math.pow(_t,2)*Math.pow(Ot.y,2)+Math.pow(It,2)*Math.pow(Ot.x,2),Jt=Ue/vt;Jt=Jt<0?0:Jt;var Qe=(ce!==xe?1:-1)*We(Jt),rt={x:Qe*(_t*Ot.y/It),y:Qe*(-(It*Ot.x)/_t)},bt={x:Ee(Ut)*rt.x-Ye(Ut)*rt.y+(W+fe)/2,y:Ye(Ut)*rt.x+Ee(Ut)*rt.y+(K+Ne)/2},ze={x:(Ot.x-rt.x)/_t,y:(Ot.y-rt.y)/It},Ze=S({x:1,y:0},ze),q={x:(-Ot.x-rt.x)/_t,y:(-Ot.y-rt.y)/It},Y=S(ze,q);!xe&&Y>0?Y-=2*je:xe&&Y<0&&(Y+=2*je),Y%=2*je;var de=Ze+Y*Ae,Je=_t*Ee(de),Te=It*Ye(de),$e={x:Ee(Ut)*Je-Ye(Ut)*Te+bt.x,y:Ye(Ut)*Je+Ee(Ut)*Te+bt.y};return $e}function x(W,K,re,ye,ge,ce,xe,fe,Ne,Ae,be){var Ye,Ee=be.bbox,We=Ee===void 0?!0:Ee,je=be.length,_t=je===void 0?!0:je,It=be.sampleSize,kt=It===void 0?30:It,Ut=typeof Ae=="number",At=W,at=K,Ot=0,ue=[At,at,Ot],Ue=[At,at],vt=0,Jt={x:0,y:0},Qe=[{x:At,y:at}];Ut&&Ae<=0&&(Jt={x:At,y:at});for(var rt=0;rt<=kt;rt+=1){if(vt=rt/kt,Ye=R(W,K,re,ye,ge,ce,xe,fe,Ne,vt),At=Ye.x,at=Ye.y,We&&Qe.push({x:At,y:at}),_t&&(Ot+=(0,O.y)(Ue,[At,at])),Ue=[At,at],Ut&&Ot>=Ae&&Ae>ue[2]){var bt=(Ot-Ae)/(Ot-ue[2]);Jt={x:Ue[0]*(1-bt)+ue[0]*bt,y:Ue[1]*(1-bt)+ue[1]*bt}}ue=[At,at,Ot]}return Ut&&Ae>=Ot&&(Jt={x:fe,y:Ne}),{length:Ot,point:Jt,min:{x:Math.min.apply(null,Qe.map(function(ze){return ze.x})),y:Math.min.apply(null,Qe.map(function(ze){return ze.y}))},max:{x:Math.max.apply(null,Qe.map(function(ze){return ze.x})),y:Math.max.apply(null,Qe.map(function(ze){return ze.y}))}}}var E=b(6489);function N(W,K,re,ye,ge,ce,xe){var fe=1-xe;return{x:Math.pow(fe,2)*W+2*fe*xe*re+Math.pow(xe,2)*ge,y:Math.pow(fe,2)*K+2*fe*xe*ye+Math.pow(xe,2)*ce}}function L(W,K,re,ye,ge,ce,xe,fe){var Ne,Ae=fe.bbox,be=Ae===void 0?!0:Ae,Ye=fe.length,Ee=Ye===void 0?!0:Ye,We=fe.sampleSize,je=We===void 0?10:We,_t=typeof xe=="number",It=W,kt=K,Ut=0,At=[It,kt,Ut],at=[It,kt],Ot=0,ue={x:0,y:0},Ue=[{x:It,y:kt}];_t&&xe<=0&&(ue={x:It,y:kt});for(var vt=0;vt<=je;vt+=1){if(Ot=vt/je,Ne=N(W,K,re,ye,ge,ce,Ot),It=Ne.x,kt=Ne.y,be&&Ue.push({x:It,y:kt}),Ee&&(Ut+=(0,O.y)(at,[It,kt])),at=[It,kt],_t&&Ut>=xe&&xe>At[2]){var Jt=(Ut-xe)/(Ut-At[2]);ue={x:at[0]*(1-Jt)+At[0]*Jt,y:at[1]*(1-Jt)+At[1]*Jt}}At=[It,kt,Ut]}return _t&&xe>=Ut&&(ue={x:ge,y:ce}),{length:Ut,point:ue,min:{x:Math.min.apply(null,Ue.map(function(Qe){return Qe.x})),y:Math.min.apply(null,Ue.map(function(Qe){return Qe.y}))},max:{x:Math.max.apply(null,Ue.map(function(Qe){return Qe.x})),y:Math.max.apply(null,Ue.map(function(Qe){return Qe.y}))}}}function P(W,K,re){for(var ye,ge,ce,xe,fe,Ne,Ae=(0,w.A)(W),be=typeof K=="number",Ye,Ee=[],We,je=0,_t=0,It=0,kt=0,Ut,At=[],at=[],Ot=0,ue={x:0,y:0},Ue=ue,vt=ue,Jt=ue,Qe=0,rt=0,bt=Ae.length;rt=K&&(Jt=vt),at.push(Ue),At.push(ue),Qe+=Ot,Ne=We!=="Z"?Ut.slice(-2):[It,kt],je=Ne[0],_t=Ne[1];return be&&K>=Qe&&(Jt={x:je,y:_t}),{length:Qe,point:Jt,min:{x:Math.min.apply(null,At.map(function(ze){return ze.x})),y:Math.min.apply(null,At.map(function(ze){return ze.y}))},max:{x:Math.max.apply(null,at.map(function(ze){return ze.x})),y:Math.max.apply(null,at.map(function(ze){return ze.y}))}}}},6489:function(ae,ne,b){"use strict";b.d(ne,{S:function(){return O}});var w=b(44078);function k(A,S,R,x,E,N,L,P,W){var K=1-W;return{x:Math.pow(K,3)*A+3*Math.pow(K,2)*W*R+3*K*Math.pow(W,2)*E+Math.pow(W,3)*L,y:Math.pow(K,3)*S+3*Math.pow(K,2)*W*x+3*K*Math.pow(W,2)*N+Math.pow(W,3)*P}}function O(A,S,R,x,E,N,L,P,W,K){var re,ye=K.bbox,ge=ye===void 0?!0:ye,ce=K.length,xe=ce===void 0?!0:ce,fe=K.sampleSize,Ne=fe===void 0?10:fe,Ae=typeof W=="number",be=A,Ye=S,Ee=0,We=[be,Ye,Ee],je=[be,Ye],_t=0,It={x:0,y:0},kt=[{x:be,y:Ye}];Ae&&W<=0&&(It={x:be,y:Ye});for(var Ut=0;Ut<=Ne;Ut+=1){if(_t=Ut/Ne,re=k(A,S,R,x,E,N,L,P,_t),be=re.x,Ye=re.y,ge&&kt.push({x:be,y:Ye}),xe&&(Ee+=(0,w.y)(je,[be,Ye])),je=[be,Ye],Ae&&Ee>=W&&W>We[2]){var At=(Ee-W)/(Ee-We[2]);It={x:je[0]*(1-At)+We[0]*At,y:je[1]*(1-At)+We[1]*At}}We=[be,Ye,Ee]}return Ae&&W>=Ee&&(It={x:L,y:P}),{length:Ee,point:It,min:{x:Math.min.apply(null,kt.map(function(at){return at.x})),y:Math.min.apply(null,kt.map(function(at){return at.y}))},max:{x:Math.max.apply(null,kt.map(function(at){return at.x})),y:Math.max.apply(null,kt.map(function(at){return at.y}))}}}},48202:function(ae,ne,b){"use strict";var w,k=Object.defineProperty,O=Le=>{throw TypeError(Le)},A=Math.pow,S=(Le,D,U)=>D in Le?k(Le,D,{enumerable:!0,configurable:!0,writable:!0,value:U}):Le[D]=U,R=(Le,D,U)=>S(Le,typeof D!="symbol"?D+"":D,U),x=(Le,D,U)=>D.has(Le)||O("Cannot "+U),E=(Le,D,U)=>(x(Le,D,"read from private field"),U?U.call(Le):D.get(Le)),N=(Le,D,U)=>D.has(Le)?O("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(Le):D.set(Le,U),L=(Le,D,U,_)=>(x(Le,D,"write to private field"),_?_.call(Le,U):D.set(Le,U),U),P=(Le,D,U)=>(x(Le,D,"access private method"),U),W,K,re;w={value:!0};var ye=b(44091),ge=b(75823);const ce=" ".repeat(2),xe=" ".repeat(4);function fe(){return Ne(this)}function Ne(Le,D={}){const{maxRows:U=15,maxColumns:_=10,maxNumSize:F=8,padMinus:X="auto"}=D;return`${Le.constructor.name} { ${ce}[ ${xe}${Ae(Le,U,_,F,X)} ${ce}] ${ce}rows: ${Le.rows} ${ce}columns: ${Le.columns} }`}function Ae(Le,D,U,_,F){const{rows:X,columns:De}=Le,Ve=Math.min(X,D),it=Math.min(De,U),st=[];if(F==="auto"){F=!1;e:for(let Ht=0;Ht=0&&U?` ${Ye(Le,D-1)}`:Ye(Le,D)).padEnd(D)}function Ye(Le,D){let U=Le.toString();if(U.length<=D)return U;let _=Le.toFixed(D);if(_.length>D&&(_=Le.toFixed(Math.max(0,D-(_.length-D)))),_.length<=D&&!_.startsWith("0.000")&&!_.startsWith("-0.000"))return _;let F=Le.toExponential(D);return F.length>D&&(F=Le.toExponential(Math.max(0,D-(F.length-D)))),F.slice(0)}function Ee(Le,D){Le.prototype.add=function(_){return typeof _=="number"?this.addS(_):this.addM(_)},Le.prototype.addS=function(_){for(let F=0;F>_);return this},Le.prototype.signPropagatingRightShiftM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F>_.get(F,X));return this},Le.signPropagatingRightShift=function(_,F){return new D(_).signPropagatingRightShift(F)},Le.prototype.rightShift=function(_){return typeof _=="number"?this.rightShiftS(_):this.rightShiftM(_)},Le.prototype.rightShiftS=function(_){for(let F=0;F>>_);return this},Le.prototype.rightShiftM=function(_){if(_=D.checkMatrix(_),this.rows!==_.rows||this.columns!==_.columns)throw new RangeError("Matrices dimensions must be equal");for(let F=0;F>>_.get(F,X));return this},Le.rightShift=function(_,F){return new D(_).rightShift(F)},Le.prototype.zeroFillRightShift=Le.prototype.rightShift,Le.prototype.zeroFillRightShiftS=Le.prototype.rightShiftS,Le.prototype.zeroFillRightShiftM=Le.prototype.rightShiftM,Le.zeroFillRightShift=Le.rightShift,Le.prototype.not=function(){for(let _=0;__)throw new RangeError("Row index out of range")}function je(Le,D,U){let _=U?Le.columns:Le.columns-1;if(D<0||D>_)throw new RangeError("Column index out of range")}function _t(Le,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Le.columns)throw new RangeError("vector size must be the same as the number of columns");return D}function It(Le,D){if(D.to1DArray&&(D=D.to1DArray()),D.length!==Le.rows)throw new RangeError("vector size must be the same as the number of rows");return D}function kt(Le,D){if(!ye.isAnyArray(D))throw new TypeError("row indices must be an array");for(let U=0;U=Le.rows)throw new RangeError("row indices are out of range")}function Ut(Le,D){if(!ye.isAnyArray(D))throw new TypeError("column indices must be an array");for(let U=0;U=Le.columns)throw new RangeError("column indices are out of range")}function At(Le,D,U,_,F){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(Ot("startRow",D),Ot("endRow",U),Ot("startColumn",_),Ot("endColumn",F),D>U||_>F||D<0||D>=Le.rows||U<0||U>=Le.rows||_<0||_>=Le.columns||F<0||F>=Le.columns)throw new RangeError("Submatrix indices are out of range")}function at(Le,D=0){let U=[];for(let _=0;_=X)throw new RangeError("min must be smaller than max");let Ve=X-F,it=new ht(D,U);for(let st=0;st_?(X=!0,_=U):(F=!1,X=!0);D++}return F}isReducedEchelonForm(){let D=0,U=0,_=-1,F=!0,X=!1;for(;D_?(X=!0,_=U):(F=!1,X=!0);for(let De=U+1;DeD.get(F,_)&&(F=X);if(D.get(F,_)===0)_++;else{D.swapRows(U,F);let X=D.get(U,_);for(let De=_;De=0;)if(D.maxRow(F)===0)F--;else{let X=0,De=!1;for(;X<_&&De===!1;)D.get(F,X)===1?De=!0:X++;for(let Ve=0;VeU[_]&&(U[_]=this.get(_,F));return U}case"column":{const U=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let _=0;_U[F]&&(U[F]=this.get(_,F));return U}case void 0:{let U=this.get(0,0);for(let _=0;_U&&(U=this.get(_,F));return U}default:throw new Error(`invalid option: ${D}`)}}maxIndex(){ue(this);let D=this.get(0,0),U=[0,0];for(let _=0;_D&&(D=this.get(_,F),U[0]=_,U[1]=F);return U}min(D){if(this.isEmpty())return NaN;switch(D){case"row":{const U=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let _=0;_U&&(U=this.get(D,_));return U}maxRowIndex(D){We(this,D),ue(this);let U=this.get(D,0),_=[D,0];for(let F=1;FU&&(U=this.get(D,F),_[1]=F);return _}minRow(D){if(We(this,D),this.isEmpty())return NaN;let U=this.get(D,0);for(let _=1;_U&&(U=this.get(_,D));return U}maxColumnIndex(D){je(this,D),ue(this);let U=this.get(0,D),_=[0,D];for(let F=1;FU&&(U=this.get(F,D),_[0]=F);return _}minColumn(D){if(je(this,D),this.isEmpty())return NaN;let U=this.get(0,D);for(let _=1;_1;F/=2)F&1&&(U=U.mmul(_)),_=_.mmul(_);return U}strassen2x2(D){D=ht.checkMatrix(D);let U=new ht(2,2);const _=this.get(0,0),F=D.get(0,0),X=this.get(0,1),De=D.get(0,1),Ve=this.get(1,0),it=D.get(1,0),st=this.get(1,1),Ht=D.get(1,1),Et=(_+st)*(F+Ht),on=(Ve+st)*F,Un=_*(De-Ht),sn=st*(it-F),bn=(_+X)*Ht,ti=(Ve-_)*(F+De),Bt=(X-st)*(it+Ht),$n=Et+sn-bn+Bt,ni=Un+bn,Pi=on+sn,ui=Et-on+Un+ti;return U.set(0,0,$n),U.set(0,1,ni),U.set(1,0,Pi),U.set(1,1,ui),U}strassen3x3(D){D=ht.checkMatrix(D);let U=new ht(3,3);const _=this.get(0,0),F=this.get(0,1),X=this.get(0,2),De=this.get(1,0),Ve=this.get(1,1),it=this.get(1,2),st=this.get(2,0),Ht=this.get(2,1),Et=this.get(2,2),on=D.get(0,0),Un=D.get(0,1),sn=D.get(0,2),bn=D.get(1,0),ti=D.get(1,1),Bt=D.get(1,2),$n=D.get(2,0),ni=D.get(2,1),Pi=D.get(2,2),ui=(_+F+X-De-Ve-Ht-Et)*ti,Ir=(_-De)*(-Un+ti),yi=Ve*(-on+Un+bn-ti-Bt-$n+Pi),vi=(-_+De+Ve)*(on-Un+ti),Mr=(De+Ve)*(-on+Un),Zt=_*on,Fn=(-_+st+Ht)*(on-sn+Bt),hi=(-_+st)*(sn-Bt),Xn=(st+Ht)*(-on+sn),hs=(_+F+X-Ve-it-st-Ht)*Bt,Xr=Ht*(-on+sn+bn-ti-Bt-$n+ni),ys=(-X+Ht+Et)*(ti+$n-ni),Ur=(X-Et)*(ti-ni),Os=X*$n,no=(Ht+Et)*(-$n+ni),io=(-X+Ve+it)*(Bt+$n-Pi),So=(X-it)*(Bt-Pi),To=(Ve+it)*(-$n+Pi),Gr=F*bn,Qs=it*ni,Eo=De*sn,ro=st*Un,qr=Et*Pi,la=Zt+Os+Gr,Ao=ui+vi+Mr+Zt+ys+Os+no,il=Zt+Fn+Xn+hs+Os+io+To,rl=Ir+yi+vi+Zt+Os+io+So,ca=Ir+vi+Mr+Zt+Qs,Oa=Os+io+So+To+Eo,sl=Zt+Fn+hi+Xr+ys+Ur+Os,bo=ys+Ur+Os+no+ro,Pc=Zt+Fn+hi+Xn+qr;return U.set(0,0,la),U.set(0,1,Ao),U.set(0,2,il),U.set(1,0,rl),U.set(1,1,ca),U.set(1,2,Oa),U.set(2,0,sl),U.set(2,1,bo),U.set(2,2,Pc),U}mmulStrassen(D){D=ht.checkMatrix(D);let U=this.clone(),_=U.rows,F=U.columns,X=D.rows,De=D.columns;F!==X&&console.warn(`Multiplying ${_} x ${F} and ${X} x ${De} matrix: dimensions do not match.`);function Ve(Et,on,Un){let sn=Et.rows,bn=Et.columns;if(sn===on&&bn===Un)return Et;{let ti=B.zeros(on,Un);return ti=ti.setSubMatrix(Et,0,0),ti}}let it=Math.max(_,X),st=Math.max(F,De);U=Ve(U,it,st),D=Ve(D,it,st);function Ht(Et,on,Un,sn){if(Un<=512||sn<=512)return Et.mmul(on);Un%2===1&&sn%2===1?(Et=Ve(Et,Un+1,sn+1),on=Ve(on,Un+1,sn+1)):Un%2===1?(Et=Ve(Et,Un+1,sn),on=Ve(on,Un+1,sn)):sn%2===1&&(Et=Ve(Et,Un,sn+1),on=Ve(on,Un,sn+1));let bn=parseInt(Et.rows/2,10),ti=parseInt(Et.columns/2,10),Bt=Et.subMatrix(0,bn-1,0,ti-1),$n=on.subMatrix(0,bn-1,0,ti-1),ni=Et.subMatrix(0,bn-1,ti,Et.columns-1),Pi=on.subMatrix(0,bn-1,ti,on.columns-1),ui=Et.subMatrix(bn,Et.rows-1,0,ti-1),Ir=on.subMatrix(bn,on.rows-1,0,ti-1),yi=Et.subMatrix(bn,Et.rows-1,ti,Et.columns-1),vi=on.subMatrix(bn,on.rows-1,ti,on.columns-1),Mr=Ht(B.add(Bt,yi),B.add($n,vi),bn,ti),Zt=Ht(B.add(ui,yi),$n,bn,ti),Fn=Ht(Bt,B.sub(Pi,vi),bn,ti),hi=Ht(yi,B.sub(Ir,$n),bn,ti),Xn=Ht(B.add(Bt,ni),vi,bn,ti),hs=Ht(B.sub(ui,Bt),B.add($n,Pi),bn,ti),Xr=Ht(B.sub(ni,yi),B.add(Ir,vi),bn,ti),ys=B.add(Mr,hi);ys.sub(Xn),ys.add(Xr);let Ur=B.add(Fn,Xn),Os=B.add(Zt,hi),no=B.sub(Mr,Zt);no.add(Fn),no.add(hs);let io=B.zeros(2*ys.rows,2*ys.columns);return io=io.setSubMatrix(ys,0,0),io=io.setSubMatrix(Ur,ys.rows,0),io=io.setSubMatrix(Os,0,ys.columns),io=io.setSubMatrix(no,ys.rows,ys.columns),io.subMatrix(0,Un-1,0,sn-1)}return Ht(U,D,it,st)}scaleRows(D={}){if(typeof D!="object")throw new TypeError("options must be an object");const{min:U=0,max:_=1}=D;if(!Number.isFinite(U))throw new TypeError("min must be a number");if(!Number.isFinite(_))throw new TypeError("max must be a number");if(U>=_)throw new RangeError("min must be smaller than max");let F=new ht(this.rows,this.columns);for(let X=0;X0&&ge(De,{min:U,max:_,output:De}),F.setRow(X,De)}return F}scaleColumns(D={}){if(typeof D!="object")throw new TypeError("options must be an object");const{min:U=0,max:_=1}=D;if(!Number.isFinite(U))throw new TypeError("min must be a number");if(!Number.isFinite(_))throw new TypeError("max must be a number");if(U>=_)throw new RangeError("min must be smaller than max");let F=new ht(this.rows,this.columns);for(let X=0;X_||U<0||U>=this.columns||_<0||_>=this.columns)throw new RangeError("Argument out of range");let F=new ht(D.length,_-U+1);for(let X=0;X=this.rows)throw new RangeError(`Row index out of range: ${D[X]}`);F.set(X,De-U,this.get(D[X],De))}return F}subMatrixColumn(D,U,_){if(U===void 0&&(U=0),_===void 0&&(_=this.rows-1),U>_||U<0||U>=this.rows||_<0||_>=this.rows)throw new RangeError("Argument out of range");let F=new ht(_-U+1,D.length);for(let X=0;X=this.columns)throw new RangeError(`Column index out of range: ${D[X]}`);F.set(De-U,X,this.get(De,D[X]))}return F}setSubMatrix(D,U,_){if(D=ht.checkMatrix(D),D.isEmpty())return this;let F=U+D.rows-1,X=_+D.columns-1;At(this,U,F,_,X);for(let De=0;Detypeof D=="number")}B.random=B.rand,B.randomInt=B.randInt,B.diagonal=B.diag,B.prototype.diagonal=B.prototype.diag,B.identity=B.eye,B.prototype.negate=B.prototype.neg,B.prototype.tensorProduct=B.prototype.kroneckerProduct;const Mt=class tE extends B{constructor(D,U){if(super(),N(this,W),R(this,"data"),tE.isMatrix(D))P(this,W,K).call(this,D.rows,D.columns),tE.copy(D,this);else if(Number.isInteger(D)&&D>=0)P(this,W,K).call(this,D,U);else if(ye.isAnyArray(D)){const _=D;if(D=_.length,U=D?_[0].length:0,typeof U!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let F=0;F=0)for(let U=0;U=0)L(this,re,new ht(D,D));else if(L(this,re,new ht(D)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return E(this,re).size}get rows(){return E(this,re).rows}get columns(){return E(this,re).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(D){return ht.isMatrix(D)&&D.klassType==="SymmetricMatrix"}static zeros(D){return new this(D)}static ones(D){return new this(D).fill(1)}clone(){const D=new nE(this.diagonalSize);for(const[U,_,F]of this.upperRightEntries())D.set(U,_,F);return D}toMatrix(){return new ht(this)}get(D,U){return E(this,re).get(D,U)}set(D,U,_){return E(this,re).set(D,U,_),E(this,re).set(U,D,_),this}removeCross(D){return E(this,re).removeRow(D),E(this,re).removeColumn(D),this}addCross(D,U){U===void 0&&(U=D,D=this.diagonalSize);const _=U.slice();return _.splice(D,1),E(this,re).addRow(D,_),E(this,re).addColumn(D,U),this}applyMask(D){if(D.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const U=[];for(const[_,F]of D.entries())F||U.push(_);U.reverse();for(const _ of U)this.removeCross(_);return this}toCompact(){const{diagonalSize:D}=this,U=new Array(D*(D+1)/2);for(let _=0,F=0,X=0;X=D&&(_=++F);return U}static fromCompact(D){const U=D.length,_=(Math.sqrt(8*U+1)-1)/2;if(!Number.isInteger(_))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(D)}`);const F=new nE(_);for(let X=0,De=0,Ve=0;Ve=_&&(X=++De);return F}*upperRightEntries(){for(let D=0,U=0;D=this.diagonalSize&&(U=++D)}}*upperRightValues(){for(let D=0,U=0;D=this.diagonalSize&&(U=++D)}};re=new WeakMap;let en=Yt;en.prototype.klassType="SymmetricMatrix";class nn extends en{static isDistanceMatrix(D){return en.isSymmetricMatrix(D)&&D.klassSubType==="DistanceMatrix"}constructor(D){if(super(D),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(D,U,_){return D===U&&(_=0),super.set(D,U,_)}addCross(D,U){return U===void 0&&(U=D,D=this.diagonalSize),U=U.slice(),U[D]=0,super.addCross(D,U)}toSymmetricMatrix(){return new en(this)}clone(){const D=new nn(this.diagonalSize);for(const[U,_,F]of this.upperRightEntries())U!==_&&D.set(U,_,F);return D}toCompact(){const{diagonalSize:D}=this,U=(D-1)*D/2,_=new Array(U);for(let F=1,X=0,De=0;De<_.length;De++)_[De]=this.get(X,F),++F>=D&&(F=++X+1);return _}static fromCompact(D){const U=D.length;if(U===0)return new this(0);const _=(Math.sqrt(8*U+1)+1)/2;if(!Number.isInteger(_))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(D)}`);const F=new this(_);for(let X=1,De=0,Ve=0;Ve=_&&(X=++De+1);return F}}nn.prototype.klassSubType="DistanceMatrix";class Me extends B{constructor(D,U,_){super(),this.matrix=D,this.rows=U,this.columns=_}}class te extends Me{constructor(D,U){je(D,U),super(D,D.rows,1),this.column=U}set(D,U,_){return this.matrix.set(D,this.column,_),this}get(D){return this.matrix.get(D,this.column)}}class Fe extends Me{constructor(D,U){Ut(D,U),super(D,D.rows,U.length),this.columnIndices=U}set(D,U,_){return this.matrix.set(D,this.columnIndices[U],_),this}get(D,U){return this.matrix.get(D,this.columnIndices[U])}}class Xe extends Me{constructor(D){super(D,D.rows,D.columns)}set(D,U,_){return this.matrix.set(D,this.columns-U-1,_),this}get(D,U){return this.matrix.get(D,this.columns-U-1)}}class Pe extends Me{constructor(D){super(D,D.rows,D.columns)}set(D,U,_){return this.matrix.set(this.rows-D-1,U,_),this}get(D,U){return this.matrix.get(this.rows-D-1,U)}}class Ie extends Me{constructor(D,U){We(D,U),super(D,1,D.columns),this.row=U}set(D,U,_){return this.matrix.set(this.row,U,_),this}get(D,U){return this.matrix.get(this.row,U)}}class Ke extends Me{constructor(D,U){kt(D,U),super(D,U.length,D.columns),this.rowIndices=U}set(D,U,_){return this.matrix.set(this.rowIndices[D],U,_),this}get(D,U){return this.matrix.get(this.rowIndices[D],U)}}class lt extends Me{constructor(D,U,_){kt(D,U),Ut(D,_),super(D,U.length,_.length),this.rowIndices=U,this.columnIndices=_}set(D,U,_){return this.matrix.set(this.rowIndices[D],this.columnIndices[U],_),this}get(D,U){return this.matrix.get(this.rowIndices[D],this.columnIndices[U])}}class qe extends Me{constructor(D,U,_,F,X){At(D,U,_,F,X),super(D,_-U+1,X-F+1),this.startRow=U,this.startColumn=F}set(D,U,_){return this.matrix.set(this.startRow+D,this.startColumn+U,_),this}get(D,U){return this.matrix.get(this.startRow+D,this.startColumn+U)}}class pt extends Me{constructor(D){super(D,D.columns,D.rows)}set(D,U,_){return this.matrix.set(U,D,_),this}get(D,U){return this.matrix.get(U,D)}}class Ct extends B{constructor(D,U={}){const{rows:_=1}=U;if(D.length%_!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=_,this.columns=D.length/_,this.data=D}set(D,U,_){let F=this._calculateIndex(D,U);return this.data[F]=_,this}get(D,U){let _=this._calculateIndex(D,U);return this.data[_]}_calculateIndex(D,U){return D*this.columns+U}}class Xt extends B{constructor(D){super(),this.data=D,this.rows=D.length,this.columns=D[0].length}set(D,U,_){return this.data[D][U]=_,this}get(D,U){return this.data[D][U]}}function Qt(Le,D){if(ye.isAnyArray(Le))return Le[0]&&ye.isAnyArray(Le[0])?new Xt(Le):new Ct(Le,D);throw new Error("the argument is not an array")}class pn{constructor(D){D=Xt.checkMatrix(D);let U=D.clone(),_=U.rows,F=U.columns,X=new Float64Array(_),De=1,Ve,it,st,Ht,Et,on,Un,sn,bn;for(Ve=0;Ve<_;Ve++)X[Ve]=Ve;for(sn=new Float64Array(_),it=0;itMath.abs(sn[Ht])&&(Ht=Ve);if(Ht!==it){for(st=0;st=0;st--){for(it=0;itDe?F.set(X,De,D.get(X,De)):X===De?F.set(X,De,1):F.set(X,De,0);return F}get upperTriangularMatrix(){let D=this.LU,U=D.rows,_=D.columns,F=new ht(U,_);for(let X=0;XMath.abs(D)?(U=D/Le,Math.abs(Le)*Math.sqrt(1+U*U)):D!==0?(U=Le/D,Math.abs(D)*Math.sqrt(1+U*U)):0}class Rn{constructor(D){D=Xt.checkMatrix(D);let U=D.clone(),_=D.rows,F=D.columns,X=new Float64Array(F),De,Ve,it,st;for(it=0;it=0;st--){for(it=0;it=0;Ve--){for(X=0;X=0;Zt--)if(sn[Zt]!==0){for(let Fn=Zt+1;Fn=0;Zt--){if(Zt0;){let Zt,Fn;for(Zt=yi-2;Zt>=-1&&Zt!==-1;Zt--){const hi=Number.MIN_VALUE+Mr*Math.abs(sn[Zt]+Math.abs(sn[Zt+1]));if(Math.abs(Bt[Zt])<=hi||Number.isNaN(Bt[Zt])){Bt[Zt]=0;break}}if(Zt===yi-2)Fn=4;else{let hi;for(hi=yi-1;hi>=Zt&&hi!==Zt;hi--){let Xn=(hi!==yi?Math.abs(Bt[hi]):0)+(hi!==Zt+1?Math.abs(Bt[hi-1]):0);if(Math.abs(sn[hi])<=Mr*Xn){sn[hi]=0;break}}hi===Zt?Fn=3:hi===yi-1?Fn=1:(Fn=2,Zt=hi)}switch(Zt++,Fn){case 1:{let hi=Bt[yi-2];Bt[yi-2]=0;for(let Xn=yi-2;Xn>=Zt;Xn--){let hs=Wn(sn[Xn],hi),Xr=sn[Xn]/hs,ys=hi/hs;if(sn[Xn]=hs,Xn!==Zt&&(hi=-ys*Bt[Xn-1],Bt[Xn-1]=Xr*Bt[Xn-1]),st)for(let Ur=0;Ur=sn[Zt+1]);){let hi=sn[Zt];if(sn[Zt]=sn[Zt+1],sn[Zt+1]=hi,st&&ZtU&&X.set(Ht,Et,D.get(Ht,Et)/this.s[Et]);let De=this.U,Ve=De.rows,it=De.columns,st=new ht(_,Ve);for(let Ht=0;Ht<_;Ht++)for(let Et=0;EtD&&U++;return U}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return ht.diag(this.s)}}function Lr(Le,D=!1){return Le=Xt.checkMatrix(Le),D?new bi(Le).inverse():Qn(Le,ht.eye(Le.rows))}function Qn(Le,D,U=!1){return Le=Xt.checkMatrix(Le),D=Xt.checkMatrix(D),U?new bi(Le).solve(D):Le.isSquare()?new pn(Le).solve(D):new Rn(Le).solve(D)}function Vi(Le){if(Le=ht.checkMatrix(Le),Le.isSquare()){if(Le.columns===0)return 1;let D,U,_,F;if(Le.columns===2)return D=Le.get(0,0),U=Le.get(0,1),_=Le.get(1,0),F=Le.get(1,1),D*F-U*_;if(Le.columns===3){let X,De,Ve;return X=new lt(Le,[1,2],[1,2]),De=new lt(Le,[1,2],[0,2]),Ve=new lt(Le,[1,2],[0,1]),D=Le.get(0,0),U=Le.get(0,1),_=Le.get(0,2),D*Vi(X)-U*Vi(De)+_*Vi(Ve)}else return new pn(Le).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Oi(Le,D){let U=[];for(let _=0;_F)return new Array(D.rows+1).fill(0);{let X=D.addRow(U,[0]);for(let De=0;DeD?X[De]=1/X[De]:X[De]=0;return F.mmul(ht.diag(X).mmul(_.transpose()))}function Is(Le,D=Le,U={}){Le=new ht(Le);let _=!1;if(typeof D=="object"&&!ht.isMatrix(D)&&!ye.isAnyArray(D)?(U=D,D=Le,_=!0):D=new ht(D),Le.rows!==D.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:F=!0}=U;F&&(Le=Le.center("column"),_||(D=D.center("column")));const X=Le.transpose().mmul(D);for(let De=0;De0?F.set(X,X+1,U[X]):U[X]<0&&F.set(X,X-1,U[X])}return F}}function Vs(Le,D,U,_){let F,X,De,Ve,it,st,Ht,Et;for(it=0;it0;Ve--){for(Et=0,De=0,st=0;st0&&(X=-X),D[Ve]=Et*X,De=De-F*X,U[Ve-1]=F-X,it=0;itst)do{for(F=U[st],Et=(U[st+1]-F)/(2*D[st]),on=Wn(Et,1),Et<0&&(on=-on),U[st]=D[st]/(Et+on),U[st+1]=D[st]*(Et+on),Un=U[st+1],X=F-U[st],De=st+2;De=st;De--)for(ti=bn,bn=sn,ni=$n,F=sn*D[De],X=sn*Et,on=Wn(Et,D[De]),D[De+1]=$n*on,$n=D[De]/on,sn=Et/on,Et=sn*U[De]-$n*F,U[De+1]=X+$n*(sn*F+$n*U[De]),it=0;itIr*ui);U[st]=U[st]+Pi,D[st]=0}for(De=0;De=Et;st--)U[st]=D.get(st,Et-1)/on,it+=U[st]*U[st];for(Ve=Math.sqrt(it),U[Et]>0&&(Ve=-Ve),it=it-U[Et]*Ve,U[Et]=U[Et]-Ve,Ht=Et;Ht=Et;st--)De+=U[st]*D.get(st,Ht);for(De=De/it,st=Et;st<=X;st++)D.set(st,Ht,D.get(st,Ht)-De*U[st])}for(st=0;st<=X;st++){for(De=0,Ht=X;Ht>=Et;Ht--)De+=U[Ht]*D.get(st,Ht);for(De=De/it,Ht=Et;Ht<=X;Ht++)D.set(st,Ht,D.get(st,Ht)-De*U[Ht])}U[Et]=on*U[Et],D.set(Et,Et-1,on*Ve)}}for(st=0;st=F+1;Et--)if(D.get(Et,Et-1)!==0){for(st=Et+1;st<=X;st++)U[st]=D.get(st,Et-1);for(Ht=Et;Ht<=X;Ht++){for(Ve=0,st=Et;st<=X;st++)Ve+=U[st]*_.get(st,Ht);for(Ve=Ve/U[Et]/D.get(Et,Et-1),st=Et;st<=X;st++)_.set(st,Ht,_.get(st,Ht)+Ve*U[st])}}}function Da(Le,D,U,_,F){let X=Le-1,De=0,Ve=Le-1,it=Number.EPSILON,st=0,Ht=0,Et=0,on=0,Un=0,sn=0,bn=0,ti=0,Bt,$n,ni,Pi,ui,Ir,yi,vi,Mr,Zt,Fn,hi,Xn,hs,Xr;for(Bt=0;BtVe)&&(U[Bt]=F.get(Bt,Bt),D[Bt]=0),$n=Math.max(Bt-1,0);$n=De;){for(Pi=X;Pi>De&&(sn=Math.abs(F.get(Pi-1,Pi-1))+Math.abs(F.get(Pi,Pi)),sn===0&&(sn=Ht),!(Math.abs(F.get(Pi,Pi-1))=0){for(bn=Et>=0?Et+bn:Et-bn,U[X-1]=vi+bn,U[X]=U[X-1],bn!==0&&(U[X]=vi-yi/bn),D[X-1]=0,D[X]=0,vi=F.get(X,X-1),sn=Math.abs(vi)+Math.abs(bn),Et=vi/sn,on=bn/sn,Un=Math.sqrt(Et*Et+on*on),Et=Et/Un,on=on/Un,$n=X-1;$n0)){for(sn=Math.sqrt(sn),Mr=Pi&&(bn=F.get(ui,ui),Un=vi-bn,sn=Mr-bn,Et=(Un*sn-yi)/F.get(ui+1,ui)+F.get(ui,ui+1),on=F.get(ui+1,ui+1)-bn-Un-sn,Un=F.get(ui+2,ui+1),sn=Math.abs(Et)+Math.abs(on)+Math.abs(Un),Et=Et/sn,on=on/sn,Un=Un/sn,!(ui===Pi||Math.abs(F.get(ui,ui-1))*(Math.abs(on)+Math.abs(Un))ui+2&&F.set(Bt,Bt-3,0);for(ni=ui;ni<=X-1&&(hs=ni!==X-1,ni!==ui&&(Et=F.get(ni,ni-1),on=F.get(ni+1,ni-1),Un=hs?F.get(ni+2,ni-1):0,vi=Math.abs(Et)+Math.abs(on)+Math.abs(Un),vi!==0&&(Et=Et/vi,on=on/vi,Un=Un/vi)),vi!==0);ni++)if(sn=Math.sqrt(Et*Et+on*on+Un*Un),Et<0&&(sn=-sn),sn!==0){for(ni!==ui?F.set(ni,ni-1,-sn*vi):Pi!==ui&&F.set(ni,ni-1,-F.get(ni,ni-1)),Et=Et+sn,vi=Et/sn,Mr=on/sn,bn=Un/sn,on=on/Et,Un=Un/Et,$n=ni;$n=0;X--)if(Et=U[X],on=D[X],on===0)for(Pi=X,F.set(X,X,1),Bt=X-1;Bt>=0;Bt--){for(yi=F.get(Bt,Bt)-Et,Un=0,$n=Pi;$n<=X;$n++)Un=Un+F.get(Bt,$n)*F.get($n,X);if(D[Bt]<0)bn=yi,sn=Un;else if(Pi=Bt,D[Bt]===0?F.set(Bt,X,yi!==0?-Un/yi:-Un/(it*Ht)):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),on=(U[Bt]-Et)*(U[Bt]-Et)+D[Bt]*D[Bt],Ir=(vi*sn-bn*Un)/on,F.set(Bt,X,Ir),F.set(Bt+1,X,Math.abs(vi)>Math.abs(bn)?(-Un-yi*Ir)/vi:(-sn-Mr*Ir)/bn)),Ir=Math.abs(F.get(Bt,X)),it*Ir*Ir>1)for($n=Bt;$n<=X;$n++)F.set($n,X,F.get($n,X)/Ir)}else if(on<0)for(Pi=X-1,Math.abs(F.get(X,X-1))>Math.abs(F.get(X-1,X))?(F.set(X-1,X-1,on/F.get(X,X-1)),F.set(X-1,X,-(F.get(X,X)-Et)/F.get(X,X-1))):(Xr=Dl(0,-F.get(X-1,X),F.get(X-1,X-1)-Et,on),F.set(X-1,X-1,Xr[0]),F.set(X-1,X,Xr[1])),F.set(X,X-1,0),F.set(X,X,1),Bt=X-2;Bt>=0;Bt--){for(Zt=0,Fn=0,$n=Pi;$n<=X;$n++)Zt=Zt+F.get(Bt,$n)*F.get($n,X-1),Fn=Fn+F.get(Bt,$n)*F.get($n,X);if(yi=F.get(Bt,Bt)-Et,D[Bt]<0)bn=yi,Un=Zt,sn=Fn;else if(Pi=Bt,D[Bt]===0?(Xr=Dl(-Zt,-Fn,yi,on),F.set(Bt,X-1,Xr[0]),F.set(Bt,X,Xr[1])):(vi=F.get(Bt,Bt+1),Mr=F.get(Bt+1,Bt),hi=(U[Bt]-Et)*(U[Bt]-Et)+D[Bt]*D[Bt]-on*on,Xn=(U[Bt]-Et)*2*on,hi===0&&Xn===0&&(hi=it*Ht*(Math.abs(yi)+Math.abs(on)+Math.abs(vi)+Math.abs(Mr)+Math.abs(bn))),Xr=Dl(vi*Un-bn*Zt+on*Fn,vi*sn-bn*Fn-on*Zt,hi,Xn),F.set(Bt,X-1,Xr[0]),F.set(Bt,X,Xr[1]),Math.abs(vi)>Math.abs(bn)+Math.abs(on)?(F.set(Bt+1,X-1,(-Zt-yi*F.get(Bt,X-1)+on*F.get(Bt,X))/vi),F.set(Bt+1,X,(-Fn-yi*F.get(Bt,X)-on*F.get(Bt,X-1))/vi)):(Xr=Dl(-Un-Mr*F.get(Bt,X-1),-sn-Mr*F.get(Bt,X),bn,on),F.set(Bt+1,X-1,Xr[0]),F.set(Bt+1,X,Xr[1]))),Ir=Math.max(Math.abs(F.get(Bt,X-1)),Math.abs(F.get(Bt,X))),it*Ir*Ir>1)for($n=Bt;$n<=X;$n++)F.set($n,X-1,F.get($n,X-1)/Ir),F.set($n,X,F.get($n,X)/Ir)}for(Bt=0;BtVe)for($n=Bt;$n=De;$n--)for(Bt=De;Bt<=Ve;Bt++){for(bn=0,ni=De;ni<=Math.min($n,Ve);ni++)bn=bn+_.get(Bt,ni)*F.get(ni,$n);_.set(Bt,$n,bn)}}}function Dl(Le,D,U,_){let F,X;return Math.abs(U)>Math.abs(_)?(F=_/U,X=U+F*_,[(Le+F*D)/X,(D-F*Le)/X]):(F=U/_,X=_+F*U,[(F*Le+D)/X,(F*D-Le)/X])}class nu{constructor(D){if(D=Xt.checkMatrix(D),!D.isSymmetric())throw new Error("Matrix is not symmetric");let U=D,_=U.rows,F=new ht(_,_),X=!0,De,Ve,it;for(Ve=0;Ve<_;Ve++){let st=0;for(it=0;it0),F.set(Ve,Ve,Math.sqrt(Math.max(st,0))),it=Ve+1;it<_;it++)F.set(Ve,it,0)}this.L=F,this.positiveDefinite=X}isPositiveDefinite(){return this.positiveDefinite}solve(D){D=Xt.checkMatrix(D);let U=this.L,_=U.rows;if(D.rows!==_)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let F=D.columns,X=D.clone(),De,Ve,it;for(it=0;it<_;it++)for(Ve=0;Ve=0;it--)for(Ve=0;VeDe;Un++)Et=D.transpose().mmul(Ve).div(Ve.transpose().mmul(Ve).get(0,0)),Et=Et.div(Et.norm()),st=D.mmul(Et).div(Et.transpose().mmul(Et).get(0,0)),Un>0&&(it=st.clone().sub(on).pow(2).sum()),on=st.clone(),_?(Ht=_.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0)),Ht=Ht.div(Ht.norm()),Ve=_.mmul(Ht).div(Ht.transpose().mmul(Ht).get(0,0))):Ve=st;if(_){let Un=D.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0));Un=Un.div(Un.norm());let sn=D.clone().sub(st.clone().mmul(Un.transpose())),bn=Ve.transpose().mmul(st).div(st.transpose().mmul(st).get(0,0)),ti=_.clone().sub(st.clone().mulS(bn.get(0,0)).mmul(Ht.transpose()));this.t=st,this.p=Un.transpose(),this.w=Et.transpose(),this.q=Ht,this.u=Ve,this.s=st.transpose().mmul(st),this.xResidual=sn,this.yResidual=ti,this.betas=bn}else this.w=Et.transpose(),this.s=st.transpose().mmul(st).sqrt(),F?this.t=st.clone().div(this.s.get(0,0)):this.t=st,this.xResidual=D.sub(st.mmul(Et.transpose()))}}ne.XA=B,ne.a_=nu,ne.yQ=nu,ne.Hs=nn,ne.Ec=gs,ne.dx=gs,ne.LU=pn,ne.Rm=pn,ne.y3=ht,ne.qK=Fe,ne.pb=te,ne.j=Xe,ne.sO=Pe,ne.BZ=Ke,ne.EK=Ie,ne.Db=lt,ne.Fx=qe,ne.tU=pt,ne.Ym=Du,ne.rs=Du,ne.QR=Rn,ne.TB=Rn,ne.oH=bi,ne.Sc=bi,ne.BN=en,ne.it=Ct,ne.$r=Xt,ne.QM=as,ne.AV=Is,w=ht,ne.GH=Vi,ne.SO=Lr,ne.uZ=ir,ne.yU=ms,ne.F1=Qn,ne.re=Qt},22150:function(ae,ne,b){"use strict";b.d(ne,{default:function(){return U}});var w=b(74902),k=b(94184),O=b.n(k),A=b(38379),S=b(67294),R=b(33603),x=b(65223);function E(_){const[F,X]=S.useState(_);return S.useEffect(()=>{const De=setTimeout(()=>{X(_)},_.length?0:10);return()=>{clearTimeout(De)}},[_]),F}var N=b(14747),L=b(50438),P=b(33507),W=b(45503),K=b(67968),ye=_=>{const{componentCls:F}=_,X=`${F}-show-help`,De=`${F}-show-help-item`;return{[X]:{transition:`opacity ${_.motionDurationSlow} ${_.motionEaseInOut}`,"&-appear, &-enter":{opacity:0,"&-active":{opacity:1}},"&-leave":{opacity:1,"&-active":{opacity:0}},[De]:{overflow:"hidden",transition:`height ${_.motionDurationSlow} ${_.motionEaseInOut}, opacity ${_.motionDurationSlow} ${_.motionEaseInOut}, transform ${_.motionDurationSlow} ${_.motionEaseInOut} !important`,[`&${De}-appear, &${De}-enter`]:{transform:"translateY(-5px)",opacity:0,"&-active":{transform:"translateY(0)",opacity:1}},[`&${De}-leave-active`]:{transform:"translateY(-5px)"}}}}};const ge=_=>({legend:{display:"block",width:"100%",marginBottom:_.marginLG,padding:0,color:_.colorTextDescription,fontSize:_.fontSizeLG,lineHeight:"inherit",border:0,borderBottom:`${_.lineWidth}px ${_.lineType} ${_.colorBorder}`},label:{fontSize:_.fontSize},'input[type="search"]':{boxSizing:"border-box"},'input[type="radio"], input[type="checkbox"]':{lineHeight:"normal"},'input[type="file"]':{display:"block"},'input[type="range"]':{display:"block",width:"100%"},"select[multiple], select[size]":{height:"auto"},"input[type='file']:focus,\n input[type='radio']:focus,\n input[type='checkbox']:focus":{outline:0,boxShadow:`0 0 0 ${_.controlOutlineWidth}px ${_.controlOutline}`},output:{display:"block",paddingTop:15,color:_.colorText,fontSize:_.fontSize,lineHeight:_.lineHeight}}),ce=(_,F)=>{const{formItemCls:X}=_;return{[X]:{[`${X}-label > label`]:{height:F},[`${X}-control-input`]:{minHeight:F}}}},xe=_=>{const{componentCls:F}=_;return{[_.componentCls]:Object.assign(Object.assign(Object.assign({},(0,N.Wf)(_)),ge(_)),{[`${F}-text`]:{display:"inline-block",paddingInlineEnd:_.paddingSM},"&-small":Object.assign({},ce(_,_.controlHeightSM)),"&-large":Object.assign({},ce(_,_.controlHeightLG))})}},fe=_=>{const{formItemCls:F,iconCls:X,componentCls:De,rootPrefixCls:Ve,labelRequiredMarkColor:it,labelColor:st,labelFontSize:Ht,labelHeight:Et,labelColonMarginInlineStart:on,labelColonMarginInlineEnd:Un,itemMarginBottom:sn}=_;return{[F]:Object.assign(Object.assign({},(0,N.Wf)(_)),{marginBottom:sn,verticalAlign:"top","&-with-help":{transition:"none"},[`&-hidden, &-hidden.${Ve}-row`]:{display:"none"},"&-has-warning":{[`${F}-split`]:{color:_.colorError}},"&-has-error":{[`${F}-split`]:{color:_.colorWarning}},[`${F}-label`]:{flexGrow:0,overflow:"hidden",whiteSpace:"nowrap",textAlign:"end",verticalAlign:"middle","&-left":{textAlign:"start"},"&-wrap":{overflow:"unset",lineHeight:`${_.lineHeight} - 0.25em`,whiteSpace:"unset"},"> label":{position:"relative",display:"inline-flex",alignItems:"center",maxWidth:"100%",height:Et,color:st,fontSize:Ht,[`> ${X}`]:{fontSize:_.fontSize,verticalAlign:"top"},[`&${F}-required:not(${F}-required-mark-optional)::before`]:{display:"inline-block",marginInlineEnd:_.marginXXS,color:it,fontSize:_.fontSize,fontFamily:"SimSun, sans-serif",lineHeight:1,content:'"*"',[`${De}-hide-required-mark &`]:{display:"none"}},[`${F}-optional`]:{display:"inline-block",marginInlineStart:_.marginXXS,color:_.colorTextDescription,[`${De}-hide-required-mark &`]:{display:"none"}},[`${F}-tooltip`]:{color:_.colorTextDescription,cursor:"help",writingMode:"horizontal-tb",marginInlineStart:_.marginXXS},"&::after":{content:'":"',position:"relative",marginBlock:0,marginInlineStart:on,marginInlineEnd:Un},[`&${F}-no-colon::after`]:{content:'"\\a0"'}}},[`${F}-control`]:{"--ant-display":"flex",flexDirection:"column",flexGrow:1,[`&:first-child:not([class^="'${Ve}-col-'"]):not([class*="' ${Ve}-col-'"])`]:{width:"100%"},"&-input":{position:"relative",display:"flex",alignItems:"center",minHeight:_.controlHeight,"&-content":{flex:"auto",maxWidth:"100%"}}},[F]:{"&-explain, &-extra":{clear:"both",color:_.colorTextDescription,fontSize:_.fontSize,lineHeight:_.lineHeight},"&-explain-connected":{width:"100%"},"&-extra":{minHeight:_.controlHeightSM,transition:`color ${_.motionDurationMid} ${_.motionEaseOut}`},"&-explain":{"&-error":{color:_.colorError},"&-warning":{color:_.colorWarning}}},[`&-with-help ${F}-explain`]:{height:"auto",opacity:1},[`${F}-feedback-icon`]:{fontSize:_.fontSize,textAlign:"center",visibility:"visible",animationName:L.kr,animationDuration:_.motionDurationMid,animationTimingFunction:_.motionEaseOutBack,pointerEvents:"none","&-success":{color:_.colorSuccess},"&-error":{color:_.colorError},"&-warning":{color:_.colorWarning},"&-validating":{color:_.colorPrimary}}})}},Ne=_=>{const{componentCls:F,formItemCls:X}=_;return{[`${F}-horizontal`]:{[`${X}-label`]:{flexGrow:0},[`${X}-control`]:{flex:"1 1 0",minWidth:0},[`${X}-label[class$='-24'], ${X}-label[class*='-24 ']`]:{[`& + ${X}-control`]:{minWidth:"unset"}}}}},Ae=_=>{const{componentCls:F,formItemCls:X}=_;return{[`${F}-inline`]:{display:"flex",flexWrap:"wrap",[X]:{flex:"none",marginInlineEnd:_.margin,marginBottom:0,"&-row":{flexWrap:"nowrap"},[`> ${X}-label, > ${X}-control`]:{display:"inline-block",verticalAlign:"top"},[`> ${X}-label`]:{flex:"none"},[`${F}-text`]:{display:"inline-block"},[`${X}-has-feedback`]:{display:"inline-block"}}}}},be=_=>({padding:_.verticalLabelPadding,margin:_.verticalLabelMargin,whiteSpace:"initial",textAlign:"start","> label":{margin:0,"&::after":{visibility:"hidden"}}}),Ye=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:De}=_;return{[`${X} ${X}-label`]:be(_),[F]:{[X]:{flexWrap:"wrap",[`${X}-label, ${X}-control`]:{[`&:not([class*=" ${De}-col-xs"])`]:{flex:"0 0 100%",maxWidth:"100%"}}}}}},Ee=_=>{const{componentCls:F,formItemCls:X,rootPrefixCls:De}=_;return{[`${F}-vertical`]:{[X]:{"&-row":{flexDirection:"column"},"&-label > label":{height:"auto"},[`${F}-item-control`]:{width:"100%"}}},[`${F}-vertical ${X}-label, .${De}-col-24${X}-label, .${De}-col-xl-24${X}-label`]:be(_),[`@media (max-width: ${_.screenXSMax}px)`]:[Ye(_),{[F]:{[`.${De}-col-xs-24${X}-label`]:be(_)}}],[`@media (max-width: ${_.screenSMMax}px)`]:{[F]:{[`.${De}-col-sm-24${X}-label`]:be(_)}},[`@media (max-width: ${_.screenMDMax}px)`]:{[F]:{[`.${De}-col-md-24${X}-label`]:be(_)}},[`@media (max-width: ${_.screenLGMax}px)`]:{[F]:{[`.${De}-col-lg-24${X}-label`]:be(_)}}}},We=(_,F)=>(0,W.TS)(_,{formItemCls:`${_.componentCls}-item`,rootPrefixCls:F});var je=(0,K.Z)("Form",(_,F)=>{let{rootPrefixCls:X}=F;const De=We(_,X);return[xe(De),fe(De),ye(De),Ne(De),Ae(De),Ee(De),(0,P.Z)(De),L.kr]},_=>({labelRequiredMarkColor:_.colorError,labelColor:_.colorTextHeading,labelFontSize:_.fontSize,labelHeight:_.controlHeight,labelColonMarginInlineStart:_.marginXXS/2,labelColonMarginInlineEnd:_.marginXS,itemMarginBottom:_.marginLG,verticalLabelPadding:`0 0 ${_.paddingXS}px`,verticalLabelMargin:0}),{order:-1e3});const _t=[];function It(_,F,X){let De=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;return{key:typeof _=="string"?_:`${F}-${De}`,error:_,errorStatus:X}}var Ut=_=>{let{help:F,helpStatus:X,errors:De=_t,warnings:Ve=_t,className:it,fieldId:st,onVisibleChanged:Ht}=_;const{prefixCls:Et}=S.useContext(x.Rk),on=`${Et}-item-explain`,[,Un]=je(Et),sn=(0,S.useMemo)(()=>(0,R.Z)(Et),[Et]),bn=E(De),ti=E(Ve),Bt=S.useMemo(()=>F!=null?[It(F,"help",X)]:[].concat((0,w.Z)(bn.map((ni,Pi)=>It(ni,"error","error",Pi))),(0,w.Z)(ti.map((ni,Pi)=>It(ni,"warning","warning",Pi)))),[F,X,bn,ti]),$n={};return st&&($n.id=`${st}_help`),S.createElement(A.default,{motionDeadline:sn.motionDeadline,motionName:`${Et}-show-help`,visible:!!Bt.length,onVisibleChanged:Ht},ni=>{const{className:Pi,style:ui}=ni;return S.createElement("div",Object.assign({},$n,{className:O()(on,Pi,it,Un),style:ui,role:"alert"}),S.createElement(A.CSSMotionList,Object.assign({keys:Bt},(0,R.Z)(Et),{motionName:`${Et}-show-help-item`,component:!1}),Ir=>{const{key:yi,error:vi,errorStatus:Mr,className:Zt,style:Fn}=Ir;return S.createElement("div",{key:yi,className:O()(Zt,{[`${on}-${Mr}`]:Mr}),style:Fn},vi)}))})},At=b(46660),at=b(53124),Ot=b(98866),ue=b(97647),Ue=b(98675),vt=b(17423);const Jt=["parentNode"],Qe="form_item";function rt(_){return _===void 0||_===!1?[]:Array.isArray(_)?_:[_]}function bt(_,F){if(!_.length)return;const X=_.join("_");return F?`${F}_${X}`:Jt.includes(X)?`${Qe}_${X}`:X}function ze(_,F,X,De,Ve,it){let st=De;return it!==void 0?st=it:X.validating?st="validating":_.length?st="error":F.length?st="warning":(X.touched||Ve&&X.validated)&&(st="success"),st}function Ze(_){return rt(_).join("_")}function q(_){const[F]=(0,At.useForm)(),X=S.useRef({}),De=S.useMemo(()=>_!=null?_:Object.assign(Object.assign({},F),{__INTERNAL__:{itemRef:Ve=>it=>{const st=Ze(Ve);it?X.current[st]=it:delete X.current[st]}},scrollToField:function(Ve){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const st=rt(Ve),Ht=bt(st,De.__INTERNAL__.name),Et=Ht?document.getElementById(Ht):null;Et&&(0,vt.Z)(Et,Object.assign({scrollMode:"if-needed",block:"nearest"},it))},getFieldInstance:Ve=>{const it=Ze(Ve);return X.current[it]}}),[_,F]);return[De]}var Y=b(37920),de=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve{const X=S.useContext(Ot.Z),{getPrefixCls:De,direction:Ve,form:it}=S.useContext(at.E_),{prefixCls:st,className:Ht,rootClassName:Et,size:on,disabled:Un=X,form:sn,colon:bn,labelAlign:ti,labelWrap:Bt,labelCol:$n,wrapperCol:ni,hideRequiredMark:Pi,layout:ui="horizontal",scrollToFirstError:Ir,requiredMark:yi,onFinishFailed:vi,name:Mr,style:Zt,feedbackIcons:Fn}=_,hi=de(_,["prefixCls","className","rootClassName","size","disabled","form","colon","labelAlign","labelWrap","labelCol","wrapperCol","hideRequiredMark","layout","scrollToFirstError","requiredMark","onFinishFailed","name","style","feedbackIcons"]),Xn=(0,Ue.Z)(on),hs=S.useContext(Y.Z),Xr=(0,S.useMemo)(()=>yi!==void 0?yi:it&&it.requiredMark!==void 0?it.requiredMark:!Pi,[Pi,yi,it]),ys=bn!=null?bn:it==null?void 0:it.colon,Ur=De("form",st),[Os,no]=je(Ur),io=O()(Ur,`${Ur}-${ui}`,{[`${Ur}-hide-required-mark`]:Xr===!1,[`${Ur}-rtl`]:Ve==="rtl",[`${Ur}-${Xn}`]:Xn},no,it==null?void 0:it.className,Ht,Et),[So]=q(sn),{__INTERNAL__:To}=So;To.name=Mr;const Gr=(0,S.useMemo)(()=>({name:Mr,labelAlign:ti,labelCol:$n,labelWrap:Bt,wrapperCol:ni,vertical:ui==="vertical",colon:ys,requiredMark:Xr,itemRef:To.itemRef,form:So,feedbackIcons:Fn}),[Mr,ti,$n,ni,ui,ys,Xr,So,Fn]);S.useImperativeHandle(F,()=>So);const Qs=(ro,qr)=>{if(ro){let la={block:"nearest"};typeof ro=="object"&&(la=ro),So.scrollToField(qr,la)}},Eo=ro=>{if(vi==null||vi(ro),ro.errorFields.length){const qr=ro.errorFields[0].name;if(Ir!==void 0){Qs(Ir,qr);return}it&&it.scrollToFirstError!==void 0&&Qs(it.scrollToFirstError,qr)}};return Os(S.createElement(Ot.n,{disabled:Un},S.createElement(ue.q,{size:Xn},S.createElement(x.RV,Object.assign({},{validateMessages:hs}),S.createElement(x.q3.Provider,{value:Gr},S.createElement(At.default,Object.assign({id:Mr},hi,{name:Mr,onFinishFailed:Eo,form:So,style:Object.assign(Object.assign({},it==null?void 0:it.style),Zt),className:io})))))))};var $e=S.forwardRef(Je),xt=b(9475),ke=b(17799),et=b(96159),yt=b(37419);function B(_){if(typeof _=="function")return _;const F=(0,yt.Z)(_);return F.length<=1?F[0]:F}const ie=()=>{const{status:_,errors:F=[],warnings:X=[]}=(0,S.useContext)(x.aM);return{status:_,errors:F,warnings:X}};ie.Context=x.aM;var ct=ie,Mt=b(96523);function ht(_){const[F,X]=S.useState(_),De=(0,S.useRef)(null),Ve=(0,S.useRef)([]),it=(0,S.useRef)(!1);S.useEffect(()=>(it.current=!1,()=>{it.current=!0,Mt.Z.cancel(De.current),De.current=null}),[]);function st(Ht){it.current||(De.current===null&&(Ve.current=[],De.current=(0,Mt.Z)(()=>{De.current=null,X(Et=>{let on=Et;return Ve.current.forEach(Un=>{on=Un(on)}),on})})),Ve.current.push(Ht))}return[F,st]}function Yt(){const{itemRef:_}=S.useContext(x.q3),F=S.useRef({});function X(De,Ve){const it=Ve&&typeof Ve=="object"&&Ve.ref,st=De.join("_");return(F.current.name!==st||F.current.originRef!==it)&&(F.current.name=st,F.current.originRef=it,F.current.ref=(0,ke.sQ)(_(De),it)),F.current.ref}return X}var en=b(48130),nn=b(14075),Me=b(10366),te=b(92820),Fe=b(21584);const Xe=_=>{const{formItemCls:F}=_;return{"@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)":{[`${F}-control`]:{display:"flex"}}}};var Pe=(0,K.b)(["Form","item-item"],(_,F)=>{let{rootPrefixCls:X}=F;const De=We(_,X);return[Xe(De)]}),Ke=_=>{const{prefixCls:F,status:X,wrapperCol:De,children:Ve,errors:it,warnings:st,_internalItemRender:Ht,extra:Et,help:on,fieldId:Un,marginBottom:sn,onErrorVisibleChanged:bn}=_,ti=`${F}-item`,Bt=S.useContext(x.q3),$n=De||Bt.wrapperCol||{},ni=O()(`${ti}-control`,$n.className),Pi=S.useMemo(()=>Object.assign({},Bt),[Bt]);delete Pi.labelCol,delete Pi.wrapperCol;const ui=S.createElement("div",{className:`${ti}-control-input`},S.createElement("div",{className:`${ti}-control-input-content`},Ve)),Ir=S.useMemo(()=>({prefixCls:F,status:X}),[F,X]),yi=sn!==null||it.length||st.length?S.createElement("div",{style:{display:"flex",flexWrap:"nowrap"}},S.createElement(x.Rk.Provider,{value:Ir},S.createElement(Ut,{fieldId:Un,errors:it,warnings:st,help:on,helpStatus:X,className:`${ti}-explain-connected`,onVisibleChanged:bn})),!!sn&&S.createElement("div",{style:{width:0,height:sn}})):null,vi={};Un&&(vi.id=`${Un}_extra`);const Mr=Et?S.createElement("div",Object.assign({},vi,{className:`${ti}-extra`}),Et):null,Zt=Ht&&Ht.mark==="pro_table_render"&&Ht.render?Ht.render(_,{input:ui,errorList:yi,extra:Mr}):S.createElement(S.Fragment,null,ui,yi,Mr);return S.createElement(x.q3.Provider,{value:Pi},S.createElement(Fe.Z,Object.assign({},$n,{className:ni}),Zt),S.createElement(Pe,{prefixCls:F}))},lt=b(17663),qe=b(24457),pt=b(10110),Ct=b(83062),Xt=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve{let{prefixCls:F,label:X,htmlFor:De,labelCol:Ve,labelAlign:it,colon:st,required:Ht,requiredMark:Et,tooltip:on}=_;var Un;const[sn]=(0,pt.Z)("Form"),{vertical:bn,labelAlign:ti,labelCol:Bt,labelWrap:$n,colon:ni}=S.useContext(x.q3);if(!X)return null;const Pi=Ve||Bt||{},ui=it||ti,Ir=`${F}-item-label`,yi=O()(Ir,ui==="left"&&`${Ir}-left`,Pi.className,{[`${Ir}-wrap`]:!!$n});let vi=X;const Mr=st===!0||ni!==!1&&st!==!1;Mr&&!bn&&typeof X=="string"&&X.trim()!==""&&(vi=X.replace(/[:|:]\s*$/,""));const Fn=Qt(on);if(Fn){const{icon:Xr=S.createElement(lt.Z,null)}=Fn,ys=Xt(Fn,["icon"]),Ur=S.createElement(Ct.Z,Object.assign({},ys),S.cloneElement(Xr,{className:`${F}-item-tooltip`,title:""}));vi=S.createElement(S.Fragment,null,vi,Ur)}const hi=Et==="optional",Xn=typeof Et=="function";Xn?vi=Et(vi,{required:!!Ht}):hi&&!Ht&&(vi=S.createElement(S.Fragment,null,vi,S.createElement("span",{className:`${F}-item-optional`,title:""},(sn==null?void 0:sn.optional)||((Un=qe.Z.Form)===null||Un===void 0?void 0:Un.optional))));const hs=O()({[`${F}-item-required`]:Ht,[`${F}-item-required-mark-optional`]:hi||Xn,[`${F}-item-no-colon`]:!Mr});return S.createElement(Fe.Z,Object.assign({},Pi,{className:yi}),S.createElement("label",{htmlFor:De,className:hs,title:typeof X=="string"?X:""},vi))},Rn=b(87725),bi=b(16646),Lr=b(87995),Qn=b(3407);const Vi={success:Rn.Z,warning:Lr.Z,error:bi.Z,validating:Qn.Z};function Oi(_){let{children:F,errors:X,warnings:De,hasFeedback:Ve,validateStatus:it,prefixCls:st,meta:Ht,noStyle:Et}=_;const on=`${st}-item`,{feedbackIcons:Un}=S.useContext(x.q3),sn=ze(X,De,Ht,null,!!Ve,it),{isFormItemInput:bn,status:ti}=S.useContext(x.aM),Bt=S.useMemo(()=>{var $n;let ni;if(Ve){const Ir=Ve!==!0&&Ve.icons||Un,yi=sn&&(($n=Ir==null?void 0:Ir({status:sn,errors:X,warnings:De}))===null||$n===void 0?void 0:$n[sn]),vi=sn&&Vi[sn];ni=yi!==!1&&vi?S.createElement("span",{className:O()(`${on}-feedback-icon`,`${on}-feedback-icon-${sn}`)},yi||S.createElement(vi,null)):null}let Pi=!0,ui=sn||"";return Et&&(Pi=bn,ui=(sn!=null?sn:ti)||""),{status:ui,errors:X,warnings:De,hasFeedback:!!Ve,feedbackIcon:ni,isFormItemInput:Pi}},[sn,Ve,Et,bn,ti]);return S.createElement(x.aM.Provider,{value:Bt},F)}var Gi=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve{if(Fn&&yi.current){const no=getComputedStyle(yi.current);hs(parseInt(no.marginBottom,10))}},[Fn,hi]);const Xr=no=>{no||hs(null)},Ur=function(){let no=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;const io=no?vi:on.errors,So=no?Mr:on.warnings;return ze(io,So,on,"",!!Un,Et)}(),Os=O()(ui,X,De,{[`${ui}-with-help`]:Zt||vi.length||Mr.length,[`${ui}-has-feedback`]:Ur&&Un,[`${ui}-has-success`]:Ur==="success",[`${ui}-has-warning`]:Ur==="warning",[`${ui}-has-error`]:Ur==="error",[`${ui}-is-validating`]:Ur==="validating",[`${ui}-hidden`]:sn});return S.createElement("div",{className:Os,style:Ve,ref:yi},S.createElement(te.Z,Object.assign({className:`${ui}-row`},(0,Me.Z)(Pi,["_internalItemRender","colon","dependencies","extra","fieldKey","getValueFromEvent","getValueProps","htmlFor","id","initialValue","isListField","label","labelAlign","labelCol","labelWrap","messageVariables","name","normalize","noStyle","preserve","requiredMark","rules","shouldUpdate","trigger","tooltip","validateFirst","validateTrigger","valuePropName","wrapperCol","validateDebounce"])),S.createElement(Wn,Object.assign({htmlFor:ti},_,{requiredMark:Ir,required:Bt!=null?Bt:$n,prefixCls:F})),S.createElement(Ke,Object.assign({},_,on,{errors:vi,warnings:Mr,prefixCls:F,status:Ur,help:it,marginBottom:Xn,onErrorVisibleChanged:Xr}),S.createElement(x.qI.Provider,{value:ni},S.createElement(Oi,{prefixCls:F,meta:on,errors:on.errors,warnings:on.warnings,hasFeedback:Un,validateStatus:Ur},bn)))),!!Xn&&S.createElement("div",{className:`${ui}-margin-offset`,style:{marginBottom:-Xn}}))}const ms="__SPLIT__",Is=null,as=S.memo(_=>{let{children:F}=_;return F},(_,F)=>_.value===F.value&&_.update===F.update&&_.childProps.length===F.childProps.length&&_.childProps.every((X,De)=>X===F.childProps[De]));function gs(_){return _!=null}function Vs(){return{errors:[],warnings:[],touched:!1,validating:!1,name:[],validated:!1}}function Xl(_){const{name:F,noStyle:X,className:De,dependencies:Ve,prefixCls:it,shouldUpdate:st,rules:Ht,children:Et,required:on,label:Un,messageVariables:sn,trigger:bn="onChange",validateTrigger:ti,hidden:Bt,help:$n}=_,{getPrefixCls:ni}=S.useContext(at.E_),{name:Pi}=S.useContext(x.q3),ui=B(Et),Ir=typeof ui=="function",yi=S.useContext(x.qI),{validateTrigger:vi}=S.useContext(At.FieldContext),Mr=ti!==void 0?ti:vi,Zt=gs(F),Fn=ni("form",it),[hi,Xn]=je(Fn),hs=S.useContext(At.ListContext),Xr=S.useRef(),[ys,Ur]=ht({}),[Os,no]=(0,xt.Z)(()=>Vs()),io=qr=>{const la=hs==null?void 0:hs.getKey(qr.name);if(no(qr.destroy?Vs():qr,!0),X&&$n!==!1&&yi){let Ao=qr.name;if(qr.destroy)Ao=Xr.current||Ao;else if(la!==void 0){const[il,rl]=la;Ao=[il].concat((0,w.Z)(rl)),Xr.current=Ao}yi(qr,Ao)}},So=(qr,la)=>{Ur(Ao=>{const il=Object.assign({},Ao),ca=[].concat((0,w.Z)(qr.name.slice(0,-1)),(0,w.Z)(la)).join(ms);return qr.destroy?delete il[ca]:il[ca]=qr,il})},[To,Gr]=S.useMemo(()=>{const qr=(0,w.Z)(Os.errors),la=(0,w.Z)(Os.warnings);return Object.values(ys).forEach(Ao=>{qr.push.apply(qr,(0,w.Z)(Ao.errors||[])),la.push.apply(la,(0,w.Z)(Ao.warnings||[]))}),[qr,la]},[ys,Os.errors,Os.warnings]),Qs=Yt();function Eo(qr,la,Ao){return X&&!Bt?S.createElement(Oi,{prefixCls:Fn,hasFeedback:_.hasFeedback,validateStatus:_.validateStatus,meta:Os,errors:To,warnings:Gr,noStyle:!0},qr):S.createElement(ir,Object.assign({key:"row"},_,{className:O()(De,Xn),prefixCls:Fn,fieldId:la,isRequired:Ao,errors:To,warnings:Gr,meta:Os,onSubItemMetaChange:So}),qr)}if(!Zt&&!Ir&&!Ve)return hi(Eo(ui));let ro={};return typeof Un=="string"?ro.label=Un:F&&(ro.label=String(F)),sn&&(ro=Object.assign(Object.assign({},ro),sn)),hi(S.createElement(At.Field,Object.assign({},_,{messageVariables:ro,trigger:bn,validateTrigger:Mr,onMetaChange:io}),(qr,la,Ao)=>{const il=rt(F).length&&la?la.name:[],rl=bt(il,Pi),ca=on!==void 0?on:!!(Ht&&Ht.some(bo=>{if(bo&&typeof bo=="object"&&bo.required&&!bo.warningOnly)return!0;if(typeof bo=="function"){const Pc=bo(Ao);return Pc&&Pc.required&&!Pc.warningOnly}return!1})),Oa=Object.assign({},qr);let sl=null;if(Array.isArray(ui)&&Zt)sl=ui;else if(!(Ir&&(!(st||Ve)||Zt))){if(!(Ve&&!Ir&&!Zt))if((0,et.l$)(ui)){const bo=Object.assign(Object.assign({},ui.props),Oa);if(bo.id||(bo.id=rl),$n||To.length>0||Gr.length>0||_.extra){const oh=[];($n||To.length>0)&&oh.push(`${rl}_help`),_.extra&&oh.push(`${rl}_extra`),bo["aria-describedby"]=oh.join(" ")}To.length>0&&(bo["aria-invalid"]="true"),ca&&(bo["aria-required"]="true"),(0,ke.Yr)(ui)&&(bo.ref=Qs(il,ui)),new Set([].concat((0,w.Z)(rt(bn)),(0,w.Z)(rt(Mr)))).forEach(oh=>{bo[oh]=function(){for(var y0,Jf,Qf,v0,Pm,$a=arguments.length,jd=new Array($a),Qo=0;Qo<$a;Qo++)jd[Qo]=arguments[Qo];(Qf=Oa[oh])===null||Qf===void 0||(y0=Qf).call.apply(y0,[Oa].concat(jd)),(Pm=(v0=ui.props)[oh])===null||Pm===void 0||(Jf=Pm).call.apply(Jf,[v0].concat(jd))}});const Qv=[bo["aria-required"],bo["aria-invalid"],bo["aria-describedby"]];sl=S.createElement(as,{value:Oa[_.valuePropName||"value"],update:ui,childProps:Qv},(0,et.Tm)(ui,bo))}else Ir&&(st||Ve)&&!Zt?sl=ui(Ao):sl=ui}return Eo(sl,rl,ca)}))}const ql=Xl;ql.useStatus=ct;var Da=ql,Dl=function(_,F){var X={};for(var De in _)Object.prototype.hasOwnProperty.call(_,De)&&F.indexOf(De)<0&&(X[De]=_[De]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ve=0,De=Object.getOwnPropertySymbols(_);Ve{var{prefixCls:F,children:X}=_,De=Dl(_,["prefixCls","children"]);const{getPrefixCls:Ve}=S.useContext(at.E_),it=Ve("form",F),st=S.useMemo(()=>({prefixCls:it,status:"error"}),[it]);return S.createElement(At.List,Object.assign({},De),(Ht,Et,on)=>S.createElement(x.Rk.Provider,{value:st},X(Ht.map(Un=>Object.assign(Object.assign({},Un),{fieldKey:Un.key})),Et,{errors:on.errors,warnings:on.warnings})))};function Le(){const{form:_}=(0,S.useContext)(x.q3);return _}const D=$e;D.Item=Da,D.List=Du,D.ErrorList=Ut,D.useForm=q,D.useFormInstance=Le,D.useWatch=At.useWatch,D.Provider=x.RV,D.create=()=>{};var U=D},78045:function(ae,ne,b){"use strict";b.d(ne,{ZP:function(){return Jt}});var w=b(94184),k=b.n(w),O=b(5663),A=b(1337),S=b(67294),R=b(53124),x=b(98675);const E=S.createContext(null),N=E.Provider;var L=E;const P=S.createContext(null),W=P.Provider;var K=b(95860),re=b(17799),ye=b(98866),ge=b(65223),ce=b(14747),xe=b(67968),fe=b(45503);const Ne=Qe=>{const{componentCls:rt,antCls:bt}=Qe,ze=`${rt}-group`;return{[ze]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{display:"inline-block",fontSize:0,[`&${ze}-rtl`]:{direction:"rtl"},[`${bt}-badge ${bt}-badge-count`]:{zIndex:1},[`> ${bt}-badge:not(:first-child) > ${bt}-button-wrapper`]:{borderInlineStart:"none"}})}},Ae=Qe=>{const{componentCls:rt,wrapperMarginInlineEnd:bt,colorPrimary:ze,radioSize:Ze,motionDurationSlow:q,motionDurationMid:Y,motionEaseInOutCirc:de,colorBgContainer:Je,colorBorder:Te,lineWidth:$e,dotSize:xt,colorBgContainerDisabled:ke,colorTextDisabled:et,paddingXS:yt,dotColorDisabled:B,lineType:ie,radioDotDisabledSize:ct,wireframe:Mt,colorWhite:ht}=Qe,Yt=`${rt}-inner`;return{[`${rt}-wrapper`]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{display:"inline-flex",alignItems:"baseline",marginInlineStart:0,marginInlineEnd:bt,cursor:"pointer",[`&${rt}-wrapper-rtl`]:{direction:"rtl"},"&-disabled":{cursor:"not-allowed",color:Qe.colorTextDisabled},"&::after":{display:"inline-block",width:0,overflow:"hidden",content:'"\\a0"'},[`${rt}-checked::after`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,width:"100%",height:"100%",border:`${$e}px ${ie} ${ze}`,borderRadius:"50%",visibility:"hidden",content:'""'},[rt]:Object.assign(Object.assign({},(0,ce.Wf)(Qe)),{position:"relative",display:"inline-block",outline:"none",cursor:"pointer",alignSelf:"center",borderRadius:"50%"}),[`${rt}-wrapper:hover &, &:hover ${Yt}`]:{borderColor:ze},[`${rt}-input:focus-visible + ${Yt}`]:Object.assign({},(0,ce.oN)(Qe)),[`${rt}:hover::after, ${rt}-wrapper:hover &::after`]:{visibility:"visible"},[`${rt}-inner`]:{"&::after":{boxSizing:"border-box",position:"absolute",insetBlockStart:"50%",insetInlineStart:"50%",display:"block",width:Ze,height:Ze,marginBlockStart:Ze/-2,marginInlineStart:Ze/-2,backgroundColor:Mt?ze:ht,borderBlockStart:0,borderInlineStart:0,borderRadius:Ze,transform:"scale(0)",opacity:0,transition:`all ${q} ${de}`,content:'""'},boxSizing:"border-box",position:"relative",insetBlockStart:0,insetInlineStart:0,display:"block",width:Ze,height:Ze,backgroundColor:Je,borderColor:Te,borderStyle:"solid",borderWidth:$e,borderRadius:"50%",transition:`all ${Y}`},[`${rt}-input`]:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",opacity:0},[`${rt}-checked`]:{[Yt]:{borderColor:ze,backgroundColor:Mt?Je:ze,"&::after":{transform:`scale(${xt/Ze})`,opacity:1,transition:`all ${q} ${de}`}}},[`${rt}-disabled`]:{cursor:"not-allowed",[Yt]:{backgroundColor:ke,borderColor:Te,cursor:"not-allowed","&::after":{backgroundColor:B}},[`${rt}-input`]:{cursor:"not-allowed"},[`${rt}-disabled + span`]:{color:et,cursor:"not-allowed"},[`&${rt}-checked`]:{[Yt]:{"&::after":{transform:`scale(${ct/Ze})`}}}},[`span${rt} + *`]:{paddingInlineStart:yt,paddingInlineEnd:yt}})}},be=Qe=>{const{buttonColor:rt,controlHeight:bt,componentCls:ze,lineWidth:Ze,lineType:q,colorBorder:Y,motionDurationSlow:de,motionDurationMid:Je,buttonPaddingInline:Te,fontSize:$e,buttonBg:xt,fontSizeLG:ke,controlHeightLG:et,controlHeightSM:yt,paddingXS:B,borderRadius:ie,borderRadiusSM:ct,borderRadiusLG:Mt,buttonCheckedBg:ht,buttonSolidCheckedColor:Yt,colorTextDisabled:en,colorBgContainerDisabled:nn,buttonCheckedBgDisabled:Me,buttonCheckedColorDisabled:te,colorPrimary:Fe,colorPrimaryHover:Xe,colorPrimaryActive:Pe,buttonSolidCheckedBg:Ie,buttonSolidCheckedHoverBg:Ke,buttonSolidCheckedActiveBg:lt}=Qe;return{[`${ze}-button-wrapper`]:{position:"relative",display:"inline-block",height:bt,margin:0,paddingInline:Te,paddingBlock:0,color:rt,fontSize:$e,lineHeight:`${bt-Ze*2}px`,background:xt,border:`${Ze}px ${q} ${Y}`,borderBlockStartWidth:Ze+.02,borderInlineStartWidth:0,borderInlineEndWidth:Ze,cursor:"pointer",transition:[`color ${Je}`,`background ${Je}`,`box-shadow ${Je}`].join(","),a:{color:rt},[`> ${ze}-button`]:{position:"absolute",insetBlockStart:0,insetInlineStart:0,zIndex:-1,width:"100%",height:"100%"},"&:not(:first-child)":{"&::before":{position:"absolute",insetBlockStart:-Ze,insetInlineStart:-Ze,display:"block",boxSizing:"content-box",width:1,height:"100%",paddingBlock:Ze,paddingInline:0,backgroundColor:Y,transition:`background-color ${de}`,content:'""'}},"&:first-child":{borderInlineStart:`${Ze}px ${q} ${Y}`,borderStartStartRadius:ie,borderEndStartRadius:ie},"&:last-child":{borderStartEndRadius:ie,borderEndEndRadius:ie},"&:first-child:last-child":{borderRadius:ie},[`${ze}-group-large &`]:{height:et,fontSize:ke,lineHeight:`${et-Ze*2}px`,"&:first-child":{borderStartStartRadius:Mt,borderEndStartRadius:Mt},"&:last-child":{borderStartEndRadius:Mt,borderEndEndRadius:Mt}},[`${ze}-group-small &`]:{height:yt,paddingInline:B-Ze,paddingBlock:0,lineHeight:`${yt-Ze*2}px`,"&:first-child":{borderStartStartRadius:ct,borderEndStartRadius:ct},"&:last-child":{borderStartEndRadius:ct,borderEndEndRadius:ct}},"&:hover":{position:"relative",color:Fe},"&:has(:focus-visible)":Object.assign({},(0,ce.oN)(Qe)),[`${ze}-inner, input[type='checkbox'], input[type='radio']`]:{width:0,height:0,opacity:0,pointerEvents:"none"},[`&-checked:not(${ze}-button-wrapper-disabled)`]:{zIndex:1,color:Fe,background:ht,borderColor:Fe,"&::before":{backgroundColor:Fe},"&:first-child":{borderColor:Fe},"&:hover":{color:Xe,borderColor:Xe,"&::before":{backgroundColor:Xe}},"&:active":{color:Pe,borderColor:Pe,"&::before":{backgroundColor:Pe}}},[`${ze}-group-solid &-checked:not(${ze}-button-wrapper-disabled)`]:{color:Yt,background:Ie,borderColor:Ie,"&:hover":{color:Yt,background:Ke,borderColor:Ke},"&:active":{color:Yt,background:lt,borderColor:lt}},"&-disabled":{color:en,backgroundColor:nn,borderColor:Y,cursor:"not-allowed","&:first-child, &:hover":{color:en,backgroundColor:nn,borderColor:Y}},[`&-disabled${ze}-button-wrapper-checked`]:{color:te,backgroundColor:Me,borderColor:Y,boxShadow:"none"}}}},Ye=Qe=>Qe-4*2;var Ee=(0,xe.Z)("Radio",Qe=>{const{controlOutline:rt,controlOutlineWidth:bt,radioSize:ze}=Qe,Ze=`0 0 0 ${bt}px ${rt}`,q=Ze,Y=Ye(ze),de=(0,fe.TS)(Qe,{radioDotDisabledSize:Y,radioFocusShadow:Ze,radioButtonFocusShadow:q});return[Ne(de),Ae(de),be(de)]},Qe=>{const{wireframe:rt,padding:bt,marginXS:ze,lineWidth:Ze,fontSizeLG:q,colorText:Y,colorBgContainer:de,colorTextDisabled:Je,controlItemBgActiveDisabled:Te,colorTextLightSolid:$e,colorPrimary:xt,colorPrimaryHover:ke,colorPrimaryActive:et}=Qe,yt=4,B=q,ie=rt?Ye(B):B-(yt+Ze)*2;return{radioSize:B,dotSize:ie,dotColorDisabled:Je,buttonSolidCheckedColor:$e,buttonSolidCheckedBg:xt,buttonSolidCheckedHoverBg:ke,buttonSolidCheckedActiveBg:et,buttonBg:de,buttonCheckedBg:de,buttonColor:Y,buttonCheckedBgDisabled:Te,buttonCheckedColorDisabled:Je,buttonPaddingInline:bt-Ze,wrapperMarginInlineEnd:ze}}),We=b(45353),je=b(92429),_t=function(Qe,rt){var bt={};for(var ze in Qe)Object.prototype.hasOwnProperty.call(Qe,ze)&&rt.indexOf(ze)<0&&(bt[ze]=Qe[ze]);if(Qe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ze=0,ze=Object.getOwnPropertySymbols(Qe);Ze{var bt,ze;const Ze=S.useContext(L),q=S.useContext(P),{getPrefixCls:Y,direction:de,radio:Je}=S.useContext(R.E_),Te=S.useRef(null),$e=(0,re.sQ)(rt,Te),{isFormItemInput:xt}=S.useContext(ge.aM),ke=Pe=>{var Ie,Ke;(Ie=Qe.onChange)===null||Ie===void 0||Ie.call(Qe,Pe),(Ke=Ze==null?void 0:Ze.onChange)===null||Ke===void 0||Ke.call(Ze,Pe)},{prefixCls:et,className:yt,rootClassName:B,children:ie,style:ct}=Qe,Mt=_t(Qe,["prefixCls","className","rootClassName","children","style"]),ht=Y("radio",et),Yt=((Ze==null?void 0:Ze.optionType)||q)==="button",en=Yt?`${ht}-button`:ht,[nn,Me]=Ee(ht),te=Object.assign({},Mt),Fe=S.useContext(ye.Z);Ze&&(te.name=Ze.name,te.onChange=ke,te.checked=Qe.value===Ze.value,te.disabled=(bt=te.disabled)!==null&&bt!==void 0?bt:Ze.disabled),te.disabled=(ze=te.disabled)!==null&&ze!==void 0?ze:Fe;const Xe=k()(`${en}-wrapper`,{[`${en}-wrapper-checked`]:te.checked,[`${en}-wrapper-disabled`]:te.disabled,[`${en}-wrapper-rtl`]:de==="rtl",[`${en}-wrapper-in-form-item`]:xt},Je==null?void 0:Je.className,yt,B,Me);return nn(S.createElement(We.Z,{component:"Radio",disabled:te.disabled},S.createElement("label",{className:Xe,style:Object.assign(Object.assign({},Je==null?void 0:Je.style),ct),onMouseEnter:Qe.onMouseEnter,onMouseLeave:Qe.onMouseLeave},S.createElement(K.Z,Object.assign({},te,{className:k()(te.className,!Yt&&je.A),type:"radio",prefixCls:en,ref:$e})),ie!==void 0?S.createElement("span",null,ie):null)))};var Ut=S.forwardRef(It);const At=S.forwardRef((Qe,rt)=>{const{getPrefixCls:bt,direction:ze}=S.useContext(R.E_),[Ze,q]=(0,O.Z)(Qe.defaultValue,{value:Qe.value}),Y=Ie=>{const Ke=Ze,lt=Ie.target.value;"value"in Qe||q(lt);const{onChange:qe}=Qe;qe&<!==Ke&&qe(Ie)},{prefixCls:de,className:Je,rootClassName:Te,options:$e,buttonStyle:xt="outline",disabled:ke,children:et,size:yt,style:B,id:ie,onMouseEnter:ct,onMouseLeave:Mt,onFocus:ht,onBlur:Yt}=Qe,en=bt("radio",de),nn=`${en}-group`,[Me,te]=Ee(en);let Fe=et;$e&&$e.length>0&&(Fe=$e.map(Ie=>typeof Ie=="string"||typeof Ie=="number"?S.createElement(Ut,{key:Ie.toString(),prefixCls:en,disabled:ke,value:Ie,checked:Ze===Ie},Ie):S.createElement(Ut,{key:`radio-group-value-options-${Ie.value}`,prefixCls:en,disabled:Ie.disabled||ke,value:Ie.value,checked:Ze===Ie.value,title:Ie.title,style:Ie.style},Ie.label)));const Xe=(0,x.Z)(yt),Pe=k()(nn,`${nn}-${xt}`,{[`${nn}-${Xe}`]:Xe,[`${nn}-rtl`]:ze==="rtl"},Je,Te,te);return Me(S.createElement("div",Object.assign({},(0,A.Z)(Qe,{aria:!0,data:!0}),{className:Pe,style:B,onMouseEnter:ct,onMouseLeave:Mt,onFocus:ht,onBlur:Yt,id:ie,ref:rt}),S.createElement(N,{value:{onChange:Y,value:Ze,disabled:Qe.disabled,name:Qe.name,optionType:Qe.optionType}},Fe)))});var at=S.memo(At),Ot=function(Qe,rt){var bt={};for(var ze in Qe)Object.prototype.hasOwnProperty.call(Qe,ze)&&rt.indexOf(ze)<0&&(bt[ze]=Qe[ze]);if(Qe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Ze=0,ze=Object.getOwnPropertySymbols(Qe);Ze{const{getPrefixCls:bt}=S.useContext(R.E_),{prefixCls:ze}=Qe,Ze=Ot(Qe,["prefixCls"]),q=bt("radio",ze);return S.createElement(W,{value:"button"},S.createElement(Ut,Object.assign({prefixCls:q},Ze,{type:"radio",ref:rt})))};var Ue=S.forwardRef(ue);const vt=Ut;vt.Button=Ue,vt.Group=at,vt.__ANT_RADIO=!0;var Jt=vt},89558:function(ae,ne,b){"use strict";b.d(ne,{Ae:function(){return ce},CF:function(){return ht},vC:function(){return B},x1:function(){return R}});function w(Me,te,Fe,Xe,Pe,Ie){const Ke=Me,lt=te,qe=Fe-Ke,pt=Xe-lt;let Ct=Pe-Ke,Xt=Ie-lt,Qt=Ct*qe+Xt*pt,pn=0;Qt<=0?pn=0:(Ct=qe-Ct,Xt=pt-Xt,Qt=Ct*qe+Xt*pt,Qt<=0?pn=0:pn=Qt*Qt/(qe*qe+pt*pt));const Wn=Ct*Ct+Xt*Xt-pn;return Wn<0?0:Wn}function k(Me,te,Fe,Xe){return(Me-Fe)*(Me-Fe)+(te-Xe)*(te-Xe)}function O(Me,te,Fe,Xe,Pe){return k(Me,te,Fe,Xe)Fe;if(Me===0)return Math.round;const te=Math.pow(10,Me);return Fe=>Math.round(Fe*te)/te}function S(Me){const te=Math.min(Me.x1,Me.x2),Fe=Math.max(Me.x1,Me.x2),Xe=Math.min(Me.y1,Me.y2),Pe=Math.max(Me.y1,Me.y2);return{x:te,y:Xe,x2:Fe,y2:Pe,width:Fe-te,height:Pe-Xe}}class R{constructor(te,Fe,Xe,Pe){this.x1=te,this.y1=Fe,this.x2=Xe,this.y2=Pe}equals(te){return this.x1===te.x1&&this.y1===te.y1&&this.x2===te.x2&&this.y2===te.y2}draw(te){te.moveTo(this.x1,this.y1),te.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(te){return new R(te.x1,te.y1,te.x2,te.y2)}cuts(te,Fe){if(this.y1===this.y2||Fethis.y1&&Fe>=this.y2||te>this.x1&&te>=this.x2)return!1;if(tethis.x2+Xe)return!1}else if(tethis.x1+Xe)return!1;if(this.y1this.y2+Xe)return!1}else if(Fethis.y1+Xe)return!1;return!0}}var x;(function(Me){Me[Me.POINT=1]="POINT",Me[Me.PARALLEL=2]="PARALLEL",Me[Me.COINCIDENT=3]="COINCIDENT",Me[Me.NONE=4]="NONE"})(x||(x={}));class E{constructor(te,Fe=0,Xe=0){this.state=te,this.x=Fe,this.y=Xe}}function N(Me,te){const Fe=(te.x2-te.x1)*(Me.y1-te.y1)-(te.y2-te.y1)*(Me.x1-te.x1),Xe=(Me.x2-Me.x1)*(Me.y1-te.y1)-(Me.y2-Me.y1)*(Me.x1-te.x1),Pe=(te.y2-te.y1)*(Me.x2-Me.x1)-(te.x2-te.x1)*(Me.y2-Me.y1);if(Pe){const Ie=Fe/Pe,Ke=Xe/Pe;return 0<=Ie&&Ie<=1&&0<=Ke&&Ke<=1?new E(x.POINT,Me.x1+Ie*(Me.x2-Me.x1),Me.y1+Ie*(Me.y2-Me.y1)):new E(x.NONE)}return new E(Fe===0||Xe===0?x.COINCIDENT:x.PARALLEL)}function L(Me,te){const Fe=(te.x2-te.x1)*(Me.y1-te.y1)-(te.y2-te.y1)*(Me.x1-te.x1),Xe=(Me.x2-Me.x1)*(Me.y1-te.y1)-(Me.y2-Me.y1)*(Me.x1-te.x1),Pe=(te.y2-te.y1)*(Me.x2-Me.x1)-(te.x2-te.x1)*(Me.y2-Me.y1);if(Pe){const Ie=Fe/Pe,Ke=Xe/Pe;if(0<=Ie&&Ie<=1&&0<=Ke&&Ke<=1)return Ie}return Number.POSITIVE_INFINITY}function P(Me,te){function Fe(Pe,Ie,Ke,lt){let qe=L(te,new R(Pe,Ie,Ke,lt));return qe=Math.abs(qe-.5),qe>=0&&qe<=1?1:0}let Xe=Fe(Me.x,Me.y,Me.x2,Me.y);return Xe+=Fe(Me.x,Me.y,Me.x,Me.y2),Xe>1||(Xe+=Fe(Me.x,Me.y2,Me.x2,Me.y2),Xe>1)?!0:(Xe+=Fe(Me.x2,Me.y,Me.x2,Me.y2),Xe>0)}var W;(function(Me){Me[Me.LEFT=0]="LEFT",Me[Me.TOP=1]="TOP",Me[Me.RIGHT=2]="RIGHT",Me[Me.BOTTOM=3]="BOTTOM"})(W||(W={}));function K(Me,te,Fe){const Xe=new Set;return Me.width<=0?(Xe.add(W.LEFT),Xe.add(W.RIGHT)):teMe.x+Me.width&&Xe.add(W.RIGHT),Me.height<=0?(Xe.add(W.TOP),Xe.add(W.BOTTOM)):FeMe.y+Me.height&&Xe.add(W.BOTTOM),Xe}function re(Me,te){let Fe=te.x1,Xe=te.y1;const Pe=te.x2,Ie=te.y2,Ke=Array.from(K(Me,Pe,Ie));if(Ke.length===0)return!0;let lt=K(Me,Fe,Xe);for(;lt.size!==0;){for(const qe of Ke)if(lt.has(qe))return!1;if(lt.has(W.RIGHT)||lt.has(W.LEFT)){let qe=Me.x;lt.has(W.RIGHT)&&(qe+=Me.width),Xe=Xe+(qe-Fe)*(Ie-Xe)/(Pe-Fe),Fe=qe}else{let qe=Me.y;lt.has(W.BOTTOM)&&(qe+=Me.height),Fe=Fe+(qe-Xe)*(Pe-Fe)/(Ie-Xe),Xe=qe}lt=K(Me,Fe,Xe)}return!0}function ye(Me,te){let Fe=Number.POSITIVE_INFINITY,Xe=0;function Pe(Ie,Ke,lt,qe){let pt=L(te,new R(Ie,Ke,lt,qe));pt=Math.abs(pt-.5),pt>=0&&pt<=1&&(Xe++,pt1||(Pe(Me.x,Me.y2,Me.x2,Me.y2),Xe>1)?Fe:(Pe(Me.x2,Me.y,Me.x2,Me.y2),Xe===0?-1:Fe)}function ge(Me,te){let Fe=0;const Xe=N(Me,new R(te.x,te.y,te.x2,te.y));Fe+=Xe.state===x.POINT?1:0;const Pe=N(Me,new R(te.x,te.y,te.x,te.y2));Fe+=Pe.state===x.POINT?1:0;const Ie=N(Me,new R(te.x,te.y2,te.x2,te.y2));Fe+=Ie.state===x.POINT?1:0;const Ke=N(Me,new R(te.x2,te.y,te.x2,te.y2));return Fe+=Ke.state===x.POINT?1:0,{top:Xe,left:Pe,bottom:Ie,right:Ke,count:Fe}}class ce{constructor(te,Fe,Xe,Pe){this.x=te,this.y=Fe,this.width=Xe,this.height=Pe}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(te){return new ce(te.x,te.y,te.width,te.height)}equals(te){return this.x===te.x&&this.y===te.y&&this.width===te.width&&this.height===te.height}clone(){return new ce(this.x,this.y,this.width,this.height)}add(te){const Fe=Math.min(this.x,te.x),Xe=Math.min(this.y,te.y),Pe=Math.max(this.x2,te.x+te.width),Ie=Math.max(this.y2,te.y+te.height);this.x=Fe,this.y=Xe,this.width=Pe-Fe,this.height=Ie-Xe}addPoint(te){const Fe=Math.min(this.x,te.x),Xe=Math.min(this.y,te.y),Pe=Math.max(this.x2,te.x),Ie=Math.max(this.y2,te.y);this.x=Fe,this.y=Xe,this.width=Pe-Fe,this.height=Ie-Xe}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(te){te.rect(this.x,this.y,this.width,this.height)}containsPt(te,Fe){return te>=this.x&&te<=this.x2&&Fe>=this.y&&Fe<=this.y2}get area(){return this.width*this.height}intersects(te){return this.area<=0||te.width<=0||te.height<=0?!1:te.x+te.width>this.x&&te.y+te.height>this.y&&te.x=this.width?this.width-1:te}boundY(te){return te=this.height?this.height-1:te}scaleX(te){return this.boundX(Math.floor((te-this.pixelX)/this.pixelGroup))}scaleY(te){return this.boundY(Math.floor((te-this.pixelY)/this.pixelGroup))}scale(te){const Fe=this.scaleX(te.x),Xe=this.scaleY(te.y),Pe=this.boundX(Math.ceil((te.x+te.width-this.pixelX)/this.pixelGroup)),Ie=this.boundY(Math.ceil((te.y+te.height-this.pixelY)/this.pixelGroup)),Ke=Pe-Fe,lt=Ie-Xe;return new ce(Fe,Xe,Ke,lt)}invertScaleX(te){return Math.round(te*this.pixelGroup+this.pixelX)}invertScaleY(te){return Math.round(te*this.pixelGroup+this.pixelY)}addPadding(te,Fe){const Xe=Math.ceil(Fe/this.pixelGroup),Pe=this.boundX(te.x-Xe),Ie=this.boundY(te.y-Xe),Ke=this.boundX(te.x2+Xe),lt=this.boundY(te.y2+Xe),qe=Ke-Pe,pt=lt-Ie;return new ce(Pe,Ie,qe,pt)}get(te,Fe){return te<0||Fe<0||te>=this.width||Fe>=this.height?Number.NaN:this.area[te+Fe*this.width]}inc(te,Fe,Xe){te<0||Fe<0||te>=this.width||Fe>=this.height||(this.area[te+Fe*this.width]+=Xe)}set(te,Fe,Xe){te<0||Fe<0||te>=this.width||Fe>=this.height||(this.area[te+Fe*this.width]=Xe)}incArea(te,Fe){if(te.width<=0||te.height<=0||Fe===0)return;const Xe=this.width,Pe=te.width,Ie=Math.max(0,te.i),Ke=Math.max(0,te.j),lt=Math.min(te.i+te.width,Xe),qe=Math.min(te.j+te.height,this.height);if(!(qe<=0||lt<=0||Ie>=Xe||qe>=this.height))for(let pt=Ke;ptMath.min(Ke,lt),Number.POSITIVE_INFINITY),Pe=this.area.reduce((Ke,lt)=>Math.max(Ke,lt),Number.NEGATIVE_INFINITY),Ie=Ke=>(Ke-Xe)/(Pe-Xe);te.scale(this.pixelGroup,this.pixelGroup);for(let Ke=0;KeFe?"black":"white",te.fillRect(Pe,Ie,1,1)}te.restore()}}}function Ae(Me,te){const Fe=Xe=>({x:Xe.x-te,y:Xe.y-te,width:Xe.width+2*te,height:Xe.height+2*te});return Array.isArray(Me)?Me.map(Fe):Fe(Me)}function be(Me,te,Fe){return Ye(Object.assign(S(Me),{distSquare:(Xe,Pe)=>w(Me.x1,Me.y1,Me.x2,Me.y2,Xe,Pe)}),te,Fe)}function Ye(Me,te,Fe){const Xe=Ae(Me,Fe),Pe=te.scale(Xe),Ie=te.createSub(Pe,Xe);return Ee(Ie,te,Fe,(Ke,lt)=>Me.distSquare(Ke,lt)),Ie}function Ee(Me,te,Fe,Xe){const Pe=Fe*Fe;for(let Ie=0;Ie{const lt=Pe.slice(0,Ke);return At(te,Ie,lt,Fe,Xe)}).flat()}function At(Me,te,Fe,Xe,Pe){const Ie=kt(te.cx,te.cy),Ke=ue(Ie,Fe,Me);if(Ke==null)return[];const lt=new R(Ie.x,Ie.y,Ke.cx,Ke.cy),qe=at(lt,Me,Xe,Pe);return Ot(qe,Me)}function at(Me,te,Fe,Xe){const Pe=[],Ie=[];Ie.push(Me);let Ke=!0;for(let lt=0;lt0;){const qe=Ie.pop(),pt=Qe(te,qe),Ct=pt?ge(qe,pt):null;if(!pt||!Ct||Ct.count!==2){Ke||Pe.push(qe);continue}let Xt=Xe,Qt=bt(pt,Xt,Ct,!0),pn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);for(;!pn&&Wn&&Xt>=1;)Xt/=1.5,Qt=bt(pt,Xt,Ct,!0),pn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);if(Qt&&!pn&&!Wn&&(Ie.push(new R(qe.x1,qe.y1,Qt.x,Qt.y)),Ie.push(new R(Qt.x,Qt.y,qe.x2,qe.y2)),Ke=!0),Ke)continue;Xt=Xe,Qt=bt(pt,Xt,Ct,!1);let Rn=Jt(Qt,Ie)||Jt(Qt,Pe);for(Wn=vt(Qt,te);!Rn&&Wn&&Xt>=1;)Xt/=1.5,Qt=bt(pt,Xt,Ct,!1),Rn=Jt(Qt,Ie)||Jt(Qt,Pe),Wn=vt(Qt,te);Qt&&!Rn&&(Ie.push(new R(qe.x1,qe.y1,Qt.x,Qt.y)),Ie.push(new R(Qt.x,Qt.y,qe.x2,qe.y2)),Ke=!0),Ke||Pe.push(qe)}for(;Ie.length>0;)Pe.push(Ie.pop());return Pe}function Ot(Me,te){const Fe=[];for(;Me.length>0;){const Xe=Me.pop();if(Me.length===0){Fe.push(Xe);break}const Pe=Me.pop(),Ie=new R(Xe.x1,Xe.y1,Pe.x2,Pe.y2);Qe(te,Ie)?(Fe.push(Xe),Me.push(Pe)):Me.push(Ie)}return Fe}function ue(Me,te,Fe){let Xe=Number.POSITIVE_INFINITY;return te.reduce((Pe,Ie)=>{const Ke=k(Me.x,Me.y,Ie.cx,Ie.cy);if(Ke>Xe)return Pe;const lt=new R(Me.x,Me.y,Ie.cx,Ie.cy),qe=rt(Fe,lt);return Ke*(qe+1)*(qe+1){te+=Xe.cx,Fe+=Xe.cy}),te/=Me.length,Fe/=Me.length,Me.map(Xe=>{const Pe=te-Xe.cx,Ie=Fe-Xe.cy,Ke=Pe*Pe+Ie*Ie;return[Xe,Ke]}).sort((Xe,Pe)=>Xe[1]-Pe[1]).map(Xe=>Xe[0])}function vt(Me,te){return te.some(Fe=>Fe.containsPt(Me.x,Me.y))}function Jt(Me,te){return te.some(Fe=>!!(O(Fe.x1,Fe.y1,Me.x,Me.y,.001)||O(Fe.x2,Fe.y2,Me.x,Me.y,.001)))}function Qe(Me,te){let Fe=Number.POSITIVE_INFINITY,Xe=null;for(const Pe of Me){if(!re(Pe,te))continue;const Ie=ye(Pe,te);Ie>=0&&Iere(Xe,te)&&P(Xe,te)?Fe+1:Fe,0)}function bt(Me,te,Fe,Xe){const Pe=Fe.top,Ie=Fe.left,Ke=Fe.bottom,lt=Fe.right;if(Xe){if(Ie.state===x.POINT){if(Pe.state===x.POINT)return kt(Me.x-te,Me.y-te);if(Ke.state===x.POINT)return kt(Me.x-te,Me.y2+te);const Qt=Me.width*Me.height;return Me.width*((Ie.y-Me.y+(lt.y-Me.y))*.5)lt.y?kt(Me.x-te,Me.y-te):kt(Me.x2+te,Me.y-te):Ie.yKe.x?kt(Me.x-te,Me.y-te):kt(Me.x-te,Me.y2+te):Pe.xlt.y?kt(Me.x2+te,Me.y2+te):kt(Me.x-te,Me.y2+te):Ie.yKe.x?kt(Me.x2+te,Me.y2+te):kt(Me.x2+te,Me.y-te):Pe.xXe)return!1}return!0}function Ze(Me=0){return te=>{if(Me<0||te.length<3)return te;const Fe=[];let Xe=0;const Pe=Me*Me;for(;Xe{if(Ke.length<3)return Ke;const lt=[],qe=Ke.closed,pt=Ke.length+3-1+(qe?0:2);lt.push(Ie(Ke,2-(qe?0:2),0));for(let Ct=2-(qe?0:2);Ct{let Fe=Me,Xe=te.length;if(Fe>1)for(Xe=Math.floor(te.length/Fe);Xe<3&&Fe>1;)Fe-=1,Xe=Math.floor(te.length/Fe);const Pe=[];for(let Ie=0,Ke=0;Ke=Xe?this.closed?this.get(te-Xe):this.points[Xe-1]:this.points[Fe]}get length(){return this.points.length}toString(te=1/0){const Fe=this.points;if(Fe.length===0)return"";const Xe=typeof te=="function"?te:A(te);let Pe="M";for(const Ie of Fe)Pe+=`${Xe(Ie.x)},${Xe(Ie.y)} L`;return Pe=Pe.slice(0,-1),this.closed&&(Pe+=" Z"),Pe}draw(te){const Fe=this.points;if(Fe.length!==0){te.beginPath(),te.moveTo(Fe[0].x,Fe[0].y);for(const Xe of Fe)te.lineTo(Xe.x,Xe.y);this.closed&&te.closePath()}}sample(te){return de(te)(this)}simplify(te){return Ze(te)(this)}bSplines(te){return Y(te)(this)}apply(te){return te(this)}containsElements(te){const Fe=xe(this.points);return Fe?te.every(Xe=>Fe.containsPt(Xe.cx,Xe.cy)&&this.withinArea(Xe.cx,Xe.cy)):!1}withinArea(te,Fe){if(this.length===0)return!1;let Xe=0;const Pe=this.points[0],Ie=new R(Pe.x,Pe.y,Pe.x,Pe.y);for(let Ke=1;Kete?Ct+Xt:Ct}function Ie(qe,pt){let Ct=$e;return Ct=Pe(qe,pt,Ct,1),Ct=Pe(qe+1,pt,Ct,2),Ct=Pe(qe,pt+1,Ct,4),Ct=Pe(qe+1,pt+1,Ct,8),Number.isNaN(Ct)?-1:Ct}let Ke=xt;function lt(qe,pt){let Ct=qe,Xt=pt,Qt=Me.invertScaleX(Ct),pn=Me.invertScaleY(Xt);for(let Wn=0;Wnct(Xe.raw,te));return Fe<0?!1:(this.members.splice(Fe,1),this.dirty.add(Mt.MEMBERS),!0)}removeNonMember(te){const Fe=this.nonMembers.findIndex(Xe=>ct(Xe.raw,te));return Fe<0?!1:(this.nonMembers.splice(Fe,1),this.dirty.add(Mt.NON_MEMBERS),!0)}removeEdge(te){const Fe=this.edges.findIndex(Xe=>Xe.obj.equals(te));return Fe<0?!1:(this.edges.splice(Fe,1),this.dirty.add(Mt.NON_MEMBERS),!0)}pushNonMember(...te){if(te.length!==0){this.dirty.add(Mt.NON_MEMBERS);for(const Fe of te)this.nonMembers.push({raw:Fe,obj:ie(Fe)?fe.from(Fe):ce.from(Fe),area:null})}}pushEdge(...te){if(te.length!==0){this.dirty.add(Mt.EDGES);for(const Fe of te)this.edges.push({raw:Fe,obj:R.from(Fe),area:null})}}update(){const te=this.dirty.has(Mt.MEMBERS),Fe=this.dirty.has(Mt.NON_MEMBERS);let Xe=this.dirty.has(Mt.EDGES);this.dirty.clear();const Pe=this.members.map(pt=>pt.obj);if(this.o.virtualEdges&&(te||Fe)){const pt=this.nonMembers.map(Qt=>Qt.obj),Ct=Ut(Pe,pt,this.o.maxRoutingIterations,this.o.morphBuffer),Xt=new Map(this.virtualEdges.map(Qt=>[Qt.obj.toString(),Qt.area]));this.virtualEdges=Ct.map(Qt=>{var pn;return{raw:Qt,obj:Qt,area:(pn=Xt.get(Qt.toString()))!==null&&pn!==void 0?pn:null}}),Xe=!0}let Ie=!1;if(te||Xe){const pt=this.virtualEdges.concat(this.edges).map(pn=>pn.obj),Ct=en(Pe,pt),Xt=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,Qt=ce.from(Ae(Ct,Xt));Qt.equals(this.activeRegion)||(Ie=!0,this.activeRegion=Qt)}if(Ie){const pt=Math.ceil(this.activeRegion.width/this.o.pixelGroup),Ct=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=Ne.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(Xt=>Xt.area=null),this.nonMembers.forEach(Xt=>Xt.area=null),this.edges.forEach(Xt=>Xt.area=null),this.virtualEdges.forEach(Xt=>Xt.area=null)):(pt!==this.potentialArea.width||Ct!==this.potentialArea.height)&&(this.potentialArea=Ne.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const Ke=new Map,lt=pt=>{if(pt.area){const Ct=`${pt.obj.width}x${pt.obj.height}x${pt.obj instanceof ce?"R":"C"}`;Ke.set(Ct,pt.area)}},qe=pt=>{if(pt.area)return;const Ct=`${pt.obj.width}x${pt.obj.height}x${pt.obj instanceof ce?"R":"C"}`;if(Ke.has(Ct)){const Qt=Ke.get(Ct);pt.area=this.potentialArea.copy(Qt,{x:pt.obj.x-this.o.nodeR1,y:pt.obj.y-this.o.nodeR1});return}const Xt=pt.obj instanceof ce?We(pt.obj,this.potentialArea,this.o.nodeR1):Ye(pt.obj,this.potentialArea,this.o.nodeR1);pt.area=Xt,Ke.set(Ct,Xt)};this.members.forEach(lt),this.nonMembers.forEach(lt),this.members.forEach(qe),this.nonMembers.forEach(pt=>{this.activeRegion.intersects(pt.obj)?qe(pt):pt.area=null}),this.edges.forEach(pt=>{pt.area||(pt.area=be(pt.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(pt=>{pt.area||(pt.area=be(pt.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(te){for(const Fe of this.members)Fe.obj.draw(te)}drawNonMembers(te){for(const Fe of this.nonMembers)Fe.obj.draw(te)}drawEdges(te){for(const Fe of this.edges)Fe.obj.draw(te)}drawPotentialArea(te,Fe=!0){this.potentialArea.draw(te,Fe)}compute(){if(this.members.length===0)return new Je([]);this.dirty.size>0&&this.update();const{o:te,potentialArea:Fe}=this,Xe=this.members.map(lt=>lt.area),Pe=this.virtualEdges.concat(this.edges).map(lt=>lt.area),Ie=this.nonMembers.filter(lt=>lt.area!=null).map(lt=>lt.area),Ke=this.members.map(lt=>lt.obj);return Yt(Fe,Xe,Pe,Ie,lt=>lt.containsElements(Ke),te)}}function Yt(Me,te,Fe,Xe,Pe,Ie={}){const Ke=Object.assign({},B,Ie);let lt=Ke.threshold,qe=Ke.memberInfluenceFactor,pt=Ke.edgeInfluenceFactor,Ct=Ke.nonMemberInfluenceFactor;const Xt=(Ke.nodeR0-Ke.nodeR1)*(Ke.nodeR0-Ke.nodeR1),Qt=(Ke.edgeR0-Ke.edgeR1)*(Ke.edgeR0-Ke.edgeR1);for(let pn=0;pn0)Ct*=.8;else break}return new Je([])}function en(Me,te){if(Me.length===0)return new ce(0,0,0,0);const Fe=ce.from(Me[0]);for(const Xe of Me)Fe.add(Xe);for(const Xe of te)Fe.add(S(Xe));return Fe}function nn(Me,te=[],Fe=[],Xe={}){if(Me.length===0)return new Je([]);const Pe=new ht(Xe);return Pe.pushMember(...Me),Pe.pushNonMember(...te),Pe.pushEdge(...Fe),Pe.compute()}},8874:function(ae){"use strict";ae.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},19818:function(ae,ne,b){var w=b(8874),k=b(86851),O=Object.hasOwnProperty,A=Object.create(null);for(var S in w)O.call(w,S)&&(A[w[S]]=S);var R=ae.exports={to:{},get:{}};R.get=function(N){var L=N.substring(0,3).toLowerCase(),P,W;switch(L){case"hsl":P=R.get.hsl(N),W="hsl";break;case"hwb":P=R.get.hwb(N),W="hwb";break;default:P=R.get.rgb(N),W="rgb";break}return P?{model:W,value:P}:null},R.get.rgb=function(N){if(!N)return null;var L=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,W=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,K=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,re=/^(\w+)$/,ye=[0,0,0,1],ge,ce,xe;if(ge=N.match(P)){for(xe=ge[2],ge=ge[1],ce=0;ce<3;ce++){var fe=ce*2;ye[ce]=parseInt(ge.slice(fe,fe+2),16)}xe&&(ye[3]=parseInt(xe,16)/255)}else if(ge=N.match(L)){for(ge=ge[1],xe=ge[3],ce=0;ce<3;ce++)ye[ce]=parseInt(ge[ce]+ge[ce],16);xe&&(ye[3]=parseInt(xe+xe,16)/255)}else if(ge=N.match(W)){for(ce=0;ce<3;ce++)ye[ce]=parseInt(ge[ce+1],0);ge[4]&&(ge[5]?ye[3]=parseFloat(ge[4])*.01:ye[3]=parseFloat(ge[4]))}else if(ge=N.match(K)){for(ce=0;ce<3;ce++)ye[ce]=Math.round(parseFloat(ge[ce+1])*2.55);ge[4]&&(ge[5]?ye[3]=parseFloat(ge[4])*.01:ye[3]=parseFloat(ge[4]))}else return(ge=N.match(re))?ge[1]==="transparent"?[0,0,0,0]:O.call(w,ge[1])?(ye=w[ge[1]],ye[3]=1,ye):null:null;for(ce=0;ce<3;ce++)ye[ce]=x(ye[ce],0,255);return ye[3]=x(ye[3],0,1),ye},R.get.hsl=function(N){if(!N)return null;var L=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=N.match(L);if(P){var W=parseFloat(P[4]),K=(parseFloat(P[1])%360+360)%360,re=x(parseFloat(P[2]),0,100),ye=x(parseFloat(P[3]),0,100),ge=x(isNaN(W)?1:W,0,1);return[K,re,ye,ge]}return null},R.get.hwb=function(N){if(!N)return null;var L=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=N.match(L);if(P){var W=parseFloat(P[4]),K=(parseFloat(P[1])%360+360)%360,re=x(parseFloat(P[2]),0,100),ye=x(parseFloat(P[3]),0,100),ge=x(isNaN(W)?1:W,0,1);return[K,re,ye,ge]}return null},R.to.hex=function(){var N=k(arguments);return"#"+E(N[0])+E(N[1])+E(N[2])+(N[3]<1?E(Math.round(N[3]*255)):"")},R.to.rgb=function(){var N=k(arguments);return N.length<4||N[3]===1?"rgb("+Math.round(N[0])+", "+Math.round(N[1])+", "+Math.round(N[2])+")":"rgba("+Math.round(N[0])+", "+Math.round(N[1])+", "+Math.round(N[2])+", "+N[3]+")"},R.to.rgb.percent=function(){var N=k(arguments),L=Math.round(N[0]/255*100),P=Math.round(N[1]/255*100),W=Math.round(N[2]/255*100);return N.length<4||N[3]===1?"rgb("+L+"%, "+P+"%, "+W+"%)":"rgba("+L+"%, "+P+"%, "+W+"%, "+N[3]+")"},R.to.hsl=function(){var N=k(arguments);return N.length<4||N[3]===1?"hsl("+N[0]+", "+N[1]+"%, "+N[2]+"%)":"hsla("+N[0]+", "+N[1]+"%, "+N[2]+"%, "+N[3]+")"},R.to.hwb=function(){var N=k(arguments),L="";return N.length>=4&&N[3]!==1&&(L=", "+N[3]),"hwb("+N[0]+", "+N[1]+"%, "+N[2]+"%"+L+")"},R.to.keyword=function(N){return A[N.slice(0,3)]};function x(N,L,P){return Math.min(Math.max(L,N),P)}function E(N){var L=Math.round(N).toString(16).toUpperCase();return L.length<2?"0"+L:L}},70681:function(ae,ne,b){ae.exports={graphlib:b(70574),layout:b(98123),debug:b(27570),util:{time:b(11138).time,notime:b(11138).notime},version:b(88177)}},92188:function(ae,ne,b){"use strict";var w=b(38436),k=b(74079);ae.exports={run:O,undo:S};function O(R){var x=R.graph().acyclicer==="greedy"?k(R,E(R)):A(R);w.forEach(x,function(N){var L=R.edge(N);R.removeEdge(N),L.forwardName=N.name,L.reversed=!0,R.setEdge(N.w,N.v,L,w.uniqueId("rev"))});function E(N){return function(L){return N.edge(L).weight}}}function A(R){var x=[],E={},N={};function L(P){w.has(N,P)||(N[P]=!0,E[P]=!0,w.forEach(R.outEdges(P),function(W){w.has(E,W.w)?x.push(W):L(W.w)}),delete E[P])}return w.forEach(R.nodes(),L),x}function S(R){w.forEach(R.edges(),function(x){var E=R.edge(x);if(E.reversed){R.removeEdge(x);var N=E.forwardName;delete E.reversed,delete E.forwardName,R.setEdge(x.w,x.v,E,N)}})}},61133:function(ae,ne,b){var w=b(38436),k=b(11138);ae.exports=O;function O(S){function R(x){var E=S.children(x),N=S.node(x);if(E.length&&w.forEach(E,R),w.has(N,"minRank")){N.borderLeft=[],N.borderRight=[];for(var L=N.minRank,P=N.maxRank+1;L0;--ce)if(ge=P[ce].dequeue(),ge){K=K.concat(x(L,P,W,ge,!0));break}}}return K}function x(L,P,W,K,re){var ye=re?[]:void 0;return w.forEach(L.inEdges(K.v),function(ge){var ce=L.edge(ge),xe=L.node(ge.v);re&&ye.push({v:ge.v,w:ge.w}),xe.out-=ce,N(P,W,xe)}),w.forEach(L.outEdges(K.v),function(ge){var ce=L.edge(ge),xe=ge.w,fe=L.node(xe);fe.in-=ce,N(P,W,fe)}),L.removeNode(K.v),ye}function E(L,P){var W=new k,K=0,re=0;w.forEach(L.nodes(),function(ce){W.setNode(ce,{v:ce,in:0,out:0})}),w.forEach(L.edges(),function(ce){var xe=W.edge(ce.v,ce.w)||0,fe=P(ce),Ne=xe+fe;W.setEdge(ce.v,ce.w,Ne),re=Math.max(re,W.node(ce.v).out+=fe),K=Math.max(K,W.node(ce.w).in+=fe)});var ye=w.range(re+K+3).map(function(){return new O}),ge=K+1;return w.forEach(W.nodes(),function(ce){N(ye,ge,W.node(ce))}),{graph:W,buckets:ye,zeroIdx:ge}}function N(L,P,W){W.out?W.in?L[W.out-W.in+P].enqueue(W):L[L.length-1].enqueue(W):L[0].enqueue(W)}},98123:function(ae,ne,b){"use strict";var w=b(38436),k=b(92188),O=b(45995),A=b(78093),S=b(11138).normalizeRanks,R=b(24219),x=b(11138).removeEmptyRanks,E=b(72981),N=b(61133),L=b(53258),P=b(53408),W=b(17873),K=b(11138),re=b(70574).Graph;ae.exports=ye;function ye(ze,Ze){var q=Ze&&Ze.debugTiming?K.time:K.notime;q("layout",function(){var Y=q(" buildLayoutGraph",function(){return je(ze)});q(" runLayout",function(){ge(Y,q)}),q(" updateInputGraph",function(){ce(ze,Y)})})}function ge(ze,Ze){Ze(" makeSpaceForEdgeLabels",function(){_t(ze)}),Ze(" removeSelfEdges",function(){vt(ze)}),Ze(" acyclic",function(){k.run(ze)}),Ze(" nestingGraph.run",function(){E.run(ze)}),Ze(" rank",function(){A(K.asNonCompoundGraph(ze))}),Ze(" injectEdgeLabelProxies",function(){It(ze)}),Ze(" removeEmptyRanks",function(){x(ze)}),Ze(" nestingGraph.cleanup",function(){E.cleanup(ze)}),Ze(" normalizeRanks",function(){S(ze)}),Ze(" assignRankMinMax",function(){kt(ze)}),Ze(" removeEdgeLabelProxies",function(){Ut(ze)}),Ze(" normalize.run",function(){O.run(ze)}),Ze(" parentDummyChains",function(){R(ze)}),Ze(" addBorderSegments",function(){N(ze)}),Ze(" order",function(){P(ze)}),Ze(" insertSelfEdges",function(){Jt(ze)}),Ze(" adjustCoordinateSystem",function(){L.adjust(ze)}),Ze(" position",function(){W(ze)}),Ze(" positionSelfEdges",function(){Qe(ze)}),Ze(" removeBorderNodes",function(){Ue(ze)}),Ze(" normalize.undo",function(){O.undo(ze)}),Ze(" fixupEdgeLabelCoords",function(){Ot(ze)}),Ze(" undoCoordinateSystem",function(){L.undo(ze)}),Ze(" translateGraph",function(){At(ze)}),Ze(" assignNodeIntersects",function(){at(ze)}),Ze(" reversePoints",function(){ue(ze)}),Ze(" acyclic.undo",function(){k.undo(ze)})}function ce(ze,Ze){w.forEach(ze.nodes(),function(q){var Y=ze.node(q),de=Ze.node(q);Y&&(Y.x=de.x,Y.y=de.y,Ze.children(q).length&&(Y.width=de.width,Y.height=de.height))}),w.forEach(ze.edges(),function(q){var Y=ze.edge(q),de=Ze.edge(q);Y.points=de.points,w.has(de,"x")&&(Y.x=de.x,Y.y=de.y)}),ze.graph().width=Ze.graph().width,ze.graph().height=Ze.graph().height}var xe=["nodesep","edgesep","ranksep","marginx","marginy"],fe={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Ne=["acyclicer","ranker","rankdir","align"],Ae=["width","height"],be={width:0,height:0},Ye=["minlen","weight","width","height","labeloffset"],Ee={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},We=["labelpos"];function je(ze){var Ze=new re({multigraph:!0,compound:!0}),q=bt(ze.graph());return Ze.setGraph(w.merge({},fe,rt(q,xe),w.pick(q,Ne))),w.forEach(ze.nodes(),function(Y){var de=bt(ze.node(Y));Ze.setNode(Y,w.defaults(rt(de,Ae),be)),Ze.setParent(Y,ze.parent(Y))}),w.forEach(ze.edges(),function(Y){var de=bt(ze.edge(Y));Ze.setEdge(Y,w.merge({},Ee,rt(de,Ye),w.pick(de,We)))}),Ze}function _t(ze){var Ze=ze.graph();Ze.ranksep/=2,w.forEach(ze.edges(),function(q){var Y=ze.edge(q);Y.minlen*=2,Y.labelpos.toLowerCase()!=="c"&&(Ze.rankdir==="TB"||Ze.rankdir==="BT"?Y.width+=Y.labeloffset:Y.height+=Y.labeloffset)})}function It(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);if(q.width&&q.height){var Y=ze.node(Ze.v),de=ze.node(Ze.w),Je={rank:(de.rank-Y.rank)/2+Y.rank,e:Ze};K.addDummyNode(ze,"edge-proxy",Je,"_ep")}})}function kt(ze){var Ze=0;w.forEach(ze.nodes(),function(q){var Y=ze.node(q);Y.borderTop&&(Y.minRank=ze.node(Y.borderTop).rank,Y.maxRank=ze.node(Y.borderBottom).rank,Ze=w.max(Ze,Y.maxRank))}),ze.graph().maxRank=Ze}function Ut(ze){w.forEach(ze.nodes(),function(Ze){var q=ze.node(Ze);q.dummy==="edge-proxy"&&(ze.edge(q.e).labelRank=q.rank,ze.removeNode(Ze))})}function At(ze){var Ze=Number.POSITIVE_INFINITY,q=0,Y=Number.POSITIVE_INFINITY,de=0,Je=ze.graph(),Te=Je.marginx||0,$e=Je.marginy||0;function xt(ke){var et=ke.x,yt=ke.y,B=ke.width,ie=ke.height;Ze=Math.min(Ze,et-B/2),q=Math.max(q,et+B/2),Y=Math.min(Y,yt-ie/2),de=Math.max(de,yt+ie/2)}w.forEach(ze.nodes(),function(ke){xt(ze.node(ke))}),w.forEach(ze.edges(),function(ke){var et=ze.edge(ke);w.has(et,"x")&&xt(et)}),Ze-=Te,Y-=$e,w.forEach(ze.nodes(),function(ke){var et=ze.node(ke);et.x-=Ze,et.y-=Y}),w.forEach(ze.edges(),function(ke){var et=ze.edge(ke);w.forEach(et.points,function(yt){yt.x-=Ze,yt.y-=Y}),w.has(et,"x")&&(et.x-=Ze),w.has(et,"y")&&(et.y-=Y)}),Je.width=q-Ze+Te,Je.height=de-Y+$e}function at(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze),Y=ze.node(Ze.v),de=ze.node(Ze.w),Je,Te;q.points?(Je=q.points[0],Te=q.points[q.points.length-1]):(q.points=[],Je=de,Te=Y),q.points.unshift(K.intersectRect(Y,Je)),q.points.push(K.intersectRect(de,Te))})}function Ot(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);if(w.has(q,"x"))switch((q.labelpos==="l"||q.labelpos==="r")&&(q.width-=q.labeloffset),q.labelpos){case"l":q.x-=q.width/2+q.labeloffset;break;case"r":q.x+=q.width/2+q.labeloffset;break}})}function ue(ze){w.forEach(ze.edges(),function(Ze){var q=ze.edge(Ze);q.reversed&&q.points.reverse()})}function Ue(ze){w.forEach(ze.nodes(),function(Ze){if(ze.children(Ze).length){var q=ze.node(Ze),Y=ze.node(q.borderTop),de=ze.node(q.borderBottom),Je=ze.node(w.last(q.borderLeft)),Te=ze.node(w.last(q.borderRight));q.width=Math.abs(Te.x-Je.x),q.height=Math.abs(de.y-Y.y),q.x=Je.x+q.width/2,q.y=Y.y+q.height/2}}),w.forEach(ze.nodes(),function(Ze){ze.node(Ze).dummy==="border"&&ze.removeNode(Ze)})}function vt(ze){w.forEach(ze.edges(),function(Ze){if(Ze.v===Ze.w){var q=ze.node(Ze.v);q.selfEdges||(q.selfEdges=[]),q.selfEdges.push({e:Ze,label:ze.edge(Ze)}),ze.removeEdge(Ze)}})}function Jt(ze){var Ze=K.buildLayerMatrix(ze);w.forEach(Ze,function(q){var Y=0;w.forEach(q,function(de,Je){var Te=ze.node(de);Te.order=Je+Y,w.forEach(Te.selfEdges,function($e){K.addDummyNode(ze,"selfedge",{width:$e.label.width,height:$e.label.height,rank:Te.rank,order:Je+ ++Y,e:$e.e,label:$e.label},"_se")}),delete Te.selfEdges})})}function Qe(ze){w.forEach(ze.nodes(),function(Ze){var q=ze.node(Ze);if(q.dummy==="selfedge"){var Y=ze.node(q.e.v),de=Y.x+Y.width/2,Je=Y.y,Te=q.x-de,$e=Y.height/2;ze.setEdge(q.e,q.label),ze.removeNode(Ze),q.label.points=[{x:de+2*Te/3,y:Je-$e},{x:de+5*Te/6,y:Je-$e},{x:de+Te,y:Je},{x:de+5*Te/6,y:Je+$e},{x:de+2*Te/3,y:Je+$e}],q.label.x=q.x,q.label.y=q.y}})}function rt(ze,Ze){return w.mapValues(w.pick(ze,Ze),Number)}function bt(ze){var Ze={};return w.forEach(ze,function(q,Y){Ze[Y.toLowerCase()]=q}),Ze}},38436:function(ae,ne,b){var w;try{w={cloneDeep:b(50361),constant:b(75703),defaults:b(91747),each:b(85768),filter:b(63105),find:b(13311),flatten:b(85564),forEach:b(84486),forIn:b(62620),has:b(18721),isUndefined:b(52353),last:b(10928),map:b(35161),mapValues:b(8521),max:b(6162),merge:b(82492),min:b(53632),minBy:b(22762),now:b(7771),pick:b(78718),range:b(96026),reduce:b(54061),sortBy:b(89734),uniqueId:b(73955),values:b(52628),zipObject:b(7287)}}catch(k){}w||(w=window._),ae.exports=w},72981:function(ae,ne,b){var w=b(38436),k=b(11138);ae.exports={run:O,cleanup:x};function O(E){var N=k.addDummyNode(E,"root",{},"_root"),L=S(E),P=w.max(w.values(L))-1,W=2*P+1;E.graph().nestingRoot=N,w.forEach(E.edges(),function(re){E.edge(re).minlen*=W});var K=R(E)+1;w.forEach(E.children(),function(re){A(E,N,W,K,P,L,re)}),E.graph().nodeRankFactor=W}function A(E,N,L,P,W,K,re){var ye=E.children(re);if(!ye.length){re!==N&&E.setEdge(N,re,{weight:0,minlen:L});return}var ge=k.addBorderNode(E,"_bt"),ce=k.addBorderNode(E,"_bb"),xe=E.node(re);E.setParent(ge,re),xe.borderTop=ge,E.setParent(ce,re),xe.borderBottom=ce,w.forEach(ye,function(fe){A(E,N,L,P,W,K,fe);var Ne=E.node(fe),Ae=Ne.borderTop?Ne.borderTop:fe,be=Ne.borderBottom?Ne.borderBottom:fe,Ye=Ne.borderTop?P:2*P,Ee=Ae!==be?1:W-K[re]+1;E.setEdge(ge,Ae,{weight:Ye,minlen:Ee,nestingEdge:!0}),E.setEdge(be,ce,{weight:Ye,minlen:Ee,nestingEdge:!0})}),E.parent(re)||E.setEdge(N,ge,{weight:0,minlen:W+K[re]})}function S(E){var N={};function L(P,W){var K=E.children(P);K&&K.length&&w.forEach(K,function(re){L(re,W+1)}),N[P]=W}return w.forEach(E.children(),function(P){L(P,1)}),N}function R(E){return w.reduce(E.edges(),function(N,L){return N+E.edge(L).weight},0)}function x(E){var N=E.graph();E.removeNode(N.nestingRoot),delete N.nestingRoot,w.forEach(E.edges(),function(L){var P=E.edge(L);P.nestingEdge&&E.removeEdge(L)})}},45995:function(ae,ne,b){"use strict";var w=b(38436),k=b(11138);ae.exports={run:O,undo:S};function O(R){R.graph().dummyChains=[],w.forEach(R.edges(),function(x){A(R,x)})}function A(R,x){var E=x.v,N=R.node(E).rank,L=x.w,P=R.node(L).rank,W=x.name,K=R.edge(x),re=K.labelRank;if(P!==N+1){R.removeEdge(x);var ye,ge,ce;for(ce=0,++N;N0;)re%2&&(ye+=P[re+1]),re=re-1>>1,P[re]+=K.weight;W+=K.weight*ye})),W}},53408:function(ae,ne,b){"use strict";var w=b(38436),k=b(2588),O=b(56630),A=b(61026),S=b(23128),R=b(55093),x=b(70574).Graph,E=b(11138);ae.exports=N;function N(K){var re=E.maxRank(K),ye=L(K,w.range(1,re+1),"inEdges"),ge=L(K,w.range(re-1,-1,-1),"outEdges"),ce=k(K);W(K,ce);for(var xe=Number.POSITIVE_INFINITY,fe,Ne=0,Ae=0;Ae<4;++Ne,++Ae){P(Ne%2?ye:ge,Ne%4>=2),ce=E.buildLayerMatrix(K);var be=O(K,ce);be=L.barycenter)&&A(L,P)}}function E(L){return function(P){P.in.push(L),--P.indegree===0&&S.push(P)}}for(;S.length;){var N=S.pop();R.push(N),w.forEach(N.in.reverse(),x(N)),w.forEach(N.out,E(N))}return w.map(w.filter(R,function(L){return!L.merged}),function(L){return w.pick(L,["vs","i","barycenter","weight"])})}function A(S,R){var x=0,E=0;S.weight&&(x+=S.barycenter*S.weight,E+=S.weight),R.weight&&(x+=R.barycenter*R.weight,E+=R.weight),S.vs=R.vs.concat(S.vs),S.barycenter=x/E,S.weight=E,S.i=Math.min(R.i,S.i),R.merged=!0}},61026:function(ae,ne,b){var w=b(38436),k=b(35439),O=b(83678),A=b(87304);ae.exports=S;function S(E,N,L,P){var W=E.children(N),K=E.node(N),re=K?K.borderLeft:void 0,ye=K?K.borderRight:void 0,ge={};re&&(W=w.filter(W,function(be){return be!==re&&be!==ye}));var ce=k(E,W);w.forEach(ce,function(be){if(E.children(be.v).length){var Ye=S(E,be.v,L,P);ge[be.v]=Ye,w.has(Ye,"barycenter")&&x(be,Ye)}});var xe=O(ce,L);R(xe,ge);var fe=A(xe,P);if(re&&(fe.vs=w.flatten([re,fe.vs,ye],!0),E.predecessors(re).length)){var Ne=E.node(E.predecessors(re)[0]),Ae=E.node(E.predecessors(ye)[0]);w.has(fe,"barycenter")||(fe.barycenter=0,fe.weight=0),fe.barycenter=(fe.barycenter*fe.weight+Ne.order+Ae.order)/(fe.weight+2),fe.weight+=2}return fe}function R(E,N){w.forEach(E,function(L){L.vs=w.flatten(L.vs.map(function(P){return N[P]?N[P].vs:P}),!0)})}function x(E,N){w.isUndefined(E.barycenter)?(E.barycenter=N.barycenter,E.weight=N.weight):(E.barycenter=(E.barycenter*E.weight+N.barycenter*N.weight)/(E.weight+N.weight),E.weight+=N.weight)}},87304:function(ae,ne,b){var w=b(38436),k=b(11138);ae.exports=O;function O(R,x){var E=k.partition(R,function(ge){return w.has(ge,"barycenter")}),N=E.lhs,L=w.sortBy(E.rhs,function(ge){return-ge.i}),P=[],W=0,K=0,re=0;N.sort(S(!!x)),re=A(P,L,re),w.forEach(N,function(ge){re+=ge.vs.length,P.push(ge.vs),W+=ge.barycenter*ge.weight,K+=ge.weight,re=A(P,L,re)});var ye={vs:w.flatten(P,!0)};return K&&(ye.barycenter=W/K,ye.weight=K),ye}function A(R,x,E){for(var N;x.length&&(N=w.last(x)).i<=E;)x.pop(),R.push(N.vs),E++;return E}function S(R){return function(x,E){return x.barycenterE.barycenter?1:R?E.i-x.i:x.i-E.i}}},24219:function(ae,ne,b){var w=b(38436);ae.exports=k;function k(S){var R=A(S);w.forEach(S.graph().dummyChains,function(x){for(var E=S.node(x),N=E.edgeObj,L=O(S,R,N.v,N.w),P=L.path,W=L.lca,K=0,re=P[K],ye=!0;x!==N.w;){if(E=S.node(x),ye){for(;(re=P[K])!==W&&S.node(re).maxRankP||W>R[K].lim));for(re=K,K=E;(K=S.parent(K))!==re;)L.push(K);return{path:N.concat(L.reverse()),lca:re}}function A(S){var R={},x=0;function E(N){var L=x;w.forEach(S.children(N),E),R[N]={low:L,lim:x++}}return w.forEach(S.children(),E),R}},3573:function(ae,ne,b){"use strict";var w=b(38436),k=b(70574).Graph,O=b(11138);ae.exports={positionX:ye,findType1Conflicts:A,findType2Conflicts:S,addConflict:x,hasConflict:E,verticalAlignment:N,horizontalCompaction:L,alignCoordinates:K,findSmallestWidthAlignment:W,balance:re};function A(xe,fe){var Ne={};function Ae(be,Ye){var Ee=0,We=0,je=be.length,_t=w.last(Ye);return w.forEach(Ye,function(It,kt){var Ut=R(xe,It),At=Ut?xe.node(Ut).order:je;(Ut||It===_t)&&(w.forEach(Ye.slice(We,kt+1),function(at){w.forEach(xe.predecessors(at),function(Ot){var ue=xe.node(Ot),Ue=ue.order;(Ue_t)&&x(Ne,Ut,It)})})}function be(Ye,Ee){var We=-1,je,_t=0;return w.forEach(Ee,function(It,kt){if(xe.node(It).dummy==="border"){var Ut=xe.predecessors(It);Ut.length&&(je=xe.node(Ut[0]).order,Ae(Ee,_t,kt,We,je),_t=kt,We=je)}Ae(Ee,_t,Ee.length,je,Ye.length)}),Ee}return w.reduce(fe,be),Ne}function R(xe,fe){if(xe.node(fe).dummy)return w.find(xe.predecessors(fe),function(Ne){return xe.node(Ne).dummy})}function x(xe,fe,Ne){if(fe>Ne){var Ae=fe;fe=Ne,Ne=Ae}var be=xe[fe];be||(xe[fe]=be={}),be[Ne]=!0}function E(xe,fe,Ne){if(fe>Ne){var Ae=fe;fe=Ne,Ne=Ae}return w.has(xe[fe],Ne)}function N(xe,fe,Ne,Ae){var be={},Ye={},Ee={};return w.forEach(fe,function(We){w.forEach(We,function(je,_t){be[je]=je,Ye[je]=je,Ee[je]=_t})}),w.forEach(fe,function(We){var je=-1;w.forEach(We,function(_t){var It=Ae(_t);if(It.length){It=w.sortBy(It,function(Ot){return Ee[Ot]});for(var kt=(It.length-1)/2,Ut=Math.floor(kt),At=Math.ceil(kt);Ut<=At;++Ut){var at=It[Ut];Ye[_t]===_t&&jeje.lim&&(_t=je,It=!0);var kt=w.filter(Ae.edges(),function(Ut){return It===fe(Ne,Ne.node(Ut.v),_t)&&It!==fe(Ne,Ne.node(Ut.w),_t)});return w.minBy(kt,function(Ut){return O(Ae,Ut)})}function ge(Ne,Ae,be,Ye){var Ee=be.v,We=be.w;Ne.removeEdge(Ee,We),Ne.setEdge(Ye.v,Ye.w,{}),W(Ne),N(Ne,Ae),ce(Ne,Ae)}function ce(Ne,Ae){var be=w.find(Ne.nodes(),function(Ee){return!Ae.node(Ee).parent}),Ye=S(Ne,be);Ye=Ye.slice(1),w.forEach(Ye,function(Ee){var We=Ne.node(Ee).parent,je=Ae.edge(Ee,We),_t=!1;je||(je=Ae.edge(We,Ee),_t=!0),Ae.node(Ee).rank=Ae.node(We).rank+(_t?je.minlen:-je.minlen)})}function xe(Ne,Ae,be){return Ne.hasEdge(Ae,be)}function fe(Ne,Ae,be){return be.low<=Ae.lim&&Ae.lim<=be.lim}},76681:function(ae,ne,b){"use strict";var w=b(38436);ae.exports={longestPath:k,slack:O};function k(A){var S={};function R(x){var E=A.node(x);if(w.has(S,x))return E.rank;S[x]=!0;var N=w.min(w.map(A.outEdges(x),function(L){return R(L.w)-A.edge(L).minlen}));return(N===Number.POSITIVE_INFINITY||N===void 0||N===null)&&(N=0),E.rank=N}w.forEach(A.sources(),R)}function O(A,S){return A.node(S.w).rank-A.node(S.v).rank-A.edge(S).minlen}},11138:function(ae,ne,b){"use strict";var w=b(38436),k=b(70574).Graph;ae.exports={addDummyNode:O,simplify:A,asNonCompoundGraph:S,successorWeights:R,predecessorWeights:x,intersectRect:E,buildLayerMatrix:N,normalizeRanks:L,removeEmptyRanks:P,addBorderNode:W,maxRank:K,partition:re,time:ye,notime:ge};function O(ce,xe,fe,Ne){var Ae;do Ae=w.uniqueId(Ne);while(ce.hasNode(Ae));return fe.dummy=xe,ce.setNode(Ae,fe),Ae}function A(ce){var xe=new k().setGraph(ce.graph());return w.forEach(ce.nodes(),function(fe){xe.setNode(fe,ce.node(fe))}),w.forEach(ce.edges(),function(fe){var Ne=xe.edge(fe.v,fe.w)||{weight:0,minlen:1},Ae=ce.edge(fe);xe.setEdge(fe.v,fe.w,{weight:Ne.weight+Ae.weight,minlen:Math.max(Ne.minlen,Ae.minlen)})}),xe}function S(ce){var xe=new k({multigraph:ce.isMultigraph()}).setGraph(ce.graph());return w.forEach(ce.nodes(),function(fe){ce.children(fe).length||xe.setNode(fe,ce.node(fe))}),w.forEach(ce.edges(),function(fe){xe.setEdge(fe,ce.edge(fe))}),xe}function R(ce){var xe=w.map(ce.nodes(),function(fe){var Ne={};return w.forEach(ce.outEdges(fe),function(Ae){Ne[Ae.w]=(Ne[Ae.w]||0)+ce.edge(Ae).weight}),Ne});return w.zipObject(ce.nodes(),xe)}function x(ce){var xe=w.map(ce.nodes(),function(fe){var Ne={};return w.forEach(ce.inEdges(fe),function(Ae){Ne[Ae.v]=(Ne[Ae.v]||0)+ce.edge(Ae).weight}),Ne});return w.zipObject(ce.nodes(),xe)}function E(ce,xe){var fe=ce.x,Ne=ce.y,Ae=xe.x-fe,be=xe.y-Ne,Ye=ce.width/2,Ee=ce.height/2;if(!Ae&&!be)throw new Error("Not possible to find intersection inside of the rectangle");var We,je;return Math.abs(be)*Ye>Math.abs(Ae)*Ee?(be<0&&(Ee=-Ee),We=Ee*Ae/be,je=Ee):(Ae<0&&(Ye=-Ye),We=Ye,je=Ye*be/Ae),{x:fe+We,y:Ne+je}}function N(ce){var xe=w.map(w.range(K(ce)+1),function(){return[]});return w.forEach(ce.nodes(),function(fe){var Ne=ce.node(fe),Ae=Ne.rank;w.isUndefined(Ae)||(xe[Ae][Ne.order]=fe)}),xe}function L(ce){var xe=w.min(w.map(ce.nodes(),function(fe){return ce.node(fe).rank}));w.forEach(ce.nodes(),function(fe){var Ne=ce.node(fe);w.has(Ne,"rank")&&(Ne.rank-=xe)})}function P(ce){var xe=w.min(w.map(ce.nodes(),function(be){return ce.node(be).rank})),fe=[];w.forEach(ce.nodes(),function(be){var Ye=ce.node(be).rank-xe;fe[Ye]||(fe[Ye]=[]),fe[Ye].push(be)});var Ne=0,Ae=ce.graph().nodeRankFactor;w.forEach(fe,function(be,Ye){w.isUndefined(be)&&Ye%Ae!==0?--Ne:Ne&&w.forEach(be,function(Ee){ce.node(Ee).rank+=Ne})})}function W(ce,xe,fe,Ne){var Ae={width:0,height:0};return arguments.length>=4&&(Ae.rank=fe,Ae.order=Ne),O(ce,"border",Ae,xe)}function K(ce){return w.max(w.map(ce.nodes(),function(xe){var fe=ce.node(xe).rank;if(!w.isUndefined(fe))return fe}))}function re(ce,xe){var fe={lhs:[],rhs:[]};return w.forEach(ce,function(Ne){xe(Ne)?fe.lhs.push(Ne):fe.rhs.push(Ne)}),fe}function ye(ce,xe){var fe=w.now();try{return xe()}finally{console.log(ce+" time: "+(w.now()-fe)+"ms")}}function ge(ce,xe){return xe()}},88177:function(ae){ae.exports="0.8.5"},26729:function(ae){"use strict";var ne=Object.prototype.hasOwnProperty,b="~";function w(){}Object.create&&(w.prototype=Object.create(null),new w().__proto__||(b=!1));function k(R,x,E){this.fn=R,this.context=x,this.once=E||!1}function O(R,x,E,N,L){if(typeof E!="function")throw new TypeError("The listener must be a function");var P=new k(E,N||R,L),W=b?b+x:x;return R._events[W]?R._events[W].fn?R._events[W]=[R._events[W],P]:R._events[W].push(P):(R._events[W]=P,R._eventsCount++),R}function A(R,x){--R._eventsCount===0?R._events=new w:delete R._events[x]}function S(){this._events=new w,this._eventsCount=0}S.prototype.eventNames=function(){var x=[],E,N;if(this._eventsCount===0)return x;for(N in E=this._events)ne.call(E,N)&&x.push(b?N.slice(1):N);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(E)):x},S.prototype.listeners=function(x){var E=b?b+x:x,N=this._events[E];if(!N)return[];if(N.fn)return[N.fn];for(var L=0,P=N.length,W=new Array(P);L0?(ct[0]=(nn*en+Fe*Mt+Me*Yt-te*ht)*2/Xe,ct[1]=(Me*en+Fe*ht+te*Mt-nn*Yt)*2/Xe,ct[2]=(te*en+Fe*Yt+nn*ht-Me*Mt)*2/Xe):(ct[0]=(nn*en+Fe*Mt+Me*Yt-te*ht)*2,ct[1]=(Me*en+Fe*ht+te*Mt-nn*Yt)*2,ct[2]=(te*en+Fe*Yt+nn*ht-Me*Mt)*2),We(B,ie,ct),B}function _t(B,ie){return B[0]=ie[12],B[1]=ie[13],B[2]=ie[14],B}function It(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[4],en=ie[5],nn=ie[6],Me=ie[8],te=ie[9],Fe=ie[10];return B[0]=Math.hypot(ct,Mt,ht),B[1]=Math.hypot(Yt,en,nn),B[2]=Math.hypot(Me,te,Fe),B}function kt(B,ie){var ct=new w.WT(3);It(ct,ie);var Mt=1/ct[0],ht=1/ct[1],Yt=1/ct[2],en=ie[0]*Mt,nn=ie[1]*ht,Me=ie[2]*Yt,te=ie[4]*Mt,Fe=ie[5]*ht,Xe=ie[6]*Yt,Pe=ie[8]*Mt,Ie=ie[9]*ht,Ke=ie[10]*Yt,lt=en+Fe+Ke,qe=0;return lt>0?(qe=Math.sqrt(lt+1)*2,B[3]=.25*qe,B[0]=(Xe-Ie)/qe,B[1]=(Pe-Me)/qe,B[2]=(nn-te)/qe):en>Fe&&en>Ke?(qe=Math.sqrt(1+en-Fe-Ke)*2,B[3]=(Xe-Ie)/qe,B[0]=.25*qe,B[1]=(nn+te)/qe,B[2]=(Pe+Me)/qe):Fe>Ke?(qe=Math.sqrt(1+Fe-en-Ke)*2,B[3]=(Pe-Me)/qe,B[0]=(nn+te)/qe,B[1]=.25*qe,B[2]=(Xe+Ie)/qe):(qe=Math.sqrt(1+Ke-en-Fe)*2,B[3]=(nn-te)/qe,B[0]=(Pe+Me)/qe,B[1]=(Xe+Ie)/qe,B[2]=.25*qe),B}function Ut(B,ie,ct,Mt){var ht=ie[0],Yt=ie[1],en=ie[2],nn=ie[3],Me=ht+ht,te=Yt+Yt,Fe=en+en,Xe=ht*Me,Pe=ht*te,Ie=ht*Fe,Ke=Yt*te,lt=Yt*Fe,qe=en*Fe,pt=nn*Me,Ct=nn*te,Xt=nn*Fe,Qt=Mt[0],pn=Mt[1],Wn=Mt[2];return B[0]=(1-(Ke+qe))*Qt,B[1]=(Pe+Xt)*Qt,B[2]=(Ie-Ct)*Qt,B[3]=0,B[4]=(Pe-Xt)*pn,B[5]=(1-(Xe+qe))*pn,B[6]=(lt+pt)*pn,B[7]=0,B[8]=(Ie+Ct)*Wn,B[9]=(lt-pt)*Wn,B[10]=(1-(Xe+Ke))*Wn,B[11]=0,B[12]=ct[0],B[13]=ct[1],B[14]=ct[2],B[15]=1,B}function At(B,ie,ct,Mt,ht){var Yt=ie[0],en=ie[1],nn=ie[2],Me=ie[3],te=Yt+Yt,Fe=en+en,Xe=nn+nn,Pe=Yt*te,Ie=Yt*Fe,Ke=Yt*Xe,lt=en*Fe,qe=en*Xe,pt=nn*Xe,Ct=Me*te,Xt=Me*Fe,Qt=Me*Xe,pn=Mt[0],Wn=Mt[1],Rn=Mt[2],bi=ht[0],Lr=ht[1],Qn=ht[2],Vi=(1-(lt+pt))*pn,Oi=(Ie+Qt)*pn,Gi=(Ke-Xt)*pn,ir=(Ie-Qt)*Wn,ms=(1-(Pe+pt))*Wn,Is=(qe+Ct)*Wn,as=(Ke+Xt)*Rn,gs=(qe-Ct)*Rn,Vs=(1-(Pe+lt))*Rn;return B[0]=Vi,B[1]=Oi,B[2]=Gi,B[3]=0,B[4]=ir,B[5]=ms,B[6]=Is,B[7]=0,B[8]=as,B[9]=gs,B[10]=Vs,B[11]=0,B[12]=ct[0]+bi-(Vi*bi+ir*Lr+as*Qn),B[13]=ct[1]+Lr-(Oi*bi+ms*Lr+gs*Qn),B[14]=ct[2]+Qn-(Gi*bi+Is*Lr+Vs*Qn),B[15]=1,B}function at(B,ie){var ct=ie[0],Mt=ie[1],ht=ie[2],Yt=ie[3],en=ct+ct,nn=Mt+Mt,Me=ht+ht,te=ct*en,Fe=Mt*en,Xe=Mt*nn,Pe=ht*en,Ie=ht*nn,Ke=ht*Me,lt=Yt*en,qe=Yt*nn,pt=Yt*Me;return B[0]=1-Xe-Ke,B[1]=Fe+pt,B[2]=Pe-qe,B[3]=0,B[4]=Fe-pt,B[5]=1-te-Ke,B[6]=Ie+lt,B[7]=0,B[8]=Pe+qe,B[9]=Ie-lt,B[10]=1-te-Xe,B[11]=0,B[12]=0,B[13]=0,B[14]=0,B[15]=1,B}function Ot(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ct-ie),Me=1/(ht-Mt),te=1/(Yt-en);return B[0]=Yt*2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt*2*Me,B[6]=0,B[7]=0,B[8]=(ct+ie)*nn,B[9]=(ht+Mt)*Me,B[10]=(en+Yt)*te,B[11]=-1,B[12]=0,B[13]=0,B[14]=en*Yt*2*te,B[15]=0,B}function ue(B,ie,ct,Mt,ht){var Yt=1/Math.tan(ie/2),en;return B[0]=Yt/ct,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ht!=null&&ht!==1/0?(en=1/(Mt-ht),B[10]=(ht+Mt)*en,B[14]=2*ht*Mt*en):(B[10]=-1,B[14]=-2*Mt),B}var Ue=ue;function vt(B,ie,ct,Mt,ht){var Yt=1/Math.tan(ie/2),en;return B[0]=Yt/ct,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=Yt,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[11]=-1,B[12]=0,B[13]=0,B[15]=0,ht!=null&&ht!==1/0?(en=1/(Mt-ht),B[10]=ht*en,B[14]=ht*Mt*en):(B[10]=-1,B[14]=-Mt),B}function Jt(B,ie,ct,Mt){var ht=Math.tan(ie.upDegrees*Math.PI/180),Yt=Math.tan(ie.downDegrees*Math.PI/180),en=Math.tan(ie.leftDegrees*Math.PI/180),nn=Math.tan(ie.rightDegrees*Math.PI/180),Me=2/(en+nn),te=2/(ht+Yt);return B[0]=Me,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=te,B[6]=0,B[7]=0,B[8]=-((en-nn)*Me*.5),B[9]=(ht-Yt)*te*.5,B[10]=Mt/(ct-Mt),B[11]=-1,B[12]=0,B[13]=0,B[14]=Mt*ct/(ct-Mt),B[15]=0,B}function Qe(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ie-ct),Me=1/(Mt-ht),te=1/(Yt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*Me,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=2*te,B[11]=0,B[12]=(ie+ct)*nn,B[13]=(ht+Mt)*Me,B[14]=(en+Yt)*te,B[15]=1,B}var rt=Qe;function bt(B,ie,ct,Mt,ht,Yt,en){var nn=1/(ie-ct),Me=1/(Mt-ht),te=1/(Yt-en);return B[0]=-2*nn,B[1]=0,B[2]=0,B[3]=0,B[4]=0,B[5]=-2*Me,B[6]=0,B[7]=0,B[8]=0,B[9]=0,B[10]=te,B[11]=0,B[12]=(ie+ct)*nn,B[13]=(ht+Mt)*Me,B[14]=Yt*te,B[15]=1,B}function ze(B,ie,ct,Mt){var ht,Yt,en,nn,Me,te,Fe,Xe,Pe,Ie,Ke=ie[0],lt=ie[1],qe=ie[2],pt=Mt[0],Ct=Mt[1],Xt=Mt[2],Qt=ct[0],pn=ct[1],Wn=ct[2];return Math.abs(Ke-Qt)0&&(Ie=1/Math.sqrt(Ie),Fe*=Ie,Xe*=Ie,Pe*=Ie);var Ke=Me*Pe-te*Xe,lt=te*Fe-nn*Pe,qe=nn*Xe-Me*Fe;return Ie=Ke*Ke+lt*lt+qe*qe,Ie>0&&(Ie=1/Math.sqrt(Ie),Ke*=Ie,lt*=Ie,qe*=Ie),B[0]=Ke,B[1]=lt,B[2]=qe,B[3]=0,B[4]=Xe*qe-Pe*lt,B[5]=Pe*Ke-Fe*qe,B[6]=Fe*lt-Xe*Ke,B[7]=0,B[8]=Fe,B[9]=Xe,B[10]=Pe,B[11]=0,B[12]=ht,B[13]=Yt,B[14]=en,B[15]=1,B}function q(B){return"mat4("+B[0]+", "+B[1]+", "+B[2]+", "+B[3]+", "+B[4]+", "+B[5]+", "+B[6]+", "+B[7]+", "+B[8]+", "+B[9]+", "+B[10]+", "+B[11]+", "+B[12]+", "+B[13]+", "+B[14]+", "+B[15]+")"}function Y(B){return Math.hypot(B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7],B[8],B[9],B[10],B[11],B[12],B[13],B[14],B[15])}function de(B,ie,ct){return B[0]=ie[0]+ct[0],B[1]=ie[1]+ct[1],B[2]=ie[2]+ct[2],B[3]=ie[3]+ct[3],B[4]=ie[4]+ct[4],B[5]=ie[5]+ct[5],B[6]=ie[6]+ct[6],B[7]=ie[7]+ct[7],B[8]=ie[8]+ct[8],B[9]=ie[9]+ct[9],B[10]=ie[10]+ct[10],B[11]=ie[11]+ct[11],B[12]=ie[12]+ct[12],B[13]=ie[13]+ct[13],B[14]=ie[14]+ct[14],B[15]=ie[15]+ct[15],B}function Je(B,ie,ct){return B[0]=ie[0]-ct[0],B[1]=ie[1]-ct[1],B[2]=ie[2]-ct[2],B[3]=ie[3]-ct[3],B[4]=ie[4]-ct[4],B[5]=ie[5]-ct[5],B[6]=ie[6]-ct[6],B[7]=ie[7]-ct[7],B[8]=ie[8]-ct[8],B[9]=ie[9]-ct[9],B[10]=ie[10]-ct[10],B[11]=ie[11]-ct[11],B[12]=ie[12]-ct[12],B[13]=ie[13]-ct[13],B[14]=ie[14]-ct[14],B[15]=ie[15]-ct[15],B}function Te(B,ie,ct){return B[0]=ie[0]*ct,B[1]=ie[1]*ct,B[2]=ie[2]*ct,B[3]=ie[3]*ct,B[4]=ie[4]*ct,B[5]=ie[5]*ct,B[6]=ie[6]*ct,B[7]=ie[7]*ct,B[8]=ie[8]*ct,B[9]=ie[9]*ct,B[10]=ie[10]*ct,B[11]=ie[11]*ct,B[12]=ie[12]*ct,B[13]=ie[13]*ct,B[14]=ie[14]*ct,B[15]=ie[15]*ct,B}function $e(B,ie,ct,Mt){return B[0]=ie[0]+ct[0]*Mt,B[1]=ie[1]+ct[1]*Mt,B[2]=ie[2]+ct[2]*Mt,B[3]=ie[3]+ct[3]*Mt,B[4]=ie[4]+ct[4]*Mt,B[5]=ie[5]+ct[5]*Mt,B[6]=ie[6]+ct[6]*Mt,B[7]=ie[7]+ct[7]*Mt,B[8]=ie[8]+ct[8]*Mt,B[9]=ie[9]+ct[9]*Mt,B[10]=ie[10]+ct[10]*Mt,B[11]=ie[11]+ct[11]*Mt,B[12]=ie[12]+ct[12]*Mt,B[13]=ie[13]+ct[13]*Mt,B[14]=ie[14]+ct[14]*Mt,B[15]=ie[15]+ct[15]*Mt,B}function xt(B,ie){return B[0]===ie[0]&&B[1]===ie[1]&&B[2]===ie[2]&&B[3]===ie[3]&&B[4]===ie[4]&&B[5]===ie[5]&&B[6]===ie[6]&&B[7]===ie[7]&&B[8]===ie[8]&&B[9]===ie[9]&&B[10]===ie[10]&&B[11]===ie[11]&&B[12]===ie[12]&&B[13]===ie[13]&&B[14]===ie[14]&&B[15]===ie[15]}function ke(B,ie){var ct=B[0],Mt=B[1],ht=B[2],Yt=B[3],en=B[4],nn=B[5],Me=B[6],te=B[7],Fe=B[8],Xe=B[9],Pe=B[10],Ie=B[11],Ke=B[12],lt=B[13],qe=B[14],pt=B[15],Ct=ie[0],Xt=ie[1],Qt=ie[2],pn=ie[3],Wn=ie[4],Rn=ie[5],bi=ie[6],Lr=ie[7],Qn=ie[8],Vi=ie[9],Oi=ie[10],Gi=ie[11],ir=ie[12],ms=ie[13],Is=ie[14],as=ie[15];return Math.abs(ct-Ct)<=w.Ib*Math.max(1,Math.abs(ct),Math.abs(Ct))&&Math.abs(Mt-Xt)<=w.Ib*Math.max(1,Math.abs(Mt),Math.abs(Xt))&&Math.abs(ht-Qt)<=w.Ib*Math.max(1,Math.abs(ht),Math.abs(Qt))&&Math.abs(Yt-pn)<=w.Ib*Math.max(1,Math.abs(Yt),Math.abs(pn))&&Math.abs(en-Wn)<=w.Ib*Math.max(1,Math.abs(en),Math.abs(Wn))&&Math.abs(nn-Rn)<=w.Ib*Math.max(1,Math.abs(nn),Math.abs(Rn))&&Math.abs(Me-bi)<=w.Ib*Math.max(1,Math.abs(Me),Math.abs(bi))&&Math.abs(te-Lr)<=w.Ib*Math.max(1,Math.abs(te),Math.abs(Lr))&&Math.abs(Fe-Qn)<=w.Ib*Math.max(1,Math.abs(Fe),Math.abs(Qn))&&Math.abs(Xe-Vi)<=w.Ib*Math.max(1,Math.abs(Xe),Math.abs(Vi))&&Math.abs(Pe-Oi)<=w.Ib*Math.max(1,Math.abs(Pe),Math.abs(Oi))&&Math.abs(Ie-Gi)<=w.Ib*Math.max(1,Math.abs(Ie),Math.abs(Gi))&&Math.abs(Ke-ir)<=w.Ib*Math.max(1,Math.abs(Ke),Math.abs(ir))&&Math.abs(lt-ms)<=w.Ib*Math.max(1,Math.abs(lt),Math.abs(ms))&&Math.abs(qe-Is)<=w.Ib*Math.max(1,Math.abs(qe),Math.abs(Is))&&Math.abs(pt-as)<=w.Ib*Math.max(1,Math.abs(pt),Math.abs(as))}var et=W,yt=Je},32945:function(ae,ne,b){"use strict";b.d(ne,{Fv:function(){return Qe},JG:function(){return _t},Jp:function(){return L},Su:function(){return Ye},U_:function(){return Ne},Ue:function(){return S},al:function(){return je},dC:function(){return Ut},t8:function(){return It},yY:function(){return x}});var w=b(49685),k=b(35600),O=b(33983),A=b(98333);function S(){var Y=new w.WT(4);return w.WT!=Float32Array&&(Y[0]=0,Y[1]=0,Y[2]=0),Y[3]=1,Y}function R(Y){return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y}function x(Y,de,Je){Je=Je*.5;var Te=Math.sin(Je);return Y[0]=Te*de[0],Y[1]=Te*de[1],Y[2]=Te*de[2],Y[3]=Math.cos(Je),Y}function E(Y,de){var Je=Math.acos(de[3])*2,Te=Math.sin(Je/2);return Te>glMatrix.EPSILON?(Y[0]=de[0]/Te,Y[1]=de[1]/Te,Y[2]=de[2]/Te):(Y[0]=1,Y[1]=0,Y[2]=0),Je}function N(Y,de){var Je=at(Y,de);return Math.acos(2*Je*Je-1)}function L(Y,de,Je){var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Je[0],yt=Je[1],B=Je[2],ie=Je[3];return Y[0]=Te*ie+ke*et+$e*B-xt*yt,Y[1]=$e*ie+ke*yt+xt*et-Te*B,Y[2]=xt*ie+ke*B+Te*yt-$e*et,Y[3]=ke*ie-Te*et-$e*yt-xt*B,Y}function P(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt+ke*et,Y[1]=$e*yt+xt*et,Y[2]=xt*yt-$e*et,Y[3]=ke*yt-Te*et,Y}function W(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt-xt*et,Y[1]=$e*yt+ke*et,Y[2]=xt*yt+Te*et,Y[3]=ke*yt-$e*et,Y}function K(Y,de,Je){Je*=.5;var Te=de[0],$e=de[1],xt=de[2],ke=de[3],et=Math.sin(Je),yt=Math.cos(Je);return Y[0]=Te*yt+$e*et,Y[1]=$e*yt-Te*et,Y[2]=xt*yt+ke*et,Y[3]=ke*yt-xt*et,Y}function re(Y,de){var Je=de[0],Te=de[1],$e=de[2];return Y[0]=Je,Y[1]=Te,Y[2]=$e,Y[3]=Math.sqrt(Math.abs(1-Je*Je-Te*Te-$e*$e)),Y}function ye(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Math.sqrt(Je*Je+Te*Te+$e*$e),et=Math.exp(xt),yt=ke>0?et*Math.sin(ke)/ke:0;return Y[0]=Je*yt,Y[1]=Te*yt,Y[2]=$e*yt,Y[3]=et*Math.cos(ke),Y}function ge(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Math.sqrt(Je*Je+Te*Te+$e*$e),et=ke>0?Math.atan2(ke,xt)/ke:0;return Y[0]=Je*et,Y[1]=Te*et,Y[2]=$e*et,Y[3]=.5*Math.log(Je*Je+Te*Te+$e*$e+xt*xt),Y}function ce(Y,de,Je){return ge(Y,de),At(Y,Y,Je),ye(Y,Y),Y}function xe(Y,de,Je,Te){var $e=de[0],xt=de[1],ke=de[2],et=de[3],yt=Je[0],B=Je[1],ie=Je[2],ct=Je[3],Mt,ht,Yt,en,nn;return ht=$e*yt+xt*B+ke*ie+et*ct,ht<0&&(ht=-ht,yt=-yt,B=-B,ie=-ie,ct=-ct),1-ht>w.Ib?(Mt=Math.acos(ht),Yt=Math.sin(Mt),en=Math.sin((1-Te)*Mt)/Yt,nn=Math.sin(Te*Mt)/Yt):(en=1-Te,nn=Te),Y[0]=en*$e+nn*yt,Y[1]=en*xt+nn*B,Y[2]=en*ke+nn*ie,Y[3]=en*et+nn*ct,Y}function fe(Y){var de=glMatrix.RANDOM(),Je=glMatrix.RANDOM(),Te=glMatrix.RANDOM(),$e=Math.sqrt(1-de),xt=Math.sqrt(de);return Y[0]=$e*Math.sin(2*Math.PI*Je),Y[1]=$e*Math.cos(2*Math.PI*Je),Y[2]=xt*Math.sin(2*Math.PI*Te),Y[3]=xt*Math.cos(2*Math.PI*Te),Y}function Ne(Y,de){var Je=de[0],Te=de[1],$e=de[2],xt=de[3],ke=Je*Je+Te*Te+$e*$e+xt*xt,et=ke?1/ke:0;return Y[0]=-Je*et,Y[1]=-Te*et,Y[2]=-$e*et,Y[3]=xt*et,Y}function Ae(Y,de){return Y[0]=-de[0],Y[1]=-de[1],Y[2]=-de[2],Y[3]=de[3],Y}function be(Y,de){var Je=de[0]+de[4]+de[8],Te;if(Je>0)Te=Math.sqrt(Je+1),Y[3]=.5*Te,Te=.5/Te,Y[0]=(de[5]-de[7])*Te,Y[1]=(de[6]-de[2])*Te,Y[2]=(de[1]-de[3])*Te;else{var $e=0;de[4]>de[0]&&($e=1),de[8]>de[$e*3+$e]&&($e=2);var xt=($e+1)%3,ke=($e+2)%3;Te=Math.sqrt(de[$e*3+$e]-de[xt*3+xt]-de[ke*3+ke]+1),Y[$e]=.5*Te,Te=.5/Te,Y[3]=(de[xt*3+ke]-de[ke*3+xt])*Te,Y[xt]=(de[xt*3+$e]+de[$e*3+xt])*Te,Y[ke]=(de[ke*3+$e]+de[$e*3+ke])*Te}return Y}function Ye(Y,de,Je,Te){var $e=.5*Math.PI/180;de*=$e,Je*=$e,Te*=$e;var xt=Math.sin(de),ke=Math.cos(de),et=Math.sin(Je),yt=Math.cos(Je),B=Math.sin(Te),ie=Math.cos(Te);return Y[0]=xt*yt*ie-ke*et*B,Y[1]=ke*et*ie+xt*yt*B,Y[2]=ke*yt*B-xt*et*ie,Y[3]=ke*yt*ie+xt*et*B,Y}function Ee(Y){return"quat("+Y[0]+", "+Y[1]+", "+Y[2]+", "+Y[3]+")"}var We=A.d9,je=A.al,_t=A.JG,It=A.t8,kt=A.IH,Ut=L,At=A.bA,at=A.AK,Ot=A.t7,ue=A.kE,Ue=null,vt=A.we,Jt=null,Qe=A.Fv,rt=A.I6,bt=A.fS,ze=function(){var Y=O.Ue(),de=O.al(1,0,0),Je=O.al(0,1,0);return function(Te,$e,xt){var ke=O.AK($e,xt);return ke<-.999999?(O.kC(Y,de,$e),O.Zh(Y)<1e-6&&O.kC(Y,Je,$e),O.Fv(Y,Y),x(Te,Y,Math.PI),Te):ke>.999999?(Te[0]=0,Te[1]=0,Te[2]=0,Te[3]=1,Te):(O.kC(Y,$e,xt),Te[0]=Y[0],Te[1]=Y[1],Te[2]=Y[2],Te[3]=1+ke,Qe(Te,Te))}}(),Ze=function(){var Y=S(),de=S();return function(Je,Te,$e,xt,ke,et){return xe(Y,Te,ke,et),xe(de,$e,xt,et),xe(Je,Y,de,2*et*(1-et)),Je}}(),q=function(){var Y=k.Ue();return function(de,Je,Te,$e){return Y[0]=Te[0],Y[3]=Te[1],Y[6]=Te[2],Y[1]=$e[0],Y[4]=$e[1],Y[7]=$e[2],Y[2]=-Je[0],Y[5]=-Je[1],Y[8]=-Je[2],Qe(de,be(de,Y))}}()},31437:function(ae,ne,b){"use strict";b.d(ne,{AK:function(){return We},Fv:function(){return Ee},I6:function(){return Jt},JG:function(){return S},Ue:function(){return k},t8:function(){return R}});var w=b(49685);function k(){var Te=new w.WT(2);return w.WT!=Float32Array&&(Te[0]=0,Te[1]=0),Te}function O(Te){var $e=new glMatrix.ARRAY_TYPE(2);return $e[0]=Te[0],$e[1]=Te[1],$e}function A(Te,$e){var xt=new glMatrix.ARRAY_TYPE(2);return xt[0]=Te,xt[1]=$e,xt}function S(Te,$e){return Te[0]=$e[0],Te[1]=$e[1],Te}function R(Te,$e,xt){return Te[0]=$e,Te[1]=xt,Te}function x(Te,$e,xt){return Te[0]=$e[0]+xt[0],Te[1]=$e[1]+xt[1],Te}function E(Te,$e,xt){return Te[0]=$e[0]-xt[0],Te[1]=$e[1]-xt[1],Te}function N(Te,$e,xt){return Te[0]=$e[0]*xt[0],Te[1]=$e[1]*xt[1],Te}function L(Te,$e,xt){return Te[0]=$e[0]/xt[0],Te[1]=$e[1]/xt[1],Te}function P(Te,$e){return Te[0]=Math.ceil($e[0]),Te[1]=Math.ceil($e[1]),Te}function W(Te,$e){return Te[0]=Math.floor($e[0]),Te[1]=Math.floor($e[1]),Te}function K(Te,$e,xt){return Te[0]=Math.min($e[0],xt[0]),Te[1]=Math.min($e[1],xt[1]),Te}function re(Te,$e,xt){return Te[0]=Math.max($e[0],xt[0]),Te[1]=Math.max($e[1],xt[1]),Te}function ye(Te,$e){return Te[0]=Math.round($e[0]),Te[1]=Math.round($e[1]),Te}function ge(Te,$e,xt){return Te[0]=$e[0]*xt,Te[1]=$e[1]*xt,Te}function ce(Te,$e,xt,ke){return Te[0]=$e[0]+xt[0]*ke,Te[1]=$e[1]+xt[1]*ke,Te}function xe(Te,$e){var xt=$e[0]-Te[0],ke=$e[1]-Te[1];return Math.hypot(xt,ke)}function fe(Te,$e){var xt=$e[0]-Te[0],ke=$e[1]-Te[1];return xt*xt+ke*ke}function Ne(Te){var $e=Te[0],xt=Te[1];return Math.hypot($e,xt)}function Ae(Te){var $e=Te[0],xt=Te[1];return $e*$e+xt*xt}function be(Te,$e){return Te[0]=-$e[0],Te[1]=-$e[1],Te}function Ye(Te,$e){return Te[0]=1/$e[0],Te[1]=1/$e[1],Te}function Ee(Te,$e){var xt=$e[0],ke=$e[1],et=xt*xt+ke*ke;return et>0&&(et=1/Math.sqrt(et)),Te[0]=$e[0]*et,Te[1]=$e[1]*et,Te}function We(Te,$e){return Te[0]*$e[0]+Te[1]*$e[1]}function je(Te,$e,xt){var ke=$e[0]*xt[1]-$e[1]*xt[0];return Te[0]=Te[1]=0,Te[2]=ke,Te}function _t(Te,$e,xt,ke){var et=$e[0],yt=$e[1];return Te[0]=et+ke*(xt[0]-et),Te[1]=yt+ke*(xt[1]-yt),Te}function It(Te,$e){$e=$e||1;var xt=glMatrix.RANDOM()*2*Math.PI;return Te[0]=Math.cos(xt)*$e,Te[1]=Math.sin(xt)*$e,Te}function kt(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[2]*et,Te[1]=xt[1]*ke+xt[3]*et,Te}function Ut(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[2]*et+xt[4],Te[1]=xt[1]*ke+xt[3]*et+xt[5],Te}function At(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[3]*et+xt[6],Te[1]=xt[1]*ke+xt[4]*et+xt[7],Te}function at(Te,$e,xt){var ke=$e[0],et=$e[1];return Te[0]=xt[0]*ke+xt[4]*et+xt[12],Te[1]=xt[1]*ke+xt[5]*et+xt[13],Te}function Ot(Te,$e,xt,ke){var et=$e[0]-xt[0],yt=$e[1]-xt[1],B=Math.sin(ke),ie=Math.cos(ke);return Te[0]=et*ie-yt*B+xt[0],Te[1]=et*B+yt*ie+xt[1],Te}function ue(Te,$e){var xt=Te[0],ke=Te[1],et=$e[0],yt=$e[1],B=Math.sqrt(xt*xt+ke*ke)*Math.sqrt(et*et+yt*yt),ie=B&&(xt*et+ke*yt)/B;return Math.acos(Math.min(Math.max(ie,-1),1))}function Ue(Te){return Te[0]=0,Te[1]=0,Te}function vt(Te){return"vec2("+Te[0]+", "+Te[1]+")"}function Jt(Te,$e){return Te[0]===$e[0]&&Te[1]===$e[1]}function Qe(Te,$e){var xt=Te[0],ke=Te[1],et=$e[0],yt=$e[1];return Math.abs(xt-et)<=glMatrix.EPSILON*Math.max(1,Math.abs(xt),Math.abs(et))&&Math.abs(ke-yt)<=glMatrix.EPSILON*Math.max(1,Math.abs(ke),Math.abs(yt))}var rt=null,bt=null,ze=null,Ze=null,q=null,Y=null,de=null,Je=function(){var Te=k();return function($e,xt,ke,et,yt,B){var ie,ct;for(xt||(xt=2),ke||(ke=0),et?ct=Math.min(et*xt+ke,$e.length):ct=$e.length,ie=ke;ie0&&(ct=1/Math.sqrt(ct)),ke[0]=et[0]*ct,ke[1]=et[1]*ct,ke[2]=et[2]*ct,ke}function We(ke,et){return ke[0]*et[0]+ke[1]*et[1]+ke[2]*et[2]}function je(ke,et,yt){var B=et[0],ie=et[1],ct=et[2],Mt=yt[0],ht=yt[1],Yt=yt[2];return ke[0]=ie*Yt-ct*ht,ke[1]=ct*Mt-B*Yt,ke[2]=B*ht-ie*Mt,ke}function _t(ke,et,yt,B){var ie=et[0],ct=et[1],Mt=et[2];return ke[0]=ie+B*(yt[0]-ie),ke[1]=ct+B*(yt[1]-ct),ke[2]=Mt+B*(yt[2]-Mt),ke}function It(ke,et,yt,B,ie,ct){var Mt=ct*ct,ht=Mt*(2*ct-3)+1,Yt=Mt*(ct-2)+ct,en=Mt*(ct-1),nn=Mt*(3-2*ct);return ke[0]=et[0]*ht+yt[0]*Yt+B[0]*en+ie[0]*nn,ke[1]=et[1]*ht+yt[1]*Yt+B[1]*en+ie[1]*nn,ke[2]=et[2]*ht+yt[2]*Yt+B[2]*en+ie[2]*nn,ke}function kt(ke,et,yt,B,ie,ct){var Mt=1-ct,ht=Mt*Mt,Yt=ct*ct,en=ht*Mt,nn=3*ct*ht,Me=3*Yt*Mt,te=Yt*ct;return ke[0]=et[0]*en+yt[0]*nn+B[0]*Me+ie[0]*te,ke[1]=et[1]*en+yt[1]*nn+B[1]*Me+ie[1]*te,ke[2]=et[2]*en+yt[2]*nn+B[2]*Me+ie[2]*te,ke}function Ut(ke,et){et=et||1;var yt=glMatrix.RANDOM()*2*Math.PI,B=glMatrix.RANDOM()*2-1,ie=Math.sqrt(1-B*B)*et;return ke[0]=Math.cos(yt)*ie,ke[1]=Math.sin(yt)*ie,ke[2]=B*et,ke}function At(ke,et,yt){var B=et[0],ie=et[1],ct=et[2],Mt=yt[3]*B+yt[7]*ie+yt[11]*ct+yt[15];return Mt=Mt||1,ke[0]=(yt[0]*B+yt[4]*ie+yt[8]*ct+yt[12])/Mt,ke[1]=(yt[1]*B+yt[5]*ie+yt[9]*ct+yt[13])/Mt,ke[2]=(yt[2]*B+yt[6]*ie+yt[10]*ct+yt[14])/Mt,ke}function at(ke,et,yt){var B=et[0],ie=et[1],ct=et[2];return ke[0]=B*yt[0]+ie*yt[3]+ct*yt[6],ke[1]=B*yt[1]+ie*yt[4]+ct*yt[7],ke[2]=B*yt[2]+ie*yt[5]+ct*yt[8],ke}function Ot(ke,et,yt){var B=yt[0],ie=yt[1],ct=yt[2],Mt=yt[3],ht=et[0],Yt=et[1],en=et[2],nn=ie*en-ct*Yt,Me=ct*ht-B*en,te=B*Yt-ie*ht,Fe=ie*te-ct*Me,Xe=ct*nn-B*te,Pe=B*Me-ie*nn,Ie=Mt*2;return nn*=Ie,Me*=Ie,te*=Ie,Fe*=2,Xe*=2,Pe*=2,ke[0]=ht+nn+Fe,ke[1]=Yt+Me+Xe,ke[2]=en+te+Pe,ke}function ue(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[0],ct[1]=ie[1]*Math.cos(B)-ie[2]*Math.sin(B),ct[2]=ie[1]*Math.sin(B)+ie[2]*Math.cos(B),ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function Ue(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[2]*Math.sin(B)+ie[0]*Math.cos(B),ct[1]=ie[1],ct[2]=ie[2]*Math.cos(B)-ie[0]*Math.sin(B),ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function vt(ke,et,yt,B){var ie=[],ct=[];return ie[0]=et[0]-yt[0],ie[1]=et[1]-yt[1],ie[2]=et[2]-yt[2],ct[0]=ie[0]*Math.cos(B)-ie[1]*Math.sin(B),ct[1]=ie[0]*Math.sin(B)+ie[1]*Math.cos(B),ct[2]=ie[2],ke[0]=ct[0]+yt[0],ke[1]=ct[1]+yt[1],ke[2]=ct[2]+yt[2],ke}function Jt(ke,et){var yt=ke[0],B=ke[1],ie=ke[2],ct=et[0],Mt=et[1],ht=et[2],Yt=Math.sqrt(yt*yt+B*B+ie*ie),en=Math.sqrt(ct*ct+Mt*Mt+ht*ht),nn=Yt*en,Me=nn&&We(ke,et)/nn;return Math.acos(Math.min(Math.max(Me,-1),1))}function Qe(ke){return ke[0]=0,ke[1]=0,ke[2]=0,ke}function rt(ke){return"vec3("+ke[0]+", "+ke[1]+", "+ke[2]+")"}function bt(ke,et){return ke[0]===et[0]&&ke[1]===et[1]&&ke[2]===et[2]}function ze(ke,et){var yt=ke[0],B=ke[1],ie=ke[2],ct=et[0],Mt=et[1],ht=et[2];return Math.abs(yt-ct)<=w.Ib*Math.max(1,Math.abs(yt),Math.abs(ct))&&Math.abs(B-Mt)<=w.Ib*Math.max(1,Math.abs(B),Math.abs(Mt))&&Math.abs(ie-ht)<=w.Ib*Math.max(1,Math.abs(ie),Math.abs(ht))}var Ze=N,q=null,Y=null,de=fe,Je=null,Te=A,$e=null,xt=function(){var ke=k();return function(et,yt,B,ie,ct,Mt){var ht,Yt;for(yt||(yt=3),B||(B=0),ie?Yt=Math.min(ie*yt+B,et.length):Yt=et.length,ht=B;ht0&&(xt=1/Math.sqrt(xt)),q[0]=de*xt,q[1]=Je*xt,q[2]=Te*xt,q[3]=$e*xt,q}function We(q,Y){return q[0]*Y[0]+q[1]*Y[1]+q[2]*Y[2]+q[3]*Y[3]}function je(q,Y,de,Je){var Te=de[0]*Je[1]-de[1]*Je[0],$e=de[0]*Je[2]-de[2]*Je[0],xt=de[0]*Je[3]-de[3]*Je[0],ke=de[1]*Je[2]-de[2]*Je[1],et=de[1]*Je[3]-de[3]*Je[1],yt=de[2]*Je[3]-de[3]*Je[2],B=Y[0],ie=Y[1],ct=Y[2],Mt=Y[3];return q[0]=ie*yt-ct*et+Mt*ke,q[1]=-(B*yt)+ct*xt-Mt*$e,q[2]=B*et-ie*xt+Mt*Te,q[3]=-(B*ke)+ie*$e-ct*Te,q}function _t(q,Y,de,Je){var Te=Y[0],$e=Y[1],xt=Y[2],ke=Y[3];return q[0]=Te+Je*(de[0]-Te),q[1]=$e+Je*(de[1]-$e),q[2]=xt+Je*(de[2]-xt),q[3]=ke+Je*(de[3]-ke),q}function It(q,Y){Y=Y||1;var de,Je,Te,$e,xt,ke;do de=glMatrix.RANDOM()*2-1,Je=glMatrix.RANDOM()*2-1,xt=de*de+Je*Je;while(xt>=1);do Te=glMatrix.RANDOM()*2-1,$e=glMatrix.RANDOM()*2-1,ke=Te*Te+$e*$e;while(ke>=1);var et=Math.sqrt((1-xt)/ke);return q[0]=Y*de,q[1]=Y*Je,q[2]=Y*Te*et,q[3]=Y*$e*et,q}function kt(q,Y,de){var Je=Y[0],Te=Y[1],$e=Y[2],xt=Y[3];return q[0]=de[0]*Je+de[4]*Te+de[8]*$e+de[12]*xt,q[1]=de[1]*Je+de[5]*Te+de[9]*$e+de[13]*xt,q[2]=de[2]*Je+de[6]*Te+de[10]*$e+de[14]*xt,q[3]=de[3]*Je+de[7]*Te+de[11]*$e+de[15]*xt,q}function Ut(q,Y,de){var Je=Y[0],Te=Y[1],$e=Y[2],xt=de[0],ke=de[1],et=de[2],yt=de[3],B=yt*Je+ke*$e-et*Te,ie=yt*Te+et*Je-xt*$e,ct=yt*$e+xt*Te-ke*Je,Mt=-xt*Je-ke*Te-et*$e;return q[0]=B*yt+Mt*-xt+ie*-et-ct*-ke,q[1]=ie*yt+Mt*-ke+ct*-xt-B*-et,q[2]=ct*yt+Mt*-et+B*-ke-ie*-xt,q[3]=Y[3],q}function At(q){return q[0]=0,q[1]=0,q[2]=0,q[3]=0,q}function at(q){return"vec4("+q[0]+", "+q[1]+", "+q[2]+", "+q[3]+")"}function Ot(q,Y){return q[0]===Y[0]&&q[1]===Y[1]&&q[2]===Y[2]&&q[3]===Y[3]}function ue(q,Y){var de=q[0],Je=q[1],Te=q[2],$e=q[3],xt=Y[0],ke=Y[1],et=Y[2],yt=Y[3];return Math.abs(de-xt)<=w.Ib*Math.max(1,Math.abs(de),Math.abs(xt))&&Math.abs(Je-ke)<=w.Ib*Math.max(1,Math.abs(Je),Math.abs(ke))&&Math.abs(Te-et)<=w.Ib*Math.max(1,Math.abs(Te),Math.abs(et))&&Math.abs($e-yt)<=w.Ib*Math.max(1,Math.abs($e),Math.abs(yt))}var Ue=null,vt=null,Jt=null,Qe=null,rt=null,bt=null,ze=null,Ze=function(){var q=k();return function(Y,de,Je,Te,$e,xt){var ke,et;for(de||(de=4),Je||(Je=0),Te?et=Math.min(Te*de+Je,Y.length):et=Y.length,ke=Je;ke0&&(W=P.removeMin(),K=L[W],K.distance!==Number.POSITIVE_INFINITY);)N(W).forEach(re);return L}},9096:function(ae,ne,b){var w=b(89126),k=b(5023);ae.exports=O;function O(A){return w.filter(k(A),function(S){return S.length>1||S.length===1&&A.hasEdge(S[0],S[0])})}},38924:function(ae,ne,b){var w=b(89126);ae.exports=O;var k=w.constant(1);function O(S,R,x){return A(S,R||k,x||function(E){return S.outEdges(E)})}function A(S,R,x){var E={},N=S.nodes();return N.forEach(function(L){E[L]={},E[L][L]={distance:0},N.forEach(function(P){L!==P&&(E[L][P]={distance:Number.POSITIVE_INFINITY})}),x(L).forEach(function(P){var W=P.v===L?P.w:P.v,K=R(P);E[L][W]={distance:K,predecessor:L}})}),N.forEach(function(L){var P=E[L];N.forEach(function(W){var K=E[W];N.forEach(function(re){var ye=K[L],ge=P[re],ce=K[re],xe=ye.distance+ge.distance;xe0;){if(L=N.removeMin(),w.has(E,L))x.setEdge(L,E[L]);else{if(W)throw new Error("Input graph is not connected: "+S);W=!0}S.nodeEdges(L).forEach(P)}return x}},5023:function(ae,ne,b){var w=b(89126);ae.exports=k;function k(O){var A=0,S=[],R={},x=[];function E(N){var L=R[N]={onStack:!0,lowlink:A,index:A++};if(S.push(N),O.successors(N).forEach(function(K){w.has(R,K)?R[K].onStack&&(L.lowlink=Math.min(L.lowlink,R[K].index)):(E(K),L.lowlink=Math.min(L.lowlink,R[K].lowlink))}),L.lowlink===L.index){var P=[],W;do W=S.pop(),R[W].onStack=!1,P.push(W);while(N!==W);x.push(P)}}return O.nodes().forEach(function(N){w.has(R,N)||E(N)}),x}},2166:function(ae,ne,b){var w=b(89126);ae.exports=k,k.CycleException=O;function k(A){var S={},R={},x=[];function E(N){if(w.has(R,N))throw new O;w.has(S,N)||(R[N]=!0,S[N]=!0,w.each(A.predecessors(N),E),delete R[N],x.push(N))}if(w.each(A.sinks(),E),w.size(S)!==A.nodeCount())throw new O;return x}function O(){}O.prototype=new Error},75639:function(ae,ne,b){var w=b(89126);ae.exports=k;function k(){this._arr=[],this._keyIndices={}}k.prototype.size=function(){return this._arr.length},k.prototype.keys=function(){return this._arr.map(function(O){return O.key})},k.prototype.has=function(O){return w.has(this._keyIndices,O)},k.prototype.priority=function(O){var A=this._keyIndices[O];if(A!==void 0)return this._arr[A].priority},k.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},k.prototype.add=function(O,A){var S=this._keyIndices;if(O=String(O),!w.has(S,O)){var R=this._arr,x=R.length;return S[O]=x,R.push({key:O,priority:A}),this._decrease(x),!0}return!1},k.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var O=this._arr.pop();return delete this._keyIndices[O.key],this._heapify(0),O.key},k.prototype.decrease=function(O,A){var S=this._keyIndices[O];if(A>this._arr[S].priority)throw new Error("New priority is greater than current priority. Key: "+O+" Old: "+this._arr[S].priority+" New: "+A);this._arr[S].priority=A,this._decrease(S)},k.prototype._heapify=function(O){var A=this._arr,S=2*O,R=S+1,x=O;S>1,!(A[R].priority1?re.setNode(ye,W):re.setNode(ye)}),this},S.prototype.setNode=function(P,W){return w.has(this._nodes,P)?(arguments.length>1&&(this._nodes[P]=W),this):(this._nodes[P]=arguments.length>1?W:this._defaultNodeLabelFn(P),this._isCompound&&(this._parent[P]=O,this._children[P]={},this._children[O][P]=!0),this._in[P]={},this._preds[P]={},this._out[P]={},this._sucs[P]={},++this._nodeCount,this)},S.prototype.node=function(P){return this._nodes[P]},S.prototype.hasNode=function(P){return w.has(this._nodes,P)},S.prototype.removeNode=function(P){var W=this;if(w.has(this._nodes,P)){var K=function(re){W.removeEdge(W._edgeObjs[re])};delete this._nodes[P],this._isCompound&&(this._removeFromParentsChildList(P),delete this._parent[P],w.each(this.children(P),function(re){W.setParent(re)}),delete this._children[P]),w.each(w.keys(this._in[P]),K),delete this._in[P],delete this._preds[P],w.each(w.keys(this._out[P]),K),delete this._out[P],delete this._sucs[P],--this._nodeCount}return this},S.prototype.setParent=function(P,W){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(w.isUndefined(W))W=O;else{W+="";for(var K=W;!w.isUndefined(K);K=this.parent(K))if(K===P)throw new Error("Setting "+W+" as parent of "+P+" would create a cycle");this.setNode(W)}return this.setNode(P),this._removeFromParentsChildList(P),this._parent[P]=W,this._children[W][P]=!0,this},S.prototype._removeFromParentsChildList=function(P){delete this._children[this._parent[P]][P]},S.prototype.parent=function(P){if(this._isCompound){var W=this._parent[P];if(W!==O)return W}},S.prototype.children=function(P){if(w.isUndefined(P)&&(P=O),this._isCompound){var W=this._children[P];if(W)return w.keys(W)}else{if(P===O)return this.nodes();if(this.hasNode(P))return[]}},S.prototype.predecessors=function(P){var W=this._preds[P];if(W)return w.keys(W)},S.prototype.successors=function(P){var W=this._sucs[P];if(W)return w.keys(W)},S.prototype.neighbors=function(P){var W=this.predecessors(P);if(W)return w.union(W,this.successors(P))},S.prototype.isLeaf=function(P){var W;return this.isDirected()?W=this.successors(P):W=this.neighbors(P),W.length===0},S.prototype.filterNodes=function(P){var W=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});W.setGraph(this.graph());var K=this;w.each(this._nodes,function(ge,ce){P(ce)&&W.setNode(ce,ge)}),w.each(this._edgeObjs,function(ge){W.hasNode(ge.v)&&W.hasNode(ge.w)&&W.setEdge(ge,K.edge(ge))});var re={};function ye(ge){var ce=K.parent(ge);return ce===void 0||W.hasNode(ce)?(re[ge]=ce,ce):ce in re?re[ce]:ye(ce)}return this._isCompound&&w.each(W.nodes(),function(ge){W.setParent(ge,ye(ge))}),W},S.prototype.setDefaultEdgeLabel=function(P){return w.isFunction(P)||(P=w.constant(P)),this._defaultEdgeLabelFn=P,this},S.prototype.edgeCount=function(){return this._edgeCount},S.prototype.edges=function(){return w.values(this._edgeObjs)},S.prototype.setPath=function(P,W){var K=this,re=arguments;return w.reduce(P,function(ye,ge){return re.length>1?K.setEdge(ye,ge,W):K.setEdge(ye,ge),ge}),this},S.prototype.setEdge=function(){var P,W,K,re,ye=!1,ge=arguments[0];typeof ge=="object"&&ge!==null&&"v"in ge?(P=ge.v,W=ge.w,K=ge.name,arguments.length===2&&(re=arguments[1],ye=!0)):(P=ge,W=arguments[1],K=arguments[3],arguments.length>2&&(re=arguments[2],ye=!0)),P=""+P,W=""+W,w.isUndefined(K)||(K=""+K);var ce=E(this._isDirected,P,W,K);if(w.has(this._edgeLabels,ce))return ye&&(this._edgeLabels[ce]=re),this;if(!w.isUndefined(K)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(P),this.setNode(W),this._edgeLabels[ce]=ye?re:this._defaultEdgeLabelFn(P,W,K);var xe=N(this._isDirected,P,W,K);return P=xe.v,W=xe.w,Object.freeze(xe),this._edgeObjs[ce]=xe,R(this._preds[W],P),R(this._sucs[P],W),this._in[W][ce]=xe,this._out[P][ce]=xe,this._edgeCount++,this},S.prototype.edge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K);return this._edgeLabels[re]},S.prototype.hasEdge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K);return w.has(this._edgeLabels,re)},S.prototype.removeEdge=function(P,W,K){var re=arguments.length===1?L(this._isDirected,arguments[0]):E(this._isDirected,P,W,K),ye=this._edgeObjs[re];return ye&&(P=ye.v,W=ye.w,delete this._edgeLabels[re],delete this._edgeObjs[re],x(this._preds[W],P),x(this._sucs[P],W),delete this._in[W][re],delete this._out[P][re],this._edgeCount--),this},S.prototype.inEdges=function(P,W){var K=this._in[P];if(K){var re=w.values(K);return W?w.filter(re,function(ye){return ye.v===W}):re}},S.prototype.outEdges=function(P,W){var K=this._out[P];if(K){var re=w.values(K);return W?w.filter(re,function(ye){return ye.w===W}):re}},S.prototype.nodeEdges=function(P,W){var K=this.inEdges(P,W);if(K)return K.concat(this.outEdges(P,W))};function R(P,W){P[W]?P[W]++:P[W]=1}function x(P,W){--P[W]||delete P[W]}function E(P,W,K,re){var ye=""+W,ge=""+K;if(!P&&ye>ge){var ce=ye;ye=ge,ge=ce}return ye+A+ge+A+(w.isUndefined(re)?k:re)}function N(P,W,K,re){var ye=""+W,ge=""+K;if(!P&&ye>ge){var ce=ye;ye=ge,ge=ce}var xe={v:ye,w:ge};return re&&(xe.name=re),xe}function L(P,W){return E(P,W.v,W.w,W.name)}},82354:function(ae,ne,b){ae.exports={Graph:b(30771),version:b(49631)}},28974:function(ae,ne,b){var w=b(89126),k=b(30771);ae.exports={write:O,read:R};function O(x){var E={options:{directed:x.isDirected(),multigraph:x.isMultigraph(),compound:x.isCompound()},nodes:A(x),edges:S(x)};return w.isUndefined(x.graph())||(E.value=w.clone(x.graph())),E}function A(x){return w.map(x.nodes(),function(E){var N=x.node(E),L=x.parent(E),P={v:E};return w.isUndefined(N)||(P.value=N),w.isUndefined(L)||(P.parent=L),P})}function S(x){return w.map(x.edges(),function(E){var N=x.edge(E),L={v:E.v,w:E.w};return w.isUndefined(E.name)||(L.name=E.name),w.isUndefined(N)||(L.value=N),L})}function R(x){var E=new k(x.options).setGraph(x.value);return w.each(x.nodes,function(N){E.setNode(N.v,N.value),N.parent&&E.setParent(N.v,N.parent)}),w.each(x.edges,function(N){E.setEdge({v:N.v,w:N.w,name:N.name},N.value)}),E}},89126:function(ae,ne,b){var w;try{w={clone:b(66678),constant:b(75703),each:b(85768),filter:b(63105),has:b(18721),isArray:b(1469),isEmpty:b(58367),isFunction:b(23560),isUndefined:b(52353),keys:b(3674),map:b(35161),reduce:b(54061),size:b(84238),transform:b(68718),union:b(93386),values:b(52628)}}catch(k){}w||(w=window._),ae.exports=w},49631:function(ae){ae.exports="2.1.8"},80817:function(ae){function ne(O,A,S){return(A[0]-O[0])*(S[1]-O[1])-(A[1]-O[1])*(S[0]-O[0])}function b(O){const A=[];for(let S=0;S=2&&ne(A[A.length-2],A[A.length-1],O[S])<=0;)A.pop();A.push(O[S])}return A.pop(),A}function w(O){const A=O.reverse(),S=[];for(let R=0;R=2&&ne(S[S.length-2],S[S.length-1],A[R])<=0;)S.pop();S.push(A[R])}return S.pop(),S}function k(O){const A=b(O),R=w(O).concat(A);return R.push(O[0]),R}ae.exports=k},63652:function(ae){ae.exports={toXy:function(ne,b){return b===void 0?ne.slice():ne.map(function(w){return new Function("pt","return [pt"+b[0]+",pt"+b[1]+"];")(w)})},fromXy:function(ne,b){return b===void 0?ne.slice():ne.map(function(w){return new Function("pt","const o = {}; o"+b[0]+"= pt[0]; o"+b[1]+"= pt[1]; return o;")(w)})}}},58867:function(ae){function ne(w,k){this._cells=[],this._cellSize=k,this._reverseCellSize=1/k;for(let O=0;O=0;be--)ce[be][0]Ne&&(Ne=ce[be][0]),ce[be][1]>Ae&&(Ae=ce[be][1]);return[Ne-xe,Ae-fe]}function P(ce){return[Math.min(ce[0][0],ce[1][0]),Math.min(ce[0][1],ce[1][1]),Math.max(ce[0][0],ce[1][0]),Math.max(ce[0][1],ce[1][1])]}function W(ce,xe,fe){let Ne=null,Ae=ye,be=ye,Ye,Ee;for(let We=0;WeAe&&Ee>be&&!N([ce[0],xe[We]],fe)&&!N([ce[1],xe[We]],fe)&&(Ae=Ye,be=Ee,Ne=xe[We]);return Ne}function K(ce,xe,fe,Ne,Ae){let be=!1;for(let Ye=0;YeIt||fe[1]>kt));It>=fe[0]&&kt>=fe[1]&&Ae.add(We),Ut!==null&&(ce.splice(Ye+1,0,Ut),Ne.removePoint(Ut),be=!0)}return be?K(ce,xe,fe,Ne,Ae):ce}function re(ce,xe,fe){let Ne=xe||20;const Ae=S(R(O.toXy(ce,fe)));if(Ae.length<4){const It=Ae.concat([Ae[0]]);return fe?O.fromXy(It,fe):It}const be=L(Ae),Ye=[be[0]*ge,be[1]*ge],Ee=A(Ae),We=Ae.filter(function(It){return Ee.indexOf(It)<0}),je=Math.ceil(1/(Ae.length/(be[0]*be[1]))),_t=K(Ee,Math.pow(Ne,2),Ye,k(We,je),new Set);return fe?O.fromXy(_t,fe):_t}const ye=Math.cos(90/(180/Math.PI)),ge=.6;ae.exports=re},77444:function(ae){function ne(w,k,O,A,S,R){const x=(R-k)*(O-w)-(A-k)*(S-w);return x>0?!0:!(x<0)}function b(w,k){const O=w[0][0],A=w[0][1],S=w[1][0],R=w[1][1],x=k[0][0],E=k[0][1],N=k[1][0],L=k[1][1];return ne(O,A,x,E,N,L)!==ne(S,R,x,E,N,L)&&ne(O,A,S,R,x,E)!==ne(O,A,S,R,N,L)}ae.exports=b},44091:function(ae,ne,b){"use strict";b.r(ne),b.d(ne,{isAnyArray:function(){return k}});const w=Object.prototype.toString;function k(O){const A=w.call(O);return A.endsWith("Array]")&&!A.includes("Big")}},18552:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"DataView");ae.exports=O},53818:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"Promise");ae.exports=O},58525:function(ae,ne,b){var w=b(10852),k=b(55639),O=w(k,"Set");ae.exports=O},88668:function(ae,ne,b){var w=b(83369),k=b(90619),O=b(72385);function A(S){var R=-1,x=S==null?0:S.length;for(this.__data__=new w;++R-1}ae.exports=k},1196:function(ae){function ne(b,w,k){for(var O=-1,A=b==null?0:b.length;++O0&&R(P)?S>1?O(P,S-1,R,x,E):w(E,P):x||(E[E.length]=P)}return E}ae.exports=O},47816:function(ae,ne,b){var w=b(28483),k=b(3674);function O(A,S){return A&&w(A,S,k)}ae.exports=O},97786:function(ae,ne,b){var w=b(71811),k=b(40327);function O(A,S){S=w(S,A);for(var R=0,x=S.length;A!=null&&Rw}ae.exports=ne},78565:function(ae){var ne=Object.prototype,b=ne.hasOwnProperty;function w(k,O){return k!=null&&b.call(k,O)}ae.exports=w},13:function(ae){function ne(b,w){return b!=null&&w in Object(b)}ae.exports=ne},42118:function(ae,ne,b){var w=b(41848),k=b(62722),O=b(42351);function A(S,R,x){return R===R?O(S,R,x):w(S,k,x)}ae.exports=A},90939:function(ae,ne,b){var w=b(2492),k=b(37005);function O(A,S,R,x,E){return A===S?!0:A==null||S==null||!k(A)&&!k(S)?A!==A&&S!==S:w(A,S,R,x,O,E)}ae.exports=O},2492:function(ae,ne,b){var w=b(46384),k=b(67114),O=b(18351),A=b(16096),S=b(64160),R=b(1469),x=b(44144),E=b(36719),N=1,L="[object Arguments]",P="[object Array]",W="[object Object]",K=Object.prototype,re=K.hasOwnProperty;function ye(ge,ce,xe,fe,Ne,Ae){var be=R(ge),Ye=R(ce),Ee=be?P:S(ge),We=Ye?P:S(ce);Ee=Ee==L?W:Ee,We=We==L?W:We;var je=Ee==W,_t=We==W,It=Ee==We;if(It&&x(ge)){if(!x(ce))return!1;be=!0,je=!1}if(It&&!je)return Ae||(Ae=new w),be||E(ge)?k(ge,ce,xe,fe,Ne,Ae):O(ge,ce,Ee,xe,fe,Ne,Ae);if(!(xe&N)){var kt=je&&re.call(ge,"__wrapped__"),Ut=_t&&re.call(ce,"__wrapped__");if(kt||Ut){var At=kt?ge.value():ge,at=Ut?ce.value():ce;return Ae||(Ae=new w),Ne(At,at,xe,fe,Ae)}}return It?(Ae||(Ae=new w),A(ge,ce,xe,fe,Ne,Ae)):!1}ae.exports=ye},25588:function(ae,ne,b){var w=b(64160),k=b(37005),O="[object Map]";function A(S){return k(S)&&w(S)==O}ae.exports=A},2958:function(ae,ne,b){var w=b(46384),k=b(90939),O=1,A=2;function S(R,x,E,N){var L=E.length,P=L,W=!N;if(R==null)return!P;for(R=Object(R);L--;){var K=E[L];if(W&&K[2]?K[1]!==R[K[0]]:!(K[0]in R))return!1}for(;++L=x){var xe=L?null:S(N);if(xe)return R(xe);ye=!1,K=A,ce=new w}else ce=L?[]:ge;e:for(;++WA||E&&N&&P&&!L&&!W||R&&N&&P||!S&&P||!x)return 1;if(!R&&!E&&!W&&O=L)return P;var W=S[R];return P*(W=="desc"?-1:1)}}return O.index-A.index}ae.exports=k},18805:function(ae,ne,b){var w=b(98363),k=b(99551);function O(A,S){return w(A,k(A),S)}ae.exports=O},1911:function(ae,ne,b){var w=b(98363),k=b(51442);function O(A,S){return w(A,k(A),S)}ae.exports=O},99291:function(ae,ne,b){var w=b(98612);function k(O,A){return function(S,R){if(S==null)return S;if(!w(S))return O(S,R);for(var x=S.length,E=A?x:-1,N=Object(S);(A?E--:++E-1?N[L?R[P]:P]:void 0}}ae.exports=A},47445:function(ae,ne,b){var w=b(40098),k=b(16612),O=b(18601);function A(S){return function(R,x,E){return E&&typeof E!="number"&&k(R,x,E)&&(x=E=void 0),R=O(R),x===void 0?(x=R,R=0):x=O(x),E=E===void 0?Rre))return!1;var ge=W.get(x),ce=W.get(E);if(ge&&ce)return ge==E&&ce==x;var xe=-1,fe=!0,Ne=N&S?new w:void 0;for(W.set(x,E),W.set(E,x);++xe2?N[2]:void 0;for(W&&O(N[0],N[1],W)&&(P=1);++L1&&A(R,x[0],x[1])?x=[]:E>2&&A(x[0],x[1],x[2])&&(x=[x[0]]),k(R,w(x,1),[])});ae.exports=S},70479:function(ae){function ne(){return[]}ae.exports=ne},18601:function(ae,ne,b){var w=b(14841),k=1/0,O=17976931348623157e292;function A(S){if(!S)return S===0?S:0;if(S=w(S),S===k||S===-k){var R=S<0?-1:1;return R*O}return S===S?S:0}ae.exports=A},40554:function(ae,ne,b){var w=b(18601);function k(O){var A=w(O),S=A%1;return A===A?S?A-S:A:0}ae.exports=k},14841:function(ae,ne,b){var w=b(27561),k=b(13218),O=b(33448),A=NaN,S=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,x=/^0o[0-7]+$/i,E=parseInt;function N(L){if(typeof L=="number")return L;if(O(L))return A;if(k(L)){var P=typeof L.valueOf=="function"?L.valueOf():L;L=k(P)?P+"":P}if(typeof L!="string")return L===0?L:+L;L=w(L);var W=R.test(L);return W||x.test(L)?E(L.slice(2),W?2:8):S.test(L)?A:+L}ae.exports=N},79833:function(ae,ne,b){var w=b(80531);function k(O){return O==null?"":w(O)}ae.exports=k},68718:function(ae,ne,b){var w=b(77412),k=b(3118),O=b(47816),A=b(67206),S=b(85924),R=b(1469),x=b(44144),E=b(23560),N=b(13218),L=b(36719);function P(W,K,re){var ye=R(W),ge=ye||x(W)||L(W);if(K=A(K,4),re==null){var ce=W&&W.constructor;ge?re=ye?new ce:[]:N(W)?re=E(ce)?k(S(W)):{}:re={}}return(ge?w:O)(W,function(xe,fe,Ne){return K(re,xe,fe,Ne)}),re}ae.exports=P},93386:function(ae,ne,b){var w=b(21078),k=b(18460),O=b(45652),A=b(29246),S=k(function(R){return O(w(R,1,A,!0))});ae.exports=S},73955:function(ae,ne,b){var w=b(79833),k=0;function O(A){var S=++k;return w(A)+S}ae.exports=O},52628:function(ae,ne,b){var w=b(47415),k=b(3674);function O(A){return A==null?[]:w(A,k(A))}ae.exports=O},7287:function(ae,ne,b){var w=b(34865),k=b(1757);function O(A,S){return k(A||[],S||[],w)}ae.exports=O},75823:function(ae,ne,b){"use strict";b.r(ne),b.d(ne,{default:function(){return A}});var w=b(44091);function k(S){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,w.isAnyArray)(S))throw new TypeError("input must be an array");if(S.length===0)throw new TypeError("input must not be empty");var x=R.fromIndex,E=x===void 0?0:x,N=R.toIndex,L=N===void 0?S.length:N;if(E<0||E>=S.length||!Number.isInteger(E))throw new Error("fromIndex must be a positive integer smaller than length");if(L<=E||L>S.length||!Number.isInteger(L))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var P=S[E],W=E+1;WP&&(P=S[W]);return P}function O(S){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,w.isAnyArray)(S))throw new TypeError("input must be an array");if(S.length===0)throw new TypeError("input must not be empty");var x=R.fromIndex,E=x===void 0?0:x,N=R.toIndex,L=N===void 0?S.length:N;if(E<0||E>=S.length||!Number.isInteger(E))throw new Error("fromIndex must be a positive integer smaller than length");if(L<=E||L>S.length||!Number.isInteger(L))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var P=S[E],W=E+1;W1&&arguments[1]!==void 0?arguments[1]:{};if((0,w.isAnyArray)(S)){if(S.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var x;if(R.output!==void 0){if(!(0,w.isAnyArray)(R.output))throw new TypeError("output option must be an array if specified");x=R.output}else x=new Array(S.length);var E=O(S),N=k(S);if(E===N)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var L=R.min,P=L===void 0?R.autoMinMax?E:0:L,W=R.max,K=W===void 0?R.autoMinMax?N:1:W;if(P>=K)throw new RangeError("min option must be smaller than max option");for(var re=(K-P)/(N-E),ye=0;ye19?Ot:at;S&&typeof S.nodeMass=="function"&&(E=S.nodeMass);var N=new Map,L={},P=0,W=x.settings.springTransform||O;Ye(),Ne();var K=!1,re={step:function(){if(P===0)return ye(!0),!0;var ue=x.step();re.lastMove=ue,re.fire("step");var Ue=ue/P,vt=Ue<=.01;return ye(vt),vt},getNodePosition:function(ue){return At(ue).pos},setNodePosition:function(ue){var Ue=At(ue);Ue.setPosition.apply(Ue,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(ue){var Ue=L[ue];if(Ue)return{from:Ue.from.pos,to:Ue.to.pos}},getGraphRect:function(){return x.getBBox()},forEachBody:ge,pinNode:function(ue,Ue){var vt=At(ue.id);vt.isPinned=!!Ue},isNodePinned:function(ue){return At(ue.id).isPinned},dispose:function(){A.off("changed",be),re.fire("disposed")},getBody:fe,getSpring:xe,getForceVectorLength:ce,simulator:x,graph:A,lastMove:0};return w(re),re;function ye(ue){K!==ue&&(K=ue,Ae(ue))}function ge(ue){N.forEach(ue)}function ce(){var ue=0,Ue=0;return ge(function(vt){ue+=Math.abs(vt.force.x),Ue+=Math.abs(vt.force.y)}),Math.sqrt(ue*ue+Ue*Ue)}function xe(ue,Ue){var vt;if(Ue===void 0)typeof ue!="object"?vt=ue:vt=ue.id;else{var Jt=A.hasLink(ue,Ue);if(!Jt)return;vt=Jt.id}return L[vt]}function fe(ue){return N.get(ue)}function Ne(){A.on("changed",be)}function Ae(ue){re.fire("stable",ue)}function be(ue){for(var Ue=0;Ue max_{var}) max_{var} = bodyPos.{var};",{indent:6})} } ${S("boundingBox.min_{var} = min_{var};",{indent:4})} ${S("boundingBox.max_{var} = max_{var};",{indent:4})} } function resetBoundingBox() { ${S("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})} } `}},6410:function(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateBodyFunctionBody=O,ae.exports.getVectorCode=S,ae.exports.getBodyCode=A;function k(R,x){let E=O(R,x),{Body:N}=new Function(E)();return N}function O(R,x){return` ${S(R,x)} ${A(R,x)} return {Body: Body, Vector: Vector}; `}function A(R){let x=w(R),E=x("{var}",{join:", "});return` function Body(${E}) { this.isPinned = false; this.pos = new Vector(${E}); this.force = new Vector(); this.velocity = new Vector(); this.mass = 1; this.springCount = 0; this.springLength = 0; } Body.prototype.reset = function() { this.force.reset(); this.springCount = 0; this.springLength = 0; } Body.prototype.setPosition = function (${E}) { ${x("this.pos.{var} = {var} || 0;",{indent:2})} };`}function S(R,x){let E=w(R),N="";return x&&(N=`${E(` var v{var}; Object.defineProperty(this, '{var}', { set: function(v) { if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}'); v{var} = v; }, get: function() { return v{var}; } });`)}`),`function Vector(${E("{var}",{join:", "})}) { ${N} if (typeof arguments[0] === 'object') { // could be another vector let v = arguments[0]; ${E('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})} ${E("this.{var} = v.{var};",{indent:4})} } else { ${E('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})} } } Vector.prototype.reset = function () { ${E("this.{var} = ",{join:""})}0; };`}},36647:function(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateDragForceFunctionBody=O;function k(A){let S=O(A);return new Function("options",S)}function O(A){return` if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number'); return { update: function(body) { ${w(A)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})} } }; `}},34079:function(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateCreateSpringForceFunctionBody=O;function k(A){let S=O(A);return new Function("options","random",S)}function O(A){let S=w(A);return` if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number'); if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number'); return { /** * Updates forces acting on a spring */ update: function (spring) { var body1 = spring.from; var body2 = spring.to; var length = spring.length < 0 ? options.springLength : spring.length; ${S("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})} var r = Math.sqrt(${S("d{var} * d{var}",{join:" + "})}); if (r === 0) { ${S("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})} r = Math.sqrt(${S("d{var} * d{var}",{join:" + "})}); } var d = r - length; var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r; ${S("body1.force.{var} += coefficient * d{var}",{indent:6})}; body1.springCount += 1; body1.springLength += r; ${S("body2.force.{var} -= coefficient * d{var}",{indent:6})}; body2.springCount += 1; body2.springLength += r; } }; `}},51763:function(ae,ne,b){const w=b(15189);ae.exports=k,ae.exports.generateIntegratorFunctionBody=O;function k(A){let S=O(A);return new Function("bodies","timeStep","adaptiveTimeStepWeight",S)}function O(A){let S=w(A);return` var length = bodies.length; if (length === 0) return 0; ${S("var d{var} = 0, t{var} = 0;",{indent:2})} for (var i = 0; i < length; ++i) { var body = bodies[i]; if (body.isPinned) continue; if (adaptiveTimeStepWeight && body.springCount) { timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount); } var coeff = timeStep / body.mass; ${S("body.velocity.{var} += coeff * body.force.{var};",{indent:4})} ${S("var v{var} = body.velocity.{var};",{indent:4})} var v = Math.sqrt(${S("v{var} * v{var}",{join:" + "})}); if (v > 1) { // We normalize it so that we move within timeStep range. // for the case when v <= 1 - we let velocity to fade out. ${S("body.velocity.{var} = v{var} / v;",{indent:6})} } ${S("d{var} = timeStep * body.velocity.{var};",{indent:4})} ${S("body.pos.{var} += d{var};",{indent:4})} ${S("t{var} += Math.abs(d{var});",{indent:4})} } return (${S("t{var} * t{var}",{join:" + "})})/length; `}},1584:function(ae,ne,b){const w=b(15189),k=b(16422);ae.exports=O,ae.exports.generateQuadTreeFunctionBody=A,ae.exports.getInsertStackCode=N,ae.exports.getQuadNodeCode=E,ae.exports.isSamePosition=S,ae.exports.getChildBodyCode=x,ae.exports.setChildBodyCode=R;function O(L){let P=A(L);return new Function(P)()}function A(L){let P=w(L),W=Math.pow(2,L);return` ${N()} ${E(L)} ${S(L)} ${x(L)} ${R(L)} function createQuadTree(options, random) { options = options || {}; options.gravity = typeof options.gravity === 'number' ? options.gravity : -1; options.theta = typeof options.theta === 'number' ? options.theta : 0.8; var gravity = options.gravity; var updateQueue = []; var insertStack = new InsertStack(); var theta = options.theta; var nodesCache = []; var currentInCache = 0; var root = newNode(); return { insertBodies: insertBodies, /** * Gets root node if it is present */ getRoot: function() { return root; }, updateBodyForce: update, options: function(newOptions) { if (newOptions) { if (typeof newOptions.gravity === 'number') { gravity = newOptions.gravity; } if (typeof newOptions.theta === 'number') { theta = newOptions.theta; } return this; } return { gravity: gravity, theta: theta }; } }; function newNode() { // To avoid pressure on GC we reuse nodes. var node = nodesCache[currentInCache]; if (node) { ${ge(" node.")} node.body = null; node.mass = ${P("node.mass_{var} = ",{join:""})}0; ${P("node.min_{var} = node.max_{var} = ",{join:""})}0; } else { node = new QuadNode(); nodesCache[currentInCache] = node; } ++currentInCache; return node; } function update(sourceBody) { var queue = updateQueue; var v; ${P("var d{var};",{indent:4})} var r; ${P("var f{var} = 0;",{indent:4})} var queueLength = 1; var shiftIdx = 0; var pushIdx = 1; queue[0] = root; while (queueLength) { var node = queue[shiftIdx]; var body = node.body; queueLength -= 1; shiftIdx += 1; var differentBody = (body !== sourceBody); if (body && differentBody) { // If the current node is a leaf node (and it is not source body), // calculate the force exerted by the current node on body, and add this // amount to body's net force. ${P("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})} r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})}); if (r === 0) { // Poor man's protection against zero distance. ${P("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})} r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})}); } // This is standard gravitation force calculation but we divide // by r^3 to save two operations when normalizing force vector. v = gravity * body.mass * sourceBody.mass / (r * r * r); ${P("f{var} += v * d{var};",{indent:8})} } else if (differentBody) { // Otherwise, calculate the ratio s / r, where s is the width of the region // represented by the internal node, and r is the distance between the body // and the node's center-of-mass ${P("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})} r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})}); if (r === 0) { // Sorry about code duplication. I don't want to create many functions // right away. Just want to see performance first. ${P("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})} r = Math.sqrt(${P("d{var} * d{var}",{join:" + "})}); } // If s / r < \u03B8, treat this internal node as a single body, and calculate the // force it exerts on sourceBody, and add this amount to sourceBody's net force. if ((node.max_${k(0)} - node.min_${k(0)}) / r < theta) { // in the if statement above we consider node's width only // because the region was made into square during tree creation. // Thus there is no difference between using width or height. v = gravity * node.mass * sourceBody.mass / (r * r * r); ${P("f{var} += v * d{var};",{indent:10})} } else { // Otherwise, run the procedure recursively on each of the current node's children. // I intentionally unfolded this loop, to save several CPU cycles. ${ye()} } } } ${P("sourceBody.force.{var} += f{var};",{indent:4})} } function insertBodies(bodies) { ${P("var {var}min = Number.MAX_VALUE;",{indent:4})} ${P("var {var}max = Number.MIN_VALUE;",{indent:4})} var i = bodies.length; // To reduce quad tree depth we are looking for exact bounding box of all particles. while (i--) { var pos = bodies[i].pos; ${P("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})} ${P("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})} } // Makes the bounds square. var maxSideLength = -Infinity; ${P("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})} currentInCache = 0; root = newNode(); ${P("root.min_{var} = {var}min;",{indent:4})} ${P("root.max_{var} = {var}min + maxSideLength;",{indent:4})} i = bodies.length - 1; if (i >= 0) { root.body = bodies[i]; } while (i--) { insert(bodies[i], root); } } function insert(newBody) { insertStack.reset(); insertStack.push(root, newBody); while (!insertStack.isEmpty()) { var stackItem = insertStack.pop(); var node = stackItem.node; var body = stackItem.body; if (!node.body) { // This is internal node. Update the total mass of the node and center-of-mass. ${P("var {var} = body.pos.{var};",{indent:8})} node.mass += body.mass; ${P("node.mass_{var} += body.mass * {var};",{indent:8})} // Recursively insert the body in the appropriate quadrant. // But first find the appropriate quadrant. var quadIdx = 0; // Assume we are in the 0's quad. ${P("var min_{var} = node.min_{var};",{indent:8})} ${P("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})} ${re(8)} var child = getChild(node, quadIdx); if (!child) { // The node is internal but this quadrant is not taken. Add // subnode to it. child = newNode(); ${P("child.min_{var} = min_{var};",{indent:10})} ${P("child.max_{var} = max_{var};",{indent:10})} child.body = body; setChild(node, quadIdx, child); } else { // continue searching in this quadrant. insertStack.push(child, body); } } else { // We are trying to add to the leaf node. // We have to convert current leaf into internal node // and continue adding two nodes. var oldBody = node.body; node.body = null; // internal nodes do not cary bodies if (isSamePosition(oldBody.pos, body.pos)) { // Prevent infinite subdivision by bumping one node // anywhere in this quadrant var retriesCount = 3; do { var offset = random.nextDouble(); ${P("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})} ${P("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})} retriesCount -= 1; // Make sure we don't bump it out of the box. If we do, next iteration should fix it } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos)); if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) { // This is very bad, we ran out of precision. // if we do not return from the method we'll get into // infinite loop here. So we sacrifice correctness of layout, and keep the app running // Next layout iteration should get larger bounding box in the first step and fix this return; } } // Next iteration should subdivide node further. insertStack.push(node, oldBody); insertStack.push(node, body); } } } } return createQuadTree; `;function re(ce){let xe=[],fe=Array(ce+1).join(" ");for(let Ne=0;Ne max_${k(Ne)}) {`),xe.push(fe+` quadIdx = quadIdx + ${Math.pow(2,Ne)};`),xe.push(fe+` min_${k(Ne)} = max_${k(Ne)};`),xe.push(fe+` max_${k(Ne)} = node.max_${k(Ne)};`),xe.push(fe+"}");return xe.join(` `)}function ye(){let ce=Array(11).join(" "),xe=[];for(let fe=0;fe 0) { return this.stack[--this.popIdx]; } }, reset: function () { this.popIdx = 0; } }; function InsertStackElement(node, body) { this.node = node; // QuadTree node this.body = body; // physical body which needs to be inserted to node } `}},16422:function(ae){ae.exports=function(b){return b===0?"x":b===1?"y":b===2?"z":"c"+(b+1)}},45818:function(ae,ne,b){ae.exports=E;var w=b(6410),k=b(1584),O=b(30891),A=b(36647),S=b(34079),R=b(51763),x={};function E(P){var W=b(68403),K=b(35510),re=b(77797);if(P){if(P.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(P.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}P=K(P,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var ye=x[P.dimensions];if(!ye){var ge=P.dimensions;ye={Body:w(ge,P.debug),createQuadTree:k(ge),createBounds:O(ge),createDragForce:A(ge),createSpringForce:S(ge),integrate:R(ge)},x[ge]=ye}var ce=ye.Body,xe=ye.createQuadTree,fe=ye.createBounds,Ne=ye.createDragForce,Ae=ye.createSpringForce,be=ye.integrate,Ye=Ze=>new ce(Ze),Ee=b(78712).random(42),We=[],je=[],_t=xe(P,Ee),It=fe(We,P,Ee),kt=Ae(P,Ee),Ut=Ne(P),At=0,at=[],Ot=new Map,ue=0;Jt("nbody",bt),Jt("spring",ze);var Ue={bodies:We,quadTree:_t,springs:je,settings:P,addForce:Jt,removeForce:Qe,getForces:rt,step:function(){for(var Ze=0;Ze=0?de:-1);return je.push(Je),Je},getTotalMovement:function(){return At},removeSpring:function(Ze){if(Ze){var q=je.indexOf(Ze);if(q>-1)return je.splice(q,1),!0}},getBestNewBodyPosition:function(Ze){return It.getBestNewPosition(Ze)},getBBox:vt,getBoundingBox:vt,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(Ze){return Ze!==void 0?(P.gravity=Ze,_t.options({gravity:Ze}),this):P.gravity},theta:function(Ze){return Ze!==void 0?(P.theta=Ze,_t.options({theta:Ze}),this):P.theta},random:Ee};return N(P,Ue),re(Ue),Ue;function vt(){return It.update(),It.box}function Jt(Ze,q){if(Ot.has(Ze))throw new Error("Force "+Ze+" is already added");Ot.set(Ze,q),at.push(q)}function Qe(Ze){var q=at.indexOf(Ot.get(Ze));q<0||(at.splice(q,1),Ot.delete(Ze))}function rt(){return Ot}function bt(){if(We.length!==0){_t.insertBodies(We);for(var Ze=We.length;Ze--;){var q=We[Ze];q.isPinned||(q.reset(),_t.updateBodyForce(q),Ut.update(q))}}}function ze(){for(var Ze=je.length;Ze--;)kt.update(je[Ze])}}function N(P,W){for(var K in P)L(P,W,K)}function L(P,W,K){if(P.hasOwnProperty(K)&&typeof W[K]!="function"){var re=Number.isFinite(P[K]);re?W[K]=function(ye){if(ye!==void 0){if(!Number.isFinite(ye))throw new Error("Value of "+K+" should be a valid number.");return P[K]=ye,W}return P[K]}:W[K]=function(ye){return ye!==void 0?(P[K]=ye,W):P[K]}}}},68403:function(ae){ae.exports=ne;function ne(b,w,k,O){this.from=b,this.to=w,this.length=k,this.coefficient=O}},35510:function(ae){ae.exports=ne;function ne(b,w){var k;if(b||(b={}),w){for(k in w)if(w.hasOwnProperty(k)){var O=b.hasOwnProperty(k),A=typeof w[k],S=!O||typeof b[k]!==A;S?b[k]=w[k]:A==="object"&&(b[k]=ne(b[k],w[k]))}}return b}},78712:function(ae){ae.exports=ne,ae.exports.random=ne,ae.exports.randomIterator=R;function ne(x){var E=typeof x=="number"?x:+new Date;return new b(E)}function b(x){this.seed=x}b.prototype.next=S,b.prototype.nextDouble=A,b.prototype.uniform=A,b.prototype.gaussian=w,b.prototype.random=A;function w(){var x,E,N;do E=this.nextDouble()*2-1,N=this.nextDouble()*2-1,x=E*E+N*N;while(x>=1||x===0);return E*Math.sqrt(-2*Math.log(x)/x)}b.prototype.levy=k;function k(){var x=1.5,E=Math.pow(O(1+x)*Math.sin(Math.PI*x/2)/(O((1+x)/2)*x*Math.pow(2,(x-1)/2)),1/x);return this.gaussian()*E/Math.pow(Math.abs(this.gaussian()),1/x)}function O(x){return Math.sqrt(2*Math.PI/x)*Math.pow(1/Math.E*(x+1/(12*x-1/(10*x))),x)}function A(){var x=this.seed;return x=x+2127912214+(x<<12)&4294967295,x=(x^3345072700^x>>>19)&4294967295,x=x+374761393+(x<<5)&4294967295,x=(x+3550635116^x<<9)&4294967295,x=x+4251993797+(x<<3)&4294967295,x=(x^3042594569^x>>>16)&4294967295,this.seed=x,(x&268435455)/268435456}function S(x){return Math.floor(this.nextDouble()*x)}function R(x,E){var N=E||ne();if(typeof N.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:P,shuffle:L};function L(){var W,K,re;for(W=x.length-1;W>0;--W)K=N.next(W+1),re=x[K],x[K]=x[W],x[W]=re;return x}function P(W){var K,re,ye;for(K=x.length-1;K>0;--K)re=N.next(K+1),ye=x[re],x[re]=x[K],x[K]=ye,W(ye);x.length&&W(x[0])}}},95860:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return Ne}});var w=b(87462),k=b(1413),O=b(4942),A=b(97685),S=b(45987),R=b(94184),x=b.n(R),E=b(67294);function N(Ae){var be=E.useRef();be.current=Ae;var Ye=E.useCallback(function(){for(var Ee,We=arguments.length,je=new Array(We),_t=0;_t=0&&(b.splice instanceof Function||Object.getOwnPropertyDescriptor(b,b.length-1)&&b.constructor.name!=="String")}},77797:function(ae){"use strict";function ne(k){w(k);const O=b(k);return k.on=O.on,k.off=O.off,k.fire=O.fire,k}function b(k){let O=Object.create(null);return{on:function(A,S,R){if(typeof S!="function")throw new Error("callback is expected to be a function");let x=O[A];return x||(x=O[A]=[]),x.push({callback:S,ctx:R}),k},off:function(A,S){if(typeof A>"u")return O=Object.create(null),k;if(O[A])if(typeof S!="function")delete O[A];else{const R=O[A];for(let x=0;x1&&(R=Array.prototype.slice.call(arguments,1));for(let x=0;x>8&255]+Xa[r>>16&255]+Xa[r>>24&255]+"-"+Xa[e&255]+Xa[e>>8&255]+"-"+Xa[e>>16&15|64]+Xa[e>>24&255]+"-"+Xa[t&63|128]+Xa[t>>8&255]+"-"+Xa[t>>16&255]+Xa[t>>24&255]+Xa[n&255]+Xa[n>>8&255]+Xa[n>>16&255]+Xa[n>>24&255]).toLowerCase()}function Sr(r,e,t){return Math.max(e,Math.min(t,r))}function tp(r,e){return(r%e+e)%e}function rx(r,e,t,n,s){return n+(r-e)*(s-n)/(t-e)}function Bm(r,e,t){return r!==e?(t-r)/(e-r):0}function _r(r,e,t){return(1-t)*r+t*e}function js(r,e,t,n){return _r(r,e,1-Math.exp(-t*n))}function Fl(r,e=1){return e-Math.abs(tp(r,e*2)-e)}function S0(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function Bu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function _a(r,e){return r+Math.floor(Math.random()*(e-r+1))}function T0(r,e){return r+Math.random()*(e-r)}function ru(r){return r*(.5-Math.random())}function Uu(r){r!==void 0&&(Fu=r);let e=Fu+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Sl(r){return r*lc}function Fr(r){return r*Fa}function np(r){return(r&r-1)===0&&r!==0}function E0(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function A0(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function qh(r,e,t,n,s){const o=Math.cos,a=Math.sin,c=o(t/2),u=a(t/2),d=o((e+n)/2),p=a((e+n)/2),m=o((e-n)/2),y=a((e-n)/2),M=o((n-e)/2),T=a((n-e)/2);switch(s){case"XYX":r.set(c*p,u*m,u*y,c*d);break;case"YZY":r.set(u*y,c*p,u*m,c*d);break;case"ZXZ":r.set(u*m,u*y,c*p,c*d);break;case"XZX":r.set(c*p,u*T,u*M,c*d);break;case"YXY":r.set(u*M,c*p,u*T,c*d);break;case"ZYZ":r.set(u*T,u*M,c*p,c*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function qa(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ls(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Yh={DEG2RAD:lc,RAD2DEG:Fa,generateUUID:yl,clamp:Sr,euclideanModulo:tp,mapLinear:rx,inverseLerp:Bm,lerp:_r,damp:js,pingpong:Fl,smoothstep:S0,smootherstep:Bu,randInt:_a,randFloat:T0,randFloatSpread:ru,seededRandom:Uu,degToRad:Sl,radToDeg:Fr,isPowerOfTwo:np,ceilPowerOfTwo:E0,floorPowerOfTwo:A0,setQuaternionFromProperEuler:qh,normalize:ls,denormalize:qa};class yn{constructor(e=0,t=0){yn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Sr(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*s+e.x,this.y=o*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ea{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,o,a,c){let u=n[s+0],d=n[s+1],p=n[s+2],m=n[s+3];const y=o[a+0],M=o[a+1],T=o[a+2],G=o[a+3];if(c===0){e[t+0]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m;return}if(c===1){e[t+0]=y,e[t+1]=M,e[t+2]=T,e[t+3]=G;return}if(m!==G||u!==y||d!==M||p!==T){let z=1-c;const I=u*y+d*M+p*T+m*G,ee=I>=0?1:-1,Q=1-I*I;if(Q>Number.EPSILON){const _e=Math.sqrt(Q),ve=Math.atan2(_e,I*ee);z=Math.sin(z*ve)/_e,c=Math.sin(c*ve)/_e}const oe=c*ee;if(u=u*z+y*oe,d=d*z+M*oe,p=p*z+T*oe,m=m*z+G*oe,z===1-c){const _e=1/Math.sqrt(u*u+d*d+p*p+m*m);u*=_e,d*=_e,p*=_e,m*=_e}}e[t]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,o,a){const c=n[s],u=n[s+1],d=n[s+2],p=n[s+3],m=o[a],y=o[a+1],M=o[a+2],T=o[a+3];return e[t]=c*T+p*m+u*M-d*y,e[t+1]=u*T+p*y+d*m-c*M,e[t+2]=d*T+p*M+c*y-u*m,e[t+3]=p*T-c*m-u*y-d*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,o=e._z,a=e._order,c=Math.cos,u=Math.sin,d=c(n/2),p=c(s/2),m=c(o/2),y=u(n/2),M=u(s/2),T=u(o/2);switch(a){case"XYZ":this._x=y*p*m+d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m-y*M*T;break;case"YXZ":this._x=y*p*m+d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m+y*M*T;break;case"ZXY":this._x=y*p*m-d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m-y*M*T;break;case"ZYX":this._x=y*p*m-d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m+y*M*T;break;case"YZX":this._x=y*p*m+d*M*T,this._y=d*M*m+y*p*T,this._z=d*p*T-y*M*m,this._w=d*p*m-y*M*T;break;case"XZY":this._x=y*p*m-d*M*T,this._y=d*M*m-y*p*T,this._z=d*p*T+y*M*m,this._w=d*p*m+y*M*T;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],o=t[8],a=t[1],c=t[5],u=t[9],d=t[2],p=t[6],m=t[10],y=n+c+m;if(y>0){const M=.5/Math.sqrt(y+1);this._w=.25/M,this._x=(p-u)*M,this._y=(o-d)*M,this._z=(a-s)*M}else if(n>c&&n>m){const M=2*Math.sqrt(1+n-c-m);this._w=(p-u)/M,this._x=.25*M,this._y=(s+a)/M,this._z=(o+d)/M}else if(c>m){const M=2*Math.sqrt(1+c-n-m);this._w=(o-d)/M,this._x=(s+a)/M,this._y=.25*M,this._z=(u+p)/M}else{const M=2*Math.sqrt(1+m-n-c);this._w=(a-s)/M,this._x=(o+d)/M,this._y=(u+p)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Sr(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,o=e._z,a=e._w,c=t._x,u=t._y,d=t._z,p=t._w;return this._x=n*p+a*c+s*d-o*u,this._y=s*p+a*u+o*c-n*d,this._z=o*p+a*d+n*u-s*c,this._w=a*p-n*c-s*u-o*d,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,s=this._y,o=this._z,a=this._w;let c=a*e._w+n*e._x+s*e._y+o*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=a,this._x=n,this._y=s,this._z=o,this;const u=1-c*c;if(u<=Number.EPSILON){const M=1-t;return this._w=M*a+t*this._w,this._x=M*n+t*this._x,this._y=M*s+t*this._y,this._z=M*o+t*this._z,this.normalize(),this}const d=Math.sqrt(u),p=Math.atan2(d,c),m=Math.sin((1-t)*p)/d,y=Math.sin(t*p)/d;return this._w=a*m+this._w*y,this._x=n*m+this._x*y,this._y=s*m+this._y*y,this._z=o*m+this._z*y,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ot{constructor(e=0,t=0,n=0){ot.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Um.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Um.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*s,this.y=o[1]*t+o[4]*n+o[7]*s,this.z=o[2]*t+o[5]*n+o[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*s+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*s+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*s+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*s+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,o=e.x,a=e.y,c=e.z,u=e.w,d=2*(a*s-c*n),p=2*(c*t-o*s),m=2*(o*n-a*t);return this.x=t+u*d+a*m-c*p,this.y=n+u*p+c*d-o*m,this.z=s+u*m+o*p-a*d,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s,this.y=o[1]*t+o[5]*n+o[9]*s,this.z=o[2]*t+o[6]*n+o[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this.z=Sr(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this.z=Sr(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,o=e.z,a=t.x,c=t.y,u=t.z;return this.x=s*u-o*c,this.y=o*a-n*u,this.z=n*c-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ip.copy(this).projectOnVector(e),this.sub(ip)}reflect(e){return this.sub(ip.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Sr(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ip=new ot,Um=new ea;class $r{constructor(e,t,n,s,o,a,c,u,d){$r.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,o,a,c,u,d)}set(e,t,n,s,o,a,c,u,d){const p=this.elements;return p[0]=e,p[1]=s,p[2]=c,p[3]=t,p[4]=o,p[5]=u,p[6]=n,p[7]=a,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,a=n[0],c=n[3],u=n[6],d=n[1],p=n[4],m=n[7],y=n[2],M=n[5],T=n[8],G=s[0],z=s[3],I=s[6],ee=s[1],Q=s[4],oe=s[7],_e=s[2],ve=s[5],Oe=s[8];return o[0]=a*G+c*ee+u*_e,o[3]=a*z+c*Q+u*ve,o[6]=a*I+c*oe+u*Oe,o[1]=d*G+p*ee+m*_e,o[4]=d*z+p*Q+m*ve,o[7]=d*I+p*oe+m*Oe,o[2]=y*G+M*ee+T*_e,o[5]=y*z+M*Q+T*ve,o[8]=y*I+M*oe+T*Oe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8];return t*a*p-t*c*d-n*o*p+n*c*u+s*o*d-s*a*u}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=p*a-c*d,y=c*u-p*o,M=d*o-a*u,T=t*m+n*y+s*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const G=1/T;return e[0]=m*G,e[1]=(s*d-p*n)*G,e[2]=(c*n-s*a)*G,e[3]=y*G,e[4]=(p*t-s*u)*G,e[5]=(s*o-c*t)*G,e[6]=M*G,e[7]=(n*u-d*t)*G,e[8]=(a*t-n*o)*G,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,o,a,c){const u=Math.cos(o),d=Math.sin(o);return this.set(n*u,n*d,-n*(u*a+d*c)+a+e,-s*d,s*u,-s*(-d*a+u*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(rp.makeScale(e,t)),this}rotate(e){return this.premultiply(rp.makeRotation(-e)),this}translate(e,t){return this.premultiply(rp.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const rp=new $r;function sp(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const C0={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ch(r,e){return new C0[r](e)}function uh(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Ya(){const r=uh("canvas");return r.style.display="block",r}const ns={};function ol(r){r in ns||(ns[r]=!0,console.warn(r))}function oi(r,e,t){return new Promise(function(n,s){function o(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:s();break;case r.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}const vl=new $r().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rt=new $r().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Kd(){const r={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(s,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===Fi&&(s.r=ua(s.r),s.g=ua(s.g),s.b=ua(s.b)),this.spaces[o].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[o].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Fi&&(s.r=ku(s.r),s.g=ku(s.g),s.b=ku(s.b))),s},workingToColorSpace:function(s,o){return this.convert(s,this.workingColorSpace,o)},colorSpaceToWorking:function(s,o){return this.convert(s,o,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Qo?ah:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,o=this.workingColorSpace){return s.fromArray(this.spaces[o].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,o,a){return s.copy(this.spaces[o].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,o){return ol("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(s,o)},toWorkingColorSpace:function(s,o){return ol("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(s,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[iu]:{primaries:e,whitePoint:n,transfer:ah,toXYZ:vl,fromXYZ:Rt,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:vl,fromXYZ:Rt,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),r}const Ki=Kd();function ua(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ku(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let su;class km{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{su===void 0&&(su=uh("canvas")),su.width=e.width,su.height=e.height;const s=su.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=su}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=uh("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),o=s.data;for(let a=0;a1),this.pmremVersion=0}get width(){return this.source.getSize(ou).x}get height(){return this.source.getSize(ou).y}get depth(){return this.source.getSize(ou).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==te)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case lt:e.x=e.x-Math.floor(e.x);break;case qe:e.x=e.x<0?0:1;break;case pt:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case lt:e.y=e.y-Math.floor(e.y);break;case qe:e.y=e.y<0?0:1;break;case pt:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Wo.DEFAULT_IMAGE=null,Wo.DEFAULT_MAPPING=te,Wo.DEFAULT_ANISOTROPY=1;class mr{constructor(e=0,t=0,n=0,s=1){mr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,o;const u=e.elements,d=u[0],p=u[4],m=u[8],y=u[1],M=u[5],T=u[9],G=u[2],z=u[6],I=u[10];if(Math.abs(p-y)<.01&&Math.abs(m-G)<.01&&Math.abs(T-z)<.01){if(Math.abs(p+y)<.1&&Math.abs(m+G)<.1&&Math.abs(T+z)<.1&&Math.abs(d+M+I-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const Q=(d+1)/2,oe=(M+1)/2,_e=(I+1)/2,ve=(p+y)/4,Oe=(m+G)/4,He=(T+z)/4;return Q>oe&&Q>_e?Q<.01?(n=0,s=.707106781,o=.707106781):(n=Math.sqrt(Q),s=ve/n,o=Oe/n):oe>_e?oe<.01?(n=.707106781,s=0,o=.707106781):(s=Math.sqrt(oe),n=ve/s,o=He/s):_e<.01?(n=.707106781,s=.707106781,o=0):(o=Math.sqrt(_e),n=Oe/o,s=He/o),this.set(n,s,o,t),this}let ee=Math.sqrt((z-T)*(z-T)+(m-G)*(m-G)+(y-p)*(y-p));return Math.abs(ee)<.001&&(ee=1),this.x=(z-T)/ee,this.y=(m-G)/ee,this.z=(y-p)/ee,this.w=Math.acos((d+M+I-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Sr(this.x,e.x,t.x),this.y=Sr(this.y,e.y,t.y),this.z=Sr(this.z,e.z,t.z),this.w=Sr(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Sr(this.x,e,t),this.y=Sr(this.y,e,t),this.z=Sr(this.z,e,t),this.w=Sr(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Sr(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Za extends Ol{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new mr(0,0,e,t),this.scissorTest=!1,this.viewport=new mr(0,0,e,t);const s={width:e,height:t,depth:n.depth},o=new Wo(s);this.textures=[];const a=n.count;for(let c=0;c1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kl),Kl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(hc),Lc.subVectors(this.max,hc),au.subVectors(e.a,hc),hh.subVectors(e.b,hc),ta.subVectors(e.c,hc),Ua.subVectors(hh,au),ba.subVectors(ta,hh),uc.subVectors(au,ta);let t=[0,-Ua.z,Ua.y,0,-ba.z,ba.y,0,-uc.z,uc.y,Ua.z,0,-Ua.x,ba.z,0,-ba.x,uc.z,0,-uc.x,-Ua.y,Ua.x,0,-ba.y,ba.x,0,-uc.y,uc.x,0];return!se(t,au,hh,ta,Lc)||(t=[1,0,0,0,1,0,0,0,1],!se(t,au,hh,ta,Lc))?!1:(Dc.crossVectors(Ua,ba),t=[Dc.x,Dc.y,Dc.z],se(t,au,hh,ta,Lc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Zl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Zl=[new ot,new ot,new ot,new ot,new ot,new ot,new ot,new ot],Kl=new ot,Qd=new ha,au=new ot,hh=new ot,ta=new ot,Ua=new ot,ba=new ot,uc=new ot,hc=new ot,Lc=new ot,Dc=new ot,Tl=new ot;function se(r,e,t,n,s){for(let o=0,a=r.length-3;o<=a;o+=3){Tl.fromArray(r,o);const c=s.x*Math.abs(Tl.x)+s.y*Math.abs(Tl.y)+s.z*Math.abs(Tl.z),u=e.dot(Tl),d=t.dot(Tl),p=n.dot(Tl);if(Math.max(-Math.max(u,d,p),Math.min(u,d,p))>c)return!1}return!0}const $=new ha,Z=new ot,le=new ot;class we{constructor(e=new ot,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):$.setFromPoints(e).getCenter(n);let s=0;for(let o=0,a=e.length;othis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Z.subVectors(e,this.center);const t=Z.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Z,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(le.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Z.copy(e.center).add(le)),this.expandByPoint(Z.copy(e.center).sub(le))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Re=new ot,Ge=new ot,wt=new ot,Tt=new ot,Lt=new ot,Gt=new ot,$t=new ot;class hn{constructor(e=new ot,t=new ot(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Re)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Re.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Re.copy(this.origin).addScaledVector(this.direction,t),Re.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Ge.copy(e).add(t).multiplyScalar(.5),wt.copy(t).sub(e).normalize(),Tt.copy(this.origin).sub(Ge);const o=e.distanceTo(t)*.5,a=-this.direction.dot(wt),c=Tt.dot(this.direction),u=-Tt.dot(wt),d=Tt.lengthSq(),p=Math.abs(1-a*a);let m,y,M,T;if(p>0)if(m=a*u-c,y=a*c-u,T=o*p,m>=0)if(y>=-T)if(y<=T){const G=1/p;m*=G,y*=G,M=m*(m+a*y+2*c)+y*(a*m+y+2*u)+d}else y=o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;else y=-o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;else y<=-T?(m=Math.max(0,-(-a*o+c)),y=m>0?-o:Math.min(Math.max(-o,-u),o),M=-m*m+y*(y+2*u)+d):y<=T?(m=0,y=Math.min(Math.max(-o,-u),o),M=y*(y+2*u)+d):(m=Math.max(0,-(a*o+c)),y=m>0?o:Math.min(Math.max(-o,-u),o),M=-m*m+y*(y+2*u)+d);else y=a>0?-o:o,m=Math.max(0,-(a*y+c)),M=-m*m+y*(y+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(Ge).addScaledVector(wt,y),M}intersectSphere(e,t){Re.subVectors(e.center,this.origin);const n=Re.dot(this.direction),s=Re.dot(Re)-n*n,o=e.radius*e.radius;if(s>o)return null;const a=Math.sqrt(o-s),c=n-a,u=n+a;return u<0?null:c<0?this.at(u,t):this.at(c,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,o,a,c,u;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,y=this.origin;return d>=0?(n=(e.min.x-y.x)*d,s=(e.max.x-y.x)*d):(n=(e.max.x-y.x)*d,s=(e.min.x-y.x)*d),p>=0?(o=(e.min.y-y.y)*p,a=(e.max.y-y.y)*p):(o=(e.max.y-y.y)*p,a=(e.min.y-y.y)*p),n>a||o>s||((o>n||isNaN(n))&&(n=o),(a=0?(c=(e.min.z-y.z)*m,u=(e.max.z-y.z)*m):(c=(e.max.z-y.z)*m,u=(e.min.z-y.z)*m),n>u||c>s)||((c>n||n!==n)&&(n=c),(u=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Re)!==null}intersectTriangle(e,t,n,s,o){Lt.subVectors(t,e),Gt.subVectors(n,e),$t.crossVectors(Lt,Gt);let a=this.direction.dot($t),c;if(a>0){if(s)return null;c=1}else if(a<0)c=-1,a=-a;else return null;Tt.subVectors(this.origin,e);const u=c*this.direction.dot(Gt.crossVectors(Tt,Gt));if(u<0)return null;const d=c*this.direction.dot(Lt.cross(Tt));if(d<0||u+d>a)return null;const p=-c*Tt.dot($t);return p<0?null:this.at(p/a,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ft{constructor(e,t,n,s,o,a,c,u,d,p,m,y,M,T,G,z){Ft.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,o,a,c,u,d,p,m,y,M,T,G,z)}set(e,t,n,s,o,a,c,u,d,p,m,y,M,T,G,z){const I=this.elements;return I[0]=e,I[4]=t,I[8]=n,I[12]=s,I[1]=o,I[5]=a,I[9]=c,I[13]=u,I[2]=d,I[6]=p,I[10]=m,I[14]=y,I[3]=M,I[7]=T,I[11]=G,I[15]=z,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ft().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,s=1/_n.setFromMatrixColumn(e,0).length(),o=1/_n.setFromMatrixColumn(e,1).length(),a=1/_n.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,o=e.z,a=Math.cos(n),c=Math.sin(n),u=Math.cos(s),d=Math.sin(s),p=Math.cos(o),m=Math.sin(o);if(e.order==="XYZ"){const y=a*p,M=a*m,T=c*p,G=c*m;t[0]=u*p,t[4]=-u*m,t[8]=d,t[1]=M+T*d,t[5]=y-G*d,t[9]=-c*u,t[2]=G-y*d,t[6]=T+M*d,t[10]=a*u}else if(e.order==="YXZ"){const y=u*p,M=u*m,T=d*p,G=d*m;t[0]=y+G*c,t[4]=T*c-M,t[8]=a*d,t[1]=a*m,t[5]=a*p,t[9]=-c,t[2]=M*c-T,t[6]=G+y*c,t[10]=a*u}else if(e.order==="ZXY"){const y=u*p,M=u*m,T=d*p,G=d*m;t[0]=y-G*c,t[4]=-a*m,t[8]=T+M*c,t[1]=M+T*c,t[5]=a*p,t[9]=G-y*c,t[2]=-a*d,t[6]=c,t[10]=a*u}else if(e.order==="ZYX"){const y=a*p,M=a*m,T=c*p,G=c*m;t[0]=u*p,t[4]=T*d-M,t[8]=y*d+G,t[1]=u*m,t[5]=G*d+y,t[9]=M*d-T,t[2]=-d,t[6]=c*u,t[10]=a*u}else if(e.order==="YZX"){const y=a*u,M=a*d,T=c*u,G=c*d;t[0]=u*p,t[4]=G-y*m,t[8]=T*m+M,t[1]=m,t[5]=a*p,t[9]=-c*p,t[2]=-d*p,t[6]=M*m+T,t[10]=y-G*m}else if(e.order==="XZY"){const y=a*u,M=a*d,T=c*u,G=c*d;t[0]=u*p,t[4]=-m,t[8]=d*p,t[1]=y*m+G,t[5]=a*p,t[9]=M*m-T,t[2]=T*m-M,t[6]=c*p,t[10]=G*m+y}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Pn,e,ei)}lookAt(e,t,n){const s=this.elements;return di.subVectors(e,t),di.lengthSq()===0&&(di.z=1),di.normalize(),ai.crossVectors(n,di),ai.lengthSq()===0&&(Math.abs(n.z)===1?di.x+=1e-4:di.z+=1e-4,di.normalize(),ai.crossVectors(n,di)),ai.normalize(),On.crossVectors(di,ai),s[0]=ai.x,s[4]=On.x,s[8]=di.x,s[1]=ai.y,s[5]=On.y,s[9]=di.y,s[2]=ai.z,s[6]=On.z,s[10]=di.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,a=n[0],c=n[4],u=n[8],d=n[12],p=n[1],m=n[5],y=n[9],M=n[13],T=n[2],G=n[6],z=n[10],I=n[14],ee=n[3],Q=n[7],oe=n[11],_e=n[15],ve=s[0],Oe=s[4],He=s[8],Ce=s[12],Be=s[1],ft=s[5],zt=s[9],tn=s[13],cn=s[2],vn=s[6],mn=s[10],Yn=s[14],xn=s[3],si=s[7],wn=s[11],Gn=s[15];return o[0]=a*ve+c*Be+u*cn+d*xn,o[4]=a*Oe+c*ft+u*vn+d*si,o[8]=a*He+c*zt+u*mn+d*wn,o[12]=a*Ce+c*tn+u*Yn+d*Gn,o[1]=p*ve+m*Be+y*cn+M*xn,o[5]=p*Oe+m*ft+y*vn+M*si,o[9]=p*He+m*zt+y*mn+M*wn,o[13]=p*Ce+m*tn+y*Yn+M*Gn,o[2]=T*ve+G*Be+z*cn+I*xn,o[6]=T*Oe+G*ft+z*vn+I*si,o[10]=T*He+G*zt+z*mn+I*wn,o[14]=T*Ce+G*tn+z*Yn+I*Gn,o[3]=ee*ve+Q*Be+oe*cn+_e*xn,o[7]=ee*Oe+Q*ft+oe*vn+_e*si,o[11]=ee*He+Q*zt+oe*mn+_e*wn,o[15]=ee*Ce+Q*tn+oe*Yn+_e*Gn,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],s=e[8],o=e[12],a=e[1],c=e[5],u=e[9],d=e[13],p=e[2],m=e[6],y=e[10],M=e[14],T=e[3],G=e[7],z=e[11],I=e[15];return T*(+o*u*m-s*d*m-o*c*y+n*d*y+s*c*M-n*u*M)+G*(+t*u*M-t*d*y+o*a*y-s*a*M+s*d*p-o*u*p)+z*(+t*d*m-t*c*M-o*a*m+n*a*M+o*c*p-n*d*p)+I*(-s*c*p-t*u*m+t*c*y+s*a*m-n*a*y+n*u*p)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=e[9],y=e[10],M=e[11],T=e[12],G=e[13],z=e[14],I=e[15],ee=m*z*d-G*y*d+G*u*M-c*z*M-m*u*I+c*y*I,Q=T*y*d-p*z*d-T*u*M+a*z*M+p*u*I-a*y*I,oe=p*G*d-T*m*d+T*c*M-a*G*M-p*c*I+a*m*I,_e=T*m*u-p*G*u-T*c*y+a*G*y+p*c*z-a*m*z,ve=t*ee+n*Q+s*oe+o*_e;if(ve===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Oe=1/ve;return e[0]=ee*Oe,e[1]=(G*y*o-m*z*o-G*s*M+n*z*M+m*s*I-n*y*I)*Oe,e[2]=(c*z*o-G*u*o+G*s*d-n*z*d-c*s*I+n*u*I)*Oe,e[3]=(m*u*o-c*y*o-m*s*d+n*y*d+c*s*M-n*u*M)*Oe,e[4]=Q*Oe,e[5]=(p*z*o-T*y*o+T*s*M-t*z*M-p*s*I+t*y*I)*Oe,e[6]=(T*u*o-a*z*o-T*s*d+t*z*d+a*s*I-t*u*I)*Oe,e[7]=(a*y*o-p*u*o+p*s*d-t*y*d-a*s*M+t*u*M)*Oe,e[8]=oe*Oe,e[9]=(T*m*o-p*G*o-T*n*M+t*G*M+p*n*I-t*m*I)*Oe,e[10]=(a*G*o-T*c*o+T*n*d-t*G*d-a*n*I+t*c*I)*Oe,e[11]=(p*c*o-a*m*o-p*n*d+t*m*d+a*n*M-t*c*M)*Oe,e[12]=_e*Oe,e[13]=(p*G*s-T*m*s+T*n*y-t*G*y-p*n*z+t*m*z)*Oe,e[14]=(T*c*s-a*G*s-T*n*u+t*G*u+a*n*z-t*c*z)*Oe,e[15]=(a*m*s-p*c*s+p*n*u-t*m*u-a*n*y+t*c*y)*Oe,this}scale(e){const t=this.elements,n=e.x,s=e.y,o=e.z;return t[0]*=n,t[4]*=s,t[8]*=o,t[1]*=n,t[5]*=s,t[9]*=o,t[2]*=n,t[6]*=s,t[10]*=o,t[3]*=n,t[7]*=s,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),o=1-n,a=e.x,c=e.y,u=e.z,d=o*a,p=o*c;return this.set(d*a+n,d*c-s*u,d*u+s*c,0,d*c+s*u,p*c+n,p*u-s*a,0,d*u-s*c,p*u+s*a,o*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,o,a){return this.set(1,n,o,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,o=t._x,a=t._y,c=t._z,u=t._w,d=o+o,p=a+a,m=c+c,y=o*d,M=o*p,T=o*m,G=a*p,z=a*m,I=c*m,ee=u*d,Q=u*p,oe=u*m,_e=n.x,ve=n.y,Oe=n.z;return s[0]=(1-(G+I))*_e,s[1]=(M+oe)*_e,s[2]=(T-Q)*_e,s[3]=0,s[4]=(M-oe)*ve,s[5]=(1-(y+I))*ve,s[6]=(z+ee)*ve,s[7]=0,s[8]=(T+Q)*Oe,s[9]=(z-ee)*Oe,s[10]=(1-(y+G))*Oe,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;let o=_n.set(s[0],s[1],s[2]).length();const a=_n.set(s[4],s[5],s[6]).length(),c=_n.set(s[8],s[9],s[10]).length();this.determinant()<0&&(o=-o),e.x=s[12],e.y=s[13],e.z=s[14],Nn.copy(this);const d=1/o,p=1/a,m=1/c;return Nn.elements[0]*=d,Nn.elements[1]*=d,Nn.elements[2]*=d,Nn.elements[4]*=p,Nn.elements[5]*=p,Nn.elements[6]*=p,Nn.elements[8]*=m,Nn.elements[9]*=m,Nn.elements[10]*=m,t.setFromRotationMatrix(Nn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,o,a,c=so,u=!1){const d=this.elements,p=2*o/(t-e),m=2*o/(n-s),y=(t+e)/(t-e),M=(n+s)/(n-s);let T,G;if(u)T=o/(a-o),G=a*o/(a-o);else if(c===so)T=-(a+o)/(a-o),G=-2*a*o/(a-o);else if(c===ja)T=-a/(a-o),G=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=y,d[12]=0,d[1]=0,d[5]=m,d[9]=M,d[13]=0,d[2]=0,d[6]=0,d[10]=T,d[14]=G,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,t,n,s,o,a,c=so,u=!1){const d=this.elements,p=2/(t-e),m=2/(n-s),y=-(t+e)/(t-e),M=-(n+s)/(n-s);let T,G;if(u)T=1/(a-o),G=a/(a-o);else if(c===so)T=-2/(a-o),G=-(a+o)/(a-o);else if(c===ja)T=-1/(a-o),G=-o/(a-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=0,d[12]=y,d[1]=0,d[5]=m,d[9]=0,d[13]=M,d[2]=0,d[6]=0,d[10]=T,d[14]=G,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const _n=new ot,Nn=new Ft,Pn=new ot(0,0,0),ei=new ot(1,1,1),ai=new ot,On=new ot,di=new ot,Ri=new Ft,ji=new ea;class Qi{constructor(e=0,t=0,n=0,s=Qi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,o=s[0],a=s[4],c=s[8],u=s[1],d=s[5],p=s[9],m=s[2],y=s[6],M=s[10];switch(t){case"XYZ":this._y=Math.asin(Sr(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-p,M),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(y,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Sr(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(c,M),this._z=Math.atan2(u,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(Sr(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(-m,M),this._z=Math.atan2(-a,d)):(this._y=0,this._z=Math.atan2(u,o));break;case"ZYX":this._y=Math.asin(-Sr(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(y,M),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,d));break;case"YZX":this._z=Math.asin(Sr(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(c,M));break;case"XZY":this._z=Math.asin(-Sr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(y,d),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-p,M),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ri.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ri,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ji.setFromEuler(this),this.setFromQuaternion(ji,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Qi.DEFAULT_ORDER="XYZ";class er{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(c=>ac(qs({},c),{boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(c=>qs({},c)),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function o(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=o(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let d=0,p=u.length;d0){s.children=[];for(let c=0;c0){s.animations=[];for(let c=0;c0&&(n.geometries=c),u.length>0&&(n.materials=u),d.length>0&&(n.textures=d),p.length>0&&(n.images=p),m.length>0&&(n.shapes=m),y.length>0&&(n.skeletons=y),M.length>0&&(n.animations=M),T.length>0&&(n.nodes=T)}return n.object=s,n;function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?s.multiplyScalar(1/Math.sqrt(o)):s.set(0,0,0)}static getBarycoord(e,t,n,s,o){Ls.subVectors(s,t),Lo.subVectors(n,t),Ka.subVectors(e,t);const a=Ls.dot(Ls),c=Ls.dot(Lo),u=Ls.dot(Ka),d=Lo.dot(Lo),p=Lo.dot(Ka),m=a*d-c*c;if(m===0)return o.set(0,0,0),null;const y=1/m,M=(d*u-c*p)*y,T=(a*p-c*u)*y;return o.set(1-M-T,T,M)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,oo)===null?!1:oo.x>=0&&oo.y>=0&&oo.x+oo.y<=1}static getInterpolation(e,t,n,s,o,a,c,u){return this.getBarycoord(e,t,n,s,oo)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(o,oo.x),u.addScaledVector(a,oo.y),u.addScaledVector(c,oo.z),u)}static getInterpolatedAttribute(e,t,n,s,o,a){return Ul.setScalar(0),Ho.setScalar(0),wa.setScalar(0),Ul.fromBufferAttribute(e,t),Ho.fromBufferAttribute(e,n),wa.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Ul,o.x),a.addScaledVector(Ho,o.y),a.addScaledVector(wa,o.z),a}static isFrontFacing(e,t,n,s){return Ls.subVectors(n,t),Lo.subVectors(e,t),Ls.cross(Lo).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ls.subVectors(this.c,this.b),Lo.subVectors(this.a,this.b),Ls.cross(Lo).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return na.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return na.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,o){return na.getInterpolation(e,this.a,this.b,this.c,t,n,s,o)}containsPoint(e){return na.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return na.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,o=this.c;let a,c;al.subVectors(s,n),xs.subVectors(o,n),Ys.subVectors(e,n);const u=al.dot(Ys),d=xs.dot(Ys);if(u<=0&&d<=0)return t.copy(n);Oc.subVectors(e,s);const p=al.dot(Oc),m=xs.dot(Oc);if(p>=0&&m<=p)return t.copy(s);const y=u*m-p*d;if(y<=0&&u>=0&&p<=0)return a=u/(u-p),t.copy(n).addScaledVector(al,a);Co.subVectors(e,o);const M=al.dot(Co),T=xs.dot(Co);if(T>=0&&M<=T)return t.copy(o);const G=M*d-u*T;if(G<=0&&d>=0&&T<=0)return c=d/(d-T),t.copy(n).addScaledVector(xs,c);const z=p*T-M*m;if(z<=0&&m-p>=0&&M-T>=0)return da.subVectors(o,s),c=(m-p)/(m-p+(M-T)),t.copy(s).addScaledVector(da,c);const I=1/(z+G+y);return a=G*I,c=y*I,t.copy(n).addScaledVector(al,a).addScaledVector(xs,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ll={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ia={h:0,s:0,l:0},is={h:0,s:0,l:0};function Bs(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class jn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=co){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ki.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ki.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ki.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ki.workingColorSpace){if(e=tp(e,1),t=Sr(t,0,1),n=Sr(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Bs(a,o,e+1/3),this.g=Bs(a,o,e),this.b=Bs(a,o,e-1/3)}return Ki.colorSpaceToWorking(this,s),this}setStyle(e,t=co){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=s[1],c=s[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=s[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=co){const n=ll[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ua(e.r),this.g=ua(e.g),this.b=ua(e.b),this}copyLinearToSRGB(e){return this.r=ku(e.r),this.g=ku(e.g),this.b=ku(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=co){return Ki.workingToColorSpace(br.copy(this),e),Math.round(Sr(br.r*255,0,255))*65536+Math.round(Sr(br.g*255,0,255))*256+Math.round(Sr(br.b*255,0,255))}getHexString(e=co){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ki.workingColorSpace){Ki.workingToColorSpace(br.copy(this),t);const n=br.r,s=br.g,o=br.b,a=Math.max(n,s,o),c=Math.min(n,s,o);let u,d;const p=(c+a)/2;if(c===a)u=0,d=0;else{const m=a-c;switch(d=p<=.5?m/(a+c):m/(2-a-c),a){case n:u=(s-o)/m+(s0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ge&&(n.blending=this.blending),this.side!==W&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ut&&(n.blendSrc=this.blendSrc),this.blendDst!==At&&(n.blendDst=this.blendDst),this.blendEquation!==Ae&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Y&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Xh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yl&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Yl&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Yl&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(o){const a=[];for(const c in o){const u=o[c];delete u.metadata,a.push(u)}return a}if(t){const o=s(e.textures),a=s(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let o=0;o!==s;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Wr extends Ei{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new jn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const vs=ar();function ar(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),s=new Uint32Array(512);for(let u=0;u<256;++u){const d=u-127;d<-27?(n[u]=0,n[u|256]=32768,s[u]=24,s[u|256]=24):d<-14?(n[u]=1024>>-d-14,n[u|256]=1024>>-d-14|32768,s[u]=-d-1,s[u|256]=-d-1):d<=15?(n[u]=d+15<<10,n[u|256]=d+15<<10|32768,s[u]=13,s[u|256]=13):d<128?(n[u]=31744,n[u|256]=64512,s[u]=24,s[u|256]=24):(n[u]=31744,n[u|256]=64512,s[u]=13,s[u|256]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),c=new Uint32Array(64);for(let u=1;u<1024;++u){let d=u<<13,p=0;for(;!(d&8388608);)d<<=1,p-=8388608;d&=-8388609,p+=947912704,o[u]=d|p}for(let u=1024;u<2048;++u)o[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(c[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:o,exponentTable:a,offsetTable:c}}function vr(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=Sr(r,-65504,65504),vs.floatView[0]=r;const e=vs.uint32View[0],t=e>>23&511;return vs.baseTable[t]+((e&8388607)>>vs.shiftTable[t])}function Cs(r){const e=r>>10;return vs.uint32View[0]=vs.mantissaTable[vs.offsetTable[e]+(r&1023)]+vs.exponentTable[e],vs.floatView[0]}class Ro{static toHalfFloat(e){return vr(e)}static fromHalfFloat(e){return Cs(e)}}const Ms=new ot,Ws=new yn;let dh=0;class Qr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:dh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ou,this.updateRanges=[],this.gpuType=gs,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,o=this.itemSize;st.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ha);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ot(-1/0,-1/0,-1/0),new ot(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const d in u)u[d]!==void 0&&(e[d]=u[d]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const d=n[u];e.data.attributes[u]=d.toJSON(e.data)}const s={};let o=!1;for(const u in this.morphAttributes){const d=this.morphAttributes[u],p=[];for(let m=0,y=d.length;m0&&(s[u]=p,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const d in s){const p=s[d];this.setAttribute(d,p.clone(t))}const o=e.morphAttributes;for(const d in o){const p=[],m=o[d];for(let y=0,M=m.length;y0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;oKf(e.far-e.near,2)))&&(Vl.copy(o).invert(),cl.copy(e.ray).applyMatrix4(Vl),!(n.boundingBox!==null&&cl.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,cl)))}_computeIntersections(e,t,n){let s;const o=this.geometry,a=this.material,c=o.index,u=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,y=o.groups,M=o.drawRange;if(c!==null)if(Array.isArray(a))for(let T=0,G=y.length;Tt.far?null:{distance:d,point:cu.clone(),object:r}}function tf(r,e,t,n,s,o,a,c,u,d){r.getVertexPosition(c,_s),r.getVertexPosition(u,Or),r.getVertexPosition(d,Jl);const p=Kh(r,e,t,n,_s,Or,Jl,Zh);if(p){const m=new ot;na.getBarycoord(Zh,_s,Or,Jl,m),s&&(p.uv=na.getInterpolatedAttribute(s,c,u,d,m,new yn)),o&&(p.uv1=na.getInterpolatedAttribute(o,c,u,d,m,new yn)),a&&(p.normal=na.getInterpolatedAttribute(a,c,u,d,m,new ot),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const y={a:c,b:u,c:d,normal:new ot,materialIndex:0};na.getNormal(_s,Or,Jl,y.normal),p.face=y,p.barycoord=m}return p}class Fc extends xr{constructor(e=1,t=1,n=1,s=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:o,depthSegments:a};const c=this;s=Math.floor(s),o=Math.floor(o),a=Math.floor(a);const u=[],d=[],p=[],m=[];let y=0,M=0;T("z","y","x",-1,-1,n,t,e,a,o,0),T("z","y","x",1,-1,n,t,-e,a,o,1),T("x","z","y",1,1,e,n,t,s,a,2),T("x","z","y",1,-1,e,n,-t,s,a,3),T("x","y","z",1,-1,e,t,n,s,o,4),T("x","y","z",-1,-1,e,t,-n,s,o,5),this.setIndex(u),this.setAttribute("position",new Zi(d,3)),this.setAttribute("normal",new Zi(p,3)),this.setAttribute("uv",new Zi(m,2));function T(G,z,I,ee,Q,oe,_e,ve,Oe,He,Ce){const Be=oe/Oe,ft=_e/He,zt=oe/2,tn=_e/2,cn=ve/2,vn=Oe+1,mn=He+1;let Yn=0,xn=0;const si=new ot;for(let wn=0;wn0?1:-1,p.push(si.x,si.y,si.z),m.push(Si/Oe),m.push(1-wn/He),Yn+=1}}for(let wn=0;wn0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Hm extends Jr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ft,this.projectionMatrix=new Ft,this.projectionMatrixInverse=new Ft,this.coordinateSystem=so,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Qh=new ot,l1=new yn,ax=new yn;class fa extends Hm{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Fa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(lc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Fa*2*Math.atan(Math.tan(lc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Qh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Qh.x,Qh.y).multiplyScalar(-e/Qh.z),Qh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Qh.x,Qh.y).multiplyScalar(-e/Qh.z)}getViewSize(e,t){return this.getViewBounds(e,l1,ax),t.subVectors(ax,l1)}setViewOffset(e,t,n,s,o,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(lc*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,o=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,d=a.fullHeight;o+=a.offsetX*s/u,t-=a.offsetY*n/d,s*=a.width/u,n*=a.height/d}const c=this.filmOffset;c!==0&&(o+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ed=-90,nf=1;class Vu extends Jr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new fa(ed,nf,e,t);s.layers=this.layers,this.add(s);const o=new fa(ed,nf,e,t);o.layers=this.layers,this.add(o);const a=new fa(ed,nf,e,t);a.layers=this.layers,this.add(a);const c=new fa(ed,nf,e,t);c.layers=this.layers,this.add(c);const u=new fa(ed,nf,e,t);u.layers=this.layers,this.add(u);const d=new fa(ed,nf,e,t);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,o,a,c,u]=t;for(const d of t)this.remove(d);if(e===so)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===ja)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const d of t)this.add(d),d.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,a,c,u,d,p]=this.children,m=e.getRenderTarget(),y=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const G=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,o),e.setRenderTarget(n,1,s),e.render(t,a),e.setRenderTarget(n,2,s),e.render(t,c),e.setRenderTarget(n,3,s),e.render(t,u),e.setRenderTarget(n,4,s),e.render(t,d),n.texture.generateMipmaps=G,e.setRenderTarget(n,5,s),e.render(t,p),e.setRenderTarget(m,y,M),e.xr.enabled=T,n.texture.needsPMREMUpdate=!0}}class ph extends Wo{constructor(e=[],t=Fe,n,s,o,a,c,u,d,p){super(e,t,n,s,o,a,c,u,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class R0 extends cc{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new ph(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},s=new Fc(5,5,5),o=new Bc({name:"CubemapFromEquirect",uniforms:Jh(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:K,blending:ye});o.uniforms.tEquirect.value=t;const a=new Zs(s,o),c=t.minFilter;return t.minFilter===Qn&&(t.minFilter=Rn),new Vu(1,10,this).update(e,a),t.minFilter=c,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(o)}}class ul extends Jr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const rf={type:"move"};class Gu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ul,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ul,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ot,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ot),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ul,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ot,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ot),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,o=null,a=null;const c=this._targetRay,u=this._grip,d=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(d&&e.hand){a=!0;for(const G of e.hand.values()){const z=t.getJointPose(G,n),I=this._getHandJoint(d,G);z!==null&&(I.matrix.fromArray(z.transform.matrix),I.matrix.decompose(I.position,I.rotation,I.scale),I.matrixWorldNeedsUpdate=!0,I.jointRadius=z.radius),I.visible=z!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],y=p.position.distanceTo(m.position),M=.02,T=.005;d.inputState.pinching&&y>M+T?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&y<=M-T&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(u.matrix.fromArray(o.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,o.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(o.linearVelocity)):u.hasLinearVelocity=!1,o.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(o.angularVelocity)):u.hasAngularVelocity=!1));c!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&o!==null&&(s=o),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(rf)))}return c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),d!==null&&(d.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ul;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class N0{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new jn(e),this.density=t}clone(){return new N0(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class lp{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new jn(e),this.near=t,this.far=n}clone(){return new lp(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $m extends Jr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Qi,this.environmentIntensity=1,this.environmentRotation=new Qi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Wu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ou,this.updateRanges=[],this.version=0,this.uuid=yl()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,o=this.stride;se.far||t.push({distance:u,point:up.clone(),uv:na.getInterpolation(up,gh,uu,Hu,rd,sd,P0,new yn),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function yh(r,e,t,n,s,o){Uc.subVectors(r,t).addScalar(.5).multiply(n),s!==void 0?(nd.x=o*Uc.x-s*Uc.y,nd.y=s*Uc.x+o*Uc.y):nd.copy(Uc),r.copy(e),r.x+=nd.x,r.y+=nd.y,r.applyMatrix4(id)}const od=new ot,I0=new ot;class L0 extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,s=t.length;n0){let n,s;for(n=1,s=t.length;n0){od.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(od);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){od.setFromMatrixPosition(e.matrixWorld),I0.setFromMatrixPosition(this.matrixWorld);const n=od.distanceTo(I0)/e.zoom;t[0].object.visible=!0;let s,o;for(s=1,o=t.length;s=a)t[s-1].object.visible=!1,t[s].object.visible=!0;else break}for(this._currentLevel=s-1;s1?null:t.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||u1.getNormalMatrix(e),s=this.coplanarPoint(of).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(o),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const zc=new we,h1=new yn(.5,.5),af=new ot;class lf{constructor(e=new Al,t=new Al,n=new Al,s=new Al,o=new Al,a=new Al){this.planes=[e,t,n,s,o,a]}set(e,t,n,s,o,a){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(s),c[4].copy(o),c[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=so,n=!1){const s=this.planes,o=e.elements,a=o[0],c=o[1],u=o[2],d=o[3],p=o[4],m=o[5],y=o[6],M=o[7],T=o[8],G=o[9],z=o[10],I=o[11],ee=o[12],Q=o[13],oe=o[14],_e=o[15];if(s[0].setComponents(d-a,M-p,I-T,_e-ee).normalize(),s[1].setComponents(d+a,M+p,I+T,_e+ee).normalize(),s[2].setComponents(d+c,M+m,I+G,_e+Q).normalize(),s[3].setComponents(d-c,M-m,I-G,_e-Q).normalize(),n)s[4].setComponents(u,y,z,oe).normalize(),s[5].setComponents(d-u,M-y,I-z,_e-oe).normalize();else if(s[4].setComponents(d-u,M-y,I-z,_e-oe).normalize(),t===so)s[5].setComponents(d+u,M+y,I+z,_e+oe).normalize();else if(t===ja)s[5].setComponents(u,y,z,oe).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),zc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),zc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zc)}intersectsSprite(e){zc.center.set(0,0,0);const t=h1.distanceTo(e.center);return zc.radius=.7071067811865476+t,zc.applyMatrix4(e.matrixWorld),this.intersectsSphere(zc)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)0?e.max.x:e.min.x,af.y=s.normal.y>0?e.max.y:e.min.y,af.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(af)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const fu=new Ft,Cl=new lf;class pu{constructor(){this.coordinateSystem=so}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const c=o[this.index];a.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=s}reset(){this.list.length=0,this.index=0}}const $o=new Ft,G0=new jn(1,1,1),Qm=new lf,d1=new pu,eg=new ha,ld=new we,Qa=new ot,dx=new ot,fx=new ot,W0=new mu,za=new Zs,gu=null;function pp(r,e,t=0){const n=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const s=r.count;for(let o=0;o65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Qr(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const s=e.getAttribute(n),o=t.getAttribute(n);if(s.itemSize!==o.itemSize||s.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ha);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,s=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(z0),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=n):(s=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;$o.identity().toArray(o.image.data,s*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(G0.toArray(a.image.data,s*4),a.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=n===-1?a.count:n),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let u;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(z0),u=this._availableGeometryIds.shift(),o[u]=s):(u=this._geometryCount,this._geometryCount++,o.push(s)),this.setGeometryAt(u,e),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,u}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,s=n.getIndex()!==null,o=n.getIndex(),a=t.getIndex(),c=this._geometryInfo[e];if(s&&a.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const u=c.vertexStart,d=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const m=t.getAttribute(p),y=n.getAttribute(p);pp(m,y,u);const M=m.itemSize;for(let T=m.count,G=d;T=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let s=0,o=n.length;sc).sort((a,c)=>n[a].vertexStart-n[c].vertexStart),o=this.geometry;for(let a=0,c=n.length;a=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingBox===null){const o=new ha,a=n.index,c=n.attributes.position;for(let u=s.start,d=s.start+s.count;u=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingSphere===null){const o=new we;this.getBoundingBoxAt(e,eg),eg.getCenter(o.center);const a=n.index,c=n.attributes.position;let u=0;for(let d=s.start,p=s.start+s.count;dc.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(u=>u.indexStart+u.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new xr,this._initializeGeometry(o));const a=this.geometry;o.index&&vh(o.index.array,a.index.array);for(const c in o.attributes)vh(o.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,s=this._geometryInfo,o=this.matrixWorld,a=this.geometry;za.material=this.material,za.geometry.index=a.index,za.geometry.attributes=a.attributes,za.geometry.boundingBox===null&&(za.geometry.boundingBox=new ha),za.geometry.boundingSphere===null&&(za.geometry.boundingSphere=new we);for(let c=0,u=n.length;cac(qs({},t),{boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>qs({},t)),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,s,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=s.getIndex(),c=a===null?1:a.array.BYTES_PER_ELEMENT,u=this._instanceInfo,d=this._multiDrawStarts,p=this._multiDrawCounts,m=this._geometryInfo,y=this.perObjectFrustumCulled,M=this._indirectTexture,T=M.image.data,G=n.isArrayCamera?d1:Qm;y&&!n.isArrayCamera&&($o.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Qm.setFromProjectionMatrix($o,n.coordinateSystem,n.reversedDepth));let z=0;if(this.sortObjects){$o.copy(this.matrixWorld).invert(),Qa.setFromMatrixPosition(n.matrixWorld).applyMatrix4($o),dx.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection($o);for(let Q=0,oe=u.length;Q0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;on)return;Rl.applyMatrix4(r.matrixWorld);const d=e.ray.origin.distanceTo(Rl);if(!(de.far))return{distance:d,point:mp.clone().applyMatrix4(r.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:r}}const cf=new ot,yp=new ot;class ng extends null{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,o=t.count;s0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=s.length;os.far)return;o.push({distance:d,distanceToRay:Math.sqrt(c),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class m1 extends null{constructor(e,t,n,s,o=Rn,a=Rn,c,u,d){super(e,t,n,s,o,a,c,u,d),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const p=this;function m(){p.needsUpdate=!0,p._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}}class gx extends null{constructor(e,t,n,s,o,a,c,u){super({},e,t,n,s,o,a,c,u),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class bp extends Wo{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class rg extends null{constructor(e,t,n,s,o,a,c,u,d,p,m,y){super(null,a,c,u,d,p,s,o,m,y),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class lE extends null{constructor(e,t,n,s,o,a){super(e,t,n,o,a),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=qe,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class g1 extends null{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Fe),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class g3 extends null{constructor(e,t,n,s,o,a,c,u,d){super(e,t,n,s,o,a,c,u,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class gc extends Wo{constructor(e,t,n=as,s,o,a,c=Ct,u=Ct,d,p=U,m=1){if(p!==U&&p!==_)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const y={width:e,height:t,depth:m};super(y,s,o,a,c,u,p,n,d),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class y1 extends Wo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class $0 extends xr{constructor(e=1,t=1,n=4,s=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:s,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),s=Math.max(3,Math.floor(s)),o=Math.max(1,Math.floor(o));const a=[],c=[],u=[],d=[],p=t/2,m=Math.PI/2*e,y=t,M=2*m+y,T=n*2+o,G=s+1,z=new ot,I=new ot;for(let ee=0;ee<=T;ee++){let Q=0,oe=0,_e=0,ve=0;if(ee<=n){const Ce=ee/n,Be=Ce*Math.PI/2;oe=-p-e*Math.cos(Be),_e=e*Math.sin(Be),ve=-e*Math.cos(Be),Q=Ce*m}else if(ee<=n+o){const Ce=(ee-n)/o;oe=-p+Ce*t,_e=e,ve=0,Q=m+Ce*y}else{const Ce=(ee-n-o)/n,Be=Ce*Math.PI/2;oe=p+e*Math.sin(Be),_e=e*Math.cos(Be),ve=e*Math.sin(Be),Q=m+y+Ce*m}const Oe=Math.max(0,Math.min(1,Q/M));let He=0;ee===0?He=.5/s:ee===T&&(He=-.5/s);for(let Ce=0;Ce<=s;Ce++){const Be=Ce/s,ft=Be*Math.PI*2,zt=Math.sin(ft),tn=Math.cos(ft);I.x=-_e*tn,I.y=oe,I.z=_e*zt,c.push(I.x,I.y,I.z),z.set(-_e*tn,ve,_e*zt),z.normalize(),u.push(z.x,z.y,z.z),d.push(Be+He,Oe)}if(ee>0){const Ce=(ee-1)*G;for(let Be=0;Be0&&Q(!0),t>0&&Q(!1)),this.setIndex(p),this.setAttribute("position",new Zi(m,3)),this.setAttribute("normal",new Zi(y,3)),this.setAttribute("uv",new Zi(M,2));function ee(){const oe=new ot,_e=new ot;let ve=0;const Oe=(t-e)/n;for(let He=0;He<=o;He++){const Ce=[],Be=He/o,ft=Be*(t-e)+e;for(let zt=0;zt<=s;zt++){const tn=zt/s,cn=tn*u+c,vn=Math.sin(cn),mn=Math.cos(cn);_e.x=ft*vn,_e.y=-Be*n+z,_e.z=ft*mn,m.push(_e.x,_e.y,_e.z),oe.set(vn,Oe,mn).normalize(),y.push(oe.x,oe.y,oe.z),M.push(tn,1-Be),Ce.push(T++)}G.push(Ce)}for(let He=0;He0||Ce!==0)&&(p.push(Be,ft,tn),ve+=3),(t>0||Ce!==o-1)&&(p.push(ft,zt,tn),ve+=3)}d.addGroup(I,ve,0),I+=ve}function Q(oe){const _e=T,ve=new yn,Oe=new ot;let He=0;const Ce=oe===!0?e:t,Be=oe===!0?1:-1;for(let zt=1;zt<=s;zt++)m.push(0,z*Be,0),y.push(0,Be,0),M.push(.5,.5),T++;const ft=T;for(let zt=0;zt<=s;zt++){const cn=zt/s*u+c,vn=Math.cos(cn),mn=Math.sin(cn);Oe.x=Ce*mn,Oe.y=z*Be,Oe.z=Ce*vn,m.push(Oe.x,Oe.y,Oe.z),y.push(0,Be,0),ve.x=vn*.5+.5,ve.y=mn*.5*Be+.5,M.push(ve.x,ve.y),T++}for(let zt=0;zt.9&&Oe<.1&&(Q<.2&&(a[ee+0]+=1),oe<.2&&(a[ee+2]+=1),_e<.2&&(a[ee+4]+=1))}}function y(ee){o.push(ee.x,ee.y,ee.z)}function M(ee,Q){const oe=ee*3;Q.x=e[oe+0],Q.y=e[oe+1],Q.z=e[oe+2]}function T(){const ee=new ot,Q=new ot,oe=new ot,_e=new ot,ve=new yn,Oe=new yn,He=new yn;for(let Ce=0,Be=0;Ce0)u=s-1;else{u=s;break}if(s=u,n[s]===a)return s/(o-1);const p=n[s],y=n[s+1]-p,M=(a-p)/y;return(s+M)/(o-1)}getTangent(e,t){let s=e-1e-4,o=e+1e-4;s<0&&(s=0),o>1&&(o=1);const a=this.getPoint(s),c=this.getPoint(o),u=t||(a.isVector2?new yn:new ot);return u.copy(c).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new ot,s=[],o=[],a=[],c=new ot,u=new Ft;for(let M=0;M<=e;M++){const T=M/e;s[M]=this.getTangentAt(T,new ot)}o[0]=new ot,a[0]=new ot;let d=Number.MAX_VALUE;const p=Math.abs(s[0].x),m=Math.abs(s[0].y),y=Math.abs(s[0].z);p<=d&&(d=p,n.set(1,0,0)),m<=d&&(d=m,n.set(0,1,0)),y<=d&&n.set(0,0,1),c.crossVectors(s[0],n).normalize(),o[0].crossVectors(s[0],c),a[0].crossVectors(s[0],o[0]);for(let M=1;M<=e;M++){if(o[M]=o[M-1].clone(),a[M]=a[M-1].clone(),c.crossVectors(s[M-1],s[M]),c.length()>Number.EPSILON){c.normalize();const T=Math.acos(Sr(s[M-1].dot(s[M]),-1,1));o[M].applyMatrix4(u.makeRotationAxis(c,T))}a[M].crossVectors(s[M],o[M])}if(t===!0){let M=Math.acos(Sr(o[0].dot(o[e]),-1,1));M/=e,s[0].dot(c.crossVectors(o[0],o[e]))>0&&(M=-M);for(let T=1;T<=e;T++)o[T].applyMatrix4(u.makeRotationAxis(s[T],M*T)),a[T].crossVectors(s[T],o[T])}return{tangents:s,normals:o,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class mf extends yc{constructor(e=0,t=0,n=1,s=1,o=0,a=Math.PI*2,c=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=c,this.aRotation=u}getPoint(e,t=new yn){const n=t,s=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const a=Math.abs(o)s;)o-=s;o0?0:(Math.floor(Math.abs(c)/o)+1)*o:u===0&&c===o-1&&(c=o-2,u=1);let d,p;this.closed||c>0?d=s[(c-1)%o]:(dd.subVectors(s[0],s[1]).add(s[0]),d=dd);const m=s[c%o],y=s[(c+1)%o];if(this.closed||c+2s.length-2?s.length-1:a+1],m=s[a>s.length-3?s.length-1:a+2];return n.set(og(c,u.x,d.x,p.x,m.x),og(c,u.y,d.y,p.y,m.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=s[o]-n,c=this.curves[o],u=c.getLength(),d=u===0?0:1-a/u;return c.getPointAt(d,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,s=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const m=d.getPoint(0);m.equals(this.currentPoint)||this.lineTo(m.x,m.y)}this.curves.push(d);const p=d.getPoint(1);return this.currentPoint.copy(p),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class md extends Z0{constructor(e){super(e),this.uuid=yl(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,s=this.holes.length;n80*t){c=1/0,u=1/0;let p=-1/0,m=-1/0;for(let y=t;yp&&(p=M),T>m&&(m=T)}d=Math.max(p-c,m-u),d=d!==0?32767/d:0}return Ap(o,a,t,c,u,d,0),a}function K0(r,e,t,n,s){let o;if(s===Ip(r,e,t,n)>0)for(let a=e;a=e;a-=n)o=Pp(a/n|0,r[a],r[a+1],o);return o&&_h(o,o.next)&&(wh(o),o=o.next),o}function yu(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(_h(t,t.next)||jo(t.prev,t,t.next)===0)){if(wh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ap(r,e,t,n,s,o,a){if(!r)return;!a&&o&&A1(r,n,s,o);let c=r;for(;r.prev!==r.next;){const u=r.prev,d=r.next;if(o?yf(r,n,s,o):J0(r)){e.push(u.i,r.i,d.i),wh(r),r=d.next,c=d.next;continue}if(r=d,r===c){a?a===1?(r=M1(yu(r),e),Ap(r,e,t,n,s,o,2)):a===2&&Tx(r,e,t,n,s,o):Ap(yu(r),e,t,n,s,o,1);break}}}function J0(r){const e=r.prev,t=r,n=r.next;if(jo(e,t,n)>=0)return!1;const s=e.x,o=t.x,a=n.x,c=e.y,u=t.y,d=n.y,p=Math.min(s,o,a),m=Math.min(c,u,d),y=Math.max(s,o,a),M=Math.max(c,u,d);let T=n.next;for(;T!==e;){if(T.x>=p&&T.x<=y&&T.y>=m&&T.y<=M&&Rp(s,c,o,u,a,d,T.x,T.y)&&jo(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function yf(r,e,t,n){const s=r.prev,o=r,a=r.next;if(jo(s,o,a)>=0)return!1;const c=s.x,u=o.x,d=a.x,p=s.y,m=o.y,y=a.y,M=Math.min(c,u,d),T=Math.min(p,m,y),G=Math.max(c,u,d),z=Math.max(p,m,y),I=Q0(M,T,e,t,n),ee=Q0(G,z,e,t,n);let Q=r.prevZ,oe=r.nextZ;for(;Q&&Q.z>=I&&oe&&oe.z<=ee;){if(Q.x>=M&&Q.x<=G&&Q.y>=T&&Q.y<=z&&Q!==s&&Q!==a&&Rp(c,p,u,m,d,y,Q.x,Q.y)&&jo(Q.prev,Q,Q.next)>=0||(Q=Q.prevZ,oe.x>=M&&oe.x<=G&&oe.y>=T&&oe.y<=z&&oe!==s&&oe!==a&&Rp(c,p,u,m,d,y,oe.x,oe.y)&&jo(oe.prev,oe,oe.next)>=0))return!1;oe=oe.nextZ}for(;Q&&Q.z>=I;){if(Q.x>=M&&Q.x<=G&&Q.y>=T&&Q.y<=z&&Q!==s&&Q!==a&&Rp(c,p,u,m,d,y,Q.x,Q.y)&&jo(Q.prev,Q,Q.next)>=0)return!1;Q=Q.prevZ}for(;oe&&oe.z<=ee;){if(oe.x>=M&&oe.x<=G&&oe.y>=T&&oe.y<=z&&oe!==s&&oe!==a&&Rp(c,p,u,m,d,y,oe.x,oe.y)&&jo(oe.prev,oe,oe.next)>=0)return!1;oe=oe.nextZ}return!0}function M1(r,e){let t=r;do{const n=t.prev,s=t.next.next;!_h(n,s)&&Ax(n,t,t.next,s)&&Mo(n,s)&&Mo(s,n)&&(e.push(n.i,t.i,s.i),wh(t),wh(t.next),t=r=s),t=t.next}while(t!==r);return yu(t)}function Tx(r,e,t,n,s,o){let a=r;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&N1(a,c)){let u=ey(a,c);a=yu(a,a.next),u=yu(u,u.next),Ap(a,e,t,n,s,o,0),Ap(u,e,t,n,s,o,0);return}c=c.next}a=a.next}while(a!==r)}function gd(r,e,t,n){const s=[];for(let o=0,a=e.length;o=t.next.y&&t.next.y!==t.y){const m=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=n&&m>o&&(o=m,a=t.x=t.x&&t.x>=u&&n!==t.x&&Ex(sa.x||t.x===a.x&&E1(a,t)))&&(a=t,p=m)}t=t.next}while(t!==c);return a}function E1(r,e){return jo(r.prev,r,e.prev)<0&&jo(e.next,r,r.next)<0}function A1(r,e,t,n){let s=r;do s.z===0&&(s.z=Q0(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,C1(s)}function C1(r){let e,t=1;do{let n=r,s;r=null;let o=null;for(e=0;n;){e++;let a=n,c=0;for(let d=0;d0||u>0&&a;)c!==0&&(u===0||!a||n.z<=a.z)?(s=n,n=n.nextZ,c--):(s=a,a=a.nextZ,u--),o?o.nextZ=s:r=s,s.prevZ=o,o=s;n=a}o.nextZ=null,t*=2}while(e>1);return r}function Q0(r,e,t,n,s){return r=(r-t)*s|0,e=(e-n)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function R1(r){let e=r,t=r;do(e.x=(r-a)*(o-c)&&(r-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(o-c)>=(s-a)*(n-c)}function Rp(r,e,t,n,s,o,a,c){return!(r===a&&e===c)&&Ex(r,e,t,n,s,o,a,c)}function N1(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!P1(r,e)&&(Mo(r,e)&&Mo(e,r)&&vf(r,e)&&(jo(r.prev,r,e.prev)||jo(r,e.prev,e))||_h(r,e)&&jo(r.prev,r,r.next)>0&&jo(e.prev,e,e.next)>0)}function jo(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function _h(r,e){return r.x===e.x&&r.y===e.y}function Ax(r,e,t,n){const s=bh(jo(r,e,t)),o=bh(jo(r,e,n)),a=bh(jo(t,n,r)),c=bh(jo(t,n,e));return!!(s!==o&&a!==c||s===0&&Np(r,t,e)||o===0&&Np(r,n,e)||a===0&&Np(t,r,n)||c===0&&Np(t,e,n))}function Np(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function bh(r){return r>0?1:r<0?-1:0}function P1(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Ax(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Mo(r,e){return jo(r.prev,r,r.next)<0?jo(r,e,r.next)>=0&&jo(r,r.prev,e)>=0:jo(r,e,r.prev)<0||jo(r,r.next,e)<0}function vf(r,e){let t=r,n=!1;const s=(r.x+e.x)/2,o=(r.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&s<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function ey(r,e){const t=ty(r.i,r.x,r.y),n=ty(e.i,e.x,e.y),s=r.next,o=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Pp(r,e,t,n){const s=ty(r,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function wh(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function ty(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ip(r,e,t,n){let s=0;for(let o=e,a=t-n;o2&&r[e-1].equals(r[0])&&r.pop()}function xf(r,e){for(let t=0;tNumber.EPSILON){const Dn=Math.sqrt(nt),ri=Math.sqrt(ps*ps+St*St),zn=Zn.x-bs/Dn,Rr=Zn.y+Ii/Dn,Ci=qn.x-St/ri,Tr=qn.y+ps/ri,Er=((Ci-zn)*St-(Tr-Rr)*ps)/(Ii*St-bs*ps);Hn=zn+Ii*Er-Kn.x,Ti=Rr+bs*Er-Kn.y;const mi=Hn*Hn+Ti*Ti;if(mi<=2)return new yn(Hn,Ti);pi=Math.sqrt(mi/2)}else{let Dn=!1;Ii>Number.EPSILON?ps>Number.EPSILON&&(Dn=!0):Ii<-Number.EPSILON?ps<-Number.EPSILON&&(Dn=!0):Math.sign(bs)===Math.sign(St)&&(Dn=!0),Dn?(Hn=-bs,Ti=Ii,pi=Math.sqrt(nt)):(Hn=Ii,Ti=bs,pi=Math.sqrt(nt/2))}return new yn(Hn/pi,Ti/pi)}const si=[];for(let Kn=0,Zn=vn.length,qn=Zn-1,Hn=Kn+1;Kn=0;Kn--){const Zn=Kn/z,qn=M*Math.cos(Zn*Math.PI/2),Hn=T*Math.sin(Zn*Math.PI/2)+G;for(let Ti=0,pi=vn.length;Ti=0;){const Hn=qn;let Ti=qn-1;Ti<0&&(Ti=Kn.length-1);for(let pi=0,Ii=p+z*2;pi0)&&M.push(Q,oe,ve),(I!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ay extends Ei{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new jn(16777215),this.specular=new jn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ly extends Ei{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new jn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Rx extends Ei{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class cy extends Ei{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new jn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new jn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qi,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Nx extends Ei{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Px extends Ei{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class uy extends Ei{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new jn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hy extends el{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function yd(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Ix(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Lx(r){function e(s,o){return r[s]-r[o]}const t=r.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function dy(r,e,t){const n=r.length,s=new r.constructor(n);for(let o=0,a=0;a!==n;++o){const c=t[o]*e;for(let u=0;u!==e;++u)s[a++]=r[c+u]}return s}function fy(r,e,t,n){let s=1,o=r[0];for(;o!==void 0&&o[n]===void 0;)o=r[s++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push(...a)),o=r[s++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=r[s++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=r[s++];while(o!==void 0)}function F1(r,e,t,n,s=30){const o=r.clone();o.name=e;const a=[];for(let u=0;u=n)){m.push(d.times[M]);for(let G=0;Go.tracks[u].times[0]&&(c=o.tracks[u].times[0]);for(let u=0;u=c.times[T]){const I=T*m+p,ee=I+m-p;G=c.values.slice(I,ee)}else{const I=c.createInterpolant(),ee=p,Q=m-p;I.evaluate(o),G=I.resultBuffer.slice(ee,Q)}u==="quaternion"&&new ea().fromArray(G).normalize().conjugate().toArray(G);const z=d.times.length;for(let I=0;I=o)){const c=t[1];e=o)break t}a=n,n=0;break n}break e}for(;n>>1;et;)--a;if(++a,o!==0||a!==s){o>=a&&(a=Math.max(a,1),o=a-1);const c=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*c,a*c)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,s=this.values,o=n.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let c=0;c!==o;c++){const u=n[c];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,u),e=!1;break}if(a!==null&&a>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,u,a),e=!1;break}a=u}if(s!==void 0&&Ix(s))for(let c=0,u=s.length;c!==u;++c){const d=s[c];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,d),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===rl,o=e.length-1;let a=1;for(let c=1;c0){e[a]=e[o];for(let c=o*n,u=a*n,d=0;d!==n;++d)t[u+d]=t[c+d];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}Wc.prototype.ValueTypeName="",Wc.prototype.TimeBufferType=Float32Array,Wc.prototype.ValueBufferType=Float32Array,Wc.prototype.DefaultInterpolation=il;class kp extends Wc{constructor(e,t,n){super(e,t,n)}}kp.prototype.ValueTypeName="bool",kp.prototype.ValueBufferType=Array,kp.prototype.DefaultInterpolation=Ao,kp.prototype.InterpolantFactoryMethodLinear=void 0,kp.prototype.InterpolantFactoryMethodSmooth=void 0;class zp extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}zp.prototype.ValueTypeName="color";class fg extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}fg.prototype.ValueTypeName="number";class Dx extends Up{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=(n-t)/(s-t);let d=e*c;for(let p=d+c;d!==p;d+=4)ea.slerpFlat(o,0,a,d-c,a,d,u);return o}}class pg extends Wc{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Dx(this.times,this.values,this.getValueSize(),e)}}pg.prototype.ValueTypeName="quaternion",pg.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends Wc{constructor(e,t,n){super(e,t,n)}}_l.prototype.ValueTypeName="string",_l.prototype.ValueBufferType=Array,_l.prototype.DefaultInterpolation=Ao,_l.prototype.InterpolantFactoryMethodLinear=void 0,_l.prototype.InterpolantFactoryMethodSmooth=void 0;class Xu extends Wc{constructor(e,t,n,s){super(e,t,n,s)}}Xu.prototype.ValueTypeName="vector";class Vp{constructor(e="",t=-1,n=[],s=bo){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=yl(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,c=n.length;a!==c;++a)t.push(k1(n[a]).scale(s));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o.userData=JSON.parse(e.userData||"{}"),o}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let o=0,a=n.length;o!==a;++o)t.push(Wc.toJSON(n[o]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const o=t.length,a=[];for(let c=0;c1){const m=p[1];let y=s[m];y||(s[m]=y=[]),y.push(d)}}const a=[];for(const c in s)a.push(this.CreateFromMorphTargetSequence(c,s[c],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(m,y,M,T,G){if(M.length!==0){const z=[],I=[];fy(M,z,I,T),z.length!==0&&G.push(new m(y,z,I))}},s=[],o=e.name||"default",a=e.fps||30,c=e.blendMode;let u=e.length||-1;const d=e.hierarchy||[];for(let m=0;m{t&&t(o),this.manager.itemEnd(e)},0),o;if(qu[e]!==void 0){qu[e].push({onLoad:t,onProgress:n,onError:s});return}qu[e]=[],qu[e].push({onLoad:t,onProgress:n,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),c=this.mimeType,u=this.responseType;fetch(a).then(d=>{if(d.status===200||d.status===0){if(d.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||d.body===void 0||d.body.getReader===void 0)return d;const p=qu[e],m=d.body.getReader(),y=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),M=y?parseInt(y):0,T=M!==0;let G=0;const z=new ReadableStream({start(I){ee();function ee(){m.read().then(({done:Q,value:oe})=>{if(Q)I.close();else{G+=oe.byteLength;const _e=new ProgressEvent("progress",{lengthComputable:T,loaded:G,total:M});for(let ve=0,Oe=p.length;ve{I.error(Q)})}}});return new Response(z)}else throw new z1(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(u){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(p=>new DOMParser().parseFromString(p,c));case"json":return d.json();default:if(c==="")return d.text();{const m=/charset="?([^;"\s]*)"?/i.exec(c),y=m&&m[1]?m[1].toLowerCase():void 0,M=new TextDecoder(y);return d.arrayBuffer().then(T=>M.decode(T))}}}).then(d=>{_c.add(`file:${e}`,d);const p=qu[e];delete qu[e];for(let m=0,y=p.length;m{const p=qu[e];if(p===void 0)throw this.manager.itemError(e),d;delete qu[e];for(let m=0,y=p.length;m{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class V1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e){const t=[];for(let n=0;n0:s.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const o in e.uniforms){const a=e.uniforms[o];switch(s.uniforms[o]={},a.type){case"t":s.uniforms[o].value=n(a.value);break;case"c":s.uniforms[o].value=new jn().setHex(a.value);break;case"v2":s.uniforms[o].value=new yn().fromArray(a.value);break;case"v3":s.uniforms[o].value=new ot().fromArray(a.value);break;case"v4":s.uniforms[o].value=new mr().fromArray(a.value);break;case"m3":s.uniforms[o].value=new $r().fromArray(a.value);break;case"m4":s.uniforms[o].value=new Ft().fromArray(a.value);break;default:s.uniforms[o].value=a.value}}if(e.defines!==void 0&&(s.defines=e.defines),e.vertexShader!==void 0&&(s.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(s.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(s.glslVersion=e.glslVersion),e.extensions!==void 0)for(const o in e.extensions)s.extensions[o]=e.extensions[o];if(e.lights!==void 0&&(s.lights=e.lights),e.clipping!==void 0&&(s.clipping=e.clipping),e.size!==void 0&&(s.size=e.size),e.sizeAttenuation!==void 0&&(s.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(s.map=n(e.map)),e.matcap!==void 0&&(s.matcap=n(e.matcap)),e.alphaMap!==void 0&&(s.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(s.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(s.bumpScale=e.bumpScale),e.normalMap!==void 0&&(s.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(s.normalMapType=e.normalMapType),e.normalScale!==void 0){let o=e.normalScale;Array.isArray(o)===!1&&(o=[o,o]),s.normalScale=new yn().fromArray(o)}return e.displacementMap!==void 0&&(s.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(s.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(s.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(s.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(s.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(s.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(s.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(s.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(s.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(s.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(s.envMap=n(e.envMap)),e.envMapRotation!==void 0&&s.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(s.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(s.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(s.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(s.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(s.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(s.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(s.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(s.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(s.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new yn().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(s.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(s.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(s.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(s.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(s.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=n(e.sheenRoughnessMap)),s}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return gy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:hg,SpriteMaterial:cp,RawShaderMaterial:oy,ShaderMaterial:Bc,PointsMaterial:uf,MeshPhysicalMaterial:Cx,MeshStandardMaterial:Bp,MeshPhongMaterial:ay,MeshToonMaterial:ly,MeshNormalMaterial:Rx,MeshLambertMaterial:cy,MeshDepthMaterial:Nx,MeshDistanceMaterial:Px,MeshBasicMaterial:Wr,MeshMatcapMaterial:uy,LineDashedMaterial:hy,LineBasicMaterial:el,Material:Ei};return new t[e]}}class kx{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class $1 extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class j1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e){const t={},n={};function s(M,T){if(t[T]!==void 0)return t[T];const z=M.interleavedBuffers[T],I=o(M,z.buffer),ee=ch(z.type,I),Q=new Wu(ee,z.stride);return Q.uuid=z.uuid,t[T]=Q,Q}function o(M,T){if(n[T]!==void 0)return n[T];const z=M.arrayBuffers[T],I=new Uint32Array(z).buffer;return n[T]=I,I}const a=e.isInstancedBufferGeometry?new $1:new xr,c=e.data.index;if(c!==void 0){const M=ch(c.type,c.array);a.setIndex(new Qr(M,1))}const u=e.data.attributes;for(const M in u){const T=u[M];let G;if(T.isInterleavedBufferAttribute){const z=s(e.data,T.data);G=new sf(z,T.itemSize,T.offset,T.normalized)}else{const z=ch(T.type,T.array),I=T.isInstancedBufferAttribute?kc:Qr;G=new I(z,T.itemSize,T.normalized)}T.name!==void 0&&(G.name=T.name),T.usage!==void 0&&G.setUsage(T.usage),a.setAttribute(M,G)}const d=e.data.morphAttributes;if(d)for(const M in d){const T=d[M],G=[];for(let z=0,I=T.length;z0){const u=new xd(t);o=new bc(u),o.setCrossOrigin(this.crossOrigin);for(let d=0,p=e.length;d0){s=new bc(this.manager),s.setCrossOrigin(this.crossOrigin);for(let a=0,c=e.length;a{let z=null,I=null;return G.boundingBox!==void 0&&(z=new ha().fromJSON(G.boundingBox)),G.boundingSphere!==void 0&&(I=new we().fromJSON(G.boundingSphere)),ac(qs({},G),{boundingBox:z,boundingSphere:I})}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=d(e.matricesTexture.uuid),a._indirectTexture=d(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=d(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new we().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new ha().fromJSON(e.boundingBox));break;case"LOD":a=new L0;break;case"Line":a=new xh(c(e.geometry),u(e.material));break;case"LineLoop":a=new mx(c(e.geometry),u(e.material));break;case"LineSegments":a=new ng(c(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new p1(c(e.geometry),u(e.material));break;case"Sprite":a=new jm(u(e.material));break;case"Group":a=new ul;break;case"Bone":a=new U0;break;default:a=new Jr}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const y=e.children;for(let M=0;M{if(vy.has(a)===!0)s&&s(vy.get(a)),o.manager.itemError(e),o.manager.itemEnd(e);else return t&&t(d),o.manager.itemEnd(e),d});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",c.headers=this.requestHeader,c.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const u=fetch(e,c).then(function(d){return d.blob()}).then(function(d){return createImageBitmap(d,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(d){return _c.add(`image-bitmap:${e}`,d),t&&t(d),o.manager.itemEnd(e),d}).catch(function(d){s&&s(d),vy.set(u,d),_c.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});_c.add(`image-bitmap:${e}`,u),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let xy;class zx{static getContext(){return xy===void 0&&(xy=new(window.AudioContext||window.webkitAudioContext)),xy}static setContext(e){xy=e}}class q1 extends null{constructor(e){super(e)}load(e,t,n,s){const o=this,a=new bl(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{const d=u.slice(0);zx.getContext().decodeAudioData(d,function(m){t(m)}).catch(c)}catch(d){c(d)}},n,s);function c(u){s?s(u):console.error(u),o.manager.itemError(e)}}}const _y=new Ft,bg=new Ft,Rf=new Ft;class by{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new fa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new fa,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Rf.copy(e.projectionMatrix);const s=t.eyeSep/2,o=s*t.near/t.focus,a=t.near*Math.tan(lc*t.fov*.5)/t.zoom;let c,u;bg.elements[12]=-s,_y.elements[12]=s,c=-a*t.aspect+o,u=a*t.aspect+o,Rf.elements[0]=2*t.near/(u-c),Rf.elements[8]=(u+c)/(u-c),this.cameraL.projectionMatrix.copy(Rf),c=-a*t.aspect-o,u=a*t.aspect-o,Rf.elements[0]=2*t.near/(u-c),Rf.elements[8]=(u+c)/(u-c),this.cameraR.projectionMatrix.copy(Rf)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(bg),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_y)}}class wy extends fa{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Vx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Sh=new ot,wg=new ea,Md=new ot,Nf=new ot,Pf=new ot;class gE extends null{constructor(){super(),this.type="AudioListener",this.context=zx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Vx}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Sh,wg,Md),Nf.set(0,0,-1).applyQuaternion(wg),Pf.set(0,1,0).applyQuaternion(wg),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Sh.x,n),t.positionY.linearRampToValueAtTime(Sh.y,n),t.positionZ.linearRampToValueAtTime(Sh.z,n),t.forwardX.linearRampToValueAtTime(Nf.x,n),t.forwardY.linearRampToValueAtTime(Nf.y,n),t.forwardZ.linearRampToValueAtTime(Nf.z,n),t.upX.linearRampToValueAtTime(Pf.x,n),t.upY.linearRampToValueAtTime(Pf.y,n),t.upZ.linearRampToValueAtTime(Pf.z,n)}else t.setPosition(Sh.x,Sh.y,Sh.z),t.setOrientation(Nf.x,Nf.y,Nf.z,Pf.x,Pf.y,Pf.z)}}class If extends null{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let u=t,d=t+t;u!==d;++u)if(n[u]!==n[u+t]){c.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let o=n,a=s;o!==a;++o)t[o]=t[s+o%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==o;++a)e[t+a]=e[n+a]}_slerp(e,t,n,s){ea.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,o){const a=this._workIndex*o;ea.multiplyQuaternionsFlat(e,a,e,t,e,n),ea.slerpFlat(e,t,e,t,e,a,s)}_lerp(e,t,n,s,o){const a=1-s;for(let c=0;c!==o;++c){const u=t+c;e[u]=e[u]*a+e[n+c]*s}}_lerpAdditive(e,t,n,s,o){for(let a=0;a!==o;++a){const c=t+a;e[c]=e[c]+e[n+a]*s}}}const Mg="\\[\\]\\.:\\/",Y1=new RegExp("["+Mg+"]","g"),Zu="[^"+Mg+"]",yE="[^"+Mg.replace("\\.","")+"]",vE=/((?:WC+[\/:])*)/.source.replace("WC",Zu),Z1=/(WCOD+)?/.source.replace("WCOD",yE),My=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zu),K1=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zu),Sy=new RegExp("^"+vE+Z1+My+K1+"$"),J1=["material","materials","bones","map"];class Q1{constructor(e,t,n){const s=n||Ks.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=n.length;s!==o;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Ks{constructor(e,t,n){this.path=t,this.parsedPath=n||Ks.parseTrackName(t),this.node=Ks.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ks.Composite(e,t,n):new Ks(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Y1,"")}static parseTrackName(e){const t=Sy.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const o=n.nodeName.substring(s+1);J1.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let a=0;a=o){const m=o++,y=e[m];t[y.uuid]=p,e[p]=y,t[d]=m,e[m]=u;for(let M=0,T=s;M!==T;++M){const G=n[M],z=G[m],I=G[p];G[p]=z,G[m]=I}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,s=n.length;let o=this.nCachedObjects_,a=e.length;for(let c=0,u=arguments.length;c!==u;++c){const d=arguments[c],p=d.uuid,m=t[p];if(m!==void 0)if(delete t[p],m0&&(t[M.uuid]=m),e[m]=M,e.pop();for(let T=0,G=s;T!==G;++T){const z=n[T];z[m]=z[y],z.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let s=n[e];const o=this._bindings;if(s!==void 0)return o[s];const a=this._paths,c=this._parsedPaths,u=this._objects,d=u.length,p=this.nCachedObjects_,m=new Array(d);s=o.length,n[e]=s,a.push(e),c.push(t),o.push(m);for(let y=p,M=u.length;y!==M;++y){const T=u[y];m[y]=new Ks(T,e,t)}return m}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const s=this._paths,o=this._parsedPaths,a=this._bindings,c=a.length-1,u=a[c],d=e[c];t[d]=n,a[n]=u,a.pop(),o[n]=o[c],o.pop(),s[n]=s[c],s.pop()}}}class ew{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const o=t.tracks,a=o.length,c=new Array(a),u={endingStart:ca,endingEnd:ca};for(let d=0;d!==a;++d){const p=o[d].createInterpolant(null);c[d]=p,p.settings=u}this._interpolantSettings=u,this._interpolants=c,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qr,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const s=this._clip.duration,o=e._clip.duration,a=o/s,c=s/o;e.warp(1,a,t),this.warp(c,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const s=this._mixer,o=s.time,a=this.timeScale;let c=this._timeScaleInterpolant;c===null&&(c=s._lendControlInterpolant(),this._timeScaleInterpolant=c);const u=c.parameterPositions,d=c.sampleValues;return u[0]=o,u[1]=o+n,d[0]=e/a,d[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,s){if(!this.enabled){this._updateWeight(e);return}const o=this._startTime;if(o!==null){const u=(e-o)*n;u<0||n===0?t=0:(this._startTime=null,t=n*u)}t*=this._updateTimeScale(e);const a=this._updateTime(t),c=this._updateWeight(e);if(c>0){const u=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case Pc:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulateAdditive(c);break;case bo:default:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulate(s,c)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let s=this.time+e,o=this._loopCount;const a=n===la;if(e===0)return o===-1?s:a&&(o&1)===1?t-s:s;if(n===ro){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<0){const c=Math.floor(s/t);s-=t*c,o+=Math.abs(c);const u=this.repetitions-o;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const d=e<0;this._setEndings(d,!d,a)}else this._setEndings(!1,!1,a);this._loopCount=o,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:c})}}else this.time=s;if(a&&(o&1)===1)return t-s}return s}_setEndings(e,t,n){const s=this._interpolantSettings;n?(s.endingStart=Oa,s.endingEnd=Oa):(e?s.endingStart=this.zeroSlopeAtStart?Oa:ca:s.endingStart=sl,t?s.endingEnd=this.zeroSlopeAtEnd?Oa:ca:s.endingEnd=sl)}_scheduleFading(e,t,n){const s=this._mixer,o=s.time;let a=this._weightInterpolant;a===null&&(a=s._lendControlInterpolant(),this._weightInterpolant=a);const c=a.parameterPositions,u=a.sampleValues;return c[0]=o,u[0]=t,c[1]=o+e,u[1]=n,this}}const tw=new Float32Array(1);class _E extends null{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,s=e._clip.tracks,o=s.length,a=e._propertyBindings,c=e._interpolants,u=n.uuid,d=this._bindingsByRootAndName;let p=d[u];p===void 0&&(p={},d[u]=p);for(let m=0;m!==o;++m){const y=s[m],M=y.name;let T=p[M];if(T!==void 0)++T.referenceCount,a[m]=T;else{if(T=a[m],T!==void 0){T._cacheIndex===null&&(++T.referenceCount,this._addInactiveBinding(T,u,M));continue}const G=t&&t._propertyBindings[m].binding.parsedPath;T=new Td(Ks.create(n,M,G),y.ValueTypeName,y.getValueSize()),++T.referenceCount,this._addInactiveBinding(T,u,M),a[m]=T}c[m].resultBuffer=T.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,s=e._clip.uuid,o=this._actionsByClip[s];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,s=this.time+=e,o=Math.sign(e),a=this._accuIndex^=1;for(let d=0;d!==n;++d)t[d]._update(s,e,o,a);const c=this._bindings,u=this._nActiveBindings;for(let d=0;d!==u;++d)c[d].apply(a);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sg).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const $x=new ot,Ay=new ot,Hp=new ot,Ed=new ot,Tg=new ot,TE=new ot,jx=new ot;class Cy{constructor(e=new ot,t=new ot){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$x.subVectors(e,this.start),Ay.subVectors(this.end,this.start);const n=Ay.dot(Ay);let o=Ay.dot($x)/n;return t&&(o=Sr(o,0,1)),o}closestPointToPoint(e,t,n){const s=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=TE,n=jx){const s=10000000000000001e-32;let o,a;const c=this.start,u=e.start,d=this.end,p=e.end;Hp.subVectors(d,c),Ed.subVectors(p,u),Tg.subVectors(c,u);const m=Hp.dot(Hp),y=Ed.dot(Ed),M=Ed.dot(Tg);if(m<=s&&y<=s)return t.copy(c),n.copy(u),t.sub(n),t.dot(t);if(m<=s)o=0,a=M/y,a=Sr(a,0,1);else{const T=Hp.dot(Tg);if(y<=s)a=0,o=Sr(-T/m,0,1);else{const G=Hp.dot(Ed),z=m*y-G*G;z!==0?o=Sr((G*M-T*y)/z,0,1):o=0,a=(G*o+M)/y,a<0?(a=0,o=Sr(-T/m,0,1)):a>1&&(a=1,o=Sr((G-T)/m,0,1))}}return t.copy(c).add(Hp.multiplyScalar(o)),n.copy(u).add(Ed.multiplyScalar(a)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ad=new ot;class $p extends null{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new xr,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,c=1,u=32;a1)for(let m=0;m.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ow.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ow,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class N3 extends null{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new xr;s.setAttribute("position",new Zi(t,3)),s.setAttribute("color",new Zi(n,3));const o=new el({vertexColors:!0,toneMapped:!1});super(s,o),this.type="AxesHelper"}setColors(e,t,n){const s=new jn,o=this.geometry.attributes.color.array;return s.set(e),s.toArray(o,0),s.toArray(o,3),s.set(t),s.toArray(o,6),s.toArray(o,9),s.set(n),s.toArray(o,12),s.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class P3{constructor(){this.type="ShapePath",this.color=new jn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Z0,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,s){return this.currentPath.quadraticCurveTo(e,t,n,s),this}bezierCurveTo(e,t,n,s,o,a){return this.currentPath.bezierCurveTo(e,t,n,s,o,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(I){const ee=[];for(let Q=0,oe=I.length;QNumber.EPSILON){if(Be<0&&(Oe=ee[ve],Ce=-Ce,He=ee[_e],Be=-Be),I.yHe.y)continue;if(I.y===Oe.y){if(I.x===Oe.x)return!0}else{const ft=Be*(I.x-Oe.x)-Ce*(I.y-Oe.y);if(ft===0)return!0;if(ft<0)continue;oe=!oe}}else{if(I.y!==Oe.y)continue;if(He.x<=I.x&&I.x<=Oe.x||Oe.x<=I.x&&I.x<=He.x)return!0}}return oe}const s=Gc.isClockWise,o=this.subPaths;if(o.length===0)return[];let a,c,u;const d=[];if(o.length===1)return c=o[0],u=new md,u.curves=c.curves,d.push(u),d;let p=!s(o[0].getPoints());p=e?!p:p;const m=[],y=[];let M=[],T=0,G;y[T]=void 0,M[T]=[];for(let I=0,ee=o.length;I1){let I=!1,ee=0;for(let Q=0,oe=y.length;Q0&&I===!1&&(M=m)}let z;for(let I=0,ee=y.length;Ie?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function Dy(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function EE(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Oy(r,e,t,n){const s=AE(n);switch(t){case Du:return r*e;case F:return r*e/s.components*s.byteLength;case X:return r*e/s.components*s.byteLength;case De:return r*e*2/s.components*s.byteLength;case Ve:return r*e*2/s.components*s.byteLength;case Le:return r*e*3/s.components*s.byteLength;case D:return r*e*4/s.components*s.byteLength;case st:return r*e*4/s.components*s.byteLength;case Ht:case Et:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case on:case Un:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case bn:case Bt:return Math.max(r,16)*Math.max(e,8)/4;case sn:case ti:return Math.max(r,8)*Math.max(e,8)/2;case $n:case ni:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Pi:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case ui:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Ir:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case yi:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case vi:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Mr:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case Zt:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Fn:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case hi:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Xn:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case hs:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case Xr:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case ys:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Ur:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case Os:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case no:case io:case So:return Math.ceil(r/4)*Math.ceil(e/4)*16;case To:case Gr:return Math.ceil(r/4)*Math.ceil(e/4)*8;case Qs:case Eo:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function AE(r){switch(r){case Oi:case Gi:return{byteLength:1,components:1};case ms:case ir:case Vs:return{byteLength:2,components:1};case Xl:case ql:return{byteLength:2,components:4};case as:case Is:case gs:return{byteLength:4,components:1};case Dl:case nu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class I3{static contain(e,t){return Cg(e,t)}static cover(e,t){return Dy(e,t)}static fill(e){return EE(e)}static getByteLength(e,t,n,s){return Oy(e,t,n,s)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:w}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=w);const Df=new Al,Ku=new yn,qx=new ot,Fy=new yn,Rg=new yn,By=new ot,j=new ot,i=new Ft,l=new ot,h=new ot;let f=null,g=null;const v=[],C={NONE:-1,PAN:0,ROTATE:1};class V extends Yp{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new Ty,this.mouseButtons={LEFT:k.PAN,MIDDLE:k.PAN,RIGHT:k.ROTATE},this.touches={ONE:O.PAN},this._onPointerMove=H.bind(this),this._onPointerDown=J.bind(this),this._onPointerCancel=he.bind(this),this._onContextMenu=pe.bind(this),n!==null&&this.connect(n)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();Ku.x=(e.clientX-t.left)/t.width*2-1,Ku.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case k.PAN:case O.PAN:this.state=C.PAN;break;case k.ROTATE:case O.ROTATE:this.state=C.ROTATE;break;default:this.state=C.NONE}}}function H(r){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(r),n.setFromCamera(Ku,e),f)this.state===C.PAN?n.ray.intersectPlane(Df,By)&&(f.position.copy(By.sub(qx).applyMatrix4(i)),this.dispatchEvent({type:"drag",object:f})):this.state===C.ROTATE&&(Fy.subVectors(Ku,Rg).multiplyScalar(this.rotateSpeed),f.rotateOnWorldAxis(l,Fy.x),f.rotateOnWorldAxis(h.normalize(),-Fy.y),this.dispatchEvent({type:"drag",object:f})),Rg.copy(Ku);else if(r.pointerType==="mouse"||r.pointerType==="pen")if(v.length=0,n.setFromCamera(Ku,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0){const s=v[0].object;Df.setFromNormalAndCoplanarPoint(e.getWorldDirection(Df.normal),j.setFromMatrixPosition(s.matrixWorld)),g!==s&&g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null),g!==s&&(this.dispatchEvent({type:"hoveron",object:s}),t.style.cursor="pointer",g=s)}else g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null);Rg.copy(Ku)}}function J(r){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(r),this._updateState(r),v.length=0,n.setFromCamera(Ku,e),n.intersectObjects(this.objects,this.recursive,v),v.length>0&&(this.transformGroup===!0?f=me(v[0].object):f=v[0].object,Df.setFromNormalAndCoplanarPoint(e.getWorldDirection(Df.normal),j.setFromMatrixPosition(f.matrixWorld)),n.ray.intersectPlane(Df,By)&&(this.state===C.PAN?(i.copy(f.parent.matrixWorld).invert(),qx.copy(By).sub(j.setFromMatrixPosition(f.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})):this.state===C.ROTATE&&(l.set(0,1,0).applyQuaternion(e.quaternion).normalize(),h.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})))),Rg.copy(Ku))}function he(){this.enabled!==!1&&(f&&(this.dispatchEvent({type:"dragend",object:f}),f=null),this.domElement.style.cursor=g?"pointer":"auto",this.state=C.NONE)}function pe(r){this.enabled!==!1&&r.preventDefault()}function me(r,e=null){return r.isGroup&&(e=r),r.parent===null?e:me(r.parent,e)}var Se={value:()=>{}};function tt(){for(var r=0,e=arguments.length,t={},n;r=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}gt.prototype=tt.prototype={constructor:gt,on:function(r,e){var t=this._,n=mt(r+"",t),s,o=-1,a=n.length;if(arguments.length<2){for(;++o0)for(var t=new Array(s),n=0,s,o;n=0&&r._call.call(void 0,e),r=r._next;--gn}function qo(){Yr=(dr=eo.now())+Ss,gn=Sn=0;try{Ca()}finally{gn=0,wc(),Yr=0}}function Hc(){var r=eo.now(),e=r-dr;e>In&&(Ss-=e,dr=r)}function wc(){for(var r,e=ii,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:ii=t);li=r,Eh(n)}function Eh(r){if(!gn){Sn&&(Sn=clearTimeout(Sn));var e=r-Yr;e>24?(r<1/0&&(Sn=setTimeout(qo,r-eo.now()-Ss)),kn&&(kn=clearInterval(kn))):(kn||(dr=eo.now(),kn=setInterval(Hc,In)),gn=1,uo(qo))}}const Zp=1664525,aw=1013904223,Yx=4294967296;function Zx(){let r=1;return()=>(r=(Zp*r+aw)%Yx)/Yx}var xu=3;function Of(r){return r.x}function Kx(r){return r.y}function Ju(r){return r.z}var Qu=10,Ui=Math.PI*(3-Math.sqrt(5)),tr=Math.PI*20/(9+Math.sqrt(221));function rr(r,e){e=e||2;var t=Math.min(xu,Math.max(1,Math.round(e))),n,s=1,o=.001,a=1-Math.pow(o,1/300),c=0,u=.6,d=new Map,p=Xo(M),m=Wt("tick","end"),y=Zx();r==null&&(r=[]);function M(){T(),m.call("tick",n),s1&&(oe.fy==null?oe.y+=oe.vy*=u:(oe.y=oe.fy,oe.vy=0)),t>2&&(oe.fz==null?oe.z+=oe.vz*=u:(oe.z=oe.fz,oe.vz=0));return n}function G(){for(var I=0,ee=r.length,Q;I1&&isNaN(Q.y)||t>2&&isNaN(Q.z)){var oe=Qu*(t>2?Math.cbrt(.5+I):t>1?Math.sqrt(.5+I):I),_e=I*Ui,ve=I*tr;t===1?Q.x=oe:t===2?(Q.x=oe*Math.cos(_e),Q.y=oe*Math.sin(_e)):(Q.x=oe*Math.sin(_e)*Math.cos(ve),Q.y=oe*Math.cos(_e),Q.z=oe*Math.sin(_e)*Math.sin(ve))}(isNaN(Q.vx)||t>1&&isNaN(Q.vy)||t>2&&isNaN(Q.vz))&&(Q.vx=0,t>1&&(Q.vy=0),t>2&&(Q.vz=0))}}function z(I){return I.initialize&&I.initialize(r,y,t),I}return G(),n={tick:T,restart:function(){return p.restart(M),n},stop:function(){return p.stop(),n},numDimensions:function(I){return arguments.length?(t=Math.min(xu,Math.max(1,Math.round(I))),d.forEach(z),n):t},nodes:function(I){return arguments.length?(r=I,G(),d.forEach(z),n):r},alpha:function(I){return arguments.length?(s=+I,n):s},alphaMin:function(I){return arguments.length?(o=+I,n):o},alphaDecay:function(I){return arguments.length?(a=+I,n):+a},alphaTarget:function(I){return arguments.length?(c=+I,n):c},velocityDecay:function(I){return arguments.length?(u=1-I,n):1-u},randomSource:function(I){return arguments.length?(y=I,d.forEach(z),n):y},force:function(I,ee){return arguments.length>1?(ee==null?d.delete(I):d.set(I,z(ee)),n):d.get(I)},find:function(){var I=Array.prototype.slice.call(arguments),ee=I.shift()||0,Q=(t>1?I.shift():null)||0,oe=(t>2?I.shift():null)||0,_e=I.shift()||1/0,ve=0,Oe=r.length,He,Ce,Be,ft,zt,tn;for(_e*=_e,ve=0;ve1?(m.on(I,ee),n):m.on(I)}}}function fr(r){return function(){return r}}function lr(r){return(r()-.5)*1e-6}function Js(r){return r.index}function Ts(r,e){var t=r.get(e);if(!t)throw new Error("node not found: "+e);return t}function zo(r){var e=Js,t=y,n,s=fr(30),o,a,c,u,d,p,m=1;r==null&&(r=[]);function y(I){return 1/Math.min(u[I.source.index],u[I.target.index])}function M(I){for(var ee=0,Q=r.length;ee1&&(Ce=Oe.y+Oe.vy-ve.y-ve.vy||lr(p)),c>2&&(Be=Oe.z+Oe.vz-ve.z-ve.vz||lr(p)),ft=Math.sqrt(He*He+Ce*Ce+Be*Be),ft=(ft-o[oe])/ft*I*n[oe],He*=ft,Ce*=ft,Be*=ft,Oe.vx-=He*(zt=d[oe]),c>1&&(Oe.vy-=Ce*zt),c>2&&(Oe.vz-=Be*zt),ve.vx+=He*(zt=1-zt),c>1&&(ve.vy+=Ce*zt),c>2&&(ve.vz+=Be*zt)}function T(){if(a){var I,ee=a.length,Q=r.length,oe=new Map(a.map((ve,Oe)=>[e(ve,Oe,a),ve])),_e;for(I=0,u=new Array(ee);Itypeof Q=="function")||Math.random,c=ee.find(Q=>[1,2,3].includes(Q))||2,T()},M.links=function(I){return arguments.length?(r=I,T(),M):r},M.id=function(I){return arguments.length?(e=I,M):e},M.iterations=function(I){return arguments.length?(m=+I,M):m},M.strength=function(I){return arguments.length?(t=typeof I=="function"?I:fr(+I),G(),M):t},M.distance=function(I){return arguments.length?(s=typeof I=="function"?I:fr(+I),z(),M):s},M}var Yo=b(20928),Ga=b(46632),nc=b(67217);function Cd(){var r,e,t,n,s,o=fr(-30),a,c=1,u=1/0,d=.81;function p(T){var G,z=r.length,I=(e===1?(0,Yo.Z)(r,Of):e===2?(0,Ga.Z)(r,Of,Kx):e===3?(0,nc.Z)(r,Of,Kx,Ju):null).visitAfter(y);for(s=T,G=0;G1&&(T.y=oe/ee),e>2&&(T.z=_e/ee)}else{z=T,z.x=z.data.x,e>1&&(z.y=z.data.y),e>2&&(z.z=z.data.z);do G+=a[z.data.index];while(z=z.next)}T.value=G}function M(T,G,z,I,ee){if(!T.value)return!0;var Q=[z,I,ee][e-1],oe=T.x-t.x,_e=e>1?T.y-t.y:0,ve=e>2?T.z-t.z:0,Oe=Q-G,He=oe*oe+_e*_e+ve*ve;if(Oe*Oe/d1&&_e===0&&(_e=lr(n),He+=_e*_e),e>2&&ve===0&&(ve=lr(n),He+=ve*ve),He1&&(t.vy+=_e*T.value*s/He),e>2&&(t.vz+=ve*T.value*s/He)),!0;if(T.length||He>=u)return;(T.data!==t||T.next)&&(oe===0&&(oe=lr(n),He+=oe*oe),e>1&&_e===0&&(_e=lr(n),He+=_e*_e),e>2&&ve===0&&(ve=lr(n),He+=ve*ve),He1&&(t.vy+=_e*Oe),e>2&&(t.vz+=ve*Oe));while(T=T.next)}return p.initialize=function(T,...G){r=T,n=G.find(z=>typeof z=="function")||Math.random,e=G.find(z=>[1,2,3].includes(z))||2,m()},p.strength=function(T){return arguments.length?(o=typeof T=="function"?T:fr(+T),m(),p):o},p.distanceMin=function(T){return arguments.length?(c=T*T,p):Math.sqrt(c)},p.distanceMax=function(T){return arguments.length?(u=T*T,p):Math.sqrt(u)},p.theta=function(T){return arguments.length?(d=T*T,p):Math.sqrt(d)},p}function ic(r,e,t){var n,s=1;r==null&&(r=0),e==null&&(e=0),t==null&&(t=0);function o(){var a,c=n.length,u,d=0,p=0,m=0;for(a=0;a1&&(T.vy+=z*Q),o>2&&(T.vz+=I*Q)}}function p(){if(s){var m,y=s.length;for(c=new Array(y),u=new Array(y),m=0;m[1,2,3].includes(M))||2,p()},d.strength=function(m){return arguments.length?(a=typeof m=="function"?m:fr(+m),p(),d):a},d.radius=function(m){return arguments.length?(r=typeof m=="function"?m:fr(+m),p(),d):r},d.x=function(m){return arguments.length?(e=+m,d):e},d.y=function(m){return arguments.length?(t=+m,d):t},d.z=function(m){return arguments.length?(n=+m,d):n},d}function Qx(r){lw(r);const e=e_(r);return r.on=e.on,r.off=e.off,r.fire=e.fire,r}function e_(r){let e=Object.create(null);return{on:function(t,n,s){if(typeof n!="function")throw new Error("callback is expected to be a function");let o=e[t];return o||(o=e[t]=[]),o.push({callback:n,ctx:s}),r},off:function(t,n){if(typeof t=="undefined")return e=Object.create(null),r;if(e[t])if(typeof n!="function")delete e[t];else{const a=e[t];for(let c=0;c1&&(s=Array.prototype.slice.call(arguments,1));for(let o=0;o0&&(m.fire("changed",a),a.length=0)}function si(wn){if(typeof wn!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+wn);for(var Gn=e.values(),Si=Gn.next();!Si.done;){if(wn(Si.value))return!0;Si=Gn.next()}}}function n_(r,e){this.id=r,this.links=null,this.data=e}function CE(r,e){r.links?r.links.add(e):r.links=new Set([e])}function RE(r,e,t,n){this.fromId=r,this.toId=e,this.data=t,this.id=n}function i_(r,e){return r.toString()+"\u{1F449} "+e.toString()}var L3=b(16505);function D3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var uw=D3,O3=typeof global=="object"&&global&&global.Object===Object&&global,F3=O3,B3=typeof self=="object"&&self&&self.Object===Object&&self,U3=F3||B3||Function("return this")(),NE=U3,k3=function(){return NE.Date.now()},hw=k3,z3=/\s/;function V3(r){for(var e=r.length;e--&&z3.test(r.charAt(e)););return e}var G3=V3,W3=/^\s+/;function H3(r){return r&&r.slice(0,G3(r)+1).replace(W3,"")}var $3=H3,j3=NE.Symbol,r_=j3,PE=Object.prototype,X3=PE.hasOwnProperty,q3=PE.toString,Uy=r_?r_.toStringTag:void 0;function Y3(r){var e=X3.call(r,Uy),t=r[Uy];try{r[Uy]=void 0;var n=!0}catch(o){}var s=q3.call(r);return n&&(e?r[Uy]=t:delete r[Uy]),s}var Z3=Y3,K3=Object.prototype,J3=K3.toString;function Q3(r){return J3.call(r)}var eD=Q3,tD="[object Null]",nD="[object Undefined]",IE=r_?r_.toStringTag:void 0;function iD(r){return r==null?r===void 0?nD:tD:IE&&IE in Object(r)?Z3(r):eD(r)}var rD=iD;function sD(r){return r!=null&&typeof r=="object"}var oD=sD,aD="[object Symbol]";function lD(r){return typeof r=="symbol"||oD(r)&&rD(r)==aD}var cD=lD,LE=NaN,uD=/^[-+]0x[0-9a-f]+$/i,hD=/^0b[01]+$/i,dD=/^0o[0-7]+$/i,fD=parseInt;function pD(r){if(typeof r=="number")return r;if(cD(r))return LE;if(uw(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=uw(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=$3(r);var t=hD.test(r);return t||dD.test(r)?fD(r.slice(2),t?2:8):uD.test(r)?LE:+r}var DE=pD,mD="Expected a function",gD=Math.max,yD=Math.min;function vD(r,e,t){var n,s,o,a,c,u,d=0,p=!1,m=!1,y=!0;if(typeof r!="function")throw new TypeError(mD);e=DE(e)||0,uw(t)&&(p=!!t.leading,m="maxWait"in t,o=m?gD(DE(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function M(ve){var Oe=n,He=s;return n=s=void 0,d=ve,a=r.apply(He,Oe),a}function T(ve){return d=ve,c=setTimeout(I,e),p?M(ve):a}function G(ve){var Oe=ve-u,He=ve-d,Ce=e-Oe;return m?yD(Ce,o-He):Ce}function z(ve){var Oe=ve-u,He=ve-d;return u===void 0||Oe>=e||Oe<0||m&&He>=o}function I(){var ve=hw();if(z(ve))return ee(ve);c=setTimeout(I,G(ve))}function ee(ve){return c=void 0,y&&n?M(ve):(n=s=void 0,a)}function Q(){c!==void 0&&clearTimeout(c),d=0,n=u=s=c=void 0}function oe(){return c===void 0?a:ee(hw())}function _e(){var ve=hw(),Oe=z(ve);if(n=arguments,s=this,u=ve,Oe){if(c===void 0)return T(u);if(m)return clearTimeout(c),c=setTimeout(I,e),M(u)}return c===void 0&&(c=setTimeout(I,e)),a}return _e.cancel=Q,_e.flush=oe,_e}var xD=vD;function OE(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);tn||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let s of r)(s=e(s,++n,r))!=null&&(t>s||t===void 0&&s>=s)&&(t=s)}return t}function RD(r,e){let t;if(e===void 0)for(const n of r)n!=null&&(t=n)&&(t=n);else{let n=-1;for(let s of r)(s=e(s,++n,r))!=null&&(t=s)&&(t=s)}return t}function dw(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);tr.length)&&(e=r.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},o=s.dataBindAttr,a=o===void 0?"__data":o,c=s.objBindAttr,u=c===void 0?"__threeObj":c;return XE(this,e),n=jE(this,e),a_(n,"scene",void 0),qE(n,Tw,void 0),qE(n,l_,void 0),n.scene=t,YE(Tw,n,a),YE(l_,n,u),n.onRemoveObj(function(){}),n}return JE(e,r),KE(e,[{key:"onCreateObj",value:function(n){var s=this;return ww(e,"onCreateObj",this)([function(o){var a=n(o);return o[vw(l_,s)]=a,a[vw(Tw,s)]=o,s.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var s=this;return ww(e,"onRemoveObj",this)([function(o,a){var c=ww(e,"getData",s)([o]);n(o,a),s.scene.remove(o),Sw(o),delete c[vw(l_,s)]}]),this}}])}(HD),Gy=function(e){return isNaN(e)?parseInt((0,HE.Z)(e).toHex(),16):e},Ew=function(e){return isNaN(e)?(0,HE.Z)(e).getAlpha():1},aO=WE(XD);function rA(r,e,t){!e||typeof t!="string"||r.filter(function(n){return!n[t]}).forEach(function(n){n[t]=aO(e(n))})}function lO(r,e){var t=r.nodes,n=r.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=s.nodeFilter,a=o===void 0?function(){return!0}:o,c=s.onLoopError,u=c===void 0?function(M){throw"Invalid DAG structure! Found cycle in node path: ".concat(M.join(" -> "),".")}:c,d={};t.forEach(function(M){return d[e(M)]={data:M,out:[],depth:-1,skip:!a(M)}}),n.forEach(function(M){var T=M.source,G=M.target,z=oe(T),I=oe(G);if(!d.hasOwnProperty(z))throw"Missing source node with id: ".concat(z);if(!d.hasOwnProperty(I))throw"Missing target node with id: ".concat(I);var ee=d[z],Q=d[I];ee.out.push(Q);function oe(_e){return Mw(_e)==="object"?e(_e):_e}});var p=[];y(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(eh(Object.entries(d).filter(function(M){var T=zy(M,2),G=T[1];return!G.skip}).map(function(M){var T=zy(M,2),G=T[0],z=T[1];return a_({},G,z.depth)}))));return m;function y(M){for(var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,z=function(){var oe=M[I];if(T.indexOf(oe)!==-1){var _e=[].concat(eh(T.slice(T.indexOf(oe))),[oe]).map(function(ve){return e(ve.data)});return p.some(function(ve){return ve.length===_e.length&&ve.every(function(Oe,He){return Oe===_e[He]})})||(p.push(_e),u(_e)),1}G>oe.depth&&(oe.depth=G,y(oe.out,[].concat(eh(T),[oe]),G+(oe.skip?0:1)))},I=0,ee=M.length;I2?-60:-30),e<3&&s(t.graphData.nodes,"z"),e<2&&s(t.graphData.nodes,"y");function s(o,a){o.forEach(function(c){delete c[a],delete c["v".concat(a)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(n){return n.fx=n.fy=n.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&n(),s(),o(),this;function n(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()0){var ve=G.x-T.x,Oe=G.y-T.y||0,He=new Zr.Vector3().subVectors(ee,I),Ce=He.clone().multiplyScalar(z).cross(ve!==0||Oe!==0?new Zr.Vector3(0,0,1):new Zr.Vector3(0,1,0)).applyAxisAngle(He.normalize(),_e).add(new Zr.Vector3().addVectors(I,ee).divideScalar(2));oe=new Zr.QuadraticBezierCurve3(I,Ce,ee)}else{var Be=z*70,ft=-_e,zt=ft+Math.PI/2;oe=new Zr.CubicBezierCurve3(I,new Zr.Vector3(Be*Math.cos(zt),Be*Math.sin(zt),0).add(I),new Zr.Vector3(Be*Math.cos(ft),Be*Math.sin(ft),0).add(I),ee)}y.__curve=oe}}}}function s(){var a=Us(e.linkDirectionalArrowRelPos),c=Us(e.linkDirectionalArrowLength),u=Us(e.nodeVal);e.arrowDataMapper.entries().forEach(function(d){var p=zy(d,2),m=p[0],y=p[1];if(y){var M=t?m:e.layout.getLinkPosition(e.layout.graph.getLink(m.source,m.target).id),T=M[t?"source":"from"],G=M[t?"target":"to"];if(!(!T||!G||!T.hasOwnProperty("x")||!G.hasOwnProperty("x"))){var z=Math.cbrt(Math.max(0,u(T)||1))*e.nodeRelSize,I=Math.cbrt(Math.max(0,u(G)||1))*e.nodeRelSize,ee=c(m),Q=a(m),oe=m.__curve?function(Be){return m.__curve.getPoint(Be)}:function(Be){var ft=function(tn,cn,vn,mn){return cn[tn]+(vn[tn]-cn[tn])*mn||0};return{x:ft("x",T,G,Be),y:ft("y",T,G,Be),z:ft("z",T,G,Be)}},_e=m.__curve?m.__curve.getLength():Math.sqrt(["x","y","z"].map(function(Be){return Math.pow((G[Be]||0)-(T[Be]||0),2)}).reduce(function(Be,ft){return Be+ft},0)),ve=z+ee+(_e-z-I-ee)*Q,Oe=oe(ve/_e),He=oe((ve-ee)/_e);["x","y","z"].forEach(function(Be){return y.position[Be]=He[Be]});var Ce=ZE(Zr.Vector3,eh(["x","y","z"].map(function(Be){return Oe[Be]})));y.parent.localToWorld(Ce),y.lookAt(Ce)}}})}function o(){var a=Us(e.linkDirectionalParticleSpeed),c=Us(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(u){var d=e.particlesDataMapper.getObj(u),p=d&&d.children,m=u.__singleHopPhotonsObj&&u.__singleHopPhotonsObj.children;if(!((!m||!m.length)&&(!p||!p.length))){var y=t?u:e.layout.getLinkPosition(e.layout.graph.getLink(u.source,u.target).id),M=y[t?"source":"from"],T=y[t?"target":"to"];if(!(!M||!T||!M.hasOwnProperty("x")||!T.hasOwnProperty("x"))){var G=a(u),z=Math.abs(c(u)),I=u.__curve?function(Q){return u.__curve.getPoint(Q)}:function(Q){var oe=function(ve,Oe,He,Ce){return Oe[ve]+(He[ve]-Oe[ve])*Ce||0};return{x:oe("x",M,T,Q),y:oe("y",M,T,Q),z:oe("z",M,T,Q)}},ee=[].concat(eh(p||[]),eh(m||[]));ee.forEach(function(Q,oe){var _e=Q.parent.__linkThreeObjType==="singleHopPhotons";if(Q.hasOwnProperty("__progressRatio")||(Q.__progressRatio=_e?0:(oe+z)/p.length),Q.__progressRatio+=G,Q.__progressRatio>=1)if(!_e)Q.__progressRatio=Q.__progressRatio%1;else{Q.parent.remove(Q),Sw(Q);return}var ve=Q.__progressRatio,Oe=I(ve);Q.geometry.type!=="SphereGeometry"&&Q.lookAt(Oe.x,Oe.y,Oe.z),["x","y","z"].forEach(function(He){return Q.position[He]=Oe[He]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new Zr.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var s=Us(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var o=Us(e.linkDirectionalParticleWidth),a=Math.ceil(o(t)*10)/10/2,c=e.linkDirectionalParticleResolution,u=new Zr.SphereGeometry(a,c,c),d=Us(e.linkColor),p=Us(e.linkDirectionalParticleColor),m=p(t)||d(t)||"#f0f0f0",y=new Zr.Color(Gy(m)),M=e.linkOpacity*3,T=new Zr.MeshLambertMaterial({color:y,transparent:!0,opacity:M});s=new Zr.Mesh(u,T)}t.__singleHopPhotonsObj.add(s)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=function s(o){var a=[];if(o.geometry){o.geometry.computeBoundingBox();var c=new Zr.Box3;c.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),a.push(c)}return a.concat.apply(a,eh((o.children||[]).filter(function(u){return!u.hasOwnProperty("__graphObjType")||u.__graphObjType==="node"&&t(u.__data)}).map(s)))}(e.graphScene);return n.length?Object.assign.apply(Object,eh(["x","y","z"].map(function(s){return a_({},s,[CD(n,function(o){return o.min[s]}),RD(n,function(o){return o.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:rr().force("link",zo()).force("charge",Cd()).force("center",ic()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new Vy(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new Vy(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new Vy(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new Vy(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function(un){return un.some(function(Mn){return t.hasOwnProperty(Mn)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&n(["nodeAutoColorBy","graphData","nodeColor"])&&rA(e.graphData.nodes,Us(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&rA(e.graphData.links,Us(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=Us(e.nodeThreeObject),o=Us(e.nodeThreeObjectExtend),a=Us(e.nodeVal),c=Us(e.nodeColor),u=Us(e.nodeVisibility),d={},p={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(Vn){var un=s(Vn),Mn=o(Vn);un&&e.nodeThreeObject===un&&(un=un.clone());var fi;return un&&!Mn?fi=un:(fi=new Zr.Mesh,fi.__graphDefaultObj=!0,un&&Mn&&fi.add(un)),fi.__graphObjType="node",fi}).onUpdateObj(function(Vn,un){if(Vn.__graphDefaultObj){var Mn=a(un)||1,fi=Math.cbrt(Mn)*e.nodeRelSize,ki=e.nodeResolution;(!Vn.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||Vn.geometry.parameters.radius!==fi||Vn.geometry.parameters.widthSegments!==ki)&&(d.hasOwnProperty(Mn)||(d[Mn]=new Zr.SphereGeometry(fi,ki,ki)),Vn.geometry.dispose(),Vn.geometry=d[Mn]);var Ni=c(un),Cr=new Zr.Color(Gy(Ni||"#ffffaa")),zs=e.nodeOpacity*Ew(Ni);(Vn.material.type!=="MeshLambertMaterial"||!Vn.material.color.equals(Cr)||Vn.material.opacity!==zs)&&(p.hasOwnProperty(Ni)||(p[Ni]=new Zr.MeshLambertMaterial({color:Cr,transparent:!0,opacity:zs})),Vn.material.dispose(),Vn.material=p[Ni])}}).digest(e.graphData.nodes.filter(u))}if(e._flushObjects||n(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var m=Us(e.linkThreeObject),y=Us(e.linkThreeObjectExtend),M=Us(e.linkMaterial),T=Us(e.linkVisibility),G=Us(e.linkColor),z=Us(e.linkWidth),I={},ee={},Q={},oe=e.graphData.links.filter(T);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(Vn){var un=Vn.__data&&Vn.__data.__singleHopPhotonsObj;un&&(un.parent.remove(un),Sw(un),delete Vn.__data.__singleHopPhotonsObj)}).onCreateObj(function(Vn){var un=m(Vn),Mn=y(Vn);un&&e.linkThreeObject===un&&(un=un.clone());var fi;if(!un||Mn){var ki=!!z(Vn);if(ki)fi=new Zr.Mesh;else{var Ni=new Zr.BufferGeometry;Ni[Aw]("position",new Zr.BufferAttribute(new Float32Array(2*3),3)),fi=new Zr.Line(Ni)}}var Cr;return un?Mn?(Cr=new Zr.Group,Cr.__graphDefaultObj=!0,Cr.add(fi),Cr.add(un)):Cr=un:(Cr=fi,Cr.__graphDefaultObj=!0),Cr.renderOrder=10,Cr.__graphObjType="link",Cr}).onUpdateObj(function(Vn,un){if(Vn.__graphDefaultObj){var Mn=Vn.children.length?Vn.children[0]:Vn,fi=Math.ceil(z(un)*10)/10,ki=!!fi;if(ki){var Ni=fi/2,Cr=e.linkResolution;if(!Mn.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Mn.geometry.parameters.radiusTop!==Ni||Mn.geometry.parameters.radialSegments!==Cr){if(!I.hasOwnProperty(fi)){var zs=new Zr.CylinderGeometry(Ni,Ni,1,Cr,1,!1);zs[c_](new Zr.Matrix4().makeTranslation(0,1/2,0)),zs[c_](new Zr.Matrix4().makeRotationX(Math.PI/2)),I[fi]=zs}Mn.geometry.dispose(),Mn.geometry=I[fi]}}var Vt=M(un);if(Vt)Mn.material=Vt;else{var Kn=G(un),Zn=new Zr.Color(Gy(Kn||"#f0f0f0")),qn=e.linkOpacity*Ew(Kn),Hn=ki?"MeshLambertMaterial":"LineBasicMaterial";if(Mn.material.type!==Hn||!Mn.material.color.equals(Zn)||Mn.material.opacity!==qn){var Ti=ki?ee:Q;Ti.hasOwnProperty(Kn)||(Ti[Kn]=new Zr[Hn]({color:Zn,transparent:qn<1,opacity:qn,depthWrite:qn>=1})),Mn.material.dispose(),Mn.material=Ti[Kn]}}}}).digest(oe),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var _e=Us(e.linkDirectionalArrowLength),ve=Us(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var Vn=new Zr.Mesh(void 0,new Zr.MeshLambertMaterial({transparent:!0}));return Vn.__linkThreeObjType="arrow",Vn}).onUpdateObj(function(Vn,un){var Mn=_e(un),fi=e.linkDirectionalArrowResolution;if(!Vn.geometry.type.match(/^Cone(Buffer)?Geometry$/)||Vn.geometry.parameters.height!==Mn||Vn.geometry.parameters.radialSegments!==fi){var ki=new Zr.ConeGeometry(Mn*.25,Mn,fi);ki.translate(0,Mn/2,0),ki.rotateX(Math.PI/2),Vn.geometry.dispose(),Vn.geometry=ki}var Ni=ve(un)||G(un)||"#f0f0f0";Vn.material.color=new Zr.Color(Gy(Ni)),Vn.material.opacity=e.linkOpacity*3*Ew(Ni)}).digest(oe.filter(_e))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var Oe=Us(e.linkDirectionalParticles),He=Us(e.linkDirectionalParticleWidth),Ce=Us(e.linkDirectionalParticleColor),Be=Us(e.linkDirectionalParticleThreeObject),ft={},zt={};e.particlesDataMapper.onCreateObj(function(){var Vn=new Zr.Group;return Vn.__linkThreeObjType="photons",Vn.__photonDataMapper=new Vy(Vn),Vn}).onUpdateObj(function(Vn,un){var Mn=!!Vn.children.length&&Vn.children[0],fi=Be(un),ki,Ni;if(fi)ki=fi.geometry,Ni=fi.material;else{var Cr=Math.ceil(He(un)*10)/10/2,zs=e.linkDirectionalParticleResolution;Mn&&Mn.geometry.parameters.radius===Cr&&Mn.geometry.parameters.widthSegments===zs?ki=Mn.geometry:(zt.hasOwnProperty(Cr)||(zt[Cr]=new Zr.SphereGeometry(Cr,zs,zs)),ki=zt[Cr]);var Vt=Ce(un)||G(un)||"#f0f0f0",Kn=new Zr.Color(Gy(Vt)),Zn=e.linkOpacity*3;Mn&&Mn.material.color.equals(Kn)&&Mn.material.opacity===Zn?Ni=Mn.material:(ft.hasOwnProperty(Vt)||(ft[Vt]=new Zr.MeshLambertMaterial({color:Kn,transparent:!0,opacity:Zn})),Ni=ft[Vt])}Mn&&(Mn.geometry!==ki&&Mn.geometry.dispose(),Mn.material!==Ni&&Mn.material.dispose());var qn=Math.round(Math.abs(Oe(un)));Vn.__photonDataMapper.id(function(Hn){return Hn.idx}).onCreateObj(function(){return new Zr.Mesh(ki,Ni)}).onUpdateObj(function(Hn){Hn.geometry=ki,Hn.material=Ni}).digest(eh(new Array(qn)).map(function(Hn,Ti){return{idx:Ti}}))}).digest(oe.filter(Oe))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(Vn){Vn.source=Vn[e.linkSource],Vn.target=Vn[e.linkTarget]});var tn=e.forceEngine!=="ngraph",cn;if(tn){(cn=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var vn=e.d3ForceLayout.force("link");vn&&vn.id(function(Vn){return Vn[e.nodeId]}).links(e.graphData.links);var mn=e.dagMode&&lO(e.graphData,function(Vn){return Vn[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),Yn=Math.max.apply(Math,eh(Object.values(mn||[]))),xn=e.dagLevelDistance||e.graphData.nodes.length/(Yn||1)*cO*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var si=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Vn){return delete Vn[si]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var wn=["rl","td","zout"].includes(e.dagMode),Gn=function(un){return(mn[un[e.nodeId]]-Yn/2)*xn*(wn?-1:1)},Si=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Vn){return Vn[Si]=Gn(Vn)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?Jx(function(Vn){var un=mn[Vn[e.nodeId]]||-1;return(e.dagMode==="radialin"?Yn-un:un)*xn}).strength(function(Vn){return e.dagNodeFilter(Vn)?1:0}):null)}else{var nr=sA.graph();e.graphData.nodes.forEach(function(Vn){nr.addNode(Vn[e.nodeId])}),e.graphData.links.forEach(function(Vn){nr.addLink(Vn.source,Vn.target)}),cn=sA.forcelayout(nr,iO({dimensions:e.numDimensions},e.ngraphPhysics)),cn.graph=nr}for(var ss=0;ss0&&e.d3ForceLayout.alpha()1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=function(s){function o(){var a;XE(this,o);for(var c=arguments.length,u=new Array(c),d=0;dM.start-T.start);let y=0;for(let M=1;M 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,NO=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,PO=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,IO=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,LO=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,DO=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,OO=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,FO=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,BO=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,UO=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,kO=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,zO=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,VO=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,GO=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,WO=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,HO="gl_FragColor = linearToOutputTexel( gl_FragColor );",$O=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,jO=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,XO=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,qO=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,YO=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,ZO=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,KO=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,JO=`#ifdef USE_FOG varying float vFogDepth; #endif`,QO=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,eF=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,tF=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,nF=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,iF=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,rF=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,sF=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,oF=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,aF=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,lF=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cF=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,uF=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,hF=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,dF=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( 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 theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( 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 ); mat3 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 += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,fF=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,pF=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,mF=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,gF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,yF=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,vF=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,xF=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,_F=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,bF=`#ifdef USE_MAP uniform sampler2D map; #endif`,wF=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,MF=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,SF=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,TF=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,EF=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,AF=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,CF=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,RF=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,NF=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,PF=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,IF=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,LF=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,DF=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,OF=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,FF=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,BF=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,UF=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,kF=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,zF=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,VF=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,GF=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,WF=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,HF=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,$F=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,jF=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,XF=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,qF=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,YF=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { float depth = unpackRGBAToDepth( texture2D( depths, uv ) ); #ifdef USE_REVERSED_DEPTH_BUFFER return step( depth, compare ); #else return step( compare, depth ); #endif } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow( sampler2D shadow, vec2 uv, float compare ) { float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( distribution.x, compare ); #else float hard_shadow = step( compare, distribution.x ); #endif if ( hard_shadow != 1.0 ) { float distance = compare - distribution.x; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,ZF=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,KF=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,JF=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,QF=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,eB=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,tB=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,nB=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,iB=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,rB=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,sB=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,oB=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; 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 < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,aB=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,lB=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,cB=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,uB=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,hB=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,dB=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const Ns={alphahash_fragment:pO,alphahash_pars_fragment:mO,alphamap_fragment:gO,alphamap_pars_fragment:yO,alphatest_fragment:vO,alphatest_pars_fragment:xO,aomap_fragment:_O,aomap_pars_fragment:bO,batching_pars_vertex:wO,batching_vertex:MO,begin_vertex:SO,beginnormal_vertex:TO,bsdfs:EO,iridescence_fragment:AO,bumpmap_pars_fragment:CO,clipping_planes_fragment:RO,clipping_planes_pars_fragment:NO,clipping_planes_pars_vertex:PO,clipping_planes_vertex:IO,color_fragment:LO,color_pars_fragment:DO,color_pars_vertex:OO,color_vertex:FO,common:BO,cube_uv_reflection_fragment:UO,defaultnormal_vertex:kO,displacementmap_pars_vertex:zO,displacementmap_vertex:VO,emissivemap_fragment:GO,emissivemap_pars_fragment:WO,colorspace_fragment:HO,colorspace_pars_fragment:$O,envmap_fragment:jO,envmap_common_pars_fragment:XO,envmap_pars_fragment:qO,envmap_pars_vertex:YO,envmap_physical_pars_fragment:oF,envmap_vertex:ZO,fog_vertex:KO,fog_pars_vertex:JO,fog_fragment:QO,fog_pars_fragment:eF,gradientmap_pars_fragment:tF,lightmap_pars_fragment:nF,lights_lambert_fragment:iF,lights_lambert_pars_fragment:rF,lights_pars_begin:sF,lights_toon_fragment:aF,lights_toon_pars_fragment:lF,lights_phong_fragment:cF,lights_phong_pars_fragment:uF,lights_physical_fragment:hF,lights_physical_pars_fragment:dF,lights_fragment_begin:fF,lights_fragment_maps:pF,lights_fragment_end:mF,logdepthbuf_fragment:gF,logdepthbuf_pars_fragment:yF,logdepthbuf_pars_vertex:vF,logdepthbuf_vertex:xF,map_fragment:_F,map_pars_fragment:bF,map_particle_fragment:wF,map_particle_pars_fragment:MF,metalnessmap_fragment:SF,metalnessmap_pars_fragment:TF,morphinstance_vertex:EF,morphcolor_vertex:AF,morphnormal_vertex:CF,morphtarget_pars_vertex:RF,morphtarget_vertex:NF,normal_fragment_begin:PF,normal_fragment_maps:IF,normal_pars_fragment:LF,normal_pars_vertex:DF,normal_vertex:OF,normalmap_pars_fragment:FF,clearcoat_normal_fragment_begin:BF,clearcoat_normal_fragment_maps:UF,clearcoat_pars_fragment:kF,iridescence_pars_fragment:zF,opaque_fragment:VF,packing:GF,premultiplied_alpha_fragment:WF,project_vertex:HF,dithering_fragment:$F,dithering_pars_fragment:jF,roughnessmap_fragment:XF,roughnessmap_pars_fragment:qF,shadowmap_pars_fragment:YF,shadowmap_pars_vertex:ZF,shadowmap_vertex:KF,shadowmask_pars_fragment:JF,skinbase_vertex:QF,skinning_pars_vertex:eB,skinning_vertex:tB,skinnormal_vertex:nB,specularmap_fragment:iB,specularmap_pars_fragment:rB,tonemapping_fragment:sB,tonemapping_pars_fragment:oB,transmission_fragment:aB,transmission_pars_fragment:lB,uv_pars_fragment:cB,uv_pars_vertex:uB,uv_vertex:hB,worldpos_vertex:dB,background_vert:`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,background_frag:`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,backgroundCube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,cube_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,cube_frag:`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,depth_vert:`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,depth_frag:`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,distanceRGBA_vert:`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,distanceRGBA_frag:`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,equirect_vert:`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,equirect_frag:`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,linedashed_vert:`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,linedashed_frag:`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,meshbasic_vert:`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,meshbasic_frag:`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,meshlambert_vert:`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshlambert_frag:`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshmatcap_vert:`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,meshmatcap_frag:`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,meshnormal_vert:`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,meshnormal_frag:`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,meshphong_vert:`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,meshphong_frag:`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,meshphysical_vert:`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,meshphysical_frag:`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,meshtoon_vert:`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,meshtoon_frag:`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,points_vert:`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,points_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,shadow_vert:`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,shadow_frag:`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,sprite_vert:`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,sprite_frag:`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`},zi={common:{diffuse:{value:new jn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $r}},envmap:{envMap:{value:null},envMapRotation:{value:new $r},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $r}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $r}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $r},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $r},normalScale:{value:new yn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $r},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $r}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $r}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $r}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new jn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new jn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0},uvTransform:{value:new $r}},sprite:{diffuse:{value:new jn(16777215)},opacity:{value:1},center:{value:new yn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $r},alphaMap:{value:null},alphaMapTransform:{value:new $r},alphaTest:{value:0}}},Ah={basic:{uniforms:Ja([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.fog]),vertexShader:Ns.meshbasic_vert,fragmentShader:Ns.meshbasic_frag},lambert:{uniforms:Ja([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,zi.lights,{emissive:{value:new jn(0)}}]),vertexShader:Ns.meshlambert_vert,fragmentShader:Ns.meshlambert_frag},phong:{uniforms:Ja([zi.common,zi.specularmap,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,zi.lights,{emissive:{value:new jn(0)},specular:{value:new jn(1118481)},shininess:{value:30}}]),vertexShader:Ns.meshphong_vert,fragmentShader:Ns.meshphong_frag},standard:{uniforms:Ja([zi.common,zi.envmap,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.roughnessmap,zi.metalnessmap,zi.fog,zi.lights,{emissive:{value:new jn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ns.meshphysical_vert,fragmentShader:Ns.meshphysical_frag},toon:{uniforms:Ja([zi.common,zi.aomap,zi.lightmap,zi.emissivemap,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.gradientmap,zi.fog,zi.lights,{emissive:{value:new jn(0)}}]),vertexShader:Ns.meshtoon_vert,fragmentShader:Ns.meshtoon_frag},matcap:{uniforms:Ja([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,zi.fog,{matcap:{value:null}}]),vertexShader:Ns.meshmatcap_vert,fragmentShader:Ns.meshmatcap_frag},points:{uniforms:Ja([zi.points,zi.fog]),vertexShader:Ns.points_vert,fragmentShader:Ns.points_frag},dashed:{uniforms:Ja([zi.common,zi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ns.linedashed_vert,fragmentShader:Ns.linedashed_frag},depth:{uniforms:Ja([zi.common,zi.displacementmap]),vertexShader:Ns.depth_vert,fragmentShader:Ns.depth_frag},normal:{uniforms:Ja([zi.common,zi.bumpmap,zi.normalmap,zi.displacementmap,{opacity:{value:1}}]),vertexShader:Ns.meshnormal_vert,fragmentShader:Ns.meshnormal_frag},sprite:{uniforms:Ja([zi.sprite,zi.fog]),vertexShader:Ns.sprite_vert,fragmentShader:Ns.sprite_frag},background:{uniforms:{uvTransform:{value:new $r},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ns.background_vert,fragmentShader:Ns.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $r}},vertexShader:Ns.backgroundCube_vert,fragmentShader:Ns.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ns.cube_vert,fragmentShader:Ns.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ns.equirect_vert,fragmentShader:Ns.equirect_frag},distanceRGBA:{uniforms:Ja([zi.common,zi.displacementmap,{referencePosition:{value:new ot},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ns.distanceRGBA_vert,fragmentShader:Ns.distanceRGBA_frag},shadow:{uniforms:Ja([zi.lights,zi.fog,{color:{value:new jn(0)},opacity:{value:1}}]),vertexShader:Ns.shadow_vert,fragmentShader:Ns.shadow_frag}};Ah.physical={uniforms:Ja([Ah.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $r},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $r},clearcoatNormalScale:{value:new yn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $r},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $r},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $r},sheen:{value:0},sheenColor:{value:new jn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $r},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $r},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $r},transmissionSamplerSize:{value:new yn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $r},attenuationDistance:{value:0},attenuationColor:{value:new jn(0)},specularColor:{value:new jn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $r},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $r},anisotropyVector:{value:new yn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $r}}]),vertexShader:Ns.meshphysical_vert,fragmentShader:Ns.meshphysical_frag};const u_={r:0,b:0,g:0},Kp=new Qi,fB=new Ft;function pB(r,e,t,n,s,o,a){const c=new jn(0);let u=o===!0?0:1,d,p,m=null,y=0,M=null;function T(Q){let oe=Q.isScene===!0?Q.background:null;return oe&&oe.isTexture&&(oe=(Q.backgroundBlurriness>0?t:e).get(oe)),oe}function G(Q){let oe=!1;const _e=T(Q);_e===null?I(c,u):_e&&_e.isColor&&(I(_e,1),oe=!0);const ve=r.xr.getEnvironmentBlendMode();ve==="additive"?n.buffers.color.setClear(0,0,0,1,a):ve==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||oe)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function z(Q,oe){const _e=T(oe);_e&&(_e.isCubeTexture||_e.mapping===Ke)?(p===void 0&&(p=new Zs(new Fc(1,1,1),new Bc({name:"BackgroundCubeMaterial",uniforms:Jh(Ah.backgroundCube.uniforms),vertexShader:Ah.backgroundCube.vertexShader,fragmentShader:Ah.backgroundCube.fragmentShader,side:K,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(ve,Oe,He){this.matrixWorld.copyPosition(He.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(p)),Kp.copy(oe.backgroundRotation),Kp.x*=-1,Kp.y*=-1,Kp.z*=-1,_e.isCubeTexture&&_e.isRenderTargetTexture===!1&&(Kp.y*=-1,Kp.z*=-1),p.material.uniforms.envMap.value=_e,p.material.uniforms.flipEnvMap.value=_e.isCubeTexture&&_e.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=oe.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=oe.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(fB.makeRotationFromEuler(Kp)),p.material.toneMapped=Ki.getTransfer(_e.colorSpace)!==Fi,(m!==_e||y!==_e.version||M!==r.toneMapping)&&(p.material.needsUpdate=!0,m=_e,y=_e.version,M=r.toneMapping),p.layers.enableAll(),Q.unshift(p,p.geometry,p.material,0,0,null)):_e&&_e.isTexture&&(d===void 0&&(d=new Zs(new Mh(2,2),new Bc({name:"BackgroundMaterial",uniforms:Jh(Ah.background.uniforms),vertexShader:Ah.background.vertexShader,fragmentShader:Ah.background.fragmentShader,side:W,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(d)),d.material.uniforms.t2D.value=_e,d.material.uniforms.backgroundIntensity.value=oe.backgroundIntensity,d.material.toneMapped=Ki.getTransfer(_e.colorSpace)!==Fi,_e.matrixAutoUpdate===!0&&_e.updateMatrix(),d.material.uniforms.uvTransform.value.copy(_e.matrix),(m!==_e||y!==_e.version||M!==r.toneMapping)&&(d.material.needsUpdate=!0,m=_e,y=_e.version,M=r.toneMapping),d.layers.enableAll(),Q.unshift(d,d.geometry,d.material,0,0,null))}function I(Q,oe){Q.getRGB(u_,ox(r)),n.buffers.color.setClear(u_.r,u_.g,u_.b,oe,a)}function ee(){p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0)}return{getClearColor:function(){return c},setClearColor:function(Q,oe=1){c.set(Q),u=oe,I(c,u)},getClearAlpha:function(){return u},setClearAlpha:function(Q){u=Q,I(c,u)},render:G,addToRenderList:z,dispose:ee}}function mB(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},s=y(null);let o=s,a=!1;function c(Be,ft,zt,tn,cn){let vn=!1;const mn=m(tn,zt,ft);o!==mn&&(o=mn,d(o.object)),vn=M(Be,tn,zt,cn),vn&&T(Be,tn,zt,cn),cn!==null&&e.update(cn,r.ELEMENT_ARRAY_BUFFER),(vn||a)&&(a=!1,oe(Be,ft,zt,tn),cn!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(cn).buffer))}function u(){return r.createVertexArray()}function d(Be){return r.bindVertexArray(Be)}function p(Be){return r.deleteVertexArray(Be)}function m(Be,ft,zt){const tn=zt.wireframe===!0;let cn=n[Be.id];cn===void 0&&(cn={},n[Be.id]=cn);let vn=cn[ft.id];vn===void 0&&(vn={},cn[ft.id]=vn);let mn=vn[tn];return mn===void 0&&(mn=y(u()),vn[tn]=mn),mn}function y(Be){const ft=[],zt=[],tn=[];for(let cn=0;cn=0){const wn=cn[xn];let Gn=vn[xn];if(Gn===void 0&&(xn==="instanceMatrix"&&Be.instanceMatrix&&(Gn=Be.instanceMatrix),xn==="instanceColor"&&Be.instanceColor&&(Gn=Be.instanceColor)),wn===void 0||wn.attribute!==Gn||Gn&&wn.data!==Gn.data)return!0;mn++}return o.attributesNum!==mn||o.index!==tn}function T(Be,ft,zt,tn){const cn={},vn=ft.attributes;let mn=0;const Yn=zt.getAttributes();for(const xn in Yn)if(Yn[xn].location>=0){let wn=vn[xn];wn===void 0&&(xn==="instanceMatrix"&&Be.instanceMatrix&&(wn=Be.instanceMatrix),xn==="instanceColor"&&Be.instanceColor&&(wn=Be.instanceColor));const Gn={};Gn.attribute=wn,wn&&wn.data&&(Gn.data=wn.data),cn[xn]=Gn,mn++}o.attributes=cn,o.attributesNum=mn,o.index=tn}function G(){const Be=o.newAttributes;for(let ft=0,zt=Be.length;ft=0){let si=cn[Yn];if(si===void 0&&(Yn==="instanceMatrix"&&Be.instanceMatrix&&(si=Be.instanceMatrix),Yn==="instanceColor"&&Be.instanceColor&&(si=Be.instanceColor)),si!==void 0){const wn=si.normalized,Gn=si.itemSize,Si=e.get(si);if(Si===void 0)continue;const nr=Si.buffer,ss=Si.type,Vn=Si.bytesPerElement,un=ss===r.INT||ss===r.UNSIGNED_INT||si.gpuType===Is;if(si.isInterleavedBufferAttribute){const Mn=si.data,fi=Mn.stride,ki=si.offset;if(Mn.isInstancedInterleavedBuffer){for(let Ni=0;Ni0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";Oe="mediump"}return Oe==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=t.precision!==void 0?t.precision:"highp";const p=u(d);p!==d&&(console.warn("THREE.WebGLRenderer:",d,"not supported, using",p,"instead."),d=p);const m=t.logarithmicDepthBuffer===!0,y=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),M=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),T=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),G=r.getParameter(r.MAX_TEXTURE_SIZE),z=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),I=r.getParameter(r.MAX_VERTEX_ATTRIBS),ee=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),Q=r.getParameter(r.MAX_VARYING_VECTORS),oe=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),_e=T>0,ve=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:c,precision:d,logarithmicDepthBuffer:m,reversedDepthBuffer:y,maxTextures:M,maxVertexTextures:T,maxTextureSize:G,maxCubemapSize:z,maxAttributes:I,maxVertexUniforms:ee,maxVaryings:Q,maxFragmentUniforms:oe,vertexTextures:_e,maxSamples:ve}}function vB(r){const e=this;let t=null,n=0,s=!1,o=!1;const a=new Al,c=new $r,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(m,y){const M=m.length!==0||y||n!==0||s;return s=y,n=m.length,M},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,y){t=p(m,y,0)},this.setState=function(m,y,M){const T=m.clippingPlanes,G=m.clipIntersection,z=m.clipShadows,I=r.get(m);if(!s||T===null||T.length===0||o&&!z)o?p(null):d();else{const ee=o?0:n,Q=ee*4;let oe=I.clippingState||null;u.value=oe,oe=p(T,y,Q,M);for(let _e=0;_e!==Q;++_e)oe[_e]=t[_e];I.clippingState=oe,this.numIntersection=G?this.numPlanes:0,this.numPlanes+=ee}};function d(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function p(m,y,M,T){const G=m!==null?m.length:0;let z=null;if(G!==0){if(z=u.value,T!==!0||z===null){const I=M+G*4,ee=y.matrixWorldInverse;c.getNormalMatrix(ee),(z===null||z.length0){const d=new R0(u.height);return d.fromEquirectangularTexture(r,a),e.set(a,d),a.addEventListener("dispose",s),t(d.texture,a.mapping)}else return null}}return a}function s(a){const c=a.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}const Dg=4,lA=[.125,.215,.35,.446,.526,.582],Jp=20,Cw=new Cf,cA=new jn;let Rw=null,Nw=0,Pw=0,Iw=!1;const Qp=(1+Math.sqrt(5))/2,Og=1/Qp,uA=[new ot(-Qp,Og,0),new ot(Qp,Og,0),new ot(-Og,0,Qp),new ot(Og,0,Qp),new ot(0,Qp,-Og),new ot(0,Qp,Og),new ot(-1,1,-1),new ot(1,1,-1),new ot(-1,1,1),new ot(1,1,1)],_B=new ot;class hA{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,s=100,o={}){const{size:a=256,position:c=_B}=o;Rw=this._renderer.getRenderTarget(),Nw=this._renderer.getActiveCubeFace(),Pw=this._renderer.getActiveMipmapLevel(),Iw=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,n,s,u,c),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=pA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=fA(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?_e:0,_e,_e),m.setRenderTarget(s),I&&m.render(z,u),m.render(e,u)}z.geometry.dispose(),z.material.dispose(),m.toneMapping=M,m.autoClear=y,e.background=ee}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Fe||e.mapping===Xe;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=pA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=fA());const o=s?this._cubemapMaterial:this._equirectMaterial,a=new Zs(this._lodPlanes[0],o),c=o.uniforms;c.envMap.value=e;const u=this._cubeSize;h_(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,Cw)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let o=1;oJp&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${Jp}`);const I=[];let ee=0;for(let Oe=0;OeQ-Dg?s-Q+Dg:0),ve=4*(this._cubeSize-oe);h_(t,_e,ve,3*oe,2*oe),u.setRenderTarget(t),u.render(m,Cw)}}function bB(r){const e=[],t=[],n=[];let s=r;const o=r-Dg+1+lA.length;for(let a=0;ar-Dg?u=lA[a-r+Dg-1]:a===0&&(u=0),n.push(u);const d=1/(c-2),p=-d,m=1+d,y=[p,p,m,p,m,m,p,p,m,m,p,m],M=6,T=6,G=3,z=2,I=1,ee=new Float32Array(G*T*M),Q=new Float32Array(z*T*M),oe=new Float32Array(I*T*M);for(let ve=0;ve2?0:-1,Ce=[Oe,He,0,Oe+2/3,He,0,Oe+2/3,He+1,0,Oe,He,0,Oe+2/3,He+1,0,Oe,He+1,0];ee.set(Ce,G*T*ve),Q.set(y,z*T*ve);const Be=[ve,ve,ve,ve,ve,ve];oe.set(Be,I*T*ve)}const _e=new xr;_e.setAttribute("position",new Qr(ee,G)),_e.setAttribute("uv",new Qr(Q,z)),_e.setAttribute("faceIndex",new Qr(oe,I)),e.push(_e),s>Dg&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function dA(r,e,t){const n=new cc(r,e,t);return n.texture.mapping=Ke,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function h_(r,e,t,n,s){r.viewport.set(e,t,n,s),r.scissor.set(e,t,n,s)}function wB(r,e,t){const n=new Float32Array(Jp),s=new ot(0,1,0);return new Bc({name:"SphericalGaussianBlur",defines:{n:Jp,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Lw(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:ye,depthTest:!1,depthWrite:!1})}function fA(){return new Bc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Lw(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:ye,depthTest:!1,depthWrite:!1})}function pA(){return new Bc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Lw(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:ye,depthTest:!1,depthWrite:!1})}function Lw(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function MB(r){let e=new WeakMap,t=null;function n(c){if(c&&c.isTexture){const u=c.mapping,d=u===Pe||u===Ie,p=u===Fe||u===Xe;if(d||p){let m=e.get(c);const y=m!==void 0?m.texture.pmremVersion:0;if(c.isRenderTargetTexture&&c.pmremVersion!==y)return t===null&&(t=new hA(r)),m=d?t.fromEquirectangular(c,m):t.fromCubemap(c,m),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),m.texture;if(m!==void 0)return m.texture;{const M=c.image;return d&&M&&M.height>0||p&&M&&s(M)?(t===null&&(t=new hA(r)),m=d?t.fromEquirectangular(c):t.fromCubemap(c),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),c.addEventListener("dispose",o),m.texture):null}}}return c}function s(c){let u=0;const d=6;for(let p=0;pe.maxTextureSize&&(_e=Math.ceil(oe/e.maxTextureSize),oe=e.maxTextureSize);const ve=new Float32Array(oe*_e*4*m),Oe=new Jd(ve,oe,_e,m);Oe.type=gs,Oe.needsUpdate=!0;const He=Q*4;for(let Be=0;Be0)return r;const s=e*t;let o=_A[s];if(o===void 0&&(o=new Float32Array(s),_A[s]=o),e!==0){n.toArray(o,0);for(let a=1,c=0;a!==e;++a)c+=t,r[a].toArray(o,c)}return o}function dl(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t":" "} ${c}: ${t[a]}`)}return n.join(` `)}const AA=new $r;function MU(r){Ki._getMatrix(AA,Ki.workingColorSpace,r);const e=`mat3( ${AA.elements.map(t=>t.toFixed(4))} )`;switch(Ki.getTransfer(r)){case ah:return[e,"LinearTransferOETF"];case Fi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function CA(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),o=(r.getShaderInfoLog(e)||"").trim();if(n&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const c=parseInt(a[1]);return t.toUpperCase()+` `+o+` `+wU(r.getShaderSource(e),c)}else return o}function SU(r,e){const t=MU(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}function TU(r,e){let t;switch(e){case B:t="Linear";break;case ie:t="Reinhard";break;case ct:t="Cineon";break;case Mt:t="ACESFilmic";break;case Yt:t="AgX";break;case en:t="Neutral";break;case ht:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const p_=new ot;function EU(){Ki.getLuminanceCoefficients(p_);const r=p_.x.toFixed(4),e=p_.y.toFixed(4),t=p_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function AU(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Wy).join(` `)}function CU(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function RU(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Ow(r){return r.replace(NU,IU)}const PU=new Map;function IU(r,e){let t=Ns[e];if(t===void 0){const n=PU.get(e);if(n!==void 0)t=Ns[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Ow(t)}const LU=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function PA(r){return r.replace(LU,DU)}function DU(r,e,t,n){let s="";for(let o=parseInt(e);o0&&(z+=` `),I=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Wy).join(` `),I.length>0&&(I+=` `)):(z=[IA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+p:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Wy).join(` `),I=[IA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.envMap?"#define "+p:"",t.envMap?"#define "+m:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==yt?"#define TONE_MAPPING":"",t.toneMapping!==yt?Ns.tonemapping_pars_fragment:"",t.toneMapping!==yt?TU("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ns.colorspace_pars_fragment,SU("linearToOutputTexel",t.outputColorSpace),EU(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Wy).join(` `)),a=Ow(a),a=RA(a,t),a=NA(a,t),c=Ow(c),c=RA(c,t),c=NA(c,t),a=PA(a),c=PA(c),t.isRawShaderMaterial!==!0&&(ee=`#version 300 es `,z=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+z,I=["#define varying in",t.glslVersion===M0?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===M0?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+I);const Q=ee+z+a,oe=ee+I+c,_e=EA(s,s.VERTEX_SHADER,Q),ve=EA(s,s.FRAGMENT_SHADER,oe);s.attachShader(G,_e),s.attachShader(G,ve),t.index0AttributeName!==void 0?s.bindAttribLocation(G,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(G,0,"position"),s.linkProgram(G);function Oe(ft){if(r.debug.checkShaderErrors){const zt=s.getProgramInfoLog(G)||"",tn=s.getShaderInfoLog(_e)||"",cn=s.getShaderInfoLog(ve)||"",vn=zt.trim(),mn=tn.trim(),Yn=cn.trim();let xn=!0,si=!0;if(s.getProgramParameter(G,s.LINK_STATUS)===!1)if(xn=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(s,G,_e,ve);else{const wn=CA(s,_e,"vertex"),Gn=CA(s,ve,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(G,s.VALIDATE_STATUS)+` Material Name: `+ft.name+` Material Type: `+ft.type+` Program Info Log: `+vn+` `+wn+` `+Gn)}else vn!==""?console.warn("THREE.WebGLProgram: Program Info Log:",vn):(mn===""||Yn==="")&&(si=!1);si&&(ft.diagnostics={runnable:xn,programLog:vn,vertexShader:{log:mn,prefix:z},fragmentShader:{log:Yn,prefix:I}})}s.deleteShader(_e),s.deleteShader(ve),He=new f_(s,G),Ce=RU(s,G)}let He;this.getUniforms=function(){return He===void 0&&Oe(this),He};let Ce;this.getAttributes=function(){return Ce===void 0&&Oe(this),Ce};let Be=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Be===!1&&(Be=s.getProgramParameter(G,_U)),Be},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(G),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=bU++,this.cacheKey=e,this.usedTimes=1,this.program=G,this.vertexShader=_e,this.fragmentShader=ve,this}let VU=0;class GU{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(o)===!1&&(a.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new WU(e),t.set(e,n)),n}}class WU{constructor(e){this.id=VU++,this.code=e,this.usedTimes=0}}function HU(r,e,t,n,s,o,a){const c=new er,u=new GU,d=new Set,p=[],m=s.logarithmicDepthBuffer,y=s.vertexTextures;let M=s.precision;const T={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function G(Ce){return d.add(Ce),Ce===0?"uv":`uv${Ce}`}function z(Ce,Be,ft,zt,tn){const cn=zt.fog,vn=tn.geometry,mn=Ce.isMeshStandardMaterial?zt.environment:null,Yn=(Ce.isMeshStandardMaterial?t:e).get(Ce.envMap||mn),xn=Yn&&Yn.mapping===Ke?Yn.image.height:null,si=T[Ce.type];Ce.precision!==null&&(M=s.getMaxPrecision(Ce.precision),M!==Ce.precision&&console.warn("THREE.WebGLProgram.getParameters:",Ce.precision,"not supported, using",M,"instead."));const wn=vn.morphAttributes.position||vn.morphAttributes.normal||vn.morphAttributes.color,Gn=wn!==void 0?wn.length:0;let Si=0;vn.morphAttributes.position!==void 0&&(Si=1),vn.morphAttributes.normal!==void 0&&(Si=2),vn.morphAttributes.color!==void 0&&(Si=3);let nr,ss,Vn,un;if(si){const _o=Ah[si];nr=_o.vertexShader,ss=_o.fragmentShader}else nr=Ce.vertexShader,ss=Ce.fragmentShader,u.update(Ce),Vn=u.getVertexShaderID(Ce),un=u.getFragmentShaderID(Ce);const Mn=r.getRenderTarget(),fi=r.state.buffers.depth.getReversed(),ki=tn.isInstancedMesh===!0,Ni=tn.isBatchedMesh===!0,Cr=!!Ce.map,zs=!!Ce.matcap,Vt=!!Yn,Kn=!!Ce.aoMap,Zn=!!Ce.lightMap,qn=!!Ce.bumpMap,Hn=!!Ce.normalMap,Ti=!!Ce.displacementMap,pi=!!Ce.emissiveMap,Ii=!!Ce.metalnessMap,bs=!!Ce.roughnessMap,ps=Ce.anisotropy>0,St=Ce.clearcoat>0,nt=Ce.dispersion>0,fn=Ce.iridescence>0,Dn=Ce.sheen>0,ri=Ce.transmission>0,zn=ps&&!!Ce.anisotropyMap,Rr=St&&!!Ce.clearcoatMap,Ci=St&&!!Ce.clearcoatNormalMap,Tr=St&&!!Ce.clearcoatRoughnessMap,Er=fn&&!!Ce.iridescenceMap,mi=fn&&!!Ce.iridescenceThicknessMap,Yi=Dn&&!!Ce.sheenColorMap,ts=Dn&&!!Ce.sheenRoughnessMap,Pr=!!Ce.specularMap,Hi=!!Ce.specularColorMap,Rs=!!Ce.specularIntensityMap,rn=ri&&!!Ce.transmissionMap,wi=ri&&!!Ce.thicknessMap,Di=!!Ce.gradientMap,pr=!!Ce.alphaMap,gi=Ce.alphaTest>0,Jn=!!Ce.alphaHash,Ar=!!Ce.extensions;let ws=yt;Ce.toneMapped&&(Mn===null||Mn.isXRRenderTarget===!0)&&(ws=r.toneMapping);const Go={shaderID:si,shaderType:Ce.type,shaderName:Ce.name,vertexShader:nr,fragmentShader:ss,defines:Ce.defines,customVertexShaderID:Vn,customFragmentShaderID:un,isRawShaderMaterial:Ce.isRawShaderMaterial===!0,glslVersion:Ce.glslVersion,precision:M,batching:Ni,batchingColor:Ni&&tn._colorsTexture!==null,instancing:ki,instancingColor:ki&&tn.instanceColor!==null,instancingMorph:ki&&tn.morphTexture!==null,supportsVertexTextures:y,outputColorSpace:Mn===null?r.outputColorSpace:Mn.isXRRenderTarget===!0?Mn.texture.colorSpace:iu,alphaToCoverage:!!Ce.alphaToCoverage,map:Cr,matcap:zs,envMap:Vt,envMapMode:Vt&&Yn.mapping,envMapCubeUVHeight:xn,aoMap:Kn,lightMap:Zn,bumpMap:qn,normalMap:Hn,displacementMap:y&&Ti,emissiveMap:pi,normalMapObjectSpace:Hn&&Ce.normalMapType===jd,normalMapTangentSpace:Hn&&Ce.normalMapType===$a,metalnessMap:Ii,roughnessMap:bs,anisotropy:ps,anisotropyMap:zn,clearcoat:St,clearcoatMap:Rr,clearcoatNormalMap:Ci,clearcoatRoughnessMap:Tr,dispersion:nt,iridescence:fn,iridescenceMap:Er,iridescenceThicknessMap:mi,sheen:Dn,sheenColorMap:Yi,sheenRoughnessMap:ts,specularMap:Pr,specularColorMap:Hi,specularIntensityMap:Rs,transmission:ri,transmissionMap:rn,thicknessMap:wi,gradientMap:Di,opaque:Ce.transparent===!1&&Ce.blending===ge&&Ce.alphaToCoverage===!1,alphaMap:pr,alphaTest:gi,alphaHash:Jn,combine:Ce.combine,mapUv:Cr&&G(Ce.map.channel),aoMapUv:Kn&&G(Ce.aoMap.channel),lightMapUv:Zn&&G(Ce.lightMap.channel),bumpMapUv:qn&&G(Ce.bumpMap.channel),normalMapUv:Hn&&G(Ce.normalMap.channel),displacementMapUv:Ti&&G(Ce.displacementMap.channel),emissiveMapUv:pi&&G(Ce.emissiveMap.channel),metalnessMapUv:Ii&&G(Ce.metalnessMap.channel),roughnessMapUv:bs&&G(Ce.roughnessMap.channel),anisotropyMapUv:zn&&G(Ce.anisotropyMap.channel),clearcoatMapUv:Rr&&G(Ce.clearcoatMap.channel),clearcoatNormalMapUv:Ci&&G(Ce.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Tr&&G(Ce.clearcoatRoughnessMap.channel),iridescenceMapUv:Er&&G(Ce.iridescenceMap.channel),iridescenceThicknessMapUv:mi&&G(Ce.iridescenceThicknessMap.channel),sheenColorMapUv:Yi&&G(Ce.sheenColorMap.channel),sheenRoughnessMapUv:ts&&G(Ce.sheenRoughnessMap.channel),specularMapUv:Pr&&G(Ce.specularMap.channel),specularColorMapUv:Hi&&G(Ce.specularColorMap.channel),specularIntensityMapUv:Rs&&G(Ce.specularIntensityMap.channel),transmissionMapUv:rn&&G(Ce.transmissionMap.channel),thicknessMapUv:wi&&G(Ce.thicknessMap.channel),alphaMapUv:pr&&G(Ce.alphaMap.channel),vertexTangents:!!vn.attributes.tangent&&(Hn||ps),vertexColors:Ce.vertexColors,vertexAlphas:Ce.vertexColors===!0&&!!vn.attributes.color&&vn.attributes.color.itemSize===4,pointsUvs:tn.isPoints===!0&&!!vn.attributes.uv&&(Cr||pr),fog:!!cn,useFog:Ce.fog===!0,fogExp2:!!cn&&cn.isFogExp2,flatShading:Ce.flatShading===!0&&Ce.wireframe===!1,sizeAttenuation:Ce.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:fi,skinning:tn.isSkinnedMesh===!0,morphTargets:vn.morphAttributes.position!==void 0,morphNormals:vn.morphAttributes.normal!==void 0,morphColors:vn.morphAttributes.color!==void 0,morphTargetsCount:Gn,morphTextureStride:Si,numDirLights:Be.directional.length,numPointLights:Be.point.length,numSpotLights:Be.spot.length,numSpotLightMaps:Be.spotLightMap.length,numRectAreaLights:Be.rectArea.length,numHemiLights:Be.hemi.length,numDirLightShadows:Be.directionalShadowMap.length,numPointLightShadows:Be.pointShadowMap.length,numSpotLightShadows:Be.spotShadowMap.length,numSpotLightShadowsWithMaps:Be.numSpotLightShadowsWithMaps,numLightProbes:Be.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:Ce.dithering,shadowMapEnabled:r.shadowMap.enabled&&ft.length>0,shadowMapType:r.shadowMap.type,toneMapping:ws,decodeVideoTexture:Cr&&Ce.map.isVideoTexture===!0&&Ki.getTransfer(Ce.map.colorSpace)===Fi,decodeVideoTextureEmissive:pi&&Ce.emissiveMap.isVideoTexture===!0&&Ki.getTransfer(Ce.emissiveMap.colorSpace)===Fi,premultipliedAlpha:Ce.premultipliedAlpha,doubleSided:Ce.side===re,flipSided:Ce.side===K,useDepthPacking:Ce.depthPacking>=0,depthPacking:Ce.depthPacking||0,index0AttributeName:Ce.index0AttributeName,extensionClipCullDistance:Ar&&Ce.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ar&&Ce.extensions.multiDraw===!0||Ni)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:Ce.customProgramCacheKey()};return Go.vertexUv1s=d.has(1),Go.vertexUv2s=d.has(2),Go.vertexUv3s=d.has(3),d.clear(),Go}function I(Ce){const Be=[];if(Ce.shaderID?Be.push(Ce.shaderID):(Be.push(Ce.customVertexShaderID),Be.push(Ce.customFragmentShaderID)),Ce.defines!==void 0)for(const ft in Ce.defines)Be.push(ft),Be.push(Ce.defines[ft]);return Ce.isRawShaderMaterial===!1&&(ee(Be,Ce),Q(Be,Ce),Be.push(r.outputColorSpace)),Be.push(Ce.customProgramCacheKey),Be.join()}function ee(Ce,Be){Ce.push(Be.precision),Ce.push(Be.outputColorSpace),Ce.push(Be.envMapMode),Ce.push(Be.envMapCubeUVHeight),Ce.push(Be.mapUv),Ce.push(Be.alphaMapUv),Ce.push(Be.lightMapUv),Ce.push(Be.aoMapUv),Ce.push(Be.bumpMapUv),Ce.push(Be.normalMapUv),Ce.push(Be.displacementMapUv),Ce.push(Be.emissiveMapUv),Ce.push(Be.metalnessMapUv),Ce.push(Be.roughnessMapUv),Ce.push(Be.anisotropyMapUv),Ce.push(Be.clearcoatMapUv),Ce.push(Be.clearcoatNormalMapUv),Ce.push(Be.clearcoatRoughnessMapUv),Ce.push(Be.iridescenceMapUv),Ce.push(Be.iridescenceThicknessMapUv),Ce.push(Be.sheenColorMapUv),Ce.push(Be.sheenRoughnessMapUv),Ce.push(Be.specularMapUv),Ce.push(Be.specularColorMapUv),Ce.push(Be.specularIntensityMapUv),Ce.push(Be.transmissionMapUv),Ce.push(Be.thicknessMapUv),Ce.push(Be.combine),Ce.push(Be.fogExp2),Ce.push(Be.sizeAttenuation),Ce.push(Be.morphTargetsCount),Ce.push(Be.morphAttributeCount),Ce.push(Be.numDirLights),Ce.push(Be.numPointLights),Ce.push(Be.numSpotLights),Ce.push(Be.numSpotLightMaps),Ce.push(Be.numHemiLights),Ce.push(Be.numRectAreaLights),Ce.push(Be.numDirLightShadows),Ce.push(Be.numPointLightShadows),Ce.push(Be.numSpotLightShadows),Ce.push(Be.numSpotLightShadowsWithMaps),Ce.push(Be.numLightProbes),Ce.push(Be.shadowMapType),Ce.push(Be.toneMapping),Ce.push(Be.numClippingPlanes),Ce.push(Be.numClipIntersection),Ce.push(Be.depthPacking)}function Q(Ce,Be){c.disableAll(),Be.supportsVertexTextures&&c.enable(0),Be.instancing&&c.enable(1),Be.instancingColor&&c.enable(2),Be.instancingMorph&&c.enable(3),Be.matcap&&c.enable(4),Be.envMap&&c.enable(5),Be.normalMapObjectSpace&&c.enable(6),Be.normalMapTangentSpace&&c.enable(7),Be.clearcoat&&c.enable(8),Be.iridescence&&c.enable(9),Be.alphaTest&&c.enable(10),Be.vertexColors&&c.enable(11),Be.vertexAlphas&&c.enable(12),Be.vertexUv1s&&c.enable(13),Be.vertexUv2s&&c.enable(14),Be.vertexUv3s&&c.enable(15),Be.vertexTangents&&c.enable(16),Be.anisotropy&&c.enable(17),Be.alphaHash&&c.enable(18),Be.batching&&c.enable(19),Be.dispersion&&c.enable(20),Be.batchingColor&&c.enable(21),Be.gradientMap&&c.enable(22),Ce.push(c.mask),c.disableAll(),Be.fog&&c.enable(0),Be.useFog&&c.enable(1),Be.flatShading&&c.enable(2),Be.logarithmicDepthBuffer&&c.enable(3),Be.reversedDepthBuffer&&c.enable(4),Be.skinning&&c.enable(5),Be.morphTargets&&c.enable(6),Be.morphNormals&&c.enable(7),Be.morphColors&&c.enable(8),Be.premultipliedAlpha&&c.enable(9),Be.shadowMapEnabled&&c.enable(10),Be.doubleSided&&c.enable(11),Be.flipSided&&c.enable(12),Be.useDepthPacking&&c.enable(13),Be.dithering&&c.enable(14),Be.transmission&&c.enable(15),Be.sheen&&c.enable(16),Be.opaque&&c.enable(17),Be.pointsUvs&&c.enable(18),Be.decodeVideoTexture&&c.enable(19),Be.decodeVideoTextureEmissive&&c.enable(20),Be.alphaToCoverage&&c.enable(21),Ce.push(c.mask)}function oe(Ce){const Be=T[Ce.type];let ft;if(Be){const zt=Ah[Be];ft=ap.clone(zt.uniforms)}else ft=Ce.uniforms;return ft}function _e(Ce,Be){let ft;for(let zt=0,tn=p.length;zt0?n.push(I):M.transparent===!0?s.push(I):t.push(I)}function u(m,y,M,T,G,z){const I=a(m,y,M,T,G,z);M.transmission>0?n.unshift(I):M.transparent===!0?s.unshift(I):t.unshift(I)}function d(m,y){t.length>1&&t.sort(m||jU),n.length>1&&n.sort(y||LA),s.length>1&&s.sort(y||LA)}function p(){for(let m=e,y=r.length;m=o.length?(a=new DA,o.push(a)):a=o[s],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function qU(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new ot,color:new jn};break;case"SpotLight":t={position:new ot,direction:new ot,color:new jn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ot,color:new jn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ot,skyColor:new jn,groundColor:new jn};break;case"RectAreaLight":t={color:new jn,position:new ot,halfWidth:new ot,halfHeight:new ot};break}return r[e.id]=t,t}}}function YU(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let ZU=0;function KU(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function JU(r){const e=new qU,t=YU(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)n.probe.push(new ot);const s=new ot,o=new Ft,a=new Ft;function c(d){let p=0,m=0,y=0;for(let Ce=0;Ce<9;Ce++)n.probe[Ce].set(0,0,0);let M=0,T=0,G=0,z=0,I=0,ee=0,Q=0,oe=0,_e=0,ve=0,Oe=0;d.sort(KU);for(let Ce=0,Be=d.length;Ce0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=zi.LTC_FLOAT_1,n.rectAreaLTC2=zi.LTC_FLOAT_2):(n.rectAreaLTC1=zi.LTC_HALF_1,n.rectAreaLTC2=zi.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=y;const He=n.hash;(He.directionalLength!==M||He.pointLength!==T||He.spotLength!==G||He.rectAreaLength!==z||He.hemiLength!==I||He.numDirectionalShadows!==ee||He.numPointShadows!==Q||He.numSpotShadows!==oe||He.numSpotMaps!==_e||He.numLightProbes!==Oe)&&(n.directional.length=M,n.spot.length=G,n.rectArea.length=z,n.point.length=T,n.hemi.length=I,n.directionalShadow.length=ee,n.directionalShadowMap.length=ee,n.pointShadow.length=Q,n.pointShadowMap.length=Q,n.spotShadow.length=oe,n.spotShadowMap.length=oe,n.directionalShadowMatrix.length=ee,n.pointShadowMatrix.length=Q,n.spotLightMatrix.length=oe+_e-ve,n.spotLightMap.length=_e,n.numSpotLightShadowsWithMaps=ve,n.numLightProbes=Oe,He.directionalLength=M,He.pointLength=T,He.spotLength=G,He.rectAreaLength=z,He.hemiLength=I,He.numDirectionalShadows=ee,He.numPointShadows=Q,He.numSpotShadows=oe,He.numSpotMaps=_e,He.numLightProbes=Oe,n.version=ZU++)}function u(d,p){let m=0,y=0,M=0,T=0,G=0;const z=p.matrixWorldInverse;for(let I=0,ee=d.length;I=a.length?(c=new OA(r),a.push(c)):c=a[o],c}function n(){e=new WeakMap}return{get:t,dispose:n}}const ek=`void main() { gl_Position = vec4( position, 1.0 ); }`,tk=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function nk(r,e,t){let n=new lf;const s=new yn,o=new yn,a=new mr,c=new Nx({depthPacking:Qf}),u=new Px,d={},p=t.maxTextureSize,m={[W]:K,[K]:W,[re]:re},y=new Bc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new yn},radius:{value:4}},vertexShader:ek,fragmentShader:tk}),M=y.clone();M.defines.HORIZONTAL_PASS=1;const T=new xr;T.setAttribute("position",new Qr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const G=new Zs(T,y),z=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=N;let I=this.type;this.render=function(ve,Oe,He){if(z.enabled===!1||z.autoUpdate===!1&&z.needsUpdate===!1||ve.length===0)return;const Ce=r.getRenderTarget(),Be=r.getActiveCubeFace(),ft=r.getActiveMipmapLevel(),zt=r.state;zt.setBlending(ye),zt.buffers.depth.getReversed()===!0?zt.buffers.color.setClear(0,0,0,0):zt.buffers.color.setClear(1,1,1,1),zt.buffers.depth.setTest(!0),zt.setScissorTest(!1);const tn=I!==P&&this.type===P,cn=I===P&&this.type!==P;for(let vn=0,mn=ve.length;vnp||s.y>p)&&(s.x>p&&(o.x=Math.floor(p/si.x),s.x=o.x*si.x,xn.mapSize.x=o.x),s.y>p&&(o.y=Math.floor(p/si.y),s.y=o.y*si.y,xn.mapSize.y=o.y)),xn.map===null||tn===!0||cn===!0){const Gn=this.type!==P?{minFilter:Ct,magFilter:Ct}:{};xn.map!==null&&xn.map.dispose(),xn.map=new cc(s.x,s.y,Gn),xn.map.texture.name=Yn.name+".shadowMap",xn.camera.updateProjectionMatrix()}r.setRenderTarget(xn.map),r.clear();const wn=xn.getViewportCount();for(let Gn=0;Gn0||Oe.map&&Oe.alphaTest>0||Oe.alphaToCoverage===!0){const zt=Be.uuid,tn=Oe.uuid;let cn=d[zt];cn===void 0&&(cn={},d[zt]=cn);let vn=cn[tn];vn===void 0&&(vn=Be.clone(),cn[tn]=vn,Oe.addEventListener("dispose",_e)),Be=vn}if(Be.visible=Oe.visible,Be.wireframe=Oe.wireframe,Ce===P?Be.side=Oe.shadowSide!==null?Oe.shadowSide:Oe.side:Be.side=Oe.shadowSide!==null?Oe.shadowSide:m[Oe.side],Be.alphaMap=Oe.alphaMap,Be.alphaTest=Oe.alphaToCoverage===!0?.5:Oe.alphaTest,Be.map=Oe.map,Be.clipShadows=Oe.clipShadows,Be.clippingPlanes=Oe.clippingPlanes,Be.clipIntersection=Oe.clipIntersection,Be.displacementMap=Oe.displacementMap,Be.displacementScale=Oe.displacementScale,Be.displacementBias=Oe.displacementBias,Be.wireframeLinewidth=Oe.wireframeLinewidth,Be.linewidth=Oe.linewidth,He.isPointLight===!0&&Be.isMeshDistanceMaterial===!0){const zt=r.properties.get(Be);zt.light=He}return Be}function oe(ve,Oe,He,Ce,Be){if(ve.visible===!1)return;if(ve.layers.test(Oe.layers)&&(ve.isMesh||ve.isLine||ve.isPoints)&&(ve.castShadow||ve.receiveShadow&&Be===P)&&(!ve.frustumCulled||n.intersectsObject(ve))){ve.modelViewMatrix.multiplyMatrices(He.matrixWorldInverse,ve.matrixWorld);const tn=e.update(ve),cn=ve.material;if(Array.isArray(cn)){const vn=tn.groups;for(let mn=0,Yn=vn.length;mn=1):xn.indexOf("OpenGL ES")!==-1&&(Yn=parseFloat(/^OpenGL ES (\d)/.exec(xn)[1]),mn=Yn>=2);let si=null,wn={};const Gn=r.getParameter(r.SCISSOR_BOX),Si=r.getParameter(r.VIEWPORT),nr=new mr().fromArray(Gn),ss=new mr().fromArray(Si);function Vn(rn,wi,Di,pr){const gi=new Uint8Array(4),Jn=r.createTexture();r.bindTexture(rn,Jn),r.texParameteri(rn,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(rn,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ar=0;Arfn||ri.height>fn)&&(Dn=fn/Math.max(ri.width,ri.height)),Dn<1)if(typeof HTMLImageElement!="undefined"&&St instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&St instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&St instanceof ImageBitmap||typeof VideoFrame!="undefined"&&St instanceof VideoFrame){const zn=Math.floor(Dn*ri.width),Rr=Math.floor(Dn*ri.height);m===void 0&&(m=T(zn,Rr));const Ci=nt?T(zn,Rr):m;return Ci.width=zn,Ci.height=Rr,Ci.getContext("2d").drawImage(St,0,0,zn,Rr),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ri.width+"x"+ri.height+") to ("+zn+"x"+Rr+")."),Ci}else return"data"in St&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ri.width+"x"+ri.height+")."),St;return St}function z(St){return St.generateMipmaps}function I(St){r.generateMipmap(St)}function ee(St){return St.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:St.isWebGL3DRenderTarget?r.TEXTURE_3D:St.isWebGLArrayRenderTarget||St.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function Q(St,nt,fn,Dn,ri=!1){if(St!==null){if(r[St]!==void 0)return r[St];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+St+"'")}let zn=nt;if(nt===r.RED&&(fn===r.FLOAT&&(zn=r.R32F),fn===r.HALF_FLOAT&&(zn=r.R16F),fn===r.UNSIGNED_BYTE&&(zn=r.R8)),nt===r.RED_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.R8UI),fn===r.UNSIGNED_SHORT&&(zn=r.R16UI),fn===r.UNSIGNED_INT&&(zn=r.R32UI),fn===r.BYTE&&(zn=r.R8I),fn===r.SHORT&&(zn=r.R16I),fn===r.INT&&(zn=r.R32I)),nt===r.RG&&(fn===r.FLOAT&&(zn=r.RG32F),fn===r.HALF_FLOAT&&(zn=r.RG16F),fn===r.UNSIGNED_BYTE&&(zn=r.RG8)),nt===r.RG_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RG8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RG16UI),fn===r.UNSIGNED_INT&&(zn=r.RG32UI),fn===r.BYTE&&(zn=r.RG8I),fn===r.SHORT&&(zn=r.RG16I),fn===r.INT&&(zn=r.RG32I)),nt===r.RGB_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RGB8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RGB16UI),fn===r.UNSIGNED_INT&&(zn=r.RGB32UI),fn===r.BYTE&&(zn=r.RGB8I),fn===r.SHORT&&(zn=r.RGB16I),fn===r.INT&&(zn=r.RGB32I)),nt===r.RGBA_INTEGER&&(fn===r.UNSIGNED_BYTE&&(zn=r.RGBA8UI),fn===r.UNSIGNED_SHORT&&(zn=r.RGBA16UI),fn===r.UNSIGNED_INT&&(zn=r.RGBA32UI),fn===r.BYTE&&(zn=r.RGBA8I),fn===r.SHORT&&(zn=r.RGBA16I),fn===r.INT&&(zn=r.RGBA32I)),nt===r.RGB&&(fn===r.UNSIGNED_INT_5_9_9_9_REV&&(zn=r.RGB9_E5),fn===r.UNSIGNED_INT_10F_11F_11F_REV&&(zn=r.R11F_G11F_B10F)),nt===r.RGBA){const Rr=ri?ah:Ki.getTransfer(Dn);fn===r.FLOAT&&(zn=r.RGBA32F),fn===r.HALF_FLOAT&&(zn=r.RGBA16F),fn===r.UNSIGNED_BYTE&&(zn=Rr===Fi?r.SRGB8_ALPHA8:r.RGBA8),fn===r.UNSIGNED_SHORT_4_4_4_4&&(zn=r.RGBA4),fn===r.UNSIGNED_SHORT_5_5_5_1&&(zn=r.RGB5_A1)}return(zn===r.R16F||zn===r.R32F||zn===r.RG16F||zn===r.RG32F||zn===r.RGBA16F||zn===r.RGBA32F)&&e.get("EXT_color_buffer_float"),zn}function oe(St,nt){let fn;return St?nt===null||nt===as||nt===Da?fn=r.DEPTH24_STENCIL8:nt===gs?fn=r.DEPTH32F_STENCIL8:nt===ms&&(fn=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):nt===null||nt===as||nt===Da?fn=r.DEPTH_COMPONENT24:nt===gs?fn=r.DEPTH_COMPONENT32F:nt===ms&&(fn=r.DEPTH_COMPONENT16),fn}function _e(St,nt){return z(St)===!0||St.isFramebufferTexture&&St.minFilter!==Ct&&St.minFilter!==Rn?Math.log2(Math.max(nt.width,nt.height))+1:St.mipmaps!==void 0&&St.mipmaps.length>0?St.mipmaps.length:St.isCompressedTexture&&Array.isArray(St.image)?nt.mipmaps.length:1}function ve(St){const nt=St.target;nt.removeEventListener("dispose",ve),He(nt),nt.isVideoTexture&&p.delete(nt)}function Oe(St){const nt=St.target;nt.removeEventListener("dispose",Oe),Be(nt)}function He(St){const nt=n.get(St);if(nt.__webglInit===void 0)return;const fn=St.source,Dn=y.get(fn);if(Dn){const ri=Dn[nt.__cacheKey];ri.usedTimes--,ri.usedTimes===0&&Ce(St),Object.keys(Dn).length===0&&y.delete(fn)}n.remove(St)}function Ce(St){const nt=n.get(St);r.deleteTexture(nt.__webglTexture);const fn=St.source,Dn=y.get(fn);delete Dn[nt.__cacheKey],a.memory.textures--}function Be(St){const nt=n.get(St);if(St.depthTexture&&(St.depthTexture.dispose(),n.remove(St.depthTexture)),St.isWebGLCubeRenderTarget)for(let Dn=0;Dn<6;Dn++){if(Array.isArray(nt.__webglFramebuffer[Dn]))for(let ri=0;ri=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+St+" texture units while this GPU supports only "+s.maxTextures),ft+=1,St}function cn(St){const nt=[];return nt.push(St.wrapS),nt.push(St.wrapT),nt.push(St.wrapR||0),nt.push(St.magFilter),nt.push(St.minFilter),nt.push(St.anisotropy),nt.push(St.internalFormat),nt.push(St.format),nt.push(St.type),nt.push(St.generateMipmaps),nt.push(St.premultiplyAlpha),nt.push(St.flipY),nt.push(St.unpackAlignment),nt.push(St.colorSpace),nt.join()}function vn(St,nt){const fn=n.get(St);if(St.isVideoTexture&&Ii(St),St.isRenderTargetTexture===!1&&St.isExternalTexture!==!0&&St.version>0&&fn.__version!==St.version){const Dn=St.image;if(Dn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Dn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{un(fn,St,nt);return}}else St.isExternalTexture&&(fn.__webglTexture=St.sourceTexture?St.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,fn.__webglTexture,r.TEXTURE0+nt)}function mn(St,nt){const fn=n.get(St);if(St.isRenderTargetTexture===!1&&St.version>0&&fn.__version!==St.version){un(fn,St,nt);return}t.bindTexture(r.TEXTURE_2D_ARRAY,fn.__webglTexture,r.TEXTURE0+nt)}function Yn(St,nt){const fn=n.get(St);if(St.isRenderTargetTexture===!1&&St.version>0&&fn.__version!==St.version){un(fn,St,nt);return}t.bindTexture(r.TEXTURE_3D,fn.__webglTexture,r.TEXTURE0+nt)}function xn(St,nt){const fn=n.get(St);if(St.version>0&&fn.__version!==St.version){Mn(fn,St,nt);return}t.bindTexture(r.TEXTURE_CUBE_MAP,fn.__webglTexture,r.TEXTURE0+nt)}const si={[lt]:r.REPEAT,[qe]:r.CLAMP_TO_EDGE,[pt]:r.MIRRORED_REPEAT},wn={[Ct]:r.NEAREST,[Xt]:r.NEAREST_MIPMAP_NEAREST,[pn]:r.NEAREST_MIPMAP_LINEAR,[Rn]:r.LINEAR,[bi]:r.LINEAR_MIPMAP_NEAREST,[Qn]:r.LINEAR_MIPMAP_LINEAR},Gn={[Lm]:r.NEVER,[Dm]:r.ALWAYS,[qd]:r.LESS,[ep]:r.LEQUAL,[Yd]:r.EQUAL,[w0]:r.GEQUAL,[_0]:r.GREATER,[b0]:r.NOTEQUAL};function Si(St,nt){if(nt.type===gs&&e.has("OES_texture_float_linear")===!1&&(nt.magFilter===Rn||nt.magFilter===bi||nt.magFilter===pn||nt.magFilter===Qn||nt.minFilter===Rn||nt.minFilter===bi||nt.minFilter===pn||nt.minFilter===Qn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(St,r.TEXTURE_WRAP_S,si[nt.wrapS]),r.texParameteri(St,r.TEXTURE_WRAP_T,si[nt.wrapT]),(St===r.TEXTURE_3D||St===r.TEXTURE_2D_ARRAY)&&r.texParameteri(St,r.TEXTURE_WRAP_R,si[nt.wrapR]),r.texParameteri(St,r.TEXTURE_MAG_FILTER,wn[nt.magFilter]),r.texParameteri(St,r.TEXTURE_MIN_FILTER,wn[nt.minFilter]),nt.compareFunction&&(r.texParameteri(St,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(St,r.TEXTURE_COMPARE_FUNC,Gn[nt.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(nt.magFilter===Ct||nt.minFilter!==pn&&nt.minFilter!==Qn||nt.type===gs&&e.has("OES_texture_float_linear")===!1)return;if(nt.anisotropy>1||n.get(nt).__currentAnisotropy){const fn=e.get("EXT_texture_filter_anisotropic");r.texParameterf(St,fn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(nt.anisotropy,s.getMaxAnisotropy())),n.get(nt).__currentAnisotropy=nt.anisotropy}}}function nr(St,nt){let fn=!1;St.__webglInit===void 0&&(St.__webglInit=!0,nt.addEventListener("dispose",ve));const Dn=nt.source;let ri=y.get(Dn);ri===void 0&&(ri={},y.set(Dn,ri));const zn=cn(nt);if(zn!==St.__cacheKey){ri[zn]===void 0&&(ri[zn]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,fn=!0),ri[zn].usedTimes++;const Rr=ri[St.__cacheKey];Rr!==void 0&&(ri[St.__cacheKey].usedTimes--,Rr.usedTimes===0&&Ce(nt)),St.__cacheKey=zn,St.__webglTexture=ri[zn].texture}return fn}function ss(St,nt,fn){return Math.floor(Math.floor(St/fn)/nt)}function Vn(St,nt,fn,Dn){const zn=St.updateRanges;if(zn.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,nt.width,nt.height,fn,Dn,nt.data);else{zn.sort((mi,Yi)=>mi.start-Yi.start);let Rr=0;for(let mi=1;mi0){rn&&wi&&t.texStorage2D(r.TEXTURE_2D,pr,Pr,Rs[0].width,Rs[0].height);for(let gi=0,Jn=Rs.length;gi0){const Ar=Oy(Hi.width,Hi.height,nt.format,nt.type);for(const ws of nt.layerUpdates){const Go=Hi.data.subarray(ws*Ar/Hi.data.BYTES_PER_ELEMENT,(ws+1)*Ar/Hi.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,gi,0,0,ws,Hi.width,Hi.height,1,Yi,Go)}nt.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,Hi.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,gi,Pr,Hi.width,Hi.height,mi.depth,0,Hi.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else rn?Di&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,gi,0,0,0,Hi.width,Hi.height,mi.depth,Yi,ts,Hi.data):t.texImage3D(r.TEXTURE_2D_ARRAY,gi,Pr,Hi.width,Hi.height,mi.depth,0,Yi,ts,Hi.data)}else{rn&&wi&&t.texStorage2D(r.TEXTURE_2D,pr,Pr,Rs[0].width,Rs[0].height);for(let gi=0,Jn=Rs.length;gi0){const gi=Oy(mi.width,mi.height,nt.format,nt.type);for(const Jn of nt.layerUpdates){const Ar=mi.data.subarray(Jn*gi/mi.data.BYTES_PER_ELEMENT,(Jn+1)*gi/mi.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Jn,mi.width,mi.height,1,Yi,ts,Ar)}nt.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ts,mi.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,Pr,mi.width,mi.height,mi.depth,0,Yi,ts,mi.data);else if(nt.isData3DTexture)rn?(wi&&t.texStorage3D(r.TEXTURE_3D,pr,Pr,mi.width,mi.height,mi.depth),Di&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,mi.width,mi.height,mi.depth,Yi,ts,mi.data)):t.texImage3D(r.TEXTURE_3D,0,Pr,mi.width,mi.height,mi.depth,0,Yi,ts,mi.data);else if(nt.isFramebufferTexture){if(wi)if(rn)t.texStorage2D(r.TEXTURE_2D,pr,Pr,mi.width,mi.height);else{let gi=mi.width,Jn=mi.height;for(let Ar=0;Ar>=1,Jn>>=1}}else if(Rs.length>0){if(rn&&wi){const gi=ps(Rs[0]);t.texStorage2D(r.TEXTURE_2D,pr,Pr,gi.width,gi.height)}for(let gi=0,Jn=Rs.length;gi0&&pr++;const Jn=ps(Yi[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,pr,Rs,Jn.width,Jn.height)}for(let Jn=0;Jn<6;Jn++)if(mi){rn?Di&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,0,0,Yi[Jn].width,Yi[Jn].height,Pr,Hi,Yi[Jn].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Jn,0,Rs,Yi[Jn].width,Yi[Jn].height,0,Pr,Hi,Yi[Jn].data);for(let Ar=0;Ar>zn),ts=Math.max(1,nt.height>>zn);ri===r.TEXTURE_3D||ri===r.TEXTURE_2D_ARRAY?t.texImage3D(ri,zn,Tr,Yi,ts,nt.depth,0,Rr,Ci,null):t.texImage2D(ri,zn,Tr,Yi,ts,0,Rr,Ci,null)}t.bindFramebuffer(r.FRAMEBUFFER,St),pi(nt)?c.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Dn,ri,mi.__webglTexture,0,Ti(nt)):(ri===r.TEXTURE_2D||ri>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ri<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Dn,ri,mi.__webglTexture,zn),t.bindFramebuffer(r.FRAMEBUFFER,null)}function ki(St,nt,fn){if(r.bindRenderbuffer(r.RENDERBUFFER,St),nt.depthBuffer){const Dn=nt.depthTexture,ri=Dn&&Dn.isDepthTexture?Dn.type:null,zn=oe(nt.stencilBuffer,ri),Rr=nt.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ci=Ti(nt);pi(nt)?c.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ci,zn,nt.width,nt.height):fn?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ci,zn,nt.width,nt.height):r.renderbufferStorage(r.RENDERBUFFER,zn,nt.width,nt.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Rr,r.RENDERBUFFER,St)}else{const Dn=nt.textures;for(let ri=0;ri{delete nt.__boundDepthTexture,delete nt.__depthDisposeCallback,Dn.removeEventListener("dispose",ri)};Dn.addEventListener("dispose",ri),nt.__depthDisposeCallback=ri}nt.__boundDepthTexture=Dn}if(St.depthTexture&&!nt.__autoAllocateDepthBuffer){if(fn)throw new Error("target.depthTexture not supported in Cube render targets");const Dn=St.texture.mipmaps;Dn&&Dn.length>0?Ni(nt.__webglFramebuffer[0],St):Ni(nt.__webglFramebuffer,St)}else if(fn){nt.__webglDepthbuffer=[];for(let Dn=0;Dn<6;Dn++)if(t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer[Dn]),nt.__webglDepthbuffer[Dn]===void 0)nt.__webglDepthbuffer[Dn]=r.createRenderbuffer(),ki(nt.__webglDepthbuffer[Dn],St,!1);else{const ri=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,zn=nt.__webglDepthbuffer[Dn];r.bindRenderbuffer(r.RENDERBUFFER,zn),r.framebufferRenderbuffer(r.FRAMEBUFFER,ri,r.RENDERBUFFER,zn)}}else{const Dn=St.texture.mipmaps;if(Dn&&Dn.length>0?t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,nt.__webglFramebuffer),nt.__webglDepthbuffer===void 0)nt.__webglDepthbuffer=r.createRenderbuffer(),ki(nt.__webglDepthbuffer,St,!1);else{const ri=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,zn=nt.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,zn),r.framebufferRenderbuffer(r.FRAMEBUFFER,ri,r.RENDERBUFFER,zn)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function zs(St,nt,fn){const Dn=n.get(St);nt!==void 0&&fi(Dn.__webglFramebuffer,St,St.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),fn!==void 0&&Cr(St)}function Vt(St){const nt=St.texture,fn=n.get(St),Dn=n.get(nt);St.addEventListener("dispose",Oe);const ri=St.textures,zn=St.isWebGLCubeRenderTarget===!0,Rr=ri.length>1;if(Rr||(Dn.__webglTexture===void 0&&(Dn.__webglTexture=r.createTexture()),Dn.__version=nt.version,a.memory.textures++),zn){fn.__webglFramebuffer=[];for(let Ci=0;Ci<6;Ci++)if(nt.mipmaps&&nt.mipmaps.length>0){fn.__webglFramebuffer[Ci]=[];for(let Tr=0;Tr0){fn.__webglFramebuffer=[];for(let Ci=0;Ci0&&pi(St)===!1){fn.__webglMultisampledFramebuffer=r.createFramebuffer(),fn.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,fn.__webglMultisampledFramebuffer);for(let Ci=0;Ci0)for(let Tr=0;Tr0)for(let Tr=0;Tr0){if(pi(St)===!1){const nt=St.textures,fn=St.width,Dn=St.height;let ri=r.COLOR_BUFFER_BIT;const zn=St.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Rr=n.get(St),Ci=nt.length>1;if(Ci)for(let Er=0;Er0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Rr.__webglFramebuffer);for(let Er=0;Er0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&nt.__useRenderToTexture!==!1}function Ii(St){const nt=a.render.frame;p.get(St)!==nt&&(p.set(St,nt),St.update())}function bs(St,nt){const fn=St.colorSpace,Dn=St.format,ri=St.type;return St.isCompressedTexture===!0||St.isVideoTexture===!0||fn!==iu&&fn!==Qo&&(Ki.getTransfer(fn)===Fi?(Dn!==D||ri!==Oi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",fn)),nt}function ps(St){return typeof HTMLImageElement!="undefined"&&St instanceof HTMLImageElement?(d.width=St.naturalWidth||St.width,d.height=St.naturalHeight||St.height):typeof VideoFrame!="undefined"&&St instanceof VideoFrame?(d.width=St.displayWidth,d.height=St.displayHeight):(d.width=St.width,d.height=St.height),d}this.allocateTextureUnit=tn,this.resetTextureUnits=zt,this.setTexture2D=vn,this.setTexture2DArray=mn,this.setTexture3D=Yn,this.setTextureCube=xn,this.rebindTextures=zs,this.setupRenderTarget=Vt,this.updateRenderTargetMipmap=Kn,this.updateMultisampleRenderTarget=Hn,this.setupDepthRenderbuffer=Cr,this.setupFrameBufferTexture=fi,this.useMultisampledRTT=pi}function ok(r,e){function t(n,s=Qo){let o;const a=Ki.getTransfer(s);if(n===Oi)return r.UNSIGNED_BYTE;if(n===Xl)return r.UNSIGNED_SHORT_4_4_4_4;if(n===ql)return r.UNSIGNED_SHORT_5_5_5_1;if(n===Dl)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===nu)return r.UNSIGNED_INT_10F_11F_11F_REV;if(n===Gi)return r.BYTE;if(n===ir)return r.SHORT;if(n===ms)return r.UNSIGNED_SHORT;if(n===Is)return r.INT;if(n===as)return r.UNSIGNED_INT;if(n===gs)return r.FLOAT;if(n===Vs)return r.HALF_FLOAT;if(n===Du)return r.ALPHA;if(n===Le)return r.RGB;if(n===D)return r.RGBA;if(n===U)return r.DEPTH_COMPONENT;if(n===_)return r.DEPTH_STENCIL;if(n===F)return r.RED;if(n===X)return r.RED_INTEGER;if(n===De)return r.RG;if(n===Ve)return r.RG_INTEGER;if(n===st)return r.RGBA_INTEGER;if(n===Ht||n===Et||n===on||n===Un)if(a===Fi)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Ht)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Et)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===on)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Un)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Ht)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Et)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===on)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Un)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===sn||n===bn||n===ti||n===Bt)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===sn)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===bn)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ti)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Bt)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===$n||n===ni||n===Pi)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===$n||n===ni)return a===Fi?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Pi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ui||n===Ir||n===yi||n===vi||n===Mr||n===Zt||n===Fn||n===hi||n===Xn||n===hs||n===Xr||n===ys||n===Ur||n===Os)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===ui)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ir)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===yi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Mr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Zt)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===hi)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Xn)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===hs)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Xr)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ys)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ur)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Os)return a===Fi?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===no||n===io||n===So)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===no)return a===Fi?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===io)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===So)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===To||n===Gr||n===Qs||n===Eo)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===To)return o.COMPRESSED_RED_RGTC1_EXT;if(n===Gr)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Qs)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Eo)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Da?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const ak=` void main() { gl_Position = vec4( position, 1.0 ); }`,lk=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class ck{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new y1(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Bc({vertexShader:ak,fragmentShader:lk,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Zs(new Mh(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class uk extends Ol{constructor(e,t){super();const n=this;let s=null,o=1,a=null,c="local-floor",u=1,d=null,p=null,m=null,y=null,M=null,T=null;const G=typeof XRWebGLBinding!="undefined",z=new ck,I={},ee=t.getContextAttributes();let Q=null,oe=null;const _e=[],ve=[],Oe=new yn;let He=null;const Ce=new fa;Ce.viewport=new mr;const Be=new fa;Be.viewport=new mr;const ft=[Ce,Be],zt=new wy;let tn=null,cn=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getTargetRaySpace()},this.getControllerGrip=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getGripSpace()},this.getHand=function(un){let Mn=_e[un];return Mn===void 0&&(Mn=new Gu,_e[un]=Mn),Mn.getHandSpace()};function vn(un){const Mn=ve.indexOf(un.inputSource);if(Mn===-1)return;const fi=_e[Mn];fi!==void 0&&(fi.update(un.inputSource,un.frame,d||a),fi.dispatchEvent({type:un.type,data:un.inputSource}))}function mn(){s.removeEventListener("select",vn),s.removeEventListener("selectstart",vn),s.removeEventListener("selectend",vn),s.removeEventListener("squeeze",vn),s.removeEventListener("squeezestart",vn),s.removeEventListener("squeezeend",vn),s.removeEventListener("end",mn),s.removeEventListener("inputsourceschange",Yn);for(let un=0;un<_e.length;un++){const Mn=ve[un];Mn!==null&&(ve[un]=null,_e[un].disconnect(Mn))}tn=null,cn=null,z.reset();for(const un in I)delete I[un];e.setRenderTarget(Q),M=null,y=null,m=null,s=null,oe=null,Vn.stop(),n.isPresenting=!1,e.setPixelRatio(He),e.setSize(Oe.width,Oe.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(un){o=un,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(un){c=un,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||a},this.setReferenceSpace=function(un){d=un},this.getBaseLayer=function(){return y!==null?y:M},this.getBinding=function(){return m===null&&G&&(m=new XRWebGLBinding(s,t)),m},this.getFrame=function(){return T},this.getSession=function(){return s},this.setSession=function(un){return hr(this,null,function*(){if(s=un,s!==null){if(Q=e.getRenderTarget(),s.addEventListener("select",vn),s.addEventListener("selectstart",vn),s.addEventListener("selectend",vn),s.addEventListener("squeeze",vn),s.addEventListener("squeezestart",vn),s.addEventListener("squeezeend",vn),s.addEventListener("end",mn),s.addEventListener("inputsourceschange",Yn),ee.xrCompatible!==!0&&(yield t.makeXRCompatible()),He=e.getPixelRatio(),e.getSize(Oe),G&&"createProjectionLayer"in XRWebGLBinding.prototype){let fi=null,ki=null,Ni=null;ee.depth&&(Ni=ee.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fi=ee.stencil?_:U,ki=ee.stencil?Da:as);const Cr={colorFormat:t.RGBA8,depthFormat:Ni,scaleFactor:o};m=this.getBinding(),y=m.createProjectionLayer(Cr),s.updateRenderState({layers:[y]}),e.setPixelRatio(1),e.setSize(y.textureWidth,y.textureHeight,!1),oe=new cc(y.textureWidth,y.textureHeight,{format:D,type:Oi,depthTexture:new gc(y.textureWidth,y.textureHeight,ki,void 0,void 0,void 0,void 0,void 0,void 0,fi),stencilBuffer:ee.stencil,colorSpace:e.outputColorSpace,samples:ee.antialias?4:0,resolveDepthBuffer:y.ignoreDepthValues===!1,resolveStencilBuffer:y.ignoreDepthValues===!1})}else{const fi={antialias:ee.antialias,alpha:!0,depth:ee.depth,stencil:ee.stencil,framebufferScaleFactor:o};M=new XRWebGLLayer(s,t,fi),s.updateRenderState({baseLayer:M}),e.setPixelRatio(1),e.setSize(M.framebufferWidth,M.framebufferHeight,!1),oe=new cc(M.framebufferWidth,M.framebufferHeight,{format:D,type:Oi,colorSpace:e.outputColorSpace,stencilBuffer:ee.stencil,resolveDepthBuffer:M.ignoreDepthValues===!1,resolveStencilBuffer:M.ignoreDepthValues===!1})}oe.isXRRenderTarget=!0,this.setFoveation(u),d=null,a=yield s.requestReferenceSpace(c),Vn.setContext(s),Vn.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return z.getDepthTexture()};function Yn(un){for(let Mn=0;Mn=0&&(ve[ki]=null,_e[ki].disconnect(fi))}for(let Mn=0;Mn=ve.length){ve.push(fi),ki=Cr;break}else if(ve[Cr]===null){ve[Cr]=fi,ki=Cr;break}if(ki===-1)break}const Ni=_e[ki];Ni&&Ni.connect(fi)}}const xn=new ot,si=new ot;function wn(un,Mn,fi){xn.setFromMatrixPosition(Mn.matrixWorld),si.setFromMatrixPosition(fi.matrixWorld);const ki=xn.distanceTo(si),Ni=Mn.projectionMatrix.elements,Cr=fi.projectionMatrix.elements,zs=Ni[14]/(Ni[10]-1),Vt=Ni[14]/(Ni[10]+1),Kn=(Ni[9]+1)/Ni[5],Zn=(Ni[9]-1)/Ni[5],qn=(Ni[8]-1)/Ni[0],Hn=(Cr[8]+1)/Cr[0],Ti=zs*qn,pi=zs*Hn,Ii=ki/(-qn+Hn),bs=Ii*-qn;if(Mn.matrixWorld.decompose(un.position,un.quaternion,un.scale),un.translateX(bs),un.translateZ(Ii),un.matrixWorld.compose(un.position,un.quaternion,un.scale),un.matrixWorldInverse.copy(un.matrixWorld).invert(),Ni[10]===-1)un.projectionMatrix.copy(Mn.projectionMatrix),un.projectionMatrixInverse.copy(Mn.projectionMatrixInverse);else{const ps=zs+Ii,St=Vt+Ii,nt=Ti-bs,fn=pi+(ki-bs),Dn=Kn*Vt/St*ps,ri=Zn*Vt/St*ps;un.projectionMatrix.makePerspective(nt,fn,Dn,ri,ps,St),un.projectionMatrixInverse.copy(un.projectionMatrix).invert()}}function Gn(un,Mn){Mn===null?un.matrixWorld.copy(un.matrix):un.matrixWorld.multiplyMatrices(Mn.matrixWorld,un.matrix),un.matrixWorldInverse.copy(un.matrixWorld).invert()}this.updateCamera=function(un){if(s===null)return;let Mn=un.near,fi=un.far;z.texture!==null&&(z.depthNear>0&&(Mn=z.depthNear),z.depthFar>0&&(fi=z.depthFar)),zt.near=Be.near=Ce.near=Mn,zt.far=Be.far=Ce.far=fi,(tn!==zt.near||cn!==zt.far)&&(s.updateRenderState({depthNear:zt.near,depthFar:zt.far}),tn=zt.near,cn=zt.far),zt.layers.mask=un.layers.mask|6,Ce.layers.mask=zt.layers.mask&3,Be.layers.mask=zt.layers.mask&5;const ki=un.parent,Ni=zt.cameras;Gn(zt,ki);for(let Cr=0;Cr0&&(z.alphaTest.value=I.alphaTest);const ee=e.get(I),Q=ee.envMap,oe=ee.envMapRotation;Q&&(z.envMap.value=Q,em.copy(oe),em.x*=-1,em.y*=-1,em.z*=-1,Q.isCubeTexture&&Q.isRenderTargetTexture===!1&&(em.y*=-1,em.z*=-1),z.envMapRotation.value.setFromMatrix4(hk.makeRotationFromEuler(em)),z.flipEnvMap.value=Q.isCubeTexture&&Q.isRenderTargetTexture===!1?-1:1,z.reflectivity.value=I.reflectivity,z.ior.value=I.ior,z.refractionRatio.value=I.refractionRatio),I.lightMap&&(z.lightMap.value=I.lightMap,z.lightMapIntensity.value=I.lightMapIntensity,t(I.lightMap,z.lightMapTransform)),I.aoMap&&(z.aoMap.value=I.aoMap,z.aoMapIntensity.value=I.aoMapIntensity,t(I.aoMap,z.aoMapTransform))}function a(z,I){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,I.map&&(z.map.value=I.map,t(I.map,z.mapTransform))}function c(z,I){z.dashSize.value=I.dashSize,z.totalSize.value=I.dashSize+I.gapSize,z.scale.value=I.scale}function u(z,I,ee,Q){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,z.size.value=I.size*ee,z.scale.value=Q*.5,I.map&&(z.map.value=I.map,t(I.map,z.uvTransform)),I.alphaMap&&(z.alphaMap.value=I.alphaMap,t(I.alphaMap,z.alphaMapTransform)),I.alphaTest>0&&(z.alphaTest.value=I.alphaTest)}function d(z,I){z.diffuse.value.copy(I.color),z.opacity.value=I.opacity,z.rotation.value=I.rotation,I.map&&(z.map.value=I.map,t(I.map,z.mapTransform)),I.alphaMap&&(z.alphaMap.value=I.alphaMap,t(I.alphaMap,z.alphaMapTransform)),I.alphaTest>0&&(z.alphaTest.value=I.alphaTest)}function p(z,I){z.specular.value.copy(I.specular),z.shininess.value=Math.max(I.shininess,1e-4)}function m(z,I){I.gradientMap&&(z.gradientMap.value=I.gradientMap)}function y(z,I){z.metalness.value=I.metalness,I.metalnessMap&&(z.metalnessMap.value=I.metalnessMap,t(I.metalnessMap,z.metalnessMapTransform)),z.roughness.value=I.roughness,I.roughnessMap&&(z.roughnessMap.value=I.roughnessMap,t(I.roughnessMap,z.roughnessMapTransform)),I.envMap&&(z.envMapIntensity.value=I.envMapIntensity)}function M(z,I,ee){z.ior.value=I.ior,I.sheen>0&&(z.sheenColor.value.copy(I.sheenColor).multiplyScalar(I.sheen),z.sheenRoughness.value=I.sheenRoughness,I.sheenColorMap&&(z.sheenColorMap.value=I.sheenColorMap,t(I.sheenColorMap,z.sheenColorMapTransform)),I.sheenRoughnessMap&&(z.sheenRoughnessMap.value=I.sheenRoughnessMap,t(I.sheenRoughnessMap,z.sheenRoughnessMapTransform))),I.clearcoat>0&&(z.clearcoat.value=I.clearcoat,z.clearcoatRoughness.value=I.clearcoatRoughness,I.clearcoatMap&&(z.clearcoatMap.value=I.clearcoatMap,t(I.clearcoatMap,z.clearcoatMapTransform)),I.clearcoatRoughnessMap&&(z.clearcoatRoughnessMap.value=I.clearcoatRoughnessMap,t(I.clearcoatRoughnessMap,z.clearcoatRoughnessMapTransform)),I.clearcoatNormalMap&&(z.clearcoatNormalMap.value=I.clearcoatNormalMap,t(I.clearcoatNormalMap,z.clearcoatNormalMapTransform),z.clearcoatNormalScale.value.copy(I.clearcoatNormalScale),I.side===K&&z.clearcoatNormalScale.value.negate())),I.dispersion>0&&(z.dispersion.value=I.dispersion),I.iridescence>0&&(z.iridescence.value=I.iridescence,z.iridescenceIOR.value=I.iridescenceIOR,z.iridescenceThicknessMinimum.value=I.iridescenceThicknessRange[0],z.iridescenceThicknessMaximum.value=I.iridescenceThicknessRange[1],I.iridescenceMap&&(z.iridescenceMap.value=I.iridescenceMap,t(I.iridescenceMap,z.iridescenceMapTransform)),I.iridescenceThicknessMap&&(z.iridescenceThicknessMap.value=I.iridescenceThicknessMap,t(I.iridescenceThicknessMap,z.iridescenceThicknessMapTransform))),I.transmission>0&&(z.transmission.value=I.transmission,z.transmissionSamplerMap.value=ee.texture,z.transmissionSamplerSize.value.set(ee.width,ee.height),I.transmissionMap&&(z.transmissionMap.value=I.transmissionMap,t(I.transmissionMap,z.transmissionMapTransform)),z.thickness.value=I.thickness,I.thicknessMap&&(z.thicknessMap.value=I.thicknessMap,t(I.thicknessMap,z.thicknessMapTransform)),z.attenuationDistance.value=I.attenuationDistance,z.attenuationColor.value.copy(I.attenuationColor)),I.anisotropy>0&&(z.anisotropyVector.value.set(I.anisotropy*Math.cos(I.anisotropyRotation),I.anisotropy*Math.sin(I.anisotropyRotation)),I.anisotropyMap&&(z.anisotropyMap.value=I.anisotropyMap,t(I.anisotropyMap,z.anisotropyMapTransform))),z.specularIntensity.value=I.specularIntensity,z.specularColor.value.copy(I.specularColor),I.specularColorMap&&(z.specularColorMap.value=I.specularColorMap,t(I.specularColorMap,z.specularColorMapTransform)),I.specularIntensityMap&&(z.specularIntensityMap.value=I.specularIntensityMap,t(I.specularIntensityMap,z.specularIntensityMapTransform))}function T(z,I){I.matcap&&(z.matcap.value=I.matcap)}function G(z,I){const ee=e.get(I).light;z.referencePosition.value.setFromMatrixPosition(ee.matrixWorld),z.nearDistance.value=ee.shadow.camera.near,z.farDistance.value=ee.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function fk(r,e,t,n){let s={},o={},a=[];const c=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function u(ee,Q){const oe=Q.program;n.uniformBlockBinding(ee,oe)}function d(ee,Q){let oe=s[ee.id];oe===void 0&&(T(ee),oe=p(ee),s[ee.id]=oe,ee.addEventListener("dispose",z));const _e=Q.program;n.updateUBOMapping(ee,_e);const ve=e.render.frame;o[ee.id]!==ve&&(y(ee),o[ee.id]=ve)}function p(ee){const Q=m();ee.__bindingPointIndex=Q;const oe=r.createBuffer(),_e=ee.__size,ve=ee.usage;return r.bindBuffer(r.UNIFORM_BUFFER,oe),r.bufferData(r.UNIFORM_BUFFER,_e,ve),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,Q,oe),oe}function m(){for(let ee=0;ee0&&(oe+=_e-ve),ee.__size=oe,ee.__cache={},this}function G(ee){const Q={boundary:0,storage:0};return typeof ee=="number"||typeof ee=="boolean"?(Q.boundary=4,Q.storage=4):ee.isVector2?(Q.boundary=8,Q.storage=8):ee.isVector3||ee.isColor?(Q.boundary=16,Q.storage=12):ee.isVector4?(Q.boundary=16,Q.storage=16):ee.isMatrix3?(Q.boundary=48,Q.storage=48):ee.isMatrix4?(Q.boundary=64,Q.storage=64):ee.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",ee),Q}function z(ee){const Q=ee.target;Q.removeEventListener("dispose",z);const oe=a.indexOf(Q.__bindingPointIndex);a.splice(oe,1),r.deleteBuffer(s[Q.id]),delete s[Q.id],delete o[Q.id]}function I(){for(const ee in s)r.deleteBuffer(s[ee]);a=[],s={},o={}}return{bind:u,update:d,dispose:I}}class pk{constructor(e={}){const{canvas:t=Ya(),context:n=null,depth:s=!0,stencil:o=!1,alpha:a=!1,antialias:c=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:y=!1}=e;this.isWebGLRenderer=!0;let M;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");M=n.getContextAttributes().alpha}else M=a;const T=new Uint32Array(4),G=new Int32Array(4);let z=null,I=null;const ee=[],Q=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=yt,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const oe=this;let _e=!1;this._outputColorSpace=co;let ve=0,Oe=0,He=null,Ce=-1,Be=null;const ft=new mr,zt=new mr;let tn=null;const cn=new jn(0);let vn=0,mn=t.width,Yn=t.height,xn=1,si=null,wn=null;const Gn=new mr(0,0,mn,Yn),Si=new mr(0,0,mn,Yn);let nr=!1;const ss=new lf;let Vn=!1,un=!1;const Mn=new Ft,fi=new ot,ki=new mr,Ni={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Cr=!1;function zs(){return He===null?xn:1}let Vt=n;function Kn(dt,ln){return t.getContext(dt,ln)}try{const dt={alpha:!0,depth:s,stencil:o,antialias:c,premultipliedAlpha:u,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${w}`),t.addEventListener("webglcontextlost",Di,!1),t.addEventListener("webglcontextrestored",pr,!1),t.addEventListener("webglcontextcreationerror",gi,!1),Vt===null){const ln="webgl2";if(Vt=Kn(ln,dt),Vt===null)throw Kn(ln)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(dt){throw console.error("THREE.WebGLRenderer: "+dt.message),dt}let Zn,qn,Hn,Ti,pi,Ii,bs,ps,St,nt,fn,Dn,ri,zn,Rr,Ci,Tr,Er,mi,Yi,ts,Pr,Hi,Rs;function rn(){Zn=new SB(Vt),Zn.init(),Pr=new ok(Vt,Zn),qn=new yB(Vt,Zn,e,Pr),Hn=new rk(Vt,Zn),qn.reversedDepthBuffer&&y&&Hn.buffers.depth.setReversed(!0),Ti=new AB(Vt),pi=new $U,Ii=new sk(Vt,Zn,Hn,pi,qn,Pr,Ti),bs=new xB(oe),ps=new MB(oe),St=new fO(Vt),Hi=new mB(Vt,St),nt=new TB(Vt,St,Ti,Hi),fn=new RB(Vt,nt,St,Ti),mi=new CB(Vt,qn,Ii),Ci=new vB(pi),Dn=new HU(oe,bs,ps,Zn,qn,Hi,Ci),ri=new dk(oe,pi),zn=new XU,Rr=new QU(Zn),Er=new pB(oe,bs,ps,Hn,fn,M,u),Tr=new nk(oe,fn,qn),Rs=new fk(Vt,Ti,qn,Hn),Yi=new gB(Vt,Zn,Ti),ts=new EB(Vt,Zn,Ti),Ti.programs=Dn.programs,oe.capabilities=qn,oe.extensions=Zn,oe.properties=pi,oe.renderLists=zn,oe.shadowMap=Tr,oe.state=Hn,oe.info=Ti}rn();const wi=new uk(oe,Vt);this.xr=wi,this.getContext=function(){return Vt},this.getContextAttributes=function(){return Vt.getContextAttributes()},this.forceContextLoss=function(){const dt=Zn.get("WEBGL_lose_context");dt&&dt.loseContext()},this.forceContextRestore=function(){const dt=Zn.get("WEBGL_lose_context");dt&&dt.restoreContext()},this.getPixelRatio=function(){return xn},this.setPixelRatio=function(dt){dt!==void 0&&(xn=dt,this.setSize(mn,Yn,!1))},this.getSize=function(dt){return dt.set(mn,Yn)},this.setSize=function(dt,ln,Tn=!0){if(wi.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}mn=dt,Yn=ln,t.width=Math.floor(dt*xn),t.height=Math.floor(ln*xn),Tn===!0&&(t.style.width=dt+"px",t.style.height=ln+"px"),this.setViewport(0,0,dt,ln)},this.getDrawingBufferSize=function(dt){return dt.set(mn*xn,Yn*xn).floor()},this.setDrawingBufferSize=function(dt,ln,Tn){mn=dt,Yn=ln,xn=Tn,t.width=Math.floor(dt*Tn),t.height=Math.floor(ln*Tn),this.setViewport(0,0,dt,ln)},this.getCurrentViewport=function(dt){return dt.copy(ft)},this.getViewport=function(dt){return dt.copy(Gn)},this.setViewport=function(dt,ln,Tn,En){dt.isVector4?Gn.set(dt.x,dt.y,dt.z,dt.w):Gn.set(dt,ln,Tn,En),Hn.viewport(ft.copy(Gn).multiplyScalar(xn).round())},this.getScissor=function(dt){return dt.copy(Si)},this.setScissor=function(dt,ln,Tn,En){dt.isVector4?Si.set(dt.x,dt.y,dt.z,dt.w):Si.set(dt,ln,Tn,En),Hn.scissor(zt.copy(Si).multiplyScalar(xn).round())},this.getScissorTest=function(){return nr},this.setScissorTest=function(dt){Hn.setScissorTest(nr=dt)},this.setOpaqueSort=function(dt){si=dt},this.setTransparentSort=function(dt){wn=dt},this.getClearColor=function(dt){return dt.copy(Er.getClearColor())},this.setClearColor=function(){Er.setClearColor(...arguments)},this.getClearAlpha=function(){return Er.getClearAlpha()},this.setClearAlpha=function(){Er.setClearAlpha(...arguments)},this.clear=function(dt=!0,ln=!0,Tn=!0){let En=0;if(dt){let dn=!1;if(He!==null){const _i=He.texture.format;dn=_i===st||_i===Ve||_i===X}if(dn){const _i=He.texture.type,$i=_i===Oi||_i===as||_i===ms||_i===Da||_i===Xl||_i===ql,wr=Er.getClearColor(),ur=Er.getClearAlpha(),es=wr.r,os=wr.g,Vr=wr.b;$i?(T[0]=es,T[1]=os,T[2]=Vr,T[3]=ur,Vt.clearBufferuiv(Vt.COLOR,0,T)):(G[0]=es,G[1]=os,G[2]=Vr,G[3]=ur,Vt.clearBufferiv(Vt.COLOR,0,G))}else En|=Vt.COLOR_BUFFER_BIT}ln&&(En|=Vt.DEPTH_BUFFER_BIT),Tn&&(En|=Vt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Vt.clear(En)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Di,!1),t.removeEventListener("webglcontextrestored",pr,!1),t.removeEventListener("webglcontextcreationerror",gi,!1),Er.dispose(),zn.dispose(),Rr.dispose(),pi.dispose(),bs.dispose(),ps.dispose(),fn.dispose(),Hi.dispose(),Rs.dispose(),Dn.dispose(),wi.dispose(),wi.removeEventListener("sessionstart",jh),wi.removeEventListener("sessionend",l3),Rm.stop()};function Di(dt){dt.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_e=!0}function pr(){console.log("THREE.WebGLRenderer: Context Restored."),_e=!1;const dt=Ti.autoReset,ln=Tr.enabled,Tn=Tr.autoUpdate,En=Tr.needsUpdate,dn=Tr.type;rn(),Ti.autoReset=dt,Tr.enabled=ln,Tr.autoUpdate=Tn,Tr.needsUpdate=En,Tr.type=dn}function gi(dt){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",dt.statusMessage)}function Jn(dt){const ln=dt.target;ln.removeEventListener("dispose",Jn),Ar(ln)}function Ar(dt){ws(dt),pi.remove(dt)}function ws(dt){const ln=pi.get(dt).programs;ln!==void 0&&(ln.forEach(function(Tn){Dn.releaseProgram(Tn)}),dt.isShaderMaterial&&Dn.releaseShaderCache(dt))}this.renderBufferDirect=function(dt,ln,Tn,En,dn,_i){ln===null&&(ln=Ni);const $i=dn.isMesh&&dn.matrixWorld.determinant()<0,wr=Nq(dt,ln,Tn,En,dn);Hn.setMaterial(En,$i);let ur=Tn.index,es=1;if(En.wireframe===!0){if(ur=nt.getWireframeAttribute(Tn),ur===void 0)return;es=2}const os=Tn.drawRange,Vr=Tn.attributes.position;let $s=os.start*es,Io=(os.start+os.count)*es;_i!==null&&($s=Math.max($s,_i.start*es),Io=Math.min(Io,(_i.start+_i.count)*es)),ur!==null?($s=Math.max($s,0),Io=Math.min(Io,ur.count)):Vr!=null&&($s=Math.max($s,0),Io=Math.min(Io,Vr.count));const La=Io-$s;if(La<0||La===1/0)return;Hi.setup(dn,En,wr,Tn,ur);let Jo,Bo=Yi;if(ur!==null&&(Jo=St.get(ur),Bo=ts,Bo.setIndex(Jo)),dn.isMesh)En.wireframe===!0?(Hn.setLineWidth(En.wireframeLinewidth*zs()),Bo.setMode(Vt.LINES)):Bo.setMode(Vt.TRIANGLES);else if(dn.isLine){let jr=En.linewidth;jr===void 0&&(jr=1),Hn.setLineWidth(jr*zs()),dn.isLineSegments?Bo.setMode(Vt.LINES):dn.isLineLoop?Bo.setMode(Vt.LINE_LOOP):Bo.setMode(Vt.LINE_STRIP)}else dn.isPoints?Bo.setMode(Vt.POINTS):dn.isSprite&&Bo.setMode(Vt.TRIANGLES);if(dn.isBatchedMesh)if(dn._multiDrawInstances!==null)ol("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Bo.renderMultiDrawInstances(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount,dn._multiDrawInstances);else if(Zn.get("WEBGL_multi_draw"))Bo.renderMultiDraw(dn._multiDrawStarts,dn._multiDrawCounts,dn._multiDrawCount);else{const jr=dn._multiDrawStarts,va=dn._multiDrawCounts,lo=dn._multiDrawCount,eu=ur?St.get(ur).bytesPerElement:1,g0=pi.get(En).currentProgram.getUniforms();for(let tu=0;tu{function _i(){if(En.forEach(function($i){pi.get($i).currentProgram.isReady()&&En.delete($i)}),En.size===0){dn(dt);return}setTimeout(_i,10)}Zn.get("KHR_parallel_shader_compile")!==null?_i():setTimeout(_i,10)})};let _o=null;function $d(dt){_o&&_o(dt)}function jh(){Rm.stop()}function l3(){Rm.start()}const Rm=new aA;Rm.setAnimationLoop($d),typeof self!="undefined"&&Rm.setContext(self),this.setAnimationLoop=function(dt){_o=dt,wi.setAnimationLoop(dt),dt===null?Rm.stop():Rm.start()},wi.addEventListener("sessionstart",jh),wi.addEventListener("sessionend",l3),this.render=function(dt,ln){if(ln!==void 0&&ln.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_e===!0)return;if(dt.matrixWorldAutoUpdate===!0&&dt.updateMatrixWorld(),ln.parent===null&&ln.matrixWorldAutoUpdate===!0&&ln.updateMatrixWorld(),wi.enabled===!0&&wi.isPresenting===!0&&(wi.cameraAutoUpdate===!0&&wi.updateCamera(ln),ln=wi.getCamera()),dt.isScene===!0&&dt.onBeforeRender(oe,dt,ln,He),I=Rr.get(dt,Q.length),I.init(ln),Q.push(I),Mn.multiplyMatrices(ln.projectionMatrix,ln.matrixWorldInverse),ss.setFromProjectionMatrix(Mn,so,ln.reversedDepth),un=this.localClippingEnabled,Vn=Ci.init(this.clippingPlanes,un),z=zn.get(dt,ee.length),z.init(),ee.push(z),wi.enabled===!0&&wi.isPresenting===!0){const _i=oe.xr.getDepthSensingMesh();_i!==null&&JT(_i,ln,-1/0,oe.sortObjects)}JT(dt,ln,0,oe.sortObjects),z.finish(),oe.sortObjects===!0&&z.sort(si,wn),Cr=wi.enabled===!1||wi.isPresenting===!1||wi.hasDepthSensing()===!1,Cr&&Er.addToRenderList(z,dt),this.info.render.frame++,Vn===!0&&Ci.beginShadows();const Tn=I.state.shadowsArray;Tr.render(Tn,dt,ln),Vn===!0&&Ci.endShadows(),this.info.autoReset===!0&&this.info.reset();const En=z.opaque,dn=z.transmissive;if(I.setupLights(),ln.isArrayCamera){const _i=ln.cameras;if(dn.length>0)for(let $i=0,wr=_i.length;$i0&&u3(En,dn,dt,ln),Cr&&Er.render(dt),c3(z,dt,ln);He!==null&&Oe===0&&(Ii.updateMultisampleRenderTarget(He),Ii.updateRenderTargetMipmap(He)),dt.isScene===!0&&dt.onAfterRender(oe,dt,ln),Hi.resetDefaultState(),Ce=-1,Be=null,Q.pop(),Q.length>0?(I=Q[Q.length-1],Vn===!0&&Ci.setGlobalState(oe.clippingPlanes,I.state.camera)):I=null,ee.pop(),ee.length>0?z=ee[ee.length-1]:z=null};function JT(dt,ln,Tn,En){if(dt.visible===!1)return;if(dt.layers.test(ln.layers)){if(dt.isGroup)Tn=dt.renderOrder;else if(dt.isLOD)dt.autoUpdate===!0&&dt.update(ln);else if(dt.isLight)I.pushLight(dt),dt.castShadow&&I.pushShadow(dt);else if(dt.isSprite){if(!dt.frustumCulled||ss.intersectsSprite(dt)){En&&ki.setFromMatrixPosition(dt.matrixWorld).applyMatrix4(Mn);const $i=fn.update(dt),wr=dt.material;wr.visible&&z.push(dt,$i,wr,Tn,ki.z,null)}}else if((dt.isMesh||dt.isLine||dt.isPoints)&&(!dt.frustumCulled||ss.intersectsObject(dt))){const $i=fn.update(dt),wr=dt.material;if(En&&(dt.boundingSphere!==void 0?(dt.boundingSphere===null&&dt.computeBoundingSphere(),ki.copy(dt.boundingSphere.center)):($i.boundingSphere===null&&$i.computeBoundingSphere(),ki.copy($i.boundingSphere.center)),ki.applyMatrix4(dt.matrixWorld).applyMatrix4(Mn)),Array.isArray(wr)){const ur=$i.groups;for(let es=0,os=ur.length;es0&&Zb(dn,ln,Tn),_i.length>0&&Zb(_i,ln,Tn),$i.length>0&&Zb($i,ln,Tn),Hn.buffers.depth.setTest(!0),Hn.buffers.depth.setMask(!0),Hn.buffers.color.setMask(!0),Hn.setPolygonOffset(!1)}function u3(dt,ln,Tn,En){if((Tn.isScene===!0?Tn.overrideMaterial:null)!==null)return;I.state.transmissionRenderTarget[En.id]===void 0&&(I.state.transmissionRenderTarget[En.id]=new cc(1,1,{generateMipmaps:!0,type:Zn.has("EXT_color_buffer_half_float")||Zn.has("EXT_color_buffer_float")?Vs:Oi,minFilter:Qn,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ki.workingColorSpace}));const _i=I.state.transmissionRenderTarget[En.id],$i=En.viewport||ft;_i.setSize($i.z*oe.transmissionResolutionScale,$i.w*oe.transmissionResolutionScale);const wr=oe.getRenderTarget(),ur=oe.getActiveCubeFace(),es=oe.getActiveMipmapLevel();oe.setRenderTarget(_i),oe.getClearColor(cn),vn=oe.getClearAlpha(),vn<1&&oe.setClearColor(16777215,.5),oe.clear(),Cr&&Er.render(Tn);const os=oe.toneMapping;oe.toneMapping=yt;const Vr=En.viewport;if(En.viewport!==void 0&&(En.viewport=void 0),I.setupLightsView(En),Vn===!0&&Ci.setGlobalState(oe.clippingPlanes,En),Zb(dt,Tn,En),Ii.updateMultisampleRenderTarget(_i),Ii.updateRenderTargetMipmap(_i),Zn.has("WEBGL_multisampled_render_to_texture")===!1){let $s=!1;for(let Io=0,La=ln.length;Io0),Vr=!!Tn.morphAttributes.position,$s=!!Tn.morphAttributes.normal,Io=!!Tn.morphAttributes.color;let La=yt;En.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&(La=oe.toneMapping);const Jo=Tn.morphAttributes.position||Tn.morphAttributes.normal||Tn.morphAttributes.color,Bo=Jo!==void 0?Jo.length:0,jr=pi.get(En),va=I.state.lights;if(Vn===!0&&(un===!0||dt!==Be)){const oc=dt===Be&&En.id===Ce;Ci.setState(En,dt,oc)}let lo=!1;En.version===jr.__version?(jr.needsLights&&jr.lightsStateVersion!==va.state.version||jr.outputColorSpace!==wr||dn.isBatchedMesh&&jr.batching===!1||!dn.isBatchedMesh&&jr.batching===!0||dn.isBatchedMesh&&jr.batchingColor===!0&&dn.colorTexture===null||dn.isBatchedMesh&&jr.batchingColor===!1&&dn.colorTexture!==null||dn.isInstancedMesh&&jr.instancing===!1||!dn.isInstancedMesh&&jr.instancing===!0||dn.isSkinnedMesh&&jr.skinning===!1||!dn.isSkinnedMesh&&jr.skinning===!0||dn.isInstancedMesh&&jr.instancingColor===!0&&dn.instanceColor===null||dn.isInstancedMesh&&jr.instancingColor===!1&&dn.instanceColor!==null||dn.isInstancedMesh&&jr.instancingMorph===!0&&dn.morphTexture===null||dn.isInstancedMesh&&jr.instancingMorph===!1&&dn.morphTexture!==null||jr.envMap!==ur||En.fog===!0&&jr.fog!==_i||jr.numClippingPlanes!==void 0&&(jr.numClippingPlanes!==Ci.numPlanes||jr.numIntersection!==Ci.numIntersection)||jr.vertexAlphas!==es||jr.vertexTangents!==os||jr.morphTargets!==Vr||jr.morphNormals!==$s||jr.morphColors!==Io||jr.toneMapping!==La||jr.morphTargetsCount!==Bo)&&(lo=!0):(lo=!0,jr.__version=En.version);let eu=jr.currentProgram;lo===!0&&(eu=Kb(En,ln,dn));let g0=!1,tu=!1,Jv=!1;const xa=eu.getUniforms(),Iu=jr.uniforms;if(Hn.useProgram(eu.program)&&(g0=!0,tu=!0,Jv=!0),En.id!==Ce&&(Ce=En.id,tu=!0),g0||Be!==dt){Hn.buffers.depth.getReversed()&&dt.reversedDepth!==!0&&(dt._reversedDepth=!0,dt.updateProjectionMatrix()),xa.setValue(Vt,"projectionMatrix",dt.projectionMatrix),xa.setValue(Vt,"viewMatrix",dt.matrixWorldInverse);const Nc=xa.map.cameraPosition;Nc!==void 0&&Nc.setValue(Vt,fi.setFromMatrixPosition(dt.matrixWorld)),qn.logarithmicDepthBuffer&&xa.setValue(Vt,"logDepthBufFC",2/(Math.log(dt.far+1)/Math.LN2)),(En.isMeshPhongMaterial||En.isMeshToonMaterial||En.isMeshLambertMaterial||En.isMeshBasicMaterial||En.isMeshStandardMaterial||En.isShaderMaterial)&&xa.setValue(Vt,"isOrthographic",dt.isOrthographicCamera===!0),Be!==dt&&(Be=dt,tu=!0,Jv=!0)}if(dn.isSkinnedMesh){xa.setOptional(Vt,dn,"bindMatrix"),xa.setOptional(Vt,dn,"bindMatrixInverse");const oc=dn.skeleton;oc&&(oc.boneTexture===null&&oc.computeBoneTexture(),xa.setValue(Vt,"boneTexture",oc.boneTexture,Ii))}dn.isBatchedMesh&&(xa.setOptional(Vt,dn,"batchingTexture"),xa.setValue(Vt,"batchingTexture",dn._matricesTexture,Ii),xa.setOptional(Vt,dn,"batchingIdTexture"),xa.setValue(Vt,"batchingIdTexture",dn._indirectTexture,Ii),xa.setOptional(Vt,dn,"batchingColorTexture"),dn._colorsTexture!==null&&xa.setValue(Vt,"batchingColorTexture",dn._colorsTexture,Ii));const Lu=Tn.morphAttributes;if((Lu.position!==void 0||Lu.normal!==void 0||Lu.color!==void 0)&&mi.update(dn,Tn,eu),(tu||jr.receiveShadow!==dn.receiveShadow)&&(jr.receiveShadow=dn.receiveShadow,xa.setValue(Vt,"receiveShadow",dn.receiveShadow)),En.isMeshGouraudMaterial&&En.envMap!==null&&(Iu.envMap.value=ur,Iu.flipEnvMap.value=ur.isCubeTexture&&ur.isRenderTargetTexture===!1?-1:1),En.isMeshStandardMaterial&&En.envMap===null&&ln.environment!==null&&(Iu.envMapIntensity.value=ln.environmentIntensity),tu&&(xa.setValue(Vt,"toneMappingExposure",oe.toneMappingExposure),jr.needsLights&&Pq(Iu,Jv),_i&&En.fog===!0&&ri.refreshFogUniforms(Iu,_i),ri.refreshMaterialUniforms(Iu,En,xn,Yn,I.state.transmissionRenderTarget[dt.id]),f_.upload(Vt,d3(jr),Iu,Ii)),En.isShaderMaterial&&En.uniformsNeedUpdate===!0&&(f_.upload(Vt,d3(jr),Iu,Ii),En.uniformsNeedUpdate=!1),En.isSpriteMaterial&&xa.setValue(Vt,"center",dn.center),xa.setValue(Vt,"modelViewMatrix",dn.modelViewMatrix),xa.setValue(Vt,"normalMatrix",dn.normalMatrix),xa.setValue(Vt,"modelMatrix",dn.matrixWorld),En.isShaderMaterial||En.isRawShaderMaterial){const oc=En.uniformsGroups;for(let Nc=0,QT=oc.length;Nc0&&Ii.useMultisampledRTT(dt)===!1?dn=pi.get(dt).__webglMultisampledFramebuffer:Array.isArray(os)?dn=os[Tn]:dn=os,ft.copy(dt.viewport),zt.copy(dt.scissor),tn=dt.scissorTest}else ft.copy(Gn).multiplyScalar(xn).floor(),zt.copy(Si).multiplyScalar(xn).floor(),tn=nr;if(Tn!==0&&(dn=Lq),Hn.bindFramebuffer(Vt.FRAMEBUFFER,dn)&&En&&Hn.drawBuffers(dt,dn),Hn.viewport(ft),Hn.scissor(zt),Hn.setScissorTest(tn),_i){const ur=pi.get(dt.texture);Vt.framebufferTexture2D(Vt.FRAMEBUFFER,Vt.COLOR_ATTACHMENT0,Vt.TEXTURE_CUBE_MAP_POSITIVE_X+ln,ur.__webglTexture,Tn)}else if($i){const ur=ln;for(let es=0;es=0&&ln<=dt.width-En&&Tn>=0&&Tn<=dt.height-dn&&(dt.textures.length>1&&Vt.readBuffer(Vt.COLOR_ATTACHMENT0+wr),Vt.readPixels(ln,Tn,En,dn,Pr.convert(os),Pr.convert(Vr),_i))}finally{const es=He!==null?pi.get(He).__webglFramebuffer:null;Hn.bindFramebuffer(Vt.FRAMEBUFFER,es)}}},this.readRenderTargetPixelsAsync=function(dt,ln,Tn,En,dn,_i,$i,wr=0){return hr(this,null,function*(){if(!(dt&&dt.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ur=pi.get(dt).__webglFramebuffer;if(dt.isWebGLCubeRenderTarget&&$i!==void 0&&(ur=ur[$i]),ur)if(ln>=0&&ln<=dt.width-En&&Tn>=0&&Tn<=dt.height-dn){Hn.bindFramebuffer(Vt.FRAMEBUFFER,ur);const es=dt.textures[wr],os=es.format,Vr=es.type;if(!qn.textureFormatReadable(os))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qn.textureTypeReadable(Vr))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const $s=Vt.createBuffer();Vt.bindBuffer(Vt.PIXEL_PACK_BUFFER,$s),Vt.bufferData(Vt.PIXEL_PACK_BUFFER,_i.byteLength,Vt.STREAM_READ),dt.textures.length>1&&Vt.readBuffer(Vt.COLOR_ATTACHMENT0+wr),Vt.readPixels(ln,Tn,En,dn,Pr.convert(os),Pr.convert(Vr),0);const Io=He!==null?pi.get(He).__webglFramebuffer:null;Hn.bindFramebuffer(Vt.FRAMEBUFFER,Io);const La=Vt.fenceSync(Vt.SYNC_GPU_COMMANDS_COMPLETE,0);return Vt.flush(),yield oi(Vt,La,4),Vt.bindBuffer(Vt.PIXEL_PACK_BUFFER,$s),Vt.getBufferSubData(Vt.PIXEL_PACK_BUFFER,0,_i),Vt.deleteBuffer($s),Vt.deleteSync(La),_i}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(dt,ln=null,Tn=0){const En=Math.pow(2,-Tn),dn=Math.floor(dt.image.width*En),_i=Math.floor(dt.image.height*En),$i=ln!==null?ln.x:0,wr=ln!==null?ln.y:0;Ii.setTexture2D(dt,0),Vt.copyTexSubImage2D(Vt.TEXTURE_2D,Tn,0,0,$i,wr,dn,_i),Hn.unbindTexture()};const Dq=Vt.createFramebuffer(),Oq=Vt.createFramebuffer();this.copyTextureToTexture=function(dt,ln,Tn=null,En=null,dn=0,_i=null){_i===null&&(dn!==0?(ol("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),_i=dn,dn=0):_i=0);let $i,wr,ur,es,os,Vr,$s,Io,La;const Jo=dt.isCompressedTexture?dt.mipmaps[_i]:dt.image;if(Tn!==null)$i=Tn.max.x-Tn.min.x,wr=Tn.max.y-Tn.min.y,ur=Tn.isBox3?Tn.max.z-Tn.min.z:1,es=Tn.min.x,os=Tn.min.y,Vr=Tn.isBox3?Tn.min.z:0;else{const Lu=Math.pow(2,-dn);$i=Math.floor(Jo.width*Lu),wr=Math.floor(Jo.height*Lu),dt.isDataArrayTexture?ur=Jo.depth:dt.isData3DTexture?ur=Math.floor(Jo.depth*Lu):ur=1,es=0,os=0,Vr=0}En!==null?($s=En.x,Io=En.y,La=En.z):($s=0,Io=0,La=0);const Bo=Pr.convert(ln.format),jr=Pr.convert(ln.type);let va;ln.isData3DTexture?(Ii.setTexture3D(ln,0),va=Vt.TEXTURE_3D):ln.isDataArrayTexture||ln.isCompressedArrayTexture?(Ii.setTexture2DArray(ln,0),va=Vt.TEXTURE_2D_ARRAY):(Ii.setTexture2D(ln,0),va=Vt.TEXTURE_2D),Vt.pixelStorei(Vt.UNPACK_FLIP_Y_WEBGL,ln.flipY),Vt.pixelStorei(Vt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ln.premultiplyAlpha),Vt.pixelStorei(Vt.UNPACK_ALIGNMENT,ln.unpackAlignment);const lo=Vt.getParameter(Vt.UNPACK_ROW_LENGTH),eu=Vt.getParameter(Vt.UNPACK_IMAGE_HEIGHT),g0=Vt.getParameter(Vt.UNPACK_SKIP_PIXELS),tu=Vt.getParameter(Vt.UNPACK_SKIP_ROWS),Jv=Vt.getParameter(Vt.UNPACK_SKIP_IMAGES);Vt.pixelStorei(Vt.UNPACK_ROW_LENGTH,Jo.width),Vt.pixelStorei(Vt.UNPACK_IMAGE_HEIGHT,Jo.height),Vt.pixelStorei(Vt.UNPACK_SKIP_PIXELS,es),Vt.pixelStorei(Vt.UNPACK_SKIP_ROWS,os),Vt.pixelStorei(Vt.UNPACK_SKIP_IMAGES,Vr);const xa=dt.isDataArrayTexture||dt.isData3DTexture,Iu=ln.isDataArrayTexture||ln.isData3DTexture;if(dt.isDepthTexture){const Lu=pi.get(dt),oc=pi.get(ln),Nc=pi.get(Lu.__renderTarget),QT=pi.get(oc.__renderTarget);Hn.bindFramebuffer(Vt.READ_FRAMEBUFFER,Nc.__webglFramebuffer),Hn.bindFramebuffer(Vt.DRAW_FRAMEBUFFER,QT.__webglFramebuffer);for(let Nm=0;Nm0){const{width:a,height:c}=e.context;t.bufferWidth=a,t.bufferHeight=c}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const s=e[n];t[n]={version:s.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const s=e[n];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[n]={id:s.id,version:s.version}:t[n]=s.clone():t[n]=s)}return t}equals(e,t){const{object:n,material:s,geometry:o}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;const c=a.material;for(const z in c){const I=c[z],ee=s[z];if(I.equals!==void 0){if(I.equals(ee)===!1)return I.copy(ee),!1}else if(ee.isTexture===!0){if(I.id!==ee.id||I.version!==ee.version)return I.id=ee.id,I.version=ee.version,!1}else if(I!==ee)return c[z]=ee,!1}if(c.transmission>0){const{width:z,height:I}=e.context;if(a.bufferWidth!==z||a.bufferHeight!==I)return a.bufferWidth=z,a.bufferHeight=I,!1}const u=a.geometry,d=o.attributes,p=u.attributes,m=Object.keys(p),y=Object.keys(d);if(u.id!==o.id)return u.id=o.id,!1;if(m.length!==y.length)return a.geometry.attributes=this.getAttributesData(d),!1;for(const z of m){const I=p[z],ee=d[z];if(ee===void 0)return delete p[z],!1;if(I.version!==ee.version)return I.version=ee.version,!1}const M=o.index,T=u.indexVersion,G=M?M.version:null;if(T!==G)return u.indexVersion=G,!1;if(u.drawRange.start!==o.drawRange.start||u.drawRange.count!==o.drawRange.count)return u.drawRange.start=o.drawRange.start,u.drawRange.count=o.drawRange.count,!1;if(a.morphTargetInfluences){let z=!1;for(let I=0;I>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const Bw=r=>Hy(r),$y=r=>Hy(r),jy=(...r)=>Hy(r);function Uw(r,e=!1){const t=[];r.isNode===!0&&t.push(r.id);for(const{property:n,childNode:s}of Xy(r))t.push(Hy(n.slice(0,-4)),s.getCacheKey(e));return Hy(t)}function*Xy(r,e=!1){for(const t of Object.getOwnPropertyNames(r)){if(t.startsWith("_")===!0)continue;const n=r[t];if(Array.isArray(n)===!0)for(let s=0;se.charCodeAt(0)).buffer}var TY=Object.freeze({__proto__:null,arrayBufferToBase64:Gw,base64ToArrayBuffer:Ww,getByteBoundaryFromType:UA,getCacheKey:Uw,getDataFromObject:Vw,getLengthFromType:zw,getMemoryLengthFromType:BA,getNodeChildren:Xy,getTypeFromLength:kw,getTypedArrayFromType:qy,getValueFromType:m_,getValueType:Rd,hash:jy,hashArray:$y,hashString:Bw});const Yy={VERTEX:"vertex",FRAGMENT:"fragment"},rs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},vk={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Nl={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},kA=["fragment","vertex"],Hw=["setup","analyze","generate"],$w=[...kA,"compute"],tm=["x","y","z","w"],xk={analyze:"setup",generate:"analyze"};let _k=0;class Wi extends Ol{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=rs.NONE,this.updateBeforeType=rs.NONE,this.updateAfterType=rs.NONE,this.uuid=Yh.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:_k++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,rs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,rs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,rs.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Xy(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=jy(Uw(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let n=0;for(const s of this.getChildren())t["node"+n++]=s;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const s=e.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[e.shaderStage]=s.stages[e.shaderStage]||[],s.stages[e.shaderStage].push(t)}if(n===1){const s=e.getNodeProperties(this);for(const o of Object.values(s))o&&o.isNode===!0&&o.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const o=xk[e.buildStage];if(o&&s.buildStages[o]!==!0){const u=e.getBuildStage();e.setBuildStage(o),this.build(e),e.setBuildStage(u)}e.addNode(this),e.addChain(this);let a=null;const c=e.getBuildStage();if(c==="setup"){this.updateReference(e);const u=e.getNodeProperties(this);if(u.initialized!==!0){u.initialized=!0,u.outputNode=this.setup(e)||u.outputNode||null;for(const d of Object.values(u))if(d&&d.isNode===!0){if(d.parents===!0){const p=e.getNodeProperties(d);p.parents=p.parents||[],p.parents.push(this)}d.build(e)}}a=u.outputNode}else if(c==="analyze")this.analyze(e,t);else if(c==="generate"){if(this.generate.length===1){const d=this.getNodeType(e),p=e.getDataFromNode(this);a=p.snippet,a===void 0?p.generated===void 0?(p.generated=!0,a=this.generate(e)||"",p.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a="/* Recursion detected. */"):p.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,d,t)}else a=this.generate(e,t)||"";a===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(console.error(`THREE.TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Xy(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:s,index:o,childNode:a}of t)o!==void 0?(n[s]===void 0&&(n[s]=Number.isInteger(o)?[]:{}),n[s][o]=a.toJSON(e.meta).uuid):n[s]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const s=[];for(const o of e.inputNodes[n])s.push(t[o]);this[n]=s}else if(typeof e.inputNodes[n]=="object"){const s={};for(const o in e.inputNodes[n]){const a=e.inputNodes[n][o];s[o]=t[a]}this[n]=s}else{const s=e.inputNodes[n];this[n]=t[s]}}}toJSON(e){const{uuid:t,type:n}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let o=e.nodes[t];o===void 0&&(o={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[o.uuid]=o),this.serialize(o),delete o.meta);function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}if(s){const c=a(e.textures),u=a(e.images),d=a(e.nodes);c.length>0&&(o.textures=c),u.length>0&&(o.images=u),d.length>0&&(o.nodes=d)}return o}}class nm extends Wi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${s} ]`}}class zA extends Wi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const s of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(s))&&(n=s);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,s=this.getNodeType(e),o=n.build(e,s);return e.format(o,s,t)}}class Ra extends Wi{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const s=e.getVectorType(this.getNodeType(e,t)),o=e.getDataFromNode(this);if(o.propertyName!==void 0)return e.format(o.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,s),c=e.getVarFromNode(this,null,s),u=e.getPropertyName(c);return e.addLineFlowCode(`${u} = ${a}`,this),o.snippet=a,o.propertyName=u,e.format(o.propertyName,s,t)}}return super.build(e,t)}}class bk extends Ra{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),s=e.getTypeLength(n),o=this.nodes,a=e.getComponentType(n),c=[];let u=0;for(const p of o){if(u>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let m=p.getNodeType(e),y=e.getTypeLength(m),M;if(u+y>s&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),y=s-u,m=e.getTypeFromLength(y)),u+=y,M=p.build(e,m),e.getComponentType(m)!==a){const G=e.getTypeFromLength(y,a);M=e.format(M,m,G)}c.push(M)}const d=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(d,n,t)}}const wk=tm.join("");class VA extends Wi{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(tm.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const n=this.node,s=e.getTypeLength(n.getNodeType(e));let o=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===s&&this.components===wk.slice(0,this.components.length)?o=e.format(u,a,t):o=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else o=n.build(e,t);return o}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Mk extends Ra{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:s}=this,o=this.getNodeType(e),a=e.getComponentType(s.getNodeType(e)),c=e.getTypeFromLength(n.length,a),u=s.build(e,c),d=t.build(e,o),p=e.getTypeLength(o),m=[];for(let y=0;yr.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),WA=r=>Ek(r).split("").sort().join("");Wi.prototype.assign=function(...r){if(this.isStackNode!==!0)return Ff!==null?Ff.assign(this,...r):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=Xw.get("assign");return this.add(e(...r))}},Wi.prototype.toVarIntent=function(){return this},Wi.prototype.get=function(r){return new Tk(this,r)};const Zy={};function g_(r,e,t){Zy[r]=Zy[e]=Zy[t]={get(){this._cache=this._cache||{};let a=this._cache[r];return a===void 0&&(a=new VA(this,r),this._cache[r]=a),a},set(a){this[r].assign(Cn(a))}};const n=r.toUpperCase(),s=e.toUpperCase(),o=t.toUpperCase();Wi.prototype["set"+n]=Wi.prototype["set"+s]=Wi.prototype["set"+o]=function(a){const c=WA(r);return new Mk(this,c,Cn(a))},Wi.prototype["flip"+n]=Wi.prototype["flip"+s]=Wi.prototype["flip"+o]=function(){const a=WA(r);return new Sk(this,a)}}const Ch=["x","y","z","w"],Rh=["r","g","b","a"],Nh=["s","t","p","q"];for(let r=0;r<4;r++){let e=Ch[r],t=Rh[r],n=Nh[r];g_(e,t,n);for(let s=0;s<4;s++){e=Ch[r]+Ch[s],t=Rh[r]+Rh[s],n=Nh[r]+Nh[s],g_(e,t,n);for(let o=0;o<4;o++){e=Ch[r]+Ch[s]+Ch[o],t=Rh[r]+Rh[s]+Rh[o],n=Nh[r]+Nh[s]+Nh[o],g_(e,t,n);for(let a=0;a<4;a++)e=Ch[r]+Ch[s]+Ch[o]+Ch[a],t=Rh[r]+Rh[s]+Rh[o]+Rh[a],n=Nh[r]+Nh[s]+Nh[o]+Nh[a],g_(e,t,n)}}}for(let r=0;r<32;r++)Zy[r]={get(){this._cache=this._cache||{};let e=this._cache[r];return e===void 0&&(e=new nm(this,new _u(r,"uint")),this._cache[r]=e),e},set(e){this[r].assign(Cn(e))}};Object.defineProperties(Wi.prototype,Zy);const HA=new WeakMap,Ak=function(r,e=null){const t=Rd(r);return t==="node"?r:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Cn(Kw(r,e)):t==="shader"?r.isFn?r:Kt(r):r},Ck=function(r,e=null){for(const t in r)r[t]=Cn(r[t],e);return r},Rk=function(r,e=null){const t=r.length;for(let n=0;nu?(console.error(`THREE.TSL: "${m}" parameter length exceeds limit.`),p.slice(0,u)):p}return e===null?o=(...p)=>s(new r(...im(d(p)))):t!==null?(t=Cn(t),o=(...p)=>s(new r(e,...im(d(p)),t))):o=(...p)=>s(new r(e,...im(d(p)))),o.setParameterLength=(...p)=>(p.length===1?c=u=p[0]:p.length===2&&([c,u]=p),o),o.setName=p=>(a=p,o),o},Nk=function(r,...e){return Cn(new r(...im(e)))};class Pk extends Wi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:n}=this,s=e.getNodeProperties(t),o=e.getClosestSubBuild(t.subBuilds)||"",a=o||"default";if(s[a])return s[a];const c=e.subBuildFn;e.subBuildFn=o;let u=null;if(t.layout){let d=HA.get(e.constructor);d===void 0&&(d=new WeakMap,HA.set(e.constructor,d));let p=d.get(t);p===void 0&&(p=Cn(e.buildFunctionNode(t)),d.set(t,p)),e.addInclude(p);const m=n?Ik(n):null;u=Cn(p.call(m))}else{const d=new Proxy(e,{get:(T,G,z)=>{let I;return Symbol.iterator===G?I=function*(){yield void 0}:I=Reflect.get(T,G,z),I}}),p=n?Lk(n):null,m=Array.isArray(n)?n.length>0:n!==null,y=t.jsFunc,M=m||y.length>1?y(p,d):y(d);u=Cn(M)}return e.subBuildFn=c,t.once&&(s[a]=u),u}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null;const s=e.getBuildStage(),o=e.getNodeProperties(this),a=e.getSubBuildOutput(this),c=this.getOutputNode(e);if(s==="setup"){const u=e.getSubBuildProperty("initialized",this);if(o[u]!==!0&&(o[u]=!0,o[a]=this.getOutputNode(e),o[a].build(e),this.shaderNode.subBuilds))for(const d of e.chaining){const p=e.getDataFromNode(d,"any");p.subBuilds=p.subBuilds||new Set;for(const m of this.shaderNode.subBuilds)p.subBuilds.add(m)}n=o[a]}else s==="analyze"?c.build(e,t):s==="generate"&&(n=c.build(e,t)||"");return n}}function Ik(r){let e;return x_(r),r[0]&&(r[0].isNode||Object.getPrototypeOf(r[0])!==Object.prototype)?e=[...r]:e=r[0],e}function Lk(r){let e=0;return x_(r),new Proxy(r,{get:(t,n,s)=>{let o;if(n==="length")return o=r.length,o;if(Symbol.iterator===n)o=function*(){for(const a of r)yield Cn(a)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){const a=r[0];a[n]===void 0?o=a[e++]:o=Reflect.get(a,n,s)}else r[0]instanceof Wi&&(r[n]===void 0?o=r[e++]:o=Reflect.get(r,n,s));else o=Reflect.get(t,n,s);o=Cn(o)}return o}})}class Dk extends Wi{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Cn(new Pk(this,e))}setup(){return this.call()}}const Ok=[!1,!0],Fk=[0,1,2,3],Bk=[-1,-2],jA=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],qw=new Map;for(const r of Ok)qw.set(r,new _u(r));const Yw=new Map;for(const r of Fk)Yw.set(r,new _u(r,"uint"));const Zw=new Map([...Yw].map(r=>new _u(r.value,"int")));for(const r of Bk)Zw.set(r,new _u(r,"int"));const y_=new Map([...Zw].map(r=>new _u(r.value)));for(const r of jA)y_.set(r,new _u(r));for(const r of jA)y_.set(-r,new _u(-r));const v_={bool:qw,uint:Yw,ints:Zw,float:y_},XA=new Map([...qw,...y_]),Kw=(r,e)=>XA.has(r)?XA.get(r):r.isNode===!0?r:new _u(r,e),tl=function(r,e=null){return(...t)=>{for(const s of t)if(s===void 0)return console.error(`THREE.TSL: Invalid parameter for the type "${r}".`),Cn(new _u(0,r));if((t.length===0||!["bool","float","int","uint"].includes(r)&&t.every(s=>{const o=typeof s;return o!=="object"&&o!=="function"}))&&(t=[m_(r,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Jy(e.get(t[0]));if(t.length===1){const s=Kw(t[0],r);return s.nodeType===r?Jy(s):Jy(new zA(s,r))}const n=t.map(s=>Kw(s));return Jy(new bk(n,r))}},Ky=r=>typeof r=="object"&&r!==null?r.value:r,qA=r=>r!=null?r.nodeType||r.convertTo||(typeof r=="string"?r:null):null;function Bg(r,e){return new Dk(r,e)}const Cn=(r,e=null)=>Ak(r,e),Jy=(r,e=null)=>Cn(r,e).toVarIntent(),x_=(r,e=null)=>new Ck(r,e),im=(r,e=null)=>new Rk(r,e),zr=(r,e=null,t=null,n=null)=>new $A(r,e,t,n),xi=(r,...e)=>new Nk(r,...e),ci=(r,e=null,t=null,n={})=>new $A(r,e,t,qs({intent:!0},n));let Uk=0;class kk extends Wi{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:console.error("THREE.TSL: Invalid layout type."),t=null)),this.shaderNode=new Bg(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+Uk++,type:t,inputs:[]};for(const s in e)s!=="return"&&n.inputs.push({name:s,type:e[s]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return console.error('THREE.TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function Kt(r,e=null){const t=new kk(r,e);return new Proxy(()=>{},{apply(n,s,o){return t.call(...o)},get(n,s,o){return Reflect.get(t,s,o)},set(n,s,o,a){return Reflect.set(t,s,o,a)}})}const Qy=r=>{Ff=r},__=()=>Ff,sr=(...r)=>Ff.If(...r),zk=(...r)=>Ff.Switch(...r);function b_(r){return Ff&&Ff.add(r),r}An("toStack",b_);const YA=new tl("color"),ut=new tl("float",v_.float),Dt=new tl("int",v_.ints),Li=new tl("uint",v_.uint),bu=new tl("bool",v_.bool),Bn=new tl("vec2"),pl=new tl("ivec2"),ZA=new tl("uvec2"),KA=new tl("bvec2"),qt=new tl("vec3"),JA=new tl("ivec3"),Ug=new tl("uvec3"),Jw=new tl("bvec3"),Bi=new tl("vec4"),QA=new tl("ivec4"),eC=new tl("uvec4"),tC=new tl("bvec4"),w_=new tl("mat2"),Wl=new tl("mat3"),rm=new tl("mat4"),Vk=(r="")=>Cn(new _u(r,"string")),Gk=r=>Cn(new _u(r,"ArrayBuffer"));An("toColor",YA),An("toFloat",ut),An("toInt",Dt),An("toUint",Li),An("toBool",bu),An("toVec2",Bn),An("toIVec2",pl),An("toUVec2",ZA),An("toBVec2",KA),An("toVec3",qt),An("toIVec3",JA),An("toUVec3",Ug),An("toBVec3",Jw),An("toVec4",Bi),An("toIVec4",QA),An("toUVec4",eC),An("toBVec4",tC),An("toMat2",w_),An("toMat3",Wl),An("toMat4",rm);const nC=zr(nm).setParameterLength(2),iC=(r,e)=>Cn(new zA(Cn(r),e)),Wk=(r,e)=>Cn(new VA(Cn(r),e));An("element",nC),An("convert",iC);const Hk=r=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),b_(r));An("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),b_(r)));class ho extends Wi{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const th=(r,e)=>Cn(new ho(r,e)),$c=(r,e)=>Cn(new ho(r,e,!0)),to=xi(ho,"vec4","DiffuseColor"),Qw=xi(ho,"vec3","EmissiveColor"),Ph=xi(ho,"float","Roughness"),ev=xi(ho,"float","Metalness"),M_=xi(ho,"float","Clearcoat"),tv=xi(ho,"float","ClearcoatRoughness"),sm=xi(ho,"vec3","Sheen"),S_=xi(ho,"float","SheenRoughness"),T_=xi(ho,"float","Iridescence"),eM=xi(ho,"float","IridescenceIOR"),tM=xi(ho,"float","IridescenceThickness"),E_=xi(ho,"float","AlphaT"),Bf=xi(ho,"float","Anisotropy"),nv=xi(ho,"vec3","AnisotropyT"),om=xi(ho,"vec3","AnisotropyB"),Mc=xi(ho,"color","SpecularColor"),iv=xi(ho,"float","SpecularF90"),A_=xi(ho,"float","Shininess"),kg=xi(ho,"vec4","Output"),am=xi(ho,"float","dashSize"),rv=xi(ho,"float","gapSize"),$k=xi(ho,"float","pointWidth"),sv=xi(ho,"float","IOR"),C_=xi(ho,"float","Transmission"),nM=xi(ho,"float","Thickness"),iM=xi(ho,"float","AttenuationDistance"),rM=xi(ho,"color","AttenuationColor"),sM=xi(ho,"float","Dispersion");class rC extends Wi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const sC=r=>new rC(r),R_=(r,e=0)=>new rC(r,!0,e),oC=R_("frame"),or=R_("render"),oM=sC("object");class ov extends jw{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=oM}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(n=>{const s=e(n,this);s!==void 0&&(this.value=s)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const n=this.getNodeType(e),s=this.getUniformHash(e);let o=e.getNodeFromHash(s);o===void 0&&(e.setHashNode(this,s),o=this);const a=o.getInputType(e),c=e.getUniformFromNode(o,a,e.shaderStage,this.name||e.context.nodeName),u=e.getPropertyName(c);e.context.nodeName!==void 0&&delete e.context.nodeName;let d=u;if(n==="bool"){const p=e.getDataFromNode(this);let m=p.propertyName;if(m===void 0){const y=e.getVarFromNode(this,null,"bool");m=e.getPropertyName(y),p.propertyName=m,d=e.format(u,a,n),e.addLineFlowCode(`${m} = ${d}`,this)}d=m}return e.format(d,n,t)}}const cr=(r,e)=>{const t=qA(e||r);return t===r&&(r=m_(t)),r=r&&r.isNode===!0?r.node&&r.node.value||r.value:r,Cn(new ov(r,t))};class aC extends Ra{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const lC=(...r)=>{let e;if(r.length===1){const t=r[0];e=new aC(null,t.length,t)}else{const t=r[0],n=r[1];e=new aC(t,n)}return Cn(e)};An("toArray",(r,e)=>lC(Array(e).fill(r)));class jk extends Ra{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return tm.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,s=t.getScope(),o=e.getNodeProperties(s);o.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:s}=e.getNodeProperties(this),o=this.needsSplitAssign(e),a=n.build(e),c=n.getNodeType(e),u=s.build(e,c),d=s.getNodeType(e),p=e.getDataFromNode(this);let m;if(p.initialized===!0)t!=="void"&&(m=a);else if(o){const y=e.getVarFromNode(this,null,c),M=e.getPropertyName(y);e.addLineFlowCode(`${M} = ${u}`,this);const T=n.node,z=T.node.context({assign:!0}).build(e);for(let I=0;I{const p=d.type,m=p==="pointer";let y;return m?y="&"+u.build(e):y=u.build(e,p),y};if(Array.isArray(o)){if(o.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),o.length=s.length;else if(o.length(e=e.length>1||e[0]&&e[0].isNode===!0?im(e):x_(e[0]),Cn(new Xk(Cn(r),e)));An("call",uC);const qk={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ra extends Ra{static get type(){return"OperatorNode"}constructor(e,t,n,...s){if(super(),s.length>0){let o=new ra(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const u=Math.max(e.getTypeLength(a),e.getTypeLength(c));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(a)){if(c==="float")return a;if(e.isVector(c))return e.getVectorFromMatrix(a);if(e.isMatrix(c))return a}else if(e.isMatrix(c)){if(a==="float")return c;if(e.isVector(a))return e.getVectorFromMatrix(c)}return e.getTypeLength(c)>e.getTypeLength(a)?c:a}}generate(e,t){const n=this.op,{aNode:s,bNode:o}=this,a=this.getNodeType(e,t);let c=null,u=null;a!=="void"?(c=s.getNodeType(e),u=o?o.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(c)?u=c:e.isVector(u)?c=u:c!==u&&(c=u="float"):n===">>"||n==="<<"?(c=a,u=e.changeComponentType(u,"uint")):n==="%"?(c=a,u=e.isInteger(c)&&e.isInteger(u)?u:c):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):e.isMatrix(u)||(c=u=a):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):c=u=a:c=u=a):c=u=a;const d=s.build(e,c),p=o?o.build(e,u):null,m=e.getFunctionOperator(n);if(t!=="void"){const y=e.renderer.coordinateSystem===so;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return y?e.isVector(c)?e.format(`${this.getOperatorMethod(e,t)}( ${d}, ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t);if(n==="%")return e.isInteger(u)?e.format(`( ${d} % ${p} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${d}, ${p} )`,a,t);if(n==="!"||n==="~")return e.format(`(${n}${d})`,c,t);if(m)return e.format(`${m}( ${d}, ${p} )`,a,t);if(e.isMatrix(c)&&u==="float")return e.format(`( ${p} ${n} ${d} )`,a,t);if(c==="float"&&e.isMatrix(u))return e.format(`${d} ${n} ${p}`,a,t);{let M=`( ${d} ${n} ${p} )`;return!y&&a==="bool"&&e.isVector(c)&&e.isVector(u)&&(M=`all${M}`),e.format(M,a,t)}}else if(c!=="void")return m?e.format(`${m}( ${d}, ${p} )`,a,t):e.isMatrix(c)&&u==="float"?e.format(`${p} ${n} ${d}`,a,t):e.format(`${d} ${n} ${p}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Wa=ci(ra,"+").setParameterLength(2,1/0).setName("add"),Ds=ci(ra,"-").setParameterLength(2,1/0).setName("sub"),Kr=ci(ra,"*").setParameterLength(2,1/0).setName("mul"),jc=ci(ra,"/").setParameterLength(2,1/0).setName("div"),av=ci(ra,"%").setParameterLength(2).setName("mod"),aM=ci(ra,"==").setParameterLength(2).setName("equal"),hC=ci(ra,"!=").setParameterLength(2).setName("notEqual"),dC=ci(ra,"<").setParameterLength(2).setName("lessThan"),lM=ci(ra,">").setParameterLength(2).setName("greaterThan"),fC=ci(ra,"<=").setParameterLength(2).setName("lessThanEqual"),pC=ci(ra,">=").setParameterLength(2).setName("greaterThanEqual"),mC=ci(ra,"&&").setParameterLength(2,1/0).setName("and"),gC=ci(ra,"||").setParameterLength(2,1/0).setName("or"),yC=ci(ra,"!").setParameterLength(1).setName("not"),vC=ci(ra,"^^").setParameterLength(2).setName("xor"),xC=ci(ra,"&").setParameterLength(2).setName("bitAnd"),_C=ci(ra,"~").setParameterLength(2).setName("bitNot"),bC=ci(ra,"|").setParameterLength(2).setName("bitOr"),wC=ci(ra,"^").setParameterLength(2).setName("bitXor"),MC=ci(ra,"<<").setParameterLength(2).setName("shiftLeft"),SC=ci(ra,">>").setParameterLength(2).setName("shiftRight"),TC=Kt(([r])=>(r.addAssign(1),r)),EC=Kt(([r])=>(r.subAssign(1),r)),AC=Kt(([r])=>{const e=Dt(r).toConst();return r.addAssign(1),e}),CC=Kt(([r])=>{const e=Dt(r).toConst();return r.subAssign(1),e});An("add",Wa),An("sub",Ds),An("mul",Kr),An("div",jc),An("mod",av),An("equal",aM),An("notEqual",hC),An("lessThan",dC),An("greaterThan",lM),An("lessThanEqual",fC),An("greaterThanEqual",pC),An("and",mC),An("or",gC),An("not",yC),An("xor",vC),An("bitAnd",xC),An("bitNot",_C),An("bitOr",bC),An("bitXor",wC),An("shiftLeft",MC),An("shiftRight",SC),An("incrementBefore",TC),An("decrementBefore",EC),An("increment",AC),An("decrement",CC);const RC=(r,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),av(Dt(r),Dt(e)));An("modInt",RC);class an extends Ra{static get type(){return"MathNode"}constructor(e,t,n=null,s=null){if(super(),(e===an.MAX||e===an.MIN)&&arguments.length>3){let o=new an(e,t,n);for(let a=2;aa&&o>c?t:a>c?n:c>o?s:t}getNodeType(e){const t=this.method;return t===an.LENGTH||t===an.DISTANCE||t===an.DOT?"float":t===an.CROSS?"vec3":t===an.ALL||t===an.ANY?"bool":t===an.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:s}=this;let o=null;if(s===an.ONE_MINUS)o=Ds(1,t);else if(s===an.RECIPROCAL)o=jc(1,t);else if(s===an.DIFFERENCE)o=Oo(Ds(t,n));else if(s===an.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=Bi(qt(c),0):a=Bi(qt(a),0);const u=Kr(a,c).xyz;o=Nd(u)}return o!==null?o:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let s=this.method;const o=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,u=this.bNode,d=this.cNode,p=e.renderer.coordinateSystem;if(s===an.NEGATE)return e.format("( - "+c.build(e,a)+" )",o,t);{const m=[];return s===an.CROSS?m.push(c.build(e,o),u.build(e,o)):p===so&&s===an.STEP?m.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):p===so&&(s===an.MIN||s===an.MAX)?m.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):s===an.REFRACT?m.push(c.build(e,a),u.build(e,a),d.build(e,"float")):s===an.MIX?m.push(c.build(e,a),u.build(e,a),d.build(e,e.getTypeLength(d.getNodeType(e))===1?"float":a)):(p===ja&&s===an.ATAN&&u!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===an.DFDX||s===an.DFDY)&&(console.warn(`THREE.TSL: '${s}' is not supported in the ${e.shaderStage} stage.`),s="/*"+s+"*/"),m.push(c.build(e,a)),u!==null&&m.push(u.build(e,a)),d!==null&&m.push(d.build(e,a))),e.format(`${e.getMethod(s,o)}( ${m.join(", ")} )`,o,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}an.ALL="all",an.ANY="any",an.RADIANS="radians",an.DEGREES="degrees",an.EXP="exp",an.EXP2="exp2",an.LOG="log",an.LOG2="log2",an.SQRT="sqrt",an.INVERSE_SQRT="inversesqrt",an.FLOOR="floor",an.CEIL="ceil",an.NORMALIZE="normalize",an.FRACT="fract",an.SIN="sin",an.COS="cos",an.TAN="tan",an.ASIN="asin",an.ACOS="acos",an.ATAN="atan",an.ABS="abs",an.SIGN="sign",an.LENGTH="length",an.NEGATE="negate",an.ONE_MINUS="oneMinus",an.DFDX="dFdx",an.DFDY="dFdy",an.ROUND="round",an.RECIPROCAL="reciprocal",an.TRUNC="trunc",an.FWIDTH="fwidth",an.TRANSPOSE="transpose",an.DETERMINANT="determinant",an.INVERSE="inverse",an.EQUALS="equals",an.MIN="min",an.MAX="max",an.STEP="step",an.REFLECT="reflect",an.DISTANCE="distance",an.DIFFERENCE="difference",an.DOT="dot",an.CROSS="cross",an.POW="pow",an.TRANSFORM_DIRECTION="transformDirection",an.MIX="mix",an.CLAMP="clamp",an.REFRACT="refract",an.SMOOTHSTEP="smoothstep",an.FACEFORWARD="faceforward";const NC=ut(1e-6),Yk=ut(1e6),N_=ut(Math.PI),Zk=ut(Math.PI*2),PC=ci(an,an.ALL).setParameterLength(1),IC=ci(an,an.ANY).setParameterLength(1),LC=ci(an,an.RADIANS).setParameterLength(1),DC=ci(an,an.DEGREES).setParameterLength(1),cM=ci(an,an.EXP).setParameterLength(1),zg=ci(an,an.EXP2).setParameterLength(1),P_=ci(an,an.LOG).setParameterLength(1),Ih=ci(an,an.LOG2).setParameterLength(1),Lh=ci(an,an.SQRT).setParameterLength(1),uM=ci(an,an.INVERSE_SQRT).setParameterLength(1),Dh=ci(an,an.FLOOR).setParameterLength(1),I_=ci(an,an.CEIL).setParameterLength(1),Nd=ci(an,an.NORMALIZE).setParameterLength(1),Pd=ci(an,an.FRACT).setParameterLength(1),Xc=ci(an,an.SIN).setParameterLength(1),Id=ci(an,an.COS).setParameterLength(1),OC=ci(an,an.TAN).setParameterLength(1),FC=ci(an,an.ASIN).setParameterLength(1),hM=ci(an,an.ACOS).setParameterLength(1),L_=ci(an,an.ATAN).setParameterLength(1,2),Oo=ci(an,an.ABS).setParameterLength(1),lv=ci(an,an.SIGN).setParameterLength(1),Oh=ci(an,an.LENGTH).setParameterLength(1),BC=ci(an,an.NEGATE).setParameterLength(1),UC=ci(an,an.ONE_MINUS).setParameterLength(1),dM=ci(an,an.DFDX).setParameterLength(1),fM=ci(an,an.DFDY).setParameterLength(1),kC=ci(an,an.ROUND).setParameterLength(1),zC=ci(an,an.RECIPROCAL).setParameterLength(1),pM=ci(an,an.TRUNC).setParameterLength(1),VC=ci(an,an.FWIDTH).setParameterLength(1),GC=ci(an,an.TRANSPOSE).setParameterLength(1),WC=ci(an,an.DETERMINANT).setParameterLength(1),HC=ci(an,an.INVERSE).setParameterLength(1),$C=(r,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),aM(r,e)),Sc=ci(an,an.MIN).setParameterLength(2,1/0),ga=ci(an,an.MAX).setParameterLength(2,1/0),D_=ci(an,an.STEP).setParameterLength(2),jC=ci(an,an.REFLECT).setParameterLength(2),XC=ci(an,an.DISTANCE).setParameterLength(2),qC=ci(an,an.DIFFERENCE).setParameterLength(2),Uf=ci(an,an.DOT).setParameterLength(2),O_=ci(an,an.CROSS).setParameterLength(2),wu=ci(an,an.POW).setParameterLength(2),mM=r=>Kr(r,r),YC=r=>Kr(r,r,r),ZC=r=>Kr(r,r,r,r),KC=ci(an,an.TRANSFORM_DIRECTION).setParameterLength(2),JC=r=>Kr(lv(r),wu(Oo(r),1/3)),gM=r=>Uf(r,r),Hs=ci(an,an.MIX).setParameterLength(3),Mu=(r,e=0,t=1)=>Cn(new an(an.CLAMP,Cn(r),Cn(e),Cn(t))),yM=r=>Mu(r),vM=ci(an,an.REFRACT).setParameterLength(3),Su=ci(an,an.SMOOTHSTEP).setParameterLength(3),xM=ci(an,an.FACEFORWARD).setParameterLength(3),QC=Kt(([r])=>{const n=43758.5453,s=Uf(r.xy,Bn(12.9898,78.233)),o=av(s,N_);return Pd(Xc(o).mul(n))}),eR=(r,e,t)=>Hs(e,t,r),tR=(r,e,t)=>Su(e,t,r),nR=(r,e)=>D_(e,r),iR=(r,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),L_(r,e)),Kk=xM,Jk=uM;An("all",PC),An("any",IC),An("equals",$C),An("radians",LC),An("degrees",DC),An("exp",cM),An("exp2",zg),An("log",P_),An("log2",Ih),An("sqrt",Lh),An("inverseSqrt",uM),An("floor",Dh),An("ceil",I_),An("normalize",Nd),An("fract",Pd),An("sin",Xc),An("cos",Id),An("tan",OC),An("asin",FC),An("acos",hM),An("atan",L_),An("abs",Oo),An("sign",lv),An("length",Oh),An("lengthSq",gM),An("negate",BC),An("oneMinus",UC),An("dFdx",dM),An("dFdy",fM),An("round",kC),An("reciprocal",zC),An("trunc",pM),An("fwidth",VC),An("atan2",iR),An("min",Sc),An("max",ga),An("step",nR),An("reflect",jC),An("distance",XC),An("dot",Uf),An("cross",O_),An("pow",wu),An("pow2",mM),An("pow3",YC),An("pow4",ZC),An("transformDirection",KC),An("mix",eR),An("clamp",Mu),An("refract",vM),An("smoothstep",tR),An("faceForward",xM),An("difference",qC),An("saturate",yM),An("cbrt",JC),An("transpose",GC),An("determinant",WC),An("inverse",HC),An("rand",QC);class Qk extends Wi{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(n!==null){const o=n.getNodeType(e);if(e.getTypeLength(o)>e.getTypeLength(s))return o}return s}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,o=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=o,s!==null&&(e.getDataFromNode(s).parentNodeBlock=o);const a=e.context.uniformFlow,c=e.getNodeProperties(this);c.condNode=t,c.ifNode=a?n:n.context({nodeBlock:n}),c.elseNode=s?a?s:s.context({nodeBlock:s}):null}generate(e,t){const n=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:o,ifNode:a,elseNode:c}=e.getNodeProperties(this),u=e.currentFunctionNode,d=t!=="void",p=d?th(n).build(e):"";s.nodeProperty=p;const m=o.build(e,"bool");if(e.context.uniformFlow&&c!==null){const T=a.build(e,n),G=c.build(e,n),z=e.getTernary(m,T,G);return e.format(z,n,t)}e.addFlowCode(` ${e.tab}if ( ${m} ) { `).addFlowTab();let M=a.build(e,n);if(M&&(d?M=p+" = "+M+";":(M="return "+M+";",u===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),M="// "+M))),e.removeFlowTab().addFlowCode(e.tab+" "+M+` `+e.tab+"}"),c!==null){e.addFlowCode(` else { `).addFlowTab();let T=c.build(e,n);T&&(d?T=p+" = "+T+";":(T="return "+T+";",u===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),T="// "+T))),e.removeFlowTab().addFlowCode(e.tab+" "+T+` `+e.tab+`} `)}else e.addFlowCode(` `);return e.format(p,n,t)}}const wl=zr(Qk).setParameterLength(2,3);An("select",wl);class rR extends Wi{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.getContext();e.setContext(qs(qs({},e.context),this.value)),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext(qs(qs({},e.context),this.value)),this.node.build(e),e.setContext(t)}generate(e,t){const n=e.getContext();e.setContext(qs(qs({},e.context),this.value));const s=this.node.build(e,t);return e.setContext(n),s}}const cv=zr(rR).setParameterLength(1,2),sR=r=>cv(r,{uniformFlow:!0}),_M=(r,e)=>cv(r,{nodeName:e});function oR(r,e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),_M(r,e)}An("context",cv),An("label",oR),An("uniformFlow",sR),An("setName",_M);class F_ extends Wi{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}build(...e){return this.intent===!0&&e[0].getNodeProperties(this).assign!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:n,readOnly:s}=this,{renderer:o}=e,a=o.backend.isWebGPUBackend===!0;let c=!1,u=!1;s&&(c=e.isDeterministic(t),u=a?s:c);const d=e.getVectorType(this.getNodeType(e)),p=t.build(e,d),m=e.getVarFromNode(this,n,d,void 0,u),y=e.getPropertyName(m);let M=y;if(u)if(a)M=c?`const ${y}`:`let ${y}`;else{const T=t.getArrayCount(e);M=`const ${e.getVar(m.type,y,T)}`}return e.addLineFlowCode(`${M} = ${p}`,this),y}}const bM=zr(F_),aR=(r,e=null)=>bM(r,e).toStack(),lR=(r,e=null)=>bM(r,e,!0).toStack(),cR=r=>__()===null?r:bM(r).setIntent(!0).toStack();An("toVar",aR),An("toConst",lR),An("toVarIntent",cR);class ez extends Wi{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const n=this.node.build(e,...t);return e.removeSubBuild(),n}}const Vg=(r,e,t=null)=>Cn(new ez(Cn(r),e,t));class tz extends Wi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const s=this.name,o=this.getNodeType(e),a=this.interpolationType,c=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,s,o,a,c),t.node=Vg(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Yy.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Yy.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),s=this.setupVarying(e);if(n[t]===void 0){const o=this.getNodeType(e),a=e.getPropertyName(s,Yy.VERTEX);e.flowNodeFromShaderStage(Yy.VERTEX,n.node,o,a),n[t]=a}return e.getPropertyName(s)}}const Fh=zr(tz).setParameterLength(1,2),uR=r=>Fh(r);An("toVarying",Fh),An("toVertexStage",uR),An("varying",(...r)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Fh(...r))),An("vertexStage",(...r)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Fh(...r)));const hR=Kt(([r])=>{const e=r.mul(.9478672986).add(.0521327014).pow(2.4),t=r.mul(.0773993808),n=r.lessThanEqual(.04045);return Hs(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),dR=Kt(([r])=>{const e=r.pow(.41666).mul(1.055).sub(.055),t=r.mul(12.92),n=r.lessThanEqual(.0031308);return Hs(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),wM="WorkingColorSpace",nz="OutputColorSpace";class MM extends Ra{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===wM?Ki.workingColorSpace:t===nz?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let o=t;return Ki.enabled===!1||n===s||!n||!s||(Ki.getTransfer(n)===Fi&&(o=Bi(hR(o.rgb),o.a)),Ki.getPrimaries(n)!==Ki.getPrimaries(s)&&(o=Bi(Wl(Ki._getMatrix(new $r,n,s)).mul(o.rgb),o.a)),Ki.getTransfer(s)===Fi&&(o=Bi(dR(o.rgb),o.a))),o}}const fR=(r,e)=>Cn(new MM(Cn(r),wM,e)),B_=(r,e)=>Cn(new MM(Cn(r),e,wM)),iz=(r,e,t)=>Cn(new MM(Cn(r),e,t));An("workingToColorSpace",fR),An("colorSpaceToWorking",B_);let rz=class extends nm{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}};class pR extends Wi{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=rs.OBJECT}setGroup(e){return this.group=e,this}element(e){return Cn(new rz(this,Cn(e)))}setNodeType(e){const t=cr(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let s=1;sCn(new pR(r,e,t));class oz extends pR{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(or)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const mR=(r,e,t=null)=>Cn(new oz(r,e,t));class az extends Ra{static get type(){return"ToneMappingNode"}constructor(e,t=yR,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return jy(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===yt)return t;let s=null;const o=e.renderer.library.getToneMappingFunction(n);return o!==null?s=Bi(o(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),s=t),s}}const gR=(r,e,t)=>Cn(new az(r,Cn(e),Cn(t))),yR=mR("toneMappingExposure","float");An("toneMapping",(r,e,t)=>gR(e,t,r));class lz extends jw{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=s,this.usage=Ou,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,s=e.getTypeLength(t),o=this.bufferStride||s,a=this.bufferOffset,c=n.isInterleavedBuffer===!0?n:new Wu(n,o),u=new sf(c,s,a);c.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(n);let o=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=s,o=s):o=Fh(this).build(e,t),o}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const uv=(r,e=null,t=0,n=0)=>Cn(new lz(r,e,t,n)),vR=(r,e=null,t=0,n=0)=>uv(r,e,t,n).setUsage(Zd),U_=(r,e=null,t=0,n=0)=>uv(r,e,t,n).setInstanced(!0),SM=(r,e=null,t=0,n=0)=>vR(r,e,t,n).setInstanced(!0);An("toAttribute",r=>uv(r.value));class cz extends Wi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=rs.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}else{const o=e.getNodeProperties(this).outputComputeNode;if(o)return o.build(e,t)}}}const TM=(r,e=[64])=>{(e.length===0||e.length>3)&&console.error("THREE.TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;tTM(r,t).setCount(e);An("compute",xR),An("computeKernel",TM);class uz extends Wi{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const n=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const o=this.node.build(e,...t);return e.setCache(n),o}}const hv=(r,e)=>Cn(new uz(Cn(r),e));An("cache",hv);class hz extends Wi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _R=zr(hz).setParameterLength(2);An("bypass",_R);class bR extends Wi{static get type(){return"RemapNode"}constructor(e,t,n,s=ut(0),o=ut(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=s,this.outHighNode=o,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:s,outHighNode:o,doClamp:a}=this;let c=e.sub(t).div(n.sub(t));return a===!0&&(c=c.clamp()),c.mul(o.sub(s)).add(s)}}const wR=zr(bR,null,null,{doClamp:!1}).setParameterLength(3,5),MR=zr(bR).setParameterLength(3,5);An("remap",wR),An("remapClamp",MR);class k_ extends Wi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),s=this.snippet;if(n==="void")e.addLineFlowCode(s,this);else return e.format(s,n,t)}}const Ld=zr(k_).setParameterLength(1,2),SR=r=>(r?wl(r,Ld("discard")):Ld("discard")).toStack(),dz=()=>Ld("return").toStack();An("discard",SR);class fz extends Ra{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||yt,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Qo;return n!==yt&&(t=t.toneMapping(n)),s!==Qo&&s!==Ki.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const EM=(r,e=null,t=null)=>Cn(new fz(Cn(r),e,t));An("renderOutput",EM);class pz extends Ra{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,n=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",o="-".repeat(s.length);let a="";return a+="// #"+s+`# `,a+=e.flow.code.replace(/^\t/mg,"")+` `,a+="/* ... */ "+n+` /* ... */ `,a+="// #"+o+`# `,t!==null?t(e,a):console.log(a),n}}const TR=(r,e=null)=>Cn(new pz(Cn(r),e)).toStack();An("debug",TR);function mz(r){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",r)}class ER extends Wi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const s=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const o=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(o),c=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(c.name,a,n):Fh(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const rc=(r,e=null)=>Cn(new ER(r,e)),vo=(r=0)=>rc("uv"+(r>0?r:""),"vec2");class gz extends Wi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${s} )`,this.getNodeType(e),t)}}const kf=zr(gz).setParameterLength(1,2);class yz extends ov{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=rs.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:s,height:o}=n;this.value=Math.log2(Math.max(s,o))}}}const AM=zr(yz).setParameterLength(1),CM=new Wo;class Bh extends ov{static get type(){return"TextureNode"}constructor(e=CM,t=null,n=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=rs.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===as?"uvec4":this.value.type===Is?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return vo(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=cr(this.value.matrix)),this._matrixUniform.mul(qt(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?rs.OBJECT:rs.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Dt(kf(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;(s===null||e.context.forceUVContext===!0)&&e.context.getUV&&(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let o=this.levelNode;o===null&&e.context.getTextureLevel&&(o=e.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=o,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,n,s,o,a,c,u,d){const p=this.value;let m;return s?m=e.generateTextureLevel(p,t,n,s,a,d):o?m=e.generateTextureBias(p,t,n,o,a,d):u?m=e.generateTextureGrad(p,t,n,u,a,d):c?m=e.generateTextureCompare(p,t,n,c,a,d):this.sampler===!1?m=e.generateTextureLoad(p,t,n,a,d):m=e.generateTexture(p,t,n,a,d),m}generate(e,t){const n=this.value,s=e.getNodeProperties(this),o=super.generate(e,"property");if(/^sampler/.test(t))return o+"_sampler";if(e.isReference(t))return o;{const a=e.getDataFromNode(this);let c=a.propertyName;if(c===void 0){const{uvNode:p,levelNode:m,biasNode:y,compareNode:M,depthNode:T,gradNode:G,offsetNode:z}=s,I=this.generateUV(e,p),ee=m?m.build(e,"float"):null,Q=y?y.build(e,"float"):null,oe=T?T.build(e,"int"):null,_e=M?M.build(e,"float"):null,ve=G?[G[0].build(e,"vec2"),G[1].build(e,"vec2")]:null,Oe=z?this.generateOffset(e,z):null,He=e.getVarFromNode(this);c=e.getPropertyName(He);const Ce=this.generateSnippet(e,o,I,ee,Q,oe,_e,ve,Oe);e.addLineFlowCode(`${c} = ${Ce}`,this),a.snippet=Ce,a.propertyName=c}let u=c;const d=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=B_(Ld(u,d),n.colorSpace).setup(e).build(e,d)),e.format(u,d,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Cn(e).mul(AM(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===Ct||n.magFilter===Ct)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Cn(t)}level(e){const t=this.clone();return t.levelNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}size(e){return kf(this,e)}bias(e){const t=this.clone();return t.biasNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}grad(e,t){const n=this.clone();return n.gradNode=[Cn(e),Cn(t)],n.referenceNode=this.getBase(),Cn(n)}depth(e){const t=this.clone();return t.depthNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}offset(e){const t=this.clone();return t.offsetNode=Cn(e),t.referenceNode=this.getBase(),Cn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const vz=zr(Bh).setParameterLength(1,4).setName("texture"),Ps=(r=CM,e=null,t=null,n=null)=>{let s;return r&&r.isTextureNode===!0?(s=Cn(r.clone()),s.referenceNode=r.getBase(),e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=vz(r,e,t,n),s},xz=(r=CM)=>Ps(r),Na=(...r)=>Ps(...r).setSampler(!1),_z=r=>(r.isNode===!0?r:Ps(r)).convert("sampler"),bz=r=>(r.isNode===!0?r:Ps(r)).convert("samplerComparison");class RM extends ov{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const dv=(r,e,t)=>Cn(new RM(r,e,t));class wz extends nm{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,n)}}class Mz extends RM{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Rd(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=rs.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let s=0;sCn(new Mz(r,e));class Sz extends Wi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Dd=zr(Sz).setParameterLength(1);let fv,pv;class Fo extends Wi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Fo.DPR?"float":this.scope===Fo.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=rs.NONE;return(this.scope===Fo.SIZE||this.scope===Fo.VIEWPORT||this.scope===Fo.DPR)&&(e=rs.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Fo.VIEWPORT?t!==null?pv.copy(t.viewport):(e.getViewport(pv),pv.multiplyScalar(e.getPixelRatio())):this.scope===Fo.DPR?this._output.value=e.getPixelRatio():t!==null?(fv.width=t.width,fv.height=t.height):e.getDrawingBufferSize(fv)}setup(){const e=this.scope;let t=null;return e===Fo.SIZE?t=cr(fv||(fv=new yn)):e===Fo.VIEWPORT?t=cr(pv||(pv=new mr)):e===Fo.DPR?t=cr(1):t=Bn(mv.div(lm)),this._output=t,t}generate(e){if(this.scope===Fo.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(lm).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Fo.COORDINATE="coordinate",Fo.VIEWPORT="viewport",Fo.SIZE="size",Fo.UV="uv",Fo.DPR="dpr";const AR=xi(Fo,Fo.DPR),Od=xi(Fo,Fo.UV),lm=xi(Fo,Fo.SIZE),mv=xi(Fo,Fo.COORDINATE),Gg=xi(Fo,Fo.VIEWPORT),NM=Gg.zw,CR=mv.sub(Gg.xy),Tz=CR.div(NM),Ez=Kt(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),lm),"vec2").once()(),zf=cr(0,"uint").setName("u_cameraIndex").setGroup(R_("cameraIndex")).toVarying("v_cameraIndex"),Fd=cr("float").setName("cameraNear").setGroup(or).onRenderUpdate(({camera:r})=>r.near),Bd=cr("float").setName("cameraFar").setGroup(or).onRenderUpdate(({camera:r})=>r.far),Tu=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.projectionMatrix);e=Hl(t).setGroup(or).setName("cameraProjectionMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraProjectionMatrix")}else e=cr("mat4").setName("cameraProjectionMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),Az=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.projectionMatrixInverse);e=Hl(t).setGroup(or).setName("cameraProjectionMatricesInverse").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraProjectionMatrixInverse")}else e=cr("mat4").setName("cameraProjectionMatrixInverse").setGroup(or).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),qc=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.matrixWorldInverse);e=Hl(t).setGroup(or).setName("cameraViewMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraViewMatrix")}else e=cr("mat4").setName("cameraViewMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),Cz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.matrixWorld);e=Hl(t).setGroup(or).setName("cameraWorldMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraWorldMatrix")}else e=cr("mat4").setName("cameraWorldMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),Rz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.normalMatrix);e=Hl(t).setGroup(or).setName("cameraNormalMatrices").element(r.isMultiViewCamera?Dd("gl_ViewID_OVR"):zf).toConst("cameraNormalMatrix")}else e=cr("mat3").setName("cameraNormalMatrix").setGroup(or).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),gv=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(let s=0,o=r.cameras.length;s{const a=s.cameras,c=o.array;for(let u=0,d=a.length;un.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),Nz=Kt(({camera:r})=>{let e;if(r.isArrayCamera&&r.cameras.length>0){const t=[];for(const s of r.cameras)t.push(s.viewport);e=Hl(t,"vec4").setGroup(or).setName("cameraViewports").element(zf).toConst("cameraViewport")}else e=Bi(0,0,lm.x,lm.y).toConst("cameraViewport");return e}).once()(),RR=new we;class Fs extends Wi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=rs.OBJECT,this.uniformNode=new ov(null)}getNodeType(){const e=this.scope;if(e===Fs.WORLD_MATRIX)return"mat4";if(e===Fs.POSITION||e===Fs.VIEW_POSITION||e===Fs.DIRECTION||e===Fs.SCALE)return"vec3";if(e===Fs.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,s=this.scope;if(s===Fs.WORLD_MATRIX)n.value=t.matrixWorld;else if(s===Fs.POSITION)n.value=n.value||new ot,n.value.setFromMatrixPosition(t.matrixWorld);else if(s===Fs.SCALE)n.value=n.value||new ot,n.value.setFromMatrixScale(t.matrixWorld);else if(s===Fs.DIRECTION)n.value=n.value||new ot,t.getWorldDirection(n.value);else if(s===Fs.VIEW_POSITION){const o=e.camera;n.value=n.value||new ot,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(o.matrixWorldInverse)}else if(s===Fs.RADIUS){const o=e.object.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),RR.copy(o.boundingSphere).applyMatrix4(t.matrixWorld),n.value=RR.radius}}generate(e){const t=this.scope;return t===Fs.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Fs.POSITION||t===Fs.VIEW_POSITION||t===Fs.DIRECTION||t===Fs.SCALE?this.uniformNode.nodeType="vec3":t===Fs.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Fs.WORLD_MATRIX="worldMatrix",Fs.POSITION="position",Fs.SCALE="scale",Fs.VIEW_POSITION="viewPosition",Fs.DIRECTION="direction",Fs.RADIUS="radius";const Pz=zr(Fs,Fs.DIRECTION).setParameterLength(1),Iz=zr(Fs,Fs.WORLD_MATRIX).setParameterLength(1),NR=zr(Fs,Fs.POSITION).setParameterLength(1),Lz=zr(Fs,Fs.SCALE).setParameterLength(1),Dz=zr(Fs,Fs.VIEW_POSITION).setParameterLength(1),Oz=zr(Fs,Fs.RADIUS).setParameterLength(1);class Eu extends Fs{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Fz=xi(Eu,Eu.DIRECTION),Au=xi(Eu,Eu.WORLD_MATRIX),Bz=xi(Eu,Eu.POSITION),Uz=xi(Eu,Eu.SCALE),kz=xi(Eu,Eu.VIEW_POSITION),PR=xi(Eu,Eu.RADIUS),IR=cr(new $r).onObjectUpdate(({object:r},e)=>e.value.getNormalMatrix(r.matrixWorld)),zz=cr(new Ft).onObjectUpdate(({object:r},e)=>e.value.copy(r.matrixWorld).invert()),Ud=Kt(r=>r.renderer.overrideNodes.modelViewMatrix||LR).once()().toVar("modelViewMatrix"),LR=qc.mul(Au),PM=Kt(r=>(r.context.isHighPrecisionModelViewMatrix=!0,cr("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),IM=Kt(r=>{const e=r.context.isHighPrecisionModelViewMatrix;return cr("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Pl=rc("position","vec3"),Pa=Pl.toVarying("positionLocal"),z_=Pl.toVarying("positionPrevious"),Yc=Kt(r=>Au.mul(Pa).xyz.toVarying(r.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),LM=Kt(()=>Pa.transformDirection(Au).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Ia=Kt(r=>r.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Vo=Ia.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Vz extends Wi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===K?"false":e.getFrontFacing()}}const DR=xi(Vz),DM=ut(DR).mul(2).sub(1),Wg=Kt(([r],{material:e})=>{const t=e.side;return t===K?r=r.mul(-1):t===re&&(r=r.mul(DM)),r}),V_=rc("normal","vec3"),Tc=Kt(r=>r.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),qt(0,1,0)):V_,"vec3").once()().toVar("normalLocal"),OR=Ia.dFdx().cross(Ia.dFdy()).normalize().toVar("normalFlat"),Hg=Kt(r=>{let e;return r.material.flatShading===!0?e=OR:e=OM(Tc).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),FR=Kt(r=>{let e=Hg.transformDirection(qc);return r.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),fo=Kt(({subBuildFn:r,material:e,context:t})=>{let n;return r==="NORMAL"||r==="VERTEX"?(n=Hg,e.flatShading!==!0&&(n=Wg(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Vf=fo.transformDirection(qc).toVar("normalWorld"),cm=Kt(({subBuildFn:r,context:e})=>{let t;return r==="NORMAL"||r==="VERTEX"?t=fo:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),BR=Kt(([r,e=Au])=>{const t=Wl(e),n=r.div(qt(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),OM=Kt(([r],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(r);const n=IR.mul(r);return qc.transformDirection(n)}),Gz=Kt(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),fo)).once(["NORMAL","VERTEX"])(),Wz=Kt(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Vf)).once(["NORMAL","VERTEX"])(),Hz=Kt(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),cm)).once(["NORMAL","VERTEX"])(),UR=new Qi,FM=new Ft,kR=cr(0).onReference(({material:r})=>r).onObjectUpdate(({material:r})=>r.refractionRatio),G_=cr(1).onReference(({material:r})=>r).onObjectUpdate(function({material:r,scene:e}){return r.envMap?r.envMapIntensity:e.environmentIntensity}),BM=cr(new Ft).onReference(function(r){return r.material}).onObjectUpdate(function({material:r,scene:e}){const t=e.environment!==null&&r.envMap===null?e.environmentRotation:r.envMapRotation;return t?(UR.copy(t),FM.makeRotationFromEuler(UR)):FM.identity(),FM}),zR=Vo.negate().reflect(fo),VR=Vo.negate().refract(fo,kR),GR=zR.transformDirection(qc).toVar("reflectVector"),WR=VR.transformDirection(qc).toVar("reflectVector"),HR=new ph;class $z extends Bh{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,s=null){super(e,t,n,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Fe?GR:e.mapping===Xe?WR:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),qt(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return(e.renderer.coordinateSystem===ja||!n.isRenderTargetTexture)&&(t=qt(t.x.negate(),t.yz)),BM.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const UM=zr($z).setParameterLength(1,4).setName("cubeTexture"),$g=(r=HR,e=null,t=null,n=null)=>{let s;return r&&r.isCubeTextureNode===!0?(s=Cn(r.clone()),s.referenceNode=r,e!==null&&(s.uvNode=Cn(e)),t!==null&&(s.levelNode=Cn(t)),n!==null&&(s.biasNode=Cn(n))):s=UM(r,e,t,n),s},jz=(r=HR)=>UM(r);class Xz extends nm{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,n,s)}}class W_ extends Wi{static get type(){return"ReferenceNode"}constructor(e,t,n=null,s=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=s,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=rs.OBJECT}element(e){return Cn(new Xz(this,Cn(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=dv(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Hl(null,e):e==="texture"?t=Ps(null):e==="cubeTexture"?t=$g(null):t=cr(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let s=1;sCn(new W_(r,e,t)),kM=(r,e,t,n)=>Cn(new W_(r,e,n,t));class qz extends W_{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const kd=(r,e,t=null)=>Cn(new qz(r,e,t)),$R=vo(),Yz=Ia.dFdx(),Zz=Ia.dFdy(),jR=$R.dFdx(),XR=$R.dFdy(),qR=fo,YR=Zz.cross(qR),ZR=qR.cross(Yz),zM=YR.mul(jR.x).add(ZR.mul(XR.x)),VM=YR.mul(jR.y).add(ZR.mul(XR.y)),KR=zM.dot(zM).max(VM.dot(VM)),JR=KR.equal(0).select(0,KR.inverseSqrt()),Kz=zM.mul(JR).toVar("tangentViewFrame"),Jz=VM.mul(JR).toVar("bitangentViewFrame"),H_=Kt(r=>(r.geometry.hasAttribute("tangent")===!1&&r.geometry.computeTangents(),rc("tangent","vec4")))(),yv=H_.xyz.toVar("tangentLocal"),$_=Kt(({subBuildFn:r,geometry:e,material:t})=>{let n;return r==="VERTEX"||e.hasAttribute("tangent")?n=Ud.mul(Bi(yv,0)).xyz.toVarying("v_tangentView").normalize():n=Kz,t.flatShading!==!0&&(n=Wg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),QR=$_.transformDirection(qc).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),j_=Kt(([r,e],{subBuildFn:t,material:n})=>{let s=r.mul(H_.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(s=s.toVarying(e)),s}).once(["NORMAL"]),Qz=j_(V_.cross(H_),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),e4=j_(Tc.cross(yv),"v_bitangentLocal").normalize().toVar("bitangentLocal"),e2=Kt(({subBuildFn:r,geometry:e,material:t})=>{let n;return r==="VERTEX"||e.hasAttribute("tangent")?n=j_(fo.cross($_),"v_bitangentView").normalize():n=Jz,t.flatShading!==!0&&(n=Wg(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),t4=j_(Vf.cross(QR),"v_bitangentWorld").normalize().toVar("bitangentWorld"),um=Wl($_,e2,fo).toVar("TBNViewMatrix"),t2=Vo.mul(um),n4=(r,e)=>r.sub(t2.mul(e)),n2=Kt(()=>{let r=om.cross(Vo);return r=r.cross(om).normalize(),r=Hs(r,fo,Bf.mul(Ph.oneMinus()).oneMinus().pow2().pow2()).normalize(),r}).once()();class i4 extends Ra{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=$a}setup({material:e}){const{normalMapType:t,scaleNode:n}=this;let s=this.node.mul(2).sub(1);if(n!==null){let a=n;e.flatShading===!0&&(a=Wg(a)),s=qt(s.xy.mul(a),s.z)}let o=null;return t===jd?o=OM(s):t===$a?o=um.mul(s).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),o=fo),o}}const GM=zr(i4).setParameterLength(1,2),r4=Kt(({textureNode:r,bumpScale:e})=>{const t=s=>r.cache().context({getUV:o=>s(o.uvNode||vo()),forceUVContext:!0}),n=ut(t(s=>s));return Bn(ut(t(s=>s.add(s.dFdx()))).sub(n),ut(t(s=>s.add(s.dFdy()))).sub(n)).mul(e)}),s4=Kt(r=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=r,s=e.dFdx().normalize(),o=e.dFdy().normalize(),a=t,c=o.cross(a),u=a.cross(s),d=s.dot(c).mul(DM),p=d.sign().mul(n.x.mul(c).add(n.y.mul(u)));return d.abs().mul(t).sub(p).normalize()});class o4 extends Ra{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=r4({textureNode:this.textureNode,bumpScale:e});return s4({surf_pos:Ia,surf_norm:fo,dHdxy:t})}}const WM=zr(o4).setParameterLength(1,2),i2=new Map;class Ln extends Wi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=i2.get(e);return n===void 0&&(n=kd(e,t),i2.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let s=null;if(n===Ln.COLOR){const o=t.color!==void 0?this.getColor(n):qt();t.map&&t.map.isTexture===!0?s=o.mul(this.getTexture("map")):s=o}else if(n===Ln.OPACITY){const o=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?s=o.mul(this.getTexture("alpha")):s=o}else if(n===Ln.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=ut(1);else if(n===Ln.SPECULAR_INTENSITY){const o=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?s=o.mul(this.getTexture(n).a):s=o}else if(n===Ln.SPECULAR_COLOR){const o=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?s=o.mul(this.getTexture(n).rgb):s=o}else if(n===Ln.ROUGHNESS){const o=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).g):s=o}else if(n===Ln.METALNESS){const o=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?s=o.mul(this.getTexture(n).b):s=o}else if(n===Ln.EMISSIVE){const o=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(o);t.emissiveMap&&t.emissiveMap.isTexture===!0?s=a.mul(this.getTexture(n)):s=a}else if(n===Ln.NORMAL)t.normalMap?(s=GM(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):t.bumpMap?s=WM(this.getTexture("bump").r,this.getFloat("bumpScale")):s=fo;else if(n===Ln.CLEARCOAT){const o=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.CLEARCOAT_ROUGHNESS){const o=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.CLEARCOAT_NORMAL)t.clearcoatNormalMap?s=GM(this.getTexture(n),this.getCache(n+"Scale","vec2")):s=fo;else if(n===Ln.SHEEN){const o=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?s=o.mul(this.getTexture("sheenColor").rgb):s=o}else if(n===Ln.SHEEN_ROUGHNESS){const o=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?s=o.mul(this.getTexture(n).a):s=o,s=s.clamp(.07,1)}else if(n===Ln.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const o=this.getTexture(n);s=w_(jg.x,jg.y,jg.y.negate(),jg.x).mul(o.rg.mul(2).sub(Bn(1)).normalize().mul(o.b))}else s=jg;else if(n===Ln.IRIDESCENCE_THICKNESS){const o=No("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=No("0","float",t.iridescenceThicknessRange);s=o.sub(a).mul(this.getTexture(n).g).add(a)}else s=o}else if(n===Ln.TRANSMISSION){const o=this.getFloat(n);t.transmissionMap?s=o.mul(this.getTexture(n).r):s=o}else if(n===Ln.THICKNESS){const o=this.getFloat(n);t.thicknessMap?s=o.mul(this.getTexture(n).g):s=o}else if(n===Ln.IOR)s=this.getFloat(n);else if(n===Ln.LIGHT_MAP)s=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===Ln.AO)s=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===Ln.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(n):ut(0);else{const o=this.getNodeType(e);s=this.getCache(n,o)}return s}}Ln.ALPHA_TEST="alphaTest",Ln.COLOR="color",Ln.OPACITY="opacity",Ln.SHININESS="shininess",Ln.SPECULAR="specular",Ln.SPECULAR_STRENGTH="specularStrength",Ln.SPECULAR_INTENSITY="specularIntensity",Ln.SPECULAR_COLOR="specularColor",Ln.REFLECTIVITY="reflectivity",Ln.ROUGHNESS="roughness",Ln.METALNESS="metalness",Ln.NORMAL="normal",Ln.CLEARCOAT="clearcoat",Ln.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Ln.CLEARCOAT_NORMAL="clearcoatNormal",Ln.EMISSIVE="emissive",Ln.ROTATION="rotation",Ln.SHEEN="sheen",Ln.SHEEN_ROUGHNESS="sheenRoughness",Ln.ANISOTROPY="anisotropy",Ln.IRIDESCENCE="iridescence",Ln.IRIDESCENCE_IOR="iridescenceIOR",Ln.IRIDESCENCE_THICKNESS="iridescenceThickness",Ln.IOR="ior",Ln.TRANSMISSION="transmission",Ln.THICKNESS="thickness",Ln.ATTENUATION_DISTANCE="attenuationDistance",Ln.ATTENUATION_COLOR="attenuationColor",Ln.LINE_SCALE="scale",Ln.LINE_DASH_SIZE="dashSize",Ln.LINE_GAP_SIZE="gapSize",Ln.LINE_WIDTH="linewidth",Ln.LINE_DASH_OFFSET="dashOffset",Ln.POINT_SIZE="size",Ln.DISPERSION="dispersion",Ln.LIGHT_MAP="light",Ln.AO="ao";const r2=xi(Ln,Ln.ALPHA_TEST),X_=xi(Ln,Ln.COLOR),s2=xi(Ln,Ln.SHININESS),o2=xi(Ln,Ln.EMISSIVE),q_=xi(Ln,Ln.OPACITY),a2=xi(Ln,Ln.SPECULAR),HM=xi(Ln,Ln.SPECULAR_INTENSITY),l2=xi(Ln,Ln.SPECULAR_COLOR),vv=xi(Ln,Ln.SPECULAR_STRENGTH),Y_=xi(Ln,Ln.REFLECTIVITY),c2=xi(Ln,Ln.ROUGHNESS),u2=xi(Ln,Ln.METALNESS),h2=xi(Ln,Ln.NORMAL),d2=xi(Ln,Ln.CLEARCOAT),f2=xi(Ln,Ln.CLEARCOAT_ROUGHNESS),p2=xi(Ln,Ln.CLEARCOAT_NORMAL),m2=xi(Ln,Ln.ROTATION),g2=xi(Ln,Ln.SHEEN),y2=xi(Ln,Ln.SHEEN_ROUGHNESS),v2=xi(Ln,Ln.ANISOTROPY),x2=xi(Ln,Ln.IRIDESCENCE),_2=xi(Ln,Ln.IRIDESCENCE_IOR),b2=xi(Ln,Ln.IRIDESCENCE_THICKNESS),w2=xi(Ln,Ln.TRANSMISSION),M2=xi(Ln,Ln.THICKNESS),S2=xi(Ln,Ln.IOR),T2=xi(Ln,Ln.ATTENUATION_DISTANCE),E2=xi(Ln,Ln.ATTENUATION_COLOR),$M=xi(Ln,Ln.LINE_SCALE),jM=xi(Ln,Ln.LINE_DASH_SIZE),XM=xi(Ln,Ln.LINE_GAP_SIZE),Z_=xi(Ln,Ln.LINE_WIDTH),qM=xi(Ln,Ln.LINE_DASH_OFFSET),A2=xi(Ln,Ln.POINT_SIZE),C2=xi(Ln,Ln.DISPERSION),YM=xi(Ln,Ln.LIGHT_MAP),R2=xi(Ln,Ln.AO),jg=cr(new yn).onReference(function(r){return r.material}).onRenderUpdate(function({material:r}){this.value.set(r.anisotropy*Math.cos(r.anisotropyRotation),r.anisotropy*Math.sin(r.anisotropyRotation))}),ZM=Kt(r=>r.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Zo extends Wi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let s;if(n===Zo.VERTEX)s=e.getVertexIndex();else if(n===Zo.INSTANCE)s=e.getInstanceIndex();else if(n===Zo.DRAW)s=e.getDrawIndex();else if(n===Zo.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(n===Zo.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(n===Zo.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let o;return e.shaderStage==="vertex"||e.shaderStage==="compute"?o=s:o=Fh(this).build(e,t),o}}Zo.VERTEX="vertex",Zo.INSTANCE="instance",Zo.SUBGROUP="subgroup",Zo.INVOCATION_LOCAL="invocationLocal",Zo.INVOCATION_SUBGROUP="invocationSubgroup",Zo.DRAW="draw";const N2=xi(Zo,Zo.VERTEX),Gf=xi(Zo,Zo.INSTANCE),a4=xi(Zo,Zo.SUBGROUP),l4=xi(Zo,Zo.INVOCATION_SUBGROUP),c4=xi(Zo,Zo.INVOCATION_LOCAL),P2=xi(Zo,Zo.DRAW);class I2 extends Wi{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=rs.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{instanceMatrix:t,instanceColor:n}=this,{count:s}=t;let{instanceMatrixNode:o,instanceColorNode:a}=this;if(o===null){if(s<=1e3)o=dv(t.array,"mat4",Math.max(s,1)).element(Gf);else{const u=new nw(t.array,16,1);this.buffer=u;const d=t.usage===Zd?SM:U_,p=[d(u,"vec4",16,0),d(u,"vec4",16,4),d(u,"vec4",16,8),d(u,"vec4",16,12)];o=rm(...p)}this.instanceMatrixNode=o}if(n&&a===null){const u=new kc(n.array,3),d=n.usage===Zd?SM:U_;this.bufferColor=u,a=qt(d(u,"vec3",3,0)),this.instanceColorNode=a}const c=o.mul(Pa).xyz;if(Pa.assign(c),e.hasGeometryAttribute("normal")){const u=BR(Tc,o);Tc.assign(u)}this.instanceColorNode!==null&&$c("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Zd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Zd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const u4=zr(I2).setParameterLength(2,3);class h4 extends I2{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:s}=e;super(t,n,s),this.instancedMesh=e}}const L2=zr(h4).setParameterLength(1);class d4 extends Wi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Gf:this.batchingIdNode=P2);const n=Kt(([T])=>{const G=Dt(kf(Na(this.batchMesh._indirectTexture),0).x),z=Dt(T).mod(G),I=Dt(T).div(G);return Na(this.batchMesh._indirectTexture,pl(z,I)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Dt(this.batchingIdNode)),s=this.batchMesh._matricesTexture,o=Dt(kf(Na(s),0).x),a=ut(n).mul(4).toInt().toVar(),c=a.mod(o),u=a.div(o),d=rm(Na(s,pl(c,u)),Na(s,pl(c.add(1),u)),Na(s,pl(c.add(2),u)),Na(s,pl(c.add(3),u))),p=this.batchMesh._colorsTexture;if(p!==null){const G=Kt(([z])=>{const I=Dt(kf(Na(p),0).x),ee=z,Q=ee.mod(I),oe=ee.div(I);return Na(p,pl(Q,oe)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);$c("vec3","vBatchColor").assign(G)}const m=Wl(d);Pa.assign(d.mul(Pa));const y=Tc.div(qt(m[0].dot(m[0]),m[1].dot(m[1]),m[2].dot(m[2]))),M=m.mul(y).xyz;Tc.assign(M),e.hasGeometryAttribute("tangent")&&yv.mulAssign(m)}}const D2=zr(d4).setParameterLength(1);class f4 extends nm{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),s!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}const p4=zr(f4).setParameterLength(2);class m4 extends RM{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let s,o=null;t&&t.isStruct?(s="struct",o=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=kw(e.itemSize),n=e.count):s=t,super(e,s,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=Nl.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return p4(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Nl.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=uv(this.value),this._varying=Fh(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),s=n.build(e);return e.registerTransform(s,t),s}}const hm=(r,e=null,t=0)=>Cn(new m4(r,e,t)),g4=(r,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),hm(r,e,t).setPBO(!0)),O2=new WeakMap;class F2 extends Wi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=rs.OBJECT,this.skinIndexNode=rc("skinIndex","uvec4"),this.skinWeightNode=rc("skinWeight","vec4"),this.bindMatrixNode=No("bindMatrix","mat4"),this.bindMatrixInverseNode=No("bindMatrixInverse","mat4"),this.boneMatricesNode=kM("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Pa,this.toPositionNode=Pa,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w),m=o.mul(t),y=Wa(c.mul(s.x).mul(m),u.mul(s.y).mul(m),d.mul(s.z).mul(m),p.mul(s.w).mul(m));return a.mul(y).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Tc){const{skinIndexNode:n,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w);let m=Wa(s.x.mul(c),s.y.mul(u),s.z.mul(d),s.w.mul(p));return m=a.mul(m).mul(o),m.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=kM("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,z_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||Vw(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&z_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Tc.assign(n),e.hasGeometryAttribute("tangent")&&yv.assign(n)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;O2.get(t)!==e.frameId&&(O2.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const B2=r=>Cn(new F2(r)),y4=(r,e=null)=>{const t=new F2(r);return t.positionNode=hm(new kc(r.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Gf).toVar(),t.skinIndexNode=hm(new kc(new Uint32Array(r.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Gf).toVar(),t.skinWeightNode=hm(new kc(r.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Gf).toVar(),t.bindMatrixNode=cr(r.bindMatrix,"mat4"),t.bindMatrixInverseNode=cr(r.bindMatrixInverse,"mat4"),t.boneMatricesNode=dv(r.skeleton.boneMatrices,"mat4",r.skeleton.bones.length),t.toPositionNode=e,Cn(t)};class v4 extends Wi{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let a=0,c=this.params.length-1;aNumber(y)?G=">=":G="<"));let I;if(p)I=`while ( ${y} )`;else{const ee={start:m,end:y},Q=ee.start,oe=ee.end;let _e;const ve=()=>G.includes("<")?"+=":"-=";if(z!=null)switch(typeof z){case"function":_e=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_e=M+" "+ve()+" "+e.generateConst(T,z);break;case"string":_e=M+" "+z;break;default:z.isNode?_e=M+" "+ve()+" "+z.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),_e="break /* invalid update */")}else T==="int"||T==="uint"?z=G.includes("<")?"++":"--":z=ve()+" 1.",_e=M+" "+z;const Oe=e.getVar(T,M)+" = "+Q,He=M+" "+G+" "+oe;I=`for ( ${Oe}; ${He}; ${_e} )`}e.addFlowCode((c===0?` `:"")+e.tab+I+` { `).addFlowTab()}const o=s.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` `+e.tab+o);for(let c=0,u=this.params.length-1;cCn(new v4(im(r,"int"))).toStack(),x4=()=>Ld("continue").toStack(),U2=()=>Ld("break").toStack(),KM=new WeakMap,Zc=new mr,k2=Kt(({bufferMap:r,influence:e,stride:t,width:n,depth:s,offset:o})=>{const a=Dt(N2).mul(t).add(o),c=a.div(n),u=a.sub(c.mul(n));return Na(r,pl(u,c)).depth(s).xyz.mul(e)});function _4(r){const e=r.morphAttributes.position!==void 0,t=r.morphAttributes.normal!==void 0,n=r.morphAttributes.color!==void 0,s=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,o=s!==void 0?s.length:0;let a=KM.get(r);if(a===void 0||a.count!==o){let I=function(){G.dispose(),KM.delete(r),r.removeEventListener("dispose",I)};a!==void 0&&a.texture.dispose();const c=r.morphAttributes.position||[],u=r.morphAttributes.normal||[],d=r.morphAttributes.color||[];let p=0;e===!0&&(p=1),t===!0&&(p=2),n===!0&&(p=3);let m=r.attributes.position.count*p,y=1;const M=4096;m>M&&(y=Math.ceil(m/M),m=M);const T=new Float32Array(m*y*4*o),G=new Jd(T,m,y,o);G.type=gs,G.needsUpdate=!0;const z=p*4;for(let ee=0;ee{const y=ut(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?y.assign(Na(this.mesh.morphTexture,pl(Dt(m).add(1),Dt(Gf))).r):y.assign(No("morphTargetInfluences","float").element(m).toVar()),sr(y.notEqual(0),()=>{n===!0&&Pa.addAssign(k2({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:Dt(0)})),s===!0&&Tc.addAssign(k2({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:Dt(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const z2=zr(b4).setParameterLength(1);class Xg extends Wi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class w4 extends Xg{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class M4 extends rR{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,s=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=qt().toVar("directDiffuse"),s=qt().toVar("directSpecular"),o=qt().toVar("indirectDiffuse"),a=qt().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:s,indirectDiffuse:o,indirectSpecular:a};return{radiance:qt().toVar("radiance"),irradiance:qt().toVar("irradiance"),iblIrradiance:qt().toVar("iblIrradiance"),ambientOcclusion:ut(1).toVar("ambientOcclusion"),reflectedLight:c,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const V2=zr(M4);class S4 extends Xg{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const qg=new yn;class K_ extends Bh{static get type(){return"ViewportTextureNode"}constructor(e=Od,t=null,n=null){let s=null;n===null?(s=new bp,s.minFilter=Qn,n=s):s=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=rs.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){const s=t.clone();n.set(e,s)}return n.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(qg):qg.set(n.width,n.height);const s=this.getTextureForReference(n);(s.image.width!==qg.width||s.image.height!==qg.height)&&(s.image.width=qg.width,s.image.height=qg.height,s.needsUpdate=!0);const o=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=o}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const T4=zr(K_).setParameterLength(0,3),JM=zr(K_,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let J_=null;class E4 extends K_{static get type(){return"ViewportDepthTextureNode"}constructor(e=Od,t=null){J_===null&&(J_=new gc),super(e,t,J_)}getTextureForReference(){return J_}}const QM=zr(E4).setParameterLength(0,2);class Ec extends Wi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ec.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let s=null;if(t===Ec.DEPTH_BASE)n!==null&&(s=G2().assign(n));else if(t===Ec.DEPTH)e.isPerspectiveCamera?s=eS(Ia.z,Fd,Bd):s=Yg(Ia.z,Fd,Bd);else if(t===Ec.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const o=tS(n,Fd,Bd);s=Yg(o,Fd,Bd)}else s=n;else s=Yg(Ia.z,Fd,Bd);return s}}Ec.DEPTH_BASE="depthBase",Ec.DEPTH="depth",Ec.LINEAR_DEPTH="linearDepth";const Yg=(r,e,t)=>r.add(e).div(e.sub(t)),A4=(r,e,t)=>e.sub(t).mul(r).sub(e),eS=(r,e,t)=>e.add(r).mul(t).div(t.sub(e).mul(r)),tS=(r,e,t)=>e.mul(t).div(t.sub(e).mul(r).sub(t)),nS=(r,e,t)=>{e=e.max(1e-6).toVar();const n=Ih(r.negate().div(e)),s=Ih(t.div(e));return n.div(s)},C4=(r,e,t)=>{const n=r.mul(P_(t.div(e)));return ut(Math.E).pow(n).mul(e).negate()},G2=zr(Ec,Ec.DEPTH_BASE),iS=xi(Ec,Ec.DEPTH),Zg=zr(Ec,Ec.LINEAR_DEPTH).setParameterLength(0,1),R4=Zg(QM());iS.assign=r=>G2(r);class Cu extends Wi{static get type(){return"ClippingNode"}constructor(e=Cu.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Cu.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,s):this.scope===Cu.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(n,s)}setupAlphaToCoverage(e,t){return Kt(()=>{const n=ut().toVar("distanceToPlane"),s=ut().toVar("distanceToGradient"),o=ut(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Hl(t).setGroup(or);po(a,({i:d})=>{const p=u.element(d);n.assign(Ia.dot(p.xyz).negate().add(p.w)),s.assign(n.fwidth().div(2)),o.mulAssign(Su(s.negate(),s,n))})}const c=e.length;if(c>0){const u=Hl(e).setGroup(or),d=ut(1).toVar("intersectionClipOpacity");po(c,({i:p})=>{const m=u.element(p);n.assign(Ia.dot(m.xyz).negate().add(m.w)),s.assign(n.fwidth().div(2)),d.mulAssign(Su(s.negate(),s,n).oneMinus())}),o.mulAssign(d.oneMinus())}to.a.mulAssign(o),to.a.equal(0).discard()})()}setupDefault(e,t){return Kt(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const o=Hl(t).setGroup(or);po(n,({i:a})=>{const c=o.element(a);Ia.dot(c.xyz).greaterThan(c.w).discard()})}const s=e.length;if(s>0){const o=Hl(e).setGroup(or),a=bu(!0).toVar("clipped");po(s,({i:c})=>{const u=o.element(c);a.assign(Ia.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Kt(()=>{const s=Hl(e).setGroup(or),o=Dd(t.getClipDistance());po(n,({i:a})=>{const c=s.element(a),u=Ia.dot(c.xyz).sub(c.w).negate();o.element(a).assign(u)})})()}}Cu.ALPHA_TO_COVERAGE="alphaToCoverage",Cu.DEFAULT="default",Cu.HARDWARE="hardware";const N4=()=>Cn(new Cu),P4=()=>Cn(new Cu(Cu.ALPHA_TO_COVERAGE)),I4=()=>Cn(new Cu(Cu.HARDWARE)),L4=.05,W2=Kt(([r])=>Pd(Kr(1e4,Xc(Kr(17,r.x).add(Kr(.1,r.y)))).mul(Wa(.1,Oo(Xc(Kr(13,r.y).add(r.x))))))),H2=Kt(([r])=>W2(Bn(W2(r.xy),r.z))),D4=Kt(([r])=>{const e=ga(Oh(dM(r.xyz)),Oh(fM(r.xyz))),t=ut(1).div(ut(L4).mul(e)).toVar("pixScale"),n=Bn(zg(Dh(Ih(t))),zg(I_(Ih(t)))),s=Bn(H2(Dh(n.x.mul(r.xyz))),H2(Dh(n.y.mul(r.xyz)))),o=Pd(Ih(t)),a=Wa(Kr(o.oneMinus(),s.x),Kr(o,s.y)),c=Sc(o,o.oneMinus()),u=qt(a.mul(a).div(Kr(2,c).mul(Ds(1,c))),a.sub(Kr(.5,c)).div(Ds(1,c)),Ds(1,Ds(1,a).mul(Ds(1,a)).div(Kr(2,c).mul(Ds(1,c))))),d=a.lessThan(c.oneMinus()).select(a.lessThan(c).select(u.x,u.y),u.z);return Mu(d,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class O4 extends ER{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let s;return n===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new mr(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const $2=(r=0)=>Cn(new O4(r)),j2=Kt(([r,e])=>Sc(1,r.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),X2=Kt(([r,e])=>Sc(r.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),q2=Kt(([r,e])=>r.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Y2=Kt(([r,e])=>Hs(r.mul(2).mul(e),r.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),D_(.5,r))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),F4=Kt(([r,e])=>{const t=e.a.add(r.a.mul(e.a.oneMinus()));return Bi(e.rgb.mul(e.a).add(r.rgb.mul(r.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Z2=Kt(([r])=>Bi(r.rgb.mul(r.a),r.a),{color:"vec4",return:"vec4"}),B4=Kt(([r])=>(sr(r.a.equal(0),()=>Bi(0)),Bi(r.rgb.div(r.a),r.a)),{color:"vec4",return:"vec4"}),U4=(...r)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),j2(r)),k4=(...r)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),X2(r)),z4=(...r)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),q2(r)),V4=(...r)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),Y2(r));class ya extends Ei{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+Uw(this)}build(e){this.setup(e)}setupObserver(e){return new gk(e)}setup(e){e.context.setupNormal=()=>Vg(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const s=Vg(this.setupVertex(e),"VERTEX"),o=this.vertexNode||s;e.stack.outputNode=o,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const c=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const u=this.setupLighting(e);c!==null&&e.stack.add(c);const d=Bi(u,to.a).max(0);a=this.setupOutput(e,d),kg.assign(a);const p=this.outputNode!==null;if(p&&(a=this.outputNode),n!==null){const m=t.getMRT(),y=this.mrtNode;m!==null?(p&&kg.assign(a),a=m,y!==null&&(a=m.merge(y))):y!==null&&(a=y)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=Bi(u)),a=this.setupOutput(e,u)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let s=null;if(t.length>0||n.length>0){const o=e.renderer.samples;this.alphaToCoverage&&o>1?s=P4():e.stack.add(N4())}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(I4()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let s=this.depthNode;if(s===null){const o=t.getMRT();o&&o.has("depth")?s=o.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?s=nS(Ia.z,Fd,Bd):s=Yg(Ia.z,Fd,Bd))}s!==null&&iS.assign(s).toStack()}setupPositionView(){return Ud.mul(Pa).xyz}setupModelViewProjection(){return Tu.mul(Ia)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),ZM}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&z2(t).toStack(),t.isSkinnedMesh===!0&&B2(t).toStack(),this.displacementMap){const s=kd("displacementMap","texture"),o=kd("displacementScale","float"),a=kd("displacementBias","float");Pa.addAssign(Tc.normalize().mul(s.x.mul(o).add(a)))}return t.isBatchedMesh&&D2(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&L2(t).toStack(),this.positionNode!==null&&Pa.assign(Vg(this.positionNode,"POSITION","vec3")),Pa}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&bu(this.maskNode).not().discard();let n=this.colorNode?Bi(this.colorNode):X_;this.vertexColors===!0&&t.hasAttribute("color")&&(n=n.mul($2())),e.instanceColor&&(n=$c("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=$c("vec3","vBatchColor").mul(n)),to.assign(n);const s=this.opacityNode?ut(this.opacityNode):q_;to.a.assign(to.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?ut(this.alphaTestNode):r2,to.a.lessThanEqual(o).discard()),this.alphaHash===!0&&to.a.lessThan(D4(Pa)).discard(),this.transparent===!1&&this.blending===ge&&this.alphaToCoverage===!1?to.a.assign(1):o===null&&to.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?qt(0):to.rgb}setupNormal(){return this.normalNode?qt(this.normalNode):h2}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?kd("envMap","cubeTexture"):kd("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new S4(YM)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:R2;t.push(new w4(a))}let o=this.lightsNode||e.lightsNode;return t.length>0&&(o=e.renderer.lighting.createNode([...o.getLights(),...t])),o}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:s,emissiveNode:o}=this,c=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(c&&c.getScope().hasLights){const d=this.setupLightingModel(e)||null;u=V2(c,d,n,s)}else n!==null&&(u=qt(s!==null?Hs(u,n,s):n));return(o&&o.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Qw.assign(qt(o||o2)),u=u.add(Qw)),u}setupFog(e,t){const n=e.fogNode;return n&&(kg.assign(t),t=Bi(n.toVar())),t}setupPremultipliedAlpha(e,t){return Z2(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const n in e){const s=e[n];this[n]===void 0&&(this[n]=s,s&&s.clone&&(this[n]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=Ei.prototype.toJSON.call(this,e),s=Xy(this);n.inputNodes={};for(const{property:a,childNode:c}of s)n.inputNodes[a]=c.toJSON(e).uuid;function o(a){const c=[];for(const u in a){const d=a[u];delete d.metadata,c.push(d)}return c}if(t){const a=o(e.textures),c=o(e.images),u=o(e.nodes);a.length>0&&(n.textures=a),c.length>0&&(n.images=c),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const G4=new el;class W4 extends ya{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(G4),this.setValues(e)}}const H4=new hy;class $4 extends ya{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(H4),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ut(this.offsetNode):qM,t=this.dashScaleNode?ut(this.dashScaleNode):$M,n=this.dashSizeNode?ut(this.dashSizeNode):jM,s=this.gapSizeNode?ut(this.gapSizeNode):XM;am.assign(n),rv.assign(s);const o=Fh(rc("lineDistance").mul(t));(e?o.add(e):o).mod(am.add(rv)).greaterThan(am).discard()}}let Q_=null;class j4 extends K_{static get type(){return"ViewportSharedTextureNode"}constructor(e=Od,t=null){Q_===null&&(Q_=new bp),super(e,t,Q_)}getTextureForReference(){return Q_}updateReference(){return this}}const K2=zr(j4).setParameterLength(0,2),X4=new hy;class EY extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(X4),this.useColor=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=NoBlending,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,n=this._useAlphaToCoverage,s=this.useColor,o=this._useDash,a=this._useWorldUnits,c=Kt(({start:d,end:p})=>{const m=Tu.element(2).element(2),T=Tu.element(3).element(2).mul(-.5).div(m).sub(d.z).div(p.z.sub(d.z));return Bi(Hs(d.xyz,p.xyz,T),p.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=Kt(()=>{const d=rc("instanceStart"),p=rc("instanceEnd"),m=Bi(Ud.mul(Bi(d,1))).toVar("start"),y=Bi(Ud.mul(Bi(p,1))).toVar("end");if(o){const _e=this.dashScaleNode?ut(this.dashScaleNode):$M,ve=this.offsetNode?ut(this.offsetNode):qM,Oe=rc("instanceDistanceStart"),He=rc("instanceDistanceEnd");let Ce=Pl.y.lessThan(.5).select(_e.mul(Oe),_e.mul(He));Ce=Ce.add(ve),$c("float","lineDistance").assign(Ce)}a&&($c("vec3","worldStart").assign(m.xyz),$c("vec3","worldEnd").assign(y.xyz));const M=Gg.z.div(Gg.w),T=Tu.element(2).element(3).equal(-1);sr(T,()=>{sr(m.z.lessThan(0).and(y.z.greaterThan(0)),()=>{y.assign(c({start:m,end:y}))}).ElseIf(y.z.lessThan(0).and(m.z.greaterThanEqual(0)),()=>{m.assign(c({start:y,end:m}))})});const G=Tu.mul(m),z=Tu.mul(y),I=G.xyz.div(G.w),ee=z.xyz.div(z.w),Q=ee.xy.sub(I.xy).toVar();Q.x.assign(Q.x.mul(M)),Q.assign(Q.normalize());const oe=Bi().toVar();if(a){const _e=y.xyz.sub(m.xyz).normalize(),ve=Hs(m.xyz,y.xyz,.5).normalize(),Oe=_e.cross(ve).normalize(),He=_e.cross(Oe),Ce=$c("vec4","worldPos");Ce.assign(Pl.y.lessThan(.5).select(m,y));const Be=Z_.mul(.5);Ce.addAssign(Bi(Pl.x.lessThan(0).select(Oe.mul(Be),Oe.mul(Be).negate()),0)),o||(Ce.addAssign(Bi(Pl.y.lessThan(.5).select(_e.mul(Be).negate(),_e.mul(Be)),0)),Ce.addAssign(Bi(He.mul(Be),0)),sr(Pl.y.greaterThan(1).or(Pl.y.lessThan(0)),()=>{Ce.subAssign(Bi(He.mul(2).mul(Be),0))})),oe.assign(Tu.mul(Ce));const ft=qt().toVar();ft.assign(Pl.y.lessThan(.5).select(I,ee)),oe.z.assign(ft.z.mul(oe.w))}else{const _e=Bn(Q.y,Q.x.negate()).toVar("offset");Q.x.assign(Q.x.div(M)),_e.x.assign(_e.x.div(M)),_e.assign(Pl.x.lessThan(0).select(_e.negate(),_e)),sr(Pl.y.lessThan(0),()=>{_e.assign(_e.sub(Q))}).ElseIf(Pl.y.greaterThan(1),()=>{_e.assign(_e.add(Q))}),_e.assign(_e.mul(Z_)),_e.assign(_e.div(Gg.w)),oe.assign(Pl.y.lessThan(.5).select(G,z)),_e.assign(_e.mul(oe.w)),oe.assign(oe.add(Bi(_e,0,0)))}return oe})();const u=Kt(({p1:d,p2:p,p3:m,p4:y})=>{const M=d.sub(m),T=y.sub(m),G=p.sub(d),z=M.dot(T),I=T.dot(G),ee=M.dot(G),Q=T.dot(T),_e=G.dot(G).mul(Q).sub(I.mul(I)),Oe=z.mul(I).sub(ee.mul(Q)).div(_e).clamp(),He=z.add(I.mul(Oe)).div(Q).clamp();return Bn(Oe,He)});if(this.colorNode=Kt(()=>{const d=vo();if(o){const y=this.dashSizeNode?ut(this.dashSizeNode):jM,M=this.gapSizeNode?ut(this.gapSizeNode):XM;am.assign(y),rv.assign(M);const T=$c("float","lineDistance");d.y.lessThan(-1).or(d.y.greaterThan(1)).discard(),T.mod(am.add(rv)).greaterThan(am).discard()}const p=ut(1).toVar("alpha");if(a){const y=$c("vec3","worldStart"),M=$c("vec3","worldEnd"),T=$c("vec4","worldPos").xyz.normalize().mul(1e5),G=M.sub(y),z=u({p1:y,p2:M,p3:qt(0,0,0),p4:T}),I=y.add(G.mul(z.x)),ee=T.mul(z.y),_e=I.sub(ee).length().div(Z_);if(!o)if(n&&t.samples>1){const ve=_e.fwidth();p.assign(Su(ve.negate().add(.5),ve.add(.5),_e).oneMinus())}else _e.greaterThan(.5).discard()}else if(n&&t.samples>1){const y=d.x,M=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1)),T=y.mul(y).add(M.mul(M)),G=ut(T.fwidth()).toVar("dlen");sr(d.y.abs().greaterThan(1),()=>{p.assign(Su(G.oneMinus(),G.add(1),T).oneMinus())})}else sr(d.y.abs().greaterThan(1),()=>{const y=d.x,M=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1));y.mul(y).add(M.mul(M)).greaterThan(1).discard()});let m;if(this.lineColorNode)m=this.lineColorNode;else if(s){const y=rc("instanceColorStart"),M=rc("instanceColorEnd");m=Pl.y.lessThan(.5).select(y,M).mul(X_)}else m=X_;return Bi(m,p)})(),this.transparent){const d=this.opacityNode?ut(this.opacityNode):q_;this.outputNode=Bi(this.colorNode.rgb.mul(d).add(K2().rgb.mul(d.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const J2=r=>Cn(r).mul(.5).add(.5),q4=r=>Cn(r).mul(2).sub(1),Y4=new Rx;class Z4 extends ya{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Y4),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ut(this.opacityNode):q_;to.assign(B_(Bi(J2(fo),e),co))}}const rS=Kt(([r=LM])=>{const e=r.z.atan(r.x).mul(1/(Math.PI*2)).add(.5),t=r.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Bn(e,t)});class Q2 extends R0{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const o=new Fc(5,5,5),a=rS(LM),c=new ya;c.colorNode=Ps(t,a,0),c.side=K,c.blending=ye;const u=new Zs(o,c),d=new $m;d.add(u),t.minFilter===Qn&&(t.minFilter=Rn);const p=new Vu(1,10,this),m=e.getMRT();return e.setMRT(null),p.update(e,d),e.setMRT(m),t.minFilter=n,t.currentGenerateMipmaps=s,u.geometry.dispose(),u.material.dispose(),this}}const xv=new WeakMap;class K4 extends Ra{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=$g(null);const t=new ph;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=rs.RENDER}updateBefore(e){const{renderer:t,material:n}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const o=s.isTextureNode?s.value:n[s.property];if(o&&o.isTexture){const a=o.mapping;if(a===Pe||a===Ie){if(xv.has(o)){const c=xv.get(o);tN(c,o.mapping),this._cubeTexture=c}else{const c=o.image;if(J4(c)){const u=new Q2(c.height);u.fromEquirectangularTexture(t,o),tN(u.texture,o.mapping),this._cubeTexture=u.texture,xv.set(o,u.texture),o.addEventListener("dispose",eN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function J4(r){return r==null?!1:r.height>0}function eN(r){const e=r.target;e.removeEventListener("dispose",eN);const t=xv.get(e);t!==void 0&&(xv.delete(e),t.dispose())}function tN(r,e){e===Pe?r.mapping=Fe:e===Ie&&(r.mapping=Xe)}const nN=zr(K4).setParameterLength(1);class sS extends Xg{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=nN(this.envNode)}}class Q4 extends Xg{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ut(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class eb{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class iN extends eb{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,s=e.irradianceLightMap;n.indirectDiffuse.assign(Bi(0)),s?n.indirectDiffuse.addAssign(s):n.indirectDiffuse.addAssign(Bi(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(to.rgb)}finish(e){const{material:t,context:n}=e,s=n.outgoingLight,o=e.context.environment;if(o)switch(t.combine){case xt:s.rgb.assign(Hs(s.rgb,s.rgb.mul(o.rgb),vv.mul(Y_)));break;case ke:s.rgb.assign(Hs(s.rgb,o.rgb,vv.mul(Y_)));break;case et:s.rgb.addAssign(o.rgb.mul(vv.mul(Y_)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const eV=new Wr;class tV extends ya{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(eV),this.setValues(e)}setupNormal(){return Wg(Hg)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Q4(YM)),t}setupOutgoingLight(){return to.rgb}setupLightingModel(){return new iN}}const Kg=Kt(({f0:r,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return r.mul(n.oneMinus()).add(e.mul(n))}),dm=Kt(r=>r.diffuseColor.mul(1/Math.PI)),nV=()=>ut(.25),iV=Kt(({dotNH:r})=>A_.mul(ut(.5)).add(1).mul(ut(1/Math.PI)).mul(r.pow(A_))),rV=Kt(({lightDirection:r})=>{const e=r.add(Vo).normalize(),t=fo.dot(e).clamp(),n=Vo.dot(e).clamp(),s=Kg({f0:Mc,f90:1,dotVH:n}),o=nV(),a=iV({dotNH:t});return s.mul(o).mul(a)});class rN extends iN{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=fo.dot(e).clamp().mul(t);n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb}))),this.specular===!0&&n.directSpecular.addAssign(o.mul(rV({lightDirection:e})).mul(vv))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(dm({diffuseColor:to}))),s.indirectDiffuse.mulAssign(t)}}const sV=new cy;class oV extends ya{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(sV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightingModel(){return new rN(!1)}}const aV=new ay;class lV extends ya{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(aV),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new sS(t):null}setupLightingModel(){return new rN}setupVariants(){const e=(this.shininessNode?ut(this.shininessNode):s2).max(1e-4);A_.assign(e);const t=this.specularNode||a2;Mc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const sN=Kt(r=>{if(r.geometry.hasAttribute("normal")===!1)return ut(0);const e=Hg.dFdx().abs().max(Hg.dFdy().abs());return e.x.max(e.y).max(e.z)}),oS=Kt(r=>{const{roughness:e}=r,t=sN();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),oN=Kt(({alpha:r,dotNL:e,dotNV:t})=>{const n=r.pow2(),s=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),o=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return jc(.5,s.add(o).max(NC))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),cV=Kt(({alphaT:r,alphaB:e,dotTV:t,dotBV:n,dotTL:s,dotBL:o,dotNV:a,dotNL:c})=>{const u=c.mul(qt(r.mul(t),e.mul(n),a).length()),d=a.mul(qt(r.mul(s),e.mul(o),c).length());return jc(.5,u.add(d)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),aN=Kt(({alpha:r,dotNH:e})=>{const t=r.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),uV=ut(1/Math.PI),hV=Kt(({alphaT:r,alphaB:e,dotNH:t,dotTH:n,dotBH:s})=>{const o=r.mul(e),a=qt(e.mul(n),r.mul(s),o.mul(t)),c=a.dot(a),u=o.div(c);return uV.mul(o.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),aS=Kt(({lightDirection:r,f0:e,f90:t,roughness:n,f:s,normalView:o=fo,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const u=n.pow2(),d=r.add(Vo).normalize(),p=o.dot(r).clamp(),m=o.dot(Vo).clamp(),y=o.dot(d).clamp(),M=Vo.dot(d).clamp();let T=Kg({f0:e,f90:t,dotVH:M}),G,z;if(Ky(a)&&(T=T_.mix(T,s)),Ky(c)){const I=nv.dot(r),ee=nv.dot(Vo),Q=nv.dot(d),oe=om.dot(r),_e=om.dot(Vo),ve=om.dot(d);G=cV({alphaT:E_,alphaB:u,dotTV:ee,dotBV:_e,dotTL:I,dotBL:oe,dotNV:m,dotNL:p}),z=hV({alphaT:E_,alphaB:u,dotNH:y,dotTH:Q,dotBH:ve})}else G=oN({alpha:u,dotNL:p,dotNV:m}),z=aN({alpha:u,dotNH:y});return T.mul(G).mul(z)}),lS=Kt(({roughness:r,dotNV:e})=>{const t=Bi(-1,-.0275,-.572,.022),n=Bi(1,.0425,1.04,-.04),s=r.mul(t).add(n),o=s.x.mul(s.x).min(e.mul(-9.28).exp2()).mul(s.x).add(s.y);return Bn(-1.04,1.04).mul(o).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),lN=Kt(r=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:s}=r,o=lS({dotNV:e,roughness:s});return t.mul(o.x).add(n.mul(o.y))}),cN=Kt(({f:r,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),s=n.mul(n),o=n.mul(s,s).clamp(0,.9999);return r.sub(qt(e).mul(o)).div(o.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),dV=Kt(({roughness:r,dotNH:e})=>{const t=r.pow2(),n=ut(1).div(t),o=e.pow2().oneMinus().max(.0078125);return ut(2).add(n).mul(o.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),fV=Kt(({dotNV:r,dotNL:e})=>ut(1).div(ut(4).mul(e.add(r).sub(e.mul(r))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),pV=Kt(({lightDirection:r})=>{const e=r.add(Vo).normalize(),t=fo.dot(r).clamp(),n=fo.dot(Vo).clamp(),s=fo.dot(e).clamp(),o=dV({roughness:S_,dotNH:s}),a=fV({dotNV:n,dotNL:t});return sm.mul(o).mul(a)}),mV=Kt(({N:r,V:e,roughness:t})=>{const o=.0078125,a=r.dot(e).saturate(),c=Bn(t,a.oneMinus().sqrt());return c.assign(c.mul(.984375).add(o)),c}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),uN=Kt(({f:r})=>{const e=r.length();return ga(e.mul(e).add(r.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Wf=Kt(({v1:r,v2:e})=>{const t=r.dot(e),n=t.abs().toVar(),s=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),o=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=s.div(o),c=t.greaterThan(0).select(a,ga(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return r.cross(e).mul(c)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),hN=Kt(({N:r,V:e,P:t,mInv:n,p0:s,p1:o,p2:a,p3:c})=>{const u=o.sub(s).toVar(),d=c.sub(s).toVar(),p=u.cross(d),m=qt().toVar();return sr(p.dot(t.sub(s)).greaterThanEqual(0),()=>{const y=e.sub(r.mul(e.dot(r))).normalize(),M=r.cross(y).negate(),T=n.mul(Wl(y,M,r).transpose()).toVar(),G=T.mul(s.sub(t)).normalize().toVar(),z=T.mul(o.sub(t)).normalize().toVar(),I=T.mul(a.sub(t)).normalize().toVar(),ee=T.mul(c.sub(t)).normalize().toVar(),Q=qt(0).toVar();Q.addAssign(Wf({v1:G,v2:z})),Q.addAssign(Wf({v1:z,v2:I})),Q.addAssign(Wf({v1:I,v2:ee})),Q.addAssign(Wf({v1:ee,v2:G})),m.assign(qt(uN({f:Q})))}),m}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),gV=Kt(({P:r,p0:e,p1:t,p2:n,p3:s})=>{const o=t.sub(e).toVar(),a=s.sub(e).toVar(),c=o.cross(a),u=qt().toVar();return sr(c.dot(r.sub(e)).greaterThanEqual(0),()=>{const d=e.sub(r).normalize().toVar(),p=t.sub(r).normalize().toVar(),m=n.sub(r).normalize().toVar(),y=s.sub(r).normalize().toVar(),M=qt(0).toVar();M.addAssign(Wf({v1:d,v2:p})),M.addAssign(Wf({v1:p,v2:m})),M.addAssign(Wf({v1:m,v2:y})),M.addAssign(Wf({v1:y,v2:d})),u.assign(qt(uN({f:M.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),tb=1/6,dN=r=>Kr(tb,Kr(r,Kr(r,r.negate().add(3)).sub(3)).add(1)),cS=r=>Kr(tb,Kr(r,Kr(r,Kr(3,r).sub(6))).add(4)),fN=r=>Kr(tb,Kr(r,Kr(r,Kr(-3,r).add(3)).add(3)).add(1)),uS=r=>Kr(tb,wu(r,3)),pN=r=>dN(r).add(cS(r)),mN=r=>fN(r).add(uS(r)),gN=r=>Wa(-1,cS(r).div(dN(r).add(cS(r)))),yN=r=>Wa(1,uS(r).div(fN(r).add(uS(r)))),vN=(r,e,t)=>{const n=r.uvNode,s=Kr(n,e.zw).add(.5),o=Dh(s),a=Pd(s),c=pN(a.x),u=mN(a.x),d=gN(a.x),p=yN(a.x),m=gN(a.y),y=yN(a.y),M=Bn(o.x.add(d),o.y.add(m)).sub(.5).mul(e.xy),T=Bn(o.x.add(p),o.y.add(m)).sub(.5).mul(e.xy),G=Bn(o.x.add(d),o.y.add(y)).sub(.5).mul(e.xy),z=Bn(o.x.add(p),o.y.add(y)).sub(.5).mul(e.xy),I=pN(a.y).mul(Wa(c.mul(r.sample(M).level(t)),u.mul(r.sample(T).level(t)))),ee=mN(a.y).mul(Wa(c.mul(r.sample(G).level(t)),u.mul(r.sample(z).level(t))));return I.add(ee)},hS=Kt(([r,e])=>{const t=Bn(r.size(Dt(e))),n=Bn(r.size(Dt(e.add(1)))),s=jc(1,t),o=jc(1,n),a=vN(r,Bi(s,t),Dh(e)),c=vN(r,Bi(o,n),I_(e));return Pd(e).mix(a,c)}),yV=Kt(([r,e])=>{const t=e.mul(AM(r));return hS(r,t)}),xN=Kt(([r,e,t,n,s])=>{const o=qt(vM(e.negate(),Nd(r),jc(1,n))),a=qt(Oh(s[0].xyz),Oh(s[1].xyz),Oh(s[2].xyz));return Nd(o).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),vV=Kt(([r,e])=>r.mul(Mu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),xV=JM(),_V=JM(),_N=Kt(([r,e,t],{material:n})=>{const o=(n.side===K?xV:_V).sample(r),a=Ih(lm.x).mul(vV(e,t));return hS(o,a)}),bN=Kt(([r,e,t])=>(sr(t.notEqual(0),()=>{const n=P_(e).negate().div(t);return cM(n.negate().mul(r))}),qt(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),bV=Kt(([r,e,t,n,s,o,a,c,u,d,p,m,y,M,T])=>{let G,z;if(T){G=Bi().toVar(),z=qt().toVar();const _e=p.sub(1).mul(T.mul(.025)),ve=qt(p.sub(_e),p,p.add(_e));po({start:0,end:3},({i:Oe})=>{const He=ve.element(Oe),Ce=xN(r,e,m,He,c),Be=a.add(Ce),ft=d.mul(u.mul(Bi(Be,1))),zt=Bn(ft.xy.div(ft.w)).toVar();zt.addAssign(1),zt.divAssign(2),zt.assign(Bn(zt.x,zt.y.oneMinus()));const tn=_N(zt,t,He);G.element(Oe).assign(tn.element(Oe)),G.a.addAssign(tn.a),z.element(Oe).assign(n.element(Oe).mul(bN(Oh(Ce),y,M).element(Oe)))}),G.a.divAssign(3)}else{const _e=xN(r,e,m,p,c),ve=a.add(_e),Oe=d.mul(u.mul(Bi(ve,1))),He=Bn(Oe.xy.div(Oe.w)).toVar();He.addAssign(1),He.divAssign(2),He.assign(Bn(He.x,He.y.oneMinus())),G=_N(He,t,p),z=n.mul(bN(Oh(_e),y,M))}const I=z.rgb.mul(G.rgb),ee=r.dot(e).clamp(),Q=qt(lN({dotNV:ee,specularColor:s,specularF90:o,roughness:t})),oe=z.r.add(z.g,z.b).div(3);return Bi(Q.oneMinus().mul(I),G.a.oneMinus().mul(oe).oneMinus())}),wV=Wl(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),MV=r=>{const e=r.sqrt();return qt(1).add(e).div(qt(1).sub(e))},wN=(r,e)=>r.sub(e).div(r.add(e)).pow2(),SV=(r,e)=>{const t=r.mul(2*Math.PI*1e-9),n=qt(54856e-17,44201e-17,52481e-17),s=qt(1681e3,1795300,2208400),o=qt(43278e5,93046e5,66121e5),a=ut(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let c=n.mul(o.mul(2*Math.PI).sqrt()).mul(s.mul(t).add(e).cos()).mul(t.pow2().negate().mul(o).exp());return c=qt(c.x.add(a),c.y,c.z).div(10685e-11),wV.mul(c)},TV=Kt(({outsideIOR:r,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:s})=>{const o=Hs(r,e,Su(0,.03,n)),c=r.div(o).pow2().mul(t.pow2().oneMinus()).oneMinus();sr(c.lessThan(0),()=>qt(1));const u=c.sqrt(),d=wN(o,r),p=Kg({f0:d,f90:1,dotVH:t}),m=p.oneMinus(),y=o.lessThan(r).select(Math.PI,0),M=ut(Math.PI).sub(y),T=MV(s.clamp(0,.9999)),G=wN(T,o.toVec3()),z=Kg({f0:G,f90:1,dotVH:u}),I=qt(T.x.lessThan(o).select(Math.PI,0),T.y.lessThan(o).select(Math.PI,0),T.z.lessThan(o).select(Math.PI,0)),ee=o.mul(n,u,2),Q=qt(M).add(I),oe=p.mul(z).clamp(1e-5,.9999),_e=oe.sqrt(),ve=m.pow2().mul(z).div(qt(1).sub(oe)),He=p.add(ve).toVar(),Ce=ve.sub(m).toVar();return po({start:1,end:2,condition:"<=",name:"m"},({m:Be})=>{Ce.mulAssign(_e);const ft=SV(ut(Be).mul(ee),ut(Be).mul(Q)).mul(2);He.addAssign(Ce.mul(ft))}),He.max(qt(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),EV=Kt(({normal:r,viewDir:e,roughness:t})=>{const n=r.dot(e).saturate(),s=t.pow2(),o=wl(t.lessThan(.25),ut(-339.2).mul(s).add(ut(161.4).mul(t)).sub(25.9),ut(-8.48).mul(s).add(ut(14.3).mul(t)).sub(9.95)),a=wl(t.lessThan(.25),ut(44).mul(s).sub(ut(23.7).mul(t)).add(3.26),ut(1.97).mul(s).sub(ut(3.27).mul(t)).add(.72));return wl(t.lessThan(.25),0,ut(.1).mul(t).sub(.025)).add(o.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),dS=qt(.04),fS=ut(1);class MN extends eb{constructor(e=!1,t=!1,n=!1,s=!1,o=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=s,this.transmission=o,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=qt().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=qt().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=qt().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=qt().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=qt().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=fo.dot(Vo).clamp();this.iridescenceFresnel=TV({outsideIOR:ut(1),eta2:eM,cosTheta1:t,thinFilmThickness:tM,baseF0:Mc}),this.iridescenceF0=cN({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Yc,n=gv.sub(Yc).normalize(),s=Vf,o=e.context;o.backdrop=bV(s,n,Ph,to,Mc,iv,t,Au,qc,Tu,sv,nM,rM,iM,this.dispersion?sM:null),o.backdropAlpha=C_,to.a.mulAssign(Hs(1,o.backdrop.a,C_))}super.start(e)}computeMultiscattering(e,t,n){const s=fo.dot(Vo).clamp(),o=lS({roughness:Ph,dotNV:s}),c=(this.iridescenceF0?T_.mix(Mc,this.iridescenceF0):Mc).mul(o.x).add(n.mul(o.y)),d=o.x.add(o.y).oneMinus(),p=Mc.add(Mc.oneMinus().mul(.047619)),m=c.mul(p).div(d.mul(p).oneMinus());e.addAssign(c),t.addAssign(m.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=fo.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(o.mul(pV({lightDirection:e}))),this.clearcoat===!0){const c=cm.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(c.mul(aS({lightDirection:e,f0:dS,f90:fS,roughness:tv,normalView:cm})))}n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb}))),n.directSpecular.addAssign(o.mul(aS({lightDirection:e,f0:Mc,f90:1,roughness:Ph,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:s,reflectedLight:o,ltc_1:a,ltc_2:c}){const u=t.add(n).sub(s),d=t.sub(n).sub(s),p=t.sub(n).add(s),m=t.add(n).add(s),y=fo,M=Vo,T=Ia.toVar(),G=mV({N:y,V:M,roughness:Ph}),z=a.sample(G).toVar(),I=c.sample(G).toVar(),ee=Wl(qt(z.x,0,z.y),qt(0,1,0),qt(z.z,0,z.w)).toVar(),Q=Mc.mul(I.x).add(Mc.oneMinus().mul(I.y)).toVar();o.directSpecular.addAssign(e.mul(Q).mul(hN({N:y,V:M,P:T,mInv:ee,p0:u,p1:d,p2:p,p3:m}))),o.directDiffuse.addAssign(e.mul(to).mul(hN({N:y,V:M,P:T,mInv:Wl(1,0,0,0,1,0,0,0,1),p0:u,p1:d,p2:p,p3:m})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:n}=e.context;n.indirectDiffuse.addAssign(t.mul(dm({diffuseColor:to})))}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(sm,EV({normal:fo,viewDir:Vo,roughness:S_}))),this.clearcoat===!0){const p=cm.dot(Vo).clamp(),m=lN({dotNV:p,specularColor:dS,specularF90:fS,roughness:tv});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const o=qt().toVar("singleScattering"),a=qt().toVar("multiScattering"),c=n.mul(1/Math.PI);this.computeMultiscattering(o,a,iv);const u=o.add(a),d=to.mul(u.r.max(u.g).max(u.b).oneMinus());s.indirectSpecular.addAssign(t.mul(o)),s.indirectSpecular.addAssign(a.mul(c)),s.indirectDiffuse.addAssign(d.mul(c))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,o=fo.dot(Vo).clamp().add(t),a=Ph.mul(-16).oneMinus().negate().exp2(),c=t.sub(o.pow(a).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(c)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=cm.dot(Vo).clamp(),s=Kg({dotVH:n,f0:dS,f90:fS}),o=t.mul(M_.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(M_));t.assign(o)}if(this.sheen===!0){const n=sm.r.max(sm.g).max(sm.b).mul(.157).oneMinus(),s=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const SN=ut(1),pS=ut(-2),nb=ut(.8),mS=ut(-1),ib=ut(.4),gS=ut(2),rb=ut(.305),yS=ut(3),TN=ut(.21),AV=ut(4),EN=ut(4),CV=ut(16),RV=Kt(([r])=>{const e=qt(Oo(r)).toVar(),t=ut(-1).toVar();return sr(e.x.greaterThan(e.z),()=>{sr(e.x.greaterThan(e.y),()=>{t.assign(wl(r.x.greaterThan(0),0,3))}).Else(()=>{t.assign(wl(r.y.greaterThan(0),1,4))})}).Else(()=>{sr(e.z.greaterThan(e.y),()=>{t.assign(wl(r.z.greaterThan(0),2,5))}).Else(()=>{t.assign(wl(r.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),NV=Kt(([r,e])=>{const t=Bn().toVar();return sr(e.equal(0),()=>{t.assign(Bn(r.z,r.y).div(Oo(r.x)))}).ElseIf(e.equal(1),()=>{t.assign(Bn(r.x.negate(),r.z.negate()).div(Oo(r.y)))}).ElseIf(e.equal(2),()=>{t.assign(Bn(r.x.negate(),r.y).div(Oo(r.z)))}).ElseIf(e.equal(3),()=>{t.assign(Bn(r.z.negate(),r.y).div(Oo(r.x)))}).ElseIf(e.equal(4),()=>{t.assign(Bn(r.x.negate(),r.z).div(Oo(r.y)))}).Else(()=>{t.assign(Bn(r.x,r.y).div(Oo(r.z)))}),Kr(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),PV=Kt(([r])=>{const e=ut(0).toVar();return sr(r.greaterThanEqual(nb),()=>{e.assign(SN.sub(r).mul(mS.sub(pS)).div(SN.sub(nb)).add(pS))}).ElseIf(r.greaterThanEqual(ib),()=>{e.assign(nb.sub(r).mul(gS.sub(mS)).div(nb.sub(ib)).add(mS))}).ElseIf(r.greaterThanEqual(rb),()=>{e.assign(ib.sub(r).mul(yS.sub(gS)).div(ib.sub(rb)).add(gS))}).ElseIf(r.greaterThanEqual(TN),()=>{e.assign(rb.sub(r).mul(AV.sub(yS)).div(rb.sub(TN)).add(yS))}).Else(()=>{e.assign(ut(-2).mul(Ih(Kr(1.16,r))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),AN=Kt(([r,e])=>{const t=r.toVar();t.assign(Kr(2,t).sub(1));const n=qt(t,1).toVar();return sr(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),CN=Kt(([r,e,t,n,s,o])=>{const a=ut(t),c=qt(e),u=Mu(PV(a),pS,o),d=Pd(u),p=Dh(u),m=qt(vS(r,c,p,n,s,o)).toVar();return sr(d.notEqual(0),()=>{const y=qt(vS(r,c,p.add(1),n,s,o)).toVar();m.assign(Hs(m,y,d))}),m}),vS=Kt(([r,e,t,n,s,o])=>{const a=ut(t).toVar(),c=qt(e),u=ut(RV(c)).toVar(),d=ut(ga(EN.sub(a),0)).toVar();a.assign(ga(a,EN));const p=ut(zg(a)).toVar(),m=Bn(NV(c,u).mul(p.sub(2)).add(1)).toVar();return sr(u.greaterThan(2),()=>{m.y.addAssign(p),u.subAssign(3)}),m.x.addAssign(u.mul(p)),m.x.addAssign(d.mul(Kr(3,CV))),m.y.addAssign(Kr(4,zg(o).sub(p))),m.x.mulAssign(n),m.y.mulAssign(s),r.sample(m).grad(Bn(),Bn())}),xS=Kt(({envMap:r,mipInt:e,outputDirection:t,theta:n,axis:s,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=Id(n),d=t.mul(u).add(s.cross(t).mul(Xc(n))).add(s.mul(s.dot(t).mul(u.oneMinus())));return vS(r,d,e,o,a,c)}),RN=Kt(({n:r,latitudinal:e,poleAxis:t,outputDirection:n,weights:s,samples:o,dTheta:a,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})=>{const y=qt(wl(e,t,O_(t,n))).toVar();sr(y.equal(qt(0)),()=>{y.assign(qt(n.z,0,n.x.negate()))}),y.assign(Nd(y));const M=qt().toVar();return M.addAssign(s.element(0).mul(xS({theta:0,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),po({start:Dt(1),end:r},({i:T})=>{sr(T.greaterThanEqual(o),()=>{U2()});const G=ut(a.mul(ut(T))).toVar();M.addAssign(s.element(T).mul(xS({theta:G.mul(-1),axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),M.addAssign(s.element(T).mul(xS({theta:G,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})))}),Bi(M,1)}),Jg=4,NN=[.125,.215,.35,.446,.526,.582],fm=20,_S=new Cf(-1,1,1,-1,0,1),IV=new fa(90,1),PN=new jn;let bS=null,wS=0,MS=0;const pm=(1+Math.sqrt(5))/2,Qg=1/pm,IN=[new ot(-pm,Qg,0),new ot(pm,Qg,0),new ot(-Qg,0,pm),new ot(Qg,0,pm),new ot(0,pm,-Qg),new ot(0,pm,Qg),new ot(-1,1,-1),new ot(1,1,-1),new ot(-1,1,1),new ot(1,1,1)],LV=new ot,LN=new WeakMap,DV=[3,1,5,0,4,2],SS=AN(vo(),rc("faceIndex")).normalize(),TS=qt(SS.x,SS.y,SS.z);class OV{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,s=100,o={}){const{size:a=256,position:c=LV,renderTarget:u=null}=o;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const p=u||this._allocateTarget();return o.renderTarget=p,this.fromSceneAsync(e,t,n,s,o),p}bS=this._renderer.getRenderTarget(),wS=this._renderer.getActiveCubeFace(),MS=this._renderer.getActiveMipmapLevel();const d=u||this._allocateTarget();return d.depthBuffer=!0,this._init(d),this._sceneToCubeUV(e,n,s,d,c),t>0&&this._blur(d,0,0,t),this._applyPMREM(d),this._cleanup(d),d}fromSceneAsync(a){return hr(this,arguments,function*(e,t=0,n=.1,s=100,o={}){return this._hasInitialized===!1&&(yield this._renderer.init()),this.fromScene(e,t,n,s,o)})}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}fromEquirectangularAsync(e,t=null){return hr(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}fromCubemapAsync(e,t=null){return hr(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}compileCubemapShader(){return hr(this,null,function*(){this._cubemapMaterial===null&&(this._cubemapMaterial=ON(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return hr(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=FN(),yield this._compileMaterial(this._equirectMaterial))})}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Fe||e.mapping===Xe?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?z:0,z,z),d.render(e,a)}d.autoClear=p,e.background=M}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Fe||e.mapping===Xe;s?this._cubemapMaterial===null&&(this._cubemapMaterial=ON(e)):this._equirectMaterial===null&&(this._equirectMaterial=FN(e));const o=s?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=o;const c=this._cubeSize;sb(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,_S)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let o=1;ofm&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${z} samples when the maximum is set to ${fm}`);const I=[];let ee=0;for(let Oe=0;OeQ-Jg?s-Q+Jg:0),ve=4*(this._cubeSize-oe);sb(t,_e,ve,3*oe,2*oe),u.setRenderTarget(t),u.render(m,_S)}}function FV(r){const e=[],t=[],n=[],s=[];let o=r;const a=r-Jg+1+NN.length;for(let c=0;cr-Jg?d=NN[c-r+Jg-1]:c===0&&(d=0),n.push(d);const p=1/(u-2),m=-p,y=1+p,M=[m,m,y,m,y,y,m,m,y,y,m,y],T=6,G=6,z=3,I=2,ee=1,Q=new Float32Array(z*G*T),oe=new Float32Array(I*G*T),_e=new Float32Array(ee*G*T);for(let Oe=0;Oe2?0:-1,Be=[He,Ce,0,He+2/3,Ce,0,He+2/3,Ce+1,0,He,Ce,0,He+2/3,Ce+1,0,He,Ce+1,0],ft=DV[Oe];Q.set(Be,z*G*ft),oe.set(M,I*G*ft);const zt=[ft,ft,ft,ft,ft,ft];_e.set(zt,ee*G*ft)}const ve=new xr;ve.setAttribute("position",new Qr(Q,z)),ve.setAttribute("uv",new Qr(oe,I)),ve.setAttribute("faceIndex",new Qr(_e,ee)),e.push(ve),s.push(new Zs(ve,null)),o>Jg&&o--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:s}}function DN(r,e){const t={magFilter:Rn,minFilter:Rn,generateMipmaps:!1,type:Vs,format:D,colorSpace:iu},n=new Za(r,e,t);return n.texture.mapping=Ke,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function sb(r,e,t,n,s){r.viewport.set(e,t,n,s),r.scissor.set(e,t,n,s)}function ES(r){const e=new ya;return e.depthTest=!1,e.depthWrite=!1,e.blending=ye,e.name=`PMREM_${r}`,e}function BV(r,e,t){const n=Hl(new Array(fm).fill(0)),s=cr(new ot(0,1,0)),o=cr(0),a=ut(fm),c=cr(0),u=cr(1),d=Ps(null),p=cr(0),m=ut(1/e),y=ut(1/t),M=ut(r),T={n:a,latitudinal:c,weights:n,poleAxis:s,outputDirection:TS,dTheta:o,samples:u,envMap:d,mipInt:p,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:y,CUBEUV_MAX_MIP:M},G=ES("blur");return G.fragmentNode=RN(ac(qs({},T),{latitudinal:c.equal(1)})),LN.set(G,T),G}function ON(r){const e=ES("cubemap");return e.fragmentNode=$g(r,TS),e}function FN(r){const e=ES("equirect");return e.fragmentNode=Ps(r,rS(TS),0),e}const BN=new WeakMap;function UV(r){const e=Math.log2(r)-2,t=1/r;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function kV(r,e,t){const n=zV(e);let s=n.get(r);if((s!==void 0?s.pmremVersion:-1)!==r.pmremVersion){const a=r.image;if(r.isCubeTexture)if(GV(a))s=t.fromCubemap(r,s);else return null;else if(WV(a))s=t.fromEquirectangular(r,s);else return null;s.pmremVersion=r.pmremVersion,n.set(r,s)}return s.texture}function zV(r){let e=BN.get(r);return e===void 0&&(e=new WeakMap,BN.set(r,e)),e}class VV extends Ra{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const s=new Wo;s.isRenderTargetTexture=!0,this._texture=Ps(s),this._width=cr(0),this._height=cr(0),this._maxMip=cr(0),this.updateBeforeType=rs.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=UV(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const n=t?t.pmremVersion:-1,s=this._value;n!==s.pmremVersion&&(s.isPMREMTexture===!0?t=s:t=kV(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new OV(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=BM.mul(qt(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),CN(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function GV(r){if(r==null)return!1;let e=0;const t=6;for(let n=0;n0}const AS=zr(VV).setParameterLength(1,3),UN=new WeakMap;class HV extends Xg{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const m=n.isTextureNode?n.value:t[n.property];let y=UN.get(m);y===void 0&&(y=AS(m),UN.set(m,y)),n=y}const o=t.useAnisotropy===!0||t.anisotropy>0?n2:fo,a=n.context(kN(Ph,o)).mul(G_),c=n.context($V(Vf)).mul(Math.PI).mul(G_),u=hv(a),d=hv(c);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(d);const p=e.context.lightingModel.clearcoatRadiance;if(p){const m=n.context(kN(tv,cm)).mul(G_),y=hv(m);p.addAssign(y)}}}const kN=(r,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Vo.negate().reflect(e),t=r.mul(r).mix(t,e).normalize(),t=t.transformDirection(qc)),t),getTextureLevel:()=>r}},$V=r=>({getUV:()=>r,getTextureLevel:()=>ut(1)}),jV=new Bp;class zN extends ya{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(jV),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new HV(t):null}setupLightingModel(){return new MN}setupSpecular(){const e=Hs(qt(.04),to.rgb,ev);Mc.assign(e),iv.assign(1)}setupVariants(){const e=this.metalnessNode?ut(this.metalnessNode):u2;ev.assign(e);let t=this.roughnessNode?ut(this.roughnessNode):c2;t=oS({roughness:t}),Ph.assign(t),this.setupSpecular(),to.assign(Bi(to.rgb.mul(e.oneMinus()),to.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const XV=new Cx;class qV extends zN{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(XV),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?ut(this.iorNode):S2;sv.assign(e),Mc.assign(Hs(Sc(mM(sv.sub(1).div(sv.add(1))).mul(l2),qt(1)).mul(HM),to.rgb,ev)),iv.assign(Hs(HM,1,ev))}setupLightingModel(){return new MN(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ut(this.clearcoatNode):d2,n=this.clearcoatRoughnessNode?ut(this.clearcoatRoughnessNode):f2;M_.assign(t),tv.assign(oS({roughness:n}))}if(this.useSheen){const t=this.sheenNode?qt(this.sheenNode):g2,n=this.sheenRoughnessNode?ut(this.sheenRoughnessNode):y2;sm.assign(t),S_.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ut(this.iridescenceNode):x2,n=this.iridescenceIORNode?ut(this.iridescenceIORNode):_2,s=this.iridescenceThicknessNode?ut(this.iridescenceThicknessNode):b2;T_.assign(t),eM.assign(n),tM.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?Bn(this.anisotropyNode):v2).toVar();Bf.assign(t.length()),sr(Bf.equal(0),()=>{t.assign(Bn(1,0))}).Else(()=>{t.divAssign(Bn(Bf)),Bf.assign(Bf.saturate())}),E_.assign(Bf.pow2().mix(Ph.pow2(),1)),nv.assign(um[0].mul(t.x).add(um[1].mul(t.y))),om.assign(um[1].mul(t.x).sub(um[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ut(this.transmissionNode):w2,n=this.thicknessNode?ut(this.thicknessNode):M2,s=this.attenuationDistanceNode?ut(this.attenuationDistanceNode):T2,o=this.attenuationColorNode?qt(this.attenuationColorNode):E2;if(C_.assign(t),nM.assign(n),iM.assign(s),rM.assign(o),this.useDispersion){const a=this.dispersionNode?ut(this.dispersionNode):C2;sM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?qt(this.clearcoatNormalNode):p2}setup(e){e.context.setupClearcoatNormal=()=>Vg(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class YV extends null{constructor(e=!1,t=!1,n=!1,s=!1,o=!1,a=!1,c=!1){super(e,t,n,s,o,a),this.useSSS=c}direct({lightDirection:e,lightColor:t,reflectedLight:n},s){if(this.useSSS===!0){const o=s.material,{thicknessColorNode:a,thicknessDistortionNode:c,thicknessAmbientNode:u,thicknessAttenuationNode:d,thicknessPowerNode:p,thicknessScaleNode:m}=o,y=e.add(fo.mul(c)).normalize(),M=ut(Vo.dot(y.negate()).saturate().pow(p).mul(m)),T=qt(M.add(u).mul(a));n.directDiffuse.addAssign(T.mul(d.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},s)}}class AY extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=ut(.1),this.thicknessAmbientNode=ut(0),this.thicknessAttenuationNode=ut(.1),this.thicknessPowerNode=ut(2),this.thicknessScaleNode=ut(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new YV(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const ZV=Kt(({normal:r,lightDirection:e,builder:t})=>{const n=r.dot(e),s=Bn(n.mul(.5).add(.5),0);if(t.material.gradientMap){const o=kd("gradientMap","texture").context({getUV:()=>s});return qt(o.r)}else{const o=s.fwidth().mul(.5);return Hs(qt(.7),qt(1),Su(ut(.7).sub(o.x),ut(.7).add(o.x),s.x))}});class KV extends eb{direct({lightDirection:e,lightColor:t,reflectedLight:n},s){const o=ZV({normal:V_,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(o.mul(dm({diffuseColor:to.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(n.mul(dm({diffuseColor:to}))),s.indirectDiffuse.mulAssign(t)}}const JV=new ly;class QV extends ya{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(JV),this.setValues(e)}setupLightingModel(){return new KV}}const VN=Kt(()=>{const r=qt(Vo.z,0,Vo.x.negate()).normalize(),e=Vo.cross(r);return Bn(r.dot(fo),e.dot(fo)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),e5=new uy;class t5 extends ya{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(e5),this.setValues(e)}setupVariants(e){const t=VN;let n;e.material.matcap?n=kd("matcap","texture").context({getUV:()=>t}):n=qt(Hs(.2,.8,t.y)),to.rgb.mulAssign(n.rgb)}}class n5 extends Ra{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const o=t.cos(),a=t.sin();return w_(o,a,a.negate(),o).mul(n)}else{const o=t,a=rm(Bi(1,0,0,0),Bi(0,Id(o.x),Xc(o.x).negate(),0),Bi(0,Xc(o.x),Id(o.x),0),Bi(0,0,0,1)),c=rm(Bi(Id(o.y),0,Xc(o.y),0),Bi(0,1,0,0),Bi(Xc(o.y).negate(),0,Id(o.y),0),Bi(0,0,0,1)),u=rm(Bi(Id(o.z),Xc(o.z).negate(),0,0),Bi(Xc(o.z),Id(o.z),0,0),Bi(0,0,1,0),Bi(0,0,0,1));return a.mul(c).mul(u).mul(Bi(n,1)).xyz}}}const _v=zr(n5).setParameterLength(2),i5=new cp;class GN extends ya{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(i5),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:s,rotationNode:o,scaleNode:a,sizeAttenuation:c}=this,u=Ud.mul(qt(s||0));let d=Bn(Au[0].xyz.length(),Au[1].xyz.length());a!==null&&(d=d.mul(Bn(a))),n.isPerspectiveCamera&&c===!1&&(d=d.mul(u.z.negate()));let p=Pl.xy;if(t.center&&t.center.isVector2===!0){const M=sz("center","vec2",t);p=p.sub(M.sub(.5))}p=p.mul(d);const m=ut(o||m2),y=_v(p,m);return Bi(u.xy.add(y),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const r5=new uf,s5=new yn;class o5 extends GN{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(r5),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ud.mul(qt(e||Pa)).xyz}setupVertexSprite(e){const{material:t,camera:n}=e,{rotationNode:s,scaleNode:o,sizeNode:a,sizeAttenuation:c}=this;let u=super.setupVertex(e);if(t.isNodeMaterial!==!0)return u;let d=a!==null?Bn(a):A2;d=d.mul(AR),n.isPerspectiveCamera&&c===!0&&(d=d.mul(a5.div(Ia.z.negate()))),o&&o.isNode&&(d=d.mul(Bn(o)));let p=Pl.xy;if(s&&s.isNode){const m=ut(s);p=_v(p,m)}return p=p.mul(d),p=p.div(NM.div(2)),p=p.mul(u.w),u=u.add(Bi(p,0,0)),u}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const a5=cr(1).onFrameUpdate(function({renderer:r}){const e=r.getSize(s5);this.value=.5*e.y});class l5 extends eb{constructor(){super(),this.shadowNode=ut(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){to.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(to.rgb)}}const c5=new hg;class u5 extends ya{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(c5),this.setValues(e)}setupLightingModel(){return new l5}}const bv=th("vec3"),WN=th("vec3"),HN=th("vec3");class h5 extends null{constructor(){super()}start(e){const{material:t,context:n}=e,s=th("vec3"),o=th("vec3");sr(gv.sub(Yc).length().greaterThan(PR.mul(2)),()=>{s.assign(gv),o.assign(Yc)}).Else(()=>{s.assign(Yc),o.assign(gv)});const a=o.sub(s),c=cr("int").onRenderUpdate(({material:y})=>y.steps),u=a.length().div(c).toVar(),d=a.normalize().toVar(),p=ut(0).toVar(),m=qt(1).toVar();t.offsetNode&&p.addAssign(t.offsetNode.mul(u)),po(c,()=>{const y=s.add(d.mul(p)),M=qc.mul(Bi(y,1)).xyz;t.depthNode!==null&&(WN.assign(Zg(eS(M.z,Fd,Bd))),n.sceneDepthNode=Zg(t.depthNode).toVar()),n.positionWorld=y,n.shadowPositionWorld=y,n.positionView=M,bv.assign(0);let T;t.scatteringNode&&(T=t.scatteringNode({positionRay:y})),super.start(e),T&&bv.mulAssign(T);const G=bv.mul(.01).negate().mul(u).exp();m.mulAssign(G),p.addAssign(u)}),HN.addAssign(m.saturate().oneMinus())}scatteringLight(e,t){const n=t.context.sceneDepthNode;n?sr(n.greaterThanEqual(WN),()=>{bv.addAssign(e)}):bv.addAssign(e)}direct({lightNode:e,lightColor:t},n){if(e.light.distance===void 0)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,n)}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:s},o){const a=t.add(n).sub(s),c=t.sub(n).sub(s),u=t.sub(n).add(s),d=t.add(n).add(s),p=o.context.positionView,m=e.xyz.mul(gV({P:p,p0:a,p1:c,p2:u,p3:d})).pow(1.5);this.scatteringLight(m,o)}finish(e){e.context.outgoingLight.assign(HN)}}class CY extends null{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=BackSide,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new h5}}class d5{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class nh{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],s=new Set,o={};for(const a of e){let c;if(a.node&&a.node.attribute?c=a.node.attribute:(c=t.getAttribute(a.name),o[a.name]=c.version),c===void 0)continue;n.push(c);const u=c.isInterleavedBufferAttribute?c.data:c;s.add(u)}return this.attributes=n,this.attributesId=o,this.vertexBuffers=Array.from(s.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:s,drawRange:o}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),c=this.getIndex(),u=c!==null;let d=1;if(n.isInstancedBufferGeometry===!0?d=n.instanceCount:e.count!==void 0&&(d=Math.max(0,e.count)),d===0)return null;if(a.instanceCount=d,e.isBatchedMesh===!0)return a;let p=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(p=2);let m=o.start*p,y=(o.start+o.count)*p;s!==null&&(m=Math.max(m,s.start*p),y=Math.min(y,(s.start+s.count)*p));const M=n.attributes.position;let T=1/0;u?T=c.count:M!=null&&(T=M.count),m=Math.max(m,0),y=Math.min(y,T);const G=y-m;return G<0||G===1/0?null:(a.vertexCount=G,a.firstVertex=m,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const s=e.attributes[n];t+=n+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[n];t+="morph-"+n+",";for(let o=0,a=s.length;o1)&&(s+=e.uuid+","),s+=e.receiveShadow+",",Bw(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=jy(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=jy(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const mm=[];class g5{constructor(e,t,n,s,o,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=s,this.bindings=o,this.info=a,this.chainMaps={}}get(e,t,n,s,o,a,c,u){const d=this.getChainMap(u);mm[0]=e,mm[1]=t,mm[2]=a,mm[3]=o;let p=d.get(mm);return p===void 0?(p=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,s,o,a,c,u),d.set(mm,p)):(p.updateClipping(c),p.needsGeometryUpdate&&p.setGeometry(e.geometry),(p.version!==t.version||p.needsUpdate)&&(p.initialCacheKey!==p.getCacheKey()?(p.dispose(),p=this.get(e,t,n,s,o,a,c,u)):p.version=t.version)),mm.length=0,p}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new nh)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,s,o,a,c,u,d,p,m){const y=this.getChainMap(m),M=new m5(e,t,n,s,o,a,c,u,d,p);return M.onDispose=()=>{this.pipelines.delete(M),this.bindings.delete(M),this.nodes.delete(M),y.delete(M.getChainArray())},M}}class Hf{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ru={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},$f=16,y5=211,v5=212;class x5 extends Hf{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Ru.VERTEX?this.backend.createAttribute(e):t===Ru.INDEX?this.backend.createIndexAttribute(e):t===Ru.STORAGE?this.backend.createStorageAttribute(e):t===Ru.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(n.version{this.info.memory.geometries--;const o=t.index,a=e.getAttributes();o!==null&&this.attributes.delete(o);for(const u of a)this.attributes.delete(u);const c=this.wireframes.get(t);c!==void 0&&this.attributes.delete(c),t.removeEventListener("dispose",s)};t.addEventListener("dispose",s)}updateAttributes(e){const t=e.getAttributes();for(const o of t)o.isStorageBufferAttribute||o.isStorageInstancedBufferAttribute?this.updateAttribute(o,Ru.STORAGE):this.updateAttribute(o,Ru.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Ru.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,Ru.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let s=t.index;if(n.wireframe===!0){const o=this.wireframes;let a=o.get(t);a===void 0?(a=jN(t),o.set(t,a)):a.version!==$N(t)&&(this.attributes.delete(a),a=jN(t),o.set(t,a)),s=a}return s}}class b5{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class XN{constructor(e){this.cacheKey=e,this.usedTimes=0}}class w5 extends XN{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class M5 extends XN{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let S5=0;class CS{constructor(e,t,n,s=null,o=null){this.id=S5++,this.code=e,this.stage=t,this.name=n,this.transforms=s,this.attributes=o,this.usedTimes=0}}class T5 extends Hf{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const o=s.pipeline;o&&(o.usedTimes--,o.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let c=this.programs.compute.get(a.computeShader);c===void 0&&(o&&o.computeProgram.usedTimes===0&&this._releaseProgram(o.computeProgram),c=new CS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,c),n.createProgram(c));const u=this._getComputeCacheKey(e,c);let d=this.caches.get(u);d===void 0&&(o&&o.usedTimes===0&&this._releasePipeline(o),d=this._getComputePipeline(e,c,u,t)),d.usedTimes++,c.usedTimes++,s.version=e.version,s.pipeline=d}return s.pipeline}getForRender(e,t=null){const{backend:n}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const o=s.pipeline;o&&(o.usedTimes--,o.vertexProgram.usedTimes--,o.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),c=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(o&&o.vertexProgram.usedTimes===0&&this._releaseProgram(o.vertexProgram),u=new CS(a.vertexShader,"vertex",c),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let d=this.programs.fragment.get(a.fragmentShader);d===void 0&&(o&&o.fragmentProgram.usedTimes===0&&this._releaseProgram(o.fragmentProgram),d=new CS(a.fragmentShader,"fragment",c),this.programs.fragment.set(a.fragmentShader,d),n.createProgram(d));const p=this._getRenderCacheKey(e,u,d);let m=this.caches.get(p);m===void 0?(o&&o.usedTimes===0&&this._releasePipeline(o),m=this._getRenderPipeline(e,u,d,p,t)):e.pipeline=m,m.usedTimes++,u.usedTimes++,d.usedTimes++,s.pipeline=m}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,s){n=n||this._getComputeCacheKey(e,t);let o=this.caches.get(n);return o===void 0&&(o=new M5(n,t),this.caches.set(n,o),this.backend.createComputePipeline(o,s)),o}_getRenderPipeline(e,t,n,s,o){s=s||this._getRenderCacheKey(e,t,n);let a=this.caches.get(s);return a===void 0&&(a=new w5(s,t,n),this.caches.set(s,a),e.pipeline=a,this.backend.createRenderPipeline(e,o)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class E5 extends Hf{constructor(e,t,n,s,o,a){super(),this.backend=e,this.textures=n,this.pipelines=o,this.attributes=s,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const s=this.get(n);s.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),s.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const s=this.get(n);s.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),s.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,s=n.isIndirectStorageBufferAttribute?Ru.INDIRECT:Ru.STORAGE;this.attributes.update(n,s)}}_update(e,t){const{backend:n}=this;let s=!1,o=!0,a=0,c=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isStorageBuffer){const d=u.attribute,p=d.isIndirectStorageBufferAttribute?Ru.INDIRECT:Ru.STORAGE;this.attributes.update(d,p)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampledTexture){const d=u.update(),p=u.texture,m=this.textures.get(p);if(d&&(this.textures.updateTexture(p),u.generation!==m.generation&&(u.generation=m.generation,s=!0,o=!1)),n.get(p).externalTexture!==void 0||m.isDefaultTexture?o=!1:(a=a*10+p.id,c+=p.version),p.isStorageTexture===!0){const M=this.get(p);u.store===!0?M.needsMipmap=!0:this.textures.needsMipmaps(p)&&M.needsMipmap===!0&&(this.backend.generateMipmaps(p),M.needsMipmap=!1)}}else u.isSampler&&u.update()}s===!0&&this.backend.updateBindings(e,t,o?a:0,c)}}function A5(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?r.z-e.z:r.id-e.id}function qN(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function YN(r){return(r.transmission>0||r.transmissionNode)&&r.side===re&&r.forceSinglePass===!1}class C5{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,s,o,a,c){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:s,renderOrder:e.renderOrder,z:o,group:a,clippingContext:c},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=s,u.renderOrder=e.renderOrder,u.z=o,u.group=a,u.clippingContext=c),this.renderItemsIndex++,u}push(e,t,n,s,o,a,c){const u=this.getNextRenderItem(e,t,n,s,o,a,c);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(YN(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,s,o,a,c){const u=this.getNextRenderItem(e,t,n,s,o,a,c);n.transparent===!0||n.transmission>0?(YN(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||A5),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||qN),this.transparent.length>1&&this.transparent.sort(t||qN)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,d=c.height>>t;let p=e.depthTexture||o[t];const m=e.depthBuffer===!0||e.stencilBuffer===!0;let y=!1;p===void 0&&m&&(p=new gc,p.format=e.stencilBuffer?_:U,p.type=e.stencilBuffer?Da:as,p.image.width=u,p.image.height=d,p.image.depth=c.depth,p.isArrayTexture=e.multiview===!0&&c.depth>1,o[t]=p),(n.width!==c.width||c.height!==n.height)&&(y=!0,p&&(p.needsUpdate=!0,p.image.width=u,p.image.height=d,p.image.depth=p.isArrayTexture?p.image.depth:1)),n.width=c.width,n.height=c.height,n.textures=a,n.depthTexture=p||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==s&&(y=!0,p&&(p.needsUpdate=!0),n.sampleCount=s);const M={sampleCount:s};if(e.isXRRenderTarget!==!0){for(let T=0;T{e.removeEventListener("dispose",T);for(let G=0;G0&&t.levels++,s||e.isStorageTexture===!0||e.isExternalTexture===!0)o.createSampler(e),o.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&o.createSampler(e),e.version>0){const p=e.image;if(p===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(p.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const m=[];for(const y of e.images)m.push(y);t.images=m}else t.image=p;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(o.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&o.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&o.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else o.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&Ki.getTransfer(e.colorSpace)!==Fi&&console.warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.");const d=()=>{e.removeEventListener("dispose",d),this._destroyTexture(e)};e.addEventListener("dispose",d)}n.version=e.version}getSize(e,t=O5){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,n)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class RS extends jn{constructor(e,t,n,s=1){super(e,t,n),this.a=s}set(e,t,n,s=1){return this.a=s,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class KN extends ho{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const B5=(r,e)=>Cn(new KN(r,e));class U5 extends Wi{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}add(e){return e.isNode!==!0?(console.error("THREE.TSL: Invalid node added to stack."),this):(this.nodes.push(e),this)}If(e,t){const n=new Bg(t);return this._currentCond=wl(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Bg(t),s=wl(e,n);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new Bg(e),this}Switch(e){return this._expressionNode=Cn(e),this}Case(...e){const t=[];if(e.length>=2)for(let c=0;ctypeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class z5 extends Wi{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=k5(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const t=Float32Array.BYTES_PER_ELEMENT;let n=0;for(const s of this.membersLayout){const o=s.type,a=BA(o)*t,c=UA(o),u=n%8,d=u%c,p=u+d;n+=d,p!==0&&8-ps.name===t);return n?n.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class V5 extends Wi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),n=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const G5=(r,e=null)=>{const t=new z5(r,e),n=(...s)=>{let o=null;if(s.length>0)if(s[0].isNode){o={};const a=Object.keys(r);for(let c=0;cnew Sv(r,"int","float"),X5=r=>new Sv(r,"uint","float"),q5=r=>new Sv(r,"float","int"),Y5=r=>new Sv(r,"float","uint"),Z5=Kt(([r])=>{const e=r.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/Kf(2,32))}),NS=(r,e)=>wu(Kr(4,r.mul(Ds(1,r))),e),K5=(r,e)=>r.lessThan(.5)?NS(r.mul(2),e).div(2):Ds(1,NS(Kr(Ds(1,r),2),e).div(2)),J5=(r,e,t)=>wu(jc(wu(r,e),Wa(wu(r,e),wu(Ds(1,r),t))),1/e),Q5=(r,e)=>Xc(N_.mul(e.mul(r).sub(1))).div(N_.mul(e.mul(r).sub(1))),zd=Kt(([r])=>r.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),eG=Kt(([r])=>qt(zd(r.z.add(zd(r.y.mul(1)))),zd(r.z.add(zd(r.x.mul(1)))),zd(r.y.add(zd(r.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),tG=Kt(([r,e,t])=>{const n=qt(r).toVar(),s=ut(1.4).toVar(),o=ut(0).toVar(),a=qt(n).toVar();return po({start:ut(0),end:ut(3),type:"float",condition:"<="},()=>{const c=qt(eG(a.mul(2))).toVar();n.addAssign(c.add(t.mul(ut(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),n.mulAssign(1.2);const u=ut(zd(n.z.add(zd(n.x.add(zd(n.y)))))).toVar();o.addAssign(u.div(s)),a.addAssign(.14)}),o}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class nG extends Wi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let s=null,o=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const d=u.inputs;if(t.length===d.length){let p=0;for(let m=0;mo&&(s=a,o=p)}}this._candidateFnCall=n=s(...t)}return n}}const iG=zr(nG),Il=r=>(...e)=>iG(r,...e),e0=cr(0).setGroup(or).onRenderUpdate(r=>r.time),rG=cr(0).setGroup(or).onRenderUpdate(r=>r.deltaTime),tP=cr(0,"uint").setGroup(or).onRenderUpdate(r=>r.frameId),sG=(r=e0)=>r.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),oG=(r=e0)=>r.fract().round(),aG=(r=e0)=>r.add(.5).fract().mul(2).sub(1).abs(),lG=(r=e0)=>r.fract(),cG=Kt(([r,e,t=Bn(.5)])=>_v(r.sub(t),e).add(t)),uG=Kt(([r,e,t=Bn(.5)])=>{const n=r.sub(t),s=n.dot(n),a=s.mul(s).mul(e);return r.add(n.mul(a))}),hG=Kt(({position:r=null,horizontal:e=!0,vertical:t=!1})=>{let n;r!==null?(n=Au.toVar(),n[3][0]=r.x,n[3][1]=r.y,n[3][2]=r.z):n=Au;const s=qc.mul(n);return Ky(e)&&(s[0][0]=Au[0].length(),s[0][1]=0,s[0][2]=0),Ky(t)&&(s[1][0]=0,s[1][1]=Au[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Tu.mul(s).mul(Pa)}),dG=Kt(([r=null])=>{const e=Zg();return Zg(QM(r)).sub(e).lessThan(0).select(Od,r)});class fG extends Wi{static get type(){return"SpriteSheetUVNode"}constructor(e,t=vo(),n=ut(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:s,height:o}=n,a=e.mod(s.mul(o)).floor(),c=a.mod(s),u=o.sub(a.add(1).div(s).ceil()),d=n.reciprocal(),p=Bn(c,u);return t.add(p).mul(d)}}const pG=zr(fG).setParameterLength(3),nP=Kt(([r,e=null,t=null,n=ut(1),s=Pa,o=Tc])=>{let a=o.abs().normalize();a=a.div(a.dot(qt(1)));const c=s.yz.mul(n),u=s.zx.mul(n),d=s.xy.mul(n),p=r.value,m=e!==null?e.value:p,y=t!==null?t.value:p,M=Ps(p,c).mul(a.x),T=Ps(m,u).mul(a.y),G=Ps(y,d).mul(a.z);return Wa(M,T,G)}),mG=(...r)=>nP(...r),t0=new Al,gm=new ot,n0=new ot,PS=new ot,Tv=new Ft,ab=new ot(0,0,-1),Uh=new mr,Ev=new ot,lb=new ot,Av=new mr,cb=new yn,ub=new Za,gG=Od.flipX();ub.depthTexture=new gc(1,1);let hb=!1;class IS extends Bh{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||ub.texture,gG),this._reflectorBaseNode=e.reflector||new yG(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Cn(new IS({defaultTexture:ub.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class yG extends Wi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Jr,resolutionScale:s=1,generateMipmaps:o=!1,bounces:a=!0,depth:c=!1,samples:u=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=s,t.resolution!==void 0&&(ol('THREE.ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=o,this.bounces=a,this.depth=c,this.samples=u,this.updateBeforeType=a?rs.RENDER:rs.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(cb),e.setSize(Math.round(cb.width*n),Math.round(cb.height*n))}setup(e){return this._updateResolution(ub,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Za(0,0,{type:Vs,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=Vi,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new gc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&hb)return!1;hb=!0;const{scene:t,camera:n,renderer:s,material:o}=e,{target:a}=this,c=this.getVirtualCamera(n),u=this.getRenderTarget(c);s.getDrawingBufferSize(cb),this._updateResolution(u,s),n0.setFromMatrixPosition(a.matrixWorld),PS.setFromMatrixPosition(n.matrixWorld),Tv.extractRotation(a.matrixWorld),gm.set(0,0,1),gm.applyMatrix4(Tv),Ev.subVectors(n0,PS);const d=Ev.dot(gm)>0;let p=!1;if(d===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){hb=!1;return}p=!0}Ev.reflect(gm).negate(),Ev.add(n0),Tv.extractRotation(n.matrixWorld),ab.set(0,0,-1),ab.applyMatrix4(Tv),ab.add(PS),lb.subVectors(n0,ab),lb.reflect(gm).negate(),lb.add(n0),c.coordinateSystem=n.coordinateSystem,c.position.copy(Ev),c.up.set(0,1,0),c.up.applyMatrix4(Tv),c.up.reflect(gm),c.lookAt(lb),c.near=n.near,c.far=n.far,c.updateMatrixWorld(),c.projectionMatrix.copy(n.projectionMatrix),t0.setFromNormalAndCoplanarPoint(gm,n0),t0.applyMatrix4(c.matrixWorldInverse),Uh.set(t0.normal.x,t0.normal.y,t0.normal.z,t0.constant);const m=c.projectionMatrix;Av.x=(Math.sign(Uh.x)+m.elements[8])/m.elements[0],Av.y=(Math.sign(Uh.y)+m.elements[9])/m.elements[5],Av.z=-1,Av.w=(1+m.elements[10])/m.elements[14],Uh.multiplyScalar(1/Uh.dot(Av));const y=0;m.elements[2]=Uh.x,m.elements[6]=Uh.y,m.elements[10]=s.coordinateSystem===ja?Uh.z-y:Uh.z+1-y,m.elements[14]=Uh.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),o.visible=!1;const M=s.getRenderTarget(),T=s.getMRT(),G=s.autoClear;s.setMRT(null),s.setRenderTarget(u),s.autoClear=!0,p?(s.clear(),this.hasOutput=!1):(s.render(t,c),this.hasOutput=!0),s.setMRT(T),s.setRenderTarget(M),s.autoClear=G,o.visible=!0,hb=!1,this.forceUpdate=!1}get resolution(){return ol('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){ol('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const vG=r=>Cn(new IS(r)),LS=new Cf(-1,1,1,-1,0,1);class xG extends xr{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Zi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Zi(t,2))}}const _G=new xG;class Cv extends Zs{constructor(e=null){super(_G,e),this.camera=LS,this.isQuadMesh=!0}renderAsync(e){return hr(this,null,function*(){return e.renderAsync(this,LS)})}render(e){e.render(this,LS)}}const bG=new yn;class wG extends Bh{static get type(){return"RTTNode"}constructor(e,t=null,n=null,s={type:Vs}){const o=new Za(t,n,s);super(o.texture,vo()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=o,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new Cv(new ya),this.updateBeforeType=rs.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(n,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){const n=e.getPixelRatio(),s=e.getSize(bG),o=s.width*n,a=s.height*n;(o!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(o,a),this.textureNeedsUpdate=!0)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Bh(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const iP=(r,...e)=>Cn(new wG(Cn(r),...e)),MG=(r,...e)=>r.isSampleNode||r.isTextureNode?r:r.isPassNode?r.getTextureNode():iP(r,...e),i0=Kt(([r,e,t],n)=>{let s;n.renderer.coordinateSystem===ja?(r=Bn(r.x,r.y.oneMinus()).mul(2).sub(1),s=Bi(qt(r,e),1)):s=Bi(qt(r.x,r.y.oneMinus(),e).mul(2).sub(1),1);const o=Bi(t.mul(s));return o.xyz.div(o.w)}),SG=Kt(([r,e])=>{const t=e.mul(Bi(r,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Bn(n.x,n.y.oneMinus())}),TG=Kt(([r,e,t])=>{const n=kf(Na(e)),s=pl(r.mul(n)).toVar(),o=Na(e,s).toVar(),a=Na(e,s.sub(pl(2,0))).toVar(),c=Na(e,s.sub(pl(1,0))).toVar(),u=Na(e,s.add(pl(1,0))).toVar(),d=Na(e,s.add(pl(2,0))).toVar(),p=Na(e,s.add(pl(0,2))).toVar(),m=Na(e,s.add(pl(0,1))).toVar(),y=Na(e,s.sub(pl(0,1))).toVar(),M=Na(e,s.sub(pl(0,2))).toVar(),T=Oo(Ds(ut(2).mul(c).sub(a),o)).toVar(),G=Oo(Ds(ut(2).mul(u).sub(d),o)).toVar(),z=Oo(Ds(ut(2).mul(m).sub(p),o)).toVar(),I=Oo(Ds(ut(2).mul(y).sub(M),o)).toVar(),ee=i0(r,o,t).toVar(),Q=T.lessThan(G).select(ee.sub(i0(r.sub(Bn(ut(1).div(n.x),0)),c,t)),ee.negate().add(i0(r.add(Bn(ut(1).div(n.x),0)),u,t))),oe=z.lessThan(I).select(ee.sub(i0(r.add(Bn(0,ut(1).div(n.y))),m,t)),ee.negate().add(i0(r.sub(Bn(0,ut(1).div(n.y))),y,t)));return Nd(O_(Q,oe))});class EG extends Wi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(vo())}sample(e){return this.callback(e)}}const AG=(r,e=null)=>Cn(new EG(r,Cn(e)));class jf extends Wi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===jf.OBJECT?this.updateType=rs.OBJECT:e===jf.MATERIAL&&(this.updateType=rs.RENDER)}update(e){this.callback(e)}}jf.OBJECT="object",jf.MATERIAL="material";const rP=(r,e)=>Cn(new jf(r,e)).toStack(),CG=r=>rP(jf.OBJECT,r),RG=r=>rP(jf.MATERIAL,r);class NG extends kc{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageInstancedBufferAttribute=!0}}class PG extends Qr{constructor(e,t,n=Float32Array){const s=ArrayBuffer.isView(e)?e:new n(e*t);super(s,t),this.isStorageBufferAttribute=!0}}const IG=(r,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=qy("float")):(t=zw(e),n=qy(e));const s=new PG(r,t,n);return hm(s,e,r)},LG=(r,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=qy("float")):(t=zw(e),n=qy(e));const s=new NG(r,t,n);return hm(s,e,r)};class DG extends Wi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const OG=xi(DG),Rv=new Qi,DS=new Ft;class Ac extends Wi{static get type(){return"SceneNode"}constructor(e=Ac.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let s;return t===Ac.BACKGROUND_BLURRINESS?s=No("backgroundBlurriness","float",n):t===Ac.BACKGROUND_INTENSITY?s=No("backgroundIntensity","float",n):t===Ac.BACKGROUND_ROTATION?s=cr("mat4").setName("backgroundRotation").setGroup(or).onRenderUpdate(()=>{const o=n.background;return o!==null&&o.isTexture&&o.mapping!==te?(Rv.copy(n.backgroundRotation),Rv.x*=-1,Rv.y*=-1,Rv.z*=-1,DS.makeRotationFromEuler(Rv)):DS.identity(),DS}):console.error("THREE.SceneNode: Unknown scope:",t),s}}Ac.BACKGROUND_BLURRINESS="backgroundBlurriness",Ac.BACKGROUND_INTENSITY="backgroundIntensity",Ac.BACKGROUND_ROTATION="backgroundRotation";const sP=xi(Ac,Ac.BACKGROUND_BLURRINESS),OS=xi(Ac,Ac.BACKGROUND_INTENSITY),oP=xi(Ac,Ac.BACKGROUND_ROTATION);class FG extends Bh{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Nl.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(Nl.READ_WRITE)}toReadOnly(){return this.setAccess(Nl.READ_ONLY)}toWriteOnly(){return this.setAccess(Nl.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:s,depthNode:o}=t,a=super.generate(e,"property"),c=n.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),u=s.build(e,"vec4"),d=o?o.build(e,"int"):null,p=e.generateTextureStore(e,a,c,d,u);e.addLineFlowCode(p,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const aP=zr(FG).setParameterLength(1,3),BG=(r,e,t)=>{const n=aP(r,e,t);return t!==null&&n.toStack(),n},UG=Kt(({texture:r,uv:e})=>{const n=qt().toVar();return sr(e.x.lessThan(1e-4),()=>{n.assign(qt(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(qt(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(qt(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(qt(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(qt(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(qt(0,0,-1))}).Else(()=>{const o=r.sample(e.add(qt(-.01,0,0))).r.sub(r.sample(e.add(qt(.01,0,0))).r),a=r.sample(e.add(qt(0,-.01,0))).r.sub(r.sample(e.add(qt(0,.01,0))).r),c=r.sample(e.add(qt(0,0,-.01))).r.sub(r.sample(e.add(qt(0,0,.01))).r);n.assign(qt(o,a,c))}),n.normalize()});class kG extends Bh{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return qt(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Dt(kf(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return UG({texture:this,uv:e})}}const lP=zr(kG).setParameterLength(1,3);class zG extends W_{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const VG=(r,e,t)=>Cn(new zG(r,e,t)),cP=new WeakMap;class GG extends Ra{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=rs.OBJECT,this.updateAfterType=rs.OBJECT,this.previousModelWorldMatrix=cr(new Ft),this.previousProjectionMatrix=cr(new Ft).setGroup(or),this.previousCameraViewMatrix=cr(new Ft)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const s=hP(n);this.previousModelWorldMatrix.value.copy(s);const o=uP(t);o.frameId!==e&&(o.frameId=e,o.previousProjectionMatrix===void 0?(o.previousProjectionMatrix=new Ft,o.previousCameraViewMatrix=new Ft,o.currentProjectionMatrix=new Ft,o.currentCameraViewMatrix=new Ft,o.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(o.previousProjectionMatrix.copy(o.currentProjectionMatrix),o.previousCameraViewMatrix.copy(o.currentCameraViewMatrix)),o.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(o.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(o.previousCameraViewMatrix))}updateAfter({object:e}){hP(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Tu:cr(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Ud).mul(Pa),s=this.previousProjectionMatrix.mul(t).mul(z_),o=n.xy.div(n.w),a=s.xy.div(s.w);return Ds(o,a)}}function uP(r){let e=cP.get(r);return e===void 0&&(e={},cP.set(r,e)),e}function hP(r,e=0){const t=uP(r);let n=t[e];return n===void 0&&(t[e]=n=new Ft,t[e].copy(r.matrixWorld)),n}const WG=xi(GG),HG=Kt(([r])=>FS(r.rgb)),$G=Kt(([r,e=ut(1)])=>e.mix(FS(r.rgb),r.rgb)),jG=Kt(([r,e=ut(1)])=>{const t=Wa(r.r,r.g,r.b).div(3),n=r.r.max(r.g.max(r.b)),s=n.sub(t).mul(e).mul(-3);return Hs(r.rgb,n,s)}),XG=Kt(([r,e=ut(1)])=>{const t=qt(.57735,.57735,.57735),n=e.cos();return qt(r.rgb.mul(n).add(t.cross(r.rgb).mul(e.sin()).add(t.mul(Uf(t,r.rgb).mul(n.oneMinus())))))}),FS=(r,e=qt(Ki.getLuminanceCoefficients(new ot)))=>Uf(r,e),qG=Kt(([r,e=qt(1),t=qt(0),n=qt(1),s=ut(1),o=qt(Ki.getLuminanceCoefficients(new ot,iu))])=>{const a=r.rgb.dot(qt(o)),c=ga(r.rgb.mul(e).add(t),0).toVar(),u=c.pow(n).toVar();return sr(c.r.greaterThan(0),()=>{c.r.assign(u.r)}),sr(c.g.greaterThan(0),()=>{c.g.assign(u.g)}),sr(c.b.greaterThan(0),()=>{c.b.assign(u.b)}),c.assign(a.add(c.sub(a).mul(s))),Bi(c.rgb,r.a)});class YG extends Ra{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const ZG=zr(YG).setParameterLength(2),db=new yn;class dP extends Bh{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class fP extends dP{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}class kh extends Ra{static get type(){return"PassNode"}constructor(e,t,n,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const o=new gc;o.isRenderTargetTexture=!0,o.name="depth";const a=new Za(this._width*this._pixelRatio,this._height*this._pixelRatio,qs({type:Vs},s));a.texture.name="output",a.depthTexture=o,this.renderTarget=a,this._textures={output:a.texture,depth:o},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=cr(0),this._cameraFar=cr(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=rs.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],s=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=Cn(new fP(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=Cn(new fP(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=tS(this.getTextureNode(e),n,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,s=this._cameraFar,o=this.getViewZNode(e);this._linearDepthNodes[e]=t=Yg(o,n,s)}return t}compileAsync(e){return hr(this,null,function*(){const t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),yield e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)})}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===kh.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n}=this;let s,o;const a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(o=1,s=t.xr.getCamera(),t.xr.updateCamera(s),db.set(a.width,a.height)):(s=this.camera,o=t.getPixelRatio(),t.getSize(db)),this._pixelRatio=o,this.setSize(db.width,db.height);const c=t.getRenderTarget(),u=t.getMRT(),d=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const p in this._previousTextures)this.toggleTexture(p);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,s),t.setRenderTarget(c),t.setMRT(u),s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,s),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new mr),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,s),this._scissor.multiplyScalar(this._pixelRatio*this._resolution).floor())}setViewport(e,t,n,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new mr),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,s),this._viewport.multiplyScalar(this._pixelRatio*this._resolution).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}kh.COLOR="color",kh.DEPTH="depth";const KG=(r,e,t)=>Cn(new kh(kh.COLOR,r,e,t)),JG=(r,e)=>Cn(new dP(r,e)),QG=(r,e,t)=>Cn(new kh(kh.DEPTH,r,e,t));class e6 extends kh{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,s,o){super(kh.COLOR,e,t),this.colorNode=n,this.thicknessNode=s,this.alphaNode=o,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((s,o,a,c,u,d,p,m)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const y=this._getOutlineMaterial(u);t.renderObject(s,o,a,c,y,d,p,m)}t.renderObject(s,o,a,c,u,d,p,m)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new ya;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=K;const t=Tc.negate(),n=Tu.mul(Ud),s=ut(1),o=n.mul(Bi(Pa,1)),a=n.mul(Bi(Pa.add(t),1)),c=Nd(o.sub(a));return e.vertexNode=o.add(c.mul(this.thicknessNode).mul(o.w).mul(s)),e.colorNode=Bi(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const t6=(r,e,t=new jn(0,0,0),n=.003,s=1)=>Cn(new e6(r,e,Cn(t),Cn(n),Cn(s))),pP=Kt(([r,e])=>r.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mP=Kt(([r,e])=>(r=r.mul(e),r.div(r.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),gP=Kt(([r,e])=>{r=r.mul(e),r=r.sub(.004).max(0);const t=r.mul(r.mul(6.2).add(.5)),n=r.mul(r.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),n6=Kt(([r])=>{const e=r.mul(r.add(.0245786)).sub(90537e-9),t=r.mul(r.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),yP=Kt(([r,e])=>{const t=Wl(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=Wl(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return r=r.mul(e).div(.6),r=t.mul(r),r=n6(r),r=n.mul(r),r.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),i6=Wl(qt(1.6605,-.1246,-.0182),qt(-.5876,1.1329,-.1006),qt(-.0728,-.0083,1.1187)),r6=Wl(qt(.6274,.0691,.0164),qt(.3293,.9195,.088),qt(.0433,.0113,.8956)),s6=Kt(([r])=>{const e=qt(r).toVar(),t=qt(e.mul(e)).toVar(),n=qt(t.mul(t)).toVar();return ut(15.5).mul(n.mul(t)).sub(Kr(40.14,n.mul(e))).add(Kr(31.96,n).sub(Kr(6.868,t.mul(e))).add(Kr(.4298,t).add(Kr(.1191,e).sub(.00232))))}),vP=Kt(([r,e])=>{const t=qt(r).toVar(),n=Wl(qt(.856627153315983,.137318972929847,.11189821299995),qt(.0951212405381588,.761241990602591,.0767994186031903),qt(.0482516061458583,.101439036467562,.811302368396859)),s=Wl(qt(1.1271005818144368,-.1413297634984383,-.14132976349843826),qt(-.11060664309660323,1.157823702216272,-.11060664309660294),qt(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=ut(-12.47393),a=ut(4.026069);return t.mulAssign(e),t.assign(r6.mul(t)),t.assign(n.mul(t)),t.assign(ga(t,1e-10)),t.assign(Ih(t)),t.assign(t.sub(o).div(a.sub(o))),t.assign(Mu(t,0,1)),t.assign(s6(t)),t.assign(s.mul(t)),t.assign(wu(ga(qt(0),t),qt(2.2))),t.assign(i6.mul(t)),t.assign(Mu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xP=Kt(([r,e])=>{const t=ut(.76),n=ut(.15);r=r.mul(e);const s=Sc(r.r,Sc(r.g,r.b)),o=wl(s.lessThan(.08),s.sub(Kr(6.25,s.mul(s))),.04);r.subAssign(o);const a=ga(r.r,ga(r.g,r.b));sr(a.lessThan(t),()=>r);const c=Ds(1,t),u=Ds(1,c.mul(c).div(a.add(c.sub(t))));r.mulAssign(u.div(a));const d=Ds(1,jc(1,n.mul(a.sub(u)).add(1)));return Hs(r,qt(u),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class $l extends Wi{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const fb=zr($l).setParameterLength(1,3),o6=(r,e)=>fb(r,e,"js"),a6=(r,e)=>fb(r,e,"wgsl"),l6=(r,e)=>fb(r,e,"glsl");class _P extends $l{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),s=n.name,o=n.type,a=e.getCodeFromNode(this,o);s!==""&&(a.name=s);const c=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(c);return a.code=u+` `,t==="property"?c:e.format(`${c}()`,o,t)}}const bP=(r,e=[],t="")=>{for(let o=0;on.call(...o);return s.functionNode=n,s},c6=(r,e)=>bP(r,e,"glsl"),u6=(r,e)=>bP(r,e,"wgsl");class h6 extends Wi{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Ol,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ut()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Gw(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Ww(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const pb=zr(h6).setParameterLength(1);class wP extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const s=t(...n);return this.set(e,s),s}}}class d6{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const mb=new wP;class f6 extends Wi{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new wP,this._output=pb(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=pb(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=pb(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const s=this.getObject()[e];if(typeof s=="function")return s(...t)}callAsync(e,...t){return hr(this,null,function*(){const s=this.getObject()[e];if(typeof s=="function")return s.constructor.name==="AsyncFunction"?yield s(...t):s(...t)})}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(d,p)=>this.setOutput(d,p),n=new d6(this),s=mb.get("THREE"),o=mb.get("TSL"),a=this.getMethod(),c=[n,this._local,mb,e,t,s,o];this._object=a(...c);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const d of u.elements){const p=d.id||d.name;d.inputType&&(this.getParameter(p)===void 0&&this.setParameter(p,null),this.getParameter(p).inputType=d.inputType),d.outputType&&(this.getOutput(p)===void 0&&this.setOutput(p,null),this.getOutput(p).outputType=d.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ut()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),s="var "+n+`; var output = {}; `,o=` return { ...output, `+n+" };",a=s+this.codeNode.code+o;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[Bw(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return $y(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const p6=zr(f6).setParameterLength(1,2);function MP(r){let e;const t=r.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Ia.z).negate()}const BS=Kt(([r,e],t)=>{const n=MP(t);return Su(r,e,n)}),US=Kt(([r],e)=>{const t=MP(e);return r.mul(r,t,t).negate().exp().oneMinus()}),Nv=Kt(([r,e])=>Bi(e.toFloat().mix(kg.rgb,r.toVec3()),kg.a));function m6(r,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Nv(r,BS(e,t))}function g6(r,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Nv(r,US(e))}let ym=null,vm=null;class y6 extends Wi{static get type(){return"RangeNode"}constructor(e=ut(),t=ut()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Rd(this.minNode.value)),n=e.getTypeLength(Rd(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const s=this.minNode.value,o=this.maxNode.value,a=e.getTypeLength(Rd(s)),c=e.getTypeLength(Rd(o));ym=ym||new mr,vm=vm||new mr,ym.setScalar(0),vm.setScalar(0),a===1?ym.setScalar(s):s.isColor?ym.set(s.r,s.g,s.b,1):ym.set(s.x,s.y,s.z||0,s.w||0),c===1?vm.setScalar(o):o.isColor?vm.set(o.r,o.g,o.b,1):vm.set(o.x,o.y,o.z||0,o.w||0);const u=4,d=u*t.count,p=new Float32Array(d);for(let y=0;yCn(new x6(r,e)),_6=Pv("numWorkgroups","uvec3"),b6=Pv("workgroupId","uvec3"),w6=Pv("globalId","uvec3"),M6=Pv("localId","uvec3"),S6=Pv("subgroupSize","uint");class T6 extends Wi{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier `):e.addLineFlowCode(`${t}Barrier()`,this)}}const kS=zr(T6),E6=()=>kS("workgroup").toStack(),A6=()=>kS("storage").toStack(),C6=()=>kS("texture").toStack();class R6 extends nm{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const s=e.context.assign;if(n=super.generate(e),s!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}class N6 extends Wi{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Cn(new R6(this,e))}generate(e){const t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const P6=(r,e)=>Cn(new N6("Workgroup",r,e));class ml extends Wi{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),n=t.parents,s=this.method,o=this.getNodeType(e),a=this.getInputType(e),c=this.pointerNode,u=this.valueNode,d=[];d.push(`&${c.build(e,a)}`),u!==null&&d.push(u.build(e,a));const p=`${e.getMethod(s,o)}( ${d.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(p,this);else return t.constNode===void 0&&(t.constNode=Ld(p,o).toConst()),t.constNode.build(e)}}ml.ATOMIC_LOAD="atomicLoad",ml.ATOMIC_STORE="atomicStore",ml.ATOMIC_ADD="atomicAdd",ml.ATOMIC_SUB="atomicSub",ml.ATOMIC_MAX="atomicMax",ml.ATOMIC_MIN="atomicMin",ml.ATOMIC_AND="atomicAnd",ml.ATOMIC_OR="atomicOr",ml.ATOMIC_XOR="atomicXor";const I6=zr(ml),zh=(r,e,t)=>I6(r,e,t).toStack(),L6=r=>zh(ml.ATOMIC_LOAD,r,null),D6=(r,e)=>zh(ml.ATOMIC_STORE,r,e),O6=(r,e)=>zh(ml.ATOMIC_ADD,r,e),F6=(r,e)=>zh(ml.ATOMIC_SUB,r,e),B6=(r,e)=>zh(ml.ATOMIC_MAX,r,e),U6=(r,e)=>zh(ml.ATOMIC_MIN,r,e),k6=(r,e)=>zh(ml.ATOMIC_AND,r,e),z6=(r,e)=>zh(ml.ATOMIC_OR,r,e),V6=(r,e)=>zh(ml.ATOMIC_XOR,r,e);class Ai extends Ra{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n);return s>o?t:n}getNodeType(e){const t=this.method;return t===Ai.SUBGROUP_ELECT?"bool":t===Ai.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,s=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,c=this.bNode,u=[];if(n===Ai.SUBGROUP_BROADCAST||n===Ai.SUBGROUP_SHUFFLE||n===Ai.QUAD_BROADCAST){const p=c.getNodeType(e);u.push(a.build(e,s),c.build(e,p==="float"?"int":s))}else n===Ai.SUBGROUP_SHUFFLE_XOR||n===Ai.SUBGROUP_SHUFFLE_DOWN||n===Ai.SUBGROUP_SHUFFLE_UP?u.push(a.build(e,s),c.build(e,"uint")):(a!==null&&u.push(a.build(e,o)),c!==null&&u.push(c.build(e,o)));const d=u.length===0?"()":`( ${u.join(", ")} )`;return e.format(`${e.getMethod(n,s)}${d}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Ai.SUBGROUP_ELECT="subgroupElect",Ai.SUBGROUP_BALLOT="subgroupBallot",Ai.SUBGROUP_ADD="subgroupAdd",Ai.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",Ai.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",Ai.SUBGROUP_MUL="subgroupMul",Ai.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",Ai.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",Ai.SUBGROUP_AND="subgroupAnd",Ai.SUBGROUP_OR="subgroupOr",Ai.SUBGROUP_XOR="subgroupXor",Ai.SUBGROUP_MIN="subgroupMin",Ai.SUBGROUP_MAX="subgroupMax",Ai.SUBGROUP_ALL="subgroupAll",Ai.SUBGROUP_ANY="subgroupAny",Ai.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",Ai.QUAD_SWAP_X="quadSwapX",Ai.QUAD_SWAP_Y="quadSwapY",Ai.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",Ai.SUBGROUP_BROADCAST="subgroupBroadcast",Ai.SUBGROUP_SHUFFLE="subgroupShuffle",Ai.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",Ai.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",Ai.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",Ai.QUAD_BROADCAST="quadBroadcast";const G6=ci(Ai,Ai.SUBGROUP_ELECT).setParameterLength(0),W6=ci(Ai,Ai.SUBGROUP_BALLOT).setParameterLength(1),H6=ci(Ai,Ai.SUBGROUP_ADD).setParameterLength(1),$6=ci(Ai,Ai.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),j6=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),X6=ci(Ai,Ai.SUBGROUP_MUL).setParameterLength(1),q6=ci(Ai,Ai.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Y6=ci(Ai,Ai.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),Z6=ci(Ai,Ai.SUBGROUP_AND).setParameterLength(1),K6=ci(Ai,Ai.SUBGROUP_OR).setParameterLength(1),J6=ci(Ai,Ai.SUBGROUP_XOR).setParameterLength(1),Q6=ci(Ai,Ai.SUBGROUP_MIN).setParameterLength(1),e8=ci(Ai,Ai.SUBGROUP_MAX).setParameterLength(1),t8=ci(Ai,Ai.SUBGROUP_ALL).setParameterLength(0),n8=ci(Ai,Ai.SUBGROUP_ANY).setParameterLength(0),i8=ci(Ai,Ai.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),r8=ci(Ai,Ai.QUAD_SWAP_X).setParameterLength(1),s8=ci(Ai,Ai.QUAD_SWAP_Y).setParameterLength(1),o8=ci(Ai,Ai.QUAD_SWAP_DIAGONAL).setParameterLength(1),a8=ci(Ai,Ai.SUBGROUP_BROADCAST).setParameterLength(2),l8=ci(Ai,Ai.SUBGROUP_SHUFFLE).setParameterLength(2),c8=ci(Ai,Ai.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),u8=ci(Ai,Ai.SUBGROUP_SHUFFLE_UP).setParameterLength(2),h8=ci(Ai,Ai.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),d8=ci(Ai,Ai.QUAD_BROADCAST).setParameterLength(1);let gb;function yb(r){gb=gb||new WeakMap;let e=gb.get(r);return e===void 0&&gb.set(r,e={}),e}function vb(r){const e=yb(r);return e.shadowMatrix||(e.shadowMatrix=cr("mat4").setGroup(or).onRenderUpdate(t=>((r.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&r.shadow.updateMatrices(r),r.shadow.matrix)))}function SP(r,e=Yc){const t=vb(r).mul(e);return t.xyz.div(t.w)}function zS(r){const e=yb(r);return e.position||(e.position=cr(new ot).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(r.matrixWorld)))}function TP(r){const e=yb(r);return e.targetPosition||(e.targetPosition=cr(new ot).setGroup(or).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(r.target.matrixWorld)))}function VS(r){const e=yb(r);return e.viewPosition||(e.viewPosition=cr(new ot).setGroup(or).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new ot,n.value.setFromMatrixPosition(r.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const GS=r=>qc.transformDirection(zS(r).sub(TP(r))),f8=r=>r.sort((e,t)=>e.id-t.id),p8=(r,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===r)return t;return null},WS=new WeakMap,Iv=[];class HS extends Wi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=th("vec3","totalDiffuse"),this.totalSpecularNode=th("vec3","totalSpecular"),this.outgoingLightNode=th("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n0}}const m8=(r=[])=>Cn(new HS).setLights(r);class g8 extends Wi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=rs.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){$S.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Yc)}}const $S=th("vec3","shadowPositionWorld");function jS(r,e={}){return e.toneMapping=r.toneMapping,e.toneMappingExposure=r.toneMappingExposure,e.outputColorSpace=r.outputColorSpace,e.renderTarget=r.getRenderTarget(),e.activeCubeFace=r.getActiveCubeFace(),e.activeMipmapLevel=r.getActiveMipmapLevel(),e.renderObjectFunction=r.getRenderObjectFunction(),e.pixelRatio=r.getPixelRatio(),e.mrt=r.getMRT(),e.clearColor=r.getClearColor(e.clearColor||new jn),e.clearAlpha=r.getClearAlpha(),e.autoClear=r.autoClear,e.scissorTest=r.getScissorTest(),e}function EP(r,e){return e=jS(r,e),r.setMRT(null),r.setRenderObjectFunction(null),r.setClearColor(0,1),r.autoClear=!0,e}function AP(r,e){r.toneMapping=e.toneMapping,r.toneMappingExposure=e.toneMappingExposure,r.outputColorSpace=e.outputColorSpace,r.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),r.setRenderObjectFunction(e.renderObjectFunction),r.setPixelRatio(e.pixelRatio),r.setMRT(e.mrt),r.setClearColor(e.clearColor,e.clearAlpha),r.autoClear=e.autoClear,r.setScissorTest(e.scissorTest)}function XS(r,e={}){return e.background=r.background,e.backgroundNode=r.backgroundNode,e.overrideMaterial=r.overrideMaterial,e}function CP(r,e){return e=XS(r,e),r.background=null,r.backgroundNode=null,r.overrideMaterial=null,e}function RP(r,e){r.background=e.background,r.backgroundNode=e.backgroundNode,r.overrideMaterial=e.overrideMaterial}function y8(r,e,t={}){return t=jS(r,t),t=XS(e,t),t}function NP(r,e,t){return t=EP(r,t),t=CP(e,t),t}function PP(r,e,t){AP(r,t),RP(e,t)}var RY=Object.freeze({__proto__:null,resetRendererAndSceneState:NP,resetRendererState:EP,resetSceneState:CP,restoreRendererAndSceneState:PP,restoreRendererState:AP,restoreSceneState:RP,saveRendererAndSceneState:y8,saveRendererState:jS,saveSceneState:XS});const IP=new WeakMap,LP=Kt(({depthTexture:r,shadowCoord:e,depthLayer:t})=>{let n=Ps(r,e.xy).setName("t_basic");return r.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),DP=Kt(({depthTexture:r,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(z,I)=>{let ee=Ps(r,z);return r.isArrayTexture&&(ee=ee.depth(n)),ee.compare(I)},o=No("mapSize","vec2",t).setGroup(or),a=No("radius","float",t).setGroup(or),c=Bn(1).div(o),u=c.x.negate().mul(a),d=c.y.negate().mul(a),p=c.x.mul(a),m=c.y.mul(a),y=u.div(2),M=d.div(2),T=p.div(2),G=m.div(2);return Wa(s(e.xy.add(Bn(u,d)),e.z),s(e.xy.add(Bn(0,d)),e.z),s(e.xy.add(Bn(p,d)),e.z),s(e.xy.add(Bn(y,M)),e.z),s(e.xy.add(Bn(0,M)),e.z),s(e.xy.add(Bn(T,M)),e.z),s(e.xy.add(Bn(u,0)),e.z),s(e.xy.add(Bn(y,0)),e.z),s(e.xy,e.z),s(e.xy.add(Bn(T,0)),e.z),s(e.xy.add(Bn(p,0)),e.z),s(e.xy.add(Bn(y,G)),e.z),s(e.xy.add(Bn(0,G)),e.z),s(e.xy.add(Bn(T,G)),e.z),s(e.xy.add(Bn(u,m)),e.z),s(e.xy.add(Bn(0,m)),e.z),s(e.xy.add(Bn(p,m)),e.z)).mul(1/17)}),OP=Kt(({depthTexture:r,shadowCoord:e,shadow:t,depthLayer:n})=>{const s=(m,y)=>{let M=Ps(r,m);return r.isArrayTexture&&(M=M.depth(n)),M.compare(y)},o=No("mapSize","vec2",t).setGroup(or),a=Bn(1).div(o),c=a.x,u=a.y,d=e.xy,p=Pd(d.mul(o).add(.5));return d.subAssign(p.mul(a)),Wa(s(d,e.z),s(d.add(Bn(c,0)),e.z),s(d.add(Bn(0,u)),e.z),s(d.add(a),e.z),Hs(s(d.add(Bn(c.negate(),0)),e.z),s(d.add(Bn(c.mul(2),0)),e.z),p.x),Hs(s(d.add(Bn(c.negate(),u)),e.z),s(d.add(Bn(c.mul(2),u)),e.z),p.x),Hs(s(d.add(Bn(0,u.negate())),e.z),s(d.add(Bn(0,u.mul(2))),e.z),p.y),Hs(s(d.add(Bn(c,u.negate())),e.z),s(d.add(Bn(c,u.mul(2))),e.z),p.y),Hs(Hs(s(d.add(Bn(c.negate(),u.negate())),e.z),s(d.add(Bn(c.mul(2),u.negate())),e.z),p.x),Hs(s(d.add(Bn(c.negate(),u.mul(2))),e.z),s(d.add(Bn(c.mul(2),u.mul(2))),e.z),p.x),p.y)).mul(1/9)}),FP=Kt(({depthTexture:r,shadowCoord:e,depthLayer:t})=>{const n=ut(1).toVar();let s=Ps(r).sample(e.xy);r.isArrayTexture&&(s=s.depth(t)),s=s.rg;const o=D_(e.z,s.x);return sr(o.notEqual(ut(1)),()=>{const a=e.z.sub(s.x),c=ga(0,s.y.mul(s.y));let u=c.div(c.add(a.mul(a)));u=Mu(Ds(u,.3).div(.95-.3)),n.assign(Mu(ga(o,u)))}),n}),v8=Kt(([r,e,t])=>{let n=Yc.sub(r).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),x8=r=>{const e=r.shadow.camera,t=No("near","float",e).setGroup(or),n=No("far","float",e).setGroup(or),s=NR(r);return v8(s,t,n)},BP=r=>{let e=IP.get(r);if(e===void 0){const t=r.isPointLight?x8(r):null;e=new ya,e.colorNode=Bi(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,IP.set(r,e)}return e},UP=new nh,r0=[],kP=(r,e,t,n)=>{r0[0]=r,r0[1]=e;let s=UP.get(r0);return(s===void 0||s.shadowType!==t||s.useVelocity!==n)&&(s=(o,a,c,u,d,p,...m)=>{(o.castShadow===!0||o.receiveShadow&&t===P)&&(n&&(Vw(o).useVelocity=!0),o.onBeforeShadow(r,o,c,e.camera,u,a.overrideMaterial,p),r.renderObject(o,a,c,u,d,p,...m),o.onAfterShadow(r,o,c,e.camera,u,a.overrideMaterial,p))},s.shadowType=t,s.useVelocity=n,UP.set(r0,s)),r0[0]=null,r0[1]=null,s},_8=Kt(({samples:r,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=ut(0).toVar("meanVertical"),a=ut(0).toVar("squareMeanVertical"),c=r.lessThanEqual(ut(1)).select(ut(0),ut(2).div(r.sub(1))),u=r.lessThanEqual(ut(1)).select(ut(0),ut(-1));po({start:Dt(0),end:Dt(r),type:"int",condition:"<"},({i:p})=>{const m=u.add(ut(p).mul(c));let y=n.sample(Wa(mv.xy,Bn(0,m).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(s)),y=y.x,o.addAssign(y),a.addAssign(y.mul(y))}),o.divAssign(r),a.divAssign(r);const d=Lh(a.sub(o.mul(o)));return Bn(o,d)}),b8=Kt(({samples:r,radius:e,size:t,shadowPass:n,depthLayer:s})=>{const o=ut(0).toVar("meanHorizontal"),a=ut(0).toVar("squareMeanHorizontal"),c=r.lessThanEqual(ut(1)).select(ut(0),ut(2).div(r.sub(1))),u=r.lessThanEqual(ut(1)).select(ut(0),ut(-1));po({start:Dt(0),end:Dt(r),type:"int",condition:"<"},({i:p})=>{const m=u.add(ut(p).mul(c));let y=n.sample(Wa(mv.xy,Bn(m,0).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(s)),o.addAssign(y.x),a.addAssign(Wa(y.y.mul(y.y),y.x.mul(y.x)))}),o.divAssign(r),a.divAssign(r);const d=Lh(a.sub(o.mul(o)));return Bn(o,d)}),w8=[LP,DP,OP,FP];let qS;const xb=new Cv;class zP extends g8{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:s,shadow:o,depthLayer:a}){const c=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),u=t({depthTexture:n,shadowCoord:s,shadow:o,depthLayer:a});return c.select(u,ut(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:s}=e,o=No("bias","float",n).setGroup(or);let a=t,c;if(n.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),c=a.z,s.coordinateSystem===ja&&(c=c.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const d=No("near","float",n.camera).setGroup(or),p=No("far","float",n.camera).setGroup(or);c=nS(u.negate(),d,p)}return a=qt(a.x,a.y.oneMinus(),c.add(o)),a}getShadowFilterFn(e){return w8[e]}setupRenderTarget(e,t){const n=new gc(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=qd;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=n,{shadowMap:s,depthTexture:n}}setupShadow(e){const{renderer:t}=e,{light:n,shadow:s}=this,o=t.shadowMap.type,{depthTexture:a,shadowMap:c}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),o===P&&s.isPointLightShadow!==!0){a.compareFunction=null,c.depth>1?(c._vsmShadowMapVertical||(c._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:De,type:Vs,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=c._vsmShadowMapVertical,c._vsmShadowMapHorizontal||(c._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:De,type:Vs,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=c._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:De,type:Vs,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:De,type:Vs,depthBuffer:!1}));let I=Ps(a);a.isArrayTexture&&(I=I.depth(this.depthLayer));let ee=Ps(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(ee=ee.depth(this.depthLayer));const Q=No("blurSamples","float",s).setGroup(or),oe=No("radius","float",s).setGroup(or),_e=No("mapSize","vec2",s).setGroup(or);let ve=this.vsmMaterialVertical||(this.vsmMaterialVertical=new ya);ve.fragmentNode=_8({samples:Q,radius:oe,size:_e,shadowPass:I,depthLayer:this.depthLayer}).context(e.getSharedContext()),ve.name="VSMVertical",ve=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new ya),ve.fragmentNode=b8({samples:Q,radius:oe,size:_e,shadowPass:ee,depthLayer:this.depthLayer}).context(e.getSharedContext()),ve.name="VSMHorizontal"}const u=No("intensity","float",s).setGroup(or),d=No("normalBias","float",s).setGroup(or),p=vb(n).mul($S.add(Vf.mul(d))),m=this.setupShadowCoord(e,p),y=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(y===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const M=o===P&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:y,shadowTexture:c.texture,depthTexture:M,shadowCoord:m,shadow:s,depthLayer:this.depthLayer});let G=Ps(c.texture,m);a.isArrayTexture&&(G=G.depth(this.depthLayer));const z=Hs(1,T.rgb.mix(G,1),u.mul(G.a)).toVar();return this.shadowMap=c,this.shadow.map=c,z}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Kt(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:s}=this,{renderer:o,scene:a}=e;t.updateMatrices(s),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),o.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:s}=this,{renderer:o,scene:a,camera:c}=e,u=o.shadowMap.type,d=t.depthTexture.version;this._depthVersionCached=d;const p=s.camera.layers.mask;s.camera.layers.mask&4294967294||(s.camera.layers.mask=c.layers.mask);const m=o.getRenderObjectFunction(),y=o.getMRT(),M=y?y.has("velocity"):!1;qS=NP(o,a,qS),a.overrideMaterial=BP(n),o.setRenderObjectFunction(kP(o,s,u,M)),o.setClearColor(0,0),o.setRenderTarget(t),this.renderShadow(e),o.setRenderObjectFunction(m),u===P&&s.isPointLightShadow!==!0&&this.vsmPass(o),s.camera.layers.mask=p,PP(o,a,qS)}vsmPass(e){const{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),xb.material=this.vsmMaterialVertical,xb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),xb.material=this.vsmMaterialHorizontal,xb.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;let n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const VP=(r,e)=>Cn(new zP(r,e)),M8=new jn,ih=Kt(([r,e])=>{const t=r.toVar(),n=Oo(t),s=jc(1,ga(n.x,ga(n.y,n.z)));n.mulAssign(s),t.mulAssign(s.mul(e.mul(2).oneMinus()));const o=Bn(t.xy).toVar(),c=e.mul(1.5).oneMinus();return sr(n.z.greaterThanEqual(c),()=>{sr(t.z.greaterThan(0),()=>{o.x.assign(Ds(4,t.x))})}).ElseIf(n.x.greaterThanEqual(c),()=>{const u=lv(t.x);o.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(c),()=>{const u=lv(t.y);o.x.assign(t.x.add(u.mul(2)).add(2)),o.y.assign(t.z.mul(u).sub(2))}),Bn(.125,.25).mul(o).add(Bn(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),GP=Kt(({depthTexture:r,bd3D:e,dp:t,texelSize:n})=>Ps(r,ih(e,n.y)).compare(t)),WP=Kt(({depthTexture:r,bd3D:e,dp:t,texelSize:n,shadow:s})=>{const o=No("radius","float",s).setGroup(or),a=Bn(-1,1).mul(o).mul(n.y);return Ps(r,ih(e.add(a.xyy),n.y)).compare(t).add(Ps(r,ih(e.add(a.yyy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.xyx),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yyx),n.y)).compare(t)).add(Ps(r,ih(e,n.y)).compare(t)).add(Ps(r,ih(e.add(a.xxy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yxy),n.y)).compare(t)).add(Ps(r,ih(e.add(a.xxx),n.y)).compare(t)).add(Ps(r,ih(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),S8=Kt(({filterFn:r,depthTexture:e,shadowCoord:t,shadow:n})=>{const s=t.xyz.toVar(),o=s.length(),a=cr("float").setGroup(or).onRenderUpdate(()=>n.camera.near),c=cr("float").setGroup(or).onRenderUpdate(()=>n.camera.far),u=No("bias","float",n).setGroup(or),d=cr(n.mapSize).setGroup(or),p=ut(1).toVar();return sr(o.sub(c).lessThanEqual(0).and(o.sub(a).greaterThanEqual(0)),()=>{const m=o.sub(a).div(c.sub(a)).toVar();m.addAssign(u);const y=s.normalize(),M=Bn(1).div(d.mul(Bn(4,2)));p.assign(r({depthTexture:e,bd3D:y,dp:m,texelSize:M,shadow:n}))}),p}),HP=new mr,s0=new yn,Lv=new yn;class T8 extends zP{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===E?GP:WP}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:s,shadowCoord:o,shadow:a}){return S8({filterFn:t,shadowTexture:n,depthTexture:s,shadowCoord:o,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:s}=this,{renderer:o,scene:a}=e,c=t.getFrameExtents();Lv.copy(t.mapSize),Lv.multiply(c),n.setSize(Lv.width,Lv.height),s0.copy(t.mapSize);const u=o.autoClear,d=o.getClearColor(M8),p=o.getClearAlpha();o.autoClear=!1,o.setClearColor(t.clearColor,t.clearAlpha),o.clear();const m=t.getViewportCount();for(let y=0;yCn(new T8(r,e));class xm extends Xg{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new jn,this.colorNode=e&&e.colorNode||cr(this.color).setGroup(or),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=rs.FRAME}getHash(){return this.light.uuid}getLightVector(e){return VS(this.light).sub(e.context.positionView||Ia)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return VP(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const s=this.light.shadow.shadowNode;let o;s!==void 0?o=Cn(s):o=this.setupShadowNode(),this.shadowNode=o,this.shadowColorNode=n=this.colorNode.mul(o),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const YS=Kt(({lightDistance:r,cutoffDistance:e,decayExponent:t})=>{const n=r.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(r.div(e).pow4().oneMinus().clamp().pow2()),n)}),jP=({color:r,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const s=e.normalize(),o=e.length(),a=YS({lightDistance:o,cutoffDistance:t,decayExponent:n}),c=r.mul(a);return{lightDirection:s,lightColor:c}};class E8 extends xm{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=cr(0).setGroup(or),this.decayExponentNode=cr(2).setGroup(or)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return $P(this.light)}setupDirect(e){return jP({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const A8=Kt(([r=vo()])=>{const e=r.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),C8=Kt(([r=vo()],{renderer:e,material:t})=>{const n=gM(r.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.samples>1){const o=ut(n.fwidth()).toVar();s=Su(o.oneMinus(),o.add(1),n).oneMinus()}else s=wl(n.greaterThan(1),0,1);return s}),Dv=Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=bu(r).toVar();return wl(o,s,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),_b=Kt(([r,e])=>{const t=bu(e).toVar(),n=ut(r).toVar();return wl(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ha=Kt(([r])=>{const e=ut(r).toVar();return Dt(Dh(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Ko=Kt(([r,e])=>{const t=ut(r).toVar();return e.assign(Ha(t)),t.sub(ut(e))}),XP=Il([Kt(([r,e,t,n,s,o])=>{const a=ut(o).toVar(),c=ut(s).toVar(),u=ut(n).toVar(),d=ut(t).toVar(),p=ut(e).toVar(),m=ut(r).toVar(),y=ut(Ds(1,c)).toVar();return Ds(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Kt(([r,e,t,n,s,o])=>{const a=ut(o).toVar(),c=ut(s).toVar(),u=qt(n).toVar(),d=qt(t).toVar(),p=qt(e).toVar(),m=qt(r).toVar(),y=ut(Ds(1,c)).toVar();return Ds(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),qP=Il([Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=ut(p).toVar(),y=ut(d).toVar(),M=ut(u).toVar(),T=ut(c).toVar(),G=ut(a).toVar(),z=ut(o).toVar(),I=ut(s).toVar(),ee=ut(n).toVar(),Q=ut(t).toVar(),oe=ut(e).toVar(),_e=ut(r).toVar(),ve=ut(Ds(1,M)).toVar(),Oe=ut(Ds(1,y)).toVar();return ut(Ds(1,m)).toVar().mul(Oe.mul(_e.mul(ve).add(oe.mul(M))).add(y.mul(Q.mul(ve).add(ee.mul(M))))).add(m.mul(Oe.mul(I.mul(ve).add(z.mul(M))).add(y.mul(G.mul(ve).add(T.mul(M))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=ut(p).toVar(),y=ut(d).toVar(),M=ut(u).toVar(),T=qt(c).toVar(),G=qt(a).toVar(),z=qt(o).toVar(),I=qt(s).toVar(),ee=qt(n).toVar(),Q=qt(t).toVar(),oe=qt(e).toVar(),_e=qt(r).toVar(),ve=ut(Ds(1,M)).toVar(),Oe=ut(Ds(1,y)).toVar();return ut(Ds(1,m)).toVar().mul(Oe.mul(_e.mul(ve).add(oe.mul(M))).add(y.mul(Q.mul(ve).add(ee.mul(M))))).add(m.mul(Oe.mul(I.mul(ve).add(z.mul(M))).add(y.mul(G.mul(ve).add(T.mul(M))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Ml=Il([Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=Li(r).toVar(),a=Li(o.bitAnd(Li(7))).toVar(),c=ut(Dv(a.lessThan(Li(4)),s,n)).toVar(),u=ut(Kr(2,Dv(a.lessThan(Li(4)),n,s))).toVar();return _b(c,bu(a.bitAnd(Li(1)))).add(_b(u,bu(a.bitAnd(Li(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=ut(e).toVar(),c=Li(r).toVar(),u=Li(c.bitAnd(Li(15))).toVar(),d=ut(Dv(u.lessThan(Li(8)),a,o)).toVar(),p=ut(Dv(u.lessThan(Li(4)),o,Dv(u.equal(Li(12)).or(u.equal(Li(14))),a,s))).toVar();return _b(d,bu(u.bitAnd(Li(1)))).add(_b(p,bu(u.bitAnd(Li(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),Nu=Il([Kt(([r,e,t])=>{const n=ut(t).toVar(),s=ut(e).toVar(),o=Ug(r).toVar();return qt(Ml(o.x,s,n),Ml(o.y,s,n),Ml(o.z,s,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=ut(e).toVar(),c=Ug(r).toVar();return qt(Ml(c.x,a,o,s),Ml(c.y,a,o,s),Ml(c.z,a,o,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),R8=Kt(([r])=>{const e=ut(r).toVar();return Kr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),N8=Kt(([r])=>{const e=ut(r).toVar();return Kr(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),YP=Il([R8,Kt(([r])=>{const e=qt(r).toVar();return Kr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),ZP=Il([N8,Kt(([r])=>{const e=qt(r).toVar();return Kr(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Kc=Kt(([r,e])=>{const t=Dt(e).toVar(),n=Li(r).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Dt(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),KP=Kt(([r,e,t])=>{r.subAssign(t),r.bitXorAssign(Kc(t,Dt(4))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(Kc(r,Dt(6))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(Kc(e,Dt(8))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(Kc(t,Dt(16))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(Kc(r,Dt(19))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(Kc(e,Dt(4))),e.addAssign(r)}),Ov=Kt(([r,e,t])=>{const n=Li(t).toVar(),s=Li(e).toVar(),o=Li(r).toVar();return n.bitXorAssign(s),n.subAssign(Kc(s,Dt(14))),o.bitXorAssign(n),o.subAssign(Kc(n,Dt(11))),s.bitXorAssign(o),s.subAssign(Kc(o,Dt(25))),n.bitXorAssign(s),n.subAssign(Kc(s,Dt(16))),o.bitXorAssign(n),o.subAssign(Kc(n,Dt(4))),s.bitXorAssign(o),s.subAssign(Kc(o,Dt(14))),n.bitXorAssign(s),n.subAssign(Kc(s,Dt(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),jl=Kt(([r])=>{const e=Li(r).toVar();return ut(e).div(ut(Li(Dt(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Vh=Kt(([r])=>{const e=ut(r).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),xo=Il([Kt(([r])=>{const e=Dt(r).toVar(),t=Li(Li(1)).toVar(),n=Li(Li(Dt(3735928559)).add(t.shiftLeft(Li(2))).add(Li(13))).toVar();return Ov(n.add(Li(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Kt(([r,e])=>{const t=Dt(e).toVar(),n=Dt(r).toVar(),s=Li(Li(2)).toVar(),o=Li().toVar(),a=Li().toVar(),c=Li().toVar();return o.assign(a.assign(c.assign(Li(Dt(3735928559)).add(s.shiftLeft(Li(2))).add(Li(13))))),o.addAssign(Li(n)),a.addAssign(Li(t)),Ov(o,a,c)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(r).toVar(),a=Li(Li(3)).toVar(),c=Li().toVar(),u=Li().toVar(),d=Li().toVar();return c.assign(u.assign(d.assign(Li(Dt(3735928559)).add(a.shiftLeft(Li(2))).add(Li(13))))),c.addAssign(Li(o)),u.addAssign(Li(s)),d.addAssign(Li(n)),Ov(c,u,d)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Kt(([r,e,t,n])=>{const s=Dt(n).toVar(),o=Dt(t).toVar(),a=Dt(e).toVar(),c=Dt(r).toVar(),u=Li(Li(4)).toVar(),d=Li().toVar(),p=Li().toVar(),m=Li().toVar();return d.assign(p.assign(m.assign(Li(Dt(3735928559)).add(u.shiftLeft(Li(2))).add(Li(13))))),d.addAssign(Li(c)),p.addAssign(Li(a)),m.addAssign(Li(o)),KP(d,p,m),d.addAssign(Li(s)),Ov(d,p,m)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Kt(([r,e,t,n,s])=>{const o=Dt(s).toVar(),a=Dt(n).toVar(),c=Dt(t).toVar(),u=Dt(e).toVar(),d=Dt(r).toVar(),p=Li(Li(5)).toVar(),m=Li().toVar(),y=Li().toVar(),M=Li().toVar();return m.assign(y.assign(M.assign(Li(Dt(3735928559)).add(p.shiftLeft(Li(2))).add(Li(13))))),m.addAssign(Li(d)),y.addAssign(Li(u)),M.addAssign(Li(c)),KP(m,y,M),m.addAssign(Li(a)),y.addAssign(Li(o)),Ov(m,y,M)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),Pu=Il([Kt(([r,e])=>{const t=Dt(e).toVar(),n=Dt(r).toVar(),s=Li(xo(n,t)).toVar(),o=Ug().toVar();return o.x.assign(s.bitAnd(Dt(255))),o.y.assign(s.shiftRight(Dt(8)).bitAnd(Dt(255))),o.z.assign(s.shiftRight(Dt(16)).bitAnd(Dt(255))),o}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=Dt(e).toVar(),o=Dt(r).toVar(),a=Li(xo(o,s,n)).toVar(),c=Ug().toVar();return c.x.assign(a.bitAnd(Dt(255))),c.y.assign(a.shiftRight(Dt(8)).bitAnd(Dt(255))),c.z.assign(a.shiftRight(Dt(16)).bitAnd(Dt(255))),c}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),ZS=Il([Kt(([r])=>{const e=Bn(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=ut(Ko(e.x,t)).toVar(),o=ut(Ko(e.y,n)).toVar(),a=ut(Vh(s)).toVar(),c=ut(Vh(o)).toVar(),u=ut(XP(Ml(xo(t,n),s,o),Ml(xo(t.add(Dt(1)),n),s.sub(1),o),Ml(xo(t,n.add(Dt(1))),s,o.sub(1)),Ml(xo(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return YP(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=ut(Ko(e.x,t)).toVar(),a=ut(Ko(e.y,n)).toVar(),c=ut(Ko(e.z,s)).toVar(),u=ut(Vh(o)).toVar(),d=ut(Vh(a)).toVar(),p=ut(Vh(c)).toVar(),m=ut(qP(Ml(xo(t,n,s),o,a,c),Ml(xo(t.add(Dt(1)),n,s),o.sub(1),a,c),Ml(xo(t,n.add(Dt(1)),s),o,a.sub(1),c),Ml(xo(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Ml(xo(t,n,s.add(Dt(1))),o,a,c.sub(1)),Ml(xo(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Ml(xo(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Ml(xo(t.add(Dt(1)),n.add(Dt(1)),s.add(Dt(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return ZP(m)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Fv=Il([Kt(([r])=>{const e=Bn(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=ut(Ko(e.x,t)).toVar(),o=ut(Ko(e.y,n)).toVar(),a=ut(Vh(s)).toVar(),c=ut(Vh(o)).toVar(),u=qt(XP(Nu(Pu(t,n),s,o),Nu(Pu(t.add(Dt(1)),n),s.sub(1),o),Nu(Pu(t,n.add(Dt(1))),s,o.sub(1)),Nu(Pu(t.add(Dt(1)),n.add(Dt(1))),s.sub(1),o.sub(1)),a,c)).toVar();return YP(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt().toVar(),n=Dt().toVar(),s=Dt().toVar(),o=ut(Ko(e.x,t)).toVar(),a=ut(Ko(e.y,n)).toVar(),c=ut(Ko(e.z,s)).toVar(),u=ut(Vh(o)).toVar(),d=ut(Vh(a)).toVar(),p=ut(Vh(c)).toVar(),m=qt(qP(Nu(Pu(t,n,s),o,a,c),Nu(Pu(t.add(Dt(1)),n,s),o.sub(1),a,c),Nu(Pu(t,n.add(Dt(1)),s),o,a.sub(1),c),Nu(Pu(t.add(Dt(1)),n.add(Dt(1)),s),o.sub(1),a.sub(1),c),Nu(Pu(t,n,s.add(Dt(1))),o,a,c.sub(1)),Nu(Pu(t.add(Dt(1)),n,s.add(Dt(1))),o.sub(1),a,c.sub(1)),Nu(Pu(t,n.add(Dt(1)),s.add(Dt(1))),o,a.sub(1),c.sub(1)),Nu(Pu(t.add(Dt(1)),n.add(Dt(1)),s.add(Dt(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return ZP(m)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),P8=Il([Kt(([r])=>{const e=ut(r).toVar(),t=Dt(Ha(e)).toVar();return jl(xo(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Kt(([r])=>{const e=Bn(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar();return jl(xo(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar();return jl(xo(t,n,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Kt(([r])=>{const e=Bi(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar(),o=Dt(Ha(e.w)).toVar();return jl(xo(t,n,s,o))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),bb=Il([Kt(([r])=>{const e=ut(r).toVar(),t=Dt(Ha(e)).toVar();return qt(jl(xo(t,Dt(0))),jl(xo(t,Dt(1))),jl(xo(t,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Kt(([r])=>{const e=Bn(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar();return qt(jl(xo(t,n,Dt(0))),jl(xo(t,n,Dt(1))),jl(xo(t,n,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Kt(([r])=>{const e=qt(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar();return qt(jl(xo(t,n,s,Dt(0))),jl(xo(t,n,s,Dt(1))),jl(xo(t,n,s,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Kt(([r])=>{const e=Bi(r).toVar(),t=Dt(Ha(e.x)).toVar(),n=Dt(Ha(e.y)).toVar(),s=Dt(Ha(e.z)).toVar(),o=Dt(Ha(e.w)).toVar();return qt(jl(xo(t,n,s,o,Dt(0))),jl(xo(t,n,s,o,Dt(1))),jl(xo(t,n,s,o,Dt(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),wb=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=ut(0).toVar(),d=ut(1).toVar();return po(a,()=>{u.addAssign(d.mul(ZS(c))),d.mulAssign(s),c.mulAssign(o)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Mb=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=qt(0).toVar(),d=ut(1).toVar();return po(a,()=>{u.addAssign(d.mul(Fv(c))),d.mulAssign(s),c.mulAssign(o)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),I8=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar();return Bn(wb(c,a,o,s),wb(c.add(qt(Dt(19),Dt(193),Dt(17))),a,o,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),L8=Kt(([r,e,t,n])=>{const s=ut(n).toVar(),o=ut(t).toVar(),a=Dt(e).toVar(),c=qt(r).toVar(),u=qt(Mb(c,a,o,s)).toVar(),d=ut(wb(c.add(qt(Dt(19),Dt(193),Dt(17))),a,o,s)).toVar();return Bi(u,d)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),o0=Il([Kt(([r,e,t,n,s,o,a])=>{const c=Dt(a).toVar(),u=ut(o).toVar(),d=Dt(s).toVar(),p=Dt(n).toVar(),m=Dt(t).toVar(),y=Dt(e).toVar(),M=Bn(r).toVar(),T=qt(bb(Bn(y.add(p),m.add(d)))).toVar(),G=Bn(T.x,T.y).toVar();G.subAssign(.5),G.mulAssign(u),G.addAssign(.5);const z=Bn(Bn(ut(y),ut(m)).add(G)).toVar(),I=Bn(z.sub(M)).toVar();return sr(c.equal(Dt(2)),()=>Oo(I.x).add(Oo(I.y))),sr(c.equal(Dt(3)),()=>ga(Oo(I.x),Oo(I.y))),Uf(I,I)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kt(([r,e,t,n,s,o,a,c,u])=>{const d=Dt(u).toVar(),p=ut(c).toVar(),m=Dt(a).toVar(),y=Dt(o).toVar(),M=Dt(s).toVar(),T=Dt(n).toVar(),G=Dt(t).toVar(),z=Dt(e).toVar(),I=qt(r).toVar(),ee=qt(bb(qt(z.add(M),G.add(y),T.add(m)))).toVar();ee.subAssign(.5),ee.mulAssign(p),ee.addAssign(.5);const Q=qt(qt(ut(z),ut(G),ut(T)).add(ee)).toVar(),oe=qt(Q.sub(I)).toVar();return sr(d.equal(Dt(2)),()=>Oo(oe.x).add(Oo(oe.y)).add(Oo(oe.z))),sr(d.equal(Dt(3)),()=>ga(Oo(oe.x),Oo(oe.y),Oo(oe.z))),Uf(oe,oe)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),D8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=ut(1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(u,p,m,a,c,s,n)).toVar();d.assign(Sc(d,y))})}),sr(n.equal(Dt(0)),()=>{d.assign(Lh(d))}),d}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),O8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=Bn(1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(u,p,m,a,c,s,n)).toVar();sr(y.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.y.assign(y)})})}),sr(n.equal(Dt(0)),()=>{d.assign(Lh(d))}),d}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),F8=Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=Bn(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Bn(Ko(o.x,a),Ko(o.y,c)).toVar(),d=qt(1e6,1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:p})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y:m})=>{const y=ut(o0(u,p,m,a,c,s,n)).toVar();sr(y.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(y)}).ElseIf(y.lessThan(d.z),()=>{d.z.assign(y)})})}),sr(n.equal(Dt(0)),()=>{d.assign(Lh(d))}),d}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),B8=Il([D8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=ut(1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(d,m,y,M,a,c,u,s,n)).toVar();p.assign(Sc(p,T))})})}),sr(n.equal(Dt(0)),()=>{p.assign(Lh(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),U8=Il([O8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=Bn(1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(d,m,y,M,a,c,u,s,n)).toVar();sr(T.lessThan(p.x),()=>{p.y.assign(p.x),p.x.assign(T)}).ElseIf(T.lessThan(p.y),()=>{p.y.assign(T)})})})}),sr(n.equal(Dt(0)),()=>{p.assign(Lh(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),KS=Il([F8,Kt(([r,e,t])=>{const n=Dt(t).toVar(),s=ut(e).toVar(),o=qt(r).toVar(),a=Dt().toVar(),c=Dt().toVar(),u=Dt().toVar(),d=qt(Ko(o.x,a),Ko(o.y,c),Ko(o.z,u)).toVar(),p=qt(1e6,1e6,1e6).toVar();return po({start:-1,end:Dt(1),name:"x",condition:"<="},({x:m})=>{po({start:-1,end:Dt(1),name:"y",condition:"<="},({y})=>{po({start:-1,end:Dt(1),name:"z",condition:"<="},({z:M})=>{const T=ut(o0(d,m,y,M,a,c,u,s,n)).toVar();sr(T.lessThan(p.x),()=>{p.z.assign(p.y),p.y.assign(p.x),p.x.assign(T)}).ElseIf(T.lessThan(p.y),()=>{p.z.assign(p.y),p.y.assign(T)}).ElseIf(T.lessThan(p.z),()=>{p.z.assign(T)})})})}),sr(n.equal(Dt(0)),()=>{p.assign(Lh(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),k8=Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(r).toVar(),y=Bn(e).toVar(),M=Bn(t).toVar(),T=Bn(n).toVar(),G=ut(s).toVar(),z=ut(o).toVar(),I=ut(a).toVar(),ee=bu(c).toVar(),Q=Dt(u).toVar(),oe=ut(d).toVar(),_e=ut(p).toVar(),ve=y.mul(M).add(T),Oe=ut(0).toVar();return sr(m.equal(Dt(0)),()=>{Oe.assign(Fv(ve))}),sr(m.equal(Dt(1)),()=>{Oe.assign(bb(ve))}),sr(m.equal(Dt(2)),()=>{Oe.assign(KS(ve,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Oe.assign(Mb(qt(ve,0),Q,oe,_e))}),Oe.assign(Oe.mul(I.sub(z)).add(z)),sr(ee,()=>{Oe.assign(Mu(Oe,z,I))}),Oe}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),z8=Kt(([r,e,t,n,s,o,a,c,u,d,p])=>{const m=Dt(r).toVar(),y=qt(e).toVar(),M=qt(t).toVar(),T=qt(n).toVar(),G=ut(s).toVar(),z=ut(o).toVar(),I=ut(a).toVar(),ee=bu(c).toVar(),Q=Dt(u).toVar(),oe=ut(d).toVar(),_e=ut(p).toVar(),ve=y.mul(M).add(T),Oe=ut(0).toVar();return sr(m.equal(Dt(0)),()=>{Oe.assign(Fv(ve))}),sr(m.equal(Dt(1)),()=>{Oe.assign(bb(ve))}),sr(m.equal(Dt(2)),()=>{Oe.assign(KS(ve,G,Dt(0)))}),sr(m.equal(Dt(3)),()=>{Oe.assign(Mb(ve,Q,oe,_e))}),Oe.assign(Oe.mul(I.sub(z)).add(z)),sr(ee,()=>{Oe.assign(Mu(Oe,z,I))}),Oe}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),V8=Kt(([r])=>{const e=r.y,t=r.z,n=qt().toVar();return sr(e.lessThan(1e-4),()=>{n.assign(qt(t,t,t))}).Else(()=>{let s=r.x;s=s.sub(Dh(s)).mul(6).toVar();const o=Dt(pM(s)),a=s.sub(ut(o)),c=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),d=t.mul(e.mul(a.oneMinus()).oneMinus());sr(o.equal(Dt(0)),()=>{n.assign(qt(t,d,c))}).ElseIf(o.equal(Dt(1)),()=>{n.assign(qt(u,t,c))}).ElseIf(o.equal(Dt(2)),()=>{n.assign(qt(c,t,d))}).ElseIf(o.equal(Dt(3)),()=>{n.assign(qt(c,u,t))}).ElseIf(o.equal(Dt(4)),()=>{n.assign(qt(d,c,t))}).Else(()=>{n.assign(qt(t,c,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),G8=Kt(([r])=>{const e=qt(r).toVar(),t=ut(e.x).toVar(),n=ut(e.y).toVar(),s=ut(e.z).toVar(),o=ut(Sc(t,Sc(n,s))).toVar(),a=ut(ga(t,ga(n,s))).toVar(),c=ut(a.sub(o)).toVar(),u=ut().toVar(),d=ut().toVar(),p=ut().toVar();return p.assign(a),sr(a.greaterThan(0),()=>{d.assign(c.div(a))}).Else(()=>{d.assign(0)}),sr(d.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{sr(t.greaterThanEqual(a),()=>{u.assign(n.sub(s).div(c))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Wa(2,s.sub(t).div(c)))}).Else(()=>{u.assign(Wa(4,t.sub(n).div(c)))}),u.mulAssign(1/6),sr(u.lessThan(0),()=>{u.addAssign(1)})}),qt(u,d,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),W8=Kt(([r])=>{const e=qt(r).toVar(),t=Jw(lM(e,qt(.04045))).toVar(),n=qt(e.div(12.92)).toVar(),s=qt(wu(ga(e.add(qt(.055)),qt(0)).div(1.055),qt(2.4))).toVar();return Hs(n,s,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),JP=(r,e)=>{r=ut(r),e=ut(e);const t=Bn(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Su(r.sub(t),r.add(t),e)},QP=(r,e,t,n)=>Hs(r,e,t[n].clamp()),H8=(r,e,t=vo())=>QP(r,e,t,"x"),$8=(r,e,t=vo())=>QP(r,e,t,"y"),j8=(r,e,t,n,s=vo())=>{const o=s.x.clamp(),a=s.y.clamp(),c=Hs(r,e,o),u=Hs(t,n,o);return Hs(c,u,a)},eI=(r,e,t,n,s)=>Hs(r,e,JP(t,n[s])),X8=(r,e,t,n=vo())=>eI(r,e,t,n,"x"),q8=(r,e,t,n=vo())=>eI(r,e,t,n,"y"),Y8=(r=1,e=0,t=vo())=>t.mul(r).add(e),Z8=(r,e=1)=>(r=ut(r),r.abs().pow(e).mul(r.sign())),K8=(r,e=1,t=.5)=>ut(r).sub(t).mul(e).add(t),J8=(r=vo(),e=1,t=0)=>ZS(r.convert("vec2|vec3")).mul(e).add(t),Q8=(r=vo(),e=1,t=0)=>Fv(r.convert("vec2|vec3")).mul(e).add(t),eW=(r=vo(),e=1,t=0)=>(r=r.convert("vec2|vec3"),Bi(Fv(r),ZS(r.add(Bn(19,73)))).mul(e).add(t)),tW=(r,e=vo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>k8(r,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),nW=(r,e=vo(),t=Bn(1,1),n=Bn(0,0),s=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>z8(r,e.convert("vec2|vec3"),t,n,s,o,a,c,u,d,p),iW=(r=vo(),e=1)=>B8(r.convert("vec2|vec3"),e,Dt(1)),rW=(r=vo(),e=1)=>U8(r.convert("vec2|vec3"),e,Dt(1)),sW=(r=vo(),e=1)=>KS(r.convert("vec2|vec3"),e,Dt(1)),oW=(r=vo())=>P8(r.convert("vec2|vec3")),aW=(r=vo(),e=3,t=2,n=.5,s=1)=>wb(r,Dt(e),t,n).mul(s),lW=(r=vo(),e=3,t=2,n=.5,s=1)=>I8(r,Dt(e),t,n).mul(s),cW=(r=vo(),e=3,t=2,n=.5,s=1)=>Mb(r,Dt(e),t,n).mul(s),uW=(r=vo(),e=3,t=2,n=.5,s=1)=>L8(r,Dt(e),t,n).mul(s),hW=(r,e=ut(0))=>Wa(r,e),dW=(r,e=ut(0))=>Ds(r,e),fW=(r,e=ut(1))=>Kr(r,e),pW=(r,e=ut(1))=>jc(r,e),mW=(r,e=ut(1))=>av(r,e),gW=(r,e=ut(1))=>wu(r,e),yW=(r=ut(0),e=ut(1))=>L_(r,e),vW=()=>e0,xW=()=>tP,_W=(r,e=ut(1))=>Ds(e,r),bW=(r,e,t,n)=>r.greaterThan(e).mix(t,n),wW=(r,e,t,n)=>r.greaterThanEqual(e).mix(t,n),MW=(r,e,t,n)=>r.equal(e).mix(t,n),SW=(r,e=null)=>{if(typeof e=="string"){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},n=e.replace(/^out/,"").toLowerCase();if(t[n]!==void 0)return r.element(t[n])}if(typeof e=="number")return r.element(e);if(typeof e=="string"&&e.length===1){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return r.element(t[e])}return r},TW=(r,e=Bn(.5,.5),t=Bn(1,1),n=ut(0),s=Bn(0,0))=>{let o=r;if(e&&(o=o.sub(e)),t&&(o=o.mul(t)),n){const a=n.mul(Math.PI/180),c=a.cos(),u=a.sin();o=Bn(o.x.mul(c).sub(o.y.mul(u)),o.x.mul(u).add(o.y.mul(c)))}return e&&(o=o.add(e)),s&&(o=o.add(s)),o},EW=(r,e)=>{r=Bn(r),e=ut(e);const t=e.mul(Math.PI/180);return _v(r,t)},AW=(r,e,t)=>{r=qt(r),e=ut(e),t=qt(t);const n=e.mul(Math.PI/180),s=t.normalize(),o=n.cos(),a=n.sin(),c=ut(1).sub(o);return r.mul(o).add(s.cross(r).mul(a)).add(s.mul(s.dot(r)).mul(c))},CW=(r,e)=>(r=qt(r),e=ut(e),WM(r,e)),RW=Kt(([r,e,t])=>{const n=Nd(r).toVar(),s=Ds(ut(.5).mul(e.sub(t)),Yc).div(n).toVar(),o=Ds(ut(-.5).mul(e.sub(t)),Yc).div(n).toVar(),a=qt().toVar();a.x=n.x.greaterThan(ut(0)).select(s.x,o.x),a.y=n.y.greaterThan(ut(0)).select(s.y,o.y),a.z=n.z.greaterThan(ut(0)).select(s.z,o.z);const c=Sc(a.x,a.y,a.z).toVar();return Yc.add(n.mul(c)).toVar().sub(t)}),tI=Kt(([r,e])=>{const t=r.x,n=r.y,s=r.z;let o=e.element(0).mul(.886227);return o=o.add(e.element(1).mul(2*.511664).mul(n)),o=o.add(e.element(2).mul(2*.511664).mul(s)),o=o.add(e.element(3).mul(2*.511664).mul(t)),o=o.add(e.element(4).mul(2*.429043).mul(t).mul(n)),o=o.add(e.element(5).mul(2*.429043).mul(n).mul(s)),o=o.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),o=o.add(e.element(7).mul(2*.429043).mul(t).mul(s)),o=o.add(e.element(8).mul(.429043).mul(Kr(t,t).sub(Kr(n,n)))),o});var uZ=Object.freeze({__proto__:null,BRDF_GGX:aS,BRDF_Lambert:dm,BasicPointShadowFilter:GP,BasicShadowFilter:LP,Break:U2,Const:lR,Continue:x4,DFGApprox:lS,D_GGX:aN,Discard:SR,EPSILON:NC,F_Schlick:Kg,Fn:Kt,INFINITY:Yk,If:sr,Loop:po,NodeAccess:Nl,NodeShaderStage:Yy,NodeType:vk,NodeUpdateType:rs,OnMaterialUpdate:RG,OnObjectUpdate:CG,PCFShadowFilter:DP,PCFSoftShadowFilter:OP,PI:N_,PI2:Zk,PointShadowFilter:WP,Return:dz,Schlick_to_F0:cN,ScriptableNodeResources:mb,ShaderNode:Bg,Stack:b_,Switch:zk,TBNViewMatrix:um,VSMShadowFilter:FP,V_GGX_SmithCorrelated:oN,Var:aR,VarIntent:cR,abs:Oo,acesFilmicToneMapping:yP,acos:hM,add:Wa,addMethodChaining:An,addNodeElement:mz,agxToneMapping:vP,all:PC,alphaT:E_,and:mC,anisotropy:Bf,anisotropyB:om,anisotropyT:nv,any:IC,append:Hk,array:lC,arrayBuffer:Gk,asin:FC,assign:cC,atan:L_,atan2:iR,atomicAdd:O6,atomicAnd:k6,atomicFunc:zh,atomicLoad:L6,atomicMax:B6,atomicMin:U6,atomicOr:z6,atomicStore:D6,atomicSub:F6,atomicXor:V6,attenuationColor:rM,attenuationDistance:iM,attribute:rc,attributeArray:IG,backgroundBlurriness:sP,backgroundIntensity:OS,backgroundRotation:oP,batch:D2,bentNormalView:n2,billboarding:hG,bitAnd:xC,bitNot:_C,bitOr:bC,bitXor:wC,bitangentGeometry:Qz,bitangentLocal:e4,bitangentView:e2,bitangentWorld:t4,bitcast:$5,blendBurn:j2,blendColor:F4,blendDodge:X2,blendOverlay:Y2,blendScreen:q2,blur:RN,bool:bu,buffer:dv,bufferAttribute:uv,builtin:Dd,bumpMap:WM,burn:U4,bvec2:KA,bvec3:Jw,bvec4:tC,bypass:_R,cache:hv,call:uC,cameraFar:Bd,cameraIndex:zf,cameraNear:Fd,cameraNormalMatrix:Rz,cameraPosition:gv,cameraProjectionMatrix:Tu,cameraProjectionMatrixInverse:Az,cameraViewMatrix:qc,cameraViewport:Nz,cameraWorldMatrix:Cz,cbrt:JC,cdl:qG,ceil:I_,checker:A8,cineonToneMapping:gP,clamp:Mu,clearcoat:M_,clearcoatNormalView:cm,clearcoatRoughness:tv,code:fb,color:YA,colorSpaceToWorking:B_,colorToDirection:q4,compute:xR,computeKernel:TM,computeSkinning:y4,context:cv,convert:iC,convertColorSpace:iz,convertToTexture:MG,cos:Id,cross:O_,cubeTexture:$g,cubeTextureBase:UM,cubeToUV:ih,dFdx:dM,dFdy:fM,dashSize:am,debug:TR,decrement:CC,decrementBefore:EC,defaultBuildStages:Hw,defaultShaderStages:kA,defined:Ky,degrees:DC,deltaTime:rG,densityFog:g6,densityFogFactor:US,depth:iS,depthPass:QG,determinant:WC,difference:qC,diffuseColor:to,directPointLight:jP,directionToColor:J2,directionToFaceDirection:Wg,dispersion:sM,distance:XC,div:jc,dodge:k4,dot:Uf,drawIndex:P2,dynamicBufferAttribute:vR,element:nC,emissive:Qw,equal:aM,equals:$C,equirectUV:rS,exp:cM,exp2:zg,expression:Ld,faceDirection:DM,faceForward:xM,faceforward:Kk,float:ut,floatBitsToInt:j5,floatBitsToUint:X5,floor:Dh,fog:Nv,fract:Pd,frameGroup:oC,frameId:tP,frontFacing:DR,fwidth:VC,gain:K5,gapSize:rv,getConstNodeType:qA,getCurrentStack:__,getDirection:AN,getDistanceAttenuation:YS,getGeometryRoughness:sN,getNormalFromDepth:TG,getParallaxCorrectNormal:RW,getRoughness:oS,getScreenPosition:SG,getShIrradianceAt:tI,getShadowMaterial:BP,getShadowRenderObjectFunction:kP,getTextureIndex:QN,getViewPosition:i0,globalId:w6,glsl:l6,glslFn:c6,grayscale:HG,greaterThan:lM,greaterThanEqual:pC,hash:Z5,highpModelNormalViewMatrix:IM,highpModelViewMatrix:PM,hue:XG,increment:AC,incrementBefore:TC,instance:u4,instanceIndex:Gf,instancedArray:LG,instancedBufferAttribute:U_,instancedDynamicBufferAttribute:SM,instancedMesh:L2,int:Dt,intBitsToFloat:q5,inverse:HC,inverseSqrt:uM,inversesqrt:Jk,invocationLocalIndex:c4,invocationSubgroupIndex:l4,ior:sv,iridescence:T_,iridescenceIOR:eM,iridescenceThickness:tM,ivec2:pl,ivec3:JA,ivec4:QA,js:o6,label:oR,length:Oh,lengthSq:gM,lessThan:dC,lessThanEqual:fC,lightPosition:zS,lightProjectionUV:SP,lightShadowMatrix:vb,lightTargetDirection:GS,lightTargetPosition:TP,lightViewPosition:VS,lightingContext:V2,lights:m8,linearDepth:Zg,linearToneMapping:pP,localId:M6,log:P_,log2:Ih,logarithmicDepthToViewZ:C4,luminance:FS,mat2:w_,mat3:Wl,mat4:rm,matcapUV:VN,materialAO:R2,materialAlphaTest:r2,materialAnisotropy:v2,materialAnisotropyVector:jg,materialAttenuationColor:E2,materialAttenuationDistance:T2,materialClearcoat:d2,materialClearcoatNormal:p2,materialClearcoatRoughness:f2,materialColor:X_,materialDispersion:C2,materialEmissive:o2,materialEnvIntensity:G_,materialEnvRotation:BM,materialIOR:S2,materialIridescence:x2,materialIridescenceIOR:_2,materialIridescenceThickness:b2,materialLightMap:YM,materialLineDashOffset:qM,materialLineDashSize:jM,materialLineGapSize:XM,materialLineScale:$M,materialLineWidth:Z_,materialMetalness:u2,materialNormal:h2,materialOpacity:q_,materialPointSize:A2,materialReference:kd,materialReflectivity:Y_,materialRefractionRatio:kR,materialRotation:m2,materialRoughness:c2,materialSheen:g2,materialSheenRoughness:y2,materialShininess:s2,materialSpecular:a2,materialSpecularColor:l2,materialSpecularIntensity:HM,materialSpecularStrength:vv,materialThickness:M2,materialTransmission:w2,max:ga,maxMipLevel:AM,mediumpModelViewMatrix:LR,metalness:ev,min:Sc,mix:Hs,mixElement:eR,mod:av,modInt:RC,modelDirection:Fz,modelNormalMatrix:IR,modelPosition:Bz,modelRadius:PR,modelScale:Uz,modelViewMatrix:Ud,modelViewPosition:kz,modelViewProjection:ZM,modelWorldMatrix:Au,modelWorldMatrixInverse:zz,morphReference:z2,mrt:eP,mul:Kr,mx_aastep:JP,mx_add:hW,mx_atan2:yW,mx_cell_noise_float:oW,mx_contrast:K8,mx_divide:pW,mx_fractal_noise_float:aW,mx_fractal_noise_vec2:lW,mx_fractal_noise_vec3:cW,mx_fractal_noise_vec4:uW,mx_frame:xW,mx_heighttonormal:CW,mx_hsvtorgb:V8,mx_ifequal:MW,mx_ifgreater:bW,mx_ifgreatereq:wW,mx_invert:_W,mx_modulo:mW,mx_multiply:fW,mx_noise_float:J8,mx_noise_vec3:Q8,mx_noise_vec4:eW,mx_place2d:TW,mx_power:gW,mx_ramp4:j8,mx_ramplr:H8,mx_ramptb:$8,mx_rgbtohsv:G8,mx_rotate2d:EW,mx_rotate3d:AW,mx_safepower:Z8,mx_separate:SW,mx_splitlr:X8,mx_splittb:q8,mx_srgb_texture_to_lin_rec709:W8,mx_subtract:dW,mx_timer:vW,mx_transform_uv:Y8,mx_unifiednoise2d:tW,mx_unifiednoise3d:nW,mx_worley_noise_float:iW,mx_worley_noise_vec2:rW,mx_worley_noise_vec3:sW,negate:BC,neutralToneMapping:xP,nodeArray:im,nodeImmutable:xi,nodeObject:Cn,nodeObjectIntent:Jy,nodeObjects:x_,nodeProxy:zr,nodeProxyIntent:ci,normalFlat:OR,normalGeometry:V_,normalLocal:Tc,normalMap:GM,normalView:fo,normalViewGeometry:Hg,normalWorld:Vf,normalWorldGeometry:FR,normalize:Nd,not:yC,notEqual:hC,numWorkgroups:_6,objectDirection:Pz,objectGroup:oM,objectPosition:NR,objectRadius:Oz,objectScale:Lz,objectViewPosition:Dz,objectWorldMatrix:Iz,oneMinus:UC,or:gC,orthographicDepthToViewZ:A4,oscSawtooth:lG,oscSine:sG,oscSquare:oG,oscTriangle:aG,output:kg,outputStruct:W5,overlay:V4,overloadingFn:Il,parabola:NS,parallaxDirection:t2,parallaxUV:n4,parameter:B5,pass:KG,passTexture:JG,pcurve:J5,perspectiveDepthToViewZ:tS,pmremTexture:AS,pointShadow:$P,pointUV:OG,pointWidth:$k,positionGeometry:Pl,positionLocal:Pa,positionPrevious:z_,positionView:Ia,positionViewDirection:Vo,positionWorld:Yc,positionWorldDirection:LM,posterize:ZG,pow:wu,pow2:mM,pow3:YC,pow4:ZC,premultiplyAlpha:Z2,property:th,quadBroadcast:d8,quadSwapDiagonal:o8,quadSwapX:r8,quadSwapY:s8,radians:LC,rand:QC,range:v6,rangeFog:m6,rangeFogFactor:BS,reciprocal:zC,reference:No,referenceBuffer:kM,reflect:jC,reflectVector:GR,reflectView:zR,reflector:vG,refract:vM,refractVector:WR,refractView:VR,reinhardToneMapping:mP,remap:wR,remapClamp:MR,renderGroup:or,renderOutput:EM,rendererReference:mR,rotate:_v,rotateUV:cG,roughness:Ph,round:kC,rtt:iP,sRGBTransferEOTF:hR,sRGBTransferOETF:dR,sample:AG,sampler:_z,samplerComparison:bz,saturate:yM,saturation:$G,screen:z4,screenCoordinate:mv,screenDPR:AR,screenSize:lm,screenUV:Od,scriptable:p6,scriptableValue:pb,select:wl,setCurrentStack:Qy,setName:_M,shaderStages:$w,shadow:VP,shadowPositionWorld:$S,shapeCircle:C8,sharedUniformGroup:R_,sheen:sm,sheenRoughness:S_,shiftLeft:MC,shiftRight:SC,shininess:A_,sign:lv,sin:Xc,sinc:Q5,skinning:B2,smoothstep:Su,smoothstepElement:tR,specularColor:Mc,specularF90:iv,spherizeUV:uG,split:Wk,spritesheetUV:pG,sqrt:Lh,stack:ob,step:D_,stepElement:nR,storage:hm,storageBarrier:A6,storageObject:g4,storageTexture:aP,string:Vk,struct:G5,sub:Ds,subBuild:Vg,subgroupAdd:H6,subgroupAll:t8,subgroupAnd:Z6,subgroupAny:n8,subgroupBallot:W6,subgroupBroadcast:a8,subgroupBroadcastFirst:i8,subgroupElect:G6,subgroupExclusiveAdd:j6,subgroupExclusiveMul:Y6,subgroupInclusiveAdd:$6,subgroupInclusiveMul:q6,subgroupIndex:a4,subgroupMax:e8,subgroupMin:Q6,subgroupMul:X6,subgroupOr:K6,subgroupShuffle:l8,subgroupShuffleDown:h8,subgroupShuffleUp:u8,subgroupShuffleXor:c8,subgroupSize:S6,subgroupXor:J6,tan:OC,tangentGeometry:H_,tangentLocal:yv,tangentView:$_,tangentWorld:QR,texture:Ps,texture3D:lP,textureBarrier:C6,textureBicubic:yV,textureBicubicLevel:hS,textureCubeUV:CN,textureLoad:Na,textureSize:kf,textureStore:BG,thickness:nM,time:e0,toneMapping:gR,toneMappingExposure:yR,toonOutlinePass:t6,transformDirection:KC,transformNormal:BR,transformNormalToView:OM,transformedClearcoatNormalView:Hz,transformedNormalView:Gz,transformedNormalWorld:Wz,transmission:C_,transpose:GC,triNoise3D:tG,triplanarTexture:mG,triplanarTextures:nP,trunc:pM,uint:Li,uintBitsToFloat:Y5,uniform:cr,uniformArray:Hl,uniformCubeTexture:jz,uniformFlow:sR,uniformGroup:sC,uniformTexture:xz,unpremultiplyAlpha:B4,userData:VG,uv:vo,uvec2:ZA,uvec3:Ug,uvec4:eC,varying:Fh,varyingProperty:$c,vec2:Bn,vec3:qt,vec4:Bi,vectorComponents:tm,velocity:WG,vertexColor:$2,vertexIndex:N2,vertexStage:uR,vibrance:jG,viewZToLogarithmicDepth:nS,viewZToOrthographicDepth:Yg,viewZToPerspectiveDepth:eS,viewport:Gg,viewportCoordinate:CR,viewportDepthTexture:QM,viewportLinearDepth:R4,viewportMipTexture:JM,viewportResolution:Ez,viewportSafeUV:dG,viewportSharedTexture:K2,viewportSize:NM,viewportTexture:T4,viewportUV:Tz,wgsl:a6,wgslFn:u6,workgroupArray:P6,workgroupBarrier:E6,workgroupId:b6,workingToColorSpace:fR,xor:vC});const rh=new RS;class NW extends Hf{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const s=this.renderer,o=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(o===null)s._clearColor.getRGB(rh),rh.a=s._clearColor.a;else if(o.isColor===!0)o.getRGB(rh),rh.a=1,a=!0;else if(o.isNode===!0){const u=this.get(e),d=o;rh.copy(s._clearColor);let p=u.backgroundMesh;if(p===void 0){let G=function(){o.removeEventListener("dispose",G),p.material.dispose(),p.geometry.dispose()};const y=cv(Bi(d).mul(OS),{getUV:()=>oP.mul(FR),getTextureLevel:()=>sP});let M=ZM;M=M.setZ(M.w);const T=new ya;T.name="Background.material",T.side=K,T.depthTest=!1,T.depthWrite=!1,T.allowOverride=!1,T.fog=!1,T.lights=!1,T.vertexNode=M,T.colorNode=y,u.backgroundMeshNode=y,u.backgroundMesh=p=new Zs(new ju(1,32,32),T),p.frustumCulled=!1,p.name="Background.mesh",p.onBeforeRender=function(z,I,ee){this.matrixWorld.copyPosition(ee.matrixWorld)},o.addEventListener("dispose",G)}const m=d.getCacheKey();u.backgroundCacheKey!==m&&(u.backgroundMeshNode.node=Bi(d).mul(OS),u.backgroundMeshNode.needsUpdate=!0,p.material.needsUpdate=!0,u.backgroundCacheKey=m),t.unshift(p,p.geometry,p.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",o);const c=s.xr.getEnvironmentBlendMode();if(c==="additive"?rh.set(0,0,0,1):c==="alpha-blend"&&rh.set(0,0,0,0),s.autoClear===!0||a===!0){const u=n.clearColorValue;u.r=rh.r,u.g=rh.g,u.b=rh.b,u.a=rh.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),n.depthClearValue=s._clearDepth,n.stencilClearValue=s._clearStencil,n.clearColor=s.autoClearColor===!0,n.clearDepth=s.autoClearDepth===!0,n.clearStencil=s.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let PW=0;class JS{constructor(e="",t=[],n=0,s=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=s,this.id=PW++}}class IW{constructor(e,t,n,s,o,a,c,u,d,p=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=p,this.nodeAttributes=s,this.bindings=o,this.updateNodes=a,this.updateBeforeNodes=c,this.updateAfterNodes=u,this.observer=d,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const s=new JS(t.name,[],t.index,t.bindingsReference);e.push(s);for(const o of t.bindings)s.bindings.push(o.clone())}else e.push(t);return e}}class nI{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class LW{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class iI{constructor(e,t,n=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=s}}class DW extends iI{constructor(e,t,n=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=s}}class OW{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let FW=0;class QS{constructor(e=null){this.id=FW++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class BW{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Xf{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class UW extends Xf{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class kW extends Xf{constructor(e,t=new yn){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class zW extends Xf{constructor(e,t=new ot){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class VW extends Xf{constructor(e,t=new mr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class GW extends Xf{constructor(e,t=new jn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class WW extends Xf{constructor(e,t=new Wp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class HW extends Xf{constructor(e,t=new $r){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class $W extends Xf{constructor(e,t=new Ft){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class jW extends UW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XW extends kW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qW extends zW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class YW extends VW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ZW extends GW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class KW extends WW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class JW extends HW{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class QW extends $W{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const rI=new WeakMap,eH=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Sb=r=>/e/g.test(r)?String(r).replace(/\+/g,""):(r=Number(r),r+(r%1?"":".0"));class sI{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=ob(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new QS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=rI.get(this.renderer);return e===void 0&&(e=new nh,rI.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Za(e,t,n)}createCubeRenderTarget(e,t){return new Q2(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const n=this.getBindGroupsCache(),s=[];let o=!0;for(const c of t)s.push(c),o=o&&c.groupNode.shared!==!0;let a;return o?(a=n.get(s),a===void 0&&(a=new JS(e,s,this.bindingsIndexes[e].group,s),n.set(s,a))):a=new JS(e,s,this.bindingsIndexes[e].group,s),a}getBindGroupArray(e,t){const n=this.bindings[t];let s=n[e];return s===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const s of $w)for(const o in n[s]){const a=n[s][o];(t[o]||(t[o]=[])).push(...a)}e=[];for(const s in t){const o=t[s],a=this._getBindGroup(s,o);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Sb(t.r)}, ${Sb(t.g)}, ${Sb(t.b)} )`;const n=this.getTypeLength(e),s=this.getComponentType(e),o=a=>this.generateConst(s,a);if(n===2)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)} )`;if(n===3)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)}, ${o(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(o).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const o of n)if(o.name===e)return o;const s=new nI(e,t);return this.registerDeclaration(s),n.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Is)return"int";if(t===as)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let n=kw(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),s+n}getTypeFromArray(e){return eH.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,s=e.itemSize,o=e.normalized;let a;return!(e instanceof Vm)&&o!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(s,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){this.stack=ob(this.stack);const e=__();return this.stacks.push(e),Qy(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Qy(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let s=n.getData(e);s===void 0&&(s={},n.setData(e,s)),s[t]===void 0&&(s[t]={});let o=s[t];const a=s.any?s.any.subBuilds:null,c=this.getClosestSubBuild(a);return c&&(o.subBuildsCache===void 0&&(o.subBuildsCache={}),o=o.subBuildsCache[c]||(o.subBuildsCache[c]={}),o.subBuilds=a),o}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let s=n.bufferAttribute;if(s===void 0){const o=this.uniforms.index++;s=new nI("nodeAttribute"+o,t,e),this.bufferAttributes.push(s),n.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,s=this.shaderStage){const o=this.getDataFromNode(e,s,this.globalCache);let a=o.structType;if(a===void 0){const c=this.structs.index++;n===null&&(n="StructType"+c),a=new BW(n,t),this.structs[s].push(a),this.types[s][n]=e,o.structType=a}return a}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,s=null){const o=this.getDataFromNode(e,n,this.globalCache);let a=o.uniform;if(a===void 0){const c=this.uniforms.index++;a=new LW(s||"nodeUniform"+c,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),o.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),s=this.shaderStage,o=!1){const a=this.getDataFromNode(e,s),c=this.getSubBuildProperty("variable",a.subBuilds);let u=a[c];if(u===void 0){const d=o?"_const":"_var",p=this.vars[s]||(this.vars[s]=[]),m=this.vars[d]||(this.vars[d]=0);t===null&&(t=(o?"nodeConst":"nodeVar")+m,this.vars[d]++),c!=="variable"&&(t=this.getSubBuildProperty(t,a.subBuilds));const y=e.getArrayCount(this);u=new iI(t,n,o,y),o||p.push(u),this.registerDeclaration(u),a[c]=u}return u}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),s=null,o=null){const a=this.getDataFromNode(e,"any"),c=this.getSubBuildProperty("varying",a.subBuilds);let u=a[c];if(u===void 0){const d=this.varyings,p=d.length;t===null&&(t="nodeVarying"+p),c!=="varying"&&(t=this.getSubBuildProperty(t,a.subBuilds)),u=new DW(t,n,s,o),d.push(u),this.registerDeclaration(u),a[c]=u}return u}registerDeclaration(e){const t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let o=1,a=s;for(;n[a]!==void 0;)a=s+"_"+o++;o>1&&(e.name=a,console.warn(`THREE.TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${a}'.`)),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){const s=this.getDataFromNode(e);let o=s.code;if(o===void 0){const a=this.codes[n]||(this.codes[n]=[]),c=a.length;o=new OW("nodeCode"+c,t),a.push(o),s.code=o}return o}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:s}=this.getDataFromNode(e);let o=!0,a=t;for(;a;){if(s.get(a)===!0){o=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(o)for(const c of n)this.addLineFlowCode(c)}addLineFlowCodeBlock(e,t,n){const s=this.getDataFromNode(e),o=s.flowCodes||(s.flowCodes=[]),a=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);o.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new _P,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const c=Object.values(this);return{next:()=>({value:c[a],done:a++>=c.length})}}};for(const a of t.inputs)n[a.name]=new KN(a.type,a.name);e.layout=null;const s=e.call(n),o=this.flowStagesNode(s,t.type);return e.layout=t,o}flowBuildStage(e,t,n=null){const s=this.getBuildStage();this.setBuildStage(t);const o=e.build(this,n);return this.setBuildStage(s),o}flowStagesNode(e,t=null){const n=this.flow,s=this.vars,o=this.declarations,a=this.cache,c=this.buildStage,u=this.stack,d={code:""};this.flow=d,this.vars={},this.declarations={},this.cache=new QS,this.stack=ob();for(const p of Hw)this.setBuildStage(p),d.result=e.build(this,t);return d.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=s,this.declarations=o,this.cache=a,this.stack=u,this.setBuildStage(c),d}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){const n=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=n,s}flowNodeFromShaderStage(e,t,n=null,s=null){const o=this.tab,a=this.cache,c=this.shaderStage,u=this.context;this.setShaderStage(e);const d=qs({},this.context);delete d.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=d;let p=null;if(this.buildStage==="generate"){const m=this.flowChildNode(t,n);s!==null&&(m.code+=`${this.tab+s} = ${m.result}; `),this.flowCode[e]=this.flowCode[e]+m.code,p=m}else p=t.build(this);return this.setShaderStage(c),this.cache=a,this.tab=o,this.context=u,p}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const s of n)t+=`${this.getVar(s.type,s.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const s of t)n+=s.code+` `;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const n=this.subBuildLayers;for(let s=t.length-1;s>=0;s--){const o=t[s];if(n.includes(o))return o}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let s;return n?s=e?n+"_"+e:n:s=e,s}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let s=n.library.fromMaterial(t);s===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),s=new ya),s.build(this)}else this.addFlow("compute",e);for(const s of Hw){this.setBuildStage(s),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const o of $w){this.setShaderStage(o);const a=this.flowNodes[o];for(const c of a)s==="generate"?this.flowNode(c):c.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new jW(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new XW(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qW(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new YW(e);if(t==="color")return new ZW(e);if(t==="mat2")return new KW(e);if(t==="mat3")return new JW(e);if(t==="mat4")return new QW(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const s=this.getTypeLength(t),o=this.getTypeLength(n);return s===16&&o===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:s===9&&o===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||o>4||o===0?e:s===o?`${this.getType(n)}( ${e} )`:s>o?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,o)}`,this.format(e,this.getTypeFromLength(o,this.getComponentType(t)),n)):o===4&&s>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:s===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(s===1&&o>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${w} - Node System `}}class oI{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===rs.FRAME){const{frameMap:s}=this._getMaps(this.updateBeforeMap,n);s.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&s.set(n,this.frameId)}else if(t===rs.RENDER){const{renderMap:s}=this._getMaps(this.updateBeforeMap,n);s.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&s.set(n,this.renderId)}else t===rs.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===rs.FRAME){const{frameMap:s}=this._getMaps(this.updateAfterMap,n);s.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&s.set(n,this.frameId)}else if(t===rs.RENDER){const{renderMap:s}=this._getMaps(this.updateAfterMap,n);s.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&s.set(n,this.renderId)}else t===rs.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===rs.FRAME){const{frameMap:s}=this._getMaps(this.updateMap,n);s.get(n)!==this.frameId&&e.update(this)!==!1&&s.set(n,this.frameId)}else if(t===rs.RENDER){const{renderMap:s}=this._getMaps(this.updateMap,n);s.get(n)!==this.renderId&&e.update(this)!==!1&&s.set(n,this.renderId)}else t===rs.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class eT{constructor(e,t,n=null,s="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=s,this.isConst=o}}eT.isNodeFunctionInput=!0;class tH extends xm{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:GS(this.light),lightColor:e}}}const tT=new Ft,Tb=new Ft;let Bv=null;class nH extends xm{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=cr(new ot).setGroup(or),this.halfWidth=cr(new ot).setGroup(or),this.updateType=rs.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Tb.identity(),tT.copy(t.matrixWorld),tT.premultiply(n),Tb.extractRotation(tT),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Tb),this.halfHeight.value.applyMatrix4(Tb)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Ps(Bv.LTC_FLOAT_1),n=Ps(Bv.LTC_FLOAT_2)):(t=Ps(Bv.LTC_HALF_1),n=Ps(Bv.LTC_HALF_2));const{colorNode:s,light:o}=this,a=VS(o);return{lightColor:s,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){Bv=e}}class nT extends xm{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=cr(0).setGroup(or),this.penumbraCosNode=cr(0).setGroup(or),this.cutoffDistanceNode=cr(0).setGroup(or),this.decayExponentNode=cr(0).setGroup(or),this.colorNode=cr(this.color).setGroup(or)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:n,penumbraCosNode:s}=this;return Su(n,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=SP(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:s,light:o}=this,a=this.getLightVector(e),c=a.normalize(),u=c.dot(GS(o)),d=this.getSpotAttenuation(e,u),p=a.length(),m=YS({lightDistance:p,cutoffDistance:n,decayExponent:s});let y=t.mul(d).mul(m),M,T;return o.colorNode?(T=this.getLightCoord(e),M=o.colorNode(T)):o.map&&(T=this.getLightCoord(e),M=Ps(o.map,T.xy).onRenderUpdate(()=>o.map)),M&&(y=T.mul(2).sub(1).abs().lessThan(1).all().select(y.mul(M),y)),{lightColor:y,lightDirection:c}}}class iH extends nT{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let s=null;if(n&&n.isTexture===!0){const o=t.acos().mul(1/Math.PI);s=Ps(n,Bn(o,0),0).r}else s=super.getSpotAttenuation(t);return s}}const rH=Kt(([r,e])=>{const t=r.abs().sub(e);return Oh(ga(t,0)).add(Sc(ga(t.x,t.y),0))});class sH extends nT{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=ut(0),n=this.penumbraCosNode,s=vb(this.light).mul(e.context.positionWorld||Yc);return sr(s.w.greaterThan(0),()=>{const o=s.xyz.div(s.w),a=rH(o.xy.sub(Bn(.5)),Bn(.5)),c=jc(-1,Ds(1,hM(n)).sub(1));t.assign(yM(a.mul(-2).mul(c)))}),t}}class oH extends xm{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class aH extends xm{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=zS(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=cr(new jn).setGroup(or)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:s}=this,a=Vf.dot(s).mul(.5).add(.5),c=Hs(n,t,a);e.context.irradiance.addAssign(c)}}class lH extends xm{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new ot);this.lightProbe=Hl(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=tI(Vf,this.lightProbe);e.context.irradiance.addAssign(t)}}class aI{parseFunction(){console.warn("Abstract function.")}}class iT{constructor(e,t,n="",s=""){this.type=e,this.inputs=t,this.name=n,this.precision=s}getCode(){console.warn("Abstract function.")}}iT.isNodeFunction=!0;const cH=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uH=/[a-z_0-9]+/ig,lI="#pragma main",hH=r=>{r=r.trim();const e=r.indexOf(lI),t=e!==-1?r.slice(e+lI.length):r,n=t.match(cH);if(n!==null&&n.length===5){const s=n[4],o=[];let a=null;for(;(a=uH.exec(s))!==null;)o.push(a);const c=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||s){const o=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Pe||n.mapping===Ie||n.mapping===Ke){if(e.backgroundBlurriness>0||n.mapping===Ke)return AS(n);{let a;return n.isCubeTexture===!0?a=$g(n):a=Ps(n),nN(a)}}else{if(n.isTexture===!0)return Ps(n,Od.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},s);t.backgroundNode=o,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,s=!1){const o=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=o.get(t);return(a===void 0||s)&&(a=n(),o.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const s=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const o=No("color","color",n).setGroup(or),a=No("density","float",n).setGroup(or);return Nv(o,US(a))}else if(n.isFog){const o=No("color","color",n).setGroup(or),a=No("near","float",n).setGroup(or),c=No("far","float",n).setGroup(or);return Nv(o,BS(a,c))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=s,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const s=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return $g(n);if(n.isTexture===!0)return Ps(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=s,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,s=null,o=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=s,a.material=o,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return cI.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),s=e.isArrayTexture?lP(e,qt(Od,Dd("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Ps(e,Od).renderOutput(t.toneMapping,t.currentColorSpace);return cI.set(e,n),s}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const s of n.updateNodes)t.updateNode(s)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const s of n.updateNodes)t.updateNode(s)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new oI,this.nodeBuilderCache=new Map,this.cacheLib={}}}const rT=new Al;class Eb{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new $r,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const s=e.length;for(let o=0;o0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},c=new XRWebGLLayer(e,s,a);this._glBaseLayer=c,e.updateRenderState({baseLayer:c}),t.setPixelRatio(1),t._setXRLayerSize(c.framebufferWidth,c.framebufferHeight),this._xrRenderTarget=new zv(c.framebufferWidth,c.framebufferHeight,{format:D,type:Oi,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=yield e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}})}updateCamera(e){const t=this._session;if(t===null)return;const n=e.near,s=e.far,o=this._cameraXR,a=this._cameraL,c=this._cameraR;o.near=c.near=a.near=n,o.far=c.far=a.far=s,o.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==o.near||this._currentDepthFar!==o.far)&&(t.updateRenderState({depthNear:o.near,depthFar:o.far}),this._currentDepthNear=o.near,this._currentDepthFar=o.far),o.layers.mask=e.layers.mask|6,a.layers.mask=o.layers.mask&3,c.layers.mask=o.layers.mask&5;const u=e.parent,d=o.cameras;fI(o,u);for(let p=0;p=0&&(t[o]=null,e[o].disconnect(s))}for(let n=0;n=t.length){t.push(s),o=c;break}else if(t[c]===null){t[c]=s,o=c;break}if(o===-1)break}const a=e[o];a&&a.connect(s)}}function TH(r){return r.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(r.translation,r.quaternion),width:r.width/2,height:r.height/2,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(r.translation,r.quaternion),radius:r.radius,centralAngle:r.centralAngle,aspectRatio:r.aspectRatio,space:this._referenceSpace,viewPixelWidth:r.pixelwidth,viewPixelHeight:r.pixelheight,clearOnAccess:!1})}function EH(r,e){if(e===void 0)return;const t=this._cameraXR,n=this._renderer,s=n.backend,o=this._glBaseLayer,a=this.getReferenceSpace(),c=e.getViewerPose(a);if(this._xrFrame=e,c!==null){const u=c.views;this._glBaseLayer!==null&&s.setXRTarget(o.framebuffer);let d=!1;u.length!==t.cameras.length&&(t.cameras.length=0,d=!0);for(let p=0;phr(this,null,function*(){yield this.compileAsync(M,T);const z=this._renderLists.get(M,T),I=this._renderContexts.get(M,T,this._renderTarget),ee=M.overrideMaterial||G.material,Q=this._objects.get(G,ee,M,T,z.lightsNode,I,I.clippingContext),{fragmentShader:oe,vertexShader:_e}=Q.getNodeBuilderState();return{fragmentShader:oe,vertexShader:_e}})}}init(){return hr(this,null,function*(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise((e,t)=>hr(this,null,function*(){let n=this.backend;try{yield n.init(this)}catch(s){if(this._getFallback!==null)try{this.backend=n=this._getFallback(s),yield n.init(this)}catch(o){t(o);return}else{t(s);return}}this._nodes=new pH(this,n),this._animation=new d5(this._nodes,this.info),this._attributes=new x5(n),this._background=new NW(this,this._nodes),this._geometries=new _5(this._attributes,this.info),this._textures=new F5(this,n,this.info),this._pipelines=new T5(n,this._nodes),this._bindings=new E5(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new g5(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new R5(this.lighting),this._bundles=new gH,this._renderContexts=new D5,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise)})}get coordinateSystem(){return this.backend.coordinateSystem}compileAsync(e,t,n=null){return hr(this,null,function*(){if(this._isDeviceLost===!0)return;this._initialized===!1&&(yield this.init());const s=this._nodes.nodeFrame,o=s.renderId,a=this._currentRenderContext,c=this._currentRenderObjectFunction,u=this._compilationPromises,d=e.isScene===!0?e:pI;n===null&&(n=e);const p=this._renderTarget,m=this._renderContexts.get(n,t,p),y=this._activeMipmapLevel,M=[];this._currentRenderContext=m,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=M,s.renderId++,s.update(),m.depth=this.depth,m.stencil=this.stencil,m.clippingContext||(m.clippingContext=new Eb),m.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,p);const T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,m.clippingContext),n!==e&&n.traverseVisible(function(Q){Q.isLight&&Q.layers.test(t.layers)&&T.pushLight(Q)}),T.finish(),p!==null){this._textures.updateRenderTarget(p,y);const Q=this._textures.get(p);m.textures=Q.textures,m.depthTexture=Q.depthTexture}else m.textures=null,m.depthTexture=null;this._background.update(d,T,m);const G=T.opaque,z=T.transparent,I=T.transparentDoublePass,ee=T.lightsNode;this.opaque===!0&&G.length>0&&this._renderObjects(G,t,d,ee),this.transparent===!0&&z.length>0&&this._renderTransparents(z,I,t,d,ee),s.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=c,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,yield Promise.all(M)})}renderAsync(e,t){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._renderScene(e,t)})}waitForGPU(){return hr(this,null,function*(){yield this.backend.waitForGPU()})}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=PM,this.overrideNodes.modelNormalViewMatrix=IM):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===PM&&this.overrideNodes.modelNormalViewMatrix===IM}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: Message: ${e.message}`;e.reason&&(t+=` Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:s,camera:o,renderList:a}=e,c=this._currentRenderContext,u=this._bundles.get(s,o),d=this.backend.get(u);d.renderContexts===void 0&&(d.renderContexts=new Set);const p=s.version!==d.version,m=d.renderContexts.has(c)===!1||p;if(d.renderContexts.add(c),m){this.backend.beginBundle(c),(d.renderObjects===void 0||p)&&(d.renderObjects=[]),this._currentRenderBundle=u;const{transparentDoublePass:y,transparent:M,opaque:T}=a;this.opaque===!0&&T.length>0&&this._renderObjects(T,o,t,n),this.transparent===!0&&M.length>0&&this._renderTransparents(M,y,o,t,n),this._currentRenderBundle=null,this.backend.finishBundle(c,u),d.version=s.version}else{const{renderObjects:y}=d;for(let M=0,T=y.length;M>=y,T.viewportValue.height>>=y,T.viewportValue.minDepth=oe,T.viewportValue.maxDepth=_e,T.viewport=T.viewportValue.equals(sT)===!1,T.scissorValue.copy(ee).multiplyScalar(Q).floor(),T.scissor=this._scissorTest&&T.scissorValue.equals(sT)===!1,T.scissorValue.width>>=y,T.scissorValue.height>>=y,T.clippingContext||(T.clippingContext=new Eb),T.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,M);const ve=t.isArrayCamera?aT:oT;t.isArrayCamera||(Ab.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ve.setFromProjectionMatrix(Ab,t.coordinateSystem,t.reversedDepth));const Oe=this._renderLists.get(e,t);if(Oe.begin(),this._projectObject(e,t,0,Oe,T.clippingContext),Oe.finish(),this.sortObjects===!0&&Oe.sort(this._opaqueSort,this._transparentSort),M!==null){this._textures.updateRenderTarget(M,y);const tn=this._textures.get(M);T.textures=tn.textures,T.depthTexture=tn.depthTexture,T.width=tn.width,T.height=tn.height,T.renderTarget=M,T.depth=M.depthBuffer,T.stencil=M.stencilBuffer}else T.textures=null,T.depthTexture=null,T.width=a0.width,T.height=a0.height,T.depth=this.depth,T.stencil=this.stencil;T.width>>=y,T.height>>=y,T.activeCubeFace=m,T.activeMipmapLevel=y,T.occlusionQueryCount=Oe.occlusionQueryCount,T.scissorValue.max(Vd.set(0,0,0,0)),T.scissorValue.x+T.scissorValue.width>T.width&&(T.scissorValue.width=Math.max(T.width-T.scissorValue.x,0)),T.scissorValue.y+T.scissorValue.height>T.height&&(T.scissorValue.height=Math.max(T.height-T.scissorValue.y,0)),this._background.update(d,Oe,T),T.camera=t,this.backend.beginRender(T);const{bundles:He,lightsNode:Ce,transparentDoublePass:Be,transparent:ft,opaque:zt}=Oe;return He.length>0&&this._renderBundles(He,d,Ce),this.opaque===!0&&zt.length>0&&this._renderObjects(zt,t,d,Ce),this.transparent===!0&&ft.length>0&&this._renderTransparents(ft,Be,t,d,Ce),this.backend.finishRender(T),o.renderId=a,this._currentRenderContext=c,this._currentRenderObjectFunction=u,s!==null&&(this.setRenderTarget(p,m,y),this._renderOutput(M)),d.onAfterRender(this,e,t,M),T}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const n=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}setAnimationLoop(e){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._animation.setAnimationLoop(e)})}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.backend.getArrayBufferAsync(e)})}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,s){const o=this._scissor;e.isVector4?o.copy(e):o.set(e,t,n,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,s,o=0,a=1){const c=this._viewport;e.isVector4?c.copy(e):c.set(e,t,n,s),c.minDepth=o,c.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const s=this._renderTarget||this._getFrameBufferTarget();let o=null;if(s!==null){this._textures.updateRenderTarget(s);const a=this._textures.get(s);o=this._renderContexts.getForClear(s),o.textures=a.textures,o.depthTexture=a.depthTexture,o.width=a.width,o.height=a.height,o.renderTarget=s,o.depth=s.depthBuffer,o.stencil=s.stencilBuffer,o.clearColorValue=this.backend.getClearColor(),o.activeCubeFace=this.getActiveCubeFace(),o.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,o),s!==null&&this._renderTarget===null&&this._renderOutput(s)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}clearAsync(e=!0,t=!0,n=!0){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this.clear(e,t,n)})}clearColorAsync(){return hr(this,null,function*(){this.clearAsync(!0,!1,!1)})}clearDepthAsync(){return hr(this,null,function*(){this.clearAsync(!1,!0,!1)})}clearStencilAsync(){return hr(this,null,function*(){this.clearAsync(!1,!1,!0)})}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:yt}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Ki.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const n=this._nodes.nodeFrame,s=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls;const o=this.backend,a=this._pipelines,c=this._bindings,u=this._nodes,d=Array.isArray(e)?e:[e];if(d[0]===void 0||d[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");o.beginCompute(e);for(const p of d){if(a.has(p)===!1){const M=()=>{p.removeEventListener("dispose",M),a.delete(p),c.delete(p),u.delete(p)};p.addEventListener("dispose",M);const T=p.onInitFunction;T!==null&&T.call(p,{renderer:this})}u.updateForCompute(p),c.updateForCompute(p);const m=c.getForCompute(p),y=a.getForCompute(p,m);o.compute(e,p,m,y,t)}o.finishCompute(e),n.renderId=s}computeAsync(e,t=null){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this.compute(e,t)})}hasFeatureAsync(e){return hr(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.hasFeature(e)})}resolveTimestampsAsync(e="render"){return hr(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.resolveTimestampsAsync(e)})}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}initTextureAsync(e){return hr(this,null,function*(){this._initialized===!1&&(yield this.init()),this._textures.updateTexture(e)})}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Vd.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Vd.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Vd.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,s;n!==null?s=n.renderTarget:(s=this._renderTarget||this._getFrameBufferTarget(),s!==null&&(this._textures.updateRenderTarget(s),n=this._textures.get(s))),this._textures.updateTexture(e,{renderTarget:s}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,s=null,o=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,s,o,a)}readRenderTargetPixelsAsync(e,t,n,s,o,a=0,c=0){return hr(this,null,function*(){return this.backend.copyTextureToBuffer(e.textures[a],t,n,s,o,c)})}_projectObject(e,t,n,s,o){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(o=o.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const u=t.isArrayCamera?aT:oT;if(!e.frustumCulled||u.intersectsSprite(e,t)){this.sortObjects===!0&&Vd.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Ab);const{geometry:d,material:p}=e;p.visible&&s.push(e,d,p,n,Vd.z,null,o)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const u=t.isArrayCamera?aT:oT;if(!e.frustumCulled||u.intersectsObject(e,t)){const{geometry:d,material:p}=e;if(this.sortObjects===!0&&(d.boundingSphere===null&&d.computeBoundingSphere(),Vd.copy(d.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Ab)),Array.isArray(p)){const m=d.groups;for(let y=0,M=m.length;y0){for(const{material:a}of t)a.side=K;this._renderObjects(t,n,s,o,"backSide");for(const{material:a}of t)a.side=W;this._renderObjects(e,n,s,o);for(const{material:a}of t)a.side=re}else this._renderObjects(e,n,s,o)}_renderObjects(e,t,n,s,o=null){for(let a=0,c=e.length;a0,M.isShadowPassMaterial&&(M.side=o.shadowSide===null?o.side:o.shadowSide,o.depthNode&&o.depthNode.isNode&&(y=M.depthNode,M.depthNode=o.depthNode),o.castShadowNode&&o.castShadowNode.isNode&&(m=M.colorNode,M.colorNode=o.castShadowNode),o.castShadowPositionNode&&o.castShadowPositionNode.isNode&&(p=M.positionNode,M.positionNode=o.castShadowPositionNode)),o=M}o.transparent===!0&&o.side===re&&o.forceSinglePass===!1?(o.side=K,this._handleObjectFunction(e,o,t,n,c,a,u,"backSide"),o.side=W,this._handleObjectFunction(e,o,t,n,c,a,u,d),o.side=re):this._handleObjectFunction(e,o,t,n,c,a,u,d),p!==void 0&&(t.overrideMaterial.positionNode=p),y!==void 0&&(t.overrideMaterial.depthNode=y),m!==void 0&&(t.overrideMaterial.colorNode=m),e.onAfterRender(this,t,n,s,o,a)}_renderObjectDirect(e,t,n,s,o,a,c,u){const d=this._objects.get(e,t,n,s,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a;const p=this._nodes.needsRefresh(d);p&&(this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d)),this._pipelines.updateForRender(d),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(d),d.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(d,this.info),p&&this._nodes.updateAfter(d)}_createObjectPipeline(e,t,n,s,o,a,c,u){const d=this._objects.get(e,t,n,s,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a,this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d),this._pipelines.getForRender(d,this._compilationPromises),this._nodes.updateAfter(d)}get compile(){return this.compileAsync}}class mI{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function CH(r){return r+($f-r%$f)%$f}class gI extends mI{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return CH(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class yI extends gI{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let RH=0;class vI extends yI{constructor(e,t){super("UniformBuffer_"+RH++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class NH extends yI{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let n=0,s=this.uniforms.length;n{this._texture=null,this.generation=null,this.version=0};this._texture&&this._texture.removeEventListener("dispose",t),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",t)}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){const e=super.clone();return e._texture=null,e.texture=this.texture,e}}let DH=0;class OH extends _I{constructor(e,t){super(e,t),this.id=DH++,this.store=!1,this.isSampledTexture=!0}}class Cb extends OH{constructor(e,t,n,s=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=s}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class bI extends Cb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledCubeTexture=!0}}class lT extends Cb{constructor(e,t,n,s=null){super(e,t,n,s),this.isSampledTexture3D=!0}}const wI={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},FH={low:"lowp",medium:"mediump",high:"highp"},MI={swizzleAssign:!0,storageBuffer:!1},SI={perspective:"smooth",linear:"noperspective"},TI={centroid:"centroid"},EI=` precision highp float; precision highp int; precision highp sampler2D; precision highp sampler3D; precision highp samplerCube; precision highp sampler2DArray; precision highp usampler2D; precision highp usampler3D; precision highp usamplerCube; precision highp usampler2DArray; precision highp isampler2D; precision highp isampler3D; precision highp isamplerCube; precision highp isampler2DArray; precision lowp sampler2DShadow; precision lowp sampler2DArrayShadow; precision lowp samplerCubeShadow; `;class BH extends sI{constructor(e,t){super(e,t,new fH),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Qo}getMethod(e){return wI[e]||e}getBitcastMethod(e,t){return wI[`bitcast_${t}_${e}`]}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),s=[];for(const a of t.inputs)s.push(this.getType(a.type)+" "+a.name);return`${this.getType(t.type)} ${t.name}( ${s.join(", ")} ) { ${n.vars} ${n.code} return ${n.result}; }`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,s=t.count*t.itemSize,{itemSize:o}=t,a=t.array.constructor.name.toLowerCase().includes("int");let c=a?X:F;o===2?c=a?Ve:De:o===3?c=a?it:Le:o===4&&(c=a?st:D);const u={Float32Array:gs,Uint8Array:Oi,Uint16Array:ms,Uint32Array:as,Int8Array:Gi,Int16Array:ir,Int32Array:Is,Uint8ClampedArray:Oi},d=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(s/o))));let p=Math.ceil(s/o/d);d*p*o0?y:"";c=`${p.name} { ${m} ${a.name}[${M}]; }; `}else c=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const d=a.node.precision;if(d!==null&&(c=FH[d]+" "+c),u){c=" "+c;const p=a.groupNode.name;(s[p]||(s[p]=[])).push(c)}else c="uniform "+c,n.push(c)}let o="";for(const a in s){const c=s[a];o+=this._getGLSLUniformStruct(e+"_"+a,c.join(` `))+` `}return o+=n.join(` `),o}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Is){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const s=n.array;s instanceof Uint32Array||s instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let s=0;for(const o of n)t+=`layout( location = ${s++} ) in ${o.type} ${o.name}; `}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(` `)}getStructs(e){const t=[],n=this.structs[e],s=[];for(const o of n)if(o.output)for(const a of o.members)s.push(`layout( location = ${a.index} ) out ${a.type} ${a.name};`);else{let a="struct "+o.name+` { `;a+=this.getStructMembers(o),a+=` }; `,t.push(a)}return s.length===0&&s.push("layout( location = 0 ) out vec4 fragColor;"),` `+s.join(` `)+` `+t.join(` `)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const s of n){e==="compute"&&(s.needsInterpolation=!0);const o=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const a=SI[s.interpolationType]||s.interpolationType,c=TI[s.interpolationSampling]||"";t+=`${a} ${c} out ${o} ${s.name}; `}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}out ${o} ${s.name}; `}else t+=`${o} ${s.name}; `}else if(e==="fragment"){for(const s of n)if(s.needsInterpolation){const o=this.getType(s.type);if(s.interpolationType){const a=SI[s.interpolationType]||s.interpolationType,c=TI[s.interpolationSampling]||"";t+=`${a} ${c} in ${o} ${s.name}; `}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}in ${o} ${s.name}; `}}}for(const s of this.builtins[e])t+=`${s}; `;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,s)=>n*s,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const s=this.extensions[n]||(this.extensions[n]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:s,behavior:o}of n.values())t.push(`#extension ${s} : ${o}`);return t.join(` `)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=MI[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const s=this.renderer.backend.extensions;s.has(n)&&(s.get(n),t=!0)}MI[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+=` `),n+=` // flow -> ${d} `),n+=`${u.code} `,c===o&&t!=="compute"&&(n+=`// result `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(c.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,s=null){const o=super.getUniformFromNode(e,t,n,s),a=this.getDataFromNode(e,n,this.globalCache);let c=a.uniformGPU;if(c===void 0){const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture")c=new Cb(o.name,o.node,u),p.push(c);else if(t==="cubeTexture")c=new bI(o.name,o.node,u),p.push(c);else if(t==="texture3D")c=new lT(o.name,o.node,u),p.push(c);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,o.name=`buffer${e.id}`;const m=new vI(e,u);m.name=e.name,p.push(m),c=m}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new xI(n+"_"+d,u),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}}let cT=null,l0=null;class AI{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}init(e){return hr(this,null,function*(){this.renderer=e})}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){return hr(this,null,function*(){})}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}getTimestampUID(e){const t=this.get(e);let n=e.isComputeNode===!0?"c":"r";return n+=":"+t.frameCalls+":"+e.id,n}isOccluded(){}resolveTimestampsAsync(e="render"){return hr(this,null,function*(){if(!this.trackTimestamp){ol("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t){ol(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}const n=yield t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n})}waitForGPU(){return hr(this,null,function*(){})}getArrayBufferAsync(){return hr(this,null,function*(){})}hasFeatureAsync(){return hr(this,null,function*(){})}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return cT=cT||new yn,this.renderer.getDrawingBufferSize(cT)}setScissorTest(){}getClearColor(){const e=this.renderer;return l0=l0||new RS,e.getClearColor(l0),l0.getRGB(l0),l0}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:Ya(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${w} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let UH=0;class kH{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class zH{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:s}=n,o=e.array,a=e.usage||s.STATIC_DRAW,c=e.isInterleavedBufferAttribute?e.data:e,u=n.get(c);let d=u.bufferGPU;d===void 0&&(d=this._createBuffer(s,t,o,a),u.bufferGPU=d,u.bufferType=t,u.version=c.version);let p;if(o instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array!="undefined"&&o instanceof Float16Array)p=s.HALF_FLOAT;else if(o instanceof Uint16Array)e.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(o instanceof Int16Array)p=s.SHORT;else if(o instanceof Uint32Array)p=s.UNSIGNED_INT;else if(o instanceof Int32Array)p=s.INT;else if(o instanceof Int8Array)p=s.BYTE;else if(o instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(o instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+o);let m={bufferGPU:d,bufferType:t,type:p,byteLength:o.byteLength,bytesPerElement:o.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:p===s.INT||p===s.UNSIGNED_INT||e.gpuType===Is,id:UH++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const y=this._createBuffer(s,t,o,a);m=new kH(m,y)}n.set(e,m)}updateAttribute(e){const t=this.backend,{gl:n}=t,s=e.array,o=e.isInterleavedBufferAttribute?e.data:e,a=t.get(o),c=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(c,a.bufferGPU),u.length===0)n.bufferSubData(c,0,s);else{for(let d=0,p=u.length;d1?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function o(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),s();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(o);return}e.deleteSync(t),n()}o()})}}let CI=!1,Rb,hT,RI;class WH{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},CI===!1&&(this._init(),CI=!0)}_init(){const e=this.gl;Rb={[lt]:e.REPEAT,[qe]:e.CLAMP_TO_EDGE,[pt]:e.MIRRORED_REPEAT},hT={[Ct]:e.NEAREST,[Xt]:e.NEAREST_MIPMAP_NEAREST,[pn]:e.NEAREST_MIPMAP_LINEAR,[Rn]:e.LINEAR,[bi]:e.LINEAR_MIPMAP_NEAREST,[Qn]:e.LINEAR_MIPMAP_LINEAR},RI={[Lm]:e.NEVER,[Dm]:e.ALWAYS,[qd]:e.LESS,[ep]:e.LEQUAL,[Yd]:e.EQUAL,[w0]:e.GEQUAL,[_0]:e.GREATER,[b0]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,s,o=!1){const{gl:a,extensions:c}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;if(t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB){const d=o?ah:Ki.getTransfer(s);n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=d===Fi?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5),n===a.UNSIGNED_INT_10F_11F_11F_REV&&(u=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA){const d=o?ah:Ki.getTransfer(s);n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=d===Fi?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_SHORT&&(u=a.DEPTH_COMPONENT16),n===a.UNSIGNED_INT&&(u=a.DEPTH_COMPONENT24),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&c.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:s,backend:o}=this,a=Ki.getPrimaries(Ki.workingColorSpace),c=t.colorSpace===Qo?null:Ki.getPrimaries(t.colorSpace),u=t.colorSpace===Qo||a===c?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),n.texParameteri(e,n.TEXTURE_WRAP_S,Rb[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Rb[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Rb[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,hT[t.magFilter]);const d=t.mipmaps!==void 0&&t.mipmaps.length>0,p=t.minFilter===Rn&&d?Qn:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,hT[p]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,RI[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Ct||t.minFilter!==pn&&t.minFilter!==Qn||t.type===gs&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const m=s.get("EXT_texture_filter_anisotropic");n.texParameterf(e,m.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,o.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:s}=this,o=this.getGLTextureType(e);let a=s[o];a===void 0&&(a=t.createTexture(),n.state.bindTexture(o,a),t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST),s[o]=a),n.set(e,{textureGPU:a,glTextureType:o,isDefault:!0})}createTexture(e,t){const{gl:n,backend:s}=this,{levels:o,width:a,height:c,depth:u}=t,d=s.utils.convert(e.format,e.colorSpace),p=s.utils.convert(e.type),m=this.getInternalFormat(e.internalFormat,d,p,e.colorSpace,e.isVideoTexture),y=n.createTexture(),M=this.getGLTextureType(e);s.state.bindTexture(M,y),this.setTextureParameters(M,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,o,m,a,c,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,o,m,a,c,u):e.isVideoTexture||n.texStorage2D(M,o,m,a,c),s.set(e,{textureGPU:y,glTextureType:M,glFormat:d,glType:p,glInternalFormat:m})}copyBufferToTexture(e,t){const{gl:n,backend:s}=this,{textureGPU:o,glTextureType:a,glFormat:c,glType:u}=s.get(t),{width:d,height:p}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,o),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,d,p,c,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:s,height:o}=t,{textureGPU:a,glTextureType:c,glFormat:u,glType:d,glInternalFormat:p}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(c,a),this.setTextureParameters(c,e),e.isCompressedTexture){const m=e.mipmaps,y=t.image;for(let M=0;M0){const y=Oy(m.width,m.height,e.format,e.type);for(const M of e.layerUpdates){const T=m.data.subarray(M*y/m.data.BYTES_PER_ELEMENT,(M+1)*y/m.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,M,m.width,m.height,1,u,d,T)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isData3DTexture){const m=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(c,0,p,u,d,t.image);else{const m=e.mipmaps;if(m.length>0)for(let y=0,M=m.length;y0,y=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(m){const M=c!==0||u!==0;let T,G;if(e.isDepthTexture===!0?(T=s.DEPTH_BUFFER_BIT,G=s.DEPTH_ATTACHMENT,t.stencil&&(T|=s.STENCIL_BUFFER_BIT)):(T=s.COLOR_BUFFER_BIT,G=s.COLOR_ATTACHMENT0),M){const z=this.backend.get(t.renderTarget),I=z.framebuffers[t.getCacheKey()],ee=z.msaaFrameBuffer;o.bindFramebuffer(s.DRAW_FRAMEBUFFER,I),o.bindFramebuffer(s.READ_FRAMEBUFFER,ee);const Q=y-u-p;s.blitFramebuffer(c,Q,c+d,Q+p,c,Q,c+d,Q+p,T,s.NEAREST),o.bindFramebuffer(s.READ_FRAMEBUFFER,I),o.bindTexture(s.TEXTURE_2D,a),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,c,Q,d,p),o.unbindTexture()}else{const z=s.createFramebuffer();o.bindFramebuffer(s.DRAW_FRAMEBUFFER,z),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,G,s.TEXTURE_2D,a,0),s.blitFramebuffer(0,0,d,p,0,0,d,p,T,s.NEAREST),s.deleteFramebuffer(z)}}else o.bindTexture(s.TEXTURE_2D,a),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,c,y-p-u,d,p),o.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,s=!1){const{gl:o}=this,a=t.renderTarget,{depthTexture:c,depthBuffer:u,stencilBuffer:d,width:p,height:m}=a;if(o.bindRenderbuffer(o.RENDERBUFFER,e),u&&!d){let y=o.DEPTH_COMPONENT24;s===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(o.RENDERBUFFER,a.samples,y,p,m):n>0?(c&&c.isDepthTexture&&c.type===o.FLOAT&&(y=o.DEPTH_COMPONENT32F),o.renderbufferStorageMultisample(o.RENDERBUFFER,n,y,p,m)):o.renderbufferStorage(o.RENDERBUFFER,y,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,e)}else u&&d&&(n>0?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH24_STENCIL8,p,m):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,e));o.bindRenderbuffer(o.RENDERBUFFER,null)}copyTextureToBuffer(e,t,n,s,o,a){return hr(this,null,function*(){const{backend:c,gl:u}=this,{textureGPU:d,glFormat:p,glType:m}=this.backend.get(e),y=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,y);const M=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,M,d,0);const T=this._getTypedArrayType(m),G=this._getBytesPerTexel(m,p),I=s*o*G,ee=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,ee),u.bufferData(u.PIXEL_PACK_BUFFER,I,u.STREAM_READ),u.readPixels(t,n,s,o,p,m,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),yield c.utils._clientWaitAsync();const Q=new T(I/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,ee),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,Q),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(y),Q})}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let s=0;if(e===n.UNSIGNED_BYTE&&(s=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(s=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(s=4),t===n.RGBA)return s*4;if(t===n.RGB)return s*3;if(t===n.ALPHA)return s}}function Nb(r){return r.isDataTexture?r.image.data:typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&r instanceof OffscreenCanvas?r:r.data}class HH{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class $H{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const NI={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class jH{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:s,object:o,type:a,info:c,index:u}=this;u!==0?n.drawElements(s,t,a,e):n.drawArrays(s,e,t),c.update(o,t,1)}renderInstances(e,t,n){const{gl:s,mode:o,type:a,index:c,object:u,info:d}=this;n!==0&&(c!==0?s.drawElementsInstanced(o,t,a,e,n):s.drawArraysInstanced(o,e,t,n),d.update(u,t,n))}renderMultiDraw(e,t,n){const{extensions:s,mode:o,object:a,info:c}=this;if(n===0)return;const u=s.get("WEBGL_multi_draw");if(u===null)for(let d=0;dthis.maxQueries)return ol(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(s){console.error("Error in beginQuery:",s),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(n){console.error("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}resolveQueriesAsync(){return hr(this,null,function*(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[s,o]of this.queryStates)if(o==="ended"){const a=this.queries[s];e.push(this.resolveQuery(a))}if(e.length===0)return this.lastValue;const n=(yield Promise.all(e)).reduce((s,o)=>s+o,0);return this.lastValue=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}})}resolveQuery(e){return hr(this,null,function*(){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,s=!1;const o=()=>{n&&(clearTimeout(n),n=null)},a=u=>{s||(s=!0,o(),t(u))},c=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(c,1);return}const p=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(p)/1e6)}catch(u){console.error("Error checking query:",u),t(this.lastValue)}};c()})})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class II extends AI{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,n={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function o(a){a.preventDefault();const c={api:"WebGL",message:a.statusMessage||"Unknown reason",reason:null,originalEvent:a};e.onDeviceLost(c)}this._onContextLost=o,e.domElement.addEventListener("webglcontextlost",o,!1),this.gl=s,this.extensions=new HH(this),this.capabilities=new $H(this),this.attributeUtils=new zH(this),this.textureUtils=new WH(this),this.bufferRenderer=new jH(this),this.state=new VH(this),this.utils=new GH(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return so}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}waitForGPU(){return hr(this,null,function*(){yield this.utils._clientWaitAsync()})}makeXRCompatible(){return hr(this,null,function*(){this.gl.getContextAttributes().xrCompatible!==!0&&(yield this.gl.makeXRCompatible())})}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),n!==null){const o=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:o}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new XH(this.gl,e,2048));const n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,n=this.get(e);if(n.frameCalls=this.renderer.info.render.frameCalls,e.viewport)this.updateViewport(e);else{const{width:o,height:a}=this.getDrawingBufferSize();t.viewport(0,0,o,a)}if(e.scissor){const{x:o,y:a,width:c,height:u}=e.scissorValue;t.scissor(o,e.height-u-a,c,u)}this.initTimestampQuery(lh.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(s),n.occlusionQueryObjects=new Array(s),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,s=this.get(e),o=s.previousContext;n.resetVertexState();const a=e.occlusionQueryCount;a>0&&(a>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const c=e.textures;if(c!==null)for(let u=0;u{let u=0;for(let d=0;d{t.isBatchedMesh?t._multiDrawInstances!==null?(ol("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Q.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?Q.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):ol("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):_e>1?Q.renderInstances(ve,oe,_e):Q.render(ve,oe)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const He=this.get(e.camera),Ce=e.camera.cameras,Be=e.getBindingGroup("cameraIndex").bindings[0];if(He.indexesGPU===void 0||He.indexesGPU.length!==Ce.length){const mn=new Uint32Array([0,0,0,0]),Yn=[];for(let xn=0,si=Ce.length;xn{const y=this.parallel,M=()=>{n.getProgramParameter(c,y.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),m()):requestAnimationFrame(M)};M()});t.push(p);return}this._completeCompile(e,s)}_handleSource(e,t){const n=e.split(` `),s=[],o=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let c=o;c":" "} ${u}: ${n[c]}`)}return s.join(` `)}_getShaderErrors(e,t,n){const s=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(s&&a==="")return"";const c=/ERROR: 0:(\d+)/.exec(a);if(c){const u=parseInt(c[1]);return n.toUpperCase()+` `+a+` `+this._handleSource(e.getShaderSource(t),u)}else return a}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const s=this.gl,a=(s.getProgramInfoLog(e)||"").trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,n,t);else{const c=this._getShaderErrors(s,n,"vertex"),u=this._getShaderErrors(s,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+` Program Info Log: `+a+` `+c+` `+u)}else a!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",a)}}_completeCompile(e,t){const{state:n,gl:s}=this,o=this.get(t),{programGPU:a,fragmentShader:c,vertexShader:u}=o;s.getProgramParameter(a,s.LINK_STATUS)===!1&&this._logProgramError(a,c,u),n.useProgram(a);const d=e.getBindings();this._setupBindings(d,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:s}=this,o={stage:"fragment",code:`#version 300 es precision highp float; void main() {}`};this.createProgram(o);const{computeProgram:a}=e,c=s.createProgram(),u=this.get(o).shaderGPU,d=this.get(a).shaderGPU,p=a.transforms,m=[],y=[];for(let z=0;zNI[s]===e),n=this.extensions;for(let s=0;s1,M=o.isXRRenderTarget===!0,T=M===!0&&o._hasExternalTextures===!0;let G=a.msaaFrameBuffer,z=a.depthRenderbuffer;const I=this.extensions.get("WEBGL_multisampled_render_to_texture"),ee=this.extensions.get("OVR_multiview2"),Q=this._useMultisampledExtension(o),oe=ZN(e);let _e;if(p?(a.cubeFramebuffers||(a.cubeFramebuffers={}),_e=a.cubeFramebuffers[oe]):M&&T===!1?_e=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),_e=a.framebuffers[oe]),_e===void 0){_e=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,_e);const ve=e.textures,Oe=[];if(p){a.cubeFramebuffers[oe]=_e;const{textureGPU:Ce}=this.get(ve[0]),Be=this.renderer._activeCubeFace,ft=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Ce,ft)}else{a.framebuffers[oe]=_e;for(let Ce=0;Ce0&&Q===!1&&!o.multiview){if(G===void 0){const ve=[];G=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,G);const Oe=[],He=e.textures;for(let Ce=0;Ce0&&this._useMultisampledExtension(s)===!1){const a=o.framebuffers[e.getCacheKey()];let c=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(c|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(c|=t.STENCIL_BUFFER_BIT));const u=o.msaaFrameBuffer,d=o.msaaRenderbuffers,p=e.textures,m=p.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,u),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),m)for(let y=0;y0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const c0={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Ll={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},sc={Store:"store"},mo={Load:"load",Clear:"clear"},LI={CCW:"ccw",CW:"cw"},DI={None:"none",Back:"back"},u0={Uint16:"uint16",Uint32:"uint32"},jt={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},dT={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},bm={Linear:"linear",Nearest:"nearest"},ks={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},wm={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},OI={None:0,All:15},qf={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},fT={Storage:"storage",ReadOnlyStorage:"read-only-storage"},pT={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},FI={NonFiltering:"non-filtering",Comparison:"comparison"},Mm={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},BI={TwoD:"2d",ThreeD:"3d"},nl={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},qH={All:"all"},Pb={Vertex:"vertex",Instance:"instance"},mT={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"};class YH extends _I{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}}class ZH extends gI{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let KH=0;class JH extends ZH{constructor(e,t){super("StorageBuffer_"+KH++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Nl.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class QH extends Hf{constructor(e){super(),this.device=e;const t=` struct VarysStruct { @builtin( position ) Position: vec4, @location( 0 ) vTex : vec2 }; @vertex fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { var Varys : VarysStruct; var pos = array< vec2, 4 >( vec2( -1.0, 1.0 ), vec2( 1.0, 1.0 ), vec2( -1.0, -1.0 ), vec2( 1.0, -1.0 ) ); var tex = array< vec2, 4 >( vec2( 0.0, 0.0 ), vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ), vec2( 1.0, 1.0 ) ); Varys.vTex = tex[ vertexIndex ]; Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); return Varys; } `,n=` @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img : texture_2d; @fragment fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { return textureSample( img, imgSampler, vTex ); } `,s=` @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img : texture_2d; @fragment fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); } `;this.mipmapSampler=e.createSampler({minFilter:bm.Linear}),this.flipYSampler=e.createSampler({minFilter:bm.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:s})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:c0.TriangleStrip,stripIndexFormat:u0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:c0.TriangleStrip,stripIndexFormat:u0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const s=t.format,{width:o,height:a}=t.size,c=this.getTransferPipeline(s),u=this.getFlipYPipeline(s),d=this.device.createTexture({size:{width:o,height:a,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),p=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:nl.TwoD,baseArrayLayer:n}),m=d.createView({baseMipLevel:0,mipLevelCount:1,dimension:nl.TwoD,baseArrayLayer:0}),y=this.device.createCommandEncoder({}),M=(T,G,z)=>{const I=T.getBindGroupLayout(0),ee=this.device.createBindGroup({layout:I,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:G}]}),Q=y.beginRenderPass({colorAttachments:[{view:z,loadOp:mo.Clear,storeOp:sc.Store,clearValue:[0,0,0,0]}]});Q.setPipeline(T),Q.setBindGroup(0,ee),Q.draw(4,1,0,0),Q.end()};M(c,p,m),M(u,m,p),this.device.queue.submit([y.finish()]),d.destroy()}generateMipmaps(e,t,n=0){const s=this.get(e);s.useCount===void 0&&(s.useCount=0,s.layers=[]);const o=s.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,o),this.device.queue.submit([a.finish()]),s.useCount!==0&&(s.layers[n]=o),s.useCount++}_mipmapCreateBundles(e,t,n){const s=this.getTransferPipeline(t.format),o=s.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:nl.TwoD,baseArrayLayer:n});const c=[];for(let u=1;u0)for(let a=0,c=s.length;a0)for(let a=0,c=s.length;a0?e.width:n.size.width,p=c>0?e.height:n.size.height;u.queue.copyExternalImageToTexture({source:e,flipY:o},{texture:t,mipLevel:c,origin:{x:0,y:0,z:s},premultipliedAlpha:a},{width:d,height:p,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new QH(this.backend.device)),e}_generateMipmaps(e,t,n=0){this._getPassUtils().generateMipmaps(e,t,n)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,s,o,a=0,c=0){const u=this.backend.device,d=e.data,p=this._getBytesPerTexel(n.format),m=e.width*p;u.queue.writeTexture({texture:t,mipLevel:c,origin:{x:0,y:0,z:s}},d,{offset:e.width*e.height*p*a,bytesPerRow:m},{width:e.width,height:e.height,depthOrArrayLayers:1}),o===!0&&this._flipY(t,n,s)}_copyCompressedBufferToTexture(e,t,n){const s=this.backend.device,o=this._getBlockData(n.format),a=n.size.depthOrArrayLayers>1;for(let c=0;c]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,r9=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,UI={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},s9=r=>{r=r.trim();const e=r.match(i9);if(e!==null&&e.length===4){const t=e[2],n=[];let s=null;for(;(s=r9.exec(t))!==null;)n.push({name:s[1],type:s[2]});const o=[];for(let p=0;p "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class a9 extends aI{parseFunction(e){return new o9(e)}}const h0=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},l9={[Nl.READ_ONLY]:"read",[Nl.WRITE_ONLY]:"write",[Nl.READ_WRITE]:"read_write"},kI={[lt]:"repeat",[qe]:"clamp",[pt]:"mirror"},Ib={vertex:h0?h0.VERTEX:1,fragment:h0?h0.FRAGMENT:2,compute:h0?h0.COMPUTE:4},zI={instance:!0,swizzleAssign:!1,storageBuffer:!0},c9={"^^":"tsl_xor"},u9={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},VI={},Gv={tsl_xor:new $l("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new $l("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new $l("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new $l("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new $l("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new $l("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new $l("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new $l("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new $l("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new $l("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new $l("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new $l("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new $l(` fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `)},h9={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};let GI="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(GI+=`diagnostic( off, derivative_uniformity ); `);class d9 extends sI{constructor(e,t){super(e,t,new a9),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,s,o,a=this.shaderStage){return a==="fragment"?s?o?`textureSample( ${t}, ${t}_sampler, ${n}, ${s}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:o?`textureSample( ${t}, ${t}_sampler, ${n}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",s)}generateTextureSampleLevel(e,t,n,s,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,s):this.generateTextureLod(e,t,n,o,a,s)}generateWrapFunction(e){const t=`tsl_coord_${kI[e.wrapS]}S_${kI[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=VI[t];if(n===void 0){const s=[],o=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${o} ) -> ${o} { return ${o}( `;const c=(u,d)=>{u===lt?(s.push(Gv.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${d} )`):u===qe?(s.push(Gv.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${d} )`):u===pt?(s.push(Gv.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${d} )`):(a+=` coord.${d}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};c(e.wrapS,"x"),a+=`, `,c(e.wrapT,"y"),e.isData3DTexture&&(a+=`, `,c(e.wrapR,"z")),a+=` ); } `,VI[t]=n=new $l(a,s)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let o=s.dimensionsSnippet[n];if(s.dimensionsSnippet[n]===void 0){let a,c;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),d=u>1;e.isData3DTexture?c="vec3":c="vec2",d||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,o=new F_(new k_(`textureDimensions( ${a} )`,c)),s.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new F_(new k_(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new F_(new k_("6u","u32")))}return o.build(this)}generateFilteredTexture(e,t,n,s,o="0u"){this._include("biquadraticTexture");const a=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,o);return s&&(n=`${n} + vec2(${s}) / ${c}`),`tsl_biquadraticTexture( ${t}, ${a}( ${n} ), ${c}, u32( ${o} ) )`}generateTextureLod(e,t,n,s,o,a="0u"){const c=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,a),d=e.isData3DTexture?"vec3":"vec2";o&&(n=`${n} + ${d}(${o}) / ${d}( ${u} )`);const p=`${d}( ${c}( ${n} ) * ${d}( ${u} ) )`;return this.generateTextureLoad(e,t,p,s,null,a)}generateTextureLoad(e,t,n,s,o,a="0u"){let c;return o&&(n=`${n} + ${o}`),s?c=`textureLoad( ${t}, ${n}, ${s}, u32( ${a} ) )`:(c=`textureLoad( ${t}, ${n}, u32( ${a} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(c+=".x")),c}generateTextureStore(e,t,n,s,o){let a;return s?a=`textureStore( ${t}, ${n}, ${s}, ${o} )`:a=`textureStore( ${t}, ${n}, ${o} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===gs||this.isSampleCompare(e)===!1&&e.minFilter===Ct&&e.magFilter===Ct||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,s,o,a=this.shaderStage){let c=null;return this.isUnfilterable(e)?c=this.generateTextureLod(e,t,n,s,o,"0",a):c=this._generateTextureSample(e,t,n,s,o,a),c}generateTextureGrad(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s[0]}, ${s[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${c} shader.`)}generateTextureCompare(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${s} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${c} shader.`)}generateTextureLevel(e,t,n,s,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,s):this.generateTextureLod(e,t,n,o,a,s)}generateTextureBias(e,t,n,s,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${c} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,s=e.type;return s==="texture"||s==="cubeTexture"||s==="storageTexture"||s==="texture3D"?n:s==="buffer"||s==="storageBuffer"||s==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=c9[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(console.warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),Nl.READ_WRITE):Nl.READ_ONLY:e.access}getStorageAccess(e,t){return l9[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,s=null){const o=super.getUniformFromNode(e,t,n,s),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let c;const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let m=null;const y=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?m=new lT(o.name,o.node,u,y):m=new Cb(o.name,o.node,u,y):t==="cubeTexture"?m=new bI(o.name,o.node,u,y):t==="texture3D"&&(m=new lT(o.name,o.node,u,y)),m.store=e.isStorageTextureNode===!0,m.setVisibility(Ib[n]),this.isUnfilterable(e.value)===!1&&m.store===!1){const M=new YH(`${o.name}_sampler`,o.node,u);M.setVisibility(Ib[n]),p.push(M,m),c=[M,m]}else p.push(m),c=[m]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const m=t==="buffer"?vI:JH,y=new m(e,u);y.setVisibility(Ib[n]),p.push(y),c=y,o.name=s||"NodeBuffer_"+o.id}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new xI(d,u),y.setVisibility(Ib[n]),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}getBuiltin(e,t,n,s=this.shaderStage){const o=this.builtins[s]||(this.builtins[s]=new Map);return o.has(e)===!1&&o.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),s=[];for(const a of t.inputs)s.push(a.name+" : "+this.getType(a.type));let o=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} { ${n.vars} ${n.code} `;return n.result&&(o+=` return ${n.result}; `),o+=` } `,o}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const s of n)t.push(`enable ${s};`);return t.join(` `)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:s,property:o,type:a}of n.values())t.push(`@builtin( ${s} ) ${o} : ${a}`);return t.join(`, `)}getScopedArray(e,t,n,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:s,bufferType:o,bufferCount:a}of this.scopedArrays.values()){const c=this.getType(o);t.push(`var<${s}> ${n}: array< ${c}, ${a} >;`)}return t.join(` `)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const s=this.getAttributesArray();for(let o=0,a=s.length;o"),t.push(` ${s+n.name} : ${o}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, `)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const s=[];for(const o of n){let a=`struct ${o.name} { `;a+=this.getStructMembers(o),a+=` };`,s.push(a)}t=` `+s.join(` `)+` `}return t}getVar(e,t,n=null){let s=`var ${t} : `;return n!==null?s+=this.generateArrayDeclaration(e,n):s+=this.getType(e),s}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const s of n)t.push(` ${this.getVar(s.type,s.name,s.count)};`);return` ${t.join(` `)} `}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const o=this.varyings,a=this.vars[e];for(let c=0;cn.value.itemSize;return s&&!o}getUniforms(e){const t=this.uniforms[e],n=[],s=[],o=[],a={};for(const u of t){const d=u.groupNode.name,p=this.bindingsIndexes[d];if(u.type==="texture"||u.type==="cubeTexture"||u.type==="storageTexture"||u.type==="texture3D"){const m=u.node.value;this.isUnfilterable(m)===!1&&u.node.isStorageTextureNode!==!0&&(this.isSampleCompare(m)?n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler_comparison;`):n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler;`));let y,M="";const{primarySamples:T}=this.renderer.backend.utils.getTextureSampleData(m);if(T>1&&(M="_multisampled"),m.isCubeTexture===!0)y="texture_cube";else if(m.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&m.compareFunction===null?y=`texture${M}_2d`:y=`texture_depth${M}_2d${m.isArrayTexture===!0?"_array":""}`;else if(u.node.isStorageTextureNode===!0){const G=gT(m),z=this.getStorageAccess(u.node,e),I=u.node.value.is3DTexture,ee=u.node.value.isArrayTexture;y=`texture_storage_${I?"3d":`2d${ee?"_array":""}`}<${G}, ${z}>`}else if(m.isArrayTexture===!0||m.isDataArrayTexture===!0||m.isCompressedArrayTexture===!0)y="texture_2d_array";else if(m.is3DTexture===!0||m.isData3DTexture===!0)y="texture_3d";else{const G=this.getComponentTypeFromTexture(m).charAt(0);y=`texture${M}_2d<${G}32>`}n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name} : ${y};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const m=u.node,y=this.getType(m.getNodeType(this)),M=m.bufferCount,T=M>0&&u.type==="buffer"?", "+M:"",G=m.isStorageBufferNode?`storage, ${this.getStorageAccess(m,e)}`:"uniform";if(this.isCustomStruct(u))s.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var<${G}> ${u.name} : ${y};`);else{const I=` value : array< ${m.isAtomic?`atomic<${y}>`:`${y}`}${T} >`;s.push(this._getWGSLStructBinding(u.name,I,G,p.binding++,p.group))}}else{const m=this.getType(this.getVectorType(u.type)),y=u.groupNode.name;(a[y]||(a[y]={index:p.binding++,id:p.group,snippets:[]})).snippets.push(` ${u.name} : ${m}`)}}for(const u in a){const d=a[u];o.push(this._getWGSLStructBinding(u,d.snippets.join(`, `),"uniform",d.index,d.id))}let c=n.join(` `);return c+=s.join(` `),c+=o.join(` `),c}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let s=`// code `;s+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],c=a.outputNode,u=c!==void 0&&c.isOutputStructNode===!0;for(const d of o){const p=this.getFlowData(d),m=d.name;if(m&&(s.length>0&&(s+=` `),s+=` // flow -> ${m} `),s+=`${p.code} `,d===a&&t!=="compute"){if(s+=`// result `,t==="vertex")s+=`varyings.Vertex = ${p.result};`;else if(t==="fragment")if(u)n.returnType=c.getNodeType(this),n.structs+="var output : "+n.returnType+";",s+=`return ${p.result};`;else{let y=" @location(0) color: vec4";const M=this.getBuiltins("output");M&&(y+=`, `+M),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",y),n.structs+=` var output : OutputStruct;`,s+=`output.color = ${p.result}; return output;`}}}n.flow=s}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return u9[e]||e}isAvailable(e){let t=zI[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),zI[e]=t),t}_getWGSLMethod(e){return Gv[e]!==void 0&&this._include(e),h9[e]}_include(e){const t=Gv[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} // directives ${e.directives} // structs ${e.structs} // uniforms ${e.uniforms} // varyings ${e.varyings} var varyings : VaryingsStruct; // codes ${e.codes} @vertex fn main( ${e.attributes} ) -> VaryingsStruct { // vars ${e.vars} // flow ${e.flow} return varyings; } `}_getWGSLFragmentCode(e){return`${this.getSignature()} // global ${GI} // structs ${e.structs} // uniforms ${e.uniforms} // codes ${e.codes} @fragment fn main( ${e.varyings} ) -> ${e.returnType} { // vars ${e.vars} // flow ${e.flow} } `}_getWGSLComputeCode(e,t){const[n,s,o]=t;return`${this.getSignature()} // directives ${e.directives} // system var instanceIndex : u32; // locals ${e.scopedArrays} // structs ${e.structs} // uniforms ${e.uniforms} // codes ${e.codes} @compute @workgroup_size( ${n}, ${s}, ${o} ) fn main( ${e.attributes} ) { // system instanceIndex = globalId.x + globalId.y * ( ${n} * numWorkgroups.x ) + globalId.z * ( ${n} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y ); // vars ${e.vars} // flow ${e.flow} } `}_getWGSLStruct(e,t){return` struct ${e} { ${t} };`}_getWGSLStructBinding(e,t,n,s=0,o=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} @binding( ${s} ) @group( ${o} ) var<${n}> ${e} : ${a};`}}class f9{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=jt.Depth24PlusStencil8:e.depth&&(t=jt.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const o=this.backend.renderer,a=o.getRenderTarget();t=a?a.samples:o.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return c0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return c0.LineList;if(e.isLine)return c0.LineStrip;if(e.isMesh)return c0.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===Oi)return jt.BGRA8Unorm;if(e===Vs)return jt.RGBA16Float;throw new Error("Unsupported outputType")}}const WI=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array!="undefined"&&WI.set(Float16Array,["float16"]);const p9=new Map([[Vm,["float16"]]]),m9=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class g9{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),s=this.backend,o=s.get(n);let a=o.buffer;if(a===void 0){const c=s.device;let u=n.array;if(e.normalized===!1){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(let m=0;m1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=Mm.UnfilterableFloat)),a.texture.isDepthTexture)t.compatibilityMode&&a.texture.compareFunction===null?u.sampleType=Mm.UnfilterableFloat:u.sampleType=Mm.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const p=a.texture.type;p===Is?u.sampleType=Mm.SInt:p===as?u.sampleType=Mm.UInt:p===gs&&(this.backend.hasFeature("float32-filterable")?u.sampleType=Mm.Float:u.sampleType=Mm.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=nl.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=nl.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=nl.ThreeD),c.texture=u}else if(a.isSampler){const u={};a.texture.isDepthTexture&&(a.texture.compareFunction!==null?u.type=FI.Comparison:t.compatibilityMode&&(u.type=FI.NonFiltering)),c.sampler=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);s.push(c)}return n.createBindGroupLayout({entries:s})}createBindings(e,t,n,s=0){const{backend:o,bindGroupLayoutCache:a}=this,c=o.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let d;n>0&&(c.groups===void 0&&(c.groups=[],c.versions=[]),c.versions[n]===s&&(d=c.groups[n])),d===void 0&&(d=this.createBindGroup(e,u),n>0&&(c.groups[n]=d,c.versions[n]=s)),c.group=d,c.layout=u}updateBinding(e){const t=this.backend,n=t.device,s=e.buffer,o=t.get(e).buffer;n.queue.writeBuffer(o,0,s,0)}createBindGroupIndex(e,t){const s=this.backend.device,o=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],c=s.createBuffer({label:"bindingCameraIndex_"+a,size:16,usage:o});s.queue.writeBuffer(c,0,e,0);const u=[{binding:0,resource:{buffer:c}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+a,layout:t,entries:u})}createBindGroup(e,t){const n=this.backend,s=n.device;let o=0;const a=[];for(const c of e.bindings){if(c.isUniformBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.byteLength,p=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,m=s.createBuffer({label:"bindingBuffer_"+c.name,size:d,usage:p});u.buffer=m}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isStorageBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.attribute;u.buffer=n.get(d).buffer}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isSampledTexture){const u=n.get(c.texture);let d;if(u.externalTexture!==void 0)d=s.importExternalTexture({source:u.externalTexture});else{const p=c.store?1:u.texture.mipLevelCount;let m=`view-${u.texture.width}-${u.texture.height}`;if(u.texture.depthOrArrayLayers>1&&(m+=`-${u.texture.depthOrArrayLayers}`),m+=`-${p}`,d=u[m],d===void 0){const y=qH.All;let M;c.isSampledCubeTexture?M=nl.Cube:c.isSampledTexture3D?M=nl.ThreeD:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?M=nl.TwoDArray:M=nl.TwoD,d=u[m]=u.texture.createView({aspect:y,dimension:M,mipLevelCount:p})}}a.push({binding:o,resource:d})}else if(c.isSampler){const u=n.get(c.texture);a.push({binding:o,resource:u.sampler})}o++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class v9{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:s,geometry:o,pipeline:a}=e,{vertexProgram:c,fragmentProgram:u}=a,d=this.backend,p=d.device,m=d.utils,y=d.get(a),M=[];for(const tn of e.getBindings()){const cn=d.get(tn);M.push(cn.layout)}const T=d.attributeUtils.createShaderVertexBuffers(e);let G;s.blending!==ye&&(s.blending!==ge||s.transparent!==!1)&&(G=this._getBlending(s));let z={};s.stencilWrite===!0&&(z={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const I=this._getColorWriteMask(s),ee=[];if(e.context.textures!==null){const tn=e.context.textures;for(let cn=0;cn1},layout:p.createPipelineLayout({bindGroupLayouts:M})},Be={},ft=e.context.depth,zt=e.context.stencil;if((ft===!0||zt===!0)&&(ft===!0&&(Be.format=Oe,Be.depthWriteEnabled=s.depthWrite,Be.depthCompare=ve),zt===!0&&(Be.stencilFront=z,Be.stencilBack={},Be.stencilReadMask=s.stencilFuncMask,Be.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(Be.depthBias=s.polygonOffsetUnits,Be.depthBiasSlopeScale=s.polygonOffsetFactor,Be.depthBiasClamp=0),Ce.depthStencil=Be),t===null)y.pipeline=p.createRenderPipeline(Ce);else{const tn=new Promise(cn=>{p.createRenderPipelineAsync(Ce).then(vn=>{y.pipeline=vn,cn()})});t.push(tn)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:s,device:o}=n,a=s.getCurrentDepthStencilFormat(e),c=s.getCurrentColorFormat(e),u=this._getSampleCount(e),d={label:t,colorFormats:[c],depthStencilFormat:a,sampleCount:u};return o.createRenderBundleEncoder(d)}createComputePipeline(e,t){const n=this.backend,s=n.device,o=n.get(e.computeProgram).module,a=n.get(e),c=[];for(const u of t){const d=n.get(u);c.push(d.layout)}a.pipeline=s.createComputePipeline({compute:o,layout:s.createPipelineLayout({bindGroupLayouts:c})})}_getBlending(e){let t,n;const s=e.blending,o=e.blendSrc,a=e.blendDst,c=e.blendEquation;if(s===Ne){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:o,d=e.blendDstAlpha!==null?e.blendDstAlpha:a,p=e.blendEquationAlpha!==null?e.blendEquationAlpha:c;t={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(c)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(d),operation:this._getBlendOperation(p)}}else{const u=e.premultipliedAlpha,d=(p,m,y,M)=>{t={srcFactor:p,dstFactor:m,operation:wm.Add},n={srcFactor:y,dstFactor:M,operation:wm.Add}};if(u)switch(s){case ge:d(ks.One,ks.OneMinusSrcAlpha,ks.One,ks.OneMinusSrcAlpha);break;case ce:d(ks.One,ks.One,ks.One,ks.One);break;case xe:d(ks.Zero,ks.OneMinusSrc,ks.Zero,ks.One);break;case fe:d(ks.Dst,ks.OneMinusSrcAlpha,ks.Zero,ks.One);break}else switch(s){case ge:d(ks.SrcAlpha,ks.OneMinusSrcAlpha,ks.One,ks.OneMinusSrcAlpha);break;case ce:d(ks.SrcAlpha,ks.One,ks.One,ks.One);break;case xe:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fe:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case je:t=ks.Zero;break;case _t:t=ks.One;break;case It:t=ks.Src;break;case kt:t=ks.OneMinusSrc;break;case Ut:t=ks.SrcAlpha;break;case At:t=ks.OneMinusSrcAlpha;break;case ue:t=ks.Dst;break;case Ue:t=ks.OneMinusDst;break;case at:t=ks.DstAlpha;break;case Ot:t=ks.OneMinusDstAlpha;break;case vt:t=ks.SrcAlphaSaturated;break;case y5:t=ks.Constant;break;case v5:t=ks.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case e1:t=Ll.Never;break;case Xh:t=Ll.Always;break;case t1:t=Ll.Less;break;case nx:t=Ll.LessEqual;break;case n1:t=Ll.Equal;break;case ix:t=Ll.GreaterEqual;break;case i1:t=Ll.Greater;break;case r1:t=Ll.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Yl:t=qf.Keep;break;case Jb:t=qf.Zero;break;case Im:t=qf.Replace;break;case Qb:t=qf.Invert;break;case Xd:t=qf.IncrementClamp;break;case ex:t=qf.DecrementClamp;break;case tx:t=qf.IncrementWrap;break;case x0:t=qf.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Ae:t=wm.Add;break;case be:t=wm.Subtract;break;case Ye:t=wm.ReverseSubtract;break;case Ee:t=wm.Min;break;case We:t=wm.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const s={},o=this.backend.utils;s.topology=o.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?u0.Uint16:u0.Uint32);let a=n.side===K;return e.isMesh&&e.matrixWorld.determinant()<0&&(a=!a),s.frontFace=a===!0?LI.CW:LI.CCW,s.cullMode=n.side===re?DI.None:DI.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?OI.All:OI.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Ll.Always;else{const n=e.depthFunc;switch(n){case ze:t=Ll.Never;break;case Ze:t=Ll.Always;break;case q:t=Ll.Less;break;case Y:t=Ll.LessEqual;break;case de:t=Ll.Equal;break;case Je:t=Ll.GreaterEqual;break;case Te:t=Ll.Greater;break;case $e:t=Ll.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class x9 extends PI{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ol(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}resolveQueriesAsync(){return hr(this,null,function*(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return yield this.pendingResolve}finally{this.pendingResolve=null}})}_resolveQueries(){return hr(this,null,function*(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const o=s.finish();if(this.device.queue.submit([o]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(yield this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n));let c=0;for(const[,u]of e){const d=a[u],p=a[u+1],m=Number(p-d)/1e6;c+=m}return this.resultBuffer.unmap(),this.lastValue=c,c}catch(e){return console.error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}})}dispose(){return hr(this,null,function*(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{yield this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){console.error("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}})}}class yT extends AI{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new f9(this),this.attributeUtils=new g9(this),this.bindingUtils=new y9(this),this.pipelineUtils=new v9(this),this.textureUtils=new n9(this),this.occludedResolveCache=new Map}init(e){return hr(this,null,function*(){yield m3(yT.prototype,this,"init").call(this,e);const t=this.parameters;let n;if(t.device===void 0){const c={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},u=typeof navigator!="undefined"?yield navigator.gpu.requestAdapter(c):null;if(u===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const d=Object.values(mT),p=[];for(const y of d)u.features.has(y)&&p.push(y);const m={requiredFeatures:p,requiredLimits:t.requiredLimits};n=yield u.requestDevice(m)}else n=t.device;n.lost.then(c=>{const u={api:"WebGPU",message:c.message||"Unknown reason",reason:c.reason||null,originalEvent:c};e.onDeviceLost(u)});const s=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=s;const o=t.alpha?"premultiplied":"opaque",a=Ki.getToneMappingMode(this.renderer.outputColorSpace);this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:o,toneMapping:{mode:a}}),this.trackTimestamp=this.trackTimestamp&&this.hasFeature(mT.TimestampQuery),this.updateSize()})}get coordinateSystem(){return ja}getArrayBufferAsync(e){return hr(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const s=e.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,s=this.get(n);let o=s.descriptors;(o===void 0||s.width!==n.width||s.height!==n.height||s.samples!==n.samples)&&(o={},s.descriptors=o);const a=e.getCacheKey();let c=o[a];if(c===void 0){const d=e.textures,p=[];let m;const y=this._isRenderCameraDepthArray(e);for(let M=0;M1)if(y===!0){const z=e.camera.cameras;for(let I=0;I0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,o=n.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=o,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:mo.Load}),this.initTimestampQuery(lh.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=o;const c=a.depthStencilAttachment;if(e.textures!==null){const d=a.colorAttachments;for(let p=0;p0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const o=[];for(let a=0;a0){const o=n*8;let a=this.occludedResolveCache.get(o);a===void 0&&(a=this.device.createBuffer({size:o,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(o,a));const c=this.device.createBuffer({size:o,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,a,0),t.encoder.copyBufferToBuffer(a,0,c,0,o),t.occlusionQueryBuffer=c,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const o=e.textures;for(let a=0;aT&&(d[0]=Math.min(M,T),d[1]=Math.ceil(M/T)),a.dispatchSize=d}d=a.dispatchSize}else d=o;c.dispatchWorkgroups(d[0],d[1]||1,d[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}waitForGPU(){return hr(this,null,function*(){yield this.device.queue.onSubmittedWorkDone()})}draw(e,t){const{object:n,material:s,context:o,pipeline:a}=e,c=e.getBindings(),u=this.get(o),d=this.get(a).pipeline,p=e.getIndex(),m=p!==null,y=e.getDrawParameters();if(y===null)return;const M=(G,z)=>{this.pipelineUtils.setPipeline(G,d),z.pipeline=d;const I=z.bindingGroups;for(let Q=0,oe=c.length;Q{if(M(G,z),n.isBatchedMesh===!0){const I=n._multiDrawStarts,ee=n._multiDrawCounts,Q=n._multiDrawCount,oe=n._multiDrawInstances;oe!==null&&ol("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let _e=0;_e1?0:_e;m===!0?G.drawIndexed(ee[_e],ve,I[_e]/p.array.BYTES_PER_ELEMENT,0,Oe):G.draw(ee[_e],ve,I[_e],Oe),t.update(n,ee[_e],ve)}}else if(m===!0){const{vertexCount:I,instanceCount:ee,firstVertex:Q}=y,oe=e.getIndirect();if(oe!==null){const _e=this.get(oe).buffer;G.drawIndexedIndirect(_e,0)}else G.drawIndexed(I,ee,Q,0,0);t.update(n,I,ee)}else{const{vertexCount:I,instanceCount:ee,firstVertex:Q}=y,oe=e.getIndirect();if(oe!==null){const _e=this.get(oe).buffer;G.drawIndirect(_e,0)}else G.draw(I,ee,Q,0);t.update(n,I,ee)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const G=this.get(e.camera),z=e.camera.cameras,I=e.getBindingGroup("cameraIndex");if(G.indexesGPU===void 0||G.indexesGPU.length!==z.length){const Q=this.get(I),oe=[],_e=new Uint32Array([0,0,0,0]);for(let ve=0,Oe=z.length;ve(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new II(e)));const n=new t(e);super(n,e),this.library=new w9,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class hZ extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class dZ{constructor(e,t=Bi(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const n=new ya;n.name="PostProcessing",this._quadMesh=new Cv(n),this._context=null}render(){const e=this.renderer;this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this.needsUpdate===!0){const e=this.renderer,t=e.toneMapping,n=e.outputColorSpace,s={postProcessing:this,onBeforePostProcessing:null,onAfterPostProcessing:null};let o=this.outputNode;this.outputColorTransform===!0?(o=o.context(s),o=EM(o,t,n)):(s.toneMapping=t,s.outputColorSpace=n,o=o.context(s)),this._context=s,this._quadMesh.material.fragmentNode=o,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}renderAsync(){return hr(this,null,function*(){this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const e=this.renderer,t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,yield this._quadMesh.renderAsync(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()})}}class fZ extends null{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}}class pZ extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.wrapR=ClampToEdgeWrapping,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class mZ extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class gZ extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class S9 extends null{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,s){const o=new FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(c){s?s(c):console.error(c),this.manager.itemError(e)}},n,s)}parseNodes(e){const t={};if(e!==void 0){for(const s of e){const{uuid:o,type:a}=s;t[o]=this.createNodeFromType(a),t[o].uuid=o}const n={nodes:t,textures:this.textures};for(const s of e)s.meta=n,t[s.uuid].deserialize(s),delete s.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const s={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=s,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),ut()):Cn(new this.nodes[e])}}class T9 extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),n=this.nodes,s=e.inputNodes;for(const o in s){const a=s[o];t[o]=n[a]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class yZ extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){const n=new S9;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){const n={};if(e!==void 0){const s=this.parseNodes(this._nodesJSON,t),o=new T9;o.setTextures(t),o.setNodes(s),o.setNodeMaterials(this.nodeMaterials);for(let a=0,c=e.length;aHI&&(this.dispatchEvent(vT),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>HI||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(vT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=go.NONE,this.keyState=go.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(vT),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Yf.copy(this._panEnd).sub(this._panStart),Yf.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Yf.x*=e,Yf.y*=t}Yf.multiplyScalar(this._eye.length()*this.panSpeed),Db.copy(this._eye).cross(this.object.up).setLength(Yf.x),Db.add(E9.copy(this.object.up).setLength(Yf.y)),this.object.position.add(Db),this.target.add(Db),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Yf.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Fb.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Fb.length();e?(this._eye.copy(this.object.position).sub(this.target),$I.copy(this._eye).normalize(),Ob.copy(this.object.up).normalize(),wT.crossVectors(Ob,$I).normalize(),Ob.setLength(this._moveCurr.y-this._movePrev.y),wT.setLength(this._moveCurr.x-this._movePrev.x),Fb.copy(Ob.add(wT)),bT.crossVectors(Fb,this._eye).normalize(),e*=this.rotateSpeed,d0.setFromAxisAngle(bT,e),this._eye.applyQuaternion(d0),this.object.up.applyQuaternion(d0),this._lastAxis.copy(bT),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),d0.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(d0),this.object.up.applyQuaternion(d0)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===go.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Yh.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Yh.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Lb.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Lb}_getMouseOnCircle(e,t){return Lb.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Lb}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=Cc),s<-Math.PI?s+=Cc:s>Math.PI&&(s-=Cc),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(gl.setFromSpherical(this._spherical),gl.applyQuaternion(this._quatInverse),t.copy(this.target).add(gl),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const c=gl.length();a=this._clampDistance(c*this._scale);const u=c-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),o=!!u}else if(this.object.isOrthographicCamera){const c=new ot(this._mouse.x,this._mouse.y,0);c.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=u!==this.object.zoom;const d=new ot(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(c),this.object.updateMatrixWorld(),a=gl.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Bb.origin.copy(this.object.position),Bb.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Bb.direction))ST||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ST||this._lastTargetPosition.distanceToSquared(this.target)>ST?(this.dispatchEvent(jI),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Cc/60*this.autoRotateSpeed*e:Cc/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){gl.setFromMatrixColumn(t,0),gl.multiplyScalar(-e),this._panOffset.add(gl)}_panUp(e,t){this.screenSpacePanning===!0?gl.setFromMatrixColumn(t,1):(gl.setFromMatrixColumn(t,0),gl.crossVectors(this.object.up,gl)),gl.multiplyScalar(e),this._panOffset.add(gl)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;gl.copy(s).sub(this.target);let o=gl.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,o=t-n.top,a=n.width,c=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(o/c)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Cc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cc*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Cc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Cc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Cc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Cc*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(s,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Cc*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cc*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,c=(e.pageY+t.y)*.5;this._updateZoomParameters(a,c)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tYI||8*(1-this._lastQuaternion.dot(t.quaternion))>YI)&&(this.dispatchEvent(n7),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function r7(r){if(!(r.altKey||this.enabled===!1)){switch(r.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function s7(r){if(this.enabled!==!1){switch(r.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function o7(r){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(r.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function a7(r){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(r.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(r.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function l7(r){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(r.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function c7(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function u7(r){this.enabled!==!1&&r.preventDefault()}const h7={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }`};class Ub{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const d7=new Cf(-1,1,1,-1,0,1);class f7 extends xr{constructor(){super(),this.setAttribute("position",new Zi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Zi([0,2,0,0,2,0],2))}}const p7=new f7;class m7{constructor(e){this._mesh=new Zs(p7,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,d7)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class g7 extends Ub{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Bc?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=ap.clone(e.uniforms),this.material=new Bc({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new m7(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class KI extends Ub{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const s=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let a,c;this.inverse?(a=0,c=1):(a=1,c=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),o.buffers.stencil.setClear(c),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(s.EQUAL,1,4294967295),o.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.buffers.stencil.setLocked(!0)}}class y7 extends Ub{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class v7{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new yn);this._width=n.width,this._height=n.height,t=new cc(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Vs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new g7(h7),this.copyPass.material.blending=ye,this.clock=new Vx}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t0)break}while(nL(s,o));c=T.notation==="postfix",T.symbol!==")"&&(s.push(T),c&&nL(s,o))}else if(m){if(s.push(m.prefix||m.func),m.func&&(n=a.exec(r),!n||n[0]!=="("))throw new Hr(38,n?n.index:r.length,r)}else o.push(+d),c=!0}while(n&&s.length);if(s.length)throw new Hr(39,n?n.index:r.length,r);if(n)throw new Hr(40,n?n.index:r.length,r);return o.pop()}function AT(r){return r.split("").reverse().join("")}function wZ(r,e){var t=AT(r),n=t.match(tL);if(n&&!n.every(function(o){return o===n[0]}))throw new Hr(41);var s=AT(t.replace(tL,""));return""+L7(s,e)+(n?AT(n[0]):"")}var D7=/--[\S]*/g;function MZ(r,e){if(!r||!r.match(D7))throw new Hr(73);var t;if(typeof document!="undefined"&&document.documentElement!==null&&(t=getComputedStyle(document.documentElement).getPropertyValue(r)),t)return t.trim();if(e)return e;throw new Hr(74)}function Hv(r){return r.charAt(0).toUpperCase()+r.slice(1)}var O7=null;function F7(r,e){if(!r)return e.toLowerCase();var t=r.split("-");if(t.length>1)return t.splice(1,0,e),t.reduce(function(s,o){return""+s+Hv(o)});var n=r.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return r===n?""+r+e:n}function B7(r,e){for(var t={},n=0;n1?e-1:0),n=1;n=0)?t[n]=r[n]+" !important":t[n]=r[n]}),t}var oL={minorSecond:1.067,majorSecond:1.125,minorThird:1.2,majorThird:1.25,perfectFourth:1.333,augFourth:1.414,perfectFifth:1.5,minorSixth:1.6,goldenSection:1.618,majorSixth:1.667,minorSeventh:1.778,majorSeventh:1.875,octave:2,majorTenth:2.5,majorEleventh:2.667,majorTwelfth:3,doubleOctave:4};function G7(r){return oL[r]}function EZ(r,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof r!="number")throw new Hr(42);if(typeof t=="string"&&!oL[t])throw new Hr(43);var n=typeof e=="string"?Gd(e):[e,""],s=n[0],o=n[1],a=typeof t=="string"?G7(t):t;if(typeof s=="string")throw new Hr(44,e);return""+s*Math.pow(a,r)+(o||"")}var AZ=sL("rem"),CZ=null,CT=16;function aL(r){var e=Gd(r);if(e[1]==="px")return parseFloat(r);if(e[1]==="%")return parseFloat(r)/100*CT;throw new Hr(78,e[1])}function W7(){if(typeof document!="undefined"&&document.documentElement!==null){var r=getComputedStyle(document.documentElement).fontSize;return r?aL(r):CT}return CT}function RZ(r,e){var t=Gd(r);if(t[1]!=="rem"&&t[1]!=="")throw new Hr(77,t[1]);var n=e?aL(e):W7();return t[0]*n+"px"}var H7={back:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",circ:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",cubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",expo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",quad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",quart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",quint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",sine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)"};function NZ(r){return H7[r.toLowerCase().trim()]}var $7={back:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",circ:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",cubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",expo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",quad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",quart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",quint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",sine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function PZ(r){return $7[r.toLowerCase().trim()]}var j7={back:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",cubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",circ:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",expo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",quad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",quart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",quint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",sine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)"};function IZ(r){return j7[r.toLowerCase().trim()]}function lL(r,e,t,n){t===void 0&&(t="320px"),n===void 0&&(n="1200px");var s=Gd(r),o=s[0],a=s[1],c=Gd(e),u=c[0],d=c[1],p=Gd(t),m=p[0],y=p[1],M=Gd(n),T=M[0],G=M[1];if(typeof m!="number"||typeof T!="number"||!y||!G||y!==G)throw new Hr(47);if(typeof o!="number"||typeof u!="number"||a!==d)throw new Hr(48);if(a!==y||d!==G)throw new Hr(76);var z=(o-u)/(m-T),I=u-z*T;return"calc("+I.toFixed(2)+(a||"")+" + "+(100*z).toFixed(2)+"vw)"}function LZ(r){var e;r===void 0&&(r="&");var t=r+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function DZ(r){return r===void 0&&(r=0),{position:"absolute",top:r,right:r,bottom:r,left:r}}function OZ(r,e){e===void 0&&(e=1);var t={display:"inline-block",maxWidth:r||"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",wordWrap:"normal"};return e>1?_extends({},t,{WebkitBoxOrient:"vertical",WebkitLineClamp:e,display:"-webkit-box",whiteSpace:"normal"}):t}function X7(r,e){var t=typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=q7(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function q7(r,e){if(r){if(typeof r=="string")return cL(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cL(r,e)}}function cL(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t1?t-1:0),s=1;s1?(e=e.slice(0,-1),e+=", "+n[o]):a.length===1&&(e+=""+n[o])}else n[o]&&(e+=n[o]+" ");return e.trim()}var dL;function zZ(r){var e=r.colorStops,t=r.fallback,n=r.toDirection,s=n===void 0?"":n;if(!e||e.length<2)throw new Hr(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:hL(dL||(dL=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),s,e.join(", ").replace(/,(?=\S)/g,", "))}}function VZ(){var r;return[(r={html:{lineHeight:"1.15",textSizeAdjust:"100%"},body:{margin:"0"},main:{display:"block"},h1:{fontSize:"2em",margin:"0.67em 0"},hr:{boxSizing:"content-box",height:"0",overflow:"visible"},pre:{fontFamily:"monospace, monospace",fontSize:"1em"},a:{backgroundColor:"transparent"},"abbr[title]":{borderBottom:"none",textDecoration:"underline"}},r[`b, strong`]={fontWeight:"bolder"},r[`code, kbd, samp`]={fontFamily:"monospace, monospace",fontSize:"1em"},r.small={fontSize:"80%"},r[`sub, sup`]={fontSize:"75%",lineHeight:"0",position:"relative",verticalAlign:"baseline"},r.sub={bottom:"-0.25em"},r.sup={top:"-0.5em"},r.img={borderStyle:"none"},r[`button, input, optgroup, select, textarea`]={fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15",margin:"0"},r[`button, input`]={overflow:"visible"},r[`button, select`]={textTransform:"none"},r[`button, html [type="button"], [type="reset"], [type="submit"]`]={WebkitAppearance:"button"},r[`button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner`]={borderStyle:"none",padding:"0"},r[`button:-moz-focusring, [type="button"]:-moz-focusring, [type="reset"]:-moz-focusring, [type="submit"]:-moz-focusring`]={outline:"1px dotted ButtonText"},r.fieldset={padding:"0.35em 0.625em 0.75em"},r.legend={boxSizing:"border-box",color:"inherit",display:"table",maxWidth:"100%",padding:"0",whiteSpace:"normal"},r.progress={verticalAlign:"baseline"},r.textarea={overflow:"auto"},r[`[type="checkbox"], [type="radio"]`]={boxSizing:"border-box",padding:"0"},r[`[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button`]={height:"auto"},r['[type="search"]']={WebkitAppearance:"textfield",outlineOffset:"-2px"},r['[type="search"]::-webkit-search-decoration']={WebkitAppearance:"none"},r["::-webkit-file-upload-button"]={WebkitAppearance:"button",font:"inherit"},r.details={display:"block"},r.summary={display:"list-item"},r.template={display:"none"},r["[hidden]"]={display:"none"},r),{"abbr[title]":{textDecoration:"underline dotted"}}]}var fL;function GZ(r){var e=r.colorStops,t=r.extent,n=t===void 0?"":t,s=r.fallback,o=r.position,a=o===void 0?"":o,c=r.shape,u=c===void 0?"":c;if(!e||e.length<2)throw new Hr(57);return{backgroundColor:s||e[0].split(" ")[0],backgroundImage:hL(fL||(fL=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),a,u,n,e.join(", "))}}function WZ(r,e,t,n,s){var o;if(t===void 0&&(t="png"),s===void 0&&(s="_2x"),!r)throw new Hr(58);var a=t.replace(/^\./,""),c=n?n+"."+a:""+r+s+"."+a;return o={backgroundImage:"url("+r+"."+a+")"},o[t$()]=_extends({backgroundImage:"url("+c+")"},e?{backgroundSize:e}:{}),o}var n$={easeInBack:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",easeInCirc:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",easeInCubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",easeInExpo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",easeInQuad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",easeInQuart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",easeInQuint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",easeInSine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)",easeOutBack:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",easeOutCubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",easeOutCirc:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",easeOutExpo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",easeOutQuad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",easeOutQuart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",easeOutQuint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",easeOutSine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)",easeInOutBack:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",easeInOutExpo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",easeInOutQuad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",easeInOutQuart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",easeInOutQuint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",easeInOutSine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function i$(r){return n$[r]}function HZ(r){return i$(r)}var r$=function(e,t,n){var s=""+n[0]+(n[1]||""),o=""+n[0]/2+(n[1]||""),a=""+t[0]+(t[1]||""),c=""+t[0]/2+(t[1]||"");switch(e){case"top":return"0 "+o+" "+a+" "+o;case"topLeft":return s+" "+a+" 0 0";case"left":return c+" "+s+" "+c+" 0";case"bottomLeft":return s+" 0 0 "+a;case"bottom":return a+" "+o+" 0 "+o;case"bottomRight":return"0 0 "+s+" "+a;case"right":return c+" 0 "+c+" "+s;case"topRight":default:return"0 "+s+" "+a+" 0"}},s$=function(e,t){switch(e){case"top":case"bottomRight":return{borderBottomColor:t};case"right":case"bottomLeft":return{borderLeftColor:t};case"bottom":case"topLeft":return{borderTopColor:t};case"left":case"topRight":return{borderRightColor:t};default:throw new Hr(59)}};function $Z(r){var e=r.pointingDirection,t=r.height,n=r.width,s=r.foregroundColor,o=r.backgroundColor,a=o===void 0?"transparent":o,c=Gd(n),u=Gd(t);if(isNaN(u[0])||isNaN(c[0]))throw new Hr(60);return _extends({width:"0",height:"0",borderColor:a},s$(e,s),{borderStyle:"solid",borderWidth:r$(e,u,c)})}function jZ(r){r===void 0&&(r="break-word");var e=r==="break-word"?"break-all":r;return{overflowWrap:r,wordWrap:r,wordBreak:e}}function RT(r){return Math.round(r*255)}function o$(r,e,t){return RT(r)+","+RT(e)+","+RT(t)}function $v(r,e,t,n){if(n===void 0&&(n=o$),e===0)return n(t,t,t);var s=(r%360+360)%360/60,o=(1-Math.abs(2*t-1))*e,a=o*(1-Math.abs(s%2-1)),c=0,u=0,d=0;s>=0&&s<1?(c=o,u=a):s>=1&&s<2?(c=a,u=o):s>=2&&s<3?(u=o,d=a):s>=3&&s<4?(u=a,d=o):s>=4&&s<5?(c=a,d=o):s>=5&&s<6&&(c=o,d=a);var p=t-o/2,m=c+p,y=u+p,M=d+p;return n(m,y,M)}var pL={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function a$(r){if(typeof r!="string")return r;var e=r.toLowerCase();return pL[e]?"#"+pL[e]:r}var l$=/^#[a-fA-F0-9]{6}$/,c$=/^#[a-fA-F0-9]{8}$/,u$=/^#[a-fA-F0-9]{3}$/,h$=/^#[a-fA-F0-9]{4}$/,NT=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,d$=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,f$=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,p$=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Wd(r){if(typeof r!="string")throw new Hr(3);var e=a$(r);if(e.match(l$))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(c$)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(u$))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(h$)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var s=NT.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var o=d$.exec(e.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=f$.exec(e);if(a){var c=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,d=parseInt(""+a[3],10)/100,p="rgb("+$v(c,u,d)+")",m=NT.exec(p);if(!m)throw new Hr(4,e,p);return{red:parseInt(""+m[1],10),green:parseInt(""+m[2],10),blue:parseInt(""+m[3],10)}}var y=p$.exec(e.substring(0,50));if(y){var M=parseInt(""+y[1],10),T=parseInt(""+y[2],10)/100,G=parseInt(""+y[3],10)/100,z="rgb("+$v(M,T,G)+")",I=NT.exec(z);if(!I)throw new Hr(4,e,z);return{red:parseInt(""+I[1],10),green:parseInt(""+I[2],10),blue:parseInt(""+I[3],10),alpha:parseFloat(""+y[4])>1?parseFloat(""+y[4])/100:parseFloat(""+y[4])}}throw new Hr(5)}function m$(r){var e=r.red/255,t=r.green/255,n=r.blue/255,s=Math.max(e,t,n),o=Math.min(e,t,n),a=(s+o)/2;if(s===o)return r.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:r.alpha}:{hue:0,saturation:0,lightness:a};var c,u=s-o,d=a>.5?u/(2-s-o):u/(s+o);switch(s){case e:c=(t-n)/u+(t=1?kb(r,e,t):"rgba("+$v(r,e,t)+","+n+")";if(typeof r=="object"&&e===void 0&&t===void 0&&n===void 0)return r.alpha>=1?kb(r.hue,r.saturation,r.lightness):"rgba("+$v(r.hue,r.saturation,r.lightness)+","+r.alpha+")";throw new Hr(2)}function zb(r,e,t){if(typeof r=="number"&&typeof e=="number"&&typeof t=="number")return PT("#"+Tm(r)+Tm(e)+Tm(t));if(typeof r=="object"&&e===void 0&&t===void 0)return PT("#"+Tm(r.red)+Tm(r.green)+Tm(r.blue));throw new Hr(6)}function jv(r,e,t,n){if(typeof r=="string"&&typeof e=="number"){var s=Wd(r);return"rgba("+s.red+","+s.green+","+s.blue+","+e+")"}else{if(typeof r=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?zb(r,e,t):"rgba("+r+","+e+","+t+","+n+")";if(typeof r=="object"&&e===void 0&&t===void 0&&n===void 0)return r.alpha>=1?zb(r.red,r.green,r.blue):"rgba("+r.red+","+r.green+","+r.blue+","+r.alpha+")"}throw new Hr(7)}var v$=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},x$=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},_$=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},b$=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function sh(r){if(typeof r!="object")throw new Hr(8);if(x$(r))return jv(r);if(v$(r))return zb(r);if(b$(r))return gL(r);if(_$(r))return mL(r);throw new Hr(8)}function yL(r,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?r.apply(this,s):yL(r,e,s)}}function Jc(r){return yL(r,r.length,[])}function w$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{hue:t.hue+parseFloat(r)}))}var XZ=Jc(w$),qZ=null;function YZ(r){if(r==="transparent")return r;var e=Wh(r);return sh(_extends({},e,{hue:(e.hue+180)%360}))}function f0(r,e,t){return Math.max(r,Math.min(e,t))}function M$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{lightness:f0(0,1,t.lightness-parseFloat(r))}))}var ZZ=Jc(M$),KZ=null;function S$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{saturation:f0(0,1,t.saturation-parseFloat(r))}))}var JZ=Jc(S$),QZ=null;function LT(r){if(r==="transparent")return 0;var e=Wd(r),t=Object.keys(e).map(function(a){var c=e[a]/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)}),n=t[0],s=t[1],o=t[2];return parseFloat((.2126*n+.7152*s+.0722*o).toFixed(3))}function vL(r,e){var t=LT(r),n=LT(e);return parseFloat((t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)).toFixed(2))}function eK(r){return r==="transparent"?r:sh(_extends({},Wh(r),{saturation:0}))}function tK(r){if(typeof r=="object"&&typeof r.hue=="number"&&typeof r.saturation=="number"&&typeof r.lightness=="number")return r.alpha&&typeof r.alpha=="number"?gL({hue:r.hue,saturation:r.saturation,lightness:r.lightness,alpha:r.alpha}):mL({hue:r.hue,saturation:r.saturation,lightness:r.lightness});throw new Hr(45)}function nK(r){if(r==="transparent")return r;var e=Wd(r);return sh(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function T$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{lightness:f0(0,1,t.lightness+parseFloat(r))}))}var iK=Jc(T$),rK=null;function sK(r,e){var t=vL(r,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function E$(r,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(r===0)return t;var n=Wd(e),s=Rc({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),o=Wd(t),a=Rc({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),c=s.alpha-a.alpha,u=parseFloat(r)*2-1,d=u*c===-1?u:u+c,p=1+u*c,m=(d/p+1)/2,y=1-m,M={red:Math.floor(s.red*m+a.red*y),green:Math.floor(s.green*m+a.green*y),blue:Math.floor(s.blue*m+a.blue*y),alpha:s.alpha*parseFloat(r)+a.alpha*(1-parseFloat(r))};return jv(M)}var A$=Jc(E$),xL=A$;function C$(r,e){if(e==="transparent")return e;var t=Wd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Rc({},t,{alpha:f0(0,1,(n*100+parseFloat(r)*100)/100)});return jv(s)}var R$=Jc(C$),N$=R$,_L="#000",bL="#fff";function oK(r,e,t,n){e===void 0&&(e=_L),t===void 0&&(t=bL),n===void 0&&(n=!0);var s=LT(r)>.179,o=s?e:t;return!n||vL(r,o)>=4.5?o:s?_L:bL}function aK(r){if(typeof r=="object"&&typeof r.red=="number"&&typeof r.green=="number"&&typeof r.blue=="number")return typeof r.alpha=="number"?jv({red:r.red,green:r.green,blue:r.blue,alpha:r.alpha}):zb({red:r.red,green:r.green,blue:r.blue});throw new Hr(46)}function P$(r,e){if(e==="transparent")return e;var t=Wh(e);return sh(Rc({},t,{saturation:f0(0,1,t.saturation+parseFloat(r))}))}var lK=Jc(P$),cK=null;function I$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{hue:parseFloat(r)}))}var uK=Jc(I$),hK=null;function L$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{lightness:parseFloat(r)}))}var dK=Jc(L$),fK=null;function D$(r,e){return e==="transparent"?e:sh(Rc({},Wh(e),{saturation:parseFloat(r)}))}var pK=Jc(D$),mK=null;function O$(r,e){return e==="transparent"?e:xL(parseFloat(r),"rgb(0, 0, 0)",e)}var gK=Jc(O$),yK=null;function F$(r,e){return e==="transparent"?e:xL(parseFloat(r),"rgb(255, 255, 255)",e)}var vK=Jc(F$),xK=null;function B$(r,e){if(e==="transparent")return e;var t=Wd(e),n=typeof t.alpha=="number"?t.alpha:1,s=Rc({},t,{alpha:f0(0,1,+(n*100-parseFloat(r)*100).toFixed(2)/100)});return jv(s)}var _K=Jc(B$),bK=null;function wK(){for(var r=arguments.length,e=new Array(r),t=0;t8)throw new Hr(64);var s=e.map(function(o){if(n&&!Array.isArray(o)||!n&&Array.isArray(o))throw new Hr(65);if(Array.isArray(o)&&o.length>8)throw new Hr(66);return Array.isArray(o)?o.join(" "):o}).join(", ");return{animation:s}}function MK(){for(var r=arguments.length,e=new Array(r),t=0;t1?e-1:0),n=1;n=0){var s;return s={},s["border"+Hv(r)+"Width"]=t[0],s["border"+Hv(r)+"Style"]=t[1],s["border"+Hv(r)+"Color"]=t[2],s}else return t.unshift(r),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function EK(){for(var r=arguments.length,e=new Array(r),t=0;t1?e-1:0),n=1;n=0&&r?_extends({},Sm.apply(void 0,[""].concat(t)),{position:r}):Sm.apply(void 0,["",r].concat(t))}function DK(r,e){return e===void 0&&(e=r),{height:r,width:e}}var G$=null;function W$(r){return'input[type="color"]'+r+`, input[type="date"]`+r+`, input[type="datetime"]`+r+`, input[type="datetime-local"]`+r+`, input[type="email"]`+r+`, input[type="month"]`+r+`, input[type="number"]`+r+`, input[type="password"]`+r+`, input[type="search"]`+r+`, input[type="tel"]`+r+`, input[type="text"]`+r+`, input[type="time"]`+r+`, input[type="url"]`+r+`, input[type="week"]`+r+`, input:not([type])`+r+`, textarea`+r}function OK(){for(var r=arguments.length,e=new Array(r),t=0;t1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),p0=function(){return performance.now()},DT=function(){function r(){for(var e=[],t=0;t0;){this._tweensAddedDuringUpdate={};for(var s=0;s1?o(r[t],r[t-1],t-n):o(r[s],r[s+1>t?t:s+1],n-s)},Bezier:function(r,e){for(var t=0,n=r.length-1,s=Math.pow,o=Em.Utils.Bernstein,a=0;a<=n;a++)t+=s(1-e,n-a)*s(e,a)*r[a]*o(n,a);return t},CatmullRom:function(r,e){var t=r.length-1,n=t*e,s=Math.floor(n),o=Em.Utils.CatmullRom;return r[0]===r[t]?(e<0&&(s=Math.floor(n=t*(1+e))),o(r[(s-1+t)%t],r[s],r[(s+1)%t],r[(s+2)%t],n-s)):e<0?r[0]-(o(r[0],r[0],r[1],r[1],-n)-r[0]):e>1?r[t]-(o(r[t],r[t],r[t-1],r[t-1],n-t)-r[t]):o(r[s?s-1:0],r[s],r[t1;n--)t*=n;return r[e]=t,t}}(),CatmullRom:function(r,e,t,n,s){var o=(t-r)*.5,a=(n-e)*.5,c=s*s,u=s*c;return(2*e-2*t+o+a)*u+(-3*e+3*t-2*o-a)*c+o*s+e}}},OT=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),FT=new DT,BT=function(){function r(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Zf.Linear.None,this._interpolationFunction=Em.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=OT.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=FT,FT.add(this))}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=p0()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var o in this._valuesEnd)s[o]=this._valuesEnd[o];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,n,s,o){for(var a in n){var c=e[a],u=Array.isArray(c),d=u?"array":typeof c,p=!u&&Array.isArray(n[a]);if(!(d==="undefined"||d==="function")){if(p){var m=n[a];if(m.length===0)continue;for(var y=[c],M=0,T=m.length;Mu)return 1;var G=Math.trunc(a/c),z=a-G*c,I=Math.min(z/n._duration,1);return I===0&&a===n._duration?1:I},p=d(),m=this._easingFunction(p);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,p),this._duration===0||a>=this._duration)if(this._repeat>0){var y=Math.min(Math.trunc((a-this._duration)/c)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=y);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=c*y,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var M=0,T=this._chainedTweens.length;M=Q&&(Q=ee+1);!(_e=z[Q])&&++Q=0;)(a=n[s])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function Tj(r){r||(r=Ej);function e(m,y){return m&&y?r(m.__data__,y.__data__):!m-!y}for(var t=this._groups,n=t.length,s=new Array(n),o=0;oe?1:r>=e?0:NaN}function Aj(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function Cj(){return Array.from(this)}function Rj(){for(var r=this._groups,e=0,t=r.length;e=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),AL.hasOwnProperty(e)?{space:AL[e],local:r}:r}function Lj(r){return function(){this.removeAttribute(r)}}function Dj(r){return function(){this.removeAttributeNS(r.space,r.local)}}function Oj(r,e){return function(){this.setAttribute(r,e)}}function Fj(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function Bj(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function Uj(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function kj(r,e){var t=CL(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?Dj:Lj:typeof e=="function"?t.local?Uj:Bj:t.local?Fj:Oj)(t,e))}function RL(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function zj(r){return function(){this.style.removeProperty(r)}}function Vj(r,e,t){return function(){this.style.setProperty(r,e,t)}}function Gj(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function Wj(r,e,t){return arguments.length>1?this.each((e==null?zj:typeof e=="function"?Gj:Vj)(r,e,t==null?"":t)):Hj(this.node(),r)}function Hj(r,e){return r.style.getPropertyValue(e)||RL(r).getComputedStyle(r,null).getPropertyValue(e)}function $j(r){return function(){delete this[r]}}function jj(r,e){return function(){this[r]=e}}function Xj(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function qj(r,e){return arguments.length>1?this.each((e==null?$j:typeof e=="function"?Xj:jj)(r,e)):this.node()[r]}function NL(r){return r.trim().split(/^|\s+/)}function kT(r){return r.classList||new PL(r)}function PL(r){this._node=r,this._names=NL(r.getAttribute("class")||"")}PL.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function IL(r,e){for(var t=kT(r),n=-1,s=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function SX(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,o;t2&&(a.children=arguments.length>3?Xv.call(arguments,2):t),typeof r=="function"&&r.defaultProps!=null)for(o in r.defaultProps)a[o]===void 0&&(a[o]=r.defaultProps[o]);return Zv(r,a,n,s,null)}function Zv(r,e,t,n,s){var o={type:r,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s==null?++BL:s,__i:-1,__u:0};return s==null&&sa.vnode!=null&&sa.vnode(o),o}function kK(){return{current:null}}function Gb(r){return r.children}function Wb(r,e){this.props=r,this.context=e}function m0(r,e){if(e==null)return r.__?m0(r.__,r.__i+1):null;for(var t;ec&&Am.sort(VL),r=Am.shift(),c=Am.length,r.__d&&(t=void 0,n=void 0,s=(n=(e=r).__v).__e,o=[],a=[],e.__P&&((t=$h({},n)).__v=n.__v+1,sa.vnode&&sa.vnode(t),$T(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?m0(n):s,!!(32&n.__u),a),t.__v=n.__v,t.__.__k[t.__i]=t,ZL(o,t,a),n.__e=n.__=null,t.__e!=s&&$L(t)));Hb.__r=0}function jL(r,e,t,n,s,o,a,c,u,d,p){var m,y,M,T,G,z,I,ee=n&&n.__k||HL,Q=e.length;for(u=UX(t,e,ee,u,Q),m=0;m0?Zv(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=r,a.__b=r.__b+1,c=null,(d=a.__i=zX(a,t,u,m))!=-1&&(m--,(c=t[d])&&(c.__u|=2)),c==null||c.__v==null?(d==-1&&(s>p?y--:su?y--:y++,a.__u|=4))):r.__k[o]=null;if(m)for(o=0;o(p?1:0)){for(s=t-1,o=t+1;s>=0||o=0?s--:o++])!=null&&!(2&d.__u)&&c==d.key&&u==d.type)return a}return-1}function qL(r,e,t){e[0]=="-"?r.setProperty(e,t==null?"":t):r[e]=t==null?"":typeof t!="number"||FX.test(e)?t:t+"px"}function $b(r,e,t,n,s){var o,a;e:if(e=="style")if(typeof t=="string")r.style.cssText=t;else{if(typeof n=="string"&&(r.style.cssText=n=""),n)for(e in n)t&&e in t||qL(r.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||qL(r.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(GL,"$1")),a=e.toLowerCase(),e=a in r||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),r.l||(r.l={}),r.l[e+o]=t,t?n?t.u=n.u:(t.u=zT,r.addEventListener(e,o?GT:VT,o)):r.removeEventListener(e,o?GT:VT,o);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in r)try{r[e]=t==null?"":t;break e}catch(c){}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?r.removeAttribute(e):r.setAttribute(e,e=="popover"&&t==1?"":t))}}function YL(r){return function(e){if(this.l){var t=this.l[e.type+r];if(e.t==null)e.t=zT++;else if(e.t0?r:Yv(r)?r.map(KL):$h({},r)}function VX(r,e,t,n,s,o,a,c,u){var d,p,m,y,M,T,G,z=t.props,I=e.props,ee=e.type;if(ee=="svg"?s="http://www.w3.org/2000/svg":ee=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(d=0;d2&&(c.children=arguments.length>3?Xv.call(arguments,2):t),Zv(r.type,c,n||r.key,s||r.ref,null)}function zK(r){function e(t){var n,s;return this.getChildContext||(n=new Set,(s={})[e.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&n.forEach(function(a){a.__e=!0,HT(a)})},this.sub=function(o){n.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){n&&n.delete(o),a&&a.call(o)}}),t.children}return e.__c="__cC"+WL++,e.__=r,e.Provider=e.__l=(e.Consumer=function(t,n){return t.children(n)}).contextType=e,e}Xv=HL.slice,sa={__e:function(r,e,t,n){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(r)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(r,n||{}),a=s.__d),a)return s.__E=s}catch(c){r=c}throw r}},BL=0,UL=function(r){return r!=null&&r.constructor==null},Wb.prototype.setState=function(r,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=$h({},this.state),typeof r=="function"&&(r=r($h({},t),this.props)),r&&$h(t,r),r!=null&&this.__v&&(e&&this._sb.push(e),HT(this))},Wb.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),HT(this))},Wb.prototype.render=Gb,Am=[],zL=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,VL=function(r,e){return r.__v.__b-e.__v.__b},Hb.__r=0,GL=/(PointerCapture)$|Capture$/i,zT=0,VT=YL(!1),GT=YL(!0),WL=0;function t3(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t2&&arguments[2]!==void 0?arguments[2]:{},s=n.style,o=s===void 0?{}:s,a=!!e&&jb(e)==="object"&&!!e.node&&typeof e.node=="function",c=LX(a?e.node():e);c.style("position")==="static"&&c.style("position","relative"),t.tooltipEl=c.append("div").attr("class","float-tooltip-kap"),Object.entries(o).forEach(function(d){var p=YX(d,2),m=p[0],y=p[1];return t.tooltipEl.style(m,y)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,c.on("mousemove.".concat(u),function(d){t.mouseInside=!0;var p=OX(d),m=c.node(),y=m.offsetWidth,M=m.offsetHeight,T=[t.offsetX===null||t.offsetX===void 0?"-".concat(p[0]/y*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?M>130&&M-p[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",p[0]+"px").style("top",p[1]+"px").style("transform","translate(".concat(T.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):QX(e.content)?(e.tooltipEl.text(""),eq(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function rq(r,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=r:s.appendChild(document.createTextNode(r))}}var sq=`.scene-nav-info { position: absolute; bottom: 5px; width: 100%; text-align: center; color: slategrey; opacity: 0.7; font-size: 10px; font-family: sans-serif; pointer-events: none; user-select: none; } .scene-container canvas:focus { outline: none; }`;rq(sq);function YT(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var s=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&s.sort(function(a,c){return e.hoverOrderComparator(a.object,c.object)});var o=s.find(function(a){return e.hoverFilter(a.object)})||null;n=o?o.object:null,e.intersection=o||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Us(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,s=t.y;return{x:n,y:s}},cameraPosition:function(e,t,n,s){var o=e.camera;if(t&&e.initialised){var a=t,c=n||{x:0,y:0,z:0};if(!s)p(a),m(c);else{var u=Object.assign({},o.position),d=y();e.tweenGroup.add(new BT(u).to(a,s).easing(Zf.Quadratic.Out).onUpdate(p).start()),e.tweenGroup.add(new BT(d).to(c,s/3).easing(Zf.Quadratic.Out).onUpdate(m).start())}return this}return Object.assign({},o.position,{lookAt:y()});function p(M){var T=M.x,G=M.y,z=M.z;T!==void 0&&(o.position.x=T),G!==void 0&&(o.position.y=G),z!==void 0&&(o.position.z=z)}function m(M){var T=new oa.Vector3(M.x,M.y,M.z);e.controls.enabled&&e.controls.target?e.controls.target=T:o.lookAt(T)}function y(){return Object.assign(new oa.Vector3(0,0,-1e3).applyQuaternion(o.quaternion).add(o.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,o=new Array(s>3?s-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,o=e.camera;if(t){var a=new oa.Vector3(0,0,0),c=Math.max.apply(Math,Cm(Object.entries(t).map(function(M){var T=fq(M,2),G=T[0],z=T[1];return Math.max.apply(Math,Cm(z.map(function(I){return Math.abs(a[G]-I)})))})))*2,u=(1-s*2/e.height)*o.fov,d=c/Math.atan(u*Math.PI/180),p=d/o.aspect,m=Math.max(d,p);if(m>0){var y=a.clone().sub(o.position).normalize().multiplyScalar(-m);this.cameraPosition(y,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new oa.Box3(new oa.Vector3(0,0,0),new oa.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(o){return n.expandByObject(o)}),Object.assign.apply(Object,Cm(["x","y","z"].map(function(o){return lq({},o,[n.min[o],n.max[o]])})))):null},getScreenCoords:function(e,t,n,s){var o=new oa.Vector3(t,n,s);return o.project(this.camera()),{x:(o.x+1)*e.width/2,y:-(o.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=new oa.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new oa.Raycaster;return a.setFromCamera(o,e.camera),Object.assign({},a.ray.at(s,new oa.Vector3))},intersectingObjects:function(e,t,n){var s=new oa.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new oa.Raycaster;return o.params.Line.threshold=e.lineHoverPrecision,o.params.Points.threshold=e.pointsHoverPrecision,o.setFromCamera(s,e.camera),o.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new oa.Scene,camera:new oa.PerspectiveCamera,clock:new oa.Clock,tweenGroup:new DT,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=n.controlType,o=s===void 0?"trackball":s,a=n.useWebGPU,c=a===void 0?!1:a,u=n.rendererConfig,d=u===void 0?{}:u,p=n.extraRenderers,m=p===void 0?[]:p,y=n.waitForLoadComplete,M=y===void 0?!0:y;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[o]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new iq(t.container),t.pointerPos=new oa.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(G){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&G.type==="pointermove"&&(G.pressure>0||t.isPointerPressed)&&(G.pointerType==="mouse"||G.movementX===void 0||[G.movementX,G.movementY].some(function(ee){return Math.abs(ee)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var z=I(t.container);t.pointerPos.x=G.pageX-z.left,t.pointerPos.y=G.pageY-z.top}function I(ee){var Q=ee.getBoundingClientRect(),oe=window.pageXOffset||document.documentElement.scrollLeft,_e=window.pageYOffset||document.documentElement.scrollTop;return{top:Q.top+_e,left:Q.left+oe}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(c?M9:oa.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},d)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=m,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new v7(t.renderer),t.postProcessingComposer.addPass(new x7(t.scene,t.camera)),t.controls=new{trackball:A9,orbit:W9,fly:i7}[o](t.camera,t.renderer.domElement),o==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(o==="trackball"||o==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Cm(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new oa.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!M,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,s=e.width,o=e.height;e.container.style.width="".concat(s,"px"),e.container.style.height="".concat(o,"px"),[e.renderer,e.postProcessingComposer].concat(Cm(e.extraRenderers)).forEach(function(M){return M.setSize(s,o)}),e.camera.aspect=s/o;var a=e.viewOffset.slice(0,2);a.some(function(M){return M})&&(n=e.camera).setViewOffset.apply(n,[s,o].concat(Cm(a),[s,o])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var c,u=e.width,d=e.height,p=e.viewOffset.slice(0,2);p.some(function(M){return M})?(c=e.camera).setViewOffset.apply(c,[u,d].concat(Cm(p),[u,d])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new oa.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var m=Wd(e.backgroundColor).alpha;m===void 0&&(m=1),e.renderer.setClearColor(new oa.Color(N$(1,e.backgroundColor)),m)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new oa.TextureLoader().load(e.backgroundImageUrl,function(M){M.colorSpace=oa.SRGBColorSpace,e.skysphere.material=new oa.MeshBasicMaterial({map:M,side:oa.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&y()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&y())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(M){return e.scene.remove(M)}),e.lights.forEach(function(M){return e.scene.add(M)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(M){return e.scene.remove(M)}),e.objects.forEach(function(M){return e.scene.add(M)}));function y(){e.loadComplete=e.scene.visible=!0}}});function gq(r,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=r:s.appendChild(document.createTextNode(r))}}var yq=`.graph-info-msg { top: 50%; width: 100%; text-align: center; color: lavender; opacity: 0.7; font-size: 22px; position: absolute; font-family: Sans-serif; } .scene-container .clickable { cursor: pointer; } .scene-container .grabbable { cursor: move; cursor: grab; cursor: -moz-grab; cursor: -webkit-grab; } .scene-container .grabbable:active { cursor: grabbing; cursor: -moz-grabbing; cursor: -webkit-grabbing; }`;gq(yq);function ZT(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t1?c-1:0),d=1;d3?o-3:0),c=3;c{}};function w(){for(var R=0,x=arguments.length,E={},N;R=0&&(N=E.slice(L+1),E=E.slice(0,L)),E&&!x.hasOwnProperty(E))throw new Error("unknown type: "+E);return{type:E,name:N}})}k.prototype=w.prototype={constructor:k,on:function(R,x){var E=this._,N=O(R+"",E),L,P=-1,W=N.length;if(arguments.length<2){for(;++P0)for(var E=new Array(L),N=0,L,P;Ntypeof at=="object"&&at!==null||typeof at=="function",x={canHandle:at=>R(at)&&at[w],serialize(at){const{port1:Ot,port2:ue}=new MessageChannel;return P(at,Ot),[ue,[ue]]},deserialize(at){return at.start(),re(at)}},E={canHandle:at=>R(at)&&S in at,serialize({value:at}){let Ot;return at instanceof Error?Ot={isError:!0,value:{message:at.message,name:at.name,stack:at.stack}}:Ot={isError:!1,value:at},[Ot,[]]},deserialize(at){throw at.isError?Object.assign(new Error(at.value.message),at.value):at.value}},N=new Map([["proxy",x],["throw",E]]);function L(at,Ot){for(const ue of at)if(Ot===ue||ue==="*"||ue instanceof RegExp&&ue.test(Ot))return!0;return!1}function P(at,Ot=globalThis,ue=["*"]){Ot.addEventListener("message",function Ue(vt){if(!vt||!vt.data)return;if(!L(ue,vt.origin)){console.warn(`Invalid origin '${vt.origin}' for comlink proxy`);return}const{id:Jt,type:Qe,path:rt}=Object.assign({path:[]},vt.data),bt=(vt.data.argumentList||[]).map(kt);let ze;try{const Ze=rt.slice(0,-1).reduce((Y,de)=>Y[de],at),q=rt.reduce((Y,de)=>Y[de],at);switch(Qe){case"GET":ze=q;break;case"SET":Ze[rt.slice(-1)[0]]=kt(vt.data.value),ze=!0;break;case"APPLY":ze=q.apply(Ze,bt);break;case"CONSTRUCT":{const Y=new q(...bt);ze=je(Y)}break;case"ENDPOINT":{const{port1:Y,port2:de}=new MessageChannel;P(at,de),ze=We(Y,[Y])}break;case"RELEASE":ze=void 0;break;default:return}}catch(Ze){ze={value:Ze,[S]:0}}Promise.resolve(ze).catch(Ze=>({value:Ze,[S]:0})).then(Ze=>{const[q,Y]=It(Ze);Ot.postMessage(Object.assign(Object.assign({},q),{id:Jt}),Y),Qe==="RELEASE"&&(Ot.removeEventListener("message",Ue),K(Ot),A in at&&typeof at[A]=="function"&&at[A]())}).catch(Ze=>{const[q,Y]=It({value:new TypeError("Unserializable return value"),[S]:0});Ot.postMessage(Object.assign(Object.assign({},q),{id:Jt}),Y)})}),Ot.start&&Ot.start()}function W(at){return at.constructor.name==="MessagePort"}function K(at){W(at)&&at.close()}function re(at,Ot){return Ae(at,[],Ot)}function ye(at){if(at)throw new Error("Proxy has been released and is not useable")}function ge(at){return Ut(at,{type:"RELEASE"}).then(()=>{K(at)})}const ce=new WeakMap,xe="FinalizationRegistry"in globalThis&&new FinalizationRegistry(at=>{const Ot=(ce.get(at)||0)-1;ce.set(at,Ot),Ot===0&&ge(at)});function fe(at,Ot){const ue=(ce.get(Ot)||0)+1;ce.set(Ot,ue),xe&&xe.register(at,Ot,at)}function Ne(at){xe&&xe.unregister(at)}function Ae(at,Ot=[],ue=function(){}){let Ue=!1;const vt=new Proxy(ue,{get(Jt,Qe){if(ye(Ue),Qe===O)return()=>{Ne(vt),ge(at),Ue=!0};if(Qe==="then"){if(Ot.length===0)return{then:()=>vt};const rt=Ut(at,{type:"GET",path:Ot.map(bt=>bt.toString())}).then(kt);return rt.then.bind(rt)}return Ae(at,[...Ot,Qe])},set(Jt,Qe,rt){ye(Ue);const[bt,ze]=It(rt);return Ut(at,{type:"SET",path:[...Ot,Qe].map(Ze=>Ze.toString()),value:bt},ze).then(kt)},apply(Jt,Qe,rt){ye(Ue);const bt=Ot[Ot.length-1];if(bt===k)return Ut(at,{type:"ENDPOINT"}).then(kt);if(bt==="bind")return Ae(at,Ot.slice(0,-1));const[ze,Ze]=Ye(rt);return Ut(at,{type:"APPLY",path:Ot.map(q=>q.toString()),argumentList:ze},Ze).then(kt)},construct(Jt,Qe){ye(Ue);const[rt,bt]=Ye(Qe);return Ut(at,{type:"CONSTRUCT",path:Ot.map(ze=>ze.toString()),argumentList:rt},bt).then(kt)}});return fe(vt,at),vt}function be(at){return Array.prototype.concat.apply([],at)}function Ye(at){const Ot=at.map(It);return[Ot.map(ue=>ue[0]),be(Ot.map(ue=>ue[1]))]}const Ee=new WeakMap;function We(at,Ot){return Ee.set(at,Ot),at}function je(at){return Object.assign(at,{[w]:!0})}function _t(at,Ot=globalThis,ue="*"){return{postMessage:(Ue,vt)=>at.postMessage(Ue,ue,vt),addEventListener:Ot.addEventListener.bind(Ot),removeEventListener:Ot.removeEventListener.bind(Ot)}}function It(at){for(const[Ot,ue]of N)if(ue.canHandle(at)){const[Ue,vt]=ue.serialize(at);return[{type:"HANDLER",name:Ot,value:Ue},vt]}return[{type:"RAW",value:at},Ee.get(at)||[]]}function kt(at){switch(at.type){case"HANDLER":return N.get(at.name).deserialize(at.value);case"RAW":return at.value}}function Ut(at,Ot,ue){return new Promise(Ue=>{const vt=At();at.addEventListener("message",function Jt(Qe){!Qe.data||!Qe.data.id||Qe.data.id!==vt||(at.removeEventListener("message",Jt),Ue(Qe.data))}),at.start&&at.start(),at.postMessage(Object.assign({id:vt},Ot),ue)})}function At(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}},51598:function(ae,ne,b){"use strict";b.d(ne,{H:function(){return O},Z:function(){return w}});function w(A){const S=+this._x.call(null,A);return k(this.cover(S),S,A)}function k(A,S,R){if(isNaN(S))return A;var x,E=A._root,N={data:R},L=A._x0,P=A._x1,W,K,re,ye,ge;if(!E)return A._root=N,A;for(;E.length;)if((re=S>=(W=(L+P)/2))?L=W:P=W,x=E,!(E=E[ye=+re]))return x[ye]=N,A;if(K=+A._x.call(null,E.data),S===K)return N.next=E,x?x[ye]=N:A._root=N,A;do x=x?x[ye]=new Array(2):A._root=new Array(2),(re=S>=(W=(L+P)/2))?L=W:P=W;while((ye=+re)==(ge=+(K>=W)));return x[ge]=E,x[ye]=N,A}function O(A){Array.isArray(A)||(A=Array.from(A));const S=A.length,R=new Float64Array(S);let x=1/0,E=-1/0;for(let N=0,L;NE&&(E=L));if(x>E)return this;this.cover(x).cover(E);for(let N=0;Nk||k>=A;)switch(E=+(kN||(E=W.x1)=re))&&(W=L[L.length-1],L[L.length-1]=L[L.length-1-K],L[L.length-1-K]=W)}else{var ye=Math.abs(O-+this._x.call(null,P.data));ye=(W=(N+L)/2))?N=W:L=W,A=S,!(S=S[re=+K]))return this;if(!S.length)break;A[re+1&1]&&(R=A,ye=re)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):A?(E?A[re]=E:delete A[re],(S=A[0]||A[1])&&S===(A[1]||A[0])&&!S.length&&(R?R[ye]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A=0&&Ae._call.call(void 0,be),Ae=Ae._next;--w}function ce(){E=(x=L.now())+N,w=k=0;try{ge()}finally{w=0,fe(),E=0}}function xe(){var Ae=L.now(),be=Ae-x;be>A&&(N-=be,x=Ae)}function fe(){for(var Ae,be=S,Ye,Ee=1/0;be;)be._call?(Ee>be._time&&(Ee=be._time),Ae=be,be=be._next):(Ye=be._next,be._next=null,be=Ae?Ae._next=Ye:S=Ye);R=Ae,Ne(Ee)}function Ne(Ae){if(!w){k&&(k=clearTimeout(k));var be=Ae-E;be>24?(Ae<1/0&&(k=setTimeout(ce,Ae-L.now()-N)),O&&(O=clearInterval(O))):(O||(x=L.now(),O=setInterval(xe,A)),w=1,P(ce))}}},46846:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return w}});function w(k,O){var A,S=1;k==null&&(k=0),O==null&&(O=0);function R(){var x,E=A.length,N,L=0,P=0;for(x=0;xfe.index){var ue=Ne-At.x-At.vx,Ue=Ae-At.y-At.vy,vt=ue*ue+Ue*Ue;vtNe+Ot||ktAe+Ot||Utge.r&&(ge.r=ge[ce].r)}function ye(){if(E){var ge,ce=E.length,xe;for(N=new Array(ce),ge=0;ge(S=(w*S+k)%O)/O}},56561:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return S}});var w=b(13548),k=b(79778);function O(R){return R.index}function A(R,x){var E=R.get(x);if(!E)throw new Error("node not found: "+x);return E}function S(R){var x=O,E=ce,N,L=(0,w.Z)(30),P,W,K,re,ye,ge=1;R==null&&(R=[]);function ce(be){return 1/Math.min(K[be.source.index],K[be.target.index])}function xe(be){for(var Ye=0,Ee=R.length;Ye[x(_t,It,W),_t])),je;for(be=0,K=new Array(Ye);be=K)return;(fe.data!==x||fe.next)&&(Ye===0&&(Ye=(0,O.Z)(E),je+=Ye*Ye),Ee===0&&(Ee=(0,O.Z)(E),je+=Ee*Ee),je1?(We==null?ge.delete(Ee):ge.set(Ee,Ye(We)),L):ge.get(Ee)},find:function(Ee,We,je){var _t=0,It=N.length,kt,Ut,At,at,Ot;for(je==null?je=1/0:je*=je,_t=0;_t1?(xe.on(Ee,We),L):xe.on(Ee)}}}},70341:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return k}});var w=b(13548);function k(O){var A=(0,w.Z)(.1),S,R,x;typeof O!="function"&&(O=(0,w.Z)(O==null?0:+O));function E(L){for(var P=0,W=S.length,K;P=(xe=(W+ye)/2))?W=xe:ye=xe,(We=R>=(fe=(K+ge)/2))?K=fe:ge=fe,(je=x>=(Ne=(re+ce)/2))?re=Ne:ce=Ne,N=L,!(L=L[_t=je<<2|We<<1|Ee]))return N[_t]=P,A;if(Ae=+A._x.call(null,L.data),be=+A._y.call(null,L.data),Ye=+A._z.call(null,L.data),S===Ae&&R===be&&x===Ye)return P.next=L,N?N[_t]=P:A._root=P,A;do N=N?N[_t]=new Array(8):A._root=new Array(8),(Ee=S>=(xe=(W+ye)/2))?W=xe:ye=xe,(We=R>=(fe=(K+ge)/2))?K=fe:ge=fe,(je=x>=(Ne=(re+ce)/2))?re=Ne:ce=Ne;while((_t=je<<2|We<<1|Ee)===(It=(Ye>=Ne)<<2|(be>=fe)<<1|Ae>=xe));return N[It]=L,N[_t]=P,A}function O(A){Array.isArray(A)||(A=Array.from(A));const S=A.length,R=new Float64Array(S),x=new Float64Array(S),E=new Float64Array(S);let N=1/0,L=1/0,P=1/0,W=-1/0,K=-1/0,re=-1/0;for(let ye=0,ge,ce,xe,fe;yeW&&(W=ce),xeK&&(K=xe),fere&&(re=fe));if(N>W||L>K||P>re)return this;this.cover(N,L,P).cover(W,K,re);for(let ye=0;yek||k>=E||R>O||O>=N||x>A||A>=L;)switch(re=(Ace||(W=be.y0)>xe||(K=be.z0)>fe||(re=be.x1)=je)<<2|(A>=We)<<1|O>=Ee)&&(be=Ne[Ne.length-1],Ne[Ne.length-1]=Ne[Ne.length-1-Ye],Ne[Ne.length-1-Ye]=be)}else{var _t=O-+this._x.call(null,Ae.data),It=A-+this._y.call(null,Ae.data),kt=S-+this._z.call(null,Ae.data),Ut=_t*_t+It*It+kt*kt;if(Ut=(xe=(N+W)/2))?N=xe:W=xe,(be=ge>=(fe=(L+K)/2))?L=fe:K=fe,(Ye=ce>=(Ne=(P+re)/2))?P=Ne:re=Ne,A=S,!(S=S[Ee=Ye<<2|be<<1|Ae]))return this;if(!S.length)break;(A[Ee+1&7]||A[Ee+2&7]||A[Ee+3&7]||A[Ee+4&7]||A[Ee+5&7]||A[Ee+6&7]||A[Ee+7&7])&&(R=A,We=Ee)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):A?(E?A[Ee]=E:delete A[Ee],(S=A[0]||A[1]||A[2]||A[3]||A[4]||A[5]||A[6]||A[7])&&S===(A[7]||A[6]||A[5]||A[4]||A[3]||A[2]||A[1]||A[0])&&!S.length&&(R?R[We]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A=(ye=(P+K)/2))?P=ye:K=ye,(Ne=R>=(ge=(W+re)/2))?W=ge:re=ge,E=N,!(N=N[Ae=Ne<<1|fe]))return E[Ae]=L,A;if(ce=+A._x.call(null,N.data),xe=+A._y.call(null,N.data),S===ce&&R===xe)return L.next=N,E?E[Ae]=L:A._root=L,A;do E=E?E[Ae]=new Array(4):A._root=new Array(4),(fe=S>=(ye=(P+K)/2))?P=ye:K=ye,(Ne=R>=(ge=(W+re)/2))?W=ge:re=ge;while((Ae=Ne<<1|fe)===(be=(xe>=ge)<<1|ce>=ye));return E[be]=N,E[Ae]=L,A}function O(A){var S,R,x=A.length,E,N,L=new Array(x),P=new Array(x),W=1/0,K=1/0,re=-1/0,ye=-1/0;for(R=0;Rre&&(re=E),Nye&&(ye=N));if(W>re||K>ye)return this;for(this.cover(W,K).cover(re,ye),R=0;Rk||k>=R||S>O||O>=x;)switch(P=(OK||(L=ce.y0)>re||(P=ce.x1)=Ne)<<1|O>=fe)&&(ce=ye[ye.length-1],ye[ye.length-1]=ye[ye.length-1-xe],ye[ye.length-1-xe]=ce)}else{var Ae=O-+this._x.call(null,ge.data),be=A-+this._y.call(null,ge.data),Ye=Ae*Ae+be*be;if(Ye=(ye=(N+P)/2))?N=ye:P=ye,(xe=re>=(ge=(L+W)/2))?L=ge:W=ge,A=S,!(S=S[fe=xe<<1|ce]))return this;if(!S.length)break;(A[fe+1&3]||A[fe+2&3]||A[fe+3&3])&&(R=A,Ne=fe)}for(;S.data!==O;)if(x=S,!(S=S.next))return this;return(E=S.next)&&delete S.next,x?(E?x.next=E:delete x.next,this):A?(E?A[fe]=E:delete A[fe],(S=A[0]||A[1]||A[2]||A[3])&&S===(A[3]||A[2]||A[1]||A[0])&&!S.length&&(R?R[Ne]=S:this._root=S),this):(this._root=E,this)}function k(O){for(var A=0,S=O.length;A=0;--i)if(j[i]>=65535)return!0;return!1}const Xa={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Fu(j,i){return new Xa[j](i)}function lc(j){return document.createElementNS("http://www.w3.org/1999/xhtml",j)}function Fa(){const j=lc("canvas");return j.style.display="block",j}const yl={};let Sr=null;function tp(j){Sr=j}function rx(){return Sr}function Bm(...j){const i="THREE."+j.shift();Sr?Sr("log",i,...j):console.log(i,...j)}function _r(...j){const i="THREE."+j.shift();Sr?Sr("warn",i,...j):console.warn(i,...j)}function js(...j){const i="THREE."+j.shift();Sr?Sr("error",i,...j):console.error(i,...j)}function Fl(...j){const i=j.join(" ");i in yl||(yl[i]=!0,_r(...j))}function S0(j,i,l){return new Promise(function(h,f){function g(){switch(j.clientWaitSync(i,j.SYNC_FLUSH_COMMANDS_BIT,0)){case j.WAIT_FAILED:f();break;case j.TIMEOUT_EXPIRED:setTimeout(g,l);break;default:h()}}setTimeout(g,l)})}class Bu{addEventListener(i,l){this._listeners===void 0&&(this._listeners={});const h=this._listeners;h[i]===void 0&&(h[i]=[]),h[i].indexOf(l)===-1&&h[i].push(l)}hasEventListener(i,l){const h=this._listeners;return h===void 0?!1:h[i]!==void 0&&h[i].indexOf(l)!==-1}removeEventListener(i,l){const h=this._listeners;if(h===void 0)return;const f=h[i];if(f!==void 0){const g=f.indexOf(l);g!==-1&&f.splice(g,1)}}dispatchEvent(i){const l=this._listeners;if(l===void 0)return;const h=l[i.type];if(h!==void 0){i.target=this;const f=h.slice(0);for(let g=0,v=f.length;g>8&255]+_a[j>>16&255]+_a[j>>24&255]+"-"+_a[i&255]+_a[i>>8&255]+"-"+_a[i>>16&15|64]+_a[i>>24&255]+"-"+_a[l&63|128]+_a[l>>8&255]+"-"+_a[l>>16&255]+_a[l>>24&255]+_a[h&255]+_a[h>>8&255]+_a[h>>16&255]+_a[h>>24&255]).toLowerCase()}function Fr(j,i,l){return Math.max(i,Math.min(l,j))}function np(j,i){return(j%i+i)%i}function E0(j,i,l,h,f){return h+(j-i)*(f-h)/(l-i)}function A0(j,i,l){return j!==i?(l-j)/(i-j):0}function qh(j,i,l){return(1-l)*j+l*i}function qa(j,i,l,h){return qh(j,i,1-Math.exp(-l*h))}function ls(j,i=1){return i-Math.abs(np(j,i*2)-i)}function Yh(j,i,l){return j<=i?0:j>=l?1:(j=(j-i)/(l-i),j*j*(3-2*j))}function yn(j,i,l){return j<=i?0:j>=l?1:(j=(j-i)/(l-i),j*j*j*(j*(j*6-15)+10))}function ea(j,i){return j+Math.floor(Math.random()*(i-j+1))}function ot(j,i){return j+Math.random()*(i-j)}function ip(j){return j*(.5-Math.random())}function Um(j){j!==void 0&&(T0=j);let i=T0+=1831565813;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}function $r(j){return j*ru}function rp(j){return j*Uu}function sp(j){return(j&j-1)===0&&j!==0}function C0(j){return Math.pow(2,Math.ceil(Math.log(j)/Math.LN2))}function ch(j){return Math.pow(2,Math.floor(Math.log(j)/Math.LN2))}function uh(j,i,l,h,f){const g=Math.cos,v=Math.sin,C=g(l/2),V=v(l/2),H=g((i+h)/2),J=v((i+h)/2),he=g((i-h)/2),pe=v((i-h)/2),me=g((h-i)/2),Se=v((h-i)/2);switch(f){case"XYX":j.set(C*J,V*he,V*pe,C*H);break;case"YZY":j.set(V*pe,C*J,V*he,C*H);break;case"ZXZ":j.set(V*he,V*pe,C*J,C*H);break;case"XZX":j.set(C*J,V*Se,V*me,C*H);break;case"YXY":j.set(V*me,C*J,V*Se,C*H);break;case"ZYZ":j.set(V*Se,V*me,C*J,C*H);break;default:_r("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+f)}}function Ya(j,i){switch(i.constructor){case Float32Array:return j;case Uint32Array:return j/4294967295;case Uint16Array:return j/65535;case Uint8Array:return j/255;case Int32Array:return Math.max(j/2147483647,-1);case Int16Array:return Math.max(j/32767,-1);case Int8Array:return Math.max(j/127,-1);default:throw new Error("Invalid component type.")}}function ns(j,i){switch(i.constructor){case Float32Array:return j;case Uint32Array:return Math.round(j*4294967295);case Uint16Array:return Math.round(j*65535);case Uint8Array:return Math.round(j*255);case Int32Array:return Math.round(j*2147483647);case Int16Array:return Math.round(j*32767);case Int8Array:return Math.round(j*127);default:throw new Error("Invalid component type.")}}const ol={DEG2RAD:ru,RAD2DEG:Uu,generateUUID:Sl,clamp:Fr,euclideanModulo:np,mapLinear:E0,inverseLerp:A0,lerp:qh,damp:qa,pingpong:ls,smoothstep:Yh,smootherstep:yn,randInt:ea,randFloat:ot,randFloatSpread:ip,seededRandom:Um,degToRad:$r,radToDeg:rp,isPowerOfTwo:sp,ceilPowerOfTwo:C0,floorPowerOfTwo:ch,setQuaternionFromProperEuler:uh,normalize:ns,denormalize:Ya};class oi{constructor(i=0,l=0){oi.prototype.isVector2=!0,this.x=i,this.y=l}get width(){return this.x}set width(i){this.x=i}get height(){return this.y}set height(i){this.y=i}set(i,l){return this.x=i,this.y=l,this}setScalar(i){return this.x=i,this.y=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setComponent(i,l){switch(i){case 0:this.x=l;break;case 1:this.y=l;break;default:throw new Error("index is out of range: "+i)}return this}getComponent(i){switch(i){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+i)}}clone(){return new this.constructor(this.x,this.y)}copy(i){return this.x=i.x,this.y=i.y,this}add(i){return this.x+=i.x,this.y+=i.y,this}addScalar(i){return this.x+=i,this.y+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this}subScalar(i){return this.x-=i,this.y-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this}multiply(i){return this.x*=i.x,this.y*=i.y,this}multiplyScalar(i){return this.x*=i,this.y*=i,this}divide(i){return this.x/=i.x,this.y/=i.y,this}divideScalar(i){return this.multiplyScalar(1/i)}applyMatrix3(i){const l=this.x,h=this.y,f=i.elements;return this.x=f[0]*l+f[3]*h+f[6],this.y=f[1]*l+f[4]*h+f[7],this}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,l))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(i){return this.x*i.x+this.y*i.y}cross(i){return this.x*i.y-this.y*i.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(i){const l=Math.sqrt(this.lengthSq()*i.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(i)/l;return Math.acos(Fr(h,-1,1))}distanceTo(i){return Math.sqrt(this.distanceToSquared(i))}distanceToSquared(i){const l=this.x-i.x,h=this.y-i.y;return l*l+h*h}manhattanDistanceTo(i){return Math.abs(this.x-i.x)+Math.abs(this.y-i.y)}setLength(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this}equals(i){return i.x===this.x&&i.y===this.y}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this}rotateAround(i,l){const h=Math.cos(l),f=Math.sin(l),g=this.x-i.x,v=this.y-i.y;return this.x=g*h-v*f+i.x,this.y=g*f+v*h+i.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vl{constructor(i=0,l=0,h=0,f=1){this.isQuaternion=!0,this._x=i,this._y=l,this._z=h,this._w=f}static slerpFlat(i,l,h,f,g,v,C){let V=h[f+0],H=h[f+1],J=h[f+2],he=h[f+3],pe=g[v+0],me=g[v+1],Se=g[v+2],tt=g[v+3];if(C<=0){i[l+0]=V,i[l+1]=H,i[l+2]=J,i[l+3]=he;return}if(C>=1){i[l+0]=pe,i[l+1]=me,i[l+2]=Se,i[l+3]=tt;return}if(he!==tt||V!==pe||H!==me||J!==Se){let gt=V*pe+H*me+J*Se+he*tt;gt<0&&(pe=-pe,me=-me,Se=-Se,tt=-tt,gt=-gt);let mt=1-C;if(gt<.9995){const Nt=Math.acos(gt),Pt=Math.sin(Nt);mt=Math.sin(mt*Nt)/Pt,C=Math.sin(C*Nt)/Pt,V=V*mt+pe*C,H=H*mt+me*C,J=J*mt+Se*C,he=he*mt+tt*C}else{V=V*mt+pe*C,H=H*mt+me*C,J=J*mt+Se*C,he=he*mt+tt*C;const Nt=1/Math.sqrt(V*V+H*H+J*J+he*he);V*=Nt,H*=Nt,J*=Nt,he*=Nt}}i[l]=V,i[l+1]=H,i[l+2]=J,i[l+3]=he}static multiplyQuaternionsFlat(i,l,h,f,g,v){const C=h[f],V=h[f+1],H=h[f+2],J=h[f+3],he=g[v],pe=g[v+1],me=g[v+2],Se=g[v+3];return i[l]=C*Se+J*he+V*me-H*pe,i[l+1]=V*Se+J*pe+H*he-C*me,i[l+2]=H*Se+J*me+C*pe-V*he,i[l+3]=J*Se-C*he-V*pe-H*me,i}get x(){return this._x}set x(i){this._x=i,this._onChangeCallback()}get y(){return this._y}set y(i){this._y=i,this._onChangeCallback()}get z(){return this._z}set z(i){this._z=i,this._onChangeCallback()}get w(){return this._w}set w(i){this._w=i,this._onChangeCallback()}set(i,l,h,f){return this._x=i,this._y=l,this._z=h,this._w=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(i){return this._x=i.x,this._y=i.y,this._z=i.z,this._w=i.w,this._onChangeCallback(),this}setFromEuler(i,l=!0){const h=i._x,f=i._y,g=i._z,v=i._order,C=Math.cos,V=Math.sin,H=C(h/2),J=C(f/2),he=C(g/2),pe=V(h/2),me=V(f/2),Se=V(g/2);switch(v){case"XYZ":this._x=pe*J*he+H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he-pe*me*Se;break;case"YXZ":this._x=pe*J*he+H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he+pe*me*Se;break;case"ZXY":this._x=pe*J*he-H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he-pe*me*Se;break;case"ZYX":this._x=pe*J*he-H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he+pe*me*Se;break;case"YZX":this._x=pe*J*he+H*me*Se,this._y=H*me*he+pe*J*Se,this._z=H*J*Se-pe*me*he,this._w=H*J*he-pe*me*Se;break;case"XZY":this._x=pe*J*he-H*me*Se,this._y=H*me*he-pe*J*Se,this._z=H*J*Se+pe*me*he,this._w=H*J*he+pe*me*Se;break;default:_r("Quaternion: .setFromEuler() encountered an unknown order: "+v)}return l===!0&&this._onChangeCallback(),this}setFromAxisAngle(i,l){const h=l/2,f=Math.sin(h);return this._x=i.x*f,this._y=i.y*f,this._z=i.z*f,this._w=Math.cos(h),this._onChangeCallback(),this}setFromRotationMatrix(i){const l=i.elements,h=l[0],f=l[4],g=l[8],v=l[1],C=l[5],V=l[9],H=l[2],J=l[6],he=l[10],pe=h+C+he;if(pe>0){const me=.5/Math.sqrt(pe+1);this._w=.25/me,this._x=(J-V)*me,this._y=(g-H)*me,this._z=(v-f)*me}else if(h>C&&h>he){const me=2*Math.sqrt(1+h-C-he);this._w=(J-V)/me,this._x=.25*me,this._y=(f+v)/me,this._z=(g+H)/me}else if(C>he){const me=2*Math.sqrt(1+C-h-he);this._w=(g-H)/me,this._x=(f+v)/me,this._y=.25*me,this._z=(V+J)/me}else{const me=2*Math.sqrt(1+he-h-C);this._w=(v-f)/me,this._x=(g+H)/me,this._y=(V+J)/me,this._z=.25*me}return this._onChangeCallback(),this}setFromUnitVectors(i,l){let h=i.dot(l)+1;return h<1e-8?(h=0,Math.abs(i.x)>Math.abs(i.z)?(this._x=-i.y,this._y=i.x,this._z=0,this._w=h):(this._x=0,this._y=-i.z,this._z=i.y,this._w=h)):(this._x=i.y*l.z-i.z*l.y,this._y=i.z*l.x-i.x*l.z,this._z=i.x*l.y-i.y*l.x,this._w=h),this.normalize()}angleTo(i){return 2*Math.acos(Math.abs(Fr(this.dot(i),-1,1)))}rotateTowards(i,l){const h=this.angleTo(i);if(h===0)return this;const f=Math.min(1,l/h);return this.slerp(i,f),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(i){return this._x*i._x+this._y*i._y+this._z*i._z+this._w*i._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let i=this.length();return i===0?(this._x=0,this._y=0,this._z=0,this._w=1):(i=1/i,this._x=this._x*i,this._y=this._y*i,this._z=this._z*i,this._w=this._w*i),this._onChangeCallback(),this}multiply(i){return this.multiplyQuaternions(this,i)}premultiply(i){return this.multiplyQuaternions(i,this)}multiplyQuaternions(i,l){const h=i._x,f=i._y,g=i._z,v=i._w,C=l._x,V=l._y,H=l._z,J=l._w;return this._x=h*J+v*C+f*H-g*V,this._y=f*J+v*V+g*C-h*H,this._z=g*J+v*H+h*V-f*C,this._w=v*J-h*C-f*V-g*H,this._onChangeCallback(),this}slerp(i,l){if(l<=0)return this;if(l>=1)return this.copy(i);let h=i._x,f=i._y,g=i._z,v=i._w,C=this.dot(i);C<0&&(h=-h,f=-f,g=-g,v=-v,C=-C);let V=1-l;if(C<.9995){const H=Math.acos(C),J=Math.sin(H);V=Math.sin(V*H)/J,l=Math.sin(l*H)/J,this._x=this._x*V+h*l,this._y=this._y*V+f*l,this._z=this._z*V+g*l,this._w=this._w*V+v*l,this._onChangeCallback()}else this._x=this._x*V+h*l,this._y=this._y*V+f*l,this._z=this._z*V+g*l,this._w=this._w*V+v*l,this.normalize();return this}slerpQuaternions(i,l,h){return this.copy(i).slerp(l,h)}random(){const i=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),h=Math.random(),f=Math.sqrt(1-h),g=Math.sqrt(h);return this.set(f*Math.sin(i),f*Math.cos(i),g*Math.sin(l),g*Math.cos(l))}equals(i){return i._x===this._x&&i._y===this._y&&i._z===this._z&&i._w===this._w}fromArray(i,l=0){return this._x=i[l],this._y=i[l+1],this._z=i[l+2],this._w=i[l+3],this._onChangeCallback(),this}toArray(i=[],l=0){return i[l]=this._x,i[l+1]=this._y,i[l+2]=this._z,i[l+3]=this._w,i}fromBufferAttribute(i,l){return this._x=i.getX(l),this._y=i.getY(l),this._z=i.getZ(l),this._w=i.getW(l),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(i){return this._onChangeCallback=i,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Rt{constructor(i=0,l=0,h=0){Rt.prototype.isVector3=!0,this.x=i,this.y=l,this.z=h}set(i,l,h){return h===void 0&&(h=this.z),this.x=i,this.y=l,this.z=h,this}setScalar(i){return this.x=i,this.y=i,this.z=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setZ(i){return this.z=i,this}setComponent(i,l){switch(i){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;default:throw new Error("index is out of range: "+i)}return this}getComponent(i){switch(i){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+i)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(i){return this.x=i.x,this.y=i.y,this.z=i.z,this}add(i){return this.x+=i.x,this.y+=i.y,this.z+=i.z,this}addScalar(i){return this.x+=i,this.y+=i,this.z+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this.z=i.z+l.z,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this.z+=i.z*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this.z-=i.z,this}subScalar(i){return this.x-=i,this.y-=i,this.z-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this.z=i.z-l.z,this}multiply(i){return this.x*=i.x,this.y*=i.y,this.z*=i.z,this}multiplyScalar(i){return this.x*=i,this.y*=i,this.z*=i,this}multiplyVectors(i,l){return this.x=i.x*l.x,this.y=i.y*l.y,this.z=i.z*l.z,this}applyEuler(i){return this.applyQuaternion(Ki.setFromEuler(i))}applyAxisAngle(i,l){return this.applyQuaternion(Ki.setFromAxisAngle(i,l))}applyMatrix3(i){const l=this.x,h=this.y,f=this.z,g=i.elements;return this.x=g[0]*l+g[3]*h+g[6]*f,this.y=g[1]*l+g[4]*h+g[7]*f,this.z=g[2]*l+g[5]*h+g[8]*f,this}applyNormalMatrix(i){return this.applyMatrix3(i).normalize()}applyMatrix4(i){const l=this.x,h=this.y,f=this.z,g=i.elements,v=1/(g[3]*l+g[7]*h+g[11]*f+g[15]);return this.x=(g[0]*l+g[4]*h+g[8]*f+g[12])*v,this.y=(g[1]*l+g[5]*h+g[9]*f+g[13])*v,this.z=(g[2]*l+g[6]*h+g[10]*f+g[14])*v,this}applyQuaternion(i){const l=this.x,h=this.y,f=this.z,g=i.x,v=i.y,C=i.z,V=i.w,H=2*(v*f-C*h),J=2*(C*l-g*f),he=2*(g*h-v*l);return this.x=l+V*H+v*he-C*J,this.y=h+V*J+C*H-g*he,this.z=f+V*he+g*J-v*H,this}project(i){return this.applyMatrix4(i.matrixWorldInverse).applyMatrix4(i.projectionMatrix)}unproject(i){return this.applyMatrix4(i.projectionMatrixInverse).applyMatrix4(i.matrixWorld)}transformDirection(i){const l=this.x,h=this.y,f=this.z,g=i.elements;return this.x=g[0]*l+g[4]*h+g[8]*f,this.y=g[1]*l+g[5]*h+g[9]*f,this.z=g[2]*l+g[6]*h+g[10]*f,this.normalize()}divide(i){return this.x/=i.x,this.y/=i.y,this.z/=i.z,this}divideScalar(i){return this.multiplyScalar(1/i)}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this.z=Math.min(this.z,i.z),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this.z=Math.max(this.z,i.z),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this.z=Fr(this.z,i.z,l.z),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this.z=Fr(this.z,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,l))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(i){return this.x*i.x+this.y*i.y+this.z*i.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this.z+=(i.z-this.z)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this.z=i.z+(l.z-i.z)*h,this}cross(i){return this.crossVectors(this,i)}crossVectors(i,l){const h=i.x,f=i.y,g=i.z,v=l.x,C=l.y,V=l.z;return this.x=f*V-g*C,this.y=g*v-h*V,this.z=h*C-f*v,this}projectOnVector(i){const l=i.lengthSq();if(l===0)return this.set(0,0,0);const h=i.dot(this)/l;return this.copy(i).multiplyScalar(h)}projectOnPlane(i){return Kd.copy(this).projectOnVector(i),this.sub(Kd)}reflect(i){return this.sub(Kd.copy(i).multiplyScalar(2*this.dot(i)))}angleTo(i){const l=Math.sqrt(this.lengthSq()*i.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(i)/l;return Math.acos(Fr(h,-1,1))}distanceTo(i){return Math.sqrt(this.distanceToSquared(i))}distanceToSquared(i){const l=this.x-i.x,h=this.y-i.y,f=this.z-i.z;return l*l+h*h+f*f}manhattanDistanceTo(i){return Math.abs(this.x-i.x)+Math.abs(this.y-i.y)+Math.abs(this.z-i.z)}setFromSpherical(i){return this.setFromSphericalCoords(i.radius,i.phi,i.theta)}setFromSphericalCoords(i,l,h){const f=Math.sin(l)*i;return this.x=f*Math.sin(h),this.y=Math.cos(l)*i,this.z=f*Math.cos(h),this}setFromCylindrical(i){return this.setFromCylindricalCoords(i.radius,i.theta,i.y)}setFromCylindricalCoords(i,l,h){return this.x=i*Math.sin(l),this.y=h,this.z=i*Math.cos(l),this}setFromMatrixPosition(i){const l=i.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this}setFromMatrixScale(i){const l=this.setFromMatrixColumn(i,0).length(),h=this.setFromMatrixColumn(i,1).length(),f=this.setFromMatrixColumn(i,2).length();return this.x=l,this.y=h,this.z=f,this}setFromMatrixColumn(i,l){return this.fromArray(i.elements,l*4)}setFromMatrix3Column(i,l){return this.fromArray(i.elements,l*3)}setFromEuler(i){return this.x=i._x,this.y=i._y,this.z=i._z,this}setFromColor(i){return this.x=i.r,this.y=i.g,this.z=i.b,this}equals(i){return i.x===this.x&&i.y===this.y&&i.z===this.z}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this.z=i[l+2],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i[l+2]=this.z,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this.z=i.getZ(l),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const i=Math.random()*Math.PI*2,l=Math.random()*2-1,h=Math.sqrt(1-l*l);return this.x=h*Math.cos(i),this.y=l,this.z=h*Math.sin(i),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Kd=new Rt,Ki=new vl;class ua{constructor(i,l,h,f,g,v,C,V,H){ua.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],i!==void 0&&this.set(i,l,h,f,g,v,C,V,H)}set(i,l,h,f,g,v,C,V,H){const J=this.elements;return J[0]=i,J[1]=f,J[2]=C,J[3]=l,J[4]=g,J[5]=V,J[6]=h,J[7]=v,J[8]=H,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(i){const l=this.elements,h=i.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],this}extractBasis(i,l,h){return i.setFromMatrix3Column(this,0),l.setFromMatrix3Column(this,1),h.setFromMatrix3Column(this,2),this}setFromMatrix4(i){const l=i.elements;return this.set(l[0],l[4],l[8],l[1],l[5],l[9],l[2],l[6],l[10]),this}multiply(i){return this.multiplyMatrices(this,i)}premultiply(i){return this.multiplyMatrices(i,this)}multiplyMatrices(i,l){const h=i.elements,f=l.elements,g=this.elements,v=h[0],C=h[3],V=h[6],H=h[1],J=h[4],he=h[7],pe=h[2],me=h[5],Se=h[8],tt=f[0],gt=f[3],mt=f[6],Nt=f[1],Pt=f[4],Wt=f[7],gn=f[2],Sn=f[5],kn=f[8];return g[0]=v*tt+C*Nt+V*gn,g[3]=v*gt+C*Pt+V*Sn,g[6]=v*mt+C*Wt+V*kn,g[1]=H*tt+J*Nt+he*gn,g[4]=H*gt+J*Pt+he*Sn,g[7]=H*mt+J*Wt+he*kn,g[2]=pe*tt+me*Nt+Se*gn,g[5]=pe*gt+me*Pt+Se*Sn,g[8]=pe*mt+me*Wt+Se*kn,this}multiplyScalar(i){const l=this.elements;return l[0]*=i,l[3]*=i,l[6]*=i,l[1]*=i,l[4]*=i,l[7]*=i,l[2]*=i,l[5]*=i,l[8]*=i,this}determinant(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8];return l*v*J-l*C*H-h*g*J+h*C*V+f*g*H-f*v*V}invert(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8],he=J*v-C*H,pe=C*V-J*g,me=H*g-v*V,Se=l*he+h*pe+f*me;if(Se===0)return this.set(0,0,0,0,0,0,0,0,0);const tt=1/Se;return i[0]=he*tt,i[1]=(f*H-J*h)*tt,i[2]=(C*h-f*v)*tt,i[3]=pe*tt,i[4]=(J*l-f*V)*tt,i[5]=(f*g-C*l)*tt,i[6]=me*tt,i[7]=(h*V-H*l)*tt,i[8]=(v*l-h*g)*tt,this}transpose(){let i;const l=this.elements;return i=l[1],l[1]=l[3],l[3]=i,i=l[2],l[2]=l[6],l[6]=i,i=l[5],l[5]=l[7],l[7]=i,this}getNormalMatrix(i){return this.setFromMatrix4(i).invert().transpose()}transposeIntoArray(i){const l=this.elements;return i[0]=l[0],i[1]=l[3],i[2]=l[6],i[3]=l[1],i[4]=l[4],i[5]=l[7],i[6]=l[2],i[7]=l[5],i[8]=l[8],this}setUvTransform(i,l,h,f,g,v,C){const V=Math.cos(g),H=Math.sin(g);return this.set(h*V,h*H,-h*(V*v+H*C)+v+i,-f*H,f*V,-f*(-H*v+V*C)+C+l,0,0,1),this}scale(i,l){return this.premultiply(ku.makeScale(i,l)),this}rotate(i){return this.premultiply(ku.makeRotation(-i)),this}translate(i,l){return this.premultiply(ku.makeTranslation(i,l)),this}makeTranslation(i,l){return i.isVector2?this.set(1,0,i.x,0,1,i.y,0,0,1):this.set(1,0,i,0,1,l,0,0,1),this}makeRotation(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,-h,0,h,l,0,0,0,1),this}makeScale(i,l){return this.set(i,0,0,0,l,0,0,0,1),this}equals(i){const l=this.elements,h=i.elements;for(let f=0;f<9;f++)if(l[f]!==h[f])return!1;return!0}fromArray(i,l=0){for(let h=0;h<9;h++)this.elements[h]=i[h+l];return this}toArray(i=[],l=0){const h=this.elements;return i[l]=h[0],i[l+1]=h[1],i[l+2]=h[2],i[l+3]=h[3],i[l+4]=h[4],i[l+5]=h[5],i[l+6]=h[6],i[l+7]=h[7],i[l+8]=h[8],i}clone(){return new this.constructor().fromArray(this.elements)}}const ku=new ua,su=new ua().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),km=new ua().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zm(){const j={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(f,g,v){return this.enabled===!1||g===v||!g||!v||(this.spaces[g].transfer===Fi&&(f.r=Bl(f.r),f.g=Bl(f.g),f.b=Bl(f.b)),this.spaces[g].primaries!==this.spaces[v].primaries&&(f.applyMatrix3(this.spaces[g].toXYZ),f.applyMatrix3(this.spaces[v].fromXYZ)),this.spaces[v].transfer===Fi&&(f.r=Ic(f.r),f.g=Ic(f.g),f.b=Ic(f.b))),f},workingToColorSpace:function(f,g){return this.convert(f,this.workingColorSpace,g)},colorSpaceToWorking:function(f,g){return this.convert(f,g,this.workingColorSpace)},getPrimaries:function(f){return this.spaces[f].primaries},getTransfer:function(f){return f===Qo?ah:this.spaces[f].transfer},getToneMappingMode:function(f){return this.spaces[f].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(f,g=this.workingColorSpace){return f.fromArray(this.spaces[g].luminanceCoefficients)},define:function(f){Object.assign(this.spaces,f)},_getMatrix:function(f,g,v){return f.copy(this.spaces[g].toXYZ).multiply(this.spaces[v].fromXYZ)},_getDrawingBufferColorSpace:function(f){return this.spaces[f].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(f=this.workingColorSpace){return this.spaces[f].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(f,g){return Fl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),j.workingToColorSpace(f,g)},toWorkingColorSpace:function(f,g){return Fl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),j.colorSpaceToWorking(f,g)}},i=[.64,.33,.3,.6,.15,.06],l=[.2126,.7152,.0722],h=[.3127,.329];return j.define({[iu]:{primaries:i,whitePoint:h,transfer:ah,toXYZ:su,fromXYZ:km,luminanceCoefficients:l,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:i,whitePoint:h,transfer:Fi,toXYZ:su,fromXYZ:km,luminanceCoefficients:l,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),j}const wo=zm();function Bl(j){return j<.04045?j*.0773993808:Math.pow(j*.9478672986+.0521327014,2.4)}function Ic(j){return j<.0031308?j*12.92:1.055*Math.pow(j,.41666)-.055}let ou;class Wo{static getDataURL(i,l="image/png"){if(/^data:/i.test(i.src)||typeof HTMLCanvasElement=="undefined")return i.src;let h;if(i instanceof HTMLCanvasElement)h=i;else{ou===void 0&&(ou=lc("canvas")),ou.width=i.width,ou.height=i.height;const f=ou.getContext("2d");i instanceof ImageData?f.putImageData(i,0,0):f.drawImage(i,0,0,i.width,i.height),h=ou}return h.toDataURL(l)}static sRGBToLinear(i){if(typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap){const l=lc("canvas");l.width=i.width,l.height=i.height;const h=l.getContext("2d");h.drawImage(i,0,0,i.width,i.height);const f=h.getImageData(0,0,i.width,i.height),g=f.data;for(let v=0;v1),this.pmremVersion=0}get width(){return this.source.getSize(op).x}get height(){return this.source.getSize(op).y}get depth(){return this.source.getSize(op).z}get image(){return this.source.data}set image(i=null){this.source.data=i}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(i){return this.name=i.name,this.source=i.source,this.mipmaps=i.mipmaps.slice(0),this.mapping=i.mapping,this.channel=i.channel,this.wrapS=i.wrapS,this.wrapT=i.wrapT,this.magFilter=i.magFilter,this.minFilter=i.minFilter,this.anisotropy=i.anisotropy,this.format=i.format,this.internalFormat=i.internalFormat,this.type=i.type,this.offset.copy(i.offset),this.repeat.copy(i.repeat),this.center.copy(i.center),this.rotation=i.rotation,this.matrixAutoUpdate=i.matrixAutoUpdate,this.matrix.copy(i.matrix),this.generateMipmaps=i.generateMipmaps,this.premultiplyAlpha=i.premultiplyAlpha,this.flipY=i.flipY,this.unpackAlignment=i.unpackAlignment,this.colorSpace=i.colorSpace,this.renderTarget=i.renderTarget,this.isRenderTargetTexture=i.isRenderTargetTexture,this.isArrayTexture=i.isArrayTexture,this.userData=JSON.parse(JSON.stringify(i.userData)),this.needsUpdate=!0,this}setValues(i){for(const l in i){const h=i[l];if(h===void 0){_r(`Texture.setValues(): parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_r(`Texture.setValues(): property '${l}' does not exist.`);continue}f&&h&&f.isVector2&&h.isVector2||f&&h&&f.isVector3&&h.isVector3||f&&h&&f.isMatrix3&&h.isMatrix3?f.copy(h):this[l]=h}}toJSON(i){const l=i===void 0||typeof i=="string";if(!l&&i.textures[this.uuid]!==void 0)return i.textures[this.uuid];const h={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(i).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(h.userData=this.userData),l||(i.textures[this.uuid]=h),h}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(i){if(this.mapping!==te)return i;if(i.applyMatrix3(this.matrix),i.x<0||i.x>1)switch(this.wrapS){case lt:i.x=i.x-Math.floor(i.x);break;case qe:i.x=i.x<0?0:1;break;case pt:Math.abs(Math.floor(i.x)%2)===1?i.x=Math.ceil(i.x)-i.x:i.x=i.x-Math.floor(i.x);break}if(i.y<0||i.y>1)switch(this.wrapT){case lt:i.y=i.y-Math.floor(i.y);break;case qe:i.y=i.y<0?0:1;break;case pt:Math.abs(Math.floor(i.y)%2)===1?i.y=Math.ceil(i.y)-i.y:i.y=i.y-Math.floor(i.y);break}return this.flipY&&(i.y=1-i.y),i}set needsUpdate(i){i===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(i){i===!0&&this.pmremVersion++}}xl.DEFAULT_IMAGE=null,xl.DEFAULT_MAPPING=te,xl.DEFAULT_ANISOTROPY=1;class Ba{constructor(i=0,l=0,h=0,f=1){Ba.prototype.isVector4=!0,this.x=i,this.y=l,this.z=h,this.w=f}get width(){return this.z}set width(i){this.z=i}get height(){return this.w}set height(i){this.w=i}set(i,l,h,f){return this.x=i,this.y=l,this.z=h,this.w=f,this}setScalar(i){return this.x=i,this.y=i,this.z=i,this.w=i,this}setX(i){return this.x=i,this}setY(i){return this.y=i,this}setZ(i){return this.z=i,this}setW(i){return this.w=i,this}setComponent(i,l){switch(i){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;case 3:this.w=l;break;default:throw new Error("index is out of range: "+i)}return this}getComponent(i){switch(i){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+i)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(i){return this.x=i.x,this.y=i.y,this.z=i.z,this.w=i.w!==void 0?i.w:1,this}add(i){return this.x+=i.x,this.y+=i.y,this.z+=i.z,this.w+=i.w,this}addScalar(i){return this.x+=i,this.y+=i,this.z+=i,this.w+=i,this}addVectors(i,l){return this.x=i.x+l.x,this.y=i.y+l.y,this.z=i.z+l.z,this.w=i.w+l.w,this}addScaledVector(i,l){return this.x+=i.x*l,this.y+=i.y*l,this.z+=i.z*l,this.w+=i.w*l,this}sub(i){return this.x-=i.x,this.y-=i.y,this.z-=i.z,this.w-=i.w,this}subScalar(i){return this.x-=i,this.y-=i,this.z-=i,this.w-=i,this}subVectors(i,l){return this.x=i.x-l.x,this.y=i.y-l.y,this.z=i.z-l.z,this.w=i.w-l.w,this}multiply(i){return this.x*=i.x,this.y*=i.y,this.z*=i.z,this.w*=i.w,this}multiplyScalar(i){return this.x*=i,this.y*=i,this.z*=i,this.w*=i,this}applyMatrix4(i){const l=this.x,h=this.y,f=this.z,g=this.w,v=i.elements;return this.x=v[0]*l+v[4]*h+v[8]*f+v[12]*g,this.y=v[1]*l+v[5]*h+v[9]*f+v[13]*g,this.z=v[2]*l+v[6]*h+v[10]*f+v[14]*g,this.w=v[3]*l+v[7]*h+v[11]*f+v[15]*g,this}divide(i){return this.x/=i.x,this.y/=i.y,this.z/=i.z,this.w/=i.w,this}divideScalar(i){return this.multiplyScalar(1/i)}setAxisAngleFromQuaternion(i){this.w=2*Math.acos(i.w);const l=Math.sqrt(1-i.w*i.w);return l<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=i.x/l,this.y=i.y/l,this.z=i.z/l),this}setAxisAngleFromRotationMatrix(i){let l,h,f,g;const V=i.elements,H=V[0],J=V[4],he=V[8],pe=V[1],me=V[5],Se=V[9],tt=V[2],gt=V[6],mt=V[10];if(Math.abs(J-pe)<.01&&Math.abs(he-tt)<.01&&Math.abs(Se-gt)<.01){if(Math.abs(J+pe)<.1&&Math.abs(he+tt)<.1&&Math.abs(Se+gt)<.1&&Math.abs(H+me+mt-3)<.1)return this.set(1,0,0,0),this;l=Math.PI;const Pt=(H+1)/2,Wt=(me+1)/2,gn=(mt+1)/2,Sn=(J+pe)/4,kn=(he+tt)/4,In=(Se+gt)/4;return Pt>Wt&&Pt>gn?Pt<.01?(h=0,f=.707106781,g=.707106781):(h=Math.sqrt(Pt),f=Sn/h,g=kn/h):Wt>gn?Wt<.01?(h=.707106781,f=0,g=.707106781):(f=Math.sqrt(Wt),h=Sn/f,g=In/f):gn<.01?(h=.707106781,f=.707106781,g=0):(g=Math.sqrt(gn),h=kn/g,f=In/g),this.set(h,f,g,l),this}let Nt=Math.sqrt((gt-Se)*(gt-Se)+(he-tt)*(he-tt)+(pe-J)*(pe-J));return Math.abs(Nt)<.001&&(Nt=1),this.x=(gt-Se)/Nt,this.y=(he-tt)/Nt,this.z=(pe-J)/Nt,this.w=Math.acos((H+me+mt-1)/2),this}setFromMatrixPosition(i){const l=i.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this.w=l[15],this}min(i){return this.x=Math.min(this.x,i.x),this.y=Math.min(this.y,i.y),this.z=Math.min(this.z,i.z),this.w=Math.min(this.w,i.w),this}max(i){return this.x=Math.max(this.x,i.x),this.y=Math.max(this.y,i.y),this.z=Math.max(this.z,i.z),this.w=Math.max(this.w,i.w),this}clamp(i,l){return this.x=Fr(this.x,i.x,l.x),this.y=Fr(this.y,i.y,l.y),this.z=Fr(this.z,i.z,l.z),this.w=Fr(this.w,i.w,l.w),this}clampScalar(i,l){return this.x=Fr(this.x,i,l),this.y=Fr(this.y,i,l),this.z=Fr(this.z,i,l),this.w=Fr(this.w,i,l),this}clampLength(i,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Fr(h,i,l))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(i){return this.x*i.x+this.y*i.y+this.z*i.z+this.w*i.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(i){return this.normalize().multiplyScalar(i)}lerp(i,l){return this.x+=(i.x-this.x)*l,this.y+=(i.y-this.y)*l,this.z+=(i.z-this.z)*l,this.w+=(i.w-this.w)*l,this}lerpVectors(i,l,h){return this.x=i.x+(l.x-i.x)*h,this.y=i.y+(l.y-i.y)*h,this.z=i.z+(l.z-i.z)*h,this.w=i.w+(l.w-i.w)*h,this}equals(i){return i.x===this.x&&i.y===this.y&&i.z===this.z&&i.w===this.w}fromArray(i,l=0){return this.x=i[l],this.y=i[l+1],this.z=i[l+2],this.w=i[l+3],this}toArray(i=[],l=0){return i[l]=this.x,i[l+1]=this.y,i[l+2]=this.z,i[l+3]=this.w,i}fromBufferAttribute(i,l){return this.x=i.getX(l),this.y=i.getY(l),this.z=i.getZ(l),this.w=i.getW(l),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ha extends null{constructor(i=1,l=1,h={}){super(),h=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},h),this.isRenderTarget=!0,this.width=i,this.height=l,this.depth=h.depth,this.scissor=new Ba(0,0,i,l),this.scissorTest=!1,this.viewport=new Ba(0,0,i,l);const f={width:i,height:l,depth:h.depth},g=new xl(f);this.textures=[];const v=h.count;for(let C=0;C1);this.dispose()}this.viewport.set(0,0,i,l),this.scissor.set(0,0,i,l)}clone(){return new this.constructor().copy(this)}copy(i){this.width=i.width,this.height=i.height,this.depth=i.depth,this.scissor.copy(i.scissor),this.scissorTest=i.scissorTest,this.viewport.copy(i.viewport),this.textures.length=0;for(let l=0,h=i.textures.length;l=this.min.x&&i.x<=this.max.x&&i.y>=this.min.y&&i.y<=this.max.y&&i.z>=this.min.z&&i.z<=this.max.z}containsBox(i){return this.min.x<=i.min.x&&i.max.x<=this.max.x&&this.min.y<=i.min.y&&i.max.y<=this.max.y&&this.min.z<=i.min.z&&i.max.z<=this.max.z}getParameter(i,l){return l.set((i.x-this.min.x)/(this.max.x-this.min.x),(i.y-this.min.y)/(this.max.y-this.min.y),(i.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(i){return i.max.x>=this.min.x&&i.min.x<=this.max.x&&i.max.y>=this.min.y&&i.min.y<=this.max.y&&i.max.z>=this.min.z&&i.min.z<=this.max.z}intersectsSphere(i){return this.clampPoint(i.center,ba),ba.distanceToSquared(i.center)<=i.radius*i.radius}intersectsPlane(i){let l,h;return i.normal.x>0?(l=i.normal.x*this.min.x,h=i.normal.x*this.max.x):(l=i.normal.x*this.max.x,h=i.normal.x*this.min.x),i.normal.y>0?(l+=i.normal.y*this.min.y,h+=i.normal.y*this.max.y):(l+=i.normal.y*this.max.y,h+=i.normal.y*this.min.y),i.normal.z>0?(l+=i.normal.z*this.min.z,h+=i.normal.z*this.max.z):(l+=i.normal.z*this.max.z,h+=i.normal.z*this.min.z),l<=-i.constant&&h>=-i.constant}intersectsTriangle(i){if(this.isEmpty())return!1;this.getCenter(Z),le.subVectors(this.max,Z),hc.subVectors(i.a,Z),Lc.subVectors(i.b,Z),Dc.subVectors(i.c,Z),Tl.subVectors(Lc,hc),se.subVectors(Dc,Lc),$.subVectors(hc,Dc);let l=[0,-Tl.z,Tl.y,0,-se.z,se.y,0,-$.z,$.y,Tl.z,0,-Tl.x,se.z,0,-se.x,$.z,0,-$.x,-Tl.y,Tl.x,0,-se.y,se.x,0,-$.y,$.x,0];return!Ge(l,hc,Lc,Dc,le)||(l=[1,0,0,0,1,0,0,0,1],!Ge(l,hc,Lc,Dc,le))?!1:(we.crossVectors(Tl,se),l=[we.x,we.y,we.z],Ge(l,hc,Lc,Dc,le))}clampPoint(i,l){return l.copy(i).clamp(this.min,this.max)}distanceToPoint(i){return this.clampPoint(i,ba).distanceTo(i)}getBoundingSphere(i){return this.isEmpty()?i.makeEmpty():(this.getCenter(i.center),i.radius=this.getSize(ba).length()*.5),i}intersect(i){return this.min.max(i.min),this.max.min(i.max),this.isEmpty()&&this.makeEmpty(),this}union(i){return this.min.min(i.min),this.max.max(i.max),this}applyMatrix4(i){return this.isEmpty()?this:(Ua[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(i),Ua[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(i),Ua[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(i),Ua[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(i),Ua[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(i),Ua[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(i),Ua[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(i),Ua[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(i),this.setFromPoints(Ua),this)}translate(i){return this.min.add(i),this.max.add(i),this}equals(i){return i.min.equals(this.min)&&i.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(i){return this.min.fromArray(i.min),this.max.fromArray(i.max),this}}const Ua=[new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt],ba=new Rt,uc=new ta,hc=new Rt,Lc=new Rt,Dc=new Rt,Tl=new Rt,se=new Rt,$=new Rt,Z=new Rt,le=new Rt,we=new Rt,Re=new Rt;function Ge(j,i,l,h,f){for(let g=0,v=j.length-3;g<=v;g+=3){Re.fromArray(j,g);const C=f.x*Math.abs(Re.x)+f.y*Math.abs(Re.y)+f.z*Math.abs(Re.z),V=i.dot(Re),H=l.dot(Re),J=h.dot(Re);if(Math.max(-Math.max(V,H,J),Math.min(V,H,J))>C)return!1}return!0}const wt=new ta,Tt=new Rt,Lt=new Rt;class Gt{constructor(i=new Rt,l=-1){this.isSphere=!0,this.center=i,this.radius=l}set(i,l){return this.center.copy(i),this.radius=l,this}setFromPoints(i,l){const h=this.center;l!==void 0?h.copy(l):wt.setFromPoints(i).getCenter(h);let f=0;for(let g=0,v=i.length;gthis.radius*this.radius&&(l.sub(this.center).normalize(),l.multiplyScalar(this.radius).add(this.center)),l}getBoundingBox(i){return this.isEmpty()?(i.makeEmpty(),i):(i.set(this.center,this.center),i.expandByScalar(this.radius),i)}applyMatrix4(i){return this.center.applyMatrix4(i),this.radius=this.radius*i.getMaxScaleOnAxis(),this}translate(i){return this.center.add(i),this}expandByPoint(i){if(this.isEmpty())return this.center.copy(i),this.radius=0,this;Tt.subVectors(i,this.center);const l=Tt.lengthSq();if(l>this.radius*this.radius){const h=Math.sqrt(l),f=(h-this.radius)*.5;this.center.addScaledVector(Tt,f/h),this.radius+=f}return this}union(i){return i.isEmpty()?this:this.isEmpty()?(this.copy(i),this):(this.center.equals(i.center)===!0?this.radius=Math.max(this.radius,i.radius):(Lt.subVectors(i.center,this.center).setLength(i.radius),this.expandByPoint(Tt.copy(i.center).add(Lt)),this.expandByPoint(Tt.copy(i.center).sub(Lt))),this)}equals(i){return i.center.equals(this.center)&&i.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(i){return this.radius=i.radius,this.center.fromArray(i.center),this}}const $t=new Rt,hn=new Rt,Ft=new Rt,_n=new Rt,Nn=new Rt,Pn=new Rt,ei=new Rt;class ai{constructor(i=new Rt,l=new Rt(0,0,-1)){this.origin=i,this.direction=l}set(i,l){return this.origin.copy(i),this.direction.copy(l),this}copy(i){return this.origin.copy(i.origin),this.direction.copy(i.direction),this}at(i,l){return l.copy(this.origin).addScaledVector(this.direction,i)}lookAt(i){return this.direction.copy(i).sub(this.origin).normalize(),this}recast(i){return this.origin.copy(this.at(i,$t)),this}closestPointToPoint(i,l){l.subVectors(i,this.origin);const h=l.dot(this.direction);return h<0?l.copy(this.origin):l.copy(this.origin).addScaledVector(this.direction,h)}distanceToPoint(i){return Math.sqrt(this.distanceSqToPoint(i))}distanceSqToPoint(i){const l=$t.subVectors(i,this.origin).dot(this.direction);return l<0?this.origin.distanceToSquared(i):($t.copy(this.origin).addScaledVector(this.direction,l),$t.distanceToSquared(i))}distanceSqToSegment(i,l,h,f){hn.copy(i).add(l).multiplyScalar(.5),Ft.copy(l).sub(i).normalize(),_n.copy(this.origin).sub(hn);const g=i.distanceTo(l)*.5,v=-this.direction.dot(Ft),C=_n.dot(this.direction),V=-_n.dot(Ft),H=_n.lengthSq(),J=Math.abs(1-v*v);let he,pe,me,Se;if(J>0)if(he=v*V-C,pe=v*C-V,Se=g*J,he>=0)if(pe>=-Se)if(pe<=Se){const tt=1/J;he*=tt,pe*=tt,me=he*(he+v*pe+2*C)+pe*(v*he+pe+2*V)+H}else pe=g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;else pe=-g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;else pe<=-Se?(he=Math.max(0,-(-v*g+C)),pe=he>0?-g:Math.min(Math.max(-g,-V),g),me=-he*he+pe*(pe+2*V)+H):pe<=Se?(he=0,pe=Math.min(Math.max(-g,-V),g),me=pe*(pe+2*V)+H):(he=Math.max(0,-(v*g+C)),pe=he>0?g:Math.min(Math.max(-g,-V),g),me=-he*he+pe*(pe+2*V)+H);else pe=v>0?-g:g,he=Math.max(0,-(v*pe+C)),me=-he*he+pe*(pe+2*V)+H;return h&&h.copy(this.origin).addScaledVector(this.direction,he),f&&f.copy(hn).addScaledVector(Ft,pe),me}intersectSphere(i,l){$t.subVectors(i.center,this.origin);const h=$t.dot(this.direction),f=$t.dot($t)-h*h,g=i.radius*i.radius;if(f>g)return null;const v=Math.sqrt(g-f),C=h-v,V=h+v;return V<0?null:C<0?this.at(V,l):this.at(C,l)}intersectsSphere(i){return i.radius<0?!1:this.distanceSqToPoint(i.center)<=i.radius*i.radius}distanceToPlane(i){const l=i.normal.dot(this.direction);if(l===0)return i.distanceToPoint(this.origin)===0?0:null;const h=-(this.origin.dot(i.normal)+i.constant)/l;return h>=0?h:null}intersectPlane(i,l){const h=this.distanceToPlane(i);return h===null?null:this.at(h,l)}intersectsPlane(i){const l=i.distanceToPoint(this.origin);return l===0||i.normal.dot(this.direction)*l<0}intersectBox(i,l){let h,f,g,v,C,V;const H=1/this.direction.x,J=1/this.direction.y,he=1/this.direction.z,pe=this.origin;return H>=0?(h=(i.min.x-pe.x)*H,f=(i.max.x-pe.x)*H):(h=(i.max.x-pe.x)*H,f=(i.min.x-pe.x)*H),J>=0?(g=(i.min.y-pe.y)*J,v=(i.max.y-pe.y)*J):(g=(i.max.y-pe.y)*J,v=(i.min.y-pe.y)*J),h>v||g>f||((g>h||isNaN(h))&&(h=g),(v=0?(C=(i.min.z-pe.z)*he,V=(i.max.z-pe.z)*he):(C=(i.max.z-pe.z)*he,V=(i.min.z-pe.z)*he),h>V||C>f)||((C>h||h!==h)&&(h=C),(V=0?h:f,l)}intersectsBox(i){return this.intersectBox(i,$t)!==null}intersectTriangle(i,l,h,f,g){Nn.subVectors(l,i),Pn.subVectors(h,i),ei.crossVectors(Nn,Pn);let v=this.direction.dot(ei),C;if(v>0){if(f)return null;C=1}else if(v<0)C=-1,v=-v;else return null;_n.subVectors(this.origin,i);const V=C*this.direction.dot(Pn.crossVectors(_n,Pn));if(V<0)return null;const H=C*this.direction.dot(Nn.cross(_n));if(H<0||V+H>v)return null;const J=-C*_n.dot(ei);return J<0?null:this.at(J/v,g)}applyMatrix4(i){return this.origin.applyMatrix4(i),this.direction.transformDirection(i),this}equals(i){return i.origin.equals(this.origin)&&i.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class On{constructor(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt){On.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],i!==void 0&&this.set(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt)}set(i,l,h,f,g,v,C,V,H,J,he,pe,me,Se,tt,gt){const mt=this.elements;return mt[0]=i,mt[4]=l,mt[8]=h,mt[12]=f,mt[1]=g,mt[5]=v,mt[9]=C,mt[13]=V,mt[2]=H,mt[6]=J,mt[10]=he,mt[14]=pe,mt[3]=me,mt[7]=Se,mt[11]=tt,mt[15]=gt,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new On().fromArray(this.elements)}copy(i){const l=this.elements,h=i.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],l[9]=h[9],l[10]=h[10],l[11]=h[11],l[12]=h[12],l[13]=h[13],l[14]=h[14],l[15]=h[15],this}copyPosition(i){const l=this.elements,h=i.elements;return l[12]=h[12],l[13]=h[13],l[14]=h[14],this}setFromMatrix3(i){const l=i.elements;return this.set(l[0],l[3],l[6],0,l[1],l[4],l[7],0,l[2],l[5],l[8],0,0,0,0,1),this}extractBasis(i,l,h){return i.setFromMatrixColumn(this,0),l.setFromMatrixColumn(this,1),h.setFromMatrixColumn(this,2),this}makeBasis(i,l,h){return this.set(i.x,l.x,h.x,0,i.y,l.y,h.y,0,i.z,l.z,h.z,0,0,0,0,1),this}extractRotation(i){const l=this.elements,h=i.elements,f=1/di.setFromMatrixColumn(i,0).length(),g=1/di.setFromMatrixColumn(i,1).length(),v=1/di.setFromMatrixColumn(i,2).length();return l[0]=h[0]*f,l[1]=h[1]*f,l[2]=h[2]*f,l[3]=0,l[4]=h[4]*g,l[5]=h[5]*g,l[6]=h[6]*g,l[7]=0,l[8]=h[8]*v,l[9]=h[9]*v,l[10]=h[10]*v,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromEuler(i){const l=this.elements,h=i.x,f=i.y,g=i.z,v=Math.cos(h),C=Math.sin(h),V=Math.cos(f),H=Math.sin(f),J=Math.cos(g),he=Math.sin(g);if(i.order==="XYZ"){const pe=v*J,me=v*he,Se=C*J,tt=C*he;l[0]=V*J,l[4]=-V*he,l[8]=H,l[1]=me+Se*H,l[5]=pe-tt*H,l[9]=-C*V,l[2]=tt-pe*H,l[6]=Se+me*H,l[10]=v*V}else if(i.order==="YXZ"){const pe=V*J,me=V*he,Se=H*J,tt=H*he;l[0]=pe+tt*C,l[4]=Se*C-me,l[8]=v*H,l[1]=v*he,l[5]=v*J,l[9]=-C,l[2]=me*C-Se,l[6]=tt+pe*C,l[10]=v*V}else if(i.order==="ZXY"){const pe=V*J,me=V*he,Se=H*J,tt=H*he;l[0]=pe-tt*C,l[4]=-v*he,l[8]=Se+me*C,l[1]=me+Se*C,l[5]=v*J,l[9]=tt-pe*C,l[2]=-v*H,l[6]=C,l[10]=v*V}else if(i.order==="ZYX"){const pe=v*J,me=v*he,Se=C*J,tt=C*he;l[0]=V*J,l[4]=Se*H-me,l[8]=pe*H+tt,l[1]=V*he,l[5]=tt*H+pe,l[9]=me*H-Se,l[2]=-H,l[6]=C*V,l[10]=v*V}else if(i.order==="YZX"){const pe=v*V,me=v*H,Se=C*V,tt=C*H;l[0]=V*J,l[4]=tt-pe*he,l[8]=Se*he+me,l[1]=he,l[5]=v*J,l[9]=-C*J,l[2]=-H*J,l[6]=me*he+Se,l[10]=pe-tt*he}else if(i.order==="XZY"){const pe=v*V,me=v*H,Se=C*V,tt=C*H;l[0]=V*J,l[4]=-he,l[8]=H*J,l[1]=pe*he+tt,l[5]=v*J,l[9]=me*he-Se,l[2]=Se*he-me,l[6]=C*J,l[10]=tt*he+pe}return l[3]=0,l[7]=0,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromQuaternion(i){return this.compose(ji,i,Qi)}lookAt(i,l,h){const f=this.elements;return yr.subVectors(i,l),yr.lengthSq()===0&&(yr.z=1),yr.normalize(),er.crossVectors(h,yr),er.lengthSq()===0&&(Math.abs(h.z)===1?yr.x+=1e-4:yr.z+=1e-4,yr.normalize(),er.crossVectors(h,yr)),er.normalize(),gr.crossVectors(yr,er),f[0]=er.x,f[4]=gr.x,f[8]=yr.x,f[1]=er.y,f[5]=gr.y,f[9]=yr.y,f[2]=er.z,f[6]=gr.z,f[10]=yr.z,this}multiply(i){return this.multiplyMatrices(this,i)}premultiply(i){return this.multiplyMatrices(i,this)}multiplyMatrices(i,l){const h=i.elements,f=l.elements,g=this.elements,v=h[0],C=h[4],V=h[8],H=h[12],J=h[1],he=h[5],pe=h[9],me=h[13],Se=h[2],tt=h[6],gt=h[10],mt=h[14],Nt=h[3],Pt=h[7],Wt=h[11],gn=h[15],Sn=f[0],kn=f[4],In=f[8],ii=f[12],li=f[1],dr=f[5],Yr=f[9],Ss=f[13],eo=f[2],uo=f[6],Aa=f[10],hl=f[14],tc=f[3],Xo=f[7],Ca=f[11],qo=f[15];return g[0]=v*Sn+C*li+V*eo+H*tc,g[4]=v*kn+C*dr+V*uo+H*Xo,g[8]=v*In+C*Yr+V*Aa+H*Ca,g[12]=v*ii+C*Ss+V*hl+H*qo,g[1]=J*Sn+he*li+pe*eo+me*tc,g[5]=J*kn+he*dr+pe*uo+me*Xo,g[9]=J*In+he*Yr+pe*Aa+me*Ca,g[13]=J*ii+he*Ss+pe*hl+me*qo,g[2]=Se*Sn+tt*li+gt*eo+mt*tc,g[6]=Se*kn+tt*dr+gt*uo+mt*Xo,g[10]=Se*In+tt*Yr+gt*Aa+mt*Ca,g[14]=Se*ii+tt*Ss+gt*hl+mt*qo,g[3]=Nt*Sn+Pt*li+Wt*eo+gn*tc,g[7]=Nt*kn+Pt*dr+Wt*uo+gn*Xo,g[11]=Nt*In+Pt*Yr+Wt*Aa+gn*Ca,g[15]=Nt*ii+Pt*Ss+Wt*hl+gn*qo,this}multiplyScalar(i){const l=this.elements;return l[0]*=i,l[4]*=i,l[8]*=i,l[12]*=i,l[1]*=i,l[5]*=i,l[9]*=i,l[13]*=i,l[2]*=i,l[6]*=i,l[10]*=i,l[14]*=i,l[3]*=i,l[7]*=i,l[11]*=i,l[15]*=i,this}determinant(){const i=this.elements,l=i[0],h=i[4],f=i[8],g=i[12],v=i[1],C=i[5],V=i[9],H=i[13],J=i[2],he=i[6],pe=i[10],me=i[14],Se=i[3],tt=i[7],gt=i[11],mt=i[15];return Se*(+g*V*he-f*H*he-g*C*pe+h*H*pe+f*C*me-h*V*me)+tt*(+l*V*me-l*H*pe+g*v*pe-f*v*me+f*H*J-g*V*J)+gt*(+l*H*he-l*C*me-g*v*he+h*v*me+g*C*J-h*H*J)+mt*(-f*C*J-l*V*he+l*C*pe+f*v*he-h*v*pe+h*V*J)}transpose(){const i=this.elements;let l;return l=i[1],i[1]=i[4],i[4]=l,l=i[2],i[2]=i[8],i[8]=l,l=i[6],i[6]=i[9],i[9]=l,l=i[3],i[3]=i[12],i[12]=l,l=i[7],i[7]=i[13],i[13]=l,l=i[11],i[11]=i[14],i[14]=l,this}setPosition(i,l,h){const f=this.elements;return i.isVector3?(f[12]=i.x,f[13]=i.y,f[14]=i.z):(f[12]=i,f[13]=l,f[14]=h),this}invert(){const i=this.elements,l=i[0],h=i[1],f=i[2],g=i[3],v=i[4],C=i[5],V=i[6],H=i[7],J=i[8],he=i[9],pe=i[10],me=i[11],Se=i[12],tt=i[13],gt=i[14],mt=i[15],Nt=he*gt*H-tt*pe*H+tt*V*me-C*gt*me-he*V*mt+C*pe*mt,Pt=Se*pe*H-J*gt*H-Se*V*me+v*gt*me+J*V*mt-v*pe*mt,Wt=J*tt*H-Se*he*H+Se*C*me-v*tt*me-J*C*mt+v*he*mt,gn=Se*he*V-J*tt*V-Se*C*pe+v*tt*pe+J*C*gt-v*he*gt,Sn=l*Nt+h*Pt+f*Wt+g*gn;if(Sn===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const kn=1/Sn;return i[0]=Nt*kn,i[1]=(tt*pe*g-he*gt*g-tt*f*me+h*gt*me+he*f*mt-h*pe*mt)*kn,i[2]=(C*gt*g-tt*V*g+tt*f*H-h*gt*H-C*f*mt+h*V*mt)*kn,i[3]=(he*V*g-C*pe*g-he*f*H+h*pe*H+C*f*me-h*V*me)*kn,i[4]=Pt*kn,i[5]=(J*gt*g-Se*pe*g+Se*f*me-l*gt*me-J*f*mt+l*pe*mt)*kn,i[6]=(Se*V*g-v*gt*g-Se*f*H+l*gt*H+v*f*mt-l*V*mt)*kn,i[7]=(v*pe*g-J*V*g+J*f*H-l*pe*H-v*f*me+l*V*me)*kn,i[8]=Wt*kn,i[9]=(Se*he*g-J*tt*g-Se*h*me+l*tt*me+J*h*mt-l*he*mt)*kn,i[10]=(v*tt*g-Se*C*g+Se*h*H-l*tt*H-v*h*mt+l*C*mt)*kn,i[11]=(J*C*g-v*he*g-J*h*H+l*he*H+v*h*me-l*C*me)*kn,i[12]=gn*kn,i[13]=(J*tt*f-Se*he*f+Se*h*pe-l*tt*pe-J*h*gt+l*he*gt)*kn,i[14]=(Se*C*f-v*tt*f-Se*h*V+l*tt*V+v*h*gt-l*C*gt)*kn,i[15]=(v*he*f-J*C*f+J*h*V-l*he*V-v*h*pe+l*C*pe)*kn,this}scale(i){const l=this.elements,h=i.x,f=i.y,g=i.z;return l[0]*=h,l[4]*=f,l[8]*=g,l[1]*=h,l[5]*=f,l[9]*=g,l[2]*=h,l[6]*=f,l[10]*=g,l[3]*=h,l[7]*=f,l[11]*=g,this}getMaxScaleOnAxis(){const i=this.elements,l=i[0]*i[0]+i[1]*i[1]+i[2]*i[2],h=i[4]*i[4]+i[5]*i[5]+i[6]*i[6],f=i[8]*i[8]+i[9]*i[9]+i[10]*i[10];return Math.sqrt(Math.max(l,h,f))}makeTranslation(i,l,h){return i.isVector3?this.set(1,0,0,i.x,0,1,0,i.y,0,0,1,i.z,0,0,0,1):this.set(1,0,0,i,0,1,0,l,0,0,1,h,0,0,0,1),this}makeRotationX(i){const l=Math.cos(i),h=Math.sin(i);return this.set(1,0,0,0,0,l,-h,0,0,h,l,0,0,0,0,1),this}makeRotationY(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,0,h,0,0,1,0,0,-h,0,l,0,0,0,0,1),this}makeRotationZ(i){const l=Math.cos(i),h=Math.sin(i);return this.set(l,-h,0,0,h,l,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(i,l){const h=Math.cos(l),f=Math.sin(l),g=1-h,v=i.x,C=i.y,V=i.z,H=g*v,J=g*C;return this.set(H*v+h,H*C-f*V,H*V+f*C,0,H*C+f*V,J*C+h,J*V-f*v,0,H*V-f*C,J*V+f*v,g*V*V+h,0,0,0,0,1),this}makeScale(i,l,h){return this.set(i,0,0,0,0,l,0,0,0,0,h,0,0,0,0,1),this}makeShear(i,l,h,f,g,v){return this.set(1,h,g,0,i,1,v,0,l,f,1,0,0,0,0,1),this}compose(i,l,h){const f=this.elements,g=l._x,v=l._y,C=l._z,V=l._w,H=g+g,J=v+v,he=C+C,pe=g*H,me=g*J,Se=g*he,tt=v*J,gt=v*he,mt=C*he,Nt=V*H,Pt=V*J,Wt=V*he,gn=h.x,Sn=h.y,kn=h.z;return f[0]=(1-(tt+mt))*gn,f[1]=(me+Wt)*gn,f[2]=(Se-Pt)*gn,f[3]=0,f[4]=(me-Wt)*Sn,f[5]=(1-(pe+mt))*Sn,f[6]=(gt+Nt)*Sn,f[7]=0,f[8]=(Se+Pt)*kn,f[9]=(gt-Nt)*kn,f[10]=(1-(pe+tt))*kn,f[11]=0,f[12]=i.x,f[13]=i.y,f[14]=i.z,f[15]=1,this}decompose(i,l,h){const f=this.elements;let g=di.set(f[0],f[1],f[2]).length();const v=di.set(f[4],f[5],f[6]).length(),C=di.set(f[8],f[9],f[10]).length();this.determinant()<0&&(g=-g),i.x=f[12],i.y=f[13],i.z=f[14],Ri.copy(this);const H=1/g,J=1/v,he=1/C;return Ri.elements[0]*=H,Ri.elements[1]*=H,Ri.elements[2]*=H,Ri.elements[4]*=J,Ri.elements[5]*=J,Ri.elements[6]*=J,Ri.elements[8]*=he,Ri.elements[9]*=he,Ri.elements[10]*=he,l.setFromRotationMatrix(Ri),h.x=g,h.y=v,h.z=C,this}makePerspective(i,l,h,f,g,v,C=so,V=!1){const H=this.elements,J=2*g/(l-i),he=2*g/(h-f),pe=(l+i)/(l-i),me=(h+f)/(h-f);let Se,tt;if(V)Se=g/(v-g),tt=v*g/(v-g);else if(C===so)Se=-(v+g)/(v-g),tt=-2*v*g/(v-g);else if(C===ja)Se=-v/(v-g),tt=-v*g/(v-g);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+C);return H[0]=J,H[4]=0,H[8]=pe,H[12]=0,H[1]=0,H[5]=he,H[9]=me,H[13]=0,H[2]=0,H[6]=0,H[10]=Se,H[14]=tt,H[3]=0,H[7]=0,H[11]=-1,H[15]=0,this}makeOrthographic(i,l,h,f,g,v,C=so,V=!1){const H=this.elements,J=2/(l-i),he=2/(h-f),pe=-(l+i)/(l-i),me=-(h+f)/(h-f);let Se,tt;if(V)Se=1/(v-g),tt=v/(v-g);else if(C===so)Se=-2/(v-g),tt=-(v+g)/(v-g);else if(C===ja)Se=-1/(v-g),tt=-g/(v-g);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+C);return H[0]=J,H[4]=0,H[8]=0,H[12]=pe,H[1]=0,H[5]=he,H[9]=0,H[13]=me,H[2]=0,H[6]=0,H[10]=Se,H[14]=tt,H[3]=0,H[7]=0,H[11]=0,H[15]=1,this}equals(i){const l=this.elements,h=i.elements;for(let f=0;f<16;f++)if(l[f]!==h[f])return!1;return!0}fromArray(i,l=0){for(let h=0;h<16;h++)this.elements[h]=i[h+l];return this}toArray(i=[],l=0){const h=this.elements;return i[l]=h[0],i[l+1]=h[1],i[l+2]=h[2],i[l+3]=h[3],i[l+4]=h[4],i[l+5]=h[5],i[l+6]=h[6],i[l+7]=h[7],i[l+8]=h[8],i[l+9]=h[9],i[l+10]=h[10],i[l+11]=h[11],i[l+12]=h[12],i[l+13]=h[13],i[l+14]=h[14],i[l+15]=h[15],i}}const di=new Rt,Ri=new On,ji=new Rt(0,0,0),Qi=new Rt(1,1,1),er=new Rt,gr=new Rt,yr=new Rt,Nr=new On,Ji=new vl;class cs{constructor(i=0,l=0,h=0,f=cs.DEFAULT_ORDER){this.isEuler=!0,this._x=i,this._y=l,this._z=h,this._order=f}get x(){return this._x}set x(i){this._x=i,this._onChangeCallback()}get y(){return this._y}set y(i){this._y=i,this._onChangeCallback()}get z(){return this._z}set z(i){this._z=i,this._onChangeCallback()}get order(){return this._order}set order(i){this._order=i,this._onChangeCallback()}set(i,l,h,f=this._order){return this._x=i,this._y=l,this._z=h,this._order=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(i){return this._x=i._x,this._y=i._y,this._z=i._z,this._order=i._order,this._onChangeCallback(),this}setFromRotationMatrix(i,l=this._order,h=!0){const f=i.elements,g=f[0],v=f[4],C=f[8],V=f[1],H=f[5],J=f[9],he=f[2],pe=f[6],me=f[10];switch(l){case"XYZ":this._y=Math.asin(Fr(C,-1,1)),Math.abs(C)<.9999999?(this._x=Math.atan2(-J,me),this._z=Math.atan2(-v,g)):(this._x=Math.atan2(pe,H),this._z=0);break;case"YXZ":this._x=Math.asin(-Fr(J,-1,1)),Math.abs(J)<.9999999?(this._y=Math.atan2(C,me),this._z=Math.atan2(V,H)):(this._y=Math.atan2(-he,g),this._z=0);break;case"ZXY":this._x=Math.asin(Fr(pe,-1,1)),Math.abs(pe)<.9999999?(this._y=Math.atan2(-he,me),this._z=Math.atan2(-v,H)):(this._y=0,this._z=Math.atan2(V,g));break;case"ZYX":this._y=Math.asin(-Fr(he,-1,1)),Math.abs(he)<.9999999?(this._x=Math.atan2(pe,me),this._z=Math.atan2(V,g)):(this._x=0,this._z=Math.atan2(-v,H));break;case"YZX":this._z=Math.asin(Fr(V,-1,1)),Math.abs(V)<.9999999?(this._x=Math.atan2(-J,H),this._y=Math.atan2(-he,g)):(this._x=0,this._y=Math.atan2(C,me));break;case"XZY":this._z=Math.asin(-Fr(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(pe,H),this._y=Math.atan2(C,g)):(this._x=Math.atan2(-J,me),this._y=0);break;default:_r("Euler: .setFromRotationMatrix() encountered an unknown order: "+l)}return this._order=l,h===!0&&this._onChangeCallback(),this}setFromQuaternion(i,l,h){return Nr.makeRotationFromQuaternion(i),this.setFromRotationMatrix(Nr,l,h)}setFromVector3(i,l=this._order){return this.set(i.x,i.y,i.z,l)}reorder(i){return Ji.setFromEuler(this),this.setFromQuaternion(Ji,i)}equals(i){return i._x===this._x&&i._y===this._y&&i._z===this._z&&i._order===this._order}fromArray(i){return this._x=i[0],this._y=i[1],this._z=i[2],i[3]!==void 0&&(this._order=i[3]),this._onChangeCallback(),this}toArray(i=[],l=0){return i[l]=this._x,i[l+1]=this._y,i[l+2]=this._z,i[l+3]=this._order,i}_onChange(i){return this._onChangeCallback=i,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}cs.DEFAULT_ORDER="XYZ";class ds{constructor(){this.mask=1}set(i){this.mask=(1<>>0}enable(i){this.mask|=1<1){for(let l=0;l1){for(let h=0;h0&&(f.userData=this.userData),f.layers=this.layers.mask,f.matrix=this.matrix.toArray(),f.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(f.matrixAutoUpdate=!1),this.isInstancedMesh&&(f.type="InstancedMesh",f.count=this.count,f.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(f.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(f.type="BatchedMesh",f.perObjectFrustumCulled=this.perObjectFrustumCulled,f.sortObjects=this.sortObjects,f.drawRanges=this._drawRanges,f.reservedRanges=this._reservedRanges,f.geometryInfo=this._geometryInfo.map(C=>ac(qs({},C),{boundingBox:C.boundingBox?C.boundingBox.toJSON():void 0,boundingSphere:C.boundingSphere?C.boundingSphere.toJSON():void 0})),f.instanceInfo=this._instanceInfo.map(C=>qs({},C)),f.availableInstanceIds=this._availableInstanceIds.slice(),f.availableGeometryIds=this._availableGeometryIds.slice(),f.nextIndexStart=this._nextIndexStart,f.nextVertexStart=this._nextVertexStart,f.geometryCount=this._geometryCount,f.maxInstanceCount=this._maxInstanceCount,f.maxVertexCount=this._maxVertexCount,f.maxIndexCount=this._maxIndexCount,f.geometryInitialized=this._geometryInitialized,f.matricesTexture=this._matricesTexture.toJSON(i),f.indirectTexture=this._indirectTexture.toJSON(i),this._colorsTexture!==null&&(f.colorsTexture=this._colorsTexture.toJSON(i)),this.boundingSphere!==null&&(f.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(f.boundingBox=this.boundingBox.toJSON()));function g(C,V){return C[V.uuid]===void 0&&(C[V.uuid]=V.toJSON(i)),V.uuid}if(this.isScene)this.background&&(this.background.isColor?f.background=this.background.toJSON():this.background.isTexture&&(f.background=this.background.toJSON(i).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(f.environment=this.environment.toJSON(i).uuid);else if(this.isMesh||this.isLine||this.isPoints){f.geometry=g(i.geometries,this.geometry);const C=this.geometry.parameters;if(C!==void 0&&C.shapes!==void 0){const V=C.shapes;if(Array.isArray(V))for(let H=0,J=V.length;H0){f.children=[];for(let C=0;C0){f.animations=[];for(let C=0;C0&&(h.geometries=C),V.length>0&&(h.materials=V),H.length>0&&(h.textures=H),J.length>0&&(h.images=J),he.length>0&&(h.shapes=he),pe.length>0&&(h.skeletons=pe),me.length>0&&(h.animations=me),Se.length>0&&(h.nodes=Se)}return h.object=f,h;function v(C){const V=[];for(const H in C){const J=C[H];delete J.metadata,V.push(J)}return V}}clone(i){return new this.constructor().copy(this,i)}copy(i,l=!0){if(this.name=i.name,this.up.copy(i.up),this.position.copy(i.position),this.rotation.order=i.rotation.order,this.quaternion.copy(i.quaternion),this.scale.copy(i.scale),this.matrix.copy(i.matrix),this.matrixWorld.copy(i.matrixWorld),this.matrixAutoUpdate=i.matrixAutoUpdate,this.matrixWorldAutoUpdate=i.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=i.matrixWorldNeedsUpdate,this.layers.mask=i.layers.mask,this.visible=i.visible,this.castShadow=i.castShadow,this.receiveShadow=i.receiveShadow,this.frustumCulled=i.frustumCulled,this.renderOrder=i.renderOrder,this.animations=i.animations.slice(),this.userData=JSON.parse(JSON.stringify(i.userData)),l===!0)for(let h=0;h0?f.multiplyScalar(1/Math.sqrt(g)):f.set(0,0,0)}static getBarycoord(i,l,h,f,g){da.subVectors(f,l),Ys.subVectors(h,l),Oc.subVectors(i,l);const v=da.dot(da),C=da.dot(Ys),V=da.dot(Oc),H=Ys.dot(Ys),J=Ys.dot(Oc),he=v*H-C*C;if(he===0)return g.set(0,0,0),null;const pe=1/he,me=(H*V-C*J)*pe,Se=(v*J-C*V)*pe;return g.set(1-me-Se,Se,me)}static containsPoint(i,l,h,f){return this.getBarycoord(i,l,h,f,Co)===null?!1:Co.x>=0&&Co.y>=0&&Co.x+Co.y<=1}static getInterpolation(i,l,h,f,g,v,C,V){return this.getBarycoord(i,l,h,f,Co)===null?(V.x=0,V.y=0,"z"in V&&(V.z=0),"w"in V&&(V.w=0),null):(V.setScalar(0),V.addScaledVector(g,Co.x),V.addScaledVector(v,Co.y),V.addScaledVector(C,Co.z),V)}static getInterpolatedAttribute(i,l,h,f,g,v){return is.setScalar(0),Bs.setScalar(0),jn.setScalar(0),is.fromBufferAttribute(i,l),Bs.fromBufferAttribute(i,h),jn.fromBufferAttribute(i,f),v.setScalar(0),v.addScaledVector(is,g.x),v.addScaledVector(Bs,g.y),v.addScaledVector(jn,g.z),v}static isFrontFacing(i,l,h,f){return da.subVectors(h,l),Ys.subVectors(i,l),da.cross(Ys).dot(f)<0}set(i,l,h){return this.a.copy(i),this.b.copy(l),this.c.copy(h),this}setFromPointsAndIndices(i,l,h,f){return this.a.copy(i[l]),this.b.copy(i[h]),this.c.copy(i[f]),this}setFromAttributeAndIndices(i,l,h,f){return this.a.fromBufferAttribute(i,l),this.b.fromBufferAttribute(i,h),this.c.fromBufferAttribute(i,f),this}clone(){return new this.constructor().copy(this)}copy(i){return this.a.copy(i.a),this.b.copy(i.b),this.c.copy(i.c),this}getArea(){return da.subVectors(this.c,this.b),Ys.subVectors(this.a,this.b),da.cross(Ys).length()*.5}getMidpoint(i){return i.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(i){return br.getNormal(this.a,this.b,this.c,i)}getPlane(i){return i.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(i,l){return br.getBarycoord(i,this.a,this.b,this.c,l)}getInterpolation(i,l,h,f,g){return br.getInterpolation(i,this.a,this.b,this.c,l,h,f,g)}containsPoint(i){return br.containsPoint(i,this.a,this.b,this.c)}isFrontFacing(i){return br.isFrontFacing(this.a,this.b,this.c,i)}intersectsBox(i){return i.intersectsTriangle(this)}closestPointToPoint(i,l){const h=this.a,f=this.b,g=this.c;let v,C;Ul.subVectors(f,h),Ho.subVectors(g,h),na.subVectors(i,h);const V=Ul.dot(na),H=Ho.dot(na);if(V<=0&&H<=0)return l.copy(h);ll.subVectors(i,f);const J=Ul.dot(ll),he=Ho.dot(ll);if(J>=0&&he<=J)return l.copy(f);const pe=V*he-J*H;if(pe<=0&&V>=0&&J<=0)return v=V/(V-J),l.copy(h).addScaledVector(Ul,v);ia.subVectors(i,g);const me=Ul.dot(ia),Se=Ho.dot(ia);if(Se>=0&&me<=Se)return l.copy(g);const tt=me*H-V*Se;if(tt<=0&&H>=0&&Se<=0)return C=H/(H-Se),l.copy(h).addScaledVector(Ho,C);const gt=J*Se-me*he;if(gt<=0&&he-J>=0&&me-Se>=0)return wa.subVectors(g,f),C=(he-J)/(he-J+(me-Se)),l.copy(f).addScaledVector(wa,C);const mt=1/(gt+tt+pe);return v=tt*mt,C=pe*mt,l.copy(h).addScaledVector(Ul,v).addScaledVector(Ho,C)}equals(i){return i.a.equals(this.a)&&i.b.equals(this.b)&&i.c.equals(this.c)}}const Do={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ei={h:0,s:0,l:0},Wr={h:0,s:0,l:0};function vs(j,i,l){return l<0&&(l+=1),l>1&&(l-=1),l<1/6?j+(i-j)*6*l:l<1/2?i:l<2/3?j+(i-j)*6*(2/3-l):j}class ar{constructor(i,l,h){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(i,l,h)}set(i,l,h){if(l===void 0&&h===void 0){const f=i;f&&f.isColor?this.copy(f):typeof f=="number"?this.setHex(f):typeof f=="string"&&this.setStyle(f)}else this.setRGB(i,l,h);return this}setScalar(i){return this.r=i,this.g=i,this.b=i,this}setHex(i,l=co){return i=Math.floor(i),this.r=(i>>16&255)/255,this.g=(i>>8&255)/255,this.b=(i&255)/255,wo.colorSpaceToWorking(this,l),this}setRGB(i,l,h,f=wo.workingColorSpace){return this.r=i,this.g=l,this.b=h,wo.colorSpaceToWorking(this,f),this}setHSL(i,l,h,f=wo.workingColorSpace){if(i=np(i,1),l=Fr(l,0,1),h=Fr(h,0,1),l===0)this.r=this.g=this.b=h;else{const g=h<=.5?h*(1+l):h+l-h*l,v=2*h-g;this.r=vs(v,g,i+1/3),this.g=vs(v,g,i),this.b=vs(v,g,i-1/3)}return wo.colorSpaceToWorking(this,f),this}setStyle(i,l=co){function h(g){g!==void 0&&parseFloat(g)<1&&_r("Color: Alpha component of "+i+" will be ignored.")}let f;if(f=/^(\w+)\(([^\)]*)\)/.exec(i)){let g;const v=f[1],C=f[2];switch(v){case"rgb":case"rgba":if(g=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))return h(g[4]),this.setRGB(Math.min(255,parseInt(g[1],10))/255,Math.min(255,parseInt(g[2],10))/255,Math.min(255,parseInt(g[3],10))/255,l);if(g=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))return h(g[4]),this.setRGB(Math.min(100,parseInt(g[1],10))/100,Math.min(100,parseInt(g[2],10))/100,Math.min(100,parseInt(g[3],10))/100,l);break;case"hsl":case"hsla":if(g=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))return h(g[4]),this.setHSL(parseFloat(g[1])/360,parseFloat(g[2])/100,parseFloat(g[3])/100,l);break;default:_r("Color: Unknown color model "+i)}}else if(f=/^\#([A-Fa-f\d]+)$/.exec(i)){const g=f[1],v=g.length;if(v===3)return this.setRGB(parseInt(g.charAt(0),16)/15,parseInt(g.charAt(1),16)/15,parseInt(g.charAt(2),16)/15,l);if(v===6)return this.setHex(parseInt(g,16),l);_r("Color: Invalid hex color "+i)}else if(i&&i.length>0)return this.setColorName(i,l);return this}setColorName(i,l=co){const h=Do[i.toLowerCase()];return h!==void 0?this.setHex(h,l):_r("Color: Unknown color "+i),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(i){return this.r=i.r,this.g=i.g,this.b=i.b,this}copySRGBToLinear(i){return this.r=Bl(i.r),this.g=Bl(i.g),this.b=Bl(i.b),this}copyLinearToSRGB(i){return this.r=Ic(i.r),this.g=Ic(i.g),this.b=Ic(i.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(i=co){return wo.workingToColorSpace(vr.copy(this),i),Math.round(Fr(vr.r*255,0,255))*65536+Math.round(Fr(vr.g*255,0,255))*256+Math.round(Fr(vr.b*255,0,255))}getHexString(i=co){return("000000"+this.getHex(i).toString(16)).slice(-6)}getHSL(i,l=wo.workingColorSpace){wo.workingToColorSpace(vr.copy(this),l);const h=vr.r,f=vr.g,g=vr.b,v=Math.max(h,f,g),C=Math.min(h,f,g);let V,H;const J=(C+v)/2;if(C===v)V=0,H=0;else{const he=v-C;switch(H=J<=.5?he/(v+C):he/(2-v-C),v){case h:V=(f-g)/he+(f0!=i>0&&this.version++,this._alphaTest=i}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(i){if(i!==void 0)for(const l in i){const h=i[l];if(h===void 0){_r(`Material: parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_r(`Material: '${l}' is not a property of THREE.${this.type}.`);continue}f&&f.isColor?f.set(h):f&&f.isVector3&&h&&h.isVector3?f.copy(h):this[l]=h}}toJSON(i){const l=i===void 0||typeof i=="string";l&&(i={textures:{},images:{}});const h={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};h.uuid=this.uuid,h.type=this.type,this.name!==""&&(h.name=this.name),this.color&&this.color.isColor&&(h.color=this.color.getHex()),this.roughness!==void 0&&(h.roughness=this.roughness),this.metalness!==void 0&&(h.metalness=this.metalness),this.sheen!==void 0&&(h.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(h.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(h.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(h.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(h.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(h.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(h.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(h.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(h.shininess=this.shininess),this.clearcoat!==void 0&&(h.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(h.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(h.clearcoatMap=this.clearcoatMap.toJSON(i).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(h.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(i).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(h.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(i).uuid,h.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(h.sheenColorMap=this.sheenColorMap.toJSON(i).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(h.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(i).uuid),this.dispersion!==void 0&&(h.dispersion=this.dispersion),this.iridescence!==void 0&&(h.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(h.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(h.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(h.iridescenceMap=this.iridescenceMap.toJSON(i).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(h.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(i).uuid),this.anisotropy!==void 0&&(h.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(h.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(h.anisotropyMap=this.anisotropyMap.toJSON(i).uuid),this.map&&this.map.isTexture&&(h.map=this.map.toJSON(i).uuid),this.matcap&&this.matcap.isTexture&&(h.matcap=this.matcap.toJSON(i).uuid),this.alphaMap&&this.alphaMap.isTexture&&(h.alphaMap=this.alphaMap.toJSON(i).uuid),this.lightMap&&this.lightMap.isTexture&&(h.lightMap=this.lightMap.toJSON(i).uuid,h.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(h.aoMap=this.aoMap.toJSON(i).uuid,h.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(h.bumpMap=this.bumpMap.toJSON(i).uuid,h.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(h.normalMap=this.normalMap.toJSON(i).uuid,h.normalMapType=this.normalMapType,h.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(h.displacementMap=this.displacementMap.toJSON(i).uuid,h.displacementScale=this.displacementScale,h.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(h.roughnessMap=this.roughnessMap.toJSON(i).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(h.metalnessMap=this.metalnessMap.toJSON(i).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(h.emissiveMap=this.emissiveMap.toJSON(i).uuid),this.specularMap&&this.specularMap.isTexture&&(h.specularMap=this.specularMap.toJSON(i).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(h.specularIntensityMap=this.specularIntensityMap.toJSON(i).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(h.specularColorMap=this.specularColorMap.toJSON(i).uuid),this.envMap&&this.envMap.isTexture&&(h.envMap=this.envMap.toJSON(i).uuid,this.combine!==void 0&&(h.combine=this.combine)),this.envMapRotation!==void 0&&(h.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(h.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(h.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(h.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(h.gradientMap=this.gradientMap.toJSON(i).uuid),this.transmission!==void 0&&(h.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(h.transmissionMap=this.transmissionMap.toJSON(i).uuid),this.thickness!==void 0&&(h.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(h.thicknessMap=this.thicknessMap.toJSON(i).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(h.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(h.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(h.size=this.size),this.shadowSide!==null&&(h.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(h.sizeAttenuation=this.sizeAttenuation),this.blending!==ge&&(h.blending=this.blending),this.side!==W&&(h.side=this.side),this.vertexColors===!0&&(h.vertexColors=!0),this.opacity<1&&(h.opacity=this.opacity),this.transparent===!0&&(h.transparent=!0),this.blendSrc!==Ut&&(h.blendSrc=this.blendSrc),this.blendDst!==At&&(h.blendDst=this.blendDst),this.blendEquation!==Ae&&(h.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(h.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(h.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(h.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(h.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(h.blendAlpha=this.blendAlpha),this.depthFunc!==Y&&(h.depthFunc=this.depthFunc),this.depthTest===!1&&(h.depthTest=this.depthTest),this.depthWrite===!1&&(h.depthWrite=this.depthWrite),this.colorWrite===!1&&(h.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(h.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Xh&&(h.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(h.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(h.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yl&&(h.stencilFail=this.stencilFail),this.stencilZFail!==Yl&&(h.stencilZFail=this.stencilZFail),this.stencilZPass!==Yl&&(h.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(h.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(h.rotation=this.rotation),this.polygonOffset===!0&&(h.polygonOffset=!0),this.polygonOffsetFactor!==0&&(h.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(h.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(h.linewidth=this.linewidth),this.dashSize!==void 0&&(h.dashSize=this.dashSize),this.gapSize!==void 0&&(h.gapSize=this.gapSize),this.scale!==void 0&&(h.scale=this.scale),this.dithering===!0&&(h.dithering=!0),this.alphaTest>0&&(h.alphaTest=this.alphaTest),this.alphaHash===!0&&(h.alphaHash=!0),this.alphaToCoverage===!0&&(h.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(h.premultipliedAlpha=!0),this.forceSinglePass===!0&&(h.forceSinglePass=!0),this.wireframe===!0&&(h.wireframe=!0),this.wireframeLinewidth>1&&(h.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(h.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(h.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(h.flatShading=!0),this.visible===!1&&(h.visible=!1),this.toneMapped===!1&&(h.toneMapped=!1),this.fog===!1&&(h.fog=!1),Object.keys(this.userData).length>0&&(h.userData=this.userData);function f(g){const v=[];for(const C in g){const V=g[C];delete V.metadata,v.push(V)}return v}if(l){const g=f(i.textures),v=f(i.images);g.length>0&&(h.textures=g),v.length>0&&(h.images=v)}return h}clone(){return new this.constructor().copy(this)}copy(i){this.name=i.name,this.blending=i.blending,this.side=i.side,this.vertexColors=i.vertexColors,this.opacity=i.opacity,this.transparent=i.transparent,this.blendSrc=i.blendSrc,this.blendDst=i.blendDst,this.blendEquation=i.blendEquation,this.blendSrcAlpha=i.blendSrcAlpha,this.blendDstAlpha=i.blendDstAlpha,this.blendEquationAlpha=i.blendEquationAlpha,this.blendColor.copy(i.blendColor),this.blendAlpha=i.blendAlpha,this.depthFunc=i.depthFunc,this.depthTest=i.depthTest,this.depthWrite=i.depthWrite,this.stencilWriteMask=i.stencilWriteMask,this.stencilFunc=i.stencilFunc,this.stencilRef=i.stencilRef,this.stencilFuncMask=i.stencilFuncMask,this.stencilFail=i.stencilFail,this.stencilZFail=i.stencilZFail,this.stencilZPass=i.stencilZPass,this.stencilWrite=i.stencilWrite;const l=i.clippingPlanes;let h=null;if(l!==null){const f=l.length;h=new Array(f);for(let g=0;g!==f;++g)h[g]=l[g].clone()}return this.clippingPlanes=h,this.clipIntersection=i.clipIntersection,this.clipShadows=i.clipShadows,this.shadowSide=i.shadowSide,this.colorWrite=i.colorWrite,this.precision=i.precision,this.polygonOffset=i.polygonOffset,this.polygonOffsetFactor=i.polygonOffsetFactor,this.polygonOffsetUnits=i.polygonOffsetUnits,this.dithering=i.dithering,this.alphaTest=i.alphaTest,this.alphaHash=i.alphaHash,this.alphaToCoverage=i.alphaToCoverage,this.premultipliedAlpha=i.premultipliedAlpha,this.forceSinglePass=i.forceSinglePass,this.visible=i.visible,this.toneMapped=i.toneMapped,this.userData=JSON.parse(JSON.stringify(i.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(i){i===!0&&this.version++}}class Ms extends Ro{constructor(i){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ar(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cs,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.fog=i.fog,this}}const Ws=null;function dh(){const j=new ArrayBuffer(4),i=new Float32Array(j),l=new Uint32Array(j),h=new Uint32Array(512),f=new Uint32Array(512);for(let V=0;V<256;++V){const H=V-127;H<-27?(h[V]=0,h[V|256]=32768,f[V]=24,f[V|256]=24):H<-14?(h[V]=1024>>-H-14,h[V|256]=1024>>-H-14|32768,f[V]=-H-1,f[V|256]=-H-1):H<=15?(h[V]=H+15<<10,h[V|256]=H+15<<10|32768,f[V]=13,f[V|256]=13):H<128?(h[V]=31744,h[V|256]=64512,f[V]=24,f[V|256]=24):(h[V]=31744,h[V|256]=64512,f[V]=13,f[V|256]=13)}const g=new Uint32Array(2048),v=new Uint32Array(64),C=new Uint32Array(64);for(let V=1;V<1024;++V){let H=V<<13,J=0;for(;!(H&8388608);)H<<=1,J-=8388608;H&=-8388609,J+=947912704,g[V]=H|J}for(let V=1024;V<2048;++V)g[V]=939524096+(V-1024<<13);for(let V=1;V<31;++V)v[V]=V<<23;v[31]=1199570944,v[32]=2147483648;for(let V=33;V<63;++V)v[V]=2147483648+(V-32<<23);v[63]=3347054592;for(let V=1;V<64;++V)V!==32&&(C[V]=1024);return{floatView:i,uint32View:l,baseTable:h,shiftTable:f,mantissaTable:g,exponentTable:v,offsetTable:C}}function Qr(j){Math.abs(j)>65504&&_r("DataUtils.toHalfFloat(): Value out of range."),j=Fr(j,-65504,65504),Ws.floatView[0]=j;const i=Ws.uint32View[0],l=i>>23&511;return Ws.baseTable[l]+((i&8388607)>>Ws.shiftTable[l])}function Ma(j){const i=j>>10;return Ws.uint32View[0]=Ws.mantissaTable[Ws.offsetTable[i]+(j&1023)]+Ws.exponentTable[i],Ws.floatView[0]}class dc{static toHalfFloat(i){return Qr(i)}static fromHalfFloat(i){return Ma(i)}}const ao=new Rt,fc=new oi;let ka=0;class yo{constructor(i,l,h=!1){if(Array.isArray(i))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ka++}),this.name="",this.array=i,this.itemSize=l,this.count=i!==void 0?i.length/l:0,this.normalized=h,this.usage=Ou,this.updateRanges=[],this.gpuType=gs,this.version=0}onUploadCallback(){}set needsUpdate(i){i===!0&&this.version++}setUsage(i){return this.usage=i,this}addUpdateRange(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(i){return this.name=i.name,this.array=new i.array.constructor(i.array),this.itemSize=i.itemSize,this.count=i.count,this.normalized=i.normalized,this.usage=i.usage,this.gpuType=i.gpuType,this}copyAt(i,l,h){i*=this.itemSize,h*=l.itemSize;for(let f=0,g=this.itemSize;fl.count&&_r("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),l.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ta);const i=this.attributes.position,l=this.morphAttributes.position;if(i&&i.isGLBufferAttribute){js("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Rt(-1/0,-1/0,-1/0),new Rt(1/0,1/0,1/0));return}if(i!==void 0){if(this.boundingBox.setFromBufferAttribute(i),l)for(let h=0,f=l.length;h0&&(i.userData=this.userData),this.parameters!==void 0){const V=this.parameters;for(const H in V)V[H]!==void 0&&(i[H]=V[H]);return i}i.data={attributes:{}};const l=this.index;l!==null&&(i.data.index={type:l.array.constructor.name,array:Array.prototype.slice.call(l.array)});const h=this.attributes;for(const V in h){const H=h[V];i.data.attributes[V]=H.toJSON(i.data)}const f={};let g=!1;for(const V in this.morphAttributes){const H=this.morphAttributes[V],J=[];for(let he=0,pe=H.length;he0&&(f[V]=J,g=!0)}g&&(i.data.morphAttributes=f,i.data.morphTargetsRelative=this.morphTargetsRelative);const v=this.groups;v.length>0&&(i.data.groups=JSON.parse(JSON.stringify(v)));const C=this.boundingSphere;return C!==null&&(i.data.boundingSphere=C.toJSON()),i}clone(){return new this.constructor().copy(this)}copy(i){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const l={};this.name=i.name;const h=i.index;h!==null&&this.setIndex(h.clone());const f=i.attributes;for(const H in f){const J=f[H];this.setAttribute(H,J.clone(l))}const g=i.morphAttributes;for(const H in g){const J=[],he=g[H];for(let pe=0,me=he.length;pe0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;gKf(i.far-i.near,2)))&&(Jl.copy(g).invert(),mc.copy(i.ray).applyMatrix4(Jl),!(h.boundingBox!==null&&mc.intersectsBox(h.boundingBox)===!1)&&this._computeIntersections(i,l,mc)))}_computeIntersections(i,l,h){let f;const g=this.geometry,v=this.material,C=g.index,V=g.attributes.position,H=g.attributes.uv,J=g.attributes.uv1,he=g.attributes.normal,pe=g.groups,me=g.drawRange;if(C!==null)if(Array.isArray(v))for(let Se=0,tt=pe.length;Sel.far?null:{distance:H,point:Ja.clone(),object:j}}function ap(j,i,l,h,f,g,v,C,V,H){j.getVertexPosition(C,cu),j.getVertexPosition(V,Zs),j.getVertexPosition(H,Kh);const J=ox(j,i,l,h,cu,Zs,Kh,Jh);if(J){const he=new Rt;br.getBarycoord(Jh,cu,Zs,Kh,he),f&&(J.uv=br.getInterpolatedAttribute(f,C,V,H,he,new oi)),g&&(J.uv1=br.getInterpolatedAttribute(g,C,V,H,he,new oi)),v&&(J.normal=br.getInterpolatedAttribute(v,C,V,H,he,new Rt),J.normal.dot(h.direction)>0&&J.normal.multiplyScalar(-1));const pe={a:C,b:V,c:H,normal:new Rt,materialIndex:0};br.getNormal(cu,Zs,Kh,pe.normal),J.face=pe,J.barycoord=he}return J}class Gm extends Or{constructor(i=1,l=1,h=1,f=1,g=1,v=1){super(),this.type="BoxGeometry",this.parameters={width:i,height:l,depth:h,widthSegments:f,heightSegments:g,depthSegments:v};const C=this;f=Math.floor(f),g=Math.floor(g),v=Math.floor(v);const V=[],H=[],J=[],he=[];let pe=0,me=0;Se("z","y","x",-1,-1,h,l,i,v,g,0),Se("z","y","x",1,-1,h,l,-i,v,g,1),Se("x","z","y",1,1,i,h,l,f,v,2),Se("x","z","y",1,-1,i,h,-l,f,v,3),Se("x","y","z",1,-1,i,l,h,f,g,4),Se("x","y","z",-1,-1,i,l,-h,f,g,5),this.setIndex(V),this.setAttribute("position",new qi(H,3)),this.setAttribute("normal",new qi(J,3)),this.setAttribute("uv",new qi(he,2));function Se(tt,gt,mt,Nt,Pt,Wt,gn,Sn,kn,In,ii){const li=Wt/kn,dr=gn/In,Yr=Wt/2,Ss=gn/2,eo=Sn/2,uo=kn+1,Aa=In+1;let hl=0,tc=0;const Xo=new Rt;for(let Ca=0;Ca0?1:-1,J.push(Xo.x,Xo.y,Xo.z),he.push(Hc/kn),he.push(1-Ca/In),hl+=1}}for(let Ca=0;Ca0&&(l.defines=this.defines),l.vertexShader=this.vertexShader,l.fragmentShader=this.fragmentShader,l.lights=this.lights,l.clipping=this.clipping;const h={};for(const f in this.extensions)this.extensions[f]===!0&&(h[f]=!0);return Object.keys(h).length>0&&(l.extensions=h),l}}class nf extends xs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new On,this.projectionMatrix=new On,this.projectionMatrixInverse=new On,this.coordinateSystem=so,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(i,l){return super.copy(i,l),this.matrixWorldInverse.copy(i.matrixWorldInverse),this.projectionMatrix.copy(i.projectionMatrix),this.projectionMatrixInverse.copy(i.projectionMatrixInverse),this.coordinateSystem=i.coordinateSystem,this}getWorldDirection(i){return super.getWorldDirection(i).negate()}updateMatrixWorld(i){super.updateMatrixWorld(i),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(i,l){super.updateWorldMatrix(i,l),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Vu=new Rt,ph=new oi,R0=new oi;class ul extends null{constructor(i=50,l=1,h=.1,f=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=i,this.zoom=1,this.near=h,this.far=f,this.focus=10,this.aspect=l,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(i,l){return super.copy(i,l),this.fov=i.fov,this.zoom=i.zoom,this.near=i.near,this.far=i.far,this.focus=i.focus,this.aspect=i.aspect,this.view=i.view===null?null:Object.assign({},i.view),this.filmGauge=i.filmGauge,this.filmOffset=i.filmOffset,this}setFocalLength(i){const l=.5*this.getFilmHeight()/i;this.fov=Uu*2*Math.atan(l),this.updateProjectionMatrix()}getFocalLength(){const i=Math.tan(ru*.5*this.fov);return .5*this.getFilmHeight()/i}getEffectiveFOV(){return Uu*2*Math.atan(Math.tan(ru*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(i,l,h){Vu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(Vu.x,Vu.y).multiplyScalar(-i/Vu.z),Vu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),h.set(Vu.x,Vu.y).multiplyScalar(-i/Vu.z)}getViewSize(i,l){return this.getViewBounds(i,ph,R0),l.subVectors(R0,ph)}setViewOffset(i,l,h,f,g,v){this.aspect=i/l,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=i,this.view.fullHeight=l,this.view.offsetX=h,this.view.offsetY=f,this.view.width=g,this.view.height=v,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const i=this.near;let l=i*Math.tan(ru*.5*this.fov)/this.zoom,h=2*l,f=this.aspect*h,g=-.5*f;const v=this.view;if(this.view!==null&&this.view.enabled){const V=v.fullWidth,H=v.fullHeight;g+=v.offsetX*f/V,l-=v.offsetY*h/H,f*=v.width/V,h*=v.height/H}const C=this.filmOffset;C!==0&&(g+=i*C/this.getFilmWidth()),this.projectionMatrix.makePerspective(g,g+f,l,l-h,i,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(i){const l=super.toJSON(i);return l.object.fov=this.fov,l.object.zoom=this.zoom,l.object.near=this.near,l.object.far=this.far,l.object.focus=this.focus,l.object.aspect=this.aspect,this.view!==null&&(l.object.view=Object.assign({},this.view)),l.object.filmGauge=this.filmGauge,l.object.filmOffset=this.filmOffset,l}}const rf=null,Gu=1;class N0 extends null{constructor(i,l,h){super(),this.type="CubeCamera",this.renderTarget=h,this.coordinateSystem=null,this.activeMipmapLevel=0;const f=new ul(rf,Gu,i,l);f.layers=this.layers,this.add(f);const g=new ul(rf,Gu,i,l);g.layers=this.layers,this.add(g);const v=new ul(rf,Gu,i,l);v.layers=this.layers,this.add(v);const C=new ul(rf,Gu,i,l);C.layers=this.layers,this.add(C);const V=new ul(rf,Gu,i,l);V.layers=this.layers,this.add(V);const H=new ul(rf,Gu,i,l);H.layers=this.layers,this.add(H)}updateCoordinateSystem(){const i=this.coordinateSystem,l=this.children.concat(),[h,f,g,v,C,V]=l;for(const H of l)this.remove(H);if(i===so)h.up.set(0,1,0),h.lookAt(1,0,0),f.up.set(0,1,0),f.lookAt(-1,0,0),g.up.set(0,0,-1),g.lookAt(0,1,0),v.up.set(0,0,1),v.lookAt(0,-1,0),C.up.set(0,1,0),C.lookAt(0,0,1),V.up.set(0,1,0),V.lookAt(0,0,-1);else if(i===ja)h.up.set(0,-1,0),h.lookAt(-1,0,0),f.up.set(0,-1,0),f.lookAt(1,0,0),g.up.set(0,0,1),g.lookAt(0,1,0),v.up.set(0,0,-1),v.lookAt(0,-1,0),C.up.set(0,-1,0),C.lookAt(0,0,1),V.up.set(0,-1,0),V.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+i);for(const H of l)this.add(H),H.updateMatrixWorld()}update(i,l){this.parent===null&&this.updateMatrixWorld();const{renderTarget:h,activeMipmapLevel:f}=this;this.coordinateSystem!==i.coordinateSystem&&(this.coordinateSystem=i.coordinateSystem,this.updateCoordinateSystem());const[g,v,C,V,H,J]=this.children,he=i.getRenderTarget(),pe=i.getActiveCubeFace(),me=i.getActiveMipmapLevel(),Se=i.xr.enabled;i.xr.enabled=!1;const tt=h.texture.generateMipmaps;h.texture.generateMipmaps=!1,i.setRenderTarget(h,0,f),i.render(l,g),i.setRenderTarget(h,1,f),i.render(l,v),i.setRenderTarget(h,2,f),i.render(l,C),i.setRenderTarget(h,3,f),i.render(l,V),i.setRenderTarget(h,4,f),i.render(l,H),h.texture.generateMipmaps=tt,i.setRenderTarget(h,5,f),i.render(l,J),i.setRenderTarget(he,pe,me),i.xr.enabled=Se,h.texture.needsPMREMUpdate=!0}}class lp extends null{constructor(i=[],l=Fe,h,f,g,v,C,V,H,J){super(i,l,h,f,g,v,C,V,H,J),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(i){this.image=i}}class $m extends null{constructor(i=1,l={}){super(i,i,l),this.isWebGLCubeRenderTarget=!0;const h={width:i,height:i,depth:1},f=[h,h,h,h,h,h];this.texture=new lp(f),this._setTextureOptions(l),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(i,l){this.texture.type=l.type,this.texture.colorSpace=l.colorSpace,this.texture.generateMipmaps=l.generateMipmaps,this.texture.minFilter=l.minFilter,this.texture.magFilter=l.magFilter;const h={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},f=new Gm(5,5,5),g=new ed({name:"CubemapFromEquirect",uniforms:Wm(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,side:K,blending:ye});g.uniforms.tEquirect.value=l;const v=new fh(f,g),C=l.minFilter;return l.minFilter===Qn&&(l.minFilter=Rn),new N0(1,10,this).update(i,v),l.minFilter=C,v.geometry.dispose(),v.material.dispose(),this}clear(i,l=!0,h=!0,f=!0){const g=i.getRenderTarget();for(let v=0;v<6;v++)i.setRenderTarget(this,v),i.clear(l,h,f);i.setRenderTarget(g)}}class Wu extends xs{constructor(){super(),this.isGroup=!0,this.type="Group"}}const El={type:"move"};class sf{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wu,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wu,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Rt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Rt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wu,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Rt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Rt),this._grip}dispatchEvent(i){return this._targetRay!==null&&this._targetRay.dispatchEvent(i),this._grip!==null&&this._grip.dispatchEvent(i),this._hand!==null&&this._hand.dispatchEvent(i),this}connect(i){if(i&&i.hand){const l=this._hand;if(l)for(const h of i.hand.values())this._getHandJoint(l,h)}return this.dispatchEvent({type:"connected",data:i}),this}disconnect(i){return this.dispatchEvent({type:"disconnected",data:i}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(i,l,h){let f=null,g=null,v=null;const C=this._targetRay,V=this._grip,H=this._hand;if(i&&l.session.visibilityState!=="visible-blurred"){if(H&&i.hand){v=!0;for(const tt of i.hand.values()){const gt=l.getJointPose(tt,h),mt=this._getHandJoint(H,tt);gt!==null&&(mt.matrix.fromArray(gt.transform.matrix),mt.matrix.decompose(mt.position,mt.rotation,mt.scale),mt.matrixWorldNeedsUpdate=!0,mt.jointRadius=gt.radius),mt.visible=gt!==null}const J=H.joints["index-finger-tip"],he=H.joints["thumb-tip"],pe=J.position.distanceTo(he.position),me=.02,Se=.005;H.inputState.pinching&&pe>me+Se?(H.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:i.handedness,target:this})):!H.inputState.pinching&&pe<=me-Se&&(H.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:i.handedness,target:this}))}else V!==null&&i.gripSpace&&(g=l.getPose(i.gripSpace,h),g!==null&&(V.matrix.fromArray(g.transform.matrix),V.matrix.decompose(V.position,V.rotation,V.scale),V.matrixWorldNeedsUpdate=!0,g.linearVelocity?(V.hasLinearVelocity=!0,V.linearVelocity.copy(g.linearVelocity)):V.hasLinearVelocity=!1,g.angularVelocity?(V.hasAngularVelocity=!0,V.angularVelocity.copy(g.angularVelocity)):V.hasAngularVelocity=!1));C!==null&&(f=l.getPose(i.targetRaySpace,h),f===null&&g!==null&&(f=g),f!==null&&(C.matrix.fromArray(f.transform.matrix),C.matrix.decompose(C.position,C.rotation,C.scale),C.matrixWorldNeedsUpdate=!0,f.linearVelocity?(C.hasLinearVelocity=!0,C.linearVelocity.copy(f.linearVelocity)):C.hasLinearVelocity=!1,f.angularVelocity?(C.hasAngularVelocity=!0,C.angularVelocity.copy(f.angularVelocity)):C.hasAngularVelocity=!1,this.dispatchEvent(El)))}return C!==null&&(C.visible=f!==null),V!==null&&(V.visible=g!==null),H!==null&&(H.visible=v!==null),this}_getHandJoint(i,l){if(i.joints[l.jointName]===void 0){const h=new Wu;h.matrixAutoUpdate=!1,h.visible=!1,i.joints[l.jointName]=h,i.add(h)}return i.joints[l.jointName]}}class cp{constructor(i,l=25e-5){this.isFogExp2=!0,this.name="",this.color=new ar(i),this.density=l}clone(){return new cp(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class mh{constructor(i,l=1,h=1e3){this.isFog=!0,this.name="",this.color=new ar(i),this.near=l,this.far=h}clone(){return new mh(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class up extends null{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new cs,this.environmentIntensity=1,this.environmentRotation=new cs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(i,l){return super.copy(i,l),i.background!==null&&(this.background=i.background.clone()),i.environment!==null&&(this.environment=i.environment.clone()),i.fog!==null&&(this.fog=i.fog.clone()),this.backgroundBlurriness=i.backgroundBlurriness,this.backgroundIntensity=i.backgroundIntensity,this.backgroundRotation.copy(i.backgroundRotation),this.environmentIntensity=i.environmentIntensity,this.environmentRotation.copy(i.environmentRotation),i.overrideMaterial!==null&&(this.overrideMaterial=i.overrideMaterial.clone()),this.matrixAutoUpdate=i.matrixAutoUpdate,this}toJSON(i){const l=super.toJSON(i);return this.fog!==null&&(l.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(l.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(l.object.backgroundIntensity=this.backgroundIntensity),l.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(l.object.environmentIntensity=this.environmentIntensity),l.object.environmentRotation=this.environmentRotation.toArray(),l}}class td{constructor(i,l){this.isInterleavedBuffer=!0,this.array=i,this.stride=l,this.count=i!==void 0?i.length/l:0,this.usage=Ou,this.updateRanges=[],this.version=0,this.uuid=Sl()}onUploadCallback(){}set needsUpdate(i){i===!0&&this.version++}setUsage(i){return this.usage=i,this}addUpdateRange(i,l){this.updateRanges.push({start:i,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(i){return this.array=new i.array.constructor(i.array),this.count=i.count,this.stride=i.stride,this.usage=i.usage,this}copyAt(i,l,h){i*=this.stride,h*=l.stride;for(let f=0,g=this.stride;fi.far||l.push({distance:V,point:gh.clone(),uv:br.getInterpolation(gh,jm,yh,od,I0,L0,D0,new oi),face:null,object:this})}copy(i,l){return super.copy(i,l),i.center!==void 0&&this.center.copy(i.center),this.material=i.material,this}}function hp(j,i,l,h,f,g){rd.subVectors(j,l).addScalar(.5).multiply(h),f!==void 0?(sd.x=g*rd.x-f*rd.y,sd.y=f*rd.x+g*rd.y):sd.copy(rd),j.copy(i),j.x+=sd.x,j.y+=sd.y,j.applyMatrix4(P0)}const Xm=new Rt,F0=new Rt;class qm extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(i){super.copy(i,!1);const l=i.levels;for(let h=0,f=l.length;h0){let h,f;for(h=1,f=l.length;h0){Xm.setFromMatrixPosition(this.matrixWorld);const f=i.ray.origin.distanceTo(Xm);this.getObjectForDistance(f).raycast(i,l)}}update(i){const l=this.levels;if(l.length>1){Xm.setFromMatrixPosition(i.matrixWorld),F0.setFromMatrixPosition(this.matrixWorld);const h=Xm.distanceTo(F0)/i.zoom;l[0].object.visible=!0;let f,g;for(f=1,g=l.length;f=v)l[f-1].object.visible=!1,l[f].object.visible=!0;else break}for(this._currentLevel=f-1;f1?null:l.copy(i.start).addScaledVector(h,g)}intersectsLine(i){const l=this.distanceToPoint(i.start),h=this.distanceToPoint(i.end);return l<0&&h>0||h<0&&l>0}intersectsBox(i){return i.intersectsPlane(this)}intersectsSphere(i){return i.intersectsPlane(this)}coplanarPoint(i){return i.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(i,l){const h=l||fu.getNormalMatrix(i),f=this.coplanarPoint(af).applyMatrix4(i),g=this.normal.applyMatrix3(h).normalize();return this.constant=-f.dot(g),this}translate(i){return this.constant-=i.dot(this.normal),this}equals(i){return i.normal.equals(this.normal)&&i.constant===this.constant}clone(){return new this.constructor().copy(this)}}const pu=new Gt,z0=new oi(.5,.5),Jm=new Rt;class V0{constructor(i=new Cl,l=new Cl,h=new Cl,f=new Cl,g=new Cl,v=new Cl){this.planes=[i,l,h,f,g,v]}set(i,l,h,f,g,v){const C=this.planes;return C[0].copy(i),C[1].copy(l),C[2].copy(h),C[3].copy(f),C[4].copy(g),C[5].copy(v),this}copy(i){const l=this.planes;for(let h=0;h<6;h++)l[h].copy(i.planes[h]);return this}setFromProjectionMatrix(i,l=so,h=!1){const f=this.planes,g=i.elements,v=g[0],C=g[1],V=g[2],H=g[3],J=g[4],he=g[5],pe=g[6],me=g[7],Se=g[8],tt=g[9],gt=g[10],mt=g[11],Nt=g[12],Pt=g[13],Wt=g[14],gn=g[15];if(f[0].setComponents(H-v,me-J,mt-Se,gn-Nt).normalize(),f[1].setComponents(H+v,me+J,mt+Se,gn+Nt).normalize(),f[2].setComponents(H+C,me+he,mt+tt,gn+Pt).normalize(),f[3].setComponents(H-C,me-he,mt-tt,gn-Pt).normalize(),h)f[4].setComponents(V,pe,gt,Wt).normalize(),f[5].setComponents(H-V,me-pe,mt-gt,gn-Wt).normalize();else if(f[4].setComponents(H-V,me-pe,mt-gt,gn-Wt).normalize(),l===so)f[5].setComponents(H+V,me+pe,mt+gt,gn+Wt).normalize();else if(l===ja)f[5].setComponents(V,pe,gt,Wt).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+l);return this}intersectsObject(i){if(i.boundingSphere!==void 0)i.boundingSphere===null&&i.computeBoundingSphere(),pu.copy(i.boundingSphere).applyMatrix4(i.matrixWorld);else{const l=i.geometry;l.boundingSphere===null&&l.computeBoundingSphere(),pu.copy(l.boundingSphere).applyMatrix4(i.matrixWorld)}return this.intersectsSphere(pu)}intersectsSprite(i){pu.center.set(0,0,0);const l=z0.distanceTo(i.center);return pu.radius=.7071067811865476+l,pu.applyMatrix4(i.matrixWorld),this.intersectsSphere(pu)}intersectsSphere(i){const l=this.planes,h=i.center,f=-i.radius;for(let g=0;g<6;g++)if(l[g].distanceToPoint(h)0?i.max.x:i.min.x,Jm.y=f.normal.y>0?i.max.y:i.min.y,Jm.z=f.normal.z>0?i.max.z:i.min.z,f.distanceToPoint(Jm)<0)return!1}return!0}containsPoint(i){const l=this.planes;for(let h=0;h<6;h++)if(l[h].distanceToPoint(i)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const mu=new On,$o=new V0;class G0{constructor(){this.coordinateSystem=so}intersectsObject(i,l){if(!l.isArrayCamera||l.cameras.length===0)return!1;for(let h=0;h=g.length&&g.push({start:-1,count:-1,z:-1,index:-1});const C=g[this.index];v.push(C),this.index++,C.start=i,C.count=l,C.z=h,C.index=f}reset(){this.list.length=0,this.index=0}}const Qa=new On,dx=new ar(1,1,1),fx=new V0,W0=new G0,za=new ta,gu=new Gt,pp=new Rt,vh=new Rt,f1=new Rt,el=new ld,Va=new fh,cd=null;function px(j,i,l=0){const h=i.itemSize;if(j.isInterleavedBufferAttribute||j.array.constructor!==i.array.constructor){const f=j.count;for(let g=0;g65535?new Uint32Array(f):new Uint16Array(f);l.setIndex(new yo(g,1))}this._geometryInitialized=!0}}_validateGeometry(i){const l=this.geometry;if(!!i.getIndex()!=!!l.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const h in l.attributes){if(!i.hasAttribute(h))throw new Error(`THREE.BatchedMesh: Added geometry missing "${h}". All geometries must have consistent attributes.`);const f=i.getAttribute(h),g=l.getAttribute(h);if(f.itemSize!==g.itemSize||f.normalized!==g.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(i){const l=this._instanceInfo;if(i<0||i>=l.length||l[i].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${i}. Instance is either out of range or has been deleted.`)}validateGeometryId(i){const l=this._geometryInfo;if(i<0||i>=l.length||l[i].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${i}. Geometry is either out of range or has been deleted.`)}setCustomSort(i){return this.customSort=i,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ta);const i=this.boundingBox,l=this._instanceInfo;i.makeEmpty();for(let h=0,f=l.length;h=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const h={visible:!0,active:!0,geometryIndex:i};let f=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Qm),f=this._availableInstanceIds.shift(),this._instanceInfo[f]=h):(f=this._instanceInfo.length,this._instanceInfo.push(h));const g=this._matricesTexture;Qa.identity().toArray(g.image.data,f*16),g.needsUpdate=!0;const v=this._colorsTexture;return v&&(dx.toArray(v.image.data,f*4),v.needsUpdate=!0),this._visibilityChanged=!0,f}addGeometry(i,l=-1,h=-1){this._initializeGeometry(i),this._validateGeometry(i);const f={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},g=this._geometryInfo;f.vertexStart=this._nextVertexStart,f.reservedVertexCount=l===-1?i.getAttribute("position").count:l;const v=i.getIndex();if(v!==null&&(f.indexStart=this._nextIndexStart,f.reservedIndexCount=h===-1?v.count:h),f.indexStart!==-1&&f.indexStart+f.reservedIndexCount>this._maxIndexCount||f.vertexStart+f.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let V;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Qm),V=this._availableGeometryIds.shift(),g[V]=f):(V=this._geometryCount,this._geometryCount++,g.push(f)),this.setGeometryAt(V,i),this._nextIndexStart=f.indexStart+f.reservedIndexCount,this._nextVertexStart=f.vertexStart+f.reservedVertexCount,V}setGeometryAt(i,l){if(i>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(l);const h=this.geometry,f=h.getIndex()!==null,g=h.getIndex(),v=l.getIndex(),C=this._geometryInfo[i];if(f&&v.count>C.reservedIndexCount||l.attributes.position.count>C.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const V=C.vertexStart,H=C.reservedVertexCount;C.vertexCount=l.getAttribute("position").count;for(const J in h.attributes){const he=l.getAttribute(J),pe=h.getAttribute(J);px(he,pe,V);const me=he.itemSize;for(let Se=he.count,tt=H;Se=l.length||l[i].active===!1)return this;const h=this._instanceInfo;for(let f=0,g=h.length;fC).sort((v,C)=>h[v].vertexStart-h[C].vertexStart),g=this.geometry;for(let v=0,C=h.length;v=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[i];if(f.boundingBox===null){const g=new ta,v=h.index,C=h.attributes.position;for(let V=f.start,H=f.start+f.count;V=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[i];if(f.boundingSphere===null){const g=new Gt;this.getBoundingBoxAt(i,za),za.getCenter(g.center);const v=h.index,C=h.attributes.position;let V=0;for(let H=f.start,J=f.start+f.count;HC.active);if(Math.max(...h.map(C=>C.vertexStart+C.reservedVertexCount))>i)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${l}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...h.map(V=>V.indexStart+V.reservedIndexCount))>l)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${l}. Cannot shrink further.`);const g=this.geometry;g.dispose(),this._maxVertexCount=i,this._maxIndexCount=l,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Or,this._initializeGeometry(g));const v=this.geometry;g.index&&Vc(g.index.array,v.index.array);for(const C in g.attributes)Vc(g.attributes[C].array,v.attributes[C].array)}raycast(i,l){const h=this._instanceInfo,f=this._geometryInfo,g=this.matrixWorld,v=this.geometry;Va.material=this.material,Va.geometry.index=v.index,Va.geometry.attributes=v.attributes,Va.geometry.boundingBox===null&&(Va.geometry.boundingBox=new ta),Va.geometry.boundingSphere===null&&(Va.geometry.boundingSphere=new Gt);for(let C=0,V=h.length;Cac(qs({},l),{boundingBox:l.boundingBox!==null?l.boundingBox.clone():null,boundingSphere:l.boundingSphere!==null?l.boundingSphere.clone():null})),this._instanceInfo=i._instanceInfo.map(l=>qs({},l)),this._availableInstanceIds=i._availableInstanceIds.slice(),this._availableGeometryIds=i._availableGeometryIds.slice(),this._nextIndexStart=i._nextIndexStart,this._nextVertexStart=i._nextVertexStart,this._geometryCount=i._geometryCount,this._maxInstanceCount=i._maxInstanceCount,this._maxVertexCount=i._maxVertexCount,this._maxIndexCount=i._maxIndexCount,this._geometryInitialized=i._geometryInitialized,this._multiDrawCounts=i._multiDrawCounts.slice(),this._multiDrawStarts=i._multiDrawStarts.slice(),this._indirectTexture=i._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=i._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=i._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(i,l,h,f,g){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const v=f.getIndex(),C=v===null?1:v.array.BYTES_PER_ELEMENT,V=this._instanceInfo,H=this._multiDrawStarts,J=this._multiDrawCounts,he=this._geometryInfo,pe=this.perObjectFrustumCulled,me=this._indirectTexture,Se=me.image.data,tt=h.isArrayCamera?W0:fx;pe&&!h.isArrayCamera&&(Qa.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse).multiply(this.matrixWorld),fx.setFromProjectionMatrix(Qa,h.coordinateSystem,h.reversedDepth));let gt=0;if(this.sortObjects){Qa.copy(this.matrixWorld).invert(),pp.setFromMatrixPosition(h.matrixWorld).applyMatrix4(Qa),vh.set(0,0,-1).transformDirection(h.matrixWorld).transformDirection(Qa);for(let Pt=0,Wt=V.length;Pt0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;gh)return;ng.applyMatrix4(j.matrixWorld);const H=i.ray.origin.distanceTo(ng);if(!(Hi.far))return{distance:H,point:mx.clone().applyMatrix4(j.matrixWorld),index:v,face:null,faceIndex:null,barycoord:null,object:j}}const ig=new Rt,xp=new Rt;class _p extends null{constructor(i,l){super(i,l),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const i=this.geometry;if(i.index===null){const l=i.attributes.position,h=[];for(let f=0,g=l.count;f0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,v=f.length;gf.far)return;g.push({distance:H,distanceToRay:Math.sqrt(C),point:V,index:i,face:null,faceIndex:null,barycoord:null,object:v})}}class g3 extends null{constructor(i,l,h,f,g=Rn,v=Rn,C,V,H){super(i,l,h,f,g,v,C,V,H),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const J=this;function he(){J.needsUpdate=!0,J._requestVideoFrameCallbackId=i.requestVideoFrameCallback(he)}"requestVideoFrameCallback"in i&&(this._requestVideoFrameCallbackId=i.requestVideoFrameCallback(he))}clone(){return new this.constructor(this.image).copy(this)}update(){const i=this.image;"requestVideoFrameCallback"in i===!1&&i.readyState>=i.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class gc extends null{constructor(i,l,h,f,g,v,C,V){super({},i,l,h,f,g,v,C,V),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(i){this.image=i,this.needsUpdate=!0}}class y1 extends null{constructor(i,l){super({width:i,height:l}),this.isFramebufferTexture=!0,this.magFilter=Ct,this.minFilter=Ct,this.generateMipmaps=!1,this.needsUpdate=!0}}class $0 extends null{constructor(i,l,h,f,g,v,C,V,H,J,he,pe){super(null,v,C,V,H,J,f,g,he,pe),this.isCompressedTexture=!0,this.image={width:l,height:h},this.mipmaps=i,this.flipY=!1,this.generateMipmaps=!1}}class yx extends null{constructor(i,l,h,f,g,v){super(i,l,h,g,v),this.isCompressedArrayTexture=!0,this.image.depth=f,this.wrapR=qe,this.layerUpdates=new Set}addLayerUpdate(i){this.layerUpdates.add(i)}clearLayerUpdates(){this.layerUpdates.clear()}}class wp extends null{constructor(i,l,h){super(void 0,i[0].width,i[0].height,l,h,Fe),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=i}}class Mp extends xl{constructor(i,l,h,f,g,v,C,V,H){super(i,l,h,f,g,v,C,V,H),this.isCanvasTexture=!0,this.needsUpdate=!0}}class hf extends null{constructor(i,l,h=as,f,g,v,C=Ct,V=Ct,H,J=U,he=1){if(J!==U&&J!==_)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const pe={width:i,height:l,depth:he};super(pe,f,g,v,C,V,J,h,H),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(i){return super.copy(i),this.source=new Za(Object.assign({},i.image)),this.compareFunction=i.compareFunction,this}toJSON(i){const l=super.toJSON(i);return this.compareFunction!==null&&(l.compareFunction=this.compareFunction),l}}class vx extends null{constructor(i=null){super(),this.sourceTexture=i,this.isExternalTexture=!0}copy(i){return super.copy(i),this.sourceTexture=i.sourceTexture,this}}class df extends Or{constructor(i=1,l=1,h=4,f=8,g=1){super(),this.type="CapsuleGeometry",this.parameters={radius:i,height:l,capSegments:h,radialSegments:f,heightSegments:g},l=Math.max(0,l),h=Math.max(1,Math.floor(h)),f=Math.max(3,Math.floor(f)),g=Math.max(1,Math.floor(g));const v=[],C=[],V=[],H=[],J=l/2,he=Math.PI/2*i,pe=l,me=2*he+pe,Se=h*2+g,tt=f+1,gt=new Rt,mt=new Rt;for(let Nt=0;Nt<=Se;Nt++){let Pt=0,Wt=0,gn=0,Sn=0;if(Nt<=h){const ii=Nt/h,li=ii*Math.PI/2;Wt=-J-i*Math.cos(li),gn=i*Math.sin(li),Sn=-i*Math.cos(li),Pt=ii*he}else if(Nt<=h+g){const ii=(Nt-h)/g;Wt=-J+ii*l,gn=i,Sn=0,Pt=he+ii*pe}else{const ii=(Nt-h-g)/h,li=ii*Math.PI/2;Wt=J+i*Math.sin(li),gn=i*Math.cos(li),Sn=i*Math.sin(li),Pt=he+pe+ii*he}const kn=Math.max(0,Math.min(1,Pt/me));let In=0;Nt===0?In=.5/f:Nt===Se&&(In=-.5/f);for(let ii=0;ii<=f;ii++){const li=ii/f,dr=li*Math.PI*2,Yr=Math.sin(dr),Ss=Math.cos(dr);mt.x=-gn*Ss,mt.y=Wt,mt.z=gn*Yr,C.push(mt.x,mt.y,mt.z),gt.set(-gn*Ss,Sn,gn*Yr),gt.normalize(),V.push(gt.x,gt.y,gt.z),H.push(li+In,kn)}if(Nt>0){const ii=(Nt-1)*tt;for(let li=0;li0&&Pt(!0),l>0&&Pt(!1)),this.setIndex(J),this.setAttribute("position",new qi(he,3)),this.setAttribute("normal",new qi(pe,3)),this.setAttribute("uv",new qi(me,2));function Nt(){const Wt=new Rt,gn=new Rt;let Sn=0;const kn=(l-i)/h;for(let In=0;In<=g;In++){const ii=[],li=In/g,dr=li*(l-i)+i;for(let Yr=0;Yr<=f;Yr++){const Ss=Yr/f,eo=Ss*V+C,uo=Math.sin(eo),Aa=Math.cos(eo);gn.x=dr*uo,gn.y=-li*h+gt,gn.z=dr*Aa,he.push(gn.x,gn.y,gn.z),Wt.set(uo,kn,Aa).normalize(),pe.push(Wt.x,Wt.y,Wt.z),me.push(Ss,1-li),ii.push(Se++)}tt.push(ii)}for(let In=0;In0||ii!==0)&&(J.push(li,dr,Ss),Sn+=3),(l>0||ii!==g-1)&&(J.push(dr,Yr,Ss),Sn+=3)}H.addGroup(mt,Sn,0),mt+=Sn}function Pt(Wt){const gn=Se,Sn=new oi,kn=new Rt;let In=0;const ii=Wt===!0?i:l,li=Wt===!0?1:-1;for(let Yr=1;Yr<=f;Yr++)he.push(0,gt*li,0),pe.push(0,li,0),me.push(.5,.5),Se++;const dr=Se;for(let Yr=0;Yr<=f;Yr++){const eo=Yr/f*V+C,uo=Math.cos(eo),Aa=Math.sin(eo);kn.x=ii*Aa,kn.y=gt*li,kn.z=ii*uo,he.push(kn.x,kn.y,kn.z),pe.push(0,li,0),Sn.x=uo*.5+.5,Sn.y=Aa*.5*li+.5,me.push(Sn.x,Sn.y),Se++}for(let Yr=0;Yr.9&&kn<.1&&(Pt<.2&&(v[Nt+0]+=1),Wt<.2&&(v[Nt+2]+=1),gn<.2&&(v[Nt+4]+=1))}}function pe(Nt){g.push(Nt.x,Nt.y,Nt.z)}function me(Nt,Pt){const Wt=Nt*3;Pt.x=i[Wt+0],Pt.y=i[Wt+1],Pt.z=i[Wt+2]}function Se(){const Nt=new Rt,Pt=new Rt,Wt=new Rt,gn=new Rt,Sn=new oi,kn=new oi,In=new oi;for(let ii=0,li=0;ii0)V=f-1;else{V=f;break}if(f=V,h[f]===v)return f/(g-1);const J=h[f],pe=h[f+1]-J,me=(v-J)/pe;return(f+me)/(g-1)}getTangent(i,l){let f=i-1e-4,g=i+1e-4;f<0&&(f=0),g>1&&(g=1);const v=this.getPoint(f),C=this.getPoint(g),V=l||(v.isVector2?new oi:new Rt);return V.copy(C).sub(v).normalize(),V}getTangentAt(i,l){const h=this.getUtoTmapping(i);return this.getTangent(h,l)}computeFrenetFrames(i,l=!1){const h=new Rt,f=[],g=[],v=[],C=new Rt,V=new On;for(let me=0;me<=i;me++){const Se=me/i;f[me]=this.getTangentAt(Se,new Rt)}g[0]=new Rt,v[0]=new Rt;let H=Number.MAX_VALUE;const J=Math.abs(f[0].x),he=Math.abs(f[0].y),pe=Math.abs(f[0].z);J<=H&&(H=J,h.set(1,0,0)),he<=H&&(H=he,h.set(0,1,0)),pe<=H&&h.set(0,0,1),C.crossVectors(f[0],h).normalize(),g[0].crossVectors(f[0],C),v[0].crossVectors(f[0],g[0]);for(let me=1;me<=i;me++){if(g[me]=g[me-1].clone(),v[me]=v[me-1].clone(),C.crossVectors(f[me-1],f[me]),C.length()>Number.EPSILON){C.normalize();const Se=Math.acos(Fr(f[me-1].dot(f[me]),-1,1));g[me].applyMatrix4(V.makeRotationAxis(C,Se))}v[me].crossVectors(f[me],g[me])}if(l===!0){let me=Math.acos(Fr(g[0].dot(g[i]),-1,1));me/=i,f[0].dot(C.crossVectors(g[0],g[i]))>0&&(me=-me);for(let Se=1;Se<=i;Se++)g[Se].applyMatrix4(V.makeRotationAxis(f[Se],me*Se)),v[Se].crossVectors(f[Se],g[Se])}return{tangents:f,normals:g,binormals:v}}clone(){return new this.constructor().copy(this)}copy(i){return this.arcLengthDivisions=i.arcLengthDivisions,this}toJSON(){const i={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return i.arcLengthDivisions=this.arcLengthDivisions,i.type=this.type,i}fromJSON(i){return this.arcLengthDivisions=i.arcLengthDivisions,this}}class Tp extends vc{constructor(i=0,l=0,h=1,f=1,g=0,v=Math.PI*2,C=!1,V=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=i,this.aY=l,this.xRadius=h,this.yRadius=f,this.aStartAngle=g,this.aEndAngle=v,this.aClockwise=C,this.aRotation=V}getPoint(i,l=new oi){const h=l,f=Math.PI*2;let g=this.aEndAngle-this.aStartAngle;const v=Math.abs(g)f;)g-=f;g0?0:(Math.floor(Math.abs(C)/g)+1)*g:V===0&&C===g-1&&(C=g-2,V=1);let H,J;this.closed||C>0?H=f[(C-1)%g]:(ag.subVectors(f[0],f[1]).add(f[0]),H=ag);const he=f[C%g],pe=f[(C+1)%g];if(this.closed||C+2f.length-2?f.length-1:v+1],he=f[v>f.length-3?f.length-1:v+2];return h.set(xx(C,V.x,H.x,J.x,he.x),xx(C,V.y,H.y,J.y,he.y)),h}copy(i){super.copy(i),this.points=[];for(let l=0,h=i.points.length;l=h){const v=f[g]-h,C=this.curves[g],V=C.getLength(),H=V===0?0:1-v/V;return C.getPointAt(H,l)}g++}return null}getLength(){const i=this.getCurveLengths();return i[i.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const i=[];let l=0;for(let h=0,f=this.curves.length;h1&&!l[l.length-1].equals(l[0])&&l.push(l[0]),l}copy(i){super.copy(i),this.curves=[];for(let l=0,h=i.curves.length;l0){const he=H.getPoint(0);he.equals(this.currentPoint)||this.lineTo(he.x,he.y)}this.curves.push(H);const J=H.getPoint(1);return this.currentPoint.copy(J),this}copy(i){return super.copy(i),this.currentPoint.copy(i.currentPoint),this}toJSON(){const i=super.toJSON();return i.currentPoint=this.currentPoint.toArray(),i}fromJSON(i){return super.fromJSON(i),this.currentPoint.fromArray(i.currentPoint),this}}class yf extends J0{constructor(i){super(i),this.uuid=Sl(),this.type="Shape",this.holes=[]}getPointsHoles(i){const l=[];for(let h=0,f=this.holes.length;h80*l){C=j[0],V=j[1];let J=C,he=V;for(let pe=l;peJ&&(J=me),Se>he&&(he=Se)}H=Math.max(J-C,he-V),H=H!==0?32767/H:0}return Cp(g,v,l,C,V,H,0),v}function Tx(j,i,l,h,f){let g;if(f===L1(j,i,l,h)>0)for(let v=i;v=i;v-=h)g=ny(v/h|0,j[v],j[v+1],g);return g&&vf(g,g.next)&&(xf(g),g=g.next),g}function gd(j,i){if(!j)return j;i||(i=j);let l=j,h;do if(h=!1,!l.steiner&&(vf(l,l.next)||Mo(l.prev,l,l.next)===0)){if(xf(l),l=i=l.prev,l===l.next)break;h=!0}else l=l.next;while(h||l!==i);return i}function Cp(j,i,l,h,f,g,v){if(!j)return;!v&&g&&N1(j,h,f,g);let C=j;for(;j.prev!==j.next;){const V=j.prev,H=j.next;if(g?T1(j,h,f,g):S1(j)){i.push(V.i,j.i,H.i),xf(j),j=H.next,C=H.next;continue}if(j=H,j===C){v?v===1?(j=E1(gd(j),i),Cp(j,i,l,h,f,g,2)):v===2&&A1(j,i,l,h,f,g):Cp(gd(j),i,l,h,f,g,1);break}}}function S1(j){const i=j.prev,l=j,h=j.next;if(Mo(i,l,h)>=0)return!1;const f=i.x,g=l.x,v=h.x,C=i.y,V=l.y,H=h.y,J=Math.min(f,g,v),he=Math.min(C,V,H),pe=Math.max(f,g,v),me=Math.max(C,V,H);let Se=h.next;for(;Se!==i;){if(Se.x>=J&&Se.x<=pe&&Se.y>=he&&Se.y<=me&&bh(f,C,g,V,v,H,Se.x,Se.y)&&Mo(Se.prev,Se,Se.next)>=0)return!1;Se=Se.next}return!0}function T1(j,i,l,h){const f=j.prev,g=j,v=j.next;if(Mo(f,g,v)>=0)return!1;const C=f.x,V=g.x,H=v.x,J=f.y,he=g.y,pe=v.y,me=Math.min(C,V,H),Se=Math.min(J,he,pe),tt=Math.max(C,V,H),gt=Math.max(J,he,pe),mt=_h(me,Se,i,l,h),Nt=_h(tt,gt,i,l,h);let Pt=j.prevZ,Wt=j.nextZ;for(;Pt&&Pt.z>=mt&&Wt&&Wt.z<=Nt;){if(Pt.x>=me&&Pt.x<=tt&&Pt.y>=Se&&Pt.y<=gt&&Pt!==f&&Pt!==v&&bh(C,J,V,he,H,pe,Pt.x,Pt.y)&&Mo(Pt.prev,Pt,Pt.next)>=0||(Pt=Pt.prevZ,Wt.x>=me&&Wt.x<=tt&&Wt.y>=Se&&Wt.y<=gt&&Wt!==f&&Wt!==v&&bh(C,J,V,he,H,pe,Wt.x,Wt.y)&&Mo(Wt.prev,Wt,Wt.next)>=0))return!1;Wt=Wt.nextZ}for(;Pt&&Pt.z>=mt;){if(Pt.x>=me&&Pt.x<=tt&&Pt.y>=Se&&Pt.y<=gt&&Pt!==f&&Pt!==v&&bh(C,J,V,he,H,pe,Pt.x,Pt.y)&&Mo(Pt.prev,Pt,Pt.next)>=0)return!1;Pt=Pt.prevZ}for(;Wt&&Wt.z<=Nt;){if(Wt.x>=me&&Wt.x<=tt&&Wt.y>=Se&&Wt.y<=gt&&Wt!==f&&Wt!==v&&bh(C,J,V,he,H,pe,Wt.x,Wt.y)&&Mo(Wt.prev,Wt,Wt.next)>=0)return!1;Wt=Wt.nextZ}return!0}function E1(j,i){let l=j;do{const h=l.prev,f=l.next.next;!vf(h,f)&&ey(h,l,l.next,f)&&Ip(h,f)&&Ip(f,h)&&(i.push(h.i,l.i,f.i),xf(l),xf(l.next),l=j=f),l=l.next}while(l!==j);return gd(l)}function A1(j,i,l,h,f,g){let v=j;do{let C=v.next.next;for(;C!==v.prev;){if(v.i!==C.i&&P1(v,C)){let V=Gc(v,C);v=gd(v,v.next),V=gd(V,V.next),Cp(v,i,l,h,f,g,0),Cp(V,i,l,h,f,g,0);return}C=C.next}v=v.next}while(v!==j)}function C1(j,i,l,h){const f=[];for(let g=0,v=i.length;g=l.next.y&&l.next.y!==l.y){const he=l.x+(f-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(he<=h&&he>g&&(g=he,v=l.x=l.x&&l.x>=V&&h!==l.x&&Np(fv.x||l.x===v.x&&Rp(v,l)))&&(v=l,J=he)}l=l.next}while(l!==C);return v}function Rp(j,i){return Mo(j.prev,j,i.prev)<0&&Mo(i.next,j,j.next)<0}function N1(j,i,l,h){let f=j;do f.z===0&&(f.z=_h(f.x,f.y,i,l,h)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==j);f.prevZ.nextZ=null,f.prevZ=null,jo(f)}function jo(j){let i,l=1;do{let h=j,f;j=null;let g=null;for(i=0;h;){i++;let v=h,C=0;for(let H=0;H0||V>0&&v;)C!==0&&(V===0||!v||h.z<=v.z)?(f=h,h=h.nextZ,C--):(f=v,v=v.nextZ,V--),g?g.nextZ=f:j=f,f.prevZ=g,g=f;h=v}g.nextZ=null,l*=2}while(i>1);return j}function _h(j,i,l,h,f){return j=(j-l)*f|0,i=(i-h)*f|0,j=(j|j<<8)&16711935,j=(j|j<<4)&252645135,j=(j|j<<2)&858993459,j=(j|j<<1)&1431655765,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,j|i<<1}function Ax(j){let i=j,l=j;do(i.x=(j-v)*(g-C)&&(j-v)*(h-C)>=(l-v)*(i-C)&&(l-v)*(g-C)>=(f-v)*(h-C)}function bh(j,i,l,h,f,g,v,C){return!(j===v&&i===C)&&Np(j,i,l,h,f,g,v,C)}function P1(j,i){return j.next.i!==i.i&&j.prev.i!==i.i&&!ty(j,i)&&(Ip(j,i)&&Ip(i,j)&&I1(j,i)&&(Mo(j.prev,j,i.prev)||Mo(j,i.prev,i))||vf(j,i)&&Mo(j.prev,j,j.next)>0&&Mo(i.prev,i,i.next)>0)}function Mo(j,i,l){return(i.y-j.y)*(l.x-i.x)-(i.x-j.x)*(l.y-i.y)}function vf(j,i){return j.x===i.x&&j.y===i.y}function ey(j,i,l,h){const f=wh(Mo(j,i,l)),g=wh(Mo(j,i,h)),v=wh(Mo(l,h,j)),C=wh(Mo(l,h,i));return!!(f!==g&&v!==C||f===0&&Pp(j,l,i)||g===0&&Pp(j,h,i)||v===0&&Pp(l,j,h)||C===0&&Pp(l,i,h))}function Pp(j,i,l){return i.x<=Math.max(j.x,l.x)&&i.x>=Math.min(j.x,l.x)&&i.y<=Math.max(j.y,l.y)&&i.y>=Math.min(j.y,l.y)}function wh(j){return j>0?1:j<0?-1:0}function ty(j,i){let l=j;do{if(l.i!==j.i&&l.next.i!==j.i&&l.i!==i.i&&l.next.i!==i.i&&ey(l,l.next,j,i))return!0;l=l.next}while(l!==j);return!1}function Ip(j,i){return Mo(j.prev,j,j.next)<0?Mo(j,i,j.next)>=0&&Mo(j,j.prev,i)>=0:Mo(j,i,j.prev)<0||Mo(j,j.next,i)<0}function I1(j,i){let l=j,h=!1;const f=(j.x+i.x)/2,g=(j.y+i.y)/2;do l.y>g!=l.next.y>g&&l.next.y!==l.y&&f<(l.next.x-l.x)*(g-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==j);return h}function Gc(j,i){const l=Lp(j.i,j.x,j.y),h=Lp(i.i,i.x,i.y),f=j.next,g=i.prev;return j.next=i,i.prev=j,l.next=f,f.prev=l,h.next=l,l.prev=h,g.next=h,h.prev=g,h}function ny(j,i,l,h){const f=Lp(j,i,l);return h?(f.next=h.next,f.prev=h,h.next.prev=f,h.next=f):(f.prev=f,f.next=f),f}function xf(j){j.next.prev=j.prev,j.prev.next=j.next,j.prevZ&&(j.prevZ.nextZ=j.nextZ),j.nextZ&&(j.nextZ.prevZ=j.prevZ)}function Lp(j,i,l){return{i:j,x:i,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function L1(j,i,l,h){let f=0;for(let g=i,v=l-h;g2&&j[i-1].equals(j[0])&&j.pop()}function Dp(j,i){for(let l=0;lNumber.EPSILON){const ic=Math.sqrt(nc),Jx=Math.sqrt(Yo*Yo+Ga*Ga),Qx=tr.x-zo/ic,e_=tr.y+Ts/ic,lw=rr.x-Ga/Jx,cw=rr.y+Yo/Jx,t_=((lw-Qx)*Ga-(cw-e_)*Yo)/(Ts*Ga-zo*Yo);fr=Qx+Ts*t_-Ui.x,lr=e_+zo*t_-Ui.y;const n_=fr*fr+lr*lr;if(n_<=2)return new oi(fr,lr);Js=Math.sqrt(n_/2)}else{let ic=!1;Ts>Number.EPSILON?Yo>Number.EPSILON&&(ic=!0):Ts<-Number.EPSILON?Yo<-Number.EPSILON&&(ic=!0):Math.sign(zo)===Math.sign(Ga)&&(ic=!0),ic?(fr=-zo,lr=Ts,Js=Math.sqrt(nc)):(fr=Ts,lr=zo,Js=Math.sqrt(nc/2))}return new oi(fr/Js,lr/Js)}const Xo=[];for(let Ui=0,tr=uo.length,rr=tr-1,fr=Ui+1;Ui=0;Ui--){const tr=Ui/gt,rr=me*Math.cos(tr*Math.PI/2),fr=Se*Math.sin(tr*Math.PI/2)+tt;for(let lr=0,Js=uo.length;lr=0;){const fr=rr;let lr=rr-1;lr<0&&(lr=Ui.length-1);for(let Js=0,Ts=J+gt*2;Js0)&&me.push(Pt,Wt,Sn),(mt!==h-1||V0!=i>0&&this.version++,this._anisotropy=i}get clearcoat(){return this._clearcoat}set clearcoat(i){this._clearcoat>0!=i>0&&this.version++,this._clearcoat=i}get iridescence(){return this._iridescence}set iridescence(i){this._iridescence>0!=i>0&&this.version++,this._iridescence=i}get dispersion(){return this._dispersion}set dispersion(i){this._dispersion>0!=i>0&&this.version++,this._dispersion=i}get sheen(){return this._sheen}set sheen(i){this._sheen>0!=i>0&&this.version++,this._sheen=i}get transmission(){return this._transmission}set transmission(i){this._transmission>0!=i>0&&this.version++,this._transmission=i}copy(i){return super.copy(i),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=i.anisotropy,this.anisotropyRotation=i.anisotropyRotation,this.anisotropyMap=i.anisotropyMap,this.clearcoat=i.clearcoat,this.clearcoatMap=i.clearcoatMap,this.clearcoatRoughness=i.clearcoatRoughness,this.clearcoatRoughnessMap=i.clearcoatRoughnessMap,this.clearcoatNormalMap=i.clearcoatNormalMap,this.clearcoatNormalScale.copy(i.clearcoatNormalScale),this.dispersion=i.dispersion,this.ior=i.ior,this.iridescence=i.iridescence,this.iridescenceMap=i.iridescenceMap,this.iridescenceIOR=i.iridescenceIOR,this.iridescenceThicknessRange=[...i.iridescenceThicknessRange],this.iridescenceThicknessMap=i.iridescenceThicknessMap,this.sheen=i.sheen,this.sheenColor.copy(i.sheenColor),this.sheenColorMap=i.sheenColorMap,this.sheenRoughness=i.sheenRoughness,this.sheenRoughnessMap=i.sheenRoughnessMap,this.transmission=i.transmission,this.transmissionMap=i.transmissionMap,this.thickness=i.thickness,this.thicknessMap=i.thicknessMap,this.attenuationDistance=i.attenuationDistance,this.attenuationColor.copy(i.attenuationColor),this.specularIntensity=i.specularIntensity,this.specularIntensityMap=i.specularIntensityMap,this.specularColor.copy(i.specularColor),this.specularColorMap=i.specularColorMap,this}}class uy extends Ro{constructor(i){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ar(16777215),this.specular=new ar(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cs,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.specular.copy(i.specular),this.shininess=i.shininess,this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.flatShading=i.flatShading,this.fog=i.fog,this}}class hy extends null{constructor(i){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ar(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.gradientMap=i.gradientMap,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.alphaMap=i.alphaMap,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.fog=i.fog,this}}class yd extends null{constructor(i){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(i)}copy(i){return super.copy(i),this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.flatShading=i.flatShading,this}}class Ix extends null{constructor(i){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ar(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ar(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new cs,this.combine=xt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.color.copy(i.color),this.map=i.map,this.lightMap=i.lightMap,this.lightMapIntensity=i.lightMapIntensity,this.aoMap=i.aoMap,this.aoMapIntensity=i.aoMapIntensity,this.emissive.copy(i.emissive),this.emissiveMap=i.emissiveMap,this.emissiveIntensity=i.emissiveIntensity,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.specularMap=i.specularMap,this.alphaMap=i.alphaMap,this.envMap=i.envMap,this.envMapRotation.copy(i.envMapRotation),this.combine=i.combine,this.reflectivity=i.reflectivity,this.refractionRatio=i.refractionRatio,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.wireframeLinecap=i.wireframeLinecap,this.wireframeLinejoin=i.wireframeLinejoin,this.flatShading=i.flatShading,this.fog=i.fog,this}}class Lx extends null{constructor(i){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jf,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(i)}copy(i){return super.copy(i),this.depthPacking=i.depthPacking,this.map=i.map,this.alphaMap=i.alphaMap,this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this}}class dy extends null{constructor(i){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(i)}copy(i){return super.copy(i),this.map=i.map,this.alphaMap=i.alphaMap,this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this}}class fy extends null{constructor(i){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ar(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=$a,this.normalScale=new oi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(i)}copy(i){return super.copy(i),this.defines={MATCAP:""},this.color.copy(i.color),this.matcap=i.matcap,this.map=i.map,this.bumpMap=i.bumpMap,this.bumpScale=i.bumpScale,this.normalMap=i.normalMap,this.normalMapType=i.normalMapType,this.normalScale.copy(i.normalScale),this.displacementMap=i.displacementMap,this.displacementScale=i.displacementScale,this.displacementBias=i.displacementBias,this.alphaMap=i.alphaMap,this.wireframe=i.wireframe,this.wireframeLinewidth=i.wireframeLinewidth,this.flatShading=i.flatShading,this.fog=i.fog,this}}class F1 extends null{constructor(i){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(i)}copy(i){return super.copy(i),this.scale=i.scale,this.dashSize=i.dashSize,this.gapSize=i.gapSize,this}}function vd(j,i){return!j||j.constructor===i?j:typeof i.BYTES_PER_ELEMENT=="number"?new i(j):Array.prototype.slice.call(j)}function B1(j){return ArrayBuffer.isView(j)&&!(j instanceof DataView)}function Up(j){function i(f,g){return j[f]-j[g]}const l=j.length,h=new Array(l);for(let f=0;f!==l;++f)h[f]=f;return h.sort(i),h}function py(j,i,l){const h=j.length,f=new j.constructor(h);for(let g=0,v=0;v!==h;++g){const C=l[g]*i;for(let V=0;V!==i;++V)f[v++]=j[C+V]}return f}function dg(j,i,l,h){let f=1,g=j[0];for(;g!==void 0&&g[h]===void 0;)g=j[f++];if(g===void 0)return;let v=g[h];if(v!==void 0)if(Array.isArray(v))do v=g[h],v!==void 0&&(i.push(g.time),l.push(...v)),g=j[f++];while(g!==void 0);else if(v.toArray!==void 0)do v=g[h],v!==void 0&&(i.push(g.time),v.toArray(l,l.length)),g=j[f++];while(g!==void 0);else do v=g[h],v!==void 0&&(i.push(g.time),l.push(v)),g=j[f++];while(g!==void 0)}function U1(j,i,l,h,f=30){const g=j.clone();g.name=i;const v=[];for(let V=0;V=h)){he.push(H.times[me]);for(let tt=0;ttg.tracks[V].times[0]&&(C=g.tracks[V].times[0]);for(let V=0;V=C.times[Se]){const mt=Se*he+J,Nt=mt+he-J;tt=C.values.slice(mt,Nt)}else{const mt=C.createInterpolant(),Nt=J,Pt=he-J;mt.evaluate(g),tt=mt.resultBuffer.slice(Nt,Pt)}V==="quaternion"&&new vl().fromArray(tt).normalize().conjugate().toArray(tt);const gt=H.times.length;for(let mt=0;mt=g)){const C=l[1];i=g)break t}v=h,h=0;break n}break e}for(;h>>1;il;)--v;if(++v,g!==0||v!==f){g>=v&&(v=Math.max(v,1),g=v-1);const C=this.getValueSize();this.times=h.slice(g,v),this.values=this.values.slice(g*C,v*C)}return this}validate(){let i=!0;const l=this.getValueSize();l-Math.floor(l)!==0&&(js("KeyframeTrack: Invalid value size in track.",this),i=!1);const h=this.times,f=this.values,g=h.length;g===0&&(js("KeyframeTrack: Track is empty.",this),i=!1);let v=null;for(let C=0;C!==g;C++){const V=h[C];if(typeof V=="number"&&isNaN(V)){js("KeyframeTrack: Time is not a valid number.",this,C,V),i=!1;break}if(v!==null&&v>V){js("KeyframeTrack: Out of order keys.",this,C,V,v),i=!1;break}v=V}if(f!==void 0&&B1(f))for(let C=0,V=f.length;C!==V;++C){const H=f[C];if(isNaN(H)){js("KeyframeTrack: Value is not a valid number.",this,C,H),i=!1;break}}return i}optimize(){const i=this.times.slice(),l=this.values.slice(),h=this.getValueSize(),f=this.getInterpolation()===rl,g=i.length-1;let v=1;for(let C=1;C0){i[v]=i[g];for(let C=g*h,V=v*h,H=0;H!==h;++H)l[V+H]=l[C+H];++v}return v!==i.length?(this.times=i.slice(0,v),this.values=l.slice(0,v*h)):(this.times=i,this.values=l),this}clone(){const i=this.times.slice(),l=this.values.slice(),h=this.constructor,f=new h(this.name,i,l);return f.createInterpolant=this.createInterpolant,f}}_l.prototype.ValueTypeName="",_l.prototype.TimeBufferType=Float32Array,_l.prototype.ValueBufferType=Float32Array,_l.prototype.DefaultInterpolation=il;class Xu extends _l{constructor(i,l,h){super(i,l,h)}}Xu.prototype.ValueTypeName="bool",Xu.prototype.ValueBufferType=Array,Xu.prototype.DefaultInterpolation=Ao,Xu.prototype.InterpolantFactoryMethodLinear=void 0,Xu.prototype.InterpolantFactoryMethodSmooth=void 0;class Vp extends _l{constructor(i,l,h,f){super(i,l,h,f)}}Vp.prototype.ValueTypeName="color";class mg extends _l{constructor(i,l,h,f){super(i,l,h,f)}}mg.prototype.ValueTypeName="number";class k1 extends zp{constructor(i,l,h,f){super(i,l,h,f)}interpolate_(i,l,h,f){const g=this.resultBuffer,v=this.sampleValues,C=this.valueSize,V=(h-l)/(f-l);let H=i*C;for(let J=H+C;H!==J;H+=4)vl.slerpFlat(g,0,v,H-C,v,H,V);return g}}class _c extends _l{constructor(i,l,h,f){super(i,l,h,f)}InterpolantFactoryMethodLinear(i){return new k1(this.times,this.values,this.getValueSize(),i)}}_c.prototype.ValueTypeName="quaternion",_c.prototype.InterpolantFactoryMethodSmooth=void 0;class xd extends _l{constructor(i,l,h){super(i,l,h)}}xd.prototype.ValueTypeName="string",xd.prototype.ValueBufferType=Array,xd.prototype.DefaultInterpolation=Ao,xd.prototype.InterpolantFactoryMethodLinear=void 0,xd.prototype.InterpolantFactoryMethodSmooth=void 0;class gg extends _l{constructor(i,l,h,f){super(i,l,h,f)}}gg.prototype.ValueTypeName="vector";class Mf{constructor(i="",l=-1,h=[],f=bo){this.name=i,this.tracks=h,this.duration=l,this.blendMode=f,this.uuid=Sl(),this.userData={},this.duration<0&&this.resetDuration()}static parse(i){const l=[],h=i.tracks,f=1/(i.fps||1);for(let v=0,C=h.length;v!==C;++v)l.push(z1(h[v]).scale(f));const g=new this(i.name,i.duration,l,i.blendMode);return g.uuid=i.uuid,g.userData=JSON.parse(i.userData||"{}"),g}static toJSON(i){const l=[],h=i.tracks,f={name:i.name,duration:i.duration,tracks:l,uuid:i.uuid,blendMode:i.blendMode,userData:JSON.stringify(i.userData)};for(let g=0,v=h.length;g!==v;++g)l.push(_l.toJSON(h[g]));return f}static CreateFromMorphTargetSequence(i,l,h,f){const g=l.length,v=[];for(let C=0;C1){const he=J[1];let pe=f[he];pe||(f[he]=pe=[]),pe.push(H)}}const v=[];for(const C in f)v.push(this.CreateFromMorphTargetSequence(C,f[C],l,h));return v}static parseAnimation(i,l){if(_r("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!i)return js("AnimationClip: No animation in JSONLoader data."),null;const h=function(he,pe,me,Se,tt){if(me.length!==0){const gt=[],mt=[];dg(me,gt,mt,Se),gt.length!==0&&tt.push(new he(pe,gt,mt))}},f=[],g=i.name||"default",v=i.fps||30,C=i.blendMode;let V=i.length||-1;const H=i.hierarchy||[];for(let he=0;he{l&&l(g),this.manager.itemEnd(i)},0),g;if(bc[i]!==void 0){bc[i].push({onLoad:l,onProgress:h,onError:f});return}bc[i]=[],bc[i].push({onLoad:l,onProgress:h,onError:f});const v=new Request(i,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),C=this.mimeType,V=this.responseType;fetch(v).then(H=>{if(H.status===200||H.status===0){if(H.status===0&&_r("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||H.body===void 0||H.body.getReader===void 0)return H;const J=bc[i],he=H.body.getReader(),pe=H.headers.get("X-File-Size")||H.headers.get("Content-Length"),me=pe?parseInt(pe):0,Se=me!==0;let tt=0;const gt=new ReadableStream({start(mt){Nt();function Nt(){he.read().then(({done:Pt,value:Wt})=>{if(Pt)mt.close();else{tt+=Wt.byteLength;const gn=new ProgressEvent("progress",{lengthComputable:Se,loaded:tt,total:me});for(let Sn=0,kn=J.length;Sn{mt.error(Pt)})}}});return new Response(gt)}else throw new uE(`fetch for "${H.url}" responded with ${H.status}: ${H.statusText}`,H)}).then(H=>{switch(V){case"arraybuffer":return H.arrayBuffer();case"blob":return H.blob();case"document":return H.text().then(J=>new DOMParser().parseFromString(J,C));case"json":return H.json();default:if(C==="")return H.text();{const he=/charset="?([^;"\s]*)"?/i.exec(C),pe=he&&he[1]?he[1].toLowerCase():void 0,me=new TextDecoder(pe);return H.arrayBuffer().then(Se=>me.decode(Se))}}}).then(H=>{bl.add(`file:${i}`,H);const J=bc[i];delete bc[i];for(let he=0,pe=J.length;he{const J=bc[i];if(J===void 0)throw this.manager.itemError(i),H;delete bc[i];for(let he=0,pe=J.length;he{this.manager.itemEnd(i)}),this.manager.itemStart(i)}setResponseType(i){return this.responseType=i,this}setMimeType(i){return this.mimeType=i,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class hE extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(this.manager);v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(i,function(C){try{l(g.parse(JSON.parse(C)))}catch(V){f?f(V):js(V),g.manager.itemError(i)}},h,f)}parse(i){const l=[];for(let h=0;h0:f.vertexColors=i.vertexColors),i.uniforms!==void 0)for(const g in i.uniforms){const v=i.uniforms[g];switch(f.uniforms[g]={},v.type){case"t":f.uniforms[g].value=h(v.value);break;case"c":f.uniforms[g].value=new ar().setHex(v.value);break;case"v2":f.uniforms[g].value=new oi().fromArray(v.value);break;case"v3":f.uniforms[g].value=new Rt().fromArray(v.value);break;case"v4":f.uniforms[g].value=new Ba().fromArray(v.value);break;case"m3":f.uniforms[g].value=new ua().fromArray(v.value);break;case"m4":f.uniforms[g].value=new On().fromArray(v.value);break;default:f.uniforms[g].value=v.value}}if(i.defines!==void 0&&(f.defines=i.defines),i.vertexShader!==void 0&&(f.vertexShader=i.vertexShader),i.fragmentShader!==void 0&&(f.fragmentShader=i.fragmentShader),i.glslVersion!==void 0&&(f.glslVersion=i.glslVersion),i.extensions!==void 0)for(const g in i.extensions)f.extensions[g]=i.extensions[g];if(i.lights!==void 0&&(f.lights=i.lights),i.clipping!==void 0&&(f.clipping=i.clipping),i.size!==void 0&&(f.size=i.size),i.sizeAttenuation!==void 0&&(f.sizeAttenuation=i.sizeAttenuation),i.map!==void 0&&(f.map=h(i.map)),i.matcap!==void 0&&(f.matcap=h(i.matcap)),i.alphaMap!==void 0&&(f.alphaMap=h(i.alphaMap)),i.bumpMap!==void 0&&(f.bumpMap=h(i.bumpMap)),i.bumpScale!==void 0&&(f.bumpScale=i.bumpScale),i.normalMap!==void 0&&(f.normalMap=h(i.normalMap)),i.normalMapType!==void 0&&(f.normalMapType=i.normalMapType),i.normalScale!==void 0){let g=i.normalScale;Array.isArray(g)===!1&&(g=[g,g]),f.normalScale=new oi().fromArray(g)}return i.displacementMap!==void 0&&(f.displacementMap=h(i.displacementMap)),i.displacementScale!==void 0&&(f.displacementScale=i.displacementScale),i.displacementBias!==void 0&&(f.displacementBias=i.displacementBias),i.roughnessMap!==void 0&&(f.roughnessMap=h(i.roughnessMap)),i.metalnessMap!==void 0&&(f.metalnessMap=h(i.metalnessMap)),i.emissiveMap!==void 0&&(f.emissiveMap=h(i.emissiveMap)),i.emissiveIntensity!==void 0&&(f.emissiveIntensity=i.emissiveIntensity),i.specularMap!==void 0&&(f.specularMap=h(i.specularMap)),i.specularIntensityMap!==void 0&&(f.specularIntensityMap=h(i.specularIntensityMap)),i.specularColorMap!==void 0&&(f.specularColorMap=h(i.specularColorMap)),i.envMap!==void 0&&(f.envMap=h(i.envMap)),i.envMapRotation!==void 0&&f.envMapRotation.fromArray(i.envMapRotation),i.envMapIntensity!==void 0&&(f.envMapIntensity=i.envMapIntensity),i.reflectivity!==void 0&&(f.reflectivity=i.reflectivity),i.refractionRatio!==void 0&&(f.refractionRatio=i.refractionRatio),i.lightMap!==void 0&&(f.lightMap=h(i.lightMap)),i.lightMapIntensity!==void 0&&(f.lightMapIntensity=i.lightMapIntensity),i.aoMap!==void 0&&(f.aoMap=h(i.aoMap)),i.aoMapIntensity!==void 0&&(f.aoMapIntensity=i.aoMapIntensity),i.gradientMap!==void 0&&(f.gradientMap=h(i.gradientMap)),i.clearcoatMap!==void 0&&(f.clearcoatMap=h(i.clearcoatMap)),i.clearcoatRoughnessMap!==void 0&&(f.clearcoatRoughnessMap=h(i.clearcoatRoughnessMap)),i.clearcoatNormalMap!==void 0&&(f.clearcoatNormalMap=h(i.clearcoatNormalMap)),i.clearcoatNormalScale!==void 0&&(f.clearcoatNormalScale=new oi().fromArray(i.clearcoatNormalScale)),i.iridescenceMap!==void 0&&(f.iridescenceMap=h(i.iridescenceMap)),i.iridescenceThicknessMap!==void 0&&(f.iridescenceThicknessMap=h(i.iridescenceThicknessMap)),i.transmissionMap!==void 0&&(f.transmissionMap=h(i.transmissionMap)),i.thicknessMap!==void 0&&(f.thicknessMap=h(i.thicknessMap)),i.anisotropyMap!==void 0&&(f.anisotropyMap=h(i.anisotropyMap)),i.sheenColorMap!==void 0&&(f.sheenColorMap=h(i.sheenColorMap)),i.sheenRoughnessMap!==void 0&&(f.sheenRoughnessMap=h(i.sheenRoughnessMap)),f}setTextures(i){return this.textures=i,this}createMaterialFromType(i){return _g.createMaterialFromType(i)}static createMaterialFromType(i){const l={ShadowMaterial:Rx,SpriteMaterial:nd,RawShaderMaterial:cy,ShaderMaterial:ed,PointsMaterial:H0,MeshPhysicalMaterial:Px,MeshStandardMaterial:Nx,MeshPhongMaterial:uy,MeshToonMaterial:hy,MeshNormalMaterial:yd,MeshLambertMaterial:Ix,MeshDepthMaterial:Lx,MeshDistanceMaterial:dy,MeshBasicMaterial:Ms,MeshMatcapMaterial:fy,LineDashedMaterial:F1,LineBasicMaterial:Rl,Material:Ro};return new l[i]}}class yy{static extractUrlBase(i){const l=i.lastIndexOf("/");return l===-1?"./":i.slice(0,l+1)}static resolveURL(i,l){return typeof i!="string"||i===""?"":(/^https?:\/\//i.test(l)&&/^\//.test(i)&&(l=l.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(i)||/^data:.*,.*$/i.test(i)||/^blob:.*$/i.test(i)?i:l+i)}}class vy extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(i){return super.copy(i),this.instanceCount=i.instanceCount,this}toJSON(){const i=super.toJSON();return i.instanceCount=this.instanceCount,i.isInstancedBufferGeometry=!0,i}}class mE extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(g.manager);v.setPath(g.path),v.setRequestHeader(g.requestHeader),v.setWithCredentials(g.withCredentials),v.load(i,function(C){try{l(g.parse(JSON.parse(C)))}catch(V){f?f(V):js(V),g.manager.itemError(i)}},h,f)}parse(i){const l={},h={};function f(me,Se){if(l[Se]!==void 0)return l[Se];const gt=me.interleavedBuffers[Se],mt=g(me,gt.buffer),Nt=Fu(gt.type,mt),Pt=new td(Nt,gt.stride);return Pt.uuid=gt.uuid,l[Se]=Pt,Pt}function g(me,Se){if(h[Se]!==void 0)return h[Se];const gt=me.arrayBuffers[Se],mt=new Uint32Array(gt).buffer;return h[Se]=mt,mt}const v=i.isInstancedBufferGeometry?new vy:new Or,C=i.data.index;if(C!==void 0){const me=Fu(C.type,C.array);v.setIndex(new yo(me,1))}const V=i.data.attributes;for(const me in V){const Se=V[me];let tt;if(Se.isInterleavedBufferAttribute){const gt=f(i.data,Se.data);tt=new Uc(gt,Se.itemSize,Se.offset,Se.normalized)}else{const gt=Fu(Se.type,Se.array),mt=Se.isInstancedBufferAttribute?$u:yo;tt=new mt(gt,Se.itemSize,Se.normalized)}Se.name!==void 0&&(tt.name=Se.name),Se.usage!==void 0&&tt.setUsage(Se.usage),v.setAttribute(me,tt)}const H=i.data.morphAttributes;if(H)for(const me in H){const Se=H[me],tt=[];for(let gt=0,mt=Se.length;gt0){const V=new V1(l);g=new Ef(V),g.setCrossOrigin(this.crossOrigin);for(let H=0,J=i.length;H0){f=new Ef(this.manager),f.setCrossOrigin(this.crossOrigin);for(let v=0,C=i.length;v{let gt=null,mt=null;return tt.boundingBox!==void 0&&(gt=new ta().fromJSON(tt.boundingBox)),tt.boundingSphere!==void 0&&(mt=new Gt().fromJSON(tt.boundingSphere)),ac(qs({},tt),{boundingBox:gt,boundingSphere:mt})}),v._instanceInfo=i.instanceInfo,v._availableInstanceIds=i._availableInstanceIds,v._availableGeometryIds=i._availableGeometryIds,v._nextIndexStart=i.nextIndexStart,v._nextVertexStart=i.nextVertexStart,v._geometryCount=i.geometryCount,v._maxInstanceCount=i.maxInstanceCount,v._maxVertexCount=i.maxVertexCount,v._maxIndexCount=i.maxIndexCount,v._geometryInitialized=i.geometryInitialized,v._matricesTexture=H(i.matricesTexture.uuid),v._indirectTexture=H(i.indirectTexture.uuid),i.colorsTexture!==void 0&&(v._colorsTexture=H(i.colorsTexture.uuid)),i.boundingSphere!==void 0&&(v.boundingSphere=new Gt().fromJSON(i.boundingSphere)),i.boundingBox!==void 0&&(v.boundingBox=new ta().fromJSON(i.boundingBox));break;case"LOD":v=new qm;break;case"Line":v=new uf(C(i.geometry),V(i.material));break;case"LineLoop":v=new p1(C(i.geometry),V(i.material));break;case"LineSegments":v=new _p(C(i.geometry),V(i.material));break;case"PointCloud":case"Points":v=new lE(C(i.geometry),V(i.material));break;case"Sprite":v=new O0(V(i.material));break;case"Group":v=new Wu;break;case"Bone":v=new ad;break;default:v=new xs}if(v.uuid=i.uuid,i.name!==void 0&&(v.name=i.name),i.matrix!==void 0?(v.matrix.fromArray(i.matrix),i.matrixAutoUpdate!==void 0&&(v.matrixAutoUpdate=i.matrixAutoUpdate),v.matrixAutoUpdate&&v.matrix.decompose(v.position,v.quaternion,v.scale)):(i.position!==void 0&&v.position.fromArray(i.position),i.rotation!==void 0&&v.rotation.fromArray(i.rotation),i.quaternion!==void 0&&v.quaternion.fromArray(i.quaternion),i.scale!==void 0&&v.scale.fromArray(i.scale)),i.up!==void 0&&v.up.fromArray(i.up),i.castShadow!==void 0&&(v.castShadow=i.castShadow),i.receiveShadow!==void 0&&(v.receiveShadow=i.receiveShadow),i.shadow&&(i.shadow.intensity!==void 0&&(v.shadow.intensity=i.shadow.intensity),i.shadow.bias!==void 0&&(v.shadow.bias=i.shadow.bias),i.shadow.normalBias!==void 0&&(v.shadow.normalBias=i.shadow.normalBias),i.shadow.radius!==void 0&&(v.shadow.radius=i.shadow.radius),i.shadow.mapSize!==void 0&&v.shadow.mapSize.fromArray(i.shadow.mapSize),i.shadow.camera!==void 0&&(v.shadow.camera=this.parseObject(i.shadow.camera))),i.visible!==void 0&&(v.visible=i.visible),i.frustumCulled!==void 0&&(v.frustumCulled=i.frustumCulled),i.renderOrder!==void 0&&(v.renderOrder=i.renderOrder),i.userData!==void 0&&(v.userData=i.userData),i.layers!==void 0&&(v.layers.mask=i.layers),i.children!==void 0){const pe=i.children;for(let me=0;me{if(bg.has(v)===!0)f&&f(bg.get(v)),g.manager.itemError(i),g.manager.itemEnd(i);else return l&&l(H),g.manager.itemEnd(i),H});return}return setTimeout(function(){l&&l(v),g.manager.itemEnd(i)},0),v}const C={};C.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",C.headers=this.requestHeader,C.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const V=fetch(i,C).then(function(H){return H.blob()}).then(function(H){return createImageBitmap(H,Object.assign(g.options,{colorSpaceConversion:"none"}))}).then(function(H){return bl.add(`image-bitmap:${i}`,H),l&&l(H),g.manager.itemEnd(i),H}).catch(function(H){f&&f(H),bg.set(V,H),bl.remove(`image-bitmap:${i}`),g.manager.itemError(i),g.manager.itemEnd(i)});bl.add(`image-bitmap:${i}`,V),g.manager.itemStart(i)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let by;class wy{static getContext(){return by===void 0&&(by=new(window.AudioContext||window.webkitAudioContext)),by}static setContext(i){by=i}}class Vx extends null{constructor(i){super(i)}load(i,l,h,f){const g=this,v=new _d(this.manager);v.setResponseType("arraybuffer"),v.setPath(this.path),v.setRequestHeader(this.requestHeader),v.setWithCredentials(this.withCredentials),v.load(i,function(V){try{const H=V.slice(0);wy.getContext().decodeAudioData(H,function(he){l(he)}).catch(C)}catch(H){C(H)}},h,f);function C(V){f?f(V):js(V),g.manager.itemError(i)}}}const Sh=new On,wg=new On,Md=new On;class Nf{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ul,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ul,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(i){const l=this._cache;if(l.focus!==i.focus||l.fov!==i.fov||l.aspect!==i.aspect*this.aspect||l.near!==i.near||l.far!==i.far||l.zoom!==i.zoom||l.eyeSep!==this.eyeSep){l.focus=i.focus,l.fov=i.fov,l.aspect=i.aspect*this.aspect,l.near=i.near,l.far=i.far,l.zoom=i.zoom,l.eyeSep=this.eyeSep,Md.copy(i.projectionMatrix);const f=l.eyeSep/2,g=f*l.near/l.focus,v=l.near*Math.tan(ru*l.fov*.5)/l.zoom;let C,V;wg.elements[12]=-f,Sh.elements[12]=f,C=-v*l.aspect+g,V=v*l.aspect+g,Md.elements[0]=2*l.near/(V-C),Md.elements[8]=(V+C)/(V-C),this.cameraL.projectionMatrix.copy(Md),C=-v*l.aspect-g,V=v*l.aspect-g,Md.elements[0]=2*l.near/(V-C),Md.elements[8]=(V+C)/(V-C),this.cameraR.projectionMatrix.copy(Md)}this.cameraL.matrixWorld.copy(i.matrixWorld).multiply(wg),this.cameraR.matrixWorld.copy(i.matrixWorld).multiply(Sh)}}class Pf extends null{constructor(i=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=i}}class gE{constructor(i=!0){this.autoStart=i,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let i=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const l=performance.now();i=(l-this.oldTime)/1e3,this.oldTime=l,this.elapsedTime+=i}return i}}const If=new Rt,Yu=new vl,Gx=new Rt,Sd=new Rt,ec=new Rt;class y3 extends null{constructor(){super(),this.type="AudioListener",this.context=wy.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new gE}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(i){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=i,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(i){return this.gain.gain.setTargetAtTime(i,this.context.currentTime,.01),this}updateMatrixWorld(i){super.updateMatrixWorld(i);const l=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(If,Yu,Gx),Sd.set(0,0,-1).applyQuaternion(Yu),ec.set(0,1,0).applyQuaternion(Yu),l.positionX){const h=this.context.currentTime+this.timeDelta;l.positionX.linearRampToValueAtTime(If.x,h),l.positionY.linearRampToValueAtTime(If.y,h),l.positionZ.linearRampToValueAtTime(If.z,h),l.forwardX.linearRampToValueAtTime(Sd.x,h),l.forwardY.linearRampToValueAtTime(Sd.y,h),l.forwardZ.linearRampToValueAtTime(Sd.z,h),l.upX.linearRampToValueAtTime(ec.x,h),l.upY.linearRampToValueAtTime(ec.y,h),l.upZ.linearRampToValueAtTime(ec.z,h)}else l.setPosition(If.x,If.y,If.z),l.setOrientation(Sd.x,Sd.y,Sd.z,ec.x,ec.y,ec.z)}}class v3 extends null{constructor(i){super(),this.type="Audio",this.listener=i,this.context=i.context,this.gain=this.context.createGain(),this.gain.connect(i.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(i){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=i,this.connect(),this}setMediaElementSource(i){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(i),this.connect(),this}setMediaStreamSource(i){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(i),this.connect(),this}setBuffer(i){return this.buffer=i,this.sourceType="buffer",this.autoplay&&this.play(),this}play(i=0){if(this.isPlaying===!0){_r("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+i;const l=this.context.createBufferSource();return l.buffer=this.buffer,l.loop=this.loop,l.loopStart=this.loopStart,l.loopEnd=this.loopEnd,l.onended=this.onEnded.bind(this),l.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=l,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(i=0){if(this.hasPlaybackControl===!1){_r("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+i),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let i=1,l=this.filters.length;i0){this.source.disconnect(this.filters[0]);for(let i=1,l=this.filters.length;i0&&this._mixBufferRegionAdditive(h,f,this._addIndex*l,1,l);for(let V=l,H=l+l;V!==H;++V)if(h[V]!==h[V+l]){C.setValue(h,f);break}}saveOriginalState(){const i=this.binding,l=this.buffer,h=this.valueSize,f=h*this._origIndex;i.getValue(l,f);for(let g=h,v=f;g!==v;++g)l[g]=l[f+g%h];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const i=this.valueSize*3;this.binding.setValue(this.buffer,i)}_setAdditiveIdentityNumeric(){const i=this._addIndex*this.valueSize,l=i+this.valueSize;for(let h=i;h=.5)for(let v=0;v!==g;++v)i[l+v]=i[h+v]}_slerp(i,l,h,f){vl.slerpFlat(i,l,i,l,i,h,f)}_slerpAdditive(i,l,h,f,g){const v=this._workIndex*g;vl.multiplyQuaternionsFlat(i,v,i,l,i,h),vl.slerpFlat(i,l,i,l,i,v,f)}_lerp(i,l,h,f,g){const v=1-f;for(let C=0;C!==g;++C){const V=l+C;i[V]=i[V]*v+i[h+C]*f}}_lerpAdditive(i,l,h,f,g){for(let v=0;v!==g;++v){const C=l+v;i[C]=i[C]+i[h+v]*f}}}const My="\\[\\]\\.:\\/",K1=new RegExp("["+My+"]","g"),Sy="[^"+My+"]",J1="[^"+My.replace("\\.","")+"]",Q1=/((?:WC+[\/:])*)/.source.replace("WC",Sy),Ks=/(WCOD+)?/.source.replace("WCOD",J1),xE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sy),ew=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sy),tw=new RegExp("^"+Q1+Ks+xE+ew+"$"),_E=["material","materials","bones","map"];class bE{constructor(i,l,h){const f=h||Xs.parseTrackName(l);this._targetGroup=i,this._bindings=i.subscribe_(l,f)}getValue(i,l){this.bind();const h=this._targetGroup.nCachedObjects_,f=this._bindings[h];f!==void 0&&f.getValue(i,l)}setValue(i,l){const h=this._bindings;for(let f=this._targetGroup.nCachedObjects_,g=h.length;f!==g;++f)h[f].setValue(i,l)}bind(){const i=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].bind()}unbind(){const i=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=i.length;l!==h;++l)i[l].unbind()}}class Xs{constructor(i,l,h){this.path=l,this.parsedPath=h||Xs.parseTrackName(l),this.node=Xs.findNode(i,this.parsedPath.nodeName),this.rootNode=i,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(i,l,h){return i&&i.isAnimationObjectGroup?new Xs.Composite(i,l,h):new Xs(i,l,h)}static sanitizeNodeName(i){return i.replace(/\s/g,"_").replace(K1,"")}static parseTrackName(i){const l=tw.exec(i);if(l===null)throw new Error("PropertyBinding: Cannot parse trackName: "+i);const h={nodeName:l[2],objectName:l[3],objectIndex:l[4],propertyName:l[5],propertyIndex:l[6]},f=h.nodeName&&h.nodeName.lastIndexOf(".");if(f!==void 0&&f!==-1){const g=h.nodeName.substring(f+1);_E.indexOf(g)!==-1&&(h.nodeName=h.nodeName.substring(0,f),h.objectName=g)}if(h.propertyName===null||h.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+i);return h}static findNode(i,l){if(l===void 0||l===""||l==="."||l===-1||l===i.name||l===i.uuid)return i;if(i.skeleton){const h=i.skeleton.getBoneByName(l);if(h!==void 0)return h}if(i.children){const h=function(g){for(let v=0;v=g){const he=g++,pe=i[he];l[pe.uuid]=J,i[J]=pe,l[H]=he,i[he]=V;for(let me=0,Se=f;me!==Se;++me){const tt=h[me],gt=tt[he],mt=tt[J];tt[J]=gt,tt[he]=mt}}}this.nCachedObjects_=g}uncache(){const i=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_,v=i.length;for(let C=0,V=arguments.length;C!==V;++C){const H=arguments[C],J=H.uuid,he=l[J];if(he!==void 0)if(delete l[J],he0&&(l[me.uuid]=he),i[he]=me,i.pop();for(let Se=0,tt=f;Se!==tt;++Se){const gt=h[Se];gt[he]=gt[pe],gt.pop()}}}this.nCachedObjects_=g}subscribe_(i,l){const h=this._bindingsIndicesByPath;let f=h[i];const g=this._bindings;if(f!==void 0)return g[f];const v=this._paths,C=this._parsedPaths,V=this._objects,H=V.length,J=this.nCachedObjects_,he=new Array(H);f=g.length,h[i]=f,v.push(i),C.push(l),g.push(he);for(let pe=J,me=V.length;pe!==me;++pe){const Se=V[pe];he[pe]=new Xs(Se,i,l)}return he}unsubscribe_(i){const l=this._bindingsIndicesByPath,h=l[i];if(h!==void 0){const f=this._paths,g=this._parsedPaths,v=this._bindings,C=v.length-1,V=v[C],H=i[C];l[H]=h,v[h]=V,v.pop(),g[h]=g[C],g.pop(),f[h]=f[C],f.pop()}}}class ME{constructor(i,l,h=null,f=l.blendMode){this._mixer=i,this._clip=l,this._localRoot=h,this.blendMode=f;const g=l.tracks,v=g.length,C=new Array(v),V={endingStart:ca,endingEnd:ca};for(let H=0;H!==v;++H){const J=g[H].createInterpolant(null);C[H]=J,J.settings=V}this._interpolantSettings=V,this._interpolants=C,this._propertyBindings=new Array(v),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qr,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(i){return this._startTime=i,this}setLoop(i,l){return this.loop=i,this.repetitions=l,this}setEffectiveWeight(i){return this.weight=i,this._effectiveWeight=this.enabled?i:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(i){return this._scheduleFading(i,0,1)}fadeOut(i){return this._scheduleFading(i,1,0)}crossFadeFrom(i,l,h=!1){if(i.fadeOut(l),this.fadeIn(l),h===!0){const f=this._clip.duration,g=i._clip.duration,v=g/f,C=f/g;i.warp(1,v,l),this.warp(C,1,l)}return this}crossFadeTo(i,l,h=!1){return i.crossFadeFrom(this,l,h)}stopFading(){const i=this._weightInterpolant;return i!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(i)),this}setEffectiveTimeScale(i){return this.timeScale=i,this._effectiveTimeScale=this.paused?0:i,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(i){return this.timeScale=this._clip.duration/i,this.stopWarping()}syncWith(i){return this.time=i.time,this.timeScale=i.timeScale,this.stopWarping()}halt(i){return this.warp(this._effectiveTimeScale,0,i)}warp(i,l,h){const f=this._mixer,g=f.time,v=this.timeScale;let C=this._timeScaleInterpolant;C===null&&(C=f._lendControlInterpolant(),this._timeScaleInterpolant=C);const V=C.parameterPositions,H=C.sampleValues;return V[0]=g,V[1]=g+h,H[0]=i/v,H[1]=l/v,this}stopWarping(){const i=this._timeScaleInterpolant;return i!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(i)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(i,l,h,f){if(!this.enabled){this._updateWeight(i);return}const g=this._startTime;if(g!==null){const V=(i-g)*h;V<0||h===0?l=0:(this._startTime=null,l=h*V)}l*=this._updateTimeScale(i);const v=this._updateTime(l),C=this._updateWeight(i);if(C>0){const V=this._interpolants,H=this._propertyBindings;switch(this.blendMode){case Pc:for(let J=0,he=V.length;J!==he;++J)V[J].evaluate(v),H[J].accumulateAdditive(C);break;case bo:default:for(let J=0,he=V.length;J!==he;++J)V[J].evaluate(v),H[J].accumulate(f,C)}}}_updateWeight(i){let l=0;if(this.enabled){l=this.weight;const h=this._weightInterpolant;if(h!==null){const f=h.evaluate(i)[0];l*=f,i>h.parameterPositions[1]&&(this.stopFading(),f===0&&(this.enabled=!1))}}return this._effectiveWeight=l,l}_updateTimeScale(i){let l=0;if(!this.paused){l=this.timeScale;const h=this._timeScaleInterpolant;if(h!==null){const f=h.evaluate(i)[0];l*=f,i>h.parameterPositions[1]&&(this.stopWarping(),l===0?this.paused=!0:this.timeScale=l)}}return this._effectiveTimeScale=l,l}_updateTime(i){const l=this._clip.duration,h=this.loop;let f=this.time+i,g=this._loopCount;const v=h===la;if(i===0)return g===-1?f:v&&(g&1)===1?l-f:f;if(h===ro){g===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(f>=l)f=l;else if(f<0)f=0;else{this.time=f;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(g===-1&&(i>=0?(g=0,this._setEndings(!0,this.repetitions===0,v)):this._setEndings(this.repetitions===0,!0,v)),f>=l||f<0){const C=Math.floor(f/l);f-=l*C,g+=Math.abs(C);const V=this.repetitions-g;if(V<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,f=i>0?l:0,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(V===1){const H=i<0;this._setEndings(H,!H,v)}else this._setEndings(!1,!1,v);this._loopCount=g,this.time=f,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:C})}}else this.time=f;if(v&&(g&1)===1)return l-f}return f}_setEndings(i,l,h){const f=this._interpolantSettings;h?(f.endingStart=Oa,f.endingEnd=Oa):(i?f.endingStart=this.zeroSlopeAtStart?Oa:ca:f.endingStart=sl,l?f.endingEnd=this.zeroSlopeAtEnd?Oa:ca:f.endingEnd=sl)}_scheduleFading(i,l,h){const f=this._mixer,g=f.time;let v=this._weightInterpolant;v===null&&(v=f._lendControlInterpolant(),this._weightInterpolant=v);const C=v.parameterPositions,V=v.sampleValues;return C[0]=g,V[0]=l,C[1]=g+i,V[1]=h,this}}const nw=new Float32Array(1);class x3 extends null{constructor(i){super(),this._root=i,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(i,l){const h=i._localRoot||this._root,f=i._clip.tracks,g=f.length,v=i._propertyBindings,C=i._interpolants,V=h.uuid,H=this._bindingsByRootAndName;let J=H[V];J===void 0&&(J={},H[V]=J);for(let he=0;he!==g;++he){const pe=f[he],me=pe.name;let Se=J[me];if(Se!==void 0)++Se.referenceCount,v[he]=Se;else{if(Se=v[he],Se!==void 0){Se._cacheIndex===null&&(++Se.referenceCount,this._addInactiveBinding(Se,V,me));continue}const tt=l&&l._propertyBindings[he].binding.parsedPath;Se=new Z1(Xs.create(h,me,tt),pe.ValueTypeName,pe.getValueSize()),++Se.referenceCount,this._addInactiveBinding(Se,V,me),v[he]=Se}C[he].resultBuffer=Se.buffer}}_activateAction(i){if(!this._isActiveAction(i)){if(i._cacheIndex===null){const h=(i._localRoot||this._root).uuid,f=i._clip.uuid,g=this._actionsByClip[f];this._bindAction(i,g&&g.knownActions[0]),this._addInactiveAction(i,f,h)}const l=i._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];g.useCount++===0&&(this._lendBinding(g),g.saveOriginalState())}this._lendAction(i)}}_deactivateAction(i){if(this._isActiveAction(i)){const l=i._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.useCount===0&&(g.restoreOriginalState(),this._takeBackBinding(g))}this._takeBackAction(i)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const i=this;this.stats={actions:{get total(){return i._actions.length},get inUse(){return i._nActiveActions}},bindings:{get total(){return i._bindings.length},get inUse(){return i._nActiveBindings}},controlInterpolants:{get total(){return i._controlInterpolants.length},get inUse(){return i._nActiveControlInterpolants}}}}_isActiveAction(i){const l=i._cacheIndex;return l!==null&&l=0;--h)i[h].stop();return this}update(i){i*=this.timeScale;const l=this._actions,h=this._nActiveActions,f=this.time+=i,g=Math.sign(i),v=this._accuIndex^=1;for(let H=0;H!==h;++H)l[H]._update(f,i,g,v);const C=this._bindings,V=this._nActiveBindings;for(let H=0;H!==V;++H)C[H].apply(v);return this}setTime(i){this.time=0;for(let l=0;l=this.min.x&&i.x<=this.max.x&&i.y>=this.min.y&&i.y<=this.max.y}containsBox(i){return this.min.x<=i.min.x&&i.max.x<=this.max.x&&this.min.y<=i.min.y&&i.max.y<=this.max.y}getParameter(i,l){return l.set((i.x-this.min.x)/(this.max.x-this.min.x),(i.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(i){return i.max.x>=this.min.x&&i.min.x<=this.max.x&&i.max.y>=this.min.y&&i.min.y<=this.max.y}clampPoint(i,l){return l.copy(i).clamp(this.min,this.max)}distanceToPoint(i){return this.clampPoint(i,Tg).distanceTo(i)}intersect(i){return this.min.max(i.min),this.max.min(i.max),this.isEmpty()&&this.makeEmpty(),this}union(i){return this.min.min(i.min),this.max.max(i.max),this}translate(i){return this.min.add(i),this.max.add(i),this}equals(i){return i.min.equals(this.min)&&i.max.equals(this.max)}}const jx=new Rt,Cy=new Rt,Ad=new Rt,$p=new Rt,vu=new Rt,Eg=new Rt,Ry=new Rt;class M3{constructor(i=new Rt,l=new Rt){this.start=i,this.end=l}set(i,l){return this.start.copy(i),this.end.copy(l),this}copy(i){return this.start.copy(i.start),this.end.copy(i.end),this}getCenter(i){return i.addVectors(this.start,this.end).multiplyScalar(.5)}delta(i){return i.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(i,l){return this.delta(l).multiplyScalar(i).add(this.start)}closestPointToPointParameter(i,l){jx.subVectors(i,this.start),Cy.subVectors(this.end,this.start);const h=Cy.dot(Cy);let g=Cy.dot(jx)/h;return l&&(g=Fr(g,0,1)),g}closestPointToPoint(i,l,h){const f=this.closestPointToPointParameter(i,l);return this.delta(h).multiplyScalar(f).add(this.start)}distanceSqToLine3(i,l=Eg,h=Ry){const f=10000000000000001e-32;let g,v;const C=this.start,V=i.start,H=this.end,J=i.end;Ad.subVectors(H,C),$p.subVectors(J,V),vu.subVectors(C,V);const he=Ad.dot(Ad),pe=$p.dot($p),me=$p.dot(vu);if(he<=f&&pe<=f)return l.copy(C),h.copy(V),l.sub(h),l.dot(l);if(he<=f)g=0,v=me/pe,v=Fr(v,0,1);else{const Se=Ad.dot(vu);if(pe<=f)v=0,g=Fr(-Se/he,0,1);else{const tt=Ad.dot($p),gt=he*pe-tt*tt;gt!==0?g=Fr((tt*me-Se*pe)/gt,0,1):g=0,v=(tt*g+me)/pe,v<0?(v=0,g=Fr(-Se/he,0,1)):v>1&&(v=1,g=Fr((tt-Se)/he,0,1))}}return l.copy(C).add(Ad.multiplyScalar(g)),h.copy(V).add($p.multiplyScalar(v)),l.sub(h),l.dot(l)}applyMatrix4(i){return this.start.applyMatrix4(i),this.end.applyMatrix4(i),this}equals(i){return i.start.equals(this.start)&&i.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ny=new Rt;class S3 extends null{constructor(i,l){super(),this.light=i,this.matrixAutoUpdate=!1,this.color=l,this.type="SpotLightHelper";const h=new Or,f=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let v=0,C=1,V=32;v1)for(let he=0;he.99999)this.quaternion.set(0,0,0,1);else if(i.y<-.99999)this.quaternion.set(1,0,0,0);else{Yp.set(i.z,0,-i.x).normalize();const l=Math.acos(i.y);this.quaternion.setFromAxisAngle(Yp,l)}}setLength(i,l=i*.2,h=l*.2){this.line.scale.set(1,Math.max(1e-4,i-l),1),this.line.updateMatrix(),this.cone.scale.set(h,l,h),this.cone.position.y=i,this.cone.updateMatrix()}setColor(i){this.line.material.color.set(i),this.cone.material.color.set(i)}copy(i){return super.copy(i,!1),this.line.copy(i.line),this.cone.copy(i.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Oy extends null{constructor(i=1){const l=[0,0,0,i,0,0,0,0,0,0,i,0,0,0,0,0,0,i],h=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],f=new Or;f.setAttribute("position",new qi(l,3)),f.setAttribute("color",new qi(h,3));const g=new Rl({vertexColors:!0,toneMapped:!1});super(f,g),this.type="AxesHelper"}setColors(i,l,h){const f=new ar,g=this.geometry.attributes.color.array;return f.set(i),f.toArray(g,0),f.toArray(g,3),f.set(l),f.toArray(g,6),f.toArray(g,9),f.set(h),f.toArray(g,12),f.toArray(g,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class AE{constructor(){this.type="ShapePath",this.color=new ar,this.subPaths=[],this.currentPath=null}moveTo(i,l){return this.currentPath=new J0,this.subPaths.push(this.currentPath),this.currentPath.moveTo(i,l),this}lineTo(i,l){return this.currentPath.lineTo(i,l),this}quadraticCurveTo(i,l,h,f){return this.currentPath.quadraticCurveTo(i,l,h,f),this}bezierCurveTo(i,l,h,f,g,v){return this.currentPath.bezierCurveTo(i,l,h,f,g,v),this}splineThru(i){return this.currentPath.splineThru(i),this}toShapes(i){function l(mt){const Nt=[];for(let Pt=0,Wt=mt.length;PtNumber.EPSILON){if(li<0&&(kn=Nt[Sn],ii=-ii,In=Nt[gn],li=-li),mt.yIn.y)continue;if(mt.y===kn.y){if(mt.x===kn.x)return!0}else{const dr=li*(mt.x-kn.x)-ii*(mt.y-kn.y);if(dr===0)return!0;if(dr<0)continue;Wt=!Wt}}else{if(mt.y!==kn.y)continue;if(In.x<=mt.x&&mt.x<=kn.x||kn.x<=mt.x&&mt.x<=In.x)return!0}}return Wt}const f=xc.isClockWise,g=this.subPaths;if(g.length===0)return[];let v,C,V;const H=[];if(g.length===1)return C=g[0],V=new yf,V.curves=C.curves,H.push(V),H;let J=!f(g[0].getPoints());J=i?!J:J;const he=[],pe=[];let me=[],Se=0,tt;pe[Se]=void 0,me[Se]=[];for(let mt=0,Nt=g.length;mt1){let mt=!1,Nt=0;for(let Pt=0,Wt=pe.length;Pt0&&mt===!1&&(me=he)}let gt;for(let mt=0,Nt=pe.length;mti?(j.repeat.x=1,j.repeat.y=l/i,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2):(j.repeat.x=i/l,j.repeat.y=1,j.offset.x=(1-j.repeat.x)/2,j.offset.y=0),j}function Ku(j,i){const l=j.image&&j.image.width?j.image.width/j.image.height:1;return l>i?(j.repeat.x=i/l,j.repeat.y=1,j.offset.x=(1-j.repeat.x)/2,j.offset.y=0):(j.repeat.x=1,j.repeat.y=l/i,j.offset.x=0,j.offset.y=(1-j.repeat.y)/2),j}function qx(j){return j.repeat.x=1,j.repeat.y=1,j.offset.x=0,j.offset.y=0,j}function Fy(j,i,l,h){const f=Rg(h);switch(l){case Du:return j*i;case F:return j*i/f.components*f.byteLength;case X:return j*i/f.components*f.byteLength;case De:return j*i*2/f.components*f.byteLength;case Ve:return j*i*2/f.components*f.byteLength;case Le:return j*i*3/f.components*f.byteLength;case D:return j*i*4/f.components*f.byteLength;case st:return j*i*4/f.components*f.byteLength;case Ht:case Et:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*8;case on:case Un:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case bn:case Bt:return Math.max(j,16)*Math.max(i,8)/4;case sn:case ti:return Math.max(j,8)*Math.max(i,8)/2;case $n:case ni:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*8;case Pi:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case ui:return Math.floor((j+3)/4)*Math.floor((i+3)/4)*16;case Ir:return Math.floor((j+4)/5)*Math.floor((i+3)/4)*16;case yi:return Math.floor((j+4)/5)*Math.floor((i+4)/5)*16;case vi:return Math.floor((j+5)/6)*Math.floor((i+4)/5)*16;case Mr:return Math.floor((j+5)/6)*Math.floor((i+5)/6)*16;case Zt:return Math.floor((j+7)/8)*Math.floor((i+4)/5)*16;case Fn:return Math.floor((j+7)/8)*Math.floor((i+5)/6)*16;case hi:return Math.floor((j+7)/8)*Math.floor((i+7)/8)*16;case Xn:return Math.floor((j+9)/10)*Math.floor((i+4)/5)*16;case hs:return Math.floor((j+9)/10)*Math.floor((i+5)/6)*16;case Xr:return Math.floor((j+9)/10)*Math.floor((i+7)/8)*16;case ys:return Math.floor((j+9)/10)*Math.floor((i+9)/10)*16;case Ur:return Math.floor((j+11)/12)*Math.floor((i+9)/10)*16;case Os:return Math.floor((j+11)/12)*Math.floor((i+11)/12)*16;case no:case io:case So:return Math.ceil(j/4)*Math.ceil(i/4)*16;case To:case Gr:return Math.ceil(j/4)*Math.ceil(i/4)*8;case Qs:case Eo:return Math.ceil(j/4)*Math.ceil(i/4)*16}throw new Error(`Unable to determine texture byte length for ${l} format.`)}function Rg(j){switch(j){case Oi:case Gi:return{byteLength:1,components:1};case ms:case ir:case Vs:return{byteLength:2,components:1};case Xl:case ql:return{byteLength:2,components:4};case as:case Is:case gs:return{byteLength:4,components:1};case Dl:case nu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${j}.`)}class By{static contain(i,l){return Df(i,l)}static cover(i,l){return Ku(i,l)}static fill(i){return qx(i)}static getByteLength(i,l,h,f){return Fy(i,l,h,f)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:w}})),typeof window!="undefined"&&(window.__THREE__?_r("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=w)},97234:function(ae,ne,b){"use strict";b.d(ne,{Z:function(){return A}});function w(q){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y},w(q)}var k=/^\s+/,O=/\s+$/;function A(q,Y){if(q=q||"",Y=Y||{},q instanceof A)return q;if(!(this instanceof A))return new A(q,Y);var de=S(q);this._originalInput=q,this._r=de.r,this._g=de.g,this._b=de.b,this._a=de.a,this._roundA=Math.round(100*this._a)/100,this._format=Y.format||de.format,this._gradientType=Y.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=de.ok}A.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var Y=this.toRgb();return(Y.r*299+Y.g*587+Y.b*114)/1e3},getLuminance:function(){var Y=this.toRgb(),de,Je,Te,$e,xt,ke;return de=Y.r/255,Je=Y.g/255,Te=Y.b/255,de<=.03928?$e=de/12.92:$e=Math.pow((de+.055)/1.055,2.4),Je<=.03928?xt=Je/12.92:xt=Math.pow((Je+.055)/1.055,2.4),Te<=.03928?ke=Te/12.92:ke=Math.pow((Te+.055)/1.055,2.4),.2126*$e+.7152*xt+.0722*ke},setAlpha:function(Y){return this._a=kt(Y),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var Y=N(this._r,this._g,this._b);return{h:Y.h*360,s:Y.s,v:Y.v,a:this._a}},toHsvString:function(){var Y=N(this._r,this._g,this._b),de=Math.round(Y.h*360),Je=Math.round(Y.s*100),Te=Math.round(Y.v*100);return this._a==1?"hsv("+de+", "+Je+"%, "+Te+"%)":"hsva("+de+", "+Je+"%, "+Te+"%, "+this._roundA+")"},toHsl:function(){var Y=x(this._r,this._g,this._b);return{h:Y.h*360,s:Y.s,l:Y.l,a:this._a}},toHslString:function(){var Y=x(this._r,this._g,this._b),de=Math.round(Y.h*360),Je=Math.round(Y.s*100),Te=Math.round(Y.l*100);return this._a==1?"hsl("+de+", "+Je+"%, "+Te+"%)":"hsla("+de+", "+Je+"%, "+Te+"%, "+this._roundA+")"},toHex:function(Y){return P(this._r,this._g,this._b,Y)},toHexString:function(Y){return"#"+this.toHex(Y)},toHex8:function(Y){return W(this._r,this._g,this._b,this._a,Y)},toHex8String:function(Y){return"#"+this.toHex8(Y)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Ut(this._r,255)*100)+"%",g:Math.round(Ut(this._g,255)*100)+"%",b:Math.round(Ut(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Ut(this._r,255)*100)+"%, "+Math.round(Ut(this._g,255)*100)+"%, "+Math.round(Ut(this._b,255)*100)+"%)":"rgba("+Math.round(Ut(this._r,255)*100)+"%, "+Math.round(Ut(this._g,255)*100)+"%, "+Math.round(Ut(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:_t[P(this._r,this._g,this._b,!0)]||!1},toFilter:function(Y){var de="#"+K(this._r,this._g,this._b,this._a),Je=de,Te=this._gradientType?"GradientType = 1, ":"";if(Y){var $e=A(Y);Je="#"+K($e._r,$e._g,$e._b,$e._a)}return"progid:DXImageTransform.Microsoft.gradient("+Te+"startColorstr="+de+",endColorstr="+Je+")"},toString:function(Y){var de=!!Y;Y=Y||this._format;var Je=!1,Te=this._a<1&&this._a>=0,$e=!de&&Te&&(Y==="hex"||Y==="hex6"||Y==="hex3"||Y==="hex4"||Y==="hex8"||Y==="name");return $e?Y==="name"&&this._a===0?this.toName():this.toRgbString():(Y==="rgb"&&(Je=this.toRgbString()),Y==="prgb"&&(Je=this.toPercentageRgbString()),(Y==="hex"||Y==="hex6")&&(Je=this.toHexString()),Y==="hex3"&&(Je=this.toHexString(!0)),Y==="hex4"&&(Je=this.toHex8String(!0)),Y==="hex8"&&(Je=this.toHex8String()),Y==="name"&&(Je=this.toName()),Y==="hsl"&&(Je=this.toHslString()),Y==="hsv"&&(Je=this.toHsvString()),Je||this.toHexString())},clone:function(){return A(this.toString())},_applyModification:function(Y,de){var Je=Y.apply(null,[this].concat([].slice.call(de)));return this._r=Je._r,this._g=Je._g,this._b=Je._b,this.setAlpha(Je._a),this},lighten:function(){return this._applyModification(ce,arguments)},brighten:function(){return this._applyModification(xe,arguments)},darken:function(){return this._applyModification(fe,arguments)},desaturate:function(){return this._applyModification(re,arguments)},saturate:function(){return this._applyModification(ye,arguments)},greyscale:function(){return this._applyModification(ge,arguments)},spin:function(){return this._applyModification(Ne,arguments)},_applyCombination:function(Y,de){return Y.apply(null,[this].concat([].slice.call(de)))},analogous:function(){return this._applyCombination(Ee,arguments)},complement:function(){return this._applyCombination(Ae,arguments)},monochromatic:function(){return this._applyCombination(We,arguments)},splitcomplement:function(){return this._applyCombination(Ye,arguments)},triad:function(){return this._applyCombination(be,[3])},tetrad:function(){return this._applyCombination(be,[4])}},A.fromRatio=function(q,Y){if(w(q)=="object"){var de={};for(var Je in q)q.hasOwnProperty(Je)&&(Je==="a"?de[Je]=q[Je]:de[Je]=vt(q[Je]));q=de}return A(q,Y)};function S(q){var Y={r:0,g:0,b:0},de=1,Je=null,Te=null,$e=null,xt=!1,ke=!1;return typeof q=="string"&&(q=ze(q)),w(q)=="object"&&(bt(q.r)&&bt(q.g)&&bt(q.b)?(Y=R(q.r,q.g,q.b),xt=!0,ke=String(q.r).substr(-1)==="%"?"prgb":"rgb"):bt(q.h)&&bt(q.s)&&bt(q.v)?(Je=vt(q.s),Te=vt(q.v),Y=L(q.h,Je,Te),xt=!0,ke="hsv"):bt(q.h)&&bt(q.s)&&bt(q.l)&&(Je=vt(q.s),$e=vt(q.l),Y=E(q.h,Je,$e),xt=!0,ke="hsl"),q.hasOwnProperty("a")&&(de=q.a)),de=kt(de),{ok:xt,format:q.format||ke,r:Math.min(255,Math.max(Y.r,0)),g:Math.min(255,Math.max(Y.g,0)),b:Math.min(255,Math.max(Y.b,0)),a:de}}function R(q,Y,de){return{r:Ut(q,255)*255,g:Ut(Y,255)*255,b:Ut(de,255)*255}}function x(q,Y,de){q=Ut(q,255),Y=Ut(Y,255),de=Ut(de,255);var Je=Math.max(q,Y,de),Te=Math.min(q,Y,de),$e,xt,ke=(Je+Te)/2;if(Je==Te)$e=xt=0;else{var et=Je-Te;switch(xt=ke>.5?et/(2-Je-Te):et/(Je+Te),Je){case q:$e=(Y-de)/et+(Y1&&(ie-=1),ie<1/6?yt+(B-yt)*6*ie:ie<1/2?B:ie<2/3?yt+(B-yt)*(2/3-ie)*6:yt}if(Y===0)Je=Te=$e=de;else{var ke=de<.5?de*(1+Y):de+Y-de*Y,et=2*de-ke;Je=xt(et,ke,q+1/3),Te=xt(et,ke,q),$e=xt(et,ke,q-1/3)}return{r:Je*255,g:Te*255,b:$e*255}}function N(q,Y,de){q=Ut(q,255),Y=Ut(Y,255),de=Ut(de,255);var Je=Math.max(q,Y,de),Te=Math.min(q,Y,de),$e,xt,ke=Je,et=Je-Te;if(xt=Je===0?0:et/Je,Je==Te)$e=0;else{switch(Je){case q:$e=(Y-de)/et+(Y>1)+720)%360;--Y;)Je.h=(Je.h+Te)%360,$e.push(A(Je));return $e}function We(q,Y){Y=Y||6;for(var de=A(q).toHsv(),Je=de.h,Te=de.s,$e=de.v,xt=[],ke=1/Y;Y--;)xt.push(A({h:Je,s:Te,v:$e})),$e=($e+ke)%1;return xt}A.mix=function(q,Y,de){de=de===0?0:de||50;var Je=A(q).toRgb(),Te=A(Y).toRgb(),$e=de/100,xt={r:(Te.r-Je.r)*$e+Je.r,g:(Te.g-Je.g)*$e+Je.g,b:(Te.b-Je.b)*$e+Je.b,a:(Te.a-Je.a)*$e+Je.a};return A(xt)},A.readability=function(q,Y){var de=A(q),Je=A(Y);return(Math.max(de.getLuminance(),Je.getLuminance())+.05)/(Math.min(de.getLuminance(),Je.getLuminance())+.05)},A.isReadable=function(q,Y,de){var Je=A.readability(q,Y),Te,$e;switch($e=!1,Te=Ze(de),Te.level+Te.size){case"AAsmall":case"AAAlarge":$e=Je>=4.5;break;case"AAlarge":$e=Je>=3;break;case"AAAsmall":$e=Je>=7;break}return $e},A.mostReadable=function(q,Y,de){var Je=null,Te=0,$e,xt,ke,et;de=de||{},xt=de.includeFallbackColors,ke=de.level,et=de.size;for(var yt=0;ytTe&&(Te=$e,Je=A(Y[yt]));return A.isReadable(q,Je,{level:ke,size:et})||!xt?Je:(de.includeFallbackColors=!1,A.mostReadable(q,["#fff","#000"],de))};var je=A.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},_t=A.hexNames=It(je);function It(q){var Y={};for(var de in q)q.hasOwnProperty(de)&&(Y[q[de]]=de);return Y}function kt(q){return q=parseFloat(q),(isNaN(q)||q<0||q>1)&&(q=1),q}function Ut(q,Y){Ot(q)&&(q="100%");var de=ue(q);return q=Math.min(Y,Math.max(0,parseFloat(q))),de&&(q=parseInt(q*Y,10)/100),Math.abs(q-Y)<1e-6?1:q%Y/parseFloat(Y)}function At(q){return Math.min(1,Math.max(0,q))}function at(q){return parseInt(q,16)}function Ot(q){return typeof q=="string"&&q.indexOf(".")!=-1&&parseFloat(q)===1}function ue(q){return typeof q=="string"&&q.indexOf("%")!=-1}function Ue(q){return q.length==1?"0"+q:""+q}function vt(q){return q<=1&&(q=q*100+"%"),q}function Jt(q){return Math.round(parseFloat(q)*255).toString(16)}function Qe(q){return at(q)/255}var rt=function(){var q="[-\\+]?\\d+%?",Y="[-\\+]?\\d*\\.\\d+%?",de="(?:"+Y+")|(?:"+q+")",Je="[\\s|\\(]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")\\s*\\)?",Te="[\\s|\\(]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")[,|\\s]+("+de+")\\s*\\)?";return{CSS_UNIT:new RegExp(de),rgb:new RegExp("rgb"+Je),rgba:new RegExp("rgba"+Te),hsl:new RegExp("hsl"+Je),hsla:new RegExp("hsla"+Te),hsv:new RegExp("hsv"+Je),hsva:new RegExp("hsva"+Te),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function bt(q){return!!rt.CSS_UNIT.exec(q)}function ze(q){q=q.replace(k,"").replace(O,"").toLowerCase();var Y=!1;if(je[q])q=je[q],Y=!0;else if(q=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var de;return(de=rt.rgb.exec(q))?{r:de[1],g:de[2],b:de[3]}:(de=rt.rgba.exec(q))?{r:de[1],g:de[2],b:de[3],a:de[4]}:(de=rt.hsl.exec(q))?{h:de[1],s:de[2],l:de[3]}:(de=rt.hsla.exec(q))?{h:de[1],s:de[2],l:de[3],a:de[4]}:(de=rt.hsv.exec(q))?{h:de[1],s:de[2],v:de[3]}:(de=rt.hsva.exec(q))?{h:de[1],s:de[2],v:de[3],a:de[4]}:(de=rt.hex8.exec(q))?{r:at(de[1]),g:at(de[2]),b:at(de[3]),a:Qe(de[4]),format:Y?"name":"hex8"}:(de=rt.hex6.exec(q))?{r:at(de[1]),g:at(de[2]),b:at(de[3]),format:Y?"name":"hex"}:(de=rt.hex4.exec(q))?{r:at(de[1]+""+de[1]),g:at(de[2]+""+de[2]),b:at(de[3]+""+de[3]),a:Qe(de[4]+""+de[4]),format:Y?"name":"hex8"}:(de=rt.hex3.exec(q))?{r:at(de[1]+""+de[1]),g:at(de[2]+""+de[2]),b:at(de[3]+""+de[3]),format:Y?"name":"hex"}:!1}function Ze(q){var Y,de;return q=q||{level:"AA",size:"small"},Y=(q.level||"AA").toUpperCase(),de=(q.size||"small").toLowerCase(),Y!=="AA"&&Y!=="AAA"&&(Y="AA"),de!=="small"&&de!=="large"&&(de="small"),{level:Y,size:de}}},97582:function(ae,ne,b){"use strict";b.d(ne,{CR:function(){return ce},Jh:function(){return K},Q_:function(){return Ut},XA:function(){return ge},ZT:function(){return k},_T:function(){return A},ev:function(){return Ne},mG:function(){return W},pi:function(){return O}});var w=function(Qe,rt){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(bt,ze){bt.__proto__=ze}||function(bt,ze){for(var Ze in ze)Object.prototype.hasOwnProperty.call(ze,Ze)&&(bt[Ze]=ze[Ze])},w(Qe,rt)};function k(Qe,rt){if(typeof rt!="function"&&rt!==null)throw new TypeError("Class extends value "+String(rt)+" is not a constructor or null");w(Qe,rt);function bt(){this.constructor=Qe}Qe.prototype=rt===null?Object.create(rt):(bt.prototype=rt.prototype,new bt)}var O=function(){return O=Object.assign||function(rt){for(var bt,ze=1,Ze=arguments.length;ze=0;de--)(Y=Qe[de])&&(q=(Ze<3?Y(q):Ze>3?Y(rt,bt,q):Y(rt,bt))||q);return Ze>3&&q&&Object.defineProperty(rt,bt,q),q}function R(Qe,rt){return function(bt,ze){rt(bt,ze,Qe)}}function x(Qe,rt,bt,ze,Ze,q){function Y(ct){if(ct!==void 0&&typeof ct!="function")throw new TypeError("Function expected");return ct}for(var de=ze.kind,Je=de==="getter"?"get":de==="setter"?"set":"value",Te=!rt&&Qe?ze.static?Qe:Qe.prototype:null,$e=rt||(Te?Object.getOwnPropertyDescriptor(Te,ze.name):{}),xt,ke=!1,et=bt.length-1;et>=0;et--){var yt={};for(var B in ze)yt[B]=B==="access"?{}:ze[B];for(var B in ze.access)yt.access[B]=ze.access[B];yt.addInitializer=function(ct){if(ke)throw new TypeError("Cannot add initializers after decoration has completed");q.push(Y(ct||null))};var ie=(0,bt[et])(de==="accessor"?{get:$e.get,set:$e.set}:$e[Je],yt);if(de==="accessor"){if(ie===void 0)continue;if(ie===null||typeof ie!="object")throw new TypeError("Object expected");(xt=Y(ie.get))&&($e.get=xt),(xt=Y(ie.set))&&($e.set=xt),(xt=Y(ie.init))&&Ze.unshift(xt)}else(xt=Y(ie))&&(de==="field"?Ze.unshift(xt):$e[Je]=xt)}Te&&Object.defineProperty(Te,ze.name,$e),ke=!0}function E(Qe,rt,bt){for(var ze=arguments.length>2,Ze=0;Ze0&&q[q.length-1])&&(Te[0]===6||Te[0]===2)){bt=0;continue}if(Te[0]===3&&(!q||Te[1]>q[0]&&Te[1]=Qe.length&&(Qe=void 0),{value:Qe&&Qe[ze++],done:!Qe}}};throw new TypeError(rt?"Object is not iterable.":"Symbol.iterator is not defined.")}function ce(Qe,rt){var bt=typeof Symbol=="function"&&Qe[Symbol.iterator];if(!bt)return Qe;var ze=bt.call(Qe),Ze,q=[],Y;try{for(;(rt===void 0||rt-- >0)&&!(Ze=ze.next()).done;)q.push(Ze.value)}catch(de){Y={error:de}}finally{try{Ze&&!Ze.done&&(bt=ze.return)&&bt.call(ze)}finally{if(Y)throw Y.error}}return q}function xe(){for(var Qe=[],rt=0;rt1||Je(et,B)})},yt&&(Ze[et]=yt(Ze[et])))}function Je(et,yt){try{Te(ze[et](yt))}catch(B){ke(q[0][3],B)}}function Te(et){et.value instanceof Ae?Promise.resolve(et.value.v).then($e,xt):ke(q[0][2],et)}function $e(et){Je("next",et)}function xt(et){Je("throw",et)}function ke(et,yt){et(yt),q.shift(),q.length&&Je(q[0][0],q[0][1])}}function Ye(Qe){var rt,bt;return rt={},ze("next"),ze("throw",function(Ze){throw Ze}),ze("return"),rt[Symbol.iterator]=function(){return this},rt;function ze(Ze,q){rt[Ze]=Qe[Ze]?function(Y){return(bt=!bt)?{value:Ae(Qe[Ze](Y)),done:!1}:q?q(Y):Y}:q}}function Ee(Qe){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var rt=Qe[Symbol.asyncIterator],bt;return rt?rt.call(Qe):(Qe=typeof ge=="function"?ge(Qe):Qe[Symbol.iterator](),bt={},ze("next"),ze("throw"),ze("return"),bt[Symbol.asyncIterator]=function(){return this},bt);function ze(q){bt[q]=Qe[q]&&function(Y){return new Promise(function(de,Je){Y=Qe[q](Y),Ze(de,Je,Y.done,Y.value)})}}function Ze(q,Y,de,Je){Promise.resolve(Je).then(function(Te){q({value:Te,done:de})},Y)}}function We(Qe,rt){return Object.defineProperty?Object.defineProperty(Qe,"raw",{value:rt}):Qe.raw=rt,Qe}var je=Object.create?function(Qe,rt){Object.defineProperty(Qe,"default",{enumerable:!0,value:rt})}:function(Qe,rt){Qe.default=rt},_t=function(Qe){return _t=Object.getOwnPropertyNames||function(rt){var bt=[];for(var ze in rt)Object.prototype.hasOwnProperty.call(rt,ze)&&(bt[bt.length]=ze);return bt},_t(Qe)};function It(Qe){if(Qe&&Qe.__esModule)return Qe;var rt={};if(Qe!=null)for(var bt=_t(Qe),ze=0;ze