@osamash/floor-planner 1.1.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,7 @@ React keys must be passed directly to JSX without using spread:
42
42
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
43
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
44
  * SOFTWARE.
45
- */var Ua="delete",kt=5,ar=1<<kt,kn=ar-1,wt={};function fh(){return{value:!1}}function Er(n){n&&(n.value=!0)}function dh(){}function uo(n){return n.size===void 0&&(n.size=n.__iterate(Fm)),n.size}function ts(n,e){if(typeof e!="number"){var t=e>>>0;if(""+t!==e||t===4294967295)return NaN;e=t}return e<0?uo(n)+e:e}function Fm(){return!0}function Fa(n,e,t){return(n===0&&!km(n)||t!==void 0&&n<=-t)&&(e===void 0||t!==void 0&&e>=t)}function ho(n,e){return zm(n,e,0)}function za(n,e){return zm(n,e,e)}function zm(n,e,t){return n===void 0?t:km(n)?e===1/0?e:Math.max(0,e+n)|0:e===void 0||e===n?n:Math.min(e,n)|0}function km(n){return n<0||n===0&&1/n===-1/0}var Bm="@@__IMMUTABLE_ITERABLE__@@";function Kn(n){return!!(n&&n[Bm])}var Yl="@@__IMMUTABLE_KEYED__@@";function Bt(n){return!!(n&&n[Yl])}var Kl="@@__IMMUTABLE_INDEXED__@@";function Bn(n){return!!(n&&n[Kl])}function Zl(n){return Bt(n)||Bn(n)}var Mn=function(e){return Kn(e)?e:vn(e)},br=(function(n){function e(t){return Bt(t)?t:is(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn),Rs=(function(n){function e(t){return Bn(t)?t:wr(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn),fo=(function(n){function e(t){return Kn(t)&&!Zl(t)?t:go(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn);Mn.Keyed=br,Mn.Indexed=Rs,Mn.Set=fo;var Vm="@@__IMMUTABLE_SEQ__@@";function Jl(n){return!!(n&&n[Vm])}var Hm="@@__IMMUTABLE_RECORD__@@";function ns(n){return!!(n&&n[Hm])}function Mr(n){return Kn(n)||ns(n)}var rs="@@__IMMUTABLE_ORDERED__@@";function kr(n){return!!(n&&n[rs])}var po=0,lr=1,cr=2,ph=typeof Symbol=="function"&&Symbol.iterator,Gm="@@iterator",Ql=ph||Gm,Tt=function(e){this.next=e};Tt.prototype.toString=function(){return"[Iterator]"},Tt.KEYS=po,Tt.VALUES=lr,Tt.ENTRIES=cr,Tt.prototype.inspect=Tt.prototype.toSource=function(){return this.toString()},Tt.prototype[Ql]=function(){return this};function Yt(n,e,t,r){var i=n===po?e:n===lr?t:[e,t];return r?r.value=i:r={value:i,done:!1},r}function In(){return{value:void 0,done:!0}}function mh(n){return Array.isArray(n)?!0:!!ec(n)}function Wm(n){return n&&typeof n.next=="function"}function gh(n){var e=ec(n);return e&&e.call(n)}function ec(n){var e=n&&(ph&&n[ph]||n[Gm]);if(typeof e=="function")return e}function Z2(n){var e=ec(n);return e&&e===n.entries}function J2(n){var e=ec(n);return e&&e===n.keys}var mo=Object.prototype.hasOwnProperty;function _h(n){return Array.isArray(n)||typeof n=="string"?!0:n&&typeof n=="object"&&Number.isInteger(n.length)&&n.length>=0&&(n.length===0?Object.keys(n).length===1:n.hasOwnProperty(n.length-1))}var vn=(function(n){function e(t){return t==null?xh():Mr(t)?t.toSeq():ey(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(r,i){var s=this._cache;if(s){for(var o=s.length,a=0;a!==o;){var l=s[i?o-++a:a++];if(r(l[1],l[0],this)===!1)break}return a}return this.__iterateUncached(r,i)},e.prototype.__iterator=function(r,i){var s=this._cache;if(s){var o=s.length,a=0;return new Tt(function(){if(a===o)return In();var l=s[i?o-++a:a++];return Yt(r,l[0],l[1])})}return this.__iteratorUncached(r,i)},e})(Mn),is=(function(n){function e(t){return t==null?xh().toKeyedSeq():Kn(t)?Bt(t)?t.toSeq():t.fromEntrySeq():ns(t)?t.toSeq():yh(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e})(vn),wr=(function(n){function e(t){return t==null?xh():Kn(t)?Bt(t)?t.entrySeq():t.toIndexedSeq():ns(t)?t.toSeq().entrySeq():Xm(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e})(vn),go=(function(n){function e(t){return(Kn(t)&&!Zl(t)?t:wr(t)).toSetSeq()}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e})(vn);vn.isSeq=Jl,vn.Keyed=is,vn.Set=go,vn.Indexed=wr,vn.prototype[Vm]=!0;var _o=(function(n){function e(t){this._array=t,this.size=t.length}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return this.has(r)?this._array[ts(this,r)]:i},e.prototype.__iterate=function(r,i){for(var s=this._array,o=s.length,a=0;a!==o;){var l=i?o-++a:a++;if(r(s[l],l,this)===!1)break}return a},e.prototype.__iterator=function(r,i){var s=this._array,o=s.length,a=0;return new Tt(function(){if(a===o)return In();var l=i?o-++a:a++;return Yt(r,l,s[l])})},e})(wr),vh=(function(n){function e(t){var r=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=r,this.size=r.length}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return i!==void 0&&!this.has(r)?i:this._object[r]},e.prototype.has=function(r){return mo.call(this._object,r)},e.prototype.__iterate=function(r,i){for(var s=this._object,o=this._keys,a=o.length,l=0;l!==a;){var c=o[i?a-++l:l++];if(r(s[c],c,this)===!1)break}return l},e.prototype.__iterator=function(r,i){var s=this._object,o=this._keys,a=o.length,l=0;return new Tt(function(){if(l===a)return In();var c=o[i?a-++l:l++];return Yt(r,c,s[c])})},e})(is);vh.prototype[rs]=!0;var Q2=(function(n){function e(t){this._collection=t,this.size=t.length||t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=this._collection,o=gh(s),a=0;if(Wm(o))for(var l;!(l=o.next()).done&&r(l.value,a++,this)!==!1;);return a},e.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=this._collection,o=gh(s);if(!Wm(o))return new Tt(In);var a=0;return new Tt(function(){var l=o.next();return l.done?l:Yt(r,a++,l.value)})},e})(wr),jm;function xh(){return jm||(jm=new _o([]))}function yh(n){var e=Sh(n);if(e)return e.fromEntrySeq();if(typeof n=="object")return new vh(n);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+n)}function Xm(n){var e=Sh(n);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+n)}function ey(n){var e=Sh(n);if(e)return Z2(n)?e.fromEntrySeq():J2(n)?e.toSetSeq():e;if(typeof n=="object")return new vh(n);throw new TypeError("Expected Array or collection object of values, or keyed object: "+n)}function Sh(n){return _h(n)?new _o(n):mh(n)?new Q2(n):void 0}var $m="@@__IMMUTABLE_MAP__@@";function tc(n){return!!(n&&n[$m])}function Eh(n){return tc(n)&&kr(n)}function bh(n){return!!(n&&typeof n.equals=="function"&&typeof n.hashCode=="function")}function Kt(n,e){if(n===e||n!==n&&e!==e)return!0;if(!n||!e)return!1;if(typeof n.valueOf=="function"&&typeof e.valueOf=="function"){if(n=n.valueOf(),e=e.valueOf(),n===e||n!==n&&e!==e)return!0;if(!n||!e)return!1}return!!(bh(n)&&bh(e)&&n.equals(e))}var ka=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(e,t){e|=0,t|=0;var r=e&65535,i=t&65535;return r*i+((e>>>16)*i+r*(t>>>16)<<16>>>0)|0};function nc(n){return n>>>1&1073741824|n&3221225471}var ty=Object.prototype.valueOf;function Zn(n){if(n==null)return Ym(n);if(typeof n.hashCode=="function")return nc(n.hashCode(n));var e=ay(n);if(e==null)return Ym(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return ny(e);case"string":return e.length>ly?ry(e):Mh(e);case"object":case"function":return sy(e);case"symbol":return iy(e);default:if(typeof e.toString=="function")return Mh(e.toString());throw new Error("Value type "+typeof e+" cannot be hashed.")}}function Ym(n){return n===null?1108378658:1108378659}function ny(n){if(n!==n||n===1/0)return 0;var e=n|0;for(e!==n&&(e^=n*4294967295);n>4294967295;)n/=4294967295,e^=n;return nc(e)}function ry(n){var e=Rh[n];return e===void 0&&(e=Mh(n),Ch===cy&&(Ch=0,Rh={}),Ch++,Rh[n]=e),e}function Mh(n){for(var e=0,t=0;t<n.length;t++)e=31*e+n.charCodeAt(t)|0;return nc(e)}function iy(n){var e=Qm[n];return e!==void 0||(e=Jm(),Qm[n]=e),e}function sy(n){var e;if(wh&&(e=Th.get(n),e!==void 0)||(e=n[Ps],e!==void 0)||!Zm&&(e=n.propertyIsEnumerable&&n.propertyIsEnumerable[Ps],e!==void 0||(e=oy(n),e!==void 0)))return e;if(e=Jm(),wh)Th.set(n,e);else{if(Km!==void 0&&Km(n)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(Zm)Object.defineProperty(n,Ps,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(n.propertyIsEnumerable!==void 0&&n.propertyIsEnumerable===n.constructor.prototype.propertyIsEnumerable)n.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},n.propertyIsEnumerable[Ps]=e;else if(n.nodeType!==void 0)n[Ps]=e;else throw new Error("Unable to set a non-enumerable property on object.")}return e}var Km=Object.isExtensible,Zm=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function oy(n){if(n&&n.nodeType>0)switch(n.nodeType){case 1:return n.uniqueID;case 9:return n.documentElement&&n.documentElement.uniqueID}}function ay(n){return n.valueOf!==ty&&typeof n.valueOf=="function"?n.valueOf(n):n}function Jm(){var n=++Ah;return Ah&1073741824&&(Ah=0),n}var wh=typeof WeakMap=="function",Th;wh&&(Th=new WeakMap);var Qm=Object.create(null),Ah=0,Ps="__immutablehash__";typeof Symbol=="function"&&(Ps=Symbol(Ps));var ly=16,cy=255,Ch=0,Rh={},rc=(function(n){function e(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return this._iter.get(r,i)},e.prototype.has=function(r){return this._iter.has(r)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var r=this,i=Ph(this,!0);return this._useKeys||(i.valueSeq=function(){return r._iter.toSeq().reverse()}),i},e.prototype.map=function(r,i){var s=this,o=i0(this,r,i);return this._useKeys||(o.valueSeq=function(){return s._iter.toSeq().map(r,i)}),o},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o,a){return r(o,a,s)},i)},e.prototype.__iterator=function(r,i){return this._iter.__iterator(r,i)},e})(is);rc.prototype[rs]=!0;var e0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.includes=function(r){return this._iter.includes(r)},e.prototype.__iterate=function(r,i){var s=this,o=0;return i&&uo(this),this._iter.__iterate(function(a){return r(a,i?s.size-++o:o++,s)},i)},e.prototype.__iterator=function(r,i){var s=this,o=this._iter.__iterator(lr,i),a=0;return i&&uo(this),new Tt(function(){var l=o.next();return l.done?l:Yt(r,i?s.size-++a:a++,l.value,l)})},e})(wr),t0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.has=function(r){return this._iter.includes(r)},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){return r(o,o,s)},i)},e.prototype.__iterator=function(r,i){var s=this._iter.__iterator(lr,i);return new Tt(function(){var o=s.next();return o.done?o:Yt(r,o.value,o.value,o)})},e})(go),n0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){if(o){c0(o);var a=Kn(o);return r(a?o.get(1):o[1],a?o.get(0):o[0],s)}},i)},e.prototype.__iterator=function(r,i){var s=this._iter.__iterator(lr,i);return new Tt(function(){for(;;){var o=s.next();if(o.done)return o;var a=o.value;if(a){c0(a);var l=Kn(a);return Yt(r,l?a.get(0):a[0],l?a.get(1):a[1],o)}}})},e})(is);e0.prototype.cacheResult=rc.prototype.cacheResult=t0.prototype.cacheResult=n0.prototype.cacheResult=Oh;function r0(n){var e=ci(n);return e._iter=n,e.size=n.size,e.flip=function(){return n},e.reverse=function(){var t=n.reverse.apply(this);return t.flip=function(){return n.reverse()},t},e.has=function(t){return n.includes(t)},e.includes=function(t){return n.has(t)},e.cacheResult=Oh,e.__iterateUncached=function(t,r){var i=this;return n.__iterate(function(s,o){return t(o,s,i)!==!1},r)},e.__iteratorUncached=function(t,r){if(t===cr){var i=n.__iterator(t,r);return new Tt(function(){var s=i.next();if(!s.done){var o=s.value[0];s.value[0]=s.value[1],s.value[1]=o}return s})}return n.__iterator(t===lr?po:lr,r)},e}function i0(n,e,t){var r=ci(n);return r.size=n.size,r.has=function(i){return n.has(i)},r.get=function(i,s){var o=n.get(i,wt);return o===wt?s:e.call(t,o,i,n)},r.__iterateUncached=function(i,s){var o=this;return n.__iterate(function(a,l,c){return i(e.call(t,a,l,c),l,o)!==!1},s)},r.__iteratorUncached=function(i,s){var o=n.__iterator(cr,s);return new Tt(function(){var a=o.next();if(a.done)return a;var l=a.value,c=l[0];return Yt(i,c,e.call(t,l[1],c,n),a)})},r}function Ph(n,e){var t=this,r=ci(n);return r._iter=n,r.size=n.size,r.reverse=function(){return n},n.flip&&(r.flip=function(){var i=r0(n);return i.reverse=function(){return n.flip()},i}),r.get=function(i,s){return n.get(e?i:-1-i,s)},r.has=function(i){return n.has(e?i:-1-i)},r.includes=function(i){return n.includes(i)},r.cacheResult=Oh,r.__iterate=function(i,s){var o=this,a=0;return s&&uo(n),n.__iterate(function(l,c){return i(l,e?c:s?o.size-++a:a++,o)},!s)},r.__iterator=function(i,s){var o=0;s&&uo(n);var a=n.__iterator(cr,!s);return new Tt(function(){var l=a.next();if(l.done)return l;var c=l.value;return Yt(i,e?c[0]:s?t.size-++o:o++,c[1],l)})},r}function s0(n,e,t,r){var i=ci(n);return r&&(i.has=function(s){var o=n.get(s,wt);return o!==wt&&!!e.call(t,o,s,n)},i.get=function(s,o){var a=n.get(s,wt);return a!==wt&&e.call(t,a,s,n)?a:o}),i.__iterateUncached=function(s,o){var a=this,l=0;return n.__iterate(function(c,h,f){if(e.call(t,c,h,f))return l++,s(c,r?h:l-1,a)},o),l},i.__iteratorUncached=function(s,o){var a=n.__iterator(cr,o),l=0;return new Tt(function(){for(;;){var c=a.next();if(c.done)return c;var h=c.value,f=h[0],p=h[1];if(e.call(t,p,f,n))return Yt(s,r?f:l++,p,c)}})},i}function uy(n,e,t){var r=Ie().asMutable();return n.__iterate(function(i,s){r.update(e.call(t,i,s,n),0,function(o){return o+1})}),r.asImmutable()}function hy(n,e,t){var r=Bt(n),i=(kr(n)?fi():Ie()).asMutable();n.__iterate(function(o,a){i.update(e.call(t,o,a,n),function(l){return l=l||[],l.push(r?[a,o]:o),l})});var s=Lh(n);return i.map(function(o){return Vt(n,s(o))}).asImmutable()}function fy(n,e,t){var r=Bt(n),i=[[],[]];n.__iterate(function(o,a){i[e.call(t,o,a,n)?1:0].push(r?[a,o]:o)});var s=Lh(n);return i.map(function(o){return Vt(n,s(o))})}function Ih(n,e,t,r){var i=n.size;if(Fa(e,t,i))return n;if(typeof i>"u"&&(e<0||t<0))return Ih(n.toSeq().cacheResult(),e,t,r);var s=ho(e,i),o=za(t,i),a=o-s,l;a===a&&(l=a<0?0:a);var c=ci(n);return c.size=l===0?l:n.size&&l||void 0,!r&&Jl(n)&&l>=0&&(c.get=function(h,f){return h=ts(this,h),h>=0&&h<l?n.get(h+s,f):f}),c.__iterateUncached=function(h,f){var p=this;if(l===0)return 0;if(f)return this.cacheResult().__iterate(h,f);var d=0,m=!0,x=0;return n.__iterate(function(v,_){if(!(m&&(m=d++<s)))return x++,h(v,r?_:x-1,p)!==!1&&x!==l}),x},c.__iteratorUncached=function(h,f){if(l!==0&&f)return this.cacheResult().__iterator(h,f);if(l===0)return new Tt(In);var p=n.__iterator(h,f),d=0,m=0;return new Tt(function(){for(;d++<s;)p.next();if(++m>l)return In();var x=p.next();return r||h===lr||x.done?x:h===po?Yt(h,m-1,void 0,x):Yt(h,m-1,x.value[1],x)})},c}function dy(n,e,t){var r=ci(n);return r.__iterateUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterate(i,s);var a=0;return n.__iterate(function(l,c,h){return e.call(t,l,c,h)&&++a&&i(l,c,o)}),a},r.__iteratorUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterator(i,s);var a=n.__iterator(cr,s),l=!0;return new Tt(function(){if(!l)return In();var c=a.next();if(c.done)return c;var h=c.value,f=h[0],p=h[1];return e.call(t,p,f,o)?i===cr?c:Yt(i,f,p,c):(l=!1,In())})},r}function o0(n,e,t,r){var i=ci(n);return i.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=!0,c=0;return n.__iterate(function(h,f,p){if(!(l&&(l=e.call(t,h,f,p))))return c++,s(h,r?f:c-1,a)}),c},i.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=n.__iterator(cr,o),c=!0,h=0;return new Tt(function(){var f,p,d;do{if(f=l.next(),f.done)return r||s===lr?f:s===po?Yt(s,h++,void 0,f):Yt(s,h++,f.value[1],f);var m=f.value;p=m[0],d=m[1],c&&(c=e.call(t,d,p,a))}while(c);return s===cr?f:Yt(s,p,d,f)})},i}var py=(function(n){function e(t){this._wrappedIterables=t.flatMap(function(r){return r._wrappedIterables?r._wrappedIterables:[r]}),this.size=this._wrappedIterables.reduce(function(r,i){if(r!==void 0){var s=i.size;if(s!==void 0)return r+s}},0),this[Yl]=this._wrappedIterables[0][Yl],this[Kl]=this._wrappedIterables[0][Kl],this[rs]=this._wrappedIterables[0][rs]}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(r,i){if(this._wrappedIterables.length!==0){if(i)return this.cacheResult().__iterate(r,i);for(var s=0,o=Bt(this),a=o?cr:lr,l=this._wrappedIterables[s].__iterator(a,i),c=!0,h=0;c;){for(var f=l.next();f.done;){if(s++,s===this._wrappedIterables.length)return h;l=this._wrappedIterables[s].__iterator(a,i),f=l.next()}var p=o?r(f.value[1],f.value[0],this):r(f.value,h,this);c=p!==!1,h++}return h}},e.prototype.__iteratorUncached=function(r,i){var s=this;if(this._wrappedIterables.length===0)return new Tt(In);if(i)return this.cacheResult().__iterator(r,i);var o=0,a=this._wrappedIterables[o].__iterator(r,i);return new Tt(function(){for(var l=a.next();l.done;){if(o++,o===s._wrappedIterables.length)return l;a=s._wrappedIterables[o].__iterator(r,i),l=a.next()}return l})},e})(vn);function my(n,e){var t=Bt(n),r=[n].concat(e).map(function(s){return Kn(s)?t&&(s=br(s)):s=t?yh(s):Xm(Array.isArray(s)?s:[s]),s}).filter(function(s){return s.size!==0});if(r.length===0)return n;if(r.length===1){var i=r[0];if(i===n||t&&Bt(i)||Bn(n)&&Bn(i))return i}return new py(r)}function a0(n,e,t){var r=ci(n);return r.__iterateUncached=function(i,s){if(s)return this.cacheResult().__iterate(i,s);var o=0,a=!1;function l(c,h){c.__iterate(function(f,p){return(!e||h<e)&&Kn(f)?l(f,h+1):(o++,i(f,t?p:o-1,r)===!1&&(a=!0)),!a},s)}return l(n,0),o},r.__iteratorUncached=function(i,s){if(s)return this.cacheResult().__iterator(i,s);var o=n.__iterator(i,s),a=[],l=0;return new Tt(function(){for(;o;){var c=o.next();if(c.done!==!1){o=a.pop();continue}var h=c.value;if(i===cr&&(h=h[1]),(!e||a.length<e)&&Kn(h))a.push(o),o=h.__iterator(i,s);else return t?c:Yt(i,l++,h,c)}return In()})},r}function gy(n,e,t){var r=Lh(n);return n.toSeq().map(function(i,s){return r(e.call(t,i,s,n))}).flatten(!0)}function _y(n,e){var t=ci(n);return t.size=n.size&&n.size*2-1,t.__iterateUncached=function(r,i){var s=this,o=0;return n.__iterate(function(a){return(!o||r(e,o++,s)!==!1)&&r(a,o++,s)!==!1},i),o},t.__iteratorUncached=function(r,i){var s=n.__iterator(lr,i),o=0,a;return new Tt(function(){return(!a||o%2)&&(a=s.next(),a.done)?a:o%2?Yt(r,o++,e):Yt(r,o++,a.value,a)})},t}function vo(n,e,t){e||(e=u0);var r=Bt(n),i=0,s=n.toSeq().map(function(o,a){return[a,o,i++,t?t(o,a,n):o]}).valueSeq().toArray();return s.sort(function(o,a){return e(o[3],a[3])||o[2]-a[2]}).forEach(r?function(o,a){s[a].length=2}:function(o,a){s[a]=o[1]}),r?is(s):Bn(n)?wr(s):go(s)}function ic(n,e,t){if(e||(e=u0),t){var r=n.toSeq().map(function(i,s){return[i,t(i,s,n)]}).reduce(function(i,s){return l0(e,i[1],s[1])?s:i});return r&&r[0]}return n.reduce(function(i,s){return l0(e,i,s)?s:i})}function l0(n,e,t){var r=n(t,e);return r===0&&t!==e&&(t==null||t!==t)||r>0}function sc(n,e,t,r){var i=ci(n),s=new _o(t).map(function(o){return o.size});return i.size=r?s.max():s.min(),i.__iterate=function(o,a){for(var l=this.__iterator(lr,a),c,h=0;!(c=l.next()).done&&o(c.value,h++,this)!==!1;);return h},i.__iteratorUncached=function(o,a){var l=t.map(function(f){return f=Mn(f),gh(a?f.reverse():f)}),c=0,h=!1;return new Tt(function(){var f;return h||(f=l.map(function(p){return p.next()}),h=r?f.every(function(p){return p.done}):f.some(function(p){return p.done})),h?In():Yt(o,c++,e.apply(null,f.map(function(p){return p.value})))})},i}function Vt(n,e){return n===e?n:Jl(n)?e:n.constructor(e)}function c0(n){if(n!==Object(n))throw new TypeError("Expected [K, V] tuple: "+n)}function Lh(n){return Bt(n)?br:Bn(n)?Rs:fo}function ci(n){return Object.create((Bt(n)?is:Bn(n)?wr:go).prototype)}function Oh(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):vn.prototype.cacheResult.call(this)}function u0(n,e){return n===void 0&&e===void 0?0:n===void 0?1:e===void 0?-1:n>e?1:n<e?-1:0}function ui(n,e){e=e||0;for(var t=Math.max(0,n.length-e),r=new Array(t),i=0;i<t;i++)r[i]=n[i+e];return r}function Ba(n,e){if(!n)throw new Error(e)}function ur(n){Ba(n!==1/0,"Cannot perform this action with an infinite size.")}function h0(n){if(_h(n)&&typeof n!="string")return n;if(kr(n))return n.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+n)}var vy=Object.prototype.toString;function qh(n){if(!n||typeof n!="object"||vy.call(n)!=="[object Object]")return!1;var e=Object.getPrototypeOf(n);if(e===null)return!0;for(var t=e,r=Object.getPrototypeOf(e);r!==null;)t=r,r=Object.getPrototypeOf(t);return t===e}function ss(n){return typeof n=="object"&&(Mr(n)||Array.isArray(n)||qh(n))}function Va(n){try{return typeof n=="string"?JSON.stringify(n):String(n)}catch{return JSON.stringify(n)}}function f0(n,e){return Mr(n)?n.has(e):ss(n)&&mo.call(n,e)}function Dh(n,e,t){return Mr(n)?n.get(e,t):f0(n,e)?typeof n.get=="function"?n.get(e):n[e]:t}function oc(n){if(Array.isArray(n))return ui(n);var e={};for(var t in n)mo.call(n,t)&&(e[t]=n[t]);return e}function d0(n,e){if(!ss(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(Mr(n)){if(!n.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+n);return n.remove(e)}if(!mo.call(n,e))return n;var t=oc(n);return Array.isArray(t)?t.splice(e,1):delete t[e],t}function p0(n,e,t){if(!ss(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(Mr(n)){if(!n.set)throw new TypeError("Cannot update immutable value without .set() method: "+n);return n.set(e,t)}if(mo.call(n,e)&&t===n[e])return n;var r=oc(n);return r[e]=t,r}function Is(n,e,t,r){r||(r=t,t=void 0);var i=m0(Mr(n),n,h0(e),0,t,r);return i===wt?t:i}function m0(n,e,t,r,i,s){var o=e===wt;if(r===t.length){var a=o?i:e,l=s(a);return l===a?e:l}if(!o&&!ss(e))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(t).slice(0,r).map(Va)+"]: "+e);var c=t[r],h=o?wt:Dh(e,c,wt),f=m0(h===wt?n:Mr(h),h,t,r+1,i,s);return f===h?e:f===wt?d0(e,c):p0(o?n?hi():{}:e,c,f)}function g0(n,e,t){return Is(n,e,wt,function(){return t})}function Nh(n,e){return g0(this,n,e)}function _0(n,e){return Is(n,e,function(){return wt})}function Uh(n){return _0(this,n)}function Fh(n,e,t,r){return Is(n,[e],t,r)}function zh(n,e,t){return arguments.length===1?n(this):Fh(this,n,e,t)}function kh(n,e,t){return Is(this,n,e,t)}function v0(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return y0(this,n)}function x0(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(typeof n!="function")throw new TypeError("Invalid merger function: "+n);return y0(this,e,n)}function y0(n,e,t){for(var r=[],i=0;i<e.length;i++){var s=br(e[i]);s.size!==0&&r.push(s)}return r.length===0?n:n.toSeq().size===0&&!n.__ownerID&&r.length===1?ns(n)?n:n.constructor(r[0]):n.withMutations(function(o){for(var a=t?function(c,h){Fh(o,h,wt,function(f){return f===wt?c:t(f,c,h)})}:function(c,h){o.set(h,c)},l=0;l<r.length;l++)r[l].forEach(a)})}function xy(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ga(n,e)}function yy(n,e){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return Ga(e,t,n)}function Sy(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ha(n,e)}function Ey(n,e){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return Ha(e,t,n)}function Ha(n,e,t){return Ga(n,e,by(t))}function Ga(n,e,t){if(!ss(n))throw new TypeError("Cannot merge into non-data-structure value: "+n);if(Mr(n))return typeof t=="function"&&n.mergeWith?n.mergeWith.apply(n,[t].concat(e)):n.merge?n.merge.apply(n,e):n.concat.apply(n,e);for(var r=Array.isArray(n),i=n,s=r?Rs:br,o=r?function(l){i===n&&(i=oc(i)),i.push(l)}:function(l,c){var h=mo.call(i,c),f=h&&t?t(i[c],l,c):l;(!h||f!==i[c])&&(i===n&&(i=oc(i)),i[c]=f)},a=0;a<e.length;a++)s(e[a]).forEach(o);return i}function by(n){function e(t,r,i){return ss(t)&&ss(r)&&My(t,r)?Ga(t,[r],e):n?n(t,r,i):r}return e}function My(n,e){var t=vn(n),r=vn(e);return Bn(t)===Bn(r)&&Bt(t)===Bt(r)}function S0(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return Ha(this,n)}function E0(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ha(this,e,n)}function Bh(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Is(this,n,hi(),function(r){return Ga(r,e)})}function Vh(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Is(this,n,hi(),function(r){return Ha(r,e)})}function Wa(n){var e=this.asMutable();return n(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function ja(){return this.__ownerID?this:this.__ensureOwner(new dh)}function Xa(){return this.__ensureOwner()}function Hh(){return this.__altered}var Ie=(function(n){function e(t){return t==null?hi():tc(t)&&!kr(t)?t:hi().withMutations(function(r){var i=n(t);ur(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},e.prototype.set=function(r,i){return w0(this,r,i)},e.prototype.remove=function(r){return w0(this,r,wt)},e.prototype.deleteAll=function(r){var i=Mn(r);return i.size===0?this:this.withMutations(function(s){i.forEach(function(o){return s.remove(o)})})},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):hi()},e.prototype.sort=function(r){return fi(vo(this,r))},e.prototype.sortBy=function(r,i){return fi(vo(this,i,r))},e.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){o.forEach(function(a,l){o.set(l,r.call(i,a,l,s))})})},e.prototype.__iterator=function(r,i){return new wy(this,r,i)},e.prototype.__iterate=function(r,i){var s=this,o=0;return this._root&&this._root.iterate(function(a){return o++,r(a[1],a[0],s)},i),o},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Wh(this.size,this._root,r,this.__hash):this.size===0?hi():(this.__ownerID=r,this.__altered=!1,this)},e})(br);Ie.isMap=tc;var Zt=Ie.prototype;Zt[$m]=!0,Zt[Ua]=Zt.remove,Zt.removeAll=Zt.deleteAll,Zt.setIn=Nh,Zt.removeIn=Zt.deleteIn=Uh,Zt.update=zh,Zt.updateIn=kh,Zt.merge=Zt.concat=v0,Zt.mergeWith=x0,Zt.mergeDeep=S0,Zt.mergeDeepWith=E0,Zt.mergeIn=Bh,Zt.mergeDeepIn=Vh,Zt.withMutations=Wa,Zt.wasAltered=Hh,Zt.asImmutable=Xa,Zt["@@transducer/init"]=Zt.asMutable=ja,Zt["@@transducer/step"]=function(n,e){return n.set(e[0],e[1])},Zt["@@transducer/result"]=function(n){return n.asImmutable()};var $a=function(e,t){this.ownerID=e,this.entries=t};$a.prototype.get=function(e,t,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Kt(r,s[o][0]))return s[o][1];return i},$a.prototype.update=function(e,t,r,i,s,o,a){for(var l=s===wt,c=this.entries,h=0,f=c.length;h<f&&!Kt(i,c[h][0]);h++);var p=h<f;if(p?c[h][1]===s:l)return this;if(Er(a),(l||!p)&&Er(o),!(l&&c.length===1)){if(!p&&!l&&c.length>=Iy)return Ty(e,c,i,s);var d=e&&e===this.ownerID,m=d?c:ui(c);return p?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),d?(this.entries=m,this):new $a(e,m)}};var xo=function(e,t,r){this.ownerID=e,this.bitmap=t,this.nodes=r};xo.prototype.get=function(e,t,r,i){t===void 0&&(t=Zn(r));var s=1<<((e===0?t:t>>>e)&kn),o=this.bitmap;return(o&s)===0?i:this.nodes[A0(o&s-1)].get(e+kt,t,r,i)},xo.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=(t===0?r:r>>>t)&kn,c=1<<l,h=this.bitmap,f=(h&c)!==0;if(!f&&s===wt)return this;var p=A0(h&c-1),d=this.nodes,m=f?d[p]:void 0,x=jh(m,e,t+kt,r,i,s,o,a);if(x===m)return this;if(!f&&x&&d.length>=Ly)return Cy(e,d,h,l,x);if(f&&!x&&d.length===2&&T0(d[p^1]))return d[p^1];if(f&&x&&d.length===1&&T0(x))return x;var v=e&&e===this.ownerID,_=f?x?h:h^c:h|c,w=f?x?C0(d,p,x,v):Py(d,p,v):Ry(d,p,x,v);return v?(this.bitmap=_,this.nodes=w,this):new xo(e,_,w)};var Ya=function(e,t,r){this.ownerID=e,this.count=t,this.nodes=r};Ya.prototype.get=function(e,t,r,i){t===void 0&&(t=Zn(r));var s=(e===0?t:t>>>e)&kn,o=this.nodes[s];return o?o.get(e+kt,t,r,i):i},Ya.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=(t===0?r:r>>>t)&kn,c=s===wt,h=this.nodes,f=h[l];if(c&&!f)return this;var p=jh(f,e,t+kt,r,i,s,o,a);if(p===f)return this;var d=this.count;if(!f)d++;else if(!p&&(d--,d<Oy))return Ay(e,h,d,l);var m=e&&e===this.ownerID,x=C0(h,l,p,m);return m?(this.count=d,this.nodes=x,this):new Ya(e,d,x)};var yo=function(e,t,r){this.ownerID=e,this.keyHash=t,this.entries=r};yo.prototype.get=function(e,t,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Kt(r,s[o][0]))return s[o][1];return i},yo.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=s===wt;if(r!==this.keyHash)return l?this:(Er(a),Er(o),Xh(this,e,t,r,[i,s]));for(var c=this.entries,h=0,f=c.length;h<f&&!Kt(i,c[h][0]);h++);var p=h<f;if(p?c[h][1]===s:l)return this;if(Er(a),(l||!p)&&Er(o),l&&f===2)return new qi(e,this.keyHash,c[h^1]);var d=e&&e===this.ownerID,m=d?c:ui(c);return p?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),d?(this.entries=m,this):new yo(e,this.keyHash,m)};var qi=function(e,t,r){this.ownerID=e,this.keyHash=t,this.entry=r};qi.prototype.get=function(e,t,r,i){return Kt(r,this.entry[0])?this.entry[1]:i},qi.prototype.update=function(e,t,r,i,s,o,a){var l=s===wt,c=Kt(i,this.entry[0]);if(c?s===this.entry[1]:l)return this;if(Er(a),l){Er(o);return}return c?e&&e===this.ownerID?(this.entry[1]=s,this):new qi(e,this.keyHash,[i,s]):(Er(o),Xh(this,e,t,Zn(i),[i,s]))},$a.prototype.iterate=yo.prototype.iterate=function(n,e){for(var t=this.entries,r=0,i=t.length-1;r<=i;r++)if(n(t[e?i-r:r])===!1)return!1},xo.prototype.iterate=Ya.prototype.iterate=function(n,e){for(var t=this.nodes,r=0,i=t.length-1;r<=i;r++){var s=t[e?i-r:r];if(s&&s.iterate(n,e)===!1)return!1}},qi.prototype.iterate=function(n,e){return n(this.entry)};var wy=(function(n){function e(t,r,i){this._type=r,this._reverse=i,this._stack=t._root&&b0(t._root)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.next=function(){for(var r=this._type,i=this._stack;i;){var s=i.node,o=i.index++,a=void 0;if(s.entry){if(o===0)return Gh(r,s.entry)}else if(s.entries){if(a=s.entries.length-1,o<=a)return Gh(r,s.entries[this._reverse?a-o:o])}else if(a=s.nodes.length-1,o<=a){var l=s.nodes[this._reverse?a-o:o];if(l){if(l.entry)return Gh(r,l.entry);i=this._stack=b0(l,i)}continue}i=this._stack=this._stack.__prev}return In()},e})(Tt);function Gh(n,e){return Yt(n,e[0],e[1])}function b0(n,e){return{node:n,index:0,__prev:e}}function Wh(n,e,t,r){var i=Object.create(Zt);return i.size=n,i._root=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var M0;function hi(){return M0||(M0=Wh(0))}function w0(n,e,t){var r,i;if(n._root){var s=fh(),o=fh();if(r=jh(n._root,n.__ownerID,0,void 0,e,t,s,o),!o.value)return n;i=n.size+(s.value?t===wt?-1:1:0)}else{if(t===wt)return n;i=1,r=new $a(n.__ownerID,[[e,t]])}return n.__ownerID?(n.size=i,n._root=r,n.__hash=void 0,n.__altered=!0,n):r?Wh(i,r):hi()}function jh(n,e,t,r,i,s,o,a){return n?n.update(e,t,r,i,s,o,a):s===wt?n:(Er(a),Er(o),new qi(e,r,[i,s]))}function T0(n){return n.constructor===qi||n.constructor===yo}function Xh(n,e,t,r,i){if(n.keyHash===r)return new yo(e,r,[n.entry,i]);var s=(t===0?n.keyHash:n.keyHash>>>t)&kn,o=(t===0?r:r>>>t)&kn,a,l=s===o?[Xh(n,e,t+kt,r,i)]:(a=new qi(e,r,i),s<o?[n,a]:[a,n]);return new xo(e,1<<s|1<<o,l)}function Ty(n,e,t,r){n||(n=new dh);for(var i=new qi(n,Zn(t),[t,r]),s=0;s<e.length;s++){var o=e[s];i=i.update(n,0,void 0,o[0],o[1])}return i}function Ay(n,e,t,r){for(var i=0,s=0,o=new Array(t),a=0,l=1,c=e.length;a<c;a++,l<<=1){var h=e[a];h!==void 0&&a!==r&&(i|=l,o[s++]=h)}return new xo(n,i,o)}function Cy(n,e,t,r,i){for(var s=0,o=new Array(ar),a=0;t!==0;a++,t>>>=1)o[a]=t&1?e[s++]:void 0;return o[r]=i,new Ya(n,s+1,o)}function A0(n){return n-=n>>1&1431655765,n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n+=n>>8,n+=n>>16,n&127}function C0(n,e,t,r){var i=r?n:ui(n);return i[e]=t,i}function Ry(n,e,t,r){var i=n.length+1;if(r&&e+1===i)return n[e]=t,n;for(var s=new Array(i),o=0,a=0;a<i;a++)a===e?(s[a]=t,o=-1):s[a]=n[a+o];return s}function Py(n,e,t){var r=n.length-1;if(t&&e===r)return n.pop(),n;for(var i=new Array(r),s=0,o=0;o<r;o++)o===e&&(s=1),i[o]=n[o+s];return i}var Iy=ar/4,Ly=ar/2,Oy=ar/4,R0="@@__IMMUTABLE_LIST__@@";function $h(n){return!!(n&&n[R0])}var He=(function(n){function e(t){var r=ac();if(t==null)return r;if($h(t))return t;var i=n(t),s=i.size;return s===0?r:(ur(s),s>0&&s<ar?Za(0,s,kt,null,new os(i.toArray())):r.withMutations(function(o){o.setSize(s),i.forEach(function(a,l){return o.set(l,a)})}))}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("List [","]")},e.prototype.get=function(r,i){if(r=ts(this,r),r>=0&&r<this.size){r+=this._origin;var s=I0(this,r);return s&&s.array[r&kn]}return i},e.prototype.set=function(r,i){return qy(this,r,i)},e.prototype.remove=function(r){return this.has(r)?r===0?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},e.prototype.insert=function(r,i){return this.splice(r,0,i)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=kt,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ac()},e.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(s){as(s,0,i+r.length);for(var o=0;o<r.length;o++)s.set(i+o,r[o])})},e.prototype.pop=function(){return as(this,0,-1)},e.prototype.unshift=function(){var r=arguments;return this.withMutations(function(i){as(i,-r.length);for(var s=0;s<r.length;s++)i.set(s,r[s])})},e.prototype.shift=function(){return as(this,1)},e.prototype.shuffle=function(r){return r===void 0&&(r=Math.random),this.withMutations(function(i){for(var s=i.size,o,a;s;)o=Math.floor(r()*s--),a=i.get(o),i.set(o,i.get(s)),i.set(s,a)})},e.prototype.concat=function(){for(var r=arguments,i=[],s=0;s<arguments.length;s++){var o=r[s],a=n(typeof o!="string"&&mh(o)?o:[o]);a.size!==0&&i.push(a)}return i.length===0?this:this.size===0&&!this.__ownerID&&i.length===1?this.constructor(i[0]):this.withMutations(function(l){i.forEach(function(c){return c.forEach(function(h){return l.push(h)})})})},e.prototype.setSize=function(r){return as(this,0,r)},e.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){for(var a=0;a<s.size;a++)o.set(a,r.call(i,o.get(a),a,s))})},e.prototype.slice=function(r,i){var s=this.size;return Fa(r,i,s)?this:as(this,ho(r,s),za(i,s))},e.prototype.__iterator=function(r,i){var s=i?this.size:0,o=P0(this,i);return new Tt(function(){var a=o();return a===Ka?In():Yt(r,i?--s:s++,a)})},e.prototype.__iterate=function(r,i){for(var s=i?this.size:0,o=P0(this,i),a;(a=o())!==Ka&&r(a,i?--s:s++,this)!==!1;);return s},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Za(this._origin,this._capacity,this._level,this._root,this._tail,r,this.__hash):this.size===0?ac():(this.__ownerID=r,this.__altered=!1,this)},e})(Rs);He.isList=$h;var dn=He.prototype;dn[R0]=!0,dn[Ua]=dn.remove,dn.merge=dn.concat,dn.setIn=Nh,dn.deleteIn=dn.removeIn=Uh,dn.update=zh,dn.updateIn=kh,dn.mergeIn=Bh,dn.mergeDeepIn=Vh,dn.withMutations=Wa,dn.wasAltered=Hh,dn.asImmutable=Xa,dn["@@transducer/init"]=dn.asMutable=ja,dn["@@transducer/step"]=function(n,e){return n.push(e)},dn["@@transducer/result"]=function(n){return n.asImmutable()};var os=function(e,t){this.array=e,this.ownerID=t};os.prototype.removeBefore=function(e,t,r){if((r&(1<<t+kt)-1)===0||this.array.length===0)return this;var i=r>>>t&kn;if(i>=this.array.length)return new os([],e);var s=i===0,o;if(t>0){var a=this.array[i];if(o=a&&a.removeBefore(e,t-kt,r),o===a&&s)return this}if(s&&!o)return this;var l=So(this,e);if(!s)for(var c=0;c<i;c++)l.array[c]=void 0;return o&&(l.array[i]=o),l},os.prototype.removeAfter=function(e,t,r){if(r===(t?1<<t+kt:ar)||this.array.length===0)return this;var i=r-1>>>t&kn;if(i>=this.array.length)return this;var s;if(t>0){var o=this.array[i];if(s=o&&o.removeAfter(e,t-kt,r),s===o&&i===this.array.length-1)return this}var a=So(this,e);return a.array.splice(i+1),s&&(a.array[i]=s),a};var Ka={};function P0(n,e){var t=n._origin,r=n._capacity,i=Ja(r),s=n._tail;return o(n._root,n._level,0);function o(c,h,f){return h===0?a(c,f):l(c,h,f)}function a(c,h){var f=h===i?s&&s.array:c&&c.array,p=h>t?0:t-h,d=r-h;return d>ar&&(d=ar),function(){if(p===d)return Ka;var m=e?--d:p++;return f&&f[m]}}function l(c,h,f){var p,d=c&&c.array,m=f>t?0:t-f>>h,x=(r-f>>h)+1;return x>ar&&(x=ar),function(){for(;;){if(p){var v=p();if(v!==Ka)return v;p=null}if(m===x)return Ka;var _=e?--x:m++;p=o(d&&d[_],h-kt,f+(_<<h))}}}}function Za(n,e,t,r,i,s,o){var a=Object.create(dn);return a.size=e-n,a._origin=n,a._capacity=e,a._level=t,a._root=r,a._tail=i,a.__ownerID=s,a.__hash=o,a.__altered=!1,a}function ac(){return Za(0,0,kt)}function qy(n,e,t){if(e=ts(n,e),e!==e)return n;if(e>=n.size||e<0)return n.withMutations(function(o){e<0?as(o,e).set(0,t):as(o,0,e+1).set(e,t)});e+=n._origin;var r=n._tail,i=n._root,s=fh();return e>=Ja(n._capacity)?r=Yh(r,n.__ownerID,0,e,t,s):i=Yh(i,n.__ownerID,n._level,e,t,s),s.value?n.__ownerID?(n._root=i,n._tail=r,n.__hash=void 0,n.__altered=!0,n):Za(n._origin,n._capacity,n._level,i,r):n}function Yh(n,e,t,r,i,s){var o=r>>>t&kn,a=n&&o<n.array.length;if(!a&&i===void 0)return n;var l;if(t>0){var c=n&&n.array[o],h=Yh(c,e,t-kt,r,i,s);return h===c?n:(l=So(n,e),l.array[o]=h,l)}return a&&n.array[o]===i?n:(s&&Er(s),l=So(n,e),i===void 0&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function So(n,e){return e&&n&&e===n.ownerID?n:new os(n?n.array.slice():[],e)}function I0(n,e){if(e>=Ja(n._capacity))return n._tail;if(e<1<<n._level+kt){for(var t=n._root,r=n._level;t&&r>0;)t=t.array[e>>>r&kn],r-=kt;return t}}function as(n,e,t){e!==void 0&&(e|=0),t!==void 0&&(t|=0);var r=n.__ownerID||new dh,i=n._origin,s=n._capacity,o=i+e,a=t===void 0?s:t<0?s+t:i+t;if(o===i&&a===s)return n;if(o>=a)return n.clear();for(var l=n._level,c=n._root,h=0;o+h<0;)c=new os(c&&c.array.length?[void 0,c]:[],r),l+=kt,h+=1<<l;h&&(o+=h,i+=h,a+=h,s+=h);for(var f=Ja(s),p=Ja(a);p>=1<<l+kt;)c=new os(c&&c.array.length?[c]:[],r),l+=kt;var d=n._tail,m=p<f?I0(n,a-1):p>f?new os([],r):d;if(d&&p>f&&o<s&&d.array.length){c=So(c,r);for(var x=c,v=l;v>kt;v-=kt){var _=f>>>v&kn;x=x.array[_]=So(x.array[_],r)}x.array[f>>>kt&kn]=d}if(a<s&&(m=m&&m.removeAfter(r,0,a)),o>=p)o-=p,a-=p,l=kt,c=null,m=m&&m.removeBefore(r,0,o);else if(o>i||p<f){for(h=0;c;){var w=o>>>l&kn;if(w!==p>>>l&kn)break;w&&(h+=(1<<l)*w),l-=kt,c=c.array[w]}c&&o>i&&(c=c.removeBefore(r,l,o-h)),c&&p<f&&(c=c.removeAfter(r,l,p-h)),h&&(o-=h,a-=h)}return n.__ownerID?(n.size=a-o,n._origin=o,n._capacity=a,n._level=l,n._root=c,n._tail=m,n.__hash=void 0,n.__altered=!0,n):Za(o,a,l,c,m)}function Ja(n){return n<ar?0:n-1>>>kt<<kt}var fi=(function(n){function e(t){return t==null?Qa():Eh(t)?t:Qa().withMutations(function(r){var i=br(t);ur(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(r,i){var s=this._map.get(r);return s!==void 0?this._list.get(s)[1]:i},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):Qa()},e.prototype.set=function(r,i){return O0(this,r,i)},e.prototype.remove=function(r){return O0(this,r,wt)},e.prototype.__iterate=function(r,i){var s=this;return this._list.__iterate(function(o){return o&&r(o[1],o[0],s)},i)},e.prototype.__iterator=function(r,i){return this._list.fromEntrySeq().__iterator(r,i)},e.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r),s=this._list.__ensureOwner(r);return r?Kh(i,s,r,this.__hash):this.size===0?Qa():(this.__ownerID=r,this.__altered=!1,this._map=i,this._list=s,this)},e})(Ie);fi.isOrderedMap=Eh,fi.prototype[rs]=!0,fi.prototype[Ua]=fi.prototype.remove;function Kh(n,e,t,r){var i=Object.create(fi.prototype);return i.size=n?n.size:0,i._map=n,i._list=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var L0;function Qa(){return L0||(L0=Kh(hi(),ac()))}function O0(n,e,t){var r=n._map,i=n._list,s=r.get(e),o=s!==void 0,a,l;if(t===wt){if(!o)return n;i.size>=ar&&i.size>=r.size*2?(l=i.filter(function(c,h){return c!==void 0&&s!==h}),a=l.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),n.__ownerID&&(a.__ownerID=l.__ownerID=n.__ownerID)):(a=r.remove(e),l=s===i.size-1?i.pop():i.set(s,void 0))}else if(o){if(t===i.get(s)[1])return n;a=r,l=i.set(s,[e,t])}else a=r.set(e,i.size),l=i.set(i.size,[e,t]);return n.__ownerID?(n.size=a.size,n._map=a,n._list=l,n.__hash=void 0,n.__altered=!0,n):Kh(a,l)}var q0="@@__IMMUTABLE_STACK__@@";function lc(n){return!!(n&&n[q0])}var cc=(function(n){function e(t){return t==null?uc():lc(t)?t:uc().pushAll(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(r,i){var s=this._head;for(r=ts(this,r);s&&r--;)s=s.next;return s?s.value:i},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var r=arguments;if(arguments.length===0)return this;for(var i=this.size+arguments.length,s=this._head,o=arguments.length-1;o>=0;o--)s={value:r[o],next:s};return this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):el(i,s)},e.prototype.pushAll=function(r){if(r=n(r),r.size===0)return this;if(this.size===0&&lc(r))return r;ur(r.size);var i=this.size,s=this._head;return r.__iterate(function(o){i++,s={value:o,next:s}},!0),this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):el(i,s)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):uc()},e.prototype.slice=function(r,i){if(Fa(r,i,this.size))return this;var s=ho(r,this.size),o=za(i,this.size);if(o!==this.size)return n.prototype.slice.call(this,r,i);for(var a=this.size-s,l=this._head;s--;)l=l.next;return this.__ownerID?(this.size=a,this._head=l,this.__hash=void 0,this.__altered=!0,this):el(a,l)},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?el(this.size,this._head,r,this.__hash):this.size===0?uc():(this.__ownerID=r,this.__altered=!1,this)},e.prototype.__iterate=function(r,i){var s=this;if(i)return new _o(this.toArray()).__iterate(function(l,c){return r(l,c,s)},i);for(var o=0,a=this._head;a&&r(a.value,o++,this)!==!1;)a=a.next;return o},e.prototype.__iterator=function(r,i){if(i)return new _o(this.toArray()).__iterator(r,i);var s=0,o=this._head;return new Tt(function(){if(o){var a=o.value;return o=o.next,Yt(r,s++,a)}return In()})},e})(Rs);cc.isStack=lc;var Vn=cc.prototype;Vn[q0]=!0,Vn.shift=Vn.pop,Vn.unshift=Vn.push,Vn.unshiftAll=Vn.pushAll,Vn.withMutations=Wa,Vn.wasAltered=Hh,Vn.asImmutable=Xa,Vn["@@transducer/init"]=Vn.asMutable=ja,Vn["@@transducer/step"]=function(n,e){return n.unshift(e)},Vn["@@transducer/result"]=function(n){return n.asImmutable()};function el(n,e,t,r){var i=Object.create(Vn);return i.size=n,i._head=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var D0;function uc(){return D0||(D0=el(0))}var N0="@@__IMMUTABLE_SET__@@";function hc(n){return!!(n&&n[N0])}function Zh(n){return hc(n)&&kr(n)}function Jh(n,e){if(n===e)return!0;if(!Kn(e)||n.size!==void 0&&e.size!==void 0&&n.size!==e.size||n.__hash!==void 0&&e.__hash!==void 0&&n.__hash!==e.__hash||Bt(n)!==Bt(e)||Bn(n)!==Bn(e)||kr(n)!==kr(e))return!1;if(n.size===0&&e.size===0)return!0;var t=!Zl(n);if(kr(n)){var r=n.entries();return e.every(function(l,c){var h=r.next().value;return h&&Kt(h[1],l)&&(t||Kt(h[0],c))})&&r.next().done}var i=!1;if(n.size===void 0)if(e.size===void 0)typeof n.cacheResult=="function"&&n.cacheResult();else{i=!0;var s=n;n=e,e=s}var o=!0,a=e.__iterate(function(l,c){if(t?!n.has(l):i?!Kt(l,n.get(c,wt)):!Kt(n.get(c,wt),l))return o=!1,!1});return o&&n.size===a}function Ls(n,e){var t=function(r){n.prototype[r]=e[r]};return Object.keys(e).forEach(t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(t),n}function fc(n){if(!n||typeof n!="object")return n;if(!Kn(n)){if(!ss(n))return n;n=vn(n)}if(Bt(n)){var e={};return n.__iterate(function(r,i){e[i]=fc(r)}),e}var t=[];return n.__iterate(function(r){t.push(fc(r))}),t}var Eo=(function(n){function e(t){return t==null?tl():hc(t)&&!kr(t)?t:tl().withMutations(function(r){var i=n(t);ur(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(r){return this(br(r).keySeq())},e.intersect=function(r){return r=Mn(r).toArray(),r.length?An.intersect.apply(e(r.pop()),r):tl()},e.union=function(r){return r=Mn(r).toArray(),r.length?An.union.apply(e(r.pop()),r):tl()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(r){return this._map.has(r)},e.prototype.add=function(r){return dc(this,this._map.set(r,r))},e.prototype.remove=function(r){return dc(this,this._map.remove(r))},e.prototype.clear=function(){return dc(this,this._map.clear())},e.prototype.map=function(r,i){var s=this,o=!1,a=dc(this,this._map.mapEntries(function(l){var c=l[1],h=r.call(i,c,c,s);return h!==c&&(o=!0),[h,h]},i));return o?a:this},e.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return r=r.filter(function(s){return s.size!==0}),r.length===0?this:this.size===0&&!this.__ownerID&&r.length===1?this.constructor(r[0]):this.withMutations(function(s){for(var o=0;o<r.length;o++)typeof r[o]=="string"?s.add(r[o]):n(r[o]).forEach(function(a){return s.add(a)})})},e.prototype.intersect=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.every(function(a){return a.includes(o)})||s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},e.prototype.subtract=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.some(function(a){return a.includes(o)})&&s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},e.prototype.sort=function(r){return wo(vo(this,r))},e.prototype.sortBy=function(r,i){return wo(vo(this,i,r))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(r,i){var s=this;return this._map.__iterate(function(o){return r(o,o,s)},i)},e.prototype.__iterator=function(r,i){return this._map.__iterator(r,i)},e.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r);return r?this.__make(i,r):this.size===0?this.__empty():(this.__ownerID=r,this._map=i,this)},e})(fo);Eo.isSet=hc;var An=Eo.prototype;An[N0]=!0,An[Ua]=An.remove,An.merge=An.concat=An.union,An.withMutations=Wa,An.asImmutable=Xa,An["@@transducer/init"]=An.asMutable=ja,An["@@transducer/step"]=function(n,e){return n.add(e)},An["@@transducer/result"]=function(n){return n.asImmutable()},An.__empty=tl,An.__make=U0;function dc(n,e){return n.__ownerID?(n.size=e.size,n._map=e,n):e===n._map?n:e.size===0?n.__empty():n.__make(e)}function U0(n,e){var t=Object.create(An);return t.size=n?n.size:0,t._map=n,t.__ownerID=e,t}var F0;function tl(){return F0||(F0=U0(hi()))}var z0=(function(n){function e(t,r,i){if(i===void 0&&(i=1),!(this instanceof e))return new e(t,r,i);if(Ba(i!==0,"Cannot step a Range by 0"),Ba(t!==void 0,"You must define a start value when using Range"),Ba(r!==void 0,"You must define an end value when using Range"),i=Math.abs(i),r<t&&(i=-i),this._start=t,this._end=r,this._step=i,this.size=Math.max(0,Math.ceil((r-t)/i-1)+1),this.size===0){if(Qh)return Qh;Qh=this}}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},e.prototype.get=function(r,i){return this.has(r)?this._start+ts(this,r)*this._step:i},e.prototype.includes=function(r){var i=(r-this._start)/this._step;return i>=0&&i<this.size&&i===Math.floor(i)},e.prototype.slice=function(r,i){return Fa(r,i,this.size)?this:(r=ho(r,this.size),i=za(i,this.size),i<=r?new e(0,0):new e(this.get(r,this._end),this.get(i,this._end),this._step))},e.prototype.indexOf=function(r){var i=r-this._start;if(i%this._step===0){var s=i/this._step;if(s>=0&&s<this.size)return s}return-1},e.prototype.lastIndexOf=function(r){return this.indexOf(r)},e.prototype.__iterate=function(r,i){for(var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;l!==s&&r(a,i?s-++l:l++,this)!==!1;)a+=i?-o:o;return l},e.prototype.__iterator=function(r,i){var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;return new Tt(function(){if(l===s)return In();var c=a;return a+=i?-o:o,Yt(r,i?s-++l:l++,c)})},e.prototype.equals=function(r){return r instanceof e?this._start===r._start&&this._end===r._end&&this._step===r._step:Jh(this,r)},e})(wr),Qh;function ef(n,e,t){for(var r=h0(e),i=0;i!==r.length;)if(n=Dh(n,r[i++],wt),n===wt)return t;return n}function k0(n,e){return ef(this,n,e)}function B0(n,e){return ef(n,e,wt)!==wt}function Dy(n){return B0(this,n)}function V0(){ur(this.size);var n={};return this.__iterate(function(e,t){n[t]=e}),n}Mn.Iterator=Tt,Ls(Mn,{toArray:function(){ur(this.size);var e=new Array(this.size||0),t=Bt(this),r=0;return this.__iterate(function(i,s){e[r++]=t?[s,i]:i}),e},toIndexedSeq:function(){return new e0(this)},toJS:function(){return fc(this)},toKeyedSeq:function(){return new rc(this,!0)},toMap:function(){return Ie(this.toKeyedSeq())},toObject:V0,toOrderedMap:function(){return fi(this.toKeyedSeq())},toOrderedSet:function(){return wo(Bt(this)?this.valueSeq():this)},toSet:function(){return Eo(Bt(this)?this.valueSeq():this)},toSetSeq:function(){return new t0(this)},toSeq:function(){return Bn(this)?this.toIndexedSeq():Bt(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return cc(Bt(this)?this.valueSeq():this)},toList:function(){return He(Bt(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(e,t){return this.size===0?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return Vt(this,my(this,e))},includes:function(e){return this.some(function(t){return Kt(t,e)})},entries:function(){return this.__iterator(cr)},every:function(e,t){ur(this.size);var r=!0;return this.__iterate(function(i,s,o){if(!e.call(t,i,s,o))return r=!1,!1}),r},filter:function(e,t){return Vt(this,s0(this,e,t,!0))},partition:function(e,t){return fy(this,e,t)},find:function(e,t,r){var i=this.findEntry(e,t);return i?i[1]:r},forEach:function(e,t){return ur(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){ur(this.size),e=e!==void 0?""+e:",";var t="",r=!0;return this.__iterate(function(i){r?r=!1:t+=e,t+=i!=null?i.toString():""}),t},keys:function(){return this.__iterator(po)},map:function(e,t){return Vt(this,i0(this,e,t))},reduce:function(e,t,r){return H0(this,e,t,r,arguments.length<2,!1)},reduceRight:function(e,t,r){return H0(this,e,t,r,arguments.length<2,!0)},reverse:function(){return Vt(this,Ph(this,!0))},slice:function(e,t){return Vt(this,Ih(this,e,t,!0))},some:function(e,t){ur(this.size);var r=!1;return this.__iterate(function(i,s,o){if(e.call(t,i,s,o))return r=!0,!1}),r},sort:function(e){return Vt(this,vo(this,e))},values:function(){return this.__iterator(lr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(e,t){return uo(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return uy(this,e,t)},equals:function(e){return Jh(this,e)},entrySeq:function(){var e=this;if(e._cache)return new _o(e._cache);var t=e.toSeq().map(Uy).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(tf(e),t)},findEntry:function(e,t,r){var i=r;return this.__iterate(function(s,o,a){if(e.call(t,s,o,a))return i=[o,s],!1}),i},findKey:function(e,t){var r=this.findEntry(e,t);return r&&r[0]},findLast:function(e,t,r){return this.toKeyedSeq().reverse().find(e,t,r)},findLastEntry:function(e,t,r){return this.toKeyedSeq().reverse().findEntry(e,t,r)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(e){return this.find(Fm,null,e)},flatMap:function(e,t){return Vt(this,gy(this,e,t))},flatten:function(e){return Vt(this,a0(this,e,!0))},fromEntrySeq:function(){return new n0(this)},get:function(e,t){return this.find(function(r,i){return Kt(i,e)},void 0,t)},getIn:k0,groupBy:function(e,t){return hy(this,e,t)},has:function(e){return this.get(e,wt)!==wt},hasIn:Dy,isSubset:function(e){return e=typeof e.includes=="function"?e:Mn(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e=typeof e.isSubset=="function"?e:Mn(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return Kt(t,e)})},keySeq:function(){return this.toSeq().map(Ny).toIndexedSeq()},last:function(e){return this.toSeq().reverse().first(e)},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return ic(this,e)},maxBy:function(e,t){return ic(this,t,e)},min:function(e){return ic(this,e?G0(e):j0)},minBy:function(e,t){return ic(this,t?G0(t):j0,e)},rest:function(){return this.slice(1)},skip:function(e){return e===0?this:this.slice(Math.max(0,e))},skipLast:function(e){return e===0?this:this.slice(0,-Math.max(0,e))},skipWhile:function(e,t){return Vt(this,o0(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(tf(e),t)},sortBy:function(e,t){return Vt(this,vo(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return this.slice(-Math.max(0,e))},takeWhile:function(e,t){return Vt(this,dy(this,e,t))},takeUntil:function(e,t){return this.takeWhile(tf(e),t)},update:function(e){return e(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Fy(this))}});var Ln=Mn.prototype;Ln[Bm]=!0,Ln[Ql]=Ln.values,Ln.toJSON=Ln.toArray,Ln.__toStringMapper=Va,Ln.inspect=Ln.toSource=function(){return this.toString()},Ln.chain=Ln.flatMap,Ln.contains=Ln.includes,Ls(br,{flip:function(){return Vt(this,r0(this))},mapEntries:function(e,t){var r=this,i=0;return Vt(this,this.toSeq().map(function(s,o){return e.call(t,[o,s],i++,r)}).fromEntrySeq())},mapKeys:function(e,t){var r=this;return Vt(this,this.toSeq().flip().map(function(i,s){return e.call(t,i,s,r)}).flip())}});var nl=br.prototype;nl[Yl]=!0,nl[Ql]=Ln.entries,nl.toJSON=V0,nl.__toStringMapper=function(n,e){return Va(e)+": "+Va(n)},Ls(Rs,{toKeyedSeq:function(){return new rc(this,!1)},filter:function(e,t){return Vt(this,s0(this,e,t,!1))},findIndex:function(e,t){var r=this.findEntry(e,t);return r?r[0]:-1},indexOf:function(e){var t=this.keyOf(e);return t===void 0?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return t===void 0?-1:t},reverse:function(){return Vt(this,Ph(this,!1))},slice:function(e,t){return Vt(this,Ih(this,e,t,!1))},splice:function(e,t){var r=arguments.length;if(t=Math.max(t||0,0),r===0||r===2&&!t)return this;e=ho(e,e<0?this.count():this.size);var i=this.slice(0,e);return Vt(this,r===1?i:i.concat(ui(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var r=this.findLastEntry(e,t);return r?r[0]:-1},first:function(e){return this.get(0,e)},flatten:function(e){return Vt(this,a0(this,e,!1))},get:function(e,t){return e=ts(this,e),e<0||this.size===1/0||this.size!==void 0&&e>this.size?t:this.find(function(r,i){return i===e},void 0,t)},has:function(e){return e=ts(this,e),e>=0&&(this.size!==void 0?this.size===1/0||e<this.size:this.indexOf(e)!==-1)},interpose:function(e){return Vt(this,_y(this,e))},interleave:function(){var e=[this].concat(ui(arguments)),t=sc(this.toSeq(),wr.of,e),r=t.flatten(!0);return t.size&&(r.size=t.size*e.length),Vt(this,r)},keySeq:function(){return z0(0,this.size)},last:function(e){return this.get(-1,e)},skipWhile:function(e,t){return Vt(this,o0(this,e,t,!1))},zip:function(){var e=[this].concat(ui(arguments));return Vt(this,sc(this,W0,e))},zipAll:function(){var e=[this].concat(ui(arguments));return Vt(this,sc(this,W0,e,!0))},zipWith:function(e){var t=ui(arguments);return t[0]=this,Vt(this,sc(this,e,t))}});var bo=Rs.prototype;bo[Kl]=!0,bo[rs]=!0,Ls(fo,{get:function(e,t){return this.has(e)?e:t},includes:function(e){return this.has(e)},keySeq:function(){return this.valueSeq()}});var Mo=fo.prototype;Mo.has=Ln.includes,Mo.contains=Mo.includes,Mo.keys=Mo.values,Ls(is,nl),Ls(wr,bo),Ls(go,Mo);function H0(n,e,t,r,i,s){return ur(n.size),n.__iterate(function(o,a,l){i?(i=!1,t=o):t=e.call(r,t,o,a,l)},s),t}function Ny(n,e){return e}function Uy(n,e){return[e,n]}function tf(n){return function(){return!n.apply(this,arguments)}}function G0(n){return function(){return-n.apply(this,arguments)}}function W0(){return ui(arguments)}function j0(n,e){return n<e?1:n>e?-1:0}function Fy(n){if(n.size===1/0)return 0;var e=kr(n),t=Bt(n),r=e?1:0;return n.__iterate(t?e?function(i,s){r=31*r+X0(Zn(i),Zn(s))|0}:function(i,s){r=r+X0(Zn(i),Zn(s))|0}:e?function(i){r=31*r+Zn(i)|0}:function(i){r=r+Zn(i)|0}),zy(n.size,r)}function zy(n,e){return e=ka(e,3432918353),e=ka(e<<15|e>>>-15,461845907),e=ka(e<<13|e>>>-13,5),e=(e+3864292196|0)^n,e=ka(e^e>>>16,2246822507),e=ka(e^e>>>13,3266489909),e=nc(e^e>>>16),e}function X0(n,e){return n^e+2654435769+(n<<6)+(n>>2)|0}var wo=(function(n){function e(t){return t==null?nf():Zh(t)?t:nf().withMutations(function(r){var i=fo(t);ur(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(r){return this(br(r).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e})(Eo);wo.isOrderedSet=Zh;var Os=wo.prototype;Os[rs]=!0,Os.zip=bo.zip,Os.zipWith=bo.zipWith,Os.zipAll=bo.zipAll,Os.__empty=nf,Os.__make=$0;function $0(n,e){var t=Object.create(Os);return t.size=n?n.size:0,t._map=n,t.__ownerID=e,t}var Y0;function nf(){return Y0||(Y0=$0(Qa()))}var ky={LeftThenRight:-1,RightThenLeft:1};function By(n){if(ns(n))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(Mr(n))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(n===null||typeof n!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var gt=function(e,t){var r;By(e);var i=function(a){var l=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var c=Object.keys(e),h=s._indices={};s._name=t,s._keys=c,s._defaultValues=e;for(var f=0;f<c.length;f++){var p=c[f];h[p]=f,s[p]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+sf(this)+' with property "'+p+'" since that property name is part of the Record API.'):Vy(s,p)}}return this.__ownerID=void 0,this._values=He().withMutations(function(d){d.setSize(l._keys.length),br(a).forEach(function(m,x){d.set(l._indices[x],m===l._defaultValues[x]?void 0:m)})}),this},s=i.prototype=Object.create(jt);return s.constructor=i,t&&(i.displayName=t),i};gt.prototype.toString=function(){for(var e=sf(this)+" { ",t=this._keys,r,i=0,s=t.length;i!==s;i++)r=t[i],e+=(i?", ":"")+r+": "+Va(this.get(r));return e+" }"},gt.prototype.equals=function(e){return this===e||ns(e)&&To(this).equals(To(e))},gt.prototype.hashCode=function(){return To(this).hashCode()},gt.prototype.has=function(e){return this._indices.hasOwnProperty(e)},gt.prototype.get=function(e,t){if(!this.has(e))return t;var r=this._indices[e],i=this._values.get(r);return i===void 0?this._defaultValues[e]:i},gt.prototype.set=function(e,t){if(this.has(e)){var r=this._values.set(this._indices[e],t===this._defaultValues[e]?void 0:t);if(r!==this._values&&!this.__ownerID)return rf(this,r)}return this},gt.prototype.remove=function(e){return this.set(e)},gt.prototype.clear=function(){var e=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:rf(this,e)},gt.prototype.wasAltered=function(){return this._values.wasAltered()},gt.prototype.toSeq=function(){return To(this)},gt.prototype.toJS=function(){return fc(this)},gt.prototype.entries=function(){return this.__iterator(cr)},gt.prototype.__iterator=function(e,t){return To(this).__iterator(e,t)},gt.prototype.__iterate=function(e,t){return To(this).__iterate(e,t)},gt.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._values.__ensureOwner(e);return e?rf(this,t,e):(this.__ownerID=e,this._values=t,this)},gt.isRecord=ns,gt.getDescriptiveName=sf;var jt=gt.prototype;jt[Hm]=!0,jt[Ua]=jt.remove,jt.deleteIn=jt.removeIn=Uh,jt.getIn=k0,jt.hasIn=Ln.hasIn,jt.merge=v0,jt.mergeWith=x0,jt.mergeIn=Bh,jt.mergeDeep=S0,jt.mergeDeepWith=E0,jt.mergeDeepIn=Vh,jt.setIn=Nh,jt.update=zh,jt.updateIn=kh,jt.withMutations=Wa,jt.asMutable=ja,jt.asImmutable=Xa,jt[Ql]=jt.entries,jt.toJSON=jt.toObject=Ln.toObject,jt.inspect=jt.toSource=function(){return this.toString()};function rf(n,e,t){var r=Object.create(Object.getPrototypeOf(n));return r._values=e,r.__ownerID=t,r}function sf(n){return n.constructor.displayName||n.constructor.name||"Record"}function To(n){return yh(n._keys.map(function(e){return[e,n.get(e)]}))}function Vy(n,e){try{Object.defineProperty(n,e,{get:function(){return this.get(e)},set:function(t){Ba(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch{}}var Hy=(function(n){function e(t,r){if(!(this instanceof e))return new e(t,r);if(this._value=t,this.size=r===void 0?1/0:Math.max(0,r),this.size===0){if(of)return of;of=this}}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},e.prototype.get=function(r,i){return this.has(r)?this._value:i},e.prototype.includes=function(r){return Kt(this._value,r)},e.prototype.slice=function(r,i){var s=this.size;return Fa(r,i,s)?this:new e(this._value,za(i,s)-ho(r,s))},e.prototype.reverse=function(){return this},e.prototype.indexOf=function(r){return Kt(this._value,r)?0:-1},e.prototype.lastIndexOf=function(r){return Kt(this._value,r)?this.size:-1},e.prototype.__iterate=function(r,i){for(var s=this.size,o=0;o!==s&&r(this._value,i?s-++o:o++,this)!==!1;);return o},e.prototype.__iterator=function(r,i){var s=this,o=this.size,a=0;return new Tt(function(){return a===o?In():Yt(r,i?o-++a:a++,s._value)})},e.prototype.equals=function(r){return r instanceof e?Kt(this._value,r._value):Jh(this,r)},e})(wr),of;function At(n,e){return K0([],e||Gy,n,"",e&&e.length>2?[]:void 0,{"":n})}function K0(n,e,t,r,i,s){if(typeof t!="string"&&!Mr(t)&&(_h(t)||mh(t)||qh(t))){if(~n.indexOf(t))throw new TypeError("Cannot convert circular structure to Immutable");n.push(t),i&&r!==""&&i.push(r);var o=e.call(s,r,vn(t).map(function(a,l){return K0(n,e,a,l,i,t)}),i&&i.slice());return n.pop(),i&&i.pop(),o}return t}function Gy(n,e){return Bn(e)?e.toList():Bt(e)?e.toMap():e.toSet()}var Wy="5.1.3",jy=Mn;const Xy=Object.freeze(Object.defineProperty({__proto__:null,Collection:Mn,Iterable:jy,List:He,Map:Ie,OrderedMap:fi,OrderedSet:wo,PairSorting:ky,Range:z0,Record:gt,Repeat:Hy,Seq:vn,Set:Eo,Stack:cc,fromJS:At,get:Dh,getIn:ef,has:f0,hasIn:B0,hash:Zn,is:Kt,isAssociative:Zl,isCollection:Kn,isImmutable:Mr,isIndexed:Bn,isKeyed:Bt,isList:$h,isMap:tc,isOrdered:kr,isOrderedMap:Eh,isOrderedSet:Zh,isPlainObject:qh,isRecord:ns,isSeq:Jl,isSet:hc,isStack:lc,isValueObject:bh,merge:xy,mergeDeep:Sy,mergeDeepWith:Ey,mergeWith:yy,remove:d0,removeIn:_0,set:p0,setIn:g0,update:Fh,updateIn:Is,version:Wy},Symbol.toStringTag,{value:"Module"})),sn="MODE_IDLE",qs="MODE_2D_ZOOM_IN",Ds="MODE_2D_ZOOM_OUT",Ns="MODE_2D_PAN",Br="MODE_3D_VIEW",Ao="MODE_3D_FIRST_PERSON",Tr="MODE_WAITING_DRAWING_LINE",Us="MODE_WAITING_DRAWING_SURFACE",Vr="MODE_DRAGGING_LINE",Hr="MODE_DRAGGING_VERTEX",Gr="MODE_DRAGGING_ITEM",Wr="MODE_DRAGGING_HOLE",Jn="MODE_DRAWING_LINE",hr="MODE_DRAWING_HOLE",Ar="MODE_DRAWING_ITEM",di="MODE_DRAWING_SURFACE",Di="MODE_ROTATING_ITEM",af="MODE_UPLOADING_IMAGE",lf="MODE_FITTING_IMAGE",cf="MODE_VIEWING_CATALOG",Z0="MODE_CONFIGURING_PROJECT",uf=[sn,qs,Ds,Ns,Tr,Jn,hr,Ar,Vr,Hr,Gr,Wr,lf,af,Di],$y="mm",Cr="cm",Yy="m",Ky="in",J0="ft",Q0=[$y,Cr,Yy,Ky,J0,"mi"],pi=1e-6,Rr={DELETE:46,BACKSPACE:8,ESC:27,Z:90,ALT:18,C:67,V:86,CTRL:17,ENTER:13,TAB:9},Qn=(n,e=6)=>n&&e?parseFloat(parseFloat(n.toString()).toFixed(e)):0,Co=n=>{let e=n;return e<0&&(e=~e+1),e};function hf(n,e){return n.x===e.x?n.y-e.y:n.x-e.x}function pc(n,e){return hf(n,e)>0?e:n}function ff(n,e){return hf(n,e)>0?n:e}function rl(n){return n.sort(hf)}function Cn(n,e,t,r){let i=n-t,s=e-r;return Math.sqrt(i*i+s*s)}function mc(n,e){let{x:t,y:r}=n,{x:i,y:s}=e;return Cn(t,r,i,s)}function gc(n){return{a:0,b:1,c:-n}}function _c(n){return{a:1,b:0,c:-n}}function Zy(n,e,t,r,i){return Co(n*r+e*i+t)/Math.sqrt(n*n+e*e)}function Jy(n,e,t,r,i){let s=n*n+e*e;return{x:(e*(e*r-n*i)-n*t)/s,y:(n*-e*r+n*i-e*t)/s}}function il(n,e,t,r,i,s){let o=e*r-n*i;if(o===0)return;let a=(n*s-t*r)/o;return{x:(t*i-e*s)/o,y:a}}function Qy(n,e,t,r){let{x:i,y:s}=n,{x:o,y:a}=e,{x:l,y:c}=t,{x:h,y:f}=r,p=(f-c)*(o-i)-(h-l)*(a-s),d=(h-l)*(s-c)-(f-c)*(i-l),m=(o-i)*(s-c)-(a-s)*(i-l);if(Co(p)<=pi){if(Co(d)<=pi&&Co(m)<=pi){let _=(A,q)=>A.x===q.x?A.y-q.y:A.x-q.x,w=[n,e].sort(_),E=[t.toJS(),r.toJS()].sort(_),[S,b]=[w,E].sort((A,q)=>_(A[0],q[0]));return S[1].x===b[0].x?{type:b[0].y<=S[1].y?"colinear":"none"}:{type:b[0].x<=S[1].x?"colinear":"none"}}return{type:"parallel"}}let x=d/p,v=m/p;return x>=0-pi&&x<=1+pi&&v>=0-pi&&v<=1+pi?{type:"intersecting",point:{x:i+x*(o-i),y:s+x*(a-s)}}:{type:"none"}}function eg(n,e,t,r,i,s){let o=i-n,a=s-e,l=t-n,c=r-e,h=o*l+a*c,f=l*l+c*c,p=-1;f!=0&&(p=h/f);let d,m;p<0?(d=n,m=e):p>1?(d=t,m=r):(d=n+p*l,m=e+p*c);let x=i-d,v=s-m;return Math.sqrt(x*x+v*v)}function e3(n,e,t,r,i,s,o=pi){return eg(n,e,t,r,i,s)<=o}function t3(n,e,t,r,i,s){if(n===t)return{x:n,y:s};if(e===r)return{x:i,y:e};let o=(r-e)/(t-n),a=e-o*n,l=-1/o,h=(s-l*i-a)/(o-l),f=o*h+a;return{x:h,y:f}}function On(n,e,t,r,i,s){let o=Cn(n,e,t,r),l=Cn(n,e,i,s)/o;return n>t&&(l=n3(l,0,1,1,0)),l}function n3(n,e,t,r,i){return r+(i-r)*(n-e)/(t-e)}function r3(n,e,t,r){return-Math.atan2(e-r,t-n)*180/Math.PI}function df(n,e,t,r){return Math.atan2(r-e,t-n)}function i3(n,e,t,r){return Math.atan2(Math.abs(r-e),Math.abs(t-n))}function jr({x:n,y:e},{x:t,y:r}){return Co(n-t)<=pi&&Co(e-r)<=pi}function vc(n,e,t,r,i,s=6){let o=df(n,e,t,r);return{x:Qn(n+Math.cos(o)*i,s),y:Qn(e+Math.sin(o)*i,s)}}function s3(n,e,t){let r=n.length>>1,i,s,o=n[2*r-3]-t,a=n[2*r-2]-e,l=n[2*r-1]-t;if(a===0&&l===0)return!1;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-e,l=n[2*h+1]-t,a===0&&l===0)return!1;o!==l&&(s=l>o)}let c=0;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-e,l=n[2*h+1]-t,o<0&&l<0||o>0&&l>0||i<0&&a<0)continue;if(o===l&&Math.min(i,a)<0)return!0;if(o===l)continue;let f=i+(a-i)*-o/(l-o);if(f===0)return!1;f>0&&c++,o===0&&s&&l>o&&c--,o===0&&!s&&l<o&&c--,s=l>o}return(c&1)===1}function o3(n,e){let t=Math.cos(n);return t<e?0:t}function a3(n,e){let t=Math.sin(n);return t<e?0:t}function l3(n,e,t,r){return{x:(n+t)/2,y:(e+r)/2}}function c3(n){let e=n.reduce((t,r)=>({x:t.x+r.x,y:t.y+r.y}),{x:0,y:0});return{x:e.x/n.length,y:e.y/n.length}}function tg(n,e,t,r,i){let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=n-t,c=e-r;return{x:o*l-a*c+t,y:a*l+o*c+r}}const pf="SNAP_POINT",mf="SNAP_LINE",gf="SNAP_SEGMENT",_f="SNAP_GRID",ng="SNAP_GUIDE",u3=Ie({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class h3 extends gt({type:"point",x:-1,y:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:Cn(this.x,this.y,e,t)}}isNear(e,t,r){return~(this.x-e)+1<r&&~(this.y-t)+1<r}}class f3 extends gt({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{...Jy(this.a,this.b,this.c,e,t),distance:Zy(this.a,this.b,this.c,e,t)}}isNear(e,t,r){return!0}}class d3 extends gt({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{...t3(this.x1,this.y1,this.x2,this.y2,e,t),distance:eg(this.x1,this.y1,this.x2,this.y2,e,t)}}isNear(e,t,r){return!0}}class p3 extends gt({type:"grid",x:-1,y:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:Cn(this.x,this.y,e,t)}}isNear(e,t,r){return~(this.x-e)+1<r&&~(this.y-t)+1<r}}function mi(n,e,t,r){let i={point:r.get(pf),line:r.get(mf),"line-segment":r.get(gf),grid:r.get(_f)};return n.valueSeq().filter(s=>i[s.type]&&s.isNear(e,t,s.radius)).map(s=>({snap:s,point:s.nearestPoint(e,t)})).filter(({snap:{radius:s},point:{distance:o}})=>o<s).min(({snap:{priority:s},point:{distance:o}},{snap:{priority:a},point:{distance:l}})=>s===a?o<l?-1:1:s>a?-1:1)}function vf(n,e,t,r,i,s){return s=He([s]),n.push(new h3({x:e,y:t,radius:r,priority:i,related:s}))}function xc(n,e,t,r,i,s,o){return o=He([o]),n.withMutations(a=>{if(a.some(c=>c.type==="line"&&e===c.a&&t===c.b&&r===c.c))return a;a.valueSeq().filter(c=>c.type==="line").map(c=>il(c.a,c.b,c.c,e,t,r)).filter(c=>c!==void 0).forEach(({x:c,y:h})=>vf(a,c,h,20,40)),a.push(new f3({a:e,b:t,c:r,radius:i,priority:s,related:o}))})}function sl(n,e,t,r,i,s,o,a){return a=He([a]),n.push(new d3({x1:e,y1:t,x2:r,y2:i,radius:s,priority:o,related:a}))}function m3(n,e,t,r,i,s){return s=He([s]),n.push(new p3({x:e,y:t,radius:r,priority:i,related:s}))}let Ni=(n,e,t)=>n?Ie(n).map(r=>new e(r)).toMap():t||Ie();class xf extends gt({id:"",type:"",properties:Ie()},"Grid"){constructor(e={}){super({...e,properties:At(e.properties||{})})}}const g3=Ie({h1:new xf({id:"h1",type:"horizontal-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}}),v1:new xf({id:"v1",type:"vertical-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}})});class rg extends gt({vertices:He(),lines:He(),holes:He(),areas:He(),items:He()},"ElementsSet"){constructor(e={}){super({vertices:He(e.vertices||[]),lines:He(e.lines||[]),holes:He(e.holes||[]),areas:He(e.areas||[]),items:He(e.items||[])})}}const Ro={id:"",type:"",prototype:"",name:"",misc:Ie(),selected:!1,properties:Ie(),visible:!0};let ig=class extends gt({...Ro,x:-1,y:-1,prototype:"vertices",lines:He(),areas:He()},"Vertex"){constructor(e={}){super({...e,lines:He(e.lines||[]),areas:He(e.areas||[])})}},sg=class extends gt({...Ro,prototype:"lines",vertices:He(),holes:He()},"Line"){constructor(e={}){super({...e,properties:At(e.properties||{}),vertices:He(e.vertices||[]),holes:He(e.holes||[])})}},og=class extends gt({...Ro,prototype:"holes",offset:-1,line:""},"Hole"){constructor(e={}){super({...e,properties:At(e.properties||{})})}},ag=class extends gt({...Ro,prototype:"areas",vertices:He(),holes:He()},"Area"){constructor(e={}){super({...e,properties:At(e.properties||{}),vertices:He(e.vertices||[])})}},lg=class extends gt({...Ro,prototype:"items",x:0,y:0,rotation:0,altitude:0},"Item"){constructor(e={}){super({...e,properties:At(e.properties||{})})}},yf=class extends gt({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:Ie(),lines:Ie(),holes:Ie(),areas:Ie(),items:Ie(),selected:new rg},"Layer"){constructor(e={}){super({...e,vertices:Ni(e.vertices,ig),lines:Ni(e.lines,sg),holes:Ni(e.holes,og),areas:Ni(e.areas,ag),items:Ni(e.items,lg),selected:new rg(e.selected)})}},Sf=class extends gt({...Ro,prototype:"groups",x:0,y:0,rotation:0,elements:Ie()},"Group"){constructor(e={}){super({...e,properties:At(e.properties||{}),elements:At(e.elements||{})})}};const _3=Ie({"layer-1":new yf({id:"layer-1",name:"default"})});let yc=class extends gt({unit:J0,layers:Ie(),grids:Ie(),selectedLayer:null,groups:Ie(),width:3e3,height:2e3,meta:Ie(),guides:Ie()},"Scene"){constructor(e={}){let t=Ni(e.layers,yf,_3);super({...e,grids:Ni(e.grids,xf,g3),layers:t,selectedLayer:t.first().id,groups:Ni(e.groups||{},Sf),meta:e.meta?At(e.meta):Ie(),guides:e.guides?At(e.guides):Ie({horizontal:Ie(),vertical:Ie(),circular:Ie()})})}};class v3 extends gt({name:"",prototype:"",info:Ie(),properties:Ie()},"CatalogElement"){constructor(e={}){super({...e,info:At(e.info),properties:At(e.properties)})}}let Ef=class extends gt({ready:!1,page:"root",path:He(),elements:Ie()},"Catalog"){constructor(e={}){let t=Ni(e.elements,v3);super({elements:t,ready:!t.isEmpty()})}factoryElement(e,t,r){if(!this.elements.has(e)){let o=this.elements.map(a=>a.name).toArray();throw new Error(`Element ${e} does not exist in catalog ${o}`)}const i=this.elements.get(e),s=i.properties.map((o,a)=>r&&r.has(a)?r.get(a):o.get("defaultValue"));switch(i.prototype){case"lines":return new sg(t).merge({properties:s});case"holes":return new og(t).merge({properties:s});case"areas":return new ag(t).merge({properties:s});case"items":return new lg(t).merge({properties:s});default:throw new Error("prototype not valid")}}};class cg extends gt({list:He(),first:null,last:null,redoList:He()},"HistoryStructure"){constructor(e={}){super({list:At(e.list||[]),first:new yc(e.scene),last:new yc(e.last||e.scene)})}}let Sc=class extends gt({mode:sn,scene:new yc,sceneHistory:new cg,catalog:new Ef,viewer2D:Ie(),mouse:Ie({x:0,y:0}),zoom:0,snapMask:u3,snapElements:He(),activeSnapElement:null,drawingSupport:Ie(),draggingSupport:Ie(),rotatingSupport:Ie(),errors:He(),warnings:He(),clipboardProperties:Ie(),selectedElementsHistory:He(),misc:Ie(),alterate:!1},"State"){constructor(e={}){super({...e,scene:new yc(e.scene),sceneHistory:new cg(e),catalog:new Ef(e.catalog||{}),viewer2D:Ie(e.viewer2D||{}),drawingSupport:Ie(e.drawingSupport||{}),draggingSupport:Ie(e.draggingSupport||{}),rotatingSupport:Ie(e.rotatingSupport||{}),misc:e.misc?At(e.misc):Ie()})}};function Ec(n){let e=[];for(let t=0;t<n;++t)e.push([]);return e}class ug{constructor(e,t){ht(this,"u");ht(this,"v");this.u=e,this.v=t}}class x3{constructor(e){ht(this,"count");ht(this,"subgraphs");ht(this,"time");ht(this,"V");ht(this,"E");ht(this,"adj");ht(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=e,this.E=0,this.adj=[],this.adj=Ec(e)}addEdge(e,t){this.adj[e].push(t),this.E++}_BCCUtil(e,t,r,i,s){t[e]=r[e]=++this.time,this.children=0,this.adj[e].forEach(o=>{if(t[o]==-1){if(this.children++,s[o]=e,i.push(new ug(e,o)),this._BCCUtil(o,t,r,i,s),r[e]>r[o]&&(r[e]=r[o]),t[e]==1&&this.children>1||t[e]>1&&r[o]>=t[e]){let a=[];for(;i[i.length-1].u!=e||i[i.length-1].v!=o;)a.push(i[i.length-1]),i.splice(i.length-1,1);a.push(i[i.length-1]),this.subgraphs.push(a),a=[],i.splice(i.length-1,1),this.count++}}else o!=s[e]&&t[o]<r[e]&&(r[e]>t[o]&&(r[e]=t[o]),i.push(new ug(e,o)))})}BCC(){let e=this.V,t=Ec(e),r=Ec(e),i=Ec(e),s=[];for(let o=0;o<e;o++)t[o]=-1,r[o]=-1,i[o]=-1;for(let o=0;o<e;o++){t[o]==-1&&this._BCCUtil(o,t,r,s,i);let a=0,l=[];for(;s.length>0;)a=1,l.push(s[s.length-1]),s.splice(s.length-1,1);a==1&&(this.subgraphs.push(l),l=[],this.count++)}}}const y3=(n,e)=>{let t=[];return n.forEach(r=>{t.push([]);let i=S3(r);i.forEach(s=>{e.adj[s].forEach(a=>{s<=a&&i.has(a)&&t[t.length-1].push([s,a])})})}),t},S3=n=>{let e=new Set;return n.forEach(t=>{e.add(t.u),e.add(t.v)}),e};function E3(n,e){return[n[0]-e[0],n[1]-e[1]]}function hg(n,e){return(n%e+e)%e}function b3(n){return n.map(function(t){return{ev:t,color:0,direction:-1}})}function M3(n,e){let t=E3(e,n);return Math.atan2(t[1],t[0])}function w3(n,e){return n.map(function(t,r){let i=[];return e.forEach(function(s,o){let a,l;s[0]===r&&(a=s[1],l=1),s[1]===r&&(a=s[0],l=0),a!==void 0&&i.push({index:o,endpoint:a,angle:M3(t,n[a]),edge:s,position:l})}),i.sort(function(s,o){return o.angle-s.angle}),i})}function fg(n,e){let t,r;for(t=0;t<e.length;t+=1)if(e[t].color<2)return r=-1*e[t].direction,pg(e,t,r),{edge:t,direction:r,position:r===-1?0:1}}function dg(n,e,t,r){let i=n[r[e][t]],s=i.length,o,a,l;for(l=0;l<s;l+=1)if(o=i[l],o.index===e)return a=i[hg(l+1,i.length)],{edge:a.index,vertex:a.endpoint,position:a.position,direction:a.position?1:-1}}function pg(n,e,t){n[e].color+=1,n[e].direction=t}function T3(n,e){let t=b3(e),r=w3(n,e),i=[],s=[],o=[],a,l,c,h,f=fg(r,t);for(;f!==void 0;){for(a=[e[f.edge][hg(f.position+1,2)],e[f.edge][f.position]],l=[f.edge],c=[f.direction],h=dg(r,f.edge,f.position,e);h.edge!==f.edge;)a.push(h.vertex),l.push(h.edge),c.push(h.direction),pg(t,h.edge,h.direction),h=dg(r,h.edge,h.position,e);s.push(l),i.push(a),o.push(c),f=fg(r,t)}return{v_cycles:i,e_cycles:s,dir_e_cycles:o,ev_mapping:t}}function A3(n,e){let t=[],r,i,s;for(s=0;s<e.length;s+=1)r=e[s],i=n[s],(r.length<3||i[0]!==i[i.length-1])&&t.push(s);return t}function C3(n,e){let t=T3(n,e),r=t.v_cycles,i=t.e_cycles;A3(r,i).forEach(p=>{r.splice(p,1),i.splice(p,1)});let o=t.dir_e_cycles,l=t.e_cycles.map((p,d)=>p.map(function(m,x){let v,_;return o[d][x]>0?(v=e[m][0],_=e[m][1]):(v=e[m][1],_=e[m][0]),(n[_][0]-n[v][0])*(n[_][1]+n[v][1])})).map(p=>p.reduce((d,m)=>d+m)),c=l.filter(p=>p>0).length,h=l.length-c,f=c>=h?1:-1;return{v_cycles:t.v_cycles.filter((p,d)=>f*l[d]>0),e_cycles:t.e_cycles.filter((p,d)=>f*l[d]>0),ev_mapping:t.ev_mapping}}function R3(n,e){let t=He();const r=new x3(n.length);e.forEach(([l,c])=>{r.addEdge(l,c),r.addEdge(c,l)}),r.BCC();const i=r.subgraphs.filter(l=>l.length>=3),s=y3(i,r),o=[];return s.forEach(l=>{l.forEach(c=>o.push(c))}),C3(n,o).v_cycles.forEach(l=>{l.shift(),t=t.push(l)}),t}function P3(n){let e=0,t=0,r=n.size;for(e=0;e<r;e++){let{x:i,y:s}=n.get(e)||{x:0,y:0},{x:o,y:a}=n.get((e+1)%r)||{x:0,y:0};t+=(o-i)*(a+s)}return t>0}function bf(n,e=He(),t=Ie()){let{width:r,height:i}=n,s,o,a;return e.withMutations(l=>{if(n.layers.forEach(c=>{let{lines:h,vertices:f}=c;f.forEach(({id:p,x:d,y:m})=>{t.get(pf)&&vf(l,d,m,10,10,p),t.get(mf)&&({a:s,b:o,c:a}=gc(m),xc(l,s,o,a,10,1,p),{a:s,b:o,c:a}=_c(d),xc(l,s,o,a,10,1,p))}),t.get(gf)&&h.forEach(({id:p,vertices:[d,m]})=>{let{x,y:v}=f.get(d),{x:_,y:w}=f.get(m);sl(l,x,v,_,w,20,1,p)})}),t.get(_f)){let c=5,h=100/c,f=r/h,p=i/h;for(let d=0;d<f;d++){let m=d*h;for(let x=0;x<p;x++){let v=x*h,_=!(d%c),w=!(x%c);m3(l,m,v,10,_&&w?15:10,null)}}}if(t.get(ng)){let c=n.getIn(["guides","horizontal"]),h=n.getIn(["guides","vertical"]),f=c.valueSeq(),p=h.valueSeq();f.forEach(d=>{p.forEach(m=>{vf(l,m,d,10,10)})}),f.forEach(d=>sl(l,0,d,r,d,20,1)),p.forEach(d=>sl(l,d,0,d,i,20,1))}})}var bc={exports:{}},I3=bc.exports,mg;function Mf(){return mg||(mg=1,(function(n,e){(function(t,r){n.exports=r()})(I3,function(){var t=Array.prototype.slice;function r(u,g){g&&(u.prototype=Object.create(g.prototype)),u.prototype.constructor=u}function i(u){return l(u)?u:z(u)}r(s,i);function s(u){return c(u)?u:rt(u)}r(o,i);function o(u){return h(u)?u:Le(u)}r(a,i);function a(u){return l(u)&&!f(u)?u:at(u)}function l(u){return!!(u&&u[d])}function c(u){return!!(u&&u[m])}function h(u){return!!(u&&u[x])}function f(u){return c(u)||h(u)}function p(u){return!!(u&&u[v])}i.isIterable=l,i.isKeyed=c,i.isIndexed=h,i.isAssociative=f,i.isOrdered=p,i.Keyed=s,i.Indexed=o,i.Set=a;var d="@@__IMMUTABLE_ITERABLE__@@",m="@@__IMMUTABLE_KEYED__@@",x="@@__IMMUTABLE_INDEXED__@@",v="@@__IMMUTABLE_ORDERED__@@",_="delete",w=5,E=1<<w,S=E-1,b={},A={value:!1},q={value:!1};function O(u){return u.value=!1,u}function T(u){u&&(u.value=!0)}function I(){}function N(u,g){g=g||0;for(var y=Math.max(0,u.length-g),M=new Array(y),C=0;C<y;C++)M[C]=u[C+g];return M}function H(u){return u.size===void 0&&(u.size=u.__iterate(Q)),u.size}function W(u,g){if(typeof g!="number"){var y=g>>>0;if(""+y!==g||y===4294967295)return NaN;g=y}return g<0?H(u)+g:g}function Q(){return!0}function ae(u,g,y){return(u===0||y!==void 0&&u<=-y)&&(g===void 0||y!==void 0&&g>=y)}function J(u,g){return B(u,g,0)}function se(u,g){return B(u,g,g)}function B(u,g,y){return u===void 0?y:u<0?Math.max(0,g+u):g===void 0?u:Math.min(g,u)}var ge=0,F=1,X=2,de=typeof Symbol=="function"&&Symbol.iterator,ye="@@iterator",Ee=de||ye;function V(u){this.next=u}V.prototype.toString=function(){return"[Iterator]"},V.KEYS=ge,V.VALUES=F,V.ENTRIES=X,V.prototype.inspect=V.prototype.toSource=function(){return this.toString()},V.prototype[Ee]=function(){return this};function re(u,g,y,M){var C=u===0?g:u===1?y:[g,y];return M?M.value=C:M={value:C,done:!1},M}function Z(){return{value:void 0,done:!0}}function he(u){return!!Pe(u)}function xe(u){return u&&typeof u.next=="function"}function ee(u){var g=Pe(u);return g&&g.call(u)}function Pe(u){var g=u&&(de&&u[de]||u[ye]);if(typeof g=="function")return g}function le(u){return u&&typeof u.length=="number"}r(z,i);function z(u){return u==null?P():l(u)?u.toSeq():Me(u)}z.of=function(){return z(arguments)},z.prototype.toSeq=function(){return this},z.prototype.toString=function(){return this.__toString("Seq {","}")},z.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},z.prototype.__iterate=function(u,g){return De(this,u,g,!0)},z.prototype.__iterator=function(u,g){return Ae(this,u,g,!0)},r(rt,z);function rt(u){return u==null?P().toKeyedSeq():l(u)?c(u)?u.toSeq():u.fromEntrySeq():te(u)}rt.prototype.toKeyedSeq=function(){return this},r(Le,z);function Le(u){return u==null?P():l(u)?c(u)?u.entrySeq():u.toIndexedSeq():pe(u)}Le.of=function(){return Le(arguments)},Le.prototype.toIndexedSeq=function(){return this},Le.prototype.toString=function(){return this.__toString("Seq [","]")},Le.prototype.__iterate=function(u,g){return De(this,u,g,!1)},Le.prototype.__iterator=function(u,g){return Ae(this,u,g,!1)},r(at,z);function at(u){return(u==null?P():l(u)?c(u)?u.entrySeq():u:pe(u)).toSetSeq()}at.of=function(){return at(arguments)},at.prototype.toSetSeq=function(){return this},z.isSeq=$e,z.Keyed=rt,z.Set=at,z.Indexed=Le;var ze="@@__IMMUTABLE_SEQ__@@";z.prototype[ze]=!0,r(Xe,Le);function Xe(u){this._array=u,this.size=u.length}Xe.prototype.get=function(u,g){return this.has(u)?this._array[W(this,u)]:g},Xe.prototype.__iterate=function(u,g){for(var y=this._array,M=y.length-1,C=0;C<=M;C++)if(u(y[g?M-C:C],C,this)===!1)return C+1;return C},Xe.prototype.__iterator=function(u,g){var y=this._array,M=y.length-1,C=0;return new V(function(){return C>M?Z():re(u,C,y[g?M-C++:C++])})},r(be,rt);function be(u){var g=Object.keys(u);this._object=u,this._keys=g,this.size=g.length}be.prototype.get=function(u,g){return g!==void 0&&!this.has(u)?g:this._object[u]},be.prototype.has=function(u){return this._object.hasOwnProperty(u)},be.prototype.__iterate=function(u,g){for(var y=this._object,M=this._keys,C=M.length-1,D=0;D<=C;D++){var k=M[g?C-D:D];if(u(y[k],k,this)===!1)return D+1}return D},be.prototype.__iterator=function(u,g){var y=this._object,M=this._keys,C=M.length-1,D=0;return new V(function(){var k=M[g?C-D:D];return D++>C?Z():re(u,k,y[k])})},be.prototype[v]=!0,r(tt,Le);function tt(u){this._iterable=u,this.size=u.length||u.size}tt.prototype.__iterateUncached=function(u,g){if(g)return this.cacheResult().__iterate(u,g);var y=this._iterable,M=ee(y),C=0;if(xe(M))for(var D;!(D=M.next()).done&&u(D.value,C++,this)!==!1;);return C},tt.prototype.__iteratorUncached=function(u,g){if(g)return this.cacheResult().__iterator(u,g);var y=this._iterable,M=ee(y);if(!xe(M))return new V(Z);var C=0;return new V(function(){var D=M.next();return D.done?D:re(u,C++,D.value)})},r(lt,Le);function lt(u){this._iterator=u,this._iteratorCache=[]}lt.prototype.__iterateUncached=function(u,g){if(g)return this.cacheResult().__iterate(u,g);for(var y=this._iterator,M=this._iteratorCache,C=0;C<M.length;)if(u(M[C],C++,this)===!1)return C;for(var D;!(D=y.next()).done;){var k=D.value;if(M[C]=k,u(k,C++,this)===!1)break}return C},lt.prototype.__iteratorUncached=function(u,g){if(g)return this.cacheResult().__iterator(u,g);var y=this._iterator,M=this._iteratorCache,C=0;return new V(function(){if(C>=M.length){var D=y.next();if(D.done)return D;M[C]=D.value}return re(u,C,M[C++])})};function $e(u){return!!(u&&u[ze])}var U;function P(){return U||(U=new Xe([]))}function te(u){var g=Array.isArray(u)?new Xe(u).fromEntrySeq():xe(u)?new lt(u).fromEntrySeq():he(u)?new tt(u).fromEntrySeq():typeof u=="object"?new be(u):void 0;if(!g)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+u);return g}function pe(u){var g=fe(u);if(!g)throw new TypeError("Expected Array or iterable object of values: "+u);return g}function Me(u){var g=fe(u)||typeof u=="object"&&new be(u);if(!g)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+u);return g}function fe(u){return le(u)?new Xe(u):xe(u)?new lt(u):he(u)?new tt(u):void 0}function De(u,g,y,M){var C=u._cache;if(C){for(var D=C.length-1,k=0;k<=D;k++){var $=C[y?D-k:k];if(g($[1],M?$[0]:k,u)===!1)return k+1}return k}return u.__iterateUncached(g,y)}function Ae(u,g,y,M){var C=u._cache;if(C){var D=C.length-1,k=0;return new V(function(){var $=C[y?D-k:k];return k++>D?Z():re(g,M?$[0]:k-1,$[1])})}return u.__iteratorUncached(g,y)}function Ge(u,g){return g?We(g,u,"",{"":u}):Ce(u)}function We(u,g,y,M){return Array.isArray(g)?u.call(M,y,Le(g).map(function(C,D){return We(u,C,D,g)})):qe(g)?u.call(M,y,rt(g).map(function(C,D){return We(u,C,D,g)})):g}function Ce(u){return Array.isArray(u)?Le(u).map(Ce).toList():qe(u)?rt(u).map(Ce).toMap():u}function qe(u){return u&&(u.constructor===Object||u.constructor===void 0)}function Be(u,g){if(u===g||u!==u&&g!==g)return!0;if(!u||!g)return!1;if(typeof u.valueOf=="function"&&typeof g.valueOf=="function"){if(u=u.valueOf(),g=g.valueOf(),u===g||u!==u&&g!==g)return!0;if(!u||!g)return!1}return!!(typeof u.equals=="function"&&typeof g.equals=="function"&&u.equals(g))}function Ye(u,g){if(u===g)return!0;if(!l(g)||u.size!==void 0&&g.size!==void 0&&u.size!==g.size||u.__hash!==void 0&&g.__hash!==void 0&&u.__hash!==g.__hash||c(u)!==c(g)||h(u)!==h(g)||p(u)!==p(g))return!1;if(u.size===0&&g.size===0)return!0;var y=!f(u);if(p(u)){var M=u.entries();return g.every(function(ce,ue){var _e=M.next().value;return _e&&Be(_e[1],ce)&&(y||Be(_e[0],ue))})&&M.next().done}var C=!1;if(u.size===void 0)if(g.size===void 0)typeof u.cacheResult=="function"&&u.cacheResult();else{C=!0;var D=u;u=g,g=D}var k=!0,$=g.__iterate(function(ce,ue){if(y?!u.has(ce):C?!Be(ce,u.get(ue,b)):!Be(u.get(ue,b),ce))return k=!1,!1});return k&&u.size===$}r(Re,Le);function Re(u,g){if(!(this instanceof Re))return new Re(u,g);if(this._value=u,this.size=g===void 0?1/0:Math.max(0,g),this.size===0){if(ft)return ft;ft=this}}Re.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Re.prototype.get=function(u,g){return this.has(u)?this._value:g},Re.prototype.includes=function(u){return Be(this._value,u)},Re.prototype.slice=function(u,g){var y=this.size;return ae(u,g,y)?this:new Re(this._value,se(g,y)-J(u,y))},Re.prototype.reverse=function(){return this},Re.prototype.indexOf=function(u){return Be(this._value,u)?0:-1},Re.prototype.lastIndexOf=function(u){return Be(this._value,u)?this.size:-1},Re.prototype.__iterate=function(u,g){for(var y=0;y<this.size;y++)if(u(this._value,y,this)===!1)return y+1;return y},Re.prototype.__iterator=function(u,g){var y=this,M=0;return new V(function(){return M<y.size?re(u,M++,y._value):Z()})},Re.prototype.equals=function(u){return u instanceof Re?Be(this._value,u._value):Ye(u)};var ft;function G(u,g){if(!u)throw new Error(g)}r(Se,Le);function Se(u,g,y){if(!(this instanceof Se))return new Se(u,g,y);if(G(y!==0,"Cannot step a Range by 0"),u=u||0,g===void 0&&(g=1/0),y=y===void 0?1:Math.abs(y),g<u&&(y=-y),this._start=u,this._end=g,this._step=y,this.size=Math.max(0,Math.ceil((g-u)/y-1)+1),this.size===0){if(Oe)return Oe;Oe=this}}Se.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},Se.prototype.get=function(u,g){return this.has(u)?this._start+W(this,u)*this._step:g},Se.prototype.includes=function(u){var g=(u-this._start)/this._step;return g>=0&&g<this.size&&g===Math.floor(g)},Se.prototype.slice=function(u,g){return ae(u,g,this.size)?this:(u=J(u,this.size),g=se(g,this.size),g<=u?new Se(0,0):new Se(this.get(u,this._end),this.get(g,this._end),this._step))},Se.prototype.indexOf=function(u){var g=u-this._start;if(g%this._step===0){var y=g/this._step;if(y>=0&&y<this.size)return y}return-1},Se.prototype.lastIndexOf=function(u){return this.indexOf(u)},Se.prototype.__iterate=function(u,g){for(var y=this.size-1,M=this._step,C=g?this._start+y*M:this._start,D=0;D<=y;D++){if(u(C,D,this)===!1)return D+1;C+=g?-M:M}return D},Se.prototype.__iterator=function(u,g){var y=this.size-1,M=this._step,C=g?this._start+y*M:this._start,D=0;return new V(function(){var k=C;return C+=g?-M:M,D>y?Z():re(u,D++,k)})},Se.prototype.equals=function(u){return u instanceof Se?this._start===u._start&&this._end===u._end&&this._step===u._step:Ye(this,u)};var Oe;r(ke,i);function ke(){throw TypeError("Abstract")}r(Te,ke);function Te(){}r(me,ke);function me(){}r(Ke,ke);function Ke(){}ke.Keyed=Te,ke.Indexed=me,ke.Set=Ke;var ut=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(g,y){g=g|0,y=y|0;var M=g&65535,C=y&65535;return M*C+((g>>>16)*C+M*(y>>>16)<<16>>>0)|0};function Ot(u){return u>>>1&1073741824|u&3221225471}function dt(u){if(u===!1||u===null||u===void 0||typeof u.valueOf=="function"&&(u=u.valueOf(),u===!1||u===null||u===void 0))return 0;if(u===!0)return 1;var g=typeof u;if(g==="number"){if(u!==u||u===1/0)return 0;var y=u|0;for(y!==u&&(y^=u*4294967295);u>4294967295;)u/=4294967295,y^=u;return Ot(y)}if(g==="string")return u.length>eh?ai(u):sr(u);if(typeof u.hashCode=="function")return u.hashCode();if(g==="object")return Ju(u);if(typeof u.toString=="function")return sr(u.toString());throw new Error("Value type "+g+" cannot be hashed.")}function ai(u){var g=Bl[u];return g===void 0&&(g=sr(u),kl===th&&(kl=0,Bl={}),kl++,Bl[u]=g),g}function sr(u){for(var g=0,y=0;y<u.length;y++)g=31*g+u.charCodeAt(y)|0;return Ot(g)}function Ju(u){var g;if(Ta&&(g=ws.get(u),g!==void 0)||(g=u[Ur],g!==void 0)||!wa&&(g=u.propertyIsEnumerable&&u.propertyIsEnumerable[Ur],g!==void 0||(g=Qu(u),g!==void 0)))return g;if(g=++Aa,Aa&1073741824&&(Aa=0),Ta)ws.set(u,g);else{if(Ri!==void 0&&Ri(u)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(wa)Object.defineProperty(u,Ur,{enumerable:!1,configurable:!1,writable:!1,value:g});else if(u.propertyIsEnumerable!==void 0&&u.propertyIsEnumerable===u.constructor.prototype.propertyIsEnumerable)u.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},u.propertyIsEnumerable[Ur]=g;else if(u.nodeType!==void 0)u[Ur]=g;else throw new Error("Unable to set a non-enumerable property on object.")}return g}var Ri=Object.isExtensible,wa=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function Qu(u){if(u&&u.nodeType>0)switch(u.nodeType){case 1:return u.uniqueID;case 9:return u.documentElement&&u.documentElement.uniqueID}}var Ta=typeof WeakMap=="function",ws;Ta&&(ws=new WeakMap);var Aa=0,Ur="__immutablehash__";typeof Symbol=="function"&&(Ur=Symbol(Ur));var eh=16,th=255,kl=0,Bl={};function jn(u){G(u!==1/0,"Cannot perform this action with an infinite size.")}r(Mt,Te);function Mt(u){return u==null?Je():Vl(u)&&!p(u)?u:Je().withMutations(function(g){var y=s(u);jn(y.size),y.forEach(function(M,C){return g.set(C,M)})})}Mt.of=function(){var u=t.call(arguments,0);return Je().withMutations(function(g){for(var y=0;y<u.length;y+=2){if(y+1>=u.length)throw new Error("Missing value for key: "+u[y]);g.set(u[y],u[y+1])}})},Mt.prototype.toString=function(){return this.__toString("Map {","}")},Mt.prototype.get=function(u,g){return this._root?this._root.get(0,void 0,u,g):g},Mt.prototype.set=function(u,g){return yt(this,u,g)},Mt.prototype.setIn=function(u,g){return this.updateIn(u,b,function(){return g})},Mt.prototype.remove=function(u){return yt(this,u,b)},Mt.prototype.deleteIn=function(u){return this.updateIn(u,function(){return b})},Mt.prototype.update=function(u,g,y){return arguments.length===1?u(this):this.updateIn([u],g,y)},Mt.prototype.updateIn=function(u,g,y){y||(y=g,g=void 0);var M=Ts(this,A2(u),g,y);return M===b?void 0:M},Mt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},Mt.prototype.merge=function(){return bt(this,void 0,arguments)},Mt.prototype.mergeWith=function(u){var g=t.call(arguments,1);return bt(this,u,g)},Mt.prototype.mergeIn=function(u){var g=t.call(arguments,1);return this.updateIn(u,Je(),function(y){return typeof y.merge=="function"?y.merge.apply(y,g):g[g.length-1]})},Mt.prototype.mergeDeep=function(){return bt(this,Un,arguments)},Mt.prototype.mergeDeepWith=function(u){var g=t.call(arguments,1);return bt(this,Qi(u),g)},Mt.prototype.mergeDeepIn=function(u){var g=t.call(arguments,1);return this.updateIn(u,Je(),function(y){return typeof y.mergeDeep=="function"?y.mergeDeep.apply(y,g):g[g.length-1]})},Mt.prototype.sort=function(u){return hn(La(this,u))},Mt.prototype.sortBy=function(u,g){return hn(La(this,g,u))},Mt.prototype.withMutations=function(u){var g=this.asMutable();return u(g),g.wasAltered()?g.__ensureOwner(this.__ownerID):this},Mt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new I)},Mt.prototype.asImmutable=function(){return this.__ensureOwner()},Mt.prototype.wasAltered=function(){return this.__altered},Mt.prototype.__iterator=function(u,g){return new Ue(this,u,g)},Mt.prototype.__iterate=function(u,g){var y=this,M=0;return this._root&&this._root.iterate(function(C){return M++,u(C[1],C[0],y)},g),M},Mt.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?st(this.size,this._root,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)};function Vl(u){return!!(u&&u[nh])}Mt.isMap=Vl;var nh="@@__IMMUTABLE_MAP__@@",L=Mt.prototype;L[nh]=!0,L[_]=L.remove,L.removeIn=L.deleteIn;function Y(u,g){this.ownerID=u,this.entries=g}Y.prototype.get=function(u,g,y,M){for(var C=this.entries,D=0,k=C.length;D<k;D++)if(Be(y,C[D][0]))return C[D][1];return M},Y.prototype.update=function(u,g,y,M,C,D,k){for(var $=C===b,ce=this.entries,ue=0,_e=ce.length;ue<_e&&!Be(M,ce[ue][0]);ue++);var Ve=ue<_e;if(Ve?ce[ue][1]===C:$)return this;if(T(k),($||!Ve)&&T(D),!($&&ce.length===1)){if(!Ve&&!$&&ce.length>=zn)return Ut(u,ce,M,C);var nt=u&&u===this.ownerID,pt=nt?ce:N(ce);return Ve?$?ue===_e-1?pt.pop():pt[ue]=pt.pop():pt[ue]=[M,C]:pt.push([M,C]),nt?(this.entries=pt,this):new Y(u,pt)}};function ie(u,g,y){this.ownerID=u,this.bitmap=g,this.nodes=y}ie.prototype.get=function(u,g,y,M){g===void 0&&(g=dt(y));var C=1<<((u===0?g:g>>>u)&S),D=this.bitmap;return(D&C)===0?M:this.nodes[$t(D&C-1)].get(u+w,g,y,M)},ie.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=(g===0?y:y>>>g)&S,ce=1<<$,ue=this.bitmap,_e=(ue&ce)!==0;if(!_e&&C===b)return this;var Ve=$t(ue&ce-1),nt=this.nodes,pt=_e?nt[Ve]:void 0,St=Rt(pt,u,g+w,y,M,C,D,k);if(St===pt)return this;if(!_e&&St&&nt.length>=Hl)return en(u,nt,ue,$,St);if(_e&&!St&&nt.length===2&&Qt(nt[Ve^1]))return nt[Ve^1];if(_e&&St&&nt.length===1&&Qt(St))return St;var rn=u&&u===this.ownerID,li=_e?St?ue:ue^ce:ue|ce,Oi=_e?St?Xn(nt,Ve,St,rn):Rn(nt,Ve,rn):or(nt,Ve,St,rn);return rn?(this.bitmap=li,this.nodes=Oi,this):new ie(u,li,Oi)};function oe(u,g,y){this.ownerID=u,this.count=g,this.nodes=y}oe.prototype.get=function(u,g,y,M){g===void 0&&(g=dt(y));var C=(u===0?g:g>>>u)&S,D=this.nodes[C];return D?D.get(u+w,g,y,M):M},oe.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=(g===0?y:y>>>g)&S,ce=C===b,ue=this.nodes,_e=ue[$];if(ce&&!_e)return this;var Ve=Rt(_e,u,g+w,y,M,C,D,k);if(Ve===_e)return this;var nt=this.count;if(!_e)nt++;else if(!Ve&&(nt--,nt<es))return ot(u,ue,nt,$);var pt=u&&u===this.ownerID,St=Xn(ue,$,Ve,pt);return pt?(this.count=nt,this.nodes=St,this):new oe(u,nt,St)};function K(u,g,y){this.ownerID=u,this.keyHash=g,this.entries=y}K.prototype.get=function(u,g,y,M){for(var C=this.entries,D=0,k=C.length;D<k;D++)if(Be(y,C[D][0]))return C[D][1];return M},K.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=C===b;if(y!==this.keyHash)return $?this:(T(k),T(D),Nt(this,u,g,y,[M,C]));for(var ce=this.entries,ue=0,_e=ce.length;ue<_e&&!Be(M,ce[ue][0]);ue++);var Ve=ue<_e;if(Ve?ce[ue][1]===C:$)return this;if(T(k),($||!Ve)&&T(D),$&&_e===2)return new we(u,this.keyHash,ce[ue^1]);var nt=u&&u===this.ownerID,pt=nt?ce:N(ce);return Ve?$?ue===_e-1?pt.pop():pt[ue]=pt.pop():pt[ue]=[M,C]:pt.push([M,C]),nt?(this.entries=pt,this):new K(u,this.keyHash,pt)};function we(u,g,y){this.ownerID=u,this.keyHash=g,this.entry=y}we.prototype.get=function(u,g,y,M){return Be(y,this.entry[0])?this.entry[1]:M},we.prototype.update=function(u,g,y,M,C,D,k){var $=C===b,ce=Be(M,this.entry[0]);if(ce?C===this.entry[1]:$)return this;if(T(k),$){T(D);return}return ce?u&&u===this.ownerID?(this.entry[1]=C,this):new we(u,this.keyHash,[M,C]):(T(D),Nt(this,u,g,dt(M),[M,C]))},Y.prototype.iterate=K.prototype.iterate=function(u,g){for(var y=this.entries,M=0,C=y.length-1;M<=C;M++)if(u(y[g?C-M:M])===!1)return!1},ie.prototype.iterate=oe.prototype.iterate=function(u,g){for(var y=this.nodes,M=0,C=y.length-1;M<=C;M++){var D=y[g?C-M:M];if(D&&D.iterate(u,g)===!1)return!1}},we.prototype.iterate=function(u,g){return u(this.entry)},r(Ue,V);function Ue(u,g,y){this._type=g,this._reverse=y,this._stack=u._root&&je(u._root)}Ue.prototype.next=function(){for(var u=this._type,g=this._stack;g;){var y=g.node,M=g.index++,C;if(y.entry){if(M===0)return Ze(u,y.entry)}else if(y.entries){if(C=y.entries.length-1,M<=C)return Ze(u,y.entries[this._reverse?C-M:M])}else if(C=y.nodes.length-1,M<=C){var D=y.nodes[this._reverse?C-M:M];if(D){if(D.entry)return Ze(u,D.entry);g=this._stack=je(D,g)}continue}g=this._stack=this._stack.__prev}return Z()};function Ze(u,g){return re(u,g[0],g[1])}function je(u,g){return{node:u,index:0,__prev:g}}function st(u,g,y,M){var C=Object.create(L);return C.size=u,C._root=g,C.__ownerID=y,C.__hash=M,C.__altered=!1,C}var ct;function Je(){return ct||(ct=st(0))}function yt(u,g,y){var M,C;if(u._root){var D=O(A),k=O(q);if(M=Rt(u._root,u.__ownerID,0,void 0,g,y,D,k),!k.value)return u;C=u.size+(D.value?y===b?-1:1:0)}else{if(y===b)return u;C=1,M=new Y(u.__ownerID,[[g,y]])}return u.__ownerID?(u.size=C,u._root=M,u.__hash=void 0,u.__altered=!0,u):M?st(C,M):Je()}function Rt(u,g,y,M,C,D,k,$){return u?u.update(g,y,M,C,D,k,$):D===b?u:(T($),T(k),new we(g,M,[C,D]))}function Qt(u){return u.constructor===we||u.constructor===K}function Nt(u,g,y,M,C){if(u.keyHash===M)return new K(g,M,[u.entry,C]);var D=(y===0?u.keyHash:u.keyHash>>>y)&S,k=(y===0?M:M>>>y)&S,$,ce=D===k?[Nt(u,g,y+w,M,C)]:($=new we(g,M,C),D<k?[u,$]:[$,u]);return new ie(g,1<<D|1<<k,ce)}function Ut(u,g,y,M){u||(u=new I);for(var C=new we(u,dt(y),[y,M]),D=0;D<g.length;D++){var k=g[D];C=C.update(u,0,void 0,k[0],k[1])}return C}function ot(u,g,y,M){for(var C=0,D=0,k=new Array(y),$=0,ce=1,ue=g.length;$<ue;$++,ce<<=1){var _e=g[$];_e!==void 0&&$!==M&&(C|=ce,k[D++]=_e)}return new ie(u,C,k)}function en(u,g,y,M,C){for(var D=0,k=new Array(E),$=0;y!==0;$++,y>>>=1)k[$]=y&1?g[D++]:void 0;return k[M]=C,new oe(u,D+1,k)}function bt(u,g,y){for(var M=[],C=0;C<y.length;C++){var D=y[C],k=s(D);l(D)||(k=k.map(function($){return Ge($)})),M.push(k)}return Fn(u,g,M)}function Un(u,g,y){return u&&u.mergeDeep&&l(g)?u.mergeDeep(g):Be(u,g)?u:g}function Qi(u){return function(g,y,M){if(g&&g.mergeDeepWith&&l(y))return g.mergeDeepWith(u,y);var C=u(g,y,M);return Be(g,C)?g:C}}function Fn(u,g,y){return y=y.filter(function(M){return M.size!==0}),y.length===0?u:u.size===0&&!u.__ownerID&&y.length===1?u.constructor(y[0]):u.withMutations(function(M){for(var C=g?function(k,$){M.update($,b,function(ce){return ce===b?k:g(ce,k,$)})}:function(k,$){M.set($,k)},D=0;D<y.length;D++)y[D].forEach(C)})}function Ts(u,g,y,M){var C=u===b,D=g.next();if(D.done){var k=C?y:u,$=M(k);return $===k?u:$}G(C||u&&u.set,"invalid keyPath");var ce=D.value,ue=C?b:u.get(ce,b),_e=Ts(ue,g,y,M);return _e===ue?u:_e===b?u.remove(ce):(C?Je():u).set(ce,_e)}function $t(u){return u=u-(u>>1&1431655765),u=(u&858993459)+(u>>2&858993459),u=u+(u>>4)&252645135,u=u+(u>>8),u=u+(u>>16),u&127}function Xn(u,g,y,M){var C=M?u:N(u);return C[g]=y,C}function or(u,g,y,M){var C=u.length+1;if(M&&g+1===C)return u[g]=y,u;for(var D=new Array(C),k=0,$=0;$<C;$++)$===g?(D[$]=y,k=-1):D[$]=u[$+k];return D}function Rn(u,g,y){var M=u.length-1;if(y&&g===M)return u.pop(),u;for(var C=new Array(M),D=0,k=0;k<M;k++)k===g&&(D=1),C[k]=u[k+D];return C}var zn=E/4,Hl=E/2,es=E/4;r(tn,me);function tn(u){var g=ym();if(u==null)return g;if(c2(u))return u;var y=o(u),M=y.size;return M===0?g:(jn(M),M>0&&M<E?Wl(0,M,w,null,new As(y.toArray())):g.withMutations(function(C){C.setSize(M),y.forEach(function(D,k){return C.set(k,D)})}))}tn.of=function(){return this(arguments)},tn.prototype.toString=function(){return this.__toString("List [","]")},tn.prototype.get=function(u,g){if(u=W(this,u),u>=0&&u<this.size){u+=this._origin;var y=d2(this,u);return y&&y.array[u&S]}return g},tn.prototype.set=function(u,g){return tC(this,u,g)},tn.prototype.remove=function(u){return this.has(u)?u===0?this.shift():u===this.size-1?this.pop():this.splice(u,1):this},tn.prototype.insert=function(u,g){return this.splice(u,0,g)},tn.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=w,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):ym()},tn.prototype.push=function(){var u=arguments,g=this.size;return this.withMutations(function(y){Cs(y,0,g+u.length);for(var M=0;M<u.length;M++)y.set(g+M,u[M])})},tn.prototype.pop=function(){return Cs(this,0,-1)},tn.prototype.unshift=function(){var u=arguments;return this.withMutations(function(g){Cs(g,-u.length);for(var y=0;y<u.length;y++)g.set(y,u[y])})},tn.prototype.shift=function(){return Cs(this,1)},tn.prototype.merge=function(){return rh(this,void 0,arguments)},tn.prototype.mergeWith=function(u){var g=t.call(arguments,1);return rh(this,u,g)},tn.prototype.mergeDeep=function(){return rh(this,Un,arguments)},tn.prototype.mergeDeepWith=function(u){var g=t.call(arguments,1);return rh(this,Qi(u),g)},tn.prototype.setSize=function(u){return Cs(this,0,u)},tn.prototype.slice=function(u,g){var y=this.size;return ae(u,g,y)?this:Cs(this,J(u,y),se(g,y))},tn.prototype.__iterator=function(u,g){var y=0,M=h2(this,g);return new V(function(){var C=M();return C===Gl?Z():re(u,y++,C)})},tn.prototype.__iterate=function(u,g){for(var y=0,M=h2(this,g),C;(C=M())!==Gl&&u(C,y++,this)!==!1;);return y},tn.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Wl(this._origin,this._capacity,this._level,this._root,this._tail,u,this.__hash):(this.__ownerID=u,this)};function c2(u){return!!(u&&u[u2])}tn.isList=c2;var u2="@@__IMMUTABLE_LIST__@@",$n=tn.prototype;$n[u2]=!0,$n[_]=$n.remove,$n.setIn=L.setIn,$n.deleteIn=$n.removeIn=L.removeIn,$n.update=L.update,$n.updateIn=L.updateIn,$n.mergeIn=L.mergeIn,$n.mergeDeepIn=L.mergeDeepIn,$n.withMutations=L.withMutations,$n.asMutable=L.asMutable,$n.asImmutable=L.asImmutable,$n.wasAltered=L.wasAltered;function As(u,g){this.array=u,this.ownerID=g}As.prototype.removeBefore=function(u,g,y){if(y===g?1<<g:this.array.length===0)return this;var M=y>>>g&S;if(M>=this.array.length)return new As([],u);var C=M===0,D;if(g>0){var k=this.array[M];if(D=k&&k.removeBefore(u,g-w,y),D===k&&C)return this}if(C&&!D)return this;var $=Ca(this,u);if(!C)for(var ce=0;ce<M;ce++)$.array[ce]=void 0;return D&&($.array[M]=D),$},As.prototype.removeAfter=function(u,g,y){if(y===(g?1<<g:0)||this.array.length===0)return this;var M=y-1>>>g&S;if(M>=this.array.length)return this;var C;if(g>0){var D=this.array[M];if(C=D&&D.removeAfter(u,g-w,y),C===D&&M===this.array.length-1)return this}var k=Ca(this,u);return k.array.splice(M+1),C&&(k.array[M]=C),k};var Gl={};function h2(u,g){var y=u._origin,M=u._capacity,C=jl(M),D=u._tail;return k(u._root,u._level,0);function k(ue,_e,Ve){return _e===0?$(ue,Ve):ce(ue,_e,Ve)}function $(ue,_e){var Ve=_e===C?D&&D.array:ue&&ue.array,nt=_e>y?0:y-_e,pt=M-_e;return pt>E&&(pt=E),function(){if(nt===pt)return Gl;var St=g?--pt:nt++;return Ve&&Ve[St]}}function ce(ue,_e,Ve){var nt,pt=ue&&ue.array,St=Ve>y?0:y-Ve>>_e,rn=(M-Ve>>_e)+1;return rn>E&&(rn=E),function(){do{if(nt){var li=nt();if(li!==Gl)return li;nt=null}if(St===rn)return Gl;var Oi=g?--rn:St++;nt=k(pt&&pt[Oi],_e-w,Ve+(Oi<<_e))}while(!0)}}}function Wl(u,g,y,M,C,D,k){var $=Object.create($n);return $.size=g-u,$._origin=u,$._capacity=g,$._level=y,$._root=M,$._tail=C,$.__ownerID=D,$.__hash=k,$.__altered=!1,$}var f2;function ym(){return f2||(f2=Wl(0,0,w))}function tC(u,g,y){if(g=W(u,g),g!==g)return u;if(g>=u.size||g<0)return u.withMutations(function(k){g<0?Cs(k,g).set(0,y):Cs(k,0,g+1).set(g,y)});g+=u._origin;var M=u._tail,C=u._root,D=O(q);return g>=jl(u._capacity)?M=Sm(M,u.__ownerID,0,g,y,D):C=Sm(C,u.__ownerID,u._level,g,y,D),D.value?u.__ownerID?(u._root=C,u._tail=M,u.__hash=void 0,u.__altered=!0,u):Wl(u._origin,u._capacity,u._level,C,M):u}function Sm(u,g,y,M,C,D){var k=M>>>y&S,$=u&&k<u.array.length;if(!$&&C===void 0)return u;var ce;if(y>0){var ue=u&&u.array[k],_e=Sm(ue,g,y-w,M,C,D);return _e===ue?u:(ce=Ca(u,g),ce.array[k]=_e,ce)}return $&&u.array[k]===C?u:(T(D),ce=Ca(u,g),C===void 0&&k===ce.array.length-1?ce.array.pop():ce.array[k]=C,ce)}function Ca(u,g){return g&&u&&g===u.ownerID?u:new As(u?u.array.slice():[],g)}function d2(u,g){if(g>=jl(u._capacity))return u._tail;if(g<1<<u._level+w){for(var y=u._root,M=u._level;y&&M>0;)y=y.array[g>>>M&S],M-=w;return y}}function Cs(u,g,y){g!==void 0&&(g=g|0),y!==void 0&&(y=y|0);var M=u.__ownerID||new I,C=u._origin,D=u._capacity,k=C+g,$=y===void 0?D:y<0?D+y:C+y;if(k===C&&$===D)return u;if(k>=$)return u.clear();for(var ce=u._level,ue=u._root,_e=0;k+_e<0;)ue=new As(ue&&ue.array.length?[void 0,ue]:[],M),ce+=w,_e+=1<<ce;_e&&(k+=_e,C+=_e,$+=_e,D+=_e);for(var Ve=jl(D),nt=jl($);nt>=1<<ce+w;)ue=new As(ue&&ue.array.length?[ue]:[],M),ce+=w;var pt=u._tail,St=nt<Ve?d2(u,$-1):nt>Ve?new As([],M):pt;if(pt&&nt>Ve&&k<D&&pt.array.length){ue=Ca(ue,M);for(var rn=ue,li=ce;li>w;li-=w){var Oi=Ve>>>li&S;rn=rn.array[Oi]=Ca(rn.array[Oi],M)}rn.array[Ve>>>w&S]=pt}if($<D&&(St=St&&St.removeAfter(M,0,$)),k>=nt)k-=nt,$-=nt,ce=w,ue=null,St=St&&St.removeBefore(M,0,k);else if(k>C||nt<Ve){for(_e=0;ue;){var uh=k>>>ce&S;if(uh!==nt>>>ce&S)break;uh&&(_e+=(1<<ce)*uh),ce-=w,ue=ue.array[uh]}ue&&k>C&&(ue=ue.removeBefore(M,ce,k-_e)),ue&&nt<Ve&&(ue=ue.removeAfter(M,ce,nt-_e)),_e&&(k-=_e,$-=_e)}return u.__ownerID?(u.size=$-k,u._origin=k,u._capacity=$,u._level=ce,u._root=ue,u._tail=St,u.__hash=void 0,u.__altered=!0,u):Wl(k,$,ce,ue,St)}function rh(u,g,y){for(var M=[],C=0,D=0;D<y.length;D++){var k=y[D],$=o(k);$.size>C&&(C=$.size),l(k)||($=$.map(function(ce){return Ge(ce)})),M.push($)}return C>u.size&&(u=u.setSize(C)),Fn(u,g,M)}function jl(u){return u<E?0:u-1>>>w<<w}r(hn,Mt);function hn(u){return u==null?ih():p2(u)?u:ih().withMutations(function(g){var y=s(u);jn(y.size),y.forEach(function(M,C){return g.set(C,M)})})}hn.of=function(){return this(arguments)},hn.prototype.toString=function(){return this.__toString("OrderedMap {","}")},hn.prototype.get=function(u,g){var y=this._map.get(u);return y!==void 0?this._list.get(y)[1]:g},hn.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ih()},hn.prototype.set=function(u,g){return g2(this,u,g)},hn.prototype.remove=function(u){return g2(this,u,b)},hn.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},hn.prototype.__iterate=function(u,g){var y=this;return this._list.__iterate(function(M){return M&&u(M[1],M[0],y)},g)},hn.prototype.__iterator=function(u,g){return this._list.fromEntrySeq().__iterator(u,g)},hn.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map.__ensureOwner(u),y=this._list.__ensureOwner(u);return u?Em(g,y,u,this.__hash):(this.__ownerID=u,this._map=g,this._list=y,this)};function p2(u){return Vl(u)&&p(u)}hn.isOrderedMap=p2,hn.prototype[v]=!0,hn.prototype[_]=hn.prototype.remove;function Em(u,g,y,M){var C=Object.create(hn.prototype);return C.size=u?u.size:0,C._map=u,C._list=g,C.__ownerID=y,C.__hash=M,C}var m2;function ih(){return m2||(m2=Em(Je(),ym()))}function g2(u,g,y){var M=u._map,C=u._list,D=M.get(g),k=D!==void 0,$,ce;if(y===b){if(!k)return u;C.size>=E&&C.size>=M.size*2?(ce=C.filter(function(ue,_e){return ue!==void 0&&D!==_e}),$=ce.toKeyedSeq().map(function(ue){return ue[0]}).flip().toMap(),u.__ownerID&&($.__ownerID=ce.__ownerID=u.__ownerID)):($=M.remove(g),ce=D===C.size-1?C.pop():C.set(D,void 0))}else if(k){if(y===C.get(D)[1])return u;$=M,ce=C.set(D,[g,y])}else $=M.set(g,C.size),ce=C.set(C.size,[g,y]);return u.__ownerID?(u.size=$.size,u._map=$,u._list=ce,u.__hash=void 0,u):Em($,ce)}r(Fr,rt);function Fr(u,g){this._iter=u,this._useKeys=g,this.size=u.size}Fr.prototype.get=function(u,g){return this._iter.get(u,g)},Fr.prototype.has=function(u){return this._iter.has(u)},Fr.prototype.valueSeq=function(){return this._iter.valueSeq()},Fr.prototype.reverse=function(){var u=this,g=bm(this,!0);return this._useKeys||(g.valueSeq=function(){return u._iter.toSeq().reverse()}),g},Fr.prototype.map=function(u,g){var y=this,M=v2(this,u,g);return this._useKeys||(M.valueSeq=function(){return y._iter.toSeq().map(u,g)}),M},Fr.prototype.__iterate=function(u,g){var y=this,M;return this._iter.__iterate(this._useKeys?function(C,D){return u(C,D,y)}:(M=g?M2(this):0,function(C){return u(C,g?--M:M++,y)}),g)},Fr.prototype.__iterator=function(u,g){if(this._useKeys)return this._iter.__iterator(u,g);var y=this._iter.__iterator(F,g),M=g?M2(this):0;return new V(function(){var C=y.next();return C.done?C:re(u,g?--M:M++,C.value,C)})},Fr.prototype[v]=!0,r(Ra,Le);function Ra(u){this._iter=u,this.size=u.size}Ra.prototype.includes=function(u){return this._iter.includes(u)},Ra.prototype.__iterate=function(u,g){var y=this,M=0;return this._iter.__iterate(function(C){return u(C,M++,y)},g)},Ra.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g),M=0;return new V(function(){var C=y.next();return C.done?C:re(u,M++,C.value,C)})},r(Pa,at);function Pa(u){this._iter=u,this.size=u.size}Pa.prototype.has=function(u){return this._iter.includes(u)},Pa.prototype.__iterate=function(u,g){var y=this;return this._iter.__iterate(function(M){return u(M,M,y)},g)},Pa.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g);return new V(function(){var M=y.next();return M.done?M:re(u,M.value,M.value,M)})},r(Ia,rt);function Ia(u){this._iter=u,this.size=u.size}Ia.prototype.entrySeq=function(){return this._iter.toSeq()},Ia.prototype.__iterate=function(u,g){var y=this;return this._iter.__iterate(function(M){if(M){b2(M);var C=l(M);return u(C?M.get(1):M[1],C?M.get(0):M[0],y)}},g)},Ia.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g);return new V(function(){for(;;){var M=y.next();if(M.done)return M;var C=M.value;if(C){b2(C);var D=l(C);return re(u,D?C.get(0):C[0],D?C.get(1):C[1],M)}}})},Ra.prototype.cacheResult=Fr.prototype.cacheResult=Pa.prototype.cacheResult=Ia.prototype.cacheResult=Tm;function _2(u){var g=Pi(u);return g._iter=u,g.size=u.size,g.flip=function(){return u},g.reverse=function(){var y=u.reverse.apply(this);return y.flip=function(){return u.reverse()},y},g.has=function(y){return u.includes(y)},g.includes=function(y){return u.has(y)},g.cacheResult=Tm,g.__iterateUncached=function(y,M){var C=this;return u.__iterate(function(D,k){return y(k,D,C)!==!1},M)},g.__iteratorUncached=function(y,M){if(y===X){var C=u.__iterator(y,M);return new V(function(){var D=C.next();if(!D.done){var k=D.value[0];D.value[0]=D.value[1],D.value[1]=k}return D})}return u.__iterator(y===F?ge:F,M)},g}function v2(u,g,y){var M=Pi(u);return M.size=u.size,M.has=function(C){return u.has(C)},M.get=function(C,D){var k=u.get(C,b);return k===b?D:g.call(y,k,C,u)},M.__iterateUncached=function(C,D){var k=this;return u.__iterate(function($,ce,ue){return C(g.call(y,$,ce,ue),ce,k)!==!1},D)},M.__iteratorUncached=function(C,D){var k=u.__iterator(X,D);return new V(function(){var $=k.next();if($.done)return $;var ce=$.value,ue=ce[0];return re(C,ue,g.call(y,ce[1],ue,u),$)})},M}function bm(u,g){var y=Pi(u);return y._iter=u,y.size=u.size,y.reverse=function(){return u},u.flip&&(y.flip=function(){var M=_2(u);return M.reverse=function(){return u.flip()},M}),y.get=function(M,C){return u.get(g?M:-1-M,C)},y.has=function(M){return u.has(g?M:-1-M)},y.includes=function(M){return u.includes(M)},y.cacheResult=Tm,y.__iterate=function(M,C){var D=this;return u.__iterate(function(k,$){return M(k,$,D)},!C)},y.__iterator=function(M,C){return u.__iterator(M,!C)},y}function x2(u,g,y,M){var C=Pi(u);return M&&(C.has=function(D){var k=u.get(D,b);return k!==b&&!!g.call(y,k,D,u)},C.get=function(D,k){var $=u.get(D,b);return $!==b&&g.call(y,$,D,u)?$:k}),C.__iterateUncached=function(D,k){var $=this,ce=0;return u.__iterate(function(ue,_e,Ve){if(g.call(y,ue,_e,Ve))return ce++,D(ue,M?_e:ce-1,$)},k),ce},C.__iteratorUncached=function(D,k){var $=u.__iterator(X,k),ce=0;return new V(function(){for(;;){var ue=$.next();if(ue.done)return ue;var _e=ue.value,Ve=_e[0],nt=_e[1];if(g.call(y,nt,Ve,u))return re(D,M?Ve:ce++,nt,ue)}})},C}function nC(u,g,y){var M=Mt().asMutable();return u.__iterate(function(C,D){M.update(g.call(y,C,D,u),0,function(k){return k+1})}),M.asImmutable()}function rC(u,g,y){var M=c(u),C=(p(u)?hn():Mt()).asMutable();u.__iterate(function(k,$){C.update(g.call(y,k,$,u),function(ce){return ce=ce||[],ce.push(M?[$,k]:k),ce})});var D=w2(u);return C.map(function(k){return Wt(u,D(k))})}function Mm(u,g,y,M){var C=u.size;if(g!==void 0&&(g=g|0),y!==void 0&&(y===1/0?y=C:y=y|0),ae(g,y,C))return u;var D=J(g,C),k=se(y,C);if(D!==D||k!==k)return Mm(u.toSeq().cacheResult(),g,y,M);var $=k-D,ce;$===$&&(ce=$<0?0:$);var ue=Pi(u);return ue.size=ce===0?ce:u.size&&ce||void 0,!M&&$e(u)&&ce>=0&&(ue.get=function(_e,Ve){return _e=W(this,_e),_e>=0&&_e<ce?u.get(_e+D,Ve):Ve}),ue.__iterateUncached=function(_e,Ve){var nt=this;if(ce===0)return 0;if(Ve)return this.cacheResult().__iterate(_e,Ve);var pt=0,St=!0,rn=0;return u.__iterate(function(li,Oi){if(!(St&&(St=pt++<D)))return rn++,_e(li,M?Oi:rn-1,nt)!==!1&&rn!==ce}),rn},ue.__iteratorUncached=function(_e,Ve){if(ce!==0&&Ve)return this.cacheResult().__iterator(_e,Ve);var nt=ce!==0&&u.__iterator(_e,Ve),pt=0,St=0;return new V(function(){for(;pt++<D;)nt.next();if(++St>ce)return Z();var rn=nt.next();return M||_e===F?rn:_e===ge?re(_e,St-1,void 0,rn):re(_e,St-1,rn.value[1],rn)})},ue}function iC(u,g,y){var M=Pi(u);return M.__iterateUncached=function(C,D){var k=this;if(D)return this.cacheResult().__iterate(C,D);var $=0;return u.__iterate(function(ce,ue,_e){return g.call(y,ce,ue,_e)&&++$&&C(ce,ue,k)}),$},M.__iteratorUncached=function(C,D){var k=this;if(D)return this.cacheResult().__iterator(C,D);var $=u.__iterator(X,D),ce=!0;return new V(function(){if(!ce)return Z();var ue=$.next();if(ue.done)return ue;var _e=ue.value,Ve=_e[0],nt=_e[1];return g.call(y,nt,Ve,k)?C===X?ue:re(C,Ve,nt,ue):(ce=!1,Z())})},M}function y2(u,g,y,M){var C=Pi(u);return C.__iterateUncached=function(D,k){var $=this;if(k)return this.cacheResult().__iterate(D,k);var ce=!0,ue=0;return u.__iterate(function(_e,Ve,nt){if(!(ce&&(ce=g.call(y,_e,Ve,nt))))return ue++,D(_e,M?Ve:ue-1,$)}),ue},C.__iteratorUncached=function(D,k){var $=this;if(k)return this.cacheResult().__iterator(D,k);var ce=u.__iterator(X,k),ue=!0,_e=0;return new V(function(){var Ve,nt,pt;do{if(Ve=ce.next(),Ve.done)return M||D===F?Ve:D===ge?re(D,_e++,void 0,Ve):re(D,_e++,Ve.value[1],Ve);var St=Ve.value;nt=St[0],pt=St[1],ue&&(ue=g.call(y,pt,nt,$))}while(ue);return D===X?Ve:re(D,nt,pt,Ve)})},C}function sC(u,g){var y=c(u),M=[u].concat(g).map(function(k){return l(k)?y&&(k=s(k)):k=y?te(k):pe(Array.isArray(k)?k:[k]),k}).filter(function(k){return k.size!==0});if(M.length===0)return u;if(M.length===1){var C=M[0];if(C===u||y&&c(C)||h(u)&&h(C))return C}var D=new Xe(M);return y?D=D.toKeyedSeq():h(u)||(D=D.toSetSeq()),D=D.flatten(!0),D.size=M.reduce(function(k,$){if(k!==void 0){var ce=$.size;if(ce!==void 0)return k+ce}},0),D}function S2(u,g,y){var M=Pi(u);return M.__iterateUncached=function(C,D){var k=0,$=!1;function ce(ue,_e){var Ve=this;ue.__iterate(function(nt,pt){return(!g||_e<g)&&l(nt)?ce(nt,_e+1):C(nt,y?pt:k++,Ve)===!1&&($=!0),!$},D)}return ce(u,0),k},M.__iteratorUncached=function(C,D){var k=u.__iterator(C,D),$=[],ce=0;return new V(function(){for(;k;){var ue=k.next();if(ue.done!==!1){k=$.pop();continue}var _e=ue.value;if(C===X&&(_e=_e[1]),(!g||$.length<g)&&l(_e))$.push(k),k=_e.__iterator(C,D);else return y?ue:re(C,ce++,_e,ue)}return Z()})},M}function oC(u,g,y){var M=w2(u);return u.toSeq().map(function(C,D){return M(g.call(y,C,D,u))}).flatten(!0)}function aC(u,g){var y=Pi(u);return y.size=u.size&&u.size*2-1,y.__iterateUncached=function(M,C){var D=this,k=0;return u.__iterate(function($,ce){return(!k||M(g,k++,D)!==!1)&&M($,k++,D)!==!1},C),k},y.__iteratorUncached=function(M,C){var D=u.__iterator(F,C),k=0,$;return new V(function(){return(!$||k%2)&&($=D.next(),$.done)?$:k%2?re(M,k++,g):re(M,k++,$.value,$)})},y}function La(u,g,y){g||(g=T2);var M=c(u),C=0,D=u.toSeq().map(function(k,$){return[$,k,C++,y?y(k,$,u):k]}).toArray();return D.sort(function(k,$){return g(k[3],$[3])||k[2]-$[2]}).forEach(M?function(k,$){D[$].length=2}:function(k,$){D[$]=k[1]}),M?rt(D):h(u)?Le(D):at(D)}function sh(u,g,y){if(g||(g=T2),y){var M=u.toSeq().map(function(C,D){return[C,y(C,D,u)]}).reduce(function(C,D){return E2(g,C[1],D[1])?D:C});return M&&M[0]}else return u.reduce(function(C,D){return E2(g,C,D)?D:C})}function E2(u,g,y){var M=u(y,g);return M===0&&y!==g&&(y==null||y!==y)||M>0}function wm(u,g,y){var M=Pi(u);return M.size=new Xe(y).map(function(C){return C.size}).min(),M.__iterate=function(C,D){for(var k=this.__iterator(F,D),$,ce=0;!($=k.next()).done&&C($.value,ce++,this)!==!1;);return ce},M.__iteratorUncached=function(C,D){var k=y.map(function(ue){return ue=i(ue),ee(D?ue.reverse():ue)}),$=0,ce=!1;return new V(function(){var ue;return ce||(ue=k.map(function(_e){return _e.next()}),ce=ue.some(function(_e){return _e.done})),ce?Z():re(C,$++,g.apply(null,ue.map(function(_e){return _e.value})))})},M}function Wt(u,g){return $e(u)?g:u.constructor(g)}function b2(u){if(u!==Object(u))throw new TypeError("Expected [K, V] tuple: "+u)}function M2(u){return jn(u.size),H(u)}function w2(u){return c(u)?s:h(u)?o:a}function Pi(u){return Object.create((c(u)?rt:h(u)?Le:at).prototype)}function Tm(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):z.prototype.cacheResult.call(this)}function T2(u,g){return u>g?1:u<g?-1:0}function A2(u){var g=ee(u);if(!g){if(!le(u))throw new TypeError("Expected iterable or array-like: "+u);g=ee(i(u))}return g}r(yr,Te);function yr(u,g){var y,M=function(k){if(k instanceof M)return k;if(!(this instanceof M))return new M(k);if(!y){y=!0;var $=Object.keys(u);lC(C,$),C.size=$.length,C._name=g,C._keys=$,C._defaultValues=u}this._map=Mt(k)},C=M.prototype=Object.create(Pn);return C.constructor=M,M}yr.prototype.toString=function(){return this.__toString(C2(this)+" {","}")},yr.prototype.has=function(u){return this._defaultValues.hasOwnProperty(u)},yr.prototype.get=function(u,g){if(!this.has(u))return g;var y=this._defaultValues[u];return this._map?this._map.get(u,y):y},yr.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var u=this.constructor;return u._empty||(u._empty=oh(this,Je()))},yr.prototype.set=function(u,g){if(!this.has(u))throw new Error('Cannot set unknown key "'+u+'" on '+C2(this));if(this._map&&!this._map.has(u)){var y=this._defaultValues[u];if(g===y)return this}var M=this._map&&this._map.set(u,g);return this.__ownerID||M===this._map?this:oh(this,M)},yr.prototype.remove=function(u){if(!this.has(u))return this;var g=this._map&&this._map.remove(u);return this.__ownerID||g===this._map?this:oh(this,g)},yr.prototype.wasAltered=function(){return this._map.wasAltered()},yr.prototype.__iterator=function(u,g){var y=this;return s(this._defaultValues).map(function(M,C){return y.get(C)}).__iterator(u,g)},yr.prototype.__iterate=function(u,g){var y=this;return s(this._defaultValues).map(function(M,C){return y.get(C)}).__iterate(u,g)},yr.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map&&this._map.__ensureOwner(u);return u?oh(this,g,u):(this.__ownerID=u,this._map=g,this)};var Pn=yr.prototype;Pn[_]=Pn.remove,Pn.deleteIn=Pn.removeIn=L.removeIn,Pn.merge=L.merge,Pn.mergeWith=L.mergeWith,Pn.mergeIn=L.mergeIn,Pn.mergeDeep=L.mergeDeep,Pn.mergeDeepWith=L.mergeDeepWith,Pn.mergeDeepIn=L.mergeDeepIn,Pn.setIn=L.setIn,Pn.update=L.update,Pn.updateIn=L.updateIn,Pn.withMutations=L.withMutations,Pn.asMutable=L.asMutable,Pn.asImmutable=L.asImmutable;function oh(u,g,y){var M=Object.create(Object.getPrototypeOf(u));return M._map=g,M.__ownerID=y,M}function C2(u){return u._name||u.constructor.name||"Record"}function lC(u,g){try{g.forEach(cC.bind(void 0,u))}catch{}}function cC(u,g){Object.defineProperty(u,g,{get:function(){return this.get(g)},set:function(y){G(this.__ownerID,"Cannot set on an immutable record."),this.set(g,y)}})}r(nn,Ke);function nn(u){return u==null?Rm():Am(u)&&!p(u)?u:Rm().withMutations(function(g){var y=a(u);jn(y.size),y.forEach(function(M){return g.add(M)})})}nn.of=function(){return this(arguments)},nn.fromKeys=function(u){return this(s(u).keySeq())},nn.prototype.toString=function(){return this.__toString("Set {","}")},nn.prototype.has=function(u){return this._map.has(u)},nn.prototype.add=function(u){return Cm(this,this._map.set(u,!0))},nn.prototype.remove=function(u){return Cm(this,this._map.remove(u))},nn.prototype.clear=function(){return Cm(this,this._map.clear())},nn.prototype.union=function(){var u=t.call(arguments,0);return u=u.filter(function(g){return g.size!==0}),u.length===0?this:this.size===0&&!this.__ownerID&&u.length===1?this.constructor(u[0]):this.withMutations(function(g){for(var y=0;y<u.length;y++)a(u[y]).forEach(function(M){return g.add(M)})})},nn.prototype.intersect=function(){var u=t.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var g=this;return this.withMutations(function(y){g.forEach(function(M){u.every(function(C){return C.includes(M)})||y.remove(M)})})},nn.prototype.subtract=function(){var u=t.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var g=this;return this.withMutations(function(y){g.forEach(function(M){u.some(function(C){return C.includes(M)})&&y.remove(M)})})},nn.prototype.merge=function(){return this.union.apply(this,arguments)},nn.prototype.mergeWith=function(u){var g=t.call(arguments,1);return this.union.apply(this,g)},nn.prototype.sort=function(u){return Ii(La(this,u))},nn.prototype.sortBy=function(u,g){return Ii(La(this,g,u))},nn.prototype.wasAltered=function(){return this._map.wasAltered()},nn.prototype.__iterate=function(u,g){var y=this;return this._map.__iterate(function(M,C){return u(C,C,y)},g)},nn.prototype.__iterator=function(u,g){return this._map.map(function(y,M){return M}).__iterator(u,g)},nn.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map.__ensureOwner(u);return u?this.__make(g,u):(this.__ownerID=u,this._map=g,this)};function Am(u){return!!(u&&u[R2])}nn.isSet=Am;var R2="@@__IMMUTABLE_SET__@@",Sr=nn.prototype;Sr[R2]=!0,Sr[_]=Sr.remove,Sr.mergeDeep=Sr.merge,Sr.mergeDeepWith=Sr.mergeWith,Sr.withMutations=L.withMutations,Sr.asMutable=L.asMutable,Sr.asImmutable=L.asImmutable,Sr.__empty=Rm,Sr.__make=P2;function Cm(u,g){return u.__ownerID?(u.size=g.size,u._map=g,u):g===u._map?u:g.size===0?u.__empty():u.__make(g)}function P2(u,g){var y=Object.create(Sr);return y.size=u?u.size:0,y._map=u,y.__ownerID=g,y}var I2;function Rm(){return I2||(I2=P2(Je()))}r(Ii,nn);function Ii(u){return u==null?Pm():L2(u)?u:Pm().withMutations(function(g){var y=a(u);jn(y.size),y.forEach(function(M){return g.add(M)})})}Ii.of=function(){return this(arguments)},Ii.fromKeys=function(u){return this(s(u).keySeq())},Ii.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function L2(u){return Am(u)&&p(u)}Ii.isOrderedSet=L2;var ah=Ii.prototype;ah[v]=!0,ah.__empty=Pm,ah.__make=O2;function O2(u,g){var y=Object.create(ah);return y.size=u?u.size:0,y._map=u,y.__ownerID=g,y}var q2;function Pm(){return q2||(q2=O2(ih()))}r(_n,me);function _n(u){return u==null?Im():D2(u)?u:Im().unshiftAll(u)}_n.of=function(){return this(arguments)},_n.prototype.toString=function(){return this.__toString("Stack [","]")},_n.prototype.get=function(u,g){var y=this._head;for(u=W(this,u);y&&u--;)y=y.next;return y?y.value:g},_n.prototype.peek=function(){return this._head&&this._head.value},_n.prototype.push=function(){if(arguments.length===0)return this;for(var u=this.size+arguments.length,g=this._head,y=arguments.length-1;y>=0;y--)g={value:arguments[y],next:g};return this.__ownerID?(this.size=u,this._head=g,this.__hash=void 0,this.__altered=!0,this):Xl(u,g)},_n.prototype.pushAll=function(u){if(u=o(u),u.size===0)return this;jn(u.size);var g=this.size,y=this._head;return u.reverse().forEach(function(M){g++,y={value:M,next:y}}),this.__ownerID?(this.size=g,this._head=y,this.__hash=void 0,this.__altered=!0,this):Xl(g,y)},_n.prototype.pop=function(){return this.slice(1)},_n.prototype.unshift=function(){return this.push.apply(this,arguments)},_n.prototype.unshiftAll=function(u){return this.pushAll(u)},_n.prototype.shift=function(){return this.pop.apply(this,arguments)},_n.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Im()},_n.prototype.slice=function(u,g){if(ae(u,g,this.size))return this;var y=J(u,this.size),M=se(g,this.size);if(M!==this.size)return me.prototype.slice.call(this,u,g);for(var C=this.size-y,D=this._head;y--;)D=D.next;return this.__ownerID?(this.size=C,this._head=D,this.__hash=void 0,this.__altered=!0,this):Xl(C,D)},_n.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Xl(this.size,this._head,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)},_n.prototype.__iterate=function(u,g){if(g)return this.reverse().__iterate(u);for(var y=0,M=this._head;M&&u(M.value,y++,this)!==!1;)M=M.next;return y},_n.prototype.__iterator=function(u,g){if(g)return this.reverse().__iterator(u);var y=0,M=this._head;return new V(function(){if(M){var C=M.value;return M=M.next,re(u,y++,C)}return Z()})};function D2(u){return!!(u&&u[N2])}_n.isStack=D2;var N2="@@__IMMUTABLE_STACK__@@",Oa=_n.prototype;Oa[N2]=!0,Oa.withMutations=L.withMutations,Oa.asMutable=L.asMutable,Oa.asImmutable=L.asImmutable,Oa.wasAltered=L.wasAltered;function Xl(u,g,y,M){var C=Object.create(Oa);return C.size=u,C._head=g,C.__ownerID=y,C.__hash=M,C.__altered=!1,C}var U2;function Im(){return U2||(U2=Xl(0))}function Li(u,g){var y=function(M){u.prototype[M]=g[M]};return Object.keys(g).forEach(y),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(g).forEach(y),u}i.Iterator=V,Li(i,{toArray:function(){jn(this.size);var u=new Array(this.size||0);return this.valueSeq().__iterate(function(g,y){u[y]=g}),u},toIndexedSeq:function(){return new Ra(this)},toJS:function(){return this.toSeq().map(function(u){return u&&typeof u.toJS=="function"?u.toJS():u}).__toJS()},toJSON:function(){return this.toSeq().map(function(u){return u&&typeof u.toJSON=="function"?u.toJSON():u}).__toJS()},toKeyedSeq:function(){return new Fr(this,!0)},toMap:function(){return Mt(this.toKeyedSeq())},toObject:function(){jn(this.size);var u={};return this.__iterate(function(g,y){u[y]=g}),u},toOrderedMap:function(){return hn(this.toKeyedSeq())},toOrderedSet:function(){return Ii(c(this)?this.valueSeq():this)},toSet:function(){return nn(c(this)?this.valueSeq():this)},toSetSeq:function(){return new Pa(this)},toSeq:function(){return h(this)?this.toIndexedSeq():c(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return _n(c(this)?this.valueSeq():this)},toList:function(){return tn(c(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(u,g){return this.size===0?u+g:u+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+g},concat:function(){var u=t.call(arguments,0);return Wt(this,sC(this,u))},includes:function(u){return this.some(function(g){return Be(g,u)})},entries:function(){return this.__iterator(X)},every:function(u,g){jn(this.size);var y=!0;return this.__iterate(function(M,C,D){if(!u.call(g,M,C,D))return y=!1,!1}),y},filter:function(u,g){return Wt(this,x2(this,u,g,!0))},find:function(u,g,y){var M=this.findEntry(u,g);return M?M[1]:y},forEach:function(u,g){return jn(this.size),this.__iterate(g?u.bind(g):u)},join:function(u){jn(this.size),u=u!==void 0?""+u:",";var g="",y=!0;return this.__iterate(function(M){y?y=!1:g+=u,g+=M!=null?M.toString():""}),g},keys:function(){return this.__iterator(ge)},map:function(u,g){return Wt(this,v2(this,u,g))},reduce:function(u,g,y){jn(this.size);var M,C;return arguments.length<2?C=!0:M=g,this.__iterate(function(D,k,$){C?(C=!1,M=D):M=u.call(y,M,D,k,$)}),M},reduceRight:function(u,g,y){var M=this.toKeyedSeq().reverse();return M.reduce.apply(M,arguments)},reverse:function(){return Wt(this,bm(this,!0))},slice:function(u,g){return Wt(this,Mm(this,u,g,!0))},some:function(u,g){return!this.every(ch(u),g)},sort:function(u){return Wt(this,La(this,u))},values:function(){return this.__iterator(F)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(u,g){return H(u?this.toSeq().filter(u,g):this)},countBy:function(u,g){return nC(this,u,g)},equals:function(u){return Ye(this,u)},entrySeq:function(){var u=this;if(u._cache)return new Xe(u._cache);var g=u.toSeq().map(hC).toIndexedSeq();return g.fromEntrySeq=function(){return u.toSeq()},g},filterNot:function(u,g){return this.filter(ch(u),g)},findEntry:function(u,g,y){var M=y;return this.__iterate(function(C,D,k){if(u.call(g,C,D,k))return M=[D,C],!1}),M},findKey:function(u,g){var y=this.findEntry(u,g);return y&&y[0]},findLast:function(u,g,y){return this.toKeyedSeq().reverse().find(u,g,y)},findLastEntry:function(u,g,y){return this.toKeyedSeq().reverse().findEntry(u,g,y)},findLastKey:function(u,g){return this.toKeyedSeq().reverse().findKey(u,g)},first:function(){return this.find(Q)},flatMap:function(u,g){return Wt(this,oC(this,u,g))},flatten:function(u){return Wt(this,S2(this,u,!0))},fromEntrySeq:function(){return new Ia(this)},get:function(u,g){return this.find(function(y,M){return Be(M,u)},void 0,g)},getIn:function(u,g){for(var y=this,M=A2(u),C;!(C=M.next()).done;){var D=C.value;if(y=y&&y.get?y.get(D,b):b,y===b)return g}return y},groupBy:function(u,g){return rC(this,u,g)},has:function(u){return this.get(u,b)!==b},hasIn:function(u){return this.getIn(u,b)!==b},isSubset:function(u){return u=typeof u.includes=="function"?u:i(u),this.every(function(g){return u.includes(g)})},isSuperset:function(u){return u=typeof u.isSubset=="function"?u:i(u),u.isSubset(this)},keyOf:function(u){return this.findKey(function(g){return Be(g,u)})},keySeq:function(){return this.toSeq().map(uC).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(u){return this.toKeyedSeq().reverse().keyOf(u)},max:function(u){return sh(this,u)},maxBy:function(u,g){return sh(this,g,u)},min:function(u){return sh(this,u?F2(u):k2)},minBy:function(u,g){return sh(this,g?F2(g):k2,u)},rest:function(){return this.slice(1)},skip:function(u){return this.slice(Math.max(0,u))},skipLast:function(u){return Wt(this,this.toSeq().reverse().skip(u).reverse())},skipWhile:function(u,g){return Wt(this,y2(this,u,g,!0))},skipUntil:function(u,g){return this.skipWhile(ch(u),g)},sortBy:function(u,g){return Wt(this,La(this,g,u))},take:function(u){return this.slice(0,Math.max(0,u))},takeLast:function(u){return Wt(this,this.toSeq().reverse().take(u).reverse())},takeWhile:function(u,g){return Wt(this,iC(this,u,g))},takeUntil:function(u,g){return this.takeWhile(ch(u),g)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=dC(this))}});var Yn=i.prototype;Yn[d]=!0,Yn[Ee]=Yn.values,Yn.__toJS=Yn.toArray,Yn.__toStringMapper=z2,Yn.inspect=Yn.toSource=function(){return this.toString()},Yn.chain=Yn.flatMap,Yn.contains=Yn.includes,Li(s,{flip:function(){return Wt(this,_2(this))},mapEntries:function(u,g){var y=this,M=0;return Wt(this,this.toSeq().map(function(C,D){return u.call(g,[D,C],M++,y)}).fromEntrySeq())},mapKeys:function(u,g){var y=this;return Wt(this,this.toSeq().flip().map(function(M,C){return u.call(g,M,C,y)}).flip())}});var lh=s.prototype;lh[m]=!0,lh[Ee]=Yn.entries,lh.__toJS=Yn.toObject,lh.__toStringMapper=function(u,g){return JSON.stringify(g)+": "+z2(u)},Li(o,{toKeyedSeq:function(){return new Fr(this,!1)},filter:function(u,g){return Wt(this,x2(this,u,g,!1))},findIndex:function(u,g){var y=this.findEntry(u,g);return y?y[0]:-1},indexOf:function(u){var g=this.keyOf(u);return g===void 0?-1:g},lastIndexOf:function(u){var g=this.lastKeyOf(u);return g===void 0?-1:g},reverse:function(){return Wt(this,bm(this,!1))},slice:function(u,g){return Wt(this,Mm(this,u,g,!1))},splice:function(u,g){var y=arguments.length;if(g=Math.max(g|0,0),y===0||y===2&&!g)return this;u=J(u,u<0?this.count():this.size);var M=this.slice(0,u);return Wt(this,y===1?M:M.concat(N(arguments,2),this.slice(u+g)))},findLastIndex:function(u,g){var y=this.findLastEntry(u,g);return y?y[0]:-1},first:function(){return this.get(0)},flatten:function(u){return Wt(this,S2(this,u,!1))},get:function(u,g){return u=W(this,u),u<0||this.size===1/0||this.size!==void 0&&u>this.size?g:this.find(function(y,M){return M===u},void 0,g)},has:function(u){return u=W(this,u),u>=0&&(this.size!==void 0?this.size===1/0||u<this.size:this.indexOf(u)!==-1)},interpose:function(u){return Wt(this,aC(this,u))},interleave:function(){var u=[this].concat(N(arguments)),g=wm(this.toSeq(),Le.of,u),y=g.flatten(!0);return g.size&&(y.size=g.size*u.length),Wt(this,y)},keySeq:function(){return Se(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(u,g){return Wt(this,y2(this,u,g,!1))},zip:function(){var u=[this].concat(N(arguments));return Wt(this,wm(this,fC,u))},zipWith:function(u){var g=N(arguments);return g[0]=this,Wt(this,wm(this,u,g))}}),o.prototype[x]=!0,o.prototype[v]=!0,Li(a,{get:function(u,g){return this.has(u)?u:g},includes:function(u){return this.has(u)},keySeq:function(){return this.valueSeq()}}),a.prototype.has=Yn.includes,a.prototype.contains=a.prototype.includes,Li(rt,s.prototype),Li(Le,o.prototype),Li(at,a.prototype),Li(Te,s.prototype),Li(me,o.prototype),Li(Ke,a.prototype);function uC(u,g){return g}function hC(u,g){return[g,u]}function ch(u){return function(){return!u.apply(this,arguments)}}function F2(u){return function(){return-u.apply(this,arguments)}}function z2(u){return typeof u=="string"?JSON.stringify(u):String(u)}function fC(){return N(arguments)}function k2(u,g){return u<g?1:u>g?-1:0}function dC(u){if(u.size===1/0)return 0;var g=p(u),y=c(u),M=g?1:0,C=u.__iterate(y?g?function(D,k){M=31*M+B2(dt(D),dt(k))|0}:function(D,k){M=M+B2(dt(D),dt(k))|0}:g?function(D){M=31*M+dt(D)|0}:function(D){M=M+dt(D)|0});return pC(C,M)}function pC(u,g){return g=ut(g,3432918353),g=ut(g<<15|g>>>-15,461845907),g=ut(g<<13|g>>>-13,5),g=(g+3864292196|0)^u,g=ut(g^g>>>16,2246822507),g=ut(g^g>>>13,3266489909),g=Ot(g^g>>>16),g}function B2(u,g){return u^g+2654435769+(u<<6)+(u>>2)|0}var mC={Iterable:i,Seq:z,Collection:ke,Map:Mt,OrderedMap:hn,List:tn,Stack:_n,Set:nn,OrderedSet:Ii,Record:yr,Range:Se,Repeat:Re,is:Be,fromJS:Ge};return mC})})(bc)),bc.exports}var wf,gg;function L3(){if(gg)return wf;gg=1;var n=Mf(),e=function(i){return n.Iterable.isKeyed(i)},t=function(i){return n.Iterable.isIndexed(i)},r=function(i,s,o){return i==="remove"?{op:i,path:s}:{op:i,path:s,value:o}};return wf={isMap:e,isIndexed:t,op:r},wf}var Tf,_g;function O3(){if(_g)return Tf;_g=1;var n=Mf(),e=function(c,h,f){for(var p=[],d=0;d<c;d++){p[d]=new Array(h);for(var m=0;m<h;m++)p[d][m]=f}return p},t=function(c,h){var f=a(c,h);return l(c,h,f)},r=n.Record({op:"=",val:null}),i=n.Record({op:"!=",val:null,newVal:null}),s=function(c,h){var f=a(c,h);return o(f,c,h,c.size||0,h.size||0)},o=function(c,h,f,p,d){for(var m=[],x=p-1,v=d-1;x>=0||v>=0;)x>=0&&v>=0&&n.is(h.get(x),f.get(v))?(m.push(new r({op:"=",val:h.get(x)})),x-=1,v-=1):x>=0&&v>=0&&x===v&&!n.is(h.get(x),f.get(v))?(m.push(new i({val:h.get(x),newVal:f.get(x)})),x-=1,v-=1):v>=0&&(x===-1||c[x+1][v]>=c[x][v+1])?(m.push(new r({op:"+",val:f.get(v)})),v-=1):x>=0&&(v===-1||c[x+1][v]<c[x][v+1])&&(m.push(new r({op:"-",val:h.get(x)})),x-=1);return m.reverse()};function a(c,h){for(var f=c.size||0,p=h.size||0,d=e(f+1,p+1,0),m=0;m<f;m++)for(var x=0;x<p;x++)n.is(c.get(m),h.get(x))?d[m+1][x+1]=d[m][x]+1:d[m+1][x+1]=Math.max(d[m+1][x],d[m][x+1]);return d}var l=function(c,h,f){for(var p=[],d=c.size,m=h.size;d!==0&&m!==0;)f[d][m]===f[d-1][m]?d--:f[d][m]===f[d][m-1]?m--:n.is(c.get(d-1),h.get(m-1))&&(p.push(c.get(d-1)),d--,m--);return p.reverse()};return Tf={lcs:t,computeLcsMatrix:a,diff:s},Tf}var Af,vg;function q3(){if(vg)return Af;vg=1;var n=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,r=/~0/g,i={escape:function(s){if(typeof s=="number")return s.toString();if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(t,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(e,"/").replace(r,"~"):s},concat:function(s,o){return s+"/"+o}};return Af=i,Af}var Cf,xg;function D3(){if(xg)return Cf;xg=1;var n=Mf(),e=L3(),t=O3(),r=q3(),i=r.concat,s=r.escape,o=e.op,a=e.isMap,l=e.isIndexed,c=function(d,m,x){var v=[],_=x||"";if(n.is(d,m)||d==m==null)return v;var w=l(d)&&l(m),E=null,S=null;return d.forEach&&d.forEach(function(b,A){if(m.has(A))if(a(b)&&a(m.get(A)))v=v.concat(c(b,m.get(A),i(_,s(A))));else if(l(m.get(A))&&l(b))v=v.concat(h(b,m.get(A),i(_,s(A))));else{var q=m.get?m.get(A):m,O=b!==q;O&&v.push(o("replace",i(_,s(A)),q))}else w?(S=E!=null&&E+1===A?S:A,v.push(o("remove",i(_,s(S)))),E=A):v.push(o("remove",i(_,s(A))))}),m.forEach(function(b,A){d.has&&!d.has(A)&&v.push(o("add",i(_,s(A)),b))}),v},h=function(d,m,x){var v=[],_=x||"";if(n.is(d,m)||d==m==null)return v;if((d.count()+1)*(m.count()+1)>=1e4)return c(d,m,x);var w=t.diff(d,m),E=0;return w.forEach(function(S){if(S.op==="=")E++;else if(S.op==="!="){if(a(S.val)&&a(S.newVal)){var b=c(S.val,S.newVal,i(_,E));v=v.concat(b)}else v.push(o("replace",i(_,E),S.newVal));E++}else S.op==="+"?(v.push(o("add",i(_,E),S.val)),E++):S.op==="-"&&v.push(o("remove",i(_,E)))}),v},f=function(d,m,x){var v=x||"";return d===m?[]:[o("replace",i(v,""),m)]},p=function(d,m,x){return n.is(d,m)?n.List():d!=m&&(d==null||m==null)?n.fromJS([o("replace","/",m)]):l(d)&&l(m)?n.fromJS(h(d,m)):a(d)&&a(m)?n.fromJS(c(d,m)):n.fromJS(f(d,m,x))};return Cf=p,Cf}var N3=D3();const U3=qa(N3),F3=Lm(Xy);var Rf,yg;function z3(){if(yg)return Rf;yg=1;var n=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,r=/~0/g,i={escape:function(s){if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(t,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(e,"/").replace(r,"~"):s}};return Rf=i,Rf}var Pf,Sg;function k3(){if(Sg)return Pf;Sg=1;var n=F3,e=z3(),t=function(h){var f=parseInt(h);return isNaN(f)?h:f},r=function(h,f){if(h==="add"||h==="replace")return f;if(h==="remove")return null},i=function(h,f,p,d,m){if(d==="add")if(p.length>0&&h.get(f)===void 0){var x=p[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(x,p,d,m))}else return h.set(f,a(h.get(f),p,d,m));else{if(d==="replace")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.set(f,m);if(d==="remove")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.remove(f);throw new Error("map patch Error, unknown op: "+d)}},s=function(h,f,p,d,m){if(f=t(f),d==="add")if(h.get(f)===void 0)if(p.length>0){var x=p[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(x,p,d,m))}else return f==="-"?h.splice(h.size,0,m):h.splice(f,0,m);else return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.splice(f,0,m);else{if(d==="replace")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.set(f,m);if(d==="remove")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.remove(f);throw new Error("sequence patch Error, unknown op: "+d)}},o=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},a=function(h,f,p,d){var m,x;return n.Iterable.isIndexed(h)?f.length===0?h:(m=f[0],x=f.slice(1),s(h,m,x,p,d)):n.Iterable.isKeyed(h)||o(h)?f.length===0?h:(m=f[0],x=f.slice(1),i(h,m,x,p,d)):f.length===0?d:r(p,d)},l=function(h,f){for(;f.size;){var p=f.get(0),f=f.slice(1),d=p.get("path").split("/").slice(1).map(e.unescape);h=a(h,d,p.get("op"),p.get("value"))}return h},c=function(h,f){if(f.size===1){var p=f.get(0);if(p.get("op")==="replace"&&p.get("path")==="/")return p.get("value")}return l(h,f)};return c.default=c,Pf=c,Pf}var B3=k3();const Eg=qa(B3),on=(n,e)=>{if(n.last){if(n.last.hashCode()!==e.hashCode()){let t=Ie({time:Date.now(),diff:U3(n.last,e)});n=n.set("last",e).set("list",n.list.push(t)).set("redoList",n.redoList.clear())}}else n=n.set("last",e);return n},V3=n=>{if(n.last&&n.redoList.size){const e=n.redoList.last(),t=Eg(n.last,e.get("diff"));n=n.set("last",t).set("list",n.list.push(e)).set("redoList",n.redoList.pop())}return n},bg=n=>{var e;if(n.last&&n.list.size){const t=n.list.last();let r=n.first;for(let i=0;i<n.list.size-1;i++)r=Eg(r,(e=n.list.get(i))==null?void 0:e.get("diff"));n=n.set("last",r).set("list",n.list.pop()).set("redoList",n.redoList.push(t))}return n};var If={exports:{}},Lf,Mg;function H3(){if(Mg)return Lf;Mg=1;var n=1;function e(){return n=(n*9301+49297)%233280,n/233280}function t(r){n=r}return Lf={nextValue:e,seed:t},Lf}var Of,wg;function Mc(){if(wg)return Of;wg=1;var n=H3(),e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",t,r,i;function s(){i=!1}function o(d){if(!d){t!==e&&(t=e,s());return}if(d!==t){if(d.length!==e.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. You submitted "+d.length+" characters: "+d);var m=d.split("").filter(function(x,v,_){return v!==_.lastIndexOf(x)});if(m.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. These characters were not unique: "+m.join(", "));t=d,s()}}function a(d){return o(d),t}function l(d){n.seed(d),r!==d&&(s(),r=d)}function c(){t||o(e);for(var d=t.split(""),m=[],x=n.nextValue(),v;d.length>0;)x=n.nextValue(),v=Math.floor(x*d.length),m.push(d.splice(v,1)[0]);return m.join("")}function h(){return i||(i=c(),i)}function f(d){var m=h();return m[d]}function p(){return t||e}return Of={get:p,characters:a,seed:l,lookup:f,shuffled:h},Of}var qf,Tg;function G3(){if(Tg)return qf;Tg=1;var n=typeof window=="object"&&(window.crypto||window.msCrypto),e;return!n||!n.getRandomValues?e=function(t){for(var r=[],i=0;i<t;i++)r.push(Math.floor(Math.random()*256));return r}:e=function(t){return n.getRandomValues(new Uint8Array(t))},qf=e,qf}let W3="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Ag=n=>crypto.getRandomValues(new Uint8Array(n)),Cg=(n,e,t)=>{let r=(2<<Math.log(n.length-1)/Math.LN2)-1,i=-~(1.6*r*e/n.length);return(s=e)=>{let o="";for(;;){let a=t(i),l=i|0;for(;l--;)if(o+=n[a[l]&r]||"",o.length===s)return o}}};const j3=Lm(Object.freeze(Object.defineProperty({__proto__:null,customAlphabet:(n,e=21)=>Cg(n,e,Ag),customRandom:Cg,nanoid:(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),random:Ag,urlAlphabet:W3},Symbol.toStringTag,{value:"Module"})));var Df,Rg;function X3(){if(Rg)return Df;Rg=1;var n=Mc(),e=G3(),t=j3.customRandom;function r(i){for(var s=0,o,a="";!o;)a=a+t(n.get(),1,e)(),o=i<Math.pow(16,s+1),s++;return a}return Df=r,Df}var Nf,Pg;function $3(){if(Pg)return Nf;Pg=1;var n=X3();Mc();var e=1567752802062,t=7,r,i;function s(o){var a="",l=Math.floor((Date.now()-e)*.001);return l===i?r++:(r=0,i=l),a=a+n(t),a=a+n(o),r>0&&(a=a+n(r)),a=a+n(l),a}return Nf=s,Nf}var Uf,Ig;function Y3(){if(Ig)return Uf;Ig=1;var n=Mc();function e(t){if(!t||typeof t!="string"||t.length<6)return!1;var r=new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!r.test(t)}return Uf=e,Uf}var Ff,Lg;function K3(){return Lg||(Lg=1,Ff=0),Ff}var Og;function Z3(){return Og||(Og=1,(function(n){var e=Mc(),t=$3(),r=Y3(),i=K3()||0;function s(c){return e.seed(c),n.exports}function o(c){return i=c,n.exports}function a(c){return c!==void 0&&e.characters(c),e.shuffled()}function l(){return t(i)}n.exports=l,n.exports.generate=l,n.exports.seed=s,n.exports.worker=o,n.exports.characters=a,n.exports.isValid=r})(If)),If.exports}var zf,qg;function J3(){return qg||(qg=1,zf=Z3()),zf}var Q3=J3();const eS=qa(Q3);class gi{static acquireID(){return eS.generate()}}class wc{static generateName(e,t){return t.charAt(0).toUpperCase()+t.slice(1)}}class pn{static create(e,t,r,i,s,o){let a=gi.acquireID(),l=e.catalog.factoryElement(r,{id:a,name:wc.generateName("holes",e.catalog.getIn(["elements",r,"info","title"])),type:r,offset:s,line:i},o);return e=e.setIn(["scene","layers",t,"holes",a],l),e=e.updateIn(["scene","layers",t,"lines",i,"holes"],c=>c.push(a)),{updatedState:e,hole:l}}static select(e,t,r){return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"holes",r).updatedState,{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"holes",r]);return e=this.unselect(e,t,r).updatedState,e=it.removeElement(e,t,"holes",r).updatedState,e=e.updateIn(["scene","layers",t,"lines",i.line,"holes"],s=>{let o=s.findIndex(a=>r===a);return o!==-1?s.remove(o):s}),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"holes",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"holes",r).updatedState,{updatedState:e}}static selectToolDrawingHole(e,t){let r=He().withMutations(i=>{let{lines:s,vertices:o}=e.getIn(["scene","layers",e.scene.selectedLayer]);s.forEach(a=>{if(a.get("type")==="surface")return;let{x:l,y:c}=o.get(a.vertices.get(0)),{x:h,y:f}=o.get(a.vertices.get(1));sl(i,l,c,h,f,20,1,a.id)})});return e=e.merge({mode:hr,snapElements:r,drawingSupport:Ie({type:t})}),{updatedState:e}}static updateDrawingHole(e,t,r,i){let s=e.catalog,o=mi(e.snapElements,r,i,e.snapMask.merge({SNAP_SEGMENT:!0}));o&&({x:r,y:i}=o.point);let a=e.getIn(["scene","layers",t,"selected","holes"]).first();if(o){let l=o.snap.related.get(0),c=e.getIn(["scene","layers",t,"lines",l,"vertices"]),{x:h,y:f}=e.getIn(["scene","layers",t,"vertices",c.get(0)]),{x:p,y:d}=e.getIn(["scene","layers",t,"vertices",c.get(1)]),m=pc({x:h,y:f},{x:p,y:d}),x=ff({x:h,y:f},{x:p,y:d}),v=s.factoryElement(e.drawingSupport.get("type")).properties.getIn(["width","length"]),_=Cn(h,f,p,d),w=i3(h,f,p,d),E=o3(w,1e-7),S=a3(w,1e-7),b={x:m.x+v/2*E,y:m.y+v/2*S},A={x:m.x+_*E-v/2*E,y:m.y+_*S-v/2*S},q;if(r<b.x?q=On(m.x,m.y,x.x,x.y,b.x,b.y):r>A.x?q=On(m.x,m.y,x.x,x.y,A.x,A.y):r===b.x&&r===A.x?i<b.y?(q=On(m.x,m.y,x.x,x.y,b.x,b.y),q=m.x===h&&m.y===f?q:1-q):i>A.y?(q=On(m.x,m.y,x.x,x.y,A.x,A.y),q=m.x===h&&m.y===f?q:1-q):q=On(h,f,p,d,r,i):q=On(h,f,p,d,r,i),a&&o){e=e.mergeIn(["scene","layers",t,"holes",a],{offset:q,line:l});let O=e.getIn(["scene","layers",t,"lines"]).findEntry(I=>I.id!==l&&I.get("holes").contains(a));if(O){let I=O[1].get("holes").filter(N=>N!==a);e=e.setIn(["scene","layers",t,"lines",O[0],"holes"],I)}let T=e.getIn(["scene","layers",t,"lines",l,"holes"]);T.contains(a)||(e=e.setIn(["scene","layers",t,"lines",l,"holes"],T.push(a)))}else if(!a&&o){let{updatedState:O,hole:T}=this.create(e,t,e.drawingSupport.get("type"),l,q);e=pn.select(O,t,T.id).updatedState}}return{updatedState:e}}static endDrawingHole(e,t,r,i){return e=this.updateDrawingHole(e,t,r,i).updatedState,e=it.unselectAll(e,t).updatedState,{updatedState:e}}static beginDraggingHole(e,t,r,i,s){let o=e.getIn(["scene","layers",t]),a=o.getIn(["holes",r]),l=o.getIn(["lines",a.line]),c=o.getIn(["vertices",l.vertices.get(0)]),h=o.getIn(["vertices",l.vertices.get(1)]),f=sl(He(),c.x,c.y,h.x,h.y,9999999,1,null);return e=e.merge({mode:Wr,snapElements:f,draggingSupport:Ie({layerID:t,holeID:r,startPointX:i,startPointY:s})}),{updatedState:e}}static updateDraggingHole(e,t,r){let i=mi(e.snapElements,t,r,e.snapMask.merge({SNAP_SEGMENT:!0}));if(!i)return e;let{draggingSupport:s,scene:o}=e,a=s.get("layerID"),l=s.get("holeID"),c=e.getIn(["scene","layers",a]),h=c.getIn(["holes",l]),f=c.getIn(["lines",h.line]),p=c.getIn(["vertices",f.vertices.get(0)]),d=c.getIn(["vertices",f.vertices.get(1)]);({x:t,y:r}=i.point);let m=pc(p,d),x=ff(p,d),v=h.properties.get("width").get("length"),_=Cn(p.x,p.y,d.x,d.y),w=Math.atan2(Math.abs(d.y-p.y),Math.abs(d.x-p.x)),E=I=>{let N=Math.cos(I);return N<1e-7?0:N},S=I=>{let N=Math.sin(I);return N<1e-7?0:N},b=E(w),A=S(w),q={x:m.x+v/2*b,y:m.y+v/2*A},O={x:m.x+_*b-v/2*b,y:m.y+_*A-v/2*A},T;return t<q.x?T=On(m.x,m.y,x.x,x.y,q.x,q.y):t>O.x?T=On(m.x,m.y,x.x,x.y,O.x,O.y):t===q.x&&t===O.x?r<q.y?(T=On(m.x,m.y,x.x,x.y,q.x,q.y),T=m===p?T:1-T):r>O.y?(T=On(m.x,m.y,x.x,x.y,O.x,O.y),T=m===p?T:1-T):(T=On(m.x,m.y,x.x,x.y,t,r),T=m===p?T:1-T):T=On(m.x,m.y,x.x,x.y,t,r),h=h.set("offset",T),e=e.merge({scene:o.mergeIn(["layers",a,"holes",l],h)}),{updatedState:e}}static endDraggingHole(e,t,r){return e=this.updateDraggingHole(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.setIn(["scene","layers",t,"holes",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"holes",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"holes",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){let s=i.toJS(),{offsetA:o,offsetB:a,offset:l}=s;delete s.offsetA,delete s.offsetB,delete s.offset;let c=Ie({_unitA:o._unit,_unitB:a._unit});return e=e.mergeIn(["scene","layers",t,"holes",r],At(s)).mergeDeepIn(["scene","layers",t,"holes",r],Ie({offset:l,misc:c})),{updatedState:e}}}let xn=class V2{static create(e,t,r,i,s,o,a,l,c){let h=gi.acquireID(),f=e.catalog.factoryElement(r,{id:h,name:wc.generateName("items",e.catalog.getIn(["elements",r,"info","title"])),type:r,height:a,width:o,x:i,y:s,rotation:l,altitude:c});return e=e.setIn(["scene","layers",t,"items",h],f),{updatedState:e,item:f}}static select(e,t,r){return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"items",r).updatedState,{updatedState:e}}static remove(e,t,r){return e=this.unselect(e,t,r).updatedState,e=it.removeElement(e,t,"items",r).updatedState,e.getIn(["scene","groups"]).forEach(i=>e=mn.removeElement(e,i.id,t,"items",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"items",r).updatedState,{updatedState:e}}static selectToolDrawingItem(e,t){return e=e.merge({mode:Ar,drawingSupport:Ie({type:t})}),{updatedState:e}}static updateDrawingItem(e,t,r,i){if(e.hasIn(["drawingSupport","currentID"]))e=e.updateIn(["scene","layers",t,"items",e.getIn(["drawingSupport","currentID"])],s=>s.merge({x:r,y:i}));else{let{updatedState:s,item:o}=this.create(e,t,e.getIn(["drawingSupport","type"]),r,i,200,100,0,0);e=V2.select(s,t,o.id).updatedState,e=e.setIn(["drawingSupport","currentID"],o.id)}return{updatedState:e}}static endDrawingItem(e,t,r,i){return e=this.updateDrawingItem(e,t,r,i).updatedState,e=it.unselectAll(e,t).updatedState,e=e.merge({drawingSupport:Ie({type:e.drawingSupport.get("type")})}),{updatedState:e}}static beginDraggingItem(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"items",r]);return e=e.merge({mode:Gr,draggingSupport:Ie({layerID:t,itemID:r,startPointX:i,startPointY:s,originalX:o.x,originalY:o.y})}),{updatedState:e}}static updateDraggingItem(e,t,r){let{draggingSupport:i,scene:s}=e,o=i.get("layerID"),a=i.get("itemID"),l=i.get("startPointX"),c=i.get("startPointY"),h=i.get("originalX"),f=i.get("originalY"),p=l-t,d=c-r,m=s.getIn(["layers",o,"items",a]);return m=m.merge({x:h-p,y:f-d}),e=e.merge({scene:s.mergeIn(["layers",o,"items",a],m)}),{updatedState:e}}static endDraggingItem(e,t,r){return e=this.updateDraggingItem(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static beginRotatingItem(e,t,r,i,s){return e=e.merge({mode:Di,rotatingSupport:Ie({layerID:t,itemID:r})}),{updatedState:e}}static updateRotatingItem(e,t,r){let{rotatingSupport:i,scene:s}=e,o=i.get("layerID"),a=i.get("itemID"),l=e.getIn(["scene","layers",o,"items",a]),c=t-l.x,h=r-l.y,f=Math.atan2(h,c)*180/Math.PI-90;return-5<f&&f<5&&(f=0),-95<f&&f<-85&&(f=-90),-185<f&&f<-175&&(f=-180),85<f&&f<90&&(f=90),-270<f&&f<-265&&(f=90),l=l.merge({rotation:f}),e=e.merge({scene:s.mergeIn(["layers",o,"items",a],l)}),{updatedState:e}}static endRotatingItem(e,t,r){return e=this.updateRotatingItem(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"items",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"items",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"items",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"items",r],i),{updatedState:e}}static setJsAttributes(e,t,r,i){return i=At(i),this.setAttributes(e,t,r,i)}},mn=class hh{static select(e,t){let r=e.getIn(["scene","groups",t,"elements"]);e=qt.setAlterate(e).updatedState,r.entrySeq().forEach(([s,o])=>{e=it.unselectAll(e,s).updatedState;let a=o.get("lines"),l=o.get("holes"),c=o.get("items"),h=o.get("areas");a&&a.forEach(f=>{e=Jt.select(e,s,f).updatedState}),l&&l.forEach(f=>{e=pn.select(e,s,f).updatedState}),c&&c.forEach(f=>{e=xn.select(e,s,f).updatedState}),h&&h.forEach(f=>{e=Fs.select(e,s,f).updatedState})}),e=qt.setAlterate(e).updatedState;let i=e.getIn(["scene","groups"]).map(s=>s.set("selected",!1));return e=e.setIn(["scene","groups"],i).setIn(["scene","groups",t,"selected"],!0),{updatedState:e}}static unselect(e,t){return e=e.getIn(["scene","groups",t,"elements"]).reduce((s,o,a)=>it.unselectAll(s,a).updatedState,e).setIn(["scene","groups",t,"selected"],!1),{updatedState:e}}static create(e){let t=gi.acquireID();return e=e.setIn(["scene","groups",t],new Sf({id:t,name:t})),{updatedState:e}}static createFromSelectedElements(e){let t=gi.acquireID();return e=e.setIn(["scene","groups",t],new Sf({id:t,name:t})),e.getIn(["scene","layers"]).forEach(r=>{let i=r.get("id"),s={lines:r.get("lines").filter(o=>o.get("selected")),items:r.get("items").filter(o=>o.get("selected")),holes:r.get("holes").filter(o=>o.get("selected")),areas:r.get("areas").filter(o=>o.get("selected"))};for(let o in s)s[o].forEach(a=>e=this.addElement(e,t,i,o,a.get("id")).updatedState)}),{updatedState:e}}static addElement(e,t,r,i,s){let o=e.getIn(["scene","groups",t,"elements",r,i])||He();return o.contains(s)||(e=e.setIn(["scene","groups",t,"elements",r,i],o.push(s)),e=this.reloadBaricenter(e,t).updatedState),{updatedState:e}}static setBarycenter(e,t,r,i){return typeof r<"u"&&(e=e.setIn(["scene","groups",t,"x"],r)),typeof i<"u"&&(e=e.setIn(["scene","groups",t,"y"],i)),{updatedState:e}}static reloadBaricenter(e,t){let r=e.getIn(["scene","groups",t,"elements"]),i=0,s=0,o=0;return r.entrySeq().forEach(([a,l])=>{e=it.unselectAll(e,a).updatedState;let c=l.get("lines"),h=l.get("holes"),f=l.get("items"),p=l.get("areas");c&&c.forEach(d=>{let m=e.getIn(["scene","layers",a,"lines",d,"vertices"]).map(b=>e.getIn(["scene","layers",a,"vertices",b])),{x,y:v}=m.get(0),{x:_,y:w}=m.get(1),{x:E,y:S}=l3(x,v,_,w);i+=E,s+=S,o++}),h&&h.forEach(d=>{let m=e.getIn(["scene","layers",a,"holes",d]),x=e.getIn(["scene","layers",a,"lines",m.line,"vertices"]).map(A=>e.getIn(["scene","layers",a,"vertices",A])),{x:v,y:_}=x.get(0),{x:w,y:E}=x.get(1),{x:S,y:b}=vc(v,_,w,E,m.offset*Cn(v,_,w,E));i+=S,s+=b,o++}),f&&f.forEach(d=>{let{x:m,y:x}=e.getIn(["scene","layers",a,"items",d]);i+=m,s+=x,o++}),p&&p.forEach(d=>{let m=e.getIn(["scene","layers",a,"areas",d,"vertices"]).map(_=>e.getIn(["scene","layers",a,"vertices",_])).toJS(),{x,y:v}=c3(m);i+=x,s+=v,o++})}),o&&(e=this.setBarycenter(e,t,i/o,s/o).updatedState),{updatedState:e}}static removeElement(e,t,r,i,s){let o=e.getIn(["scene","groups",t,"elements",r,i]);return!o||!o.contains(s)?{updatedState:e}:(e=e.setIn(["scene","groups",t,"elements",r,i],o.filterNot(a=>a===s)),{updatedState:e})}static setAttributes(e,t,r){return e=e.mergeIn(["scene","groups",t],r),{updatedState:e}}static setProperties(e,t,r){return e=e.mergeIn(["scene","groups",t,"properties"],r),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","groups",t]),{updatedState:e}}static removeAndDeleteElements(e,t){return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([i,s])=>{e=it.unselectAll(e,i).updatedState;let o=s.get("lines"),a=s.get("holes"),l=s.get("items");s.get("areas"),o&&o.forEach(c=>{e=Jt.remove(e,i,c).updatedState,e=it.detectAndUpdateAreas(e,i).updatedState}),a&&a.forEach(c=>{e=pn.remove(e,i,c).updatedState}),l&&l.forEach(c=>{e=xn.remove(e,i,c).updatedState})}),e=e.deleteIn(["scene","groups",t]),{updatedState:e}}static translate(e,t,r,i){let s=r-e.getIn(["scene","groups",t,"x"]),o=i-e.getIn(["scene","groups",t,"y"]);return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([l,c])=>{let h=c.get("lines"),f=c.get("items");if(h){let p={};h.forEach(d=>{let m=e.getIn(["scene","layers",l,"lines",d]);p[m.vertices.get(0)]||(p[m.vertices.get(0)]=e.getIn(["scene","layers",l,"vertices",m.vertices.get(0)])),p[m.vertices.get(1)]||(p[m.vertices.get(1)]=e.getIn(["scene","layers",l,"vertices",m.vertices.get(1)]))});for(let d in p){let{x:m,y:x}=p[d];e=cn.setAttributes(e,l,d,Ie({x:m+s,y:x+o})).updatedState}for(let d in p)e=cn.beginDraggingVertex(e,l,d).updatedState,e=cn.endDraggingVertex(e).updatedState}f&&(e=f.map(p=>e.getIn(["scene","layers",l,"items",p])).reduce((p,d)=>{let{x:m,y:x}=d;return xn.setAttributes(p,l,d.id,Ie({x:m+s,y:x+o})).updatedState},e)),e=it.detectAndUpdateAreas(e,l).updatedState}),e=this.setBarycenter(e,t,r,i).updatedState,e=hh.select(e,t).updatedState,{updatedState:e}}static rotate(e,t,r){let{x:i,y:s,rotation:o}=e.getIn(["scene","groups",t]),a=r-o;return e=hh.setAttributes(e,t,Ie({rotation:r})).updatedState,e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([c,h])=>{let f=h.get("lines"),p=h.get("items");if(f){let d={};f.forEach(m=>{let x=e.getIn(["scene","layers",c,"lines",m]);d[x.vertices.get(0)]||(d[x.vertices.get(0)]=e.getIn(["scene","layers",c,"vertices",x.vertices.get(0)])),d[x.vertices.get(1)]||(d[x.vertices.get(1)]=e.getIn(["scene","layers",c,"vertices",x.vertices.get(1)]))});for(let m in d){let{x,y:v}=d[m],{x:_,y:w}=tg(x,v,i,s,a);e=cn.setAttributes(e,c,m,Ie({x:_,y:w})).updatedState}for(let m in d)e=cn.beginDraggingVertex(e,c,m).updatedState,e=cn.endDraggingVertex(e).updatedState}p&&(e=p.map(d=>e.getIn(["scene","layers",c,"items",d])).reduce((d,m)=>{let{x,y:v,rotation:_}=m,{x:w,y:E}=tg(x,v,i,s,a);return xn.setAttributes(d,c,m.id,Ie({x:w,y:E,rotation:_+a})).updatedState},e)),e=it.detectAndUpdateAreas(e,c).updatedState}),e=hh.select(e,t).updatedState,{updatedState:e}}},Jt=class zr{static create(e,t,r,i,s,o,a,l){let c=gi.acquireID(),{updatedState:h,vertex:f}=cn.add(e,t,i,s,"lines",c),{updatedState:p,vertex:d}=cn.add(h,t,o,a,"lines",c);e=p;let m=e.catalog.factoryElement(r,{id:c,name:wc.generateName("lines",e.catalog.getIn(["elements",r,"info","title"])),vertices:He([f.id,d.id]),type:r},l);return e=e.setIn(["scene","layers",t,"lines",c],m),{updatedState:e,line:m}}static select(e,t,r,i){i||(e=it.select(e,t).updatedState);let s=e.getIn(["scene","layers",t,"lines",r]);return e=it.selectElement(e,t,"lines",r).updatedState,e=it.selectElement(e,t,"vertices",s.vertices.get(0)).updatedState,e=it.selectElement(e,t,"vertices",s.vertices.get(1)).updatedState,{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"lines",r]);return i&&(e=this.unselect(e,t,r).updatedState,i.holes.forEach(s=>e=pn.remove(e,t,s).updatedState),e=it.removeElement(e,t,"lines",r).updatedState,i.vertices.forEach(s=>e=cn.remove(e,t,s,"lines",r).updatedState),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"lines",r).updatedState)),{updatedState:e}}static unselect(e,t,r){let i=e.getIn(["scene","layers",t,"lines",r]);return i&&(e=it.unselect(e,t,"vertices",i.vertices.get(0)).updatedState,e=it.unselect(e,t,"vertices",i.vertices.get(1)).updatedState,e=it.unselect(e,t,"lines",r).updatedState),{updatedState:e}}static split(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"lines",r]),a=e.getIn(["scene","layers",t,"vertices",o.vertices.get(0)]),l=e.getIn(["scene","layers",t,"vertices",o.vertices.get(1)]),{x:c,y:h}=a,{x:f,y:p}=l,{updatedState:d,line:m}=zr.create(e,t,o.type,c,h,i,s,o.get("properties")),{updatedState:x,line:v}=zr.create(d,t,o.type,f,p,i,s,o.get("properties"));e=x;let _=On(c,h,f,p,i,s),w=pc(a,l);return o.holes.forEach(S=>{let b=e.getIn(["scene","layers",t,"holes",S]),A=b.offset;if(w.x===f&&w.y===p&&(_=1-_,A=1-b.offset),A<_){let q=A/_;w.x===f&&w.y===p&&(q=1-q),e=pn.create(e,t,b.type,m.id,q,b.properties).updatedState}else{let q=(A-_)/(1-_);w.x===f&&w.y===p&&(q=1-q),e=pn.create(e,t,b.type,v.id,q,b.properties).updatedState}}),e.getIn(["scene","groups"]).filter(S=>{const b=S.getIn(["elements",t,"lines"]);return b&&b.contains(r)}).forEach(S=>{e=mn.addElement(e,S.id,t,"lines",m.id).updatedState,e=mn.addElement(e,S.id,t,"lines",v.id).updatedState}),e=zr.remove(e,t,r).updatedState,{updatedState:e,lines:He([m,v])}}static addFromPoints(e,t,r,i,s,o){i=He(i).sort(({x:c,y:h},{x:f,y:p})=>c===f?h-p:c-f);let a=i.zip(i.skip(1)).filterNot(([{x:c,y:h},{x:f,y:p}])=>c===f&&h===p),l=[];return a.forEach(([{x:c,y:h},{x:f,y:p}])=>{let{updatedState:d,line:m}=this.create(e,t,r,c,h,f,p,s);e=d,o&&o.forEach(x=>{let{x:v,y:_}=x.offsetPosition;if(e3(c,h,f,p,v,_)){let w=On(c,h,f,p,v,_);w>=0&&w<=1&&(e=pn.create(e,t,x.hole.type,m.id,w,x.hole.properties).updatedState)}}),l.push(m)}),{updatedState:e,lines:He(l)}}static createAvoidingIntersections(e,t,r,i,s,o,a,l,c){let h=[{x:i,y:s},{x:o,y:a}];e=e.getIn(["scene","layers",t,"lines"]).reduce((d,m)=>{var E,S;let[x,v]=m.vertices.map(b=>d.getIn(["scene","layers",t,"vertices"]).get(b)).toArray(),_=jr(x,h[0])||jr(x,h[1])||jr(v,h[0])||jr(v,h[1]),w=Qy(h[0],h[1],x,v);if(w.type==="colinear"){c||(c=[]);const b=rl(h);d.getIn(["scene","layers",t,"lines",m.id,"holes"]).forEach(A=>{let q=d.getIn(["scene","layers",t,"holes",A]),O=Cn(x.x,x.y,v.x,v.y),T=jr(b[1],m.vertices.get(1))?1-q.offset:q.offset,I=vc(x.x,x.y,v.x,v.y,O*T);c.push({hole:q,offsetPosition:I})}),d=this.remove(d,t,m.id).updatedState,h.push(x,v)}return w.type==="intersecting"&&!_&&(d=this.split(d,t,m.id,((E=w.point)==null?void 0:E.x)??0,((S=w.point)==null?void 0:S.y)??0).updatedState,h.push(w.point??{x:0,y:0})),d},e);let{updatedState:f,lines:p}=zr.addFromPoints(e,t,r,h,l,c);return{updatedState:f,lines:p}}static replaceVertex(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"lines",r,"vertices",i]);e=cn.remove(e,t,a,"lines",r).updatedState;let{updatedState:l,vertex:c}=cn.add(e,t,s,o,"lines",r);return e=l,e=e.setIn(["scene","layers",t,"lines",r,"vertices",i],c.id),e=e.setIn(["scene","layers",t,"lines",r],e.getIn(["scene","layers",t,"lines",r])),{updatedState:e,line:e.getIn(["scene","layers",t,"lines",r]),vertex:c}}static selectToolDrawingLine(e,t){return e=e.merge({mode:Tr,drawingSupport:Ie({type:t})}),{updatedState:e}}static beginDrawingLine(e,t,r,i){let s=bf(e.scene,He(),e.snapMask),o=null;e.snapMask&&!e.snapMask.isEmpty()&&(o=mi(s,r,i,e.snapMask),o&&({x:r,y:i}=o.point),s=s.withMutations(h=>{let f,p,d;({a:f,b:p,c:d}=gc(i)),xc(h,f,p,d,10,3,null),{a:f,b:p,c:d}=_c(r),xc(h,f,p,d,10,3,null)}));let a=e.get("drawingSupport").set("layerID",t);e=it.unselectAll(e,t).updatedState;let{updatedState:l,line:c}=zr.create(e,t,a.get("type"),r,i,r,i);return e=zr.select(l,t,c.id).updatedState,e=e.merge({mode:Jn,snapElements:s,activeSnapElement:o?o.snap:null,drawingSupport:a}),{updatedState:e}}static updateDrawingLine(e,t,r){let i=null;e.snapMask&&!e.snapMask.isEmpty()&&(i=mi(e.snapElements,t,r,e.snapMask),i&&({x:t,y:r}=i.point));let s=e.getIn(["drawingSupport","layerID"]),o=e.getIn(["scene","layers",s,"selected","lines"]).first(),{updatedState:a}=zr.replaceVertex(e,s,o,1,t,r);return e=a,e=this.select(e,s,o).updatedState,e=e.merge({activeSnapElement:i?i.snap:null}),{updatedState:e}}static endDrawingLine(e,t,r){if(e.snapMask&&!e.snapMask.isEmpty()){let c=mi(e.snapElements,t,r,e.snapMask);c&&({x:t,y:r}=c.point)}const i=e.getIn(["drawingSupport","layerID"]),s=e.getIn(["scene","layers",i]),o=e.getIn(["scene","layers",i,"selected","lines"]).first(),a=e.getIn(["scene","layers",i,"lines",o]),l=s.vertices.get(a.vertices.get(0));return e=zr.remove(e,i,o).updatedState,e=zr.createAvoidingIntersections(e,i,a.type,l.x,l.y,t,r).updatedState,e=it.detectAndUpdateAreas(e,i).updatedState,e=e.merge({mode:Tr,snapElements:He(),activeSnapElement:null}),{updatedState:e}}static beginDraggingLine(e,t,r,i,s){let o=bf(e.scene,He(),e.snapMask),a=e.scene.layers.get(t),l=a.lines.get(r),c=a.vertices.get(l.vertices.get(0)),h=a.vertices.get(l.vertices.get(1));return e=e.merge({mode:Vr,snapElements:o,draggingSupport:Ie({layerID:t,lineID:r,startPointX:i,startPointY:s,startVertex0X:c.x,startVertex0Y:c.y,startVertex1X:h.x,startVertex1Y:h.y})}),{updatedState:e}}static updateDraggingLine(e,t,r){let i=e.draggingSupport,s=e.snapElements,o=i.get("layerID"),a=i.get("lineID"),l=t-i.get("startPointX"),c=r-i.get("startPointY"),h=i.get("startVertex0X")+l,f=i.get("startVertex0Y")+c,p=i.get("startVertex1X")+l,d=i.get("startVertex1Y")+c,m=null,x=null,v=null;e.snapMask&&!e.snapMask.isEmpty()&&(x=mi(s,h,f,e.snapMask),v=mi(s,p,d,e.snapMask));let _=0,w=0;return x&&v?x.point.distance<v.point.distance?(_=x.point.x-h,w=x.point.y-f,m=x.snap):(_=v.point.x-p,w=v.point.y-d,m=v.snap):(x&&(_=x.point.x-h,w=x.point.y-f,m=x.snap),v&&(_=v.point.x-p,w=v.point.y-d,m=v.snap)),h+=_,f+=w,p+=_,d+=w,e=e.merge({activeSnapElement:m,scene:e.scene.updateIn(["layers",o],E=>E.withMutations(S=>{let b=S.getIn(["lines",a,"vertices"]);return S.updateIn(["vertices",b.get(0)],A=>A.merge({x:h,y:f})),S.updateIn(["vertices",b.get(1)],A=>A.merge({x:p,y:d})),S}))}),{updatedState:e}}static endDraggingLine(e,t,r){let{draggingSupport:i}=e,s=i.get("layerID"),o=e.scene.layers.get(s),a=i.get("lineID"),l=o.lines.get(a),c=o.vertices.get(l.vertices.get(0)),h=o.vertices.get(l.vertices.get(1)),f=ff(c,h),p=pc(c,h),d=mc(p,f),m=Math.atan2(f.y-p.y,f.x-p.x),x=[];o.lines.get(a).holes.forEach(q=>{let O=o.holes.get(q),T=d*O.offset,I={x:T*Math.cos(m)+p.x,y:T*Math.sin(m)+p.y};x.push({hole:O,offsetPosition:I})});let v=t-i.get("startPointX"),_=r-i.get("startPointY"),w=i.get("startVertex0X")+v,E=i.get("startVertex0Y")+_,S=i.get("startVertex1X")+v,b=i.get("startVertex1Y")+_;if(e.snapMask&&!e.snapMask.isEmpty()){let q=mi(e.snapElements,w,E,e.snapMask),O=mi(e.snapElements,S,b,e.snapMask),T=0,I=0;q&&O?q.point.distance<O.point.distance?(T=q.point.x-w,I=q.point.y-E):(T=O.point.x-S,I=O.point.y-b):(q&&(T=q.point.x-w,I=q.point.y-E),O&&(T=O.point.x-S,I=O.point.y-b)),w+=T,E+=I,S+=T,b+=I}let A=e.getIn(["scene","groups"]).filter(q=>{const O=q.getIn(["elements",s,"lines"]);return O&&O.contains(a)});if(e=it.mergeEqualsVertices(e,s,l.vertices.get(0)).updatedState,e=it.mergeEqualsVertices(e,s,l.vertices.get(1)).updatedState,e=zr.remove(e,s,a).updatedState,!jr({x:w,y:E},{x:S,y:b})){let q=zr.createAvoidingIntersections(e,s,l.type,w,E,S,b,l.properties,x);e=q.updatedState,q.lines.forEach(O=>{A.forEach(T=>{e=mn.addElement(e,T.id,s,"lines",O.id).updatedState})})}return e=it.detectAndUpdateAreas(e,s).updatedState,e=e.merge({mode:sn,draggingSupport:null,activeSnapElement:null,snapElements:He()}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"lines",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"lines",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"lines",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){let s=i.toJS(),{vertexOne:o,vertexTwo:a,lineLength:l}=s;return delete s.vertexOne,delete s.vertexTwo,delete s.lineLength,e=e.mergeIn(["scene","layers",t,"lines",r],At(s)).mergeIn(["scene","layers",t,"vertices",o.id],{x:o.x,y:o.y}).mergeIn(["scene","layers",t,"vertices",a.id],{x:a.x,y:a.y}).mergeIn(["scene","layers",t,"lines",r,"misc"],Ie({_unitLength:l._unit})),e=it.mergeEqualsVertices(e,t,o.id).updatedState,o.x!=a.x&&o.y!=a.y&&(e=it.mergeEqualsVertices(e,t,a.id).updatedState),e=it.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static setVerticesCoords(e,t,r,i,s,o,a){let l=e.getIn(["scene","layers",t,"lines",r]);return e=cn.setAttributes(e,t,l.vertices.get(0),Ie({x:i,y:s})).updatedState,e=cn.setAttributes(e,t,l.vertices.get(1),Ie({x:o,y:a})).updatedState,{updatedState:e}}},cn=class{static add(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"vertices"]).find(l=>jr(l,{x:r,y:i}));return a?a=a.update(s,l=>l.push(o)):a=new ig({id:gi.acquireID(),name:"Vertex",x:r,y:i,[s]:He([o])}),e=e.setIn(["scene","layers",t,"vertices",a.id],a),{updatedState:e,vertex:a}}static setAttributes(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"vertices",r],i),{updatedState:e}}static addElement(e,t,r,i,s){return e=e.updateIn(["scene","layers",t,"vertices",r,i],o=>o.push(s)),{updatedState:e}}static removeElement(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"vertices",r,i]).findIndex(a=>a===s);return o!==-1&&(e=e.updateIn(["scene","layers",t,"vertices",r,i],a=>a.remove(o))),{updatedState:e}}static select(e,t,r){return e=e.setIn(["scene","layers",t,"vertices",r,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected","vertices"],i=>i.push(r)),{updatedState:e}}static unselect(e,t,r){return e=e.setIn(["scene","layers",t,"vertices",r,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected","vertices"],i=>i.filter(s=>s.id!==r)),{updatedState:e}}static remove(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"vertices",r]);return a&&(i&&s&&(a=a.update(i,c=>{let h=c.findIndex(f=>s===f);return c.delete(h)})),(a.areas.size||a.lines.size)&&!o?e=e.setIn(["scene","layers",t,"vertices",r],a):e=e.deleteIn(["scene","layers",t,"vertices",r])),{updatedState:e}}static beginDraggingVertex(e,t,r){let i=bf(e.scene,He(),e.snapMask);return e=e.merge({mode:Hr,snapElements:i,draggingSupport:Ie({layerID:t,vertexID:r,previousMode:e.get("mode")})}),{updatedState:e}}static updateDraggingVertex(e,t,r){let{draggingSupport:i,snapElements:s,scene:o}=e,a=null;e.snapMask&&!e.snapMask.isEmpty()&&(a=mi(s,t,r,e.snapMask),a&&({x:t,y:r}=a.point));let l=i.get("layerID"),c=i.get("vertexID");return e=e.merge({activeSnapElement:a?a.snap:null,scene:o.mergeIn(["layers",l,"vertices",c],{x:t,y:r})}),{updatedState:e}}static endDraggingVertex(e){let{draggingSupport:t}=e,r=t.get("layerID"),i=t.get("vertexID"),s=e.getIn(["scene","layers",r,"vertices",i,"lines"]);return s&&(e=s.reduce((o,a)=>{if(!o.getIn(["scene","layers",r,"lines",a]))return o;let l=o.getIn(["scene","layers",r,"lines",a,"vertices",0]),c=o.getIn(["scene","layers",r,"lines",a,"vertices",1]),h=l===i?c:l,f=o.getIn(["scene","layers",r,"vertices",h]),p=o.getIn(["scene","layers",r,"vertices",i]),d=[],m=rl([f,p]);o.getIn(["scene","layers",r,"lines",a,"holes"]).forEach(w=>{let E=o.getIn(["scene","layers",r,"holes",w]),S=Cn(f.x,f.y,p.x,p.y),b=jr(m[1],o.getIn(["scene","layers",r,"lines",a,"vertices",1]))?1-E.offset:E.offset,A=vc(f.x,f.y,p.x,p.y,S*b);d.push({hole:E,offsetPosition:A})});let x=o.getIn(["scene","layers",r,"lines",a,"type"]),v=o.getIn(["scene","layers",r,"lines",a,"properties"]),_=o.getIn(["scene","groups"]).filter(w=>{const E=w.getIn(["elements",r,"lines"]);return E&&E.contains(a)});if(o=it.removeZeroLengthLines(o,r).updatedState,o=it.mergeEqualsVertices(o,r,i).updatedState,o=Jt.remove(o,r,a).updatedState,!jr(f,p)){let w=Jt.createAvoidingIntersections(o,r,x,f.x,f.y,p.x,p.y,v,d);o=w.updatedState,w.lines.forEach(E=>{_.forEach(S=>{o=mn.addElement(o,S.id,r,"lines",E.id).updatedState})})}return o},e)),e=it.detectAndUpdateAreas(e,r).updatedState,e=e.merge({mode:t.get("previousMode"),draggingSupport:null,activeSnapElement:null,snapElements:He()}),{updatedState:e}}},Fs=class H2{static getSurfaceLines(e,t,r){const i=e.getIn(["scene","layers",t,"areas",r]),s=e.getIn(["scene","layers",t,"lines"]),o=e.getIn(["scene","layers",t,"vertices"]);let a=Eo();return i.get("vertices").forEach(l=>{o.get(l).get("lines").forEach(h=>{s.get(h).get("type")==="surface"&&(a=a.add(h))})}),a}static add(e,t,r,i,s){let o,a=e.getIn(["scene","layers",t]);return a=a.withMutations(l=>{const c=gi.acquireID(),h=i.map(f=>cn.add(e,t,f.x,f.y,"areas",c).vertex.id);o=s.factoryElement(r,{id:c,name:wc.generateName("areas",s.getIn(["elements",r,"info","title"])),type:r,prototype:"areas",vertices:h}),l.setIn(["areas",c],o)}),e=e.setIn(["scene","layers",t],a),{updatedState:e,area:o}}static select(e,t,r){let i=H2.getSurfaceLines(e,t,r);return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"areas",r).updatedState,i.size>0&&i.forEach(s=>{e=Jt.select(e,t,s,!0).updatedState}),{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"areas",r]);return i.get("selected")===!0&&(e=this.unselect(e,t,r).updatedState),i.vertices.forEach(s=>{e=cn.remove(e,t,s,"areas",r).updatedState}),e=e.deleteIn(["scene","layers",t,"areas",r]),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"areas",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"areas",r).updatedState,{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"areas",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"areas",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"areas",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e){return{updatedState:e}}};const Dg=(n,e)=>n.size===e.size&&n.isSuperset(e)&&n.isSubset(e);let it=class{static create(e,t,r){let i=gi.acquireID();t=t||`layer ${i}`,r=r||0;let s=new yf({id:i,name:t,altitude:r});return e=e.setIn(["scene","selectedLayer"],i),e=e.setIn(["scene","layers",i],s),{updatedState:e}}static select(e,t){return e.get("alterate")||(e=qt.unselectAll(e).updatedState),e=e.setIn(["scene","selectedLayer"],t),{updatedState:e}}static selectElement(e,t,r,i){return e=e.setIn(["scene","layers",t,r,i,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected",r],s=>s.push(i)),{updatedState:e}}static unselect(e,t,r,i){return e=e.setIn(["scene","layers",t,r,i,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected",r],s=>s.filter(o=>o.id===i)),{updatedState:e}}static unselectAll(e,t){let{lines:r,holes:i,items:s,areas:o}=e.getIn(["scene","layers",t]);return r&&r.forEach(a=>{e=Jt.unselect(e,t,a.id).updatedState}),i&&i.forEach(a=>{e=pn.unselect(e,t,a.id).updatedState}),s&&s.forEach(a=>{e=xn.unselect(e,t,a.id).updatedState}),o&&o.forEach(a=>{e=Fs.unselect(e,t,a.id).updatedState}),{updatedState:e}}static setProperties(e,t,r){return e=e.mergeIn(["scene","layers",t],r),e=e.updateIn(["scene","layers"],i=>i.sort((s,o)=>s.altitude!==o.altitude?s.altitude-o.altitude:s.order-o.order)),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","layers",t]),e=e.setIn(["scene","selectedLayer"],e.scene.selectedLayer!==t?e.scene.selectedLayer:e.scene.layers.first().id),{updatedState:e}}static removeElement(e,t,r,i){return e=e.deleteIn(["scene","layers",t,r,i]),{updatedState:e}}static detectAndUpdateAreas(e,t){let r=[],i,s={},o={};e.getIn(["scene","layers",t,"vertices"]).forEach(d=>{let x=r.push([d.x,d.y])-1;s[d.id]=x,o[x]=d.id}),i=e.getIn(["scene","layers",t,"lines"]).map(d=>d.vertices.map(m=>s[m]).toArray());const a=R3(r,i);let l=He(a).map(d=>He(d.map(m=>o[m])));l=l.map(d=>P3(d.map(m=>e.getIn(["scene","layers",t,"vertices",m])))?d.reverse():d);const c=[];e.getIn(["scene","layers",t,"areas"]).forEach(d=>{l.some(x=>Dg(x,d.vertices))||(e=Fs.remove(e,t,d.id).updatedState)}),l.forEach((d,m)=>{const x=e.getIn(["scene","layers",t,"areas"]).find(v=>Dg(v.vertices,d));if(x)c[m]=x.id,e=e.setIn(["scene","layers",t,"areas",c[m],"holes"],He());else{const v=d.map(w=>e.getIn(["scene","layers",t,"vertices",w])),_=Fs.add(e,t,"area",v,e.catalog);c[m]=_.area.id,e=_.updatedState}});let h=c.map(d=>{let m=e.getIn(["scene","layers",t,"areas",d]).vertices.map(x=>{let{x:v,y:_}=e.getIn(["scene","layers",t,"vertices",x]);return He([v,_])});return{id:d,vertices:m}}),f,p;for(f=0;f<h.length;f++){let d=He(),m=h[f].vertices.flatten().toArray();for(p=0;p<h.length;p++)f!==p&&s3(m,h[p].vertices.get(0).get(0),h[p].vertices.get(0).get(1))&&(d=d.push(h[p].id));e=e.setIn(["scene","layers",t,"areas",h[f].id,"holes"],d)}return c.forEach(d=>{let m=new Set,x=e.getIn(["scene","layers",t,"areas",d,"holes"]);x.forEach(v=>{e.getIn(["scene","layers",t,"areas",v,"holes"]).forEach(w=>{x.indexOf(w)!==-1&&m.add(w)})}),m.forEach(v=>{x=x.remove(x.indexOf(v))}),e=e.setIn(["scene","layers",t,"areas",d,"holes"],x)}),{updatedState:e}}static removeZeroLengthLines(e,t){return{updatedState:e.getIn(["scene","layers",t,"lines"]).reduce((i,s)=>{let o=s.getIn(["vertices",0]),a=s.getIn(["vertices",1]),l=i.getIn(["scene","layers",t,"vertices",o]),c=i.getIn(["scene","layers",t,"vertices",a]);return mc(l,c)===0&&(i=Jt.remove(i,t,s.id).updatedState),i},e)}}static mergeEqualsVertices(e,t,r){let i=e.getIn(["scene","layers",t,"vertices",r]),s=e.getIn(["scene","layers",t,"vertices"]).filter(o=>o.id!==r&&jr(i,o));return s.isEmpty()?{updatedState:e}:(s.forEach(o=>{let a=o.lines.reduce((c,h)=>(c=c.updateIn(["scene","layers",t,"lines",h,"vertices"],f=>{if(f)return f.map(p=>p===o.id?r:p)}),c=cn.addElement(c,t,r,"lines",h).updatedState,c),e),l=o.areas.reduce((c,h)=>(c=c.updateIn(["scene","layers",t,"areas",h,"vertices"],f=>{if(f)return f.map(p=>p===o.id?r:p)}),c=cn.addElement(c,t,r,"areas",h).updatedState,c),a);e=cn.remove(l,t,o.id,null,null,!0).updatedState}),{updatedState:e})}static setPropertiesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.setProperties(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.setProperties(e,t,s,r).updatedState),i.areas.forEach(s=>e=Fs.setProperties(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.setProperties(e,t,s,r).updatedState),{updatedState:e}}static updatePropertiesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.updateProperties(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.updateProperties(e,t,s,r).updatedState),i.areas.forEach(s=>e=Fs.updateProperties(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.updateProperties(e,t,s,r).updatedState),{updatedState:e}}static setAttributesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.setAttributes(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.setAttributes(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.setAttributes(e,t,s,r).updatedState),{updatedState:e}}};class Tc{static create(e,t){let r=gi.acquireID();return e=e.setIn(["scene","guides","horizontal",r],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","horizontal",t]),{updatedState:e}}}class Ac{static create(e,t){let r=gi.acquireID();return e=e.setIn(["scene","guides","vertical",r],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","vertical",t]),{updatedState:e}}}class qt{static setAlterate(e){return{updatedState:e.set("alterate",!e.alterate)}}static openCatalog(e){return e=this.setMode(e,cf).updatedState,{updatedState:e}}static newProject(e){return e=new Sc({viewer2D:e.get("viewer2D")}),{updatedState:e}}static loadProject(e,t){return e=new Sc({scene:t,catalog:e.catalog.toJS()}),{updatedState:e}}static setProperties(e,t,r){return e=it.setPropertiesOnSelected(e,t,r).updatedState,{updatedState:e}}static updateProperties(e,t,r){return e=it.updatePropertiesOnSelected(e,t,r).updatedState,{updatedState:e}}static setItemsAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static setLinesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static setHolesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static unselectAll(e){return e.getIn(["scene","layers"]).forEach(({id:t})=>{e=it.unselectAll(e,t).updatedState}),e.getIn(["scene","groups"]).forEach(t=>{e=mn.unselect(e,t.get("id")).updatedState}),{updatedState:e}}static remove(e){let t=e.getIn(["scene","selectedLayer"]),{lines:r,holes:i,items:s}=e.getIn(["scene","layers",t,"selected"]);return e=it.unselectAll(e,t).updatedState,r.forEach(o=>{e=Jt.remove(e,t,o).updatedState}),i.forEach(o=>{e=pn.remove(e,t,o).updatedState}),s.forEach(o=>{e=xn.remove(e,t,o).updatedState}),e=it.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static undo(e){let t=e.sceneHistory;return e.scene===t.last&&t.list.size>1&&(t=bg(t)),e=e.merge({mode:sn,scene:t.last,sceneHistory:bg(t)}),{updatedState:e}}static redo(e){let t=e.sceneHistory;return e.scene===t.last&&t.redoList.size>0&&(t=V3(t)),e=e.merge({mode:sn,scene:t.last,sceneHistory:t}),{updatedState:e}}static rollback(e){let t=e.sceneHistory;return!t.last&&t.list.isEmpty()?{updatedState:e}:(e=this.unselectAll(e).updatedState,e=e.merge({mode:sn,scene:t.last,sceneHistory:on(t,t.last),snapElements:He(),activeSnapElement:null,drawingSupport:Ie(),draggingSupport:Ie(),rotatingSupport:Ie()}),{updatedState:e})}static setProjectProperties(e,t){let r=e.scene.merge(t);return e=e.merge({mode:sn,scene:r}),{updatedState:e}}static openProjectConfigurator(e){return e=e.merge({mode:Z0}),{updatedState:e}}static initCatalog(e,t){return e=e.set("catalog",new Ef(t)),{updatedState:e}}static updateMouseCoord(e,t){return e=e.set("mouse",Ie(t)),{updatedState:e}}static updateZoomScale(e,t){return e=e.set("zoom",t),{updatedState:e}}static toggleSnap(e,t){return e=e.set("snapMask",t),{updatedState:e}}static throwError(e,t){return e=e.set("errors",e.get("errors").push({date:Date.now(),error:t})),{updatedState:e}}static throwWarning(e,t){return e=e.set("warnings",e.get("warnings").push({date:Date.now(),warning:t})),{updatedState:e}}static copyProperties(e,t){return e=e.set("clipboardProperties",t),{updatedState:e}}static pasteProperties(e){return e=this.updateProperties(e,e.getIn(["scene","selectedLayer"]),e.get("clipboardProperties")).updatedState,{updatedState:e}}static pushLastSelectedCatalogElementToHistory(e,t){let r=e.selectedElementsHistory,i=r.findIndex(s=>s.name===t.name);return i!==-1&&(r=r.splice(i,1)),r=r.splice(0,0,t),e=e.set("selectedElementsHistory",r),{updatedState:e}}static changeCatalogPage(e,t,r){return e=e.setIn(["catalog","page"],r).updateIn(["catalog","path"],i=>i.push(t)),{updatedState:e}}static goBackToCatalogPage(e,t){let r=e.catalog.path.findIndex(i=>i===t);return e=e.setIn(["catalog","page"],t).updateIn(["catalog","path"],i=>i.take(r)),{updatedState:e}}static setMode(e,t){return e=e.set("mode",t),{updatedState:e}}static addHorizontalGuide(e,t){return e=Tc.create(e,t).updatedState,{updatedState:e}}static addVerticalGuide(e,t){return e=Ac.create(e,t).updatedState,{updatedState:e}}static addCircularGuide(e,t,r,i){return console.log("adding horizontal guide at",t,r,i),{updatedState:e}}static removeHorizontalGuide(e,t){return e=Tc.remove(e,t).updatedState,{updatedState:e}}static removeVerticalGuide(e,t){return e=Ac.remove(e,t).updatedState,{updatedState:e}}static removeCircularGuide(e,t){return console.log("removeing horizontal guide ",t),{updatedState:e}}}class Cc{static selectToolDrawingSurface(e,t){return e=e.merge({mode:Us,drawingSupport:Ie({type:t})}),{updatedState:e}}static beginDrawingSurface(e,t,r,i){let s=e.getIn(["drawingSupport","points"]);s&&s.size?s.push({x:r,y:i}):s=He([{x:r,y:i}]);let o=e.get("drawingSupport").merge({layerID:t,points:s});e=it.unselectAll(e,t).updatedState;let{updatedState:a,line:l}=Jt.create(e,t,o.get("type"),r,i,r,i);return e=Jt.select(a,t,l.id).updatedState,e=e.merge({mode:di,drawingSupport:o}),{updatedState:e}}static updateDrawingSurface(e,t,r){let i=Jt.updateDrawingLine(e,t,r).updatedState;const s=i.getIn(["drawingSupport","layerID"]),o=i.getIn(["drawingSupport","closingLineID"]);return o&&(i=Jt.replaceVertex(i,s,o,0,t,r).updatedState,i=it.detectAndUpdateAreas(i,s).updatedState),{updatedState:i}}static endDrawingSurface(e,t,r){const i=e.getIn(["drawingSupport","layerID"]),s=e.getIn(["drawingSupport","type"]),o=e.getIn(["drawingSupport","points"]);let{updatedState:a}=Jt.endDrawingLine(e,t,r),l=o.push({x:t,y:r});if(l.size===2){const c=l.first();let{updatedState:h,line:f}=Jt.create(a,i,s,c.x,c.y,c.x,c.y),p=e.get("drawingSupport").merge({points:l,closingLineID:f.id});return h=h.merge({drawingSupport:p}),{updatedState:h}}return{updatedState:a}}}var Rc={exports:{}},Pc={exports:{}},Pt={};/** @license React v16.13.1
45
+ */var Ua="delete",kt=5,ar=1<<kt,kn=ar-1,wt={};function fh(){return{value:!1}}function Er(n){n&&(n.value=!0)}function dh(){}function uo(n){return n.size===void 0&&(n.size=n.__iterate(Fm)),n.size}function ts(n,e){if(typeof e!="number"){var t=e>>>0;if(""+t!==e||t===4294967295)return NaN;e=t}return e<0?uo(n)+e:e}function Fm(){return!0}function Fa(n,e,t){return(n===0&&!km(n)||t!==void 0&&n<=-t)&&(e===void 0||t!==void 0&&e>=t)}function ho(n,e){return zm(n,e,0)}function za(n,e){return zm(n,e,e)}function zm(n,e,t){return n===void 0?t:km(n)?e===1/0?e:Math.max(0,e+n)|0:e===void 0||e===n?n:Math.min(e,n)|0}function km(n){return n<0||n===0&&1/n===-1/0}var Bm="@@__IMMUTABLE_ITERABLE__@@";function Kn(n){return!!(n&&n[Bm])}var Yl="@@__IMMUTABLE_KEYED__@@";function Bt(n){return!!(n&&n[Yl])}var Kl="@@__IMMUTABLE_INDEXED__@@";function Bn(n){return!!(n&&n[Kl])}function Zl(n){return Bt(n)||Bn(n)}var Mn=function(e){return Kn(e)?e:vn(e)},br=(function(n){function e(t){return Bt(t)?t:is(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn),Rs=(function(n){function e(t){return Bn(t)?t:wr(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn),fo=(function(n){function e(t){return Kn(t)&&!Zl(t)?t:go(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Mn);Mn.Keyed=br,Mn.Indexed=Rs,Mn.Set=fo;var Vm="@@__IMMUTABLE_SEQ__@@";function Jl(n){return!!(n&&n[Vm])}var Hm="@@__IMMUTABLE_RECORD__@@";function ns(n){return!!(n&&n[Hm])}function Mr(n){return Kn(n)||ns(n)}var rs="@@__IMMUTABLE_ORDERED__@@";function Br(n){return!!(n&&n[rs])}var po=0,lr=1,cr=2,ph=typeof Symbol=="function"&&Symbol.iterator,Gm="@@iterator",Ql=ph||Gm,Tt=function(e){this.next=e};Tt.prototype.toString=function(){return"[Iterator]"},Tt.KEYS=po,Tt.VALUES=lr,Tt.ENTRIES=cr,Tt.prototype.inspect=Tt.prototype.toSource=function(){return this.toString()},Tt.prototype[Ql]=function(){return this};function Yt(n,e,t,r){var i=n===po?e:n===lr?t:[e,t];return r?r.value=i:r={value:i,done:!1},r}function In(){return{value:void 0,done:!0}}function mh(n){return Array.isArray(n)?!0:!!ec(n)}function Wm(n){return n&&typeof n.next=="function"}function gh(n){var e=ec(n);return e&&e.call(n)}function ec(n){var e=n&&(ph&&n[ph]||n[Gm]);if(typeof e=="function")return e}function Z2(n){var e=ec(n);return e&&e===n.entries}function J2(n){var e=ec(n);return e&&e===n.keys}var mo=Object.prototype.hasOwnProperty;function _h(n){return Array.isArray(n)||typeof n=="string"?!0:n&&typeof n=="object"&&Number.isInteger(n.length)&&n.length>=0&&(n.length===0?Object.keys(n).length===1:n.hasOwnProperty(n.length-1))}var vn=(function(n){function e(t){return t==null?xh():Mr(t)?t.toSeq():ey(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(r,i){var s=this._cache;if(s){for(var o=s.length,a=0;a!==o;){var l=s[i?o-++a:a++];if(r(l[1],l[0],this)===!1)break}return a}return this.__iterateUncached(r,i)},e.prototype.__iterator=function(r,i){var s=this._cache;if(s){var o=s.length,a=0;return new Tt(function(){if(a===o)return In();var l=s[i?o-++a:a++];return Yt(r,l[0],l[1])})}return this.__iteratorUncached(r,i)},e})(Mn),is=(function(n){function e(t){return t==null?xh().toKeyedSeq():Kn(t)?Bt(t)?t.toSeq():t.fromEntrySeq():ns(t)?t.toSeq():yh(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e})(vn),wr=(function(n){function e(t){return t==null?xh():Kn(t)?Bt(t)?t.entrySeq():t.toIndexedSeq():ns(t)?t.toSeq().entrySeq():Xm(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e})(vn),go=(function(n){function e(t){return(Kn(t)&&!Zl(t)?t:wr(t)).toSetSeq()}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e})(vn);vn.isSeq=Jl,vn.Keyed=is,vn.Set=go,vn.Indexed=wr,vn.prototype[Vm]=!0;var _o=(function(n){function e(t){this._array=t,this.size=t.length}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return this.has(r)?this._array[ts(this,r)]:i},e.prototype.__iterate=function(r,i){for(var s=this._array,o=s.length,a=0;a!==o;){var l=i?o-++a:a++;if(r(s[l],l,this)===!1)break}return a},e.prototype.__iterator=function(r,i){var s=this._array,o=s.length,a=0;return new Tt(function(){if(a===o)return In();var l=i?o-++a:a++;return Yt(r,l,s[l])})},e})(wr),vh=(function(n){function e(t){var r=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=r,this.size=r.length}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return i!==void 0&&!this.has(r)?i:this._object[r]},e.prototype.has=function(r){return mo.call(this._object,r)},e.prototype.__iterate=function(r,i){for(var s=this._object,o=this._keys,a=o.length,l=0;l!==a;){var c=o[i?a-++l:l++];if(r(s[c],c,this)===!1)break}return l},e.prototype.__iterator=function(r,i){var s=this._object,o=this._keys,a=o.length,l=0;return new Tt(function(){if(l===a)return In();var c=o[i?a-++l:l++];return Yt(r,c,s[c])})},e})(is);vh.prototype[rs]=!0;var Q2=(function(n){function e(t){this._collection=t,this.size=t.length||t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=this._collection,o=gh(s),a=0;if(Wm(o))for(var l;!(l=o.next()).done&&r(l.value,a++,this)!==!1;);return a},e.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=this._collection,o=gh(s);if(!Wm(o))return new Tt(In);var a=0;return new Tt(function(){var l=o.next();return l.done?l:Yt(r,a++,l.value)})},e})(wr),jm;function xh(){return jm||(jm=new _o([]))}function yh(n){var e=Sh(n);if(e)return e.fromEntrySeq();if(typeof n=="object")return new vh(n);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+n)}function Xm(n){var e=Sh(n);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+n)}function ey(n){var e=Sh(n);if(e)return Z2(n)?e.fromEntrySeq():J2(n)?e.toSetSeq():e;if(typeof n=="object")return new vh(n);throw new TypeError("Expected Array or collection object of values, or keyed object: "+n)}function Sh(n){return _h(n)?new _o(n):mh(n)?new Q2(n):void 0}var $m="@@__IMMUTABLE_MAP__@@";function tc(n){return!!(n&&n[$m])}function Eh(n){return tc(n)&&Br(n)}function bh(n){return!!(n&&typeof n.equals=="function"&&typeof n.hashCode=="function")}function Kt(n,e){if(n===e||n!==n&&e!==e)return!0;if(!n||!e)return!1;if(typeof n.valueOf=="function"&&typeof e.valueOf=="function"){if(n=n.valueOf(),e=e.valueOf(),n===e||n!==n&&e!==e)return!0;if(!n||!e)return!1}return!!(bh(n)&&bh(e)&&n.equals(e))}var ka=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(e,t){e|=0,t|=0;var r=e&65535,i=t&65535;return r*i+((e>>>16)*i+r*(t>>>16)<<16>>>0)|0};function nc(n){return n>>>1&1073741824|n&3221225471}var ty=Object.prototype.valueOf;function Zn(n){if(n==null)return Ym(n);if(typeof n.hashCode=="function")return nc(n.hashCode(n));var e=ay(n);if(e==null)return Ym(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return ny(e);case"string":return e.length>ly?ry(e):Mh(e);case"object":case"function":return sy(e);case"symbol":return iy(e);default:if(typeof e.toString=="function")return Mh(e.toString());throw new Error("Value type "+typeof e+" cannot be hashed.")}}function Ym(n){return n===null?1108378658:1108378659}function ny(n){if(n!==n||n===1/0)return 0;var e=n|0;for(e!==n&&(e^=n*4294967295);n>4294967295;)n/=4294967295,e^=n;return nc(e)}function ry(n){var e=Rh[n];return e===void 0&&(e=Mh(n),Ch===cy&&(Ch=0,Rh={}),Ch++,Rh[n]=e),e}function Mh(n){for(var e=0,t=0;t<n.length;t++)e=31*e+n.charCodeAt(t)|0;return nc(e)}function iy(n){var e=Qm[n];return e!==void 0||(e=Jm(),Qm[n]=e),e}function sy(n){var e;if(wh&&(e=Th.get(n),e!==void 0)||(e=n[Ps],e!==void 0)||!Zm&&(e=n.propertyIsEnumerable&&n.propertyIsEnumerable[Ps],e!==void 0||(e=oy(n),e!==void 0)))return e;if(e=Jm(),wh)Th.set(n,e);else{if(Km!==void 0&&Km(n)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(Zm)Object.defineProperty(n,Ps,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(n.propertyIsEnumerable!==void 0&&n.propertyIsEnumerable===n.constructor.prototype.propertyIsEnumerable)n.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},n.propertyIsEnumerable[Ps]=e;else if(n.nodeType!==void 0)n[Ps]=e;else throw new Error("Unable to set a non-enumerable property on object.")}return e}var Km=Object.isExtensible,Zm=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function oy(n){if(n&&n.nodeType>0)switch(n.nodeType){case 1:return n.uniqueID;case 9:return n.documentElement&&n.documentElement.uniqueID}}function ay(n){return n.valueOf!==ty&&typeof n.valueOf=="function"?n.valueOf(n):n}function Jm(){var n=++Ah;return Ah&1073741824&&(Ah=0),n}var wh=typeof WeakMap=="function",Th;wh&&(Th=new WeakMap);var Qm=Object.create(null),Ah=0,Ps="__immutablehash__";typeof Symbol=="function"&&(Ps=Symbol(Ps));var ly=16,cy=255,Ch=0,Rh={},rc=(function(n){function e(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.get=function(r,i){return this._iter.get(r,i)},e.prototype.has=function(r){return this._iter.has(r)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var r=this,i=Ph(this,!0);return this._useKeys||(i.valueSeq=function(){return r._iter.toSeq().reverse()}),i},e.prototype.map=function(r,i){var s=this,o=i0(this,r,i);return this._useKeys||(o.valueSeq=function(){return s._iter.toSeq().map(r,i)}),o},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o,a){return r(o,a,s)},i)},e.prototype.__iterator=function(r,i){return this._iter.__iterator(r,i)},e})(is);rc.prototype[rs]=!0;var e0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.includes=function(r){return this._iter.includes(r)},e.prototype.__iterate=function(r,i){var s=this,o=0;return i&&uo(this),this._iter.__iterate(function(a){return r(a,i?s.size-++o:o++,s)},i)},e.prototype.__iterator=function(r,i){var s=this,o=this._iter.__iterator(lr,i),a=0;return i&&uo(this),new Tt(function(){var l=o.next();return l.done?l:Yt(r,i?s.size-++a:a++,l.value,l)})},e})(wr),t0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.has=function(r){return this._iter.includes(r)},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){return r(o,o,s)},i)},e.prototype.__iterator=function(r,i){var s=this._iter.__iterator(lr,i);return new Tt(function(){var o=s.next();return o.done?o:Yt(r,o.value,o.value,o)})},e})(go),n0=(function(n){function e(t){this._iter=t,this.size=t.size}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){if(o){c0(o);var a=Kn(o);return r(a?o.get(1):o[1],a?o.get(0):o[0],s)}},i)},e.prototype.__iterator=function(r,i){var s=this._iter.__iterator(lr,i);return new Tt(function(){for(;;){var o=s.next();if(o.done)return o;var a=o.value;if(a){c0(a);var l=Kn(a);return Yt(r,l?a.get(0):a[0],l?a.get(1):a[1],o)}}})},e})(is);e0.prototype.cacheResult=rc.prototype.cacheResult=t0.prototype.cacheResult=n0.prototype.cacheResult=Oh;function r0(n){var e=ci(n);return e._iter=n,e.size=n.size,e.flip=function(){return n},e.reverse=function(){var t=n.reverse.apply(this);return t.flip=function(){return n.reverse()},t},e.has=function(t){return n.includes(t)},e.includes=function(t){return n.has(t)},e.cacheResult=Oh,e.__iterateUncached=function(t,r){var i=this;return n.__iterate(function(s,o){return t(o,s,i)!==!1},r)},e.__iteratorUncached=function(t,r){if(t===cr){var i=n.__iterator(t,r);return new Tt(function(){var s=i.next();if(!s.done){var o=s.value[0];s.value[0]=s.value[1],s.value[1]=o}return s})}return n.__iterator(t===lr?po:lr,r)},e}function i0(n,e,t){var r=ci(n);return r.size=n.size,r.has=function(i){return n.has(i)},r.get=function(i,s){var o=n.get(i,wt);return o===wt?s:e.call(t,o,i,n)},r.__iterateUncached=function(i,s){var o=this;return n.__iterate(function(a,l,c){return i(e.call(t,a,l,c),l,o)!==!1},s)},r.__iteratorUncached=function(i,s){var o=n.__iterator(cr,s);return new Tt(function(){var a=o.next();if(a.done)return a;var l=a.value,c=l[0];return Yt(i,c,e.call(t,l[1],c,n),a)})},r}function Ph(n,e){var t=this,r=ci(n);return r._iter=n,r.size=n.size,r.reverse=function(){return n},n.flip&&(r.flip=function(){var i=r0(n);return i.reverse=function(){return n.flip()},i}),r.get=function(i,s){return n.get(e?i:-1-i,s)},r.has=function(i){return n.has(e?i:-1-i)},r.includes=function(i){return n.includes(i)},r.cacheResult=Oh,r.__iterate=function(i,s){var o=this,a=0;return s&&uo(n),n.__iterate(function(l,c){return i(l,e?c:s?o.size-++a:a++,o)},!s)},r.__iterator=function(i,s){var o=0;s&&uo(n);var a=n.__iterator(cr,!s);return new Tt(function(){var l=a.next();if(l.done)return l;var c=l.value;return Yt(i,e?c[0]:s?t.size-++o:o++,c[1],l)})},r}function s0(n,e,t,r){var i=ci(n);return r&&(i.has=function(s){var o=n.get(s,wt);return o!==wt&&!!e.call(t,o,s,n)},i.get=function(s,o){var a=n.get(s,wt);return a!==wt&&e.call(t,a,s,n)?a:o}),i.__iterateUncached=function(s,o){var a=this,l=0;return n.__iterate(function(c,h,f){if(e.call(t,c,h,f))return l++,s(c,r?h:l-1,a)},o),l},i.__iteratorUncached=function(s,o){var a=n.__iterator(cr,o),l=0;return new Tt(function(){for(;;){var c=a.next();if(c.done)return c;var h=c.value,f=h[0],p=h[1];if(e.call(t,p,f,n))return Yt(s,r?f:l++,p,c)}})},i}function uy(n,e,t){var r=Ie().asMutable();return n.__iterate(function(i,s){r.update(e.call(t,i,s,n),0,function(o){return o+1})}),r.asImmutable()}function hy(n,e,t){var r=Bt(n),i=(Br(n)?fi():Ie()).asMutable();n.__iterate(function(o,a){i.update(e.call(t,o,a,n),function(l){return l=l||[],l.push(r?[a,o]:o),l})});var s=Lh(n);return i.map(function(o){return Vt(n,s(o))}).asImmutable()}function fy(n,e,t){var r=Bt(n),i=[[],[]];n.__iterate(function(o,a){i[e.call(t,o,a,n)?1:0].push(r?[a,o]:o)});var s=Lh(n);return i.map(function(o){return Vt(n,s(o))})}function Ih(n,e,t,r){var i=n.size;if(Fa(e,t,i))return n;if(typeof i>"u"&&(e<0||t<0))return Ih(n.toSeq().cacheResult(),e,t,r);var s=ho(e,i),o=za(t,i),a=o-s,l;a===a&&(l=a<0?0:a);var c=ci(n);return c.size=l===0?l:n.size&&l||void 0,!r&&Jl(n)&&l>=0&&(c.get=function(h,f){return h=ts(this,h),h>=0&&h<l?n.get(h+s,f):f}),c.__iterateUncached=function(h,f){var p=this;if(l===0)return 0;if(f)return this.cacheResult().__iterate(h,f);var d=0,m=!0,x=0;return n.__iterate(function(v,_){if(!(m&&(m=d++<s)))return x++,h(v,r?_:x-1,p)!==!1&&x!==l}),x},c.__iteratorUncached=function(h,f){if(l!==0&&f)return this.cacheResult().__iterator(h,f);if(l===0)return new Tt(In);var p=n.__iterator(h,f),d=0,m=0;return new Tt(function(){for(;d++<s;)p.next();if(++m>l)return In();var x=p.next();return r||h===lr||x.done?x:h===po?Yt(h,m-1,void 0,x):Yt(h,m-1,x.value[1],x)})},c}function dy(n,e,t){var r=ci(n);return r.__iterateUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterate(i,s);var a=0;return n.__iterate(function(l,c,h){return e.call(t,l,c,h)&&++a&&i(l,c,o)}),a},r.__iteratorUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterator(i,s);var a=n.__iterator(cr,s),l=!0;return new Tt(function(){if(!l)return In();var c=a.next();if(c.done)return c;var h=c.value,f=h[0],p=h[1];return e.call(t,p,f,o)?i===cr?c:Yt(i,f,p,c):(l=!1,In())})},r}function o0(n,e,t,r){var i=ci(n);return i.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=!0,c=0;return n.__iterate(function(h,f,p){if(!(l&&(l=e.call(t,h,f,p))))return c++,s(h,r?f:c-1,a)}),c},i.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=n.__iterator(cr,o),c=!0,h=0;return new Tt(function(){var f,p,d;do{if(f=l.next(),f.done)return r||s===lr?f:s===po?Yt(s,h++,void 0,f):Yt(s,h++,f.value[1],f);var m=f.value;p=m[0],d=m[1],c&&(c=e.call(t,d,p,a))}while(c);return s===cr?f:Yt(s,p,d,f)})},i}var py=(function(n){function e(t){this._wrappedIterables=t.flatMap(function(r){return r._wrappedIterables?r._wrappedIterables:[r]}),this.size=this._wrappedIterables.reduce(function(r,i){if(r!==void 0){var s=i.size;if(s!==void 0)return r+s}},0),this[Yl]=this._wrappedIterables[0][Yl],this[Kl]=this._wrappedIterables[0][Kl],this[rs]=this._wrappedIterables[0][rs]}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(r,i){if(this._wrappedIterables.length!==0){if(i)return this.cacheResult().__iterate(r,i);for(var s=0,o=Bt(this),a=o?cr:lr,l=this._wrappedIterables[s].__iterator(a,i),c=!0,h=0;c;){for(var f=l.next();f.done;){if(s++,s===this._wrappedIterables.length)return h;l=this._wrappedIterables[s].__iterator(a,i),f=l.next()}var p=o?r(f.value[1],f.value[0],this):r(f.value,h,this);c=p!==!1,h++}return h}},e.prototype.__iteratorUncached=function(r,i){var s=this;if(this._wrappedIterables.length===0)return new Tt(In);if(i)return this.cacheResult().__iterator(r,i);var o=0,a=this._wrappedIterables[o].__iterator(r,i);return new Tt(function(){for(var l=a.next();l.done;){if(o++,o===s._wrappedIterables.length)return l;a=s._wrappedIterables[o].__iterator(r,i),l=a.next()}return l})},e})(vn);function my(n,e){var t=Bt(n),r=[n].concat(e).map(function(s){return Kn(s)?t&&(s=br(s)):s=t?yh(s):Xm(Array.isArray(s)?s:[s]),s}).filter(function(s){return s.size!==0});if(r.length===0)return n;if(r.length===1){var i=r[0];if(i===n||t&&Bt(i)||Bn(n)&&Bn(i))return i}return new py(r)}function a0(n,e,t){var r=ci(n);return r.__iterateUncached=function(i,s){if(s)return this.cacheResult().__iterate(i,s);var o=0,a=!1;function l(c,h){c.__iterate(function(f,p){return(!e||h<e)&&Kn(f)?l(f,h+1):(o++,i(f,t?p:o-1,r)===!1&&(a=!0)),!a},s)}return l(n,0),o},r.__iteratorUncached=function(i,s){if(s)return this.cacheResult().__iterator(i,s);var o=n.__iterator(i,s),a=[],l=0;return new Tt(function(){for(;o;){var c=o.next();if(c.done!==!1){o=a.pop();continue}var h=c.value;if(i===cr&&(h=h[1]),(!e||a.length<e)&&Kn(h))a.push(o),o=h.__iterator(i,s);else return t?c:Yt(i,l++,h,c)}return In()})},r}function gy(n,e,t){var r=Lh(n);return n.toSeq().map(function(i,s){return r(e.call(t,i,s,n))}).flatten(!0)}function _y(n,e){var t=ci(n);return t.size=n.size&&n.size*2-1,t.__iterateUncached=function(r,i){var s=this,o=0;return n.__iterate(function(a){return(!o||r(e,o++,s)!==!1)&&r(a,o++,s)!==!1},i),o},t.__iteratorUncached=function(r,i){var s=n.__iterator(lr,i),o=0,a;return new Tt(function(){return(!a||o%2)&&(a=s.next(),a.done)?a:o%2?Yt(r,o++,e):Yt(r,o++,a.value,a)})},t}function vo(n,e,t){e||(e=u0);var r=Bt(n),i=0,s=n.toSeq().map(function(o,a){return[a,o,i++,t?t(o,a,n):o]}).valueSeq().toArray();return s.sort(function(o,a){return e(o[3],a[3])||o[2]-a[2]}).forEach(r?function(o,a){s[a].length=2}:function(o,a){s[a]=o[1]}),r?is(s):Bn(n)?wr(s):go(s)}function ic(n,e,t){if(e||(e=u0),t){var r=n.toSeq().map(function(i,s){return[i,t(i,s,n)]}).reduce(function(i,s){return l0(e,i[1],s[1])?s:i});return r&&r[0]}return n.reduce(function(i,s){return l0(e,i,s)?s:i})}function l0(n,e,t){var r=n(t,e);return r===0&&t!==e&&(t==null||t!==t)||r>0}function sc(n,e,t,r){var i=ci(n),s=new _o(t).map(function(o){return o.size});return i.size=r?s.max():s.min(),i.__iterate=function(o,a){for(var l=this.__iterator(lr,a),c,h=0;!(c=l.next()).done&&o(c.value,h++,this)!==!1;);return h},i.__iteratorUncached=function(o,a){var l=t.map(function(f){return f=Mn(f),gh(a?f.reverse():f)}),c=0,h=!1;return new Tt(function(){var f;return h||(f=l.map(function(p){return p.next()}),h=r?f.every(function(p){return p.done}):f.some(function(p){return p.done})),h?In():Yt(o,c++,e.apply(null,f.map(function(p){return p.value})))})},i}function Vt(n,e){return n===e?n:Jl(n)?e:n.constructor(e)}function c0(n){if(n!==Object(n))throw new TypeError("Expected [K, V] tuple: "+n)}function Lh(n){return Bt(n)?br:Bn(n)?Rs:fo}function ci(n){return Object.create((Bt(n)?is:Bn(n)?wr:go).prototype)}function Oh(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):vn.prototype.cacheResult.call(this)}function u0(n,e){return n===void 0&&e===void 0?0:n===void 0?1:e===void 0?-1:n>e?1:n<e?-1:0}function ui(n,e){e=e||0;for(var t=Math.max(0,n.length-e),r=new Array(t),i=0;i<t;i++)r[i]=n[i+e];return r}function Ba(n,e){if(!n)throw new Error(e)}function ur(n){Ba(n!==1/0,"Cannot perform this action with an infinite size.")}function h0(n){if(_h(n)&&typeof n!="string")return n;if(Br(n))return n.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+n)}var vy=Object.prototype.toString;function qh(n){if(!n||typeof n!="object"||vy.call(n)!=="[object Object]")return!1;var e=Object.getPrototypeOf(n);if(e===null)return!0;for(var t=e,r=Object.getPrototypeOf(e);r!==null;)t=r,r=Object.getPrototypeOf(t);return t===e}function ss(n){return typeof n=="object"&&(Mr(n)||Array.isArray(n)||qh(n))}function Va(n){try{return typeof n=="string"?JSON.stringify(n):String(n)}catch{return JSON.stringify(n)}}function f0(n,e){return Mr(n)?n.has(e):ss(n)&&mo.call(n,e)}function Dh(n,e,t){return Mr(n)?n.get(e,t):f0(n,e)?typeof n.get=="function"?n.get(e):n[e]:t}function oc(n){if(Array.isArray(n))return ui(n);var e={};for(var t in n)mo.call(n,t)&&(e[t]=n[t]);return e}function d0(n,e){if(!ss(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(Mr(n)){if(!n.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+n);return n.remove(e)}if(!mo.call(n,e))return n;var t=oc(n);return Array.isArray(t)?t.splice(e,1):delete t[e],t}function p0(n,e,t){if(!ss(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(Mr(n)){if(!n.set)throw new TypeError("Cannot update immutable value without .set() method: "+n);return n.set(e,t)}if(mo.call(n,e)&&t===n[e])return n;var r=oc(n);return r[e]=t,r}function Is(n,e,t,r){r||(r=t,t=void 0);var i=m0(Mr(n),n,h0(e),0,t,r);return i===wt?t:i}function m0(n,e,t,r,i,s){var o=e===wt;if(r===t.length){var a=o?i:e,l=s(a);return l===a?e:l}if(!o&&!ss(e))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(t).slice(0,r).map(Va)+"]: "+e);var c=t[r],h=o?wt:Dh(e,c,wt),f=m0(h===wt?n:Mr(h),h,t,r+1,i,s);return f===h?e:f===wt?d0(e,c):p0(o?n?hi():{}:e,c,f)}function g0(n,e,t){return Is(n,e,wt,function(){return t})}function Nh(n,e){return g0(this,n,e)}function _0(n,e){return Is(n,e,function(){return wt})}function Uh(n){return _0(this,n)}function Fh(n,e,t,r){return Is(n,[e],t,r)}function zh(n,e,t){return arguments.length===1?n(this):Fh(this,n,e,t)}function kh(n,e,t){return Is(this,n,e,t)}function v0(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return y0(this,n)}function x0(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(typeof n!="function")throw new TypeError("Invalid merger function: "+n);return y0(this,e,n)}function y0(n,e,t){for(var r=[],i=0;i<e.length;i++){var s=br(e[i]);s.size!==0&&r.push(s)}return r.length===0?n:n.toSeq().size===0&&!n.__ownerID&&r.length===1?ns(n)?n:n.constructor(r[0]):n.withMutations(function(o){for(var a=t?function(c,h){Fh(o,h,wt,function(f){return f===wt?c:t(f,c,h)})}:function(c,h){o.set(h,c)},l=0;l<r.length;l++)r[l].forEach(a)})}function xy(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ga(n,e)}function yy(n,e){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return Ga(e,t,n)}function Sy(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ha(n,e)}function Ey(n,e){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return Ha(e,t,n)}function Ha(n,e,t){return Ga(n,e,by(t))}function Ga(n,e,t){if(!ss(n))throw new TypeError("Cannot merge into non-data-structure value: "+n);if(Mr(n))return typeof t=="function"&&n.mergeWith?n.mergeWith.apply(n,[t].concat(e)):n.merge?n.merge.apply(n,e):n.concat.apply(n,e);for(var r=Array.isArray(n),i=n,s=r?Rs:br,o=r?function(l){i===n&&(i=oc(i)),i.push(l)}:function(l,c){var h=mo.call(i,c),f=h&&t?t(i[c],l,c):l;(!h||f!==i[c])&&(i===n&&(i=oc(i)),i[c]=f)},a=0;a<e.length;a++)s(e[a]).forEach(o);return i}function by(n){function e(t,r,i){return ss(t)&&ss(r)&&My(t,r)?Ga(t,[r],e):n?n(t,r,i):r}return e}function My(n,e){var t=vn(n),r=vn(e);return Bn(t)===Bn(r)&&Bt(t)===Bt(r)}function S0(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return Ha(this,n)}function E0(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Ha(this,e,n)}function Bh(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Is(this,n,hi(),function(r){return Ga(r,e)})}function Vh(n){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Is(this,n,hi(),function(r){return Ha(r,e)})}function Wa(n){var e=this.asMutable();return n(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function ja(){return this.__ownerID?this:this.__ensureOwner(new dh)}function Xa(){return this.__ensureOwner()}function Hh(){return this.__altered}var Ie=(function(n){function e(t){return t==null?hi():tc(t)&&!Br(t)?t:hi().withMutations(function(r){var i=n(t);ur(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},e.prototype.set=function(r,i){return w0(this,r,i)},e.prototype.remove=function(r){return w0(this,r,wt)},e.prototype.deleteAll=function(r){var i=Mn(r);return i.size===0?this:this.withMutations(function(s){i.forEach(function(o){return s.remove(o)})})},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):hi()},e.prototype.sort=function(r){return fi(vo(this,r))},e.prototype.sortBy=function(r,i){return fi(vo(this,i,r))},e.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){o.forEach(function(a,l){o.set(l,r.call(i,a,l,s))})})},e.prototype.__iterator=function(r,i){return new wy(this,r,i)},e.prototype.__iterate=function(r,i){var s=this,o=0;return this._root&&this._root.iterate(function(a){return o++,r(a[1],a[0],s)},i),o},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Wh(this.size,this._root,r,this.__hash):this.size===0?hi():(this.__ownerID=r,this.__altered=!1,this)},e})(br);Ie.isMap=tc;var Zt=Ie.prototype;Zt[$m]=!0,Zt[Ua]=Zt.remove,Zt.removeAll=Zt.deleteAll,Zt.setIn=Nh,Zt.removeIn=Zt.deleteIn=Uh,Zt.update=zh,Zt.updateIn=kh,Zt.merge=Zt.concat=v0,Zt.mergeWith=x0,Zt.mergeDeep=S0,Zt.mergeDeepWith=E0,Zt.mergeIn=Bh,Zt.mergeDeepIn=Vh,Zt.withMutations=Wa,Zt.wasAltered=Hh,Zt.asImmutable=Xa,Zt["@@transducer/init"]=Zt.asMutable=ja,Zt["@@transducer/step"]=function(n,e){return n.set(e[0],e[1])},Zt["@@transducer/result"]=function(n){return n.asImmutable()};var $a=function(e,t){this.ownerID=e,this.entries=t};$a.prototype.get=function(e,t,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Kt(r,s[o][0]))return s[o][1];return i},$a.prototype.update=function(e,t,r,i,s,o,a){for(var l=s===wt,c=this.entries,h=0,f=c.length;h<f&&!Kt(i,c[h][0]);h++);var p=h<f;if(p?c[h][1]===s:l)return this;if(Er(a),(l||!p)&&Er(o),!(l&&c.length===1)){if(!p&&!l&&c.length>=Iy)return Ty(e,c,i,s);var d=e&&e===this.ownerID,m=d?c:ui(c);return p?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),d?(this.entries=m,this):new $a(e,m)}};var xo=function(e,t,r){this.ownerID=e,this.bitmap=t,this.nodes=r};xo.prototype.get=function(e,t,r,i){t===void 0&&(t=Zn(r));var s=1<<((e===0?t:t>>>e)&kn),o=this.bitmap;return(o&s)===0?i:this.nodes[A0(o&s-1)].get(e+kt,t,r,i)},xo.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=(t===0?r:r>>>t)&kn,c=1<<l,h=this.bitmap,f=(h&c)!==0;if(!f&&s===wt)return this;var p=A0(h&c-1),d=this.nodes,m=f?d[p]:void 0,x=jh(m,e,t+kt,r,i,s,o,a);if(x===m)return this;if(!f&&x&&d.length>=Ly)return Cy(e,d,h,l,x);if(f&&!x&&d.length===2&&T0(d[p^1]))return d[p^1];if(f&&x&&d.length===1&&T0(x))return x;var v=e&&e===this.ownerID,_=f?x?h:h^c:h|c,w=f?x?C0(d,p,x,v):Py(d,p,v):Ry(d,p,x,v);return v?(this.bitmap=_,this.nodes=w,this):new xo(e,_,w)};var Ya=function(e,t,r){this.ownerID=e,this.count=t,this.nodes=r};Ya.prototype.get=function(e,t,r,i){t===void 0&&(t=Zn(r));var s=(e===0?t:t>>>e)&kn,o=this.nodes[s];return o?o.get(e+kt,t,r,i):i},Ya.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=(t===0?r:r>>>t)&kn,c=s===wt,h=this.nodes,f=h[l];if(c&&!f)return this;var p=jh(f,e,t+kt,r,i,s,o,a);if(p===f)return this;var d=this.count;if(!f)d++;else if(!p&&(d--,d<Oy))return Ay(e,h,d,l);var m=e&&e===this.ownerID,x=C0(h,l,p,m);return m?(this.count=d,this.nodes=x,this):new Ya(e,d,x)};var yo=function(e,t,r){this.ownerID=e,this.keyHash=t,this.entries=r};yo.prototype.get=function(e,t,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Kt(r,s[o][0]))return s[o][1];return i},yo.prototype.update=function(e,t,r,i,s,o,a){r===void 0&&(r=Zn(i));var l=s===wt;if(r!==this.keyHash)return l?this:(Er(a),Er(o),Xh(this,e,t,r,[i,s]));for(var c=this.entries,h=0,f=c.length;h<f&&!Kt(i,c[h][0]);h++);var p=h<f;if(p?c[h][1]===s:l)return this;if(Er(a),(l||!p)&&Er(o),l&&f===2)return new qi(e,this.keyHash,c[h^1]);var d=e&&e===this.ownerID,m=d?c:ui(c);return p?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),d?(this.entries=m,this):new yo(e,this.keyHash,m)};var qi=function(e,t,r){this.ownerID=e,this.keyHash=t,this.entry=r};qi.prototype.get=function(e,t,r,i){return Kt(r,this.entry[0])?this.entry[1]:i},qi.prototype.update=function(e,t,r,i,s,o,a){var l=s===wt,c=Kt(i,this.entry[0]);if(c?s===this.entry[1]:l)return this;if(Er(a),l){Er(o);return}return c?e&&e===this.ownerID?(this.entry[1]=s,this):new qi(e,this.keyHash,[i,s]):(Er(o),Xh(this,e,t,Zn(i),[i,s]))},$a.prototype.iterate=yo.prototype.iterate=function(n,e){for(var t=this.entries,r=0,i=t.length-1;r<=i;r++)if(n(t[e?i-r:r])===!1)return!1},xo.prototype.iterate=Ya.prototype.iterate=function(n,e){for(var t=this.nodes,r=0,i=t.length-1;r<=i;r++){var s=t[e?i-r:r];if(s&&s.iterate(n,e)===!1)return!1}},qi.prototype.iterate=function(n,e){return n(this.entry)};var wy=(function(n){function e(t,r,i){this._type=r,this._reverse=i,this._stack=t._root&&b0(t._root)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.next=function(){for(var r=this._type,i=this._stack;i;){var s=i.node,o=i.index++,a=void 0;if(s.entry){if(o===0)return Gh(r,s.entry)}else if(s.entries){if(a=s.entries.length-1,o<=a)return Gh(r,s.entries[this._reverse?a-o:o])}else if(a=s.nodes.length-1,o<=a){var l=s.nodes[this._reverse?a-o:o];if(l){if(l.entry)return Gh(r,l.entry);i=this._stack=b0(l,i)}continue}i=this._stack=this._stack.__prev}return In()},e})(Tt);function Gh(n,e){return Yt(n,e[0],e[1])}function b0(n,e){return{node:n,index:0,__prev:e}}function Wh(n,e,t,r){var i=Object.create(Zt);return i.size=n,i._root=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var M0;function hi(){return M0||(M0=Wh(0))}function w0(n,e,t){var r,i;if(n._root){var s=fh(),o=fh();if(r=jh(n._root,n.__ownerID,0,void 0,e,t,s,o),!o.value)return n;i=n.size+(s.value?t===wt?-1:1:0)}else{if(t===wt)return n;i=1,r=new $a(n.__ownerID,[[e,t]])}return n.__ownerID?(n.size=i,n._root=r,n.__hash=void 0,n.__altered=!0,n):r?Wh(i,r):hi()}function jh(n,e,t,r,i,s,o,a){return n?n.update(e,t,r,i,s,o,a):s===wt?n:(Er(a),Er(o),new qi(e,r,[i,s]))}function T0(n){return n.constructor===qi||n.constructor===yo}function Xh(n,e,t,r,i){if(n.keyHash===r)return new yo(e,r,[n.entry,i]);var s=(t===0?n.keyHash:n.keyHash>>>t)&kn,o=(t===0?r:r>>>t)&kn,a,l=s===o?[Xh(n,e,t+kt,r,i)]:(a=new qi(e,r,i),s<o?[n,a]:[a,n]);return new xo(e,1<<s|1<<o,l)}function Ty(n,e,t,r){n||(n=new dh);for(var i=new qi(n,Zn(t),[t,r]),s=0;s<e.length;s++){var o=e[s];i=i.update(n,0,void 0,o[0],o[1])}return i}function Ay(n,e,t,r){for(var i=0,s=0,o=new Array(t),a=0,l=1,c=e.length;a<c;a++,l<<=1){var h=e[a];h!==void 0&&a!==r&&(i|=l,o[s++]=h)}return new xo(n,i,o)}function Cy(n,e,t,r,i){for(var s=0,o=new Array(ar),a=0;t!==0;a++,t>>>=1)o[a]=t&1?e[s++]:void 0;return o[r]=i,new Ya(n,s+1,o)}function A0(n){return n-=n>>1&1431655765,n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n+=n>>8,n+=n>>16,n&127}function C0(n,e,t,r){var i=r?n:ui(n);return i[e]=t,i}function Ry(n,e,t,r){var i=n.length+1;if(r&&e+1===i)return n[e]=t,n;for(var s=new Array(i),o=0,a=0;a<i;a++)a===e?(s[a]=t,o=-1):s[a]=n[a+o];return s}function Py(n,e,t){var r=n.length-1;if(t&&e===r)return n.pop(),n;for(var i=new Array(r),s=0,o=0;o<r;o++)o===e&&(s=1),i[o]=n[o+s];return i}var Iy=ar/4,Ly=ar/2,Oy=ar/4,R0="@@__IMMUTABLE_LIST__@@";function $h(n){return!!(n&&n[R0])}var He=(function(n){function e(t){var r=ac();if(t==null)return r;if($h(t))return t;var i=n(t),s=i.size;return s===0?r:(ur(s),s>0&&s<ar?Za(0,s,kt,null,new os(i.toArray())):r.withMutations(function(o){o.setSize(s),i.forEach(function(a,l){return o.set(l,a)})}))}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("List [","]")},e.prototype.get=function(r,i){if(r=ts(this,r),r>=0&&r<this.size){r+=this._origin;var s=I0(this,r);return s&&s.array[r&kn]}return i},e.prototype.set=function(r,i){return qy(this,r,i)},e.prototype.remove=function(r){return this.has(r)?r===0?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},e.prototype.insert=function(r,i){return this.splice(r,0,i)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=kt,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ac()},e.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(s){as(s,0,i+r.length);for(var o=0;o<r.length;o++)s.set(i+o,r[o])})},e.prototype.pop=function(){return as(this,0,-1)},e.prototype.unshift=function(){var r=arguments;return this.withMutations(function(i){as(i,-r.length);for(var s=0;s<r.length;s++)i.set(s,r[s])})},e.prototype.shift=function(){return as(this,1)},e.prototype.shuffle=function(r){return r===void 0&&(r=Math.random),this.withMutations(function(i){for(var s=i.size,o,a;s;)o=Math.floor(r()*s--),a=i.get(o),i.set(o,i.get(s)),i.set(s,a)})},e.prototype.concat=function(){for(var r=arguments,i=[],s=0;s<arguments.length;s++){var o=r[s],a=n(typeof o!="string"&&mh(o)?o:[o]);a.size!==0&&i.push(a)}return i.length===0?this:this.size===0&&!this.__ownerID&&i.length===1?this.constructor(i[0]):this.withMutations(function(l){i.forEach(function(c){return c.forEach(function(h){return l.push(h)})})})},e.prototype.setSize=function(r){return as(this,0,r)},e.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){for(var a=0;a<s.size;a++)o.set(a,r.call(i,o.get(a),a,s))})},e.prototype.slice=function(r,i){var s=this.size;return Fa(r,i,s)?this:as(this,ho(r,s),za(i,s))},e.prototype.__iterator=function(r,i){var s=i?this.size:0,o=P0(this,i);return new Tt(function(){var a=o();return a===Ka?In():Yt(r,i?--s:s++,a)})},e.prototype.__iterate=function(r,i){for(var s=i?this.size:0,o=P0(this,i),a;(a=o())!==Ka&&r(a,i?--s:s++,this)!==!1;);return s},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Za(this._origin,this._capacity,this._level,this._root,this._tail,r,this.__hash):this.size===0?ac():(this.__ownerID=r,this.__altered=!1,this)},e})(Rs);He.isList=$h;var dn=He.prototype;dn[R0]=!0,dn[Ua]=dn.remove,dn.merge=dn.concat,dn.setIn=Nh,dn.deleteIn=dn.removeIn=Uh,dn.update=zh,dn.updateIn=kh,dn.mergeIn=Bh,dn.mergeDeepIn=Vh,dn.withMutations=Wa,dn.wasAltered=Hh,dn.asImmutable=Xa,dn["@@transducer/init"]=dn.asMutable=ja,dn["@@transducer/step"]=function(n,e){return n.push(e)},dn["@@transducer/result"]=function(n){return n.asImmutable()};var os=function(e,t){this.array=e,this.ownerID=t};os.prototype.removeBefore=function(e,t,r){if((r&(1<<t+kt)-1)===0||this.array.length===0)return this;var i=r>>>t&kn;if(i>=this.array.length)return new os([],e);var s=i===0,o;if(t>0){var a=this.array[i];if(o=a&&a.removeBefore(e,t-kt,r),o===a&&s)return this}if(s&&!o)return this;var l=So(this,e);if(!s)for(var c=0;c<i;c++)l.array[c]=void 0;return o&&(l.array[i]=o),l},os.prototype.removeAfter=function(e,t,r){if(r===(t?1<<t+kt:ar)||this.array.length===0)return this;var i=r-1>>>t&kn;if(i>=this.array.length)return this;var s;if(t>0){var o=this.array[i];if(s=o&&o.removeAfter(e,t-kt,r),s===o&&i===this.array.length-1)return this}var a=So(this,e);return a.array.splice(i+1),s&&(a.array[i]=s),a};var Ka={};function P0(n,e){var t=n._origin,r=n._capacity,i=Ja(r),s=n._tail;return o(n._root,n._level,0);function o(c,h,f){return h===0?a(c,f):l(c,h,f)}function a(c,h){var f=h===i?s&&s.array:c&&c.array,p=h>t?0:t-h,d=r-h;return d>ar&&(d=ar),function(){if(p===d)return Ka;var m=e?--d:p++;return f&&f[m]}}function l(c,h,f){var p,d=c&&c.array,m=f>t?0:t-f>>h,x=(r-f>>h)+1;return x>ar&&(x=ar),function(){for(;;){if(p){var v=p();if(v!==Ka)return v;p=null}if(m===x)return Ka;var _=e?--x:m++;p=o(d&&d[_],h-kt,f+(_<<h))}}}}function Za(n,e,t,r,i,s,o){var a=Object.create(dn);return a.size=e-n,a._origin=n,a._capacity=e,a._level=t,a._root=r,a._tail=i,a.__ownerID=s,a.__hash=o,a.__altered=!1,a}function ac(){return Za(0,0,kt)}function qy(n,e,t){if(e=ts(n,e),e!==e)return n;if(e>=n.size||e<0)return n.withMutations(function(o){e<0?as(o,e).set(0,t):as(o,0,e+1).set(e,t)});e+=n._origin;var r=n._tail,i=n._root,s=fh();return e>=Ja(n._capacity)?r=Yh(r,n.__ownerID,0,e,t,s):i=Yh(i,n.__ownerID,n._level,e,t,s),s.value?n.__ownerID?(n._root=i,n._tail=r,n.__hash=void 0,n.__altered=!0,n):Za(n._origin,n._capacity,n._level,i,r):n}function Yh(n,e,t,r,i,s){var o=r>>>t&kn,a=n&&o<n.array.length;if(!a&&i===void 0)return n;var l;if(t>0){var c=n&&n.array[o],h=Yh(c,e,t-kt,r,i,s);return h===c?n:(l=So(n,e),l.array[o]=h,l)}return a&&n.array[o]===i?n:(s&&Er(s),l=So(n,e),i===void 0&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function So(n,e){return e&&n&&e===n.ownerID?n:new os(n?n.array.slice():[],e)}function I0(n,e){if(e>=Ja(n._capacity))return n._tail;if(e<1<<n._level+kt){for(var t=n._root,r=n._level;t&&r>0;)t=t.array[e>>>r&kn],r-=kt;return t}}function as(n,e,t){e!==void 0&&(e|=0),t!==void 0&&(t|=0);var r=n.__ownerID||new dh,i=n._origin,s=n._capacity,o=i+e,a=t===void 0?s:t<0?s+t:i+t;if(o===i&&a===s)return n;if(o>=a)return n.clear();for(var l=n._level,c=n._root,h=0;o+h<0;)c=new os(c&&c.array.length?[void 0,c]:[],r),l+=kt,h+=1<<l;h&&(o+=h,i+=h,a+=h,s+=h);for(var f=Ja(s),p=Ja(a);p>=1<<l+kt;)c=new os(c&&c.array.length?[c]:[],r),l+=kt;var d=n._tail,m=p<f?I0(n,a-1):p>f?new os([],r):d;if(d&&p>f&&o<s&&d.array.length){c=So(c,r);for(var x=c,v=l;v>kt;v-=kt){var _=f>>>v&kn;x=x.array[_]=So(x.array[_],r)}x.array[f>>>kt&kn]=d}if(a<s&&(m=m&&m.removeAfter(r,0,a)),o>=p)o-=p,a-=p,l=kt,c=null,m=m&&m.removeBefore(r,0,o);else if(o>i||p<f){for(h=0;c;){var w=o>>>l&kn;if(w!==p>>>l&kn)break;w&&(h+=(1<<l)*w),l-=kt,c=c.array[w]}c&&o>i&&(c=c.removeBefore(r,l,o-h)),c&&p<f&&(c=c.removeAfter(r,l,p-h)),h&&(o-=h,a-=h)}return n.__ownerID?(n.size=a-o,n._origin=o,n._capacity=a,n._level=l,n._root=c,n._tail=m,n.__hash=void 0,n.__altered=!0,n):Za(o,a,l,c,m)}function Ja(n){return n<ar?0:n-1>>>kt<<kt}var fi=(function(n){function e(t){return t==null?Qa():Eh(t)?t:Qa().withMutations(function(r){var i=br(t);ur(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(r,i){var s=this._map.get(r);return s!==void 0?this._list.get(s)[1]:i},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):Qa()},e.prototype.set=function(r,i){return O0(this,r,i)},e.prototype.remove=function(r){return O0(this,r,wt)},e.prototype.__iterate=function(r,i){var s=this;return this._list.__iterate(function(o){return o&&r(o[1],o[0],s)},i)},e.prototype.__iterator=function(r,i){return this._list.fromEntrySeq().__iterator(r,i)},e.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r),s=this._list.__ensureOwner(r);return r?Kh(i,s,r,this.__hash):this.size===0?Qa():(this.__ownerID=r,this.__altered=!1,this._map=i,this._list=s,this)},e})(Ie);fi.isOrderedMap=Eh,fi.prototype[rs]=!0,fi.prototype[Ua]=fi.prototype.remove;function Kh(n,e,t,r){var i=Object.create(fi.prototype);return i.size=n?n.size:0,i._map=n,i._list=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var L0;function Qa(){return L0||(L0=Kh(hi(),ac()))}function O0(n,e,t){var r=n._map,i=n._list,s=r.get(e),o=s!==void 0,a,l;if(t===wt){if(!o)return n;i.size>=ar&&i.size>=r.size*2?(l=i.filter(function(c,h){return c!==void 0&&s!==h}),a=l.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),n.__ownerID&&(a.__ownerID=l.__ownerID=n.__ownerID)):(a=r.remove(e),l=s===i.size-1?i.pop():i.set(s,void 0))}else if(o){if(t===i.get(s)[1])return n;a=r,l=i.set(s,[e,t])}else a=r.set(e,i.size),l=i.set(i.size,[e,t]);return n.__ownerID?(n.size=a.size,n._map=a,n._list=l,n.__hash=void 0,n.__altered=!0,n):Kh(a,l)}var q0="@@__IMMUTABLE_STACK__@@";function lc(n){return!!(n&&n[q0])}var cc=(function(n){function e(t){return t==null?uc():lc(t)?t:uc().pushAll(t)}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(r,i){var s=this._head;for(r=ts(this,r);s&&r--;)s=s.next;return s?s.value:i},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var r=arguments;if(arguments.length===0)return this;for(var i=this.size+arguments.length,s=this._head,o=arguments.length-1;o>=0;o--)s={value:r[o],next:s};return this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):el(i,s)},e.prototype.pushAll=function(r){if(r=n(r),r.size===0)return this;if(this.size===0&&lc(r))return r;ur(r.size);var i=this.size,s=this._head;return r.__iterate(function(o){i++,s={value:o,next:s}},!0),this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):el(i,s)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):uc()},e.prototype.slice=function(r,i){if(Fa(r,i,this.size))return this;var s=ho(r,this.size),o=za(i,this.size);if(o!==this.size)return n.prototype.slice.call(this,r,i);for(var a=this.size-s,l=this._head;s--;)l=l.next;return this.__ownerID?(this.size=a,this._head=l,this.__hash=void 0,this.__altered=!0,this):el(a,l)},e.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?el(this.size,this._head,r,this.__hash):this.size===0?uc():(this.__ownerID=r,this.__altered=!1,this)},e.prototype.__iterate=function(r,i){var s=this;if(i)return new _o(this.toArray()).__iterate(function(l,c){return r(l,c,s)},i);for(var o=0,a=this._head;a&&r(a.value,o++,this)!==!1;)a=a.next;return o},e.prototype.__iterator=function(r,i){if(i)return new _o(this.toArray()).__iterator(r,i);var s=0,o=this._head;return new Tt(function(){if(o){var a=o.value;return o=o.next,Yt(r,s++,a)}return In()})},e})(Rs);cc.isStack=lc;var Vn=cc.prototype;Vn[q0]=!0,Vn.shift=Vn.pop,Vn.unshift=Vn.push,Vn.unshiftAll=Vn.pushAll,Vn.withMutations=Wa,Vn.wasAltered=Hh,Vn.asImmutable=Xa,Vn["@@transducer/init"]=Vn.asMutable=ja,Vn["@@transducer/step"]=function(n,e){return n.unshift(e)},Vn["@@transducer/result"]=function(n){return n.asImmutable()};function el(n,e,t,r){var i=Object.create(Vn);return i.size=n,i._head=e,i.__ownerID=t,i.__hash=r,i.__altered=!1,i}var D0;function uc(){return D0||(D0=el(0))}var N0="@@__IMMUTABLE_SET__@@";function hc(n){return!!(n&&n[N0])}function Zh(n){return hc(n)&&Br(n)}function Jh(n,e){if(n===e)return!0;if(!Kn(e)||n.size!==void 0&&e.size!==void 0&&n.size!==e.size||n.__hash!==void 0&&e.__hash!==void 0&&n.__hash!==e.__hash||Bt(n)!==Bt(e)||Bn(n)!==Bn(e)||Br(n)!==Br(e))return!1;if(n.size===0&&e.size===0)return!0;var t=!Zl(n);if(Br(n)){var r=n.entries();return e.every(function(l,c){var h=r.next().value;return h&&Kt(h[1],l)&&(t||Kt(h[0],c))})&&r.next().done}var i=!1;if(n.size===void 0)if(e.size===void 0)typeof n.cacheResult=="function"&&n.cacheResult();else{i=!0;var s=n;n=e,e=s}var o=!0,a=e.__iterate(function(l,c){if(t?!n.has(l):i?!Kt(l,n.get(c,wt)):!Kt(n.get(c,wt),l))return o=!1,!1});return o&&n.size===a}function Ls(n,e){var t=function(r){n.prototype[r]=e[r]};return Object.keys(e).forEach(t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(t),n}function fc(n){if(!n||typeof n!="object")return n;if(!Kn(n)){if(!ss(n))return n;n=vn(n)}if(Bt(n)){var e={};return n.__iterate(function(r,i){e[i]=fc(r)}),e}var t=[];return n.__iterate(function(r){t.push(fc(r))}),t}var Eo=(function(n){function e(t){return t==null?tl():hc(t)&&!Br(t)?t:tl().withMutations(function(r){var i=n(t);ur(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(r){return this(br(r).keySeq())},e.intersect=function(r){return r=Mn(r).toArray(),r.length?An.intersect.apply(e(r.pop()),r):tl()},e.union=function(r){return r=Mn(r).toArray(),r.length?An.union.apply(e(r.pop()),r):tl()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(r){return this._map.has(r)},e.prototype.add=function(r){return dc(this,this._map.set(r,r))},e.prototype.remove=function(r){return dc(this,this._map.remove(r))},e.prototype.clear=function(){return dc(this,this._map.clear())},e.prototype.map=function(r,i){var s=this,o=!1,a=dc(this,this._map.mapEntries(function(l){var c=l[1],h=r.call(i,c,c,s);return h!==c&&(o=!0),[h,h]},i));return o?a:this},e.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return r=r.filter(function(s){return s.size!==0}),r.length===0?this:this.size===0&&!this.__ownerID&&r.length===1?this.constructor(r[0]):this.withMutations(function(s){for(var o=0;o<r.length;o++)typeof r[o]=="string"?s.add(r[o]):n(r[o]).forEach(function(a){return s.add(a)})})},e.prototype.intersect=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.every(function(a){return a.includes(o)})||s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},e.prototype.subtract=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.some(function(a){return a.includes(o)})&&s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},e.prototype.sort=function(r){return wo(vo(this,r))},e.prototype.sortBy=function(r,i){return wo(vo(this,i,r))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(r,i){var s=this;return this._map.__iterate(function(o){return r(o,o,s)},i)},e.prototype.__iterator=function(r,i){return this._map.__iterator(r,i)},e.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r);return r?this.__make(i,r):this.size===0?this.__empty():(this.__ownerID=r,this._map=i,this)},e})(fo);Eo.isSet=hc;var An=Eo.prototype;An[N0]=!0,An[Ua]=An.remove,An.merge=An.concat=An.union,An.withMutations=Wa,An.asImmutable=Xa,An["@@transducer/init"]=An.asMutable=ja,An["@@transducer/step"]=function(n,e){return n.add(e)},An["@@transducer/result"]=function(n){return n.asImmutable()},An.__empty=tl,An.__make=U0;function dc(n,e){return n.__ownerID?(n.size=e.size,n._map=e,n):e===n._map?n:e.size===0?n.__empty():n.__make(e)}function U0(n,e){var t=Object.create(An);return t.size=n?n.size:0,t._map=n,t.__ownerID=e,t}var F0;function tl(){return F0||(F0=U0(hi()))}var z0=(function(n){function e(t,r,i){if(i===void 0&&(i=1),!(this instanceof e))return new e(t,r,i);if(Ba(i!==0,"Cannot step a Range by 0"),Ba(t!==void 0,"You must define a start value when using Range"),Ba(r!==void 0,"You must define an end value when using Range"),i=Math.abs(i),r<t&&(i=-i),this._start=t,this._end=r,this._step=i,this.size=Math.max(0,Math.ceil((r-t)/i-1)+1),this.size===0){if(Qh)return Qh;Qh=this}}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},e.prototype.get=function(r,i){return this.has(r)?this._start+ts(this,r)*this._step:i},e.prototype.includes=function(r){var i=(r-this._start)/this._step;return i>=0&&i<this.size&&i===Math.floor(i)},e.prototype.slice=function(r,i){return Fa(r,i,this.size)?this:(r=ho(r,this.size),i=za(i,this.size),i<=r?new e(0,0):new e(this.get(r,this._end),this.get(i,this._end),this._step))},e.prototype.indexOf=function(r){var i=r-this._start;if(i%this._step===0){var s=i/this._step;if(s>=0&&s<this.size)return s}return-1},e.prototype.lastIndexOf=function(r){return this.indexOf(r)},e.prototype.__iterate=function(r,i){for(var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;l!==s&&r(a,i?s-++l:l++,this)!==!1;)a+=i?-o:o;return l},e.prototype.__iterator=function(r,i){var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;return new Tt(function(){if(l===s)return In();var c=a;return a+=i?-o:o,Yt(r,i?s-++l:l++,c)})},e.prototype.equals=function(r){return r instanceof e?this._start===r._start&&this._end===r._end&&this._step===r._step:Jh(this,r)},e})(wr),Qh;function ef(n,e,t){for(var r=h0(e),i=0;i!==r.length;)if(n=Dh(n,r[i++],wt),n===wt)return t;return n}function k0(n,e){return ef(this,n,e)}function B0(n,e){return ef(n,e,wt)!==wt}function Dy(n){return B0(this,n)}function V0(){ur(this.size);var n={};return this.__iterate(function(e,t){n[t]=e}),n}Mn.Iterator=Tt,Ls(Mn,{toArray:function(){ur(this.size);var e=new Array(this.size||0),t=Bt(this),r=0;return this.__iterate(function(i,s){e[r++]=t?[s,i]:i}),e},toIndexedSeq:function(){return new e0(this)},toJS:function(){return fc(this)},toKeyedSeq:function(){return new rc(this,!0)},toMap:function(){return Ie(this.toKeyedSeq())},toObject:V0,toOrderedMap:function(){return fi(this.toKeyedSeq())},toOrderedSet:function(){return wo(Bt(this)?this.valueSeq():this)},toSet:function(){return Eo(Bt(this)?this.valueSeq():this)},toSetSeq:function(){return new t0(this)},toSeq:function(){return Bn(this)?this.toIndexedSeq():Bt(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return cc(Bt(this)?this.valueSeq():this)},toList:function(){return He(Bt(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(e,t){return this.size===0?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return Vt(this,my(this,e))},includes:function(e){return this.some(function(t){return Kt(t,e)})},entries:function(){return this.__iterator(cr)},every:function(e,t){ur(this.size);var r=!0;return this.__iterate(function(i,s,o){if(!e.call(t,i,s,o))return r=!1,!1}),r},filter:function(e,t){return Vt(this,s0(this,e,t,!0))},partition:function(e,t){return fy(this,e,t)},find:function(e,t,r){var i=this.findEntry(e,t);return i?i[1]:r},forEach:function(e,t){return ur(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){ur(this.size),e=e!==void 0?""+e:",";var t="",r=!0;return this.__iterate(function(i){r?r=!1:t+=e,t+=i!=null?i.toString():""}),t},keys:function(){return this.__iterator(po)},map:function(e,t){return Vt(this,i0(this,e,t))},reduce:function(e,t,r){return H0(this,e,t,r,arguments.length<2,!1)},reduceRight:function(e,t,r){return H0(this,e,t,r,arguments.length<2,!0)},reverse:function(){return Vt(this,Ph(this,!0))},slice:function(e,t){return Vt(this,Ih(this,e,t,!0))},some:function(e,t){ur(this.size);var r=!1;return this.__iterate(function(i,s,o){if(e.call(t,i,s,o))return r=!0,!1}),r},sort:function(e){return Vt(this,vo(this,e))},values:function(){return this.__iterator(lr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(e,t){return uo(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return uy(this,e,t)},equals:function(e){return Jh(this,e)},entrySeq:function(){var e=this;if(e._cache)return new _o(e._cache);var t=e.toSeq().map(Uy).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(tf(e),t)},findEntry:function(e,t,r){var i=r;return this.__iterate(function(s,o,a){if(e.call(t,s,o,a))return i=[o,s],!1}),i},findKey:function(e,t){var r=this.findEntry(e,t);return r&&r[0]},findLast:function(e,t,r){return this.toKeyedSeq().reverse().find(e,t,r)},findLastEntry:function(e,t,r){return this.toKeyedSeq().reverse().findEntry(e,t,r)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(e){return this.find(Fm,null,e)},flatMap:function(e,t){return Vt(this,gy(this,e,t))},flatten:function(e){return Vt(this,a0(this,e,!0))},fromEntrySeq:function(){return new n0(this)},get:function(e,t){return this.find(function(r,i){return Kt(i,e)},void 0,t)},getIn:k0,groupBy:function(e,t){return hy(this,e,t)},has:function(e){return this.get(e,wt)!==wt},hasIn:Dy,isSubset:function(e){return e=typeof e.includes=="function"?e:Mn(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e=typeof e.isSubset=="function"?e:Mn(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return Kt(t,e)})},keySeq:function(){return this.toSeq().map(Ny).toIndexedSeq()},last:function(e){return this.toSeq().reverse().first(e)},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return ic(this,e)},maxBy:function(e,t){return ic(this,t,e)},min:function(e){return ic(this,e?G0(e):j0)},minBy:function(e,t){return ic(this,t?G0(t):j0,e)},rest:function(){return this.slice(1)},skip:function(e){return e===0?this:this.slice(Math.max(0,e))},skipLast:function(e){return e===0?this:this.slice(0,-Math.max(0,e))},skipWhile:function(e,t){return Vt(this,o0(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(tf(e),t)},sortBy:function(e,t){return Vt(this,vo(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return this.slice(-Math.max(0,e))},takeWhile:function(e,t){return Vt(this,dy(this,e,t))},takeUntil:function(e,t){return this.takeWhile(tf(e),t)},update:function(e){return e(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Fy(this))}});var Ln=Mn.prototype;Ln[Bm]=!0,Ln[Ql]=Ln.values,Ln.toJSON=Ln.toArray,Ln.__toStringMapper=Va,Ln.inspect=Ln.toSource=function(){return this.toString()},Ln.chain=Ln.flatMap,Ln.contains=Ln.includes,Ls(br,{flip:function(){return Vt(this,r0(this))},mapEntries:function(e,t){var r=this,i=0;return Vt(this,this.toSeq().map(function(s,o){return e.call(t,[o,s],i++,r)}).fromEntrySeq())},mapKeys:function(e,t){var r=this;return Vt(this,this.toSeq().flip().map(function(i,s){return e.call(t,i,s,r)}).flip())}});var nl=br.prototype;nl[Yl]=!0,nl[Ql]=Ln.entries,nl.toJSON=V0,nl.__toStringMapper=function(n,e){return Va(e)+": "+Va(n)},Ls(Rs,{toKeyedSeq:function(){return new rc(this,!1)},filter:function(e,t){return Vt(this,s0(this,e,t,!1))},findIndex:function(e,t){var r=this.findEntry(e,t);return r?r[0]:-1},indexOf:function(e){var t=this.keyOf(e);return t===void 0?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return t===void 0?-1:t},reverse:function(){return Vt(this,Ph(this,!1))},slice:function(e,t){return Vt(this,Ih(this,e,t,!1))},splice:function(e,t){var r=arguments.length;if(t=Math.max(t||0,0),r===0||r===2&&!t)return this;e=ho(e,e<0?this.count():this.size);var i=this.slice(0,e);return Vt(this,r===1?i:i.concat(ui(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var r=this.findLastEntry(e,t);return r?r[0]:-1},first:function(e){return this.get(0,e)},flatten:function(e){return Vt(this,a0(this,e,!1))},get:function(e,t){return e=ts(this,e),e<0||this.size===1/0||this.size!==void 0&&e>this.size?t:this.find(function(r,i){return i===e},void 0,t)},has:function(e){return e=ts(this,e),e>=0&&(this.size!==void 0?this.size===1/0||e<this.size:this.indexOf(e)!==-1)},interpose:function(e){return Vt(this,_y(this,e))},interleave:function(){var e=[this].concat(ui(arguments)),t=sc(this.toSeq(),wr.of,e),r=t.flatten(!0);return t.size&&(r.size=t.size*e.length),Vt(this,r)},keySeq:function(){return z0(0,this.size)},last:function(e){return this.get(-1,e)},skipWhile:function(e,t){return Vt(this,o0(this,e,t,!1))},zip:function(){var e=[this].concat(ui(arguments));return Vt(this,sc(this,W0,e))},zipAll:function(){var e=[this].concat(ui(arguments));return Vt(this,sc(this,W0,e,!0))},zipWith:function(e){var t=ui(arguments);return t[0]=this,Vt(this,sc(this,e,t))}});var bo=Rs.prototype;bo[Kl]=!0,bo[rs]=!0,Ls(fo,{get:function(e,t){return this.has(e)?e:t},includes:function(e){return this.has(e)},keySeq:function(){return this.valueSeq()}});var Mo=fo.prototype;Mo.has=Ln.includes,Mo.contains=Mo.includes,Mo.keys=Mo.values,Ls(is,nl),Ls(wr,bo),Ls(go,Mo);function H0(n,e,t,r,i,s){return ur(n.size),n.__iterate(function(o,a,l){i?(i=!1,t=o):t=e.call(r,t,o,a,l)},s),t}function Ny(n,e){return e}function Uy(n,e){return[e,n]}function tf(n){return function(){return!n.apply(this,arguments)}}function G0(n){return function(){return-n.apply(this,arguments)}}function W0(){return ui(arguments)}function j0(n,e){return n<e?1:n>e?-1:0}function Fy(n){if(n.size===1/0)return 0;var e=Br(n),t=Bt(n),r=e?1:0;return n.__iterate(t?e?function(i,s){r=31*r+X0(Zn(i),Zn(s))|0}:function(i,s){r=r+X0(Zn(i),Zn(s))|0}:e?function(i){r=31*r+Zn(i)|0}:function(i){r=r+Zn(i)|0}),zy(n.size,r)}function zy(n,e){return e=ka(e,3432918353),e=ka(e<<15|e>>>-15,461845907),e=ka(e<<13|e>>>-13,5),e=(e+3864292196|0)^n,e=ka(e^e>>>16,2246822507),e=ka(e^e>>>13,3266489909),e=nc(e^e>>>16),e}function X0(n,e){return n^e+2654435769+(n<<6)+(n>>2)|0}var wo=(function(n){function e(t){return t==null?nf():Zh(t)?t:nf().withMutations(function(r){var i=fo(t);ur(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(r){return this(br(r).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e})(Eo);wo.isOrderedSet=Zh;var Os=wo.prototype;Os[rs]=!0,Os.zip=bo.zip,Os.zipWith=bo.zipWith,Os.zipAll=bo.zipAll,Os.__empty=nf,Os.__make=$0;function $0(n,e){var t=Object.create(Os);return t.size=n?n.size:0,t._map=n,t.__ownerID=e,t}var Y0;function nf(){return Y0||(Y0=$0(Qa()))}var ky={LeftThenRight:-1,RightThenLeft:1};function By(n){if(ns(n))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(Mr(n))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(n===null||typeof n!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var gt=function(e,t){var r;By(e);var i=function(a){var l=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var c=Object.keys(e),h=s._indices={};s._name=t,s._keys=c,s._defaultValues=e;for(var f=0;f<c.length;f++){var p=c[f];h[p]=f,s[p]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+sf(this)+' with property "'+p+'" since that property name is part of the Record API.'):Vy(s,p)}}return this.__ownerID=void 0,this._values=He().withMutations(function(d){d.setSize(l._keys.length),br(a).forEach(function(m,x){d.set(l._indices[x],m===l._defaultValues[x]?void 0:m)})}),this},s=i.prototype=Object.create(jt);return s.constructor=i,t&&(i.displayName=t),i};gt.prototype.toString=function(){for(var e=sf(this)+" { ",t=this._keys,r,i=0,s=t.length;i!==s;i++)r=t[i],e+=(i?", ":"")+r+": "+Va(this.get(r));return e+" }"},gt.prototype.equals=function(e){return this===e||ns(e)&&To(this).equals(To(e))},gt.prototype.hashCode=function(){return To(this).hashCode()},gt.prototype.has=function(e){return this._indices.hasOwnProperty(e)},gt.prototype.get=function(e,t){if(!this.has(e))return t;var r=this._indices[e],i=this._values.get(r);return i===void 0?this._defaultValues[e]:i},gt.prototype.set=function(e,t){if(this.has(e)){var r=this._values.set(this._indices[e],t===this._defaultValues[e]?void 0:t);if(r!==this._values&&!this.__ownerID)return rf(this,r)}return this},gt.prototype.remove=function(e){return this.set(e)},gt.prototype.clear=function(){var e=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:rf(this,e)},gt.prototype.wasAltered=function(){return this._values.wasAltered()},gt.prototype.toSeq=function(){return To(this)},gt.prototype.toJS=function(){return fc(this)},gt.prototype.entries=function(){return this.__iterator(cr)},gt.prototype.__iterator=function(e,t){return To(this).__iterator(e,t)},gt.prototype.__iterate=function(e,t){return To(this).__iterate(e,t)},gt.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._values.__ensureOwner(e);return e?rf(this,t,e):(this.__ownerID=e,this._values=t,this)},gt.isRecord=ns,gt.getDescriptiveName=sf;var jt=gt.prototype;jt[Hm]=!0,jt[Ua]=jt.remove,jt.deleteIn=jt.removeIn=Uh,jt.getIn=k0,jt.hasIn=Ln.hasIn,jt.merge=v0,jt.mergeWith=x0,jt.mergeIn=Bh,jt.mergeDeep=S0,jt.mergeDeepWith=E0,jt.mergeDeepIn=Vh,jt.setIn=Nh,jt.update=zh,jt.updateIn=kh,jt.withMutations=Wa,jt.asMutable=ja,jt.asImmutable=Xa,jt[Ql]=jt.entries,jt.toJSON=jt.toObject=Ln.toObject,jt.inspect=jt.toSource=function(){return this.toString()};function rf(n,e,t){var r=Object.create(Object.getPrototypeOf(n));return r._values=e,r.__ownerID=t,r}function sf(n){return n.constructor.displayName||n.constructor.name||"Record"}function To(n){return yh(n._keys.map(function(e){return[e,n.get(e)]}))}function Vy(n,e){try{Object.defineProperty(n,e,{get:function(){return this.get(e)},set:function(t){Ba(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch{}}var Hy=(function(n){function e(t,r){if(!(this instanceof e))return new e(t,r);if(this._value=t,this.size=r===void 0?1/0:Math.max(0,r),this.size===0){if(of)return of;of=this}}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},e.prototype.get=function(r,i){return this.has(r)?this._value:i},e.prototype.includes=function(r){return Kt(this._value,r)},e.prototype.slice=function(r,i){var s=this.size;return Fa(r,i,s)?this:new e(this._value,za(i,s)-ho(r,s))},e.prototype.reverse=function(){return this},e.prototype.indexOf=function(r){return Kt(this._value,r)?0:-1},e.prototype.lastIndexOf=function(r){return Kt(this._value,r)?this.size:-1},e.prototype.__iterate=function(r,i){for(var s=this.size,o=0;o!==s&&r(this._value,i?s-++o:o++,this)!==!1;);return o},e.prototype.__iterator=function(r,i){var s=this,o=this.size,a=0;return new Tt(function(){return a===o?In():Yt(r,i?o-++a:a++,s._value)})},e.prototype.equals=function(r){return r instanceof e?Kt(this._value,r._value):Jh(this,r)},e})(wr),of;function At(n,e){return K0([],e||Gy,n,"",e&&e.length>2?[]:void 0,{"":n})}function K0(n,e,t,r,i,s){if(typeof t!="string"&&!Mr(t)&&(_h(t)||mh(t)||qh(t))){if(~n.indexOf(t))throw new TypeError("Cannot convert circular structure to Immutable");n.push(t),i&&r!==""&&i.push(r);var o=e.call(s,r,vn(t).map(function(a,l){return K0(n,e,a,l,i,t)}),i&&i.slice());return n.pop(),i&&i.pop(),o}return t}function Gy(n,e){return Bn(e)?e.toList():Bt(e)?e.toMap():e.toSet()}var Wy="5.1.3",jy=Mn;const Xy=Object.freeze(Object.defineProperty({__proto__:null,Collection:Mn,Iterable:jy,List:He,Map:Ie,OrderedMap:fi,OrderedSet:wo,PairSorting:ky,Range:z0,Record:gt,Repeat:Hy,Seq:vn,Set:Eo,Stack:cc,fromJS:At,get:Dh,getIn:ef,has:f0,hasIn:B0,hash:Zn,is:Kt,isAssociative:Zl,isCollection:Kn,isImmutable:Mr,isIndexed:Bn,isKeyed:Bt,isList:$h,isMap:tc,isOrdered:Br,isOrderedMap:Eh,isOrderedSet:Zh,isPlainObject:qh,isRecord:ns,isSeq:Jl,isSet:hc,isStack:lc,isValueObject:bh,merge:xy,mergeDeep:Sy,mergeDeepWith:Ey,mergeWith:yy,remove:d0,removeIn:_0,set:p0,setIn:g0,update:Fh,updateIn:Is,version:Wy},Symbol.toStringTag,{value:"Module"})),sn="MODE_IDLE",qs="MODE_2D_ZOOM_IN",Ds="MODE_2D_ZOOM_OUT",Ns="MODE_2D_PAN",Tr="MODE_3D_VIEW",Ao="MODE_3D_FIRST_PERSON",Ar="MODE_WAITING_DRAWING_LINE",Us="MODE_WAITING_DRAWING_SURFACE",Vr="MODE_DRAGGING_LINE",Hr="MODE_DRAGGING_VERTEX",Gr="MODE_DRAGGING_ITEM",Wr="MODE_DRAGGING_HOLE",Jn="MODE_DRAWING_LINE",hr="MODE_DRAWING_HOLE",Cr="MODE_DRAWING_ITEM",di="MODE_DRAWING_SURFACE",Di="MODE_ROTATING_ITEM",af="MODE_UPLOADING_IMAGE",lf="MODE_FITTING_IMAGE",cf="MODE_VIEWING_CATALOG",Z0="MODE_CONFIGURING_PROJECT",uf=[sn,qs,Ds,Ns,Ar,Jn,hr,Cr,Vr,Hr,Gr,Wr,lf,af,Di],$y="mm",Rr="cm",Yy="m",Ky="in",J0="ft",Q0=[$y,Rr,Yy,Ky,J0,"mi"],pi=1e-6,Pr={DELETE:46,BACKSPACE:8,ESC:27,Z:90,ALT:18,C:67,V:86,CTRL:17,ENTER:13,TAB:9},Qn=(n,e=6)=>n&&e?parseFloat(parseFloat(n.toString()).toFixed(e)):0,Co=n=>{let e=n;return e<0&&(e=~e+1),e};function hf(n,e){return n.x===e.x?n.y-e.y:n.x-e.x}function pc(n,e){return hf(n,e)>0?e:n}function ff(n,e){return hf(n,e)>0?n:e}function rl(n){return n.sort(hf)}function Cn(n,e,t,r){let i=n-t,s=e-r;return Math.sqrt(i*i+s*s)}function mc(n,e){let{x:t,y:r}=n,{x:i,y:s}=e;return Cn(t,r,i,s)}function gc(n){return{a:0,b:1,c:-n}}function _c(n){return{a:1,b:0,c:-n}}function Zy(n,e,t,r,i){return Co(n*r+e*i+t)/Math.sqrt(n*n+e*e)}function Jy(n,e,t,r,i){let s=n*n+e*e;return{x:(e*(e*r-n*i)-n*t)/s,y:(n*-e*r+n*i-e*t)/s}}function il(n,e,t,r,i,s){let o=e*r-n*i;if(o===0)return;let a=(n*s-t*r)/o;return{x:(t*i-e*s)/o,y:a}}function Qy(n,e,t,r){let{x:i,y:s}=n,{x:o,y:a}=e,{x:l,y:c}=t,{x:h,y:f}=r,p=(f-c)*(o-i)-(h-l)*(a-s),d=(h-l)*(s-c)-(f-c)*(i-l),m=(o-i)*(s-c)-(a-s)*(i-l);if(Co(p)<=pi){if(Co(d)<=pi&&Co(m)<=pi){let _=(A,q)=>A.x===q.x?A.y-q.y:A.x-q.x,w=[n,e].sort(_),E=[t.toJS(),r.toJS()].sort(_),[S,b]=[w,E].sort((A,q)=>_(A[0],q[0]));return S[1].x===b[0].x?{type:b[0].y<=S[1].y?"colinear":"none"}:{type:b[0].x<=S[1].x?"colinear":"none"}}return{type:"parallel"}}let x=d/p,v=m/p;return x>=0-pi&&x<=1+pi&&v>=0-pi&&v<=1+pi?{type:"intersecting",point:{x:i+x*(o-i),y:s+x*(a-s)}}:{type:"none"}}function eg(n,e,t,r,i,s){let o=i-n,a=s-e,l=t-n,c=r-e,h=o*l+a*c,f=l*l+c*c,p=-1;f!=0&&(p=h/f);let d,m;p<0?(d=n,m=e):p>1?(d=t,m=r):(d=n+p*l,m=e+p*c);let x=i-d,v=s-m;return Math.sqrt(x*x+v*v)}function e3(n,e,t,r,i,s,o=pi){return eg(n,e,t,r,i,s)<=o}function t3(n,e,t,r,i,s){if(n===t)return{x:n,y:s};if(e===r)return{x:i,y:e};let o=(r-e)/(t-n),a=e-o*n,l=-1/o,h=(s-l*i-a)/(o-l),f=o*h+a;return{x:h,y:f}}function On(n,e,t,r,i,s){let o=Cn(n,e,t,r),l=Cn(n,e,i,s)/o;return n>t&&(l=n3(l,0,1,1,0)),l}function n3(n,e,t,r,i){return r+(i-r)*(n-e)/(t-e)}function r3(n,e,t,r){return-Math.atan2(e-r,t-n)*180/Math.PI}function df(n,e,t,r){return Math.atan2(r-e,t-n)}function i3(n,e,t,r){return Math.atan2(Math.abs(r-e),Math.abs(t-n))}function jr({x:n,y:e},{x:t,y:r}){return Co(n-t)<=pi&&Co(e-r)<=pi}function vc(n,e,t,r,i,s=6){let o=df(n,e,t,r);return{x:Qn(n+Math.cos(o)*i,s),y:Qn(e+Math.sin(o)*i,s)}}function s3(n,e,t){let r=n.length>>1,i,s,o=n[2*r-3]-t,a=n[2*r-2]-e,l=n[2*r-1]-t;if(a===0&&l===0)return!1;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-e,l=n[2*h+1]-t,a===0&&l===0)return!1;o!==l&&(s=l>o)}let c=0;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-e,l=n[2*h+1]-t,o<0&&l<0||o>0&&l>0||i<0&&a<0)continue;if(o===l&&Math.min(i,a)<0)return!0;if(o===l)continue;let f=i+(a-i)*-o/(l-o);if(f===0)return!1;f>0&&c++,o===0&&s&&l>o&&c--,o===0&&!s&&l<o&&c--,s=l>o}return(c&1)===1}function o3(n,e){let t=Math.cos(n);return t<e?0:t}function a3(n,e){let t=Math.sin(n);return t<e?0:t}function l3(n,e,t,r){return{x:(n+t)/2,y:(e+r)/2}}function c3(n){let e=n.reduce((t,r)=>({x:t.x+r.x,y:t.y+r.y}),{x:0,y:0});return{x:e.x/n.length,y:e.y/n.length}}function tg(n,e,t,r,i){let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=n-t,c=e-r;return{x:o*l-a*c+t,y:a*l+o*c+r}}const pf="SNAP_POINT",mf="SNAP_LINE",gf="SNAP_SEGMENT",_f="SNAP_GRID",ng="SNAP_GUIDE",u3=Ie({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class h3 extends gt({type:"point",x:-1,y:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:Cn(this.x,this.y,e,t)}}isNear(e,t,r){return~(this.x-e)+1<r&&~(this.y-t)+1<r}}class f3 extends gt({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{...Jy(this.a,this.b,this.c,e,t),distance:Zy(this.a,this.b,this.c,e,t)}}isNear(e,t,r){return!0}}class d3 extends gt({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{...t3(this.x1,this.y1,this.x2,this.y2,e,t),distance:eg(this.x1,this.y1,this.x2,this.y2,e,t)}}isNear(e,t,r){return!0}}class p3 extends gt({type:"grid",x:-1,y:-1,radius:1,priority:1,related:He()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:Cn(this.x,this.y,e,t)}}isNear(e,t,r){return~(this.x-e)+1<r&&~(this.y-t)+1<r}}function mi(n,e,t,r){let i={point:r.get(pf),line:r.get(mf),"line-segment":r.get(gf),grid:r.get(_f)};return n.valueSeq().filter(s=>i[s.type]&&s.isNear(e,t,s.radius)).map(s=>({snap:s,point:s.nearestPoint(e,t)})).filter(({snap:{radius:s},point:{distance:o}})=>o<s).min(({snap:{priority:s},point:{distance:o}},{snap:{priority:a},point:{distance:l}})=>s===a?o<l?-1:1:s>a?-1:1)}function vf(n,e,t,r,i,s){return s=He([s]),n.push(new h3({x:e,y:t,radius:r,priority:i,related:s}))}function xc(n,e,t,r,i,s,o){return o=He([o]),n.withMutations(a=>{if(a.some(c=>c.type==="line"&&e===c.a&&t===c.b&&r===c.c))return a;a.valueSeq().filter(c=>c.type==="line").map(c=>il(c.a,c.b,c.c,e,t,r)).filter(c=>c!==void 0).forEach(({x:c,y:h})=>vf(a,c,h,20,40)),a.push(new f3({a:e,b:t,c:r,radius:i,priority:s,related:o}))})}function sl(n,e,t,r,i,s,o,a){return a=He([a]),n.push(new d3({x1:e,y1:t,x2:r,y2:i,radius:s,priority:o,related:a}))}function m3(n,e,t,r,i,s){return s=He([s]),n.push(new p3({x:e,y:t,radius:r,priority:i,related:s}))}let Ni=(n,e,t)=>n?Ie(n).map(r=>new e(r)).toMap():t||Ie();class xf extends gt({id:"",type:"",properties:Ie()},"Grid"){constructor(e={}){super({...e,properties:At(e.properties||{})})}}const g3=Ie({h1:new xf({id:"h1",type:"horizontal-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}}),v1:new xf({id:"v1",type:"vertical-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}})});class rg extends gt({vertices:He(),lines:He(),holes:He(),areas:He(),items:He()},"ElementsSet"){constructor(e={}){super({vertices:He(e.vertices||[]),lines:He(e.lines||[]),holes:He(e.holes||[]),areas:He(e.areas||[]),items:He(e.items||[])})}}const Ro={id:"",type:"",prototype:"",name:"",misc:Ie(),selected:!1,properties:Ie(),visible:!0};let ig=class extends gt({...Ro,x:-1,y:-1,prototype:"vertices",lines:He(),areas:He()},"Vertex"){constructor(e={}){super({...e,lines:He(e.lines||[]),areas:He(e.areas||[])})}},sg=class extends gt({...Ro,prototype:"lines",vertices:He(),holes:He()},"Line"){constructor(e={}){super({...e,properties:At(e.properties||{}),vertices:He(e.vertices||[]),holes:He(e.holes||[])})}},og=class extends gt({...Ro,prototype:"holes",offset:-1,line:""},"Hole"){constructor(e={}){super({...e,properties:At(e.properties||{})})}},ag=class extends gt({...Ro,prototype:"areas",vertices:He(),holes:He()},"Area"){constructor(e={}){super({...e,properties:At(e.properties||{}),vertices:He(e.vertices||[])})}},lg=class extends gt({...Ro,prototype:"items",x:0,y:0,rotation:0,altitude:0},"Item"){constructor(e={}){super({...e,properties:At(e.properties||{})})}},yf=class extends gt({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:Ie(),lines:Ie(),holes:Ie(),areas:Ie(),items:Ie(),selected:new rg},"Layer"){constructor(e={}){super({...e,vertices:Ni(e.vertices,ig),lines:Ni(e.lines,sg),holes:Ni(e.holes,og),areas:Ni(e.areas,ag),items:Ni(e.items,lg),selected:new rg(e.selected)})}},Sf=class extends gt({...Ro,prototype:"groups",x:0,y:0,rotation:0,elements:Ie()},"Group"){constructor(e={}){super({...e,properties:At(e.properties||{}),elements:At(e.elements||{})})}};const _3=Ie({"layer-1":new yf({id:"layer-1",name:"default"})});let yc=class extends gt({unit:J0,layers:Ie(),grids:Ie(),selectedLayer:null,groups:Ie(),width:3e3,height:2e3,meta:Ie(),guides:Ie()},"Scene"){constructor(e={}){let t=Ni(e.layers,yf,_3);super({...e,grids:Ni(e.grids,xf,g3),layers:t,selectedLayer:t.first().id,groups:Ni(e.groups||{},Sf),meta:e.meta?At(e.meta):Ie(),guides:e.guides?At(e.guides):Ie({horizontal:Ie(),vertical:Ie(),circular:Ie()})})}};class v3 extends gt({name:"",prototype:"",info:Ie(),properties:Ie()},"CatalogElement"){constructor(e={}){super({...e,info:At(e.info),properties:At(e.properties)})}}let Ef=class extends gt({ready:!1,page:"root",path:He(),elements:Ie()},"Catalog"){constructor(e={}){let t=Ni(e.elements,v3);super({elements:t,ready:!t.isEmpty()})}factoryElement(e,t,r){if(!this.elements.has(e)){let o=this.elements.map(a=>a.name).toArray();throw new Error(`Element ${e} does not exist in catalog ${o}`)}const i=this.elements.get(e),s=i.properties.map((o,a)=>r&&r.has(a)?r.get(a):o.get("defaultValue"));switch(i.prototype){case"lines":return new sg(t).merge({properties:s});case"holes":return new og(t).merge({properties:s});case"areas":return new ag(t).merge({properties:s});case"items":return new lg(t).merge({properties:s});default:throw new Error("prototype not valid")}}};class cg extends gt({list:He(),first:null,last:null,redoList:He()},"HistoryStructure"){constructor(e={}){super({list:At(e.list||[]),first:new yc(e.scene),last:new yc(e.last||e.scene)})}}let Sc=class extends gt({mode:sn,scene:new yc,sceneHistory:new cg,catalog:new Ef,viewer2D:Ie(),mouse:Ie({x:0,y:0}),zoom:0,snapMask:u3,snapElements:He(),activeSnapElement:null,drawingSupport:Ie(),draggingSupport:Ie(),rotatingSupport:Ie(),errors:He(),warnings:He(),clipboardProperties:Ie(),selectedElementsHistory:He(),misc:Ie(),alterate:!1},"State"){constructor(e={}){super({...e,scene:new yc(e.scene),sceneHistory:new cg(e),catalog:new Ef(e.catalog||{}),viewer2D:Ie(e.viewer2D||{}),drawingSupport:Ie(e.drawingSupport||{}),draggingSupport:Ie(e.draggingSupport||{}),rotatingSupport:Ie(e.rotatingSupport||{}),misc:e.misc?At(e.misc):Ie()})}};function Ec(n){let e=[];for(let t=0;t<n;++t)e.push([]);return e}class ug{constructor(e,t){ht(this,"u");ht(this,"v");this.u=e,this.v=t}}class x3{constructor(e){ht(this,"count");ht(this,"subgraphs");ht(this,"time");ht(this,"V");ht(this,"E");ht(this,"adj");ht(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=e,this.E=0,this.adj=[],this.adj=Ec(e)}addEdge(e,t){this.adj[e].push(t),this.E++}_BCCUtil(e,t,r,i,s){t[e]=r[e]=++this.time,this.children=0,this.adj[e].forEach(o=>{if(t[o]==-1){if(this.children++,s[o]=e,i.push(new ug(e,o)),this._BCCUtil(o,t,r,i,s),r[e]>r[o]&&(r[e]=r[o]),t[e]==1&&this.children>1||t[e]>1&&r[o]>=t[e]){let a=[];for(;i[i.length-1].u!=e||i[i.length-1].v!=o;)a.push(i[i.length-1]),i.splice(i.length-1,1);a.push(i[i.length-1]),this.subgraphs.push(a),a=[],i.splice(i.length-1,1),this.count++}}else o!=s[e]&&t[o]<r[e]&&(r[e]>t[o]&&(r[e]=t[o]),i.push(new ug(e,o)))})}BCC(){let e=this.V,t=Ec(e),r=Ec(e),i=Ec(e),s=[];for(let o=0;o<e;o++)t[o]=-1,r[o]=-1,i[o]=-1;for(let o=0;o<e;o++){t[o]==-1&&this._BCCUtil(o,t,r,s,i);let a=0,l=[];for(;s.length>0;)a=1,l.push(s[s.length-1]),s.splice(s.length-1,1);a==1&&(this.subgraphs.push(l),l=[],this.count++)}}}const y3=(n,e)=>{let t=[];return n.forEach(r=>{t.push([]);let i=S3(r);i.forEach(s=>{e.adj[s].forEach(a=>{s<=a&&i.has(a)&&t[t.length-1].push([s,a])})})}),t},S3=n=>{let e=new Set;return n.forEach(t=>{e.add(t.u),e.add(t.v)}),e};function E3(n,e){return[n[0]-e[0],n[1]-e[1]]}function hg(n,e){return(n%e+e)%e}function b3(n){return n.map(function(t){return{ev:t,color:0,direction:-1}})}function M3(n,e){let t=E3(e,n);return Math.atan2(t[1],t[0])}function w3(n,e){return n.map(function(t,r){let i=[];return e.forEach(function(s,o){let a,l;s[0]===r&&(a=s[1],l=1),s[1]===r&&(a=s[0],l=0),a!==void 0&&i.push({index:o,endpoint:a,angle:M3(t,n[a]),edge:s,position:l})}),i.sort(function(s,o){return o.angle-s.angle}),i})}function fg(n,e){let t,r;for(t=0;t<e.length;t+=1)if(e[t].color<2)return r=-1*e[t].direction,pg(e,t,r),{edge:t,direction:r,position:r===-1?0:1}}function dg(n,e,t,r){let i=n[r[e][t]],s=i.length,o,a,l;for(l=0;l<s;l+=1)if(o=i[l],o.index===e)return a=i[hg(l+1,i.length)],{edge:a.index,vertex:a.endpoint,position:a.position,direction:a.position?1:-1}}function pg(n,e,t){n[e].color+=1,n[e].direction=t}function T3(n,e){let t=b3(e),r=w3(n,e),i=[],s=[],o=[],a,l,c,h,f=fg(r,t);for(;f!==void 0;){for(a=[e[f.edge][hg(f.position+1,2)],e[f.edge][f.position]],l=[f.edge],c=[f.direction],h=dg(r,f.edge,f.position,e);h.edge!==f.edge;)a.push(h.vertex),l.push(h.edge),c.push(h.direction),pg(t,h.edge,h.direction),h=dg(r,h.edge,h.position,e);s.push(l),i.push(a),o.push(c),f=fg(r,t)}return{v_cycles:i,e_cycles:s,dir_e_cycles:o,ev_mapping:t}}function A3(n,e){let t=[],r,i,s;for(s=0;s<e.length;s+=1)r=e[s],i=n[s],(r.length<3||i[0]!==i[i.length-1])&&t.push(s);return t}function C3(n,e){let t=T3(n,e),r=t.v_cycles,i=t.e_cycles;A3(r,i).forEach(p=>{r.splice(p,1),i.splice(p,1)});let o=t.dir_e_cycles,l=t.e_cycles.map((p,d)=>p.map(function(m,x){let v,_;return o[d][x]>0?(v=e[m][0],_=e[m][1]):(v=e[m][1],_=e[m][0]),(n[_][0]-n[v][0])*(n[_][1]+n[v][1])})).map(p=>p.reduce((d,m)=>d+m)),c=l.filter(p=>p>0).length,h=l.length-c,f=c>=h?1:-1;return{v_cycles:t.v_cycles.filter((p,d)=>f*l[d]>0),e_cycles:t.e_cycles.filter((p,d)=>f*l[d]>0),ev_mapping:t.ev_mapping}}function R3(n,e){let t=He();const r=new x3(n.length);e.forEach(([l,c])=>{r.addEdge(l,c),r.addEdge(c,l)}),r.BCC();const i=r.subgraphs.filter(l=>l.length>=3),s=y3(i,r),o=[];return s.forEach(l=>{l.forEach(c=>o.push(c))}),C3(n,o).v_cycles.forEach(l=>{l.shift(),t=t.push(l)}),t}function P3(n){let e=0,t=0,r=n.size;for(e=0;e<r;e++){let{x:i,y:s}=n.get(e)||{x:0,y:0},{x:o,y:a}=n.get((e+1)%r)||{x:0,y:0};t+=(o-i)*(a+s)}return t>0}function bf(n,e=He(),t=Ie()){let{width:r,height:i}=n,s,o,a;return e.withMutations(l=>{if(n.layers.forEach(c=>{let{lines:h,vertices:f}=c;f.forEach(({id:p,x:d,y:m})=>{t.get(pf)&&vf(l,d,m,10,10,p),t.get(mf)&&({a:s,b:o,c:a}=gc(m),xc(l,s,o,a,10,1,p),{a:s,b:o,c:a}=_c(d),xc(l,s,o,a,10,1,p))}),t.get(gf)&&h.forEach(({id:p,vertices:[d,m]})=>{let{x,y:v}=f.get(d),{x:_,y:w}=f.get(m);sl(l,x,v,_,w,20,1,p)})}),t.get(_f)){let c=5,h=100/c,f=r/h,p=i/h;for(let d=0;d<f;d++){let m=d*h;for(let x=0;x<p;x++){let v=x*h,_=!(d%c),w=!(x%c);m3(l,m,v,10,_&&w?15:10,null)}}}if(t.get(ng)){let c=n.getIn(["guides","horizontal"]),h=n.getIn(["guides","vertical"]),f=c.valueSeq(),p=h.valueSeq();f.forEach(d=>{p.forEach(m=>{vf(l,m,d,10,10)})}),f.forEach(d=>sl(l,0,d,r,d,20,1)),p.forEach(d=>sl(l,d,0,d,i,20,1))}})}var bc={exports:{}},I3=bc.exports,mg;function Mf(){return mg||(mg=1,(function(n,e){(function(t,r){n.exports=r()})(I3,function(){var t=Array.prototype.slice;function r(u,g){g&&(u.prototype=Object.create(g.prototype)),u.prototype.constructor=u}function i(u){return l(u)?u:z(u)}r(s,i);function s(u){return c(u)?u:rt(u)}r(o,i);function o(u){return h(u)?u:Le(u)}r(a,i);function a(u){return l(u)&&!f(u)?u:at(u)}function l(u){return!!(u&&u[d])}function c(u){return!!(u&&u[m])}function h(u){return!!(u&&u[x])}function f(u){return c(u)||h(u)}function p(u){return!!(u&&u[v])}i.isIterable=l,i.isKeyed=c,i.isIndexed=h,i.isAssociative=f,i.isOrdered=p,i.Keyed=s,i.Indexed=o,i.Set=a;var d="@@__IMMUTABLE_ITERABLE__@@",m="@@__IMMUTABLE_KEYED__@@",x="@@__IMMUTABLE_INDEXED__@@",v="@@__IMMUTABLE_ORDERED__@@",_="delete",w=5,E=1<<w,S=E-1,b={},A={value:!1},q={value:!1};function O(u){return u.value=!1,u}function T(u){u&&(u.value=!0)}function I(){}function N(u,g){g=g||0;for(var y=Math.max(0,u.length-g),M=new Array(y),C=0;C<y;C++)M[C]=u[C+g];return M}function H(u){return u.size===void 0&&(u.size=u.__iterate(Q)),u.size}function W(u,g){if(typeof g!="number"){var y=g>>>0;if(""+y!==g||y===4294967295)return NaN;g=y}return g<0?H(u)+g:g}function Q(){return!0}function ae(u,g,y){return(u===0||y!==void 0&&u<=-y)&&(g===void 0||y!==void 0&&g>=y)}function J(u,g){return B(u,g,0)}function se(u,g){return B(u,g,g)}function B(u,g,y){return u===void 0?y:u<0?Math.max(0,g+u):g===void 0?u:Math.min(g,u)}var ge=0,F=1,X=2,de=typeof Symbol=="function"&&Symbol.iterator,ye="@@iterator",Ee=de||ye;function V(u){this.next=u}V.prototype.toString=function(){return"[Iterator]"},V.KEYS=ge,V.VALUES=F,V.ENTRIES=X,V.prototype.inspect=V.prototype.toSource=function(){return this.toString()},V.prototype[Ee]=function(){return this};function re(u,g,y,M){var C=u===0?g:u===1?y:[g,y];return M?M.value=C:M={value:C,done:!1},M}function Z(){return{value:void 0,done:!0}}function he(u){return!!Pe(u)}function xe(u){return u&&typeof u.next=="function"}function ee(u){var g=Pe(u);return g&&g.call(u)}function Pe(u){var g=u&&(de&&u[de]||u[ye]);if(typeof g=="function")return g}function le(u){return u&&typeof u.length=="number"}r(z,i);function z(u){return u==null?P():l(u)?u.toSeq():Me(u)}z.of=function(){return z(arguments)},z.prototype.toSeq=function(){return this},z.prototype.toString=function(){return this.__toString("Seq {","}")},z.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},z.prototype.__iterate=function(u,g){return De(this,u,g,!0)},z.prototype.__iterator=function(u,g){return Ae(this,u,g,!0)},r(rt,z);function rt(u){return u==null?P().toKeyedSeq():l(u)?c(u)?u.toSeq():u.fromEntrySeq():te(u)}rt.prototype.toKeyedSeq=function(){return this},r(Le,z);function Le(u){return u==null?P():l(u)?c(u)?u.entrySeq():u.toIndexedSeq():pe(u)}Le.of=function(){return Le(arguments)},Le.prototype.toIndexedSeq=function(){return this},Le.prototype.toString=function(){return this.__toString("Seq [","]")},Le.prototype.__iterate=function(u,g){return De(this,u,g,!1)},Le.prototype.__iterator=function(u,g){return Ae(this,u,g,!1)},r(at,z);function at(u){return(u==null?P():l(u)?c(u)?u.entrySeq():u:pe(u)).toSetSeq()}at.of=function(){return at(arguments)},at.prototype.toSetSeq=function(){return this},z.isSeq=$e,z.Keyed=rt,z.Set=at,z.Indexed=Le;var ze="@@__IMMUTABLE_SEQ__@@";z.prototype[ze]=!0,r(Xe,Le);function Xe(u){this._array=u,this.size=u.length}Xe.prototype.get=function(u,g){return this.has(u)?this._array[W(this,u)]:g},Xe.prototype.__iterate=function(u,g){for(var y=this._array,M=y.length-1,C=0;C<=M;C++)if(u(y[g?M-C:C],C,this)===!1)return C+1;return C},Xe.prototype.__iterator=function(u,g){var y=this._array,M=y.length-1,C=0;return new V(function(){return C>M?Z():re(u,C,y[g?M-C++:C++])})},r(be,rt);function be(u){var g=Object.keys(u);this._object=u,this._keys=g,this.size=g.length}be.prototype.get=function(u,g){return g!==void 0&&!this.has(u)?g:this._object[u]},be.prototype.has=function(u){return this._object.hasOwnProperty(u)},be.prototype.__iterate=function(u,g){for(var y=this._object,M=this._keys,C=M.length-1,D=0;D<=C;D++){var k=M[g?C-D:D];if(u(y[k],k,this)===!1)return D+1}return D},be.prototype.__iterator=function(u,g){var y=this._object,M=this._keys,C=M.length-1,D=0;return new V(function(){var k=M[g?C-D:D];return D++>C?Z():re(u,k,y[k])})},be.prototype[v]=!0,r(tt,Le);function tt(u){this._iterable=u,this.size=u.length||u.size}tt.prototype.__iterateUncached=function(u,g){if(g)return this.cacheResult().__iterate(u,g);var y=this._iterable,M=ee(y),C=0;if(xe(M))for(var D;!(D=M.next()).done&&u(D.value,C++,this)!==!1;);return C},tt.prototype.__iteratorUncached=function(u,g){if(g)return this.cacheResult().__iterator(u,g);var y=this._iterable,M=ee(y);if(!xe(M))return new V(Z);var C=0;return new V(function(){var D=M.next();return D.done?D:re(u,C++,D.value)})},r(lt,Le);function lt(u){this._iterator=u,this._iteratorCache=[]}lt.prototype.__iterateUncached=function(u,g){if(g)return this.cacheResult().__iterate(u,g);for(var y=this._iterator,M=this._iteratorCache,C=0;C<M.length;)if(u(M[C],C++,this)===!1)return C;for(var D;!(D=y.next()).done;){var k=D.value;if(M[C]=k,u(k,C++,this)===!1)break}return C},lt.prototype.__iteratorUncached=function(u,g){if(g)return this.cacheResult().__iterator(u,g);var y=this._iterator,M=this._iteratorCache,C=0;return new V(function(){if(C>=M.length){var D=y.next();if(D.done)return D;M[C]=D.value}return re(u,C,M[C++])})};function $e(u){return!!(u&&u[ze])}var U;function P(){return U||(U=new Xe([]))}function te(u){var g=Array.isArray(u)?new Xe(u).fromEntrySeq():xe(u)?new lt(u).fromEntrySeq():he(u)?new tt(u).fromEntrySeq():typeof u=="object"?new be(u):void 0;if(!g)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+u);return g}function pe(u){var g=fe(u);if(!g)throw new TypeError("Expected Array or iterable object of values: "+u);return g}function Me(u){var g=fe(u)||typeof u=="object"&&new be(u);if(!g)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+u);return g}function fe(u){return le(u)?new Xe(u):xe(u)?new lt(u):he(u)?new tt(u):void 0}function De(u,g,y,M){var C=u._cache;if(C){for(var D=C.length-1,k=0;k<=D;k++){var $=C[y?D-k:k];if(g($[1],M?$[0]:k,u)===!1)return k+1}return k}return u.__iterateUncached(g,y)}function Ae(u,g,y,M){var C=u._cache;if(C){var D=C.length-1,k=0;return new V(function(){var $=C[y?D-k:k];return k++>D?Z():re(g,M?$[0]:k-1,$[1])})}return u.__iteratorUncached(g,y)}function Ge(u,g){return g?We(g,u,"",{"":u}):Ce(u)}function We(u,g,y,M){return Array.isArray(g)?u.call(M,y,Le(g).map(function(C,D){return We(u,C,D,g)})):qe(g)?u.call(M,y,rt(g).map(function(C,D){return We(u,C,D,g)})):g}function Ce(u){return Array.isArray(u)?Le(u).map(Ce).toList():qe(u)?rt(u).map(Ce).toMap():u}function qe(u){return u&&(u.constructor===Object||u.constructor===void 0)}function Be(u,g){if(u===g||u!==u&&g!==g)return!0;if(!u||!g)return!1;if(typeof u.valueOf=="function"&&typeof g.valueOf=="function"){if(u=u.valueOf(),g=g.valueOf(),u===g||u!==u&&g!==g)return!0;if(!u||!g)return!1}return!!(typeof u.equals=="function"&&typeof g.equals=="function"&&u.equals(g))}function Ye(u,g){if(u===g)return!0;if(!l(g)||u.size!==void 0&&g.size!==void 0&&u.size!==g.size||u.__hash!==void 0&&g.__hash!==void 0&&u.__hash!==g.__hash||c(u)!==c(g)||h(u)!==h(g)||p(u)!==p(g))return!1;if(u.size===0&&g.size===0)return!0;var y=!f(u);if(p(u)){var M=u.entries();return g.every(function(ce,ue){var _e=M.next().value;return _e&&Be(_e[1],ce)&&(y||Be(_e[0],ue))})&&M.next().done}var C=!1;if(u.size===void 0)if(g.size===void 0)typeof u.cacheResult=="function"&&u.cacheResult();else{C=!0;var D=u;u=g,g=D}var k=!0,$=g.__iterate(function(ce,ue){if(y?!u.has(ce):C?!Be(ce,u.get(ue,b)):!Be(u.get(ue,b),ce))return k=!1,!1});return k&&u.size===$}r(Re,Le);function Re(u,g){if(!(this instanceof Re))return new Re(u,g);if(this._value=u,this.size=g===void 0?1/0:Math.max(0,g),this.size===0){if(ft)return ft;ft=this}}Re.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Re.prototype.get=function(u,g){return this.has(u)?this._value:g},Re.prototype.includes=function(u){return Be(this._value,u)},Re.prototype.slice=function(u,g){var y=this.size;return ae(u,g,y)?this:new Re(this._value,se(g,y)-J(u,y))},Re.prototype.reverse=function(){return this},Re.prototype.indexOf=function(u){return Be(this._value,u)?0:-1},Re.prototype.lastIndexOf=function(u){return Be(this._value,u)?this.size:-1},Re.prototype.__iterate=function(u,g){for(var y=0;y<this.size;y++)if(u(this._value,y,this)===!1)return y+1;return y},Re.prototype.__iterator=function(u,g){var y=this,M=0;return new V(function(){return M<y.size?re(u,M++,y._value):Z()})},Re.prototype.equals=function(u){return u instanceof Re?Be(this._value,u._value):Ye(u)};var ft;function G(u,g){if(!u)throw new Error(g)}r(Se,Le);function Se(u,g,y){if(!(this instanceof Se))return new Se(u,g,y);if(G(y!==0,"Cannot step a Range by 0"),u=u||0,g===void 0&&(g=1/0),y=y===void 0?1:Math.abs(y),g<u&&(y=-y),this._start=u,this._end=g,this._step=y,this.size=Math.max(0,Math.ceil((g-u)/y-1)+1),this.size===0){if(Oe)return Oe;Oe=this}}Se.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},Se.prototype.get=function(u,g){return this.has(u)?this._start+W(this,u)*this._step:g},Se.prototype.includes=function(u){var g=(u-this._start)/this._step;return g>=0&&g<this.size&&g===Math.floor(g)},Se.prototype.slice=function(u,g){return ae(u,g,this.size)?this:(u=J(u,this.size),g=se(g,this.size),g<=u?new Se(0,0):new Se(this.get(u,this._end),this.get(g,this._end),this._step))},Se.prototype.indexOf=function(u){var g=u-this._start;if(g%this._step===0){var y=g/this._step;if(y>=0&&y<this.size)return y}return-1},Se.prototype.lastIndexOf=function(u){return this.indexOf(u)},Se.prototype.__iterate=function(u,g){for(var y=this.size-1,M=this._step,C=g?this._start+y*M:this._start,D=0;D<=y;D++){if(u(C,D,this)===!1)return D+1;C+=g?-M:M}return D},Se.prototype.__iterator=function(u,g){var y=this.size-1,M=this._step,C=g?this._start+y*M:this._start,D=0;return new V(function(){var k=C;return C+=g?-M:M,D>y?Z():re(u,D++,k)})},Se.prototype.equals=function(u){return u instanceof Se?this._start===u._start&&this._end===u._end&&this._step===u._step:Ye(this,u)};var Oe;r(ke,i);function ke(){throw TypeError("Abstract")}r(Te,ke);function Te(){}r(me,ke);function me(){}r(Ke,ke);function Ke(){}ke.Keyed=Te,ke.Indexed=me,ke.Set=Ke;var ut=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(g,y){g=g|0,y=y|0;var M=g&65535,C=y&65535;return M*C+((g>>>16)*C+M*(y>>>16)<<16>>>0)|0};function Ot(u){return u>>>1&1073741824|u&3221225471}function dt(u){if(u===!1||u===null||u===void 0||typeof u.valueOf=="function"&&(u=u.valueOf(),u===!1||u===null||u===void 0))return 0;if(u===!0)return 1;var g=typeof u;if(g==="number"){if(u!==u||u===1/0)return 0;var y=u|0;for(y!==u&&(y^=u*4294967295);u>4294967295;)u/=4294967295,y^=u;return Ot(y)}if(g==="string")return u.length>eh?ai(u):sr(u);if(typeof u.hashCode=="function")return u.hashCode();if(g==="object")return Ju(u);if(typeof u.toString=="function")return sr(u.toString());throw new Error("Value type "+g+" cannot be hashed.")}function ai(u){var g=Bl[u];return g===void 0&&(g=sr(u),kl===th&&(kl=0,Bl={}),kl++,Bl[u]=g),g}function sr(u){for(var g=0,y=0;y<u.length;y++)g=31*g+u.charCodeAt(y)|0;return Ot(g)}function Ju(u){var g;if(Ta&&(g=ws.get(u),g!==void 0)||(g=u[Fr],g!==void 0)||!wa&&(g=u.propertyIsEnumerable&&u.propertyIsEnumerable[Fr],g!==void 0||(g=Qu(u),g!==void 0)))return g;if(g=++Aa,Aa&1073741824&&(Aa=0),Ta)ws.set(u,g);else{if(Ri!==void 0&&Ri(u)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(wa)Object.defineProperty(u,Fr,{enumerable:!1,configurable:!1,writable:!1,value:g});else if(u.propertyIsEnumerable!==void 0&&u.propertyIsEnumerable===u.constructor.prototype.propertyIsEnumerable)u.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},u.propertyIsEnumerable[Fr]=g;else if(u.nodeType!==void 0)u[Fr]=g;else throw new Error("Unable to set a non-enumerable property on object.")}return g}var Ri=Object.isExtensible,wa=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function Qu(u){if(u&&u.nodeType>0)switch(u.nodeType){case 1:return u.uniqueID;case 9:return u.documentElement&&u.documentElement.uniqueID}}var Ta=typeof WeakMap=="function",ws;Ta&&(ws=new WeakMap);var Aa=0,Fr="__immutablehash__";typeof Symbol=="function"&&(Fr=Symbol(Fr));var eh=16,th=255,kl=0,Bl={};function jn(u){G(u!==1/0,"Cannot perform this action with an infinite size.")}r(Mt,Te);function Mt(u){return u==null?Je():Vl(u)&&!p(u)?u:Je().withMutations(function(g){var y=s(u);jn(y.size),y.forEach(function(M,C){return g.set(C,M)})})}Mt.of=function(){var u=t.call(arguments,0);return Je().withMutations(function(g){for(var y=0;y<u.length;y+=2){if(y+1>=u.length)throw new Error("Missing value for key: "+u[y]);g.set(u[y],u[y+1])}})},Mt.prototype.toString=function(){return this.__toString("Map {","}")},Mt.prototype.get=function(u,g){return this._root?this._root.get(0,void 0,u,g):g},Mt.prototype.set=function(u,g){return yt(this,u,g)},Mt.prototype.setIn=function(u,g){return this.updateIn(u,b,function(){return g})},Mt.prototype.remove=function(u){return yt(this,u,b)},Mt.prototype.deleteIn=function(u){return this.updateIn(u,function(){return b})},Mt.prototype.update=function(u,g,y){return arguments.length===1?u(this):this.updateIn([u],g,y)},Mt.prototype.updateIn=function(u,g,y){y||(y=g,g=void 0);var M=Ts(this,A2(u),g,y);return M===b?void 0:M},Mt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},Mt.prototype.merge=function(){return bt(this,void 0,arguments)},Mt.prototype.mergeWith=function(u){var g=t.call(arguments,1);return bt(this,u,g)},Mt.prototype.mergeIn=function(u){var g=t.call(arguments,1);return this.updateIn(u,Je(),function(y){return typeof y.merge=="function"?y.merge.apply(y,g):g[g.length-1]})},Mt.prototype.mergeDeep=function(){return bt(this,Un,arguments)},Mt.prototype.mergeDeepWith=function(u){var g=t.call(arguments,1);return bt(this,Qi(u),g)},Mt.prototype.mergeDeepIn=function(u){var g=t.call(arguments,1);return this.updateIn(u,Je(),function(y){return typeof y.mergeDeep=="function"?y.mergeDeep.apply(y,g):g[g.length-1]})},Mt.prototype.sort=function(u){return hn(La(this,u))},Mt.prototype.sortBy=function(u,g){return hn(La(this,g,u))},Mt.prototype.withMutations=function(u){var g=this.asMutable();return u(g),g.wasAltered()?g.__ensureOwner(this.__ownerID):this},Mt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new I)},Mt.prototype.asImmutable=function(){return this.__ensureOwner()},Mt.prototype.wasAltered=function(){return this.__altered},Mt.prototype.__iterator=function(u,g){return new Ue(this,u,g)},Mt.prototype.__iterate=function(u,g){var y=this,M=0;return this._root&&this._root.iterate(function(C){return M++,u(C[1],C[0],y)},g),M},Mt.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?st(this.size,this._root,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)};function Vl(u){return!!(u&&u[nh])}Mt.isMap=Vl;var nh="@@__IMMUTABLE_MAP__@@",L=Mt.prototype;L[nh]=!0,L[_]=L.remove,L.removeIn=L.deleteIn;function Y(u,g){this.ownerID=u,this.entries=g}Y.prototype.get=function(u,g,y,M){for(var C=this.entries,D=0,k=C.length;D<k;D++)if(Be(y,C[D][0]))return C[D][1];return M},Y.prototype.update=function(u,g,y,M,C,D,k){for(var $=C===b,ce=this.entries,ue=0,_e=ce.length;ue<_e&&!Be(M,ce[ue][0]);ue++);var Ve=ue<_e;if(Ve?ce[ue][1]===C:$)return this;if(T(k),($||!Ve)&&T(D),!($&&ce.length===1)){if(!Ve&&!$&&ce.length>=zn)return Ut(u,ce,M,C);var nt=u&&u===this.ownerID,pt=nt?ce:N(ce);return Ve?$?ue===_e-1?pt.pop():pt[ue]=pt.pop():pt[ue]=[M,C]:pt.push([M,C]),nt?(this.entries=pt,this):new Y(u,pt)}};function ie(u,g,y){this.ownerID=u,this.bitmap=g,this.nodes=y}ie.prototype.get=function(u,g,y,M){g===void 0&&(g=dt(y));var C=1<<((u===0?g:g>>>u)&S),D=this.bitmap;return(D&C)===0?M:this.nodes[$t(D&C-1)].get(u+w,g,y,M)},ie.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=(g===0?y:y>>>g)&S,ce=1<<$,ue=this.bitmap,_e=(ue&ce)!==0;if(!_e&&C===b)return this;var Ve=$t(ue&ce-1),nt=this.nodes,pt=_e?nt[Ve]:void 0,St=Rt(pt,u,g+w,y,M,C,D,k);if(St===pt)return this;if(!_e&&St&&nt.length>=Hl)return en(u,nt,ue,$,St);if(_e&&!St&&nt.length===2&&Qt(nt[Ve^1]))return nt[Ve^1];if(_e&&St&&nt.length===1&&Qt(St))return St;var rn=u&&u===this.ownerID,li=_e?St?ue:ue^ce:ue|ce,Oi=_e?St?Xn(nt,Ve,St,rn):Rn(nt,Ve,rn):or(nt,Ve,St,rn);return rn?(this.bitmap=li,this.nodes=Oi,this):new ie(u,li,Oi)};function oe(u,g,y){this.ownerID=u,this.count=g,this.nodes=y}oe.prototype.get=function(u,g,y,M){g===void 0&&(g=dt(y));var C=(u===0?g:g>>>u)&S,D=this.nodes[C];return D?D.get(u+w,g,y,M):M},oe.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=(g===0?y:y>>>g)&S,ce=C===b,ue=this.nodes,_e=ue[$];if(ce&&!_e)return this;var Ve=Rt(_e,u,g+w,y,M,C,D,k);if(Ve===_e)return this;var nt=this.count;if(!_e)nt++;else if(!Ve&&(nt--,nt<es))return ot(u,ue,nt,$);var pt=u&&u===this.ownerID,St=Xn(ue,$,Ve,pt);return pt?(this.count=nt,this.nodes=St,this):new oe(u,nt,St)};function K(u,g,y){this.ownerID=u,this.keyHash=g,this.entries=y}K.prototype.get=function(u,g,y,M){for(var C=this.entries,D=0,k=C.length;D<k;D++)if(Be(y,C[D][0]))return C[D][1];return M},K.prototype.update=function(u,g,y,M,C,D,k){y===void 0&&(y=dt(M));var $=C===b;if(y!==this.keyHash)return $?this:(T(k),T(D),Nt(this,u,g,y,[M,C]));for(var ce=this.entries,ue=0,_e=ce.length;ue<_e&&!Be(M,ce[ue][0]);ue++);var Ve=ue<_e;if(Ve?ce[ue][1]===C:$)return this;if(T(k),($||!Ve)&&T(D),$&&_e===2)return new we(u,this.keyHash,ce[ue^1]);var nt=u&&u===this.ownerID,pt=nt?ce:N(ce);return Ve?$?ue===_e-1?pt.pop():pt[ue]=pt.pop():pt[ue]=[M,C]:pt.push([M,C]),nt?(this.entries=pt,this):new K(u,this.keyHash,pt)};function we(u,g,y){this.ownerID=u,this.keyHash=g,this.entry=y}we.prototype.get=function(u,g,y,M){return Be(y,this.entry[0])?this.entry[1]:M},we.prototype.update=function(u,g,y,M,C,D,k){var $=C===b,ce=Be(M,this.entry[0]);if(ce?C===this.entry[1]:$)return this;if(T(k),$){T(D);return}return ce?u&&u===this.ownerID?(this.entry[1]=C,this):new we(u,this.keyHash,[M,C]):(T(D),Nt(this,u,g,dt(M),[M,C]))},Y.prototype.iterate=K.prototype.iterate=function(u,g){for(var y=this.entries,M=0,C=y.length-1;M<=C;M++)if(u(y[g?C-M:M])===!1)return!1},ie.prototype.iterate=oe.prototype.iterate=function(u,g){for(var y=this.nodes,M=0,C=y.length-1;M<=C;M++){var D=y[g?C-M:M];if(D&&D.iterate(u,g)===!1)return!1}},we.prototype.iterate=function(u,g){return u(this.entry)},r(Ue,V);function Ue(u,g,y){this._type=g,this._reverse=y,this._stack=u._root&&je(u._root)}Ue.prototype.next=function(){for(var u=this._type,g=this._stack;g;){var y=g.node,M=g.index++,C;if(y.entry){if(M===0)return Ze(u,y.entry)}else if(y.entries){if(C=y.entries.length-1,M<=C)return Ze(u,y.entries[this._reverse?C-M:M])}else if(C=y.nodes.length-1,M<=C){var D=y.nodes[this._reverse?C-M:M];if(D){if(D.entry)return Ze(u,D.entry);g=this._stack=je(D,g)}continue}g=this._stack=this._stack.__prev}return Z()};function Ze(u,g){return re(u,g[0],g[1])}function je(u,g){return{node:u,index:0,__prev:g}}function st(u,g,y,M){var C=Object.create(L);return C.size=u,C._root=g,C.__ownerID=y,C.__hash=M,C.__altered=!1,C}var ct;function Je(){return ct||(ct=st(0))}function yt(u,g,y){var M,C;if(u._root){var D=O(A),k=O(q);if(M=Rt(u._root,u.__ownerID,0,void 0,g,y,D,k),!k.value)return u;C=u.size+(D.value?y===b?-1:1:0)}else{if(y===b)return u;C=1,M=new Y(u.__ownerID,[[g,y]])}return u.__ownerID?(u.size=C,u._root=M,u.__hash=void 0,u.__altered=!0,u):M?st(C,M):Je()}function Rt(u,g,y,M,C,D,k,$){return u?u.update(g,y,M,C,D,k,$):D===b?u:(T($),T(k),new we(g,M,[C,D]))}function Qt(u){return u.constructor===we||u.constructor===K}function Nt(u,g,y,M,C){if(u.keyHash===M)return new K(g,M,[u.entry,C]);var D=(y===0?u.keyHash:u.keyHash>>>y)&S,k=(y===0?M:M>>>y)&S,$,ce=D===k?[Nt(u,g,y+w,M,C)]:($=new we(g,M,C),D<k?[u,$]:[$,u]);return new ie(g,1<<D|1<<k,ce)}function Ut(u,g,y,M){u||(u=new I);for(var C=new we(u,dt(y),[y,M]),D=0;D<g.length;D++){var k=g[D];C=C.update(u,0,void 0,k[0],k[1])}return C}function ot(u,g,y,M){for(var C=0,D=0,k=new Array(y),$=0,ce=1,ue=g.length;$<ue;$++,ce<<=1){var _e=g[$];_e!==void 0&&$!==M&&(C|=ce,k[D++]=_e)}return new ie(u,C,k)}function en(u,g,y,M,C){for(var D=0,k=new Array(E),$=0;y!==0;$++,y>>>=1)k[$]=y&1?g[D++]:void 0;return k[M]=C,new oe(u,D+1,k)}function bt(u,g,y){for(var M=[],C=0;C<y.length;C++){var D=y[C],k=s(D);l(D)||(k=k.map(function($){return Ge($)})),M.push(k)}return Fn(u,g,M)}function Un(u,g,y){return u&&u.mergeDeep&&l(g)?u.mergeDeep(g):Be(u,g)?u:g}function Qi(u){return function(g,y,M){if(g&&g.mergeDeepWith&&l(y))return g.mergeDeepWith(u,y);var C=u(g,y,M);return Be(g,C)?g:C}}function Fn(u,g,y){return y=y.filter(function(M){return M.size!==0}),y.length===0?u:u.size===0&&!u.__ownerID&&y.length===1?u.constructor(y[0]):u.withMutations(function(M){for(var C=g?function(k,$){M.update($,b,function(ce){return ce===b?k:g(ce,k,$)})}:function(k,$){M.set($,k)},D=0;D<y.length;D++)y[D].forEach(C)})}function Ts(u,g,y,M){var C=u===b,D=g.next();if(D.done){var k=C?y:u,$=M(k);return $===k?u:$}G(C||u&&u.set,"invalid keyPath");var ce=D.value,ue=C?b:u.get(ce,b),_e=Ts(ue,g,y,M);return _e===ue?u:_e===b?u.remove(ce):(C?Je():u).set(ce,_e)}function $t(u){return u=u-(u>>1&1431655765),u=(u&858993459)+(u>>2&858993459),u=u+(u>>4)&252645135,u=u+(u>>8),u=u+(u>>16),u&127}function Xn(u,g,y,M){var C=M?u:N(u);return C[g]=y,C}function or(u,g,y,M){var C=u.length+1;if(M&&g+1===C)return u[g]=y,u;for(var D=new Array(C),k=0,$=0;$<C;$++)$===g?(D[$]=y,k=-1):D[$]=u[$+k];return D}function Rn(u,g,y){var M=u.length-1;if(y&&g===M)return u.pop(),u;for(var C=new Array(M),D=0,k=0;k<M;k++)k===g&&(D=1),C[k]=u[k+D];return C}var zn=E/4,Hl=E/2,es=E/4;r(tn,me);function tn(u){var g=ym();if(u==null)return g;if(c2(u))return u;var y=o(u),M=y.size;return M===0?g:(jn(M),M>0&&M<E?Wl(0,M,w,null,new As(y.toArray())):g.withMutations(function(C){C.setSize(M),y.forEach(function(D,k){return C.set(k,D)})}))}tn.of=function(){return this(arguments)},tn.prototype.toString=function(){return this.__toString("List [","]")},tn.prototype.get=function(u,g){if(u=W(this,u),u>=0&&u<this.size){u+=this._origin;var y=d2(this,u);return y&&y.array[u&S]}return g},tn.prototype.set=function(u,g){return tC(this,u,g)},tn.prototype.remove=function(u){return this.has(u)?u===0?this.shift():u===this.size-1?this.pop():this.splice(u,1):this},tn.prototype.insert=function(u,g){return this.splice(u,0,g)},tn.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=w,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):ym()},tn.prototype.push=function(){var u=arguments,g=this.size;return this.withMutations(function(y){Cs(y,0,g+u.length);for(var M=0;M<u.length;M++)y.set(g+M,u[M])})},tn.prototype.pop=function(){return Cs(this,0,-1)},tn.prototype.unshift=function(){var u=arguments;return this.withMutations(function(g){Cs(g,-u.length);for(var y=0;y<u.length;y++)g.set(y,u[y])})},tn.prototype.shift=function(){return Cs(this,1)},tn.prototype.merge=function(){return rh(this,void 0,arguments)},tn.prototype.mergeWith=function(u){var g=t.call(arguments,1);return rh(this,u,g)},tn.prototype.mergeDeep=function(){return rh(this,Un,arguments)},tn.prototype.mergeDeepWith=function(u){var g=t.call(arguments,1);return rh(this,Qi(u),g)},tn.prototype.setSize=function(u){return Cs(this,0,u)},tn.prototype.slice=function(u,g){var y=this.size;return ae(u,g,y)?this:Cs(this,J(u,y),se(g,y))},tn.prototype.__iterator=function(u,g){var y=0,M=h2(this,g);return new V(function(){var C=M();return C===Gl?Z():re(u,y++,C)})},tn.prototype.__iterate=function(u,g){for(var y=0,M=h2(this,g),C;(C=M())!==Gl&&u(C,y++,this)!==!1;);return y},tn.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Wl(this._origin,this._capacity,this._level,this._root,this._tail,u,this.__hash):(this.__ownerID=u,this)};function c2(u){return!!(u&&u[u2])}tn.isList=c2;var u2="@@__IMMUTABLE_LIST__@@",$n=tn.prototype;$n[u2]=!0,$n[_]=$n.remove,$n.setIn=L.setIn,$n.deleteIn=$n.removeIn=L.removeIn,$n.update=L.update,$n.updateIn=L.updateIn,$n.mergeIn=L.mergeIn,$n.mergeDeepIn=L.mergeDeepIn,$n.withMutations=L.withMutations,$n.asMutable=L.asMutable,$n.asImmutable=L.asImmutable,$n.wasAltered=L.wasAltered;function As(u,g){this.array=u,this.ownerID=g}As.prototype.removeBefore=function(u,g,y){if(y===g?1<<g:this.array.length===0)return this;var M=y>>>g&S;if(M>=this.array.length)return new As([],u);var C=M===0,D;if(g>0){var k=this.array[M];if(D=k&&k.removeBefore(u,g-w,y),D===k&&C)return this}if(C&&!D)return this;var $=Ca(this,u);if(!C)for(var ce=0;ce<M;ce++)$.array[ce]=void 0;return D&&($.array[M]=D),$},As.prototype.removeAfter=function(u,g,y){if(y===(g?1<<g:0)||this.array.length===0)return this;var M=y-1>>>g&S;if(M>=this.array.length)return this;var C;if(g>0){var D=this.array[M];if(C=D&&D.removeAfter(u,g-w,y),C===D&&M===this.array.length-1)return this}var k=Ca(this,u);return k.array.splice(M+1),C&&(k.array[M]=C),k};var Gl={};function h2(u,g){var y=u._origin,M=u._capacity,C=jl(M),D=u._tail;return k(u._root,u._level,0);function k(ue,_e,Ve){return _e===0?$(ue,Ve):ce(ue,_e,Ve)}function $(ue,_e){var Ve=_e===C?D&&D.array:ue&&ue.array,nt=_e>y?0:y-_e,pt=M-_e;return pt>E&&(pt=E),function(){if(nt===pt)return Gl;var St=g?--pt:nt++;return Ve&&Ve[St]}}function ce(ue,_e,Ve){var nt,pt=ue&&ue.array,St=Ve>y?0:y-Ve>>_e,rn=(M-Ve>>_e)+1;return rn>E&&(rn=E),function(){do{if(nt){var li=nt();if(li!==Gl)return li;nt=null}if(St===rn)return Gl;var Oi=g?--rn:St++;nt=k(pt&&pt[Oi],_e-w,Ve+(Oi<<_e))}while(!0)}}}function Wl(u,g,y,M,C,D,k){var $=Object.create($n);return $.size=g-u,$._origin=u,$._capacity=g,$._level=y,$._root=M,$._tail=C,$.__ownerID=D,$.__hash=k,$.__altered=!1,$}var f2;function ym(){return f2||(f2=Wl(0,0,w))}function tC(u,g,y){if(g=W(u,g),g!==g)return u;if(g>=u.size||g<0)return u.withMutations(function(k){g<0?Cs(k,g).set(0,y):Cs(k,0,g+1).set(g,y)});g+=u._origin;var M=u._tail,C=u._root,D=O(q);return g>=jl(u._capacity)?M=Sm(M,u.__ownerID,0,g,y,D):C=Sm(C,u.__ownerID,u._level,g,y,D),D.value?u.__ownerID?(u._root=C,u._tail=M,u.__hash=void 0,u.__altered=!0,u):Wl(u._origin,u._capacity,u._level,C,M):u}function Sm(u,g,y,M,C,D){var k=M>>>y&S,$=u&&k<u.array.length;if(!$&&C===void 0)return u;var ce;if(y>0){var ue=u&&u.array[k],_e=Sm(ue,g,y-w,M,C,D);return _e===ue?u:(ce=Ca(u,g),ce.array[k]=_e,ce)}return $&&u.array[k]===C?u:(T(D),ce=Ca(u,g),C===void 0&&k===ce.array.length-1?ce.array.pop():ce.array[k]=C,ce)}function Ca(u,g){return g&&u&&g===u.ownerID?u:new As(u?u.array.slice():[],g)}function d2(u,g){if(g>=jl(u._capacity))return u._tail;if(g<1<<u._level+w){for(var y=u._root,M=u._level;y&&M>0;)y=y.array[g>>>M&S],M-=w;return y}}function Cs(u,g,y){g!==void 0&&(g=g|0),y!==void 0&&(y=y|0);var M=u.__ownerID||new I,C=u._origin,D=u._capacity,k=C+g,$=y===void 0?D:y<0?D+y:C+y;if(k===C&&$===D)return u;if(k>=$)return u.clear();for(var ce=u._level,ue=u._root,_e=0;k+_e<0;)ue=new As(ue&&ue.array.length?[void 0,ue]:[],M),ce+=w,_e+=1<<ce;_e&&(k+=_e,C+=_e,$+=_e,D+=_e);for(var Ve=jl(D),nt=jl($);nt>=1<<ce+w;)ue=new As(ue&&ue.array.length?[ue]:[],M),ce+=w;var pt=u._tail,St=nt<Ve?d2(u,$-1):nt>Ve?new As([],M):pt;if(pt&&nt>Ve&&k<D&&pt.array.length){ue=Ca(ue,M);for(var rn=ue,li=ce;li>w;li-=w){var Oi=Ve>>>li&S;rn=rn.array[Oi]=Ca(rn.array[Oi],M)}rn.array[Ve>>>w&S]=pt}if($<D&&(St=St&&St.removeAfter(M,0,$)),k>=nt)k-=nt,$-=nt,ce=w,ue=null,St=St&&St.removeBefore(M,0,k);else if(k>C||nt<Ve){for(_e=0;ue;){var uh=k>>>ce&S;if(uh!==nt>>>ce&S)break;uh&&(_e+=(1<<ce)*uh),ce-=w,ue=ue.array[uh]}ue&&k>C&&(ue=ue.removeBefore(M,ce,k-_e)),ue&&nt<Ve&&(ue=ue.removeAfter(M,ce,nt-_e)),_e&&(k-=_e,$-=_e)}return u.__ownerID?(u.size=$-k,u._origin=k,u._capacity=$,u._level=ce,u._root=ue,u._tail=St,u.__hash=void 0,u.__altered=!0,u):Wl(k,$,ce,ue,St)}function rh(u,g,y){for(var M=[],C=0,D=0;D<y.length;D++){var k=y[D],$=o(k);$.size>C&&(C=$.size),l(k)||($=$.map(function(ce){return Ge(ce)})),M.push($)}return C>u.size&&(u=u.setSize(C)),Fn(u,g,M)}function jl(u){return u<E?0:u-1>>>w<<w}r(hn,Mt);function hn(u){return u==null?ih():p2(u)?u:ih().withMutations(function(g){var y=s(u);jn(y.size),y.forEach(function(M,C){return g.set(C,M)})})}hn.of=function(){return this(arguments)},hn.prototype.toString=function(){return this.__toString("OrderedMap {","}")},hn.prototype.get=function(u,g){var y=this._map.get(u);return y!==void 0?this._list.get(y)[1]:g},hn.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ih()},hn.prototype.set=function(u,g){return g2(this,u,g)},hn.prototype.remove=function(u){return g2(this,u,b)},hn.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},hn.prototype.__iterate=function(u,g){var y=this;return this._list.__iterate(function(M){return M&&u(M[1],M[0],y)},g)},hn.prototype.__iterator=function(u,g){return this._list.fromEntrySeq().__iterator(u,g)},hn.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map.__ensureOwner(u),y=this._list.__ensureOwner(u);return u?Em(g,y,u,this.__hash):(this.__ownerID=u,this._map=g,this._list=y,this)};function p2(u){return Vl(u)&&p(u)}hn.isOrderedMap=p2,hn.prototype[v]=!0,hn.prototype[_]=hn.prototype.remove;function Em(u,g,y,M){var C=Object.create(hn.prototype);return C.size=u?u.size:0,C._map=u,C._list=g,C.__ownerID=y,C.__hash=M,C}var m2;function ih(){return m2||(m2=Em(Je(),ym()))}function g2(u,g,y){var M=u._map,C=u._list,D=M.get(g),k=D!==void 0,$,ce;if(y===b){if(!k)return u;C.size>=E&&C.size>=M.size*2?(ce=C.filter(function(ue,_e){return ue!==void 0&&D!==_e}),$=ce.toKeyedSeq().map(function(ue){return ue[0]}).flip().toMap(),u.__ownerID&&($.__ownerID=ce.__ownerID=u.__ownerID)):($=M.remove(g),ce=D===C.size-1?C.pop():C.set(D,void 0))}else if(k){if(y===C.get(D)[1])return u;$=M,ce=C.set(D,[g,y])}else $=M.set(g,C.size),ce=C.set(C.size,[g,y]);return u.__ownerID?(u.size=$.size,u._map=$,u._list=ce,u.__hash=void 0,u):Em($,ce)}r(zr,rt);function zr(u,g){this._iter=u,this._useKeys=g,this.size=u.size}zr.prototype.get=function(u,g){return this._iter.get(u,g)},zr.prototype.has=function(u){return this._iter.has(u)},zr.prototype.valueSeq=function(){return this._iter.valueSeq()},zr.prototype.reverse=function(){var u=this,g=bm(this,!0);return this._useKeys||(g.valueSeq=function(){return u._iter.toSeq().reverse()}),g},zr.prototype.map=function(u,g){var y=this,M=v2(this,u,g);return this._useKeys||(M.valueSeq=function(){return y._iter.toSeq().map(u,g)}),M},zr.prototype.__iterate=function(u,g){var y=this,M;return this._iter.__iterate(this._useKeys?function(C,D){return u(C,D,y)}:(M=g?M2(this):0,function(C){return u(C,g?--M:M++,y)}),g)},zr.prototype.__iterator=function(u,g){if(this._useKeys)return this._iter.__iterator(u,g);var y=this._iter.__iterator(F,g),M=g?M2(this):0;return new V(function(){var C=y.next();return C.done?C:re(u,g?--M:M++,C.value,C)})},zr.prototype[v]=!0,r(Ra,Le);function Ra(u){this._iter=u,this.size=u.size}Ra.prototype.includes=function(u){return this._iter.includes(u)},Ra.prototype.__iterate=function(u,g){var y=this,M=0;return this._iter.__iterate(function(C){return u(C,M++,y)},g)},Ra.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g),M=0;return new V(function(){var C=y.next();return C.done?C:re(u,M++,C.value,C)})},r(Pa,at);function Pa(u){this._iter=u,this.size=u.size}Pa.prototype.has=function(u){return this._iter.includes(u)},Pa.prototype.__iterate=function(u,g){var y=this;return this._iter.__iterate(function(M){return u(M,M,y)},g)},Pa.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g);return new V(function(){var M=y.next();return M.done?M:re(u,M.value,M.value,M)})},r(Ia,rt);function Ia(u){this._iter=u,this.size=u.size}Ia.prototype.entrySeq=function(){return this._iter.toSeq()},Ia.prototype.__iterate=function(u,g){var y=this;return this._iter.__iterate(function(M){if(M){b2(M);var C=l(M);return u(C?M.get(1):M[1],C?M.get(0):M[0],y)}},g)},Ia.prototype.__iterator=function(u,g){var y=this._iter.__iterator(F,g);return new V(function(){for(;;){var M=y.next();if(M.done)return M;var C=M.value;if(C){b2(C);var D=l(C);return re(u,D?C.get(0):C[0],D?C.get(1):C[1],M)}}})},Ra.prototype.cacheResult=zr.prototype.cacheResult=Pa.prototype.cacheResult=Ia.prototype.cacheResult=Tm;function _2(u){var g=Pi(u);return g._iter=u,g.size=u.size,g.flip=function(){return u},g.reverse=function(){var y=u.reverse.apply(this);return y.flip=function(){return u.reverse()},y},g.has=function(y){return u.includes(y)},g.includes=function(y){return u.has(y)},g.cacheResult=Tm,g.__iterateUncached=function(y,M){var C=this;return u.__iterate(function(D,k){return y(k,D,C)!==!1},M)},g.__iteratorUncached=function(y,M){if(y===X){var C=u.__iterator(y,M);return new V(function(){var D=C.next();if(!D.done){var k=D.value[0];D.value[0]=D.value[1],D.value[1]=k}return D})}return u.__iterator(y===F?ge:F,M)},g}function v2(u,g,y){var M=Pi(u);return M.size=u.size,M.has=function(C){return u.has(C)},M.get=function(C,D){var k=u.get(C,b);return k===b?D:g.call(y,k,C,u)},M.__iterateUncached=function(C,D){var k=this;return u.__iterate(function($,ce,ue){return C(g.call(y,$,ce,ue),ce,k)!==!1},D)},M.__iteratorUncached=function(C,D){var k=u.__iterator(X,D);return new V(function(){var $=k.next();if($.done)return $;var ce=$.value,ue=ce[0];return re(C,ue,g.call(y,ce[1],ue,u),$)})},M}function bm(u,g){var y=Pi(u);return y._iter=u,y.size=u.size,y.reverse=function(){return u},u.flip&&(y.flip=function(){var M=_2(u);return M.reverse=function(){return u.flip()},M}),y.get=function(M,C){return u.get(g?M:-1-M,C)},y.has=function(M){return u.has(g?M:-1-M)},y.includes=function(M){return u.includes(M)},y.cacheResult=Tm,y.__iterate=function(M,C){var D=this;return u.__iterate(function(k,$){return M(k,$,D)},!C)},y.__iterator=function(M,C){return u.__iterator(M,!C)},y}function x2(u,g,y,M){var C=Pi(u);return M&&(C.has=function(D){var k=u.get(D,b);return k!==b&&!!g.call(y,k,D,u)},C.get=function(D,k){var $=u.get(D,b);return $!==b&&g.call(y,$,D,u)?$:k}),C.__iterateUncached=function(D,k){var $=this,ce=0;return u.__iterate(function(ue,_e,Ve){if(g.call(y,ue,_e,Ve))return ce++,D(ue,M?_e:ce-1,$)},k),ce},C.__iteratorUncached=function(D,k){var $=u.__iterator(X,k),ce=0;return new V(function(){for(;;){var ue=$.next();if(ue.done)return ue;var _e=ue.value,Ve=_e[0],nt=_e[1];if(g.call(y,nt,Ve,u))return re(D,M?Ve:ce++,nt,ue)}})},C}function nC(u,g,y){var M=Mt().asMutable();return u.__iterate(function(C,D){M.update(g.call(y,C,D,u),0,function(k){return k+1})}),M.asImmutable()}function rC(u,g,y){var M=c(u),C=(p(u)?hn():Mt()).asMutable();u.__iterate(function(k,$){C.update(g.call(y,k,$,u),function(ce){return ce=ce||[],ce.push(M?[$,k]:k),ce})});var D=w2(u);return C.map(function(k){return Wt(u,D(k))})}function Mm(u,g,y,M){var C=u.size;if(g!==void 0&&(g=g|0),y!==void 0&&(y===1/0?y=C:y=y|0),ae(g,y,C))return u;var D=J(g,C),k=se(y,C);if(D!==D||k!==k)return Mm(u.toSeq().cacheResult(),g,y,M);var $=k-D,ce;$===$&&(ce=$<0?0:$);var ue=Pi(u);return ue.size=ce===0?ce:u.size&&ce||void 0,!M&&$e(u)&&ce>=0&&(ue.get=function(_e,Ve){return _e=W(this,_e),_e>=0&&_e<ce?u.get(_e+D,Ve):Ve}),ue.__iterateUncached=function(_e,Ve){var nt=this;if(ce===0)return 0;if(Ve)return this.cacheResult().__iterate(_e,Ve);var pt=0,St=!0,rn=0;return u.__iterate(function(li,Oi){if(!(St&&(St=pt++<D)))return rn++,_e(li,M?Oi:rn-1,nt)!==!1&&rn!==ce}),rn},ue.__iteratorUncached=function(_e,Ve){if(ce!==0&&Ve)return this.cacheResult().__iterator(_e,Ve);var nt=ce!==0&&u.__iterator(_e,Ve),pt=0,St=0;return new V(function(){for(;pt++<D;)nt.next();if(++St>ce)return Z();var rn=nt.next();return M||_e===F?rn:_e===ge?re(_e,St-1,void 0,rn):re(_e,St-1,rn.value[1],rn)})},ue}function iC(u,g,y){var M=Pi(u);return M.__iterateUncached=function(C,D){var k=this;if(D)return this.cacheResult().__iterate(C,D);var $=0;return u.__iterate(function(ce,ue,_e){return g.call(y,ce,ue,_e)&&++$&&C(ce,ue,k)}),$},M.__iteratorUncached=function(C,D){var k=this;if(D)return this.cacheResult().__iterator(C,D);var $=u.__iterator(X,D),ce=!0;return new V(function(){if(!ce)return Z();var ue=$.next();if(ue.done)return ue;var _e=ue.value,Ve=_e[0],nt=_e[1];return g.call(y,nt,Ve,k)?C===X?ue:re(C,Ve,nt,ue):(ce=!1,Z())})},M}function y2(u,g,y,M){var C=Pi(u);return C.__iterateUncached=function(D,k){var $=this;if(k)return this.cacheResult().__iterate(D,k);var ce=!0,ue=0;return u.__iterate(function(_e,Ve,nt){if(!(ce&&(ce=g.call(y,_e,Ve,nt))))return ue++,D(_e,M?Ve:ue-1,$)}),ue},C.__iteratorUncached=function(D,k){var $=this;if(k)return this.cacheResult().__iterator(D,k);var ce=u.__iterator(X,k),ue=!0,_e=0;return new V(function(){var Ve,nt,pt;do{if(Ve=ce.next(),Ve.done)return M||D===F?Ve:D===ge?re(D,_e++,void 0,Ve):re(D,_e++,Ve.value[1],Ve);var St=Ve.value;nt=St[0],pt=St[1],ue&&(ue=g.call(y,pt,nt,$))}while(ue);return D===X?Ve:re(D,nt,pt,Ve)})},C}function sC(u,g){var y=c(u),M=[u].concat(g).map(function(k){return l(k)?y&&(k=s(k)):k=y?te(k):pe(Array.isArray(k)?k:[k]),k}).filter(function(k){return k.size!==0});if(M.length===0)return u;if(M.length===1){var C=M[0];if(C===u||y&&c(C)||h(u)&&h(C))return C}var D=new Xe(M);return y?D=D.toKeyedSeq():h(u)||(D=D.toSetSeq()),D=D.flatten(!0),D.size=M.reduce(function(k,$){if(k!==void 0){var ce=$.size;if(ce!==void 0)return k+ce}},0),D}function S2(u,g,y){var M=Pi(u);return M.__iterateUncached=function(C,D){var k=0,$=!1;function ce(ue,_e){var Ve=this;ue.__iterate(function(nt,pt){return(!g||_e<g)&&l(nt)?ce(nt,_e+1):C(nt,y?pt:k++,Ve)===!1&&($=!0),!$},D)}return ce(u,0),k},M.__iteratorUncached=function(C,D){var k=u.__iterator(C,D),$=[],ce=0;return new V(function(){for(;k;){var ue=k.next();if(ue.done!==!1){k=$.pop();continue}var _e=ue.value;if(C===X&&(_e=_e[1]),(!g||$.length<g)&&l(_e))$.push(k),k=_e.__iterator(C,D);else return y?ue:re(C,ce++,_e,ue)}return Z()})},M}function oC(u,g,y){var M=w2(u);return u.toSeq().map(function(C,D){return M(g.call(y,C,D,u))}).flatten(!0)}function aC(u,g){var y=Pi(u);return y.size=u.size&&u.size*2-1,y.__iterateUncached=function(M,C){var D=this,k=0;return u.__iterate(function($,ce){return(!k||M(g,k++,D)!==!1)&&M($,k++,D)!==!1},C),k},y.__iteratorUncached=function(M,C){var D=u.__iterator(F,C),k=0,$;return new V(function(){return(!$||k%2)&&($=D.next(),$.done)?$:k%2?re(M,k++,g):re(M,k++,$.value,$)})},y}function La(u,g,y){g||(g=T2);var M=c(u),C=0,D=u.toSeq().map(function(k,$){return[$,k,C++,y?y(k,$,u):k]}).toArray();return D.sort(function(k,$){return g(k[3],$[3])||k[2]-$[2]}).forEach(M?function(k,$){D[$].length=2}:function(k,$){D[$]=k[1]}),M?rt(D):h(u)?Le(D):at(D)}function sh(u,g,y){if(g||(g=T2),y){var M=u.toSeq().map(function(C,D){return[C,y(C,D,u)]}).reduce(function(C,D){return E2(g,C[1],D[1])?D:C});return M&&M[0]}else return u.reduce(function(C,D){return E2(g,C,D)?D:C})}function E2(u,g,y){var M=u(y,g);return M===0&&y!==g&&(y==null||y!==y)||M>0}function wm(u,g,y){var M=Pi(u);return M.size=new Xe(y).map(function(C){return C.size}).min(),M.__iterate=function(C,D){for(var k=this.__iterator(F,D),$,ce=0;!($=k.next()).done&&C($.value,ce++,this)!==!1;);return ce},M.__iteratorUncached=function(C,D){var k=y.map(function(ue){return ue=i(ue),ee(D?ue.reverse():ue)}),$=0,ce=!1;return new V(function(){var ue;return ce||(ue=k.map(function(_e){return _e.next()}),ce=ue.some(function(_e){return _e.done})),ce?Z():re(C,$++,g.apply(null,ue.map(function(_e){return _e.value})))})},M}function Wt(u,g){return $e(u)?g:u.constructor(g)}function b2(u){if(u!==Object(u))throw new TypeError("Expected [K, V] tuple: "+u)}function M2(u){return jn(u.size),H(u)}function w2(u){return c(u)?s:h(u)?o:a}function Pi(u){return Object.create((c(u)?rt:h(u)?Le:at).prototype)}function Tm(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):z.prototype.cacheResult.call(this)}function T2(u,g){return u>g?1:u<g?-1:0}function A2(u){var g=ee(u);if(!g){if(!le(u))throw new TypeError("Expected iterable or array-like: "+u);g=ee(i(u))}return g}r(yr,Te);function yr(u,g){var y,M=function(k){if(k instanceof M)return k;if(!(this instanceof M))return new M(k);if(!y){y=!0;var $=Object.keys(u);lC(C,$),C.size=$.length,C._name=g,C._keys=$,C._defaultValues=u}this._map=Mt(k)},C=M.prototype=Object.create(Pn);return C.constructor=M,M}yr.prototype.toString=function(){return this.__toString(C2(this)+" {","}")},yr.prototype.has=function(u){return this._defaultValues.hasOwnProperty(u)},yr.prototype.get=function(u,g){if(!this.has(u))return g;var y=this._defaultValues[u];return this._map?this._map.get(u,y):y},yr.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var u=this.constructor;return u._empty||(u._empty=oh(this,Je()))},yr.prototype.set=function(u,g){if(!this.has(u))throw new Error('Cannot set unknown key "'+u+'" on '+C2(this));if(this._map&&!this._map.has(u)){var y=this._defaultValues[u];if(g===y)return this}var M=this._map&&this._map.set(u,g);return this.__ownerID||M===this._map?this:oh(this,M)},yr.prototype.remove=function(u){if(!this.has(u))return this;var g=this._map&&this._map.remove(u);return this.__ownerID||g===this._map?this:oh(this,g)},yr.prototype.wasAltered=function(){return this._map.wasAltered()},yr.prototype.__iterator=function(u,g){var y=this;return s(this._defaultValues).map(function(M,C){return y.get(C)}).__iterator(u,g)},yr.prototype.__iterate=function(u,g){var y=this;return s(this._defaultValues).map(function(M,C){return y.get(C)}).__iterate(u,g)},yr.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map&&this._map.__ensureOwner(u);return u?oh(this,g,u):(this.__ownerID=u,this._map=g,this)};var Pn=yr.prototype;Pn[_]=Pn.remove,Pn.deleteIn=Pn.removeIn=L.removeIn,Pn.merge=L.merge,Pn.mergeWith=L.mergeWith,Pn.mergeIn=L.mergeIn,Pn.mergeDeep=L.mergeDeep,Pn.mergeDeepWith=L.mergeDeepWith,Pn.mergeDeepIn=L.mergeDeepIn,Pn.setIn=L.setIn,Pn.update=L.update,Pn.updateIn=L.updateIn,Pn.withMutations=L.withMutations,Pn.asMutable=L.asMutable,Pn.asImmutable=L.asImmutable;function oh(u,g,y){var M=Object.create(Object.getPrototypeOf(u));return M._map=g,M.__ownerID=y,M}function C2(u){return u._name||u.constructor.name||"Record"}function lC(u,g){try{g.forEach(cC.bind(void 0,u))}catch{}}function cC(u,g){Object.defineProperty(u,g,{get:function(){return this.get(g)},set:function(y){G(this.__ownerID,"Cannot set on an immutable record."),this.set(g,y)}})}r(nn,Ke);function nn(u){return u==null?Rm():Am(u)&&!p(u)?u:Rm().withMutations(function(g){var y=a(u);jn(y.size),y.forEach(function(M){return g.add(M)})})}nn.of=function(){return this(arguments)},nn.fromKeys=function(u){return this(s(u).keySeq())},nn.prototype.toString=function(){return this.__toString("Set {","}")},nn.prototype.has=function(u){return this._map.has(u)},nn.prototype.add=function(u){return Cm(this,this._map.set(u,!0))},nn.prototype.remove=function(u){return Cm(this,this._map.remove(u))},nn.prototype.clear=function(){return Cm(this,this._map.clear())},nn.prototype.union=function(){var u=t.call(arguments,0);return u=u.filter(function(g){return g.size!==0}),u.length===0?this:this.size===0&&!this.__ownerID&&u.length===1?this.constructor(u[0]):this.withMutations(function(g){for(var y=0;y<u.length;y++)a(u[y]).forEach(function(M){return g.add(M)})})},nn.prototype.intersect=function(){var u=t.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var g=this;return this.withMutations(function(y){g.forEach(function(M){u.every(function(C){return C.includes(M)})||y.remove(M)})})},nn.prototype.subtract=function(){var u=t.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var g=this;return this.withMutations(function(y){g.forEach(function(M){u.some(function(C){return C.includes(M)})&&y.remove(M)})})},nn.prototype.merge=function(){return this.union.apply(this,arguments)},nn.prototype.mergeWith=function(u){var g=t.call(arguments,1);return this.union.apply(this,g)},nn.prototype.sort=function(u){return Ii(La(this,u))},nn.prototype.sortBy=function(u,g){return Ii(La(this,g,u))},nn.prototype.wasAltered=function(){return this._map.wasAltered()},nn.prototype.__iterate=function(u,g){var y=this;return this._map.__iterate(function(M,C){return u(C,C,y)},g)},nn.prototype.__iterator=function(u,g){return this._map.map(function(y,M){return M}).__iterator(u,g)},nn.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var g=this._map.__ensureOwner(u);return u?this.__make(g,u):(this.__ownerID=u,this._map=g,this)};function Am(u){return!!(u&&u[R2])}nn.isSet=Am;var R2="@@__IMMUTABLE_SET__@@",Sr=nn.prototype;Sr[R2]=!0,Sr[_]=Sr.remove,Sr.mergeDeep=Sr.merge,Sr.mergeDeepWith=Sr.mergeWith,Sr.withMutations=L.withMutations,Sr.asMutable=L.asMutable,Sr.asImmutable=L.asImmutable,Sr.__empty=Rm,Sr.__make=P2;function Cm(u,g){return u.__ownerID?(u.size=g.size,u._map=g,u):g===u._map?u:g.size===0?u.__empty():u.__make(g)}function P2(u,g){var y=Object.create(Sr);return y.size=u?u.size:0,y._map=u,y.__ownerID=g,y}var I2;function Rm(){return I2||(I2=P2(Je()))}r(Ii,nn);function Ii(u){return u==null?Pm():L2(u)?u:Pm().withMutations(function(g){var y=a(u);jn(y.size),y.forEach(function(M){return g.add(M)})})}Ii.of=function(){return this(arguments)},Ii.fromKeys=function(u){return this(s(u).keySeq())},Ii.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function L2(u){return Am(u)&&p(u)}Ii.isOrderedSet=L2;var ah=Ii.prototype;ah[v]=!0,ah.__empty=Pm,ah.__make=O2;function O2(u,g){var y=Object.create(ah);return y.size=u?u.size:0,y._map=u,y.__ownerID=g,y}var q2;function Pm(){return q2||(q2=O2(ih()))}r(_n,me);function _n(u){return u==null?Im():D2(u)?u:Im().unshiftAll(u)}_n.of=function(){return this(arguments)},_n.prototype.toString=function(){return this.__toString("Stack [","]")},_n.prototype.get=function(u,g){var y=this._head;for(u=W(this,u);y&&u--;)y=y.next;return y?y.value:g},_n.prototype.peek=function(){return this._head&&this._head.value},_n.prototype.push=function(){if(arguments.length===0)return this;for(var u=this.size+arguments.length,g=this._head,y=arguments.length-1;y>=0;y--)g={value:arguments[y],next:g};return this.__ownerID?(this.size=u,this._head=g,this.__hash=void 0,this.__altered=!0,this):Xl(u,g)},_n.prototype.pushAll=function(u){if(u=o(u),u.size===0)return this;jn(u.size);var g=this.size,y=this._head;return u.reverse().forEach(function(M){g++,y={value:M,next:y}}),this.__ownerID?(this.size=g,this._head=y,this.__hash=void 0,this.__altered=!0,this):Xl(g,y)},_n.prototype.pop=function(){return this.slice(1)},_n.prototype.unshift=function(){return this.push.apply(this,arguments)},_n.prototype.unshiftAll=function(u){return this.pushAll(u)},_n.prototype.shift=function(){return this.pop.apply(this,arguments)},_n.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Im()},_n.prototype.slice=function(u,g){if(ae(u,g,this.size))return this;var y=J(u,this.size),M=se(g,this.size);if(M!==this.size)return me.prototype.slice.call(this,u,g);for(var C=this.size-y,D=this._head;y--;)D=D.next;return this.__ownerID?(this.size=C,this._head=D,this.__hash=void 0,this.__altered=!0,this):Xl(C,D)},_n.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Xl(this.size,this._head,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)},_n.prototype.__iterate=function(u,g){if(g)return this.reverse().__iterate(u);for(var y=0,M=this._head;M&&u(M.value,y++,this)!==!1;)M=M.next;return y},_n.prototype.__iterator=function(u,g){if(g)return this.reverse().__iterator(u);var y=0,M=this._head;return new V(function(){if(M){var C=M.value;return M=M.next,re(u,y++,C)}return Z()})};function D2(u){return!!(u&&u[N2])}_n.isStack=D2;var N2="@@__IMMUTABLE_STACK__@@",Oa=_n.prototype;Oa[N2]=!0,Oa.withMutations=L.withMutations,Oa.asMutable=L.asMutable,Oa.asImmutable=L.asImmutable,Oa.wasAltered=L.wasAltered;function Xl(u,g,y,M){var C=Object.create(Oa);return C.size=u,C._head=g,C.__ownerID=y,C.__hash=M,C.__altered=!1,C}var U2;function Im(){return U2||(U2=Xl(0))}function Li(u,g){var y=function(M){u.prototype[M]=g[M]};return Object.keys(g).forEach(y),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(g).forEach(y),u}i.Iterator=V,Li(i,{toArray:function(){jn(this.size);var u=new Array(this.size||0);return this.valueSeq().__iterate(function(g,y){u[y]=g}),u},toIndexedSeq:function(){return new Ra(this)},toJS:function(){return this.toSeq().map(function(u){return u&&typeof u.toJS=="function"?u.toJS():u}).__toJS()},toJSON:function(){return this.toSeq().map(function(u){return u&&typeof u.toJSON=="function"?u.toJSON():u}).__toJS()},toKeyedSeq:function(){return new zr(this,!0)},toMap:function(){return Mt(this.toKeyedSeq())},toObject:function(){jn(this.size);var u={};return this.__iterate(function(g,y){u[y]=g}),u},toOrderedMap:function(){return hn(this.toKeyedSeq())},toOrderedSet:function(){return Ii(c(this)?this.valueSeq():this)},toSet:function(){return nn(c(this)?this.valueSeq():this)},toSetSeq:function(){return new Pa(this)},toSeq:function(){return h(this)?this.toIndexedSeq():c(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return _n(c(this)?this.valueSeq():this)},toList:function(){return tn(c(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(u,g){return this.size===0?u+g:u+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+g},concat:function(){var u=t.call(arguments,0);return Wt(this,sC(this,u))},includes:function(u){return this.some(function(g){return Be(g,u)})},entries:function(){return this.__iterator(X)},every:function(u,g){jn(this.size);var y=!0;return this.__iterate(function(M,C,D){if(!u.call(g,M,C,D))return y=!1,!1}),y},filter:function(u,g){return Wt(this,x2(this,u,g,!0))},find:function(u,g,y){var M=this.findEntry(u,g);return M?M[1]:y},forEach:function(u,g){return jn(this.size),this.__iterate(g?u.bind(g):u)},join:function(u){jn(this.size),u=u!==void 0?""+u:",";var g="",y=!0;return this.__iterate(function(M){y?y=!1:g+=u,g+=M!=null?M.toString():""}),g},keys:function(){return this.__iterator(ge)},map:function(u,g){return Wt(this,v2(this,u,g))},reduce:function(u,g,y){jn(this.size);var M,C;return arguments.length<2?C=!0:M=g,this.__iterate(function(D,k,$){C?(C=!1,M=D):M=u.call(y,M,D,k,$)}),M},reduceRight:function(u,g,y){var M=this.toKeyedSeq().reverse();return M.reduce.apply(M,arguments)},reverse:function(){return Wt(this,bm(this,!0))},slice:function(u,g){return Wt(this,Mm(this,u,g,!0))},some:function(u,g){return!this.every(ch(u),g)},sort:function(u){return Wt(this,La(this,u))},values:function(){return this.__iterator(F)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(u,g){return H(u?this.toSeq().filter(u,g):this)},countBy:function(u,g){return nC(this,u,g)},equals:function(u){return Ye(this,u)},entrySeq:function(){var u=this;if(u._cache)return new Xe(u._cache);var g=u.toSeq().map(hC).toIndexedSeq();return g.fromEntrySeq=function(){return u.toSeq()},g},filterNot:function(u,g){return this.filter(ch(u),g)},findEntry:function(u,g,y){var M=y;return this.__iterate(function(C,D,k){if(u.call(g,C,D,k))return M=[D,C],!1}),M},findKey:function(u,g){var y=this.findEntry(u,g);return y&&y[0]},findLast:function(u,g,y){return this.toKeyedSeq().reverse().find(u,g,y)},findLastEntry:function(u,g,y){return this.toKeyedSeq().reverse().findEntry(u,g,y)},findLastKey:function(u,g){return this.toKeyedSeq().reverse().findKey(u,g)},first:function(){return this.find(Q)},flatMap:function(u,g){return Wt(this,oC(this,u,g))},flatten:function(u){return Wt(this,S2(this,u,!0))},fromEntrySeq:function(){return new Ia(this)},get:function(u,g){return this.find(function(y,M){return Be(M,u)},void 0,g)},getIn:function(u,g){for(var y=this,M=A2(u),C;!(C=M.next()).done;){var D=C.value;if(y=y&&y.get?y.get(D,b):b,y===b)return g}return y},groupBy:function(u,g){return rC(this,u,g)},has:function(u){return this.get(u,b)!==b},hasIn:function(u){return this.getIn(u,b)!==b},isSubset:function(u){return u=typeof u.includes=="function"?u:i(u),this.every(function(g){return u.includes(g)})},isSuperset:function(u){return u=typeof u.isSubset=="function"?u:i(u),u.isSubset(this)},keyOf:function(u){return this.findKey(function(g){return Be(g,u)})},keySeq:function(){return this.toSeq().map(uC).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(u){return this.toKeyedSeq().reverse().keyOf(u)},max:function(u){return sh(this,u)},maxBy:function(u,g){return sh(this,g,u)},min:function(u){return sh(this,u?F2(u):k2)},minBy:function(u,g){return sh(this,g?F2(g):k2,u)},rest:function(){return this.slice(1)},skip:function(u){return this.slice(Math.max(0,u))},skipLast:function(u){return Wt(this,this.toSeq().reverse().skip(u).reverse())},skipWhile:function(u,g){return Wt(this,y2(this,u,g,!0))},skipUntil:function(u,g){return this.skipWhile(ch(u),g)},sortBy:function(u,g){return Wt(this,La(this,g,u))},take:function(u){return this.slice(0,Math.max(0,u))},takeLast:function(u){return Wt(this,this.toSeq().reverse().take(u).reverse())},takeWhile:function(u,g){return Wt(this,iC(this,u,g))},takeUntil:function(u,g){return this.takeWhile(ch(u),g)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=dC(this))}});var Yn=i.prototype;Yn[d]=!0,Yn[Ee]=Yn.values,Yn.__toJS=Yn.toArray,Yn.__toStringMapper=z2,Yn.inspect=Yn.toSource=function(){return this.toString()},Yn.chain=Yn.flatMap,Yn.contains=Yn.includes,Li(s,{flip:function(){return Wt(this,_2(this))},mapEntries:function(u,g){var y=this,M=0;return Wt(this,this.toSeq().map(function(C,D){return u.call(g,[D,C],M++,y)}).fromEntrySeq())},mapKeys:function(u,g){var y=this;return Wt(this,this.toSeq().flip().map(function(M,C){return u.call(g,M,C,y)}).flip())}});var lh=s.prototype;lh[m]=!0,lh[Ee]=Yn.entries,lh.__toJS=Yn.toObject,lh.__toStringMapper=function(u,g){return JSON.stringify(g)+": "+z2(u)},Li(o,{toKeyedSeq:function(){return new zr(this,!1)},filter:function(u,g){return Wt(this,x2(this,u,g,!1))},findIndex:function(u,g){var y=this.findEntry(u,g);return y?y[0]:-1},indexOf:function(u){var g=this.keyOf(u);return g===void 0?-1:g},lastIndexOf:function(u){var g=this.lastKeyOf(u);return g===void 0?-1:g},reverse:function(){return Wt(this,bm(this,!1))},slice:function(u,g){return Wt(this,Mm(this,u,g,!1))},splice:function(u,g){var y=arguments.length;if(g=Math.max(g|0,0),y===0||y===2&&!g)return this;u=J(u,u<0?this.count():this.size);var M=this.slice(0,u);return Wt(this,y===1?M:M.concat(N(arguments,2),this.slice(u+g)))},findLastIndex:function(u,g){var y=this.findLastEntry(u,g);return y?y[0]:-1},first:function(){return this.get(0)},flatten:function(u){return Wt(this,S2(this,u,!1))},get:function(u,g){return u=W(this,u),u<0||this.size===1/0||this.size!==void 0&&u>this.size?g:this.find(function(y,M){return M===u},void 0,g)},has:function(u){return u=W(this,u),u>=0&&(this.size!==void 0?this.size===1/0||u<this.size:this.indexOf(u)!==-1)},interpose:function(u){return Wt(this,aC(this,u))},interleave:function(){var u=[this].concat(N(arguments)),g=wm(this.toSeq(),Le.of,u),y=g.flatten(!0);return g.size&&(y.size=g.size*u.length),Wt(this,y)},keySeq:function(){return Se(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(u,g){return Wt(this,y2(this,u,g,!1))},zip:function(){var u=[this].concat(N(arguments));return Wt(this,wm(this,fC,u))},zipWith:function(u){var g=N(arguments);return g[0]=this,Wt(this,wm(this,u,g))}}),o.prototype[x]=!0,o.prototype[v]=!0,Li(a,{get:function(u,g){return this.has(u)?u:g},includes:function(u){return this.has(u)},keySeq:function(){return this.valueSeq()}}),a.prototype.has=Yn.includes,a.prototype.contains=a.prototype.includes,Li(rt,s.prototype),Li(Le,o.prototype),Li(at,a.prototype),Li(Te,s.prototype),Li(me,o.prototype),Li(Ke,a.prototype);function uC(u,g){return g}function hC(u,g){return[g,u]}function ch(u){return function(){return!u.apply(this,arguments)}}function F2(u){return function(){return-u.apply(this,arguments)}}function z2(u){return typeof u=="string"?JSON.stringify(u):String(u)}function fC(){return N(arguments)}function k2(u,g){return u<g?1:u>g?-1:0}function dC(u){if(u.size===1/0)return 0;var g=p(u),y=c(u),M=g?1:0,C=u.__iterate(y?g?function(D,k){M=31*M+B2(dt(D),dt(k))|0}:function(D,k){M=M+B2(dt(D),dt(k))|0}:g?function(D){M=31*M+dt(D)|0}:function(D){M=M+dt(D)|0});return pC(C,M)}function pC(u,g){return g=ut(g,3432918353),g=ut(g<<15|g>>>-15,461845907),g=ut(g<<13|g>>>-13,5),g=(g+3864292196|0)^u,g=ut(g^g>>>16,2246822507),g=ut(g^g>>>13,3266489909),g=Ot(g^g>>>16),g}function B2(u,g){return u^g+2654435769+(u<<6)+(u>>2)|0}var mC={Iterable:i,Seq:z,Collection:ke,Map:Mt,OrderedMap:hn,List:tn,Stack:_n,Set:nn,OrderedSet:Ii,Record:yr,Range:Se,Repeat:Re,is:Be,fromJS:Ge};return mC})})(bc)),bc.exports}var wf,gg;function L3(){if(gg)return wf;gg=1;var n=Mf(),e=function(i){return n.Iterable.isKeyed(i)},t=function(i){return n.Iterable.isIndexed(i)},r=function(i,s,o){return i==="remove"?{op:i,path:s}:{op:i,path:s,value:o}};return wf={isMap:e,isIndexed:t,op:r},wf}var Tf,_g;function O3(){if(_g)return Tf;_g=1;var n=Mf(),e=function(c,h,f){for(var p=[],d=0;d<c;d++){p[d]=new Array(h);for(var m=0;m<h;m++)p[d][m]=f}return p},t=function(c,h){var f=a(c,h);return l(c,h,f)},r=n.Record({op:"=",val:null}),i=n.Record({op:"!=",val:null,newVal:null}),s=function(c,h){var f=a(c,h);return o(f,c,h,c.size||0,h.size||0)},o=function(c,h,f,p,d){for(var m=[],x=p-1,v=d-1;x>=0||v>=0;)x>=0&&v>=0&&n.is(h.get(x),f.get(v))?(m.push(new r({op:"=",val:h.get(x)})),x-=1,v-=1):x>=0&&v>=0&&x===v&&!n.is(h.get(x),f.get(v))?(m.push(new i({val:h.get(x),newVal:f.get(x)})),x-=1,v-=1):v>=0&&(x===-1||c[x+1][v]>=c[x][v+1])?(m.push(new r({op:"+",val:f.get(v)})),v-=1):x>=0&&(v===-1||c[x+1][v]<c[x][v+1])&&(m.push(new r({op:"-",val:h.get(x)})),x-=1);return m.reverse()};function a(c,h){for(var f=c.size||0,p=h.size||0,d=e(f+1,p+1,0),m=0;m<f;m++)for(var x=0;x<p;x++)n.is(c.get(m),h.get(x))?d[m+1][x+1]=d[m][x]+1:d[m+1][x+1]=Math.max(d[m+1][x],d[m][x+1]);return d}var l=function(c,h,f){for(var p=[],d=c.size,m=h.size;d!==0&&m!==0;)f[d][m]===f[d-1][m]?d--:f[d][m]===f[d][m-1]?m--:n.is(c.get(d-1),h.get(m-1))&&(p.push(c.get(d-1)),d--,m--);return p.reverse()};return Tf={lcs:t,computeLcsMatrix:a,diff:s},Tf}var Af,vg;function q3(){if(vg)return Af;vg=1;var n=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,r=/~0/g,i={escape:function(s){if(typeof s=="number")return s.toString();if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(t,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(e,"/").replace(r,"~"):s},concat:function(s,o){return s+"/"+o}};return Af=i,Af}var Cf,xg;function D3(){if(xg)return Cf;xg=1;var n=Mf(),e=L3(),t=O3(),r=q3(),i=r.concat,s=r.escape,o=e.op,a=e.isMap,l=e.isIndexed,c=function(d,m,x){var v=[],_=x||"";if(n.is(d,m)||d==m==null)return v;var w=l(d)&&l(m),E=null,S=null;return d.forEach&&d.forEach(function(b,A){if(m.has(A))if(a(b)&&a(m.get(A)))v=v.concat(c(b,m.get(A),i(_,s(A))));else if(l(m.get(A))&&l(b))v=v.concat(h(b,m.get(A),i(_,s(A))));else{var q=m.get?m.get(A):m,O=b!==q;O&&v.push(o("replace",i(_,s(A)),q))}else w?(S=E!=null&&E+1===A?S:A,v.push(o("remove",i(_,s(S)))),E=A):v.push(o("remove",i(_,s(A))))}),m.forEach(function(b,A){d.has&&!d.has(A)&&v.push(o("add",i(_,s(A)),b))}),v},h=function(d,m,x){var v=[],_=x||"";if(n.is(d,m)||d==m==null)return v;if((d.count()+1)*(m.count()+1)>=1e4)return c(d,m,x);var w=t.diff(d,m),E=0;return w.forEach(function(S){if(S.op==="=")E++;else if(S.op==="!="){if(a(S.val)&&a(S.newVal)){var b=c(S.val,S.newVal,i(_,E));v=v.concat(b)}else v.push(o("replace",i(_,E),S.newVal));E++}else S.op==="+"?(v.push(o("add",i(_,E),S.val)),E++):S.op==="-"&&v.push(o("remove",i(_,E)))}),v},f=function(d,m,x){var v=x||"";return d===m?[]:[o("replace",i(v,""),m)]},p=function(d,m,x){return n.is(d,m)?n.List():d!=m&&(d==null||m==null)?n.fromJS([o("replace","/",m)]):l(d)&&l(m)?n.fromJS(h(d,m)):a(d)&&a(m)?n.fromJS(c(d,m)):n.fromJS(f(d,m,x))};return Cf=p,Cf}var N3=D3();const U3=qa(N3),F3=Lm(Xy);var Rf,yg;function z3(){if(yg)return Rf;yg=1;var n=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,r=/~0/g,i={escape:function(s){if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(t,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(e,"/").replace(r,"~"):s}};return Rf=i,Rf}var Pf,Sg;function k3(){if(Sg)return Pf;Sg=1;var n=F3,e=z3(),t=function(h){var f=parseInt(h);return isNaN(f)?h:f},r=function(h,f){if(h==="add"||h==="replace")return f;if(h==="remove")return null},i=function(h,f,p,d,m){if(d==="add")if(p.length>0&&h.get(f)===void 0){var x=p[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(x,p,d,m))}else return h.set(f,a(h.get(f),p,d,m));else{if(d==="replace")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.set(f,m);if(d==="remove")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.remove(f);throw new Error("map patch Error, unknown op: "+d)}},s=function(h,f,p,d,m){if(f=t(f),d==="add")if(h.get(f)===void 0)if(p.length>0){var x=p[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(x,p,d,m))}else return f==="-"?h.splice(h.size,0,m):h.splice(f,0,m);else return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.splice(f,0,m);else{if(d==="replace")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.set(f,m);if(d==="remove")return p.length>0?h.set(f,a(h.get(f),p,d,m)):h.remove(f);throw new Error("sequence patch Error, unknown op: "+d)}},o=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},a=function(h,f,p,d){var m,x;return n.Iterable.isIndexed(h)?f.length===0?h:(m=f[0],x=f.slice(1),s(h,m,x,p,d)):n.Iterable.isKeyed(h)||o(h)?f.length===0?h:(m=f[0],x=f.slice(1),i(h,m,x,p,d)):f.length===0?d:r(p,d)},l=function(h,f){for(;f.size;){var p=f.get(0),f=f.slice(1),d=p.get("path").split("/").slice(1).map(e.unescape);h=a(h,d,p.get("op"),p.get("value"))}return h},c=function(h,f){if(f.size===1){var p=f.get(0);if(p.get("op")==="replace"&&p.get("path")==="/")return p.get("value")}return l(h,f)};return c.default=c,Pf=c,Pf}var B3=k3();const Eg=qa(B3),on=(n,e)=>{if(n.last){if(n.last.hashCode()!==e.hashCode()){let t=Ie({time:Date.now(),diff:U3(n.last,e)});n=n.set("last",e).set("list",n.list.push(t)).set("redoList",n.redoList.clear())}}else n=n.set("last",e);return n},V3=n=>{if(n.last&&n.redoList.size){const e=n.redoList.last(),t=Eg(n.last,e.get("diff"));n=n.set("last",t).set("list",n.list.push(e)).set("redoList",n.redoList.pop())}return n},bg=n=>{var e;if(n.last&&n.list.size){const t=n.list.last();let r=n.first;for(let i=0;i<n.list.size-1;i++)r=Eg(r,(e=n.list.get(i))==null?void 0:e.get("diff"));n=n.set("last",r).set("list",n.list.pop()).set("redoList",n.redoList.push(t))}return n};var If={exports:{}},Lf,Mg;function H3(){if(Mg)return Lf;Mg=1;var n=1;function e(){return n=(n*9301+49297)%233280,n/233280}function t(r){n=r}return Lf={nextValue:e,seed:t},Lf}var Of,wg;function Mc(){if(wg)return Of;wg=1;var n=H3(),e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",t,r,i;function s(){i=!1}function o(d){if(!d){t!==e&&(t=e,s());return}if(d!==t){if(d.length!==e.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. You submitted "+d.length+" characters: "+d);var m=d.split("").filter(function(x,v,_){return v!==_.lastIndexOf(x)});if(m.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. These characters were not unique: "+m.join(", "));t=d,s()}}function a(d){return o(d),t}function l(d){n.seed(d),r!==d&&(s(),r=d)}function c(){t||o(e);for(var d=t.split(""),m=[],x=n.nextValue(),v;d.length>0;)x=n.nextValue(),v=Math.floor(x*d.length),m.push(d.splice(v,1)[0]);return m.join("")}function h(){return i||(i=c(),i)}function f(d){var m=h();return m[d]}function p(){return t||e}return Of={get:p,characters:a,seed:l,lookup:f,shuffled:h},Of}var qf,Tg;function G3(){if(Tg)return qf;Tg=1;var n=typeof window=="object"&&(window.crypto||window.msCrypto),e;return!n||!n.getRandomValues?e=function(t){for(var r=[],i=0;i<t;i++)r.push(Math.floor(Math.random()*256));return r}:e=function(t){return n.getRandomValues(new Uint8Array(t))},qf=e,qf}let W3="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Ag=n=>crypto.getRandomValues(new Uint8Array(n)),Cg=(n,e,t)=>{let r=(2<<Math.log(n.length-1)/Math.LN2)-1,i=-~(1.6*r*e/n.length);return(s=e)=>{let o="";for(;;){let a=t(i),l=i|0;for(;l--;)if(o+=n[a[l]&r]||"",o.length===s)return o}}};const j3=Lm(Object.freeze(Object.defineProperty({__proto__:null,customAlphabet:(n,e=21)=>Cg(n,e,Ag),customRandom:Cg,nanoid:(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),random:Ag,urlAlphabet:W3},Symbol.toStringTag,{value:"Module"})));var Df,Rg;function X3(){if(Rg)return Df;Rg=1;var n=Mc(),e=G3(),t=j3.customRandom;function r(i){for(var s=0,o,a="";!o;)a=a+t(n.get(),1,e)(),o=i<Math.pow(16,s+1),s++;return a}return Df=r,Df}var Nf,Pg;function $3(){if(Pg)return Nf;Pg=1;var n=X3();Mc();var e=1567752802062,t=7,r,i;function s(o){var a="",l=Math.floor((Date.now()-e)*.001);return l===i?r++:(r=0,i=l),a=a+n(t),a=a+n(o),r>0&&(a=a+n(r)),a=a+n(l),a}return Nf=s,Nf}var Uf,Ig;function Y3(){if(Ig)return Uf;Ig=1;var n=Mc();function e(t){if(!t||typeof t!="string"||t.length<6)return!1;var r=new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!r.test(t)}return Uf=e,Uf}var Ff,Lg;function K3(){return Lg||(Lg=1,Ff=0),Ff}var Og;function Z3(){return Og||(Og=1,(function(n){var e=Mc(),t=$3(),r=Y3(),i=K3()||0;function s(c){return e.seed(c),n.exports}function o(c){return i=c,n.exports}function a(c){return c!==void 0&&e.characters(c),e.shuffled()}function l(){return t(i)}n.exports=l,n.exports.generate=l,n.exports.seed=s,n.exports.worker=o,n.exports.characters=a,n.exports.isValid=r})(If)),If.exports}var zf,qg;function J3(){return qg||(qg=1,zf=Z3()),zf}var Q3=J3();const eS=qa(Q3);class gi{static acquireID(){return eS.generate()}}class wc{static generateName(e,t){return t.charAt(0).toUpperCase()+t.slice(1)}}class pn{static create(e,t,r,i,s,o){let a=gi.acquireID(),l=e.catalog.factoryElement(r,{id:a,name:wc.generateName("holes",e.catalog.getIn(["elements",r,"info","title"])),type:r,offset:s,line:i},o);return e=e.setIn(["scene","layers",t,"holes",a],l),e=e.updateIn(["scene","layers",t,"lines",i,"holes"],c=>c.push(a)),{updatedState:e,hole:l}}static select(e,t,r){return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"holes",r).updatedState,{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"holes",r]);return e=this.unselect(e,t,r).updatedState,e=it.removeElement(e,t,"holes",r).updatedState,e=e.updateIn(["scene","layers",t,"lines",i.line,"holes"],s=>{let o=s.findIndex(a=>r===a);return o!==-1?s.remove(o):s}),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"holes",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"holes",r).updatedState,{updatedState:e}}static selectToolDrawingHole(e,t){let r=He().withMutations(i=>{let{lines:s,vertices:o}=e.getIn(["scene","layers",e.scene.selectedLayer]);s.forEach(a=>{if(a.get("type")==="surface")return;let{x:l,y:c}=o.get(a.vertices.get(0)),{x:h,y:f}=o.get(a.vertices.get(1));sl(i,l,c,h,f,20,1,a.id)})});return e=e.merge({mode:hr,snapElements:r,drawingSupport:Ie({type:t})}),{updatedState:e}}static updateDrawingHole(e,t,r,i){let s=e.catalog,o=mi(e.snapElements,r,i,e.snapMask.merge({SNAP_SEGMENT:!0}));o&&({x:r,y:i}=o.point);let a=e.getIn(["scene","layers",t,"selected","holes"]).first();if(o){let l=o.snap.related.get(0),c=e.getIn(["scene","layers",t,"lines",l,"vertices"]),{x:h,y:f}=e.getIn(["scene","layers",t,"vertices",c.get(0)]),{x:p,y:d}=e.getIn(["scene","layers",t,"vertices",c.get(1)]),m=pc({x:h,y:f},{x:p,y:d}),x=ff({x:h,y:f},{x:p,y:d}),v=s.factoryElement(e.drawingSupport.get("type")).properties.getIn(["width","length"]),_=Cn(h,f,p,d),w=i3(h,f,p,d),E=o3(w,1e-7),S=a3(w,1e-7),b={x:m.x+v/2*E,y:m.y+v/2*S},A={x:m.x+_*E-v/2*E,y:m.y+_*S-v/2*S},q;if(r<b.x?q=On(m.x,m.y,x.x,x.y,b.x,b.y):r>A.x?q=On(m.x,m.y,x.x,x.y,A.x,A.y):r===b.x&&r===A.x?i<b.y?(q=On(m.x,m.y,x.x,x.y,b.x,b.y),q=m.x===h&&m.y===f?q:1-q):i>A.y?(q=On(m.x,m.y,x.x,x.y,A.x,A.y),q=m.x===h&&m.y===f?q:1-q):q=On(h,f,p,d,r,i):q=On(h,f,p,d,r,i),a&&o){e=e.mergeIn(["scene","layers",t,"holes",a],{offset:q,line:l});let O=e.getIn(["scene","layers",t,"lines"]).findEntry(I=>I.id!==l&&I.get("holes").contains(a));if(O){let I=O[1].get("holes").filter(N=>N!==a);e=e.setIn(["scene","layers",t,"lines",O[0],"holes"],I)}let T=e.getIn(["scene","layers",t,"lines",l,"holes"]);T.contains(a)||(e=e.setIn(["scene","layers",t,"lines",l,"holes"],T.push(a)))}else if(!a&&o){let{updatedState:O,hole:T}=this.create(e,t,e.drawingSupport.get("type"),l,q);e=pn.select(O,t,T.id).updatedState}}return{updatedState:e}}static endDrawingHole(e,t,r,i){return e=this.updateDrawingHole(e,t,r,i).updatedState,e=it.unselectAll(e,t).updatedState,{updatedState:e}}static beginDraggingHole(e,t,r,i,s){let o=e.getIn(["scene","layers",t]),a=o.getIn(["holes",r]),l=o.getIn(["lines",a.line]),c=o.getIn(["vertices",l.vertices.get(0)]),h=o.getIn(["vertices",l.vertices.get(1)]),f=sl(He(),c.x,c.y,h.x,h.y,9999999,1,null);return e=e.merge({mode:Wr,snapElements:f,draggingSupport:Ie({layerID:t,holeID:r,startPointX:i,startPointY:s})}),{updatedState:e}}static updateDraggingHole(e,t,r){let i=mi(e.snapElements,t,r,e.snapMask.merge({SNAP_SEGMENT:!0}));if(!i)return e;let{draggingSupport:s,scene:o}=e,a=s.get("layerID"),l=s.get("holeID"),c=e.getIn(["scene","layers",a]),h=c.getIn(["holes",l]),f=c.getIn(["lines",h.line]),p=c.getIn(["vertices",f.vertices.get(0)]),d=c.getIn(["vertices",f.vertices.get(1)]);({x:t,y:r}=i.point);let m=pc(p,d),x=ff(p,d),v=h.properties.get("width").get("length"),_=Cn(p.x,p.y,d.x,d.y),w=Math.atan2(Math.abs(d.y-p.y),Math.abs(d.x-p.x)),E=I=>{let N=Math.cos(I);return N<1e-7?0:N},S=I=>{let N=Math.sin(I);return N<1e-7?0:N},b=E(w),A=S(w),q={x:m.x+v/2*b,y:m.y+v/2*A},O={x:m.x+_*b-v/2*b,y:m.y+_*A-v/2*A},T;return t<q.x?T=On(m.x,m.y,x.x,x.y,q.x,q.y):t>O.x?T=On(m.x,m.y,x.x,x.y,O.x,O.y):t===q.x&&t===O.x?r<q.y?(T=On(m.x,m.y,x.x,x.y,q.x,q.y),T=m===p?T:1-T):r>O.y?(T=On(m.x,m.y,x.x,x.y,O.x,O.y),T=m===p?T:1-T):(T=On(m.x,m.y,x.x,x.y,t,r),T=m===p?T:1-T):T=On(m.x,m.y,x.x,x.y,t,r),h=h.set("offset",T),e=e.merge({scene:o.mergeIn(["layers",a,"holes",l],h)}),{updatedState:e}}static endDraggingHole(e,t,r){return e=this.updateDraggingHole(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.setIn(["scene","layers",t,"holes",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"holes",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"holes",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){let s=i.toJS(),{offsetA:o,offsetB:a,offset:l}=s;delete s.offsetA,delete s.offsetB,delete s.offset;let c=Ie({_unitA:o._unit,_unitB:a._unit});return e=e.mergeIn(["scene","layers",t,"holes",r],At(s)).mergeDeepIn(["scene","layers",t,"holes",r],Ie({offset:l,misc:c})),{updatedState:e}}}let xn=class V2{static create(e,t,r,i,s,o,a,l,c){let h=gi.acquireID(),f=e.catalog.factoryElement(r,{id:h,name:wc.generateName("items",e.catalog.getIn(["elements",r,"info","title"])),type:r,height:a,width:o,x:i,y:s,rotation:l,altitude:c});return e=e.setIn(["scene","layers",t,"items",h],f),{updatedState:e,item:f}}static select(e,t,r){return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"items",r).updatedState,{updatedState:e}}static remove(e,t,r){return e=this.unselect(e,t,r).updatedState,e=it.removeElement(e,t,"items",r).updatedState,e.getIn(["scene","groups"]).forEach(i=>e=mn.removeElement(e,i.id,t,"items",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"items",r).updatedState,{updatedState:e}}static selectToolDrawingItem(e,t){return e=e.merge({mode:Cr,drawingSupport:Ie({type:t})}),{updatedState:e}}static updateDrawingItem(e,t,r,i){if(e.hasIn(["drawingSupport","currentID"]))e=e.updateIn(["scene","layers",t,"items",e.getIn(["drawingSupport","currentID"])],s=>s.merge({x:r,y:i}));else{let{updatedState:s,item:o}=this.create(e,t,e.getIn(["drawingSupport","type"]),r,i,200,100,0,0);e=V2.select(s,t,o.id).updatedState,e=e.setIn(["drawingSupport","currentID"],o.id)}return{updatedState:e}}static endDrawingItem(e,t,r,i){return e=this.updateDrawingItem(e,t,r,i).updatedState,e=it.unselectAll(e,t).updatedState,e=e.merge({drawingSupport:Ie({type:e.drawingSupport.get("type")})}),{updatedState:e}}static beginDraggingItem(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"items",r]);return e=e.merge({mode:Gr,draggingSupport:Ie({layerID:t,itemID:r,startPointX:i,startPointY:s,originalX:o.x,originalY:o.y})}),{updatedState:e}}static updateDraggingItem(e,t,r){let{draggingSupport:i,scene:s}=e,o=i.get("layerID"),a=i.get("itemID"),l=i.get("startPointX"),c=i.get("startPointY"),h=i.get("originalX"),f=i.get("originalY"),p=l-t,d=c-r,m=s.getIn(["layers",o,"items",a]);return m=m.merge({x:h-p,y:f-d}),e=e.merge({scene:s.mergeIn(["layers",o,"items",a],m)}),{updatedState:e}}static endDraggingItem(e,t,r){return e=this.updateDraggingItem(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static beginRotatingItem(e,t,r,i,s){return e=e.merge({mode:Di,rotatingSupport:Ie({layerID:t,itemID:r})}),{updatedState:e}}static updateRotatingItem(e,t,r){let{rotatingSupport:i,scene:s}=e,o=i.get("layerID"),a=i.get("itemID"),l=e.getIn(["scene","layers",o,"items",a]),c=t-l.x,h=r-l.y,f=Math.atan2(h,c)*180/Math.PI-90;return-5<f&&f<5&&(f=0),-95<f&&f<-85&&(f=-90),-185<f&&f<-175&&(f=-180),85<f&&f<90&&(f=90),-270<f&&f<-265&&(f=90),l=l.merge({rotation:f}),e=e.merge({scene:s.mergeIn(["layers",o,"items",a],l)}),{updatedState:e}}static endRotatingItem(e,t,r){return e=this.updateRotatingItem(e,t,r).updatedState,e=e.merge({mode:sn}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"items",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"items",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"items",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"items",r],i),{updatedState:e}}static setJsAttributes(e,t,r,i){return i=At(i),this.setAttributes(e,t,r,i)}},mn=class hh{static select(e,t){let r=e.getIn(["scene","groups",t,"elements"]);e=qt.setAlterate(e).updatedState,r.entrySeq().forEach(([s,o])=>{e=it.unselectAll(e,s).updatedState;let a=o.get("lines"),l=o.get("holes"),c=o.get("items"),h=o.get("areas");a&&a.forEach(f=>{e=Jt.select(e,s,f).updatedState}),l&&l.forEach(f=>{e=pn.select(e,s,f).updatedState}),c&&c.forEach(f=>{e=xn.select(e,s,f).updatedState}),h&&h.forEach(f=>{e=Fs.select(e,s,f).updatedState})}),e=qt.setAlterate(e).updatedState;let i=e.getIn(["scene","groups"]).map(s=>s.set("selected",!1));return e=e.setIn(["scene","groups"],i).setIn(["scene","groups",t,"selected"],!0),{updatedState:e}}static unselect(e,t){return e=e.getIn(["scene","groups",t,"elements"]).reduce((s,o,a)=>it.unselectAll(s,a).updatedState,e).setIn(["scene","groups",t,"selected"],!1),{updatedState:e}}static create(e){let t=gi.acquireID();return e=e.setIn(["scene","groups",t],new Sf({id:t,name:t})),{updatedState:e}}static createFromSelectedElements(e){let t=gi.acquireID();return e=e.setIn(["scene","groups",t],new Sf({id:t,name:t})),e.getIn(["scene","layers"]).forEach(r=>{let i=r.get("id"),s={lines:r.get("lines").filter(o=>o.get("selected")),items:r.get("items").filter(o=>o.get("selected")),holes:r.get("holes").filter(o=>o.get("selected")),areas:r.get("areas").filter(o=>o.get("selected"))};for(let o in s)s[o].forEach(a=>e=this.addElement(e,t,i,o,a.get("id")).updatedState)}),{updatedState:e}}static addElement(e,t,r,i,s){let o=e.getIn(["scene","groups",t,"elements",r,i])||He();return o.contains(s)||(e=e.setIn(["scene","groups",t,"elements",r,i],o.push(s)),e=this.reloadBaricenter(e,t).updatedState),{updatedState:e}}static setBarycenter(e,t,r,i){return typeof r<"u"&&(e=e.setIn(["scene","groups",t,"x"],r)),typeof i<"u"&&(e=e.setIn(["scene","groups",t,"y"],i)),{updatedState:e}}static reloadBaricenter(e,t){let r=e.getIn(["scene","groups",t,"elements"]),i=0,s=0,o=0;return r.entrySeq().forEach(([a,l])=>{e=it.unselectAll(e,a).updatedState;let c=l.get("lines"),h=l.get("holes"),f=l.get("items"),p=l.get("areas");c&&c.forEach(d=>{let m=e.getIn(["scene","layers",a,"lines",d,"vertices"]).map(b=>e.getIn(["scene","layers",a,"vertices",b])),{x,y:v}=m.get(0),{x:_,y:w}=m.get(1),{x:E,y:S}=l3(x,v,_,w);i+=E,s+=S,o++}),h&&h.forEach(d=>{let m=e.getIn(["scene","layers",a,"holes",d]),x=e.getIn(["scene","layers",a,"lines",m.line,"vertices"]).map(A=>e.getIn(["scene","layers",a,"vertices",A])),{x:v,y:_}=x.get(0),{x:w,y:E}=x.get(1),{x:S,y:b}=vc(v,_,w,E,m.offset*Cn(v,_,w,E));i+=S,s+=b,o++}),f&&f.forEach(d=>{let{x:m,y:x}=e.getIn(["scene","layers",a,"items",d]);i+=m,s+=x,o++}),p&&p.forEach(d=>{let m=e.getIn(["scene","layers",a,"areas",d,"vertices"]).map(_=>e.getIn(["scene","layers",a,"vertices",_])).toJS(),{x,y:v}=c3(m);i+=x,s+=v,o++})}),o&&(e=this.setBarycenter(e,t,i/o,s/o).updatedState),{updatedState:e}}static removeElement(e,t,r,i,s){let o=e.getIn(["scene","groups",t,"elements",r,i]);return!o||!o.contains(s)?{updatedState:e}:(e=e.setIn(["scene","groups",t,"elements",r,i],o.filterNot(a=>a===s)),{updatedState:e})}static setAttributes(e,t,r){return e=e.mergeIn(["scene","groups",t],r),{updatedState:e}}static setProperties(e,t,r){return e=e.mergeIn(["scene","groups",t,"properties"],r),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","groups",t]),{updatedState:e}}static removeAndDeleteElements(e,t){return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([i,s])=>{e=it.unselectAll(e,i).updatedState;let o=s.get("lines"),a=s.get("holes"),l=s.get("items");s.get("areas"),o&&o.forEach(c=>{e=Jt.remove(e,i,c).updatedState,e=it.detectAndUpdateAreas(e,i).updatedState}),a&&a.forEach(c=>{e=pn.remove(e,i,c).updatedState}),l&&l.forEach(c=>{e=xn.remove(e,i,c).updatedState})}),e=e.deleteIn(["scene","groups",t]),{updatedState:e}}static translate(e,t,r,i){let s=r-e.getIn(["scene","groups",t,"x"]),o=i-e.getIn(["scene","groups",t,"y"]);return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([l,c])=>{let h=c.get("lines"),f=c.get("items");if(h){let p={};h.forEach(d=>{let m=e.getIn(["scene","layers",l,"lines",d]);p[m.vertices.get(0)]||(p[m.vertices.get(0)]=e.getIn(["scene","layers",l,"vertices",m.vertices.get(0)])),p[m.vertices.get(1)]||(p[m.vertices.get(1)]=e.getIn(["scene","layers",l,"vertices",m.vertices.get(1)]))});for(let d in p){let{x:m,y:x}=p[d];e=cn.setAttributes(e,l,d,Ie({x:m+s,y:x+o})).updatedState}for(let d in p)e=cn.beginDraggingVertex(e,l,d).updatedState,e=cn.endDraggingVertex(e).updatedState}f&&(e=f.map(p=>e.getIn(["scene","layers",l,"items",p])).reduce((p,d)=>{let{x:m,y:x}=d;return xn.setAttributes(p,l,d.id,Ie({x:m+s,y:x+o})).updatedState},e)),e=it.detectAndUpdateAreas(e,l).updatedState}),e=this.setBarycenter(e,t,r,i).updatedState,e=hh.select(e,t).updatedState,{updatedState:e}}static rotate(e,t,r){let{x:i,y:s,rotation:o}=e.getIn(["scene","groups",t]),a=r-o;return e=hh.setAttributes(e,t,Ie({rotation:r})).updatedState,e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([c,h])=>{let f=h.get("lines"),p=h.get("items");if(f){let d={};f.forEach(m=>{let x=e.getIn(["scene","layers",c,"lines",m]);d[x.vertices.get(0)]||(d[x.vertices.get(0)]=e.getIn(["scene","layers",c,"vertices",x.vertices.get(0)])),d[x.vertices.get(1)]||(d[x.vertices.get(1)]=e.getIn(["scene","layers",c,"vertices",x.vertices.get(1)]))});for(let m in d){let{x,y:v}=d[m],{x:_,y:w}=tg(x,v,i,s,a);e=cn.setAttributes(e,c,m,Ie({x:_,y:w})).updatedState}for(let m in d)e=cn.beginDraggingVertex(e,c,m).updatedState,e=cn.endDraggingVertex(e).updatedState}p&&(e=p.map(d=>e.getIn(["scene","layers",c,"items",d])).reduce((d,m)=>{let{x,y:v,rotation:_}=m,{x:w,y:E}=tg(x,v,i,s,a);return xn.setAttributes(d,c,m.id,Ie({x:w,y:E,rotation:_+a})).updatedState},e)),e=it.detectAndUpdateAreas(e,c).updatedState}),e=hh.select(e,t).updatedState,{updatedState:e}}},Jt=class kr{static create(e,t,r,i,s,o,a,l){let c=gi.acquireID(),{updatedState:h,vertex:f}=cn.add(e,t,i,s,"lines",c),{updatedState:p,vertex:d}=cn.add(h,t,o,a,"lines",c);e=p;let m=e.catalog.factoryElement(r,{id:c,name:wc.generateName("lines",e.catalog.getIn(["elements",r,"info","title"])),vertices:He([f.id,d.id]),type:r},l);return e=e.setIn(["scene","layers",t,"lines",c],m),{updatedState:e,line:m}}static select(e,t,r,i){i||(e=it.select(e,t).updatedState);let s=e.getIn(["scene","layers",t,"lines",r]);return e=it.selectElement(e,t,"lines",r).updatedState,e=it.selectElement(e,t,"vertices",s.vertices.get(0)).updatedState,e=it.selectElement(e,t,"vertices",s.vertices.get(1)).updatedState,{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"lines",r]);return i&&(e=this.unselect(e,t,r).updatedState,i.holes.forEach(s=>e=pn.remove(e,t,s).updatedState),e=it.removeElement(e,t,"lines",r).updatedState,i.vertices.forEach(s=>e=cn.remove(e,t,s,"lines",r).updatedState),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"lines",r).updatedState)),{updatedState:e}}static unselect(e,t,r){let i=e.getIn(["scene","layers",t,"lines",r]);return i&&(e=it.unselect(e,t,"vertices",i.vertices.get(0)).updatedState,e=it.unselect(e,t,"vertices",i.vertices.get(1)).updatedState,e=it.unselect(e,t,"lines",r).updatedState),{updatedState:e}}static split(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"lines",r]),a=e.getIn(["scene","layers",t,"vertices",o.vertices.get(0)]),l=e.getIn(["scene","layers",t,"vertices",o.vertices.get(1)]),{x:c,y:h}=a,{x:f,y:p}=l,{updatedState:d,line:m}=kr.create(e,t,o.type,c,h,i,s,o.get("properties")),{updatedState:x,line:v}=kr.create(d,t,o.type,f,p,i,s,o.get("properties"));e=x;let _=On(c,h,f,p,i,s),w=pc(a,l);return o.holes.forEach(S=>{let b=e.getIn(["scene","layers",t,"holes",S]),A=b.offset;if(w.x===f&&w.y===p&&(_=1-_,A=1-b.offset),A<_){let q=A/_;w.x===f&&w.y===p&&(q=1-q),e=pn.create(e,t,b.type,m.id,q,b.properties).updatedState}else{let q=(A-_)/(1-_);w.x===f&&w.y===p&&(q=1-q),e=pn.create(e,t,b.type,v.id,q,b.properties).updatedState}}),e.getIn(["scene","groups"]).filter(S=>{const b=S.getIn(["elements",t,"lines"]);return b&&b.contains(r)}).forEach(S=>{e=mn.addElement(e,S.id,t,"lines",m.id).updatedState,e=mn.addElement(e,S.id,t,"lines",v.id).updatedState}),e=kr.remove(e,t,r).updatedState,{updatedState:e,lines:He([m,v])}}static addFromPoints(e,t,r,i,s,o){i=He(i).sort(({x:c,y:h},{x:f,y:p})=>c===f?h-p:c-f);let a=i.zip(i.skip(1)).filterNot(([{x:c,y:h},{x:f,y:p}])=>c===f&&h===p),l=[];return a.forEach(([{x:c,y:h},{x:f,y:p}])=>{let{updatedState:d,line:m}=this.create(e,t,r,c,h,f,p,s);e=d,o&&o.forEach(x=>{let{x:v,y:_}=x.offsetPosition;if(e3(c,h,f,p,v,_)){let w=On(c,h,f,p,v,_);w>=0&&w<=1&&(e=pn.create(e,t,x.hole.type,m.id,w,x.hole.properties).updatedState)}}),l.push(m)}),{updatedState:e,lines:He(l)}}static createAvoidingIntersections(e,t,r,i,s,o,a,l,c){let h=[{x:i,y:s},{x:o,y:a}];e=e.getIn(["scene","layers",t,"lines"]).reduce((d,m)=>{var E,S;let[x,v]=m.vertices.map(b=>d.getIn(["scene","layers",t,"vertices"]).get(b)).toArray(),_=jr(x,h[0])||jr(x,h[1])||jr(v,h[0])||jr(v,h[1]),w=Qy(h[0],h[1],x,v);if(w.type==="colinear"){c||(c=[]);const b=rl(h);d.getIn(["scene","layers",t,"lines",m.id,"holes"]).forEach(A=>{let q=d.getIn(["scene","layers",t,"holes",A]),O=Cn(x.x,x.y,v.x,v.y),T=jr(b[1],m.vertices.get(1))?1-q.offset:q.offset,I=vc(x.x,x.y,v.x,v.y,O*T);c.push({hole:q,offsetPosition:I})}),d=this.remove(d,t,m.id).updatedState,h.push(x,v)}return w.type==="intersecting"&&!_&&(d=this.split(d,t,m.id,((E=w.point)==null?void 0:E.x)??0,((S=w.point)==null?void 0:S.y)??0).updatedState,h.push(w.point??{x:0,y:0})),d},e);let{updatedState:f,lines:p}=kr.addFromPoints(e,t,r,h,l,c);return{updatedState:f,lines:p}}static replaceVertex(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"lines",r,"vertices",i]);e=cn.remove(e,t,a,"lines",r).updatedState;let{updatedState:l,vertex:c}=cn.add(e,t,s,o,"lines",r);return e=l,e=e.setIn(["scene","layers",t,"lines",r,"vertices",i],c.id),e=e.setIn(["scene","layers",t,"lines",r],e.getIn(["scene","layers",t,"lines",r])),{updatedState:e,line:e.getIn(["scene","layers",t,"lines",r]),vertex:c}}static selectToolDrawingLine(e,t){return e=e.merge({mode:Ar,drawingSupport:Ie({type:t})}),{updatedState:e}}static beginDrawingLine(e,t,r,i){let s=bf(e.scene,He(),e.snapMask),o=null;e.snapMask&&!e.snapMask.isEmpty()&&(o=mi(s,r,i,e.snapMask),o&&({x:r,y:i}=o.point),s=s.withMutations(h=>{let f,p,d;({a:f,b:p,c:d}=gc(i)),xc(h,f,p,d,10,3,null),{a:f,b:p,c:d}=_c(r),xc(h,f,p,d,10,3,null)}));let a=e.get("drawingSupport").set("layerID",t);e=it.unselectAll(e,t).updatedState;let{updatedState:l,line:c}=kr.create(e,t,a.get("type"),r,i,r,i);return e=kr.select(l,t,c.id).updatedState,e=e.merge({mode:Jn,snapElements:s,activeSnapElement:o?o.snap:null,drawingSupport:a}),{updatedState:e}}static updateDrawingLine(e,t,r){let i=null;e.snapMask&&!e.snapMask.isEmpty()&&(i=mi(e.snapElements,t,r,e.snapMask),i&&({x:t,y:r}=i.point));let s=e.getIn(["drawingSupport","layerID"]),o=e.getIn(["scene","layers",s,"selected","lines"]).first(),{updatedState:a}=kr.replaceVertex(e,s,o,1,t,r);return e=a,e=this.select(e,s,o).updatedState,e=e.merge({activeSnapElement:i?i.snap:null}),{updatedState:e}}static endDrawingLine(e,t,r){if(e.snapMask&&!e.snapMask.isEmpty()){let c=mi(e.snapElements,t,r,e.snapMask);c&&({x:t,y:r}=c.point)}const i=e.getIn(["drawingSupport","layerID"]),s=e.getIn(["scene","layers",i]),o=e.getIn(["scene","layers",i,"selected","lines"]).first(),a=e.getIn(["scene","layers",i,"lines",o]),l=s.vertices.get(a.vertices.get(0));return e=kr.remove(e,i,o).updatedState,e=kr.createAvoidingIntersections(e,i,a.type,l.x,l.y,t,r).updatedState,e=it.detectAndUpdateAreas(e,i).updatedState,e=e.merge({mode:Ar,snapElements:He(),activeSnapElement:null}),{updatedState:e}}static beginDraggingLine(e,t,r,i,s){let o=bf(e.scene,He(),e.snapMask),a=e.scene.layers.get(t),l=a.lines.get(r),c=a.vertices.get(l.vertices.get(0)),h=a.vertices.get(l.vertices.get(1));return e=e.merge({mode:Vr,snapElements:o,draggingSupport:Ie({layerID:t,lineID:r,startPointX:i,startPointY:s,startVertex0X:c.x,startVertex0Y:c.y,startVertex1X:h.x,startVertex1Y:h.y})}),{updatedState:e}}static updateDraggingLine(e,t,r){let i=e.draggingSupport,s=e.snapElements,o=i.get("layerID"),a=i.get("lineID"),l=t-i.get("startPointX"),c=r-i.get("startPointY"),h=i.get("startVertex0X")+l,f=i.get("startVertex0Y")+c,p=i.get("startVertex1X")+l,d=i.get("startVertex1Y")+c,m=null,x=null,v=null;e.snapMask&&!e.snapMask.isEmpty()&&(x=mi(s,h,f,e.snapMask),v=mi(s,p,d,e.snapMask));let _=0,w=0;return x&&v?x.point.distance<v.point.distance?(_=x.point.x-h,w=x.point.y-f,m=x.snap):(_=v.point.x-p,w=v.point.y-d,m=v.snap):(x&&(_=x.point.x-h,w=x.point.y-f,m=x.snap),v&&(_=v.point.x-p,w=v.point.y-d,m=v.snap)),h+=_,f+=w,p+=_,d+=w,e=e.merge({activeSnapElement:m,scene:e.scene.updateIn(["layers",o],E=>E.withMutations(S=>{let b=S.getIn(["lines",a,"vertices"]);return S.updateIn(["vertices",b.get(0)],A=>A.merge({x:h,y:f})),S.updateIn(["vertices",b.get(1)],A=>A.merge({x:p,y:d})),S}))}),{updatedState:e}}static endDraggingLine(e,t,r){let{draggingSupport:i}=e,s=i.get("layerID"),o=e.scene.layers.get(s),a=i.get("lineID"),l=o.lines.get(a),c=o.vertices.get(l.vertices.get(0)),h=o.vertices.get(l.vertices.get(1)),f=ff(c,h),p=pc(c,h),d=mc(p,f),m=Math.atan2(f.y-p.y,f.x-p.x),x=[];o.lines.get(a).holes.forEach(q=>{let O=o.holes.get(q),T=d*O.offset,I={x:T*Math.cos(m)+p.x,y:T*Math.sin(m)+p.y};x.push({hole:O,offsetPosition:I})});let v=t-i.get("startPointX"),_=r-i.get("startPointY"),w=i.get("startVertex0X")+v,E=i.get("startVertex0Y")+_,S=i.get("startVertex1X")+v,b=i.get("startVertex1Y")+_;if(e.snapMask&&!e.snapMask.isEmpty()){let q=mi(e.snapElements,w,E,e.snapMask),O=mi(e.snapElements,S,b,e.snapMask),T=0,I=0;q&&O?q.point.distance<O.point.distance?(T=q.point.x-w,I=q.point.y-E):(T=O.point.x-S,I=O.point.y-b):(q&&(T=q.point.x-w,I=q.point.y-E),O&&(T=O.point.x-S,I=O.point.y-b)),w+=T,E+=I,S+=T,b+=I}let A=e.getIn(["scene","groups"]).filter(q=>{const O=q.getIn(["elements",s,"lines"]);return O&&O.contains(a)});if(e=it.mergeEqualsVertices(e,s,l.vertices.get(0)).updatedState,e=it.mergeEqualsVertices(e,s,l.vertices.get(1)).updatedState,e=kr.remove(e,s,a).updatedState,!jr({x:w,y:E},{x:S,y:b})){let q=kr.createAvoidingIntersections(e,s,l.type,w,E,S,b,l.properties,x);e=q.updatedState,q.lines.forEach(O=>{A.forEach(T=>{e=mn.addElement(e,T.id,s,"lines",O.id).updatedState})})}return e=it.detectAndUpdateAreas(e,s).updatedState,e=e.merge({mode:sn,draggingSupport:null,activeSnapElement:null,snapElements:He()}),{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"lines",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"lines",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"lines",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e,t,r,i){let s=i.toJS(),{vertexOne:o,vertexTwo:a,lineLength:l}=s;return delete s.vertexOne,delete s.vertexTwo,delete s.lineLength,e=e.mergeIn(["scene","layers",t,"lines",r],At(s)).mergeIn(["scene","layers",t,"vertices",o.id],{x:o.x,y:o.y}).mergeIn(["scene","layers",t,"vertices",a.id],{x:a.x,y:a.y}).mergeIn(["scene","layers",t,"lines",r,"misc"],Ie({_unitLength:l._unit})),e=it.mergeEqualsVertices(e,t,o.id).updatedState,o.x!=a.x&&o.y!=a.y&&(e=it.mergeEqualsVertices(e,t,a.id).updatedState),e=it.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static setVerticesCoords(e,t,r,i,s,o,a){let l=e.getIn(["scene","layers",t,"lines",r]);return e=cn.setAttributes(e,t,l.vertices.get(0),Ie({x:i,y:s})).updatedState,e=cn.setAttributes(e,t,l.vertices.get(1),Ie({x:o,y:a})).updatedState,{updatedState:e}}},cn=class{static add(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"vertices"]).find(l=>jr(l,{x:r,y:i}));return a?a=a.update(s,l=>l.push(o)):a=new ig({id:gi.acquireID(),name:"Vertex",x:r,y:i,[s]:He([o])}),e=e.setIn(["scene","layers",t,"vertices",a.id],a),{updatedState:e,vertex:a}}static setAttributes(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"vertices",r],i),{updatedState:e}}static addElement(e,t,r,i,s){return e=e.updateIn(["scene","layers",t,"vertices",r,i],o=>o.push(s)),{updatedState:e}}static removeElement(e,t,r,i,s){let o=e.getIn(["scene","layers",t,"vertices",r,i]).findIndex(a=>a===s);return o!==-1&&(e=e.updateIn(["scene","layers",t,"vertices",r,i],a=>a.remove(o))),{updatedState:e}}static select(e,t,r){return e=e.setIn(["scene","layers",t,"vertices",r,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected","vertices"],i=>i.push(r)),{updatedState:e}}static unselect(e,t,r){return e=e.setIn(["scene","layers",t,"vertices",r,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected","vertices"],i=>i.filter(s=>s.id!==r)),{updatedState:e}}static remove(e,t,r,i,s,o){let a=e.getIn(["scene","layers",t,"vertices",r]);return a&&(i&&s&&(a=a.update(i,c=>{let h=c.findIndex(f=>s===f);return c.delete(h)})),(a.areas.size||a.lines.size)&&!o?e=e.setIn(["scene","layers",t,"vertices",r],a):e=e.deleteIn(["scene","layers",t,"vertices",r])),{updatedState:e}}static beginDraggingVertex(e,t,r){let i=bf(e.scene,He(),e.snapMask);return e=e.merge({mode:Hr,snapElements:i,draggingSupport:Ie({layerID:t,vertexID:r,previousMode:e.get("mode")})}),{updatedState:e}}static updateDraggingVertex(e,t,r){let{draggingSupport:i,snapElements:s,scene:o}=e,a=null;e.snapMask&&!e.snapMask.isEmpty()&&(a=mi(s,t,r,e.snapMask),a&&({x:t,y:r}=a.point));let l=i.get("layerID"),c=i.get("vertexID");return e=e.merge({activeSnapElement:a?a.snap:null,scene:o.mergeIn(["layers",l,"vertices",c],{x:t,y:r})}),{updatedState:e}}static endDraggingVertex(e){let{draggingSupport:t}=e,r=t.get("layerID"),i=t.get("vertexID"),s=e.getIn(["scene","layers",r,"vertices",i,"lines"]);return s&&(e=s.reduce((o,a)=>{if(!o.getIn(["scene","layers",r,"lines",a]))return o;let l=o.getIn(["scene","layers",r,"lines",a,"vertices",0]),c=o.getIn(["scene","layers",r,"lines",a,"vertices",1]),h=l===i?c:l,f=o.getIn(["scene","layers",r,"vertices",h]),p=o.getIn(["scene","layers",r,"vertices",i]),d=[],m=rl([f,p]);o.getIn(["scene","layers",r,"lines",a,"holes"]).forEach(w=>{let E=o.getIn(["scene","layers",r,"holes",w]),S=Cn(f.x,f.y,p.x,p.y),b=jr(m[1],o.getIn(["scene","layers",r,"lines",a,"vertices",1]))?1-E.offset:E.offset,A=vc(f.x,f.y,p.x,p.y,S*b);d.push({hole:E,offsetPosition:A})});let x=o.getIn(["scene","layers",r,"lines",a,"type"]),v=o.getIn(["scene","layers",r,"lines",a,"properties"]),_=o.getIn(["scene","groups"]).filter(w=>{const E=w.getIn(["elements",r,"lines"]);return E&&E.contains(a)});if(o=it.removeZeroLengthLines(o,r).updatedState,o=it.mergeEqualsVertices(o,r,i).updatedState,o=Jt.remove(o,r,a).updatedState,!jr(f,p)){let w=Jt.createAvoidingIntersections(o,r,x,f.x,f.y,p.x,p.y,v,d);o=w.updatedState,w.lines.forEach(E=>{_.forEach(S=>{o=mn.addElement(o,S.id,r,"lines",E.id).updatedState})})}return o},e)),e=it.detectAndUpdateAreas(e,r).updatedState,e=e.merge({mode:t.get("previousMode"),draggingSupport:null,activeSnapElement:null,snapElements:He()}),{updatedState:e}}},Fs=class H2{static getSurfaceLines(e,t,r){const i=e.getIn(["scene","layers",t,"areas",r]),s=e.getIn(["scene","layers",t,"lines"]),o=e.getIn(["scene","layers",t,"vertices"]);let a=Eo();return i.get("vertices").forEach(l=>{o.get(l).get("lines").forEach(h=>{s.get(h).get("type")==="surface"&&(a=a.add(h))})}),a}static add(e,t,r,i,s){let o,a=e.getIn(["scene","layers",t]);return a=a.withMutations(l=>{const c=gi.acquireID(),h=i.map(f=>cn.add(e,t,f.x,f.y,"areas",c).vertex.id);o=s.factoryElement(r,{id:c,name:wc.generateName("areas",s.getIn(["elements",r,"info","title"])),type:r,prototype:"areas",vertices:h}),l.setIn(["areas",c],o)}),e=e.setIn(["scene","layers",t],a),{updatedState:e,area:o}}static select(e,t,r){let i=H2.getSurfaceLines(e,t,r);return e=it.select(e,t).updatedState,e=it.selectElement(e,t,"areas",r).updatedState,i.size>0&&i.forEach(s=>{e=Jt.select(e,t,s,!0).updatedState}),{updatedState:e}}static remove(e,t,r){let i=e.getIn(["scene","layers",t,"areas",r]);return i.get("selected")===!0&&(e=this.unselect(e,t,r).updatedState),i.vertices.forEach(s=>{e=cn.remove(e,t,s,"areas",r).updatedState}),e=e.deleteIn(["scene","layers",t,"areas",r]),e.getIn(["scene","groups"]).forEach(s=>e=mn.removeElement(e,s.id,t,"areas",r).updatedState),{updatedState:e}}static unselect(e,t,r){return e=it.unselect(e,t,"areas",r).updatedState,{updatedState:e}}static setProperties(e,t,r,i){return e=e.mergeIn(["scene","layers",t,"areas",r,"properties"],i),{updatedState:e}}static setJsProperties(e,t,r,i){return this.setProperties(e,t,r,At(i))}static updateProperties(e,t,r,i){return i.forEach((s,o)=>{e.hasIn(["scene","layers",t,"areas",r,"properties",o])&&(e=e.mergeIn(["scene","layers",t,"areas",r,"properties",o],s))}),{updatedState:e}}static updateJsProperties(e,t,r,i){return this.updateProperties(e,t,r,At(i))}static setAttributes(e){return{updatedState:e}}};const Dg=(n,e)=>n.size===e.size&&n.isSuperset(e)&&n.isSubset(e);let it=class{static create(e,t,r){let i=gi.acquireID();t=t||`layer ${i}`,r=r||0;let s=new yf({id:i,name:t,altitude:r});return e=e.setIn(["scene","selectedLayer"],i),e=e.setIn(["scene","layers",i],s),{updatedState:e}}static select(e,t){return e.get("alterate")||(e=qt.unselectAll(e).updatedState),e=e.setIn(["scene","selectedLayer"],t),{updatedState:e}}static selectElement(e,t,r,i){return e=e.setIn(["scene","layers",t,r,i,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected",r],s=>s.push(i)),{updatedState:e}}static unselect(e,t,r,i){return e=e.setIn(["scene","layers",t,r,i,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected",r],s=>s.filter(o=>o.id===i)),{updatedState:e}}static unselectAll(e,t){let{lines:r,holes:i,items:s,areas:o}=e.getIn(["scene","layers",t]);return r&&r.forEach(a=>{e=Jt.unselect(e,t,a.id).updatedState}),i&&i.forEach(a=>{e=pn.unselect(e,t,a.id).updatedState}),s&&s.forEach(a=>{e=xn.unselect(e,t,a.id).updatedState}),o&&o.forEach(a=>{e=Fs.unselect(e,t,a.id).updatedState}),{updatedState:e}}static setProperties(e,t,r){return e=e.mergeIn(["scene","layers",t],r),e=e.updateIn(["scene","layers"],i=>i.sort((s,o)=>s.altitude!==o.altitude?s.altitude-o.altitude:s.order-o.order)),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","layers",t]),e=e.setIn(["scene","selectedLayer"],e.scene.selectedLayer!==t?e.scene.selectedLayer:e.scene.layers.first().id),{updatedState:e}}static removeElement(e,t,r,i){return e=e.deleteIn(["scene","layers",t,r,i]),{updatedState:e}}static detectAndUpdateAreas(e,t){let r=[],i,s={},o={};e.getIn(["scene","layers",t,"vertices"]).forEach(d=>{let x=r.push([d.x,d.y])-1;s[d.id]=x,o[x]=d.id}),i=e.getIn(["scene","layers",t,"lines"]).map(d=>d.vertices.map(m=>s[m]).toArray());const a=R3(r,i);let l=He(a).map(d=>He(d.map(m=>o[m])));l=l.map(d=>P3(d.map(m=>e.getIn(["scene","layers",t,"vertices",m])))?d.reverse():d);const c=[];e.getIn(["scene","layers",t,"areas"]).forEach(d=>{l.some(x=>Dg(x,d.vertices))||(e=Fs.remove(e,t,d.id).updatedState)}),l.forEach((d,m)=>{const x=e.getIn(["scene","layers",t,"areas"]).find(v=>Dg(v.vertices,d));if(x)c[m]=x.id,e=e.setIn(["scene","layers",t,"areas",c[m],"holes"],He());else{const v=d.map(w=>e.getIn(["scene","layers",t,"vertices",w])),_=Fs.add(e,t,"area",v,e.catalog);c[m]=_.area.id,e=_.updatedState}});let h=c.map(d=>{let m=e.getIn(["scene","layers",t,"areas",d]).vertices.map(x=>{let{x:v,y:_}=e.getIn(["scene","layers",t,"vertices",x]);return He([v,_])});return{id:d,vertices:m}}),f,p;for(f=0;f<h.length;f++){let d=He(),m=h[f].vertices.flatten().toArray();for(p=0;p<h.length;p++)f!==p&&s3(m,h[p].vertices.get(0).get(0),h[p].vertices.get(0).get(1))&&(d=d.push(h[p].id));e=e.setIn(["scene","layers",t,"areas",h[f].id,"holes"],d)}return c.forEach(d=>{let m=new Set,x=e.getIn(["scene","layers",t,"areas",d,"holes"]);x.forEach(v=>{e.getIn(["scene","layers",t,"areas",v,"holes"]).forEach(w=>{x.indexOf(w)!==-1&&m.add(w)})}),m.forEach(v=>{x=x.remove(x.indexOf(v))}),e=e.setIn(["scene","layers",t,"areas",d,"holes"],x)}),{updatedState:e}}static removeZeroLengthLines(e,t){return{updatedState:e.getIn(["scene","layers",t,"lines"]).reduce((i,s)=>{let o=s.getIn(["vertices",0]),a=s.getIn(["vertices",1]),l=i.getIn(["scene","layers",t,"vertices",o]),c=i.getIn(["scene","layers",t,"vertices",a]);return mc(l,c)===0&&(i=Jt.remove(i,t,s.id).updatedState),i},e)}}static mergeEqualsVertices(e,t,r){let i=e.getIn(["scene","layers",t,"vertices",r]),s=e.getIn(["scene","layers",t,"vertices"]).filter(o=>o.id!==r&&jr(i,o));return s.isEmpty()?{updatedState:e}:(s.forEach(o=>{let a=o.lines.reduce((c,h)=>(c=c.updateIn(["scene","layers",t,"lines",h,"vertices"],f=>{if(f)return f.map(p=>p===o.id?r:p)}),c=cn.addElement(c,t,r,"lines",h).updatedState,c),e),l=o.areas.reduce((c,h)=>(c=c.updateIn(["scene","layers",t,"areas",h,"vertices"],f=>{if(f)return f.map(p=>p===o.id?r:p)}),c=cn.addElement(c,t,r,"areas",h).updatedState,c),a);e=cn.remove(l,t,o.id,null,null,!0).updatedState}),{updatedState:e})}static setPropertiesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.setProperties(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.setProperties(e,t,s,r).updatedState),i.areas.forEach(s=>e=Fs.setProperties(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.setProperties(e,t,s,r).updatedState),{updatedState:e}}static updatePropertiesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.updateProperties(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.updateProperties(e,t,s,r).updatedState),i.areas.forEach(s=>e=Fs.updateProperties(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.updateProperties(e,t,s,r).updatedState),{updatedState:e}}static setAttributesOnSelected(e,t,r){let i=e.getIn(["scene","layers",t,"selected"]);return i.lines.forEach(s=>e=Jt.setAttributes(e,t,s,r).updatedState),i.holes.forEach(s=>e=pn.setAttributes(e,t,s,r).updatedState),i.items.forEach(s=>e=xn.setAttributes(e,t,s,r).updatedState),{updatedState:e}}};class Tc{static create(e,t){let r=gi.acquireID();return e=e.setIn(["scene","guides","horizontal",r],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","horizontal",t]),{updatedState:e}}}class Ac{static create(e,t){let r=gi.acquireID();return e=e.setIn(["scene","guides","vertical",r],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","vertical",t]),{updatedState:e}}}class qt{static setAlterate(e){return{updatedState:e.set("alterate",!e.alterate)}}static openCatalog(e){return e=this.setMode(e,cf).updatedState,{updatedState:e}}static newProject(e){return e=new Sc({viewer2D:e.get("viewer2D")}),{updatedState:e}}static loadProject(e,t){return e=new Sc({scene:t,catalog:e.catalog.toJS()}),{updatedState:e}}static setProperties(e,t,r){return e=it.setPropertiesOnSelected(e,t,r).updatedState,{updatedState:e}}static updateProperties(e,t,r){return e=it.updatePropertiesOnSelected(e,t,r).updatedState,{updatedState:e}}static setItemsAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static setLinesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static setHolesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(r=>{e=it.setAttributesOnSelected(e,r.id,t).updatedState}),{updatedState:e}}static unselectAll(e){return e.getIn(["scene","layers"]).forEach(({id:t})=>{e=it.unselectAll(e,t).updatedState}),e.getIn(["scene","groups"]).forEach(t=>{e=mn.unselect(e,t.get("id")).updatedState}),{updatedState:e}}static remove(e){let t=e.getIn(["scene","selectedLayer"]),{lines:r,holes:i,items:s}=e.getIn(["scene","layers",t,"selected"]);return e=it.unselectAll(e,t).updatedState,r.forEach(o=>{e=Jt.remove(e,t,o).updatedState}),i.forEach(o=>{e=pn.remove(e,t,o).updatedState}),s.forEach(o=>{e=xn.remove(e,t,o).updatedState}),e=it.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static undo(e){let t=e.sceneHistory;return e.scene===t.last&&t.list.size>1&&(t=bg(t)),e=e.merge({mode:sn,scene:t.last,sceneHistory:bg(t)}),{updatedState:e}}static redo(e){let t=e.sceneHistory;return e.scene===t.last&&t.redoList.size>0&&(t=V3(t)),e=e.merge({mode:sn,scene:t.last,sceneHistory:t}),{updatedState:e}}static rollback(e){let t=e.sceneHistory;return!t.last&&t.list.isEmpty()?{updatedState:e}:(e=this.unselectAll(e).updatedState,e=e.merge({mode:sn,scene:t.last,sceneHistory:on(t,t.last),snapElements:He(),activeSnapElement:null,drawingSupport:Ie(),draggingSupport:Ie(),rotatingSupport:Ie()}),{updatedState:e})}static setProjectProperties(e,t){let r=e.scene.merge(t);return e=e.merge({mode:sn,scene:r}),{updatedState:e}}static openProjectConfigurator(e){return e=e.merge({mode:Z0}),{updatedState:e}}static initCatalog(e,t){return e=e.set("catalog",new Ef(t)),{updatedState:e}}static updateMouseCoord(e,t){return e=e.set("mouse",Ie(t)),{updatedState:e}}static updateZoomScale(e,t){return e=e.set("zoom",t),{updatedState:e}}static toggleSnap(e,t){return e=e.set("snapMask",t),{updatedState:e}}static throwError(e,t){return e=e.set("errors",e.get("errors").push({date:Date.now(),error:t})),{updatedState:e}}static throwWarning(e,t){return e=e.set("warnings",e.get("warnings").push({date:Date.now(),warning:t})),{updatedState:e}}static copyProperties(e,t){return e=e.set("clipboardProperties",t),{updatedState:e}}static pasteProperties(e){return e=this.updateProperties(e,e.getIn(["scene","selectedLayer"]),e.get("clipboardProperties")).updatedState,{updatedState:e}}static pushLastSelectedCatalogElementToHistory(e,t){let r=e.selectedElementsHistory,i=r.findIndex(s=>s.name===t.name);return i!==-1&&(r=r.splice(i,1)),r=r.splice(0,0,t),e=e.set("selectedElementsHistory",r),{updatedState:e}}static changeCatalogPage(e,t,r){return e=e.setIn(["catalog","page"],r).updateIn(["catalog","path"],i=>i.push(t)),{updatedState:e}}static goBackToCatalogPage(e,t){let r=e.catalog.path.findIndex(i=>i===t);return e=e.setIn(["catalog","page"],t).updateIn(["catalog","path"],i=>i.take(r)),{updatedState:e}}static setMode(e,t){return e=e.set("mode",t),{updatedState:e}}static addHorizontalGuide(e,t){return e=Tc.create(e,t).updatedState,{updatedState:e}}static addVerticalGuide(e,t){return e=Ac.create(e,t).updatedState,{updatedState:e}}static addCircularGuide(e,t,r,i){return console.log("adding horizontal guide at",t,r,i),{updatedState:e}}static removeHorizontalGuide(e,t){return e=Tc.remove(e,t).updatedState,{updatedState:e}}static removeVerticalGuide(e,t){return e=Ac.remove(e,t).updatedState,{updatedState:e}}static removeCircularGuide(e,t){return console.log("removeing horizontal guide ",t),{updatedState:e}}}class Cc{static selectToolDrawingSurface(e,t){return e=e.merge({mode:Us,drawingSupport:Ie({type:t})}),{updatedState:e}}static beginDrawingSurface(e,t,r,i){let s=e.getIn(["drawingSupport","points"]);s&&s.size?s.push({x:r,y:i}):s=He([{x:r,y:i}]);let o=e.get("drawingSupport").merge({layerID:t,points:s});e=it.unselectAll(e,t).updatedState;let{updatedState:a,line:l}=Jt.create(e,t,o.get("type"),r,i,r,i);return e=Jt.select(a,t,l.id).updatedState,e=e.merge({mode:di,drawingSupport:o}),{updatedState:e}}static updateDrawingSurface(e,t,r){let i=Jt.updateDrawingLine(e,t,r).updatedState;const s=i.getIn(["drawingSupport","layerID"]),o=i.getIn(["drawingSupport","closingLineID"]);return o&&(i=Jt.replaceVertex(i,s,o,0,t,r).updatedState,i=it.detectAndUpdateAreas(i,s).updatedState),{updatedState:i}}static endDrawingSurface(e,t,r){const i=e.getIn(["drawingSupport","layerID"]),s=e.getIn(["drawingSupport","type"]),o=e.getIn(["drawingSupport","points"]);let{updatedState:a}=Jt.endDrawingLine(e,t,r),l=o.push({x:t,y:r});if(l.size===2){const c=l.first();let{updatedState:h,line:f}=Jt.create(a,i,s,c.x,c.y,c.x,c.y),p=e.get("drawingSupport").merge({points:l,closingLineID:f.id});return h=h.merge({drawingSupport:p}),{updatedState:h}}return{updatedState:a}}}var Rc={exports:{}},Pc={exports:{}},Pt={};/** @license React v16.13.1
46
46
  * react-is.production.min.js
47
47
  *
48
48
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -66,12 +66,12 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var le=Pe(Z,ee,Ee,V,re+"
66
66
  `+l+` |
67
67
  `+s.line+" | "+c+`
68
68
  `+l+" | "+$f("",i.column-1," ")+$f("",f,"^")}else e+=`
69
- at `+o}return e},Ic.buildMessage=function(n,e){var t={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var h=c.parts.map(function(f){return Array.isArray(f)?s(f[0])+"-"+s(f[1]):s(f)});return"["+(c.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function s(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function o(c){return t[c.type](c)}function a(c){var h=c.map(o),f,p;if(h.sort(),h.length>0){for(f=1,p=1;f<h.length;f++)h[f-1]!==h[f]&&(h[p]=h[f],p++);h.length=p}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(n)+" but "+l(e)+" found."};const dr="idle",Xr="panning",$r="zooming",Pr="auto",_i="none",Ir="pan",Yr="zoom-in",vi="zoom-out",Lc="none",xi="top",pr="right",yi="bottom",Hn="left",Oc="zoom",al="pan",Po="center",Io="left",Yf="right",Lo="top",Kf="bottom",Jg="cover";function Qg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function qc(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qg(Object(t),!0).forEach(function(r){fS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Qg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function fS(n,e,t){return(e=dS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function dS(n){var e=pS(n,"string");return typeof e=="symbol"?e:e+""}function pS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}const e1=3,t1=dr;function n1(n,e,t,r,i,s){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,a=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return Xt({},qc(qc({},Kg()),{},{version:e1,mode:t1,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:n,viewerHeight:e,SVGMinX:t,SVGMinY:r,SVGWidth:i,SVGHeight:s,scaleFactorMin:o,scaleFactorMax:a,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function Xt(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return n=Object.assign({},n,e,{lastAction:t}),Object.freeze(n)}function mS(n){return n!==null&&typeof n=="object"&&n.hasOwnProperty("version")&&n.version===e1}function Lr(n,e,t){let r=ol(n),i=Zg(r);return $g(i,{x:e,y:t})}function Dc(n){let e=ol(n);return{scaleFactor:e.a,translationX:e.e,translationY:e.f}}function gS(n,e){return Xt(n,{focus:e})}function _S(n,e,t){return Xt(n,{viewerWidth:e,viewerHeight:t})}function r1(n,e,t,r,i){return Xt(n,{SVGMinX:e,SVGMinY:t,SVGWidth:r,SVGHeight:i})}function vS(n,e,t){return Xt(n,{scaleFactorMin:e,scaleFactorMax:t})}function xS(n,e,t,r){let{viewerWidth:i,viewerHeight:s}=n,o=Ui(fr(-e+i/2,-t+s/2),fr(e,t),zs(r,r),fr(-e,-t));return Xt(n,qc({mode:dr},o))}function yS(n){return Xt(n,qc({mode:dr},Kg()))}function i1(n){return Xt(n,{mode:t1,startX:null,startY:null,endX:null,endY:null})}class s1{constructor(e,t,r){this.originalEvent=e,this.value=t,this.SVGViewer=r}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function o1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function SS(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?o1(Object(t),!0).forEach(function(r){ES(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):o1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function ES(n,e,t){return(e=bS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function bS(n){var e=MS(n,"string");return typeof e=="symbol"?e:e+""}function MS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Zf(n,e,t){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,i=Ui(ol(n),fr(e,t));if(r){let[{x:s,y:o},{x:a,y:l}]=Yg(i,[{x:n.SVGMinX+r,y:n.SVGMinY+r},{x:n.SVGMinX+n.SVGWidth-r,y:n.SVGMinY+n.SVGHeight-r}]),c=0;n.viewerWidth-s<0?c=n.viewerWidth-s:a<0&&(c=-a);let h=0;n.viewerHeight-o<0?h=n.viewerHeight-o:l<0&&(h=-l),i=Ui(fr(c,h),i)}return Xt(n,SS({mode:dr},i),al)}function wS(n,e,t){return Xt(n,{mode:Xr,startX:e,startY:t,endX:e,endY:t},al)}function TS(n,e,t,r){if(n.mode!==Xr)throw new Error("update pan not allowed in this mode "+n.mode);let{endX:i,endY:s}=n,o=Lr(n,i,s),a=Lr(n,e,t),l=a.x-o.x,c=a.y-o.y,h=Zf(n,l,c,r);return Xt(h,{mode:Xr,endX:e,endY:t},al)}function a1(n){return Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null},al)}function AS(n,e,t){let r=0,i=0;return t<=20&&(i=2),n.viewerWidth-e<=20&&(r=-2),n.viewerHeight-t<=20&&(i=-2),e<=20&&(r=2),r=r/n.d,i=i/n.d,r===0&&i===0?n:Zf(n,r,i)}function l1(n,e){if(n.x<=e.x&&n.y<=e.y)return{x:n.x,y:n.y,width:e.x-n.x,height:e.y-n.y};if(n.x>=e.x&&n.y<=e.y)return{x:e.x,y:n.y,width:n.x-e.x,height:e.y-n.y};if(n.x>=e.x&&n.y>=e.y)return{x:e.x,y:e.y,width:n.x-e.x,height:n.y-e.y};if(n.x<=e.x&&n.y>=e.y)return{x:n.x,y:e.y,width:e.x-n.x,height:n.y-e.y}}function c1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Oo(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?c1(Object(t),!0).forEach(function(r){CS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):c1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function CS(n,e,t){return(e=RS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function RS(n){var e=PS(n,"string");return typeof e=="symbol"?e:e+""}function PS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Nc(n,e){const{scaleFactor:t}=Dc(n),r=n.scaleFactorMin&&t*e<n.scaleFactorMin,i=n.scaleFactorMax&&t*e>n.scaleFactorMax;return r&&e<1||i&&e>1}function Jf(n,e){let t=e.a;return n.scaleFactorMin!=null&&(t=Math.max(t,n.scaleFactorMin)),n.scaleFactorMax!=null&&(t=Math.min(t,n.scaleFactorMax)),Xt(e,{a:t,d:t})}function qo(n,e,t,r){if(Nc(n,r))return n;const i=Ui(ol(n),fr(e,t),zs(r,r),fr(-e,-t));return Xt(n,Oo(Oo({mode:dr},i),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function u1(n,e,t,r,i){let{viewerWidth:s,viewerHeight:o}=n,a=s/r,l=o/i,c=Math.min(a,l);const h=Ui(zs(c,c),fr(-e,-t));return Nc(n,c/n.d)?Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null}):Xt(n,Oo(Oo({mode:dr},Jf(n,h)),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function h1(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Io,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Lo,{viewerWidth:r,viewerHeight:i,SVGMinX:s,SVGMinY:o,SVGWidth:a,SVGHeight:l}=n,c=r/a,h=i/l,f=Math.min(c,h),p=zs(f,f),d=-s*c,m=-o*h;if(c<h){let _=i-c*l;switch(t){case Lo:m=-o*f;break;case Po:m=Math.round(_/2)-o*f;break;case Kf:m=_-o*f;break;case Jg:p=zs(h,h);let w=r-h*a;d=s+Math.round(w/2);break}}else{let _=r-h*a;switch(e){case Io:d=-s*f;break;case Po:d=Math.round(_/2)-s*f;break;case Yf:d=_-s*f;break;case Jg:p=zs(c,c);let w=i-c*l;m=o+Math.round(w/2);break}}const x=fr(d,m),v=Ui(x,p);return Nc(n,f/n.d)?Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null}):Xt(n,Oo(Oo({mode:dr},Jf(n,v)),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function IS(n,e){let{viewerWidth:t,viewerHeight:r}=n,i=Lr(n,t/2,r/2);return qo(n,i.x,i.y,e)}function LS(n,e,t){return Xt(n,{mode:$r,startX:e,startY:t,endX:e,endY:t})}function OS(n,e,t){if(n.mode!==$r)throw new Error("update selection not allowed in this mode "+n.mode);return Xt(n,{endX:e,endY:t})}function Qf(n,e,t,r){let{startX:s,startY:o}=n,a=Lr(n,s,o),l=Lr(n,e,t);if(Math.abs(s-e)>7&&Math.abs(o-t)>7){let c=l1(a,l);return u1(n,c.x,c.y,c.width,c.height)}else{let c=Lr(n,e,t);return qo(n,c.x,c.y,r)}}function qS(n,e,t,r,i){return r+(i-r)*(n-e)/(t-e)}function Do(n,e){let{left:t,top:r}=e.getBoundingClientRect(),i=n.clientX-Math.round(t),s=n.clientY-Math.round(r);return{x:i,y:s}}function f1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;switch(t){case vi:let c=Lr(r,o,a);l=qo(r,c.x,c.y,1/i.scaleFactor);break;case Yr:l=LS(r,o,a);break;case Pr:case Ir:l=wS(r,o,a);break;default:return r}return n.preventDefault(),l}function d1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=n.buttons===0,c=r;switch(t){case Yr:r.mode===$r&&(c=l?Qf(r,o,a,i.scaleFactor):OS(r,o,a));break;case Pr:case Ir:r.mode===Xr&&(c=l?a1(r):TS(r,o,a,i.preventPanOutside?20:void 0));break;default:return r}return n.preventDefault(),c}function p1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;switch(t){case vi:r.mode===$r&&(l=Qf(r,o,a,1/i.scaleFactor));break;case Yr:r.mode===$r&&(l=Qf(r,o,a,i.scaleFactor));break;case Pr:case Ir:r.mode===Xr&&(l=a1(r));break;default:return r}return n.preventDefault(),l}function DS(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;if(t===Pr&&!i.disableDoubleClickZoomWithToolAuto){const{modifierKeys:c=[]}=i;let h=Lr(r,o,a),f=(m,x)=>m||n.getModifierState(x),d=c.reduce(f,!1)?1/i.scaleFactor:i.scaleFactor;l=qo(r,h.x,h.y,d)}return n.preventDefault(),l}function NS(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);if(!i.detectWheel)return r;let l=Math.max(-1,Math.min(1,n.deltaY)),c=qS(l,-1,1,i.scaleFactorOnWheel,1/i.scaleFactorOnWheel),h=Lr(r,o,a),f=qo(r,h.x,h.y,c);return n.preventDefault(),f}function m1(n,e,t,r,i){let s=gS(r,n.type==="mouseenter");return n.preventDefault(),s}function US(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:o,y:a}=s;return!([_i,Pr].indexOf(t)>=0)||!i.detectAutoPan||!r.focus?r:AS(r,o,a)}class FS extends s1{get point(){if(!this._cachePoint){const{originalEvent:e,SVGViewer:t,value:r}=this,i=Do(e,t);this._cachePoint=Lr(r,i.x,i.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function g1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function _1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?g1(Object(t),!0).forEach(function(r){zS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):g1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function zS(n,e,t){return(e=kS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function kS(n){var e=BS(n,"string");return typeof e=="symbol"?e:e+""}function BS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Uc extends s1{get points(){return this._cachePoints||(this._cachePoints=Uc.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=Uc.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(e,t,r){let i=[];for(let s=0;s<e.length;s++){let o=e[s],a=t.getBoundingClientRect(),l=o.clientX-Math.round(a.left),c=o.clientY-Math.round(a.top),h=Lr(r,l,c);i.push(_1(_1({},h),{},{identifier:o.identifier}))}return i}}function VS(n,e,t){let r=n.type;switch(r){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new FS(n,e,t);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new Uc(n,e,t);default:throw new Error(`${r} not supported`)}}function v1(n){return n.split(/[ ,]/).filter(Boolean).map(Number)}function x1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function y1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?x1(Object(t),!0).forEach(function(r){HS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):x1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function HS(n,e,t){return(e=GS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function GS(n){var e=WS(n,"string");return typeof e=="symbol"?e:e+""}function WS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function jS(n,e){let{left:t,top:r}=e.getBoundingClientRect(),i=n.clientX-Math.round(t),s=n.clientY-Math.round(r);return{x:i,y:s}}function XS(n,e,t,r,i){if(E1(n,i))return b1(n,e,t,r);if(n.touches.length!==1){if([Xr,$r].indexOf(r.mode)>=0)return i1(r);if([dr].indexOf(r.mode)>=0)return r}return ed(n,e,t,r,i,f1)}function $S(n,e,t,r,i){return E1(n,i)?b1(n,e,t,r):[Xr,$r].indexOf(r.mode)>=0?ed(n,e,t,r,i,d1):r}function YS(n,e,t,r,i){if(!([Xr,$r].indexOf(r.mode)>=0))return r;let s=ZS(n,r,i)?Xt(r,{pinchPointDistance:null}):r;return n.touches.length>0?s:ed(n,e,t,s,i,p1)}function KS(n,e,t,r,i){return n.stopPropagation(),n.preventDefault(),i1(r)}function S1(n){return typeof n.pinchPointDistance=="number"}function ZS(n,e,t){return t.detectPinchGesture&&S1(e)&&n.touches.length<2}function E1(n,e){return e.detectPinchGesture&&n.touches.length>1}function ed(n,e,t,r,i,s){let o=n.touches.length===0?Xt(r,{mode:r.prePinchMode?dr:r.mode,prePinchMode:null}):r,a=n.touches.length>0?n.touches[0]:n.changedTouches[0],l=jS(a,e);switch(t){case vi:case Yr:case Pr:case Ir:return n.stopPropagation(),n.preventDefault(),s(n,e,t,o,i,l);default:return o}}function b1(n,e,t,r,i){const{left:s,top:o}=e.getBoundingClientRect(),a=n.touches[0].clientX-Math.round(s),l=n.touches[0].clientY-Math.round(o),c=n.touches[1].clientX-Math.round(s),h=n.touches[1].clientY-Math.round(o),f=Math.sqrt(Math.pow(c-a,2)+Math.pow(h-l,2)),p=S1(r)?r.pinchPointDistance:f,d=Lr(r,(a+c)/2,(l+h)/2);let m=f/p;if(Nc(r,m))return r;n.cancelable&&n.preventDefault();let x=Ui(ol(r),fr(d.x,d.y),zs(m,m),fr(-d.x,-d.y));return Xt(r,Xt(y1(y1({mode:$r},Jf(r,x)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:r.prePinchMode?r.prePinchMode:r.mode,pinchPointDistance:f})))}function M1(n){return Xt(n,{miniatureOpen:!0})}function w1(n){return Xt(n,{miniatureOpen:!1})}let JS=n=>["zoom-in","zoom-out","grab","grabbing"].indexOf(n)>-1,T1=()=>navigator.userAgent.toLowerCase(),QS=()=>T1().indexOf("firefox")>-1,eE=()=>T1().indexOf("webkit")>-1;function Fc(n){if(!JS(n))return n;if(QS())return`-moz-${n}`;if(eE())return`-webkit-${n}`}function tE(n){return n.displayName||n.name||"Component"}function td(){return td=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},td.apply(null,arguments)}let nE=1;const rE=()=>`uid${nE++}`;function A1(n){class e extends ne.Component{constructor(r){super(r),this.state={uid:rE()}}render(){return ne.createElement(n,td({_uid:this.state.uid},this.props))}}return e.displayName=`RandomUID(${tE(n)})`,e}const C1="react-svg-pan-zoom_border_gradient";function R1(n){let{direction:e,width:t,height:r,_uid:i}=n,s;switch(e){case xi:s=`translate(${t}, 0) rotate(90)`;break;case pr:s=`translate(${t}, ${r}) rotate(180)`;break;case yi:s=`translate(0, ${r}) rotate(270)`;break;case Hn:default:s=" ";break}let o=`${C1}_gradient_${i}`,a=`${C1}_mask_${i}`;return ne.createElement("g",null,ne.createElement("defs",null,ne.createElement("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},ne.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),ne.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),ne.createElement("mask",{id:a,x:"0",y:"0",width:"20",height:Math.max(t,r)},ne.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,r),style:{stroke:"none",fill:`url(#${o})`}}))),ne.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,r),style:{stroke:"none",fill:"#000",mask:`url(#${a})`},transform:s}))}R1.propTypes={direction:ve.oneOf([xi,pr,yi,Hn]).isRequired,width:ve.number.isRequired,height:ve.number.isRequired};const zc=A1(R1);function P1(n){let{startX:e,startY:t,endX:r,endY:i}=n;if(!e||!t||!r||!i)return null;let s=l1({x:e,y:t},{x:r,y:i});return ne.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:s.x,y:s.y,width:s.width,height:s.height,style:{pointerEvents:"none"}})}P1.propTypes={startX:ve.number,startY:ve.number,endX:ve.number,endY:ve.number};function iE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function sE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function oE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("g",null,ne.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),ne.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function aE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function lE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let No=class extends ne.Component{constructor(e){super(e),this.state={hover:!1}}change(e){switch(e.preventDefault(),e.stopPropagation(),e.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let e={display:"block",width:"24px",height:"24px",margin:[xi,yi].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return ne.createElement("button",{onMouseEnter:t=>this.change(t),onMouseLeave:t=>this.change(t),onTouchStart:t=>{this.change(t),this.props.onClick(t)},onTouchEnd:t=>this.change(t),onTouchCancel:t=>this.change(t),onClick:this.props.onClick,style:e,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};No.propTypes={title:ve.string.isRequired,name:ve.string.isRequired,toolbarPosition:ve.string.isRequired,activeColor:ve.string.isRequired,onClick:ve.func.isRequired,active:ve.bool.isRequired};const cE="#1CA6FC";function I1(n){let{tool:e,value:t,onChangeValue:r,onChangeTool:i,activeToolColor:s=cE,position:o=pr,SVGAlignX:a=Io,SVGAlignY:l=Lo}=n,c=(d,m)=>{i(m),d.stopPropagation(),d.preventDefault()},h=d=>{r(h1(t,a,l)),d.stopPropagation(),d.preventDefault()},f=[xi,yi].indexOf(o)>=0,p={position:"absolute",transform:[xi,yi].indexOf(o)>=0?"translate(-50%, 0px)":"none",top:[Hn,pr,xi].indexOf(o)>=0?"5px":"unset",left:[xi,yi].indexOf(o)>=0?"50%":Hn===o?"5px":"unset",right:[pr].indexOf(o)>=0?"5px":"unset",bottom:[yi].indexOf(o)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:f?"row":"column",padding:f?"1px 2px":"2px 1px"};return ne.createElement("div",{style:p,role:"toolbar"},ne.createElement(No,{toolbarPosition:o,active:e===_i,activeColor:s,name:"unselect-tools",title:"Selection",onClick:d=>c(d,_i)},ne.createElement(iE,null)),ne.createElement(No,{toolbarPosition:o,active:e===Ir,activeColor:s,name:"select-tool-pan",title:"Pan",onClick:d=>c(d,Ir)},ne.createElement(sE,null)),ne.createElement(No,{toolbarPosition:o,active:e===Yr,activeColor:s,name:"select-tool-zoom-in",title:"Zoom in",onClick:d=>c(d,Yr)},ne.createElement(oE,null)),ne.createElement(No,{toolbarPosition:o,active:e===vi,activeColor:s,name:"select-tool-zoom-out",title:"Zoom out",onClick:d=>c(d,vi)},ne.createElement(aE,null)),ne.createElement(No,{toolbarPosition:o,active:!1,activeColor:s,name:"fit-to-viewer",title:"Fit to viewer",onClick:d=>h(d)},ne.createElement(lE,null)))}I1.propTypes={tool:ve.string.isRequired,onChangeTool:ve.func.isRequired,value:ve.object.isRequired,onChangeValue:ve.func.isRequired,position:ve.oneOf([xi,pr,yi,Hn]),SVGAlignX:ve.oneOf([Po,Io,Yf]),SVGAlignY:ve.oneOf([Po,Lo,Kf]),activeToolColor:ve.string};function uE(){return"ontouchstart"in window||navigator.maxTouchPoints}function L1(n){let{open:e,position:t}=n,r=0;switch(t){case Hn:r=e?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case pr:r=r=e?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("g",{transform:r},ne.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}L1.propTypes={open:ve.bool.isRequired,position:ve.oneOf([pr,Hn]).isRequired};function O1(n){let{value:e,onChangeValue:t,position:r}=n,i={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[r===Hn?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},s=e.miniatureOpen?w1:M1;return ne.createElement("button",{type:"button",style:i,onClick:()=>t(s(e))},ne.createElement(L1,{open:e.miniatureOpen,position:r}))}O1.propTypes={value:ve.object.isRequired,onChangeValue:ve.func.isRequired,position:ve.oneOf([pr,Hn]).isRequired};const hE="react-svg-pan-zoom_miniature";function q1(n){let{SVGMinX:e,SVGMinY:t,SVGWidth:r,SVGHeight:i,x1:s,y1:o,x2:a,y2:l,zoomToFit:c,_uid:h}=n;const f=`${hE}_mask_${h}`;return ne.createElement("g",null,ne.createElement("defs",null,ne.createElement("mask",{id:f},ne.createElement("rect",{x:e,y:t,width:r,height:i,fill:"#ffffff"}),ne.createElement("rect",{x:s,y:o,width:a-s,height:l-o}))),ne.createElement("rect",{x:e,y:t,width:r,height:i,style:{stroke:"none",fill:"#000",mask:`url(#${f})`,opacity:.4}}))}q1.propTypes={SVGWidth:ve.number.isRequired,SVGHeight:ve.number.isRequired,SVGMinX:ve.number.isRequired,SVGMinY:ve.number.isRequired,x1:ve.number.isRequired,y1:ve.number.isRequired,x2:ve.number.isRequired,y2:ve.number.isRequired,zoomToFit:ve.number.isRequired};const fE=A1(q1),dE="#616264";function D1(n){let{value:e,onChangeValue:t,children:r,SVGBackground:i,background:s=dE,position:o=Hn,width:a=100,height:l=80}=n,{SVGMinX:c,SVGMinY:h,SVGWidth:f,SVGHeight:p,viewerWidth:d,viewerHeight:m}=e,x=p/f,v=x>=1?l/p:a/f,[{x:_,y:w},{x:E,y:S}]=Yg(Zg(e),[{x:0,y:0},{x:d,y:m}]),b,A;e.miniatureOpen?(b=a,A=l):(b=24,A=24);let q={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:b+"px",height:A+"px",bottom:"6px",[o===Hn?"left":"right"]:"6px",background:s},O=x>=1?`translate(${(a-f*v)/2-c*v}, ${-h*v})`:`translate(${-c*v}, ${(l-p*v)/2-h*v})`;return ne.createElement("div",{role:"navigation",style:q},ne.createElement("svg",{width:a,height:l,style:{pointerEvents:"none"}},ne.createElement("g",{transform:O},ne.createElement("g",{transform:`scale(${v}, ${v})`},ne.createElement("rect",{fill:i,x:c,y:h,width:f,height:p}),r,ne.createElement(fE,{SVGWidth:f,SVGHeight:p,SVGMinX:c,SVGMinY:h,x1:_,y1:w,x2:E,y2:S,zoomToFit:v})))),ne.createElement(O1,{value:e,onChangeValue:t,position:o}))}D1.propTypes={value:ve.object.isRequired,onChangeValue:ve.func.isRequired,SVGBackground:ve.string.isRequired,position:ve.oneOf([pr,Hn]),background:ve.string,width:ve.number,height:ve.number};function ks(n){return typeof n>"u"||n===null}const nd="https://github.com/chrvadala/react-svg-pan-zoom/blob/main"+"/docs/migrate-from-v2-to-v3.md";function pE(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${nd}`)}function mE(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${nd}`)}function gE(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${nd}`)}function N1(n){(ks(n.tool)||ks(n.value))&&pE(),(!ks(n.miniaturePosition)||!ks(n.miniatureBackground)||!ks(n.miniatureWidth)||!ks(n.miniatureHeight))&&mE(),ks(n.toolbarPosition)||gE()}function kc(){return kc=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},kc.apply(null,arguments)}function U1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function _E(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?U1(Object(t),!0).forEach(function(r){vE(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):U1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function vE(n,e,t){return(e=xE(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function xE(n){var e=yE(n,"string");return typeof e=="symbol"?e:e+""}function yE(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Bc extends ne.Component{constructor(e,t){const{width:r,height:i,scaleFactorMin:s,scaleFactorMax:o,children:a}=e,{viewBox:l}=a.props;let c;if(l){const[h,f,p,d]=v1(l);c=n1(r,i,h,f,p,d,s,o)}else{const{width:h,height:f}=a.props;c=n1(r,i,0,0,h,f,s,o)}super(e,t),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:c},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&N1(e)}componentDidUpdate(e){const t=this.getValue(),r=this.props;let i=t,s=!1;process.env.NODE_ENV!=="production"&&N1(r);const{viewBox:o}=r.children.props;if(o){const[a,l,c,h]=v1(o);(t.SVGMinX!==a||t.SVGMinY!==l||t.SVGWidth!==c||t.SVGHeight!==h)&&(i=r1(i,a,l,c,h),s=!0)}else{const{width:a,height:l}=r.children.props;(t.SVGWidth!==a||t.SVGHeight!==l)&&(i=r1(i,0,0,a,l),s=!0)}(e.width!==r.width||e.height!==r.height)&&(i=_S(i,r.width,r.height),s=!0),(e.scaleFactorMin!==r.scaleFactorMin||e.scaleFactorMax!==r.scaleFactorMax)&&(i=vS(i,r.scaleFactorMin,r.scaleFactorMax),s=!0),s&&this.setValue(i)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return mS(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:_i}setValue(e){let{onChangeValue:t,onZoom:r,onPan:i}=this.props;t&&t(e),e.lastAction&&(r&&e.lastAction===Oc&&r(e),i&&e.lastAction===al&&i(e))}pan(e,t){let r=Zf(this.getValue(),e,t);this.setValue(r)}zoom(e,t,r){let i=qo(this.getValue(),e,t,r);this.setValue(i)}fitSelection(e,t,r,i){let s=u1(this.getValue(),e,t,r,i);this.setValue(s)}fitToViewer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Io,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lo,r=h1(this.getValue(),e,t);this.setValue(r)}zoomOnViewerCenter(e){let t=IS(this.getValue(),e);this.setValue(t)}setPointOnViewerCenter(e,t,r){let i=xS(this.getValue(),e,t,r);this.setValue(i)}reset(){let e=yS(this.getValue());this.setValue(e)}openMiniature(){let e=M1(this.getValue());this.setValue(e)}closeMiniature(){let e=w1(this.getValue());this.setValue(e)}handleViewerEvent(e){let{props:t,ViewerDOM:r}=this;if(!([_i,Pr].indexOf(this.getTool())>=0)||e.target===r)return;let s={click:t.onClick,dblclick:t.onDoubleClick,mousemove:t.onMouseMove,mouseup:t.onMouseUp,mousedown:t.onMouseDown,touchstart:t.onTouchStart,touchmove:t.onTouchMove,touchend:t.onTouchEnd,touchcancel:t.onTouchCancel}[e.type];s&&s(VS(e,t.value,r))}autoPanLoop(){let e={x:this.state.pointerX,y:this.state.pointerY},t=US(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,e);this.getValue()!==t&&this.setValue(t),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(e){let t=NS(e,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==t&&this.setValue(t)}render(){let{props:e,state:{pointerX:t,pointerY:r}}=this,i=this.getTool(),s=this.getValue(),{customToolbar:o=I1,customMiniature:a=D1}=e,l=i===Pr&&s.mode===Xr&&s.startX!==s.endX&&s.startY!==s.endY,c;i===Ir&&(c=Fc(s.mode===Xr?"grabbing":"grab")),i===Yr&&(c=Fc("zoom-in")),i===vi&&(c=Fc("zoom-out")),l&&(c=Fc("grabbing"));let h=[Ir,Yr,vi].indexOf(i)>=0;h=h||l;const f=this.props.detectPinchGesture||[Ir,Pr].indexOf(this.getTool())!==-1?"none":void 0,p={display:"block",cursor:c,touchAction:f};return ne.createElement("div",{style:_E({position:"relative",width:s.viewerWidth,height:s.viewerHeight},e.style),className:this.props.className},ne.createElement("svg",{ref:d=>this.ViewerDOM=d,width:s.viewerWidth,height:s.viewerHeight,style:p,onMouseDown:d=>{let m=f1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onMouseMove:d=>{let{left:m,top:x}=this.ViewerDOM.getBoundingClientRect(),v=d.clientX-Math.round(m),_=d.clientY-Math.round(x),w=d1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x:v,y:_});this.getValue()!==w&&this.setValue(w),this.setState({pointerX:v,pointerY:_}),this.handleViewerEvent(d)},onMouseUp:d=>{let m=p1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onClick:d=>{this.handleViewerEvent(d)},onDoubleClick:d=>{let m=DS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onMouseEnter:d=>{if(uE())return;let m=m1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onMouseLeave:d=>{let m=m1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onTouchStart:d=>{let m=XS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchMove:d=>{let m=$S(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchEnd:d=>{let m=YS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchCancel:d=>{let m=KS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)}},ne.createElement("rect",{fill:e.background,x:0,y:0,width:s.viewerWidth,height:s.viewerHeight,style:{pointerEvents:"none"}}),ne.createElement("g",{transform:cS(s),style:h?{pointerEvents:"none"}:{}},ne.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:s.SVGMinX||0,y:s.SVGMinY||0,width:s.SVGWidth,height:s.SVGHeight}),ne.createElement("g",null,e.children.props.children)),[_i,Pr].indexOf(i)>=0&&e.detectAutoPan&&s.focus?ne.createElement("g",{style:{pointerEvents:"none"}},r<=20?ne.createElement(zc,{direction:xi,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerWidth-t<=20?ne.createElement(zc,{direction:pr,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerHeight-r<=20?ne.createElement(zc,{direction:yi,width:s.viewerWidth,height:s.viewerHeight}):null,s.focus&&t<=20?ne.createElement(zc,{direction:Hn,width:s.viewerWidth,height:s.viewerHeight}):null):null,s.mode!==$r?null:ne.createElement(P1,{startX:s.startX,startY:s.startY,endX:s.endX,endY:s.endY})),e.toolbarProps.position===Lc?null:ne.createElement(o,kc({},this.props.toolbarProps,{value:s,onChangeValue:d=>this.setValue(d),tool:i,onChangeTool:d=>this.props.onChangeTool(d)})),e.miniatureProps.position===Lc?null:ne.createElement(a,kc({},this.props.miniatureProps,{value:s,onChangeValue:d=>this.setValue(d),SVGBackground:this.props.SVGBackground}),e.children.props.children))}}Bc.propTypes={width:ve.number.isRequired,height:ve.number.isRequired,value:ve.oneOfType([ve.object,ve.shape({version:ve.oneOf([2]).isRequired,mode:ve.oneOf([dr,Xr,$r]).isRequired,focus:ve.bool.isRequired,a:ve.number.isRequired,b:ve.number.isRequired,c:ve.number.isRequired,d:ve.number.isRequired,e:ve.number.isRequired,f:ve.number.isRequired,viewerWidth:ve.number.isRequired,viewerHeight:ve.number.isRequired,SVGMinX:ve.number.isRequired,SVGMinY:ve.number.isRequired,SVGWidth:ve.number.isRequired,SVGHeight:ve.number.isRequired,startX:ve.number,startY:ve.number,endX:ve.number,endY:ve.number,miniatureOpen:ve.bool.isRequired})]).isRequired,onChangeValue:ve.func.isRequired,tool:ve.oneOf([Pr,_i,Ir,Yr,vi]).isRequired,onChangeTool:ve.func.isRequired,background:ve.string,SVGBackground:ve.string,SVGStyle:ve.object,style:ve.object,className:ve.string,detectWheel:ve.bool,detectAutoPan:ve.bool,detectPinchGesture:ve.bool,onZoom:ve.func,onPan:ve.func,onClick:ve.func,onDoubleClick:ve.func,onMouseUp:ve.func,onMouseMove:ve.func,onMouseDown:ve.func,preventPanOutside:ve.bool,scaleFactor:ve.number,scaleFactorOnWheel:ve.number,scaleFactorMax:ve.number,scaleFactorMin:ve.number,modifierKeys:ve.array,disableDoubleClickZoomWithToolAuto:ve.bool,customMiniature:ve.oneOfType([ve.element,ve.func]),miniatureProps:ve.shape({position:ve.oneOf([Lc,pr,Hn]),background:ve.string,width:ve.number,height:ve.number}),customToolbar:ve.oneOfType([ve.element,ve.func]),toolbarProps:ve.shape({position:ve.oneOf([Lc,xi,pr,yi,Hn]),SVGAlignX:ve.oneOf([Po,Io,Yf]),SVGAlignY:ve.oneOf([Po,Lo,Kf]),activeToolColor:ve.string}),children:function(n,e,t){let r=n[e],i=["svg"];if(ne.Children.count(r)!==1||i.indexOf(r.type)===-1)return new Error("`"+t+"` should have a single child of the following types: `"+i.join("`, `")+"`.");if((!r.props.hasOwnProperty("width")||!r.props.hasOwnProperty("height"))&&!r.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},Bc.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const SE=["width","height","onChangeTool","onChangeValue"];function rd(){return rd=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},rd.apply(null,arguments)}function EE(n,e){if(n==null)return{};var t,r,i=bE(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)t=s[r],e.includes(t)||{}.propertyIsEnumerable.call(n,t)&&(i[t]=n[t])}return i}function bE(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.includes(r))continue;t[r]=n[r]}return t}class ME extends ne.Component{constructor(e){super(e),this.state={value:e.defaultValue||{},tool:e.defaultTool||_i},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(e){this.setState({tool:e})}changeValue(e){this.setState({value:e})}pan(e,t){this.Viewer.pan(e,t)}zoom(e,t,r){this.Viewer.zoom(e,t,r)}fitSelection(e,t,r,i){this.Viewer.fitSelection(e,t,r,i)}fitToViewer(e,t){this.Viewer.fitToViewer(e,t)}zoomOnViewerCenter(e){this.Viewer.zoomOnViewerCenter(e)}setPointOnViewerCenter(e,t,r){this.Viewer.setPointOnViewerCenter(e,t,r)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const e=this.props,{width:t,height:r,onChangeTool:i,onChangeValue:s}=e,o=EE(e,SE),{tool:a,value:l}=this.state;return ne.createElement(Bc,rd({width:t,height:r,tool:a,onChangeTool:this.changeTool,value:l,onChangeValue:this.changeValue,ref:c=>this.Viewer=c},o))}}ME.propTypes={width:ve.number.isRequired,height:ve.number.isRequired,defaultValue:ve.object,defaultTool:ve.string};const Ht=K2(n=>({planner:new Sc,viewer:null,plan:null,toast:null,showDimensions:!1,activeFloor:0,setViewer:e=>{n(t=>({...t,viewer:e}))},setToast:e=>{n(t=>({...t,toast:e}))},setActiveFloor:e=>{n(t=>({...t,activeFloor:e}))},newProject:()=>{n(e=>({...e,planner:qt.newProject(e.planner).updatedState}))},selectTool3DView:()=>{n(e=>{const r=qt.unselectAll(e.planner).updatedState.set("mode",Br);return{...e,planner:r}})},selectTool3DFirstPerson:()=>{n(e=>{const r=qt.rollback(e.planner).updatedState.set("mode",Ao);return{...e,planner:r}})},loadProject:e=>{n(t=>{const r=new Sc({scene:e,catalog:t.planner.catalog.toJS()});return{...t,planner:r}})},undo:()=>{n(e=>{const t=qt.undo(e.planner).updatedState;return{...e,planner:t}})},redo:()=>{n(e=>{const t=qt.redo(e.planner).updatedState;return{...e,planner:t}})},addLayer:(e,t)=>{n(r=>{const i=it.create(r.planner,e,t).updatedState;return{...r,planner:i}})},removeLayer:e=>{n(t=>{const r=it.remove(t.planner,e).updatedState;return{...t,planner:r}})},addGroup:()=>{n(e=>{const t=mn.create(e.planner).updatedState;return{...e,planner:t}})},selectGroup:e=>{n(t=>{const r=mn.select(t.planner,e).updatedState;return{...t,planner:r}})},setGroupProperties:(e,t)=>{n(r=>{const i=mn.setProperties(r.planner,e,t).updatedState;return{...r,planner:i}})},addToGroup:(e,t,r,i)=>{n(s=>{const o=mn.addElement(s.planner,e,t,r,i).updatedState;return{...s,planner:o}})},removeGroup:e=>{n(t=>{const r=mn.remove(t.planner,e).updatedState;return{...t,planner:r}})},setGroupAttributes:(e,t)=>{n(r=>{const i=mn.setAttributes(r.planner,e,t).updatedState;return{...r,planner:i}})},groupTranslate:(e,t,r)=>{n(i=>{const s=mn.translate(i.planner,e,t,r).updatedState;return{...i,planner:s}})},removeFromGroup:(e,t,r,i)=>{n(s=>{const o=mn.removeElement(s.planner,e,t,r,i).updatedState;return{...s,planner:o}})},groupRotate:(e,t)=>{n(r=>{const i=mn.rotate(r.planner,e,t).updatedState;return{...r,planner:i}})},removeGroupAndDeleteElements:e=>{n(t=>{const r=mn.removeAndDeleteElements(t.planner,e).updatedState;return{...t,planner:r}})},addGroupFromSelected:()=>{n(e=>{const t=mn.createFromSelectedElements(e.planner).updatedState;return{...e,planner:t}})},copyProperties:e=>{n(t=>({...t,planner:qt.copyProperties(t.planner,e).updatedState}))},setProjectProperties:e=>{n(t=>({...t,planner:qt.setProjectProperties(t.planner,e).updatedState}))},pasteProperties:()=>{n(e=>{const t=e.planner.merge({sceneHistory:on(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.pasteProperties(t).updatedState}})},setProperties:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setProperties(r,r.getIn(["scene","selectedLayer"]),e).updatedState}})},setHolesAttributes:e=>{n(t=>{const r=e.set("offset",parseFloat(e.get("offset"))),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setHolesAttributes(i,r).updatedState}})},setLinesAttributes:e=>{n(t=>{const r=e.withMutations(s=>{s.setIn(["vertexOne","x"],parseFloat(e.getIn(["vertexOne","x"]))),s.setIn(["vertexOne","y"],parseFloat(e.getIn(["vertexOne","y"]))),s.setIn(["vertexTwo","x"],parseFloat(e.getIn(["vertexTwo","x"]))),s.setIn(["vertexTwo","y"],parseFloat(e.getIn(["vertexTwo","y"])))}),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setLinesAttributes(i,r).updatedState}})},setItemsAttributes:e=>{n(t=>{const r=e.set("rotation",parseFloat(e.get("rotation"))),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setItemsAttributes(i,r).updatedState}})},selectLine:(e,t)=>{n(r=>{const i=Jt.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectHole:(e,t)=>{n(r=>{const i=pn.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectItem:(e,t)=>{n(r=>{const i=xn.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectLayer:e=>{n(t=>{const r=it.select(t.planner,e).updatedState;return{...t,planner:r}})},setLayerProperties:(e,t)=>{n(r=>{const i=it.setProperties(r.planner,e,t).updatedState;return{...r,planner:i}})},addVerticalGuide:e=>{n(t=>{const r=Ac.create(t.planner,e).updatedState;return{...t,planner:r}})},addHorizontalGuide:e=>{n(t=>{const r=Tc.create(t.planner,e).updatedState;return{...t,planner:r}})},removeVerticalGuide:e=>{n(t=>{const r=Ac.remove(t.planner,e).updatedState;return{...t,planner:r}})},removeHorizontalGuide:e=>{n(t=>{const r=Tc.remove(t.planner,e).updatedState;return{...t,planner:r}})},toggleSnap:e=>{n(t=>{const r=qt.toggleSnap(t.planner,e).updatedState;return{...t,planner:r}})},openProjectConfigurator:()=>{n(e=>{const t=qt.openProjectConfigurator(e.planner).updatedState;return{...e,planner:t}})},setMode:e=>{n(t=>{const r=t.planner.set("mode",e);return{...t,planner:r}})},updateZoomScale:e=>{n(t=>({...t,planner:qt.updateZoomScale(t.planner,e).updatedState}))},updateCameraView:e=>{n(t=>{const r=t.planner.update("viewer2D",i=>i.merge(At(e)));return{...t,planner:r}})},selectToolPan:()=>{n(e=>{const t=e.planner.set("mode",Ns);return{...e,planner:t}})},selectToolEdit:()=>{n(e=>({...e,planner:qt.setMode(e.planner,sn).updatedState}))},selectToolZoomIn:()=>{n(e=>{const t=e.planner.set("mode",qs);return{...e,planner:t}})},selectToolZoomOut:()=>{n(e=>{const t=e.planner.set("mode",Ds);return{...e,planner:t}})},updateDrawingLine:(e,t)=>{n(r=>({...r,planner:Jt.updateDrawingLine(r.planner,e,t).updatedState}))},updateDrawingSurface:(e,t)=>{n(r=>({...r,planner:Cc.updateDrawingSurface(r.planner,e,t).updatedState}))},updateMouseCoord:e=>{n(t=>({...t,planner:qt.updateMouseCoord(t.planner,e).updatedState}))},openCatalog:()=>{n(e=>{const t=e.planner.set("mode",cf);return{...e,planner:t}})},updateDrawingHole:(e,t,r)=>{n(i=>({...i,planner:pn.updateDrawingHole(i.planner,e,t,r).updatedState}))},updateDrawingItem:(e,t,r)=>{n(i=>({...i,planner:xn.updateDrawingItem(i.planner,e,t,r).updatedState}))},blur:()=>{n(e=>{const t=e.planner.merge({mode:sn,activeSnapElement:null});return{...e,planner:t}})},updateDraggingHole:(e,t)=>{n(r=>({...r,planner:pn.updateDraggingHole(r.planner,e,t).updatedState}))},updateDraggingLine:(e,t)=>{n(r=>({...r,planner:Jt.updateDraggingLine(r.planner,e,t).updatedState}))},updateDraggingVertex:(e,t)=>{n(r=>({...r,planner:cn.updateDraggingVertex(r.planner,e,t).updatedState}))},updateDraggingItem:(e,t)=>{n(r=>({...r,planner:xn.updateDraggingItem(r.planner,e,t).updatedState}))},updateRotatingItem:(e,t)=>{n(r=>({...r,planner:xn.updateRotatingItem(r.planner,e,t).updatedState}))},beginDraggingLine:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Jt.beginDraggingLine(o,e,t,r,i).updatedState}})},endDraggingLine:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Jt.endDraggingLine(i,e,t).updatedState}})},beginDraggingVertex:(e,t)=>{n(r=>({...r,planner:cn.beginDraggingVertex(r.planner,e,t).updatedState}))},endDraggingVertex:()=>{n(e=>({...e,planner:cn.endDraggingVertex(e.planner).updatedState}))},beginRotatingItem:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xn.beginRotatingItem(o,e,t,r,i).updatedState}})},endRotatingItem:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xn.endRotatingItem(i,e,t).updatedState}})},beginDraggingItem:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xn.beginDraggingItem(o,e,t,r,i).updatedState}})},endDraggingItem:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xn.endDraggingItem(i,e,t).updatedState}})},beginDraggingHole:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:pn.beginDraggingHole(o,e,t,r,i).updatedState}})},endDraggingHole:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:pn.endDraggingHole(i,e,t).updatedState}})},beginDrawingLine:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Jt.beginDrawingLine(s,e,t,r).updatedState}})},endDrawingLine:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Jt.endDrawingLine(i,e,t).updatedState}})},beginDrawingSurface:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Cc.beginDrawingSurface(s,e,t,r).updatedState}})},endDrawingSurface:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Cc.endDrawingSurface(i,e,t).updatedState}})},endDrawingHole:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:pn.endDrawingHole(s,e,t,r).updatedState}})},endDrawingItem:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:xn.endDrawingItem(s,e,t,r).updatedState}})},selectArea:(e,t)=>{n(r=>({...r,planner:Fs.select(r.planner,e,t).updatedState}))},initCatalog:e=>{n(t=>({...t,planner:qt.initCatalog(t.planner,e).updatedState}))},goBackToCatalogPage:e=>{n(t=>({...t,planner:qt.goBackToCatalogPage(t.planner,e).updatedState}))},pushLastSelectedCatalogElementToHistory:e=>{n(t=>({...t,planner:qt.pushLastSelectedCatalogElementToHistory(t.planner,e).updatedState}))},selectToolDrawingLine:e=>{n(t=>({...t,planner:Jt.selectToolDrawingLine(t.planner,e).updatedState}))},selectToolDrawingSurface:e=>{n(t=>({...t,planner:Cc.selectToolDrawingSurface(t.planner,e).updatedState}))},selectToolDrawingItem:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:xn.selectToolDrawingItem(r,e).updatedState}})},selectToolDrawingHole:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:pn.selectToolDrawingHole(r,e).updatedState}})},changeCatalogPage:(e,t)=>{n(r=>({...r,planner:qt.changeCatalogPage(r.planner,t,e).updatedState}))},remove:()=>{n(e=>{const t=e.planner.merge({sceneHistory:on(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.remove(t).updatedState}})},rollback:()=>{n(e=>({...e,planner:qt.rollback(e.planner).updatedState}))},setAlterateState:()=>{n(e=>({...e,planner:qt.setAlterate(e.planner).updatedState}))},setPlan:e=>{n(t=>({...t,plan:e}))},unselectAll:()=>{n(e=>({...e,planner:qt.unselectAll(e.planner).updatedState}))},setShowDimensions:e=>{n(t=>({...t,showDimensions:e}))}})),ll={stroke:"#D32F2F",strokeWidth:"1px"};function wE({snap:n,width:e,height:t}){switch(n.type){case"point":return R.jsxs("g",{transform:`translate(${n.x} ${n.y})`,children:[R.jsx("line",{x1:"0",y1:"-70",x2:"0",y2:"70",style:ll}),R.jsx("line",{x1:"-70",y1:"0",x2:"70",y2:"0",style:ll})]});case"line":let r=gc(0),i=gc(t),s=il(n.a,n.b,n.c,r.a,r.b,r.c),o=il(n.a,n.b,n.c,i.a,i.b,i.c),a=_c(0),l=_c(e),c=il(n.a,n.b,n.c,a.a,a.b,a.c),h=il(n.a,n.b,n.c,l.a,l.b,l.c);return s&&o?R.jsx("line",{x1:s.x,y1:s.y,x2:o.x,y2:o.y,style:ll}):c&&h?R.jsx("line",{x1:c.x,y1:c.y,x2:h.x,y2:h.y,style:ll}):null;case"line-segment":return R.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,style:ll});default:return null}}const Vc={white:"#FFFFFF",black:"#000000"},F1={500:{orange:"#FF9800"}},TE={alt:"#2E2F33",text_main:Vc.white},AE={main:"#1CA6FC"},id="#99C3FB",Lt={COLORS:Vc,PRIMARY_COLOR:TE,SECONDARY_COLOR:AE,MESH_SELECTED:id,AREA_MESH_COLOR:{selected:id,unselected:"#F5F4F4"},LINE_MESH_COLOR:{selected:id}};function CE({width:n,height:e,grid:t}){let r=t.properties.get("step"),i;t.properties.has("color")?i=He([t.properties.get("color")]):i=t.properties.get("colors");let s=[],o=0;for(let a=0;a<=e;a+=r){let l=i.get(o%i.size);o++,s.push(R.jsx("line",{x1:"0",y1:a,x2:n,y2:a,strokeWidth:"1",stroke:l},a))}return R.jsx("g",{children:s})}function RE({width:n,height:e,grid:t}){let r=t.properties.get("step"),i;t.properties.has("color")?i=He([t.properties.get("color")]):i=t.properties.get("colors");let s=[],o=0;for(let a=0;a<=n;a+=r){let l=i.get(o%i.size);o++,s.push(R.jsx("line",{x1:a,y1:"0",x2:a,y2:e,strokeWidth:"1",stroke:l},a))}return R.jsx("g",{children:s})}function PE({scene:n}){let{width:e,height:t,grids:r}=n,i=r.entrySeq().map(([s,o])=>{switch(o.type){case"horizontal-streak":return R.jsx(CE,{width:e,height:t,grid:o},s);case"vertical-streak":return R.jsx(RE,{width:e,height:t,grid:o},s);default:console.warn(`grid ${o.type} not allowed`)}}).toList();return R.jsx("g",{children:i})}class IE{constructor(e=[],t=(r,i)=>r<i?-1:r>i?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const s=e-1>>1,o=t[s];if(r(i,o)>=0)break;t[e]=o,e=s}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,s=t[e];for(;e<i;){let o=(e<<1)+1;const a=o+1;if(a<this.length&&r(t[a],t[o])<0&&(o=a),r(t[o],s)>=0)break;t[e]=t[o],e=o}t[e]=s}}function LE(n,e=1,t=!1){let r=1/0,i=1/0,s=-1/0,o=-1/0;for(const[_,w]of n[0])_<r&&(r=_),w<i&&(i=w),_>s&&(s=_),w>o&&(o=w);const a=s-r,l=o-i,c=Math.max(e,Math.min(a,l));if(c===e){const _=[r,i];return _.distance=0,_}const h=new IE([],(_,w)=>w.max-_.max);let f=qE(n);const p=new Hc(r+a/2,i+l/2,0,n);p.d>f.d&&(f=p);let d=2;function m(_,w,E){const S=new Hc(_,w,E,n);d++,S.max>f.d+e&&h.push(S),S.d>f.d&&(f=S,t&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${d} probes`))}let x=c/2;for(let _=r;_<s;_+=c)for(let w=i;w<o;w+=c)m(_+x,w+x,x);for(;h.length;){const{max:_,x:w,y:E,h:S}=h.pop();if(_-f.d<=e)break;x=S/2,m(w-x,E-x,x),m(w+x,E-x,x),m(w-x,E+x,x),m(w+x,E+x,x)}t&&console.log(`num probes: ${d}
70
- best distance: ${f.d}`);const v=[f.x,f.y];return v.distance=f.d,v}function Hc(n,e,t,r){this.x=n,this.y=e,this.h=t,this.d=OE(n,e,r),this.max=this.d+this.h*Math.SQRT2}function OE(n,e,t){let r=!1,i=1/0;for(const s of t)for(let o=0,a=s.length,l=a-1;o<a;l=o++){const c=s[o],h=s[l];c[1]>e!=h[1]>e&&n<(h[0]-c[0])*(e-c[1])/(h[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,DE(n,e,c,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function qE(n){let e=0,t=0,r=0;const i=n[0];for(let o=0,a=i.length,l=a-1;o<a;l=o++){const c=i[o],h=i[l],f=c[0]*h[1]-h[0]*c[1];t+=(c[0]+h[0])*f,r+=(c[1]+h[1])*f,e+=f*3}const s=new Hc(t/e,r/e,0,n);return e===0||s.d<0?new Hc(i[0][0],i[0][1],0,n):s}function DE(n,e,t,r){let i=t[0],s=t[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){const l=((n-i)*o+(e-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=e-s,o*o+a*a}function z1(n,e){var t=n.length,r=0;n=n.map(NE),n[0]!=n[n.length-1]&&(n=n.concat(n[0]));for(var i=0;i<t;i++)r+=n[i].x*n[i+1].y-n[i].y*n[i+1].x;return Math.abs(r)/2}function NE(n){return Array.isArray(n)?{x:n[0],y:n[1]}:n}const UE={textAnchor:"middle",fontSize:"12px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function FE({layer:n,area:e,catalog:t}){let r=t.getElement(e.type).render2D(e,n),i=null;if(e.selected){let s=e.vertices.toArray().map(c=>{let{x:h,y:f}=n.vertices.get(c);return[h,f]}),o=s;e.holes.forEach(c=>{let h=n.areas.get(c).vertices.toArray().map(f=>{let{x:p,y:d}=n.vertices.get(f);return[p,d]});o=o.concat(h.reverse())});let a=LE([o],1),l=z1(s);e.holes.forEach(c=>{let f=n.areas.get(c).vertices.toArray().map(p=>{let{x:d,y:m}=n.vertices.get(p);return[d,m]});l-=z1(f)}),i=R.jsxs("text",{x:"0",y:"0",transform:`translate(${a[0]} ${a[1]}) scale(1, -1)`,style:UE,children:[(l/1e4).toFixed(2)," m","²"]})}return R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,children:[r,i]})}const zE=0,kE=0,BE=5,VE={fill:F1[500].orange,stroke:F1[500].orange,cursor:"default"};function HE({layer:n,group:e}){return R.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${e.x},${e.y}) rotate(${e.rotation})`,children:e.selected&&R.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:R.jsx("circle",{cx:zE,cy:kE,r:BE,style:VE,children:R.jsx("title",{children:"Group's Barycenter"})})})})}const GE={fill:"#0096fd",stroke:"#0096fd",cursor:"ew-resize"},WE={fill:"none",stroke:"#0096fd",cursor:"ew-resize"};function jE({layer:n,item:e,scene:t,catalog:r}){let{x:i,y:s,rotation:o}=e,a=r.getElement(e.type).render2D(e,n,t);return R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${i},${s}) rotate(${o})`,children:[a,e.selected&&R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:[R.jsx("circle",{cx:"0",cy:"100",r:"10",style:GE}),R.jsx("circle",{cx:"0",cy:"0",r:"100",style:WE})]})]})}const XE={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},$E={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},YE={metric:XE,imperial:$E,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},KE={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},ZE={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},JE={metric:KE,imperial:ZE,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},QE={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},eb={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},tb={metric:QE,imperial:eb,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},nb={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},rb={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},ib={metric:nb,imperial:rb,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},sb={metric:{ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},ob={metric:{C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial:{F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},_anchors:{metric:{unit:"C",transform:function(n){return n/(5/9)+32}},imperial:{unit:"F",transform:function(n){return(n-32)*(5/9)}}}},k1=365.25,ab={metric:{ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*k1/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*k1}},_anchors:{metric:{unit:"s",ratio:1}}},lb={bits:{b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes:{B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},cb={metric:{ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},ub={metric:{"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial:{"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},hb={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},fb={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},db={metric:hb,imperial:fb,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},pb={metric:{A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},_anchors:{metric:{unit:"A",ratio:1}}},mb={metric:{V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},_anchors:{metric:{unit:"V",ratio:1}}},gb={metric:{W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},_anchors:{metric:{unit:"W",ratio:1}}},_b={metric:{VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},_anchors:{metric:{unit:"VAR",ratio:1}}},vb={metric:{VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},_anchors:{metric:{unit:"VA",ratio:1}}},xb={metric:{Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},_anchors:{metric:{unit:"J",ratio:1}}},yb={metric:{VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},_anchors:{metric:{unit:"VARh",ratio:1}}},Sb={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},Eb={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},bb={metric:Sb,imperial:Eb,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},Mb={metric:{lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial:{"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},wb={metric:{mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},_anchors:{frequency:{unit:"hz",ratio:1}}},ls={length:YE,area:JE,mass:tb,volume:ib,each:sb,temperature:ob,time:ab,digital:lb,partsPer:cb,speed:ub,pressure:db,current:pb,voltage:mb,power:gb,reactivePower:_b,apparentPower:vb,energy:xb,reactiveEnergy:yb,volumeFlowRate:bb,illuminance:Mb,frequency:wb};function cl(n){return Object.keys(n)}function B1(n){return{abbr:n.abbr,measure:n.measure,system:n.system,singular:n.unit.name.singular,plural:n.unit.name.plural}}function Or(n,e){if(Array.isArray(n))for(let t=0;t<n.length;t++)e(n[t],t,n);else if(n&&typeof n=="object")for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(n[t],t,n)}class Tb{constructor(e,t){ht(this,"val");ht(this,"destination");ht(this,"origin");this.val=t?e/t:e}from(e){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(e),this.origin||this.throwUnsupportedUnitError(e),this}to(e){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(e),this.destination||this.throwUnsupportedUnitError(e),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let t=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(t-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const r=ls[this.origin.measure]._anchors[this.origin.system];t=typeof r.transform=="function"?r.transform(t):t*r.ratio}return this.destination.unit.anchor_shift&&(t+=this.destination.unit.anchor_shift),t/this.destination.unit.to_anchor}toBest(e){if(!this.origin)throw new Error(".toBest must be called after .from");const t={exclude:[],cutOffNumber:1,...e};let r=null;return Or(this.possibilities(),i=>{if(t.exclude.includes(i))return;const s=this.describe(i);if(s.system!==this.origin.system)return;const o=this.to(i);(!r||o>=t.cutOffNumber&&o<r.val)&&(r={val:o,unit:i,singular:s.singular,plural:s.plural})}),r}getUnit(e){let t=null;return Or(ls,(r,i)=>{Or(r,(s,o)=>{o!=="_anchors"&&Or(s,(a,l)=>{l===e&&(t={abbr:e,measure:i,system:o,unit:a})})})}),t}describe(e){const t=this.getUnit(e);return t||this.throwUnsupportedUnitError(e),B1(t)}list(e){const t=[];return Or(ls,(r,i)=>{e&&e!==i||Or(r,(s,o)=>{o!=="_anchors"&&Or(s,(a,l)=>{t.push(B1({abbr:l,measure:i,system:o,unit:a}))})})}),t}throwUnsupportedUnitError(e){const t=[];throw Or(ls,r=>{Or(r,(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})}),new Error(`Unsupported unit ${e}, use one of: ${t.join(", ")}`)}possibilities(e){const t=[];if(!this.origin&&!e)Or(cl(ls),r=>{Or(ls[r],(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})});else{const r=e||this.origin.measure;Or(ls[r],(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})}return t}measures(){return cl(ls)}}function Kr(n){return new Tb(n)}const sd={stroke:"#0096fd",strokeWidth:"1px"},Ab={textAnchor:"middle",fontSize:"16px",fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function Cb({length:n,unit:e,transform:t}){let r=`${e!==Cr?Kr(n).from(Cr).to(e).toFixed(2):n.toFixed(2)} ${e}`;return R.jsxs("g",{transform:t,children:[R.jsx("text",{x:n/2,y:"-12",transform:"scale(1, -1)",style:Ab,children:r}),R.jsx("line",{x1:"0",y1:"-5",x2:"0",y2:"5",style:sd}),R.jsx("line",{x1:n,y1:"-5",x2:n,y2:"5",style:sd}),R.jsx("line",{x1:"0",y1:"0",x2:n,y2:"0",style:sd})]})}const Rb=({line:n,layer:e,scene:t,catalog:r,mode:i,showDimensions:s})=>{let o=e.vertices.get(n.vertices.get(0)),a=e.vertices.get(n.vertices.get(1));if(o.id===a.id||jr(o,a))return null;let{x:l,y:c}=o,{x:h,y:f}=a;l>h&&({x:l,y:c}=a,{x:h,y:f}=o);let p=Cn(l,c,h,f),d=r3(l,c,h,f),m=n.holes.map(E=>{let S=e.holes.get(E),b=p*S.offset,A=r.getElement(S.type).render2D(S,e,t);return R.jsx("g",{transform:`translate(${b}, 0)`,"data-element-root":!0,"data-prototype":S.prototype,"data-id":S.id,"data-selected":S.selected,"data-layer":e.id,children:A},E)}),v=(n.getIn(["properties","thickness","length"])??0)/2,_=r.getElement(n.type).render2D(n,e,t,i),w=n.selected||s?R.jsx(Cb,{unit:t.unit,length:p,transform:`translate(0, ${v+10} )`}):null;return R.jsxs("g",{transform:`translate(${l}, ${c}) rotate(${d}, 0, 0)`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":e.id,style:n.selected?{cursor:"move"}:{},children:[w,_,m]})},Pb={fill:"#0096fd",stroke:Lt.COLORS.white,cursor:"move"},Ib=({vertex:n,layer:e})=>R.jsx("g",{transform:`translate(${n.x}, ${n.y})`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":e.id,children:R.jsx("circle",{cx:"0",cy:"0",r:"7",style:Pb})});function V1({layer:n,scene:e,catalog:t,mode:r,showDimensions:i}){const{groups:s}=e,{lines:o,areas:a,vertices:l,id:c,items:h,opacity:f}=n;return R.jsxs("g",{opacity:f,children:[a.valueSeq().map(p=>R.jsx(FE,{layer:n,area:p,catalog:t},p.id)),o.valueSeq().map(p=>R.jsx(Rb,{mode:r,showDimensions:i,layer:n,line:p,scene:e,catalog:t},p.id)),h.valueSeq().map(p=>R.jsx(jE,{layer:n,item:p,scene:e,catalog:t},p.id)),l.valueSeq().filter(p=>p.selected).map(p=>R.jsx(Ib,{layer:n,vertex:p},p.id)),s.valueSeq().filter(p=>p.hasIn(["elements",c])&&p.get("selected")).map(p=>R.jsx(HE,{layer:n,group:p,scene:e,catalog:t},p.get("id")))]})}const Lb=({scene:n,catalog:e,mode:t,showDimensions:r})=>{const{layers:i}=n,s=i.get(n.selectedLayer);return R.jsxs("g",{children:[R.jsx(PE,{scene:n}),R.jsx("g",{style:{pointerEvents:"none"},children:i.entrySeq().filter(([o,a])=>o!==n.selectedLayer&&a.visible).map(([o,a])=>R.jsx(V1,{mode:t,layer:a,scene:n,showDimensions:r,catalog:e},o))}),R.jsx(V1,{mode:t,layer:s,scene:n,showDimensions:r,catalog:e},s.id)]})},Ob=ne.memo(Lb,(n,e)=>n.scene.hashCode()===e.scene.hashCode()&&n.mode===e.mode&&n.showDimensions===e.showDimensions),H1={stroke:Lt.SECONDARY_COLOR.main,strokeWidth:"2.5px"},qb=({catalog:n})=>{const{planner:e,showDimensions:t}=Ht(),{activeSnapElement:r,snapElements:i,scene:s,mode:o}=e,{width:a,height:l}=s;return R.jsxs("g",{children:[R.jsx("rect",{x:"0",y:"0",width:a,height:l,fill:Lt.COLORS.white}),R.jsxs("g",{transform:`translate(0, ${s.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[R.jsx(Ob,{scene:s,mode:o,catalog:n,showDimensions:t}),s.getIn(["guides","horizontal"]).entrySeq().map(([c,h])=>R.jsx("line",{id:"hGuide"+c,x1:0,y1:h,x2:a,y2:h,style:H1},c)),s.getIn(["guides","vertical"]).entrySeq().map(([c,h])=>R.jsx("line",{x1:h,y1:0,x2:h,y2:l,style:H1},c)),r?R.jsx(wE,{snap:r,width:s.width,height:s.height}):null,i?null:R.jsx(R.Fragment,{})]})]})},od=.25,G1=5,Db=.1,Nb=5.5;function W1(n){return(Math.min(Math.max(n,od),G1)-od)/(G1-od)*100}function Ub(n){switch(n){case Ns:return Ir;case qs:return Yr;case Ds:return vi;case sn:return Pr;default:return _i}}function Fb(n){switch(n){case Jn:case di:case hr:case Ar:case Wr:case Gr:case Vr:case Hr:return{pointerEvents:"none"};default:return{}}}function zb(n){switch(n){case Wr:case Vr:case Hr:case Gr:return{cursor:"move"};case Di:return{cursor:"ew-resize"};case Tr:case Jn:case Us:case di:return{cursor:"crosshair"};default:return{cursor:"default"}}}function kb(n){switch(n){case Jn:case di:case Vr:case Hr:case Wr:case Gr:case hr:case Ar:return!0;default:return!1}}function j1(n){for(;!n.attributes.getNamedItem("data-element-root")&&n.tagName!=="svg";)n=n.parentNode;return n.tagName==="svg"?null:{part:n.attributes.getNamedItem("data-part")?n.attributes.getNamedItem("data-part").value:void 0,layer:n.attributes.getNamedItem("data-layer").value,prototype:n.attributes.getNamedItem("data-prototype").value,selected:n.attributes.getNamedItem("data-selected").value==="true",id:n.attributes.getNamedItem("data-id").value}}const Bb=({width:n,height:e,catalog:t})=>{const r=ne.useRef(null),{planner:i,selectToolZoomOut:s,selectToolZoomIn:o,selectToolPan:a,selectToolEdit:l,updateCameraView:c,updateZoomScale:h,updateMouseCoord:f,updateDrawingLine:p,updateDrawingSurface:d,updateDrawingHole:m,updateDrawingItem:x,updateDraggingHole:v,updateDraggingLine:_,updateDraggingVertex:w,updateDraggingItem:E,updateRotatingItem:S,beginDraggingLine:b,beginDraggingVertex:A,beginRotatingItem:q,beginDraggingItem:O,beginDraggingHole:T,beginDrawingSurface:I,endDrawingSurface:N,selectArea:H,unselectAll:W,beginDrawingLine:Q,endDrawingLine:ae,endDrawingHole:J,endDrawingItem:se,endDraggingLine:B,endDraggingVertex:ge,endDraggingItem:F,endDraggingHole:X,endRotatingItem:de,selectLine:ye,selectHole:Ee,selectItem:V,rollback:re,setViewer:Z}=Ht(),{viewer2D:he,scene:xe,mode:ee}=i,Pe=xe.selectedLayer??"";ne.useEffect(()=>{r.current&&(Z(r.current),r.current.setPointOnViewerCenter(xe.width/2,xe.height/2,.725))},[]);const le=({x:be,y:tt})=>({x:be,y:-tt+xe.height}),z=be=>{const tt=new Event("mousemove-planner-event");tt.viewerEvent=be,document.dispatchEvent(tt);let{x:lt,y:$e}=le(be);switch(f({x:lt,y:$e}),ee){case Jn:p(lt,$e,i.snapMask);break;case di:d(lt,$e,i.snapMask);break;case hr:m(Pe,lt,$e);break;case Ar:x(Pe,lt,$e);break;case Wr:v(lt,$e);break;case Vr:_(lt,$e,i.snapMask);break;case Hr:w(lt,$e,i.snapMask);break;case Gr:E(lt,$e);break;case Di:S(lt,$e);break}be.originalEvent.stopPropagation()},rt=be=>{const tt=be.originalEvent,lt=new Event("mousedown-planner-event");lt.viewerEvent=be,document.dispatchEvent(lt);let{x:$e,y:U}=le(be);if(ee===sn){let P=j1(tt.target);if(!P||!P.selected)return;switch(P.prototype){case"lines":b(P.layer,P.id,$e,U,i.snapMask);break;case"vertices":A(P.layer,P.id,$e,U,i.snapMask);break;case"items":P.part==="rotation-anchor"?q(P.layer,P.id,$e,U):O(P.layer,P.id,$e,U);break;case"holes":T(P.layer,P.id,$e,U);break}}tt.stopPropagation()},Le=be=>{const tt=be.originalEvent,lt=new Event("mouseup-planner-event");lt.viewerEvent=be,document.dispatchEvent(lt);const{x:$e,y:U}=le(be);switch(ee){case sn:const P=j1(tt.target);if(P&&P.selected)return;switch(P?P.prototype:"none"){case"areas":H(P.layer,P.id);break;case"lines":ye(P.layer,P.id);break;case"holes":Ee(P.layer,P.id);break;case"items":V(P.layer,P.id);break;case"none":W();break}break;case Us:I(Pe,$e,U,i.snapMask);break;case di:N($e,U,i.snapMask),I(Pe,$e,U,i.snapMask);break;case Tr:Q(Pe,$e,U,i.snapMask);break;case Jn:ae($e,U,i.snapMask),Q(Pe,$e,U,i.snapMask);break;case hr:J(Pe,$e,U);break;case Ar:se(Pe,$e,U);break;case Vr:B($e,U,i.snapMask);break;case Hr:ge($e,U,i.snapMask);break;case Gr:F($e,U);break;case Wr:X($e,U);break;case Di:de($e,U);break}tt.stopPropagation()},at=()=>{[Us,di,Tr,Jn,hr,Ar].includes(ee)&&re()},ze=be=>{h(be.a),c(be)},Xe=be=>{switch(be){case _i:l();break;case Ir:a();break;case Yr:o();break;case vi:s();break}};return R.jsx("div",{className:"m-0 p-0 relative",children:R.jsx(Bc,{className:"floor_planner-svgPanZoom",ref:r,width:n,height:e,scaleFactorMin:Db,scaleFactorMax:Nb,value:he.isEmpty()?{}:he.toJS(),onChangeValue:ze,tool:Ub(ee),onChangeTool:Xe,detectAutoPan:kb(ee),onMouseDown:rt,onMouseMove:z,onMouseUp:Le,onDoubleClick:at,miniatureProps:{position:"none",width:0,height:0,background:""},toolbarProps:{position:"none"},children:R.jsxs("svg",{width:xe.width,height:xe.height,children:[R.jsx("defs",{children:R.jsxs("pattern",{id:"diagonalFill",patternUnits:"userSpaceOnUse",width:"4",height:"4",fill:"#FFF",children:[R.jsx("rect",{x:"0",y:"0",width:"4",height:"4",fill:"#FFF"}),R.jsx("path",{d:"M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2",style:{stroke:"#8E9BA2",strokeWidth:1}})]})}),R.jsx("g",{style:Object.assign(zb(ee),Fb(ee)),children:R.jsx(qb,{catalog:t})})]})})})};/**
69
+ at `+o}return e},Ic.buildMessage=function(n,e){var t={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var h=c.parts.map(function(f){return Array.isArray(f)?s(f[0])+"-"+s(f[1]):s(f)});return"["+(c.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function s(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function o(c){return t[c.type](c)}function a(c){var h=c.map(o),f,p;if(h.sort(),h.length>0){for(f=1,p=1;f<h.length;f++)h[f-1]!==h[f]&&(h[p]=h[f],p++);h.length=p}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(n)+" but "+l(e)+" found."};const dr="idle",Xr="panning",$r="zooming",Ir="auto",_i="none",Lr="pan",Yr="zoom-in",vi="zoom-out",Lc="none",xi="top",pr="right",yi="bottom",Hn="left",Oc="zoom",al="pan",Po="center",Io="left",Yf="right",Lo="top",Kf="bottom",Jg="cover";function Qg(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function qc(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qg(Object(t),!0).forEach(function(r){fS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Qg(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function fS(n,e,t){return(e=dS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function dS(n){var e=pS(n,"string");return typeof e=="symbol"?e:e+""}function pS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}const e1=3,t1=dr;function n1(n,e,t,r,i,s){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,a=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return Xt({},qc(qc({},Kg()),{},{version:e1,mode:t1,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:n,viewerHeight:e,SVGMinX:t,SVGMinY:r,SVGWidth:i,SVGHeight:s,scaleFactorMin:o,scaleFactorMax:a,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function Xt(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return n=Object.assign({},n,e,{lastAction:t}),Object.freeze(n)}function mS(n){return n!==null&&typeof n=="object"&&n.hasOwnProperty("version")&&n.version===e1}function Or(n,e,t){let r=ol(n),i=Zg(r);return $g(i,{x:e,y:t})}function Dc(n){let e=ol(n);return{scaleFactor:e.a,translationX:e.e,translationY:e.f}}function gS(n,e){return Xt(n,{focus:e})}function _S(n,e,t){return Xt(n,{viewerWidth:e,viewerHeight:t})}function r1(n,e,t,r,i){return Xt(n,{SVGMinX:e,SVGMinY:t,SVGWidth:r,SVGHeight:i})}function vS(n,e,t){return Xt(n,{scaleFactorMin:e,scaleFactorMax:t})}function xS(n,e,t,r){let{viewerWidth:i,viewerHeight:s}=n,o=Ui(fr(-e+i/2,-t+s/2),fr(e,t),zs(r,r),fr(-e,-t));return Xt(n,qc({mode:dr},o))}function yS(n){return Xt(n,qc({mode:dr},Kg()))}function i1(n){return Xt(n,{mode:t1,startX:null,startY:null,endX:null,endY:null})}class s1{constructor(e,t,r){this.originalEvent=e,this.value=t,this.SVGViewer=r}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Dc(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function o1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function SS(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?o1(Object(t),!0).forEach(function(r){ES(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):o1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function ES(n,e,t){return(e=bS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function bS(n){var e=MS(n,"string");return typeof e=="symbol"?e:e+""}function MS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Zf(n,e,t){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,i=Ui(ol(n),fr(e,t));if(r){let[{x:s,y:o},{x:a,y:l}]=Yg(i,[{x:n.SVGMinX+r,y:n.SVGMinY+r},{x:n.SVGMinX+n.SVGWidth-r,y:n.SVGMinY+n.SVGHeight-r}]),c=0;n.viewerWidth-s<0?c=n.viewerWidth-s:a<0&&(c=-a);let h=0;n.viewerHeight-o<0?h=n.viewerHeight-o:l<0&&(h=-l),i=Ui(fr(c,h),i)}return Xt(n,SS({mode:dr},i),al)}function wS(n,e,t){return Xt(n,{mode:Xr,startX:e,startY:t,endX:e,endY:t},al)}function TS(n,e,t,r){if(n.mode!==Xr)throw new Error("update pan not allowed in this mode "+n.mode);let{endX:i,endY:s}=n,o=Or(n,i,s),a=Or(n,e,t),l=a.x-o.x,c=a.y-o.y,h=Zf(n,l,c,r);return Xt(h,{mode:Xr,endX:e,endY:t},al)}function a1(n){return Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null},al)}function AS(n,e,t){let r=0,i=0;return t<=20&&(i=2),n.viewerWidth-e<=20&&(r=-2),n.viewerHeight-t<=20&&(i=-2),e<=20&&(r=2),r=r/n.d,i=i/n.d,r===0&&i===0?n:Zf(n,r,i)}function l1(n,e){if(n.x<=e.x&&n.y<=e.y)return{x:n.x,y:n.y,width:e.x-n.x,height:e.y-n.y};if(n.x>=e.x&&n.y<=e.y)return{x:e.x,y:n.y,width:n.x-e.x,height:e.y-n.y};if(n.x>=e.x&&n.y>=e.y)return{x:e.x,y:e.y,width:n.x-e.x,height:n.y-e.y};if(n.x<=e.x&&n.y>=e.y)return{x:n.x,y:e.y,width:e.x-n.x,height:n.y-e.y}}function c1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Oo(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?c1(Object(t),!0).forEach(function(r){CS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):c1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function CS(n,e,t){return(e=RS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function RS(n){var e=PS(n,"string");return typeof e=="symbol"?e:e+""}function PS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Nc(n,e){const{scaleFactor:t}=Dc(n),r=n.scaleFactorMin&&t*e<n.scaleFactorMin,i=n.scaleFactorMax&&t*e>n.scaleFactorMax;return r&&e<1||i&&e>1}function Jf(n,e){let t=e.a;return n.scaleFactorMin!=null&&(t=Math.max(t,n.scaleFactorMin)),n.scaleFactorMax!=null&&(t=Math.min(t,n.scaleFactorMax)),Xt(e,{a:t,d:t})}function qo(n,e,t,r){if(Nc(n,r))return n;const i=Ui(ol(n),fr(e,t),zs(r,r),fr(-e,-t));return Xt(n,Oo(Oo({mode:dr},i),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function u1(n,e,t,r,i){let{viewerWidth:s,viewerHeight:o}=n,a=s/r,l=o/i,c=Math.min(a,l);const h=Ui(zs(c,c),fr(-e,-t));return Nc(n,c/n.d)?Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null}):Xt(n,Oo(Oo({mode:dr},Jf(n,h)),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function h1(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Io,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Lo,{viewerWidth:r,viewerHeight:i,SVGMinX:s,SVGMinY:o,SVGWidth:a,SVGHeight:l}=n,c=r/a,h=i/l,f=Math.min(c,h),p=zs(f,f),d=-s*c,m=-o*h;if(c<h){let _=i-c*l;switch(t){case Lo:m=-o*f;break;case Po:m=Math.round(_/2)-o*f;break;case Kf:m=_-o*f;break;case Jg:p=zs(h,h);let w=r-h*a;d=s+Math.round(w/2);break}}else{let _=r-h*a;switch(e){case Io:d=-s*f;break;case Po:d=Math.round(_/2)-s*f;break;case Yf:d=_-s*f;break;case Jg:p=zs(c,c);let w=i-c*l;m=o+Math.round(w/2);break}}const x=fr(d,m),v=Ui(x,p);return Nc(n,f/n.d)?Xt(n,{mode:dr,startX:null,startY:null,endX:null,endY:null}):Xt(n,Oo(Oo({mode:dr},Jf(n,v)),{},{startX:null,startY:null,endX:null,endY:null}),Oc)}function IS(n,e){let{viewerWidth:t,viewerHeight:r}=n,i=Or(n,t/2,r/2);return qo(n,i.x,i.y,e)}function LS(n,e,t){return Xt(n,{mode:$r,startX:e,startY:t,endX:e,endY:t})}function OS(n,e,t){if(n.mode!==$r)throw new Error("update selection not allowed in this mode "+n.mode);return Xt(n,{endX:e,endY:t})}function Qf(n,e,t,r){let{startX:s,startY:o}=n,a=Or(n,s,o),l=Or(n,e,t);if(Math.abs(s-e)>7&&Math.abs(o-t)>7){let c=l1(a,l);return u1(n,c.x,c.y,c.width,c.height)}else{let c=Or(n,e,t);return qo(n,c.x,c.y,r)}}function qS(n,e,t,r,i){return r+(i-r)*(n-e)/(t-e)}function Do(n,e){let{left:t,top:r}=e.getBoundingClientRect(),i=n.clientX-Math.round(t),s=n.clientY-Math.round(r);return{x:i,y:s}}function f1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;switch(t){case vi:let c=Or(r,o,a);l=qo(r,c.x,c.y,1/i.scaleFactor);break;case Yr:l=LS(r,o,a);break;case Ir:case Lr:l=wS(r,o,a);break;default:return r}return n.preventDefault(),l}function d1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=n.buttons===0,c=r;switch(t){case Yr:r.mode===$r&&(c=l?Qf(r,o,a,i.scaleFactor):OS(r,o,a));break;case Ir:case Lr:r.mode===Xr&&(c=l?a1(r):TS(r,o,a,i.preventPanOutside?20:void 0));break;default:return r}return n.preventDefault(),c}function p1(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;switch(t){case vi:r.mode===$r&&(l=Qf(r,o,a,1/i.scaleFactor));break;case Yr:r.mode===$r&&(l=Qf(r,o,a,i.scaleFactor));break;case Ir:case Lr:r.mode===Xr&&(l=a1(r));break;default:return r}return n.preventDefault(),l}function DS(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);let l=r;if(t===Ir&&!i.disableDoubleClickZoomWithToolAuto){const{modifierKeys:c=[]}=i;let h=Or(r,o,a),f=(m,x)=>m||n.getModifierState(x),d=c.reduce(f,!1)?1/i.scaleFactor:i.scaleFactor;l=qo(r,h.x,h.y,d)}return n.preventDefault(),l}function NS(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Do(n,e);if(!i.detectWheel)return r;let l=Math.max(-1,Math.min(1,n.deltaY)),c=qS(l,-1,1,i.scaleFactorOnWheel,1/i.scaleFactorOnWheel),h=Or(r,o,a),f=qo(r,h.x,h.y,c);return n.preventDefault(),f}function m1(n,e,t,r,i){let s=gS(r,n.type==="mouseenter");return n.preventDefault(),s}function US(n,e,t,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:o,y:a}=s;return!([_i,Ir].indexOf(t)>=0)||!i.detectAutoPan||!r.focus?r:AS(r,o,a)}class FS extends s1{get point(){if(!this._cachePoint){const{originalEvent:e,SVGViewer:t,value:r}=this,i=Do(e,t);this._cachePoint=Or(r,i.x,i.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function g1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function _1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?g1(Object(t),!0).forEach(function(r){zS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):g1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function zS(n,e,t){return(e=kS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function kS(n){var e=BS(n,"string");return typeof e=="symbol"?e:e+""}function BS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Uc extends s1{get points(){return this._cachePoints||(this._cachePoints=Uc.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=Uc.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(e,t,r){let i=[];for(let s=0;s<e.length;s++){let o=e[s],a=t.getBoundingClientRect(),l=o.clientX-Math.round(a.left),c=o.clientY-Math.round(a.top),h=Or(r,l,c);i.push(_1(_1({},h),{},{identifier:o.identifier}))}return i}}function VS(n,e,t){let r=n.type;switch(r){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new FS(n,e,t);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new Uc(n,e,t);default:throw new Error(`${r} not supported`)}}function v1(n){return n.split(/[ ,]/).filter(Boolean).map(Number)}function x1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function y1(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?x1(Object(t),!0).forEach(function(r){HS(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):x1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function HS(n,e,t){return(e=GS(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function GS(n){var e=WS(n,"string");return typeof e=="symbol"?e:e+""}function WS(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function jS(n,e){let{left:t,top:r}=e.getBoundingClientRect(),i=n.clientX-Math.round(t),s=n.clientY-Math.round(r);return{x:i,y:s}}function XS(n,e,t,r,i){if(E1(n,i))return b1(n,e,t,r);if(n.touches.length!==1){if([Xr,$r].indexOf(r.mode)>=0)return i1(r);if([dr].indexOf(r.mode)>=0)return r}return ed(n,e,t,r,i,f1)}function $S(n,e,t,r,i){return E1(n,i)?b1(n,e,t,r):[Xr,$r].indexOf(r.mode)>=0?ed(n,e,t,r,i,d1):r}function YS(n,e,t,r,i){if(!([Xr,$r].indexOf(r.mode)>=0))return r;let s=ZS(n,r,i)?Xt(r,{pinchPointDistance:null}):r;return n.touches.length>0?s:ed(n,e,t,s,i,p1)}function KS(n,e,t,r,i){return n.stopPropagation(),n.preventDefault(),i1(r)}function S1(n){return typeof n.pinchPointDistance=="number"}function ZS(n,e,t){return t.detectPinchGesture&&S1(e)&&n.touches.length<2}function E1(n,e){return e.detectPinchGesture&&n.touches.length>1}function ed(n,e,t,r,i,s){let o=n.touches.length===0?Xt(r,{mode:r.prePinchMode?dr:r.mode,prePinchMode:null}):r,a=n.touches.length>0?n.touches[0]:n.changedTouches[0],l=jS(a,e);switch(t){case vi:case Yr:case Ir:case Lr:return n.stopPropagation(),n.preventDefault(),s(n,e,t,o,i,l);default:return o}}function b1(n,e,t,r,i){const{left:s,top:o}=e.getBoundingClientRect(),a=n.touches[0].clientX-Math.round(s),l=n.touches[0].clientY-Math.round(o),c=n.touches[1].clientX-Math.round(s),h=n.touches[1].clientY-Math.round(o),f=Math.sqrt(Math.pow(c-a,2)+Math.pow(h-l,2)),p=S1(r)?r.pinchPointDistance:f,d=Or(r,(a+c)/2,(l+h)/2);let m=f/p;if(Nc(r,m))return r;n.cancelable&&n.preventDefault();let x=Ui(ol(r),fr(d.x,d.y),zs(m,m),fr(-d.x,-d.y));return Xt(r,Xt(y1(y1({mode:$r},Jf(r,x)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:r.prePinchMode?r.prePinchMode:r.mode,pinchPointDistance:f})))}function M1(n){return Xt(n,{miniatureOpen:!0})}function w1(n){return Xt(n,{miniatureOpen:!1})}let JS=n=>["zoom-in","zoom-out","grab","grabbing"].indexOf(n)>-1,T1=()=>navigator.userAgent.toLowerCase(),QS=()=>T1().indexOf("firefox")>-1,eE=()=>T1().indexOf("webkit")>-1;function Fc(n){if(!JS(n))return n;if(QS())return`-moz-${n}`;if(eE())return`-webkit-${n}`}function tE(n){return n.displayName||n.name||"Component"}function td(){return td=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},td.apply(null,arguments)}let nE=1;const rE=()=>`uid${nE++}`;function A1(n){class e extends ne.Component{constructor(r){super(r),this.state={uid:rE()}}render(){return ne.createElement(n,td({_uid:this.state.uid},this.props))}}return e.displayName=`RandomUID(${tE(n)})`,e}const C1="react-svg-pan-zoom_border_gradient";function R1(n){let{direction:e,width:t,height:r,_uid:i}=n,s;switch(e){case xi:s=`translate(${t}, 0) rotate(90)`;break;case pr:s=`translate(${t}, ${r}) rotate(180)`;break;case yi:s=`translate(0, ${r}) rotate(270)`;break;case Hn:default:s=" ";break}let o=`${C1}_gradient_${i}`,a=`${C1}_mask_${i}`;return ne.createElement("g",null,ne.createElement("defs",null,ne.createElement("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},ne.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),ne.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),ne.createElement("mask",{id:a,x:"0",y:"0",width:"20",height:Math.max(t,r)},ne.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,r),style:{stroke:"none",fill:`url(#${o})`}}))),ne.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,r),style:{stroke:"none",fill:"#000",mask:`url(#${a})`},transform:s}))}R1.propTypes={direction:ve.oneOf([xi,pr,yi,Hn]).isRequired,width:ve.number.isRequired,height:ve.number.isRequired};const zc=A1(R1);function P1(n){let{startX:e,startY:t,endX:r,endY:i}=n;if(!e||!t||!r||!i)return null;let s=l1({x:e,y:t},{x:r,y:i});return ne.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:s.x,y:s.y,width:s.width,height:s.height,style:{pointerEvents:"none"}})}P1.propTypes={startX:ve.number,startY:ve.number,endX:ve.number,endY:ve.number};function iE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function sE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function oE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("g",null,ne.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),ne.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function aE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function lE(){return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let No=class extends ne.Component{constructor(e){super(e),this.state={hover:!1}}change(e){switch(e.preventDefault(),e.stopPropagation(),e.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let e={display:"block",width:"24px",height:"24px",margin:[xi,yi].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return ne.createElement("button",{onMouseEnter:t=>this.change(t),onMouseLeave:t=>this.change(t),onTouchStart:t=>{this.change(t),this.props.onClick(t)},onTouchEnd:t=>this.change(t),onTouchCancel:t=>this.change(t),onClick:this.props.onClick,style:e,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};No.propTypes={title:ve.string.isRequired,name:ve.string.isRequired,toolbarPosition:ve.string.isRequired,activeColor:ve.string.isRequired,onClick:ve.func.isRequired,active:ve.bool.isRequired};const cE="#1CA6FC";function I1(n){let{tool:e,value:t,onChangeValue:r,onChangeTool:i,activeToolColor:s=cE,position:o=pr,SVGAlignX:a=Io,SVGAlignY:l=Lo}=n,c=(d,m)=>{i(m),d.stopPropagation(),d.preventDefault()},h=d=>{r(h1(t,a,l)),d.stopPropagation(),d.preventDefault()},f=[xi,yi].indexOf(o)>=0,p={position:"absolute",transform:[xi,yi].indexOf(o)>=0?"translate(-50%, 0px)":"none",top:[Hn,pr,xi].indexOf(o)>=0?"5px":"unset",left:[xi,yi].indexOf(o)>=0?"50%":Hn===o?"5px":"unset",right:[pr].indexOf(o)>=0?"5px":"unset",bottom:[yi].indexOf(o)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:f?"row":"column",padding:f?"1px 2px":"2px 1px"};return ne.createElement("div",{style:p,role:"toolbar"},ne.createElement(No,{toolbarPosition:o,active:e===_i,activeColor:s,name:"unselect-tools",title:"Selection",onClick:d=>c(d,_i)},ne.createElement(iE,null)),ne.createElement(No,{toolbarPosition:o,active:e===Lr,activeColor:s,name:"select-tool-pan",title:"Pan",onClick:d=>c(d,Lr)},ne.createElement(sE,null)),ne.createElement(No,{toolbarPosition:o,active:e===Yr,activeColor:s,name:"select-tool-zoom-in",title:"Zoom in",onClick:d=>c(d,Yr)},ne.createElement(oE,null)),ne.createElement(No,{toolbarPosition:o,active:e===vi,activeColor:s,name:"select-tool-zoom-out",title:"Zoom out",onClick:d=>c(d,vi)},ne.createElement(aE,null)),ne.createElement(No,{toolbarPosition:o,active:!1,activeColor:s,name:"fit-to-viewer",title:"Fit to viewer",onClick:d=>h(d)},ne.createElement(lE,null)))}I1.propTypes={tool:ve.string.isRequired,onChangeTool:ve.func.isRequired,value:ve.object.isRequired,onChangeValue:ve.func.isRequired,position:ve.oneOf([xi,pr,yi,Hn]),SVGAlignX:ve.oneOf([Po,Io,Yf]),SVGAlignY:ve.oneOf([Po,Lo,Kf]),activeToolColor:ve.string};function uE(){return"ontouchstart"in window||navigator.maxTouchPoints}function L1(n){let{open:e,position:t}=n,r=0;switch(t){case Hn:r=e?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case pr:r=r=e?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return ne.createElement("svg",{width:24,height:24,stroke:"currentColor"},ne.createElement("g",{transform:r},ne.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}L1.propTypes={open:ve.bool.isRequired,position:ve.oneOf([pr,Hn]).isRequired};function O1(n){let{value:e,onChangeValue:t,position:r}=n,i={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[r===Hn?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},s=e.miniatureOpen?w1:M1;return ne.createElement("button",{type:"button",style:i,onClick:()=>t(s(e))},ne.createElement(L1,{open:e.miniatureOpen,position:r}))}O1.propTypes={value:ve.object.isRequired,onChangeValue:ve.func.isRequired,position:ve.oneOf([pr,Hn]).isRequired};const hE="react-svg-pan-zoom_miniature";function q1(n){let{SVGMinX:e,SVGMinY:t,SVGWidth:r,SVGHeight:i,x1:s,y1:o,x2:a,y2:l,zoomToFit:c,_uid:h}=n;const f=`${hE}_mask_${h}`;return ne.createElement("g",null,ne.createElement("defs",null,ne.createElement("mask",{id:f},ne.createElement("rect",{x:e,y:t,width:r,height:i,fill:"#ffffff"}),ne.createElement("rect",{x:s,y:o,width:a-s,height:l-o}))),ne.createElement("rect",{x:e,y:t,width:r,height:i,style:{stroke:"none",fill:"#000",mask:`url(#${f})`,opacity:.4}}))}q1.propTypes={SVGWidth:ve.number.isRequired,SVGHeight:ve.number.isRequired,SVGMinX:ve.number.isRequired,SVGMinY:ve.number.isRequired,x1:ve.number.isRequired,y1:ve.number.isRequired,x2:ve.number.isRequired,y2:ve.number.isRequired,zoomToFit:ve.number.isRequired};const fE=A1(q1),dE="#616264";function D1(n){let{value:e,onChangeValue:t,children:r,SVGBackground:i,background:s=dE,position:o=Hn,width:a=100,height:l=80}=n,{SVGMinX:c,SVGMinY:h,SVGWidth:f,SVGHeight:p,viewerWidth:d,viewerHeight:m}=e,x=p/f,v=x>=1?l/p:a/f,[{x:_,y:w},{x:E,y:S}]=Yg(Zg(e),[{x:0,y:0},{x:d,y:m}]),b,A;e.miniatureOpen?(b=a,A=l):(b=24,A=24);let q={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:b+"px",height:A+"px",bottom:"6px",[o===Hn?"left":"right"]:"6px",background:s},O=x>=1?`translate(${(a-f*v)/2-c*v}, ${-h*v})`:`translate(${-c*v}, ${(l-p*v)/2-h*v})`;return ne.createElement("div",{role:"navigation",style:q},ne.createElement("svg",{width:a,height:l,style:{pointerEvents:"none"}},ne.createElement("g",{transform:O},ne.createElement("g",{transform:`scale(${v}, ${v})`},ne.createElement("rect",{fill:i,x:c,y:h,width:f,height:p}),r,ne.createElement(fE,{SVGWidth:f,SVGHeight:p,SVGMinX:c,SVGMinY:h,x1:_,y1:w,x2:E,y2:S,zoomToFit:v})))),ne.createElement(O1,{value:e,onChangeValue:t,position:o}))}D1.propTypes={value:ve.object.isRequired,onChangeValue:ve.func.isRequired,SVGBackground:ve.string.isRequired,position:ve.oneOf([pr,Hn]),background:ve.string,width:ve.number,height:ve.number};function ks(n){return typeof n>"u"||n===null}const nd="https://github.com/chrvadala/react-svg-pan-zoom/blob/main"+"/docs/migrate-from-v2-to-v3.md";function pE(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${nd}`)}function mE(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${nd}`)}function gE(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${nd}`)}function N1(n){(ks(n.tool)||ks(n.value))&&pE(),(!ks(n.miniaturePosition)||!ks(n.miniatureBackground)||!ks(n.miniatureWidth)||!ks(n.miniatureHeight))&&mE(),ks(n.toolbarPosition)||gE()}function kc(){return kc=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},kc.apply(null,arguments)}function U1(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function _E(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?U1(Object(t),!0).forEach(function(r){vE(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):U1(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function vE(n,e,t){return(e=xE(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function xE(n){var e=yE(n,"string");return typeof e=="symbol"?e:e+""}function yE(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Bc extends ne.Component{constructor(e,t){const{width:r,height:i,scaleFactorMin:s,scaleFactorMax:o,children:a}=e,{viewBox:l}=a.props;let c;if(l){const[h,f,p,d]=v1(l);c=n1(r,i,h,f,p,d,s,o)}else{const{width:h,height:f}=a.props;c=n1(r,i,0,0,h,f,s,o)}super(e,t),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:c},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&N1(e)}componentDidUpdate(e){const t=this.getValue(),r=this.props;let i=t,s=!1;process.env.NODE_ENV!=="production"&&N1(r);const{viewBox:o}=r.children.props;if(o){const[a,l,c,h]=v1(o);(t.SVGMinX!==a||t.SVGMinY!==l||t.SVGWidth!==c||t.SVGHeight!==h)&&(i=r1(i,a,l,c,h),s=!0)}else{const{width:a,height:l}=r.children.props;(t.SVGWidth!==a||t.SVGHeight!==l)&&(i=r1(i,0,0,a,l),s=!0)}(e.width!==r.width||e.height!==r.height)&&(i=_S(i,r.width,r.height),s=!0),(e.scaleFactorMin!==r.scaleFactorMin||e.scaleFactorMax!==r.scaleFactorMax)&&(i=vS(i,r.scaleFactorMin,r.scaleFactorMax),s=!0),s&&this.setValue(i)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return mS(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:_i}setValue(e){let{onChangeValue:t,onZoom:r,onPan:i}=this.props;t&&t(e),e.lastAction&&(r&&e.lastAction===Oc&&r(e),i&&e.lastAction===al&&i(e))}pan(e,t){let r=Zf(this.getValue(),e,t);this.setValue(r)}zoom(e,t,r){let i=qo(this.getValue(),e,t,r);this.setValue(i)}fitSelection(e,t,r,i){let s=u1(this.getValue(),e,t,r,i);this.setValue(s)}fitToViewer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Io,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lo,r=h1(this.getValue(),e,t);this.setValue(r)}zoomOnViewerCenter(e){let t=IS(this.getValue(),e);this.setValue(t)}setPointOnViewerCenter(e,t,r){let i=xS(this.getValue(),e,t,r);this.setValue(i)}reset(){let e=yS(this.getValue());this.setValue(e)}openMiniature(){let e=M1(this.getValue());this.setValue(e)}closeMiniature(){let e=w1(this.getValue());this.setValue(e)}handleViewerEvent(e){let{props:t,ViewerDOM:r}=this;if(!([_i,Ir].indexOf(this.getTool())>=0)||e.target===r)return;let s={click:t.onClick,dblclick:t.onDoubleClick,mousemove:t.onMouseMove,mouseup:t.onMouseUp,mousedown:t.onMouseDown,touchstart:t.onTouchStart,touchmove:t.onTouchMove,touchend:t.onTouchEnd,touchcancel:t.onTouchCancel}[e.type];s&&s(VS(e,t.value,r))}autoPanLoop(){let e={x:this.state.pointerX,y:this.state.pointerY},t=US(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,e);this.getValue()!==t&&this.setValue(t),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(e){let t=NS(e,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==t&&this.setValue(t)}render(){let{props:e,state:{pointerX:t,pointerY:r}}=this,i=this.getTool(),s=this.getValue(),{customToolbar:o=I1,customMiniature:a=D1}=e,l=i===Ir&&s.mode===Xr&&s.startX!==s.endX&&s.startY!==s.endY,c;i===Lr&&(c=Fc(s.mode===Xr?"grabbing":"grab")),i===Yr&&(c=Fc("zoom-in")),i===vi&&(c=Fc("zoom-out")),l&&(c=Fc("grabbing"));let h=[Lr,Yr,vi].indexOf(i)>=0;h=h||l;const f=this.props.detectPinchGesture||[Lr,Ir].indexOf(this.getTool())!==-1?"none":void 0,p={display:"block",cursor:c,touchAction:f};return ne.createElement("div",{style:_E({position:"relative",width:s.viewerWidth,height:s.viewerHeight},e.style),className:this.props.className},ne.createElement("svg",{ref:d=>this.ViewerDOM=d,width:s.viewerWidth,height:s.viewerHeight,style:p,onMouseDown:d=>{let m=f1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onMouseMove:d=>{let{left:m,top:x}=this.ViewerDOM.getBoundingClientRect(),v=d.clientX-Math.round(m),_=d.clientY-Math.round(x),w=d1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x:v,y:_});this.getValue()!==w&&this.setValue(w),this.setState({pointerX:v,pointerY:_}),this.handleViewerEvent(d)},onMouseUp:d=>{let m=p1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onClick:d=>{this.handleViewerEvent(d)},onDoubleClick:d=>{let m=DS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onMouseEnter:d=>{if(uE())return;let m=m1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onMouseLeave:d=>{let m=m1(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onTouchStart:d=>{let m=XS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchMove:d=>{let m=$S(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchEnd:d=>{let m=YS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)},onTouchCancel:d=>{let m=KS(d,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(d)}},ne.createElement("rect",{fill:e.background,x:0,y:0,width:s.viewerWidth,height:s.viewerHeight,style:{pointerEvents:"none"}}),ne.createElement("g",{transform:cS(s),style:h?{pointerEvents:"none"}:{}},ne.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:s.SVGMinX||0,y:s.SVGMinY||0,width:s.SVGWidth,height:s.SVGHeight}),ne.createElement("g",null,e.children.props.children)),[_i,Ir].indexOf(i)>=0&&e.detectAutoPan&&s.focus?ne.createElement("g",{style:{pointerEvents:"none"}},r<=20?ne.createElement(zc,{direction:xi,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerWidth-t<=20?ne.createElement(zc,{direction:pr,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerHeight-r<=20?ne.createElement(zc,{direction:yi,width:s.viewerWidth,height:s.viewerHeight}):null,s.focus&&t<=20?ne.createElement(zc,{direction:Hn,width:s.viewerWidth,height:s.viewerHeight}):null):null,s.mode!==$r?null:ne.createElement(P1,{startX:s.startX,startY:s.startY,endX:s.endX,endY:s.endY})),e.toolbarProps.position===Lc?null:ne.createElement(o,kc({},this.props.toolbarProps,{value:s,onChangeValue:d=>this.setValue(d),tool:i,onChangeTool:d=>this.props.onChangeTool(d)})),e.miniatureProps.position===Lc?null:ne.createElement(a,kc({},this.props.miniatureProps,{value:s,onChangeValue:d=>this.setValue(d),SVGBackground:this.props.SVGBackground}),e.children.props.children))}}Bc.propTypes={width:ve.number.isRequired,height:ve.number.isRequired,value:ve.oneOfType([ve.object,ve.shape({version:ve.oneOf([2]).isRequired,mode:ve.oneOf([dr,Xr,$r]).isRequired,focus:ve.bool.isRequired,a:ve.number.isRequired,b:ve.number.isRequired,c:ve.number.isRequired,d:ve.number.isRequired,e:ve.number.isRequired,f:ve.number.isRequired,viewerWidth:ve.number.isRequired,viewerHeight:ve.number.isRequired,SVGMinX:ve.number.isRequired,SVGMinY:ve.number.isRequired,SVGWidth:ve.number.isRequired,SVGHeight:ve.number.isRequired,startX:ve.number,startY:ve.number,endX:ve.number,endY:ve.number,miniatureOpen:ve.bool.isRequired})]).isRequired,onChangeValue:ve.func.isRequired,tool:ve.oneOf([Ir,_i,Lr,Yr,vi]).isRequired,onChangeTool:ve.func.isRequired,background:ve.string,SVGBackground:ve.string,SVGStyle:ve.object,style:ve.object,className:ve.string,detectWheel:ve.bool,detectAutoPan:ve.bool,detectPinchGesture:ve.bool,onZoom:ve.func,onPan:ve.func,onClick:ve.func,onDoubleClick:ve.func,onMouseUp:ve.func,onMouseMove:ve.func,onMouseDown:ve.func,preventPanOutside:ve.bool,scaleFactor:ve.number,scaleFactorOnWheel:ve.number,scaleFactorMax:ve.number,scaleFactorMin:ve.number,modifierKeys:ve.array,disableDoubleClickZoomWithToolAuto:ve.bool,customMiniature:ve.oneOfType([ve.element,ve.func]),miniatureProps:ve.shape({position:ve.oneOf([Lc,pr,Hn]),background:ve.string,width:ve.number,height:ve.number}),customToolbar:ve.oneOfType([ve.element,ve.func]),toolbarProps:ve.shape({position:ve.oneOf([Lc,xi,pr,yi,Hn]),SVGAlignX:ve.oneOf([Po,Io,Yf]),SVGAlignY:ve.oneOf([Po,Lo,Kf]),activeToolColor:ve.string}),children:function(n,e,t){let r=n[e],i=["svg"];if(ne.Children.count(r)!==1||i.indexOf(r.type)===-1)return new Error("`"+t+"` should have a single child of the following types: `"+i.join("`, `")+"`.");if((!r.props.hasOwnProperty("width")||!r.props.hasOwnProperty("height"))&&!r.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},Bc.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const SE=["width","height","onChangeTool","onChangeValue"];function rd(){return rd=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},rd.apply(null,arguments)}function EE(n,e){if(n==null)return{};var t,r,i=bE(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)t=s[r],e.includes(t)||{}.propertyIsEnumerable.call(n,t)&&(i[t]=n[t])}return i}function bE(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.includes(r))continue;t[r]=n[r]}return t}class ME extends ne.Component{constructor(e){super(e),this.state={value:e.defaultValue||{},tool:e.defaultTool||_i},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(e){this.setState({tool:e})}changeValue(e){this.setState({value:e})}pan(e,t){this.Viewer.pan(e,t)}zoom(e,t,r){this.Viewer.zoom(e,t,r)}fitSelection(e,t,r,i){this.Viewer.fitSelection(e,t,r,i)}fitToViewer(e,t){this.Viewer.fitToViewer(e,t)}zoomOnViewerCenter(e){this.Viewer.zoomOnViewerCenter(e)}setPointOnViewerCenter(e,t,r){this.Viewer.setPointOnViewerCenter(e,t,r)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const e=this.props,{width:t,height:r,onChangeTool:i,onChangeValue:s}=e,o=EE(e,SE),{tool:a,value:l}=this.state;return ne.createElement(Bc,rd({width:t,height:r,tool:a,onChangeTool:this.changeTool,value:l,onChangeValue:this.changeValue,ref:c=>this.Viewer=c},o))}}ME.propTypes={width:ve.number.isRequired,height:ve.number.isRequired,defaultValue:ve.object,defaultTool:ve.string};const Ht=K2(n=>({planner:new Sc,viewer:null,plan:null,toast:null,showDimensions:!1,activeFloor:0,setViewer:e=>{n(t=>({...t,viewer:e}))},setToast:e=>{n(t=>({...t,toast:e}))},setActiveFloor:e=>{n(t=>({...t,activeFloor:e}))},newProject:()=>{n(e=>({...e,planner:qt.newProject(e.planner).updatedState}))},selectTool3DView:()=>{n(e=>{const r=qt.unselectAll(e.planner).updatedState.set("mode",Tr);return{...e,planner:r,showDimensions:!1}})},selectTool3DFirstPerson:()=>{n(e=>{const r=qt.rollback(e.planner).updatedState.set("mode",Ao);return{...e,planner:r}})},loadProject:e=>{n(t=>{const r=new Sc({scene:e,catalog:t.planner.catalog.toJS()});return{...t,planner:r}})},undo:()=>{n(e=>{const t=qt.undo(e.planner).updatedState;return{...e,planner:t}})},redo:()=>{n(e=>{const t=qt.redo(e.planner).updatedState;return{...e,planner:t}})},addLayer:(e,t)=>{n(r=>{const i=it.create(r.planner,e,t).updatedState;return{...r,planner:i}})},removeLayer:e=>{n(t=>{const r=it.remove(t.planner,e).updatedState;return{...t,planner:r}})},addGroup:()=>{n(e=>{const t=mn.create(e.planner).updatedState;return{...e,planner:t}})},selectGroup:e=>{n(t=>{const r=mn.select(t.planner,e).updatedState;return{...t,planner:r}})},setGroupProperties:(e,t)=>{n(r=>{const i=mn.setProperties(r.planner,e,t).updatedState;return{...r,planner:i}})},addToGroup:(e,t,r,i)=>{n(s=>{const o=mn.addElement(s.planner,e,t,r,i).updatedState;return{...s,planner:o}})},removeGroup:e=>{n(t=>{const r=mn.remove(t.planner,e).updatedState;return{...t,planner:r}})},setGroupAttributes:(e,t)=>{n(r=>{const i=mn.setAttributes(r.planner,e,t).updatedState;return{...r,planner:i}})},groupTranslate:(e,t,r)=>{n(i=>{const s=mn.translate(i.planner,e,t,r).updatedState;return{...i,planner:s}})},removeFromGroup:(e,t,r,i)=>{n(s=>{const o=mn.removeElement(s.planner,e,t,r,i).updatedState;return{...s,planner:o}})},groupRotate:(e,t)=>{n(r=>{const i=mn.rotate(r.planner,e,t).updatedState;return{...r,planner:i}})},removeGroupAndDeleteElements:e=>{n(t=>{const r=mn.removeAndDeleteElements(t.planner,e).updatedState;return{...t,planner:r}})},addGroupFromSelected:()=>{n(e=>{const t=mn.createFromSelectedElements(e.planner).updatedState;return{...e,planner:t}})},copyProperties:e=>{n(t=>({...t,planner:qt.copyProperties(t.planner,e).updatedState}))},setProjectProperties:e=>{n(t=>({...t,planner:qt.setProjectProperties(t.planner,e).updatedState}))},pasteProperties:()=>{n(e=>{const t=e.planner.merge({sceneHistory:on(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.pasteProperties(t).updatedState}})},setProperties:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setProperties(r,r.getIn(["scene","selectedLayer"]),e).updatedState}})},setHolesAttributes:e=>{n(t=>{const r=e.set("offset",parseFloat(e.get("offset"))),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setHolesAttributes(i,r).updatedState}})},setLinesAttributes:e=>{n(t=>{const r=e.withMutations(s=>{s.setIn(["vertexOne","x"],parseFloat(e.getIn(["vertexOne","x"]))),s.setIn(["vertexOne","y"],parseFloat(e.getIn(["vertexOne","y"]))),s.setIn(["vertexTwo","x"],parseFloat(e.getIn(["vertexTwo","x"]))),s.setIn(["vertexTwo","y"],parseFloat(e.getIn(["vertexTwo","y"])))}),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setLinesAttributes(i,r).updatedState}})},setItemsAttributes:e=>{n(t=>{const r=e.set("rotation",parseFloat(e.get("rotation"))),i=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.setItemsAttributes(i,r).updatedState}})},selectLine:(e,t)=>{n(r=>{const i=Jt.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectHole:(e,t)=>{n(r=>{const i=pn.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectItem:(e,t)=>{n(r=>{const i=xn.select(r.planner,e,t).updatedState;return{...r,planner:i}})},selectLayer:e=>{n(t=>{const r=it.select(t.planner,e).updatedState;return{...t,planner:r}})},setLayerProperties:(e,t)=>{n(r=>{const i=it.setProperties(r.planner,e,t).updatedState;return{...r,planner:i}})},addVerticalGuide:e=>{n(t=>{const r=Ac.create(t.planner,e).updatedState;return{...t,planner:r}})},addHorizontalGuide:e=>{n(t=>{const r=Tc.create(t.planner,e).updatedState;return{...t,planner:r}})},removeVerticalGuide:e=>{n(t=>{const r=Ac.remove(t.planner,e).updatedState;return{...t,planner:r}})},removeHorizontalGuide:e=>{n(t=>{const r=Tc.remove(t.planner,e).updatedState;return{...t,planner:r}})},toggleSnap:e=>{n(t=>{const r=qt.toggleSnap(t.planner,e).updatedState;return{...t,planner:r}})},openProjectConfigurator:()=>{n(e=>{const t=qt.openProjectConfigurator(e.planner).updatedState;return{...e,planner:t}})},setMode:e=>{n(t=>{const r=t.planner.set("mode",e);return{...t,planner:r}})},updateZoomScale:e=>{n(t=>({...t,planner:qt.updateZoomScale(t.planner,e).updatedState}))},updateCameraView:e=>{n(t=>{const r=t.planner.update("viewer2D",i=>i.merge(At(e)));return{...t,planner:r}})},selectToolPan:()=>{n(e=>{const t=e.planner.set("mode",Ns);return{...e,planner:t}})},selectToolEdit:()=>{n(e=>({...e,planner:qt.setMode(e.planner,sn).updatedState}))},selectToolZoomIn:()=>{n(e=>{const t=e.planner.set("mode",qs);return{...e,planner:t}})},selectToolZoomOut:()=>{n(e=>{const t=e.planner.set("mode",Ds);return{...e,planner:t}})},updateDrawingLine:(e,t)=>{n(r=>({...r,planner:Jt.updateDrawingLine(r.planner,e,t).updatedState}))},updateDrawingSurface:(e,t)=>{n(r=>({...r,planner:Cc.updateDrawingSurface(r.planner,e,t).updatedState}))},updateMouseCoord:e=>{n(t=>({...t,planner:qt.updateMouseCoord(t.planner,e).updatedState}))},openCatalog:()=>{n(e=>{const t=e.planner.set("mode",cf);return{...e,planner:t}})},updateDrawingHole:(e,t,r)=>{n(i=>({...i,planner:pn.updateDrawingHole(i.planner,e,t,r).updatedState}))},updateDrawingItem:(e,t,r)=>{n(i=>({...i,planner:xn.updateDrawingItem(i.planner,e,t,r).updatedState}))},blur:()=>{n(e=>{const t=e.planner.merge({mode:sn,activeSnapElement:null});return{...e,planner:t}})},updateDraggingHole:(e,t)=>{n(r=>({...r,planner:pn.updateDraggingHole(r.planner,e,t).updatedState}))},updateDraggingLine:(e,t)=>{n(r=>({...r,planner:Jt.updateDraggingLine(r.planner,e,t).updatedState}))},updateDraggingVertex:(e,t)=>{n(r=>({...r,planner:cn.updateDraggingVertex(r.planner,e,t).updatedState}))},updateDraggingItem:(e,t)=>{n(r=>({...r,planner:xn.updateDraggingItem(r.planner,e,t).updatedState}))},updateRotatingItem:(e,t)=>{n(r=>({...r,planner:xn.updateRotatingItem(r.planner,e,t).updatedState}))},beginDraggingLine:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Jt.beginDraggingLine(o,e,t,r,i).updatedState}})},endDraggingLine:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Jt.endDraggingLine(i,e,t).updatedState}})},beginDraggingVertex:(e,t)=>{n(r=>({...r,planner:cn.beginDraggingVertex(r.planner,e,t).updatedState}))},endDraggingVertex:()=>{n(e=>({...e,planner:cn.endDraggingVertex(e.planner).updatedState}))},beginRotatingItem:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xn.beginRotatingItem(o,e,t,r,i).updatedState}})},endRotatingItem:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xn.endRotatingItem(i,e,t).updatedState}})},beginDraggingItem:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xn.beginDraggingItem(o,e,t,r,i).updatedState}})},endDraggingItem:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xn.endDraggingItem(i,e,t).updatedState}})},beginDraggingHole:(e,t,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:on(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:pn.beginDraggingHole(o,e,t,r,i).updatedState}})},endDraggingHole:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:pn.endDraggingHole(i,e,t).updatedState}})},beginDrawingLine:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Jt.beginDrawingLine(s,e,t,r).updatedState}})},endDrawingLine:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Jt.endDrawingLine(i,e,t).updatedState}})},beginDrawingSurface:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Cc.beginDrawingSurface(s,e,t,r).updatedState}})},endDrawingSurface:(e,t)=>{n(r=>{const i=r.planner.merge({sceneHistory:on(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Cc.endDrawingSurface(i,e,t).updatedState}})},endDrawingHole:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:pn.endDrawingHole(s,e,t,r).updatedState}})},endDrawingItem:(e,t,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:on(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:xn.endDrawingItem(s,e,t,r).updatedState}})},selectArea:(e,t)=>{n(r=>({...r,planner:Fs.select(r.planner,e,t).updatedState}))},initCatalog:e=>{n(t=>({...t,planner:qt.initCatalog(t.planner,e).updatedState}))},goBackToCatalogPage:e=>{n(t=>({...t,planner:qt.goBackToCatalogPage(t.planner,e).updatedState}))},pushLastSelectedCatalogElementToHistory:e=>{n(t=>({...t,planner:qt.pushLastSelectedCatalogElementToHistory(t.planner,e).updatedState}))},selectToolDrawingLine:e=>{n(t=>({...t,planner:Jt.selectToolDrawingLine(t.planner,e).updatedState}))},selectToolDrawingSurface:e=>{n(t=>({...t,planner:Cc.selectToolDrawingSurface(t.planner,e).updatedState}))},selectToolDrawingItem:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:xn.selectToolDrawingItem(r,e).updatedState}})},selectToolDrawingHole:e=>{n(t=>{const r=t.planner.merge({sceneHistory:on(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:pn.selectToolDrawingHole(r,e).updatedState}})},changeCatalogPage:(e,t)=>{n(r=>({...r,planner:qt.changeCatalogPage(r.planner,t,e).updatedState}))},remove:()=>{n(e=>{const t=e.planner.merge({sceneHistory:on(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.remove(t).updatedState}})},rollback:()=>{n(e=>({...e,planner:qt.rollback(e.planner).updatedState}))},setAlterateState:()=>{n(e=>({...e,planner:qt.setAlterate(e.planner).updatedState}))},setPlan:e=>{n(t=>({...t,plan:e}))},unselectAll:()=>{n(e=>({...e,planner:qt.unselectAll(e.planner).updatedState}))},setShowDimensions:e=>{n(t=>({...t,showDimensions:e}))}})),ll={stroke:"#D32F2F",strokeWidth:"1px"};function wE({snap:n,width:e,height:t}){switch(n.type){case"point":return R.jsxs("g",{transform:`translate(${n.x} ${n.y})`,children:[R.jsx("line",{x1:"0",y1:"-70",x2:"0",y2:"70",style:ll}),R.jsx("line",{x1:"-70",y1:"0",x2:"70",y2:"0",style:ll})]});case"line":let r=gc(0),i=gc(t),s=il(n.a,n.b,n.c,r.a,r.b,r.c),o=il(n.a,n.b,n.c,i.a,i.b,i.c),a=_c(0),l=_c(e),c=il(n.a,n.b,n.c,a.a,a.b,a.c),h=il(n.a,n.b,n.c,l.a,l.b,l.c);return s&&o?R.jsx("line",{x1:s.x,y1:s.y,x2:o.x,y2:o.y,style:ll}):c&&h?R.jsx("line",{x1:c.x,y1:c.y,x2:h.x,y2:h.y,style:ll}):null;case"line-segment":return R.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,style:ll});default:return null}}const Vc={white:"#FFFFFF",black:"#000000"},F1={500:{orange:"#FF9800"}},TE={alt:"#2E2F33",text_main:Vc.white},AE={main:"#1CA6FC"},id="#99C3FB",Lt={COLORS:Vc,PRIMARY_COLOR:TE,SECONDARY_COLOR:AE,MESH_SELECTED:id,AREA_MESH_COLOR:{selected:id,unselected:"#F5F4F4"},LINE_MESH_COLOR:{selected:id}};function CE({width:n,height:e,grid:t}){let r=t.properties.get("step"),i;t.properties.has("color")?i=He([t.properties.get("color")]):i=t.properties.get("colors");let s=[],o=0;for(let a=0;a<=e;a+=r){let l=i.get(o%i.size);o++,s.push(R.jsx("line",{x1:"0",y1:a,x2:n,y2:a,strokeWidth:"1",stroke:l},a))}return R.jsx("g",{children:s})}function RE({width:n,height:e,grid:t}){let r=t.properties.get("step"),i;t.properties.has("color")?i=He([t.properties.get("color")]):i=t.properties.get("colors");let s=[],o=0;for(let a=0;a<=n;a+=r){let l=i.get(o%i.size);o++,s.push(R.jsx("line",{x1:a,y1:"0",x2:a,y2:e,strokeWidth:"1",stroke:l},a))}return R.jsx("g",{children:s})}function PE({scene:n}){let{width:e,height:t,grids:r}=n,i=r.entrySeq().map(([s,o])=>{switch(o.type){case"horizontal-streak":return R.jsx(CE,{width:e,height:t,grid:o},s);case"vertical-streak":return R.jsx(RE,{width:e,height:t,grid:o},s);default:console.warn(`grid ${o.type} not allowed`)}}).toList();return R.jsx("g",{children:i})}class IE{constructor(e=[],t=(r,i)=>r<i?-1:r>i?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const s=e-1>>1,o=t[s];if(r(i,o)>=0)break;t[e]=o,e=s}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,s=t[e];for(;e<i;){let o=(e<<1)+1;const a=o+1;if(a<this.length&&r(t[a],t[o])<0&&(o=a),r(t[o],s)>=0)break;t[e]=t[o],e=o}t[e]=s}}function LE(n,e=1,t=!1){let r=1/0,i=1/0,s=-1/0,o=-1/0;for(const[_,w]of n[0])_<r&&(r=_),w<i&&(i=w),_>s&&(s=_),w>o&&(o=w);const a=s-r,l=o-i,c=Math.max(e,Math.min(a,l));if(c===e){const _=[r,i];return _.distance=0,_}const h=new IE([],(_,w)=>w.max-_.max);let f=qE(n);const p=new Hc(r+a/2,i+l/2,0,n);p.d>f.d&&(f=p);let d=2;function m(_,w,E){const S=new Hc(_,w,E,n);d++,S.max>f.d+e&&h.push(S),S.d>f.d&&(f=S,t&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${d} probes`))}let x=c/2;for(let _=r;_<s;_+=c)for(let w=i;w<o;w+=c)m(_+x,w+x,x);for(;h.length;){const{max:_,x:w,y:E,h:S}=h.pop();if(_-f.d<=e)break;x=S/2,m(w-x,E-x,x),m(w+x,E-x,x),m(w-x,E+x,x),m(w+x,E+x,x)}t&&console.log(`num probes: ${d}
70
+ best distance: ${f.d}`);const v=[f.x,f.y];return v.distance=f.d,v}function Hc(n,e,t,r){this.x=n,this.y=e,this.h=t,this.d=OE(n,e,r),this.max=this.d+this.h*Math.SQRT2}function OE(n,e,t){let r=!1,i=1/0;for(const s of t)for(let o=0,a=s.length,l=a-1;o<a;l=o++){const c=s[o],h=s[l];c[1]>e!=h[1]>e&&n<(h[0]-c[0])*(e-c[1])/(h[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,DE(n,e,c,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function qE(n){let e=0,t=0,r=0;const i=n[0];for(let o=0,a=i.length,l=a-1;o<a;l=o++){const c=i[o],h=i[l],f=c[0]*h[1]-h[0]*c[1];t+=(c[0]+h[0])*f,r+=(c[1]+h[1])*f,e+=f*3}const s=new Hc(t/e,r/e,0,n);return e===0||s.d<0?new Hc(i[0][0],i[0][1],0,n):s}function DE(n,e,t,r){let i=t[0],s=t[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){const l=((n-i)*o+(e-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=e-s,o*o+a*a}function z1(n,e){var t=n.length,r=0;n=n.map(NE),n[0]!=n[n.length-1]&&(n=n.concat(n[0]));for(var i=0;i<t;i++)r+=n[i].x*n[i+1].y-n[i].y*n[i+1].x;return Math.abs(r)/2}function NE(n){return Array.isArray(n)?{x:n[0],y:n[1]}:n}const UE={textAnchor:"middle",fontSize:"12px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function FE({layer:n,area:e,catalog:t}){let r=t.getElement(e.type).render2D(e,n),i=null;if(e.selected){let s=e.vertices.toArray().map(c=>{let{x:h,y:f}=n.vertices.get(c);return[h,f]}),o=s;e.holes.forEach(c=>{let h=n.areas.get(c).vertices.toArray().map(f=>{let{x:p,y:d}=n.vertices.get(f);return[p,d]});o=o.concat(h.reverse())});let a=LE([o],1),l=z1(s);e.holes.forEach(c=>{let f=n.areas.get(c).vertices.toArray().map(p=>{let{x:d,y:m}=n.vertices.get(p);return[d,m]});l-=z1(f)}),i=R.jsxs("text",{x:"0",y:"0",transform:`translate(${a[0]} ${a[1]}) scale(1, -1)`,style:UE,children:[(l/1e4).toFixed(2)," m","²"]})}return R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,children:[r,i]})}const zE=0,kE=0,BE=5,VE={fill:F1[500].orange,stroke:F1[500].orange,cursor:"default"};function HE({layer:n,group:e}){return R.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${e.x},${e.y}) rotate(${e.rotation})`,children:e.selected&&R.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:R.jsx("circle",{cx:zE,cy:kE,r:BE,style:VE,children:R.jsx("title",{children:"Group's Barycenter"})})})})}const GE={fill:"#0096fd",stroke:"#0096fd",cursor:"ew-resize"},WE={fill:"none",stroke:"#0096fd",cursor:"ew-resize"};function jE({layer:n,item:e,scene:t,catalog:r}){let{x:i,y:s,rotation:o}=e,a=r.getElement(e.type).render2D(e,n,t);return R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${i},${s}) rotate(${o})`,children:[a,e.selected&&R.jsxs("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:[R.jsx("circle",{cx:"0",cy:"100",r:"10",style:GE}),R.jsx("circle",{cx:"0",cy:"0",r:"100",style:WE})]})]})}const XE={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},$E={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},YE={metric:XE,imperial:$E,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},KE={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},ZE={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},JE={metric:KE,imperial:ZE,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},QE={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},eb={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},tb={metric:QE,imperial:eb,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},nb={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},rb={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},ib={metric:nb,imperial:rb,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},sb={metric:{ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},ob={metric:{C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial:{F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},_anchors:{metric:{unit:"C",transform:function(n){return n/(5/9)+32}},imperial:{unit:"F",transform:function(n){return(n-32)*(5/9)}}}},k1=365.25,ab={metric:{ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*k1/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*k1}},_anchors:{metric:{unit:"s",ratio:1}}},lb={bits:{b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes:{B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},cb={metric:{ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},ub={metric:{"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial:{"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},hb={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},fb={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},db={metric:hb,imperial:fb,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},pb={metric:{A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},_anchors:{metric:{unit:"A",ratio:1}}},mb={metric:{V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},_anchors:{metric:{unit:"V",ratio:1}}},gb={metric:{W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},_anchors:{metric:{unit:"W",ratio:1}}},_b={metric:{VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},_anchors:{metric:{unit:"VAR",ratio:1}}},vb={metric:{VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},_anchors:{metric:{unit:"VA",ratio:1}}},xb={metric:{Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},_anchors:{metric:{unit:"J",ratio:1}}},yb={metric:{VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},_anchors:{metric:{unit:"VARh",ratio:1}}},Sb={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},Eb={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},bb={metric:Sb,imperial:Eb,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},Mb={metric:{lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial:{"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},wb={metric:{mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},_anchors:{frequency:{unit:"hz",ratio:1}}},ls={length:YE,area:JE,mass:tb,volume:ib,each:sb,temperature:ob,time:ab,digital:lb,partsPer:cb,speed:ub,pressure:db,current:pb,voltage:mb,power:gb,reactivePower:_b,apparentPower:vb,energy:xb,reactiveEnergy:yb,volumeFlowRate:bb,illuminance:Mb,frequency:wb};function cl(n){return Object.keys(n)}function B1(n){return{abbr:n.abbr,measure:n.measure,system:n.system,singular:n.unit.name.singular,plural:n.unit.name.plural}}function qr(n,e){if(Array.isArray(n))for(let t=0;t<n.length;t++)e(n[t],t,n);else if(n&&typeof n=="object")for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(n[t],t,n)}class Tb{constructor(e,t){ht(this,"val");ht(this,"destination");ht(this,"origin");this.val=t?e/t:e}from(e){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(e),this.origin||this.throwUnsupportedUnitError(e),this}to(e){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(e),this.destination||this.throwUnsupportedUnitError(e),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let t=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(t-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const r=ls[this.origin.measure]._anchors[this.origin.system];t=typeof r.transform=="function"?r.transform(t):t*r.ratio}return this.destination.unit.anchor_shift&&(t+=this.destination.unit.anchor_shift),t/this.destination.unit.to_anchor}toBest(e){if(!this.origin)throw new Error(".toBest must be called after .from");const t={exclude:[],cutOffNumber:1,...e};let r=null;return qr(this.possibilities(),i=>{if(t.exclude.includes(i))return;const s=this.describe(i);if(s.system!==this.origin.system)return;const o=this.to(i);(!r||o>=t.cutOffNumber&&o<r.val)&&(r={val:o,unit:i,singular:s.singular,plural:s.plural})}),r}getUnit(e){let t=null;return qr(ls,(r,i)=>{qr(r,(s,o)=>{o!=="_anchors"&&qr(s,(a,l)=>{l===e&&(t={abbr:e,measure:i,system:o,unit:a})})})}),t}describe(e){const t=this.getUnit(e);return t||this.throwUnsupportedUnitError(e),B1(t)}list(e){const t=[];return qr(ls,(r,i)=>{e&&e!==i||qr(r,(s,o)=>{o!=="_anchors"&&qr(s,(a,l)=>{t.push(B1({abbr:l,measure:i,system:o,unit:a}))})})}),t}throwUnsupportedUnitError(e){const t=[];throw qr(ls,r=>{qr(r,(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})}),new Error(`Unsupported unit ${e}, use one of: ${t.join(", ")}`)}possibilities(e){const t=[];if(!this.origin&&!e)qr(cl(ls),r=>{qr(ls[r],(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})});else{const r=e||this.origin.measure;qr(ls[r],(i,s)=>{s!=="_anchors"&&t.push(...cl(i))})}return t}measures(){return cl(ls)}}function Kr(n){return new Tb(n)}const sd={stroke:"#0096fd",strokeWidth:"1px"},Ab={textAnchor:"middle",fontSize:"16px",fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function Cb({length:n,unit:e,transform:t}){let r=`${e!==Rr?Kr(n).from(Rr).to(e).toFixed(2):n.toFixed(2)} ${e}`;return R.jsxs("g",{transform:t,children:[R.jsx("text",{x:n/2,y:"-12",transform:"scale(1, -1)",style:Ab,children:r}),R.jsx("line",{x1:"0",y1:"-5",x2:"0",y2:"5",style:sd}),R.jsx("line",{x1:n,y1:"-5",x2:n,y2:"5",style:sd}),R.jsx("line",{x1:"0",y1:"0",x2:n,y2:"0",style:sd})]})}const Rb=({line:n,layer:e,scene:t,catalog:r,mode:i,showDimensions:s})=>{let o=e.vertices.get(n.vertices.get(0)),a=e.vertices.get(n.vertices.get(1));if(o.id===a.id||jr(o,a))return null;let{x:l,y:c}=o,{x:h,y:f}=a;l>h&&({x:l,y:c}=a,{x:h,y:f}=o);let p=Cn(l,c,h,f),d=r3(l,c,h,f),m=n.holes.map(E=>{let S=e.holes.get(E),b=p*S.offset,A=r.getElement(S.type).render2D(S,e,t);return R.jsx("g",{transform:`translate(${b}, 0)`,"data-element-root":!0,"data-prototype":S.prototype,"data-id":S.id,"data-selected":S.selected,"data-layer":e.id,children:A},E)}),v=(n.getIn(["properties","thickness","length"])??0)/2,_=r.getElement(n.type).render2D(n,e,t,i),w=n.selected||s?R.jsx(Cb,{unit:t.unit,length:p,transform:`translate(0, ${v+10} )`}):null;return R.jsxs("g",{transform:`translate(${l}, ${c}) rotate(${d}, 0, 0)`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":e.id,style:n.selected?{cursor:"move"}:{},children:[w,_,m]})},Pb={fill:"#0096fd",stroke:Lt.COLORS.white,cursor:"move"},Ib=({vertex:n,layer:e})=>R.jsx("g",{transform:`translate(${n.x}, ${n.y})`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":e.id,children:R.jsx("circle",{cx:"0",cy:"0",r:"7",style:Pb})});function V1({layer:n,scene:e,catalog:t,mode:r,showDimensions:i}){const{groups:s}=e,{lines:o,areas:a,vertices:l,id:c,items:h,opacity:f}=n;return R.jsxs("g",{opacity:f,children:[a.valueSeq().map(p=>R.jsx(FE,{layer:n,area:p,catalog:t},p.id)),o.valueSeq().map(p=>R.jsx(Rb,{mode:r,showDimensions:i,layer:n,line:p,scene:e,catalog:t},p.id)),h.valueSeq().map(p=>R.jsx(jE,{layer:n,item:p,scene:e,catalog:t},p.id)),l.valueSeq().filter(p=>p.selected).map(p=>R.jsx(Ib,{layer:n,vertex:p},p.id)),s.valueSeq().filter(p=>p.hasIn(["elements",c])&&p.get("selected")).map(p=>R.jsx(HE,{layer:n,group:p,scene:e,catalog:t},p.get("id")))]})}const Lb=({scene:n,catalog:e,mode:t,showDimensions:r})=>{const{layers:i}=n,s=i.get(n.selectedLayer);return R.jsxs("g",{children:[R.jsx(PE,{scene:n}),R.jsx("g",{style:{pointerEvents:"none"},children:i.entrySeq().filter(([o,a])=>o!==n.selectedLayer&&a.visible).map(([o,a])=>R.jsx(V1,{mode:t,layer:a,scene:n,showDimensions:r,catalog:e},o))}),R.jsx(V1,{mode:t,layer:s,scene:n,showDimensions:r,catalog:e},s.id)]})},Ob=ne.memo(Lb,(n,e)=>n.scene.hashCode()===e.scene.hashCode()&&n.mode===e.mode&&n.showDimensions===e.showDimensions),H1={stroke:Lt.SECONDARY_COLOR.main,strokeWidth:"2.5px"},qb=({catalog:n})=>{const{planner:e,showDimensions:t}=Ht(),{activeSnapElement:r,snapElements:i,scene:s,mode:o}=e,{width:a,height:l}=s;return R.jsxs("g",{children:[R.jsx("rect",{x:"0",y:"0",width:a,height:l,fill:Lt.COLORS.white}),R.jsxs("g",{transform:`translate(0, ${s.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[R.jsx(Ob,{scene:s,mode:o,catalog:n,showDimensions:t}),s.getIn(["guides","horizontal"]).entrySeq().map(([c,h])=>R.jsx("line",{id:"hGuide"+c,x1:0,y1:h,x2:a,y2:h,style:H1},c)),s.getIn(["guides","vertical"]).entrySeq().map(([c,h])=>R.jsx("line",{x1:h,y1:0,x2:h,y2:l,style:H1},c)),r?R.jsx(wE,{snap:r,width:s.width,height:s.height}):null,i?null:R.jsx(R.Fragment,{})]})]})},od=.25,G1=5,Db=.1,Nb=5.5;function W1(n){return(Math.min(Math.max(n,od),G1)-od)/(G1-od)*100}function Ub(n){switch(n){case Ns:return Lr;case qs:return Yr;case Ds:return vi;case sn:return Ir;default:return _i}}function Fb(n){switch(n){case Jn:case di:case hr:case Cr:case Wr:case Gr:case Vr:case Hr:return{pointerEvents:"none"};default:return{}}}function zb(n){switch(n){case Wr:case Vr:case Hr:case Gr:return{cursor:"move"};case Di:return{cursor:"ew-resize"};case Ar:case Jn:case Us:case di:return{cursor:"crosshair"};default:return{cursor:"default"}}}function kb(n){switch(n){case Jn:case di:case Vr:case Hr:case Wr:case Gr:case hr:case Cr:return!0;default:return!1}}function j1(n){for(;!n.attributes.getNamedItem("data-element-root")&&n.tagName!=="svg";)n=n.parentNode;return n.tagName==="svg"?null:{part:n.attributes.getNamedItem("data-part")?n.attributes.getNamedItem("data-part").value:void 0,layer:n.attributes.getNamedItem("data-layer").value,prototype:n.attributes.getNamedItem("data-prototype").value,selected:n.attributes.getNamedItem("data-selected").value==="true",id:n.attributes.getNamedItem("data-id").value}}const Bb=({width:n,height:e,catalog:t})=>{const r=ne.useRef(null),{planner:i,selectToolZoomOut:s,selectToolZoomIn:o,selectToolPan:a,selectToolEdit:l,updateCameraView:c,updateZoomScale:h,updateMouseCoord:f,updateDrawingLine:p,updateDrawingSurface:d,updateDrawingHole:m,updateDrawingItem:x,updateDraggingHole:v,updateDraggingLine:_,updateDraggingVertex:w,updateDraggingItem:E,updateRotatingItem:S,beginDraggingLine:b,beginDraggingVertex:A,beginRotatingItem:q,beginDraggingItem:O,beginDraggingHole:T,beginDrawingSurface:I,endDrawingSurface:N,selectArea:H,unselectAll:W,beginDrawingLine:Q,endDrawingLine:ae,endDrawingHole:J,endDrawingItem:se,endDraggingLine:B,endDraggingVertex:ge,endDraggingItem:F,endDraggingHole:X,endRotatingItem:de,selectLine:ye,selectHole:Ee,selectItem:V,rollback:re,setViewer:Z}=Ht(),{viewer2D:he,scene:xe,mode:ee}=i,Pe=xe.selectedLayer??"";ne.useEffect(()=>{r.current&&(Z(r.current),r.current.setPointOnViewerCenter(xe.width/2,xe.height/2,.725))},[]);const le=({x:be,y:tt})=>({x:be,y:-tt+xe.height}),z=be=>{const tt=new Event("mousemove-planner-event");tt.viewerEvent=be,document.dispatchEvent(tt);let{x:lt,y:$e}=le(be);switch(f({x:lt,y:$e}),ee){case Jn:p(lt,$e,i.snapMask);break;case di:d(lt,$e,i.snapMask);break;case hr:m(Pe,lt,$e);break;case Cr:x(Pe,lt,$e);break;case Wr:v(lt,$e);break;case Vr:_(lt,$e,i.snapMask);break;case Hr:w(lt,$e,i.snapMask);break;case Gr:E(lt,$e);break;case Di:S(lt,$e);break}be.originalEvent.stopPropagation()},rt=be=>{const tt=be.originalEvent,lt=new Event("mousedown-planner-event");lt.viewerEvent=be,document.dispatchEvent(lt);let{x:$e,y:U}=le(be);if(ee===sn){let P=j1(tt.target);if(!P||!P.selected)return;switch(P.prototype){case"lines":b(P.layer,P.id,$e,U,i.snapMask);break;case"vertices":A(P.layer,P.id,$e,U,i.snapMask);break;case"items":P.part==="rotation-anchor"?q(P.layer,P.id,$e,U):O(P.layer,P.id,$e,U);break;case"holes":T(P.layer,P.id,$e,U);break}}tt.stopPropagation()},Le=be=>{const tt=be.originalEvent,lt=new Event("mouseup-planner-event");lt.viewerEvent=be,document.dispatchEvent(lt);const{x:$e,y:U}=le(be);switch(ee){case sn:const P=j1(tt.target);if(P&&P.selected)return;switch(P?P.prototype:"none"){case"areas":H(P.layer,P.id);break;case"lines":ye(P.layer,P.id);break;case"holes":Ee(P.layer,P.id);break;case"items":V(P.layer,P.id);break;case"none":W();break}break;case Us:I(Pe,$e,U,i.snapMask);break;case di:N($e,U,i.snapMask),I(Pe,$e,U,i.snapMask);break;case Ar:Q(Pe,$e,U,i.snapMask);break;case Jn:ae($e,U,i.snapMask),Q(Pe,$e,U,i.snapMask);break;case hr:J(Pe,$e,U);break;case Cr:se(Pe,$e,U);break;case Vr:B($e,U,i.snapMask);break;case Hr:ge($e,U,i.snapMask);break;case Gr:F($e,U);break;case Wr:X($e,U);break;case Di:de($e,U);break}tt.stopPropagation()},at=()=>{[Us,di,Ar,Jn,hr,Cr].includes(ee)&&re()},ze=be=>{h(be.a),c(be)},Xe=be=>{switch(be){case _i:l();break;case Lr:a();break;case Yr:o();break;case vi:s();break}};return R.jsx("div",{className:"m-0 p-0 relative",children:R.jsx(Bc,{className:"floor_planner-svgPanZoom",ref:r,width:n,height:e,scaleFactorMin:Db,scaleFactorMax:Nb,value:he.isEmpty()?{}:he.toJS(),onChangeValue:ze,tool:Ub(ee),onChangeTool:Xe,detectAutoPan:kb(ee),onMouseDown:rt,onMouseMove:z,onMouseUp:Le,onDoubleClick:at,miniatureProps:{position:"none",width:0,height:0,background:""},toolbarProps:{position:"none"},children:R.jsxs("svg",{width:xe.width,height:xe.height,children:[R.jsx("defs",{children:R.jsxs("pattern",{id:"diagonalFill",patternUnits:"userSpaceOnUse",width:"4",height:"4",fill:"#FFF",children:[R.jsx("rect",{x:"0",y:"0",width:"4",height:"4",fill:"#FFF"}),R.jsx("path",{d:"M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2",style:{stroke:"#8E9BA2",strokeWidth:1}})]})}),R.jsx("g",{style:Object.assign(zb(ee),Fb(ee)),children:R.jsx(qb,{catalog:t})})]})})})};/**
71
71
  * @license
72
72
  * Copyright 2010-2025 Three.js Authors
73
73
  * SPDX-License-Identifier: MIT
74
- */const ad="179",Uo={ROTATE:0,DOLLY:1,PAN:2},Fo={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Vb=0,X1=1,Hb=2,$1=1,Gb=2,Fi=3,cs=0,er=1,Si=2,us=0,zo=1,Y1=2,K1=3,Z1=4,Wb=5,Bs=100,jb=101,Xb=102,$b=103,Yb=104,Kb=200,Zb=201,Jb=202,Qb=203,ld=204,cd=205,eM=206,tM=207,nM=208,rM=209,iM=210,sM=211,oM=212,aM=213,lM=214,ud=0,hd=1,fd=2,ko=3,dd=4,pd=5,md=6,gd=7,_d=0,cM=1,uM=2,hs=0,hM=1,fM=2,dM=3,pM=4,mM=5,gM=6,_M=7,J1=300,Bo=301,Vo=302,vd=303,xd=304,Gc=306,Zr=1e3,Vs=1001,yd=1002,Jr=1003,vM=1004,Wc=1005,Ei=1006,Sd=1007,Hs=1008,bi=1009,Q1=1010,e_=1011,ul=1012,Ed=1013,Gs=1014,zi=1015,hl=1016,bd=1017,Md=1018,fl=1020,t_=35902,n_=1021,r_=1022,Qr=1023,dl=1026,pl=1027,i_=1028,wd=1029,s_=1030,Td=1031,Ad=1033,jc=33776,Xc=33777,$c=33778,Yc=33779,Cd=35840,Rd=35841,Pd=35842,Id=35843,Ld=36196,Od=37492,qd=37496,Dd=37808,Nd=37809,Ud=37810,Fd=37811,zd=37812,kd=37813,Bd=37814,Vd=37815,Hd=37816,Gd=37817,Wd=37818,jd=37819,Xd=37820,$d=37821,Kc=36492,Yd=36494,Kd=36495,o_=36283,Zd=36284,Jd=36285,Qd=36286,xM=3200,yM=3201,ep=0,SM=1,fs="",mr="srgb",Ho="srgb-linear",Zc="linear",Ft="srgb",Go=7680,a_=519,EM=512,bM=513,MM=514,l_=515,wM=516,TM=517,AM=518,CM=519,c_=35044,u_="300 es",Mi=2e3,Jc=2001;class Ws{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const qn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Qc=Math.PI/180,eu=180/Math.PI;function Wo(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(qn[n&255]+qn[n>>8&255]+qn[n>>16&255]+qn[n>>24&255]+"-"+qn[e&255]+qn[e>>8&255]+"-"+qn[e>>16&15|64]+qn[e>>24&255]+"-"+qn[t&63|128]+qn[t>>8&255]+"-"+qn[t>>16&255]+qn[t>>24&255]+qn[r&255]+qn[r>>8&255]+qn[r>>16&255]+qn[r>>24&255]).toLowerCase()}function vt(n,e,t){return Math.max(e,Math.min(t,n))}function RM(n,e){return(n%e+e)%e}function tp(n,e,t){return(1-t)*n+t*e}function ml(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function tr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const PM={DEG2RAD:Qc};class Ne{constructor(e=0,t=0){Ne.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,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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 r=this.dot(e)/t;return Math.acos(vt(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ds{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const p=s[o+0],d=s[o+1],m=s[o+2],x=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(a===1){e[t+0]=p,e[t+1]=d,e[t+2]=m,e[t+3]=x;return}if(f!==x||l!==p||c!==d||h!==m){let v=1-a;const _=l*p+c*d+h*m+f*x,w=_>=0?1:-1,E=1-_*_;if(E>Number.EPSILON){const b=Math.sqrt(E),A=Math.atan2(b,_*w);v=Math.sin(v*A)/b,a=Math.sin(a*A)/b}const S=a*w;if(l=l*v+p*S,c=c*v+d*S,h=h*v+m*S,f=f*v+x*S,v===1-a){const b=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=b,c*=b,h*=b,f*=b}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],p=s[o+1],d=s[o+2],m=s[o+3];return e[t]=a*m+h*f+l*d-c*p,e[t+1]=l*m+h*p+c*f-a*d,e[t+2]=c*m+h*d+a*p-l*f,e[t+3]=h*m-a*f-l*p-c*d,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,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,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 r=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),p=l(r/2),d=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=p*h*f+c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f-p*d*m;break;case"YXZ":this._x=p*h*f+c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f+p*d*m;break;case"ZXY":this._x=p*h*f-c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f-p*d*m;break;case"ZYX":this._x=p*h*f-c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f+p*d*m;break;case"YZX":this._x=p*h*f+c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f-p*d*m;break;case"XZY":this._x=p*h*f-c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f+p*d*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],f=t[10],p=r+a+f;if(p>0){const d=.5/Math.sqrt(p+1);this._w=.25/d,this._x=(h-l)*d,this._y=(s-c)*d,this._z=(o-i)*d}else if(r>a&&r>f){const d=2*Math.sqrt(1+r-a-f);this._w=(h-l)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(s+c)/d}else if(a>f){const d=2*Math.sqrt(1+a-r-f);this._w=(s-c)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(l+h)/d}else{const d=2*Math.sqrt(1+f-r-a);this._w=(o-i)/d,this._x=(s+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(vt(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);return this.slerp(e,i),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 r=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+r*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*r+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*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 j{constructor(e=0,t=0,r=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,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(h_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(h_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*r),h=2*(a*t-s*i),f=2*(s*r-o*t);return this.x=t+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,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,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this.z=vt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this.z=vt(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return np.copy(this).projectOnVector(e),this.sub(np)}reflect(e){return this.sub(np.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 r=this.dot(e)/t;return Math.acos(vt(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}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,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,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,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const np=new j,h_=new ds;class mt{constructor(e,t,r,i,s,o,a,l,c){mt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,o,a,l,c)}set(e,t,r,i,s,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],p=r[2],d=r[5],m=r[8],x=i[0],v=i[3],_=i[6],w=i[1],E=i[4],S=i[7],b=i[2],A=i[5],q=i[8];return s[0]=o*x+a*w+l*b,s[3]=o*v+a*E+l*A,s[6]=o*_+a*S+l*q,s[1]=c*x+h*w+f*b,s[4]=c*v+h*E+f*A,s[7]=c*_+h*S+f*q,s[2]=p*x+d*w+m*b,s[5]=p*v+d*E+m*A,s[8]=p*_+d*S+m*q,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],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,p=a*l-h*s,d=c*s-o*l,m=t*f+r*p+i*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/m;return e[0]=f*x,e[1]=(i*c-h*r)*x,e[2]=(a*r-i*o)*x,e[3]=p*x,e[4]=(h*t-i*l)*x,e[5]=(i*s-a*t)*x,e[6]=d*x,e[7]=(r*l-c*t)*x,e[8]=(o*t-r*s)*x,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,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const rp=new mt;function f_(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function gl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function IM(){const n=gl("canvas");return n.style.display="block",n}const d_={};function jo(n){n in d_||(d_[n]=!0,console.warn(n))}function LM(n,e,t){return new Promise(function(r,i){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:r()}}setTimeout(s,t)})}const p_=new mt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),m_=new mt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OM(){const n={enabled:!0,workingColorSpace:Ho,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ft&&(i.r=ki(i.r),i.g=ki(i.g),i.b=ki(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Ft&&(i.r=Xo(i.r),i.g=Xo(i.g),i.b=Xo(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===fs?Zc:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return jo("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return jo("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[Ho]:{primaries:e,whitePoint:r,transfer:Zc,toXYZ:p_,fromXYZ:m_,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:mr},outputColorSpaceConfig:{drawingBufferColorSpace:mr}},[mr]:{primaries:e,whitePoint:r,transfer:Ft,toXYZ:p_,fromXYZ:m_,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:mr}}}),n}const Ct=OM();function ki(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Xo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let $o;class qM{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{$o===void 0&&($o=gl("canvas")),$o.width=e.width,$o.height=e.height;const i=$o.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=$o}return r.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=gl("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=ki(s[o]/255)*255;return r.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let r=0;r<t.length;r++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[r]=Math.floor(ki(t[r]/255)*255):t[r]=ki(t[r]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let DM=0;class ip{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:DM++}),this.uuid=Wo(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(sp(i[o].image)):s.push(sp(i[o]))}else s=sp(i);r.url=s}return t||(e.images[this.uuid]=r),r}}function sp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?qM.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let NM=0;const op=new j;class Dn extends Ws{constructor(e=Dn.DEFAULT_IMAGE,t=Dn.DEFAULT_MAPPING,r=Vs,i=Vs,s=Ei,o=Hs,a=Qr,l=bi,c=Dn.DEFAULT_ANISOTROPY,h=fs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:NM++}),this.uuid=Wo(),this.name="",this.source=new ip(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new mt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),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(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 r=e[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==J1)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zr:e.x=e.x-Math.floor(e.x);break;case Vs:e.x=e.x<0?0:1;break;case yd: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 Zr:e.y=e.y-Math.floor(e.y);break;case Vs:e.y=e.y<0?0:1;break;case yd: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++}}Dn.DEFAULT_IMAGE=null,Dn.DEFAULT_MAPPING=J1,Dn.DEFAULT_ANISOTROPY=1;class ln{constructor(e=0,t=0,r=0,i=1){ln.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*s,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,r,i,s;const l=e.elements,c=l[0],h=l[4],f=l[8],p=l[1],d=l[5],m=l[9],x=l[2],v=l[6],_=l[10];if(Math.abs(h-p)<.01&&Math.abs(f-x)<.01&&Math.abs(m-v)<.01){if(Math.abs(h+p)<.1&&Math.abs(f+x)<.1&&Math.abs(m+v)<.1&&Math.abs(c+d+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(d+1)/2,b=(_+1)/2,A=(h+p)/4,q=(f+x)/4,O=(m+v)/4;return E>S&&E>b?E<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(E),i=A/r,s=q/r):S>b?S<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),r=A/i,s=O/i):b<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),r=q/s,i=O/s),this.set(r,i,s,t),this}let w=Math.sqrt((v-m)*(v-m)+(f-x)*(f-x)+(p-h)*(p-h));return Math.abs(w)<.001&&(w=1),this.x=(v-m)/w,this.y=(f-x)/w,this.z=(p-h)/w,this.w=Math.acos((c+d+_-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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this.z=vt(this.z,e.z,t.z),this.w=vt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this.z=vt(this.z,e,t),this.w=vt(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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 UM extends Ws{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ei,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new ln(0,0,e,t),this.scissorTest=!1,this.viewport=new ln(0,0,e,t);const i={width:e,height:t,depth:r.depth},s=new Dn(i);this.textures=[];const o=r.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const t={minFilter:Ei,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;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,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new ip(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class js extends UM{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class g_ extends Dn{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class FM extends Dn{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wi{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(ei.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(ei.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=ei.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,ei):ei.fromBufferAttribute(s,o),ei.applyMatrix4(e.matrixWorld),this.expandByPoint(ei);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),tu.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),tu.copy(r.boundingBox)),tu.applyMatrix4(e.matrixWorld),this.union(tu)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=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,ei),ei.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_l),nu.subVectors(this.max,_l),Yo.subVectors(e.a,_l),Ko.subVectors(e.b,_l),Zo.subVectors(e.c,_l),ps.subVectors(Ko,Yo),ms.subVectors(Zo,Ko),Xs.subVectors(Yo,Zo);let t=[0,-ps.z,ps.y,0,-ms.z,ms.y,0,-Xs.z,Xs.y,ps.z,0,-ps.x,ms.z,0,-ms.x,Xs.z,0,-Xs.x,-ps.y,ps.x,0,-ms.y,ms.x,0,-Xs.y,Xs.x,0];return!ap(t,Yo,Ko,Zo,nu)||(t=[1,0,0,0,1,0,0,0,1],!ap(t,Yo,Ko,Zo,nu))?!1:(ru.crossVectors(ps,ms),t=[ru.x,ru.y,ru.z],ap(t,Yo,Ko,Zo,nu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ei).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ei).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:(Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),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 Bi=[new j,new j,new j,new j,new j,new j,new j,new j],ei=new j,tu=new wi,Yo=new j,Ko=new j,Zo=new j,ps=new j,ms=new j,Xs=new j,_l=new j,nu=new j,ru=new j,$s=new j;function ap(n,e,t,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){$s.fromArray(n,s);const a=i.x*Math.abs($s.x)+i.y*Math.abs($s.y)+i.z*Math.abs($s.z),l=e.dot($s),c=t.dot($s),h=r.dot($s);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const zM=new wi,vl=new j,lp=new j;class iu{constructor(e=new j,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 r=this.center;t!==void 0?r.copy(t):zM.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const r=this.center.distanceToSquared(e);return t.copy(e),r>this.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;vl.subVectors(e,this.center);const t=vl.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(vl,i/r),this.radius+=i}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):(lp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vl.copy(e.center).add(lp)),this.expandByPoint(vl.copy(e.center).sub(lp))),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 Vi=new j,cp=new j,su=new j,gs=new j,up=new j,ou=new j,hp=new j;class au{constructor(e=new j,t=new j(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,Vi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Vi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Vi.copy(this.origin).addScaledVector(this.direction,t),Vi.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){cp.copy(e).add(t).multiplyScalar(.5),su.copy(t).sub(e).normalize(),gs.copy(this.origin).sub(cp);const s=e.distanceTo(t)*.5,o=-this.direction.dot(su),a=gs.dot(this.direction),l=-gs.dot(su),c=gs.lengthSq(),h=Math.abs(1-o*o);let f,p,d,m;if(h>0)if(f=o*l-a,p=o*a-l,m=s*h,f>=0)if(p>=-m)if(p<=m){const x=1/h;f*=x,p*=x,d=f*(f+o*p+2*a)+p*(o*f+p+2*l)+c}else p=s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;else p=-s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;else p<=-m?(f=Math.max(0,-(-o*s+a)),p=f>0?-s:Math.min(Math.max(-s,-l),s),d=-f*f+p*(p+2*l)+c):p<=m?(f=0,p=Math.min(Math.max(-s,-l),s),d=p*(p+2*l)+c):(f=Math.max(0,-(o*s+a)),p=f>0?s:Math.min(Math.max(-s,-l),s),d=-f*f+p*(p+2*l)+c);else p=o>0?-s:s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(cp).addScaledVector(su,p),d}intersectSphere(e,t){Vi.subVectors(e.center,this.origin);const r=Vi.dot(this.direction),i=Vi.dot(Vi)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,t):this.at(a,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 r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(r=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(r=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,o=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,o=(e.min.y-p.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(a=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,Vi)!==null}intersectTriangle(e,t,r,i,s){up.subVectors(t,e),ou.subVectors(r,e),hp.crossVectors(up,ou);let o=this.direction.dot(hp),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;gs.subVectors(this.origin,e);const l=a*this.direction.dot(ou.crossVectors(gs,ou));if(l<0)return null;const c=a*this.direction.dot(up.cross(gs));if(c<0||l+c>o)return null;const h=-a*gs.dot(hp);return h<0?null:this.at(h/o,s)}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 Gt{constructor(e,t,r,i,s,o,a,l,c,h,f,p,d,m,x,v){Gt.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,r,i,s,o,a,l,c,h,f,p,d,m,x,v)}set(e,t,r,i,s,o,a,l,c,h,f,p,d,m,x,v){const _=this.elements;return _[0]=e,_[4]=t,_[8]=r,_[12]=i,_[1]=s,_[5]=o,_[9]=a,_[13]=l,_[2]=c,_[6]=h,_[10]=f,_[14]=p,_[3]=d,_[7]=m,_[11]=x,_[15]=v,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 Gt().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/Jo.setFromMatrixColumn(e,0).length(),s=1/Jo.setFromMatrixColumn(e,1).length(),o=1/Jo.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const p=o*h,d=o*f,m=a*h,x=a*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=d+m*c,t[5]=p-x*c,t[9]=-a*l,t[2]=x-p*c,t[6]=m+d*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*h,d=l*f,m=c*h,x=c*f;t[0]=p+x*a,t[4]=m*a-d,t[8]=o*c,t[1]=o*f,t[5]=o*h,t[9]=-a,t[2]=d*a-m,t[6]=x+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*h,d=l*f,m=c*h,x=c*f;t[0]=p-x*a,t[4]=-o*f,t[8]=m+d*a,t[1]=d+m*a,t[5]=o*h,t[9]=x-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*h,d=o*f,m=a*h,x=a*f;t[0]=l*h,t[4]=m*c-d,t[8]=p*c+x,t[1]=l*f,t[5]=x*c+p,t[9]=d*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,d=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=x-p*f,t[8]=m*f+d,t[1]=f,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=d*f+m,t[10]=p-x*f}else if(e.order==="XZY"){const p=o*l,d=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=p*f+x,t[5]=o*h,t[9]=d*f-m,t[2]=m*f-d,t[6]=a*h,t[10]=x*f+p}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(kM,e,BM)}lookAt(e,t,r){const i=this.elements;return gr.subVectors(e,t),gr.lengthSq()===0&&(gr.z=1),gr.normalize(),_s.crossVectors(r,gr),_s.lengthSq()===0&&(Math.abs(r.z)===1?gr.x+=1e-4:gr.z+=1e-4,gr.normalize(),_s.crossVectors(r,gr)),_s.normalize(),lu.crossVectors(gr,_s),i[0]=_s.x,i[4]=lu.x,i[8]=gr.x,i[1]=_s.y,i[5]=lu.y,i[9]=gr.y,i[2]=_s.z,i[6]=lu.z,i[10]=gr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],p=r[9],d=r[13],m=r[2],x=r[6],v=r[10],_=r[14],w=r[3],E=r[7],S=r[11],b=r[15],A=i[0],q=i[4],O=i[8],T=i[12],I=i[1],N=i[5],H=i[9],W=i[13],Q=i[2],ae=i[6],J=i[10],se=i[14],B=i[3],ge=i[7],F=i[11],X=i[15];return s[0]=o*A+a*I+l*Q+c*B,s[4]=o*q+a*N+l*ae+c*ge,s[8]=o*O+a*H+l*J+c*F,s[12]=o*T+a*W+l*se+c*X,s[1]=h*A+f*I+p*Q+d*B,s[5]=h*q+f*N+p*ae+d*ge,s[9]=h*O+f*H+p*J+d*F,s[13]=h*T+f*W+p*se+d*X,s[2]=m*A+x*I+v*Q+_*B,s[6]=m*q+x*N+v*ae+_*ge,s[10]=m*O+x*H+v*J+_*F,s[14]=m*T+x*W+v*se+_*X,s[3]=w*A+E*I+S*Q+b*B,s[7]=w*q+E*N+S*ae+b*ge,s[11]=w*O+E*H+S*J+b*F,s[15]=w*T+E*W+S*se+b*X,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],r=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],f=e[6],p=e[10],d=e[14],m=e[3],x=e[7],v=e[11],_=e[15];return m*(+s*l*f-i*c*f-s*a*p+r*c*p+i*a*d-r*l*d)+x*(+t*l*d-t*c*p+s*o*p-i*o*d+i*c*h-s*l*h)+v*(+t*c*f-t*a*d-s*o*f+r*o*d+s*a*h-r*c*h)+_*(-i*a*h-t*l*f+t*a*p+i*o*f-r*o*p+r*l*h)}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,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=e[9],p=e[10],d=e[11],m=e[12],x=e[13],v=e[14],_=e[15],w=f*v*c-x*p*c+x*l*d-a*v*d-f*l*_+a*p*_,E=m*p*c-h*v*c-m*l*d+o*v*d+h*l*_-o*p*_,S=h*x*c-m*f*c+m*a*d-o*x*d-h*a*_+o*f*_,b=m*f*l-h*x*l-m*a*p+o*x*p+h*a*v-o*f*v,A=t*w+r*E+i*S+s*b;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const q=1/A;return e[0]=w*q,e[1]=(x*p*s-f*v*s-x*i*d+r*v*d+f*i*_-r*p*_)*q,e[2]=(a*v*s-x*l*s+x*i*c-r*v*c-a*i*_+r*l*_)*q,e[3]=(f*l*s-a*p*s-f*i*c+r*p*c+a*i*d-r*l*d)*q,e[4]=E*q,e[5]=(h*v*s-m*p*s+m*i*d-t*v*d-h*i*_+t*p*_)*q,e[6]=(m*l*s-o*v*s-m*i*c+t*v*c+o*i*_-t*l*_)*q,e[7]=(o*p*s-h*l*s+h*i*c-t*p*c-o*i*d+t*l*d)*q,e[8]=S*q,e[9]=(m*f*s-h*x*s-m*r*d+t*x*d+h*r*_-t*f*_)*q,e[10]=(o*x*s-m*a*s+m*r*c-t*x*c-o*r*_+t*a*_)*q,e[11]=(h*a*s-o*f*s-h*r*c+t*f*c+o*r*d-t*a*d)*q,e[12]=b*q,e[13]=(h*x*i-m*f*i+m*r*p-t*x*p-h*r*v+t*f*v)*q,e[14]=(m*a*i-o*x*i-m*r*l+t*x*l+o*r*v-t*a*v)*q,e[15]=(o*f*i-h*a*i+h*r*l-t*f*l-o*r*p+t*a*p)*q,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,f=a+a,p=s*c,d=s*h,m=s*f,x=o*h,v=o*f,_=a*f,w=l*c,E=l*h,S=l*f,b=r.x,A=r.y,q=r.z;return i[0]=(1-(x+_))*b,i[1]=(d+S)*b,i[2]=(m-E)*b,i[3]=0,i[4]=(d-S)*A,i[5]=(1-(p+_))*A,i[6]=(v+w)*A,i[7]=0,i[8]=(m+E)*q,i[9]=(v-w)*q,i[10]=(1-(p+x))*q,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=Jo.set(i[0],i[1],i[2]).length();const o=Jo.set(i[4],i[5],i[6]).length(),a=Jo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],ti.copy(this);const c=1/s,h=1/o,f=1/a;return ti.elements[0]*=c,ti.elements[1]*=c,ti.elements[2]*=c,ti.elements[4]*=h,ti.elements[5]*=h,ti.elements[6]*=h,ti.elements[8]*=f,ti.elements[9]*=f,ti.elements[10]*=f,t.setFromRotationMatrix(ti),r.x=s,r.y=o,r.z=a,this}makePerspective(e,t,r,i,s,o,a=Mi,l=!1){const c=this.elements,h=2*s/(t-e),f=2*s/(r-i),p=(t+e)/(t-e),d=(r+i)/(r-i);let m,x;if(l)m=s/(o-s),x=o*s/(o-s);else if(a===Mi)m=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===Jc)m=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=f,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,r,i,s,o,a=Mi,l=!1){const c=this.elements,h=2/(t-e),f=2/(r-i),p=-(t+e)/(t-e),d=-(r+i)/(r-i);let m,x;if(l)m=1/(o-s),x=o/(o-s);else if(a===Mi)m=-2/(o-s),x=-(o+s)/(o-s);else if(a===Jc)m=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=f,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const Jo=new j,ti=new Gt,kM=new j(0,0,0),BM=new j(1,1,1),_s=new j,lu=new j,gr=new j,__=new Gt,v_=new ds;class ni{constructor(e=0,t=0,r=0,i=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,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,r=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],p=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(vt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-vt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(vt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-vt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(vt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-vt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return __.makeRotationFromQuaternion(e),this.setFromRotationMatrix(__,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return v_.setFromEuler(this),this.setFromQuaternion(v_,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}}ni.DEFAULT_ORDER="XYZ";class fp{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let VM=0;const x_=new j,Qo=new ds,Hi=new Gt,cu=new j,xl=new j,HM=new j,GM=new ds,y_=new j(1,0,0),S_=new j(0,1,0),E_=new j(0,0,1),b_={type:"added"},WM={type:"removed"},ea={type:"childadded",child:null},dp={type:"childremoved",child:null};class Dt extends Ws{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:VM++}),this.uuid=Wo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dt.DEFAULT_UP.clone();const e=new j,t=new ni,r=new ds,i=new j(1,1,1);function s(){r.setFromEuler(t,!1)}function o(){t.setFromQuaternion(r,void 0,!1)}t._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Gt},normalMatrix:{value:new mt}}),this.matrix=new Gt,this.matrixWorld=new Gt,this.matrixAutoUpdate=Dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fp,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Qo.setFromAxisAngle(e,t),this.quaternion.multiply(Qo),this}rotateOnWorldAxis(e,t){return Qo.setFromAxisAngle(e,t),this.quaternion.premultiply(Qo),this}rotateX(e){return this.rotateOnAxis(y_,e)}rotateY(e){return this.rotateOnAxis(S_,e)}rotateZ(e){return this.rotateOnAxis(E_,e)}translateOnAxis(e,t){return x_.copy(e).applyQuaternion(this.quaternion),this.position.add(x_.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(y_,e)}translateY(e){return this.translateOnAxis(S_,e)}translateZ(e){return this.translateOnAxis(E_,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Hi.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?cu.copy(e):cu.set(e,t,r);const i=this.parent;this.updateWorldMatrix(!0,!1),xl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Hi.lookAt(xl,cu,this.up):Hi.lookAt(cu,xl,this.up),this.quaternion.setFromRotationMatrix(Hi),i&&(Hi.extractRotation(i.matrixWorld),Qo.setFromRotationMatrix(Hi),this.quaternion.premultiply(Qo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(b_),ea.child=e,this.dispatchEvent(ea),ea.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(WM),dp.child=e,this.dispatchEvent(dp),dp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Hi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Hi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Hi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(b_),ea.child=e,this.dispatchEvent(ea),ea.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xl,e,HM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xl,GM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)}updateWorldMatrix(e,t){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),f=o(e.shapes),p=o(e.skeletons),d=o(e.animations),m=o(e.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),d.length>0&&(r.animations=d),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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 r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Dt.DEFAULT_UP=new j(0,1,0),Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ri=new j,Gi=new j,pp=new j,Wi=new j,ta=new j,na=new j,M_=new j,mp=new j,gp=new j,_p=new j,vp=new ln,xp=new ln,yp=new ln;class ii{constructor(e=new j,t=new j,r=new j){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),ri.subVectors(e,t),i.cross(ri);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){ri.subVectors(i,t),Gi.subVectors(r,t),pp.subVectors(e,t);const o=ri.dot(ri),a=ri.dot(Gi),l=ri.dot(pp),c=Gi.dot(Gi),h=Gi.dot(pp),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const p=1/f,d=(c*l-a*h)*p,m=(o*h-a*l)*p;return s.set(1-d-m,m,d)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,Wi)===null?!1:Wi.x>=0&&Wi.y>=0&&Wi.x+Wi.y<=1}static getInterpolation(e,t,r,i,s,o,a,l){return this.getBarycoord(e,t,r,i,Wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Wi.x),l.addScaledVector(o,Wi.y),l.addScaledVector(a,Wi.z),l)}static getInterpolatedAttribute(e,t,r,i,s,o){return vp.setScalar(0),xp.setScalar(0),yp.setScalar(0),vp.fromBufferAttribute(e,t),xp.fromBufferAttribute(e,r),yp.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(vp,s.x),o.addScaledVector(xp,s.y),o.addScaledVector(yp,s.z),o}static isFrontFacing(e,t,r,i){return ri.subVectors(r,t),Gi.subVectors(e,t),ri.cross(Gi).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 ri.subVectors(this.c,this.b),Gi.subVectors(this.a,this.b),ri.cross(Gi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ii.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ii.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return ii.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return ii.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ii.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let o,a;ta.subVectors(i,r),na.subVectors(s,r),mp.subVectors(e,r);const l=ta.dot(mp),c=na.dot(mp);if(l<=0&&c<=0)return t.copy(r);gp.subVectors(e,i);const h=ta.dot(gp),f=na.dot(gp);if(h>=0&&f<=h)return t.copy(i);const p=l*f-h*c;if(p<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(r).addScaledVector(ta,o);_p.subVectors(e,s);const d=ta.dot(_p),m=na.dot(_p);if(m>=0&&d<=m)return t.copy(s);const x=d*c-l*m;if(x<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(r).addScaledVector(na,a);const v=h*m-d*f;if(v<=0&&f-h>=0&&d-m>=0)return M_.subVectors(s,i),a=(f-h)/(f-h+(d-m)),t.copy(i).addScaledVector(M_,a);const _=1/(v+x+p);return o=x*_,a=p*_,t.copy(r).addScaledVector(ta,o).addScaledVector(na,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const w_={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},vs={h:0,s:0,l:0},uu={h:0,s:0,l:0};function Sp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Et{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(t===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=mr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ct.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=Ct.workingColorSpace){return this.r=e,this.g=t,this.b=r,Ct.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=Ct.workingColorSpace){if(e=RM(e,1),t=vt(t,0,1),r=vt(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=Sp(o,s,e+1/3),this.g=Sp(o,s,e),this.b=Sp(o,s,e-1/3)}return Ct.colorSpaceToWorking(this,i),this}setStyle(e,t=mr){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,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=mr){const r=w_[e.toLowerCase()];return r!==void 0?this.setHex(r,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=ki(e.r),this.g=ki(e.g),this.b=ki(e.b),this}copyLinearToSRGB(e){return this.r=Xo(e.r),this.g=Xo(e.g),this.b=Xo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mr){return Ct.workingToColorSpace(Nn.copy(this),e),Math.round(vt(Nn.r*255,0,255))*65536+Math.round(vt(Nn.g*255,0,255))*256+Math.round(vt(Nn.b*255,0,255))}getHexString(e=mr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ct.workingColorSpace){Ct.workingToColorSpace(Nn.copy(this),t);const r=Nn.r,i=Nn.g,s=Nn.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ct.workingColorSpace){return Ct.workingToColorSpace(Nn.copy(this),t),e.r=Nn.r,e.g=Nn.g,e.b=Nn.b,e}getStyle(e=mr){Ct.workingToColorSpace(Nn.copy(this),e);const t=Nn.r,r=Nn.g,i=Nn.b;return e!==mr?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,t,r){return this.getHSL(vs),this.setHSL(vs.h+e,vs.s+t,vs.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(vs),e.getHSL(uu);const r=tp(vs.h,uu.h,t),i=tp(vs.s,uu.s,t),s=tp(vs.l,uu.l,t);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*r+s[6]*i,this.g=s[1]*t+s[4]*r+s[7]*i,this.b=s[2]*t+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Nn=new Et;Et.NAMES=w_;let jM=0;class Ys extends Ws{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Wo(),this.name="",this.type="Material",this.blending=zo,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ld,this.blendDst=cd,this.blendEquation=Bs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Et(0,0,0),this.blendAlpha=0,this.depthFunc=ko,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=a_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Go,this.stencilZFail=Go,this.stencilZPass=Go,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=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 r=e[t];if(r===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==zo&&(r.blending=this.blending),this.side!==cs&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==ld&&(r.blendSrc=this.blendSrc),this.blendDst!==cd&&(r.blendDst=this.blendDst),this.blendEquation!==Bs&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==ko&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==a_&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Go&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Go&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Go&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}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 r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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 Ks extends Ys{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Et(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 ni,this.combine=_d,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 gn=new j,hu=new Ne;let XM=0;class qr{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:XM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=c_,this.updateRanges=[],this.gpuType=zi,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,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,r=this.count;t<r;t++)hu.fromBufferAttribute(this,t),hu.applyMatrix3(e),this.setXY(t,hu.x,hu.y);else if(this.itemSize===3)for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix3(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=ml(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=tr(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ml(t,this.array)),t}setX(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ml(t,this.array)),t}setY(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ml(t,this.array)),t}setZ(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ml(t,this.array)),t}setW(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array),i=tr(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array),i=tr(i,this.array),s=tr(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==c_&&(e.usage=this.usage),e}}class T_ extends qr{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class A_ extends qr{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class Gn extends qr{constructor(e,t,r){super(new Float32Array(e),t,r)}}let $M=0;const Dr=new Gt,Ep=new Dt,ra=new j,_r=new wi,yl=new wi,wn=new j;class nr extends Ws{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$M++}),this.uuid=Wo(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(f_(e)?A_:T_)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new mt().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Dr.makeRotationFromQuaternion(e),this.applyMatrix4(Dr),this}rotateX(e){return Dr.makeRotationX(e),this.applyMatrix4(Dr),this}rotateY(e){return Dr.makeRotationY(e),this.applyMatrix4(Dr),this}rotateZ(e){return Dr.makeRotationZ(e),this.applyMatrix4(Dr),this}translate(e,t,r){return Dr.makeTranslation(e,t,r),this.applyMatrix4(Dr),this}scale(e,t,r){return Dr.makeScale(e,t,r),this.applyMatrix4(Dr),this}lookAt(e){return Ep.lookAt(e),Ep.updateMatrix(),this.applyMatrix4(Ep.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ra).negate(),this.translate(ra.x,ra.y,ra.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Gn(r,3))}else{const r=Math.min(e.length,t.count);for(let i=0;i<r;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.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 wi);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 j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let r=0,i=t.length;r<i;r++){const s=t[r];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(wn.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(wn),wn.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(wn)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new iu);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){const r=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];yl.setFromBufferAttribute(a),this.morphTargetsRelative?(wn.addVectors(_r.min,yl.min),_r.expandByPoint(wn),wn.addVectors(_r.max,yl.max),_r.expandByPoint(wn)):(_r.expandByPoint(yl.min),_r.expandByPoint(yl.max))}_r.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)wn.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(wn));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)wn.fromBufferAttribute(a,c),l&&(ra.fromBufferAttribute(e,c),wn.add(ra)),i=Math.max(i,r.distanceToSquared(wn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new qr(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let O=0;O<r.count;O++)a[O]=new j,l[O]=new j;const c=new j,h=new j,f=new j,p=new Ne,d=new Ne,m=new Ne,x=new j,v=new j;function _(O,T,I){c.fromBufferAttribute(r,O),h.fromBufferAttribute(r,T),f.fromBufferAttribute(r,I),p.fromBufferAttribute(s,O),d.fromBufferAttribute(s,T),m.fromBufferAttribute(s,I),h.sub(c),f.sub(c),d.sub(p),m.sub(p);const N=1/(d.x*m.y-m.x*d.y);isFinite(N)&&(x.copy(h).multiplyScalar(m.y).addScaledVector(f,-d.y).multiplyScalar(N),v.copy(f).multiplyScalar(d.x).addScaledVector(h,-m.x).multiplyScalar(N),a[O].add(x),a[T].add(x),a[I].add(x),l[O].add(v),l[T].add(v),l[I].add(v))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let O=0,T=w.length;O<T;++O){const I=w[O],N=I.start,H=I.count;for(let W=N,Q=N+H;W<Q;W+=3)_(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const E=new j,S=new j,b=new j,A=new j;function q(O){b.fromBufferAttribute(i,O),A.copy(b);const T=a[O];E.copy(T),E.sub(b.multiplyScalar(b.dot(T))).normalize(),S.crossVectors(A,T);const N=S.dot(l[O])<0?-1:1;o.setXYZW(O,E.x,E.y,E.z,N)}for(let O=0,T=w.length;O<T;++O){const I=w[O],N=I.start,H=I.count;for(let W=N,Q=N+H;W<Q;W+=3)q(e.getX(W+0)),q(e.getX(W+1)),q(e.getX(W+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new qr(new Float32Array(t.count*3),3),this.setAttribute("normal",r);else for(let p=0,d=r.count;p<d;p++)r.setXYZ(p,0,0,0);const i=new j,s=new j,o=new j,a=new j,l=new j,c=new j,h=new j,f=new j;if(e)for(let p=0,d=e.count;p<d;p+=3){const m=e.getX(p+0),x=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,x),o.fromBufferAttribute(t,v),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let p=0,d=t.count;p<d;p+=3)i.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(p+0,h.x,h.y,h.z),r.setXYZ(p+1,h.x,h.y,h.z),r.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)wn.fromBufferAttribute(e,t),wn.normalize(),e.setXYZ(t,wn.x,wn.y,wn.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,f=a.normalized,p=new c.constructor(l.length*h);let d=0,m=0;for(let x=0,v=l.length;x<v;x++){a.isInterleavedBufferAttribute?d=l[x]*a.data.stride+a.offset:d=l[x]*h;for(let _=0;_<h;_++)p[m++]=c[d++]}return new qr(p,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new nr,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,r);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const p=c[h],d=e(p,r);l.push(d)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,p=c.length;f<p;f++){const d=c[f];h.push(d.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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 r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],f=s[c];for(let p=0,d=f.length;p<d;p++)h.push(f[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const C_=new Gt,Zs=new au,fu=new iu,R_=new j,du=new j,pu=new j,mu=new j,bp=new j,gu=new j,P_=new j,_u=new j;class Tn extends Dt{constructor(e=new nr,t=new Ks){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){gu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(bp.fromBufferAttribute(f,e),o?gu.addScaledVector(bp,h):gu.addScaledVector(bp.sub(t),h))}t.add(gu)}return t}raycast(e,t){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),fu.copy(r.boundingSphere),fu.applyMatrix4(s),Zs.copy(e.ray).recast(e.near),!(fu.containsPoint(Zs.origin)===!1&&(Zs.intersectSphere(fu,R_)===null||Zs.origin.distanceToSquared(R_)>(e.far-e.near)**2))&&(C_.copy(s).invert(),Zs.copy(e.ray).applyMatrix4(C_),!(r.boundingBox!==null&&Zs.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,t,Zs)))}_computeIntersections(e,t,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,p=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,x=p.length;m<x;m++){const v=p[m],_=o[v.materialIndex],w=Math.max(v.start,d.start),E=Math.min(a.count,Math.min(v.start+v.count,d.start+d.count));for(let S=w,b=E;S<b;S+=3){const A=a.getX(S),q=a.getX(S+1),O=a.getX(S+2);i=vu(this,_,e,r,c,h,f,A,q,O),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=v.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),x=Math.min(a.count,d.start+d.count);for(let v=m,_=x;v<_;v+=3){const w=a.getX(v),E=a.getX(v+1),S=a.getX(v+2);i=vu(this,o,e,r,c,h,f,w,E,S),i&&(i.faceIndex=Math.floor(v/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,x=p.length;m<x;m++){const v=p[m],_=o[v.materialIndex],w=Math.max(v.start,d.start),E=Math.min(l.count,Math.min(v.start+v.count,d.start+d.count));for(let S=w,b=E;S<b;S+=3){const A=S,q=S+1,O=S+2;i=vu(this,_,e,r,c,h,f,A,q,O),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=v.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),x=Math.min(l.count,d.start+d.count);for(let v=m,_=x;v<_;v+=3){const w=v,E=v+1,S=v+2;i=vu(this,o,e,r,c,h,f,w,E,S),i&&(i.faceIndex=Math.floor(v/3),t.push(i))}}}}function YM(n,e,t,r,i,s,o,a){let l;if(e.side===er?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,e.side===cs,a),l===null)return null;_u.copy(a),_u.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(_u);return c<t.near||c>t.far?null:{distance:c,point:_u.clone(),object:n}}function vu(n,e,t,r,i,s,o,a,l,c){n.getVertexPosition(a,du),n.getVertexPosition(l,pu),n.getVertexPosition(c,mu);const h=YM(n,e,t,r,du,pu,mu,P_);if(h){const f=new j;ii.getBarycoord(P_,du,pu,mu,f),i&&(h.uv=ii.getInterpolatedAttribute(i,a,l,c,f,new Ne)),s&&(h.uv1=ii.getInterpolatedAttribute(s,a,l,c,f,new Ne)),o&&(h.normal=ii.getInterpolatedAttribute(o,a,l,c,f,new j),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const p={a,b:l,c,normal:new j,materialIndex:0};ii.getNormal(du,pu,mu,p.normal),h.face=p,h.barycoord=f}return h}class Js extends nr{constructor(e=1,t=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let p=0,d=0;m("z","y","x",-1,-1,r,t,e,o,s,0),m("z","y","x",1,-1,r,t,-e,o,s,1),m("x","z","y",1,1,e,r,t,i,o,2),m("x","z","y",1,-1,e,r,-t,i,o,3),m("x","y","z",1,-1,e,t,r,i,s,4),m("x","y","z",-1,-1,e,t,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(h,3)),this.setAttribute("uv",new Gn(f,2));function m(x,v,_,w,E,S,b,A,q,O,T){const I=S/q,N=b/O,H=S/2,W=b/2,Q=A/2,ae=q+1,J=O+1;let se=0,B=0;const ge=new j;for(let F=0;F<J;F++){const X=F*N-W;for(let de=0;de<ae;de++){const ye=de*I-H;ge[x]=ye*w,ge[v]=X*E,ge[_]=Q,c.push(ge.x,ge.y,ge.z),ge[x]=0,ge[v]=0,ge[_]=A>0?1:-1,h.push(ge.x,ge.y,ge.z),f.push(de/q),f.push(1-F/O),se+=1}}for(let F=0;F<O;F++)for(let X=0;X<q;X++){const de=p+X+ae*F,ye=p+X+ae*(F+1),Ee=p+(X+1)+ae*(F+1),V=p+(X+1)+ae*F;l.push(de,ye,V),l.push(ye,Ee,V),B+=6}a.addGroup(d,B,T),d+=B,p+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Js(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ia(n){const e={};for(const t in n){e[t]={};for(const r in n[t]){const i=n[t][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][r]=null):e[t][r]=i.clone():Array.isArray(i)?e[t][r]=i.slice():e[t][r]=i}}return e}function Wn(n){const e={};for(let t=0;t<n.length;t++){const r=ia(n[t]);for(const i in r)e[i]=r[i]}return e}function KM(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function I_(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ct.workingColorSpace}const ZM={clone:ia,merge:Wn};var JM=`void main() {
74
+ */const ad="179",Uo={ROTATE:0,DOLLY:1,PAN:2},Fo={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Vb=0,X1=1,Hb=2,$1=1,Gb=2,Fi=3,cs=0,er=1,Si=2,us=0,zo=1,Y1=2,K1=3,Z1=4,Wb=5,Bs=100,jb=101,Xb=102,$b=103,Yb=104,Kb=200,Zb=201,Jb=202,Qb=203,ld=204,cd=205,eM=206,tM=207,nM=208,rM=209,iM=210,sM=211,oM=212,aM=213,lM=214,ud=0,hd=1,fd=2,ko=3,dd=4,pd=5,md=6,gd=7,_d=0,cM=1,uM=2,hs=0,hM=1,fM=2,dM=3,pM=4,mM=5,gM=6,_M=7,J1=300,Bo=301,Vo=302,vd=303,xd=304,Gc=306,Zr=1e3,Vs=1001,yd=1002,Jr=1003,vM=1004,Wc=1005,Ei=1006,Sd=1007,Hs=1008,bi=1009,Q1=1010,e_=1011,ul=1012,Ed=1013,Gs=1014,zi=1015,hl=1016,bd=1017,Md=1018,fl=1020,t_=35902,n_=1021,r_=1022,Qr=1023,dl=1026,pl=1027,i_=1028,wd=1029,s_=1030,Td=1031,Ad=1033,jc=33776,Xc=33777,$c=33778,Yc=33779,Cd=35840,Rd=35841,Pd=35842,Id=35843,Ld=36196,Od=37492,qd=37496,Dd=37808,Nd=37809,Ud=37810,Fd=37811,zd=37812,kd=37813,Bd=37814,Vd=37815,Hd=37816,Gd=37817,Wd=37818,jd=37819,Xd=37820,$d=37821,Kc=36492,Yd=36494,Kd=36495,o_=36283,Zd=36284,Jd=36285,Qd=36286,xM=3200,yM=3201,ep=0,SM=1,fs="",mr="srgb",Ho="srgb-linear",Zc="linear",Ft="srgb",Go=7680,a_=519,EM=512,bM=513,MM=514,l_=515,wM=516,TM=517,AM=518,CM=519,c_=35044,u_="300 es",Mi=2e3,Jc=2001;class Ws{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const qn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Qc=Math.PI/180,eu=180/Math.PI;function Wo(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(qn[n&255]+qn[n>>8&255]+qn[n>>16&255]+qn[n>>24&255]+"-"+qn[e&255]+qn[e>>8&255]+"-"+qn[e>>16&15|64]+qn[e>>24&255]+"-"+qn[t&63|128]+qn[t>>8&255]+"-"+qn[t>>16&255]+qn[t>>24&255]+qn[r&255]+qn[r>>8&255]+qn[r>>16&255]+qn[r>>24&255]).toLowerCase()}function vt(n,e,t){return Math.max(e,Math.min(t,n))}function RM(n,e){return(n%e+e)%e}function tp(n,e,t){return(1-t)*n+t*e}function ml(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function tr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const PM={DEG2RAD:Qc};class Ne{constructor(e=0,t=0){Ne.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,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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 r=this.dot(e)/t;return Math.acos(vt(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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 r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ds{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const p=s[o+0],d=s[o+1],m=s[o+2],x=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(a===1){e[t+0]=p,e[t+1]=d,e[t+2]=m,e[t+3]=x;return}if(f!==x||l!==p||c!==d||h!==m){let v=1-a;const _=l*p+c*d+h*m+f*x,w=_>=0?1:-1,E=1-_*_;if(E>Number.EPSILON){const b=Math.sqrt(E),A=Math.atan2(b,_*w);v=Math.sin(v*A)/b,a=Math.sin(a*A)/b}const S=a*w;if(l=l*v+p*S,c=c*v+d*S,h=h*v+m*S,f=f*v+x*S,v===1-a){const b=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=b,c*=b,h*=b,f*=b}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],p=s[o+1],d=s[o+2],m=s[o+3];return e[t]=a*m+h*f+l*d-c*p,e[t+1]=l*m+h*p+c*f-a*d,e[t+2]=c*m+h*d+a*p-l*f,e[t+3]=h*m-a*f-l*p-c*d,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,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,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 r=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),p=l(r/2),d=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=p*h*f+c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f-p*d*m;break;case"YXZ":this._x=p*h*f+c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f+p*d*m;break;case"ZXY":this._x=p*h*f-c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f-p*d*m;break;case"ZYX":this._x=p*h*f-c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f+p*d*m;break;case"YZX":this._x=p*h*f+c*d*m,this._y=c*d*f+p*h*m,this._z=c*h*m-p*d*f,this._w=c*h*f-p*d*m;break;case"XZY":this._x=p*h*f-c*d*m,this._y=c*d*f-p*h*m,this._z=c*h*m+p*d*f,this._w=c*h*f+p*d*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],f=t[10],p=r+a+f;if(p>0){const d=.5/Math.sqrt(p+1);this._w=.25/d,this._x=(h-l)*d,this._y=(s-c)*d,this._z=(o-i)*d}else if(r>a&&r>f){const d=2*Math.sqrt(1+r-a-f);this._w=(h-l)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(s+c)/d}else if(a>f){const d=2*Math.sqrt(1+a-r-f);this._w=(s-c)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(l+h)/d}else{const d=2*Math.sqrt(1+f-r-a);this._w=(o-i)/d,this._x=(s+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(vt(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);return this.slerp(e,i),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 r=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+r*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*r+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*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 j{constructor(e=0,t=0,r=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,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(h_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(h_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*r),h=2*(a*t-s*i),f=2*(s*r-o*t);return this.x=t+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,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,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this.z=vt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this.z=vt(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return np.copy(this).projectOnVector(e),this.sub(np)}reflect(e){return this.sub(np.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 r=this.dot(e)/t;return Math.acos(vt(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}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,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,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,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const np=new j,h_=new ds;class mt{constructor(e,t,r,i,s,o,a,l,c){mt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,o,a,l,c)}set(e,t,r,i,s,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.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 r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],p=r[2],d=r[5],m=r[8],x=i[0],v=i[3],_=i[6],w=i[1],E=i[4],S=i[7],b=i[2],A=i[5],q=i[8];return s[0]=o*x+a*w+l*b,s[3]=o*v+a*E+l*A,s[6]=o*_+a*S+l*q,s[1]=c*x+h*w+f*b,s[4]=c*v+h*E+f*A,s[7]=c*_+h*S+f*q,s[2]=p*x+d*w+m*b,s[5]=p*v+d*E+m*A,s[8]=p*_+d*S+m*q,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],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,p=a*l-h*s,d=c*s-o*l,m=t*f+r*p+i*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/m;return e[0]=f*x,e[1]=(i*c-h*r)*x,e[2]=(a*r-i*o)*x,e[3]=p*x,e[4]=(h*t-i*l)*x,e[5]=(i*s-a*t)*x,e[6]=d*x,e[7]=(r*l-c*t)*x,e[8]=(o*t-r*s)*x,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,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+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),r=Math.sin(e);return this.set(t,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const rp=new mt;function f_(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function gl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function IM(){const n=gl("canvas");return n.style.display="block",n}const d_={};function jo(n){n in d_||(d_[n]=!0,console.warn(n))}function LM(n,e,t){return new Promise(function(r,i){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:r()}}setTimeout(s,t)})}const p_=new mt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),m_=new mt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OM(){const n={enabled:!0,workingColorSpace:Ho,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ft&&(i.r=ki(i.r),i.g=ki(i.g),i.b=ki(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Ft&&(i.r=Xo(i.r),i.g=Xo(i.g),i.b=Xo(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===fs?Zc:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return jo("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return jo("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[Ho]:{primaries:e,whitePoint:r,transfer:Zc,toXYZ:p_,fromXYZ:m_,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:mr},outputColorSpaceConfig:{drawingBufferColorSpace:mr}},[mr]:{primaries:e,whitePoint:r,transfer:Ft,toXYZ:p_,fromXYZ:m_,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:mr}}}),n}const Ct=OM();function ki(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Xo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let $o;class qM{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{$o===void 0&&($o=gl("canvas")),$o.width=e.width,$o.height=e.height;const i=$o.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=$o}return r.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=gl("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=ki(s[o]/255)*255;return r.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let r=0;r<t.length;r++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[r]=Math.floor(ki(t[r]/255)*255):t[r]=ki(t[r]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let DM=0;class ip{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:DM++}),this.uuid=Wo(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(sp(i[o].image)):s.push(sp(i[o]))}else s=sp(i);r.url=s}return t||(e.images[this.uuid]=r),r}}function sp(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?qM.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let NM=0;const op=new j;class Dn extends Ws{constructor(e=Dn.DEFAULT_IMAGE,t=Dn.DEFAULT_MAPPING,r=Vs,i=Vs,s=Ei,o=Hs,a=Qr,l=bi,c=Dn.DEFAULT_ANISOTROPY,h=fs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:NM++}),this.uuid=Wo(),this.name="",this.source=new ip(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new mt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),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(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 r=e[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==J1)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zr:e.x=e.x-Math.floor(e.x);break;case Vs:e.x=e.x<0?0:1;break;case yd: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 Zr:e.y=e.y-Math.floor(e.y);break;case Vs:e.y=e.y<0?0:1;break;case yd: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++}}Dn.DEFAULT_IMAGE=null,Dn.DEFAULT_MAPPING=J1,Dn.DEFAULT_ANISOTROPY=1;class ln{constructor(e=0,t=0,r=0,i=1){ln.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*r+o[11]*i+o[15]*s,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,r,i,s;const l=e.elements,c=l[0],h=l[4],f=l[8],p=l[1],d=l[5],m=l[9],x=l[2],v=l[6],_=l[10];if(Math.abs(h-p)<.01&&Math.abs(f-x)<.01&&Math.abs(m-v)<.01){if(Math.abs(h+p)<.1&&Math.abs(f+x)<.1&&Math.abs(m+v)<.1&&Math.abs(c+d+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(d+1)/2,b=(_+1)/2,A=(h+p)/4,q=(f+x)/4,O=(m+v)/4;return E>S&&E>b?E<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(E),i=A/r,s=q/r):S>b?S<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),r=A/i,s=O/i):b<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),r=q/s,i=O/s),this.set(r,i,s,t),this}let w=Math.sqrt((v-m)*(v-m)+(f-x)*(f-x)+(p-h)*(p-h));return Math.abs(w)<.001&&(w=1),this.x=(v-m)/w,this.y=(f-x)/w,this.z=(p-h)/w,this.w=Math.acos((c+d+_-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=vt(this.x,e.x,t.x),this.y=vt(this.y,e.y,t.y),this.z=vt(this.z,e.z,t.z),this.w=vt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=vt(this.x,e,t),this.y=vt(this.y,e,t),this.z=vt(this.z,e,t),this.w=vt(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(vt(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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 UM extends Ws{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ei,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new ln(0,0,e,t),this.scissorTest=!1,this.viewport=new ln(0,0,e,t);const i={width:e,height:t,depth:r.depth},s=new Dn(i);this.textures=[];const o=r.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const t={minFilter:Ei,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;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,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new ip(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class js extends UM{constructor(e=1,t=1,r={}){super(e,t,r),this.isWebGLRenderTarget=!0}}class g_ extends Dn{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class FM extends Dn{constructor(e=null,t=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Vs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wi{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(ei.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(ei.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const r=ei.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,ei):ei.fromBufferAttribute(s,o),ei.applyMatrix4(e.matrixWorld),this.expandByPoint(ei);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),tu.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),tu.copy(r.boundingBox)),tu.applyMatrix4(e.matrixWorld),this.union(tu)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return e.x>=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,ei),ei.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_l),nu.subVectors(this.max,_l),Yo.subVectors(e.a,_l),Ko.subVectors(e.b,_l),Zo.subVectors(e.c,_l),ps.subVectors(Ko,Yo),ms.subVectors(Zo,Ko),Xs.subVectors(Yo,Zo);let t=[0,-ps.z,ps.y,0,-ms.z,ms.y,0,-Xs.z,Xs.y,ps.z,0,-ps.x,ms.z,0,-ms.x,Xs.z,0,-Xs.x,-ps.y,ps.x,0,-ms.y,ms.x,0,-Xs.y,Xs.x,0];return!ap(t,Yo,Ko,Zo,nu)||(t=[1,0,0,0,1,0,0,0,1],!ap(t,Yo,Ko,Zo,nu))?!1:(ru.crossVectors(ps,ms),t=[ru.x,ru.y,ru.z],ap(t,Yo,Ko,Zo,nu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ei).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ei).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:(Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),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 Bi=[new j,new j,new j,new j,new j,new j,new j,new j],ei=new j,tu=new wi,Yo=new j,Ko=new j,Zo=new j,ps=new j,ms=new j,Xs=new j,_l=new j,nu=new j,ru=new j,$s=new j;function ap(n,e,t,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){$s.fromArray(n,s);const a=i.x*Math.abs($s.x)+i.y*Math.abs($s.y)+i.z*Math.abs($s.z),l=e.dot($s),c=t.dot($s),h=r.dot($s);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const zM=new wi,vl=new j,lp=new j;class iu{constructor(e=new j,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 r=this.center;t!==void 0?r.copy(t):zM.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const r=this.center.distanceToSquared(e);return t.copy(e),r>this.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;vl.subVectors(e,this.center);const t=vl.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(vl,i/r),this.radius+=i}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):(lp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vl.copy(e.center).add(lp)),this.expandByPoint(vl.copy(e.center).sub(lp))),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 Vi=new j,cp=new j,su=new j,gs=new j,up=new j,ou=new j,hp=new j;class au{constructor(e=new j,t=new j(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,Vi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Vi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Vi.copy(this.origin).addScaledVector(this.direction,t),Vi.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){cp.copy(e).add(t).multiplyScalar(.5),su.copy(t).sub(e).normalize(),gs.copy(this.origin).sub(cp);const s=e.distanceTo(t)*.5,o=-this.direction.dot(su),a=gs.dot(this.direction),l=-gs.dot(su),c=gs.lengthSq(),h=Math.abs(1-o*o);let f,p,d,m;if(h>0)if(f=o*l-a,p=o*a-l,m=s*h,f>=0)if(p>=-m)if(p<=m){const x=1/h;f*=x,p*=x,d=f*(f+o*p+2*a)+p*(o*f+p+2*l)+c}else p=s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;else p=-s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;else p<=-m?(f=Math.max(0,-(-o*s+a)),p=f>0?-s:Math.min(Math.max(-s,-l),s),d=-f*f+p*(p+2*l)+c):p<=m?(f=0,p=Math.min(Math.max(-s,-l),s),d=p*(p+2*l)+c):(f=Math.max(0,-(o*s+a)),p=f>0?s:Math.min(Math.max(-s,-l),s),d=-f*f+p*(p+2*l)+c);else p=o>0?-s:s,f=Math.max(0,-(o*p+a)),d=-f*f+p*(p+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(cp).addScaledVector(su,p),d}intersectSphere(e,t){Vi.subVectors(e.center,this.origin);const r=Vi.dot(this.direction),i=Vi.dot(Vi)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,t):this.at(a,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 r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(r=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(r=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,o=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,o=(e.min.y-p.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(a=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,Vi)!==null}intersectTriangle(e,t,r,i,s){up.subVectors(t,e),ou.subVectors(r,e),hp.crossVectors(up,ou);let o=this.direction.dot(hp),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;gs.subVectors(this.origin,e);const l=a*this.direction.dot(ou.crossVectors(gs,ou));if(l<0)return null;const c=a*this.direction.dot(up.cross(gs));if(c<0||l+c>o)return null;const h=-a*gs.dot(hp);return h<0?null:this.at(h/o,s)}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 Gt{constructor(e,t,r,i,s,o,a,l,c,h,f,p,d,m,x,v){Gt.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,r,i,s,o,a,l,c,h,f,p,d,m,x,v)}set(e,t,r,i,s,o,a,l,c,h,f,p,d,m,x,v){const _=this.elements;return _[0]=e,_[4]=t,_[8]=r,_[12]=i,_[1]=s,_[5]=o,_[9]=a,_[13]=l,_[2]=c,_[6]=h,_[10]=f,_[14]=p,_[3]=d,_[7]=m,_[11]=x,_[15]=v,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 Gt().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[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,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,i=1/Jo.setFromMatrixColumn(e,0).length(),s=1/Jo.setFromMatrixColumn(e,1).length(),o=1/Jo.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const p=o*h,d=o*f,m=a*h,x=a*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=d+m*c,t[5]=p-x*c,t[9]=-a*l,t[2]=x-p*c,t[6]=m+d*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*h,d=l*f,m=c*h,x=c*f;t[0]=p+x*a,t[4]=m*a-d,t[8]=o*c,t[1]=o*f,t[5]=o*h,t[9]=-a,t[2]=d*a-m,t[6]=x+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*h,d=l*f,m=c*h,x=c*f;t[0]=p-x*a,t[4]=-o*f,t[8]=m+d*a,t[1]=d+m*a,t[5]=o*h,t[9]=x-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*h,d=o*f,m=a*h,x=a*f;t[0]=l*h,t[4]=m*c-d,t[8]=p*c+x,t[1]=l*f,t[5]=x*c+p,t[9]=d*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,d=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=x-p*f,t[8]=m*f+d,t[1]=f,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=d*f+m,t[10]=p-x*f}else if(e.order==="XZY"){const p=o*l,d=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=p*f+x,t[5]=o*h,t[9]=d*f-m,t[2]=m*f-d,t[6]=a*h,t[10]=x*f+p}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(kM,e,BM)}lookAt(e,t,r){const i=this.elements;return gr.subVectors(e,t),gr.lengthSq()===0&&(gr.z=1),gr.normalize(),_s.crossVectors(r,gr),_s.lengthSq()===0&&(Math.abs(r.z)===1?gr.x+=1e-4:gr.z+=1e-4,gr.normalize(),_s.crossVectors(r,gr)),_s.normalize(),lu.crossVectors(gr,_s),i[0]=_s.x,i[4]=lu.x,i[8]=gr.x,i[1]=_s.y,i[5]=lu.y,i[9]=gr.y,i[2]=_s.z,i[6]=lu.z,i[10]=gr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],p=r[9],d=r[13],m=r[2],x=r[6],v=r[10],_=r[14],w=r[3],E=r[7],S=r[11],b=r[15],A=i[0],q=i[4],O=i[8],T=i[12],I=i[1],N=i[5],H=i[9],W=i[13],Q=i[2],ae=i[6],J=i[10],se=i[14],B=i[3],ge=i[7],F=i[11],X=i[15];return s[0]=o*A+a*I+l*Q+c*B,s[4]=o*q+a*N+l*ae+c*ge,s[8]=o*O+a*H+l*J+c*F,s[12]=o*T+a*W+l*se+c*X,s[1]=h*A+f*I+p*Q+d*B,s[5]=h*q+f*N+p*ae+d*ge,s[9]=h*O+f*H+p*J+d*F,s[13]=h*T+f*W+p*se+d*X,s[2]=m*A+x*I+v*Q+_*B,s[6]=m*q+x*N+v*ae+_*ge,s[10]=m*O+x*H+v*J+_*F,s[14]=m*T+x*W+v*se+_*X,s[3]=w*A+E*I+S*Q+b*B,s[7]=w*q+E*N+S*ae+b*ge,s[11]=w*O+E*H+S*J+b*F,s[15]=w*T+E*W+S*se+b*X,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],r=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],f=e[6],p=e[10],d=e[14],m=e[3],x=e[7],v=e[11],_=e[15];return m*(+s*l*f-i*c*f-s*a*p+r*c*p+i*a*d-r*l*d)+x*(+t*l*d-t*c*p+s*o*p-i*o*d+i*c*h-s*l*h)+v*(+t*c*f-t*a*d-s*o*f+r*o*d+s*a*h-r*c*h)+_*(-i*a*h-t*l*f+t*a*p+i*o*f-r*o*p+r*l*h)}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,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=e[9],p=e[10],d=e[11],m=e[12],x=e[13],v=e[14],_=e[15],w=f*v*c-x*p*c+x*l*d-a*v*d-f*l*_+a*p*_,E=m*p*c-h*v*c-m*l*d+o*v*d+h*l*_-o*p*_,S=h*x*c-m*f*c+m*a*d-o*x*d-h*a*_+o*f*_,b=m*f*l-h*x*l-m*a*p+o*x*p+h*a*v-o*f*v,A=t*w+r*E+i*S+s*b;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const q=1/A;return e[0]=w*q,e[1]=(x*p*s-f*v*s-x*i*d+r*v*d+f*i*_-r*p*_)*q,e[2]=(a*v*s-x*l*s+x*i*c-r*v*c-a*i*_+r*l*_)*q,e[3]=(f*l*s-a*p*s-f*i*c+r*p*c+a*i*d-r*l*d)*q,e[4]=E*q,e[5]=(h*v*s-m*p*s+m*i*d-t*v*d-h*i*_+t*p*_)*q,e[6]=(m*l*s-o*v*s-m*i*c+t*v*c+o*i*_-t*l*_)*q,e[7]=(o*p*s-h*l*s+h*i*c-t*p*c-o*i*d+t*l*d)*q,e[8]=S*q,e[9]=(m*f*s-h*x*s-m*r*d+t*x*d+h*r*_-t*f*_)*q,e[10]=(o*x*s-m*a*s+m*r*c-t*x*c-o*r*_+t*a*_)*q,e[11]=(h*a*s-o*f*s-h*r*c+t*f*c+o*r*d-t*a*d)*q,e[12]=b*q,e[13]=(h*x*i-m*f*i+m*r*p-t*x*p-h*r*v+t*f*v)*q,e[14]=(m*a*i-o*x*i-m*r*l+t*x*l+o*r*v-t*a*v)*q,e[15]=(o*f*i-h*a*i+h*r*l-t*f*l-o*r*p+t*a*p)*q,this}scale(e){const t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))}makeTranslation(e,t,r){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,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),i=Math.sin(t),s=1-r,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,f=a+a,p=s*c,d=s*h,m=s*f,x=o*h,v=o*f,_=a*f,w=l*c,E=l*h,S=l*f,b=r.x,A=r.y,q=r.z;return i[0]=(1-(x+_))*b,i[1]=(d+S)*b,i[2]=(m-E)*b,i[3]=0,i[4]=(d-S)*A,i[5]=(1-(p+_))*A,i[6]=(v+w)*A,i[7]=0,i[8]=(m+E)*q,i[9]=(v-w)*q,i[10]=(1-(p+x))*q,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){const i=this.elements;let s=Jo.set(i[0],i[1],i[2]).length();const o=Jo.set(i[4],i[5],i[6]).length(),a=Jo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],ti.copy(this);const c=1/s,h=1/o,f=1/a;return ti.elements[0]*=c,ti.elements[1]*=c,ti.elements[2]*=c,ti.elements[4]*=h,ti.elements[5]*=h,ti.elements[6]*=h,ti.elements[8]*=f,ti.elements[9]*=f,ti.elements[10]*=f,t.setFromRotationMatrix(ti),r.x=s,r.y=o,r.z=a,this}makePerspective(e,t,r,i,s,o,a=Mi,l=!1){const c=this.elements,h=2*s/(t-e),f=2*s/(r-i),p=(t+e)/(t-e),d=(r+i)/(r-i);let m,x;if(l)m=s/(o-s),x=o*s/(o-s);else if(a===Mi)m=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(a===Jc)m=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=f,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,r,i,s,o,a=Mi,l=!1){const c=this.elements,h=2/(t-e),f=2/(r-i),p=-(t+e)/(t-e),d=-(r+i)/(r-i);let m,x;if(l)m=1/(o-s),x=o/(o-s);else if(a===Mi)m=-2/(o-s),x=-(o+s)/(o-s);else if(a===Jc)m=-1/(o-s),x=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=f,c[9]=0,c[13]=d,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const Jo=new j,ti=new Gt,kM=new j(0,0,0),BM=new j(1,1,1),_s=new j,lu=new j,gr=new j,__=new Gt,v_=new ds;class ni{constructor(e=0,t=0,r=0,i=ni.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,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,r=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],p=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(vt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-vt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(vt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-vt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(vt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-vt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return __.makeRotationFromQuaternion(e),this.setFromRotationMatrix(__,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return v_.setFromEuler(this),this.setFromQuaternion(v_,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}}ni.DEFAULT_ORDER="XYZ";class fp{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let VM=0;const x_=new j,Qo=new ds,Hi=new Gt,cu=new j,xl=new j,HM=new j,GM=new ds,y_=new j(1,0,0),S_=new j(0,1,0),E_=new j(0,0,1),b_={type:"added"},WM={type:"removed"},ea={type:"childadded",child:null},dp={type:"childremoved",child:null};class Dt extends Ws{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:VM++}),this.uuid=Wo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dt.DEFAULT_UP.clone();const e=new j,t=new ni,r=new ds,i=new j(1,1,1);function s(){r.setFromEuler(t,!1)}function o(){t.setFromQuaternion(r,void 0,!1)}t._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Gt},normalMatrix:{value:new mt}}),this.matrix=new Gt,this.matrixWorld=new Gt,this.matrixAutoUpdate=Dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fp,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Qo.setFromAxisAngle(e,t),this.quaternion.multiply(Qo),this}rotateOnWorldAxis(e,t){return Qo.setFromAxisAngle(e,t),this.quaternion.premultiply(Qo),this}rotateX(e){return this.rotateOnAxis(y_,e)}rotateY(e){return this.rotateOnAxis(S_,e)}rotateZ(e){return this.rotateOnAxis(E_,e)}translateOnAxis(e,t){return x_.copy(e).applyQuaternion(this.quaternion),this.position.add(x_.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(y_,e)}translateY(e){return this.translateOnAxis(S_,e)}translateZ(e){return this.translateOnAxis(E_,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Hi.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?cu.copy(e):cu.set(e,t,r);const i=this.parent;this.updateWorldMatrix(!0,!1),xl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Hi.lookAt(xl,cu,this.up):Hi.lookAt(cu,xl,this.up),this.quaternion.setFromRotationMatrix(Hi),i&&(Hi.extractRotation(i.matrixWorld),Qo.setFromRotationMatrix(Hi),this.quaternion.premultiply(Qo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(b_),ea.child=e,this.dispatchEvent(ea),ea.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(WM),dp.child=e,this.dispatchEvent(dp),dp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Hi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Hi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Hi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(b_),ea.child=e,this.dispatchEvent(ea),ea.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xl,e,HM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xl,GM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)}updateWorldMatrix(e,t){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),f=o(e.shapes),p=o(e.skeletons),d=o(e.animations),m=o(e.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),d.length>0&&(r.animations=d),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}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 r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Dt.DEFAULT_UP=new j(0,1,0),Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ri=new j,Gi=new j,pp=new j,Wi=new j,ta=new j,na=new j,M_=new j,mp=new j,gp=new j,_p=new j,vp=new ln,xp=new ln,yp=new ln;class ii{constructor(e=new j,t=new j,r=new j){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),ri.subVectors(e,t),i.cross(ri);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){ri.subVectors(i,t),Gi.subVectors(r,t),pp.subVectors(e,t);const o=ri.dot(ri),a=ri.dot(Gi),l=ri.dot(pp),c=Gi.dot(Gi),h=Gi.dot(pp),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const p=1/f,d=(c*l-a*h)*p,m=(o*h-a*l)*p;return s.set(1-d-m,m,d)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,Wi)===null?!1:Wi.x>=0&&Wi.y>=0&&Wi.x+Wi.y<=1}static getInterpolation(e,t,r,i,s,o,a,l){return this.getBarycoord(e,t,r,i,Wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Wi.x),l.addScaledVector(o,Wi.y),l.addScaledVector(a,Wi.z),l)}static getInterpolatedAttribute(e,t,r,i,s,o){return vp.setScalar(0),xp.setScalar(0),yp.setScalar(0),vp.fromBufferAttribute(e,t),xp.fromBufferAttribute(e,r),yp.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(vp,s.x),o.addScaledVector(xp,s.y),o.addScaledVector(yp,s.z),o}static isFrontFacing(e,t,r,i){return ri.subVectors(r,t),Gi.subVectors(e,t),ri.cross(Gi).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 ri.subVectors(this.c,this.b),Gi.subVectors(this.a,this.b),ri.cross(Gi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ii.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ii.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return ii.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return ii.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ii.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let o,a;ta.subVectors(i,r),na.subVectors(s,r),mp.subVectors(e,r);const l=ta.dot(mp),c=na.dot(mp);if(l<=0&&c<=0)return t.copy(r);gp.subVectors(e,i);const h=ta.dot(gp),f=na.dot(gp);if(h>=0&&f<=h)return t.copy(i);const p=l*f-h*c;if(p<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(r).addScaledVector(ta,o);_p.subVectors(e,s);const d=ta.dot(_p),m=na.dot(_p);if(m>=0&&d<=m)return t.copy(s);const x=d*c-l*m;if(x<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(r).addScaledVector(na,a);const v=h*m-d*f;if(v<=0&&f-h>=0&&d-m>=0)return M_.subVectors(s,i),a=(f-h)/(f-h+(d-m)),t.copy(i).addScaledVector(M_,a);const _=1/(v+x+p);return o=x*_,a=p*_,t.copy(r).addScaledVector(ta,o).addScaledVector(na,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const w_={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},vs={h:0,s:0,l:0},uu={h:0,s:0,l:0};function Sp(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Et{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(t===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=mr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ct.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=Ct.workingColorSpace){return this.r=e,this.g=t,this.b=r,Ct.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=Ct.workingColorSpace){if(e=RM(e,1),t=vt(t,0,1),r=vt(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,o=2*r-s;this.r=Sp(o,s,e+1/3),this.g=Sp(o,s,e),this.b=Sp(o,s,e-1/3)}return Ct.colorSpaceToWorking(this,i),this}setStyle(e,t=mr){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,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=mr){const r=w_[e.toLowerCase()];return r!==void 0?this.setHex(r,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=ki(e.r),this.g=ki(e.g),this.b=ki(e.b),this}copyLinearToSRGB(e){return this.r=Xo(e.r),this.g=Xo(e.g),this.b=Xo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mr){return Ct.workingToColorSpace(Nn.copy(this),e),Math.round(vt(Nn.r*255,0,255))*65536+Math.round(vt(Nn.g*255,0,255))*256+Math.round(vt(Nn.b*255,0,255))}getHexString(e=mr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ct.workingColorSpace){Ct.workingToColorSpace(Nn.copy(this),t);const r=Nn.r,i=Nn.g,s=Nn.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ct.workingColorSpace){return Ct.workingToColorSpace(Nn.copy(this),t),e.r=Nn.r,e.g=Nn.g,e.b=Nn.b,e}getStyle(e=mr){Ct.workingToColorSpace(Nn.copy(this),e);const t=Nn.r,r=Nn.g,i=Nn.b;return e!==mr?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,t,r){return this.getHSL(vs),this.setHSL(vs.h+e,vs.s+t,vs.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(vs),e.getHSL(uu);const r=tp(vs.h,uu.h,t),i=tp(vs.s,uu.s,t),s=tp(vs.l,uu.l,t);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*r+s[6]*i,this.g=s[1]*t+s[4]*r+s[7]*i,this.b=s[2]*t+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Nn=new Et;Et.NAMES=w_;let jM=0;class Ys extends Ws{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Wo(),this.name="",this.type="Material",this.blending=zo,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ld,this.blendDst=cd,this.blendEquation=Bs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Et(0,0,0),this.blendAlpha=0,this.depthFunc=ko,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=a_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Go,this.stencilZFail=Go,this.stencilZPass=Go,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=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 r=e[t];if(r===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==zo&&(r.blending=this.blending),this.side!==cs&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==ld&&(r.blendSrc=this.blendSrc),this.blendDst!==cd&&(r.blendDst=this.blendDst),this.blendEquation!==Bs&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==ko&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==a_&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Go&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Go&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Go&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}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 r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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 Ks extends Ys{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Et(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 ni,this.combine=_d,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 gn=new j,hu=new Ne;let XM=0;class Dr{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:XM++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=c_,this.updateRanges=[],this.gpuType=zi,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,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,r=this.count;t<r;t++)hu.fromBufferAttribute(this,t),hu.applyMatrix3(e),this.setXY(t,hu.x,hu.y);else if(this.itemSize===3)for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix3(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyMatrix4(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.applyNormalMatrix(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)gn.fromBufferAttribute(this,t),gn.transformDirection(e),this.setXYZ(t,gn.x,gn.y,gn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=ml(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=tr(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ml(t,this.array)),t}setX(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ml(t,this.array)),t}setY(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ml(t,this.array)),t}setZ(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ml(t,this.array)),t}setW(e,t){return this.normalized&&(t=tr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array),i=tr(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=tr(t,this.array),r=tr(r,this.array),i=tr(i,this.array),s=tr(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==c_&&(e.usage=this.usage),e}}class T_ extends Dr{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class A_ extends Dr{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class Gn extends Dr{constructor(e,t,r){super(new Float32Array(e),t,r)}}let $M=0;const Nr=new Gt,Ep=new Dt,ra=new j,_r=new wi,yl=new wi,wn=new j;class nr extends Ws{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$M++}),this.uuid=Wo(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(f_(e)?A_:T_)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new mt().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Nr.makeRotationFromQuaternion(e),this.applyMatrix4(Nr),this}rotateX(e){return Nr.makeRotationX(e),this.applyMatrix4(Nr),this}rotateY(e){return Nr.makeRotationY(e),this.applyMatrix4(Nr),this}rotateZ(e){return Nr.makeRotationZ(e),this.applyMatrix4(Nr),this}translate(e,t,r){return Nr.makeTranslation(e,t,r),this.applyMatrix4(Nr),this}scale(e,t,r){return Nr.makeScale(e,t,r),this.applyMatrix4(Nr),this}lookAt(e){return Ep.lookAt(e),Ep.updateMatrix(),this.applyMatrix4(Ep.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ra).negate(),this.translate(ra.x,ra.y,ra.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Gn(r,3))}else{const r=Math.min(e.length,t.count);for(let i=0;i<r;i++){const s=e[i];t.setXYZ(i,s.x,s.y,s.z||0)}e.length>t.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 wi);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 j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let r=0,i=t.length;r<i;r++){const s=t[r];_r.setFromBufferAttribute(s),this.morphTargetsRelative?(wn.addVectors(this.boundingBox.min,_r.min),this.boundingBox.expandByPoint(wn),wn.addVectors(this.boundingBox.max,_r.max),this.boundingBox.expandByPoint(wn)):(this.boundingBox.expandByPoint(_r.min),this.boundingBox.expandByPoint(_r.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new iu);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){const r=this.boundingSphere.center;if(_r.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];yl.setFromBufferAttribute(a),this.morphTargetsRelative?(wn.addVectors(_r.min,yl.min),_r.expandByPoint(wn),wn.addVectors(_r.max,yl.max),_r.expandByPoint(wn)):(_r.expandByPoint(yl.min),_r.expandByPoint(yl.max))}_r.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)wn.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(wn));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)wn.fromBufferAttribute(a,c),l&&(ra.fromBufferAttribute(e,c),wn.add(ra)),i=Math.max(i,r.distanceToSquared(wn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=t.position,i=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Dr(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let O=0;O<r.count;O++)a[O]=new j,l[O]=new j;const c=new j,h=new j,f=new j,p=new Ne,d=new Ne,m=new Ne,x=new j,v=new j;function _(O,T,I){c.fromBufferAttribute(r,O),h.fromBufferAttribute(r,T),f.fromBufferAttribute(r,I),p.fromBufferAttribute(s,O),d.fromBufferAttribute(s,T),m.fromBufferAttribute(s,I),h.sub(c),f.sub(c),d.sub(p),m.sub(p);const N=1/(d.x*m.y-m.x*d.y);isFinite(N)&&(x.copy(h).multiplyScalar(m.y).addScaledVector(f,-d.y).multiplyScalar(N),v.copy(f).multiplyScalar(d.x).addScaledVector(h,-m.x).multiplyScalar(N),a[O].add(x),a[T].add(x),a[I].add(x),l[O].add(v),l[T].add(v),l[I].add(v))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let O=0,T=w.length;O<T;++O){const I=w[O],N=I.start,H=I.count;for(let W=N,Q=N+H;W<Q;W+=3)_(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const E=new j,S=new j,b=new j,A=new j;function q(O){b.fromBufferAttribute(i,O),A.copy(b);const T=a[O];E.copy(T),E.sub(b.multiplyScalar(b.dot(T))).normalize(),S.crossVectors(A,T);const N=S.dot(l[O])<0?-1:1;o.setXYZW(O,E.x,E.y,E.z,N)}for(let O=0,T=w.length;O<T;++O){const I=w[O],N=I.start,H=I.count;for(let W=N,Q=N+H;W<Q;W+=3)q(e.getX(W+0)),q(e.getX(W+1)),q(e.getX(W+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Dr(new Float32Array(t.count*3),3),this.setAttribute("normal",r);else for(let p=0,d=r.count;p<d;p++)r.setXYZ(p,0,0,0);const i=new j,s=new j,o=new j,a=new j,l=new j,c=new j,h=new j,f=new j;if(e)for(let p=0,d=e.count;p<d;p+=3){const m=e.getX(p+0),x=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,x),o.fromBufferAttribute(t,v),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let p=0,d=t.count;p<d;p+=3)i.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(p+0,h.x,h.y,h.z),r.setXYZ(p+1,h.x,h.y,h.z),r.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)wn.fromBufferAttribute(e,t),wn.normalize(),e.setXYZ(t,wn.x,wn.y,wn.z)}toNonIndexed(){function e(a,l){const c=a.array,h=a.itemSize,f=a.normalized,p=new c.constructor(l.length*h);let d=0,m=0;for(let x=0,v=l.length;x<v;x++){a.isInterleavedBufferAttribute?d=l[x]*a.data.stride+a.offset:d=l[x]*h;for(let _=0;_<h;_++)p[m++]=c[d++]}return new Dr(p,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new nr,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,r);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const p=c[h],d=e(p,r);l.push(d)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,p=c.length;f<p;f++){const d=c[f];h.push(d.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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 r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],f=s[c];for(let p=0,d=f.length;p<d;p++)h.push(f[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const C_=new Gt,Zs=new au,fu=new iu,R_=new j,du=new j,pu=new j,mu=new j,bp=new j,gu=new j,P_=new j,_u=new j;class Tn extends Dt{constructor(e=new nr,t=new Ks){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){gu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(bp.fromBufferAttribute(f,e),o?gu.addScaledVector(bp,h):gu.addScaledVector(bp.sub(t),h))}t.add(gu)}return t}raycast(e,t){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),fu.copy(r.boundingSphere),fu.applyMatrix4(s),Zs.copy(e.ray).recast(e.near),!(fu.containsPoint(Zs.origin)===!1&&(Zs.intersectSphere(fu,R_)===null||Zs.origin.distanceToSquared(R_)>(e.far-e.near)**2))&&(C_.copy(s).invert(),Zs.copy(e.ray).applyMatrix4(C_),!(r.boundingBox!==null&&Zs.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,t,Zs)))}_computeIntersections(e,t,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,p=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,x=p.length;m<x;m++){const v=p[m],_=o[v.materialIndex],w=Math.max(v.start,d.start),E=Math.min(a.count,Math.min(v.start+v.count,d.start+d.count));for(let S=w,b=E;S<b;S+=3){const A=a.getX(S),q=a.getX(S+1),O=a.getX(S+2);i=vu(this,_,e,r,c,h,f,A,q,O),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=v.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),x=Math.min(a.count,d.start+d.count);for(let v=m,_=x;v<_;v+=3){const w=a.getX(v),E=a.getX(v+1),S=a.getX(v+2);i=vu(this,o,e,r,c,h,f,w,E,S),i&&(i.faceIndex=Math.floor(v/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,x=p.length;m<x;m++){const v=p[m],_=o[v.materialIndex],w=Math.max(v.start,d.start),E=Math.min(l.count,Math.min(v.start+v.count,d.start+d.count));for(let S=w,b=E;S<b;S+=3){const A=S,q=S+1,O=S+2;i=vu(this,_,e,r,c,h,f,A,q,O),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=v.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),x=Math.min(l.count,d.start+d.count);for(let v=m,_=x;v<_;v+=3){const w=v,E=v+1,S=v+2;i=vu(this,o,e,r,c,h,f,w,E,S),i&&(i.faceIndex=Math.floor(v/3),t.push(i))}}}}function YM(n,e,t,r,i,s,o,a){let l;if(e.side===er?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,e.side===cs,a),l===null)return null;_u.copy(a),_u.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(_u);return c<t.near||c>t.far?null:{distance:c,point:_u.clone(),object:n}}function vu(n,e,t,r,i,s,o,a,l,c){n.getVertexPosition(a,du),n.getVertexPosition(l,pu),n.getVertexPosition(c,mu);const h=YM(n,e,t,r,du,pu,mu,P_);if(h){const f=new j;ii.getBarycoord(P_,du,pu,mu,f),i&&(h.uv=ii.getInterpolatedAttribute(i,a,l,c,f,new Ne)),s&&(h.uv1=ii.getInterpolatedAttribute(s,a,l,c,f,new Ne)),o&&(h.normal=ii.getInterpolatedAttribute(o,a,l,c,f,new j),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const p={a,b:l,c,normal:new j,materialIndex:0};ii.getNormal(du,pu,mu,p.normal),h.face=p,h.barycoord=f}return h}class Js extends nr{constructor(e=1,t=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let p=0,d=0;m("z","y","x",-1,-1,r,t,e,o,s,0),m("z","y","x",1,-1,r,t,-e,o,s,1),m("x","z","y",1,1,e,r,t,i,o,2),m("x","z","y",1,-1,e,r,-t,i,o,3),m("x","y","z",1,-1,e,t,r,i,s,4),m("x","y","z",-1,-1,e,t,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(h,3)),this.setAttribute("uv",new Gn(f,2));function m(x,v,_,w,E,S,b,A,q,O,T){const I=S/q,N=b/O,H=S/2,W=b/2,Q=A/2,ae=q+1,J=O+1;let se=0,B=0;const ge=new j;for(let F=0;F<J;F++){const X=F*N-W;for(let de=0;de<ae;de++){const ye=de*I-H;ge[x]=ye*w,ge[v]=X*E,ge[_]=Q,c.push(ge.x,ge.y,ge.z),ge[x]=0,ge[v]=0,ge[_]=A>0?1:-1,h.push(ge.x,ge.y,ge.z),f.push(de/q),f.push(1-F/O),se+=1}}for(let F=0;F<O;F++)for(let X=0;X<q;X++){const de=p+X+ae*F,ye=p+X+ae*(F+1),Ee=p+(X+1)+ae*(F+1),V=p+(X+1)+ae*F;l.push(de,ye,V),l.push(ye,Ee,V),B+=6}a.addGroup(d,B,T),d+=B,p+=se}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Js(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ia(n){const e={};for(const t in n){e[t]={};for(const r in n[t]){const i=n[t][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][r]=null):e[t][r]=i.clone():Array.isArray(i)?e[t][r]=i.slice():e[t][r]=i}}return e}function Wn(n){const e={};for(let t=0;t<n.length;t++){const r=ia(n[t]);for(const i in r)e[i]=r[i]}return e}function KM(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function I_(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ct.workingColorSpace}const ZM={clone:ia,merge:Wn};var JM=`void main() {
75
75
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
76
76
  }`,QM=`void main() {
77
77
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -110,7 +110,7 @@ best distance: ${f.d}`);const v=[f.x,f.y];return v.distance=f.d,v}function Hc(n,
110
110
  gl_FragColor = texture2D( tEquirect, sampleUV );
111
111
 
112
112
  }
113
- `},i=new Js(5,5,5),s=new xs({name:"CubemapFromEquirect",uniforms:ia(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:er,blending:us});s.uniforms.tEquirect.value=t;const o=new Tn(i,s),a=t.minFilter;return t.minFilter===Hs&&(t.minFilter=Ei),new e4(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,i);e.setRenderTarget(s)}}class aa extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const n4={type:"move"};class Mp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new aa,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 aa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new aa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j),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 r of e.hand.values())this._getHandJoint(t,r)}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,r){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const x of e.hand.values()){const v=t.getJointPose(x,r),_=this._getHandJoint(c,x);v!==null&&(_.matrix.fromArray(v.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=v.radius),_.visible=v!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=h.position.distanceTo(f.position),d=.02,m=.005;c.inputState.pinching&&p>d+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=d-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(n4)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new aa;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class r4 extends Dt{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 ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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}}const xu=new j,N_=new j;class yu extends Dt{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 r=0,i=t.length;r<i;r++){const s=t[r];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,r=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:r,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let r=0;r<t.length;r++)if(t[r].distance===e){const i=t.splice(r,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let r,i;for(r=1,i=t.length;r<i;r++){let s=t[r].distance;if(t[r].object.visible&&(s-=s*t[r].hysteresis),e<s)break}return t[r-1].object}return null}raycast(e,t){if(this.levels.length>0){xu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(xu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){xu.setFromMatrixPosition(e.matrixWorld),N_.setFromMatrixPosition(this.matrixWorld);const r=xu.distanceTo(N_)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),r>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const r=this.levels;for(let i=0,s=r.length;i<s;i++){const o=r[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const wp=new j,i4=new j,s4=new mt;class Ss{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const i=wp.subVectors(r,t).cross(i4.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const r=e.delta(wp),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||s4.getNormalMatrix(e),i=this.coplanarPoint(wp).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 Qs=new iu,o4=new Ne(.5,.5),Su=new j;class Tp{constructor(e=new Ss,t=new Ss,r=new Ss,i=new Ss,s=new Ss,o=new Ss){this.planes=[e,t,r,i,s,o]}set(e,t,r,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=Mi,r=!1){const i=this.planes,s=e.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],f=s[5],p=s[6],d=s[7],m=s[8],x=s[9],v=s[10],_=s[11],w=s[12],E=s[13],S=s[14],b=s[15];if(i[0].setComponents(c-o,d-h,_-m,b-w).normalize(),i[1].setComponents(c+o,d+h,_+m,b+w).normalize(),i[2].setComponents(c+a,d+f,_+x,b+E).normalize(),i[3].setComponents(c-a,d-f,_-x,b-E).normalize(),r)i[4].setComponents(l,p,v,S).normalize(),i[5].setComponents(c-l,d-p,_-v,b-S).normalize();else if(i[4].setComponents(c-l,d-p,_-v,b-S).normalize(),t===Mi)i[5].setComponents(c+l,d+p,_+v,b+S).normalize();else if(t===Jc)i[5].setComponents(l,p,v,S).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(),Qs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qs)}intersectsSprite(e){Qs.center.set(0,0,0);const t=o4.distanceTo(e.center);return Qs.radius=.7071067811865476+t,Qs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qs)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const i=t[r];if(Su.x=i.normal.x>0?e.max.x:e.min.x,Su.y=i.normal.y>0?e.max.y:e.min.y,Su.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Su)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Eu extends Ys{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Et(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const bu=new j,Mu=new j,U_=new Gt,Sl=new au,wu=new iu,Ap=new j,F_=new j;class a4 extends Dt{constructor(e=new nr,t=new Eu){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[0];for(let i=1,s=t.count;i<s;i++)bu.fromBufferAttribute(t,i-1),Mu.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=bu.distanceTo(Mu);e.setAttribute("lineDistance",new Gn(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),wu.copy(r.boundingSphere),wu.applyMatrix4(i),wu.radius+=s,e.ray.intersectsSphere(wu)===!1)return;U_.copy(i).invert(),Sl.copy(e.ray).applyMatrix4(U_);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=r.index,p=r.attributes.position;if(h!==null){const d=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let x=d,v=m-1;x<v;x+=c){const _=h.getX(x),w=h.getX(x+1),E=Tu(this,e,Sl,l,_,w,x);E&&t.push(E)}if(this.isLineLoop){const x=h.getX(m-1),v=h.getX(d),_=Tu(this,e,Sl,l,x,v,m-1);_&&t.push(_)}}else{const d=Math.max(0,o.start),m=Math.min(p.count,o.start+o.count);for(let x=d,v=m-1;x<v;x+=c){const _=Tu(this,e,Sl,l,x,x+1,x);_&&t.push(_)}if(this.isLineLoop){const x=Tu(this,e,Sl,l,m-1,d,m-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Tu(n,e,t,r,i,s,o){const a=n.geometry.attributes.position;if(bu.fromBufferAttribute(a,i),Mu.fromBufferAttribute(a,s),t.distanceSqToSegment(bu,Mu,Ap,F_)>r)return;Ap.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Ap);if(!(c<e.near||c>e.far))return{distance:c,point:F_.clone().applyMatrix4(n.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:n}}const z_=new j,k_=new j;class El extends a4{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,r=[];for(let i=0,s=t.count;i<s;i+=2)z_.fromBufferAttribute(t,i),k_.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+z_.distanceTo(k_);e.setAttribute("lineDistance",new Gn(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class B_ extends Dn{constructor(e,t,r=Gs,i,s,o,a=Jr,l=Jr,c,h=dl,f=1){if(h!==dl&&h!==pl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:f};super(p,i,s,o,a,l,h,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ip(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 Ti{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],p=r[i+1]-h,d=(o-h)/p;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new Ne:new j);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t=!1){const r=new j,i=[],s=[],o=[],a=new j,l=new Gt;for(let d=0;d<=e;d++){const m=d/e;i[d]=this.getTangentAt(m,new j)}s[0]=new j,o[0]=new j;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),p=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),p<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(vt(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(vt(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}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 Cp extends Ti{constructor(e=0,t=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Ne){const r=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),p=l-this.aX,d=c-this.aY;l=p*h-d*f+this.aX,c=p*f+d*h+this.aY}return r.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class l4 extends Cp{constructor(e,t,r,i,s,o){super(e,t,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Rp(){let n=0,e=0,t=0,r=0;function i(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let p=(o-s)/c-(a-s)/(c+h)+(a-o)/h,d=(a-o)/h-(l-o)/(h+f)+(l-a)/f;p*=h,d*=h,i(o,a,p,d)},calc:function(s){const o=s*s,a=o*s;return n+e*s+t*o+r*a}}}const Au=new j,Pp=new Rp,Ip=new Rp,Lp=new Rp;class c4 extends Ti{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(e,t=new j){const r=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(Au.subVectors(i[0],i[1]).add(i[0]),c=Au);const f=i[a%s],p=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(Au.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=Au),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),d),x=Math.pow(f.distanceToSquared(p),d),v=Math.pow(p.distanceToSquared(h),d);x<1e-4&&(x=1),m<1e-4&&(m=x),v<1e-4&&(v=x),Pp.initNonuniformCatmullRom(c.x,f.x,p.x,h.x,m,x,v),Ip.initNonuniformCatmullRom(c.y,f.y,p.y,h.y,m,x,v),Lp.initNonuniformCatmullRom(c.z,f.z,p.z,h.z,m,x,v)}else this.curveType==="catmullrom"&&(Pp.initCatmullRom(c.x,f.x,p.x,h.x,this.tension),Ip.initCatmullRom(c.y,f.y,p.y,h.y,this.tension),Lp.initCatmullRom(c.z,f.z,p.z,h.z,this.tension));return r.set(Pp.calc(l),Ip.calc(l),Lp.calc(l)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(new j().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function V_(n,e,t,r,i){const s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function u4(n,e){const t=1-n;return t*t*e}function h4(n,e){return 2*(1-n)*n*e}function f4(n,e){return n*n*e}function bl(n,e,t,r){return u4(n,e)+h4(n,t)+f4(n,r)}function d4(n,e){const t=1-n;return t*t*t*e}function p4(n,e){const t=1-n;return 3*t*t*n*e}function m4(n,e){return 3*(1-n)*n*n*e}function g4(n,e){return n*n*n*e}function Ml(n,e,t,r,i){return d4(n,e)+p4(n,t)+m4(n,r)+g4(n,i)}class H_ extends Ti{constructor(e=new Ne,t=new Ne,r=new Ne,i=new Ne){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new Ne){const r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Ml(e,i.x,s.x,o.x,a.x),Ml(e,i.y,s.y,o.y,a.y)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class _4 extends Ti{constructor(e=new j,t=new j,r=new j,i=new j){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new j){const r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Ml(e,i.x,s.x,o.x,a.x),Ml(e,i.y,s.y,o.y,a.y),Ml(e,i.z,s.z,o.z,a.z)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class G_ extends Ti{constructor(e=new Ne,t=new Ne){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ne){const r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ne){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class v4 extends Ti{constructor(e=new j,t=new j){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new j){const r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new j){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class W_ extends Ti{constructor(e=new Ne,t=new Ne,r=new Ne){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new Ne){const r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(bl(e,i.x,s.x,o.x),bl(e,i.y,s.y,o.y)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class x4 extends Ti{constructor(e=new j,t=new j,r=new j){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new j){const r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(bl(e,i.x,s.x,o.x),bl(e,i.y,s.y,o.y),bl(e,i.z,s.z,o.z)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class j_ extends Ti{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ne){const r=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(V_(a,l.x,c.x,h.x,f.x),V_(a,l.y,c.y,h.y,f.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(new Ne().fromArray(i))}return this}}var X_=Object.freeze({__proto__:null,ArcCurve:l4,CatmullRomCurve3:c4,CubicBezierCurve:H_,CubicBezierCurve3:_4,EllipseCurve:Cp,LineCurve:G_,LineCurve3:v4,QuadraticBezierCurve:W_,QuadraticBezierCurve3:x4,SplineCurve:j_});class y4 extends Ti{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const r=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new X_[r](t,e))}return this}getPoint(e,t){const r=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}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 r=0,i=this.curves.length;r<i;r++)t+=this.curves[r].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(t.push(h),r=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,r=this.curves.length;t<r;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){const i=e.curves[t];this.curves.push(new X_[i.type]().fromJSON(i))}return this}}class Op extends y4{constructor(e){super(),this.type="Path",this.currentPoint=new Ne,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const r=new G_(this.currentPoint.clone(),new Ne(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){const s=new W_(this.currentPoint.clone(),new Ne(e,t),new Ne(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,s,o){const a=new H_(this.currentPoint.clone(),new Ne(e,t),new Ne(r,i),new Ne(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),r=new j_(t);return this.curves.push(r),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,r,i,s,o),this}absarc(e,t,r,i,s,o){return this.absellipse(e,t,r,r,i,s,o),this}ellipse(e,t,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,r,i,s,o,a,l),this}absellipse(e,t,r,i,s,o,a,l){const c=new Cp(e,t,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),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 la extends Op{constructor(e){super(e),this.uuid=Wo(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let r=0,i=this.holes.length;r<i;r++)t[r]=this.holes[r].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,r=this.holes.length;t<r;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){const i=e.holes[t];this.holes.push(new Op().fromJSON(i))}return this}}function S4(n,e,t=2){const r=e&&e.length,i=r?e[0]*t:n.length;let s=$_(n,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=T4(n,e,s,t)),n.length>80*t){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let p=t;p<i;p+=t){const d=n[p],m=n[p+1];d<a&&(a=d),m<l&&(l=m),d>h&&(h=d),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return wl(s,o,t,a,l,c,0),o}function $_(n,e,t,r,i){let s;if(i===U4(n,e,t,r)>0)for(let o=e;o<t;o+=r)s=J_(o/r|0,n[o],n[o+1],s);else for(let o=t-r;o>=e;o-=r)s=J_(o/r|0,n[o],n[o+1],s);return s&&ca(s,s.next)&&(Cl(s),s=s.next),s}function eo(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(ca(t,t.next)||an(t.prev,t,t.next)===0)){if(Cl(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function wl(n,e,t,r,i,s,o){if(!n)return;!o&&s&&I4(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?b4(n,r,i,s):E4(n)){e.push(l.i,n.i,c.i),Cl(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=M4(eo(n),e),wl(n,e,t,r,i,s,2)):o===2&&w4(n,e,t,r,i,s):wl(eo(n),e,t,r,i,s,1);break}}}function E4(n){const e=n.prev,t=n,r=n.next;if(an(e,t,r)>=0)return!1;const i=e.x,s=t.x,o=r.x,a=e.y,l=t.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),p=Math.max(i,s,o),d=Math.max(a,l,c);let m=r.next;for(;m!==e;){if(m.x>=h&&m.x<=p&&m.y>=f&&m.y<=d&&Tl(i,a,s,l,o,c,m.x,m.y)&&an(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function b4(n,e,t,r){const i=n.prev,s=n,o=n.next;if(an(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,p=o.y,d=Math.min(a,l,c),m=Math.min(h,f,p),x=Math.max(a,l,c),v=Math.max(h,f,p),_=qp(d,m,e,t,r),w=qp(x,v,e,t,r);let E=n.prevZ,S=n.nextZ;for(;E&&E.z>=_&&S&&S.z<=w;){if(E.x>=d&&E.x<=x&&E.y>=m&&E.y<=v&&E!==i&&E!==o&&Tl(a,h,l,f,c,p,E.x,E.y)&&an(E.prev,E,E.next)>=0||(E=E.prevZ,S.x>=d&&S.x<=x&&S.y>=m&&S.y<=v&&S!==i&&S!==o&&Tl(a,h,l,f,c,p,S.x,S.y)&&an(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;E&&E.z>=_;){if(E.x>=d&&E.x<=x&&E.y>=m&&E.y<=v&&E!==i&&E!==o&&Tl(a,h,l,f,c,p,E.x,E.y)&&an(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;S&&S.z<=w;){if(S.x>=d&&S.x<=x&&S.y>=m&&S.y<=v&&S!==i&&S!==o&&Tl(a,h,l,f,c,p,S.x,S.y)&&an(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function M4(n,e){let t=n;do{const r=t.prev,i=t.next.next;!ca(r,i)&&K_(r,t,t.next,i)&&Al(r,i)&&Al(i,r)&&(e.push(r.i,t.i,i.i),Cl(t),Cl(t.next),t=n=i),t=t.next}while(t!==n);return eo(t)}function w4(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&q4(o,a)){let l=Z_(o,a);o=eo(o,o.next),l=eo(l,l.next),wl(o,e,t,r,i,s,0),wl(l,e,t,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function T4(n,e,t,r){const i=[];for(let s=0,o=e.length;s<o;s++){const a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,c=$_(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(O4(c))}i.sort(A4);for(let s=0;s<i.length;s++)t=C4(i[s],t);return t}function A4(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function C4(n,e){const t=R4(n,e);if(!t)return e;const r=Z_(t,n);return eo(r,r.next),eo(t,t.next)}function R4(n,e){let t=e;const r=n.x,i=n.y;let s=-1/0,o;if(ca(n,t))return t;do{if(ca(n,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>s&&(s=f,o=t.x<t.next.x?t:t.next,f===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&Y_(i<c?r:s,i,l,c,i<c?s:r,i,t.x,t.y)){const f=Math.abs(i-t.y)/(r-t.x);Al(t,n)&&(f<h||f===h&&(t.x>o.x||t.x===o.x&&P4(o,t)))&&(o=t,h=f)}t=t.next}while(t!==a);return o}function P4(n,e){return an(n.prev,n,e.prev)<0&&an(e.next,n,n.next)<0}function I4(n,e,t,r){let i=n;do i.z===0&&(i.z=qp(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,L4(i)}function L4(n){let e,t=1;do{let r=n,i;n=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,t*=2}while(e>1);return n}function qp(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function O4(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Y_(n,e,t,r,i,s,o,a){return(i-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(r-a)}function Tl(n,e,t,r,i,s,o,a){return!(n===o&&e===a)&&Y_(n,e,t,r,i,s,o,a)}function q4(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!D4(n,e)&&(Al(n,e)&&Al(e,n)&&N4(n,e)&&(an(n.prev,n,e.prev)||an(n,e.prev,e))||ca(n,e)&&an(n.prev,n,n.next)>0&&an(e.prev,e,e.next)>0)}function an(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ca(n,e){return n.x===e.x&&n.y===e.y}function K_(n,e,t,r){const i=Ru(an(n,e,t)),s=Ru(an(n,e,r)),o=Ru(an(t,r,n)),a=Ru(an(t,r,e));return!!(i!==s&&o!==a||i===0&&Cu(n,t,e)||s===0&&Cu(n,r,e)||o===0&&Cu(t,n,r)||a===0&&Cu(t,e,r))}function Cu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ru(n){return n>0?1:n<0?-1:0}function D4(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&K_(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Al(n,e){return an(n.prev,n,n.next)<0?an(n,e,n.next)>=0&&an(n,n.prev,e)>=0:an(n,e,n.prev)<0||an(n,n.next,e)<0}function N4(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function Z_(n,e){const t=Dp(n.i,n.x,n.y),r=Dp(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function J_(n,e,t,r){const i=Dp(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Cl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Dp(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function U4(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class F4{static triangulate(e,t,r=2){return S4(e,t,r)}}class ua{static area(e){const t=e.length;let r=0;for(let i=t-1,s=0;s<t;i=s++)r+=e[i].x*e[s].y-e[s].x*e[i].y;return r*.5}static isClockWise(e){return ua.area(e)<0}static triangulateShape(e,t){const r=[],i=[],s=[];Q_(e),ev(r,e);let o=e.length;t.forEach(Q_);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,ev(r,t[l]);const a=F4.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function Q_(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function ev(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Pu extends nr{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(r),l=Math.floor(i),c=a+1,h=l+1,f=e/a,p=t/l,d=[],m=[],x=[],v=[];for(let _=0;_<h;_++){const w=_*p-o;for(let E=0;E<c;E++){const S=E*f-s;m.push(S,-w,0),x.push(0,0,1),v.push(E/a),v.push(1-_/l)}}for(let _=0;_<l;_++)for(let w=0;w<a;w++){const E=w+c*_,S=w+c*(_+1),b=w+1+c*(_+1),A=w+1+c*_;d.push(E,S,A),d.push(S,b,A)}this.setIndex(d),this.setAttribute("position",new Gn(m,3)),this.setAttribute("normal",new Gn(x,3)),this.setAttribute("uv",new Gn(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pu(e.width,e.height,e.widthSegments,e.heightSegments)}}class Np extends nr{constructor(e=new la([new Ne(0,.5),new Ne(-.5,-.5),new Ne(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new Gn(i,3)),this.setAttribute("normal",new Gn(s,3)),this.setAttribute("uv",new Gn(o,2));function c(h){const f=i.length/3,p=h.extractPoints(t);let d=p.shape;const m=p.holes;ua.isClockWise(d)===!1&&(d=d.reverse());for(let v=0,_=m.length;v<_;v++){const w=m[v];ua.isClockWise(w)===!0&&(m[v]=w.reverse())}const x=ua.triangulateShape(d,m);for(let v=0,_=m.length;v<_;v++){const w=m[v];d=d.concat(w)}for(let v=0,_=d.length;v<_;v++){const w=d[v];i.push(w.x,w.y,0),s.push(0,0,1),o.push(w.x,w.y)}for(let v=0,_=x.length;v<_;v++){const w=x[v],E=w[0]+f,S=w[1]+f,b=w[2]+f;r.push(E,S,b),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return z4(t,e)}static fromJSON(e,t){const r=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];r.push(o)}return new Np(r,e.curveSegments)}}function z4(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const i=n[t];e.shapes.push(i.uuid)}else e.shapes.push(n.uuid);return e}class k4 extends Ys{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Et(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ep,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,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.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,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 B4 extends Ys{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Et(16777215),this.specular=new Et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ep,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=_d,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 V4 extends Ys{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xM,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 H4 extends Ys{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}}const Rl={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class G4{constructor(e,t,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,p=c.length;f<p;f+=2){const d=c[f],m=c[f+1];if(d.global&&(d.lastIndex=0),d.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const W4=new G4;class Pl{constructor(e){this.manager=e!==void 0?e:W4,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise(function(i,s){r.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Pl.DEFAULT_MATERIAL_NAME="__DEFAULT";const ji={};class j4 extends Error{constructor(e,t){super(e),this.response=t}}class X4 extends Pl{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rl.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ji[e]!==void 0){ji[e].push({onLoad:t,onProgress:r,onError:i});return}ji[e]=[],ji[e].push({onLoad:t,onProgress:r,onError:i});const o=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}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=ji[e],f=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=p?parseInt(p):0,m=d!==0;let x=0;const v=new ReadableStream({start(_){w();function w(){f.read().then(({done:E,value:S})=>{if(E)_.close();else{x+=S.byteLength;const b=new ProgressEvent("progress",{lengthComputable:m,loaded:x,total:d});for(let A=0,q=h.length;A<q;A++){const O=h[A];O.onProgress&&O.onProgress(b)}_.enqueue(S),w()}},E=>{_.error(E)})}}});return new Response(v)}else throw new j4(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),p=f&&f[1]?f[1].toLowerCase():void 0,d=new TextDecoder(p);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{Rl.add(`file:${e}`,c);const h=ji[e];delete ji[e];for(let f=0,p=h.length;f<p;f++){const d=h[f];d.onLoad&&d.onLoad(c)}}).catch(c=>{const h=ji[e];if(h===void 0)throw this.manager.itemError(e),c;delete ji[e];for(let f=0,p=h.length;f<p;f++){const d=h[f];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{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}}const ha=new WeakMap;class $4 extends Pl{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Rl.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);else{let f=ha.get(o);f===void 0&&(f=[],ha.set(o,f)),f.push({onLoad:t,onError:i})}return o}const a=gl("img");function l(){h(),t&&t(this);const f=ha.get(this)||[];for(let p=0;p<f.length;p++){const d=f[p];d.onLoad&&d.onLoad(this)}ha.delete(this),s.manager.itemEnd(e)}function c(f){h(),i&&i(f),Rl.remove(`image:${e}`);const p=ha.get(this)||[];for(let d=0;d<p.length;d++){const m=p[d];m.onError&&m.onError(f)}ha.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Rl.add(`image:${e}`,a),s.manager.itemStart(e),a.src=e,a}}class tv extends Pl{constructor(e){super(e)}load(e,t,r,i){const s=new Dn,o=new $4(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class Up extends Dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Et(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Fp=new Gt,nv=new j,rv=new j;class iv{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=bi,this.map=null,this.mapPass=null,this.matrix=new Gt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Tp,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ln(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;nv.setFromMatrixPosition(e.matrixWorld),t.position.copy(nv),rv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rv),t.updateMatrixWorld(),Fp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fp,t.coordinateSystem,t.reversedDepth),t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Fp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Y4 extends iv{constructor(){super(new vr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=eu*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class K4 extends Up{constructor(e,t,r=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Y4}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class sv extends L_{constructor(e=-1,t=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,o){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=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Z4 extends iv{constructor(){super(new sv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class J4 extends Up{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new Z4}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class ov extends Up{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Q4 extends vr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const av=new Gt;class ew{constructor(e,t,r=0,i=1/0){this.ray=new au(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new fp,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return av.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(av),this}intersectObject(e,t=!0,r=[]){return zp(e,this,r,t),r.sort(lv),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)zp(e[i],this,r,t);return r.sort(lv),r}}function lv(n,e){return n.distance-e.distance}function zp(n,e,t,r){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&r===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)zp(s[o],e,t,!0)}}class cv{constructor(e=1,t=0,r=0){this.radius=e,this.phi=t,this.theta=r}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=vt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(vt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Iu=new wi;class tw extends El{constructor(e,t=16776960){const r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new nr;s.setIndex(new qr(r,1)),s.setAttribute("position",new qr(i,3)),super(s,new Eu({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Iu.setFromObject(this.object),Iu.isEmpty())return;const e=Iu.min,t=Iu.max,r=this.geometry.attributes.position,i=r.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class nw{constructor(){this.type="ShapePath",this.color=new Et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Op,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(_){const w=[];for(let E=0,S=_.length;E<S;E++){const b=_[E],A=new la;A.curves=b.curves,w.push(A)}return w}function r(_,w){const E=w.length;let S=!1;for(let b=E-1,A=0;A<E;b=A++){let q=w[b],O=w[A],T=O.x-q.x,I=O.y-q.y;if(Math.abs(I)>Number.EPSILON){if(I<0&&(q=w[A],T=-T,O=w[b],I=-I),_.y<q.y||_.y>O.y)continue;if(_.y===q.y){if(_.x===q.x)return!0}else{const N=I*(_.x-q.x)-T*(_.y-q.y);if(N===0)return!0;if(N<0)continue;S=!S}}else{if(_.y!==q.y)continue;if(O.x<=_.x&&_.x<=q.x||q.x<=_.x&&_.x<=O.x)return!0}}return S}const i=ua.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new la,l.curves=a.curves,c.push(l),c;let h=!i(s[0].getPoints());h=e?!h:h;const f=[],p=[];let d=[],m=0,x;p[m]=void 0,d[m]=[];for(let _=0,w=s.length;_<w;_++)a=s[_],x=a.getPoints(),o=i(x),o=e?!o:o,o?(!h&&p[m]&&m++,p[m]={s:new la,p:x},p[m].s.curves=a.curves,h&&m++,d[m]=[]):d[m].push({h:a,p:x[0]});if(!p[0])return t(s);if(p.length>1){let _=!1,w=0;for(let E=0,S=p.length;E<S;E++)f[E]=[];for(let E=0,S=p.length;E<S;E++){const b=d[E];for(let A=0;A<b.length;A++){const q=b[A];let O=!0;for(let T=0;T<p.length;T++)r(q.p,p[T].p)&&(E!==T&&w++,O?(O=!1,f[T].push(q)):_=!0);O&&f[E].push(q)}}w>0&&_===!1&&(d=f)}let v;for(let _=0,w=p.length;_<w;_++){l=p[_].s,c.push(l),v=d[_];for(let E=0,S=v.length;E<S;E++)l.holes.push(v[E].h)}return c}}class rw extends Ws{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function uv(n,e,t,r){const i=iw(r);switch(t){case n_:return n*e;case i_:return n*e/i.components*i.byteLength;case wd:return n*e/i.components*i.byteLength;case s_:return n*e*2/i.components*i.byteLength;case Td:return n*e*2/i.components*i.byteLength;case r_:return n*e*3/i.components*i.byteLength;case Qr:return n*e*4/i.components*i.byteLength;case Ad:return n*e*4/i.components*i.byteLength;case jc:case Xc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case $c:case Yc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Rd:case Id:return Math.max(n,16)*Math.max(e,8)/4;case Cd:case Pd:return Math.max(n,8)*Math.max(e,8)/2;case Ld:case Od:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case qd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Dd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Nd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ud:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Fd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case zd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case kd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Bd:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Vd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Hd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Gd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Wd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case jd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Xd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case $d:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Kc:case Yd:case Kd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case o_:case Zd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Jd:case Qd:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function iw(n){switch(n){case bi:case Q1:return{byteLength:1,components:1};case ul:case e_:case hl:return{byteLength:2,components:1};case bd:case Md:return{byteLength:2,components:4};case Gs:case Ed:case zi:return{byteLength:4,components:1};case t_:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ad}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ad);/**
113
+ `},i=new Js(5,5,5),s=new xs({name:"CubemapFromEquirect",uniforms:ia(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:er,blending:us});s.uniforms.tEquirect.value=t;const o=new Tn(i,s),a=t.minFilter;return t.minFilter===Hs&&(t.minFilter=Ei),new e4(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,i);e.setRenderTarget(s)}}class aa extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const n4={type:"move"};class Mp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new aa,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 aa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new aa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j),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 r of e.hand.values())this._getHandJoint(t,r)}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,r){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const x of e.hand.values()){const v=t.getJointPose(x,r),_=this._getHandJoint(c,x);v!==null&&(_.matrix.fromArray(v.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=v.radius),_.visible=v!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=h.position.distanceTo(f.position),d=.02,m=.005;c.inputState.pinching&&p>d+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=d-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(n4)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new aa;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class r4 extends Dt{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 ni,this.environmentIntensity=1,this.environmentRotation=new ni,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__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}}const xu=new j,N_=new j;class yu extends Dt{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 r=0,i=t.length;r<i;r++){const s=t[r];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,r=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:r,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let r=0;r<t.length;r++)if(t[r].distance===e){const i=t.splice(r,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let r,i;for(r=1,i=t.length;r<i;r++){let s=t[r].distance;if(t[r].object.visible&&(s-=s*t[r].hysteresis),e<s)break}return t[r-1].object}return null}raycast(e,t){if(this.levels.length>0){xu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(xu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){xu.setFromMatrixPosition(e.matrixWorld),N_.setFromMatrixPosition(this.matrixWorld);const r=xu.distanceTo(N_)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),r>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const r=this.levels;for(let i=0,s=r.length;i<s;i++){const o=r[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const wp=new j,i4=new j,s4=new mt;class Ss{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const i=wp.subVectors(r,t).cross(i4.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const r=e.delta(wp),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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 r=t||s4.getNormalMatrix(e),i=this.coplanarPoint(wp).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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 Qs=new iu,o4=new Ne(.5,.5),Su=new j;class Tp{constructor(e=new Ss,t=new Ss,r=new Ss,i=new Ss,s=new Ss,o=new Ss){this.planes=[e,t,r,i,s,o]}set(e,t,r,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=Mi,r=!1){const i=this.planes,s=e.elements,o=s[0],a=s[1],l=s[2],c=s[3],h=s[4],f=s[5],p=s[6],d=s[7],m=s[8],x=s[9],v=s[10],_=s[11],w=s[12],E=s[13],S=s[14],b=s[15];if(i[0].setComponents(c-o,d-h,_-m,b-w).normalize(),i[1].setComponents(c+o,d+h,_+m,b+w).normalize(),i[2].setComponents(c+a,d+f,_+x,b+E).normalize(),i[3].setComponents(c-a,d-f,_-x,b-E).normalize(),r)i[4].setComponents(l,p,v,S).normalize(),i[5].setComponents(c-l,d-p,_-v,b-S).normalize();else if(i[4].setComponents(c-l,d-p,_-v,b-S).normalize(),t===Mi)i[5].setComponents(c+l,d+p,_+v,b+S).normalize();else if(t===Jc)i[5].setComponents(l,p,v,S).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(),Qs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qs)}intersectsSprite(e){Qs.center.set(0,0,0);const t=o4.distanceTo(e.center);return Qs.radius=.7071067811865476+t,Qs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qs)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let r=0;r<6;r++){const i=t[r];if(Su.x=i.normal.x>0?e.max.x:e.min.x,Su.y=i.normal.y>0?e.max.y:e.min.y,Su.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Su)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Eu extends Ys{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Et(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const bu=new j,Mu=new j,U_=new Gt,Sl=new au,wu=new iu,Ap=new j,F_=new j;class a4 extends Dt{constructor(e=new nr,t=new Eu){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[0];for(let i=1,s=t.count;i<s;i++)bu.fromBufferAttribute(t,i-1),Mu.fromBufferAttribute(t,i),r[i]=r[i-1],r[i]+=bu.distanceTo(Mu);e.setAttribute("lineDistance",new Gn(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),wu.copy(r.boundingSphere),wu.applyMatrix4(i),wu.radius+=s,e.ray.intersectsSphere(wu)===!1)return;U_.copy(i).invert(),Sl.copy(e.ray).applyMatrix4(U_);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=r.index,p=r.attributes.position;if(h!==null){const d=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let x=d,v=m-1;x<v;x+=c){const _=h.getX(x),w=h.getX(x+1),E=Tu(this,e,Sl,l,_,w,x);E&&t.push(E)}if(this.isLineLoop){const x=h.getX(m-1),v=h.getX(d),_=Tu(this,e,Sl,l,x,v,m-1);_&&t.push(_)}}else{const d=Math.max(0,o.start),m=Math.min(p.count,o.start+o.count);for(let x=d,v=m-1;x<v;x+=c){const _=Tu(this,e,Sl,l,x,x+1,x);_&&t.push(_)}if(this.isLineLoop){const x=Tu(this,e,Sl,l,m-1,d,m-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function Tu(n,e,t,r,i,s,o){const a=n.geometry.attributes.position;if(bu.fromBufferAttribute(a,i),Mu.fromBufferAttribute(a,s),t.distanceSqToSegment(bu,Mu,Ap,F_)>r)return;Ap.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Ap);if(!(c<e.near||c>e.far))return{distance:c,point:F_.clone().applyMatrix4(n.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:n}}const z_=new j,k_=new j;class El extends a4{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,r=[];for(let i=0,s=t.count;i<s;i+=2)z_.fromBufferAttribute(t,i),k_.fromBufferAttribute(t,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+z_.distanceTo(k_);e.setAttribute("lineDistance",new Gn(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class B_ extends Dn{constructor(e,t,r=Gs,i,s,o,a=Jr,l=Jr,c,h=dl,f=1){if(h!==dl&&h!==pl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:f};super(p,i,s,o,a,l,h,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ip(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 Ti{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],p=r[i+1]-h,d=(o-h)/p;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new Ne:new j);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t=!1){const r=new j,i=[],s=[],o=[],a=new j,l=new Gt;for(let d=0;d<=e;d++){const m=d/e;i[d]=this.getTangentAt(m,new j)}s[0]=new j,o[0]=new j;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),p=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),p<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(vt(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(vt(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}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 Cp extends Ti{constructor(e=0,t=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Ne){const r=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),p=l-this.aX,d=c-this.aY;l=p*h-d*f+this.aX,c=p*f+d*h+this.aY}return r.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class l4 extends Cp{constructor(e,t,r,i,s,o){super(e,t,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Rp(){let n=0,e=0,t=0,r=0;function i(s,o,a,l){n=s,e=a,t=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let p=(o-s)/c-(a-s)/(c+h)+(a-o)/h,d=(a-o)/h-(l-o)/(h+f)+(l-a)/f;p*=h,d*=h,i(o,a,p,d)},calc:function(s){const o=s*s,a=o*s;return n+e*s+t*o+r*a}}}const Au=new j,Pp=new Rp,Ip=new Rp,Lp=new Rp;class c4 extends Ti{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(e,t=new j){const r=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(Au.subVectors(i[0],i[1]).add(i[0]),c=Au);const f=i[a%s],p=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(Au.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=Au),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),d),x=Math.pow(f.distanceToSquared(p),d),v=Math.pow(p.distanceToSquared(h),d);x<1e-4&&(x=1),m<1e-4&&(m=x),v<1e-4&&(v=x),Pp.initNonuniformCatmullRom(c.x,f.x,p.x,h.x,m,x,v),Ip.initNonuniformCatmullRom(c.y,f.y,p.y,h.y,m,x,v),Lp.initNonuniformCatmullRom(c.z,f.z,p.z,h.z,m,x,v)}else this.curveType==="catmullrom"&&(Pp.initCatmullRom(c.x,f.x,p.x,h.x,this.tension),Ip.initCatmullRom(c.y,f.y,p.y,h.y,this.tension),Lp.initCatmullRom(c.z,f.z,p.z,h.z,this.tension));return r.set(Pp.calc(l),Ip.calc(l),Lp.calc(l)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(new j().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function V_(n,e,t,r,i){const s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function u4(n,e){const t=1-n;return t*t*e}function h4(n,e){return 2*(1-n)*n*e}function f4(n,e){return n*n*e}function bl(n,e,t,r){return u4(n,e)+h4(n,t)+f4(n,r)}function d4(n,e){const t=1-n;return t*t*t*e}function p4(n,e){const t=1-n;return 3*t*t*n*e}function m4(n,e){return 3*(1-n)*n*n*e}function g4(n,e){return n*n*n*e}function Ml(n,e,t,r,i){return d4(n,e)+p4(n,t)+m4(n,r)+g4(n,i)}class H_ extends Ti{constructor(e=new Ne,t=new Ne,r=new Ne,i=new Ne){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new Ne){const r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Ml(e,i.x,s.x,o.x,a.x),Ml(e,i.y,s.y,o.y,a.y)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class _4 extends Ti{constructor(e=new j,t=new j,r=new j,i=new j){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new j){const r=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Ml(e,i.x,s.x,o.x,a.x),Ml(e,i.y,s.y,o.y,a.y),Ml(e,i.z,s.z,o.z,a.z)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class G_ extends Ti{constructor(e=new Ne,t=new Ne){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ne){const r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ne){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class v4 extends Ti{constructor(e=new j,t=new j){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new j){const r=t;return e===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new j){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class W_ extends Ti{constructor(e=new Ne,t=new Ne,r=new Ne){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new Ne){const r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(bl(e,i.x,s.x,o.x),bl(e,i.y,s.y,o.y)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class x4 extends Ti{constructor(e=new j,t=new j,r=new j){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new j){const r=t,i=this.v0,s=this.v1,o=this.v2;return r.set(bl(e,i.x,s.x,o.x),bl(e,i.y,s.y,o.y),bl(e,i.z,s.z,o.z)),r}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class j_ extends Ti{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ne){const r=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(V_(a,l.x,c.x,h.x,f.x),V_(a,l.y,c.y,h.y,f.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,r=this.points.length;t<r;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++){const i=e.points[t];this.points.push(new Ne().fromArray(i))}return this}}var X_=Object.freeze({__proto__:null,ArcCurve:l4,CatmullRomCurve3:c4,CubicBezierCurve:H_,CubicBezierCurve3:_4,EllipseCurve:Cp,LineCurve:G_,LineCurve3:v4,QuadraticBezierCurve:W_,QuadraticBezierCurve3:x4,SplineCurve:j_});class y4 extends Ti{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const r=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new X_[r](t,e))}return this}getPoint(e,t){const r=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}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 r=0,i=this.curves.length;r<i;r++)t+=this.curves[r].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(t.push(h),r=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,r=this.curves.length;t<r;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,r=e.curves.length;t<r;t++){const i=e.curves[t];this.curves.push(new X_[i.type]().fromJSON(i))}return this}}class Op extends y4{constructor(e){super(),this.type="Path",this.currentPoint=new Ne,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const r=new G_(this.currentPoint.clone(),new Ne(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){const s=new W_(this.currentPoint.clone(),new Ne(e,t),new Ne(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,s,o){const a=new H_(this.currentPoint.clone(),new Ne(e,t),new Ne(r,i),new Ne(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),r=new j_(t);return this.curves.push(r),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,r,i,s,o),this}absarc(e,t,r,i,s,o){return this.absellipse(e,t,r,r,i,s,o),this}ellipse(e,t,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,r,i,s,o,a,l),this}absellipse(e,t,r,i,s,o,a,l){const c=new Cp(e,t,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),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 la extends Op{constructor(e){super(e),this.uuid=Wo(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let r=0,i=this.holes.length;r<i;r++)t[r]=this.holes[r].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,r=this.holes.length;t<r;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,r=e.holes.length;t<r;t++){const i=e.holes[t];this.holes.push(new Op().fromJSON(i))}return this}}function S4(n,e,t=2){const r=e&&e.length,i=r?e[0]*t:n.length;let s=$_(n,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=T4(n,e,s,t)),n.length>80*t){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let p=t;p<i;p+=t){const d=n[p],m=n[p+1];d<a&&(a=d),m<l&&(l=m),d>h&&(h=d),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return wl(s,o,t,a,l,c,0),o}function $_(n,e,t,r,i){let s;if(i===U4(n,e,t,r)>0)for(let o=e;o<t;o+=r)s=J_(o/r|0,n[o],n[o+1],s);else for(let o=t-r;o>=e;o-=r)s=J_(o/r|0,n[o],n[o+1],s);return s&&ca(s,s.next)&&(Cl(s),s=s.next),s}function eo(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(ca(t,t.next)||an(t.prev,t,t.next)===0)){if(Cl(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function wl(n,e,t,r,i,s,o){if(!n)return;!o&&s&&I4(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?b4(n,r,i,s):E4(n)){e.push(l.i,n.i,c.i),Cl(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=M4(eo(n),e),wl(n,e,t,r,i,s,2)):o===2&&w4(n,e,t,r,i,s):wl(eo(n),e,t,r,i,s,1);break}}}function E4(n){const e=n.prev,t=n,r=n.next;if(an(e,t,r)>=0)return!1;const i=e.x,s=t.x,o=r.x,a=e.y,l=t.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),p=Math.max(i,s,o),d=Math.max(a,l,c);let m=r.next;for(;m!==e;){if(m.x>=h&&m.x<=p&&m.y>=f&&m.y<=d&&Tl(i,a,s,l,o,c,m.x,m.y)&&an(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function b4(n,e,t,r){const i=n.prev,s=n,o=n.next;if(an(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,p=o.y,d=Math.min(a,l,c),m=Math.min(h,f,p),x=Math.max(a,l,c),v=Math.max(h,f,p),_=qp(d,m,e,t,r),w=qp(x,v,e,t,r);let E=n.prevZ,S=n.nextZ;for(;E&&E.z>=_&&S&&S.z<=w;){if(E.x>=d&&E.x<=x&&E.y>=m&&E.y<=v&&E!==i&&E!==o&&Tl(a,h,l,f,c,p,E.x,E.y)&&an(E.prev,E,E.next)>=0||(E=E.prevZ,S.x>=d&&S.x<=x&&S.y>=m&&S.y<=v&&S!==i&&S!==o&&Tl(a,h,l,f,c,p,S.x,S.y)&&an(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;E&&E.z>=_;){if(E.x>=d&&E.x<=x&&E.y>=m&&E.y<=v&&E!==i&&E!==o&&Tl(a,h,l,f,c,p,E.x,E.y)&&an(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;S&&S.z<=w;){if(S.x>=d&&S.x<=x&&S.y>=m&&S.y<=v&&S!==i&&S!==o&&Tl(a,h,l,f,c,p,S.x,S.y)&&an(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function M4(n,e){let t=n;do{const r=t.prev,i=t.next.next;!ca(r,i)&&K_(r,t,t.next,i)&&Al(r,i)&&Al(i,r)&&(e.push(r.i,t.i,i.i),Cl(t),Cl(t.next),t=n=i),t=t.next}while(t!==n);return eo(t)}function w4(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&q4(o,a)){let l=Z_(o,a);o=eo(o,o.next),l=eo(l,l.next),wl(o,e,t,r,i,s,0),wl(l,e,t,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function T4(n,e,t,r){const i=[];for(let s=0,o=e.length;s<o;s++){const a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,c=$_(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(O4(c))}i.sort(A4);for(let s=0;s<i.length;s++)t=C4(i[s],t);return t}function A4(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function C4(n,e){const t=R4(n,e);if(!t)return e;const r=Z_(t,n);return eo(r,r.next),eo(t,t.next)}function R4(n,e){let t=e;const r=n.x,i=n.y;let s=-1/0,o;if(ca(n,t))return t;do{if(ca(n,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>s&&(s=f,o=t.x<t.next.x?t:t.next,f===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&Y_(i<c?r:s,i,l,c,i<c?s:r,i,t.x,t.y)){const f=Math.abs(i-t.y)/(r-t.x);Al(t,n)&&(f<h||f===h&&(t.x>o.x||t.x===o.x&&P4(o,t)))&&(o=t,h=f)}t=t.next}while(t!==a);return o}function P4(n,e){return an(n.prev,n,e.prev)<0&&an(e.next,n,n.next)<0}function I4(n,e,t,r){let i=n;do i.z===0&&(i.z=qp(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,L4(i)}function L4(n){let e,t=1;do{let r=n,i;n=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,t*=2}while(e>1);return n}function qp(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function O4(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Y_(n,e,t,r,i,s,o,a){return(i-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(r-a)}function Tl(n,e,t,r,i,s,o,a){return!(n===o&&e===a)&&Y_(n,e,t,r,i,s,o,a)}function q4(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!D4(n,e)&&(Al(n,e)&&Al(e,n)&&N4(n,e)&&(an(n.prev,n,e.prev)||an(n,e.prev,e))||ca(n,e)&&an(n.prev,n,n.next)>0&&an(e.prev,e,e.next)>0)}function an(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ca(n,e){return n.x===e.x&&n.y===e.y}function K_(n,e,t,r){const i=Ru(an(n,e,t)),s=Ru(an(n,e,r)),o=Ru(an(t,r,n)),a=Ru(an(t,r,e));return!!(i!==s&&o!==a||i===0&&Cu(n,t,e)||s===0&&Cu(n,r,e)||o===0&&Cu(t,n,r)||a===0&&Cu(t,e,r))}function Cu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ru(n){return n>0?1:n<0?-1:0}function D4(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&K_(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Al(n,e){return an(n.prev,n,n.next)<0?an(n,e,n.next)>=0&&an(n,n.prev,e)>=0:an(n,e,n.prev)<0||an(n,n.next,e)<0}function N4(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function Z_(n,e){const t=Dp(n.i,n.x,n.y),r=Dp(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function J_(n,e,t,r){const i=Dp(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Cl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Dp(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function U4(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class F4{static triangulate(e,t,r=2){return S4(e,t,r)}}class ua{static area(e){const t=e.length;let r=0;for(let i=t-1,s=0;s<t;i=s++)r+=e[i].x*e[s].y-e[s].x*e[i].y;return r*.5}static isClockWise(e){return ua.area(e)<0}static triangulateShape(e,t){const r=[],i=[],s=[];Q_(e),ev(r,e);let o=e.length;t.forEach(Q_);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,ev(r,t[l]);const a=F4.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function Q_(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function ev(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Pu extends nr{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(r),l=Math.floor(i),c=a+1,h=l+1,f=e/a,p=t/l,d=[],m=[],x=[],v=[];for(let _=0;_<h;_++){const w=_*p-o;for(let E=0;E<c;E++){const S=E*f-s;m.push(S,-w,0),x.push(0,0,1),v.push(E/a),v.push(1-_/l)}}for(let _=0;_<l;_++)for(let w=0;w<a;w++){const E=w+c*_,S=w+c*(_+1),b=w+1+c*(_+1),A=w+1+c*_;d.push(E,S,A),d.push(S,b,A)}this.setIndex(d),this.setAttribute("position",new Gn(m,3)),this.setAttribute("normal",new Gn(x,3)),this.setAttribute("uv",new Gn(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pu(e.width,e.height,e.widthSegments,e.heightSegments)}}class Np extends nr{constructor(e=new la([new Ne(0,.5),new Ne(-.5,-.5),new Ne(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new Gn(i,3)),this.setAttribute("normal",new Gn(s,3)),this.setAttribute("uv",new Gn(o,2));function c(h){const f=i.length/3,p=h.extractPoints(t);let d=p.shape;const m=p.holes;ua.isClockWise(d)===!1&&(d=d.reverse());for(let v=0,_=m.length;v<_;v++){const w=m[v];ua.isClockWise(w)===!0&&(m[v]=w.reverse())}const x=ua.triangulateShape(d,m);for(let v=0,_=m.length;v<_;v++){const w=m[v];d=d.concat(w)}for(let v=0,_=d.length;v<_;v++){const w=d[v];i.push(w.x,w.y,0),s.push(0,0,1),o.push(w.x,w.y)}for(let v=0,_=x.length;v<_;v++){const w=x[v],E=w[0]+f,S=w[1]+f,b=w[2]+f;r.push(E,S,b),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return z4(t,e)}static fromJSON(e,t){const r=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];r.push(o)}return new Np(r,e.curveSegments)}}function z4(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const i=n[t];e.shapes.push(i.uuid)}else e.shapes.push(n.uuid);return e}class k4 extends Ys{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Et(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ep,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.envMapIntensity=1,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.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,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 B4 extends Ys{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Et(16777215),this.specular=new Et(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Et(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ep,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ni,this.combine=_d,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 V4 extends Ys{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xM,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 H4 extends Ys{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}}const Rl={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class G4{constructor(e,t,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,p=c.length;f<p;f+=2){const d=c[f],m=c[f+1];if(d.global&&(d.lastIndex=0),d.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const W4=new G4;class Pl{constructor(e){this.manager=e!==void 0?e:W4,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const r=this;return new Promise(function(i,s){r.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Pl.DEFAULT_MATERIAL_NAME="__DEFAULT";const ji={};class j4 extends Error{constructor(e,t){super(e),this.response=t}}class X4 extends Pl{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rl.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ji[e]!==void 0){ji[e].push({onLoad:t,onProgress:r,onError:i});return}ji[e]=[],ji[e].push({onLoad:t,onProgress:r,onError:i});const o=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}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=ji[e],f=c.body.getReader(),p=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=p?parseInt(p):0,m=d!==0;let x=0;const v=new ReadableStream({start(_){w();function w(){f.read().then(({done:E,value:S})=>{if(E)_.close();else{x+=S.byteLength;const b=new ProgressEvent("progress",{lengthComputable:m,loaded:x,total:d});for(let A=0,q=h.length;A<q;A++){const O=h[A];O.onProgress&&O.onProgress(b)}_.enqueue(S),w()}},E=>{_.error(E)})}}});return new Response(v)}else throw new j4(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),p=f&&f[1]?f[1].toLowerCase():void 0,d=new TextDecoder(p);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{Rl.add(`file:${e}`,c);const h=ji[e];delete ji[e];for(let f=0,p=h.length;f<p;f++){const d=h[f];d.onLoad&&d.onLoad(c)}}).catch(c=>{const h=ji[e];if(h===void 0)throw this.manager.itemError(e),c;delete ji[e];for(let f=0,p=h.length;f<p;f++){const d=h[f];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{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}}const ha=new WeakMap;class $4 extends Pl{constructor(e){super(e)}load(e,t,r,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Rl.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);else{let f=ha.get(o);f===void 0&&(f=[],ha.set(o,f)),f.push({onLoad:t,onError:i})}return o}const a=gl("img");function l(){h(),t&&t(this);const f=ha.get(this)||[];for(let p=0;p<f.length;p++){const d=f[p];d.onLoad&&d.onLoad(this)}ha.delete(this),s.manager.itemEnd(e)}function c(f){h(),i&&i(f),Rl.remove(`image:${e}`);const p=ha.get(this)||[];for(let d=0;d<p.length;d++){const m=p[d];m.onError&&m.onError(f)}ha.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Rl.add(`image:${e}`,a),s.manager.itemStart(e),a.src=e,a}}class tv extends Pl{constructor(e){super(e)}load(e,t,r,i){const s=new Dn,o=new $4(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},r,i),s}}class Up extends Dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Et(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const Fp=new Gt,nv=new j,rv=new j;class iv{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=bi,this.map=null,this.mapPass=null,this.matrix=new Gt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Tp,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ln(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,r=this.matrix;nv.setFromMatrixPosition(e.matrixWorld),t.position.copy(nv),rv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rv),t.updateMatrixWorld(),Fp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fp,t.coordinateSystem,t.reversedDepth),t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Fp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Y4 extends iv{constructor(){super(new vr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,r=eu*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class K4 extends Up{constructor(e,t,r=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Y4}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class sv extends L_{constructor(e=-1,t=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,o){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=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Z4 extends iv{constructor(){super(new sv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class J4 extends Up{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new Z4}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class ov extends Up{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Q4 extends vr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const av=new Gt;class ew{constructor(e,t,r=0,i=1/0){this.ray=new au(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new fp,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return av.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(av),this}intersectObject(e,t=!0,r=[]){return zp(e,this,r,t),r.sort(lv),r}intersectObjects(e,t=!0,r=[]){for(let i=0,s=e.length;i<s;i++)zp(e[i],this,r,t);return r.sort(lv),r}}function lv(n,e){return n.distance-e.distance}function zp(n,e,t,r){let i=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(i=!1),i===!0&&r===!0){const s=n.children;for(let o=0,a=s.length;o<a;o++)zp(s[o],e,t,!0)}}class cv{constructor(e=1,t=0,r=0){this.radius=e,this.phi=t,this.theta=r}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=vt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,r){return this.radius=Math.sqrt(e*e+t*t+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(vt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Iu=new wi;class tw extends El{constructor(e,t=16776960){const r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new nr;s.setIndex(new Dr(r,1)),s.setAttribute("position",new Dr(i,3)),super(s,new Eu({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Iu.setFromObject(this.object),Iu.isEmpty())return;const e=Iu.min,t=Iu.max,r=this.geometry.attributes.position,i=r.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class nw{constructor(){this.type="ShapePath",this.color=new Et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Op,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(_){const w=[];for(let E=0,S=_.length;E<S;E++){const b=_[E],A=new la;A.curves=b.curves,w.push(A)}return w}function r(_,w){const E=w.length;let S=!1;for(let b=E-1,A=0;A<E;b=A++){let q=w[b],O=w[A],T=O.x-q.x,I=O.y-q.y;if(Math.abs(I)>Number.EPSILON){if(I<0&&(q=w[A],T=-T,O=w[b],I=-I),_.y<q.y||_.y>O.y)continue;if(_.y===q.y){if(_.x===q.x)return!0}else{const N=I*(_.x-q.x)-T*(_.y-q.y);if(N===0)return!0;if(N<0)continue;S=!S}}else{if(_.y!==q.y)continue;if(O.x<=_.x&&_.x<=q.x||q.x<=_.x&&_.x<=O.x)return!0}}return S}const i=ua.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new la,l.curves=a.curves,c.push(l),c;let h=!i(s[0].getPoints());h=e?!h:h;const f=[],p=[];let d=[],m=0,x;p[m]=void 0,d[m]=[];for(let _=0,w=s.length;_<w;_++)a=s[_],x=a.getPoints(),o=i(x),o=e?!o:o,o?(!h&&p[m]&&m++,p[m]={s:new la,p:x},p[m].s.curves=a.curves,h&&m++,d[m]=[]):d[m].push({h:a,p:x[0]});if(!p[0])return t(s);if(p.length>1){let _=!1,w=0;for(let E=0,S=p.length;E<S;E++)f[E]=[];for(let E=0,S=p.length;E<S;E++){const b=d[E];for(let A=0;A<b.length;A++){const q=b[A];let O=!0;for(let T=0;T<p.length;T++)r(q.p,p[T].p)&&(E!==T&&w++,O?(O=!1,f[T].push(q)):_=!0);O&&f[E].push(q)}}w>0&&_===!1&&(d=f)}let v;for(let _=0,w=p.length;_<w;_++){l=p[_].s,c.push(l),v=d[_];for(let E=0,S=v.length;E<S;E++)l.holes.push(v[E].h)}return c}}class rw extends Ws{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function uv(n,e,t,r){const i=iw(r);switch(t){case n_:return n*e;case i_:return n*e/i.components*i.byteLength;case wd:return n*e/i.components*i.byteLength;case s_:return n*e*2/i.components*i.byteLength;case Td:return n*e*2/i.components*i.byteLength;case r_:return n*e*3/i.components*i.byteLength;case Qr:return n*e*4/i.components*i.byteLength;case Ad:return n*e*4/i.components*i.byteLength;case jc:case Xc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case $c:case Yc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Rd:case Id:return Math.max(n,16)*Math.max(e,8)/4;case Cd:case Pd:return Math.max(n,8)*Math.max(e,8)/2;case Ld:case Od:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case qd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Dd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Nd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ud:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Fd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case zd:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case kd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Bd:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Vd:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Hd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Gd:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Wd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case jd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Xd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case $d:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Kc:case Yd:case Kd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case o_:case Zd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Jd:case Qd:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function iw(n){switch(n){case bi:case Q1:return{byteLength:1,components:1};case ul:case e_:case hl:return{byteLength:2,components:1};case bd:case Md:return{byteLength:2,components:4};case Gs:case Ed:case zi:return{byteLength:4,components:1};case t_:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ad}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ad);/**
114
114
  * @license
115
115
  * Copyright 2010-2025 Three.js Authors
116
116
  * SPDX-License-Identifier: MIT
@@ -3653,7 +3653,7 @@ void main() {
3653
3653
  #include <tonemapping_fragment>
3654
3654
  #include <colorspace_fragment>
3655
3655
  #include <fog_fragment>
3656
- }`},Fe={common:{diffuse:{value:new Et(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new mt},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new mt}},envmap:{envMap:{value:null},envMapRotation:{value:new mt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new mt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new mt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new mt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new mt},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new mt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new mt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new mt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new mt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Et(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 Et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0},uvTransform:{value:new mt}},sprite:{diffuse:{value:new Et(16777215)},opacity:{value:1},center:{value:new Ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new mt},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0}}},Ai={basic:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:_t.meshbasic_vert,fragmentShader:_t.meshbasic_frag},lambert:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)}}]),vertexShader:_t.meshlambert_vert,fragmentShader:_t.meshlambert_frag},phong:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)},specular:{value:new Et(1118481)},shininess:{value:30}}]),vertexShader:_t.meshphong_vert,fragmentShader:_t.meshphong_frag},standard:{uniforms:Wn([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag},toon:{uniforms:Wn([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)}}]),vertexShader:_t.meshtoon_vert,fragmentShader:_t.meshtoon_frag},matcap:{uniforms:Wn([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:_t.meshmatcap_vert,fragmentShader:_t.meshmatcap_frag},points:{uniforms:Wn([Fe.points,Fe.fog]),vertexShader:_t.points_vert,fragmentShader:_t.points_frag},dashed:{uniforms:Wn([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:_t.linedashed_vert,fragmentShader:_t.linedashed_frag},depth:{uniforms:Wn([Fe.common,Fe.displacementmap]),vertexShader:_t.depth_vert,fragmentShader:_t.depth_frag},normal:{uniforms:Wn([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:_t.meshnormal_vert,fragmentShader:_t.meshnormal_frag},sprite:{uniforms:Wn([Fe.sprite,Fe.fog]),vertexShader:_t.sprite_vert,fragmentShader:_t.sprite_frag},background:{uniforms:{uvTransform:{value:new mt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:_t.background_vert,fragmentShader:_t.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new mt}},vertexShader:_t.backgroundCube_vert,fragmentShader:_t.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:_t.cube_vert,fragmentShader:_t.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:_t.equirect_vert,fragmentShader:_t.equirect_frag},distanceRGBA:{uniforms:Wn([Fe.common,Fe.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:_t.distanceRGBA_vert,fragmentShader:_t.distanceRGBA_frag},shadow:{uniforms:Wn([Fe.lights,Fe.fog,{color:{value:new Et(0)},opacity:{value:1}}]),vertexShader:_t.shadow_vert,fragmentShader:_t.shadow_frag}};Ai.physical={uniforms:Wn([Ai.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new mt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new mt},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new mt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new mt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new mt},sheen:{value:0},sheenColor:{value:new Et(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new mt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new mt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new mt},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new mt},attenuationDistance:{value:0},attenuationColor:{value:new Et(0)},specularColor:{value:new Et(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new mt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new mt},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new mt}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag};const Lu={r:0,b:0,g:0},to=new ni,s6=new Gt;function o6(n,e,t,r,i,s,o){const a=new Et(0);let l=s===!0?0:1,c,h,f=null,p=0,d=null;function m(E){let S=E.isScene===!0?E.background:null;return S&&S.isTexture&&(S=(E.backgroundBlurriness>0?t:e).get(S)),S}function x(E){let S=!1;const b=m(E);b===null?_(a,l):b&&b.isColor&&(_(b,1),S=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(n.autoClear||S)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function v(E,S){const b=m(S);b&&(b.isCubeTexture||b.mapping===Gc)?(h===void 0&&(h=new Tn(new Js(1,1,1),new xs({name:"BackgroundCubeMaterial",uniforms:ia(Ai.backgroundCube.uniforms),vertexShader:Ai.backgroundCube.vertexShader,fragmentShader:Ai.backgroundCube.fragmentShader,side:er,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(A,q,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),to.copy(S.backgroundRotation),to.x*=-1,to.y*=-1,to.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(to.y*=-1,to.z*=-1),h.material.uniforms.envMap.value=b,h.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(s6.makeRotationFromEuler(to)),h.material.toneMapped=Ct.getTransfer(b.colorSpace)!==Ft,(f!==b||p!==b.version||d!==n.toneMapping)&&(h.material.needsUpdate=!0,f=b,p=b.version,d=n.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new Tn(new Pu(2,2),new xs({name:"BackgroundMaterial",uniforms:ia(Ai.background.uniforms),vertexShader:Ai.background.vertexShader,fragmentShader:Ai.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=Ct.getTransfer(b.colorSpace)!==Ft,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(f!==b||p!==b.version||d!==n.toneMapping)&&(c.material.needsUpdate=!0,f=b,p=b.version,d=n.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function _(E,S){E.getRGB(Lu,I_(n)),r.buffers.color.setClear(Lu.r,Lu.g,Lu.b,S,o)}function w(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,S=1){a.set(E),l=S,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,_(a,l)},render:x,addToRenderList:v,dispose:w}}function a6(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,o=!1;function a(I,N,H,W,Q){let ae=!1;const J=f(W,H,N);s!==J&&(s=J,c(s.object)),ae=d(I,W,H,Q),ae&&m(I,W,H,Q),Q!==null&&e.update(Q,n.ELEMENT_ARRAY_BUFFER),(ae||o)&&(o=!1,S(I,N,H,W),Q!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Q).buffer))}function l(){return n.createVertexArray()}function c(I){return n.bindVertexArray(I)}function h(I){return n.deleteVertexArray(I)}function f(I,N,H){const W=H.wireframe===!0;let Q=r[I.id];Q===void 0&&(Q={},r[I.id]=Q);let ae=Q[N.id];ae===void 0&&(ae={},Q[N.id]=ae);let J=ae[W];return J===void 0&&(J=p(l()),ae[W]=J),J}function p(I){const N=[],H=[],W=[];for(let Q=0;Q<t;Q++)N[Q]=0,H[Q]=0,W[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:H,attributeDivisors:W,object:I,attributes:{},index:null}}function d(I,N,H,W){const Q=s.attributes,ae=N.attributes;let J=0;const se=H.getAttributes();for(const B in se)if(se[B].location>=0){const F=Q[B];let X=ae[B];if(X===void 0&&(B==="instanceMatrix"&&I.instanceMatrix&&(X=I.instanceMatrix),B==="instanceColor"&&I.instanceColor&&(X=I.instanceColor)),F===void 0||F.attribute!==X||X&&F.data!==X.data)return!0;J++}return s.attributesNum!==J||s.index!==W}function m(I,N,H,W){const Q={},ae=N.attributes;let J=0;const se=H.getAttributes();for(const B in se)if(se[B].location>=0){let F=ae[B];F===void 0&&(B==="instanceMatrix"&&I.instanceMatrix&&(F=I.instanceMatrix),B==="instanceColor"&&I.instanceColor&&(F=I.instanceColor));const X={};X.attribute=F,F&&F.data&&(X.data=F.data),Q[B]=X,J++}s.attributes=Q,s.attributesNum=J,s.index=W}function x(){const I=s.newAttributes;for(let N=0,H=I.length;N<H;N++)I[N]=0}function v(I){_(I,0)}function _(I,N){const H=s.newAttributes,W=s.enabledAttributes,Q=s.attributeDivisors;H[I]=1,W[I]===0&&(n.enableVertexAttribArray(I),W[I]=1),Q[I]!==N&&(n.vertexAttribDivisor(I,N),Q[I]=N)}function w(){const I=s.newAttributes,N=s.enabledAttributes;for(let H=0,W=N.length;H<W;H++)N[H]!==I[H]&&(n.disableVertexAttribArray(H),N[H]=0)}function E(I,N,H,W,Q,ae,J){J===!0?n.vertexAttribIPointer(I,N,H,Q,ae):n.vertexAttribPointer(I,N,H,W,Q,ae)}function S(I,N,H,W){x();const Q=W.attributes,ae=H.getAttributes(),J=N.defaultAttributeValues;for(const se in ae){const B=ae[se];if(B.location>=0){let ge=Q[se];if(ge===void 0&&(se==="instanceMatrix"&&I.instanceMatrix&&(ge=I.instanceMatrix),se==="instanceColor"&&I.instanceColor&&(ge=I.instanceColor)),ge!==void 0){const F=ge.normalized,X=ge.itemSize,de=e.get(ge);if(de===void 0)continue;const ye=de.buffer,Ee=de.type,V=de.bytesPerElement,re=Ee===n.INT||Ee===n.UNSIGNED_INT||ge.gpuType===Ed;if(ge.isInterleavedBufferAttribute){const Z=ge.data,he=Z.stride,xe=ge.offset;if(Z.isInstancedInterleavedBuffer){for(let ee=0;ee<B.locationSize;ee++)_(B.location+ee,Z.meshPerAttribute);I.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ee=0;ee<B.locationSize;ee++)v(B.location+ee);n.bindBuffer(n.ARRAY_BUFFER,ye);for(let ee=0;ee<B.locationSize;ee++)E(B.location+ee,X/B.locationSize,Ee,F,he*V,(xe+X/B.locationSize*ee)*V,re)}else{if(ge.isInstancedBufferAttribute){for(let Z=0;Z<B.locationSize;Z++)_(B.location+Z,ge.meshPerAttribute);I.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Z=0;Z<B.locationSize;Z++)v(B.location+Z);n.bindBuffer(n.ARRAY_BUFFER,ye);for(let Z=0;Z<B.locationSize;Z++)E(B.location+Z,X/B.locationSize,Ee,F,X*V,X/B.locationSize*Z*V,re)}}else if(J!==void 0){const F=J[se];if(F!==void 0)switch(F.length){case 2:n.vertexAttrib2fv(B.location,F);break;case 3:n.vertexAttrib3fv(B.location,F);break;case 4:n.vertexAttrib4fv(B.location,F);break;default:n.vertexAttrib1fv(B.location,F)}}}}w()}function b(){O();for(const I in r){const N=r[I];for(const H in N){const W=N[H];for(const Q in W)h(W[Q].object),delete W[Q];delete N[H]}delete r[I]}}function A(I){if(r[I.id]===void 0)return;const N=r[I.id];for(const H in N){const W=N[H];for(const Q in W)h(W[Q].object),delete W[Q];delete N[H]}delete r[I.id]}function q(I){for(const N in r){const H=r[N];if(H[I.id]===void 0)continue;const W=H[I.id];for(const Q in W)h(W[Q].object),delete W[Q];delete H[I.id]}}function O(){T(),o=!0,s!==i&&(s=i,c(s.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:O,resetDefaultState:T,dispose:b,releaseStatesOfGeometry:A,releaseStatesOfProgram:q,initAttributes:x,enableAttribute:v,disableUnusedAttributes:w}}function l6(n,e,t){let r;function i(c){r=c}function s(c,h){n.drawArrays(r,c,h),t.update(h,r,1)}function o(c,h,f){f!==0&&(n.drawArraysInstanced(r,c,h,f),t.update(h,r,f))}function a(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,h,0,f);let d=0;for(let m=0;m<f;m++)d+=h[m];t.update(d,r,1)}function l(c,h,f,p){if(f===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let m=0;m<c.length;m++)o(c[m],h[m],p[m]);else{d.multiDrawArraysInstancedWEBGL(r,c,0,h,0,p,0,f);let m=0;for(let x=0;x<f;x++)m+=h[x]*p[x];t.update(m,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function c6(n,e,t,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const q=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(q.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(q){return!(q!==Qr&&r.convert(q)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(q){const O=q===hl&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(q!==bi&&r.convert(q)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&q!==zi&&!O)}function l(q){if(q==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";q="mediump"}return q==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),v=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),S=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=m>0,A=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:d,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:v,maxAttributes:_,maxVertexUniforms:w,maxVaryings:E,maxFragmentUniforms:S,vertexTextures:b,maxSamples:A}}function u6(n){const e=this;let t=null,r=0,i=!1,s=!1;const o=new Ss,a=new mt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const d=f.length!==0||p||r!==0||i;return i=p,r=f.length,d},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,p){t=h(f,p,0)},this.setState=function(f,p,d){const m=f.clippingPlanes,x=f.clipIntersection,v=f.clipShadows,_=n.get(f);if(!i||m===null||m.length===0||s&&!v)s?h(null):c();else{const w=s?0:r,E=w*4;let S=_.clippingState||null;l.value=S,S=h(m,p,E,d);for(let b=0;b!==E;++b)S[b]=t[b];_.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function h(f,p,d,m){const x=f!==null?f.length:0;let v=null;if(x!==0){if(v=l.value,m!==!0||v===null){const _=d+x*4,w=p.matrixWorldInverse;a.getNormalMatrix(w),(v===null||v.length<_)&&(v=new Float32Array(_));for(let E=0,S=d;E!==x;++E,S+=4)o.copy(f[E]).applyMatrix4(w,a),o.normal.toArray(v,S),v[S+3]=o.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,v}}function h6(n){let e=new WeakMap;function t(o,a){return a===vd?o.mapping=Bo:a===xd&&(o.mapping=Vo),o}function r(o){if(o&&o.isTexture){const a=o.mapping;if(a===vd||a===xd)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new t4(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const fa=4,fv=[.125,.215,.35,.446,.526,.582],no=20,kp=new sv,dv=new Et;let Bp=null,Vp=0,Hp=0,Gp=!1;const ro=(1+Math.sqrt(5))/2,da=1/ro,pv=[new j(-ro,da,0),new j(ro,da,0),new j(-da,0,ro),new j(da,0,ro),new j(0,ro,-da),new j(0,ro,da),new j(-1,1,-1),new j(1,1,-1),new j(-1,1,1),new j(1,1,1)],f6=new j;class mv{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,r=.1,i=100,s={}){const{size:o=256,position:a=f6}=s;Bp=this._renderer.getRenderTarget(),Vp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_v(),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;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Bp,Vp,Hp),this._renderer.xr.enabled=Gp,e.scissorTest=!1,Ou(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Bo||e.mapping===Vo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Bp=this._renderer.getRenderTarget(),Vp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:Ei,minFilter:Ei,generateMipmaps:!1,type:hl,format:Qr,colorSpace:Ho,depthBuffer:!1},i=gv(e,t,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gv(e,t,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=d6(s)),this._blurMaterial=p6(s,e,t)}return i}_compileMaterial(e){const t=new Tn(this._lodPlanes[0],e);this._renderer.compile(t,kp)}_sceneToCubeUV(e,t,r,i,s){const l=new vr(90,1,t,r),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,d=f.toneMapping;f.getClearColor(dv),f.toneMapping=hs,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null));const x=new Ks({name:"PMREM.Background",side:er,depthWrite:!1,depthTest:!1}),v=new Tn(new Js,x);let _=!1;const w=e.background;w?w.isColor&&(x.color.copy(w),e.background=null,_=!0):(x.color.copy(dv),_=!0);for(let E=0;E<6;E++){const S=E%3;S===0?(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[E],s.y,s.z)):S===1?(l.up.set(0,0,c[E]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[E],s.z)):(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[E]));const b=this._cubeSize;Ou(i,S*b,E>2?b:0,b,b),f.setRenderTarget(i),_&&f.render(v,l),f.render(e,l)}v.geometry.dispose(),v.material.dispose(),f.toneMapping=d,f.autoClear=p,e.background=w}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===Bo||e.mapping===Vo;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=vv()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_v());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Tn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Ou(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(o,kp)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=pv[(i-s-1)%pv.length];this._blur(e,s-1,s,o,a)}t.autoClear=r}_blur(e,t,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new Tn(this._lodPlanes[i],c),p=c.uniforms,d=this._sizeLods[r]-1,m=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*no-1),x=s/m,v=isFinite(s)?1+Math.floor(h*x):no;v>no&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${no}`);const _=[];let w=0;for(let q=0;q<no;++q){const O=q/x,T=Math.exp(-O*O/2);_.push(T),q===0?w+=T:q<v&&(w+=2*T)}for(let q=0;q<_.length;q++)_[q]=_[q]/w;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=_,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:E}=this;p.dTheta.value=m,p.mipInt.value=E-r;const S=this._sizeLods[i],b=3*S*(i>E-fa?i-E+fa:0),A=4*(this._cubeSize-S);Ou(t,b,A,3*S,2*S),l.setRenderTarget(t),l.render(f,kp)}}function d6(n){const e=[],t=[],r=[];let i=n;const s=n-fa+1+fv.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>n-fa?l=fv[o-n+fa-1]:o===0&&(l=0),r.push(l);const c=1/(a-2),h=-c,f=1+c,p=[h,h,f,h,f,f,h,h,f,f,h,f],d=6,m=6,x=3,v=2,_=1,w=new Float32Array(x*m*d),E=new Float32Array(v*m*d),S=new Float32Array(_*m*d);for(let A=0;A<d;A++){const q=A%3*2/3-1,O=A>2?0:-1,T=[q,O,0,q+2/3,O,0,q+2/3,O+1,0,q,O,0,q+2/3,O+1,0,q,O+1,0];w.set(T,x*m*A),E.set(p,v*m*A);const I=[A,A,A,A,A,A];S.set(I,_*m*A)}const b=new nr;b.setAttribute("position",new qr(w,x)),b.setAttribute("uv",new qr(E,v)),b.setAttribute("faceIndex",new qr(S,_)),e.push(b),i>fa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function gv(n,e,t){const r=new js(n,e,t);return r.texture.mapping=Gc,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ou(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function p6(n,e,t){const r=new Float32Array(no),i=new j(0,1,0);return new xs({name:"SphericalGaussianBlur",defines:{n:no,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Wp(),fragmentShader:`
3656
+ }`},Fe={common:{diffuse:{value:new Et(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new mt},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new mt}},envmap:{envMap:{value:null},envMapRotation:{value:new mt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new mt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new mt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new mt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new mt},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new mt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new mt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new mt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new mt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Et(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 Et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0},uvTransform:{value:new mt}},sprite:{diffuse:{value:new Et(16777215)},opacity:{value:1},center:{value:new Ne(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new mt},alphaMap:{value:null},alphaMapTransform:{value:new mt},alphaTest:{value:0}}},Ai={basic:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.fog]),vertexShader:_t.meshbasic_vert,fragmentShader:_t.meshbasic_frag},lambert:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)}}]),vertexShader:_t.meshlambert_vert,fragmentShader:_t.meshlambert_frag},phong:{uniforms:Wn([Fe.common,Fe.specularmap,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)},specular:{value:new Et(1118481)},shininess:{value:30}}]),vertexShader:_t.meshphong_vert,fragmentShader:_t.meshphong_frag},standard:{uniforms:Wn([Fe.common,Fe.envmap,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.roughnessmap,Fe.metalnessmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag},toon:{uniforms:Wn([Fe.common,Fe.aomap,Fe.lightmap,Fe.emissivemap,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.gradientmap,Fe.fog,Fe.lights,{emissive:{value:new Et(0)}}]),vertexShader:_t.meshtoon_vert,fragmentShader:_t.meshtoon_frag},matcap:{uniforms:Wn([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,Fe.fog,{matcap:{value:null}}]),vertexShader:_t.meshmatcap_vert,fragmentShader:_t.meshmatcap_frag},points:{uniforms:Wn([Fe.points,Fe.fog]),vertexShader:_t.points_vert,fragmentShader:_t.points_frag},dashed:{uniforms:Wn([Fe.common,Fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:_t.linedashed_vert,fragmentShader:_t.linedashed_frag},depth:{uniforms:Wn([Fe.common,Fe.displacementmap]),vertexShader:_t.depth_vert,fragmentShader:_t.depth_frag},normal:{uniforms:Wn([Fe.common,Fe.bumpmap,Fe.normalmap,Fe.displacementmap,{opacity:{value:1}}]),vertexShader:_t.meshnormal_vert,fragmentShader:_t.meshnormal_frag},sprite:{uniforms:Wn([Fe.sprite,Fe.fog]),vertexShader:_t.sprite_vert,fragmentShader:_t.sprite_frag},background:{uniforms:{uvTransform:{value:new mt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:_t.background_vert,fragmentShader:_t.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new mt}},vertexShader:_t.backgroundCube_vert,fragmentShader:_t.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:_t.cube_vert,fragmentShader:_t.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:_t.equirect_vert,fragmentShader:_t.equirect_frag},distanceRGBA:{uniforms:Wn([Fe.common,Fe.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:_t.distanceRGBA_vert,fragmentShader:_t.distanceRGBA_frag},shadow:{uniforms:Wn([Fe.lights,Fe.fog,{color:{value:new Et(0)},opacity:{value:1}}]),vertexShader:_t.shadow_vert,fragmentShader:_t.shadow_frag}};Ai.physical={uniforms:Wn([Ai.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new mt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new mt},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new mt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new mt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new mt},sheen:{value:0},sheenColor:{value:new Et(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new mt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new mt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new mt},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new mt},attenuationDistance:{value:0},attenuationColor:{value:new Et(0)},specularColor:{value:new Et(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new mt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new mt},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new mt}}]),vertexShader:_t.meshphysical_vert,fragmentShader:_t.meshphysical_frag};const Lu={r:0,b:0,g:0},to=new ni,s6=new Gt;function o6(n,e,t,r,i,s,o){const a=new Et(0);let l=s===!0?0:1,c,h,f=null,p=0,d=null;function m(E){let S=E.isScene===!0?E.background:null;return S&&S.isTexture&&(S=(E.backgroundBlurriness>0?t:e).get(S)),S}function x(E){let S=!1;const b=m(E);b===null?_(a,l):b&&b.isColor&&(_(b,1),S=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(n.autoClear||S)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function v(E,S){const b=m(S);b&&(b.isCubeTexture||b.mapping===Gc)?(h===void 0&&(h=new Tn(new Js(1,1,1),new xs({name:"BackgroundCubeMaterial",uniforms:ia(Ai.backgroundCube.uniforms),vertexShader:Ai.backgroundCube.vertexShader,fragmentShader:Ai.backgroundCube.fragmentShader,side:er,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(A,q,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),to.copy(S.backgroundRotation),to.x*=-1,to.y*=-1,to.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(to.y*=-1,to.z*=-1),h.material.uniforms.envMap.value=b,h.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(s6.makeRotationFromEuler(to)),h.material.toneMapped=Ct.getTransfer(b.colorSpace)!==Ft,(f!==b||p!==b.version||d!==n.toneMapping)&&(h.material.needsUpdate=!0,f=b,p=b.version,d=n.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new Tn(new Pu(2,2),new xs({name:"BackgroundMaterial",uniforms:ia(Ai.background.uniforms),vertexShader:Ai.background.vertexShader,fragmentShader:Ai.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=Ct.getTransfer(b.colorSpace)!==Ft,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(f!==b||p!==b.version||d!==n.toneMapping)&&(c.material.needsUpdate=!0,f=b,p=b.version,d=n.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function _(E,S){E.getRGB(Lu,I_(n)),r.buffers.color.setClear(Lu.r,Lu.g,Lu.b,S,o)}function w(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,S=1){a.set(E),l=S,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,_(a,l)},render:x,addToRenderList:v,dispose:w}}function a6(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,o=!1;function a(I,N,H,W,Q){let ae=!1;const J=f(W,H,N);s!==J&&(s=J,c(s.object)),ae=d(I,W,H,Q),ae&&m(I,W,H,Q),Q!==null&&e.update(Q,n.ELEMENT_ARRAY_BUFFER),(ae||o)&&(o=!1,S(I,N,H,W),Q!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(Q).buffer))}function l(){return n.createVertexArray()}function c(I){return n.bindVertexArray(I)}function h(I){return n.deleteVertexArray(I)}function f(I,N,H){const W=H.wireframe===!0;let Q=r[I.id];Q===void 0&&(Q={},r[I.id]=Q);let ae=Q[N.id];ae===void 0&&(ae={},Q[N.id]=ae);let J=ae[W];return J===void 0&&(J=p(l()),ae[W]=J),J}function p(I){const N=[],H=[],W=[];for(let Q=0;Q<t;Q++)N[Q]=0,H[Q]=0,W[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:H,attributeDivisors:W,object:I,attributes:{},index:null}}function d(I,N,H,W){const Q=s.attributes,ae=N.attributes;let J=0;const se=H.getAttributes();for(const B in se)if(se[B].location>=0){const F=Q[B];let X=ae[B];if(X===void 0&&(B==="instanceMatrix"&&I.instanceMatrix&&(X=I.instanceMatrix),B==="instanceColor"&&I.instanceColor&&(X=I.instanceColor)),F===void 0||F.attribute!==X||X&&F.data!==X.data)return!0;J++}return s.attributesNum!==J||s.index!==W}function m(I,N,H,W){const Q={},ae=N.attributes;let J=0;const se=H.getAttributes();for(const B in se)if(se[B].location>=0){let F=ae[B];F===void 0&&(B==="instanceMatrix"&&I.instanceMatrix&&(F=I.instanceMatrix),B==="instanceColor"&&I.instanceColor&&(F=I.instanceColor));const X={};X.attribute=F,F&&F.data&&(X.data=F.data),Q[B]=X,J++}s.attributes=Q,s.attributesNum=J,s.index=W}function x(){const I=s.newAttributes;for(let N=0,H=I.length;N<H;N++)I[N]=0}function v(I){_(I,0)}function _(I,N){const H=s.newAttributes,W=s.enabledAttributes,Q=s.attributeDivisors;H[I]=1,W[I]===0&&(n.enableVertexAttribArray(I),W[I]=1),Q[I]!==N&&(n.vertexAttribDivisor(I,N),Q[I]=N)}function w(){const I=s.newAttributes,N=s.enabledAttributes;for(let H=0,W=N.length;H<W;H++)N[H]!==I[H]&&(n.disableVertexAttribArray(H),N[H]=0)}function E(I,N,H,W,Q,ae,J){J===!0?n.vertexAttribIPointer(I,N,H,Q,ae):n.vertexAttribPointer(I,N,H,W,Q,ae)}function S(I,N,H,W){x();const Q=W.attributes,ae=H.getAttributes(),J=N.defaultAttributeValues;for(const se in ae){const B=ae[se];if(B.location>=0){let ge=Q[se];if(ge===void 0&&(se==="instanceMatrix"&&I.instanceMatrix&&(ge=I.instanceMatrix),se==="instanceColor"&&I.instanceColor&&(ge=I.instanceColor)),ge!==void 0){const F=ge.normalized,X=ge.itemSize,de=e.get(ge);if(de===void 0)continue;const ye=de.buffer,Ee=de.type,V=de.bytesPerElement,re=Ee===n.INT||Ee===n.UNSIGNED_INT||ge.gpuType===Ed;if(ge.isInterleavedBufferAttribute){const Z=ge.data,he=Z.stride,xe=ge.offset;if(Z.isInstancedInterleavedBuffer){for(let ee=0;ee<B.locationSize;ee++)_(B.location+ee,Z.meshPerAttribute);I.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ee=0;ee<B.locationSize;ee++)v(B.location+ee);n.bindBuffer(n.ARRAY_BUFFER,ye);for(let ee=0;ee<B.locationSize;ee++)E(B.location+ee,X/B.locationSize,Ee,F,he*V,(xe+X/B.locationSize*ee)*V,re)}else{if(ge.isInstancedBufferAttribute){for(let Z=0;Z<B.locationSize;Z++)_(B.location+Z,ge.meshPerAttribute);I.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Z=0;Z<B.locationSize;Z++)v(B.location+Z);n.bindBuffer(n.ARRAY_BUFFER,ye);for(let Z=0;Z<B.locationSize;Z++)E(B.location+Z,X/B.locationSize,Ee,F,X*V,X/B.locationSize*Z*V,re)}}else if(J!==void 0){const F=J[se];if(F!==void 0)switch(F.length){case 2:n.vertexAttrib2fv(B.location,F);break;case 3:n.vertexAttrib3fv(B.location,F);break;case 4:n.vertexAttrib4fv(B.location,F);break;default:n.vertexAttrib1fv(B.location,F)}}}}w()}function b(){O();for(const I in r){const N=r[I];for(const H in N){const W=N[H];for(const Q in W)h(W[Q].object),delete W[Q];delete N[H]}delete r[I]}}function A(I){if(r[I.id]===void 0)return;const N=r[I.id];for(const H in N){const W=N[H];for(const Q in W)h(W[Q].object),delete W[Q];delete N[H]}delete r[I.id]}function q(I){for(const N in r){const H=r[N];if(H[I.id]===void 0)continue;const W=H[I.id];for(const Q in W)h(W[Q].object),delete W[Q];delete H[I.id]}}function O(){T(),o=!0,s!==i&&(s=i,c(s.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:O,resetDefaultState:T,dispose:b,releaseStatesOfGeometry:A,releaseStatesOfProgram:q,initAttributes:x,enableAttribute:v,disableUnusedAttributes:w}}function l6(n,e,t){let r;function i(c){r=c}function s(c,h){n.drawArrays(r,c,h),t.update(h,r,1)}function o(c,h,f){f!==0&&(n.drawArraysInstanced(r,c,h,f),t.update(h,r,f))}function a(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,h,0,f);let d=0;for(let m=0;m<f;m++)d+=h[m];t.update(d,r,1)}function l(c,h,f,p){if(f===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let m=0;m<c.length;m++)o(c[m],h[m],p[m]);else{d.multiDrawArraysInstancedWEBGL(r,c,0,h,0,p,0,f);let m=0;for(let x=0;x<f;x++)m+=h[x]*p[x];t.update(m,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function c6(n,e,t,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const q=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(q.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(q){return!(q!==Qr&&r.convert(q)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(q){const O=q===hl&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(q!==bi&&r.convert(q)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&q!==zi&&!O)}function l(q){if(q==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";q="mediump"}return q==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),v=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),w=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),S=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=m>0,A=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:d,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:v,maxAttributes:_,maxVertexUniforms:w,maxVaryings:E,maxFragmentUniforms:S,vertexTextures:b,maxSamples:A}}function u6(n){const e=this;let t=null,r=0,i=!1,s=!1;const o=new Ss,a=new mt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const d=f.length!==0||p||r!==0||i;return i=p,r=f.length,d},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,p){t=h(f,p,0)},this.setState=function(f,p,d){const m=f.clippingPlanes,x=f.clipIntersection,v=f.clipShadows,_=n.get(f);if(!i||m===null||m.length===0||s&&!v)s?h(null):c();else{const w=s?0:r,E=w*4;let S=_.clippingState||null;l.value=S,S=h(m,p,E,d);for(let b=0;b!==E;++b)S[b]=t[b];_.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function h(f,p,d,m){const x=f!==null?f.length:0;let v=null;if(x!==0){if(v=l.value,m!==!0||v===null){const _=d+x*4,w=p.matrixWorldInverse;a.getNormalMatrix(w),(v===null||v.length<_)&&(v=new Float32Array(_));for(let E=0,S=d;E!==x;++E,S+=4)o.copy(f[E]).applyMatrix4(w,a),o.normal.toArray(v,S),v[S+3]=o.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,v}}function h6(n){let e=new WeakMap;function t(o,a){return a===vd?o.mapping=Bo:a===xd&&(o.mapping=Vo),o}function r(o){if(o&&o.isTexture){const a=o.mapping;if(a===vd||a===xd)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new t4(l.height);return c.fromEquirectangularTexture(n,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const fa=4,fv=[.125,.215,.35,.446,.526,.582],no=20,kp=new sv,dv=new Et;let Bp=null,Vp=0,Hp=0,Gp=!1;const ro=(1+Math.sqrt(5))/2,da=1/ro,pv=[new j(-ro,da,0),new j(ro,da,0),new j(-da,0,ro),new j(da,0,ro),new j(0,ro,-da),new j(0,ro,da),new j(-1,1,-1),new j(1,1,-1),new j(-1,1,1),new j(1,1,1)],f6=new j;class mv{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,r=.1,i=100,s={}){const{size:o=256,position:a=f6}=s;Bp=this._renderer.getRenderTarget(),Vp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_v(),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;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Bp,Vp,Hp),this._renderer.xr.enabled=Gp,e.scissorTest=!1,Ou(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Bo||e.mapping===Vo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Bp=this._renderer.getRenderTarget(),Vp=this._renderer.getActiveCubeFace(),Hp=this._renderer.getActiveMipmapLevel(),Gp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:Ei,minFilter:Ei,generateMipmaps:!1,type:hl,format:Qr,colorSpace:Ho,depthBuffer:!1},i=gv(e,t,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gv(e,t,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=d6(s)),this._blurMaterial=p6(s,e,t)}return i}_compileMaterial(e){const t=new Tn(this._lodPlanes[0],e);this._renderer.compile(t,kp)}_sceneToCubeUV(e,t,r,i,s){const l=new vr(90,1,t,r),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,d=f.toneMapping;f.getClearColor(dv),f.toneMapping=hs,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null));const x=new Ks({name:"PMREM.Background",side:er,depthWrite:!1,depthTest:!1}),v=new Tn(new Js,x);let _=!1;const w=e.background;w?w.isColor&&(x.color.copy(w),e.background=null,_=!0):(x.color.copy(dv),_=!0);for(let E=0;E<6;E++){const S=E%3;S===0?(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[E],s.y,s.z)):S===1?(l.up.set(0,0,c[E]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[E],s.z)):(l.up.set(0,c[E],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[E]));const b=this._cubeSize;Ou(i,S*b,E>2?b:0,b,b),f.setRenderTarget(i),_&&f.render(v,l),f.render(e,l)}v.geometry.dispose(),v.material.dispose(),f.toneMapping=d,f.autoClear=p,e.background=w}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===Bo||e.mapping===Vo;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=vv()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_v());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Tn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Ou(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(o,kp)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;s<i;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=pv[(i-s-1)%pv.length];this._blur(e,s-1,s,o,a)}t.autoClear=r}_blur(e,t,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,f=new Tn(this._lodPlanes[i],c),p=c.uniforms,d=this._sizeLods[r]-1,m=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*no-1),x=s/m,v=isFinite(s)?1+Math.floor(h*x):no;v>no&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${no}`);const _=[];let w=0;for(let q=0;q<no;++q){const O=q/x,T=Math.exp(-O*O/2);_.push(T),q===0?w+=T:q<v&&(w+=2*T)}for(let q=0;q<_.length;q++)_[q]=_[q]/w;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=_,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:E}=this;p.dTheta.value=m,p.mipInt.value=E-r;const S=this._sizeLods[i],b=3*S*(i>E-fa?i-E+fa:0),A=4*(this._cubeSize-S);Ou(t,b,A,3*S,2*S),l.setRenderTarget(t),l.render(f,kp)}}function d6(n){const e=[],t=[],r=[];let i=n;const s=n-fa+1+fv.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>n-fa?l=fv[o-n+fa-1]:o===0&&(l=0),r.push(l);const c=1/(a-2),h=-c,f=1+c,p=[h,h,f,h,f,f,h,h,f,f,h,f],d=6,m=6,x=3,v=2,_=1,w=new Float32Array(x*m*d),E=new Float32Array(v*m*d),S=new Float32Array(_*m*d);for(let A=0;A<d;A++){const q=A%3*2/3-1,O=A>2?0:-1,T=[q,O,0,q+2/3,O,0,q+2/3,O+1,0,q,O,0,q+2/3,O+1,0,q,O+1,0];w.set(T,x*m*A),E.set(p,v*m*A);const I=[A,A,A,A,A,A];S.set(I,_*m*A)}const b=new nr;b.setAttribute("position",new Dr(w,x)),b.setAttribute("uv",new Dr(E,v)),b.setAttribute("faceIndex",new Dr(S,_)),e.push(b),i>fa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function gv(n,e,t){const r=new js(n,e,t);return r.texture.mapping=Gc,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ou(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function p6(n,e,t){const r=new Float32Array(no),i=new j(0,1,0);return new xs({name:"SphericalGaussianBlur",defines:{n:no,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Wp(),fragmentShader:`
3657
3657
 
3658
3658
  precision mediump float;
3659
3659
  precision mediump int;
@@ -3882,7 +3882,7 @@ void main() {
3882
3882
  squared_mean = squared_mean / samples;
3883
3883
  float std_dev = sqrt( squared_mean - mean * mean );
3884
3884
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3885
- }`;function $T(n,e,t){let r=new Tp;const i=new Ne,s=new Ne,o=new ln,a=new V4({depthPacking:yM}),l=new H4,c={},h=t.maxTextureSize,f={[cs]:er,[er]:cs,[Si]:Si},p=new xs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:jT,fragmentShader:XT}),d=p.clone();d.defines.HORIZONTAL_PASS=1;const m=new nr;m.setAttribute("position",new qr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Tn(m,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$1;let _=this.type;this.render=function(A,q,O){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||A.length===0)return;const T=n.getRenderTarget(),I=n.getActiveCubeFace(),N=n.getActiveMipmapLevel(),H=n.state;H.setBlending(us),H.buffers.depth.getReversed()?H.buffers.color.setClear(0,0,0,0):H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const W=_!==Fi&&this.type===Fi,Q=_===Fi&&this.type!==Fi;for(let ae=0,J=A.length;ae<J;ae++){const se=A[ae],B=se.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;i.copy(B.mapSize);const ge=B.getFrameExtents();if(i.multiply(ge),s.copy(B.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/ge.x),i.x=s.x*ge.x,B.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/ge.y),i.y=s.y*ge.y,B.mapSize.y=s.y)),B.map===null||W===!0||Q===!0){const X=this.type!==Fi?{minFilter:Jr,magFilter:Jr}:{};B.map!==null&&B.map.dispose(),B.map=new js(i.x,i.y,X),B.map.texture.name=se.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const F=B.getViewportCount();for(let X=0;X<F;X++){const de=B.getViewport(X);o.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),H.viewport(o),B.updateMatrices(se,X),r=B.getFrustum(),S(q,O,B.camera,se,this.type)}B.isPointLightShadow!==!0&&this.type===Fi&&w(B,O),B.needsUpdate=!1}_=this.type,v.needsUpdate=!1,n.setRenderTarget(T,I,N)};function w(A,q){const O=e.update(x);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,d.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,d.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new js(i.x,i.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(q,null,O,p,x,null),d.uniforms.shadow_pass.value=A.mapPass.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(q,null,O,d,x,null)}function E(A,q,O,T){let I=null;const N=O.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(N!==void 0)I=N;else if(I=O.isPointLight===!0?l:a,n.localClippingEnabled&&q.clipShadows===!0&&Array.isArray(q.clippingPlanes)&&q.clippingPlanes.length!==0||q.displacementMap&&q.displacementScale!==0||q.alphaMap&&q.alphaTest>0||q.map&&q.alphaTest>0||q.alphaToCoverage===!0){const H=I.uuid,W=q.uuid;let Q=c[H];Q===void 0&&(Q={},c[H]=Q);let ae=Q[W];ae===void 0&&(ae=I.clone(),Q[W]=ae,q.addEventListener("dispose",b)),I=ae}if(I.visible=q.visible,I.wireframe=q.wireframe,T===Fi?I.side=q.shadowSide!==null?q.shadowSide:q.side:I.side=q.shadowSide!==null?q.shadowSide:f[q.side],I.alphaMap=q.alphaMap,I.alphaTest=q.alphaToCoverage===!0?.5:q.alphaTest,I.map=q.map,I.clipShadows=q.clipShadows,I.clippingPlanes=q.clippingPlanes,I.clipIntersection=q.clipIntersection,I.displacementMap=q.displacementMap,I.displacementScale=q.displacementScale,I.displacementBias=q.displacementBias,I.wireframeLinewidth=q.wireframeLinewidth,I.linewidth=q.linewidth,O.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const H=n.properties.get(I);H.light=O}return I}function S(A,q,O,T,I){if(A.visible===!1)return;if(A.layers.test(q.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&I===Fi)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,A.matrixWorld);const W=e.update(A),Q=A.material;if(Array.isArray(Q)){const ae=W.groups;for(let J=0,se=ae.length;J<se;J++){const B=ae[J],ge=Q[B.materialIndex];if(ge&&ge.visible){const F=E(A,ge,T,I);A.onBeforeShadow(n,A,q,O,W,F,B),n.renderBufferDirect(O,null,W,F,A,B),A.onAfterShadow(n,A,q,O,W,F,B)}}}else if(Q.visible){const ae=E(A,Q,T,I);A.onBeforeShadow(n,A,q,O,W,ae,null),n.renderBufferDirect(O,null,W,ae,A,null),A.onAfterShadow(n,A,q,O,W,ae,null)}}const H=A.children;for(let W=0,Q=H.length;W<Q;W++)S(H[W],q,O,T,I)}function b(A){A.target.removeEventListener("dispose",b);for(const O in c){const T=c[O],I=A.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}const YT={[ud]:hd,[fd]:md,[dd]:gd,[ko]:pd,[hd]:ud,[md]:fd,[gd]:dd,[pd]:ko};function KT(n,e){function t(){let G=!1;const Se=new ln;let Oe=null;const ke=new ln(0,0,0,0);return{setMask:function(Te){Oe!==Te&&!G&&(n.colorMask(Te,Te,Te,Te),Oe=Te)},setLocked:function(Te){G=Te},setClear:function(Te,me,Ke,ut,Ot){Ot===!0&&(Te*=ut,me*=ut,Ke*=ut),Se.set(Te,me,Ke,ut),ke.equals(Se)===!1&&(n.clearColor(Te,me,Ke,ut),ke.copy(Se))},reset:function(){G=!1,Oe=null,ke.set(-1,0,0,0)}}}function r(){let G=!1,Se=!1,Oe=null,ke=null,Te=null;return{setReversed:function(me){if(Se!==me){const Ke=e.get("EXT_clip_control");me?Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.ZERO_TO_ONE_EXT):Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.NEGATIVE_ONE_TO_ONE_EXT),Se=me;const ut=Te;Te=null,this.setClear(ut)}},getReversed:function(){return Se},setTest:function(me){me?Z(n.DEPTH_TEST):he(n.DEPTH_TEST)},setMask:function(me){Oe!==me&&!G&&(n.depthMask(me),Oe=me)},setFunc:function(me){if(Se&&(me=YT[me]),ke!==me){switch(me){case ud:n.depthFunc(n.NEVER);break;case hd:n.depthFunc(n.ALWAYS);break;case fd:n.depthFunc(n.LESS);break;case ko:n.depthFunc(n.LEQUAL);break;case dd:n.depthFunc(n.EQUAL);break;case pd:n.depthFunc(n.GEQUAL);break;case md:n.depthFunc(n.GREATER);break;case gd:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ke=me}},setLocked:function(me){G=me},setClear:function(me){Te!==me&&(Se&&(me=1-me),n.clearDepth(me),Te=me)},reset:function(){G=!1,Oe=null,ke=null,Te=null,Se=!1}}}function i(){let G=!1,Se=null,Oe=null,ke=null,Te=null,me=null,Ke=null,ut=null,Ot=null;return{setTest:function(dt){G||(dt?Z(n.STENCIL_TEST):he(n.STENCIL_TEST))},setMask:function(dt){Se!==dt&&!G&&(n.stencilMask(dt),Se=dt)},setFunc:function(dt,ai,sr){(Oe!==dt||ke!==ai||Te!==sr)&&(n.stencilFunc(dt,ai,sr),Oe=dt,ke=ai,Te=sr)},setOp:function(dt,ai,sr){(me!==dt||Ke!==ai||ut!==sr)&&(n.stencilOp(dt,ai,sr),me=dt,Ke=ai,ut=sr)},setLocked:function(dt){G=dt},setClear:function(dt){Ot!==dt&&(n.clearStencil(dt),Ot=dt)},reset:function(){G=!1,Se=null,Oe=null,ke=null,Te=null,me=null,Ke=null,ut=null,Ot=null}}}const s=new t,o=new r,a=new i,l=new WeakMap,c=new WeakMap;let h={},f={},p=new WeakMap,d=[],m=null,x=!1,v=null,_=null,w=null,E=null,S=null,b=null,A=null,q=new Et(0,0,0),O=0,T=!1,I=null,N=null,H=null,W=null,Q=null;const ae=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,se=0;const B=n.getParameter(n.VERSION);B.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec(B)[1]),J=se>=1):B.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),J=se>=2);let ge=null,F={};const X=n.getParameter(n.SCISSOR_BOX),de=n.getParameter(n.VIEWPORT),ye=new ln().fromArray(X),Ee=new ln().fromArray(de);function V(G,Se,Oe,ke){const Te=new Uint8Array(4),me=n.createTexture();n.bindTexture(G,me),n.texParameteri(G,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(G,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ke=0;Ke<Oe;Ke++)G===n.TEXTURE_3D||G===n.TEXTURE_2D_ARRAY?n.texImage3D(Se,0,n.RGBA,1,1,ke,0,n.RGBA,n.UNSIGNED_BYTE,Te):n.texImage2D(Se+Ke,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Te);return me}const re={};re[n.TEXTURE_2D]=V(n.TEXTURE_2D,n.TEXTURE_2D,1),re[n.TEXTURE_CUBE_MAP]=V(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[n.TEXTURE_2D_ARRAY]=V(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),re[n.TEXTURE_3D]=V(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Z(n.DEPTH_TEST),o.setFunc(ko),at(!1),ze(X1),Z(n.CULL_FACE),rt(us);function Z(G){h[G]!==!0&&(n.enable(G),h[G]=!0)}function he(G){h[G]!==!1&&(n.disable(G),h[G]=!1)}function xe(G,Se){return f[G]!==Se?(n.bindFramebuffer(G,Se),f[G]=Se,G===n.DRAW_FRAMEBUFFER&&(f[n.FRAMEBUFFER]=Se),G===n.FRAMEBUFFER&&(f[n.DRAW_FRAMEBUFFER]=Se),!0):!1}function ee(G,Se){let Oe=d,ke=!1;if(G){Oe=p.get(Se),Oe===void 0&&(Oe=[],p.set(Se,Oe));const Te=G.textures;if(Oe.length!==Te.length||Oe[0]!==n.COLOR_ATTACHMENT0){for(let me=0,Ke=Te.length;me<Ke;me++)Oe[me]=n.COLOR_ATTACHMENT0+me;Oe.length=Te.length,ke=!0}}else Oe[0]!==n.BACK&&(Oe[0]=n.BACK,ke=!0);ke&&n.drawBuffers(Oe)}function Pe(G){return m!==G?(n.useProgram(G),m=G,!0):!1}const le={[Bs]:n.FUNC_ADD,[jb]:n.FUNC_SUBTRACT,[Xb]:n.FUNC_REVERSE_SUBTRACT};le[$b]=n.MIN,le[Yb]=n.MAX;const z={[Kb]:n.ZERO,[Zb]:n.ONE,[Jb]:n.SRC_COLOR,[ld]:n.SRC_ALPHA,[iM]:n.SRC_ALPHA_SATURATE,[nM]:n.DST_COLOR,[eM]:n.DST_ALPHA,[Qb]:n.ONE_MINUS_SRC_COLOR,[cd]:n.ONE_MINUS_SRC_ALPHA,[rM]:n.ONE_MINUS_DST_COLOR,[tM]:n.ONE_MINUS_DST_ALPHA,[sM]:n.CONSTANT_COLOR,[oM]:n.ONE_MINUS_CONSTANT_COLOR,[aM]:n.CONSTANT_ALPHA,[lM]:n.ONE_MINUS_CONSTANT_ALPHA};function rt(G,Se,Oe,ke,Te,me,Ke,ut,Ot,dt){if(G===us){x===!0&&(he(n.BLEND),x=!1);return}if(x===!1&&(Z(n.BLEND),x=!0),G!==Wb){if(G!==v||dt!==T){if((_!==Bs||S!==Bs)&&(n.blendEquation(n.FUNC_ADD),_=Bs,S=Bs),dt)switch(G){case zo:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Y1:n.blendFunc(n.ONE,n.ONE);break;case K1:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Z1:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",G);break}else switch(G){case zo:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Y1:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case K1:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Z1:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",G);break}w=null,E=null,b=null,A=null,q.set(0,0,0),O=0,v=G,T=dt}return}Te=Te||Se,me=me||Oe,Ke=Ke||ke,(Se!==_||Te!==S)&&(n.blendEquationSeparate(le[Se],le[Te]),_=Se,S=Te),(Oe!==w||ke!==E||me!==b||Ke!==A)&&(n.blendFuncSeparate(z[Oe],z[ke],z[me],z[Ke]),w=Oe,E=ke,b=me,A=Ke),(ut.equals(q)===!1||Ot!==O)&&(n.blendColor(ut.r,ut.g,ut.b,Ot),q.copy(ut),O=Ot),v=G,T=!1}function Le(G,Se){G.side===Si?he(n.CULL_FACE):Z(n.CULL_FACE);let Oe=G.side===er;Se&&(Oe=!Oe),at(Oe),G.blending===zo&&G.transparent===!1?rt(us):rt(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),o.setFunc(G.depthFunc),o.setTest(G.depthTest),o.setMask(G.depthWrite),s.setMask(G.colorWrite);const ke=G.stencilWrite;a.setTest(ke),ke&&(a.setMask(G.stencilWriteMask),a.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),a.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass)),be(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?Z(n.SAMPLE_ALPHA_TO_COVERAGE):he(n.SAMPLE_ALPHA_TO_COVERAGE)}function at(G){I!==G&&(G?n.frontFace(n.CW):n.frontFace(n.CCW),I=G)}function ze(G){G!==Vb?(Z(n.CULL_FACE),G!==N&&(G===X1?n.cullFace(n.BACK):G===Hb?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):he(n.CULL_FACE),N=G}function Xe(G){G!==H&&(J&&n.lineWidth(G),H=G)}function be(G,Se,Oe){G?(Z(n.POLYGON_OFFSET_FILL),(W!==Se||Q!==Oe)&&(n.polygonOffset(Se,Oe),W=Se,Q=Oe)):he(n.POLYGON_OFFSET_FILL)}function tt(G){G?Z(n.SCISSOR_TEST):he(n.SCISSOR_TEST)}function lt(G){G===void 0&&(G=n.TEXTURE0+ae-1),ge!==G&&(n.activeTexture(G),ge=G)}function $e(G,Se,Oe){Oe===void 0&&(ge===null?Oe=n.TEXTURE0+ae-1:Oe=ge);let ke=F[Oe];ke===void 0&&(ke={type:void 0,texture:void 0},F[Oe]=ke),(ke.type!==G||ke.texture!==Se)&&(ge!==Oe&&(n.activeTexture(Oe),ge=Oe),n.bindTexture(G,Se||re[G]),ke.type=G,ke.texture=Se)}function U(){const G=F[ge];G!==void 0&&G.type!==void 0&&(n.bindTexture(G.type,null),G.type=void 0,G.texture=void 0)}function P(){try{n.compressedTexImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function te(){try{n.compressedTexImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function pe(){try{n.texSubImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Me(){try{n.texSubImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function fe(){try{n.compressedTexSubImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function De(){try{n.compressedTexSubImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ae(){try{n.texStorage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ge(){try{n.texStorage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function We(){try{n.texImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ce(){try{n.texImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function qe(G){ye.equals(G)===!1&&(n.scissor(G.x,G.y,G.z,G.w),ye.copy(G))}function Be(G){Ee.equals(G)===!1&&(n.viewport(G.x,G.y,G.z,G.w),Ee.copy(G))}function Ye(G,Se){let Oe=c.get(Se);Oe===void 0&&(Oe=new WeakMap,c.set(Se,Oe));let ke=Oe.get(G);ke===void 0&&(ke=n.getUniformBlockIndex(Se,G.name),Oe.set(G,ke))}function Re(G,Se){const ke=c.get(Se).get(G);l.get(Se)!==ke&&(n.uniformBlockBinding(Se,ke,G.__bindingPointIndex),l.set(Se,ke))}function ft(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},ge=null,F={},f={},p=new WeakMap,d=[],m=null,x=!1,v=null,_=null,w=null,E=null,S=null,b=null,A=null,q=new Et(0,0,0),O=0,T=!1,I=null,N=null,H=null,W=null,Q=null,ye.set(0,0,n.canvas.width,n.canvas.height),Ee.set(0,0,n.canvas.width,n.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:Z,disable:he,bindFramebuffer:xe,drawBuffers:ee,useProgram:Pe,setBlending:rt,setMaterial:Le,setFlipSided:at,setCullFace:ze,setLineWidth:Xe,setPolygonOffset:be,setScissorTest:tt,activeTexture:lt,bindTexture:$e,unbindTexture:U,compressedTexImage2D:P,compressedTexImage3D:te,texImage2D:We,texImage3D:Ce,updateUBOMapping:Ye,uniformBlockBinding:Re,texStorage2D:Ae,texStorage3D:Ge,texSubImage2D:pe,texSubImage3D:Me,compressedTexSubImage2D:fe,compressedTexSubImage3D:De,scissor:qe,viewport:Be,reset:ft}}function ZT(n,e,t,r,i,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ne,h=new WeakMap;let f;const p=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(U,P){return d?new OffscreenCanvas(U,P):gl("canvas")}function x(U,P,te){let pe=1;const Me=$e(U);if((Me.width>te||Me.height>te)&&(pe=te/Math.max(Me.width,Me.height)),pe<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const fe=Math.floor(pe*Me.width),De=Math.floor(pe*Me.height);f===void 0&&(f=m(fe,De));const Ae=P?m(fe,De):f;return Ae.width=fe,Ae.height=De,Ae.getContext("2d").drawImage(U,0,0,fe,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+fe+"x"+De+")."),Ae}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),U;return U}function v(U){return U.generateMipmaps}function _(U){n.generateMipmap(U)}function w(U){return U.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?n.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function E(U,P,te,pe,Me=!1){if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let fe=P;if(P===n.RED&&(te===n.FLOAT&&(fe=n.R32F),te===n.HALF_FLOAT&&(fe=n.R16F),te===n.UNSIGNED_BYTE&&(fe=n.R8)),P===n.RED_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.R8UI),te===n.UNSIGNED_SHORT&&(fe=n.R16UI),te===n.UNSIGNED_INT&&(fe=n.R32UI),te===n.BYTE&&(fe=n.R8I),te===n.SHORT&&(fe=n.R16I),te===n.INT&&(fe=n.R32I)),P===n.RG&&(te===n.FLOAT&&(fe=n.RG32F),te===n.HALF_FLOAT&&(fe=n.RG16F),te===n.UNSIGNED_BYTE&&(fe=n.RG8)),P===n.RG_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RG8UI),te===n.UNSIGNED_SHORT&&(fe=n.RG16UI),te===n.UNSIGNED_INT&&(fe=n.RG32UI),te===n.BYTE&&(fe=n.RG8I),te===n.SHORT&&(fe=n.RG16I),te===n.INT&&(fe=n.RG32I)),P===n.RGB_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RGB8UI),te===n.UNSIGNED_SHORT&&(fe=n.RGB16UI),te===n.UNSIGNED_INT&&(fe=n.RGB32UI),te===n.BYTE&&(fe=n.RGB8I),te===n.SHORT&&(fe=n.RGB16I),te===n.INT&&(fe=n.RGB32I)),P===n.RGBA_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RGBA8UI),te===n.UNSIGNED_SHORT&&(fe=n.RGBA16UI),te===n.UNSIGNED_INT&&(fe=n.RGBA32UI),te===n.BYTE&&(fe=n.RGBA8I),te===n.SHORT&&(fe=n.RGBA16I),te===n.INT&&(fe=n.RGBA32I)),P===n.RGB&&te===n.UNSIGNED_INT_5_9_9_9_REV&&(fe=n.RGB9_E5),P===n.RGBA){const De=Me?Zc:Ct.getTransfer(pe);te===n.FLOAT&&(fe=n.RGBA32F),te===n.HALF_FLOAT&&(fe=n.RGBA16F),te===n.UNSIGNED_BYTE&&(fe=De===Ft?n.SRGB8_ALPHA8:n.RGBA8),te===n.UNSIGNED_SHORT_4_4_4_4&&(fe=n.RGBA4),te===n.UNSIGNED_SHORT_5_5_5_1&&(fe=n.RGB5_A1)}return(fe===n.R16F||fe===n.R32F||fe===n.RG16F||fe===n.RG32F||fe===n.RGBA16F||fe===n.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function S(U,P){let te;return U?P===null||P===Gs||P===fl?te=n.DEPTH24_STENCIL8:P===zi?te=n.DEPTH32F_STENCIL8:P===ul&&(te=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===Gs||P===fl?te=n.DEPTH_COMPONENT24:P===zi?te=n.DEPTH_COMPONENT32F:P===ul&&(te=n.DEPTH_COMPONENT16),te}function b(U,P){return v(U)===!0||U.isFramebufferTexture&&U.minFilter!==Jr&&U.minFilter!==Ei?Math.log2(Math.max(P.width,P.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?P.mipmaps.length:1}function A(U){const P=U.target;P.removeEventListener("dispose",A),O(P),P.isVideoTexture&&h.delete(P)}function q(U){const P=U.target;P.removeEventListener("dispose",q),I(P)}function O(U){const P=r.get(U);if(P.__webglInit===void 0)return;const te=U.source,pe=p.get(te);if(pe){const Me=pe[P.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&T(U),Object.keys(pe).length===0&&p.delete(te)}r.remove(U)}function T(U){const P=r.get(U);n.deleteTexture(P.__webglTexture);const te=U.source,pe=p.get(te);delete pe[P.__cacheKey],o.memory.textures--}function I(U){const P=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(P.__webglFramebuffer[pe]))for(let Me=0;Me<P.__webglFramebuffer[pe].length;Me++)n.deleteFramebuffer(P.__webglFramebuffer[pe][Me]);else n.deleteFramebuffer(P.__webglFramebuffer[pe]);P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer[pe])}else{if(Array.isArray(P.__webglFramebuffer))for(let pe=0;pe<P.__webglFramebuffer.length;pe++)n.deleteFramebuffer(P.__webglFramebuffer[pe]);else n.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&n.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let pe=0;pe<P.__webglColorRenderbuffer.length;pe++)P.__webglColorRenderbuffer[pe]&&n.deleteRenderbuffer(P.__webglColorRenderbuffer[pe]);P.__webglDepthRenderbuffer&&n.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const te=U.textures;for(let pe=0,Me=te.length;pe<Me;pe++){const fe=r.get(te[pe]);fe.__webglTexture&&(n.deleteTexture(fe.__webglTexture),o.memory.textures--),r.remove(te[pe])}r.remove(U)}let N=0;function H(){N=0}function W(){const U=N;return U>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),N+=1,U}function Q(U){const P=[];return P.push(U.wrapS),P.push(U.wrapT),P.push(U.wrapR||0),P.push(U.magFilter),P.push(U.minFilter),P.push(U.anisotropy),P.push(U.internalFormat),P.push(U.format),P.push(U.type),P.push(U.generateMipmaps),P.push(U.premultiplyAlpha),P.push(U.flipY),P.push(U.unpackAlignment),P.push(U.colorSpace),P.join()}function ae(U,P){const te=r.get(U);if(U.isVideoTexture&&tt(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&te.__version!==U.version){const pe=U.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(te,U,P);return}}else U.isExternalTexture&&(te.__webglTexture=U.sourceTexture?U.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,te.__webglTexture,n.TEXTURE0+P)}function J(U,P){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){re(te,U,P);return}t.bindTexture(n.TEXTURE_2D_ARRAY,te.__webglTexture,n.TEXTURE0+P)}function se(U,P){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){re(te,U,P);return}t.bindTexture(n.TEXTURE_3D,te.__webglTexture,n.TEXTURE0+P)}function B(U,P){const te=r.get(U);if(U.version>0&&te.__version!==U.version){Z(te,U,P);return}t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture,n.TEXTURE0+P)}const ge={[Zr]:n.REPEAT,[Vs]:n.CLAMP_TO_EDGE,[yd]:n.MIRRORED_REPEAT},F={[Jr]:n.NEAREST,[vM]:n.NEAREST_MIPMAP_NEAREST,[Wc]:n.NEAREST_MIPMAP_LINEAR,[Ei]:n.LINEAR,[Sd]:n.LINEAR_MIPMAP_NEAREST,[Hs]:n.LINEAR_MIPMAP_LINEAR},X={[EM]:n.NEVER,[CM]:n.ALWAYS,[bM]:n.LESS,[l_]:n.LEQUAL,[MM]:n.EQUAL,[AM]:n.GEQUAL,[wM]:n.GREATER,[TM]:n.NOTEQUAL};function de(U,P){if(P.type===zi&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Ei||P.magFilter===Sd||P.magFilter===Wc||P.magFilter===Hs||P.minFilter===Ei||P.minFilter===Sd||P.minFilter===Wc||P.minFilter===Hs)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(U,n.TEXTURE_WRAP_S,ge[P.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,ge[P.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,ge[P.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,F[P.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,F[P.minFilter]),P.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,X[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===Jr||P.minFilter!==Wc&&P.minFilter!==Hs||P.type===zi&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||r.get(P).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");n.texParameterf(U,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,i.getMaxAnisotropy())),r.get(P).__currentAnisotropy=P.anisotropy}}}function ye(U,P){let te=!1;U.__webglInit===void 0&&(U.__webglInit=!0,P.addEventListener("dispose",A));const pe=P.source;let Me=p.get(pe);Me===void 0&&(Me={},p.set(pe,Me));const fe=Q(P);if(fe!==U.__cacheKey){Me[fe]===void 0&&(Me[fe]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,te=!0),Me[fe].usedTimes++;const De=Me[U.__cacheKey];De!==void 0&&(Me[U.__cacheKey].usedTimes--,De.usedTimes===0&&T(P)),U.__cacheKey=fe,U.__webglTexture=Me[fe].texture}return te}function Ee(U,P,te){return Math.floor(Math.floor(U/te)/P)}function V(U,P,te,pe){const fe=U.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,P.width,P.height,te,pe,P.data);else{fe.sort((Ce,qe)=>Ce.start-qe.start);let De=0;for(let Ce=1;Ce<fe.length;Ce++){const qe=fe[De],Be=fe[Ce],Ye=qe.start+qe.count,Re=Ee(Be.start,P.width,4),ft=Ee(qe.start,P.width,4);Be.start<=Ye+1&&Re===ft&&Ee(Be.start+Be.count-1,P.width,4)===Re?qe.count=Math.max(qe.count,Be.start+Be.count-qe.start):(++De,fe[De]=Be)}fe.length=De+1;const Ae=n.getParameter(n.UNPACK_ROW_LENGTH),Ge=n.getParameter(n.UNPACK_SKIP_PIXELS),We=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,P.width);for(let Ce=0,qe=fe.length;Ce<qe;Ce++){const Be=fe[Ce],Ye=Math.floor(Be.start/4),Re=Math.ceil(Be.count/4),ft=Ye%P.width,G=Math.floor(Ye/P.width),Se=Re,Oe=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,ft),n.pixelStorei(n.UNPACK_SKIP_ROWS,G),t.texSubImage2D(n.TEXTURE_2D,0,ft,G,Se,Oe,te,pe,P.data)}U.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,Ae),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Ge),n.pixelStorei(n.UNPACK_SKIP_ROWS,We)}}function re(U,P,te){let pe=n.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(pe=n.TEXTURE_2D_ARRAY),P.isData3DTexture&&(pe=n.TEXTURE_3D);const Me=ye(U,P),fe=P.source;t.bindTexture(pe,U.__webglTexture,n.TEXTURE0+te);const De=r.get(fe);if(fe.version!==De.__version||Me===!0){t.activeTexture(n.TEXTURE0+te);const Ae=Ct.getPrimaries(Ct.workingColorSpace),Ge=P.colorSpace===fs?null:Ct.getPrimaries(P.colorSpace),We=P.colorSpace===fs||Ae===Ge?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);let Ce=x(P.image,!1,i.maxTextureSize);Ce=lt(P,Ce);const qe=s.convert(P.format,P.colorSpace),Be=s.convert(P.type);let Ye=E(P.internalFormat,qe,Be,P.colorSpace,P.isVideoTexture);de(pe,P);let Re;const ft=P.mipmaps,G=P.isVideoTexture!==!0,Se=De.__version===void 0||Me===!0,Oe=fe.dataReady,ke=b(P,Ce);if(P.isDepthTexture)Ye=S(P.format===pl,P.type),Se&&(G?t.texStorage2D(n.TEXTURE_2D,1,Ye,Ce.width,Ce.height):t.texImage2D(n.TEXTURE_2D,0,Ye,Ce.width,Ce.height,0,qe,Be,null));else if(P.isDataTexture)if(ft.length>0){G&&Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,ft[0].width,ft[0].height);for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Be,Re.data):t.texImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,qe,Be,Re.data);P.generateMipmaps=!1}else G?(Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,Ce.width,Ce.height),Oe&&V(P,Ce,qe,Be)):t.texImage2D(n.TEXTURE_2D,0,Ye,Ce.width,Ce.height,0,qe,Be,Ce.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){G&&Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ke,Ye,ft[0].width,ft[0].height,Ce.depth);for(let Te=0,me=ft.length;Te<me;Te++)if(Re=ft[Te],P.format!==Qr)if(qe!==null)if(G){if(Oe)if(P.layerUpdates.size>0){const Ke=uv(Re.width,Re.height,P.format,P.type);for(const ut of P.layerUpdates){const Ot=Re.data.subarray(ut*Ke/Re.data.BYTES_PER_ELEMENT,(ut+1)*Ke/Re.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,ut,Re.width,Re.height,1,qe,Ot)}P.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,0,Re.width,Re.height,Ce.depth,qe,Re.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Te,Ye,Re.width,Re.height,Ce.depth,0,Re.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else G?Oe&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,0,Re.width,Re.height,Ce.depth,qe,Be,Re.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Te,Ye,Re.width,Re.height,Ce.depth,0,qe,Be,Re.data)}else{G&&Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,ft[0].width,ft[0].height);for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],P.format!==Qr?qe!==null?G?Oe&&t.compressedTexSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Re.data):t.compressedTexImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Be,Re.data):t.texImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,qe,Be,Re.data)}else if(P.isDataArrayTexture)if(G){if(Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ke,Ye,Ce.width,Ce.height,Ce.depth),Oe)if(P.layerUpdates.size>0){const Te=uv(Ce.width,Ce.height,P.format,P.type);for(const me of P.layerUpdates){const Ke=Ce.data.subarray(me*Te/Ce.data.BYTES_PER_ELEMENT,(me+1)*Te/Ce.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,me,Ce.width,Ce.height,1,qe,Be,Ke)}P.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ce.width,Ce.height,Ce.depth,qe,Be,Ce.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ye,Ce.width,Ce.height,Ce.depth,0,qe,Be,Ce.data);else if(P.isData3DTexture)G?(Se&&t.texStorage3D(n.TEXTURE_3D,ke,Ye,Ce.width,Ce.height,Ce.depth),Oe&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ce.width,Ce.height,Ce.depth,qe,Be,Ce.data)):t.texImage3D(n.TEXTURE_3D,0,Ye,Ce.width,Ce.height,Ce.depth,0,qe,Be,Ce.data);else if(P.isFramebufferTexture){if(Se)if(G)t.texStorage2D(n.TEXTURE_2D,ke,Ye,Ce.width,Ce.height);else{let Te=Ce.width,me=Ce.height;for(let Ke=0;Ke<ke;Ke++)t.texImage2D(n.TEXTURE_2D,Ke,Ye,Te,me,0,qe,Be,null),Te>>=1,me>>=1}}else if(ft.length>0){if(G&&Se){const Te=$e(ft[0]);t.texStorage2D(n.TEXTURE_2D,ke,Ye,Te.width,Te.height)}for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,qe,Be,Re):t.texImage2D(n.TEXTURE_2D,Te,Ye,qe,Be,Re);P.generateMipmaps=!1}else if(G){if(Se){const Te=$e(Ce);t.texStorage2D(n.TEXTURE_2D,ke,Ye,Te.width,Te.height)}Oe&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,qe,Be,Ce)}else t.texImage2D(n.TEXTURE_2D,0,Ye,qe,Be,Ce);v(P)&&_(pe),De.__version=fe.version,P.onUpdate&&P.onUpdate(P)}U.__version=P.version}function Z(U,P,te){if(P.image.length!==6)return;const pe=ye(U,P),Me=P.source;t.bindTexture(n.TEXTURE_CUBE_MAP,U.__webglTexture,n.TEXTURE0+te);const fe=r.get(Me);if(Me.version!==fe.__version||pe===!0){t.activeTexture(n.TEXTURE0+te);const De=Ct.getPrimaries(Ct.workingColorSpace),Ae=P.colorSpace===fs?null:Ct.getPrimaries(P.colorSpace),Ge=P.colorSpace===fs||De===Ae?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const We=P.isCompressedTexture||P.image[0].isCompressedTexture,Ce=P.image[0]&&P.image[0].isDataTexture,qe=[];for(let me=0;me<6;me++)!We&&!Ce?qe[me]=x(P.image[me],!0,i.maxCubemapSize):qe[me]=Ce?P.image[me].image:P.image[me],qe[me]=lt(P,qe[me]);const Be=qe[0],Ye=s.convert(P.format,P.colorSpace),Re=s.convert(P.type),ft=E(P.internalFormat,Ye,Re,P.colorSpace),G=P.isVideoTexture!==!0,Se=fe.__version===void 0||pe===!0,Oe=Me.dataReady;let ke=b(P,Be);de(n.TEXTURE_CUBE_MAP,P);let Te;if(We){G&&Se&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ke,ft,Be.width,Be.height);for(let me=0;me<6;me++){Te=qe[me].mipmaps;for(let Ke=0;Ke<Te.length;Ke++){const ut=Te[Ke];P.format!==Qr?Ye!==null?G?Oe&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,0,0,ut.width,ut.height,Ye,ut.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,ft,ut.width,ut.height,0,ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,0,0,ut.width,ut.height,Ye,Re,ut.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,ft,ut.width,ut.height,0,Ye,Re,ut.data)}}}else{if(Te=P.mipmaps,G&&Se){Te.length>0&&ke++;const me=$e(qe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ke,ft,me.width,me.height)}for(let me=0;me<6;me++)if(Ce){G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,0,0,qe[me].width,qe[me].height,Ye,Re,qe[me].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,ft,qe[me].width,qe[me].height,0,Ye,Re,qe[me].data);for(let Ke=0;Ke<Te.length;Ke++){const Ot=Te[Ke].image[me].image;G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,0,0,Ot.width,Ot.height,Ye,Re,Ot.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,ft,Ot.width,Ot.height,0,Ye,Re,Ot.data)}}else{G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,0,0,Ye,Re,qe[me]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,ft,Ye,Re,qe[me]);for(let Ke=0;Ke<Te.length;Ke++){const ut=Te[Ke];G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,0,0,Ye,Re,ut.image[me]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,ft,Ye,Re,ut.image[me])}}}v(P)&&_(n.TEXTURE_CUBE_MAP),fe.__version=Me.version,P.onUpdate&&P.onUpdate(P)}U.__version=P.version}function he(U,P,te,pe,Me,fe){const De=s.convert(te.format,te.colorSpace),Ae=s.convert(te.type),Ge=E(te.internalFormat,De,Ae,te.colorSpace),We=r.get(P),Ce=r.get(te);if(Ce.__renderTarget=P,!We.__hasExternalTextures){const qe=Math.max(1,P.width>>fe),Be=Math.max(1,P.height>>fe);Me===n.TEXTURE_3D||Me===n.TEXTURE_2D_ARRAY?t.texImage3D(Me,fe,Ge,qe,Be,P.depth,0,De,Ae,null):t.texImage2D(Me,fe,Ge,qe,Be,0,De,Ae,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,pe,Me,Ce.__webglTexture,0,Xe(P)):(Me===n.TEXTURE_2D||Me>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,pe,Me,Ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function xe(U,P,te){if(n.bindRenderbuffer(n.RENDERBUFFER,U),P.depthBuffer){const pe=P.depthTexture,Me=pe&&pe.isDepthTexture?pe.type:null,fe=S(P.stencilBuffer,Me),De=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=Xe(P);be(P)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ae,fe,P.width,P.height):te?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ae,fe,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,fe,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,U)}else{const pe=P.textures;for(let Me=0;Me<pe.length;Me++){const fe=pe[Me],De=s.convert(fe.format,fe.colorSpace),Ae=s.convert(fe.type),Ge=E(fe.internalFormat,De,Ae,fe.colorSpace),We=Xe(P);te&&be(P)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,We,Ge,P.width,P.height):be(P)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,We,Ge,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,Ge,P.width,P.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ee(U,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,U),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const pe=r.get(P.depthTexture);pe.__renderTarget=P,(!pe.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),ae(P.depthTexture,0);const Me=pe.__webglTexture,fe=Xe(P);if(P.depthTexture.format===dl)be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Me,0,fe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Me,0);else if(P.depthTexture.format===pl)be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Me,0,fe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Me,0);else throw new Error("Unknown depthTexture format")}function Pe(U){const P=r.get(U),te=U.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==U.depthTexture){const pe=U.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),pe){const Me=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,pe.removeEventListener("dispose",Me)};pe.addEventListener("dispose",Me),P.__depthDisposeCallback=Me}P.__boundDepthTexture=pe}if(U.depthTexture&&!P.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");const pe=U.texture.mipmaps;pe&&pe.length>0?ee(P.__webglFramebuffer[0],U):ee(P.__webglFramebuffer,U)}else if(te){P.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)if(t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[pe]),P.__webglDepthbuffer[pe]===void 0)P.__webglDepthbuffer[pe]=n.createRenderbuffer(),xe(P.__webglDepthbuffer[pe],U,!1);else{const Me=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=P.__webglDepthbuffer[pe];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Me,n.RENDERBUFFER,fe)}}else{const pe=U.texture.mipmaps;if(pe&&pe.length>0?t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=n.createRenderbuffer(),xe(P.__webglDepthbuffer,U,!1);else{const Me=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=P.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Me,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function le(U,P,te){const pe=r.get(U);P!==void 0&&he(pe.__webglFramebuffer,U,U.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),te!==void 0&&Pe(U)}function z(U){const P=U.texture,te=r.get(U),pe=r.get(P);U.addEventListener("dispose",q);const Me=U.textures,fe=U.isWebGLCubeRenderTarget===!0,De=Me.length>1;if(De||(pe.__webglTexture===void 0&&(pe.__webglTexture=n.createTexture()),pe.__version=P.version,o.memory.textures++),fe){te.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(P.mipmaps&&P.mipmaps.length>0){te.__webglFramebuffer[Ae]=[];for(let Ge=0;Ge<P.mipmaps.length;Ge++)te.__webglFramebuffer[Ae][Ge]=n.createFramebuffer()}else te.__webglFramebuffer[Ae]=n.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ae=0;Ae<P.mipmaps.length;Ae++)te.__webglFramebuffer[Ae]=n.createFramebuffer()}else te.__webglFramebuffer=n.createFramebuffer();if(De)for(let Ae=0,Ge=Me.length;Ae<Ge;Ae++){const We=r.get(Me[Ae]);We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture(),o.memory.textures++)}if(U.samples>0&&be(U)===!1){te.__webglMultisampledFramebuffer=n.createFramebuffer(),te.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Ae=0;Ae<Me.length;Ae++){const Ge=Me[Ae];te.__webglColorRenderbuffer[Ae]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,te.__webglColorRenderbuffer[Ae]);const We=s.convert(Ge.format,Ge.colorSpace),Ce=s.convert(Ge.type),qe=E(Ge.internalFormat,We,Ce,Ge.colorSpace,U.isXRRenderTarget===!0),Be=Xe(U);n.renderbufferStorageMultisample(n.RENDERBUFFER,Be,qe,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.RENDERBUFFER,te.__webglColorRenderbuffer[Ae])}n.bindRenderbuffer(n.RENDERBUFFER,null),U.depthBuffer&&(te.__webglDepthRenderbuffer=n.createRenderbuffer(),xe(te.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,pe.__webglTexture),de(n.TEXTURE_CUBE_MAP,P);for(let Ae=0;Ae<6;Ae++)if(P.mipmaps&&P.mipmaps.length>0)for(let Ge=0;Ge<P.mipmaps.length;Ge++)he(te.__webglFramebuffer[Ae][Ge],U,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge);else he(te.__webglFramebuffer[Ae],U,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);v(P)&&_(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(De){for(let Ae=0,Ge=Me.length;Ae<Ge;Ae++){const We=Me[Ae],Ce=r.get(We);let qe=n.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(qe=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(qe,Ce.__webglTexture),de(qe,We),he(te.__webglFramebuffer,U,We,n.COLOR_ATTACHMENT0+Ae,qe,0),v(We)&&_(qe)}t.unbindTexture()}else{let Ae=n.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ae=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ae,pe.__webglTexture),de(Ae,P),P.mipmaps&&P.mipmaps.length>0)for(let Ge=0;Ge<P.mipmaps.length;Ge++)he(te.__webglFramebuffer[Ge],U,P,n.COLOR_ATTACHMENT0,Ae,Ge);else he(te.__webglFramebuffer,U,P,n.COLOR_ATTACHMENT0,Ae,0);v(P)&&_(Ae),t.unbindTexture()}U.depthBuffer&&Pe(U)}function rt(U){const P=U.textures;for(let te=0,pe=P.length;te<pe;te++){const Me=P[te];if(v(Me)){const fe=w(U),De=r.get(Me).__webglTexture;t.bindTexture(fe,De),_(fe),t.unbindTexture()}}}const Le=[],at=[];function ze(U){if(U.samples>0){if(be(U)===!1){const P=U.textures,te=U.width,pe=U.height;let Me=n.COLOR_BUFFER_BIT;const fe=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,De=r.get(U),Ae=P.length>1;if(Ae)for(let We=0;We<P.length;We++)t.bindFramebuffer(n.FRAMEBUFFER,De.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,De.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,De.__webglMultisampledFramebuffer);const Ge=U.texture.mipmaps;Ge&&Ge.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglFramebuffer);for(let We=0;We<P.length;We++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(Me|=n.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(Me|=n.STENCIL_BUFFER_BIT)),Ae){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,De.__webglColorRenderbuffer[We]);const Ce=r.get(P[We]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ce,0)}n.blitFramebuffer(0,0,te,pe,0,0,te,pe,Me,n.NEAREST),l===!0&&(Le.length=0,at.length=0,Le.push(n.COLOR_ATTACHMENT0+We),U.depthBuffer&&U.resolveDepthBuffer===!1&&(Le.push(fe),at.push(fe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,at)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Le))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ae)for(let We=0;We<P.length;We++){t.bindFramebuffer(n.FRAMEBUFFER,De.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.RENDERBUFFER,De.__webglColorRenderbuffer[We]);const Ce=r.get(P[We]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,De.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.TEXTURE_2D,Ce,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const P=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[P])}}}function Xe(U){return Math.min(i.maxSamples,U.samples)}function be(U){const P=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function tt(U){const P=o.render.frame;h.get(U)!==P&&(h.set(U,P),U.update())}function lt(U,P){const te=U.colorSpace,pe=U.format,Me=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||te!==Ho&&te!==fs&&(Ct.getTransfer(te)===Ft?(pe!==Qr||Me!==bi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),P}function $e(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=H,this.setTexture2D=ae,this.setTexture2DArray=J,this.setTexture3D=se,this.setTextureCube=B,this.rebindTextures=le,this.setupRenderTarget=z,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=Pe,this.setupFrameBufferTexture=he,this.useMultisampledRTT=be}function JT(n,e){function t(r,i=fs){let s;const o=Ct.getTransfer(i);if(r===bi)return n.UNSIGNED_BYTE;if(r===bd)return n.UNSIGNED_SHORT_4_4_4_4;if(r===Md)return n.UNSIGNED_SHORT_5_5_5_1;if(r===t_)return n.UNSIGNED_INT_5_9_9_9_REV;if(r===Q1)return n.BYTE;if(r===e_)return n.SHORT;if(r===ul)return n.UNSIGNED_SHORT;if(r===Ed)return n.INT;if(r===Gs)return n.UNSIGNED_INT;if(r===zi)return n.FLOAT;if(r===hl)return n.HALF_FLOAT;if(r===n_)return n.ALPHA;if(r===r_)return n.RGB;if(r===Qr)return n.RGBA;if(r===dl)return n.DEPTH_COMPONENT;if(r===pl)return n.DEPTH_STENCIL;if(r===i_)return n.RED;if(r===wd)return n.RED_INTEGER;if(r===s_)return n.RG;if(r===Td)return n.RG_INTEGER;if(r===Ad)return n.RGBA_INTEGER;if(r===jc||r===Xc||r===$c||r===Yc)if(o===Ft)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===jc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Xc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===$c)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Yc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===jc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Xc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===$c)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Yc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Cd||r===Rd||r===Pd||r===Id)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Cd)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Rd)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Pd)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Id)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Ld||r===Od||r===qd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===Ld||r===Od)return o===Ft?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===qd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Dd||r===Nd||r===Ud||r===Fd||r===zd||r===kd||r===Bd||r===Vd||r===Hd||r===Gd||r===Wd||r===jd||r===Xd||r===$d)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===Dd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Nd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Ud)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Fd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===zd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===kd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Bd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Vd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Hd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Gd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Wd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===jd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Xd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===$d)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Kc||r===Yd||r===Kd)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===Kc)return o===Ft?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Yd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Kd)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===o_||r===Zd||r===Jd||r===Qd)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===Kc)return s.COMPRESSED_RED_RGTC1_EXT;if(r===Zd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Jd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Qd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===fl?n.UNSIGNED_INT_24_8:n[r]!==void 0?n[r]:null}return{convert:t}}class kv extends Dn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}}const QT=`
3885
+ }`;function $T(n,e,t){let r=new Tp;const i=new Ne,s=new Ne,o=new ln,a=new V4({depthPacking:yM}),l=new H4,c={},h=t.maxTextureSize,f={[cs]:er,[er]:cs,[Si]:Si},p=new xs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:jT,fragmentShader:XT}),d=p.clone();d.defines.HORIZONTAL_PASS=1;const m=new nr;m.setAttribute("position",new Dr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Tn(m,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$1;let _=this.type;this.render=function(A,q,O){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||A.length===0)return;const T=n.getRenderTarget(),I=n.getActiveCubeFace(),N=n.getActiveMipmapLevel(),H=n.state;H.setBlending(us),H.buffers.depth.getReversed()?H.buffers.color.setClear(0,0,0,0):H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const W=_!==Fi&&this.type===Fi,Q=_===Fi&&this.type!==Fi;for(let ae=0,J=A.length;ae<J;ae++){const se=A[ae],B=se.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",se,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;i.copy(B.mapSize);const ge=B.getFrameExtents();if(i.multiply(ge),s.copy(B.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/ge.x),i.x=s.x*ge.x,B.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/ge.y),i.y=s.y*ge.y,B.mapSize.y=s.y)),B.map===null||W===!0||Q===!0){const X=this.type!==Fi?{minFilter:Jr,magFilter:Jr}:{};B.map!==null&&B.map.dispose(),B.map=new js(i.x,i.y,X),B.map.texture.name=se.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();const F=B.getViewportCount();for(let X=0;X<F;X++){const de=B.getViewport(X);o.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),H.viewport(o),B.updateMatrices(se,X),r=B.getFrustum(),S(q,O,B.camera,se,this.type)}B.isPointLightShadow!==!0&&this.type===Fi&&w(B,O),B.needsUpdate=!1}_=this.type,v.needsUpdate=!1,n.setRenderTarget(T,I,N)};function w(A,q){const O=e.update(x);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,d.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,d.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new js(i.x,i.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,n.setRenderTarget(A.mapPass),n.clear(),n.renderBufferDirect(q,null,O,p,x,null),d.uniforms.shadow_pass.value=A.mapPass.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,n.setRenderTarget(A.map),n.clear(),n.renderBufferDirect(q,null,O,d,x,null)}function E(A,q,O,T){let I=null;const N=O.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(N!==void 0)I=N;else if(I=O.isPointLight===!0?l:a,n.localClippingEnabled&&q.clipShadows===!0&&Array.isArray(q.clippingPlanes)&&q.clippingPlanes.length!==0||q.displacementMap&&q.displacementScale!==0||q.alphaMap&&q.alphaTest>0||q.map&&q.alphaTest>0||q.alphaToCoverage===!0){const H=I.uuid,W=q.uuid;let Q=c[H];Q===void 0&&(Q={},c[H]=Q);let ae=Q[W];ae===void 0&&(ae=I.clone(),Q[W]=ae,q.addEventListener("dispose",b)),I=ae}if(I.visible=q.visible,I.wireframe=q.wireframe,T===Fi?I.side=q.shadowSide!==null?q.shadowSide:q.side:I.side=q.shadowSide!==null?q.shadowSide:f[q.side],I.alphaMap=q.alphaMap,I.alphaTest=q.alphaToCoverage===!0?.5:q.alphaTest,I.map=q.map,I.clipShadows=q.clipShadows,I.clippingPlanes=q.clippingPlanes,I.clipIntersection=q.clipIntersection,I.displacementMap=q.displacementMap,I.displacementScale=q.displacementScale,I.displacementBias=q.displacementBias,I.wireframeLinewidth=q.wireframeLinewidth,I.linewidth=q.linewidth,O.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const H=n.properties.get(I);H.light=O}return I}function S(A,q,O,T,I){if(A.visible===!1)return;if(A.layers.test(q.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&I===Fi)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,A.matrixWorld);const W=e.update(A),Q=A.material;if(Array.isArray(Q)){const ae=W.groups;for(let J=0,se=ae.length;J<se;J++){const B=ae[J],ge=Q[B.materialIndex];if(ge&&ge.visible){const F=E(A,ge,T,I);A.onBeforeShadow(n,A,q,O,W,F,B),n.renderBufferDirect(O,null,W,F,A,B),A.onAfterShadow(n,A,q,O,W,F,B)}}}else if(Q.visible){const ae=E(A,Q,T,I);A.onBeforeShadow(n,A,q,O,W,ae,null),n.renderBufferDirect(O,null,W,ae,A,null),A.onAfterShadow(n,A,q,O,W,ae,null)}}const H=A.children;for(let W=0,Q=H.length;W<Q;W++)S(H[W],q,O,T,I)}function b(A){A.target.removeEventListener("dispose",b);for(const O in c){const T=c[O],I=A.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}const YT={[ud]:hd,[fd]:md,[dd]:gd,[ko]:pd,[hd]:ud,[md]:fd,[gd]:dd,[pd]:ko};function KT(n,e){function t(){let G=!1;const Se=new ln;let Oe=null;const ke=new ln(0,0,0,0);return{setMask:function(Te){Oe!==Te&&!G&&(n.colorMask(Te,Te,Te,Te),Oe=Te)},setLocked:function(Te){G=Te},setClear:function(Te,me,Ke,ut,Ot){Ot===!0&&(Te*=ut,me*=ut,Ke*=ut),Se.set(Te,me,Ke,ut),ke.equals(Se)===!1&&(n.clearColor(Te,me,Ke,ut),ke.copy(Se))},reset:function(){G=!1,Oe=null,ke.set(-1,0,0,0)}}}function r(){let G=!1,Se=!1,Oe=null,ke=null,Te=null;return{setReversed:function(me){if(Se!==me){const Ke=e.get("EXT_clip_control");me?Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.ZERO_TO_ONE_EXT):Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.NEGATIVE_ONE_TO_ONE_EXT),Se=me;const ut=Te;Te=null,this.setClear(ut)}},getReversed:function(){return Se},setTest:function(me){me?Z(n.DEPTH_TEST):he(n.DEPTH_TEST)},setMask:function(me){Oe!==me&&!G&&(n.depthMask(me),Oe=me)},setFunc:function(me){if(Se&&(me=YT[me]),ke!==me){switch(me){case ud:n.depthFunc(n.NEVER);break;case hd:n.depthFunc(n.ALWAYS);break;case fd:n.depthFunc(n.LESS);break;case ko:n.depthFunc(n.LEQUAL);break;case dd:n.depthFunc(n.EQUAL);break;case pd:n.depthFunc(n.GEQUAL);break;case md:n.depthFunc(n.GREATER);break;case gd:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}ke=me}},setLocked:function(me){G=me},setClear:function(me){Te!==me&&(Se&&(me=1-me),n.clearDepth(me),Te=me)},reset:function(){G=!1,Oe=null,ke=null,Te=null,Se=!1}}}function i(){let G=!1,Se=null,Oe=null,ke=null,Te=null,me=null,Ke=null,ut=null,Ot=null;return{setTest:function(dt){G||(dt?Z(n.STENCIL_TEST):he(n.STENCIL_TEST))},setMask:function(dt){Se!==dt&&!G&&(n.stencilMask(dt),Se=dt)},setFunc:function(dt,ai,sr){(Oe!==dt||ke!==ai||Te!==sr)&&(n.stencilFunc(dt,ai,sr),Oe=dt,ke=ai,Te=sr)},setOp:function(dt,ai,sr){(me!==dt||Ke!==ai||ut!==sr)&&(n.stencilOp(dt,ai,sr),me=dt,Ke=ai,ut=sr)},setLocked:function(dt){G=dt},setClear:function(dt){Ot!==dt&&(n.clearStencil(dt),Ot=dt)},reset:function(){G=!1,Se=null,Oe=null,ke=null,Te=null,me=null,Ke=null,ut=null,Ot=null}}}const s=new t,o=new r,a=new i,l=new WeakMap,c=new WeakMap;let h={},f={},p=new WeakMap,d=[],m=null,x=!1,v=null,_=null,w=null,E=null,S=null,b=null,A=null,q=new Et(0,0,0),O=0,T=!1,I=null,N=null,H=null,W=null,Q=null;const ae=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,se=0;const B=n.getParameter(n.VERSION);B.indexOf("WebGL")!==-1?(se=parseFloat(/^WebGL (\d)/.exec(B)[1]),J=se>=1):B.indexOf("OpenGL ES")!==-1&&(se=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),J=se>=2);let ge=null,F={};const X=n.getParameter(n.SCISSOR_BOX),de=n.getParameter(n.VIEWPORT),ye=new ln().fromArray(X),Ee=new ln().fromArray(de);function V(G,Se,Oe,ke){const Te=new Uint8Array(4),me=n.createTexture();n.bindTexture(G,me),n.texParameteri(G,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(G,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ke=0;Ke<Oe;Ke++)G===n.TEXTURE_3D||G===n.TEXTURE_2D_ARRAY?n.texImage3D(Se,0,n.RGBA,1,1,ke,0,n.RGBA,n.UNSIGNED_BYTE,Te):n.texImage2D(Se+Ke,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Te);return me}const re={};re[n.TEXTURE_2D]=V(n.TEXTURE_2D,n.TEXTURE_2D,1),re[n.TEXTURE_CUBE_MAP]=V(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[n.TEXTURE_2D_ARRAY]=V(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),re[n.TEXTURE_3D]=V(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Z(n.DEPTH_TEST),o.setFunc(ko),at(!1),ze(X1),Z(n.CULL_FACE),rt(us);function Z(G){h[G]!==!0&&(n.enable(G),h[G]=!0)}function he(G){h[G]!==!1&&(n.disable(G),h[G]=!1)}function xe(G,Se){return f[G]!==Se?(n.bindFramebuffer(G,Se),f[G]=Se,G===n.DRAW_FRAMEBUFFER&&(f[n.FRAMEBUFFER]=Se),G===n.FRAMEBUFFER&&(f[n.DRAW_FRAMEBUFFER]=Se),!0):!1}function ee(G,Se){let Oe=d,ke=!1;if(G){Oe=p.get(Se),Oe===void 0&&(Oe=[],p.set(Se,Oe));const Te=G.textures;if(Oe.length!==Te.length||Oe[0]!==n.COLOR_ATTACHMENT0){for(let me=0,Ke=Te.length;me<Ke;me++)Oe[me]=n.COLOR_ATTACHMENT0+me;Oe.length=Te.length,ke=!0}}else Oe[0]!==n.BACK&&(Oe[0]=n.BACK,ke=!0);ke&&n.drawBuffers(Oe)}function Pe(G){return m!==G?(n.useProgram(G),m=G,!0):!1}const le={[Bs]:n.FUNC_ADD,[jb]:n.FUNC_SUBTRACT,[Xb]:n.FUNC_REVERSE_SUBTRACT};le[$b]=n.MIN,le[Yb]=n.MAX;const z={[Kb]:n.ZERO,[Zb]:n.ONE,[Jb]:n.SRC_COLOR,[ld]:n.SRC_ALPHA,[iM]:n.SRC_ALPHA_SATURATE,[nM]:n.DST_COLOR,[eM]:n.DST_ALPHA,[Qb]:n.ONE_MINUS_SRC_COLOR,[cd]:n.ONE_MINUS_SRC_ALPHA,[rM]:n.ONE_MINUS_DST_COLOR,[tM]:n.ONE_MINUS_DST_ALPHA,[sM]:n.CONSTANT_COLOR,[oM]:n.ONE_MINUS_CONSTANT_COLOR,[aM]:n.CONSTANT_ALPHA,[lM]:n.ONE_MINUS_CONSTANT_ALPHA};function rt(G,Se,Oe,ke,Te,me,Ke,ut,Ot,dt){if(G===us){x===!0&&(he(n.BLEND),x=!1);return}if(x===!1&&(Z(n.BLEND),x=!0),G!==Wb){if(G!==v||dt!==T){if((_!==Bs||S!==Bs)&&(n.blendEquation(n.FUNC_ADD),_=Bs,S=Bs),dt)switch(G){case zo:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Y1:n.blendFunc(n.ONE,n.ONE);break;case K1:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Z1:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",G);break}else switch(G){case zo:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Y1:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case K1:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Z1:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",G);break}w=null,E=null,b=null,A=null,q.set(0,0,0),O=0,v=G,T=dt}return}Te=Te||Se,me=me||Oe,Ke=Ke||ke,(Se!==_||Te!==S)&&(n.blendEquationSeparate(le[Se],le[Te]),_=Se,S=Te),(Oe!==w||ke!==E||me!==b||Ke!==A)&&(n.blendFuncSeparate(z[Oe],z[ke],z[me],z[Ke]),w=Oe,E=ke,b=me,A=Ke),(ut.equals(q)===!1||Ot!==O)&&(n.blendColor(ut.r,ut.g,ut.b,Ot),q.copy(ut),O=Ot),v=G,T=!1}function Le(G,Se){G.side===Si?he(n.CULL_FACE):Z(n.CULL_FACE);let Oe=G.side===er;Se&&(Oe=!Oe),at(Oe),G.blending===zo&&G.transparent===!1?rt(us):rt(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),o.setFunc(G.depthFunc),o.setTest(G.depthTest),o.setMask(G.depthWrite),s.setMask(G.colorWrite);const ke=G.stencilWrite;a.setTest(ke),ke&&(a.setMask(G.stencilWriteMask),a.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),a.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass)),be(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?Z(n.SAMPLE_ALPHA_TO_COVERAGE):he(n.SAMPLE_ALPHA_TO_COVERAGE)}function at(G){I!==G&&(G?n.frontFace(n.CW):n.frontFace(n.CCW),I=G)}function ze(G){G!==Vb?(Z(n.CULL_FACE),G!==N&&(G===X1?n.cullFace(n.BACK):G===Hb?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):he(n.CULL_FACE),N=G}function Xe(G){G!==H&&(J&&n.lineWidth(G),H=G)}function be(G,Se,Oe){G?(Z(n.POLYGON_OFFSET_FILL),(W!==Se||Q!==Oe)&&(n.polygonOffset(Se,Oe),W=Se,Q=Oe)):he(n.POLYGON_OFFSET_FILL)}function tt(G){G?Z(n.SCISSOR_TEST):he(n.SCISSOR_TEST)}function lt(G){G===void 0&&(G=n.TEXTURE0+ae-1),ge!==G&&(n.activeTexture(G),ge=G)}function $e(G,Se,Oe){Oe===void 0&&(ge===null?Oe=n.TEXTURE0+ae-1:Oe=ge);let ke=F[Oe];ke===void 0&&(ke={type:void 0,texture:void 0},F[Oe]=ke),(ke.type!==G||ke.texture!==Se)&&(ge!==Oe&&(n.activeTexture(Oe),ge=Oe),n.bindTexture(G,Se||re[G]),ke.type=G,ke.texture=Se)}function U(){const G=F[ge];G!==void 0&&G.type!==void 0&&(n.bindTexture(G.type,null),G.type=void 0,G.texture=void 0)}function P(){try{n.compressedTexImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function te(){try{n.compressedTexImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function pe(){try{n.texSubImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Me(){try{n.texSubImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function fe(){try{n.compressedTexSubImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function De(){try{n.compressedTexSubImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ae(){try{n.texStorage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ge(){try{n.texStorage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function We(){try{n.texImage2D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function Ce(){try{n.texImage3D(...arguments)}catch(G){console.error("THREE.WebGLState:",G)}}function qe(G){ye.equals(G)===!1&&(n.scissor(G.x,G.y,G.z,G.w),ye.copy(G))}function Be(G){Ee.equals(G)===!1&&(n.viewport(G.x,G.y,G.z,G.w),Ee.copy(G))}function Ye(G,Se){let Oe=c.get(Se);Oe===void 0&&(Oe=new WeakMap,c.set(Se,Oe));let ke=Oe.get(G);ke===void 0&&(ke=n.getUniformBlockIndex(Se,G.name),Oe.set(G,ke))}function Re(G,Se){const ke=c.get(Se).get(G);l.get(Se)!==ke&&(n.uniformBlockBinding(Se,ke,G.__bindingPointIndex),l.set(Se,ke))}function ft(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),o.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},ge=null,F={},f={},p=new WeakMap,d=[],m=null,x=!1,v=null,_=null,w=null,E=null,S=null,b=null,A=null,q=new Et(0,0,0),O=0,T=!1,I=null,N=null,H=null,W=null,Q=null,ye.set(0,0,n.canvas.width,n.canvas.height),Ee.set(0,0,n.canvas.width,n.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:Z,disable:he,bindFramebuffer:xe,drawBuffers:ee,useProgram:Pe,setBlending:rt,setMaterial:Le,setFlipSided:at,setCullFace:ze,setLineWidth:Xe,setPolygonOffset:be,setScissorTest:tt,activeTexture:lt,bindTexture:$e,unbindTexture:U,compressedTexImage2D:P,compressedTexImage3D:te,texImage2D:We,texImage3D:Ce,updateUBOMapping:Ye,uniformBlockBinding:Re,texStorage2D:Ae,texStorage3D:Ge,texSubImage2D:pe,texSubImage3D:Me,compressedTexSubImage2D:fe,compressedTexSubImage3D:De,scissor:qe,viewport:Be,reset:ft}}function ZT(n,e,t,r,i,s,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ne,h=new WeakMap;let f;const p=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(U,P){return d?new OffscreenCanvas(U,P):gl("canvas")}function x(U,P,te){let pe=1;const Me=$e(U);if((Me.width>te||Me.height>te)&&(pe=te/Math.max(Me.width,Me.height)),pe<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const fe=Math.floor(pe*Me.width),De=Math.floor(pe*Me.height);f===void 0&&(f=m(fe,De));const Ae=P?m(fe,De):f;return Ae.width=fe,Ae.height=De,Ae.getContext("2d").drawImage(U,0,0,fe,De),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+fe+"x"+De+")."),Ae}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),U;return U}function v(U){return U.generateMipmaps}function _(U){n.generateMipmap(U)}function w(U){return U.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?n.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function E(U,P,te,pe,Me=!1){if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let fe=P;if(P===n.RED&&(te===n.FLOAT&&(fe=n.R32F),te===n.HALF_FLOAT&&(fe=n.R16F),te===n.UNSIGNED_BYTE&&(fe=n.R8)),P===n.RED_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.R8UI),te===n.UNSIGNED_SHORT&&(fe=n.R16UI),te===n.UNSIGNED_INT&&(fe=n.R32UI),te===n.BYTE&&(fe=n.R8I),te===n.SHORT&&(fe=n.R16I),te===n.INT&&(fe=n.R32I)),P===n.RG&&(te===n.FLOAT&&(fe=n.RG32F),te===n.HALF_FLOAT&&(fe=n.RG16F),te===n.UNSIGNED_BYTE&&(fe=n.RG8)),P===n.RG_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RG8UI),te===n.UNSIGNED_SHORT&&(fe=n.RG16UI),te===n.UNSIGNED_INT&&(fe=n.RG32UI),te===n.BYTE&&(fe=n.RG8I),te===n.SHORT&&(fe=n.RG16I),te===n.INT&&(fe=n.RG32I)),P===n.RGB_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RGB8UI),te===n.UNSIGNED_SHORT&&(fe=n.RGB16UI),te===n.UNSIGNED_INT&&(fe=n.RGB32UI),te===n.BYTE&&(fe=n.RGB8I),te===n.SHORT&&(fe=n.RGB16I),te===n.INT&&(fe=n.RGB32I)),P===n.RGBA_INTEGER&&(te===n.UNSIGNED_BYTE&&(fe=n.RGBA8UI),te===n.UNSIGNED_SHORT&&(fe=n.RGBA16UI),te===n.UNSIGNED_INT&&(fe=n.RGBA32UI),te===n.BYTE&&(fe=n.RGBA8I),te===n.SHORT&&(fe=n.RGBA16I),te===n.INT&&(fe=n.RGBA32I)),P===n.RGB&&te===n.UNSIGNED_INT_5_9_9_9_REV&&(fe=n.RGB9_E5),P===n.RGBA){const De=Me?Zc:Ct.getTransfer(pe);te===n.FLOAT&&(fe=n.RGBA32F),te===n.HALF_FLOAT&&(fe=n.RGBA16F),te===n.UNSIGNED_BYTE&&(fe=De===Ft?n.SRGB8_ALPHA8:n.RGBA8),te===n.UNSIGNED_SHORT_4_4_4_4&&(fe=n.RGBA4),te===n.UNSIGNED_SHORT_5_5_5_1&&(fe=n.RGB5_A1)}return(fe===n.R16F||fe===n.R32F||fe===n.RG16F||fe===n.RG32F||fe===n.RGBA16F||fe===n.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function S(U,P){let te;return U?P===null||P===Gs||P===fl?te=n.DEPTH24_STENCIL8:P===zi?te=n.DEPTH32F_STENCIL8:P===ul&&(te=n.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===Gs||P===fl?te=n.DEPTH_COMPONENT24:P===zi?te=n.DEPTH_COMPONENT32F:P===ul&&(te=n.DEPTH_COMPONENT16),te}function b(U,P){return v(U)===!0||U.isFramebufferTexture&&U.minFilter!==Jr&&U.minFilter!==Ei?Math.log2(Math.max(P.width,P.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?P.mipmaps.length:1}function A(U){const P=U.target;P.removeEventListener("dispose",A),O(P),P.isVideoTexture&&h.delete(P)}function q(U){const P=U.target;P.removeEventListener("dispose",q),I(P)}function O(U){const P=r.get(U);if(P.__webglInit===void 0)return;const te=U.source,pe=p.get(te);if(pe){const Me=pe[P.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&T(U),Object.keys(pe).length===0&&p.delete(te)}r.remove(U)}function T(U){const P=r.get(U);n.deleteTexture(P.__webglTexture);const te=U.source,pe=p.get(te);delete pe[P.__cacheKey],o.memory.textures--}function I(U){const P=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(P.__webglFramebuffer[pe]))for(let Me=0;Me<P.__webglFramebuffer[pe].length;Me++)n.deleteFramebuffer(P.__webglFramebuffer[pe][Me]);else n.deleteFramebuffer(P.__webglFramebuffer[pe]);P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer[pe])}else{if(Array.isArray(P.__webglFramebuffer))for(let pe=0;pe<P.__webglFramebuffer.length;pe++)n.deleteFramebuffer(P.__webglFramebuffer[pe]);else n.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&n.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let pe=0;pe<P.__webglColorRenderbuffer.length;pe++)P.__webglColorRenderbuffer[pe]&&n.deleteRenderbuffer(P.__webglColorRenderbuffer[pe]);P.__webglDepthRenderbuffer&&n.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const te=U.textures;for(let pe=0,Me=te.length;pe<Me;pe++){const fe=r.get(te[pe]);fe.__webglTexture&&(n.deleteTexture(fe.__webglTexture),o.memory.textures--),r.remove(te[pe])}r.remove(U)}let N=0;function H(){N=0}function W(){const U=N;return U>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),N+=1,U}function Q(U){const P=[];return P.push(U.wrapS),P.push(U.wrapT),P.push(U.wrapR||0),P.push(U.magFilter),P.push(U.minFilter),P.push(U.anisotropy),P.push(U.internalFormat),P.push(U.format),P.push(U.type),P.push(U.generateMipmaps),P.push(U.premultiplyAlpha),P.push(U.flipY),P.push(U.unpackAlignment),P.push(U.colorSpace),P.join()}function ae(U,P){const te=r.get(U);if(U.isVideoTexture&&tt(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&te.__version!==U.version){const pe=U.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(te,U,P);return}}else U.isExternalTexture&&(te.__webglTexture=U.sourceTexture?U.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,te.__webglTexture,n.TEXTURE0+P)}function J(U,P){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){re(te,U,P);return}t.bindTexture(n.TEXTURE_2D_ARRAY,te.__webglTexture,n.TEXTURE0+P)}function se(U,P){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){re(te,U,P);return}t.bindTexture(n.TEXTURE_3D,te.__webglTexture,n.TEXTURE0+P)}function B(U,P){const te=r.get(U);if(U.version>0&&te.__version!==U.version){Z(te,U,P);return}t.bindTexture(n.TEXTURE_CUBE_MAP,te.__webglTexture,n.TEXTURE0+P)}const ge={[Zr]:n.REPEAT,[Vs]:n.CLAMP_TO_EDGE,[yd]:n.MIRRORED_REPEAT},F={[Jr]:n.NEAREST,[vM]:n.NEAREST_MIPMAP_NEAREST,[Wc]:n.NEAREST_MIPMAP_LINEAR,[Ei]:n.LINEAR,[Sd]:n.LINEAR_MIPMAP_NEAREST,[Hs]:n.LINEAR_MIPMAP_LINEAR},X={[EM]:n.NEVER,[CM]:n.ALWAYS,[bM]:n.LESS,[l_]:n.LEQUAL,[MM]:n.EQUAL,[AM]:n.GEQUAL,[wM]:n.GREATER,[TM]:n.NOTEQUAL};function de(U,P){if(P.type===zi&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Ei||P.magFilter===Sd||P.magFilter===Wc||P.magFilter===Hs||P.minFilter===Ei||P.minFilter===Sd||P.minFilter===Wc||P.minFilter===Hs)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(U,n.TEXTURE_WRAP_S,ge[P.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,ge[P.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,ge[P.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,F[P.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,F[P.minFilter]),P.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,X[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===Jr||P.minFilter!==Wc&&P.minFilter!==Hs||P.type===zi&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||r.get(P).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");n.texParameterf(U,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,i.getMaxAnisotropy())),r.get(P).__currentAnisotropy=P.anisotropy}}}function ye(U,P){let te=!1;U.__webglInit===void 0&&(U.__webglInit=!0,P.addEventListener("dispose",A));const pe=P.source;let Me=p.get(pe);Me===void 0&&(Me={},p.set(pe,Me));const fe=Q(P);if(fe!==U.__cacheKey){Me[fe]===void 0&&(Me[fe]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,te=!0),Me[fe].usedTimes++;const De=Me[U.__cacheKey];De!==void 0&&(Me[U.__cacheKey].usedTimes--,De.usedTimes===0&&T(P)),U.__cacheKey=fe,U.__webglTexture=Me[fe].texture}return te}function Ee(U,P,te){return Math.floor(Math.floor(U/te)/P)}function V(U,P,te,pe){const fe=U.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,P.width,P.height,te,pe,P.data);else{fe.sort((Ce,qe)=>Ce.start-qe.start);let De=0;for(let Ce=1;Ce<fe.length;Ce++){const qe=fe[De],Be=fe[Ce],Ye=qe.start+qe.count,Re=Ee(Be.start,P.width,4),ft=Ee(qe.start,P.width,4);Be.start<=Ye+1&&Re===ft&&Ee(Be.start+Be.count-1,P.width,4)===Re?qe.count=Math.max(qe.count,Be.start+Be.count-qe.start):(++De,fe[De]=Be)}fe.length=De+1;const Ae=n.getParameter(n.UNPACK_ROW_LENGTH),Ge=n.getParameter(n.UNPACK_SKIP_PIXELS),We=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,P.width);for(let Ce=0,qe=fe.length;Ce<qe;Ce++){const Be=fe[Ce],Ye=Math.floor(Be.start/4),Re=Math.ceil(Be.count/4),ft=Ye%P.width,G=Math.floor(Ye/P.width),Se=Re,Oe=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,ft),n.pixelStorei(n.UNPACK_SKIP_ROWS,G),t.texSubImage2D(n.TEXTURE_2D,0,ft,G,Se,Oe,te,pe,P.data)}U.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,Ae),n.pixelStorei(n.UNPACK_SKIP_PIXELS,Ge),n.pixelStorei(n.UNPACK_SKIP_ROWS,We)}}function re(U,P,te){let pe=n.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(pe=n.TEXTURE_2D_ARRAY),P.isData3DTexture&&(pe=n.TEXTURE_3D);const Me=ye(U,P),fe=P.source;t.bindTexture(pe,U.__webglTexture,n.TEXTURE0+te);const De=r.get(fe);if(fe.version!==De.__version||Me===!0){t.activeTexture(n.TEXTURE0+te);const Ae=Ct.getPrimaries(Ct.workingColorSpace),Ge=P.colorSpace===fs?null:Ct.getPrimaries(P.colorSpace),We=P.colorSpace===fs||Ae===Ge?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);let Ce=x(P.image,!1,i.maxTextureSize);Ce=lt(P,Ce);const qe=s.convert(P.format,P.colorSpace),Be=s.convert(P.type);let Ye=E(P.internalFormat,qe,Be,P.colorSpace,P.isVideoTexture);de(pe,P);let Re;const ft=P.mipmaps,G=P.isVideoTexture!==!0,Se=De.__version===void 0||Me===!0,Oe=fe.dataReady,ke=b(P,Ce);if(P.isDepthTexture)Ye=S(P.format===pl,P.type),Se&&(G?t.texStorage2D(n.TEXTURE_2D,1,Ye,Ce.width,Ce.height):t.texImage2D(n.TEXTURE_2D,0,Ye,Ce.width,Ce.height,0,qe,Be,null));else if(P.isDataTexture)if(ft.length>0){G&&Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,ft[0].width,ft[0].height);for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Be,Re.data):t.texImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,qe,Be,Re.data);P.generateMipmaps=!1}else G?(Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,Ce.width,Ce.height),Oe&&V(P,Ce,qe,Be)):t.texImage2D(n.TEXTURE_2D,0,Ye,Ce.width,Ce.height,0,qe,Be,Ce.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){G&&Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ke,Ye,ft[0].width,ft[0].height,Ce.depth);for(let Te=0,me=ft.length;Te<me;Te++)if(Re=ft[Te],P.format!==Qr)if(qe!==null)if(G){if(Oe)if(P.layerUpdates.size>0){const Ke=uv(Re.width,Re.height,P.format,P.type);for(const ut of P.layerUpdates){const Ot=Re.data.subarray(ut*Ke/Re.data.BYTES_PER_ELEMENT,(ut+1)*Ke/Re.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,ut,Re.width,Re.height,1,qe,Ot)}P.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,0,Re.width,Re.height,Ce.depth,qe,Re.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Te,Ye,Re.width,Re.height,Ce.depth,0,Re.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else G?Oe&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Te,0,0,0,Re.width,Re.height,Ce.depth,qe,Be,Re.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Te,Ye,Re.width,Re.height,Ce.depth,0,qe,Be,Re.data)}else{G&&Se&&t.texStorage2D(n.TEXTURE_2D,ke,Ye,ft[0].width,ft[0].height);for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],P.format!==Qr?qe!==null?G?Oe&&t.compressedTexSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Re.data):t.compressedTexImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,Re.width,Re.height,qe,Be,Re.data):t.texImage2D(n.TEXTURE_2D,Te,Ye,Re.width,Re.height,0,qe,Be,Re.data)}else if(P.isDataArrayTexture)if(G){if(Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ke,Ye,Ce.width,Ce.height,Ce.depth),Oe)if(P.layerUpdates.size>0){const Te=uv(Ce.width,Ce.height,P.format,P.type);for(const me of P.layerUpdates){const Ke=Ce.data.subarray(me*Te/Ce.data.BYTES_PER_ELEMENT,(me+1)*Te/Ce.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,me,Ce.width,Ce.height,1,qe,Be,Ke)}P.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ce.width,Ce.height,Ce.depth,qe,Be,Ce.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ye,Ce.width,Ce.height,Ce.depth,0,qe,Be,Ce.data);else if(P.isData3DTexture)G?(Se&&t.texStorage3D(n.TEXTURE_3D,ke,Ye,Ce.width,Ce.height,Ce.depth),Oe&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ce.width,Ce.height,Ce.depth,qe,Be,Ce.data)):t.texImage3D(n.TEXTURE_3D,0,Ye,Ce.width,Ce.height,Ce.depth,0,qe,Be,Ce.data);else if(P.isFramebufferTexture){if(Se)if(G)t.texStorage2D(n.TEXTURE_2D,ke,Ye,Ce.width,Ce.height);else{let Te=Ce.width,me=Ce.height;for(let Ke=0;Ke<ke;Ke++)t.texImage2D(n.TEXTURE_2D,Ke,Ye,Te,me,0,qe,Be,null),Te>>=1,me>>=1}}else if(ft.length>0){if(G&&Se){const Te=$e(ft[0]);t.texStorage2D(n.TEXTURE_2D,ke,Ye,Te.width,Te.height)}for(let Te=0,me=ft.length;Te<me;Te++)Re=ft[Te],G?Oe&&t.texSubImage2D(n.TEXTURE_2D,Te,0,0,qe,Be,Re):t.texImage2D(n.TEXTURE_2D,Te,Ye,qe,Be,Re);P.generateMipmaps=!1}else if(G){if(Se){const Te=$e(Ce);t.texStorage2D(n.TEXTURE_2D,ke,Ye,Te.width,Te.height)}Oe&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,qe,Be,Ce)}else t.texImage2D(n.TEXTURE_2D,0,Ye,qe,Be,Ce);v(P)&&_(pe),De.__version=fe.version,P.onUpdate&&P.onUpdate(P)}U.__version=P.version}function Z(U,P,te){if(P.image.length!==6)return;const pe=ye(U,P),Me=P.source;t.bindTexture(n.TEXTURE_CUBE_MAP,U.__webglTexture,n.TEXTURE0+te);const fe=r.get(Me);if(Me.version!==fe.__version||pe===!0){t.activeTexture(n.TEXTURE0+te);const De=Ct.getPrimaries(Ct.workingColorSpace),Ae=P.colorSpace===fs?null:Ct.getPrimaries(P.colorSpace),Ge=P.colorSpace===fs||De===Ae?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const We=P.isCompressedTexture||P.image[0].isCompressedTexture,Ce=P.image[0]&&P.image[0].isDataTexture,qe=[];for(let me=0;me<6;me++)!We&&!Ce?qe[me]=x(P.image[me],!0,i.maxCubemapSize):qe[me]=Ce?P.image[me].image:P.image[me],qe[me]=lt(P,qe[me]);const Be=qe[0],Ye=s.convert(P.format,P.colorSpace),Re=s.convert(P.type),ft=E(P.internalFormat,Ye,Re,P.colorSpace),G=P.isVideoTexture!==!0,Se=fe.__version===void 0||pe===!0,Oe=Me.dataReady;let ke=b(P,Be);de(n.TEXTURE_CUBE_MAP,P);let Te;if(We){G&&Se&&t.texStorage2D(n.TEXTURE_CUBE_MAP,ke,ft,Be.width,Be.height);for(let me=0;me<6;me++){Te=qe[me].mipmaps;for(let Ke=0;Ke<Te.length;Ke++){const ut=Te[Ke];P.format!==Qr?Ye!==null?G?Oe&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,0,0,ut.width,ut.height,Ye,ut.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,ft,ut.width,ut.height,0,ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,0,0,ut.width,ut.height,Ye,Re,ut.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke,ft,ut.width,ut.height,0,Ye,Re,ut.data)}}}else{if(Te=P.mipmaps,G&&Se){Te.length>0&&ke++;const me=$e(qe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ke,ft,me.width,me.height)}for(let me=0;me<6;me++)if(Ce){G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,0,0,qe[me].width,qe[me].height,Ye,Re,qe[me].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,ft,qe[me].width,qe[me].height,0,Ye,Re,qe[me].data);for(let Ke=0;Ke<Te.length;Ke++){const Ot=Te[Ke].image[me].image;G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,0,0,Ot.width,Ot.height,Ye,Re,Ot.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,ft,Ot.width,Ot.height,0,Ye,Re,Ot.data)}}else{G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,0,0,Ye,Re,qe[me]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,ft,Ye,Re,qe[me]);for(let Ke=0;Ke<Te.length;Ke++){const ut=Te[Ke];G?Oe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,0,0,Ye,Re,ut.image[me]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+me,Ke+1,ft,Ye,Re,ut.image[me])}}}v(P)&&_(n.TEXTURE_CUBE_MAP),fe.__version=Me.version,P.onUpdate&&P.onUpdate(P)}U.__version=P.version}function he(U,P,te,pe,Me,fe){const De=s.convert(te.format,te.colorSpace),Ae=s.convert(te.type),Ge=E(te.internalFormat,De,Ae,te.colorSpace),We=r.get(P),Ce=r.get(te);if(Ce.__renderTarget=P,!We.__hasExternalTextures){const qe=Math.max(1,P.width>>fe),Be=Math.max(1,P.height>>fe);Me===n.TEXTURE_3D||Me===n.TEXTURE_2D_ARRAY?t.texImage3D(Me,fe,Ge,qe,Be,P.depth,0,De,Ae,null):t.texImage2D(Me,fe,Ge,qe,Be,0,De,Ae,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,pe,Me,Ce.__webglTexture,0,Xe(P)):(Me===n.TEXTURE_2D||Me>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,pe,Me,Ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function xe(U,P,te){if(n.bindRenderbuffer(n.RENDERBUFFER,U),P.depthBuffer){const pe=P.depthTexture,Me=pe&&pe.isDepthTexture?pe.type:null,fe=S(P.stencilBuffer,Me),De=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=Xe(P);be(P)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ae,fe,P.width,P.height):te?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ae,fe,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,fe,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,U)}else{const pe=P.textures;for(let Me=0;Me<pe.length;Me++){const fe=pe[Me],De=s.convert(fe.format,fe.colorSpace),Ae=s.convert(fe.type),Ge=E(fe.internalFormat,De,Ae,fe.colorSpace),We=Xe(P);te&&be(P)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,We,Ge,P.width,P.height):be(P)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,We,Ge,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,Ge,P.width,P.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function ee(U,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,U),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const pe=r.get(P.depthTexture);pe.__renderTarget=P,(!pe.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),ae(P.depthTexture,0);const Me=pe.__webglTexture,fe=Xe(P);if(P.depthTexture.format===dl)be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Me,0,fe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Me,0);else if(P.depthTexture.format===pl)be(P)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Me,0,fe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Me,0);else throw new Error("Unknown depthTexture format")}function Pe(U){const P=r.get(U),te=U.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==U.depthTexture){const pe=U.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),pe){const Me=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,pe.removeEventListener("dispose",Me)};pe.addEventListener("dispose",Me),P.__depthDisposeCallback=Me}P.__boundDepthTexture=pe}if(U.depthTexture&&!P.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");const pe=U.texture.mipmaps;pe&&pe.length>0?ee(P.__webglFramebuffer[0],U):ee(P.__webglFramebuffer,U)}else if(te){P.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)if(t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[pe]),P.__webglDepthbuffer[pe]===void 0)P.__webglDepthbuffer[pe]=n.createRenderbuffer(),xe(P.__webglDepthbuffer[pe],U,!1);else{const Me=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=P.__webglDepthbuffer[pe];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Me,n.RENDERBUFFER,fe)}}else{const pe=U.texture.mipmaps;if(pe&&pe.length>0?t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=n.createRenderbuffer(),xe(P.__webglDepthbuffer,U,!1);else{const Me=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=P.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,Me,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function le(U,P,te){const pe=r.get(U);P!==void 0&&he(pe.__webglFramebuffer,U,U.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),te!==void 0&&Pe(U)}function z(U){const P=U.texture,te=r.get(U),pe=r.get(P);U.addEventListener("dispose",q);const Me=U.textures,fe=U.isWebGLCubeRenderTarget===!0,De=Me.length>1;if(De||(pe.__webglTexture===void 0&&(pe.__webglTexture=n.createTexture()),pe.__version=P.version,o.memory.textures++),fe){te.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(P.mipmaps&&P.mipmaps.length>0){te.__webglFramebuffer[Ae]=[];for(let Ge=0;Ge<P.mipmaps.length;Ge++)te.__webglFramebuffer[Ae][Ge]=n.createFramebuffer()}else te.__webglFramebuffer[Ae]=n.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ae=0;Ae<P.mipmaps.length;Ae++)te.__webglFramebuffer[Ae]=n.createFramebuffer()}else te.__webglFramebuffer=n.createFramebuffer();if(De)for(let Ae=0,Ge=Me.length;Ae<Ge;Ae++){const We=r.get(Me[Ae]);We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture(),o.memory.textures++)}if(U.samples>0&&be(U)===!1){te.__webglMultisampledFramebuffer=n.createFramebuffer(),te.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Ae=0;Ae<Me.length;Ae++){const Ge=Me[Ae];te.__webglColorRenderbuffer[Ae]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,te.__webglColorRenderbuffer[Ae]);const We=s.convert(Ge.format,Ge.colorSpace),Ce=s.convert(Ge.type),qe=E(Ge.internalFormat,We,Ce,Ge.colorSpace,U.isXRRenderTarget===!0),Be=Xe(U);n.renderbufferStorageMultisample(n.RENDERBUFFER,Be,qe,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ae,n.RENDERBUFFER,te.__webglColorRenderbuffer[Ae])}n.bindRenderbuffer(n.RENDERBUFFER,null),U.depthBuffer&&(te.__webglDepthRenderbuffer=n.createRenderbuffer(),xe(te.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,pe.__webglTexture),de(n.TEXTURE_CUBE_MAP,P);for(let Ae=0;Ae<6;Ae++)if(P.mipmaps&&P.mipmaps.length>0)for(let Ge=0;Ge<P.mipmaps.length;Ge++)he(te.__webglFramebuffer[Ae][Ge],U,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Ge);else he(te.__webglFramebuffer[Ae],U,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);v(P)&&_(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(De){for(let Ae=0,Ge=Me.length;Ae<Ge;Ae++){const We=Me[Ae],Ce=r.get(We);let qe=n.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(qe=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(qe,Ce.__webglTexture),de(qe,We),he(te.__webglFramebuffer,U,We,n.COLOR_ATTACHMENT0+Ae,qe,0),v(We)&&_(qe)}t.unbindTexture()}else{let Ae=n.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ae=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ae,pe.__webglTexture),de(Ae,P),P.mipmaps&&P.mipmaps.length>0)for(let Ge=0;Ge<P.mipmaps.length;Ge++)he(te.__webglFramebuffer[Ge],U,P,n.COLOR_ATTACHMENT0,Ae,Ge);else he(te.__webglFramebuffer,U,P,n.COLOR_ATTACHMENT0,Ae,0);v(P)&&_(Ae),t.unbindTexture()}U.depthBuffer&&Pe(U)}function rt(U){const P=U.textures;for(let te=0,pe=P.length;te<pe;te++){const Me=P[te];if(v(Me)){const fe=w(U),De=r.get(Me).__webglTexture;t.bindTexture(fe,De),_(fe),t.unbindTexture()}}}const Le=[],at=[];function ze(U){if(U.samples>0){if(be(U)===!1){const P=U.textures,te=U.width,pe=U.height;let Me=n.COLOR_BUFFER_BIT;const fe=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,De=r.get(U),Ae=P.length>1;if(Ae)for(let We=0;We<P.length;We++)t.bindFramebuffer(n.FRAMEBUFFER,De.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,De.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,De.__webglMultisampledFramebuffer);const Ge=U.texture.mipmaps;Ge&&Ge.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglFramebuffer);for(let We=0;We<P.length;We++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(Me|=n.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(Me|=n.STENCIL_BUFFER_BIT)),Ae){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,De.__webglColorRenderbuffer[We]);const Ce=r.get(P[We]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ce,0)}n.blitFramebuffer(0,0,te,pe,0,0,te,pe,Me,n.NEAREST),l===!0&&(Le.length=0,at.length=0,Le.push(n.COLOR_ATTACHMENT0+We),U.depthBuffer&&U.resolveDepthBuffer===!1&&(Le.push(fe),at.push(fe),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,at)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Le))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ae)for(let We=0;We<P.length;We++){t.bindFramebuffer(n.FRAMEBUFFER,De.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.RENDERBUFFER,De.__webglColorRenderbuffer[We]);const Ce=r.get(P[We]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,De.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+We,n.TEXTURE_2D,Ce,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,De.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const P=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[P])}}}function Xe(U){return Math.min(i.maxSamples,U.samples)}function be(U){const P=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function tt(U){const P=o.render.frame;h.get(U)!==P&&(h.set(U,P),U.update())}function lt(U,P){const te=U.colorSpace,pe=U.format,Me=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||te!==Ho&&te!==fs&&(Ct.getTransfer(te)===Ft?(pe!==Qr||Me!==bi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),P}function $e(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=H,this.setTexture2D=ae,this.setTexture2DArray=J,this.setTexture3D=se,this.setTextureCube=B,this.rebindTextures=le,this.setupRenderTarget=z,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=Pe,this.setupFrameBufferTexture=he,this.useMultisampledRTT=be}function JT(n,e){function t(r,i=fs){let s;const o=Ct.getTransfer(i);if(r===bi)return n.UNSIGNED_BYTE;if(r===bd)return n.UNSIGNED_SHORT_4_4_4_4;if(r===Md)return n.UNSIGNED_SHORT_5_5_5_1;if(r===t_)return n.UNSIGNED_INT_5_9_9_9_REV;if(r===Q1)return n.BYTE;if(r===e_)return n.SHORT;if(r===ul)return n.UNSIGNED_SHORT;if(r===Ed)return n.INT;if(r===Gs)return n.UNSIGNED_INT;if(r===zi)return n.FLOAT;if(r===hl)return n.HALF_FLOAT;if(r===n_)return n.ALPHA;if(r===r_)return n.RGB;if(r===Qr)return n.RGBA;if(r===dl)return n.DEPTH_COMPONENT;if(r===pl)return n.DEPTH_STENCIL;if(r===i_)return n.RED;if(r===wd)return n.RED_INTEGER;if(r===s_)return n.RG;if(r===Td)return n.RG_INTEGER;if(r===Ad)return n.RGBA_INTEGER;if(r===jc||r===Xc||r===$c||r===Yc)if(o===Ft)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===jc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Xc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===$c)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Yc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===jc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Xc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===$c)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Yc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Cd||r===Rd||r===Pd||r===Id)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Cd)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Rd)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Pd)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Id)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Ld||r===Od||r===qd)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===Ld||r===Od)return o===Ft?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===qd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Dd||r===Nd||r===Ud||r===Fd||r===zd||r===kd||r===Bd||r===Vd||r===Hd||r===Gd||r===Wd||r===jd||r===Xd||r===$d)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===Dd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Nd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Ud)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Fd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===zd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===kd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Bd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Vd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Hd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Gd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Wd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===jd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Xd)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===$d)return o===Ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Kc||r===Yd||r===Kd)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===Kc)return o===Ft?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Yd)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Kd)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===o_||r===Zd||r===Jd||r===Qd)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===Kc)return s.COMPRESSED_RED_RGTC1_EXT;if(r===Zd)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Jd)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Qd)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===fl?n.UNSIGNED_INT_24_8:n[r]!==void 0?n[r]:null}return{convert:t}}class kv extends Dn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}}const QT=`
3886
3886
  void main() {
3887
3887
 
3888
3888
  gl_Position = vec4( position, 1.0 );
@@ -3906,7 +3906,7 @@ void main() {
3906
3906
 
3907
3907
  }
3908
3908
 
3909
- }`;class t8{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const r=new kv(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,r=new xs({vertexShader:QT,fragmentShader:e8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Tn(new Pu(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class n8 extends Ws{constructor(e,t){super();const r=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,h=null,f=null,p=null,d=null,m=null;const x=new t8,v={},_=t.getContextAttributes();let w=null,E=null;const S=[],b=[],A=new Ne;let q=null;const O=new vr;O.viewport=new ln;const T=new vr;T.viewport=new ln;const I=[O,T],N=new Q4;let H=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getTargetRaySpace()},this.getControllerGrip=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getGripSpace()},this.getHand=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getHandSpace()};function Q(V){const re=b.indexOf(V.inputSource);if(re===-1)return;const Z=S[re];Z!==void 0&&(Z.update(V.inputSource,V.frame,c||o),Z.dispatchEvent({type:V.type,data:V.inputSource}))}function ae(){i.removeEventListener("select",Q),i.removeEventListener("selectstart",Q),i.removeEventListener("selectend",Q),i.removeEventListener("squeeze",Q),i.removeEventListener("squeezestart",Q),i.removeEventListener("squeezeend",Q),i.removeEventListener("end",ae),i.removeEventListener("inputsourceschange",J);for(let V=0;V<S.length;V++){const re=b[V];re!==null&&(b[V]=null,S[V].disconnect(re))}H=null,W=null,x.reset();for(const V in v)delete v[V];e.setRenderTarget(w),d=null,p=null,f=null,i=null,E=null,Ee.stop(),r.isPresenting=!1,e.setPixelRatio(q),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(V){s=V,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(V){a=V,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(V){c=V},this.getBaseLayer=function(){return p!==null?p:d},this.getBinding=function(){return f},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(V){if(i=V,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",Q),i.addEventListener("selectstart",Q),i.addEventListener("selectend",Q),i.addEventListener("squeeze",Q),i.addEventListener("squeezestart",Q),i.addEventListener("squeezeend",Q),i.addEventListener("end",ae),i.addEventListener("inputsourceschange",J),_.xrCompatible!==!0&&await t.makeXRCompatible(),q=e.getPixelRatio(),e.getSize(A),typeof XRWebGLBinding<"u"&&(f=new XRWebGLBinding(i,t)),f!==null&&"createProjectionLayer"in XRWebGLBinding.prototype){let Z=null,he=null,xe=null;_.depth&&(xe=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=_.stencil?pl:dl,he=_.stencil?fl:Gs);const ee={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:s};p=f.createProjectionLayer(ee),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),E=new js(p.textureWidth,p.textureHeight,{format:Qr,type:bi,depthTexture:new B_(p.textureWidth,p.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Z={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,Z),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),E=new js(d.framebufferWidth,d.framebufferHeight,{format:Qr,type:bi,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),Ee.setContext(i),Ee.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function J(V){for(let re=0;re<V.removed.length;re++){const Z=V.removed[re],he=b.indexOf(Z);he>=0&&(b[he]=null,S[he].disconnect(Z))}for(let re=0;re<V.added.length;re++){const Z=V.added[re];let he=b.indexOf(Z);if(he===-1){for(let ee=0;ee<S.length;ee++)if(ee>=b.length){b.push(Z),he=ee;break}else if(b[ee]===null){b[ee]=Z,he=ee;break}if(he===-1)break}const xe=S[he];xe&&xe.connect(Z)}}const se=new j,B=new j;function ge(V,re,Z){se.setFromMatrixPosition(re.matrixWorld),B.setFromMatrixPosition(Z.matrixWorld);const he=se.distanceTo(B),xe=re.projectionMatrix.elements,ee=Z.projectionMatrix.elements,Pe=xe[14]/(xe[10]-1),le=xe[14]/(xe[10]+1),z=(xe[9]+1)/xe[5],rt=(xe[9]-1)/xe[5],Le=(xe[8]-1)/xe[0],at=(ee[8]+1)/ee[0],ze=Pe*Le,Xe=Pe*at,be=he/(-Le+at),tt=be*-Le;if(re.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(tt),V.translateZ(be),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert(),xe[10]===-1)V.projectionMatrix.copy(re.projectionMatrix),V.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const lt=Pe+be,$e=le+be,U=ze-tt,P=Xe+(he-tt),te=z*le/$e*lt,pe=rt*le/$e*lt;V.projectionMatrix.makePerspective(U,P,te,pe,lt,$e),V.projectionMatrixInverse.copy(V.projectionMatrix).invert()}}function F(V,re){re===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(re.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(i===null)return;let re=V.near,Z=V.far;x.texture!==null&&(x.depthNear>0&&(re=x.depthNear),x.depthFar>0&&(Z=x.depthFar)),N.near=T.near=O.near=re,N.far=T.far=O.far=Z,(H!==N.near||W!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),H=N.near,W=N.far),N.layers.mask=V.layers.mask|6,O.layers.mask=N.layers.mask&3,T.layers.mask=N.layers.mask&5;const he=V.parent,xe=N.cameras;F(N,he);for(let ee=0;ee<xe.length;ee++)F(xe[ee],he);xe.length===2?ge(N,O,T):N.projectionMatrix.copy(O.projectionMatrix),X(V,N,he)};function X(V,re,Z){Z===null?V.matrix.copy(re.matrixWorld):(V.matrix.copy(Z.matrixWorld),V.matrix.invert(),V.matrix.multiply(re.matrixWorld)),V.matrix.decompose(V.position,V.quaternion,V.scale),V.updateMatrixWorld(!0),V.projectionMatrix.copy(re.projectionMatrix),V.projectionMatrixInverse.copy(re.projectionMatrixInverse),V.isPerspectiveCamera&&(V.fov=eu*2*Math.atan(1/V.projectionMatrix.elements[5]),V.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(p===null&&d===null))return l},this.setFoveation=function(V){l=V,p!==null&&(p.fixedFoveation=V),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=V)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(N)},this.getCameraTexture=function(V){return v[V]};let de=null;function ye(V,re){if(h=re.getViewerPose(c||o),m=re,h!==null){const Z=h.views;d!==null&&(e.setRenderTargetFramebuffer(E,d.framebuffer),e.setRenderTarget(E));let he=!1;Z.length!==N.cameras.length&&(N.cameras.length=0,he=!0);for(let le=0;le<Z.length;le++){const z=Z[le];let rt=null;if(d!==null)rt=d.getViewport(z);else{const at=f.getViewSubImage(p,z);rt=at.viewport,le===0&&(e.setRenderTargetTextures(E,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(E))}let Le=I[le];Le===void 0&&(Le=new vr,Le.layers.enable(le),Le.viewport=new ln,I[le]=Le),Le.matrix.fromArray(z.transform.matrix),Le.matrix.decompose(Le.position,Le.quaternion,Le.scale),Le.projectionMatrix.fromArray(z.projectionMatrix),Le.projectionMatrixInverse.copy(Le.projectionMatrix).invert(),Le.viewport.set(rt.x,rt.y,rt.width,rt.height),le===0&&(N.matrix.copy(Le.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),he===!0&&N.cameras.push(Le)}const xe=i.enabledFeatures;if(xe&&xe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&f){const le=f.getDepthInformation(Z[0]);le&&le.isValid&&le.texture&&x.init(le,i.renderState)}if(xe&&xe.includes("camera-access")&&(e.state.unbindTexture(),f))for(let le=0;le<Z.length;le++){const z=Z[le].camera;if(z){let rt=v[z];rt||(rt=new kv,v[z]=rt);const Le=f.getCameraImage(z);rt.sourceTexture=Le}}}for(let Z=0;Z<S.length;Z++){const he=b[Z],xe=S[Z];he!==null&&xe!==void 0&&xe.update(he,re,c||o)}de&&de(V,re),re.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:re}),m=null}const Ee=new hv;Ee.setAnimationLoop(ye),this.setAnimationLoop=function(V){de=V},this.dispose=function(){}}}const io=new ni,r8=new Gt;function i8(n,e){function t(v,_){v.matrixAutoUpdate===!0&&v.updateMatrix(),_.value.copy(v.matrix)}function r(v,_){_.color.getRGB(v.fogColor.value,I_(n)),_.isFog?(v.fogNear.value=_.near,v.fogFar.value=_.far):_.isFogExp2&&(v.fogDensity.value=_.density)}function i(v,_,w,E,S){_.isMeshBasicMaterial||_.isMeshLambertMaterial?s(v,_):_.isMeshToonMaterial?(s(v,_),f(v,_)):_.isMeshPhongMaterial?(s(v,_),h(v,_)):_.isMeshStandardMaterial?(s(v,_),p(v,_),_.isMeshPhysicalMaterial&&d(v,_,S)):_.isMeshMatcapMaterial?(s(v,_),m(v,_)):_.isMeshDepthMaterial?s(v,_):_.isMeshDistanceMaterial?(s(v,_),x(v,_)):_.isMeshNormalMaterial?s(v,_):_.isLineBasicMaterial?(o(v,_),_.isLineDashedMaterial&&a(v,_)):_.isPointsMaterial?l(v,_,w,E):_.isSpriteMaterial?c(v,_):_.isShadowMaterial?(v.color.value.copy(_.color),v.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function s(v,_){v.opacity.value=_.opacity,_.color&&v.diffuse.value.copy(_.color),_.emissive&&v.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(v.map.value=_.map,t(_.map,v.mapTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.bumpMap&&(v.bumpMap.value=_.bumpMap,t(_.bumpMap,v.bumpMapTransform),v.bumpScale.value=_.bumpScale,_.side===er&&(v.bumpScale.value*=-1)),_.normalMap&&(v.normalMap.value=_.normalMap,t(_.normalMap,v.normalMapTransform),v.normalScale.value.copy(_.normalScale),_.side===er&&v.normalScale.value.negate()),_.displacementMap&&(v.displacementMap.value=_.displacementMap,t(_.displacementMap,v.displacementMapTransform),v.displacementScale.value=_.displacementScale,v.displacementBias.value=_.displacementBias),_.emissiveMap&&(v.emissiveMap.value=_.emissiveMap,t(_.emissiveMap,v.emissiveMapTransform)),_.specularMap&&(v.specularMap.value=_.specularMap,t(_.specularMap,v.specularMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest);const w=e.get(_),E=w.envMap,S=w.envMapRotation;E&&(v.envMap.value=E,io.copy(S),io.x*=-1,io.y*=-1,io.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(io.y*=-1,io.z*=-1),v.envMapRotation.value.setFromMatrix4(r8.makeRotationFromEuler(io)),v.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=_.reflectivity,v.ior.value=_.ior,v.refractionRatio.value=_.refractionRatio),_.lightMap&&(v.lightMap.value=_.lightMap,v.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,v.lightMapTransform)),_.aoMap&&(v.aoMap.value=_.aoMap,v.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,v.aoMapTransform))}function o(v,_){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,_.map&&(v.map.value=_.map,t(_.map,v.mapTransform))}function a(v,_){v.dashSize.value=_.dashSize,v.totalSize.value=_.dashSize+_.gapSize,v.scale.value=_.scale}function l(v,_,w,E){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,v.size.value=_.size*w,v.scale.value=E*.5,_.map&&(v.map.value=_.map,t(_.map,v.uvTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest)}function c(v,_){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,v.rotation.value=_.rotation,_.map&&(v.map.value=_.map,t(_.map,v.mapTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest)}function h(v,_){v.specular.value.copy(_.specular),v.shininess.value=Math.max(_.shininess,1e-4)}function f(v,_){_.gradientMap&&(v.gradientMap.value=_.gradientMap)}function p(v,_){v.metalness.value=_.metalness,_.metalnessMap&&(v.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,v.metalnessMapTransform)),v.roughness.value=_.roughness,_.roughnessMap&&(v.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,v.roughnessMapTransform)),_.envMap&&(v.envMapIntensity.value=_.envMapIntensity)}function d(v,_,w){v.ior.value=_.ior,_.sheen>0&&(v.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),v.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(v.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,v.sheenColorMapTransform)),_.sheenRoughnessMap&&(v.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,v.sheenRoughnessMapTransform))),_.clearcoat>0&&(v.clearcoat.value=_.clearcoat,v.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(v.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,v.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(v.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===er&&v.clearcoatNormalScale.value.negate())),_.dispersion>0&&(v.dispersion.value=_.dispersion),_.iridescence>0&&(v.iridescence.value=_.iridescence,v.iridescenceIOR.value=_.iridescenceIOR,v.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(v.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,v.iridescenceMapTransform)),_.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),_.transmission>0&&(v.transmission.value=_.transmission,v.transmissionSamplerMap.value=w.texture,v.transmissionSamplerSize.value.set(w.width,w.height),_.transmissionMap&&(v.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,v.transmissionMapTransform)),v.thickness.value=_.thickness,_.thicknessMap&&(v.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=_.attenuationDistance,v.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(v.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(v.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=_.specularIntensity,v.specularColor.value.copy(_.specularColor),_.specularColorMap&&(v.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,v.specularColorMapTransform)),_.specularIntensityMap&&(v.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,v.specularIntensityMapTransform))}function m(v,_){_.matcap&&(v.matcap.value=_.matcap)}function x(v,_){const w=e.get(_).light;v.referencePosition.value.setFromMatrixPosition(w.matrixWorld),v.nearDistance.value=w.shadow.camera.near,v.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function s8(n,e,t,r){let i={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,E){const S=E.program;r.uniformBlockBinding(w,S)}function c(w,E){let S=i[w.id];S===void 0&&(m(w),S=h(w),i[w.id]=S,w.addEventListener("dispose",v));const b=E.program;r.updateUBOMapping(w,b);const A=e.render.frame;s[w.id]!==A&&(p(w),s[w.id]=A)}function h(w){const E=f();w.__bindingPointIndex=E;const S=n.createBuffer(),b=w.__size,A=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,b,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,S),S}function f(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(w){const E=i[w.id],S=w.uniforms,b=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,E);for(let A=0,q=S.length;A<q;A++){const O=Array.isArray(S[A])?S[A]:[S[A]];for(let T=0,I=O.length;T<I;T++){const N=O[T];if(d(N,A,T,b)===!0){const H=N.__offset,W=Array.isArray(N.value)?N.value:[N.value];let Q=0;for(let ae=0;ae<W.length;ae++){const J=W[ae],se=x(J);typeof J=="number"||typeof J=="boolean"?(N.__data[0]=J,n.bufferSubData(n.UNIFORM_BUFFER,H+Q,N.__data)):J.isMatrix3?(N.__data[0]=J.elements[0],N.__data[1]=J.elements[1],N.__data[2]=J.elements[2],N.__data[3]=0,N.__data[4]=J.elements[3],N.__data[5]=J.elements[4],N.__data[6]=J.elements[5],N.__data[7]=0,N.__data[8]=J.elements[6],N.__data[9]=J.elements[7],N.__data[10]=J.elements[8],N.__data[11]=0):(J.toArray(N.__data,Q),Q+=se.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,H,N.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function d(w,E,S,b){const A=w.value,q=E+"_"+S;if(b[q]===void 0)return typeof A=="number"||typeof A=="boolean"?b[q]=A:b[q]=A.clone(),!0;{const O=b[q];if(typeof A=="number"||typeof A=="boolean"){if(O!==A)return b[q]=A,!0}else if(O.equals(A)===!1)return O.copy(A),!0}return!1}function m(w){const E=w.uniforms;let S=0;const b=16;for(let q=0,O=E.length;q<O;q++){const T=Array.isArray(E[q])?E[q]:[E[q]];for(let I=0,N=T.length;I<N;I++){const H=T[I],W=Array.isArray(H.value)?H.value:[H.value];for(let Q=0,ae=W.length;Q<ae;Q++){const J=W[Q],se=x(J),B=S%b,ge=B%se.boundary,F=B+ge;S+=ge,F!==0&&b-F<se.storage&&(S+=b-F),H.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=se.storage}}}const A=S%b;return A>0&&(S+=b-A),w.__size=S,w.__cache={},this}function x(w){const E={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(E.boundary=4,E.storage=4):w.isVector2?(E.boundary=8,E.storage=8):w.isVector3||w.isColor?(E.boundary=16,E.storage=12):w.isVector4?(E.boundary=16,E.storage=16):w.isMatrix3?(E.boundary=48,E.storage=48):w.isMatrix4?(E.boundary=64,E.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),E}function v(w){const E=w.target;E.removeEventListener("dispose",v);const S=o.indexOf(E.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[E.id]),delete i[E.id],delete s[E.id]}function _(){for(const w in i)n.deleteBuffer(i[w]);o=[],i={},s={}}return{bind:l,update:c,dispose:_}}class o8{constructor(e={}){const{canvas:t=IM(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let d;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=r.getContextAttributes().alpha}else d=o;const m=new Uint32Array(4),x=new Int32Array(4);let v=null,_=null;const w=[],E=[];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=hs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let b=!1;this._outputColorSpace=mr;let A=0,q=0,O=null,T=-1,I=null;const N=new ln,H=new ln;let W=null;const Q=new Et(0);let ae=0,J=t.width,se=t.height,B=1,ge=null,F=null;const X=new ln(0,0,J,se),de=new ln(0,0,J,se);let ye=!1;const Ee=new Tp;let V=!1,re=!1;const Z=new Gt,he=new j,xe=new ln,ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Pe=!1;function le(){return O===null?B:1}let z=r;function rt(L,Y){return t.getContext(L,Y)}try{const L={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ad}`),t.addEventListener("webglcontextlost",Oe,!1),t.addEventListener("webglcontextrestored",ke,!1),t.addEventListener("webglcontextcreationerror",Te,!1),z===null){const Y="webgl2";if(z=rt(Y,L),z===null)throw rt(Y)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Le,at,ze,Xe,be,tt,lt,$e,U,P,te,pe,Me,fe,De,Ae,Ge,We,Ce,qe,Be,Ye,Re,ft;function G(){Le=new g6(z),Le.init(),Ye=new JT(z,Le),at=new c6(z,Le,e,Ye),ze=new KT(z,Le),at.reversedDepthBuffer&&p&&ze.buffers.depth.setReversed(!0),Xe=new x6(z),be=new UT,tt=new ZT(z,Le,ze,be,at,Ye,Xe),lt=new h6(S),$e=new m6(S),U=new sw(z),Re=new a6(z,U),P=new _6(z,U,Xe,Re),te=new S6(z,P,U,Xe),Ce=new y6(z,at,tt),Ae=new u6(be),pe=new NT(S,lt,$e,Le,at,Re,Ae),Me=new i8(S,be),fe=new zT,De=new WT(Le),We=new o6(S,lt,$e,ze,te,d,l),Ge=new $T(S,te,at),ft=new s8(z,Xe,at,ze),qe=new l6(z,Le,Xe),Be=new v6(z,Le,Xe),Xe.programs=pe.programs,S.capabilities=at,S.extensions=Le,S.properties=be,S.renderLists=fe,S.shadowMap=Ge,S.state=ze,S.info=Xe}G();const Se=new n8(S,z);this.xr=Se,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const L=Le.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){const L=Le.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(L){L!==void 0&&(B=L,this.setSize(J,se,!1))},this.getSize=function(L){return L.set(J,se)},this.setSize=function(L,Y,ie=!0){if(Se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}J=L,se=Y,t.width=Math.floor(L*B),t.height=Math.floor(Y*B),ie===!0&&(t.style.width=L+"px",t.style.height=Y+"px"),this.setViewport(0,0,L,Y)},this.getDrawingBufferSize=function(L){return L.set(J*B,se*B).floor()},this.setDrawingBufferSize=function(L,Y,ie){J=L,se=Y,B=ie,t.width=Math.floor(L*ie),t.height=Math.floor(Y*ie),this.setViewport(0,0,L,Y)},this.getCurrentViewport=function(L){return L.copy(N)},this.getViewport=function(L){return L.copy(X)},this.setViewport=function(L,Y,ie,oe){L.isVector4?X.set(L.x,L.y,L.z,L.w):X.set(L,Y,ie,oe),ze.viewport(N.copy(X).multiplyScalar(B).round())},this.getScissor=function(L){return L.copy(de)},this.setScissor=function(L,Y,ie,oe){L.isVector4?de.set(L.x,L.y,L.z,L.w):de.set(L,Y,ie,oe),ze.scissor(H.copy(de).multiplyScalar(B).round())},this.getScissorTest=function(){return ye},this.setScissorTest=function(L){ze.setScissorTest(ye=L)},this.setOpaqueSort=function(L){ge=L},this.setTransparentSort=function(L){F=L},this.getClearColor=function(L){return L.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor(...arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha(...arguments)},this.clear=function(L=!0,Y=!0,ie=!0){let oe=0;if(L){let K=!1;if(O!==null){const we=O.texture.format;K=we===Ad||we===Td||we===wd}if(K){const we=O.texture.type,Ue=we===bi||we===Gs||we===ul||we===fl||we===bd||we===Md,Ze=We.getClearColor(),je=We.getClearAlpha(),st=Ze.r,ct=Ze.g,Je=Ze.b;Ue?(m[0]=st,m[1]=ct,m[2]=Je,m[3]=je,z.clearBufferuiv(z.COLOR,0,m)):(x[0]=st,x[1]=ct,x[2]=Je,x[3]=je,z.clearBufferiv(z.COLOR,0,x))}else oe|=z.COLOR_BUFFER_BIT}Y&&(oe|=z.DEPTH_BUFFER_BIT),ie&&(oe|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(oe)},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",Oe,!1),t.removeEventListener("webglcontextrestored",ke,!1),t.removeEventListener("webglcontextcreationerror",Te,!1),We.dispose(),fe.dispose(),De.dispose(),be.dispose(),lt.dispose(),$e.dispose(),te.dispose(),Re.dispose(),ft.dispose(),pe.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",sr),Se.removeEventListener("sessionend",Ju),Ri.stop()};function Oe(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function ke(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const L=Xe.autoReset,Y=Ge.enabled,ie=Ge.autoUpdate,oe=Ge.needsUpdate,K=Ge.type;G(),Xe.autoReset=L,Ge.enabled=Y,Ge.autoUpdate=ie,Ge.needsUpdate=oe,Ge.type=K}function Te(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function me(L){const Y=L.target;Y.removeEventListener("dispose",me),Ke(Y)}function Ke(L){ut(L),be.remove(L)}function ut(L){const Y=be.get(L).programs;Y!==void 0&&(Y.forEach(function(ie){pe.releaseProgram(ie)}),L.isShaderMaterial&&pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,Y,ie,oe,K,we){Y===null&&(Y=ee);const Ue=K.isMesh&&K.matrixWorld.determinant()<0,Ze=kl(L,Y,ie,oe,K);ze.setMaterial(oe,Ue);let je=ie.index,st=1;if(oe.wireframe===!0){if(je=P.getWireframeAttribute(ie),je===void 0)return;st=2}const ct=ie.drawRange,Je=ie.attributes.position;let yt=ct.start*st,Rt=(ct.start+ct.count)*st;we!==null&&(yt=Math.max(yt,we.start*st),Rt=Math.min(Rt,(we.start+we.count)*st)),je!==null?(yt=Math.max(yt,0),Rt=Math.min(Rt,je.count)):Je!=null&&(yt=Math.max(yt,0),Rt=Math.min(Rt,Je.count));const Qt=Rt-yt;if(Qt<0||Qt===1/0)return;Re.setup(K,oe,Ze,ie,je);let Nt,Ut=qe;if(je!==null&&(Nt=U.get(je),Ut=Be,Ut.setIndex(Nt)),K.isMesh)oe.wireframe===!0?(ze.setLineWidth(oe.wireframeLinewidth*le()),Ut.setMode(z.LINES)):Ut.setMode(z.TRIANGLES);else if(K.isLine){let ot=oe.linewidth;ot===void 0&&(ot=1),ze.setLineWidth(ot*le()),K.isLineSegments?Ut.setMode(z.LINES):K.isLineLoop?Ut.setMode(z.LINE_LOOP):Ut.setMode(z.LINE_STRIP)}else K.isPoints?Ut.setMode(z.POINTS):K.isSprite&&Ut.setMode(z.TRIANGLES);if(K.isBatchedMesh)if(K._multiDrawInstances!==null)jo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ut.renderMultiDrawInstances(K._multiDrawStarts,K._multiDrawCounts,K._multiDrawCount,K._multiDrawInstances);else if(Le.get("WEBGL_multi_draw"))Ut.renderMultiDraw(K._multiDrawStarts,K._multiDrawCounts,K._multiDrawCount);else{const ot=K._multiDrawStarts,en=K._multiDrawCounts,bt=K._multiDrawCount,Un=je?U.get(je).bytesPerElement:1,Qi=be.get(oe).currentProgram.getUniforms();for(let Fn=0;Fn<bt;Fn++)Qi.setValue(z,"_gl_DrawID",Fn),Ut.render(ot[Fn]/Un,en[Fn])}else if(K.isInstancedMesh)Ut.renderInstances(yt,Qt,K.count);else if(ie.isInstancedBufferGeometry){const ot=ie._maxInstanceCount!==void 0?ie._maxInstanceCount:1/0,en=Math.min(ie.instanceCount,ot);Ut.renderInstances(yt,Qt,en)}else Ut.render(yt,Qt)};function Ot(L,Y,ie){L.transparent===!0&&L.side===Si&&L.forceSinglePass===!1?(L.side=er,L.needsUpdate=!0,Ur(L,Y,ie),L.side=cs,L.needsUpdate=!0,Ur(L,Y,ie),L.side=Si):Ur(L,Y,ie)}this.compile=function(L,Y,ie=null){ie===null&&(ie=L),_=De.get(ie),_.init(Y),E.push(_),ie.traverseVisible(function(K){K.isLight&&K.layers.test(Y.layers)&&(_.pushLight(K),K.castShadow&&_.pushShadow(K))}),L!==ie&&L.traverseVisible(function(K){K.isLight&&K.layers.test(Y.layers)&&(_.pushLight(K),K.castShadow&&_.pushShadow(K))}),_.setupLights();const oe=new Set;return L.traverse(function(K){if(!(K.isMesh||K.isPoints||K.isLine||K.isSprite))return;const we=K.material;if(we)if(Array.isArray(we))for(let Ue=0;Ue<we.length;Ue++){const Ze=we[Ue];Ot(Ze,ie,K),oe.add(Ze)}else Ot(we,ie,K),oe.add(we)}),_=E.pop(),oe},this.compileAsync=function(L,Y,ie=null){const oe=this.compile(L,Y,ie);return new Promise(K=>{function we(){if(oe.forEach(function(Ue){be.get(Ue).currentProgram.isReady()&&oe.delete(Ue)}),oe.size===0){K(L);return}setTimeout(we,10)}Le.get("KHR_parallel_shader_compile")!==null?we():setTimeout(we,10)})};let dt=null;function ai(L){dt&&dt(L)}function sr(){Ri.stop()}function Ju(){Ri.start()}const Ri=new hv;Ri.setAnimationLoop(ai),typeof self<"u"&&Ri.setContext(self),this.setAnimationLoop=function(L){dt=L,Se.setAnimationLoop(L),L===null?Ri.stop():Ri.start()},Se.addEventListener("sessionstart",sr),Se.addEventListener("sessionend",Ju),this.render=function(L,Y){if(Y!==void 0&&Y.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;if(L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Y.parent===null&&Y.matrixWorldAutoUpdate===!0&&Y.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(Y),Y=Se.getCamera()),L.isScene===!0&&L.onBeforeRender(S,L,Y,O),_=De.get(L,E.length),_.init(Y),E.push(_),Z.multiplyMatrices(Y.projectionMatrix,Y.matrixWorldInverse),Ee.setFromProjectionMatrix(Z,Mi,Y.reversedDepth),re=this.localClippingEnabled,V=Ae.init(this.clippingPlanes,re),v=fe.get(L,w.length),v.init(),w.push(v),Se.enabled===!0&&Se.isPresenting===!0){const we=S.xr.getDepthSensingMesh();we!==null&&wa(we,Y,-1/0,S.sortObjects)}wa(L,Y,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ge,F),Pe=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Pe&&We.addToRenderList(v,L),this.info.render.frame++,V===!0&&Ae.beginShadows();const ie=_.state.shadowsArray;Ge.render(ie,L,Y),V===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset();const oe=v.opaque,K=v.transmissive;if(_.setupLights(),Y.isArrayCamera){const we=Y.cameras;if(K.length>0)for(let Ue=0,Ze=we.length;Ue<Ze;Ue++){const je=we[Ue];Ta(oe,K,L,je)}Pe&&We.render(L);for(let Ue=0,Ze=we.length;Ue<Ze;Ue++){const je=we[Ue];Qu(v,L,je,je.viewport)}}else K.length>0&&Ta(oe,K,L,Y),Pe&&We.render(L),Qu(v,L,Y);O!==null&&q===0&&(tt.updateMultisampleRenderTarget(O),tt.updateRenderTargetMipmap(O)),L.isScene===!0&&L.onAfterRender(S,L,Y),Re.resetDefaultState(),T=-1,I=null,E.pop(),E.length>0?(_=E[E.length-1],V===!0&&Ae.setGlobalState(S.clippingPlanes,_.state.camera)):_=null,w.pop(),w.length>0?v=w[w.length-1]:v=null};function wa(L,Y,ie,oe){if(L.visible===!1)return;if(L.layers.test(Y.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(Y);else if(L.isLight)_.pushLight(L),L.castShadow&&_.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Ee.intersectsSprite(L)){oe&&xe.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Z);const Ue=te.update(L),Ze=L.material;Ze.visible&&v.push(L,Ue,Ze,ie,xe.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||Ee.intersectsObject(L))){const Ue=te.update(L),Ze=L.material;if(oe&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),xe.copy(L.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),xe.copy(Ue.boundingSphere.center)),xe.applyMatrix4(L.matrixWorld).applyMatrix4(Z)),Array.isArray(Ze)){const je=Ue.groups;for(let st=0,ct=je.length;st<ct;st++){const Je=je[st],yt=Ze[Je.materialIndex];yt&&yt.visible&&v.push(L,Ue,yt,ie,xe.z,Je)}}else Ze.visible&&v.push(L,Ue,Ze,ie,xe.z,null)}}const we=L.children;for(let Ue=0,Ze=we.length;Ue<Ze;Ue++)wa(we[Ue],Y,ie,oe)}function Qu(L,Y,ie,oe){const K=L.opaque,we=L.transmissive,Ue=L.transparent;_.setupLightsView(ie),V===!0&&Ae.setGlobalState(S.clippingPlanes,ie),oe&&ze.viewport(N.copy(oe)),K.length>0&&ws(K,Y,ie),we.length>0&&ws(we,Y,ie),Ue.length>0&&ws(Ue,Y,ie),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function Ta(L,Y,ie,oe){if((ie.isScene===!0?ie.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[oe.id]===void 0&&(_.state.transmissionRenderTarget[oe.id]=new js(1,1,{generateMipmaps:!0,type:Le.has("EXT_color_buffer_half_float")||Le.has("EXT_color_buffer_float")?hl:bi,minFilter:Hs,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ct.workingColorSpace}));const we=_.state.transmissionRenderTarget[oe.id],Ue=oe.viewport||N;we.setSize(Ue.z*S.transmissionResolutionScale,Ue.w*S.transmissionResolutionScale);const Ze=S.getRenderTarget(),je=S.getActiveCubeFace(),st=S.getActiveMipmapLevel();S.setRenderTarget(we),S.getClearColor(Q),ae=S.getClearAlpha(),ae<1&&S.setClearColor(16777215,.5),S.clear(),Pe&&We.render(ie);const ct=S.toneMapping;S.toneMapping=hs;const Je=oe.viewport;if(oe.viewport!==void 0&&(oe.viewport=void 0),_.setupLightsView(oe),V===!0&&Ae.setGlobalState(S.clippingPlanes,oe),ws(L,ie,oe),tt.updateMultisampleRenderTarget(we),tt.updateRenderTargetMipmap(we),Le.has("WEBGL_multisampled_render_to_texture")===!1){let yt=!1;for(let Rt=0,Qt=Y.length;Rt<Qt;Rt++){const Nt=Y[Rt],Ut=Nt.object,ot=Nt.geometry,en=Nt.material,bt=Nt.group;if(en.side===Si&&Ut.layers.test(oe.layers)){const Un=en.side;en.side=er,en.needsUpdate=!0,Aa(Ut,ie,oe,ot,en,bt),en.side=Un,en.needsUpdate=!0,yt=!0}}yt===!0&&(tt.updateMultisampleRenderTarget(we),tt.updateRenderTargetMipmap(we))}S.setRenderTarget(Ze,je,st),S.setClearColor(Q,ae),Je!==void 0&&(oe.viewport=Je),S.toneMapping=ct}function ws(L,Y,ie){const oe=Y.isScene===!0?Y.overrideMaterial:null;for(let K=0,we=L.length;K<we;K++){const Ue=L[K],Ze=Ue.object,je=Ue.geometry,st=Ue.group;let ct=Ue.material;ct.allowOverride===!0&&oe!==null&&(ct=oe),Ze.layers.test(ie.layers)&&Aa(Ze,Y,ie,je,ct,st)}}function Aa(L,Y,ie,oe,K,we){L.onBeforeRender(S,Y,ie,oe,K,we),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),K.onBeforeRender(S,Y,ie,oe,L,we),K.transparent===!0&&K.side===Si&&K.forceSinglePass===!1?(K.side=er,K.needsUpdate=!0,S.renderBufferDirect(ie,Y,oe,K,L,we),K.side=cs,K.needsUpdate=!0,S.renderBufferDirect(ie,Y,oe,K,L,we),K.side=Si):S.renderBufferDirect(ie,Y,oe,K,L,we),L.onAfterRender(S,Y,ie,oe,K,we)}function Ur(L,Y,ie){Y.isScene!==!0&&(Y=ee);const oe=be.get(L),K=_.state.lights,we=_.state.shadowsArray,Ue=K.state.version,Ze=pe.getParameters(L,K.state,we,Y,ie),je=pe.getProgramCacheKey(Ze);let st=oe.programs;oe.environment=L.isMeshStandardMaterial?Y.environment:null,oe.fog=Y.fog,oe.envMap=(L.isMeshStandardMaterial?$e:lt).get(L.envMap||oe.environment),oe.envMapRotation=oe.environment!==null&&L.envMap===null?Y.environmentRotation:L.envMapRotation,st===void 0&&(L.addEventListener("dispose",me),st=new Map,oe.programs=st);let ct=st.get(je);if(ct!==void 0){if(oe.currentProgram===ct&&oe.lightsStateVersion===Ue)return th(L,Ze),ct}else Ze.uniforms=pe.getUniforms(L),L.onBeforeCompile(Ze,S),ct=pe.acquireProgram(Ze,je),st.set(je,ct),oe.uniforms=Ze.uniforms;const Je=oe.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Je.clippingPlanes=Ae.uniform),th(L,Ze),oe.needsLights=jn(L),oe.lightsStateVersion=Ue,oe.needsLights&&(Je.ambientLightColor.value=K.state.ambient,Je.lightProbe.value=K.state.probe,Je.directionalLights.value=K.state.directional,Je.directionalLightShadows.value=K.state.directionalShadow,Je.spotLights.value=K.state.spot,Je.spotLightShadows.value=K.state.spotShadow,Je.rectAreaLights.value=K.state.rectArea,Je.ltc_1.value=K.state.rectAreaLTC1,Je.ltc_2.value=K.state.rectAreaLTC2,Je.pointLights.value=K.state.point,Je.pointLightShadows.value=K.state.pointShadow,Je.hemisphereLights.value=K.state.hemi,Je.directionalShadowMap.value=K.state.directionalShadowMap,Je.directionalShadowMatrix.value=K.state.directionalShadowMatrix,Je.spotShadowMap.value=K.state.spotShadowMap,Je.spotLightMatrix.value=K.state.spotLightMatrix,Je.spotLightMap.value=K.state.spotLightMap,Je.pointShadowMap.value=K.state.pointShadowMap,Je.pointShadowMatrix.value=K.state.pointShadowMatrix),oe.currentProgram=ct,oe.uniformsList=null,ct}function eh(L){if(L.uniformsList===null){const Y=L.currentProgram.getUniforms();L.uniformsList=Du.seqWithValue(Y.seq,L.uniforms)}return L.uniformsList}function th(L,Y){const ie=be.get(L);ie.outputColorSpace=Y.outputColorSpace,ie.batching=Y.batching,ie.batchingColor=Y.batchingColor,ie.instancing=Y.instancing,ie.instancingColor=Y.instancingColor,ie.instancingMorph=Y.instancingMorph,ie.skinning=Y.skinning,ie.morphTargets=Y.morphTargets,ie.morphNormals=Y.morphNormals,ie.morphColors=Y.morphColors,ie.morphTargetsCount=Y.morphTargetsCount,ie.numClippingPlanes=Y.numClippingPlanes,ie.numIntersection=Y.numClipIntersection,ie.vertexAlphas=Y.vertexAlphas,ie.vertexTangents=Y.vertexTangents,ie.toneMapping=Y.toneMapping}function kl(L,Y,ie,oe,K){Y.isScene!==!0&&(Y=ee),tt.resetTextureUnits();const we=Y.fog,Ue=oe.isMeshStandardMaterial?Y.environment:null,Ze=O===null?S.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Ho,je=(oe.isMeshStandardMaterial?$e:lt).get(oe.envMap||Ue),st=oe.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ct=!!ie.attributes.tangent&&(!!oe.normalMap||oe.anisotropy>0),Je=!!ie.morphAttributes.position,yt=!!ie.morphAttributes.normal,Rt=!!ie.morphAttributes.color;let Qt=hs;oe.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Qt=S.toneMapping);const Nt=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Ut=Nt!==void 0?Nt.length:0,ot=be.get(oe),en=_.state.lights;if(V===!0&&(re===!0||L!==I)){const Rn=L===I&&oe.id===T;Ae.setState(oe,L,Rn)}let bt=!1;oe.version===ot.__version?(ot.needsLights&&ot.lightsStateVersion!==en.state.version||ot.outputColorSpace!==Ze||K.isBatchedMesh&&ot.batching===!1||!K.isBatchedMesh&&ot.batching===!0||K.isBatchedMesh&&ot.batchingColor===!0&&K.colorTexture===null||K.isBatchedMesh&&ot.batchingColor===!1&&K.colorTexture!==null||K.isInstancedMesh&&ot.instancing===!1||!K.isInstancedMesh&&ot.instancing===!0||K.isSkinnedMesh&&ot.skinning===!1||!K.isSkinnedMesh&&ot.skinning===!0||K.isInstancedMesh&&ot.instancingColor===!0&&K.instanceColor===null||K.isInstancedMesh&&ot.instancingColor===!1&&K.instanceColor!==null||K.isInstancedMesh&&ot.instancingMorph===!0&&K.morphTexture===null||K.isInstancedMesh&&ot.instancingMorph===!1&&K.morphTexture!==null||ot.envMap!==je||oe.fog===!0&&ot.fog!==we||ot.numClippingPlanes!==void 0&&(ot.numClippingPlanes!==Ae.numPlanes||ot.numIntersection!==Ae.numIntersection)||ot.vertexAlphas!==st||ot.vertexTangents!==ct||ot.morphTargets!==Je||ot.morphNormals!==yt||ot.morphColors!==Rt||ot.toneMapping!==Qt||ot.morphTargetsCount!==Ut)&&(bt=!0):(bt=!0,ot.__version=oe.version);let Un=ot.currentProgram;bt===!0&&(Un=Ur(oe,Y,K));let Qi=!1,Fn=!1,Ts=!1;const $t=Un.getUniforms(),Xn=ot.uniforms;if(ze.useProgram(Un.program)&&(Qi=!0,Fn=!0,Ts=!0),oe.id!==T&&(T=oe.id,Fn=!0),Qi||I!==L){ze.buffers.depth.getReversed()&&L.reversedDepth!==!0&&(L._reversedDepth=!0,L.updateProjectionMatrix()),$t.setValue(z,"projectionMatrix",L.projectionMatrix),$t.setValue(z,"viewMatrix",L.matrixWorldInverse);const zn=$t.map.cameraPosition;zn!==void 0&&zn.setValue(z,he.setFromMatrixPosition(L.matrixWorld)),at.logarithmicDepthBuffer&&$t.setValue(z,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(oe.isMeshPhongMaterial||oe.isMeshToonMaterial||oe.isMeshLambertMaterial||oe.isMeshBasicMaterial||oe.isMeshStandardMaterial||oe.isShaderMaterial)&&$t.setValue(z,"isOrthographic",L.isOrthographicCamera===!0),I!==L&&(I=L,Fn=!0,Ts=!0)}if(K.isSkinnedMesh){$t.setOptional(z,K,"bindMatrix"),$t.setOptional(z,K,"bindMatrixInverse");const Rn=K.skeleton;Rn&&(Rn.boneTexture===null&&Rn.computeBoneTexture(),$t.setValue(z,"boneTexture",Rn.boneTexture,tt))}K.isBatchedMesh&&($t.setOptional(z,K,"batchingTexture"),$t.setValue(z,"batchingTexture",K._matricesTexture,tt),$t.setOptional(z,K,"batchingIdTexture"),$t.setValue(z,"batchingIdTexture",K._indirectTexture,tt),$t.setOptional(z,K,"batchingColorTexture"),K._colorsTexture!==null&&$t.setValue(z,"batchingColorTexture",K._colorsTexture,tt));const or=ie.morphAttributes;if((or.position!==void 0||or.normal!==void 0||or.color!==void 0)&&Ce.update(K,ie,Un),(Fn||ot.receiveShadow!==K.receiveShadow)&&(ot.receiveShadow=K.receiveShadow,$t.setValue(z,"receiveShadow",K.receiveShadow)),oe.isMeshGouraudMaterial&&oe.envMap!==null&&(Xn.envMap.value=je,Xn.flipEnvMap.value=je.isCubeTexture&&je.isRenderTargetTexture===!1?-1:1),oe.isMeshStandardMaterial&&oe.envMap===null&&Y.environment!==null&&(Xn.envMapIntensity.value=Y.environmentIntensity),Fn&&($t.setValue(z,"toneMappingExposure",S.toneMappingExposure),ot.needsLights&&Bl(Xn,Ts),we&&oe.fog===!0&&Me.refreshFogUniforms(Xn,we),Me.refreshMaterialUniforms(Xn,oe,B,se,_.state.transmissionRenderTarget[L.id]),Du.upload(z,eh(ot),Xn,tt)),oe.isShaderMaterial&&oe.uniformsNeedUpdate===!0&&(Du.upload(z,eh(ot),Xn,tt),oe.uniformsNeedUpdate=!1),oe.isSpriteMaterial&&$t.setValue(z,"center",K.center),$t.setValue(z,"modelViewMatrix",K.modelViewMatrix),$t.setValue(z,"normalMatrix",K.normalMatrix),$t.setValue(z,"modelMatrix",K.matrixWorld),oe.isShaderMaterial||oe.isRawShaderMaterial){const Rn=oe.uniformsGroups;for(let zn=0,Hl=Rn.length;zn<Hl;zn++){const es=Rn[zn];ft.update(es,Un),ft.bind(es,Un)}}return Un}function Bl(L,Y){L.ambientLightColor.needsUpdate=Y,L.lightProbe.needsUpdate=Y,L.directionalLights.needsUpdate=Y,L.directionalLightShadows.needsUpdate=Y,L.pointLights.needsUpdate=Y,L.pointLightShadows.needsUpdate=Y,L.spotLights.needsUpdate=Y,L.spotLightShadows.needsUpdate=Y,L.rectAreaLights.needsUpdate=Y,L.hemisphereLights.needsUpdate=Y}function jn(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(L,Y,ie){const oe=be.get(L);oe.__autoAllocateDepthBuffer=L.resolveDepthBuffer===!1,oe.__autoAllocateDepthBuffer===!1&&(oe.__useRenderToTexture=!1),be.get(L.texture).__webglTexture=Y,be.get(L.depthTexture).__webglTexture=oe.__autoAllocateDepthBuffer?void 0:ie,oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(L,Y){const ie=be.get(L);ie.__webglFramebuffer=Y,ie.__useDefaultFramebuffer=Y===void 0};const Mt=z.createFramebuffer();this.setRenderTarget=function(L,Y=0,ie=0){O=L,A=Y,q=ie;let oe=!0,K=null,we=!1,Ue=!1;if(L){const je=be.get(L);if(je.__useDefaultFramebuffer!==void 0)ze.bindFramebuffer(z.FRAMEBUFFER,null),oe=!1;else if(je.__webglFramebuffer===void 0)tt.setupRenderTarget(L);else if(je.__hasExternalTextures)tt.rebindTextures(L,be.get(L.texture).__webglTexture,be.get(L.depthTexture).__webglTexture);else if(L.depthBuffer){const Je=L.depthTexture;if(je.__boundDepthTexture!==Je){if(Je!==null&&be.has(Je)&&(L.width!==Je.image.width||L.height!==Je.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(L)}}const st=L.texture;(st.isData3DTexture||st.isDataArrayTexture||st.isCompressedArrayTexture)&&(Ue=!0);const ct=be.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(ct[Y])?K=ct[Y][ie]:K=ct[Y],we=!0):L.samples>0&&tt.useMultisampledRTT(L)===!1?K=be.get(L).__webglMultisampledFramebuffer:Array.isArray(ct)?K=ct[ie]:K=ct,N.copy(L.viewport),H.copy(L.scissor),W=L.scissorTest}else N.copy(X).multiplyScalar(B).floor(),H.copy(de).multiplyScalar(B).floor(),W=ye;if(ie!==0&&(K=Mt),ze.bindFramebuffer(z.FRAMEBUFFER,K)&&oe&&ze.drawBuffers(L,K),ze.viewport(N),ze.scissor(H),ze.setScissorTest(W),we){const je=be.get(L.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+Y,je.__webglTexture,ie)}else if(Ue){const je=Y;for(let st=0;st<L.textures.length;st++){const ct=be.get(L.textures[st]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+st,ct.__webglTexture,ie,je)}}else if(L!==null&&ie!==0){const je=be.get(L.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,je.__webglTexture,ie)}T=-1},this.readRenderTargetPixels=function(L,Y,ie,oe,K,we,Ue,Ze=0){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let je=be.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){ze.bindFramebuffer(z.FRAMEBUFFER,je);try{const st=L.textures[Ze],ct=st.format,Je=st.type;if(!at.textureFormatReadable(ct)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!at.textureTypeReadable(Je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Y>=0&&Y<=L.width-oe&&ie>=0&&ie<=L.height-K&&(L.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ze),z.readPixels(Y,ie,oe,K,Ye.convert(ct),Ye.convert(Je),we))}finally{const st=O!==null?be.get(O).__webglFramebuffer:null;ze.bindFramebuffer(z.FRAMEBUFFER,st)}}},this.readRenderTargetPixelsAsync=async function(L,Y,ie,oe,K,we,Ue,Ze=0){if(!(L&&L.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let je=be.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je)if(Y>=0&&Y<=L.width-oe&&ie>=0&&ie<=L.height-K){ze.bindFramebuffer(z.FRAMEBUFFER,je);const st=L.textures[Ze],ct=st.format,Je=st.type;if(!at.textureFormatReadable(ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!at.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const yt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,yt),z.bufferData(z.PIXEL_PACK_BUFFER,we.byteLength,z.STREAM_READ),L.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ze),z.readPixels(Y,ie,oe,K,Ye.convert(ct),Ye.convert(Je),0);const Rt=O!==null?be.get(O).__webglFramebuffer:null;ze.bindFramebuffer(z.FRAMEBUFFER,Rt);const Qt=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await LM(z,Qt,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,yt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,we),z.deleteBuffer(yt),z.deleteSync(Qt),we}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(L,Y=null,ie=0){const oe=Math.pow(2,-ie),K=Math.floor(L.image.width*oe),we=Math.floor(L.image.height*oe),Ue=Y!==null?Y.x:0,Ze=Y!==null?Y.y:0;tt.setTexture2D(L,0),z.copyTexSubImage2D(z.TEXTURE_2D,ie,0,0,Ue,Ze,K,we),ze.unbindTexture()};const Vl=z.createFramebuffer(),nh=z.createFramebuffer();this.copyTextureToTexture=function(L,Y,ie=null,oe=null,K=0,we=null){we===null&&(K!==0?(jo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),we=K,K=0):we=0);let Ue,Ze,je,st,ct,Je,yt,Rt,Qt;const Nt=L.isCompressedTexture?L.mipmaps[we]:L.image;if(ie!==null)Ue=ie.max.x-ie.min.x,Ze=ie.max.y-ie.min.y,je=ie.isBox3?ie.max.z-ie.min.z:1,st=ie.min.x,ct=ie.min.y,Je=ie.isBox3?ie.min.z:0;else{const or=Math.pow(2,-K);Ue=Math.floor(Nt.width*or),Ze=Math.floor(Nt.height*or),L.isDataArrayTexture?je=Nt.depth:L.isData3DTexture?je=Math.floor(Nt.depth*or):je=1,st=0,ct=0,Je=0}oe!==null?(yt=oe.x,Rt=oe.y,Qt=oe.z):(yt=0,Rt=0,Qt=0);const Ut=Ye.convert(Y.format),ot=Ye.convert(Y.type);let en;Y.isData3DTexture?(tt.setTexture3D(Y,0),en=z.TEXTURE_3D):Y.isDataArrayTexture||Y.isCompressedArrayTexture?(tt.setTexture2DArray(Y,0),en=z.TEXTURE_2D_ARRAY):(tt.setTexture2D(Y,0),en=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Y.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Y.unpackAlignment);const bt=z.getParameter(z.UNPACK_ROW_LENGTH),Un=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Qi=z.getParameter(z.UNPACK_SKIP_PIXELS),Fn=z.getParameter(z.UNPACK_SKIP_ROWS),Ts=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,Nt.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Nt.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,st),z.pixelStorei(z.UNPACK_SKIP_ROWS,ct),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Je);const $t=L.isDataArrayTexture||L.isData3DTexture,Xn=Y.isDataArrayTexture||Y.isData3DTexture;if(L.isDepthTexture){const or=be.get(L),Rn=be.get(Y),zn=be.get(or.__renderTarget),Hl=be.get(Rn.__renderTarget);ze.bindFramebuffer(z.READ_FRAMEBUFFER,zn.__webglFramebuffer),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,Hl.__webglFramebuffer);for(let es=0;es<je;es++)$t&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,be.get(L).__webglTexture,K,Je+es),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,be.get(Y).__webglTexture,we,Qt+es)),z.blitFramebuffer(st,ct,Ue,Ze,yt,Rt,Ue,Ze,z.DEPTH_BUFFER_BIT,z.NEAREST);ze.bindFramebuffer(z.READ_FRAMEBUFFER,null),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(K!==0||L.isRenderTargetTexture||be.has(L)){const or=be.get(L),Rn=be.get(Y);ze.bindFramebuffer(z.READ_FRAMEBUFFER,Vl),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,nh);for(let zn=0;zn<je;zn++)$t?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,or.__webglTexture,K,Je+zn):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,or.__webglTexture,K),Xn?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Rn.__webglTexture,we,Qt+zn):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Rn.__webglTexture,we),K!==0?z.blitFramebuffer(st,ct,Ue,Ze,yt,Rt,Ue,Ze,z.COLOR_BUFFER_BIT,z.NEAREST):Xn?z.copyTexSubImage3D(en,we,yt,Rt,Qt+zn,st,ct,Ue,Ze):z.copyTexSubImage2D(en,we,yt,Rt,st,ct,Ue,Ze);ze.bindFramebuffer(z.READ_FRAMEBUFFER,null),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else Xn?L.isDataTexture||L.isData3DTexture?z.texSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,ot,Nt.data):Y.isCompressedArrayTexture?z.compressedTexSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,Nt.data):z.texSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,ot,Nt):L.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,we,yt,Rt,Ue,Ze,Ut,ot,Nt.data):L.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,we,yt,Rt,Nt.width,Nt.height,Ut,Nt.data):z.texSubImage2D(z.TEXTURE_2D,we,yt,Rt,Ue,Ze,Ut,ot,Nt);z.pixelStorei(z.UNPACK_ROW_LENGTH,bt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Un),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Qi),z.pixelStorei(z.UNPACK_SKIP_ROWS,Fn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Ts),we===0&&Y.generateMipmaps&&z.generateMipmap(en),ze.unbindTexture()},this.copyTextureToTexture3D=function(L,Y,ie=null,oe=null,K=0){return jo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(L,Y,ie,oe,K)},this.initRenderTarget=function(L){be.get(L).__webglFramebuffer===void 0&&tt.setupRenderTarget(L)},this.initTexture=function(L){L.isCubeTexture?tt.setTextureCube(L,0):L.isData3DTexture?tt.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?tt.setTexture2DArray(L,0):tt.setTexture2D(L,0),ze.unbindTexture()},this.resetState=function(){A=0,q=0,O=null,ze.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Mi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ct._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ct._getUnpackColorSpace()}}class a8 extends Pl{constructor(e){super(e)}load(e,t,r,i){const s=this,o=new X4(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},r,i)}parse(e){return new l8(e)}}class l8{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const r=[],i=c8(e,t,this.data);for(let s=0,o=i.length;s<o;s++)r.push(...i[s].toShapes());return r}}function c8(n,e,t){const r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[];let a=0,l=0;for(let c=0;c<r.length;c++){const h=r[c];if(h===`
3909
+ }`;class t8{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const r=new kv(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,r=new xs({vertexShader:QT,fragmentShader:e8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Tn(new Pu(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class n8 extends Ws{constructor(e,t){super();const r=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,h=null,f=null,p=null,d=null,m=null;const x=new t8,v={},_=t.getContextAttributes();let w=null,E=null;const S=[],b=[],A=new Ne;let q=null;const O=new vr;O.viewport=new ln;const T=new vr;T.viewport=new ln;const I=[O,T],N=new Q4;let H=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getTargetRaySpace()},this.getControllerGrip=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getGripSpace()},this.getHand=function(V){let re=S[V];return re===void 0&&(re=new Mp,S[V]=re),re.getHandSpace()};function Q(V){const re=b.indexOf(V.inputSource);if(re===-1)return;const Z=S[re];Z!==void 0&&(Z.update(V.inputSource,V.frame,c||o),Z.dispatchEvent({type:V.type,data:V.inputSource}))}function ae(){i.removeEventListener("select",Q),i.removeEventListener("selectstart",Q),i.removeEventListener("selectend",Q),i.removeEventListener("squeeze",Q),i.removeEventListener("squeezestart",Q),i.removeEventListener("squeezeend",Q),i.removeEventListener("end",ae),i.removeEventListener("inputsourceschange",J);for(let V=0;V<S.length;V++){const re=b[V];re!==null&&(b[V]=null,S[V].disconnect(re))}H=null,W=null,x.reset();for(const V in v)delete v[V];e.setRenderTarget(w),d=null,p=null,f=null,i=null,E=null,Ee.stop(),r.isPresenting=!1,e.setPixelRatio(q),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(V){s=V,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(V){a=V,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(V){c=V},this.getBaseLayer=function(){return p!==null?p:d},this.getBinding=function(){return f},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(V){if(i=V,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",Q),i.addEventListener("selectstart",Q),i.addEventListener("selectend",Q),i.addEventListener("squeeze",Q),i.addEventListener("squeezestart",Q),i.addEventListener("squeezeend",Q),i.addEventListener("end",ae),i.addEventListener("inputsourceschange",J),_.xrCompatible!==!0&&await t.makeXRCompatible(),q=e.getPixelRatio(),e.getSize(A),typeof XRWebGLBinding<"u"&&(f=new XRWebGLBinding(i,t)),f!==null&&"createProjectionLayer"in XRWebGLBinding.prototype){let Z=null,he=null,xe=null;_.depth&&(xe=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=_.stencil?pl:dl,he=_.stencil?fl:Gs);const ee={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:s};p=f.createProjectionLayer(ee),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),E=new js(p.textureWidth,p.textureHeight,{format:Qr,type:bi,depthTexture:new B_(p.textureWidth,p.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Z={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,Z),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),E=new js(d.framebufferWidth,d.framebufferHeight,{format:Qr,type:bi,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),Ee.setContext(i),Ee.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function J(V){for(let re=0;re<V.removed.length;re++){const Z=V.removed[re],he=b.indexOf(Z);he>=0&&(b[he]=null,S[he].disconnect(Z))}for(let re=0;re<V.added.length;re++){const Z=V.added[re];let he=b.indexOf(Z);if(he===-1){for(let ee=0;ee<S.length;ee++)if(ee>=b.length){b.push(Z),he=ee;break}else if(b[ee]===null){b[ee]=Z,he=ee;break}if(he===-1)break}const xe=S[he];xe&&xe.connect(Z)}}const se=new j,B=new j;function ge(V,re,Z){se.setFromMatrixPosition(re.matrixWorld),B.setFromMatrixPosition(Z.matrixWorld);const he=se.distanceTo(B),xe=re.projectionMatrix.elements,ee=Z.projectionMatrix.elements,Pe=xe[14]/(xe[10]-1),le=xe[14]/(xe[10]+1),z=(xe[9]+1)/xe[5],rt=(xe[9]-1)/xe[5],Le=(xe[8]-1)/xe[0],at=(ee[8]+1)/ee[0],ze=Pe*Le,Xe=Pe*at,be=he/(-Le+at),tt=be*-Le;if(re.matrixWorld.decompose(V.position,V.quaternion,V.scale),V.translateX(tt),V.translateZ(be),V.matrixWorld.compose(V.position,V.quaternion,V.scale),V.matrixWorldInverse.copy(V.matrixWorld).invert(),xe[10]===-1)V.projectionMatrix.copy(re.projectionMatrix),V.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const lt=Pe+be,$e=le+be,U=ze-tt,P=Xe+(he-tt),te=z*le/$e*lt,pe=rt*le/$e*lt;V.projectionMatrix.makePerspective(U,P,te,pe,lt,$e),V.projectionMatrixInverse.copy(V.projectionMatrix).invert()}}function F(V,re){re===null?V.matrixWorld.copy(V.matrix):V.matrixWorld.multiplyMatrices(re.matrixWorld,V.matrix),V.matrixWorldInverse.copy(V.matrixWorld).invert()}this.updateCamera=function(V){if(i===null)return;let re=V.near,Z=V.far;x.texture!==null&&(x.depthNear>0&&(re=x.depthNear),x.depthFar>0&&(Z=x.depthFar)),N.near=T.near=O.near=re,N.far=T.far=O.far=Z,(H!==N.near||W!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),H=N.near,W=N.far),N.layers.mask=V.layers.mask|6,O.layers.mask=N.layers.mask&3,T.layers.mask=N.layers.mask&5;const he=V.parent,xe=N.cameras;F(N,he);for(let ee=0;ee<xe.length;ee++)F(xe[ee],he);xe.length===2?ge(N,O,T):N.projectionMatrix.copy(O.projectionMatrix),X(V,N,he)};function X(V,re,Z){Z===null?V.matrix.copy(re.matrixWorld):(V.matrix.copy(Z.matrixWorld),V.matrix.invert(),V.matrix.multiply(re.matrixWorld)),V.matrix.decompose(V.position,V.quaternion,V.scale),V.updateMatrixWorld(!0),V.projectionMatrix.copy(re.projectionMatrix),V.projectionMatrixInverse.copy(re.projectionMatrixInverse),V.isPerspectiveCamera&&(V.fov=eu*2*Math.atan(1/V.projectionMatrix.elements[5]),V.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(p===null&&d===null))return l},this.setFoveation=function(V){l=V,p!==null&&(p.fixedFoveation=V),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=V)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(N)},this.getCameraTexture=function(V){return v[V]};let de=null;function ye(V,re){if(h=re.getViewerPose(c||o),m=re,h!==null){const Z=h.views;d!==null&&(e.setRenderTargetFramebuffer(E,d.framebuffer),e.setRenderTarget(E));let he=!1;Z.length!==N.cameras.length&&(N.cameras.length=0,he=!0);for(let le=0;le<Z.length;le++){const z=Z[le];let rt=null;if(d!==null)rt=d.getViewport(z);else{const at=f.getViewSubImage(p,z);rt=at.viewport,le===0&&(e.setRenderTargetTextures(E,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(E))}let Le=I[le];Le===void 0&&(Le=new vr,Le.layers.enable(le),Le.viewport=new ln,I[le]=Le),Le.matrix.fromArray(z.transform.matrix),Le.matrix.decompose(Le.position,Le.quaternion,Le.scale),Le.projectionMatrix.fromArray(z.projectionMatrix),Le.projectionMatrixInverse.copy(Le.projectionMatrix).invert(),Le.viewport.set(rt.x,rt.y,rt.width,rt.height),le===0&&(N.matrix.copy(Le.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),he===!0&&N.cameras.push(Le)}const xe=i.enabledFeatures;if(xe&&xe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&f){const le=f.getDepthInformation(Z[0]);le&&le.isValid&&le.texture&&x.init(le,i.renderState)}if(xe&&xe.includes("camera-access")&&(e.state.unbindTexture(),f))for(let le=0;le<Z.length;le++){const z=Z[le].camera;if(z){let rt=v[z];rt||(rt=new kv,v[z]=rt);const Le=f.getCameraImage(z);rt.sourceTexture=Le}}}for(let Z=0;Z<S.length;Z++){const he=b[Z],xe=S[Z];he!==null&&xe!==void 0&&xe.update(he,re,c||o)}de&&de(V,re),re.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:re}),m=null}const Ee=new hv;Ee.setAnimationLoop(ye),this.setAnimationLoop=function(V){de=V},this.dispose=function(){}}}const io=new ni,r8=new Gt;function i8(n,e){function t(v,_){v.matrixAutoUpdate===!0&&v.updateMatrix(),_.value.copy(v.matrix)}function r(v,_){_.color.getRGB(v.fogColor.value,I_(n)),_.isFog?(v.fogNear.value=_.near,v.fogFar.value=_.far):_.isFogExp2&&(v.fogDensity.value=_.density)}function i(v,_,w,E,S){_.isMeshBasicMaterial||_.isMeshLambertMaterial?s(v,_):_.isMeshToonMaterial?(s(v,_),f(v,_)):_.isMeshPhongMaterial?(s(v,_),h(v,_)):_.isMeshStandardMaterial?(s(v,_),p(v,_),_.isMeshPhysicalMaterial&&d(v,_,S)):_.isMeshMatcapMaterial?(s(v,_),m(v,_)):_.isMeshDepthMaterial?s(v,_):_.isMeshDistanceMaterial?(s(v,_),x(v,_)):_.isMeshNormalMaterial?s(v,_):_.isLineBasicMaterial?(o(v,_),_.isLineDashedMaterial&&a(v,_)):_.isPointsMaterial?l(v,_,w,E):_.isSpriteMaterial?c(v,_):_.isShadowMaterial?(v.color.value.copy(_.color),v.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function s(v,_){v.opacity.value=_.opacity,_.color&&v.diffuse.value.copy(_.color),_.emissive&&v.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(v.map.value=_.map,t(_.map,v.mapTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.bumpMap&&(v.bumpMap.value=_.bumpMap,t(_.bumpMap,v.bumpMapTransform),v.bumpScale.value=_.bumpScale,_.side===er&&(v.bumpScale.value*=-1)),_.normalMap&&(v.normalMap.value=_.normalMap,t(_.normalMap,v.normalMapTransform),v.normalScale.value.copy(_.normalScale),_.side===er&&v.normalScale.value.negate()),_.displacementMap&&(v.displacementMap.value=_.displacementMap,t(_.displacementMap,v.displacementMapTransform),v.displacementScale.value=_.displacementScale,v.displacementBias.value=_.displacementBias),_.emissiveMap&&(v.emissiveMap.value=_.emissiveMap,t(_.emissiveMap,v.emissiveMapTransform)),_.specularMap&&(v.specularMap.value=_.specularMap,t(_.specularMap,v.specularMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest);const w=e.get(_),E=w.envMap,S=w.envMapRotation;E&&(v.envMap.value=E,io.copy(S),io.x*=-1,io.y*=-1,io.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(io.y*=-1,io.z*=-1),v.envMapRotation.value.setFromMatrix4(r8.makeRotationFromEuler(io)),v.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=_.reflectivity,v.ior.value=_.ior,v.refractionRatio.value=_.refractionRatio),_.lightMap&&(v.lightMap.value=_.lightMap,v.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,v.lightMapTransform)),_.aoMap&&(v.aoMap.value=_.aoMap,v.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,v.aoMapTransform))}function o(v,_){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,_.map&&(v.map.value=_.map,t(_.map,v.mapTransform))}function a(v,_){v.dashSize.value=_.dashSize,v.totalSize.value=_.dashSize+_.gapSize,v.scale.value=_.scale}function l(v,_,w,E){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,v.size.value=_.size*w,v.scale.value=E*.5,_.map&&(v.map.value=_.map,t(_.map,v.uvTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest)}function c(v,_){v.diffuse.value.copy(_.color),v.opacity.value=_.opacity,v.rotation.value=_.rotation,_.map&&(v.map.value=_.map,t(_.map,v.mapTransform)),_.alphaMap&&(v.alphaMap.value=_.alphaMap,t(_.alphaMap,v.alphaMapTransform)),_.alphaTest>0&&(v.alphaTest.value=_.alphaTest)}function h(v,_){v.specular.value.copy(_.specular),v.shininess.value=Math.max(_.shininess,1e-4)}function f(v,_){_.gradientMap&&(v.gradientMap.value=_.gradientMap)}function p(v,_){v.metalness.value=_.metalness,_.metalnessMap&&(v.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,v.metalnessMapTransform)),v.roughness.value=_.roughness,_.roughnessMap&&(v.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,v.roughnessMapTransform)),_.envMap&&(v.envMapIntensity.value=_.envMapIntensity)}function d(v,_,w){v.ior.value=_.ior,_.sheen>0&&(v.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),v.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(v.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,v.sheenColorMapTransform)),_.sheenRoughnessMap&&(v.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,v.sheenRoughnessMapTransform))),_.clearcoat>0&&(v.clearcoat.value=_.clearcoat,v.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(v.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,v.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(v.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===er&&v.clearcoatNormalScale.value.negate())),_.dispersion>0&&(v.dispersion.value=_.dispersion),_.iridescence>0&&(v.iridescence.value=_.iridescence,v.iridescenceIOR.value=_.iridescenceIOR,v.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(v.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,v.iridescenceMapTransform)),_.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),_.transmission>0&&(v.transmission.value=_.transmission,v.transmissionSamplerMap.value=w.texture,v.transmissionSamplerSize.value.set(w.width,w.height),_.transmissionMap&&(v.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,v.transmissionMapTransform)),v.thickness.value=_.thickness,_.thicknessMap&&(v.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=_.attenuationDistance,v.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(v.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(v.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=_.specularIntensity,v.specularColor.value.copy(_.specularColor),_.specularColorMap&&(v.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,v.specularColorMapTransform)),_.specularIntensityMap&&(v.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,v.specularIntensityMapTransform))}function m(v,_){_.matcap&&(v.matcap.value=_.matcap)}function x(v,_){const w=e.get(_).light;v.referencePosition.value.setFromMatrixPosition(w.matrixWorld),v.nearDistance.value=w.shadow.camera.near,v.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function s8(n,e,t,r){let i={},s={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,E){const S=E.program;r.uniformBlockBinding(w,S)}function c(w,E){let S=i[w.id];S===void 0&&(m(w),S=h(w),i[w.id]=S,w.addEventListener("dispose",v));const b=E.program;r.updateUBOMapping(w,b);const A=e.render.frame;s[w.id]!==A&&(p(w),s[w.id]=A)}function h(w){const E=f();w.__bindingPointIndex=E;const S=n.createBuffer(),b=w.__size,A=w.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,b,A),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,S),S}function f(){for(let w=0;w<a;w++)if(o.indexOf(w)===-1)return o.push(w),w;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(w){const E=i[w.id],S=w.uniforms,b=w.__cache;n.bindBuffer(n.UNIFORM_BUFFER,E);for(let A=0,q=S.length;A<q;A++){const O=Array.isArray(S[A])?S[A]:[S[A]];for(let T=0,I=O.length;T<I;T++){const N=O[T];if(d(N,A,T,b)===!0){const H=N.__offset,W=Array.isArray(N.value)?N.value:[N.value];let Q=0;for(let ae=0;ae<W.length;ae++){const J=W[ae],se=x(J);typeof J=="number"||typeof J=="boolean"?(N.__data[0]=J,n.bufferSubData(n.UNIFORM_BUFFER,H+Q,N.__data)):J.isMatrix3?(N.__data[0]=J.elements[0],N.__data[1]=J.elements[1],N.__data[2]=J.elements[2],N.__data[3]=0,N.__data[4]=J.elements[3],N.__data[5]=J.elements[4],N.__data[6]=J.elements[5],N.__data[7]=0,N.__data[8]=J.elements[6],N.__data[9]=J.elements[7],N.__data[10]=J.elements[8],N.__data[11]=0):(J.toArray(N.__data,Q),Q+=se.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,H,N.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function d(w,E,S,b){const A=w.value,q=E+"_"+S;if(b[q]===void 0)return typeof A=="number"||typeof A=="boolean"?b[q]=A:b[q]=A.clone(),!0;{const O=b[q];if(typeof A=="number"||typeof A=="boolean"){if(O!==A)return b[q]=A,!0}else if(O.equals(A)===!1)return O.copy(A),!0}return!1}function m(w){const E=w.uniforms;let S=0;const b=16;for(let q=0,O=E.length;q<O;q++){const T=Array.isArray(E[q])?E[q]:[E[q]];for(let I=0,N=T.length;I<N;I++){const H=T[I],W=Array.isArray(H.value)?H.value:[H.value];for(let Q=0,ae=W.length;Q<ae;Q++){const J=W[Q],se=x(J),B=S%b,ge=B%se.boundary,F=B+ge;S+=ge,F!==0&&b-F<se.storage&&(S+=b-F),H.__data=new Float32Array(se.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=se.storage}}}const A=S%b;return A>0&&(S+=b-A),w.__size=S,w.__cache={},this}function x(w){const E={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(E.boundary=4,E.storage=4):w.isVector2?(E.boundary=8,E.storage=8):w.isVector3||w.isColor?(E.boundary=16,E.storage=12):w.isVector4?(E.boundary=16,E.storage=16):w.isMatrix3?(E.boundary=48,E.storage=48):w.isMatrix4?(E.boundary=64,E.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),E}function v(w){const E=w.target;E.removeEventListener("dispose",v);const S=o.indexOf(E.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[E.id]),delete i[E.id],delete s[E.id]}function _(){for(const w in i)n.deleteBuffer(i[w]);o=[],i={},s={}}return{bind:l,update:c,dispose:_}}class o8{constructor(e={}){const{canvas:t=IM(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let d;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=r.getContextAttributes().alpha}else d=o;const m=new Uint32Array(4),x=new Int32Array(4);let v=null,_=null;const w=[],E=[];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=hs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let b=!1;this._outputColorSpace=mr;let A=0,q=0,O=null,T=-1,I=null;const N=new ln,H=new ln;let W=null;const Q=new Et(0);let ae=0,J=t.width,se=t.height,B=1,ge=null,F=null;const X=new ln(0,0,J,se),de=new ln(0,0,J,se);let ye=!1;const Ee=new Tp;let V=!1,re=!1;const Z=new Gt,he=new j,xe=new ln,ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Pe=!1;function le(){return O===null?B:1}let z=r;function rt(L,Y){return t.getContext(L,Y)}try{const L={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ad}`),t.addEventListener("webglcontextlost",Oe,!1),t.addEventListener("webglcontextrestored",ke,!1),t.addEventListener("webglcontextcreationerror",Te,!1),z===null){const Y="webgl2";if(z=rt(Y,L),z===null)throw rt(Y)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Le,at,ze,Xe,be,tt,lt,$e,U,P,te,pe,Me,fe,De,Ae,Ge,We,Ce,qe,Be,Ye,Re,ft;function G(){Le=new g6(z),Le.init(),Ye=new JT(z,Le),at=new c6(z,Le,e,Ye),ze=new KT(z,Le),at.reversedDepthBuffer&&p&&ze.buffers.depth.setReversed(!0),Xe=new x6(z),be=new UT,tt=new ZT(z,Le,ze,be,at,Ye,Xe),lt=new h6(S),$e=new m6(S),U=new sw(z),Re=new a6(z,U),P=new _6(z,U,Xe,Re),te=new S6(z,P,U,Xe),Ce=new y6(z,at,tt),Ae=new u6(be),pe=new NT(S,lt,$e,Le,at,Re,Ae),Me=new i8(S,be),fe=new zT,De=new WT(Le),We=new o6(S,lt,$e,ze,te,d,l),Ge=new $T(S,te,at),ft=new s8(z,Xe,at,ze),qe=new l6(z,Le,Xe),Be=new v6(z,Le,Xe),Xe.programs=pe.programs,S.capabilities=at,S.extensions=Le,S.properties=be,S.renderLists=fe,S.shadowMap=Ge,S.state=ze,S.info=Xe}G();const Se=new n8(S,z);this.xr=Se,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const L=Le.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){const L=Le.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(L){L!==void 0&&(B=L,this.setSize(J,se,!1))},this.getSize=function(L){return L.set(J,se)},this.setSize=function(L,Y,ie=!0){if(Se.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}J=L,se=Y,t.width=Math.floor(L*B),t.height=Math.floor(Y*B),ie===!0&&(t.style.width=L+"px",t.style.height=Y+"px"),this.setViewport(0,0,L,Y)},this.getDrawingBufferSize=function(L){return L.set(J*B,se*B).floor()},this.setDrawingBufferSize=function(L,Y,ie){J=L,se=Y,B=ie,t.width=Math.floor(L*ie),t.height=Math.floor(Y*ie),this.setViewport(0,0,L,Y)},this.getCurrentViewport=function(L){return L.copy(N)},this.getViewport=function(L){return L.copy(X)},this.setViewport=function(L,Y,ie,oe){L.isVector4?X.set(L.x,L.y,L.z,L.w):X.set(L,Y,ie,oe),ze.viewport(N.copy(X).multiplyScalar(B).round())},this.getScissor=function(L){return L.copy(de)},this.setScissor=function(L,Y,ie,oe){L.isVector4?de.set(L.x,L.y,L.z,L.w):de.set(L,Y,ie,oe),ze.scissor(H.copy(de).multiplyScalar(B).round())},this.getScissorTest=function(){return ye},this.setScissorTest=function(L){ze.setScissorTest(ye=L)},this.setOpaqueSort=function(L){ge=L},this.setTransparentSort=function(L){F=L},this.getClearColor=function(L){return L.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor(...arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha(...arguments)},this.clear=function(L=!0,Y=!0,ie=!0){let oe=0;if(L){let K=!1;if(O!==null){const we=O.texture.format;K=we===Ad||we===Td||we===wd}if(K){const we=O.texture.type,Ue=we===bi||we===Gs||we===ul||we===fl||we===bd||we===Md,Ze=We.getClearColor(),je=We.getClearAlpha(),st=Ze.r,ct=Ze.g,Je=Ze.b;Ue?(m[0]=st,m[1]=ct,m[2]=Je,m[3]=je,z.clearBufferuiv(z.COLOR,0,m)):(x[0]=st,x[1]=ct,x[2]=Je,x[3]=je,z.clearBufferiv(z.COLOR,0,x))}else oe|=z.COLOR_BUFFER_BIT}Y&&(oe|=z.DEPTH_BUFFER_BIT),ie&&(oe|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(oe)},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",Oe,!1),t.removeEventListener("webglcontextrestored",ke,!1),t.removeEventListener("webglcontextcreationerror",Te,!1),We.dispose(),fe.dispose(),De.dispose(),be.dispose(),lt.dispose(),$e.dispose(),te.dispose(),Re.dispose(),ft.dispose(),pe.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",sr),Se.removeEventListener("sessionend",Ju),Ri.stop()};function Oe(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function ke(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const L=Xe.autoReset,Y=Ge.enabled,ie=Ge.autoUpdate,oe=Ge.needsUpdate,K=Ge.type;G(),Xe.autoReset=L,Ge.enabled=Y,Ge.autoUpdate=ie,Ge.needsUpdate=oe,Ge.type=K}function Te(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function me(L){const Y=L.target;Y.removeEventListener("dispose",me),Ke(Y)}function Ke(L){ut(L),be.remove(L)}function ut(L){const Y=be.get(L).programs;Y!==void 0&&(Y.forEach(function(ie){pe.releaseProgram(ie)}),L.isShaderMaterial&&pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,Y,ie,oe,K,we){Y===null&&(Y=ee);const Ue=K.isMesh&&K.matrixWorld.determinant()<0,Ze=kl(L,Y,ie,oe,K);ze.setMaterial(oe,Ue);let je=ie.index,st=1;if(oe.wireframe===!0){if(je=P.getWireframeAttribute(ie),je===void 0)return;st=2}const ct=ie.drawRange,Je=ie.attributes.position;let yt=ct.start*st,Rt=(ct.start+ct.count)*st;we!==null&&(yt=Math.max(yt,we.start*st),Rt=Math.min(Rt,(we.start+we.count)*st)),je!==null?(yt=Math.max(yt,0),Rt=Math.min(Rt,je.count)):Je!=null&&(yt=Math.max(yt,0),Rt=Math.min(Rt,Je.count));const Qt=Rt-yt;if(Qt<0||Qt===1/0)return;Re.setup(K,oe,Ze,ie,je);let Nt,Ut=qe;if(je!==null&&(Nt=U.get(je),Ut=Be,Ut.setIndex(Nt)),K.isMesh)oe.wireframe===!0?(ze.setLineWidth(oe.wireframeLinewidth*le()),Ut.setMode(z.LINES)):Ut.setMode(z.TRIANGLES);else if(K.isLine){let ot=oe.linewidth;ot===void 0&&(ot=1),ze.setLineWidth(ot*le()),K.isLineSegments?Ut.setMode(z.LINES):K.isLineLoop?Ut.setMode(z.LINE_LOOP):Ut.setMode(z.LINE_STRIP)}else K.isPoints?Ut.setMode(z.POINTS):K.isSprite&&Ut.setMode(z.TRIANGLES);if(K.isBatchedMesh)if(K._multiDrawInstances!==null)jo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ut.renderMultiDrawInstances(K._multiDrawStarts,K._multiDrawCounts,K._multiDrawCount,K._multiDrawInstances);else if(Le.get("WEBGL_multi_draw"))Ut.renderMultiDraw(K._multiDrawStarts,K._multiDrawCounts,K._multiDrawCount);else{const ot=K._multiDrawStarts,en=K._multiDrawCounts,bt=K._multiDrawCount,Un=je?U.get(je).bytesPerElement:1,Qi=be.get(oe).currentProgram.getUniforms();for(let Fn=0;Fn<bt;Fn++)Qi.setValue(z,"_gl_DrawID",Fn),Ut.render(ot[Fn]/Un,en[Fn])}else if(K.isInstancedMesh)Ut.renderInstances(yt,Qt,K.count);else if(ie.isInstancedBufferGeometry){const ot=ie._maxInstanceCount!==void 0?ie._maxInstanceCount:1/0,en=Math.min(ie.instanceCount,ot);Ut.renderInstances(yt,Qt,en)}else Ut.render(yt,Qt)};function Ot(L,Y,ie){L.transparent===!0&&L.side===Si&&L.forceSinglePass===!1?(L.side=er,L.needsUpdate=!0,Fr(L,Y,ie),L.side=cs,L.needsUpdate=!0,Fr(L,Y,ie),L.side=Si):Fr(L,Y,ie)}this.compile=function(L,Y,ie=null){ie===null&&(ie=L),_=De.get(ie),_.init(Y),E.push(_),ie.traverseVisible(function(K){K.isLight&&K.layers.test(Y.layers)&&(_.pushLight(K),K.castShadow&&_.pushShadow(K))}),L!==ie&&L.traverseVisible(function(K){K.isLight&&K.layers.test(Y.layers)&&(_.pushLight(K),K.castShadow&&_.pushShadow(K))}),_.setupLights();const oe=new Set;return L.traverse(function(K){if(!(K.isMesh||K.isPoints||K.isLine||K.isSprite))return;const we=K.material;if(we)if(Array.isArray(we))for(let Ue=0;Ue<we.length;Ue++){const Ze=we[Ue];Ot(Ze,ie,K),oe.add(Ze)}else Ot(we,ie,K),oe.add(we)}),_=E.pop(),oe},this.compileAsync=function(L,Y,ie=null){const oe=this.compile(L,Y,ie);return new Promise(K=>{function we(){if(oe.forEach(function(Ue){be.get(Ue).currentProgram.isReady()&&oe.delete(Ue)}),oe.size===0){K(L);return}setTimeout(we,10)}Le.get("KHR_parallel_shader_compile")!==null?we():setTimeout(we,10)})};let dt=null;function ai(L){dt&&dt(L)}function sr(){Ri.stop()}function Ju(){Ri.start()}const Ri=new hv;Ri.setAnimationLoop(ai),typeof self<"u"&&Ri.setContext(self),this.setAnimationLoop=function(L){dt=L,Se.setAnimationLoop(L),L===null?Ri.stop():Ri.start()},Se.addEventListener("sessionstart",sr),Se.addEventListener("sessionend",Ju),this.render=function(L,Y){if(Y!==void 0&&Y.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;if(L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Y.parent===null&&Y.matrixWorldAutoUpdate===!0&&Y.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(Y),Y=Se.getCamera()),L.isScene===!0&&L.onBeforeRender(S,L,Y,O),_=De.get(L,E.length),_.init(Y),E.push(_),Z.multiplyMatrices(Y.projectionMatrix,Y.matrixWorldInverse),Ee.setFromProjectionMatrix(Z,Mi,Y.reversedDepth),re=this.localClippingEnabled,V=Ae.init(this.clippingPlanes,re),v=fe.get(L,w.length),v.init(),w.push(v),Se.enabled===!0&&Se.isPresenting===!0){const we=S.xr.getDepthSensingMesh();we!==null&&wa(we,Y,-1/0,S.sortObjects)}wa(L,Y,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ge,F),Pe=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,Pe&&We.addToRenderList(v,L),this.info.render.frame++,V===!0&&Ae.beginShadows();const ie=_.state.shadowsArray;Ge.render(ie,L,Y),V===!0&&Ae.endShadows(),this.info.autoReset===!0&&this.info.reset();const oe=v.opaque,K=v.transmissive;if(_.setupLights(),Y.isArrayCamera){const we=Y.cameras;if(K.length>0)for(let Ue=0,Ze=we.length;Ue<Ze;Ue++){const je=we[Ue];Ta(oe,K,L,je)}Pe&&We.render(L);for(let Ue=0,Ze=we.length;Ue<Ze;Ue++){const je=we[Ue];Qu(v,L,je,je.viewport)}}else K.length>0&&Ta(oe,K,L,Y),Pe&&We.render(L),Qu(v,L,Y);O!==null&&q===0&&(tt.updateMultisampleRenderTarget(O),tt.updateRenderTargetMipmap(O)),L.isScene===!0&&L.onAfterRender(S,L,Y),Re.resetDefaultState(),T=-1,I=null,E.pop(),E.length>0?(_=E[E.length-1],V===!0&&Ae.setGlobalState(S.clippingPlanes,_.state.camera)):_=null,w.pop(),w.length>0?v=w[w.length-1]:v=null};function wa(L,Y,ie,oe){if(L.visible===!1)return;if(L.layers.test(Y.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(Y);else if(L.isLight)_.pushLight(L),L.castShadow&&_.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Ee.intersectsSprite(L)){oe&&xe.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Z);const Ue=te.update(L),Ze=L.material;Ze.visible&&v.push(L,Ue,Ze,ie,xe.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||Ee.intersectsObject(L))){const Ue=te.update(L),Ze=L.material;if(oe&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),xe.copy(L.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),xe.copy(Ue.boundingSphere.center)),xe.applyMatrix4(L.matrixWorld).applyMatrix4(Z)),Array.isArray(Ze)){const je=Ue.groups;for(let st=0,ct=je.length;st<ct;st++){const Je=je[st],yt=Ze[Je.materialIndex];yt&&yt.visible&&v.push(L,Ue,yt,ie,xe.z,Je)}}else Ze.visible&&v.push(L,Ue,Ze,ie,xe.z,null)}}const we=L.children;for(let Ue=0,Ze=we.length;Ue<Ze;Ue++)wa(we[Ue],Y,ie,oe)}function Qu(L,Y,ie,oe){const K=L.opaque,we=L.transmissive,Ue=L.transparent;_.setupLightsView(ie),V===!0&&Ae.setGlobalState(S.clippingPlanes,ie),oe&&ze.viewport(N.copy(oe)),K.length>0&&ws(K,Y,ie),we.length>0&&ws(we,Y,ie),Ue.length>0&&ws(Ue,Y,ie),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function Ta(L,Y,ie,oe){if((ie.isScene===!0?ie.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[oe.id]===void 0&&(_.state.transmissionRenderTarget[oe.id]=new js(1,1,{generateMipmaps:!0,type:Le.has("EXT_color_buffer_half_float")||Le.has("EXT_color_buffer_float")?hl:bi,minFilter:Hs,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ct.workingColorSpace}));const we=_.state.transmissionRenderTarget[oe.id],Ue=oe.viewport||N;we.setSize(Ue.z*S.transmissionResolutionScale,Ue.w*S.transmissionResolutionScale);const Ze=S.getRenderTarget(),je=S.getActiveCubeFace(),st=S.getActiveMipmapLevel();S.setRenderTarget(we),S.getClearColor(Q),ae=S.getClearAlpha(),ae<1&&S.setClearColor(16777215,.5),S.clear(),Pe&&We.render(ie);const ct=S.toneMapping;S.toneMapping=hs;const Je=oe.viewport;if(oe.viewport!==void 0&&(oe.viewport=void 0),_.setupLightsView(oe),V===!0&&Ae.setGlobalState(S.clippingPlanes,oe),ws(L,ie,oe),tt.updateMultisampleRenderTarget(we),tt.updateRenderTargetMipmap(we),Le.has("WEBGL_multisampled_render_to_texture")===!1){let yt=!1;for(let Rt=0,Qt=Y.length;Rt<Qt;Rt++){const Nt=Y[Rt],Ut=Nt.object,ot=Nt.geometry,en=Nt.material,bt=Nt.group;if(en.side===Si&&Ut.layers.test(oe.layers)){const Un=en.side;en.side=er,en.needsUpdate=!0,Aa(Ut,ie,oe,ot,en,bt),en.side=Un,en.needsUpdate=!0,yt=!0}}yt===!0&&(tt.updateMultisampleRenderTarget(we),tt.updateRenderTargetMipmap(we))}S.setRenderTarget(Ze,je,st),S.setClearColor(Q,ae),Je!==void 0&&(oe.viewport=Je),S.toneMapping=ct}function ws(L,Y,ie){const oe=Y.isScene===!0?Y.overrideMaterial:null;for(let K=0,we=L.length;K<we;K++){const Ue=L[K],Ze=Ue.object,je=Ue.geometry,st=Ue.group;let ct=Ue.material;ct.allowOverride===!0&&oe!==null&&(ct=oe),Ze.layers.test(ie.layers)&&Aa(Ze,Y,ie,je,ct,st)}}function Aa(L,Y,ie,oe,K,we){L.onBeforeRender(S,Y,ie,oe,K,we),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),K.onBeforeRender(S,Y,ie,oe,L,we),K.transparent===!0&&K.side===Si&&K.forceSinglePass===!1?(K.side=er,K.needsUpdate=!0,S.renderBufferDirect(ie,Y,oe,K,L,we),K.side=cs,K.needsUpdate=!0,S.renderBufferDirect(ie,Y,oe,K,L,we),K.side=Si):S.renderBufferDirect(ie,Y,oe,K,L,we),L.onAfterRender(S,Y,ie,oe,K,we)}function Fr(L,Y,ie){Y.isScene!==!0&&(Y=ee);const oe=be.get(L),K=_.state.lights,we=_.state.shadowsArray,Ue=K.state.version,Ze=pe.getParameters(L,K.state,we,Y,ie),je=pe.getProgramCacheKey(Ze);let st=oe.programs;oe.environment=L.isMeshStandardMaterial?Y.environment:null,oe.fog=Y.fog,oe.envMap=(L.isMeshStandardMaterial?$e:lt).get(L.envMap||oe.environment),oe.envMapRotation=oe.environment!==null&&L.envMap===null?Y.environmentRotation:L.envMapRotation,st===void 0&&(L.addEventListener("dispose",me),st=new Map,oe.programs=st);let ct=st.get(je);if(ct!==void 0){if(oe.currentProgram===ct&&oe.lightsStateVersion===Ue)return th(L,Ze),ct}else Ze.uniforms=pe.getUniforms(L),L.onBeforeCompile(Ze,S),ct=pe.acquireProgram(Ze,je),st.set(je,ct),oe.uniforms=Ze.uniforms;const Je=oe.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Je.clippingPlanes=Ae.uniform),th(L,Ze),oe.needsLights=jn(L),oe.lightsStateVersion=Ue,oe.needsLights&&(Je.ambientLightColor.value=K.state.ambient,Je.lightProbe.value=K.state.probe,Je.directionalLights.value=K.state.directional,Je.directionalLightShadows.value=K.state.directionalShadow,Je.spotLights.value=K.state.spot,Je.spotLightShadows.value=K.state.spotShadow,Je.rectAreaLights.value=K.state.rectArea,Je.ltc_1.value=K.state.rectAreaLTC1,Je.ltc_2.value=K.state.rectAreaLTC2,Je.pointLights.value=K.state.point,Je.pointLightShadows.value=K.state.pointShadow,Je.hemisphereLights.value=K.state.hemi,Je.directionalShadowMap.value=K.state.directionalShadowMap,Je.directionalShadowMatrix.value=K.state.directionalShadowMatrix,Je.spotShadowMap.value=K.state.spotShadowMap,Je.spotLightMatrix.value=K.state.spotLightMatrix,Je.spotLightMap.value=K.state.spotLightMap,Je.pointShadowMap.value=K.state.pointShadowMap,Je.pointShadowMatrix.value=K.state.pointShadowMatrix),oe.currentProgram=ct,oe.uniformsList=null,ct}function eh(L){if(L.uniformsList===null){const Y=L.currentProgram.getUniforms();L.uniformsList=Du.seqWithValue(Y.seq,L.uniforms)}return L.uniformsList}function th(L,Y){const ie=be.get(L);ie.outputColorSpace=Y.outputColorSpace,ie.batching=Y.batching,ie.batchingColor=Y.batchingColor,ie.instancing=Y.instancing,ie.instancingColor=Y.instancingColor,ie.instancingMorph=Y.instancingMorph,ie.skinning=Y.skinning,ie.morphTargets=Y.morphTargets,ie.morphNormals=Y.morphNormals,ie.morphColors=Y.morphColors,ie.morphTargetsCount=Y.morphTargetsCount,ie.numClippingPlanes=Y.numClippingPlanes,ie.numIntersection=Y.numClipIntersection,ie.vertexAlphas=Y.vertexAlphas,ie.vertexTangents=Y.vertexTangents,ie.toneMapping=Y.toneMapping}function kl(L,Y,ie,oe,K){Y.isScene!==!0&&(Y=ee),tt.resetTextureUnits();const we=Y.fog,Ue=oe.isMeshStandardMaterial?Y.environment:null,Ze=O===null?S.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Ho,je=(oe.isMeshStandardMaterial?$e:lt).get(oe.envMap||Ue),st=oe.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ct=!!ie.attributes.tangent&&(!!oe.normalMap||oe.anisotropy>0),Je=!!ie.morphAttributes.position,yt=!!ie.morphAttributes.normal,Rt=!!ie.morphAttributes.color;let Qt=hs;oe.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Qt=S.toneMapping);const Nt=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Ut=Nt!==void 0?Nt.length:0,ot=be.get(oe),en=_.state.lights;if(V===!0&&(re===!0||L!==I)){const Rn=L===I&&oe.id===T;Ae.setState(oe,L,Rn)}let bt=!1;oe.version===ot.__version?(ot.needsLights&&ot.lightsStateVersion!==en.state.version||ot.outputColorSpace!==Ze||K.isBatchedMesh&&ot.batching===!1||!K.isBatchedMesh&&ot.batching===!0||K.isBatchedMesh&&ot.batchingColor===!0&&K.colorTexture===null||K.isBatchedMesh&&ot.batchingColor===!1&&K.colorTexture!==null||K.isInstancedMesh&&ot.instancing===!1||!K.isInstancedMesh&&ot.instancing===!0||K.isSkinnedMesh&&ot.skinning===!1||!K.isSkinnedMesh&&ot.skinning===!0||K.isInstancedMesh&&ot.instancingColor===!0&&K.instanceColor===null||K.isInstancedMesh&&ot.instancingColor===!1&&K.instanceColor!==null||K.isInstancedMesh&&ot.instancingMorph===!0&&K.morphTexture===null||K.isInstancedMesh&&ot.instancingMorph===!1&&K.morphTexture!==null||ot.envMap!==je||oe.fog===!0&&ot.fog!==we||ot.numClippingPlanes!==void 0&&(ot.numClippingPlanes!==Ae.numPlanes||ot.numIntersection!==Ae.numIntersection)||ot.vertexAlphas!==st||ot.vertexTangents!==ct||ot.morphTargets!==Je||ot.morphNormals!==yt||ot.morphColors!==Rt||ot.toneMapping!==Qt||ot.morphTargetsCount!==Ut)&&(bt=!0):(bt=!0,ot.__version=oe.version);let Un=ot.currentProgram;bt===!0&&(Un=Fr(oe,Y,K));let Qi=!1,Fn=!1,Ts=!1;const $t=Un.getUniforms(),Xn=ot.uniforms;if(ze.useProgram(Un.program)&&(Qi=!0,Fn=!0,Ts=!0),oe.id!==T&&(T=oe.id,Fn=!0),Qi||I!==L){ze.buffers.depth.getReversed()&&L.reversedDepth!==!0&&(L._reversedDepth=!0,L.updateProjectionMatrix()),$t.setValue(z,"projectionMatrix",L.projectionMatrix),$t.setValue(z,"viewMatrix",L.matrixWorldInverse);const zn=$t.map.cameraPosition;zn!==void 0&&zn.setValue(z,he.setFromMatrixPosition(L.matrixWorld)),at.logarithmicDepthBuffer&&$t.setValue(z,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(oe.isMeshPhongMaterial||oe.isMeshToonMaterial||oe.isMeshLambertMaterial||oe.isMeshBasicMaterial||oe.isMeshStandardMaterial||oe.isShaderMaterial)&&$t.setValue(z,"isOrthographic",L.isOrthographicCamera===!0),I!==L&&(I=L,Fn=!0,Ts=!0)}if(K.isSkinnedMesh){$t.setOptional(z,K,"bindMatrix"),$t.setOptional(z,K,"bindMatrixInverse");const Rn=K.skeleton;Rn&&(Rn.boneTexture===null&&Rn.computeBoneTexture(),$t.setValue(z,"boneTexture",Rn.boneTexture,tt))}K.isBatchedMesh&&($t.setOptional(z,K,"batchingTexture"),$t.setValue(z,"batchingTexture",K._matricesTexture,tt),$t.setOptional(z,K,"batchingIdTexture"),$t.setValue(z,"batchingIdTexture",K._indirectTexture,tt),$t.setOptional(z,K,"batchingColorTexture"),K._colorsTexture!==null&&$t.setValue(z,"batchingColorTexture",K._colorsTexture,tt));const or=ie.morphAttributes;if((or.position!==void 0||or.normal!==void 0||or.color!==void 0)&&Ce.update(K,ie,Un),(Fn||ot.receiveShadow!==K.receiveShadow)&&(ot.receiveShadow=K.receiveShadow,$t.setValue(z,"receiveShadow",K.receiveShadow)),oe.isMeshGouraudMaterial&&oe.envMap!==null&&(Xn.envMap.value=je,Xn.flipEnvMap.value=je.isCubeTexture&&je.isRenderTargetTexture===!1?-1:1),oe.isMeshStandardMaterial&&oe.envMap===null&&Y.environment!==null&&(Xn.envMapIntensity.value=Y.environmentIntensity),Fn&&($t.setValue(z,"toneMappingExposure",S.toneMappingExposure),ot.needsLights&&Bl(Xn,Ts),we&&oe.fog===!0&&Me.refreshFogUniforms(Xn,we),Me.refreshMaterialUniforms(Xn,oe,B,se,_.state.transmissionRenderTarget[L.id]),Du.upload(z,eh(ot),Xn,tt)),oe.isShaderMaterial&&oe.uniformsNeedUpdate===!0&&(Du.upload(z,eh(ot),Xn,tt),oe.uniformsNeedUpdate=!1),oe.isSpriteMaterial&&$t.setValue(z,"center",K.center),$t.setValue(z,"modelViewMatrix",K.modelViewMatrix),$t.setValue(z,"normalMatrix",K.normalMatrix),$t.setValue(z,"modelMatrix",K.matrixWorld),oe.isShaderMaterial||oe.isRawShaderMaterial){const Rn=oe.uniformsGroups;for(let zn=0,Hl=Rn.length;zn<Hl;zn++){const es=Rn[zn];ft.update(es,Un),ft.bind(es,Un)}}return Un}function Bl(L,Y){L.ambientLightColor.needsUpdate=Y,L.lightProbe.needsUpdate=Y,L.directionalLights.needsUpdate=Y,L.directionalLightShadows.needsUpdate=Y,L.pointLights.needsUpdate=Y,L.pointLightShadows.needsUpdate=Y,L.spotLights.needsUpdate=Y,L.spotLightShadows.needsUpdate=Y,L.rectAreaLights.needsUpdate=Y,L.hemisphereLights.needsUpdate=Y}function jn(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(L,Y,ie){const oe=be.get(L);oe.__autoAllocateDepthBuffer=L.resolveDepthBuffer===!1,oe.__autoAllocateDepthBuffer===!1&&(oe.__useRenderToTexture=!1),be.get(L.texture).__webglTexture=Y,be.get(L.depthTexture).__webglTexture=oe.__autoAllocateDepthBuffer?void 0:ie,oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(L,Y){const ie=be.get(L);ie.__webglFramebuffer=Y,ie.__useDefaultFramebuffer=Y===void 0};const Mt=z.createFramebuffer();this.setRenderTarget=function(L,Y=0,ie=0){O=L,A=Y,q=ie;let oe=!0,K=null,we=!1,Ue=!1;if(L){const je=be.get(L);if(je.__useDefaultFramebuffer!==void 0)ze.bindFramebuffer(z.FRAMEBUFFER,null),oe=!1;else if(je.__webglFramebuffer===void 0)tt.setupRenderTarget(L);else if(je.__hasExternalTextures)tt.rebindTextures(L,be.get(L.texture).__webglTexture,be.get(L.depthTexture).__webglTexture);else if(L.depthBuffer){const Je=L.depthTexture;if(je.__boundDepthTexture!==Je){if(Je!==null&&be.has(Je)&&(L.width!==Je.image.width||L.height!==Je.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");tt.setupDepthRenderbuffer(L)}}const st=L.texture;(st.isData3DTexture||st.isDataArrayTexture||st.isCompressedArrayTexture)&&(Ue=!0);const ct=be.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(ct[Y])?K=ct[Y][ie]:K=ct[Y],we=!0):L.samples>0&&tt.useMultisampledRTT(L)===!1?K=be.get(L).__webglMultisampledFramebuffer:Array.isArray(ct)?K=ct[ie]:K=ct,N.copy(L.viewport),H.copy(L.scissor),W=L.scissorTest}else N.copy(X).multiplyScalar(B).floor(),H.copy(de).multiplyScalar(B).floor(),W=ye;if(ie!==0&&(K=Mt),ze.bindFramebuffer(z.FRAMEBUFFER,K)&&oe&&ze.drawBuffers(L,K),ze.viewport(N),ze.scissor(H),ze.setScissorTest(W),we){const je=be.get(L.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+Y,je.__webglTexture,ie)}else if(Ue){const je=Y;for(let st=0;st<L.textures.length;st++){const ct=be.get(L.textures[st]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+st,ct.__webglTexture,ie,je)}}else if(L!==null&&ie!==0){const je=be.get(L.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,je.__webglTexture,ie)}T=-1},this.readRenderTargetPixels=function(L,Y,ie,oe,K,we,Ue,Ze=0){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let je=be.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){ze.bindFramebuffer(z.FRAMEBUFFER,je);try{const st=L.textures[Ze],ct=st.format,Je=st.type;if(!at.textureFormatReadable(ct)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!at.textureTypeReadable(Je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Y>=0&&Y<=L.width-oe&&ie>=0&&ie<=L.height-K&&(L.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ze),z.readPixels(Y,ie,oe,K,Ye.convert(ct),Ye.convert(Je),we))}finally{const st=O!==null?be.get(O).__webglFramebuffer:null;ze.bindFramebuffer(z.FRAMEBUFFER,st)}}},this.readRenderTargetPixelsAsync=async function(L,Y,ie,oe,K,we,Ue,Ze=0){if(!(L&&L.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let je=be.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je)if(Y>=0&&Y<=L.width-oe&&ie>=0&&ie<=L.height-K){ze.bindFramebuffer(z.FRAMEBUFFER,je);const st=L.textures[Ze],ct=st.format,Je=st.type;if(!at.textureFormatReadable(ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!at.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const yt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,yt),z.bufferData(z.PIXEL_PACK_BUFFER,we.byteLength,z.STREAM_READ),L.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ze),z.readPixels(Y,ie,oe,K,Ye.convert(ct),Ye.convert(Je),0);const Rt=O!==null?be.get(O).__webglFramebuffer:null;ze.bindFramebuffer(z.FRAMEBUFFER,Rt);const Qt=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await LM(z,Qt,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,yt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,we),z.deleteBuffer(yt),z.deleteSync(Qt),we}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(L,Y=null,ie=0){const oe=Math.pow(2,-ie),K=Math.floor(L.image.width*oe),we=Math.floor(L.image.height*oe),Ue=Y!==null?Y.x:0,Ze=Y!==null?Y.y:0;tt.setTexture2D(L,0),z.copyTexSubImage2D(z.TEXTURE_2D,ie,0,0,Ue,Ze,K,we),ze.unbindTexture()};const Vl=z.createFramebuffer(),nh=z.createFramebuffer();this.copyTextureToTexture=function(L,Y,ie=null,oe=null,K=0,we=null){we===null&&(K!==0?(jo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),we=K,K=0):we=0);let Ue,Ze,je,st,ct,Je,yt,Rt,Qt;const Nt=L.isCompressedTexture?L.mipmaps[we]:L.image;if(ie!==null)Ue=ie.max.x-ie.min.x,Ze=ie.max.y-ie.min.y,je=ie.isBox3?ie.max.z-ie.min.z:1,st=ie.min.x,ct=ie.min.y,Je=ie.isBox3?ie.min.z:0;else{const or=Math.pow(2,-K);Ue=Math.floor(Nt.width*or),Ze=Math.floor(Nt.height*or),L.isDataArrayTexture?je=Nt.depth:L.isData3DTexture?je=Math.floor(Nt.depth*or):je=1,st=0,ct=0,Je=0}oe!==null?(yt=oe.x,Rt=oe.y,Qt=oe.z):(yt=0,Rt=0,Qt=0);const Ut=Ye.convert(Y.format),ot=Ye.convert(Y.type);let en;Y.isData3DTexture?(tt.setTexture3D(Y,0),en=z.TEXTURE_3D):Y.isDataArrayTexture||Y.isCompressedArrayTexture?(tt.setTexture2DArray(Y,0),en=z.TEXTURE_2D_ARRAY):(tt.setTexture2D(Y,0),en=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Y.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Y.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Y.unpackAlignment);const bt=z.getParameter(z.UNPACK_ROW_LENGTH),Un=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Qi=z.getParameter(z.UNPACK_SKIP_PIXELS),Fn=z.getParameter(z.UNPACK_SKIP_ROWS),Ts=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,Nt.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Nt.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,st),z.pixelStorei(z.UNPACK_SKIP_ROWS,ct),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Je);const $t=L.isDataArrayTexture||L.isData3DTexture,Xn=Y.isDataArrayTexture||Y.isData3DTexture;if(L.isDepthTexture){const or=be.get(L),Rn=be.get(Y),zn=be.get(or.__renderTarget),Hl=be.get(Rn.__renderTarget);ze.bindFramebuffer(z.READ_FRAMEBUFFER,zn.__webglFramebuffer),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,Hl.__webglFramebuffer);for(let es=0;es<je;es++)$t&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,be.get(L).__webglTexture,K,Je+es),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,be.get(Y).__webglTexture,we,Qt+es)),z.blitFramebuffer(st,ct,Ue,Ze,yt,Rt,Ue,Ze,z.DEPTH_BUFFER_BIT,z.NEAREST);ze.bindFramebuffer(z.READ_FRAMEBUFFER,null),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(K!==0||L.isRenderTargetTexture||be.has(L)){const or=be.get(L),Rn=be.get(Y);ze.bindFramebuffer(z.READ_FRAMEBUFFER,Vl),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,nh);for(let zn=0;zn<je;zn++)$t?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,or.__webglTexture,K,Je+zn):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,or.__webglTexture,K),Xn?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Rn.__webglTexture,we,Qt+zn):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Rn.__webglTexture,we),K!==0?z.blitFramebuffer(st,ct,Ue,Ze,yt,Rt,Ue,Ze,z.COLOR_BUFFER_BIT,z.NEAREST):Xn?z.copyTexSubImage3D(en,we,yt,Rt,Qt+zn,st,ct,Ue,Ze):z.copyTexSubImage2D(en,we,yt,Rt,st,ct,Ue,Ze);ze.bindFramebuffer(z.READ_FRAMEBUFFER,null),ze.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else Xn?L.isDataTexture||L.isData3DTexture?z.texSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,ot,Nt.data):Y.isCompressedArrayTexture?z.compressedTexSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,Nt.data):z.texSubImage3D(en,we,yt,Rt,Qt,Ue,Ze,je,Ut,ot,Nt):L.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,we,yt,Rt,Ue,Ze,Ut,ot,Nt.data):L.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,we,yt,Rt,Nt.width,Nt.height,Ut,Nt.data):z.texSubImage2D(z.TEXTURE_2D,we,yt,Rt,Ue,Ze,Ut,ot,Nt);z.pixelStorei(z.UNPACK_ROW_LENGTH,bt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Un),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Qi),z.pixelStorei(z.UNPACK_SKIP_ROWS,Fn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,Ts),we===0&&Y.generateMipmaps&&z.generateMipmap(en),ze.unbindTexture()},this.copyTextureToTexture3D=function(L,Y,ie=null,oe=null,K=0){return jo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(L,Y,ie,oe,K)},this.initRenderTarget=function(L){be.get(L).__webglFramebuffer===void 0&&tt.setupRenderTarget(L)},this.initTexture=function(L){L.isCubeTexture?tt.setTextureCube(L,0):L.isData3DTexture?tt.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?tt.setTexture2DArray(L,0):tt.setTexture2D(L,0),ze.unbindTexture()},this.resetState=function(){A=0,q=0,O=null,ze.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Mi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ct._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ct._getUnpackColorSpace()}}class a8 extends Pl{constructor(e){super(e)}load(e,t,r,i){const s=this,o=new X4(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},r,i)}parse(e){return new l8(e)}}class l8{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const r=[],i=c8(e,t,this.data);for(let s=0,o=i.length;s<o;s++)r.push(...i[s].toShapes());return r}}function c8(n,e,t){const r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[];let a=0,l=0;for(let c=0;c<r.length;c++){const h=r[c];if(h===`
3910
3910
  `)a=0,l-=s;else{const f=u8(h,i,a,l,t);a+=f.offsetX,o.push(f.path)}}return o}function u8(n,e,t,r,i){const s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}const o=new nw;let a,l,c,h,f,p,d,m;if(s.o){const x=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let v=0,_=x.length;v<_;)switch(x[v++]){case"m":a=x[v++]*e+t,l=x[v++]*e+r,o.moveTo(a,l);break;case"l":a=x[v++]*e+t,l=x[v++]*e+r,o.lineTo(a,l);break;case"q":c=x[v++]*e+t,h=x[v++]*e+r,f=x[v++]*e+t,p=x[v++]*e+r,o.quadraticCurveTo(f,p,c,h);break;case"b":c=x[v++]*e+t,h=x[v++]*e+r,f=x[v++]*e+t,p=x[v++]*e+r,d=x[v++]*e+t,m=x[v++]*e+r,o.bezierCurveTo(f,p,d,m,c,h);break}}return{offsetX:s.ha*e,path:o}}const h8={glyphs:{ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},cssFontWeight:"normal",ascender:1189,underlinePosition:-100,cssFontStyle:"normal",boundingBox:{yMin:-334,xMin:-111,yMax:1189,xMax:1672},resolution:1e3,original_font_information:{postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r
3911
3911
  \r
3912
3912
  Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r
@@ -3919,7 +3919,7 @@ This License becomes null and void to the extent applicable to Fonts or Font Sof
3919
3919
  \r
3920
3920
  The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r
3921
3921
  \r
3922
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50};function f8(n,e,t,r){const i=t.properties.get("step"),s=t.properties.has("color")?He([t.properties.get("color")]):t.properties.get("colors"),o=new Dt;o.name="streak";let a=0;for(let l=0;l<=e;l+=i){const c=[new j(0,0,-l),new j(n,0,-l)],h=new nr().setFromPoints(c),f=s.get(a%s.size),p=new Eu({color:f}),d=new El(h,p);o.add(d),o.add(new El(h,p)),a++}return o}function d8(n,e,t,r){const i=t.properties.get("step"),s=t.properties.has("color")?He([t.properties.get("color")]):t.properties.get("colors"),o=new Dt;o.name="streak";let a=0;for(let l=0;l<=n;l+=i){const c=[new j(l,0,0),new j(l,0,-e)],h=new nr().setFromPoints(c),f=s.get(a%s.size),p=new Eu({color:f});o.add(new El(h,p)),a++}return o}function p8(n){const e=new Dt;e.name="grid",new a8().parse(h8);const{grids:r,width:i,height:s}=n;return r.forEach(o=>{switch(o.type){case"horizontal-streak":e.add(f8(i,s,o));break;case"vertical-streak":e.add(d8(i,s,o));break}}),e.position.y=-1,e}function m8(n){n&&n.dispose&&n.dispose()}function g8(n){n&&n.dispose&&n.dispose()}function Bv(n){if(n){if(Array.isArray(n)){n.forEach(e=>Bv(e));return}for(const e in n){const t=n[e];t instanceof Dn&&g8(t)}n.dispose()}}function Vv(n){(n instanceof Tn||n instanceof tw||n instanceof El)&&(m8(n.geometry),Bv(n.material),n.geometry=null,n.material=null)}function _8(n){n.traverse(e=>{Vv(e)})}function Uu(n){n.traverse(e=>{Vv(e)})}function v8(n,e,t){const r={sceneGraph:{unit:n.unit,layers:{},busyResources:{layers:{}},width:n.width,height:n.height,LODs:{}},plan:new Dt,grid:p8(n),boundingBox:new wi};r.plan.name="plan",r.grid.name="grid",r.boundingBox.setFromObject(r.grid);let i=[];return n.layers.forEach(s=>{(s.id===n.selectedLayer||s.visible)&&(i=i.concat(Fu(s,r,n,e,t)))}),Promise.all(i).then(()=>Yi(r)),r}function Fu(n,e,t,r,i){const s=[];return e.sceneGraph.layers[n.id]={id:n.id,lines:{},holes:{},areas:{},items:{},visible:n.visible,altitude:n.altitude},e.sceneGraph.busyResources.layers[n.id]={id:n.id,lines:{},holes:{},areas:{},items:{}},n.lines.forEach(o=>{s.push(so(t,e,n,o.id,i,r.linesActions)),o.holes.forEach(a=>{s.push(ma(t,e,n,a,i,r.holesActions))})}),n.areas.forEach(o=>{s.push(Ol(t,e,n,o.id,i,r.areaActions))}),n.items.forEach(o=>{s.push(zu(t,e,n,o.id,i,r.itemsActions))}),s}function x8(n,e,t,r,i,s){const o=r.map(l=>({op:l.op,path:l.path.split("/"),value:l.value}));let a=A8(o,e,t);return a=a.filter(({path:l})=>l[3]!=="selected"),a=a.filter(({path:l})=>l[1]!=="groups"),a.forEach(({op:l,path:c,value:h})=>{if(c[1]==="layers"){const f=e.getIn(["layers",c[2]]);if(c.length===3&&l==="remove")S8(c[2],n);else if(c.length>3)switch(l){case"replace":Ll(c,f,n,i,e,t,s);break;case"add":E8(c,f,n,i,e,t,s);break;case"remove":y8(c,f,n,i,e,t,s);break}}else if(c[1]==="selectedLayer"){const f=h,p=e.getIn(["layers",f]);if(!p.visible){const m=Fu(p,n,e,i,s);Promise.all(m).then(()=>Yi(n))}const d=n.sceneGraph.layers[(t==null?void 0:t.selectedLayer)??""];if(d&&!d.visible){for(let m in d.lines)$i(n,d.id,m);for(let m in d.areas)Es(n,d.id,m);for(let m in d.items)bs(n,d.id,m);for(let m in d.holes)Xi(n,d.id,m)}}}),n}function Ll(n,e,t,r,i,s,o){let a=[];switch(n[3]){case"vertices":if(n[5]!=="selected"){const d=e.getIn(["vertices",n[4]]);if((n[5]==="x"||n[5]==="y")&&(d.lines.forEach(m=>{const x=s.getIn(["layers",e.id,"lines",m,"holes"]);return x&&x.forEach(v=>{Ll([0,0,0,"holes",v,"selected"],e,t,r,i,s,o)}),Ll([0,0,0,"lines",m],e,t,r,i,s,o)}),d.areas.forEach(m=>Ll([0,0,0,"areas",m],e,t,r,i,s,o))),n[5]==="areas"){let m=d.getIn(["areas",~~n[6]]);Ll([0,0,0,"areas",m],e,t,r,i,s,o)}}break;case"holes":const l=e.getIn(["holes",n[4]]);if(o.getElement(l.type).updateRender3D)a.push(b8(i,s,t,e,n[4],n.slice(5),o,r.holesActions,()=>Xi(t,e.id,l.id),()=>ma(i,t,e,l.id,o,r.holesActions)));else{let d=l.line;n[5]==="selected"?(Xi(t,e.id,l.id),a.push(ma(i,t,e,l.id,o,r.holesActions))):(e.getIn(["lines",d,"holes"]).forEach(m=>{Xi(t,e.id,m)}),$i(t,e.id,d),a.push(so(i,t,e,d,o,r.linesActions)),e.getIn(["lines",d,"holes"]).forEach(m=>{a.push(ma(i,t,e,m,o,r.holesActions))}))}break;case"lines":const c=e.getIn(["lines",n[4]]);o.getElement(c.type).updateRender3D?a.push(M8(i,s,t,e,n[4],n.slice(5),o,r.linesActions,()=>$i(t,e.id,n[4]),()=>so(i,t,e,n[4],o,r.linesActions))):($i(t,e.id,n[4]),a.push(so(i,t,e,n[4],o,r.linesActions)));break;case"areas":const h=e.getIn(["areas",n[4]]);o.getElement(h.type).updateRender3D?a.push(w8(i,s,t,e,n[4],n.slice(5),o,r.areaActions,()=>Es(t,e.id,n[4]),()=>Ol(i,t,e,n[4],o,r.areaActions))):(t.sceneGraph.layers[e.id].areas[n[4]]&&Es(t,e.id,n[4]),a.push(Ol(i,t,e,n[4],o,r.areaActions)));break;case"items":const f=e.getIn(["items",n[4]]);o.getElement(f.type).updateRender3D?a.push(T8(i,s,t,e,n[4],n.slice(5),o,r.itemsActions,()=>bs(t,e.id,n[4]),()=>zu(i,t,e,n[4],o,r.itemsActions))):(bs(t,e.id,n[4]),a.push(zu(i,t,e,n[4],o,r.itemsActions)));break;case"visible":if(e.visible)a=a.concat(Fu(e,t,i,r,o));else{let d=t.sceneGraph.layers[e.id];for(let m in d.lines)$i(t,e.id,m);for(let m in d.areas)Es(t,e.id,m);for(let m in d.items)bs(t,e.id,m);for(let m in d.holes)Xi(t,e.id,m)}break;case"opacity":case"altitude":let p=t.sceneGraph.layers[e.id];for(let d in p.lines)$i(t,e.id,d);for(let d in p.areas)Es(t,e.id,d);for(let d in p.items)bs(t,e.id,d);for(let d in p.holes)Xi(t,e.id,d);a=a.concat(Fu(e,t,i,r,o))}Promise.all(a).then(()=>Yi(t))}function y8(n,e,t,r,i,s,o){let a=[];switch(n[3]){case"lines":const l=n[4];s.getIn(["layers",e.id,"lines",l,"holes"]).forEach(c=>{Xi(t,e.id,c)}),$i(t,e.id,l),n.length>5&&(a.push(so(i,t,e,l,o,r.linesActions)),e.getIn(["lines",l,"holes"]).forEach(c=>{a.push(ma(i,t,e,c,o,r.holesActions))}));break;case"areas":n.length===5&&Es(t,e.id,n[4]);break;case"items":n.length===5&&bs(t,e.id,n[4]);break}Promise.all(a).then(()=>Yi(t))}function S8(n,e){let t=e.sceneGraph.layers[n];for(let r in t.lines)$i(e,n,r);for(let r in t.areas)Es(e,n,r);for(let r in t.items)bs(e,n,r);for(let r in t.holes)Xi(e,n,r);delete e.sceneGraph.layers[n]}function Xi(n,e,t){if(n.sceneGraph.busyResources.layers[e].holes[t]){setTimeout(()=>Xi(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].holes[t]=!0;let r=n.sceneGraph.layers[e].holes[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].holes[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].holes[t]=!1}function $i(n,e,t){if(n.sceneGraph.busyResources.layers[e].lines[t]){setTimeout(()=>$i(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].lines[t]=!0;let r=n.sceneGraph.layers[e].lines[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].lines[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].lines[t]=!1}function Es(n,e,t){if(n.sceneGraph.busyResources.layers[e].areas[t]){setTimeout(()=>Es(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].areas[t]=!0;let r=n.sceneGraph.layers[e].areas[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].areas[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].areas[t]=!1}function bs(n,e,t){if(n.sceneGraph.busyResources.layers[e].items[t]){setTimeout(()=>bs(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].items[t]=!0;let r=n.sceneGraph.layers[e].items[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].items[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].items[t]=!1}function E8(n,e,t,r,i,s,o){if(n.length===5){let a=null,l=null;switch(n[3]){case"lines":a=so,l=r.linesActions;break;case"areas":a=Ol,l=r.areaActions;break;case"items":a=zu,l=r.itemsActions;break;case"holes":a=ma,l=r.holesActions;break}a&&a(i,t,e,n[4],o,l).then(()=>Yi(t))}}function ma(n,e,t,r,i,s){const o=t.getIn(["holes",r]);return i.getElement(o.type).render3D(o,t,n).then(a=>{a instanceof yu&&(e.sceneGraph.LODs[r]=a);const l=new Dt;l.name="pivot",l.add(a);const c=t.getIn(["lines",o.line]);let h=t.vertices.get(c.vertices.get(0)),f=t.vertices.get(c.vertices.get(1)),p=o.offset;if(h.x>f.x){const S=h;h=f,f=S,p=1-p}let d=Math.sqrt(Math.pow(h.x-f.x,2)+Math.pow(h.y-f.y,2)),m=Math.asin((f.y-h.y)/d),x=new wi().setFromObject(l),v=[(x.max.x-x.min.x)/2+x.min.x,(x.max.y-x.min.y)/2+x.min.y,(x.max.z-x.min.z)/2+x.min.z],_=o.properties.getIn(["altitude","length"]),w=o.properties.getIn(["height","length"]);l.rotation.y=m,l.position.x=h.x+d*p*Math.cos(m)-v[2]*Math.sin(m),l.position.y=_+w/2-v[1]+t.altitude,l.position.z=-h.y-d*p*Math.sin(m)-v[2]*Math.cos(m),e.plan.add(l),e.sceneGraph.layers[t.id].holes[o.id]=l,ku(l,()=>s.selectHole(t.id,o.id));let E=t.opacity;o.selected&&(E=1),Bu(l,E)})}function b8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["holes",i]),f=e.getIn(["layers",r.id,"holes",i]),p=t.sceneGraph.layers[r.id].holes[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function so(n,e,t,r,i,s){if(e.sceneGraph.busyResources.layers[t.id].lines[r]){setTimeout(()=>so(n,e,t,r,i,s),100);return}e.sceneGraph.busyResources.layers[t.id].lines[r]=!0;const o=t.getIn(["lines",r]);let a=t.vertices.get(o.vertices.get(0)),l=t.vertices.get(o.vertices.get(1));if(a.x>l.x){let c=a;a=l,l=c}return i.getElement(o.type).render3D(o,t,n).then(c=>{c instanceof yu&&(e.sceneGraph.LODs[o.id]=c);let h=new Dt;h.name="pivot",h.add(c),h.position.x=a.x,h.position.y=t.altitude,h.position.z=-a.y,e.plan.add(h),e.sceneGraph.layers[t.id].lines[r]=h,ku(h,()=>s.selectLine(t.id,o.id));let f=t.opacity;o.selected&&(f=1),Bu(h,f),e.sceneGraph.busyResources.layers[t.id].lines[r]=!1})}function M8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["lines",i]),f=e.getIn(["layers",r.id,"lines",i]),p=t.sceneGraph.layers[r.id].lines[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function Ol(n,e,t,r,i,s){if(e.sceneGraph.busyResources.layers[t.id].areas[r]){setTimeout(()=>Ol(n,e,t,r,i,s),100);return}e.sceneGraph.busyResources.layers[t.id].areas[r]=!0;const o=t.getIn(["areas",r]),a=()=>s.selectArea(t.id,r);return i.getElement(o.type).render3D(o,t,n).then(l=>{l instanceof yu&&(e.sceneGraph.LODs[r]=l);let c=new Dt;c.name="pivot",c.add(l),c.position.y=t.altitude,e.plan.add(c),e.sceneGraph.layers[t.id].areas[r]=c,ku(c,a);let h=t.opacity;o.selected&&(h=1),Bu(c,h),e.sceneGraph.busyResources.layers[t.id].areas[r]=!1})}function w8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["areas",i]),f=e.getIn(["layers",r.id,"areas",i]),p=t.sceneGraph.layers[r.id].areas[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function zu(n,e,t,r,i,s){const o=t.getIn(["items",r]);return i.getElement(o.type).render3D(o,t,n).then(a=>{a instanceof yu&&(e.sceneGraph.LODs[r]=a);const l=new Dt;l.name="pivot",l.add(a),l.rotation.y=o.rotation*Math.PI/180,l.position.x=o.x,l.position.y=t.altitude,l.position.z=-o.y,ku(a,()=>{s.selectItem(t.id,o.id)});let c=t.opacity;o.selected&&(c=1),Bu(l,c),e.plan.add(l),e.sceneGraph.layers[t.id].items[o.id]=l})}function T8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["items",i]),f=e.getIn(["layers",r.id,"items",i]),p=t.sceneGraph.layers[r.id].items[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function ku(n,e){n.traverse(t=>{(t instanceof Tn||t.isMesh)&&(t.interact=e)})}function Bu(n,e){n.traverse(t=>{t instanceof Tn&&(t.material instanceof Array?t.material.forEach(r=>{r.transparent=!0,r.maxOpacity?r.opacity=Math.min(r.maxOpacity,e):r.opacity&&r.opacity>e&&(r.maxOpacity=r.opacity,r.opacity=e)}):(t.material.transparent=!0,t.material.maxOpacity?t.material.opacity=Math.min(t.material.maxOpacity,e):t.material.opacity&&t.material.opacity>e&&(t.material.maxOpacity=t.material.opacity,t.material.opacity=e)))})}function Yi(n){let e=new wi().setFromObject(n.plan);if(isFinite(e.max.x)&&isFinite(e.min.x)&&isFinite(e.max.y)&&isFinite(e.min.y)&&isFinite(e.max.z)&&isFinite(e.min.z)){let t=new j((e.max.x-e.min.x)/2+e.min.x,(e.max.y-e.min.y)/2+e.min.y,(e.max.z-e.min.z)/2+e.min.z);n.plan.position.sub(t),n.grid.position.sub(t),e.min.sub(t),e.max.sub(t),n.boundingBox=e}}function A8(n,e,t){return C8(R8(P8(n)),e,t)}function C8(n,e,t){let r,i;for(i=0;i<n.length&&!r;i++)n[i].path[1]==="selectedLayer"&&(r=n[i]);return r&&!e.getIn(["layers",t.selectedLayer,"visible"])?n.filter(({op:s,path:o})=>!(o[o.length-1]==="selected"&&o[1]==="layers"&&o[2]===t.selectedLayer)&&!(s==="remove"&&o.indexOf(t.selectedLayer)!==-1)):n}function R8(n,e,t){const r={};return n.forEach(({path:i})=>{i[5]==="selected"&&(r[i[4]]=i[4])}),n.filter(({path:i})=>i[5]==="properties"?!r[i[4]]:!0)}function P8(n,e,t){const r={};return n.filter(({path:i})=>i[5]==="properties"?r[i[4]]?!1:r[i[4]]=!0:i[5]!=="misc")}const Hv={type:"change"},$p={type:"start"},Gv={type:"end"},Vu=new au,Wv=new Ss,I8=Math.cos(70*PM.DEG2RAD),En=new j,rr=2*Math.PI,zt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yp=1e-6;class L8 extends rw{constructor(e,t=null){super(e,t),this.state=zt.NONE,this.target=new j,this.cursor=new j,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Uo.ROTATE,MIDDLE:Uo.DOLLY,RIGHT:Uo.PAN},this.touches={ONE:Fo.ROTATE,TWO:Fo.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new j,this._lastQuaternion=new ds,this._lastTargetPosition=new j,this._quat=new ds().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new cv,this._sphericalDelta=new cv,this._scale=1,this._panOffset=new j,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new j,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=q8.bind(this),this._onPointerDown=O8.bind(this),this._onPointerUp=D8.bind(this),this._onContextMenu=V8.bind(this),this._onMouseWheel=F8.bind(this),this._onKeyDown=z8.bind(this),this._onTouchStart=k8.bind(this),this._onTouchMove=B8.bind(this),this._onMouseDown=N8.bind(this),this._onMouseMove=U8.bind(this),this._interceptControlDown=H8.bind(this),this._interceptControlUp=G8.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Hv),this.update(),this.state=zt.NONE}update(e=null){const t=this.object.position;En.copy(t).sub(this.target),En.applyQuaternion(this._quat),this._spherical.setFromVector3(En),this.autoRotate&&this.state===zt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=rr:r>Math.PI&&(r-=rr),i<-Math.PI?i+=rr:i>Math.PI&&(i-=rr),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(En.setFromSpherical(this._spherical),En.applyQuaternion(this._quatInverse),t.copy(this.target).add(En),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 o=null;if(this.object.isPerspectiveCamera){const a=En.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=En.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Vu.origin.copy(this.object.position),Vu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Vu.direction))<I8?this.object.lookAt(this.target):(Wv.setFromNormalAndCoplanarPoint(this.object.up,this.target),Vu.intersectPlane(Wv,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Yp||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yp||this._lastTargetPosition.distanceToSquared(this.target)>Yp?(this.dispatchEvent(Hv),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?rr/60*this.autoRotateSpeed*e:rr/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){En.setFromMatrixColumn(t,0),En.multiplyScalar(-e),this._panOffset.add(En)}_panUp(e,t){this.screenSpacePanning===!0?En.setFromMatrixColumn(t,1):(En.setFromMatrixColumn(t,0),En.crossVectors(this.object.up,En)),En.multiplyScalar(e),this._panOffset.add(En)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;En.copy(i).sub(this.target);let s=En.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*t*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.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 r=this.domElement.getBoundingClientRect(),i=e-r.left,s=t-r.top,o=r.width,a=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*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(rr*this._rotateDelta.x/t.clientHeight),this._rotateUp(rr*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(rr*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(-rr*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(rr*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(-rr*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),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_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 r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(rr*this._rotateDelta.x/t.clientHeight),this._rotateUp(rr*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),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(r,i)}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),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),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 o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_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;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ne,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function O8(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function q8(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function D8(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Gv),this.state=zt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function N8(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Uo.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=zt.DOLLY;break;case Uo.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=zt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=zt.ROTATE}break;case Uo.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=zt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=zt.PAN}break;default:this.state=zt.NONE}this.state!==zt.NONE&&this.dispatchEvent($p)}function U8(n){switch(this.state){case zt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case zt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case zt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function F8(n){this.enabled===!1||this.enableZoom===!1||this.state!==zt.NONE||(n.preventDefault(),this.dispatchEvent($p),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Gv))}function z8(n){this.enabled!==!1&&this._handleKeyDown(n)}function k8(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case Fo.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=zt.TOUCH_ROTATE;break;case Fo.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=zt.TOUCH_PAN;break;default:this.state=zt.NONE}break;case 2:switch(this.touches.TWO){case Fo.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=zt.TOUCH_DOLLY_PAN;break;case Fo.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=zt.TOUCH_DOLLY_ROTATE;break;default:this.state=zt.NONE}break;default:this.state=zt.NONE}this.state!==zt.NONE&&this.dispatchEvent($p)}function B8(n){switch(this._trackPointer(n),this.state){case zt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case zt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case zt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case zt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=zt.NONE}}function V8(n){this.enabled!==!1&&n.preventDefault()}function H8(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function G8(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ga=n=>Bt(n),_a=n=>Bn(n),va=n=>gt.isRecord(n),Ki=(n,e,t)=>n==="remove"?{op:n,path:e}:{op:n,path:e,value:t},W8=(n,e,t)=>{const r=[];for(let i=0;i<n;i++){r[i]=new Array(e);for(let s=0;s<e;s++)r[i][s]=t}return r},Kp=gt({op:"=",val:null}),j8=gt({op:"!=",val:null,newVal:null}),X8=(n,e)=>{const t=$8(n,e);return Y8(t,n,e,n.size??0,e.size??0)},$8=(n,e)=>{const t=n.size??0,r=e.size??0,i=W8(t+1,r+1,0);for(let s=0;s<t;s++)for(let o=0;o<r;o++)Kt(n.get(s),e.get(o))?i[s+1][o+1]=i[s][o]+1:i[s+1][o+1]=Math.max(i[s+1][o],i[s][o+1]);return i},Y8=(n,e,t,r,i)=>{const s=[];let o=r-1,a=i-1;for(;o>=0||a>=0;)o>=0&&a>=0&&Kt(e.get(o),t.get(a))?(s.push(new Kp({op:"=",val:e.get(o)})),o--,a--):o>=0&&a>=0&&o===a&&!Kt(e.get(o),t.get(a))?(s.push(new j8({val:e.get(o),newVal:t.get(o)})),o--,a--):a>=0&&(o===-1||n[o+1][a]>=n[o][a+1])?(s.push(new Kp({op:"+",val:t.get(a)})),a--):o>=0&&(a===-1||n[o+1][a]<n[o][a+1])&&(s.push(new Kp({op:"-",val:e.get(o)})),o--);return s.reverse()},K8=/\//g,Z8=/~/g,oo=n=>{if(typeof n=="number")return n.toString();if(typeof n!="string")throw new Error(`param str (${String(n)}) is not a string`);return n.replace(Z8,"~0").replace(K8,"~1")},xr=(n,e)=>`${n}/${e}`,ql=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;const i=_a(n)&&_a(e);let s=null,o=null;return n.forEach&&n.forEach((a,l)=>{if(e.has(l))if(va(a)&&va(e.get(l)))r=r.concat(Zp(a,e.get(l),xr(t,oo(l))));else if(ga(a)&&ga(e.get(l)))r=r.concat(ql(a,e.get(l),xr(t,oo(l))));else if(_a(a)&&_a(e.get(l)))r=r.concat(jv(a,e.get(l),xr(t,oo(l))));else{const c=e.get?e.get(l):e;a!==c&&r.push(Ki("replace",xr(t,oo(l)),c))}else i?(o=s!=null&&Number(s)+1===l?o:l,r.push(Ki("remove",xr(t,oo(o)))),s=l):r.push(Ki("remove",xr(t,oo(l))))}),e.forEach((a,l)=>{n.has&&!n.has(l)&&r.push(Ki("add",xr(t,oo(l)),a))}),r},Zp=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;const i=n.toSeq().toMap(),s=e.toSeq().toMap();return r=r.concat(ql(i,s,t)),r},jv=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;if((n.count()+1)*(e.count()+1)>=1e4)return ql(n,e,t);const i=X8(n,e);let s=0;return i.forEach(o=>{if(o.op==="=")s++;else if(o.op==="!="){if(va(o.val)&&va(o.newVal)){const a=Zp(o.val,o.newVal,xr(t,String(s)));r=r.concat(a)}else if(ga(o.val)&&ga(o.newVal)){const a=ql(o.val,o.newVal,xr(t,String(s)));r=r.concat(a)}else r.push(Ki("replace",xr(t,String(s)),o.newVal));s++}else o.op==="+"?(r.push(Ki("add",xr(t,String(s)),o.val)),s++):o.op==="-"&&r.push(Ki("remove",xr(t,String(s))))}),r},J8=(n,e,t="")=>n===e?[]:[Ki("replace",xr(t,""),e)],Q8=(n,e,t="")=>Kt(n,e)?He():n!=e&&(n==null||e==null)?At([Ki("replace","/",e)]):_a(n)&&_a(e)?At(jv(n,e)):va(n)&&va(e)?At(Zp(n,e)):ga(n)&&ga(e)?At(ql(n,e)):At(J8(n,e,t));class eA extends ne.Component{constructor(t){super(t);ht(this,"canvasWrapperRef",ne.createRef());ht(this,"renderer");ht(this,"scene3D",null);ht(this,"camera",null);ht(this,"orbitControls",null);ht(this,"planData");ht(this,"renderingID",0);ht(this,"width");ht(this,"height");ht(this,"lastMousePosition",{});ht(this,"mouseDownEvent");ht(this,"mouseUpEvent");this.width=t.width,this.height=t.height,this.renderer=new o8({preserveDrawingBuffer:!0,antialias:!0})}componentDidMount(){const{state:t,actions:r}=this.props,i={areaActions:r.areaActions,holesActions:r.holesActions,itemsActions:r.itemsActions,linesActions:r.linesActions,projectActions:r.projectActions},s=t.scene,o=this.canvasWrapperRef.current,a=new r4;this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.outputColorSpace=mr,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(new Et(Vc.white));const l=v8(s,i,this.props.catalog);a.add(l.plan),a.add(l.grid);const c=this.width/this.height,h=new vr(45,c,1,3e5);a.add(h);const f=-(l.boundingBox.max.x-l.boundingBox.min.x)/2,p=(l.boundingBox.max.y-l.boundingBox.min.y)/2*10,d=(l.boundingBox.max.z-l.boundingBox.min.z)/2;h.position.set(f,p,d),h.up.set(0,1,0);const m=new K4(Vc.white,.3);m.position.set(f,p,d),a.add(m),a.add(new ov(11513775)),a.add(new ov(16777215,.7));const x=new J4(16777215,.6);x.position.set(100,200,100),x.castShadow=!0,a.add(x);const v=[l.plan],_=new Ne,w=new ew;this.mouseDownEvent=A=>{this.lastMousePosition.x=A.offsetX/this.width*2-1,this.lastMousePosition.y=-A.offsetY/this.height*2+1},this.mouseUpEvent=A=>{var q,O;if(A.preventDefault(),_.x=A.offsetX/this.width*2-1,_.y=-(A.offsetY/this.height)*2+1,Math.abs(_.x-(this.lastMousePosition.x??0))<=.02&&Math.abs(_.y-(this.lastMousePosition.y??0))<=.02){w.setFromCamera(_,h);const T=w.intersectObjects(v,!0);T.length>0&&!isNaN(T[0].distance)?(O=(q=T[0].object).interact)==null||O.call(q):this.props.actions.projectActions.unselectAll()}},this.renderer.domElement.addEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.addEventListener("mouseup",this.mouseUpEvent),o&&o.appendChild(this.renderer.domElement);const E=new L8(h,this.renderer.domElement);E.enableDamping=!0,E.dampingFactor=.05;const S=new Dt;S.name="spotLightTarget",S.position.copy(E.target),a.add(S),m.target=S;const b=()=>{E.update(),m.position.copy(h.position),S.position.copy(E.target);for(const A in l.sceneGraph.LODs)l.sceneGraph.LODs[A].update(h);this.renderer.render(a,h),this.renderingID=requestAnimationFrame(b)};b(),this.orbitControls=E,this.camera=h,this.scene3D=a,this.planData=l}componentWillUnmount(){var t;cancelAnimationFrame(this.renderingID),(t=this.orbitControls)==null||t.dispose(),this.renderer.domElement.removeEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.removeEventListener("mouseup",this.mouseUpEvent),this.scene3D&&(_8(this.scene3D),this.scene3D.remove(this.planData.plan),this.scene3D.remove(this.planData.grid)),this.scene3D=null,this.planData=null,this.camera=null,this.orbitControls=null,this.renderer.renderLists.dispose()}componentDidUpdate(t){const{width:r,height:i}=this.props;if(this.width=r,this.height=i,this.camera&&(this.camera.aspect=r/i,this.camera.updateProjectionMatrix()),t.state.scene!==this.props.state.scene){const s=Q8(t.state.scene,this.props.state.scene),o={areaActions:this.props.actions.areaActions,holesActions:this.props.actions.holesActions,itemsActions:this.props.actions.itemsActions,linesActions:this.props.actions.linesActions,projectActions:this.props.actions.projectActions};x8(this.planData,this.props.state.scene,t.state.scene,s.toJS(),o,this.props.catalog)}this.renderer.setSize(r,i)}render(){return ne.createElement("div",{ref:this.canvasWrapperRef})}}const tA={color:Lt.PRIMARY_COLOR.alt,fontWeight:300};function nA({children:n,style:e={},...t}){return R.jsx("h1",{style:{...tA,...e},...t,children:n})}const rA={padding:"0 20px",overflowY:"auto"};function iA({children:n,width:e,height:t,style:r={}}){return R.jsx("div",{style:{width:e,height:t,...rA,...r},onWheel:i=>i.stopPropagation(),children:n})}var Xv={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$v=ne.createContext&&ne.createContext(Xv),sA=["attr","size","title"];function oA(n,e){if(n==null)return{};var t=aA(n,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(t[r]=n[r])}return t}function aA(n,e){if(n==null)return{};var t={};for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){if(e.indexOf(r)>=0)continue;t[r]=n[r]}return t}function Hu(){return Hu=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Hu.apply(this,arguments)}function Yv(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Gu(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yv(Object(t),!0).forEach(function(r){lA(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Yv(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function lA(n,e,t){return e=cA(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function cA(n){var e=uA(n,"string");return typeof e=="symbol"?e:e+""}function uA(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Kv(n){return n&&n.map((e,t)=>ne.createElement(e.tag,Gu({key:t},e.attr),Kv(e.child)))}function un(n){return e=>ne.createElement(hA,Hu({attr:Gu({},n.attr)},e),Kv(n.child))}function hA(n){var e=t=>{var{attr:r,size:i,title:s}=n,o=oA(n,sA),a=i||t.size||"1em",l;return t.className&&(l=t.className),n.className&&(l=(l?l+" ":"")+n.className),ne.createElement("svg",Hu({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,o,{className:l,style:Gu(Gu({color:n.color||t.color},t.style),n.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&ne.createElement("title",null,s),n.children)};return $v!==void 0?ne.createElement($v.Consumer,null,t=>e(t)):e(Xv)}function fA(n){return un({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"},child:[]}]})(n)}function dA(n){return un({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"},child:[]}]})(n)}function pA(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(n)}function mA(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(n)}function gA(n){return un({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(n)}function _A(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(n)}const Zv={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},vA={...Zv,background:Lt.SECONDARY_COLOR.main},Jv={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},xA={...Jv,color:Lt.COLORS.white},yA={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},Qv={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:Lt.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},SA={...Qv,transform:"scale(1.2)"},EA={marginTop:"1.5em",color:Lt.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},bA={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},MA={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},wA={display:"inline-block",background:"#337ab7",color:Lt.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},ex=({element:n})=>{const[e,t]=ne.useState(!1),{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=Ht(),a=()=>{switch(n.prototype){case"lines":r(n.name);break;case"items":i(n.name);break;case"holes":s(n.name);break}o(n)};return R.jsxs("div",{style:e?vA:Zv,onClick:a,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[R.jsx("b",{style:e?xA:Jv,children:n.info.title}),R.jsx("div",{style:yA,children:R.jsx("div",{style:{...e?SA:Qv,backgroundImage:"url("+n.info.image+")"},children:e?R.jsx(mA,{style:EA}):null})}),R.jsx("ul",{style:MA,children:n.info.tag.map((l,c)=>R.jsx("li",{style:wA,children:l},c))}),R.jsx("div",{style:bA,children:n.info.description})]})};function TA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(n)}function AA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 0 1 7.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"},child:[]}]})(n)}function CA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"},child:[]}]})(n)}function RA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(n)}function tx(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(n)}function PA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(n)}const IA={margin:"1.5em",display:"flex"},nx={fontSize:"20px",cursor:"pointer"},LA={...nx,fontWeight:"bolder",color:Lt.SECONDARY_COLOR.main},OA={fill:Lt.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},qA=({names:n})=>{let e=n.map((t,r)=>{let i=r===n.length-1;return R.jsxs("div",{style:{display:"flex"},children:[R.jsx("div",{style:i?LA:nx,onClick:t.action||null,children:t.name}),i?null:R.jsx(tx,{style:OA})]},r)});return R.jsx("div",{style:IA,children:e})},rx={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},DA={...rx,background:Lt.SECONDARY_COLOR.main},ix={position:"absolute",color:Lt.COLORS.black,fontSize:"5em",width:"100%"},NA={...ix,color:Lt.SECONDARY_COLOR.main},UA={background:Lt.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},FA=({page:n})=>{const[e,t]=ne.useState(!1),{goBackToCatalogPage:r}=Ht(),i=s=>{r(s)};return R.jsx("div",{style:e?DA:rx,onClick:()=>i(n.name),onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:R.jsx("div",{style:UA,children:R.jsx(RA,{style:e?NA:ix})})})},zA={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},kA={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},sx={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},BA={width:"8em",display:"inline-block"},VA={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},HA={...sx,padding:"0.2em 0.625em"},GA={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:Lt.PRIMARY_COLOR.alt,color:Lt.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},WA=({width:n,height:e,style:t,catalog:r})=>{const{planner:i,goBackToCatalogPage:s,selectToolDrawingHole:o,selectToolDrawingItem:a,selectToolDrawingLine:l,pushLastSelectedCatalogElementToHistory:c}=Ht();let h=i.catalog.page;const f=r.getCategory(h);let p=f.elements.filter(T=>T.info.visibility?T.info.visibility.catalog:!0);const[d,m]=ne.useState(""),[x,v]=ne.useState([]);let _=null;if(h!=="root"){let T=[];i.catalog.path.forEach(I=>{T.push({name:r.getCategory(I).label,action:()=>s(I)})}),T.push({name:f.label,action:""}),_=R.jsx(qA,{names:T})}let w=i.catalog.path.size,E=w>0?R.jsx(FA,{page:r.categories[i.catalog.path.get(w-1)]},w):null,S=i.get("selectedElementsHistory"),b=S.map((T,I)=>R.jsx("div",{style:GA,title:T.name,onClick:()=>O(T),children:T.name},I));const A=T=>{let I=[];for(let N=0;N<T.length;N++){let H=T[N];I=I.concat(H.elements),H.categories.length&&(I=I.concat(A(H.categories)))}return I},q=T=>{let I=p.concat(A(f.categories)),N=[];if(T!=""){let H=new RegExp(T,"i");for(let W=0;W<I.length;W++)H.test(I[W].info.title)&&N.push(I[W])}m(T),v(N)},O=T=>{switch(T.prototype){case"lines":l(T.name);break;case"items":a(T.name);break;case"holes":o(T.name);break}c(T)};return R.jsxs(iA,{width:n,height:e,style:{...zA,...t},children:[R.jsx(nA,{children:"Catalog"}),_,R.jsxs("div",{style:sx,children:[R.jsx("span",{style:BA,children:"Search Element"}),R.jsx("input",{type:"text",style:VA,onChange:T=>{q(T.target.value)}})]}),S.size?R.jsxs("div",{style:HA,children:[R.jsx("span",{children:"Last Selected"}),b]}):null,R.jsx("div",{style:kA,children:d===""?[E,p.map(T=>R.jsx(ex,{element:T},T.name))]:x.map(T=>R.jsx(ex,{element:T},T.name))})]})},jA={MODE_IDLE:sn,MODE_2D_ZOOM_IN:qs,MODE_2D_ZOOM_OUT:Ds,MODE_2D_PAN:Ns,MODE_WAITING_DRAWING_LINE:Tr,MODE_WAITING_DRAWING_SURFACE:Us,MODE_DRAGGING_LINE:Vr,MODE_DRAGGING_VERTEX:Hr,MODE_DRAGGING_ITEM:Gr,MODE_DRAWING_SURFACE:di,MODE_DRAWING_LINE:Jn,MODE_DRAWING_HOLE:hr,MODE_DRAWING_ITEM:Ar,MODE_DRAGGING_HOLE:Wr,MODE_ROTATING_ITEM:Di};function XA({width:n,height:e,catalog:t}){const r=Ht(),{planner:i}=r,{mode:s}=i;return s===Br?R.jsx(eA,{width:n,height:e,state:i,catalog:t,actions:{areaActions:{selectArea:r.selectArea},holesActions:{selectHole:r.selectHole,selectToolDrawingHole:r.selectToolDrawingHole,updateDrawingHole:r.updateDrawingHole,endDrawingHole:r.endDrawingHole,beginDraggingHole:r.beginDraggingHole,updateDraggingHole:r.updateDraggingHole,endDraggingHole:r.endDraggingHole},itemsActions:{selectItem:r.selectItem,selectToolDrawingItem:r.selectToolDrawingItem,updateDrawingItem:r.updateDrawingItem,endDrawingItem:r.endDrawingItem,beginDraggingItem:r.beginDraggingItem,updateDraggingItem:r.updateDraggingItem,endDraggingItem:r.endDraggingItem,beginRotatingItem:r.beginRotatingItem,updateRotatingItem:r.updateRotatingItem,endRotatingItem:r.endRotatingItem},linesActions:{selectLine:r.selectLine,selectToolDrawingLine:r.selectToolDrawingLine,beginDrawingLine:r.beginDrawingLine,updateDrawingLine:r.updateDrawingLine,endDrawingLine:r.endDrawingLine,beginDraggingLine:r.beginDraggingLine,updateDraggingLine:r.updateDraggingLine,endDraggingLine:r.endDraggingLine},projectActions:{loadProject:r.loadProject,newProject:r.newProject,openCatalog:r.openCatalog,changeCatalogPage:r.changeCatalogPage,goBackToCatalogPage:r.goBackToCatalogPage,selectToolEdit:r.selectToolEdit,unselectAll:r.unselectAll,setProperties:r.setProperties,setItemsAttributes:r.setItemsAttributes,setLinesAttributes:r.setLinesAttributes,setHolesAttributes:r.setHolesAttributes,remove:r.remove,undo:r.undo,rollback:r.rollback,openProjectConfigurator:r.openProjectConfigurator,initCatalog:r.initCatalog,updateMouseCoord:r.updateMouseCoord,updateZoomScale:r.updateZoomScale,toggleSnap:r.toggleSnap,copyProperties:r.copyProperties,pasteProperties:r.pasteProperties,pushLastSelectedCatalogElementToHistory:r.pushLastSelectedCatalogElementToHistory,setAlterateState:r.setAlterateState,setMode:r.setMode,addHorizontalGuide:r.addHorizontalGuide,addVerticalGuide:r.addVerticalGuide,removeHorizontalGuide:r.removeHorizontalGuide,removeVerticalGuide:r.removeVerticalGuide}}}):s===Ao?R.jsx(R.Fragment,{}):s===cf?R.jsx(WA,{width:n,height:e,catalog:t}):jA[s]?R.jsx(Bb,{width:n,height:e,catalog:t}):s===Z0?R.jsx(R.Fragment,{}):null}function $A(n){return un({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM13.5 10.5h-6"},child:[]}]})(n)}function YA(n){return un({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM10.5 7.5v6m3-3h-6"},child:[]}]})(n)}const KA=(n,e,t,r,i)=>r+(i-r)*(n-e)/(t-e),ZA=()=>{const{planner:n,viewer:e}=Ht(),{mode:t,mouse:r,zoom:i}=n,s=o=>{const a=parseInt(W1(i).toFixed());if(a===0&&o==="out"||a===100&&o==="in"||!e)return;const l=e==null?void 0:e.getValue(),c=l.viewerWidth/2,h=l.viewerHeight/2,f=o==="in"?-1:1,p=1.06,d=Math.max(-1,Math.min(1,f)),m=KA(d,-1,1,p,1/p);e.zoom(c,h,m)};if(uf.includes(t))return R.jsx("div",{className:"floor_planner-footerbar right-0 absolute rounded-tl w-auto z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] h-5 select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:R.jsx("div",{className:"relative float-left inline-block",title:"Scene Zoom Level",children:R.jsxs("div",{className:"flex items-center gap-2",children:[R.jsx($A,{className:"inline-block cursor-pointer",size:16,onClick:()=>s("out")})," ",R.jsxs("span",{children:[W1(i).toFixed(),"%"]})," ",R.jsx(YA,{className:"inline-block cursor-pointer",size:16,onClick:()=>s("in")})]})})})};function ox(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=ox(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function JA(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ox(n))&&(r&&(r+=" "),r+=e);return r}const Jp="-",QA=n=>{const e=t7(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{const a=o.split(Jp);return a[0]===""&&a.length!==1&&a.shift(),ax(a,e)||e7(o)},getConflictingClassGroupIds:(o,a)=>{const l=t[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},ax=(n,e)=>{var o;if(n.length===0)return e.classGroupId;const t=n[0],r=e.nextPart.get(t),i=r?ax(n.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=n.join(Jp);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},lx=/^\[(.+)\]$/,e7=n=>{if(lx.test(n)){const e=lx.exec(n)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},t7=n=>{const{theme:e,classGroups:t}=n,r={nextPart:new Map,validators:[]};for(const i in t)Qp(t[i],r,i,e);return r},Qp=(n,e,t,r)=>{n.forEach(i=>{if(typeof i=="string"){const s=i===""?e:cx(e,i);s.classGroupId=t;return}if(typeof i=="function"){if(n7(i)){Qp(i(r),e,t,r);return}e.validators.push({validator:i,classGroupId:t});return}Object.entries(i).forEach(([s,o])=>{Qp(o,cx(e,s),t,r)})})},cx=(n,e)=>{let t=n;return e.split(Jp).forEach(r=>{t.nextPart.has(r)||t.nextPart.set(r,{nextPart:new Map,validators:[]}),t=t.nextPart.get(r)}),t},n7=n=>n.isThemeGetter,r7=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,r=new Map;const i=(s,o)=>{t.set(s,o),e++,e>n&&(e=0,r=t,t=new Map)};return{get(s){let o=t.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){t.has(s)?t.set(s,o):i(s,o)}}},em="!",tm=":",i7=tm.length,s7=n=>{const{prefix:e,experimentalParseClassName:t}=n;let r=i=>{const s=[];let o=0,a=0,l=0,c;for(let m=0;m<i.length;m++){let x=i[m];if(o===0&&a===0){if(x===tm){s.push(i.slice(l,m)),l=m+i7;continue}if(x==="/"){c=m;continue}}x==="["?o++:x==="]"?o--:x==="("?a++:x===")"&&a--}const h=s.length===0?i:i.substring(l),f=o7(h),p=f!==h,d=c&&c>l?c-l:void 0;return{modifiers:s,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:d}};if(e){const i=e+tm,s=r;r=o=>o.startsWith(i)?s(o.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(t){const i=r;r=s=>t({className:s,parseClassName:i})}return r},o7=n=>n.endsWith(em)?n.substring(0,n.length-1):n.startsWith(em)?n.substring(1):n,a7=n=>{const e=Object.fromEntries(n.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(o=>{o[0]==="["||e[o]?(i.push(...s.sort(),o),s=[]):s.push(o)}),i.push(...s.sort()),i}},l7=n=>({cache:r7(n.cacheSize),parseClassName:s7(n),sortModifiers:a7(n),...QA(n)}),c7=/\s+/,u7=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,o=[],a=n.trim().split(c7);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:f,modifiers:p,hasImportantModifier:d,baseClassName:m,maybePostfixModifierPosition:x}=t(h);if(f){l=h+(l.length>0?" "+l:l);continue}let v=!!x,_=r(v?m.substring(0,x):m);if(!_){if(!v){l=h+(l.length>0?" "+l:l);continue}if(_=r(m),!_){l=h+(l.length>0?" "+l:l);continue}v=!1}const w=s(p).join(":"),E=d?w+em:w,S=E+_;if(o.includes(S))continue;o.push(S);const b=i(_,v);for(let A=0;A<b.length;++A){const q=b[A];o.push(E+q)}l=h+(l.length>0?" "+l:l)}return l};function h7(){let n=0,e,t,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=ux(e))&&(r&&(r+=" "),r+=t);return r}const ux=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=ux(n[r]))&&(t&&(t+=" "),t+=e);return t};function f7(n,...e){let t,r,i,s=o;function o(l){const c=e.reduce((h,f)=>f(h),n());return t=l7(c),r=t.cache.get,i=t.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const h=u7(l,t);return i(l,h),h}return function(){return s(h7.apply(null,arguments))}}const bn=n=>{const e=t=>t[n]||[];return e.isThemeGetter=!0,e},hx=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,fx=/^\((?:(\w[\w-]*):)?(.+)\)$/i,d7=/^\d+\/\d+$/,p7=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,m7=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,g7=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_7=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,v7=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xa=n=>d7.test(n),xt=n=>!!n&&!Number.isNaN(Number(n)),Ms=n=>!!n&&Number.isInteger(Number(n)),nm=n=>n.endsWith("%")&&xt(n.slice(0,-1)),Zi=n=>p7.test(n),x7=()=>!0,y7=n=>m7.test(n)&&!g7.test(n),dx=()=>!1,S7=n=>_7.test(n),E7=n=>v7.test(n),b7=n=>!Qe(n)&&!et(n),M7=n=>ya(n,vx,dx),Qe=n=>hx.test(n),ao=n=>ya(n,xx,y7),rm=n=>ya(n,R7,xt),px=n=>ya(n,gx,dx),w7=n=>ya(n,_x,E7),Wu=n=>ya(n,yx,S7),et=n=>fx.test(n),Dl=n=>Sa(n,xx),T7=n=>Sa(n,P7),mx=n=>Sa(n,gx),A7=n=>Sa(n,vx),C7=n=>Sa(n,_x),ju=n=>Sa(n,yx,!0),ya=(n,e,t)=>{const r=hx.exec(n);return r?r[1]?e(r[1]):t(r[2]):!1},Sa=(n,e,t=!1)=>{const r=fx.exec(n);return r?r[1]?e(r[1]):t:!1},gx=n=>n==="position"||n==="percentage",_x=n=>n==="image"||n==="url",vx=n=>n==="length"||n==="size"||n==="bg-size",xx=n=>n==="length",R7=n=>n==="number",P7=n=>n==="family-name",yx=n=>n==="shadow",I7=f7(()=>{const n=bn("color"),e=bn("font"),t=bn("text"),r=bn("font-weight"),i=bn("tracking"),s=bn("leading"),o=bn("breakpoint"),a=bn("container"),l=bn("spacing"),c=bn("radius"),h=bn("shadow"),f=bn("inset-shadow"),p=bn("text-shadow"),d=bn("drop-shadow"),m=bn("blur"),x=bn("perspective"),v=bn("aspect"),_=bn("ease"),w=bn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...S(),et,Qe],A=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto","contain","none"],O=()=>[et,Qe,l],T=()=>[xa,"full","auto",...O()],I=()=>[Ms,"none","subgrid",et,Qe],N=()=>["auto",{span:["full",Ms,et,Qe]},Ms,et,Qe],H=()=>[Ms,"auto",et,Qe],W=()=>["auto","min","max","fr",et,Qe],Q=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ae=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...O()],se=()=>[xa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],B=()=>[n,et,Qe],ge=()=>[...S(),mx,px,{position:[et,Qe]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",A7,M7,{size:[et,Qe]}],de=()=>[nm,Dl,ao],ye=()=>["","none","full",c,et,Qe],Ee=()=>["",xt,Dl,ao],V=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[xt,nm,mx,px],he=()=>["","none",m,et,Qe],xe=()=>["none",xt,et,Qe],ee=()=>["none",xt,et,Qe],Pe=()=>[xt,et,Qe],le=()=>[xa,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Zi],breakpoint:[Zi],color:[x7],container:[Zi],"drop-shadow":[Zi],ease:["in","out","in-out"],font:[b7],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Zi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Zi],shadow:[Zi],spacing:["px",xt],text:[Zi],"text-shadow":[Zi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xa,Qe,et,v]}],container:["container"],columns:[{columns:[xt,Qe,et,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[Ms,"auto",et,Qe]}],basis:[{basis:[xa,"full","auto",a,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[xt,xa,"auto","initial","none",Qe]}],grow:[{grow:["",xt,et,Qe]}],shrink:[{shrink:["",xt,et,Qe]}],order:[{order:[Ms,"first","last","none",et,Qe]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:N()}],"col-start":[{"col-start":H()}],"col-end":[{"col-end":H()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:N()}],"row-start":[{"row-start":H()}],"row-end":[{"row-end":H()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...Q(),"normal"]}],"justify-items":[{"justify-items":[...ae(),"normal"]}],"justify-self":[{"justify-self":["auto",...ae()]}],"align-content":[{content:["normal",...Q()]}],"align-items":[{items:[...ae(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ae(),{baseline:["","last"]}]}],"place-content":[{"place-content":Q()}],"place-items":[{"place-items":[...ae(),"baseline"]}],"place-self":[{"place-self":["auto",...ae()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],w:[{w:[a,"screen",...se()]}],"min-w":[{"min-w":[a,"screen","none",...se()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",t,Dl,ao]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,rm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",nm,Qe]}],"font-family":[{font:[T7,Qe,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,et,Qe]}],"line-clamp":[{"line-clamp":[xt,"none",et,rm]}],leading:[{leading:[s,...O()]}],"list-image":[{"list-image":["none",et,Qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:[xt,"from-font","auto",et,ao]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[xt,"auto",et,Qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Qe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ge()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ms,et,Qe],radial:["",et,Qe],conic:[Ms,et,Qe]},C7,w7]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:de()}],"gradient-via-pos":[{via:de()}],"gradient-to-pos":[{to:de()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:ye()}],"rounded-s":[{"rounded-s":ye()}],"rounded-e":[{"rounded-e":ye()}],"rounded-t":[{"rounded-t":ye()}],"rounded-r":[{"rounded-r":ye()}],"rounded-b":[{"rounded-b":ye()}],"rounded-l":[{"rounded-l":ye()}],"rounded-ss":[{"rounded-ss":ye()}],"rounded-se":[{"rounded-se":ye()}],"rounded-ee":[{"rounded-ee":ye()}],"rounded-es":[{"rounded-es":ye()}],"rounded-tl":[{"rounded-tl":ye()}],"rounded-tr":[{"rounded-tr":ye()}],"rounded-br":[{"rounded-br":ye()}],"rounded-bl":[{"rounded-bl":ye()}],"border-w":[{border:Ee()}],"border-w-x":[{"border-x":Ee()}],"border-w-y":[{"border-y":Ee()}],"border-w-s":[{"border-s":Ee()}],"border-w-e":[{"border-e":Ee()}],"border-w-t":[{"border-t":Ee()}],"border-w-r":[{"border-r":Ee()}],"border-w-b":[{"border-b":Ee()}],"border-w-l":[{"border-l":Ee()}],"divide-x":[{"divide-x":Ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...V(),"hidden","none"]}],"divide-style":[{divide:[...V(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...V(),"none","hidden"]}],"outline-offset":[{"outline-offset":[xt,et,Qe]}],"outline-w":[{outline:["",xt,Dl,ao]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",h,ju,Wu]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",f,ju,Wu]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:Ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[xt,ao]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":Ee()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",p,ju,Wu]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[xt,et,Qe]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[xt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[et,Qe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[xt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ge()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Qe]}],filter:[{filter:["","none",et,Qe]}],blur:[{blur:he()}],brightness:[{brightness:[xt,et,Qe]}],contrast:[{contrast:[xt,et,Qe]}],"drop-shadow":[{"drop-shadow":["","none",d,ju,Wu]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",xt,et,Qe]}],"hue-rotate":[{"hue-rotate":[xt,et,Qe]}],invert:[{invert:["",xt,et,Qe]}],saturate:[{saturate:[xt,et,Qe]}],sepia:[{sepia:["",xt,et,Qe]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Qe]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[xt,et,Qe]}],"backdrop-contrast":[{"backdrop-contrast":[xt,et,Qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",xt,et,Qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[xt,et,Qe]}],"backdrop-invert":[{"backdrop-invert":["",xt,et,Qe]}],"backdrop-opacity":[{"backdrop-opacity":[xt,et,Qe]}],"backdrop-saturate":[{"backdrop-saturate":[xt,et,Qe]}],"backdrop-sepia":[{"backdrop-sepia":["",xt,et,Qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[xt,"initial",et,Qe]}],ease:[{ease:["linear","initial",_,et,Qe]}],delay:[{delay:[xt,et,Qe]}],animate:[{animate:["none",w,et,Qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,et,Qe]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:xe()}],"rotate-x":[{"rotate-x":xe()}],"rotate-y":[{"rotate-y":xe()}],"rotate-z":[{"rotate-z":xe()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":["scale-3d"],skew:[{skew:Pe()}],"skew-x":[{"skew-x":Pe()}],"skew-y":[{"skew-y":Pe()}],transform:[{transform:[et,Qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",et,Qe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",et,Qe]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[xt,Dl,ao,rm]}],stroke:[{stroke:["none",...B()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Nr(...n){return I7(JA(n))}const Sx=({children:n,name:e,...t})=>{const[r,i]=ne.useState(t.opened||!1);return R.jsxs("div",{className:"select-none",style:{borderBottom:"1px solid #5e5e5e"},children:[R.jsxs("div",{className:"flex px-4 pt-2.5 pb-3 items-center gap-1 bg-[#2b2b2b] text-white cursor-pointer",onClick:()=>i(!r),children:[r?R.jsx(fA,{size:16}):R.jsx(dA,{size:16}),R.jsx("span",{className:"text-sm leading-none",children:e})]}),R.jsx("div",{className:Nr("text-[11px] text-[#EBEBEB] border border-[#222222] bg-[#424242]",r?"block":"hidden"),children:n})]})};function si({children:n,style:e,className:t,...r}){return R.jsx("label",{className:Nr("mb-1 text-xs capitalize font-bold text-white block",t),style:e,...r,children:n})}const Ci=({value:n,min:e,max:t,precision:r,onChange:i,onValid:s,onInvalid:o,style:a,placeholder:l})=>{const[c,h]=ne.useState(!0),[f,p]=ne.useState(n);let d=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${r}})?$`);ne.useEffect(()=>{e!==void 0&&!isNaN(e)&&isFinite(e)&&Number(f)<e&&p(e),t&&!isNaN(t)&&isFinite(t)&&Number(f)>t&&p(t)},[e,t,f]);const m=ne.useMemo(()=>parseFloat(String(n)).toFixed(r)!==parseFloat(String(f)).toFixed(r),[n,f,r]),x=v=>{if(v.stopPropagation(),c){let _=f!==""&&f!=="-"?parseFloat(String(f)):0;p(_),i({target:{value:_}})}};return R.jsxs("div",{className:"relative w-full",children:[R.jsx("input",{type:"text",value:d.test(String(f))?f:parseFloat(String(f)).toFixed(r),className:"block text-[13px] text-white h-[35px] w-full px-2 leading-5 rounded border border-[#5e5e5e] bg-[#2b2b2b] outline-none focus:outline-none",style:{...a},onChange:v=>{let _=d.test(v.target.value);_?(p(v.target.value),s&&s(v.nativeEvent)):o&&o(v.nativeEvent),h(_)},onKeyDown:v=>{var _=v.keyCode||v.which;(_==Rr.ENTER||_==Rr.TAB)&&m&&x(v)},placeholder:l}),R.jsx("div",{onClick:v=>{m&&x(v)},title:"Confirm",className:"absolute cursor-pointer w-[2em] h-[2em] text-white top-[0.35em] right-[0.35em] bg-dark-blue",style:{transition:"all 0.1s linear",visibility:m?"visible":"hidden",opacity:m?"1":"0"},children:R.jsx(TA,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},L7={fontSize:"13px",WebkitAppearance:"none"};function im({children:n,style:e,...t}){return R.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] text-white bg-[#5e5e5e]",style:{...L7,...e},...t,children:n})}const sm=({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s})=>{const{planner:o}=Ht(),{mode:a}=o,l=n.get("length")||0,c=n.get("_length")||l;n.get("_unit");const{hook:h,label:f,...p}=r,d=(m,x)=>{let v=Qn(m),_=n.merge({length:v,_length:m,_unit:x});return h?h(_,i,s,o).then(w=>e(w)):e(_)};if(a!==Br)return R.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[R.jsx(si,{children:f}),R.jsxs("div",{className:"w-full flex",children:[R.jsx(Ci,{value:c,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:m=>d(m.target.value,Cr),onValid:t,...p}),R.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:R.jsx(im,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:Cr,onChange:m=>{},children:Q0.map(m=>R.jsx("option",{value:m,children:m},m))})})]})]})},Nl=({style:n,...e})=>R.jsx("input",{className:"block w-full px-2 text-sm leading-5 bg-[#2b2b2b] rounded border border-[#5e5e5e] outline-none h-[35px] text-white",style:{...n},type:"text",...e}),O7=({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i})=>{const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyString w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(Nl,{value:n,onChange:a=>o(a.target.value)})]})},q7=({element:n,attributeFormData:e,onUpdate:t,...r})=>{let i=e.has("name")?e.get("name"):n.name,s=e.has("offsetA")?e.get("offsetA"):n.offsetA,o=e.has("offsetB")?e.get("offsetB"):n.offsetA;return R.jsxs("div",{children:[R.jsx(O7,{value:i,onUpdate:a=>t("name",a),configs:{label:"Nome"},...r}),R.jsx(sm,{value:s,onUpdate:a=>t("offsetA",a),configs:{label:"Offset 1",min:0,max:1/0,precision:2},...r}),R.jsx(sm,{value:o,onUpdate:a=>t("offsetB",a),configs:{label:"Offset 2",min:0,max:1/0,precision:2},...r})]})},D7=({element:n,onUpdate:e,attributeFormData:t,...r})=>{let i=t.has("name")?t.get("name"):n.name,s=t.has("x")?t.get("x"):n.x,o=t.has("y")?t.get("y"):n.y,a=t.has("rotation")?t.get("rotation"):n.rotation,l=t.has("altitude")?t.get("altitude"):n.altitude;return R.jsx("table",{className:"w-full",children:R.jsxs("tbody",{children:[R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Name"}),R.jsx("td",{children:R.jsx(Nl,{value:i,onChange:c=>e("name",c.target.value),style:{textAlign:"left"}})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"X"}),R.jsx("td",{children:R.jsx(Ci,{value:s,onChange:c=>e("x",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Y"}),R.jsx("td",{children:R.jsx(Ci,{value:o,onChange:c=>e("y",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Rotation"}),R.jsx("td",{children:R.jsx(Ci,{value:a,onChange:c=>e("rotation",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Elevation"}),R.jsx("td",{children:R.jsx(Ci,{value:l,onChange:c=>e("altitude",c.target.value),style:{textAlign:"left"},precision:2,...r})})]})]})})},N7=({element:n,onUpdate:e,attributeFormData:t})=>{let r=t.has("name")?t.get("name"):n.name,i=t.has("lineLength")?t.get("lineLength"):null;return R.jsxs("div",{children:[R.jsxs("div",{className:"w-full mb-2",children:[R.jsx(si,{children:"Name"}),R.jsx(Nl,{value:r,onChange:s=>e("name",s.target.value),style:{textAlign:"left"}})]}),R.jsx(sm,{value:i,onUpdate:s=>e("lineLength",s),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},U7=({element:n,onUpdate:e,onValid:t,attributeFormData:r,...i})=>n.prototype==="items"?R.jsx(D7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):n.prototype==="lines"?R.jsx(N7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):n.prototype==="holes"?R.jsx(q7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):null,oi=2,F7=(n,e,t)=>{switch(n=typeof n.misc=="object"?n.set("misc",Ie(n.misc)):n,n.prototype){case"items":return Ie(n);case"lines":{let r=e.vertices.get(n.vertices.get(0)),i=e.vertices.get(n.vertices.get(1)),s=Cn(r.x,r.y,i.x,i.y),o=n.misc.get("_unitLength")||t.unit,a=Kr(s).from(t.unit).to(o);return Ie({vertexOne:r,vertexTwo:i,lineLength:Ie({length:s,_length:a,_unit:o})})}case"holes":{let r=e.lines.get(n.line),{x:i,y:s}=e.vertices.get(r.vertices.get(0)),{x:o,y:a}=e.vertices.get(r.vertices.get(1)),l=Cn(i,s,o,a),c=l*n.offset-n.properties.get("width").get("length")/2,h=n.misc.get("_unitA")||t.unit,f=Kr(c).from(t.unit).to(h),p=l-l*n.offset-n.properties.get("width").get("length")/2,d=n.misc.get("_unitB")||t.unit,m=Kr(p).from(t.unit).to(d);return Ie({offset:n.offset,offsetA:Ie({length:Qn(c,oi),_length:Qn(f,oi),_unit:h}),offsetB:Ie({length:Qn(p,oi),_length:Qn(m,oi),_unit:d})})}case"areas":return Ie({});default:return null}},z7=(n,e)=>{const t=e.getElement(n.type),r={};for(const i in t.properties)r[i]=Ie({currentValue:n.properties.has(i)?n.properties.get(i):At(t.properties[i].defaultValue),configs:t.properties[i]});return Ie(r)},k7=({element:n,layer:e,catalog:t})=>{const{planner:r,setItemsAttributes:i,setProperties:s,setLinesAttributes:o,setHolesAttributes:a}=Ht(),[l,c]=ne.useState(F7(n,e,t)),[h,f]=ne.useState(z7(n,t)),p=({propertiesFormData:x,attributesFormData:v})=>{if(x){let _=x.map(w=>w.get("currentValue"));s(_)}if(v)switch(n.prototype){case"items":{i(v);break}case"lines":{o(v);break}case"holes":{a(v);break}}},d=(x,v)=>{if(!l)return;let _;switch(n.prototype){case"items":{_=l.set(x,v);break}case"lines":{switch(x){case"lineLength":{let w=l.get("vertexOne"),E=l.get("vertexTwo"),[S,b]=rl([w,E]),A=vc(S.x,S.y,b.x,b.y,v.get("length"),oi);_=l.withMutations(q=>{q.set(w===S?"vertexTwo":"vertexOne",b.merge(A)),q.set("lineLength",v)});break}case"vertexOne":case"vertexTwo":{_=l.withMutations(w=>{w.set(x,w.get(x).merge(v));let E=mc(w.get("vertexOne"),w.get("vertexTwo"));w.mergeIn(["lineLength"],w.get("lineLength").merge({length:E,_length:Kr(E).from(t.unit).to(w.get("lineLength").get("_unit"))}))});break}default:{_=l.set(x,v);break}}break}case"holes":{switch(x){case"offsetA":{let w=e.lines.get(n.line),E=rl([e.vertices.get(w.vertices.get(0)),e.vertices.get(w.vertices.get(1))]),[{x:S,y:b},{x:A,y:q}]=E,O=df(S,b,A,q),T=Cn(S,b,A,q),I=n.properties.get("width").get("length"),N=I/2,H=v.get("length");H=Math.max(H,0),H=Math.min(H,T-I);let W=(H+N)*Math.cos(O)+S,Q=(H+N)*Math.sin(O)+b,ae=On(S,b,A,q,W,Q),J=Qn(T-T*ae-N,oi),se=l.getIn(["offsetB","_unit"]),B=Ie({length:J,_length:Kr(J).from(t.unit).to(se),_unit:se});_=l.set("offsetB",B).set("offset",ae);let ge=Ie({length:Qn(H,oi),_unit:v.get("_unit"),_length:Qn(Kr(H).from(t.unit).to(v.get("_unit")),oi)});_=l.set(x,ge);break}case"offsetB":{let w=e.lines.get(n.line),E=rl([e.vertices.get(w.vertices.get(0)),e.vertices.get(w.vertices.get(1))]),[{x:S,y:b},{x:A,y:q}]=E,O=df(S,b,A,q),T=Cn(S,b,A,q),I=n.properties.get("width").get("length"),N=I/2,H=v.get("length");H=Math.max(H,0),H=Math.min(H,T-I);let W=A-(H+N)*Math.cos(O),Q=q-(H+N)*Math.sin(O),ae=On(S,b,A,q,W,Q),J=Qn(T*ae-N,oi),se=l.getIn(["offsetA","_unit"]),B=Ie({length:J,_length:Kr(J).from(t.unit).to(se),_unit:se});_=l.set("offsetA",B).set("offset",ae);let ge=Ie({length:Qn(H,oi),_unit:v.get("_unit"),_length:Qn(Kr(H).from(t.unit).to(v.get("_unit")),oi)});_=l.set(x,ge);break}default:{_=l.set(x,v);break}}break}}_&&(c(_),p({attributesFormData:_,propertiesFormData:h}))},m=(x,v)=>{const _=h.setIn([x,"currentValue"],v);f(_),p({propertiesFormData:_,attributesFormData:l})};return R.jsxs("div",{children:[R.jsx(U7,{element:n,onValid:()=>{},onUpdate:d,attributeFormData:l}),h.entrySeq().map(([x,v])=>{let _=v.get("currentValue"),w=v.get("configs"),{Editor:E}=t.getPropertyType(w.type);return R.jsx(E,{propertyName:x,value:_,configs:w,onUpdate:S=>m(x,S),state:r,sourceElement:n,internalState:{attributesFormData:l,propertiesFormData:h}},x)})]})},B7=()=>R.jsx("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:R.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})}),V7=[sn,qs,Ds,Ns,Br,Ao,Tr,Jn,hr,Ar,Vr,Hr,Gr,Wr,Di,af,lf],H7=({catalog:n})=>{const{planner:e}=Ht(),{scene:t,mode:r}=e;return V7.includes(r)?t.layers.valueSeq().flatMap(s=>vn().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>({element:o,layer:s}))).toArray().length===0?R.jsx(B7,{}):R.jsx("div",{children:t.layers.valueSeq().map(s=>vn().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected&&o.type!=="surface").map(o=>R.jsx(Sx,{name:"Properties",opened:!0,children:R.jsx("div",{className:"py-[5px] px-[15px]",children:R.jsx(k7,{element:o,layer:s,catalog:n})})},o.id)).valueSeq())}):null},G7={MODE_IDLE:sn,MODE_2D_ZOOM_IN:qs,MODE_2D_ZOOM_OUT:Ds,MODE_2D_PAN:Ns,MODE_3D_VIEW:Br,MODE_3D_FIRST_PERSON:Ao,MODE_WAITING_DRAWING_LINE:Tr,MODE_DRAWING_LINE:Jn,MODE_DRAWING_HOLE:hr,MODE_DRAWING_ITEM:Ar,MODE_DRAGGING_LINE:Vr,MODE_DRAGGING_VERTEX:Hr,MODE_DRAGGING_ITEM:Gr,MODE_DRAGGING_HOLE:Wr,MODE_FITTING_IMAGE:lf,MODE_UPLOADING_IMAGE:af,MODE_ROTATING_ITEM:Di},W7={width:"100%"},Xu={width:"6em"},$u={textAlign:"left"},j7={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},X7={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},Ex={width:"2em"},$7=({groupID:n})=>{const{planner:e,setGroupAttributes:t,groupTranslate:r,groupRotate:i,removeFromGroup:s}=Ht(),{mode:o}=e;if(!n||!G7[o])return null;const a=e.getIn(["scene","groups",n]),l=a.get("elements");return R.jsx(Sx,{name:`Group [${a.get("name")}]`,opened:!0,children:R.jsxs("div",{style:{padding:"5px 15px"},children:[R.jsx("table",{style:W7,children:R.jsxs("tbody",{children:[R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Name"}),R.jsx("td",{children:R.jsx(Nl,{value:a.get("name"),onChange:c=>t(n,Ie({name:c.target.value})),style:$u})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"X"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("x"),onChange:c=>r(n,c.target.value,a.get("y")),style:$u,precision:2})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Y"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("y"),onChange:c=>r(n,a.get("x"),c.target.value),style:$u,precision:2})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Rotation"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("rotation"),onChange:c=>i(n,c.target.value),style:$u,precision:2})})]})]})}),l.size?R.jsxs("div",{children:[R.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),R.jsxs("table",{style:X7,children:[R.jsx("thead",{children:R.jsxs("tr",{children:[R.jsx("th",{style:Ex}),R.jsx("th",{children:"Layer"}),R.jsx("th",{children:"Prototype"}),R.jsx("th",{children:"Name"})]})}),R.jsx("tbody",{children:l.entrySeq().map(([c,h])=>h.entrySeq().map(([f,p])=>p.valueSeq().map(d=>{let m=e.getIn(["scene","layers",c,f,d]);return R.jsxs("tr",{children:[R.jsx("td",{style:Ex,title:"Un-chain Element from Group",children:R.jsx(_A,{onClick:()=>s(n,c,f,d),style:j7})}),R.jsx("td",{style:{textAlign:"center"},children:c}),R.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:f}),R.jsx("td",{style:{textAlign:"center"},children:m.name})]},d)})))})]})]}):null]})})},Y7=({catalog:n,width:e=280})=>{const{planner:t}=Ht(),r=t.getIn(["scene","selectedLayer"]),i=t.getIn(["scene","layers",r,"selected"]),s=t.getIn(["scene","layers",r,"lines"]),o=t.getIn(["scene","groups"]).findEntry(h=>h.get("selected")),a=i.lines.filter(h=>{var f;return((f=s.get(h))==null?void 0:f.get("type"))!=="surface"}),l=a.size>1||i.items.size>1||i.holes.size>1||i.areas.size>1||a.size+i.items.size+i.holes.size+i.areas.size>1;return a.size>0||i.items.size>0||i.holes.size>0||i.areas.size>0?R.jsxs("aside",{onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation(),className:"floor_planner-sidebar bg-[#424242] h-full block overflow-y-auto overflow-x-hidden pb-5",style:{width:e},children:[!l&&R.jsx(H7,{catalog:n}),!!o&&R.jsx($7,{groupID:o?o[0]:null})]}):null},K7=({anchorEl:n,title:e,position:t="right",visible:r,collisionPadding:i=8})=>{const s=ne.useRef(null);return ne.useLayoutEffect(()=>{if(!n||!s.current)return;const o=s.current;if(!r){o.style.opacity="0",o.style.transform="scale(0.95)",o.style.pointerEvents="none";return}o.style.visibility="hidden",o.style.top="-9999px",o.style.left="-9999px",o.style.opacity="0",o.style.transform="scale(0.95)";const a=o.getBoundingClientRect(),l=n.getBoundingClientRect(),c=8,h=window.innerWidth,f=window.innerHeight,p={right:h-l.right>=a.width+c+i,left:l.left>=a.width+c+i,top:l.top>=a.height+c+i,bottom:f-l.bottom>=a.height+c+i};let d=t;p[t]||(d=["right","left","top","bottom"].find(_=>p[_])??t);let m=0,x=0;switch(d){case"right":m=l.top+l.height/2-a.height/2,x=l.right+c;break;case"left":m=l.top+l.height/2-a.height/2,x=l.left-a.width-c;break;case"top":m=l.top-a.height-c,x=l.left+l.width/2-a.width/2;break;case"bottom":m=l.bottom+c,x=l.left+l.width/2-a.width/2;break}const v=(_,w,E)=>Math.min(Math.max(_,w),E);o.style.position="fixed",o.style.top=`${v(m,i,f-a.height-i)}px`,o.style.left=`${v(x,i,h-a.width-i)}px`,o.style.visibility="visible",o.style.opacity="1",o.style.transform="scale(1)",o.style.pointerEvents="none"},[r,n,t,i]),co.createPortal(R.jsx("div",{ref:s,className:`
3922
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50};function f8(n,e,t,r){const i=t.properties.get("step"),s=t.properties.has("color")?He([t.properties.get("color")]):t.properties.get("colors"),o=new Dt;o.name="streak";let a=0;for(let l=0;l<=e;l+=i){const c=[new j(0,0,-l),new j(n,0,-l)],h=new nr().setFromPoints(c),f=s.get(a%s.size),p=new Eu({color:f}),d=new El(h,p);o.add(d),o.add(new El(h,p)),a++}return o}function d8(n,e,t,r){const i=t.properties.get("step"),s=t.properties.has("color")?He([t.properties.get("color")]):t.properties.get("colors"),o=new Dt;o.name="streak";let a=0;for(let l=0;l<=n;l+=i){const c=[new j(l,0,0),new j(l,0,-e)],h=new nr().setFromPoints(c),f=s.get(a%s.size),p=new Eu({color:f});o.add(new El(h,p)),a++}return o}function p8(n){const e=new Dt;e.name="grid",new a8().parse(h8);const{grids:r,width:i,height:s}=n;return r.forEach(o=>{switch(o.type){case"horizontal-streak":e.add(f8(i,s,o));break;case"vertical-streak":e.add(d8(i,s,o));break}}),e.position.y=-1,e}function m8(n){n&&n.dispose&&n.dispose()}function g8(n){n&&n.dispose&&n.dispose()}function Bv(n){if(n){if(Array.isArray(n)){n.forEach(e=>Bv(e));return}for(const e in n){const t=n[e];t instanceof Dn&&g8(t)}n.dispose()}}function Vv(n){(n instanceof Tn||n instanceof tw||n instanceof El)&&(m8(n.geometry),Bv(n.material),n.geometry=null,n.material=null)}function _8(n){n.traverse(e=>{Vv(e)})}function Uu(n){n.traverse(e=>{Vv(e)})}function v8(n,e,t){const r={sceneGraph:{unit:n.unit,layers:{},busyResources:{layers:{}},width:n.width,height:n.height,LODs:{}},plan:new Dt,grid:p8(n),boundingBox:new wi};r.plan.name="plan",r.grid.name="grid",r.boundingBox.setFromObject(r.grid);let i=[];return n.layers.forEach(s=>{(s.id===n.selectedLayer||s.visible)&&(i=i.concat(Fu(s,r,n,e,t)))}),Promise.all(i).then(()=>Yi(r)),r}function Fu(n,e,t,r,i){const s=[];return e.sceneGraph.layers[n.id]={id:n.id,lines:{},holes:{},areas:{},items:{},visible:n.visible,altitude:n.altitude},e.sceneGraph.busyResources.layers[n.id]={id:n.id,lines:{},holes:{},areas:{},items:{}},n.lines.forEach(o=>{s.push(so(t,e,n,o.id,i,r.linesActions)),o.holes.forEach(a=>{s.push(ma(t,e,n,a,i,r.holesActions))})}),n.areas.forEach(o=>{s.push(Ol(t,e,n,o.id,i,r.areaActions))}),n.items.forEach(o=>{s.push(zu(t,e,n,o.id,i,r.itemsActions))}),s}function x8(n,e,t,r,i,s){const o=r.map(l=>({op:l.op,path:l.path.split("/"),value:l.value}));let a=A8(o,e,t);return a=a.filter(({path:l})=>l[3]!=="selected"),a=a.filter(({path:l})=>l[1]!=="groups"),a.forEach(({op:l,path:c,value:h})=>{if(c[1]==="layers"){const f=e.getIn(["layers",c[2]]);if(c.length===3&&l==="remove")S8(c[2],n);else if(c.length>3)switch(l){case"replace":Ll(c,f,n,i,e,t,s);break;case"add":E8(c,f,n,i,e,t,s);break;case"remove":y8(c,f,n,i,e,t,s);break}}else if(c[1]==="selectedLayer"){const f=h,p=e.getIn(["layers",f]);if(!p.visible){const m=Fu(p,n,e,i,s);Promise.all(m).then(()=>Yi(n))}const d=n.sceneGraph.layers[(t==null?void 0:t.selectedLayer)??""];if(d&&!d.visible){for(let m in d.lines)$i(n,d.id,m);for(let m in d.areas)Es(n,d.id,m);for(let m in d.items)bs(n,d.id,m);for(let m in d.holes)Xi(n,d.id,m)}}}),n}function Ll(n,e,t,r,i,s,o){let a=[];switch(n[3]){case"vertices":if(n[5]!=="selected"){const d=e.getIn(["vertices",n[4]]);if((n[5]==="x"||n[5]==="y")&&(d.lines.forEach(m=>{const x=s.getIn(["layers",e.id,"lines",m,"holes"]);return x&&x.forEach(v=>{Ll([0,0,0,"holes",v,"selected"],e,t,r,i,s,o)}),Ll([0,0,0,"lines",m],e,t,r,i,s,o)}),d.areas.forEach(m=>Ll([0,0,0,"areas",m],e,t,r,i,s,o))),n[5]==="areas"){let m=d.getIn(["areas",~~n[6]]);Ll([0,0,0,"areas",m],e,t,r,i,s,o)}}break;case"holes":const l=e.getIn(["holes",n[4]]);if(o.getElement(l.type).updateRender3D)a.push(b8(i,s,t,e,n[4],n.slice(5),o,r.holesActions,()=>Xi(t,e.id,l.id),()=>ma(i,t,e,l.id,o,r.holesActions)));else{let d=l.line;n[5]==="selected"?(Xi(t,e.id,l.id),a.push(ma(i,t,e,l.id,o,r.holesActions))):(e.getIn(["lines",d,"holes"]).forEach(m=>{Xi(t,e.id,m)}),$i(t,e.id,d),a.push(so(i,t,e,d,o,r.linesActions)),e.getIn(["lines",d,"holes"]).forEach(m=>{a.push(ma(i,t,e,m,o,r.holesActions))}))}break;case"lines":const c=e.getIn(["lines",n[4]]);o.getElement(c.type).updateRender3D?a.push(M8(i,s,t,e,n[4],n.slice(5),o,r.linesActions,()=>$i(t,e.id,n[4]),()=>so(i,t,e,n[4],o,r.linesActions))):($i(t,e.id,n[4]),a.push(so(i,t,e,n[4],o,r.linesActions)));break;case"areas":const h=e.getIn(["areas",n[4]]);o.getElement(h.type).updateRender3D?a.push(w8(i,s,t,e,n[4],n.slice(5),o,r.areaActions,()=>Es(t,e.id,n[4]),()=>Ol(i,t,e,n[4],o,r.areaActions))):(t.sceneGraph.layers[e.id].areas[n[4]]&&Es(t,e.id,n[4]),a.push(Ol(i,t,e,n[4],o,r.areaActions)));break;case"items":const f=e.getIn(["items",n[4]]);o.getElement(f.type).updateRender3D?a.push(T8(i,s,t,e,n[4],n.slice(5),o,r.itemsActions,()=>bs(t,e.id,n[4]),()=>zu(i,t,e,n[4],o,r.itemsActions))):(bs(t,e.id,n[4]),a.push(zu(i,t,e,n[4],o,r.itemsActions)));break;case"visible":if(e.visible)a=a.concat(Fu(e,t,i,r,o));else{let d=t.sceneGraph.layers[e.id];for(let m in d.lines)$i(t,e.id,m);for(let m in d.areas)Es(t,e.id,m);for(let m in d.items)bs(t,e.id,m);for(let m in d.holes)Xi(t,e.id,m)}break;case"opacity":case"altitude":let p=t.sceneGraph.layers[e.id];for(let d in p.lines)$i(t,e.id,d);for(let d in p.areas)Es(t,e.id,d);for(let d in p.items)bs(t,e.id,d);for(let d in p.holes)Xi(t,e.id,d);a=a.concat(Fu(e,t,i,r,o))}Promise.all(a).then(()=>Yi(t))}function y8(n,e,t,r,i,s,o){let a=[];switch(n[3]){case"lines":const l=n[4];s.getIn(["layers",e.id,"lines",l,"holes"]).forEach(c=>{Xi(t,e.id,c)}),$i(t,e.id,l),n.length>5&&(a.push(so(i,t,e,l,o,r.linesActions)),e.getIn(["lines",l,"holes"]).forEach(c=>{a.push(ma(i,t,e,c,o,r.holesActions))}));break;case"areas":n.length===5&&Es(t,e.id,n[4]);break;case"items":n.length===5&&bs(t,e.id,n[4]);break}Promise.all(a).then(()=>Yi(t))}function S8(n,e){let t=e.sceneGraph.layers[n];for(let r in t.lines)$i(e,n,r);for(let r in t.areas)Es(e,n,r);for(let r in t.items)bs(e,n,r);for(let r in t.holes)Xi(e,n,r);delete e.sceneGraph.layers[n]}function Xi(n,e,t){if(n.sceneGraph.busyResources.layers[e].holes[t]){setTimeout(()=>Xi(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].holes[t]=!0;let r=n.sceneGraph.layers[e].holes[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].holes[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].holes[t]=!1}function $i(n,e,t){if(n.sceneGraph.busyResources.layers[e].lines[t]){setTimeout(()=>$i(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].lines[t]=!0;let r=n.sceneGraph.layers[e].lines[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].lines[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].lines[t]=!1}function Es(n,e,t){if(n.sceneGraph.busyResources.layers[e].areas[t]){setTimeout(()=>Es(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].areas[t]=!0;let r=n.sceneGraph.layers[e].areas[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].areas[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].areas[t]=!1}function bs(n,e,t){if(n.sceneGraph.busyResources.layers[e].items[t]){setTimeout(()=>bs(n,e,t),100);return}n.sceneGraph.busyResources.layers[e].items[t]=!0;let r=n.sceneGraph.layers[e].items[t];r&&(n.plan.remove(r),Uu(r),delete n.sceneGraph.layers[e].items[t],delete n.sceneGraph.LODs[t],r=null,Yi(n)),n.sceneGraph.busyResources.layers[e].items[t]=!1}function E8(n,e,t,r,i,s,o){if(n.length===5){let a=null,l=null;switch(n[3]){case"lines":a=so,l=r.linesActions;break;case"areas":a=Ol,l=r.areaActions;break;case"items":a=zu,l=r.itemsActions;break;case"holes":a=ma,l=r.holesActions;break}a&&a(i,t,e,n[4],o,l).then(()=>Yi(t))}}function ma(n,e,t,r,i,s){const o=t.getIn(["holes",r]);return i.getElement(o.type).render3D(o,t,n).then(a=>{a instanceof yu&&(e.sceneGraph.LODs[r]=a);const l=new Dt;l.name="pivot",l.add(a);const c=t.getIn(["lines",o.line]);let h=t.vertices.get(c.vertices.get(0)),f=t.vertices.get(c.vertices.get(1)),p=o.offset;if(h.x>f.x){const S=h;h=f,f=S,p=1-p}let d=Math.sqrt(Math.pow(h.x-f.x,2)+Math.pow(h.y-f.y,2)),m=Math.asin((f.y-h.y)/d),x=new wi().setFromObject(l),v=[(x.max.x-x.min.x)/2+x.min.x,(x.max.y-x.min.y)/2+x.min.y,(x.max.z-x.min.z)/2+x.min.z],_=o.properties.getIn(["altitude","length"]),w=o.properties.getIn(["height","length"]);l.rotation.y=m,l.position.x=h.x+d*p*Math.cos(m)-v[2]*Math.sin(m),l.position.y=_+w/2-v[1]+t.altitude,l.position.z=-h.y-d*p*Math.sin(m)-v[2]*Math.cos(m),e.plan.add(l),e.sceneGraph.layers[t.id].holes[o.id]=l,ku(l,()=>s.selectHole(t.id,o.id));let E=t.opacity;o.selected&&(E=1),Bu(l,E)})}function b8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["holes",i]),f=e.getIn(["layers",r.id,"holes",i]),p=t.sceneGraph.layers[r.id].holes[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function so(n,e,t,r,i,s){if(e.sceneGraph.busyResources.layers[t.id].lines[r]){setTimeout(()=>so(n,e,t,r,i,s),100);return}e.sceneGraph.busyResources.layers[t.id].lines[r]=!0;const o=t.getIn(["lines",r]);let a=t.vertices.get(o.vertices.get(0)),l=t.vertices.get(o.vertices.get(1));if(a.x>l.x){let c=a;a=l,l=c}return i.getElement(o.type).render3D(o,t,n).then(c=>{c instanceof yu&&(e.sceneGraph.LODs[o.id]=c);let h=new Dt;h.name="pivot",h.add(c),h.position.x=a.x,h.position.y=t.altitude,h.position.z=-a.y,e.plan.add(h),e.sceneGraph.layers[t.id].lines[r]=h,ku(h,()=>s.selectLine(t.id,o.id));let f=t.opacity;o.selected&&(f=1),Bu(h,f),e.sceneGraph.busyResources.layers[t.id].lines[r]=!1})}function M8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["lines",i]),f=e.getIn(["layers",r.id,"lines",i]),p=t.sceneGraph.layers[r.id].lines[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function Ol(n,e,t,r,i,s){if(e.sceneGraph.busyResources.layers[t.id].areas[r]){setTimeout(()=>Ol(n,e,t,r,i,s),100);return}e.sceneGraph.busyResources.layers[t.id].areas[r]=!0;const o=t.getIn(["areas",r]),a=()=>s.selectArea(t.id,r);return i.getElement(o.type).render3D(o,t,n).then(l=>{l instanceof yu&&(e.sceneGraph.LODs[r]=l);let c=new Dt;c.name="pivot",c.add(l),c.position.y=t.altitude,e.plan.add(c),e.sceneGraph.layers[t.id].areas[r]=c,ku(c,a);let h=t.opacity;o.selected&&(h=1),Bu(c,h),e.sceneGraph.busyResources.layers[t.id].areas[r]=!1})}function w8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["areas",i]),f=e.getIn(["layers",r.id,"areas",i]),p=t.sceneGraph.layers[r.id].areas[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function zu(n,e,t,r,i,s){const o=t.getIn(["items",r]);return i.getElement(o.type).render3D(o,t,n).then(a=>{a instanceof yu&&(e.sceneGraph.LODs[r]=a);const l=new Dt;l.name="pivot",l.add(a),l.rotation.y=o.rotation*Math.PI/180,l.position.x=o.x,l.position.y=t.altitude,l.position.z=-o.y,ku(a,()=>{s.selectItem(t.id,o.id)});let c=t.opacity;o.selected&&(c=1),Bu(l,c),e.plan.add(l),e.sceneGraph.layers[t.id].items[o.id]=l})}function T8(n,e,t,r,i,s,o,a,l,c){const h=r.getIn(["items",i]),f=e.getIn(["layers",r.id,"items",i]),p=t.sceneGraph.layers[r.id].items[i];return p?o.getElement(h.type).updateRender3D(h,r,n,p,f,s,l,c):null}function ku(n,e){n.traverse(t=>{(t instanceof Tn||t.isMesh)&&(t.interact=e)})}function Bu(n,e){n.traverse(t=>{t instanceof Tn&&(t.material instanceof Array?t.material.forEach(r=>{r.transparent=!0,r.maxOpacity?r.opacity=Math.min(r.maxOpacity,e):r.opacity&&r.opacity>e&&(r.maxOpacity=r.opacity,r.opacity=e)}):(t.material.transparent=!0,t.material.maxOpacity?t.material.opacity=Math.min(t.material.maxOpacity,e):t.material.opacity&&t.material.opacity>e&&(t.material.maxOpacity=t.material.opacity,t.material.opacity=e)))})}function Yi(n){let e=new wi().setFromObject(n.plan);if(isFinite(e.max.x)&&isFinite(e.min.x)&&isFinite(e.max.y)&&isFinite(e.min.y)&&isFinite(e.max.z)&&isFinite(e.min.z)){let t=new j((e.max.x-e.min.x)/2+e.min.x,(e.max.y-e.min.y)/2+e.min.y,(e.max.z-e.min.z)/2+e.min.z);n.plan.position.sub(t),n.grid.position.sub(t),e.min.sub(t),e.max.sub(t),n.boundingBox=e}}function A8(n,e,t){return C8(R8(P8(n)),e,t)}function C8(n,e,t){let r,i;for(i=0;i<n.length&&!r;i++)n[i].path[1]==="selectedLayer"&&(r=n[i]);return r&&!e.getIn(["layers",t.selectedLayer,"visible"])?n.filter(({op:s,path:o})=>!(o[o.length-1]==="selected"&&o[1]==="layers"&&o[2]===t.selectedLayer)&&!(s==="remove"&&o.indexOf(t.selectedLayer)!==-1)):n}function R8(n,e,t){const r={};return n.forEach(({path:i})=>{i[5]==="selected"&&(r[i[4]]=i[4])}),n.filter(({path:i})=>i[5]==="properties"?!r[i[4]]:!0)}function P8(n,e,t){const r={};return n.filter(({path:i})=>i[5]==="properties"?r[i[4]]?!1:r[i[4]]=!0:i[5]!=="misc")}const Hv={type:"change"},$p={type:"start"},Gv={type:"end"},Vu=new au,Wv=new Ss,I8=Math.cos(70*PM.DEG2RAD),En=new j,rr=2*Math.PI,zt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yp=1e-6;class L8 extends rw{constructor(e,t=null){super(e,t),this.state=zt.NONE,this.target=new j,this.cursor=new j,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Uo.ROTATE,MIDDLE:Uo.DOLLY,RIGHT:Uo.PAN},this.touches={ONE:Fo.ROTATE,TWO:Fo.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new j,this._lastQuaternion=new ds,this._lastTargetPosition=new j,this._quat=new ds().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new cv,this._sphericalDelta=new cv,this._scale=1,this._panOffset=new j,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new j,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=q8.bind(this),this._onPointerDown=O8.bind(this),this._onPointerUp=D8.bind(this),this._onContextMenu=V8.bind(this),this._onMouseWheel=F8.bind(this),this._onKeyDown=z8.bind(this),this._onTouchStart=k8.bind(this),this._onTouchMove=B8.bind(this),this._onMouseDown=N8.bind(this),this._onMouseMove=U8.bind(this),this._interceptControlDown=H8.bind(this),this._interceptControlUp=G8.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Hv),this.update(),this.state=zt.NONE}update(e=null){const t=this.object.position;En.copy(t).sub(this.target),En.applyQuaternion(this._quat),this._spherical.setFromVector3(En),this.autoRotate&&this.state===zt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=rr:r>Math.PI&&(r-=rr),i<-Math.PI?i+=rr:i>Math.PI&&(i-=rr),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(En.setFromSpherical(this._spherical),En.applyQuaternion(this._quatInverse),t.copy(this.target).add(En),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 o=null;if(this.object.isPerspectiveCamera){const a=En.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=En.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Vu.origin.copy(this.object.position),Vu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Vu.direction))<I8?this.object.lookAt(this.target):(Wv.setFromNormalAndCoplanarPoint(this.object.up,this.target),Vu.intersectPlane(Wv,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Yp||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yp||this._lastTargetPosition.distanceToSquared(this.target)>Yp?(this.dispatchEvent(Hv),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?rr/60*this.autoRotateSpeed*e:rr/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){En.setFromMatrixColumn(t,0),En.multiplyScalar(-e),this._panOffset.add(En)}_panUp(e,t){this.screenSpacePanning===!0?En.setFromMatrixColumn(t,1):(En.setFromMatrixColumn(t,0),En.crossVectors(this.object.up,En)),En.multiplyScalar(e),this._panOffset.add(En)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;En.copy(i).sub(this.target);let s=En.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*t*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.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 r=this.domElement.getBoundingClientRect(),i=e-r.left,s=t-r.top,o=r.width,a=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*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(rr*this._rotateDelta.x/t.clientHeight),this._rotateUp(rr*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(rr*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(-rr*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(rr*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(-rr*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),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_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 r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(rr*this._rotateDelta.x/t.clientHeight),this._rotateUp(rr*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),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(r,i)}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),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),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 o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_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;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ne,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function O8(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function q8(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function D8(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Gv),this.state=zt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function N8(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Uo.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=zt.DOLLY;break;case Uo.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=zt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=zt.ROTATE}break;case Uo.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=zt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=zt.PAN}break;default:this.state=zt.NONE}this.state!==zt.NONE&&this.dispatchEvent($p)}function U8(n){switch(this.state){case zt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case zt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case zt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function F8(n){this.enabled===!1||this.enableZoom===!1||this.state!==zt.NONE||(n.preventDefault(),this.dispatchEvent($p),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Gv))}function z8(n){this.enabled!==!1&&this._handleKeyDown(n)}function k8(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case Fo.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=zt.TOUCH_ROTATE;break;case Fo.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=zt.TOUCH_PAN;break;default:this.state=zt.NONE}break;case 2:switch(this.touches.TWO){case Fo.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=zt.TOUCH_DOLLY_PAN;break;case Fo.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=zt.TOUCH_DOLLY_ROTATE;break;default:this.state=zt.NONE}break;default:this.state=zt.NONE}this.state!==zt.NONE&&this.dispatchEvent($p)}function B8(n){switch(this._trackPointer(n),this.state){case zt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case zt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case zt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case zt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=zt.NONE}}function V8(n){this.enabled!==!1&&n.preventDefault()}function H8(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function G8(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ga=n=>Bt(n),_a=n=>Bn(n),va=n=>gt.isRecord(n),Ki=(n,e,t)=>n==="remove"?{op:n,path:e}:{op:n,path:e,value:t},W8=(n,e,t)=>{const r=[];for(let i=0;i<n;i++){r[i]=new Array(e);for(let s=0;s<e;s++)r[i][s]=t}return r},Kp=gt({op:"=",val:null}),j8=gt({op:"!=",val:null,newVal:null}),X8=(n,e)=>{const t=$8(n,e);return Y8(t,n,e,n.size??0,e.size??0)},$8=(n,e)=>{const t=n.size??0,r=e.size??0,i=W8(t+1,r+1,0);for(let s=0;s<t;s++)for(let o=0;o<r;o++)Kt(n.get(s),e.get(o))?i[s+1][o+1]=i[s][o]+1:i[s+1][o+1]=Math.max(i[s+1][o],i[s][o+1]);return i},Y8=(n,e,t,r,i)=>{const s=[];let o=r-1,a=i-1;for(;o>=0||a>=0;)o>=0&&a>=0&&Kt(e.get(o),t.get(a))?(s.push(new Kp({op:"=",val:e.get(o)})),o--,a--):o>=0&&a>=0&&o===a&&!Kt(e.get(o),t.get(a))?(s.push(new j8({val:e.get(o),newVal:t.get(o)})),o--,a--):a>=0&&(o===-1||n[o+1][a]>=n[o][a+1])?(s.push(new Kp({op:"+",val:t.get(a)})),a--):o>=0&&(a===-1||n[o+1][a]<n[o][a+1])&&(s.push(new Kp({op:"-",val:e.get(o)})),o--);return s.reverse()},K8=/\//g,Z8=/~/g,oo=n=>{if(typeof n=="number")return n.toString();if(typeof n!="string")throw new Error(`param str (${String(n)}) is not a string`);return n.replace(Z8,"~0").replace(K8,"~1")},xr=(n,e)=>`${n}/${e}`,ql=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;const i=_a(n)&&_a(e);let s=null,o=null;return n.forEach&&n.forEach((a,l)=>{if(e.has(l))if(va(a)&&va(e.get(l)))r=r.concat(Zp(a,e.get(l),xr(t,oo(l))));else if(ga(a)&&ga(e.get(l)))r=r.concat(ql(a,e.get(l),xr(t,oo(l))));else if(_a(a)&&_a(e.get(l)))r=r.concat(jv(a,e.get(l),xr(t,oo(l))));else{const c=e.get?e.get(l):e;a!==c&&r.push(Ki("replace",xr(t,oo(l)),c))}else i?(o=s!=null&&Number(s)+1===l?o:l,r.push(Ki("remove",xr(t,oo(o)))),s=l):r.push(Ki("remove",xr(t,oo(l))))}),e.forEach((a,l)=>{n.has&&!n.has(l)&&r.push(Ki("add",xr(t,oo(l)),a))}),r},Zp=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;const i=n.toSeq().toMap(),s=e.toSeq().toMap();return r=r.concat(ql(i,s,t)),r},jv=(n,e,t="")=>{let r=[];if(Kt(n,e)||n==e&&n==null)return r;if((n.count()+1)*(e.count()+1)>=1e4)return ql(n,e,t);const i=X8(n,e);let s=0;return i.forEach(o=>{if(o.op==="=")s++;else if(o.op==="!="){if(va(o.val)&&va(o.newVal)){const a=Zp(o.val,o.newVal,xr(t,String(s)));r=r.concat(a)}else if(ga(o.val)&&ga(o.newVal)){const a=ql(o.val,o.newVal,xr(t,String(s)));r=r.concat(a)}else r.push(Ki("replace",xr(t,String(s)),o.newVal));s++}else o.op==="+"?(r.push(Ki("add",xr(t,String(s)),o.val)),s++):o.op==="-"&&r.push(Ki("remove",xr(t,String(s))))}),r},J8=(n,e,t="")=>n===e?[]:[Ki("replace",xr(t,""),e)],Q8=(n,e,t="")=>Kt(n,e)?He():n!=e&&(n==null||e==null)?At([Ki("replace","/",e)]):_a(n)&&_a(e)?At(jv(n,e)):va(n)&&va(e)?At(Zp(n,e)):ga(n)&&ga(e)?At(ql(n,e)):At(J8(n,e,t));class eA extends ne.Component{constructor(t){super(t);ht(this,"canvasWrapperRef",ne.createRef());ht(this,"renderer");ht(this,"scene3D",null);ht(this,"camera",null);ht(this,"orbitControls",null);ht(this,"planData");ht(this,"renderingID",0);ht(this,"width");ht(this,"height");ht(this,"lastMousePosition",{});ht(this,"mouseDownEvent");ht(this,"mouseUpEvent");this.width=t.width,this.height=t.height,this.renderer=new o8({preserveDrawingBuffer:!0,antialias:!0})}componentDidMount(){const{state:t,actions:r}=this.props,i={areaActions:r.areaActions,holesActions:r.holesActions,itemsActions:r.itemsActions,linesActions:r.linesActions,projectActions:r.projectActions},s=t.scene,o=this.canvasWrapperRef.current,a=new r4;this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.outputColorSpace=mr,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(new Et(Vc.white));const l=v8(s,i,this.props.catalog);a.add(l.plan),a.add(l.grid);const c=this.width/this.height,h=new vr(45,c,1,3e5);a.add(h);const f=-(l.boundingBox.max.x-l.boundingBox.min.x)/2,p=(l.boundingBox.max.y-l.boundingBox.min.y)/2*10,d=(l.boundingBox.max.z-l.boundingBox.min.z)/2;h.position.set(f,p,d),h.up.set(0,1,0);const m=new K4(Vc.white,.3);m.position.set(f,p,d),a.add(m),a.add(new ov(11513775)),a.add(new ov(16777215,.7));const x=new J4(16777215,.6);x.position.set(100,200,100),x.castShadow=!0,a.add(x);const v=[l.plan],_=new Ne,w=new ew;this.mouseDownEvent=A=>{this.lastMousePosition.x=A.offsetX/this.width*2-1,this.lastMousePosition.y=-A.offsetY/this.height*2+1},this.mouseUpEvent=A=>{var q,O;if(A.preventDefault(),_.x=A.offsetX/this.width*2-1,_.y=-(A.offsetY/this.height)*2+1,Math.abs(_.x-(this.lastMousePosition.x??0))<=.02&&Math.abs(_.y-(this.lastMousePosition.y??0))<=.02){w.setFromCamera(_,h);const T=w.intersectObjects(v,!0);T.length>0&&!isNaN(T[0].distance)?(O=(q=T[0].object).interact)==null||O.call(q):this.props.actions.projectActions.unselectAll()}},this.renderer.domElement.addEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.addEventListener("mouseup",this.mouseUpEvent),o&&o.appendChild(this.renderer.domElement);const E=new L8(h,this.renderer.domElement);E.enableDamping=!0,E.dampingFactor=.05;const S=new Dt;S.name="spotLightTarget",S.position.copy(E.target),a.add(S),m.target=S;const b=()=>{E.update(),m.position.copy(h.position),S.position.copy(E.target);for(const A in l.sceneGraph.LODs)l.sceneGraph.LODs[A].update(h);this.renderer.render(a,h),this.renderingID=requestAnimationFrame(b)};b(),this.orbitControls=E,this.camera=h,this.scene3D=a,this.planData=l}componentWillUnmount(){var t;cancelAnimationFrame(this.renderingID),(t=this.orbitControls)==null||t.dispose(),this.renderer.domElement.removeEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.removeEventListener("mouseup",this.mouseUpEvent),this.scene3D&&(_8(this.scene3D),this.scene3D.remove(this.planData.plan),this.scene3D.remove(this.planData.grid)),this.scene3D=null,this.planData=null,this.camera=null,this.orbitControls=null,this.renderer.renderLists.dispose()}componentDidUpdate(t){const{width:r,height:i}=this.props;if(this.width=r,this.height=i,this.camera&&(this.camera.aspect=r/i,this.camera.updateProjectionMatrix()),t.state.scene!==this.props.state.scene){const s=Q8(t.state.scene,this.props.state.scene),o={areaActions:this.props.actions.areaActions,holesActions:this.props.actions.holesActions,itemsActions:this.props.actions.itemsActions,linesActions:this.props.actions.linesActions,projectActions:this.props.actions.projectActions};x8(this.planData,this.props.state.scene,t.state.scene,s.toJS(),o,this.props.catalog)}this.renderer.setSize(r,i)}render(){return ne.createElement("div",{ref:this.canvasWrapperRef})}}const tA={color:Lt.PRIMARY_COLOR.alt,fontWeight:300};function nA({children:n,style:e={},...t}){return R.jsx("h1",{style:{...tA,...e},...t,children:n})}const rA={padding:"0 20px",overflowY:"auto"};function iA({children:n,width:e,height:t,style:r={}}){return R.jsx("div",{style:{width:e,height:t,...rA,...r},onWheel:i=>i.stopPropagation(),children:n})}var Xv={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$v=ne.createContext&&ne.createContext(Xv),sA=["attr","size","title"];function oA(n,e){if(n==null)return{};var t=aA(n,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(t[r]=n[r])}return t}function aA(n,e){if(n==null)return{};var t={};for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){if(e.indexOf(r)>=0)continue;t[r]=n[r]}return t}function Hu(){return Hu=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Hu.apply(this,arguments)}function Yv(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Gu(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yv(Object(t),!0).forEach(function(r){lA(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Yv(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function lA(n,e,t){return e=cA(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function cA(n){var e=uA(n,"string");return typeof e=="symbol"?e:e+""}function uA(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Kv(n){return n&&n.map((e,t)=>ne.createElement(e.tag,Gu({key:t},e.attr),Kv(e.child)))}function un(n){return e=>ne.createElement(hA,Hu({attr:Gu({},n.attr)},e),Kv(n.child))}function hA(n){var e=t=>{var{attr:r,size:i,title:s}=n,o=oA(n,sA),a=i||t.size||"1em",l;return t.className&&(l=t.className),n.className&&(l=(l?l+" ":"")+n.className),ne.createElement("svg",Hu({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,o,{className:l,style:Gu(Gu({color:n.color||t.color},t.style),n.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&ne.createElement("title",null,s),n.children)};return $v!==void 0?ne.createElement($v.Consumer,null,t=>e(t)):e(Xv)}function fA(n){return un({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"},child:[]}]})(n)}function dA(n){return un({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"},child:[]}]})(n)}function pA(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(n)}function mA(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(n)}function gA(n){return un({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(n)}function _A(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(n)}const Zv={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},vA={...Zv,background:Lt.SECONDARY_COLOR.main},Jv={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},xA={...Jv,color:Lt.COLORS.white},yA={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},Qv={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:Lt.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},SA={...Qv,transform:"scale(1.2)"},EA={marginTop:"1.5em",color:Lt.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},bA={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},MA={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},wA={display:"inline-block",background:"#337ab7",color:Lt.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},ex=({element:n})=>{const[e,t]=ne.useState(!1),{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=Ht(),a=()=>{switch(n.prototype){case"lines":r(n.name);break;case"items":i(n.name);break;case"holes":s(n.name);break}o(n)};return R.jsxs("div",{style:e?vA:Zv,onClick:a,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[R.jsx("b",{style:e?xA:Jv,children:n.info.title}),R.jsx("div",{style:yA,children:R.jsx("div",{style:{...e?SA:Qv,backgroundImage:"url("+n.info.image+")"},children:e?R.jsx(mA,{style:EA}):null})}),R.jsx("ul",{style:MA,children:n.info.tag.map((l,c)=>R.jsx("li",{style:wA,children:l},c))}),R.jsx("div",{style:bA,children:n.info.description})]})};function TA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(n)}function AA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 0 1 7.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"},child:[]}]})(n)}function CA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"},child:[]}]})(n)}function RA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(n)}function tx(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(n)}function PA(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(n)}const IA={margin:"1.5em",display:"flex"},nx={fontSize:"20px",cursor:"pointer"},LA={...nx,fontWeight:"bolder",color:Lt.SECONDARY_COLOR.main},OA={fill:Lt.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},qA=({names:n})=>{let e=n.map((t,r)=>{let i=r===n.length-1;return R.jsxs("div",{style:{display:"flex"},children:[R.jsx("div",{style:i?LA:nx,onClick:t.action||null,children:t.name}),i?null:R.jsx(tx,{style:OA})]},r)});return R.jsx("div",{style:IA,children:e})},rx={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},DA={...rx,background:Lt.SECONDARY_COLOR.main},ix={position:"absolute",color:Lt.COLORS.black,fontSize:"5em",width:"100%"},NA={...ix,color:Lt.SECONDARY_COLOR.main},UA={background:Lt.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},FA=({page:n})=>{const[e,t]=ne.useState(!1),{goBackToCatalogPage:r}=Ht(),i=s=>{r(s)};return R.jsx("div",{style:e?DA:rx,onClick:()=>i(n.name),onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:R.jsx("div",{style:UA,children:R.jsx(RA,{style:e?NA:ix})})})},zA={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},kA={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},sx={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},BA={width:"8em",display:"inline-block"},VA={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},HA={...sx,padding:"0.2em 0.625em"},GA={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:Lt.PRIMARY_COLOR.alt,color:Lt.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},WA=({width:n,height:e,style:t,catalog:r})=>{const{planner:i,goBackToCatalogPage:s,selectToolDrawingHole:o,selectToolDrawingItem:a,selectToolDrawingLine:l,pushLastSelectedCatalogElementToHistory:c}=Ht();let h=i.catalog.page;const f=r.getCategory(h);let p=f.elements.filter(T=>T.info.visibility?T.info.visibility.catalog:!0);const[d,m]=ne.useState(""),[x,v]=ne.useState([]);let _=null;if(h!=="root"){let T=[];i.catalog.path.forEach(I=>{T.push({name:r.getCategory(I).label,action:()=>s(I)})}),T.push({name:f.label,action:""}),_=R.jsx(qA,{names:T})}let w=i.catalog.path.size,E=w>0?R.jsx(FA,{page:r.categories[i.catalog.path.get(w-1)]},w):null,S=i.get("selectedElementsHistory"),b=S.map((T,I)=>R.jsx("div",{style:GA,title:T.name,onClick:()=>O(T),children:T.name},I));const A=T=>{let I=[];for(let N=0;N<T.length;N++){let H=T[N];I=I.concat(H.elements),H.categories.length&&(I=I.concat(A(H.categories)))}return I},q=T=>{let I=p.concat(A(f.categories)),N=[];if(T!=""){let H=new RegExp(T,"i");for(let W=0;W<I.length;W++)H.test(I[W].info.title)&&N.push(I[W])}m(T),v(N)},O=T=>{switch(T.prototype){case"lines":l(T.name);break;case"items":a(T.name);break;case"holes":o(T.name);break}c(T)};return R.jsxs(iA,{width:n,height:e,style:{...zA,...t},children:[R.jsx(nA,{children:"Catalog"}),_,R.jsxs("div",{style:sx,children:[R.jsx("span",{style:BA,children:"Search Element"}),R.jsx("input",{type:"text",style:VA,onChange:T=>{q(T.target.value)}})]}),S.size?R.jsxs("div",{style:HA,children:[R.jsx("span",{children:"Last Selected"}),b]}):null,R.jsx("div",{style:kA,children:d===""?[E,p.map(T=>R.jsx(ex,{element:T},T.name))]:x.map(T=>R.jsx(ex,{element:T},T.name))})]})},jA={MODE_IDLE:sn,MODE_2D_ZOOM_IN:qs,MODE_2D_ZOOM_OUT:Ds,MODE_2D_PAN:Ns,MODE_WAITING_DRAWING_LINE:Ar,MODE_WAITING_DRAWING_SURFACE:Us,MODE_DRAGGING_LINE:Vr,MODE_DRAGGING_VERTEX:Hr,MODE_DRAGGING_ITEM:Gr,MODE_DRAWING_SURFACE:di,MODE_DRAWING_LINE:Jn,MODE_DRAWING_HOLE:hr,MODE_DRAWING_ITEM:Cr,MODE_DRAGGING_HOLE:Wr,MODE_ROTATING_ITEM:Di};function XA({width:n,height:e,catalog:t}){const r=Ht(),{planner:i}=r,{mode:s}=i;return s===Tr?R.jsx(eA,{width:n,height:e,state:i,catalog:t,actions:{areaActions:{selectArea:r.selectArea},holesActions:{selectHole:r.selectHole,selectToolDrawingHole:r.selectToolDrawingHole,updateDrawingHole:r.updateDrawingHole,endDrawingHole:r.endDrawingHole,beginDraggingHole:r.beginDraggingHole,updateDraggingHole:r.updateDraggingHole,endDraggingHole:r.endDraggingHole},itemsActions:{selectItem:r.selectItem,selectToolDrawingItem:r.selectToolDrawingItem,updateDrawingItem:r.updateDrawingItem,endDrawingItem:r.endDrawingItem,beginDraggingItem:r.beginDraggingItem,updateDraggingItem:r.updateDraggingItem,endDraggingItem:r.endDraggingItem,beginRotatingItem:r.beginRotatingItem,updateRotatingItem:r.updateRotatingItem,endRotatingItem:r.endRotatingItem},linesActions:{selectLine:r.selectLine,selectToolDrawingLine:r.selectToolDrawingLine,beginDrawingLine:r.beginDrawingLine,updateDrawingLine:r.updateDrawingLine,endDrawingLine:r.endDrawingLine,beginDraggingLine:r.beginDraggingLine,updateDraggingLine:r.updateDraggingLine,endDraggingLine:r.endDraggingLine},projectActions:{loadProject:r.loadProject,newProject:r.newProject,openCatalog:r.openCatalog,changeCatalogPage:r.changeCatalogPage,goBackToCatalogPage:r.goBackToCatalogPage,selectToolEdit:r.selectToolEdit,unselectAll:r.unselectAll,setProperties:r.setProperties,setItemsAttributes:r.setItemsAttributes,setLinesAttributes:r.setLinesAttributes,setHolesAttributes:r.setHolesAttributes,remove:r.remove,undo:r.undo,rollback:r.rollback,openProjectConfigurator:r.openProjectConfigurator,initCatalog:r.initCatalog,updateMouseCoord:r.updateMouseCoord,updateZoomScale:r.updateZoomScale,toggleSnap:r.toggleSnap,copyProperties:r.copyProperties,pasteProperties:r.pasteProperties,pushLastSelectedCatalogElementToHistory:r.pushLastSelectedCatalogElementToHistory,setAlterateState:r.setAlterateState,setMode:r.setMode,addHorizontalGuide:r.addHorizontalGuide,addVerticalGuide:r.addVerticalGuide,removeHorizontalGuide:r.removeHorizontalGuide,removeVerticalGuide:r.removeVerticalGuide}}}):s===Ao?R.jsx(R.Fragment,{}):s===cf?R.jsx(WA,{width:n,height:e,catalog:t}):jA[s]?R.jsx(Bb,{width:n,height:e,catalog:t}):s===Z0?R.jsx(R.Fragment,{}):null}function $A(n){return un({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM13.5 10.5h-6"},child:[]}]})(n)}function YA(n){return un({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM10.5 7.5v6m3-3h-6"},child:[]}]})(n)}const KA=(n,e,t,r,i)=>r+(i-r)*(n-e)/(t-e),ZA=()=>{const{planner:n,viewer:e}=Ht(),{mode:t,mouse:r,zoom:i}=n,s=o=>{const a=parseInt(W1(i).toFixed());if(a===0&&o==="out"||a===100&&o==="in"||!e)return;const l=e==null?void 0:e.getValue(),c=l.viewerWidth/2,h=l.viewerHeight/2,f=o==="in"?-1:1,p=1.06,d=Math.max(-1,Math.min(1,f)),m=KA(d,-1,1,p,1/p);e.zoom(c,h,m)};if(uf.includes(t))return R.jsx("div",{className:"floor_planner-footerbar right-0 absolute rounded-tl w-auto z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] h-5 select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:R.jsx("div",{className:"relative float-left inline-block",title:"Scene Zoom Level",children:R.jsxs("div",{className:"flex items-center gap-2",children:[R.jsx($A,{className:"inline-block cursor-pointer",size:16,onClick:()=>s("out")})," ",R.jsxs("span",{children:[W1(i).toFixed(),"%"]})," ",R.jsx(YA,{className:"inline-block cursor-pointer",size:16,onClick:()=>s("in")})]})})})};function ox(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=ox(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function JA(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ox(n))&&(r&&(r+=" "),r+=e);return r}const Jp="-",QA=n=>{const e=t7(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{const a=o.split(Jp);return a[0]===""&&a.length!==1&&a.shift(),ax(a,e)||e7(o)},getConflictingClassGroupIds:(o,a)=>{const l=t[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},ax=(n,e)=>{var o;if(n.length===0)return e.classGroupId;const t=n[0],r=e.nextPart.get(t),i=r?ax(n.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=n.join(Jp);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},lx=/^\[(.+)\]$/,e7=n=>{if(lx.test(n)){const e=lx.exec(n)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},t7=n=>{const{theme:e,classGroups:t}=n,r={nextPart:new Map,validators:[]};for(const i in t)Qp(t[i],r,i,e);return r},Qp=(n,e,t,r)=>{n.forEach(i=>{if(typeof i=="string"){const s=i===""?e:cx(e,i);s.classGroupId=t;return}if(typeof i=="function"){if(n7(i)){Qp(i(r),e,t,r);return}e.validators.push({validator:i,classGroupId:t});return}Object.entries(i).forEach(([s,o])=>{Qp(o,cx(e,s),t,r)})})},cx=(n,e)=>{let t=n;return e.split(Jp).forEach(r=>{t.nextPart.has(r)||t.nextPart.set(r,{nextPart:new Map,validators:[]}),t=t.nextPart.get(r)}),t},n7=n=>n.isThemeGetter,r7=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,r=new Map;const i=(s,o)=>{t.set(s,o),e++,e>n&&(e=0,r=t,t=new Map)};return{get(s){let o=t.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){t.has(s)?t.set(s,o):i(s,o)}}},em="!",tm=":",i7=tm.length,s7=n=>{const{prefix:e,experimentalParseClassName:t}=n;let r=i=>{const s=[];let o=0,a=0,l=0,c;for(let m=0;m<i.length;m++){let x=i[m];if(o===0&&a===0){if(x===tm){s.push(i.slice(l,m)),l=m+i7;continue}if(x==="/"){c=m;continue}}x==="["?o++:x==="]"?o--:x==="("?a++:x===")"&&a--}const h=s.length===0?i:i.substring(l),f=o7(h),p=f!==h,d=c&&c>l?c-l:void 0;return{modifiers:s,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:d}};if(e){const i=e+tm,s=r;r=o=>o.startsWith(i)?s(o.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(t){const i=r;r=s=>t({className:s,parseClassName:i})}return r},o7=n=>n.endsWith(em)?n.substring(0,n.length-1):n.startsWith(em)?n.substring(1):n,a7=n=>{const e=Object.fromEntries(n.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(o=>{o[0]==="["||e[o]?(i.push(...s.sort(),o),s=[]):s.push(o)}),i.push(...s.sort()),i}},l7=n=>({cache:r7(n.cacheSize),parseClassName:s7(n),sortModifiers:a7(n),...QA(n)}),c7=/\s+/,u7=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=e,o=[],a=n.trim().split(c7);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:f,modifiers:p,hasImportantModifier:d,baseClassName:m,maybePostfixModifierPosition:x}=t(h);if(f){l=h+(l.length>0?" "+l:l);continue}let v=!!x,_=r(v?m.substring(0,x):m);if(!_){if(!v){l=h+(l.length>0?" "+l:l);continue}if(_=r(m),!_){l=h+(l.length>0?" "+l:l);continue}v=!1}const w=s(p).join(":"),E=d?w+em:w,S=E+_;if(o.includes(S))continue;o.push(S);const b=i(_,v);for(let A=0;A<b.length;++A){const q=b[A];o.push(E+q)}l=h+(l.length>0?" "+l:l)}return l};function h7(){let n=0,e,t,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=ux(e))&&(r&&(r+=" "),r+=t);return r}const ux=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=ux(n[r]))&&(t&&(t+=" "),t+=e);return t};function f7(n,...e){let t,r,i,s=o;function o(l){const c=e.reduce((h,f)=>f(h),n());return t=l7(c),r=t.cache.get,i=t.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const h=u7(l,t);return i(l,h),h}return function(){return s(h7.apply(null,arguments))}}const bn=n=>{const e=t=>t[n]||[];return e.isThemeGetter=!0,e},hx=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,fx=/^\((?:(\w[\w-]*):)?(.+)\)$/i,d7=/^\d+\/\d+$/,p7=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,m7=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,g7=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_7=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,v7=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xa=n=>d7.test(n),xt=n=>!!n&&!Number.isNaN(Number(n)),Ms=n=>!!n&&Number.isInteger(Number(n)),nm=n=>n.endsWith("%")&&xt(n.slice(0,-1)),Zi=n=>p7.test(n),x7=()=>!0,y7=n=>m7.test(n)&&!g7.test(n),dx=()=>!1,S7=n=>_7.test(n),E7=n=>v7.test(n),b7=n=>!Qe(n)&&!et(n),M7=n=>ya(n,vx,dx),Qe=n=>hx.test(n),ao=n=>ya(n,xx,y7),rm=n=>ya(n,R7,xt),px=n=>ya(n,gx,dx),w7=n=>ya(n,_x,E7),Wu=n=>ya(n,yx,S7),et=n=>fx.test(n),Dl=n=>Sa(n,xx),T7=n=>Sa(n,P7),mx=n=>Sa(n,gx),A7=n=>Sa(n,vx),C7=n=>Sa(n,_x),ju=n=>Sa(n,yx,!0),ya=(n,e,t)=>{const r=hx.exec(n);return r?r[1]?e(r[1]):t(r[2]):!1},Sa=(n,e,t=!1)=>{const r=fx.exec(n);return r?r[1]?e(r[1]):t:!1},gx=n=>n==="position"||n==="percentage",_x=n=>n==="image"||n==="url",vx=n=>n==="length"||n==="size"||n==="bg-size",xx=n=>n==="length",R7=n=>n==="number",P7=n=>n==="family-name",yx=n=>n==="shadow",I7=f7(()=>{const n=bn("color"),e=bn("font"),t=bn("text"),r=bn("font-weight"),i=bn("tracking"),s=bn("leading"),o=bn("breakpoint"),a=bn("container"),l=bn("spacing"),c=bn("radius"),h=bn("shadow"),f=bn("inset-shadow"),p=bn("text-shadow"),d=bn("drop-shadow"),m=bn("blur"),x=bn("perspective"),v=bn("aspect"),_=bn("ease"),w=bn("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...S(),et,Qe],A=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto","contain","none"],O=()=>[et,Qe,l],T=()=>[xa,"full","auto",...O()],I=()=>[Ms,"none","subgrid",et,Qe],N=()=>["auto",{span:["full",Ms,et,Qe]},Ms,et,Qe],H=()=>[Ms,"auto",et,Qe],W=()=>["auto","min","max","fr",et,Qe],Q=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ae=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...O()],se=()=>[xa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],B=()=>[n,et,Qe],ge=()=>[...S(),mx,px,{position:[et,Qe]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",A7,M7,{size:[et,Qe]}],de=()=>[nm,Dl,ao],ye=()=>["","none","full",c,et,Qe],Ee=()=>["",xt,Dl,ao],V=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[xt,nm,mx,px],he=()=>["","none",m,et,Qe],xe=()=>["none",xt,et,Qe],ee=()=>["none",xt,et,Qe],Pe=()=>[xt,et,Qe],le=()=>[xa,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Zi],breakpoint:[Zi],color:[x7],container:[Zi],"drop-shadow":[Zi],ease:["in","out","in-out"],font:[b7],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Zi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Zi],shadow:[Zi],spacing:["px",xt],text:[Zi],"text-shadow":[Zi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xa,Qe,et,v]}],container:["container"],columns:[{columns:[xt,Qe,et,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[Ms,"auto",et,Qe]}],basis:[{basis:[xa,"full","auto",a,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[xt,xa,"auto","initial","none",Qe]}],grow:[{grow:["",xt,et,Qe]}],shrink:[{shrink:["",xt,et,Qe]}],order:[{order:[Ms,"first","last","none",et,Qe]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:N()}],"col-start":[{"col-start":H()}],"col-end":[{"col-end":H()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:N()}],"row-start":[{"row-start":H()}],"row-end":[{"row-end":H()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...Q(),"normal"]}],"justify-items":[{"justify-items":[...ae(),"normal"]}],"justify-self":[{"justify-self":["auto",...ae()]}],"align-content":[{content:["normal",...Q()]}],"align-items":[{items:[...ae(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ae(),{baseline:["","last"]}]}],"place-content":[{"place-content":Q()}],"place-items":[{"place-items":[...ae(),"baseline"]}],"place-self":[{"place-self":["auto",...ae()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],w:[{w:[a,"screen",...se()]}],"min-w":[{"min-w":[a,"screen","none",...se()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",t,Dl,ao]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,et,rm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",nm,Qe]}],"font-family":[{font:[T7,Qe,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,et,Qe]}],"line-clamp":[{"line-clamp":[xt,"none",et,rm]}],leading:[{leading:[s,...O()]}],"list-image":[{"list-image":["none",et,Qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",et,Qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:[xt,"from-font","auto",et,ao]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[xt,"auto",et,Qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",et,Qe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",et,Qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ge()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ms,et,Qe],radial:["",et,Qe],conic:[Ms,et,Qe]},C7,w7]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:de()}],"gradient-via-pos":[{via:de()}],"gradient-to-pos":[{to:de()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],rounded:[{rounded:ye()}],"rounded-s":[{"rounded-s":ye()}],"rounded-e":[{"rounded-e":ye()}],"rounded-t":[{"rounded-t":ye()}],"rounded-r":[{"rounded-r":ye()}],"rounded-b":[{"rounded-b":ye()}],"rounded-l":[{"rounded-l":ye()}],"rounded-ss":[{"rounded-ss":ye()}],"rounded-se":[{"rounded-se":ye()}],"rounded-ee":[{"rounded-ee":ye()}],"rounded-es":[{"rounded-es":ye()}],"rounded-tl":[{"rounded-tl":ye()}],"rounded-tr":[{"rounded-tr":ye()}],"rounded-br":[{"rounded-br":ye()}],"rounded-bl":[{"rounded-bl":ye()}],"border-w":[{border:Ee()}],"border-w-x":[{"border-x":Ee()}],"border-w-y":[{"border-y":Ee()}],"border-w-s":[{"border-s":Ee()}],"border-w-e":[{"border-e":Ee()}],"border-w-t":[{"border-t":Ee()}],"border-w-r":[{"border-r":Ee()}],"border-w-b":[{"border-b":Ee()}],"border-w-l":[{"border-l":Ee()}],"divide-x":[{"divide-x":Ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...V(),"hidden","none"]}],"divide-style":[{divide:[...V(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...V(),"none","hidden"]}],"outline-offset":[{"outline-offset":[xt,et,Qe]}],"outline-w":[{outline:["",xt,Dl,ao]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",h,ju,Wu]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",f,ju,Wu]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:Ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[xt,ao]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":Ee()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",p,ju,Wu]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[xt,et,Qe]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[xt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[et,Qe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[xt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ge()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",et,Qe]}],filter:[{filter:["","none",et,Qe]}],blur:[{blur:he()}],brightness:[{brightness:[xt,et,Qe]}],contrast:[{contrast:[xt,et,Qe]}],"drop-shadow":[{"drop-shadow":["","none",d,ju,Wu]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",xt,et,Qe]}],"hue-rotate":[{"hue-rotate":[xt,et,Qe]}],invert:[{invert:["",xt,et,Qe]}],saturate:[{saturate:[xt,et,Qe]}],sepia:[{sepia:["",xt,et,Qe]}],"backdrop-filter":[{"backdrop-filter":["","none",et,Qe]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[xt,et,Qe]}],"backdrop-contrast":[{"backdrop-contrast":[xt,et,Qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",xt,et,Qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[xt,et,Qe]}],"backdrop-invert":[{"backdrop-invert":["",xt,et,Qe]}],"backdrop-opacity":[{"backdrop-opacity":[xt,et,Qe]}],"backdrop-saturate":[{"backdrop-saturate":[xt,et,Qe]}],"backdrop-sepia":[{"backdrop-sepia":["",xt,et,Qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",et,Qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[xt,"initial",et,Qe]}],ease:[{ease:["linear","initial",_,et,Qe]}],delay:[{delay:[xt,et,Qe]}],animate:[{animate:["none",w,et,Qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,et,Qe]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:xe()}],"rotate-x":[{"rotate-x":xe()}],"rotate-y":[{"rotate-y":xe()}],"rotate-z":[{"rotate-z":xe()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":["scale-3d"],skew:[{skew:Pe()}],"skew-x":[{"skew-x":Pe()}],"skew-y":[{"skew-y":Pe()}],transform:[{transform:[et,Qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",et,Qe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",et,Qe]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[xt,Dl,ao,rm]}],stroke:[{stroke:["none",...B()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Ur(...n){return I7(JA(n))}const Sx=({children:n,name:e,...t})=>{const[r,i]=ne.useState(t.opened||!1);return R.jsxs("div",{className:"select-none",style:{borderBottom:"1px solid #5e5e5e"},children:[R.jsxs("div",{className:"flex px-4 pt-2.5 pb-3 items-center gap-1 bg-[#2b2b2b] text-white cursor-pointer",onClick:()=>i(!r),children:[r?R.jsx(fA,{size:16}):R.jsx(dA,{size:16}),R.jsx("span",{className:"text-sm leading-none",children:e})]}),R.jsx("div",{className:Ur("text-[11px] text-[#EBEBEB] border border-[#222222] bg-[#424242]",r?"block":"hidden"),children:n})]})};function si({children:n,style:e,className:t,...r}){return R.jsx("label",{className:Ur("mb-1 text-xs capitalize font-bold text-white block",t),style:e,...r,children:n})}const Ci=({value:n,min:e,max:t,precision:r,onChange:i,onValid:s,onInvalid:o,style:a,placeholder:l})=>{const[c,h]=ne.useState(!0),[f,p]=ne.useState(n);let d=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${r}})?$`);ne.useEffect(()=>{e!==void 0&&!isNaN(e)&&isFinite(e)&&Number(f)<e&&p(e),t&&!isNaN(t)&&isFinite(t)&&Number(f)>t&&p(t)},[e,t,f]);const m=ne.useMemo(()=>parseFloat(String(n)).toFixed(r)!==parseFloat(String(f)).toFixed(r),[n,f,r]),x=v=>{if(v.stopPropagation(),c){let _=f!==""&&f!=="-"?parseFloat(String(f)):0;p(_),i({target:{value:_}})}};return R.jsxs("div",{className:"relative w-full",children:[R.jsx("input",{type:"text",value:d.test(String(f))?f:parseFloat(String(f)).toFixed(r),className:"block text-[13px] text-white h-[35px] w-full px-2 leading-5 rounded border border-[#5e5e5e] bg-[#2b2b2b] outline-none focus:outline-none",style:{...a},onChange:v=>{let _=d.test(v.target.value);_?(p(v.target.value),s&&s(v.nativeEvent)):o&&o(v.nativeEvent),h(_)},onKeyDown:v=>{var _=v.keyCode||v.which;(_==Pr.ENTER||_==Pr.TAB)&&m&&x(v)},placeholder:l}),R.jsx("div",{onClick:v=>{m&&x(v)},title:"Confirm",className:"absolute cursor-pointer w-[2em] h-[2em] text-white top-[0.35em] right-[0.35em] bg-dark-blue",style:{transition:"all 0.1s linear",visibility:m?"visible":"hidden",opacity:m?"1":"0"},children:R.jsx(TA,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},L7={fontSize:"13px",WebkitAppearance:"none"};function im({children:n,style:e,...t}){return R.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] text-white bg-[#5e5e5e]",style:{...L7,...e},...t,children:n})}const sm=({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s})=>{const{planner:o}=Ht(),{mode:a}=o,l=n.get("length")||0,c=n.get("_length")||l;n.get("_unit");const{hook:h,label:f,...p}=r,d=(m,x)=>{let v=Qn(m),_=n.merge({length:v,_length:m,_unit:x});return h?h(_,i,s,o).then(w=>e(w)):e(_)};if(a!==Tr)return R.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[R.jsx(si,{children:f}),R.jsxs("div",{className:"w-full flex",children:[R.jsx(Ci,{value:c,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:m=>d(m.target.value,Rr),onValid:t,...p}),R.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:R.jsx(im,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:Rr,onChange:m=>{},children:Q0.map(m=>R.jsx("option",{value:m,children:m},m))})})]})]})},Nl=({style:n,...e})=>R.jsx("input",{className:"block w-full px-2 text-sm leading-5 bg-[#2b2b2b] rounded border border-[#5e5e5e] outline-none h-[35px] text-white",style:{...n},type:"text",...e}),O7=({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i})=>{const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyString w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(Nl,{value:n,onChange:a=>o(a.target.value)})]})},q7=({element:n,attributeFormData:e,onUpdate:t,...r})=>{let i=e.has("name")?e.get("name"):n.name,s=e.has("offsetA")?e.get("offsetA"):n.offsetA,o=e.has("offsetB")?e.get("offsetB"):n.offsetA;return R.jsxs("div",{children:[R.jsx(O7,{value:i,onUpdate:a=>t("name",a),configs:{label:"Nome"},...r}),R.jsx(sm,{value:s,onUpdate:a=>t("offsetA",a),configs:{label:"Offset 1",min:0,max:1/0,precision:2},...r}),R.jsx(sm,{value:o,onUpdate:a=>t("offsetB",a),configs:{label:"Offset 2",min:0,max:1/0,precision:2},...r})]})},D7=({element:n,onUpdate:e,attributeFormData:t,...r})=>{let i=t.has("name")?t.get("name"):n.name,s=t.has("x")?t.get("x"):n.x,o=t.has("y")?t.get("y"):n.y,a=t.has("rotation")?t.get("rotation"):n.rotation,l=t.has("altitude")?t.get("altitude"):n.altitude;return R.jsx("table",{className:"w-full",children:R.jsxs("tbody",{children:[R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Name"}),R.jsx("td",{children:R.jsx(Nl,{value:i,onChange:c=>e("name",c.target.value),style:{textAlign:"left"}})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"X"}),R.jsx("td",{children:R.jsx(Ci,{value:s,onChange:c=>e("x",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Y"}),R.jsx("td",{children:R.jsx(Ci,{value:o,onChange:c=>e("y",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Rotation"}),R.jsx("td",{children:R.jsx(Ci,{value:a,onChange:c=>e("rotation",c.target.value),style:{textAlign:"left"},precision:2,...r})})]}),R.jsxs("tr",{children:[R.jsx("td",{className:"w-[6em]",children:"Elevation"}),R.jsx("td",{children:R.jsx(Ci,{value:l,onChange:c=>e("altitude",c.target.value),style:{textAlign:"left"},precision:2,...r})})]})]})})},N7=({element:n,onUpdate:e,attributeFormData:t})=>{let r=t.has("name")?t.get("name"):n.name,i=t.has("lineLength")?t.get("lineLength"):null;return R.jsxs("div",{children:[R.jsxs("div",{className:"w-full mb-2",children:[R.jsx(si,{children:"Name"}),R.jsx(Nl,{value:r,onChange:s=>e("name",s.target.value),style:{textAlign:"left"}})]}),R.jsx(sm,{value:i,onUpdate:s=>e("lineLength",s),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},U7=({element:n,onUpdate:e,onValid:t,attributeFormData:r,...i})=>n.prototype==="items"?R.jsx(D7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):n.prototype==="lines"?R.jsx(N7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):n.prototype==="holes"?R.jsx(q7,{element:n,onUpdate:e,onValid:t,attributeFormData:r,...i}):null,oi=2,F7=(n,e,t)=>{switch(n=typeof n.misc=="object"?n.set("misc",Ie(n.misc)):n,n.prototype){case"items":return Ie(n);case"lines":{let r=e.vertices.get(n.vertices.get(0)),i=e.vertices.get(n.vertices.get(1)),s=Cn(r.x,r.y,i.x,i.y),o=n.misc.get("_unitLength")||t.unit,a=Kr(s).from(t.unit).to(o);return Ie({vertexOne:r,vertexTwo:i,lineLength:Ie({length:s,_length:a,_unit:o})})}case"holes":{let r=e.lines.get(n.line),{x:i,y:s}=e.vertices.get(r.vertices.get(0)),{x:o,y:a}=e.vertices.get(r.vertices.get(1)),l=Cn(i,s,o,a),c=l*n.offset-n.properties.get("width").get("length")/2,h=n.misc.get("_unitA")||t.unit,f=Kr(c).from(t.unit).to(h),p=l-l*n.offset-n.properties.get("width").get("length")/2,d=n.misc.get("_unitB")||t.unit,m=Kr(p).from(t.unit).to(d);return Ie({offset:n.offset,offsetA:Ie({length:Qn(c,oi),_length:Qn(f,oi),_unit:h}),offsetB:Ie({length:Qn(p,oi),_length:Qn(m,oi),_unit:d})})}case"areas":return Ie({});default:return null}},z7=(n,e)=>{const t=e.getElement(n.type),r={};for(const i in t.properties)r[i]=Ie({currentValue:n.properties.has(i)?n.properties.get(i):At(t.properties[i].defaultValue),configs:t.properties[i]});return Ie(r)},k7=({element:n,layer:e,catalog:t})=>{const{planner:r,setItemsAttributes:i,setProperties:s,setLinesAttributes:o,setHolesAttributes:a}=Ht(),[l,c]=ne.useState(F7(n,e,t)),[h,f]=ne.useState(z7(n,t)),p=({propertiesFormData:x,attributesFormData:v})=>{if(x){let _=x.map(w=>w.get("currentValue"));s(_)}if(v)switch(n.prototype){case"items":{i(v);break}case"lines":{o(v);break}case"holes":{a(v);break}}},d=(x,v)=>{if(!l)return;let _;switch(n.prototype){case"items":{_=l.set(x,v);break}case"lines":{switch(x){case"lineLength":{let w=l.get("vertexOne"),E=l.get("vertexTwo"),[S,b]=rl([w,E]),A=vc(S.x,S.y,b.x,b.y,v.get("length"),oi);_=l.withMutations(q=>{q.set(w===S?"vertexTwo":"vertexOne",b.merge(A)),q.set("lineLength",v)});break}case"vertexOne":case"vertexTwo":{_=l.withMutations(w=>{w.set(x,w.get(x).merge(v));let E=mc(w.get("vertexOne"),w.get("vertexTwo"));w.mergeIn(["lineLength"],w.get("lineLength").merge({length:E,_length:Kr(E).from(t.unit).to(w.get("lineLength").get("_unit"))}))});break}default:{_=l.set(x,v);break}}break}case"holes":{switch(x){case"offsetA":{let w=e.lines.get(n.line),E=rl([e.vertices.get(w.vertices.get(0)),e.vertices.get(w.vertices.get(1))]),[{x:S,y:b},{x:A,y:q}]=E,O=df(S,b,A,q),T=Cn(S,b,A,q),I=n.properties.get("width").get("length"),N=I/2,H=v.get("length");H=Math.max(H,0),H=Math.min(H,T-I);let W=(H+N)*Math.cos(O)+S,Q=(H+N)*Math.sin(O)+b,ae=On(S,b,A,q,W,Q),J=Qn(T-T*ae-N,oi),se=l.getIn(["offsetB","_unit"]),B=Ie({length:J,_length:Kr(J).from(t.unit).to(se),_unit:se});_=l.set("offsetB",B).set("offset",ae);let ge=Ie({length:Qn(H,oi),_unit:v.get("_unit"),_length:Qn(Kr(H).from(t.unit).to(v.get("_unit")),oi)});_=l.set(x,ge);break}case"offsetB":{let w=e.lines.get(n.line),E=rl([e.vertices.get(w.vertices.get(0)),e.vertices.get(w.vertices.get(1))]),[{x:S,y:b},{x:A,y:q}]=E,O=df(S,b,A,q),T=Cn(S,b,A,q),I=n.properties.get("width").get("length"),N=I/2,H=v.get("length");H=Math.max(H,0),H=Math.min(H,T-I);let W=A-(H+N)*Math.cos(O),Q=q-(H+N)*Math.sin(O),ae=On(S,b,A,q,W,Q),J=Qn(T*ae-N,oi),se=l.getIn(["offsetA","_unit"]),B=Ie({length:J,_length:Kr(J).from(t.unit).to(se),_unit:se});_=l.set("offsetA",B).set("offset",ae);let ge=Ie({length:Qn(H,oi),_unit:v.get("_unit"),_length:Qn(Kr(H).from(t.unit).to(v.get("_unit")),oi)});_=l.set(x,ge);break}default:{_=l.set(x,v);break}}break}}_&&(c(_),p({attributesFormData:_,propertiesFormData:h}))},m=(x,v)=>{const _=h.setIn([x,"currentValue"],v);f(_),p({propertiesFormData:_,attributesFormData:l})};return R.jsxs("div",{children:[R.jsx(U7,{element:n,onValid:()=>{},onUpdate:d,attributeFormData:l}),h.entrySeq().map(([x,v])=>{let _=v.get("currentValue"),w=v.get("configs"),{Editor:E}=t.getPropertyType(w.type);return R.jsx(E,{propertyName:x,value:_,configs:w,onUpdate:S=>m(x,S),state:r,sourceElement:n,internalState:{attributesFormData:l,propertiesFormData:h}},x)})]})},B7=()=>R.jsx("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:R.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})}),V7=[sn,qs,Ds,Ns,Tr,Ao,Ar,Jn,hr,Cr,Vr,Hr,Gr,Wr,Di,af,lf],H7=({catalog:n})=>{const{planner:e}=Ht(),{scene:t,mode:r}=e;return V7.includes(r)?t.layers.valueSeq().flatMap(s=>vn().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>({element:o,layer:s}))).toArray().length===0?R.jsx(B7,{}):R.jsx("div",{children:t.layers.valueSeq().map(s=>vn().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected&&o.type!=="surface").map(o=>R.jsx(Sx,{name:"Properties",opened:!0,children:R.jsx("div",{className:"py-[5px] px-[15px]",children:R.jsx(k7,{element:o,layer:s,catalog:n})})},o.id)).valueSeq())}):null},G7={MODE_IDLE:sn,MODE_2D_ZOOM_IN:qs,MODE_2D_ZOOM_OUT:Ds,MODE_2D_PAN:Ns,MODE_3D_VIEW:Tr,MODE_3D_FIRST_PERSON:Ao,MODE_WAITING_DRAWING_LINE:Ar,MODE_DRAWING_LINE:Jn,MODE_DRAWING_HOLE:hr,MODE_DRAWING_ITEM:Cr,MODE_DRAGGING_LINE:Vr,MODE_DRAGGING_VERTEX:Hr,MODE_DRAGGING_ITEM:Gr,MODE_DRAGGING_HOLE:Wr,MODE_FITTING_IMAGE:lf,MODE_UPLOADING_IMAGE:af,MODE_ROTATING_ITEM:Di},W7={width:"100%"},Xu={width:"6em"},$u={textAlign:"left"},j7={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},X7={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},Ex={width:"2em"},$7=({groupID:n})=>{const{planner:e,setGroupAttributes:t,groupTranslate:r,groupRotate:i,removeFromGroup:s}=Ht(),{mode:o}=e;if(!n||!G7[o])return null;const a=e.getIn(["scene","groups",n]),l=a.get("elements");return R.jsx(Sx,{name:`Group [${a.get("name")}]`,opened:!0,children:R.jsxs("div",{style:{padding:"5px 15px"},children:[R.jsx("table",{style:W7,children:R.jsxs("tbody",{children:[R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Name"}),R.jsx("td",{children:R.jsx(Nl,{value:a.get("name"),onChange:c=>t(n,Ie({name:c.target.value})),style:$u})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"X"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("x"),onChange:c=>r(n,c.target.value,a.get("y")),style:$u,precision:2})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Y"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("y"),onChange:c=>r(n,a.get("x"),c.target.value),style:$u,precision:2})})]}),R.jsxs("tr",{children:[R.jsx("td",{style:Xu,children:"Rotation"}),R.jsx("td",{children:R.jsx(Ci,{value:a.get("rotation"),onChange:c=>i(n,c.target.value),style:$u,precision:2})})]})]})}),l.size?R.jsxs("div",{children:[R.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),R.jsxs("table",{style:X7,children:[R.jsx("thead",{children:R.jsxs("tr",{children:[R.jsx("th",{style:Ex}),R.jsx("th",{children:"Layer"}),R.jsx("th",{children:"Prototype"}),R.jsx("th",{children:"Name"})]})}),R.jsx("tbody",{children:l.entrySeq().map(([c,h])=>h.entrySeq().map(([f,p])=>p.valueSeq().map(d=>{let m=e.getIn(["scene","layers",c,f,d]);return R.jsxs("tr",{children:[R.jsx("td",{style:Ex,title:"Un-chain Element from Group",children:R.jsx(_A,{onClick:()=>s(n,c,f,d),style:j7})}),R.jsx("td",{style:{textAlign:"center"},children:c}),R.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:f}),R.jsx("td",{style:{textAlign:"center"},children:m.name})]},d)})))})]})]}):null]})})},Y7=({catalog:n,width:e=280})=>{const{planner:t}=Ht(),r=t.getIn(["scene","selectedLayer"]),i=t.getIn(["scene","layers",r,"selected"]),s=t.getIn(["scene","layers",r,"lines"]),o=t.getIn(["scene","groups"]).findEntry(h=>h.get("selected")),a=i.lines.filter(h=>{var f;return((f=s.get(h))==null?void 0:f.get("type"))!=="surface"}),l=a.size>1||i.items.size>1||i.holes.size>1||i.areas.size>1||a.size+i.items.size+i.holes.size+i.areas.size>1;return a.size>0||i.items.size>0||i.holes.size>0||i.areas.size>0?R.jsxs("aside",{onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation(),className:"floor_planner-sidebar bg-[#424242] h-full block overflow-y-auto overflow-x-hidden pb-5",style:{width:e},children:[!l&&R.jsx(H7,{catalog:n}),!!o&&R.jsx($7,{groupID:o?o[0]:null})]}):null},K7=({anchorEl:n,title:e,position:t="right",visible:r,collisionPadding:i=8})=>{const s=ne.useRef(null);return ne.useLayoutEffect(()=>{if(!n||!s.current)return;const o=s.current;if(!r){o.style.opacity="0",o.style.transform="scale(0.95)",o.style.pointerEvents="none";return}o.style.visibility="hidden",o.style.top="-9999px",o.style.left="-9999px",o.style.opacity="0",o.style.transform="scale(0.95)";const a=o.getBoundingClientRect(),l=n.getBoundingClientRect(),c=8,h=window.innerWidth,f=window.innerHeight,p={right:h-l.right>=a.width+c+i,left:l.left>=a.width+c+i,top:l.top>=a.height+c+i,bottom:f-l.bottom>=a.height+c+i};let d=t;p[t]||(d=["right","left","top","bottom"].find(_=>p[_])??t);let m=0,x=0;switch(d){case"right":m=l.top+l.height/2-a.height/2,x=l.right+c;break;case"left":m=l.top+l.height/2-a.height/2,x=l.left-a.width-c;break;case"top":m=l.top-a.height-c,x=l.left+l.width/2-a.width/2;break;case"bottom":m=l.bottom+c,x=l.left+l.width/2-a.width/2;break}const v=(_,w,E)=>Math.min(Math.max(_,w),E);o.style.position="fixed",o.style.top=`${v(m,i,f-a.height-i)}px`,o.style.left=`${v(x,i,h-a.width-i)}px`,o.style.visibility="visible",o.style.opacity="1",o.style.transform="scale(1)",o.style.pointerEvents="none"},[r,n,t,i]),co.createPortal(R.jsx("div",{ref:s,className:`
3923
3923
  z-[9999]
3924
3924
  fixed
3925
3925
  bg-black text-white text-xs
@@ -3928,11 +3928,11 @@ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3928
3928
  transform-gpu
3929
3929
  transition-opacity transition-transform
3930
3930
  duration-150 ease-out
3931
- `,children:e}),document.body)},ir=({active:n,tooltip:e,tooltipPosition:t="right",onClick:r,children:i,className:s,showDelay:o=300,hideDelay:a=0})=>{const l=ne.useRef(null),c=ne.useRef(null),h=ne.useRef(null),[f,p]=ne.useState(!1),d=()=>{c.current&&(window.clearTimeout(c.current),c.current=null),h.current&&(window.clearTimeout(h.current),h.current=null)},m=()=>{d(),c.current=window.setTimeout(()=>{p(!0)},o)},x=()=>{d(),h.current=window.setTimeout(()=>{p(!1)},a)};return R.jsxs(R.Fragment,{children:[R.jsx("div",{ref:l,className:Nr("w-[30px] h-[30px] flex items-center justify-center text-[25px] cursor-pointer",s),onMouseEnter:m,onMouseLeave:x,onClick:r,children:R.jsx("div",{className:Nr("transition-colors",n?"text-dark-blue":"text-[#C2C2C2]"),children:i})}),R.jsx(K7,{anchorEl:l.current,title:e,visible:f,position:t})]})},bx=()=>new Promise(async n=>{const e=document.getElementsByTagName("svg");if(!e.length)return;let t=e[0];for(let p=1;p<e.length;p++)e[p].width.baseVal.value>t.width.baseVal.value&&(t=e[p]);const r=t.cloneNode(!0),i=r.querySelectorAll("image");await Promise.all(Array.from(i).map(async p=>{const d=p.getAttribute("href")||p.getAttribute("xlink:href");if(d)try{const x=await(await fetch(d)).blob(),v=new FileReader;await new Promise(_=>{v.onloadend=()=>{p.setAttribute("href",v.result),_()},v.readAsDataURL(x)})}catch(m){console.warn("⚠️ Could not inline image:",d,m)}}));const o=new XMLSerializer().serializeToString(r),a=t.width.baseVal.value,l=t.height.baseVal.value,c=document.createElement("canvas");c.width=a,c.height=l;const h=c.getContext("2d");h.fillStyle="white",h.fillRect(0,0,a,l);const f=new Image;f.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(o)))}`,f.onload=()=>{h.drawImage(f,0,0,a,l),n(c.toDataURL("image/png"))}});function Mx(n){return un({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(n)}const wx=n=>{let e=document.createElement("a"),t="output"+Date.now()+".png";t=window.prompt("Insert output filename",t),t&&(e.setAttribute("download",t),e.href=n,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e))};function Z7({mode:n}){const e=r=>{r.preventDefault();const i=document.getElementsByTagName("canvas")[0];wx(i.toDataURL())},t=async r=>{r.preventDefault(),bx().then(wx)};return[Ao,Br].includes(n)?R.jsx(ir,{active:!1,tooltip:"Get Screenshot",onClick:e,children:R.jsx(Mx,{size:28})}):[sn,qs,Ds,Ns,Tr,Us,Vr,Hr,Gr,Jn,di,hr,Ar,Wr,Di].includes(n)?R.jsx(ir,{active:!1,tooltip:"Get Screenshot",onClick:t,children:R.jsx(Mx,{size:28})}):null}function J7(n){return un({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(n)}function Q7(n){return un({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M224,48H32a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H224a8,8,0,0,0,8-8V56A8,8,0,0,0,224,48ZM88,144V112h80v32Zm-48,0V112H72v32Zm144-32h32v32H184Zm32-16H136V64h80ZM120,64V96H40V64ZM40,160h80v32H40Zm96,32V160h80v32Z"},child:[]}]})(n)}const e9=/^.*$/;function t9({onChange:n,...e}){const[t,r]=ne.useState(""),i=ne.useRef(null);ne.useEffect(()=>{r(e.value)},[e.value]);const s=a=>{if(!a)return;const l=a.target.value;e9.test(l)&&n&&n(a)},o=a=>{(!a.key||a.key==="Enter")&&s({target:{value:t}})};return R.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[R.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:e.value},onClick:()=>{i.current&&i.current.click()},children:R.jsx("input",{ref:i,type:"color",onChange:s,value:e.value,className:"absolute invisible h-full w-full"})}),R.jsx("div",{className:"flex-1 pl-2",children:R.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:t,onKeyDown:o,onChange:a=>r(a.target.value),onBlur:o})})]})}function Tx({value:n,onUpdate:e,configs:t,propertyName:r,sourceElement:i,internalState:s}){const o=i.toJS(),{planner:a}=Ht(),l=c=>t.hook?t.hook(c,i,s,a).then(h=>e(h)):e(c);return ne.useEffect(()=>{var p;const c=o.type==="wall",h=r==="colorA"||r==="colorB",f=!((p=o.properties)!=null&&p[r]);c&&h&&f&&l(n)},[o.type,o.properties,r,l,n]),R.jsxs("div",{className:"PropertyColor w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(t9,{value:n,onChange:c=>l(c.target.value)})]})}function Ax({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(im,{value:n,onChange:a=>o(a.target.value),children:vn(t.values).entrySeq().map(([a,l])=>R.jsx("option",{value:a,children:l},a))})]})}function Cx({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht();let o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyString w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(Nl,{value:n,onChange:a=>o(a.target.value)})]})}function Rx({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Ht(),a=l=>{let c=parseFloat(l);return isNaN(c)&&(c=0),r.hook?r.hook(c,i,s,o).then(h=>e(h)):e(c)};return R.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[R.jsx(si,{children:r.label}),R.jsx(Ci,{value:n,onChange:l=>a(l.target.value),onValid:t,min:r.min,max:r.max})]})}function Px({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Ht(),{mode:a}=o,l=n.get("length")||0,c=n.get("_length")||l,h=n.get("_unit")||Cr,{hook:f,label:p,...d}=r,m=(x,v)=>{let _=Qn(x),w=n.merge({length:v!==Cr?Kr(_).from(v).to(Cr):_,_length:x,_unit:v});return f?f(w,i,s,o).then(E=>e(E)):e(w)};if(a!==Br)return R.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[R.jsx(si,{children:p}),R.jsxs("div",{className:"w-full flex",children:[R.jsx(Ci,{value:c,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:x=>m(x.target.value,h),onValid:t,...d}),R.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:R.jsx(im,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:h,onChange:x=>{},children:Q0.map(x=>R.jsx("option",{value:x,children:x},x))})})]})]})}function n9({type:n="button",size:e="normal",style:t,styleHover:r,children:i,...s}){const[o,a]=ne.useState(!1),l="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",c=e==="small"?"text-[12px] px-2 py-[3px]":e==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},f={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return R.jsx("button",{type:n,className:`${l} ${c}`,style:{...o?{...f,...r}:{...h,...t}},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),...s,children:i})}const Yu={tableStyle:{width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle:{width:"6em",textTransform:"capitalize"}};function Ix({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsx("table",{className:"PropertyToggle",style:Yu.tableStyle,children:R.jsx("tbody",{children:R.jsxs("tr",{children:[R.jsx("td",{style:Yu.firstTdStyle,children:R.jsx(si,{children:t.label})}),R.jsx("td",{children:R.jsx(n9,{onClick:()=>o(!n),size:"small",children:t.actionName})})]})})})}function Lx({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[R.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:n,onChange:()=>o(!n)}),R.jsx(si,{className:"mb-0",children:t.label})]})}function Ox(){return null}function qx({value:n,configs:e}){return R.jsx("table",{className:"PropertyReadOnly",style:Yu.tableStyle,children:R.jsx("tbody",{children:R.jsxs("tr",{children:[R.jsx("td",{style:Yu.firstTdStyle,children:R.jsx(si,{children:e.label})}),R.jsx("td",{children:R.jsx("div",{children:n})})]})})})}class r9{constructor(e=Cr){ht(this,"elements");ht(this,"categories");ht(this,"propertyTypes");ht(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=e,this.registerMultiplePropertyType([["color",Tx,Tx],["enum",Ax,Ax],["string",Cx,Cx],["number",Rx,Rx],["length-measure",Px,Px],["toggle",Ix,Ix],["checkbox",Lx,Lx],["hidden",Ox,Ox],["read-only",qx,qx]])}getElement(e){if(this.hasElement(e))return this.elements[e];throw new Error(`Element ${e} does not exist in catalog`)}getCategory(e){if(this.hasCategory(e))return this.categories[e];throw new Error(`Category ${e} does not exist in catalog`)}getPropertyType(e){if(this.propertyTypes.hasOwnProperty(e))return this.propertyTypes[e];throw new Error(`Element ${e} does not exist in catalog`)}registerElement(e){e.properties=e.properties||{},this.validateElement(e)&&(this.elements[e.name]=e,this.categories.root.elements.push(this.elements[e.name]))}registerMultipleElements(e){e.forEach(t=>this.registerElement(t))}registerPropertyType(e,t,r){this.propertyTypes[e]={type:e,Viewer:t,Editor:r}}registerMultiplePropertyType(e){e.forEach(t=>this.registerPropertyType(...t))}validateElement(e){if(!e.hasOwnProperty("name"))throw new Error("Element not valid");let t=e.name;if(!e.hasOwnProperty("prototype"))throw new Error(`Element ${t} doesn't have prototype`);if(!e.hasOwnProperty("info"))throw new Error(`Element ${t} doesn't have info`);if(!e.info.hasOwnProperty("tag"))throw new Error(`Element ${t} doesn't have tag`);if(!e.info.hasOwnProperty("description"))throw new Error(`Element ${t} doesn't have description`);if(!e.info.hasOwnProperty("image"))throw new Error(`Element ${t} doesn't have image`);if(!e.hasOwnProperty("render2D"))throw new Error(`Element ${t} doesn't have render2D handler`);if(!e.hasOwnProperty("render3D"))throw new Error(`Element ${t} doesn't have render3D handler`);if(!e.hasOwnProperty("properties"))throw new Error(`Element ${t} doesn't have properties`);for(let r in e.properties){let i=e.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${t}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${t}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(e){return this.elements.hasOwnProperty(e)}registerCategory(e,t,r){return this.validateCategory(e,t)?(this.categories[e]={name:e,label:t,categories:[],elements:[]},this.categories.root.categories.push(this.categories[e]),r&&r.length&&r.forEach(i=>this.addToCategory(e,i)),this.categories[e]):null}addToCategory(e,t){if(this.hasElement(t.name))this.categories[e].elements.push(t),this.categories.root.elements.splice(this.categories.root.elements.indexOf(t),1);else if(this.hasCategory(t.name))this.categories[e].categories.push(t),this.categories.root.categories.splice(this.categories.root.categories.indexOf(t),1);else throw new Error(`child ${t} is either category nor element`)}categoryHasElement(e,t){return this.hasCategory(e)&&this.categories[e].elements.some(r=>r.name===t)}validateCategory(e,t){if(!e)throw new Error("Category has undefined name");if(e==="")throw new Error("Category has empty name");if(this.hasCategory(e))throw new Error("Category has already been registered");return!0}hasCategory(e){return this.categories.hasOwnProperty(e)}}function i9(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const s9=({term:n="",placeholder:e="Search",noSpacing:t=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a,value:l})=>{const[c,h]=ne.useState("");return ne.useEffect(()=>{l!==void 0&&l!==c&&h(l??"")},[l]),R.jsxs("div",{className:Nr(`relative w-full ${t?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[R.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${t?"":"ml-2"}`,style:{zIndex:2},children:R.jsx(i9,{size:18})}),i?R.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):R.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:e,onChange:f=>{o(f.target.value,f),h(f.target.value)},value:c,onClick:r??(()=>!1)}),r!==null&&s&&R.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${t?"":"ml-2"}`,style:{zIndex:1},children:R.jsx(gA,{className:"-mb-1"})})]})},Dx=0,Nx=58,Ux=n=>{const e=[{label:"All Categories",value:"all"}],t=n.map(r=>r.info.tag);for(const r of t){let i=e;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return e},o9=({selected:n,options:e,onChange:t})=>{const r=ne.useMemo(()=>e.findIndex(s=>s.value===n),[e,n]),i=100/e.length;return R.jsxs("div",{className:"relative w-full rounded-lg border border-gray-200 bg-white p-1",children:[R.jsx("div",{className:"absolute top-1 bottom-1 rounded-md bg-slate-900 transition-transform duration-300 ease-out",style:{width:`calc(${i}% - 4px)`,transform:`translateX(${r*100}%)`}}),R.jsx("div",{role:"tablist",className:"relative z-10 grid",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(s=>{const o=s.value===n;return R.jsx("button",{role:"tab","aria-selected":o,className:Nr("h-8 text-sm font-medium capitalize transition-colors",o?"text-white":"text-gray-700 hover:text-black"),onClick:()=>t(s),children:s.label},s.value)})})]})},Fx=({options:n,selections:e,level:t,onChange:r})=>{var i,s;return R.jsxs(R.Fragment,{children:[R.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:e[t]||"all",onChange:o=>r(t,o.target.value),children:n.map(o=>R.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),e[t]&&e[t]!=="all"&&((i=n.find(o=>o.value===e[t]))==null?void 0:i.options)&&R.jsx(Fx,{options:((s=n.find(o=>o.value===e[t]))==null?void 0:s.options)||[],level:t+1,selections:e,onChange:r})]})},a9=({catalog:n,popupEvent:e,onClose:t})=>{const{setToast:r,selectToolDrawingLine:i,selectToolDrawingItem:s,selectToolDrawingHole:o,pushLastSelectedCatalogElementToHistory:a}=Ht(),[l,c]=ne.useState([]),[h,f]=ne.useState(""),[p,d]=ne.useState([]),[m,x]=ne.useState(["all"]),[v,_]=ne.useState([]),[w,E]=ne.useState(""),S=ne.useRef(null),b=ne.useRef(null),A=()=>{E(""),d([]),c([]),x(["all"]),f("")};ne.useEffect(()=>{if(e){A();const W=n.getCategory(e.page).elements.filter(J=>J.info.visibility?J.info.visibility.catalog:!0);S.current=e.page,_(W);const{x:Q,y:ae}=e.rect;if(b.current={top:ae+Dx,left:Q+Nx},e.page==="objects"){const J=Array.from(new Set(W.map(ge=>ge.info.category).filter(Boolean))),se=J[0]??"",B=W.filter(ge=>ge.info.category===se);f(se),c(J),d(Ux(B))}}},[e]);const q=()=>{t()},O=H=>{q(),e&&r({text:`Cancel placing ${e.page}`}),setTimeout(()=>{switch(H.prototype){case"lines":i(H.name);break;case"items":s(H.name);break;case"holes":o(H.name);break}a(H)},0)},T=(H,W)=>{const Q=[...m.slice(0,H),W];x(Q)},I=(H,W)=>{H.preventDefault();const Q=H.currentTarget.closest(".fp_side-bar");let ae=!1;const J=ge=>{const{clientX:F,clientY:X}=ge,de=Q==null?void 0:Q.getBoundingClientRect();de&&(F<de.left||F>de.right||X<de.top||X>de.bottom)&&(ae=!0),ae&&(O(W),B())},se=()=>B(),B=()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",se)};document.addEventListener("mousemove",J),document.addEventListener("mouseup",se)},N=ne.useMemo(()=>v.filter(H=>{const W=H.info.title.toLowerCase().includes(w.toLowerCase()),Q=h?H.info.category===h:H,ae=m.every(J=>J==="all"||H.info.tag.includes(J));return W&&Q&&ae}),[v,w,h,m]);return R.jsxs(R.Fragment,{children:[e&&R.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:q}),R.jsxs("div",{style:e&&e.rect?{top:e.rect.y+Dx,left:e.rect.x+Nx}:b.current?b.current:{},className:Nr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[250px] !min-w-[330px] max-w-[330px] !max-h-[510px] transition-all duration-200 ease-out transform",e?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[R.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[R.jsx("div",{className:"flex items-center gap-1",children:R.jsx("span",{className:Nr("flex flex-col gap-0.5"),children:R.jsx("span",{className:"fp-sidebar-label capitalize",children:(e==null?void 0:e.page)??S.current})})}),R.jsxs("div",{className:Nr("fp-highlight"),children:[l.length>1&&R.jsx(o9,{selected:h,onChange:H=>{x(["all"]),f(H.value),d(Ux(v.filter(W=>W.info.category===H.value)))},options:l.map(H=>({label:H,value:H}))}),p.length>0&&R.jsx(Fx,{options:p,level:0,selections:m,onChange:T}),R.jsx(s9,{className:"mt-0",placeholder:"Search",value:w,onSearch:(H,W)=>{W.preventDefault(),W.stopPropagation(),E(H)}})]})]}),N.length>0?R.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:H=>H.stopPropagation(),children:N.map(H=>R.jsxs("div",{className:"w-full space-y-1.5",children:[R.jsx("div",{className:"fp-aspect-ratio-container",children:R.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:W=>I(W,H),children:R.jsx("img",{draggable:!1,className:"fp-item-image",alt:H.info.title,src:H.info.image})})}),R.jsx("p",{className:"text-xs font-semibold capitalize",children:H.info.description})]},H.name.replace(/\s+/g,"_")))}):R.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:R.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function l9(n){return un({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function c9(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function u9(n){return un({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M3.00014 2.73895C3.00014 2.94698 2.76087 3.06401 2.59666 2.93628L1.00386 1.69744C0.875177 1.59735 0.875177 1.40286 1.00386 1.30277L2.59666 0.063928C2.76087 -0.0637944 3.00014 0.0532293 3.00014 0.261266V1.00012H9.00009V0.261296C9.00009 0.0532591 9.23936 -0.0637646 9.40358 0.0639578L10.9964 1.3028C11.1251 1.40289 11.1251 1.59738 10.9964 1.69747L9.40358 2.93631C9.23936 3.06404 9.00009 2.94701 9.00009 2.73898V2.00012H3.00014V2.73895ZM9.50002 4.99998H2.50002C2.22388 4.99998 2.00002 5.22384 2.00002 5.49998V12.5C2.00002 12.7761 2.22388 13 2.50002 13H9.50002C9.77616 13 10 12.7761 10 12.5V5.49998C10 5.22384 9.77616 4.99998 9.50002 4.99998ZM2.50002 3.99998C1.67159 3.99998 1.00002 4.67156 1.00002 5.49998V12.5C1.00002 13.3284 1.67159 14 2.50002 14H9.50002C10.3284 14 11 13.3284 11 12.5V5.49998C11 4.67156 10.3284 3.99998 9.50002 3.99998H2.50002ZM14.7389 6.00001H14V12H14.7389C14.9469 12 15.064 12.2393 14.9362 12.4035L13.6974 13.9963C13.5973 14.125 13.4028 14.125 13.3027 13.9963L12.0639 12.4035C11.9362 12.2393 12.0532 12 12.2612 12H13V6.00001H12.2612C12.0532 6.00001 11.9361 5.76074 12.0639 5.59653L13.3027 4.00373C13.4028 3.87505 13.5973 3.87505 13.6974 4.00374L14.9362 5.59653C15.0639 5.76074 14.9469 6.00001 14.7389 6.00001Z",fill:"currentColor"},child:[]}]})(n)}const zx={fontSize:"19px",textDecoration:"none",fontWeight:"bold",margin:"0px",userSelect:"none"},h9=({style:n})=>R.jsx("p",{style:{...zx,...n},children:"2D"}),f9=({style:n})=>R.jsx("p",{style:{...zx,...n},children:"3D"});function d9({catalog:n,has3dView:e}){const{planner:t,setMode:r,setToast:i,selectTool3DView:s,unselectAll:o,selectToolDrawingLine:a,selectToolDrawingSurface:l,showDimensions:c,setShowDimensions:h}=Ht(),{mode:f,alterate:p,drawingSupport:d}=t,[m,x]=ne.useState(null);return R.jsxs(R.Fragment,{children:[R.jsxs("aside",{className:"floor_planner-toolbar -mt-[20px] absolute left-2 !pt-3 top-1/2 -translate-y-1/2 z-[1] rounded max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[R.jsx(ir,{active:[Tr,Jn].includes(f)&&d.get("type")==="wall",tooltip:"Draw wall",onClick:()=>{i({text:"Cancel drawing"}),a("wall")},children:R.jsx(J7,{})}),R.jsx(ir,{active:[Us,di].includes(f),tooltip:"Draw landscape surface",onClick:()=>{i({text:"Cancel drawing"}),l("surface")},children:R.jsx(Q7,{size:26})}),R.jsx(ir,{active:!!([hr].includes(f)&&m&&m.page==="windows"),tooltip:"Place windows",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"windows"})},children:R.jsx(PA,{size:26})}),R.jsx(ir,{active:!!([hr].includes(f)&&m&&m.page==="doors"),tooltip:"Place doors",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"doors"})},children:R.jsx(l9,{size:26})}),R.jsx(ir,{active:!!([Ar].includes(f)&&m&&m.page==="objects"),tooltip:"Place objects",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"objects"})},children:R.jsx(c9,{size:26})}),e?[Br].includes(f)?R.jsx(ir,{active:[sn].includes(f),tooltip:"2D View",onClick:()=>{o(),setTimeout(()=>{r(sn)},0)},children:R.jsx(h9,{style:{color:p?"#FF9800":""}})}):R.jsx(ir,{active:[Br].includes(f),tooltip:"3D View",onClick:s,children:R.jsx(f9,{})}):null,R.jsx(Z7,{mode:f}),R.jsx(ir,{active:c,tooltip:"Show dimensions",onClick:()=>h(!c),children:R.jsx(u9,{size:24})})]}),R.jsx(a9,{catalog:n,popupEvent:m,onClose:()=>x(null)})]})}const Ul=window.hasOwnProperty("localStorage")?window.localStorage:!1,p9=500;let om=null;function m9(n,e){return(t,r,i)=>{let s;if(e=e||p9,!!n&&Ul){if(r){t.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(Ul.getItem(n)!==null){const o=Ul.getItem(n);s=JSON.parse(o)}s&&t.loadProject(s),Ht.subscribe(o=>{om&&clearTimeout(om),om=setTimeout(()=>{const a=Ul.getItem(n),l=qt.unselectAll(o.planner).updatedState,c=JSON.stringify(l.scene.toJS());if(a!==c&&(Ul.setItem(n,c),o.plan))try{const h=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:h.floorID,title:h.floorTitle,description:h.floorDescription,design:c}})}catch{}},e)})}}}function g9(){return n=>{window.addEventListener("keydown",e=>{const t=n.planner,r=t.get("mode");switch(e.keyCode){case Rr.BACKSPACE:case Rr.DELETE:{[sn,Ao,Br].includes(r)&&n.remove();break}case Rr.ESC:{n.rollback();break}case Rr.Z:{(e.getModifierState("Control")||e.getModifierState("Meta"))&&(e.getModifierState("Shift")?n.redo():n.undo());break}case Rr.ALT:{uf.includes(r)&&n.toggleSnap(t.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:t.snapMask.toJS()}));break}case Rr.C:{let i=t.getIn(["scene","selectedLayer"]),s=t.getIn(["scene","layers",i,"selected"]);if((r===sn||r===Br)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=t.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=t.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=t.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=t.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case Rr.V:{n.pasteProperties();break}case Rr.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",e=>{const t=n.planner,r=t.get("mode");switch(e.keyCode){case Rr.ALT:{uf.includes(r)&&n.toggleSnap(t.snapMask.merge(t.snapMask.get("tempSnapConfiguartion")));break}case Rr.CTRL:{n.setAlterateState();break}}})}}const kx=38,Bx=-220,Fl=({title:n,toggleState:e,toggleOn:t,toggleOff:r})=>{const[i,s]=ne.useState(e||!1),o=()=>{s(!i),i?r():t()};return R.jsxs("div",{className:"flex items-center",children:[R.jsx("div",{className:"fp__onoffswitch",onClick:o,children:R.jsxs("div",{className:Nr("fp__onoffswitch_label",i?"fp__onoffswitch_label-checked":""),children:[R.jsx("span",{className:"fp__onoffswitch_inner"}),R.jsx("span",{className:"fp__onoffswitch_switch"})]})}),R.jsx("div",{className:"fp__onoffswitch_caption",children:n})]})},_9=({popupEvent:n,onClose:e})=>{const{planner:t,toggleSnap:r}=Ht(),{snapMask:i}=t,s=ne.useRef(null);ne.useEffect(()=>{if(n){const{x:l,y:c}=n.rect;s.current={top:c+kx,left:l+Bx}}},[n]);const o=()=>{e()},a=l=>r(i.merge(l));return R.jsxs(R.Fragment,{children:[n&&R.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:o}),R.jsxs("div",{style:n&&n.rect?{top:n.rect.y+kx,left:n.rect.x+Bx}:s.current?s.current:{},id:"headerbar-popup",className:Nr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[200px] !min-w-[250px] max-w-[250px] !max-h-[300px] transition-all duration-200 ease-out transform",n?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[R.jsx("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:R.jsx("div",{className:"flex items-center gap-1",children:R.jsx("span",{className:Nr("flex flex-col gap-0.5"),children:R.jsx("span",{className:"fp-sidebar-label capitalize",children:"Settings"})})})}),R.jsxs("div",{className:"min-h-28 w-full space-y-2.5 px-2 py-4",children:[R.jsx(Fl,{title:"Snap to Point",toggleState:i.get(pf),toggleOn:()=>{a({SNAP_POINT:!0})},toggleOff:()=>{a({SNAP_POINT:!1})}}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_LINE:!0})},toggleOff:()=>{a({SNAP_LINE:!1})},toggleState:i.get(mf),title:"Snap to Line"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_SEGMENT:!0})},toggleOff:()=>{a({SNAP_SEGMENT:!1})},toggleState:i.get(gf),title:"Snap to Segment"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_GRID:!0})},toggleOff:()=>{a({SNAP_GRID:!1})},toggleState:i.get(_f),title:"Snap to Grid"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_GUIDE:!0})},toggleOff:()=>{a({SNAP_GUIDE:!1})},toggleState:i.get(ng),title:"Snap to Guide"})]})]})]})},v9=({onBack:n,onSave:e})=>{const{undo:t,redo:r,plan:i,setPlan:s}=Ht(),[o,a]=ne.useState(!1),[l,c]=ne.useState(null),h=()=>{a(!0)},f=p=>{if(!i)return;a(!1);const d=p.target.value.trim();if(d&&d!==(i==null?void 0:i.planTitle)){s({...i,planTitle:d});try{e&&e({title:d,description:""})}catch{}}};return R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[R.jsx(ir,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:R.jsx(tx,{})}),R.jsx("div",{className:"flex flex-col items-center justify-center",children:o?R.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:f,onKeyDown:p=>{(p.key==="Enter"||p.key==="Escape")&&f(p)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):R.jsx("span",{onDoubleClick:h,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),R.jsxs("div",{className:"flex items-center gap-2 relative",children:[R.jsx(ir,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:t,children:R.jsx(CA,{})}),R.jsx(ir,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:R.jsx(AA,{})}),R.jsx("div",{className:"ml-8",children:R.jsx(ir,{active:!1,tooltip:"Settings",onClick:p=>{c({rect:p.currentTarget.getBoundingClientRect()})},children:R.jsx(pA,{size:17})})})]})]}),R.jsx(_9,{popupEvent:l,onClose:()=>c(null)})]})};var am={exports:{}},Vx;function Hx(){if(Vx)return am.exports;Vx=1;var n=am.exports={};return n.forEach=function(e,t){for(var r=0;r<e.length;r++){var i=t(e[r]);if(i)return i}},am.exports}var lm,Gx;function x9(){return Gx||(Gx=1,lm=function(n){var e=n.stateHandler.getState;function t(o){var a=e(o);return a&&!!a.isDetectable}function r(o){e(o).isDetectable=!0}function i(o){return!!e(o).busy}function s(o,a){e(o).busy=!!a}return{isDetectable:t,markAsDetectable:r,isBusy:i,markBusy:s}}),lm}var cm,Wx;function y9(){return Wx||(Wx=1,cm=function(n){var e={};function t(o){var a=n.get(o);return a===void 0?[]:e[a]||[]}function r(o,a){var l=n.get(o);e[l]||(e[l]=[]),e[l].push(a)}function i(o,a){for(var l=t(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=t(o);a&&(a.length=0)}return{get:t,add:r,removeListener:i,removeAllListeners:s}}),cm}var um,jx;function S9(){return jx||(jx=1,um=function(){var n=1;function e(){return n++}return{generate:e}}),um}var hm,Xx;function E9(){return Xx||(Xx=1,hm=function(n){var e=n.idGenerator,t=n.stateHandler.getState;function r(s){var o=t(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=t(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=e.generate();return o.id=a,a}return{get:r,set:i}}),hm}var fm,$x;function b9(){return $x||($x=1,fm=function(n){function e(){}var t={log:e,warn:e,error:e};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(t,"log"),r(t,"warn"),r(t,"error")}return t}),fm}var dm={exports:{}},Yx;function Kx(){if(Yx)return dm.exports;Yx=1;var n=dm.exports={};return n.isIE=function(e){function t(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!t())return!1;if(!e)return!0;var r=(function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i})();return e===r},n.isLegacyOpera=function(){return!!window.opera},dm.exports}var pm={exports:{}},Zx;function M9(){if(Zx)return pm.exports;Zx=1;var n=pm.exports={};n.getOption=e;function e(t,r,i){var s=t[r];return s==null&&i!==void 0?i:s}return pm.exports}var mm,Jx;function w9(){if(Jx)return mm;Jx=1;var n=M9();mm=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=e(),l,c=!1;function h(v,_){!c&&o&&s&&a.size()===0&&d(),a.add(v,_)}function f(){for(c=!0;a.size();){var v=a;a=e(),v.process()}c=!1}function p(v){c||(v===void 0&&(v=s),l&&(m(l),l=null),v?d():f())}function d(){l=x(f)}function m(v){var _=clearTimeout;return _(v)}function x(v){var _=function(w){return setTimeout(w,0)};return _(v)}return{add:h,force:p}};function e(){var t={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),t[c]||(t[c]=[]),t[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=t[c],f=0;f<h.length;f++){var p=h[f];p()}}function l(){return r}return{add:o,process:a,size:l}}return mm}var gm,Qx;function T9(){if(Qx)return gm;Qx=1;var n="_erd";function e(i){return i[n]={},t(i)}function t(i){return i[n]}function r(i){delete i[n]}return gm={initState:e,getState:t,cleanState:r},gm}var _m,e2;function A9(){if(e2)return _m;e2=1;var n=Kx();return _m=function(e){e=e||{};var t=e.reporter,r=e.batchProcessor,i=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function s(h,f){function p(){f(h)}if(n.isIE(8))i(h).object={proxy:p},h.attachEvent("onresize",p);else{var d=l(h);if(!d)throw new Error("Element is not detectable by this strategy.");d.contentDocument.defaultView.addEventListener("resize",p)}}function o(h){var f=e.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,p){p||(p=f,f=h,h=null),h=h||{},h.debug;function d(m,x){var v=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),_=!1,w=window.getComputedStyle(m),E=m.offsetWidth,S=m.offsetHeight;i(m).startSize={width:E,height:S};function b(){function A(){if(w.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var T=function(I,N,H,W){function Q(J){return J.replace(/[^-\d\.]/g,"")}var ae=H[W];ae!=="auto"&&Q(ae)!=="0"&&(I.warn("An element that is positioned static has style."+W+"="+ae+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+W+" will be set to 0. Element: ",N),N.style.setProperty(W,"0",h.important?"important":""))};T(t,m,w,"top"),T(t,m,w,"right"),T(t,m,w,"bottom"),T(t,m,w,"left")}}function q(){_||A();function T(N,H){if(!N.contentDocument){var W=i(N);W.checkForObjectDocumentTimeoutId&&window.clearTimeout(W.checkForObjectDocumentTimeoutId),W.checkForObjectDocumentTimeoutId=setTimeout(function(){W.checkForObjectDocumentTimeoutId=0,T(N,H)},100);return}H(N.contentDocument)}var I=this;T(I,function(H){x(m)})}w.position!==""&&(A(),_=!0);var O=document.createElement("object");O.style.cssText=v,O.tabIndex=-1,O.type="text/html",O.setAttribute("aria-hidden","true"),O.onload=q,n.isIE()||(O.data="about:blank"),i(m)&&(m.appendChild(O),i(m).object=O,n.isIE()&&(O.data="about:blank"))}r?r.add(b):b()}n.isIE(8)?p(f):d(f,p)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},_m}var vm,t2;function C9(){if(t2)return vm;t2=1;var n=Hx().forEach;return vm=function(e){e=e||{};var t=e.reporter,r=e.batchProcessor,i=e.stateHandler.getState;e.stateHandler.hasState;var s=e.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(b){p(b,a,l)}c(window.document);function h(b){var A=e.important?" !important; ":"; ";return(b.join(A)+A).trim()}function f(){var b=500,A=500,q=document.createElement("div");q.style.cssText=h(["position: absolute","width: "+b*2+"px","height: "+A*2+"px","visibility: hidden","margin: 0","padding: 0"]);var O=document.createElement("div");O.style.cssText=h(["position: absolute","width: "+b+"px","height: "+A+"px","overflow: scroll","visibility: none","top: "+-b*3+"px","left: "+-A*3+"px","visibility: hidden","margin: 0","padding: 0"]),O.appendChild(q),document.body.insertBefore(O,document.body.firstChild);var T=b-O.clientWidth,I=A-O.clientHeight;return document.body.removeChild(O),{width:T,height:I}}function p(b,A,q){function O(H,W){W=W||function(ae){b.head.appendChild(ae)};var Q=b.createElement("style");return Q.innerHTML=H,Q.id=A,W(Q),Q}if(!b.getElementById(A)){var T=q+"_animation",I=q+"_animation_active",N=`/* Created by the element-resize-detector library. */
3931
+ `,children:e}),document.body)},ir=({active:n,tooltip:e,tooltipPosition:t="right",onClick:r,children:i,className:s,showDelay:o=300,hideDelay:a=0})=>{const l=ne.useRef(null),c=ne.useRef(null),h=ne.useRef(null),[f,p]=ne.useState(!1),d=()=>{c.current&&(window.clearTimeout(c.current),c.current=null),h.current&&(window.clearTimeout(h.current),h.current=null)},m=()=>{d(),c.current=window.setTimeout(()=>{p(!0)},o)},x=()=>{d(),h.current=window.setTimeout(()=>{p(!1)},a)};return R.jsxs(R.Fragment,{children:[R.jsx("div",{ref:l,className:Ur("w-[30px] h-[30px] flex items-center justify-center text-[25px] cursor-pointer",s),onMouseEnter:m,onMouseLeave:x,onClick:r,children:R.jsx("div",{className:Ur("transition-colors",n?"text-dark-blue":"text-[#C2C2C2]"),children:i})}),R.jsx(K7,{anchorEl:l.current,title:e,visible:f,position:t})]})},bx=()=>new Promise(async n=>{const e=document.getElementsByTagName("svg");if(!e.length)return;let t=e[0];for(let p=1;p<e.length;p++)e[p].width.baseVal.value>t.width.baseVal.value&&(t=e[p]);const r=t.cloneNode(!0),i=r.querySelectorAll("image");await Promise.all(Array.from(i).map(async p=>{const d=p.getAttribute("href")||p.getAttribute("xlink:href");if(d)try{const x=await(await fetch(d)).blob(),v=new FileReader;await new Promise(_=>{v.onloadend=()=>{p.setAttribute("href",v.result),_()},v.readAsDataURL(x)})}catch(m){console.warn("⚠️ Could not inline image:",d,m)}}));const o=new XMLSerializer().serializeToString(r),a=t.width.baseVal.value,l=t.height.baseVal.value,c=document.createElement("canvas");c.width=a,c.height=l;const h=c.getContext("2d");h.fillStyle="white",h.fillRect(0,0,a,l);const f=new Image;f.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(o)))}`,f.onload=()=>{h.drawImage(f,0,0,a,l),n(c.toDataURL("image/png"))}});function Mx(n){return un({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(n)}const wx=n=>{let e=document.createElement("a"),t="output"+Date.now()+".png";t=window.prompt("Insert output filename",t),t&&(e.setAttribute("download",t),e.href=n,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e))};function Z7({mode:n}){const e=r=>{r.preventDefault();const i=document.getElementsByTagName("canvas")[0];wx(i.toDataURL())},t=async r=>{r.preventDefault(),bx().then(wx)};return[Ao,Tr].includes(n)?R.jsx(ir,{active:!1,tooltip:"Get Screenshot",onClick:e,children:R.jsx(Mx,{size:28})}):[sn,qs,Ds,Ns,Ar,Us,Vr,Hr,Gr,Jn,di,hr,Cr,Wr,Di].includes(n)?R.jsx(ir,{active:!1,tooltip:"Get Screenshot",onClick:t,children:R.jsx(Mx,{size:28})}):null}function J7(n){return un({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(n)}function Q7(n){return un({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M224,48H32a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H224a8,8,0,0,0,8-8V56A8,8,0,0,0,224,48ZM88,144V112h80v32Zm-48,0V112H72v32Zm144-32h32v32H184Zm32-16H136V64h80ZM120,64V96H40V64ZM40,160h80v32H40Zm96,32V160h80v32Z"},child:[]}]})(n)}const e9=/^.*$/;function t9({onChange:n,...e}){const[t,r]=ne.useState(""),i=ne.useRef(null);ne.useEffect(()=>{r(e.value)},[e.value]);const s=a=>{if(!a)return;const l=a.target.value;e9.test(l)&&n&&n(a)},o=a=>{(!a.key||a.key==="Enter")&&s({target:{value:t}})};return R.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[R.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:e.value},onClick:()=>{i.current&&i.current.click()},children:R.jsx("input",{ref:i,type:"color",onChange:s,value:e.value,className:"absolute invisible h-full w-full"})}),R.jsx("div",{className:"flex-1 pl-2",children:R.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:t,onKeyDown:o,onChange:a=>r(a.target.value),onBlur:o})})]})}function Tx({value:n,onUpdate:e,configs:t,propertyName:r,sourceElement:i,internalState:s}){const o=i.toJS(),{planner:a}=Ht(),l=c=>t.hook?t.hook(c,i,s,a).then(h=>e(h)):e(c);return ne.useEffect(()=>{var p;const c=o.type==="wall",h=r==="colorA"||r==="colorB",f=!((p=o.properties)!=null&&p[r]);c&&h&&f&&l(n)},[o.type,o.properties,r,l,n]),R.jsxs("div",{className:"PropertyColor w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(t9,{value:n,onChange:c=>l(c.target.value)})]})}function Ax({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(im,{value:n,onChange:a=>o(a.target.value),children:vn(t.values).entrySeq().map(([a,l])=>R.jsx("option",{value:a,children:l},a))})]})}function Cx({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht();let o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyString w-full mb-2",children:[R.jsx(si,{children:t.label}),R.jsx(Nl,{value:n,onChange:a=>o(a.target.value)})]})}function Rx({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Ht(),a=l=>{let c=parseFloat(l);return isNaN(c)&&(c=0),r.hook?r.hook(c,i,s,o).then(h=>e(h)):e(c)};return R.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[R.jsx(si,{children:r.label}),R.jsx(Ci,{value:n,onChange:l=>a(l.target.value),onValid:t,min:r.min,max:r.max})]})}function Px({value:n,onUpdate:e,onValid:t,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Ht(),{mode:a}=o,l=n.get("length")||0,c=n.get("_length")||l,h=n.get("_unit")||Rr,{hook:f,label:p,...d}=r,m=(x,v)=>{let _=Qn(x),w=n.merge({length:v!==Rr?Kr(_).from(v).to(Rr):_,_length:x,_unit:v});return f?f(w,i,s,o).then(E=>e(E)):e(w)};if(a!==Tr)return R.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[R.jsx(si,{children:p}),R.jsxs("div",{className:"w-full flex",children:[R.jsx(Ci,{value:c,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:x=>m(x.target.value,h),onValid:t,...d}),R.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:R.jsx(im,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:h,onChange:x=>{},children:Q0.map(x=>R.jsx("option",{value:x,children:x},x))})})]})]})}function n9({type:n="button",size:e="normal",style:t,styleHover:r,children:i,...s}){const[o,a]=ne.useState(!1),l="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",c=e==="small"?"text-[12px] px-2 py-[3px]":e==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},f={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return R.jsx("button",{type:n,className:`${l} ${c}`,style:{...o?{...f,...r}:{...h,...t}},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),...s,children:i})}const Yu={tableStyle:{width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle:{width:"6em",textTransform:"capitalize"}};function Ix({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsx("table",{className:"PropertyToggle",style:Yu.tableStyle,children:R.jsx("tbody",{children:R.jsxs("tr",{children:[R.jsx("td",{style:Yu.firstTdStyle,children:R.jsx(si,{children:t.label})}),R.jsx("td",{children:R.jsx(n9,{onClick:()=>o(!n),size:"small",children:t.actionName})})]})})})}function Lx({value:n,onUpdate:e,configs:t,sourceElement:r,internalState:i}){const{planner:s}=Ht(),o=a=>t.hook?t.hook(a,r,i,s).then(l=>e(l)):e(a);return R.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[R.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:n,onChange:()=>o(!n)}),R.jsx(si,{className:"mb-0",children:t.label})]})}function Ox(){return null}function qx({value:n,configs:e}){return R.jsx("table",{className:"PropertyReadOnly",style:Yu.tableStyle,children:R.jsx("tbody",{children:R.jsxs("tr",{children:[R.jsx("td",{style:Yu.firstTdStyle,children:R.jsx(si,{children:e.label})}),R.jsx("td",{children:R.jsx("div",{children:n})})]})})})}class r9{constructor(e=Rr){ht(this,"elements");ht(this,"categories");ht(this,"propertyTypes");ht(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=e,this.registerMultiplePropertyType([["color",Tx,Tx],["enum",Ax,Ax],["string",Cx,Cx],["number",Rx,Rx],["length-measure",Px,Px],["toggle",Ix,Ix],["checkbox",Lx,Lx],["hidden",Ox,Ox],["read-only",qx,qx]])}getElement(e){if(this.hasElement(e))return this.elements[e];throw new Error(`Element ${e} does not exist in catalog`)}getCategory(e){if(this.hasCategory(e))return this.categories[e];throw new Error(`Category ${e} does not exist in catalog`)}getPropertyType(e){if(this.propertyTypes.hasOwnProperty(e))return this.propertyTypes[e];throw new Error(`Element ${e} does not exist in catalog`)}registerElement(e){e.properties=e.properties||{},this.validateElement(e)&&(this.elements[e.name]=e,this.categories.root.elements.push(this.elements[e.name]))}registerMultipleElements(e){e.forEach(t=>this.registerElement(t))}registerPropertyType(e,t,r){this.propertyTypes[e]={type:e,Viewer:t,Editor:r}}registerMultiplePropertyType(e){e.forEach(t=>this.registerPropertyType(...t))}validateElement(e){if(!e.hasOwnProperty("name"))throw new Error("Element not valid");let t=e.name;if(!e.hasOwnProperty("prototype"))throw new Error(`Element ${t} doesn't have prototype`);if(!e.hasOwnProperty("info"))throw new Error(`Element ${t} doesn't have info`);if(!e.info.hasOwnProperty("tag"))throw new Error(`Element ${t} doesn't have tag`);if(!e.info.hasOwnProperty("description"))throw new Error(`Element ${t} doesn't have description`);if(!e.info.hasOwnProperty("image"))throw new Error(`Element ${t} doesn't have image`);if(!e.hasOwnProperty("render2D"))throw new Error(`Element ${t} doesn't have render2D handler`);if(!e.hasOwnProperty("render3D"))throw new Error(`Element ${t} doesn't have render3D handler`);if(!e.hasOwnProperty("properties"))throw new Error(`Element ${t} doesn't have properties`);for(let r in e.properties){let i=e.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${t}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${t}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(e){return this.elements.hasOwnProperty(e)}registerCategory(e,t,r){return this.validateCategory(e,t)?(this.categories[e]={name:e,label:t,categories:[],elements:[]},this.categories.root.categories.push(this.categories[e]),r&&r.length&&r.forEach(i=>this.addToCategory(e,i)),this.categories[e]):null}addToCategory(e,t){if(this.hasElement(t.name))this.categories[e].elements.push(t),this.categories.root.elements.splice(this.categories.root.elements.indexOf(t),1);else if(this.hasCategory(t.name))this.categories[e].categories.push(t),this.categories.root.categories.splice(this.categories.root.categories.indexOf(t),1);else throw new Error(`child ${t} is either category nor element`)}categoryHasElement(e,t){return this.hasCategory(e)&&this.categories[e].elements.some(r=>r.name===t)}validateCategory(e,t){if(!e)throw new Error("Category has undefined name");if(e==="")throw new Error("Category has empty name");if(this.hasCategory(e))throw new Error("Category has already been registered");return!0}hasCategory(e){return this.categories.hasOwnProperty(e)}}function i9(n){return un({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const s9=({term:n="",placeholder:e="Search",noSpacing:t=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a,value:l})=>{const[c,h]=ne.useState("");return ne.useEffect(()=>{l!==void 0&&l!==c&&h(l??"")},[l]),R.jsxs("div",{className:Ur(`relative w-full ${t?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[R.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${t?"":"ml-2"}`,style:{zIndex:2},children:R.jsx(i9,{size:18})}),i?R.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):R.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:e,onChange:f=>{o(f.target.value,f),h(f.target.value)},value:c,onClick:r??(()=>!1)}),r!==null&&s&&R.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${t?"":"ml-2"}`,style:{zIndex:1},children:R.jsx(gA,{className:"-mb-1"})})]})},Dx=0,Nx=58,Ux=n=>{const e=[{label:"All Categories",value:"all"}],t=n.map(r=>r.info.tag);for(const r of t){let i=e;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return e},o9=({selected:n,options:e,onChange:t})=>{const r=ne.useMemo(()=>e.findIndex(s=>s.value===n),[e,n]),i=100/e.length;return R.jsxs("div",{className:"relative w-full rounded-lg border border-gray-200 bg-white p-1",children:[R.jsx("div",{className:"absolute top-1 bottom-1 rounded-md bg-slate-900 transition-transform duration-300 ease-out",style:{width:`calc(${i}% - 4px)`,transform:`translateX(${r*100}%)`}}),R.jsx("div",{role:"tablist",className:"relative z-10 grid",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(s=>{const o=s.value===n;return R.jsx("button",{role:"tab","aria-selected":o,className:Ur("h-8 text-sm font-medium capitalize transition-colors",o?"text-white":"text-gray-700 hover:text-black"),onClick:()=>t(s),children:s.label},s.value)})})]})},Fx=({options:n,selections:e,level:t,onChange:r})=>{var i,s;return R.jsxs(R.Fragment,{children:[R.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:e[t]||"all",onChange:o=>r(t,o.target.value),children:n.map(o=>R.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),e[t]&&e[t]!=="all"&&((i=n.find(o=>o.value===e[t]))==null?void 0:i.options)&&R.jsx(Fx,{options:((s=n.find(o=>o.value===e[t]))==null?void 0:s.options)||[],level:t+1,selections:e,onChange:r})]})},a9=({catalog:n,popupEvent:e,onClose:t})=>{const{setToast:r,selectToolDrawingLine:i,selectToolDrawingItem:s,selectToolDrawingHole:o,pushLastSelectedCatalogElementToHistory:a}=Ht(),[l,c]=ne.useState([]),[h,f]=ne.useState(""),[p,d]=ne.useState([]),[m,x]=ne.useState(["all"]),[v,_]=ne.useState([]),[w,E]=ne.useState(""),S=ne.useRef(null),b=ne.useRef(null),A=()=>{E(""),d([]),c([]),x(["all"]),f("")};ne.useEffect(()=>{if(e){A();const W=n.getCategory(e.page).elements.filter(J=>J.info.visibility?J.info.visibility.catalog:!0);S.current=e.page,_(W);const{x:Q,y:ae}=e.rect;if(b.current={top:ae+Dx,left:Q+Nx},e.page==="objects"){const J=Array.from(new Set(W.map(ge=>ge.info.category).filter(Boolean))),se=J[0]??"",B=W.filter(ge=>ge.info.category===se);f(se),c(J),d(Ux(B))}}},[e]);const q=()=>{t()},O=H=>{q(),e&&r({text:`Cancel placing ${e.page}`}),setTimeout(()=>{switch(H.prototype){case"lines":i(H.name);break;case"items":s(H.name);break;case"holes":o(H.name);break}a(H)},0)},T=(H,W)=>{const Q=[...m.slice(0,H),W];x(Q)},I=(H,W)=>{H.preventDefault();const Q=H.currentTarget.closest(".fp_side-bar");let ae=!1;const J=ge=>{const{clientX:F,clientY:X}=ge,de=Q==null?void 0:Q.getBoundingClientRect();de&&(F<de.left||F>de.right||X<de.top||X>de.bottom)&&(ae=!0),ae&&(O(W),B())},se=()=>B(),B=()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",se)};document.addEventListener("mousemove",J),document.addEventListener("mouseup",se)},N=ne.useMemo(()=>v.filter(H=>{const W=H.info.title.toLowerCase().includes(w.toLowerCase()),Q=h?H.info.category===h:H,ae=m.every(J=>J==="all"||H.info.tag.includes(J));return W&&Q&&ae}),[v,w,h,m]);return R.jsxs(R.Fragment,{children:[e&&R.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:q}),R.jsxs("div",{style:e&&e.rect?{top:e.rect.y+Dx,left:e.rect.x+Nx}:b.current?b.current:{},className:Ur("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[250px] !min-w-[330px] max-w-[330px] !max-h-[510px] transition-all duration-200 ease-out transform",e?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[R.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[R.jsx("div",{className:"flex items-center gap-1",children:R.jsx("span",{className:Ur("flex flex-col gap-0.5"),children:R.jsx("span",{className:"fp-sidebar-label capitalize",children:(e==null?void 0:e.page)??S.current})})}),R.jsxs("div",{className:Ur("fp-highlight"),children:[l.length>1&&R.jsx(o9,{selected:h,onChange:H=>{x(["all"]),f(H.value),d(Ux(v.filter(W=>W.info.category===H.value)))},options:l.map(H=>({label:H,value:H}))}),p.length>0&&R.jsx(Fx,{options:p,level:0,selections:m,onChange:T}),R.jsx(s9,{className:"mt-0",placeholder:"Search",value:w,onSearch:(H,W)=>{W.preventDefault(),W.stopPropagation(),E(H)}})]})]}),N.length>0?R.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:H=>H.stopPropagation(),children:N.map(H=>R.jsxs("div",{className:"w-full space-y-1.5",children:[R.jsx("div",{className:"fp-aspect-ratio-container",children:R.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:W=>I(W,H),children:R.jsx("img",{draggable:!1,className:"fp-item-image",alt:H.info.title,src:H.info.image})})}),R.jsx("p",{className:"text-xs font-semibold capitalize",children:H.info.description})]},H.name.replace(/\s+/g,"_")))}):R.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:R.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function l9(n){return un({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function c9(n){return un({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function u9(n){return un({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M3.00014 2.73895C3.00014 2.94698 2.76087 3.06401 2.59666 2.93628L1.00386 1.69744C0.875177 1.59735 0.875177 1.40286 1.00386 1.30277L2.59666 0.063928C2.76087 -0.0637944 3.00014 0.0532293 3.00014 0.261266V1.00012H9.00009V0.261296C9.00009 0.0532591 9.23936 -0.0637646 9.40358 0.0639578L10.9964 1.3028C11.1251 1.40289 11.1251 1.59738 10.9964 1.69747L9.40358 2.93631C9.23936 3.06404 9.00009 2.94701 9.00009 2.73898V2.00012H3.00014V2.73895ZM9.50002 4.99998H2.50002C2.22388 4.99998 2.00002 5.22384 2.00002 5.49998V12.5C2.00002 12.7761 2.22388 13 2.50002 13H9.50002C9.77616 13 10 12.7761 10 12.5V5.49998C10 5.22384 9.77616 4.99998 9.50002 4.99998ZM2.50002 3.99998C1.67159 3.99998 1.00002 4.67156 1.00002 5.49998V12.5C1.00002 13.3284 1.67159 14 2.50002 14H9.50002C10.3284 14 11 13.3284 11 12.5V5.49998C11 4.67156 10.3284 3.99998 9.50002 3.99998H2.50002ZM14.7389 6.00001H14V12H14.7389C14.9469 12 15.064 12.2393 14.9362 12.4035L13.6974 13.9963C13.5973 14.125 13.4028 14.125 13.3027 13.9963L12.0639 12.4035C11.9362 12.2393 12.0532 12 12.2612 12H13V6.00001H12.2612C12.0532 6.00001 11.9361 5.76074 12.0639 5.59653L13.3027 4.00373C13.4028 3.87505 13.5973 3.87505 13.6974 4.00374L14.9362 5.59653C15.0639 5.76074 14.9469 6.00001 14.7389 6.00001Z",fill:"currentColor"},child:[]}]})(n)}const zx={fontSize:"19px",textDecoration:"none",fontWeight:"bold",margin:"0px",userSelect:"none"},h9=({style:n})=>R.jsx("p",{style:{...zx,...n},children:"2D"}),f9=({style:n})=>R.jsx("p",{style:{...zx,...n},children:"3D"});function d9({catalog:n,has3dView:e}){const{planner:t,setMode:r,setToast:i,selectTool3DView:s,unselectAll:o,selectToolDrawingLine:a,selectToolDrawingSurface:l,showDimensions:c,setShowDimensions:h}=Ht(),{mode:f,alterate:p,drawingSupport:d}=t,[m,x]=ne.useState(null);return R.jsxs(R.Fragment,{children:[R.jsxs("aside",{className:"floor_planner-toolbar -mt-[20px] absolute left-2 !pt-3 top-1/2 -translate-y-1/2 z-[1] rounded max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[R.jsx(ir,{active:[Ar,Jn].includes(f)&&d.get("type")==="wall",tooltip:"Draw wall",onClick:()=>{i({text:"Cancel drawing"}),a("wall")},children:R.jsx(J7,{})}),R.jsx(ir,{active:[Us,di].includes(f),tooltip:"Draw landscape surface",onClick:()=>{i({text:"Cancel drawing"}),l("surface")},children:R.jsx(Q7,{size:26})}),R.jsx(ir,{active:!!([hr].includes(f)&&m&&m.page==="windows"),tooltip:"Place windows",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"windows"})},children:R.jsx(PA,{size:26})}),R.jsx(ir,{active:!!([hr].includes(f)&&m&&m.page==="doors"),tooltip:"Place doors",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"doors"})},children:R.jsx(l9,{size:26})}),R.jsx(ir,{active:!!([Cr].includes(f)&&m&&m.page==="objects"),tooltip:"Place objects",onClick:v=>{x({rect:(v.currentTarget.parentElement??v.currentTarget).getBoundingClientRect(),page:"objects"})},children:R.jsx(c9,{size:26})}),e?[Tr].includes(f)?R.jsx(ir,{active:[sn].includes(f),tooltip:"2D View",onClick:()=>{o(),setTimeout(()=>{r(sn)},0)},children:R.jsx(h9,{style:{color:p?"#FF9800":""}})}):R.jsx(ir,{active:[Tr].includes(f),tooltip:"3D View",onClick:s,children:R.jsx(f9,{})}):null,R.jsx(Z7,{mode:f}),R.jsx(ir,{active:c,tooltip:"Show dimensions",onClick:()=>{[Tr].includes(f)||h(!c)},children:R.jsx(u9,{size:24})})]}),R.jsx(a9,{catalog:n,popupEvent:m,onClose:()=>x(null)})]})}const Ul=window.hasOwnProperty("localStorage")?window.localStorage:!1,p9=500;let om=null;function m9(n,e){return(t,r,i)=>{let s;if(e=e||p9,!!n&&Ul){if(r){t.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(Ul.getItem(n)!==null){const o=Ul.getItem(n);s=JSON.parse(o)}s&&t.loadProject(s),Ht.subscribe(o=>{om&&clearTimeout(om),om=setTimeout(()=>{const a=Ul.getItem(n),l=qt.unselectAll(o.planner).updatedState,c=JSON.stringify(l.scene.toJS());if(a!==c&&(Ul.setItem(n,c),o.plan))try{const h=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:h.floorID,title:h.floorTitle,description:h.floorDescription,design:c}})}catch{}},e)})}}}function g9(){return n=>{window.addEventListener("keydown",e=>{const t=n.planner,r=t.get("mode");switch(e.keyCode){case Pr.BACKSPACE:case Pr.DELETE:{[sn,Ao,Tr].includes(r)&&n.remove();break}case Pr.ESC:{n.rollback();break}case Pr.Z:{(e.getModifierState("Control")||e.getModifierState("Meta"))&&(e.getModifierState("Shift")?n.redo():n.undo());break}case Pr.ALT:{uf.includes(r)&&n.toggleSnap(t.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:t.snapMask.toJS()}));break}case Pr.C:{let i=t.getIn(["scene","selectedLayer"]),s=t.getIn(["scene","layers",i,"selected"]);if((r===sn||r===Tr)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=t.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=t.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=t.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=t.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case Pr.V:{n.pasteProperties();break}case Pr.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",e=>{const t=n.planner,r=t.get("mode");switch(e.keyCode){case Pr.ALT:{uf.includes(r)&&n.toggleSnap(t.snapMask.merge(t.snapMask.get("tempSnapConfiguartion")));break}case Pr.CTRL:{n.setAlterateState();break}}})}}const kx=38,Bx=-220,Fl=({title:n,toggleState:e,toggleOn:t,toggleOff:r})=>{const[i,s]=ne.useState(e||!1),o=()=>{s(!i),i?r():t()};return R.jsxs("div",{className:"flex items-center",children:[R.jsx("div",{className:"fp__onoffswitch",onClick:o,children:R.jsxs("div",{className:Ur("fp__onoffswitch_label",i?"fp__onoffswitch_label-checked":""),children:[R.jsx("span",{className:"fp__onoffswitch_inner"}),R.jsx("span",{className:"fp__onoffswitch_switch"})]})}),R.jsx("div",{className:"fp__onoffswitch_caption",children:n})]})},_9=({popupEvent:n,onClose:e})=>{const{planner:t,toggleSnap:r}=Ht(),{snapMask:i}=t,s=ne.useRef(null);ne.useEffect(()=>{if(n){const{x:l,y:c}=n.rect;s.current={top:c+kx,left:l+Bx}}},[n]);const o=()=>{e()},a=l=>r(i.merge(l));return R.jsxs(R.Fragment,{children:[n&&R.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:o}),R.jsxs("div",{style:n&&n.rect?{top:n.rect.y+kx,left:n.rect.x+Bx}:s.current?s.current:{},id:"headerbar-popup",className:Ur("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[200px] !min-w-[250px] max-w-[250px] !max-h-[300px] transition-all duration-200 ease-out transform",n?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[R.jsx("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:R.jsx("div",{className:"flex items-center gap-1",children:R.jsx("span",{className:Ur("flex flex-col gap-0.5"),children:R.jsx("span",{className:"fp-sidebar-label capitalize",children:"Settings"})})})}),R.jsxs("div",{className:"min-h-28 w-full space-y-2.5 px-2 py-4",children:[R.jsx(Fl,{title:"Snap to Point",toggleState:i.get(pf),toggleOn:()=>{a({SNAP_POINT:!0})},toggleOff:()=>{a({SNAP_POINT:!1})}}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_LINE:!0})},toggleOff:()=>{a({SNAP_LINE:!1})},toggleState:i.get(mf),title:"Snap to Line"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_SEGMENT:!0})},toggleOff:()=>{a({SNAP_SEGMENT:!1})},toggleState:i.get(gf),title:"Snap to Segment"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_GRID:!0})},toggleOff:()=>{a({SNAP_GRID:!1})},toggleState:i.get(_f),title:"Snap to Grid"}),R.jsx(Fl,{toggleOn:()=>{a({SNAP_GUIDE:!0})},toggleOff:()=>{a({SNAP_GUIDE:!1})},toggleState:i.get(ng),title:"Snap to Guide"})]})]})]})},v9=({onBack:n,onSave:e})=>{const{undo:t,redo:r,plan:i,setPlan:s}=Ht(),[o,a]=ne.useState(!1),[l,c]=ne.useState(null),h=()=>{a(!0)},f=p=>{if(!i)return;a(!1);const d=p.target.value.trim();if(d&&d!==(i==null?void 0:i.planTitle)){s({...i,planTitle:d});try{e&&e({title:d,description:""})}catch{}}};return R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[R.jsx(ir,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:R.jsx(tx,{})}),R.jsx("div",{className:"flex flex-col items-center justify-center",children:o?R.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:f,onKeyDown:p=>{(p.key==="Enter"||p.key==="Escape")&&f(p)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):R.jsx("span",{onDoubleClick:h,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),R.jsxs("div",{className:"flex items-center gap-2 relative",children:[R.jsx(ir,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:t,children:R.jsx(CA,{})}),R.jsx(ir,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:R.jsx(AA,{})}),R.jsx("div",{className:"ml-8",children:R.jsx(ir,{active:!1,tooltip:"Settings",onClick:p=>{c({rect:p.currentTarget.getBoundingClientRect()})},children:R.jsx(pA,{size:17})})})]})]}),R.jsx(_9,{popupEvent:l,onClose:()=>c(null)})]})};var am={exports:{}},Vx;function Hx(){if(Vx)return am.exports;Vx=1;var n=am.exports={};return n.forEach=function(e,t){for(var r=0;r<e.length;r++){var i=t(e[r]);if(i)return i}},am.exports}var lm,Gx;function x9(){return Gx||(Gx=1,lm=function(n){var e=n.stateHandler.getState;function t(o){var a=e(o);return a&&!!a.isDetectable}function r(o){e(o).isDetectable=!0}function i(o){return!!e(o).busy}function s(o,a){e(o).busy=!!a}return{isDetectable:t,markAsDetectable:r,isBusy:i,markBusy:s}}),lm}var cm,Wx;function y9(){return Wx||(Wx=1,cm=function(n){var e={};function t(o){var a=n.get(o);return a===void 0?[]:e[a]||[]}function r(o,a){var l=n.get(o);e[l]||(e[l]=[]),e[l].push(a)}function i(o,a){for(var l=t(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=t(o);a&&(a.length=0)}return{get:t,add:r,removeListener:i,removeAllListeners:s}}),cm}var um,jx;function S9(){return jx||(jx=1,um=function(){var n=1;function e(){return n++}return{generate:e}}),um}var hm,Xx;function E9(){return Xx||(Xx=1,hm=function(n){var e=n.idGenerator,t=n.stateHandler.getState;function r(s){var o=t(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=t(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=e.generate();return o.id=a,a}return{get:r,set:i}}),hm}var fm,$x;function b9(){return $x||($x=1,fm=function(n){function e(){}var t={log:e,warn:e,error:e};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(t,"log"),r(t,"warn"),r(t,"error")}return t}),fm}var dm={exports:{}},Yx;function Kx(){if(Yx)return dm.exports;Yx=1;var n=dm.exports={};return n.isIE=function(e){function t(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!t())return!1;if(!e)return!0;var r=(function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i})();return e===r},n.isLegacyOpera=function(){return!!window.opera},dm.exports}var pm={exports:{}},Zx;function M9(){if(Zx)return pm.exports;Zx=1;var n=pm.exports={};n.getOption=e;function e(t,r,i){var s=t[r];return s==null&&i!==void 0?i:s}return pm.exports}var mm,Jx;function w9(){if(Jx)return mm;Jx=1;var n=M9();mm=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=e(),l,c=!1;function h(v,_){!c&&o&&s&&a.size()===0&&d(),a.add(v,_)}function f(){for(c=!0;a.size();){var v=a;a=e(),v.process()}c=!1}function p(v){c||(v===void 0&&(v=s),l&&(m(l),l=null),v?d():f())}function d(){l=x(f)}function m(v){var _=clearTimeout;return _(v)}function x(v){var _=function(w){return setTimeout(w,0)};return _(v)}return{add:h,force:p}};function e(){var t={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),t[c]||(t[c]=[]),t[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=t[c],f=0;f<h.length;f++){var p=h[f];p()}}function l(){return r}return{add:o,process:a,size:l}}return mm}var gm,Qx;function T9(){if(Qx)return gm;Qx=1;var n="_erd";function e(i){return i[n]={},t(i)}function t(i){return i[n]}function r(i){delete i[n]}return gm={initState:e,getState:t,cleanState:r},gm}var _m,e2;function A9(){if(e2)return _m;e2=1;var n=Kx();return _m=function(e){e=e||{};var t=e.reporter,r=e.batchProcessor,i=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function s(h,f){function p(){f(h)}if(n.isIE(8))i(h).object={proxy:p},h.attachEvent("onresize",p);else{var d=l(h);if(!d)throw new Error("Element is not detectable by this strategy.");d.contentDocument.defaultView.addEventListener("resize",p)}}function o(h){var f=e.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,p){p||(p=f,f=h,h=null),h=h||{},h.debug;function d(m,x){var v=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),_=!1,w=window.getComputedStyle(m),E=m.offsetWidth,S=m.offsetHeight;i(m).startSize={width:E,height:S};function b(){function A(){if(w.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var T=function(I,N,H,W){function Q(J){return J.replace(/[^-\d\.]/g,"")}var ae=H[W];ae!=="auto"&&Q(ae)!=="0"&&(I.warn("An element that is positioned static has style."+W+"="+ae+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+W+" will be set to 0. Element: ",N),N.style.setProperty(W,"0",h.important?"important":""))};T(t,m,w,"top"),T(t,m,w,"right"),T(t,m,w,"bottom"),T(t,m,w,"left")}}function q(){_||A();function T(N,H){if(!N.contentDocument){var W=i(N);W.checkForObjectDocumentTimeoutId&&window.clearTimeout(W.checkForObjectDocumentTimeoutId),W.checkForObjectDocumentTimeoutId=setTimeout(function(){W.checkForObjectDocumentTimeoutId=0,T(N,H)},100);return}H(N.contentDocument)}var I=this;T(I,function(H){x(m)})}w.position!==""&&(A(),_=!0);var O=document.createElement("object");O.style.cssText=v,O.tabIndex=-1,O.type="text/html",O.setAttribute("aria-hidden","true"),O.onload=q,n.isIE()||(O.data="about:blank"),i(m)&&(m.appendChild(O),i(m).object=O,n.isIE()&&(O.data="about:blank"))}r?r.add(b):b()}n.isIE(8)?p(f):d(f,p)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},_m}var vm,t2;function C9(){if(t2)return vm;t2=1;var n=Hx().forEach;return vm=function(e){e=e||{};var t=e.reporter,r=e.batchProcessor,i=e.stateHandler.getState;e.stateHandler.hasState;var s=e.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(b){p(b,a,l)}c(window.document);function h(b){var A=e.important?" !important; ":"; ";return(b.join(A)+A).trim()}function f(){var b=500,A=500,q=document.createElement("div");q.style.cssText=h(["position: absolute","width: "+b*2+"px","height: "+A*2+"px","visibility: hidden","margin: 0","padding: 0"]);var O=document.createElement("div");O.style.cssText=h(["position: absolute","width: "+b+"px","height: "+A+"px","overflow: scroll","visibility: none","top: "+-b*3+"px","left: "+-A*3+"px","visibility: hidden","margin: 0","padding: 0"]),O.appendChild(q),document.body.insertBefore(O,document.body.firstChild);var T=b-O.clientWidth,I=A-O.clientHeight;return document.body.removeChild(O),{width:T,height:I}}function p(b,A,q){function O(H,W){W=W||function(ae){b.head.appendChild(ae)};var Q=b.createElement("style");return Q.innerHTML=H,Q.id=A,W(Q),Q}if(!b.getElementById(A)){var T=q+"_animation",I=q+"_animation_active",N=`/* Created by the element-resize-detector library. */
3932
3932
  `;N+="."+q+" > div::-webkit-scrollbar { "+h(["display: none"])+` }
3933
3933
 
3934
3934
  `,N+="."+I+" { "+h(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+T,"animation-name: "+T])+` }
3935
3935
  `,N+="@-webkit-keyframes "+T+` { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }
3936
3936
  `,N+="@keyframes "+T+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",O(N)}}function d(b){b.className+=" "+l+"_animation_active"}function m(b,A,q){if(b.addEventListener)b.addEventListener(A,q);else if(b.attachEvent)b.attachEvent("on"+A,q);else return t.error("[scroll] Don't know how to add event listeners.")}function x(b,A,q){if(b.removeEventListener)b.removeEventListener(A,q);else if(b.detachEvent)b.detachEvent("on"+A,q);else return t.error("[scroll] Don't know how to remove event listeners.")}function v(b){return i(b).container.childNodes[0].childNodes[0].childNodes[0]}function _(b){return i(b).container.childNodes[0].childNodes[0].childNodes[1]}function w(b,A){var q=i(b).listeners;if(!q.push)throw new Error("Cannot add listener to an element that is not detectable.");i(b).listeners.push(A)}function E(b,A,q){q||(q=A,A=b,b=null),b=b||{};function O(){if(b.debug){var ee=Array.prototype.slice.call(arguments);if(ee.unshift(s.get(A),"Scroll: "),t.log.apply)t.log.apply(null,ee);else for(var Pe=0;Pe<ee.length;Pe++)t.log(ee[Pe])}}function T(ee){function Pe(le){var z=le.getRootNode&&le.getRootNode().contains(le);return le===le.ownerDocument.body||le.ownerDocument.body.contains(le)||z}return!Pe(ee)||window.getComputedStyle(ee)===null}function I(ee){var Pe=i(ee).container.childNodes[0],le=window.getComputedStyle(Pe);return!le.width||le.width.indexOf("px")===-1}function N(){var ee=window.getComputedStyle(A),Pe={};return Pe.position=ee.position,Pe.width=A.offsetWidth,Pe.height=A.offsetHeight,Pe.top=ee.top,Pe.right=ee.right,Pe.bottom=ee.bottom,Pe.left=ee.left,Pe.widthCSS=ee.width,Pe.heightCSS=ee.height,Pe}function H(){var ee=N();i(A).startSize={width:ee.width,height:ee.height},O("Element start size",i(A).startSize)}function W(){i(A).listeners=[]}function Q(){if(O("storeStyle invoked."),!i(A)){O("Aborting because element has been uninstalled");return}var ee=N();i(A).style=ee}function ae(ee,Pe,le){i(ee).lastWidth=Pe,i(ee).lastHeight=le}function J(ee){return v(ee).childNodes[0]}function se(){return 2*o.width+1}function B(){return 2*o.height+1}function ge(ee){return ee+10+se()}function F(ee){return ee+10+B()}function X(ee){return ee*2+se()}function de(ee){return ee*2+B()}function ye(ee,Pe,le){var z=v(ee),rt=_(ee),Le=ge(Pe),at=F(le),ze=X(Pe),Xe=de(le);z.scrollLeft=Le,z.scrollTop=at,rt.scrollLeft=ze,rt.scrollTop=Xe}function Ee(){var ee=i(A).container;if(!ee){ee=document.createElement("div"),ee.className=l,ee.style.cssText=h(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(A).container=ee,d(ee),A.appendChild(ee);var Pe=function(){i(A).onRendered&&i(A).onRendered()};m(ee,"animationstart",Pe),i(A).onAnimationStart=Pe}return ee}function V(){function ee(){var De=i(A).style;if(De.position==="static"){A.style.setProperty("position","relative",b.important?"important":"");var Ae=function(Ge,We,Ce,qe){function Be(Re){return Re.replace(/[^-\d\.]/g,"")}var Ye=Ce[qe];Ye!=="auto"&&Be(Ye)!=="0"&&(Ge.warn("An element that is positioned static has style."+qe+"="+Ye+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+qe+" will be set to 0. Element: ",We),We.style[qe]=0)};Ae(t,A,De,"top"),Ae(t,A,De,"right"),Ae(t,A,De,"bottom"),Ae(t,A,De,"left")}}function Pe(De,Ae,Ge,We){return De=De?De+"px":"0",Ae=Ae?Ae+"px":"0",Ge=Ge?Ge+"px":"0",We=We?We+"px":"0",["left: "+De,"top: "+Ae,"right: "+We,"bottom: "+Ge]}if(O("Injecting elements"),!i(A)){O("Aborting because element has been uninstalled");return}ee();var le=i(A).container;le||(le=Ee());var z=o.width,rt=o.height,Le=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),at=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(Pe(-(1+z),-(1+rt),-rt,-z))),ze=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),Xe=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),be=h(["position: absolute","left: 0","top: 0"]),tt=h(["position: absolute","width: 200%","height: 200%"]),lt=document.createElement("div"),$e=document.createElement("div"),U=document.createElement("div"),P=document.createElement("div"),te=document.createElement("div"),pe=document.createElement("div");lt.dir="ltr",lt.style.cssText=Le,lt.className=l,$e.className=l,$e.style.cssText=at,U.style.cssText=ze,P.style.cssText=be,te.style.cssText=Xe,pe.style.cssText=tt,U.appendChild(P),te.appendChild(pe),$e.appendChild(U),$e.appendChild(te),lt.appendChild($e),le.appendChild(lt);function Me(){var De=i(A);De&&De.onExpand?De.onExpand():O("Aborting expand scroll handler: element has been uninstalled")}function fe(){var De=i(A);De&&De.onShrink?De.onShrink():O("Aborting shrink scroll handler: element has been uninstalled")}m(U,"scroll",Me),m(te,"scroll",fe),i(A).onExpandScroll=Me,i(A).onShrinkScroll=fe}function re(){function ee(ze,Xe,be){var tt=J(ze),lt=ge(Xe),$e=F(be);tt.style.setProperty("width",lt+"px",b.important?"important":""),tt.style.setProperty("height",$e+"px",b.important?"important":"")}function Pe(ze){var Xe=A.offsetWidth,be=A.offsetHeight,tt=Xe!==i(A).lastWidth||be!==i(A).lastHeight;O("Storing current size",Xe,be),ae(A,Xe,be),r.add(0,function(){if(tt){if(!i(A)){O("Aborting because element has been uninstalled");return}if(!le()){O("Aborting because element container has not been initialized");return}if(b.debug){var $e=A.offsetWidth,U=A.offsetHeight;($e!==Xe||U!==be)&&t.warn(s.get(A),"Scroll: Size changed before updating detector elements.")}ee(A,Xe,be)}}),r.add(1,function(){if(!i(A)){O("Aborting because element has been uninstalled");return}if(!le()){O("Aborting because element container has not been initialized");return}ye(A,Xe,be)}),tt&&ze&&r.add(2,function(){if(!i(A)){O("Aborting because element has been uninstalled");return}if(!le()){O("Aborting because element container has not been initialized");return}ze()})}function le(){return!!i(A).container}function z(){function ze(){return i(A).lastNotifiedWidth===void 0}O("notifyListenersIfNeeded invoked");var Xe=i(A);if(ze()&&Xe.lastWidth===Xe.startSize.width&&Xe.lastHeight===Xe.startSize.height)return O("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(Xe.lastWidth===Xe.lastNotifiedWidth&&Xe.lastHeight===Xe.lastNotifiedHeight)return O("Not notifying: Size already notified");O("Current size not notified, notifying..."),Xe.lastNotifiedWidth=Xe.lastWidth,Xe.lastNotifiedHeight=Xe.lastHeight,n(i(A).listeners,function(be){be(A)})}function rt(){if(O("startanimation triggered."),I(A)){O("Ignoring since element is still unrendered...");return}O("Element rendered.");var ze=v(A),Xe=_(A);(ze.scrollLeft===0||ze.scrollTop===0||Xe.scrollLeft===0||Xe.scrollTop===0)&&(O("Scrollbars out of sync. Updating detector elements..."),Pe(z))}function Le(){if(O("Scroll detected."),I(A)){O("Scroll event fired while unrendered. Ignoring...");return}Pe(z)}if(O("registerListenersAndPositionElements invoked."),!i(A)){O("Aborting because element has been uninstalled");return}i(A).onRendered=rt,i(A).onExpand=Le,i(A).onShrink=Le;var at=i(A).style;ee(A,at.width,at.height)}function Z(){if(O("finalizeDomMutation invoked."),!i(A)){O("Aborting because element has been uninstalled");return}var ee=i(A).style;ae(A,ee.width,ee.height),ye(A,ee.width,ee.height)}function he(){q(A)}function xe(){O("Installing..."),W(),H(),r.add(0,Q),r.add(1,V),r.add(2,re),r.add(3,Z),r.add(4,he)}O("Making detectable..."),T(A)?(O("Element is detached"),Ee(),O("Waiting until element is attached..."),i(A).onRendered=function(){O("Element is now attached"),xe()}):xe()}function S(b){var A=i(b);A&&(A.onExpandScroll&&x(v(b),"scroll",A.onExpandScroll),A.onShrinkScroll&&x(_(b),"scroll",A.onShrinkScroll),A.onAnimationStart&&x(A.container,"animationstart",A.onAnimationStart),A.container&&b.removeChild(A.container))}return{makeDetectable:E,addListener:w,uninstall:S,initDocument:c}},vm}var xm,n2;function R9(){if(n2)return xm;n2=1;var n=Hx().forEach,e=x9(),t=y9(),r=S9(),i=E9(),s=b9(),o=Kx(),a=w9(),l=T9(),c=A9(),h=C9();function f(x){return Array.isArray(x)||x.length!==void 0}function p(x){if(Array.isArray(x))return x;var v=[];return n(x,function(_){v.push(_)}),v}function d(x){return x&&x.nodeType===1}xm=function(x){x=x||{};var v;if(x.idHandler)v={get:function(se){return x.idHandler.get(se,!0)},set:x.idHandler.set};else{var _=r(),w=i({idGenerator:_,stateHandler:l});v=w}var E=x.reporter;if(!E){var S=E===!1;E=s(S)}var b=m(x,"batchProcessor",a({reporter:E})),A={};A.callOnAdd=!!m(x,"callOnAdd",!0),A.debug=!!m(x,"debug",!1);var q=t(v),O=e({stateHandler:l}),T,I=m(x,"strategy","object"),N=m(x,"important",!1),H={reporter:E,batchProcessor:b,stateHandler:l,idHandler:v,important:N};if(I==="scroll"&&(o.isLegacyOpera()?(E.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),I="object"):o.isIE(9)&&(E.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),I="object")),I==="scroll")T=h(H);else if(I==="object")T=c(H);else throw new Error("Invalid strategy name: "+I);var W={};function Q(se,B,ge){function F(re){var Z=q.get(re);n(Z,function(xe){xe(re)})}function X(re,Z,he){q.add(Z,he),re&&he(Z)}if(ge||(ge=B,B=se,se={}),!B)throw new Error("At least one element required.");if(!ge)throw new Error("Listener required.");if(d(B))B=[B];else if(f(B))B=p(B);else return E.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var de=0,ye=m(se,"callOnAdd",A.callOnAdd),Ee=m(se,"onReady",function(){}),V=m(se,"debug",A.debug);n(B,function(Z){l.getState(Z)||(l.initState(Z),v.set(Z));var he=v.get(Z);if(V&&E.log("Attaching listener to element",he,Z),!O.isDetectable(Z)){if(V&&E.log(he,"Not detectable."),O.isBusy(Z)){V&&E.log(he,"System busy making it detectable"),X(ye,Z,ge),W[he]=W[he]||[],W[he].push(function(){de++,de===B.length&&Ee()});return}return V&&E.log(he,"Making detectable..."),O.markBusy(Z,!0),T.makeDetectable({debug:V,important:N},Z,function(ee){if(V&&E.log(he,"onElementDetectable"),l.getState(ee)){O.markAsDetectable(ee),O.markBusy(ee,!1),T.addListener(ee,F),X(ye,ee,ge);var Pe=l.getState(ee);if(Pe&&Pe.startSize){var le=ee.offsetWidth,z=ee.offsetHeight;(Pe.startSize.width!==le||Pe.startSize.height!==z)&&F(ee)}W[he]&&n(W[he],function(rt){rt()})}else V&&E.log(he,"Element uninstalled before being detectable.");delete W[he],de++,de===B.length&&Ee()})}V&&E.log(he,"Already detecable, adding listener."),X(ye,Z,ge),de++}),de===B.length&&Ee()}function ae(se){if(!se)return E.error("At least one element is required.");if(d(se))se=[se];else if(f(se))se=p(se);else return E.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");n(se,function(B){q.removeAllListeners(B),T.uninstall(B),l.cleanState(B)})}function J(se){T.initDocument&&T.initDocument(se)}return{listenTo:Q,removeListener:q.removeListener,removeAllListeners:q.removeAllListeners,uninstall:ae,initDocument:J}};function m(x,v,_){var w=x[v];return w==null&&_!==void 0?_:w}return xm}var P9=R9();const I9=qa(P9);function L9(n){const{top:e,right:t,bottom:r,left:i,width:s,height:o}=n.getBoundingClientRect();return{top:e,right:t,bottom:r,left:i,width:s,height:o}}const O9=({children:n})=>{const[e,t]=ne.useState(null),r=ne.useRef(null),i=ne.useRef(null);return ne.useEffect(()=>{if(!r.current)return;const s=r.current.parentElement;if(!s)return;i.current=I9({strategy:"scroll",callOnAdd:!1});const o=()=>{const a=L9(s);t(a)};return i.current.listenTo(s,o),o(),()=>{i.current&&s&&i.current.uninstall(s)}},[]),e?typeof n=="function"?n(e):ne.cloneElement(n,e):R.jsx("div",{ref:r})};function q9(n){const e=ne.useRef(!1),t=ne.useRef(!1),r=ne.useCallback(async()=>{if(!(t.current||e.current)){t.current=!0;try{const i=await bx();e.current=!0,n&&n(i)}catch{}finally{t.current=!1}}},[n]);return ne.useEffect(()=>{const i=s=>{if(!e.current)return r(),s.preventDefault(),s.returnValue="",""};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i)}},[r]),{ensureScreenshot:r,screenshotDone:e}}const D9=()=>{const{toast:n,setToast:e}=Ht(),[t,r]=ne.useState(!1);return ne.useEffect(()=>{let i;return n&&(r(!0),i=setTimeout(()=>{r(!1),setTimeout(()=>e(null),300)},2500)),()=>clearTimeout(i)},[n,e]),n?R.jsx("div",{className:`absolute top-6 left-1/2 -translate-x-1/2 z-[9999] transition-all duration-300 ease-in-out
3937
3937
  ${t?"opacity-100 translate-y-0":"opacity-0 -translate-y-2"}
3938
- `,children:R.jsx("div",{className:"p-1 px-3 shadow-md rounded-md bg-white text-slate-600",children:R.jsxs("div",{className:"flex gap-1 justify-center items-center h-8 rounded",children:[R.jsx("span",{className:"text-xs",children:n.text}),R.jsx("div",{className:"text-xs bg-gray-50 border rounded-md px-1 py-0.5 font-medium",children:"ESC"})]})})}):null},N9=[m9("pub_planner_v0"),g9()],U9=({plan:n,catalog:e,onSave:t,onBack:r,has3dView:i})=>{const s=Ht();return ne.useEffect(()=>{s.initCatalog(e),N9.forEach(o=>o(s,n,t))},[]),ne.useEffect(()=>{s.planner.getIn(["catalog","ready"])||s.initCatalog(e)},[e]),q9(o=>{t&&t({imageURI:o})}),R.jsx(O9,{children:({width:o,height:a})=>{const l=o,c=a;return R.jsxs("div",{className:"flex flex-nowrap flex-row h-full floor_planner",children:[R.jsx(D9,{}),R.jsx(v9,{onSave:t,onBack:r}),R.jsx(d9,{catalog:e,has3dView:i}),R.jsx(XA,{width:l,height:c,catalog:e}),R.jsx(Y7,{catalog:e,width:280}),R.jsx(ZA,{})]})}})},F9=()=>R.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-[#2b2d35] overflow-hidden",children:[R.jsxs("div",{className:"flex h-[45px] items-center justify-between border border-[#424242] bg-[#2b2d35] px-2",children:[R.jsx("div",{className:"flex flex-1 items-center",children:R.jsx("div",{className:"h-[30px] w-[30px] rounded bg-[#424242] animate-pulse"})}),R.jsx("div",{className:"flex items-center",children:R.jsx("div",{className:"h-[18px] w-[175px] bg-[#424242] animate-pulse"})}),R.jsx("div",{className:"flex flex-1 items-center justify-end",children:R.jsx("div",{className:"mr-20 flex flex-row gap-3",children:[...Array(2)].map((n,e)=>R.jsx("div",{className:"h-[24px] w-[24px] rounded bg-[#424242] animate-pulse"},`${e}`))})})]}),R.jsx("div",{className:"flex flex-1",children:R.jsx("div",{className:"flex flex-1 items-center justify-center bg-[#2b2d35]",children:R.jsx("div",{className:"h-[90%] w-[90%] bg-[#424242] animate-pulse"})})})]}),z9=(n,e,t,r)=>{if(!e)return;const i=new tv;n.map=i.load(e.uri),n.needsUpdate=!0,n.map.wrapS=Zr,n.map.wrapT=Zr,n.map.repeat.set(t*e.lengthRepeatScale,r*e.heightRepeatScale),e.normal&&(n.normalMap=i.load(e.normal.uri),n.normalScale=new Ne(e.normal.normalScaleX,e.normal.normalScaleY),n.normalMap.wrapS=Zr,n.normalMap.wrapT=Zr,n.normalMap.repeat.set(t*e.normal.lengthRepeatScale,r*e.normal.heightRepeatScale))},k9=n=>{n.computeBoundingBox();const e=n.boundingBox;if(!e)return;const t=e.min,r=e.max,i=new Ne(0-t.x,0-t.y),s=new Ne(r.x-t.x,r.y-t.y),o=n.getAttribute("position");new Float32Array(o.count/3*2*3);const a=[];for(let l=0;l<o.count;l++){const c=o.getX(l),h=o.getY(l),f=(c+i.x)/s.x,p=(h+i.y)/s.y;a.push(f,p)}n.setAttribute("uv",new Gn(a,2))};function B9(n,e,t,r){let i=[];n.vertices.forEach(x=>{i.push(e.vertices.get(x))});let s=n.properties.get("patternColor");const o=n.properties.get("texture");n.selected?s=Lt.AREA_MESH_COLOR.selected:o&&o!=="none"&&(s=Lt.AREA_MESH_COLOR.unselected);const a=new la;a.moveTo(i[0].x,i[0].y);for(let x=1;x<i.length;x++)a.lineTo(i[x].x,i[x].y);const l=new B4({side:Si,color:s});n.holes.forEach(x=>{let v=[];e.getIn(["areas",x,"vertices"]).forEach(w=>{const{x:E,y:S}=e.getIn(["vertices",w]);v.push([E,S])}),v=v.reverse();let _=H9(v);a.holes.push(_)});const c=new Np(a);k9(c);const h=new wi().setFromObject(new Tn(c,new Ks)),f=h.max.x-h.min.x,p=h.max.y-h.min.y,d=r[o];z9(l,d,f,p);const m=new Tn(c,l);return m.rotation.x-=Math.PI/2,m.name="floor",Promise.resolve(m)}async function V9(n,e,t,r,i,s,o,a,l){const c=async()=>(a(),await l()),h=i.getObjectByName("floor");if(!h)return i;if(o[0]=="selected"){const f=n.selected?Lt.AREA_MESH_COLOR.selected:n.properties.get("patternColor")||Lt.AREA_MESH_COLOR.unselected;h.material.color.set(f)}else if(o[0]=="properties"){if(o[1]==="texture")return await c()}else return await c();return Promise.resolve(i)}const H9=n=>{const e=new la;e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);return e};function G9(n,e,t){let r={name:n,prototype:"areas",info:{...e,visibility:{catalog:!1,layerElementsVisible:!1}},properties:{patternColor:{label:"color",type:"color",defaultValue:Lt.AREA_MESH_COLOR.unselected},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:0,_length:0,_unit:Cr}}},render2D:function(i,s,o){let a="";const l=i.properties.get("texture"),c=t[l],h=[];i.vertices.forEach((E,S)=>{const b=s.vertices.get(E);h.push(b),a+=(S?"L":"M")+b.x+" "+b.y+" "}),i.holes.forEach(E=>{s.areas.get(E).vertices.reverse().forEach((b,A)=>{const q=s.vertices.get(b);a+=(A?"L":"M")+q.x+" "+q.y+" "})});const f=Math.min(...h.map(E=>E.x)),p=Math.max(...h.map(E=>E.x)),d=Math.min(...h.map(E=>E.y)),m=Math.max(...h.map(E=>E.y)),x=p-f,v=m-d;i.properties.get("patternColor"),i.selected;const _=i.selected?Lt.AREA_MESH_COLOR.selected:i.properties.get("patternColor"),w=`pattern-${i.id}`;return R.jsxs("g",{children:[R.jsx("defs",{children:c&&R.jsx("pattern",{id:w,patternUnits:"userSpaceOnUse",width:x/(x*c.lengthRepeatScale),height:v/(v*c.heightRepeatScale),x:f,y:d,children:R.jsx("image",{href:c.uri,width:x,height:v,preserveAspectRatio:"none"})})}),R.jsx("path",{d:a,fill:c?`url(#${w})`:_})]})},render3D:function(i,s,o){return B9(i,s,o,t)},updateRender3D:(i,s,o,a,l,c,h,f)=>V9(i,s,o,t,a,l,c,h,f)};if(t&&Object.keys(t).length>0){let i={none:"None"};for(let s in t)i[s]=t[s].name;r.properties.texture={label:"texture",type:"enum",defaultValue:"none",values:i}}return r}const r2=1e-5,Ku=0,zl=1,Ea=2,i2=3;class lo{constructor(e){ht(this,"Polygon");ht(this,"Vertex");ht(this,"Node");ht(this,"matrix");ht(this,"tree");if(this.Polygon=ba,this.Vertex=Zu,this.Node=Ji,e instanceof Tn)e.updateMatrixWorld(),this.matrix=e.matrixWorld.clone(),e=e.geometry;else if(e instanceof nr)this.matrix=new Gt;else{if(e instanceof Ji)return this.tree=e,this.matrix=new Gt,this;throw new Error("ThreeBSP: Given geometry is unsupported")}const t=[],r=e.getAttribute("position"),i=e.getAttribute("uv"),s=e.getIndex(),o=l=>{const c=r.getX(l),h=r.getY(l),f=r.getZ(l),p=i?new Ne(i.getX(l),i.getY(l)):null,d=new Zu(c,h,f,new j,p);return d.applyMatrix4(this.matrix),d},a=s?s.array:[...Array(r.count).keys()];for(let l=0;l<a.length;l+=3){const c=o(a[l]),h=o(a[l+1]),f=o(a[l+2]),p=new ba([c,h,f]);p.calculateProperties(),t.push(p)}this.tree=new Ji(t)}subtract(e){let t=this.tree.clone(),r=e.tree.clone();return t.invert(),t.clipTo(r),r.clipTo(t),r.invert(),r.clipTo(t),r.invert(),t.build(r.allPolygons()),t.invert(),t=new lo(t),t.matrix=this.matrix,t}union(e){let t=this.tree.clone(),r=e.tree.clone();return t.clipTo(r),r.clipTo(t),r.invert(),r.clipTo(t),r.invert(),t.build(r.allPolygons()),t=new lo(t),t.matrix=this.matrix,t}intersect(e){let t=this.tree.clone(),r=e.tree.clone();return t.invert(),r.clipTo(t),r.invert(),t.clipTo(r),r.clipTo(t),t.build(r.allPolygons()),t.invert(),t=new lo(t),t.matrix=this.matrix,t}toGeometry(){const e=new Gt().copy(this.matrix).invert(),t=[],r=[];this.tree.allPolygons().forEach(o=>{for(let a=2;a<o.vertices.length;a++)[o.vertices[0],o.vertices[a-1],o.vertices[a]].forEach(c=>{const h=new j(c.x,c.y,c.z).applyMatrix4(e);t.push(h.x,h.y,h.z),c.uv?r.push(c.uv.x,c.uv.y):r.push(0,0)})});const s=new nr;return s.setAttribute("position",new Gn(t,3)),s.setAttribute("uv",new Gn(r,2)),s.computeVertexNormals(),s}toMesh(e){const t=this.toGeometry(),r=new Tn(t,e),i=new j,s=new ds,o=new j;return this.matrix.decompose(i,s,o),r.position.copy(i),r.quaternion.copy(s),r.scale.copy(o),r}}class ba{constructor(e,t,r){ht(this,"vertices");ht(this,"normal");ht(this,"w");e instanceof Array||(e=[]),this.vertices=e,e.length>0?this.calculateProperties():this.normal=this.w=void 0}calculateProperties(){var e=this.vertices[0],t=this.vertices[1],r=this.vertices[2];return this.normal=t.clone().subtract(e).cross(r.clone().subtract(e)).normalize(),this.normal&&(this.w=this.normal.clone().dot(e)),this}clone(){var e,t,r=new ba;for(e=0,t=this.vertices.length;e<t;e++)r.vertices.push(this.vertices[e].clone());return r.calculateProperties(),r}flip(){var e,t=[];for(this.normal&&this.normal.multiplyScalar(-1),this.w&&(this.w*=-1),e=this.vertices.length-1;e>=0;e--)t.push(this.vertices[e]);return this.vertices=t,this}classifyVertex(e){if(!this.normal||!this.w)return Ku;var t=this.normal.dot(e)-this.w;return t<-r2?Ea:t>r2?zl:Ku}classifySide(e){var t,r,i,s=0,o=0,a=e.vertices.length;for(t=0;t<a;t++)r=e.vertices[t],i=this.classifyVertex(r),i===zl?s++:i===Ea&&o++;return s>0&&o===0?zl:s===0&&o>0?Ea:s===0&&o===0?Ku:i2}splitPolygon(e,t,r,i,s){var o=this.classifySide(e);if(o===Ku)(this.normal&&e.normal&&this.normal.dot(e.normal)>0?t:r).push(e);else if(o===zl)i.push(e);else if(o===Ea)s.push(e);else{var a,l,c,h,f,p,d,m,x,v=[],_=[];for(l=0,a=e.vertices.length;l<a;l++)c=(l+1)%a,p=e.vertices[l],d=e.vertices[c],h=this.classifyVertex(p),f=this.classifyVertex(d),h!=Ea&&v.push(p),h!=zl&&_.push(p),(h|f)===i2&&this.w&&this.normal&&(m=(this.w-this.normal.dot(p))/this.normal.dot(d.clone().subtract(p)),x=p.interpolate(d,m),v.push(x),_.push(x));v.length>=3&&i.push(new ba(v).calculateProperties()),_.length>=3&&s.push(new ba(_).calculateProperties())}}}class Zu{constructor(e,t,r,i,s){ht(this,"x");ht(this,"y");ht(this,"z");ht(this,"normal");ht(this,"uv");this.x=e,this.y=t,this.z=r,this.normal=i||new j,this.uv=s||new Ne}clone(){return new Zu(this.x,this.y,this.z,this.normal.clone(),this.uv?this.uv.clone():null)}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}subtract(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}cross(e){var t=this.x,r=this.y,i=this.z;return this.x=r*e.z-i*e.y,this.y=i*e.x-t*e.z,this.z=t*e.y-r*e.x,this}normalize(){var e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=e,this.y/=e,this.z/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lerp(e,t){return this.add(e.clone().subtract(this).multiplyScalar(t)),this.normal.add(e.normal.clone().sub(this.normal).multiplyScalar(t)),this.uv&&e.uv&&this.uv.add(e.uv.clone().sub(this.uv).multiplyScalar(t)),this}interpolate(e,t){return this.clone().lerp(e,t)}applyMatrix4(e){var t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i+s[12],this.y=s[1]*t+s[5]*r+s[9]*i+s[13],this.z=s[2]*t+s[6]*r+s[10]*i+s[14],this}}class Ji{constructor(e){ht(this,"polygons");ht(this,"front");ht(this,"back");ht(this,"divider");var t,r,i=[],s=[];if(this.polygons=[],this.front=this.back=void 0,!(!(e instanceof Array)||e.length===0)){for(this.divider=e[0].clone(),t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],this.polygons,this.polygons,i,s);i.length>0&&(this.front=new Ji(i)),s.length>0&&(this.back=new Ji(s))}}isConvex(e){var t,r;for(t=0;t<e.length;t++)for(r=0;r<e.length;r++)if(t!==r&&e[t].classifySide(e[r])!==Ea)return!1;return!0}build(e){var t,r,i=[],s=[];for(this.divider||(this.divider=e[0].clone()),t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],this.polygons,this.polygons,i,s);i.length>0&&(this.front||(this.front=new Ji),this.front.build(i)),s.length>0&&(this.back||(this.back=new Ji),this.back.build(s))}allPolygons(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e}clone(){var e=new Ji;return e.divider=this.divider?this.divider.clone():void 0,e.polygons=this.polygons.map(function(t){return t.clone()}),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone(),e}invert(){var e,t,r;for(e=0,t=this.polygons.length;e<t;e++)this.polygons[e].flip();return this.divider&&this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),r=this.front,this.front=this.back,this.back=r,this}clipPolygons(e){var t,r,i,s;if(!this.divider)return e.slice();for(i=[],s=[],t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],i,s,i,s);return this.front&&(i=this.front.clipPolygons(i)),this.back?s=this.back.clipPolygons(s):s=[],i.concat(s)}clipTo(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)}}window.ThreeBSP=lo;const Ma=Math.PI/2,W9=(n,e)=>n.x*e.x+n.y*e.y,s2=n=>{const e=Math.hypot(n.x,n.y);return{x:n.x/e,y:n.y/e}},o2=(n,e=16777215)=>n&&(typeof n=="string"||typeof n=="number")?n:e,a2=(n,e,t,r)=>{if(!e)return;const i=new tv;n.map=i.load(e.uri),n.needsUpdate=!0,n.map.wrapS=Zr,n.map.wrapT=Zr,n.map.repeat.set(t*(e.lengthRepeatScale??1),r*(e.heightRepeatScale??1)),e.normal&&n instanceof k4&&(n.normalMap=i.load(e.normal.uri),n.normalScale=new Ne(e.normal.normalScaleX,e.normal.normalScaleY),n.normalMap.wrapS=Zr,n.normalMap.wrapT=Zr,n.normalMap.repeat.set(t*(e.normal.lengthRepeatScale??1),r*(e.normal.heightRepeatScale??1)))},j9=(n,e,t)=>{for(const r of n.areas.valueSeq()){const i=r.vertices,s=i.size;for(let o=0;o<s;o++){const a=i.get(o),l=i.get((o+1)%s);if(a===e&&l===t||a===t&&l===e)return{area:r,edgeIndex:o}}}return null},X9=(n,e,t)=>{let r=!0;const i=s2({x:t.x-e.x,y:t.y-e.y}),s={x:-i.y,y:i.x},o=j9(n,e.id,t.id);if(o){const{area:a,edgeIndex:l}=o,c=a.vertices.get(l),h=a.vertices.get((l+1)%a.vertices.size),f=n.vertices.get(c),p=n.vertices.get(h),d=s2({x:p.x-f.x,y:p.y-f.y}),m={x:-d.y,y:d.x};r=W9(s,m)<0}return r};function $9(n,e,t,r){let i=!1,s=e.vertices.get(n.vertices.get(0)),o=e.vertices.get(n.vertices.get(1)),a=X9(e,s,o);if(s.x>o.x){const W=s;s=o,o=W,i=!0}const l=n.properties.getIn(["height","length"]),c=n.properties.getIn(["thickness","length"]),h=.2,f=1,p=mc(s,o),d=p/2,m=c/2,x=new Ks({color:n.selected?Lt.MESH_SELECTED:13882323});let v=new Tn(new Js(p,l,c),x);const _=Math.asin((o.y-s.y)/p),w=Math.sin(_),E=Math.cos(_);v.position.y+=l/2,v.position.x+=d*E,v.position.z-=d*w,v.rotation.y=_,n.holes.forEach(W=>{const Q=e.holes.get(W),ae=Q.properties.getIn(["width","length"]),J=Q.properties.getIn(["height","length"]),se=Q.properties.getIn(["altitude","length"]),ge=(i?1-Q.offset:Q.offset)*p,F=new Js(ae,J,c),X=new Tn(F);X.position.y+=J/2+se,X.position.x+=ge*E,X.position.z-=ge*w,X.rotation.y=_;const de=new lo(v),ye=new lo(X);v=de.subtract(ye).toMesh(x)}),v.name="soul";let S="A",b="B";if(a){const W=S;S=b,b=W}const A=new Ks({color:o2(n.properties.get(`color${b}`))}),q=new Ks({color:o2(n.properties.get(`color${S}`))});a2(A,r[n.properties.get(`texture${b}`)],p,l),a2(q,r[n.properties.get(`texture${S}`)],p,l);const O=h/c,T=m+f,I=v.clone();I.material=A,I.scale.set(1,1,O),I.position.x+=T*Math.cos(_-Ma),I.position.z-=T*Math.sin(_-Ma),I.name="frontFace";const N=v.clone();N.material=q,N.scale.set(1,1,O),N.position.x+=T*Math.cos(_+Ma),N.position.z-=T*Math.sin(_+Ma),N.name="backFace";const H=new aa;return H.add(v,I,N),Promise.resolve(H)}function Y9(n,e,t,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("soul"),f=i.getObjectByName("frontFace"),p=i.getObjectByName("backFace");if(o[0]=="selected")h.material=new Ks({color:n.selected?Lt.MESH_SELECTED:13882323});else if(o[0]=="properties")if(o[1]=="thickness"){let d=n.getIn(["properties","thickness","length"]),m=s.getIn(["properties","thickness","length"]),v=d/2+1,_=m/h.scale.z,w=h.rotation.y,E=v*Math.cos(w-Ma),S=v*Math.sin(w-Ma);h.scale.set(1,1,d/_),f.position.x=h.position.x+E,f.position.z=h.position.z+S,p.position.x=h.position.x-E,p.position.z=h.position.z-S}else return c();else return c();return Promise.resolve(i)}function K9(n,e,t){let r={name:n,prototype:"lines",info:e,properties:{height:{label:"height",type:"length-measure",defaultValue:{length:300}},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:10,_length:10,_unit:Cr}}},render2D:function(i,s,o,a){let{x:l,y:c}=s.vertices.get(i.vertices.get(0)),{x:h,y:f}=s.vertices.get(i.vertices.get(1)),p=Cn(l,c,h,f),d=i.getIn(["properties","thickness","length"]),m=d/2;return R.jsx("g",{children:R.jsx("rect",{x:"0",y:-m,width:p,height:d,style:{fill:i.selected&&![Tr,Jn].includes(a)?Lt.LINE_MESH_COLOR.selected:Lt.COLORS.black,stroke:"none"}})})},render3D:function(i,s,o){return $9(i,s,o,t)},updateRender3D:(i,s,o,a,l,c,h,f)=>Y9(i,s,o,t,a,l,c,h,f)};if(r.properties.colorA={label:"inside color",type:"color",defaultValue:Lt.COLORS.white},r.properties.colorB={label:"outside color",type:"color",defaultValue:Lt.COLORS.white},t&&Object.keys(t).length>0){const i={none:"None"};for(let s in t)i[s]=t[s].name;r.properties.textureA={label:"inside texture",type:"enum",defaultValue:i.painted?"painted":"none",values:i},r.properties.textureB={label:"outside texture",type:"enum",defaultValue:i.painted?"painted":"none",values:i}}return r}function Z9(n,e,t,r){const i=new aa;return i.name="surface",Promise.resolve(i)}function J9(n,e,t,r,i,s,o,a,l){return Promise.resolve(i)}const l2={strokeWidth:1,stroke:"transparent"},Q9={...l2,stroke:Lt.LINE_MESH_COLOR.selected};function eC(n,e,t){return{name:n,prototype:"lines",info:e,properties:{},render2D:function(i,s,o){let{x:a,y:l}=s.vertices.get(i.vertices.get(0)),{x:c,y:h}=s.vertices.get(i.vertices.get(1)),f=Cn(a,l,c,h);return i.selected?R.jsx("g",{children:R.jsx("rect",{x:"0",y:"0",width:f,height:0,style:Q9})}):R.jsx("rect",{x:"0",y:"0",width:f,height:0,style:l2})},render3D:function(i,s,o){return Z9()},updateRender3D:(i,s,o,a,l,c,h,f)=>J9(i,s,o,t,a)}}fn.AreaFactory=G9,fn.Catalog=r9,fn.ReactPlannerLoader=F9,fn.SurfaceFactory=eC,fn.WallFactory=K9,fn.convertUnits=Kr,fn.default=U9,Object.defineProperties(fn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
3938
+ `,children:R.jsx("div",{className:"p-1 px-3 shadow-md rounded-md bg-white text-slate-600",children:R.jsxs("div",{className:"flex gap-1 justify-center items-center h-8 rounded",children:[R.jsx("span",{className:"text-xs",children:n.text}),R.jsx("div",{className:"text-xs bg-gray-50 border rounded-md px-1 py-0.5 font-medium",children:"ESC"})]})})}):null},N9=[m9("pub_planner_v0"),g9()],U9=({plan:n,catalog:e,onSave:t,onBack:r,has3dView:i})=>{const s=Ht();return ne.useEffect(()=>{s.initCatalog(e),N9.forEach(o=>o(s,n,t))},[]),ne.useEffect(()=>{s.planner.getIn(["catalog","ready"])||s.initCatalog(e)},[e]),q9(o=>{t&&t({imageURI:o})}),R.jsx(O9,{children:({width:o,height:a})=>{const l=o,c=a;return R.jsxs("div",{className:"flex flex-nowrap flex-row h-full floor_planner",children:[R.jsx(D9,{}),R.jsx(v9,{onSave:t,onBack:r}),R.jsx(d9,{catalog:e,has3dView:i}),R.jsx(XA,{width:l,height:c,catalog:e}),R.jsx(Y7,{catalog:e,width:280}),R.jsx(ZA,{})]})}})},F9=()=>R.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-[#2b2d35] overflow-hidden",children:[R.jsxs("div",{className:"flex h-[45px] items-center justify-between border border-[#424242] bg-[#2b2d35] px-2",children:[R.jsx("div",{className:"flex flex-1 items-center",children:R.jsx("div",{className:"h-[30px] w-[30px] rounded bg-[#424242] animate-pulse"})}),R.jsx("div",{className:"flex items-center",children:R.jsx("div",{className:"h-[18px] w-[175px] bg-[#424242] animate-pulse"})}),R.jsx("div",{className:"flex flex-1 items-center justify-end",children:R.jsx("div",{className:"mr-20 flex flex-row gap-3",children:[...Array(2)].map((n,e)=>R.jsx("div",{className:"h-[24px] w-[24px] rounded bg-[#424242] animate-pulse"},`${e}`))})})]}),R.jsx("div",{className:"flex flex-1",children:R.jsx("div",{className:"flex flex-1 items-center justify-center bg-[#2b2d35]",children:R.jsx("div",{className:"h-[90%] w-[90%] bg-[#424242] animate-pulse"})})})]}),z9=(n,e,t,r)=>{if(!e)return;const i=new tv;n.map=i.load(e.uri),n.needsUpdate=!0,n.map.wrapS=Zr,n.map.wrapT=Zr,n.map.repeat.set(t*e.lengthRepeatScale,r*e.heightRepeatScale),e.normal&&(n.normalMap=i.load(e.normal.uri),n.normalScale=new Ne(e.normal.normalScaleX,e.normal.normalScaleY),n.normalMap.wrapS=Zr,n.normalMap.wrapT=Zr,n.normalMap.repeat.set(t*e.normal.lengthRepeatScale,r*e.normal.heightRepeatScale))},k9=n=>{n.computeBoundingBox();const e=n.boundingBox;if(!e)return;const t=e.min,r=e.max,i=new Ne(0-t.x,0-t.y),s=new Ne(r.x-t.x,r.y-t.y),o=n.getAttribute("position");new Float32Array(o.count/3*2*3);const a=[];for(let l=0;l<o.count;l++){const c=o.getX(l),h=o.getY(l),f=(c+i.x)/s.x,p=(h+i.y)/s.y;a.push(f,p)}n.setAttribute("uv",new Gn(a,2))};function B9(n,e,t,r){let i=[];n.vertices.forEach(x=>{i.push(e.vertices.get(x))});let s=n.properties.get("patternColor");const o=n.properties.get("texture");n.selected?s=Lt.AREA_MESH_COLOR.selected:o&&o!=="none"&&(s=Lt.AREA_MESH_COLOR.unselected);const a=new la;a.moveTo(i[0].x,i[0].y);for(let x=1;x<i.length;x++)a.lineTo(i[x].x,i[x].y);const l=new B4({side:Si,color:s});n.holes.forEach(x=>{let v=[];e.getIn(["areas",x,"vertices"]).forEach(w=>{const{x:E,y:S}=e.getIn(["vertices",w]);v.push([E,S])}),v=v.reverse();let _=H9(v);a.holes.push(_)});const c=new Np(a);k9(c);const h=new wi().setFromObject(new Tn(c,new Ks)),f=h.max.x-h.min.x,p=h.max.y-h.min.y,d=r[o];z9(l,d,f,p);const m=new Tn(c,l);return m.rotation.x-=Math.PI/2,m.name="floor",Promise.resolve(m)}async function V9(n,e,t,r,i,s,o,a,l){const c=async()=>(a(),await l()),h=i.getObjectByName("floor");if(!h)return i;if(o[0]=="selected"){const f=n.selected?Lt.AREA_MESH_COLOR.selected:n.properties.get("patternColor")||Lt.AREA_MESH_COLOR.unselected;h.material.color.set(f)}else if(o[0]=="properties"){if(o[1]==="texture")return await c()}else return await c();return Promise.resolve(i)}const H9=n=>{const e=new la;e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);return e};function G9(n,e,t){let r={name:n,prototype:"areas",info:{...e,visibility:{catalog:!1,layerElementsVisible:!1}},properties:{patternColor:{label:"color",type:"color",defaultValue:Lt.AREA_MESH_COLOR.unselected},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:0,_length:0,_unit:Rr}}},render2D:function(i,s,o){let a="";const l=i.properties.get("texture"),c=t[l],h=[];i.vertices.forEach((E,S)=>{const b=s.vertices.get(E);h.push(b),a+=(S?"L":"M")+b.x+" "+b.y+" "}),i.holes.forEach(E=>{s.areas.get(E).vertices.reverse().forEach((b,A)=>{const q=s.vertices.get(b);a+=(A?"L":"M")+q.x+" "+q.y+" "})});const f=Math.min(...h.map(E=>E.x)),p=Math.max(...h.map(E=>E.x)),d=Math.min(...h.map(E=>E.y)),m=Math.max(...h.map(E=>E.y)),x=p-f,v=m-d;i.properties.get("patternColor"),i.selected;const _=i.selected?Lt.AREA_MESH_COLOR.selected:i.properties.get("patternColor"),w=`pattern-${i.id}`;return R.jsxs("g",{children:[R.jsx("defs",{children:c&&R.jsx("pattern",{id:w,patternUnits:"userSpaceOnUse",width:x/(x*c.lengthRepeatScale),height:v/(v*c.heightRepeatScale),x:f,y:d,children:R.jsx("image",{href:c.uri,width:x,height:v,preserveAspectRatio:"none"})})}),R.jsx("path",{d:a,fill:c?`url(#${w})`:_})]})},render3D:function(i,s,o){return B9(i,s,o,t)},updateRender3D:(i,s,o,a,l,c,h,f)=>V9(i,s,o,t,a,l,c,h,f)};if(t&&Object.keys(t).length>0){let i={none:"None"};for(let s in t)i[s]=t[s].name;r.properties.texture={label:"texture",type:"enum",defaultValue:"none",values:i}}return r}const r2=1e-5,Ku=0,zl=1,Ea=2,i2=3;class lo{constructor(e){ht(this,"Polygon");ht(this,"Vertex");ht(this,"Node");ht(this,"matrix");ht(this,"tree");if(this.Polygon=ba,this.Vertex=Zu,this.Node=Ji,e instanceof Tn)e.updateMatrixWorld(),this.matrix=e.matrixWorld.clone(),e=e.geometry;else if(e instanceof nr)this.matrix=new Gt;else{if(e instanceof Ji)return this.tree=e,this.matrix=new Gt,this;throw new Error("ThreeBSP: Given geometry is unsupported")}const t=[],r=e.getAttribute("position"),i=e.getAttribute("uv"),s=e.getIndex(),o=l=>{const c=r.getX(l),h=r.getY(l),f=r.getZ(l),p=i?new Ne(i.getX(l),i.getY(l)):null,d=new Zu(c,h,f,new j,p);return d.applyMatrix4(this.matrix),d},a=s?s.array:[...Array(r.count).keys()];for(let l=0;l<a.length;l+=3){const c=o(a[l]),h=o(a[l+1]),f=o(a[l+2]),p=new ba([c,h,f]);p.calculateProperties(),t.push(p)}this.tree=new Ji(t)}subtract(e){let t=this.tree.clone(),r=e.tree.clone();return t.invert(),t.clipTo(r),r.clipTo(t),r.invert(),r.clipTo(t),r.invert(),t.build(r.allPolygons()),t.invert(),t=new lo(t),t.matrix=this.matrix,t}union(e){let t=this.tree.clone(),r=e.tree.clone();return t.clipTo(r),r.clipTo(t),r.invert(),r.clipTo(t),r.invert(),t.build(r.allPolygons()),t=new lo(t),t.matrix=this.matrix,t}intersect(e){let t=this.tree.clone(),r=e.tree.clone();return t.invert(),r.clipTo(t),r.invert(),t.clipTo(r),r.clipTo(t),t.build(r.allPolygons()),t.invert(),t=new lo(t),t.matrix=this.matrix,t}toGeometry(){const e=new Gt().copy(this.matrix).invert(),t=[],r=[];this.tree.allPolygons().forEach(o=>{for(let a=2;a<o.vertices.length;a++)[o.vertices[0],o.vertices[a-1],o.vertices[a]].forEach(c=>{const h=new j(c.x,c.y,c.z).applyMatrix4(e);t.push(h.x,h.y,h.z),c.uv?r.push(c.uv.x,c.uv.y):r.push(0,0)})});const s=new nr;return s.setAttribute("position",new Gn(t,3)),s.setAttribute("uv",new Gn(r,2)),s.computeVertexNormals(),s}toMesh(e){const t=this.toGeometry(),r=new Tn(t,e),i=new j,s=new ds,o=new j;return this.matrix.decompose(i,s,o),r.position.copy(i),r.quaternion.copy(s),r.scale.copy(o),r}}class ba{constructor(e,t,r){ht(this,"vertices");ht(this,"normal");ht(this,"w");e instanceof Array||(e=[]),this.vertices=e,e.length>0?this.calculateProperties():this.normal=this.w=void 0}calculateProperties(){var e=this.vertices[0],t=this.vertices[1],r=this.vertices[2];return this.normal=t.clone().subtract(e).cross(r.clone().subtract(e)).normalize(),this.normal&&(this.w=this.normal.clone().dot(e)),this}clone(){var e,t,r=new ba;for(e=0,t=this.vertices.length;e<t;e++)r.vertices.push(this.vertices[e].clone());return r.calculateProperties(),r}flip(){var e,t=[];for(this.normal&&this.normal.multiplyScalar(-1),this.w&&(this.w*=-1),e=this.vertices.length-1;e>=0;e--)t.push(this.vertices[e]);return this.vertices=t,this}classifyVertex(e){if(!this.normal||!this.w)return Ku;var t=this.normal.dot(e)-this.w;return t<-r2?Ea:t>r2?zl:Ku}classifySide(e){var t,r,i,s=0,o=0,a=e.vertices.length;for(t=0;t<a;t++)r=e.vertices[t],i=this.classifyVertex(r),i===zl?s++:i===Ea&&o++;return s>0&&o===0?zl:s===0&&o>0?Ea:s===0&&o===0?Ku:i2}splitPolygon(e,t,r,i,s){var o=this.classifySide(e);if(o===Ku)(this.normal&&e.normal&&this.normal.dot(e.normal)>0?t:r).push(e);else if(o===zl)i.push(e);else if(o===Ea)s.push(e);else{var a,l,c,h,f,p,d,m,x,v=[],_=[];for(l=0,a=e.vertices.length;l<a;l++)c=(l+1)%a,p=e.vertices[l],d=e.vertices[c],h=this.classifyVertex(p),f=this.classifyVertex(d),h!=Ea&&v.push(p),h!=zl&&_.push(p),(h|f)===i2&&this.w&&this.normal&&(m=(this.w-this.normal.dot(p))/this.normal.dot(d.clone().subtract(p)),x=p.interpolate(d,m),v.push(x),_.push(x));v.length>=3&&i.push(new ba(v).calculateProperties()),_.length>=3&&s.push(new ba(_).calculateProperties())}}}class Zu{constructor(e,t,r,i,s){ht(this,"x");ht(this,"y");ht(this,"z");ht(this,"normal");ht(this,"uv");this.x=e,this.y=t,this.z=r,this.normal=i||new j,this.uv=s||new Ne}clone(){return new Zu(this.x,this.y,this.z,this.normal.clone(),this.uv?this.uv.clone():null)}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}subtract(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}cross(e){var t=this.x,r=this.y,i=this.z;return this.x=r*e.z-i*e.y,this.y=i*e.x-t*e.z,this.z=t*e.y-r*e.x,this}normalize(){var e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=e,this.y/=e,this.z/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lerp(e,t){return this.add(e.clone().subtract(this).multiplyScalar(t)),this.normal.add(e.normal.clone().sub(this.normal).multiplyScalar(t)),this.uv&&e.uv&&this.uv.add(e.uv.clone().sub(this.uv).multiplyScalar(t)),this}interpolate(e,t){return this.clone().lerp(e,t)}applyMatrix4(e){var t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i+s[12],this.y=s[1]*t+s[5]*r+s[9]*i+s[13],this.z=s[2]*t+s[6]*r+s[10]*i+s[14],this}}class Ji{constructor(e){ht(this,"polygons");ht(this,"front");ht(this,"back");ht(this,"divider");var t,r,i=[],s=[];if(this.polygons=[],this.front=this.back=void 0,!(!(e instanceof Array)||e.length===0)){for(this.divider=e[0].clone(),t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],this.polygons,this.polygons,i,s);i.length>0&&(this.front=new Ji(i)),s.length>0&&(this.back=new Ji(s))}}isConvex(e){var t,r;for(t=0;t<e.length;t++)for(r=0;r<e.length;r++)if(t!==r&&e[t].classifySide(e[r])!==Ea)return!1;return!0}build(e){var t,r,i=[],s=[];for(this.divider||(this.divider=e[0].clone()),t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],this.polygons,this.polygons,i,s);i.length>0&&(this.front||(this.front=new Ji),this.front.build(i)),s.length>0&&(this.back||(this.back=new Ji),this.back.build(s))}allPolygons(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e}clone(){var e=new Ji;return e.divider=this.divider?this.divider.clone():void 0,e.polygons=this.polygons.map(function(t){return t.clone()}),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone(),e}invert(){var e,t,r;for(e=0,t=this.polygons.length;e<t;e++)this.polygons[e].flip();return this.divider&&this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),r=this.front,this.front=this.back,this.back=r,this}clipPolygons(e){var t,r,i,s;if(!this.divider)return e.slice();for(i=[],s=[],t=0,r=e.length;t<r;t++)this.divider.splitPolygon(e[t],i,s,i,s);return this.front&&(i=this.front.clipPolygons(i)),this.back?s=this.back.clipPolygons(s):s=[],i.concat(s)}clipTo(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)}}window.ThreeBSP=lo;const Ma=Math.PI/2,W9=(n,e)=>n.x*e.x+n.y*e.y,s2=n=>{const e=Math.hypot(n.x,n.y);return{x:n.x/e,y:n.y/e}},o2=(n,e=16777215)=>n&&(typeof n=="string"||typeof n=="number")?n:e,a2=(n,e,t,r)=>{if(!e)return;const i=new tv;n.map=i.load(e.uri),n.needsUpdate=!0,n.map.wrapS=Zr,n.map.wrapT=Zr,n.map.repeat.set(t*(e.lengthRepeatScale??1),r*(e.heightRepeatScale??1)),e.normal&&n instanceof k4&&(n.normalMap=i.load(e.normal.uri),n.normalScale=new Ne(e.normal.normalScaleX,e.normal.normalScaleY),n.normalMap.wrapS=Zr,n.normalMap.wrapT=Zr,n.normalMap.repeat.set(t*(e.normal.lengthRepeatScale??1),r*(e.normal.heightRepeatScale??1)))},j9=(n,e,t)=>{for(const r of n.areas.valueSeq()){const i=r.vertices,s=i.size;for(let o=0;o<s;o++){const a=i.get(o),l=i.get((o+1)%s);if(a===e&&l===t||a===t&&l===e)return{area:r,edgeIndex:o}}}return null},X9=(n,e,t)=>{let r=!0;const i=s2({x:t.x-e.x,y:t.y-e.y}),s={x:-i.y,y:i.x},o=j9(n,e.id,t.id);if(o){const{area:a,edgeIndex:l}=o,c=a.vertices.get(l),h=a.vertices.get((l+1)%a.vertices.size),f=n.vertices.get(c),p=n.vertices.get(h),d=s2({x:p.x-f.x,y:p.y-f.y}),m={x:-d.y,y:d.x};r=W9(s,m)<0}return r};function $9(n,e,t,r){let i=!1,s=e.vertices.get(n.vertices.get(0)),o=e.vertices.get(n.vertices.get(1)),a=X9(e,s,o);if(s.x>o.x){const W=s;s=o,o=W,i=!0}const l=n.properties.getIn(["height","length"]),c=n.properties.getIn(["thickness","length"]),h=.2,f=1,p=mc(s,o),d=p/2,m=c/2,x=new Ks({color:n.selected?Lt.MESH_SELECTED:13882323});let v=new Tn(new Js(p,l,c),x);const _=Math.asin((o.y-s.y)/p),w=Math.sin(_),E=Math.cos(_);v.position.y+=l/2,v.position.x+=d*E,v.position.z-=d*w,v.rotation.y=_,n.holes.forEach(W=>{const Q=e.holes.get(W),ae=Q.properties.getIn(["width","length"]),J=Q.properties.getIn(["height","length"]),se=Q.properties.getIn(["altitude","length"]),ge=(i?1-Q.offset:Q.offset)*p,F=new Js(ae,J,c),X=new Tn(F);X.position.y+=J/2+se,X.position.x+=ge*E,X.position.z-=ge*w,X.rotation.y=_;const de=new lo(v),ye=new lo(X);v=de.subtract(ye).toMesh(x)}),v.name="soul";let S="A",b="B";if(a){const W=S;S=b,b=W}const A=new Ks({color:o2(n.properties.get(`color${b}`))}),q=new Ks({color:o2(n.properties.get(`color${S}`))});a2(A,r[n.properties.get(`texture${b}`)],p,l),a2(q,r[n.properties.get(`texture${S}`)],p,l);const O=h/c,T=m+f,I=v.clone();I.material=A,I.scale.set(1,1,O),I.position.x+=T*Math.cos(_-Ma),I.position.z-=T*Math.sin(_-Ma),I.name="frontFace";const N=v.clone();N.material=q,N.scale.set(1,1,O),N.position.x+=T*Math.cos(_+Ma),N.position.z-=T*Math.sin(_+Ma),N.name="backFace";const H=new aa;return H.add(v,I,N),Promise.resolve(H)}function Y9(n,e,t,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("soul"),f=i.getObjectByName("frontFace"),p=i.getObjectByName("backFace");if(o[0]=="selected")h.material=new Ks({color:n.selected?Lt.MESH_SELECTED:13882323});else if(o[0]=="properties")if(o[1]=="thickness"){let d=n.getIn(["properties","thickness","length"]),m=s.getIn(["properties","thickness","length"]),v=d/2+1,_=m/h.scale.z,w=h.rotation.y,E=v*Math.cos(w-Ma),S=v*Math.sin(w-Ma);h.scale.set(1,1,d/_),f.position.x=h.position.x+E,f.position.z=h.position.z+S,p.position.x=h.position.x-E,p.position.z=h.position.z-S}else return c();else return c();return Promise.resolve(i)}function K9(n,e,t){let r={name:n,prototype:"lines",info:e,properties:{height:{label:"height",type:"length-measure",defaultValue:{length:300}},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:10,_length:10,_unit:Rr}}},render2D:function(i,s,o,a){let{x:l,y:c}=s.vertices.get(i.vertices.get(0)),{x:h,y:f}=s.vertices.get(i.vertices.get(1)),p=Cn(l,c,h,f),d=i.getIn(["properties","thickness","length"]),m=d/2;return R.jsx("g",{children:R.jsx("rect",{x:"0",y:-m,width:p,height:d,style:{fill:i.selected&&![Ar,Jn].includes(a)?Lt.LINE_MESH_COLOR.selected:Lt.COLORS.black,stroke:"none"}})})},render3D:function(i,s,o){return $9(i,s,o,t)},updateRender3D:(i,s,o,a,l,c,h,f)=>Y9(i,s,o,t,a,l,c,h,f)};if(r.properties.colorA={label:"inside color",type:"color",defaultValue:Lt.COLORS.white},r.properties.colorB={label:"outside color",type:"color",defaultValue:Lt.COLORS.white},t&&Object.keys(t).length>0){const i={none:"None"};for(let s in t)i[s]=t[s].name;r.properties.textureA={label:"inside texture",type:"enum",defaultValue:i.painted?"painted":"none",values:i},r.properties.textureB={label:"outside texture",type:"enum",defaultValue:i.painted?"painted":"none",values:i}}return r}function Z9(n,e,t,r){const i=new aa;return i.name="surface",Promise.resolve(i)}function J9(n,e,t,r,i,s,o,a,l){return Promise.resolve(i)}const l2={strokeWidth:1,stroke:"transparent"},Q9={...l2,stroke:Lt.LINE_MESH_COLOR.selected};function eC(n,e,t){return{name:n,prototype:"lines",info:e,properties:{},render2D:function(i,s,o){let{x:a,y:l}=s.vertices.get(i.vertices.get(0)),{x:c,y:h}=s.vertices.get(i.vertices.get(1)),f=Cn(a,l,c,h);return i.selected?R.jsx("g",{children:R.jsx("rect",{x:"0",y:"0",width:f,height:0,style:Q9})}):R.jsx("rect",{x:"0",y:"0",width:f,height:0,style:l2})},render3D:function(i,s,o){return Z9()},updateRender3D:(i,s,o,a,l,c,h,f)=>J9(i,s,o,t,a)}}fn.AreaFactory=G9,fn.Catalog=r9,fn.ReactPlannerLoader=F9,fn.SurfaceFactory=eC,fn.WallFactory=K9,fn.convertUnits=Kr,fn.default=U9,Object.defineProperties(fn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));