!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).mapray=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof e&&e)||Function("return this")(),i=function(e){try{return!!e()}catch(e){return!0}},o=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=function(e){return"object"==typeof e?null!==e:"function"==typeof e},s=n.document,u=a(s)&&a(s.createElement),l=function(e){return u?s.createElement(e):{}},_=!o&&!i((function(){return 7!=Object.defineProperty(l("div"),"a",{get:function(){return 7}}).a})),c=function(e){if(!a(e))throw TypeError(String(e)+" is not an object");return e},h=function(e,t){if(!a(e))return e;var r,n;if(t&&"function"==typeof(r=e.toString)&&!a(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!a(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!a(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},f=Object.defineProperty,d={f:o?f:function(e,t,r){if(c(e),t=h(t,!0),c(r),_)try{return f(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(e[t]=r.value),e}},v=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},y=o?function(e,t,r){return d.f(e,t,v(1,r))}:function(e,t,r){return e[t]=r,e},p={}.hasOwnProperty,g=function(e,t){return p.call(e,t)},m=function(e,t){try{y(n,e,t)}catch(r){n[e]=t}return t},k=n["__core-js_shared__"]||m("__core-js_shared__",{}),w=Function.toString;"function"!=typeof k.inspectSource&&(k.inspectSource=function(e){return w.call(e)});var E,b,x,A=k.inspectSource,T=n.WeakMap,I="function"==typeof T&&/native code/.test(A(T)),P=t((function(e){(e.exports=function(e,t){return k[e]||(k[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.4",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),L=0,M=Math.random(),S=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++L+M).toString(36)},R=P("keys"),C=function(e){return R[e]||(R[e]=S(e))},D={},O=n.WeakMap;if(I){var F=new O,N=F.get,V=F.has,U=F.set;E=function(e,t){return U.call(F,e,t),t},b=function(e){return N.call(F,e)||{}},x=function(e){return V.call(F,e)}}else{var B=C("state");D[B]=!0,E=function(e,t){return y(e,B,t),t},b=function(e){return g(e,B)?e[B]:{}},x=function(e){return g(e,B)}}var z={set:E,get:b,has:x,enforce:function(e){return x(e)?b(e):E(e,{})},getterFor:function(e){return function(t){var r;if(!a(t)||(r=b(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}},G=t((function(e){var t=z.get,r=z.enforce,i=String(String).split("String");(e.exports=function(e,t,o,a){var s=!!a&&!!a.unsafe,u=!!a&&!!a.enumerable,l=!!a&&!!a.noTargetGet;"function"==typeof o&&("string"!=typeof t||g(o,"name")||y(o,"name",t),r(o).source=i.join("string"==typeof t?t:"")),e!==n?(s?!l&&e[t]&&(u=!0):delete e[t],u?e[t]=o:y(e,t,o)):u?e[t]=o:m(t,o)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||A(this)}))})),j=Date.prototype,q=j.toString,Y=j.getTime;new Date(NaN)+""!="Invalid Date"&&G(j,"toString",(function(){var e=Y.call(this);return e==e?q.call(this):"Invalid Date"}));var H={}.propertyIsEnumerable,X=Object.getOwnPropertyDescriptor,W={f:X&&!H.call({1:2},1)?function(e){var t=X(this,e);return!!t&&t.enumerable}:H},Q={}.toString,Z=function(e){return Q.call(e).slice(8,-1)},J="".split,K=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==Z(e)?J.call(e,""):Object(e)}:Object,$=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},ee=function(e){return K($(e))},te=Object.getOwnPropertyDescriptor,re={f:o?te:function(e,t){if(e=ee(e),t=h(t,!0),_)try{return te(e,t)}catch(e){}if(g(e,t))return v(!W.f.call(e,t),e[t])}},ne=n,ie=function(e){return"function"==typeof e?e:void 0},oe=function(e,t){return arguments.length<2?ie(ne[e])||ie(n[e]):ne[e]&&ne[e][t]||n[e]&&n[e][t]},ae=Math.ceil,se=Math.floor,ue=function(e){return isNaN(e=+e)?0:(e>0?se:ae)(e)},le=Math.min,_e=function(e){return e>0?le(ue(e),9007199254740991):0},ce=Math.max,he=Math.min,fe=function(e,t){var r=ue(e);return r<0?ce(r+t,0):he(r,t)},de=function(e){return function(t,r,n){var i,o=ee(t),a=_e(o.length),s=fe(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},ve={includes:de(!0),indexOf:de(!1)},ye=ve.indexOf,pe=function(e,t){var r,n=ee(e),i=0,o=[];for(r in n)!g(D,r)&&g(n,r)&&o.push(r);for(;t.length>i;)g(n,r=t[i++])&&(~ye(o,r)||o.push(r));return o},ge=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],me=ge.concat("length","prototype"),ke={f:Object.getOwnPropertyNames||function(e){return pe(e,me)}},we={f:Object.getOwnPropertySymbols},Ee=oe("Reflect","ownKeys")||function(e){var t=ke.f(c(e)),r=we.f;return r?t.concat(r(e)):t},be=function(e,t){for(var r=Ee(t),n=d.f,i=re.f,o=0;o<r.length;o++){var a=r[o];g(e,a)||n(e,a,i(t,a))}},xe=/#|\.prototype\./,Ae=function(e,t){var r=Ie[Te(e)];return r==Le||r!=Pe&&("function"==typeof t?i(t):!!t)},Te=Ae.normalize=function(e){return String(e).replace(xe,".").toLowerCase()},Ie=Ae.data={},Pe=Ae.NATIVE="N",Le=Ae.POLYFILL="P",Me=Ae,Se=re.f,Re=function(e,t){var r,i,o,a,s,u=e.target,l=e.global,_=e.stat;if(r=l?n:_?n[u]||m(u,{}):(n[u]||{}).prototype)for(i in t){if(a=t[i],o=e.noTargetGet?(s=Se(r,i))&&s.value:r[i],!Me(l?i:u+(_?".":"#")+i,e.forced)&&void 0!==o){if(typeof a==typeof o)continue;be(a,o)}(e.sham||o&&o.sham)&&y(a,"sham",!0),G(r,i,a,e)}},Ce=Math.log,De=Math.LN2;Re({target:"Math",stat:!0},{log2:function(e){return Ce(e)/De}});var Oe=d.f,Fe=Function.prototype,Ne=Fe.toString,Ve=/^\s*function ([^ (]*)/;function Ue(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Be(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ue(o,n,i,a,s,"next",e)}function s(e){Ue(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ze(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ge(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function je(e,t,r){return t&&Ge(e.prototype,t),r&&Ge(e,r),e}function qe(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&He(e,t)}function Ye(e){return(Ye=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function He(e,t){return(He=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Xe(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function We(e,t,r){return(We=Xe()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&He(i,r.prototype),i}).apply(null,arguments)}function Qe(e){var t="function"==typeof Map?new Map:void 0;return(Qe=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return We(e,arguments,Ye(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),He(n,e)})(e)}function Ze(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Je(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?Ze(e):t}function Ke(e,t,r){return(Ke="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ye(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function $e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function et(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}!o||"name"in Fe||Oe(Fe,"name",{configurable:!0,get:function(){try{return Ne.call(this).match(Ve)[1]}catch(e){return""}}});var tt,rt=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e))).name="mapray.animation.AnimationError",r}return qe(t,e),t}(Qe(Error)),nt=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return c(r),function(e){if(!a(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(n),t?e.call(r,n):r.__proto__=n,r}}():void 0),it=function(e,t,r){var n,i;return nt&&"function"==typeof(n=t.constructor)&&n!==r&&a(i=n.prototype)&&i!==r.prototype&&nt(e,i),e},ot=Object.keys||function(e){return pe(e,ge)},at=o?Object.defineProperties:function(e,t){c(e);for(var r,n=ot(t),i=n.length,o=0;i>o;)d.f(e,r=n[o++],t[r]);return e},st=oe("document","documentElement"),ut=C("IE_PROTO"),lt=function(){},_t=function(e){return"<script>"+e+"<\/script>"},ct=function(){try{tt=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;ct=tt?function(e){e.write(_t("")),e.close();var t=e.parentWindow.Object;return e=null,t}(tt):((t=l("iframe")).style.display="none",st.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(_t("document.F=Object")),e.close(),e.F);for(var r=ge.length;r--;)delete ct.prototype[ge[r]];return ct()};D[ut]=!0;var ht=Object.create||function(e,t){var r;return null!==e?(lt.prototype=c(e),r=new lt,lt.prototype=null,r[ut]=e):r=ct(),void 0===t?r:at(r,t)},ft="\t\n\v\f\r                　\u2028\u2029\ufeff",dt="["+ft+"]",vt=RegExp("^"+dt+dt+"*"),yt=RegExp(dt+dt+"*$"),pt=function(e){return function(t){var r=String($(t));return 1&e&&(r=r.replace(vt,"")),2&e&&(r=r.replace(yt,"")),r}},gt={start:pt(1),end:pt(2),trim:pt(3)},mt=ke.f,kt=re.f,wt=d.f,Et=gt.trim,bt=n.Number,xt=bt.prototype,At="Number"==Z(ht(xt)),Tt=function(e){var t,r,n,i,o,a,s,u,l=h(e,!1);if("string"==typeof l&&l.length>2)if(43===(t=(l=Et(l)).charCodeAt(0))||45===t){if(88===(r=l.charCodeAt(2))||120===r)return NaN}else if(48===t){switch(l.charCodeAt(1)){case 66:case 98:n=2,i=49;break;case 79:case 111:n=8,i=55;break;default:return+l}for(a=(o=l.slice(2)).length,s=0;s<a;s++)if((u=o.charCodeAt(s))<48||u>i)return NaN;return parseInt(o,n)}return+l};if(Me("Number",!bt(" 0o1")||!bt("0b1")||bt("+0x1"))){for(var It,Pt=function(e){var t=arguments.length<1?0:e,r=this;return r instanceof Pt&&(At?i((function(){xt.valueOf.call(r)})):"Number"!=Z(r))?it(new bt(Tt(t)),r,Pt):Tt(t)},Lt=o?mt(bt):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),Mt=0;Lt.length>Mt;Mt++)g(bt,It=Lt[Mt])&&!g(Pt,It)&&wt(Pt,It,kt(bt,It));Pt.prototype=xt,xt.constructor=Pt,G(n,"Number",Pt)}var St=function(){function e(t){ze(this,e),this._ntime=t}return je(e,[{key:"toNumber",value:function(){return this._ntime}},{key:"equals",value:function(e){return this._ntime==e._ntime}},{key:"lessThan",value:function(e){return this._ntime<e._ntime}},{key:"lessEqual",value:function(e){return this._ntime<=e._ntime}}],[{key:"fromNumber",value:function(t){return new e(t)}},{key:"MIN_TIME",get:function(){return Dt}},{key:"MAX_TIME",get:function(){return Ot}},{key:"MIN_NTIME",get:function(){return Rt}},{key:"MAX_NTIME",get:function(){return Ct}}]),e}(),Rt=-Number.MAX_VALUE,Ct=+Number.MAX_VALUE,Dt=St.fromNumber(Rt),Ot=St.fromNumber(Ct),Ft=function(){function e(t,r,n,i){ze(this,e),this._lower=t,this._upper=r,this._l_open=void 0!==n&&n,this._u_open=void 0!==i&&i}return je(e,[{key:"isEmpty",value:function(){var e=this._lower,t=this._upper;return t.lessThan(e)||t.equals(e)&&(this._l_open||this._u_open)}},{key:"isSingle",value:function(){return this._lower.equals(this._upper)&&!(this._l_open||this._u_open)}},{key:"isProper",value:function(){return this._lower.lessThan(this._upper)}},{key:"precedes",value:function(e){if(this.isEmpty()||e.isEmpty())return!0;var t=this._upper,r=this._u_open,n=e._lower,i=e._l_open;return t.lessThan(n)||t.equals(n)&&(r||i)}},{key:"includes",value:function(e){if(e.isEmpty())return!0;var t=this._lower,r=e._lower,n=this._l_open,i=e._l_open,o=t.lessThan(r)||t.equals(r)&&(!n||i),a=this._upper,s=e._upper,u=this._u_open,l=e._u_open,_=s.lessThan(a)||s.equals(a)&&(l||!u);return o&&_}},{key:"includesTime",value:function(e){var t=this._lower,r=t.lessThan(e)||t.equals(e)&&!this._l_open,n=this._upper,i=e.lessThan(n)||e.equals(n)&&!this._u_open;return r&&i}},{key:"hasIntersection",value:function(e){return!this.getIntersection(e).isEmpty()}},{key:"getPrecedings",value:function(){return this.isEmpty()?Nt:new e(St.MIN_TIME,this._lower,!1,!this._l_open)}},{key:"getFollowings",value:function(){return this.isEmpty()?Nt:new e(this._upper,St.MAX_TIME,!this._u_open,!1)}},{key:"getIntersection",value:function(e){return this._getIntersectionByLower(e._lower,e._l_open)._getIntersectionByUpper(e._upper,e._u_open)}},{key:"getUnion",value:function(t){if(this.isEmpty())return t.isEmpty()?[]:[t];if(t.isEmpty())return[this];var r=this._lower,n=this._upper,i=this._l_open,o=this._u_open,a=t._lower,s=t._upper,u=t._l_open,l=t._u_open;if(n.lessThan(a)||n.equals(a)&&o&&u)return[this,t];if(s.lessThan(r)||r.equals(s)&&i&&l)return[t,this];var _=$e(r.lessThan(a)||r.equals(a)&&u?[r,i]:[a,u],2),c=_[0],h=_[1],f=$e(s.lessThan(n)||s.equals(n)&&l?[n,o]:[s,l],2);return[new e(c,f[0],h,f[1])]}},{key:"getDifference",value:function(e){var t=this._getIntersectionByUpper(e._lower,!e._l_open),r=this._getIntersectionByLower(e._upper,!e._u_open);return t.getUnion(r)}},{key:"getComplement",value:function(){return Nt.getDifference(this)}},{key:"_getIntersectionByLower",value:function(t,r){return t.lessThan(this._lower)||t.equals(this._lower)&&this._l_open?this:new e(t,this._upper,r,this._u_open)}},{key:"_getIntersectionByUpper",value:function(t,r){return this._upper.lessThan(t)||this._upper.equals(t)&&this._u_open?this:new e(this._lower,t,this._l_open,r)}},{key:"lower",get:function(){return this._lower}},{key:"upper",get:function(){return this._upper}},{key:"l_open",get:function(){return this._l_open}},{key:"u_open",get:function(){return this._u_open}}],[{key:"UNIVERSAL",get:function(){return Nt}}]),e}(),Nt=new Ft(St.MIN_TIME,St.MAX_TIME),Vt=!!Object.getOwnPropertySymbols&&!i((function(){return!String(Symbol())})),Ut=Vt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Bt=Array.isArray||function(e){return"Array"==Z(e)},zt=function(e){return Object($(e))},Gt=ke.f,jt={}.toString,qt="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Yt={f:function(e){return qt&&"[object Window]"==jt.call(e)?function(e){try{return Gt(e)}catch(e){return qt.slice()}}(e):Gt(ee(e))}},Ht=P("wks"),Xt=n.Symbol,Wt=Ut?Xt:Xt&&Xt.withoutSetter||S,Qt=function(e){return g(Ht,e)||(Vt&&g(Xt,e)?Ht[e]=Xt[e]:Ht[e]=Wt("Symbol."+e)),Ht[e]},Zt={f:Qt},Jt=d.f,Kt=function(e){var t=ne.Symbol||(ne.Symbol={});g(t,e)||Jt(t,e,{value:Zt.f(e)})},$t=d.f,er=Qt("toStringTag"),tr=function(e,t,r){e&&!g(e=r?e:e.prototype,er)&&$t(e,er,{configurable:!0,value:t})},rr=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},nr=function(e,t,r){if(rr(e),void 0===t)return e;switch(r){case 0:return function(){return e.call(t)};case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}},ir=Qt("species"),or=function(e,t){var r;return Bt(e)&&("function"!=typeof(r=e.constructor)||r!==Array&&!Bt(r.prototype)?a(r)&&null===(r=r[ir])&&(r=void 0):r=void 0),new(void 0===r?Array:r)(0===t?0:t)},ar=[].push,sr=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=5==e||o;return function(s,u,l,_){for(var c,h,f=zt(s),d=K(f),v=nr(u,l,3),y=_e(d.length),p=0,g=_||or,m=t?g(s,y):r?g(s,0):void 0;y>p;p++)if((a||p in d)&&(h=v(c=d[p],p,f),e))if(t)m[p]=h;else if(h)switch(e){case 3:return!0;case 5:return c;case 6:return p;case 2:ar.call(m,c)}else if(i)return!1;return o?-1:n||i?i:m}},ur={forEach:sr(0),map:sr(1),filter:sr(2),some:sr(3),every:sr(4),find:sr(5),findIndex:sr(6)},lr=ur.forEach,_r=C("hidden"),cr=Qt("toPrimitive"),hr=z.set,fr=z.getterFor("Symbol"),dr=Object.prototype,vr=n.Symbol,yr=oe("JSON","stringify"),pr=re.f,gr=d.f,mr=Yt.f,kr=W.f,wr=P("symbols"),Er=P("op-symbols"),br=P("string-to-symbol-registry"),xr=P("symbol-to-string-registry"),Ar=P("wks"),Tr=n.QObject,Ir=!Tr||!Tr.prototype||!Tr.prototype.findChild,Pr=o&&i((function(){return 7!=ht(gr({},"a",{get:function(){return gr(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=pr(dr,t);n&&delete dr[t],gr(e,t,r),n&&e!==dr&&gr(dr,t,n)}:gr,Lr=function(e,t){var r=wr[e]=ht(vr.prototype);return hr(r,{type:"Symbol",tag:e,description:t}),o||(r.description=t),r},Mr=Ut?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof vr},Sr=function(e,t,r){e===dr&&Sr(Er,t,r),c(e);var n=h(t,!0);return c(r),g(wr,n)?(r.enumerable?(g(e,_r)&&e[_r][n]&&(e[_r][n]=!1),r=ht(r,{enumerable:v(0,!1)})):(g(e,_r)||gr(e,_r,v(1,{})),e[_r][n]=!0),Pr(e,n,r)):gr(e,n,r)},Rr=function(e,t){c(e);var r=ee(t),n=ot(r).concat(Fr(r));return lr(n,(function(t){o&&!Cr.call(r,t)||Sr(e,t,r[t])})),e},Cr=function(e){var t=h(e,!0),r=kr.call(this,t);return!(this===dr&&g(wr,t)&&!g(Er,t))&&(!(r||!g(this,t)||!g(wr,t)||g(this,_r)&&this[_r][t])||r)},Dr=function(e,t){var r=ee(e),n=h(t,!0);if(r!==dr||!g(wr,n)||g(Er,n)){var i=pr(r,n);return!i||!g(wr,n)||g(r,_r)&&r[_r][n]||(i.enumerable=!0),i}},Or=function(e){var t=mr(ee(e)),r=[];return lr(t,(function(e){g(wr,e)||g(D,e)||r.push(e)})),r},Fr=function(e){var t=e===dr,r=mr(t?Er:ee(e)),n=[];return lr(r,(function(e){!g(wr,e)||t&&!g(dr,e)||n.push(wr[e])})),n};if(Vt||(G((vr=function(){if(this instanceof vr)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=S(e),r=function(e){this===dr&&r.call(Er,e),g(this,_r)&&g(this[_r],t)&&(this[_r][t]=!1),Pr(this,t,v(1,e))};return o&&Ir&&Pr(dr,t,{configurable:!0,set:r}),Lr(t,e)}).prototype,"toString",(function(){return fr(this).tag})),G(vr,"withoutSetter",(function(e){return Lr(S(e),e)})),W.f=Cr,d.f=Sr,re.f=Dr,ke.f=Yt.f=Or,we.f=Fr,Zt.f=function(e){return Lr(Qt(e),e)},o&&(gr(vr.prototype,"description",{configurable:!0,get:function(){return fr(this).description}}),G(dr,"propertyIsEnumerable",Cr,{unsafe:!0}))),Re({global:!0,wrap:!0,forced:!Vt,sham:!Vt},{Symbol:vr}),lr(ot(Ar),(function(e){Kt(e)})),Re({target:"Symbol",stat:!0,forced:!Vt},{for:function(e){var t=String(e);if(g(br,t))return br[t];var r=vr(t);return br[t]=r,xr[r]=t,r},keyFor:function(e){if(!Mr(e))throw TypeError(e+" is not a symbol");if(g(xr,e))return xr[e]},useSetter:function(){Ir=!0},useSimple:function(){Ir=!1}}),Re({target:"Object",stat:!0,forced:!Vt,sham:!o},{create:function(e,t){return void 0===t?ht(e):Rr(ht(e),t)},defineProperty:Sr,defineProperties:Rr,getOwnPropertyDescriptor:Dr}),Re({target:"Object",stat:!0,forced:!Vt},{getOwnPropertyNames:Or,getOwnPropertySymbols:Fr}),Re({target:"Object",stat:!0,forced:i((function(){we.f(1)}))},{getOwnPropertySymbols:function(e){return we.f(zt(e))}}),yr){var Nr=!Vt||i((function(){var e=vr();return"[null]"!=yr([e])||"{}"!=yr({a:e})||"{}"!=yr(Object(e))}));Re({target:"JSON",stat:!0,forced:Nr},{stringify:function(e,t,r){for(var n,i=[e],o=1;arguments.length>o;)i.push(arguments[o++]);if(n=t,(a(t)||void 0!==e)&&!Mr(e))return Bt(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!Mr(t))return t}),i[1]=t,yr.apply(null,i)}})}vr.prototype[cr]||y(vr.prototype,cr,vr.prototype.valueOf),tr(vr,"Symbol"),D[_r]=!0;var Vr=d.f,Ur=n.Symbol;if(o&&"function"==typeof Ur&&(!("description"in Ur.prototype)||void 0!==Ur().description)){var Br={},zr=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof zr?new Ur(e):void 0===e?Ur():Ur(e);return""===e&&(Br[t]=!0),t};be(zr,Ur);var Gr=zr.prototype=Ur.prototype;Gr.constructor=zr;var jr=Gr.toString,qr="Symbol(test)"==String(Ur("test")),Yr=/^Symbol\((.*)\)[^)]+$/;Vr(Gr,"description",{configurable:!0,get:function(){var e=a(this)?this.valueOf():this,t=jr.call(e);if(g(Br,e))return"";var r=qr?t.slice(7,-1):t.replace(Yr,"$1");return""===r?void 0:r}}),Re({global:!0,forced:!0},{Symbol:zr})}Kt("iterator");var Hr=Qt("unscopables"),Xr=Array.prototype;null==Xr[Hr]&&d.f(Xr,Hr,{configurable:!0,value:ht(null)});var Wr=function(e){Xr[Hr][e]=!0},Qr=Object.defineProperty,Zr={},Jr=function(e){throw e},Kr=function(e,t){if(g(Zr,e))return Zr[e];t||(t={});var r=[][e],n=!!g(t,"ACCESSORS")&&t.ACCESSORS,a=g(t,0)?t[0]:Jr,s=g(t,1)?t[1]:void 0;return Zr[e]=!!r&&!i((function(){if(n&&!o)return!0;var e={length:-1};n?Qr(e,1,{enumerable:!0,get:Jr}):e[1]=1,r.call(e,a,s)}))},$r=ve.includes,en=Kr("indexOf",{ACCESSORS:!0,1:0});Re({target:"Array",proto:!0,forced:!en},{includes:function(e){return $r(this,e,arguments.length>1?arguments[1]:void 0)}}),Wr("includes");var tn,rn,nn,on={},an=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),sn=C("IE_PROTO"),un=Object.prototype,ln=an?Object.getPrototypeOf:function(e){return e=zt(e),g(e,sn)?e[sn]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?un:null},_n=Qt("iterator"),cn=!1;[].keys&&("next"in(nn=[].keys())?(rn=ln(ln(nn)))!==Object.prototype&&(tn=rn):cn=!0),null==tn&&(tn={}),g(tn,_n)||y(tn,_n,(function(){return this}));var hn={IteratorPrototype:tn,BUGGY_SAFARI_ITERATORS:cn},fn=hn.IteratorPrototype,dn=function(){return this},vn=function(e,t,r){var n=t+" Iterator";return e.prototype=ht(fn,{next:v(1,r)}),tr(e,n,!1),on[n]=dn,e},yn=hn.IteratorPrototype,pn=hn.BUGGY_SAFARI_ITERATORS,gn=Qt("iterator"),mn=function(){return this},kn=function(e,t,r,n,i,o,a){vn(r,t,n);var s,u,l,_=function(e){if(e===i&&v)return v;if(!pn&&e in f)return f[e];switch(e){case"keys":case"values":case"entries":return function(){return new r(this,e)}}return function(){return new r(this)}},c=t+" Iterator",h=!1,f=e.prototype,d=f[gn]||f["@@iterator"]||i&&f[i],v=!pn&&d||_(i),p="Array"==t&&f.entries||d;if(p&&(s=ln(p.call(new e)),yn!==Object.prototype&&s.next&&(ln(s)!==yn&&(nt?nt(s,yn):"function"!=typeof s[gn]&&y(s,gn,mn)),tr(s,c,!0))),"values"==i&&d&&"values"!==d.name&&(h=!0,v=function(){return d.call(this)}),f[gn]!==v&&y(f,gn,v),on[t]=v,i)if(u={values:_("values"),keys:o?v:_("keys"),entries:_("entries")},a)for(l in u)!pn&&!h&&l in f||G(f,l,u[l]);else Re({target:t,proto:!0,forced:pn||h},u);return u},wn=z.set,En=z.getterFor("Array Iterator"),bn=kn(Array,"Array",(function(e,t){wn(this,{type:"Array Iterator",target:ee(e),index:0,kind:t})}),(function(){var e=En(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==r?{value:n,done:!1}:"values"==r?{value:t[n],done:!1}:{value:[n,t[n]],done:!1}}),"values");on.Arguments=on.Array,Wr("keys"),Wr("values"),Wr("entries");var xn={};xn[Qt("toStringTag")]="z";var An="[object z]"===String(xn),Tn=Qt("toStringTag"),In="Arguments"==Z(function(){return arguments}()),Pn=An?Z:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Tn))?r:In?Z(t):"Object"==(n=Z(t))&&"function"==typeof t.callee?"Arguments":n},Ln=An?{}.toString:function(){return"[object "+Pn(this)+"]"};An||G(Object.prototype,"toString",Ln,{unsafe:!0});var Mn=Qt("match"),Sn=function(e){var t;return a(e)&&(void 0!==(t=e[Mn])?!!t:"RegExp"==Z(e))},Rn=function(e){if(Sn(e))throw TypeError("The method doesn't accept regular expressions");return e},Cn=Qt("match"),Dn=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Cn]=!1,"/./"[e](t)}catch(e){}}return!1};Re({target:"String",proto:!0,forced:!Dn("includes")},{includes:function(e){return!!~String($(this)).indexOf(Rn(e),arguments.length>1?arguments[1]:void 0)}});var On=function(e){return function(t,r){var n,i,o=String($(t)),a=ue(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=o.charCodeAt(a))<55296||n>56319||a+1===s||(i=o.charCodeAt(a+1))<56320||i>57343?e?o.charAt(a):n:e?o.slice(a,a+2):i-56320+(n-55296<<10)+65536}},Fn={codeAt:On(!1),charAt:On(!0)},Nn=Fn.charAt,Vn=z.set,Un=z.getterFor("String Iterator");kn(String,"String",(function(e){Vn(this,{type:"String Iterator",string:String(e),index:0})}),(function(){var e,t=Un(this),r=t.string,n=t.index;return n>=r.length?{value:void 0,done:!0}:(e=Nn(r,n),t.index+=e.length,{value:e,done:!1})}));var Bn,zn={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Gn=Qt("iterator"),jn=Qt("toStringTag"),qn=bn.values;for(var Yn in zn){var Hn=n[Yn],Xn=Hn&&Hn.prototype;if(Xn){if(Xn[Gn]!==qn)try{y(Xn,Gn,qn)}catch(e){Xn[Gn]=qn}if(Xn[jn]||y(Xn,jn,Yn),zn[Yn])for(var Wn in bn)if(Xn[Wn]!==bn[Wn])try{y(Xn,Wn,bn[Wn])}catch(e){Xn[Wn]=bn[Wn]}}}var Qn=function(){function e(t){ze(this,e),this._compare=t,this._root=Bn,this._size=0}return je(e,[{key:"clone",value:function(){var t=new e(this._compare);return this._root!==Bn&&(t._root=this._root._clone(Bn)),t._size=this._size,t}},{key:"isEmpty",value:function(){return this._root===Bn}},{key:"findFirst",value:function(){return this._root!==Bn?this._root._findMinimum():null}},{key:"findLast",value:function(){return this._root!==Bn?this._root._findMaximum():null}},{key:"findLower",value:function(e){return this._root._findLowerBound(e,this._compare)}},{key:"findUpper",value:function(e){return this._root._findUpperBound(e,this._compare)}},{key:"findEqual",value:function(e){return this._root._findEqual(e,this._compare)}},{key:"clear",value:function(){this._root=Bn,this._size=0}},{key:"insert",value:function(e,t){for(var r=this._root,n=Bn,i=this._compare;r!==Bn;)if(n=r,i(e,r.key))r=r._child_L;else{if(!i(r.key,e))return r._value=t,r;r=r._child_R}var o=new Zn(n,e,t);return o._is_red=!0,n===Bn?this._root=o:i(e,n.key)?n._child_L=o:n._child_R=o,++this._size,this._insert_fixup(o),o}},{key:"_insert_fixup",value:function(e){for(var t=e;t._parent._is_red;)if(t._parent===t._parent._parent._child_L){var r=t._parent._parent._child_R;r._is_red?(t._parent._is_red=!1,r._is_red=!1,t._parent._parent._is_red=!0,t=t._parent._parent):(t===t._parent._child_R&&(t=t._parent,this._rotate_L(t)),t._parent._is_red=!1,t._parent._parent._is_red=!0,this._rotate_R(t._parent._parent))}else{var n=t._parent._parent._child_L;n._is_red?(t._parent._is_red=!1,n._is_red=!1,t._parent._parent._is_red=!0,t=t._parent._parent):(t===t._parent._child_L&&(t=t._parent,this._rotate_R(t)),t._parent._is_red=!1,t._parent._parent._is_red=!0,this._rotate_L(t._parent._parent))}this._root._is_red=!1}},{key:"remove",value:function(e,t){if(void 0===t)return this._remove(e);for(var r=e;r!=t;)r=this._remove(r);return t}},{key:"_remove",value:function(e){var t,r,n=e.findSuccessor();return e._child_L===Bn?(t=e._is_red,r=e._child_R,this._replace(e._child_R,e)):e._child_R===Bn?(t=e._is_red,r=e._child_L,this._replace(e._child_L,e)):(t=n._is_red,r=n._child_R,n._parent===e?r._parent=n:(this._replace(n._child_R,n),n._child_R=e._child_R,n._child_R._parent=n),this._replace(n,e),n._child_L=e._child_L,n._child_L._parent=n,n._is_red=e._is_red),--this._size,t||this._remove_fixup(r),n}},{key:"_remove_fixup",value:function(e){for(var t=e;t!==this._root&&!t._is_red;)if(t===t._parent._child_L){var r=t._parent._child_R;r._is_red&&(r._is_red=!1,t._parent._is_red=!0,this._rotate_L(t._parent),r=t._parent._child_R),r._child_L._is_red||r._child_R._is_red?(r._child_R._is_red||(r._child_L._is_red=!1,r._is_red=!0,this._rotate_R(r),r=t._parent._child_R),r._is_red=t._parent._is_red,t._parent._is_red=!1,r._child_R._is_red=!1,this._rotate_L(t._parent),t=this._root):(r._is_red=!0,t=t._parent)}else{var n=t._parent._child_L;n._is_red&&(n._is_red=!1,t._parent._is_red=!0,this._rotate_R(t._parent),n=t._parent._child_L),n._child_R._is_red||n._child_L._is_red?(n._child_L._is_red||(n._child_R._is_red=!1,n._is_red=!0,this._rotate_L(n),n=t._parent._child_L),n._is_red=t._parent._is_red,t._parent._is_red=!1,n._child_L._is_red=!1,this._rotate_R(t._parent),t=this._root):(n._is_red=!0,t=t._parent)}t._is_red=!1}},{key:"_replace",value:function(e,t){var r=t._parent;r!==Bn?r._child_L===t?r._child_L=e:r._child_R=e:this._root=e,e._parent=r}},{key:"_rotate_L",value:function(e){var t=e._child_R;e._child_R=t._child_L,t._child_L!==Bn&&(t._child_L._parent=e),t._parent=e._parent,e._parent===Bn?this._root=t:e===e._parent._child_L?e._parent._child_L=t:e._parent._child_R=t,t._child_L=e,e._parent=t}},{key:"_rotate_R",value:function(e){var t=e._child_L;e._child_L=t._child_R,t._child_R!==Bn&&(t._child_R._parent=e),t._parent=e._parent,e._parent===Bn?this._root=t:e===e._parent._child_R?e._parent._child_R=t:e._parent._child_L=t,t._child_R=e,e._parent=t}},{key:"size",get:function(){return this._size}}]),e}(),Zn=function(){function e(t,r,n){ze(this,e),this._parent=t,this._child_L=Bn,this._child_R=Bn,this._is_red=!1,this._key=r,this._value=n}return je(e,[{key:"_clone",value:function(t){var r=new e(t,this._key,this._value);return this._child_L!==Bn&&(r._child_L=this._child_L._clone(r)),this._child_R!==Bn&&(r._child_R=this._child_R._clone(r)),r._is_red=this._is_red,r}},{key:"_findMinimum",value:function(){for(var e=this;e._child_L!==Bn;)e=e._child_L;return e}},{key:"_findMaximum",value:function(){for(var e=this;e._child_R!==Bn;)e=e._child_R;return e}},{key:"findPredecessor",value:function(){if(this._child_L!==Bn)return this._child_L._findMaximum();for(var e=this,t=e._parent;t!==Bn&&e===t._child_L;)t=(e=t)._parent;return t!==Bn?t:null}},{key:"findSuccessor",value:function(){if(this._child_R!==Bn)return this._child_R._findMinimum();for(var e=this,t=e._parent;t!==Bn&&e===t._child_R;)t=(e=t)._parent;return t!==Bn?t:null}},{key:"_findLowerBound",value:function(e,t){for(var r=this;r!==Bn;){if(t(e,r._key)){if(r._child_L!==Bn){var n=r._child_L._findLowerBound(e,t);if(null!==n)return n}return r}if(!t(r._key,e))return r;r=r._child_R}return null}},{key:"_findUpperBound",value:function(e,t){for(var r=this;r!==Bn;){if(t(e,r._key)){if(r._child_L!==Bn){var n=r._child_L._findUpperBound(e,t);if(null!==n)return n}return r}r=r._child_R}return null}},{key:"_findEqual",value:function(e,t){for(var r=this;r!==Bn;)if(t(e,r._key))r=r._child_L;else{if(!t(r._key,e))return r;r=r._child_R}return null}},{key:"_findLowerBoundR",value:function(e,t){var r=this;if(r._parent!==Bn)return r._findLowerBound(e,t);var n=r._findMinimum(),i=r._findMaximum();do{if(!t(e,n._key)&&!t(i._key,e))break;r._parent._child_L===r?i=r._findMaximum():n=r._findMinimum(),r=r._parent}while(r._parent!==Bn);return r._findLowerBound(e,t)}},{key:"key",get:function(){return this._key}},{key:"value",get:function(){return this._value}}]),e}();Bn=new Zn;var Jn=function(){function e(){ze(this,e),this._imap=$n()}return je(e,[{key:"clone",value:function(){var t=new e;return t._imap=this._imap.clone(),t}},{key:"write",value:function(e){return this.remove(e),this._insert(e),this}},{key:"remove",value:function(e){if(e.isEmpty())return this;var t=e.l_open?this._imap.findUpper(e.lower):this._imap.findLower(e.lower),r=null!==t?t.findPredecessor():this._imap.findLast();if(this._chopItem(r,e),null!==t&&e.includes(t.value)){var n=e.u_open?this._imap.findLower(e.upper):this._imap.findUpper(e.upper),i=null!==n?n.findPredecessor():this._imap.findLast(),o=e.includes(i.value)?n:i;this._imap.remove(t,o),this._chopItem(o,e)}else this._chopItem(t,e);return this}},{key:"getNarrowed",value:function(t){var r=new e;if(t.isEmpty())return r;for(var n=this._imap.findUpper(t.lower),i=null!==n?n.findPredecessor():this._imap.findLast(),o=null!==i&&i.value.hasIntersection(t)?i:n,a=t.u_open?this._imap.findLower(t.upper):this._imap.findUpper(t.upper),s=o;s!==a;s=s.findSuccessor())r._imap.insert(s.key,s.value);return r}},{key:"_$getArray",value:function(){for(var e=[],t=this._imap.findFirst();null!==t;t=t.findSuccessor())e.push(t.value);return e}},{key:"_$modify",value:function(e){var t=e._imap.findFirst();if(null!==t){var r=e._imap.findLast(),n=t.value,i=r.value;this.remove(new Ft(n.lower,i.upper,n.l_open,i.u_open));for(var o=t;null!==o;o=o.findSuccessor())this._insert(o.value)}}},{key:"_$expandIntervalByAlignment",value:function(e){var t,r,n=this._imap,i=n.findLower(e.lower);if(null===i||!i.value.lower.equals(e.lower)||!e.l_open&&i.value.l_open){var o=null!==i?i.findPredecessor():n.findLast();t=null!==o?o.value.hasIntersection(e)?e:o.value.getFollowings():Ft.UNIVERSAL}else t=e;var a=n.findLower(e.upper);if(null===a||!e.upper.equals(a.value.lower)||e.u_open&&a.value.l_open){var s=null!==a?a.findPredecessor():n.findLast();r=null!==s&&s.value.hasIntersection(e)&&(e.upper.lessThan(s.value.upper)||e.upper.equals(s.value.upper)&&(e.u_open||!s.value.u_open))?e:null!==a?a.value.getPrecedings():Ft.UNIVERSAL}else r=e;return new Ft(t.lower,r.upper,t.l_open,r.u_open)}},{key:"_chopItem",value:function(e,t){if(null!==e){var r=e.value.getDifference(t);this._imap.remove(e);var n=!0,i=!1,o=void 0;try{for(var a,s=r[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;u.isProper()&&this._imap.insert(u.lower,u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}}}},{key:"_insert",value:function(e){e.isProper()&&this._imap.insert(e.lower,e)}},{key:"_merge_from_invariance",value:function(e){for(var t=$n(),r=this._imap.findFirst();null!==r;r=r.findSuccessor())Kn(r.value,e,t);this._imap=t}}],[{key:"merge",value:function(t){var r=new e;r.write(Ft.UNIVERSAL);var n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;r._merge_from_invariance(u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}}]),e}();function Kn(e,t,r){var n=t._imap,i=n.findLower(e.lower),o=null!==i?i.findPredecessor():null;null===o&&(o=n.findFirst());for(var a=n.findUpper(e.upper),s=o;s!==a;s=s.findSuccessor()){var u=s.value,l=e.getIntersection(u);l.isProper()&&r.insert(l.lower,l)}}function $n(){return new Qn((function(e,t){return e.lessThan(t)}))}var ei=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),ti=t((function(e){var t=d.f,r=S("meta"),n=0,i=Object.isExtensible||function(){return!0},o=function(e){t(e,r,{value:{objectID:"O"+ ++n,weakData:{}}})},s=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!g(e,r)){if(!i(e))return"F";if(!t)return"E";o(e)}return e[r].objectID},getWeakData:function(e,t){if(!g(e,r)){if(!i(e))return!0;if(!t)return!1;o(e)}return e[r].weakData},onFreeze:function(e){return ei&&s.REQUIRED&&i(e)&&!g(e,r)&&o(e),e}};D[r]=!0})),ri=(ti.REQUIRED,ti.fastKey,ti.getWeakData,ti.onFreeze,Qt("iterator")),ni=Array.prototype,ii=function(e){return void 0!==e&&(on.Array===e||ni[ri]===e)},oi=Qt("iterator"),ai=function(e){if(null!=e)return e[oi]||e["@@iterator"]||on[Pn(e)]},si=function(e,t,r,n){try{return n?t(c(r)[0],r[1]):t(r)}catch(t){var i=e.return;throw void 0!==i&&c(i.call(e)),t}},ui=t((function(e){var t=function(e,t){this.stopped=e,this.result=t};(e.exports=function(e,r,n,i,o){var a,s,u,l,_,h,f,d=nr(r,n,i?2:1);if(o)a=e;else{if("function"!=typeof(s=ai(e)))throw TypeError("Target is not iterable");if(ii(s)){for(u=0,l=_e(e.length);l>u;u++)if((_=i?d(c(f=e[u])[0],f[1]):d(e[u]))&&_ instanceof t)return _;return new t(!1)}a=s.call(e)}for(h=a.next;!(f=h.call(a)).done;)if("object"==typeof(_=si(a,d,f.value,i))&&_&&_ instanceof t)return _;return new t(!1)}).stop=function(e){return new t(!0,e)}})),li=function(e,t,r){if(!(e instanceof t))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation");return e},_i=Qt("iterator"),ci=!1;try{var hi=0,fi={next:function(){return{done:!!hi++}},return:function(){ci=!0}};fi[_i]=function(){return this},Array.from(fi,(function(){throw 2}))}catch(e){}var di=function(e,t){if(!t&&!ci)return!1;var r=!1;try{var n={};n[_i]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},vi=function(e,t,r){var o=-1!==e.indexOf("Map"),s=-1!==e.indexOf("Weak"),u=o?"set":"add",l=n[e],_=l&&l.prototype,c=l,h={},f=function(e){var t=_[e];G(_,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(s&&!a(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return s&&!a(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(s&&!a(e))&&t.call(this,0===e?0:e)}:function(e,r){return t.call(this,0===e?0:e,r),this})};if(Me(e,"function"!=typeof l||!(s||_.forEach&&!i((function(){(new l).entries().next()})))))c=r.getConstructor(t,e,o,u),ti.REQUIRED=!0;else if(Me(e,!0)){var d=new c,v=d[u](s?{}:-0,1)!=d,y=i((function(){d.has(1)})),p=di((function(e){new l(e)})),g=!s&&i((function(){for(var e=new l,t=5;t--;)e[u](t,t);return!e.has(-0)}));p||((c=t((function(t,r){li(t,c,e);var n=it(new l,t,c);return null!=r&&ui(r,n[u],n,o),n}))).prototype=_,_.constructor=c),(y||g)&&(f("delete"),f("has"),o&&f("get")),(g||v)&&f(u),s&&_.clear&&delete _.clear}return h[e]=c,Re({global:!0,forced:c!=l},h),tr(c,e),s||r.setStrong(c,e,o),c},yi=function(e,t,r){for(var n in t)G(e,n,t[n],r);return e},pi=Qt("species"),gi=function(e){var t=oe(e),r=d.f;o&&t&&!t[pi]&&r(t,pi,{configurable:!0,get:function(){return this}})},mi=d.f,ki=ti.fastKey,wi=z.set,Ei=z.getterFor,bi={getConstructor:function(e,t,r,n){var i=e((function(e,a){li(e,i,t),wi(e,{type:t,index:ht(null),first:void 0,last:void 0,size:0}),o||(e.size=0),null!=a&&ui(a,e[n],e,r)})),a=Ei(t),s=function(e,t,r){var n,i,s=a(e),l=u(e,t);return l?l.value=r:(s.last=l={index:i=ki(t,!0),key:t,value:r,previous:n=s.last,next:void 0,removed:!1},s.first||(s.first=l),n&&(n.next=l),o?s.size++:e.size++,"F"!==i&&(s.index[i]=l)),e},u=function(e,t){var r,n=a(e),i=ki(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return yi(i.prototype,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,o?e.size=0:this.size=0},delete:function(e){var t=a(this),r=u(this,e);if(r){var n=r.next,i=r.previous;delete t.index[r.index],r.removed=!0,i&&(i.next=n),n&&(n.previous=i),t.first==r&&(t.first=n),t.last==r&&(t.last=i),o?t.size--:this.size--}return!!r},forEach:function(e){for(var t,r=a(this),n=nr(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),yi(i.prototype,r?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),o&&mi(i.prototype,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=Ei(t),o=Ei(n);kn(e,t,(function(e,t){wi(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?"keys"==t?{value:r.key,done:!1}:"values"==t?{value:r.value,done:!1}:{value:[r.key,r.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),r?"entries":"values",!r,!0),gi(t)}},xi=(vi("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),bi),function(){function e(t){ze(this,e),this._name=t}return je(e,[{key:"isConvertible",value:function(e){this._override_error("isConvertible")}},{key:"convertValue",value:function(e,t){this._override_error("convertValue")}},{key:"getDefaultValue",value:function(){this._override_error("getDefaultValue")}},{key:"getCloneValue",value:function(e){this._override_error("getCloneValue")}},{key:"_override_error",value:function(e){throw new Error("Type#"+e+"() method has not been overridden in "+this.constructor.name)}},{key:"name",get:function(){return this._name}}],[{key:"register",value:function(e,t){if(Ii.has(e))throw new Ai("specified name ("+e+") has already been registered");return Ii.set(e,t),t}},{key:"find",value:function(e){var t=Ii.get(e);if(void 0===t)throw new Ti("type with the specified name ("+e+") is not registered");return t}}]),e}()),Ai=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e))).name="mapray.animation.Type.AlreadyRegisteredError",r}return qe(t,e),t}(rt);xi.AlreadyRegisteredError=Ai;var Ti=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e))).name="mapray.animation.Type.NotRegisteredError",r}return qe(t,e),t}(rt);xi.NotRegisteredError=Ti;var Ii=new Map,Pi=ur.find,Li=!0,Mi=Kr("find");"find"in[]&&Array(1).find((function(){Li=!1})),Re({target:"Array",proto:!0,forced:Li||!Mi},{find:function(e){return Pi(this,e,arguments.length>1?arguments[1]:void 0)}}),Wr("find");vi("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),bi);var Si="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Ri=function(e){if(void 0===e)return 0;var t=ue(e),r=_e(t);if(t!==r)throw RangeError("Wrong length or index");return r},Ci=Math.abs,Di=Math.pow,Oi=Math.floor,Fi=Math.log,Ni=Math.LN2,Vi=function(e,t,r){var n,i,o,a=new Array(r),s=8*r-t-1,u=(1<<s)-1,l=u>>1,_=23===t?Di(2,-24)-Di(2,-77):0,c=e<0||0===e&&1/e<0?1:0,h=0;for((e=Ci(e))!=e||e===1/0?(i=e!=e?1:0,n=u):(n=Oi(Fi(e)/Ni),e*(o=Di(2,-n))<1&&(n--,o*=2),(e+=n+l>=1?_/o:_*Di(2,1-l))*o>=2&&(n++,o/=2),n+l>=u?(i=0,n=u):n+l>=1?(i=(e*o-1)*Di(2,t),n+=l):(i=e*Di(2,l-1)*Di(2,t),n=0));t>=8;a[h++]=255&i,i/=256,t-=8);for(n=n<<t|i,s+=t;s>0;a[h++]=255&n,n/=256,s-=8);return a[--h]|=128*c,a},Ui=function(e,t){var r,n=e.length,i=8*n-t-1,o=(1<<i)-1,a=o>>1,s=i-7,u=n-1,l=e[u--],_=127&l;for(l>>=7;s>0;_=256*_+e[u],u--,s-=8);for(r=_&(1<<-s)-1,_>>=-s,s+=t;s>0;r=256*r+e[u],u--,s-=8);if(0===_)_=1-a;else{if(_===o)return r?NaN:l?-1/0:1/0;r+=Di(2,t),_-=a}return(l?-1:1)*r*Di(2,_-t)},Bi=function(e){for(var t=zt(this),r=_e(t.length),n=arguments.length,i=fe(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:fe(o,r);a>i;)t[i++]=e;return t},zi=ke.f,Gi=d.f,ji=z.get,qi=z.set,Yi=n.ArrayBuffer,Hi=Yi,Xi=n.DataView,Wi=Xi&&Xi.prototype,Qi=Object.prototype,Zi=n.RangeError,Ji=Vi,Ki=Ui,$i=function(e){return[255&e]},eo=function(e){return[255&e,e>>8&255]},to=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},ro=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},no=function(e){return Ji(e,23,4)},io=function(e){return Ji(e,52,8)},oo=function(e,t){Gi(e.prototype,t,{get:function(){return ji(this)[t]}})},ao=function(e,t,r,n){var i=Ri(r),o=ji(e);if(i+t>o.byteLength)throw Zi("Wrong index");var a=ji(o.buffer).bytes,s=i+o.byteOffset,u=a.slice(s,s+t);return n?u:u.reverse()},so=function(e,t,r,n,i,o){var a=Ri(r),s=ji(e);if(a+t>s.byteLength)throw Zi("Wrong index");for(var u=ji(s.buffer).bytes,l=a+s.byteOffset,_=n(+i),c=0;c<t;c++)u[l+c]=_[o?c:t-c-1]};if(Si){if(!i((function(){Yi(1)}))||!i((function(){new Yi(-1)}))||i((function(){return new Yi,new Yi(1.5),new Yi(NaN),"ArrayBuffer"!=Yi.name}))){for(var uo,lo=(Hi=function(e){return li(this,Hi),new Yi(Ri(e))}).prototype=Yi.prototype,_o=zi(Yi),co=0;_o.length>co;)(uo=_o[co++])in Hi||y(Hi,uo,Yi[uo]);lo.constructor=Hi}nt&&ln(Wi)!==Qi&&nt(Wi,Qi);var ho=new Xi(new Hi(2)),fo=Wi.setInt8;ho.setInt8(0,2147483648),ho.setInt8(1,2147483649),!ho.getInt8(0)&&ho.getInt8(1)||yi(Wi,{setInt8:function(e,t){fo.call(this,e,t<<24>>24)},setUint8:function(e,t){fo.call(this,e,t<<24>>24)}},{unsafe:!0})}else Hi=function(e){li(this,Hi,"ArrayBuffer");var t=Ri(e);qi(this,{bytes:Bi.call(new Array(t),0),byteLength:t}),o||(this.byteLength=t)},Xi=function(e,t,r){li(this,Xi,"DataView"),li(e,Hi,"DataView");var n=ji(e).byteLength,i=ue(t);if(i<0||i>n)throw Zi("Wrong offset");if(i+(r=void 0===r?n-i:_e(r))>n)throw Zi("Wrong length");qi(this,{buffer:e,byteLength:r,byteOffset:i}),o||(this.buffer=e,this.byteLength=r,this.byteOffset=i)},o&&(oo(Hi,"byteLength"),oo(Xi,"buffer"),oo(Xi,"byteLength"),oo(Xi,"byteOffset")),yi(Xi.prototype,{getInt8:function(e){return ao(this,1,e)[0]<<24>>24},getUint8:function(e){return ao(this,1,e)[0]},getInt16:function(e){var t=ao(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ao(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return ro(ao(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return ro(ao(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Ki(ao(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Ki(ao(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){so(this,1,e,$i,t)},setUint8:function(e,t){so(this,1,e,$i,t)},setInt16:function(e,t){so(this,2,e,eo,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){so(this,2,e,eo,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){so(this,4,e,to,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){so(this,4,e,to,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){so(this,4,e,no,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){so(this,8,e,io,t,arguments.length>2?arguments[2]:void 0)}});tr(Hi,"ArrayBuffer"),tr(Xi,"DataView");var vo={ArrayBuffer:Hi,DataView:Xi},yo=Qt("species"),po=function(e,t){var r,n=c(e).constructor;return void 0===n||null==(r=c(n)[yo])?t:rr(r)},go=vo.ArrayBuffer,mo=vo.DataView,ko=go.prototype.slice,wo=i((function(){return!new go(2).slice(1,void 0).byteLength}));Re({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wo},{slice:function(e,t){if(void 0!==ko&&void 0===t)return ko.call(c(this),e);for(var r=c(this).byteLength,n=fe(e,r),i=fe(void 0===t?r:t,r),o=new(po(this,go))(_e(i-n)),a=new mo(this),s=new mo(o),u=0;n<i;)s.setUint8(u++,a.getUint8(n++));return o}});var Eo,bo=d.f,xo=n.Int8Array,Ao=xo&&xo.prototype,To=n.Uint8ClampedArray,Io=To&&To.prototype,Po=xo&&ln(xo),Lo=Ao&&ln(Ao),Mo=Object.prototype,So=Mo.isPrototypeOf,Ro=Qt("toStringTag"),Co=S("TYPED_ARRAY_TAG"),Do=Si&&!!nt&&"Opera"!==Pn(n.opera),Oo=!1,Fo={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},No=function(e){return a(e)&&g(Fo,Pn(e))};for(Eo in Fo)n[Eo]||(Do=!1);if((!Do||"function"!=typeof Po||Po===Function.prototype)&&(Po=function(){throw TypeError("Incorrect invocation")},Do))for(Eo in Fo)n[Eo]&&nt(n[Eo],Po);if((!Do||!Lo||Lo===Mo)&&(Lo=Po.prototype,Do))for(Eo in Fo)n[Eo]&&nt(n[Eo].prototype,Lo);if(Do&&ln(Io)!==Lo&&nt(Io,Lo),o&&!g(Lo,Ro))for(Eo in Oo=!0,bo(Lo,Ro,{get:function(){return a(this)?this[Co]:void 0}}),Fo)n[Eo]&&y(n[Eo],Co,Eo);var Vo={NATIVE_ARRAY_BUFFER_VIEWS:Do,TYPED_ARRAY_TAG:Oo&&Co,aTypedArray:function(e){if(No(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(nt){if(So.call(Po,e))return e}else for(var t in Fo)if(g(Fo,Eo)){var r=n[t];if(r&&(e===r||So.call(r,e)))return e}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r){if(o){if(r)for(var i in Fo){var a=n[i];a&&g(a.prototype,e)&&delete a.prototype[e]}Lo[e]&&!r||G(Lo,e,r?t:Do&&Ao[e]||t)}},exportTypedArrayStaticMethod:function(e,t,r){var i,a;if(o){if(nt){if(r)for(i in Fo)(a=n[i])&&g(a,e)&&delete a[e];if(Po[e]&&!r)return;try{return G(Po,e,r?t:Do&&xo[e]||t)}catch(e){}}for(i in Fo)!(a=n[i])||a[e]&&!r||G(a,e,t)}},isView:function(e){var t=Pn(e);return"DataView"===t||g(Fo,t)},isTypedArray:No,TypedArray:Po,TypedArrayPrototype:Lo},Uo=Vo.NATIVE_ARRAY_BUFFER_VIEWS,Bo=n.ArrayBuffer,zo=n.Int8Array,Go=!Uo||!i((function(){zo(1)}))||!i((function(){new zo(-1)}))||!di((function(e){new zo,new zo(null),new zo(1.5),new zo(e)}),!0)||i((function(){return 1!==new zo(new Bo(2),1,void 0).length})),jo=function(e,t){var r=function(e){var t=ue(e);if(t<0)throw RangeError("The argument can't be less than 0");return t}(e);if(r%t)throw RangeError("Wrong offset");return r},qo=Vo.aTypedArrayConstructor,Yo=function(e){var t,r,n,i,o,a,s=zt(e),u=arguments.length,l=u>1?arguments[1]:void 0,_=void 0!==l,c=ai(s);if(null!=c&&!ii(c))for(a=(o=c.call(s)).next,s=[];!(i=a.call(o)).done;)s.push(i.value);for(_&&u>2&&(l=nr(l,arguments[2],2)),r=_e(s.length),n=new(qo(this))(r),t=0;r>t;t++)n[t]=_?l(s[t],t):s[t];return n},Ho=t((function(e){var t=ke.f,r=ur.forEach,i=z.get,s=z.set,u=d.f,l=re.f,_=Math.round,c=n.RangeError,f=vo.ArrayBuffer,p=vo.DataView,m=Vo.NATIVE_ARRAY_BUFFER_VIEWS,k=Vo.TYPED_ARRAY_TAG,w=Vo.TypedArray,E=Vo.TypedArrayPrototype,b=Vo.aTypedArrayConstructor,x=Vo.isTypedArray,A=function(e,t){for(var r=0,n=t.length,i=new(b(e))(n);n>r;)i[r]=t[r++];return i},T=function(e,t){u(e,t,{get:function(){return i(this)[t]}})},I=function(e){var t;return e instanceof f||"ArrayBuffer"==(t=Pn(e))||"SharedArrayBuffer"==t},P=function(e,t){return x(e)&&"symbol"!=typeof t&&t in e&&String(+t)==String(t)},L=function(e,t){return P(e,t=h(t,!0))?v(2,e[t]):l(e,t)},M=function(e,t,r){return!(P(e,t=h(t,!0))&&a(r)&&g(r,"value"))||g(r,"get")||g(r,"set")||r.configurable||g(r,"writable")&&!r.writable||g(r,"enumerable")&&!r.enumerable?u(e,t,r):(e[t]=r.value,e)};o?(m||(re.f=L,d.f=M,T(E,"buffer"),T(E,"byteOffset"),T(E,"byteLength"),T(E,"length")),Re({target:"Object",stat:!0,forced:!m},{getOwnPropertyDescriptor:L,defineProperty:M}),e.exports=function(e,o,l){var h=e.match(/\d+$/)[0]/8,d=e+(l?"Clamped":"")+"Array",v="get"+e,g="set"+e,b=n[d],T=b,P=T&&T.prototype,L={},M=function(e,t){u(e,t,{get:function(){return function(e,t){var r=i(e);return r.view[v](t*h+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,r){var n=i(e);l&&(r=(r=_(r))<0?0:r>255?255:255&r),n.view[g](t*h+n.byteOffset,r,!0)}(this,t,e)},enumerable:!0})};m?Go&&(T=o((function(e,t,r,n){return li(e,T,d),it(a(t)?I(t)?void 0!==n?new b(t,jo(r,h),n):void 0!==r?new b(t,jo(r,h)):new b(t):x(t)?A(T,t):Yo.call(T,t):new b(Ri(t)),e,T)})),nt&&nt(T,w),r(t(b),(function(e){e in T||y(T,e,b[e])})),T.prototype=P):(T=o((function(e,t,r,n){li(e,T,d);var i,o,u,l=0,_=0;if(a(t)){if(!I(t))return x(t)?A(T,t):Yo.call(T,t);i=t,_=jo(r,h);var v=t.byteLength;if(void 0===n){if(v%h)throw c("Wrong length");if((o=v-_)<0)throw c("Wrong length")}else if((o=_e(n)*h)+_>v)throw c("Wrong length");u=o/h}else u=Ri(t),i=new f(o=u*h);for(s(e,{buffer:i,byteOffset:_,byteLength:o,length:u,view:new p(i)});l<u;)M(e,l++)})),nt&&nt(T,w),P=T.prototype=ht(E)),P.constructor!==T&&y(P,"constructor",T),k&&y(P,k,d),L[d]=T,Re({global:!0,forced:T!=b,sham:!m},L),"BYTES_PER_ELEMENT"in T||y(T,"BYTES_PER_ELEMENT",h),"BYTES_PER_ELEMENT"in P||y(P,"BYTES_PER_ELEMENT",h),gi(d)}):e.exports=function(){}}));Ho("Float32",(function(e){return function(t,r,n){return e(this,t,r,n)}})),Ho("Float64",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var Xo=Math.min,Wo=[].copyWithin||function(e,t){var r=zt(this),n=_e(r.length),i=fe(e,n),o=fe(t,n),a=arguments.length>2?arguments[2]:void 0,s=Xo((void 0===a?n:fe(a,n))-o,n-i),u=1;for(o<i&&i<o+s&&(u=-1,o+=s-1,i+=s-1);s-- >0;)o in r?r[i]=r[o]:delete r[i],i+=u,o+=u;return r},Qo=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("copyWithin",(function(e,t){return Wo.call(Qo(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Zo=ur.every,Jo=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("every",(function(e){return Zo(Jo(this),e,arguments.length>1?arguments[1]:void 0)}));var Ko=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("fill",(function(e){return Bi.apply(Ko(this),arguments)}));var $o=ur.filter,ea=Vo.aTypedArray,ta=Vo.aTypedArrayConstructor;(0,Vo.exportTypedArrayMethod)("filter",(function(e){for(var t=$o(ea(this),e,arguments.length>1?arguments[1]:void 0),r=po(this,this.constructor),n=0,i=t.length,o=new(ta(r))(i);i>n;)o[n]=t[n++];return o}));var ra=ur.find,na=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("find",(function(e){return ra(na(this),e,arguments.length>1?arguments[1]:void 0)}));var ia=ur.findIndex,oa=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("findIndex",(function(e){return ia(oa(this),e,arguments.length>1?arguments[1]:void 0)}));var aa=ur.forEach,sa=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("forEach",(function(e){aa(sa(this),e,arguments.length>1?arguments[1]:void 0)}));var ua=ve.includes,la=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("includes",(function(e){return ua(la(this),e,arguments.length>1?arguments[1]:void 0)}));var _a=ve.indexOf,ca=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("indexOf",(function(e){return _a(ca(this),e,arguments.length>1?arguments[1]:void 0)}));var ha=Qt("iterator"),fa=n.Uint8Array,da=bn.values,va=bn.keys,ya=bn.entries,pa=Vo.aTypedArray,ga=Vo.exportTypedArrayMethod,ma=fa&&fa.prototype[ha],ka=!!ma&&("values"==ma.name||null==ma.name),wa=function(){return da.call(pa(this))};ga("entries",(function(){return ya.call(pa(this))})),ga("keys",(function(){return va.call(pa(this))})),ga("values",wa,!ka),ga(ha,wa,!ka);var Ea=Vo.aTypedArray,ba=[].join;(0,Vo.exportTypedArrayMethod)("join",(function(e){return ba.apply(Ea(this),arguments)}));var xa=function(e,t){var r=[][e];return!!r&&i((function(){r.call(null,t||function(){throw 1},1)}))},Aa=Math.min,Ta=[].lastIndexOf,Ia=!!Ta&&1/[1].lastIndexOf(1,-0)<0,Pa=xa("lastIndexOf"),La=Kr("indexOf",{ACCESSORS:!0,1:0}),Ma=Ia||!Pa||!La?function(e){if(Ia)return Ta.apply(this,arguments)||0;var t=ee(this),r=_e(t.length),n=r-1;for(arguments.length>1&&(n=Aa(n,ue(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:Ta,Sa=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("lastIndexOf",(function(e){return Ma.apply(Sa(this),arguments)}));var Ra=ur.map,Ca=Vo.aTypedArray,Da=Vo.aTypedArrayConstructor;(0,Vo.exportTypedArrayMethod)("map",(function(e){return Ra(Ca(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(Da(po(e,e.constructor)))(t)}))}));var Oa=function(e){return function(t,r,n,i){rr(r);var o=zt(t),a=K(o),s=_e(o.length),u=e?s-1:0,l=e?-1:1;if(n<2)for(;;){if(u in a){i=a[u],u+=l;break}if(u+=l,e?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=l)u in a&&(i=r(i,a[u],u,o));return i}},Fa={left:Oa(!1),right:Oa(!0)},Na=Fa.left,Va=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("reduce",(function(e){return Na(Va(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var Ua=Fa.right,Ba=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("reduceRight",(function(e){return Ua(Ba(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var za=Vo.aTypedArray,Ga=Vo.exportTypedArrayMethod,ja=Math.floor;Ga("reverse",(function(){for(var e,t=za(this).length,r=ja(t/2),n=0;n<r;)e=this[n],this[n++]=this[--t],this[t]=e;return this}));var qa=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("set",(function(e){qa(this);var t=jo(arguments.length>1?arguments[1]:void 0,1),r=this.length,n=zt(e),i=_e(n.length),o=0;if(i+t>r)throw RangeError("Wrong length");for(;o<i;)this[t+o]=n[o++]}),i((function(){new Int8Array(1).set({})})));var Ya=Vo.aTypedArray,Ha=Vo.aTypedArrayConstructor,Xa=[].slice;(0,Vo.exportTypedArrayMethod)("slice",(function(e,t){for(var r=Xa.call(Ya(this),e,t),n=po(this,this.constructor),i=0,o=r.length,a=new(Ha(n))(o);o>i;)a[i]=r[i++];return a}),i((function(){new Int8Array(1).slice()})));var Wa=ur.some,Qa=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("some",(function(e){return Wa(Qa(this),e,arguments.length>1?arguments[1]:void 0)}));var Za=Vo.aTypedArray,Ja=[].sort;(0,Vo.exportTypedArrayMethod)("sort",(function(e){return Ja.call(Za(this),e)}));var Ka=Vo.aTypedArray;(0,Vo.exportTypedArrayMethod)("subarray",(function(e,t){var r=Ka(this),n=r.length,i=fe(e,n);return new(po(r,r.constructor))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,_e((void 0===t?n:fe(t,n))-i))}));var $a=n.Int8Array,es=Vo.aTypedArray,ts=Vo.exportTypedArrayMethod,rs=[].toLocaleString,ns=[].slice,is=!!$a&&i((function(){rs.call(new $a(1))}));ts("toLocaleString",(function(){return rs.apply(is?ns.call(es(this)):es(this),arguments)}),i((function(){return[1,2].toLocaleString()!=new $a([1,2]).toLocaleString()}))||!i((function(){$a.prototype.toLocaleString.call([1,2])})));var os=Vo.exportTypedArrayMethod,as=n.Uint8Array,ss=as&&as.prototype||{},us=[].toString,ls=[].join;i((function(){us.call({})}))&&(us=function(){return ls.call(this)});var _s=ss.toString!=us;os("toString",us,_s);var cs=function(){function e(){ze(this,e)}return je(e,null,[{key:"createMatrix",value:function(e){return new Float64Array(e||16)}},{key:"createMatrixf",value:function(e){return new Float32Array(e||16)}},{key:"createVector4",value:function(e){return new Float64Array(e||4)}},{key:"createVector4f",value:function(e){return new Float32Array(e||4)}},{key:"createVector3",value:function(e){return new Float64Array(e||3)}},{key:"createVector3f",value:function(e){return new Float32Array(e||3)}},{key:"createVector2",value:function(e){return new Float64Array(e||2)}},{key:"createVector2f",value:function(e){return new Float32Array(e||2)}},{key:"copyMatrix",value:function(e,t){for(var r=0;r<16;++r)t[r]=e[r];return t}},{key:"copyVector4",value:function(e,t){for(var r=0;r<4;++r)t[r]=e[r];return t}},{key:"copyVector3",value:function(e,t){for(var r=0;r<3;++r)t[r]=e[r];return t}},{key:"copyVector2",value:function(e,t){return t[0]=e[0],t[1]=e[1],t}},{key:"setIdentity",value:function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}},{key:"dot3",value:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}},{key:"cross3",value:function(e,t,r){var n=e[1]*t[2]-e[2]*t[1],i=e[2]*t[0]-e[0]*t[2],o=e[0]*t[1]-e[1]*t[0];return r[0]=n,r[1]=i,r[2]=o,r}},{key:"normalize3",value:function(e,t){var r=e[0],n=e[1],i=e[2],o=1/Math.sqrt(r*r+n*n+i*i);return t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}},{key:"scale3",value:function(e,t,r){return r[0]=e*t[0],r[1]=e*t[1],r[2]=e*t[2],r}},{key:"mul_AA",value:function(e,t,r){var n=e[0],i=e[4],o=e[8],a=e[12],s=e[1],u=e[5],l=e[9],_=e[13],c=e[2],h=e[6],f=e[10],d=e[14],v=t[0],y=t[4],p=t[8],g=t[12],m=t[1],k=t[5],w=t[9],E=t[13],b=t[2],x=t[6],A=t[10],T=t[14];return r[0]=n*v+i*m+o*b,r[1]=s*v+u*m+l*b,r[2]=c*v+h*m+f*b,r[3]=0,r[4]=n*y+i*k+o*x,r[5]=s*y+u*k+l*x,r[6]=c*y+h*k+f*x,r[7]=0,r[8]=n*p+i*w+o*A,r[9]=s*p+u*w+l*A,r[10]=c*p+h*w+f*A,r[11]=0,r[12]=n*g+i*E+o*T+a,r[13]=s*g+u*E+l*T+_,r[14]=c*g+h*E+f*T+d,r[15]=1,r}},{key:"mul_GA",value:function(e,t,r){var n=e[0],i=e[4],o=e[8],a=e[12],s=e[1],u=e[5],l=e[9],_=e[13],c=e[2],h=e[6],f=e[10],d=e[14],v=e[3],y=e[7],p=e[11],g=e[15],m=t[0],k=t[4],w=t[8],E=t[12],b=t[1],x=t[5],A=t[9],T=t[13],I=t[2],P=t[6],L=t[10],M=t[14];return r[0]=n*m+i*b+o*I,r[1]=s*m+u*b+l*I,r[2]=c*m+h*b+f*I,r[3]=v*m+y*b+p*I,r[4]=n*k+i*x+o*P,r[5]=s*k+u*x+l*P,r[6]=c*k+h*x+f*P,r[7]=v*k+y*x+p*P,r[8]=n*w+i*A+o*L,r[9]=s*w+u*A+l*L,r[10]=c*w+h*A+f*L,r[11]=v*w+y*A+p*L,r[12]=n*E+i*T+o*M+a,r[13]=s*E+u*T+l*M+_,r[14]=c*E+h*T+f*M+d,r[15]=v*E+y*T+p*M+g,r}},{key:"mul_PzA",value:function(e,t,r){var n=e[0],i=e[8],o=e[12],a=e[5],s=e[9],u=e[13],l=e[10],_=e[14],c=e[11],h=e[15],f=t[0],d=t[4],v=t[8],y=t[12],p=t[1],g=t[5],m=t[9],k=t[13],w=t[2],E=t[6],b=t[10],x=t[14];return r[0]=n*f+i*w,r[1]=a*p+s*w,r[2]=l*w,r[3]=c*w,r[4]=n*d+i*E,r[5]=a*g+s*E,r[6]=l*E,r[7]=c*E,r[8]=n*v+i*b,r[9]=a*m+s*b,r[10]=l*b,r[11]=c*b,r[12]=n*y+i*x+o,r[13]=a*k+s*x+u,r[14]=l*x+_,r[15]=c*x+h,r}},{key:"inverse_A",value:function(e,t){var r=e[0],n=e[4],i=e[8],o=e[12],a=e[1],s=e[5],u=e[9],l=e[13],_=e[2],c=e[6],h=e[10],f=e[14],d=s*h-c*u,v=_*u-a*h,y=a*c-_*s,p=c*i-n*h,g=r*h-_*i,m=_*n-r*c,k=n*u-s*i,w=a*i-r*u,E=r*s-a*n,b=-(o*d+l*p+f*k),x=-(o*v+l*g+f*w),A=-(o*y+l*m+f*E),T=1/(r*d+n*v+i*y);return t[0]=d*T,t[1]=v*T,t[2]=y*T,t[3]=0,t[4]=p*T,t[5]=g*T,t[6]=m*T,t[7]=0,t[8]=k*T,t[9]=w*T,t[10]=E*T,t[11]=0,t[12]=b*T,t[13]=x*T,t[14]=A*T,t[15]=1,t}},{key:"transformPlane_A",value:function(e,t,r){var n=e,i=t[0],o=t[1],a=t[2],s=t[3];return r[0]=i*n[0]+o*n[1]+a*n[2],r[1]=i*n[4]+o*n[5]+a*n[6],r[2]=i*n[8]+o*n[9]+a*n[10],r[3]=i*n[12]+o*n[13]+a*n[14]+s,r}},{key:"iscs_to_gocs_matrix",value:function(t,r){var n=t.longitude*e.DEGREE,i=t.latitude*e.DEGREE,o=Math.sin(n),a=Math.cos(n),s=Math.sin(i),u=Math.cos(i),l=e.EARTH_RADIUS+t.height;return r[0]=-o,r[1]=a,r[2]=0,r[3]=0,r[4]=-a*s,r[5]=-o*s,r[6]=u,r[7]=0,r[8]=u*a,r[9]=u*o,r[10]=s,r[11]=0,r[12]=l*u*a,r[13]=l*u*o,r[14]=l*s,r[15]=1,r}},{key:"gocs_to_iscs",value:function(t,r){var n=t[0],i=t[1],o=t[2],a=n*n,s=i*i,u=o*o;return 0!=n||0!=i?(r.latitude=Math.atan(o/Math.sqrt(a+s))/e.DEGREE,r.longitude=Math.atan2(i,n)/e.DEGREE):(r.latitude=o>0?90:o<0?-90:0,r.longitude=0),r.height=Math.sqrt(a+s+u)-e.EARTH_RADIUS,r}},{key:"frustum_matrix",value:function(e,t,r,n,i,o,a){return a[0]=2*i/(t-e),a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2*i/(n-r),a[6]=0,a[7]=0,a[8]=(t+e)/(t-e),a[9]=(n+r)/(n-r),a[10]=(o+i)/(i-o),a[11]=-1,a[12]=0,a[13]=0,a[14]=2*o*i/(i-o),a[15]=0,a}},{key:"lookat_matrix",value:function(t,r,n,i){var o=e._xaxis,a=e._yaxis,s=e._zaxis;return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],e.normalize3(s,s),e.cross3(n,s,o),e.normalize3(o,o),e.cross3(s,o,a),i[0]=o[0],i[1]=o[1],i[2]=o[2],i[3]=0,i[4]=a[0],i[5]=a[1],i[6]=a[2],i[7]=0,i[8]=s[0],i[9]=s[1],i[10]=s[2],i[11]=0,i[12]=t[0],i[13]=t[1],i[14]=t[2],i[15]=1,i}},{key:"rotation_matrix",value:function(t,r,n){var i=r*e.DEGREE,o=Math.sin(i),a=Math.cos(i),s=t[0],u=t[1],l=t[2];return n[0]=s*s*(1-a)+a,n[1]=s*u*(1-a)+l*o,n[2]=s*l*(1-a)-u*o,n[3]=0,n[4]=s*u*(1-a)-l*o,n[5]=u*u*(1-a)+a,n[6]=u*l*(1-a)+s*o,n[7]=0,n[8]=s*l*(1-a)+u*o,n[9]=u*l*(1-a)-s*o,n[10]=l*l*(1-a)+a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}},{key:"kml_model_matrix",value:function(t,r,n,i,o){var a=t*e.DEGREE,s=r*e.DEGREE,u=n*e.DEGREE,l=Math.sin(a),_=Math.cos(a),c=Math.sin(s),h=Math.cos(s),f=Math.sin(u),d=Math.cos(u),v=i[0],y=i[1],p=i[2];return o[0]=v*(l*f*c+_*d),o[1]=v*(_*f*c-l*d),o[2]=v*f*h,o[3]=0,o[4]=y*l*h,o[5]=y*_*h,o[6]=-y*c,o[7]=0,o[8]=p*(l*d*c-_*f),o[9]=p*(_*d*c+l*f),o[10]=p*d*h,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}},{key:"gudermannian",value:function(e){return 2*Math.atan(Math.exp(e))-Math.PI/2}},{key:"invGudermannian",value:function(e){return Math.log(Math.tan(e/2+Math.PI/4))}},{key:"clamp",value:function(e,t,r){return Math.min(Math.max(e,t),r)}}]),e}();cs.EARTH_RADIUS=6378137,cs.DEGREE=.017453292519943295,cs.LOG2PI=1.6514961294723187,cs._xaxis=cs.createVector3(),cs._yaxis=cs.createVector3(),cs._zaxis=cs.createVector3();var hs=function(){function e(t,r,n){ze(this,e),this.longitude=void 0!==t?t:0,this.latitude=void 0!==r?r:0,this.altitude=void 0!==n?n:0}return je(e,[{key:"clone",value:function(){return new e(this.longitude,this.latitude,this.altitude)}},{key:"assign",value:function(e){return this.longitude=e.longitude,this.latitude=e.latitude,this.altitude=e.altitude,this}},{key:"setFromArray",value:function(e){return this.longitude=e[0],this.latitude=e[1],this.altitude=e.length>2?e[2]:0,this}},{key:"setFromGocs",value:function(e){var t=e[0],r=e[1],n=e[2],i=t*t,o=r*r,a=n*n;return 0!=t||0!=r?(this.latitude=Math.atan(n/Math.sqrt(i+o))/cs.DEGREE,this.longitude=Math.atan2(r,t)/cs.DEGREE):(this.latitude=n>0?90:n<0?-90:0,this.longitude=0),this.altitude=Math.sqrt(i+o+a)-cs.EARTH_RADIUS,this}},{key:"getAsGocs",value:function(e){var t=this.longitude*cs.DEGREE,r=this.latitude*cs.DEGREE,n=cs.EARTH_RADIUS+this.altitude,i=Math.cos(r);return e[0]=n*i*Math.cos(t),e[1]=n*i*Math.sin(t),e[2]=n*Math.sin(r),e}},{key:"getMlocsToGocsMatrix",value:function(e){var t=this.longitude*cs.DEGREE,r=this.latitude*cs.DEGREE,n=Math.sin(t),i=Math.cos(t),o=Math.sin(r),a=Math.cos(r),s=cs.EARTH_RADIUS+this.altitude;return e[0]=-n,e[1]=i,e[2]=0,e[3]=0,e[4]=-i*o,e[5]=-n*o,e[6]=a,e[7]=0,e[8]=a*i,e[9]=a*n,e[10]=o,e[11]=0,e[12]=s*a*i,e[13]=s*a*n,e[14]=s*o,e[15]=1,e}},{key:"getUpwardVector",value:function(e){var t=this.longitude*cs.DEGREE,r=this.latitude*cs.DEGREE,n=Math.cos(r);return e[0]=n*Math.cos(t),e[1]=n*Math.sin(t),e[2]=Math.sin(r),e}}],[{key:"toGocsArray",value:function(e,t,r){for(var n=cs.DEGREE,i=cs.EARTH_RADIUS,o=0;o<t;++o){var a=3*o,s=e[a]*n,u=e[a+1]*n,l=i+e[a+2],_=Math.cos(u);r[a]=l*_*Math.cos(s),r[a+1]=l*_*Math.sin(s),r[a+2]=l*Math.sin(u)}return r}}]),e}(),fs=function(){function e(t,r,n){ze(this,e),this.heading=void 0!==t?t:0,this.tilt=void 0!==r?r:0,this.roll=void 0!==n?n:0}return je(e,[{key:"clone",value:function(){return new e(this.heading,this.tilt,this.roll)}},{key:"assign",value:function(e){return this.heading=e.heading,this.tilt=e.tilt,this.roll=e.roll,this}},{key:"getTransformMatrix",value:function(e,t){var r=this.heading*cs.DEGREE,n=this.tilt*cs.DEGREE,i=this.roll*cs.DEGREE,o=Math.sin(r),a=Math.cos(r),s=Math.sin(n),u=Math.cos(n),l=Math.sin(i),_=Math.cos(i),c=e[0],h=e[1],f=e[2];return t[0]=c*(o*l*s+a*_),t[1]=c*(a*l*s-o*_),t[2]=c*l*u,t[3]=0,t[4]=h*o*u,t[5]=h*a*u,t[6]=-h*s,t[7]=0,t[8]=f*(o*_*s-a*l),t[9]=f*(a*_*s+o*l),t[10]=f*_*u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}}]),e}(),ds=function(e){function t(){var e;return ze(this,t),(e=Je(this,Ye(t).call(this,"boolean")))._number_type=null,e._convertibles=new Set([Ze(e)]),e}return qe(t,e),je(t,[{key:"_postinit",value:function(){this._number_type=xi.find("number"),this._convertibles.add(this._number_type)}},{key:"isConvertible",value:function(e){return this._convertibles.has(e)}},{key:"convertValue",value:function(e,t){return e===this?t:t>=.5}},{key:"getDefaultValue",value:function(){return!1}},{key:"getCloneValue",value:function(e){return e}}]),t}(xi),vs=function(e){function t(){var e;return ze(this,t),(e=Je(this,Ye(t).call(this,"number")))._boolean_type=null,e._convertibles=new Set([Ze(e)]),e}return qe(t,e),je(t,[{key:"_postinit",value:function(){this._boolean_type=xi.find("boolean"),this._convertibles.add(this._boolean_type)}},{key:"isConvertible",value:function(e){return this._convertibles.has(e)}},{key:"convertValue",value:function(e,t){return e===this?t:t?1:0}},{key:"getDefaultValue",value:function(){return 0}},{key:"getCloneValue",value:function(e){return e}}]),t}(xi),ys=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this,"string"))}return qe(t,e),je(t,[{key:"_postinit",value:function(){}},{key:"isConvertible",value:function(e){return e===this}},{key:"convertValue",value:function(e,t){return t}},{key:"getDefaultValue",value:function(){return""}},{key:"getCloneValue",value:function(e){return e}}]),t}(xi),ps=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this,"vector2"))}return qe(t,e),je(t,[{key:"_postinit",value:function(){}},{key:"isConvertible",value:function(e){return e===this}},{key:"convertValue",value:function(e,t){return t}},{key:"getDefaultValue",value:function(){return cs.createVector2()}},{key:"getCloneValue",value:function(e){return cs.createVector2(e)}}]),t}(xi),gs=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this,"vector3"))}return qe(t,e),je(t,[{key:"_postinit",value:function(){}},{key:"isConvertible",value:function(e){return e===this}},{key:"convertValue",value:function(e,t){return t}},{key:"getDefaultValue",value:function(){return cs.createVector3()}},{key:"getCloneValue",value:function(e){return cs.createVector3(e)}}]),t}(xi),ms=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this,"vector4"))}return qe(t,e),je(t,[{key:"_postinit",value:function(){}},{key:"isConvertible",value:function(e){return e===this}},{key:"convertValue",value:function(e,t){return t}},{key:"getDefaultValue",value:function(){return cs.createVector4()}},{key:"getCloneValue",value:function(e){return cs.createVector4(e)}}]),t}(xi),ks=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this,"matrix"))}return qe(t,e),je(t,[{key:"_postinit",value:function(){}},{key:"isConvertible",value:function(e){return e===this}},{key:"convertValue",value:function(e,t){return t}},{key:"getDefaultValue",value:function(){return cs.setIdentity(cs.createMatrix())}},{key:"getCloneValue",value:function(e){return cs.createMatrix(e)}}]),t}(xi);!function(){for(var e=[],t=0,r=[ds,vs,ys,gs,ps,ms,ks];t<r.length;t++){var n=new(0,r[t]);xi.register(n.name,n),e.push(n)}for(var i=0,o=e;i<o.length;i++){o[i]._postinit()}}();var ws=function(){function e(){ze(this,e),this._value_change_listeners=new Set}return je(e,[{key:"isTypeSupported",value:function(e){this._override_error("isTypeSupported")}},{key:"getValue",value:function(e,t){this._override_error("getValue")}},{key:"getInvariance",value:function(e){this._override_error("getInvariance")}},{key:"notifyValueChange",value:function(e){if(!e.isEmpty()){var t=!0,r=!1,n=void 0;try{for(var i,o=this._value_change_listeners[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){(0,i.value)(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}}},{key:"addValueChangeListener",value:function(e){this._value_change_listeners.add(e)}},{key:"removeValueChangeListener",value:function(e){this._value_change_listeners.delete(e)}},{key:"_override_error",value:function(e){throw new Error("Curve#"+e+"() method has not been overridden in "+this.constructor.name)}}]),e}(),Es=function(e,t,r){var n=h(t);n in e?d.f(e,n,v(0,r)):e[n]=r},bs=function(e){var t,r,n,i,o,a,s=zt(e),u="function"==typeof this?this:Array,l=arguments.length,_=l>1?arguments[1]:void 0,c=void 0!==_,h=ai(s),f=0;if(c&&(_=nr(_,l>2?arguments[2]:void 0,2)),null==h||u==Array&&ii(h))for(r=new u(t=_e(s.length));t>f;f++)a=c?_(s[f],f):s[f],Es(r,f,a);else for(o=(i=h.call(s)).next,r=new u;!(n=o.call(i)).done;f++)a=c?si(i,_,[n.value,f],!0):n.value,Es(r,f,a);return r.length=f,r},xs=!di((function(e){Array.from(e)}));Re({target:"Array",stat:!0,forced:xs},{from:bs});var As=function(){function e(){ze(this,e),this._prev_time=null,this._track_binders=new Map,this._dirty_binders=new Set,this._vary_curves=new Is}return je(e,[{key:"update",value:function(e){if(this._update_dirty_binders(e),null!==this._prev_time){var t=this._vary_curves.getVaryCurves(this._prev_time,e),r=!0,n=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;this._track_binders.get(s).updateBinders(e)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}}this._flush_dirty_binders(),this._prev_time=e}},{key:"_$register",value:function(e){this._dirty_binders.add(e)}},{key:"_$unregister",value:function(e){this._dirty_binders.delete(e)||this._track_binders.get(e._$curve).unregister(e)}},{key:"_update_dirty_binders",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,o=this._dirty_binders[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){i.value._$update(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"_flush_dirty_binders",value:function(){for(var e=0,t=Array.from(this._dirty_binders);e<t.length;e++){var r=t[e];this._dirty_binders.delete(r);var n=r._$curve,i=this._track_binders.get(n);void 0===i?(i=new Ts(this,n,r),this._track_binders.set(n,i)):i.register(r)}}}]),e}(),Ts=function(){function e(t,r,n){var i=this;ze(this,e),this._updater=t,this._curve=r,this._binders=new Set([n]),this._invariance=r.getInvariance(Ft.UNIVERSAL),this._listener=function(e){i._onValueChange(e)},r.addValueChangeListener(this._listener),t._vary_curves.addCurve(r,this._invariance)}return je(e,[{key:"register",value:function(e){this._binders.add(e)}},{key:"unregister",value:function(e){this._binders.delete(e),this._binders.size>0||(this._updater._vary_curves.removeCurve(this._curve,this._invariance),this._curve.removeValueChangeListener(this._listener),this._updater._track_binders.delete(this._curve))}},{key:"updateBinders",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,o=this._binders[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){i.value._$update(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"_onValueChange",value:function(e){if(e.includesTime(this._updater._prev_time))this._move_to_dirty_binders();else{var t=this._curve.getInvariance(e);this._updater._vary_curves.modifyCurve(this._curve,e,t,this._invariance),this._invariance._$modify(t)}}},{key:"_move_to_dirty_binders",value:function(){for(var e=0,t=Array.from(this._binders);e<t.length;e++){var r=t[e];this.unregister(r),this._updater._dirty_binders.add(r)}}}]),e}(),Is=function(){function e(){ze(this,e),this._continuous=Ls(),this._oneshot=Ls(),this._oneshot_L=Ls(),this._oneshot_R=Ls()}return je(e,[{key:"addCurve",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ft.UNIVERSAL,n=t.getNarrowed(r)._$getArray();if(0==n.length)this._addToGeneric(e,r);else{var i=n.length-1,o=n[0],a=r.getIntersection(o.getPrecedings());a.isEmpty()?Ms(r,o)&&!this._hasContiguous_L(o,e)&&(o.l_open?this._addToOneshotGroup(e,o,"_oneshot_R"):o.getPrecedings().isEmpty()||this._addToOneshotGroup(e,o,"_oneshot_L")):this._addToGeneric(e,a);for(var s=0;s<i;++s){var u=n[s].getFollowings(),l=n[s+1].getPrecedings(),_=u.getIntersection(l);_.isEmpty()?this._addToOneshotGroup(e,u,u.l_open?"_oneshot_R":"_oneshot_L"):this._addToGeneric(e,_)}var c=n[i],h=r.getIntersection(c.getFollowings());h.isEmpty()?Ss(r,c)&&!this._hasContiguous_R(c,e)&&(c.u_open?this._addToOneshotGroup(e,c,"_oneshot_L"):c.getFollowings().isEmpty()||this._addToOneshotGroup(e,c,"_oneshot_R")):this._addToGeneric(e,h)}}},{key:"_hasContiguous_L",value:function(e,t){var r=this._continuous,n=r.findLower(e.lower),i=null!==n?n.findPredecessor():r.findLast();if(null!==i){var o=i.value,a=o.interval;if(a.upper.equals(e.lower)&&(e.l_open&&!a.u_open||!e.l_open&&a.u_open)&&o.curves.has(t))return!0}return!1}},{key:"_hasContiguous_R",value:function(e,t){var r=this._continuous.findLower(e.upper);if(null===r)return!1;var n=r.value,i=n.interval;return!!i.lower.equals(e.upper)&&(!(i.l_open&&e.u_open||!i.l_open&&!e.u_open)&&n.curves.has(t))}},{key:"removeCurve",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ft.UNIVERSAL,n=t.getNarrowed(r)._$getArray();if(0==n.length)this._removeForGeneric(e,r);else{var i=n.length-1,o=n[0],a=r.getIntersection(o.getPrecedings());a.isEmpty()?Ms(r,o)&&this._removeForOneshotGroup(e,r):this._removeForGeneric(e,a);for(var s=0;s<i;++s){var u=n[s].getFollowings(),l=n[s+1].getPrecedings(),_=u.getIntersection(l);_.isEmpty()?this._removeForOneshotGroup(e,u):this._removeForGeneric(e,_)}var c=n[i],h=r.getIntersection(c.getFollowings());if(h.isEmpty()){if(Ss(r,c)){var f=r.upper;this._removeForOneshotGroup(e,new Ft(f,f))}}else this._removeForGeneric(e,h)}}},{key:"modifyCurve",value:function(e,t,r,n){var i=n._$expandIntervalByAlignment(t);this.removeCurve(e,n,i),this.addCurve(e,r,i)}},{key:"getVaryCurves",value:function(e,t){return e.lessThan(t)?this._collectCurves(e,t):t.lessThan(e)?this._collectCurves(t,e):[]}},{key:"_addToGeneric",value:function(e,t){t.isProper()?this._addToContinuous(e,t):t.isSingle()&&this._addToOneshotGroup(e,t,"_oneshot")}},{key:"_addToOneshotGroup",value:function(e,t,r){var n=this[r],i=t.lower,o=n.findEqual(i);null===o&&(o=n.insert(i,new Set)),o.value.add(e)}},{key:"_addToContinuous",value:function(e,t){for(var r=t,n=e;;){var i=this._removeFirstCrossInContinuous(r);if(null!==i){var o=i.cc.interval,a=i.cc.curves,s=i.cross,u=r.getPrecedings().getIntersection(o);if(u.isEmpty()){var l=r.getIntersection(o.getPrecedings());l.isEmpty()||this._addForContinuous(l,n)}else this._addForContinuous(u,new Set(a));var _=r.getFollowings().getIntersection(o);if(_.isEmpty()){this._addForContinuous(s,a.add(n));var c=r.getIntersection(o.getFollowings());if(!c.isEmpty()){r=c;continue}}else this._addForContinuous(_,new Set(a)),this._addForContinuous(s,a.add(n))}else this._addForContinuous(r,n);break}}},{key:"_removeFirstCrossInContinuous",value:function(e){var t=this._continuous,r=t.findUpper(e.lower),n=null!==r?r.findPredecessor():t.findLast();if(null!==n){var i=e.getIntersection(n.value.interval);if(!i.isEmpty()){var o=n.value;return t.remove(n),{cc:o,cross:i}}}if(null!==r){var a=e.getIntersection(r.value.interval);if(!a.isEmpty()){var s=r.value;return t.remove(r),{cc:s,cross:a}}}return null}},{key:"_addForContinuous",value:function(e,t){var r=e.lower;if(e.isSingle()){var n=this._oneshot.findEqual(r);null===n&&(n=this._oneshot.insert(r,new Set));var i=n.value;if(t instanceof Set){var o=!0,a=!1,s=void 0;try{for(var u,l=t[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var _=u.value;i.add(_)}}catch(e){a=!0,s=e}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}}else i.add(t)}else this._continuous.insert(r,new Ps(e,t))}},{key:"_removeForGeneric",value:function(e,t){t.isProper()?this._removeForContinuous(e,t):t.isSingle()&&this._removeForOneshotGroup(e,t)}},{key:"_removeForOneshotGroup",value:function(e,t){for(var r=t.lower,n=0,i=["_oneshot","_oneshot_L","_oneshot_R"];n<i.length;n++){var o=this[i[n]],a=o.findEqual(r);if(null!==a){var s=a.value;s.has(e)&&(s.delete(e),0==s.size&&o.remove(a));break}}}},{key:"_removeForContinuous",value:function(e,t){for(var r=this._continuous,n=r.findUpper(t.lower),i=null!==n?n.findPredecessor():r.findLast(),o=r.findUpper(t.upper),a=i||n;a!==o;){var s=a.value.curves;s.delete(e),a=0==s.size?r.remove(a):a.findSuccessor()}for(var u=this._oneshot,l=u.findLower(t.lower),_=u.findUpper(t.upper),c=l;c!==_;){var h=c.value;h.delete(e),c=0==h.size?u.remove(c):c.findSuccessor()}}},{key:"_collectCurves",value:function(e,t){var r=new Set;return this._collectContinuousCurves(e,t,r),this._collectOneshotCurves(e,t,"_oneshot",!0,!0,r),this._collectOneshotCurves(e,t,"_oneshot_L",!1,!0,r),this._collectOneshotCurves(e,t,"_oneshot_R",!0,!1,r),r}},{key:"_collectContinuousCurves",value:function(e,t,r){var n=this._continuous.findLower(e);if(null!==n){var i=n.findPredecessor();null!==i&&i.value.interval.includeTime(e)&&(n=i)}var o=this._continuous.findLower(t);if(null!==o){var a=o.value.interval;a.lower.equals(t)&&!a.l_open&&(o=o.findSuccessor())}for(var s=n;s!==o;s=s.findSuccessor()){var u=!0,l=!1,_=void 0;try{for(var c,h=s.value.curves[Symbol.iterator]();!(u=(c=h.next()).done);u=!0){var f=c.value;r.add(f)}}catch(e){l=!0,_=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw _}}}}},{key:"_collectOneshotCurves",value:function(e,t,r,n,i,o){for(var a=this[r],s=n?a.findLower(e):a.findUpper(e),u=n?a.findUpper(t):a.findLower(t),l=s;l!==u;l=l.findSuccessor()){var _=!0,c=!1,h=void 0;try{for(var f,d=l.value[Symbol.iterator]();!(_=(f=d.next()).done);_=!0){var v=f.value;o.add(v)}}catch(e){c=!0,h=e}finally{try{_||null==d.return||d.return()}finally{if(c)throw h}}}}}]),e}(),Ps=function e(t,r){ze(this,e),this.interval=t,this.curves=new Set(r instanceof Set?r:[r])};function Ls(){return new Qn((function(e,t){return e.lessThan(t)}))}function Ms(e,t){return e.lower.equals(t.lower)&&(e.l_open&&t.l_open||!e.l_open&&!t.l_open)}function Ss(e,t){return e.upper.equals(t.upper)&&(e.u_open&&t.u_open||!e.u_open&&!t.u_open)}var Rs,Cs,Ds=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e))).name="mapray.animation.TypeMismatchError",r}return qe(t,e),t}(rt),Os=function(){function e(t,r,n,i){if(ze(this,e),!r.isTypeSupported(n))throw new Ds("type mismatch error");this._updater=t,this._curve=r,this._type=n,this._setter=i,t._$register(this)}return je(e,[{key:"unbind",value:function(){this._updater._$unregister(this)}},{key:"_$update",value:function(e){var t=this._curve.getValue(e,this._type);(0,this._setter)(t)}},{key:"updater",get:function(){return this._updater}},{key:"curve",get:function(){return this._curve}},{key:"type",get:function(){return this._type}},{key:"setter",get:function(){return this._setter}},{key:"_$curve",get:function(){return this._curve}}]),e}(),Fs=oe("navigator","userAgent")||"",Ns=n.process,Vs=Ns&&Ns.versions,Us=Vs&&Vs.v8;Us?Cs=(Rs=Us.split("."))[0]+Rs[1]:Fs&&(!(Rs=Fs.match(/Edge\/(\d+)/))||Rs[1]>=74)&&(Rs=Fs.match(/Chrome\/(\d+)/))&&(Cs=Rs[1]);var Bs=Cs&&+Cs,zs=Qt("species"),Gs=function(e){return Bs>=51||!i((function(){var t=[];return(t.constructor={})[zs]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},js=Qt("isConcatSpreadable"),qs=Bs>=51||!i((function(){var e=[];return e[js]=!1,e.concat()[0]!==e})),Ys=Gs("concat"),Hs=function(e){if(!a(e))return!1;var t=e[js];return void 0!==t?!!t:Bt(e)};Re({target:"Array",proto:!0,forced:!qs||!Ys},{concat:function(e){var t,r,n,i,o,a=zt(this),s=or(a,0),u=0;for(t=-1,n=arguments.length;t<n;t++)if(o=-1===t?a:arguments[t],Hs(o)){if(u+(i=_e(o.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(r=0;r<i;r++,u++)r in o&&Es(s,u,o[r])}else{if(u>=9007199254740991)throw TypeError("Maximum allowed index exceeded");Es(s,u++,o)}return s.length=u,s}});var Xs=function(){function e(){ze(this,e)}return je(e,[{key:"enumSupportedParameters",value:function(){this._override_error("enumSupportedParameters")}},{key:"isBound",value:function(e){this._override_error("isBound")}},{key:"getBoundUpdater",value:function(e){this._override_error("getBoundUpdater")}},{key:"getBoundCurve",value:function(e){this._override_error("getBoundCurve")}},{key:"bind",value:function(e,t,r){this._override_error("bind")}},{key:"unbind",value:function(e){this._override_error("unbind")}},{key:"unbindAll",value:function(){this._override_error("unbindAll")}},{key:"unbindAllRecursively",value:function(){this._override_error("unbindAllRecursively")}},{key:"_override_error",value:function(e){throw new Error("BindingBlock#"+e+"() method has not been overridden in "+this.constructor.name)}}]),e}(),Ws=function(){function e(t,r){ze(this,e),this._id=t,this._types=r.concat()}return je(e,[{key:"id",get:function(){return this._id}},{key:"types",get:function(){return this._types}}]),e}();Xs.Parameter=Ws;var Qs=function(e){function t(){var e;return ze(this,t),(e=Je(this,Ye(t).call(this)))._entries=new Map,e._bounds=new Map,e._descendant_unbinders=[],e}return qe(t,e),je(t,[{key:"addEntry",value:function(e,t,r,n){this._entries.set(e,new Zs(t,r,n));var i=this._bounds.get(e);void 0!==i&&(i.unbind(),this._bounds.delete(e))}},{key:"addDescendantUnbinder",value:function(e){this._descendant_unbinders.push(e)}},{key:"enumSupportedParameters",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,o=this._entries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=$e(i.value,2),s=a[0],u=a[1];e.push(new Xs.Parameter(s,u.types))}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return e}},{key:"isBound",value:function(e){return this._bounds.has(e)}},{key:"getBoundUpdater",value:function(e){var t=this._bounds.get(e);return void 0!==t?t.updater:null}},{key:"getBoundCurve",value:function(e){var t=this._bounds.get(e);return void 0!==t?t.curve:null}},{key:"bind",value:function(e,t,r){var n=this._entries.get(e);if(void 0===n)throw new rt("unsupported parameter");this.unbind(e);var i=n.types,o=1==i.length?i[0]:n.type_solver(r);if(null==o||!r.isTypeSupported(o))throw new Ds("type mismatch error");this._bounds.set(e,new Os(t,r,o,n.setter))}},{key:"unbind",value:function(e){var t=this._bounds.get(e);void 0!==t&&t.unbind()}},{key:"unbindAll",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._bounds[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){$e(n.value,2)[1].unbind()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"unbindAllRecursively",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._descendant_unbinders[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){(0,n.value)()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}this.unbindAll()}}]),t}(Xs),Zs=function e(t,r,n){if(ze(this,e),t.length<1||t.length>=2&&!r)throw new rt("bad parameter entry");this.types=t.concat(),this.type_solver=r,this.setter=n},Js=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this)))._constant_type=e,n._constant_value=e.getDefaultValue(),void 0!==r&&n.setConstantValue(r),n}return qe(t,e),je(t,[{key:"setConstantValue",value:function(e){e!=this._constant_value&&(this._constant_value=this._constant_type.getCloneValue(e),this.notifyValueChange(Ft.UNIVERSAL))}},{key:"isTypeSupported",value:function(e){var t=this._constant_type;return e.isConvertible(t)}},{key:"getValue",value:function(e,t){var r=this._constant_type,n=r.getCloneValue(this._constant_value);return t.convertValue(r,n)}},{key:"getInvariance",value:function(e){return(new Jn).write(Ft.UNIVERSAL)}}]),t}(ws),Ks=function(){function e(){ze(this,e)}return je(e,null,[{key:"getDimension",value:function(e){return xi.find("number")===e?1:xi.find("vector2")===e?2:xi.find("vector3")===e?3:xi.find("vector4")===e?4:0}},{key:"findKeyFrameIndex",value:function(e,t,r,n){for(var i=r,o=n;;){if(!(o-i>=2)){var a=t[i];return e.lessThan(a)?i:o}var s=Math.floor((i+o)/2),u=t[s];if(u.lessThan(e))i=s;else{if(!e.lessThan(u))return s+1;o=s}}return 0}},{key:"findFirstTypeSupported",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;if(e.isTypeSupported(s))return s}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return null}}]),e}(),$s=function(e){function t(e,r){var n;ze(this,t),n=Je(this,Ye(t).call(this));var i=Ks.getDimension(e);if(0==i)throw rt("unsupported type");if(n._value_type=e,n._dimension=i,n._num_keyframes=void 0,n._key_times=void 0,n._key_values=void 0,void 0!==r)n.setKeyFrames(r);else{var o=St.fromNumber(0),a=St.fromNumber(1),s=e.getDefaultValue();n.setKeyFrames([o,s,a,s])}return n}return qe(t,e),je(t,[{key:"setKeyFrames",value:function(e){var t=this._dimension;this._num_keyframes=e.length/2,this._key_times=new Array(this._num_keyframes),this._key_values=new Float64Array(this._num_keyframes*t);for(var r=0,n=0;r<this._num_keyframes;++r,n+=t){var i=e[2*r],o=e[2*r+1];if(this._key_times[r]=i,1==t)this._key_values[n]=o;else for(var a=0;a<t;++a)this._key_values[n+a]=o[a]}this.notifyValueChange(Ft.UNIVERSAL)}},{key:"isTypeSupported",value:function(e){var t=this._value_type;return e.isConvertible(t)}},{key:"getValue",value:function(e,t){var r=this._value_type,n=this._getInterpolatedValue(e);return t.convertValue(r,n)}},{key:"getInvariance",value:function(e){var t=this._key_times[0],r=this._key_times[this._num_keyframes-1],n=new Ft(t,r,!0,!0),i=new Jn;return i.write(n.getPrecedings()),i.write(n.getFollowings()),i.getNarrowed(e)}},{key:"_getInterpolatedValue",value:function(e){var t=Ks.findKeyFrameIndex(e,this._key_times,0,this._num_keyframes);return 0==t?this._createKeyFrameValue(0):t==this._num_keyframes?this._createKeyFrameValue(t-1):this._createValueBy2Keys(t-1,t,e)}},{key:"_createKeyFrameValue",value:function(e){var t=this._dimension,r=this._key_values;if(1==t)return r[e];for(var n=t*e,i=new Float64Array(t),o=0;o<t;++o)i[o]=r[n+o];return i}},{key:"_createValueBy2Keys",value:function(e,t,r){var n=this._key_times[e].toNumber(),i=this._key_times[t].toNumber(),o=(r.toNumber()-n)/(i-n),a=1-o,s=this._dimension,u=this._key_values;if(1==s)return a*u[e]+o*u[t];for(var l=s*e,_=s*t,c=new Float64Array(s),h=0;h<s;++h)c[h]=a*u[l+h]+o*u[_+h];return c}}]),t}(ws),eu=function(e){function t(e,r){var n;if(ze(this,t),(n=Je(this,Ye(t).call(this)))._value_type=e,n._num_keyframes=void 0,n._key_times=void 0,n._key_values=void 0,void 0!==r)n.setKeyFrames(r);else{var i=St.fromNumber(0),o=e.getDefaultValue();n.setKeyFrames([i,o])}return n}return qe(t,e),je(t,[{key:"setKeyFrames",value:function(e){this._num_keyframes=e.length/2,this._key_times=new Array(this._num_keyframes),this._key_values=new Array(this._num_keyframes);for(var t=0;t<this._num_keyframes;++t){var r=e[2*t],n=e[2*t+1];this._key_times[t]=r,this._key_values[t]=this._value_type.getCloneValue(n)}this.notifyValueChange(Ft.UNIVERSAL)}},{key:"isTypeSupported",value:function(e){var t=this._value_type;return e.isConvertible(t)}},{key:"getValue",value:function(e,t){var r=this._value_type,n=this._getInterpolatedValue(e);return t.convertValue(r,n)}},{key:"getInvariance",value:function(e){if(1==this._num_keyframes)return(new Jn).write(Ft.UNIVERSAL);var t=new Jn,r=this._key_times[1];t.write(new Ft(r,r).getPrecedings());var n=this._key_times[this._num_keyframes-2],i=this._key_times[this._num_keyframes-1];return t.write(new Ft(n,i,!1,!0).getFollowings()),t.getNarrowed(e)}},{key:"_getInterpolatedValue",value:function(e){var t=Ks.findKeyFrameIndex(e,this._key_times,0,this._num_keyframes),r=t>0?t-1:0;return this._value_type.getCloneValue(this._key_values[r])}}]),t}(ws),tu=ur.map,ru=Gs("map"),nu=Kr("map");Re({target:"Array",proto:!0,forced:!ru||!nu},{map:function(e){return tu(this,e,arguments.length>1?arguments[1]:void 0)}});var iu=function(e){function t(e,r){var n;ze(this,t),n=Je(this,Ye(t).call(this));var i=Ks.getDimension(e);if(i<2&&i>4)throw new Ds("unexpected type");return n._vector_type=e,n._dimension=i,n._children=new Array(i),n._listeners=new Array(i),n._setupInitialChildren(),void 0!==r&&n.setChildren(r),n}return qe(t,e),je(t,[{key:"setChild",value:function(e,t){this._setChildCommon(e,t),this.notifyValueChange(Ft.UNIVERSAL)}},{key:"setChildren",value:function(e){for(var t=0;t<this._dimension;++t)this._setChildCommon(t,e[t]);this.notifyValueChange(Ft.UNIVERSAL)}},{key:"isTypeSupported",value:function(e){var t=this._vector_type;return e.isConvertible(t)}},{key:"getValue",value:function(e,t){var r=this._vector_type,n=this._getCompoundValue(e);return t.convertValue(r,n)}},{key:"getInvariance",value:function(e){var t=this._children.map((function(t){return t.getInvariance(e)}));return Jn.merge(t)}},{key:"_setupInitialChildren",value:function(){for(var e=this,t=new Js(ou),r=0;r<this._dimension;++r){var n=function(t){e.notifyValueChange(t)};t.addValueChangeListener(n),this._children[r]=t,this._listeners[r]=n}}},{key:"_setChildCommon",value:function(e,t){var r=this;if(!t.isTypeSupported(ou))throw new Ds("type mismatch error");var n=this._children[e],i=this._listeners[e];n.removeValueChangeListener(i);var o=function(e){r.notifyValueChange(e)};t.addValueChangeListener(o),this._children[e]=t,this._listeners[e]=o}},{key:"_getCompoundValue",value:function(e){for(var t=this._dimension,r=new Float64Array(t),n=0;n<t;++n)r[n]=this._children[n].getValue(e,ou);return r}}]),t}(ws),ou=xi.find("number"),au={AnimationError:rt,Time:St,Interval:Ft,Invariance:Jn,Type:xi,Curve:ws,Updater:As,Binder:Os,TypeMismatchError:Ds,BindingBlock:Xs,EasyBindingBlock:Qs,ConstantCurve:Js,KFLinearCurve:$s,KFStepCurve:eu,ComboVectorCurve:iu},su=function e(t,r){ze(this,e),this.position=t||cs.createVector3(),this.direction=r||cs.createVector3([0,0,-1])},uu=function(){function e(t){ze(this,e),this._canvas=t,this.fov=46,this.near=1,this.far=1e3,this.view_to_gocs=cs.createMatrix(),cs.setIdentity(this.view_to_gocs)}return je(e,[{key:"getCanvasToView",value:function(e){var t=e||cs.createMatrix(),r=this._canvas.width,n=this._canvas.height,i=this.near,o=this.far,a=this.fov*cs.DEGREE/2,s=n/r,u=i*Math.tan(a)/Math.sqrt(1+s*s),l=u*s;return t[0]=2*u/(i*r),t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l/(i*n),t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=(i-o)/(i*o),t[12]=-u/i,t[13]=l/i,t[14]=-1,t[15]=1/i,t}},{key:"getCanvasToGocs",value:function(e){var t=this.getCanvasToView(e),r=t[0],n=t[5],i=t[11],o=t[12],a=t[13],s=t[15],u=this.view_to_gocs,l=u[0],_=u[1],c=u[2],h=u[4],f=u[5],d=u[6],v=u[8],y=u[9],p=u[10],g=u[12],m=u[13],k=u[14],w=t;return w[0]=l*r,w[1]=_*r,w[2]=c*r,w[4]=h*n,w[5]=f*n,w[6]=d*n,w[8]=g*i,w[9]=m*i,w[10]=k*i,w[12]=l*o+h*a-v+g*s,w[13]=_*o+f*a-y+m*s,w[14]=c*o+d*a-p+k*s,w}},{key:"getViewToCanvas",value:function(e){var t=e||cs.createMatrix(),r=this._canvas.width,n=this._canvas.height,i=this.near,o=this.far,a=this.fov*cs.DEGREE/2,s=n/r,u=i*Math.tan(a)/Math.sqrt(1+s*s),l=u*s;return t[0]=i*r/(2*u),t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-i*n/(2*l),t[6]=0,t[7]=0,t[8]=-r/2,t[9]=-n/2,t[10]=o/(i-o),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*o/(i-o),t[15]=0,t}},{key:"getCanvasRay",value:function(t,r){var n=t[0],i=t[1],o=r||new su,a=this.getCanvasToGocs(e._temp_mat),s=n*a[0]+i*a[4]+a[12],u=n*a[1]+i*a[5]+a[13],l=n*a[2]+i*a[6]+a[14],_=n*a[3]+i*a[7]+a[15],c=o.position;c[0]=s/_,c[1]=u/_,c[2]=l/_;var h=this.view_to_gocs,f=o.direction;return f[0]=c[0]-h[12],f[1]=c[1]-h[13],f[2]=c[2]-h[14],cs.normalize3(f,f),o}},{key:"createRenderInfo",value:function(){var e=this._canvas;return new lu(this,e.width,e.height)}}]),e}();uu._temp_mat=cs.createMatrix();var lu=function(){function e(t,r,n){ze(this,e),this._view_to_clip=cs.createMatrix(),this._volume_planes=[];for(var i=0;i<6;++i)this._volume_planes.push(cs.createVector4());this._pixel_step=0,this._setup_view_to_clip(t,r,n),this._setup_volume_planes(),this._setup_pixel_step(r,n)}return je(e,[{key:"_setup_view_to_clip",value:function(e,t,r){var n=e.fov*cs.DEGREE/2,i=r/t,o=e.near*Math.tan(n)/Math.sqrt(1+i*i),a=-o,s=o,u=-o*i,l=o*i;cs.frustum_matrix(a,s,u,l,e.near,e.far,this._view_to_clip)}},{key:"_setup_volume_planes",value:function(){var e=this._view_to_clip,t=this._volume_planes;this._add_matrix_rows(e,3,2,t[0]),this._sub_matrix_rows(e,3,2,t[1]),this._add_matrix_rows(e,3,0,t[2]),this._sub_matrix_rows(e,3,0,t[3]),this._add_matrix_rows(e,3,1,t[4]),this._sub_matrix_rows(e,3,1,t[5]);for(var r=0;r<6;++r){var n=t[r],i=n[0],o=n[1],a=n[2],s=1/Math.sqrt(i*i+o*o+a*a);n[0]*=s,n[1]*=s,n[2]*=s,n[3]*=s}}},{key:"_setup_pixel_step",value:function(e,t){var r=this._view_to_clip,n=r[0],i=r[5],o=r[11],a=2*(r[15]-o),s=a/(n*e),u=a/(i*t);this._pixel_step=Math.sqrt(s*s+u*u)*Math.SQRT1_2}},{key:"_add_matrix_rows",value:function(e,t,r,n){return n[0]=e[t]+e[r],n[1]=e[t+4]+e[r+4],n[2]=e[t+8]+e[r+8],n[3]=e[t+12]+e[r+12],n}},{key:"_sub_matrix_rows",value:function(e,t,r,n){return n[0]=e[t]-e[r],n[1]=e[t+4]-e[r+4],n[2]=e[t+8]-e[r+8],n[3]=e[t+12]-e[r+12],n}},{key:"view_to_clip",get:function(){return this._view_to_clip}},{key:"volume_planes",get:function(){return this._volume_planes}},{key:"pixel_step",get:function(){return this._pixel_step}}]),e}(),_u=function(){function e(t){ze(this,e);var r=this._getContextWebGL(t,{depth:!0,antialias:!0});if(!r)throw new Error("It doesn't appear your computer can support WebGL.");this._canvas=t,this._context=r,this._setupExtensions(r)}return je(e,[{key:"_getContextWebGL",value:function(e,t){for(var r=["webgl","experimental-webgl"],n=0;n<r.length;++n){var i=e.getContext(r[n],t);if(i)return i}return null}},{key:"_setupExtensions",value:function(e){this.OES_element_index_uint=e.getExtension("OES_element_index_uint"),this.EXT_texture_filter_anisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")}},{key:"canvas",get:function(){return this._canvas}},{key:"context",get:function(){return this._context}}]),e}(),cu=ur.forEach,hu=xa("forEach"),fu=Kr("forEach"),du=hu&&fu?[].forEach:function(e){return cu(this,e,arguments.length>1?arguments[1]:void 0)};Re({target:"Array",proto:!0,forced:[].forEach!=du},{forEach:du});var vu=Gs("slice"),yu=Kr("slice",{ACCESSORS:!0,0:0,1:2}),pu=Qt("species"),gu=[].slice,mu=Math.max;Re({target:"Array",proto:!0,forced:!vu||!yu},{slice:function(e,t){var r,n,i,o=ee(this),s=_e(o.length),u=fe(e,s),l=fe(void 0===t?s:t,s);if(Bt(o)&&("function"!=typeof(r=o.constructor)||r!==Array&&!Bt(r.prototype)?a(r)&&null===(r=r[pu])&&(r=void 0):r=void 0,r===Array||void 0===r))return gu.call(o,u,l);for(n=new(void 0===r?Array:r)(mu(l-u,0)),i=0;u<l;u++,i++)u in o&&Es(n,i,o[u]);return n.length=i,n}});var ku=[],wu=ku.sort,Eu=i((function(){ku.sort(void 0)})),bu=i((function(){ku.sort(null)})),xu=xa("sort");Re({target:"Array",proto:!0,forced:Eu||!bu||!xu},{sort:function(e){return void 0===e?wu.call(zt(this)):wu.call(zt(this),rr(e))}});var Au=Gs("splice"),Tu=Kr("splice",{ACCESSORS:!0,0:0,1:2}),Iu=Math.max,Pu=Math.min;Re({target:"Array",proto:!0,forced:!Au||!Tu},{splice:function(e,t){var r,n,i,o,a,s,u=zt(this),l=_e(u.length),_=fe(e,l),c=arguments.length;if(0===c?r=n=0:1===c?(r=0,n=l-_):(r=c-2,n=Pu(Iu(ue(t),0),l-_)),l+r-n>9007199254740991)throw TypeError("Maximum allowed length exceeded");for(i=or(u,n),o=0;o<n;o++)(a=_+o)in u&&Es(i,o,u[a]);if(i.length=n,r<n){for(o=_;o<l-n;o++)s=o+r,(a=o+n)in u?u[s]=u[a]:delete u[s];for(o=l;o>l-n+r;o--)delete u[o-1]}else if(r>n)for(o=l-n;o>_;o--)s=o+r-1,(a=o+n-1)in u?u[s]=u[a]:delete u[s];for(o=0;o<r;o++)u[o+_]=arguments[o+2];return u.length=l-n+r,i}});var Lu=Math.expm1,Mu=Math.exp,Su=!Lu||Lu(10)>22025.465794806718||Lu(10)<22025.465794806718||-2e-17!=Lu(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:Mu(e)-1}:Lu,Ru=Math.cosh,Cu=Math.abs,Du=Math.E;Re({target:"Math",stat:!0,forced:!Ru||Ru(710)===1/0},{cosh:function(e){var t=Su(Cu(e)-1)+1;return(t+1/(t*Du*Du))*(Du/2)}});var Ou=function(){var e=c(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t};function Fu(e,t){return RegExp(e,t)}var Nu={UNSUPPORTED_Y:i((function(){var e=Fu("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),BROKEN_CARET:i((function(){var e=Fu("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},Vu=RegExp.prototype.exec,Uu=String.prototype.replace,Bu=Vu,zu=function(){var e=/a/,t=/b*/g;return Vu.call(e,"a"),Vu.call(t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Gu=Nu.UNSUPPORTED_Y||Nu.BROKEN_CARET,ju=void 0!==/()??/.exec("")[1];(zu||ju||Gu)&&(Bu=function(e){var t,r,n,i,o=this,a=Gu&&o.sticky,s=Ou.call(o),u=o.source,l=0,_=e;return a&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),_=String(e).slice(o.lastIndex),o.lastIndex>0&&(!o.multiline||o.multiline&&"\n"!==e[o.lastIndex-1])&&(u="(?: "+u+")",_=" "+_,l++),r=new RegExp("^(?:"+u+")",s)),ju&&(r=new RegExp("^"+u+"$(?!\\s)",s)),zu&&(t=o.lastIndex),n=Vu.call(a?r:o,_),a?n?(n.input=n.input.slice(l),n[0]=n[0].slice(l),n.index=o.lastIndex,o.lastIndex+=n[0].length):o.lastIndex=0:zu&&n&&(o.lastIndex=o.global?n.index+n[0].length:t),ju&&n&&n.length>1&&Uu.call(n[0],r,(function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(n[i]=void 0)})),n});var qu=Bu;Re({target:"RegExp",proto:!0,forced:/./.exec!==qu},{exec:qu});var Yu=Qt("species"),Hu=!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})),Xu="$0"==="a".replace(/./,"$0"),Wu=Qt("replace"),Qu=!!/./[Wu]&&""===/./[Wu]("a","$0"),Zu=!i((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]})),Ju=Fn.charAt,Ku=function(e,t,r){return t+(r?Ju(e,t).length:1)},$u=function(e,t){var r=e.exec;if("function"==typeof r){var n=r.call(e,t);if("object"!=typeof n)throw TypeError("RegExp exec method returned something other than an Object or null");return n}if("RegExp"!==Z(e))throw TypeError("RegExp#exec called on incompatible receiver");return qu.call(e,t)};for(var el in function(e,t,r,n){var o=Qt(e),a=!i((function(){var t={};return t[o]=function(){return 7},7!=""[e](t)})),s=a&&!i((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Yu]=function(){return r},r.flags="",r[o]=/./[o]),r.exec=function(){return t=!0,null},r[o](""),!t}));if(!a||!s||"replace"===e&&(!Hu||!Xu||Qu)||"split"===e&&!Zu){var u=/./[o],l=r(o,""[e],(function(e,t,r,n,i){return t.exec===qu?a&&!i?{done:!0,value:u.call(t,r,n)}:{done:!0,value:e.call(r,t,n)}:{done:!1}}),{REPLACE_KEEPS_$0:Xu,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Qu}),_=l[0],c=l[1];G(String.prototype,e,_),G(RegExp.prototype,o,2==t?function(e,t){return c.call(e,this,t)}:function(e){return c.call(e,this)})}n&&y(RegExp.prototype[o],"sham",!0)}("match",1,(function(e,t,r){return[function(t){var r=$(this),n=null==t?void 0:t[e];return void 0!==n?n.call(t,r):new RegExp(t)[e](String(r))},function(e){var n=r(t,e,this);if(n.done)return n.value;var i=c(e),o=String(this);if(!i.global)return $u(i,o);var a=i.unicode;i.lastIndex=0;for(var s,u=[],l=0;null!==(s=$u(i,o));){var _=String(s[0]);u[l]=_,""===_&&(i.lastIndex=Ku(o,_e(i.lastIndex),a)),l++}return 0===l?null:u}]})),zn){var tl=n[el],rl=tl&&tl.prototype;if(rl&&rl.forEach!==du)try{y(rl,"forEach",du)}catch(e){rl.forEach=du}}Re({global:!0,forced:!Si},{DataView:vo.DataView});var nl=function(){function e(t,r,n){ze(this,e);var i=Math.pow(2,t.z-1),o=1<<r;this._sx=i/Math.PI*o,this._sy=-this._sx,this._ox=(i-t.x)*o,this._oy=(i-t.y)*o,this._body=n,this._pitch=4*(o+1),this._max=o}return je(e,[{key:"sample",value:function(e,t){return 0}}]),e}(),il=function(e){function t(e,r,n){return ze(this,t),Je(this,Ye(t).call(this,e,r,n))}return qe(t,e),je(t,[{key:"sample",value:function(e,t){var r=this._sx*e+this._ox,n=Math.floor(r),i=n+1,o=this._sy*t+this._oy,a=Math.floor(o),s=a+1,u=r-n,l=o-a;return(this._sampleInt(n,a)*(1-u)+this._sampleInt(i,a)*u)*(1-l)+(this._sampleInt(n,s)*(1-u)+this._sampleInt(i,s)*u)*l}},{key:"_sampleInt",value:function(e,t){var r=cs.clamp(e,0,this._max),n=cs.clamp(t,0,this._max),i=this._pitch*n+4*r;return this._body.getFloat32(i,!0)}}]),t}(nl),ol=function(e){function t(e,r,n){return ze(this,t),Je(this,Ye(t).call(this,e,r,n))}return qe(t,e),je(t,[{key:"sample",value:function(e,t){var r=Math.round(this._sx*e+this._ox),n=Math.round(this._sy*t+this._oy),i=this._pitch*n+4*r;return this._body.getFloat32(i,!0)}}]),t}(nl),al=function(){function e(t,r){if(ze(this,e),this._ρ=t,this._maps=[],t>=1){var n=this._create_first_map(r);this._maps.push(n);for(var i=n,o=-2;o>=-t;--o){var a=this._create_next_map(o,i);this._maps.push(a),i=a}}}return je(e,[{key:"_create_first_map",value:function(e){for(var t=1<<this._ρ-1,r=new Float32Array(t*t),n=4*(2*t+1),i=t,o=0;o<t;++o)for(var a=2*o*n,s=o*i,u=0;u<t;++u){var l=e.getFloat32(a,!0),_=e.getFloat32(a+4,!0),c=e.getFloat32(a+8,!0),h=e.getFloat32(a+n,!0),f=e.getFloat32(a+n+4,!0),d=e.getFloat32(a+n+8,!0),v=e.getFloat32(a+2*n,!0),y=e.getFloat32(a+2*n+4,!0),p=e.getFloat32(a+2*(n+4),!0);r[s]=(l+2*_+c+2*h+4*f+2*d+v+2*y+p)/16,a+=8,s+=1}return r}},{key:"_create_next_map",value:function(e,t){for(var r=1<<this._ρ+e,n=new Float32Array(r*r),i=2*r,o=r,a=0;a<r;++a)for(var s=2*a*i,u=a*o,l=0;l<r;++l){var _=t[s],c=t[s+1],h=t[s+i],f=t[s+i+1];n[u]=(_+c+h+f)/4,s+=2,u+=1}return n}},{key:"sample",value:function(e,t,r){return this._maps[this._ρ-e-1][r*(1<<e)+t]}}]),e}(),sl=function(){function e(t,r,n,i,o){ze(this,e),this._z=t,this._x=r,this._y=n,this._ρ=i;var a=new DataView(o);this._qlevels=[a.getUint8(e.OFFSET_QLEVEL_00),a.getUint8(e.OFFSET_QLEVEL_10),a.getUint8(e.OFFSET_QLEVEL_01),a.getUint8(e.OFFSET_QLEVEL_11)],this._hmin=a.getFloat32(e.OFFSET_HMIN,!0),this._hmax=a.getFloat32(e.OFFSET_HMAX,!0),this._ω=this._createωArray(a),this._body=new DataView(o,e.HEADER_BYTES),this._size=1+(1<<i)}return je(e,[{key:"isLeaf",value:function(e,t,r){if(e>this._z)return 0==this.getQuadLevel(e,t,r);var n=this._qlevels;return 0==n[0]||0==n[1]||0==n[2]||0==n[3]}},{key:"getQuadLevel",value:function(e,t,r){var n=Math.pow(2,this._z-e),i=Math.floor(2*((t+.5)*n-this._x)),o=Math.floor(2*((r+.5)*n-this._y));return this._qlevels[2*o+i]}},{key:"getQuadLevelDirect",value:function(e,t){var r=Math.round(Math.pow(2,this._z+1)),n=cs.clamp(Math.floor(e*r),0,r-1)%2,i=cs.clamp(Math.floor(t*r),0,r-1)%2;return this._qlevels[2*i+n]}},{key:"getHeights",value:function(t,r){var n=4*(r*this._size+t),i=4*this._size,o=e._getHeights_result;return o[0]=this._body.getFloat32(n,!0),o[1]=this._body.getFloat32(n+4,!0),o[2]=this._body.getFloat32(n+i,!0),o[3]=this._body.getFloat32(n+i+4,!0),o}},{key:"getDivisionPowers",value:function(t,r,n,i){var o=t.z,a=this._z,s=cs.LOG2PI-this._ρ+1,u=this._getComplexity(o,t.x,t.y),l=Math.min(a+this._ρ,Math.round(r+s+u))-o,_=e._getDivisionPowers_result;return _[0]=Math.max(n,l),_[1]=Math.max(i,l),_}},{key:"newSampler",value:function(e){return new(e.z-this._z>this._ρ?il:ol)(this,this._ρ,this._body)}},{key:"newLinearSampler",value:function(){return new il(this,this._ρ,this._body)}},{key:"newAvgHeightMaps",value:function(){return new al(this._ρ,this._body)}},{key:"_createωArray",value:function(t){for(var r=[],n=0,i=0;i<3;++i){for(var o=1<<2*i,a=new Float32Array(o),s=0;s<o;++s)a[s]=t.getFloat32(e.OFFSET_ω+n,!0),n+=4;r.push(a)}return r}},{key:"_getComplexity",value:function(t,r,n){var i,o,a=t-this._z,s=Math.round(Math.pow(2,a));a<=2?(i=r-s*this._x,o=n-s*this._y):(i=Math.floor(4*((r+.5)/s-this._x)),o=Math.floor(4*((n+.5)/s-this._y)));var u=Math.min(a,2),l=this._ω[u];return Math.min(l[o*(1<<u)+i],e.ω_limit)}},{key:"z",get:function(){return this._z}},{key:"x",get:function(){return this._x}},{key:"y",get:function(){return this._y}},{key:"height_min",get:function(){return this._hmin}},{key:"height_max",get:function(){return this._hmax}}]),e}();sl.OFFSET_QLEVEL_00=0,sl.OFFSET_QLEVEL_10=1,sl.OFFSET_QLEVEL_01=2,sl.OFFSET_QLEVEL_11=3,sl.OFFSET_HMIN=4,sl.OFFSET_HMAX=8,sl.OFFSET_ω=12,sl.HEADER_BYTES=96,sl.ω_limit=6,sl._getHeights_result=new Array(4),sl._getDivisionPowers_result=new Array(2),Ho("Int16",(function(e){return function(t,r,n){return e(this,t,r,n)}})),Ho("Int32",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var ul=function(){function e(){ze(this,e)}return je(e,null,[{key:"getCenter",value:function(e,t){switch(e.z){case 0:return function(e){return e[0]=0,e[1]=0,e[2]=0,e}(t);case 1:return function(e,t,r){var n=cs.EARTH_RADIUS;return r[0]=0,r[1]=n*(e-.5),r[2]=n*(.5-t),r}(e.x,e.y,t);default:return function(e,t,r,n){var i=Math.PI,o=Math.pow(2,1-e)*i,a=i-(r+1)*o,s=i-r*o,u=t*o-i,l=(t+1)*o-i,_=Math.exp(a),c=Math.exp(s),h=_*_,f=c*c,d=cs.EARTH_RADIUS/2,v=2*_/(h+1),y=2*c/(f+1);a+s<0?u+l<-i?(n[0]=d*(y*Math.cos(u)+v*Math.cos(l)),n[1]=d*(y*Math.sin(l)+v*Math.sin(u))):u+l<0?(n[0]=d*(v*Math.cos(u)+y*Math.cos(l)),n[1]=d*(y*Math.sin(u)+v*Math.sin(l))):u+l<i?(n[0]=d*(v*Math.cos(l)+y*Math.cos(u)),n[1]=d*(v*Math.sin(u)+y*Math.sin(l))):(n[0]=d*(y*Math.cos(l)+v*Math.cos(u)),n[1]=d*(v*Math.sin(l)+y*Math.sin(u))):u+l<-i?(n[0]=d*(v*Math.cos(u)+y*Math.cos(l)),n[1]=d*(v*Math.sin(l)+y*Math.sin(u))):u+l<0?(n[0]=d*(y*Math.cos(u)+v*Math.cos(l)),n[1]=d*(v*Math.sin(u)+y*Math.sin(l))):u+l<i?(n[0]=d*(y*Math.cos(l)+v*Math.cos(u)),n[1]=d*(y*Math.sin(u)+v*Math.sin(l))):(n[0]=d*(v*Math.cos(l)+y*Math.cos(u)),n[1]=d*(y*Math.sin(l)+v*Math.sin(u)));return n[2]=2*d*(f/(f+1)-1/(h+1)),n}(e.z,e.x,e.y,t)}}}]),e}();var ll=function(){function e(t,r,n,i){ze(this,e);var o=t.context;this._center=this._createCenter(r),this._vertices=null,this._num_vertices=0,this._vertex_attribs={},this._num_quads_x=0,this._num_quads_y=0,this._createVertices(o,r,n,i),this._setupVertexAttribs(o),this._index_type=this._num_vertices<65536?o.UNSIGNED_SHORT:o.UNSIGNED_INT,this._indices=null,this._num_indices=0,this._wire_indices=null,this._num_wire_indices=0,this._gl=o}return je(e,[{key:"_createCenter",value:function(e){return ul.getCenter(e,cs.createVector3())}},{key:"_createVertices",value:function(e,t,r,n){var i=e.ARRAY_BUFFER,o=e.createBuffer(),a=this._createVerticesData(t,r,n);e.bindBuffer(i,o),e.bufferData(i,a.array,e.STATIC_DRAW),e.bindBuffer(i,null),this._vertices=o,this._num_vertices=a.num_vertices,this._num_quads_x=a.num_quads_x,this._num_quads_y=a.num_quads_y}},{key:"_createVerticesData",value:function(t,r,n){for(var i=Math.pow(2,1-t.z)*Math.PI,o=t.x*i-Math.PI,a=Math.PI-(t.y+1)*i,s=1<<r[0],u=1<<r[1],l=1/s,_=1/u,c=i/s,h=i/u,f=this._center,d=n.newSampler(t),v=(s+1)*(u+1),y=new Float32Array(e.VERTEX_SIZE*v),p=0,g=0,m=a;g<u+1;++g,m+=h)for(var k=Math.exp(m),w=k*k,E=(w-1)/(w+1),b=2*k/(w+1),x=0,A=o;x<s+1;++x,A+=c){var T=Math.sin(A),I=Math.cos(A),P=d.sample(A,m),L=cs.EARTH_RADIUS+P,M=b*I,S=b*T,R=E,C=L*M,D=L*S,O=L*R;y[p++]=C-f[0],y[p++]=D-f[1],y[p++]=O-f[2],y[p++]=M,y[p++]=S,y[p++]=R,y[p++]=x*l,y[p++]=g*_}return{array:y,num_vertices:v,num_quads_x:s,num_quads_y:u}}},{key:"_setupVertexAttribs",value:function(t){var r=t.FLOAT,n=e.VERTEX_BYTES;this._vertex_attribs={a_position:{buffer:this._vertices,num_components:3,component_type:r,normalized:!1,byte_stride:n,byte_offset:e.OFFSET_P},a_normal:{buffer:this._vertices,num_components:3,component_type:r,normalized:!1,byte_stride:n,byte_offset:e.OFFSET_N},a_uv:{buffer:this._vertices,num_components:2,component_type:r,normalized:!1,byte_stride:n,byte_offset:e.OFFSET_UV}}}},{key:"_createIndices",value:function(){for(var e=this._gl,t=6*(this._num_quads_x*this._num_quads_y),r=new(this._index_type===e.UNSIGNED_INT?Int32Array:Int16Array)(t),n=0,i=0;i<this._num_quads_y;++i)for(var o=0;o<this._num_quads_x;++o){var a=(this._num_quads_x+1)*i+o,s=a+1,u=a+this._num_quads_x+1,l=u+1;r[n++]=a,r[n++]=s,r[n++]=u,r[n++]=u,r[n++]=s,r[n++]=l}var _=e.ELEMENT_ARRAY_BUFFER,c=e.createBuffer();e.bindBuffer(_,c),e.bufferData(_,r,e.STATIC_DRAW),e.bindBuffer(_,null),this._indices=c,this._num_indices=t}},{key:"_createWireIndices",value:function(){for(var e=this._gl,t=this._index_type===e.UNSIGNED_INT?Int32Array:Int16Array,r=2*(2*this._num_quads_x*this._num_quads_y+this._num_quads_x+this._num_quads_y),n=new t(r),i=0,o=0;o<this._num_quads_y+1;++o)for(var a=0;a<this._num_quads_x;++a){var s=(this._num_quads_x+1)*o+a,u=s+1;n[i++]=s,n[i++]=u}for(a=0;a<this._num_quads_x+1;++a)for(o=0;o<this._num_quads_y;++o){var l=(this._num_quads_x+1)*o+a,_=l+this._num_quads_x+1;n[i++]=l,n[i++]=_}var c=e.ELEMENT_ARRAY_BUFFER,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,n,e.STATIC_DRAW),e.bindBuffer(c,null),this._wire_indices=h,this._num_wire_indices=r}},{key:"dispose",value:function(){var e=this._gl;this._vertex_attribs={},e.deleteBuffer(this._vertices),this._vertices=null,this._indices&&(e.deleteBuffer(this._indices),this._indices=null),this._wire_indices&&(e.deleteBuffer(this._wire_indices),this._wire_indices=null)}},{key:"mul_flake_to_gocs",value:function(e,t){var r=e[0],n=e[4],i=e[8],o=e[12],a=e[1],s=e[5],u=e[9],l=e[13],_=e[2],c=e[6],h=e[10],f=e[14],d=e[3],v=e[7],y=e[11],p=e[15],g=this._center[0],m=this._center[1],k=this._center[2];return t[0]=r,t[1]=a,t[2]=_,t[3]=d,t[4]=n,t[5]=s,t[6]=c,t[7]=v,t[8]=i,t[9]=u,t[10]=h,t[11]=y,t[12]=r*g+n*m+i*k+o,t[13]=a*g+s*m+u*k+l,t[14]=_*g+c*m+h*k+f,t[15]=d*g+v*m+y*k+p,t}},{key:"draw",value:function(e){var t=this._gl,r=e.isWireframe();e.bindVertexAttribs(this._vertex_attribs);var n=r?this.wire_indices:this.indices;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n);var i=r?t.LINES:t.TRIANGLES,o=r?this.num_wire_indices:this.num_indices;t.drawElements(i,o,this._index_type,0)}},{key:"num_vertices",get:function(){return this._num_vertices}},{key:"indices",get:function(){return null===this._indices&&this._createIndices(),this._indices}},{key:"num_indices",get:function(){return null===this._indices&&this._createIndices(),this._num_indices}},{key:"wire_indices",get:function(){return null===this._wire_indices&&this._createWireIndices(),this._wire_indices}},{key:"num_wire_indices",get:function(){return null===this._wire_indices&&this._createWireIndices(),this._num_wire_indices}}]),e}();ll.VERTEX_SIZE=8,ll.VERTEX_BYTES=4*ll.VERTEX_SIZE,ll.OFFSET_P=0,ll.OFFSET_N=12,ll.OFFSET_UV=24;var _l=function(){function e(t,r,n,i){ze(this,e),this._glenv=t,this.mesh=r,this.material=n,this.transform=i,this.pivot=null,this.bbox=null,this.properties=null,this.sort_z=void 0}return je(e,[{key:"fastClone",value:function(){var t=new e(this._glenv,this.mesh,this.material,cs.createMatrix(this.transform));return this.pivot&&(t.pivot=cs.createVector3(this.pivot)),this.bbox&&(t.bbox=this.bbox.map((function(e){return cs.createVector3(e)}))),t.properties=this.properties,t}},{key:"isVisible",value:function(t){var r=e._obj_to_view;cs.mul_AA(t._gocs_to_view,this.transform,r);var n=this.bbox;if(n){e._transformBBox(n,r);for(var i=t._volume_planes,o=0;o<i.length;++o)if(e._isBBoxBackSide(i[o]))return!1}var a=this.pivot;return this.sort_z=a?r[2]*a[0]+r[6]*a[1]+r[10]*a[2]+r[14]:r[14],!0}},{key:"isTranslucent",value:function(e){return this.material.isTranslucent(e,this)}},{key:"draw",value:function(e){var t=this.material;t.bindProgram(),t.setParameters(e,this),this.mesh.draw(t)}}],[{key:"_transformBBox",value:function(t,r){for(var n=0;n<2;++n)for(var i=t[n][2],o=0;o<2;++o)for(var a=t[o][1],s=0;s<2;++s){var u=t[s][0],l=e._bbox_points[s+2*o+4*n];l[0]=r[0]*u+r[4]*a+r[8]*i+r[12],l[1]=r[1]*u+r[5]*a+r[9]*i+r[13],l[2]=r[2]*u+r[6]*a+r[10]*i+r[14]}}},{key:"_isBBoxBackSide",value:function(t){for(var r=e._bbox_points,n=0;n<r.length;++n){var i=r[n];if(i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+t[3]>=0)return!1}return!0}}]),e}();_l._obj_to_view=cs.createMatrix(),_l._bbox_points=[];for(var cl=0;cl<8;++cl)_l._bbox_points.push(cs.createVector3());var hl=function(){function e(t,r,n){ze(this,e),this.z=t.z,this.x=t.x,this.y=t.y,this._glenv=r,this._base_mesh=n,this._edata_list=[],this._transform=null}return je(e,[{key:"addEntityData",value:function(e,t){var r={mesh:e,producer:t};this._edata_list.push(r)}},{key:"getBaseMesh",value:function(){return this._base_mesh}},{key:"getEntityPrimitive",value:function(e,t){var r=this._edata_list[e],n=r.producer.getMaterialAndProperties(t),i=n.material,o=n.properties;if(null===this._transform){this._transform=cs.setIdentity(cs.createMatrix());var a=ul.getCenter(this,cs.createVector3());this._transform[12]=a[0],this._transform[13]=a[1],this._transform[14]=a[2]}var s=new _l(this._glenv,r.mesh,i,this._transform);return s.properties=o,s}},{key:"num_entities",get:function(){return this._edata_list.length}}]),e}();Re({target:"Array",proto:!0},{fill:Bi}),Wr("fill"),Ho("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var fl=function(){function e(){ze(this,e),this._area_list=[],this._flat_area_list=null}return je(e,[{key:"isEmpty",value:function(){return 0==this._area_list.length}},{key:"clear",value:function(){this._area_list.length=0,this._flat_area_list=null}},{key:"addTileArea",value:function(e){this._area_list.push({z:e.z,x:e.x,y:e.y}),this._flat_area_list=null}},{key:"getFlatAreaList",value:function(){return null===this._flat_area_list&&(this._flat_area_list=this._createFlatAreaList()),this._flat_area_list}},{key:"_createFlatAreaList",value:function(){for(var e=new dl,t=0;t<this._area_list.length;++t){var r=this._area_list[t];e.addDescendant(r.z,r.x,r.y)}return e.reduceTree(),e.collectFlatAreas(0,new Uint8Array(64),[])}}]),e}(),dl=function(){function e(){ze(this,e),this.present=!1,this.children=new Array(4).fill(null)}return je(e,[{key:"addDescendant",value:function(t,r,n){if(!0!==this.present)if(0==t)this.present=!0,this.children.fill(null);else{var i=Math.round(Math.pow(2,t-1)),o=Math.floor(r/i)+2*Math.floor(n/i);null===this.children[o]&&(this.children[o]=new e),this.children[o].addDescendant(t-1,r%i,n%i)}}},{key:"reduceTree",value:function(){if(!0===this.present)return 1;for(var e=0,t=0;t<4;++t){var r=this.children[t];null!==r&&(e+=r.reduceTree())}return 4==e?(this.present=!0,this.children.fill(null),1):0}},{key:"collectFlatAreas",value:function(e,t,r){if(!0===this.present)r.push(new Uint8Array(t.slice(0,e)));else for(var n=0;n<4;++n){var i=this.children[n];null!==i&&(t[e]=n,i.collectFlatAreas(e+1,t,r))}return r}}]),e}();Re({target:"Array",stat:!0},{isArray:Bt});var vl=vo.ArrayBuffer,yl=n.ArrayBuffer;Re({global:!0,forced:yl!==vl},{ArrayBuffer:vl}),gi("ArrayBuffer"),Ho("Uint16",(function(e){return function(t,r,n){return e(this,t,r,n)}})),Ho("Uint32",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var pl=function(){function e(t,r,n){ze(this,e),this._glenv=t;var i=n||{},o=t.context,a=e._getBindingPoint(o,i.target),s=o.createBuffer();o.bindBuffer(a,s),o.bufferData(a,r,o.STATIC_DRAW),o.bindBuffer(a,null),this._handle=s}return je(e,[{key:"dispose",value:function(){this._glenv.context.deleteBuffer(this._handle),this._handle=null}},{key:"handle",get:function(){return this._handle}}],[{key:"_getBindingPoint",value:function(e,t){switch(t){default:case gl.ATTRIBUTE:return e.ARRAY_BUFFER;case gl.INDEX:return e.ELEMENT_ARRAY_BUFFER}}}]),e}(),gl={ATTRIBUTE:{id:"ATTRIBUTE"},INDEX:{id:"INDEX"}};pl.Target=gl;var ml=function(){function e(t,r){ze(this,e),this._glenv=t,this._draw_mode=void 0,this._num_vertices=0,this._attrib_data={},this._index_data=null,r instanceof kl?this._initByInitializer(r):r instanceof ArrayBuffer?this._initByInitializer(new xl(t,r).initializer):this._initByInitializer(new bl(t,r).initializer)}return je(e,[{key:"_initByInitializer",value:function(e){this._draw_mode=this._convertDrawMode(e.draw_mode),this._num_vertices=e.num_vertices;for(var t=e.attribute_data,r=0;r<t.length;++r){var n=t[r];this._attrib_data[n.id]={mesh_buffer:n.buffer,buffer:n.buffer.handle,num_components:n.num_components,component_type:this._convertComponentType(n.component_type),normalized:n.normalized,byte_stride:n.byte_stride,byte_offset:n.byte_offset}}if(e.index_data){var i=e.index_data;this._index_data={mesh_buffer:i.buffer,buffer:i.buffer.handle,num_indices:i.num_indices,type:this._convertComponentType(i.type),byte_offset:i.byte_offset}}}},{key:"_convertDrawMode",value:function(e){var t=this._glenv.context;switch(e){case wl.POINTS:return t.POINTS;case wl.LINES:return t.LINES;case wl.TRIANGLES:return t.TRIANGLES;case wl.LINE_LOOP:return t.LINE_LOOP;case wl.LINE_STRIP:return t.LINE_STRIP;case wl.TRIANGLE_STRIP:return t.TRIANGLE_STRIP;case wl.TRIANGLE_FAN:return t.TRIANGLE_FAN;default:throw new Error("mapray: invalid Mesh.DrawMode: "+e)}}},{key:"_convertComponentType",value:function(e){var t=this._glenv.context;switch(e){case El.BYTE:return t.BYTE;case El.UNSIGNED_BYTE:return t.UNSIGNED_BYTE;case El.SHORT:return t.SHORT;case El.UNSIGNED_SHORT:return t.UNSIGNED_SHORT;case El.UNSIGNED_INT:return t.UNSIGNED_INT;case El.FLOAT:return t.FLOAT;default:throw new Error("mapray: invalid Mesh.ComponentType: "+e)}}},{key:"dispose",value:function(){this._attrib_data={},this._index_data=null}},{key:"draw",value:function(e){var t=this._glenv.context;e.bindVertexAttribs(this._attrib_data);var r=this._index_data;null!==r?(t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.buffer),t.drawElements(this._draw_mode,r.num_indices,r.type,r.byte_offset)):t.drawArrays(this._draw_mode,0,this._num_vertices)}}]),e}(),kl=function(){function e(t,r){ze(this,e),this.draw_mode=t,this.num_vertices=r,this.index_data=null,this.attribute_data=[]}return je(e,[{key:"addIndex",value:function(e,t,r,n){var i=n||{};this.index_data={buffer:e,num_indices:t,type:r,byte_offset:void 0!==i.byte_offset?i.byte_offset:0}}},{key:"addAttribute",value:function(e,t,r,n,i){var o=i||{},a={id:e,buffer:t,num_components:r,component_type:n,normalized:void 0!==o.normalized&&o.normalized,byte_stride:void 0!==o.byte_stride?o.byte_stride:0,byte_offset:void 0!==o.byte_offset?o.byte_offset:0};this.attribute_data.push(a)}}]),e}(),wl={POINTS:{id:"POINTS"},LINES:{id:"LINES"},TRIANGLES:{id:"TRIANGLES"},LINE_LOOP:{id:"LINE_LOOP"},LINE_STRIP:{id:"LINE_STRIP"},TRIANGLE_STRIP:{id:"TRIANGLE_STRIP"},TRIANGLE_FAN:{id:"TRIANGLE_FAN"}},El={BYTE:{id:"BYTE"},UNSIGNED_BYTE:{id:"UNSIGNED_BYTE"},SHORT:{id:"SHORT"},UNSIGNED_SHORT:{id:"UNSIGNED_SHORT"},UNSIGNED_INT:{id:"UNSIGNED_INT"},FLOAT:{id:"FLOAT"}},bl=function(){function e(t,r){ze(this,e);var n=Al.createVertexInfo(r.vtype),i=Al.numVertexComponents(n),o=r.vertices.length/i;this._initializer=new kl(e._toDrawMode(r),o),this._addIndex(t,r.indices,o);for(var a=new pl(t,Al.toTypedArray(r.vertices,El.FLOAT)),s=4*i,u=0,l=0;l<n.length;++l){var _=n[l].size;this._initializer.addAttribute(n[l].name,a,_,El.FLOAT,{byte_stride:s,byte_offset:u}),u+=4*_}}return je(e,[{key:"_addIndex",value:function(e,t,r){var n=r<65536?El.UNSIGNED_SHORT:El.UNSIGNED_INT,i=new pl(e,Al.toTypedArray(t,n),{target:pl.Target.INDEX});this._initializer.addIndex(i,t.length,n)}},{key:"initializer",get:function(){return this._initializer}}],[{key:"_toDrawMode",value:function(e){switch(e.ptype){case"triangles":return wl.TRIANGLES;case"lines":return wl.LINES;default:return wl.TRIANGLES}}}]),e}(),xl=function(){function e(t,r){ze(this,e);var n=new DataView(r,0),i=n.getUint8(e.OFFSET_VTYPE),o=n.getUint8(e.OFFSET_ITYPE),a=n.getUint8(e.OFFSET_PTYPE),s=n.getUint32(e.OFFSET_NUM_VERTICES,!0),u=n.getUint32(e.OFFSET_NUM_INDICES,!0);this._initializer=new kl(e._toDrawMode(a),s);var l=Al.createVertexInfo(i),_=this._createIndexArray(t,r,o,u,l,s);this._addIndex(t,o,_);for(var c=new pl(t,this._createVertexArray(r,l,s)),h=4*Al.numVertexComponents(l),f=0,d=0;d<l.length;++d){var v=l[d].size;this._initializer.addAttribute(l[d].name,c,v,El.FLOAT,{byte_stride:h,byte_offset:f}),f+=4*v}}return je(e,[{key:"_createIndexArray",value:function(t,r,n,i,o,a){var s,u,l,_=Al.numVertexComponents(o)*a*4,c=new DataView(r,e.OFFSET_BODY+_);switch(n){case e.ENUM_ITYPE_UINT16:for(u=new Uint16Array(i),l=2,s=0;s<i;++s)u[s]=c.getUint16(l*s,!0);break;case e.ENUM_ITYPE_UINT32:for(u=new Uint32Array(i),l=4,s=0;s<i;++s)u[s]=c.getUint32(l*s,!0);break;default:throw new Error("mapray: unknown itype: "+n)}return u}},{key:"_createVertexArray",value:function(t,r,n){for(var i=Al.numVertexComponents(r)*n,o=new DataView(t,e.OFFSET_BODY),a=new Float32Array(i),s=0;s<i;++s)a[s]=o.getFloat32(4*s,!0);return a}},{key:"_addIndex",value:function(t,r,n){var i=new pl(t,n,{target:pl.Target.INDEX}),o=e._indexTypeToComponentType(r);this._initializer.addIndex(i,n.length,o)}},{key:"initializer",get:function(){return this._initializer}}],[{key:"_toDrawMode",value:function(t){switch(t){case e.ENUM_PTYPE_TRIANGLES:return wl.TRIANGLES;case e.ENUM_PTYPE_LINES:return wl.LINES;default:throw new Error("mapray: invalid ptype: "+t)}}},{key:"_indexTypeToComponentType",value:function(t){switch(t){case e.ENUM_ITYPE_UINT16:return El.UNSIGNED_SHORT;case e.ENUM_ITYPE_UINT32:default:return El.UNSIGNED_INT}}}]),e}();xl.OFFSET_VTYPE=0,xl.OFFSET_ITYPE=1,xl.OFFSET_PTYPE=2,xl.OFFSET_NUM_VERTICES=4,xl.OFFSET_NUM_INDICES=8,xl.OFFSET_BODY=12,xl.ENUM_ITYPE_UINT16=0,xl.ENUM_ITYPE_UINT32=1,xl.ENUM_PTYPE_TRIANGLES=0,xl.ENUM_PTYPE_LINES=1;var Al=function(){function e(){ze(this,e)}return je(e,null,[{key:"createVertexInfo",value:function(t){if(Array.isArray(t))return t;var r=null;switch(t){case"P":case e.ENUM_VTYPE_P:r=[{name:e.ANAME_P,size:e.FSIZE_P}];break;case"PN":case e.ENUM_VTYPE_PN:r=[{name:e.ANAME_P,size:e.FSIZE_P},{name:e.ANAME_N,size:e.FSIZE_N}];break;case"PT":case e.ENUM_VTYPE_PT:r=[{name:e.ANAME_P,size:e.FSIZE_P},{name:e.ANAME_T,size:e.FSIZE_T}];break;case"PNT":case e.ENUM_VTYPE_PNT:r=[{name:e.ANAME_P,size:e.FSIZE_P},{name:e.ANAME_N,size:e.FSIZE_N},{name:e.ANAME_T,size:e.FSIZE_T}];break;default:throw new Error("mapray: unknown vtype: "+t)}return r}},{key:"numVertexComponents",value:function(e){for(var t=e.length,r=0,n=0;n<t;++n)r+=e[n].size;return r}},{key:"toTypedArray",value:function(e,t){switch(t){case El.UNSIGNED_SHORT:return e instanceof Uint16Array?e:new Uint16Array(e);case El.UNSIGNED_INT:return e instanceof Uint32Array?e:new Uint32Array(e);case El.FLOAT:return e instanceof Float32Array?e:new Float32Array(e);default:throw new Error("mapray: invalid component type: "+t)}}}]),e}();Al.ENUM_VTYPE_P=0,Al.ENUM_VTYPE_PN=1,Al.ENUM_VTYPE_PT=2,Al.ENUM_VTYPE_PNT=3,Al.ANAME_P="a_position",Al.ANAME_N="a_normal",Al.ANAME_T="a_texcoord",Al.FSIZE_P=3,Al.FSIZE_N=3,Al.FSIZE_T=2,ml.Initializer=kl,ml.DrawMode=wl,ml.ComponentType=El;var Tl={ABSOLUTE:{id:"ABSOLUTE"},RELATIVE:{id:"RELATIVE"},CLAMP:{id:"CLAMP"}},Il=function(){function e(t,r){ze(this,e),this.scene=t,this._altitude_mode=Tl.ABSOLUTE,this._need_to_create_regions=!1,this._animation=new Qs,r&&r.json&&this._setupEntityByJson(r.json)}return je(e,[{key:"onChangeAltitudeMode",value:function(e){}},{key:"getPrimitiveProducer",value:function(){return null}},{key:"getFlakePrimitiveProducer",value:function(){return null}},{key:"_setupEntityByJson",value:function(e){if(e.altitude_mode)switch(e.altitude_mode){case"absolute":this._altitude_mode=Tl.ABSOLUTE;break;case"relative":this._altitude_mode=Tl.RELATIVE;break;case"clamp":this._altitude_mode=Tl.CLAMP;break;default:console.error("unrecognized altitude_mode: "+e.altitude_mode)}}},{key:"animation",get:function(){return this._animation}},{key:"altitude_mode",set:function(e){if(this._altitude_mode!==e){var t=this._altitude_mode;this._altitude_mode=e,this.onChangeAltitudeMode(t)}},get:function(){return this._altitude_mode}}]),e}(),Pl=function(){function e(t){ze(this,e),this._entity=t,this._need_to_create_regions=!1}return je(e,[{key:"needToCreateRegions",value:function(){this._need_to_create_regions=!0}},{key:"checkToCreateRegions",value:function(){var e=this._need_to_create_regions;return this._need_to_create_regions=!1,e}},{key:"needsElevation",value:function(){return this._entity._altitude_mode!==Tl.ABSOLUTE}},{key:"createRegions",value:function(){return[]}},{key:"onChangeElevation",value:function(e){}},{key:"getPrimitives",value:function(e){throw new Error("mapray.Entity.PrimitiveProducer#getPrimitives() method has not been overridden.")}},{key:"entity",get:function(){return this._entity}}]),e}(),Ll=function(){function e(t){ze(this,e),this._entity=t,this._updated=!1}return je(e,[{key:"notifyForUpdate",value:function(){this._updated=!0}},{key:"getAreaStatus",value:function(e){return Ml.EMPTY}},{key:"createMesh",value:function(e,t,r){return null}},{key:"getMaterialAndProperties",value:function(e){throw new Error("mapray.Entity.FlakePrimitiveProducer#getMaterialAndProperties() method has not been overridden.")}},{key:"checkForUpdate",value:function(){var e=this._updated;return this._updated=!1,e}},{key:"entity",get:function(){return this._entity}}]),e}(),Ml={EMPTY:{id:"EMPTY"},FULL:{id:"FULL"},PARTIAL:{id:"PARTIAL"}};Il.PrimitiveProducer=Pl,Il.FlakePrimitiveProducer=Ll,Il.AreaStatus=Ml;var Sl=function(){function e(t,r){ze(this,e),this._glenv=t,this._dem_provider=r,this._status=Rl.NOT_READY,this._dem_area_updated=new fl,this._prev_producers=new Set,this._ρ=r.getResolutionPower(),this._dem_zbias=cs.LOG2PI-this._ρ+1,this._hist_stats=new Dl,this._flake_reduce_thresh=1.5,this._flake_reduce_factor=1.2,this._num_cache_flakes=0,this._num_touch_flakes=0,this._mesh_reduce_lower=300,this._mesh_reduce_thresh=1.5,this._mesh_reduce_factor=1.2,this._num_cache_meshes=0,this._num_touch_meshes=0,this._max_dem_requesteds=10,this._num_dem_requesteds=0,this._frame_counter=0,this._root_flake=null,this._avg_height=null,this._root_cancel_id=null,this._requestRoot()}return je(e,[{key:"cancel",value:function(){if(this._status===Rl.READY)for(var e=this._root_flake._children,t=0;t<4;++t)e[t].dispose();else this._status===Rl.NOT_READY&&(this._dem_provider.cancelRequest(this._root_cancel_id),this._root_cancel_id=null)}},{key:"putNextEntityProducers",value:function(e){var t=new Set,r=[],n=[],i=!0,o=!1,a=void 0;try{for(var s,u=e[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,_=l.checkForUpdate();this._prev_producers.has(l)?(_&&n.push(l),this._prev_producers.delete(l)):r.push(l),t.add(l)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}var c=this._prev_producers,h=!0,f=!1,d=void 0;try{for(var v,y=c[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var p=v.value;this._root_flake.removeEntityProducer(p)}}catch(e){f=!0,d=e}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}for(var g=0,m=r;g<m.length;g++){var k=m[g];this._root_flake.addEntityProducer(k)}for(var w=0,E=n;w<E.length;w++){var b=E[w];this._root_flake.updateEntityProducer(b)}this._prev_producers=t}},{key:"getNumDemWaitingRequests",value:function(){return this._num_dem_requesteds}},{key:"findHighestAccuracy",value:function(e,t){var r=this._root_flake;if(null===r)return null;for(var n=2,i=n*e,o=n*t,a=r;;){var s=cs.clamp(Math.floor(i),0,n-1)%2,u=cs.clamp(Math.floor(o),0,n-1)%2,l=r._children[s+2*u];if(r.touch(),null===l)break;r._dem_state===Fl.LOADED&&(a=r),r=l,n*=2,i*=2,o*=2}return a._requestHighestAccuracy(e,t),a._dem_data}},{key:"getExistingElevations",value:function(e,t,r,n,i,o,a){for(var s=2*Math.PI,u=1<<this._ρ,l=r,_=o,c=0;c<e;++c){var h=t[l],f=t[l+1],d=h+180*Math.floor((90-f)/360+Math.floor((90+f)/360)),v=d-360-360*Math.floor((d-180)/360),y=90-Math.abs(90-f+360*Math.floor((90+f)/360)),p=v*cs.DEGREE/s+.5,g=.5-cs.invGudermannian(y*cs.DEGREE)/s;if(g>=0&&g<=1){var m=this._findHighestAccuracy2(p,g);if(null!==m){var k=Math.pow(2,m.z),w=u*(k*p-m.x),E=u*(k*g-m.y),b=cs.clamp(Math.floor(w),0,u-1),x=cs.clamp(Math.floor(E),0,u-1),A=m.getHeights(b,x),T=A[0],I=A[1],P=A[2],L=A[3],M=w-b,S=E-x;i[_]=(T*(1-M)+I*M)*(1-S)+(P*(1-M)+L*M)*S}else i[_]=0}else i[_]=0;l+=n,_+=a}return i}},{key:"_findHighestAccuracy2",value:function(e,t){var r=this._root_flake;if(null===r)return null;for(var n=2,i=n*e,o=n*t,a=r;;){var s=cs.clamp(Math.floor(i),0,n-1)%2,u=cs.clamp(Math.floor(o),0,n-1)%2,l=r._children[s+2*u];if(null===l)break;r._dem_state===Fl.LOADED&&(a=r),r=l,n*=2,i*=2,o*=2}return a._dem_data}},{key:"endFrame",value:function(){var e=this._hist_stats.getMaxValue(this._num_touch_flakes);this._num_cache_flakes>this._flake_reduce_thresh*e&&this._reduceFlakes(e),this._num_cache_meshes>this._mesh_reduce_lower&&this._num_cache_meshes>this._mesh_reduce_thresh*this._num_touch_meshes&&this._reduceMeshes(),this._dem_area_updated.clear(),this._num_touch_flakes=0,this._num_touch_meshes=0,++this._frame_counter}},{key:"_requestRoot",value:function(){var e=this;this._root_cancel_id=this._dem_provider.requestTile(0,0,0,(function(t){if(t){var r=new sl(0,0,0,e._ρ,t);e._avg_height=r.newAvgHeightMaps(),e._root_flake=new Cl(null,0,0,0),e._root_flake.setupRoot(e,r),e._status=Rl.READY,e._dem_area_updated.addTileArea(r)}else e._status=Rl.FAILED;e._root_cancel_id=null,--e._num_dem_requesteds})),++this._num_dem_requesteds}},{key:"_reduceFlakes",value:function(e){var t=this._root_flake.flattenFlakes();t.sort((function(e,t){return e.compareForReduce(t)}));var r=Math.floor(this._flake_reduce_factor*e);t.slice(r).forEach((function(e){return e.dispose()}))}},{key:"_reduceMeshes",value:function(){var e=this._root_flake.flattenMeshes();e.sort((function(e,t){return e.compareForReduce(t)}));var t=Math.floor(this._mesh_reduce_factor*this._num_touch_meshes);e.slice(t).forEach((function(e){return e.dispose()}))}},{key:"glenv",get:function(){return this._glenv}},{key:"dem_provider",get:function(){return this._dem_provider}},{key:"status",get:function(){return this._status}},{key:"dem_area_updated",get:function(){return this._dem_area_updated}},{key:"root_flake",get:function(){var e=this._root_flake;return e.touch(),e}}]),e}(),Rl={NOT_READY:{id:"NOT_READY"},READY:{id:"READY"},FAILED:{id:"FAILED"}};Sl.Status=Rl;var Cl=function(){function e(t,r,n,i){ze(this,e),this.z=r,this.x=n,this.y=i,this._parent=t,this._children=[null,null,null,null],this._globe=null!==t?t._globe:null,this._dem_data=null,this._dem_state=Fl.NONE,this._entity_map=null,this._meshes=[],this._prev_Za_dem=null,this._prev_Zr_dem=null,this._base_height=0,this._height_min=0,this._height_max=0,this._dem_zlimit=0,this._gocs_x_min=0,this._gocs_x_max=0,this._gocs_y_min=0,this._gocs_y_max=0,this._gocs_z_min=0,this._gocs_z_max=0,this._aframe=-1,null!==this._globe&&(this._globe._num_cache_flakes+=1)}return je(e,[{key:"setupRoot",value:function(e,t){this._globe=e,this._dem_data=t,this._dem_state=Fl.LOADED,this._entity_map=new Map,this._estimate(),e._num_cache_flakes+=1}},{key:"newChild",value:function(t,r){var n=t+2*r,i=this._children[n];return null===i&&(i=new e(this,this.z+1,2*this.x+t,2*this.y+r),this._children[n]=i),i._estimate(),i.touch(),i}},{key:"isInvisible",value:function(e){switch(this.z){case 0:return this._isInvisible_0(e);default:return this._isInvisible_N(e)}}},{key:"getRenderObject",value:function(t){var r,n=Math.pow(2,-t)*e.ε;r=n<=2?Math.max(Math.ceil(cs.LOG2PI-this.z-Math.maprayLog2(Math.acos(1-n))),0):0;var i,o=this._getCosφ();i=n*o<=2?Math.max(Math.ceil(cs.LOG2PI-this.z+Math.maprayLog2(o/Math.acos(1-n*o))),0):0;var a=this._getMeshNode(t,r,i);return a.touch(),a.getRenderObject()}},{key:"getEntityProducers",value:function(){return this._getEntityMap().keys()}},{key:"addEntityProducer",value:function(e){switch(e.getAreaStatus(this)){case Il.AreaStatus.PARTIAL:this._entity_map.set(e,!1);var t=!0,r=!1,n=void 0;try{for(var i,o=this._children[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;null!==a&&null!==a._entity_map&&a.addEntityProducer(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}break;case Il.AreaStatus.FULL:this._addEntityFullProducer(e)}}},{key:"_addEntityFullProducer",value:function(e){this._entity_map.set(e,!0);var t=!0,r=!1,n=void 0;try{for(var i,o=this._children[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;null!==a&&null!==a._entity_map&&a._addEntityFullProducer(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"removeEntityProducer",value:function(e){if(this._entity_map.has(e)){this._entity_map.delete(e),this._removeEntityMeshes(e);var t=!0,r=!1,n=void 0;try{for(var i,o=this._children[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;null!==a&&null!==a._entity_map&&a.removeEntityProducer(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}}},{key:"updateEntityProducer",value:function(e){this.removeEntityProducer(e),this.addEntityProducer(e)}},{key:"findRayDistance",value:function(e,t){var r;for(r=this;r._dem_state!==Fl.LOADED;r=r._parent);if(this.z-r.z===this._globe._ρ)return this._findQuadRayDistance(e,t,r);if(this._cullForRayDistance(e,t))return t;for(var n=t,i=0;i<2;++i)for(var o=0;o<2;++o)n=this.newChild(o,i).findRayDistance(e,n);return n}},{key:"dispose",value:function(){var e,t=this._parent;if(null!==t){for(var r=this._globe,n=this._meshes;n.length>0;)n[0].dispose();var i=this._children;for(e=0;e<4;++e){var o=i[e];null!==o&&o.dispose()}var a=t._children;for(e=0;e<4;++e)if(a[e]===this){a[e]=null;break}this._parent=null,this._dem_state===Fl.REQUESTED&&(r._dem_provider.cancelRequest(this._dem_data),--r._num_dem_requesteds),r._num_cache_flakes-=1}}},{key:"flattenFlakes",value:function(){var e=[];return this._flattenFlakes(e),e}},{key:"flattenMeshes",value:function(){var e=[];return this._flattenMeshes(e),e}},{key:"compareForReduce",value:function(e){var t=e,r=t._aframe-this._aframe;return 0!==r?r:this.z-t.z}},{key:"_flattenFlakes",value:function(e){e.push(this);for(var t=this._children,r=0;r<4;++r){var n=t[r];null!==n&&n._flattenFlakes(e)}}},{key:"_flattenMeshes",value:function(e){Array.prototype.push.apply(e,this._meshes);for(var t=this._children,r=0;r<4;++r){var n=t[r];null!==n&&n._flattenMeshes(e)}}},{key:"touch",value:function(){var e=this._globe;this._aframe!==e._frame_counter&&(this._aframe=e._frame_counter,e._num_touch_flakes+=1)}},{key:"_getMeshNode",value:function(e,t,r){for(var n=this._getMeshDemBinary(e),i=n.getDivisionPowers(this,e,t,r),o=this._meshes,a=o.length,s=0;s<a;++s){var u=o[s];if(u.match(n,i))return u}var l=new Ol(this,n,i);return o.unshift(l),l}},{key:"_getMeshDemBinary",value:function(e){var t=cs.clamp(Math.round(e+this._globe._dem_zbias),0,this._dem_zlimit),r=this._findNearestDemTile(t);if(r.z<t){var n=r.getQuadLevel(this.z,this.x,this.y);n>0&&this._requestAncestorDemTile(Math.min(r.z+n,t))}return r}},{key:"_findNearestDemTile",value:function(e){for(var t=this,r=this.z-e,n=0;n<r;++n)t=t._parent;for(;t._dem_state!==Fl.LOADED;)t=t._parent;return t._dem_data}},{key:"_requestAncestorDemTile",value:function(e){var t=this._globe;if(!(t._num_dem_requesteds>=t._max_dem_requesteds)){for(var r=this,n=this.z-e,i=0;i<n;++i)r=r._parent;for(;;){var o=r._dem_state;if(o===Fl.LOADED||o===Fl.REQUESTED)break;if(o!==Fl.FAILED){var a=t._dem_provider;r._dem_data=a.requestTile(r.z,r.x,r.y,(function(e){null!==r._parent&&(e?(r._dem_data=new sl(r.z,r.x,r.y,t._ρ,e),r._dem_state=Fl.LOADED,t._dem_area_updated.addTileArea(r)):(r._dem_data=null,r._dem_state=Fl.FAILED),--t._num_dem_requesteds)})),r._dem_state=Fl.REQUESTED,++t._num_dem_requesteds;break}r=r._parent}}}},{key:"_isInvisible_0",value:function(e){for(var t=cs.EARTH_RADIUS+this._height_max,r=0;r<e.length;++r){if(e[r][3]<-t)return!0}return!1}},{key:"_isInvisible_N",value:function(e){for(var t=this._gocs_x_min,r=this._gocs_x_max,n=this._gocs_y_min,i=this._gocs_y_max,o=this._gocs_z_min,a=this._gocs_z_max,s=0;s<e.length;++s){var u=e[s],l=u[0],_=u[1],c=u[2],h=u[3],f=l*t+_*n,d=l*r+_*n,v=l*t+_*i,y=l*r+_*i,p=-c*o-h,g=-c*a-h;if(f<p&&d<p&&v<p&&y<p&&f<g&&d<g&&v<g&&y<g)return!0}return!1}},{key:"_getCosφ",value:function(){var e=this.z;if(e>0){var t=this.y,r=Math.pow(2,1-e),n=Math.abs(1-r*t),i=Math.abs(1-r*(t+1)),o=Math.exp(Math.PI*Math.min(n,i));return 2*o/(o*o+1)}return 1}},{key:"_estimate",value:function(){if(this._prev_Za_dem!==this){var e,t=this.z,r=this._globe._ρ;if(t<r){if((e=this._findNearestDemTile(t))===this._prev_Zr_dem)return;this._prev_Zr_dem=e,this._estimate_low(e),this._dem_zlimit=t}else{var n=this._findNearestDemTile(t-r);if(n.isLeaf(t,this.x,this.y))this._estimate_leaf(n);else{if(e=this._findNearestDemTile(n.z+r),n===this._prev_Za_dem&&e===this._prev_Zr_dem)return;this._prev_Za_dem=n,this._prev_Zr_dem=e,this._estimate_high(n,e)}this._dem_zlimit=n.z+r}switch(t){case 0:this._updataBoundingBox_0();break;case 1:this._updataBoundingBox_1();break;default:this._updataBoundingBox_N()}}}},{key:"_estimate_low",value:function(t){var r=this.z,n=this.x,i=this.y,o=this._calcAlpha();this._base_height=this._globe._avg_height.sample(r,n,i),this._height_min=Math.max(this._base_height+o*e.Fm,t.height_min),this._height_max=Math.min(this._base_height+o*e.Fp,t.height_max),(t.z==r||t.isLeaf(r,n,i))&&(this._prev_Za_dem=this)}},{key:"_estimate_high",value:function(t,r){var n=this._globe,i=this.z,o=this.x,a=this.y,s=t.z,u=t.x,l=t.y,_=n._ρ,c=Math.pow(2,s-i),h=1<<_,f=Math.floor(h*((o+.5)*c-u)),d=Math.floor(h*((a+.5)*c-l)),v=h*(o*c-u)-f,y=h*((o+1)*c-u)-f,p=h*(a*c-l)-d,g=h*((a+1)*c-l)-d,m=t.getHeights(f,d),k=m[0],w=m[1],E=m[2],b=m[3],x=(k*(1-v)+w*v)*(1-p)+(E*(1-v)+b*v)*p,A=(k*(1-y)+w*y)*(1-p)+(E*(1-y)+b*y)*p,T=(k*(1-v)+w*v)*(1-g)+(E*(1-v)+b*v)*g,I=(k*(1-y)+w*y)*(1-g)+(E*(1-y)+b*y)*g,P=this._calcAlpha();if(this._base_height=.25*(x+A+T+I),this._height_min=Math.max(this._base_height+P*e.Fm,r.height_min),this._height_max=Math.min(this._base_height+P*e.Fp,r.height_max),s<i-_){var L=t.getQuadLevel(i,o,a);this._requestAncestorDemTile(Math.min(s+L,i-_))}else(r.z==i||r.isLeaf(i,o,a))&&(this._prev_Za_dem=this)}},{key:"_estimate_leaf",value:function(e){var t=this.z,r=this.x,n=this.y,i=e.z,o=e.x,a=e.y,s=Math.pow(2,i-t),u=1<<this._globe._ρ,l=Math.floor(u*((r+.5)*s-o)),_=Math.floor(u*((n+.5)*s-a)),c=u*(r*s-o)-l,h=u*((r+1)*s-o)-l,f=u*(n*s-a)-_,d=u*((n+1)*s-a)-_,v=e.getHeights(l,_),y=v[0],p=v[1],g=v[2],m=v[3],k=(y*(1-c)+p*c)*(1-f)+(g*(1-c)+m*c)*f,w=(y*(1-h)+p*h)*(1-f)+(g*(1-h)+m*h)*f,E=(y*(1-c)+p*c)*(1-d)+(g*(1-c)+m*c)*d,b=(y*(1-h)+p*h)*(1-d)+(g*(1-h)+m*h)*d;this._base_height=.25*(k+w+E+b),this._height_min=Math.min(k,w,E,b),this._height_max=Math.max(k,w,E,b),this._prev_Za_dem=this}},{key:"_calcAlpha",value:function(){var t=Math.pow(2,1-this.z);return t*e.πr/Math.cosh((1-t*(this.y+.5))*Math.PI)}},{key:"_updataBoundingBox_0",value:function(){var e=cs.EARTH_RADIUS+this._height_max;this._gocs_x_min=-e,this._gocs_x_max=e,this._gocs_y_min=-e,this._gocs_y_max=e,this._gocs_z_min=-e,this._gocs_z_max=e}},{key:"_updataBoundingBox_1",value:function(){var e=cs.EARTH_RADIUS+this._height_max,t=this.x,r=this.y;this._gocs_x_min=-e,this._gocs_x_max=e,this._gocs_y_min=e*(t-1),this._gocs_y_max=e*t,this._gocs_z_min=-e*r,this._gocs_z_max=e*(1-r)}},{key:"_updataBoundingBox_N",value:function(){var e=Math.PI,t=this.z,r=this.x,n=this.y,i=Math.pow(2,1-t)*e,o=e-(n+1)*i,a=e-n*i,s=r*i-e,u=(r+1)*i-e,l=Math.exp(o),_=Math.exp(a),c=l*l,h=_*_,f=cs.EARTH_RADIUS+this._height_min,d=cs.EARTH_RADIUS+this._height_max,v=2*l/(c+1),y=2*_/(h+1);o+a<0?(s+u<-e?(this._gocs_x_min=d*y*Math.cos(s),this._gocs_x_max=f*v*Math.cos(u),this._gocs_y_min=d*y*Math.sin(u),this._gocs_y_max=f*v*Math.sin(s)):s+u<0?(this._gocs_x_min=f*v*Math.cos(s),this._gocs_x_max=d*y*Math.cos(u),this._gocs_y_min=d*y*Math.sin(s),this._gocs_y_max=f*v*Math.sin(u)):s+u<e?(this._gocs_x_min=f*v*Math.cos(u),this._gocs_x_max=d*y*Math.cos(s),this._gocs_y_min=f*v*Math.sin(s),this._gocs_y_max=d*y*Math.sin(u)):(this._gocs_x_min=d*y*Math.cos(u),this._gocs_x_max=f*v*Math.cos(s),this._gocs_y_min=f*v*Math.sin(u),this._gocs_y_max=d*y*Math.sin(s)),this._gocs_z_min=d*(c-1)/(c+1),this._gocs_z_max=f*(h-1)/(h+1)):(s+u<-e?(this._gocs_x_min=d*v*Math.cos(s),this._gocs_x_max=f*y*Math.cos(u),this._gocs_y_min=d*v*Math.sin(u),this._gocs_y_max=f*y*Math.sin(s)):s+u<0?(this._gocs_x_min=f*y*Math.cos(s),this._gocs_x_max=d*v*Math.cos(u),this._gocs_y_min=d*v*Math.sin(s),this._gocs_y_max=f*y*Math.sin(u)):s+u<e?(this._gocs_x_min=f*y*Math.cos(u),this._gocs_x_max=d*v*Math.cos(s),this._gocs_y_min=f*y*Math.sin(s),this._gocs_y_max=d*v*Math.sin(u)):(this._gocs_x_min=d*v*Math.cos(u),this._gocs_x_max=f*y*Math.cos(s),this._gocs_y_min=f*y*Math.sin(u),this._gocs_y_max=d*v*Math.sin(s)),this._gocs_z_min=f*(c-1)/(c+1),this._gocs_z_max=d*(h-1)/(h+1))}},{key:"_requestHighestAccuracy",value:function(e,t){var r=this._dem_data.getQuadLevelDirect(e,t);if(0!=r){for(var n=this,i=Math.round(Math.pow(2,this.z+1)),o=i*e,a=i*t,s=0;s<r;++s){var u=cs.clamp(Math.floor(o),0,i-1)%2,l=cs.clamp(Math.floor(a),0,i-1)%2;n=n.newChild(u,l),i*=2,o*=2,a*=2}n._requestAncestorDemTile(n.z)}}},{key:"_findQuadRayDistance",value:function(t,r,n){var i=this._getQuadPositions(n,e._temp_positions),o=e._findTriRayDistance(t,r,i[0],i[2],i[1]);return o===r?e._findTriRayDistance(t,r,i[1],i[2],i[3]):o}},{key:"_getQuadPositions",value:function(e,t){for(var r=this.x,n=this.y,i=e.x,o=e.y,a=1<<this._globe._ρ,s=e._dem_data.getHeights(r-a*i,n-a*o),u=Math.pow(2,1-this.z)*Math.PI,l=r*u-Math.PI,_=0,c=Math.PI-n*u;_<2;++_,c-=u)for(var h=Math.exp(c),f=h*h,d=(f-1)/(f+1),v=2*h/(f+1),y=0,p=l;y<2;++y,p+=u){var g=y+2*_,m=cs.EARTH_RADIUS+s[g],k=Math.sin(p),w=Math.cos(p),E=t[g];E[0]=m*v*w,E[1]=m*v*k,E[2]=m*d}return t}},{key:"_cullForRayDistance",value:function(e,t){var r=e.position,n=r[0],i=r[1],o=r[2],a=this._gocs_x_min,s=this._gocs_x_max,u=this._gocs_y_min,l=this._gocs_y_max,_=this._gocs_z_min,c=this._gocs_z_max;if(a<=n&&n<=s&&u<=i&&i<=l&&_<=o&&o<=c)return!1;var h,f,d,v,y=e.direction,p=y[0],g=y[1],m=y[2];if(n<a&&p>0){if((h=(a-n)/p)<t&&(v=o+h*m,u<=(d=i+h*g)&&d<=l&&_<=v&&v<=c))return!1}else if(n>s&&p<0&&(h=(s-n)/p)<t&&(v=o+h*m,u<=(d=i+h*g)&&d<=l&&_<=v&&v<=c))return!1;if(i<u&&g>0){if((h=(u-i)/g)<t&&(v=o+h*m,a<=(f=n+h*p)&&f<=s&&_<=v&&v<=c))return!1}else if(i>l&&g<0&&(h=(l-i)/g)<t&&(v=o+h*m,a<=(f=n+h*p)&&f<=s&&_<=v&&v<=c))return!1;if(o<_&&m>0){if((h=(_-o)/m)<t&&(d=i+h*g,a<=(f=n+h*p)&&f<=s&&u<=d&&d<=l))return!1}else if(o>c&&m<0&&(h=(c-o)/m)<t&&(d=i+h*g,a<=(f=n+h*p)&&f<=s&&u<=d&&d<=l))return!1;return!0}},{key:"_removeEntityMeshes",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,o=this._meshes[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){i.value.removeEntityMesh(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"_getEntityMap",value:function(){if(null===this._entity_map){var e=this._parent._getEntityMap(),t=new Map,r=!0,n=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=$e(o.value,2),u=s[0];if(s[1])t.set(u,!0);else switch(u.getAreaStatus(this)){case Il.AreaStatus.PARTIAL:t.set(u,!1);break;case Il.AreaStatus.FULL:t.set(u,!0)}}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}this._entity_map=t}return this._entity_map}},{key:"base_height",get:function(){return this._base_height}},{key:"height_min",get:function(){return this._height_min}},{key:"height_max",get:function(){return this._height_max}}],[{key:"_findTriRayDistance",value:function(t,r,n,i,o){var a=t.direction,s=e._temp_ray_1;s[0]=i[0]-n[0],s[1]=i[1]-n[1],s[2]=i[2]-n[2];var u=e._temp_ray_2;u[0]=o[0]-n[0],u[1]=o[1]-n[1],u[2]=o[2]-n[2];var l=cs.cross3(s,u,e._temp_ray_3),_=cs.dot3(l,a);if(_<0){var c=t.position,h=e._temp_ray_4;h[0]=n[0]-c[0],h[1]=n[1]-c[1],h[2]=n[2]-c[2];var f=cs.dot3(l,h)/_;if(f>=0&&f<r){var d=e._temp_ray_5;d[0]=c[0]+f*a[0],d[1]=c[1]+f*a[1],d[2]=c[2]+f*a[2];var v=e._temp_ray_6;v[0]=n[0]-d[0],v[1]=n[1]-d[1],v[2]=n[2]-d[2];var y=e._temp_ray_7;y[0]=i[0]-d[0],y[1]=i[1]-d[1],y[2]=i[2]-d[2];var p=e._temp_ray_8;if(p[0]=o[0]-d[0],p[1]=o[1]-d[1],p[2]=o[2]-d[2],cs.dot3(cs.cross3(v,y,e._temp_ray_9),l)>=0&&cs.dot3(cs.cross3(y,p,e._temp_ray_10),l)>=0&&cs.dot3(cs.cross3(p,v,e._temp_ray_11),l)>=0)return f}}return r}}]),e}();Cl.ε=.0625,Cl.Fm=-2,Cl.Fp=2,Cl.πr=Math.PI*cs.EARTH_RADIUS,Cl._temp_positions=function(){for(var e=[],t=0;t<4;++t)e.push(cs.createVector3());return e}(),Cl._temp_ray_1=cs.createVector3(),Cl._temp_ray_2=cs.createVector3(),Cl._temp_ray_3=cs.createVector3(),Cl._temp_ray_4=cs.createVector3(),Cl._temp_ray_5=cs.createVector3(),Cl._temp_ray_6=cs.createVector3(),Cl._temp_ray_7=cs.createVector3(),Cl._temp_ray_8=cs.createVector3(),Cl._temp_ray_9=cs.createVector3(),Cl._temp_ray_10=cs.createVector3(),Cl._temp_ray_11=cs.createVector3();var Dl=function(){function e(){ze(this,e),this._history=[],this._max_value=0,this._hsize=200}return je(e,[{key:"getMaxValue",value:function(t){var r=this._history,n=this._max_value;return r.length<this._hsize?t>n&&(this._max_value=t):t>=n?(this._max_value=t,r.shift()):r[0]<n?r.shift():(r.shift(),this._max_value=e._find_max(r)),r.push(t),this._max_value}}],[{key:"_find_max",value:function(e){for(var t=e[0],r=e.length,n=1;n<r;++n){var i=e[n];i>t&&(t=i)}return t}}]),e}(),Ol=function(){function e(t,r,n){ze(this,e),this._flake=t,this._dem=r,this._dpows=Array.from(n),this._aframe=-1,this._base_mesh=new ll(t._globe.glenv,t,n,r),this._entity_meshes=new Map,t._globe._num_cache_meshes+=1}return je(e,[{key:"getRenderObject",value:function(){var e=this._flake,t=new hl(e,e._globe.glenv,this._base_mesh),r=!0,n=!1,i=void 0;try{for(var o,a=e.getEntityProducers()[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value,u=this._getEntityMesh(s);u!==Nl&&(null===u&&(u=s.createMesh(e,this._dpows,this._dem),this._setEntityMesh(s,u),null===u)||t.addEntityData(u,s))}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return t}},{key:"match",value:function(e,t){return this._dem===e&&this._dpows[0]===t[0]&&this._dpows[1]===t[1]}},{key:"touch",value:function(){var e=this._flake._globe;this._aframe!==e._frame_counter&&(this._aframe=e._frame_counter,e._num_touch_meshes+=1)}},{key:"dispose",value:function(){if(null!==this._base_mesh){for(var e=this._flake,t=e._meshes,r=t.length,n=0;n<r;++n)if(t[n]===this){t.splice(n,1);break}this._base_mesh.dispose(),this._base_mesh=null;var i=!0,o=!1,a=void 0;try{for(var s,u=this._entity_meshes.values()[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;l instanceof ml&&l.dispose()}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}e._globe._num_cache_meshes-=1}}},{key:"compareForReduce",value:function(e){return e._aframe-this._aframe}},{key:"removeEntityMesh",value:function(e){this._entity_meshes.delete(e)}},{key:"_getEntityMesh",value:function(e){var t=this._entity_meshes.get(e);return void 0!==t?t:null}},{key:"_setEntityMesh",value:function(e,t){var r=null!==t?t:Nl;this._entity_meshes.set(e,r)}}]),e}(),Fl={NONE:{id:"NONE"},LOADED:{id:"LOADED"},REQUESTED:{id:"REQUESTED"},FAILED:{id:"FAILED"}},Nl={id:"CACHED_EMPTY_MESH"},Vl=function(){function e(t){ze(this,e),this.flake=t}return je(e,[{key:"getRenderObject",value:function(){return this.flake.getRenderObject(this.lod)}}]),e}(),Ul=function(){function e(t){ze(this,e),this._setupViewVectors(t),this._setupClipPlanes(t);var r=t._viewer,n=r.dem_provider,i=r.tile_texture_cache;this._min_image_z=i.getImageZMin();var o=cs.LOG2PI-n.getResolutionPower()+1;this._max_zbias=Math.max(i.getImageZBias(),o),this._globe=r.globe,this._rflake_list=[],this._debug_stats=r.debug_stats,this._debug_stats&&(this._num_procA_flakes=0,this._num_procB_flakes=0),this._view_dir_N=cs.createVector3(),this._view_dir_V=cs.createVector3()}return je(e,[{key:"_setupViewVectors",value:function(e){var t=e._view_to_gocs,r=e._pixel_step,n=cs.createVector3(),i=cs.createVector3();n[0]=t[12],n[1]=t[13],n[2]=t[14],i[0]=-t[8]*r,i[1]=-t[9]*r,i[2]=-t[10]*r,this._view_pos_Q=n,this._view_dir_wU=i}},{key:"_setupClipPlanes",value:function(e){var t=e._view_to_gocs,r=e._gocs_to_view,n=e._volume_planes,i=[],o=e._viewer._globe.root_flake,a=cs.EARTH_RADIUS+o.height_min,s=cs.EARTH_RADIUS+o.height_max,u=t[12],l=t[13],_=t[14],c=u*u+l*l+_*_,h=a*a,f=s*s,d=Math.sqrt((c-h)*(f-h))-h,v=cs.createVector4(),y=1/Math.sqrt(c);v[0]=u*y,v[1]=l*y,v[2]=_*y,v[3]=d*y,i.push(v);for(var p=Math.sqrt(c+f+2*d),g=0;g<6;++g){var m=n[g],k=cs.createVector4();1==g&&m[3]>p&&((m=cs.createVector4(m))[3]=p),cs.transformPlane_A(r,m,k),i.push(k)}this._clip_planes=i}},{key:"traverse",value:function(){return this._collectFlakes(this._globe.root_flake),this._debug_stats&&(this._debug_stats.num_procA_flakes=this._num_procA_flakes,this._debug_stats.num_procB_flakes=this._num_procB_flakes),this._rflake_list}},{key:"_collectFlakes",value:function(t){if(null!==this._debug_stats&&(this._num_procA_flakes+=1),!t.isInvisible(this._clip_planes))if(t.z<this._min_image_z)this._collectNextLevelFlakes(t);else{null!==this._debug_stats&&(this._num_procB_flakes+=1);var r=this._getLevelOfDetailRange(t),n=r.mid+this._max_zbias;r.max-r.min>e.MAX_LOD_INTERVAL||n>t.z?this._collectNextLevelFlakes(t):this._addRenderFlake(t,r)}}},{key:"_collectNextLevelFlakes",value:function(e){for(var t=0;t<2;++t)for(var r=0;r<2;++r)this._collectFlakes(e.newChild(r,t))}},{key:"_getLevelOfDetailRange",value:function(e){for(var t=Math.PI,r=e.z,n=e.x,i=e.y,o=Math.pow(2,1-r)*t,a=n*o-t,s=t-(i+1)*o,u=t/32,l=Math.ceil(o/u),_=o/l,c=cs.EARTH_RADIUS+e.base_height,h=this._view_pos_Q,f=this._view_dir_wU,d=this._view_dir_N,v=this._view_dir_V,y=Number.MAX_VALUE,p=-Number.MAX_VALUE,g=0,m=s;g<l+1;++g,m+=_)for(var k=Math.exp(m),w=k*k,E=(w-1)/(w+1),b=2*k/(w+1),x=1/(c*b),A=0,T=a;A<l+1;++A,T+=_){var I=Math.sin(T),P=Math.cos(T);d[0]=b*P,d[1]=b*I,d[2]=E,v[0]=c*d[0]-h[0],v[1]=c*d[1]-h[1],v[2]=c*d[2]-h[2];var L=cs.dot3(f,v);if(L<=0)return{min:-1e3,max:1e3,mid:0};var M=L*x;y=Math.min(y,M),p=Math.max(p,M)}var S=-Math.maprayLog2(p),R=-Math.maprayLog2(y);return{min:S,max:R,mid:(S+R)/2}}},{key:"_calcLOD",value:function(e,t,r){var n=Math.sin(e),i=Math.cos(e),o=Math.exp(t),a=o*o,s=(a-1)/(a+1),u=2*o/(a+1),l=this._view_dir_N;l[0]=u*i,l[1]=u*n,l[2]=s;var _=this._view_dir_V,c=this._view_pos_Q;_[0]=r*l[0]-c[0],_[1]=r*l[1]-c[1],_[2]=r*l[2]-c[2];var h=this._view_dir_wU,f=r*u/cs.dot3(h,_);return Math.maprayLog2(f)}},{key:"_setCornerLODs",value:function(e){var t=Math.PI,r=e.flake,n=r.z,i=r.x,o=r.y,a=Math.pow(2,1-n)*t,s=i*a-t,u=(i+1)*a-t,l=t-(o+1)*a,_=t-o*a,c=cs.EARTH_RADIUS+r.base_height;e.lod_00=this._calcLOD(s,l,c),e.lod_10=this._calcLOD(u,l,c),e.lod_01=this._calcLOD(s,_,c),e.lod_11=this._calcLOD(u,_,c)}},{key:"_addRenderFlake",value:function(e,t){var r=new Vl(e);r.lod=t.mid,this._setCornerLODs(r),this._rflake_list.push(r)}}]),e}();Ul.MAX_LOD_INTERVAL=.5;var Bl=function(){function e(t,r,n){ze(this,e),this._glenv=t;try{this.vs_object=this._compile_shader("VERTEX_SHADER",r),this.fs_object=this._compile_shader("FRAGMENT_SHADER",n)}catch(e){var i=t.context;throw this.vs_object&&i.deleteShader(this.vs_object),this.fs_object&&i.deleteShader(this.fs_object),e}}return je(e,[{key:"dispose",value:function(){var e=this._glenv.context;this.vs_object&&(e.deleteShader(this.vs_object),this.vs_object=null),this.fs_object&&(e.deleteShader(this.fs_object),this.fs_object=null)}},{key:"_compile_shader",value:function(e,t){var r=this._glenv.context,n=r.createShader(r[e]);if(!n)throw new Error(e+" オブジェクトの生成に失敗しました");try{if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS)){var i=r.getShaderInfoLog(n);throw new Error(e+" のコンパイルに失敗: "+i)}}catch(e){throw r.deleteShader(n),e}return n}}]),e}(),zl=function(){function e(t,r,n){ze(this,e);var i=new Bl(t,r,n);this._gl=t.context,this._program=this._link_shaders(i.vs_object,i.fs_object),this._vertex_attribs=this._create_vertex_attribs(),this._uniform_location=this._create_uniform_location(),i.dispose()}return je(e,[{key:"_link_shaders",value:function(e,t){var r=this._gl,n=r.createProgram();if(!n)throw new Error("プログラムオブジェクトの生成に失敗しました");try{if(r.attachShader(n,e),r.attachShader(n,t),r.linkProgram(n),!r.getProgramParameter(n,r.LINK_STATUS)){var i=r.getProgramInfoLog(n);throw r.detachShader(n,t),r.detachShader(n,e),new Error("シェーダのリンクに失敗: "+i)}}catch(e){throw r.deleteProgram(n),e}return n}},{key:"_create_vertex_attribs",value:function(){for(var e=this._gl,t=this._program,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<n;++i){var o=e.getActiveAttrib(t,i),a={name:o.name,location:e.getAttribLocation(t,o.name)};r.push(a)}return r}},{key:"_create_uniform_location",value:function(){for(var e=this._gl,t=this._program,r={},n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),i=0;i<n;++i){var o=e.getActiveUniform(t,i);r[o.name]=e.getUniformLocation(t,o.name)}return r}},{key:"dispose",value:function(){this._gl.deleteProgram(this._program),this._program=null}},{key:"bindProgram",value:function(){this._gl.useProgram(this._program)}},{key:"setBoolean",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform1i(r,t?1:0)}},{key:"setInteger",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform1i(r,t)}},{key:"setFloat",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform1f(r,t)}},{key:"setVector2",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform2fv(r,t)}},{key:"setVector3",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform3fv(r,t)}},{key:"setVector4",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniform4fv(r,t)}},{key:"setMatrix",value:function(e,t){var r=this._uniform_location[e];r&&this._gl.uniformMatrix4fv(r,!1,t)}},{key:"bindVertexAttribs",value:function(e){for(var t=this._gl,r=this._vertex_attribs,n=r.length,i=0;i<n;++i){var o=r[i],a=e[o.name],s=o.location;void 0!==a?(t.bindBuffer(t.ARRAY_BUFFER,a.buffer),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,a.num_components,a.component_type,a.normalized,a.byte_stride,a.byte_offset)):t.disableVertexAttribArray(s)}}},{key:"bindTexture2D",value:function(e,t){var r=this._gl;r.activeTexture(r.TEXTURE0+e),r.bindTexture(r.TEXTURE_2D,t)}}]),e}(),Gl=function(e){function t(e,r,n){var i;return ze(this,t),(i=Je(this,Ye(t).call(this,e.glenv,r,n)))._flake_to_clip=cs.createMatrixf(),i}return qe(t,e),je(t,[{key:"numDrawings",value:function(){return 1}},{key:"isWireframe",value:function(){return!1}},{key:"setFlakeParameter",value:function(e,t,r,n){return!1}},{key:"setCommonParameter",value:function(e,t){t.mul_flake_to_gocs(e._gocs_to_clip,this._flake_to_clip),this.setMatrix("u_obj_to_clip",this._flake_to_clip)}}]),t}(zl),jl=function(){function e(){ze(this,e)}return je(e,[{key:"status",value:function(e){return Yl.READY}},{key:"requestTile",value:function(e,t,r,n){throw new Error("mapray.ImageProvider#requestTile() method has not been overridden.")}},{key:"cancelRequest",value:function(e){throw new Error("mapray.ImageProvider#cancelRequest() method has not been overridden.")}},{key:"getImageSize",value:function(){throw new Error("mapray.ImageProvider#getImageSize() method has not been overridden.")}},{key:"getZoomLevelRange",value:function(){throw new Error("mapray.ImageProvider#getZoomLevelRange() method has not been overridden.")}}]),e}(),ql=function(){function e(t,r){ze(this,e),this._min=t,this._max=r}return je(e,[{key:"min",get:function(){return this._min}},{key:"max",get:function(){return this._max}}]),e}();jl.Range=ql;var Yl={NOT_READY:{id:"NOT_READY"},READY:{id:"READY"},FAILED:{id:"FAILED"}};jl.Status=Yl;var Hl=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this))}return qe(t,e),je(t,[{key:"requestTile",value:function(e,t,r,n){return this}},{key:"cancelRequest",value:function(e){}},{key:"getImageSize",value:function(){return 4096}},{key:"getZoomLevelRange",value:function(){return new jl.Range(0,0)}}]),t}(jl),Xl=function(){function e(t,r,n,i){ze(this,e),this.z=t,this.x=r,this.y=n,this.texture=i}return je(e,[{key:"dispose",value:function(e){e.deleteTexture(this.texture),this.texture=null}}]),e}(),Wl=function(){function e(t,r){var n=this;ze(this,e),this._glenv=t,this._provider=null,this._min_image_z=0,this._max_image_z=0,this._image_zbias=0;this._resetImageProvider(r.status((function(e){e===jl.Status.READY?(n._flush(),n._resetImageProvider(r)):e===jl.Status.FAILED&&console.error("ImageProvider.Status.FAILED in TileTextureCache")}))===jl.Status.READY?r:new Hl),this._croot=new Ql,this._max_accesses=0,this._frame_counter=0,this._lower_bound=1,this._upper_bound=1.2,this._num_requesteds=0,this._max_requesteds=75,this._new_requesteds=[];var i=t.context,o=t.EXT_texture_filter_anisotropic;o&&(this._aniso_ext=o,this._max_aniso=i.getParameter(o.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this._use_mipmap=!1}return je(e,[{key:"_resetImageProvider",value:function(e){this._provider=e;var t=e.getZoomLevelRange();this._min_image_z=t.min,this._max_image_z=t.max,this._image_zbias=Math.maprayLog2(2*Math.PI/e.getImageSize())}},{key:"cancel",value:function(){this._flush()}},{key:"_flush",value:function(){new Kl(this,this._croot),this._croot=new Ql,this._max_accesses=0}},{key:"getImageZBias",value:function(){return this._image_zbias}},{key:"getImageZMin",value:function(){return this._min_image_z}},{key:"getNumWaitingRequests",value:function(){return this._num_requesteds}},{key:"findNearestAncestors",value:function(t,r,n,i){for(var o,a,s,u=0,l=this._min_image_z,_=Math.pow(2,1-t),c=(r+.5)*_,h=(n+.5)*_,f=this._croot;u<l;++u)o=Math.floor(c)%2+2*(Math.floor(h)%2),null===(s=(a=f.children)[o])&&(s=new Ql,a[o]=s),c*=2,h*=2,f=s;var d=this._max_image_z,v=cs.clamp(i-1,l,d),y=null,p=null;if(v<cs.clamp(i,l,d)){for(;u<=v;++u)f.state===$l.LOADED?y=f:f.state===$l.NONE?(f.state=$l.REQUESTED,f.req_power=i-u,this._new_requesteds.push([f,u,Math.floor(.5*c),Math.floor(.5*h)])):f.state===$l.REQUESTED&&f.updateRequestPower(i-u),o=Math.floor(c)%2+2*(Math.floor(h)%2),null===(s=(a=f.children)[o])&&(s=new Ql,a[o]=s),c*=2,h*=2,f=s;p=y,f.state===$l.LOADED?p=f:f.state===$l.NONE?(f.state=$l.REQUESTED,f.req_power=i-u,this._new_requesteds.push([f,u,Math.floor(.5*c),Math.floor(.5*h)])):f.state===$l.REQUESTED&&f.updateRequestPower(i-u)}else for(;;++u){if(f.state===$l.LOADED?y=f:f.state===$l.NONE?(f.state=$l.REQUESTED,f.req_power=i-u,this._new_requesteds.push([f,u,Math.floor(.5*c),Math.floor(.5*h)])):f.state===$l.REQUESTED&&f.updateRequestPower(i-u),u==v){p=y;break}o=Math.floor(c)%2+2*(Math.floor(h)%2),null===(s=(a=f.children)[o])&&(s=new Ql,a[o]=s),c*=2,h*=2,f=s}f.touch();var g=e._findNearestAncestors_result;return g[0]=null!==p?p.data:null,g[1]=null!==y?y.data:null,g}},{key:"endFrame",value:function(){this._performNewRequests();var e=new Zl(this._croot,this._frame_counter);if(this._max_accesses=Math.max(e.num_accesses,this._max_accesses),e.num_loadeds>this._upper_bound*this._max_accesses){var t=Math.floor(this._lower_bound*this._max_accesses);this._reduceCache(t)}++this._frame_counter}},{key:"_performNewRequests",value:function(){var e=Math.min(this._max_requesteds-this._num_requesteds,this._new_requesteds.length);this._new_requesteds.sort((function(e,t){var r=e[0];return t[0].req_power-r.req_power}));var t=this;this._new_requesteds.slice(0,e).forEach((function(e){var r=e[0],n=e[1],i=e[2],o=e[3];t._requestTileTexture(n,i,o,r)})),this._new_requesteds.slice(e).forEach((function(e){e[0].state=$l.NONE})),this._new_requesteds.length=0}},{key:"_requestTileTexture",value:function(e,t,r,n){var i=this;n.data=this._provider.requestTile(e,t,r,(function(o){n.state===$l.REQUESTED&&(o?(n.data=new Xl(e,t,r,i._createTexture(o)),n.state=$l.LOADED):(n.data=null,n.state=$l.FAILED),--i._num_requesteds)})),++this._num_requesteds}},{key:"_createTexture",value:function(e){var t=this._glenv.context,r=this._aniso_ext,n=t.TEXTURE_2D,i=t.createTexture();return t.bindTexture(n,i),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(n,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),this._use_mipmap&&t.generateMipmap(n),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,this._use_mipmap?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),r&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._max_aniso),t.bindTexture(n,null),i}},{key:"_reduceCache",value:function(e){var t=new Jl(this._croot);t.nodes.sort((function(e,t){var r=t.aframe-e.aframe;return 0==r&&e.state===$l.LOADED&&t.state===$l.LOADED?e.data.z-t.data.z:r}));var r=this._glenv.context;t.nodes.slice(e).forEach((function(e){e.state===$l.LOADED&&e.data.dispose(r),e.state=$l.NONE,e.data=null})),t.clean()}}]),e}();Wl._findNearestAncestors_result=new Array(2);var Ql=function(){function e(){ze(this,e),this.children=[null,null,null,null],this.state=$l.NONE,this.data=null,this.req_power=-1,this.aframe=-1}return je(e,[{key:"updateRequestPower",value:function(e){e>this.req_power&&(this.req_power=e)}},{key:"touch",value:function(){this.aframe=!0}}]),e}(),Zl=function(){function e(t,r){ze(this,e),this.num_loadeds=0,this.num_accesses=0,this._frame=r,this._traverse(t)}return je(e,[{key:"_traverse",value:function(e){for(var t=e.children,r=!0===e.aframe,n=0;n<4;++n){var i=t[n];null!==i&&(r=this._traverse(i)||r)}return e.state===$l.LOADED&&(++this.num_loadeds,r&&++this.num_accesses),r&&(e.aframe=this._frame),r}}]),e}(),Jl=function(){function e(t){ze(this,e),this._root=t,this.nodes=[],this._traverse(t)}return je(e,[{key:"_traverse",value:function(e){var t=e.state;t!==$l.LOADED&&t!==$l.FAILED||this.nodes.push(e);for(var r=e.children,n=0;n<4;++n){var i=r[n];null!==i&&this._traverse(i)}}},{key:"clean",value:function(){this._clean_recur(this._root)}},{key:"_clean_recur",value:function(e){for(var t=e.state===$l.NONE,r=e.children,n=0;n<4;++n){var i=r[n];if(null!==i){var o=this._clean_recur(i);!0===o&&(r[n]=null),t=o&&t}}return t}}]),e}(),Kl=function(){function e(t,r){ze(this,e),this._owner=t,this._traverse(r)}return je(e,[{key:"_traverse",value:function(e){for(var t=e.children,r=0;r<4;++r){var n=t[r];null!==n&&this._traverse(n)}if(e.state===$l.REQUESTED){var i=this._owner;e.state=$l.NONE,i._provider.cancelRequest(e.data),--i._num_requesteds}}}]),e}(),$l={NONE:{id:"NONE"},LOADED:{id:"LOADED"},REQUESTED:{id:"REQUESTED"},FAILED:{id:"FAILED"}},e_=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e,"attribute vec4 a_position;         // 位置 (地表断片座標系)\nattribute vec2 a_uv;               // uv 座標\n\nuniform mat4  u_obj_to_clip;       // 地表断片座標系からクリップ座標系への変換\n\nuniform vec4  u_texcoord_rect_hi;  // 高レベル画像 左下座標: (x, y), 座標サイズ: (z, w)\nuniform vec4  u_texcoord_rect_lo;  // 低レベル画像 左下座標: (x, y), 座標サイズ: (z, w)\nuniform vec4  u_corner_lod;        // uv = (0,0), (1,0), (0,1), (1,1) の LOD\n\nvarying vec2  v_texcoord_hi;       // 高レベル画像のテクスチャ座標\nvarying vec2  v_texcoord_lo;       // 低レベル画像のテクスチャ座標\nvarying float v_lod;               // 補間された LOD\n\nvoid main()\n{\n    gl_Position = u_obj_to_clip * a_position;\n\n    // uv 座標をテクスチャ座標に変換\n    v_texcoord_hi = u_texcoord_rect_hi.xy + u_texcoord_rect_hi.zw * a_uv;\n    v_texcoord_lo = u_texcoord_rect_lo.xy + u_texcoord_rect_lo.zw * a_uv;\n\n    // LOD の補間\n    float u = a_uv.x;\n    float v = a_uv.y;\n\n    float lod_00 = u_corner_lod.x;  // uv = (0,0) の LOD\n    float lod_10 = u_corner_lod.y;  // uv = (1,0) の LOD\n    float lod_01 = u_corner_lod.z;  // uv = (0,1) の LOD\n    float lod_11 = u_corner_lod.w;  // uv = (1,1) の LOD\n\n    float lod_u0 = mix( lod_00, lod_10, u );  // uv = (u, 0) の LOD\n    float lod_u1 = mix( lod_01, lod_11, u );  // uv = (u, 1) の LOD\n    float lod_uv = mix( lod_u0, lod_u1, v );  // uv = (u, v) の LOD\n\n    v_lod = lod_uv;\n}\n","precision mediump float;\n\nvarying vec2  v_texcoord_hi;    // 高レベル画像のテクスチャ座標\nvarying vec2  v_texcoord_lo;    // 低レベル画像のテクスチャ座標\nvarying float v_lod;            // 補間された LOD\n\nuniform sampler2D u_image_hi;   // 高レベル画像\nuniform sampler2D u_image_lo;   // 低レベル画像\nuniform float     u_opacity;    // 不透明度\n\n/** 画像パラメータ\n *\n *  x = u_image_lo の LOD\n *  y = 1 / (u_image_hi の LOD - x)\n *\n *  ただし u_image_hi と u_image_lo が同じ画像のときは y = 0\n */\nuniform vec2 u_image_param;\n\n\nvoid main()\n{\n    vec4 color_hi = texture2D( u_image_hi, v_texcoord_hi );\n    vec4 color_lo = texture2D( u_image_lo, v_texcoord_lo );\n\n    // 画像の混合率\n    float lo_lod = u_image_param.x;\n    float  delta = u_image_param.y;\n    float  ratio = clamp( (v_lod - lo_lod) * delta, 0.0, 1.0 );\n\n    gl_FragColor = mix( color_lo, color_hi, ratio );\n    gl_FragColor.a *= u_opacity;  // 不透明度を適用\n}\n"))).bindProgram(),r.setInteger("u_image_hi",t.TEXUNIT_IMAGE_HI),r.setInteger("u_image_lo",t.TEXUNIT_IMAGE_LO),r._tile_texture_cache=e.tile_texture_cache,r._layers=e.layers,r._dummy_tile_texture=r._createDummyTileTexture(e.glenv),r._image_zbias=0,r}return qe(t,e),je(t,[{key:"numDrawings",value:function(){return 1+this._layers.numDrawingLayers()}},{key:"setFlakeParameter",value:function(e,r,n,i){this.setCommonParameter(e,n);var o=this._getMaterialParamater(r,i);return null!==o&&(this.setVector4("u_corner_lod",o.corner_lod),this.setVector4("u_texcoord_rect_hi",o.image_hi.texcoord_rect),this.setVector4("u_texcoord_rect_lo",o.image_lo.texcoord_rect),this.setVector2("u_image_param",[o.image_lo.lod,o.image_hi.lod==o.image_lo.lod?0:1/(o.image_hi.lod-o.image_lo.lod)]),this.setFloat("u_opacity",0==i?1:this._layers.getDrawingLayer(i-1).opacity),this.bindTexture2D(t.TEXUNIT_IMAGE_HI,o.image_hi.texture),this.bindTexture2D(t.TEXUNIT_IMAGE_LO,o.image_lo.texture),!0)}},{key:"_getMaterialParamater",value:function(e,t){var r=0==t?this._tile_texture_cache:this._layers.getDrawingLayer(t-1).tile_cache;this._image_zbias=r.getImageZBias();var n=e.flake,i=n.z;if(i<r.getImageZMin())return null;var o=n.x,a=n.y,s=Math.ceil(e.lod+this._image_zbias);if(i<s)return null;var u=r.findNearestAncestors(i,o,a,s);return t>=1&&null===u[0]?null:{corner_lod:[e.lod_00,e.lod_10,e.lod_01,e.lod_11],image_hi:this._getImageParamater(u[0],i,o,a,s),image_lo:this._getImageParamater(u[1],i,o,a,s-1)}}},{key:"_getImageParamater",value:function(e,t,r,n,i){var o;return null!==e?(o=Math.pow(2,e.z-t),{lod:e.z-this._image_zbias,texture:e.texture,texcoord_rect:[r*o-e.x,1-(n+1)*o+e.y,o,o]}):(o=Math.pow(2,-t),{lod:-this._image_zbias,texture:this._dummy_tile_texture,texcoord_rect:[r*o-Math.floor(o*(r+.5)),1-(n+1)*o+Math.floor(o*(n+.5)),o,o]})}},{key:"_createDummyTileTexture",value:function(e){var t=e.context,r=t.TEXTURE_2D,n=t.createTexture();return t.bindTexture(r,n),t.texImage2D(r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([128,128,128,255])),t.bindTexture(r,null),n}}]),t}(Gl);e_.TEXUNIT_IMAGE_HI=0,e_.TEXUNIT_IMAGE_LO=1;var t_=function(e){function t(e){return ze(this,t),Je(this,Ye(t).call(this,e,"attribute vec4 a_position;\nattribute vec2 a_uv;\n\nuniform mat4 u_obj_to_clip;\n\nvarying vec2 v_uv;\n\nvoid main()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    v_uv  = a_uv;\n}\n","precision mediump float;\n\nvarying vec2 v_uv;\n\nvoid main()\n{\n    vec4 color = (v_uv.x < 0.005 || v_uv.y < 0.005 || v_uv.x > 0.995 || v_uv.y > 0.995) ?\n                 vec4( 1, 1, 0, 1 ) : vec4( 0.5, 0.5, 0.5, 1 );\n    gl_FragColor = color;\n}\n"))}return qe(t,e),je(t,[{key:"isWireframe",value:function(){return!0}},{key:"setFlakeParameter",value:function(e,t,r,n){return this.setCommonParameter(e,r),!0}}]),t}(Gl),r_=ve.indexOf,n_=[].indexOf,i_=!!n_&&1/[1].indexOf(1,-0)<0,o_=xa("indexOf"),a_=Kr("indexOf",{ACCESSORS:!0,1:0});Re({target:"Array",proto:!0,forced:i_||!o_||!a_},{indexOf:function(e){return i_?n_.apply(this,arguments)||0:r_(this,e,arguments.length>1?arguments[1]:void 0)}});var s_=Fa.left,u_=xa("reduce"),l_=Kr("reduce",{1:0});Re({target:"Array",proto:!0,forced:!u_||!l_},{reduce:function(e){return s_(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}}),Re({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var __=i((function(){ot(1)}));Re({target:"Object",stat:!0,forced:__},{keys:function(e){return ot(zt(e))}});var c_,h_,f_,d_=n.Promise,v_=/(iphone|ipod|ipad).*applewebkit/i.test(Fs),y_=n.location,p_=n.setImmediate,g_=n.clearImmediate,m_=n.process,k_=n.MessageChannel,w_=n.Dispatch,E_=0,b_={},x_=function(e){if(b_.hasOwnProperty(e)){var t=b_[e];delete b_[e],t()}},A_=function(e){return function(){x_(e)}},T_=function(e){x_(e.data)},I_=function(e){n.postMessage(e+"",y_.protocol+"//"+y_.host)};p_&&g_||(p_=function(e){for(var t=[],r=1;arguments.length>r;)t.push(arguments[r++]);return b_[++E_]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},c_(E_),E_},g_=function(e){delete b_[e]},"process"==Z(m_)?c_=function(e){m_.nextTick(A_(e))}:w_&&w_.now?c_=function(e){w_.now(A_(e))}:k_&&!v_?(f_=(h_=new k_).port2,h_.port1.onmessage=T_,c_=nr(f_.postMessage,f_,1)):!n.addEventListener||"function"!=typeof postMessage||n.importScripts||i(I_)?c_="onreadystatechange"in l("script")?function(e){st.appendChild(l("script")).onreadystatechange=function(){st.removeChild(this),x_(e)}}:function(e){setTimeout(A_(e),0)}:(c_=I_,n.addEventListener("message",T_,!1)));var P_,L_,M_,S_,R_,C_,D_,O_,F_={set:p_,clear:g_},N_=re.f,V_=F_.set,U_=n.MutationObserver||n.WebKitMutationObserver,B_=n.process,z_=n.Promise,G_="process"==Z(B_),j_=N_(n,"queueMicrotask"),q_=j_&&j_.value;q_||(P_=function(){var e,t;for(G_&&(e=B_.domain)&&e.exit();L_;){t=L_.fn,L_=L_.next;try{t()}catch(e){throw L_?S_():M_=void 0,e}}M_=void 0,e&&e.enter()},G_?S_=function(){B_.nextTick(P_)}:U_&&!v_?(R_=!0,C_=document.createTextNode(""),new U_(P_).observe(C_,{characterData:!0}),S_=function(){C_.data=R_=!R_}):z_&&z_.resolve?(D_=z_.resolve(void 0),O_=D_.then,S_=function(){O_.call(D_,P_)}):S_=function(){V_.call(n,P_)});var Y_,H_,X_,W_,Q_=q_||function(e){var t={fn:e,next:void 0};M_&&(M_.next=t),L_||(L_=t,S_()),M_=t},Z_=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw TypeError("Bad Promise constructor");t=e,r=n})),this.resolve=rr(t),this.reject=rr(r)},J_={f:function(e){return new Z_(e)}},K_=function(e,t){if(c(e),a(t)&&t.constructor===e)return t;var r=J_.f(e);return(0,r.resolve)(t),r.promise},$_=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},ec=F_.set,tc=Qt("species"),rc="Promise",nc=z.get,ic=z.set,oc=z.getterFor(rc),ac=d_,sc=n.TypeError,uc=n.document,lc=n.process,_c=oe("fetch"),cc=J_.f,hc=cc,fc="process"==Z(lc),dc=!!(uc&&uc.createEvent&&n.dispatchEvent),vc=Me(rc,(function(){if(!(A(ac)!==String(ac))){if(66===Bs)return!0;if(!fc&&"function"!=typeof PromiseRejectionEvent)return!0}if(Bs>=51&&/native code/.test(ac))return!1;var e=ac.resolve(1),t=function(e){e((function(){}),(function(){}))};return(e.constructor={})[tc]=t,!(e.then((function(){}))instanceof t)})),yc=vc||!di((function(e){ac.all(e).catch((function(){}))})),pc=function(e){var t;return!(!a(e)||"function"!=typeof(t=e.then))&&t},gc=function(e,t,r){if(!t.notified){t.notified=!0;var n=t.reactions;Q_((function(){for(var i=t.value,o=1==t.state,a=0;n.length>a;){var s,u,l,_=n[a++],c=o?_.ok:_.fail,h=_.resolve,f=_.reject,d=_.domain;try{c?(o||(2===t.rejection&&Ec(e,t),t.rejection=1),!0===c?s=i:(d&&d.enter(),s=c(i),d&&(d.exit(),l=!0)),s===_.promise?f(sc("Promise-chain cycle")):(u=pc(s))?u.call(s,h,f):h(s)):f(i)}catch(e){d&&!l&&d.exit(),f(e)}}t.reactions=[],t.notified=!1,r&&!t.rejection&&kc(e,t)}))}},mc=function(e,t,r){var i,o;dc?((i=uc.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),n.dispatchEvent(i)):i={promise:t,reason:r},(o=n["on"+e])?o(i):"unhandledrejection"===e&&function(e,t){var r=n.console;r&&r.error&&(1===arguments.length?r.error(e):r.error(e,t))}("Unhandled promise rejection",r)},kc=function(e,t){ec.call(n,(function(){var r,n=t.value;if(wc(t)&&(r=$_((function(){fc?lc.emit("unhandledRejection",n,e):mc("unhandledrejection",e,n)})),t.rejection=fc||wc(t)?2:1,r.error))throw r.value}))},wc=function(e){return 1!==e.rejection&&!e.parent},Ec=function(e,t){ec.call(n,(function(){fc?lc.emit("rejectionHandled",e):mc("rejectionhandled",e,t.value)}))},bc=function(e,t,r,n){return function(i){e(t,r,i,n)}},xc=function(e,t,r,n){t.done||(t.done=!0,n&&(t=n),t.value=r,t.state=2,gc(e,t,!0))},Ac=function(e,t,r,n){if(!t.done){t.done=!0,n&&(t=n);try{if(e===r)throw sc("Promise can't be resolved itself");var i=pc(r);i?Q_((function(){var n={done:!1};try{i.call(r,bc(Ac,e,n,t),bc(xc,e,n,t))}catch(r){xc(e,n,r,t)}})):(t.value=r,t.state=1,gc(e,t,!1))}catch(r){xc(e,{done:!1},r,t)}}};vc&&(ac=function(e){li(this,ac,rc),rr(e),Y_.call(this);var t=nc(this);try{e(bc(Ac,this,t),bc(xc,this,t))}catch(e){xc(this,t,e)}},(Y_=function(e){ic(this,{type:rc,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=yi(ac.prototype,{then:function(e,t){var r=oc(this),n=cc(po(this,ac));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=fc?lc.domain:void 0,r.parent=!0,r.reactions.push(n),0!=r.state&&gc(this,r,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),H_=function(){var e=new Y_,t=nc(e);this.promise=e,this.resolve=bc(Ac,e,t),this.reject=bc(xc,e,t)},J_.f=cc=function(e){return e===ac||e===X_?new H_(e):hc(e)},"function"==typeof d_&&(W_=d_.prototype.then,G(d_.prototype,"then",(function(e,t){var r=this;return new ac((function(e,t){W_.call(r,e,t)})).then(e,t)}),{unsafe:!0}),"function"==typeof _c&&Re({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return K_(ac,_c.apply(n,arguments))}}))),Re({global:!0,wrap:!0,forced:vc},{Promise:ac}),tr(ac,rc,!1),gi(rc),X_=oe(rc),Re({target:rc,stat:!0,forced:vc},{reject:function(e){var t=cc(this);return t.reject.call(void 0,e),t.promise}}),Re({target:rc,stat:!0,forced:vc},{resolve:function(e){return K_(this,e)}}),Re({target:rc,stat:!0,forced:yc},{all:function(e){var t=this,r=cc(t),n=r.resolve,i=r.reject,o=$_((function(){var r=rr(t.resolve),o=[],a=0,s=1;ui(e,(function(e){var u=a++,l=!1;o.push(void 0),s++,r.call(t,e).then((function(e){l||(l=!0,o[u]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise},race:function(e){var t=this,r=cc(t),n=r.reject,i=$_((function(){var i=rr(t.resolve);ui(e,(function(e){i.call(t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var Tc=RegExp.prototype,Ic=Tc.toString,Pc=i((function(){return"/a/b"!=Ic.call({source:"a",flags:"b"})})),Lc="toString"!=Ic.name;(Pc||Lc)&&G(RegExp.prototype,"toString",(function(){var e=c(this),t=String(e.source),r=e.flags;return"/"+t+"/"+String(void 0===r&&e instanceof RegExp&&!("flags"in Tc)?Ou.call(e):r)}),{unsafe:!0});t((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r,n){var i=t&&t.prototype instanceof _?t:_,o=Object.create(i.prototype),a=new E(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return x()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=m(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var _=u(e,t,r);if("normal"===_.type){if(n=r.done?"completed":"suspendedYield",_.arg===l)continue;return{value:_.arg,done:r.done}}"throw"===_.type&&(n="completed",r.method="throw",r.arg=_.arg)}}}(e,r,a),o}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l={};function _(){}function c(){}function h(){}var f={};f[i]=function(){return this};var d=Object.getPrototypeOf,v=d&&d(d(b([])));v&&v!==t&&r.call(v,i)&&(f=v);var y=h.prototype=_.prototype=Object.create(f);function p(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function g(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var l=u(e[i],e,o);if("throw"!==l.type){var _=l.arg,c=_.value;return c&&"object"==typeof c&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(c).then((function(e){_.value=e,a(_)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function m(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,m(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function b(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return c.prototype=y.constructor=h,h.constructor=c,h[a]=c.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===c||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a in e||(e[a]="GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},p(g.prototype),g.prototype[o]=function(){return this},e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(s(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},p(y),y[a]="Generator",y[i]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=b,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:b(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));var Mc=[].join,Sc=K!=Object,Rc=xa("join",",");Re({target:"Array",proto:!0,forced:Sc||!Rc},{join:function(e){return Mc.call(ee(this),void 0===e?",":e)}});var Cc="attribute vec4 a_position;\nattribute vec3 a_color;\n\nuniform mat4 u_obj_to_clip; // モデル座標系からクリップ座標系への変換\nuniform float u_point_size; // 点描画サイズ(負の場合は[m]、正の場合は[px])\n\nuniform float u_debug;      // デバッグ用パラメータ(正の場合のみ有効)\n\nvarying vec3 v_color;       // 色\n\n\nvoid main(void) {\n    gl_Position = u_obj_to_clip * a_position;\n\n    if ( u_point_size < 0.0 ) {\n        gl_PointSize = -u_point_size / gl_Position.w;\n    }\n    else {\n        gl_PointSize = u_point_size;\n    }\n\n    if ( u_debug < 0.0 ) {\n        v_color = a_color;\n    }\n    else {\n        float alpha = min( 1.0, u_debug );\n        v_color = vec3( alpha, 0.0, 1.0 - alpha );\n    }\n}\n",Dc="precision highp float;\n\n\nvarying vec3 v_color;       // 色\n\n\nvoid main(void) {\n#if POINT_SHAPE_TYPE == 0 // RECTANGLE\n    gl_FragColor = vec4( v_color,  1.0 );\n\n#elif POINT_SHAPE_TYPE == 1 // CIRCLE\n    if ( length( gl_PointCoord - 0.5 ) > 0.5 ) {\n        discard;\n    }\n    else {\n        gl_FragColor = vec4( v_color,  1.0 );\n    }\n\n#elif POINT_SHAPE_TYPE == 2 // CIRCLE_WITH_BORDER\n    float distance = length( gl_PointCoord - 0.5 );\n    if ( distance > 0.5 ) {\n        discard;\n    }\n    else if ( distance > 0.45 ) {\n        gl_FragColor = vec4( 0, 0, 0, 1.0 );\n    }\n    else {\n        gl_FragColor = vec4( v_color,  1.0 );\n    }\n\n#elif POINT_SHAPE_TYPE == 3 // GRADIENT_CIRCLE\n    vec2 p = 2.0 * gl_PointCoord - 1.0;\n    if ( length(p) > 1.0 ) {\n        discard;\n    }\n    else {\n        gl_FragColor = vec4( v_color * (1.0 - 0.3 * tan((p.x + p.y)*0.7853981633)),  1.0 );\n    }\n\n#endif\n}\n",Oc=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ze(this,t);var i=t._getPreamble(n);return(r=Je(this,Ye(t).call(this,e.glenv,i+Cc,i+Dc))).bindProgram(),r.setFloat("u_point_size",10),r.setFloat("u_debug",-1),r._local_to_clip=cs.createMatrixf(),r}return qe(t,e),je(t,[{key:"setPointSize",value:function(e){this.setFloat("u_point_size",e)}},{key:"setDebug",value:function(e){this.setFloat("u_debug",e)}},{key:"setDebugBoundsParameter",value:function(e,t){return Fc(e._gocs_to_clip,t,this._local_to_clip),this.setMatrix("u_obj_to_clip",this._local_to_clip),!0}}],[{key:"_getPreamble",value:function(e){var t=[],r=e.point_shape_type||Uc.PointShapeType.CIRCLE;return t.push("#define POINT_SHAPE_TYPE "+r.shader_code),t.join("\n")+"\n\n"}}]),t}(zl),Fc=function(e,t,r){var n=e[0],i=e[4],o=e[8],a=e[12],s=e[1],u=e[5],l=e[9],_=e[13],c=e[2],h=e[6],f=e[10],d=e[14],v=e[3],y=e[7],p=e[11],g=e[15],m=t[0],k=t[1],w=t[2];return r[0]=n,r[1]=s,r[2]=c,r[3]=v,r[4]=i,r[5]=u,r[6]=h,r[7]=y,r[8]=o,r[9]=l,r[10]=f,r[11]=p,r[12]=n*m+i*k+o*w+a,r[13]=s*m+u*k+l*w+_,r[14]=c*m+h*k+f*w+d,r[15]=v*m+y*k+p*w+g,r},Nc=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e.glenv,"attribute vec4 a_position;\n\nuniform mat4 u_obj_to_clip;\n\nvoid main(void) {\n    gl_Position = u_obj_to_clip * a_position;\n}\n","precision highp float;\n\nuniform vec3 u_color;\n\nvoid main(void) {\n    gl_FragColor = vec4(u_color, 1.0);\n}\n"))).bindProgram(),r._color=cs.createVector3([0,.2,.4]),r.setVector3("u_color",r._color),r._local_to_clip=cs.createMatrixf(),r}return qe(t,e),je(t,[{key:"setDebugBoundsParameter",value:function(e,t,r){return Fc(e._gocs_to_clip,t,this._local_to_clip),this.setMatrix("u_obj_to_clip",this._local_to_clip),r&&(this._color[0]=r[0],this._color[1]=r[1],this._color[2]=r[2]),this.setVector3("u_color",this._color),!0}}]),t}(zl),Vc=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e.glenv,"attribute vec4 a_position;\n\nuniform mat4 u_obj_to_clip;\nvarying vec4 pos;\n\nvoid main(void) {\n    pos = gl_Position;\n    gl_Position = u_obj_to_clip * a_position;\n}\n","precision highp float;\n\nuniform vec4 u_color;\nvarying vec4 pos;\n\nvoid main(void) {\n    // gl_FragCoord.x, gl_FragCoord.y\n    if (mod(gl_FragCoord.x, 3.0) < 1.0 && mod(gl_FragCoord.y, 3.0) < 1.0) {\n        gl_FragColor = vec4(u_color.x, u_color.y, u_color.z, 1.0);\n    }\n    else {\n        discard;\n    }\n}\n"))).bindProgram(),r._color=cs.createVector4([.3,.9,1,.5]),r.setVector4("u_color",r._color),r._local_to_clip=cs.createMatrixf(),r}return qe(t,e),je(t,[{key:"setDebugBoundsParameter",value:function(e,t,r){return Fc(e._gocs_to_clip,t,this._local_to_clip),this.setMatrix("u_obj_to_clip",this._local_to_clip),r&&(this._color[0]=r[0],this._color[1]=r[1],this._color[2]=r[2],this._color[3]=r[3]||0),this.setVector4("u_color",this._color),!0}}]),t}(zl),Uc=function(){function e(t,r){ze(this,e),this._glenv=t.glenv,this._scene=t,this._provider=r,this._root=jc.createRoot(this),this._points_per_pixel=.7,this._point_shape=e.PointShapeType.CIRCLE,this._point_size_type=e.PointSizeType.FLEXIBLE,this._point_size=1,this._point_size_limit=10,this._dispersion=!0,this._debug_shader=!1,this._debug_render_box=!1,this._debug_render_ellipsoid=!1,this._debug_render_axis=!1,this._debug_render_section=!1,this._checkMaterials(),e._instances.push(this)}var t,r,n;return je(e,[{key:"init",value:(n=Be(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._provider.init();case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"destroy",value:(r=Be(regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._provider){t.next=3;break}return t.next=3,this._provider.destroy();case 3:if(!this._root){t.next=7;break}return t.next=6,this._root.dispose(null);case 6:this._root=null;case 7:-1!==(r=e._instances.indexOf(this))&&e._instances.splice(r,1),this._provider=null;case 10:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"getPointsPerPixel",value:function(){return this._points_per_pixel}},{key:"setPointsPerPixel",value:function(e){console.assert(e<=1),this._points_per_pixel=e}},{key:"getPointShape",value:function(){return this._point_shape}},{key:"setPointShape",value:function(e){this._point_shape=e}},{key:"getPointSizeType",value:function(){return this._point_size_type}},{key:"setPointSizeType",value:function(e){this._point_size_type=e}},{key:"getPointSize",value:function(){return this._point_size}},{key:"setPointSize",value:function(e){console.assert(e>0),this._point_size=e}},{key:"getPointSizeLimit",value:function(){return this._point_size_limit}},{key:"setPointSizeLimit",value:function(e){console.assert(e>0),this._point_size_limit=e}},{key:"getDispersion",value:function(){return this._dispersion}},{key:"setDispersion",value:function(e){this._dispersion=e}},{key:"getDebugShader",value:function(){return this._debug_shader}},{key:"setDebugShader",value:function(e){this._debug_shader=e}},{key:"setDebugRenderBox",value:function(e){this._debug_render_box=e,this._updateDebugMesh()}},{key:"setDebugRenderEllipsoid",value:function(e){this._debug_render_ellipsoid=e,this._updateDebugMesh()}},{key:"setDebugRenderAxis",value:function(e){this._debug_render_axis=e,this._updateDebugMesh()}},{key:"setDebugRenderSection",value:function(e){this._debug_render_section=e,this._updateDebugMesh()}},{key:"_updateDebugMesh",value:function(){this._root&&this._root._updateDebugMeshes()}},{key:"getURL",value:function(e,t,r,n){return this._urlGenerator(e,t,r,n)}},{key:"_checkMaterials",value:function(){var e=this._scene.viewer,t=e._render_cache||(e._render_cache={});t.point_cloud_materials||(t.point_cloud_materials=Object.keys(zc).reduce((function(t,r){var n=zc[r];return t[n.id]=new Oc(e,{point_shape_type:n}),t}),{})),t.point_cloud_debug_wire_material||(t.point_cloud_debug_wire_material=new Nc(e)),t.point_cloud_debug_face_material||(t.point_cloud_debug_face_material=new Vc(e))}},{key:"_getMaterial",value:function(e){return this._scene.viewer._render_cache.point_cloud_materials[e.id]}},{key:"provider",get:function(){return this._provider}},{key:"root",get:function(){return this._root}}],[{key:"requestTraverseSummary",value:(t=Be(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){e.getTraverseDataRequestQueue().push((function r(n){t(n);var i=e.getTraverseDataRequestQueue().indexOf(r);-1!==i&&e.getTraverseDataRequestQueue().splice(i,1)}))})));case 1:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})},{key:"getTraverseDataRequestQueue",value:function(){return e._traverseDataRequestQueue||(e._traverseDataRequestQueue=[])}},{key:"setStatisticsHandler",value:function(t){t&&(e._statistics={statistics_obj:new Bc,statistics_handler:t})}},{key:"getStatistics",value:function(){return e._statistics}},{key:"getStatisticsHandler",value:function(){return e._statistics_handler}},{key:"PointShapeType",get:function(){return zc}},{key:"PointSizeType",get:function(){return Gc}}]),e}();Uc._instances=[];var Bc=function(){function e(){ze(this,e),this._now=performance?function(){return performance.now()}:function(){return Date.now()},this.clear()}return je(e,[{key:"start",value:function(){this._start_time=this._now()}},{key:"doneTraverse",value:function(){this._done_traverse_time=this._now(),this.traverse_time+=this._done_traverse_time-this._start_time}},{key:"done",value:function(){this._done_time=this._now(),this.render_time+=this._done_time-this._done_traverse_time,this.total_time+=this._done_time-this._start_time}},{key:"clear",value:function(){this.render_point_count=0,this.total_point_count=0,this.render_boxes=0,this.total_boxes=0,this.loading_boxes=0,this.created_boxes=0,this.disposed_boxes=0,this.total_time=0,this.traverse_time=0,this.render_time=0}}]),e}(),zc={RECTANGLE:{id:"RECTANGLE",shader_code:0},CIRCLE:{id:"CIRCLE",shader_code:1},CIRCLE_WITH_BORDER:{id:"CIRCLE_WITH_BORDER",shader_code:2},GRADIENT_CIRCLE:{id:"GRADIENT_CIRCLE",shader_code:3}},Gc={PIXEL:{id:"PIXEL"},MILLIMETERS:{id:"MILLIMETERS"},FLEXIBLE:{id:"FLEXIBLE"}},jc=function(){function e(t,r,n,i,o){ze(this,e),this._parent=t,this._owner=t?t._owner:null,this.level=r,this.x=n,this.y=i,this.z=o;var a=this.size=0===r?2147483648:r<31?1<<31-r:Math.pow(.5,r-31);this.proj_area=4*this.size*this.size,this.gocs_center=cs.createVector3([Yc+(2*n+1)*a,Yc+(2*i+1)*a,Yc+(2*o+1)*a]),this.gocs_min=cs.createVector3([this.gocs_center[0]-a,this.gocs_center[1]-a,this.gocs_center[2]-a]),this.gocs_max=cs.createVector3([this.gocs_center[0]+a,this.gocs_center[1]+a,this.gocs_center[2]+a]),this._status=e.Status.NOT_LOADED,this._metaInfo=null,this._children=[null,null,null,null,null,null,null,null],this.average=null,this.eigenVector=null,this.eigenVectorLength=null,this._vertex_buffer=null,this._vertex_length=null,this._vertex_attribs=null,this.debug1=null,this._owner&&this._updateDebugMesh()}return je(e,[{key:"_updateDebugMeshes",value:function(){this._updateDebugMesh();for(var e=0;e<this._children.length;e++)this._children[e]&&this._children[e]._updateDebugMeshes()}},{key:"_updateDebugMesh",value:function(){var t=[],r=[],n=[];if(this._owner._debug_render_box){for(var i=0;i<e.CHILDREN_INDICES.length;i++)t.push(this.size*(2*e.CHILDREN_INDICES[i][2]-1),this.size*(2*e.CHILDREN_INDICES[i][1]-1),this.size*(2*e.CHILDREN_INDICES[i][0]-1));r.push(0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,3,7,2,6),n.push(0,2,1,1,2,3,4,5,6,7,6,5,0,1,4,1,5,4,1,3,5,3,7,5,3,6,7,3,2,6,6,2,4,2,0,4)}if(this.average&&!isNaN(this.eigenVector[0][0])){if(this._owner._debug_render_axis)for(var o=t.length/3,a=0;a<3;a++){for(var s=Math.max(.2,this.eigenVectorLength[a]),u=this.eigenVector[a],l=0;l<3;l++)t.push(this.average[l]-s*u[l]);for(var _=0;_<3;_++)t.push(this.average[_]+s*u[_]);r.push(o++,o++)}this._owner._debug_render_section&&this.level>20&&this.getPointsLength()>5e3&&this.eigenVectorLength[0]<.2*this.size&&this._putSectionShapePoints(t,r,n),this._owner._debug_render_ellipsoid&&this._putVariancePoints(t,r,n)}var c=[];if(r.length>0){var h={vtype:[{name:"a_position",size:3}],ptype:"lines",vertices:t,indices:r};c.push(new ml(this._owner._glenv,h))}if(n.length>0){var f={vtype:[{name:"a_position",size:3}],ptype:"triangles",vertices:t,indices:n};c.push(new ml(this._owner._glenv,f))}this.debugMesh=c}},{key:"_putVariancePoints",value:function(e,t,r){for(var n,i,o,a,s,u,l,_=this,c=e.length/3,h=$e(this.eigenVector,3),f=h[0],d=h[1],v=h[2],y=$e(this.eigenVectorLength,3),p=y[0],g=y[1],m=y[2],k=12,w=Uc._variance_points_cache||function(){for(var e={cos_ro:[],sin_ro:[],cos_th:[],sin_th:[]},t=0;t<=6;++t){var r=Math.PI*t/6;e.cos_ro[t]=Math.cos(r),e.sin_ro[t]=Math.sin(r)}for(var n=0;n<=k;++n){var i=2*Math.PI*n/k;e.cos_th[n]=Math.cos(i),e.sin_th[n]=Math.sin(i)}return Uc._variance_points_cache=e}(),E=0;E<=6;++E)for(var b=0;b<=k;++b)n=E,i=b,o=e,a=void 0,s=void 0,u=void 0,l=void 0,a=w.cos_ro[n],s=w.sin_ro[n],u=w.cos_th[i],l=w.sin_th[i],o.push(_.average[0]+s*(g*u*d[0]+m*l*v[0])+p*a*f[0],_.average[1]+s*(g*u*d[1]+m*l*v[1])+p*a*f[1],_.average[2]+s*(g*u*d[2]+m*l*v[2])+p*a*f[2]);for(var x=0;x<6;++x)for(var A=0;A<k;++A){var T=c+13*x+A;t.push(T,T+1,T,T+k+1),r.push(T,T+1,T+k+1,T+k+1,T+1,T+k+2)}}},{key:"_putSectionShapePoints",value:function(e,t,r){for(var n,i,o=e.length/3,a=this.average,s=this.eigenVector[0],u=this.size,l=Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]),_=[s[0]/l,s[1]/l,s[2]/l],c=[],h=[],f=0;f<2;++f)for(var d=0;d<2;++d)h.push({p:[f>0?u:-u,d>0?u:-u,0],v:[0,0,u]},{p:[d>0?u:-u,0,f>0?u:-u],v:[0,u,0]},{p:[0,f>0?u:-u,d>0?u:-u],v:[u,0,0]});for(var v=0;v<h.length;v++){var y=h[v].p,p=h[v].v,g=((a[0]-y[0])*_[0]+(a[1]-y[1])*_[1]+(a[2]-y[2])*_[2])/(p[0]*_[0]+p[1]*_[1]+p[2]*_[2]);if(Math.abs(g)<=1){var m=[y[0]+g*p[0],y[1]+g*p[1],y[2]+g*p[2]],k=[m[0]-a[0],m[1]-a[1],m[2]-a[2]],w=void 0;n?w=Math.atan2(i[0]*k[0]+i[1]*k[1]+i[2]*k[2],n[0]*k[0]+n[1]*k[1]+n[2]*k[2]):(w=0,n=[(i=[_[1]*k[2]-_[2]*k[1],_[2]*k[0]-_[0]*k[2],_[0]*k[1]-_[1]*k[0]])[1]*_[2]-i[2]*_[1],i[2]*_[0]-i[0]*_[2],i[0]*_[1]-i[1]*_[0]]),c.push([].concat(m,[w,k[0],k[1],k[2],n[0]*k[0]+n[1]*k[1]+n[2]*k[2],i[0]*k[0]+i[1]*k[1]+i[2]*k[2]]))}}c.sort((function(e,t){return e[3]-t[3]}));for(var E=0;E<c.length;++E)e.push(c[E][0],c[E][1],c[E][2]),t.push(o+E),E==c.length-1?t.push(o):t.push(o+E+1),r&&(r.push(o,o+E),E==c.length-1?r.push(o):r.push(o+E+1))}},{key:"getChildInfo",value:function(e){return this._metaInfo?this._metaInfo.children[e]:null}},{key:"cellPointsAvailable",value:function(e){return this._metaInfo&&(0===e?this._metaInfo.indices[e]>0:this._metaInfo.indices[e]>this._metaInfo.indices[e-1])}},{key:"getPointsLength",value:function(){return this._metaInfo?this._metaInfo.indices[7]:0}},{key:"indexOf",value:function(e){return this._children.indexOf(e)}},{key:"isInvisible",value:function(e){if(0===this.level)return!1;for(var t=this.gocs_min[0],r=this.gocs_max[0],n=this.gocs_min[1],i=this.gocs_max[1],o=this.gocs_min[2],a=this.gocs_max[2],s=0;s<e.length;++s){var u=e[s],l=u[0],_=u[1],c=u[2],h=u[3],f=l*t+_*n,d=l*r+_*n,v=l*t+_*i,y=l*r+_*i,p=-c*o-h,g=-c*a-h;if(f<p&&d<p&&v<p&&y<p&&f<g&&d<g&&v<g&&y<g)return!0}return!1}},{key:"load",value:function(){var t=this;if(this._status!==e.Status.NOT_LOADED)throw new Error("illegal status: "+this._status.id);if(this._owner._provider.isReady()){this._status=e.Status.LOADING;var r=this._owner._provider.load(this.level,this.x,this.y,this.z,!0);return this._loadId=r.id,r.done.then((function(r){t._metaInfo={children:[],indices:r.header.indices};for(var n=r.header.childFlags,i=7;i>=0;--i)t._metaInfo.children[i]=1&n?{}:null,n>>=1;t.average=r.header.average,t.eigenVector=r.header.eigenVector,t.eigenVectorLength=r.header.eigenVectorLength,t.debug1=r.header.debug1;var o=r.body;console.assert(o.length>0),console.assert(o.length/6===t._metaInfo.indices[7]);for(var a=o.length/6,s=0;s<8;++s)t._metaInfo.indices[s]>a&&(console.log("warning fix indices"),t._metaInfo.indices[s]=a);var u=t._owner._glenv.context;t._vertex_buffer=u.createBuffer(),t._vertex_length=o.length/6,u.bindBuffer(u.ARRAY_BUFFER,t._vertex_buffer),u.bufferData(u.ARRAY_BUFFER,o,u.STATIC_DRAW),u.bindBuffer(u.ARRAY_BUFFER,null),t._vertex_attribs={a_position:{buffer:t._vertex_buffer,num_components:3,component_type:u.FLOAT,normalized:!1,byte_stride:24,byte_offset:0},a_color:{buffer:t._vertex_buffer,num_components:3,component_type:u.FLOAT,normalized:!1,byte_stride:24,byte_offset:12}},t._status=e.Status.LOADED,t._updateDebugMesh()})).catch((function(r){"cancel"===r.message||"not loading"===r.message||"The user aborted a request."===r.message||r.is_aborted||(console.log(r),t._status=e.Status.DESTROYED)}))}}},{key:"newChild",value:function(t,r){var n=$e(e.CHILDREN_INDICES[t],3),i=n[0],o=n[1],a=n[2];return this.newChildAt(i,o,a,r)}},{key:"newChildAt",value:function(t,r,n,i){console.assert(this._status===e.Status.LOADED);var o=t|r<<1|n<<2,a=this._children[o];return a||(this.getChildInfo(o)?(i&&i.created_boxes++,this._children[o]=new e(this,this.level+1,this.x<<1|t,this.y<<1|r,this.z<<1|n)):null)}},{key:"getChild",value:function(e){return this._children[e]}},{key:"_drawDebugMesh",value:function(t){if(this.debugMesh){var r=t._glenv.context,n=e.STATUS_COLOR_TABLE[this._status.id];r.disable(r.CULL_FACE);var i=!0,o=!1,a=void 0;try{for(var s,u=this.debugMesh[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,_=1===l._draw_mode?this._owner._scene.viewer._render_cache.point_cloud_debug_wire_material:this._owner._scene.viewer._render_cache.point_cloud_debug_face_material;_.bindProgram(),_.setDebugBoundsParameter(t,this.gocs_center,n),l.draw(_)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}r.enable(r.CULL_FACE)}}},{key:"draw",value:function(t,r,n,i){if(this.debugMesh&&this._drawDebugMesh(t),this._status===e.Status.LOADED){var o=t._glenv.context,a=this._owner._point_shape,s=this._owner._point_size_type,u=this._owner._point_size,l=this._owner._point_size_limit,_=this._owner._debug_shader;if(this._status===e.Status.LOADED){var c=this._owner._getMaterial(a);c.bindProgram(),c.setDebugBoundsParameter(t,this.gocs_center),c.bindVertexAttribs(this._vertex_attribs);if(null===r){var h=n[0];c.setPointSize(s===Uc.PointSizeType.PIXEL?u:s===Uc.PointSizeType.MILLIMETERS?-.001*u/t._pixel_step:Math.min(l,Math.max(1,3/h))),c.setDebug(_?.5/h:-1),o.drawArrays(o.POINTS,0,this._vertex_length)}else for(var f=0;f<r.length;f++){var d=n[f];c.setPointSize(s===Uc.PointSizeType.PIXEL?u:s===Uc.PointSizeType.MILLIMETERS?-.001*u/t._pixel_step:Math.min(l,Math.max(1,3/d))),c.setDebug(_?.5/d:-1);var v=r[f],y=v>0?this._metaInfo.indices[v-1]:0,p=this._metaInfo.indices[v]-y;p>0&&o.drawArrays(o.POINTS,y,p)}if(o.bindBuffer(o.ARRAY_BUFFER,null),i)if(i.render_boxes++,r&&this._metaInfo.indices){var g=!0,m=!1,k=void 0;try{for(var w,E=r[Symbol.iterator]();!(g=(w=E.next()).done);g=!0){var b=w.value,x=b>0?this._metaInfo.indices[b-1]:0,A=this._metaInfo.indices[b]-x;i.render_point_count+=A}}catch(e){m=!0,k=e}finally{try{g||null==E.return||E.return()}finally{if(m)throw k}}}else i.render_point_count+=this._vertex_length}}}},{key:"disposeChildren",value:function(e){for(var t=0;t<this._children.length;t++)this._children[t]&&(this._children[t].dispose(e),this._children[t]=null)}},{key:"dispose",value:function(t){(this._status===e.Status.LOADING&&(this._abort_controller&&this._abort_controller.abort(),this._owner._provider.cancel(this._loadId)),this.disposeChildren(t),this._vertex_buffer)&&(this._owner._glenv.context.deleteBuffer(this._vertex_buffer),this._vertex_buffer=null);this.debugMesh,t&&t.disposed_boxes++,this._status=e.Status.DESTROYED}},{key:"toString",value:function(){return"Box-".concat(this.level,"-").concat(this.x,"-").concat(this.y,"-").concat(this.z)}},{key:"toTreeString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this._children.reduce((function(t,r){return t+(r?"\n"+r.toTreeString(e+"  "):"")}),e+this.toString())}},{key:"status",get:function(){return this._status}},{key:"is_loaded",get:function(){return this._status===e.Status.LOADED}},{key:"parent",get:function(){return this._parent}}],[{key:"createRoot",value:function(t){var r=new e(null,0,0,0,0);return r._owner=t,r}},{key:"Status",get:function(){return qc}}]),e}();jc.CHILDREN_INDICES=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]];var qc={NOT_LOADED:{id:"NOT_LOADED"},LOADING:{id:"LOADING"},LOADED:{id:"LOADED"},DESTROYED:{id:"DESTROYED"}};jc.STATUS_COLOR_TABLE={},jc.STATUS_COLOR_TABLE[jc.Status.LOADED.id]=[0,.8,1,.5],jc.STATUS_COLOR_TABLE[jc.Status.DESTROYED.id]=[1,0,0],jc.STATUS_COLOR_TABLE[jc.Status.LOADING.id]=[1,1,0],jc.STATUS_COLOR_TABLE[jc.Status.NOT_LOADED.id]=[0,1,0];var Yc=1<<31,Hc=function(){function e(t,r,n){ze(this,e),this._box=t,this._distance=r,this._target_children=[],this._points_per_pixel=[],this._parent_points_per_pixel=n}return je(e,[{key:"pushRegion",value:function(e,t){if(null!==this._target_children){var r=this._target_children.indexOf(e);-1===r?(this._target_children.push(e),this._points_per_pixel.push(t)):(this._target_children[r]=e,this._points_per_pixel[r]=t)}}},{key:"setWholeRegion",value:function(e){this._target_children=null,this._points_per_pixel=[e]}},{key:"draw",value:function(e,t){this._box.draw(e,this._target_children,this._points_per_pixel,t)}},{key:"box",get:function(){return this._box}},{key:"distance",get:function(){return this._distance}},{key:"parent_points_per_pixel",get:function(){return this._parent_points_per_pixel}}]),e}(),Xc=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;ze(this,e),this._setupViewVectors(t),this._setupClipPlanes(t),this._point_cloud_collection=t._point_cloud_collection,this._render_boxes=[],this._render_boxes_map=new Map,this._load_boxes=[],this._load_limit=r}return je(e,[{key:"_setupViewVectors",value:function(e){var t=e._view_to_gocs,r=e._pixel_step,n=cs.createVector3(),i=cs.createVector3();n[0]=t[12],n[1]=t[13],n[2]=t[14],i[0]=-t[8]*r,i[1]=-t[9]*r,i[2]=-t[10]*r,this._view_pos_Q=n,this._view_dir_wU=i}},{key:"_setupClipPlanes",value:function(e){var t=e._view_to_gocs,r=e._gocs_to_view;this.volume_planes=e._volume_planes;var n=[],i=e._viewer._globe.root_flake,o=cs.EARTH_RADIUS+i.height_min,a=cs.EARTH_RADIUS+i.height_max,s=t[12],u=t[13],l=t[14],_=s*s+u*u+l*l,c=o*o,h=a*a,f=Math.sqrt((_-c)*(h-c))-c,d=cs.createVector4(),v=1/Math.sqrt(_);d[0]=s*v,d[1]=u*v,d[2]=l*v,d[3]=f*v;for(var y=Math.sqrt(_+h+2*f),p=0;p<6;++p){var g=this.volume_planes[p],m=cs.createVector4();1==p&&g[3]>y&&((g=cs.createVector4(g))[3]=y),cs.transformPlane_A(r,g,m),n.push(m)}this._clip_planes=n}},{key:"traverse",value:function(e,t){return this._points_per_pixel=e.getPointsPerPixel(),this._dispersion=e.getDispersion(),this._statistics=t,this._updateBox(e.root,0),{visible_boxes:this._render_boxes,load_boxes:this._load_boxes}}},{key:"_updateBox",value:function(e,t){var r,n;if(this._statistics&&(this._statistics.total_boxes++,e.status===jc.Status.LOADING&&this._statistics.loading_boxes++,e.getPointsLength()&&(this._statistics.total_point_count+=e.getPointsLength())),e.isInvisible(this._clip_planes))e.disposeChildren(this._statistics);else if((n=e.is_loaded?(r=this._calcPointsPerPixel(e))<this._points_per_pixel?Wc.LOAD_NEXT_LEVEL:Wc.UNLOAD_NEXT_LEVEL:Wc.KEEP_STATUS)!==Wc.LOAD_NEXT_LEVEL)n===Wc.UNLOAD_NEXT_LEVEL&&e.disposeChildren(this._statistics),e.status!==jc.Status.DESTROYED&&(this._pushBox(e,null,r,t),e.status!==jc.Status.LOADING&&e.status!==jc.Status.NOT_LOADED||e.level>1&&this._pushBox(e.parent,e.parent.indexOf(e),t,t));else{this._collectNextLevel(e,r);for(var i=0;i<8;i++)e.cellPointsAvailable(i)&&!e.getChild(i)&&this._pushBox(e,i,r,t)}}},{key:"_calcPointsPerPixel",value:function(e){var t;if(e.eigenVectorLength[0]<.8*e.size&&this._dispersion&&e.eigenVectorLength[0]>0){var r=cs.normalize3(this._view_dir_wU,cs.createVector3f()),n=$e(e.eigenVector,3),i=n[0],o=n[1],a=n[2],s=$e(e.eigenVectorLength,3),u=s[0],l=s[1],_=s[2],c=[cs.dot3(o,r),cs.dot3(i,r),cs.dot3(a,r)],h=c[0]*c[0]/(l*l)+c[2]*c[2]/(_*_),f=[h*_*u/l*c[0],h*l*_/u*c[1],h*u*l/_*c[2]];cs.normalize3(f,f);var d=(f[0]*c[0]+f[1]*c[1]+f[2]*c[2])*(Math.PI*u*l*_/Math.sqrt(f[0]*f[0]*l*l+f[1]*f[1]*u*u+f[2]*f[2]*_*_)),v=Math.min(Math.max(d,.05*e.proj_area),e.proj_area);t=Math.sqrt(e.getPointsLength()/v)}else t=64/e.size;var y=[e.gocs_center[0]+e.average[0]-this._view_pos_Q[0],e.gocs_center[1]+e.average[1]-this._view_pos_Q[1],e.gocs_center[2]+e.average[2]-this._view_pos_Q[2]];return cs.dot3(this._view_dir_wU,y)*t}},{key:"_pushBox",value:function(e,t,r,n){var i=this._render_boxes_map.get(e);if(i)null===t?i.setWholeRegion(r):i.pushRegion(t,r);else{var o=e.is_loaded?[e.gocs_center[0]+e.average[0]-this._view_pos_Q[0],e.gocs_center[1]+e.average[1]-this._view_pos_Q[1],e.gocs_center[2]+e.average[2]-this._view_pos_Q[2]]:[e.gocs_center[0]-this._view_pos_Q[0],e.gocs_center[1]-this._view_pos_Q[1],e.gocs_center[2]-this._view_pos_Q[2]],a=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]);i=new Hc(e,a,n),null===t?i.setWholeRegion(r):i.pushRegion(t,r),this._render_boxes.push(i),this._render_boxes_map.set(e,i),e.status===jc.Status.NOT_LOADED&&this._pushLoadBox(i)}}},{key:"_pushLoadBox",value:function(e){var t=this._binarySearch(this._load_boxes,e,(function(e,t){return e.parent_points_per_pixel<t.parent_points_per_pixel}));-1===t?this._load_boxes.push(e):this._insert_with_limit(this._load_boxes,t,e,this._load_limit)}},{key:"_insert_with_limit",value:function(e,t,r,n){if(void 0===n||n-e.length>0)e.splice(t,0,r);else{if(t===e.length)return;for(var i=e.length-1;i>t;i--)e[i]=e[i-1];e[t]=r}}},{key:"_binarySearch",value:function(e,t,r){return 0===e.length?-1:r(t,e[0])?0:r(e[e.length-1],t)?e.length:1===e.length?e.length:this._binarySearchInner(e,t,r,0,e.length-1)}},{key:"_binarySearchInner",value:function(e,t,r,n,i){if(i-n==1)return i;var o=.5*(n+i)|0;return r(e[o],t)?n=o:i=o,this._binarySearchInner(e,t,r,n,i)}},{key:"_collectNextLevel",value:function(e,t){for(var r,n=0;n<8;n++)(r=e.newChild(n,this._statistics))&&this._updateBox(r,t)}}]),e}(),Wc={LOAD_NEXT_LEVEL:1,KEEP_STATUS:0,UNLOAD_NEXT_LEVEL:-1},Qc=function(){function e(t){ze(this,e),this._viewer=t,this._glenv=t.glenv;var r=t.canvas_element;if(this._width=r.width,this._height=r.height,0!==this._width&&0!==this._height){var n=t.camera,i=n.createRenderInfo();this._setupBasicMatrices(i,n),this._volume_planes=i.volume_planes,this._pixel_step=i.pixel_step,this._scene=t.scene,this._globe=t.globe,this._tile_texture_cache=t.tile_texture_cache,this._point_cloud_collection=t.point_cloud_collection,t._render_cache||(t._render_cache={surface_material:new e_(t),wireframe_material:new t_(t)}),this._flake_material=t.render_mode===Py.RenderMode.WIREFRAME?t._render_cache.wireframe_material:t._render_cache.surface_material,this._debug_stats=t.debug_stats}else this._rendering_cancel=!0}return je(e,[{key:"_setupBasicMatrices",value:function(e,t){this._view_to_gocs=t.view_to_gocs,this._gocs_to_view=cs.createMatrix(),cs.inverse_A(this._view_to_gocs,this._gocs_to_view),this._view_to_clip=e.view_to_clip,this._gocs_to_clip=cs.createMatrix(),cs.mul_PzA(this._view_to_clip,this._gocs_to_view,this._gocs_to_clip)}},{key:"render",value:function(){if(!this._rendering_cancel){var e=this._glenv.context;if(e.viewport(0,0,this._width,this._height),e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.enable(e.CULL_FACE),e.enable(e.DEPTH_TEST),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE),e.depthFunc(e.LEQUAL),this._globe.status===Sl.Status.READY){var t=new Ul(this).traverse(),r=this._viewer.getVisibility(Py.Category.GROUND),n=this._viewer.getVisibility(Py.Category.ENTITY);this._prepare_draw_flake();var i=!0,o=!1,a=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,_=l.getRenderObject();r&&this._draw_flake_base(l,_.getBaseMesh()),n&&this._draw_entities_on_flake(_)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}this._draw_point_cloud(),n&&this._scene.draw(this);var c=this._debug_stats;null!==c&&(c.num_drawing_flakes=t.length),this._globe.endFrame(),this._tile_texture_cache.endFrame(),this._viewer.layers.endFrame()}}}},{key:"_prepare_draw_flake",value:function(){var e=this._scene.getFlakePrimitiveProducers();this._globe.putNextEntityProducers(e)}},{key:"_draw_flake_base",value:function(e,t){var r=this._glenv.context,n=this._flake_material;n.bindProgram();var i=n.numDrawings();n.setFlakeParameter(this,e,t,0)&&(r.disable(r.BLEND),r.depthMask(!0),t.draw(n));for(var o=1;o<i;++o)n.setFlakeParameter(this,e,t,o)&&(r.enable(r.BLEND),r.depthMask(!1),t.draw(n));var a=this._debug_stats;null!==a&&(a.num_drawing_flake_vertices+=t.num_vertices)}},{key:"_draw_entities_on_flake",value:function(e){var t=e.num_entities;if(0!=t){var r=this._glenv.context;r.enable(r.POLYGON_OFFSET_FILL),r.depthMask(!1),r.polygonOffset(-8,-8);for(var n=0;n<t;++n){var i=e.getEntityPrimitive(n,this);i.isTranslucent(this)?r.enable(r.BLEND):r.disable(r.BLEND),i.draw(this)}r.disable(r.POLYGON_OFFSET_FILL)}}},{key:"_draw_point_cloud",value:function(){var e=Uc.getTraverseDataRequestQueue(),t=0===e.length?null:[],r=Uc.getStatistics()||{};r.statistics_obj&&r.statistics_obj.clear();for(var n=0;n<this._point_cloud_collection.length;++n){r.statistics_obj&&r.statistics_obj.start();var i=this._point_cloud_collection.get(n),o=Math.max(0,10-i.provider.getNumberOfRequests()),a=new Xc(this,o).traverse(i,r.statistics_obj);if(r.statistics_obj&&r.statistics_obj.doneTraverse(),i.provider.isReady()){var s=!0,u=!1,l=void 0;try{for(var _,c=a.load_boxes[Symbol.iterator]();!(s=(_=c.next()).done);s=!0){_.value.box.load()}}catch(e){u=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(u)throw l}}}var h=!0,f=!1,d=void 0;try{for(var v,y=a.visible_boxes[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){v.value.draw(this,r.statistics_obj)}}catch(e){f=!0,d=e}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}i.provider.flushQueue(),t&&t.push({point_cloud:i,pcb_collection:a.visible_boxes}),r.statistics_obj&&r.statistics_obj.done()}if(t)for(var p=0;p<e.length;p++)e[p](t);r.statistics_handler&&r.statistics_handler(r.statistics_obj)}}]),e}(),Zc={OMIT:{id:"OMIT",credentials:"omit"},SAME_ORIGIN:{id:"SAME_ORIGIN",credentials:"same-origin"},INCLUDE:{id:"INCLUDE",credentials:"include"}},Jc=function(e){function t(e,r,n,i,o,a){var s,u,l;return ze(this,t),(s=Je(this,Ye(t).call(this)))._prefix=e,s._suffix=r,s._size=n,s._min_level=i,s._max_level=o,a&&a.coord_order&&(a.coord_order===Kc.ZYX?u=function(e,t,r){return e+"/"+r+"/"+t}:a.coord_order===Kc.XYZ&&(u=function(e,t,r){return t+"/"+r+"/"+e})),u||(u=function(e,t,r){return e+"/"+t+"/"+r}),a&&a.coord_system&&a.coord_system===$c.LOWER_LEFT&&(l=function(e,t,r){var n=Math.round(Math.pow(2,e));return u(e,t,n-r-1)}),l||(l=u),s._coords_part=l,s._crossOrigin="anonymous",a&&a.credentials&&(a.credentials===Zc.OMIT?s._crossOrigin=null:a.credentials===Zc.INCLUDE&&(s._crossOrigin="use-credentials")),s}return qe(t,e),je(t,[{key:"requestTile",value:function(e,t,r,n){var i=new Image;return i.onload=function(){n(i)},i.onerror=function(){n(null)},null!==this._crossOrigin&&(i.crossOrigin=this._crossOrigin),i.src=this._makeURL(e,t,r),i}},{key:"cancelRequest",value:function(e){}},{key:"getImageSize",value:function(){return this._size}},{key:"getZoomLevelRange",value:function(){return new jl.Range(this._min_level,this._max_level)}},{key:"_makeURL",value:function(e,t,r){return this._prefix+this._coords_part(e,t,r)+this._suffix}}]),t}(jl),Kc={ZXY:{id:"ZXY"},ZYX:{id:"ZYX"},XYZ:{id:"XYZ"}},$c={UPPER_LEFT:{id:"UPPER_LEFT"},LOWER_LEFT:{id:"LOWER_LEFT"}};Jc.CoordOrder=Kc,Jc.CoordSystem=$c;var eh=Object.assign,th=Object.defineProperty,rh=!eh||i((function(){if(o&&1!==eh({b:1},eh(th({},"a",{enumerable:!0,get:function(){th(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol();return e[r]=7,"abcdefghijklmnopqrst".split("").forEach((function(e){t[e]=e})),7!=eh({},e)[r]||"abcdefghijklmnopqrst"!=ot(eh({},t)).join("")}))?function(e,t){for(var r=zt(e),n=arguments.length,i=1,a=we.f,s=W.f;n>i;)for(var u,l=K(arguments[i++]),_=a?ot(l).concat(a(l)):ot(l),c=_.length,h=0;c>h;)u=_[h++],o&&!s.call(l,u)||(r[u]=l[u]);return r}:eh;Re({target:"Object",stat:!0,forced:Object.assign!==rh},{assign:rh});var nh=function(){function e(){ze(this,e)}return je(e,[{key:"requestTile",value:function(e,t,r,n){throw new Error("mapray.DemProvider#requestTile() method has not been overridden.")}},{key:"cancelRequest",value:function(e){throw new Error("mapray.DemProvider#cancelRequest() method has not been overridden.")}},{key:"getResolutionPower",value:function(){return 8}}]),e}(),ih=function(e){function t(e,r,n){var i;ze(this,t);var o=n||{};return(i=Je(this,Ye(t).call(this)))._prefix=e,i._suffix=r,i._credentials=(o.credentials||Zc.OMIT).credentials,i._headers=Object.assign({},o.headers),i}return qe(t,e),je(t,[{key:"requestTile",value:function(e,t,r,n){var i=new AbortController;return fetch(this._makeURL(e,t,r),{credentials:this._credentials,headers:this._headers,signal:i.signal}).then((function(e){return e.ok?e.arrayBuffer():Promise.reject(Error(e.statusText))})).then((function(e){n(e)})).catch((function(){n(null)})),i}},{key:"cancelRequest",value:function(e){e.abort()}},{key:"_makeURL",value:function(e,t,r){return this._prefix+e+"/"+t+"/"+r+this._suffix}}]),t}(nh),oh=function(){function e(t,r){ze(this,e),this._owner=t,this._glenv=t.glenv;var n=r instanceof jl?{image_provider:r}:r;this._image_provider=n.image_provider,this._visibility=n.visibility||!0,this._opacity=n.opacity||1,this._tile_cache=new Wl(this._glenv,this._image_provider),this._image_provider.status((function(e){t.dirtyDrawingLayers()}))}return je(e,[{key:"setImageProvider",value:function(e){var t=this;this._image_provider!==e&&(this._owner.dirtyDrawingLayers(),e.status((function(e){t._owner.dirtyDrawingLayers()}))),this._image_provider=e,this._tile_cache.cancel(),this._tile_cache=new Wl(this._glenv,e)}},{key:"setVisibility",value:function(e){this._visibility!=e&&this._owner.dirtyDrawingLayers(),this._visibility=e}},{key:"setOpacity",value:function(e){this._opacity=e}},{key:"image_provider",get:function(){return this._image_provider}},{key:"visibility",get:function(){return this._visibility}},{key:"opacity",get:function(){return this._opacity}},{key:"tile_cache",get:function(){return this._tile_cache}}]),e}(),ah=function(){function e(t,r){ze(this,e),this._glenv=t,this._layers=[],this._draw_layers=null;for(var n=0;n<r.length;++n)this.add(r[n])}return je(e,[{key:"getLayer",value:function(e){return this._layers[e]}},{key:"clear",value:function(){for(;this.num_layers()>0;)this.remove(0)}},{key:"add",value:function(e){this.insert(this.num_layers,e)}},{key:"insert",value:function(e,t){this._layers.splice(e,0,new oh(this,t)),this.dirtyDrawingLayers()}},{key:"remove",value:function(e){this._layers.splice(e,1),this.dirtyDrawingLayers()}},{key:"numDrawingLayers",value:function(){return null===this._draw_layers&&this._updataDrawingLayers(),this._draw_layers.length}},{key:"getDrawingLayer",value:function(e){return null===this._draw_layers&&this._updataDrawingLayers(),this._draw_layers[e]}},{key:"endFrame",value:function(){for(var e=this._layers,t=0;t<e.length;++t)e[t].tile_cache.endFrame()}},{key:"cancel",value:function(){for(var e=this._layers,t=0;t<e.length;++t)e[t].tile_cache.cancel()}},{key:"dirtyDrawingLayers",value:function(){this._draw_layers=null}},{key:"_updataDrawingLayers",value:function(){for(var e=this.num_layers,t=[],r=0;r<e;++r){var n=this._layers[r];n.image_provider.status()===jl.Status.READY&&!0===n.visibility&&t.push(n)}this._draw_layers=t}},{key:"glenv",get:function(){return this._glenv}},{key:"num_layers",get:function(){return this._layers.length}}]),e}(),sh=function(){function e(t){ze(this,e),this._scene=t,this._items=[]}return je(e,[{key:"get",value:function(e){return this._items[e]}},{key:"add",value:function(e){return this.insert(this.length,e)}},{key:"insert",value:function(e,t){var r=new Uc(this._scene,t);return this._items.splice(e,0,r),r.init(),r}},{key:"removeByIndex",value:function(e){var t=this._items.splice(e,1)[0];return t.destroy(),t}},{key:"remove",value:function(e){var t=this._items.indexOf(e);if(-1===t)throw new Error("Couldn't find item: "+e);this.removeByIndex(t)}},{key:"length",get:function(){return this._items.length}}]),e}(),uh=function(){function e(){ze(this,e),this._viewer=null,this._is_started_=!1}return je(e,[{key:"attach",value:function(e){if(this._viewer)throw new Error("RenderCallback instance is already attached");this._viewer=e,this._is_started_=!1}},{key:"detach",value:function(){this._is_started_&&(this.onStop(),this._is_started_=!1),this._viewer=null}},{key:"onUpdateFrameInner",value:function(e){this._is_started_||(this.onStart(),this._is_started_=!0),this.onUpdateFrame(e)}},{key:"onStart",value:function(){}},{key:"onUpdateFrame",value:function(e){}},{key:"onStop",value:function(){}},{key:"viewer",get:function(){return this._viewer}}]),e}(),lh=function(e){function t(){return ze(this,t),Je(this,Ye(t).call(this))}return qe(t,e),t}(uh),_h=function(){function e(t,r){var n=this;ze(this,e),this._viewer=t,this._glenv=r,this._enode_list=[],this._loaders=[],this._animation=new Qs,this._animation.addDescendantUnbinder((function(){n._unbindDescendantAnimations()}))}return je(e,[{key:"clearEntities",value:function(){this._enode_list=[]}},{key:"addEntity",value:function(e){if(e.scene!==this)throw new Error("invalid entity");this._enode_list.push(new ch(e))}},{key:"removeEntity",value:function(e){for(var t=this._enode_list,r=0;r<t.length;++r)if(t[r].entity===e){t.splice(r,1);break}}},{key:"getEntity",value:function(e){return this._enode_list[e].entity}},{key:"draw",value:function(e){this._prepare_entities();var t=[],r=[],n=!0,i=!1,o=void 0;try{for(var a,s=this._enode_list[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value.entity;this._add_primitives(e,u,t,r)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}this._draw_opaque_primitives(e,t),this._draw_translucent_primitives(e,r)}},{key:"_prepare_entities",value:function(){var e=this._viewer.globe.dem_area_updated,t=!0,r=!1,n=void 0;try{for(var i,o=this._enode_list[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value,s=a.entity.getPrimitiveProducer();if(null!==s&&s.needsElevation())if(s.checkToCreateRegions()||null===a.regions)a.regions=s.createRegions(),a.regions.length>0&&(a.regions.forEach((function(e){e.compile()})),s.onChangeElevation(a.regions));else{if(e.isEmpty())continue;var u=[];a.regions.forEach((function(t){t.intersectsWith(e)&&u.push(t)})),u.length>0&&s.onChangeElevation(u)}}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"_add_primitives",value:function(e,t,r,n){var i=t.getPrimitiveProducer();if(null!==i){var o=!0,a=!1,s=void 0;try{for(var u,l=i.getPrimitives(e)[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var _=u.value;if(_.isVisible(e))(_.isTranslucent(e)?n:r).push(_)}}catch(e){a=!0,s=e}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}}}},{key:"_draw_opaque_primitives",value:function(e,t){t.sort((function(e,t){return t.sort_z-e.sort_z}));var r=this._glenv.context;r.disable(r.BLEND),r.depthMask(!0);for(var n=0;n<t.length;++n)t[n].draw(e)}},{key:"_draw_translucent_primitives",value:function(e,t){t.sort((function(e,t){return e.sort_z-t.sort_z}));var r=this._glenv.context;r.enable(r.BLEND),r.depthMask(!1);for(var n=0;n<t.length;++n)t[n].draw(e)}},{key:"cancelLoaders",value:function(){for(var e=this._loaders.concat(),t=0;t<e.length;++t)e[t].cancel()}},{key:"addLoader",value:function(e){this._loaders.push(e)}},{key:"removeLoader",value:function(e){var t=this._loaders.indexOf(e);t>=0&&this._loaders.splice(t,1)}},{key:"getFlakePrimitiveProducers",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,o=this._enode_list[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value.entity.getFlakePrimitiveProducer();null!==a&&e.push(a)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return e}},{key:"_unbindDescendantAnimations",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._enode_list[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){n.value.entity.animation.unbindAllRecursively()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"glenv",get:function(){return this._glenv}},{key:"viewer",get:function(){return this._viewer}},{key:"animation",get:function(){return this._animation}},{key:"num_entities",get:function(){return this._enode_list.length}}]),e}(),ch=function e(t){ze(this,e),this.entity=t,this.regions=null},hh=/"/g;Re({target:"String",proto:!0,forced:function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}("link")},{link:function(e){return t="a",r="href",n=e,i=String($(this)),o="<"+t,""!==r&&(o+=" "+r+'="'+String(n).replace(hh,"&quot;")+'"'),o+">"+i+"</"+t+">";var t,r,n,i,o}}),Re({target:"Array",proto:!0,forced:Ma!==[].lastIndexOf},{lastIndexOf:Ma});var fh,dh=re.f,vh="".startsWith,yh=Math.min,ph=Dn("startsWith"),gh=!(ph||(fh=dh(String.prototype,"startsWith"),!fh||fh.writable));Re({target:"String",proto:!0,forced:!gh&&!ph},{startsWith:function(e){var t=String($(this));Rn(e);var r=_e(yh(arguments.length>1?arguments[1]:void 0,t.length)),n=String(e);return vh?vh.call(t,n,r):t.slice(r,r+n.length)===n}});var mh=function(){function e(){ze(this,e)}return je(e,null,[{key:"get",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.fetch(e.METHOD.GET,t,r,null,n)}},{key:"post",value:function(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.fetch(e.METHOD.POST,t,r,n,i)}},{key:"patch",value:function(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.fetch(e.METHOD.PATCH,t,r,n,i)}},{key:"put",value:function(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.fetch(e.METHOD.PUT,t,r,n,i)}},{key:"delete",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.fetch(e.METHOD.DELETE,t,r,null,n)}},{key:"fetch",value:function(e){function t(t,r,n,i){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=r?"?"+Object.keys(r).map((function(e){return e+"="+r[e]})).join("&"):"";return i.method=e,n&&(i.body=n),fetch(t+o,i).catch((function(e){throw new kh("Failed to fetch",t,null,e)})).then((function(e){if(!e.ok)throw new kh("Failed to fetch: "+e.statusText,t,e);return e}))}))},{key:"isJson",value:function(e){return e.startsWith("application/json")||"model/gltf+json"===e}}]),e}();mh.METHOD={GET:"GET",POST:"POST",PATCH:"PATCH",PUT:"PUT",DELETE:"DELETE"},mh.CONTENT_TYPE="Content-Type",mh.RESPONSE_STATUS={NO_CONTENT:204},mh.CREDENTIAL_MODE={OMIT:{id:"OMIT",credentials:"omit"},SAME_ORIGIN:{id:"SAME_ORIGIN",credentials:"same-origin"},INCLUDE:{id:"INCLUDE",credentials:"include"}};var kh=function(e){function t(e,r,n,i){var o;ze(this,t),o=Je(this,Ye(t).call(this,e+" "+r)),Error.captureStackTrace&&Error.captureStackTrace(Ze(o),t),o.name="FetchError",o.url=r,o.response=n,o.cause=i;var a=!1;return i&&(a="The user aborted a request."===i.message,o.stack+="\nCaused-By: "+(i.stack||i)),o.is_aborted=a,o}return qe(t,e),t}(Qe(Error)),wh=d.f,Eh=ke.f,bh=z.set,xh=Qt("match"),Ah=n.RegExp,Th=Ah.prototype,Ih=/a/g,Ph=/a/g,Lh=new Ah(Ih)!==Ih,Mh=Nu.UNSUPPORTED_Y;if(o&&Me("RegExp",!Lh||Mh||i((function(){return Ph[xh]=!1,Ah(Ih)!=Ih||Ah(Ph)==Ph||"/a/i"!=Ah(Ih,"i")})))){for(var Sh=function(e,t){var r,n=this instanceof Sh,i=Sn(e),o=void 0===t;if(!n&&i&&e.constructor===Sh&&o)return e;Lh?i&&!o&&(e=e.source):e instanceof Sh&&(o&&(t=Ou.call(e)),e=e.source),Mh&&(r=!!t&&t.indexOf("y")>-1)&&(t=t.replace(/y/g,""));var a=it(Lh?new Ah(e,t):Ah(e,t),n?this:Th,Sh);return Mh&&r&&bh(a,{sticky:r}),a},Rh=function(e){e in Sh||wh(Sh,e,{configurable:!0,get:function(){return Ah[e]},set:function(t){Ah[e]=t}})},Ch=Eh(Ah),Dh=0;Ch.length>Dh;)Rh(Ch[Dh++]);Th.constructor=Sh,Sh.prototype=Th,G(n,"RegExp",Sh)}gi("RegExp");var Oh=Qt("iterator"),Fh=!i((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Oh]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),Nh=/[^\0-\u007E]/,Vh=/[.\u3002\uFF0E\uFF61]/g,Uh="Overflow: input needs wider integers to process",Bh=Math.floor,zh=String.fromCharCode,Gh=function(e){return e+22+75*(e<26)},jh=function(e,t,r){var n=0;for(e=r?Bh(e/700):e>>1,e+=Bh(e/t);e>455;n+=36)e=Bh(e/35);return Bh(n+36*e/(e+38))},qh=function(e){var t,r,n=[],i=(e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){var o=e.charCodeAt(r++);56320==(64512&o)?t.push(((1023&i)<<10)+(1023&o)+65536):(t.push(i),r--)}else t.push(i)}return t}(e)).length,o=128,a=0,s=72;for(t=0;t<e.length;t++)(r=e[t])<128&&n.push(zh(r));var u=n.length,l=u;for(u&&n.push("-");l<i;){var _=2147483647;for(t=0;t<e.length;t++)(r=e[t])>=o&&r<_&&(_=r);var c=l+1;if(_-o>Bh((2147483647-a)/c))throw RangeError(Uh);for(a+=(_-o)*c,o=_,t=0;t<e.length;t++){if((r=e[t])<o&&++a>2147483647)throw RangeError(Uh);if(r==o){for(var h=a,f=36;;f+=36){var d=f<=s?1:f>=s+26?26:f-s;if(h<d)break;var v=h-d,y=36-d;n.push(zh(Gh(d+v%y))),h=Bh(v/y)}n.push(zh(Gh(h))),s=jh(a,c,l==u),a=0,++l}}++a,++o}return n.join("")},Yh=function(e){var t=ai(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return c(t.call(e))},Hh=oe("fetch"),Xh=oe("Headers"),Wh=Qt("iterator"),Qh=z.set,Zh=z.getterFor("URLSearchParams"),Jh=z.getterFor("URLSearchParamsIterator"),Kh=/\+/g,$h=Array(4),ef=function(e){return $h[e-1]||($h[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},tf=function(e){try{return decodeURIComponent(e)}catch(t){return e}},rf=function(e){var t=e.replace(Kh," "),r=4;try{return decodeURIComponent(t)}catch(e){for(;r;)t=t.replace(ef(r--),tf);return t}},nf=/[!'()~]|%20/g,of={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},af=function(e){return of[e]},sf=function(e){return encodeURIComponent(e).replace(nf,af)},uf=function(e,t){if(t)for(var r,n,i=t.split("&"),o=0;o<i.length;)(r=i[o++]).length&&(n=r.split("="),e.push({key:rf(n.shift()),value:rf(n.join("="))}))},lf=function(e){this.entries.length=0,uf(this.entries,e)},_f=function(e,t){if(e<t)throw TypeError("Not enough arguments")},cf=vn((function(e,t){Qh(this,{type:"URLSearchParamsIterator",iterator:Yh(Zh(e).entries),kind:t})}),"Iterator",(function(){var e=Jh(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r})),hf=function(){li(this,hf,"URLSearchParams");var e,t,r,n,i,o,s,u,l,_=arguments.length>0?arguments[0]:void 0,h=this,f=[];if(Qh(h,{type:"URLSearchParams",entries:f,updateURL:function(){},updateSearchParams:lf}),void 0!==_)if(a(_))if("function"==typeof(e=ai(_)))for(r=(t=e.call(_)).next;!(n=r.call(t)).done;){if((s=(o=(i=Yh(c(n.value))).next).call(i)).done||(u=o.call(i)).done||!o.call(i).done)throw TypeError("Expected sequence with length 2");f.push({key:s.value+"",value:u.value+""})}else for(l in _)g(_,l)&&f.push({key:l,value:_[l]+""});else uf(f,"string"==typeof _?"?"===_.charAt(0)?_.slice(1):_:_+"")},ff=hf.prototype;yi(ff,{append:function(e,t){_f(arguments.length,2);var r=Zh(this);r.entries.push({key:e+"",value:t+""}),r.updateURL()},delete:function(e){_f(arguments.length,1);for(var t=Zh(this),r=t.entries,n=e+"",i=0;i<r.length;)r[i].key===n?r.splice(i,1):i++;t.updateURL()},get:function(e){_f(arguments.length,1);for(var t=Zh(this).entries,r=e+"",n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){_f(arguments.length,1);for(var t=Zh(this).entries,r=e+"",n=[],i=0;i<t.length;i++)t[i].key===r&&n.push(t[i].value);return n},has:function(e){_f(arguments.length,1);for(var t=Zh(this).entries,r=e+"",n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){_f(arguments.length,1);for(var r,n=Zh(this),i=n.entries,o=!1,a=e+"",s=t+"",u=0;u<i.length;u++)(r=i[u]).key===a&&(o?i.splice(u--,1):(o=!0,r.value=s));o||i.push({key:a,value:s}),n.updateURL()},sort:function(){var e,t,r,n=Zh(this),i=n.entries,o=i.slice();for(i.length=0,r=0;r<o.length;r++){for(e=o[r],t=0;t<r;t++)if(i[t].key>e.key){i.splice(t,0,e);break}t===r&&i.push(e)}n.updateURL()},forEach:function(e){for(var t,r=Zh(this).entries,n=nr(e,arguments.length>1?arguments[1]:void 0,3),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new cf(this,"keys")},values:function(){return new cf(this,"values")},entries:function(){return new cf(this,"entries")}},{enumerable:!0}),G(ff,Wh,ff.entries),G(ff,"toString",(function(){for(var e,t=Zh(this).entries,r=[],n=0;n<t.length;)e=t[n++],r.push(sf(e.key)+"="+sf(e.value));return r.join("&")}),{enumerable:!0}),tr(hf,"URLSearchParams"),Re({global:!0,forced:!Fh},{URLSearchParams:hf}),Fh||"function"!=typeof Hh||"function"!=typeof Xh||Re({global:!0,enumerable:!0,forced:!0},{fetch:function(e){var t,r,n,i=[e];return arguments.length>1&&(t=arguments[1],a(t)&&(r=t.body,"URLSearchParams"===Pn(r)&&((n=t.headers?new Xh(t.headers):new Xh).has("content-type")||n.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),t=ht(t,{body:v(0,String(r)),headers:v(0,n)}))),i.push(t)),Hh.apply(this,i)}});var df,vf={URLSearchParams:hf,getState:Zh},yf=Fn.codeAt,pf=n.URL,gf=vf.URLSearchParams,mf=vf.getState,kf=z.set,wf=z.getterFor("URL"),Ef=Math.floor,bf=Math.pow,xf=/[A-Za-z]/,Af=/[\d+\-.A-Za-z]/,Tf=/\d/,If=/^(0x|0X)/,Pf=/^[0-7]+$/,Lf=/^\d+$/,Mf=/^[\dA-Fa-f]+$/,Sf=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,Rf=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,Cf=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,Df=/[\u0009\u000A\u000D]/g,Of=function(e,t){var r,n,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return"Invalid host";if(!(r=Nf(t.slice(1,-1))))return"Invalid host";e.host=r}else if(Yf(e)){if(t=function(e){var t,r,n=[],i=e.toLowerCase().replace(Vh,".").split(".");for(t=0;t<i.length;t++)r=i[t],n.push(Nh.test(r)?"xn--"+qh(r):r);return n.join(".")}(t),Sf.test(t))return"Invalid host";if(null===(r=Ff(t)))return"Invalid host";e.host=r}else{if(Rf.test(t))return"Invalid host";for(r="",n=bs(t),i=0;i<n.length;i++)r+=jf(n[i],Uf);e.host=r}},Ff=function(e){var t,r,n,i,o,a,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=u[n]))return e;if(o=10,i.length>1&&"0"==i.charAt(0)&&(o=If.test(i)?16:8,i=i.slice(8==o?1:2)),""===i)a=0;else{if(!(10==o?Lf:8==o?Pf:Mf).test(i))return e;a=parseInt(i,o)}r.push(a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=bf(256,5-t))return null}else if(a>255)return null;for(s=r.pop(),n=0;n<r.length;n++)s+=r[n]*bf(256,3-n);return s},Nf=function(e){var t,r,n,i,o,a,s,u=[0,0,0,0,0,0,0,0],l=0,_=null,c=0,h=function(){return e.charAt(c)};if(":"==h()){if(":"!=e.charAt(1))return;c+=2,_=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=r=0;r<4&&Mf.test(h());)t=16*t+parseInt(h(),16),c++,r++;if("."==h()){if(0==r)return;if(c-=r,l>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;c++}if(!Tf.test(h()))return;for(;Tf.test(h());){if(o=parseInt(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;c++}u[l]=256*u[l]+i,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==h()){if(c++,!h())return}else if(h())return;u[l++]=t}else{if(null!==_)return;c++,_=++l}}if(null!==_)for(a=l-_,l=7;0!=l&&a>0;)s=u[l],u[l--]=u[_+a-1],u[_+--a]=s;else if(8!=l)return;return u},Vf=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)t.unshift(e%256),e=Ef(e/256);return t.join(".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=e[r].toString(16),r<7&&(t+=":")));return"["+t+"]"}return e},Uf={},Bf=rh({},Uf,{" ":1,'"':1,"<":1,">":1,"`":1}),zf=rh({},Bf,{"#":1,"?":1,"{":1,"}":1}),Gf=rh({},zf,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),jf=function(e,t){var r=yf(e,0);return r>32&&r<127&&!g(t,e)?e:encodeURIComponent(e)},qf={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Yf=function(e){return g(qf,e.scheme)},Hf=function(e){return""!=e.username||""!=e.password},Xf=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},Wf=function(e,t){var r;return 2==e.length&&xf.test(e.charAt(0))&&(":"==(r=e.charAt(1))||!t&&"|"==r)},Qf=function(e){var t;return e.length>1&&Wf(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},Zf=function(e){var t=e.path,r=t.length;!r||"file"==e.scheme&&1==r&&Wf(t[0],!0)||t.pop()},Jf=function(e){return"."===e||"%2e"===e.toLowerCase()},Kf={},$f={},ed={},td={},rd={},nd={},id={},od={},ad={},sd={},ud={},ld={},_d={},cd={},hd={},fd={},dd={},vd={},yd={},pd={},gd={},md=function(e,t,r,n){var i,o,a,s,u,l=r||Kf,_=0,c="",h=!1,f=!1,d=!1;for(r||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(Cf,"")),t=t.replace(Df,""),i=bs(t);_<=i.length;){switch(o=i[_],l){case Kf:if(!o||!xf.test(o)){if(r)return"Invalid scheme";l=ed;continue}c+=o.toLowerCase(),l=$f;break;case $f:if(o&&(Af.test(o)||"+"==o||"-"==o||"."==o))c+=o.toLowerCase();else{if(":"!=o){if(r)return"Invalid scheme";c="",l=ed,_=0;continue}if(r&&(Yf(e)!=g(qf,c)||"file"==c&&(Hf(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=c,r)return void(Yf(e)&&qf[e.scheme]==e.port&&(e.port=null));c="","file"==e.scheme?l=cd:Yf(e)&&n&&n.scheme==e.scheme?l=td:Yf(e)?l=od:"/"==i[_+1]?(l=rd,_++):(e.cannotBeABaseURL=!0,e.path.push(""),l=yd)}break;case ed:if(!n||n.cannotBeABaseURL&&"#"!=o)return"Invalid scheme";if(n.cannotBeABaseURL&&"#"==o){e.scheme=n.scheme,e.path=n.path.slice(),e.query=n.query,e.fragment="",e.cannotBeABaseURL=!0,l=gd;break}l="file"==n.scheme?cd:nd;continue;case td:if("/"!=o||"/"!=i[_+1]){l=nd;continue}l=ad,_++;break;case rd:if("/"==o){l=sd;break}l=vd;continue;case nd:if(e.scheme=n.scheme,o==df)e.username=n.username,e.password=n.password,e.host=n.host,e.port=n.port,e.path=n.path.slice(),e.query=n.query;else if("/"==o||"\\"==o&&Yf(e))l=id;else if("?"==o)e.username=n.username,e.password=n.password,e.host=n.host,e.port=n.port,e.path=n.path.slice(),e.query="",l=pd;else{if("#"!=o){e.username=n.username,e.password=n.password,e.host=n.host,e.port=n.port,e.path=n.path.slice(),e.path.pop(),l=vd;continue}e.username=n.username,e.password=n.password,e.host=n.host,e.port=n.port,e.path=n.path.slice(),e.query=n.query,e.fragment="",l=gd}break;case id:if(!Yf(e)||"/"!=o&&"\\"!=o){if("/"!=o){e.username=n.username,e.password=n.password,e.host=n.host,e.port=n.port,l=vd;continue}l=sd}else l=ad;break;case od:if(l=ad,"/"!=o||"/"!=c.charAt(_+1))continue;_++;break;case ad:if("/"!=o&&"\\"!=o){l=sd;continue}break;case sd:if("@"==o){h&&(c="%40"+c),h=!0,a=bs(c);for(var v=0;v<a.length;v++){var y=a[v];if(":"!=y||d){var p=jf(y,Gf);d?e.password+=p:e.username+=p}else d=!0}c=""}else if(o==df||"/"==o||"?"==o||"#"==o||"\\"==o&&Yf(e)){if(h&&""==c)return"Invalid authority";_-=bs(c).length+1,c="",l=ud}else c+=o;break;case ud:case ld:if(r&&"file"==e.scheme){l=fd;continue}if(":"!=o||f){if(o==df||"/"==o||"?"==o||"#"==o||"\\"==o&&Yf(e)){if(Yf(e)&&""==c)return"Invalid host";if(r&&""==c&&(Hf(e)||null!==e.port))return;if(s=Of(e,c))return s;if(c="",l=dd,r)return;continue}"["==o?f=!0:"]"==o&&(f=!1),c+=o}else{if(""==c)return"Invalid host";if(s=Of(e,c))return s;if(c="",l=_d,r==ld)return}break;case _d:if(!Tf.test(o)){if(o==df||"/"==o||"?"==o||"#"==o||"\\"==o&&Yf(e)||r){if(""!=c){var m=parseInt(c,10);if(m>65535)return"Invalid port";e.port=Yf(e)&&m===qf[e.scheme]?null:m,c=""}if(r)return;l=dd;continue}return"Invalid port"}c+=o;break;case cd:if(e.scheme="file","/"==o||"\\"==o)l=hd;else{if(!n||"file"!=n.scheme){l=vd;continue}if(o==df)e.host=n.host,e.path=n.path.slice(),e.query=n.query;else if("?"==o)e.host=n.host,e.path=n.path.slice(),e.query="",l=pd;else{if("#"!=o){Qf(i.slice(_).join(""))||(e.host=n.host,e.path=n.path.slice(),Zf(e)),l=vd;continue}e.host=n.host,e.path=n.path.slice(),e.query=n.query,e.fragment="",l=gd}}break;case hd:if("/"==o||"\\"==o){l=fd;break}n&&"file"==n.scheme&&!Qf(i.slice(_).join(""))&&(Wf(n.path[0],!0)?e.path.push(n.path[0]):e.host=n.host),l=vd;continue;case fd:if(o==df||"/"==o||"\\"==o||"?"==o||"#"==o){if(!r&&Wf(c))l=vd;else if(""==c){if(e.host="",r)return;l=dd}else{if(s=Of(e,c))return s;if("localhost"==e.host&&(e.host=""),r)return;c="",l=dd}continue}c+=o;break;case dd:if(Yf(e)){if(l=vd,"/"!=o&&"\\"!=o)continue}else if(r||"?"!=o)if(r||"#"!=o){if(o!=df&&(l=vd,"/"!=o))continue}else e.fragment="",l=gd;else e.query="",l=pd;break;case vd:if(o==df||"/"==o||"\\"==o&&Yf(e)||!r&&("?"==o||"#"==o)){if(".."===(u=(u=c).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(Zf(e),"/"==o||"\\"==o&&Yf(e)||e.path.push("")):Jf(c)?"/"==o||"\\"==o&&Yf(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&Wf(c)&&(e.host&&(e.host=""),c=c.charAt(0)+":"),e.path.push(c)),c="","file"==e.scheme&&(o==df||"?"==o||"#"==o))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==o?(e.query="",l=pd):"#"==o&&(e.fragment="",l=gd)}else c+=jf(o,zf);break;case yd:"?"==o?(e.query="",l=pd):"#"==o?(e.fragment="",l=gd):o!=df&&(e.path[0]+=jf(o,Uf));break;case pd:r||"#"!=o?o!=df&&("'"==o&&Yf(e)?e.query+="%27":e.query+="#"==o?"%23":jf(o,Uf)):(e.fragment="",l=gd);break;case gd:o!=df&&(e.fragment+=jf(o,Bf))}_++}},kd=function(e){var t,r,n=li(this,kd,"URL"),i=arguments.length>1?arguments[1]:void 0,a=String(e),s=kf(n,{type:"URL"});if(void 0!==i)if(i instanceof kd)t=wf(i);else if(r=md(t={},String(i)))throw TypeError(r);if(r=md(s,a,null,t))throw TypeError(r);var u=s.searchParams=new gf,l=mf(u);l.updateSearchParams(s.query),l.updateURL=function(){s.query=String(u)||null},o||(n.href=Ed.call(n),n.origin=bd.call(n),n.protocol=xd.call(n),n.username=Ad.call(n),n.password=Td.call(n),n.host=Id.call(n),n.hostname=Pd.call(n),n.port=Ld.call(n),n.pathname=Md.call(n),n.search=Sd.call(n),n.searchParams=Rd.call(n),n.hash=Cd.call(n))},wd=kd.prototype,Ed=function(){var e=wf(this),t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,u=e.fragment,l=t+":";return null!==i?(l+="//",Hf(e)&&(l+=r+(n?":"+n:"")+"@"),l+=Vf(i),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+a.join("/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},bd=function(){var e=wf(this),t=e.scheme,r=e.port;if("blob"==t)try{return new URL(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&Yf(e)?t+"://"+Vf(e.host)+(null!==r?":"+r:""):"null"},xd=function(){return wf(this).scheme+":"},Ad=function(){return wf(this).username},Td=function(){return wf(this).password},Id=function(){var e=wf(this),t=e.host,r=e.port;return null===t?"":null===r?Vf(t):Vf(t)+":"+r},Pd=function(){var e=wf(this).host;return null===e?"":Vf(e)},Ld=function(){var e=wf(this).port;return null===e?"":String(e)},Md=function(){var e=wf(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},Sd=function(){var e=wf(this).query;return e?"?"+e:""},Rd=function(){return wf(this).searchParams},Cd=function(){var e=wf(this).fragment;return e?"#"+e:""},Dd=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(o&&at(wd,{href:Dd(Ed,(function(e){var t=wf(this),r=String(e),n=md(t,r);if(n)throw TypeError(n);mf(t.searchParams).updateSearchParams(t.query)})),origin:Dd(bd),protocol:Dd(xd,(function(e){var t=wf(this);md(t,String(e)+":",Kf)})),username:Dd(Ad,(function(e){var t=wf(this),r=bs(String(e));if(!Xf(t)){t.username="";for(var n=0;n<r.length;n++)t.username+=jf(r[n],Gf)}})),password:Dd(Td,(function(e){var t=wf(this),r=bs(String(e));if(!Xf(t)){t.password="";for(var n=0;n<r.length;n++)t.password+=jf(r[n],Gf)}})),host:Dd(Id,(function(e){var t=wf(this);t.cannotBeABaseURL||md(t,String(e),ud)})),hostname:Dd(Pd,(function(e){var t=wf(this);t.cannotBeABaseURL||md(t,String(e),ld)})),port:Dd(Ld,(function(e){var t=wf(this);Xf(t)||(""==(e=String(e))?t.port=null:md(t,e,_d))})),pathname:Dd(Md,(function(e){var t=wf(this);t.cannotBeABaseURL||(t.path=[],md(t,e+"",dd))})),search:Dd(Sd,(function(e){var t=wf(this);""==(e=String(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",md(t,e,pd)),mf(t.searchParams).updateSearchParams(t.query)})),searchParams:Dd(Rd),hash:Dd(Cd,(function(e){var t=wf(this);""!=(e=String(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",md(t,e,gd)):t.fragment=null}))}),G(wd,"toJSON",(function(){return Ed.call(this)}),{enumerable:!0}),G(wd,"toString",(function(){return Ed.call(this)}),{enumerable:!0}),pf){var Od=pf.createObjectURL,Fd=pf.revokeObjectURL;Od&&G(kd,"createObjectURL",(function(e){return Od.apply(pf,arguments)})),Fd&&G(kd,"revokeObjectURL",(function(e){return Fd.apply(pf,arguments)}))}tr(kd,"URL"),Re({global:!0,forced:!Fh,sham:!o},{URL:kd});var Nd=new RegExp("^data:"),Vd=new RegExp("^https?://"),Ud=function(){function e(){ze(this,e)}return je(e,null,[{key:"createCanvasContext",value:function(e,t){var r=document.createElement("canvas");return r.width=e,r.height=t,r.getContext("2d")}},{key:"loadImage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var i=new Image;i.onload=function(e){return r(e.target)},i.onerror=function(e){return n(new Error("Failed to load image"))},void 0!==t.crossOrigin&&(i.crossOrigin=t.crossOrigin),e instanceof Blob?i.src=URL.createObjectURL(e):i.src=e}))}},{key:"waitForLoad",value:function(e){return e.src?e.complete?Promise.resolve(e):new Promise((function(t,r){var n=e.onload,i=e.onerror;e.onload=function(e){n&&n(e),t(e.target)},e.onerror=function(e){i&&i(e),r(new Error("Failed to load image"))}})):Promise.reject(new Error("src was not set"))}},{key:"resolveUrl",value:function(e,t){return Nd.test(t)||Vd.test(t)?t:e+t}}]),e}();Ud.SYSTEM_FONT_FAMILY="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'";var Bd=function(){function e(){ze(this,e)}return je(e,[{key:"load",value:function(){return Promise.reject(new Error("Not Implemented"))}},{key:"cancel",value:function(){}},{key:"loadSubResourceSupported",value:function(){return!1}},{key:"loadSubResource",value:function(e){return Promise.reject(new Error("Not Supported"))}},{key:"resolveResourceSupported",value:function(){return!1}},{key:"resolveResource",value:function(e){return Promise.reject(new Error("Not Supported"))}}],[{key:"ResourceType",get:function(){return zd}}]),e}(),zd={JSON:{id:"JSON"},BINARY:{id:"BINARY"},IMAGE:{id:"IMAGE"}},Gd=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ze(this,t),(r=Je(this,Ye(t).call(this)))._url=e;var i=e.lastIndexOf("/");if(-1===i)throw new Error("invalid url");return r._base_url=r._url.substr(0,i+1),r._type=n.type||"json",r._transform=n.transform||jd,r._abort_ctrl=new AbortController,r}return qe(t,e),je(t,[{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this._transform(this._url,e.type),r=this._make_fetch_params(t)||{};return e.signal&&(r.signal=e.signal),mh.get(t.url,null,r).then((function(n){if(!n.ok)throw new Error(n.statusText);return e.type===zd.JSON?n.json():e.type===zd.IMAGE?Ud.loadImage(t.url,r):e.type===zd.BINARY?n.arrayBuffer():n}))}},{key:"cancel",value:function(){this._abort_ctrl.abort()}},{key:"loadSubResourceSupported",value:function(){return!0}},{key:"loadSubResource",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Ud.resolveUrl(this._base_url,e),i=this._transform(n,r.type),o=i.init||{};return r.signal&&(o.signal=r.signal),r.type===t.ResourceType.BINARY?mh.get(i.url,null,o).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.arrayBuffer()})):r.type===t.ResourceType.IMAGE?Ud.loadImage(i.url,o):r.type===t.ResourceType.JSON?mh.get(i.url,null,o).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.json()})):mh.get(i.url,null,this._make_fetch_params(i)).then((function(e){if(!e.ok)throw new Error(e.statusText);return e}))}},{key:"resolveResourceSupported",value:function(){return!0}},{key:"resolveResource",value:function(e){return new t(Ud.resolveUrl(this._base_url,e),{transform:this._transform})}},{key:"_make_fetch_params",value:function(e){var t={signal:this._abort_ctrl.signal,credentials:(e.credentials||mh.CREDENTIAL_MODE.OMIT).credentials};return e.headers&&(t.headers=e.headers),t}},{key:"makeBinaryFetchParams",value:function(e,t){var r=this._transform(e,t),n={credentials:(r.credentials||Zc.OMIT).credentials};return r.headers&&(n.headers=r.headers),{url:r.url,init:n}}},{key:"_makeImageLoadParams",value:function(e,t){var r=this._transform(e,t),n={url:r.url};return r.credentials===Zc.SAME_ORIGIN?n.crossOrigin="anonymous":r.credentials===Zc.INCLUDE&&(n.crossOrigin="use-credentials"),n}}]),t}(Bd);function jd(e,t){return{url:e}}var qd=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(ze(this,e),this._scene=t,!(r instanceof Bd))throw new Error("Unsupported Resource Type: "+r);this._resource=r,this._status=e.Status.NOT_LOADED,this._onLoad=n.onLoad||Yd}return je(e,[{key:"_setStatus",value:function(e){this._status=e}},{key:"load",value:function(){var t=this;return this.status!==e.Status.NOT_LOADED?Promise.reject(new Error("Illegal Status: "+this.status)):Promise.resolve().then((function(){return t._setStatus(e.Status.LOADING),t.scene.addLoader(t),t._load()})).catch((function(r){throw console.log(r),t._scene.removeLoader(t),t._onLoad(t,!1),t._status!==e.Status.CANCELED&&t._setStatus(e.Status.ABORTED),r})).then((function(r){if(t._scene.removeLoader(t),t._status===e.Status.CANCELED)throw t._onLoad(t,!1),new Error("canceled");return t._setStatus(e.Status.LOADED),t._onLoad(t,!0),r}))}},{key:"_load",value:function(){throw new Error("_load() is not implemented in "+this.constructor.name)}},{key:"cancel",value:function(){this._status!==e.Status.LOADING&&this._status!==e.Status.LOADED||(this._setStatus(e.Status.CANCELED),this._resource.cancel(),this._cancel())}},{key:"_cancel",value:function(){}},{key:"_check_cancel",value:function(){if(this.status===e.Status.CANCELED)throw new Error("canceled")}},{key:"scene",get:function(){return this._scene}},{key:"resource",get:function(){return this._resource}},{key:"status",get:function(){return this._status}}]),e}();function Yd(e,t){}qd.Status={NOT_LOADED:"Not Loaded",LOADING:"Loading",LOADED:"Loaded",CANCELED:"Canceled",ERROR:"ERROR"};var Hd=function(){function e(t,r){ze(this,e),this._name=t.name||null,this._extensions=r.extractUsedExtensions(t.extensions||{}),this._extras=t.extras||{}}return je(e,[{key:"getName",value:function(){return this._name}},{key:"getExtensions",value:function(e){var t=this._extensions[e];return void 0!==t?t:null}},{key:"getExtras",value:function(e){var t=this._extras[e];return void 0!==t?t:null}}]),e}(),Xd=function(){function e(t,r,n){ze(this,e),this._commonData=new Hd(t.gjson,t),this._scenes=r,this._default_scene_index=n}return je(e,[{key:"commonData",get:function(){return this._commonData}},{key:"scenes",get:function(){return this._scenes}},{key:"default_scene_index",get:function(){return this._default_scene_index}}]),e}(),Wd=function(){function e(t,r,n){ze(this,e);var i=n||{};this._glenv=t,this._handle=this._createTexture(r,i)}return je(e,[{key:"dispose",value:function(){this._glenv.context.deleteTexture(this._handle),this._handle=null}},{key:"_createTexture",value:function(t,r){var n=this._glenv.context,i=n.TEXTURE_2D,o=n.createTexture(),a=e._getParameters(n,r);n.bindTexture(i,o);var s=void 0===r.flip_y||r.flip_y;return n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,s),r.usage===e.Usage.COLOR?n.texImage2D(i,0,a.format,1,1,0,a.format,a.type,e._getColorArray(r)):n.texImage2D(i,0,a.format,a.format,a.type,t),s&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),e._generateMipmapQ(n,a)&&n.generateMipmap(i),n.texParameteri(i,n.TEXTURE_MAG_FILTER,a.mag_filter),n.texParameteri(i,n.TEXTURE_MIN_FILTER,a.min_filter),n.texParameteri(i,n.TEXTURE_WRAP_S,a.wrap_s),n.texParameteri(i,n.TEXTURE_WRAP_T,a.wrap_t),n.bindTexture(i,null),o}},{key:"handle",get:function(){return this._handle}}],[{key:"_getParameters",value:function(t,r){var n={format:t.RGBA,type:t.UNSIGNED_BYTE,mag_filter:t.LINEAR,min_filter:t.LINEAR_MIPMAP_LINEAR,wrap_s:t.REPEAT,wrap_t:t.REPEAT};return r.usage===e.Usage.SIMPLETEXT?(n.format=t.ALPHA,n.min_filter=t.LINEAR,n.wrap_s=t.CLAMP_TO_EDGE,n.wrap_t=t.CLAMP_TO_EDGE):r.usage===e.Usage.TEXT?(n.min_filter=t.LINEAR,n.wrap_s=t.CLAMP_TO_EDGE,n.wrap_t=t.CLAMP_TO_EDGE):r.usage===e.Usage.COLOR?(n.mag_filter=t.NEAREST,n.min_filter=t.NEAREST):r.usage===e.Usage.ICON&&(n.min_filter=t.LINEAR,n.wrap_s=t.CLAMP_TO_EDGE,n.wrap_t=t.CLAMP_TO_EDGE),void 0!==r.mag_filter&&(n.mag_filter=r.mag_filter),void 0!==r.min_filter&&(n.min_filter=r.min_filter),void 0!==r.wrap_s&&(n.wrap_s=r.wrap_s),void 0!==r.wrap_t&&(n.wrap_t=r.wrap_t),n}},{key:"_getColorArray",value:function(e){var t=(e.color||[1,1,1,1]).map((function(e){return Math.round(255*e)}));return new Uint8Array(t)}},{key:"_generateMipmapQ",value:function(e,t){var r=t.min_filter;return r==e.NEAREST_MIPMAP_NEAREST||r==e.LINEAR_MIPMAP_NEAREST||r==e.NEAREST_MIPMAP_LINEAR||r==e.LINEAR_MIPMAP_LINEAR}}]),e}();Wd.Usage={GENERAL:{id:"GENERAL"},COLOR:{id:"COLOR"},TEXT:{id:"TEXT"},SIMPLETEXT:{id:"SIMPLETEXT"},ICON:{id:"ICON"}};var Qd=function(e){function t(e,r,n){return ze(this,t),Je(this,Ye(t).call(this,e,r,n))}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,t){return!1}},{key:"setParameters",value:function(e,t){}},{key:"setObjToClip",value:function(e,r){var n=r.transform,i=t._obj_to_clip;cs.mul_GA(e._gocs_to_clip,n,i),this.setMatrix("u_obj_to_clip",i)}},{key:"setObjToView",value:function(e,r){var n=r.transform,i=t._obj_to_view;cs.mul_AA(e._gocs_to_view,n,i),this.setMatrix("u_obj_to_view",i)}}]),t}(zl);Qd._obj_to_clip=cs.createMatrixf(),Qd._obj_to_view=cs.createMatrixf();var Zd="attribute vec4 a_position;    // 位置 (モデル座標系)\nattribute vec3 a_normal;      // 法線 (モデル座標系)\nattribute vec2 a_texcoord;    // テクスチャ座標\n\nuniform mat4  u_obj_to_clip;  // モデル座標系からクリップ座標系への変換\nuniform mat4  u_obj_to_view;  // モデル座標系から視点座標系への変換\n\nvarying vec3  v_normal;       // 法線 (視点座標系)\nvarying vec2  v_texcoord;     // テクスチャ座標\n\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n\n#ifndef UNLIT\n    v_normal = normalize( vec3( u_obj_to_view * vec4( a_normal, 0.0 ) ) );  // 法線 (視点座標系)\n#endif\n\n    v_texcoord = a_texcoord;\n}\n",Jd="precision highp float;\n\nvarying vec3  v_normal;    // 法線 (視点座標系)\nvarying vec2  v_texcoord;  // テクスチャ座標\n\nuniform vec3      u_light_dir;   // ライト逆方向 (視点座標系) と強さ\nuniform vec4      u_base_color;  // 基本色係数\nuniform sampler2D u_base_image;  // 基本色画像\n\n\nvoid\nmain()\n{\n#ifndef UNLIT\n    vec3 normal = normalize( v_normal );  // 法線 (視点座標系)\n\n    vec3 dlit = vec3( dot( normal, u_light_dir ) );  // 拡散光の強さ\n#else\n    vec3 dlit = vec3( 1.0 );\n#endif\n\n    gl_FragColor = u_base_color * texture2D( u_base_image, v_texcoord ) * vec4( dlit, 1.0 );\n}\n",Kd=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ze(this,t);var i=t._getPreamble(n);return(r=Je(this,Ye(t).call(this,e,i+Zd,i+Jd)))._white_texture=new Wd(e,null,{usage:Wd.Usage.COLOR,color:[1,1,1,1]}),r.bindProgram(),r.setInteger("u_base_image",t.TEXUNIT_BASE_IMAGE),r}return qe(t,e),je(t,[{key:"setParameters",value:function(e,r){var n=r.properties.pbrMetallicRoughness;this.setObjToClip(e,r),this.setObjToView(e,r),this.setVector4("u_base_color",n.baseColorFactor),this.setVector3("u_light_dir",[0,0,1]);var i=this._selectTexture(n.baseColorTexture,this._white_texture);this.bindTexture2D(t.TEXUNIT_BASE_IMAGE,i.handle)}},{key:"_selectTexture",value:function(e,t){return null!==e?e.texture:t}}],[{key:"_getPreamble",value:function(e){var t=[];return void 0!==e.is_unlit&&e.is_unlit&&t.push("#define UNLIT"),t.join("\n")+"\n\n"}}]),t}(Qd);Kd.TEXUNIT_BASE_IMAGE=0;var $d=function(){function e(t,r){ze(this,e);var n="number"==typeof r?t.gjson.samplers[r]:{};this._magFilter=n.magFilter,this._minFilter=n.minFilter,this._wrapS=void 0!==n.wrapS?n.wrapS:e.WRAP_DEFAULT,this._wrapT=void 0!==n.wrapT?n.wrapT:e.WRAP_DEFAULT}return je(e,[{key:"magFilter",get:function(){return this._magFilter}},{key:"minFilter",get:function(){return this._minFilter}},{key:"wrapS",get:function(){return this._wrapS}},{key:"wrapT",get:function(){return this._wrapT}}]),e}();$d.WRAP_DEFAULT=10497;var ev=function(){function e(t,r){ze(this,e);var n=t.gjson.textures[r];this._sampler=new $d(t,n.sampler),this._source=t.findImage(n.source)}return je(e,[{key:"source",get:function(){return this._source}},{key:"sampler",get:function(){return this._sampler}}]),e}(),tv=function(){function e(t,r){ze(this,e),this._texture=new ev(r,t.index),this._texCoord=void 0!==t.texCoord?t.texCoord:0}return je(e,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture=e}},{key:"texCoord",get:function(){return this._texCoord}}]),e}(),rv=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._scale=void 0!==e.scale?e.scale:1,n}return qe(t,e),je(t,[{key:"texCoord",get:function(){return this._scale}}]),t}(tv),nv=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._strength=void 0!==e.strength?e.strength:1,n}return qe(t,e),je(t,[{key:"strength",get:function(){return this._strength}}]),t}(tv),iv=function(){function e(t,r){ze(this,e),this._entries=[],this._name_map={},this._default=null,this._offset_transform=cs.setIdentity(cs.createMatrix());var n={},i=!0,o=!1,a=void 0;try{for(var s,u=r.scenes[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value,_=new ov(t,l,n);this._entries.push(_),null!==l.name&&(this._name_map[l.name]=_)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}if(r.default_scene_index>=0){if(!(r.default_scene_index<this._entries.length))throw new Error("default_scene_index is out of range");this._default=this._entries[r.default_scene_index]}else this._entries.length>=1&&(this._default=this._entries[0])}return je(e,[{key:"setOffsetTransform",value:function(e){cs.copyMatrix(e,this._offset_transform)}},{key:"createPrimitives",value:function(e){var t=this._getEntry(e);if(null===t)return null;var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t.primitives[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value.fastClone();cs.mul_AA(this._offset_transform,u.transform,u.transform),u.properties=av.fastCloneProperties(u.properties),r.push(u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}},{key:"_getEntry",value:function(e){if("number"==typeof e){if(0<=e&&e<this._entries.length)return this._entries[e]}else if("string"==typeof e){if(this._name_map.hasOwnProperty(e))return this._name_map[e]}else if(this._entries.length>0)return this._entries[0];return null}}],[{key:"getSupportedExtensions_glTF",value:function(){return["KHR_materials_unlit"]}}]),e}(),ov=function(){function e(t,r,n){ze(this,e);var i=new av(t,r,n);this._primitives=i.primitives}return je(e,[{key:"primitives",get:function(){return this._primitives}}]),e}(),av=function(){function e(t,r,n){ze(this,e),n.buffer_map||(n.buffer_map=new Map,n.texture_map=new Map),this._mr_scene=t,this._glenv=t.glenv,this._primitives=[],this._buffer_map=n.buffer_map,this._texture_map=n.texture_map;var i=cs.setIdentity(cs.createMatrix()),o=!0,a=!1,s=void 0;try{for(var u,l=r.root_nodes[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var _=u.value;this._addNode(_,i)}}catch(e){a=!0,s=e}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}}return je(e,[{key:"_addNode",value:function(t,r){var n=e._getNodeToScene(t,r);if(null!==t.mesh){var i=!0,o=!1,a=void 0;try{for(var s,u=t.mesh.primitives[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;this._primitives.push(this._createPrimitive(l,n))}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}}var _=!0,c=!1,h=void 0;try{for(var f,d=t.children[Symbol.iterator]();!(_=(f=d.next()).done);_=!0){var v=f.value;this._addNode(v,n)}}catch(e){c=!0,h=e}finally{try{_||null==d.return||d.return()}finally{if(c)throw h}}}},{key:"_createPrimitive",value:function(e,t){var r=this._createMesh(e),n=this._createMaterial(e),i=new _l(this._glenv,r,n,cs.createMatrix(t));return i.pivot=this._createMeshPivot(e),i.bbox=this._createBoundingBox(e),i.properties=this._createProperties(e),i}},{key:"_createMesh",value:function(t){var r=new ml.Initializer(e._convertPrimitiveMode(t),e._calcNumVertices(t)),n=t.attributes;for(var i in n)this._addAttribToInit(r,i,n[i]);var o=t.indices;return null!==o&&this._addIndexToInit(r,o),new ml(this._glenv,r)}},{key:"_addAttribToInit",value:function(t,r,n){var i=this._findMeshBuffer(n.bufferView.buffer,pl.Target.ATTRIBUTE),o=e._NumComponents[n.type],a=e._ComponentType[n.componentType],s={normalized:n.normalized,byte_stride:n.bufferView.byteStride,byte_offset:n.bufferView.byteOffset+n.byteOffset},u=e._VertexAttribId[r]||r;t.addAttribute(u,i,o,a,s)}},{key:"_addIndexToInit",value:function(t,r){var n=this._findMeshBuffer(r.bufferView.buffer,pl.Target.INDEX),i=r.count,o=e._ComponentType[r.componentType],a={byte_offset:r.bufferView.byteOffset+r.byteOffset};t.addIndex(n,i,o,a)}},{key:"_findMeshBuffer",value:function(e,t){var r=this._buffer_map.get(e);return void 0===r&&(r=new pl(this._glenv,e.binary,{target:t}),this._buffer_map.set(e,r)),r}},{key:"_createMaterial",value:function(e){var t="basic",r={};e.material&&e.material.commonData.getExtensions("KHR_materials_unlit")&&(t="unlit",r.is_unlit=!0);var n=this._mr_scene,i="_ModelEntity_model_material_"+t;return n[i]||(n[i]=new Kd(n.glenv,r)),n[i]}},{key:"_createMeshPivot",value:function(e){var t=null,r=this._createBoundingBox(e);if(null!==r){t=cs.createVector3();for(var n=0;n<3;++n)t[n]=(r[0][n]+r[1][n])/2}return t}},{key:"_createBoundingBox",value:function(e){var t=null,r=e.attributes.POSITION;if(void 0!==r){var n=r.min,i=r.max;null!==n&&null!==i&&(t=[cs.createVector3(n),cs.createVector3(i)])}return t}},{key:"_createProperties",value:function(e){var t=e.material;if(null===t)return{pbrMetallicRoughness:{baseColorFactor:cs.createVector4f([1,1,1,1]),baseColorTexture:null,metallicFactor:1,roughnessFactor:1,metallicRoughnessTexture:null},doubleSided:!1,alphaMode:"OPAQUE",alphaCutoff:.5,emissiveFactor:cs.createVector3f([0,0,0]),emissiveTexture:null,normalTexture:null,occlusionTexture:null};var r=t.pbrMetallicRoughness;return{pbrMetallicRoughness:{baseColorFactor:cs.createVector4f(r.baseColorFactor),baseColorTexture:this._createTextureParam(r.baseColorTexture),metallicFactor:r.metallicFactor,roughnessFactor:r.roughnessFactor,metallicRoughnessTexture:this._createTextureParam(r.metallicRoughnessTexture)},doubleSided:t.doubleSided,alphaMode:t.alphaMode,alphaCutoff:t.alphaCutoff,emissiveFactor:cs.createVector3f(t.emissiveFactor),emissiveTexture:this._createTextureParam(t.emissiveTexture),normalTexture:this._createTextureParam(t.normalTexture),occlusionTexture:this._createTextureParam(t.occlusionTexture)}}},{key:"_createTextureParam",value:function(e){if(null===e)return null;var t={texture:this._findTexture(e.texture),texCoord:e.texCoord};return e instanceof rv?t.scale=e.scale:e instanceof nv&&(t.strength=e.strength),t}},{key:"_findTexture",value:function(e){var t=this._texture_map.get(e);if(void 0===t){var r=e.sampler,n=this._glenv.context,i={mag_filter:void 0!==r.magFilter?r.magFilter:n.LINEAR,min_filter:void 0!==r.minFilter?r.minFilter:n.LINEAR_MIPMAP_LINEAR,wrap_s:r.wrapS,wrap_t:r.wrapT,flip_y:!1};t=new Wd(this._glenv,e.source.image,i),this._texture_map.set(e,t)}return t}},{key:"primitives",get:function(){return this._primitives}}],[{key:"_getNodeToScene",value:function(e,t){var r=t,n=e.matrix;return null!==n&&(r=cs.createMatrix(),cs.mul_AA(t,n,r)),r}},{key:"_convertPrimitiveMode",value:function(t){return e._DrawMode[t.mode]}},{key:"_calcNumVertices",value:function(e){var t=e.attributes,r=[];for(var n in t){var i=t[n];r.push(i.count)}return Math.min.apply(null,r)}},{key:"fastCloneProperties",value:function(t){var r=t.pbrMetallicRoughness;return{pbrMetallicRoughness:{baseColorFactor:cs.createVector3f(r.baseColorFactor),baseColorTexture:e._fastCloneTextureParam(r.baseColorTexture),metallicFactor:r.metallicFactor,roughnessFactor:r.roughnessFactor,metallicRoughnessTexture:e._fastCloneTextureParam(r.metallicRoughnessTexture)},doubleSided:t.doubleSided,alphaMode:t.alphaMode,alphaCutoff:t.alphaCutoff,emissiveFactor:cs.createVector3f(t.emissiveFactor),emissiveTexture:e._fastCloneTextureParam(t.emissiveTexture),normalTexture:e._fastCloneTextureParam(t.normalTexture),occlusionTexture:e._fastCloneTextureParam(t.occlusionTexture)}}},{key:"_fastCloneTextureParam",value:function(e){if(null===e)return null;var t={texture:e.texture,texCoord:e.texCoord};return"scale"in e?t.scale=e.scale:"strength"in e&&(t.strength=e.strength),t}}]),e}();av._DrawMode={0:ml.DrawMode.POINTS,1:ml.DrawMode.LINES,2:ml.DrawMode.LINE_LOOP,3:ml.DrawMode.LINE_STRIP,4:ml.DrawMode.TRIANGLES,5:ml.DrawMode.TRIANGLE_STRIP,6:ml.DrawMode.TRIANGLE_FAN},av._NumComponents={SCALAR:1,VEC2:2,VEC3:3,VEC4:4},av._ComponentType={5120:ml.ComponentType.BYTE,5121:ml.ComponentType.UNSIGNED_BYTE,5122:ml.ComponentType.SHORT,5123:ml.ComponentType.UNSIGNED_SHORT,5125:ml.ComponentType.UNSIGNED_INT,5126:ml.ComponentType.FLOAT},av._VertexAttribId={POSITION:"a_position",NORMAL:"a_normal",TANGENT:"a_tangent",TEXCOORD_0:"a_texcoord",TEXCOORD_1:"a_texcoord1",COLOR_0:"a_color"};var sv=function(e){function t(e,r){var n;ze(this,t);var i=t._getPreamble(r);return(n=Je(this,Ye(t).call(this,e,i+"/**\n * 太さ付き線分の頂点シェーダ\n */\n\nattribute vec4 a_position;      // 頂点位置 (モデル座標系)\nattribute vec3 a_direction;     // 線分方向 (モデル座標系) = 終点位置 - 始点位置\nattribute vec2 a_where;         // 線分の4隅指定: 始点左: {-1, 1}, 始点右: {-1, -1}, 終点左: {1, 1}, 終点右: {1, -1}\nattribute float a_length;\n\nuniform mat4 u_obj_to_clip;     // モデル座標系からクリップ座標系への変換\nuniform vec3 u_sparam;          // 画面パラメータ: {2/w, 2/h, h/w}\nuniform vec2 u_thickness;       // 線の太さの半分: {u, v}\n\nvarying highp float  v_length;  // 始点からの距離 (PathEntityのみ利用)\n\nvec2\noffset( vec4 cpos )\n{\n    vec4 q0 = cpos;\n    q0.y *= u_sparam.z;  // q0 = A * q0\n    vec4 q1 = cpos + u_obj_to_clip * vec4( a_direction, 0 );\n    q1.y *= u_sparam.z;  // q1 = A * q1\n\n    vec2 ds = normalize( q1.xy / q1.w - q0.xy / q0.w );\n    vec2 wt = a_where * u_thickness;\n    return mat2( ds.x, ds.y, -ds.y, ds.x ) * wt;\n}\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    gl_Position.xy += offset( gl_Position ) * u_sparam.xy * gl_Position.w;\n    v_length = a_length;\n}\n",i+"/**\n * 太さ付き線分のフラグメントシェーダ\n */\n\nprecision mediump float;\n\nuniform vec4 u_color;               // 線の基本色と不透明度\nuniform highp float u_lower_length; // 距離の下限値 (PathEntityのみ利用)\nuniform highp float u_upper_length; // 距離の上限値 (PathEntityのみ利用)\n\nvarying highp float  v_length;      // 始点からの距離 (PathEntityのみ利用)\n\nvoid\nmain()\n{\n#ifdef PATH\n// PathEntityの場合\n    if ( u_lower_length <= v_length && v_length <= u_upper_length ) {\n        gl_FragColor = vec4( u_color.xyz * u_color.w, u_color.w );\n    }\n    else {\n        discard;  // フラグメントを破棄\n    }\n#else\n// MarkerLineEntityの場合\n    gl_FragColor = vec4( u_color.xyz * u_color.w, u_color.w );\n#endif\n}\n")))._line_type=r,n}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,r){var n=r.properties;return(void 0!==n.opacity?n.opacity:t.DEFAULT_OPACITY)<1}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r);var i=t._sparam;i[0]=2/e._width,i[1]=2/e._height,i[2]=e._height/e._width,this.setVector3("u_sparam",i);var o=n.width||t.DEFAULT_WIDTH,a=t._thickness;a[0]=o/2,a[1]=o/2,this.setVector2("u_thickness",a);var s=void 0!==n.color?n.color:t.DEFAULT_COLOR,u=void 0!==n.opacity?n.opacity:t.DEFAULT_OPACITY,l=t._color;if(cs.copyVector3(s,l),l[3]=u,this.setVector4("u_color",l),this._line_type==dv.LineType.PATH){var _=n.lower_length;this.setFloat("u_lower_length",_);var c=n.upper_length;this.setFloat("u_upper_length",c)}}}],[{key:"_getPreamble",value:function(e){var t=[];return e==dv.LineType.PATH&&t.push("#define PATH"),t.join("\n")+"\n\n"}}]),t}(Qd);sv.DEFAULT_WIDTH=1,sv.DEFAULT_COLOR=cs.createVector3f([1,1,1]),sv.DEFAULT_OPACITY=1,sv.DEFAULT_LOWER_LENGTH=0,sv.DEFAULT_UPPER_LENGTH=0,sv._sparam=cs.createVector3f(),sv._thickness=cs.createVector2f(),sv._color=cs.createVector4f();var uv=function(){function e(){ze(this,e),this._is_compiled=!1,this._point_array=new Float64Array(0),this._num_points=0,this._node_array=new Uint32Array(0),this._next_node=0}return je(e,[{key:"addPoint",value:function(e){this._checkNotCompiled(),this._ensurePointArrayCapacity(2);var t=2*this._num_points;this._point_array[t]=e.longitude,this._point_array[t+1]=e.latitude,this._num_points+=1}},{key:"addPoints",value:function(e,t,r,n){this._checkNotCompiled(),this._ensurePointArrayCapacity(2*n);for(var i=t,o=2*this._num_points,a=this._point_array,s=0;s<n;++s)a[o]=e[i],a[o+1]=e[i+1],i+=r,o+=2;this._num_points+=n}},{key:"compile",value:function(){this._is_compiled||(this._buildCollisionQuadTree(),this._node_array.length>this._next_node&&(this._node_array=new Uint32Array(this._node_array.slice(0,this._next_node))),this._point_array=null,this._is_compiled=!0)}},{key:"intersectsWith",value:function(e){if(0==this._node_array.length)return!1;for(var t=e.getFlatAreaList(),r=0;r<t.length;++r)if(this._intersectsWith(t[r]))return!0;return!1}},{key:"_intersectsWith",value:function(e){for(var t=0,r=this._node_array,n=0;n<e.length;++n){if((t=r[t+e[n]])==cv)return!0;if(t==_v)return!1}return!0}},{key:"_checkNotCompiled",value:function(){if(this._is_compiled)throw new Error("EitityRegion is already compiled.")}},{key:"_ensurePointArrayCapacity",value:function(e){var t=2*this._num_points,r=t+e,n=this._point_array.length;if(r>n){var i=Math.max(r,Math.floor(1.5*n)),o=new Float64Array(i);o.set(this._point_array.slice(0,t)),this._point_array=o}}},{key:"_buildCollisionQuadTree",value:function(){for(var e=2*Math.PI,t=this._point_array,r=2*this._num_points,n=0;n<r;){var i=t[n++],o=t[n++],a=i+180*Math.floor((90-o)/360+Math.floor((90+o)/360)),s=a-360-360*Math.floor((a-180)/360),u=90-Math.abs(90-o+360*Math.floor((90+o)/360)),l=s*cs.DEGREE/e+.5,_=.5-cs.invGudermannian(u*cs.DEGREE)/e;this._addCollisionQuadTreeNode(l,_)}this._next_node>0&&(this._setFullNodeRecur(0),this._reduceNodeRecur(0))}},{key:"_addCollisionQuadTreeNode",value:function(e,t){if(!(t<0||t>1))for(var r=1<<lv,n=cs.clamp(Math.floor(e*r),0,r-1),i=Math.min(Math.floor(t*r),r-1),o=this._findRootNode(),a=r>>1;0!=a;a>>=1){var s=0==(n&a)?0:1,u=0==(i&a)?0:2;o=this._findChildNode(o,s+u)}}},{key:"_findRootNode",value:function(){if(0==this._next_node){this._ensureNodeArrayCapacity();for(var e=0;e<4;++e)this._node_array[e]=_v;this._next_node=4}return 0}},{key:"_findChildNode",value:function(e,t){var r=this._node_array[e+t];if(0==r){this._ensureNodeArrayCapacity(),r=this._next_node;for(var n=0;n<4;++n)this._node_array[r+n]=_v;this._next_node+=4,this._node_array[e+t]=r}return r}},{key:"_setFullNodeRecur",value:function(e){for(var t=this._node_array,r=!0,n=0;n<4;++n){var i=t[e+n];i!=_v&&(this._setFullNodeRecur(i),r=!1)}if(r)for(n=0;n<4;++n)t[e+n]=cv}},{key:"_reduceNodeRecur",value:function(e){for(var t=this._node_array,r=0,n=0;n<4;++n){var i=t[e+n];i==cv?++r:i!=_v&&this._reduceNodeRecur(i)&&(t[e+n]=cv,++r)}return 4==r}},{key:"_ensureNodeArrayCapacity",value:function(){var e=this._next_node,t=e+4,r=this._node_array.length;if(t>r){var n=Math.max(t,Math.floor(1.5*r)),i=new Uint32Array(n);i.set(this._node_array.slice(0,e)),this._node_array=i}}}]),e}(),lv=20,_v=0,cv=4294967295,hv=function(){function e(){ze(this,e),this._tree_root=null}return je(e,[{key:"getAreaStatus",value:function(e){var t=this._get_area_node(e);return t===Il.AreaStatus.EMPTY||t===Il.AreaStatus.FULL?t:Il.AreaStatus.PARTIAL}},{key:"getAreaContent",value:function(e){var t=this._get_area_node(e);return t===Il.AreaStatus.EMPTY||t===Il.AreaStatus.FULL?t:t.content}},{key:"getInitialContent",value:function(){return null}},{key:"createAreaContent",value:function(e,t,r,n){return Il.AreaStatus.EMPTY}},{key:"notifyForUpdateContent",value:function(){this._tree_root=null}},{key:"_create_area_node",value:function(e,t,r,n){var i=this.createAreaContent(e,t-r,r,n);return i===Il.AreaStatus.EMPTY||i===Il.AreaStatus.FULL?i:new fv(i)}},{key:"_get_area_node",value:function(e){var t=2,r=-1,n=1;if(null===this._tree_root){var i=this.getInitialContent();this._tree_root=this._create_area_node(r,n,t,i)}for(var o=this._tree_root,a=Math.round(Math.pow(2,e.z)),s=e.x,u=e.y;1!=a&&o!==Il.AreaStatus.EMPTY&&o!==Il.AreaStatus.FULL;){var l=s>=(a/=2)?1:0,_=u>=a?1:0;r+=l*(t/=2),n-=_*t;var c=l+2*_,h=o.children[c];null===h&&(h=this._create_area_node(r,n,t,o.content),o.children[c]=h),s-=l*a,u-=_*a,o=h}return o}}]),e}(),fv=function e(t){ze(this,e),this.children=[null,null,null,null],this.content=t},dv=function(e){function t(e,r,n){var i;return ze(this,t),(i=Je(this,Ye(t).call(this,e,n)))._line_type=r,i.altitude_mode===Tl.CLAMP?(i._producer=new yv(Ze(i)),i._is_flake_mode=!0):(i._producer=new vv(Ze(i)),i._is_flake_mode=!1),i}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._is_flake_mode?null:this._producer}},{key:"getFlakePrimitiveProducer",value:function(){return this._is_flake_mode?this._producer:null}},{key:"onChangeAltitudeMode",value:function(e){this.altitude_mode===Tl.CLAMP?(this._producer=new yv(this),this._is_flake_mode=!0):(this._producer=new vv(this),this._is_flake_mode=!1)}},{key:"setLineWidth",value:function(e){this._width!==e&&(this._width=e,this._producer.onChangeProperty())}},{key:"setColor",value:function(e){this._color[0]===e[0]&&this._color[1]===e[1]&&this._color[2]===e[2]||(cs.copyVector3(e,this._color),this._producer.onChangeProperty())}},{key:"setOpacity",value:function(e){this._opacity!==e&&(this._opacity=e,this._producer.onChangeProperty())}},{key:"_getLineMaterial",value:function(){var e=this._line_type===mv.PATH?"path":"markerline",t=this.scene,r="_AbstractLineEntity_material_"+e;return t[r]||(t[r]=new sv(t.glenv,this._line_type)),t[r]}}]),t}(Il),vv=function(e){function t(e){var r;ze(this,t),(r=Je(this,Ye(t).call(this,e)))._transform=cs.setIdentity(cs.createMatrix()),r._pivot=cs.createVector3(),r._bbox=[cs.createVector3(),cs.createVector3()],r._properties={width:1,color:cs.createVector3f(),opacity:1},e._line_type==mv.PATH&&(r._properties.lower_length=0,r._properties.upper_length=0);var n=new _l(e.scene.glenv,null,e._getLineMaterial(),r._transform);return n.pivot=r._pivot,n.bbox=r._bbox,n.properties=r._properties,r._primitive=n,r._primitives=[n],r._geom_dirty=!0,r}return qe(t,e),je(t,[{key:"createRegions",value:function(){var e=new uv;return e.addPoints(this.entity._point_array,0,3,this._numPoints()),[e]}},{key:"onChangeElevation",value:function(e){this._geom_dirty=!0}},{key:"getPrimitives",value:function(e){return this._num_floats<6?[]:(this._updatePrimitive(),this._primitives)}},{key:"onChangePoints",value:function(){this.needToCreateRegions(),this._geom_dirty=!0}},{key:"onChangeProperty",value:function(){}},{key:"_updatePrimitive",value:function(){if(this._updateProperties(),this._geom_dirty){var e=this.entity,t=this._numPoints(),r=hs.toGocsArray(this._getFlatGeoPoints_with_Absolute(),t,new Float64Array(e._num_floats));this._updateTransformPivotBBox(r,t);var n=e._line_type===mv.PATH,i=n?e._length_array:void 0,o={vtype:[{name:"a_position",size:3},{name:"a_direction",size:3},{name:"a_where",size:2}],vertices:this._createVertices(r,t,i),indices:this._createIndices()};n&&o.vtype.push({name:"a_length",size:1});var a=new ml(e.scene.glenv,o),s=this._primitive;s.mesh&&s.mesh.dispose(),s.mesh=a,this._geom_dirty=!1}}},{key:"_updateProperties",value:function(){var e=this.entity,t=this._properties;t.width=e._width,cs.copyVector3(e._color,t.color),t.opacity=e._opacity,t.lower_length=e._lower_length,t.upper_length=e._upper_length}},{key:"_getFlatGeoPoints_with_Absolute",value:function(){var e=this.entity,t=e._point_array,r=e._num_floats,n=null;switch(e.altitude_mode){case Tl.RELATIVE:var i=this._numPoints();n=new Float64Array(r),e.scene.viewer.getExistingElevations(i,t,0,3,n,2,3);for(var o=0;o<r;o+=3)n[o]=t[o],n[o+1]=t[o+1],n[o+2]+=t[o+2];break;default:n=t}return n}},{key:"_updateTransformPivotBBox",value:function(e,t){var r=e[0],n=e[1],i=e[2],o=this._transform;o[12]=r,o[13]=n,o[14]=i;for(var a=0,s=0,u=0,l=Number.MAX_VALUE,_=Number.MAX_VALUE,c=Number.MAX_VALUE,h=-Number.MAX_VALUE,f=-Number.MAX_VALUE,d=-Number.MAX_VALUE,v=0;v<t;++v){var y=3*v,p=e[y]-r,g=e[y+1]-n,m=e[y+2]-i;a+=p,s+=g,u+=m,p<l&&(l=p),g<_&&(_=g),m<c&&(c=m),p>h&&(h=p),g>f&&(f=g),m>d&&(d=m)}var k=this._pivot;k[0]=a/t,k[1]=s/t,k[2]=u/t;var w=this._bbox,E=w[0],b=w[1];E[0]=l,E[1]=_,E[2]=c,b[0]=h,b[1]=f,b[2]=d}},{key:"_createVertices",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=void 0!==r,i=e[0],o=e[1],a=e[2],s=t-1,u=4*s,l=new Float32Array((n?9:8)*u),_=0;_<s;++_)for(var c=3*_,h=e[c]-i,f=e[c+1]-o,d=e[c+2]-a,v=e[c+3]-i,y=e[c+4]-o,p=e[c+5]-a,g=e[c+3]-e[c],m=e[c+4]-e[c+1],k=e[c+5]-e[c+2],w=(n?36:32)*_,E=0;E<4;++E){var b=E<2,x=w+E*(n?9:8);switch(l[x]=b?h:v,l[x+1]=b?f:y,l[x+2]=b?d:p,l[x+3]=g,l[x+4]=m,l[x+5]=k,E){case 0:l[x+6]=-1,l[x+7]=1;break;case 1:l[x+6]=-1,l[x+7]=-1;break;case 2:l[x+6]=1,l[x+7]=1;break;case 3:l[x+6]=1,l[x+7]=-1}n&&(l[x+8]=r[b?_:_+1])}return l}},{key:"_createIndices",value:function(){for(var e=this._numPoints()-1,t=new Uint32Array(6*e),r=0;r<e;++r){var n=6*r,i=4*r;t[n]=i,t[n+1]=i+1,t[n+2]=i+2,t[n+3]=i+2,t[n+4]=i+1,t[n+5]=i+3}return t}},{key:"_numPoints",value:function(){return Math.floor(this.entity._num_floats/3)}}]),t}(Il.PrimitiveProducer),yv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e)))._material=e._getLineMaterial(),r._properties=null,r._area_manager=new gv(e),r}return qe(t,e),je(t,[{key:"getAreaStatus",value:function(e){return this._area_manager.getAreaStatus(e)}},{key:"createMesh",value:function(e,t,r){var n=this._divideXY(e,t);if(0==n.length)return null;var i=this.entity._line_type===mv.PATH,o={vtype:[{name:"a_position",size:3},{name:"a_direction",size:3},{name:"a_where",size:2}],vertices:this._createVertices(e,r,n,i),indices:this._createIndices(n.length)};return i&&o.vtype.push({name:"a_length",size:1}),new ml(this.entity.scene.glenv,o)}},{key:"getMaterialAndProperties",value:function(e){if(null===this._properties){var t=this.entity;this._properties={width:t._width,color:cs.createVector3f(t._color),opacity:t._opacity},t._line_type==mv.PATH&&(this._properties.lower_length=t._lower_length,this._properties.upper_length=t._upper_length)}return{material:this._material,properties:this._properties}}},{key:"onChangePoints",value:function(){this._area_manager.notifyForUpdateContent(),this.notifyForUpdate()}},{key:"onChangeProperty",value:function(){this._properties=null}},{key:"_divideXOnly",value:function(e,t,r){var n=Math.PI*(e.x*t-1),i=Math.PI*((e.x+1)*t-1),o=1<<r,a=(i-n)/o,s=[],u=!0,l=!1,_=void 0;try{for(var c,h=this._area_manager.getAreaContent(e)[Symbol.iterator]();!(u=(c=h.next()).done);u=!0){var f=$e(c.value,6),d=f[0],v=f[1],y=f[2],p=f[3],g=f[4],m=f[5],k=$e(d<=p?[d,v,y,p,g,m]:[p,g,m,d,v,y],6),w=k[0],E=k[1],b=k[2],x=k[3],A=k[4],T=k[5];if(!(x<n||w>=i))if(w!=x){var I=w,P=E,L=b;if(w<n){var M=(n-w)/(x-w),S=1-M;I=n,P=S*E+M*A,L=S*b+M*T}var R=x,C=A,D=T;if(x>i){var O=(i-w)/(x-w),F=1-O;R=i,C=F*E+O*A,D=F*b+O*T}for(var N=Math.max(Math.ceil((w-n)/a),1),V=Math.min(Math.floor((x-n)/a),o-1),U=I,B=P,z=L,G=N;G<=V;++G){var j=n+a*G,q=(j-w)/(x-w),Y=1-q,H=Y*E+q*A,X=Y*b+q*T;U==j&&B==H||s.push([U,B,z,j,H,X]),U=j,B=H,z=X}U==R&&B==C||s.push([U,B,z,R,C,D])}else s.push([w,E,b,x,A,T])}}catch(e){l=!0,_=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw _}}return s}},{key:"_divideXY",value:function(e,t){var r=2/Math.round(Math.pow(2,e.z)),n=Math.PI*(1-(e.y+1)*r),i=Math.PI*(1-e.y*r),o=1<<t[1],a=(i-n)/o,s=[],u=!0,l=!1,_=void 0;try{for(var c,h=this._divideXOnly(e,r,t[0])[Symbol.iterator]();!(u=(c=h.next()).done);u=!0){var f=$e(c.value,6),d=f[0],v=f[1],y=f[2],p=f[3],g=f[4],m=f[5],k=$e(v<=g?[d,v,y,p,g,m]:[p,g,m,d,v,y],6),w=k[0],E=k[1],b=k[2],x=k[3],A=k[4],T=k[5];if(!(A<n||E>=i))if(E!=A){var I=w,P=E,L=b;if(E<n){var M=(n-E)/(A-E),S=1-M;I=S*w+M*x,P=n,L=S*b+M*T}var R=x,C=A,D=T;if(A>i){var O=(i-E)/(A-E),F=1-O;R=F*w+O*x,C=i,D=F*b+O*T}for(var N=Math.max(Math.ceil((E-n)/a),1),V=Math.min(Math.floor((A-n)/a),o-1),U=I,B=P,z=L,G=N;G<=V;++G){var j=n+a*G,q=(j-E)/(A-E),Y=1-q,H=Y*w+q*x,X=Y*b+q*T;U==H&&B==j||s.push([U,B,z,H,j,X]),U=H,B=j,z=X}U==R&&B==C||s.push([U,B,z,R,C,D])}else s.push([w,E,b,x,A,T])}}catch(e){l=!0,_=e}finally{try{u||null==h.return||h.return()}finally{if(l)throw _}}return s}},{key:"_createVertices",value:function(e,t,r){for(var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=t.newLinearSampler(),o=ul.getCenter(e,cs.createVector3()),a=$e(o,3),s=a[0],u=a[1],l=a[2],_=r.length,c=4*_,h=new Float32Array((n?9:8)*c),f=0;f<_;++f)for(var d=$e(r[f],6),v=d[0],y=d[1],p=d[2],g=d[3],m=d[4],k=d[5],w=pv(v,y,i),E=$e(w,3),b=E[0],x=E[1],A=E[2],T=pv(g,m,i),I=$e(T,3),P=I[0],L=I[1],M=I[2],S=b-s,R=x-u,C=A-l,D=P-s,O=L-u,F=M-l,N=P-b,V=L-x,U=M-A,B=(n?36:32)*f,z=0;z<4;++z){var G=z<2,j=B+z*(n?9:8);switch(h[j]=G?S:D,h[j+1]=G?R:O,h[j+2]=G?C:F,h[j+3]=N,h[j+4]=V,h[j+5]=U,z){case 0:h[j+6]=-1,h[j+7]=1;break;case 1:h[j+6]=-1,h[j+7]=-1;break;case 2:h[j+6]=1,h[j+7]=1;break;case 3:h[j+6]=1,h[j+7]=-1}n&&(h[j+8]=G?p:k)}return h}},{key:"_createIndices",value:function(e){for(var t=new Uint32Array(6*e),r=0;r<e;++r){var n=6*r,i=4*r;t[n]=i,t[n+1]=i+1,t[n+2]=i+2,t[n+3]=i+2,t[n+4]=i+1,t[n+5]=i+3}return t}}]),t}(Il.FlakePrimitiveProducer);function pv(e,t,r){var n=e,i=cs.gudermannian(t),o=cs.EARTH_RADIUS+r.sample(e,t),a=Math.cos(i);return[o*a*Math.cos(n),o*a*Math.sin(n),o*Math.sin(i)]}var gv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this)))._entity=e,r}return qe(t,e),je(t,[{key:"getInitialContent",value:function(){var e=cs.DEGREE,t=Math.PI/2,r=2*Math.PI,n=[],i=this._entity._point_array,o=this._entity._num_floats;if(o<6)return n;for(var a,s,u,l=this._entity._line_type===mv.PATH,_=l?this._entity._length_array:null,c=i[0]*e,h=i[1]*e,f=l?_[0]:0,d=3;d<o;d+=3,c=a,h=s,f=u)if(a=i[d]*e,s=i[d+1]*e,u=l?_[d/3]:0,!(h<=-t||h>=t||s<=-t||s>=t)){var v=c,y=cs.invGudermannian(h),p=f,g=a,m=cs.invGudermannian(s),k=$e(v<g?[v,y,p,g,m,u]:[g,m,u,v,y,p],6),w=k[0],E=k[1],b=k[2],x=k[3],A=k[4],T=k[5];if(w<-Math.PI||w>=Math.PI){var I=x-w;((w-=r*(Math.floor((w-Math.PI)/r)+1))<-Math.PI||w>=Math.PI)&&(w=-Math.PI),x=w+I}w==x&&E==A||(n.push([w,E,b,x,A,T]),x>Math.PI&&n.push([w-r,E,b,x-r,A,T]))}return n}},{key:"createAreaContent",value:function(e,t,r,n){var i=Math.PI*e,o=Math.PI*(e+r),a=Math.PI*t,s=Math.PI*(t+r),u=[],l=!0,_=!1,c=void 0;try{for(var h,f=n[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var d=h.value,v=$e(d,5),y=v[0],p=v[1],g=v[3],m=v[4];this._intersect(i,o,a,s,y,p,g,m)&&u.push(d)}}catch(e){_=!0,c=e}finally{try{l||null==f.return||f.return()}finally{if(_)throw c}}return u.length>0?u:Il.AreaStatus.EMPTY}},{key:"_intersect",value:function(e,t,r,n,i,o,a,s){return Math.abs(i-a)<Math.abs(o-s)?this._nhorz_intersect(e,t,r,n,i,o,a,s):this._nhorz_intersect(r,n,e,t,o,i,s,a)}},{key:"_nhorz_intersect",value:function(e,t,r,n,i,o,a,s){var u=$e(o<s?[o,s]:[s,o],2),l=u[0],_=u[1];if(l>=n||_<r)return!1;var c=i+(a-i)*((r>=_?r:_)-o)/(s-o),h=i+(a-i)*((n<=l?n:l)-o)/(s-o),f=$e(c<h?[c,h]:[h,c],2),d=f[0],v=f[1];return d<t&&v>=e}}]),t}(hv),mv={MARKERLINE:{id:"MARKERLINE"},PATH:{id:"PATH"}};dv.LineType=mv;var kv=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,dv.LineType.MARKERLINE,r)))._point_array=new Float64Array(0),n._num_floats=0,n._width=1,n._color=cs.createVector3([1,1,1]),n._opacity=1,n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector3");t.addEntry("width",[r],null,(function(t){e.setLineWidth(t)})),t.addEntry("color",[n],null,(function(t){e.setColor(t)})),t.addEntry("opacity",[r],null,(function(t){e.setOpacity(t)}))}},{key:"addPoints",value:function(e){var t=e.length;if(0!=t){var r=this._num_floats+t,n=this._point_array.length;if(r>n){for(var i=new Float64Array(Math.max(r,2*n)),o=this._point_array,a=this._num_floats,s=0;s<a;++s)i[s]=o[s];this._point_array=i}for(var u=this._point_array,l=this._num_floats,_=0;_<t;++_)u[l+_]=e[_];this._num_floats=r,this._producer.onChangePoints()}}},{key:"_setupByJson",value:function(e){this.addPoints(e.points),void 0!==e.line_width&&this.setLineWidth(e.line_width),void 0!==e.color&&this.setColor(e.color),void 0!==e.opacity&&this.setOpacity(e.opacity)}}]),t}(dv),wv=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,dv.LineType.PATH,r)))._point_array=new Float64Array(0),n._num_floats=0,n._length_array=new Float64Array(0),n._width=1,n._color=cs.createVector3([1,1,1]),n._opacity=1,n._lower_length=0,n._upper_length=0,n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector3");t.addEntry("width",[r],null,(function(t){e.setLineWidth(t)})),t.addEntry("color",[n],null,(function(t){e.setColor(t)})),t.addEntry("opacity",[r],null,(function(t){e.setOpacity(t)})),t.addEntry("lower_length",[r],null,(function(t){e.setLowerLength(t)})),t.addEntry("upper_length",[r],null,(function(t){e.setUpperLength(t)}))}},{key:"setLowerLength",value:function(e){this._lower_length!==e&&(this._lower_length=e,this._producer.onChangeProperty())}},{key:"setUpperLength",value:function(e){this._upper_length!==e&&(this._upper_length=e,this._producer.onChangeProperty())}},{key:"addPoints",value:function(e,t){var r=e.length,n=t.length;if(0!=r&&0!=n){var i=this._num_floats/3,o=this._num_floats+r,a=this._point_array.length;if(o>a){for(var s=new Float64Array(Math.max(o,2*a)),u=this._point_array,l=this._num_floats,_=0;_<l;++_)s[_]=u[_];this._point_array=s}var c=i+n,h=this._length_array.length;if(c>h){for(var f=new Float64Array(Math.max(c,2*h)),d=this._length_array,v=i,y=0;y<v;++y)f[y]=d[y];this._length_array=f}for(var p=this._point_array,g=this._num_floats,m=0;m<e.length;++m)p[g+m]=e[m];for(var k=this._length_array,w=i,E=0;E<t.length;++E)k[w+E]=t[E];this._num_floats=o,this._producer.onChangePoints()}}},{key:"_setupByJson",value:function(e){this.addPoints(e.points.positions,e.points.lengths),void 0!==e.line_width&&this.setLineWidth(e.line_width),void 0!==e.color&&this.setColor(e.color),void 0!==e.opacity&&this.setOpacity(e.opacity),void 0!==e.lower_length&&this.setLowerLength(e.lower_length),void 0!==e.upper_length&&this.setUpperLength(e.upper_length)}}]),t}(dv),Ev=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e,"/**\n * テキスト (頂点シェーダ)\n */\n\nattribute vec4 a_position;    // 頂点位置 (モデル座標系)\nattribute vec2 a_offset;      // 頂点変位 (スクリーン座標系)\nattribute vec2 a_texcoord;    // テクスチャ座標\n\nuniform mat4 u_obj_to_clip;   // モデル座標系からクリップ座標系への変換\nuniform vec2 u_sparam;        // 画面パラメータ: {2/w, 2/h}\n\nvarying vec2 v_texcoord;      // テキストのテクスチャ座標\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    gl_Position.xy += a_offset * u_sparam * gl_Position.w;\n    v_texcoord = a_texcoord;\n}","/**\n * テキスト (フラグメントシェーダ)\n */\n\nprecision mediump float;\n\nvarying vec2 v_texcoord;        // テクスチャ座標\nuniform sampler2D u_image;      // 画像\n\nvoid\nmain()\n{\n    gl_FragColor = texture2D( u_image, v_texcoord );\n}"))).bindProgram(),r.setInteger("u_image",t.TEXUNIT_IMAGE),r}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,t){return!t.properties.enable_bg}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r);var i=t._sparam;i[0]=2/e._width,i[1]=2/e._height,this.setVector2("u_sparam",i);var o=n.image;this.bindTexture2D(t.TEXUNIT_IMAGE,o.handle)}}]),t}(Qd);Ev.TEXUNIT_IMAGE=0,Ev._sparam=cs.createVector2f();var bv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e,"/**\n * テキスト (頂点シェーダ)\n */\n\nattribute vec4 a_position;    // 頂点位置 (モデル座標系)\nattribute vec2 a_offset;      // 頂点変位 (スクリーン座標系)\nattribute vec2 a_texcoord;    // テクスチャ座標\nattribute vec4 a_color;       // テキストの色と不透明度\n\nuniform mat4 u_obj_to_clip;   // モデル座標系からクリップ座標系への変換\nuniform vec2 u_sparam;        // 画面パラメータ: {2/w, 2/h}\n\nvarying vec2 v_texcoord;      // テキストのテクスチャ座標\nvarying vec4 v_color;         // テキストの色と不透明度\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    gl_Position.xy += a_offset * u_sparam * gl_Position.w;\n    v_texcoord = a_texcoord;\n    v_color    = a_color;\n}\n","/**\n * テキスト (フラグメントシェーダ)\n */\n\nprecision mediump float;\n\nvarying vec2 v_texcoord;     // テキストのテクスチャ座標\nvarying vec4 v_color;        // テキストの色と不透明度\n\nuniform sampler2D u_image;   // テキスト画像\n\nvoid\nmain()\n{\n    float level = texture2D( u_image, v_texcoord ).w;  // 輝度\n    float alpha = v_color.w * level;\n    gl_FragColor = vec4( v_color.xyz * alpha, alpha );\n}\n"))).bindProgram(),r.setInteger("u_image",t.TEXUNIT_IMAGE),r}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,t){return!0}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r);var i=t._sparam;i[0]=2/e._width,i[1]=2/e._height,this.setVector2("u_sparam",i);var o=n.image;this.bindTexture2D(t.TEXUNIT_IMAGE,o.handle)}}]),t}(Qd);bv.TEXUNIT_IMAGE=0,bv._sparam=cs.createVector2f();var xv=function(){function e(t,r,n,i){ze(this,e),this._r=t,this._g=r,this._b=n,this._a=i}return je(e,[{key:"toArray",value:function(){return 0===this._a?[0,0,0,0]:[this.floatToByte(this._r)/this._a,this.floatToByte(this._g)/this._a,this.floatToByte(this._b)/this._a,this._a]}},{key:"toVector4",value:function(){return 0===this._a?[0,0,0,0]:[this._r/this._a,this._g/this._a,this._b/this._a,this._a]}},{key:"toRGBString",value:function(){var e=this.toArray();return"rgba(".concat(Math.round(e[0]),",").concat(Math.round(e[1]),",").concat(Math.round(e[2]),",").concat(e[3],")")}},{key:"floatToByte",value:function(e){return 1===e?255:256*e|0}},{key:"r",get:function(){return this._r}},{key:"g",get:function(){return this._g}},{key:"b",get:function(){return this._b}},{key:"a",get:function(){return this._a}}],[{key:"generateOpacityColor",value:function(t){return new e(t[0],t[1],t[2],1)}},{key:"copyColor",value:function(e,t){return t._r=e._r,t._g=e._g,t._b=e._b,t._a=e._a,t}},{key:"setOpacityColor",value:function(e,t){t._r=e[0],t._g=e[1],t._b=e[2],t._a=1}}]),e}(),Av=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._entries=[],n._text_parent_props={font_style:"normal",font_weight:"normal",font_size:t.DEFAULT_FONT_SIZE,font_family:t.DEFAULT_FONT_FAMILY,color:xv.generateOpacityColor(t.DEFAULT_COLOR),stroke_color:xv.generateOpacityColor(t.DEFAULT_STROKE_COLOR),stroke_width:t.DEFAULT_STROKE_WIDTH,bg_color:xv.generateOpacityColor(t.DEFAULT_BG_COLOR),enable_stroke:!1,enable_bg:!1},n._animation.addDescendantUnbinder((function(){n._unbindDescendantAnimations()})),n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._primitive_producer}},{key:"onChangeAltitudeMode",value:function(e){this._primitive_producer.onChangeAltitudeMode()}},{key:"_unbindDescendantAnimations",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){n.value.animation.unbindAllRecursively()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("string"),i=xi.find("vector3");t.addEntry("font_style",[n],null,(function(t){e.setFontStyle(t)})),t.addEntry("font_weight",[n],null,(function(t){e.setFontWeight(t)})),t.addEntry("font_size",[r],null,(function(t){e.setFontSize(t)})),t.addEntry("color",[i],null,(function(t){e.setColor(t)})),t.addEntry("stroke_color",[i],null,(function(t){e.setStrokeColor(t)})),t.addEntry("stroke_width",[r],null,(function(t){e.setStrokeLineWidth(t)}))}},{key:"setFontStyle",value:function(e){this._setValueProperty("font_style",e)}},{key:"setFontWeight",value:function(e){this._setValueProperty("font_weight",e)}},{key:"setFontSize",value:function(e){this._setValueProperty("font_size",e)}},{key:"setFontFamily",value:function(e){this._setValueProperty("font_family",e)}},{key:"setColor",value:function(e){this._setColorProperty("color",e)}},{key:"setStrokeColor",value:function(e){this._setColorProperty("stroke_color",e)}},{key:"setStrokeLineWidth",value:function(e){this._setValueProperty("stroke_width",e)}},{key:"setEnableStroke",value:function(e){this._setValueProperty("enable_stroke",e),this._primitive_producer=new Tv(this)}},{key:"setBackgroundColor",value:function(e){this._setColorProperty("bg_color",e)}},{key:"setEnableBackground",value:function(e){this._setValueProperty("enable_bg",e),this._primitive_producer=new Tv(this)}},{key:"addText",value:function(e,t,r){var n=new Iv(this,e,t,r);return this._entries.push(n),this._primitive_producer=new Tv(this),this._primitive_producer.onAddTextEntry(),n}},{key:"_getTextMaterial",value:function(){var e=this.scene;return e._TextEntity_text_material||(e._TextEntity_text_material=new Ev(e.glenv)),e._TextEntity_text_material}},{key:"_getSimpleTextMaterial",value:function(){var e=this.scene;return e._SimpleTextEntity_text_material||(e._SimpleTextEntity_text_material=new bv(e.glenv)),e._SimpleTextEntity_text_material}},{key:"_setValueProperty",value:function(e,t){var r=this._text_parent_props;r[e]!=t&&(r[e]=t,this._primitive_producer.onChangeParentProperty())}},{key:"_setColorProperty",value:function(e,t){var r=this._text_parent_props[e];r.r==t[0]&&r.g==t[1]&&r.b==t[2]||(xv.setOpacityColor(t,r),this._primitive_producer.onChangeParentProperty())}},{key:"_setupByJson",value:function(e){var t=new hs,r=!0,n=!1,i=void 0;try{for(var o,a=e.entries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;t.setFromArray(s.position),this.addText(s.text,t,s)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}void 0!==e.font_style&&this.setFontStyle(e.font_style),void 0!==e.font_weight&&this.setFontWeight(e.font_weight),void 0!==e.font_size&&this.setFontSize(e.font_size),void 0!==e.font_family&&this.setFontFamily(e.font_family),void 0!==e.color&&this.setColor(e.color),void 0!==e.stroke_color&&this.setStrokeColor(e.stroke_color),void 0!==e.stroke_width&&this.setStrokeLineWidth(e.stroke_width),void 0!==e.enable_stroke&&this.setEnableStroke(e.enable_stroke),void 0!==e.bg_color&&this.setBackgroundColor(e.bg_color),void 0!==e.enable_bg&&this.setEnableBackground(e.enable_bg)}},{key:"_enableStroke",value:function(){return this._text_parent_props.enable_stroke}},{key:"getEntry",value:function(e){return this._entries.find((function(t){return t.id===e}))}}]),t}(Il);Av.DEFAULT_FONT_SIZE=16,Av.DEFAULT_FONT_FAMILY="sans-serif",Av.DEFAULT_COLOR=[1,1,1],Av.DEFAULT_STROKE_COLOR=[0,0,0],Av.DEFAULT_STROKE_WIDTH=.48,Av.DEFAULT_BG_COLOR=[.3,.3,.3],Av.DEFAULT_TEXT_UPPER=1.1,Av.DEFAULT_TEXT_LOWER=.38,Av.SAFETY_PIXEL_MARGIN=1,Av.MAX_IMAGE_WIDTH=4096;var Tv=function(e){function t(e){var r;ze(this,t),(r=Je(this,Ye(t).call(this,e)))._glenv=e.scene.glenv,r._dirty=!0,r._transform=cs.setIdentity(cs.createMatrix()),r._properties={enable_bg:!1,image:null};var n=null;n=r._isSimpleText()?e._getSimpleTextMaterial():e._getTextMaterial();var i=new _l(r._glenv,null,n,r._transform);return i.properties=r._properties,r._primitive=i,r._primitives=[],r}return qe(t,e),je(t,[{key:"createRegions",value:function(){var e=new uv,t=!0,r=!1,n=void 0;try{for(var i,o=this.entity._entries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value.position;e.addPoint(a)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return[e]}},{key:"onChangeElevation",value:function(e){this._dirty=!0}},{key:"getPrimitives",value:function(e){return this._updatePrimitive()}},{key:"onChangeParentProperty",value:function(){this._dirty=!0}},{key:"onChangeChildProperty",value:function(){this._dirty=!0}},{key:"onChangeAltitudeMode",value:function(){this._dirty=!0}},{key:"onAddTextEntry",value:function(){this.needToCreateRegions(),this._dirty=!0}},{key:"_updatePrimitive",value:function(){if(!this._dirty)return this._primitives;if(this._updateProperties(),0==this.entity._entries.length)return this._primitives=[],this._dirty=!1,this._primitives;var e=this._createFlatGocsArray();this._updateTransform(e);var t=new Pv(this,e);if(!t.isValid())return this._primitives=[],this._dirty=!1,this._primitives;var r=this._properties;r.image&&r.image.dispose(),r.image=t.texture;var n={vtype:this._isSimpleText()?[{name:"a_position",size:3},{name:"a_offset",size:2},{name:"a_texcoord",size:2},{name:"a_color",size:4}]:[{name:"a_position",size:3},{name:"a_offset",size:2},{name:"a_texcoord",size:2}],vertices:t.vertices,indices:t.indices},i=new ml(this._glenv,n),o=this._primitive;return o.mesh&&o.mesh.dispose(),o.mesh=i,this._primitives=[o],this._dirty=!1,this._primitives}},{key:"_updateProperties",value:function(){var e=this.entity;this._properties.enable_bg=e._text_parent_props.enable_bg}},{key:"_updateTransform",value:function(e){for(var t=this.entity._entries.length,r=0,n=0,i=0,o=0;o<t;++o){var a=3*o;r+=e[a],n+=e[a+1],i+=e[a+2]}var s=this._transform;s[12]=r/t,s[13]=n/t,s[14]=i/t}},{key:"_createFlatGocsArray",value:function(){var e=this.entity._entries.length;return hs.toGocsArray(this._getFlatGeoPoints_with_Absolute(),e,new Float64Array(3*e))}},{key:"_getFlatGeoPoints_with_Absolute",value:function(){for(var e=this.entity,t=e._entries,r=t.length,n=new Float64Array(3*r),i=0;i<r;++i){var o=t[i].position;n[3*i]=o.longitude,n[3*i+1]=o.latitude}switch(e.altitude_mode){case Tl.RELATIVE:case Tl.CLAMP:if(e.scene.viewer.getExistingElevations(r,n,0,3,n,2,3),e.altitude_mode===Tl.RELATIVE)for(var a=0;a<r;++a)n[3*a+2]+=t[a].position.altitude;break;default:for(var s=0;s<r;++s)n[3*s+2]=t[s].position.altitude}return n}},{key:"_isSimpleText",value:function(){var e=this.entity,t=!0;(e._text_parent_props.enable_bg||e._text_parent_props.enable_stroke)&&(t=!1);for(var r=0;t&&e._entries.length>r;){t=!e._entries[r].enable_stroke,r++}return t}}]),t}(Il.PrimitiveProducer),Iv=function(){function e(t,r,n,i){ze(this,e),this._owner=t,this._text=r,this._position=n.clone(),this._animation=new Qs,this._setupAnimationBindingBlock(),this._props=Object.assign({},i),this._copyColorProperty("color"),this._copyColorProperty("stroke_color"),this._copyColorProperty("bg_color")}return je(e,[{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("string"),i=xi.find("vector3"),o=new hs;t.addEntry("position",[i],null,(function(t){o.setFromArray(t),e.setPosition(o)})),t.addEntry("font_style",[n],null,(function(t){e.setFontStyle(t)})),t.addEntry("font_weight",[n],null,(function(t){e.setFontWeight(t)})),t.addEntry("font_size",[r],null,(function(t){e.setFontSize(t)})),t.addEntry("color",[i],null,(function(t){e.setColor(t)})),t.addEntry("stroke_color",[i],null,(function(t){e.setStrokeColor(t)})),t.addEntry("stroke_width",[r],null,(function(t){e.setStrokeLineWidth(t)})),t.addEntry("text",[n],null,(function(t){e.setText(t)}))}},{key:"setPosition",value:function(e){this._position.longitude===e.longitude&&this._position.latitude===e.latitude&&this._position.altitude===e.altitude||(this._position.assign(e),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"setFontStyle",value:function(e){this._setValueProperty("font_style",e)}},{key:"setFontWeight",value:function(e){this._setValueProperty("font_weight",e)}},{key:"setFontSize",value:function(e){this._setValueProperty("font_size",e)}},{key:"setColor",value:function(e){this._setColorProperty("color",e)}},{key:"setStrokeColor",value:function(e){this._setColorProperty("stroke_color",e)}},{key:"setStrokeLineWidth",value:function(e){this._setValueProperty("stroke_width",e)}},{key:"setEnableStroke",value:function(e){this._setValueProperty("enable_stroke",e),this._owner._primitive_producer=new Tv(this._owner)}},{key:"setText",value:function(e){this._text!==e&&(this._text=e,this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"_copyColorProperty",value:function(e){var t=this._props;t.hasOwnProperty(e)&&(t[e]=xv.generateOpacityColor(t[e]))}},{key:"_setValueProperty",value:function(e,t){var r=this._props;r[e]!=t&&(r[e]=t,this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"_setColorProperty",value:function(e,t){var r=this._props[e];r?r.r==t[0]&&r.g==t[1]&&r.b==t[2]||(xv.setOpacityColor(t,r),this._owner.getPrimitiveProducer().onChangeChildProperty()):(this._props[e]=xv.generateOpacityColor(t),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"text",get:function(){return this._text}},{key:"position",get:function(){return this._position}},{key:"id",get:function(){return this._props.hasOwnProperty("id")?this._props.id:""}},{key:"size",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.font_size||t.font_size}},{key:"color",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.color||t.color}},{key:"font",get:function(){var e=this._props,t=this._owner._text_parent_props,r=e.font_style||t.font_style,n=e.font_weight||t.font_weight,i=e.font_family||t.font_family;return r+" normal "+n+" "+this.size+"px "+i}},{key:"stroke_color",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.stroke_color||t.stroke_color}},{key:"stroke_width",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.stroke_width||t.stroke_width}},{key:"enable_stroke",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.enable_stroke||t.enable_stroke}},{key:"bg_color",get:function(){var e=this._props,t=this._owner._text_parent_props;return e.bg_color||t.bg_color}},{key:"enable_background",get:function(){return this._owner._text_parent_props.enable_bg}},{key:"animation",get:function(){return this._animation}}]),e}();Av.Entry=Iv;var Pv=function(){function e(t,r){ze(this,e),this._owner=t,this._items=this._createItemList(),this._is_valid=!0;var n=this._createRowLayouts();if(0!=n.length){var i=this._setupLocation(n);this._isSimpleTextWithAllItems(this._items)?(this._texture=this._createTextureForSimple(i.width,i.height),this._vertices=this._createVerticesForSimple(i.width,i.height,r)):(this._texture=this._createTexture(i.width,i.height),this._vertices=this._createVertices(i.width,i.height,r)),this._indices=this._createIndices()}else this._is_valid=!1}return je(e,[{key:"isValid",value:function(){return this._is_valid}},{key:"_createItemList",value:function(){var e=Ud.createCanvasContext(1,1),t=[],r=!0,n=!1,i=void 0;try{for(var o,a=this._owner.entity._entries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;t.push(new Lv(this,s,e))}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return t}},{key:"_createRowLayouts",value:function(){var e=[].concat(this._items);e.sort((function(e,t){return e.height_pixel-t.height_pixel}));for(var t=[];e.length>0;){var r=new Mv(e);r.isValid()&&t.push(r)}return t}},{key:"_createTexture",value:function(e,t){var r=Ud.createCanvasContext(e,t);r.textAlign="left",r.textBaseline="alphabetic",r.fillStyle="rgba( 255, 255, 255, 1.0 )";for(var n=this._items,i=0;i<n.length;++i){var o=n[i];o.is_canceled||(o._entry.enable_background&&o.drawRect(r),o.drawText(r),o._entry.enable_stroke&&o.drawStrokeText(r))}var a=this._owner._glenv,s={usage:Wd.Usage.TEXT};return new Wd(a,r.canvas,s)}},{key:"_createVertices",value:function(e,t,r){for(var n=[],i=this._owner._transform,o=i[12],a=i[13],s=i[14],u=this._items,l=0;l<u.length;++l){var _=u[l];if(!_.is_canceled){var c=3*l,h=r[c]-o,f=r[c+1]-a,d=r[c+2]-s,v=_.pos_x,y=_.pos_y,p=_.upper,g=_.lower,m=_.width,k=1/e,w=1/t;n.push(h,f,d),n.push(-m/2,-g),n.push(v*k,1-(y+g)*w),n.push(h,f,d),n.push(m/2,-g),n.push((v+m)*k,1-(y+g)*w),n.push(h,f,d),n.push(-m/2,p),n.push(v*k,1-(y-p)*w),n.push(h,f,d),n.push(m/2,p),n.push((v+m)*k,1-(y-p)*w)}}return n}},{key:"_createTextureForSimple",value:function(e,t){var r=Ud.createCanvasContext(e,t);r.textAlign="left",r.textBaseline="alphabetic",r.fillStyle="rgba( 255, 255, 255, 1.0 )";for(var n=this._items,i=0;i<n.length;++i){var o=n[i];o.is_canceled||o.drawText(r)}var a=this._owner._glenv,s={usage:Wd.Usage.SIMPLETEXT};return new Wd(a,r.canvas,s)}},{key:"_createVerticesForSimple",value:function(e,t,r){for(var n=[],i=this._owner._transform,o=i[12],a=i[13],s=i[14],u=this._items,l=0;l<u.length;++l){var _=u[l];if(!_.is_canceled){var c=_.entry.color.toVector4(),h=3*l,f=r[h]-o,d=r[h+1]-a,v=r[h+2]-s,y=_.pos_x,p=_.pos_y,g=_.upper,m=_.lower,k=_.width,w=1/e,E=1/t;n.push(f,d,v),n.push(-k/2,-m),n.push(y*w,1-(p+m)*E),n.push(c[0],c[1],c[2],1),n.push(f,d,v),n.push(k/2,-m),n.push((y+k)*w,1-(p+m)*E),n.push(c[0],c[1],c[2],1),n.push(f,d,v),n.push(-k/2,g),n.push(y*w,1-(p-g)*E),n.push(c[0],c[1],c[2],1),n.push(f,d,v),n.push(k/2,g),n.push((y+k)*w,1-(p-g)*E),n.push(c[0],c[1],c[2],1)}}return n}},{key:"_createIndices",value:function(){for(var e=[],t=this._items,r=0;r<t.length;++r){if(!t[r].is_canceled){var n=4*r;e.push(n,n+1,n+2,n+2,n+1,n+3)}}return e}},{key:"_setupLocation",value:function(e){var t=0,r=0;r+=Av.SAFETY_PIXEL_MARGIN;for(var n=0;n<e.length;++n){var i=e[n];i.locate(r),t=Math.max(i.width_assumed,t),r+=i.height_pixel+Av.SAFETY_PIXEL_MARGIN}return{width:t,height:r}}},{key:"_isSimpleText",value:function(e){return!e._entry.enable_background&&!e._entry.enable_stroke}},{key:"_isSimpleTextWithAllItems",value:function(e){for(var t=!0,r=0;t&&e.length>r;){var n=e[r];t=this._isSimpleText(n),r++}return t}},{key:"texture",get:function(){return this._texture}},{key:"vertices",get:function(){return this._vertices}},{key:"indices",get:function(){return this._indices}}]),e}(),Lv=function(){function e(t,r,n){ze(this,e),this._entry=r,this._pos_x=0,this._pos_y=0,n.font=r.font,this._width=n.measureText(r.text).width,this._upper=r.size*Av.DEFAULT_TEXT_UPPER,this._lower=r.size*Av.DEFAULT_TEXT_LOWER,this._is_canceled=!1}return je(e,[{key:"cancel",value:function(){this._is_canceled=!0}},{key:"locate",value:function(e,t){this._pos_x=e,this._pos_y=t+Math.ceil(this._upper)}},{key:"drawTextOnly",value:function(e){var t=this._entry;e.font=t.font,e.fillText(t.text,this._pos_x,this._pos_y)}},{key:"drawText",value:function(e){var t=this._entry;e.font=t.font,e.fillStyle=t.color.toRGBString(),e.fillText(t.text,this._pos_x,this._pos_y)}},{key:"drawStrokeText",value:function(e){var t=this._entry;e.strokeStyle=t.stroke_color.toRGBString(),e.lineWidth=t.stroke_width,e.lineJoin="round",e.strokeText(t.text,this._pos_x,this._pos_y)}},{key:"drawRect",value:function(e){var t=this._entry;e.fillStyle=t.bg_color.toRGBString(),e.fillRect(this._pos_x-Av.SAFETY_PIXEL_MARGIN,this._pos_y-this._upper-Av.SAFETY_PIXEL_MARGIN,this.width_pixel+Av.SAFETY_PIXEL_MARGIN,this.height_pixel+Av.SAFETY_PIXEL_MARGIN)}},{key:"entry",get:function(){return this._entry}},{key:"pos_x",get:function(){return this._pos_x}},{key:"pos_y",get:function(){return this._pos_y}},{key:"width",get:function(){return this._width}},{key:"upper",get:function(){return this._upper}},{key:"lower",get:function(){return this._lower}},{key:"width_pixel",get:function(){return Math.ceil(this._width)}},{key:"height_pixel",get:function(){return Math.ceil(this._upper)+Math.ceil(this._lower)}},{key:"is_canceled",get:function(){return this._is_canceled}}]),e}(),Mv=function(){function e(t){ze(this,e);var r=0,n=0,i=[];for(r+=Av.SAFETY_PIXEL_MARGIN;t.length>0;){var o=t.shift(),a=o.width_pixel+Av.SAFETY_PIXEL_MARGIN;if(r+a<=Av.MAX_IMAGE_WIDTH)i.push(o),r+=a,n=Math.max(o.height_pixel,n);else{if(0!=i.length){t.unshift(o);break}o.cancel()}}this._items=i,this._width_assumed=r,this._height_pixel=n}return je(e,[{key:"isValid",value:function(){return this._items.length>0}},{key:"locate",value:function(e){var t=this._items,r=0;r+=Av.SAFETY_PIXEL_MARGIN;for(var n=0;n<t.length;++n){var i=t[n];i.locate(r,e),r+=i.width_pixel+Av.SAFETY_PIXEL_MARGIN}}},{key:"items",get:function(){return this._items}},{key:"width_assumed",get:function(){return this._width_assumed}},{key:"height_pixel",get:function(){return this._height_pixel}}]),e}(),Sv=function(e){function t(e,r){var n;if(ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._position=new hs(0,0,0),n._rotation=cs.setIdentity(cs.createMatrix()),n._scale=cs.createVector3([1,1,1]),n._primitive_producer=new Rv(Ze(n)),n._setupAnimationBindingBlock(),r&&r.json){var i=r.json,o=r.refs||{};n._setupTransform(i),n._setupModelObject(i,o)}return n}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._primitive_producer}},{key:"onChangeAltitudeMode",value:function(e){this._primitive_producer.onChangeAltitudeMode()}},{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector3"),i=xi.find("matrix"),o=new hs;t.addEntry("position",[n],null,(function(t){o.setFromArray(t),e.setPosition(o)}));var a,s=new fs;t.addEntry("orientation",[i,n],(function(e){return a=Ks.findFirstTypeSupported(e,[i,n])}),(function(t){a===i?e._setRotation(t):(s.heading=t[0],s.tilt=t[1],s.roll=t[2],e.setOrientation(s))}));var u,l=cs.createVector3();t.addEntry("scale",[n,r],(function(e){return u=Ks.findFirstTypeSupported(e,[n,r])}),(function(t){u===n?e.setScale(t):(l[0]=t,l[1]=t,l[2]=t,e.setScale(l))}))}},{key:"_setupTransform",value:function(e){var t=e.transform;this.setPosition((new hs).setFromArray(t.position)),this.setOrientation(new fs(t.heading,t.tilt,t.roll));var r=void 0!==t.scale?t.scale:[1,1,1];"number"==typeof r&&(r=[r,r,r]),this.setScale(r)}},{key:"_setupModelObject",value:function(e,t){var r=t[e.ref_model];this._primitive_producer.setModelObject(r,e.index)}},{key:"setPosition",value:function(e){var t=this._position;e.longitude==t.longitude&&e.latitude==t.latitude&&e.altitude==t.altitude||(this._position.assign(e),this._primitive_producer.onChangePosition())}},{key:"setOrientation",value:function(e){e.getTransformMatrix(Cv,this._rotation)}},{key:"setScale",value:function(e){cs.copyVector3(e,this._scale)}},{key:"_setRotation",value:function(e){cs.copyMatrix(e,this._rotation)}},{key:"_getElevation",value:function(){return this.scene.viewer.getExistingElevation(this._position)}}]),t}(Il),Rv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e)))._primitives=[],r._ptoe_array=[],r._abs_position=null,r}return qe(t,e),je(t,[{key:"setModelObject",value:function(e,t){var r=e.createPrimitives(t);if(!r)throw new Error("model is not found in ModelContainer");this._primitives=r,this._ptoe_array=r.map((function(e){return cs.createMatrix(e.transform)}))}},{key:"createRegions",value:function(){var e=new uv;return e.addPoint(this.entity._position),[e]}},{key:"onChangeElevation",value:function(e){this._abs_position=null}},{key:"getPrimitives",value:function(e){var t=this.entity;this._updateAbsPosition();for(var r,n,i,o,a,s,u=this._abs_position.getMlocsToGocsMatrix(cs.createMatrix()),l=(r=t._rotation,n=t._scale,i=cs.createMatrix(),o=n[0],a=n[1],s=n[2],i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o,i[3]=0,i[4]=r[4]*a,i[5]=r[5]*a,i[6]=r[6]*a,i[7]=0,i[8]=r[8]*s,i[9]=r[9]*s,i[10]=r[10]*s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i),_=cs.mul_AA(u,l,cs.createMatrix()),c=this._primitives,h=this._ptoe_array,f=0;f<c.length;++f){var d=c[f],v=h[f];cs.mul_AA(_,v,d.transform)}return this._primitives}},{key:"onChangeAltitudeMode",value:function(){this._abs_position=null}},{key:"onChangePosition",value:function(){this.needToCreateRegions(),this._abs_position=null}},{key:"_updateAbsPosition",value:function(){if(null===this._abs_position){var e=this.entity;switch(this._abs_position=e._position.clone(),e.altitude_mode){case Tl.RELATIVE:this._abs_position.altitude+=e._getElevation();break;case Tl.CLAMP:this._abs_position.altitude=e._getElevation()}}}}]),t}(Il.PrimitiveProducer),Cv=cs.createVector3([1,1,1]);(0,Vo.exportTypedArrayStaticMethod)("from",Yo,Go);var Dv=function(e){function t(e){return ze(this,t),Je(this,Ye(t).call(this,e,"/**\n * 多角形の頂点シェーダ\n */\n\nattribute vec4 a_position;   // 位置 (モデル座標系)\nattribute vec3 a_normal;     // 法線 (モデル座標系)\n\nuniform mat4 u_obj_to_clip;  // モデル座標系からクリップ座標系への変換\nuniform mat4 u_obj_to_view;  // モデル座標系から視点座標系への変換\nuniform bool u_lighting;     // 照光の有無\nuniform vec3 u_light_dir;    // ライト逆方向 (視点座標系) と強さ\n\nvarying vec3 v_lit_diffuse;  // 拡散光ライト\n\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n\n    if ( u_lighting ) {\n        // 法線 (視点座標系)\n        vec3 normal = normalize( vec3( u_obj_to_view * vec4( a_normal, 0.0 ) ) );\n\n        // 拡散光の強さ\n        v_lit_diffuse = vec3( dot( normal, u_light_dir ) );\n    }\n    else {\n        // 照光なしのときは 1 に固定\n        v_lit_diffuse = vec3( 1 );\n    }\n}\n","/**\n * 多角形のフラグメントシェーダ\n */\n\nprecision mediump float;\n\nvarying vec3 v_lit_diffuse;  // 拡散光ライト\n\nuniform vec4 u_color;        // 基本色と不透明度\n\n\nvoid\nmain()\n{\n    vec3  color   = u_color.xyz * v_lit_diffuse;\n    float opacity = u_color.w;\n\n    gl_FragColor = vec4( color * opacity, opacity );\n}\n"))}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,r){var n=r.properties;return(void 0!==n.opacity?n.opacity:t.DEFAULT_OPACITY)<1}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r),this.setObjToView(e,r);var i=void 0!==n.color?n.color:t.DEFAULT_COLOR,o=void 0!==n.opacity?n.opacity:t.DEFAULT_OPACITY,a=t._color;cs.copyVector3(i,a),a[3]=o,this.setVector4("u_color",a),this.setBoolean("u_lighting",n.lighting),this.setVector3("u_light_dir",[0,0,1])}}]),t}(Qd);Dv.DEFAULT_COLOR=cs.createVector3f([1,1,1]),Dv.DEFAULT_OPACITY=1,Dv._color=cs.createVector4f();var Ov=function(){function e(t,r,n,i){ze(this,e),this._points=new Float64Array(2*i),this._polygons=new Set;for(var o=r,a=0,s=0;s<i;++s)this._points[a]=t[o],this._points[a+1]=t[o+1],o+=n,a+=2}return je(e,[{key:"addBoundary",value:function(e){this._polygons.add(Nv.create(this._points,e))}},{key:"run",value:function(){this._makeYMonotonePolygons();var e=new Uint32Array(3*this._numTriangles()),t=0,r=!0,n=!1,i=void 0;try{for(var o,a=this._polygons[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value,u=this._makeTriangleArray(s);e.set(u,t),t+=u.length}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return e}},{key:"_numTriangles",value:function(){var e=0,t=!0,r=!1,n=void 0;try{for(var i,o=this._polygons[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){e+=i.value.numVertices()-2}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return e}},{key:"_makeYMonotonePolygons",value:function(){for(var e=this._getYOrderedVertices(),t=new Vv,r=new Bv(this._polygons),n=0;n<e.length;++n){var i=e[n];switch(i.getVertexType()){case"start":var o=i.getFrontEdge();t.addEdge(o,i);break;case"end":var a=i.getBackEdge(),s=t.getHelper(a);"merge"==s.getVertexType()&&r.addDiagonal(i,s),t.removeEdge(a);break;case"split":var u=t.findNearestLeftEdge(i);r.addDiagonal(i,t.getHelper(u)),t.setHelper(u,i);var l=i.getFrontEdge();t.addEdge(l,i);break;case"merge":var _=i.getBackEdge(),c=t.getHelper(_);"merge"==c.getVertexType()&&r.addDiagonal(i,c),t.removeEdge(_);var h=t.findNearestLeftEdge(i),f=t.getHelper(h);"merge"==f.getVertexType()&&r.addDiagonal(i,f),t.setHelper(h,i);break;default:if(i.isRightInner()){var d=i.getBackEdge(),v=t.getHelper(d);"merge"==v.getVertexType()&&r.addDiagonal(i,v),t.removeEdge(d);var y=i.getFrontEdge();t.addEdge(y,i)}else{var p=t.findNearestLeftEdge(i),g=t.getHelper(p);"merge"==g.getVertexType()&&r.addDiagonal(i,g),t.setHelper(p,i)}}}r.splitPolygons()}},{key:"_getYOrderedVertices",value:function(){var e=[],t=!0,r=!1,n=void 0;try{for(var i,o=this._polygons[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;Array.prototype.push.apply(e,a.getVertices())}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return e.sort((function(e,t){return Fv.comparePositionY(t,e)}))}},{key:"_makeTriangleArray",value:function(e){var t=0,r=new Uint32Array(3*(e.numVertices()-2)),n=new Gv,i=0,o=e.getVertices().sort((function(e,t){return Fv.comparePositionY(t,e)})),a=o[0].prev===o[1];for(n.push(o[i++]),n.push(o[i++]);i<o.length-1;){var s=o[i];if(a?s===n.top.prev:s===n.top.next){for(var u=n.pop();n.size>0;){var l=n.top,_=$e(a?[u,l]:[l,u],2),c=_[0],h=_[1];if(!Fv.isCCW(s,c,h))break;r[t++]=s.id,r[t++]=c.id,r[t++]=h.id,u=n.pop()}n.push(u),n.push(s)}else{for(var f=n.pop();n.size>0;){var d=n.pop(),v=$e(a?[f,d]:[d,f],2),y=v[0],p=v[1];r[t++]=s.id,r[t++]=y.id,r[t++]=p.id,f=d}n.push(o[i-1]),n.push(s),a=!a}++i}for(var g=o[i],m=n.pop();n.size>0;){var k=n.pop(),w=$e(a?[m,k]:[k,m],2),E=w[0],b=w[1];r[t++]=g.id,r[t++]=E.id,r[t++]=b.id,m=k}return r}}]),e}(),Fv=function(){function e(t,r,n){ze(this,e),this.id=t,this.x=r,this.y=n,this.polygon=null,this.next=null,this.prev=null}return je(e,[{key:"clone",value:function(){return new e(this.id,this.x,this.y)}},{key:"getVertexType",value:function(){var t=this.prev,r=this.next,n=e.comparePositionY(t,this),i=e.comparePositionY(r,this);if(n>0&&i>0||n<0&&i<0){var o=t.y-this.y,a=this.x-t.x,s=o*(r.x-this.x)+a*(r.y-this.y);return n>0&&i>0?s<0?"merge":"end":s<0?"split":"start"}return"regular"}},{key:"getFrontEdge",value:function(){return this}},{key:"getBackEdge",value:function(){return this.prev}},{key:"isRightInner",value:function(){return e.comparePositionY(this.next,this)<0}}],[{key:"comparePositionY",value:function(e,t){return e.y<t.y||e.y==t.y&&e.x>t.x?-1:e.y>t.y||e.y==t.y&&e.x<t.x?1:0}},{key:"isCCW",value:function(e,t,r){var n=t.x-e.x,i=t.y-e.y,o=r.x-e.x;return n*(r.y-e.y)-i*o>0}}]),e}(),Nv=function(){function e(){ze(this,e),this._first=null}return je(e,[{key:"numVertices",value:function(){var e=0,t=this._first;++e;var r=this._first;for(t=t.next;t!==r;t=t.next)++e;return e}},{key:"getVertices",value:function(){var e=[],t=this._first;e.push(t);var r=this._first;for(t=t.next;t!==r;t=t.next)e.push(t);return e}},{key:"_updateVertices",value:function(){var e=this._first;e.polygon=this;var t=this._first;for(e=e.next;e!==t;e=e.next)e.polygon=this}}],[{key:"create",value:function(t,r){var n=new e,i=r[0],o=2*i,a=new Fv(i,t[o],t[o+1]);n._first=a;for(var s=1;s<r.length;++s){var u=a;i=r[s],a=new Fv(i,t[o=2*i],t[o+1]),u.next=a,a.prev=u}return n._first.prev=a,a.next=n._first,n._updateVertices(),n}},{key:"createByVertex",value:function(t){var r=new e;return r._first=t,r._updateVertices(),r}}]),e}(),Vv=function(){function e(){ze(this,e),this._edges=new Map}return je(e,[{key:"addEdge",value:function(e,t){this._edges.set(e,{helper:t})}},{key:"removeEdge",value:function(e){this._edges.delete(e)}},{key:"setHelper",value:function(e,t){this._edges.get(e).helper=t}},{key:"getHelper",value:function(e){return this._edges.get(e).helper}},{key:"findNearestLeftEdge",value:function(e){var t,r=Number.MAX_VALUE,n=e.x,i=e.y,o=!0,a=!1,s=void 0;try{for(var u,l=this._edges[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var _=$e(u.value,1)[0],c=_.x,h=_.y,f=n-(c+(i-h)*((_.next.x-c)/(_.next.y-h)));f>0&&f<r&&(r=f,t=_)}}catch(e){a=!0,s=e}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}if(void 0===t)throw new Error("Probably a degenerate polygon");return t}}]),e}(),Uv=function e(t,r){ze(this,e),this.v1=t,this.v2=r},Bv=function(){function e(t){ze(this,e),this._polygons=t,this._diagonals=[],this._dmap=new zv}return je(e,[{key:"addDiagonal",value:function(e,t){var r=new Uv(e,t);this._diagonals.push(r),this._dmap.addDiagonal(r)}},{key:"splitPolygons",value:function(){for(this._shuffleArray(this._diagonals);this._diagonals.length>0;){var e=this._diagonals.pop();this._dmap.removeDiagonal(e);var t=e.v1,r=e.v2,n=$e(this._splitPolygonHalf(t,r),2),i=n[0],o=n[1],a=$e(this._splitPolygonHalf(r,t),2),s=a[0],u=a[1],l=t.polygon,_=r.polygon;l===_?(this._polygons.delete(l),this._polygons.add(Nv.createByVertex(i)),this._polygons.add(Nv.createByVertex(u))):(this._polygons.delete(l),this._polygons.delete(_),this._polygons.add(Nv.createByVertex(i))),this._replaceVertexInDiagonals(t,i,u),this._replaceVertexInDiagonals(r,o,s)}}},{key:"_splitPolygonHalf",value:function(e,t){var r=e.clone(),n=t.clone();return r.prev=e.prev,r.next=n,e.prev.next=r,n.prev=r,n.next=t.next,t.next.prev=n,[r,n]}},{key:"_replaceVertexInDiagonals",value:function(e,t,r){var n=!0,i=!1,o=void 0;try{for(var a,s=this._dmap.removeDiagonals(e)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value,l=u.v1===e?u.v2:u.v1;u.v1=this._testDiagonal(t,l)?t:r,u.v2=l,this._dmap.addDiagonal(u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}}},{key:"_testDiagonal",value:function(e,t){var r=e.next.x-e.x,n=e.next.y-e.y,i=e.prev.x-e.x,o=e.prev.y-e.y,a=t.x-e.x,s=t.y-e.y,u=r*s-a*n>0,l=i*s-a*o<0;return r*o-i*n>=0?u&&l:u||l}},{key:"_shuffleArray",value:function(e){for(var t=e.length-1;t>0;--t){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}}}]),e}(),zv=function(){function e(){ze(this,e),this._map=new Map}return je(e,[{key:"addDiagonal",value:function(e){this._addDiagonalByVertex(e.v1,e),this._addDiagonalByVertex(e.v2,e)}},{key:"removeDiagonal",value:function(e){this._removeDiagonalByVertex(e.v1,e),this._removeDiagonalByVertex(e.v2,e)}},{key:"removeDiagonals",value:function(e){var t=this._map.get(e);if(void 0!==t){var r=t.slice(),n=!0,i=!1,o=void 0;try{for(var a,s=r[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;this.removeDiagonal(u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}return[]}},{key:"_addDiagonalByVertex",value:function(e,t){var r=this._map.get(e);if(void 0===r)this._map.set(e,[t]);else{if(-1!=r.indexOf(t))throw new Error("Unexpected");if(r.length<1||r.length>2)throw new Error("Unexpected");r.push(t)}}},{key:"_removeDiagonalByVertex",value:function(e,t){var r=this._map.get(e);if(void 0===r)throw new Error("Unexpected");var n=r.indexOf(t);if(-1==n)throw new Error("Unexpected");r.splice(n,1),0==r.length&&this._map.delete(e)}}]),e}(),Gv=function(){function e(){ze(this,e),this._array=new Array}return je(e,[{key:"push",value:function(e){this._array.push(e)}},{key:"pop",value:function(){return this._array.pop()}},{key:"size",get:function(){return this._array.length}},{key:"top",get:function(){var e=this._array;return e.length>0?e[e.length-1]:null}}]),e}(),jv=n.isFinite,qv=Number.isFinite||function(e){return"number"==typeof e&&jv(e)};Re({target:"Number",stat:!0},{isFinite:qv});var Yv=function(){function e(t){ze(this,e),this._vertices=Float64Array.from(t),this._num_vertices=this._vertices.length/2}return je(e,[{key:"isValid",value:function(){if(this._num_vertices<3)return!1;for(var e=0;e<this._num_vertices;++e){var t=this._vertices[2*e],r=this._vertices[2*e+1];if(!Number.isFinite(t)||!Number.isFinite(r))return!1}for(var n=0;n<this._num_vertices;++n){var i=0!=n?n-1:this._num_vertices-1,o=this._vertices[2*i],a=this._vertices[2*i+1],s=this._vertices[2*n],u=this._vertices[2*n+1];if(o==s&&a==u)return!1}for(var l=0;l<this._num_vertices;++l){var _=this._vertices[2*l],c=this._vertices[2*l+1],h=l==this._num_vertices-1?0:l+1,f=this._vertices[2*h]-_,d=this._vertices[2*h+1]-c,v=0==l?this._num_vertices-1:l-1,y=this._vertices[2*v]-_,p=this._vertices[2*v+1]-c,g=f*p-y*d;if(g<0||0==g&&f*y+d*p>0)return!1}return!0}},{key:"getIntersection",value:function(e){try{return this._clip_by_polygon(e)}catch(e){throw new Error("ConvexPolygon#getIntersection failed")}}},{key:"hasIntersection",value:function(e){try{return null!==this._clip_by_polygon(e)}catch(e){throw new Error("ConvexPolygon#hasIntersection failed")}}},{key:"includes",value:function(e){for(var t=0;t<this._num_vertices;++t)for(var r=0!=t?t-1:this._num_vertices-1,n=this._vertices[2*r],i=this._vertices[2*r+1],o=i-this._vertices[2*t+1],a=this._vertices[2*t]-n,s=n*o+i*a,u=0;u<e._num_vertices;++u){if(e._vertices[2*u]*o+e._vertices[2*u+1]*a<s)return!1}return!0}},{key:"_clip_by_polygon",value:function(e){for(var t=e,r=0;r<this._num_vertices;++r){var n=0!=r?r-1:this._num_vertices-1,i=this._vertices[2*n],o=this._vertices[2*n+1],a=o-this._vertices[2*r+1],s=this._vertices[2*r]-i,u=i*a+o*s;if(null===(t=t._clip_by_halfspace(a,s,u)))break}return t}},{key:"_clip_by_halfspace",value:function(e,t,r){for(var n=Number.MAX_VALUE,i=-Number.MAX_VALUE,o=0;o<this._num_vertices;++o){var a=this._vertices[2*o]*e+this._vertices[2*o+1]*t-r;n=Math.min(n,a),i=Math.max(i,a)}return n>=0?this:i<=0?null:this._clip_by_crossed_halfspace(e,t,r)}},{key:"_clip_by_crossed_halfspace",value:function(t,r,n){var i=$e(this._get_cross_edges_by_crossed_halfspace_boundary(t,r,n),2),o=i[0],a=i[1],s=[];s.push(o.qx),s.push(o.qy);for(var u=o.ei,l=a.ei,_=u;_!=l;_=(_+1)%this._num_vertices)s.push(this._vertices[2*_]),s.push(this._vertices[2*_+1]);return s.push(a.qx),s.push(a.qy),new e(s)}},{key:"_get_cross_edges_by_crossed_halfspace_boundary",value:function(e,t,r){for(var n=new Array(2),i=0,o=0;o<2;++i){if(i==this._num_vertices)throw new Error("cross edges could not be found");var a=(i+1)%this._num_vertices,s=this._vertices[2*i],u=this._vertices[2*i+1],l=this._vertices[2*a],_=this._vertices[2*a+1],c=s*e+u*t-r,h=l*e+_*t-r;if(c<=0&&0<h||h<=0&&0<c){var f=c/(c-h),d=s+(l-s)*f,v=u+(_-u)*f;n[c<h?0:1]={ei:a,qx:d,qy:v},++o}}return n}},{key:"num_vertices",get:function(){return this._num_vertices}},{key:"vertices",get:function(){return this._vertices}}],[{key:"createByRectangle",value:function(t,r,n,i){return new e([t,r,n,r,n,i,t,i])}}]),e}(),Hv=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._extruded_height=0,n._color=cs.createVector3([1,1,1]),n._opacity=1,n._boundaries=[],n._position=null,n.altitude_mode===Tl.CLAMP?(n._producer=new Wv(Ze(n)),n._is_flake_mode=!0):(n._producer=new Xv(Ze(n)),n._is_flake_mode=!1),n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._is_flake_mode?null:this._producer}},{key:"getFlakePrimitiveProducer",value:function(){return this._is_flake_mode?this._producer:null}},{key:"onChangeAltitudeMode",value:function(e){this.altitude_mode===Tl.CLAMP?(this._producer=new Wv(this),this._is_flake_mode=!0):(this._producer=new Xv(this),this._is_flake_mode=!1)}},{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector3");t.addEntry("color",[n],null,(function(t){e.setColor(t)})),t.addEntry("opacity",[r],null,(function(t){e.setOpacity(t)})),t.addEntry("height",[r],null,(function(t){e.setExtrudedHeight(t)}))}},{key:"setColor",value:function(e){this._color[0]===e[0]&&this._color[1]===e[1]&&this._color[2]===e[2]||(cs.copyVector3(e,this._color),this._producer.onChangeProperty())}},{key:"setOpacity",value:function(e){this._opacity!==e&&(this._opacity=e,this._producer.onChangeProperty())}},{key:"setExtrudedHeight",value:function(e){this.extruded_height=e}},{key:"addOuterBoundary",value:function(e){this._addBoundary(e,!1)}},{key:"addInnerBoundary",value:function(e){this._addBoundary(e,!0)}},{key:"_addBoundary",value:function(e,t){this._boundaries.push(new Qv(e,t)),this._position=null,this._producer.onChangeBoundary()}},{key:"_getPolygonMaterial",value:function(){var e=this.scene;return e._PolygonEntity_material||(e._PolygonEntity_material=new Dv(e.glenv)),e._PolygonEntity_material}},{key:"_setupByJson",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,o=e.boundaries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;"inner"==a.type?this.addInnerBoundary(a.points):this.addOuterBoundary(a.points)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}void 0!==e.extruded_height&&(this.extruded_height=e.extruded_height),void 0!==e.color&&cs.copyVector3(e.color,this._color),void 0!==e.opacity&&(this._opacity=e.opacity)}},{key:"_getPosition",value:function(){if(null!==this._position)return this._position;if(0==this._boundaries.length)return null;var e=Number.MAX_VALUE,t=-Number.MAX_VALUE,r=Number.MAX_VALUE,n=-Number.MAX_VALUE,i=!0,o=!1,a=void 0;try{for(var s,u=this._boundaries[Symbol.iterator]();!(i=(s=u.next()).done);i=!0)for(var l=s.value,_=l.num_points,c=l.points,h=0;h<_;++h){var f=c[3*h],d=c[3*h+1];f<e&&(e=f),f>t&&(t=f),d<r&&(r=d),d>n&&(n=d)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}return this._position=new hs((e+t)/2,(r+n)/2),this._position}},{key:"_countNumPointsOnBoundaries",value:function(){var e=0,t=!0,r=!1,n=void 0;try{for(var i,o=this._boundaries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){e+=i.value.num_points}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return e}},{key:"_getCombinedBoundaryPoints",value:function(){var e=new Float64Array(3*this._countNumPointsOnBoundaries()),t=0,r=!0,n=!1,i=void 0;try{for(var o,a=this._boundaries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;e.set(s.points,t),t+=3*s.num_points}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return e}},{key:"_getCombinedBoundary2DPoints",value:function(){var e=new Float64Array(2*this._countNumPointsOnBoundaries()),t=0,r=!0,n=!1,i=void 0;try{for(var o,a=this._boundaries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0)for(var s=o.value,u=3*s.num_points,l=s.points,_=0;_<u;_+=3)e[t++]=l[_],e[t++]=l[_+1]}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return e}},{key:"_createTriangles",value:function(){var e=this._getCombinedBoundary2DPoints(),t=this._countNumPointsOnBoundaries(),r=new Ov(e,0,2,t),n=0,i=!0,o=!1,a=void 0;try{for(var s,u=this._boundaries[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){for(var l=s.value.num_points,_=new Uint32Array(l),c=0;c<l;++c)_[c]=n++;r.addBoundary(_)}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}try{return r.run()}catch(e){return console.error(e.message),null}}},{key:"extruded_height",set:function(e){this._extruded_height!==e&&(this._extruded_height=e,this._producer.onChangeExtruded())},get:function(){return this._extruded_height}}]),t}(Il),Xv=function(e){function t(e){var r;ze(this,t),(r=Je(this,Ye(t).call(this,e)))._status=ay.INVALID,r._triangles=null,r._transform=cs.setIdentity(cs.createMatrix()),r._pivot=cs.createVector3(),r._bbox=[cs.createVector3(),cs.createVector3()],r._properties={color:cs.createVector3f(),opacity:1,lighting:!1};var n=new _l(e.glenv,null,e._getPolygonMaterial(),r._transform);return n.pivot=r._pivot,n.bbox=r._bbox,n.properties=r._properties,r._primitive=n,r}return qe(t,e),je(t,[{key:"needsElevation",value:function(){return this.entity.altitude_mode!==Tl.ABSOLUTE}},{key:"createRegions",value:function(){var e=this.entity;if(this._status===ay.INVALID)return[];var t=new uv,r=!0,n=!1,i=void 0;try{for(var o,a=e._boundaries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;t.addPoints(s.points,0,3,s.num_points)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return t.addPoint(e._getPosition()),[t]}},{key:"onChangeElevation",value:function(e){this._status===ay.NORMAL&&(this._status=ay.MESH_DIRTY)}},{key:"getPrimitives",value:function(e){if(this._status===ay.INVALID)return[];if(this._status===ay.TRIANGLE_DIRTY){if(this._triangles=this.entity._createTriangles(),null===this._triangles)return this._primitive.mesh=null,this._status=ay.INVALID,[];this._updatePrimitiveMesh()}else this._status===ay.MESH_DIRTY&&this._updatePrimitiveMesh();return this._updatePrimitiveProperties(),this._status=ay.NORMAL,[this._primitive]}},{key:"onChangeExtruded",value:function(){this._status===ay.NORMAL&&(this._status=ay.MESH_DIRTY)}},{key:"onChangeProperty",value:function(){}},{key:"onChangeBoundary",value:function(){this._status=ay.TRIANGLE_DIRTY,this._triangles=null,this.needToCreateRegions()}},{key:"_updatePrimitiveMesh",value:function(){var e=new Zv(this.entity);this._updateTransformPivotBBox(e);var t={vtype:[{name:"a_position",size:3},{name:"a_normal",size:3}],vertices:this._createVertices(e),indices:this._createIndices(e)},r=new ml(this.entity.scene.glenv,t);this._primitive.mesh=r}},{key:"_updateTransformPivotBBox",value:function(e){var t=this._transform;t[12]=e.origin[0],t[13]=e.origin[1],t[14]=e.origin[2];var r=Number.MAX_VALUE,n=Number.MAX_VALUE,i=Number.MAX_VALUE,o=-Number.MAX_VALUE,a=-Number.MAX_VALUE,s=-Number.MAX_VALUE,u=[e.upper];e.lower&&u.push(e.lower);for(var l=0;l<u.length;++l)for(var _=u[l],c=0;c<e.num_points;++c){var h=3*c,f=_[h],d=_[h+1],v=_[h+2];f<r&&(r=f),d<n&&(n=d),v<i&&(i=v),f>o&&(o=f),d>a&&(a=d),v>s&&(s=v)}var y=this._pivot;y[0]=(r+o)/2,y[1]=(n+a)/2,y[2]=(i+s)/2;var p=this._bbox,g=p[0],m=p[1];g[0]=r,g[1]=n,g[2]=i,m[0]=o,m[1]=a,m[2]=s}},{key:"_createVertices",value:function(e){for(var t=6*e.num_points,r=e.lower?4*e.num_points*6:0,n=e.lower?t:0,i=new Float32Array(t+r+n),o=cs.normalize3(e.origin,cs.createVector3()),a=0;a<e.num_points;++a){var s=3*a,u=e.upper[s],l=e.upper[s+1],_=e.upper[s+2],c=6*a;i[c]=u,i[c+1]=l,i[c+2]=_,ry(o,i,c+3)}if(e.lower){var h=cs.createVector3(),f=cs.createVector3(),d=cs.createVector3(),v=cs.createVector3(),y=cs.createVector3(),p=0,g=!0,m=!1,k=void 0;try{for(var w,E=this.entity._boundaries[Symbol.iterator]();!(g=(w=E.next()).done);g=!0){for(var b=p+w.value.num_points,x=p;x<b;++x){var A=3*x,T=3*(x+1<b?x+1:p);ty(e.lower,A,h),ty(e.lower,T,f),ty(e.upper,A,d),ty(e.upper,T,v),ny(h,f,d,y);var I=t+24*x;ry(h,i,I),ry(y,i,I+3),ry(f,i,I+=6),ry(y,i,I+3),ry(d,i,I+=6),ry(y,i,I+3),ry(v,i,I+=6),ry(y,i,I+3)}p=b}}catch(e){m=!0,k=e}finally{try{g||null==E.return||E.return()}finally{if(m)throw k}}}if(e.lower)for(var P=cs.scale3(-1,o,cs.createVector3()),L=0;L<e.num_points;++L){var M=3*L,S=e.lower[M],R=e.lower[M+1],C=e.lower[M+2],D=t+r+6*L;i[D]=S,i[D+1]=R,i[D+2]=C,ry(P,i,D+3)}return i}},{key:"_createIndices",value:function(e){var t=this._triangles.length/3,r=e.lower?2*e.num_points:0,n=e.lower?t:0,i=new Uint32Array(3*(t+r+n));if(i.set(this._triangles),e.lower)for(var o=e.num_points,a=3*t,s=e.num_points,u=0;u<o;++u,a+=6,s+=4)i[a]=s,i[a+1]=s+1,i[a+2]=s+2,i[a+3]=s+2,i[a+4]=s+1,i[a+5]=s+3;if(e.lower)for(var l=this._triangles.length/3,_=e.num_points+4*e.num_points,c=0;c<l;++c)i[3*(t+r+c)+0]=this._triangles[3*c+0]+_,i[3*(t+r+c)+1]=this._triangles[3*c+2]+_,i[3*(t+r+c)+2]=this._triangles[3*c+1]+_;return i}},{key:"_updatePrimitiveProperties",value:function(){var e=this.entity,t=this._properties;cs.copyVector3(e._color,t.color),t.opacity=e._opacity,t.lighting=0!==this.extruded_height}}]),t}(Il.PrimitiveProducer),Wv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e)))._material=e._getPolygonMaterial(),r._properties=null,r._area_manager=new Jv(e),r}return qe(t,e),je(t,[{key:"getAreaStatus",value:function(e){return this._area_manager.getAreaStatus(e)}},{key:"createMesh",value:function(e,t,r){var n=this._area_manager.getAreaContent(e),i=Math.PI*Math.pow(2,1-e.z),o=e.x*i-Math.PI,a=Math.PI-(e.y+1)*i,s=1<<t[0],u=1<<t[1],l=this._createSubmeshes(o,a,o+i,a+i,s,u,n),_={vtype:[{name:"a_position",size:3},{name:"a_normal",size:3}],vertices:this._createVertices(l,e,r),indices:this._createIndices(l)};return new ml(this.entity.scene.glenv,_)}},{key:"getMaterialAndProperties",value:function(e){if(null===this._properties){var t=this.entity;this._properties={color:cs.createVector3f(t._color),opacity:t._opacity,lighting:!1}}return{material:this._material,properties:this._properties}}},{key:"onChangeExtruded",value:function(){}},{key:"onChangeProperty",value:function(){this._properties=null}},{key:"onChangeBoundary",value:function(){this._area_manager.notifyForUpdateContent(),this.notifyForUpdate()}},{key:"_createVertices",value:function(e,t,r){var n=ul.getCenter(t,cs.createVector3()),i=r.newSampler(t),o=0,a=!0,s=!1,u=void 0;try{for(var l,_=e[Symbol.iterator]();!(a=(l=_.next()).done);a=!0){o+=l.value.getNumVertices()}}catch(e){s=!0,u=e}finally{try{a||null==_.return||_.return()}finally{if(s)throw u}}var c=new Float32Array(6*o),h=0,f=!0,d=!1,v=void 0;try{for(var y,p=e[Symbol.iterator]();!(f=(y=p.next()).done);f=!0){h=y.value.addVertices(n,i,c,h)}}catch(e){d=!0,v=e}finally{try{f||null==p.return||p.return()}finally{if(d)throw v}}return c}},{key:"_createIndices",value:function(e){var t=0,r=!0,n=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){t+=o.value.getNumTriangles()}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}var s=new Uint32Array(3*t),u=0,l=0,_=!0,c=!1,h=void 0;try{for(var f,d=e[Symbol.iterator]();!(_=(f=d.next()).done);_=!0){var v=f.value;l=v.addIndices(u,s,l),u+=v.getNumVertices()}}catch(e){c=!0,h=e}finally{try{_||null==d.return||d.return()}finally{if(c)throw h}}return s}},{key:"_createSubmeshes",value:function(e,t,r,n,i,o,a){if(a===Il.AreaStatus.FULL)return[new $v(e,t,r,n,i,o)];if(0==a.length)return[];if(1==i&&1==o){var s=[e,t,r,t,e,n],u=[e,n,r,t,r,n],l=this._create_clipped_polygons_submeshes(s,a),_=this._create_clipped_polygons_submeshes(u,a);return l.concat(_)}if(i>=o){var c=(r-e)/2,h=i/2,f=this._create_submeshes_sp(e,t,e+c,n,h,o,a),d=this._create_submeshes_sp(e+c,t,r,n,h,o,a);return f.concat(d)}var v=(n-t)/2,y=o/2,p=this._create_submeshes_sp(e,t,r,t+v,i,y,a),g=this._create_submeshes_sp(e,t+v,r,n,i,y,a);return p.concat(g)}},{key:"_create_submeshes_sp",value:function(e,t,r,n,i,o,a){var s=Yv.createByRectangle(e,t,r,n),u=[],l=!0,_=!1,c=void 0;try{for(var h,f=a[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var d=h.value;if(d.includes(s)){u=Il.AreaStatus.FULL;break}try{s.hasIntersection(d)&&u.push(d)}catch(e){}}}catch(e){_=!0,c=e}finally{try{l||null==f.return||f.return()}finally{if(_)throw c}}return this._createSubmeshes(e,t,r,n,i,o,u)}},{key:"_create_clipped_polygons_submeshes",value:function(e,t){var r=new Yv(e),n=[],i=!0,o=!1,a=void 0;try{for(var s,u=t[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;try{var _=r.getIntersection(l);null!==_&&n.push(_)}catch(e){}}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}return n.length>0?[new ey(e,n)]:[]}}]),t}(Il.FlakePrimitiveProducer),Qv=function(){function e(t,r){ze(this,e);var n=Math.floor(t.length/3);this._points=new Float64Array(3*n),this._num_points=n;var i,o,a=e.isCCW(t,n);!r&&a||r&&!a?(i=0,o=3):(i=3*(n-1),o=-3);for(var s=0;s<n;++s)this._points[3*s]=t[i],this._points[3*s+1]=t[i+1],this._points[3*s+2]=t[i+2],i+=o}return je(e,[{key:"points",get:function(){return this._points}},{key:"num_points",get:function(){return this._num_points}}],[{key:"isCCW",value:function(e,t){for(var r,n=-Number.MAX_VALUE,i=-Number.MAX_VALUE,o=0;o<t;++o){var a=e[3*o],s=e[3*o+1];(s>i||s==i&&a<n)&&(r=o,n=a,i=s)}var u=r==t-1?0:r+1,l=e[3*u],_=e[3*u+1],c=0==r?t-1:r-1,h=e[3*c];return(l-n)*(e[3*c+1]-i)-(h-n)*(_-i)>0}}]),e}(),Zv=function e(t){ze(this,e);var r=t.scene.viewer,n=t.altitude_mode,i=t._getCombinedBoundaryPoints(),o=t._countNumPointsOnBoundaries(),a=Float64Array.from(i);if(n===Tl.RELATIVE)for(var s=r.getExistingElevation(t._getPosition()),u=0;u<o;++u){a[3*u+2]+=s}var l=null,_=null;if(0!==t._extruded_height)if(n===Tl.CLAMP){l=a,_=Float64Array.from(i);for(var c=0;c<o;++c){_[3*c+2]=0}}else{_=a,l=Float64Array.from(i);for(var h=0;h<o;++h){var f=3*h+2;l[f]=_[f]+t._extruded_height}}else l=a;for(var d=t._getPosition().getAsGocs(cs.createVector3()),v=hs.toGocsArray(l,o,new Float64Array(3*o)),y=0;y<o;++y){var p=3*y;v[p]-=d[0],v[p+1]-=d[1],v[p+2]-=d[2]}var g=null;if(_){g=hs.toGocsArray(_,o,new Float64Array(3*o));for(var m=0;m<o;++m){var k=3*m;g[k]-=d[0],g[k+1]-=d[1],g[k+2]-=d[2]}}this.origin=d,this.num_points=o,this.upper=v,this.lower=g},Jv=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this)))._entity=e,r}return qe(t,e),je(t,[{key:"getInitialContent",value:function(){for(var e=this._entity._createTriangles()||[],t=e.length,r=this._entity._getCombinedBoundary2DPoints(),n=[],i=0;i<t;i+=3){var o=e[i],a=e[i+1],s=e[i+2];this._add_polygon_to_array(r,o,a,s,n)}return n}},{key:"createAreaContent",value:function(e,t,r,n){var i=Math.PI*e,o=Math.PI*t,a=Math.PI*(e+r),s=Math.PI*(t+r),u=Yv.createByRectangle(i,o,a,s),l=[],_=!0,c=!1,h=void 0;try{for(var f,d=n[Symbol.iterator]();!(_=(f=d.next()).done);_=!0){var v=f.value;if(v.includes(u))return Il.AreaStatus.FULL;try{u.hasIntersection(v)&&l.push(v)}catch(e){}}}catch(e){c=!0,h=e}finally{try{_||null==d.return||d.return()}finally{if(c)throw h}}return l.length>0?l:Il.AreaStatus.EMPTY}},{key:"_add_polygon_to_array",value:function(e,t,r,n,i){for(var o=cs.DEGREE,a=Math.PI/2,s=2*Math.PI,u=[],l=Number.MAX_VALUE,_=0,c=[t,r,n];_<c.length;_++){var h=c[_],f=e[2*h]*o,d=e[2*h+1]*o;if(Math.abs(d)>=a)return;var v=f,y=cs.invGudermannian(d);u.push(v),u.push(y),l=Math.min(v,l)}var p=l-s*(Math.floor((l-Math.PI)/s)+1);(p<-Math.PI||p>=Math.PI)&&(p=-Math.PI);for(var g=-Number.MAX_VALUE,m=0;m<3;++m){var k=2*m,w=p+(u[k]-l);u[k]=w,g=Math.max(w,g)}if(i.push(new Yv(u)),g>Math.PI){for(var E=0;E<3;++E){var b=2*E,x=u[b]-s;u[b]=x}i.push(new Yv(u))}}}]),t}(hv),Kv=function(){function e(){ze(this,e)}return je(e,[{key:"getNumVertices",value:function(){throw""}},{key:"getNumTriangles",value:function(){throw""}},{key:"addVertices",value:function(e,t,r,n){throw""}},{key:"addIndices",value:function(e,t,r){throw""}}]),e}(),$v=function(e){function t(e,r,n,i,o,a){var s;return ze(this,t),(s=Je(this,Ye(t).call(this)))._x_min=e,s._y_min=r,s._x_max=n,s._y_max=i,s._div_x=o,s._div_y=a,s}return qe(t,e),je(t,[{key:"getNumVertices",value:function(){return(this._div_x+1)*(this._div_y+1)}},{key:"getNumTriangles",value:function(){return 2*this._div_x*this._div_y}},{key:"addVertices",value:function(e,t,r,n){for(var i=(this._x_max-this._x_min)/this._div_x,o=(this._y_max-this._y_min)/this._div_y,a=this._div_x+1,s=this._div_y+1,u=n,l=0,_=this._y_min;l<s;++l,_+=o)for(var c=Math.exp(_),h=c*c,f=(h-1)/(h+1),d=2*c/(h+1),v=0,y=this._x_min;v<a;++v,y+=i){var p=Math.sin(y),g=Math.cos(y),m=t.sample(y,_),k=cs.EARTH_RADIUS+m,w=d*g,E=d*p,b=f,x=k*w,A=k*E,T=k*b;r[u++]=x-e[0],r[u++]=A-e[1],r[u++]=T-e[2],r[u++]=w,r[u++]=E,r[u++]=b}return u}},{key:"addIndices",value:function(e,t,r){for(var n=this._div_x,i=this._div_y,o=r,a=0;a<i;++a)for(var s=0;s<n;++s){var u=e+(n+1)*a+s,l=u+1,_=u+n+1,c=_+1;t[o++]=u,t[o++]=l,t[o++]=_,t[o++]=_,t[o++]=l,t[o++]=c}return o}}]),t}(Kv),ey=function(e){function t(e,r){var n;ze(this,t),(n=Je(this,Ye(t).call(this)))._arit_coords=e,n._polygons=r,n._num_vertices=0,n._num_triangles=0;var i=!0,o=!1,a=void 0;try{for(var s,u=r[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;n._num_vertices+=l.num_vertices,n._num_triangles+=l.num_vertices-2}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}return n}return qe(t,e),je(t,[{key:"getNumVertices",value:function(){return this._num_vertices}},{key:"getNumTriangles",value:function(){return this._num_triangles}},{key:"addVertices",value:function(e,t,r,n){var i=this._get_elevation_plane(t),o=n,a=!0,s=!1,u=void 0;try{for(var l,_=this._polygons[Symbol.iterator]();!(a=(l=_.next()).done);a=!0){var c=l.value;o=this._add_polygon_vertices(c,i,e,r,o)}}catch(e){s=!0,u=e}finally{try{a||null==_.return||_.return()}finally{if(s)throw u}}return o}},{key:"addIndices",value:function(e,t,r){var n=r,i=e,o=!0,a=!1,s=void 0;try{for(var u,l=this._polygons[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var _=u.value;n=this._add_polygon_indices(_,i,t,n),i+=_.num_vertices}}catch(e){a=!0,s=e}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}return n}},{key:"_add_polygon_vertices",value:function(e,t,r,n,i){for(var o=i,a=e.num_vertices,s=e.vertices,u=0;u<a;++u){var l=s[2*u],_=s[2*u+1],c=Math.exp(_),h=c*c,f=Math.sin(l),d=Math.cos(l),v=(h-1)/(h+1),y=2*c/(h+1),p=-(l*t[0]+_*t[1]+t[3])/t[2],g=cs.EARTH_RADIUS+p,m=y*d,k=y*f,w=v,E=g*m,b=g*k,x=g*w;n[o++]=E-r[0],n[o++]=b-r[1],n[o++]=x-r[2],n[o++]=m,n[o++]=k,n[o++]=w}return o}},{key:"_add_polygon_indices",value:function(e,t,r,n){for(var i=n,o=e.num_vertices-2,a=1;a<=o;++a)r[i++]=t,r[i++]=t+a,r[i++]=t+a+1;return i}},{key:"_get_elevation_plane",value:function(e){for(var t=this._arit_coords,r=new Array(3),n=0;n<3;++n){var i=t[2*n],o=t[2*n+1];r[n]=e.sample(i,o)}var a=t[0],s=t[1],u=r[0],l=t[2]-a,_=t[3]-s,c=r[1]-u,h=t[4]-a,f=t[5]-s,d=r[2]-u,v=_*d-c*f,y=c*h-l*d,p=l*f-_*h;return[v,y,p,-a*v-s*y-u*p]}}]),t}(Kv);function ty(e,t,r){r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2]}function ry(e,t,r){t[r]=e[0],t[r+1]=e[1],t[r+2]=e[2]}function ny(e,t,r,n){for(var i=0;i<3;++i)iy[i]=t[i]-e[i],oy[i]=r[i]-e[i];return cs.cross3(iy,oy,n),cs.normalize3(n,n),n}var iy=cs.createVector3(),oy=cs.createVector3(),ay={INVALID:{id:"INVALID"},NORMAL:{id:"NORMAL"},TRIANGLE_DIRTY:{id:"TRIANGLE_DIRTY"},MESH_DIRTY:{id:"MESH_DIRTY"}};Ho("Int8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var sy=function(){function e(t,r){ze(this,e);var n=t.gjson.bufferViews[r];this._buffer=t.findBuffer(n.buffer),this._byteLength=n.byteLength,this._target=n.target,this._byteOffset=void 0!==n.byteOffset?n.byteOffset:0,this._byteStride=void 0!==n.byteStride?n.byteStride:0}return je(e,[{key:"rebuildBySplitter",value:function(e){this._buffer=e,this._byteLength=e.byteLength,this._byteOffset=0}},{key:"buffer",get:function(){return this._buffer}},{key:"byteOffset",get:function(){return this._byteOffset}},{key:"byteStride",get:function(){return this._byteStride}}]),e}(),uy=function(){function e(t,r){ze(this,e);var n=t.gjson.accessors[r];this._type=n.type,this._componentType=n.componentType,this._count=n.count,this._bufferView=new sy(t,n.bufferView),this._byteOffset=void 0!==n.byteOffset?n.byteOffset:0,this._normalized=n.normalized||!1,this._min=n.min?n.min.slice():null,this._max=n.max?n.max.slice():null,this._index=r}return je(e,[{key:"getRangeInBuffer",value:function(){var t=this._bufferView,r=e._ComponentData[this._componentType].bytes*e._NumComponents[this._type],n=0==t.byteStride?r:t.byteStride,i=this._byteOffset+t.byteOffset;return{first:i,last:i+n*(this._count-1)+r}}},{key:"modifyByteOrder",value:function(t){var r=e._ComponentData[this._componentType],n=r.bytes;if(1!=n)for(var i=e._NumComponents[this._type],o=this._byteOffset+this._bufferView.byteOffset,a=0==this._bufferView.byteStride?i:this._bufferView.byteStride/n,s=this._bufferView.buffer.binary,u=new DataView(s,o),l=new r.typedarray(s,o),_=r.getcompo,c=n/2,h=o/2,f=a*c,d=0;d<this._count;++d)for(var v=h+d*f,y=d*a,p=0;p<i;++p){var g=v+p*c;if(!t.getBit(g)){var m=y+p,k=_.call(u,m*n,!0);l[m]=k,t.setBit(g,!0)}}}},{key:"isIncluded",value:function(e,t){var r=this._byteOffset+this._bufferView.byteOffset;return e<=r&&r<t}},{key:"rebuildBySplitter",value:function(e,t){this._index=-1;var r=this._byteOffset+this._bufferView.byteOffset;this._byteOffset=r-t,this._bufferView.rebuildBySplitter(e)}},{key:"index",get:function(){return this._index}},{key:"bufferView",get:function(){return this._bufferView}},{key:"type",get:function(){return this._type}},{key:"componentType",get:function(){return this._componentType}},{key:"count",get:function(){return this._count}},{key:"byteOffset",get:function(){return this._byteOffset}},{key:"normalized",get:function(){return this._normalized}},{key:"min",get:function(){return this._min}},{key:"max",get:function(){return this._max}}]),e}();uy._NumComponents={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uy._ComponentData={5120:{bytes:1,getcompo:DataView.prototype.getInt8,typedarray:Int8Array},5121:{bytes:1,getcompo:DataView.prototype.getUint8,typedarray:Uint8Array},5122:{bytes:2,getcompo:DataView.prototype.getInt16,typedarray:Int16Array},5123:{bytes:2,getcompo:DataView.prototype.getUint16,typedarray:Uint16Array},5125:{bytes:4,getcompo:DataView.prototype.getUint32,typedarray:Uint32Array},5126:{bytes:4,getcompo:DataView.prototype.getFloat32,typedarray:Float32Array}};var ly=function(){function e(t,r){ze(this,e);var n=t.gjson.materials[r];this._commonData=new Hd(n,t),this._pbrMetallicRoughness={baseColorFactor:[1,1,1,1],baseColorTexture:null,metallicFactor:1,roughnessFactor:1,metallicRoughnessTexture:null},this._doubleSided=!1,this._alphaMode="OPAQUE",this._alphaCutoff=.5,this._emissiveFactor=[0,0,0],this._emissiveTexture=null,this._normalTexture=null,this._occlusionTexture=null,this._setupPbrMetallicRoughness(n,t),this._setupGenericParameters(n,t)}return je(e,[{key:"_setupPbrMetallicRoughness",value:function(e,t){if(void 0!==e.pbrMetallicRoughness){var r=e.pbrMetallicRoughness,n=this._pbrMetallicRoughness;void 0!==r.baseColorFactor&&(n.baseColorFactor=r.baseColorFactor.slice()),void 0!==r.baseColorTexture&&(n.baseColorTexture=new tv(r.baseColorTexture,t),t.addTextureInfo(n.baseColorTexture)),void 0!==r.metallicFactor&&(n.metallicFactor=r.metallicFactor),void 0!==r.roughnessFactor&&(n.roughnessFactor=r.roughnessFactor),void 0!==r.metallicRoughnessTexture&&(n.metallicRoughnessTexture=new tv(r.metallicRoughnessTexture,t),t.addTextureInfo(n.metallicRoughnessTexture))}}},{key:"_setupGenericParameters",value:function(e,t){void 0!==e.doubleSided&&(this._doubleSided=e.doubleSided),void 0!==e.alphaMode&&(this._alphaMode=e.alphaMode),void 0!==e.alphaCutoff&&(this._alphaCutoff=e.alphaCutoff),void 0!==e.emissiveFactor&&(this._emissiveFactor=e.emissiveFactor.slice()),void 0!==e.emissiveTexture&&(this._emissiveTexture=new tv(e.emissiveTexture,t),t.addTextureInfo(this._emissiveTexture)),void 0!==e.normalTexture&&(this._normalTexture=new rv(e.normalTexture,t),t.addTextureInfo(this._normalTexture)),void 0!==e.occlusionTexture&&(this._occlusionTexture=new nv(e.occlusionTexture,t),t.addTextureInfo(this._occlusionTexture))}},{key:"commonData",get:function(){return this._commonData}},{key:"pbrMetallicRoughness",get:function(){return this._pbrMetallicRoughness}},{key:"doubleSided",get:function(){return this._doubleSided}},{key:"alphaMode",get:function(){return this._alphaMode}},{key:"alphaCutoff",get:function(){return this._alphaCutoff}},{key:"emissiveFactor",get:function(){return this._emissiveFactor}},{key:"emissiveTexture",get:function(){return this._emissiveTexture}},{key:"normalTexture",get:function(){return this._normalTexture}},{key:"occlusionTexture",get:function(){return this._occlusionTexture}}]),e}(),_y=function(){function e(t,r){ze(this,e),this._mode=void 0!==t.mode?t.mode:4,this._attributes={},this._indices=null,this._material=null,this._setupAttributes(t.attributes,r),this._setupIndices(t,r),this._setupMaterial(t,r)}return je(e,[{key:"_setupAttributes",value:function(e,t){for(var r in e){var n=new uy(t,e[r]);this._attributes[r]=n,t.addAccessor(n,"ATTRIBUTE")}}},{key:"_setupIndices",value:function(e,t){if(void 0!==e.indices){var r=new uy(t,e.indices);this._indices=r,t.addAccessor(r,"INDEX")}}},{key:"_setupMaterial",value:function(e,t){void 0!==e.material&&(this._material=new ly(t,e.material))}},{key:"mode",get:function(){return this._mode}},{key:"attributes",get:function(){return this._attributes}},{key:"indices",get:function(){return this._indices}},{key:"material",get:function(){return this._material}}]),e}(),cy=function(){function e(t,r){ze(this,e),this._primitives=[];for(var n=t.gjson.meshes[r].primitives,i=0;i<n.length;++i){var o=n[i];this._primitives.push(new _y(o,t))}}return je(e,[{key:"primitives",get:function(){return this._primitives}}]),e}(),hy=function(){function e(t,r){ze(this,e);var n=t.gjson.nodes[r];this._commonData=new Hd(n,t),this._children=[],this._matrix=null,this._mesh=null,this._setupChildren(n,t),this._setupMatrix(n),this._setupMesh(n,t)}return je(e,[{key:"_setupChildren",value:function(t,r){var n=t.children;if(void 0!==n)for(var i=0;i<n.length;++i){var o=n[i];this._children.push(new e(r,o))}}},{key:"_setupMatrix",value:function(e){if(e.matrix)this._matrix=cs.createMatrix(e.matrix);else if(e.scale||e.rotation||e.translation){var t=$e(e.scale||[1,1,1],3),r=t[0],n=t[1],i=t[2],o=$e(e.rotation||[0,0,0,1],4),a=o[0],s=o[1],u=o[2],l=o[3],_=$e(e.translation||[0,0,0],3),c=_[0],h=_[1],f=_[2];this._matrix=cs.createMatrix([(1-2*(s*s+u*u))*r,2*(a*s+u*l)*r,2*(a*u-s*l)*r,0,2*(a*s-u*l)*n,(1-2*(a*a+u*u))*n,2*(a*l+s*u)*n,0,2*(s*l+a*u)*i,2*(s*u-a*l)*i,(1-2*(a*a+s*s))*i,0,c,h,f,1])}}},{key:"_setupMesh",value:function(e,t){var r=e.mesh;void 0!==r&&(this._mesh=new cy(t,r))}},{key:"commonData",get:function(){return this._commonData}},{key:"children",get:function(){return this._children}},{key:"matrix",get:function(){return this._matrix}},{key:"mesh",get:function(){return this._mesh}}]),e}(),fy=function(){function e(t,r){ze(this,e);var n=t.gjson.scenes[r];this._commonData=new Hd(n,t),this._root_nodes=[];var i=!0,o=!1,a=void 0;try{for(var s,u=(n.nodes||[])[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;this._root_nodes.push(new hy(t,l))}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}}return je(e,[{key:"commonData",get:function(){return this._commonData}},{key:"root_nodes",get:function(){return this._root_nodes}},{key:"name",get:function(){return this._commonData.getName()}}]),e}(),dy=function(){function e(){ze(this,e);var t=new vy(-2,-1),r=new vy(Math.pow(2,32)+1,Math.pow(2,32)+2);t.next=r,r.prev=t,this._fragments=t}return je(e,[{key:"update",value:function(t){var r=t.getRangeInBuffer();this._updateByRange({first:e._floor4(r.first),last:r.last})}},{key:"close",value:function(e){this._fragments=this._fragments.next;for(var t=this._fragments;;t=t.next){if(null===t.next){t.prev.next=null;break}t.buffer=e.createSubBuffer(t.first,t.last)}}},{key:"rebuildAccessor",value:function(e){for(var t=this._fragments;null!==t;t=t.next)if(e.isIncluded(t.first,t.last)){e.rebuildBySplitter(t.buffer,t.first);break}}},{key:"_updateByRange",value:function(e){for(var t=this._fragments;null!==t.next;){if(t.isInside(e)){var r=t,n=t.next,i=new vy(e.first,e.last);r.next=i,n.prev=i,i.prev=r,i.next=n;break}if(t.isTouch(e)){var o=t.prev,a=t.next;o.next=a,a.prev=o,e=t.mergeRange(e),t=o}else t=t.next}}}],[{key:"_floor4",value:function(e){return 4*Math.floor(e/4)}}]),e}(),vy=function(){function e(t,r){ze(this,e),this.first=t,this.last=r,this.buffer=null,this.prev=null,this.next=null}return je(e,[{key:"isInside",value:function(e){return this.last<e.first&&e.last<this.next.first}},{key:"isTouch",value:function(e){return this.last>=e.first&&e.last>=this.first}},{key:"mergeRange",value:function(e){return{first:Math.min(this.first,e.first),last:Math.max(this.last,e.last)}}}]),e}(),yy=function(){function e(t){ze(this,e),this._length=t,this._array=new Uint32Array(Math.ceil(t/32))}return je(e,[{key:"setBit",value:function(e,t){var r=Math.floor(e/32),n=this._array[r],i=1<<e%32;this._array[r]=t?n|i:n&~i}},{key:"getBit",value:function(e){var t=Math.floor(e/32);return 0!=(this._array[t]&1<<e%32)}},{key:"length",get:function(){return this._length}}]),e}(),py=function(){function e(t){ze(this,e),this._buffer=t,this._attrib_accessors=[],this._index_accessors=[]}return je(e,[{key:"addAttributeAccessor",value:function(e){this._attrib_accessors.push(e)}},{key:"addIndexAccessor",value:function(e){this._index_accessors.push(e)}},{key:"rewriteByteOrder",value:function(){var e=new yy(Math.ceil(this._buffer.byteLength/2)),t=!0,r=!1,n=void 0;try{for(var i,o=this._getUnitedOriginalAccessors()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){i.value.modifyByteOrder(e)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"splitBufferAndRebuildAccessors",value:function(){this._splitBufferAndRebuildAccessors(this._attrib_accessors),this._splitBufferAndRebuildAccessors(this._index_accessors)}},{key:"_splitBufferAndRebuildAccessors",value:function(t){var r=new dy,n=!0,i=!1,o=void 0;try{for(var a,s=e._getOriginalAccessors(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;r.update(u)}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}r.close(this._buffer);var l=!0,_=!1,c=void 0;try{for(var h,f=t[Symbol.iterator]();!(l=(h=f.next()).done);l=!0){var d=h.value;r.rebuildAccessor(d)}}catch(e){_=!0,c=e}finally{try{l||null==f.return||f.return()}finally{if(_)throw c}}}},{key:"_getUnitedOriginalAccessors",value:function(){return e._getOriginalAccessors(this._attrib_accessors.concat(this._index_accessors))}},{key:"buffer",get:function(){return this._buffer}}],[{key:"_getOriginalAccessors",value:function(e){var t=new Map,r=!0,n=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value,u=s.index;t.has(u)||t.set(u,s)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return t.values()}}]),e}(),gy=function(){function e(t){ze(this,e),this._image=t,this._texinfo_objects=[]}return je(e,[{key:"addTextureInfo",value:function(e){this._texinfo_objects.push(e)}},{key:"rebuildTextureInfo",value:function(){var e=this._texinfo_objects;if(!(e.length<=1))for(var t=e[0].texture,r=1;r<e.length;++r)e[r].texture=t}},{key:"image",get:function(){return this._image}}]),e}(),my=function(){function e(t,r){var n=this;if(ze(this,e),void 0===t)this._index=-1,this._byteLength=0,this._uri=null,this._binary=null;else{this._index=r;var i=t.gjson.buffers[r];this._byteLength=i.byteLength,void 0!==i.uri?(t.onStartLoadBuffer(),t.loadBinary(i.uri).then((function(e){n._binary=e,t.onFinishLoadBuffer()})).catch((function(e){console.error(e),t.onFinishLoadBuffer(e)}))):(this._uri=null,this._binary=null)}}return je(e,[{key:"createSubBuffer",value:function(t,r){var n=new e;return n._byteLength=r-t,n._binary=this._binary.slice(t,r),n}},{key:"index",get:function(){return this._index}},{key:"binary",get:function(){return this._binary}},{key:"byteLength",get:function(){return this._byteLength}}]),e}(),ky=function(){function e(t,r){var n=this;ze(this,e),this._index=r;var i=t.gjson.images[r];void 0!==i.uri?(t.onStartLoadImage(),t.loadImage(i.uri).then((function(e){n._image=e,t.onFinishLoadImage()})).catch((function(e){t.onFinishLoadImage(e)}))):void 0!==i.bufferView&&(this._bufferView=new sy(t,i.bufferView)),this._mimeType=i.mimeType,this._image=null}return je(e,[{key:"index",get:function(){return this._index}},{key:"image",get:function(){return this._image}}]),e}(),wy=function(){function e(t,r){ze(this,e);var n=r||{};this._gjson=t,this._base_resource=n.base_resource,this._binary_type=n.binary_type,this._image_type=n.image_type,this._supported_extensions=n.supported_extensions||[],this._resolve=null,this._reject=null,this._used_extensions=new Set,this._scenes=[],this._default_scene_index=-1,this._buffer_entries=[],this._image_entries=[],this._body_finished=!1,this._load_count=0,this._load_error=null,this._settled=!1}return je(e,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._resolve=t,e._reject=r,e._loadVersion().major<2)r(new Error("glTF version error"));else{var n=e._getSupportedExtensionNames(),i=!0,o=!1,a=void 0;try{for(var s,u=e._enumRequiredExtensionNames()[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;if(!n.has(l))return void r(new Error("glTF extension error: "+l))}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}e._loadExtensionsUsed(),e._loadScenes(),e._loadDefaultSceneIndex(),e._onFinishLoadBody()}}))}},{key:"_loadVersion",value:function(){var e=this._gjson.asset.version,t=/^(\d+)\.(\d+)/.exec(e);return{major:Number(t[1]),minor:Number(t[2])}}},{key:"_enumRequiredExtensionNames",value:function(){return this._gjson.extensionsRequired||[]}},{key:"_getSupportedExtensionNames",value:function(){var e=this._supported_extensions;return new Set([].concat(e))}},{key:"_loadExtensionsUsed",value:function(){this._used_extensions=new Set(this._gjson.extensionsUsed||[])}},{key:"_loadScenes",value:function(){for(var e=(this._gjson.scenes||[]).length,t=[],r=0;r<e;++r)t.push(new fy(this,r));this._scenes=t}},{key:"_loadDefaultSceneIndex",value:function(){"number"==typeof this._gjson.scene&&(this._default_scene_index=this._gjson.scene)}},{key:"extractUsedExtensions",value:function(e){var t={};for(var r in e)this._used_extensions.has(r)&&(t[r]=e[r]);return t}},{key:"loadBinary",value:function(e){return this._base_resource.loadSubResource(e,{type:this._binary_type})}},{key:"loadImage",value:function(e){return this._base_resource.loadSubResource(e,{type:this._image_type})}},{key:"findBuffer",value:function(e){return void 0===this._buffer_entries[e]&&(this._buffer_entries[e]=new py(new my(this,e))),this._buffer_entries[e].buffer}},{key:"findImage",value:function(e){return void 0===this._image_entries[e]&&(this._image_entries[e]=new gy(new ky(this,e))),this._image_entries[e].image}},{key:"addAccessor",value:function(e,t){var r=this._buffer_entries[e.bufferView.buffer.index];switch(t){case"ATTRIBUTE":r.addAttributeAccessor(e);break;case"INDEX":r.addIndexAccessor(e)}}},{key:"addTextureInfo",value:function(e){var t=e.texture.source;this._image_entries[t.index].addTextureInfo(e)}},{key:"onStartLoadBuffer",value:function(){this._load_count+=1}},{key:"onFinishLoadBuffer",value:function(e){e&&(this._load_error=e),this._load_count-=1,this._onFinishLoadSomething()}},{key:"onStartLoadImage",value:function(){this._load_count+=1}},{key:"onFinishLoadImage",value:function(e){e&&(this._load_error=e),this._load_count-=1,this._onFinishLoadSomething()}},{key:"_onFinishLoadBody",value:function(){this._body_finished=!0,this._onFinishLoadSomething()}},{key:"_onFinishLoadSomething",value:function(){this._settled||(null!==this._load_error?(this._reject(this._load_error),this._settled=!0):this._body_finished&&0==this._load_count&&(this._rewriteBuffersForByteOrder(),this._splitBuffersAndRebuildAccessors(),this._rebuildTextureInfo(),this._resolve(new Xd(this,this._scenes,this._default_scene_index)),this._settled=!0))}},{key:"_rewriteBuffersForByteOrder",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._buffer_entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var o=n.value;void 0!==o&&o.rewriteByteOrder()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"_splitBuffersAndRebuildAccessors",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._buffer_entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var o=n.value;void 0!==o&&o.splitBufferAndRebuildAccessors()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"_rebuildTextureInfo",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._image_entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var o=n.value;void 0!==o&&o.rebuildTextureInfo()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"gjson",get:function(){return this._gjson}}]),e}(),Ey=function(){function e(){ze(this,e)}return je(e,null,[{key:"load",value:function(e,t){return new wy(e,t).load()}}]),e}(),by=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(ze(this,t),r instanceof Bd);else{if("string"!=typeof r)throw new Error("Unsupported Resource: "+r);r=new Gd(r,{type:"json",transform:i.transform})}return(n=Je(this,Ye(t).call(this,e,r,{onLoad:i.callback})))._glenv=e.glenv,n._references={},n._finished=!1,n}return qe(t,e),je(t,[{key:"getReference",value:function(e){var t=this._references[e];return void 0!==t?t:null}},{key:"_setReference",value:function(e,t){this._references[e]=t}},{key:"_load",value:function(){var e=this;return this._resource.load({type:zd.JSON}).then((function(t){return e._check_cancel(),e._load_object(t)}))}},{key:"_load_object",value:function(e){var t=this;return Promise.resolve().then((function(){return t._load_model_register(e)})).then((function(){return t._postload_object(e)}))}},{key:"_postload_object",value:function(e){this.status===qd.Status.LOADING&&this._load_entity_list(e)}},{key:"_load_model_register",value:function(e){var t=e.model_register;if(t){for(var r=Object.keys(t),n=[],i=0;i<r.length;++i){var o=r[i],a=t[o];n.push(this._load_model_container(e,o,a))}return Promise.all(n)}}},{key:"_load_model_container",value:function(e,r,n){var i=this,o=n.link;if(!this._resource.resolveResourceSupported())return Promise.reject(new Error("Sub Resource is not supported"));var a=this._resource.resolveResource(o);return a.load({type:zd.JSON}).then((function(e){return i._check_cancel(),Ey.load(e,{base_resource:a,binary_type:zd.BINARY,image_type:zd.IMAGE,supported_extensions:iv.getSupportedExtensions_glTF()})})).then((function(e){var o=new iv(i._scene,e);if(n.offset_transform){var a=t.parseOffsetTransform(n.offset_transform);o.setOffsetTransform(a)}i._setReference(r,o)}))}},{key:"_load_entity_list",value:function(e){var t=e.entity_list;if(t)for(var r=this._scene,n=0;n<t.length;++n){var i=t[n],o=i.type,a=null;switch(o){case"markerline":a=new kv(r,{json:i,refs:this._references});break;case"path":a=new wv(r,{json:i,refs:this._references});break;case"text":a=new Av(r,{json:i,refs:this._references});break;case"model":a=new Sv(r,{json:i,refs:this._references});break;case"polygon":a=new Hv(r,{json:i,refs:this._references});break;default:console.error("mapray: unknown entity type: "+o)}if(a){r.addEntity(a);var s=i.id;s&&this._setReference(s,a)}}}}],[{key:"parseOffsetTransform",value:function(e){var t=e,r=t.translate||[0,0,0],n=new fs(t.heading,t.tilt,t.roll),i=void 0!==t.scale?t.scale:[1,1,1];"number"==typeof i&&(i=[i,i,i]);var o=cs.createMatrix();return n.getTransformMatrix(i,o),o[12]=r[0],o[13]=r[1],o[14]=r[2],o}}]),t}(qd);by._defaultHeaders={};var xy=function(){function e(t,r){var n;ze(this,e),this._visibility=r&&r.visibility||!0,this._position=r&&r.position||Ay.TOP_LEFT,n="string"==typeof t?document.getElementById(t):t,this._viewer_container=n,this._container=null,this._is_compact=!1;var i=this;window.addEventListener("resize",(function(){i._sizeChanged()}),!1)}return je(e,[{key:"setVisibility",value:function(e){this._visibility=e,this._setContainerVisibility()}},{key:"setPosition",value:function(e){this._position=e,this._deleteContainer(),this.createContainer()}},{key:"_setContainerVisibility",value:function(){this._container&&(this._visibility?this._container.style.visibility="visible":this._container.style.visibility="collapse")}},{key:"_destroy",value:function(){var e=this;window.removeEventListener("resize",(function(){e._sizeChanged()}),!1),this._deleteContainer()}},{key:"_deleteContainer",value:function(){this._container.parentElement.removeChild(this._container),this._container=null}},{key:"_sizeChanged",value:function(){}},{key:"createContainer",value:function(){}}]),e}(),Ay={TOP_LEFT:{id:"top-left"},TOP_RIGHT:{id:"top-right"},BOTTOM_LEFT:{id:"bottom-left"},BOTTOM_RIGHT:{id:"bottom-right"}};xy._compact_size=500,xy.ContainerPosition=Ay;var Ty=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._position=r&&r.position||xy.ContainerPosition.BOTTOM_LEFT,n}return qe(t,e),je(t,[{key:"_sizeChanged",value:function(){if(this._container){var e=this._container.children[0];this._container.parentElement.parentElement.clientWidth<xy._compact_size?e.classList.add("mapray-logo-compact"):e.classList.remove("mapray-logo-compact")}}},{key:"createContainer",value:function(){var e="control-"+this._position.id,t=this._viewer_container.getElementsByClassName(e)[0],r=document.createElement("div");r.className="control";var n=document.createElement("a");n.className="mapray-logo",n.href="https://mapray.com",n.target="_blank",r.appendChild(n),this._container=r,t.appendChild(this._container),this._sizeChanged()}}]),t}(xy),Iy=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._position=r&&r.position||xy.ContainerPosition.BOTTOM_RIGHT,n._attributions=[],r&&r.attributions?n.copyAttributions(r.attributions):n.copyAttributions(t._default_attribution),n}return qe(t,e),je(t,[{key:"addAttribution",value:function(e){this._attributions.push(e),this._deleteContainer(),this.createContainer()}},{key:"clearAttribution",value:function(){this._attributions=[],this._deleteContainer(),this.createContainer()}},{key:"_sizeChanged",value:function(){this._container&&(this._container.parentElement.parentElement.clientWidth<xy._compact_size?this._container.classList.add("mapray-attribution-compact"):this._container.classList.remove("mapray-attribution-compact"))}},{key:"createContainer",value:function(){var e="control-"+this._position.id,t=this._viewer_container.getElementsByClassName(e)[0],r=document.createElement("div");r.classList.add("control"),r.classList.add("mapray-attribution");var n=document.createElement("div");n.classList.add("mapray-attribution-container");var i=!0,o=!1,a=void 0;try{for(var s,u=this._attributions[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var l=s.value;if(l.display){var _=document.createElement("a");l.link&&(_.href=l.link,_.target="_blank");var c=document.createTextNode(l.display);_.appendChild(c),n.appendChild(_)}}}catch(e){o=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(o)throw a}}r.appendChild(n),this._container=r,t.appendChild(this._container),this._sizeChanged()}},{key:"copyAttributions",value:function(e){this._attributions=e.map((function(e){return e}))}}]),t}(xy);Iy._default_attribution=[{display:"©Mapray",link:"https://mapray.com"},{display:"©JAXA",link:"http://www.jaxa.jp/"},{display:"測量法に基づく国土地理院長承認（複製）H30JHf626",link:"https://www.gsi.go.jp/kiban/index.html"}];var Py=function(){function e(t,r){var n;ze(this,e),n="string"==typeof t?document.getElementById(t):t;var i=this._createCanvas(n);this._container_element=n,this._canvas_element=i,this._glenv=new _u(i),this._camera=new uu(i),this._animation=this._createAnimationBindingBlock(),this._dem_provider=this._createDemProvider(r),this._image_provider=this._createImageProvider(r),this._layers=this._createLayerCollection(r),this._globe=new Sl(this._glenv,this._dem_provider),this._tile_texture_cache=new Wl(this._glenv,this._image_provider),this._scene=new _h(this,this._glenv),this._ground_visibility=e._getBoolOption(r,"ground_visibility",!0),this._entity_visibility=e._getBoolOption(r,"entity_visibility",!0),this._render_mode=r&&r.render_mode||My.SURFACE,this._debug_stats=r&&r.debug_stats||null,this._point_cloud_collection=this._createPointCloudCollection(r),this._render_callback=this._createRenderCallback(r),this._frame_req_id=0,this._previous_time=void 0,this._is_destroyed=!1,this._logo_controller=r&&r.logo_controller||new Ty(this._container_element),this._attribution_controller=r&&r.attribution_controller||new Iy(this._container_element),this._createLogoAttributionContainer(),this._logo_controller.createContainer(),this._attribution_controller.createContainer(),this._requestNextFrame(),this._updateCanvasSize()}return je(e,[{key:"destroy",value:function(){this._is_destroyed||(0!=this._frame_req_id&&(window.maprayCancelAnimationFrame(this._frame_req_id),this._frame_req_id=0),this._render_callback.detach(),this._render_callback=this._createRenderCallback(),this._container_element.removeChild(this._canvas_element),this._globe.cancel(),this._tile_texture_cache.cancel(),this._layers.cancel(),this._scene.cancelLoaders(),this._logo_controller._destroy(),this._attribution_controller._destroy(),this._attribution_controller=null,this._deleteLogoAttributionContainer(),this._is_destroyed=!0)}},{key:"_createCanvas",value:function(e){var t=document.createElement("canvas");return t.className="mapray-canvas",t.style.width="100%",t.style.height="100%",e.appendChild(t),t}},{key:"_createDemProvider",value:function(e){return e&&e.dem_provider?e.dem_provider:new ih("/dem/",".bin")}},{key:"_createAnimationBindingBlock",value:function(){var e=this,t=new Qs;return t.addDescendantUnbinder((function(){e._unbindDescendantAnimations()})),t}},{key:"_createImageProvider",value:function(e){return e&&e.image_provider?e.image_provider:new Jc("http://cyberjapandata.gsi.go.jp/xyz/std/",".png",256,0,18)}},{key:"_createLayerCollection",value:function(e){var t=e&&e.layers?e.layers:{};return new ah(this._glenv,t)}},{key:"_createPointCloudCollection",value:function(e){var t=e&&e.point_cloud_providers?e.point_cloud_providers:{};return new sh(this._scene,t)}},{key:"_createRenderCallback",value:function(e){var t;return(t=e&&e.render_callback?e.render_callback:new lh).attach(this),t}},{key:"_createLogoAttributionContainer",value:function(){var t=!0,r=!1,n=void 0;try{for(var i,o=e._positions[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value,s=document.createElement("div");s.className=a,this._container_element.appendChild(s)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"_deleteLogoAttributionContainer",value:function(){var t=!0,r=!1,n=void 0;try{for(var i,o=e._positions[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value;document.getElementById(a)&&this._container_element.removeChild(a)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}}},{key:"setVisibility",value:function(e,t){switch(e){case Ly.GROUND:this._ground_visibility=t;break;case Ly.ENTITY:this._entity_visibility=t;break;default:throw new Error("invalid target: "+e)}}},{key:"getVisibility",value:function(e,t){switch(e){case Ly.GROUND:return this._ground_visibility;case Ly.ENTITY:return this._entity_visibility;default:throw new Error("invalid target: "+e)}}},{key:"getElevation",value:function(e,t){var r=t+180*Math.floor((90-e)/360+Math.floor((90+e)/360)),n=90-Math.abs(90-e+360*Math.floor((90+e)/360)),i=(r-360-360*Math.floor((r-180)/360))*cs.DEGREE,o=cs.invGudermannian(n*cs.DEGREE),a=2*Math.PI,s=i/a+.5,u=.5-o/a;if(u<0||u>1)return 0;var l=this._globe,_=l.findHighestAccuracy(s,u);if(null===_)return 0;var c=1<<l.dem_provider.getResolutionPower(),h=Math.pow(2,_.z),f=c*(h*s-_.x),d=c*(h*u-_.y),v=cs.clamp(Math.floor(f),0,c-1),y=cs.clamp(Math.floor(d),0,c-1),p=_.getHeights(v,y),g=f-v,m=d-y;return(p[0]*(1-g)+p[1]*g)*(1-m)+(p[2]*(1-g)+p[3]*g)*m}},{key:"getExistingElevation",value:function(e){var t=[e.longitude,e.latitude,0];return this._globe.getExistingElevations(1,t,0,3,t,2,3),t[2]}},{key:"getExistingElevations",value:function(e,t,r,n,i,o,a){return this._globe.getExistingElevations(e,t,r,n,i,o,a)}},{key:"getRayIntersection",value:function(e){var t=this._globe;if(t.status!==Sl.Status.READY)return null;var r=t.root_flake.findRayDistance(e,Number.MAX_VALUE);if(r===Number.MAX_VALUE)return null;var n=cs.createVector3(),i=e.position,o=e.direction;return n[0]=i[0]+r*o[0],n[1]=i[1]+r*o[1],n[2]=i[2]+r*o[2],n}},{key:"_requestNextFrame",value:function(){var e=this;this._frame_req_id=window.maprayRequestAnimationFrame((function(){return e._updateFrame()}))}},{key:"_updateFrame",value:function(){var e=this._updateTime();this._requestNextFrame(),this._updateCanvasSize(),this._render_callback.onUpdateFrameInner(e),null!==this._debug_stats&&this._debug_stats.clearStats(),new Qc(this).render(),this._finishDebugStats()}},{key:"_updateTime",value:function(){var e=window.maprayNow(),t=void 0!==this._previous_time?(e-this._previous_time)/1e3:0;return this._previous_time=e,t}},{key:"_updateCanvasSize",value:function(){var e=this._canvas_element;e.width!=e.clientWidth&&(e.width=e.clientWidth),e.height!=e.clientHeight&&(e.height=e.clientHeight)}},{key:"_finishDebugStats",value:function(){var e=this._debug_stats;null!==e&&(e.num_wait_reqs_dem=this._globe.getNumDemWaitingRequests(),e.num_wait_reqs_img=this._tile_texture_cache.getNumWaitingRequests(),e.onUpdate())}},{key:"_unbindDescendantAnimations",value:function(){this._scene.animation.unbindAllRecursively()}},{key:"container_element",get:function(){return this._container_element}},{key:"canvas_element",get:function(){return this._canvas_element}},{key:"animation",get:function(){return this._animation}},{key:"dem_provider",get:function(){return this._dem_provider}},{key:"image_provider",get:function(){return this._image_provider}},{key:"layers",get:function(){return this._layers}},{key:"point_cloud_collection",get:function(){return this._point_cloud_collection}},{key:"render_callback",get:function(){return this._render_callback}},{key:"render_mode",get:function(){return this._render_mode},set:function(e){this._render_mode=e}},{key:"debug_stats",get:function(){return this._debug_stats}},{key:"camera",get:function(){return this._camera}},{key:"scene",get:function(){return this._scene}},{key:"glenv",get:function(){return this._glenv}},{key:"globe",get:function(){return this._globe}},{key:"tile_texture_cache",get:function(){return this._tile_texture_cache}},{key:"logo_controller",get:function(){return this._logo_controller}},{key:"attribution_controller",get:function(){return this._attribution_controller}}],[{key:"_getBoolOption",value:function(e,t,r){return e&&void 0!==e[t]?e[t]:r}}]),e}(),Ly={GROUND:{id:"GROUND"},ENTITY:{id:"ENTITY"}},My={SURFACE:{id:"SURFACE"},WIREFRAME:{id:"WIREFRAME"}};Py.Category=Ly,Py.RenderMode=My,Py.ContainerPosition=xy.ContainerPosition,Py._positions=["control-top-left","control-top-right","control-bottom-left","control-bottom-right"];var Sy=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this)))._headers={"X-Api-Key":e},r}return qe(t,e),je(t,[{key:"requestTile",value:function(e,t,r,n){var i=new AbortController;return fetch(this._makeURL(e,t,r),{headers:this._headers,signal:i.signal}).then((function(e){return e.ok?e.arrayBuffer():Promise.reject(Error(e.statusText))})).then((function(e){n(e)})).catch((function(){n(null)})),i}},{key:"cancelRequest",value:function(e){e.abort()}},{key:"_makeURL",value:function(e,t,r){return"https://tiles.mapray.com/dem/"+e+"/"+t+"/"+r+".bin"}}]),t}(nh),Ry=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e,"/**\n * テキスト (頂点シェーダ)\n */\n\nattribute vec4 a_position;     // 頂点位置 (モデル座標系)\nattribute vec2 a_offset;       // 頂点変位 (スクリーン座標系)\nattribute vec2 a_texcoord;     // テクスチャ座標\nattribute vec2 a_texmaskcoord; // テクスチャマスク座標\nattribute vec3 a_fg_color;     // 前景色\nattribute vec3 a_bg_color;     // 背景色\n\nuniform mat4 u_obj_to_clip;    // モデル座標系からクリップ座標系への変換\nuniform vec2 u_sparam;         // 画面パラメータ: {2/w, 2/h}\n\nvarying vec2 v_texcoord;       // テクスチャ座標\nvarying vec2 v_texmaskcoord;   // テクスチャマスク座標\nvarying vec3 v_fg_color;       // 前景色\nvarying vec3 v_bg_color;       // 背景色\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    gl_Position.xy += a_offset * u_sparam * gl_Position.w;\n    v_texcoord = a_texcoord;\n    v_texmaskcoord = a_texmaskcoord;\n    v_fg_color = a_fg_color;\n    v_bg_color = a_bg_color;\n}\n","/**\n * テキスト (フラグメントシェーダ)\n */\n\nprecision mediump float;\n\nvarying vec2 v_texcoord;        // アイコンのテクスチャ座標\nvarying vec2 v_texmaskcoord;    // アイコンマスクのテクスチャ座標\nvarying vec3 v_fg_color;        // 前景色\nvarying vec3 v_bg_color;        // 背景色\n\nuniform sampler2D u_image;      // アイコン画像\nuniform sampler2D u_image_mask; // アイコンマスク画像\n\n\nvoid\nmain()\n{\n    float alpha = texture2D( u_image, v_texcoord ).w;          // 輝度\n    float mask = texture2D( u_image_mask, v_texmaskcoord ).w;  // マスク\n    alpha *= mask;\n    gl_FragColor = vec4(v_fg_color * alpha + v_bg_color * (1.0 - alpha), 1.0);\n}\n"))).bindProgram(),r.setInteger("u_image",t.TEXUNIT_IMAGE),r.setInteger("u_image_mask",t.TEXUNIT_IMAGE_MASK),r}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,t){return!1}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r);var i=t._sparam;i[0]=2/e._width,i[1]=2/e._height,this.setVector2("u_sparam",i);var o=n.image;this.bindTexture2D(t.TEXUNIT_IMAGE,o.handle);var a=n.image_mask;this.bindTexture2D(t.TEXUNIT_IMAGE_MASK,a.handle)}}]),t}(Qd);Ry.TEXUNIT_IMAGE=0,Ry.TEXUNIT_IMAGE_MASK=1,Ry._sparam=cs.createVector2f(),Ry._bg_color=cs.createVector3f(),Ry._fg_color=cs.createVector3f();var Cy=function(){function e(){ze(this,e),this._cache=new Map}return je(e,[{key:"create",value:function(e){var t=this.getKey(e),r=this._cache.get(t);return r||this._cache.set(t,r=this.doCreate(e)),r}},{key:"doCreate",value:function(e){}},{key:"getKey",value:function(e){return e}},{key:"load",value:function(e){var t=this.create(e);return t.load(),t}}]),e}(),Dy=function(){function e(){ze(this,e),this._status=e.Status.NOT_LOADED,this.funcs=[]}return je(e,[{key:"isLoaded",value:function(){return this._status===e.Status.LOADED}},{key:"onEnd",value:function(t){this._status===e.Status.LOADED||this._status===e.Status.ABORTED?t(this):this.funcs.push(t)}},{key:"load",value:function(){var t=this;if(this._status===e.Status.NOT_LOADED)return this._status=e.Status.LOADING,this.doLoad().then((function(r){t._icon=r,t._status=e.Status.LOADED;for(var n=0;n<t.funcs.length;n++)t.funcs[n](t);t.funcs.length=0})).catch((function(r){t._status=e.Status.ABORTED;for(var n=0;n<t.funcs.length;n++)t.funcs[n](t);t.funcs.length=0}))}},{key:"doLoad",value:function(e,t){return Promise.reject(new Error("doLoad() is not implemented in: "+this.constructor.name))}},{key:"draw",value:function(e,t,r,n,i){e.drawImage(this.icon,t,r,n,i)}},{key:"status",get:function(){return this._status}},{key:"icon",get:function(){return this._icon}},{key:"width",get:function(){return this.icon?this.icon.width:-1}},{key:"height",get:function(){return this.icon?this.icon.height:-1}}]),e}();Dy.Status={NOT_LOADED:"not loaded",LOADING:"loading",LOADED:"loaded",ABORTED:"aborted"};var Oy=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this))).urlPrefix=e,n.urlSuffix=r,n}return qe(t,e),je(t,[{key:"doCreate",value:function(e){return new Fy(this.urlPrefix+e+this.urlSuffix)}}]),t}(Cy),Fy=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this))).url=e,r}return qe(t,e),je(t,[{key:"doLoad",value:function(e,t){return Ud.loadImage(this.url,{crossOrigin:"Anonymous"})}}]),t}(Dy),Ny=function(e){function t(){return ze(this,t),Je(this,Ye(t).apply(this,arguments))}return qe(t,e),je(t,[{key:"doCreate",value:function(e){return new Vy(e.text,e.props)}},{key:"getKey",value:function(e){return e.text}}]),t}(Cy),Vy=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ze(this,t),(r=Je(this,Ye(t).call(this))).text=e,r.props=n,r}return qe(t,e),je(t,[{key:"doLoad",value:function(e,t){var r=this.props,n=r.size?r.size[0]:20,i=r.font_family?"'"+r.font_family+"'":Ud.SYSTEM_FONT_FAMILY,o=Ud.createCanvasContext(n,n);return o.textAlign="center",o.textBaseline="alphabetic",o.font=.6756756757*n+"px "+i,o.fillText(this.text,.5*n,.7432432432*n),Promise.resolve(o.canvas)}},{key:"draw",value:function(e,t,r,n,i){e.drawImage(this.icon,t,r,n,i)}}]),t}(Dy),Uy=function(e){function t(){return ze(this,t),Je(this,Ye(t).apply(this,arguments))}return qe(t,e),je(t,[{key:"doCreate",value:function(e){return new By(e)}}]),t}(Cy),By=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this)))._image_src=e,r}return qe(t,e),je(t,[{key:"doLoad",value:function(e,t){var r=this._image_src;return"string"==typeof r?Ud.loadImage(r):r instanceof HTMLImageElement?Ud.waitForLoad(r):r instanceof HTMLCanvasElement?Promise.resolve(r):Promise.reject(new Error("not supported: "+r))}}]),t}(Dy),zy=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._entries=[],n._parent_props={fg_color:null,bg_color:null,size:null,font_family:null},n._primitive_producer=new Gy(Ze(n)),n._animation.addDescendantUnbinder((function(){n._unbindDescendantAnimations()})),n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._primitive_producer}},{key:"onChangeAltitudeMode",value:function(e){this._primitive_producer.onChangeAltitudeMode()}},{key:"_unbindDescendantAnimations",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){n.value.animation.unbindAllRecursively()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector2"),i=xi.find("vector3");t.addEntry("fg_color",[i],null,(function(t){e.setFGColor(t)})),t.addEntry("bg_color",[i],null,(function(t){e.setBGColor(t)}));var o,a=cs.createVector2();t.addEntry("size",[n,r],(function(e){return o=Ks.findFirstTypeSupported(e,[n,r])}),(function(t){o===n?e.setSize(t):(a[0]=t,a[1]=t,e.setSize(a))}))}},{key:"setSize",value:function(e){this._setVector2Property("size",e)}},{key:"setFGColor",value:function(e){this._setVector3Property("fg_color",e)}},{key:"setBGColor",value:function(e){this._setVector3Property("bg_color",e)}},{key:"setFontFamily",value:function(e){this._setValueProperty("font_family",e)}},{key:"addPin",value:function(e,t){return this.addTextPin("",e,t)}},{key:"addMakiIconPin",value:function(e,t,r){var n=new qy(this,e,t,r);return this._entries.push(n),this._primitive_producer.onAddEntry(),n}},{key:"addTextPin",value:function(e,t,r){var n=new Yy(this,e,t,r);return this._entries.push(n),this._primitive_producer.onAddEntry(),n}},{key:"_getMaterial",value:function(){var e=this.scene;return e._PinEntity_pin_material||(e._PinEntity_pin_material=new Ry(e.glenv)),e._PinEntity_pin_material}},{key:"_setValueProperty",value:function(e,t){var r=this._parent_props;r[e]!=t&&(r[e]=t,this._primitive_producer.onChangeParentProperty())}},{key:"_setVector3Property",value:function(e,t){var r=this._parent_props[e];r?r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]||(cs.copyVector3(t,r),this._primitive_producer.onChangeParentProperty()):r=this._parent_props[e]=cs.createVector3f(t)}},{key:"_setVector2Property",value:function(e,t){var r=this._parent_props[e];r?r[0]===t[0]&&r[1]===t[1]||(cs.copyVector2(t,r),this._primitive_producer.onChangeParentProperty()):(this._parent_props[e]=cs.createVector2f(t),this._primitive_producer.onChangeParentProperty())}},{key:"_setupByJson",value:function(e){var t=new hs,r=!0,n=!1,i=void 0;try{for(var o,a=e.entries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;t.setFromArray(s.position),this.addPin(t,s)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}e.size&&this.setSize(e.size),e.fg_color&&this.setFGColor(e.fg_color),e.bg_color&&this.setBGColor(e.bg_color),e.font_family&&this.setBGColor(e.font_family)}},{key:"getEntry",value:function(e){return this._entries.find((function(t){return t.id===e}))}}]),t}(Il);zy.SAFETY_PIXEL_MARGIN=1,zy.MAX_IMAGE_WIDTH=4096,zy.CIRCLE_SEP_LENGTH=32,zy.DEFAULT_SIZE=cs.createVector2f([30,30]),zy.DEFAULT_FONT_FAMILY="sans-serif",zy.DEFAULT_FG_COLOR=cs.createVector3f([1,1,1]),zy.DEFAULT_BG_COLOR=cs.createVector3f([.35,.61,.81]),zy.SAFETY_PIXEL_MARGIN=1,zy.MAX_IMAGE_WIDTH=4096;var Gy=function(e){function t(e){var r;ze(this,t),(r=Je(this,Ye(t).call(this,e)))._glenv=e.scene.glenv,r._dirty=!0,r._transform=cs.setIdentity(cs.createMatrix()),r._properties={image:null,image_mask:null};var n=new _l(r._glenv,null,e._getMaterial(),r._transform);return n.properties=r._properties,r._primitive=n,r._primitives=[],r}return qe(t,e),je(t,[{key:"createRegions",value:function(){var e=new uv,t=!0,r=!1,n=void 0;try{for(var i,o=this.entity._entries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value.position;e.addPoint(a)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return[e]}},{key:"onChangeElevation",value:function(e){this._dirty=!0}},{key:"getPrimitives",value:function(e){return this._updatePrimitive()}},{key:"onChangeParentProperty",value:function(){this._dirty=!0}},{key:"onChangeChildProperty",value:function(){this._dirty=!0}},{key:"onChangeAltitudeMode",value:function(){this._dirty=!0}},{key:"onAddEntry",value:function(){this.needToCreateRegions(),this._dirty=!0}},{key:"_updatePrimitive",value:function(){if(!this._dirty)return this._primitives;if(0==this.entity._entries.length)return this._primitives=[],this._dirty=!1,this._primitives;var e=this._createFlatGocsArray();this._updateTransform(e);var t=new Hy(this,e);if(!t.isValid())return this._primitives=[],this._dirty=!1,this._primitives;var r=this._properties;r.image&&r.image.dispose(),r.image=t.texture,r.image_mask&&r.image_mask.dispose(),r.image_mask=t.texture_mask;var n={vtype:[{name:"a_position",size:3},{name:"a_offset",size:2},{name:"a_texcoord",size:2},{name:"a_texmaskcoord",size:2},{name:"a_fg_color",size:3},{name:"a_bg_color",size:3}],vertices:t.vertices,indices:t.indices},i=new ml(this._glenv,n),o=this._primitive;return o.mesh&&o.mesh.dispose(),o.mesh=i,this._primitives=[o],this._dirty=!1,this._primitives}},{key:"_updateTransform",value:function(e){for(var t=this.entity._entries.length,r=0,n=0,i=0,o=0;o<t;++o){var a=3*o;r+=e[a],n+=e[a+1],i+=e[a+2]}var s=this._transform;s[12]=r/t,s[13]=n/t,s[14]=i/t}},{key:"_createFlatGocsArray",value:function(){var e=this.entity._entries.length;return hs.toGocsArray(this._getFlatGeoPoints_with_Absolute(),e,new Float64Array(3*e))}},{key:"_getFlatGeoPoints_with_Absolute",value:function(){for(var e=this.entity,t=e._entries,r=t.length,n=new Float64Array(3*r),i=0;i<r;++i){var o=t[i].position;n[3*i]=o.longitude,n[3*i+1]=o.latitude}switch(e.altitude_mode){case Tl.RELATIVE:case Tl.CLAMP:if(e.scene.viewer.getExistingElevations(r,n,0,3,n,2,3),e.altitude_mode===Tl.RELATIVE)for(var a=0;a<r;++a)n[3*a+2]+=t[a].position.altitude;break;default:for(var s=0;s<r;++s)n[3*s+2]=t[s].position.altitude}return n}}]),t}(Il.PrimitiveProducer),jy=function(){function e(t,r,n){ze(this,e),this._owner=t,this._position=r.clone(),this._animation=new Qs,this._setupAnimationBindingBlock(),this._props=Object.assign({},n),this._copyPropertyVector3f("fg_color"),this._copyPropertyVector3f("bg_color"),this._copyPropertyVector2f("size")}return je(e,[{key:"_loadIcon",value:function(){throw new Error("loadIcon() is not implemented: "+this.constructor.name)}},{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("vector2"),i=xi.find("vector3"),o=new hs;t.addEntry("position",[i],null,(function(t){o.setFromArray(t),e.setPosition(o)})),t.addEntry("fg_color",[i],null,(function(t){e.setFGColor(t)})),t.addEntry("bg_color",[i],null,(function(t){e.setBGColor(t)}));var a,s=cs.createVector2();t.addEntry("size",[n,r],(function(e){return a=Ks.findFirstTypeSupported(e,[n,r])}),(function(t){a===n?e.setSize(t):(s[0]=t,s[1]=t,e.setSize(s))}))}},{key:"setPosition",value:function(e){this._position.longitude===e.longitude&&this._position.latitude===e.latitude&&this._position.altitude===e.altitude||(this._position.assign(e),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"setSize",value:function(e){this._setVector2Property("size",e)}},{key:"setFGColor",value:function(e){this._setVector3Property("fg_color",e)}},{key:"setBGColor",value:function(e){this._setVector3Property("bg_color",e)}},{key:"_copyPropertyVector3f",value:function(e){var t=this._props;t.hasOwnProperty(e)&&(t[e]=cs.createVector3f(t[e]))}},{key:"_copyPropertyVector2f",value:function(e){var t=this._props;t.hasOwnProperty(e)&&("number"==typeof t[e]?t[e]=cs.createVector2f([t[e],t[e]]):t[e]=cs.createVector2f(t[e]))}},{key:"_setVector3Property",value:function(e,t){var r=this._props[e];r?r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]||(cs.copyVector3(t,r),this._owner.getPrimitiveProducer().onChangeChildProperty()):(r=this._props[e]=cs.createVector3f(t),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"_setVector2Property",value:function(e,t){var r=this._props[e];r?r[0]===t[0]&&r[1]===t[1]||(cs.copyVector2(t,r),this._owner.getPrimitiveProducer().onChangeChildProperty()):(this._props[e]=cs.createVector2f(t),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"isLoaded",value:function(){return this._icon.isLoaded()}},{key:"draw",value:function(e,t,r,n,i){this._icon.draw(e,t,r,n,i)}},{key:"position",get:function(){return this._position}},{key:"id",get:function(){return this._props.hasOwnProperty("id")?this._props.id:""}},{key:"size",get:function(){var e=this._props,t=this._owner._parent_props;return e.size||t.size||(this.icon?cs.createVector2f([this.icon.width,this.icon.height]):zy.DEFAULT_SIZE)}},{key:"fg_color",get:function(){var e=this._props,t=this._owner._parent_props;return e.fg_color||t.fg_color||zy.DEFAULT_FG_COLOR}},{key:"bg_color",get:function(){var e=this._props,t=this._owner._parent_props;return e.bg_color||t.bg_color||zy.DEFAULT_BG_COLOR}},{key:"animation",get:function(){return this._animation}},{key:"icon",get:function(){return this._icon}}]),e}();zy.AbstractPinEntry=jy;var qy=function(e){function t(e,r,n,i){var o;return ze(this,t),(o=Je(this,Ye(t).call(this,e,n,i))).setId(r),o._setupMakiIconPinAnimationBindingBlock(),o}return qe(t,e),je(t,[{key:"_setupMakiIconPinAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("string");t.addEntry("id",[r],null,(function(t){e.setId(t)}))}},{key:"setId",value:function(e){var r=this;this._maki_id!==e&&(this._maki_id=e,this._icon=t.makiIconLoader.load(e),this._icon.onEnd((function(e){r._owner.getPrimitiveProducer()._dirty=!0})))}}]),t}(jy);zy.MakiIconPinEntry=qy,qy.makiIconLoader=new Oy("https://resource.mapray.com/styles/v1/icons/maki/",".svg");var Yy=function(e){function t(e,r,n,i){var o;return ze(this,t),(o=Je(this,Ye(t).call(this,e,n,i))).setText(r),o._setupTextPinAnimationBindingBlock(),o}return qe(t,e),je(t,[{key:"_setupTextPinAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("string");t.addEntry("text",[r],null,(function(t){e.setText(t)}))}},{key:"setText",value:function(e){var r=this;this._text!==e&&(this._text=e,this._icon=t.textIconLoader.load({text:this._text,props:{size:this.size,font_family:this.font_family}}),this._icon.onEnd((function(e){r._owner.getPrimitiveProducer()._dirty=!0})))}},{key:"font_family",get:function(){var e=this._props,t=this._owner._parent_props;return e.font_family||t.font_family||zy.DEFAULT_FONT_FAMILY}}]),t}(jy);zy.TextPinEntry=Yy,Yy.textIconLoader=new Ny;var Hy=function(){function e(t,r){ze(this,e),this._owner=t,this._items=this._createItemList(),this._is_valid=!0;var n=this._createRowLayouts();if(0!=n.length){var i=this._setupLocation(n);this._texture=this._createTexture(i.width,i.height),this._texture_mask=this._createTextureMask(),this._vertices=this._createVertices(i.width,i.height,r),this._indices=this._createIndices()}else this._is_valid=!1}return je(e,[{key:"isValid",value:function(){return this._is_valid}},{key:"_createItemList",value:function(){var e=new Map,t=[],r=0,n=!0,i=!1,o=void 0;try{for(var a,s=this._owner.entity._entries[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(u.isLoaded()){var l=e.get(u.icon);l||(e.set(u.icon,l=new Xy(this)),t.push(l)),l.add(r++,u)}}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return t}},{key:"_createRowLayouts",value:function(){var e=[].concat(this._items);e.sort((function(e,t){return e.height_pixel-t.height_pixel}));for(var t=[];e.length>0;){var r=new Wy(e);r.isValid()&&t.push(r)}return t}},{key:"_createTexture",value:function(e,t){for(var r=Ud.createCanvasContext(e,t),n=this._items,i=0;i<n.length;++i){var o=n[i];o.is_canceled||o.draw(r)}var a=this._owner._glenv,s={usage:Wd.Usage.ICON};return new Wd(a,r.canvas,s)}},{key:"_createTextureMask",value:function(){var e=Ud.createCanvasContext(3,3);e.fillRect(1,1,1,1);var t=this._owner._glenv,r={usage:Wd.Usage.ICON,mag_filter:t.context.NEAREST};return new Wd(t,e.canvas,r)}},{key:"_createVertices",value:function(e,t,r){for(var n=[],i=this._owner._transform,o=i[12],a=i[13],s=i[14],u=1/e,l=1/t,_=this._items,c=0;c<_.length;++c){var h=_[c];if(!h.is_canceled)for(var f=0;f<h.entries.length;f++){var d=h.entries[f],v=d.entry,y=v.size,p=1.5*y[0]/2,g=1.5*y[1]/2,m=2*g,k=Math.max(2,p/10),w=3*d.index,E=r[w]-o,b=r[w+1]-a,x=r[w+2]-s,A=v.fg_color,T=v.bg_color,I=h.pos_x,P=h.pos_y,L=h.width,M=h.height,S=function(e,t){n.push((I+L*e)*u,1-(P+M*t)*l)};n.push(E,b,x),n.push(-k/2,m-g),S(.5-k/2/p,1.25),n.push(.25,.25),n.push.apply(n,et(A)),n.push.apply(n,et(T)),n.push(E,b,x),n.push(-k/2,0),S(.5-k/2/p,1.25),n.push(.25,.25),n.push.apply(n,et(A)),n.push.apply(n,et(T)),n.push(E,b,x),n.push(k/2,0),S(.5+k/2/p,1.25),n.push(.25,.25),n.push.apply(n,et(A)),n.push.apply(n,et(T)),n.push(E,b,x),n.push(k/2,m-g),S(.5+k/2/p,1.25),n.push(.25,.25),n.push.apply(n,et(A)),n.push.apply(n,et(T)),n.push(E,b,x),n.push(0,m),S(.5,.5),n.push(.5,.5),n.push.apply(n,et(A)),n.push.apply(n,et(T));for(var R=1;R<zy.CIRCLE_SEP_LENGTH;R++){var C=(R/zy.CIRCLE_SEP_LENGTH*2-.5)*Math.PI,D=Math.cos(C),O=Math.sin(C);n.push(E,b,x),n.push(p*D,g*O+m),S(1.5*D/2+.5,-1.5*O/2+.5),n.push(.25*D+.5,.25*O+.5),n.push.apply(n,et(A)),n.push.apply(n,et(T))}}}return n}},{key:"_createIndices",value:function(){for(var e=[],t=this._items,r=0;r<t.length;++r){var n=t[r];if(!n.is_canceled)for(var i=0;i<n.entries.length;i++){var o=n.entries[i],a=(5+zy.CIRCLE_SEP_LENGTH-1)*o.index,s=a,u=a+3;e.push(a,a+1,a+2),e.push(a,a+2,a+3),a+=4;var l=a++;e.push(l,s,u),e.push(l,u,a);for(var _=1;_<zy.CIRCLE_SEP_LENGTH-1;_++)e.push(l,a++,a);e.push(l,a++,s)}}return e}},{key:"_setupLocation",value:function(e){var t=0,r=0;r+=zy.SAFETY_PIXEL_MARGIN;for(var n=0;n<e.length;++n){var i=e[n];i.locate(r),t=Math.max(i.width_assumed,t),r+=i.height_pixel+zy.SAFETY_PIXEL_MARGIN}return{width:t,height:r}}},{key:"texture",get:function(){return this._texture}},{key:"texture_mask",get:function(){return this._texture_mask}},{key:"vertices",get:function(){return this._vertices}},{key:"indices",get:function(){return this._indices}}]),e}(),Xy=function(){function e(t){ze(this,e),this.entries=[],this._pos_x=0,this._pos_y=0,this._height=this._width=null,this._is_canceled=!1}return je(e,[{key:"add",value:function(e,t){var r=t.size;(null===this._width||this._width<r[0])&&(this._width=r[0]),(null===this._height||this._height<r[1])&&(this._height=r[1]),this.entries.push({index:e,entry:t})}},{key:"cancel",value:function(){this._is_canceled=!0}},{key:"locate",value:function(e,t){this._pos_x=e,this._pos_y=t}},{key:"draw",value:function(e){this.entries[0].entry.draw(e,this._pos_x,this.pos_y,this.width,this.height)}},{key:"pos_x",get:function(){return this._pos_x}},{key:"pos_y",get:function(){return this._pos_y}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"width_pixel",get:function(){return Math.ceil(this._width)}},{key:"height_pixel",get:function(){return Math.ceil(this._height)}},{key:"is_canceled",get:function(){return this._is_canceled}}]),e}(),Wy=function(){function e(t){ze(this,e);var r=0,n=0,i=[];for(r+=zy.SAFETY_PIXEL_MARGIN;t.length>0;){var o=t.shift(),a=o.width_pixel+zy.SAFETY_PIXEL_MARGIN;if(r+a<=zy.MAX_IMAGE_WIDTH)i.push(o),r+=a,n=Math.max(o.height_pixel,n);else{if(0!=i.length){t.unshift(o);break}o.cancel()}}this._items=i,this._width_assumed=r,this._height_pixel=n}return je(e,[{key:"isValid",value:function(){return this._items.length>0}},{key:"locate",value:function(e){var t=this._items,r=0;r+=zy.SAFETY_PIXEL_MARGIN;for(var n=0;n<t.length;++n){var i=t[n];i.locate(r,e),r+=i.width_pixel+zy.SAFETY_PIXEL_MARGIN}}},{key:"items",get:function(){return this._items}},{key:"width_assumed",get:function(){return this._width_assumed}},{key:"height_pixel",get:function(){return this._height_pixel}}]),e}(),Qy=function(e){function t(e){var r;return ze(this,t),(r=Je(this,Ye(t).call(this,e,"/**\n * テキスト (頂点シェーダ)\n */\n\nattribute vec4 a_position;     // 頂点位置 (モデル座標系)\nattribute vec2 a_offset;       // 頂点変位 (スクリーン座標系)\nattribute vec2 a_texcoord;     // テクスチャ座標\n\nuniform mat4 u_obj_to_clip;    // モデル座標系からクリップ座標系への変換\nuniform vec2 u_sparam;         // 画面パラメータ: {2/w, 2/h}\n\nvarying vec2 v_texcoord;       // テクスチャ座標\n\nvoid\nmain()\n{\n    gl_Position = u_obj_to_clip * a_position;\n    gl_Position.xy += a_offset * u_sparam * gl_Position.w;\n    v_texcoord = a_texcoord;\n}\n","/**\n * テキスト (フラグメントシェーダ)\n */\n\nprecision mediump float;\n\nvarying vec2 v_texcoord;        // テクスチャ座標\nuniform sampler2D u_image;      // 画像\n\n\nvoid\nmain()\n{\n    gl_FragColor = texture2D( u_image, v_texcoord );\n}\n"))).bindProgram(),r.setInteger("u_image",t.TEXUNIT_IMAGE),r}return qe(t,e),je(t,[{key:"isTranslucent",value:function(e,t){return!1}},{key:"setParameters",value:function(e,r){var n=r.properties;this.setObjToClip(e,r);var i=t._sparam;i[0]=2/e._width,i[1]=2/e._height,this.setVector2("u_sparam",i);var o=n.image;this.bindTexture2D(t.TEXUNIT_IMAGE,o.handle)}}]),t}(Qd);Qy.TEXUNIT_IMAGE=0,Qy._sparam=cs.createVector2f(),Qy._bg_color=cs.createVector3f(),Qy._fg_color=cs.createVector3f();var Zy=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this,e,r)))._entries=[],n._parent_props={size:null,origin:null},n._primitive_producer=new Jy(Ze(n)),n._animation.addDescendantUnbinder((function(){n._unbindDescendantAnimations()})),n._setupAnimationBindingBlock(),r&&r.json&&n._setupByJson(r.json),n}return qe(t,e),je(t,[{key:"getPrimitiveProducer",value:function(){return this._primitive_producer}},{key:"_unbindDescendantAnimations",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this._entries[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){n.value.animation.unbindAllRecursively()}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"_setupAnimationBindingBlock",value:function(){var e,t=this,r=this.animation,n=xi.find("number"),i=xi.find("vector2"),o=cs.createVector2();r.addEntry("size",[i,n],(function(t){return e=Ks.findFirstTypeSupported(t,[i,n])}),(function(r){e===i?t.setSize(r):(o[0]=r,o[1]=r,t.setSize(o))}))}},{key:"setSize",value:function(e){this._setVector2Property("size",e)}},{key:"setOrigin",value:function(e){this._setVector2Property("origin",e)}},{key:"addImageIcon",value:function(e,t,r){var n=new Ky(this,e,t,r);return this._entries.push(n),this._primitive_producer.onAddEntry(),n}},{key:"_getMaterial",value:function(){var e=this.scene;return e._ImageEntity_image_material||(e._ImageEntity_image_material=new Qy(e.glenv)),e._ImageEntity_image_material}},{key:"_setValueProperty",value:function(e,t){var r=this._parent_props;r[e]!=t&&(r[e]=t,this._primitive_producer.onChangeParentProperty())}},{key:"_setVector2Property",value:function(e,t){var r=this._parent_props[e];r?r[0]===t[0]&&r[1]===t[1]||(cs.copyVector2(t,r),this._primitive_producer.onChangeParentProperty()):(this._parent_props[e]=cs.createVector2f(t),this._primitive_producer.onChangeParentProperty())}},{key:"_setupByJson",value:function(e){var t=new hs,r=!0,n=!1,i=void 0;try{for(var o,a=e.entries[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value;t.setFromArray(s.position),this.addImageIcon(t,s)}}catch(e){n=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}e.size&&this.setSize(e.size),e.origin&&this.setOrigin(e.origin)}},{key:"getEntry",value:function(e){return this._entries.find((function(t){return t.id===e}))}}]),t}(Il);Zy.DEFAULT_COLOR=cs.createVector3f([1,1,1]),Zy.SAFETY_PIXEL_MARGIN=1,Zy.MAX_IMAGE_WIDTH=4096,Zy.CIRCLE_SEP_LENGTH=32,Zy.DEFAULT_ICON_SIZE=cs.createVector2f([30,30]),Zy.DEFAULT_ORIGIN=cs.createVector2f([.5,.5]),Zy.SAFETY_PIXEL_MARGIN=1,Zy.MAX_IMAGE_WIDTH=4096;var Jy=function(e){function t(e){var r;ze(this,t),(r=Je(this,Ye(t).call(this,e)))._glenv=e.scene.glenv,r._dirty=!0,r._transform=cs.setIdentity(cs.createMatrix()),r._properties={image:null};var n=new _l(r._glenv,null,e._getMaterial(),r._transform);return n.properties=r._properties,r._primitive=n,r._primitives=[],r}return qe(t,e),je(t,[{key:"createRegions",value:function(){var e=new uv,t=!0,r=!1,n=void 0;try{for(var i,o=this.entity._entries[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var a=i.value.position;e.addPoint(a)}}catch(e){r=!0,n=e}finally{try{t||null==o.return||o.return()}finally{if(r)throw n}}return[e]}},{key:"onChangeElevation",value:function(e){this._dirty=!0}},{key:"getPrimitives",value:function(e){return this._updatePrimitive()}},{key:"onChangeParentProperty",value:function(){this._dirty=!0}},{key:"onChangeChildProperty",value:function(){this._dirty=!0}},{key:"onChangeAltitudeMode",value:function(){this._dirty=!0}},{key:"onAddEntry",value:function(){this.needToCreateRegions(),this._dirty=!0}},{key:"_updatePrimitive",value:function(){if(!this._dirty)return this._primitives;if(0==this.entity._entries.length)return this._primitives=[],this._dirty=!1,this._primitives;var e=this._createFlatGocsArray();this._updateTransform(e);var t=new $y(this,e);if(!t.isValid())return this._primitives=[],this._dirty=!1,this._primitives;var r=this._properties;r.image&&r.image.dispose(),r.image=t.texture;var n={vtype:[{name:"a_position",size:3},{name:"a_offset",size:2},{name:"a_texcoord",size:2}],vertices:t.vertices,indices:t.indices},i=new ml(this._glenv,n),o=this._primitive;return o.mesh&&o.mesh.dispose(),o.mesh=i,this._primitives=[o],this._dirty=!1,this._primitives}},{key:"_updateTransform",value:function(e){for(var t=this.entity._entries.length,r=0,n=0,i=0,o=0;o<t;++o){var a=3*o;r+=e[a],n+=e[a+1],i+=e[a+2]}var s=this._transform;s[12]=r/t,s[13]=n/t,s[14]=i/t}},{key:"_createFlatGocsArray",value:function(){var e=this.entity._entries.length;return hs.toGocsArray(this._getFlatGeoPoints_with_Absolute(),e,new Float64Array(3*e))}},{key:"_getFlatGeoPoints_with_Absolute",value:function(){for(var e=this.entity,t=e._entries,r=t.length,n=new Float64Array(3*r),i=0;i<r;++i){var o=t[i].position;n[3*i]=o.longitude,n[3*i+1]=o.latitude}switch(e.altitude_mode){case Tl.RELATIVE:case Tl.CLAMP:if(e.scene.viewer.getExistingElevations(r,n,0,3,n,2,3),e.altitude_mode===Tl.RELATIVE)for(var a=0;a<r;++a)n[3*a+2]+=t[a].position.altitude;break;default:for(var s=0;s<r;++s)n[3*s+2]=t[s].position.altitude}return n}}]),t}(Il.PrimitiveProducer),Ky=function(){function e(t,r,n,i){ze(this,e),this._owner=t,this._position=n.clone(),this._animation=new Qs,this._setupAnimationBindingBlock(),this._props=Object.assign({},i),this._copyPropertyVector2f("size"),this._copyPropertyVector2f("origin"),this.setImage(r)}return je(e,[{key:"_setupAnimationBindingBlock",value:function(){var e=this,t=this.animation,r=xi.find("number"),n=xi.find("string"),i=xi.find("vector2"),o=xi.find("vector3");t.addEntry("image_src",[n],null,(function(t){e.setImage(t)}));var a=new hs;t.addEntry("position",[o],null,(function(t){a.setFromArray(t),e.setPosition(a)}));var s,u=cs.createVector2();t.addEntry("size",[i,r],(function(e){return s=Ks.findFirstTypeSupported(e,[i,r])}),(function(t){s===i?e.setSize(t):(u[0]=t,u[1]=t,e.setSize(u))}))}},{key:"setImage",value:function(t){var r=this;this._image_src!==t&&(this._image_src=t,this._icon=e.iconLoader.load(t),this._icon.onEnd((function(e){r._owner.getPrimitiveProducer()._dirty=!0})))}},{key:"setPosition",value:function(e){this._position.longitude===e.longitude&&this._position.latitude===e.latitude&&this._position.altitude===e.altitude||(this._position.assign(e),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"setSize",value:function(e){this._setVector2Property("size",e)}},{key:"_copyPropertyVector3f",value:function(e){var t=this._props;t.hasOwnProperty(e)&&(t[e]=cs.createVector3f(t[e]))}},{key:"_copyPropertyVector2f",value:function(e){var t=this._props;t.hasOwnProperty(e)&&("number"==typeof t[e]?t[e]=cs.createVector2f([t[e],t[e]]):t[e]=cs.createVector2f(t[e]))}},{key:"_setVector2Property",value:function(e,t){var r=this._props[e];r?r[0]===t[0]&&r[1]===t[1]||(cs.copyVector2(t,r),this._owner.getPrimitiveProducer().onChangeChildProperty()):(this._props[e]=cs.createVector2f(t),this._owner.getPrimitiveProducer().onChangeChildProperty())}},{key:"isLoaded",value:function(){return this._icon.isLoaded()}},{key:"draw",value:function(e,t,r,n,i){this._icon.draw(e,t,r,n,i)}},{key:"position",get:function(){return this._position}},{key:"id",get:function(){return this._props.hasOwnProperty("id")?this._props.id:""}},{key:"size",get:function(){var e=this._props,t=this._owner._parent_props;return e.size||t.size||cs.createVector2f([this._icon.width,this._icon.height])}},{key:"origin",get:function(){var e=this._props,t=this._owner._parent_props;return e.origin||t.origin||Zy.DEFAULT_ORIGIN}},{key:"animation",get:function(){return this._animation}},{key:"icon",get:function(){return this._icon}}]),e}();Zy.ImageEntry=Ky,Ky.iconLoader=new Uy;var $y=function(){function e(t,r){ze(this,e),this._owner=t,this._items=this._createItemList(),this._is_valid=!0;var n=this._createRowLayouts();if(0!=n.length){var i=this._setupLocation(n);this._texture=this._createTexture(i.width,i.height),this._vertices=this._createVertices(i.width,i.height,r),this._indices=this._createIndices()}else this._is_valid=!1}return je(e,[{key:"isValid",value:function(){return this._is_valid}},{key:"_createItemList",value:function(){var e=new Map,t=[],r=0,n=!0,i=!1,o=void 0;try{for(var a,s=this._owner.entity._entries[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(u.isLoaded()){var l=e.get(u.icon);l||(e.set(u.icon,l=new ep(this)),t.push(l)),l.add(r++,u)}}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return t}},{key:"_createRowLayouts",value:function(){var e=[].concat(this._items);e.sort((function(e,t){return e.height_pixel-t.height_pixel}));for(var t=[];e.length>0;){var r=new tp(e);r.isValid()&&t.push(r)}return t}},{key:"_createTexture",value:function(e,t){for(var r=Ud.createCanvasContext(e,t),n=this._items,i=0;i<n.length;++i){var o=n[i];o.is_canceled||o.draw(r)}var a=this._owner._glenv,s={usage:Wd.Usage.ICON};return new Wd(a,r.canvas,s)}},{key:"_createVertices",value:function(e,t,r){for(var n=[],i=this._owner._transform,o=i[12],a=i[13],s=i[14],u=1/e,l=1/t,_=this._items,c=0;c<_.length;++c){var h=_[c];if(!h.is_canceled)for(var f=0;f<h.entries.length;f++){var d=h.entries[f],v=d.entry,y=v.size,p=v.origin,g=3*d.index,m=r[g]-o,k=r[g+1]-a,w=r[g+2]-s,E=h.pos_x,b=h.pos_y,x=h.width,A=h.height;n.push(m,k,w),n.push(-p[0]*y[0],p[1]*y[1]),n.push(E*u,1-b*l),n.push(m,k,w),n.push(-p[0]*y[0],-(1-p[1])*y[1]),n.push(E*u,1-(b+A)*l),n.push(m,k,w),n.push((1-p[0])*y[0],-(1-p[1])*y[1]),n.push((E+x)*u,1-(b+A)*l),n.push(m,k,w),n.push((1-p[0])*y[0],p[1]*y[1]),n.push((E+x)*u,1-b*l)}}return n}},{key:"_createIndices",value:function(){for(var e=[],t=this._items,r=0;r<t.length;++r){var n=t[r];if(!n.is_canceled)for(var i=0;i<n.entries.length;i++){var o=4*n.entries[i].index;e.push(o,o+1,o+2),e.push(o,o+2,o+3)}}return e}},{key:"_setupLocation",value:function(e){var t=0,r=0;r+=Zy.SAFETY_PIXEL_MARGIN;for(var n=0;n<e.length;++n){var i=e[n];i.locate(r),t=Math.max(i.width_assumed,t),r+=i.height_pixel+Zy.SAFETY_PIXEL_MARGIN}return{width:t,height:r}}},{key:"texture",get:function(){return this._texture}},{key:"vertices",get:function(){return this._vertices}},{key:"indices",get:function(){return this._indices}}]),e}(),ep=function(){function e(t){ze(this,e),this.entries=[],this._pos_x=0,this._pos_y=0,this._height=this._width=null,this._is_canceled=!1}return je(e,[{key:"add",value:function(e,t){var r=t.size;(null===this._width||this._width<r[0])&&(this._width=r[0]),(null===this._height||this._height<r[1])&&(this._height=r[1]),this.entries.push({index:e,entry:t})}},{key:"cancel",value:function(){this._is_canceled=!0}},{key:"locate",value:function(e,t){this._pos_x=e,this._pos_y=t}},{key:"draw",value:function(e){this.entries[0].entry.draw(e,this._pos_x,this.pos_y,this.width,this.height)}},{key:"pos_x",get:function(){return this._pos_x}},{key:"pos_y",get:function(){return this._pos_y}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"width_pixel",get:function(){return Math.ceil(this._width)}},{key:"height_pixel",get:function(){return Math.ceil(this._height)}},{key:"is_canceled",get:function(){return this._is_canceled}}]),e}(),tp=function(){function e(t){ze(this,e);var r=0,n=0,i=[];for(r+=Zy.SAFETY_PIXEL_MARGIN;t.length>0;){var o=t.shift(),a=o.width_pixel+Zy.SAFETY_PIXEL_MARGIN;if(r+a<=Zy.MAX_IMAGE_WIDTH)i.push(o),r+=a,n=Math.max(o.height_pixel,n);else{if(0!=i.length){t.unshift(o);break}o.cancel()}}this._items=i,this._width_assumed=r,this._height_pixel=n}return je(e,[{key:"isValid",value:function(){return this._items.length>0}},{key:"locate",value:function(e){var t=this._items,r=0;r+=Zy.SAFETY_PIXEL_MARGIN;for(var n=0;n<t.length;++n){var i=t[n];i.locate(r,e),r+=i.width_pixel+Zy.SAFETY_PIXEL_MARGIN}}},{key:"items",get:function(){return this._items}},{key:"width_assumed",get:function(){return this._width_assumed}},{key:"height_pixel",get:function(){return this._height_pixel}}]),e}(),rp=W.f,np=function(e){return function(t){for(var r,n=ee(t),i=ot(n),a=i.length,s=0,u=[];a>s;)r=i[s++],o&&!rp.call(n,r)||u.push(e?[r,n[r]]:n[r]);return u}},ip={entries:np(!0),values:np(!1)}.values;Re({target:"Object",stat:!0},{values:function(e){return ip(e)}});var op=function(e){function t(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(ze(this,t),r instanceof Bd);else{if("string"!=typeof r)throw new Error("Unsupported Resource: "+r);r=new Gd(r,{type:"json",transform:i.transform})}return(n=Je(this,Ye(t).call(this,e,r,{onLoad:i.onLoad})))._getPointFGColor=i.getPointFGColor||lp,n._getPointBGColor=i.getPointBGColor||_p,n._getPointSize=i.getPointSize||cp,n._getPointIconId=i.getPointIconId||hp,n._getLineColor=i.getLineColor||ap,n._getLineWidth=i.getLineWidth||sp,n._getFillColor=i.getFillColor||up,n._getExtrudedHeight=i.getExtrudedHeight||vp,n._getAltitudeMode=i.getAltitudeMode||fp,n._getAltitude=i.getAltitude||dp,n._transform=i.transform||yp,n._glenv=e.glenv,n._references={},n._cancelled=!1,n._finished=!1,n}return qe(t,e),je(t,[{key:"_load",value:function(){var e=this;return this._resource.load({type:zd.JSON}).then((function(t){e._check_cancel(),e._load_geojson_object(t)}))}},{key:"_load_geojson_object",value:function(e){var t;if(e.type===pp.FEATURE_COLLECTION){var r=e.features;t=!1;for(var n=0,i=r.length;n<i;n++){var o=r[n],a=this._load_geojson_object(o.featureId?o.feature:o);a&&!t&&(t=a)}}else if(e.type===pp.FEATURE){var s=e.geometry;t=this._load_geometry_object(s,e)}else{if(-1===mp.indexOf(e.type))throw new Error("Unnsupported Type: "+e.type);t=this._load_geometry_object(e,null)}return!this._cancelled&&t}},{key:"_load_geometry_object",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.coordinates;if(!r&&!e)return!1;switch(e.type){case gp.POINT:case gp.MULTI_POINT:return this._loadPoint(e,t);case gp.LINE_STRING:case gp.MULTI_LINE_STRING:return this._loadLines(e,t);case gp.POLYGON:case gp.MULTI_POLYGON:return this._loadPolygons(e,t);case gp.GEOMETRY_COLLECTION:return!0;default:throw new Error("Invalid GeoJSON type: "+e.type)}}},{key:"_make_fetch_params",value:function(e){var r={signal:this._abort_ctrl.signal,credentials:(e.credentials||Zc.OMIT).credentials};return e.headers&&(r.headers=e.headers||t._defaultHeaders),r}},{key:"_loadLines",value:function(e,t){var r=this,n=this._getLineColor(t),i=this._getLineWidth(t),o=this._getAltitude(t),a=this._getAltitudeMode(t);if(!e||4!==n.length)return!1;var s=e.type,u=e.coordinates,l=n.slice(0,3),_=n[3];return s===gp.MULTI_LINE_STRING?(u.forEach((function(e){if(!r._generateLine(e,i,l,_,a,o))return!1})),!0):this._generateLine(u,i,l,_,a,o)}},{key:"_generateLine",value:function(e,t,r,n,i,o){if(!e)return!1;var a=new kv(this._scene);a.altitude_mode=i;var s=this._flatten(e,o);return a.addPoints(s),a.setLineWidth(t),a.setColor(r),a.setOpacity(n),this._scene.addEntity(a),!0}},{key:"_loadPoint",value:function(e,r){var n=this._getPointFGColor(r),i=this._getPointBGColor(r),o=this._getPointIconId(r),a=this._getPointSize(r),s=this._getAltitudeMode(r),u=this._getAltitude(r);if(!e)return!1;var l=e.type,_={fg_color:n.slice(0,3),bg_color:i.slice(0,3),size:a};if(l===gp.POINT){(f=new zy(this._scene)).altitude_mode=s;var c=this._getActualValue(u,e.coordinates[2],t.defaultAltitude),h=new hs(e.coordinates[0],e.coordinates[1],c);null!==o?f.addMakiIconPin(o,h,_):f.addPin(h,_),this._scene.addEntity(f)}else{var f;(f=new zy(this._scene)).altitude_mode=s;for(var d=0;d<e.coordinates.length;d++){var v=e.coordinates[d];c=this._getActualValue(u,e.coordinates[2],t.defaultAltitude),h=new hs(v[0],v[1],c);null!==o?f.addMakiIconPin(o,h,_):f.addPin(h,_)}this._scene.addEntity(f)}return!0}},{key:"_loadPolygons",value:function(e,t){var r=this,n=this._getFillColor(t),i=this._getAltitudeMode(t),o=this._getAltitude(t),a=this._getExtrudedHeight(t);if(!e||4!==n.length)return!1;var s=e.type,u=e.coordinates,l=n.slice(0,3),_=n[3];return s===gp.MULTI_POLYGON?(u.forEach((function(e){if(!r._generatePolygon(e,l,_,i,o,a))return!1})),!0):this._generatePolygon(u,l,_,i,o,a)}},{key:"_generatePolygon",value:function(e,t,r,n,i,o){if(!e)return!1;var a=new Hv(this._scene);a.altitude_mode=n,a.extruded_height=o,a.setColor(t),a.setOpacity(r);for(var s=0;s<e.length;s++){var u=this._flatten(e[s],i,e[s].length-1);if(!u)return!1;0===s?a.addOuterBoundary(u):a.addInnerBoundary(u)}return this._scene.addEntity(a),!0}},{key:"_getActualValue",value:function(e,t,r){return null!=e?e:null!=t?t:r}},{key:"_flatten",value:function(e,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length;return e.reduce((function(e,o,a){return a>=i?e:e.concat(o.slice(0,2),n._getActualValue(r,o[2],t.defaultAltitude))}),[])}}]),t}(qd);function ap(e){return op.defaultLineColor}function sp(e){return op.defaultLineWidth}function up(e){return op.defaultFillColor}function lp(e){return op.defaultPointFGColor}function _p(e){return op.defaultPointBGColor}function cp(e){return op.defaultPointSize}function hp(e){return op.defaultPointIconId}function fp(e){return Tl.ABSOLUTE}function dp(e){return null}function vp(e){return op.defaultExtrudedHeight}function yp(e){return{url:e}}op._defaultHeaders={},op.defaultLineColor=[0,0,0,1],op.defaultFillColor=[0,0,0,1],op.defaultLineWidth=1,op.defaultPointFGColor=[1,1,1],op.defaultPointBGColor=[.35,.61,.81],op.defaultPointSize=30,op.defaultPointIconId=null,op.defaultAltitude=0,op.defaultExtrudedHeight=0;var pp={FEATURE:"Feature",FEATURE_COLLECTION:"FeatureCollection"},gp={POINT:"Point",MULTI_POINT:"MultiPoint",LINE_STRING:"LineString",MULTI_LINE_STRING:"MultiLineString",POLYGON:"Polygon",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",FEATURE:"Feature"},mp=Object.values(gp),kp=function(){function e(){ze(this,e),this.clearStats()}return je(e,[{key:"clearStats",value:function(){this.num_wait_reqs_dem=0,this.num_wait_reqs_img=0,this.num_drawing_flakes=0,this.num_drawing_flake_vertices=0,this.num_procA_flakes=0,this.num_procB_flakes=0}},{key:"onUpdate",value:function(){}}]),e}(),wp=gt.trim,Ep=n.parseInt,bp=/^[+-]?0[Xx]/,xp=8!==Ep(ft+"08")||22!==Ep(ft+"0x16")?function(e,t){var r=wp(String(e));return Ep(r,t>>>0||(bp.test(r)?16:10))}:Ep;Re({global:!0,forced:parseInt!=xp},{parseInt:xp});var Ap=re.f,Tp="".endsWith,Ip=Math.min,Pp=Dn("endsWith"),Lp=!Pp&&!!function(){var e=Ap(String.prototype,"endsWith");return e&&!e.writable}();Re({target:"String",proto:!0,forced:!Lp&&!Pp},{endsWith:function(e){var t=String($(this));Rn(e);var r=arguments.length>1?arguments[1]:void 0,n=_e(t.length),i=void 0===r?n:Ip(_e(r),n),o=String(e);return Tp?Tp.call(t,o,i):t.slice(i-o.length,i)===o}});var Mp=function(){function e(t){ze(this,e),this._aip=t}return je(e,[{key:"getId",value:function(){return this._id}},{key:"getOwnerId",value:function(){return this._owner_id}},{key:"getName",value:function(){return this._name}},{key:"getDescription",value:function(){return this._description}},{key:"getCreatedAt",value:function(){return this._created_at}},{key:"getUpdatedAt",value:function(){return this._updated_at}},{key:"_restoreFromJson",value:function(e){this._id=e.id,this._owner_id=e.owner_id,this._name=e.name,this._description=e.description,this._created_at=new Date(e.created_at),this._updated_at=new Date(e.updated_at)}}]),e}(),Sp=function(e){function t(e){return ze(this,t),Je(this,Ye(t).call(this,e))}return qe(t,e),je(t,[{key:"_restoreFromJson",value:function(e){Ke(Ye(t.prototype),"_restoreFromJson",this).call(this,e)}}],[{key:"createFromJson",value:function(e,r){var n=new t(e);return n._restoreFromJson(r),n}}]),t}(Mp),Rp=function(e){function t(e){return ze(this,t),Je(this,Ye(t).call(this,e))}return qe(t,e),je(t,[{key:"getUrl",value:function(){return this._url}},{key:"getFormat",value:function(){return this._format}},{key:"getSceneId",value:function(){return this._scene_id}},{key:"getPath",value:function(){return this._path}},{key:"getSRID",value:function(){return this._srid}},{key:"_restoreFromJson",value:function(e){Ke(Ye(t.prototype),"_restoreFromJson",this).call(this,e),this._url=e.url,this._scene_id=e.scene_id,this._path=e.path,this._format=e.format,this._srid=e.srid}}],[{key:"createFromJson",value:function(e,r){var n=new t(e);return n._restoreFromJson(r),n}}]),t}(Mp),Cp=function(e){function t(e){return ze(this,t),Je(this,Ye(t).call(this,e))}return qe(t,e),je(t,[{key:"getUrl",value:function(){return this._url}},{key:"getBoundingBox",value:function(){return this._bounding_box}},{key:"getContentRoot",value:function(){return this._content_root}},{key:"getFormat",value:function(){return this._format}},{key:"_restoreFromJson",value:function(e){Ke(Ye(t.prototype),"_restoreFromJson",this).call(this,e),this._url=e.url,this._bounding_box=e.bbox,this._content_root=Array.isArray(e.content_root)?e.content_root.join("/"):e.content_root,this._format=e.format}}],[{key:"createFromJson",value:function(e,r){var n=new t(e);return n._restoreFromJson(r),n}}]),t}(Mp),Dp=function(e){function t(e,r){var n;ze(this,t);var i=r.lastIndexOf("/");if(-1===i)throw new Error("invalid url");return(n=Je(this,Ye(t).call(this)))._api=e,n._url=r,n._base_url=r.substr(0,i+1),n}return qe(t,e),je(t,[{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.type===zd.JSON?this._api.fetch(mh.METHOD.GET,this._url).then((function(e){return e.json()})):this._api.fetch(mh.METHOD.GET,this._url)}},{key:"loadSubResourceSupported",value:function(){return!0}},{key:"loadSubResource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Ud.resolveUrl(this._base_url,e);return t.type===zd.BINARY?this._api.fetch(mh.METHOD.GET,r).then((function(e){return e.arrayBuffer()})):t.type===zd.IMAGE?this._api.fetch(mh.METHOD.GET,r).then((function(e){if(!e.ok)throw new Error(e.statusText);return e.blob()})).then(Ud.loadImage):this._api.fetch(mh.METHOD.GET,r)}}]),t}(Bd),Op=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this)))._api=e,n._datasetId=r,n}return qe(t,e),je(t,[{key:"load",value:function(){return this._api.listFeatures(this._datasetId)}}]),t}(Bd),Fp=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this)))._api=e,n._datasetIds=Array.isArray(r)?r:[r],n}return qe(t,e),je(t,[{key:"load",value:function(){return this._api.get3DDatasetScene(this._datasetIds)}},{key:"resolveResourceSupported",value:function(){return!0}},{key:"resolveResource",value:function(e){return new Dp(this._api,e)}}]),t}(Bd),Np=function(e){function t(e,r){var n;return ze(this,t),(n=Je(this,Ye(t).call(this)))._api=e,n._datasetId=r,n}return qe(t,e),je(t,[{key:"load",value:function(){return this._api.getPointCloudDataset(this._datasetId)}},{key:"resolveResourceSupported",value:function(){return!0}},{key:"resolveResource",value:function(e){return new Dp(this._api,e)}}]),t}(Bd),Vp=function(e){function t(e,r,n,i,o){var a;return ze(this,t),a=Je(this,Ye(t).call(this,r+" ["+e+"]",n)),Error.captureStackTrace&&Error.captureStackTrace(Ze(a),t),a.name="MaprayApiError",a.code=e,a.resonse=i,a.cause=o,o&&(a.stack+="\nCaused-By: "+o.stack),a}return qe(t,e),t}(kh),Up=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ze(this,t),e=Je(this,Ye(t).call(this));var n=r.basePath.endsWith("/")?r.basePath.slice(0,-1):r.basePath;return e._option={basePath:n||DEFAULT_BASE_PATH,version:r.version,token:r.token,userId:r.userId},e}var r,n,i,o,a,s,u,l,_;return qe(t,e),je(t,[{key:"loadDatasets",value:(_=Be(regeneratorRuntime.mark((function e(){var t,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getDatasets();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return Sp.createFromJson(r,e)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"loadDataset",value:(l=Be(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getDataset(t);case 2:return r=e.sent,e.abrupt("return",Sp.createFromJson(this,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"load3DDatasets",value:(u=Be(regeneratorRuntime.mark((function e(){var t,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get3DDatasets();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return Rp.createFromJson(r,e)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"load3DDataset",value:(s=Be(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get3DDataset(t);case 2:return r=e.sent,e.abrupt("return",Rp.createFromJson(this,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"loadPointCloudDatasets",value:(a=Be(regeneratorRuntime.mark((function e(){var t,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPointCloudDatasets();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return Cp.createFromJson(r,e)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"loadPointCloudDataset",value:(o=Be(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPointCloudDataset(t);case 2:return r=e.sent,e.abrupt("return",Cp.createFromJson(this,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getDatasetAsResource",value:function(e){return new Op(this,e)}},{key:"get3DDatasetAsResource",value:function(e){return new Fp(this,e)}},{key:"getPointCloudDatasetAsResource",value:function(e){return new Np(this,e)}},{key:"getDatasets",value:function(){var e=this._option;return this.get("datasets",[e.userId],null)}},{key:"getDataset",value:function(e){var t=this._option;return this.get("datasets",[t.userId,e],null)}},{key:"createDataset",value:function(e,t){var r=this._option,n={name:e,description:t};return this.post("datasets",[r.userId],null,n)}},{key:"deleteDataset",value:function(e){var t=this._option;return this.delete("datasets",[t.userId,e])}},{key:"getFeatures",value:function(e){var t=this._option;return this.get("datasets",[t.userId,e,"features"])}},{key:"insertFeature",value:function(e,t){var r=this._option;return this.post("datasets",[r.userId,e,"features"],null,t)}},{key:"updateFeature",value:function(e,t,r){var n=this._option;return this.put("datasets",[n.userId,"features",t],null,r)}},{key:"get3DDatasets",value:function(){var e=this._option;return this.get("3ddatasets",[e.userId])}},{key:"create3DDataset",value:function(e,t,r){var n=this._option,i={name:e,description:t,path:r.path,format:r.format,srid:r.srid,x:r.x,y:r.y,z:r.z};return this.post("3ddatasets",[n.userId],null,i)}},{key:"update3DDataset",value:function(e,t,r,n){var i=this._option,o={name:t,description:r,path:n.path,format:n.format,srid:n.srid,x:n.x,y:n.y,z:n.z};return this.patch("3ddatasets",[i.userId,e],null,o)}},{key:"create3DDatasetUploadUrl",value:function(e){var t=this._option;return this.post("3ddatasets",["uploads",t.userId,e],null,{})}},{key:"get3DDataset",value:function(e){var t=this._option;return this.get("3ddatasets",[t.userId,e],null)}},{key:"delete3DDataset",value:function(e){var t=this._option;return this.delete("3ddatasets",[t.userId,e])}},{key:"get3DDatasetScene",value:function(e){var t=this._option;return this.get("3ddatasets",["scene",t.userId],{"3ddatasets_ids":Array.isArray(e)?e.join(","):e}).then((function(e){return e.entity_list.forEach((function(e){var t=e.index,r=parseInt(t);if(r.toString()!==t)throw new Error("Internal Error: ID couldn't be convert to 'number'");e.index=r})),e}))}},{key:"getPointCloudDatasets",value:function(){var e=this._option;return this.get("pcdatasets",[e.userId])}},{key:"getPointCloudDataset",value:function(e){var t=this._option;return this.get("pcdatasets",[t.userId,e])}},{key:"get",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.fetchAPI(mh.METHOD.GET,e,t,r,null,n)}},{key:"post",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return"string"!=typeof n&&(n=JSON.stringify(n)),this.fetchAPI(mh.METHOD.POST,e,t,r,n,i)}},{key:"patch",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return"string"!=typeof n&&(n=JSON.stringify(n)),this.fetchAPI(mh.METHOD.PATCH,e,t,r,n,i)}},{key:"put",value:(i=Be(regeneratorRuntime.mark((function e(t,r,n,i){var o,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=a.length>4&&void 0!==a[4]?a[4]:{},"string"!=typeof i&&(i=JSON.stringify(i)),e.next=4,this.fetchAPI(mh.METHOD.PUT,t,r,n,i,o);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return i.apply(this,arguments)})},{key:"delete",value:(n=Be(regeneratorRuntime.mark((function e(t,r,n){var i,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.length>3&&void 0!==o[3]?o[3]:{},e.next=3,this.fetchAPI(mh.METHOD.DELETE,t,r,n,null,i);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"fetchAPI",value:(r=Be(regeneratorRuntime.mark((function e(t,r,n,i,o){var a,s,u,l,_=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=_.length>5&&void 0!==_[5]?_[5]:{},s=this._option,u=s.basePath+"/"+r+"/"+s.version+(n.length>0?"/"+n.join("/"):""),e.next=5,this.fetch(t,u,i,o,a);case 5:return l=e.sent,e.next=8,l.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"fetch",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=this._option,a=i.headers||(i.headers={});return a["x-api-key"]=o.token,mh.fetch(e,t,r,n,i).catch((function(e){if("FetchError"===e.name&&e.response)return e.response.json().catch((function(r){throw new Vp(-1,"Failed to fetch",t,null,e)})).then((function(r){throw new Vp(r.code,r.error,t,e.response,e)}));throw new Vp(-1,"Failed to fetch",t,null,e)}))}}]),t}(mh);Up.DEFAULT_BASE_PATH="https://cloud.mapray.com";var Bp=function(){function e(){ze(this,e),this._status=e.Status.NOT_INITIALIZED}var t,r,n,i,o;return je(e,[{key:"init",value:(o=Be(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._status===e.Status.NOT_INITIALIZED){t.next=2;break}throw new Error("invalid status");case 2:return t.prev=2,t.next=5,this.doInit();case 5:this._status=e.Status.INITIALIZED,t.next=12;break;case 8:throw t.prev=8,t.t0=t.catch(2),this._status=e.Status.DESTROYED,t.t0;case 12:case"end":return t.stop()}}),t,this,[[2,8]])}))),function(){return o.apply(this,arguments)})},{key:"isReady",value:function(){return this._status==e.Status.INITIALIZED&&this.getNumberOfRequests()<10}},{key:"load",value:function(t,r,n,i){if(this._status!==e.Status.INITIALIZED)return{id:-1,done:Promise.reject(new Error("invalid status"))};var o=e._id_max++;return{id:o,done:this.doLoad(o,t,r,n,i)}}},{key:"flushQueue",value:function(){}},{key:"toString",value:function(){return"PointCloudProvider"}},{key:"cancel",value:function(t){if(this._status!==e.Status.INITIALIZED)throw new Error("invalid status");console.log("cancel not implemented")}},{key:"getNumberOfRequests",value:function(){throw new Error("not implemented")}},{key:"destroy",value:(i=Be(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._status===e.Status.INITIALIZED){t.next=2;break}throw new Error("invalid status");case 2:return t.prev=2,t.next=5,this.doDestroy();case 5:return t.prev=5,this._status=e.Status.DESTROYED,t.finish(5);case 8:case"end":return t.stop()}}),t,this,[[2,,5,8]])}))),function(){return i.apply(this,arguments)})},{key:"doInit",value:(n=Be(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"doLoad",value:(r=Be(regeneratorRuntime.mark((function e(t,r,n,i,o){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("not implemented");case 1:case"end":return e.stop()}}),e)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"doDestroy",value:(t=Be(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}],[{key:"Status",get:function(){return zp}}]),e}();Bp._id_max=0;var zp={NOT_INITIALIZED:{id:"NOT_INITIALIZED"},INITIALIZED:{id:"INITIALIZED"},DESTROYED:{id:"DESTROYED"}},Gp=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(ze(this,t),(r=Je(this,Ye(t).call(this,n)))._suffix=".xyz",e instanceof Bd)r._info_resource=e;else{if(!e.url)throw new Error("unsupported resource");r._info_resource=new Gd(e.url,e.option)}return r._taskMap=new Map,r._requests=0,r}var r,n,i;return qe(t,e),je(t,[{key:"_createPath",value:function(e,t,r,n){return e+"/"+t+"/"+r+"/"+n+this._suffix}},{key:"doInit",value:(i=Be(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._info_resource.load({type:zd.JSON});case 2:(t=e.sent).url?this._resource=this._info_resource.resolveResource(t.url):this._resource=this._info_resource;case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"doDestroy",value:(n=Be(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"getNumberOfRequests",value:function(){return this._requests}},{key:"doLoad",value:(r=Be(regeneratorRuntime.mark((function e(t,r,n,i,o){var a,s,u,l,_,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._requests++,e.prev=1,a=new AbortController,this._taskMap.set(t,{id:t,abortController:a}),s=this._createPath(r,n,i,o),e.next=7,this._resource.loadSubResource(s,{type:zd.BINARY,signal:a.signal});case 7:return u=e.sent,_=0,(l={}).childFlags=new Uint8Array(u,_,1)[0],_+=1,l.debug1=new Int8Array(u,_,1)[0],_+=1,_+=2,l.indices=new Int32Array(u,_,8),_+=32,l.average=new Float32Array(u,_,3),_+=12,l.eigenVector=[],l.eigenVectorLength=[],l.eigenVector[0]=new Float32Array(u,_,3),_+=12,l.eigenVectorLength[0]=new Float32Array(u,_,1)[0],_+=4,l.eigenVector[1]=new Float32Array(u,_,3),_+=12,l.eigenVectorLength[1]=new Float32Array(u,_,1)[0],_+=4,l.eigenVector[2]=new Float32Array(u,_,3),_+=12,l.eigenVectorLength[2]=new Float32Array(u,_,1)[0],_+=4,console.assert(96==_),c=new Float32Array(u,_),this._taskMap.delete(t),e.abrupt("return",{header:l,body:c});case 37:return e.prev=37,this._requests--,e.finish(37);case 40:case"end":return e.stop()}}),e,this,[[1,,37,40]])}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"cancel",value:function(e){var t=this._taskMap.get(e);t&&t.abortController.abort()}}]),t}(Bp),jp={animation:au,Viewer:Py,Camera:uu,GeoMath:cs,GeoPoint:hs,Orientation:fs,Ray:su,AltitudeMode:Tl,CredentialMode:Zc,Layer:oh,LayerCollection:ah,DemProvider:nh,StandardDemProvider:ih,CloudDemProvider:Sy,ImageProvider:jl,RenderCallback:uh,StandardImageProvider:Jc,Scene:_h,Entity:Il,MarkerLineEntity:kv,PathEntity:wv,TextEntity:Av,ModelEntity:Sv,PolygonEntity:Hv,PinEntity:zy,ImageIconEntity:Zy,SceneLoader:by,GeoJSONLoader:op,URLResource:Gd,MaprayApi:Up,DebugStats:kp,PointCloud:Uc,RawPointCloudProvider:Gp,LogoController:Ty,AttributionController:Iy};window.maprayRequestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame,window.maprayCancelAnimationFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame;var qp=window.performance,Yp=qp&&(qp.now||qp.mozNow||qp.msNow||qp.oNow||qp.webkitNow),Hp=new Date;return window.maprayNow=Yp?function(){return Yp.call(qp)}:function(){return Hp.getTime()},Math.maprayLog2=Math.log2||function(e){return 1.4426950408889634*Math.log(e)},jp}));
