/*

 Copyright 2016 Google Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 Copyright 2017 Google Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 Copyright 2018 Google Inc.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(p,g,c){p!=Array.prototype&&p!=Object.prototype&&(p[g]=c.value)};$jscomp.getGlobal=function(p){return"undefined"!=typeof window&&window===p?p:"undefined"!=typeof global&&null!=global?global:p};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(p){return $jscomp.SYMBOL_PREFIX+(p||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var p=$jscomp.global.Symbol.iterator;p||(p=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[p]&&$jscomp.defineProperty(Array.prototype,p,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(p){var g=0;return $jscomp.iteratorPrototype(function(){return g<p.length?{done:!1,value:p[g++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(p){$jscomp.initSymbolIterator();p={next:p};p[$jscomp.global.Symbol.iterator]=function(){return this};return p};$jscomp.makeIterator=function(p){$jscomp.initSymbolIterator();$jscomp.initSymbol();$jscomp.initSymbolIterator();var g=p[Symbol.iterator];return g?g.call(p):$jscomp.arrayIterator(p)};$jscomp.arrayFromIterator=function(p){for(var g,c=[];!(g=p.next()).done;)c.push(g.value);return c};$jscomp.arrayFromIterable=function(p){return p instanceof Array?p:$jscomp.arrayFromIterator($jscomp.makeIterator(p))};
$jscomp.polyfill=function(p,g,c,u){if(g){c=$jscomp.global;p=p.split(".");for(u=0;u<p.length-1;u++){var n=p[u];n in c||(c[n]={});c=c[n]}p=p[p.length-1];u=c[p];g=g(u);g!=u&&null!=g&&$jscomp.defineProperty(c,p,{configurable:!0,writable:!0,value:g})}};$jscomp.polyfill("Number.isNaN",function(p){return p?p:function(g){return"number"===typeof g&&isNaN(g)}},"es6","es3");
$jscomp.polyfill("Number.isFinite",function(p){return p?p:function(g){return"number"!==typeof g?!1:!isNaN(g)&&Infinity!==g&&-Infinity!==g}},"es6","es3");$jscomp.iteratorFromArray=function(p,g){$jscomp.initSymbolIterator();p instanceof String&&(p+="");var c=0,u={next:function(){if(c<p.length){var n=c++;return{value:g(n,p[n]),done:!1}}u.next=function(){return{done:!0,value:void 0}};return u.next()}};u[Symbol.iterator]=function(){return u};return u};
$jscomp.polyfill("Array.prototype.keys",function(p){return p?p:function(){return $jscomp.iteratorFromArray(this,function(g){return g})}},"es6","es3");$jscomp.polyfill("Number.isInteger",function(p){return p?p:function(g){return Number.isFinite(g)?g===Math.floor(g):!1}},"es6","es3");
$jscomp.polyfill("Array.from",function(p){return p?p:function(g,c,u){$jscomp.initSymbolIterator();c=null!=c?c:function(a){return a};var n=[],q=g[Symbol.iterator];if("function"==typeof q)for(g=q.call(g);!(q=g.next()).done;)n.push(c.call(u,q.value));else{q=g.length;for(var a=0;a<q;a++)n.push(c.call(u,g[a]))}return n}},"es6","es3");$jscomp.owns=function(p,g){return Object.prototype.hasOwnProperty.call(p,g)};
$jscomp.polyfill("WeakMap",function(p){function g(a){$jscomp.owns(a,u)||$jscomp.defineProperty(a,u,{value:{}})}function c(a){var f=Object[a];f&&(Object[a]=function(a){g(a);return f(a)})}if(function(){if(!p||!Object.seal)return!1;try{var a=Object.seal({}),f=Object.seal({}),c=new p([[a,2],[f,3]]);if(2!=c.get(a)||3!=c.get(f))return!1;c.delete(a);c.set(f,4);return!c.has(a)&&4==c.get(f)}catch(v){return!1}}())return p;var u="$jscomp_hidden_"+Math.random().toString().substring(2);c("freeze");c("preventExtensions");
c("seal");var n=0,q=function(a){this.id_=(n+=Math.random()+1).toString();if(a){$jscomp.initSymbol();$jscomp.initSymbolIterator();a=$jscomp.makeIterator(a);for(var f;!(f=a.next()).done;)f=f.value,this.set(f[0],f[1])}};q.prototype.set=function(a,f){g(a);if(!$jscomp.owns(a,u))throw Error("WeakMap key fail: "+a);a[u][this.id_]=f;return this};q.prototype.get=function(a){return $jscomp.owns(a,u)?a[u][this.id_]:void 0};q.prototype.has=function(a){return $jscomp.owns(a,u)&&$jscomp.owns(a[u],this.id_)};q.prototype.delete=
function(a){return $jscomp.owns(a,u)&&$jscomp.owns(a[u],this.id_)?delete a[u][this.id_]:!1};return q},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(p){if(!$jscomp.ASSUME_NO_NATIVE_MAP&&function(){if(!p||!p.prototype.entries||"function"!=typeof Object.seal)return!1;try{var a=Object.seal({x:4}),c=new p($jscomp.makeIterator([[a,"s"]]));if("s"!=c.get(a)||1!=c.size||c.get({x:4})||c.set({x:4},"t")!=c||2!=c.size)return!1;var v=c.entries(),t=v.next();if(t.done||t.value[0]!=a||"s"!=t.value[1])return!1;t=v.next();return t.done||4!=t.value[0].x||"t"!=t.value[1]||!v.next().done?!1:!0}catch(m){return!1}}())return p;$jscomp.initSymbol();
$jscomp.initSymbolIterator();var g=new WeakMap,c=function(a){this.data_={};this.head_=q();this.size=0;if(a){a=$jscomp.makeIterator(a);for(var f;!(f=a.next()).done;)f=f.value,this.set(f[0],f[1])}};c.prototype.set=function(a,c){var f=u(this,a);f.list||(f.list=this.data_[f.id]=[]);f.entry?f.entry.value=c:(f.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:a,value:c},f.list.push(f.entry),this.head_.previous.next=f.entry,this.head_.previous=f.entry,this.size++);return this};c.prototype.delete=
function(a){a=u(this,a);return a.entry&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.data_[a.id],a.entry.previous.next=a.entry.next,a.entry.next.previous=a.entry.previous,a.entry.head=null,this.size--,!0):!1};c.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=q();this.size=0};c.prototype.has=function(a){return!!u(this,a).entry};c.prototype.get=function(a){return(a=u(this,a).entry)&&a.value};c.prototype.entries=function(){return n(this,function(a){return[a.key,
a.value]})};c.prototype.keys=function(){return n(this,function(a){return a.key})};c.prototype.values=function(){return n(this,function(a){return a.value})};c.prototype.forEach=function(a,c){for(var f=this.entries(),l;!(l=f.next()).done;)l=l.value,a.call(c,l[1],l[0],this)};c.prototype[Symbol.iterator]=c.prototype.entries;var u=function(f,c){var l=c&&typeof c;"object"==l||"function"==l?g.has(c)?l=g.get(c):(l=""+ ++a,g.set(c,l)):l="p_"+c;var t=f.data_[l];if(t&&$jscomp.owns(f.data_,l))for(f=0;f<t.length;f++){var m=
t[f];if(c!==c&&m.key!==m.key||c===m.key)return{id:l,list:t,index:f,entry:m}}return{id:l,list:t,index:-1,entry:void 0}},n=function(a,c){var f=a.head_;return $jscomp.iteratorPrototype(function(){if(f){for(;f.head!=a.head_;)f=f.previous;for(;f.next!=f.head;)return f=f.next,{done:!1,value:c(f)};f=null}return{done:!0,value:void 0}})},q=function(){var a={};return a.previous=a.next=a.head=a},a=0;return c},"es6","es3");
$jscomp.checkStringArgs=function(p,g,c){if(null==p)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return p+""};
$jscomp.polyfill("String.prototype.startsWith",function(p){return p?p:function(g,c){var u=$jscomp.checkStringArgs(this,g,"startsWith");g+="";var n=u.length,q=g.length;c=Math.max(0,Math.min(c|0,u.length));for(var a=0;a<q&&c<n;)if(u[c++]!=g[a++])return!1;return a>=q}},"es6","es3");
$jscomp.polyfill("Set",function(p){if(!$jscomp.ASSUME_NO_NATIVE_SET&&function(){if(!p||!p.prototype.entries||"function"!=typeof Object.seal)return!1;try{var c=Object.seal({x:4}),g=new p($jscomp.makeIterator([c]));if(!g.has(c)||1!=g.size||g.add(c)!=g||1!=g.size||g.add({x:4})!=g||2!=g.size)return!1;var n=g.entries(),q=n.next();if(q.done||q.value[0]!=c||q.value[1]!=c)return!1;q=n.next();return q.done||q.value[0]==c||4!=q.value[0].x||q.value[1]!=q.value[0]?!1:n.next().done}catch(a){return!1}}())return p;
$jscomp.initSymbol();$jscomp.initSymbolIterator();var g=function(c){this.map_=new Map;if(c){c=$jscomp.makeIterator(c);for(var g;!(g=c.next()).done;)this.add(g.value)}this.size=this.map_.size};g.prototype.add=function(c){this.map_.set(c,c);this.size=this.map_.size;return this};g.prototype.delete=function(c){c=this.map_.delete(c);this.size=this.map_.size;return c};g.prototype.clear=function(){this.map_.clear();this.size=0};g.prototype.has=function(c){return this.map_.has(c)};g.prototype.entries=function(){return this.map_.entries()};
g.prototype.values=function(){return this.map_.values()};g.prototype.keys=g.prototype.values;g.prototype[Symbol.iterator]=g.prototype.values;g.prototype.forEach=function(c,g){var n=this;this.map_.forEach(function(q){return c.call(g,q,q,n)})};return g},"es6","es3");$jscomp.polyfill("Array.prototype.values",function(p){return p?p:function(){return $jscomp.iteratorFromArray(this,function(g,c){return c})}},"es6","es3");
$jscomp.polyfill("WeakSet",function(p){if(function(){if(!p||!Object.seal)return!1;try{var c=Object.seal({}),g=Object.seal({}),n=new p([c]);if(!n.has(c)||n.has(g))return!1;n.delete(c);n.add(g);return!n.has(c)&&n.has(g)}catch(q){return!1}}())return p;var g=function(c){this.map_=new WeakMap;if(c){$jscomp.initSymbol();$jscomp.initSymbolIterator();c=$jscomp.makeIterator(c);for(var g;!(g=c.next()).done;)this.add(g.value)}};g.prototype.add=function(c){this.map_.set(c,!0);return this};g.prototype.has=function(c){return this.map_.has(c)};
g.prototype.delete=function(c){return this.map_.delete(c)};return g},"es6","es3");$jscomp.findInternal=function(p,g,c){p instanceof String&&(p=String(p));for(var u=p.length,n=0;n<u;n++){var q=p[n];if(g.call(c,q,n,p))return{i:n,v:q}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(p){return p?p:function(g,c){return $jscomp.findInternal(this,g,c).v}},"es6","es3");
$jscomp.polyfill("Object.assign",function(p){return p?p:function(g,c){for(var u=1;u<arguments.length;u++){var n=arguments[u];if(n)for(var q in n)$jscomp.owns(n,q)&&(g[q]=n[q])}return g}},"es6","es3");$jscomp.FORCE_POLYFILL_PROMISE=!1;
$jscomp.polyfill("Promise",function(p){function g(){this.batch_=null}function c(a){return a instanceof n?a:new n(function(f,c){f(a)})}if(p&&!$jscomp.FORCE_POLYFILL_PROMISE)return p;g.prototype.asyncExecute=function(a){null==this.batch_&&(this.batch_=[],this.asyncExecuteBatch_());this.batch_.push(a);return this};g.prototype.asyncExecuteBatch_=function(){var a=this;this.asyncExecuteFunction(function(){a.executeBatch_()})};var u=$jscomp.global.setTimeout;g.prototype.asyncExecuteFunction=function(a){u(a,
0)};g.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var a=this.batch_;this.batch_=[];for(var f=0;f<a.length;++f){var c=a[f];delete a[f];try{c()}catch(v){this.asyncThrow_(v)}}}this.batch_=null};g.prototype.asyncThrow_=function(a){this.asyncExecuteFunction(function(){throw a;})};var n=function(a){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];var f=this.createResolveAndReject_();try{a(f.resolve,f.reject)}catch(l){f.reject(l)}};n.prototype.createResolveAndReject_=
function(){function a(a){return function(l){c||(c=!0,a.call(f,l))}}var f=this,c=!1;return{resolve:a(this.resolveTo_),reject:a(this.reject_)}};n.prototype.resolveTo_=function(a){if(a===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(a instanceof n)this.settleSameAsPromise_(a);else{a:switch(typeof a){case "object":var f=null!=a;break a;case "function":f=!0;break a;default:f=!1}f?this.resolveToNonPromiseObj_(a):this.fulfill_(a)}};n.prototype.resolveToNonPromiseObj_=function(a){var f=
void 0;try{f=a.then}catch(l){this.reject_(l);return}"function"==typeof f?this.settleSameAsThenable_(f,a):this.fulfill_(a)};n.prototype.reject_=function(a){this.settle_(2,a)};n.prototype.fulfill_=function(a){this.settle_(1,a)};n.prototype.settle_=function(a,f){if(0!=this.state_)throw Error("Cannot settle("+a+", "+f|"): Promise already settled in state"+this.state_);this.state_=a;this.result_=f;this.executeOnSettledCallbacks_()};n.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a=
this.onSettledCallbacks_,f=0;f<a.length;++f)a[f].call(),a[f]=null;this.onSettledCallbacks_=null}};var q=new g;n.prototype.settleSameAsPromise_=function(a){var f=this.createResolveAndReject_();a.callWhenSettled_(f.resolve,f.reject)};n.prototype.settleSameAsThenable_=function(a,f){var c=this.createResolveAndReject_();try{a.call(f,c.resolve,c.reject)}catch(v){c.reject(v)}};n.prototype.then=function(a,f){function c(a,e){return"function"==typeof a?function(d){try{v(a(d))}catch(b){t(b)}}:e}var v,t,m=new n(function(a,
e){v=a;t=e});this.callWhenSettled_(c(a,v),c(f,t));return m};n.prototype.catch=function(a){return this.then(void 0,a)};n.prototype.callWhenSettled_=function(a,f){function c(){switch(v.state_){case 1:a(v.result_);break;case 2:f(v.result_);break;default:throw Error("Unexpected state: "+v.state_);}}var v=this;null==this.onSettledCallbacks_?q.asyncExecute(c):this.onSettledCallbacks_.push(function(){q.asyncExecute(c)})};n.resolve=c;n.reject=function(a){return new n(function(f,c){c(a)})};n.race=function(a){return new n(function(f,
l){for(var v=$jscomp.makeIterator(a),t=v.next();!t.done;t=v.next())c(t.value).callWhenSettled_(f,l)})};n.all=function(a){var f=$jscomp.makeIterator(a),l=f.next();return l.done?c([]):new n(function(a,t){function m(d){return function(b){k[d]=b;e--;0==e&&a(k)}}var k=[],e=0;do k.push(void 0),e++,c(l.value).callWhenSettled_(m(k.length-1),t),l=f.next();while(!l.done)})};return n},"es6","es3");$jscomp.polyfill("Math.log2",function(p){return p?p:function(g){return Math.log(g)/Math.LN2}},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(p){return p?p:function(g){var c=$jscomp.checkStringArgs(this,null,"repeat");if(0>g||1342177279<g)throw new RangeError("Invalid count value");g|=0;for(var u="";g;)if(g&1&&(u+=c),g>>>=1)c+=c;return u}},"es6","es3");$jscomp.polyfill("Math.sign",function(p){return p?p:function(g){g=Number(g);return 0===g||isNaN(g)?g:0<g?1:-1}},"es6","es3");
$jscomp.polyfill("Array.prototype.entries",function(p){return p?p:function(){return $jscomp.iteratorFromArray(this,function(g,c){return[g,c]})}},"es6","es3");$jscomp.polyfill("Array.prototype.fill",function(p){return p?p:function(g,c,u){var n=this.length||0;0>c&&(c=Math.max(0,n+c));if(null==u||u>n)u=n;u=Number(u);0>u&&(u=Math.max(0,n+u));for(c=Number(c||0);c<u;c++)this[c]=g;return this}},"es6","es3");
(function(p){function g(u){if(c[u])return c[u].exports;var n=c[u]={i:u,l:!1,exports:{}};p[u].call(n.exports,n,n.exports,g);n.l=!0;return n.exports}var c={};g.m=p;g.c=c;g.d=function(c,n,q){g.o(c,n)||Object.defineProperty(c,n,{configurable:!1,enumerable:!0,get:q})};g.n=function(c){var n=c&&c.__esModule?function(){return c["default"]}:function(){return c};g.d(n,"a",n);return n};g.o=function(c,g){return Object.prototype.hasOwnProperty.call(c,g)};g.p="";return g(g.s=174)})([function(p,g,c){function u(a,
f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a,f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");}function q(a,f,c,k){a.addEventListener(f,c,k);return function(){return a.removeEventListener(f,c,k)}}c.d(g,
"c",function(){return q});c.d(g,"a",function(){return f});c.d(g,"b",function(){return l});var a=function(){function a(a,f){for(var k=0;k<f.length;k++){var e=f[k];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),f=function(){function f(){n(this,f);this.refCount=1}a(f,[{key:"addRef",value:function(){++this.refCount;return this}},{key:"dispose",value:function(){0===--this.refCount&&
this.refCountReachedZero()}},{key:"refCountReachedZero",value:function(){this.disposed();var a=this.disposers;if(null!=a){for(var f=a.length;0<f;--f){var k=a[f-1];"object"===typeof k?k.dispose():k.call(this)}this.disposers=void 0}this.wasDisposed=!0}},{key:"disposed",value:function(){}},{key:"registerDisposer",value:function(a){var f=this.disposers;null==f?this.disposers=[a]:f.push(a);return a}},{key:"unregisterDisposer",value:function(a){var f=this.disposers;if(null!=f){var k=f.indexOf(a);-1!==k&&
f.splice(k,1)}return a}},{key:"registerEventListener",value:function(a,f,k,e){this.registerDisposer(q(a,f,k,e))}},{key:"registerCancellable",value:function(a){this.registerDisposer(function(){a.cancel()});return a}}]);return f}(),l=function(a){function f(a){n(this,f);var k=(f.__proto__||Object.getPrototypeOf(f)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");k=!k||"object"!==typeof k&&"function"!==typeof k?this:k;k.value=a;return k}u(f,a);
return f}(f)},function(p,g,c){function u(a,f){var c=Math.abs(a[f]),v=Math.abs(a[f+1]),t=Math.abs(a[f+2]),m=Math.max(c,v,t);1E-4>c/m&&(a[f]=0);1E-4>v/m&&(a[f+1]=0);1E-4>t/m&&(a[f+2]=0)}c.d(g,"b",function(){return q});g.l=function(a){return a[0]*a[1]*a[2]};g.t=function(a){return a[0]+","+a[1]+","+a[2]};g.o=function(a){u(a,0);u(a,4);u(a,8)};g.p=function(a,f,c){var l=f[0],t=f[1];f=f[2];a[0]=c[0]*l+c[4]*t+c[8]*f;a[1]=c[1]*l+c[5]*t+c[9]*f;a[2]=c[2]*l+c[6]*t+c[10]*f;return a};g.c=function(a,f){var c=f[0],
v=f[1],t=f[2],m=f[4],k=f[5],e=f[6],d=f[8],b=f[9];f=f[10];a[0]=Math.sqrt(c*c+v*v+t*t);a[1]=Math.sqrt(m*m+k*k+e*e);a[2]=Math.sqrt(d*d+b*b+f*f);return a};g.q=function(a,f,c,v,t){a[0]=v[0];a[1]=v[1];a[2]=v[2]*t;return n.b.fromRotationTranslationScale(a,c,f,a)};g.m=function(a,f,c,v){for(var l=n.e.squaredDistance(f,c),m=0,k=0;3>k;++k){var e=f[k];m-=(e-v[k])*(c[k]-e)}v=m/Math.max(l,1E-6);v=Math.max(0,Math.min(1,v));for(l=0;3>l;++l)m=f[l],a[l]=m+v*(c[l]-m);return a};g.j=function(a,f){var c=f[1],v=f[2],t=
f[4],m=f[5],k=f[6],e=f[8],d=f[9],b=f[10];a[0]=f[0];a[1]=c;a[2]=v;a[3]=t;a[4]=m;a[5]=k;a[6]=e;a[7]=d;a[8]=b;return a};var n=c(71);p=c(23);c.d(g,"i",function(){return n.a});c.d(g,"k",function(){return n.b});c.d(g,"n",function(){return n.c});c.d(g,"r",function(){return n.d});c.d(g,"s",function(){return n.e});c.d(g,"u",function(){return n.f});c=n.b.create();g.d=c;g.a=["x","y","z"];var q=function f(c,v){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this.lower=c;this.upper=
v};c=[n.e.fromValues(1,0,0),n.e.fromValues(0,1,0),n.e.fromValues(0,0,1)];g.e=c;c=n.e.fromValues(0,0,0);g.h=c;c=n.e.fromValues(1,1,1);g.g=c;c=n.e.fromValues(Infinity,Infinity,Infinity);g.f=c;n.c.create();new p.a(1227133513,306783378);new p.a(3272356035,818089008);new p.a(251719695,4027515120);new p.a(4278190335,16711680);new p.a(65535,16711680);new p.a(2097151,0)},function(p,g,c){function u(b){var a=typeof b;if("number"===a||"string"===a)if(a=parseFloat(""+b),!Number.isNaN(a))return a;throw Error("Expected floating-point number, but received: "+
JSON.stringify(b)+".");}function n(b){b=u(b);if(Number.isFinite(b))return b;throw Error("Expected finite floating-point number, but received: "+b+".");}function q(b){b=n(b);if(0<b)return b;throw Error("Expected positive finite floating-point number, but received: "+b+".");}function a(b){if("object"===typeof b){if(null===b)return"null";if(Array.isArray(b)){var d="[",h=b.length,e=0;if(e<h)for(d+=a(b[e]);++e<h;)d+=",",d+=a(b[e]);return d+"]"}d="{";h=Object.keys(b).sort();e=0;var f=h.length;if(e<f){var k=
h[e];d+=JSON.stringify(k);for(d=d+":"+a(b[k]);++e<f;)d+=",",k=h[e],d+=JSON.stringify(k),d+=":",d+=a(b[k])}return d+"}"}return JSON.stringify(b)}function f(b){return b.replace(/['"]/g,function(b){return'"'===b?"'":'"'})}function l(b){if("object"===typeof b){if(null===b)return"null";var a=b.toJSON;if("function"===typeof a)return l(a.call(b));if(Array.isArray(b)){a="[";var d=b.length,h=0;if(h<d)for(a+=l(b[h]);++h<d;)a+="_",a+=l(b[h]);return a+"]"}a="{";h=Object.keys(b);d=!0;h=$jscomp.makeIterator(h);
for(var e=h.next();!e.done;e=h.next()){e=e.value;var k=b[e];void 0!==k&&(k=l(k))&&(d?d=!1:a+="_",a+=f(JSON.stringify(f(e))),a+=":",a+=k)}return a+"}"}return"string"===typeof b?f(JSON.stringify(f(b))):JSON.stringify(b)}function v(b,a,d){var h=/[&_,]/g;if('"'===d){var e="'";var f=z;var k=r}else e='"',f=A,k=x;for(var c="";0<b.length;){var m=b.match(k);if(null===m){var l=b;m=b=""}else{l=b.substr(0,m.index);b=b.substr(m.index+m[0].length);var t=m[1];if(void 0!==t){var v=t;m=e;t=d;var g=f;if(2<=v.length&&
v.charAt(0)===m&&v.charAt(v.length-1)===m){v=v.substr(1,v.length-2);for(var y=t;0<v.length;){var E=v.match(g);if(null===E){y+=v;break}y+=E[1];E[2]===t?(y+="\\",y+=t):y+=m;v=v.substr(E.index+E[0].length)}m=y+t}else m=v}else m=m[2]}c+=l.replace(h,a);c+=m}return c}function t(b){return JSON.parse(v(b,",",'"'))}function m(b,a,d){var h=b.length;if(!Array.isArray(a)||a.length!==h)throw Error("Expected length "+h+" array, but received: "+JSON.stringify(a)+".");for(var e=0;e<h;++e)b[e]=d(a[e],e);return b}
function k(b){if("object"!==typeof b||null==b||Array.isArray(b))throw Error("Expected JSON object, but received: "+JSON.stringify(b)+".");return b}function e(b){var a=parseInt(b,10);if(!Number.isInteger(a))throw Error("Expected integer, but received: "+JSON.stringify(b)+".");return a}function d(b){b=e(b);if(0>=b)throw Error("Expected positive integer, but received: "+b+".");return b}function b(b){if("string"!==typeof b)throw Error("Expected string, but received: "+JSON.stringify(b)+".");return b}
g.q=u;g.o=n;g.p=q;g.f=function(b,a,d){d=void 0===d?u:d;k(a);b[0]=b[1]=b[2]=0;for(var h=$jscomp.makeIterator(Object.keys(a)),e=h.next();!e.done;e=h.next())switch(e=e.value,e){case "x":b[0]=d(a[e]);break;case "y":b[1]=d(a[e]);break;case "z":b[2]=d(a[e]);break;default:throw Error("Expected object to have keys ['x', 'y', 'z'], but received: "+JSON.stringify(a)+".");}return b};g.b=function(b,a){var d=b.length;if(!Array.isArray(a)||a.length!==d)throw Error("Incompatible sizes");for(var h=0;h<d;++h)if(!Number.isFinite(parseFloat(a[h])))throw Error("Non-finite value.");
for(h=0;h<d;++h)b[h]=parseFloat(a[h]);return b};g.d=function(b,a){var d=b.length;if(!Array.isArray(a)||a.length!==d)throw Error("Incompatible sizes.");for(var h=0;h<d;++h){var e=parseInt(a[h],void 0);if(!Number.isInteger(e))throw Error("Non-integer value.");}for(h=0;h<d;++h)b[h]=parseInt(a[h],void 0);return b};g.g=a;g.i=l;g.h=t;g.a=function(b,a){if(!Array.isArray(b))throw Error("Expected array, but received: "+JSON.stringify(b)+".");return b.map(a)};g.c=m;g.u=k;g.s=e;g.A=d;g.t=function(b,a){var d=
a.get(b);if(void 0===d)throw Error("Expected one of "+JSON.stringify(Array.from(a.keys()))+", "+("but received: "+JSON.stringify(b)+"."));return d};g.B=b;g.z=function(a){if(void 0!==a)return b(a)};g.y=function(b){if(void 0!==b)return e(b)};g.x=function(b){if(void 0!==b){if("boolean"===typeof b)return b;if("true"===b)return!0;if("false"===b)return!1;throw Error("Expected string or boolean but received: "+JSON.stringify(b));}};g.w=function(b,a,d){b=b.hasOwnProperty(a)?b[a]:void 0;try{return d(b)}catch(G){throw Error("Error parsing "+
JSON.stringify(a)+" property: "+G.message);}};g.v=function(b,a){k(b);for(var d=new Map,h=$jscomp.makeIterator(Object.keys(b)),e=h.next();!e.done;e=h.next()){e=e.value;try{d.set(e,a(b[e]))}catch(B){throw Error("Error parsing value associated with key "+JSON.stringify(e)+": "+B.message);}}return d};g.r=function(b){if("number"!==typeof b||!Number.isFinite(b)||0>b||1<b)throw Error("Expected floating point number in [0,1], but received: "+JSON.stringify(b)+".");return b};g.e=function(b){if(""===b)return{};
if(b.startsWith("{"))return t(b);var a={};b=b.split(/[&;]/);b=$jscomp.makeIterator(b);for(var d=b.next();!d.done;d=b.next()){d=d.value;var h=d.match(/^([^=&;]+)=([^&;]*)$/);if(null===h)throw Error("Invalid query string part: "+JSON.stringify(d)+".");a[h[1]]=decodeURIComponent(h[2])}return a};g.n=function(b,a){if("string"===typeof b&&null!==b.match(/^[a-zA-Z]/)&&(b=b.toUpperCase(),a.hasOwnProperty(b)))return a[b];throw Error("Invalid enum value: "+JSON.stringify(b)+".");};g.l=function(b){return m(h.s.create(),
b,n)};g.k=function(b){return m(h.s.create(),b,q)};g.j=function(b){return m(h.s.create(),b,d)};g.C=function(b){if(!Array.isArray(b))throw Error("Expected array, received: "+JSON.stringify(b)+".");for(var a=$jscomp.makeIterator(b),d=a.next();!d.done;d=a.next())if(d=d.value,"string"!==typeof d)throw Error("Expected string, received: "+JSON.stringify(d)+".");return b};g.m=function(b){if("boolean"!==typeof b)throw Error("Expected boolean, received: "+JSON.stringify(b));return b};var h=c(1);p=/('(?:[^'\\]|(?:\\.))*')/;
g=/("(?:[^'\\]|(?:\\.))*")/;var r=new RegExp(p.source+"|"+g.source),x=new RegExp(g.source+"|"+p.source),z=/^((?:[^"'\\]|(?:\\[^']))*)("|\\')/,A=/^((?:[^"'\\]|(?:\\.))*)'/},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=
f)}function n(a,f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");}c.d(g,"b",function(){return a});c.d(g,"a",function(){return f});var q=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,m){c&&a(f.prototype,c);m&&a(f,m);return f}}(),a=function(){function a(){n(this,a);this.handlers=new Set;this.count=0;var f=this;this.dispatch=
function(){var a=this,c=arguments;++f.count;f.handlers.forEach(function(f){f.apply(a,c)})}}q(a,[{key:"add",value:function(a){var f=this;this.handlers.add(a);return function(){return f.remove(a)}}},{key:"remove",value:function(a){return this.handlers.delete(a)}},{key:"dispose",value:function(){this.handlers=void 0}}]);return a}(),f=function(a){function f(){n(this,f);var a=(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(f,a);return f}(a)},function(p,g){p.exports="function"===typeof Object.create?function(c,g){c.super_=g;c.prototype=Object.create(g.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}})}:function(c,g){c.super_=g;var n=function(){};n.prototype=g.prototype;c.prototype=new n;c.prototype.constructor=c}},function(p,g,c){function u(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function n(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function q(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}c.d(g,"f",function(){return v});c.d(g,
"c",function(){return t});g.g=function(b,a){for(var d=[],h=1;h<arguments.length;++h)d[h-1]=arguments[h];return new m(b,d)};c.d(g,"a",function(){return k});c.d(g,"d",function(){return e});c.d(g,"b",function(){return d});c.d(g,"e",function(){return b});p=c(0);var a=c(3),f=function r(b,a,d){null===b&&(b=Function.prototype);var e=Object.getOwnPropertyDescriptor(b,a);if(void 0===e){if(b=Object.getPrototypeOf(b),null!==b)return r(b,a,d)}else{if("value"in e)return e.value;a=e.get;return void 0===a?void 0:
a.call(d)}},l=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),v=function(){function b(d){q(this,b);this.value_=d;this.changed=new a.a}l(b,[{key:"value",get:function(){return this.value_},set:function(b){b!==this.value_&&(this.value_=b,this.changed.dispatch())}}]);return b}(),t=function(b){function a(b,d,e){e=
void 0===e?b:e;q(this,a);b=u(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,b));b.validator=d;b.defaultValue=e;return b}n(a,b);l(a,[{key:"toJSON",value:function(){if(this.value_!==this.defaultValue)return this.value_}},{key:"reset",value:function(){this.value=this.defaultValue}},{key:"restoreState",value:function(b){if(void 0!==b){var a=this.validator;try{this.value=a(b);return}catch(D){}}this.value=this.defaultValue}}]);return a}(v),m=function(b){function d(b,e){q(this,d);var f=u(this,(d.__proto__||
Object.getPrototypeOf(d)).call(this));f.changed=new a.a;f.f=b;f.ws=e;b=$jscomp.makeIterator(e);for(e=b.next();!e.done;e=b.next())f.registerDisposer(e.value.changed.add(f.changed.dispatch));return f}n(d,b);l(d,[{key:"value",get:function(){return this.f.apply(this,[].concat($jscomp.arrayFromIterable(this.ws.map(function(b){return b.value}))))}}]);return d}(p.a),k=function(b){function d(b,e){for(var f=[],k=1;k<arguments.length;++k)f[k-1]=arguments[k];q(this,d);k=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));
k.f=b;k.changed=new a.a;f=$jscomp.makeIterator(f);for(var c=f.next();!c.done;c=f.next())k.registerDisposer(c.value.add(k.changed.dispatch));return k}n(d,b);l(d,[{key:"value",get:function(){return this.f()}}]);return d}(p.a),e=function(b){function d(){q(this,d);var b=u(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments));b.changed=new a.a;return b}n(d,b);l(d,[{key:"reset",value:function(){this.value=void 0}},{key:"disposed",value:function(){void 0!==this.value_&&this.value_.dispose();
this.value_=void 0;f(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}},{key:"value",get:function(){return this.value_},set:function(b){var a=this,d=this.value_;this.value_=b;void 0!==d&&(d.dispose(),this.valueHandler=void 0);if(void 0!==b){var e=this.valueHandler=function(){a.value_===b&&(a.value_=void 0,a.changed.dispatch())};b.registerDisposer(e)}b!==d&&this.changed.dispatch()}}]);return d}(p.a),d=function(b){function a(b,d){q(this,a);var e=u(this,(a.__proto__||
Object.getPrototypeOf(a)).call(this));e.validator=b;e.jsonConverter=d;return e}n(a,b);l(a,[{key:"toJSON",value:function(){var b=this.value;return b&&this.jsonConverter(b)}},{key:"restoreState",value:function(b){this.value=this.validator(b)}}]);return a}(e),b=function(){function b(d){q(this,b);this.changed=new a.a;this.values=void 0===d?new Set:new Set(d)}$jscomp.initSymbol();$jscomp.initSymbolIterator();l(b,[{key:"add",value:function(b){var a=this.values;a.has(b)||(a.add(b),this.changed.dispatch());
return this}},{key:"delete",value:function(b){return this.values.delete(b)?(this.changed.dispatch(),!0):!1}},{key:"has",value:function(b){return this.values.has(b)}},{key:Symbol.iterator,value:function(){$jscomp.initSymbol();$jscomp.initSymbolIterator();return this.values[Symbol.iterator]()}},{key:"clear",value:function(){var b=this.values;0<b.size&&(b.clear(),this.changed.dispatch())}},{key:"size",get:function(){return this.values.size}}]);return b}()},function(p,g,c){var u=c(73),n=c(183),q=c(185),
a=Math.max,f=Math.min;p.exports=function(c,g,t){function m(b){var a=h,d=r;h=r=void 0;D=b;return x=c.apply(d,a)}function k(b){var a=b-v;b-=D;return void 0===v||a>=g||0>a||E&&b>=H}function e(){var b=n();if(k(b))return d(b);var a=setTimeout;var h=b-D;b=g-(b-v);h=E?f(b,H-h):b;l=a(e,h)}function d(b){l=void 0;if(G&&h)return m(b);h=r=void 0;return x}function b(){var b=n(),a=k(b);h=arguments;r=this;v=b;if(a){if(void 0===l)return D=b=v,l=setTimeout(e,g),y?m(b):x;if(E)return l=setTimeout(e,g),m(v)}void 0===
l&&(l=setTimeout(e,g));return x}var h,r,x,l,v,D=0,y=!1,E=!1,G=!0;if("function"!=typeof c)throw new TypeError("Expected a function");g=q(g)||0;if(u(t)){y=!!t.leading;var H=(E="maxWait"in t)?a(q(t.maxWait)||0,g):H;G="trailing"in t?!!t.trailing:G}b.cancel=function(){void 0!==l&&clearTimeout(l);D=0;h=v=r=l=void 0};b.flush=function(){return void 0===l?x:d(n())};return b}},function(p,g){g=function(){return this}();try{g=g||Function("return this")()||(0,eval)("this")}catch(c){"object"===typeof window&&(g=
window)}p.exports=g},function(p,g){function c(){throw Error("setTimeout has not been defined");}function u(){throw Error("clearTimeout has not been defined");}function n(b){if(t===setTimeout)return setTimeout(b,0);if((t===c||!t)&&setTimeout)return t=setTimeout,setTimeout(b,0);try{return t(b,0)}catch(r){try{return t.call(null,b,0)}catch(x){return t.call(this,b,0)}}}function q(b){if(m===clearTimeout)return clearTimeout(b);if((m===u||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(b);try{return m(b)}catch(r){try{return m.call(null,
b)}catch(x){return m.call(this,b)}}}function a(){e&&d&&(e=!1,d.length?k=d.concat(k):b=-1,k.length&&f())}function f(){if(!e){var h=n(a);e=!0;for(var f=k.length;f;){d=k;for(k=[];++b<f;)d&&d[b].run();b=-1;f=k.length}d=null;e=!1;q(h)}}function l(b,a){this.fun=b;this.array=a}function v(){}p=p.exports={};try{var t="function"===typeof setTimeout?setTimeout:c}catch(h){t=c}try{var m="function"===typeof clearTimeout?clearTimeout:u}catch(h){m=u}var k=[],e=!1,d,b=-1;p.nextTick=function(b){var a=Array(arguments.length-
1);if(1<arguments.length)for(var d=1;d<arguments.length;d++)a[d-1]=arguments[d];k.push(new l(b,a));1!==k.length||e||n(f)};l.prototype.run=function(){this.fun.apply(null,this.array)};p.title="browser";p.browser=!0;p.env={};p.argv=[];p.version="";p.versions={};p.on=v;p.addListener=v;p.once=v;p.off=v;p.removeListener=v;p.removeAllListeners=v;p.emit=v;p.prependListener=v;p.prependOnceListener=v;p.listeners=function(b){return[]};p.binding=function(b){throw Error("process.binding is not supported");};p.cwd=
function(){return"/"};p.chdir=function(b){throw Error("process.chdir is not supported");};p.umask=function(){return 0}},function(p,g,c){(function(u){function n(){try{var a=g.storage.debug}catch(l){}!a&&"undefined"!==typeof u&&"env"in u&&(a=u.env.DEBUG);return a}g=p.exports=c(316);g.log=function(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)};g.formatArgs=function(a){var f=this.useColors;a[0]=(f?"%c":"")+this.namespace+(f?" %c":" ")+a[0]+
(f?"%c ":" ")+"+"+g.humanize(this.diff);if(f){f="color: "+this.color;a.splice(1,0,f,"color: inherit");var c=0,t=0;a[0].replace(/%[a-zA-Z%]/g,function(a){"%%"!==a&&(c++,"%c"===a&&(t=c))});a.splice(t,0,f)}};g.save=function(a){try{null==a?g.storage.removeItem("debug"):g.storage.debug=a}catch(l){}};g.load=n;g.useColors=function(){return"undefined"!==typeof window&&window.process&&"renderer"===window.process.type?!0:"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&
document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)};var q=g;if("undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage)var a=
chrome.storage.local;else a:{try{a=window.localStorage;break a}catch(f){}a=void 0}q.storage=a;g.colors="lightseagreen forestgreen goldenrod dodgerblue darkorchid crimson".split(" ");g.formatters.j=function(a){try{return JSON.stringify(a)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}};g.enable(n())}).call(g,c(8))},function(p,g,c){g.a=function(c){for(;;){var g=c.firstElementChild;if(!g)break;c.removeChild(g)}};g.b=function(c){var g=c.parentElement;return g?(g.removeChild(c),!0):!1}},function(p,
g,c){g.d=16384;g.C=4;g.D=6;g.J=0;g.o=1;g.u=770;g.p=771;g.a=34962;g.f=34963;g.v=35044;g.b=3042;g.e=2929;g.t=3089;g.q=32823;g.E=3317;g.G=5121;g.H=5123;g.g=5126;g.r=6407;g.s=6408;g.l=6409;g.m=6410;g.h=35632;g.I=35633;g.j=513;g.i=515;g.n=9728;g.k=9729;g.y=10240;g.z=10241;g.A=10242;g.B=10243;g.x=3553;g.w=33984;g.c=33071;g.F=37440},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function a(b,a){m.set(b,a)}g.e=a;g.d=function(b,d){a(b,function(b){var a=this,e=b.id,h=new f.b;b=d.call(this,b,h);this.set(e,{promise:b,
cancellationToken:h});b.then(function(b){var d=b.value;b=b.transfers;a.delete(e);a.invoke("rpc.promise.response",{id:e,value:d},b)},function(b){a.delete(e);a.invoke("rpc.promise.response",{id:e,error:b.message,errorName:b.name})})})};c.d(g,"a",function(){return d});c.d(g,"b",function(){return b});c.d(g,"c",function(){return h});g.g=function(b){return function(a){a.prototype.RPC_TYPE_ID=b}};g.f=function(b){return function(a){if(void 0!==b)a.prototype.RPC_TYPE_ID=b;else if(b=a.prototype.RPC_TYPE_ID,
void 0===b)throw Error("RPC_TYPE_ID should have already been defined");r.set(b,a)}};var f=c(34);p=c(0);var l=function z(b,a,d){null===b&&(b=Function.prototype);var e=Object.getOwnPropertyDescriptor(b,a);if(void 0===e){if(b=Object.getPrototypeOf(b),null!==b)return z(b,a,d)}else{if("value"in e)return e.value;a=e.get;return void 0===a?void 0:a.call(d)}},v=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,
e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),t=!("undefined"!==typeof Window&&self instanceof Window),m=new Map,k=function(b){function a(b,d){u(this,a);var e=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,d));e.name=b;e.message=d;return e}q(a,b);return a}(Error);a("rpc.promise.cancel",function(b){this.get(b.id).cancellationToken.cancel()});a("rpc.promise.response",function(b){var a=b.id,d=this.get(a),e=d.resolve;d=d.reject;this.delete(a);b.hasOwnProperty("value")?
e(b.value):b.errorName===f.a.name?d(f.a):d(new k(b.errorName,b.error))});var e=t?-1:0,d=function(){function b(a){var d=this;u(this,b);this.target=a;this.objects=new Map;this.nextId=e;a.onmessage=function(b){b=b.data;m.get(b.functionName).call(d,b)}}v(b,[{key:"set",value:function(b,a){this.objects.set(b,a)}},{key:"delete",value:function(b){this.objects.delete(b)}},{key:"get",value:function(b){return this.objects.get(b)}},{key:"getRef",value:function(b){var a=this.get(b.id);a.referencedGeneration=b.gen;
a.addRef();return a}},{key:"invoke",value:function(b,a,d){a.functionName=b;this.target.postMessage(a,d)}},{key:"promiseInvoke",value:function(b,a,d,e){var h=this;d=void 0===d?f.e:d;return Object(f.d)(d,function(d,f,c){var k=a.id=h.newId();h.set(k,{resolve:d,reject:f});h.invoke(b,a,e);c.add(function(){h.invoke("rpc.promise.cancel",{id:k})})})}},{key:"newId",value:function(){return t?this.nextId--:this.nextId++}},{key:"numObjects",get:function(){return this.objects.size}}]);return b}(),b=function(b){function a(){u(this,
a);var b=n(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments));b.rpc=null;b.rpcId=null;return b}q(a,b);v(a,[{key:"initializeSharedObject",value:function(b,a){a=void 0===a?b.newId():a;this.rpc=b;this.rpcId=a;this.isOwner=!1;b.set(a,this)}},{key:"initializeCounterpart",value:function(b,a){a=void 0===a?{}:a;this.initializeSharedObject(b);this.referencedGeneration=this.unreferencedGeneration=0;this.isOwner=!0;a.id=this.rpcId;a.type=this.RPC_TYPE_ID;b.invoke("SharedObject.new",a)}},{key:"dispose",
value:function(){l(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"dispose",this).call(this)}},{key:"addCounterpartRef",value:function(){return{id:this.rpcId,gen:++this.referencedGeneration}}},{key:"refCountReachedZero",value:function(){!0===this.isOwner?this.referencedGeneration===this.unreferencedGeneration&&this.ownerDispose():!1===this.isOwner?this.rpc.invoke("SharedObject.refCountReachedZero",{id:this.rpcId,gen:this.referencedGeneration}):l(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),
"refCountReachedZero",this).call(this)}},{key:"ownerDispose",value:function(){var b=this.rpc,d=this.rpcId;l(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"refCountReachedZero",this).call(this);b.delete(d);b.invoke("SharedObject.dispose",{id:d})}},{key:"counterpartRefCountReachedZero",value:function(b){this.unreferencedGeneration=b;0===this.refCount&&b===this.referencedGeneration&&this.ownerDispose()}}]);return a}(p.a),h=function(b){function a(b,d){d=void 0===d?{}:d;u(this,a);var e=n(this,
(a.__proto__||Object.getPrototypeOf(a)).call(this));d=void 0===d?{}:d;null!=b&&e.initializeSharedObject(b,d.id);return e}q(a,b);return a}(b);a("SharedObject.dispose",function(b){b=this.get(b.id);if(0!==b.refCount)throw Error("Attempted to dispose object with non-zero reference count.");b.disposed();this.delete(b.rpcId);b.rpcId=null;b.rpc=null});a("SharedObject.refCountReachedZero",function(b){this.get(b.id).counterpartRefCountReachedZero(b.gen)});var r=new Map;a("SharedObject.new",function(b){--(new (r.get(b.type))(this,
b)).refCount})},function(p,g,c){function u(){n.call(this)}g=c(4);var n=c(159);g(u,n);u.prototype.removeAllListeners=function(c){c?delete this._listeners[c]:this._listeners={}};u.prototype.once=function(c,a){function f(){l.removeListener(c,f);g||(g=!0,a.apply(this,arguments))}var l=this,g=!1;this.on(c,f)};u.prototype.emit=function(){var c=this._listeners[arguments[0]];if(c){for(var a=arguments.length,f=Array(a-1),l=1;l<a;l++)f[l-1]=arguments[l];for(a=0;a<c.length;a++)c[a].apply(this,f)}};u.prototype.on=
u.prototype.addListener=n.prototype.addEventListener;u.prototype.removeListener=n.prototype.removeEventListener;p.exports.EventEmitter=u},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+
typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}c.d(g,"f",function(){return z});g.j=function(){return new l.e([z.DATA,z.ANNOTATION,z.DEFAULT_ANNOTATION])};c.d(g,"e",function(){return A});c.d(g,"i",function(){return D});c.d(g,"h",function(){return y});c.d(g,"c",function(){return E});c.d(g,"a",function(){return G});c.d(g,"d",function(){return H});c.d(g,"b",function(){return B});
g.k=function(b,a,d,e,h){return e.registerDisposer(new C(b,a,d,function(b){var a=b.redrawNeeded.add(function(){return e.scheduleRedraw()}),d=h&&h(b);e.scheduleRedraw();return function(){void 0!==d&&d();a();e.scheduleRedraw()}},e.visibility))};c.d(g,"g",function(){return F});p=c(6);var a=c.n(p);p=c(109);var f=c.n(p),l=c(5),v=c(110);p=c(0);var t=c(1),m=c(2),k=c(3),e=c(191),d=c(23),b=c(26),h=c(35),r=function I(b,a,d){null===b&&(b=Function.prototype);var e=Object.getOwnPropertyDescriptor(b,a);if(void 0===
e){if(b=Object.getPrototypeOf(b),null!==b)return I(b,a,d)}else{if("value"in e)return e.value;a=e.get;return void 0===a?void 0:a.call(d)}},x=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),z;(function(b){b[b.DATA=0]="DATA";b[b.ANNOTATION=1]="ANNOTATION";b[b.DEFAULT_ANNOTATION=2]="DEFAULT_ANNOTATION"})(z||(z=
{}));var A=function(b){function a(){u(this,a);var b=n(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments));b.ready=!1;b.role=z.DATA;b.layerChanged=new k.a;b.redrawNeeded=new k.a;b.readyStateChanged=new k.a;b.voxelSize=null;b.boundingBox=null;return b}q(a,b);x(a,[{key:"setReady",value:function(b){this.ready=b;this.readyStateChanged.dispatch();this.layerChanged.dispatch()}},{key:"handleAction",value:function(b){}},{key:"getValueAt",value:function(b){}},{key:"transformPickedValue",value:function(b,
a){return b}},{key:"updateMouseState",value:function(b,a,d,e){}}]);return a}(p.a),D=function(a){function d(){u(this,d);var a=n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments));a.visibility=new b.a;return a}q(d,a);return d}(A),y=function(b){function a(b,d){u(this,a);var e=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));e.manager=b;e.layersChanged=new k.a;e.readyStateChanged=new k.a;e.specificationChanged=new k.a;e.renderLayers=[];e.isReady=!1;e.tabs=e.registerDisposer(new h.c);
e.tool=e.registerDisposer(new l.b(function(b){return Object(v.c)(e,b)},function(b){return b.toJSON()}));d;e.tabs.changed.add(e.specificationChanged.dispatch);e.tool.changed.add(e.specificationChanged.dispatch);return e}q(a,b);x(a,[{key:"restoreState",value:function(b){this.tool.restoreState(b.tool);this.tabs.restoreState(b.tab)}},{key:"addRenderLayer",value:function(b){this.renderLayers.push(b);var a=this.layersChanged,d=this.readyStateChanged;this.registerDisposer(b);this.registerDisposer(b.layerChanged.add(a.dispatch));
this.registerDisposer(b.readyStateChanged.add(d.dispatch));d.dispatch();a.dispatch()}},{key:"getValueAt",value:function(b,a){var d=this.renderLayers,e=a.pickedRenderLayer;if(null!==e&&-1!==d.indexOf(e)){var h=e.transformPickedValue(a.pickedValue,a.pickedOffset);return this.transformPickedValue(h)}a=$jscomp.makeIterator(d);for(d=a.next();!d.done&&(d=d.value,!d.ready||(h=d.getValueAt(b),void 0===h));d=a.next());return this.transformPickedValue(h)}},{key:"transformPickedValue",value:function(b){return b}},
{key:"toJSON",value:function(){var b={};return b.tab=this.tabs.toJSON(),b.tool=this.tool.toJSON(),b}},{key:"handleAction",value:function(b){}}]);return a}(p.a),E=function(b){function a(b,d,e){d=void 0===d?null:d;e=void 0===e?!0:e;u(this,a);var h=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));h.visible=e;h.readyStateChanged=new k.a;h.layerChanged=new k.a;h.specificationChanged=new k.a;h.wasDisposed=!1;h.layer_=null;h.name_=b;h.layer=d;return h}q(a,b);x(a,[{key:"isReady",value:function(){var b=
this.layer;return null!==b&&b.isReady}},{key:"handleLayerChanged",value:function(){this.visible&&this.layerChanged.dispatch()}},{key:"setVisible",value:function(b){b!==this.visible&&(this.visible=b,this.layerChanged.dispatch())}},{key:"disposed",value:function(){this.wasDisposed=!0;this.layer=null;r(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"disposed",this).call(this)}},{key:"layer",get:function(){return this.layer_},set:function(b){var a=this,d=this.layer_;null!=d&&(this.unregisterUserLayer(),
d.dispose());this.layer_=b;if(null!=b){var e=[b.layersChanged.add(function(){return a.handleLayerChanged()}),b.readyStateChanged.add(this.readyStateChanged.dispatch),b.specificationChanged.add(this.specificationChanged.dispatch)];this.unregisterUserLayer=function(){e.forEach(function(b){return b()})};this.readyStateChanged.dispatch();this.handleLayerChanged()}}},{key:"name",get:function(){return this.name_},set:function(b){b!==this.name_&&(this.name_=b,this.layerChanged.dispatch())}}]);return a}(p.a),
G=function(b){function d(){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));b.managedLayers=[];b.layerSet=new Set;b.layersChanged=new k.a;b.readyStateChanged=new k.a;b.specificationChanged=new k.a;b.boundPositions=new WeakSet;b.numDirectUsers=0;b.renderLayerToManagedLayerMapGeneration=-1;b.renderLayerToManagedLayerMap_=new Map;b.scheduleRemoveLayersWithSingleRef=b.registerCancellable(a()(function(){return b.removeLayersWithSingleRef()},0));b.layersChanged.add(b.scheduleRemoveLayersWithSingleRef);
return b}q(d,b);x(d,[{key:"filter",value:function(b){var a=this,d=!1;this.managedLayers=this.managedLayers.filter(function(e){return b(e)?!0:(a.unbindManagedLayer(e),a.layerSet.delete(e),d=!0,!1)});d&&this.layersChanged.dispatch()}},{key:"removeLayersWithSingleRef",value:function(){0<this.numDirectUsers||this.filter(function(b){return 1!==b.refCount})}},{key:"updateSignalBindings",value:function(b,a){a(b.layerChanged,this.layersChanged.dispatch);a(b.readyStateChanged,this.readyStateChanged.dispatch);
a(b.specificationChanged,this.specificationChanged.dispatch)}},{key:"useDirectly",value:function(){var b=this;1===++this.numDirectUsers&&this.layersChanged.remove(this.scheduleRemoveLayersWithSingleRef);return function(){0===--b.numDirectUsers&&(b.layersChanged.add(b.scheduleRemoveLayersWithSingleRef),b.scheduleRemoveLayersWithSingleRef())}}},{key:"addManagedLayer",value:function(b,a){this.updateSignalBindings(b,e.a);this.layerSet.add(b);void 0===a&&(a=this.managedLayers.length);this.managedLayers.splice(a,
0,b);this.layersChanged.dispatch();this.readyStateChanged.dispatch();return b}},{key:"addUserLayer",value:function(b,a,d){b=new E(b,a,d);return this.addManagedLayer(b)}},{key:"readyRenderLayers",value:function(){function b(b,m){for(;;)switch(a){case 0:k=$jscomp.makeIterator(r.managedLayers),c=k.next();case 1:if(c.done){a=3;break}f=c.value;if(f.visible&&f.layer){a=4;break}a=2;break;case 4:h=$jscomp.makeIterator(f.layer.renderLayers),e=h.next();case 5:if(e.done){a=7;break}d=e.value;if(d.ready){a=8;
break}a=6;break;case 8:return a=9,{value:d,done:!1};case 9:if(void 0===m){a=10;break}a=-1;throw m;case 10:case 6:e=h.next();a=5;break;case 7:case 2:c=k.next();a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,d,e,h,f,c,k,r=this,m={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(b){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();m[Symbol.iterator]=function(){return this};return m}},{key:"unbindManagedLayer",value:function(b){this.updateSignalBindings(b,
e.b);b.dispose()}},{key:"clear",value:function(){for(var b=$jscomp.makeIterator(this.managedLayers),a=b.next();!a.done;a=b.next())this.unbindManagedLayer(a.value);this.managedLayers.length=0;this.layerSet.clear();this.layersChanged.dispatch()}},{key:"remove",value:function(b){var a=this.managedLayers[b];this.unbindManagedLayer(a);this.managedLayers.splice(b,1);this.layerSet.delete(a);this.layersChanged.dispatch()}},{key:"removeManagedLayer",value:function(b){b=this.managedLayers.indexOf(b);if(-1===
b)throw Error("Internal error: invalid managed layer.");this.remove(b)}},{key:"reorderManagedLayer",value:function(b,a){var d=this.managedLayers.length;b===a||0>b||b>=d||0>a||a>=d||(b=$jscomp.makeIterator(this.managedLayers.splice(b,1)).next().value,this.managedLayers.splice(a,0,b),this.layersChanged.dispatch())}},{key:"disposed",value:function(){this.clear();r(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}},{key:"getLayerByName",value:function(b){return this.managedLayers.find(function(a){return a.name===
b})}},{key:"getUniqueLayerName",value:function(b){for(var a=b,d=0;void 0!==this.getLayerByName(a);)a=b+ ++d;return a}},{key:"has",value:function(b){return this.layerSet.has(b)}},{key:"initializePosition",value:function(b){var d=this,e=this.boundPositions;e.has(b)||(e.add(b),e=a()(function(){d.updatePositionFromLayers(b)}),this.readyStateChanged.add(e),b.changed.add(e),this.updatePositionFromLayers(b))}},{key:"updatePositionFromLayers",value:function(b){if(!b.valid)for(var a=$jscomp.makeIterator(this.managedLayers),
d=a.next();!d.done;d=a.next())if(d=d.value.layer,null!=d){d=$jscomp.makeIterator(d.renderLayers);for(var e=d.next();!e.done;e=d.next())if(e=e.value,e.ready&&(b.voxelSize.valid||null==e.voxelSize||(t.s.copy(b.voxelSize.size,e.voxelSize),b.voxelSize.setValid()),!b.spatialCoordinatesValid&&!b.voxelCoordinatesValid&&null!=e.boundingBox)){e=e.boundingBox;var h=b.spatialCoordinates;t.s.add(h,e.lower,e.upper);t.s.scale(h,h,.5);b.spatialCoordinatesValid=!0;b.changed.dispatch()}}}},{key:"invokeAction",value:function(b){for(var a=
$jscomp.makeIterator(this.managedLayers),d=a.next();!d.done;d=a.next())if(d=d.value,null!==d.layer&&d.visible){d=d.layer;d.handleAction(b);d=$jscomp.makeIterator(d.renderLayers);for(var e=d.next();!e.done;e=d.next())e=e.value,e.ready&&e.handleAction(b)}}},{key:"renderLayerToManagedLayerMap",get:function(){var b=this.layersChanged.count,a=this.renderLayerToManagedLayerMap_;if(this.renderLayerToManagedLayerMapGeneration!==b){this.renderLayerToManagedLayerMapGeneration=b;a.clear();b=$jscomp.makeIterator(this.managedLayers);
for(var d=b.next();!d.done;d=b.next()){d=d.value;var e=d.layer;if(null!==e){e=$jscomp.makeIterator(e.renderLayers);for(var h=e.next();!h.done;h=e.next())a.set(h.value,d)}}}return a}},{key:"renderLayers",get:function(){var b=this;$jscomp.initSymbol();$jscomp.initSymbolIterator();var a={};return a[Symbol.iterator]=function(){function a(a,m){for(;;)switch(d){case 0:r=$jscomp.makeIterator(b.managedLayers),k=r.next();case 1:if(k.done){d=3;break}c=k.value;if(null!==c.layer){d=4;break}d=2;break;case 4:f=
$jscomp.makeIterator(c.layer.renderLayers),h=f.next();case 5:if(h.done){d=7;break}e=h.value;d=8;return{value:e,done:!1};case 8:if(void 0===m){d=9;break}d=-1;throw m;case 9:case 6:h=f.next();d=5;break;case 7:case 2:k=r.next();d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,e,h,f,c,k,r,m={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(b){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();m[Symbol.iterator]=function(){return this};
return m},a}},{key:"visibleRenderLayers",get:function(){var b=this;$jscomp.initSymbol();$jscomp.initSymbolIterator();var a={};return a[Symbol.iterator]=function(){function a(a,m){for(;;)switch(d){case 0:r=$jscomp.makeIterator(b.managedLayers),k=r.next();case 1:if(k.done){d=3;break}c=k.value;if(null!==c.layer&&c.visible){d=4;break}d=2;break;case 4:f=$jscomp.makeIterator(c.layer.renderLayers),h=f.next();case 5:if(h.done){d=7;break}e=h.value;d=8;return{value:e,done:!1};case 8:if(void 0===m){d=9;break}d=
-1;throw m;case 9:case 6:h=f.next();d=5;break;case 7:case 2:k=r.next();d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,e,h,f,c,k,r,m={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(b){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();m[Symbol.iterator]=function(){return this};return m},a}}]);return d}(p.a),H=function(){function b(){var a=this;u(this,b);this.changed=new k.a;this.position=t.s.create();this.active=!1;this.pickedRenderLayer=
null;this.pickedValue=new d.a(0,0);this.pickedOffset=0;this.updater=this.pickedAnnotationId=this.pickedAnnotationLayer=void 0;this.stale=!1;this.triggerUpdate=f()(function(){a.update()},50,{leading:!0,trailing:!0})}x(b,[{key:"updateUnconditionally",value:function(){this.triggerUpdate.cancel();this.update();return this.active}},{key:"updateIfStale",value:function(){this.stale&&this.update()}},{key:"update",value:function(){var b=this.updater;this.stale=!1;b?this.setActive(b(this)):this.setActive(!1)}},
{key:"setActive",value:function(b){this.stale=!1;if(this.active!==b||!0===b)this.active=b,this.changed.dispatch()}}]);return b}(),B=function(b){function a(b,d){u(this,a);var e=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));e.layerManager=b;e.mouseState=d;e.values=new Map;e.changed=new k.a;e.needsUpdate=!0;e.registerDisposer(d.changed.add(function(){e.handleChange()}));e.registerDisposer(b.layersChanged.add(function(){e.handleLayerChange()}));return e}q(a,b);x(a,[{key:"handleLayerChange",
value:function(){this.mouseState.active&&this.handleChange()}},{key:"handleChange",value:function(){this.needsUpdate=!0;this.changed.dispatch()}},{key:"update",value:function(){if(this.needsUpdate){this.needsUpdate=!1;var b=this.values,a=this.mouseState;b.clear();if(a.active)for(var d=a.position,e=$jscomp.makeIterator(this.layerManager.managedLayers),h=e.next();!h.done;h=e.next()){h=h.value;var f=h.layer;h.visible&&f&&b.set(f,f.getValueAt(d,a))}}}},{key:"get",value:function(b){this.update();return this.values.get(b)}},
{key:"toJSON",value:function(){this.update();for(var b={},a=this.values,e=$jscomp.makeIterator(this.layerManager.managedLayers),h=e.next();!h.done;h=e.next()){h=h.value;var f=h.layer;f&&(f=a.get(f),void 0!==f&&(f instanceof d.a&&(f={t:"u64",v:f}),b[h.name]=f))}return b}}]);return a}(p.a),C=function(b){function d(b,e,h,f,c){u(this,d);var k=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));k.layerManager=b;k.renderLayerType=e;k.roles=h;k.layerAdded=f;k.visibility=c;k.visibleLayers=new Map;
k.newVisibleLayers=new Set;k.debouncedUpdateVisibleLayers=k.registerCancellable(a()(function(){return k.updateVisibleLayers()},0));k.registerDisposer(b.layersChanged.add(k.debouncedUpdateVisibleLayers));k.registerDisposer(h.changed.add(k.debouncedUpdateVisibleLayers));k.updateVisibleLayers();return k}q(d,b);x(d,[{key:"disposed",value:function(){this.visibleLayers.forEach(function(b){return b()});this.visibleLayers.clear();r(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}},
{key:"updateVisibleLayers",value:function(){for(var b=this.visibleLayers,a=this.newVisibleLayers,d=this.renderLayerType,e=this.layerAdded,h=this.roles,f={},k=$jscomp.makeIterator(this.layerManager.readyRenderLayers()),c=k.next();!c.done;f={disposer:f.disposer,visibilityDisposer:f.visibilityDisposer,typedLayer:f.typedLayer},c=k.next())c=c.value,c instanceof d&&h.has(c.role)&&(f.typedLayer=c,a.add(f.typedLayer),b.has(f.typedLayer)||(f.visibilityDisposer=f.typedLayer.visibility.add(this.visibility),
f.disposer=e(f.typedLayer),b.set(f.typedLayer.addRef(),function(b){return function(){b.disposer();b.visibilityDisposer();b.typedLayer.dispose()}}(f))));d=$jscomp.makeIterator(b);for(e=d.next();!e.done;e=d.next())h=$jscomp.makeIterator(e.value),e=h.next().value,h=h.next().value,a.has(e)||(b.delete(e),h());a.clear()}},{key:"getVisibleLayers",value:function(){this.debouncedUpdateVisibleLayers.flush();return[].concat($jscomp.arrayFromIterable(this.visibleLayers.keys()))}}]);return d}(p.a),F=function(b){function a(b){u(this,
a);var d=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));d.layerManager=b;d.changed=new k.a;d.visible_=!1;d.registerDisposer(b);return d}q(a,b);x(a,[{key:"toJSON",value:function(){if(void 0!==this.layer)return{layer:this.layer.name,visible:!0===this.visible?!0:void 0}}},{key:"restoreState",value:function(b){if(void 0===b)this.reset();else{Object(m.u)(b);var a=Object(m.w)(b,"layer",m.z);this.layer=void 0!==a?this.layerManager.getLayerByName(a):void 0;this.visible=Object(m.w)(b,"visible",
m.x)?!0:!1}}},{key:"reset",value:function(){this.layer=void 0}},{key:"layer",get:function(){return this.layer_},set:function(b){var a=this;if(b!==this.layer_){void 0!==this.layer_&&(this.existingLayerDisposer(),this.existingLayerDisposer=void 0);this.layer_=b;if(void 0!==b){var d=function(){a.layer_=void 0;a.visible=!1;a.existingLayerDisposer=void 0;a.changed.dispatch()};b.registerDisposer(d);var e=b.specificationChanged.add(function(){a.changed.dispatch()});this.existingLayerDisposer=function(){var a=
b.layer;null!==a&&(a=a.tool.value,void 0!==a&&a.deactivate());b.unregisterDisposer(d);e()}}else this.visible_=!1;this.changed.dispatch()}}},{key:"visible",get:function(){return this.visible_},set:function(b){void 0===this.layer_&&(b=!1);this.visible_!==b&&(this.visible_=b,this.changed.dispatch())}}]);return a}(p.a)},function(p,g,c){c.d(g,"a",function(){return l});g.b=function(f,c,m,k){for(var e=[],d=3;d<arguments.length;++d)e[d-3]=arguments[d];return f.memoize.get(Object(n.g)({id:"getMemoizedBuffer",
getter:Object(q.a)(m),args:e}),function(){var b=new u.b(l.fromData(f,m.apply(null,[].concat($jscomp.arrayFromIterable(e))),c,a.v));b.registerDisposer(b.value);return b})};var u=c(0),n=c(2),q=c(24),a=c(11),f=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),l=function(){function c(f,m){m=void 0===m?a.a:m;if(!(this instanceof
c))throw new TypeError("Cannot call a class as a function");this.gl=f;this.bufferType=m;this.gl=f;this.buffer=f.createBuffer()}f(c,[{key:"bind",value:function(){this.gl.bindBuffer(this.bufferType,this.buffer)}},{key:"bindToVertexAttrib",value:function(f,c,k,e,d,b){k=void 0===k?a.g:k;e=void 0===e?!1:e;d=void 0===d?0:d;b=void 0===b?0:b;this.bind();this.gl.enableVertexAttribArray(f);this.gl.vertexAttribPointer(f,c,k,e,d,b)}},{key:"setData",value:function(f,c){c=void 0===c?a.v:c;var k=this.gl;this.bind();
k.bufferData(this.bufferType,f,c)}},{key:"dispose",value:function(){this.gl.deleteBuffer(this.buffer);this.gl=this.buffer=void 0}}],[{key:"fromData",value:function(a,f,k,e){a=new c(a,k);a.setData(f,e);return a}}]);return c}()},function(p,g,c){c.d(g,"k",function(){return q});g.s=function(a){return(a[3]+1/256*a[2]+1/65536*a[1]+1/16777216*a[0])/256};c.d(g,"h",function(){return a});c.d(g,"g",function(){return v});c.d(g,"i",function(){return t});c.d(g,"e",function(){return m});g.r=function(a,e){for(var d=
0;4>d;++d)a[d]=(e>>8*d&255)/255;return a};g.a=function(a,e){e=void 0===e?1:e;switch(a){case u.b.FLOAT32:if(1===e)return"float";if(1<e&&4>e)return"vec"+e;break;case u.b.UINT8:if(1===e)return"uint8_t";if(1<e&&4>e)return"uint8x"+e+"_t";break;case u.b.UINT16:if(1===e)return"uint16_t";if(2===e)return"uint16x2_t";break;case u.b.UINT32:if(1===e)return"uint32_t";break;case u.b.UINT64:if(1===e)return"uint64_t"}throw Error("No shader type for "+u.b[a]+"["+e+"].");};var u=c(43),n=c(193),q="\nvec4 packFloat01ToFixedPoint(const float value) {\n  const vec4 shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n  const vec4 mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n  vec4 result = fract(value * shift);\n  result -= result.xxyz * mask;\n  return result * 256.0 / 255.0;\n}\n",
a="\nvec3 hueToRgb(float hue) {\n  float hue6 = hue * 6.0;\n  float r = abs(hue6 - 3.0) - 1.0;\n  float g = 2.0 - abs(hue6 - 2.0);\n  float b = 2.0 - abs(hue6 - 4.0);\n  return clamp(vec3(r, g, b), 0.0, 1.0);\n}\nvec3 hsvToRgb(vec3 c) {\n  vec3 hueRgb = hueToRgb(c.x);\n  return c.z * ((hueRgb - 1.0) * c.y + 1.0);\n}\n";p=["float","vec2","vec3","vec4"].map(function(a){return"\n"+a+" unnormalizeUint8("+a+" value) {\n  return floor(value * 255.0 + 0.5);\n}\n"}).join("");g.q=p;var f=[p,"\nfloat uintleToFloat(float v) {\n  return unnormalizeUint8(v);\n}\nfloat uintleToFloat(vec2 v) {\n  v = unnormalizeUint8(v);\n  return v.x + v.y * 256.0;\n}\nfloat uintleToFloat(vec3 v) {\n  v = unnormalizeUint8(v);\n  return v.x + v.y * 256.0 + v.z * 256.0 * 256.0;\n}\n"];
g.p=f;var l=[p,"\nfloat uintbeToFloat(float v) {\n  return unnormalizeUint8(v);\n}\nfloat uintbeToFloat(vec2 v) {\n  v = unnormalizeUint8(v);\n  return v.y + v.x * 256.0;\n}\nfloat uintbeToFloat(vec3 v) {\n  v = unnormalizeUint8(v);\n  return v.z + v.y * 256.0 + v.x * 256.0 * 256.0;\n}\n"];(function(){var a=n.a===n.b.BIG?"be":"le";return[n.a===n.b.BIG?l:f,"\nfloat uintToFloat(float v) {\n  return uint"+a+"ToFloat(v);\n}\nfloat uintToFloat(vec2 v) {\n  return uint"+a+"ToFloat(v);\n}\nfloat uintToFloat(vec3 v) {\n  return uint"+
a+"ToFloat(v);\n}\n"]})();g.n="\nstruct uint64_t {\n  vec4 low, high;\n};\nuint64_t toUint64(uint64_t x) { return x; }\n";g.o=[p,"\nstruct uint64_t {\n  vec4 low, high;\n};\nuint64_t toUint64(uint64_t x) { return x; }\n","\nstruct uint8_t {\n  float value;\n};\nstruct uint8x2_t {\n  vec2 value;\n};\nstruct uint8x3_t {\n  vec3 value;\n};\nstruct uint8x4_t {\n  vec4 value;\n};\nfloat toRaw(uint8_t x) { return unnormalizeUint8(x.value); }\nfloat toNormalized(uint8_t x) { return x.value; }\nvec2 toRaw(uint8x2_t x) { return unnormalizeUint8(x.value); }\nvec2 toNormalized(uint8x2_t x) { return x.value; }\nvec3 toRaw(uint8x3_t x) { return unnormalizeUint8(x.value); }\nvec3 toNormalized(uint8x3_t x) { return x.value; }\nvec4 toRaw(uint8x4_t x) { return unnormalizeUint8(x.value); }\nvec4 toNormalized(uint8x4_t x) { return x.value; }\nuint64_t toUint64(uint8_t x) {\n  uint64_t result;\n  result.low = vec4(x.value, 0.0, 0.0, 0.0);\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];
g.f="\nfloat toRaw(float x) { return x; }\nfloat toNormalized(float x) { return x; }\nvec2 toRaw(vec2 x) { return x; }\nvec2 toNormalized(vec2 x) { return x; }\nvec3 toRaw(vec3 x) { return x; }\nvec3 toNormalized(vec3 x) { return x; }\nvec4 toRaw(vec4 x) { return x; }\nvec4 toNormalized(vec4 x) { return x; }\n";g.l=["\nstruct uint64_t {\n  vec4 low, high;\n};\nuint64_t toUint64(uint64_t x) { return x; }\n",f,"\nstruct uint16_t {\n  vec2 value;\n};\nstruct uint16x2_t {\n  vec4 value;\n};\nfloat toRaw(uint16_t x) { return uintleToFloat(x.value); }\nfloat toNormalized(uint16_t x) { return toRaw(x) / 65535.0; }\nvec2 toRaw(uint16x2_t x) { return vec2(uintleToFloat(x.value.xy), uintleToFloat(x.value.zw)); }\nvec2 toNormalized(uint16x2_t x) { return toRaw(x) / 65535.0; }\nuint64_t toUint64(uint16_t x) {\n  uint64_t result;\n  result.low = vec4(x.value, 0.0, 0.0);\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];
p=["\nstruct uint64_t {\n  vec4 low, high;\n};\nuint64_t toUint64(uint64_t x) { return x; }\n","\nstruct uint32_t {\n  vec4 value;\n};\nuint64_t toUint64(uint32_t x) {\n  uint64_t result;\n  result.low = x.value;\n  result.high = vec4(0.0, 0.0, 0.0, 0.0);\n  return result;\n}\n"];g.m=p;var v=["\nvec3 getSubscriptsFromNormalized(vec3 normalizedPosition, vec3 size) {\n  return floor(min(normalizedPosition * size, size - 1.0));\n}\n","\nfloat getFortranOrderIndex(vec3 subscripts, vec3 size) {\n  return subscripts.x + size.x * (subscripts.y + size.y * subscripts.z);\n}\n",
"\nfloat getFortranOrderIndexFromNormalized(vec3 normalizedPosition, vec3 size) {\n  return getFortranOrderIndex(getSubscriptsFromNormalized(normalizedPosition, size), size);\n}\n"],t="\nfloat imod(float x, float y) {\n  return x - y * floor(x / y);\n}\n",m="\nfloat exactDot(vec4 a, vec4 b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\nfloat exactDot(vec3 a, vec3 b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n";g.d=[p,"\nbool equal(uint32_t a, uint32_t b) {\n  return all(lessThan(abs(a.value - b.value), vec4(1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0)));\n}\n"];
g.b=[p,"\nuint32_t add(uint32_t a, float b) {\n  uint32_t result;\n  float partial = 0.0;\n\n  partial += a.value.x * 255.0 + b;\n  {\n    float byte0 = mod(partial, 256.0);\n    result.value.x = byte0 / 255.0;\n    partial = (partial - byte0) / 256.0;\n  }\n\n  partial += a.value.y * 255.0;\n  {\n    float byte1 = mod(partial, 256.0);\n    result.value.y = byte1 / 255.0;\n    partial = (partial - byte1) / 256.0;\n  }\n\n  partial += a.value.z * 255.0;\n  {\n    float byte2 = mod(partial, 256.0);\n    result.value.z = byte2 / 255.0;\n    partial = (partial - byte2) / 256.0;\n  }\n\n  partial += a.value.w * 255.0;\n  {\n    float byte3 = mod(partial, 256.0);\n    result.value.w = byte3 / 255.0;\n    partial = (partial - byte3) / 256.0;\n  }\n  return result;\n}\n\nuint32_t add(uint32_t a, uint32_t b) {\n  uint32_t result;\n  float partial = 0.0;\n\n  partial += a.value.x * 255.0 + b.value.x * 255.0;\n  {\n    float byte0 = mod(partial, 256.0);\n    result.value.x = byte0 / 255.0;\n    partial = (partial - byte0) / 256.0;\n  }\n\n  partial += a.value.y * 255.0 + b.value.y * 255.0;\n  {\n    float byte1 = mod(partial, 256.0);\n    result.value.y = byte1 / 255.0;\n    partial = (partial - byte1) / 256.0;\n  }\n\n  partial += a.value.z * 255.0 + b.value.z * 255.0;\n  {\n    float byte2 = mod(partial, 256.0);\n    result.value.z = byte2 / 255.0;\n    partial = (partial - byte2) / 256.0;\n  }\n\n  partial += a.value.w * 255.0 + b.value.w * 255.0;\n  {\n    float byte3 = mod(partial, 256.0);\n    result.value.w = byte3 / 255.0;\n    partial = (partial - byte3) / 256.0;\n  }\n  return result;\n}\n"];
g.j=[p,"\nuint32_t multiply(uint32_t a, float b) {\n  uint32_t result;\n  float partial = 0.0;\n  partial += a.value.x * 255.0 * b;\n  {\n    float byte0 = mod(floor(partial + 0.5), 256.0);\n    result.value.x = byte0 / 255.0;\n    partial = (partial - byte0) / 256.0;\n  }\n\n  partial += a.value.y * 255.0 * b;\n  {\n    float byte1 = mod(floor(partial + 0.5), 256.0);\n    result.value.y = byte1 / 255.0;\n    partial = (partial - byte1) / 256.0;\n  }\n\n  partial += a.value.z * 255.0 * b;\n  {\n    float byte2 = mod(floor(partial + 0.5), 256.0);\n    result.value.z = byte2 / 255.0;\n    partial = (partial - byte2) / 256.0;\n  }\n\n  partial += a.value.w * 255.0 * b;\n  {\n    float byte3 = mod(floor(partial + 0.5), 256.0);\n    result.value.w = byte3 / 255.0;\n    partial = (partial - byte3) / 256.0;\n  }\n  return result;\n}\n"];
g.c=[p,"\nfloat divmod(uint32_t dividend, float divisor, out uint32_t quotient) {\n\n  float partial = dividend.value.w * 255.0;\n  float remainder;\n\n  remainder = mod(partial, divisor);\n  quotient.value.w = (partial - remainder) / divisor / 255.0;\n  partial = remainder * 256.0 + dividend.value.z * 255.0;\n\n  remainder = mod(partial, divisor);\n  quotient.value.z = (partial - remainder) / divisor / 255.0;\n  partial = remainder * 256.0 + dividend.value.y * 255.0;\n\n  remainder = mod(partial, divisor);\n  quotient.value.y = (partial - remainder) / divisor / 255.0;\n  partial = remainder * 256.0 + dividend.value.x * 255.0;\n\n  remainder = mod(partial, divisor);\n  quotient.value.x = (partial - remainder) / divisor / 255.0;\n\n  return remainder;\n}\n"]},
function(p,g,c){function u(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function n(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function q(b,
a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function a(b){if("number"!==typeof b||0>b)throw Error("Expected non-negative number as limit, but received: "+JSON.stringify(b));return b}c.d(g,"b",function(){return x});c.d(g,"a",function(){return z});c.d(g,"d",function(){return A});c.d(g,"c",function(){return D});c.d(g,"e",function(){return y});g.f=function(a,e){a=function(a){function d(b){for(var a=[],e=0;e<arguments.length;++e)a[e-0]=arguments[e];q(this,d);var h;
e=u(this,(h=d.__proto__||Object.getPrototypeOf(d)).call.apply(h,[].concat([this],$jscomp.arrayFromIterable(a))));e.parameters=a[1].parameters;return e}n(d,a);h(d,[{key:"initializeCounterpart",value:function(a,e){e.parameters=this.parameters;b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"initializeCounterpart",this).call(this,a,e)}}],[{key:"encodeOptions",value:function(a){var e=b(d.__proto__||Object.getPrototypeOf(d),"encodeOptions",this).call(this,a);e.parameters=a.parameters;return e}}]);
return d}(a);return a=r([Object(d.g)(e.RPC_ID)],a)};var f=c(36),l=c(74),v=c(5),t=c(2),m=c(63),k=c(24),e=c(3),d=c(12),b=function G(b,a,d){null===b&&(b=Function.prototype);var e=Object.getOwnPropertyDescriptor(b,a);if(void 0===e){if(b=Object.getPrototypeOf(b),null!==b)return G(b,a,d)}else{if("value"in e)return e.value;a=e.get;return void 0===a?void 0:a.call(d)}},h=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=
!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),r=this&&this.__decorate||function(b,a,d,e){var h=arguments.length,f=3>h?a:null===e?e=Object.getOwnPropertyDescriptor(a,d):e,c;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)f=Reflect.decorate(b,a,d,e);else for(var k=b.length-1;0<=k;k--)if(c=b[k])f=(3>h?c(f):3<h?c(a,d,f):c(a,d))||f;return 3<h&&f&&Object.defineProperty(a,d,f),f},x=function(){function b(a){q(this,b);this.source=
a;this.state=f.d.SYSTEM_MEMORY}h(b,[{key:"copyToGPU",value:function(b){this.state=f.d.GPU_MEMORY}},{key:"freeGPUMemory",value:function(b){this.state=f.d.SYSTEM_MEMORY}},{key:"gl",get:function(){return this.source.gl}}]);return b}(),z=function H(b){var d=void 0===b?{}:b;b=void 0===d.defaultItemLimit?Number.POSITIVE_INFINITY:d.defaultItemLimit;d=void 0===d.defaultSizeLimit?Number.POSITIVE_INFINITY:d.defaultSizeLimit;q(this,H);this.sizeLimit=new v.c(d,a);this.itemLimit=new v.c(b,a)},A=function(b){function a(b,
d,h){q(this,a);var f=u(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));f.gl=d;f.capacities=h;f.visibleChunksChanged=new e.a;f.pendingChunkUpdates=null;f.pendingChunkUpdatesTail=null;f.chunkUpdateDeadline=null;f.chunkUpdateDelay=30;d=function(a){return{itemLimit:f.registerDisposer(l.a.makeFromExisting(b,a.itemLimit)).rpcId,sizeLimit:f.registerDisposer(l.a.makeFromExisting(b,a.sizeLimit)).rpcId}};f.initializeCounterpart(b,{gpuMemoryCapacity:d(h.gpuMemory),systemMemoryCapacity:d(h.systemMemory),
downloadCapacity:d(h.download)});return f}n(a,b);h(a,[{key:"scheduleChunkUpdate",value:function(){var b=this.chunkUpdateDeadline;b=null===b||Date.now()<b?0:this.chunkUpdateDelay;setTimeout(this.processPendingChunkUpdates.bind(this),b)}},{key:"processPendingChunkUpdates",value:function(){var b=this.chunkUpdateDeadline;null===b&&(b=Date.now()+30);for(var a=!1;;){if(Date.now()>b){setTimeout(this.processPendingChunkUpdates.bind(this),this.chunkUpdateDelay);break}var d=this.pendingChunkUpdates;this.applyChunkUpdate(d)&&
(a=!0);d=this.pendingChunkUpdates=d.nextUpdate;--window.numPendingChunkUpdates;if(null==d){this.pendingChunkUpdatesTail=null;break}}a&&this.visibleChunksChanged.dispatch()}},{key:"applyChunkUpdate",value:function(b){var a=!1,d=this.rpc.get(b.source);if(void 0===b.id){a=$jscomp.makeIterator(d.chunks.keys());for(var e=a.next();!e.done;e=a.next())d.deleteChunk(e.value);a=!0}else if(e=b.state,e===f.d.EXPIRED)d.deleteChunk(b.id);else{var h=b.id;b["new"]?(b=d.getChunk(b),d.addChunk(h,b)):b=d.chunks.get(h);
if(e!==b.state)switch(e){case f.d.GPU_MEMORY:b.copyToGPU(this.gl);a=!0;break;case f.d.SYSTEM_MEMORY:b.freeGPUMemory(this.gl);break;default:throw Error("INTERNAL ERROR: Invalid chunk state: "+f.d[e]);}}return a}}]);return a}(d.b);A=r([Object(d.g)(f.b)],A);window.numPendingChunkUpdates=0;Object(d.e)("Chunk.update",function(b){var a=this.get(b.source),d=a.chunkManager.chunkQueueManager;a.immediateChunkUpdates?d.applyChunkUpdate(b):(a=d.pendingChunkUpdatesTail,++window.numPendingChunkUpdates,null==a?
(d.pendingChunkUpdates=b,d.pendingChunkUpdatesTail=b,d.scheduleChunkUpdate()):(a.nextUpdate=b,d.pendingChunkUpdatesTail=b))});var D=function(b){function a(b){q(this,a);var d=u(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));d.chunkQueueManager=b;d.memoize=new m.b;d.registerDisposer(b.addRef());d.initializeCounterpart(b.rpc,{chunkQueueManager:b.rpcId});return d}n(a,b);h(a,[{key:"getChunkSource",value:function(b,a){var d=this,e=b.encodeOptions(a);e.constructorId=Object(k.a)(b);e=Object(t.g)(e);
return this.memoize.get(e,function(){var e=new b(d,a);e.initializeCounterpart(d.rpc,{});return e})}},{key:"gl",get:function(){return this.chunkQueueManager.gl}}]);return a}(d.b);D=r([Object(d.g)(f.a)],D);var y=function(a){function d(b,a){q(this,d);a=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));a.chunkManager=b;a.chunks=new Map;a.immediateChunkUpdates=!1;return a}n(d,a);h(d,[{key:"initializeCounterpart",value:function(a,e){e.chunkManager=this.chunkManager.rpcId;b(d.prototype.__proto__||
Object.getPrototypeOf(d.prototype),"initializeCounterpart",this).call(this,a,e)}},{key:"deleteChunk",value:function(b){var a=this.chunks.get(b);a.state===f.d.GPU_MEMORY&&a.freeGPUMemory(this.gl);this.chunks.delete(b)}},{key:"addChunk",value:function(b,a){this.chunks.set(b,a)}},{key:"getChunk",value:function(b){throw Error("Not implemented.");}},{key:"invalidateCache",value:function(){this.rpc.invoke(f.c,{id:this.rpcId})}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}],[{key:"encodeOptions",
value:function(b){return{}}}]);return d}(d.b)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"c",function(){return v});c.d(g,"b",function(){return t});var n=c(31),q=c(43),a=c(1);c.d(g,"a",function(){return q.b});
var f=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(f,e,d){e&&a(f.prototype,e);d&&a(f,d);return f}}(),l=function k(a,d,b){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}},v;(function(a){a[a.UNKNOWN=
0]="UNKNOWN";a[a.IMAGE=1]="IMAGE";a[a.SEGMENTATION=2]="SEGMENTATION"})(v||(v={}));var t=function(c){function e(d){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");for(var b=void 0===d.lowerVoxelBound?a.h:d.lowerVoxelBound,h=d.upperVoxelBound,f=d.chunkDataSize,c=d.voxelSize,k=d.transform,l=void 0===d.baseVoxelOffset?a.h:d.baseVoxelOffset,t=void 0===d.lowerClipBound?a.s.multiply(a.s.create(),c,b):d.lowerClipBound,g=void 0===d.upperClipBound?a.s.multiply(a.s.create(),
c,h):d.upperClipBound,v=a.s.multiply(a.s.create(),f,c),G=a.s.create(),H=a.s.create(),B=0;3>B;++B)G[B]=Math.floor(b[B]/f[B]),H[B]=Math.floor((h[B]-1)/f[B]+1);c=(e.__proto__||Object.getPrototypeOf(e)).call(this,{voxelSize:c,transform:k,lowerChunkBound:G,upperChunkBound:H,chunkSize:v});if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.baseVoxelOffset=l;c.lowerClipBound=t;c.upperClipBound=g;c.lowerVoxelBound=
b;c.upperVoxelBound=h;c.chunkDataSize=f;b=c.dataType=d.dataType;h=c.numChannels=d.numChannels;c.chunkBytes=Object(a.l)(f)*q.a[b]*h;c.compressedSegmentationBlockSize=d.compressedSegmentationBlockSize;return c}u(e,c);f(e,[{key:"toObject",value:function(){return Object.assign({},l(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"toObject",this).call(this),{numChannels:this.numChannels,chunkDataSize:this.chunkDataSize,dataType:this.dataType,lowerVoxelBound:this.lowerVoxelBound,upperVoxelBound:this.upperVoxelBound,
lowerClipBound:this.lowerClipBound,upperClipBound:this.upperClipBound,baseVoxelOffset:this.baseVoxelOffset,compressedSegmentationBlockSize:this.compressedSegmentationBlockSize})}}],[{key:"make",value:function(a){return new e(Object.assign({},a,{transform:Object(n.m)(a.transform,a.volumeSourceOptions)}))}},{key:"fromObject",value:function(a){return new e(a)}},{key:"withDefaultCompression",value:function(a){var b=a.compressedSegmentationBlockSize,d=a.dataType,f=a.voxelSize,c=a.transform,k=a.lowerVoxelBound,
l=a.upperVoxelBound;c=Object(n.m)(c,a.volumeSourceOptions);void 0!==b||a.volumeType!==v.SEGMENTATION||d!==q.b.UINT32&&d!==q.b.UINT64||(b=Object(n.n)({voxelSize:f,transform:c,lowerVoxelBound:k,upperVoxelBound:l,maxVoxelsPerChunkLog2:9}));return new e(Object.assign({},a,{compressedSegmentationBlockSize:b,transform:c}))}},{key:"getDefaults",value:function(a){var b=Object.assign({},a,{transform:Object(n.m)(a.transform,a.volumeSourceOptions)});return(void 0===a.chunkDataSizes?Object(n.l)(b):a.chunkDataSizes).map(function(b){return e.withDefaultCompression(Object.assign({},
a,{chunkDataSize:b}))})}}]);return e}(n.k)},function(p,g,c){function u(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function n(a,d){var b="";d&1&&(b+="control+");d&2&&(b+="alt+");d&4&&(b+="meta+");d&8&&(b+="shift+");return b+a}function q(a){return"string"===
typeof a?{action:a}:a}function a(a){function d(d,h){for(;;)switch(b){case 0:c=a.indexOf(":");a:{d=void 0;var k=a.substring(c+1).split("+"),r=0;k=$jscomp.makeIterator(k);for(var m=k.next();!m.done;m=k.next())switch(m=m.value,m){case "control":r|=1;break;case "alt":r|=2;break;case "meta":r|=4;break;case "shift":r|=8;break;default:if(void 0===d)d=m;else{f=void 0;break a}}f=void 0===d?void 0:n(d,r)}if(void 0!==f){b=1;break}b=-1;throw Error("Invalid event identifier: "+JSON.stringify(a));case 1:if(-1===
c){b=2;break}e=a.substring(0,c);if("at"===e||"bubble"===e){b=4;break}b=-1;throw Error("Invalid event phase: "+JSON.stringify(e));case 4:return b=5,{value:e+":"+f,done:!1};case 5:if(void 0===h){b=6;break}b=-1;throw h;case 6:b=3;break;case 2:return b=7,{value:"at:"+f,done:!1};case 7:if(void 0===h){b=8;break}b=-1;throw h;case 8:return b=9,{value:"bubble:"+f,done:!1};case 9:if(void 0===h){b=10;break}b=-1;throw h;case 10:case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,e,f,c,k={next:function(b){return d(b,
void 0)},throw:function(b){return d(void 0,b)},return:function(b){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();k[Symbol.iterator]=function(){return this};return k}c.d(g,"a",function(){return m});g.b=function(a,d,b){a=k[d.eventPhase]+":"+n(a,(d.ctrlKey?1:0)|(d.altKey?2:0)|(d.metaKey?4:0)|(d.shiftKey?8:0));b=b.get(a);void 0!==b&&(!1!==b.stopPropagation&&d.stopPropagation(),a=new CustomEvent("action:"+b.action,{bubbles:!0,detail:d,cancelable:!0}),a=!d.target.dispatchEvent(a),(!1!==
b.preventDefault||a)&&d.preventDefault())};g.c=function(a,d,b,h){return Object(f.c)(a,"action:"+d,b,h)};var f=c(0);p=c(205);var l=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),v=function d(b,a,f){null===b&&(b=Function.prototype);var h=Object.getOwnPropertyDescriptor(b,a);if(void 0===h){if(b=Object.getPrototypeOf(b),
null!==b)return d(b,a,f)}else{if("value"in h)return h.value;a=h.get;return void 0===a?void 0:a.call(f)}},t;(function(a){a[a.CONTROL=1]="CONTROL";a[a.ALT=2]="ALT";a[a.META=4]="META";a[a.SHIFT=8]="SHIFT"})(t||(t={}));var m=function(d){function b(){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");var a=(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==
typeof a&&"function"!==typeof a?this:a}u(b,d);l(b,[{key:"setFromObject",value:function(b){for(var a=$jscomp.makeIterator(Object.keys(b)),d=a.next();!d.done;d=a.next())d=d.value,this.set(d,q(b[d]))}},{key:"set",value:function(d,f){f=q(f);d=$jscomp.makeIterator(a(d));for(var h=d.next();!h.done;h=d.next())h=h.value,v(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"set",this).call(this,h,f)}},{key:"delete",value:function(d){d=$jscomp.makeIterator(a(d));for(var h=d.next();!h.done;h=d.next())h=
h.value,v(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"delete",this).call(this,h)}}],[{key:"fromObject",value:function(a,d){d=void 0===d?{}:d;var h=new b;h.label=d.label;if(void 0!==d.parents){d=$jscomp.makeIterator(d.parents);for(var f=d.next();!f.done;f=d.next()){var c=$jscomp.makeIterator(f.value);f=c.next().value;c=c.next().value;h.addParent(f,c)}}d=$jscomp.makeIterator(Object.keys(a));for(f=d.next();!f.done;f=d.next())f=f.value,h.set(f,q(a[f]));return h}}]);return b}(p.a),k=[];
k[Event.AT_TARGET]="at";k[Event.CAPTURING_PHASE]="capture";k[Event.BUBBLING_PHASE]="bubble"},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);
b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function a(b,a,d,e){e=void 0===e?{}:e;return v.a.forPromise(new Promise(function(h){h(b.getVolume(a,d,e))}),{initialMessage:"Retrieving metadata for volume "+d+".",delay:!0,errorPrefix:"Error retrieving metadata for volume "+d+": "})}g.d=a;c.d(g,"b",function(){return e});c.d(g,"c",function(){return d});c.d(g,"a",function(){return b});
g.e=function(b,a){h.set(b,a)};g.f=function(b,a){r.set(b,a)};var f=c(14),l=c(18),v=c(25);p=c(0);var t=c(2),m=c(3),k=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),e=function(b){function a(b,d,e){u(this,a);b=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,b));b.initialSpecification=d;b.manager=e;return b}
q(a,b);k(a,[{key:"toJSON",value:function(){var b=this.layer;if(!b)return this.initialSpecification;b=b.toJSON();this.visible||(b.visible=!1);return b}}]);return a}(f.c),d=function(b){function d(b,a,e,h,f){u(this,d);var c=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));c.dataSourceProvider=b;c.layerManager=a;c.chunkManager=e;c.layerSelectedValues=h;c.voxelSize=f;c.changed=new m.a;c.voxelCoordinatesSet=new m.b;c.spatialCoordinatesSet=new m.b;c.registerDisposer(a.layersChanged.add(c.changed.dispatch));
c.registerDisposer(a.specificationChanged.add(c.changed.dispatch));return c}q(d,b);k(d,[{key:"reset",value:function(){this.layerManager.clear()}},{key:"restoreState",value:function(b){Object(t.u)(b);this.layerManager.clear();for(var a=$jscomp.makeIterator(Object.keys(b)),d=a.next();!d.done;d=a.next())d=d.value,this.layerManager.addManagedLayer(this.getLayer(d,b[d]))}},{key:"initializeLayerFromSpec",value:function(b,d){var e=this;b.initialSpecification=d;"string"===typeof d&&(d={source:d});Object(t.u)(d);
var f=Object(t.w)(d,"type",t.z);b.visible=Object(t.w)(d,"visible",function(b){if(void 0===b||!0===b)return!0;if(!1===b)return!1;throw Error("Expected boolean, but received: "+JSON.stringify(b)+".");});var c=function(a,d){a=new a(e,d);a.restoreState(d);b.layer=a},k=b.sourceUrl=Object(t.w)(d,"source",t.z);if(void 0===f){if(void 0===k)throw Error("Either layer 'type' or 'source' URL must be specified.");a(this.dataSourceProvider,this.chunkManager,k).then(function(a){if(-1!==e.layerManager.managedLayers.indexOf(b)){var h=
r.get(a.volumeType);if(void 0!==h)c(h,d);else throw Error("Unsupported volume type: "+l.c[a.volumeType]+".");}})}else if(k=h.get(f),void 0!==k)c(k,d);else throw Error("Unsupported layer type: "+JSON.stringify(f)+".");}},{key:"getLayer",value:function(b,a){b=new e(b,a,this);this.initializeLayerFromSpec(b,a);return b}},{key:"add",value:function(b,a){-1===this.layerManager.managedLayers.indexOf(b)&&(b.name=this.layerManager.getUniqueLayerName(b.name));this.layerManager.addManagedLayer(b,a)}},{key:"toJSON",
value:function(){for(var b={},a=0,d=$jscomp.makeIterator(this.layerManager.managedLayers),e=d.next();!e.done;e=d.next()){e=e.value;var h=e.toJSON();null!=h&&(b[e.name]=h,++a)}if(0!==a)return b}},{key:"setVoxelCoordinates",value:function(b){this.voxelCoordinatesSet.dispatch(b)}},{key:"setSpatialCoordinates",value:function(b){this.spatialCoordinatesSet.dispatch(b)}},{key:"worker",get:function(){return this.chunkManager.rpc}},{key:"rpc",get:function(){return this.chunkManager.rpc}},{key:"rootLayers",
get:function(){return this.layerManager}}]);return d}(p.a),b=function(b){function a(b){u(this,a);var d=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this));d.master=b;d.changed=new m.a;d.layerManager=new f.a;d.registerDisposer(b);b=d.layerManager;d.registerDisposer(b.layersChanged.add(d.changed.dispatch));d.registerDisposer(b.specificationChanged.add(d.changed.dispatch));return d}q(a,b);k(a,[{key:"reset",value:function(){this.layerManager.clear()}},{key:"restoreState",value:function(b){var a=
this.master.layerManager,d=[];b=$jscomp.makeIterator(new Set(Object(t.a)(b,t.B)));for(var e=b.next();!e.done;e=b.next()){e=e.value;var h=a.getLayerByName(e);if(void 0===h)throw Error("Undefined layer referenced in subset specification: "+JSON.stringify(e));d.push(h)}this.layerManager.clear();a=$jscomp.makeIterator(d);for(d=a.next();!d.done;d=a.next())this.layerManager.addManagedLayer(d.value.addRef())}},{key:"toJSON",value:function(){return this.layerManager.managedLayers.map(function(b){return b.name})}},
{key:"initializeLayerFromSpec",value:function(b,a){this.master.initializeLayerFromSpec(b,a)}},{key:"getLayer",value:function(b,a){return this.master.getLayer(b,a)}},{key:"add",value:function(b,a){-1===this.master.layerManager.managedLayers.indexOf(b)&&(b.name=this.master.layerManager.getUniqueLayerName(b.name),this.master.layerManager.addManagedLayer(b.addRef()));this.layerManager.addManagedLayer(b,a)}},{key:"setVoxelCoordinates",value:function(b){this.master.setVoxelCoordinates(b)}},{key:"setSpatialCoordinates",
value:function(b){this.master.setSpatialCoordinates(b)}},{key:"voxelCoordinatesSet",get:function(){return this.master.voxelCoordinatesSet}},{key:"spatialCoordinatesSet",get:function(){return this.master.spatialCoordinatesSet}},{key:"worker",get:function(){return this.master.rpc}},{key:"rpc",get:function(){return this.master.rpc}},{key:"dataSourceProvider",get:function(){return this.master.dataSourceProvider}},{key:"chunkManager",get:function(){return this.master.chunkManager}},{key:"voxelSize",get:function(){return this.master.voxelSize}},
{key:"layerSelectedValues",get:function(){return this.master.layerSelectedValues}},{key:"rootLayers",get:function(){return this.master.rootLayers}}]);return a}(p.a),h=new Map,r=new Map},function(p,g,c){(function(g){var n=c(158),q=function(){};"production"!==g.env.NODE_ENV&&(q=c(9)("sockjs-client:utils:url"));p.exports={getOrigin:function(a){if(!a)return null;a=new n(a);if("file:"===a.protocol)return null;var f=a.port;f||(f="https:"===a.protocol?"443":"80");return a.protocol+"//"+a.hostname+":"+f},
isOriginEqual:function(a,f){var c=this.getOrigin(a)===this.getOrigin(f);q("same",a,f,c);return c},isSchemeEqual:function(a,f){return a.split(":")[0]===f.split(":")[0]},addPath:function(a,f){a=a.split("?");return a[0]+f+(a[1]?"?"+a[1]:"")},addQuery:function(a,f){return a+(-1===a.indexOf("?")?"?"+f:"&"+f)}}}).call(g,c(8))},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function a(b){return A.get(b)}function f(b){var d=a(b.type).toJSON(b);d.type=x[b.type].toLowerCase();d.id=b.id;d.description=b.description||
void 0;return d}function l(b,d){d=void 0===d?!1:d;Object(e.u)(b);var h=Object(e.w)(b,"type",function(b){return Object(e.n)(b,x)});d={id:Object(e.w)(b,"id",d?e.z:e.B)||v(),description:Object(e.w)(b,"description",e.z),type:h};a(h).restoreState(d,b);return d}function v(){return Object(d.a)(160)}function t(b,a){return b.id<a.id?-1:b.id===a.id?0:1}function m(b){for(var d=0,e=[],h=$jscomp.makeIterator(z),f=h.next();!f.done;f=h.next()){var c=f.value;e[c]=d;f=b[c];f.sort(t);f=f.length;c=a(c);d+=c.serializedBytes*
f}h=[];d=new ArrayBuffer(d);c=$jscomp.makeIterator(z);for(f=c.next();!f.done;f=c.next()){var k=f.value;f=b[k];h[k]=f.map(function(b){return b.id});var r=f.length;k=a(k).serializer(d,e[k],r);f.forEach(k)}return{data:new Uint8Array(d),typeToIds:h,typeToOffset:e}}c.d(g,"a",function(){return r});c.d(g,"c",function(){return x});g.f=a;c.d(g,"b",function(){return D});c.d(g,"d",function(){return y});g.g=v;g.h=function(b,a){return{type:x.AXIS_ALIGNED_BOUNDING_BOX,id:"data-bounds",description:"Data Bounds",
pointA:b,pointB:a}};p=c(0);var k=c(1),e=c(2),d=c(106),b=c(3),h=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),r=function(a){function d(a){u(this,d);var e=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.id=a;e.changed=new b.a;return e}q(d,a);return d}(p.a),x;(function(b){b[b.POINT=0]="POINT";
b[b.LINE=1]="LINE";b[b.AXIS_ALIGNED_BOUNDING_BOX=2]="AXIS_ALIGNED_BOUNDING_BOX";b[b.ELLIPSOID=3]="ELLIPSOID"})(x||(x={}));var z=[x.POINT,x.LINE,x.AXIS_ALIGNED_BOUNDING_BOX,x.ELLIPSOID];g.e=z;var A=new Map;A.set(x.LINE,{icon:"\ua579",description:"Line",toJSON:function(b){return{pointA:Array.from(b.pointA),pointB:Array.from(b.pointB)}},restoreState:function(b,a){b.pointA=Object(e.w)(a,"pointA",e.l);b.pointB=Object(e.w)(a,"pointB",e.l)},serializedBytes:24,serializer:function(b,a,d){var e=new Float32Array(b,
a,6*d);return function(b,a){var d=b.pointA;b=b.pointB;a*=6;e[a]=d[0];e[a+1]=d[1];e[a+2]=d[2];e[a+3]=b[0];e[a+4]=b[1];e[a+5]=b[2]}}});A.set(x.POINT,{icon:"\u26ac",description:"Point",toJSON:function(b){return{point:Array.from(b.point)}},restoreState:function(b,a){b.point=Object(e.w)(a,"point",e.l)},serializedBytes:12,serializer:function(b,a,d){var e=new Float32Array(b,a,3*d);return function(b,a){b=b.point;a*=3;e[a]=b[0];e[a+1]=b[1];e[a+2]=b[2]}}});A.set(x.AXIS_ALIGNED_BOUNDING_BOX,{icon:"\u2751",description:"Bounding Box",
toJSON:function(b){return{pointA:Array.from(b.pointA),pointB:Array.from(b.pointB)}},restoreState:function(b,a){b.pointA=Object(e.w)(a,"pointA",e.l);b.pointB=Object(e.w)(a,"pointB",e.l)},serializedBytes:24,serializer:function(b,a,d){var e=new Float32Array(b,a,6*d);return function(b,a){var d=b.pointA;b=b.pointB;a*=6;e[a]=Math.min(d[0],b[0]);e[a+1]=Math.min(d[1],b[1]);e[a+2]=Math.min(d[2],b[2]);e[a+3]=Math.max(d[0],b[0]);e[a+4]=Math.max(d[1],b[1]);e[a+5]=Math.max(d[2],b[2])}}});A.set(x.ELLIPSOID,{icon:"\u25ce",
description:"Ellipsoid",toJSON:function(b){return{center:Array.from(b.center),radii:Array.from(b.radii)}},restoreState:function(b,a){b.center=Object(e.w)(a,"center",e.l);b.radii=Object(e.w)(a,"radii",e.k)},serializedBytes:24,serializer:function(b,a,d){var e=new Float32Array(b,a,6*d);return function(b,a){var d=b.radii;a*=6;e.set(b.center,a);e.set(d,a+3)}}});var D=function(a){function d(a){a=void 0===a?k.k.create():a;u(this,d);var e=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.objectToLocal=
a;e.annotationMap=new Map;e.changed=new b.a;e.readonly=!1;e.pending=new Set;e.references=new Map;return e}q(d,a);$jscomp.initSymbol();$jscomp.initSymbolIterator();h(d,[{key:"add",value:function(b,a){a=void 0===a?!0:a;if(!b.id)b.id=v();else if(this.annotationMap.has(b.id))throw Error("Annotation id already exists: "+JSON.stringify(b.id)+".");this.annotationMap.set(b.id,b);this.changed.dispatch();a||this.pending.add(b.id);return this.getReference(b.id)}},{key:"commit",value:function(b){this.pending.delete(b.id)}},
{key:"update",value:function(b,a){if(null===b.value)throw Error("Annotation already deleted.");b.value=a;this.annotationMap.set(a.id,a);b.changed.dispatch();this.changed.dispatch()}},{key:Symbol.iterator,value:function(){return this.annotationMap.values()}},{key:"get",value:function(b){return this.annotationMap.get(b)}},{key:"delete",value:function(b){null!==b.value&&(b.value=null,this.annotationMap.delete(b.id),this.pending.delete(b.id),b.changed.dispatch(),this.changed.dispatch())}},{key:"getReference",
value:function(b){var a=this,d=this.references.get(b);if(void 0!==d)return d.addRef();d=new r(b);d.value=this.annotationMap.get(b)||null;this.references.set(b,d);d.registerDisposer(function(){a.references.delete(b)});return d}},{key:"toJSON",value:function(){for(var b=[],a=this.pending,d=$jscomp.makeIterator(this),e=d.next();!e.done;e=d.next())e=e.value,a.has(e.id)||b.push(f(e));return b}},{key:"clear",value:function(){this.annotationMap.clear();this.pending.clear();this.changed.dispatch()}},{key:"restoreState",
value:function(b){var a=this.annotationMap;a.clear();this.pending.clear();void 0!==b&&Object(e.a)(b,function(b){b=l(b);a.set(b.id,b)});b=$jscomp.makeIterator(this.references.values());for(var d=b.next();!d.done;d=b.next()){d=d.value;var h=a.get(d.id);d.value=h||null;d.changed.dispatch()}this.changed.dispatch()}},{key:"reset",value:function(){this.clear()}}]);return d}(p.a),y=function(b){function a(){u(this,a);return n(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments))}q(a,b);return a}(D);
(function(){function b(){u(this,b);this.annotations=[[],[],[],[]]}h(b,[{key:"add",value:function(b){this.annotations[b.type].push(b)}},{key:"serialize",value:function(){return m(this.annotations)}}]);return b})()},function(p,g,c){c.d(g,"a",function(){return v});var u=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}(),
n=new Uint32Array(2),q=[];for(p=2;36>=p;++p){g=Math.floor(32/Math.log2(p));c=Math.pow(p,g);var a=Math.floor(g/2),f=Math.pow(p,a);a=Math.pow(p,g-a);var l="^[0-"+String.fromCharCode(48+Math.min(9,p-1));10<p&&(l+="a-"+String.fromCharCode(97+p-11),l+="A-"+String.fromCharCode(65+p-11));l+="]{1,"+Math.ceil(64/Math.log2(p))+"}$";q[p]={lowDigits:g,lowBase:c,lowBase1:f,lowBase2:a,pattern:new RegExp(l)}}var v=function(){function a(f,c){f=void 0===f?0:f;c=void 0===c?0:c;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");
this.low=f;this.high=c}u(a,[{key:"clone",value:function(){return new a(this.low,this.high)}},{key:"assign",value:function(a){this.low=a.low;this.high=a.high}},{key:"toString",value:function(a){a=void 0===a?10:a;var f=this.low,e=this.high;if(0===e)return f.toString(a);e*=4294967296;var d=q[a],b=d.lowBase;d=d.lowDigits;var h=e%b;e=Math.floor(e/b);f+=h;e+=Math.floor(f/b);f=(f%b).toString(a);return e.toString(a)+"0".repeat(d-f.length)+f}},{key:"tryParseString",value:function(a,f){f=void 0===f?10:f;var e=
q[f],d=e.lowDigits,b=e.lowBase,h=e.lowBase1,c=e.lowBase2;if(!e.pattern.test(a))return!1;if(a.length<=d)return this.low=parseInt(a,f),this.high=0,!0;d=a.length-d;e=parseInt(a.substr(d),f);a=parseInt(a.substr(0,d),f);b=Math.floor(a*b/4294967296);h=e+a%4294967296*h%4294967296*c%4294967296;4294967296<h&&(++b,h-=4294967296);if(h>>>0!==h||b>>>0!==b)return!1;this.low=h;this.high=b;return!0}},{key:"parseString",value:function(a,f){if(!this.tryParseString(a,void 0===f?10:f))throw Error("Failed to parse string as uint64 value: "+
JSON.stringify(a)+".");return this}},{key:"valid",value:function(){var a=this.low,f=this.high;return a>>>0===a&&f>>>0===f}},{key:"toJSON",value:function(){return this.toString()}},{key:"lshift",value:function(f){f&=63;if(0==f)return this.clone();var c=this.low,e=this.high;return 32>f?new a(c<<f,e<<f|c>>>32-f):new a(0,c<<f-32)}},{key:"rshift",value:function(f){f&=63;if(0==f)return this.clone();var c=this.low,e=this.high;return 32>f?new a(c>>>f|e<<32-f,e>>f):new a(e>>f-32,0<=e?0:-1)}},{key:"or",value:function(f){return new a(this.low|
f.low,this.high|f.high)}},{key:"xor",value:function(f){return new a(this.low^f.low,this.high^f.high)}},{key:"and",value:function(f){return new a(this.low&f.low,this.high&f.high)}}],[{key:"less",value:function(a,f){return a.high<f.high||a.high===f.high&&a.low<f.low}},{key:"compare",value:function(a,f){return a.high-f.high||a.low-f.low}},{key:"equal",value:function(a,f){return a.low===f.low&&a.high===f.high}},{key:"min",value:function(f,c){return a.less(f,c)?f:c}},{key:"random",value:function(){crypto.getRandomValues(n);
return new a(n[0],n[1])}},{key:"parseString",value:function(f,c){c=void 0===c?10:c;return(new a).parseString(f,c)}}]);return a}();v.ZERO=new v(0,0)},function(p,g,c){g.a=function(c){if(c instanceof Object){var a=c[u];void 0===a&&(a=c[u]=n++);return"o"+a}return""+JSON.stringify(c)};$jscomp.initSymbol();var u=Symbol("objectId"),n=0},function(p,g,c){c.d(g,"a",function(){return q});var u=function(){function a(a,c){for(var f=0;f<c.length;f++){var l=c[f];l.enumerable=l.enumerable||!1;l.configurable=!0;"value"in
l&&(l.writable=!0);Object.defineProperty(a,l.key,l)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}();c(194);var n=null,q=function(){function a(f){f=void 0===f?!1:f;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");null===n&&(n=document.createElement("ul"),n.id="statusContainer",document.body.appendChild(n));var c=document.createElement("li");this.element=c;!0===f&&(f=200);!1!==f?(this.setVisible(!1),this.timer=setTimeout(this.setVisible.bind(this,!0),
f)):this.timer=null;n.appendChild(c)}u(a,[{key:"dispose",value:function(){n.removeChild(this.element);this.element=void 0;null!==this.timer&&clearTimeout(this.timer)}},{key:"setText",value:function(a,c){this.element.textContent=a;c&&this.setVisible(!0)}},{key:"setHTML",value:function(a,c){this.element.innerHTML=a;c&&this.setVisible(!0)}},{key:"setVisible",value:function(a){null!==this.timer&&(clearTimeout(this.timer),this.timer=null);this.element.style.display=a?"block":"none"}},{key:"setErrorMessage",
value:function(a){var f=this;this.element.textContent=a+" ";a=document.createElement("button");a.textContent="Dismiss";a.addEventListener("click",function(){f.dispose()});this.element.appendChild(a)}}],[{key:"forPromise",value:function(f,c){var l=new a(c.delay);l.setText(c.initialMessage);var t=l.dispose.bind(l);f.then(t,function(a){l.setErrorMessage((void 0===c.errorPrefix?"":c.errorPrefix)+(a instanceof Error?a.message:""+a));l.setVisible(!0)});return f}},{key:"showMessage",value:function(f){var c=
new a;c.element.textContent=f;c.setVisible(!0);return c}},{key:"showTemporaryMessage",value:function(a,c){c=void 0===c?2E3:c;var f=this.showMessage(a);setTimeout(function(){return f.dispose()},c);return f}}]);return a}()},function(p,g,c){function u(a,f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");}function n(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||"object"!==typeof f&&"function"!==typeof f?a:f}function q(a,
f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"b",function(){return v});c.d(g,"a",function(){return t});g.c=function(c){return function(c){function e(){u(this,e);var a=n(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));
a.visibility=new t;return a}q(e,c);l(e,[{key:"initializeCounterpart",value:function(d,b){b=void 0===b?{}:b;b.visibility=this.registerDisposer(a.a.makeFromExisting(d,this.visibility)).rpcId;f(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"initializeCounterpart",this).call(this,d,b)}}]);return e}(c)};var a=c(74);p=c(5);var f=function k(a,d,b){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in
e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}},l=function(){function a(a,d){for(var b=0;b<d.length;b++){var e=d[b];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(e,d,b){d&&a(e.prototype,d);b&&a(e,b);return e}}(),v=function(a){function e(a){a=void 0===a?Number.NEGATIVE_INFINITY:a;u(this,e);return n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,a))}q(e,a);l(e,[{key:"visible",get:function(){return this.value===
Number.POSITIVE_INFINITY}},{key:"ignored",get:function(){return this.value===Number.NEGATIVE_INFINITY}}]);return e}(p.f);v.VISIBLE=Number.POSITIVE_INFINITY;v.IGNORED=Number.NEGATIVE_INFINITY;var t=function(a){function e(){u(this,e);var a=n(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));a.contributors=new Map;return a}q(e,a);l(e,[{key:"add",value:function(a){var b=this,d=this.contributors,e=a.changed.add(function(){b.update()}),f=function(){d.delete(f);e();b.update()};d.set(f,
a);this.update();return f}},{key:"update",value:function(){for(var a=Number.NEGATIVE_INFINITY,b=$jscomp.makeIterator(this.contributors.values()),e=b.next();!e.done;e=b.next())a=Math.max(a,e.value.value);this.value=a}}]);return e}(v)},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?
b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function a(b,a,d){var e=b.createShader(d);b.shaderSource(e,a);b.compileShader(e);if(!b.getShaderParameter(e,b.COMPILE_STATUS)){b=b.getShaderInfoLog(e)||"";var f=b.replace("\x00","");
e=[];f=$jscomp.makeIterator(f.split("\n"));for(var h=f.next();!h.done;h=f.next()){h=h.value;var c=h.match(/^ERROR:\s*(\d+):(\d+)\s*(.+)$/);null!==c?e.push({message:c[3].trim(),file:parseInt(c[1],10),line:parseInt(c[2],10)}):(c=h.match(/^ERROR:\s*(.+)$/),null!==c?e.push({message:c[1]}):(h=h.trim())&&e.push({message:h}))}throw new t(d,a,b,e);}return e}c.d(g,"a",function(){return d});g.b=function(b,a,e){var f=new Map;return function(h){var c=f.get(h);void 0===c&&(c=new d(a),c.require(h),e(c),c=b.registerDisposer(c.build()),
f.set(h,c));return c}};p=c(0);var f=c(11),l=function(){function b(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),v;(function(b){b[b.VERTEX=f.I]="VERTEX";b[b.FRAGMENT=f.h]="FRAGMENT"})(v||(v={}));var t=function(b){function a(b,d,e,f){u(this,a);var h="Error compiling "+v[b].toLowerCase()+" shader: "+e,c=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,
h));c.name="ShaderCompilationError";c.log=e;c.message=h;c.shaderType=b;c.source=d;c.errorMessages=f;return c}q(a,b);return a}(Error),m=function(b){function a(b,d,e){u(this,a);var f="Error linking shader: "+e,h=n(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,f));h.name="ShaderLinkError";h.log=e;h.message=f;h.vertexSource=b;h.fragmentSource=d;return h}q(a,b);return a}(Error),k=function(b){function d(b,e,f,h,c){u(this,d);var k=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));k.gl=
b;k.vertexSource=e;k.fragmentSource=f;k.attributes=new Map;k.uniforms=new Map;var r=k.vertexShader=a(b,e,b.VERTEX_SHADER),l=k.fragmentShader=a(b,f,b.FRAGMENT_SHADER),x=b.createProgram();b.attachShader(x,r);b.attachShader(x,l);b.linkProgram(x);if(!b.getProgramParameter(x,b.LINK_STATUS))throw b=b.getProgramInfoLog(x)||"",new m(e,f,b);k.program=x;f=k.uniforms;e=k.attributes;if(h)for(h=$jscomp.makeIterator(h),r=h.next();!r.done;r=h.next())r=r.value,f.set(r,b.getUniformLocation(x,r));if(c)for(c=$jscomp.makeIterator(c),
r=c.next();!r.done;r=c.next())h=r.value,e.set(h,b.getAttribLocation(x,h));return k}q(d,b);l(d,[{key:"uniform",value:function(b){return this.uniforms.get(b)}},{key:"attribute",value:function(b){return this.attributes.get(b)}},{key:"textureUnit",value:function(b){return this.textureUnits.get(b)}},{key:"bind",value:function(){this.gl.useProgram(this.program)}},{key:"disposed",value:function(){var b=this.gl;b.deleteShader(this.vertexShader);this.vertexShader=void 0;b.deleteShader(this.fragmentShader);
this.fragmentShader=void 0;b.deleteProgram(this.program);this.uniforms=this.attributes=this.gl=this.program=void 0}}]);return d}(p.a),e=function(){function b(){u(this,b);this.code="";this.parts=new Set}l(b,[{key:"add",value:function(b){if(!this.parts.has(b))switch(this.parts.add(b),typeof b){case "string":this.code+=b;break;case "function":this.add(b());break;default:if(Array.isArray(b)){b=$jscomp.makeIterator(b);for(var a=b.next();!a.done;a=b.next())this.add(a.value)}else throw Error("Invalid code type");
}}},{key:"toString",value:function(){return this.code}}]);return b}(),d=function(){function b(a){u(this,b);this.gl=a;this.nextTextureUnit=this.nextSymbolID=0;this.varyingsCode=this.attributesCode=this.uniformsCode="";this.fragmentExtensionsSet=new Set;this.fragmentExtensions="";this.vertexCode=new e;this.vertexMain="";this.fragmentCode=new e;this.fragmentMain="";this.required=new Set;this.uniforms=[];this.attributes=[];this.initializers=[];this.textureUnits=new Map}l(b,[{key:"allocateTextureUnit",
value:function(b,a){a=void 0===a?1:a;if(this.textureUnits.has(b))throw Error("Duplicate texture unit symbol: "+b);var d=this.nextTextureUnit;this.nextTextureUnit+=a;this.textureUnits.set(b,d);return d}},{key:"addTextureSampler2D",value:function(b,a,d){var e=this.allocateTextureUnit(a,d);this.addUniform("highp sampler2D",b,d);this.addInitializer(function(a){if(d){for(var f=new Int32Array(d),c=0;c<d;++c)f[c]=c+e;a.gl.uniform1iv(a.uniform(b),f)}else a.gl.uniform1i(a.uniform(b),e)});return e}},{key:"symbol",
value:function(b){return b+this.nextSymbolID++}},{key:"addAttribute",value:function(b,a){this.attributes.push(a);this.attributesCode+="attribute "+b+" "+a+";\n";return a}},{key:"addVarying",value:function(b,a){this.varyingsCode+="varying "+b+" "+a+";\n"}},{key:"addUniform",value:function(b,a,d){this.uniforms.push(a);this.uniformsCode=null!=d?this.uniformsCode+("uniform "+b+" "+a+"["+d+"];\n"):this.uniformsCode+("uniform "+b+" "+a+";\n");return a}},{key:"addFragmentExtension",value:function(b){this.fragmentExtensionsSet.has(b)||
(this.fragmentExtensionsSet.add(b),this.fragmentExtensions+="#extension "+b+" : require\n")}},{key:"addVertexCode",value:function(b){this.vertexCode.add(b)}},{key:"addFragmentCode",value:function(b){this.fragmentCode.add(b)}},{key:"setVertexMain",value:function(b){this.vertexMain=b}},{key:"addVertexMain",value:function(b){this.vertexMain=(this.vertexMain||"")+b}},{key:"setFragmentMain",value:function(b){this.fragmentMain="void main() {\n"+b+"\n}\n"}},{key:"setFragmentMainFunction",value:function(b){this.fragmentMain=
b}},{key:"addInitializer",value:function(b){this.initializers.push(b)}},{key:"require",value:function(b){this.required.has(b)||(this.required.add(b),b(this))}},{key:"build",value:function(){var b=new k(this.gl,"\nprecision highp float;\n"+this.uniformsCode+"\n"+this.attributesCode+"\n"+this.varyingsCode+"\n"+this.vertexCode+"\nvoid main() {\n"+this.vertexMain+"\n}\n","\n"+this.fragmentExtensions+"\nprecision highp float;\n"+this.uniformsCode+"\n"+this.varyingsCode+"\n"+this.fragmentCode+"\n"+this.fragmentMain+
"\n",this.uniforms,this.attributes);b.textureUnits=this.textureUnits;var a=this.initializers;if(0<a.length){b.bind();a=$jscomp.makeIterator(a);for(var d=a.next();!d.done;d=a.next())d=d.value,d(b)}return b}}]);return b}()},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,
b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){for(var d=$jscomp.makeIterator(m),e=d.next();!e.done;e=d.next())if(e=e.value,e=e(a,b),null!=e)return e;throw Error("No chunk format handler found.");}g.c=function(a){m.push(a)};c.d(g,
"b",function(){return k});c.d(g,"a",function(){return e});p=c(45);var f=c(1),l=function(){function a(b,a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),v=f.s.create(),t=f.s.create(),m=[],k=function(d){function b(d,e){u(this,b);e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,d,e));e.chunkFormatHandler=e.registerDisposer(a(d.chunkQueueManager.gl,
e.spec));return e}q(b,d);l(b,[{key:"getValueAt",value:function(b,a){a=void 0===a?this.spec.chunkLayout:a;var d=this.spec,e=a.size;a.globalToLocalSpatial(t,b);for(b=0;3>b;++b)v[b]=Math.floor(t[b]/e[b]);b=Object(f.t)(v);b=this.chunks.get(b);if(!b)return null;a=d.voxelSize;for(var c=0;3>c;++c)v[c]=Math.floor((t[c]-v[c]*e[c])/a[c]);e=b.chunkDataSize;for(a=0;3>a;++a)if(v[a]>=e[a])return;d=d.numChannels;if(1===d)return b.getChannelValueAt(v,0);e=Array(d);for(a=0;a<d;++a)e[a]=b.getChannelValueAt(v,a);return e}},
{key:"getChunk",value:function(b){return this.chunkFormatHandler.getChunk(this,b)}},{key:"chunkFormat",get:function(){return this.chunkFormatHandler.chunkFormat}}]);return b}(p.c),e=function(a){function b(a,d){u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));e.chunkDataSize=d.chunkDataSize||a.spec.chunkDataSize;return e}q(b,a);l(b,[{key:"chunkFormat",get:function(){return this.source.chunkFormat}}]);return b}(p.b)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(d){var b=
e.get(d),f=d.changed.count;if(void 0!==b&&b.generation===f)return b;if(d instanceof m){var c=d.baseJSON();for(var k=$jscomp.makeIterator(d.children),l=k.next();!l.done;l=k.next()){var t=$jscomp.makeIterator(l.value);l=t.next().value;t=t.next().value;c[l]=a(t).value}}else c=d.toJSON();void 0===b?(b={generation:f,value:c},e.set(d,b)):(b.generation=f,b.value=c);return b}c.d(g,"a",function(){return m});c.d(g,"b",function(){return k});g.c=a;p=c(0);var f=c(2),l=c(3),v=function(){function a(b,a){for(var d=
0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),t=function b(a,e,f){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,e);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return b(a,e,f)}else{if("value"in c)return c.value;e=c.get;return void 0===e?void 0:e.call(f)}},m=function(b){function a(){u(this,a);var b=n(this,
(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments));b.children=new Map;b.changed=new l.a;return b}q(a,b);v(a,[{key:"add",value:function(b,a){var e=this;if(this.children.has(b))throw Error("Key "+JSON.stringify(b)+" already registered.");this.children.set(b,a);a.changed.add(this.changed.dispatch);this.changed.dispatch();return function(){e.remove(b)}}},{key:"remove",value:function(b){var a=this.children;if(a.has(b))throw Error("Key "+JSON.stringify(b)+" not registered.");a=a.get(b);this.children.delete(b);
a.changed.remove(this.changed.dispatch);this.changed.dispatch()}},{key:"disposed",value:function(){for(var b=this.changed,e=$jscomp.makeIterator(this.children.values()),f=e.next();!f.done;f=e.next())f.value.changed.remove(b.dispatch);this.children=void 0;t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"disposed",this).call(this)}},{key:"toJSON",value:function(){for(var b=this.baseJSON(),a=$jscomp.makeIterator(this.children),e=a.next();!e.done;e=a.next()){var f=$jscomp.makeIterator(e.value);
e=f.next().value;f=f.next().value;b[e]=f.toJSON()}return b}},{key:"baseJSON",value:function(){return{}}},{key:"reset",value:function(){for(var b=$jscomp.makeIterator(this.children.values()),a=b.next();!a.done;a=b.next())a.value.reset()}},{key:"restoreState",value:function(b){Object(f.u)(b);for(var a=$jscomp.makeIterator(this.children),e=a.next();!e.done;e=a.next()){var c=$jscomp.makeIterator(e.value);e=c.next().value;c=c.next().value;try{b.hasOwnProperty(e)&&c.restoreState(b[e])}catch(D){throw Error("Error restoring property "+
JSON.stringify(e)+": "+D.message);}}}}]);return a}(p.a),k=function(b){function a(){u(this,a);var b=n(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments));b.lastState={};return b}q(a,b);v(a,[{key:"restoreState",value:function(b){Object(f.u)(b);this.lastState=b;t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"restoreState",this).call(this,b)}},{key:"reset",value:function(){this.lastState={};t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"reset",this).call(this)}},
{key:"baseJSON",value:function(){for(var b=Object.assign(t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"baseJSON",this).call(this),this.lastState),e=$jscomp.makeIterator(this.children.keys()),f=e.next();!f.done;f=e.next())delete b[f.value];return b}},{key:"toJSON",value:function(){var b=t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"toJSON",this).call(this);return this.lastState=b}},{key:"add",value:function(b,e){var f=t(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),
"add",this).call(this,b,e);b=this.lastState[b];void 0!==b&&(e.reset(),e.restoreState(b));return f}}]);return a}(m),e=new WeakMap},function(p,g,c){c.d(g,"a",function(){return u});g.b=1E-6;var u="undefined"!==typeof Float32Array?Float32Array:Array;g.c=Math.random},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+
typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}function q(b,a,d){for(var e=0;3>e;++e)b[e]=Number.POSITIVE_INFINITY,a[e]=Number.NEGATIVE_INFINITY;d=$jscomp.makeIterator(d);for(e=d.next();!e.done;e=d.next()){var f=e.value.spec;e=f.lowerChunkBound;f=f.upperChunkBound;for(var c=0;3>c;++c)b[c]=Math.min(b[c],e[c]),a[c]=Math.max(a[c],f[c])}}function a(b,a,d,e){for(var f=
z.FULLY_INSIDE,c=0;3>c;++c){var h=b[c];var k=a[c],r=d[c],m=e[c];h=h>=m||k<=r?z.FULLY_OUTSIDE:h>=r&&k<=m?z.FULLY_INSIDE:z.PARTIALLY_INSIDE;switch(h){case z.FULLY_OUTSIDE:return h;case z.PARTIALLY_INSIDE:f=h}}return f}function f(b){var a=b.transform,d=b.transformedSources,e=a.changed.count;e!==b.transformedSourcesGeneration&&(b.transformedSourcesGeneration=e,d=h.k.equals(a.transform,h.d)?b.sources.map(function(b){return b.map(function(b){return{source:b,chunkLayout:b.spec.chunkLayout}})}):b.sources.map(function(b){return b.map(function(b){var d=
b.spec.chunkLayout;return{chunkLayout:k.a.get(d.size,m(d.transform,a)),source:b}})}),b.transformedSources=d);return d}function l(b,a){var d=a.length,e=0;if(1<d)for(var f=0,c=0;c<d;++c){var h=a[c].chunkLayout;var k=h.size;h=h.globalToLocalSpatialVector(x,b);for(var r=0,m=0,l=1,t=0;3>t;++t){var g=k[t];l*=g;g*=h[t];r=Math.min(r,g);m=Math.max(m,g)}k=l/(m-r);k>f&&(f=k,e=c)}return a[e]}function v(b){var a=b.voxelSize,d=void 0===b.lowerVoxelBound?h.h:b.lowerVoxelBound,e=b.upperVoxelBound,f=void 0===b.maxVoxelsPerChunkLog2?
18:b.maxVoxelsPerChunkLog2;b=void 0===b.transform?h.d:b.transform;b=Object(h.c)(h.s.create(),b);a=h.s.multiply(b,b,a);b=h.s.fromValues(1,1,1);if(void 0===e)var c=h.f;else{c=h.s.create();for(var k=0;3>k;++k)c[k]=Math.pow(2,Math.floor(Math.log2(e[k]-d[k])))}for(d=0;d<f;++d){e=Infinity;k=-1;for(var r=0;3>r;++r)if(!(b[r]>=c[r])){var m=b[r]*a[r];m<e&&(e=m,k=r)}e=k;if(-1===e)break;b[e]*=2}return b}function t(b){var a=b.flatDimension,d=b.voxelSize,e=b.maxVoxelsPerChunkLog2,f=b.transform;h.s.subtract(x,void 0===
b.upperVoxelBound?h.f:b.upperVoxelBound,void 0===b.lowerVoxelBound?h.h:b.lowerVoxelBound);x[a]=1;return v({voxelSize:d,upperVoxelBound:x,maxVoxelsPerChunkLog2:e,transform:f})}function m(b,a){a=a.transform;return void 0===a?void 0===b?h.d:b:void 0===b?a:h.k.multiply(h.k.create(),a,b)}g.o=f;c.d(g,"j",function(){return D});g.n=v;g.p=t;c.d(g,"a",function(){return y});g.m=m;g.l=function(b){if(void 0!==b.chunkDataSizes)return b.chunkDataSizes;var a=void 0===b.chunkLayoutPreference?y.ISOTROPIC:b.chunkLayoutPreference;
switch(a){case y.ISOTROPIC:return[v(b)];case y.FLAT:a=[];for(var d=0;3>d;++d)a[d]=t({flatDimension:d,voxelSize:b.voxelSize,lowerVoxelBound:b.lowerVoxelBound,upperVoxelBound:b.upperVoxelBound,maxVoxelsPerChunkLog2:b.maxVoxelsPerChunkLog2,transform:b.transform});a.push(v(b));return a}throw Error("Invalid chunk layout preference: "+a+".");};c.d(g,"k",function(){return E});var k=c(180),e=c(39),d=c(181),b=c(43),h=c(1);p=c(12);c.d(g,"c",function(){return b.b});var r=function(){function b(b,a){for(var d=
0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),x=h.s.create(),z;(function(b){b[b.FULLY_OUTSIDE=0]="FULLY_OUTSIDE";b[b.FULLY_INSIDE=1]="FULLY_INSIDE";b[b.PARTIALLY_INSIDE=2]="PARTIALLY_INSIDE"})(z||(z={}));var A=[h.s.create(),h.s.create(),h.s.create(),h.s.create()],D=function(b){function c(){u(this,c);var b=(c.__proto__||Object.getPrototypeOf(c)).call(this);
if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");b=!b||"object"!==typeof b&&"function"!==typeof b?this:b;b.width=-1;b.height=-1;b.hasViewportToData=!1;b.hasValidViewport=!1;b.viewportToData=h.k.create();b.viewportAxes=[h.s.create(),h.s.create(),h.s.create()];b.previousViewportAxes=[h.s.create(),h.s.create()];b.centerDataPosition=h.s.create();b.viewportPlaneDistanceToOrigin=0;b.visibleChunkLayouts=new Map;b.visibleLayers=new Map;b.visibleSourcesStale=!0;
b.pixelSize=0;h.k.identity(b.viewportToData);return b}n(c,b);r(c,[{key:"onViewportChanged",value:function(){}},{key:"maybeSetHasValidViewport",value:function(){!this.hasValidViewport&&-1!==this.width&&-1!==this.height&&this.hasViewportToData&&(this.hasValidViewport=!0,this.onHasValidViewport());if(this.hasValidViewport)this.onViewportChanged()}},{key:"onHasValidViewport",value:function(){}},{key:"setViewportSize",value:function(b,a){return b!==this.width||a!==this.height?(this.width=b,this.height=
a,this.maybeSetHasValidViewport(),!0):!1}},{key:"setViewportToDataMatrix",value:function(b){if(this.hasViewportToData&&h.k.equals(this.viewportToData,b))return!1;this.hasViewportToData=!0;var a=this.viewportToData;h.k.copy(a,b);Object(h.o)(a);h.s.transformMat4(this.centerDataPosition,h.h,b);b=0;for(var e=this.viewportAxes,f=this.previousViewportAxes,c=0;3>c;++c){var k=e[c];Object(h.p)(k,h.e[c],a);0===c&&(b=h.s.length(k));h.s.normalize(k,k)}this.viewportAxes=e;this.previousViewportAxes=f;if(!Object(d.a)(b,
this.pixelSize)||.95>h.s.dot(e[0],f[0])||.95>h.s.dot(e[1],f[1]))h.s.copy(f[0],e[0]),h.s.copy(f[1],e[1]),this.visibleSourcesStale=!0,this.pixelSize=b;this.viewportPlaneDistanceToOrigin=h.s.dot(this.centerDataPosition,this.viewportAxes[2]);this.onViewportToDataMatrixChanged();this.maybeSetHasValidViewport();return!0}},{key:"onViewportToDataMatrixChanged",value:function(){}},{key:"updateVisibleSources",value:function(){if(this.visibleSourcesStale){this.visibleSourcesStale=!1;var b=1.1*this.pixelSize,
a=this.visibleChunkLayouts,d=this.viewportAxes[2],e=this.visibleLayers;a.clear();var c={};e=$jscomp.makeIterator(e);for(var h=e.next();!h.done;c={smallestVoxelSize:c.smallestVoxelSize,visibleSources:c.visibleSources},h=e.next()){h=$jscomp.makeIterator(h.value);var k=h.next().value;c.visibleSources=h.next().value;c.visibleSources.length=0;h=f(k);var r=h.length;k=void 0;c.smallestVoxelSize=h[0][0].source.spec.voxelSize;var m=function(a){return function(d){for(var e=0;3>e;++e){var f=d[e];if(f>b&&f>a.smallestVoxelSize[e])return!0}return!1}}(c),
t=function(b){return function(d,e){var f=d.source,c=d.chunkLayout;b.visibleSources[b.visibleSources.length++]=d;d=a.get(c);void 0===d&&(d=new Map,a.set(c,d));d.set(f,e)}}(c);for(k=r-1;;){r=l(d,h[k]);t(r,k);if(0===k||!m(r.source.spec.voxelSize))break;--k}c.visibleSources.reverse()}}}},{key:"computeVisibleChunks",value:function(b,d){var f=this;this.updateVisibleSources();for(var c=this.width,k=this.height,r=this.viewportToData,m=0;3>m;++m)A[0][m]=-h.e[0][m]*c/2-h.e[1][m]*k/2,A[1][m]=-h.e[0][m]*c/2+
h.e[1][m]*k/2,A[2][m]=h.e[0][m]*c/2-h.e[1][m]*k/2,A[3][m]=h.e[0][m]*c/2+h.e[1][m]*k/2;for(c=0;4>c;++c)h.s.transformMat4(A[c],A[c],r);var l=h.s.create(),t=h.s.create(),g=h.s.create(),v=h.s.create(),B=h.s.create(),n=h.s.create(),H=[],C=[];this.visibleChunkLayouts.forEach(function(c,k){function r(){for(var b=0,a=0,d=0;3>d;++d){var e=n[d],f=l[d],c=t[d]-f,h=B[d]*c;b+=e*(f+h);a+=e*(f+c-h)}return b<u?!1:a<=u}function m(b){function f(){p=Object(e.c)(H,0,B,function(b){var d=b.spec;switch(a(l,t,d.lowerChunkBound,
d.upperChunkBound)){case z.PARTIALLY_INSIDE:return!0;case z.FULLY_INSIDE:C.push(b);default:return!1}})}if(0!==C.length||0!==p){for(var c=1,h=0;3>h;++h)c*=Math.max(0,t[h]-l[h]);if(0!==c&&r())if(1===c)d(k,y,l,C);else{for(var g;;)if(c=l[b],h=t[b],g=h-c,1===g)b=(b+1)%3;else break;g=c+Math.floor(.5*g);var x=(b+1)%3,v=C.length;t[b]=g;var B=p;f();m(x);C.length=v;p=B;t[b]=h;l[b]=g;f();m(x);l[b]=c;C.length=v;p=B}}}var y=b(k);q(g,v,c.keys());h.s.set(l,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);
h.s.set(t,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);k.globalToLocalSpatialVector(n,f.viewportAxes[2]);for(var F=0;3>F;++F)B[F]=0<n[F]?1:0;var u=h.s.dot(k.globalToLocalGrid(x,f.centerDataPosition),n);for(F=0;4>F;++F)for(var E=k.globalToLocalGrid(x,A[F]),G=0;3>G;++G)l[G]=Math.min(l[G],Math.floor(E[G])),t[G]=Math.max(t[G],Math.floor(E[G])+1);h.s.max(l,l,g);h.s.min(t,t,v);C.length=0;H.length=0;c=$jscomp.makeIterator(c.keys());for(F=c.next();!F.done;F=c.next())switch(F=
F.value,E=F.spec,a(l,t,E.lowerChunkBound,E.upperChunkBound)){case z.FULLY_INSIDE:C.push(F);break;case z.PARTIALLY_INSIDE:H.push(F)}var p=H.length;m(0)})}}]);return c}(p.b);g.b=18;var y;(function(b){b[b.ISOTROPIC=0]="ISOTROPIC";b[b.FLAT=1]="FLAT"})(y||(y={}));var E=function(){function b(a){u(this,b);var d=a.chunkSize,e=a.transform,f=void 0===a.lowerChunkBound?h.h:a.lowerChunkBound,c=a.upperChunkBound;this.voxelSize=a.voxelSize;this.chunkLayout=k.a.get(d,e);this.lowerChunkBound=f;this.upperChunkBound=
c}r(b,[{key:"toObject",value:function(){return{transform:this.chunkLayout.transform,chunkSize:this.chunkLayout.size,voxelSize:this.voxelSize,lowerChunkBound:this.lowerChunkBound,upperChunkBound:this.upperChunkBound}}}]);return b}();g.h="SliceView";g.f="sliceview/RenderLayer";g.d="SliceView.addVisibleLayer";g.e="SliceView.removeVisibleLayer";g.i="SliceView.updateView";g.g="SliceView.updateTransform"},function(p,g,c){g.b=function(c,a){n.set(c,a)};g.a=function(c){for(var a=new u.b,f=$jscomp.makeIterator(n),
l=f.next();!l.done;l=f.next()){var g=$jscomp.makeIterator(l.value);l=g.next().value;g=g.next().value;a.register(l,g(c))}return a};var u=c(37),n=new Map},function(p,g,c){(function(u,n){var q;(function(){function a(b,d){function e(b){var a;if(e[b]!==q)return e[b];if("bug-string-char-index"==b)var h=!1;else if("json"==b)h=e("json-stringify")&&e("json-parse");else{var r;if("json-stringify"==b){h=d.stringify;var m="function"==typeof h&&u;if(m){(r=function(){return 1}).toJSON=r;try{m="0"===h(0)&&"0"===
h(new f)&&'""'==h(new c)&&h(v)===q&&h(q)===q&&h()===q&&"1"===h(r)&&"[1]"==h([r])&&"[null]"==h([q])&&"null"==h(null)&&"[null,null,null]"==h([q,v,null])&&'{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'==h({a:[r,!0,!1,null,"\x00\b\n\f\r\t"]})&&"1"===h(null,r)&&"[\n 1,\n 2\n]"==h([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==h(new k(-864E13))&&'"+275760-09-13T00:00:00.000Z"'==h(new k(864E13))&&'"-000001-01-01T00:00:00.000Z"'==h(new k(-621987552E5))&&'"1969-12-31T23:59:59.999Z"'==h(new k(-1))}catch(Za){m=
!1}}h=m}if("json-parse"==b){h=d.parse;if("function"==typeof h)try{if(0===h("0")&&!h(!1)&&(r=h('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'),a=5==r.a.length&&1===r.a[0])){try{a=!h('"\t"')}catch(Za){}if(a)try{a=1!==h("01")}catch(Za){}if(a)try{a=1!==h("1.")}catch(Za){}}}catch(Za){a=!1}h=a}}return e[b]=!!h}b||(b=t.Object());d||(d=t.Object());var f=b.Number||t.Number,c=b.String||t.String,h=b.Object||t.Object,k=b.Date||t.Date,r=b.SyntaxError||t.SyntaxError,m=b.TypeError||t.TypeError,g=b.Math||t.Math;
b=b.JSON||t.JSON;"object"==typeof b&&b&&(d.stringify=b.stringify,d.parse=b.parse);h=h.prototype;var v=h.toString,n,q,u=new k(-0xc782b5b800cec);try{u=-109252==u.getUTCFullYear()&&0===u.getUTCMonth()&&1===u.getUTCDate()&&10==u.getUTCHours()&&37==u.getUTCMinutes()&&6==u.getUTCSeconds()&&708==u.getUTCMilliseconds()}catch(fb){}if(!e("json")){var p=e("bug-string-char-index");if(!u){var P=g.floor;var N=[0,31,59,90,120,151,181,212,243,273,304,334];var U=function(b,a){return N[a]+365*(b-1970)+P((b-1969+(a=
+(1<a)))/4)-P((b-1901+a)/100)+P((b-1601+a)/400)}}(n=h.hasOwnProperty)||(n=function(b){var a={};if((a.__proto__=null,a.__proto__={toString:1},a).toString!=v)n=function(b){var a=this.__proto__;b=b in(this.__proto__=null,this);this.__proto__=a;return b};else{var d=a.constructor;n=function(b){var a=(this.constructor||d).prototype;return b in this&&!(b in a&&this[b]===a[b])}}a=null;return n.call(this,b)});var O=function(b,a){var d=0,e,f;(e=function(){this.valueOf=0}).prototype.valueOf=0;var c=new e;for(f in c)n.call(c,
f)&&d++;e=c=null;d?O=2==d?function(b,a){var d={},e="[object Function]"==v.call(b),f;for(f in b)e&&"prototype"==f||n.call(d,f)||!(d[f]=1)||!n.call(b,f)||a(f)}:function(b,a){var d="[object Function]"==v.call(b),e,f;for(e in b)d&&"prototype"==e||!n.call(b,e)||(f="constructor"===e)||a(e);(f||n.call(b,e="constructor"))&&a(e)}:(c="valueOf toString toLocaleString propertyIsEnumerable isPrototypeOf hasOwnProperty constructor".split(" "),O=function(b,a){var d="[object Function]"==v.call(b),e,f=!d&&"function"!=
typeof b.constructor&&l[typeof b.hasOwnProperty]&&b.hasOwnProperty||n;for(e in b)d&&"prototype"==e||!f.call(b,e)||a(e);for(d=c.length;e=c[--d];f.call(b,e)&&a(e));});return O(b,a)};if(!e("json-stringify")){var T={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},W=function(b,a){return("000000"+(a||0)).slice(-b)},aa=function(b){for(var a='"',d=0,e=b.length,f=!p||10<e,c=f&&(p?b.split(""):b);d<e;d++){var h=b.charCodeAt(d);switch(h){case 8:case 9:case 10:case 12:case 13:case 34:case 92:a+=
T[h];break;default:a=32>h?a+("\\u00"+W(2,h.toString(16))):a+(f?c[d]:b.charAt(d))}}return a+'"'},J=function(b,a,d,e,f,c,h){var k;try{var r=a[b]}catch(Nc){}if("object"==typeof r&&r){var l=v.call(r);if("[object Date]"!=l||n.call(r,"toJSON"))"function"==typeof r.toJSON&&("[object Number]"!=l&&"[object String]"!=l&&"[object Array]"!=l||n.call(r,"toJSON"))&&(r=r.toJSON(b));else if(r>-1/0&&r<1/0){if(U){var t=P(r/864E5);for(l=P(t/365.2425)+1970-1;U(l+1,0)<=t;l++);for(k=P((t-U(l,0))/30.42);U(l,k+1)<=t;k++);
t=1+t-U(l,k);var g=(r%864E5+864E5)%864E5;var x=P(g/36E5)%24;var B=P(g/6E4)%60;var z=P(g/1E3)%60;g%=1E3}else l=r.getUTCFullYear(),k=r.getUTCMonth(),t=r.getUTCDate(),x=r.getUTCHours(),B=r.getUTCMinutes(),z=r.getUTCSeconds(),g=r.getUTCMilliseconds();r=(0>=l||1E4<=l?(0>l?"-":"+")+W(6,0>l?-l:l):W(4,l))+"-"+W(2,k+1)+"-"+W(2,t)+"T"+W(2,x)+":"+W(2,B)+":"+W(2,z)+"."+W(3,g)+"Z"}else r=null}d&&(r=d.call(a,b,r));if(null===r)return"null";l=v.call(r);if("[object Boolean]"==l)return""+r;if("[object Number]"==l)return r>
-1/0&&r<1/0?""+r:"null";if("[object String]"==l)return aa(""+r);if("object"==typeof r){for(b=h.length;b--;)if(h[b]===r)throw m();h.push(r);var A=[];a=c;c+=f;if("[object Array]"==l){k=0;for(b=r.length;k<b;k++)l=J(k,r,d,e,f,c,h),A.push(l===q?"null":l);b=A.length?f?"[\n"+c+A.join(",\n"+c)+"\n"+a+"]":"["+A.join(",")+"]":"[]"}else O(e||r,function(b){var a=J(b,r,d,e,f,c,h);a!==q&&A.push(aa(b)+":"+(f?" ":"")+a)}),b=A.length?f?"{\n"+c+A.join(",\n"+c)+"\n"+a+"}":"{"+A.join(",")+"}":"{}";h.pop();return b}};
d.stringify=function(b,a,d){var e;if(l[typeof a]&&a)if("[object Function]"==(e=v.call(a)))var f=a;else if("[object Array]"==e){var c={};for(var h=0,k=a.length,r;h<k;r=a[h++],(e=v.call(r),"[object String]"==e||"[object Number]"==e)&&(c[r]=1));}if(d)if("[object Number]"==(e=v.call(d))){if(0<(d-=d%1)){var m="";for(10<d&&(d=10);m.length<d;m+=" ");}}else"[object String]"==e&&(m=10>=d.length?d:d.slice(0,10));return J("",(r={},r[""]=b,r),f,c,m,"",[])}}if(!e("json-parse")){var S=c.fromCharCode,ha={92:"\\",
34:'"',47:"/",98:"\b",116:"\t",110:"\n",102:"\f",114:"\r"},L,ma,X=function(){L=ma=null;throw r();},R=function(){for(var b=ma,a=b.length,d,e,f,c,h;L<a;)switch(h=b.charCodeAt(L),h){case 9:case 10:case 13:case 32:L++;break;case 123:case 125:case 91:case 93:case 58:case 44:return d=p?b.charAt(L):b[L],L++,d;case 34:d="@";for(L++;L<a;)if(h=b.charCodeAt(L),32>h)X();else if(92==h)switch(h=b.charCodeAt(++L),h){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:d+=ha[h];L++;break;case 117:e=
++L;for(f=L+4;L<f;L++)h=b.charCodeAt(L),48<=h&&57>=h||97<=h&&102>=h||65<=h&&70>=h||X();d+=S("0x"+b.slice(e,L));break;default:X()}else{if(34==h)break;h=b.charCodeAt(L);for(e=L;32<=h&&92!=h&&34!=h;)h=b.charCodeAt(++L);d+=b.slice(e,L)}if(34==b.charCodeAt(L))return L++,d;X();default:e=L;45==h&&(c=!0,h=b.charCodeAt(++L));if(48<=h&&57>=h){for(48==h&&(h=b.charCodeAt(L+1),48<=h&&57>=h)&&X();L<a&&(h=b.charCodeAt(L),48<=h&&57>=h);L++);if(46==b.charCodeAt(L)){for(f=++L;f<a&&(h=b.charCodeAt(f),48<=h&&57>=h);f++);
f==L&&X();L=f}h=b.charCodeAt(L);if(101==h||69==h){h=b.charCodeAt(++L);43!=h&&45!=h||L++;for(f=L;f<a&&(h=b.charCodeAt(f),48<=h&&57>=h);f++);f==L&&X();L=f}return+b.slice(e,L)}c&&X();if("true"==b.slice(L,L+4))return L+=4,!0;if("false"==b.slice(L,L+5))return L+=5,!1;if("null"==b.slice(L,L+4))return L+=4,null;X()}return"$"},Y=function(b){var a,d;"$"==b&&X();if("string"==typeof b){if("@"==(p?b.charAt(0):b[0]))return b.slice(1);if("["==b){for(a=[];;d||(d=!0)){b=R();if("]"==b)break;d&&(","==b?(b=R(),"]"==
b&&X()):X());","==b&&X();a.push(Y(b))}return a}if("{"==b){for(a={};;d||(d=!0)){b=R();if("}"==b)break;d&&(","==b?(b=R(),"}"==b&&X()):X());","!=b&&"string"==typeof b&&"@"==(p?b.charAt(0):b[0])&&":"==R()||X();a[b.slice(1)]=Y(R())}return a}X()}return b},Ca=function(b,a,d){d=na(b,a,d);d===q?delete b[a]:b[a]=d},na=function(b,a,d){var e=b[a],f;if("object"==typeof e&&e)if("[object Array]"==v.call(e))for(f=e.length;f--;)Ca(e,f,d);else O(e,function(b){Ca(e,b,d)});return d.call(b,a,e)};d.parse=function(b,a){var d;
L=0;ma=""+b;b=Y(R());"$"!=R()&&X();L=ma=null;return a&&"[object Function]"==v.call(a)?na((d={},d[""]=b,d),"",a):b}}}d.runInContext=a;return d}var f=c(324),l={"function":!0,object:!0},v=l[typeof g]&&g&&!g.nodeType&&g,t=l[typeof window]&&window||this,m=v&&l[typeof u]&&u&&!u.nodeType&&"object"==typeof n&&n;!m||m.global!==m&&m.window!==m&&m.self!==m||(t=m);if(v&&!f)a(t,v);else{var k=t.JSON,e=t.JSON3,d=!1;var b=a(t,t.JSON3={noConflict:function(){d||(d=!0,t.JSON=k,t.JSON3=e,k=e=null);return b}});t.JSON=
{parse:b.parse,stringify:b.stringify}}f&&!(q=b,void 0!==q&&(u.exports=q))}).call(this)}).call(g,c(323)(p),c(7))},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a,f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");
}c.d(g,"b",function(){return l});c.d(g,"c",function(){return v});g.d=function(a,c){return new Promise(function(k,e){if(a===f)c(k,e,f);else{var d=new l,b=a.add(function(){d.cancel()});c(function(a){b();k(a)},function(a){b();e(a)},d)}})};var q=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}();p=new (function(){function a(){n(this,
a);this.name="CancellationError";this.message="CANCELED"}q(a,[{key:"toString",value:function(){return"CANCELED"}}]);return a}());g.a=p;var a=function(){},f={isCanceled:!1,add:function(){return a},remove:a};g.e=f;var l=function(){function f(){n(this,f)}q(f,[{key:"cancel",value:function(){var a=this.handlers;if(null!==a&&(this.handlers=null,void 0!==a)){a=$jscomp.makeIterator(a);for(var f=a.next();!f.done;f=a.next())f=f.value,f()}}},{key:"add",value:function(f){var c=this,e=this.handlers;if(null===
e)return f(),a;void 0===e&&(e=this.handlers=new Set);e.add(f);return function(){c.remove(f)}}},{key:"remove",value:function(a){var f=this.handlers;null!=f&&f.delete(a)}},{key:"isCanceled",get:function(){return null===this.handlers}}]);return f}(),v=function(a){function c(){n(this,c);var a=(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");a=!a||"object"!==typeof a&&"function"!==typeof a?this:
a;a.consumers=new Set;return a}u(c,a);q(c,[{key:"addConsumer",value:function(a){var e=this;a=void 0===a?f:a;var d=this.consumers;d.has(a)||a.isCanceled||(d.add(a),a.add(function(){d.delete(a);0===d.size&&e.cancel()}))}}]);return c}(l)},function(p,g,c){function u(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}function n(b,a){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?
b:a}function q(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(b,a):b.__proto__=a)}c.d(g,"b",function(){return m});c.d(g,"a",function(){return k});c.d(g,"c",function(){return e});c.d(g,"d",function(){return d});p=c(192);c.n(p);p=c(0);var a=c(10),f=c(3),l=c(26),v=function(){function b(b,
a){for(var d=0;d<a.length;d++){var e=a[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(a,d,e){d&&b(a.prototype,d);e&&b(a,e);return a}}(),t=function h(a,d,e){null===a&&(a=Function.prototype);var f=Object.getOwnPropertyDescriptor(a,d);if(void 0===f){if(a=Object.getPrototypeOf(a),null!==a)return h(a,d,e)}else{if("value"in f)return f.value;d=f.get;return void 0===d?void 0:d.call(e)}},m=function(d){function e(a){a=void 0===
a?new l.b:a;u(this,e);var d=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.visibility=a;d.element=document.createElement("div");d.element.classList.add("neuroglancer-tab-content");return d}q(e,d);v(e,[{key:"disposed",value:function(){Object(a.b)(this.element);t(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"visible",get:function(){return this.visibility.visible}}]);return e}(p.a);c=function(a){function d(){u(this,d);var a=n(this,(d.__proto__||
Object.getPrototypeOf(d)).apply(this,arguments));a.changed=new f.a;a.options=new Map;a.optionsChanged=new f.a;a.selectedValue=void 0;a.defaultValue=void 0;a.ready_=!0;return a}q(d,a);v(d,[{key:"add",value:function(a,d){var e=this.options;if(e.has(a))throw Error("Option already defined: "+JSON.stringify(a)+".");e.set(a,d);this.optionsChanged.dispatch();void 0===this.defaultValue&&(this.default=a)}},{key:"toJSON",value:function(){var a=this.value;if(a!==this.defaultValue)return a}},{key:"reset",value:function(){this.value=
void 0}},{key:"restoreState",value:function(a){"string"!==typeof a&&(a=void 0);this.value=a}},{key:"value",get:function(){var a=this.selectedValue;return void 0!==a?a:this.defaultValue},set:function(a){void 0!==a&&this.ready_&&!this.options.has(a)&&(a=void 0);this.selectedValue!==a&&(this.selectedValue=a,this.changed.dispatch())}},{key:"default",set:function(a){this.defaultValue!==a&&(this.defaultValue=a,this.changed.dispatch())},get:function(){return this.defaultValue}},{key:"validValue",get:function(){var a=
this.selectedValue;return void 0!==a&&this.options.has(a)?a:this.defaultValue}},{key:"ready",get:function(){return this.ready_},set:function(a){if(a!==this.ready_){if(this.ready_=a)this.value=this.value;this.changed.dispatch()}}}]);return d}(p.a);var k=function(d){function e(a,d){d=void 0===d?new l.b:d;u(this,e);var c=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));c.getter=a;c.visibility=d;c.element=document.createElement("div");c.tabs=new Map;c.tabVisibilityChanged=new f.b;c.element.className=
"neuroglancer-stack-view";c.registerDisposer(d.changed.add(function(){return c.updateSelectedTab()}));c.updateSelectedTab();return c}q(e,d);v(e,[{key:"invalidate",value:function(a){var d=this.tabs,e=d.get(a);void 0!==e&&(e.dispose(),d.delete(a),a===this.displayedTab&&(this.displayedTab=void 0,this.updateSelectedTab()))}},{key:"hideTab",value:function(a){var d=this.tabs.get(a);void 0!==d&&(d.visibility.value=l.b.IGNORED,d.element.style.display="none");this.tabVisibilityChanged.dispatch(a,!1)}},{key:"showTab",
value:function(a){var d=this.tabs,e=d.get(a);void 0===e&&(e=this.getter(a),this.element.appendChild(e.element),d.set(a,e));e.element.style.display=null;e.visibility.value=l.b.VISIBLE;this.tabVisibilityChanged.dispatch(a,!0)}},{key:"updateSelectedTab",value:function(){var a=this.displayedTab,d=this.visible?this.selectedTabValue:void 0;d!==a&&(void 0!==a&&this.hideTab(a),this.displayedTab=d,void 0!==d&&this.showTab(d))}},{key:"invalidateAll",value:function(){for(var a=this.tabs,d=$jscomp.makeIterator(a.values()),
e=d.next();!e.done;e=d.next())e.value.dispose();a.clear();this.updateSelectedTab()}},{key:"disposed",value:function(){this.selectedTabValue=void 0;this.invalidateAll();Object(a.b)(this.element);t(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"visible",get:function(){return this.visibility.visible}},{key:"selected",get:function(){return this.selectedTabValue},set:function(a){this.selectedTabValue=a;this.updateSelectedTab()}}]);return e}(p.a),e=function(a){function d(){u(this,
d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,a);return d}(c),d=function(d){function e(a,d){d=void 0===d?new l.b:d;u(this,e);var f=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));f.state=a;f.visibility=d;f.element=document.createElement("div");f.tabBar=document.createElement("div");f.tabLabels=new Map;f.tabsGeneration=-1;a=f.element;var c=f.tabBar;a.className="neuroglancer-tab-view";c.className="neuroglancer-tab-view-bar";a.appendChild(c);f.registerDisposer(d.changed.add(function(){f.updateTabs()}));
d=f.stack=f.registerDisposer(new k(function(a){return f.state.options.get(a).getter()},f.visibility));a.appendChild(d.element);f.registerDisposer(f.state.changed.add(function(){return f.updateSelectedTab()}));f.registerDisposer(f.state.optionsChanged.add(function(){return f.updateTabs()}));f.stack.tabVisibilityChanged.add(function(a,d){a=f.tabLabels.get(a);d?a.classList.add("neuroglancer-selected-tab-label"):a.classList.remove("neuroglancer-selected-tab-label")});f.updateTabs();return f}q(e,d);v(e,
[{key:"updateTabs",value:function(){this.tabsGeneration!==this.state.optionsChanged.count&&(this.destroyTabs(),this.visible&&this.makeTabs(),this.updateSelectedTab())}},{key:"updateSelectedTab",value:function(){this.stack.selected=this.state.value}},{key:"destroyTabs",value:function(){-1!==this.tabsGeneration&&(this.stack.selected=void 0,this.tabLabels.clear(),Object(a.a)(this.tabBar),this.tabsGeneration=-1,this.stack.invalidateAll())}},{key:"makeTabs",value:function(){var a=this,d=this.tabBar,e=
this.tabLabels,f=Array.from(this.state.options);f.sort(function(a,d){a=$jscomp.makeIterator(a);a.next();a=a.next().value;a=void 0===a.order?0:a.order;d=$jscomp.makeIterator(d);d.next();d=d.next().value;return a-(void 0===d.order?0:d.order)});var c={};f=$jscomp.makeIterator(f);for(var h=f.next();!h.done;c={id:c.id},h=f.next()){h=$jscomp.makeIterator(h.value);c.id=h.next().value;h=h.next().value.label;var k=document.createElement("div");k.classList.add("neuroglancer-tab-label");k.textContent=h;k.addEventListener("click",
function(d){return function(){a.state.value=d.id}}(c));e.set(c.id,k);d.appendChild(k)}this.tabsGeneration=this.state.optionsChanged.count}},{key:"disposed",value:function(){Object(a.a)(this.tabBar);this.tabLabels.clear();Object(a.b)(this.element);t(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"visible",get:function(){return this.visibility.visible}}]);return e}(p.a)},function(p,g,c){c.d(g,"d",function(){return u});var u;(function(c){c[c.GPU_MEMORY=0]=
"GPU_MEMORY";c[c.SYSTEM_MEMORY=1]="SYSTEM_MEMORY";c[c.SYSTEM_MEMORY_WORKER=2]="SYSTEM_MEMORY_WORKER";c[c.DOWNLOADING=3]="DOWNLOADING";c[c.QUEUED=4]="QUEUED";c[c.NEW=5]="NEW";c[c.FAILED=6]="FAILED";c[c.EXPIRED=7]="EXPIRED"})(u||(u={}));var n;(function(c){c[c.FIRST_TIER=0]="FIRST_TIER";c[c.FIRST_ORDERED_TIER=0]="FIRST_ORDERED_TIER";c[c.VISIBLE=0]="VISIBLE";c[c.PREFETCH=1]="PREFETCH";c[c.LAST_ORDERED_TIER=1]="LAST_ORDERED_TIER";c[c.RECENT=2]="RECENT";c[c.LAST_TIER=2]="LAST_TIER"})(n||(n={}));g.b="ChunkQueueManager";
g.a="ChunkManager";g.c="ChunkSource.invalidate"},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function q(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function a(a,d){void 0===d&&(d=-1===a.indexOf("/")?":":"/");a=a.lastIndexOf(d);return-1===a?0:a+1}c.d(g,"a",function(){return t});c.d(g,"b",function(){return k});var f=c(34),l=c(54);p=c(0);var v=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,
e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),t=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,a);return d}(p.a),m=/^(?:([a-zA-Z-+_]+):\/\/)?(.*)$/,k=function(e){function d(){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments));b.dataSources=new Map;return b}q(d,e);v(d,[{key:"register",value:function(b,a){this.dataSources.set(b,this.registerDisposer(a))}},{key:"getDataSource",
value:function(b){b=b.match(m);if(null===b||void 0===b[1])throw Error('Data source URL must have the form "<protocol>://<path>".');var a=b[1],d=this.dataSources.get(a);if(void 0===d)throw Error("Unsupported data source: "+JSON.stringify(a)+".");return[d,b[2],a]}},{key:"getVolume",value:function(b,a,d,e){d=void 0===d?{}:d;e=void 0===e?f.e:e;a=$jscomp.makeIterator(this.getDataSource(a));var c=a.next().value,h=a.next().value;return new Promise(function(a){a(c.getVolume(b,h,d,e))})}},{key:"getAnnotationSource",
value:function(a,d,e){e=void 0===e?f.e:e;d=$jscomp.makeIterator(this.getDataSource(d));var b=d.next().value,c=d.next().value;return new Promise(function(d){d(b.getAnnotationSource(a,c,e))})}},{key:"getVectorGraphicsSource",value:function(a,d,e,c){e=void 0===e?{}:e;c=void 0===c?f.e:c;d=$jscomp.makeIterator(this.getDataSource(d));var b=d.next().value,h=d.next().value;return new Promise(function(d){d(b.getVectorGraphicsSource(a,h,e,c))})}},{key:"getMeshSource",value:function(a,d,e){e=void 0===e?f.e:
e;d=$jscomp.makeIterator(this.getDataSource(d));var b=d.next().value,c=d.next().value;return new Promise(function(d){d(b.getMeshSource(a,c,e))})}},{key:"getSkeletonSource",value:function(a,d,e){e=void 0===e?f.e:e;d=$jscomp.makeIterator(this.getDataSource(d));var b=d.next().value,c=d.next().value;return new Promise(function(d){d(b.getSkeletonSource(a,c,e))})}},{key:"volumeCompleter",value:function(a,d,e){e=void 0===e?f.e:e;var b=a.match(m),c=b[1];if(void 0===c){d=[];e=$jscomp.makeIterator(this.dataSources);
for(b=e.next();!b.done;b=e.next()){var h=$jscomp.makeIterator(b.value);b=h.next().value;h=h.next().value;b+="://";b.startsWith(a)&&d.push({value:b,description:h.description})}return Promise.resolve({offset:0,completions:d})}a=this.dataSources.get(c);return void 0!==a&&void 0!==a.volumeCompleter?a.volumeCompleter(b[2],d,e).then(function(a){return Object(l.a)(c.length+3,a)}):Promise.reject(null)}},{key:"suggestLayerName",value:function(b){b=$jscomp.makeIterator(this.getDataSource(b));var d=b.next().value;
b=b.next().value;d=d.suggestLayerName;if(void 0!==d)return d(b);d=a(b,void 0);return b.substring(d)}},{key:"findSourceGroup",value:function(b){var d=$jscomp.makeIterator(this.getDataSource(b));b=d.next().value;var e=d.next().value;d=d.next().value;return(b.findSourceGroup||a)(e)+d.length+3}}]);return d}(p.a)},function(p,g,c){(function(g){var n=c(48),q={},a=!1,f=g.chrome&&g.chrome.app&&g.chrome.app.runtime;p.exports={attachEvent:function(a,f){"undefined"!==typeof g.addEventListener?g.addEventListener(a,
f,!1):g.document&&g.attachEvent&&(g.document.attachEvent("on"+a,f),g.attachEvent("on"+a,f))},detachEvent:function(a,f){"undefined"!==typeof g.addEventListener?g.removeEventListener(a,f,!1):g.document&&g.detachEvent&&(g.document.detachEvent("on"+a,f),g.detachEvent("on"+a,f))},unloadAdd:function(c){if(f)return null;var l=n.string(8);q[l]=c;a&&setTimeout(this.triggerUnloadCallbacks,0);return l},unloadDel:function(a){a in q&&delete q[a]},triggerUnloadCallbacks:function(){for(var a in q)q[a](),delete q[a]}};
f||p.exports.attachEvent("unload",function(){a||(a=!0,p.exports.triggerUnloadCallbacks())})}).call(g,c(7))},function(p,g,c){g.c=function(c,g,q,a){for(;g<q;){var f=c[g];a(f)?++g:(--q,c[g]=c[q],c[q]=f)}return q};g.b=function(c,g){if(c.length===g)return c;g=new c.constructor(g);g.set(c);return g};g.d=function(c,g,q,a){for(var f=c.length/g,l=new c.constructor(c.length*q*a),v=c.length*a,t=g*a,m=0;m<f;++m)for(var k=0;k<g;++k)for(var e=c[m*g+k],d=m*t+k,b=0;b<q;++b)for(var h=0;h<a;++h)l[b*v+h*g+d]=e;return l};
g.a=function(c,g,q,a,f){a=void 0===a?0:a;for(f=void 0===f?c.length:f;a<f;){var l=a+f-1>>1,v=q(g,c[l]);if(0<v)a=l+1;else if(0>v)f=l;else return l}return~a}},function(p,g){},function(p,g,c){function u(a,e){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==typeof e&&"function"!==typeof e?a:e}function n(a,e){if("function"!==typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);a.prototype=
Object.create(e&&e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(a,e):a.__proto__=e)}c.d(g,"b",function(){return v});c.d(g,"a",function(){return m});var q=c(66);p=c(0);var a=c(53),f=function(){function a(a,d){for(var b=0;b<d.length;b++){var e=d[b];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(e,d,b){d&&a(e.prototype,d);b&&a(e,b);return e}}(),
l=function e(a,b,f){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return e(a,b,f)}else{if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(f)}};c(230);var v=0,t=a.a.fromObject({escape:{action:"close"}}),m=function(e){function d(){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");var b=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));b.keyMap=new a.a;b.keyMap.addParent(t,
Number.NEGATIVE_INFINITY);++v;var e=b.container=document.createElement("div");e.className="overlay";var f=b.content=document.createElement("div");b.registerDisposer(new q.a(f));f.className="overlay-content";e.appendChild(f);document.body.appendChild(e);b.registerDisposer(new a.b(b.container,b.keyMap));b.registerEventListener(e,"action:close",function(){b.dispose()});f.focus();return b}n(d,e);f(d,[{key:"disposed",value:function(){--v;document.body.removeChild(this.container);l(d.prototype.__proto__||
Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}}]);return d}(p.a)},function(p,g,c){(function(c,g){p.exports=g()})(this,function(){function c(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function g(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function q(a,b){return g(a).appendChild(b)}function a(a,b,d,e){a=document.createElement(a);d&&(a.className=d);e&&(a.style.cssText=e);if("string"==typeof b)a.appendChild(document.createTextNode(b));else if(b)for(d=
0;d<b.length;++d)a.appendChild(b[d]);return a}function f(b,d,e,f){b=a(b,d,e,f);b.setAttribute("role","presentation");return b}function l(a,b){3==b.nodeType&&(b=b.parentNode);if(a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)}function v(){try{var a=document.activeElement}catch(Q){a=document.body||null}for(;a&&a.shadowRoot&&a.shadowRoot.activeElement;)a=a.shadowRoot.activeElement;return a}function t(a,b){var d=a.className;c(b).test(d)||(a.className+=
(d?" ":"")+b)}function m(a,b){a=a.split(" ");for(var d=0;d<a.length;d++)a[d]&&!c(a[d]).test(b)&&(b+=" "+a[d]);return b}function k(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function e(a,b,d){b||(b={});for(var e in a)!a.hasOwnProperty(e)||!1===d&&b.hasOwnProperty(e)||(b[e]=a[e]);return b}function d(a,b,d,e,f){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));e=e||0;for(f=f||0;;){var w=a.indexOf("\t",e);if(0>w||w>=b)return f+(b-e);f+=w-e;f+=d-f%
d;e=w+1}}function b(a,b){for(var d=0;d<a.length;++d)if(a[d]==b)return d;return-1}function h(a,b,d){for(var e=0,w=0;;){var f=a.indexOf("\t",e);-1==f&&(f=a.length);var c=f-e;if(f==a.length||w+c>=b)return e+Math.min(c,b-w);w+=f-e;w+=d-w%d;e=f+1;if(w>=b)return e}}function r(a){for(;Oc.length<=a;)Oc.push(x(Oc)+" ");return Oc[a]}function x(a){return a[a.length-1]}function z(a,b){for(var d=[],e=0;e<a.length;e++)d[e]=b(a[e],e);return d}function A(a,b,d){for(var e=0,w=d(b);e<a.length&&d(a[e])<=w;)e++;a.splice(e,
0,b)}function p(){}function y(a,b){Object.create?a=Object.create(a):(p.prototype=a,a=new p);b&&e(b,a);return a}function E(a){return/\w/.test(a)||"\u0080"<a&&(a.toUpperCase()!=a.toLowerCase()||bg.test(a))}function G(a,b){return b?-1<b.source.indexOf("\\w")&&E(a)?!0:b.test(a):E(a)}function H(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function B(a){return 768<=a.charCodeAt(0)&&cg.test(a)}function C(a,b,d){for(;(0>d?0<b:b<a.length)&&B(a.charAt(b));)b+=d;return b}function F(a,b,d){for(var e=
b>d?-1:1;;){if(b==d)return b;var w=(b+d)/2;w=0>e?Math.ceil(w):Math.floor(w);if(w==b)return a(w)?b:d;a(w)?d=w:b=w+e}}function M(b,d,e){this.input=e;this.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler");this.scrollbarFiller.setAttribute("cm-not-content","true");this.gutterFiller=a("div",null,"CodeMirror-gutter-filler");this.gutterFiller.setAttribute("cm-not-content","true");this.lineDiv=f("div",null,"CodeMirror-code");this.selectionDiv=a("div",null,null,"position: relative; z-index: 1");
this.cursorDiv=a("div",null,"CodeMirror-cursors");this.measure=a("div",null,"CodeMirror-measure");this.lineMeasure=a("div",null,"CodeMirror-measure");this.lineSpace=f("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");var w=f("div",[this.lineSpace],"CodeMirror-lines");this.mover=a("div",[w],null,"position: relative");this.sizer=a("div",[this.mover],"CodeMirror-sizer");this.sizerWidth=null;this.heightForcer=a("div",null,null,
"position: absolute; height: 30px; width: 1px;");this.gutters=a("div",null,"CodeMirror-gutters");this.lineGutter=null;this.scroller=a("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll");this.scroller.setAttribute("tabIndex","-1");this.wrapper=a("div",[this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror");Z&&8>da&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);ta||gb&&Yb||(this.scroller.draggable=!0);b&&(b.appendChild?b.appendChild(this.wrapper):
b(this.wrapper));this.reportedViewFrom=this.reportedViewTo=this.viewFrom=this.viewTo=d.first;this.view=[];this.externalMeasured=this.renderedView=null;this.lastWrapHeight=this.lastWrapWidth=this.viewOffset=0;this.updateLineNumbers=null;this.nativeBarWidth=this.barHeight=this.barWidth=0;this.scrollbarsClipped=!1;this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null;this.alignWidgets=!1;this.maxLine=this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.maxLineLength=0;this.maxLineChanged=
!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.activeTouch=this.selForContextMenu=null;e.init(this)}function I(a,b){b-=a.first;if(0>b||b>=a.size)throw Error("There is no line "+(b+a.first)+" in the document.");for(;!a.lines;)for(var d=0;;++d){var e=a.children[d],w=e.chunkSize();if(b<w){a=e;break}b-=w}return a.lines[b]}function P(a,b,d){var e=[],w=b.line;a.iter(b.line,d.line+1,function(a){a=a.text;w==d.line&&(a=a.slice(0,d.ch));w==b.line&&(a=a.slice(b.ch));e.push(a);
++w});return e}function N(a,b,d){var e=[];a.iter(b,d,function(a){e.push(a.text)});return e}function U(a,b){if(b-=a.height)for(;a;a=a.parent)a.height+=b}function O(a){if(null==a.parent)return null;var d=a.parent;a=b(d.lines,a);for(var e=d.parent;e;d=e,e=e.parent)for(var w=0;e.children[w]!=d;++w)a+=e.children[w].chunkSize();return a+d.first}function T(a,b){var d=a.first;a:do{for(var e=0;e<a.children.length;++e){var w=a.children[e],f=w.height;if(b<f){a=w;continue a}b-=f;d+=w.chunkSize()}return d}while(!a.lines);
for(e=0;e<a.lines.length;++e){w=a.lines[e].height;if(b<w)break;b-=w}return d+e}function W(a,b){return b>=a.first&&b<a.first+a.size}function aa(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function J(a,b,d){void 0===d&&(d=null);if(!(this instanceof J))return new J(a,b,d);this.line=a;this.ch=b;this.sticky=d}function S(a,b){return a.line-b.line||a.ch-b.ch}function ha(a,b){return a.sticky==b.sticky&&0==S(a,b)}function L(a){return J(a.line,a.ch)}function ma(a,b){return 0>S(a,b)?b:a}function X(a,
b){return 0>S(a,b)?a:b}function R(a,b){if(b.line<a.first)return J(a.first,0);var d=a.first+a.size-1;if(b.line>d)return J(d,I(a,d).text.length);a=I(a,b.line).text.length;d=b.ch;b=null==d||d>a?J(b.line,a):0>d?J(b.line,0):b;return b}function Y(a,b){for(var d=[],e=0;e<b.length;e++)d[e]=R(a,b[e]);return d}function Ca(a,b,d){this.marker=a;this.from=b;this.to=d}function na(a,b){if(a)for(var d=0;d<a.length;++d){var e=a[d];if(e.marker==b)return e}}function fb(a,b){if(b.full)return null;var d=W(a,b.from.line)&&
I(a,b.from.line).markedSpans,e=W(a,b.to.line)&&I(a,b.to.line).markedSpans;if(!d&&!e)return null;a=b.from.ch;var w=b.to.ch,f=0==S(b.from,b.to),c;if(d)for(var h=0;h<d.length;++h){var k=d[h],Q=k.marker;if(null==k.from||(Q.inclusiveLeft?k.from<=a:k.from<a)||!(k.from!=a||"bookmark"!=Q.type||f&&k.marker.insertLeft)){var r=null==k.to||(Q.inclusiveRight?k.to>=a:k.to>a);(c||(c=[])).push(new Ca(Q,k.from,r?null:k.to))}}d=c;var m;if(e)for(c=0;c<e.length;++c)if(h=e[c],k=h.marker,null==h.to||(k.inclusiveRight?
h.to>=w:h.to>w)||h.from==w&&"bookmark"==k.type&&(!f||h.marker.insertLeft))Q=null==h.from||(k.inclusiveLeft?h.from<=w:h.from<w),(m||(m=[])).push(new Ca(k,Q?null:h.from-w,null==h.to?null:h.to-w));e=1==b.text.length;w=x(b.text).length+(e?a:0);if(d)for(f=0;f<d.length;++f)if(c=d[f],null==c.to)(h=na(m,c.marker),h)?e&&(c.to=null==h.to?null:h.to+w):c.to=a;if(m)for(a=0;a<m.length;++a)f=m[a],null!=f.to&&(f.to+=w),null==f.from?na(d,f.marker)||(f.from=w,e&&(d||(d=[])).push(f)):(f.from+=w,e&&(d||(d=[])).push(f));
d&&(d=La(d));m&&m!=d&&(m=La(m));a=[d];if(!e){b=b.text.length-2;var l;if(0<b&&d)for(e=0;e<d.length;++e)null==d[e].to&&(l||(l=[])).push(new Ca(d[e].marker,null,null));for(d=0;d<b;++d)a.push(l);a.push(m)}return a}function La(a){for(var b=0;b<a.length;++b){var d=a[b];null!=d.from&&d.from==d.to&&!1!==d.marker.clearWhenEmpty&&a.splice(b--,1)}return a.length?a:null}function qd(a,d,e){var w=null;a.iter(d.line,e.line+1,function(a){if(a.markedSpans)for(var d=0;d<a.markedSpans.length;++d){var e=a.markedSpans[d].marker;
!e.readOnly||w&&-1!=b(w,e)||(w||(w=[])).push(e)}});if(!w)return null;a=[{from:d,to:e}];for(d=0;d<w.length;++d){e=w[d];for(var f=e.find(0),c=0;c<a.length;++c){var h=a[c];if(!(0>S(h.to,f.from)||0<S(h.from,f.to))){var k=[c,1],Q=S(h.from,f.from),r=S(h.to,f.to);(0>Q||!e.inclusiveLeft&&!Q)&&k.push({from:h.from,to:f.from});(0<r||!e.inclusiveRight&&!r)&&k.push({from:f.to,to:h.to});a.splice.apply(a,k);c+=k.length-3}}}return a}function Fb(a){var b=a.markedSpans;if(b){for(var d=0;d<b.length;++d)b[d].marker.detachLine(a);
a.markedSpans=null}}function Ba(a,b){if(b){for(var d=0;d<b.length;++d)b[d].marker.attachLine(a);a.markedSpans=b}}function Za(a,b){var d=a.lines.length-b.lines.length;if(0!=d)return d;d=a.find();var e=b.find(),w=S(d.from,e.from)||(a.inclusiveLeft?-1:0)-(b.inclusiveLeft?-1:0);return w?-w:(d=S(d.to,e.to)||(a.inclusiveRight?1:0)-(b.inclusiveRight?1:0))?d:b.id-a.id}function xa(a,b){a=hb&&a.markedSpans;if(a)for(var d,e=0;e<a.length;++e)if(d=a[e],d.marker.collapsed&&null==(b?d.from:d.to)&&(!w||0>Za(w,d.marker)))var w=
d.marker;return w}function Gb(a,b,d,e,f){a=I(a,b);if(a=hb&&a.markedSpans)for(b=0;b<a.length;++b){var w=a[b];if(w.marker.collapsed){var c=w.marker.find(0),h=S(c.from,d)||(w.marker.inclusiveLeft?-1:0)-(f.inclusiveLeft?-1:0),k=S(c.to,e)||(w.marker.inclusiveRight?1:0)-(f.inclusiveRight?1:0);if(!(0<=h&&0>=k||0>=h&&0<=k)&&(0>=h&&(w.marker.inclusiveRight&&f.inclusiveLeft?0<=S(c.to,d):0<S(c.to,d))||0<=h&&(w.marker.inclusiveRight&&f.inclusiveLeft?0>=S(c.from,e):0>S(c.from,e))))return!0}}}function Ha(a){for(var b;b=
xa(a,!0);)a=b.find(-1,!0).line;return a}function Xb(a,b){a=I(a,b);var d=Ha(a);return a==d?b:O(d)}function Mc(a,b){if(b>a.lastLine())return b;var d=I(a,b);if(!$a(a,d))return b;for(;a=xa(d,!1);)d=a.find(1,!0).line;return O(d)+1}function $a(a,b){var d=hb&&b.markedSpans;if(d)for(var e,w=0;w<d.length;++w)if(e=d[w],e.marker.collapsed&&(null==e.from||!e.marker.widgetNode&&0==e.from&&e.marker.inclusiveLeft&&eb(a,b,e)))return!0}function eb(a,b,d){if(null==d.to)return b=d.marker.find(1,!0),eb(a,b.line,na(b.line.markedSpans,
d.marker));if(d.marker.inclusiveRight&&d.to==b.text.length)return!0;for(var e,w=0;w<b.markedSpans.length;++w)if(e=b.markedSpans[w],e.marker.collapsed&&!e.marker.widgetNode&&e.from==d.to&&(null==e.to||e.to!=d.from)&&(e.marker.inclusiveLeft||d.marker.inclusiveRight)&&eb(a,b,e))return!0}function Ia(a){a=Ha(a);for(var b=0,d=a.parent,e=0;e<d.lines.length;++e){var w=d.lines[e];if(w==a)break;else b+=w.height}for(a=d.parent;a;d=a,a=d.parent)for(e=0;e<a.children.length&&(w=a.children[e],w!=d);++e)b+=w.height;
return b}function ya(a){if(0==a.height)return 0;for(var b=a.text.length,d,e=a;d=xa(e,!0);)d=d.find(0,!0),e=d.from.line,b+=d.from.ch-d.to.ch;for(e=a;d=xa(e,!1);)a=d.find(0,!0),b-=e.text.length-a.from.ch,e=a.to.line,b+=e.text.length-a.to.ch;return b}function ab(a){var b=a.display;a=a.doc;b.maxLine=I(a,a.first);b.maxLineLength=ya(b.maxLine);b.maxLineChanged=!0;a.iter(function(a){var d=ya(a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function Nc(a,b,d,e){if(!a)return e(b,d,"ltr",0);for(var w=
!1,f=0;f<a.length;++f){var c=a[f];if(c.from<d&&c.to>b||b==d&&c.to==b)e(Math.max(c.from,b),Math.min(c.to,d),1==c.level?"rtl":"ltr",f),w=!0}w||e(b,d,"ltr")}function Ua(a,b,d){var e;Zb=null;for(var w=0;w<a.length;++w){var f=a[w];if(f.from<b&&f.to>b)return w;f.to==b&&(f.from!=f.to&&"before"==d?e=w:Zb=w);f.from==b&&(f.from!=f.to&&"before"!=d?e=w:Zb=w)}return null!=e?e:Zb}function Da(a,b){var d=a.order;null==d&&(d=a.order=dg(a.text,b));return d}function ia(a,d,e){if(a.removeEventListener)a.removeEventListener(d,
e,!1);else if(a.detachEvent)a.detachEvent("on"+d,e);else{var w=(a=a._handlers)&&a[d];w&&(e=b(w,e),-1<e&&(a[d]=w.slice(0,e).concat(w.slice(e+1))))}}function ea(a,b){var d=a._handlers&&a._handlers[b]||Pc;if(d.length)for(var e=Array.prototype.slice.call(arguments,2),w=0;w<d.length;++w)d[w].apply(null,e)}function ja(a,b,d){"string"==typeof b&&(b={type:b,preventDefault:function(){this.defaultPrevented=!0}});ea(a,d||b.type,a,b);return pb(b)||b.codemirrorIgnore}function $b(a){var d=a._handlers&&a._handlers.cursorActivity;
if(d){a=a.curOp.cursorActivityHandlers||(a.curOp.cursorActivityHandlers=[]);for(var e=0;e<d.length;++e)-1==b(a,d[e])&&a.push(d[e])}}function Ea(a,b){return 0<(a._handlers&&a._handlers[b]||Pc).length}function Ma(a){a.prototype.on=function(a,b){V(this,a,b)};a.prototype.off=function(a,b){ia(this,a,b)}}function oa(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Qc(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function pb(a){return null!=a.defaultPrevented?a.defaultPrevented:
0==a.returnValue}function qb(a){oa(a);Qc(a)}function ac(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));Na&&a.ctrlKey&&1==b&&(b=3);return b}function ib(b){if(null==rd){var d=a("span","\u200b");q(b,a("span",[d,document.createTextNode("x")]));0!=b.firstChild.offsetHeight&&(rd=1>=d.offsetWidth&&2<d.offsetHeight&&!(Z&&8>da))}b=rd?a("span","\u200b"):a("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px");b.setAttribute("cm-text","");return b}function Rc(a,
b){2<arguments.length&&(b.dependencies=Array.prototype.slice.call(arguments,2));sd[a]=b}function bb(a){if("string"==typeof a&&Hb.hasOwnProperty(a))a=Hb[a];else if(a&&"string"==typeof a.name&&Hb.hasOwnProperty(a.name)){var b=Hb[a.name];"string"==typeof b&&(b={name:b});a=y(b,a);a.name=b.name}else{if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return bb("application/xml");if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+json$/.test(a))return bb("application/json")}return"string"==typeof a?{name:a}:
a||{name:"null"}}function Oa(a,b){b=bb(b);var d=sd[b.name];if(!d)return Oa(a,"text/plain");a=d(a,b);if(Ib.hasOwnProperty(b.name)){d=Ib[b.name];for(var e in d)d.hasOwnProperty(e)&&(a.hasOwnProperty(e)&&(a["_"+e]=a[e]),a[e]=d[e])}a.name=b.name;b.helperType&&(a.helperType=b.helperType);if(b.modeProps)for(var f in b.modeProps)a[f]=b.modeProps[f];return a}function ua(a,b){a=Ib.hasOwnProperty(a)?Ib[a]:Ib[a]={};e(b,a)}function Pa(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);a={};for(var d in b){var e=
b[d];e instanceof Array&&(e=e.concat([]));a[d]=e}return a}function Jb(a,b){for(var d;a.innerMode;){d=a.innerMode(b);if(!d||d.mode==a)break;b=d.state;a=d.mode}return d||{mode:a,state:b}}function bc(a,b,d){return a.startState?a.startState(b,d):!0}function Sc(a,b,d,e){var f=[a.state.modeGen],w={};ie(a,b.text,a.doc.mode,d,function(a,b){return f.push(a,b)},w,e);var c=d.state;e=function(e){d.baseTokens=f;var h=a.state.overlays[e],k=1,Q=0;d.state=!0;ie(a,b.text,h.mode,d,function(a,b){for(var d=k;Q<a;){var e=
f[k];e>a&&f.splice(k,1,a,f[k+1],e);k+=2;Q=Math.min(a,e)}if(b)if(h.opaque)f.splice(d,k-d,a,"overlay "+b),k=d+2;else for(;d<k;d+=2)a=f[d+1],f[d+1]=(a?a+" ":"")+"overlay "+b},w);d.state=c;d.baseTokens=null;d.baseTokenPos=1};for(var h=0;h<a.state.overlays.length;++h)e(h);return{styles:f,classes:w.bgClass||w.textClass?w:null}}function jb(a,b,d){if(!b.styles||b.styles[0]!=a.state.modeGen){var e=Va(a,O(b)),f=b.text.length>a.options.maxHighlightLength&&Pa(a.doc.mode,e.state),c=Sc(a,b,e);f&&(e.state=f);b.stateAfter=
e.save(!f);b.styles=c.styles;c.classes?b.styleClasses=c.classes:b.styleClasses&&(b.styleClasses=null);d===a.doc.highlightFrontier&&(a.doc.modeFrontier=Math.max(a.doc.modeFrontier,++a.doc.highlightFrontier))}return b.styles}function Va(a,b,d){var e=a.doc,f=a.display;if(!e.mode.startState)return new Wa(e,!0,b);var c=eg(a,b,d),w=c>e.first&&I(e,c-1).stateAfter,h=w?Wa.fromSaved(e,w,c):new Wa(e,bc(e.mode),c);e.iter(c,b,function(d){cc(a,d.text,h);var e=h.line;d.stateAfter=e==b-1||0==e%5||e>=f.viewFrom&&
e<f.viewTo?h.save():null;h.nextLine()});d&&(e.modeFrontier=h.line);return h}function cc(a,b,d,e){var f=a.doc.mode;a=new ka(b,a.options.tabSize,d);a.start=a.pos=e||0;for(""==b&&K(f,d.state);!a.eol();)dc(f,a,d.state),a.start=a.pos}function K(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode&&(a=Jb(a,b),a.mode.blankLine))return a.mode.blankLine(a.state)}function dc(a,b,d,e){for(var f=0;10>f;f++){e&&(e[0]=Jb(a,d).mode);var c=a.token(b,d);if(b.pos>b.start)return c}throw Error("Mode "+a.name+" failed to advance stream.");
}function je(a,b,d,e){var f=a.doc,c=f.mode;b=R(f,b);var w=I(f,b.line);d=Va(a,b.line,d);a=new ka(w.text,a.options.tabSize,d);var h;for(e&&(h=[]);(e||a.pos<b.ch)&&!a.eol();){a.start=a.pos;var k=dc(c,a,d.state);e&&h.push(new ke(a,k,Pa(f.mode,d.state)))}return e?h:new ke(a,k,d.state)}function le(a,b){if(a)for(;;){var d=a.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!d)break;a=a.slice(0,d.index)+a.slice(d.index+d[0].length);var e=d[1]?"bgClass":"textClass";null==b[e]?b[e]=d[2]:(new RegExp("(?:^|s)"+d[2]+
"(?:$|s)")).test(b[e])||(b[e]+=" "+d[2])}return a}function ie(a,b,d,e,f,c,h){var w=d.flattenSpans;null==w&&(w=a.options.flattenSpans);var k=0,Q=null,r=new ka(b,a.options.tabSize,e),m=a.options.addModeClass&&[null];for(""==b&&le(K(d,e.state),c);!r.eol();){if(r.pos>a.options.maxHighlightLength){w=!1;h&&cc(a,b,e,r.pos);r.pos=b.length;var l=null}else l=le(dc(d,r,e.state,m),c);if(m){var g=m[0].name;g&&(l="m-"+(l?g+" "+l:g))}if(!w||Q!=l){for(;k<r.start;)k=Math.min(r.start,k+5E3),f(k,Q);Q=l}r.start=r.pos}for(;k<
r.pos;)a=Math.min(r.pos,k+5E3),f(a,Q),k=a}function eg(a,b,e){for(var f,c,w=a.doc,h=e?-1:b-(a.doc.mode.innerMode?1E3:100);b>h;--b){if(b<=w.first)return w.first;var k=I(w,b-1),r=k.stateAfter;if(r&&(!e||b+(r instanceof Tc?r.lookAhead:0)<=w.modeFrontier))return b;k=d(k.text,null,a.options.tabSize);if(null==c||f>k)c=b-1,f=k}return c}function fg(a,b){a.modeFrontier=Math.min(a.modeFrontier,b);if(!(a.highlightFrontier<b-10)){for(var d=a.first,e=b-1;e>d;e--){var f=I(a,e).stateAfter;if(f&&(!(f instanceof Tc)||
e+f.lookAhead<b)){d=e+1;break}}a.highlightFrontier=Math.min(a.highlightFrontier,d)}}function me(a,b){if(!a||/^\s*$/.test(a))return null;b=b.addModeClass?gg:hg;return b[a]||(b[a]=a.replace(/\S+/g,"cm-$&"))}function ne(a,b){var d=f("span",null,null,ta?"padding-right: .1px":null);d={pre:f("pre",[d],"CodeMirror-line"),content:d,col:0,pos:0,cm:a,trailingSpace:!1,splitSpaces:(Z||ta)&&a.getOption("lineWrapping")};b.measure={};for(var e=0;e<=(b.rest?b.rest.length:0);e++){var c=e?b.rest[e-1]:b.line,w=void 0;
d.pos=0;d.addToken=ig;var h=a.display.measure;if(null!=td)h=td;else{var k=q(h,document.createTextNode("A\u062eA")),r=ec(k,0,1).getBoundingClientRect();k=ec(k,1,2).getBoundingClientRect();g(h);h=r&&r.left!=r.right?td=3>k.right-r.right:!1}h&&(w=Da(c,a.doc.direction))&&(d.addToken=jg(d.addToken,w));d.map=[];var Q=b!=a.display.externalMeasured&&O(c);a:{var l=k=r=h=void 0,t=void 0,v=void 0,x=void 0;w=d;Q=jb(a,c,Q);var B=c.markedSpans,n=c.text,z=0;if(B)for(var C=n.length,H=0,y=1,F="",A=0;;){if(A==H){t=
l=k=r=v="";h=null;A=Infinity;for(var E=[],u=void 0,G=0;G<B.length;++G){var p=B[G],D=p.marker;"bookmark"==D.type&&p.from==H&&D.widgetNode?E.push(D):p.from<=H&&(null==p.to||p.to>H||D.collapsed&&p.to==H&&p.from==H)?(null!=p.to&&p.to!=H&&A>p.to&&(A=p.to,l=""),D.className&&(t+=" "+D.className),D.css&&(v=(v?v+";":"")+D.css),D.startStyle&&p.from==H&&(k+=" "+D.startStyle),D.endStyle&&p.to==A&&(u||(u=[])).push(D.endStyle,p.to),D.title&&!r&&(r=D.title),D.collapsed&&(!h||0>Za(h.marker,D))&&(h=p)):p.from>H&&
A>p.from&&(A=p.from)}if(u)for(G=0;G<u.length;G+=2)u[G+1]==A&&(l+=" "+u[G]);if(!h||h.from==H)for(u=0;u<E.length;++u)oe(w,0,E[u]);if(h&&(h.from||0)==H){oe(w,(null==h.to?C+1:h.to)-H,h.marker,null==h.from);if(null==h.to)break a;h.to==H&&(h=!1)}}if(H>=C)break;for(E=Math.min(C,A);;){if(F){u=H+F.length;h||(G=u>E?F.slice(0,E-H):F,w.addToken(w,G,x?x+t:t,k,H+G.length==A?l:"",r,v));if(u>=E){F=F.slice(E-H);H=E;break}H=u;k=""}F=n.slice(z,z=Q[y++]);x=me(Q[y++],w.cm.options)}}else for(h=1;h<Q.length;h+=2)w.addToken(w,
n.slice(z,z=Q[h]),me(Q[h+1],w.cm.options))}c.styleClasses&&(c.styleClasses.bgClass&&(d.bgClass=m(c.styleClasses.bgClass,d.bgClass||"")),c.styleClasses.textClass&&(d.textClass=m(c.styleClasses.textClass,d.textClass||"")));0==d.map.length&&d.map.push(0,0,d.content.appendChild(ib(a.display.measure)));0==e?(b.measure.map=d.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(d.map),(b.measure.caches||(b.measure.caches=[])).push({}))}ta&&(e=d.content.lastChild,/\bcm-tab\b/.test(e.className)||
e.querySelector&&e.querySelector(".cm-tab"))&&(d.content.className="cm-tab-wrap-hack");ea(a,"renderLine",a,b.line,d.pre);d.pre.className&&(d.textClass=m(d.pre.className,d.textClass||""));return d}function kg(b){var d=a("span","\u2022","cm-invalidchar");d.title="\\u"+b.charCodeAt(0).toString(16);d.setAttribute("aria-label",d.title);return d}function ig(b,d,e,f,c,h,k){if(d){if(b.splitSpaces){var w=b.trailingSpace;if(1<d.length&&!/  /.test(d))w=d;else{for(var Q="",m=0;m<d.length;m++){var l=d.charAt(m);
" "!=l||!w||m!=d.length-1&&32!=d.charCodeAt(m+1)||(l="\u00a0");Q+=l;w=" "==l}w=Q}}else w=d;Q=w;m=b.cm.state.specialChars;l=!1;if(m.test(d)){w=document.createDocumentFragment();for(var g=0;;){m.lastIndex=g;var t=m.exec(d),v=t?t.index-g:d.length-g;if(v){var x=document.createTextNode(Q.slice(g,g+v));Z&&9>da?w.appendChild(a("span",[x])):w.appendChild(x);b.map.push(b.pos,b.pos+v,x);b.col+=v;b.pos+=v}if(!t)break;g+=v+1;"\t"==t[0]?(t=b.cm.options.tabSize,t-=b.col%t,v=w.appendChild(a("span",r(t),"cm-tab")),
v.setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),b.col+=t):("\r"==t[0]||"\n"==t[0]?(v=w.appendChild(a("span","\r"==t[0]?"\u240d":"\u2424","cm-invalidchar")),v.setAttribute("cm-text",t[0])):(v=b.cm.options.specialCharPlaceholder(t[0]),v.setAttribute("cm-text",t[0]),Z&&9>da?w.appendChild(a("span",[v])):w.appendChild(v)),b.col+=1);b.map.push(b.pos,b.pos+1,v);b.pos++}}else b.col+=d.length,w=document.createTextNode(Q),b.map.push(b.pos,b.pos+d.length,w),Z&&9>da&&(l=!0),b.pos+=d.length;
b.trailingSpace=32==Q.charCodeAt(d.length-1);if(e||f||c||l||k)return d=e||"",f&&(d+=f),c&&(d+=c),f=a("span",[w],d,k),h&&(f.title=h),b.content.appendChild(f);b.content.appendChild(w)}}function jg(a,b){return function(d,e,f,c,w,h,k){f=f?f+" cm-force-border":"cm-force-border";for(var r=d.pos,Q=r+e.length;;){for(var m=void 0,l=0;l<b.length&&!(m=b[l],m.to>r&&m.from<=r);l++);if(m.to>=Q)return a(d,e,f,c,w,h,k);a(d,e.slice(0,m.to-r),f,c,null,h,k);c=null;e=e.slice(m.to-r);r=m.to}}}function oe(a,b,d,e){var f=
!e&&d.widgetNode;f&&a.map.push(a.pos,a.pos+b,f);!e&&a.cm.display.input.needsContentAttribute&&(f||(f=a.content.appendChild(document.createElement("span"))),f.setAttribute("cm-marker",d.id));f&&(a.cm.display.input.setUneditable(f),a.content.appendChild(f));a.pos+=b;a.trailingSpace=!1}function pe(a,b,d){for(var e=this.line=b,f;e=xa(e,!1);)e=e.find(1,!0).line,(f||(f=[])).push(e);this.size=(this.rest=f)?O(x(this.rest))-d+1:1;this.node=this.text=null;this.hidden=$a(a,b)}function Uc(a,b,d){var e=[],f;for(f=
b;f<d;)b=new pe(a.doc,I(a.doc,f),f),f+=b.size,e.push(b);return e}function lg(a,b){if(a=a.ownsGroup)try{var d=a.delayedCallbacks,e=0;do{for(;e<d.length;e++)d[e].call(null);for(var f=0;f<a.ops.length;f++){var c=a.ops[f];if(c.cursorActivityHandlers)for(;c.cursorActivityCalled<c.cursorActivityHandlers.length;)c.cursorActivityHandlers[c.cursorActivityCalled++].call(null,c.cm)}}while(e<d.length)}finally{Kb=null,b(a)}}function ra(a,b){var d=a._handlers&&a._handlers[b]||Pc;if(d.length){var e=Array.prototype.slice.call(arguments,
2);if(Kb)var f=Kb.delayedCallbacks;else fc?f=fc:(f=fc=[],setTimeout(mg,0));for(var c=function(a){f.push(function(){return d[a].apply(null,e)})},w=0;w<d.length;++w)c(w)}}function mg(){var a=fc;fc=null;for(var b=0;b<a.length;++b)a[b]()}function qe(a,b,d,e){for(var f=0;f<b.changes.length;f++){var c=b.changes[f];if("text"==c){c=a;var w=b,h=w.text.className,k=re(c,w);w.text==w.node&&(w.node=k.pre);w.text.parentNode.replaceChild(k.pre,w.text);w.text=k.pre;k.bgClass!=w.bgClass||k.textClass!=w.textClass?
(w.bgClass=k.bgClass,w.textClass=k.textClass,ud(c,w)):h&&(w.text.className=h)}else if("gutter"==c)se(a,b,d,e);else if("class"==c)ud(a,b);else if("widget"==c){c=a;w=b;h=e;w.alignable&&(w.alignable=null);k=w.node.firstChild;for(var r;k;k=r)r=k.nextSibling,"CodeMirror-linewidget"==k.className&&w.node.removeChild(k);te(c,w,h)}}b.changes=null}function gc(b){b.node==b.text&&(b.node=a("div",null,null,"position: relative"),b.text.parentNode&&b.text.parentNode.replaceChild(b.node,b.text),b.node.appendChild(b.text),
Z&&8>da&&(b.node.style.zIndex=2));return b.node}function re(a,b){var d=a.display.externalMeasured;return d&&d.line==b.line?(a.display.externalMeasured=null,b.measure=d.measure,d.built):ne(a,b)}function ud(b,d){var e=d.bgClass?d.bgClass+" "+(d.line.bgClass||""):d.line.bgClass;e&&(e+=" CodeMirror-linebackground");if(d.background)e?d.background.className=e:(d.background.parentNode.removeChild(d.background),d.background=null);else if(e){var f=gc(d);d.background=f.insertBefore(a("div",null,e),f.firstChild);
b.display.input.setUneditable(d.background)}d.line.wrapClass?gc(d).className=d.line.wrapClass:d.node!=d.text&&(d.node.className="");d.text.className=(d.textClass?d.textClass+" "+(d.line.textClass||""):d.line.textClass)||""}function se(b,d,e,f){d.gutter&&(d.node.removeChild(d.gutter),d.gutter=null);d.gutterBackground&&(d.node.removeChild(d.gutterBackground),d.gutterBackground=null);if(d.line.gutterClass){var c=gc(d);d.gutterBackground=a("div",null,"CodeMirror-gutter-background "+d.line.gutterClass,
"left: "+(b.options.fixedGutter?f.fixedPos:-f.gutterTotalWidth)+"px; width: "+f.gutterTotalWidth+"px");b.display.input.setUneditable(d.gutterBackground);c.insertBefore(d.gutterBackground,d.text)}c=d.line.gutterMarkers;if(b.options.lineNumbers||c){var w=gc(d),h=d.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(b.options.fixedGutter?f.fixedPos:-f.gutterTotalWidth)+"px");b.display.input.setUneditable(h);w.insertBefore(h,d.text);d.line.gutterClass&&(h.className+=" "+d.line.gutterClass);!b.options.lineNumbers||
c&&c["CodeMirror-linenumbers"]||(d.lineNumber=h.appendChild(a("div",aa(b.options,e),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+f.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+b.display.lineNumInnerWidth+"px")));if(c)for(d=0;d<b.options.gutters.length;++d)e=b.options.gutters[d],(w=c.hasOwnProperty(e)&&c[e])&&h.appendChild(a("div",[w],"CodeMirror-gutter-elt","left: "+f.gutterLeft[e]+"px; width: "+f.gutterWidth[e]+"px"))}}function ng(a,b,d,e){var f=re(a,b);b.text=b.node=f.pre;f.bgClass&&
(b.bgClass=f.bgClass);f.textClass&&(b.textClass=f.textClass);ud(a,b);se(a,b,d,e);te(a,b,e);return b.node}function te(a,b,d){ue(a,b.line,b,d,!0);if(b.rest)for(var e=0;e<b.rest.length;e++)ue(a,b.rest[e],b,d,!1)}function ue(b,d,e,f,c){if(d.widgets){var w=gc(e),h=0;for(d=d.widgets;h<d.length;++h){var k=d[h],r=a("div",[k.node],"CodeMirror-linewidget");k.handleMouseEvents||r.setAttribute("cm-ignore-events","true");var m=k,l=r,Q=f;if(m.noHScroll){(e.alignable||(e.alignable=[])).push(l);var g=Q.wrapperWidth;
l.style.left=Q.fixedPos+"px";m.coverGutter||(g-=Q.gutterTotalWidth,l.style.paddingLeft=Q.gutterTotalWidth+"px");l.style.width=g+"px"}m.coverGutter&&(l.style.zIndex=5,l.style.position="relative",m.noHScroll||(l.style.marginLeft=-Q.gutterTotalWidth+"px"));b.display.input.setUneditable(r);c&&k.above?w.insertBefore(r,e.gutter||e.text):w.appendChild(r);ra(k,"redraw")}}}function hc(b){if(null!=b.height)return b.height;var d=b.doc.cm;if(!d)return 0;if(!l(document.body,b.node)){var e="position: relative;";
b.coverGutter&&(e+="margin-left: -"+d.display.gutters.offsetWidth+"px;");b.noHScroll&&(e+="width: "+d.display.wrapper.clientWidth+"px;");q(d.display.measure,a("div",[b.node],null,e))}return b.height=b.node.parentNode.offsetHeight}function cb(a,b){for(b=b.target||b.srcElement;b!=a.wrapper;b=b.parentNode)if(!b||1==b.nodeType&&"true"==b.getAttribute("cm-ignore-events")||b.parentNode==a.sizer&&b!=a.mover)return!0}function vd(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function ve(b){if(b.cachedPaddingH)return b.cachedPaddingH;
var d=q(b.measure,a("pre","x"));d=window.getComputedStyle?window.getComputedStyle(d):d.currentStyle;d={left:parseInt(d.paddingLeft),right:parseInt(d.paddingRight)};isNaN(d.left)||isNaN(d.right)||(b.cachedPaddingH=d);return d}function Xa(a){return 30-a.display.nativeBarWidth}function rb(a){return a.display.scroller.clientWidth-Xa(a)-a.display.barWidth}function wd(a){return a.display.scroller.clientHeight-Xa(a)-a.display.barHeight}function we(a,b,d){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};
for(var e=0;e<a.rest.length;e++)if(a.rest[e]==b)return{map:a.measure.maps[e],cache:a.measure.caches[e]};for(b=0;b<a.rest.length;b++)if(O(a.rest[b])>d)return{map:a.measure.maps[b],cache:a.measure.caches[b],before:!0}}function xd(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[sb(a,b)];if((a=a.display.externalMeasured)&&b>=a.lineN&&b<a.lineN+a.size)return a}function tb(a,b){var d=O(b),e=xd(a,d);e&&!e.text?e=null:e&&e.changes&&(qe(a,e,d,yd(a)),a.curOp.forceUpdate=!0);if(!e){var f=
Ha(b);e=O(f);f=a.display.externalMeasured=new pe(a.doc,f,e);f.lineN=e;e=f.built=ne(a,f);f.text=e.pre;q(a.display.lineMeasure,e.pre);e=f}a=we(e,b,d);return{line:b,view:e,rect:null,map:a.map,cache:a.cache,before:a.before,hasHeights:!1}}function Qa(b,d,e,f,c){d.before&&(e=-1);var w=e+(f||"");if(d.cache.hasOwnProperty(w))b=d.cache[w];else{d.rect||(d.rect=d.view.text.getBoundingClientRect());if(!d.hasHeights){var h=d.view,k=d.rect,r=b.options.lineWrapping,m=r&&rb(b);if(!h.measure.heights||r&&h.measure.width!=
m){var l=h.measure.heights=[];if(r)for(h.measure.width=m,h=h.text.firstChild.getClientRects(),r=0;r<h.length-1;r++){m=h[r];var g=h[r+1];2<Math.abs(m.bottom-g.bottom)&&l.push((m.bottom+g.top)/2-k.top)}l.push(k.bottom-k.top)}d.hasHeights=!0}l=f;h=xe(d.map,e,l);f=h.node;k=h.start;r=h.end;e=h.collapse;if(3==f.nodeType){for(var Q=0;4>Q;Q++){for(;k&&B(d.line.text.charAt(h.coverStart+k));)--k;for(;h.coverStart+r<h.coverEnd&&B(d.line.text.charAt(h.coverStart+r));)++r;if(Z&&9>da&&0==k&&r==h.coverEnd-h.coverStart)var t=
f.parentNode.getBoundingClientRect();else{t=ec(f,k,r).getClientRects();r=ye;if("left"==l)for(m=0;m<t.length&&(r=t[m]).left==r.right;m++);else for(m=t.length-1;0<=m&&(r=t[m]).left==r.right;m--);t=r}if(t.left||t.right||0==k)break;r=k;--k;e="right"}Z&&11>da&&((Q=!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI)||(null!=zd?Q=zd:(l=q(b.display.measure,a("span","x")),Q=l.getBoundingClientRect(),l=ec(l,0,1).getBoundingClientRect(),Q=zd=1<Math.abs(Q.left-l.left)),Q=!Q),Q||(Q=
screen.logicalXDPI/screen.deviceXDPI,l=screen.logicalYDPI/screen.deviceYDPI,t={left:t.left*Q,right:t.right*Q,top:t.top*l,bottom:t.bottom*l}))}else 0<k&&(e=l="right"),t=b.options.lineWrapping&&1<(Q=f.getClientRects()).length?Q["right"==l?Q.length-1:0]:f.getBoundingClientRect();!(Z&&9>da)||k||t&&(t.left||t.right)||(t=(t=f.parentNode.getClientRects()[0])?{left:t.left,right:t.left+ic(b.display),top:t.top,bottom:t.bottom}:ye);f=t.top-d.rect.top;k=t.bottom-d.rect.top;Q=(f+k)/2;l=d.view.measure.heights;
for(h=0;h<l.length-1&&!(Q<l[h]);h++);e={left:("right"==e?t.right:t.left)-d.rect.left,right:("left"==e?t.left:t.right)-d.rect.left,top:h?l[h-1]:0,bottom:l[h]};t.left||t.right||(e.bogus=!0);b.options.singleCursorHeightPerLine||(e.rtop=f,e.rbottom=k);b=e;b.bogus||(d.cache[w]=b)}return{left:b.left,right:b.right,top:c?b.rtop:b.top,bottom:c?b.rbottom:b.bottom}}function xe(a,b,d){for(var e,f,c,w,h,k,r=0;r<a.length;r+=3){h=a[r];k=a[r+1];if(b<h)f=0,c=1,w="left";else if(b<k)f=b-h,c=f+1;else if(r==a.length-
3||b==k&&a[r+3]>b)c=k-h,f=c-1,b>=k&&(w="right");if(null!=f){e=a[r+2];h==k&&d==(e.insertLeft?"left":"right")&&(w=d);if("left"==d&&0==f)for(;r&&a[r-2]==a[r-3]&&a[r-1].insertLeft;)e=a[(r-=3)+2],w="left";if("right"==d&&f==k-h)for(;r<a.length-3&&a[r+3]==a[r+4]&&!a[r+5].insertLeft;)e=a[(r+=3)+2],w="right";break}}return{node:e,start:f,end:c,collapse:w,coverStart:h,coverEnd:k}}function ze(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;b<a.rest.length;b++)a.measure.caches[b]=
{}}function Ae(a){a.display.externalMeasure=null;g(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)ze(a.display.view[b])}function jc(a){Ae(a);a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function Be(){return Vc&&Wc?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}
function Ce(){return Vc&&Wc?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Ad(a){var b=0;if(a.widgets)for(var d=0;d<a.widgets.length;++d)a.widgets[d].above&&(b+=hc(a.widgets[d]));return b}function Xc(a,b,d,e,f){f||(f=Ad(b),d.top+=f,d.bottom+=f);if("line"==e)return d;e||(e="local");b=Ia(b);b="local"==e?b+a.display.lineSpace.offsetTop:b-a.display.viewOffset;if("page"==e||
"window"==e)a=a.display.lineSpace.getBoundingClientRect(),b+=a.top+("window"==e?0:Ce()),e=a.left+("window"==e?0:Be()),d.left+=e,d.right+=e;d.top+=b;d.bottom+=b;return d}function De(a,b,d){if("div"==d)return b;var e=b.left;b=b.top;"page"==d?(e-=Be(),b-=Ce()):"local"!=d&&d||(d=a.display.sizer.getBoundingClientRect(),e+=d.left,b+=d.top);a=a.display.lineSpace.getBoundingClientRect();return{left:e-a.left,top:b-a.top}}function Bd(a,b,d,e,f){e||(e=I(a.doc,b.line));var c=e;b=b.ch;e=Qa(a,tb(a,e),b,f);return Xc(a,
c,e,d)}function Ra(a,b,d,e,f,c){function h(b,h){b=Qa(a,f,b,h?"right":"left",c);h?b.left=b.right:b.right=b.left;return Xc(a,e,b,d)}function w(a,b,d){return h(d?a-1:a,1==k[b].level!=d)}e=e||I(a.doc,b.line);f||(f=tb(a,e));var k=Da(e,a.doc.direction),r=b.ch;b=b.sticky;r>=e.text.length?(r=e.text.length,b="before"):0>=r&&(r=0,b="after");if(!k)return h("before"==b?r-1:r,"before"==b);var m=Ua(k,r,b),l=Zb;m=w(r,m,"before"==b);null!=l&&(m.other=w(r,l,"before"!=b));return m}function Ee(a,b){var d=0;b=R(a.doc,
b);a.options.lineWrapping||(d=ic(a.display)*b.ch);b=I(a.doc,b.line);a=Ia(b)+a.display.lineSpace.offsetTop;return{left:d,right:d,top:a,bottom:a+b.height}}function Cd(a,b,d,e,f){a=J(a,b,d);a.xRel=f;e&&(a.outside=!0);return a}function Dd(a,b,d){var e=a.doc;d+=a.display.viewOffset;if(0>d)return Cd(e.first,0,null,!0,-1);var f=T(e,d),c=e.first+e.size-1;if(f>c)return Cd(e.first+e.size-1,I(e,c).text.length,null,!0,1);0>b&&(b=0);for(e=I(e,f);;)if(f=og(a,e,f,b,d),c=(e=xa(e,!1))&&e.find(0,!0),e&&(f.ch>c.from.ch||
f.ch==c.from.ch&&0<f.xRel))f=O(e=c.to.line);else return f}function Fe(a,b,d,e){e-=Ad(b);b=b.text.length;var f=F(function(b){return Qa(a,d,b-1).bottom<=e},b,0);b=F(function(b){return Qa(a,d,b).top>e},f,b);return{begin:f,end:b}}function Ge(a,b,d,e){d||(d=tb(a,b));e=Xc(a,b,Qa(a,d,e),"line").top;return Fe(a,b,d,e)}function Ed(a,b,d,e){return a.bottom<=d?!1:a.top>d?!0:(e?a.left:a.right)>b}function og(a,b,d,e,f){f-=Ia(b);var c=tb(a,b),h=Ad(b),w=0,k=b.text.length,r=!0,m=Da(b,a.doc.direction);m&&(m=(a.options.lineWrapping?
pg:qg)(a,b,d,c,m,e,f),w=(r=1!=m.level)?m.from:m.to-1,k=r?m.to:m.from-1);var l=null,g=null;m=F(function(b){var d=Qa(a,c,b);d.top+=h;d.bottom+=h;if(!Ed(d,e,f,!1))return!1;d.top<=f&&d.left<=e&&(l=b,g=d);return!0},w,k);var t=!1;g?(w=e-g.left<g.right-e,r=w==r,m=l+(r?0:1),r=r?"after":"before",w=w?g.left:g.right):(r||m!=k&&m!=w||m++,r=0==m?"after":m==b.text.length?"before":Qa(a,c,m-(r?1:0)).bottom+h<=f==r?"after":"before",t=Ra(a,J(d,m,r),"line",b,c),w=t.left,t=f<t.top||f>=t.bottom);m=C(b.text,m,1);return Cd(d,
m,r,t,e-w)}function qg(a,b,d,e,f,c,h){var w=F(function(w){w=f[w];var k=1!=w.level;return Ed(Ra(a,J(d,k?w.to:w.from,k?"before":"after"),"line",b,e),c,h,!0)},0,f.length-1),k=f[w];if(0<w){var r=1!=k.level;r=Ra(a,J(d,r?k.from:k.to,r?"after":"before"),"line",b,e);Ed(r,c,h,!0)&&r.top>h&&(k=f[w-1])}return k}function pg(a,b,d,e,f,c,h){h=Fe(a,b,e,h);d=h.begin;h=h.end;/\s/.test(b.text.charAt(h-1))&&h--;for(var w=b=null,k=0;k<f.length;k++){var r=f[k];if(!(r.from>=h||r.to<=d)){var m=Qa(a,e,1!=r.level?Math.min(h,
r.to)-1:Math.max(d,r.from)).right;m=m<c?c-m+1E9:m-c;if(!b||w>m)b=r,w=m}}b||(b=f[f.length-1]);b.from<d&&(b={from:d,to:b.to,level:b.level});b.to>h&&(b={from:b.from,to:h,level:b.level});return b}function ub(b){if(null!=b.cachedTextHeight)return b.cachedTextHeight;if(null==vb){vb=a("pre");for(var d=0;49>d;++d)vb.appendChild(document.createTextNode("x")),vb.appendChild(a("br"));vb.appendChild(document.createTextNode("x"))}q(b.measure,vb);d=vb.offsetHeight/50;3<d&&(b.cachedTextHeight=d);g(b.measure);return d||
1}function ic(b){if(null!=b.cachedCharWidth)return b.cachedCharWidth;var d=a("span","xxxxxxxxxx"),e=a("pre",[d]);q(b.measure,e);d=d.getBoundingClientRect();d=(d.right-d.left)/10;2<d&&(b.cachedCharWidth=d);return d||10}function yd(a){for(var b=a.display,d={},e={},f=b.gutters.clientLeft,c=b.gutters.firstChild,h=0;c;c=c.nextSibling,++h)d[a.options.gutters[h]]=c.offsetLeft+c.clientLeft+f,e[a.options.gutters[h]]=c.clientWidth;return{fixedPos:Fd(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:d,gutterWidth:e,
wrapperWidth:b.wrapper.clientWidth}}function Fd(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function He(a){var b=ub(a.display),d=a.options.lineWrapping,e=d&&Math.max(5,a.display.scroller.clientWidth/ic(a.display)-3);return function(f){if($a(a.doc,f))return 0;var c=0;if(f.widgets)for(var h=0;h<f.widgets.length;h++)f.widgets[h].height&&(c+=f.widgets[h].height);return d?c+(Math.ceil(f.text.length/e)||1)*b:c+b}}function Gd(a){var b=a.doc,d=He(a);b.iter(function(a){var b=
d(a);b!=a.height&&U(a,b)})}function wb(a,b,e,f){var c=a.display;if(!e&&"true"==(b.target||b.srcElement).getAttribute("cm-not-content"))return null;e=c.lineSpace.getBoundingClientRect();try{var h=b.clientX-e.left;var w=b.clientY-e.top}catch(he){return null}b=Dd(a,h,w);var k;f&&1==b.xRel&&(k=I(a.doc,b.line).text).length==b.ch&&(f=d(k,k.length,a.options.tabSize)-k.length,b=J(b.line,Math.max(0,Math.round((h-ve(a.display).left)/ic(a.display))-f)));return b}function sb(a,b){if(b>=a.display.viewTo)return null;
b-=a.display.viewFrom;if(0>b)return null;a=a.display.view;for(var d=0;d<a.length;d++)if(b-=a[d].size,0>b)return d}function kc(a){a.display.input.showSelection(a.display.input.prepareSelection())}function Ie(a,b){void 0===b&&(b=!0);for(var d=a.doc,e={},f=e.cursors=document.createDocumentFragment(),c=e.selection=document.createDocumentFragment(),h=0;h<d.sel.ranges.length;h++)if(b||h!=d.sel.primIndex){var w=d.sel.ranges[h];if(!(w.from().line>=a.display.viewTo||w.to().line<a.display.viewFrom)){var k=
w.empty();(k||a.options.showCursorWhenSelecting)&&Je(a,w.head,f);k||rg(a,w,c)}}return e}function Je(b,d,e){d=Ra(b,d,"div",null,null,!b.options.singleCursorHeightPerLine);var f=e.appendChild(a("div","\u00a0","CodeMirror-cursor"));f.style.left=d.left+"px";f.style.top=d.top+"px";f.style.height=Math.max(0,d.bottom-d.top)*b.options.cursorHeight+"px";d.other&&(b=e.appendChild(a("div","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor")),b.style.display="",b.style.left=d.other.left+"px",b.style.top=
d.other.top+"px",b.style.height=.85*(d.other.bottom-d.other.top)+"px")}function Yc(a,b){return a.top-b.top||a.left-b.left}function rg(b,d,e){function f(b,d,e,f){0>d&&(d=0);d=Math.round(d);f=Math.round(f);k.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+b+"px;\n                             top: "+d+"px; width: "+(null==e?l-b:e)+"px;\n                             height: "+(f-d)+"px"))}function c(a,d,e){function c(d,e){return Bd(b,J(a,d),"div",k,e)}function h(a,d,e){a=Ge(b,
k,null,a);d="ltr"==d==("after"==e)?"left":"right";e="after"==e?a.begin:a.end-(/\s/.test(k.text.charAt(a.end-1))?2:1);return c(e,d)[d]}var k=I(w,a),r=k.text.length,t,v,Q=Da(k,w.direction);Nc(Q,d||0,null==e?r:e,function(a,b,w,k){var x="ltr"==w,B=c(a,x?"left":"right"),n=c(b-1,x?"right":"left"),z=null==d&&0==a,H=null==e&&b==r,q=0==k;k=!Q||k==Q.length-1;3>=n.top-B.top?(b=(g?z:H)&&q?m:(x?B:n).left,f(b,B.top,((g?H:z)&&k?l:(x?n:B).right)-b,B.bottom)):(x?(x=g&&z&&q?m:B.left,z=g?l:h(a,w,"before"),a=g?m:h(b,
w,"after"),H=g&&H&&k?l:n.right):(x=g?h(a,w,"before"):m,z=!g&&z&&q?l:B.right,a=!g&&H&&k?m:n.left,H=g?h(b,w,"after"):l),f(x,B.top,z-x,B.bottom),B.bottom<n.top&&f(m,B.bottom,null,n.top),f(a,n.top,H-a,n.bottom));if(!t||0>Yc(B,t))t=B;0>Yc(n,t)&&(t=n);if(!v||0>Yc(B,v))v=B;0>Yc(n,v)&&(v=n)});return{start:t,end:v}}var h=b.display,w=b.doc,k=document.createDocumentFragment(),r=ve(b.display),m=r.left,l=Math.max(h.sizerWidth,rb(b)-h.sizer.offsetLeft)-r.right,g="ltr"==w.direction;h=d.from();d=d.to();if(h.line==
d.line)c(h.line,h.ch,d.ch);else{var t=I(w,h.line);r=I(w,d.line);r=Ha(t)==Ha(r);h=c(h.line,h.ch,r?t.text.length+1:null).end;d=c(d.line,r?0:null,d.ch).start;r&&(h.top<d.top-2?(f(h.right,h.top,null,h.bottom),f(m,d.top,d.left,d.bottom)):f(h.right,h.top,d.left-h.right,h.bottom));h.bottom<d.top&&f(m,h.bottom,null,d.top)}e.appendChild(k)}function Hd(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var d=!0;b.cursorDiv.style.visibility="";0<a.options.cursorBlinkRate?b.blinker=setInterval(function(){return b.cursorDiv.style.visibility=
(d=!d)?"":"hidden"},a.options.cursorBlinkRate):0>a.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function Ke(a){a.state.focused||(a.display.input.focus(),Id(a))}function Le(a){a.state.delayingBlurEvent=!0;setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,lc(a))},100)}function Id(a,b){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1);"nocursor"!=a.options.readOnly&&(a.state.focused||(ea(a,"focus",a,b),a.state.focused=!0,t(a.display.wrapper,"CodeMirror-focused"),
a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),ta&&setTimeout(function(){return a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),Hd(a))}function lc(a,b){a.state.delayingBlurEvent||(a.state.focused&&(ea(a,"blur",a,b),a.state.focused=!1,xb(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function Zc(a){a=a.display;for(var b=a.lineDiv.offsetTop,d=0;d<a.view.length;d++){var e=
a.view[d];if(!e.hidden){if(Z&&8>da){var f=e.node.offsetTop+e.node.offsetHeight;var c=f-b;b=f}else c=e.node.getBoundingClientRect(),c=c.bottom-c.top;f=e.line.height-c;2>c&&(c=ub(a));if(.005<f||-.005>f)if(U(e.line,c),Me(e.line),e.rest)for(c=0;c<e.rest.length;c++)Me(e.rest[c])}}}function Me(a){if(a.widgets)for(var b=0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.parentNode.offsetHeight}function Jd(a,b,d){var e=d&&null!=d.top?Math.max(0,d.top):a.scroller.scrollTop;e=Math.floor(e-a.lineSpace.offsetTop);
var f=d&&null!=d.bottom?d.bottom:e+a.wrapper.clientHeight;e=T(b,e);f=T(b,f);if(d&&d.ensure){var c=d.ensure.from.line;d=d.ensure.to.line;c<e?(e=c,f=T(b,Ia(I(b,c))+a.wrapper.clientHeight)):Math.min(d,b.lastLine())>=f&&(e=T(b,Ia(I(b,d))-a.wrapper.clientHeight),f=d)}return{from:e,to:Math.max(f,e+1)}}function Ne(a){var b=a.display,d=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var e=Fd(b)-b.scroller.scrollLeft+a.doc.scrollLeft,f=b.gutters.offsetWidth,c=e+"px",h=0;h<d.length;h++)if(!d[h].hidden){a.options.fixedGutter&&
(d[h].gutter&&(d[h].gutter.style.left=c),d[h].gutterBackground&&(d[h].gutterBackground.style.left=c));var k=d[h].alignable;if(k)for(var w=0;w<k.length;w++)k[w].style.left=c}a.options.fixedGutter&&(b.gutters.style.left=e+f+"px")}}function Oe(b){if(!b.options.lineNumbers)return!1;var d=b.doc;d=aa(b.options,d.first+d.size-1);var e=b.display;if(d.length!=e.lineNumChars){var f=e.measure.appendChild(a("div",[a("div",d)],"CodeMirror-linenumber CodeMirror-gutter-elt")),c=f.firstChild.offsetWidth;f=f.offsetWidth-
c;e.lineGutter.style.width="";e.lineNumInnerWidth=Math.max(c,e.lineGutter.offsetWidth-f)+1;e.lineNumWidth=e.lineNumInnerWidth+f;e.lineNumChars=e.lineNumInnerWidth?d.length:-1;e.lineGutter.style.width=e.lineNumWidth+"px";Kd(b);return!0}return!1}function Ld(a,b){var d=a.display,e=ub(a.display);0>b.top&&(b.top=0);var f=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:d.scroller.scrollTop,c=wd(a),h={};b.bottom-b.top>c&&(b.bottom=b.top+c);var k=a.doc.height+vd(d),w=b.top<e;e=b.bottom>k-e;b.top<f?h.scrollTop=
w?0:b.top:b.bottom>f+c&&(c=Math.min(b.top,(e?k:b.bottom)-c),c!=f&&(h.scrollTop=c));f=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:d.scroller.scrollLeft;a=rb(a)-(a.options.fixedGutter?d.gutters.offsetWidth:0);if(d=b.right-b.left>a)b.right=b.left+a;10>b.left?h.scrollLeft=0:b.left<f?h.scrollLeft=Math.max(0,b.left-(d?0:10)):b.right>a+f-3&&(h.scrollLeft=b.right+(d?0:10)-a);return h}function $c(a,b){null!=b&&(ad(a),a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+b)}
function Lb(a){ad(a);var b=a.getCursor();a.curOp.scrollToPos={from:b,to:b,margin:a.options.cursorScrollMargin}}function mc(a,b,d){null==b&&null==d||ad(a);null!=b&&(a.curOp.scrollLeft=b);null!=d&&(a.curOp.scrollTop=d)}function ad(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var d=Ee(a,b.from),e=Ee(a,b.to);Pe(a,d,e,b.margin)}}function Pe(a,b,d,e){b=Ld(a,{left:Math.min(b.left,d.left),top:Math.min(b.top,d.top)-e,right:Math.max(b.right,d.right),bottom:Math.max(b.bottom,d.bottom)+e});mc(a,
b.scrollLeft,b.scrollTop)}function nc(a,b){2>Math.abs(a.doc.scrollTop-b)||(gb||Md(a,{top:b}),Qe(a,b,!0),gb&&Md(a),oc(a,100))}function Qe(a,b,d){b=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,b);if(a.display.scroller.scrollTop!=b||d)a.doc.scrollTop=b,a.display.scrollbars.setScrollTop(b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b)}function yb(a,b,d,e){b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth);(d?b==a.doc.scrollLeft:
2>Math.abs(a.doc.scrollLeft-b))&&!e||(a.doc.scrollLeft=b,Ne(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function pc(a){var b=a.display,d=b.gutters.offsetWidth,e=Math.round(a.doc.height+vd(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?d:0,docHeight:e,scrollHeight:e+
Xa(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:d}}function Mb(a,b){b||(b=pc(a));var d=a.display.barWidth,e=a.display.barHeight;Re(a,b);for(b=0;4>b&&d!=a.display.barWidth||e!=a.display.barHeight;b++)d!=a.display.barWidth&&a.options.lineWrapping&&Zc(a),Re(a,pc(a)),d=a.display.barWidth,e=a.display.barHeight}function Re(a,b){var d=a.display,e=d.scrollbars.update(b);d.sizer.style.paddingRight=(d.barWidth=e.right)+"px";d.sizer.style.paddingBottom=(d.barHeight=e.bottom)+"px";d.heightForcer.style.borderBottom=
e.bottom+"px solid transparent";e.right&&e.bottom?(d.scrollbarFiller.style.display="block",d.scrollbarFiller.style.height=e.bottom+"px",d.scrollbarFiller.style.width=e.right+"px"):d.scrollbarFiller.style.display="";e.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(d.gutterFiller.style.display="block",d.gutterFiller.style.height=e.bottom+"px",d.gutterFiller.style.width=b.gutterWidth+"px"):d.gutterFiller.style.display=""}function Se(a){a.display.scrollbars&&(a.display.scrollbars.clear(),
a.display.scrollbars.addClass&&xb(a.display.wrapper,a.display.scrollbars.addClass));a.display.scrollbars=new Te[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);V(b,"mousedown",function(){a.state.focused&&setTimeout(function(){return a.display.input.focus()},0)});b.setAttribute("cm-not-content","true")},function(b,d){"horizontal"==d?yb(a,b):nc(a,b)},a);a.display.scrollbars.addClass&&t(a.display.wrapper,a.display.scrollbars.addClass)}function zb(a){a.curOp=
{cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++sg};a=a.curOp;Kb?Kb.ops.push(a):a.ownsGroup=Kb={ops:[a],delayedCallbacks:[]}}function Ab(b){lg(b.curOp,function(b){for(var d=0;d<b.ops.length;d++)b.ops[d].cm.curOp=null;b=b.ops;for(d=0;d<b.length;d++){var e=b[d],f=e.cm,c=f.display,h=f.display;!h.scrollbarsClipped&&
h.scroller.offsetWidth&&(h.nativeBarWidth=h.scroller.offsetWidth-h.scroller.clientWidth,h.heightForcer.style.height=Xa(f)+"px",h.sizer.style.marginBottom=-h.nativeBarWidth+"px",h.sizer.style.borderRightWidth=Xa(f)+"px",h.scrollbarsClipped=!0);e.updateMaxLine&&ab(f);e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<c.viewFrom||e.scrollToPos.to.line>=c.viewTo)||c.maxLineChanged&&f.options.lineWrapping;e.update=e.mustUpdate&&new bd(f,e.mustUpdate&&
{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}for(d=0;d<b.length;d++)e=b[d],e.updatedDisplay=e.mustUpdate&&Nd(e.cm,e.update);for(d=0;d<b.length;d++)if(e=b[d],f=e.cm,c=f.display,e.updatedDisplay&&Zc(f),e.barMeasure=pc(f),c.maxLineChanged&&!f.options.lineWrapping&&(h=c.maxLine.text.length,h=Qa(f,tb(f,c.maxLine),h,void 0),e.adjustWidthTo=h.left+3,f.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+e.adjustWidthTo+Xa(f)+f.display.barWidth),
e.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+e.adjustWidthTo-rb(f))),e.updatedDisplay||e.selectionChanged)e.preparedSelection=c.input.prepareSelection();for(d=0;d<b.length;d++)e=b[d],f=e.cm,null!=e.adjustWidthTo&&(f.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<f.doc.scrollLeft&&yb(f,Math.min(f.display.scroller.scrollLeft,e.maxScrollLeft),!0),f.display.maxLineChanged=!1),c=e.focus&&e.focus==v(),e.preparedSelection&&f.display.input.showSelection(e.preparedSelection,c),(e.updatedDisplay||
e.startHeight!=f.doc.height)&&Mb(f,e.barMeasure),e.updatedDisplay&&Od(f,e.barMeasure),e.selectionChanged&&Hd(f),f.state.focused&&e.updateInput&&f.display.input.reset(e.typing),c&&Ke(e.cm);for(d=0;d<b.length;d++){var k=void 0;e=b[d];f=e.cm;c=f.display;h=f.doc;e.updatedDisplay&&Ue(f,e.update);null==c.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(c.wheelStartX=c.wheelStartY=null);null!=e.scrollTop&&Qe(f,e.scrollTop,e.forceScroll);null!=e.scrollLeft&&yb(f,e.scrollLeft,!0,!0);if(e.scrollToPos){var w=
R(h,e.scrollToPos.from),r=R(h,e.scrollToPos.to),m=e.scrollToPos.margin;null==m&&(m=0);f.options.lineWrapping||w!=r||(w=w.ch?J(w.line,"before"==w.sticky?w.ch-1:w.ch,"after"):w,r="before"==w.sticky?J(w.line,w.ch+1,"before"):w);for(var l=0;5>l;l++){var g=!1;k=Ra(f,w);var t=r&&r!=w?Ra(f,r):k;k={left:Math.min(k.left,t.left),top:Math.min(k.top,t.top)-m,right:Math.max(k.left,t.left),bottom:Math.max(k.bottom,t.bottom)+m};t=Ld(f,k);var x=f.doc.scrollTop,Q=f.doc.scrollLeft;null!=t.scrollTop&&(nc(f,t.scrollTop),
1<Math.abs(f.doc.scrollTop-x)&&(g=!0));null!=t.scrollLeft&&(yb(f,t.scrollLeft),1<Math.abs(f.doc.scrollLeft-Q)&&(g=!0));if(!g)break}r=k;ja(f,"scrollCursorIntoView")||(m=f.display,l=m.sizer.getBoundingClientRect(),w=null,0>r.top+l.top?w=!0:r.bottom+l.top>(window.innerHeight||document.documentElement.clientHeight)&&(w=!1),null==w||tg||(r=a("div","\u200b",null,"position: absolute;\n                         top: "+(r.top-m.viewOffset-f.display.lineSpace.offsetTop)+"px;\n                         height: "+
(r.bottom-r.top+Xa(f)+m.barHeight)+"px;\n                         left: "+r.left+"px; width: "+Math.max(2,r.right-r.left)+"px;"),f.display.lineSpace.appendChild(r),r.scrollIntoView(w),f.display.lineSpace.removeChild(r)))}r=e.maybeHiddenMarkers;w=e.maybeUnhiddenMarkers;if(r)for(m=0;m<r.length;++m)r[m].lines.length||ea(r[m],"hide");if(w)for(r=0;r<w.length;++r)w[r].lines.length&&ea(w[r],"unhide");c.wrapper.offsetHeight&&(h.scrollTop=f.display.scroller.scrollTop);e.changeObjs&&ea(f,"changes",f,e.changeObjs);
e.update&&e.update.finish()}})}function Fa(a,b){if(a.curOp)return b();zb(a);try{return b()}finally{Ab(a)}}function pa(a,b){return function(){if(a.curOp)return b.apply(a,arguments);zb(a);try{return b.apply(a,arguments)}finally{Ab(a)}}}function va(a){return function(){if(this.curOp)return a.apply(this,arguments);zb(this);try{return a.apply(this,arguments)}finally{Ab(this)}}}function qa(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,arguments);zb(b);try{return a.apply(this,arguments)}finally{Ab(b)}}}
function za(a,b,d,e){null==b&&(b=a.doc.first);null==d&&(d=a.doc.first+a.doc.size);e||(e=0);var f=a.display;e&&d<f.viewTo&&(null==f.updateLineNumbers||f.updateLineNumbers>b)&&(f.updateLineNumbers=b);a.curOp.viewChanged=!0;if(b>=f.viewTo)hb&&Xb(a.doc,b)<f.viewTo&&kb(a);else if(d<=f.viewFrom)hb&&Mc(a.doc,d+e)>f.viewFrom?kb(a):(f.viewFrom+=e,f.viewTo+=e);else if(b<=f.viewFrom&&d>=f.viewTo)kb(a);else if(b<=f.viewFrom){var c=cd(a,d,d+e,1);c?(f.view=f.view.slice(c.index),f.viewFrom=c.lineN,f.viewTo+=e):
kb(a)}else if(d>=f.viewTo)(c=cd(a,b,b,-1))?(f.view=f.view.slice(0,c.index),f.viewTo=c.lineN):kb(a);else{c=cd(a,b,b,-1);var h=cd(a,d,d+e,1);c&&h?(f.view=f.view.slice(0,c.index).concat(Uc(a,c.lineN,h.lineN)).concat(f.view.slice(h.index)),f.viewTo+=e):kb(a)}if(a=f.externalMeasured)d<a.lineN?a.lineN+=e:b<a.lineN+a.size&&(f.externalMeasured=null)}function lb(a,d,e){a.curOp.viewChanged=!0;var f=a.display,c=a.display.externalMeasured;c&&d>=c.lineN&&d<c.lineN+c.size&&(f.externalMeasured=null);d<f.viewFrom||
d>=f.viewTo||(a=f.view[sb(a,d)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==b(a,e)&&a.push(e)))}function kb(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function cd(a,b,d,e){var f=sb(a,b),c=a.display.view;if(!hb||d==a.doc.first+a.doc.size)return{index:f,lineN:d};for(var h=a.display.viewFrom,k=0;k<f;k++)h+=c[k].size;if(h!=b){if(0<e){if(f==c.length-1)return null;b=h+c[f].size-b;f++}else b=h-b;d+=b}for(;Xb(a.doc,d)!=d;){if(f==(0>e?0:c.length-1))return null;
d+=e*c[f-(0>e?1:0)].size;f+=e}return{index:f,lineN:d}}function Ve(a){a=a.display.view;for(var b=0,d=0;d<a.length;d++){var e=a[d];e.hidden||e.node&&!e.changes||++b}return b}function oc(a,b){a.doc.highlightFrontier<a.display.viewTo&&a.state.highlight.set(b,k(ug,a))}function ug(a){var b=a.doc;if(!(b.highlightFrontier>=a.display.viewTo)){var d=+new Date+a.options.workTime,e=Va(a,b.highlightFrontier),f=[];b.iter(e.line,Math.min(b.first+b.size,a.display.viewTo+500),function(c){if(e.line>=a.display.viewFrom){var h=
c.styles,k=c.text.length>a.options.maxHighlightLength?Pa(b.mode,e.state):null,w=Sc(a,c,e,!0);k&&(e.state=k);c.styles=w.styles;k=c.styleClasses;(w=w.classes)?c.styleClasses=w:k&&(c.styleClasses=null);w=!h||h.length!=c.styles.length||k!=w&&(!k||!w||k.bgClass!=w.bgClass||k.textClass!=w.textClass);for(k=0;!w&&k<h.length;++k)w=h[k]!=c.styles[k];w&&f.push(e.line);c.stateAfter=e.save()}else c.text.length<=a.options.maxHighlightLength&&cc(a,c.text,e),c.stateAfter=0==e.line%5?e.save():null;e.nextLine();if(+new Date>
d)return oc(a,a.options.workDelay),!0});b.highlightFrontier=e.line;b.modeFrontier=Math.max(b.modeFrontier,e.line);f.length&&Fa(a,function(){for(var b=0;b<f.length;b++)lb(a,f[b],"text")})}}function Nd(a,b){var d=a.display,e=a.doc;if(b.editorIsHidden)return kb(a),!1;if(!b.force&&b.visible.from>=d.viewFrom&&b.visible.to<=d.viewTo&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo)&&d.renderedView==d.view&&0==Ve(a))return!1;Oe(a)&&(kb(a),b.dims=yd(a));var f=e.first+e.size,c=Math.max(b.visible.from-
a.options.viewportMargin,e.first),h=Math.min(f,b.visible.to+a.options.viewportMargin);d.viewFrom<c&&20>c-d.viewFrom&&(c=Math.max(e.first,d.viewFrom));d.viewTo>h&&20>d.viewTo-h&&(h=Math.min(f,d.viewTo));hb&&(c=Xb(a.doc,c),h=Mc(a.doc,h));e=c!=d.viewFrom||h!=d.viewTo||d.lastWrapHeight!=b.wrapperHeight||d.lastWrapWidth!=b.wrapperWidth;f=a.display;0==f.view.length||c>=f.viewTo||h<=f.viewFrom?(f.view=Uc(a,c,h),f.viewFrom=c):(f.viewFrom>c?f.view=Uc(a,c,f.viewFrom).concat(f.view):f.viewFrom<c&&(f.view=f.view.slice(sb(a,
c))),f.viewFrom=c,f.viewTo<h?f.view=f.view.concat(Uc(a,f.viewTo,h)):f.viewTo>h&&(f.view=f.view.slice(0,sb(a,h))));f.viewTo=h;d.viewOffset=Ia(I(a.doc,d.viewFrom));a.display.mover.style.top=d.viewOffset+"px";h=Ve(a);if(!e&&0==h&&!b.force&&d.renderedView==d.view&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo))return!1;a.hasFocus()?c=null:(c=v())&&l(a.display.lineDiv,c)?(c={activeElt:c},window.getSelection&&(f=window.getSelection(),f.anchorNode&&f.extend&&l(a.display.lineDiv,f.anchorNode)&&
(c.anchorNode=f.anchorNode,c.anchorOffset=f.anchorOffset,c.focusNode=f.focusNode,c.focusOffset=f.focusOffset))):c=null;4<h&&(d.lineDiv.style.display="none");vg(a,d.updateLineNumbers,b.dims);4<h&&(d.lineDiv.style.display="");d.renderedView=d.view;(h=c)&&h.activeElt&&h.activeElt!=v()&&(h.activeElt.focus(),h.anchorNode&&l(document.body,h.anchorNode)&&l(document.body,h.focusNode)&&(c=window.getSelection(),f=document.createRange(),f.setEnd(h.anchorNode,h.anchorOffset),f.collapse(!1),c.removeAllRanges(),
c.addRange(f),c.extend(h.focusNode,h.focusOffset)));g(d.cursorDiv);g(d.selectionDiv);d.gutters.style.height=d.sizer.style.minHeight=0;e&&(d.lastWrapHeight=b.wrapperHeight,d.lastWrapWidth=b.wrapperWidth,oc(a,400));d.updateLineNumbers=null;return!0}function Ue(a,b){for(var d=b.viewport,e=!0;;e=!1){if(!e||!a.options.lineWrapping||b.oldDisplayWidth==rb(a))if(d&&null!=d.top&&(d={top:Math.min(a.doc.height+vd(a.display)-wd(a),d.top)}),b.visible=Jd(a.display,a.doc,d),b.visible.from>=a.display.viewFrom&&b.visible.to<=
a.display.viewTo)break;if(!Nd(a,b))break;Zc(a);e=pc(a);kc(a);Mb(a,e);Od(a,e);b.force=!1}b.signal(a,"update",a);if(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function Md(a,b){b=new bd(a,b);if(Nd(a,b)){Zc(a);Ue(a,b);var d=pc(a);kc(a);Mb(a,d);Od(a,d);b.finish()}}function vg(a,d,e){function f(b){var d=
b.nextSibling;ta&&Na&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b);return d}var c=a.display,h=a.options.lineNumbers,k=c.lineDiv,w=k.firstChild,r=c.view;c=c.viewFrom;for(var m=0;m<r.length;m++){var l=r[m];if(!l.hidden)if(l.node&&l.node.parentNode==k){for(;w!=l.node;)w=f(w);w=h&&null!=d&&d<=c&&l.lineNumber;l.changes&&(-1<b(l.changes,"gutter")&&(w=!1),qe(a,l,c,e));w&&(g(l.lineNumber),l.lineNumber.appendChild(document.createTextNode(aa(a.options,c))));w=l.node.nextSibling}else{var t=
ng(a,l,c,e);k.insertBefore(t,w)}c+=l.size}for(;w;)w=f(w)}function Kd(a){a.display.sizer.style.marginLeft=a.display.gutters.offsetWidth+"px"}function Od(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";a.display.heightForcer.style.top=b.docHeight+"px";a.display.gutters.style.height=b.docHeight+a.display.barHeight+Xa(a)+"px"}function We(b){var d=b.display.gutters,e=b.options.gutters;g(d);for(var f=0;f<e.length;++f){var c=e[f],h=d.appendChild(a("div",null,"CodeMirror-gutter "+c));"CodeMirror-linenumbers"==
c&&(b.display.lineGutter=h,h.style.width=(b.display.lineNumWidth||1)+"px")}d.style.display=f?"":"none";Kd(b)}function Pd(a){var d=b(a.gutters,"CodeMirror-linenumbers");-1==d&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):-1<d&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(d,1))}function Xe(a){var b=a.wheelDeltaX,d=a.wheelDeltaY;null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail);null==d&&a.detail&&a.axis==a.VERTICAL_AXIS?d=a.detail:null==d&&(d=a.wheelDelta);
return{x:b,y:d}}function wg(a){a=Xe(a);a.x*=Ja;a.y*=Ja;return a}function Ye(a,b){var d=Xe(b),e=d.x;d=d.y;var f=a.display,c=f.scroller,h=c.scrollWidth>c.clientWidth,k=c.scrollHeight>c.clientHeight;if(e&&h||d&&k){if(d&&Na&&ta){h=b.target;var r=f.view;a:for(;h!=c;h=h.parentNode)for(var w=0;w<r.length;w++)if(r[w].node==h){a.display.currentWheelTarget=h;break a}}!e||gb||Sa||null==Ja?(d&&null!=Ja&&(b=d*Ja,k=a.doc.scrollTop,h=k+f.wrapper.clientHeight,0>b?k=Math.max(0,k+b-50):h=Math.min(a.doc.height,h+b+
50),Md(a,{top:k,bottom:h})),20>dd&&(null==f.wheelStartX?(f.wheelStartX=c.scrollLeft,f.wheelStartY=c.scrollTop,f.wheelDX=e,f.wheelDY=d,setTimeout(function(){if(null!=f.wheelStartX){var a=c.scrollLeft-f.wheelStartX,b=c.scrollTop-f.wheelStartY;a=b&&f.wheelDY&&b/f.wheelDY||a&&f.wheelDX&&a/f.wheelDX;f.wheelStartX=f.wheelStartY=null;a&&(Ja=(Ja*dd+a)/(dd+1),++dd)}},200)):(f.wheelDX+=e,f.wheelDY+=d))):(d&&k&&nc(a,Math.max(0,c.scrollTop+d*Ja)),yb(a,Math.max(0,c.scrollLeft+e*Ja)),(!d||d&&k)&&oa(b),f.wheelStartX=
null)}}function Ta(a,d){d=a[d];a.sort(function(a,b){return S(a.from(),b.from())});d=b(a,d);for(var e=1;e<a.length;e++){var f=a[e],c=a[e-1];if(0<=S(c.to(),f.from())){var h=X(c.from(),f.from()),k=ma(c.to(),f.to());f=c.empty()?f.from()==f.head:c.from()==c.head;e<=d&&--d;a.splice(--e,2,new ba(f?k:h,f?h:k))}}return new Ka(a,d)}function db(a,b){return new Ka([new ba(a,b||a)],0)}function mb(a){return a.text?J(a.from.line+a.text.length-1,x(a.text).length+(1==a.text.length?a.from.ch:0)):a.to}function Ze(a,
b){if(0>S(a,b.from))return a;if(0>=S(a,b.to))return mb(b);var d=a.line+b.text.length-(b.to.line-b.from.line)-1,e=a.ch;a.line==b.to.line&&(e+=mb(b).ch-b.to.ch);return J(d,e)}function Qd(a,b){for(var d=[],e=0;e<a.sel.ranges.length;e++){var f=a.sel.ranges[e];d.push(new ba(Ze(f.anchor,b),Ze(f.head,b)))}return Ta(d,a.sel.primIndex)}function $e(a,b,d){return a.line==b.line?J(d.line,a.ch-b.ch+d.ch):J(d.line+(a.line-b.line),a.ch)}function Rd(a){a.doc.mode=Oa(a.options,a.doc.modeOption);qc(a)}function qc(a){a.doc.iter(function(a){a.stateAfter&&
(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.modeFrontier=a.doc.highlightFrontier=a.doc.first;oc(a,100);a.state.modeGen++;a.curOp&&za(a)}function af(a,b){return 0==b.from.ch&&0==b.to.ch&&""==x(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function Sd(a,b,d,e){function f(a,d,f){a.text=d;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);Fb(a);Ba(a,f);d=e?e(a):1;d!=a.height&&U(a,d);ra(a,"change",a,b)}function c(a,b){for(var f=[];a<b;++a)f.push(new Nb(r[a],
d?d[a]:null,e));return f}var h=b.from,k=b.to,r=b.text,w=I(a,h.line),m=I(a,k.line),l=x(r),g=d?d[r.length-1]:null,t=k.line-h.line;b.full?(a.insert(0,c(0,r.length)),a.remove(r.length,a.size-r.length)):af(a,b)?(k=c(0,r.length-1),f(m,m.text,g),t&&a.remove(h.line,t),k.length&&a.insert(h.line,k)):w==m?1==r.length?f(w,w.text.slice(0,h.ch)+l+w.text.slice(k.ch),g):(t=c(1,r.length-1),t.push(new Nb(l+w.text.slice(k.ch),g,e)),f(w,w.text.slice(0,h.ch)+r[0],d?d[0]:null),a.insert(h.line+1,t)):1==r.length?(f(w,w.text.slice(0,
h.ch)+r[0]+m.text.slice(k.ch),d?d[0]:null),a.remove(h.line+1,t)):(f(w,w.text.slice(0,h.ch)+r[0],d?d[0]:null),f(m,l+m.text.slice(k.ch),g),g=c(1,r.length-1),1<t&&a.remove(h.line+1,t-1),a.insert(h.line+1,g));ra(a,"change",a,b)}function Bb(a,b,d){function e(a,f,c){if(a.linked)for(var h=0;h<a.linked.length;++h){var k=a.linked[h];if(k.doc!=f){var r=c&&k.sharedHist;if(!d||r)b(k.doc,r),e(k.doc,a,r)}}}e(a,null,!0)}function bf(a,b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=a;Gd(a);
Rd(a);cf(a);a.options.lineWrapping||ab(a);a.options.mode=b.modeOption;za(a)}function cf(a){("rtl"==a.doc.direction?t:xb)(a.display.lineDiv,"CodeMirror-rtl")}function xg(a){Fa(a,function(){cf(a);za(a)})}function ed(a){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOrigin=this.lastSelOrigin=this.lastOp=this.lastSelOp=null;this.generation=this.maxGeneration=a||1}function Td(a,b){var d={from:L(b.from),to:mb(b),text:P(a,b.from,b.to)};df(a,d,b.from.line,
b.to.line+1);Bb(a,function(a){return df(a,d,b.from.line,b.to.line+1)},!0);return d}function ef(a){for(;a.length;)if(x(a).ranges)a.pop();else break}function ff(a,b,d,e){var f=a.history;f.undone.length=0;var c=+new Date,h;if(h=f.lastOp==e||f.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&f.lastModTime>c-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0))){if(f.lastOp==e){ef(f.done);var k=x(f.done)}else f.done.length&&!x(f.done).ranges?k=x(f.done):1<f.done.length&&!f.done[f.done.length-
2].ranges?(f.done.pop(),k=x(f.done)):k=void 0;h=k}if(h){var r=x(k.changes);0==S(b.from,b.to)&&0==S(b.from,r.to)?r.to=mb(b):k.changes.push(Td(a,b))}else for((k=x(f.done))&&k.ranges||fd(a.sel,f.done),k={changes:[Td(a,b)],generation:f.generation},f.done.push(k);f.done.length>f.undoDepth;)f.done.shift(),f.done[0].ranges||f.done.shift();f.done.push(d);f.generation=++f.maxGeneration;f.lastModTime=f.lastSelTime=c;f.lastOp=f.lastSelOp=e;f.lastOrigin=f.lastSelOrigin=b.origin;r||ea(a,"historyAdded")}function fd(a,
b){var d=x(b);d&&d.ranges&&d.equals(a)||b.push(a)}function df(a,b,d,e){var f=b["spans_"+a.id],c=0;a.iter(Math.max(a.first,d),Math.min(a.first+a.size,e),function(d){d.markedSpans&&((f||(f=b["spans_"+a.id]={}))[c]=d.markedSpans);++c})}function yg(a){if(!a)return null;for(var b,d=0;d<a.length;++d)a[d].marker.explicitlyCleared?b||(b=a.slice(0,d)):b&&b.push(a[d]);return b?b.length?b:null:a}function gf(a,b){var d;if(d=b["spans_"+a.id]){for(var e=[],f=0;f<b.text.length;++f)e.push(yg(d[f]));d=e}else d=null;
a=fb(a,b);if(!d)return a;if(!a)return d;for(b=0;b<d.length;++b)if(e=d[b],f=a[b],e&&f){var c=0;a:for(;c<f.length;++c){for(var h=f[c],k=0;k<e.length;++k)if(e[k].marker==h.marker)continue a;e.push(h)}}else f&&(d[b]=f);return d}function Ob(a,d,e){for(var f=[],c=0;c<a.length;++c){var h=a[c];if(h.ranges)f.push(e?Ka.prototype.deepCopy.call(h):h);else{h=h.changes;var k=[];f.push({changes:k});for(var r=0;r<h.length;++r){var m=h[r],w;k.push({from:m.from,to:m.to,text:m.text});if(d)for(var l in m)(w=l.match(/^spans_(\d+)$/))&&
-1<b(d,Number(w[1]))&&(x(k)[l]=m[l],delete m[l])}}}return f}function Ud(a,b,d,e){return e?(a=a.anchor,d&&(e=0>S(b,a),e!=0>S(d,a)?(a=b,b=d):e!=0>S(b,d)&&(b=d)),new ba(a,b)):new ba(d||b,b)}function gd(a,b,d,e,f){null==f&&(f=a.cm&&(a.cm.display.shift||a.extend));sa(a,new Ka([Ud(a.sel.primary(),b,d,f)],0),e)}function hf(a,b,d){for(var e=[],f=a.cm&&(a.cm.display.shift||a.extend),c=0;c<a.sel.ranges.length;c++)e[c]=Ud(a.sel.ranges[c],b[c],null,f);b=Ta(e,a.sel.primIndex);sa(a,b,d)}function Vd(a,b,d,e){var f=
a.sel.ranges.slice(0);f[b]=d;sa(a,Ta(f,a.sel.primIndex),e)}function zg(a,b,d){d={ranges:b.ranges,update:function(b){this.ranges=[];for(var d=0;d<b.length;d++)this.ranges[d]=new ba(R(a,b[d].anchor),R(a,b[d].head))},origin:d&&d.origin};ea(a,"beforeSelectionChange",a,d);a.cm&&ea(a.cm,"beforeSelectionChange",a.cm,d);return d.ranges!=b.ranges?Ta(d.ranges,d.ranges.length-1):b}function jf(a,b,d){var e=a.history.done,f=x(e);f&&f.ranges?(e[e.length-1]=b,hd(a,b,d)):sa(a,b,d)}function sa(a,b,d){hd(a,b,d);b=
a.sel;var e=a.cm?a.cm.curOp.id:NaN,f=a.history,c=d&&d.origin,h;if(!(h=e==f.lastSelOp)&&(h=c&&f.lastSelOrigin==c)&&!(h=f.lastModTime==f.lastSelTime&&f.lastOrigin==c)){h=x(f.done);var k=c.charAt(0);h="*"==k||"+"==k&&h.ranges.length==b.ranges.length&&h.somethingSelected()==b.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}h?f.done[f.done.length-1]=b:fd(b,f.done);f.lastSelTime=+new Date;f.lastSelOrigin=c;f.lastSelOp=e;d&&!1!==d.clearRedo&&ef(f.undone)}function hd(a,
b,d){if(Ea(a,"beforeSelectionChange")||a.cm&&Ea(a.cm,"beforeSelectionChange"))b=zg(a,b,d);var e=d&&d.bias||(0>S(b.primary().head,a.sel.primary().head)?-1:1);kf(a,lf(a,b,e,!0));d&&!1===d.scroll||!a.cm||Lb(a.cm)}function kf(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,$b(a.cm)),ra(a,"cursorActivity",a))}function mf(a){kf(a,lf(a,a.sel,null,!1))}function lf(a,b,d,e){for(var f,c=0;c<b.ranges.length;c++){var h=b.ranges[c],k=b.ranges.length==a.sel.ranges.length&&
a.sel.ranges[c],r=Wd(a,h.anchor,k&&k.anchor,d,e);k=Wd(a,h.head,k&&k.head,d,e);if(f||r!=h.anchor||k!=h.head)f||(f=b.ranges.slice(0,c)),f[c]=new ba(r,k)}return f?Ta(f,b.primIndex):b}function Pb(a,b,d,e,f){var c=I(a,b.line);if(c.markedSpans)for(var h=0;h<c.markedSpans.length;++h){var k=c.markedSpans[h],r=k.marker;if((null==k.from||(r.inclusiveLeft?k.from<=b.ch:k.from<b.ch))&&(null==k.to||(r.inclusiveRight?k.to>=b.ch:k.to>b.ch))){if(f&&(ea(r,"beforeCursorEnter"),r.explicitlyCleared))if(c.markedSpans){--h;
continue}else break;if(r.atomic){if(d){h=r.find(0>e?1:-1);k=void 0;if(0>e?r.inclusiveRight:r.inclusiveLeft)h=nf(a,h,-e,h&&h.line==b.line?c:null);if(h&&h.line==b.line&&(k=S(h,d))&&(0>e?0>k:0<k))return Pb(a,h,b,e,f)}d=r.find(0>e?-1:1);if(0>e?r.inclusiveLeft:r.inclusiveRight)d=nf(a,d,e,d.line==b.line?c:null);return d?Pb(a,d,b,e,f):null}}}return b}function Wd(a,b,d,e,f){e=e||1;b=Pb(a,b,d,e,f)||!f&&Pb(a,b,d,e,!0)||Pb(a,b,d,-e,f)||!f&&Pb(a,b,d,-e,!0);return b?b:(a.cantEdit=!0,J(a.first,0))}function nf(a,
b,d,e){return 0>d&&0==b.ch?b.line>a.first?R(a,J(b.line-1)):null:0<d&&b.ch==(e||I(a,b.line)).text.length?b.line<a.first+a.size-1?J(b.line+1,0):null:new J(b.line,b.ch+d)}function of(a){a.setSelection(J(a.firstLine(),0),J(a.lastLine()),Ya)}function pf(a,b,d){var e={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){return e.canceled=!0}};d&&(e.update=function(b,d,f,c){b&&(e.from=R(a,b));d&&(e.to=R(a,d));f&&(e.text=f);void 0!==c&&(e.origin=c)});ea(a,"beforeChange",a,e);a.cm&&
ea(a.cm,"beforeChange",a.cm,e);return e.canceled?null:{from:e.from,to:e.to,text:e.text,origin:e.origin}}function Qb(a,b,d){if(a.cm){if(!a.cm.curOp)return pa(a.cm,Qb)(a,b,d);if(a.cm.state.suppressEdits)return}if(Ea(a,"beforeChange")||a.cm&&Ea(a.cm,"beforeChange"))if(b=pf(a,b,!0),!b)return;if(d=qf&&!d&&qd(a,b.from,b.to))for(var e=d.length-1;0<=e;--e)rf(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text,origin:b.origin});else rf(a,b)}function rf(a,d){if(1!=d.text.length||""!=d.text[0]||0!=S(d.from,d.to)){var e=
Qd(a,d);ff(a,d,e,a.cm?a.cm.curOp.id:NaN);rc(a,d,e,fb(a,d));var f=[];Bb(a,function(a,e){e||-1!=b(f,a.history)||(sf(a.history,d),f.push(a.history));rc(a,d,null,fb(a,d))})}}function id(a,d,e){if(!a.cm||!a.cm.state.suppressEdits||e){for(var f=a.history,c,h=a.sel,k="undo"==d?f.done:f.undone,r="undo"==d?f.undone:f.done,m=0;m<k.length&&(c=k[m],e?!c.ranges||c.equals(a.sel):c.ranges);m++);if(m!=k.length){for(f.lastOrigin=f.lastSelOrigin=null;;)if(c=k.pop(),c.ranges){fd(c,r);if(e&&!c.equals(a.sel)){sa(a,c,
{clearRedo:!1});return}h=c}else break;var l=[];fd(h,r);r.push({changes:l,generation:f.generation});f.generation=c.generation||++f.maxGeneration;var w=Ea(a,"beforeChange")||a.cm&&Ea(a.cm,"beforeChange");e=function(e){var f=c.changes[e];f.origin=d;if(w&&!pf(a,f,!1))return k.length=0,{};l.push(Td(a,f));var h=e?Qd(a,f):x(k);rc(a,f,h,gf(a,f));!e&&a.cm&&a.cm.scrollIntoView({from:f.from,to:mb(f)});var r=[];Bb(a,function(a,d){d||-1!=b(r,a.history)||(sf(a.history,f),r.push(a.history));rc(a,f,null,gf(a,f))})};
for(f=c.changes.length-1;0<=f;--f)if(h=e(f))return h.v}}}function tf(a,b){if(0!=b&&(a.first+=b,a.sel=new Ka(z(a.sel.ranges,function(a){return new ba(J(a.anchor.line+b,a.anchor.ch),J(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){za(a.cm,a.first,a.first-b,b);for(var d=a.cm.display,e=d.viewFrom;e<d.viewTo;e++)lb(a.cm,e,"gutter")}}function rc(a,b,d,e){if(a.cm&&!a.cm.curOp)return pa(a.cm,rc)(a,b,d,e);if(b.to.line<a.first)tf(a,b.text.length-1-(b.to.line-b.from.line));else if(!(b.from.line>a.lastLine())){if(b.from.line<
a.first){var f=b.text.length-1-(a.first-b.from.line);tf(a,f);b={from:J(a.first,0),to:J(b.to.line+f,b.to.ch),text:[x(b.text)],origin:b.origin}}f=a.lastLine();b.to.line>f&&(b={from:b.from,to:J(f,I(a,f).text.length),text:[b.text[0]],origin:b.origin});b.removed=P(a,b.from,b.to);d||(d=Qd(a,b));a.cm?Ag(a.cm,b,e):Sd(a,b,e);hd(a,d,Ya)}}function Ag(a,b,d){var e=a.doc,f=a.display,c=b.from,h=b.to,k=!1,r=c.line;a.options.lineWrapping||(r=O(Ha(I(e,c.line))),e.iter(r,h.line+1,function(a){if(a==f.maxLine)return k=
!0}));-1<e.sel.contains(b.from,b.to)&&$b(a);Sd(e,b,d,He(a));a.options.lineWrapping||(e.iter(r,c.line+b.text.length,function(a){var b=ya(a);b>f.maxLineLength&&(f.maxLine=a,f.maxLineLength=b,f.maxLineChanged=!0,k=!1)}),k&&(a.curOp.updateMaxLine=!0));fg(e,c.line);oc(a,400);d=b.text.length-(h.line-c.line)-1;b.full?za(a):c.line!=h.line||1!=b.text.length||af(a.doc,b)?za(a,c.line,h.line+1,d):lb(a,c.line,"text");d=Ea(a,"changes");if((e=Ea(a,"change"))||d)b={from:c,to:h,text:b.text,removed:b.removed,origin:b.origin},
e&&ra(a,"change",a,b),d&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function Rb(a,b,d,e,f){e||(e=d);if(0>S(e,d)){var c=[e,d];d=c[0];e=c[1];c}"string"==typeof b&&(b=a.splitLines(b));Qb(a,{from:d,to:e,text:b,origin:f})}function uf(a,b,d,e){d<a.line?a.line+=e:b<a.line&&(a.line=b,a.ch=0)}function vf(a,b,d,e){for(var f=0;f<a.length;++f){var c=a[f],h=!0;if(c.ranges)for(c.copied||(c=a[f]=c.deepCopy(),c.copied=!0),h=0;h<c.ranges.length;h++)uf(c.ranges[h].anchor,
b,d,e),uf(c.ranges[h].head,b,d,e);else{for(var k=0;k<c.changes.length;++k){var r=c.changes[k];if(d<r.from.line)r.from=J(r.from.line+e,r.from.ch),r.to=J(r.to.line+e,r.to.ch);else if(b<=r.to.line){h=!1;break}}h||(a.splice(0,f+1),f=0)}}}function sf(a,b){var d=b.from.line,e=b.to.line;b=b.text.length-(e-d)-1;vf(a.done,d,e,b);vf(a.undone,d,e,b)}function sc(a,b,d,e){var f=b,c=b;"number"==typeof b?c=I(a,Math.max(a.first,Math.min(b,a.first+a.size-1))):f=O(b);if(null==f)return null;e(c,f)&&a.cm&&lb(a.cm,f,
d);return c}function tc(a){this.lines=a;this.parent=null;for(var b=0,d=0;d<a.length;++d)a[d].parent=this,b+=a[d].height;this.height=b}function uc(a){this.children=a;for(var b=0,d=0,e=0;e<a.length;++e){var f=a[e];b+=f.chunkSize();d+=f.height;f.parent=this}this.size=b;this.height=d;this.parent=null}function Bg(a,b,d,e){var f=new vc(a,d,e),c=a.cm;c&&f.noHScroll&&(c.display.alignWidgets=!0);sc(a,b,"widget",function(b){var d=b.widgets||(b.widgets=[]);null==f.insertAt?d.push(f):d.splice(Math.min(d.length-
1,Math.max(0,f.insertAt)),0,f);f.line=b;c&&!$a(a,b)&&(d=Ia(b)<a.scrollTop,U(b,b.height+hc(f)),d&&$c(c,f.height),c.curOp.forceUpdate=!0);return!0});ra(c,"lineWidgetAdded",c,f,"number"==typeof b?b:O(b));return f}function Sb(a,b,d,c,h){if(c&&c.shared)return Cg(a,b,d,c,h);if(a.cm&&!a.cm.curOp)return pa(a.cm,Sb)(a,b,d,c,h);var k=new nb(a,h);h=S(b,d);c&&e(c,k,!1);if(0<h||0==h&&!1!==k.clearWhenEmpty)return k;k.replacedWith&&(k.collapsed=!0,k.widgetNode=f("span",[k.replacedWith],"CodeMirror-widget"),c.handleMouseEvents||
k.widgetNode.setAttribute("cm-ignore-events","true"),c.insertLeft&&(k.widgetNode.insertLeft=!0));if(k.collapsed){if(Gb(a,b.line,b,d,k)||b.line!=d.line&&Gb(a,d.line,b,d,k))throw Error("Inserting collapsed marker partially overlapping an existing one");hb=!0}k.addToHistory&&ff(a,{from:b,to:d,origin:"markText"},a.sel,NaN);var r=b.line,m=a.cm,l;a.iter(r,d.line+1,function(a){m&&k.collapsed&&!m.options.lineWrapping&&Ha(a)==m.display.maxLine&&(l=!0);k.collapsed&&r!=b.line&&U(a,0);var e=new Ca(k,r==b.line?
b.ch:null,r==d.line?d.ch:null);a.markedSpans=a.markedSpans?a.markedSpans.concat([e]):[e];e.marker.attachLine(a);++r});k.collapsed&&a.iter(b.line,d.line+1,function(b){$a(a,b)&&U(b,0)});k.clearOnEnter&&V(k,"beforeCursorEnter",function(){return k.clear()});k.readOnly&&(qf=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());k.collapsed&&(k.id=++wf,k.atomic=!0);if(m){l&&(m.curOp.updateMaxLine=!0);if(k.collapsed)za(m,b.line,d.line+1);else if(k.className||k.title||k.startStyle||k.endStyle||
k.css)for(c=b.line;c<=d.line;c++)lb(m,c,"text");k.atomic&&mf(m.doc);ra(m,"markerAdded",m,k)}return k}function Cg(a,b,d,f,c){f=e(f);f.shared=!1;var h=[Sb(a,b,d,f,c)],k=h[0],r=f.widgetNode;Bb(a,function(a){r&&(f.widgetNode=r.cloneNode(!0));h.push(Sb(a,R(a,b),R(a,d),f,c));for(var e=0;e<a.linked.length;++e)if(a.linked[e].isParent)return;k=x(h)});return new wc(h,k)}function xf(a){return a.findMarks(J(a.first,0),a.clipPos(J(a.lastLine())),function(a){return a.parent})}function Dg(a){for(var d=function(d){d=
a[d];var e=[d.primary.doc];Bb(d.primary.doc,function(a){return e.push(a)});for(var f=0;f<d.markers.length;f++){var c=d.markers[f];-1==b(e,c.doc)&&(c.parent=null,d.markers.splice(f--,1))}},e=0;e<a.length;e++)d(e)}function Eg(a){var d=this;yf(d);if(!ja(d,a)&&!cb(d.display,a)){oa(a);Z&&(zf=+new Date);var e=wb(d,a,!0),f=a.dataTransfer.files;if(e&&!d.isReadOnly())if(f&&f.length&&window.FileReader&&window.File)for(var c=f.length,h=Array(c),k=0,r=function(a,f){if(!d.options.allowDropFileTypes||-1!=b(d.options.allowDropFileTypes,
a.type)){var r=new FileReader;r.onload=pa(d,function(){var a=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(a)&&(a="");h[f]=a;++k==c&&(e=R(d.doc,e),a={from:e,to:e,text:d.doc.splitLines(h.join(d.doc.lineSeparator())),origin:"paste"},Qb(d.doc,a),jf(d.doc,db(e,mb(a))))});r.readAsText(a)}},m=0;m<c;++m)r(f[m],m);else if(d.state.draggingText&&-1<d.doc.sel.contains(e))d.state.draggingText(a),setTimeout(function(){return d.display.input.focus()},20);else try{if(r=a.dataTransfer.getData("Text")){d.state.draggingText&&
!d.state.draggingText.copy&&(m=d.listSelections());hd(d.doc,db(e,e));if(m)for(f=0;f<m.length;++f)Rb(d.doc,"",m[f].anchor,m[f].head,"drag");d.replaceSelection(r,"around","paste");d.display.input.focus()}}catch(lh){}}}function yf(a){a.display.dragCursor&&(a.display.lineSpace.removeChild(a.display.dragCursor),a.display.dragCursor=null)}function Af(a){if(document.getElementsByClassName)for(var b=document.getElementsByClassName("CodeMirror"),d=0;d<b.length;d++){var e=b[d].CodeMirror;e&&a(e)}}function Fg(){var a;
V(window,"resize",function(){null==a&&(a=setTimeout(function(){a=null;Af(Gg)},100))});V(window,"blur",function(){return Af(lc)})}function Gg(a){var b=a.display;if(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize()}function Hg(a){var b=a.split(/-(?!$)/);a=b[b.length-1];for(var d,e,f,c,h=0;h<b.length-1;h++){var k=b[h];if(/^(cmd|meta|m)$/i.test(k))c=!0;else if(/^a(lt)?$/i.test(k))d=
!0;else if(/^(c|ctrl|control)$/i.test(k))e=!0;else if(/^s(hift)?$/i.test(k))f=!0;else throw Error("Unrecognized modifier name: "+k);}d&&(a="Alt-"+a);e&&(a="Ctrl-"+a);c&&(a="Cmd-"+a);f&&(a="Shift-"+a);return a}function Ig(a){var b={},d;for(d in a)if(a.hasOwnProperty(d)){var e=a[d];if(!/^(name|fallthrough|(de|at)tach)$/.test(d)){if("..."!=e)for(var f=z(d.split(" "),Hg),c=0;c<f.length;c++){if(c==f.length-1){var h=f.join(" ");var k=e}else h=f.slice(0,c+1).join(" "),k="...";var r=b[h];if(!r)b[h]=k;else if(r!=
k)throw Error("Inconsistent bindings for "+h);}delete a[d]}}for(var m in b)a[m]=b[m];return a}function Tb(a,b,d,e){b=jd(b);var f=b.call?b.call(a,e):b[a];if(!1===f)return"nothing";if("..."===f)return"multi";if(null!=f&&d(f))return"handled";if(b.fallthrough){if("[object Array]"!=Object.prototype.toString.call(b.fallthrough))return Tb(a,b.fallthrough,d,e);for(f=0;f<b.fallthrough.length;f++){var c=Tb(a,b.fallthrough[f],d,e);if(c)return c}}}function Bf(a){a="string"==typeof a?a:ob[a.keyCode];return"Ctrl"==
a||"Alt"==a||"Shift"==a||"Mod"==a}function Cf(a,b,d){var e=a;b.altKey&&"Alt"!=e&&(a="Alt-"+a);(Df?b.metaKey:b.ctrlKey)&&"Ctrl"!=e&&(a="Ctrl-"+a);(Df?b.ctrlKey:b.metaKey)&&"Cmd"!=e&&(a="Cmd-"+a);!d&&b.shiftKey&&"Shift"!=e&&(a="Shift-"+a);return a}function Ef(a,b){if(Sa&&34==a.keyCode&&a["char"])return!1;var d=ob[a.keyCode];return null==d||a.altGraphKey?!1:Cf(d,a,b)}function jd(a){return"string"==typeof a?xc[a]:a}function Ub(a,b){for(var d=a.doc.sel.ranges,e=[],f=0;f<d.length;f++){for(var c=b(d[f]);e.length&&
0>=S(c.from,x(e).to);){var h=e.pop();if(0>S(h.from,c.from)){c.from=h.from;break}}e.push(c)}Fa(a,function(){for(var b=e.length-1;0<=b;b--)Rb(a.doc,"",e[b].from,e[b].to,"+delete");Lb(a)})}function Xd(a,b,d){b=C(a.text,b+d,d);return 0>b||b>a.text.length?null:b}function Yd(a,b,d){a=Xd(a,b.ch,d);return null==a?null:new J(b.line,a,0>d?"after":"before")}function Zd(a,b,d,e,f){if(a&&(a=Da(d,b.doc.direction))){a=0>f?x(a):a[0];var c=0>f==(1==a.level)?"after":"before";if(0<a.level||"rtl"==b.doc.direction){var h=
tb(b,d);var k=0>f?d.text.length-1:0;var r=Qa(b,h,k).top;k=F(function(a){return Qa(b,h,a).top==r},0>f==(1==a.level)?a.from:a.to-1,k);"before"==c&&(k=Xd(d,k,1))}else k=0>f?a.to:a.from;return new J(e,k,c)}return new J(e,0>f?d.text.length:0,0>f?"before":"after")}function Jg(a,b,d,e){var f=Da(b,a.doc.direction);if(!f)return Yd(b,d,e);d.ch>=b.text.length?(d.ch=b.text.length,d.sticky="before"):0>=d.ch&&(d.ch=0,d.sticky="after");var c=Ua(f,d.ch,d.sticky),h=f[c];if("ltr"==a.doc.direction&&0==h.level%2&&(0<
e?h.to>d.ch:h.from<d.ch))return Yd(b,d,e);var k=function(a,d){return Xd(b,a instanceof J?a.ch:a,d)},r,m=function(d){if(!a.options.lineWrapping)return{begin:0,end:b.text.length};r=r||tb(a,b);return Ge(a,b,r,d)},l=m("before"==d.sticky?k(d,-1):d.ch);if("rtl"==a.doc.direction||1==h.level){var g=1==h.level==0>e,t=k(d,g?1:-1);if(null!=t&&(g?t<=h.to&&t<=l.end:t>=h.from&&t>=l.begin))return new J(d.line,t,g?"before":"after")}h=function(a,b,e){for(var c=function(a,b){return b?new J(d.line,k(a,1),"before"):
new J(d.line,a,"after")};0<=a&&a<f.length;a+=b){var h=f[a],r=0<b==(1!=h.level),m=r?e.begin:k(e.end,-1);if(h.from<=m&&m<h.to)return c(m,r);m=r?h.from:k(h.to,-1);if(e.begin<=m&&m<e.end)return c(m,r)}};if(c=h(c+e,e,l))return c;l=0<e?l.end:k(l.begin,-1);return null==l||0<e&&l==b.text.length||!(c=h(0<e?0:f.length-1,e,m(l)))?null:c}function Ff(a,b){var d=I(a.doc,b),e=Ha(d);e!=d&&(b=O(e));return Zd(!0,a,e,b,1)}function Gf(a,b){var d=Ff(a,b.line),e=I(a.doc,d.line);a=Da(e,a.doc.direction);return a&&0!=a[0].level?
d:(e=Math.max(0,e.text.search(/\S/)),J(d.line,b.line==d.line&&b.ch<=e&&b.ch?0:e,d.sticky))}function kd(a,b,d){if("string"==typeof b&&(b=yc[b],!b))return!1;a.display.input.ensurePolled();var e=a.display.shift,f=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),d&&(a.display.shift=!1),f=b(a)!=ld}finally{a.display.shift=e,a.state.suppressEdits=!1}return f}function Kg(a,b,d){for(var e=0;e<a.state.keyMaps.length;e++){var f=Tb(b,a.state.keyMaps[e],d,a);if(f)return f}return a.options.extraKeys&&Tb(b,a.options.extraKeys,
d,a)||Tb(b,a.options.keyMap,d,a)}function zc(a,b,d,e){var f=a.state.keySeq;if(f){if(Bf(b))return"handled";Lg.set(50,function(){a.state.keySeq==f&&(a.state.keySeq=null,a.display.input.reset())});b=f+" "+b}e=Kg(a,b,e);"multi"==e&&(a.state.keySeq=b);"handled"==e&&ra(a,"keyHandled",a,b,d);if("handled"==e||"multi"==e)oa(d),Hd(a);return f&&!e&&/\'$/.test(b)?(oa(d),!0):!!e}function Hf(a,b){var d=Ef(b,!0);return d?b.shiftKey&&!a.state.keySeq?zc(a,"Shift-"+d,b,function(b){return kd(a,b,!0)})||zc(a,d,b,function(b){if("string"==
typeof b?/^go[A-Z]/.test(b):b.motion)return kd(a,b)}):zc(a,d,b,function(b){return kd(a,b)}):!1}function Mg(a,b,d){return zc(a,"'"+d+"'",b,function(b){return kd(a,b,!0)})}function If(a){this.curOp.focus=v();if(!ja(this,a)){Z&&11>da&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var d=Hf(this,a);Sa&&($d=d?b:null,!d&&88==b&&!Ng&&(Na?a.metaKey:a.ctrlKey)&&this.replaceSelection("",null,"cut"));18!=b||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||
Og(this)}}function Og(a){function b(a){18!=a.keyCode&&a.altKey||(xb(d,"CodeMirror-crosshair"),ia(document,"keyup",b),ia(document,"mouseover",b))}var d=a.display.lineDiv;t(d,"CodeMirror-crosshair");V(document,"keyup",b);V(document,"mouseover",b)}function Jf(a){16==a.keyCode&&(this.doc.sel.shift=!1);ja(this,a)}function Kf(a){if(!(cb(this.display,a)||ja(this,a)||a.ctrlKey&&!a.altKey||Na&&a.metaKey)){var b=a.keyCode,d=a.charCode;if(Sa&&b==$d)$d=null,oa(a);else if(!Sa||a.which&&!(10>a.which)||!Hf(this,
a))if(b=String.fromCharCode(null==d?b:d),"\b"!=b&&!Mg(this,a,b))this.display.input.onKeyPress(a)}}function Pg(a,b){var d=+new Date;if(Ac&&Ac.compare(d,a,b))return Bc=Ac=null,"triple";if(Bc&&Bc.compare(d,a,b))return Ac=new ae(d,a,b),Bc=null,"double";Bc=new ae(d,a,b);Ac=null;return"single"}function Lf(a){var b=this.display;if(!(ja(this,a)||b.activeTouch&&b.input.supportsTouch()))if(b.input.ensurePolled(),b.shift=a.shiftKey,cb(b,a))ta||(b.scroller.draggable=!1,setTimeout(function(){return b.scroller.draggable=
!0},100));else if(!md(this,a,"gutterClick",!0)){var d=wb(this,a),e=ac(a),f=d?Pg(d,e):"single";window.focus();1==e&&this.state.selectingText&&this.state.selectingText(a);d&&Qg(this,e,d,f,a)||(1==e?d?Rg(this,d,f,a):(a.target||a.srcElement)==b.scroller&&oa(a):2==e?(d&&gd(this.doc,d),setTimeout(function(){return b.input.focus()},20)):3==e&&(be?Mf(this,a):Le(this)))}}function Qg(a,b,d,e,f){var c="Click";"double"==e?c="Double"+c:"triple"==e&&(c="Triple"+c);return zc(a,Cf((1==b?"Left":2==b?"Middle":"Right")+
c,f),f,function(b){"string"==typeof b&&(b=yc[b]);if(!b)return!1;var e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),e=b(a,d)!=ld}finally{a.state.suppressEdits=!1}return e})}function Rg(a,b,d,e){Z?setTimeout(k(Ke,a),0):a.curOp.focus=v();var f=a.getOption("configureMouse");f=f?f(a,d,e):{};null==f.unit&&(f.unit=(Sg?e.shiftKey&&e.metaKey:e.altKey)?"rectangle":"single"==d?"char":"double"==d?"word":"line");if(null==f.extend||a.doc.extend)f.extend=a.doc.extend||e.shiftKey;null==f.addNew&&(f.addNew=Na?
e.metaKey:e.ctrlKey);null==f.moveOnDrag&&(f.moveOnDrag=!(Na?e.altKey:e.ctrlKey));var c=a.doc.sel,h;a.options.dragDrop&&Tg&&!a.isReadOnly()&&"single"==d&&-1<(h=c.contains(b))&&(0>S((h=c.ranges[h]).from(),b)||0<b.xRel)&&(0<S(h.to(),b)||0>b.xRel)?Ug(a,e,b,f):Vg(a,e,b,f)}function Ug(a,b,d,e){var f=a.display,c=!1,h=pa(a,function(b){ta&&(f.scroller.draggable=!1);a.state.draggingText=!1;ia(document,"mouseup",h);ia(document,"mousemove",k);ia(f.scroller,"dragstart",r);ia(f.scroller,"drop",h);c||(oa(b),e.addNew||
gd(a.doc,d,null,null,e.extend),ta||Z&&9==da?setTimeout(function(){document.body.focus();f.input.focus()},20):f.input.focus())}),k=function(a){c=c||10<=Math.abs(b.clientX-a.clientX)+Math.abs(b.clientY-a.clientY)},r=function(){return c=!0};ta&&(f.scroller.draggable=!0);a.state.draggingText=h;h.copy=!e.moveOnDrag;f.scroller.dragDrop&&f.scroller.dragDrop();V(document,"mouseup",h);V(document,"mousemove",k);V(f.scroller,"dragstart",r);V(f.scroller,"drop",h);Le(a);setTimeout(function(){return f.input.focus()},
20)}function Nf(a,b,d){if("char"==d)return new ba(b,b);if("word"==d)return a.findWordAt(b);if("line"==d)return new ba(J(b.line,0),R(a.doc,J(b.line+1,0)));a=d(a,b);return new ba(a.from,a.to)}function Vg(a,b,e,f){function c(b){if(0!=S(B,b))if(B=b,"rectangle"==f.unit){var c=[],k=a.options.tabSize,r=d(I(l,e.line).text,e.ch,k),m=d(I(l,b.line).text,b.ch,k),t=Math.min(r,m);r=Math.max(r,m);m=Math.min(e.line,b.line);for(var v=Math.min(a.lastLine(),Math.max(e.line,b.line));m<=v;m++){var n=I(l,m).text,z=h(n,
t,k);t==r?c.push(new ba(J(m,z),J(m,z))):n.length>z&&c.push(new ba(J(m,z),J(m,h(n,r,k))))}c.length||c.push(new ba(e,e));sa(l,Ta(g.ranges.slice(0,x).concat(c),x),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else c=w,t=Nf(a,b,f.unit),b=c.anchor,0<S(t.anchor,b)?(k=t.head,b=X(c.from(),t.anchor)):(k=t.anchor,b=ma(c.to(),t.head)),c=g.ranges.slice(0),c[x]=Wg(a,new ba(R(l,b),k)),sa(l,Ta(c,x),ce)}function k(b){var d=++z,e=wb(a,b,!0,"rectangle"==f.unit);if(e)if(0!=S(e,B)){a.curOp.focus=v();c(e);var h=Jd(m,
l);(e.line>=h.to||e.line<h.from)&&setTimeout(pa(a,function(){z==d&&k(b)}),150)}else{var r=b.clientY<n.top?-20:b.clientY>n.bottom?20:0;r&&setTimeout(pa(a,function(){z==d&&(m.scroller.scrollTop+=r,k(b))}),50)}}function r(b){a.state.selectingText=!1;z=Infinity;oa(b);m.input.focus();ia(document,"mousemove",H);ia(document,"mouseup",q);l.history.lastSelOrigin=null}var m=a.display,l=a.doc;oa(b);var g=l.sel,t=g.ranges;if(f.addNew&&!f.extend){var x=l.sel.contains(e);var w=-1<x?t[x]:new ba(e,e)}else w=l.sel.primary(),
x=l.sel.primIndex;"rectangle"==f.unit?(f.addNew||(w=new ba(e,e)),e=wb(a,b,!0,!0),x=-1):(b=Nf(a,e,f.unit),w=f.extend?Ud(w,b.anchor,b.head,f.extend):b);f.addNew?-1==x?(x=t.length,sa(l,Ta(t.concat([w]),x),{scroll:!1,origin:"*mouse"})):1<t.length&&t[x].empty()&&"char"==f.unit&&!f.extend?(sa(l,Ta(t.slice(0,x).concat(t.slice(x+1)),0),{scroll:!1,origin:"*mouse"}),g=l.sel):Vd(l,x,w,ce):(x=0,sa(l,new Ka([w],0),ce),g=l.sel);var B=e,n=m.wrapper.getBoundingClientRect(),z=0,H=pa(a,function(a){ac(a)?k(a):r(a)}),
q=pa(a,r);a.state.selectingText=q;V(document,"mousemove",H);V(document,"mouseup",q)}function Wg(a,b){var d=b.anchor,e=b.head,f=I(a.doc,d.line);if(0==S(d,e)&&d.sticky==e.sticky)return b;f=Da(f);if(!f)return b;var c=Ua(f,d.ch,d.sticky),h=f[c];if(h.from!=d.ch&&h.to!=d.ch)return b;var k=c+(h.from==d.ch==(1!=h.level)?0:1);if(0==k||k==f.length)return b;e.line!=d.line?a=0<(e.line-d.line)*("ltr"==a.doc.direction?1:-1):(a=Ua(f,e.ch,e.sticky),c=a-c||(e.ch-d.ch)*(1==h.level?-1:1),a=a==k-1||a==k?0>c:0<c);f=f[k+
(a?-1:0)];f=(k=a==(1==f.level))?f.from:f.to;k=k?"after":"before";return d.ch==f&&d.sticky==k?b:new ba(new J(d.line,f,k),e)}function md(a,b,d,e){if(b.touches){var f=b.touches[0].clientX;var c=b.touches[0].clientY}else try{f=b.clientX,c=b.clientY}catch(he){return!1}if(f>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;e&&oa(b);e=a.display;var h=e.lineDiv.getBoundingClientRect();if(c>h.bottom||!Ea(a,d))return pb(b);c-=h.top-e.viewOffset;for(h=0;h<a.options.gutters.length;++h){var k=
e.gutters.childNodes[h];if(k&&k.getBoundingClientRect().right>=f)return f=T(a.doc,c),ea(a,d,a,f,a.options.gutters[h],b),pb(b)}}function Mf(a,b){var d;(d=cb(a.display,b))||(d=Ea(a,"gutterContextMenu")?md(a,b,"gutterContextMenu",!1):!1);if(!d&&!ja(a,b,"contextmenu"))a.display.input.onContextMenu(b)}function Of(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");jc(a)}function Cc(a){We(a);za(a);Ne(a)}function Xg(a,b,d){!b!=
!(d&&d!=Vb)&&(d=a.display.dragFunctions,b=b?V:ia,b(a.display.scroller,"dragstart",d.start),b(a.display.scroller,"dragenter",d.enter),b(a.display.scroller,"dragover",d.over),b(a.display.scroller,"dragleave",d.leave),b(a.display.scroller,"drop",d.drop))}function Yg(a){a.options.lineWrapping?(t(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(xb(a.display.wrapper,"CodeMirror-wrap"),ab(a));Gd(a);za(a);jc(a);setTimeout(function(){return Mb(a)},100)}function fa(a,
b){var d=this;if(!(this instanceof fa))return new fa(a,b);this.options=b=b?e(b):{};e(Pf,b,!1);Pd(b);var f=b.value;"string"==typeof f&&(f=new Aa(f,b.mode,null,b.lineSeparator,b.direction));this.doc=f;var c=new fa.inputStyles[b.inputStyle](this);a=this.display=new M(a,f,c);a.wrapper.CodeMirror=this;We(this);Of(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");Se(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,
pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Cb,keySeq:null,specialChars:null};b.autofocus&&!Yb&&a.input.focus();Z&&11>da&&setTimeout(function(){return d.display.input.reset(!0)},20);Zg(this);Qf||(Fg(),Qf=!0);zb(this);this.curOp.forceUpdate=!0;bf(this,f);b.autofocus&&!Yb||this.hasFocus()?setTimeout(k(Id,this),20):lc(this);for(var h in nd)if(nd.hasOwnProperty(h))nd[h](d,b[h],Vb);Oe(this);b.finishInit&&b.finishInit(this);for(f=0;f<de.length;++f)de[f](d);Ab(this);ta&&
b.lineWrapping&&"optimizelegibility"==getComputedStyle(a.lineDiv).textRendering&&(a.lineDiv.style.textRendering="auto")}function Zg(b){function d(){f.activeTouch&&(c=setTimeout(function(){return f.activeTouch=null},1E3),h=f.activeTouch,h.end=+new Date)}function e(a,b){if(null==b.left)return!0;var d=b.left-a.left;a=b.top-a.top;return 400<d*d+a*a}var f=b.display;V(f.scroller,"mousedown",pa(b,Lf));Z&&11>da?V(f.scroller,"dblclick",pa(b,function(a){if(!ja(b,a)){var d=wb(b,a);!d||md(b,a,"gutterClick",!0)||
cb(b.display,a)||(oa(a),a=b.findWordAt(d),gd(b.doc,a.anchor,a.head))}})):V(f.scroller,"dblclick",function(a){return ja(b,a)||oa(a)});be||V(f.scroller,"contextmenu",function(a){return Mf(b,a)});var c,h={end:0};V(f.scroller,"touchstart",function(a){var d;if(d=!ja(b,a))1!=a.touches.length?d=!1:(d=a.touches[0],d=1>=d.radiusX&&1>=d.radiusY),d=!d;d&&!md(b,a,"gutterClick",!0)&&(f.input.ensurePolled(),clearTimeout(c),d=+new Date,f.activeTouch={start:d,moved:!1,prev:300>=d-h.end?h:null},1==a.touches.length&&
(f.activeTouch.left=a.touches[0].pageX,f.activeTouch.top=a.touches[0].pageY))});V(f.scroller,"touchmove",function(){f.activeTouch&&(f.activeTouch.moved=!0)});V(f.scroller,"touchend",function(a){var c=f.activeTouch;if(c&&!cb(f,a)&&null!=c.left&&!c.moved&&300>new Date-c.start){var h=b.coordsChar(f.activeTouch,"page");c=!c.prev||e(c,c.prev)?new ba(h,h):!c.prev.prev||e(c,c.prev.prev)?b.findWordAt(h):new ba(J(h.line,0),R(b.doc,J(h.line+1,0)));b.setSelection(c.anchor,c.head);b.focus();oa(a)}d()});V(f.scroller,
"touchcancel",d);V(f.scroller,"scroll",function(){f.scroller.clientHeight&&(nc(b,f.scroller.scrollTop),yb(b,f.scroller.scrollLeft,!0),ea(b,"scroll",b))});V(f.scroller,"mousewheel",function(a){return Ye(b,a)});V(f.scroller,"DOMMouseScroll",function(a){return Ye(b,a)});V(f.wrapper,"scroll",function(){return f.wrapper.scrollTop=f.wrapper.scrollLeft=0});f.dragFunctions={enter:function(a){ja(b,a)||qb(a)},over:function(d){if(!ja(b,d)){var e=wb(b,d);if(e){var f=document.createDocumentFragment();Je(b,e,f);
b.display.dragCursor||(b.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),b.display.lineSpace.insertBefore(b.display.dragCursor,b.display.cursorDiv));q(b.display.dragCursor,f)}qb(d)}},start:function(d){if(Z&&(!b.state.draggingText||100>+new Date-zf))qb(d);else if(!ja(b,d)&&!cb(b.display,d)&&(d.dataTransfer.setData("Text",b.getSelection()),d.dataTransfer.effectAllowed="copyMove",d.dataTransfer.setDragImage&&!Rf)){var e=a("img",null,null,"position: fixed; left: 0; top: 0;");
e.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";Sa&&(e.width=e.height=1,b.display.wrapper.appendChild(e),e._top=e.offsetTop);d.dataTransfer.setDragImage(e,0,0);Sa&&e.parentNode.removeChild(e)}},drop:pa(b,Eg),leave:function(a){ja(b,a)||yf(b)}};var k=f.input.getField();V(k,"keyup",function(a){return Jf.call(b,a)});V(k,"keydown",pa(b,If));V(k,"keypress",pa(b,Kf));V(k,"focus",function(a){return Id(b,a)});V(k,"blur",function(a){return lc(b,a)})}function Dc(a,b,e,f){var c=
a.doc,h;null==e&&(e="add");"smart"==e&&(c.mode.indent?h=Va(a,b).state:e="prev");var k=a.options.tabSize,m=I(c,b),l=d(m.text,null,k);m.stateAfter&&(m.stateAfter=null);var t=m.text.match(/^\s*/)[0];if(!f&&!/\S/.test(m.text)){var g=0;e="not"}else if("smart"==e&&(g=c.mode.indent(h,m.text.slice(t.length),m.text),g==ld||150<g)){if(!f)return;e="prev"}"prev"==e?g=b>c.first?d(I(c,b-1).text,null,k):0:"add"==e?g=l+a.options.indentUnit:"subtract"==e?g=l-a.options.indentUnit:"number"==typeof e&&(g=l+e);g=Math.max(0,
g);e="";f=0;if(a.options.indentWithTabs)for(a=Math.floor(g/k);a;--a)f+=k,e+="\t";f<g&&(e+=r(g-f));if(e!=t)return Rb(c,e,J(b,0),J(b,t.length),"+input"),m.stateAfter=null,!0;for(k=0;k<c.sel.ranges.length;k++)if(m=c.sel.ranges[k],m.head.line==b&&m.head.ch<t.length){b=J(b,t.length);Vd(c,k,new ba(b,b));break}}function ee(a,b,d,e,f){var c=a.doc;a.display.shift=!1;e||(e=c.sel);var h=a.state.pasteIncoming||"paste"==f,k=fe(b),r=null;if(h&&1<e.ranges.length)if(Ga&&Ga.text.join("\n")==b){if(0==e.ranges.length%
Ga.text.length){r=[];for(var m=0;m<Ga.text.length;m++)r.push(c.splitLines(Ga.text[m]))}}else k.length==e.ranges.length&&a.options.pasteLinesPerSelection&&(r=z(k,function(a){return[a]}));for(m=e.ranges.length-1;0<=m;m--){var l=e.ranges[m];var g=l.from(),t=l.to();l.empty()&&(d&&0<d?g=J(g.line,g.ch-d):a.state.overwrite&&!h?t=J(t.line,Math.min(I(c,t.line).text.length,t.ch+x(k).length)):Ga&&Ga.lineWise&&Ga.text.join("\n")==b&&(g=t=J(g.line,0)));l=a.curOp.updateInput;g={from:g,to:t,text:r?r[m%r.length]:
k,origin:f||(h?"paste":a.state.cutIncoming?"cut":"+input")};Qb(a.doc,g);ra(a,"inputRead",a,g)}b&&!h&&Sf(a,b);Lb(a);a.curOp.updateInput=l;a.curOp.typing=!0;a.state.pasteIncoming=a.state.cutIncoming=!1}function Tf(a,b){var d=a.clipboardData&&a.clipboardData.getData("Text");if(d)return a.preventDefault(),b.isReadOnly()||b.options.disableInput||Fa(b,function(){return ee(b,d,0,null,"paste")}),!0}function Sf(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var d=a.doc.sel,e=d.ranges.length-1;0<=
e;e--){var f=d.ranges[e];if(!(100<f.head.ch||e&&d.ranges[e-1].head.line==f.head.line)){var c=a.getModeAt(f.head),h=!1;if(c.electricChars)for(var k=0;k<c.electricChars.length;k++){if(-1<b.indexOf(c.electricChars.charAt(k))){h=Dc(a,f.head.line,"smart");break}}else c.electricInput&&c.electricInput.test(I(a.doc,f.head.line).text.slice(0,f.head.ch))&&(h=Dc(a,f.head.line,"smart"));h&&ra(a,"electricInput",a,f.head.line)}}}function Uf(a){for(var b=[],d=[],e=0;e<a.doc.sel.ranges.length;e++){var f=a.doc.sel.ranges[e].head.line;
f={anchor:J(f,0),head:J(f+1,0)};d.push(f);b.push(a.getRange(f.anchor,f.head))}return{text:b,ranges:d}}function Vf(a,b){a.setAttribute("autocorrect","off");a.setAttribute("autocapitalize","off");a.setAttribute("spellcheck",!!b)}function Wf(){var b=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),d=a("div",[b],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");ta?b.style.width="1000px":b.setAttribute("wrap","off");Ec&&
(b.style.border="1px solid black");Vf(b);return d}function ge(a,b,d,e,f){function c(e){var c=f?Jg(a.cm,r,b,d):Yd(r,b,d);if(null==c){if(e=!e)e=b.line+d,e<a.first||e>=a.first+a.size?e=!1:(b=new J(e,b.ch,b.sticky),e=r=I(a,e));if(e)b=Zd(f,a.cm,r,b.line,d);else return!1}else b=c;return!0}var h=b,k=d,r=I(a,b.line);if("char"==e)c();else if("column"==e)c(!0);else if("word"==e||"group"==e){var m=null;e="group"==e;for(var l=a.cm&&a.cm.getHelper(b,"wordChars"),g=!0;!(0>d)||c(!g);g=!1){var t=r.text.charAt(b.ch)||
"\n";t=G(t,l)?"w":e&&"\n"==t?"n":!e||/\s/.test(t)?null:"p";!e||g||t||(t="s");if(m&&m!=t){0>d&&(d=1,c(),b.sticky="after");break}t&&(m=t);if(0<d&&!c(!g))break}}k=Wd(a,b,h,k,!0);ha(h,k)&&(k.hitSide=!0);return k}function Xf(a,b,d,e){var f=a.doc,c=b.left;if("page"==e){var h=Math.max(Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight)-.5*ub(a.display),3);h=(0<d?b.bottom:b.top)+d*h}else"line"==e&&(h=0<d?b.bottom+3:b.top-3);for(;;){b=Dd(a,c,h);if(!b.outside)break;
if(0>d?0>=h:h>=f.height){b.hitSide=!0;break}h+=5*d}return b}function Yf(a,b){var d=xd(a,b.line);if(!d||d.hidden)return null;var e=I(a.doc,b.line);d=we(d,e,b.line);a=Da(e,a.doc.direction);e="left";a&&(e=Ua(a,b.ch)%2?"right":"left");b=xe(d.map,b.ch,e);b.offset="right"==b.collapse?b.end:b.start;return b}function $g(a){for(;a;a=a.parentNode)if(/CodeMirror-gutter-wrapper/.test(a.className))return!0;return!1}function Wb(a,b){b&&(a.bad=!0);return a}function ah(a,b,d,e,f){function c(a){return function(b){return b.id==
a}}function h(a){a&&(m&&(r+=l,m=!1),r+=a)}function k(b){if(1==b.nodeType){var d=b.getAttribute("cm-text");if(null!=d)h(d||b.textContent.replace(/\u200b/g,""));else{d=b.getAttribute("cm-marker");var t;if(d)b=a.findMarks(J(e,0),J(f+1,0),c(+d)),b.length&&(t=b[0].find(0))&&h(P(a.doc,t.from,t.to).join(l));else if("false"!=b.getAttribute("contenteditable")){(t=/^(pre|div|p)$/i.test(b.nodeName))&&m&&(r+=l,m=!1);for(d=0;d<b.childNodes.length;d++)k(b.childNodes[d]);t&&(m=!0)}}}else 3==b.nodeType&&h(b.nodeValue)}
for(var r="",m=!1,l=a.doc.lineSeparator();;){k(b);if(b==d)break;b=b.nextSibling}return r}function od(a,b,d){if(b==a.display.lineDiv){var e=a.display.lineDiv.childNodes[d];if(!e)return Wb(a.clipPos(J(a.display.viewTo-1)),!0);b=null;d=0}else for(e=b;;e=e.parentNode){if(!e||e==a.display.lineDiv)return null;if(e.parentNode&&e.parentNode==a.display.lineDiv)break}for(var f=0;f<a.display.view.length;f++){var c=a.display.view[f];if(c.node==e)return bh(c,b,d)}}function bh(a,b,d){function e(b,d,e){for(var f=
-1;f<(m?m.length:0);f++)for(var c=0>f?r.map:m[f],h=0;h<c.length;h+=3){var k=c[h+2];if(k==b||k==d){d=O(0>f?a.line:a.rest[f]);f=c[h]+e;if(0>e||k!=b)f=c[h+(e?1:0)];return J(d,f)}}}var f=a.text.firstChild,c=!1;if(!b||!l(f,b))return Wb(J(O(a.line),0),!0);if(b==f&&(c=!0,b=f.childNodes[d],d=0,!b))return d=a.rest?x(a.rest):a.line,Wb(J(O(d),d.text.length),c);var h=3==b.nodeType?b:null,k=b;h||1!=b.childNodes.length||3!=b.firstChild.nodeType||(h=b.firstChild,d&&(d=h.nodeValue.length));for(;k.parentNode!=f;)k=
k.parentNode;var r=a.measure,m=r.maps;if(b=e(h,k,d))return Wb(b,c);f=k.nextSibling;for(h=h?h.nodeValue.length-d:0;f;f=f.nextSibling){if(b=e(f,f.firstChild,0))return Wb(J(b.line,b.ch-h),c);h+=f.textContent.length}for(k=k.previousSibling;k;k=k.previousSibling){if(b=e(k,k.firstChild,-1))return Wb(J(b.line,b.ch+d),c);d+=k.textContent.length}}var wa=navigator.userAgent,Zf=navigator.platform,gb=/gecko\/\d/i.test(wa),$f=/MSIE \d/.test(wa),ag=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wa),Fc=/Edge\/(\d+)/.exec(wa),
Z=$f||ag||Fc,da=Z&&($f?document.documentMode||6:+(Fc||ag)[1]),ta=!Fc&&/WebKit\//.test(wa),ch=ta&&/Qt\/\d+\.\d+/.test(wa),Vc=!Fc&&/Chrome\//.test(wa),Sa=/Opera\//.test(wa),Rf=/Apple Computer/.test(navigator.vendor),dh=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(wa),tg=/PhantomJS/.test(wa),Ec=!Fc&&/AppleWebKit/.test(wa)&&/Mobile\/\w+/.test(wa),Wc=/Android/.test(wa),Yb=Ec||Wc||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(wa),Na=Ec||/Mac/.test(Zf),Sg=/\bCrOS\b/.test(wa),eh=/win/i.test(Zf),Db=Sa&&wa.match(/Version\/(\d*\.\d*)/);
Db&&(Db=Number(Db[1]));Db&&15<=Db&&(Sa=!1,ta=!0);var Df=Na&&(ch||Sa&&(null==Db||12.11>Db)),be=gb||Z&&9<=da,xb=function(a,b){var d=a.className;if(b=c(b).exec(d)){var e=d.slice(b.index+b[0].length);a.className=d.slice(0,b.index)+(e?b[1]+e:"")}};var ec=document.createRange?function(a,b,d,e){var f=document.createRange();f.setEnd(e||a,d);f.setStart(a,b);return f}:function(a,b,d){var e=document.body.createTextRange();try{e.moveToElementText(a.parentNode)}catch(jh){return e}e.collapse(!0);e.moveEnd("character",
d);e.moveStart("character",b);return e};var Gc=function(a){a.select()};Ec?Gc=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:Z&&(Gc=function(a){try{a.select()}catch(Q){}});var Cb=function(){this.id=null};Cb.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var ld={toString:function(){return"CodeMirror.Pass"}},Ya={scroll:!1},ce={origin:"*mouse"},Hc={origin:"+move"},Oc=[""],bg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,
cg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,
qf=!1,hb=!1,Zb=null,dg=function(){function a(a){return 247>=a?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1785>=a?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(a-
1536):1774<=a&&2220>=a?"r":8192<=a&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,d){this.level=a;this.from=b;this.to=d}var d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,c=/[Lb1n]/,h=/[1n]/;return function(k,r){var m="ltr"==r?"L":"R";if(0==k.length||"ltr"==r&&!d.test(k))return!1;for(var l=k.length,t=[],g=0;g<l;++g)t.push(a(k.charCodeAt(g)));g=0;for(var v=m;g<l;++g){var B=t[g];"m"==B?t[g]=v:v=B}g=0;for(v=m;g<l;++g)B=t[g],"1"==B&&"r"==v?t[g]="n":f.test(B)&&(v=B,"r"==B&&(t[g]="R"));
g=1;for(v=t[0];g<l-1;++g)B=t[g],"+"==B&&"1"==v&&"1"==t[g+1]?t[g]="1":","!=B||v!=t[g+1]||"1"!=v&&"n"!=v||(t[g]=v),v=B;for(g=0;g<l;++g)if(v=t[g],","==v)t[g]="N";else if("%"==v){for(v=g+1;v<l&&"%"==t[v];++v);for(B=g&&"!"==t[g-1]||v<l&&"1"==t[v]?"1":"N";g<v;++g)t[g]=B;g=v-1}g=0;for(v=m;g<l;++g)B=t[g],"L"==v&&"1"==B?t[g]="L":f.test(B)&&(v=B);for(v=0;v<l;++v)if(e.test(t[v])){for(g=v+1;g<l&&e.test(t[g]);++g);B="L"==(v?t[v-1]:m);for(B=B==("L"==(g<l?t[g]:m))?B?"L":"R":m;v<g;++v)t[v]=B;v=g-1}m=[];var n;for(g=
0;g<l;)if(c.test(t[g])){v=g;for(++g;g<l&&c.test(t[g]);++g);m.push(new b(0,v,g))}else{var z=g;v=m.length;for(++g;g<l&&"L"!=t[g];++g);for(B=z;B<g;)if(h.test(t[B])){z<B&&m.splice(v,0,new b(1,z,B));z=B;for(++B;B<g&&h.test(t[B]);++B);m.splice(v,0,new b(2,z,B));z=B}else++B;z<g&&m.splice(v,0,new b(1,z,g))}"ltr"==r&&(1==m[0].level&&(n=k.match(/^\s+/))&&(m[0].from=n[0].length,m.unshift(new b(0,0,n[0].length))),1==x(m).level&&(n=k.match(/\s+$/))&&(x(m).to-=n[0].length,m.push(new b(0,l-n[0].length,l))));return"rtl"==
r?m.reverse():m}}(),Pc=[],V=function(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent?a.attachEvent("on"+b,d):(a=a._handlers||(a._handlers={}),a[b]=(a[b]||Pc).concat(d))},Tg=function(){if(Z&&9>da)return!1;var b=a("div");return"draggable"in b||"dragDrop"in b}(),rd,td,fe=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,d=[],e=a.length;b<=e;){var f=a.indexOf("\n",b);-1==f&&(f=a.length);var c=a.slice(b,"\r"==a.charAt(f-1)?f-1:f),h=c.indexOf("\r");-1!=h?(d.push(c.slice(0,h)),b+=
h+1):(d.push(c),b=f+1)}return d}:function(a){return a.split(/\r\n?|\n/)},fh=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(Q){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(ih){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},Ng=function(){var b=a("div");if("oncopy"in b)return!0;b.setAttribute("oncopy","return;");return"function"==typeof b.oncopy}(),zd=null,sd={},Hb={},Ib={},ka=function(a,b,d){this.pos=this.start=
0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0;this.lineOracle=d};ka.prototype.eol=function(){return this.pos>=this.string.length};ka.prototype.sol=function(){return this.pos==this.lineStart};ka.prototype.peek=function(){return this.string.charAt(this.pos)||void 0};ka.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)};ka.prototype.eat=function(a){var b=this.string.charAt(this.pos);if("string"==typeof a?b==a:b&&
(a.test?a.test(b):a(b)))return++this.pos,b};ka.prototype.eatWhile=function(a){for(var b=this.pos;this.eat(a););return this.pos>b};ka.prototype.eatSpace=function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a};ka.prototype.skipToEnd=function(){this.pos=this.string.length};ka.prototype.skipTo=function(a){a=this.string.indexOf(a,this.pos);if(-1<a)return this.pos=a,!0};ka.prototype.backUp=function(a){this.pos-=a};ka.prototype.column=function(){this.lastColumnPos<
this.start&&(this.lastColumnValue=d(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue-(this.lineStart?d(this.string,this.lineStart,this.tabSize):0)};ka.prototype.indentation=function(){return d(this.string,null,this.tabSize)-(this.lineStart?d(this.string,this.lineStart,this.tabSize):0)};ka.prototype.match=function(a,b,d){if("string"==typeof a){var e=function(a){return d?a.toLowerCase():a},f=this.string.substr(this.pos,
a.length);if(e(f)==e(a))return!1!==b&&(this.pos+=a.length),!0}else{if((a=this.string.slice(this.pos).match(a))&&0<a.index)return null;a&&!1!==b&&(this.pos+=a[0].length);return a}};ka.prototype.current=function(){return this.string.slice(this.start,this.pos)};ka.prototype.hideFirstChars=function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}};ka.prototype.lookAhead=function(a){var b=this.lineOracle;return b&&b.lookAhead(a)};ka.prototype.baseToken=function(){var a=this.lineOracle;
return a&&a.baseToken(this.pos)};var Tc=function(a,b){this.state=a;this.lookAhead=b},Wa=function(a,b,d,e){this.state=b;this.doc=a;this.line=d;this.maxLookAhead=e||0;this.baseTokens=null;this.baseTokenPos=1};Wa.prototype.lookAhead=function(a){var b=this.doc.getLine(this.line+a);null!=b&&a>this.maxLookAhead&&(this.maxLookAhead=a);return b};Wa.prototype.baseToken=function(a){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=a;)this.baseTokenPos+=2;var b=this.baseTokens[this.baseTokenPos+
1];return{type:b&&b.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-a}};Wa.prototype.nextLine=function(){this.line++;0<this.maxLookAhead&&this.maxLookAhead--};Wa.fromSaved=function(a,b,d){return b instanceof Tc?new Wa(a,Pa(a.mode,b.state),d,b.lookAhead):new Wa(a,Pa(a.mode,b),d)};Wa.prototype.save=function(a){a=!1!==a?Pa(this.doc.mode,this.state):this.state;return 0<this.maxLookAhead?new Tc(a,this.maxLookAhead):a};var ke=function(a,b,d){this.start=a.start;this.end=a.pos;this.string=
a.current();this.type=b||null;this.state=d},Nb=function(a,b,d){this.text=a;Ba(this,b);this.height=d?d(this):1};Nb.prototype.lineNo=function(){return O(this)};Ma(Nb);var hg={},gg={},Kb=null,fc=null,ye={left:0,right:0,top:0,bottom:0},vb,Eb=function(b,d,e){this.cm=e;var f=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),c=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");b(f);b(c);V(f,"scroll",function(){f.clientHeight&&d(f.scrollTop,
"vertical")});V(c,"scroll",function(){c.clientWidth&&d(c.scrollLeft,"horizontal")});this.checkedZeroWidth=!1;Z&&8>da&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Eb.prototype.update=function(a){var b=a.scrollWidth>a.clientWidth+1,d=a.scrollHeight>a.clientHeight+1,e=a.nativeBarWidth;d?(this.vert.style.display="block",this.vert.style.bottom=b?e+"px":"0",this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+(a.viewHeight-(b?e:0)))+"px"):(this.vert.style.display=
"",this.vert.firstChild.style.height="0");b?(this.horiz.style.display="block",this.horiz.style.right=d?e+"px":"0",this.horiz.style.left=a.barLeft+"px",this.horiz.firstChild.style.width=Math.max(0,a.scrollWidth-a.clientWidth+(a.viewWidth-a.barLeft-(d?e:0)))+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0");!this.checkedZeroWidth&&0<a.clientHeight&&(0==e&&this.zeroWidthHack(),this.checkedZeroWidth=!0);return{right:d?e:0,bottom:b?e:0}};Eb.prototype.setScrollLeft=function(a){this.horiz.scrollLeft!=
a&&(this.horiz.scrollLeft=a);this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")};Eb.prototype.setScrollTop=function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a);this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")};Eb.prototype.zeroWidthHack=function(){this.horiz.style.height=this.vert.style.width=Na&&!dh?"12px":"18px";this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new Cb;this.disableVert=new Cb};Eb.prototype.enableZeroWidthBar=
function(a,b,d){function e(){var f=a.getBoundingClientRect();("vert"==d?document.elementFromPoint(f.right-1,(f.top+f.bottom)/2):document.elementFromPoint((f.right+f.left)/2,f.bottom-1))!=a?a.style.pointerEvents="none":b.set(1E3,e)}a.style.pointerEvents="auto";b.set(1E3,e)};Eb.prototype.clear=function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)};var Ic=function(){};Ic.prototype.update=function(){return{bottom:0,right:0}};Ic.prototype.setScrollLeft=function(){};
Ic.prototype.setScrollTop=function(){};Ic.prototype.clear=function(){};var Te={"native":Eb,"null":Ic},sg=0,bd=function(a,b,d){var e=a.display;this.viewport=b;this.visible=Jd(e,a.doc,b);this.editorIsHidden=!e.wrapper.offsetWidth;this.wrapperHeight=e.wrapper.clientHeight;this.wrapperWidth=e.wrapper.clientWidth;this.oldDisplayWidth=rb(a);this.force=d;this.dims=yd(a);this.events=[]};bd.prototype.signal=function(a,b){Ea(a,b)&&this.events.push(arguments)};bd.prototype.finish=function(){for(var a=0;a<this.events.length;a++)ea.apply(null,
this.events[a])};var dd=0,Ja=null;Z?Ja=-.53:gb?Ja=15:Vc?Ja=-.7:Rf&&(Ja=-1/3);var Ka=function(a,b){this.ranges=a;this.primIndex=b};Ka.prototype.primary=function(){return this.ranges[this.primIndex]};Ka.prototype.equals=function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b<this.ranges.length;b++){var d=this.ranges[b],e=a.ranges[b];if(!ha(d.anchor,e.anchor)||!ha(d.head,e.head))return!1}return!0};Ka.prototype.deepCopy=function(){for(var a=
[],b=0;b<this.ranges.length;b++)a[b]=new ba(L(this.ranges[b].anchor),L(this.ranges[b].head));return new Ka(a,this.primIndex)};Ka.prototype.somethingSelected=function(){for(var a=0;a<this.ranges.length;a++)if(!this.ranges[a].empty())return!0;return!1};Ka.prototype.contains=function(a,b){b||(b=a);for(var d=0;d<this.ranges.length;d++){var e=this.ranges[d];if(0<=S(b,e.from())&&0>=S(a,e.to()))return d}return-1};var ba=function(a,b){this.anchor=a;this.head=b};ba.prototype.from=function(){return X(this.anchor,
this.head)};ba.prototype.to=function(){return ma(this.anchor,this.head)};ba.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};tc.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var d=a,e=a+b;d<e;++d){var f=this.lines[d];this.height-=f.height;var c=f;c.parent=null;Fb(c);ra(f,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,d){this.height+=d;this.lines=this.lines.slice(0,
a).concat(b).concat(this.lines.slice(a));for(a=0;a<b.length;++a)b[a].parent=this},iterN:function(a,b,d){for(b=a+b;a<b;++a)if(d(this.lines[a]))return!0}};uc.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<f){var c=Math.min(b,f-a),h=e.height;e.removeInner(a,c);this.height-=h-e.height;f==c&&(this.children.splice(d--,1),e.parent=null);if(0==(b-=c))break;a=0}else a-=f}25>this.size-
b&&(1<this.children.length||!(this.children[0]instanceof tc))&&(a=[],this.collapse(a),this.children=[new tc(a)],this.children[0].parent=this)},collapse:function(a){for(var b=0;b<this.children.length;++b)this.children[b].collapse(a)},insertInner:function(a,b,d){this.size+=b.length;this.height+=d;for(var e=0;e<this.children.length;++e){var f=this.children[e],c=f.chunkSize();if(a<=c){f.insertInner(a,b,d);if(f.lines&&50<f.lines.length){for(b=a=f.lines.length%25+25;b<f.lines.length;)d=new tc(f.lines.slice(b,
b+=25)),f.height-=d.height,this.children.splice(++e,0,d),d.parent=this;f.lines=f.lines.slice(0,a);this.maybeSpill()}break}a-=c}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var d=a.children.splice(a.children.length-5,5);d=new uc(d);if(a.parent){a.size-=d.size;a.height-=d.height;var e=b(a.parent.children,a);a.parent.children.splice(e+1,0,d)}else e=new uc(a.children),e.parent=a,a.children=[e,d],a=e;d.parent=a.parent}while(10<a.children.length);a.parent.maybeSpill()}},iterN:function(a,
b,d){for(var e=0;e<this.children.length;++e){var f=this.children[e],c=f.chunkSize();if(a<c){c=Math.min(b,c-a);if(f.iterN(a,c,d))return!0;if(0==(b-=c))break;a=0}else a-=c}}};var vc=function(a,b,d){if(d)for(var e in d)d.hasOwnProperty(e)&&(this[e]=d[e]);this.doc=a;this.node=b};vc.prototype.clear=function(){var a=this.doc.cm,b=this.line.widgets,d=this.line,e=O(d);if(null!=e&&b){for(var f=0;f<b.length;++f)b[f]==this&&b.splice(f--,1);b.length||(d.widgets=null);var c=hc(this);U(d,Math.max(0,d.height-c));
a&&(Fa(a,function(){var b=-c;Ia(d)<(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&$c(a,b);lb(a,e,"widget")}),ra(a,"lineWidgetCleared",a,this,e))}};vc.prototype.changed=function(){var a=this,b=this.height,d=this.doc.cm,e=this.line;this.height=null;var f=hc(this)-b;f&&(U(e,e.height+f),d&&Fa(d,function(){d.curOp.forceUpdate=!0;Ia(e)<(d.curOp&&d.curOp.scrollTop||d.doc.scrollTop)&&$c(d,f);ra(d,"lineWidgetChanged",d,a,O(e))}))};Ma(vc);var wf=0,nb=function(a,b){this.lines=[];this.type=b;this.doc=a;this.id=
++wf};nb.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&zb(a);if(Ea(this,"clear")){var d=this.find();d&&ra(this,"clear",d.from,d.to)}for(var e=d=null,f=0;f<this.lines.length;++f){var c=this.lines[f],h=na(c.markedSpans,this);a&&!this.collapsed?lb(a,O(c),"text"):a&&(null!=h.to&&(e=O(c)),null!=h.from&&(d=O(c)));for(var k=c,r=void 0,m=c.markedSpans,l=h,g=0;g<m.length;++g)m[g]!=l&&(r||(r=[])).push(m[g]);k.markedSpans=r;null==h.from&&this.collapsed&&!$a(this.doc,
c)&&a&&U(c,ub(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(f=0;f<this.lines.length;++f)c=Ha(this.lines[f]),h=ya(c),h>a.display.maxLineLength&&(a.display.maxLine=c,a.display.maxLineLength=h,a.display.maxLineChanged=!0);null!=d&&a&&this.collapsed&&za(a,d,e+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&mf(a.doc));a&&ra(a,"markerCleared",a,this,d,e);b&&Ab(a);this.parent&&this.parent.clear()}};nb.prototype.find=function(a,b){null==
a&&"bookmark"==this.type&&(a=1);for(var d,e,f=0;f<this.lines.length;++f){var c=this.lines[f],h=na(c.markedSpans,this);if(null!=h.from&&(d=J(b?c:O(c),h.from),-1==a))return d;if(null!=h.to&&(e=J(b?c:O(c),h.to),1==a))return e}return d&&{from:d,to:e}};nb.prototype.changed=function(){var a=this,b=this.find(-1,!0),d=this,e=this.doc.cm;b&&e&&Fa(e,function(){var f=b.line,c=O(b.line);if(c=xd(e,c))ze(c),e.curOp.selectionChanged=e.curOp.forceUpdate=!0;e.curOp.updateMaxLine=!0;$a(d.doc,f)||null==d.height||(c=
d.height,d.height=null,(c=hc(d)-c)&&U(f,f.height+c));ra(e,"markerChanged",e,a)})};nb.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var d=this.doc.cm.curOp;d.maybeHiddenMarkers&&-1!=b(d.maybeHiddenMarkers,this)||(d.maybeUnhiddenMarkers||(d.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};nb.prototype.detachLine=function(a){this.lines.splice(b(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this))};
Ma(nb);var wc=function(a,b){this.markers=a;this.primary=b;for(b=0;b<a.length;++b)a[b].parent=this};wc.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();ra(this,"clear")}};wc.prototype.find=function(a,b){return this.primary.find(a,b)};Ma(wc);var gh=0,Aa=function(a,b,d,e,f){if(!(this instanceof Aa))return new Aa(a,b,d,e,f);null==d&&(d=0);uc.call(this,[new tc([new Nb("",null)])]);this.first=d;this.scrollTop=
this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.modeFrontier=this.highlightFrontier=d;d=J(d,0);this.sel=db(d);this.history=new ed(null);this.id=++gh;this.modeOption=b;this.lineSep=e;this.direction="rtl"==f?"rtl":"ltr";this.extend=!1;"string"==typeof a&&(a=this.splitLines(a));Sd(this,{from:d,to:d,text:a});sa(this,db(d),Ya)};Aa.prototype=y(uc.prototype,{constructor:Aa,iter:function(a,b,d){d?this.iterN(a-this.first,b-a,d):this.iterN(this.first,this.first+this.size,a)},insert:function(a,
b){for(var d=0,e=0;e<b.length;++e)d+=b[e].height;this.insertInner(a-this.first,b,d)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=N(this,this.first,this.first+this.size);return!1===a?b:b.join(a||this.lineSeparator())},setValue:qa(function(a){var b=J(this.first,0),d=this.first+this.size-1;Qb(this,{from:b,to:J(d,I(this,d).text.length),text:this.splitLines(a),origin:"setValue",full:!0},!0);this.cm&&mc(this.cm,0,0);sa(this,db(b),Ya)}),replaceRange:function(a,b,d,e){b=
R(this,b);d=d?R(this,d):b;Rb(this,a,b,d,e)},getRange:function(a,b,d){a=P(this,R(this,a),R(this,b));return!1===d?a:a.join(d||this.lineSeparator())},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){if(W(this,a))return I(this,a)},getLineNumber:function(a){return O(a)},getLineHandleVisualStart:function(a){"number"==typeof a&&(a=I(this,a));return Ha(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+
this.size-1},clipPos:function(a){return R(this,a)},getCursor:function(a){var b=this.sel.primary();return null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||"to"==a||!1===a?b.to():b.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:qa(function(a,b,d){a=R(this,"number"==typeof a?J(a,b||0):a);sa(this,db(a,null),d)}),setSelection:qa(function(a,b,d){var e=R(this,a);a=R(this,b||a);sa(this,db(e,a),d)}),extendSelection:qa(function(a,
b,d){gd(this,R(this,a),b&&R(this,b),d)}),extendSelections:qa(function(a,b){hf(this,Y(this,a),b)}),extendSelectionsBy:qa(function(a,b){a=z(this.sel.ranges,a);hf(this,Y(this,a),b)}),setSelections:qa(function(a,b,d){if(a.length){for(var e=[],f=0;f<a.length;f++)e[f]=new ba(R(this,a[f].anchor),R(this,a[f].head));null==b&&(b=Math.min(a.length-1,this.sel.primIndex));sa(this,Ta(e,b),d)}}),addSelection:qa(function(a,b,d){var e=this.sel.ranges.slice(0);e.push(new ba(R(this,a),R(this,b||a)));sa(this,Ta(e,e.length-
1),d)}),getSelection:function(a){for(var b=this.sel.ranges,d,e=0;e<b.length;e++){var f=P(this,b[e].from(),b[e].to());d=d?d.concat(f):f}return!1===a?d:d.join(a||this.lineSeparator())},getSelections:function(a){for(var b=[],d=this.sel.ranges,e=0;e<d.length;e++){var f=P(this,d[e].from(),d[e].to());!1!==a&&(f=f.join(a||this.lineSeparator()));b[e]=f}return b},replaceSelection:function(a,b,d){for(var e=[],f=0;f<this.sel.ranges.length;f++)e[f]=a;this.replaceSelections(e,b,d||"+input")},replaceSelections:qa(function(a,
b,d){for(var e=[],f=this.sel,c=0;c<f.ranges.length;c++){var h=f.ranges[c];e[c]={from:h.from(),to:h.to(),text:this.splitLines(a[c]),origin:d}}if(a=b&&"end"!=b){a=[];f=d=J(this.first,0);for(c=0;c<e.length;c++){var k=e[c];h=$e(k.from,d,f);var r=$e(mb(k),d,f);d=k.to;f=r;"around"==b?(k=this.sel.ranges[c],k=0>S(k.head,k.anchor),a[c]=new ba(k?r:h,k?h:r)):a[c]=new ba(h,h)}a=new Ka(a,this.sel.primIndex)}b=a;for(a=e.length-1;0<=a;a--)Qb(this,e[a]);b?jf(this,b):this.cm&&Lb(this.cm)}),undo:qa(function(){id(this,
"undo")}),redo:qa(function(){id(this,"redo")}),undoSelection:qa(function(){id(this,"undo",!0)}),redoSelection:qa(function(){id(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,d=0,e=0;e<a.done.length;e++)a.done[e].ranges||++b;for(e=0;e<a.undone.length;e++)a.undone[e].ranges||++d;return{undo:b,redo:d}},clearHistory:function(){this.history=new ed(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=
this.changeGeneration(!0)},changeGeneration:function(a){a&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null);return this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:Ob(this.history.done),undone:Ob(this.history.undone)}},setHistory:function(a){var b=this.history=new ed(this.history.maxGeneration);b.done=Ob(a.done.slice(0),null,!0);b.undone=Ob(a.undone.slice(0),null,!0)},setGutterMarker:qa(function(a,
b,d){return sc(this,a,"gutter",function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=d;!d&&H(e)&&(a.gutterMarkers=null);return!0})}),clearGutter:qa(function(a){var b=this;this.iter(function(d){d.gutterMarkers&&d.gutterMarkers[a]&&sc(b,d,"gutter",function(){d.gutterMarkers[a]=null;H(d.gutterMarkers)&&(d.gutterMarkers=null);return!0})})}),lineInfo:function(a){if("number"==typeof a){if(!W(this,a))return null;var b=a;a=I(this,a);if(!a)return null}else if(b=O(a),null==b)return null;return{line:b,
handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},addLineClass:qa(function(a,b,d){return sc(this,a,"gutter"==b?"gutter":"class",function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass";if(a[e]){if(c(d).test(a[e]))return!1;a[e]+=" "+d}else a[e]=d;return!0})}),removeLineClass:qa(function(a,b,d){return sc(this,a,"gutter"==b?"gutter":"class",function(a){var e="text"==b?"textClass":
"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass",f=a[e];if(f)if(null==d)a[e]=null;else{var h=f.match(c(d));if(!h)return!1;var k=h.index+h[0].length;a[e]=f.slice(0,h.index)+(h.index&&k!=f.length?" ":"")+f.slice(k)||null}else return!1;return!0})}),addLineWidget:qa(function(a,b,d){return Bg(this,a,b,d)}),removeLineWidget:function(a){a.clear()},markText:function(a,b,d){return Sb(this,R(this,a),R(this,b),d,d&&d.type||"range")},setBookmark:function(a,b){b={replacedWith:b&&(null==b.nodeType?
b.widget:b),insertLeft:b&&b.insertLeft,clearWhenEmpty:!1,shared:b&&b.shared,handleMouseEvents:b&&b.handleMouseEvents};a=R(this,a);return Sb(this,a,a,b,"bookmark")},findMarksAt:function(a){a=R(this,a);var b=[],d=I(this,a.line).markedSpans;if(d)for(var e=0;e<d.length;++e){var f=d[e];(null==f.from||f.from<=a.ch)&&(null==f.to||f.to>=a.ch)&&b.push(f.marker.parent||f.marker)}return b},findMarks:function(a,b,d){a=R(this,a);b=R(this,b);var e=[],f=a.line;this.iter(a.line,b.line+1,function(c){if(c=c.markedSpans)for(var h=
0;h<c.length;h++){var k=c[h];null!=k.to&&f==a.line&&a.ch>=k.to||null==k.from&&f!=a.line||null!=k.from&&f==b.line&&k.from>=b.ch||d&&!d(k.marker)||e.push(k.marker.parent||k.marker)}++f});return e},getAllMarks:function(){var a=[];this.iter(function(b){if(b=b.markedSpans)for(var d=0;d<b.length;++d)null!=b[d].from&&a.push(b[d].marker)});return a},posFromIndex:function(a){var b,d=this.first,e=this.lineSeparator().length;this.iter(function(f){f=f.text.length+e;if(f>a)return b=a,!0;a-=f;++d});return R(this,
J(d,b))},indexFromPos:function(a){a=R(this,a);var b=a.ch;if(a.line<this.first||0>a.ch)return 0;var d=this.lineSeparator().length;this.iter(this.first,a.line,function(a){b+=a.text.length+d});return b},copy:function(a){var b=new Aa(N(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel=this.sel;b.extend=!1;a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory()));return b},linkedDoc:function(a){a||
(a={});var b=this.first,d=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from);null!=a.to&&a.to<d&&(d=a.to);b=new Aa(N(this,b,d),a.mode||this.modeOption,b,this.lineSep,this.direction);a.sharedHist&&(b.history=this.history);(this.linked||(this.linked=[])).push({doc:b,sharedHist:a.sharedHist});b.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}];a=xf(this);for(d=0;d<a.length;d++){var e=a[d],f=e.find(),c=b.clipPos(f.from);f=b.clipPos(f.to);S(c,f)&&(c=Sb(b,c,f,e.primary,e.primary.type),e.markers.push(c),
c.parent=e)}return b},unlinkDoc:function(a){a instanceof fa&&(a=a.doc);if(this.linked)for(var b=0;b<this.linked.length;++b)if(this.linked[b].doc==a){this.linked.splice(b,1);a.unlinkDoc(this);Dg(xf(this));break}if(a.history==this.history){var d=[a.id];Bb(a,function(a){return d.push(a.id)},!0);a.history=new ed(null);a.history.done=Ob(this.history.done,d);a.history.undone=Ob(this.history.undone,d)}},iterLinkedDocs:function(a){Bb(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm},
splitLines:function(a){return this.lineSep?a.split(this.lineSep):fe(a)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:qa(function(a){"rtl"!=a&&(a="ltr");a!=this.direction&&(this.direction=a,this.iter(function(a){return a.order=null}),this.cm&&xg(this.cm))})});Aa.prototype.eachLine=Aa.prototype.iter;for(var zf=0,Qf=!1,ob={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",
37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Jc=0;10>Jc;Jc++)ob[Jc+48]=ob[Jc+96]=String(Jc);for(var pd=65;90>=pd;pd++)ob[pd]=String.fromCharCode(pd);
for(var Kc=1;12>=Kc;Kc++)ob[Kc+111]=ob[Kc+63235]="F"+Kc;var xc={basic:{Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},pcDefault:{"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo",
"Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection",
"Alt-U":"redoSelection",fallthrough:"basic"},emacsy:{"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},macDefault:{"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo",
"Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft",
"Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]}};xc["default"]=Na?xc.macDefault:xc.pcDefault;var yc={selectAll:of,singleSelection:function(a){return a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Ya)},killLine:function(a){return Ub(a,function(b){if(b.empty()){var d=I(a.doc,b.head.line).text.length;return b.head.ch==d&&b.head.line<a.lastLine()?{from:b.head,to:J(b.head.line+
1,0)}:{from:b.head,to:J(b.head.line,d)}}return{from:b.from(),to:b.to()}})},deleteLine:function(a){return Ub(a,function(b){return{from:J(b.from().line,0),to:R(a.doc,J(b.to().line+1,0))}})},delLineLeft:function(a){return Ub(a,function(a){return{from:J(a.from().line,0),to:a.from()}})},delWrappedLineLeft:function(a){return Ub(a,function(b){var d=a.charCoords(b.head,"div").top+5;return{from:a.coordsChar({left:0,top:d},"div"),to:b.from()}})},delWrappedLineRight:function(a){return Ub(a,function(b){var d=
a.charCoords(b.head,"div").top+5;d=a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:d},"div");return{from:b.from(),to:d}})},undo:function(a){return a.undo()},redo:function(a){return a.redo()},undoSelection:function(a){return a.undoSelection()},redoSelection:function(a){return a.redoSelection()},goDocStart:function(a){return a.extendSelection(J(a.firstLine(),0))},goDocEnd:function(a){return a.extendSelection(J(a.lastLine()))},goLineStart:function(a){return a.extendSelectionsBy(function(b){return Ff(a,
b.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(a){return a.extendSelectionsBy(function(b){return Gf(a,b.head)},{origin:"+move",bias:1})},goLineEnd:function(a){return a.extendSelectionsBy(function(b){b=b.head.line;var d=I(a.doc,b);var e=d;for(var f;f=xa(e,!1);)e=f.find(1,!0).line;e!=d&&(b=O(e));return Zd(!0,a,d,b,-1)},{origin:"+move",bias:-1})},goLineRight:function(a){return a.extendSelectionsBy(function(b){b=a.cursorCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+
100,top:b},"div")},Hc)},goLineLeft:function(a){return a.extendSelectionsBy(function(b){b=a.cursorCoords(b.head,"div").top+5;return a.coordsChar({left:0,top:b},"div")},Hc)},goLineLeftSmart:function(a){return a.extendSelectionsBy(function(b){var d=a.cursorCoords(b.head,"div").top+5;d=a.coordsChar({left:0,top:d},"div");return d.ch<a.getLine(d.line).search(/\S/)?Gf(a,b.head):d},Hc)},goLineUp:function(a){return a.moveV(-1,"line")},goLineDown:function(a){return a.moveV(1,"line")},goPageUp:function(a){return a.moveV(-1,
"page")},goPageDown:function(a){return a.moveV(1,"page")},goCharLeft:function(a){return a.moveH(-1,"char")},goCharRight:function(a){return a.moveH(1,"char")},goColumnLeft:function(a){return a.moveH(-1,"column")},goColumnRight:function(a){return a.moveH(1,"column")},goWordLeft:function(a){return a.moveH(-1,"word")},goGroupRight:function(a){return a.moveH(1,"group")},goGroupLeft:function(a){return a.moveH(-1,"group")},goWordRight:function(a){return a.moveH(1,"word")},delCharBefore:function(a){return a.deleteH(-1,
"char")},delCharAfter:function(a){return a.deleteH(1,"char")},delWordBefore:function(a){return a.deleteH(-1,"word")},delWordAfter:function(a){return a.deleteH(1,"word")},delGroupBefore:function(a){return a.deleteH(-1,"group")},delGroupAfter:function(a){return a.deleteH(1,"group")},indentAuto:function(a){return a.indentSelection("smart")},indentMore:function(a){return a.indentSelection("add")},indentLess:function(a){return a.indentSelection("subtract")},insertTab:function(a){return a.replaceSelection("\t")},
insertSoftTab:function(a){for(var b=[],e=a.listSelections(),f=a.options.tabSize,c=0;c<e.length;c++){var h=e[c].from();h=d(a.getLine(h.line),h.ch,f);b.push(r(f-h%f))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.execCommand("insertTab")},transposeChars:function(a){return Fa(a,function(){for(var b=a.listSelections(),d=[],e=0;e<b.length;e++)if(b[e].empty()){var f=b[e].head,c=I(a.doc,f.line).text;if(c)if(f.ch==c.length&&(f=new J(f.line,f.ch-1)),0<f.ch)f=
new J(f.line,f.ch+1),a.replaceRange(c.charAt(f.ch-1)+c.charAt(f.ch-2),J(f.line,f.ch-2),f,"+transpose");else if(f.line>a.doc.first){var h=I(a.doc,f.line-1).text;h&&(f=new J(f.line,1),a.replaceRange(c.charAt(0)+a.doc.lineSeparator()+h.charAt(h.length-1),J(f.line-1,h.length-1),f,"+transpose"))}d.push(new ba(f,f))}a.setSelections(d)})},newlineAndIndent:function(a){return Fa(a,function(){for(var b=a.listSelections(),d=b.length-1;0<=d;d--)a.replaceRange(a.doc.lineSeparator(),b[d].anchor,b[d].head,"+input");
b=a.listSelections();for(d=0;d<b.length;d++)a.indentLine(b[d].from().line,null,!0);Lb(a)})},openLine:function(a){return a.replaceSelection("\n","start")},toggleOverwrite:function(a){return a.toggleOverwrite()}},Lg=new Cb,$d=null,ae=function(a,b,d){this.time=a;this.pos=b;this.button=d};ae.prototype.compare=function(a,b,d){return this.time+400>a&&0==S(b,this.pos)&&d==this.button};var Bc,Ac,Vb={toString:function(){return"CodeMirror.Init"}},Pf={},nd={};fa.defaults=Pf;fa.optionHandlers=nd;var de=[];fa.defineInitHook=
function(a){return de.push(a)};var Ga=null,ca=function(a){this.cm=a;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new Cb;this.composing=null;this.gracePeriod=!1;this.readDOMTimeout=null};ca.prototype.init=function(a){function b(a){if(!ja(f,a)){if(f.somethingSelected())Ga={lineWise:!1,text:f.getSelections()},"cut"==a.type&&f.replaceSelection("",null,"cut");else if(f.options.lineWiseCopyCut){var b=Uf(f);Ga={lineWise:!0,text:b.text};"cut"==a.type&&
f.operation(function(){f.setSelections(b.ranges,0,Ya);f.replaceSelection("",null,"cut")})}else return;if(a.clipboardData){a.clipboardData.clearData();var d=Ga.text.join("\n");a.clipboardData.setData("Text",d);if(a.clipboardData.getData("Text")==d){a.preventDefault();return}}var h=Wf();a=h.firstChild;f.display.lineSpace.insertBefore(h,f.display.lineSpace.firstChild);a.value=Ga.text.join("\n");var k=document.activeElement;Gc(a);setTimeout(function(){f.display.lineSpace.removeChild(h);k.focus();k==c&&
e.showPrimarySelection()},50)}}var d=this,e=this,f=e.cm,c=e.div=a.lineDiv;Vf(c,f.options.spellcheck);V(c,"paste",function(a){ja(f,a)||Tf(a,f)||11>=da&&setTimeout(pa(f,function(){return d.updateFromDOM()}),20)});V(c,"compositionstart",function(a){d.composing={data:a.data,done:!1}});V(c,"compositionupdate",function(a){d.composing||(d.composing={data:a.data,done:!1})});V(c,"compositionend",function(a){d.composing&&(a.data!=d.composing.data&&d.readFromDOMSoon(),d.composing.done=!0)});V(c,"touchstart",
function(){return e.forceCompositionEnd()});V(c,"input",function(){d.composing||d.readFromDOMSoon()});V(c,"copy",b);V(c,"cut",b)};ca.prototype.prepareSelection=function(){var a=Ie(this.cm,!1);a.focus=this.cm.state.focused;return a};ca.prototype.showSelection=function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))};ca.prototype.showPrimarySelection=function(){var a=window.getSelection(),b=this.cm,d=b.doc.sel.primary(),e=d.from();d=d.to();
if(b.display.viewTo==b.display.viewFrom||e.line>=b.display.viewTo||d.line<b.display.viewFrom)a.removeAllRanges();else{var f=od(b,a.anchorNode,a.anchorOffset),c=od(b,a.focusNode,a.focusOffset);if(!f||f.bad||!c||c.bad||0!=S(X(f,c),e)||0!=S(ma(f,c),d))if(f=b.display.view,e=e.line>=b.display.viewFrom&&Yf(b,e)||{node:f[0].measure.map[2],offset:0},d=d.line<b.display.viewTo&&Yf(b,d),d||(d=f[f.length-1].measure,d=d.maps?d.maps[d.maps.length-1]:d.map,d={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}),
e&&d){f=a.rangeCount&&a.getRangeAt(0);try{var h=ec(e.node,e.offset,d.offset,d.node)}catch(kh){}h&&(!gb&&b.state.focused?(a.collapse(e.node,e.offset),h.collapsed||(a.removeAllRanges(),a.addRange(h))):(a.removeAllRanges(),a.addRange(h)),f&&null==a.anchorNode?a.addRange(f):gb&&this.startGracePeriod());this.rememberSelection()}else a.removeAllRanges()}};ca.prototype.startGracePeriod=function(){var a=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){a.gracePeriod=!1;a.selectionChanged()&&
a.cm.operation(function(){return a.cm.curOp.selectionChanged=!0})},20)};ca.prototype.showMultipleSelections=function(a){q(this.cm.display.cursorDiv,a.cursors);q(this.cm.display.selectionDiv,a.selection)};ca.prototype.rememberSelection=function(){var a=window.getSelection();this.lastAnchorNode=a.anchorNode;this.lastAnchorOffset=a.anchorOffset;this.lastFocusNode=a.focusNode;this.lastFocusOffset=a.focusOffset};ca.prototype.selectionInEditor=function(){var a=window.getSelection();if(!a.rangeCount)return!1;
a=a.getRangeAt(0).commonAncestorContainer;return l(this.div,a)};ca.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())};ca.prototype.blur=function(){this.div.blur()};ca.prototype.getField=function(){return this.div};ca.prototype.supportsTouch=function(){return!0};ca.prototype.receivedFocus=function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}
var b=this;this.selectionInEditor()?this.pollSelection():Fa(this.cm,function(){return b.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,a)};ca.prototype.selectionChanged=function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset};ca.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var a=
window.getSelection(),b=this.cm;if(Wc&&Vc&&this.cm.options.gutters.length&&$g(a.anchorNode))this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();else if(!this.composing){this.rememberSelection();var d=od(b,a.anchorNode,a.anchorOffset),e=od(b,a.focusNode,a.focusOffset);d&&e&&Fa(b,function(){sa(b.doc,db(d,e),Ya);if(d.bad||e.bad)b.curOp.selectionChanged=!0})}}};ca.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),
this.readDOMTimeout=null);var a=this.cm,b=a.display,d=a.doc.sel.primary(),e=d.from(),f=d.to();0==e.ch&&e.line>a.firstLine()&&(e=J(e.line-1,I(a.doc,e.line-1).length));f.ch==I(a.doc,f.line).text.length&&f.line<a.lastLine()&&(f=J(f.line+1,0));if(e.line<b.viewFrom||f.line>b.viewTo-1)return!1;var c;e.line==b.viewFrom||0==(c=sb(a,e.line))?(d=O(b.view[0].line),c=b.view[0].node):(d=O(b.view[c].line),c=b.view[c-1].node.nextSibling);var h=sb(a,f.line);h==b.view.length-1?(f=b.viewTo-1,b=b.lineDiv.lastChild):
(f=O(b.view[h+1].line)-1,b=b.view[h+1].node.previousSibling);if(!c)return!1;b=a.doc.splitLines(ah(a,c,b,d,f));for(c=P(a.doc,J(d,0),J(f,I(a.doc,f).text.length));1<b.length&&1<c.length;)if(x(b)==x(c))b.pop(),c.pop(),f--;else if(b[0]==c[0])b.shift(),c.shift(),d++;else break;var k=0;h=0;for(var r=b[0],m=c[0],l=Math.min(r.length,m.length);k<l&&r.charCodeAt(k)==m.charCodeAt(k);)++k;r=x(b);m=x(c);for(l=Math.min(r.length-(1==b.length?k:0),m.length-(1==c.length?k:0));h<l&&r.charCodeAt(r.length-h-1)==m.charCodeAt(m.length-
h-1);)++h;if(1==b.length&&1==c.length&&d==e.line)for(;k&&k>e.ch&&r.charCodeAt(r.length-h-1)==m.charCodeAt(m.length-h-1);)k--,h++;b[b.length-1]=r.slice(0,r.length-h).replace(/^\u200b+/,"");b[0]=b[0].slice(k).replace(/\u200b+$/,"");e=J(d,k);d=J(f,c.length?x(c).length-h:0);if(1<b.length||b[0]||S(e,d))return Rb(a.doc,b,e,d,"+input"),!0};ca.prototype.ensurePolled=function(){this.forceCompositionEnd()};ca.prototype.reset=function(){this.forceCompositionEnd()};ca.prototype.forceCompositionEnd=function(){this.composing&&
(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())};ca.prototype.readFromDOMSoon=function(){var a=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){a.readDOMTimeout=null;if(a.composing)if(a.composing.done)a.composing=null;else return;a.updateFromDOM()},80))};ca.prototype.updateFromDOM=function(){var a=this;!this.cm.isReadOnly()&&this.pollContent()||Fa(this.cm,function(){return za(a.cm)})};ca.prototype.setUneditable=
function(a){a.contentEditable="false"};ca.prototype.onKeyPress=function(a){0!=a.charCode&&(a.preventDefault(),this.cm.isReadOnly()||pa(this.cm,ee)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0))};ca.prototype.readOnlyChanged=function(a){this.div.contentEditable=String("nocursor"!=a)};ca.prototype.onContextMenu=function(){};ca.prototype.resetPosition=function(){};ca.prototype.needsContentAttribute=!0;var la=function(a){this.cm=a;this.prevInput="";this.pollingFast=!1;this.polling=
new Cb;this.hasSelection=!1;this.composing=null};la.prototype.init=function(a){function b(a){if(!ja(f,a)){if(f.somethingSelected())Ga={lineWise:!1,text:f.getSelections()};else if(f.options.lineWiseCopyCut){var b=Uf(f);Ga={lineWise:!0,text:b.text};"cut"==a.type?f.setSelections(b.ranges,null,Ya):(e.prevInput="",h.value=b.text.join("\n"),Gc(h))}else return;"cut"==a.type&&(f.state.cutIncoming=!0)}}var d=this,e=this,f=this.cm,c=this.wrapper=Wf(),h=this.textarea=c.firstChild;a.wrapper.insertBefore(c,a.wrapper.firstChild);
Ec&&(h.style.width="0px");V(h,"input",function(){Z&&9<=da&&d.hasSelection&&(d.hasSelection=null);e.poll()});V(h,"paste",function(a){ja(f,a)||Tf(a,f)||(f.state.pasteIncoming=!0,e.fastPoll())});V(h,"cut",b);V(h,"copy",b);V(a.scroller,"paste",function(b){cb(a,b)||ja(f,b)||(f.state.pasteIncoming=!0,e.focus())});V(a.lineSpace,"selectstart",function(b){cb(a,b)||oa(b)});V(h,"compositionstart",function(){var a=f.getCursor("from");e.composing&&e.composing.range.clear();e.composing={start:a,range:f.markText(a,
f.getCursor("to"),{className:"CodeMirror-composing"})}});V(h,"compositionend",function(){e.composing&&(e.poll(),e.composing.range.clear(),e.composing=null)})};la.prototype.prepareSelection=function(){var a=this.cm,b=a.display,d=a.doc,e=Ie(a);if(a.options.moveInputWithCursor){a=Ra(a,d.sel.primary().head,"div");d=b.wrapper.getBoundingClientRect();var f=b.lineDiv.getBoundingClientRect();e.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+f.top-d.top));e.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-
10,a.left+f.left-d.left))}return e};la.prototype.showSelection=function(a){var b=this.cm.display;q(b.cursorDiv,a.cursors);q(b.selectionDiv,a.selection);null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")};la.prototype.reset=function(a){if(!this.contextMenuPending&&!this.composing){var b=this.cm;b.somethingSelected()?(this.prevInput="",a=b.getSelection(),this.textarea.value=a,b.state.focused&&Gc(this.textarea),Z&&9<=da&&(this.hasSelection=a)):a||(this.prevInput=
this.textarea.value="",Z&&9<=da&&(this.hasSelection=null))}};la.prototype.getField=function(){return this.textarea};la.prototype.supportsTouch=function(){return!1};la.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Yb||v()!=this.textarea))try{this.textarea.focus()}catch(w){}};la.prototype.blur=function(){this.textarea.blur()};la.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0};la.prototype.receivedFocus=function(){this.slowPoll()};la.prototype.slowPoll=
function(){var a=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){a.poll();a.cm.state.focused&&a.slowPoll()})};la.prototype.fastPoll=function(){function a(){d.poll()||b?(d.pollingFast=!1,d.slowPoll()):(b=!0,d.polling.set(60,a))}var b=!1,d=this;d.pollingFast=!0;d.polling.set(20,a)};la.prototype.poll=function(){var a=this,b=this.cm,d=this.textarea,e=this.prevInput;if(this.contextMenuPending||!b.state.focused||fh(d)&&!e&&!this.composing||b.isReadOnly()||b.options.disableInput||
b.state.keySeq)return!1;var f=d.value;if(f==e&&!b.somethingSelected())return!1;if(Z&&9<=da&&this.hasSelection===f||Na&&/[\uf700-\uf7ff]/.test(f))return b.display.input.reset(),!1;if(b.doc.sel==b.display.selForContextMenu){var c=f.charCodeAt(0);8203!=c||e||(e="\u200b");if(8666==c)return this.reset(),this.cm.execCommand("undo")}var h=0;for(c=Math.min(e.length,f.length);h<c&&e.charCodeAt(h)==f.charCodeAt(h);)++h;Fa(b,function(){ee(b,f.slice(h),e.length-h,null,a.composing?"*compose":null);1E3<f.length||
-1<f.indexOf("\n")?d.value=a.prevInput="":a.prevInput=f;a.composing&&(a.composing.range.clear(),a.composing.range=b.markText(a.composing.start,b.getCursor("to"),{className:"CodeMirror-composing"}))});return!0};la.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)};la.prototype.onKeyPress=function(){Z&&9<=da&&(this.hasSelection=null);this.fastPoll()};la.prototype.onContextMenu=function(a){function b(){if(null!=h.selectionStart){var a=f.somethingSelected(),b="\u200b"+
(a?h.value:"");h.value="\u21da";h.value=b;e.prevInput=a?"":"\u200b";h.selectionStart=1;h.selectionEnd=b.length;c.selForContextMenu=f.doc.sel}}function d(){e.contextMenuPending=!1;e.wrapper.style.cssText=l;h.style.cssText=m;Z&&9>da&&c.scrollbars.setScrollTop(c.scroller.scrollTop=r);if(null!=h.selectionStart){(!Z||Z&&9>da)&&b();var a=0,d=function(){c.selForContextMenu==f.doc.sel&&0==h.selectionStart&&0<h.selectionEnd&&"\u200b"==e.prevInput?pa(f,of)(f):10>a++?c.detectingSelectAll=setTimeout(d,500):(c.selForContextMenu=
null,c.input.reset())};c.detectingSelectAll=setTimeout(d,200)}}var e=this,f=e.cm,c=f.display,h=e.textarea,k=wb(f,a),r=c.scroller.scrollTop;if(k&&!Sa){f.options.resetSelectionOnContextMenu&&-1==f.doc.sel.contains(k)&&pa(f,sa)(f.doc,db(k),Ya);var m=h.style.cssText,l=e.wrapper.style.cssText;e.wrapper.style.cssText="position: absolute";k=e.wrapper.getBoundingClientRect();h.style.cssText="position: absolute; width: 30px; height: 30px;\n      top: "+(a.clientY-k.top-5)+"px; left: "+(a.clientX-k.left-5)+
"px;\n      z-index: 1000; background: "+(Z?"rgba(255, 255, 255, .05)":"transparent")+";\n      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(ta)var g=window.scrollY;c.input.focus();ta&&window.scrollTo(null,g);c.input.reset();f.somethingSelected()||(h.value=e.prevInput=" ");e.contextMenuPending=!0;c.selForContextMenu=f.doc.sel;clearTimeout(c.detectingSelectAll);Z&&9<=da&&b();if(be){qb(a);var t=function(){ia(window,"mouseup",t);setTimeout(d,
20)};V(window,"mouseup",t)}else setTimeout(d,50)}};la.prototype.readOnlyChanged=function(a){a||this.reset();this.textarea.disabled="nocursor"==a};la.prototype.setUneditable=function(){};la.prototype.needsContentAttribute=!1;(function(a){function b(b,e,f,c){a.defaults[b]=e;f&&(d[b]=c?function(a,b,d){d!=Vb&&f(a,b,d)}:f)}var d=a.optionHandlers;a.defineOption=b;a.Init=Vb;b("value","",function(a,b){return a.setValue(b)},!0);b("mode",null,function(a,b){a.doc.modeOption=b;Rd(a)},!0);b("indentUnit",2,Rd,
!0);b("indentWithTabs",!1);b("smartIndent",!0);b("tabSize",4,function(a){qc(a);jc(a);za(a)},!0);b("lineSeparator",null,function(a,b){if(a.doc.lineSep=b){var d=[],e=a.doc.first;a.doc.iter(function(a){for(var f=0;;){var c=a.text.indexOf(b,f);if(-1==c)break;f=c+b.length;d.push(J(e,c))}e++});for(var f=d.length-1;0<=f;f--)Rb(a.doc,b,d[f],J(d[f].line,d[f].ch+b.length))}});b("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,d){a.state.specialChars=new RegExp(b.source+
(b.test("\t")?"":"|\t"),"g");d!=Vb&&a.refresh()});b("specialCharPlaceholder",kg,function(a){return a.refresh()},!0);b("electricChars",!0);b("inputStyle",Yb?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor");},!0);b("spellcheck",!1,function(a,b){return a.getInputField().spellcheck=b},!0);b("rtlMoveVisually",!eh);b("wholeLineUpdateBefore",!0);b("theme","default",function(a){Of(a);Cc(a)},!0);b("keyMap","default",function(a,b,d){b=jd(b);(d=d!=
Vb&&jd(d))&&d.detach&&d.detach(a,b);b.attach&&b.attach(a,d||null)});b("extraKeys",null);b("configureMouse",null);b("lineWrapping",!1,Yg,!0);b("gutters",[],function(a){Pd(a.options);Cc(a)},!0);b("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?Fd(a.display)+"px":"0";a.refresh()},!0);b("coverGutterNextToScrollbar",!1,function(a){return Mb(a)},!0);b("scrollbarStyle","native",function(a){Se(a);Mb(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},
!0);b("lineNumbers",!1,function(a){Pd(a.options);Cc(a)},!0);b("firstLineNumber",1,Cc,!0);b("lineNumberFormatter",function(a){return a},Cc,!0);b("showCursorWhenSelecting",!1,kc,!0);b("resetSelectionOnContextMenu",!0);b("lineWiseCopyCut",!0);b("pasteLinesPerSelection",!0);b("readOnly",!1,function(a,b){"nocursor"==b&&(lc(a),a.display.input.blur());a.display.input.readOnlyChanged(b)});b("disableInput",!1,function(a,b){b||a.display.input.reset()},!0);b("dragDrop",!0,Xg);b("allowDropFileTypes",null);b("cursorBlinkRate",
530);b("cursorScrollMargin",0);b("cursorHeight",1,kc,!0);b("singleCursorHeightPerLine",!0,kc,!0);b("workTime",100);b("workDelay",100);b("flattenSpans",!0,qc,!0);b("addModeClass",!1,qc,!0);b("pollInterval",100);b("undoDepth",200,function(a,b){return a.doc.history.undoDepth=b});b("historyEventDelay",1250);b("viewportMargin",10,function(a){return a.refresh()},!0);b("maxHighlightLength",1E4,qc,!0);b("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()});b("tabindex",null,function(a,
b){return a.display.input.getField().tabIndex=b||""});b("autofocus",null);b("direction","ltr",function(a,b){return a.doc.setDirection(b)},!0)})(fa);(function(a){var d=a.optionHandlers,e=a.helpers={};a.prototype={constructor:a,focus:function(){window.focus();this.display.input.focus()},setOption:function(a,b){var e=this.options,f=e[a];if(e[a]!=b||"mode"==a)e[a]=b,d.hasOwnProperty(a)&&pa(this,d[a])(this,b,f),ea(this,"optionChange",this,a)},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},
addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](jd(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,d=0;d<b.length;++d)if(b[d]==a||b[d].name==a)return b.splice(d,1),!0},addOverlay:va(function(b,d){var e=b.token?b:a.getMode(this.options,b);if(e.startState)throw Error("Overlays may not be stateful.");A(this.state.overlays,{mode:e,modeSpec:b,opaque:d&&d.opaque,priority:d&&d.priority||0},function(a){return a.priority});this.state.modeGen++;za(this)}),removeOverlay:va(function(a){for(var b=
this.state.overlays,d=0;d<b.length;++d){var e=b[d].modeSpec;if(e==a||"string"==typeof a&&e.name==a){b.splice(d,1);this.state.modeGen++;za(this);break}}}),indentLine:va(function(a,b,d){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");W(this.doc,a)&&Dc(this,a,b,d)}),indentSelection:va(function(a){for(var b=this.doc.sel.ranges,d=-1,e=0;e<b.length;e++){var f=b[e];if(f.empty())f.head.line>d&&(Dc(this,f.head.line,a,!0),d=f.head.line,e==this.doc.sel.primIndex&&
Lb(this));else{var c=f.from();f=f.to();var h=Math.max(d,c.line);d=Math.min(this.lastLine(),f.line-(f.ch?0:1))+1;for(f=h;f<d;++f)Dc(this,f,a);f=this.doc.sel.ranges;0==c.ch&&b.length==f.length&&0<f[e].from().ch&&Vd(this.doc,e,new ba(c,f[e].to()),Ya)}}}),getTokenAt:function(a,b){return je(this,a,b)},getLineTokens:function(a,b){return je(this,J(a),b,!0)},getTokenTypeAt:function(a){a=R(this.doc,a);var b=jb(this,I(this.doc,a.line)),d=0,e=(b.length-1)/2;a=a.ch;if(0==a)b=b[2];else for(;;){var f=d+e>>1;if((f?
b[2*f-1]:0)>=a)e=f;else if(b[2*f+1]<a)d=f+1;else{b=b[2*f+2];break}}d=b?b.indexOf("overlay "):-1;return 0>d?b:0==d?null:b.slice(0,d-1)},getModeAt:function(b){var d=this.doc.mode;return d.innerMode?a.innerMode(d,this.getTokenAt(b).state).mode:d},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,d){var f=[];if(!e.hasOwnProperty(d))return f;var c=e[d];a=this.getModeAt(a);if("string"==typeof a[d])c[a[d]]&&f.push(c[a[d]]);else if(a[d])for(var h=0;h<a[d].length;h++){var k=c[a[d][h]];
k&&f.push(k)}else a.helperType&&c[a.helperType]?f.push(c[a.helperType]):c[a.name]&&f.push(c[a.name]);for(d=0;d<c._global.length;d++)h=c._global[d],h.pred(a,this)&&-1==b(f,h.val)&&f.push(h.val);return f},getStateAfter:function(a,b){var d=this.doc;a=Math.max(d.first,Math.min(null==a?d.first+d.size-1:a,d.first+d.size-1));return Va(this,a+1,b).state},cursorCoords:function(a,b){var d=this.doc.sel.primary();a=null==a?d.head:"object"==typeof a?R(this.doc,a):a?d.from():d.to();return Ra(this,a,b||"page")},
charCoords:function(a,b){return Bd(this,R(this.doc,a),b||"page")},coordsChar:function(a,b){a=De(this,a,b||"page");return Dd(this,a.left,a.top)},lineAtHeight:function(a,b){a=De(this,{top:a,left:0},b||"page").top;return T(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b,d){var e=!1;if("number"==typeof a){var f=this.doc.first+this.doc.size-1;a<this.doc.first?a=this.doc.first:a>f&&(a=f,e=!0);a=I(this.doc,a)}return Xc(this,a,{top:0,left:0},b||"page",d||e).top+(e?this.doc.height-Ia(a):0)},
defaultTextHeight:function(){return ub(this.display)},defaultCharWidth:function(){return ic(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,d,e,f){var c=this.display;a=Ra(this,R(this.doc,a));var h=a.bottom,k=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);c.sizer.appendChild(b);if("over"==e)h=a.top;else if("above"==e||"near"==e){var r=Math.max(c.wrapper.clientHeight,
this.doc.height),m=Math.max(c.sizer.clientWidth,c.lineSpace.clientWidth);("above"==e||a.bottom+b.offsetHeight>r)&&a.top>b.offsetHeight?h=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=r&&(h=a.bottom);k+b.offsetWidth>m&&(k=m-b.offsetWidth)}b.style.top=h+"px";b.style.left=b.style.right="";"right"==f?(k=c.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==f?k=0:"middle"==f&&(k=(c.sizer.clientWidth-b.offsetWidth)/2),b.style.left=k+"px");d&&(a=Ld(this,{left:k,top:h,right:k+b.offsetWidth,bottom:h+
b.offsetHeight}),null!=a.scrollTop&&nc(this,a.scrollTop),null!=a.scrollLeft&&yb(this,a.scrollLeft))},triggerOnKeyDown:va(If),triggerOnKeyPress:va(Kf),triggerOnKeyUp:Jf,triggerOnMouseDown:va(Lf),execCommand:function(a){if(yc.hasOwnProperty(a))return yc[a].call(null,this)},triggerElectric:va(function(a){Sf(this,a)}),findPosH:function(a,b,d,e){var f=1;0>b&&(f=-1,b=-b);a=R(this.doc,a);for(var c=0;c<b&&(a=ge(this.doc,a,f,d,e),!a.hitSide);++c);return a},moveH:va(function(a,b){var d=this;this.extendSelectionsBy(function(e){return d.display.shift||
d.doc.extend||e.empty()?ge(d.doc,e.head,a,b,d.options.rtlMoveVisually):0>a?e.from():e.to()},Hc)}),deleteH:va(function(a,b){var d=this.doc;this.doc.sel.somethingSelected()?d.replaceSelection("",null,"+delete"):Ub(this,function(e){var f=ge(d,e.head,a,b,!1);return 0>a?{from:f,to:e.head}:{from:e.head,to:f}})}),findPosV:function(a,b,d,e){var f=1;0>b&&(f=-1,b=-b);var c=R(this.doc,a);for(a=0;a<b&&(c=Ra(this,c,"div"),null==e?e=c.left:c.left=e,c=Xf(this,c,f,d),!c.hitSide);++a);return c},moveV:va(function(a,
b){var d=this,e=this.doc,f=[],c=!this.display.shift&&!e.extend&&e.sel.somethingSelected();e.extendSelectionsBy(function(h){if(c)return 0>a?h.from():h.to();var k=Ra(d,h.head,"div");null!=h.goalColumn&&(k.left=h.goalColumn);f.push(k.left);var r=Xf(d,k,a,b);"page"==b&&h==e.sel.primary()&&$c(d,Bd(d,r,"div").top-k.top);return r},Hc);if(f.length)for(var h=0;h<e.sel.ranges.length;h++)e.sel.ranges[h].goalColumn=f[h]}),findWordAt:function(a){var b=I(this.doc,a.line).text,d=a.ch,e=a.ch;if(b){var f=this.getHelper(a,
"wordChars");"before"!=a.sticky&&e!=b.length||!d?++e:--d;var c=b.charAt(d);for(c=G(c,f)?function(a){return G(a,f)}:/\s/.test(c)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!G(a)};0<d&&c(b.charAt(d-1));)--d;for(;e<b.length&&c(b.charAt(e));)++e}return new ba(J(a.line,d),J(a.line,e))},toggleOverwrite:function(a){if(null==a||a!=this.state.overwrite)(this.state.overwrite=!this.state.overwrite)?t(this.display.cursorDiv,"CodeMirror-overwrite"):xb(this.display.cursorDiv,"CodeMirror-overwrite"),
ea(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==v()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:va(function(a,b){mc(this,a,b)}),getScrollInfo:function(){var a=this.display.scroller;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-Xa(this)-this.display.barHeight,width:a.scrollWidth-Xa(this)-this.display.barWidth,clientHeight:wd(this),clientWidth:rb(this)}},scrollIntoView:va(function(a,
b){null==a?(a={from:this.doc.sel.primary().head,to:null},null==b&&(b=this.options.cursorScrollMargin)):"number"==typeof a?a={from:J(a,0),to:null}:null==a.from&&(a={from:a,to:null});a.to||(a.to=a.from);a.margin=b||0;null!=a.from.line?(ad(this),this.curOp.scrollToPos=a):Pe(this,a.from,a.to,a.margin)}),setSize:va(function(a,b){var d=this,e=function(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a};null!=a&&(this.display.wrapper.style.width=e(a));null!=b&&(this.display.wrapper.style.height=
e(b));this.options.lineWrapping&&Ae(this);var f=this.display.viewFrom;this.doc.iter(f,this.display.viewTo,function(a){if(a.widgets)for(var b=0;b<a.widgets.length;b++)if(a.widgets[b].noHScroll){lb(d,f,"widget");break}++f});this.curOp.forceUpdate=!0;ea(this,"refresh",this)}),operation:function(a){return Fa(this,a)},startOperation:function(){return zb(this)},endOperation:function(){return Ab(this)},refresh:va(function(){var a=this.display.cachedTextHeight;za(this);this.curOp.forceUpdate=!0;jc(this);
mc(this,this.doc.scrollLeft,this.doc.scrollTop);Kd(this);(null==a||.5<Math.abs(a-ub(this.display)))&&Gd(this);ea(this,"refresh",this)}),swapDoc:va(function(a){var b=this.doc;b.cm=null;bf(this,a);jc(this);this.display.input.reset();mc(this,a.scrollLeft,a.scrollTop);this.curOp.forceScroll=!0;ra(this,"swapDoc",this,b);return b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},
getGutterElement:function(){return this.display.gutters}};Ma(a);a.registerHelper=function(b,d,f){e.hasOwnProperty(b)||(e[b]=a[b]={_global:[]});e[b][d]=f};a.registerGlobalHelper=function(b,d,f,c){a.registerHelper(b,d,c);e[b]._global.push({pred:f,val:c})}})(fa);var hh="iter insert remove copy getEditor constructor".split(" "),Lc;for(Lc in Aa.prototype)Aa.prototype.hasOwnProperty(Lc)&&0>b(hh,Lc)&&(fa.prototype[Lc]=function(a){return function(){return a.apply(this.doc,arguments)}}(Aa.prototype[Lc]));
Ma(Aa);fa.inputStyles={textarea:la,contenteditable:ca};fa.defineMode=function(a){fa.defaults.mode||"null"==a||(fa.defaults.mode=a);Rc.apply(this,arguments)};fa.defineMIME=function(a,b){Hb[a]=b};fa.defineMode("null",function(){return{token:function(a){return a.skipToEnd()}}});fa.defineMIME("text/plain","null");fa.defineExtension=function(a,b){fa.prototype[a]=b};fa.defineDocExtension=function(a,b){Aa.prototype[a]=b};fa.fromTextArea=function(a,b){function d(){a.value=r.getValue()}b=b?e(b):{};b.value=
a.value;!b.tabindex&&a.tabIndex&&(b.tabindex=a.tabIndex);!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder);if(null==b.autofocus){var f=v();b.autofocus=f==a||null!=a.getAttribute("autofocus")&&f==document.body}if(a.form&&(V(a.form,"submit",d),!b.leaveSubmitMethodAlone)){var c=a.form;var h=c.submit;try{var k=c.submit=function(){d();c.submit=h;c.submit();c.submit=k}}catch(he){}}b.finishInit=function(b){b.save=d;b.getTextArea=function(){return a};b.toTextArea=function(){b.toTextArea=isNaN;
d();a.parentNode.removeChild(b.getWrapperElement());a.style.display="";a.form&&(ia(a.form,"submit",d),"function"==typeof a.form.submit&&(a.form.submit=h))}};a.style.display="none";var r=fa(function(b){return a.parentNode.insertBefore(b,a.nextSibling)},b);return r};(function(a){a.off=ia;a.on=V;a.wheelEventPixels=wg;a.Doc=Aa;a.splitLines=fe;a.countColumn=d;a.findColumn=h;a.isWordChar=E;a.Pass=ld;a.signal=ea;a.Line=Nb;a.changeEnd=mb;a.scrollbarModel=Te;a.Pos=J;a.cmpPos=S;a.modes=sd;a.mimeModes=Hb;a.resolveMode=
bb;a.getMode=Oa;a.modeExtensions=Ib;a.extendMode=ua;a.copyState=Pa;a.startState=bc;a.innerMode=Jb;a.commands=yc;a.keyMap=xc;a.keyName=Ef;a.isModifierKey=Bf;a.lookupKey=Tb;a.normalizeKeyMap=Ig;a.StringStream=ka;a.SharedTextMarker=wc;a.TextMarker=nb;a.LineWidget=vc;a.e_preventDefault=oa;a.e_stopPropagation=Qc;a.e_stop=qb;a.addClass=t;a.contains=l;a.rmClass=xb;a.keyNames=ob})(fa);fa.version="5.31.0";return fa})},function(p,g,c){c.d(g,"b",function(){return u});var u;(function(c){c[c.UINT8=0]="UINT8";
c[c.UINT16=1]="UINT16";c[c.UINT32=2]="UINT32";c[c.UINT64=3]="UINT64";c[c.FLOAT32=4]="FLOAT32"})(u||(u={}));p=[];g.a=p;p[u.UINT8]=1;p[u.UINT16]=2;p[u.UINT32]=4;p[u.UINT64]=8;p[u.FLOAT32]=4},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
f):a.__proto__=f)}c.d(g,"a",function(){return l});g.c=function(a,f){v.set(a,f)};g.b=function(a){return v.get(a)};p=c(0);var n=c(111),q=c(16),a=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}(),f=new Float32Array(4),l=function(c){function m(a){if(!(this instanceof m))throw new TypeError("Cannot call a class as a function");
var e=(m.__proto__||Object.getPrototypeOf(m)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.gl=a;e.countingBuffer=e.registerDisposer(Object(n.d)(e.gl));return e}u(m,c);a(m,[{key:"setPartIndex",value:function(a,e){for(var d=[],b=1;b<arguments.length;++b)d[b-1]=arguments[b];b="\nvoid setPartIndex("+d.map(function(a,b){return"float partIndex"+b}).join()+") {\n  uint32_t pickID; pickID.value = uPickID;\n  uint32_t pickBaseOffset = getPickBaseOffset();\n"+
d.map(function(a,b){return"uint32_t pickOffset"+b+" = add(pickBaseOffset, partIndex"+b+");"}).join("\n")+"\n";0===d.length&&(b+="\n  uint32_t pickOffset0 = pickBaseOffset;\n");b+="\n  vPickID = add(pickID, pickOffset0).value;\n  uint32_t selectedIndex; selectedIndex.value = uSelectedIndex;\nif (equal(selectedIndex, pickBaseOffset)"+d.map(function(a,b){return" || equal(selectedIndex, pickOffset"+b+")"}).join("")+") {\n    vColor = uColorSelected;\n  } else {\n    vColor = uColor;\n  }\n}\n";a.addVertexCode(q.d);
a.addVertexCode(q.b);a.addVertexCode(b);return"setPartIndex("+d.join()+")"}},{key:"getCrossSectionFadeFactor",value:function(){return this.targetIsSliceView?"(clamp(1.0 - 2.0 * abs(0.5 - gl_FragCoord.z), 0.0, 1.0))":"(1.0)"}},{key:"defineShader",value:function(a){a.addUniform("highp vec4","uColor");a.addUniform("highp vec4","uColorSelected");a.addUniform("highp vec4","uSelectedIndex");a.addVarying("highp vec4","vColor");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");
a.addVarying("highp vec4","vPickID");a.require(n.b);1===this.pickIdsPerInstance?a.addVertexCode("\nuint32_t getPickBaseOffset() { return getPrimitiveIndex(); }\n"):(a.addVertexCode(q.j),a.addVertexCode("\nuint32_t getPickBaseOffset() {       \n  return multiply(getPrimitiveIndex(), "+this.pickIdsPerInstance.toFixed(1)+");\n}\n"));a.addFragmentCode("\nvoid emitAnnotation(vec4 color) {\n  emit(color, vPickID);\n}\n")}},{key:"enable",value:function(a,e,d){a.bind();var b=this.gl,c=e.renderContext,k=e.annotationLayer;
this.countingBuffer.ensure(e.count).bind(a,1);b.uniformMatrix4fv(a.uniform("uProjection"),!1,e.projectionMatrix);c.emitPickID&&b.uniform4fv(a.uniform("uPickID"),Object(q.r)(f,e.basePickId));if(c.emitColor){c=k.state.color.value;f[0]=c[0];f[1]=c[1];f[2]=c[2];f[3]=1;b.uniform4fv(a.uniform("uColor"),f);for(c=0;3>c;++c)f[c]=.75+.25*f[c];b.uniform4fv(a.uniform("uColorSelected"),f);b.uniform4fv(a.uniform("uSelectedIndex"),Object(q.r)(f,e.selectedIndex))}d();Object(n.c)(this.gl,a,!0)}}]);return m}(p.a),
v=new Map},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,
writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return D});c.d(g,"c",function(){return y});c.d(g,"b",function(){return E});c.d(g,"d",function(){return G});p=c(6);var a=c.n(p),f=c(36);p=c(17);var l=c(31),v=c(64);g=c(0);var t=c(1),m=c(24),k=c(3),e=c(26),d=c(76),b=c(27),h=c(51);c=c(12);var r=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=
!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),x=function B(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return B(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},z=this&&this.__decorate||function(a,b,d,e){var f=arguments.length,c=3>f?b:null===e?e=Object.getOwnPropertyDescriptor(b,d):e,h;if("object"===typeof Reflect&&
"function"===typeof Reflect.decorate)c=Reflect.decorate(a,b,d,e);else for(var k=a.length-1;0<=k;k--)if(h=a[k])c=(3>f?h(c):3<f?h(b,d,c):h(b,d))||c;return 3<f&&c&&Object.defineProperty(b,d,c),c},A=t.k.create(),D=function(b){function e(b,f,c){u(this,e);var h=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));h.chunkManager=b;h.layerManager=f;h.navigationState=c;h.gl=h.chunkManager.gl;h.dataToViewport=t.k.create();h.viewportToDevice=t.k.create();h.dataToDevice=t.k.create();h.visibleChunks=new Map;
h.viewChanged=new k.a;h.renderingStale=!0;h.visibleChunksStale=!0;h.visibleLayerList=[];h.newVisibleLayers=new Set;h.offscreenFramebuffer=h.registerDisposer(new d.b(h.gl,{colorBuffers:Object(d.e)(h.gl,1),depthBuffer:new d.d(h.gl)}));h.numVisibleChunks=0;h.updateVisibleLayers=h.registerCancellable(a()(function(){h.updateVisibleLayersNow()},0));h.invalidateVisibleSources=function(){h.visibleSourcesStale=!0;h.viewChanged.dispatch()};h.setViewportSizeDebounced=h.registerCancellable(a()(function(a,b){return h.setViewportSize(a,
b)},0));t.k.identity(h.dataToViewport);h.initializeCounterpart(h.chunkManager.rpc,{chunkManager:b.rpcId});h.registerDisposer(c.changed.add(function(){h.updateViewportFromNavigationState()}));h.updateViewportFromNavigationState();h.registerDisposer(f.layersChanged.add(function(){h.hasValidViewport&&h.updateVisibleLayers()}));h.viewChanged.add(function(){h.renderingStale=!0});h.registerDisposer(b.chunkQueueManager.visibleChunksChanged.add(h.viewChanged.dispatch));h.updateViewportFromNavigationState();
h.updateVisibleLayers();return h}q(e,b);r(e,[{key:"isReady",value:function(){this.setViewportSizeDebounced.flush();if(!this.hasValidViewport)return!1;this.maybeUpdateVisibleChunks();for(var a=0,b=$jscomp.makeIterator(this.visibleLayers.values()),d=b.next();!d.done;d=b.next()){d=$jscomp.makeIterator(d.value);for(var e=d.next();!e.done;e=d.next()){var c=e.value;e=c.source;c=this.visibleChunks.get(c.chunkLayout);if(!c)return!1;e=e.chunks;c=$jscomp.makeIterator(c);for(var h=c.next();!h.done;h=c.next())(h=
e.get(h.value))&&h.state===f.d.GPU_MEMORY&&++a}}return a===this.numVisibleChunks}},{key:"updateViewportFromNavigationState",value:function(){var a=this.navigationState;a.valid&&(a.toMat4(A),this.setViewportToDataMatrix(A))}},{key:"bindVisibleRenderLayer",value:function(a){a.redrawNeeded.add(this.viewChanged.dispatch);a.transform.changed.add(this.invalidateVisibleSources)}},{key:"unbindVisibleRenderLayer",value:function(a){a.redrawNeeded.remove(this.viewChanged.dispatch);a.transform.changed.remove(this.invalidateVisibleSources)}},
{key:"updateVisibleLayersNow",value:function(){if(this.wasDisposed||!this.hasValidViewport)return!1;var a=this.visibleLayers,b=this.rpc,d={id:this.rpcId},e=this.newVisibleLayers,f=!1,c=this.visibleLayerList;c.length=0;for(var h=$jscomp.makeIterator(this.layerManager.readyRenderLayers()),k=h.next();!k.done;k=h.next())k=k.value,k instanceof v.a&&(e.add(k),c.push(k),a.has(k)||(a.set(k.addRef(),[]),this.bindVisibleRenderLayer(k),d.layerId=k.rpcId,b.invoke(l.d,d),f=!0));c=$jscomp.makeIterator(a.keys());
for(k=c.next();!k.done;k=c.next())h=k.value,e.has(h)||(a.delete(h),this.unbindVisibleRenderLayer(h),d.layerId=h.rpcId,b.invoke(l.e,d),h.dispose(),f=!0);e.clear();f&&(this.visibleSourcesStale=!0);this.viewChanged.dispatch();return f}},{key:"onViewportChanged",value:function(){var a=this.width,b=this.height,d=this.viewportToDevice,e=this.dataToViewport,f=this.dataToDevice;t.k.ortho(d,-a/2,a/2,b/2,-b/2,-10,10);t.k.multiply(f,d,e);this.visibleChunksStale=!0;this.viewChanged.dispatch()}},{key:"setViewportSize",
value:function(a,b){this.setViewportSizeDebounced.cancel();return x(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setViewportSize",this).call(this,a,b)?(this.rpc.invoke(l.i,{id:this.rpcId,width:a,height:b}),!0):!1}},{key:"onViewportToDataMatrixChanged",value:function(){var a=this.viewportToData,b=this.dataToViewport;t.k.invert(b,a);Object(t.o)(b);this.rpc.invoke(l.i,{id:this.rpcId,viewportToData:a})}},{key:"onHasValidViewport",value:function(){this.updateVisibleLayers()}},{key:"updateRendering",
value:function(){this.setViewportSizeDebounced.flush();if(this.renderingStale&&this.hasValidViewport&&0!==this.width&&0!==this.height){this.renderingStale=!1;this.maybeUpdateVisibleChunks();var a=this.gl,b=this.offscreenFramebuffer;b.bind(this.width,this.height);a.disable(a.SCISSOR_TEST);a.clearStencil(0);a.clearColor(0,0,0,0);a.colorMask(!0,!0,!0,!0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.STENCIL_TEST);a.disable(a.DEPTH_TEST);a.stencilOpSeparate(a.FRONT_AND_BACK,a.KEEP,a.KEEP,a.REPLACE);for(var d=
0,e=$jscomp.makeIterator(this.visibleLayerList),f=e.next();!f.done;f=e.next())f=f.value,a.clear(a.STENCIL_BUFFER_BIT),a.stencilFuncSeparate(a.FRONT_AND_BACK,a.GREATER,1,1),f.setGLBlendMode(a,d),f.draw(this),++d;a.disable(a.BLEND);a.disable(a.STENCIL_TEST);b.unbind()}}},{key:"maybeUpdateVisibleChunks",value:function(){this.updateVisibleLayers.flush();if(!this.visibleChunksStale&&!this.visibleSourcesStale)return!1;this.visibleChunksStale=!1;this.updateVisibleChunks();return!0}},{key:"updateVisibleChunks",
value:function(){var a=this.visibleChunks,b=0;this.computeVisibleChunks(function(b){var d=a.get(b);void 0===d?(d=[],a.set(b,d)):d.length=0;return d},function(a,d,e,f){a=Object(t.t)(e);d[d.length]=a;b+=f.length});this.numVisibleChunks=b}},{key:"disposed",value:function(){for(var a=$jscomp.makeIterator(this.visibleLayers.keys()),b=a.next();!b.done;b=a.next())b=b.value,this.unbindVisibleRenderLayer(b),b.dispose();this.visibleLayers.clear();this.visibleLayerList.length=0}}]);return e}(Object(e.c)(l.j));
D=z([Object(c.g)(l.h)],D);var y=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));a.spec=d.spec;return a}q(b,a);r(b,[{key:"initializeCounterpart",value:function(a,d){d.spec=this.spec.toObject();x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"initializeCounterpart",this).call(this,a,d)}}],[{key:"encodeOptions",value:function(a){var d=x(b.__proto__||Object.getPrototypeOf(b),"encodeOptions",this).call(this,a);d.spec=a.spec.toObject();
return d}}]);return b}(p.e),E=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));a.chunkGridPosition=d.chunkGridPosition;a.state=f.d.SYSTEM_MEMORY;return a}q(b,a);return b}(p.b),G=function(a){function d(a,e){u(this,d);var f=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));f.gl=a;f.copyVertexPositionsBuffer=Object(h.a)(f.gl);f.textureCoordinateAdjustment=new Float32Array(4);var c=new b.a(a);c.addVarying("vec2","vTexCoord");c.addUniform("sampler2D",
"uSampler");c.addInitializer(function(b){a.uniform1i(b.uniform("uSampler"),0)});c.addUniform("vec4","uColorFactor");c.addUniform("vec4","uBackgroundColor");c.addUniform("mat4","uProjectionMatrix");c.addUniform("vec4","uTextureCoordinateAdjustment");c.require(e);c.setFragmentMain("\nvec4 sampledColor = texture2D(uSampler, vTexCoord);\nif (sampledColor.a == 0.0) {\n  sampledColor = uBackgroundColor;\n}\nemit(sampledColor * uColorFactor, vec4(0,0,0,0));\n");c.addAttribute("vec4","aVertexPosition");c.setVertexMain("\nvTexCoord = uTextureCoordinateAdjustment.xy + 0.5 * (aVertexPosition.xy + 1.0) * uTextureCoordinateAdjustment.zw;\ngl_Position = uProjectionMatrix * aVertexPosition;\n");
f.shader=f.registerDisposer(c.build());return f}q(d,a);r(d,[{key:"draw",value:function(a,b,d,e,f,c,h,k){var r=this.gl,m=this.shader,l=this.textureCoordinateAdjustment;l[0]=f;l[1]=c;l[2]=h-f;l[3]=k-c;m.bind();r.activeTexture(r.TEXTURE0);r.bindTexture(r.TEXTURE_2D,a);r.uniformMatrix4fv(m.uniform("uProjectionMatrix"),!1,b);r.uniform4fv(m.uniform("uColorFactor"),d);r.uniform4fv(m.uniform("uBackgroundColor"),e);r.uniform4fv(m.uniform("uTextureCoordinateAdjustment"),l);a=m.attribute("aVertexPosition");
this.copyVertexPositionsBuffer.bindToVertexAttrib(a,2);r.drawArrays(r.TRIANGLE_FAN,0,4);r.disableVertexAttribArray(a);r.bindTexture(r.TEXTURE_2D,null)}}],[{key:"get",value:function(a,b){return a.memoize.get("sliceview/SliceViewRenderHelper:"+Object(m.a)(b),function(){return new d(a,b)})}}]);return d}(g.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return v});g.b=function(a,c){c=void 0===c?"GET":c;var k=new XMLHttpRequest;k[l]=c;k[f]=a;k.open(c,a);return k};g.c=function(a,c,k){k=void 0===k?"GET":k;var e=new XMLHttpRequest;if(Array.isArray(a)){var d=a.length;d=1===d?0:Math.abs(Object(q.a)(c))%d;a=a[d]+c}else a+=c;e[l]=k;e[f]=a;e.open(k,a);return e};g.e=function(a,f,c){c=void 0===c?n.e:c;a.responseType=
f;return new Promise(function(e,d){var b=function(){a.abort()};c.add(b);a.onloadend=function(){var f=this.status;c.remove(b);200<=f&&300>f?e(this.response):d(v.fromXhr(a))};a.send()})};g.d=function(a){var f=a.match(/^([^:\/]+):\/\/([^\/]+)(\/.*)?$/);if(null===f)throw Error("Invalid URL: "+JSON.stringify(a));return"gs"===f[1]?[["https://storage.googleapis.com/"+f[2]],f[3]]:[[a],""]};var n=c(34),q=c(211),a=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||
!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}();$jscomp.initSymbol();var f=Symbol("url");$jscomp.initSymbol();var l=Symbol("method"),v=function(c){function m(a,e,d,b){if(!(this instanceof m))throw new TypeError("Cannot call a class as a function");var f=a+" "+JSON.stringify(e)+" resulted in HTTP error "+d;b&&(f+=": "+b);f+=".";var c=(m.__proto__||Object.getPrototypeOf(m)).call(this,f);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.name="HttpError";c.message=f;c.method=a;c.url=e;c.code=d;c.statusMessage=b;return c}u(m,c);a(m,null,[{key:"fromXhr",value:function(a){return new m(a[l],a[f],a.status,a.statusText)}}]);return m}(Error)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,
configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(){return new q.f(void 0)}g.c=n;g.b=function(f){return new q.c(f,a.B)};c.d(g,"a",function(){return t});var q=c(5);p=c(0);var a=c(2),f=c(27),l=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(f,e,d){e&&a(f.prototype,e);d&&a(f,d);return f}}(),v=function k(a,d,b){null===
a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}},t=function(a){function e(a,b,f,c){c=void 0===c?n():c;if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var d=(e.__proto__||Object.getPrototypeOf(e)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
d=!d||"object"!==typeof d&&"function"!==typeof d?this:d;d.gl=a;d.defineShader=b;d.getShaderKey=f;d.shaderError=c;d.shaderUpdated=!0;d.shader=void 0;c.value=void 0;return d}u(e,a);l(e,[{key:"invalidateShader",value:function(){this.shaderUpdated=!0}},{key:"get",value:function(){if(!this.shaderUpdated)return this.shader;this.shaderUpdated=!1;try{var a=this.getShader();this.disposeShader();this.shader=a;this.shaderError.value=null}catch(b){this.shaderError.value=b}return this.shader}},{key:"getShader",
value:function(){var a=this,b=this.getShaderKey();return this.gl.memoize.get(b,function(){return a.buildShader()})}},{key:"buildShader",value:function(){var a=new f.a(this.gl);this.defineShader(a);return a.build()}},{key:"disposed",value:function(){v(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this);this.disposeShader()}},{key:"disposeShader",value:function(){this.shader&&(this.shader.dispose(),this.shader=void 0)}}]);return e}(p.a)},function(p,g,c){var u=c(313);
p.exports={string:function(c){for(var g=u.randomBytes(c),a=[],f=0;f<c;f++)a.push("abcdefghijklmnopqrstuvwxyz012345".substr(g[f]%32,1));return a.join("")},number:function(c){return Math.floor(Math.random()*c)},numberString:function(c){var g=(""+(c-1)).length;return(Array(g+1).join("0")+this.number(c)).slice(-g)}}},function(p,g,c){(function(g){function n(a){return function(c,k,e){v("create ajax sender",c,k);var d={};"string"===typeof k&&(d.headers={"Content-type":"text/plain"});c=f.addPath(c,"/xhr_send");
var b=new a("POST",c,k,d);b.once("finish",function(a){v("finish",a);b=null;if(200!==a&&204!==a)return e(Error("http status "+a));e()});return function(){v("abort");b.close();b=null;var a=Error("Aborted");a.code=1E3;e(a)}}}function q(a,f,c,e){l.call(this,a,f,n(e),c,e)}var a=c(4),f=c(21),l=c(160),v=function(){};"production"!==g.env.NODE_ENV&&(v=c(9)("sockjs-client:ajax-based"));a(q,l);p.exports=q}).call(g,c(8))},function(p,g,c){c.d(g,"a",function(){return f});g.b=function(a,f,c){c(a.transform,f.transform);
return f.changed.add(function(){c(a.transform,f.transform);a.changed.dispatch()})};var u=c(1),n=c(2),q=c(3),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,m){c&&a(f.prototype,c);m&&a(f,m);return f}}(),f=function(){function f(a){a=void 0===a?u.k.create():a;if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this.transform=
a;this.changed=new q.a}a(f,[{key:"reset",value:function(){u.k.copy(this.transform,u.d);this.changed.dispatch()}},{key:"toJSON",value:function(){if(!u.k.equals(u.d,this.transform)){var a=this.transform;return[[a[0],a[4],a[8],a[12]],[a[1],a[5],a[9],a[13]],[a[2],a[6],a[10],a[14]],[a[3],a[7],a[11],a[15]]]}}},{key:"restoreState",value:function(a){if(null==a)this.reset();else if(Array.isArray(a))if(4===a.length)try{for(var f=0;4>f;++f)Object(n.b)(this.transform.subarray(4*f,4*(f+1)),a[f]);u.k.transpose(this.transform,
this.transform)}catch(e){this.reset()}else if(16===a.length)try{Object(n.b)(this.transform,a),u.k.transpose(this.transform,this.transform)}catch(e){this.reset()}else this.reset();else if("object"===typeof a){f=u.n.create();var c=u.s.create(),k=u.s.fromValues(1,1,1);try{Object(n.b)(f,a.rotation),u.n.normalize(f,f)}catch(e){u.n.identity(f)}try{Object(n.b)(c,a.translation)}catch(e){u.s.copy(c,u.h)}try{Object(n.b)(k,a.scale)}catch(e){u.s.copy(k,u.g)}u.k.fromRotationTranslationScale(this.transform,f,c,
k);this.changed.dispatch()}else this.reset()}},{key:"clone",value:function(){return new f(u.k.clone(this.transform))}}]);return f}()},function(p,g,c){function u(a,c,g,t,m,k){a=void 0===a?-1:a;c=void 0===c?-1:c;g=void 0===g?1:g;t=void 0===t?1:t;m=void 0===m?1:m;k=void 0===k?1:k;return Object(n.d)(new Float32Array([a,c,a,t,g,t,g,c]),2,m,k)}g.a=function(f,c,g,t,m,k,e){return Object(q.b)(f,a.a,u,void 0===c?-1:c,void 0===g?-1:g,void 0===t?1:t,void 0===m?1:m,void 0===k?1:k,void 0===e?1:e).value};var n=
c(39),q=c(15),a=c(11)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return q});p=c(14);var n=function(){function a(a,c){for(var f=0;f<c.length;f++){var l=c[f];l.enumerable=l.enumerable||!1;l.configurable=
!0;"value"in l&&(l.writable=!0);Object.defineProperty(a,l.key,l)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),q=function(a){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var a=(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(f,a);n(f,[{key:"draw",value:function(a){}},
{key:"isReady",value:function(){return!0}}]);return f}(p.i)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"b",function(){return l});p=c(0);var n=c(19);c.d(g,"a",function(){return n.a});c.d(g,"c",function(){return n.c});
var q=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),a=new Set("f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 escape pause".split(" ")),f=new Set("color date datetime datetime-local email month number password search tel text time url week".split(" ")),l=function(c){function l(a,f){if(!(this instanceof l))throw new TypeError("Cannot call a class as a function");
var e=(l.__proto__||Object.getPrototypeOf(l)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.target=a;e.eventMap=f;e.modifierShortcutsAreGlobal=!0;e.allShortcutsAreGlobal=!1;e.allowSpaceKeyOnButtons=!1;e.registerEventListener(a,"keydown",e.handleKeyDown.bind(e),!1);return e}u(l,c);q(l,[{key:"shouldIgnoreEvent",value:function(c,k){var e=k.target,d=e.tagName;if(e===this.target)return!1;
var b="TEXTAREA"===d||"INPUT"===d||"BUTTON"===d||"SELECT"===d,h=!b&&(e.isContentEditable||e.ownerDocument&&"on"===e.ownerDocument.designMode);return!b&&!h||this.allShortcutsAreGlobal||a.has(c)?!1:h||this.modifierShortcutsAreGlobal&&(k.altKey||k.ctrlKey||k.metaKey)?!0:"INPUT"===d&&f.has(e.type)?"enter"!==c:"INPUT"===d||"BUTTON"===d?this.allowSpaceKeyOnButtons?!1:"space"===c:!0}},{key:"handleKeyDown",value:function(a){var f=a.code.toLowerCase();this.shouldIgnoreEvent(f,a)||Object(n.b)(f,a,this.eventMap)}}]);
return l}(p.a)},function(p,g,c){g.a=function(c,g){g.offset+=c;return g};g.b=function(c,g){var n=[];g=$jscomp.makeIterator(g);for(var a=g.next();!a.done;a=g.next())a=a.value,a.startsWith(c)&&n.push({value:a});return n};g.c=function(c,g,q,a){var f=[];g=$jscomp.makeIterator(g);for(var l=g.next();!l.done;l=g.next()){l=l.value;var v=q(l);v.startsWith(c)&&f.push({value:v,description:a(l)})}return f}},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}c.d(g,"a",function(){return z});c.d(g,
"b",function(){return y});var a=c(36);p=c(17);var f=c(213);g=c(52);var l=c(122),v=c(67),t=c(1),m=c(24),k=c(15),e=c(27),d=c(16);c=c(12);var b=function H(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return H(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},h=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;
"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),r=this&&this.__decorate||function(a,b,d,e){var f=arguments.length,c=3>f?b:null===e?e=Object.getOwnPropertyDescriptor(b,d):e,h;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)c=Reflect.decorate(a,b,d,e);else for(var k=a.length-1;0<=k;k--)if(h=a[k])c=(3>f?h(c):3<f?h(b,d,c):h(b,d))||c;return 3<f&&c&&Object.defineProperty(b,d,c),c},x=function(){function a(){q(this,
a);this.tempLightVec=new Float32Array(4);this.tempPickID=new Float32Array(4)}h(a,[{key:"defineShader",value:function(a){a.addAttribute("highp vec3","aVertexPosition");a.addAttribute("highp vec3","aVertexNormal");a.addVarying("highp vec4","vColor");a.addUniform("highp vec4","uLightDirection");a.addUniform("highp vec4","uColor");a.addUniform("highp mat4","uModelMatrix");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");a.setVertexMain("\ngl_Position = uProjection * (uModelMatrix * vec4(aVertexPosition, 1.0));\nvec3 normal = (uModelMatrix * vec4(aVertexNormal, 0.0)).xyz;\nfloat lightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w;\nvColor = vec4(lightingFactor * uColor.rgb, uColor.a);\n");
a.setFragmentMain("emit(vColor, uPickID);")}},{key:"beginLayer",value:function(a,b,d){var e=d.dataToDevice,f=d.lightDirection,c=d.ambientLighting;d=d.directionalLighting;a.uniformMatrix4fv(b.uniform("uProjection"),!1,e);e=this.tempLightVec;t.s.scale(e,f,d);e[3]=c;a.uniform4fv(b.uniform("uLightDirection"),e)}},{key:"setColor",value:function(a,b,d){a.uniform4fv(b.uniform("uColor"),d)}},{key:"setPickID",value:function(a,b,e){a.uniform4fv(b.uniform("uPickID"),Object(d.r)(this.tempPickID,e))}},{key:"beginObject",
value:function(a,b,d){a.uniformMatrix4fv(b.uniform("uModelMatrix"),!1,d)}},{key:"getShader",value:function(a,b){var d=this;return a.memoize.get("mesh/MeshShaderManager:"+Object(m.a)(b),function(){var f=new e.a(a);f.require(b);d.defineShader(f);return f.build()})}},{key:"drawFragment",value:function(a,b,d){d.vertexBuffer.bindToVertexAttrib(b.attribute("aVertexPosition"),3);d.normalBuffer.bindToVertexAttrib(b.attribute("aVertexNormal"),3);d.indexBuffer.bind();a.drawElements(a.TRIANGLES,d.numIndices,
a.UNSIGNED_INT,0)}},{key:"endLayer",value:function(a,b){a.disableVertexAttribArray(b.attribute("aVertexPosition"));a.disableVertexAttribArray(b.attribute("aVertexNormal"))}}]);return a}(),z=function(b){function d(a,b,e){q(this,d);var c=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));c.chunkManager=a;c.source=b;c.displayState=e;c.meshShaderManager=new x;c.shaders=new Map;Object(v.f)(e,c);a=c.sharedObject=c.registerDisposer(new v.b(a,e));a.RPC_TYPE_ID=f.b;a.initializeCounterpartWithChunkManager({source:b.addCounterpartRef()});
c.setReady(!0);a.visibility.add(c.visibility);return c}n(d,b);h(d,[{key:"getShader",value:function(a){var b=this.shaders,d=b.get(a);void 0===d&&(d=this.registerDisposer(this.meshShaderManager.getShader(this.gl,a)),b.set(a,d));return d}},{key:"draw",value:function(b){var d=this;if(b.emitColor||!b.alreadyEmittedPickID){var e=this.gl,f=this.displayState,c=this.meshShaderManager,h=Math.min(1,f.objectAlpha.value);if(!(0>=h)){var k=this.getShader(b.emitter);k.bind();c.beginLayer(e,k,b);var r=b.pickIDs,
m=this.displayState.objectToDataTransform.transform;Object(v.d)(f,this.source.fragmentSource.objectChunks,function(l,g,t){b.emitColor&&c.setColor(e,k,Object(v.e)(f,l,h));b.emitPickID&&c.setPickID(e,k,r.registerUint64(d,g));c.beginObject(e,k,m);l=$jscomp.makeIterator(t);for(g=l.next();!g.done;g=l.next())g=g.value,g.state===a.d.GPU_MEMORY&&c.drawFragment(e,k,g)});c.endLayer(e,k)}}}},{key:"isReady",value:function(){var b=this.displayState,d=this.source,e=!0,f=d.fragmentSource.chunks;Object(l.a)(b,function(c){c=
Object(l.b)(c,b.clipBounds.value);var h=d.chunks.get(c);if(void 0===h)e=!1;else{h=$jscomp.makeIterator(h.fragmentIds);for(var k=h.next();!k.done;k=h.next())if(k=f.get(c+"/"+k.value),void 0===k||k.state!==a.d.GPU_MEMORY){e=!1;break}}});return e}},{key:"isTransparent",get:function(){return 1>this.displayState.objectAlpha.value}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);return d}(g.a),A=function(a){function b(a,d){q(this,b);a=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,
a));a.fragmentIds=d.fragmentIds;return a}n(b,a);return b}(p.b),D=function(a){function d(a,b){q(this,d);a=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,a));a.objectKey=b.objectKey;a.vertexPositions=b.vertexPositions;var e=a.indices=b.indices;a.numIndices=e.length;a.vertexNormals=b.vertexNormals;return a}n(d,a);h(d,[{key:"copyToGPU",value:function(a){b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"copyToGPU",this).call(this,a);this.vertexBuffer=k.a.fromData(a,this.vertexPositions,
a.ARRAY_BUFFER,a.STATIC_DRAW);this.indexBuffer=k.a.fromData(a,this.indices,a.ELEMENT_ARRAY_BUFFER,a.STATIC_DRAW);this.normalBuffer=k.a.fromData(a,this.vertexNormals,a.ARRAY_BUFFER,a.STATIC_DRAW)}},{key:"freeGPUMemory",value:function(a){b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"freeGPUMemory",this).call(this,a);this.vertexBuffer.dispose();this.indexBuffer.dispose();this.normalBuffer.dispose()}}]);return d}(p.b),y=function(a){function d(){q(this,d);var a=u(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,
arguments));a.fragmentSource=a.registerDisposer(new E(a.chunkManager,a));return a}n(d,a);h(d,[{key:"initializeCounterpart",value:function(a,e){this.fragmentSource.initializeCounterpart(this.chunkManager.rpc,{});e.fragmentSource=this.fragmentSource.addCounterpartRef();b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"initializeCounterpart",this).call(this,a,e)}},{key:"getChunk",value:function(a){return new A(this,a)}}]);return d}(p.e),E=function(a){function d(a,b){q(this,d);a=u(this,(d.__proto__||
Object.getPrototypeOf(d)).call(this,a));a.meshSource=b;a.objectChunks=new Map;return a}n(d,a);h(d,[{key:"addChunk",value:function(a,e){b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"addChunk",this).call(this,a,e);a=this.objectChunks;var f=e.objectKey,c=a.get(f);void 0===c&&(c=new Set,a.set(f,c));c.add(e)}},{key:"deleteChunk",value:function(a){var e=this.chunks.get(a);b(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"deleteChunk",this).call(this,a);a=this.objectChunks;var f=
e.objectKey,c=a.get(f);c.delete(e);0===c.size&&a.delete(f)}},{key:"getChunk",value:function(a){return new D(this,a)}}]);return d}(p.e);E=r([Object(c.g)(f.a)],E)},function(p,g,c){g.a=function(c){return new u.c(void 0===c?.5:c,n.r)};var u=c(5),n=c(2)},function(p,g,c){function u(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function n(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+
typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function q(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}c.d(g,"b",function(){return t});c.d(g,"c",function(){return m});c.d(g,"a",function(){return k});p=c(6);var a=c.n(p);p=c(0);var f=c(3),l=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,
f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;return void 0===f?void 0:f.call(c)}},v=function(){function a(a,d){for(var b=0;b<d.length;b++){var f=d[b];f.enumerable=f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,d,f){d&&a(b.prototype,d);f&&a(b,f);return b}}(),t=function(){function a(b,d){d=void 0===d?b:d;q(this,a);this.value_=b;this.defaultValue=d;this.changed=
new f.a}v(a,[{key:"toggle",value:function(){this.value=!this.value}},{key:"toJSON",value:function(){if(this.value_!==this.defaultValue)return this.value_}},{key:"restoreState",value:function(a){this.value=!0===a||!1===a?a:this.defaultValue}},{key:"reset",value:function(){this.value=this.defaultValue}},{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&(this.value_=a,this.changed.dispatch())}}]);return a}(),m=function(a){function b(a){q(this,b);var d=u(this,(b.__proto__||
Object.getPrototypeOf(b)).call(this));d.model=a;d.element=document.createElement("input");var f=d.element;f.type="checkbox";d.registerDisposer(a.changed.add(function(){d.updateCheckbox()}));d.updateCheckbox();d.registerEventListener(f,"change",function(b){a.value=this.checked});f.addEventListener("mousedown",function(a){a.preventDefault()});return d}n(b,a);v(b,[{key:"updateCheckbox",value:function(){this.element.checked=this.model.value}},{key:"disposed",value:function(){var a=this.element,d=a.parentElement;
d&&d.removeChild(a);l(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}}]);return b}(p.a),k=function(d){function b(d,f){q(this,b);var c=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.model=d;c.element=f;c.initialDisplay=c.element.style.display;c.updateVisibility();c.registerDisposer(d.changed.add(c.registerCancellable(a()(function(){return c.updateVisibility()},0))));return c}n(b,d);v(b,[{key:"updateVisibility",value:function(){this.element.style.display=
this.model.value?this.initialDisplay:"none"}}]);return b}(p.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&
b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b,d,e){var f=!1,c;a.registerDisposer(b);var h=m.UNLINKED,k=function(){var f=d.value;if(f!==h)switch(f){case m.UNLINKED:c=void 0;break;case m.LINKED:c=void 0;e.assign(a,b);break;case m.RELATIVE:c=e.difference(a,b)}h=f;a.changed.dispatch()};a.registerDisposer(a.changed.add(function(){if(!f)switch(d.value){case m.LINKED:e.assign(b,a);break;case m.RELATIVE:e.subtract(b,
a,c)}}));a.registerDisposer(b.changed.add(function(){f=!0;switch(d.value){case m.UNLINKED:if(e.isValid(a))break;case m.LINKED:e.assign(a,b);break;case m.RELATIVE:e.add(a,b,c)}f=!1}));a.registerDisposer(d.changed.add(k));k();return a}c.d(g,"d",function(){return m});c.d(g,"h",function(){return e});c.d(g,"b",function(){return r});c.d(g,"f",function(){return x});c.d(g,"a",function(){return z});c.d(g,"g",function(){return A});c.d(g,"c",function(){return y});c.d(g,"e",function(){return E});p=c(0);var f=
c(1),l=c(2),v=c(3);c=c(260);var t=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),m;(function(a){a[a.LINKED=0]="LINKED";a[a.RELATIVE=1]="RELATIVE";a[a.UNLINKED=2]="UNLINKED"})(m||(m={}));var k=function(a){function b(a){a=void 0===a?m.LINKED:a;u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,
m,a))}q(b,a);return b}(c.a),e=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.changed=new v.a;var e=!0;null==a&&(a=f.s.create(),e=!1);d.size=a;d.valid=e;return d}q(b,a);t(b,[{key:"reset",value:function(){this.valid=!1;this.changed.dispatch()}},{key:"setValid",value:function(){this.valid||(this.valid=!0,this.changed.dispatch())}},{key:"toJSON",value:function(){if(this.valid)return Array.prototype.slice.call(this.size)}},{key:"restoreState",value:function(a){try{Object(l.b)(this.size,
a),this.valid=!0,this.changed.dispatch()}catch(C){this.valid=!1,this.changed.dispatch()}}},{key:"toString",value:function(){return this.valid?this.size.toString():null}},{key:"voxelFromSpatial",value:function(a,b){return f.s.divide(a,b,this.size)}},{key:"spatialFromVoxel",value:function(a,b){return f.s.multiply(a,b,this.size)}}]);return b}(p.a),d=f.s.create(),b=f.n.create(),h=function(a){function b(a,d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.voxelCoordinates=
null;c.changed=new v.a;null==a&&(a=new e);c.voxelSize=a;var h=!0;null==d&&(d=f.s.create(),h=!1);c.spatialCoordinates=d;c.spatialCoordinatesValid=h;c.registerDisposer(a);c.registerDisposer(a.changed.add(function(){c.handleVoxelSizeChanged()}));return c}q(b,a);t(b,[{key:"reset",value:function(){this.spatialCoordinatesValid=!1;this.voxelCoordinates=null;this.voxelSize.reset();this.changed.dispatch()}},{key:"getVoxelCoordinates",value:function(a){var b=this.voxelCoordinates;if(b)f.s.copy(a,b);else if(this.valid)this.voxelSize.voxelFromSpatial(a,
this.spatialCoordinates);else return!1;return!0}},{key:"setVoxelCoordinates",value:function(a){var b=this.voxelSize;b.valid?(b.spatialFromVoxel(this.spatialCoordinates,a),this.markSpatialCoordinatesChanged()):(b=this.voxelCoordinates)?f.s.copy(b,a):this.voxelCoordinates=f.s.clone(a);this.changed.dispatch()}},{key:"markSpatialCoordinatesChanged",value:function(){this.spatialCoordinatesValid=!0;this.voxelCoordinates=null;this.changed.dispatch()}},{key:"handleVoxelSizeChanged",value:function(){null==
this.voxelCoordinates||this.spatialCoordinatesValid||(this.voxelSize.spatialFromVoxel(this.spatialCoordinates,this.voxelCoordinates),this.spatialCoordinatesValid=!0);this.voxelCoordinates=null;this.changed.dispatch()}},{key:"toJSON",value:function(){var a=!0,b=this.voxelSize.toJSON(),e={};void 0!==b&&(a=!1,e.voxelSize=b);this.voxelCoordinatesValid?(this.getVoxelCoordinates(d),e.voxelCoordinates=Array.prototype.slice.call(d),a=!1):this.spatialCoordinatesValid&&(e.spatialCoordinates=Array.prototype.slice.call(this.spatialCoordinates),
a=!1);if(!a)return e}},{key:"restoreState",value:function(a){var b=this;Object(l.u)(a);Object(l.w)(a,"voxelSize",function(a){void 0!==a&&b.voxelSize.restoreState(a)});this.spatialCoordinatesValid=!1;Object(l.w)(a,"voxelCoordinates",function(a){void 0!==a&&b.setVoxelCoordinates(Object(l.b)(f.s.create(),a))});Object(l.w)(a,"spatialCoordinates",function(a){void 0!==a&&(Object(l.b)(b.spatialCoordinates,a),b.markSpatialCoordinatesChanged())})}},{key:"snapToVoxel",value:function(){if(this.valid){for(var a=
this.spatialCoordinates,b=this.voxelSize.size,d=0;3>d;++d){var e=b[d];a[d]=Math.round(a[d]/e)*e}this.changed.dispatch()}else if(a=this.voxelCoordinates,null!=a){for(b=0;3>b;++b)a[b]=Math.round(a[b]);this.changed.dispatch()}}},{key:"assign",value:function(a){this.spatialCoordinatesValid=a.spatialCoordinatesValid;f.s.copy(this.spatialCoordinates,a.spatialCoordinates);this.voxelCoordinates=(a=a.voxelCoordinates)&&f.s.clone(a);this.changed.dispatch()}},{key:"valid",get:function(){return this.spatialCoordinatesValid&&
this.voxelSize.valid}},{key:"voxelCoordinatesValid",get:function(){return this.valid||null!=this.voxelCoordinates}}],[{key:"getOffset",value:function(a,b){if(a.spatialCoordinatesValid&&b.spatialCoordinatesValid)return{spatialOffset:f.s.subtract(f.s.create(),a.spatialCoordinates,b.spatialCoordinates)};if(a.voxelCoordinates&&b.voxelCoordinates){if(a.voxelSize!==b.voxelSize)throw Error("Voxel offsets are only meaningful with identical voxelSize.");return{voxelOffset:f.s.subtract(f.s.create(),a.voxelCoordinates,
b.voxelCoordinates)}}return{}}},{key:"addOffset",value:function(a,b,e,c){c=void 0===c?1:c;var h=e.spatialOffset;e=e.voxelOffset;void 0!==h&&b.spatialCoordinatesValid?(f.s.scaleAndAdd(a.spatialCoordinates,b.spatialCoordinates,h,c),a.markSpatialCoordinatesChanged()):void 0!==e&&b.getVoxelCoordinates(d)&&a.setVoxelCoordinates(f.s.scaleAndAdd(d,d,e,c))}}]);return b}(p.a);c=function(){function a(b,d){d=void 0===d?new k:d;u(this,a);this.peer=b;this.link=d}t(a,[{key:"toJSON",value:function(){var a=this.link;
if(a.value!==m.LINKED)return{link:a.toJSON(),value:this.getValueJson()}}},{key:"getValueJson",value:function(){return this.value.toJSON()}},{key:"reset",value:function(){this.link.value=m.LINKED}},{key:"restoreState",value:function(a){var b=this;void 0===a||0===Object.keys(a).length?this.link.value=m.LINKED:(Object(l.u)(a),this.link.value=m.UNLINKED,Object(l.w)(a,"value",function(a){void 0!==a&&b.value.restoreState(a)}),Object(l.w)(a,"link",function(a){return b.link.restoreState(a)}))}},{key:"copyToPeer",
value:function(){this.link.value!==m.LINKED&&(this.link.value=m.UNLINKED,this.peer.assign(this.value),this.link.value=m.LINKED)}},{key:"changed",get:function(){return this.value.changed}}]);return a}();var r=function(b){function d(){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments));b.value=a(new h(b.peer.voxelSize.addRef()),b.peer,b.link,{assign:function(a,b){return a.assign(b)},isValid:function(a){return a.spatialCoordinatesValid||a.voxelCoordinatesValid},difference:h.getOffset,
add:h.addOffset,subtract:function(a,b,d){h.addOffset(a,b,d,-1)}});return b}q(d,b);t(d,[{key:"getValueJson",value:function(){var a=this.value.toJSON()||{};delete a.voxelSize;return a}}]);return d}(c),x=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.changed=new v.a;null==a&&(a=f.n.create());d.orientation=a;return d}q(b,a);t(b,[{key:"toJSON",value:function(){var a=this.orientation;f.n.normalize(this.orientation,this.orientation);if(0!==a[0]||0!==
a[1]||0!==a[2]||1!==a[3])return Array.prototype.slice.call(this.orientation)}},{key:"restoreState",value:function(a){try{Object(l.b)(this.orientation,a),f.n.normalize(this.orientation,this.orientation)}catch(C){f.n.identity(this.orientation)}this.changed.dispatch()}},{key:"reset",value:function(){f.n.identity(this.orientation);this.changed.dispatch()}},{key:"snap",value:function(){var a=f.i.create();f.i.fromQuat(a,this.orientation);for(var b=[!1,!1,!1],d=0;3>d;++d){for(var e=0,c=0,h=0;3>h;++h){var k=
a[3*d+h];a[3*d+h]=0;!b[h]&&Math.abs(k)>Math.abs(e)&&(e=k,c=h)}a[3*d+c]=Math.sign(e);b[c]=!0}f.n.fromMat3(this.orientation,a);this.changed.dispatch()}},{key:"assign",value:function(a){f.n.copy(this.orientation,a.orientation);this.changed.dispatch()}}],[{key:"makeRelative",value:function(a,d){var e=new b(f.n.multiply(f.n.create(),a.orientation,d)),c=!1;e.registerDisposer(a.changed.add(function(){c||(h=!0,f.n.multiply(e.orientation,a.orientation,d),e.changed.dispatch(),h=!1)}));var h=!1,k=f.n.invert(f.n.create(),
d);e.registerDisposer(e.changed.add(function(){h||(c=!0,f.n.multiply(a.orientation,e.orientation,k),a.changed.dispatch(),c=!1)}));return e}}]);return b}(p.a),z=function(d){function e(){u(this,e);var d=n(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));d.value=a(new x,d.peer,d.link,{assign:function(a,b){return a.assign(b)},isValid:function(){return!0},difference:function(a,b){var d=f.n.create();return f.n.multiply(d,f.n.invert(d,b.orientation),a.orientation)},add:function(a,b,d){f.n.multiply(a.orientation,
b.orientation,d);a.changed.dispatch()},subtract:function(a,d,e){f.n.multiply(a.orientation,d.orientation,f.n.invert(b,e));a.changed.dispatch()}});return d}q(e,d);return e}(c),A=function(a){function e(a,b){u(this,e);var d=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.changed=new v.a;null==a&&(a=new h);d.position=a;null==b&&(b=new x);d.orientation=b;d.registerDisposer(d.position);d.registerDisposer(d.orientation);d.registerDisposer(d.position.changed.add(d.changed.dispatch));d.registerDisposer(d.orientation.changed.add(d.changed.dispatch));
return d}q(e,a);t(e,[{key:"reset",value:function(){this.position.reset();this.orientation.reset()}},{key:"toMat4",value:function(a){f.k.fromRotationTranslation(a,this.orientation.orientation,this.position.spatialCoordinates)}},{key:"toJSON",value:function(){var a=this.position.toJSON(),b=this.orientation.toJSON();if(void 0!==a||void 0!==b)return{position:a,orientation:b}}},{key:"restoreState",value:function(a){var b=this;Object(l.u)(a);Object(l.w)(a,"position",function(a){void 0!==a&&b.position.restoreState(a)});
Object(l.w)(a,"orientation",function(a){void 0!==a&&b.orientation.restoreState(a)})}},{key:"snap",value:function(){this.orientation.snap();this.position.snapToVoxel();this.changed.dispatch()}},{key:"translateAbsolute",value:function(a){f.s.add(this.position.spatialCoordinates,this.position.spatialCoordinates,a);this.position.changed.dispatch()}},{key:"translateRelative",value:function(a){this.valid&&(f.s.transformQuat(d,a,this.orientation.orientation),f.s.add(this.position.spatialCoordinates,this.position.spatialCoordinates,
d),this.position.changed.dispatch())}},{key:"translateVoxelsRelative",value:function(a){if(this.valid){var b=f.s.create();f.s.transformQuat(b,a,this.orientation.orientation);f.s.multiply(b,b,this.position.voxelSize.size);f.s.add(this.position.spatialCoordinates,this.position.spatialCoordinates,b);this.position.changed.dispatch()}}},{key:"rotateRelative",value:function(a,b){var d=f.n.create();f.n.setAxisAngle(d,a,b);a=this.orientation.orientation;f.n.multiply(a,a,d);this.orientation.changed.dispatch()}},
{key:"rotateAbsolute",value:function(a,e,c){var h=f.n.create();f.n.setAxisAngle(h,a,e);a=this.orientation.orientation;if(void 0!==c){e=this.position.spatialCoordinates;var k=f.s.subtract(d,c,e),r=f.n.invert(b,a);f.s.transformQuat(k,k,r);f.n.multiply(a,h,a);f.s.transformQuat(e,k,a);f.s.subtract(e,c,e);this.position.changed.dispatch()}else f.n.multiply(a,h,a);this.orientation.changed.dispatch()}},{key:"valid",get:function(){return this.position.valid}}]);return e}(p.a),D=function(a){function b(a,d){a=
void 0===a?Number.NaN:a;d=void 0===d?a:d;u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.value_=a;e.defaultValue=d;e.changed=new v.a;return e}q(b,a);t(b,[{key:"toJSON",value:function(){var a=this.value_,b=this.defaultValue;if(!(Number.isNaN(a)&&Number.isNaN(b)||a===b))return a}},{key:"restoreState",value:function(a){"number"===typeof a&&Number.isFinite(a)&&0<a?this.value=a:this.value=this.defaultValue}},{key:"reset",value:function(){this.value=this.defaultValue}},{key:"zoomBy",
value:function(a){var b=this.value_;Number.isNaN(b)||(this.value=b*a)}},{key:"assign",value:function(a){this.value=a.value}},{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&(this.value_=a,this.changed.dispatch())}},{key:"valid",get:function(){return!Number.isNaN(this.value)}}]);return b}(p.a),y=function(b){function d(){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments));b.value=function(){var d=new D;return a(d,b.peer,b.link,{assign:function(a,
b){return a.assign(b)},isValid:function(a){return a.valid},difference:function(a,b){return a.value/b.value},add:function(a,b,d){a.value=b.value*d},subtract:function(a,b,d){a.value=b.value/d}})}();return b}q(d,b);return d}(c),E=function(a){function b(a,d){a=void 0===a?new A:a;d=void 0===d?Number.NaN:d;u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.pose=a;e.changed=new v.a;e.zoomFactor="number"===typeof d?new D(d):d;e.registerDisposer(e.zoomFactor);e.registerDisposer(a);
e.registerDisposer(e.pose.changed.add(function(){e.changed.dispatch()}));e.registerDisposer(e.zoomFactor.changed.add(function(){e.changed.dispatch()}));e.registerDisposer(e.voxelSize.changed.add(function(){e.handleVoxelSizeChanged()}));e.handleVoxelSizeChanged();return e}q(b,a);t(b,[{key:"reset",value:function(){this.pose.reset();this.zoomFactor.reset()}},{key:"setZoomFactorFromVoxelSize",value:function(){this.voxelSize.valid&&(this.zoomFactor.value=Math.min.apply(null,this.voxelSize.size))}},{key:"handleVoxelSizeChanged",
value:function(){this.zoomFactor.valid||this.setZoomFactorFromVoxelSize()}},{key:"toMat4",value:function(a){this.pose.toMat4(a);var b=this.zoomFactor.value;f.k.scale(a,a,f.s.fromValues(b,b,b))}},{key:"toJSON",value:function(){var a=this.pose.toJSON(),b=this.zoomFactor.toJSON();if(void 0!==a||void 0!==b)return{pose:a,zoomFactor:b}}},{key:"restoreState",value:function(a){var b=this;try{Object(l.u)(a),Object(l.w)(a,"pose",function(a){void 0!==a&&b.pose.restoreState(a)}),Object(l.w)(a,"zoomFactor",function(a){void 0!==
a&&b.zoomFactor.restoreState(a)}),this.handleVoxelSizeChanged(),this.changed.dispatch()}catch(F){this.reset()}}},{key:"zoomBy",value:function(a){this.zoomFactor.zoomBy(a)}},{key:"voxelSize",get:function(){return this.pose.position.voxelSize}},{key:"position",get:function(){return this.pose.position}},{key:"valid",get:function(){return this.pose.valid}}]);return b}(p.a)},function(p,g,c){function u(c,a,f){n.call(this,c,a,f,{noCredentials:!0})}g=c(4);var n=c(161);g(u,n);u.enabled=n.enabled;p.exports=
u},function(p,g,c){(function(c){p.exports={isOpera:function(){return c.navigator&&/opera/i.test(c.navigator.userAgent)},isKonqueror:function(){return c.navigator&&/konqueror/i.test(c.navigator.userAgent)},hasDomain:function(){if(!c.document)return!0;try{return!!c.document.domain}catch(n){return!1}}}}).call(g,c(7))},function(p,g,c){(function(g,n){var q=c(38),a=c(33),f=c(60),l=function(){};"production"!==g.env.NODE_ENV&&(l=c(9)("sockjs-client:utils:iframe"));p.exports={WPrefix:"_jp",currentWindowId:null,
polluteGlobalNamespace:function(){p.exports.WPrefix in n||(n[p.exports.WPrefix]={})},postMessage:function(f,c){n.parent!==n?n.parent.postMessage(a.stringify({windowId:p.exports.currentWindowId,type:f,data:c||""}),"*"):l("Cannot postMessage, no parent window.",f,c)},createIframe:function(a,f){var c=n.document.createElement("iframe"),k=function(){l("unattach");clearTimeout(b);try{c.onload=null}catch(r){}c.onerror=null},e=function(){l("cleanup");c&&(k(),setTimeout(function(){c&&c.parentNode.removeChild(c);
c=null},0),q.unloadDel(h))},d=function(a){l("onerror",a);c&&(e(),f(a))};c.src=a;c.style.display="none";c.style.position="absolute";c.onerror=function(){d("onerror")};c.onload=function(){l("onload");clearTimeout(b);b=setTimeout(function(){d("onload timeout")},2E3)};n.document.body.appendChild(c);var b=setTimeout(function(){d("timeout")},15E3);var h=q.unloadAdd(e);return{post:function(a,b){l("post",a,b);try{setTimeout(function(){c&&c.contentWindow&&c.contentWindow.postMessage(a,b)},0)}catch(z){}},cleanup:e,
loaded:k}},createHtmlfile:function(a,f){var c=["Active"].concat("Object").join("X"),k=new n[c]("htmlfile"),e=function(){clearTimeout(r);h.onerror=null},d=function(){k&&(e(),q.unloadDel(g),h.parentNode.removeChild(h),h=k=null,CollectGarbage())},b=function(a){l("onerror",a);k&&(d(),f(a))};k.open();k.write('<html><script>document.domain="'+n.document.domain+'";\x3c/script></html>');k.close();k.parentWindow[p.exports.WPrefix]=n[p.exports.WPrefix];c=k.createElement("div");k.body.appendChild(c);var h=k.createElement("iframe");
c.appendChild(h);h.src=a;h.onerror=function(){b("onerror")};var r=setTimeout(function(){b("timeout")},15E3);var g=q.unloadAdd(d);return{post:function(a,b){try{setTimeout(function(){h&&h.contentWindow&&h.contentWindow.postMessage(a,b)},0)}catch(D){}},cleanup:d,loaded:e}}};p.exports.iframeEnabled=!1;n.document&&(p.exports.iframeEnabled=("function"===typeof n.postMessage||"object"===typeof n.postMessage)&&!f.isKonqueror())}).call(g,c(8),c(7))},function(p,g,c){var u=c(182);c.d(g,"b",function(){return u.a});
var n=c(75);c.d(g,"c",function(){return n.b});var q=c(195);c.d(g,"a",function(){return q.a});c.d(g,"d",function(){return q.b});c.d(g,"e",function(){return q.c})},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a,
f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");}c.d(g,"a",function(){return v});c.d(g,"b",function(){return t});var q=c(0),a=c(2),f=function k(a,d,b){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}},l=function(){function a(a,d){for(var b=0;b<d.length;b++){var e=d[b];e.enumerable=e.enumerable||
!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(e,d,b){d&&a(e.prototype,d);b&&a(e,b);return e}}(),v=function(){function a(){n(this,a);this.map=new Map}l(a,[{key:"get",value:function(a,d){var b=this.map,e=b.get(a);void 0===e?(e=d(),e.registerDisposer(function(){b.delete(a)}),b.set(a,e)):e.addRef();return e}}]);return a}(),t=function(c){function e(){n(this,e);var a=(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(e,c);l(e,[{key:"get",value:function(d,b){"string"!==typeof d&&(d=Object(a.g)(d));return f(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"get",this).call(this,d,b)}},{key:"getUncounted",value:function(a,b){return this.get(a,function(){return new q.b(b())}).value}}]);return e}(v)},function(p,g,c){function u(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||"object"!==typeof f&&
"function"!==typeof f?a:f}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return t});var q=c(50);p=c(14);var a=c(31),f=c(1),l=c(12),v=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=
b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(f,e,d){e&&a(f.prototype,e);d&&a(f,d);return f}}(),t=function(c){function k(e,d,b){b=void 0===b?{}:b;if(!(this instanceof k))throw new TypeError("Cannot call a class as a function");var c=u(this,(k.__proto__||Object.getPrototypeOf(k)).call(this));c.chunkManager=e;c.sources=d;c.rpcId=null;c.transformedSourcesGeneration=-1;e=b;var r=void 0===e.transform?new q.a:e.transform;c.transform=r;
e=Object(a.o)(c)[0][0];b=e.source.spec;e=c.voxelSize=e.chunkLayout.localSpatialVectorToGlobal(f.s.create(),b.voxelSize);for(b=0;3>b;++b)e[b]=Math.abs(e[b]);e=c.registerDisposer(new l.b);var m=c.chunkManager.rpc;e.RPC_TYPE_ID=a.f;d=d.map(function(a){return a.map(function(a){return a.rpcId})});e.initializeCounterpart(m,{sources:d,transform:r.transform});c.rpcId=e.rpcId;c.registerDisposer(r.changed.add(function(){m.invoke(a.g,{id:c.rpcId,value:r.transform})}));c.setReady(!0);return c}n(k,c);v(k,[{key:"setGLBlendMode",
value:function(a,d){0<d&&(a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA))}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);return k}(p.e)},function(p,g,c){function u(c){c.texParameteri(n.x,n.z,n.n);c.texParameteri(n.x,n.y,n.n);c.texParameteri(n.x,n.A,n.c);c.texParameteri(n.x,n.B,n.c)}g.b=u;g.a=function(c,a,f,l,g,t){g=void 0===g?n.s:g;t=void 0===t?n.G:t;c.activeTexture(n.w+c.tempTextureUnit);c.bindTexture(n.x,a);u(c);c.texImage2D(n.x,0,g,f,l,0,g,t,null);
c.bindTexture(n.x,null)};g.c=function(c,a,f){c.activeTexture(n.w+c.tempTextureUnit);c.bindTexture(n.x,a);c.texParameteri(n.x,n.z,n.k);c.texParameteri(n.x,n.y,n.k);c.texParameteri(n.x,n.A,n.c);c.texParameteri(n.x,n.B,n.c);c.pixelStorei(n.F,!0);c.pixelStorei(n.E,4);c.texImage2D(n.x,0,n.s,n.s,n.G,f);c.pixelStorei(n.F,!1);c.bindTexture(n.x,null)};var n=c(11)},function(p,g,c){function u(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==
typeof d&&"function"!==typeof d?a:d}function n(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function q(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}c.d(g,"a",function(){return k});p=c(6);var a=c.n(p);p=
c(0);var f=c(204),l=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),v=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;return void 0===f?void 0:f.call(c)}},
t=new function b(){q(this,b);f.a.initializeHead(this)},m=a()(function(){var a=document.activeElement;if(null===a||a===document.body)a=f.a.front(t),null!==a&&a.element.focus()});window.addEventListener("focus",function(){m()},!0);window.addEventListener("blur",function(){m()},!0);var k=function(b){function c(b){q(this,c);var h=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));h.element=b;h.prev0=null;h.next0=null;h.lastFocusedElement=null;h.scheduleUpdateFocus=h.registerCancellable(a()(function(){var a=
document.activeElement,b=h.element;b.contains(a)||((a===h.lastFocusedElement||a.contains(b))&&h.element.focus(),h.lastFocusedElement=null)},0));b.tabIndex=-1;h.registerEventListener(b,"mouseenter",function(){h.lastFocusedElement=document.activeElement;h.scheduleUpdateFocus()});h.registerEventListener(b,"mouseleave",function(){h.scheduleUpdateFocus.cancel()});f.a.insertBefore(t,h);h.registerEventListener(b,"focus",function(){f.a.pop(h);f.a.insertAfter(t,h)});m();return h}n(c,b);l(c,[{key:"disposed",
value:function(){f.a.pop(this);v(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}}]);return c}(p.a)},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function a(a,b){var d=b.redrawNeeded.dispatch;b.registerDisposer(a.segmentColorHash.changed.add(d));b.registerDisposer(a.visibleSegments.changed.add(d));b.registerDisposer(a.highlightedSegments.changed.add(d));b.registerDisposer(a.segmentEquivalences.changed.add(d));b.registerDisposer(a.segmentSelectionState.changed.add(d))}
c.d(g,"c",function(){return b});c.d(g,"a",function(){return h});g.g=a;g.f=function(b,d){a(b,d);d.registerDisposer(b.objectAlpha.changed.add(d.redrawNeeded.dispatch));d.registerDisposer(b.objectToDataTransform.changed.add(d.redrawNeeded.dispatch))};g.e=function(a,b,d){d=void 0===d?1:d;var e=r;e[3]=d;a.segmentColorHash.compute(e,b);if(a.segmentSelectionState.isSelected(b))for(var f=0;3>f;++f)e[f]=.5*e[f]+.5;f=new Float32Array(3);Object(k.b)(f,e[0],e[1],e[2]);f[1]*=a.saturation.value;var c=new Float32Array(3);
Object(k.a)(c,f[0],f[1],f[2]);e[0]=c[0];e[1]=c[1];e[2]=c[2];a.highlightedSegments.has(b)&&(e[0]=.2,e[1]=.2,e[2]=2,e[3]=1);e[0]*=d;e[1]*=d;e[2]*=d;return e};g.d=function(a,b,d){Object(f.a)(a,function(e,c){var h=Object(f.b)(e,a.clipBounds.value);h=b.get(h);void 0!==h&&d(c,e,h)})};c.d(g,"b",function(){return x});var f=c(122);p=c(0);g=c(1);var l=c(3),v=c(23),t=c(26),m=c(12),k=c(123),e=function A(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),
null!==a)return A(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},d=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),b=function(){function a(b,d){q(this,a);this.key=b;this.value=d}d(a,[{key:"toString",value:function(){return this.key+"\u2192"+this.value}}]);return a}(),
h=function(a){function e(){q(this,e);var a=u(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));a.selectedSegment=new v.a;a.hasSelectedSegment=!1;a.changed=new l.a;return a}n(e,a);d(e,[{key:"set",value:function(a){if(null==a)this.hasSelectedSegment&&(this.hasSelectedSegment=!1,this.changed.dispatch());else{var b=this.selectedSegment;this.hasSelectedSegment&&a.low===b.low&&a.high===b.high||(b.low=a.low,b.high=a.high,this.hasSelectedSegment=!0,this.changed.dispatch())}}},{key:"isSelected",
value:function(a){return this.hasSelectedSegment&&v.a.equal(a,this.selectedSegment)}},{key:"bindTo",value:function(a,d){var e=this,f=new v.a;this.registerDisposer(a.changed.add(function(){var c=a.get(d);"number"===typeof c?(f.low=c,f.high=0,c=f):c instanceof b&&(c=c.value);e.set(c)}))}}]);return e}(p.a),r=g.u.create(),x=function(a){function b(a,d){q(this,b);var e=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.chunkManager=a;e.displayState=d;e.registerDisposer(d.clipBounds.changed.add(function(){return a.chunkQueueManager.scheduleChunkUpdate()}));
return e}n(b,a);d(b,[{key:"initializeCounterpartWithChunkManager",value:function(a){var d=this.displayState;a.chunkManager=this.chunkManager.rpcId;a.visibleSegments=d.visibleSegments.rpcId;a.segmentEquivalences=d.segmentEquivalences.rpcId;a.clipBounds=d.clipBounds.rpcId;e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"initializeCounterpart",this).call(this,this.chunkManager.rpc,a)}}]);return b}(Object(t.c)(m.b))},function(p,g){},function(p,g,c){(function(g){function n(c,g){f(c);a.call(this);
var l=this;this.bufferPosition=0;this.xo=new g("POST",c,null);this.xo.on("chunk",this._chunkHandler.bind(this));this.xo.once("finish",function(a,c){f("finish",a,c);l._chunkHandler(a,c);l.xo=null;a=200===a?"network":"permanent";f("close",a);l.emit("close",null,a);l._cleanup()})}var q=c(4),a=c(13).EventEmitter,f=function(){};"production"!==g.env.NODE_ENV&&(f=c(9)("sockjs-client:receiver:xhr"));q(n,a);n.prototype._chunkHandler=function(a,c){f("_chunkHandler",a);if(200===a&&c)for(;;this.bufferPosition+=
a+1){var l=c.slice(this.bufferPosition);a=l.indexOf("\n");if(-1===a)break;if(l=l.slice(0,a))f("message",l),this.emit("message",l)}};n.prototype._cleanup=function(){f("_cleanup");this.removeAllListeners()};n.prototype.abort=function(){f("abort");this.xo&&(this.xo.close(),f("close"),this.emit("close",null,"user"),this.xo=null);this._cleanup()};p.exports=n}).call(g,c(8))},function(p,g,c){function u(c,a,f,l){n.call(this,c,a,f,l)}g=c(4);var n=c(161);g(u,n);u.enabled=n.enabled&&n.supportsCORS;p.exports=
u},function(p,g,c){c(30);c(175);c(176);var u=c(103),n=c(177),q=c(178),a=c(179),f=c(104),l=c(105);c.d(g,"a",function(){return u});c.d(g,"b",function(){return n});c.d(g,"c",function(){return q});c.d(g,"d",function(){return a});c.d(g,"e",function(){return f});c.d(g,"f",function(){return l})},function(p,g,c){function u(c,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);c.prototype=Object.create(a&&a.prototype,{constructor:{value:c,
enumerable:!1,writable:!0,configurable:!0}});a&&(Object.setPrototypeOf?Object.setPrototypeOf(c,a):c.__proto__=a)}c.d(g,"h",function(){return n});p=c(31);g.d="annotation.MetadataChunkSource";g.c="annotation.GeometryChunkSource";g.f="annotation.reference.add";g.g="annotation.reference.delete";g.b="annotation.commit";g.a="annotation.commit";var n=function(c){function a(){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");var f=(a.__proto__||Object.getPrototypeOf(a)).apply(this,
arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||"object"!==typeof f&&"function"!==typeof f?this:f}u(a,c);return a}(p.k);g.e="annotation/PerspectiveRenderLayer"},function(p,g){p.exports=function(c){var g=typeof c;return null!=c&&("object"==g||"function"==g)}},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&
f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return f});var n=c(5);p=c(12);var q=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),a=function t(a,f,e){null===a&&(a=Function.prototype);var d=
Object.getOwnPropertyDescriptor(a,f);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,f,e)}else{if("value"in d)return d.value;f=d.get;return void 0===f?void 0:f.call(e)}};g=this&&this.__decorate||function(a,f,c,e){var d=arguments.length,b=3>d?f:null===e?e=Object.getOwnPropertyDescriptor(f,c):e,h;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)b=Reflect.decorate(a,f,c,e);else for(var k=a.length-1;0<=k;k--)if(h=a[k])b=(3>d?h(b):3<d?h(f,c,b):h(f,c))||b;return 3<d&&
b&&Object.defineProperty(f,c,b),b};var f=l=function(f){function c(a,e){e=void 0===e?{}:e;if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var d=(c.__proto__||Object.getPrototypeOf(c)).call(this,a,e);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");d=!d||"object"!==typeof d&&"function"!==typeof d?this:d;d.updatingValue_=!1;void 0!==a&&(d.base=new n.f(e.value),d.setupChangedHandler());return d}u(c,f);q(c,[{key:"initializeCounterpart",
value:function(f,e){e=void 0===e?{}:e;e.value=this.value;a(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"initializeCounterpart",this).call(this,f,e)}},{key:"setupChangedHandler",value:function(){var a=this;this.registerDisposer(this.base.changed.add(function(){if(a.updatingValue_)a.updatingValue_=!1;else{var e=a.rpc;null!==e&&e.invoke("SharedWatchableValue.changed",{id:a.rpcId,value:a.value})}}))}},{key:"value",get:function(){return this.base.value},set:function(a){this.base.value=a}},
{key:"changed",get:function(){return this.base.changed}}],[{key:"makeFromExisting",value:function(a,e){var d=new l;d.base=e;d.setupChangedHandler();d.initializeCounterpart(a);return d}},{key:"make",value:function(a,e){return l.makeFromExisting(a,new n.f(e))}}]);return c}(p.c);f=l=g([Object(p.f)("SharedWatchableValue")],f);Object(p.e)("SharedWatchableValue.changed",function(a){var f=this.get(a.id);f.updatingValue_=!0;f.base.value=a.value;f.updatingValue_=!1});var l},function(p,g,c){function u(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
b):a.__proto__=b)}function a(a,b){var e=b.type,f=a.typeToIds[e],c=Object(v.f)(e),h=c.serializedBytes,k=Object(m.b)(e),r=Object(d.a)(f,b.id,function(a,b){return a<b?-1:a===b?0:1}),l=0;if(0>r){r=~r;f.splice(r,0,b.id);var g=new Uint8Array(a.data.length+h);a.numPickIds+=k.pickIdsPerInstance;l=a.typeToOffset[e]+h*r;g.set(a.data.subarray(0,l),0);g.set(a.data.subarray(l),l+h);a.data=g}else l=a.typeToOffset[e]+c.serializedBytes*r;c.serializer(a.data.buffer,a.typeToOffset[e],f.length)(b,r);b=$jscomp.makeIterator(v.e);
for(f=b.next();!f.done;f=b.next())f=f.value,f>e&&(a.typeToOffset[f]+=h);a.bufferValid=!1}function f(a,b,e){var f=a.typeToIds[b],c=Object(m.b)(b),h=c.bytes;e=Object(d.a)(f,e,function(a,b){return a<b?-1:a===b?0:1});if(0>e)return!1;a.numPickIds-=c.pickIdsPerInstance;f.splice(e,1);f=a.typeToOffset[b]+c.bytes*e;c=new Uint8Array(a.data.length-h);c.set(a.data.subarray(0,f),0);c.set(a.data.subarray(f+h),f);a.data=c;f=$jscomp.makeIterator(v.e);for(c=f.next();!c.done;c=f.next())c=c.value,c>b&&(a.typeToOffset[c]-=
h);a.bufferValid=!1;return!0}function l(){for(var a=[],b=[],d=$jscomp.makeIterator(v.e),e=d.next();!e.done;e=d.next())e=e.value,a[e]=[],b[e]=0;return new D(void 0,{data:new Uint8Array(0),numPickIds:0,typeToOffset:b,typeToIds:a})}c.d(g,"b",function(){return G});c.d(g,"a",function(){return H});var v=c(22),t=c(72),m=c(44);p=c(17);g=c(45);var k=c(64),e=c(25),d=c(39),b=c(1),h=c(3);c=c(12);var r=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=
!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),x=function C(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return C(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},z=this&&this.__decorate||function(a,b,d,e){var f=arguments.length,c=3>f?b:null===e?e=Object.getOwnPropertyDescriptor(b,d):e,
h;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)c=Reflect.decorate(a,b,d,e);else for(var k=a.length-1;0<=k;k--)if(h=a[k])c=(3>f?h(c):3<f?h(b,d,c):h(b,d))||c;return 3<f&&c&&Object.defineProperty(b,d,c),c},A=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));a.parent=d.parent;a.parameters=d.parameters;a.spec=d.spec;return a}q(b,a);r(b,[{key:"initializeCounterpart",value:function(a,d){d.parameters=this.parameters;d.parent=this.parent.rpcId;
x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"initializeCounterpart",this).call(this,a,d)}},{key:"addChunk",value:function(a,d){x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"addChunk",this).call(this,a,d)}},{key:"getChunk",value:function(a){return new D(this,a)}}]);return b}(g.c);A=z([Object(c.g)(t.c)],A);var D=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));a.bufferValid=!1;a.immediateChunkUpdates=!0;a.data=d.data;
for(var e=a.typeToIds=d.typeToIds,f=0,c=$jscomp.makeIterator(v.e),h=c.next();!h.done;h=c.next())h=h.value,f+=Object(m.b)(h).pickIdsPerInstance*e[h].length;a.numPickIds=f;a.typeToOffset=d.typeToOffset;return a}q(b,a);r(b,[{key:"freeGPUMemory",value:function(a){x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"freeGPUMemory",this).call(this,a);a=this.buffer;void 0!==a&&(a.dispose(),this.bufferValid=!1,this.buffer=void 0)}},{key:"dispose",value:function(){this.typeToOffset=this.typeToDescription=
this.typeToIds=this.data=void 0}}]);return b}(g.b),y=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));a.annotation=d.annotation;return a}q(b,a);return b}(p.b),E=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));a.parent=d;return a}q(b,a);r(b,[{key:"getChunk",value:function(a){return new y(this,a)}},{key:"addChunk",value:function(a,d){x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"addChunk",
this).call(this,a,d);a=this.parent.references.get(a);void 0!==a&&(a.value=d.annotation,a.changed.dispatch())}},{key:"deleteChunk",value:function(a){a=this.parent.references.get(a);void 0!==a&&(a.value=void 0,a.changed.dispatch())}},{key:"initializeCounterpart",value:function(a,d){d.parent=this.parent.rpcId;x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"initializeCounterpart",this).call(this,a,d)}}]);return b}(p.e);E=z([Object(c.g)(t.d)],E);var G=function(d){function c(a,d){u(this,c);
var e=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));e.chunkManager=a;e.metadataChunkSource=e.registerDisposer(new E(e.chunkManager,e));e.objectToLocal=b.k.create();e.temporary=l();e.references=new Map;e.localUpdates=new Map;e.numCommitsInProgress=0;e.changed=new h.a;e.readonly=!1;e.sources=d.sourceSpecifications.map(function(b){return b.map(function(b){return e.registerDisposer(new A(a,{spec:b.spec,parameters:b.parameters,parent:e}))})});return e}q(c,d);$jscomp.initSymbol();$jscomp.initSymbolIterator();
r(c,[{key:"getSources",value:function(a){a=this.sources;a.forEach(function(a){return a.forEach(function(a){return a.addRef()})});return a}},{key:"initializeCounterpart",value:function(a,b){this.metadataChunkSource.initializeCounterpart(a,{});for(var d=$jscomp.makeIterator(this.sources),e=d.next();!e.done;e=d.next()){e=$jscomp.makeIterator(e.value);for(var f=e.next();!f.done;f=e.next())f.value.initializeCounterpart(a,{})}b.metadataChunkSource=this.metadataChunkSource.addCounterpartRef();b.sources=
this.sources.map(function(a){return a.map(function(a){return a.addCounterpartRef()})});b.chunkManager=this.chunkManager.rpcId;x(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"initializeCounterpart",this).call(this,a,b)}},{key:"add",value:function(a,b){b=void 0===b?!0:b;a.id=Object(v.g)();var d=new v.a(a.id);d.value=a;this.applyLocalUpdate(d,!1,b,a);return d}},{key:"applyLocalUpdate",value:function(b,d,e,c){var h=this.localUpdates,k=b.id,r=this.localUpdates.get(k),l=b.value;if(null==l)throw Error("Cannot create local update from null annotation");
void 0===r?(r={type:l.type,reference:b.addRef(),existingAnnotation:d?l:void 0,pendingCommit:void 0,commitInProgress:void 0},h.set(k,r),this.forEachPossibleChunk(l,function(a,b){a;f(b,l.type,k)}),null!==c&&a(this.temporary,c)):null===c?f(this.temporary,l.type,l.id):a(this.temporary,c);if(e)if(void 0!==r.commitInProgress)r.pendingCommit=c;else{if(null===c&&void 0===r.existingAnnotation){h.delete(k);r.reference.dispose();return}this.sendCommitRequest(r,c)}this.notifyChanged(b.id,c||void 0)}},{key:"sendCommitRequest",
value:function(a,b){this.updateCommitsInProgress(1);a.commitInProgress=b;this.rpc.invoke(t.b,{id:this.rpcId,annotationId:a.existingAnnotation&&a.reference.id,newAnnotation:b})}},{key:"delete",value:function(a){this.applyLocalUpdate(a,!0,!0,null)}},{key:"update",value:function(a,b){this.applyLocalUpdate(a,!0,!1,b)}},{key:"notifyChanged",value:function(a,b){var d=this.references.get(a);a=this.metadataChunkSource.chunks.get(a);void 0!==a&&(a.annotation=b||null);void 0!==d&&(d.value=b||null,d.changed.dispatch());
this.chunkManager.chunkQueueManager.visibleChunksChanged.dispatch()}},{key:"commit",value:function(a){this.applyLocalUpdate(a,!0,!0,a.value)}},{key:"getReference",value:function(a){var b=this,d=this.references.get(a);if(void 0!==d)return d.addRef();d=new v.a(a);this.references.set(a,d);this.rpc.invoke(t.f,{id:this.rpcId,annotation:a});d.registerDisposer(function(){b.references.delete(a);b.rpc.invoke(t.g,{id:b.rpcId,annotation:a})});var e=this.metadataChunkSource.chunks.get(a);void 0!==e&&(d.value=
e.annotation);return d}},{key:"forEachPossibleChunk",value:function(a,b){var d=this.sources;if(1!==d.length||1!==d[0].length)throw Error("Not implemented");d=d[0][0];if(1<d.chunks.size)throw Error("Not implemented");a;a=$jscomp.makeIterator(d.chunks);for(d=a.next();!d.done;d=a.next()){var e=$jscomp.makeIterator(d.value);d=e.next().value;e=e.next().value;b(d,e)}}},{key:"handleSuccessfulUpdate",value:function(b,d){var e=this.localUpdates.get(b);if(void 0===e||void 0===e.commitInProgress)throw Error("Received invalid successful update notification");
this.updateCommitsInProgress(-1);if(null!==d&&e.reference.id!==d.id){if(null===e.commitInProgress)throw Error("Received invalid successful update notification");e.reference.id=d.id;this.localUpdates.delete(b);this.localUpdates.set(d.id,e);null!==e.reference.value&&(e.reference.value.id=d.id,f(this.temporary,e.type,b),a(this.temporary,e.reference.value));e.reference.changed.dispatch()}e.existingAnnotation=d||void 0;e.commitInProgress=void 0;b=e.pendingCommit;e.pendingCommit=void 0;null===d&&(b=void 0);
void 0!==b?(null!==b&&(b.id=d.id),this.sendCommitRequest(e,b)):this.revertLocalUpdate(e)}},{key:"disposed",value:function(){var a=this.commitStatus;void 0!==a&&a.dispose()}},{key:"updateCommitsInProgress",value:function(a){this.numCommitsInProgress+=a;0===this.numCommitsInProgress?void 0!==this.commitStatus&&(this.commitStatus.dispose(),this.commitStatus=void 0):void 0===this.commitStatus&&(this.commitStatus=new e.a(!0)).setText("Commiting annotations")}},{key:"handleFailedUpdate",value:function(a,
b){a=this.localUpdates.get(a);if(void 0===a||void 0===a.commitInProgress)throw Error("Received invalid update notification");(new e.a).setErrorMessage("Error commiting annotation update: "+b);this.revertLocalUpdate(a);this.updateCommitsInProgress(-1)}},{key:"revertLocalUpdate",value:function(b){f(this.temporary,b.type,b.reference.id);var d=b.existingAnnotation;void 0!==d&&this.forEachPossibleChunk(d,function(b,e){b;a(e,d)});b=b.reference;var e=b.id;b.value=d||null;b.changed.dispatch();b.dispose();
this.localUpdates.delete(e)}},{key:Symbol.iterator,value:function(){function a(a,d){for(;;)switch(b){case 0:b=-1;default:return{value:void 0,done:!0}}}var b=0,d={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();d[Symbol.iterator]=function(){return this};return d}}],[{key:"encodeOptions",value:function(a){return{}}}]);return c}(c.b);Object(c.e)(t.a,function(a){var b=this.get(a.id),d=a.annotationId,
e=a.error;void 0!==e?b.handleFailedUpdate(d,e):b.handleSuccessfulUpdate(d,a.newAnnotation)});var H=function(a){function b(a){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a.chunkManager,a.getSources({})))}q(b,a);r(b,[{key:"draw",value:function(){}}]);return b}(k.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return e});g.e=function(a,b,d,e){d=void 0===d?a.RGBA:d;e=void 0===e?a.UNSIGNED_BYTE:e;for(var f=[],c=0;c<b;++c)f[c]=
new h(a,d,e);return f};c.d(g,"b",function(){return x});c.d(g,"c",function(){return z});p=c(0);var a=c(1),f=c(24),l=c(51),v=c(65),t=c(112),m=function D(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return D(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},k=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in
e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}();c=function(a){function b(){u(this,b);var a=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));a.width=Number.NaN;a.height=Number.NaN;return a}q(b,a);k(b,[{key:"hasSize",value:function(a,b){return this.width===a&&this.height===b}},{key:"resize",value:function(a,b){this.hasSize(a,b)||(this.width=a,this.height=b,this.performResize())}}]);return b}(p.a);var e=function(a){function b(a,
d){d=void 0===d?!1:d;u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d?a.DEPTH_STENCIL:a.DEPTH_COMPONENT16));e.gl=a;e.includeStencilBuffer=d;return e}q(b,a);k(b,[{key:"attachToFramebuffer",value:function(){var a=this.gl;m(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"attachToFramebuffer",this).call(this,this.includeStencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT)}}]);return b}(function(a){function b(a,d){u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));
e.gl=a;e.internalformat=d;e.renderbuffer=null;e.renderbuffer=a.createRenderbuffer();return e}q(b,a);k(b,[{key:"performResize",value:function(){var a=this.gl;a.bindRenderbuffer(a.RENDERBUFFER,this.renderbuffer);a.renderbufferStorage(a.RENDERBUFFER,this.internalformat,this.width,this.height);a.bindRenderbuffer(a.RENDERBUFFER,null)}},{key:"disposed",value:function(){this.gl.deleteRenderbuffer(this.renderbuffer)}},{key:"attachToFramebuffer",value:function(a){var b=this.gl;b.framebufferRenderbuffer(b.FRAMEBUFFER,
a,b.RENDERBUFFER,this.renderbuffer)}}]);return b}(c)),d=function(a){function b(a){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,!0))}q(b,a);return b}(e);g.d=d;var b=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.gl=a;d.framebuffer=d.gl.createFramebuffer();return d}q(b,a);k(b,[{key:"disposed",value:function(){this.gl.deleteFramebuffer(this.framebuffer)}},{key:"bind",value:function(){var a=this.gl;a.bindFramebuffer(a.FRAMEBUFFER,
this.framebuffer)}},{key:"unbind",value:function(){var a=this.gl;a.bindFramebuffer(a.FRAMEBUFFER,null)}}]);return b}(p.a),h=function(a){function b(a,d,e){u(this,b);var f=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));f.gl=a;f.format=d;f.dataType=e;f.texture=a.createTexture();return f}q(b,a);k(b,[{key:"performResize",value:function(){Object(v.a)(this.gl,this.texture,this.width,this.height,this.format,this.dataType)}},{key:"disposed",value:function(){this.gl.deleteTexture(this.texture)}},
{key:"attachToFramebuffer",value:function(a){var b=this.gl;b.framebufferTexture2D(b.FRAMEBUFFER,a,b.TEXTURE_2D,this.texture,0)}}]);return b}(c),r=new Uint8Array(4),x=function(a){function d(a,e){u(this,d);var f=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));f.gl=a;f.width=Number.NaN;f.height=Number.NaN;f.fullAttachmentList=[];f.attachmentVerified=!1;f.singleAttachmentList=[f.gl.COLOR_ATTACHMENT0];var c=void 0===e.framebuffer?new b(a):e.framebuffer,h=e.colorBuffers;e=e.depthBuffer;f.framebuffer=
f.registerDisposer(c);f.colorBuffers=h;f.depthBuffer=e;void 0!==e&&f.registerDisposer(e);var k=f.fullAttachmentList;h.forEach(function(b,d){f.registerDisposer(b);k[d]=a.COLOR_ATTACHMENT0+d});return f}q(d,a);k(d,[{key:"hasSize",value:function(a,b){return this.width===a&&this.height===b}},{key:"bind",value:function(a,b){this.width=a;this.height=b;this.framebuffer.bind();var d=this.gl,e=this.depthBuffer;void 0!==e&&(e.resize(a,b),e.attachToFramebuffer());this.colorBuffers.forEach(function(e,f){e.resize(a,
b);e.attachToFramebuffer(d.COLOR_ATTACHMENT0+f)});d.WEBGL_draw_buffers.drawBuffersWEBGL(this.fullAttachmentList);this.verifyAttachment();d.viewport(0,0,a,b)}},{key:"bindSingle",value:function(a){var b=this.gl;this.framebuffer.bind();0!==a&&b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0+a,b.TEXTURE_2D,null,0);b.bindTexture(b.TEXTURE_2D,null);this.colorBuffers[a].attachToFramebuffer(b.COLOR_ATTACHMENT0);b.WEBGL_draw_buffers.drawBuffersWEBGL(this.singleAttachmentList)}},{key:"unbind",value:function(){this.framebuffer.unbind()}},
{key:"readPixel",value:function(a,b,d){var e=this.gl;try{this.bindSingle(a),e.readPixels(b,d,1,1,e.RGBA,e.UNSIGNED_BYTE,r)}finally{this.framebuffer.unbind()}return r}},{key:"readPixelAsUint32",value:function(a,b,d){a=this.readPixel(a,b,d);return a[0]+(a[1]<<8)+(a[2]<<16)+(a[3]<<24)}},{key:"verifyAttachment",value:function(){if(!this.attachmentVerified){var a=this.gl;if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error("Framebuffer configuration not supported");this.attachmentVerified=
!0}}}]);return d}(p.a),z=function(b){function d(a,b){u(this,d);var e=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.gl=a;e.shader=b;e.copyVertexPositionsBuffer=Object(l.a)(e.gl);e.copyTexCoordsBuffer=Object(l.a)(e.gl,0,0,1,1);e.registerDisposer(b);return e}q(d,b);k(d,[{key:"draw",value:function(b){for(var d=[],e=0;e<arguments.length;++e)d[e-0]=arguments[e];e=this.gl;var f=this.shader;f.bind();for(var c=d.length,h=0;h<c;++h)e.activeTexture(e.TEXTURE0+h),e.bindTexture(e.TEXTURE_2D,d[h]);
e.uniformMatrix4fv(f.uniform("uProjectionMatrix"),!1,a.d);d=f.attribute("aVertexPosition");this.copyVertexPositionsBuffer.bindToVertexAttrib(d,2);f=f.attribute("aTexCoord");this.copyTexCoordsBuffer.bindToVertexAttrib(f,2);e.drawArrays(e.TRIANGLE_FAN,0,4);e.disableVertexAttribArray(d);e.disableVertexAttribArray(f);for(d=0;d<c;++d)e.activeTexture(e.TEXTURE0+d),e.bindTexture(e.TEXTURE_2D,null)}}],[{key:"get",value:function(a,b,e){b=void 0===b?t.a:b;e=void 0===e?1:e;return a.memoize.get("OffscreenCopyHelper:"+
e+":"+Object(f.a)(b),function(){return new d(a,Object(t.b)(a,b,e))})}}]);return d}(p.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a){for(var f=new Uint16Array(6*a),c=0;c<a;++c){var k=4*c,e=6*c;f[e]=k;
f[e+1]=k+1;f[e+2]=k+2;f[e+3]=k+2;f[e+4]=k+3;f[e+5]=k}return f}c.d(g,"a",function(){return l});p=c(0);var q=c(15),a=c(11),f=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}();g.b=4;var l=function(c){function l(f,c){if(!(this instanceof l))throw new TypeError("Cannot call a class as a function");var e=(l.__proto__||
Object.getPrototypeOf(l)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.quadsPerInstance=c;1!==c&&(e.quadIndexBuffer=e.registerDisposer(Object(q.b)(f,a.f,n,c)).value);return e}u(l,c);f(l,[{key:"draw",value:function(f,c){1===this.quadsPerInstance?f.ANGLE_instanced_arrays.drawArraysInstancedANGLE(a.D,0,4,c):(this.quadIndexBuffer.bind(),f.ANGLE_instanced_arrays.drawElementsInstancedANGLE(a.C,
6*this.quadsPerInstance,a.H,0,c))}}]);return l}(p.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return f});p=c(0);var n=c(77),q=c(51),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=
f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,l){c&&a(f.prototype,c);l&&a(f,l);return f}}();g.b=4;var f=function(f){function c(a,f){f=void 0===f?1:f;if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var k=(c.__proto__||Object.getPrototypeOf(c)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");k=!k||"object"!==typeof k&&"function"!==
typeof k?this:k;k.circlesPerInstance=f;k.squareCornersBuffer=Object(q.a)(a,-1,-1,1,1,f,1);k.quadHelper=k.registerDisposer(new n.a(a,f));return k}u(c,f);a(c,[{key:"defineShader",value:function(a,f){a.addAttribute("highp vec2","aCircleCornerOffset");a.addUniform("highp vec4","uCircleParams");a.addVarying("highp vec2","vCircleCoord");a.addVertexCode("\nvoid emitCircle(vec4 position) {\n  gl_Position = position;\n  gl_Position.xy += aCircleCornerOffset * uCircleParams.xy * gl_Position.w;\n  vCircleCoord = aCircleCornerOffset;\n}\n");
f?a.addFragmentCode("\nfloat getCircleAlphaMultiplier() {\n  return 1.0 - 2.0 * abs(0.5 - gl_FragCoord.z);\n}\n"):a.addFragmentCode("\nfloat getCircleAlphaMultiplier() {\n  return 1.0;\n}\n");a.addFragmentCode("\nvec4 getCircleColor(vec4 interiorColor, vec4 borderColor) {\n  float radius = length(vCircleCoord);\n  if (radius > 1.0) {\n    discard;\n  }\n\n  float borderColorFraction = clamp((radius - uCircleParams.z) / uCircleParams.w, 0.0, 1.0);\n  float feather = clamp((1.0 - radius) / uCircleParams.w, 0.0, 1.0);\n  vec4 color = mix(interiorColor, borderColor, borderColorFraction);\n\n  return vec4(color.rgb, color.a * feather * getCircleAlphaMultiplier());\n}\n")}},
{key:"draw",value:function(a,f,c,e){var d=a.gl,b=a.attribute("aCircleCornerOffset");this.squareCornersBuffer.bindToVertexAttrib(b,2);var h=c.interiorRadiusInPixels+c.borderWidthInPixels+c.featherWidthInPixels;d.uniform4f(a.uniform("uCircleParams"),h/f.viewportWidth,h/f.viewportHeight,c.interiorRadiusInPixels/h,c.featherWidthInPixels/h);this.quadHelper.draw(d,e);a.gl.disableVertexAttribArray(b)}}]);return c}(p.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){a.addFragmentCode("\nvoid emit(vec4 color, vec4 pickId) {\n  gl_FragColor = color;\n}\n")}
function f(a){a.addFragmentCode("\nvoid emit(vec4 color, vec4 pickId) {\n  gl_FragColor = pickId;\n}\n")}c.d(g,"b",function(){return A});c.d(g,"a",function(){return y});var l=c(115),v=c(14),t=c(116);p=c(117);var m=c(45),k=c(19),e=c(1),d=c(120),b=c(11),h=c(76),r=c(81),x=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),
z;(function(a){a[a.COLOR=0]="COLOR";a[a.PICK=1]="PICK";a[a.NUM_TEXTURES=2]="NUM_TEXTURES"})(z||(z={}));var A=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);x(b,[{key:"draw",value:function(a){}},{key:"isReady",value:function(){return!0}}]);return b}(v.i),D=e.u.create(),y=function(c){function g(b,f,c,x){u(this,g);var q=n(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,b,f,x));q.sliceView=c;q.axesLineHelper=q.registerDisposer(l.a.get(q.gl));
q.sliceViewRenderHelper=q.registerDisposer(m.d.get(q.gl,a));q.colorFactor=e.u.fromValues(1,1,1,1);q.pickIDs=new t.a;q.visibleLayerTracker=Object(v.k)(q.viewer.layerManager,A,q.viewer.visibleLayerRoles,q);q.offscreenFramebuffer=q.registerDisposer(new h.b(q.gl,{colorBuffers:Object(h.e)(q.gl,z.NUM_TEXTURES)}));q.offscreenCopyHelper=q.registerDisposer(h.c.get(q.gl));q.scaleBarCopyHelper=q.registerDisposer(h.c.get(q.gl));q.scaleBarTexture=q.registerDisposer(new r.a(q.gl));Object(k.c)(f,"translate-via-mouse-drag",
function(a){q.viewer.mouseState.updateUnconditionally()&&Object(d.a)(a.detail,function(a,b,d){a=q.viewer.navigationState.position;var f=a.spatialCoordinates;e.s.set(f,b,d,0);e.s.transformMat4(f,f,q.sliceView.viewportToData);a.changed.dispatch()})});Object(k.c)(f,"rotate-via-mouse-drag",function(a){var b=q.viewer.mouseState;if(b.updateUnconditionally()){var f=e.s.clone(b.position);Object(d.a)(a.detail,function(a,b,d){a=q.sliceView.viewportAxes;q.viewer.navigationState.pose.rotateAbsolute(a[1],b/4*
Math.PI/180,f);q.viewer.navigationState.pose.rotateAbsolute(a[0],d/4*Math.PI/180,f)})}});q.registerDisposer(c);q.registerDisposer(x.crossSectionBackgroundColor.changed.add(function(){return q.scheduleRedraw()}));q.registerDisposer(c.visibility.add(q.visibility));q.registerDisposer(c.viewChanged.add(function(){q.visible&&b.scheduleRedraw()}));q.registerDisposer(x.showAxisLines.changed.add(function(){q.visible&&q.scheduleRedraw()}));q.registerDisposer(x.showScaleBar.changed.add(function(){q.visible&&
q.context.scheduleRedraw()}));return q}q(g,c);x(g,[{key:"isReady",value:function(){if(!this.visible||!this.sliceView.isReady())return!1;var a=this.visibleLayerTracker.getVisibleLayers();a=$jscomp.makeIterator(a);for(var b=a.next();!b.done;b=a.next())if(!b.value.isReady())return!1;return!0}},{key:"draw",value:function(){var d=this.sliceView;this.onResize();d.updateRendering();if(d.hasValidViewport){var c=this.gl,h=d.width,k=d.height,r=d.dataToDevice;this.offscreenFramebuffer.bind(h,k);c.disable(b.t);
this.gl.clearColor(0,0,0,0);c.clear(b.d);var l=e.k.create(),g=this.viewer.crossSectionBackgroundColor.value;D[0]=g[0];D[1]=g[1];D[2]=g[2];D[3]=1;this.sliceViewRenderHelper.draw(d.offscreenFramebuffer.colorBuffers[0].texture,e.d,this.colorFactor,D,0,0,1,1);g=this.visibleLayerTracker.getVisibleLayers();var m=this.pickIDs;m.clear();this.offscreenFramebuffer.bindSingle(z.COLOR);m={dataToDevice:d.dataToDevice,pickIDs:m,emitter:a,emitColor:!0,emitPickID:!1,viewportWidth:h,viewportHeight:k,sliceView:d};
c.enable(b.b);c.blendFunc(b.u,b.p);for(var t=$jscomp.makeIterator(g),v=t.next();!v.done;v=t.next())v.value.draw(m);c.disable(b.b);this.offscreenFramebuffer.bindSingle(z.PICK);m.emitColor=!1;m.emitPickID=!0;m.emitter=f;g=$jscomp.makeIterator(g);for(v=g.next();!v.done;v=g.next())v.value.draw(m);if(this.viewer.showAxisLines.value||this.viewer.showScaleBar.value){if(this.viewer.showAxisLines.value){e.k.copy(l,r);for(r=0;3>r;++r)l[12+r]=0;for(r=0;4>r;++r)l[2+4*r]=0;k=Math.min(h,k)/4*1.5;r=d.pixelSize;
for(g=0;12>g;++g)l[g]=l[g]*k*r}this.offscreenFramebuffer.bindSingle(z.COLOR);this.viewer.showAxisLines.value&&this.axesLineHelper.draw(l);this.viewer.showScaleBar.value&&(c.enable(b.b),c.blendFunc(b.u,b.p),l=this.scaleBarTexture,k=l.dimensions,k.targetLengthInPixels=Math.min(h/4,100),k.nanometersPerPixel=d.pixelSize,l.update(),c.viewport(10,10,l.width,l.height),this.scaleBarCopyHelper.draw(l.texture),c.disable(b.b))}this.offscreenFramebuffer.unbind();this.setGLViewport();this.offscreenCopyHelper.draw(this.offscreenFramebuffer.colorBuffers[z.COLOR].texture)}}},
{key:"onResize",value:function(){this.sliceView.setViewportSizeDebounced(this.element.clientWidth,this.element.clientHeight)}},{key:"updateMouseState",value:function(a){a.pickedRenderLayer=null;var b=this.sliceView;if(!b.hasValidViewport)return!1;var d=b.width,f=b.height,c=this.offscreenFramebuffer;if(!c.hasSize(d,f))return!1;var h=a.position,k=this.mouseX,r=this.mouseY;e.s.set(h,k-d/2,r-f/2,0);e.s.transformMat4(h,h,b.viewportToData);this.pickIDs.setMouseState(a,c.readPixelAsUint32(z.PICK,k,f-r));
return!0}},{key:"zoomByMouse",value:function(a){var b=this.navigationState;if(b.valid){var d=this.sliceView,f=d.height,c=this.mouseX,h=this.mouseY;c-=d.width/2;h-=f/2;f=this.navigationState.zoomFactor.value;b.zoomBy(a);a=b.zoomFactor.value;var k=b.position.spatialCoordinates;e.s.scaleAndAdd(k,k,d.viewportAxes[0],c*(f-a));e.s.scaleAndAdd(k,k,d.viewportAxes[1],h*(f-a));b.position.changed.dispatch()}}},{key:"navigationState",get:function(){return this.sliceView.navigationState}}]);return g}(p.a)},function(p,
g,c){g.a=function(c,g){if(c.active&&void 0!==c.pickedAnnotationId){var n=c.pickedRenderLayer;if(null!==n){var a=c.pickedAnnotationLayer;if(void 0!==a&&(g=g.renderLayerToManagedLayerMap.get(n),void 0!==g))return{layer:g,annotationLayer:a,id:c.pickedAnnotationId,partIndex:c.pickedOffset}}}};g.b=function(c,g){c.registerDisposer(g.changed.add(function(){c.hoverState.value=g.active&&g.pickedAnnotationLayer===c?{id:g.pickedAnnotationId,partIndex:g.pickedOffset}:void 0}))}},function(p,g,c){function u(a,
d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function n(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function q(a){for(var d=t.length,b=t[d-1],e=0;e<d;++e){var f=t[e];if(a>=f.lengthInNanometers){b=f;break}}return b}
g.b=q;g.c=function(a){for(var d=t.length,b=t[d-1],e=0;e<d;++e){var f=t[e];if(a>=Math.pow(f.lengthInNanometers,3)){b=f;break}}return b};c.d(g,"a",function(){return k});p=c(0);var a=c(65),f=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;return void 0===f?void 0:f.call(c)}},l=function(){function a(a,d){for(var b=0;b<d.length;b++){var f=d[b];f.enumerable=
f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,d,f){d&&a(b.prototype,d);f&&a(b,f);return b}}(),v=[1.5,2,3,5,7.5,10],t=[{unit:"km",lengthInNanometers:1E12},{unit:"m",lengthInNanometers:1E9},{unit:"mm",lengthInNanometers:1E6},{unit:"\u00b5m",lengthInNanometers:1E3},{unit:"nm",lengthInNanometers:1},{unit:"pm",lengthInNanometers:.001}],m=function(){function a(){n(this,a);this.allowedSignificands=v;this.prevTargetLengthInPixels=this.prevNanometersPerPixel=
this.nanometersPerPixel=this.targetLengthInPixels=0}l(a,[{key:"update",value:function(){var a=this.nanometersPerPixel,d=this.targetLengthInPixels;if(this.prevNanometersPerPixel===a&&this.prevTargetLengthInPixels===d)return!1;this.prevNanometersPerPixel=a;this.prevTargetLengthInPixels=d;var f=d*a;d=Math.pow(10,Math.floor(Math.log(f)/Math.LN10));f/=d;for(var c=1,k=$jscomp.makeIterator(this.allowedSignificands),l=k.next();!l.done;l=k.next())if(l=l.value,Math.abs(l-f)<Math.abs(c-f))c=l;else break;d*=
c;f=q(d);this.lengthInPixels=Math.round(d/a);this.physicalUnit=f.unit;this.physicalLength=d/f.lengthInNanometers;return!0}}]);return a}(),k=function(d){function b(a,d){d=void 0===d?new m:d;n(this,b);var f=(b.__proto__||Object.getPrototypeOf(b)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");f=!f||"object"!==typeof f&&"function"!==typeof f?this:f;f.gl=a;f.dimensions=d;f.texture=null;f.width=0;f.height=0;return f}u(b,d);l(b,[{key:"update",value:function(){var b=
this.dimensions,d=this.texture;if(b.update()||null===d){null===d&&(d=this.texture=this.gl.createTexture());var f=this.gl,c=document.createElement("canvas"),k=c.getContext("2d");k.font="bold 15px sans-serif";k.fillStyle="white";var l=b.physicalLength+" "+b.physicalUnit,g=k.measureText(l);g=Math.max(b.lengthInPixels,g.width)+4;c.width=g;c.height=32;k.font="bold 15px sans-serif";k.textAlign="center";k.fillStyle="rgba(0, 0, 0, 0.3)";k.fillRect(0,0,g,32);k.fillStyle="white";k.fillText(l,g/2,17);k.fillRect(2,
22,b.lengthInPixels,8);Object(a.c)(f,d,c);this.width=g;this.height=32}}},{key:"disposed",value:function(){this.gl.deleteTexture(this.texture);this.texture=null;f(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}}]);return b}(p.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==
typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){switch(a){case e.b.FLOAT32:return A.g;default:throw Error("Data type not supported by WebGL: ${DataType[dataType]}");}}g.f=function(a){return new k.c(void 0===
a?"void main() {\n  emitDefault();\n}\n":a,h.B)};c.d(g,"c",function(){return M});c.d(g,"b",function(){return I});c.d(g,"e",function(){return P});c.d(g,"d",function(){return T});var f=c(36);p=c(17);var l=c(52),v=c(67),t=c(214),m=c(79),k=c(5),e=c(43),d=c(0),b=c(1),h=c(2),r=c(24),x=c(3),z=c(15),A=c(11),D=c(27),y=c(16),E=function aa(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return aa(a,b,d)}else{if("value"in
e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},G=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),H=c(83),B=b.k.create(),C=new Float32Array(4);g.a="//NEUROGLANCER_SKELETON_LAYER_FRAGMENT_MAIN_START";var F=function(a){function d(a){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));
b.vertexAttributes=a;b.shaders=new Map;b.shaderGeneration=-1;b.vertexAttributesKey=Object(h.g)(b.vertexAttributes);return b}q(d,a);G(d,[{key:"defineShader",value:function(a,b){a.addUniform("highp vec4","uColor");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");var d="\ngl_Position = uProjection * vec4(aVertex0, 1.0);\n";a.addFragmentCode("\nvec4 segmentColor() {\n  return uColor;\n}\nvoid emitRGB(vec3 color) {\n  emit(vec4(color * uColor.a, uColor.a), uPickID);\n}\nvoid emitDefault() {\n  emit(uColor, uPickID);\n}\n");
a.addFragmentCode(H);this.vertexAttributes.forEach(function(b,e){a.addAttribute("highp "+b.glslDataType,"aVertex"+e);0!==e&&(a.addVarying("highp "+b.glslDataType,"vVertex"+e),d+="vVertex"+e+" = aVertex"+e+";\n",a.addFragmentCode("#define "+b.name+" vVertex"+e+"\n"))});a.setVertexMain(d);a.setFragmentMainFunction("//NEUROGLANCER_SKELETON_LAYER_FRAGMENT_MAIN_START\n"+b)}},{key:"beginLayer",value:function(a,d,e,f){e=b.k.multiply(B,e.dataToDevice,f);a.uniformMatrix4fv(d.uniform("uProjection"),!1,e)}},
{key:"getShader",value:function(a,b,d){var e=this;return this.registerDisposer(a.memoize.get("skeleton/SkeletonShaderManager:"+Object(r.a)(b)+":"+this.vertexAttributesKey+":"+d,function(){var f=new D.a(a);f.require(b);e.defineShader(f,d);return f.build()}))}},{key:"setColor",value:function(a,b,d){a.uniform4fv(b.uniform("uColor"),d)}},{key:"setPickID",value:function(a,b,d){a.uniform4fv(b.uniform("uPickID"),Object(y.r)(C,d))}},{key:"drawSkeleton",value:function(a,b,d){for(var e=this.vertexAttributes,
f=e.length,c=d.vertexAttributeOffsets,h=0;h<f;++h){var k=e[h];d.vertexBuffer.bindToVertexAttrib(b.attribute("aVertex"+h),k.numComponents,k.webglDataType,!1,0,c[h])}d.indexBuffer.bind();a.drawElements(a.LINES,d.numIndices,a.UNSIGNED_INT,0)}},{key:"endLayer",value:function(a,b){for(var d=this.vertexAttributes.length,e=0;e<d;++e)a.disableVertexAttribArray(b.attribute("aVertex"+e))}}]);return d}(d.a),M=function(d){function e(d,f,c,h){u(this,e);var k=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));
k.chunkManager=d;k.source=f;k.voxelSizeObject=c;k.displayState=h;k.tempMat=b.k.create();k.redrawNeeded=new x.a;k.fallbackFragmentMain="void main() {\n  emitDefault();\n}\n";Object(v.f)(h,k);k.displayState.shaderError.value=void 0;k.registerDisposer(h.fragmentMain.changed.add(function(){k.displayState.shaderError.value=void 0;k.redrawNeeded.dispatch()}));d=k.sharedObject=k.registerDisposer(new v.b(d,h));d.RPC_TYPE_ID=t.a;d.initializeCounterpartWithChunkManager({source:f.addCounterpartRef()});d=k.vertexAttributes=
[N];f=$jscomp.makeIterator(f.vertexAttributes);for(c=f.next();!c.done;c=f.next())h=$jscomp.makeIterator(c.value),c=h.next().value,h=h.next().value,d.push({name:c,dataType:h.dataType,numComponents:h.numComponents,webglDataType:a(h.dataType),glslDataType:1<h.numComponents?"vec"+h.numComponents:"float"});return k}q(e,d);G(e,[{key:"getShader",value:function(a,b,d){var e=this.displayState.fragmentMain,f=e.changed.count,c=b.shaders;b.shaderGeneration!==f&&(c.clear(),b.shaderGeneration=f);f=c.get(d);if(void 0===
f){f=null;try{f=b.getShader(a,d,e.value),this.fallbackFragmentMain=e.value,this.displayState.shaderError.value=null}catch(Y){this.displayState.shaderError.value=Y;try{f=b.getShader(a,d,this.fallbackFragmentMain)}catch(Ca){}}c.set(d,f)}return f}},{key:"draw",value:function(a,d,e,c){void 0===c&&(c=a.emitColor?1:5);var h=this.gl,k=this.source,r=this.displayState,l=Math.min(1,r.objectAlpha.value);if(!(0>=l)){var g=this.getShader(h,e,a.emitter);if(null!==g){g.bind();var m=this.tempMat;b.k.identity(m);
k.skeletonVertexCoordinatesInVoxels&&b.k.scale(m,m,this.voxelSizeObject.size);b.k.multiply(m,this.displayState.objectToDataTransform.transform,m);e.beginLayer(h,g,a,m);k=k.chunks;var t=a.pickIDs;h.lineWidth(c);Object(v.d)(r,k,function(b,c,k){k.state===f.d.GPU_MEMORY&&(a.emitColor&&e.setColor(h,g,Object(v.e)(r,b,l)),a.emitPickID&&e.setPickID(h,g,t.registerUint64(d,c)),e.drawSkeleton(h,g,k))});e.endLayer(h,g)}}}},{key:"visibility",get:function(){return this.sharedObject.visibility}},{key:"gl",get:function(){return this.chunkManager.chunkQueueManager.gl}}]);
return e}(d.a),I=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.base=a;d.renderHelper=d.registerDisposer(new F(d.base.vertexAttributes));d.registerDisposer(a);d.registerDisposer(a.redrawNeeded.add(function(){d.redrawNeeded.dispatch()}));d.setReady(!0);d.registerDisposer(a.visibility.add(d.visibility));return d}q(b,a);G(b,[{key:"draw",value:function(a){this.base.draw(a,this,this.renderHelper)}},{key:"gl",get:function(){return this.base.gl}},{key:"isTransparent",
get:function(){return 1>this.base.displayState.objectAlpha.value}}]);return b}(l.a),P=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.base=a;d.renderHelper=d.registerDisposer(new F(d.base.vertexAttributes));d.registerDisposer(a);d.registerDisposer(a.redrawNeeded.add(function(){d.redrawNeeded.dispatch()}));d.setReady(!0);d.registerDisposer(a.visibility.add(d.visibility));return d}q(b,a);G(b,[{key:"draw",value:function(a){this.base.draw(a,this,
this.renderHelper,10)}},{key:"gl",get:function(){return this.base.gl}}]);return b}(m.b),N={dataType:e.b.FLOAT32,numComponents:3,name:"",webglDataType:A.g,glslDataType:"vec3"},U=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));a.vertexAttributes=d.vertexAttributes;var e=a.indices=d.indices;a.vertexAttributeOffsets=d.vertexAttributeOffsets;a.numIndices=e.length;return a}q(b,a);G(b,[{key:"copyToGPU",value:function(a){E(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),
"copyToGPU",this).call(this,a);this.vertexBuffer=z.a.fromData(a,this.vertexAttributes,a.ARRAY_BUFFER,a.STATIC_DRAW);this.indexBuffer=z.a.fromData(a,this.indices,a.ELEMENT_ARRAY_BUFFER,a.STATIC_DRAW)}},{key:"freeGPUMemory",value:function(a){E(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"freeGPUMemory",this).call(this,a);this.vertexBuffer.dispose();this.indexBuffer.dispose()}}]);return b}(p.b),O=new Map,T=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,
arguments))}q(b,a);G(b,[{key:"getChunk",value:function(a){return new U(this,a)}},{key:"skeletonVertexCoordinatesInVoxels",get:function(){return!0}},{key:"vertexAttributes",get:function(){return O}}]);return b}(p.e)},function(p,g){p.exports="\n\nvec3 colormapJet(float x) {\n  vec3 result;\n  result.r = x < 0.89 ? ((x - 0.35) / 0.31) : (1.0 - (x - 0.89) / 0.11 * 0.5);\n  result.g = x < 0.64 ? ((x - 0.125) * 4.0) : (1.0 - (x - 0.64) / 0.27);\n  result.b = x < 0.34 ? (0.5 + x * 0.5 / 0.11) : (1.0 - (x - 0.34) / 0.31);\n  return clamp(result, 0.0, 1.0);\n}\n"},
function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,
configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){Object(y.u)(a);var b=Object(y.w)(a,"neariso_voxelres",function(a){return Object(y.v)(a,y.k)}),d=Object(y.w)(a,"neariso_imagesize",function(a){return Object(y.v)(a,y.j)}),e=Object(y.w)(a,"neariso_offset",function(a){return Object(y.v)(a,y.l)});return Object(y.w)(a,"resolutions",function(a){return Object(y.a)(a,y.s)}).map(function(a){var f=""+a,c=b.get(f),h=d.get(f),k=e.get(f);if(void 0===c||void 0===
h||void 0===k)throw Error("Missing neariso_voxelres/neariso_imagesize/neariso_offset for resolution "+(a+"."));return{key:f,voxelSize:c,imageSize:h,voxelOffset:k}})}function f(a){a=G.get(a);void 0===a&&(a=r.c.UNKNOWN);return a}function l(a){Object(y.u)(a);var b=Object(y.w)(a,"channel_type",y.B);return{channelType:b,description:Object(y.w)(a,"description",y.B),volumeType:f(b),dataType:Object(y.w)(a,"datatype",function(a){return Object(y.n)(a,r.a)})}}function v(b){Object(y.u)(b);return{channels:Object(y.w)(b,
"channels",function(a){return Object(y.v)(a,l)}),scales:Object(y.w)(b,"dataset",a)}}function t(a,b,d,e){return a.memoize.getUncounted({type:"ndstore:getTokenInfo",hostnames:b,token:d},function(){return Object(D.e)(Object(D.c)(b,e+"/"+d+"/info/"),"json").then(v)})}function m(a,b,d,e){var f=d.match(F);if(null===f)throw Error("Invalid volume path "+JSON.stringify(d));var c=f[1],h=f[2],k=Object(y.e)(f[3]||"");return a.memoize.getUncounted({type:"ndstore:MultiscaleVolumeChunkSource",hostnames:b,path:d},
function(){return t(a,b,c,e).then(function(d){return new C(a,b,c,d,h,e,k)})})}function k(a,b){var d=b.match(M);if(null===d)throw Error("Invalid ndstore volume path: "+JSON.stringify(b));return m(a,[d[1]],d[2],h.b)}function e(a,b,d){return a.memoize.getUncounted({type:"dvid:getPublicTokens",hostnames:b},function(){return Object(D.e)(Object(D.c)(b,d+"/public_tokens/"),"json").then(function(a){return Object(y.a)(a,y.B)})})}function d(a,b,d,f){var c=d.match(/^(?:([^\/]+)(?:\/([^\/]*))?)?$/);if(null===
c)return Promise.reject(null);if(void 0===c[2]){var h=c[1]||"";return e(a,b,f).then(function(a){return{offset:0,completions:Object(z.c)(h,a,function(a){return a+"/"},function(){})}})}return t(a,b,c[1],f).then(function(a){a=Object(z.c)(c[2],a.channels,function(a){return a[0]},function(a){return a[1].channelType+" ("+r.a[a[1].dataType]+")"});return{offset:c[1].length+1,completions:a}})}function b(a,b){var e=a.match(M);return null===e?Promise.reject(null):d(b,[e[1]],e[2],h.b).then(function(a){return Object(z.a)(e[1].length+
1,a)})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"getVolume",function(){return k});c.d(g,"volumeCompleter",function(){return b});c.d(g,"MultiscaleVolumeChunkSource",function(){return C});g.getTokenInfo=t;g.getShardedVolume=m;g.getPublicTokens=e;g.tokenAndChannelCompleter=d;c.d(g,"NDStoreDataSource",function(){return I});c.d(g,"SingleServerDataSource",function(){return P});p=c(17);g=c(37);var h=c(124),r=c(18),x=c(28),z=c(54),A=c(1),D=c(46),y=c(2),E=function(){function a(a,b){for(var d=
0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),G=new Map;G.set("image",r.c.IMAGE);G.set("annotation",r.c.SEGMENTATION);var H=new Set(["npz","raw","jpeg"]),B=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(p.f)(x.b,h.c)),C=function(){function a(b,d,e,f,c,
k,l){u(this,a);this.chunkManager=b;this.baseUrls=d;this.key=e;this.tokenInfo=f;this.parameters=l;this.urlPrefix=h.b;this.neariso=!0;if(void 0===c){c=Array.from(f.channels.keys());if(1!==c.length)throw Error("Dataset contains multiple channels: "+JSON.stringify(c));c=c[0]}b=f.channels.get(c);if(void 0===b)throw Error("Specified channel "+JSON.stringify(c)+" is not one of the supported "+("channels "+JSON.stringify(Array.from(f.channels.keys()))));this.channel=c;this.channelInfo=b;this.scales=f.scales;
void 0!==k&&(this.urlPrefix=k);"false"===Object(y.z)(l.neariso)&&(this.neariso=!1);f=Object(y.z)(l.encoding);if(void 0===f)f=this.volumeType===r.c.IMAGE?"jpeg":"npz";else if(!H.has(f))throw Error("Invalid encoding: "+JSON.stringify(f)+".");this.encoding=f}E(a,[{key:"getSources",value:function(a){var b=this;return this.scales.map(function(d){for(var e=d.voxelOffset,f=d.voxelSize,c=A.s.create(),h=0;3>h;++h)c[h]=Math.ceil(e[h]);return r.b.getDefaults({numChannels:b.numChannels,volumeType:b.volumeType,
dataType:b.dataType,voxelSize:f,transform:A.k.fromTranslation(A.k.create(),A.s.multiply(A.s.create(),e,f)),baseVoxelOffset:c,upperVoxelBound:d.imageSize,volumeSourceOptions:a}).map(function(a){return b.chunkManager.getChunkSource(B,{spec:a,parameters:{baseUrls:b.baseUrls,urlPrefix:b.urlPrefix,key:b.key,channel:b.channel,resolution:d.key,encoding:b.encoding,neariso:b.neariso}})})})}},{key:"getMeshSource",value:function(){return null}},{key:"dataType",get:function(){return this.channelInfo.dataType}},
{key:"numChannels",get:function(){return 1}},{key:"volumeType",get:function(){return this.channelInfo.volumeType}}]);return a}(),F=/^([^\/?]+)(?:\/([^\/?]+))?(?:\?(.*))?$/,M=/^((?:http|https):\/\/[^\/?]+)\/(.*)$/,I=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,a);E(d,[{key:"volumeCompleter",value:function(a,d){return b(a,d)}},{key:"getVolume",value:function(a,b){return k(a,b)}},{key:"description",get:function(){return"NDstore"}}]);
return d}(g.a),P=function(a){function b(a,d,e){e=void 0===e?h.b:e;u(this,b);var f=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));f.description=a;f.hostnames=d;f.urlprefix=e;return f}q(b,a);E(b,[{key:"getVolume",value:function(a,b){return m(a,this.hostnames,b,this.urlprefix)}},{key:"volumeCompleter",value:function(a,b){return d(b,this.hostnames,a,this.urlprefix)}}]);return b}(g.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b,d,e){var f=
x.s.transformMat4(x.s.create(),a,b);a=Object(D.c)(d.voxelFromSpatial(I,f));return void 0!==e?(b=document.createElement("span"),b.className="neuroglancer-voxel-coordinates-link",b.textContent=a,b.title="Center view on voxel coordinates "+a+".",b.addEventListener("click",function(){e(f)}),b):document.createTextNode(a)}function f(b,d,e,f,c){switch(d.type){case m.c.AXIS_ALIGNED_BOUNDING_BOX:case m.c.LINE:b.appendChild(a(d.pointA,e,f,c));b.appendChild(document.createTextNode("\u2013"));b.appendChild(a(d.pointB,
e,f,c));break;case m.c.POINT:b.appendChild(a(d.point,e,f,c));break;case m.c.ELLIPSOID:b.appendChild(a(d.center,e,f,c)),d=Object(x.p)(I,d.radii,e),f.voxelFromSpatial(d,d),b.appendChild(document.createTextNode("\u00b1"+Object(D.b)(d)))}}function l(a,b){var d=x.s.create();switch(a.type){case m.c.AXIS_ALIGNED_BOUNDING_BOX:case m.c.LINE:x.s.add(d,a.pointA,a.pointB);x.s.scale(d,d,.5);break;case m.c.POINT:x.s.copy(d,a.point);break;case m.c.ELLIPSOID:x.s.copy(d,a.center)}return x.s.transformMat4(d,d,b)}function v(a,
b){return x.s.transformMat4(x.s.create(),a.position,b.globalToObject)}g.b=f;g.a=function(a){return function(a){function f(a){for(var c=[],r=0;r<arguments.length;++r)c[r-0]=arguments[r];u(this,f);var l,g=n(this,(l=f.__proto__||Object.getPrototypeOf(f)).call.apply(l,[].concat([this],$jscomp.arrayFromIterable(c))));g.annotationLayerState=g.registerDisposer(new b.d);g.selectedAnnotation=g.registerDisposer(new M(g.annotationLayerState.addRef()));g.annotationColor=new h.a(x.s.fromValues(1,1,0));g.selectedAnnotation.changed.add(g.specificationChanged.dispatch);
g.annotationColor.changed.add(g.specificationChanged.dispatch);g.tabs.add("annotations",{label:"Annotations",order:10,getter:function(){return new U(g,g.selectedAnnotation.addRef(),g.manager.voxelSize.addRef(),function(a){return g.manager.setSpatialCoordinates(a)})}});g.annotationLayerState.changed.add(function(){var a=g.annotationLayerState.value;if(void 0!==a){var b=new k.a(g.manager.chunkManager,a.addRef());Object(d.b)(a,g.manager.layerSelectedValues.mouseState);g.addRenderLayer(new k.e(b));g.addRenderLayer(new k.d(b.addRef()));
b.source instanceof e.b&&g.addRenderLayer(new e.a(b.source.addRef()))}});return g}q(f,a);C(f,[{key:"restoreState",value:function(a){F(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"restoreState",this).call(this,a);this.selectedAnnotation.restoreState(a.selectedAnnotation);this.annotationColor.restoreState(a.annotationColor)}},{key:"toJSON",value:function(){var a=F(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"toJSON",this).call(this);a.selectedAnnotation=this.selectedAnnotation.toJSON();
a.annotationColor=this.annotationColor.toJSON();return a}}]);return f}(a)};p=c(232);c.n(p);var t=c(71),m=c(22),k=c(62),e=c(75),d=c(80),b=c(5);p=c(110);var h=c(136);g=c(0);var r=c(10),x=c(1),z=c(2),A=c(3),D=c(139),y=c(26),E=c(86),G=c(234),H=c(35),B=c(87),C=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),F=
function S(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return S(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},M=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.annotationLayerState=a;d.changed=new A.a;d.referenceChanged=function(){d.validate();d.changed.dispatch()};d.validate=function(){var a=d.updateAnnotationLayer(),
b=d.annotationLayer;if(void 0!==b){var e=d.value_;if(void 0!==e){var f=d.reference_;void 0!==f&&f.id!==e.id&&(d.unbindReference(),f=void 0);void 0===f&&(f=d.reference_=b.source.getReference(e.id),f.changed.add(d.referenceChanged));if(null===f.value){d.unbindReference();d.value=void 0;return}}else d.unbindReference()}a&&d.changed.dispatch()};d.registerDisposer(a);d.registerDisposer(a.changed.add(d.validate));d.updateAnnotationLayer();d.reference_=void 0;d.value_=void 0;return d}q(b,a);C(b,[{key:"updateAnnotationLayer",
value:function(){var a=this.annotationLayerState.value;if(a===this.annotationLayer)return!1;this.unbindLayer();this.annotationLayer=a;void 0!==a&&a.source.changed.add(this.validate);return!0}},{key:"unbindLayer",value:function(){void 0!==this.annotationLayer&&(this.annotationLayer.source.changed.remove(this.validate),this.annotationLayer=void 0)}},{key:"disposed",value:function(){this.unbindLayer();this.unbindReference();F(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},
{key:"unbindReference",value:function(){var a=this.reference_;void 0!==a&&(a.changed.remove(this.referenceChanged),this.reference_=void 0)}},{key:"toJSON",value:function(){var a=this.value_;if(void 0!==a)return 0===a.partIndex?a.id:a}},{key:"reset",value:function(){this.value=void 0}},{key:"restoreState",value:function(a){void 0===a?this.value=void 0:"string"===typeof a?this.value={id:a,partIndex:0}:(Object(z.u)(a),this.value={id:Object(z.w)(a,"id",z.B),partIndex:Object(z.w)(a,"partIndex",z.y)})}},
{key:"reference",get:function(){return this.reference_}},{key:"value",get:function(){return this.value_},set:function(a){this.value_=a;this.validate();this.changed.dispatch()}},{key:"validValue",get:function(){return this.annotationLayer&&this.value_}}]);return b}(g.a),I=x.s.create(),P=function(a){function b(a,d,e,f,c){u(this,b);var h=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));h.layer=a;h.state=d;h.annotationLayer=e;h.voxelSize=f;h.setSpatialCoordinates=c;h.annotationListContainer=
document.createElement("ul");h.annotationListElements=new Map;h.updated=!1;h.element.classList.add("neuroglancer-annotation-layer-view");h.annotationListContainer.classList.add("neuroglancer-annotation-list");h.registerDisposer(d);h.registerDisposer(f);h.registerDisposer(e);a=function(){h.updated=!1;h.updateView()};h.registerDisposer(e.source.changed.add(a));h.registerDisposer(h.visibility.changed.add(function(){return h.updateView()}));h.registerDisposer(e.transform.changed.add(a));h.updateView();
a=document.createElement("div");a.className="neuroglancer-annotation-toolbox";d=h.registerDisposer(new G.a(h.annotationLayer.color));d.element.title="Change annotation display color";a.appendChild(d.element);e.source.readonly||(e=document.createElement("button"),e.textContent=Object(m.f)(m.c.POINT).icon,e.title="Annotate point",e.addEventListener("click",function(){h.layer.tool.value=new O(h.layer,{})}),a.appendChild(e),e=document.createElement("button"),e.textContent=Object(m.f)(m.c.AXIS_ALIGNED_BOUNDING_BOX).icon,
e.title="Annotate bounding box",e.addEventListener("click",function(){h.layer.tool.value=new T(h.layer,{})}),a.appendChild(e),e=document.createElement("button"),e.textContent=Object(m.f)(m.c.LINE).icon,e.title="Annotate line",e.addEventListener("click",function(){h.layer.tool.value=new W(h.layer,{})}),a.appendChild(e),e=document.createElement("button"),e.textContent=Object(m.f)(m.c.ELLIPSOID).icon,e.title="Annotate ellipsoid",e.addEventListener("click",function(){h.layer.tool.value=new aa(h.layer,
{})}),a.appendChild(e));h.element.appendChild(a);h.element.appendChild(h.annotationListContainer);h.annotationListContainer.addEventListener("mouseleave",function(){h.annotationLayer.hoverState.value=void 0});h.registerDisposer(h.annotationLayer.hoverState.changed.add(function(){return h.updateHoverView()}));h.registerDisposer(h.state.changed.add(function(){return h.updateSelectionView()}));return h}q(b,a);C(b,[{key:"updateSelectionView",value:function(){var a=this.state.value;if(void 0!==a)var b=
a.id;a=this.previousSelectedId;b!==a&&(void 0!==a&&(a=this.annotationListElements.get(a),void 0!==a&&a.classList.remove("neuroglancer-annotation-selected")),void 0!==b&&(a=this.annotationListElements.get(b),void 0!==a&&(a.classList.add("neuroglancer-annotation-selected"),a.scrollIntoView())),this.previousSelectedId=b)}},{key:"updateHoverView",value:function(){var a=this.annotationLayer.hoverState.value;if(void 0!==a)var b=a.id;a=this.previousHoverId;b!==a&&(void 0!==a&&(a=this.annotationListElements.get(a),
void 0!==a&&a.classList.remove("neuroglancer-annotation-hover")),void 0!==b&&(a=this.annotationListElements.get(b),void 0!==a&&a.classList.add("neuroglancer-annotation-hover")),this.previousHoverId=b)}},{key:"updateView",value:function(){var a=this;if(this.visible&&!this.updated){var b=this.annotationLayer,d=this.annotationListContainer,e=this.annotationListElements,f=b.source;Object(r.a)(d);this.annotationListElements.clear();b=b.objectToGlobal;var c={};f=$jscomp.makeIterator(f);for(var h=f.next();!h.done;c=
{annotation:c.annotation},h=f.next())c.annotation=h.value,h=this.makeAnnotationListElement(c.annotation,b),d.appendChild(h),e.set(c.annotation.id,h),h.addEventListener("mouseenter",function(b){return function(){a.annotationLayer.hoverState.value={id:b.annotation.id,partIndex:0}}}(c)),h.addEventListener("click",function(b){return function(){a.state.value={id:b.annotation.id,partIndex:0}}}(c)),h.addEventListener("mouseup",function(b){return function(d){2===d.button&&a.setSpatialCoordinates(l(b.annotation,
a.annotationLayer.objectToGlobal))}}(c));this.previousHoverId=this.previousSelectedId=void 0;this.updated=!0;this.updateHoverView();this.updateSelectionView()}}},{key:"makeAnnotationListElement",value:function(a,b){var d=document.createElement("li");d.title="Click to select, right click to recenter view.";var e=document.createElement("div");e.className="neuroglancer-annotation-icon";e.textContent=Object(m.f)(a.type).icon;d.appendChild(e);e=document.createElement("div");e.className="neuroglancer-annotation-position";
f(e,a,b,this.voxelSize,this.setSpatialCoordinates);d.appendChild(e);a.description&&(b=document.createElement("div"),b.className="neuroglancer-annotation-description",b.textContent=a.description,d.appendChild(b));return d}}]);return b}(H.b),N=function(a){function b(a,d,e){u(this,b);var f=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));f.state=a;f.voxelSize=d;f.setSpatialCoordinates=e;f.valid=!1;f.mouseEntered=!1;f.element.classList.add("neuroglancer-annotation-details");f.registerDisposer(a);
f.registerDisposer(d);f.registerDisposer(f.state.changed.add(function(){f.valid=!1;f.updateView()}));f.registerDisposer(f.visibility.changed.add(function(){return f.updateView()}));f.state.changed.add(function(){f.valid=!1;f.updateView()});f.element.addEventListener("mouseenter",function(){f.mouseEntered=!0;void 0!==f.hoverState&&(f.hoverState.value=f.state.value)});f.element.addEventListener("mouseleave",function(){f.mouseEntered=!1;void 0!==f.hoverState&&(f.hoverState.value=void 0)});f.updateView();
return f}q(b,a);C(b,[{key:"updateView",value:function(){var a=this;if(this.visible){if(this.element.style.display=null,!this.valid){var b=this.element;Object(r.a)(b);this.valid=!0;var d=this.state.reference;if(void 0!==d){var e=this.state.value,c=d.value;if(null!=c){var h=this.state.annotationLayerState.value;this.hoverState=h.hoverState;this.mouseEntered&&(this.hoverState.value=e);var k=h.objectToGlobal,g=this.voxelSize,l=Object(m.f)(c.type),t=document.createElement("div");t.className="neuroglancer-annotation-details-title";
var v=document.createElement("div");v.className="neuroglancer-annotation-details-icon";v.textContent=l.icon;var n=document.createElement("div");n.className="neuroglancer-annotation-details-title-text";n.textContent=""+l.description;t.appendChild(v);t.appendChild(n);h.source.readonly||(l=Object(B.a)("\ud83d\uddd1","Delete annotation"),l.addEventListener("click",function(){var a=h.source.getReference(e.id);try{h.source.delete(a)}finally{a.dispose()}}),t.appendChild(l));l=Object(E.a)();l.title="Hide annotation details";
l.addEventListener("click",function(){a.state.value=void 0});t.appendChild(l);b.appendChild(t);t=document.createElement("div");t.className="neuroglancer-annotation-details-position";f(t,c,k,g,this.setSpatialCoordinates);b.appendChild(t);c.type===m.c.AXIS_ALIGNED_BOUNDING_BOX?(t=document.createElement("div"),t.className="neuroglancer-annotation-details-volume",t.textContent=Object(D.a)(c.pointA,c.pointB,k),b.appendChild(t),t=Object(x.p)(I,x.s.subtract(I,c.pointA,c.pointB),k),k=document.createElement("div"),
k.className="neuroglancer-annotation-details-volume-in-voxels",g=g.voxelFromSpatial(I,t),k.textContent=""+Object(D.b)(g),b.appendChild(k)):c.type===m.c.LINE&&(l=Object(x.p)(I,x.s.subtract(I,c.pointA,c.pointB),k),k=document.createElement("div"),k.className="neuroglancer-annotation-details-length",t=Object(D.d)(x.s.length(l)),v="",g.valid&&(g=x.s.length(g.voxelFromSpatial(I,l)),v=", "+Math.round(g)+" vx"),k.textContent=t+v,b.appendChild(k));var z=document.createElement("textarea");z.value=c.description||
"";z.rows=3;z.className="neuroglancer-annotation-details-description";z.placeholder="Description";h.source.readonly?z.readOnly=!0:z.addEventListener("change",function(){var a=z.value;h.source.update(d,Object.assign({},c,{description:a?a:void 0}));h.source.commit(d)});b.appendChild(z)}}}}else this.element.style.display="none",this.hoverState=void 0}}]);return b}(H.b),U=function(a){function b(a,d,e,f){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.layer=a;c.state=d;c.voxelSize=
e;c.setSpatialCoordinates=f;c.stack=c.registerDisposer(new H.a(function(a){return new P(c.layer,c.state.addRef(),a.addRef(),c.voxelSize.addRef(),c.setSpatialCoordinates)},c.visibility));c.detailsTab=c.registerDisposer(new N(c.state,c.voxelSize.addRef(),c.setSpatialCoordinates));c.registerDisposer(d);c.registerDisposer(e);a=c.element;a.classList.add("neuroglancer-annotations-tab");c.stack.element.classList.add("neuroglancer-annotations-stack");a.appendChild(c.stack.element);a.appendChild(c.detailsTab.element);
a=function(){c.detailsTab.visibility.value=void 0!==c.state.validValue&&c.visible?y.b.VISIBLE:y.b.IGNORED};c.registerDisposer(c.state.changed.add(a));c.registerDisposer(c.visibility.changed.add(a));a=function(){c.stack.selected=c.state.annotationLayerState.value};c.registerDisposer(c.state.annotationLayerState.changed.add(a));a();return c}q(b,a);return b}(H.b);c=function(a){function b(a,d){u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.layer=a;if(void 0===a.annotationLayerState)throw Error("Invalid layer for annotation tool.");
e.annotationDescription=Object(z.w)(d,"description",z.z);return e}q(b,a);C(b,[{key:"annotationLayer",get:function(){return this.layer.annotationLayerState.value}}]);return b}(p.a);var O=function(a){function b(a,d){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d))}q(b,a);C(b,[{key:"trigger",value:function(a){var b=this.annotationLayer;void 0!==b&&a.active&&(a={id:"",description:"",point:x.s.transformMat4(x.s.create(),a.position,b.globalToObject),type:m.c.POINT},b=b.source.add(a,
!0),this.layer.selectedAnnotation.value={id:b.id},b.dispose())}},{key:"toJSON",value:function(){return"annotatePoint"}},{key:"description",get:function(){return"annotate point"}}]);return b}(c);c=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);C(b,[{key:"trigger",value:function(a){var b=this,d=this.annotationLayer;if(void 0!==d&&a.active){var e=function(){var e=b.inProgressAnnotation,f=e.reference,c=b.getUpdatedAnnotation(f.value,
a,d);e.annotationLayer.source.update(f,c);b.layer.selectedAnnotation.value={id:f.id}};if(void 0===this.inProgressAnnotation){var f=d.source.add(this.getInitialAnnotation(a,d),!1);this.layer.selectedAnnotation.value={id:f.id};var c=a.changed.add(e);this.inProgressAnnotation={annotationLayer:d,reference:f,disposer:function(){c();f.dispose()}}}else e(),this.inProgressAnnotation.annotationLayer.source.commit(this.inProgressAnnotation.reference),this.inProgressAnnotation.disposer(),this.inProgressAnnotation=
void 0}}},{key:"disposed",value:function(){this.deactivate();F(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"deactivate",value:function(){void 0!==this.inProgressAnnotation&&(this.inProgressAnnotation.annotationLayer.source.delete(this.inProgressAnnotation.reference),this.inProgressAnnotation.disposer(),this.inProgressAnnotation=void 0)}}]);return b}(c);g=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,
arguments))}q(b,a);C(b,[{key:"getInitialAnnotation",value:function(a,b){a=v(a,b);return{id:"",type:this.annotationType,description:"",pointA:a,pointB:a}}},{key:"getUpdatedAnnotation",value:function(a,b,d){b=v(b,d);return Object.assign({},a,{pointB:b})}}]);return b}(c);var T=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);C(b,[{key:"toJSON",value:function(){return"annotateBoundingBox"}},{key:"description",get:function(){return"annotate bounding box"}}]);
return b}(g);T.prototype.annotationType=m.c.AXIS_ALIGNED_BOUNDING_BOX;var W=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);C(b,[{key:"toJSON",value:function(){return"annotateLine"}},{key:"description",get:function(){return"annotate line"}}]);return b}(g);W.prototype.annotationType=m.c.LINE;var aa=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);C(b,[{key:"getInitialAnnotation",
value:function(a,b){a=v(a,b);return{type:m.c.ELLIPSOID,id:"",description:"",center:a,radii:x.s.fromValues(0,0,0)}}},{key:"getUpdatedAnnotation",value:function(a,b,d){var e=x.s.transformMat4(x.s.create(),a.center,d.objectToGlobal);e=x.s.distance(e,b.position);b=t.a.create();b[0]=b[4]=b[8]=1/(e*e);d=Object(x.j)(t.a.create(),d.objectToGlobal);t.a.multiply(b,b,d);t.a.transpose(d,d);t.a.multiply(b,d,b);return Object.assign({},a,{radii:x.s.fromValues(1/Math.sqrt(b[0]),1/Math.sqrt(b[4]),1/Math.sqrt(b[8]))})}},
{key:"toJSON",value:function(){return"annotateSphere"}},{key:"description",get:function(){return"annotate ellipsoid"}}]);return b}(c);Object(p.b)("annotatePoint",function(a,b){return new O(a,b)});Object(p.b)("annotateBoundingBox",function(a,b){return new T(a,b)});Object(p.b)("annotateLine",function(a,b){return new W(a,b)});Object(p.b)("annotateSphere",function(a,b){return new aa(a,b)})},function(p,g,c){g.a=function(){return Object(u.a)("\u274c")};var u=c(87)},function(p,g,c){g.a=function(c,g){var n=
document.createElement("div"),a=document.createElement("div");a.textContent=c;n.className="neuroglancer-icon-button";n.appendChild(a);void 0!==g&&(n.title=g);return n};p=c(233);c.n(p)},function(p,g,c){function u(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||"object"!==typeof f&&"function"!==typeof f?a:f}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);
a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}g.a=function(c){return function(c){function g(f){for(var e=[],d=0;d<arguments.length;++d)e[d-0]=arguments[d];if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var b,c=u(this,(b=g.__proto__||Object.getPrototypeOf(g)).call.apply(b,[].concat([this],$jscomp.arrayFromIterable(e))));c.transform=new q.a;
c.transform.changed.add(c.specificationChanged.dispatch);c.tabs.add("transform",{label:"Transform",order:100,getter:function(){return new a.a(c.transform)}});c.transform.restoreState(e[1].transform);return c}n(g,c);f(g,[{key:"toJSON",value:function(){var a=l(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"toJSON",this).call(this);a.transform=this.transform.toJSON();return a}}]);return g}(c)};var q=c(50),a=c(235),f=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=
e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),l=function t(a,f,e){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,f);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,f,e)}else{if("value"in d)return d.value;f=d.get;return void 0===f?void 0:f.call(e)}}},function(p,g,c){function u(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!f||"object"!==typeof f&&"function"!==typeof f?a:f}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return l});p=c(0);var q=c(10),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=
e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),f=function t(a,f,e){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,f);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,f,e)}else{if("value"in d)return d.value;f=d.get;return void 0===f?void 0:f.call(e)}};c(237);var l=function(c){function g(a,e){var d=void 0===e?{}:e;e=void 0===d.min?0:d.min;var b=
void 0===d.max?1:d.max;d=void 0===d.step?.01:d.step;if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var f=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));f.value=a;f.element=document.createElement("label");f.promptElement=document.createElement("span");f.inputElement=document.createElement("input");var c=f.element,k=f.promptElement,l=f.inputElement;c.className="range-slider";k.className="range-prompt";l.type="range";l.min=""+e;l.max=""+b;l.step=""+d;l.valueAsNumber=
f.value.value;c.appendChild(k);c.appendChild(l);var m=function(){f.value.value=f.inputElement.valueAsNumber};f.registerEventListener(l,"change",m);f.registerEventListener(l,"input",m);f.registerEventListener(l,"wheel",function(a){a=a.deltaY;0<a?(f.inputElement.stepUp(),m()):0>a&&(f.inputElement.stepDown(),m())});a.changed.add(function(){f.inputElement.valueAsNumber=f.value.value});return f}n(g,c);a(g,[{key:"disposed",value:function(){Object(q.b)(this.element);f(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),
"disposed",this).call(this)}}]);return g}(p.a)},function(p,g,c){function u(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!f||"object"!==typeof f&&"function"!==typeof f?a:f}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return t});p=c(238);c.n(p);p=c(239);c.n(p);p=c(140);c.n(p);p=c(141);c.n(p);p=c(42);var q=c.n(p);p=c(6);var a=c.n(p);p=c(0);var f=c(10),l=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(f,e,d){e&&a(f.prototype,e);d&&a(f,d);return f}}(),v=function k(a,d,b){null===a&&(a=Function.prototype);var e=
Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}};c(240)(q.a);var t=function(c){function e(d){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var b=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));b.state=d;b.changingValue=!1;b.debouncedValueUpdater=a()(function(){b.changingValue=!0;try{b.state.fragmentMain.value=b.textEditor.getValue()}finally{b.changingValue=
!1}},500);b.textEditor=q()(function(a){},{value:b.state.fragmentMain.value,mode:"glsl",gutters:["CodeMirror-lint-markers"]});b.textEditor.on("change",function(){b.setValidState(void 0);b.debouncedValueUpdater()});b.registerDisposer(b.state.fragmentMain.changed.add(function(){b.changingValue||b.textEditor.setValue(b.state.fragmentMain.value)}));b.element.classList.add("neuroglancer-shader-code-widget");b.registerDisposer(b.state.shaderError.changed.add(function(){b.updateErrorState()}));b.updateErrorState();
return b}n(e,c);l(e,[{key:"updateErrorState",value:function(){var a=this,b=this.state.shaderError.value;void 0===b?this.setValidState(void 0):null!==b?(this.textEditor.setOption("lint",{getAnnotations:function(){if("ShaderCompilationError"===b.name){var d=b.source.split("\n").indexOf(a.state.fragmentMainStartLine)+2;return b.errorMessages.map(function(a){return{message:a.message,severity:"error",from:q.a.Pos(void 0===a.line?0:a.line-d)}})}return"ShaderLinkError"===b.name?[{message:b.log,severity:"error",
from:q.a.Pos(0)}]:[{message:b.message,severity:"error",from:q.a.Pos(0)}]}}),this.setValidState(!1)):(this.textEditor.setOption("lint",void 0),this.setValidState(!0))}},{key:"setValidState",value:function(a){var b=this.element;b.classList.remove("invalid-input");b.classList.remove("valid-input");!0===a?b.classList.add("valid-input"):!1===a&&b.classList.add("invalid-input")}},{key:"disposed",value:function(){this.debouncedValueUpdater.flush();this.debouncedValueUpdater=void 0;Object(f.b)(this.element);
this.textEditor=void 0;v(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"element",get:function(){return this.textEditor.getWrapperElement()}}]);return e}(p.a)},function(p,g,c){c.d(g,"a",function(){return n});var u=function(){function c(a,f){for(var c=0;c<f.length;c++){var g=f[c];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(a,f,g){f&&c(a.prototype,f);g&&c(a,g);return a}}();
g.b=4093;var n=function(){function c(a,f,g,v){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.a0=a;this.a1=f;this.b=g;this.c=v}u(c,[{key:"computeDotProduct",value:function(a,f){var c=this.a0,g=this.a1;return c[0]*(a&255)+c[1]*(a>>8&255)+c[2]*(a>>16&255)+c[3]*(a>>24&255)+(g[0]*(f&255)+g[1]*(f>>8&255)+g[2]*(f>>16&255)+g[3]*(f>>24&255))}},{key:"compute",value:function(a,f){var c=this.b,g=this.c;a=this.computeDotProduct(a,f);return(a+a*a%4093*g+c)%4093}},{key:"toString",
value:function(){return"new HashFunction(Float32Array.of("+this.a0+"), "+("Float32Array.of("+this.a1+"), "+this.b+", "+this.c+")")}}],[{key:"generate",value:function(){function a(){return Math.floor(4093*Math.random())}return new c(Float32Array.of(a(),a(),a(),a()),Float32Array.of(a(),a(),a(),a()),a(),a())}}]);return c}()},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?
a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}c.d(g,"b",function(){return d});c.d(g,"a",function(){return z});var a=c(91),f=c(23),l=
function D(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return D(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},v=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}();g.c=3;var t=
0,m=0,k=0,e=0;p=function(){function b(a){a=void 0===a?b.generateHashFunctions(3):a;q(this,b);this.loadFactor=.9;this.size=0;this.growFactor=1.2;this.maxHeight=8192;this.emptyHigh=this.emptyLow=4294967295;this.maxAttempts=this.maxRehashAttempts=5;this.maxWidth=4096/this.entryStride;this.generation=0;this.mungedEmptyKey=-1;this.hashFunctions=a;this.allocate(4,1)}v(b,[{key:"updateHashFunctions",value:function(a){this.hashFunctions=b.generateHashFunctions(a);this.mungedEmptyKey=-1}},{key:"tableWithMungedEmptyKey",
value:function(a){for(var b=this.hashFunctions.length,d=Array(b),e=0;e<b;++e)d[e]=this.getHash(e,this.emptyLow,this.emptyHigh);e=this.mungedEmptyKey;if(-1===e)a:for(;;){e=16777216*Math.random()>>>0;for(var f=0;f<b;++f)for(var c=this.getHash(f,e,e),h=0;h<b;++h)if(d[h]===c)continue a;this.mungedEmptyKey=e;break}f=this.table;c=this.emptyLow;h=this.emptyHigh;for(var k=0;k<b;++k){var r=d[k];f[r]===c&&f[r+1]===h&&(f[r]=e,f[r+1]=e)}try{a(f)}finally{for(a=0;a<b;++a)k=d[a],f[k]===e&&f[k+1]===e&&(f[k]=c,f[k+
1]=h)}}},{key:"getHash",value:function(a,b,d){a=this.hashFunctions[a];var e=this.width,f=this.height;e=a[0].compute(b,d)%e;b=a[1].compute(b,d)%f;return this.entryStride*(b*this.width+e)}},{key:"keys",value:function(a){function b(b,n){for(;;)switch(d){case 0:a=void 0===a?new f.a:a,v=x,t=v.emptyLow,m=v.emptyHigh,l=v.entryStride,g=x,r=g.table,k=0,h=r.length;case 1:if(!(k<h)){d=3;break}c=r[k];e=r[k+1];if(c===t&&e===m){d=4;break}a.low=c;a.high=e;d=5;return{value:a,done:!1};case 5:if(void 0===n){d=6;break}d=
-1;throw n;case 6:case 4:case 2:k+=l;d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,e,c,h,k,r,g,l,m,t,v,x=this,n={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();n[Symbol.iterator]=function(){return this};return n}},{key:"indexOfPair",value:function(a,b){var d=this.table,e=this.emptyHigh;if(a===this.emptyLow&&b===e)return-1;e=0;for(var f=this.hashFunctions.length;e<
f;++e){var c=this.getHash(e,a,b);if(d[c]===a&&d[c+1]===b)return c}return-1}},{key:"indexOf",value:function(a){return this.indexOfPair(a.low,a.high)}},{key:"chooseAnotherEmptyKey",value:function(){for(var a=this.emptyLow,b=this.emptyHigh,d=this.table,e=this.entryStride,f,c;f=4294967296*Math.random()>>>0,c=4294967296*Math.random()>>>0,f===a&&c===b||this.hasPair(f,c););this.emptyLow=f;this.emptyHigh=c;for(var h=0,k=d.length;h<k;h+=e)d[h]===a&&d[h+1]===b&&(d[h]=f,d[h+1]=c)}},{key:"has",value:function(a){return-1!==
this.indexOf(a)}},{key:"hasPair",value:function(a,b){return-1!==this.indexOfPair(a,b)}},{key:"delete",value:function(a){a=this.indexOf(a);if(-1!==a){var b=this.table;b[a]=this.emptyLow;b[a+1]=this.emptyHigh;++this.generation;this.size--;return!0}return!1}},{key:"clearTable",value:function(){for(var a=this.table,b=this.entryStride,d=this.emptyLow,e=this.emptyHigh,f=a.length,c=0;c<f;c+=b)a[c]=d,a[c+1]=e}},{key:"clear",value:function(){if(0===this.size)return!1;this.size=0;++this.generation;this.clearTable();
return!0}},{key:"swapPending",value:function(a,b){var d=t,e=m;this.storePending(a,b);a[b]=d;a[b+1]=e}},{key:"storePending",value:function(a,b){t=a[b];m=a[b+1]}},{key:"backupPending",value:function(){k=t;e=m}},{key:"restorePending",value:function(){t=k;m=e}},{key:"tryToInsert",value:function(){for(var a=0,b=this.emptyLow,d=this.emptyHigh,e=this.maxAttempts,f=this.table,c=this.hashFunctions.length,h=Math.floor(Math.random()*c);;){var k=this.getHash(h,t,m);this.swapPending(f,k);if(t===b&&m===d)return!0;
if(++a===e)break;h=(h+Math.floor(Math.random()*(c-1))+1)%c}return!1}},{key:"allocate",value:function(a,b){var d=a*b;this.width=a;this.height=b;this.table=new Uint32Array(d*this.entryStride);this.maxAttempts=d;this.clearTable();this.capacity=d*this.loadFactor;this.mungedEmptyKey=-1}},{key:"rehash",value:function(a,b,d){this.allocate(b,d);this.updateHashFunctions(this.hashFunctions.length);b=this.emptyLow;d=this.emptyHigh;for(var e=this.entryStride,f=0,c=a.length;f<c;f+=e){var h=a[f+1];if(a[f]!==b||
h!==d)if(this.storePending(a,f),!this.tryToInsert())return!1}return!0}},{key:"grow",value:function(a){for(var b=this.table,d=this.width,e=this.height,f=this.maxWidth,c=this.maxHeight;;){var h=d*e;d=Math.min(f,Math.ceil(a/this.height));d*e<a&&(e=Math.min(c,Math.ceil(a/d)));var k=d*e;if(k<a&&k===h)throw Error("Maximum table size exceeded");for(h=0;h<this.maxRehashAttempts;++h)if(this.rehash(b,d,e))return;a=Math.ceil(this.growFactor*a)}}},{key:"insertInternal",value:function(){++this.generation;t===
this.emptyLow&&m===this.emptyHigh&&this.chooseAnotherEmptyKey();++this.size>this.capacity&&(this.backupPending(),this.grow(Math.ceil(this.growFactor*this.width*this.height)),this.restorePending());for(;!this.tryToInsert();)this.backupPending(),this.grow(this.width*this.height),this.restorePending()}}],[{key:"generateHashFunctions",value:function(b){b=void 0===b?3:b;for(var d=[],e=0;e<b;++e){var f=[a.a.generate(),a.a.generate()];d.push(f)}return d}}]);return b}();var d=function(a){function b(){q(this,
b);return u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}n(b,a);$jscomp.initSymbol();$jscomp.initSymbolIterator();v(b,[{key:"add",value:function(a){var b=a.low;a=a.high;if(this.hasPair(b,a))return!1;t=b;m=a;this.insertInternal();return!0}},{key:Symbol.iterator,value:function(){return this.keys()}}]);return b}(p);d.prototype.entryStride=2;var b=0,h=0,r=0,x=0,z=function(a){function d(){q(this,d);return u(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}n(d,
a);$jscomp.initSymbol();$jscomp.initSymbolIterator();v(d,[{key:"set",value:function(a,d){var e=a.low;a=a.high;if(this.hasPair(e,a))return!1;t=e;m=a;b=d.low;h=d.high;this.insertInternal();return!0}},{key:"get",value:function(a,b){a=this.indexOf(a);if(-1===a)return!1;var d=this.table;b.low=d[a+2];b.high=d[a+3];return!0}},{key:"swapPending",value:function(a,e){var f=b,c=h;l(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"swapPending",this).call(this,a,e);a[e+2]=f;a[e+3]=c}},{key:"storePending",
value:function(a,e){l(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"storePending",this).call(this,a,e);b=a[e+2];h=a[e+3]}},{key:"backupPending",value:function(){l(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"backupPending",this).call(this);r=b;x=h}},{key:"restorePending",value:function(){l(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"restorePending",this).call(this);b=r;h=x}},{key:Symbol.iterator,value:function(){return this.entries()}},{key:"entries",value:function(a){function b(b,
u){for(;;)switch(d){case 0:a=void 0===a?[new f.a,new f.a]:a,z=q,n=z.emptyLow,x=z.emptyHigh,v=z.entryStride,t=q,m=t.table,l=$jscomp.makeIterator(a),g=l.next().value,r=l.next().value,k=0,h=m.length;case 1:if(!(k<h)){d=3;break}c=m[k];e=m[k+1];if(c===n&&e===x){d=4;break}g.low=c;g.high=e;r.low=m[k+2];r.high=m[k+3];d=5;return{value:a,done:!1};case 5:if(void 0===u){d=6;break}d=-1;throw u;case 6:case 4:case 2:k+=v;d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,e,c,h,k,r,g,l,m,t,v,x,n,
z,q=this,u={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();u[Symbol.iterator]=function(){return this};return u}}]);return d}(p);z.prototype.entryStride=4},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a,d,e){e=Math.ceil(e/d);a.dataWidth=d;a.textureHeight=e;a.textureAccessCoefficients=Float32Array.of(1/d,1/(d*e),
d)}c.d(g,"b",function(){return m});g.c=function(b,d,e){e=void 0===e?1:e;switch(d){case a.b.UINT8:if(1>e||4<e)break;b.texelsPerElement=1;b.textureFormat=k[e];b.texelType=f.G;b.arrayElementsPerTexel=e;b.arrayConstructor=Uint8Array;return b;case a.b.UINT16:if(1>e||2<e)break;b.texelsPerElement=1;b.textureFormat=k[2*e];b.texelType=f.G;b.arrayElementsPerTexel=2*e;b.arrayConstructor=Uint8Array;return b;case a.b.UINT64:if(1!==e)break;b.texelsPerElement=2;b.textureFormat=f.s;b.texelType=f.G;b.arrayElementsPerTexel=
4;b.arrayConstructor=Uint8Array;return b;case a.b.UINT32:if(1!==e)break;b.texelsPerElement=1;b.textureFormat=f.s;b.texelType=f.G;b.arrayElementsPerTexel=4;b.arrayConstructor=Uint8Array;return b;case a.b.FLOAT32:if(!(1>e||4<e))return b.texelsPerElement=1,b.textureFormat=k[e],b.texelType=f.g,b.arrayElementsPerTexel=e,b.arrayConstructor=Float32Array,b}throw Error("No supported texture format for "+a.b[d]+"["+e+"].");};g.e=function(a,d,e,f,c,k){d=d.maxTextureSize;var b=f*c*k;if(!(e*f<=d&&c*k<=d))if(e*
f*c<=d&&k<=d)f*=c;else if(f=Math.ceil(b/d),f*e>d)throw Error("Chunk data size exceeds maximum texture size: "+e+" * "+b);n(a,f,b)};g.d=function(a,d,e,f){d=d.maxTextureSize;var b=Math.ceil(f/d);if(b*e>d)throw Error("Number of elements exceeds maximum texture size: "+e+" * "+f);n(a,b,f)};g.f=function(a,d,e,c){var b=e.arrayConstructor,h=e.textureFormat,k=e.texelsPerElement,r=d.dataWidth;d=d.textureHeight;var g=r*d*e.arrayElementsPerTexel*k;c.constructor!==b&&(c=new b(c.buffer,c.byteOffset,c.byteLength/
b.BYTES_PER_ELEMENT));c=Object(q.b)(c,g);a.pixelStorei(f.E,1);Object(v.b)(a);a.texImage2D(a.TEXTURE_2D,0,h,r*k,d,0,h,e.texelType,c)};c.d(g,"a",function(){return d});var q=c(39),a=c(43),f=c(11),l=c(16),v=c(65),t=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),m=function h(){u(this,h)},k=[-1,f.l,f.m,f.r,f.s],
e=["","r","ra","rgb","rgba"],d=function(){function d(a){u(this,d);this.key=a;this.uniformName="uTextureAccessCoefficients_"+this.key;this.readTextureValue="readTextureValue_"+this.key}t(d,[{key:"defineShader",value:function(a){a.addUniform("highp vec3",this.uniformName)}},{key:"getReadTextureValueCode",value:function(a){for(var d=this.uniformName,e="\nvoid "+this.readTextureValue+"(highp sampler2D sampler, float index",f=0;f<a;++f)e+=", out vec4 output"+f;e+=") {\n  float offset = "+.5/a+";\n  float xCoord = fract((index + offset) * "+
d+".x);\n  vec2 texCoords = vec2(xCoord,\n                        (index - (xCoord - 0.5 - offset * "+d+".x) * "+d+".z) *\n                        "+d+".y);\n";for(f=0;f<a;++f)e+="\n  output"+f+" = texture2D(sampler,\n                        vec2(texCoords.x +\n                             "+d+".x * "+(f/a).toFixed(8)+",\n                             texCoords.y));\n";return e+"\n}\n"}},{key:"getAccessor",value:function(d,f,c,h){h=void 0===h?1:h;var k=Object(l.a)(c,h),r=[];r.push(this.getReadTextureValueCode(c===
a.b.UINT64?2:1));d="\n"+k+" "+d+"(float index) {\n";switch(c){case a.b.UINT8:r.push(l.o);d+="\n  "+k+" result;\n  vec4 temp;\n  "+this.readTextureValue+"("+f+", index, temp);\n  result.value = temp."+e[h]+";\n  return result;\n";break;case a.b.UINT16:r.push(l.l);d+="\n  "+k+" result;\n  vec4 temp;\n  "+this.readTextureValue+"("+f+", index, temp);\n  result.value = temp."+e[2*h]+";\n  return result;\n";break;case a.b.UINT32:r.push(l.m);d+="\n  "+k+" result;\n  "+this.readTextureValue+"("+f+", index, result.value);\n  return result;\n";
break;case a.b.UINT64:r.push(l.n);d+="\n  "+k+" result;\n  "+this.readTextureValue+"("+f+", index, result.low, result.high);\n  return result;\n";break;case a.b.FLOAT32:r.push(l.f),d+="\n  vec4 temp;\n  "+this.readTextureValue+"("+f+", index, temp);\n  return temp."+e[h]+";\n"}r.push(d+"\n}\n");return r}},{key:"setupTextureLayout",value:function(a,d,e){a.uniform3fv(d.uniform(this.uniformName),e.textureAccessCoefficients)}}]);return d}()},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");
}function n(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function q(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}c.d(g,"c",function(){return v});
g.d=function(e){var d,b,f;return function(c,h){if(void 0!==b&&(void 0===d||void 0===c||d.generation!==c.generation))return void 0===d&&f.addConsumer(h),b;d=void 0;f=new a.c;return b=e(c,f).then(function(a){d=a;f=void 0;return a},function(a){f.isCanceled&&(b=f=void 0);throw a;})}};c.d(g,"a",function(){return m});c.d(g,"b",function(){return k});var a=c(34);p=c(0);var f=c(63),l=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in
e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),v=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,a);return d}(p.a),t=function(){function a(){u(this,a);this.providers=new Map}l(a,[{key:"register",value:function(a,b){this.providers.set(a,b)}},{key:"getCredentialsProvider",value:function(a,b){var d=this.providers.get(a);if(void 0===d)throw Error("No registered credentials provider: "+
JSON.stringify(a));return d(b)}}]);return a}(),m=function(a){function d(a){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));b.base=a;b.memoize=new f.b;return b}q(d,a);l(d,[{key:"getCredentialsProvider",value:function(a,d){var b=this;return this.memoize.get({key:a,parameters:d},function(){return b.registerDisposer(b.base.getCredentialsProvider(a,d).addRef())})}}]);return d}(p.a),k=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,
new t))}q(d,a);l(d,[{key:"register",value:function(a,d){this.base.register(a,d)}}]);return d}(m)},function(p,g,c){function u(a){return Object(f.a)(a.dataTransfer.types,"neuroglancer-layer\x00")}function n(a){if(void 0!==t&&t.manager.rootLayers===a.rootLayers)return t}function q(a,e,d){if(a.shiftKey)return"copy";if(a.ctrlKey)return"move";a=void 0===d?!1:d;a=void 0===a?!1:a;d=n(e);e=void 0===d?"copy":a||d.manager!==e?"link":"move";return e}g.e=function(a,e){a.dataTransfer.setData(Object(f.b)("neuroglancer-layer\x00",
e.layers.map(function(a){return{name:a.name,visible:a.visible}})),JSON.stringify(e.layers.map(function(a){return a.toJSON()})));void 0!==t&&t.disposer();var d,b=function(){e.manager.unregisterDisposer(b);for(var a=$jscomp.makeIterator(e.layers),f=a.next();!f.done;f=a.next())f.value.dispose();e.manager.dispose();t===d&&(t=void 0)};t=d={manager:e.manager.addRef(),layers:e.layers.map(function(a){return a.addRef()}),disposer:b}};g.a=function(a){if(void 0!==t){if(a&&"move"===a.dataTransfer.dropEffect){var e=
new Set(t.layers);t.manager.layerManager.filter(function(a){return!e.has(a)})}t.disposer()}};g.c=u;g.d=q;g.f=function(a,e,d){return Object(f.e)(a,q(a,e,void 0===d?!1:d))};g.b=function(f,e,d,b,c){var h=n(e),k=!c&&void 0!==h&&h.manager===e;if(!d&&void 0!==h){var g=new m;g.manager=e;g.numSourceLayers=h.layers.length;g.sourceManager=h.manager;g.moveSupported=k;g.layers=new Map;if(!c&&h.manager===e)if(b)h.layers.forEach(function(a,b){g.layers.set(a,b)});else return;h.layers.forEach(function(a,b){!c&&e.layerManager.has(a)||
g.layers.set(a.addRef(),b)});return g}f=u(f);if(void 0!==f)try{var t=Object(l.a)(f.parameters,function(b,d){var f=Object(l.w)(b,"name",l.B);b=Object(l.w)(b,"visible",l.m);f=new a.b(f,null,e);f.visible=b;return[f,d]}),v=new m;v.numSourceLayers=t.length;v.moveSupported=k;v.manager=e;v.dragType=f.dragType;v.layers=new Map(t);return v}catch(y){}};var a=c(20),f=c(96),l=c(2),v=function(){function a(a,d){for(var b=0;b<d.length;b++){var e=d[b];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&
(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(e,d,b){d&&a(e.prototype,d);b&&a(e,b);return e}}(),t,m=function(){function a(){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");}v(a,[{key:"finalize",value:function(a){var d=this.dragType;if(void 0!==d)try{var b=JSON.parse(a.dataTransfer.getData(d));if(!Array.isArray(b)||this.numSourceLayers!==b.length)throw Error("Invalid layer drop data");for(var e=$jscomp.makeIterator(this.layers),f=e.next();!f.done;f=
e.next()){var c=$jscomp.makeIterator(f.value),k=c.next().value,g=c.next().value;this.manager.initializeLayerFromSpec(k,b[g])}}catch(D){return!1}return!0}},{key:"compatibleWithMethod",value:function(a){return this.method===a||!this.moveSupported&&"move"===a?!0:!1}},{key:"method",get:function(){return void 0!==this.sourceManager?this.manager===this.sourceManager?"move":"link":"copy"}}]);return a}()},function(p,g,c){g.b=function(a,f){f=JSON.stringify(f);f=Object(u.b)((new TextEncoder).encode(f));return a+
f};g.a=function(a,f){a=$jscomp.makeIterator(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;a:{var g=f;if(c.startsWith(g))try{var t=c.substring(g.length);var m=(new TextDecoder).decode(Object(u.a)(t));var k=JSON.parse(m);break a}catch(e){k=void 0;break a}k=void 0}g=k;if(void 0!==g)return{parameters:g,dragType:c}}};g.e=function(a,f){return q=a.dataTransfer.dropEffect=f};g.c=function(){return q};g.d=function(a){a.draggable=!0;return Object(n.c)(a,"dragstart",function(a){a.stopPropagation();a.preventDefault()})};
var u=c(138),n=c(0),q},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"b",function(){return x});c.d(g,"c",function(){return z});c.d(g,"a",function(){return A});var a=c(25),f=c(153),l=c(154);p=c(0);var v=c(10),t=c(19),m=c(1),k=c(53),e=c(119),d=c(81),b=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&
a(b.prototype,d);e&&a(b,e);return b}}(),h=function y(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return y(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}};c(283);c(68);g.d="neuroglancer-position";var r=t.a.fromObject({tab:{action:"tab-forward",preventDefault:!1},arrowup:{action:"adjust-up"},arrowdown:{action:"adjust-down"},wheel:{action:"adjust-via-wheel"},"shift+tab":{action:"tab-backward",
preventDefault:!1},backspace:{action:"delete-backward",preventDefault:!1},escape:{action:"cancel"},mouseup0:{action:"select-all-if-was-not-focused",preventDefault:!1}}),x=function(d){function c(b,d){d=void 0===d?6:d;u(this,c);var h=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));h.position=b;h.maxNumberWidth=d;h.element=document.createElement("div");h.inputContainer=document.createElement("div");h.inputElement=document.createElement("input");h.hintElement=document.createElement("input");
h.tempPosition=m.s.create();h.updateHintScrollPosition=h.registerCancellable(Object(f.a)(function(){h.hintElement.scrollLeft=h.inputElement.scrollLeft}));var g=h.element,v=h.inputElement,x=h.hintElement,q=h.inputContainer;q.className="neuroglancer-position-widget-input-container";v.className="neuroglancer-position-widget-input";x.className="neuroglancer-position-widget-hint";h.inputFieldWidth=3*d+11;d=$jscomp.makeIterator([v,x]);for(var z=d.next();!z.done;z=d.next())z=z.value,z.spellcheck=!1,z.autocomplete=
"off",z.type="text",z.style.width=h.inputFieldWidth+"ch";x.disabled=!0;d=document.createElement("div");d.textContent="\u29c9";d.className="neuroglancer-copy-button neuroglancer-button";d.title="Copy position to clipboard";d.addEventListener("click",function(){var b=Object(l.b)(h.getPositionText());a.a.showTemporaryMessage(b?"Position copied to clipboard":"Failed to copy position to clipboard")});d.addEventListener("dragstart",function(a){a.dataTransfer.setData("neuroglancer-position",JSON.stringify(b.toJSON()));
a.dataTransfer.setData("text",h.getPositionText());a.stopPropagation()});d.draggable=!0;g.appendChild(d);g.appendChild(q);q.appendChild(v);q.appendChild(x);g.className="neuroglancer-position-widget";h.registerDisposer(b.changed.add(h.registerCancellable(Object(f.a)(function(){return h.updateView()}))));h.registerDisposer(new k.b(v,r)).allShortcutsAreGlobal=!0;h.registerDisposer(new e.a(v,r));h.registerEventListener(v,"change",function(){return h.updatePosition()});h.registerEventListener(v,"blur",
function(){return h.updatePosition()});h.registerEventListener(v,"input",function(){return h.cleanInput()});h.registerEventListener(v,"keydown",h.updateHintScrollPosition);h.registerEventListener(v,"copy",function(a){var b=v.value.substring(v.selectionStart,v.selectionEnd);b=b.trim().replace(/\s+/g," ");a.clipboardData.setData("text/plain",b);a.stopPropagation();a.preventDefault()});var p=!1;h.registerEventListener(v,"mousedown",function(){p=document.activeElement===v});h.registerDisposer(Object(t.c)(v,
"select-all-if-was-not-focused",function(a){p||(v.selectionStart=0,v.selectionEnd=v.value.length,v.selectionDirection="forward",a.preventDefault())}));h.registerDisposer(Object(t.c)(v,"tab-forward",function(a){var b=Math.min(v.selectionStart,v.selectionEnd),d=v.value.substring(b).match(/^([^,\s]*)((?:\s+)|(?:\s*,\s*))?([^,\s]*)/);null!==d&&void 0!==d[2]&&(v.selectionStart=b+d[1].length+d[2].length,v.selectionEnd=v.selectionStart+d[3].length,v.selectionDirection="forward",a.preventDefault())}));h.registerDisposer(Object(t.c)(v,
"tab-backward",function(a){var b=v.value.substring(0,Math.max(v.selectionStart,v.selectionEnd)).match(/([^,\s]*)((?:\s+)|(?:\s*,\s*))?([^,\s]*)$/);null!==b&&void 0!==b[2]&&(v.selectionStart=b.index,v.selectionEnd=v.selectionStart+b[1].length,v.selectionDirection="forward",a.preventDefault())}));h.registerDisposer(Object(t.c)(v,"delete-backward",function(a){if(v.selectionStart===v.selectionEnd&&v.selectionStart===v.value.length){var b=v.value.match(/^(.*)(?![\s])(?:(?:\s+)|(?:\s*,\s*))$/);null!==b&&
(v.value=b[1],h.cleanInput(),a.preventDefault())}}));h.registerDisposer(Object(t.c)(v,"cancel",function(){h.updateView();h.inputElement.blur()}));h.registerDisposer(Object(t.c)(v,"adjust-via-wheel",function(a){a=a.detail;var b=a.deltaY;0!==b&&h.adjustFromCursor(Math.ceil((v.scrollLeft+a.offsetX-v.clientLeft)/(v.scrollWidth/h.inputFieldWidth)),-Math.sign(b))}));h.registerDisposer(Object(t.c)(v,"adjust-up",function(){h.adjustFromCursor(void 0,1)}));h.registerDisposer(Object(t.c)(v,"adjust-down",function(){h.adjustFromCursor(void 0,
-1)}));h.updateView();return h}q(c,d);b(c,[{key:"adjustFromCursor",value:function(a,b){var d=this.inputElement;void 0===a&&(a="forward"===d.selectionDirection?d.selectionEnd:d.selectionStart);void 0!==this.cleanInput()&&(a=d.value.substring(0,a).split(",").length-1,this.updatePosition(),d=this.tempPosition,this.position.getVoxelCoordinates(d)&&(d[a]+=b,this.position.setVoxelCoordinates(d),this.updateView()))}},{key:"cleanInput",value:function(){var a=this.inputElement.selectionStart,b=/(-?\d+(?:\.(?:\d+)?)?)/.source,
d=/((?:\s+(?![\s,]))|(?:\s*,\s*))/.source,e=/([\[\]{}()\s]*)/.source;b=this.inputElement.value.match(new RegExp("^"+e+"(?![\\s])"+b+"?"+("(?:"+d+b+"?(?:"+d+b+"?)?)?")+(e+"$")));if(null!==b){var f="  ",c="x ",h=2,k=b[1].length;d=function(b,d,e){if(void 0!==b){var r=k+b.length;void 0===d&&(d=b,e=" ".repeat(d.length));a>=k&&(h=a===r?f.length+d.length:f.length+Math.min(d.length,a-k));f+=d;c+=e;k=r}};d(b[2]);d(b[3],",   ","  y ");d(b[4]);d(b[5],",   ","  z ");d(b[6]);this.hintElement.value=c;this.inputElement.value!==
f&&(this.inputElement.value=f,this.inputElement.selectionEnd=h,this.inputElement.selectionStart=h);this.updateHintScrollPosition();return void 0!==b[2]&&void 0!==b[4]&&void 0!==b[6]?{position:m.s.set(this.tempPosition,parseFloat(b[2]),parseFloat(b[4]),parseFloat(b[6]))}:{}}this.hintElement.value=""}},{key:"updatePosition",value:function(){var a=this.cleanInput();void 0!==a&&void 0!==a.position&&this.position.setVoxelCoordinates(a.position)}},{key:"getPositionText",value:function(){var a=this.tempPosition;
return this.position.getVoxelCoordinates(a)?Math.floor(a[0])+", "+Math.floor(a[1])+", "+Math.floor(a[2]):"<unspecified position>"}},{key:"updateView",value:function(){var a=this.tempPosition;if(this.position.getVoxelCoordinates(a)){var b=this.inputElement;a="  "+Math.floor(a[0])+",   "+Math.floor(a[1])+",   "+Math.floor(a[2]);var d=a.indexOf(","),e=a.indexOf(",",d+1)-d-4;d="x "+" ".repeat(d-2)+"  y "+" ".repeat(e)+"  z";e=b.selectionStart;var f=b.selectionEnd,c=b.selectionDirection;b.value=a;b.setSelectionRange(e,
f,c);this.hintElement.value=d+" ".repeat(a.length-d.length);this.updateHintScrollPosition()}else this.inputElement.value="",this.hintElement.value=""}},{key:"disposed",value:function(){Object(v.b)(this.element);h(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}}]);return c}(p.a),z=function(a){function e(a,b){u(this,e);var d=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.element=a;d.voxelSize=b;d.dimensionsContainer=document.createElement("span");
d.unitsElement=document.createElement("span");var c=d.dimensionsContainer,h=d.unitsElement;a.className="neuroglancer-voxel-size-widget";a.title="Voxel size";c.className="neuroglancer-voxel-size-dimensions-container";a.appendChild(c);a.appendChild(h);h.className="neuroglancer-voxel-size-units";d.registerDisposer(b.changed.add(d.registerCancellable(Object(f.a)(function(){return d.updateView()}))));d.updateView();return d}q(e,a);b(e,[{key:"updateView",value:function(){var a=this.dimensionsContainer,
b=this.unitsElement;Object(v.a)(a);this.element.style.display=this.voxelSize.valid?null:"none";var e=this.voxelSize.size,f=Object(d.b)(Math.min(e[0],e[1],e[2]));b.textContent=f.unit;for(b=0;3>b;++b){for(var c=e[b]/f.lengthInNanometers,h="",k=0;2>=k&&(h=c.toFixed(k),parseFloat(h)!==c);++k);c=document.createElement("span");c.className="neuroglancer-voxel-size-dimension";c.textContent=h;a.appendChild(c)}}},{key:"disposed",value:function(){Object(v.b)(this.element);h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),
"disposed",this).call(this)}}]);return e}(p.a),A=function(a){function d(a,b,e){u(this,d);var c=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));c.element=a;c.mouseState=b;c.voxelSize=e;c.tempPosition=m.s.create();a.className="neuroglancer-mouse-position-widget";a=c.registerCancellable(Object(f.a)(function(){return c.updateView()}));c.registerDisposer(b.changed.add(a));c.registerDisposer(e.changed.add(a));return c}q(d,a);b(d,[{key:"updateView",value:function(){var a="",b=this.mouseState,
d=this.voxelSize;b.active&&d.valid&&(a=this.tempPosition,d.voxelFromSpatial(a,b.position),a="x "+Math.floor(a[0])+",  y "+Math.floor(a[1])+",  z "+Math.floor(a[2]));this.element.textContent=a}},{key:"disposed",value:function(){Object(v.b)(this.element);h(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}}]);return d}(p.a)},function(p,g,c){(function(g,n){function q(f,e,d){m(f,e);var b=this;a.call(this);setTimeout(function(){b._start(f,e,d)},0)}var a=c(13).EventEmitter,
f=c(4),l=c(38),v=c(60),t=c(21),m=function(){};"production"!==g.env.NODE_ENV&&(m=c(9)("sockjs-client:sender:xdr"));f(q,a);q.prototype._start=function(a,e,d){m("_start");var b=this,f=new n.XDomainRequest;e=t.addQuery(e,"t="+ +new Date);f.onerror=function(){m("onerror");b._error()};f.ontimeout=function(){m("ontimeout");b._error()};f.onprogress=function(){m("progress",f.responseText);b.emit("chunk",200,f.responseText)};f.onload=function(){m("load");b.emit("finish",200,f.responseText);b._cleanup(!1)};
this.xdr=f;this.unloadRef=l.unloadAdd(function(){b._cleanup(!0)});try{this.xdr.open(a,e),this.timeout&&(this.xdr.timeout=this.timeout),this.xdr.send(d)}catch(r){this._error()}};q.prototype._error=function(){this.emit("finish",0,"");this._cleanup(!1)};q.prototype._cleanup=function(a){m("cleanup",a);if(this.xdr){this.removeAllListeners();l.unloadDel(this.unloadRef);this.xdr.ontimeout=this.xdr.onerror=this.xdr.onprogress=this.xdr.onload=null;if(a)try{this.xdr.abort()}catch(e){}this.unloadRef=this.xdr=
null}};q.prototype.close=function(){m("close");this._cleanup(!0)};q.enabled=!(!n.XDomainRequest||!v.hasDomain());p.exports=q}).call(g,c(8),c(7))},function(p,g,c){(function(g){var n=c(4),q=c(165),a=c(100);p.exports=function(f){function c(a,c){q.call(this,f.transportName,a,c)}n(c,q);c.enabled=function(c,l){if(!g.document)return!1;c=a.extend({},l);c.sameOrigin=!0;return f.enabled(c)&&q.enabled()};c.transportName="iframe-"+f.transportName;c.needBody=!0;c.roundTrips=q.roundTrips+f.roundTrips-1;c.facadeTransport=
f;return c}}).call(g,c(7))},function(p,g,c){p.exports={isObject:function(c){var g=typeof c;return"function"===g||"object"===g&&!!c},extend:function(c){if(!this.isObject(c))return c;for(var g,q,a=1,f=arguments.length;a<f;a++)for(q in g=arguments[a],g)Object.prototype.hasOwnProperty.call(g,q)&&(c[q]=g[q]);return c}}},function(p,g,c){function u(c){this.type=c}u.prototype.initEvent=function(c,g,a){this.type=c;this.bubbles=g;this.cancelable=a;this.timeStamp=+new Date;return this};u.prototype.stopPropagation=
function(){};u.prototype.preventDefault=function(){};u.CAPTURING_PHASE=1;u.AT_TARGET=2;u.BUBBLING_PHASE=3;p.exports=u},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){Object(C.u)(a);try{return{corner:Object(C.w)(a,"corner",function(a){return Object(C.f)(B.s.create(),a,C.o)}),size:Object(C.w)(a,"size",function(a){return Object(C.f)(B.s.create(),a,C.p)}),metadata:Object(C.w)(a,"metadata",C.z)}}catch(X){throw Error("Failed to parse bounding box: "+X.message);}}function f(a){var b=
a.match(/^([^:?]+:[^:?]+:[^:?]+)(?::([^:?]+))?(?:\?(.*))?$/);if(null===b)throw Error("Invalid Brain Maps volume key: "+JSON.stringify(a)+".");var d;void 0!==b[2]&&(d={changeStackId:b[2]});a=Object(C.e)(b[3]||"");return{volumeId:b[1],changeSpec:d,parameters:a}}function l(a){try{return Object(C.u)(a),{id:Object(C.w)(a,"id",C.B),label:Object(C.w)(a,"label",C.B),description:Object(C.w)(a,"description",C.z)}}catch(X){throw Error("Failed to parse project: "+X.message);}}function v(a){try{return Object(C.u)(a),
Object(C.w)(a,"project",function(a){return void 0===a?[]:Object(C.a)(a,l)})}catch(X){throw Error("Error parsing project list: "+X.message);}}function t(a){return Object(C.w)(a,"changeStackId",function(a){return void 0===a?void 0:Object(C.a)(a,C.B)})}function m(a){a=a.scales[0];return[[{parameters:void 0,spec:new e.h({voxelSize:a.voxelSize,chunkSize:B.s.multiply(B.s.create(),a.upperVoxelBound,a.voxelSize),upperChunkBound:B.s.fromValues(1,1,1)})}]]}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,
"BrainmapsSkeletonSource",function(){return N});c.d(g,"VolumeInfo",function(){return O});c.d(g,"MultiscaleVolumeInfo",function(){return T});c.d(g,"MeshInfo",function(){return W});c.d(g,"MultiscaleVolumeChunkSource",function(){return aa});g.parseVolumeKey=f;c.d(g,"VolumeList",function(){return S});g.parseChangeStackList=t;c.d(g,"BrainmapsAnnotationSource",function(){return ha});c.d(g,"BrainmapsDataSource",function(){return L});var k=c(22),e=c(72);p=c(62);var d=c(17),b=c(208),h=c(37),r=c(121),x=c(212),
z=c(55),A=c(82),D=c(31),y=c(18),E=c(28),G=c(25),H=c(54),B=c(1),C=c(2),F=c(24),M=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),I=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(d.f)(Object(b.a)()(E.b),x.e)),P=function(a){function b(){u(this,
b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(d.f)(Object(b.a)()(z.b),x.b)),N=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);M(b,[{key:"skeletonVertexCoordinatesInVoxels",get:function(){return!1}}]);return b}(Object(d.f)(Object(b.a)()(A.d),x.c)),U=new Map;U.set("UINT8",y.a.UINT8);U.set("FLOAT",y.a.FLOAT32);U.set("UINT64",y.a.UINT64);var O=function X(b){u(this,X);try{Object(C.u)(b),
this.numChannels=Object(C.w)(b,"channelCount",C.A),this.dataType=Object(C.w)(b,"channelType",function(a){return Object(C.t)(a,U)}),this.voxelSize=Object(C.w)(b,"pixelSize",function(a){return Object(C.f)(B.s.create(),a,C.p)}),this.upperVoxelBound=Object(C.w)(b,"volumeSize",function(a){return Object(C.f)(B.s.create(),a,C.A)}),this.boundingBoxes=Object(C.w)(b,"boundingBox",function(b){return void 0===b?[]:Object(C.a)(b,a)})}catch(Y){throw Error("Failed to parse BrainMaps volume geometry: "+Y.message);
}},T=function R(a){u(this,R);try{Object(C.u)(a);var b=this.scales=Object(C.w)(a,"geometry",function(a){return Object(C.a)(a,function(a){return new O(a)})});if(0===b.length)throw Error("Expected at least one scale.");var d=b[0],e=this.numChannels=d.numChannels,f=this.dataType=d.dataType;a=1;for(var c=b.length;a<c;++a){var h=b[a];if(h.dataType!==f)throw Error("Scale "+a+" has data type "+y.a[h.dataType]+" "+("but scale 0 has data type "+y.a[f]+"."));if(h.numChannels!==e)throw Error("Scale "+a+" has "+
h.numChannels+" channel(s) "+("but scale 0 has "+e+" channels."));}}catch(Ba){throw Error("Failed to parse BrainMaps multiscale volume specification: "+Ba.message);}},W=function Y(a){u(this,Y);Object(C.u)(a);this.name=Object(C.w)(a,"name",C.B);this.type=Object(C.w)(a,"type",C.B)},aa=function(){function a(b,d,e,f,c,h,k,r){u(this,a);this.chunkManager=b;this.instance=d;this.credentialsProvider=e;this.volumeId=f;this.changeSpec=c;this.multiscaleVolumeInfo=h;this.encoding=r.encoding;this.chunkLayoutPreference=
r.chunkLayoutPreference;if(1===this.numChannels)switch(this.dataType){case y.a.UINT64:var g=y.c.SEGMENTATION}void 0===g&&(g=void 0!==r.volumeType?r.volumeType:y.c.IMAGE);this.volumeType=g;try{Object(C.u)(k),this.meshes=Object(C.w)(k,"meshes",function(a){return void 0===a?[]:Object(C.a)(a,function(a){return new W(a)})})}catch(Gb){throw Error("Failed to parse BrainMaps meshes specification: "+Gb.message);}}M(a,[{key:"getSources",value:function(a){var b=this,d=x.d.RAW;this.dataType===y.a.UINT64?d=x.d.COMPRESSED_SEGMENTATION:
this.volumeType===y.c.IMAGE&&this.dataType===y.a.UINT8&&1===this.numChannels&&this.encoding!==x.d.RAW&&(d=x.d.JPEG);return this.scales.map(function(e,f){return y.b.getDefaults({voxelSize:e.voxelSize,dataType:e.dataType,numChannels:e.numChannels,upperVoxelBound:e.upperVoxelBound,volumeType:b.volumeType,volumeSourceOptions:a,chunkLayoutPreference:b.chunkLayoutPreference}).map(function(a){return b.chunkManager.getChunkSource(I,{credentialsProvider:b.credentialsProvider,spec:a,parameters:{instance:b.instance,
volumeId:b.volumeId,changeSpec:b.changeSpec,scaleIndex:f,encoding:d}})})})}},{key:"getMeshSource",value:function(){for(var a=$jscomp.makeIterator(this.meshes),b=a.next();!b.done;b=a.next()){b=b.value;if("TRIANGLES"===b.type)return this.chunkManager.getChunkSource(P,{credentialsProvider:this.credentialsProvider,parameters:{instance:this.instance,volumeId:this.volumeId,meshName:b.name,changeSpec:this.changeSpec}});if("LINE_SEGMENTS"===b.type)return this.chunkManager.getChunkSource(N,{credentialsProvider:this.credentialsProvider,
parameters:{instance:this.instance,volumeId:this.volumeId,meshName:b.name,changeSpec:this.changeSpec}})}return null}},{key:"getStaticAnnotations",value:function(){var a=this.scales[0],b=new k.b(B.k.fromScaling(B.k.create(),a.voxelSize));b.readonly=!0;b.add(Object(k.h)(B.s.create(),a.upperVoxelBound));a.boundingBoxes.forEach(function(a,d){b.add({type:k.c.AXIS_ALIGNED_BOUNDING_BOX,description:a.metadata,pointA:a.corner,pointB:B.s.add(B.s.create(),a.corner,a.size),id:"boundingBox"+d})});return b}},{key:"scales",
get:function(){return this.multiscaleVolumeInfo.scales}},{key:"dataType",get:function(){return this.multiscaleVolumeInfo.dataType}},{key:"numChannels",get:function(){return this.multiscaleVolumeInfo.numChannels}}]);return a}(),J=/^([^\/]+)\/(.*)$/,S=function Ca(a,b){u(this,Ca);this.projects=new Map;this.hierarchicalVolumeIds=new Map;var d=this.projects;a=$jscomp.makeIterator(v(a));for(var e=a.next();!e.done;e=a.next())e=e.value,d.set(e.id,e);try{Object(C.u)(b);var f=this.volumeIds=Object(C.w)(b,"volumeId",
function(a){return void 0===a?[]:Object(C.a)(a,C.B)});f.sort();for(var c=new Map,h=$jscomp.makeIterator(f),k=h.next();!k.done;k=h.next()){var r=k.value;for(b=0;;){var g=r.indexOf(":",b);-1===g?g=void 0:++g;var l=r.substring(0,b),m=c.get(l);void 0===m&&(m=new Set,c.set(l,m));m.add(r.substring(b,g));if(void 0===g)break;b=g}}for(var t=this.hierarchicalVolumeIds,x=$jscomp.makeIterator(c),n=x.next();!n.done;n=x.next()){var q=$jscomp.makeIterator(n.value),z=q.next().value,p=q.next().value;t.set(z,Array.from(p))}}catch(Ua){throw Error("Failed to parse Brain Maps volume list reply: "+
Ua.message);}},ha=function(a){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,Object.assign({sourceSpecifications:m(d.multiscaleVolumeInfo)},d)));B.k.fromScaling(a.objectToLocal,d.multiscaleVolumeInfo.scales[0].voxelSize);return a}q(b,a);return b}(Object(d.f)(Object(b.a)()(p.c),x.a)),L=function(a){function b(a,d){u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.instance=a;e.credentialsProvider=d;return e}q(b,a);M(b,[{key:"getMeshSource",
value:function(a,b){return a.getChunkSource(P,{credentialsProvider:this.credentialsProvider,parameters:this.getMeshSourceParameters(b)})}},{key:"getMeshSourceParameters",value:function(a){var b=a.match(J);if(null===b)throw Error("Invalid Brainmaps mesh URL: "+a);a=f(b[1]);return{instance:this.instance,volumeId:a.volumeId,changeSpec:a.changeSpec,meshName:b[2]}}},{key:"getSkeletonSource",value:function(a,b){return a.getChunkSource(N,{credentialsProvider:this.credentialsProvider,parameters:this.getMeshSourceParameters(b)})}},
{key:"getMultiscaleInfo",value:function(a,b){var d=this;return a.memoize.getUncounted({type:"brainmaps:getMultiscaleInfo",volumeId:b,instance:this.instance,credentialsProvider:Object(F.a)(this.credentialsProvider)},function(){return Object(r.b)(d.instance,d.credentialsProvider,{method:"GET",path:"/v1beta2/volumes/"+b,responseType:"json"}).then(function(a){return new T(a)})})}},{key:"getVolume",value:function(a,b,d){var e=this;b=f(b);var c=b.volumeId,h=b.changeSpec,k=b.parameters;Object(C.u)(k);b=
Object(C.w)(k,"encoding",function(a){return void 0===a?void 0:Object(C.n)(a,x.d)});k=Object(C.w)(k,"chunkLayout",function(a){return void 0===a?void 0:Object(C.n)(a,D.a)});var g=Object.assign({},d,{encoding:b,chunkLayoutPreference:k});return a.memoize.getUncounted({type:"brainmaps:getVolume",instance:this.instance,volumeId:c,changeSpec:h,brainmapsOptions:g},function(){return Promise.all([e.getMultiscaleInfo(a,c),Object(r.b)(e.instance,e.credentialsProvider,{method:"GET",path:"/v1beta2/objects/"+c+
"/meshes",responseType:"json"})]).then(function(b){var d=$jscomp.makeIterator(b);b=d.next().value;d=d.next().value;return new aa(a,e.instance,e.credentialsProvider,c,h,b,d,g)})})}},{key:"getAnnotationSource",value:function(a,b){var d=this;b=f(b);var e=b.volumeId;b=b.changeSpec;if(void 0===b)throw Error("A changestack must be specified.");var c={instance:this.instance,volumeId:e,changestack:b.changeStackId};return a.memoize.getUncounted({type:"brainmaps:getAnnotationSource",instance:this.instance,
credentialsProvider:Object(F.a)(this.credentialsProvider),parameters:c},function(){return d.getMultiscaleInfo(a,e).then(function(b){return a.getChunkSource(ha,{parameters:c,credentialsProvider:d.credentialsProvider,multiscaleVolumeInfo:b})})})}},{key:"getVolumeList",value:function(a){var b=this;return a.memoize.getUncounted({instance:this.instance,type:"brainmaps:getVolumeList"},function(){var a=Promise.all([Object(r.b)(b.instance,b.credentialsProvider,{method:"GET",path:"/v1beta2/projects",responseType:"json"}),
Object(r.b)(b.instance,b.credentialsProvider,{method:"GET",path:"/v1beta2/volumes",responseType:"json"})]).then(function(a){var b=$jscomp.makeIterator(a);a=b.next().value;b=b.next().value;return new S(a,b)}),d=b.instance.description+" volume list";G.a.forPromise(a,{delay:!0,initialMessage:"Retrieving "+d+".",errorPrefix:"Error retrieving "+d+": "});return a})}},{key:"getChangeStackList",value:function(a,b){var d=this;return a.memoize.getUncounted({instance:this.instance,type:"brainmaps:getChangeStackList",
volumeId:b},function(){var a=Object(r.b)(d.instance,d.credentialsProvider,{method:"GET",path:"/v1beta2/changes/"+b+"/change_stacks",responseType:"json"}).then(function(a){return t(a)}),e="change stacks for "+b;G.a.forPromise(a,{delay:!0,initialMessage:"Retrieving "+e+".",errorPrefix:"Error retrieving "+e+": "});return a})}},{key:"volumeCompleter",value:function(a,b){var d=this;return this.getVolumeList(b).then(function(e){var f=a.match(/^([^:]+:[^:]+:[^:]+):(.*)$/);if(null!==f){var c=f[1],h=f[2];
return d.getChangeStackList(b,c).then(function(a){if(void 0===a)throw null;return{offset:c.length+1,completions:Object(H.b)(h,a)}})}var k=a.lastIndexOf(":")+1;f=a.substring(0,k);k=a.substring(k);var r=e.hierarchicalVolumeIds.get(f);if(void 0===r)throw null;return f?{offset:f.length,completions:Object(H.b)(k,r)}:{offset:0,completions:Object(H.c)(k,r,function(a){return a},function(a){return(a=e.projects.get(a.substring(0,a.length-1)))&&a.label})}})}},{key:"description",get:function(){return this.instance.description}}]);
return b}(h.a);g.productionInstance={description:"Google Brain Maps",serverUrls:["https://brainmaps.googleapis.com"]}},function(p,g,c){function u(a,f,c){var g=f[0],l=f[1],m=f[2],k=f[3],e=f[4],d=f[5],b=f[6],h=f[7];f=f[8];var r=c[0],x=c[1],n=c[2],q=c[3],u=c[4],p=c[5],E=c[6],G=c[7];c=c[8];a[0]=r*g+x*k+n*b;a[1]=r*l+x*e+n*h;a[2]=r*m+x*d+n*f;a[3]=q*g+u*k+p*b;a[4]=q*l+u*e+p*h;a[5]=q*m+u*d+p*f;a[6]=E*g+G*k+c*b;a[7]=E*l+G*e+c*h;a[8]=E*m+G*d+c*f;return a}function n(a,f,c){a[0]=f[0]-c[0];a[1]=f[1]-c[1];a[2]=
f[2]-c[2];a[3]=f[3]-c[3];a[4]=f[4]-c[4];a[5]=f[5]-c[5];a[6]=f[6]-c[6];a[7]=f[7]-c[7];a[8]=f[8]-c[8];return a}Object.defineProperty(g,"__esModule",{value:!0});g.create=function(){var a=new q.a(9);a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};g.fromMat4=function(a,f){a[0]=f[0];a[1]=f[1];a[2]=f[2];a[3]=f[4];a[4]=f[5];a[5]=f[6];a[6]=f[8];a[7]=f[9];a[8]=f[10];return a};g.clone=function(a){var f=new q.a(9);f[0]=a[0];f[1]=a[1];f[2]=a[2];f[3]=a[3];f[4]=a[4];f[5]=a[5];f[6]=a[6];
f[7]=a[7];f[8]=a[8];return f};g.copy=function(a,f){a[0]=f[0];a[1]=f[1];a[2]=f[2];a[3]=f[3];a[4]=f[4];a[5]=f[5];a[6]=f[6];a[7]=f[7];a[8]=f[8];return a};g.fromValues=function(a,f,c,g,t,m,k,e,d){var b=new q.a(9);b[0]=a;b[1]=f;b[2]=c;b[3]=g;b[4]=t;b[5]=m;b[6]=k;b[7]=e;b[8]=d;return b};g.set=function(a,f,c,g,t,m,k,e,d,b){a[0]=f;a[1]=c;a[2]=g;a[3]=t;a[4]=m;a[5]=k;a[6]=e;a[7]=d;a[8]=b;return a};g.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};g.transpose=function(a,
f){if(a===f){var c=f[1],g=f[2],t=f[5];a[1]=f[3];a[2]=f[6];a[3]=c;a[5]=f[7];a[6]=g;a[7]=t}else a[0]=f[0],a[1]=f[3],a[2]=f[6],a[3]=f[1],a[4]=f[4],a[5]=f[7],a[6]=f[2],a[7]=f[5],a[8]=f[8];return a};g.invert=function(a,f){var c=f[0],g=f[1],t=f[2],m=f[3],k=f[4],e=f[5],d=f[6],b=f[7];f=f[8];var h=f*k-e*b,r=-f*m+e*d,x=b*m-k*d,n=c*h+g*r+t*x;if(!n)return null;n=1/n;a[0]=h*n;a[1]=(-f*g+t*b)*n;a[2]=(e*g-t*k)*n;a[3]=r*n;a[4]=(f*c-t*d)*n;a[5]=(-e*c+t*m)*n;a[6]=x*n;a[7]=(-b*c+g*d)*n;a[8]=(k*c-g*m)*n;return a};g.adjoint=
function(a,f){var c=f[0],g=f[1],t=f[2],m=f[3],k=f[4],e=f[5],d=f[6],b=f[7];f=f[8];a[0]=k*f-e*b;a[1]=t*b-g*f;a[2]=g*e-t*k;a[3]=e*d-m*f;a[4]=c*f-t*d;a[5]=t*m-c*e;a[6]=m*b-k*d;a[7]=g*d-c*b;a[8]=c*k-g*m;return a};g.determinant=function(a){var f=a[3],c=a[4],g=a[5],t=a[6],m=a[7],k=a[8];return a[0]*(k*c-g*m)+a[1]*(-k*f+g*t)+a[2]*(m*f-c*t)};g.multiply=u;g.translate=function(a,f,c){var g=f[0],l=f[1],m=f[2],k=f[3],e=f[4],d=f[5],b=f[6],h=f[7];f=f[8];var r=c[0];c=c[1];a[0]=g;a[1]=l;a[2]=m;a[3]=k;a[4]=e;a[5]=d;
a[6]=r*g+c*k+b;a[7]=r*l+c*e+h;a[8]=r*m+c*d+f;return a};g.rotate=function(a,f,c){var g=f[0],l=f[1],m=f[2],k=f[3],e=f[4],d=f[5],b=f[6],h=f[7];f=f[8];var r=Math.sin(c);c=Math.cos(c);a[0]=c*g+r*k;a[1]=c*l+r*e;a[2]=c*m+r*d;a[3]=c*k-r*g;a[4]=c*e-r*l;a[5]=c*d-r*m;a[6]=b;a[7]=h;a[8]=f;return a};g.scale=function(a,f,c){var g=c[0];c=c[1];a[0]=g*f[0];a[1]=g*f[1];a[2]=g*f[2];a[3]=c*f[3];a[4]=c*f[4];a[5]=c*f[5];a[6]=f[6];a[7]=f[7];a[8]=f[8];return a};g.fromTranslation=function(a,f){a[0]=1;a[1]=0;a[2]=0;a[3]=0;
a[4]=1;a[5]=0;a[6]=f[0];a[7]=f[1];a[8]=1;return a};g.fromRotation=function(a,f){var c=Math.sin(f);f=Math.cos(f);a[0]=f;a[1]=c;a[2]=0;a[3]=-c;a[4]=f;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};g.fromScaling=function(a,f){a[0]=f[0];a[1]=0;a[2]=0;a[3]=0;a[4]=f[1];a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a};g.fromMat2d=function(a,f){a[0]=f[0];a[1]=f[1];a[2]=0;a[3]=f[2];a[4]=f[3];a[5]=0;a[6]=f[4];a[7]=f[5];a[8]=1;return a};g.fromQuat=function(a,f){var c=f[0],g=f[1],t=f[2];f=f[3];var m=c+c,k=g+g,e=t+t;c*=m;var d=g*
m;g*=k;var b=t*m,h=t*k;t*=e;m*=f;k*=f;f*=e;a[0]=1-g-t;a[3]=d-f;a[6]=b+k;a[1]=d+f;a[4]=1-c-t;a[7]=h-m;a[2]=b-k;a[5]=h+m;a[8]=1-c-g;return a};g.normalFromMat4=function(a,f){var c=f[0],g=f[1],t=f[2],m=f[3],k=f[4],e=f[5],d=f[6],b=f[7],h=f[8],r=f[9],x=f[10],n=f[11],q=f[12],u=f[13],p=f[14];f=f[15];var E=c*e-g*k,G=c*d-t*k,H=c*b-m*k,B=g*d-t*e,C=g*b-m*e,F=t*b-m*d,M=h*u-r*q,I=h*p-x*q;h=h*f-n*q;var P=r*p-x*u;r=r*f-n*u;x=x*f-n*p;n=E*x-G*r+H*P+B*h-C*I+F*M;if(!n)return null;n=1/n;a[0]=(e*x-d*r+b*P)*n;a[1]=(d*h-
k*x-b*I)*n;a[2]=(k*r-e*h+b*M)*n;a[3]=(t*r-g*x-m*P)*n;a[4]=(c*x-t*h+m*I)*n;a[5]=(g*h-c*r-m*M)*n;a[6]=(u*F-p*C+f*B)*n;a[7]=(p*H-q*F-f*G)*n;a[8]=(q*C-u*H+f*E)*n;return a};g.projection=function(a,f,c){a[0]=2/f;a[1]=0;a[2]=0;a[3]=0;a[4]=-2/c;a[5]=0;a[6]=-1;a[7]=1;a[8]=1;return a};g.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"};g.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+
Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2))};g.add=function(a,f,c){a[0]=f[0]+c[0];a[1]=f[1]+c[1];a[2]=f[2]+c[2];a[3]=f[3]+c[3];a[4]=f[4]+c[4];a[5]=f[5]+c[5];a[6]=f[6]+c[6];a[7]=f[7]+c[7];a[8]=f[8]+c[8];return a};g.subtract=n;g.multiplyScalar=function(a,f,c){a[0]=f[0]*c;a[1]=f[1]*c;a[2]=f[2]*c;a[3]=f[3]*c;a[4]=f[4]*c;a[5]=f[5]*c;a[6]=f[6]*c;a[7]=f[7]*c;a[8]=f[8]*c;return a};g.multiplyScalarAndAdd=function(a,f,c,g){a[0]=f[0]+c[0]*g;a[1]=f[1]+c[1]*g;a[2]=f[2]+
c[2]*g;a[3]=f[3]+c[3]*g;a[4]=f[4]+c[4]*g;a[5]=f[5]+c[5]*g;a[6]=f[6]+c[6]*g;a[7]=f[7]+c[7]*g;a[8]=f[8]+c[8]*g;return a};g.exactEquals=function(a,f){return a[0]===f[0]&&a[1]===f[1]&&a[2]===f[2]&&a[3]===f[3]&&a[4]===f[4]&&a[5]===f[5]&&a[6]===f[6]&&a[7]===f[7]&&a[8]===f[8]};g.equals=function(a,f){var c=a[0],g=a[1],t=a[2],m=a[3],k=a[4],e=a[5],d=a[6],b=a[7];a=a[8];var h=f[0],r=f[1],x=f[2],n=f[3],u=f[4],p=f[5],y=f[6],E=f[7];f=f[8];return Math.abs(c-h)<=q.b*Math.max(1,Math.abs(c),Math.abs(h))&&Math.abs(g-
r)<=q.b*Math.max(1,Math.abs(g),Math.abs(r))&&Math.abs(t-x)<=q.b*Math.max(1,Math.abs(t),Math.abs(x))&&Math.abs(m-n)<=q.b*Math.max(1,Math.abs(m),Math.abs(n))&&Math.abs(k-u)<=q.b*Math.max(1,Math.abs(k),Math.abs(u))&&Math.abs(e-p)<=q.b*Math.max(1,Math.abs(e),Math.abs(p))&&Math.abs(d-y)<=q.b*Math.max(1,Math.abs(d),Math.abs(y))&&Math.abs(b-E)<=q.b*Math.max(1,Math.abs(b),Math.abs(E))&&Math.abs(a-f)<=q.b*Math.max(1,Math.abs(a),Math.abs(f))};var q=c(30);g.mul=u;g.sub=n},function(p,g,c){function u(){var a=
new d.a(3);a[0]=0;a[1]=0;a[2]=0;return a}function n(a){var b=a[0],d=a[1];a=a[2];return Math.sqrt(b*b+d*d+a*a)}function q(a,e,f){var b=new d.a(3);b[0]=a;b[1]=e;b[2]=f;return b}function a(a,d,e){a[0]=d[0]-e[0];a[1]=d[1]-e[1];a[2]=d[2]-e[2];return a}function f(a,d,e){a[0]=d[0]*e[0];a[1]=d[1]*e[1];a[2]=d[2]*e[2];return a}function l(a,d,e){a[0]=d[0]/e[0];a[1]=d[1]/e[1];a[2]=d[2]/e[2];return a}function v(a,d){var b=d[0]-a[0],e=d[1]-a[1];a=d[2]-a[2];return Math.sqrt(b*b+e*e+a*a)}function t(a,d){var b=d[0]-
a[0],e=d[1]-a[1];a=d[2]-a[2];return b*b+e*e+a*a}function m(a){var b=a[0],d=a[1];a=a[2];return b*b+d*d+a*a}function k(a,d){var b=d[0],e=d[1],f=d[2];b=b*b+e*e+f*f;0<b&&(b=1/Math.sqrt(b),a[0]=d[0]*b,a[1]=d[1]*b,a[2]=d[2]*b);return a}function e(a,d){return a[0]*d[0]+a[1]*d[1]+a[2]*d[2]}Object.defineProperty(g,"__esModule",{value:!0});g.create=u;g.clone=function(a){var b=new d.a(3);b[0]=a[0];b[1]=a[1];b[2]=a[2];return b};g.length=n;g.fromValues=q;g.copy=function(a,d){a[0]=d[0];a[1]=d[1];a[2]=d[2];return a};
g.set=function(a,d,e,f){a[0]=d;a[1]=e;a[2]=f;return a};g.add=function(a,d,e){a[0]=d[0]+e[0];a[1]=d[1]+e[1];a[2]=d[2]+e[2];return a};g.subtract=a;g.multiply=f;g.divide=l;g.ceil=function(a,d){a[0]=Math.ceil(d[0]);a[1]=Math.ceil(d[1]);a[2]=Math.ceil(d[2]);return a};g.floor=function(a,d){a[0]=Math.floor(d[0]);a[1]=Math.floor(d[1]);a[2]=Math.floor(d[2]);return a};g.min=function(a,d,e){a[0]=Math.min(d[0],e[0]);a[1]=Math.min(d[1],e[1]);a[2]=Math.min(d[2],e[2]);return a};g.max=function(a,d,e){a[0]=Math.max(d[0],
e[0]);a[1]=Math.max(d[1],e[1]);a[2]=Math.max(d[2],e[2]);return a};g.round=function(a,d){a[0]=Math.round(d[0]);a[1]=Math.round(d[1]);a[2]=Math.round(d[2]);return a};g.scale=function(a,d,e){a[0]=d[0]*e;a[1]=d[1]*e;a[2]=d[2]*e;return a};g.scaleAndAdd=function(a,d,e,f){a[0]=d[0]+e[0]*f;a[1]=d[1]+e[1]*f;a[2]=d[2]+e[2]*f;return a};g.distance=v;g.squaredDistance=t;g.squaredLength=m;g.negate=function(a,d){a[0]=-d[0];a[1]=-d[1];a[2]=-d[2];return a};g.inverse=function(a,d){a[0]=1/d[0];a[1]=1/d[1];a[2]=1/d[2];
return a};g.normalize=k;g.dot=e;g.cross=function(a,d,e){var b=d[0],f=d[1];d=d[2];var c=e[0],h=e[1];e=e[2];a[0]=f*e-d*h;a[1]=d*c-b*e;a[2]=b*h-f*c;return a};g.lerp=function(a,d,e,f){var b=d[0],c=d[1];d=d[2];a[0]=b+f*(e[0]-b);a[1]=c+f*(e[1]-c);a[2]=d+f*(e[2]-d);return a};g.hermite=function(a,d,e,f,c,k){var b=k*k,h=b*(2*k-3)+1,g=b*(k-2)+k,r=b*(k-1);k=b*(3-2*k);a[0]=d[0]*h+e[0]*g+f[0]*r+c[0]*k;a[1]=d[1]*h+e[1]*g+f[1]*r+c[1]*k;a[2]=d[2]*h+e[2]*g+f[2]*r+c[2]*k;return a};g.bezier=function(a,d,e,f,c,k){var b=
1-k,h=b*b,g=k*k,r=h*b;h*=3*k;b*=3*g;k*=g;a[0]=d[0]*r+e[0]*h+f[0]*b+c[0]*k;a[1]=d[1]*r+e[1]*h+f[1]*b+c[1]*k;a[2]=d[2]*r+e[2]*h+f[2]*b+c[2]*k;return a};g.random=function(a,e){e=e||1;var b=2*d.c()*Math.PI,f=2*d.c()-1,c=Math.sqrt(1-f*f)*e;a[0]=Math.cos(b)*c;a[1]=Math.sin(b)*c;a[2]=f*e;return a};g.transformMat4=function(a,d,e){var b=d[0],f=d[1];d=d[2];var c=e[3]*b+e[7]*f+e[11]*d+e[15];c=c||1;a[0]=(e[0]*b+e[4]*f+e[8]*d+e[12])/c;a[1]=(e[1]*b+e[5]*f+e[9]*d+e[13])/c;a[2]=(e[2]*b+e[6]*f+e[10]*d+e[14])/c;return a};
g.transformMat3=function(a,d,e){var b=d[0],f=d[1];d=d[2];a[0]=b*e[0]+f*e[3]+d*e[6];a[1]=b*e[1]+f*e[4]+d*e[7];a[2]=b*e[2]+f*e[5]+d*e[8];return a};g.transformQuat=function(a,d,e){var b=d[0],f=d[1],c=d[2];d=e[0];var h=e[1],k=e[2];e=e[3];var g=e*b+h*c-k*f,r=e*f+k*b-d*c,l=e*c+d*f-h*b;b=-d*b-h*f-k*c;a[0]=g*e+b*-d+r*-k-l*-h;a[1]=r*e+b*-h+l*-d-g*-k;a[2]=l*e+b*-k+g*-h-r*-d;return a};g.rotateX=function(a,d,e,f){var b=[],c=[];b[0]=d[0]-e[0];b[1]=d[1]-e[1];b[2]=d[2]-e[2];c[0]=b[0];c[1]=b[1]*Math.cos(f)-b[2]*
Math.sin(f);c[2]=b[1]*Math.sin(f)+b[2]*Math.cos(f);a[0]=c[0]+e[0];a[1]=c[1]+e[1];a[2]=c[2]+e[2];return a};g.rotateY=function(a,d,e,f){var b=[],c=[];b[0]=d[0]-e[0];b[1]=d[1]-e[1];b[2]=d[2]-e[2];c[0]=b[2]*Math.sin(f)+b[0]*Math.cos(f);c[1]=b[1];c[2]=b[2]*Math.cos(f)-b[0]*Math.sin(f);a[0]=c[0]+e[0];a[1]=c[1]+e[1];a[2]=c[2]+e[2];return a};g.rotateZ=function(a,d,e,f){var b=[],c=[];b[0]=d[0]-e[0];b[1]=d[1]-e[1];b[2]=d[2]-e[2];c[0]=b[0]*Math.cos(f)-b[1]*Math.sin(f);c[1]=b[0]*Math.sin(f)+b[1]*Math.cos(f);
c[2]=b[2];a[0]=c[0]+e[0];a[1]=c[1]+e[1];a[2]=c[2]+e[2];return a};g.angle=function(a,d){a=q(a[0],a[1],a[2]);d=q(d[0],d[1],d[2]);k(a,a);k(d,d);d=e(a,d);return 1<d?0:-1>d?Math.PI:Math.acos(d)};g.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"};g.exactEquals=function(a,d){return a[0]===d[0]&&a[1]===d[1]&&a[2]===d[2]};g.equals=function(a,e){var b=a[0],f=a[1];a=a[2];var c=e[0],h=e[1];e=e[2];return Math.abs(b-c)<=d.b*Math.max(1,Math.abs(b),Math.abs(c))&&Math.abs(f-h)<=d.b*Math.max(1,Math.abs(f),
Math.abs(h))&&Math.abs(a-e)<=d.b*Math.max(1,Math.abs(a),Math.abs(e))};var d=c(30);g.sub=a;g.mul=f;g.div=l;g.dist=v;g.sqrDist=t;g.len=n;g.sqrLen=m;p=function(){var a=u();return function(b,d,e,f,c,k){d||(d=3);e||(e=0);for(f=f?Math.min(f*d+e,b.length):b.length;e<f;e+=d)a[0]=b[e],a[1]=b[e+1],a[2]=b[e+2],c(a,a,k),b[e]=a[0],b[e+1]=a[1],b[e+2]=a[2];return b}}();g.forEach=p},function(p,g,c){function u(){var a=new e.a(4);a[0]=0;a[1]=0;a[2]=0;a[3]=0;return a}function n(a,b,e){a[0]=b[0]-e[0];a[1]=b[1]-e[1];
a[2]=b[2]-e[2];a[3]=b[3]-e[3];return a}function q(a,b,e){a[0]=b[0]*e[0];a[1]=b[1]*e[1];a[2]=b[2]*e[2];a[3]=b[3]*e[3];return a}function a(a,b,e){a[0]=b[0]/e[0];a[1]=b[1]/e[1];a[2]=b[2]/e[2];a[3]=b[3]/e[3];return a}function f(a,b,e){a[0]=b[0]*e;a[1]=b[1]*e;a[2]=b[2]*e;a[3]=b[3]*e;return a}function l(a,b){var d=b[0]-a[0],e=b[1]-a[1],f=b[2]-a[2];a=b[3]-a[3];return Math.sqrt(d*d+e*e+f*f+a*a)}function v(a,b){var d=b[0]-a[0],e=b[1]-a[1],f=b[2]-a[2];a=b[3]-a[3];return d*d+e*e+f*f+a*a}function t(a){var b=
a[0],d=a[1],e=a[2];a=a[3];return Math.sqrt(b*b+d*d+e*e+a*a)}function m(a){var b=a[0],d=a[1],e=a[2];a=a[3];return b*b+d*d+e*e+a*a}function k(a,b){var d=b[0],e=b[1],f=b[2];b=b[3];var c=d*d+e*e+f*f+b*b;0<c&&(c=1/Math.sqrt(c),a[0]=d*c,a[1]=e*c,a[2]=f*c,a[3]=b*c);return a}Object.defineProperty(g,"__esModule",{value:!0});g.create=u;g.clone=function(a){var b=new e.a(4);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b};g.fromValues=function(a,b,f,c){var d=new e.a(4);d[0]=a;d[1]=b;d[2]=f;d[3]=c;return d};
g.copy=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];return a};g.set=function(a,b,e,f,c){a[0]=b;a[1]=e;a[2]=f;a[3]=c;return a};g.add=function(a,b,e){a[0]=b[0]+e[0];a[1]=b[1]+e[1];a[2]=b[2]+e[2];a[3]=b[3]+e[3];return a};g.subtract=n;g.multiply=q;g.divide=a;g.ceil=function(a,b){a[0]=Math.ceil(b[0]);a[1]=Math.ceil(b[1]);a[2]=Math.ceil(b[2]);a[3]=Math.ceil(b[3]);return a};g.floor=function(a,b){a[0]=Math.floor(b[0]);a[1]=Math.floor(b[1]);a[2]=Math.floor(b[2]);a[3]=Math.floor(b[3]);return a};g.min=
function(a,b,e){a[0]=Math.min(b[0],e[0]);a[1]=Math.min(b[1],e[1]);a[2]=Math.min(b[2],e[2]);a[3]=Math.min(b[3],e[3]);return a};g.max=function(a,b,e){a[0]=Math.max(b[0],e[0]);a[1]=Math.max(b[1],e[1]);a[2]=Math.max(b[2],e[2]);a[3]=Math.max(b[3],e[3]);return a};g.round=function(a,b){a[0]=Math.round(b[0]);a[1]=Math.round(b[1]);a[2]=Math.round(b[2]);a[3]=Math.round(b[3]);return a};g.scale=f;g.scaleAndAdd=function(a,b,e,f){a[0]=b[0]+e[0]*f;a[1]=b[1]+e[1]*f;a[2]=b[2]+e[2]*f;a[3]=b[3]+e[3]*f;return a};g.distance=
l;g.squaredDistance=v;g.length=t;g.squaredLength=m;g.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];a[3]=-b[3];return a};g.inverse=function(a,b){a[0]=1/b[0];a[1]=1/b[1];a[2]=1/b[2];a[3]=1/b[3];return a};g.normalize=k;g.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};g.lerp=function(a,b,e,f){var d=b[0],c=b[1],h=b[2];b=b[3];a[0]=d+f*(e[0]-d);a[1]=c+f*(e[1]-c);a[2]=h+f*(e[2]-h);a[3]=b+f*(e[3]-b);return a};g.random=function(a,b){b=b||1;a[0]=e.c();a[1]=e.c();a[2]=e.c();a[3]=e.c();
k(a,a);f(a,a,b);return a};g.transformMat4=function(a,b,e){var d=b[0],f=b[1],c=b[2];b=b[3];a[0]=e[0]*d+e[4]*f+e[8]*c+e[12]*b;a[1]=e[1]*d+e[5]*f+e[9]*c+e[13]*b;a[2]=e[2]*d+e[6]*f+e[10]*c+e[14]*b;a[3]=e[3]*d+e[7]*f+e[11]*c+e[15]*b;return a};g.transformQuat=function(a,b,e){var d=b[0],f=b[1],c=b[2],h=e[0],k=e[1],g=e[2];e=e[3];var l=e*d+k*c-g*f,m=e*f+g*d-h*c,t=e*c+h*f-k*d;d=-h*d-k*f-g*c;a[0]=l*e+d*-h+m*-g-t*-k;a[1]=m*e+d*-k+t*-h-l*-g;a[2]=t*e+d*-g+l*-k-m*-h;a[3]=b[3];return a};g.str=function(a){return"vec4("+
a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};g.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]};g.equals=function(a,b){var d=a[0],f=a[1],c=a[2];a=a[3];var k=b[0],g=b[1],l=b[2];b=b[3];return Math.abs(d-k)<=e.b*Math.max(1,Math.abs(d),Math.abs(k))&&Math.abs(f-g)<=e.b*Math.max(1,Math.abs(f),Math.abs(g))&&Math.abs(c-l)<=e.b*Math.max(1,Math.abs(c),Math.abs(l))&&Math.abs(a-b)<=e.b*Math.max(1,Math.abs(a),Math.abs(b))};var e=c(30);g.sub=n;g.mul=q;g.div=a;g.dist=l;g.sqrDist=v;
g.len=t;g.sqrLen=m;p=function(){var a=u();return function(b,d,e,f,c,k){d||(d=4);e||(e=0);for(f=f?Math.min(f*d+e,b.length):b.length;e<f;e+=d)a[0]=b[e],a[1]=b[e+1],a[2]=b[e+2],a[3]=b[e+3],c(a,a,k),b[e]=a[0],b[e+1]=a[1],b[e+2]=a[2],b[e+3]=a[3];return b}}();g.forEach=p},function(p,g,c){g.a=function(c){c=Math.ceil((void 0===c?128:c)/32);var g=new Uint32Array(c);crypto.getRandomValues(g);for(var q="",a=0;a<c;++a)q+=("00000000"+g[a].toString(16)).slice(-8);return q}},function(p,g,c){g=c(184);c="object"==
typeof self&&self&&self.Object===Object&&self;g=g||c||Function("return this")();p.exports=g},function(p,g,c){g=c(107).Symbol;p.exports=g},function(p,g,c){var u=c(6),n=c(73);p.exports=function(c,a,f){var g=!0,v=!0;if("function"!=typeof c)throw new TypeError("Expected a function");n(f)&&(g="leading"in f?!!f.leading:g,v="trailing"in f?!!f.trailing:v);return u(c,a,{leading:g,maxWait:a,trailing:v})}},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+
typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return a});g.c=function(a,c){if(void 0!==c){"string"===typeof c&&(c={type:c});Object(n.u)(c);var g=Object(n.w)(c,"type",n.B);g=f.get(g);if(void 0===g)throw Error("Invalid tool type: "+JSON.stringify(c)+".");return g(a,c)}};g.b=function(a,c){f.set(a,c)};p=c(0);var n=c(2),q=function(){function a(a,
f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),a=function(a){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var a=(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==
typeof a&&"function"!==typeof a?this:a}u(f,a);q(f,[{key:"setActive",value:function(a){}},{key:"deactivate",value:function(){}}]);return f}(p.a),f=new Map},function(p,g,c){function u(a,f){if(!(a instanceof f))throw new TypeError("Cannot call a class as a function");}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});
f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}g.c=function(a,f,e){e=void 0===e?!1:e;f=f.attribute("aIndexRaw");0<=f&&(e&&a.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(f,0),a.disableVertexAttribArray(f))};g.d=function(a){return a.memoize.get("IndexBuffer",function(){return new v(a)})};g.b=function(a){a.addAttribute("highp vec3","aIndexRaw");a.addVertexCode(f.m);a.addVertexCode("\nuint32_t getPrimitiveIndex() {\n  uint32_t result;\n  result.value = vec4(aIndexRaw, 0.0);\n  return result;\n}\n")};
c.d(g,"a",function(){return t});g.e=function(f,c){return q.a.fromData(f,new Uint8Array(c.buffer,c.byteOffset,c.byteLength),a.a,a.v)};p=c(0);var q=c(15),a=c(11),f=c(16),l=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(f,e,d){e&&a(f.prototype,e);d&&a(f,d);return f}}(),v=function(f){function c(a){u(this,c);var d=(c.__proto__||Object.getPrototypeOf(c)).call(this);
if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");d=!d||"object"!==typeof d&&"function"!==typeof d?this:d;d.gl=a;d.buffer=d.registerDisposer(new q.a(a));return d}n(c,f);l(c,[{key:"resize",value:function(a){var d;if(256>a){var b=d=new Uint8Array(a);for(var e=0;e<a;++e)b[e]=e;b=1}else if(65536>a){b=d=new Uint8Array(2*a);e=0;for(var f=2*a,c=0;c<f;c+=2)b[c]=e,b[c+1]=e>>8,++e;b=2}else if(16777216>a){b=d=new Uint8Array(3*a);e=3*a;for(c=f=0;c<e;c+=3)b[c]=f,b[c+
1]=f>>8,b[c+2]=f>>16,++f;b=3}else throw Error("Length of index buffer must not exceed 2^24.");this.buffer.setData(d);this.numComponents=b;this.length=a}},{key:"ensure",value:function(a){(void 0===this.length||this.length<a)&&this.resize(a);return this}},{key:"bindToVertexAttrib",value:function(e){this.buffer.bindToVertexAttrib(e,this.numComponents,a.G,!0)}},{key:"bind",value:function(a,d){d=void 0===d?0:d;a=a.attribute("aIndexRaw");0<=a&&(this.bindToVertexAttrib(a),0!==d&&this.gl.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(a,
d))}}]);return c}(p.a),t=function(){function f(a){u(this,f);this.name=a;this.attributeName="a"+this.name;this.getterName="get"+this.name}l(f,[{key:"defineShader",value:function(a){a.addAttribute("highp vec4",this.attributeName);a.addVertexCode("\nfloat "+this.getterName+" () {\n  vec4 temp = "+this.attributeName+";\n  return temp.x + temp.y * 256.0 + temp.z * 65536.0;\n}\n")}},{key:"bind",value:function(f,e){f.bindToVertexAttrib(e.attribute(this.attributeName),4,a.G,!1)}},{key:"disable",value:function(a){a.gl.disableVertexAttribArray(a.attribute(this.attributeName))}}]);
return f}()},function(p,g,c){function u(a){a.setFragmentMain("gl_FragColor = getValue0();")}g.a=u;g.b=function(a,f,c){f=void 0===f?u:f;c=void 0===c?1:c;return a.memoize.get("elementWiseTextureShader:"+c+":"+Object(n.a)(f),function(){var g=new q.a(a);g.addVarying("vec2","vTexCoord");g.addUniform("sampler2D","uSampler",c);g.addInitializer(function(f){for(var k=[],e=0;e<c;++e)k[e]=e;a.uniform1iv(f.uniform("uSampler"),k)});for(var l=0;l<c;++l)g.addFragmentCode("\nvec4 getValue"+l+"() {\n  return texture2D(uSampler["+
l+"], vTexCoord);\n}\n");g.addUniform("mat4","uProjectionMatrix");g.require(f);g.addAttribute("vec4","aVertexPosition");g.addAttribute("vec2","aTexCoord");g.setVertexMain("vTexCoord = aTexCoord; gl_Position = uProjectionMatrix * aVertexPosition;");return g.build()})};g.c=function(a){return a.memoize.get("trivialColorShader",function(){var f=new q.a(a);f.addVarying("vec4","vColor");f.setFragmentMain("gl_FragColor = vColor;");f.addAttribute("vec4","aVertexPosition");f.addAttribute("vec4","aColor");
f.addUniform("mat4","uProjectionMatrix");f.setVertexMain("vColor = aColor; gl_Position = uProjectionMatrix * aVertexPosition;");return f.build()})};var n=c(24),q=c(27)},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function q(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+
typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function a(a){for(var b=0,d=0;3>d;++d)0>a[d]&&(b+=1<<d);return b}c.d(g,"a",function(){return d});p=c(0);var f=c(1),l=c(15),v=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,
d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),t=f.s.create(),m=f.s.create(),k=new Float32Array([0,0,0,1,0,0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,1,1,1,1]);g.b=k;var e=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.outputVertexIndices=d.registerDisposer(l.a.fromData(a,new Float32Array([0,1,2,3,4,5]),a.ARRAY_BUFFER,a.STATIC_DRAW));a=[0,1,2,4,5,3,6,7];for(var e=[0,1,2,5,3,4,6,7],f=[0,1,1,4,4,7,4,7,1,5,0,1,1,4,4,7,0,2,2,5,5,7,5,7,2,6,0,2,2,5,5,7,0,3,3,
6,6,7,6,7,3,4,0,3,3,6,6,7],c=[0,1,2,3,4,5,6,7,1,4,5,0,3,7,2,6,2,6,0,5,7,3,1,4,3,0,6,4,1,2,7,5,4,3,7,1,0,6,5,2,5,2,1,7,6,0,4,3,6,7,3,2,5,4,0,1,7,5,4,6,2,1,3,0],h=[],k=0;8>k;++k)for(var g=0;g<f.length;++g)h.push(a[c[8*e[k]+f[g]]]);d.vertexIndices=new Int32Array(h);return d}q(b,a);v(b,null,[{key:"get",value:function(a){return a.memoize.get("SliceViewShaderBuffers",function(){return new b(a)})}}]);return b}(p.a),d=function(b){function d(a){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));
b.data=b.registerDisposer(e.get(a));return b}q(d,b);v(d,null,[{key:"get",value:function(a){return a.memoize.get("BoundingBoxCrossSectionRenderHelper",function(){return new d(a)})}}]);v(d,[{key:"defineShader",value:function(a){a.addUniform("highp vec3","uPlaneNormal");a.addUniform("highp float","uPlaneDistance");a.addUniform("highp ivec2","uVertexIndex",24);a.addUniform("highp vec3","uVertexBasePosition",8);a.addInitializer(function(a){a.gl.uniform3fv(a.uniform("uVertexBasePosition"),k)});a.addVertexCode("\nvec3 getBoundingBoxPlaneIntersectionVertexPosition(vec3 chunkSize, vec3 boxLower, vec3 lowerClipBound, vec3 upperClipBound, int vertexIndex) {\n  for (int e = 0; e < 4; ++e) {\n    highp ivec2 vidx = uVertexIndex[vertexIndex*4 + e];\n    highp vec3 v1 = max(lowerClipBound, min(upperClipBound, chunkSize * uVertexBasePosition[vidx.x] + boxLower));\n    highp vec3 v2 = max(lowerClipBound, min(upperClipBound, chunkSize * uVertexBasePosition[vidx.y] + boxLower));\n    highp vec3 vDir = v2 - v1;\n    highp float denom = dot(vDir, uPlaneNormal);\n    if (abs(denom) > 0.001) {\n      highp float lambda = (uPlaneDistance - dot(v1, uPlaneNormal)) / denom;\n      if ((lambda >= -0.001) && (lambda <= (1.0 + 0.001))) {\n        lambda = clamp(lambda, 0.0, 1.0);\n        highp vec3 position = v1 + lambda * vDir;\n        return position;\n      }\n    }\n  }\n  return vec3(0, 0, 0);\n}\n")}},
{key:"computeVertexPositionDebug",value:function(b,d,e,c,h,g,l){var r=a(h);r=this.data.vertexIndices.subarray(48*r,48*(r+1));for(var m=[0,0],t=[f.s.create(),f.s.create()],v=f.s.create(),n=f.s.create(),q=function(a){return k.subarray(3*a,3*a+3)},x=0;4>x;++x){for(var u=0;2>u;++u)m[u]=r[2*(4*l+x)+u],f.s.multiply(t[u],b,q(m[u])),f.s.add(t[u],t[u],g),f.s.min(t[u],t[u],e),f.s.max(t[u],t[u],d);f.s.subtract(v,t[1],t[0]);u=f.s.dot(v,h);if(.001<Math.abs(u)){var p=(c-f.s.dot(t[0],h))/u;if(-.001<=p&&1.001>=p)return p=
Math.max(0,Math.min(1,p)),f.s.scaleAndAdd(n,t[0],v,p),n;console.log("vertex "+l+", e = "+x+", skipped, deom = "+u+", "+("vDir = "+Object(f.t)(v)+", ")+("uPlaneNormal = "+Object(f.t)(h)+", ")+("lambda="+p))}else console.log("vertex "+l+", e = "+x+", skipped, deom = "+u+", "+("vDir = "+Object(f.t)(v)+", uPlaneNormal = "+Object(f.t)(h)))}}},{key:"setPlane",value:function(b,d,e){var f=b.gl;f.uniform3fv(b.uniform("uPlaneNormal"),d);f.uniform1f(b.uniform("uPlaneDistance"),e);d=a(d);f.uniform2iv(b.uniform("uVertexIndex"),
this.data.vertexIndices.subarray(48*d,48*(d+1)))}},{key:"setViewportPlane",value:function(a,b,d,e){b=Object(f.p)(t,b,e);d=f.s.dot(f.s.transformMat4(m,d,e),b);this.setPlane(a,b,d)}}]);return d}(p.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
f):a.__proto__=f)}c.d(g,"a",function(){return f});p=c(0);var n=c(77),q=c(51),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}();g.b=n.b;var f=function(f){function c(a,f){f=void 0===f?1:f;if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var k=(c.__proto__||Object.getPrototypeOf(c)).call(this);
if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");k=!k||"object"!==typeof k&&"function"!==typeof k?this:k;k.linesPerInstance=f;k.lineOffsetsBuffer=Object(q.a)(a,0,-1,1,1,f,1);k.quadHelper=k.registerDisposer(new n.a(a,f));return k}u(c,f);a(c,[{key:"defineShader",value:function(a){a.addAttribute("highp vec2","aLineOffset");a.addUniform("highp vec3","uLineParams");a.addVarying("highp float","vLineCoord");a.addVertexCode("\nvoid emitLine(mat4 projection, vec3 vertexA, vec3 vertexB) {\n  vec3 vertexPosition = mix(vertexA, vertexB, aLineOffset.x);\n  vec3 otherVertexPosition = mix(vertexB, vertexA, aLineOffset.x);\n\n  vec4 vertexPositionClip = projection * vec4(vertexPosition, 1.0);\n  vec4 otherVertexPositionClip = projection * vec4(otherVertexPosition, 1.0);\n\n  vec3 vertexPositionDevice = vertexPositionClip.xyz / vertexPositionClip.w;\n  vec3 otherVertexPositionDevice = otherVertexPositionClip.xyz / otherVertexPositionClip.w;\n\n  vec2 lineDirection = normalize(otherVertexPositionDevice.xy - vertexPositionDevice.xy);\n  vec2 lineNormal = vec2(lineDirection.y, -lineDirection.x);\n\n  gl_Position = vertexPositionClip;\n  gl_Position.xy += aLineOffset.y * (2.0 * aLineOffset.x - 1.0) * lineNormal * uLineParams.xy * 0.5 * gl_Position.w;\n  vLineCoord = aLineOffset.y;\n}\n");
a.addFragmentCode("\nfloat getLineAlpha() {\n  return clamp((1.0 - abs(vLineCoord)) / uLineParams.z, 0.0, 1.0);\n}\n")}},{key:"draw",value:function(a,f,c,e,d){var b=a.attribute("aLineOffset");this.lineOffsetsBuffer.bindToVertexAttrib(b,2);c+=e;var h=a.gl;h.uniform3f(a.uniform("uLineParams"),2*c/f.viewportWidth,2*c/f.viewportHeight,e/c);this.quadHelper.draw(h,d);h.disableVertexAttribArray(b)}}]);return c}(p.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+
typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return f});p=c(0);var n=c(15),q=c(112),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),f=function(f){function c(a){if(!(this instanceof
c))throw new TypeError("Cannot call a class as a function");var f=(c.__proto__||Object.getPrototypeOf(c)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");f=!f||"object"!==typeof f&&"function"!==typeof f?this:f;f.gl=a;f.vertexBuffer=f.registerDisposer(n.a.fromData(a,new Float32Array([0,0,0,1,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,1]),a.ARRAY_BUFFER,a.STATIC_DRAW));f.colorBuffer=f.registerDisposer(n.a.fromData(a,new Float32Array([1,0,0,.5,1,0,
0,.5,0,1,0,.5,0,1,0,.5,0,0,1,.5,0,0,1,.5]),a.ARRAY_BUFFER,a.STATIC_DRAW));f.trivialColorShader=f.registerDisposer(Object(q.c)(a));return f}u(c,f);a(c,[{key:"draw",value:function(a,f){f=void 0===f?!0:f;var c=this.trivialColorShader,e=this.gl;c.bind();e.uniformMatrix4fv(c.uniform("uProjectionMatrix"),!1,a);a=c.attribute("aVertexPosition");this.vertexBuffer.bindToVertexAttrib(a,4);c=c.attribute("aColor");this.colorBuffer.bindToVertexAttrib(c,4);f&&(e.colorMask(!1,!1,!1,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),
e.colorMask(!0,!0,!0,!0),e.enable(e.BLEND),e.blendFunc(e.ONE_MINUS_DST_ALPHA,e.DST_ALPHA));e.lineWidth(1);e.drawArrays(e.LINES,0,6);f&&e.disable(e.BLEND);e.disableVertexAttribArray(a);e.disableVertexAttribArray(c)}}],[{key:"get",value:function(a){return a.memoize.get("SliceViewPanel:AxesLineHelper",function(){return new c(a)})}}]);return c}(p.a)},function(p,g,c){c.d(g,"a",function(){return n});var u=function(){function c(a,f){for(var c=0;c<f.length;c++){var g=f[c];g.enumerable=g.enumerable||!1;g.configurable=
!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(a,f,g){f&&c(a.prototype,f);g&&c(a,g);return a}}(),n=function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.renderLayers=[null];this.pickData=[null];this.values=[0,0,0];this.nextPickID=1}u(c,[{key:"clear",value:function(){this.renderLayers.length=1;this.pickData.length=1;this.values.length=3;this.nextPickID=1}},{key:"registerUint64",value:function(a,f,c){return this.register(a,
void 0===c?1:c,f.low,f.high)}},{key:"register",value:function(a,f,c,g,t){var l=this.renderLayers,k=this.values,e=this.nextPickID;this.nextPickID+=void 0===f?1:f;f=l.length;l[f]=a;a=3*f;k[a]=e;k[a+1]=void 0===c?0:c;k[a+2]=void 0===g?0:g;this.pickData[f]=void 0===t?null:t;return e}},{key:"setMouseState",value:function(a,f){for(var c=this.renderLayers,g=this.values,t=0,m=c.length-1;t<m;){var k=Math.ceil(t+(m-t)/2);g[3*k]>f?m=k-1:t=k}c=a.pickedRenderLayer=c[t];m=3*t;f=a.pickedOffset=f-g[m];k=a.pickedValue;
k.low=g[m+1];k.high=g[m+2];a.pickedAnnotationId=void 0;a.pickedAnnotationLayer=void 0;null!==c&&c.updateMouseState(a,k,f,this.pickData[t])}}]);return c}()},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&
b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return b});var q=c(80);p=c(118);var a=c(66),f=c(19),l=c(1),v=c(53),t=c(119),m=c(206),k=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),e=function r(a,
b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return r(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}};c(207);c(40);var d=l.s.create(),b=function(b){function c(b,e,k){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var g=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b,e,k.visibility));g.viewer=k;g.mouseX=0;g.mouseY=0;g.mouseStateUpdater=
g.updateMouseState.bind(g);g.inputEventMap=k.inputEventMap;e.classList.add("neuroglancer-rendered-data-panel");e.classList.add("neuroglancer-panel");e.classList.add("neuroglancer-noselect");g.registerDisposer(new a.a(e));g.registerDisposer(new v.b(e,g.inputEventMap));g.registerDisposer(new t.a(e,g.inputEventMap));g.registerEventListener(e,"mousemove",g.onMousemove.bind(g));g.registerEventListener(e,"mouseleave",g.onMouseout.bind(g));Object(f.c)(e,"snap",function(){g.navigationState.pose.snap()});
Object(f.c)(e,"zoom-in",function(){g.navigationState.zoomBy(.5)});Object(f.c)(e,"zoom-out",function(){g.navigationState.zoomBy(2)});Object(f.c)(e,"highlight",function(){g.viewer.layerManager.invokeAction("highlight")});for(b={axis:0};3>b.axis;b={axis:b.axis},++b.axis){k=l.a[b.axis];for(var r={},n=$jscomp.makeIterator([-1,1]),x=n.next();!x.done;r={sign:r.sign,tempOffset:r.tempOffset},x=n.next())r.sign=x.value,x=0>r.sign?"-":"+",Object(f.c)(e,"rotate-relative-"+k+x,function(a,b){return function(){g.navigationState.pose.rotateRelative(l.e[a.axis],
.1*b.sign)}}(b,r)),r.tempOffset=l.s.create(),Object(f.c)(e,""+k+x,function(a,b){return function(){var d=g.navigationState,e=a.tempOffset;e[0]=0;e[1]=0;e[2]=0;e[b.axis]=a.sign;d.pose.translateVoxelsRelative(e)}}(r,b))}Object(f.c)(e,"zoom-via-wheel",function(a){a=a.detail;g.onMousemove(a);g.zoomByMouse(Object(m.a)(a))});b={};k=$jscomp.makeIterator([1,10]);for(r=k.next();!r.done;b={amount:b.amount},r=k.next())b.amount=r.value,Object(f.c)(e,"z+"+b.amount+"-via-wheel",function(a){return function(b){var e=
b.detail;b=g.navigationState;e=0!==e.deltaY?e.deltaY:e.deltaX;d[0]=0;d[1]=0;d[2]=(0<e?-1:1)*a.amount;b.pose.translateVoxelsRelative(d)}}(b));Object(f.c)(e,"move-to-mouse-position",function(){var a=g.viewer.mouseState;if(a.updateUnconditionally()){var b=g.navigationState.pose.position;l.s.copy(b.spatialCoordinates,a.position);b.changed.dispatch()}});Object(f.c)(e,"snap",function(){return g.navigationState.pose.snap()});Object(f.c)(e,"select-annotation",function(){var a=g.viewer;a=Object(q.a)(a.mouseState,
a.layerManager);if(void 0!==a){var b=a.layer.layer;null!==b&&(g.viewer.selectedLayer.layer=a.layer,g.viewer.selectedLayer.visible=!0,b.tabs.value="annotations",b.selectedAnnotation.value={id:a.id,partIndex:a.partIndex})}});return g}n(c,b);k(c,[{key:"onMouseout",value:function(a){a=this.viewer.mouseState;a.updater=void 0;a.setActive(!1)}},{key:"onMousemove",value:function(a){var b=this.element;a.target===b&&(this.mouseX=a.offsetX-b.clientLeft,this.mouseY=a.offsetY-b.clientTop,b=this.viewer.mouseState,
b.pageX=a.pageX,b.pageY=a.pageY,b.updater=this.mouseStateUpdater,b.triggerUpdate())}},{key:"disposed",value:function(){var a=this.viewer.mouseState;a.updater===this.mouseStateUpdater&&(a.updater=void 0,a.setActive(!1));e(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}}]);return c}(p.b)},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a,d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function q(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}c.d(g,"b",function(){return m});c.d(g,"a",function(){return k});p=c(6);var a=c.n(p);p=c(0);var f=c(3),l=c(203),v=function(){function a(a,
b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),t=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;return void 0===f?void 0:f.call(c)}},m=function(a){function b(a,d,f){u(this,
b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.context=a;c.element=d;c.visibility=f;c.gl=a.gl;a.addPanel(c);return c}q(b,a);v(b,[{key:"scheduleRedraw",value:function(){this.context.scheduleRedraw()}},{key:"setGLViewport",value:function(){var a=this.element,b=a.getBoundingClientRect(),d=this.context.canvasRect,f=a.clientLeft+b.left-d.left,c=a.clientWidth,k=a.clientHeight;b=b.top-d.top+a.clientTop+k;a=this.gl;a.enable(a.SCISSOR_TEST);b=this.context.canvas.height-b;a.viewport(f,
b,c,k);a.scissor(f,b,c,k)}},{key:"disposed",value:function(){this.context.removePanel(this);t(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"visible",get:function(){return this.visibility.visible}}]);return b}(p.a),k=function(d){function b(d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.container=d;c.canvas=document.createElement("canvas");c.updateStarted=new f.a;c.updateFinished=new f.a;c.panels=new Set;c.updatePending=
null;c.onResize=c.registerCancellable(a()(function(){c.scheduleRedraw();for(var a=$jscomp.makeIterator(c.panels),b=a.next();!b.done;b=a.next())b.value.onResize()},0));var h=c.canvas;d.style.position="relative";h.style.position="absolute";h.style.top="0px";h.style.left="0px";h.style.width="100%";h.style.height="100%";h.style.zIndex="0";d.appendChild(h);c.gl=Object(l.a)(h);c.registerEventListener(window,"resize",c.onResize.bind(c));return c}q(b,d);v(b,[{key:"isReady",value:function(){for(var a=$jscomp.makeIterator(this.panels),
b=a.next();!b.done;b=a.next())if(b=b.value,b.visible&&!b.isReady())return!1;return!0}},{key:"makeCanvasOverlayElement",value:function(){var a=document.createElement("div");a.style.position="absolute";a.style.top="0px";a.style.left="0px";a.style.width="100%";a.style.height="100%";a.style.zIndex="2";this.container.appendChild(a);return a}},{key:"disposed",value:function(){null!=this.updatePending&&(cancelAnimationFrame(this.updatePending),this.updatePending=null)}},{key:"addPanel",value:function(a){this.panels.add(a)}},
{key:"removePanel",value:function(a){this.panels.delete(a);a.dispose()}},{key:"scheduleRedraw",value:function(){null===this.updatePending&&(this.updatePending=requestAnimationFrame(this.update.bind(this)))}},{key:"draw",value:function(){this.updateStarted.dispatch();var a=this.gl,b=this.canvas;b.width=b.offsetWidth;b.height=b.offsetHeight;this.canvasRect=b.getBoundingClientRect();this.gl.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT);b=$jscomp.makeIterator(this.panels);for(var d=
b.next();!d.done;d=b.next()){d=d.value;var f=d.element;d.visible&&0!==f.clientWidth&&0!==f.clientHeight&&0!==f.offsetWidth&&0!==f.offsetHeight&&(d.setGLViewport(),d.draw())}a.disable(a.SCISSOR_TEST);this.gl.clearColor(1,1,1,1);this.gl.colorMask(!1,!1,!1,!0);a.clear(a.COLOR_BUFFER_BIT);this.gl.colorMask(!0,!0,!0,!0);this.updateFinished.dispatch()}},{key:"update",value:function(){this.updatePending=null;this.draw()}}]);return b}(p.a)},function(p,g,c){function u(a,f){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!f||"object"!==typeof f&&"function"!==typeof f?a:f}function n(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return f});p=c(0);var q=c(19),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=
k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),f=function(f){function c(a,f){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var k=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));k.target=a;k.eventMap=f;k.registerEventListener(a,"wheel",function(a){k.dispatch("wheel",a)});k.registerEventListener(a,"click",function(a){k.dispatch("click"+a.button,
a)});k.registerEventListener(a,"dblclick",function(a){k.dispatch("dblclick"+a.button,a)});k.registerEventListener(a,"mousedown",function(a){k.dispatch("mousedown"+a.button,a)});k.registerEventListener(a,"mouseup",function(a){k.dispatch("mouseup"+a.button,a)});return k}n(c,f);a(c,[{key:"dispatch",value:function(a,f){Object(q.b)(a,f,this.eventMap)}}]);return c}(p.a)},function(p,g,c){g.a=function(c,g){var n=c.view.document,a=c.screenX,f=c.screenY,l=function(c){var k=a-c.screenX,e=f-c.screenY;a=c.screenX;
f=c.screenY;g(c,k,e)},v=c.button,t=function(a){a.button===v&&(n.removeEventListener("mousemove",l,!0),n.removeEventListener("mouseup",t,!1))};n.addEventListener("mousemove",l,!0);n.addEventListener("mouseup",t,!1)}},function(p,g,c){g.b=function(c,a,f,g){g=void 0===g?u.e:g;var l=void 0;return new Promise(function(t,m){function k(d){null!==l&&(l=Object(n.c)(c.serverUrls,f.path,f.method),l.responseType=f.responseType,l.setRequestHeader("Authorization",d.credentials.tokenType+" "+d.credentials.accessToken),
l.onloadend=function(){if(null!==l){var b=this.status;200<=b&&300>b?(g.remove(e),t(this.response)):401===b?a.get(d,g).then(k):504===b||503===b?a.get(void 0,g).then(k):(g.remove(e),m(n.a.fromXhr(this)))}},l.send(f.payload))}var e=function(){var a=l;l=null;null!=a&&a.abort();m(u.a)};g.add(e);a.get(void 0,g).then(k)})};var u=c(34),n=c(46);g.a="google-brainmaps"},function(p,g,c){g.b=function(c,g){return c.low+","+c.high+(g?"_"+g.center.toString()+"_"+g.size.toString():"")};g.a=function(c,g){var n=c.segmentEquivalences;
c=$jscomp.makeIterator(c.visibleSegments);for(var a=c.next();!a.done;a=c.next())if(a=a.value,n.disjointSets.isMinElement(a))for(var f=$jscomp.makeIterator(n.setElements(a)),l=f.next();!l.done;l=f.next())g(l.value,a)}},function(p,g,c){g.a=function(c,g,q,a){g*=6;var f=Math.floor(g),l=g-f;g=a*(1-q);var n=a*(1-q*l);q=a*(1-q*(1-l));switch(f%6){case 0:c[0]=a;c[1]=q;c[2]=g;break;case 1:c[0]=n;c[1]=a;c[2]=g;break;case 2:c[0]=g;c[1]=a;c[2]=q;break;case 3:c[0]=g;c[1]=n;c[2]=a;break;case 4:c[0]=q;c[1]=g;c[2]=
a;break;case 5:c[0]=a,c[1]=g,c[2]=n}return c};g.b=function(c,g,q,a){var f=Math.max(Math.max(g,q),a),l=Math.min(Math.min(g,q),a);c[2]=f;l===f?(c[0]=0,c[1]=0):(l=f-l,c[1]=l/f,c[0]=g===f?(q-a)/l:q===f?2+(a-g)/l:4+(g-q)/l,c[0]/=6,0>c[0]&&(c[0]+=1),1<c[0]&&--c[0]);return c}},function(p,g,c){c.d(g,"c",function(){return u});g.a="/ocp/ca";g.b="/nd/sd";var u=function q(){if(!(this instanceof q))throw new TypeError("Cannot call a class as a function");};u.RPC_ID="ndstore/VolumeChunkSource"},function(p,g,c){function u(a,
b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function a(a,d,e){Object(y.u)(a);var f=Object(y.w)(a,"Base",function(a){return new H(a)});switch(f.typeName){case "uint8blk":case "grayscale8":return new F(a,d,f,b.c.JPEG,e);case "imagetile":return new N(a,d,f);case "labels64":case "labelblk":return new F(a,d,f,b.c.COMPRESSED_SEGMENTATION,e);default:throw Error("DVID data type "+JSON.stringify(f.typeName)+" is not supported.");}}function f(a){try{for(var b=Object(y.v)(a,function(a){return new U(a)}),
d=new Map,e=$jscomp.makeIterator(b),f=e.next();!f.done;f=e.next()){var c=$jscomp.makeIterator(f.value),h=c.next().value,k=c.next().value;d.set(h,k);for(var g=$jscomp.makeIterator(k.vnodes),l=g.next();!l.done;l=g.next()){var r=l.value;if(r!==h){var m=new U(k);d.set(r,m)}}}for(var t=$jscomp.makeIterator(d),n=t.next();!n.done;n=t.next()){var v=$jscomp.makeIterator(n.value),q=v.next().value;v.next().value.uuid=q}return d}catch(xa){throw Error("Failed to parse DVID repositories info: "+xa.message);}}function l(a,
b){return a.memoize.getUncounted({type:"dvid:getServerInfo",baseUrls:b},function(){var a=Object(D.e)(Object(D.c)(b,"/api/repos/info","GET"),"json").then(function(a){return new O(a)}),d="repository info for DVID server "+b[0];x.a.forPromise(a,{initialMessage:"Retrieving "+d+".",delay:!0,errorPrefix:"Error retrieving "+d+": "});return a})}function v(a,b,d,e){return a.memoize.getUncounted({type:"dvid:getInstanceDetails",baseUrls:b,nodeKey:d,name:e.name},function(){var a=Object(D.e)(Object(D.c)(b,"/api/node/"+
d+"/"+e.name+"/info","GET"),"json"),f="datainstance info for node "+d+" and instance "+e.name+" "+("on DVID server "+b[0]);x.a.forPromise(a,{initialMessage:"Retrieving "+f+".",delay:!0,errorPrefix:"Error retrieving "+f+": "});return a.then(function(a){a=Object(y.w)(a,"Extended",y.u);e.lowerVoxelBound=Object(y.w)(a,"MinPoint",function(a){return Object(y.d)(A.s.create(),a)});e.upperVoxelBound=Object(y.w)(a,"MaxPoint",function(a){return Object(y.d)(A.s.create(),a)});return e})})}function t(a,b,d,e){return l(a,
b).then(function(f){f=f.getNode(d);if(void 0===f)throw Error("Invalid node: "+JSON.stringify(d)+".");f=f.dataInstances.get(e);if(!(f instanceof F||f instanceof N))throw Error("Invalid data instance "+e+".");return v(a,b,d,f)}).then(function(f){return a.memoize.getUncounted({type:"dvid:MultiscaleVolumeChunkSource",baseUrls:b,nodeKey:d,dataInstanceKey:e},function(){return new T(a,b,d,e,f)})})}function m(a,b){var d=b.match(W);if(null===d)throw Error("Invalid DVID URL: "+JSON.stringify(b)+".");return t(a,
[d[1]],d[2],d[3])}function k(a,b){return{offset:0,completions:Object(z.c)(b,a.dataInstances.values(),function(a){return a.name},function(a){return""+a.base.typeName})}}function e(a,b){var d=b.match(/^(?:([^\/]+)(?:\/([^\/]*))?)?$/);if(null===d)throw Error("Invalid DVID URL syntax.");if(void 0===d[2])return{offset:0,completions:Object(z.c)(b,a.repositories.values(),function(a){return a.uuid+"/"},function(a){return a.alias+": "+a.description})};b=d[1];a=a.getNode(b);return Object(z.a)(b.length+1,k(a,
d[2]))}function d(a,b){a=a.match(/^((?:http|https):\/\/[^\/]+)\/(.*)$/);if(null===a)return Promise.reject(null);var d=a[1],f=a[2];return l(b,[d]).then(function(a){return Object(z.a)(d.length+1,e(a,f))})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"getVolume",function(){return m});c.d(g,"volumeCompleter",function(){return d});c.d(g,"DataInstanceBaseInfo",function(){return H});c.d(g,"DataInstanceInfo",function(){return B});c.d(g,"VolumeDataInstanceInfo",function(){return F});c.d(g,"TileLevelInfo",
function(){return M});c.d(g,"TileDataInstanceInfo",function(){return N});g.parseDataInstance=a;c.d(g,"RepositoryInfo",function(){return U});g.parseRepositoriesInfo=f;c.d(g,"ServerInfo",function(){return O});g.getServerInfo=l;g.getDataInstanceDetails=v;c.d(g,"MultiscaleVolumeChunkSource",function(){return T});g.getShardedVolume=t;g.completeInstanceName=k;g.completeNodeAndInstance=e;c.d(g,"DVIDDataSource",function(){return aa});p=c(17);g=c(37);var b=c(217),h=c(18),r=c(28),x=c(25),z=c(54),A=c(1),D=c(46),
y=c(2),E=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),G=new Map;G.set("uint8",h.a.UINT8);G.set("uint32",h.a.UINT32);G.set("uint64",h.a.UINT64);var H=function(){function a(b){q(this,a);this.obj=b;Object(y.u)(b);Object(y.w)(b,"TypeName",y.B)}E(a,[{key:"typeName",get:function(){return this.obj.TypeName}}]);
return a}(),B=function S(a,b,d){q(this,S);this.obj=a;this.name=b;this.base=d},C=function(a){function b(){q(this,b);return u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}n(b,a);return b}(Object(p.f)(r.b,b.d)),F=function(a){function d(a,b,e,f,c){q(this,d);e=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,a,b,e));e.encoding=f;a=Object(y.w)(a,"Extended",y.u);f=Object(y.w)(a,"Values",function(a){return Object(y.a)(a,y.u)});if(1>f.length)throw Error("Expected Extended.Values property to have length >= 1, but received: ${JSON.stringify(extendedValues)}.");
e.numLevels=1;for(c=new Set(c);c.has(b+"_"+e.numLevels.toString());)e.numLevels+=1;e.dataType=Object(y.w)(f[0],"DataType",function(a){return Object(y.t)(a,G)});e.voxelSize=Object(y.w)(a,"VoxelSize",function(a){return Object(y.c)(A.s.create(),a,y.p)});e.numChannels=1;return e}n(d,a);E(d,[{key:"getSources",value:function(a,d,e){for(var f=this.encoding,c=[],k={},g=0;g<this.numLevels;k={volParameters:k.volParameters},++g){for(var l=A.s.scale(A.s.create(),this.voxelSize,Math.pow(2,g)),r=A.s.create(),m=
A.s.create(),t=0;3>t;++t)r[t]=Math.floor(this.voxelSize[t]/l[t]*this.lowerVoxelBound[t]),m[t]=Math.ceil(this.voxelSize[t]/l[t]*this.upperVoxelBound[t]);t=d.dataInstanceKey;0<g&&(t+="_"+g.toString());k.volParameters={baseUrls:d.baseUrls,nodeKey:d.nodeKey,dataInstanceKey:t,encoding:f};l=h.b.getDefaults({voxelSize:l,dataType:this.dataType,numChannels:this.numChannels,transform:A.k.fromTranslation(A.k.create(),A.s.multiply(A.s.create(),r,l)),baseVoxelOffset:r,upperVoxelBound:A.s.subtract(A.s.create(),
m,r),volumeType:this.volumeType,volumeSourceOptions:e,compressedSegmentationBlockSize:f===b.c.COMPRESSED_SEGMENTATION?A.s.fromValues(8,8,8):void 0}).map(function(b){return function(d){return a.getChunkSource(C,{spec:d,parameters:b.volParameters})}}(k));c.push(l)}return c}},{key:"volumeType",get:function(){return this.encoding===b.c.COMPRESSED_SEGMENTATION?h.c.SEGMENTATION:h.c.IMAGE}}]);return d}(B),M=function ha(a){q(this,ha);Object(y.u)(a);this.resolution=Object(y.w)(a,"Resolution",function(a){return Object(y.c)(A.s.create(),
a,y.p)});this.tileSize=Object(y.w)(a,"TileSize",function(a){return Object(y.c)(A.s.create(),a,y.A)})},I=[[0,1],[0,2],[1,2]],P=function(a){function b(){q(this,b);return u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}n(b,a);return b}(Object(p.f)(r.b,b.a)),N=function(a){function d(a,e,f){q(this,d);e=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,a,e,f));a=Object(y.w)(a,"Extended",y.u);e.levels=Object(y.w)(a,"Levels",function(a){return Object(y.v)(a,function(a){return new M(a)})});
f=e.levels.get("0");if(void 0===f)throw Error("Level 0 is not defined.");e.voxelSize=f.resolution;var c=Object(y.w)(a,"MinTileCoord",function(a){return Object(y.c)(A.s.create(),a,y.s)}),h=Object(y.w)(a,"MaxTileCoord",function(a){return Object(y.c)(A.s.create(),a,y.s)});e.lowerVoxelBound=A.s.multiply(A.s.create(),f.tileSize,c);e.upperVoxelBound=A.s.multiply(A.s.create(),f.tileSize,h);a=Object(y.w)(a,"Encoding",function(a){return a});switch(a){case 2:e.encoding=b.b.JPEG;break;default:throw Error("Unsupported tile encoding: "+
JSON.stringify(a)+".");}return e}n(d,a);E(d,[{key:"dataType",get:function(){return h.a.UINT8}},{key:"volumeType",get:function(){return h.c.IMAGE}},{key:"numChannels",get:function(){return 1}}]);E(d,[{key:"getSources",value:function(a,b,d){for(var e=this,f=[],c=this.numChannels,k=this.dataType,g=this.encoding,l={},r=$jscomp.makeIterator(this.levels),m=r.next();!m.done;l={levelInfo:l.levelInfo,level:l.level},m=r.next())m=$jscomp.makeIterator(m.value),l.level=m.next().value,l.levelInfo=m.next().value,
m=I.map(function(f){return function(l){for(var r=A.s.clone(e.voxelSize),m=A.s.fromValues(1,1,1),t=0;2>t;++t)r[l[t]]=f.levelInfo.resolution[l[t]],m[l[t]]=f.levelInfo.tileSize[l[t]];t=A.s.create();for(var n=A.s.create(),v=0;3>v;++v)t[v]=Math.floor(e.voxelSize[v]/r[v]*e.lowerVoxelBound[v]),n[v]=Math.ceil(e.voxelSize[v]/r[v]*e.upperVoxelBound[v]);r=h.b.make({voxelSize:r,chunkDataSize:m,numChannels:c,dataType:k,lowerVoxelBound:t,upperVoxelBound:n,volumeSourceOptions:d});return a.getChunkSource(P,{spec:r,
parameters:{baseUrls:b.baseUrls,nodeKey:b.nodeKey,dataInstanceKey:b.dataInstanceKey,encoding:g,level:f.level,dims:l[0]+"_"+l[1]}})}}(l)),f.push(m);return f}}]);return d}(B),U=function L(b){q(this,L);this.errors=[];this.dataInstances=new Map;this.vnodes=new Set;if(b instanceof L)this.alias=b.alias,this.description=b.description,this.errors=b.errors,this.dataInstances=b.dataInstances;else{Object(y.u)(b);this.alias=Object(y.w)(b,"Alias",y.B);this.description=Object(y.w)(b,"Description",y.B);for(var d=
Object(y.w)(b,"DataInstances",y.u),e=Object.keys(d),f=$jscomp.makeIterator(e),c=f.next();!c.done;c=f.next()){c=c.value;try{this.dataInstances.set(c,a(d[c],c,e))}catch(na){c="Failed to parse data instance "+JSON.stringify(c)+": "+na.message,console.log(c),this.errors.push(c)}}b=Object(y.w)(b,"DAG",y.u);b=Object(y.w)(b,"Nodes",y.u);b=$jscomp.makeIterator(Object.keys(b));for(c=b.next();!c.done;c=b.next())this.vnodes.add(c.value)}},O=function(){function a(b){q(this,a);this.repositories=f(b)}E(a,[{key:"getNode",
value:function(a){for(var b=[],d=$jscomp.makeIterator(this.repositories.keys()),e=d.next();!e.done;e=d.next())e=e.value,e.startsWith(a)&&b.push(e);if(1!==b.length)throw Error("Node key "+JSON.stringify(a)+" matches "+JSON.stringify(b)+" nodes.");return this.repositories.get(b[0])}}]);return a}(),T=function(){function a(b,d,e,f,c){q(this,a);this.chunkManager=b;this.baseUrls=d;this.nodeKey=e;this.dataInstanceKey=f;this.info=c}E(a,[{key:"getSources",value:function(a){return this.info.getSources(this.chunkManager,
{baseUrls:this.baseUrls,nodeKey:this.nodeKey,dataInstanceKey:this.dataInstanceKey},a)}},{key:"getMeshSource",value:function(){return null}},{key:"dataType",get:function(){return this.info.dataType}},{key:"numChannels",get:function(){return this.info.numChannels}},{key:"volumeType",get:function(){return this.info.volumeType}}]);return a}(),W=/^((?:http|https):\/\/[^\/]+)\/([^\/]+)\/([^\/]+)$/,aa=function(a){function b(){q(this,b);return u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}
n(b,a);E(b,[{key:"getVolume",value:function(a,b){return m(a,b)}},{key:"volumeCompleter",value:function(a,b){return d(a,b)}},{key:"description",get:function(){return"DVID"}}]);return b}(g.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&
null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){var b=Object(F.a)(a,F.u);if(1>b.length)throw Error("No stacks found for owner object.");a=new Map;var d=Object(F.w)(b[0],"stackId",l);b=$jscomp.makeIterator(b);for(var e=b.next();!e.done;e=b.next()){var c=e.value;
e=Object(F.w)(c,"stackId",f);Object(F.u)(c);var h=Object(F.w)(c,"state",F.B);if(U.has(h)){h=Object(F.w)(c,"stats",F.u);var k=h;Object(F.u)(k);k=Object(F.w)(k,"stackBounds",F.u);var g=B.s.create();g[0]=Object(F.w)(k,"minX",F.q);g[1]=Object(F.w)(k,"minY",F.q);g[2]=Object(F.w)(k,"minZ",F.q);k=g;g=h;Object(F.u)(g);g=Object(F.w)(g,"stackBounds",F.u);var r=B.s.create();r[0]=Object(F.w)(g,"maxX",F.q);r[1]=Object(F.w)(g,"maxY",F.q);r[2]=Object(F.w)(g,"maxZ",F.q);g=r;r=[];h.hasOwnProperty("channelNames")&&
(r=v(h));h=Object(F.w)(c,"currentVersion",t);c=Object(F.w)(c,"stackId",m);c={lowerVoxelBound:k,upperVoxelBound:g,voxelResolution:h,project:c,channels:r}}else c=void 0;void 0!==c&&(h=c.project,k=a.get(h),void 0===k&&(k=new Map,a.set(h,{stacks:k}),k=a.get(h)),k.stacks.set(e,c))}return{owner:d,projects:a}}function f(a){Object(F.u)(a);return Object(F.w)(a,"stack",F.B)}function l(a){Object(F.u)(a);return Object(F.w)(a,"owner",F.B)}function v(a){Object(F.u)(a);return Object(F.w)(a,"channelNames",function(a){return Object(F.a)(a,
F.B)})}function t(a){Object(F.u)(a);var b=B.s.create();try{b[0]=Object(F.w)(a,"stackResolutionX",F.q),b[1]=Object(F.w)(a,"stackResolutionY",F.q),b[2]=Object(F.w)(a,"stackResolutionZ",F.q)}catch(L){b[0]=1,b[1]=1,b[2]=1}return b}function m(a){Object(F.u)(a);return Object(F.w)(a,"project",F.B)}function k(a,b){for(var d=0,e=0;2>e;e++)d<a.upperVoxelBound[e]&&(d=a.upperVoxelBound[e]);if(b>=d)return 1;for(a=0;d>b;)d/=2,a++;return a}function e(b,d,e){return b.memoize.getUncounted({type:"render:getOwnerInfo",
hostnames:d,owner:e},function(){return Object(C.e)(Object(C.c)(d,"/render-ws/v1/owner/"+e+"/stacks"),"json").then(a)})}function d(a,b,d){var f=d.match(T);if(null===f)throw Error("Invalid volume path "+JSON.stringify(d));var c=f[1],h=f[2],k=f[3],g=f[4],l=Object(F.e)(f[5]||"");return a.memoize.getUncounted({type:"render:MultiscaleVolumeChunkSource",hostnames:b,path:d},function(){return e(a,b,c).then(function(d){return new O(a,b,d,k,h,g,l)})})}function b(a,b){var e=b.match(W);if(null===e)throw Error("Invalid render volume path: "+
JSON.stringify(b));b=e[1].split(",");return d(a,b,e[2])}function h(a,b,d){var f=d.match(/^(?:([^\/]+)(?:\/([^\/]*))?(?:\/([^\/]*))?(\/.*?)?)?$/);if(null===f||void 0===f[2])return Promise.reject(null);if(void 0===f[3]){var c=f[2]||"";return e(a,b,f[1]).then(function(a){a=Object(H.c)(c,a.projects,function(a){return a[0]+"/"},function(){});return{offset:f[1].length+1,completions:a}})}if(void 0===f[4]){var h=f[3]||"";return e(a,b,f[1]).then(function(a){a=a.projects.get(f[2]);if(void 0===a)return Promise.reject(null);
a=Object(H.c)(h,a.stacks,function(a){return a[0]+"/"},function(a){return"("+a[1].project+")"});return{offset:f[1].length+f[2].length+2,completions:a}})}var k=f[4].substr(1)||"";return e(a,b,f[1]).then(function(a){a=a.projects.get(f[2]);if(void 0===a)return Promise.reject(null);a=a.stacks.get(f[3]);if(void 0===a)return Promise.reject(null);a=a.channels;if(0===a.length)return Promise.reject(null);a=Object(H.c)(k,a,function(a){return a},function(){});return{offset:f[1].length+f[2].length+f[3].length+
3,completions:a}})}function r(a,b){var d=a.match(W);if(null===d)return Promise.reject(null);a=d[1].split(",");return h(b,a,d[2]).then(function(a){return Object(H.a)(d[1].length+1,a)})}function x(a,b){var d=b.match(W);if(null===d)throw Error("Invalid render point path: "+JSON.stringify(b));return z(a,[d[1]],d[2])}function z(a,b,d){var f=d.match(T);if(null===f)throw Error("Invalid point path "+JSON.stringify(d));var c=f[1],h=f[2],k=f[3],g=Object(F.e)(f[4]||"");return a.memoize.getUncounted({type:"render:MultiscaleVectorGraphicsChunkSource",
hostnames:b,path:d},function(){return e(a,b,c).then(function(d){return new aa(a,b,d,k,h,g)})})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"getVolume",function(){return b});c.d(g,"volumeCompleter",function(){return r});c.d(g,"MultiscaleVolumeChunkSource",function(){return O});g.computeStackHierarchy=k;g.getOwnerInfo=e;g.getShardedVolume=d;g.stackAndProjectCompleter=h;c.d(g,"MultiscaleVectorGraphicsChunkSource",function(){return aa});g.getPointMatches=x;g.getShardedPointMatches=z;c.d(g,
"RenderDataSource",function(){return J});p=c(17);g=c(37);var A=c(219),D=c(127),y=c(128),E=c(18),G=c(28),H=c(54),B=c(1),C=c(46),F=c(2),M=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),I=new Set(["jpg"]),P=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}
q(b,a);return b}(Object(p.f)(G.b,A.b)),N=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(p.f)(y.b,A.a)),U=new Set(["COMPLETE"]),O=function(){function a(b,d,e,f,c,h,k){u(this,a);this.chunkManager=b;this.baseUrls=d;this.ownerInfo=e;this.project=c;this.parameters=k;b=e.projects.get(c);if(void 0===b)throw Error("Specified project "+JSON.stringify(c)+" does not exist for "+("specified owner "+JSON.stringify(e.owner)));
if(void 0===f){f=Array.from(b.stacks.keys());if(1!==f.length)throw Error("Dataset contains multiple stacks: "+JSON.stringify(f));f=f[0]}e=b.stacks.get(f);if(void 0===e)throw Error("Specified stack "+JSON.stringify(f)+" is not one of the supported stacks: "+JSON.stringify(Array.from(b.stacks.keys())));this.stack=f;this.stackInfo=e;void 0!==h&&0<h.length&&(this.channel=h);this.minIntensity=Object(F.y)(k.minIntensity);this.maxIntensity=Object(F.y)(k.maxIntensity);this.maxTileSpecsToRender=Object(F.y)(k.maxTileSpecsToRender);
this.filter=Object(F.x)(k.filter);h=Object(F.z)(k.encoding);if(void 0===h)h="jpg";else if(!I.has(h))throw Error("Invalid encoding: "+JSON.stringify(h)+".");this.encoding=h;this.numLevels=Object(F.y)(k.numlevels);this.dims=B.s.create();k=Object(F.y)(k.tilesize);void 0===k&&(k=1024);this.dims[0]=k;this.dims[1]=k;this.dims[2]=1}M(a,[{key:"getSources",value:function(a){var b=[],d=this.numLevels;void 0===d&&(d=k(this.stackInfo,this.dims[0]));for(var e=B.s.create(),f=B.s.create(),c=0;3>c;c++)e[c]=this.stackInfo.lowerVoxelBound[c]*
this.stackInfo.voxelResolution[c],f[c]=this.stackInfo.upperVoxelBound[c]*this.stackInfo.voxelResolution[c];for(c=0;c<d;c++){for(var h=B.s.clone(this.stackInfo.voxelResolution),g=B.s.fromValues(1,1,1),l=0;2>l;++l)h[l]*=Math.pow(2,c),g[l]=this.dims[l];l=B.s.create();for(var r=B.s.create(),m=0;3>m;m++)l[m]=Math.floor(this.stackInfo.voxelResolution[m]/h[m]*this.stackInfo.lowerVoxelBound[m]),r[m]=Math.ceil(this.stackInfo.voxelResolution[m]/h[m]*this.stackInfo.upperVoxelBound[m]);h=E.b.make({voxelSize:h,
chunkDataSize:g,numChannels:this.numChannels,dataType:this.dataType,lowerClipBound:e,upperClipBound:f,lowerVoxelBound:l,upperVoxelBound:r,volumeSourceOptions:a});h=this.chunkManager.getChunkSource(P,{spec:h,parameters:{baseUrls:this.baseUrls,owner:this.ownerInfo.owner,project:this.stackInfo.project,stack:this.stack,channel:this.channel,minIntensity:this.minIntensity,maxIntensity:this.maxIntensity,maxTileSpecsToRender:this.maxTileSpecsToRender,filter:this.filter,dims:this.dims[0]+"_"+this.dims[1],
level:c,encoding:this.encoding}});b.push([h])}return b}},{key:"getMeshSource",value:function(){return null}},{key:"dataType",get:function(){return E.a.UINT8}},{key:"numChannels",get:function(){return 3}},{key:"volumeType",get:function(){return E.c.IMAGE}}]);return a}(),T=/^([^\/?]+)(?:\/([^\/?]+))?(?:\/([^\/?]+))(?:\/([^\/?]*))?(?:\?(.*))?$/,W=/^((?:(?:(?:http|https):\/\/[^,\/]+)[^\/?])+)\/(.*)$/,aa=function(){function a(b,d,e,f,c,h){u(this,a);this.chunkManager=b;this.baseUrls=d;this.ownerInfo=e;
this.project=c;this.parameters=h;b=e.projects.get(c);if(void 0===b)throw Error("Specified project "+JSON.stringify(c)+" does not exist for "+("specified owner "+JSON.stringify(e.owner)));if(void 0===f){f=Array.from(b.stacks.keys());if(1!==f.length)throw Error("Dataset contains multiple stacks: "+JSON.stringify(f));f=f[0]}e=b.stacks.get(f);if(void 0===e)throw Error("Specified stack "+JSON.stringify(f)+" is not one of the supported stacks: "+JSON.stringify(Array.from(b.stacks.keys())));this.stack=f;
this.stackInfo=e;e=Object(F.z)(h.matchCollection);void 0===e&&(e=f);this.matchCollection=e;f=Object(F.y)(h.zoffset);void 0===f&&(f=1);this.zoffset=f;this.dims=B.s.create();h=Object(F.y)(h.tilesize);void 0===h&&(h=1024);this.dims[0]=h;this.dims[1]=h;this.dims[2]=1}M(a,[{key:"getSources",value:function(a){var b=this.stackInfo.voxelResolution,d=B.s.subtract(B.s.create(),this.stackInfo.upperVoxelBound,this.stackInfo.lowerVoxelBound);B.s.multiply(d,d,b);d[2]=b[2];a=D.a.make({voxelSize:b,chunkSize:d,lowerChunkBound:B.s.fromValues(0,
0,this.stackInfo.lowerVoxelBound[2]),upperChunkBound:B.s.fromValues(1,1,this.stackInfo.upperVoxelBound[2]),vectorGraphicsSourceOptions:a});return[[this.chunkManager.getChunkSource(N,{spec:a,parameters:{baseUrls:this.baseUrls,owner:this.ownerInfo.owner,project:this.stackInfo.project,stack:this.stack,encoding:"points",matchCollection:this.matchCollection,zoffset:this.zoffset}})]]}}]);return a}(),J=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}
q(d,a);M(d,[{key:"getVolume",value:function(a,d){return b(a,d)}},{key:"volumeCompleter",value:function(a,b){return r(a,b)}},{key:"getVectorGraphicsSource",value:function(a,b){return x(a,b)}},{key:"description",get:function(){return"Render"}}]);return d}(g.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,
configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"b",function(){return f});c.d(g,"a",function(){return l});var n=c(31),q=function(){function a(a,f){for(var c=0;c<f.length;c++){var e=f[c];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(f,c,k){c&&a(f.prototype,c);k&&a(f,k);return f}}(),a=function t(a,f,e){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,
f);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,f,e)}else{if("value"in d)return d.value;f=d.get;return void 0===f?void 0:f.call(e)}},f;(function(a){a[a.LINE=0]="LINE";a[a.POINT=1]="POINT"})(f||(f={}));var l=function(f){function c(a){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");a=(c.__proto__||Object.getPrototypeOf(c)).call(this,a);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==
typeof a&&"function"!==typeof a?this:a}u(c,f);q(c,[{key:"toObject",value:function(){return a(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"toObject",this).call(this)}}],[{key:"make",value:function(a){return new c(Object.assign({},a,{transform:Object(n.m)(a.transform,a.vectorGraphicsSourceOptions)}))}},{key:"fromObject",value:function(a){return new c(a)}}]);return c}(n.k)},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a,
d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function q(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}c.d(g,"a",function(){return t});c.d(g,
"b",function(){return k});p=c(45);g=c(64);var a=c(15),f=c(47),l=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;return void 0===f?void 0:f.call(c)}},v=function(){function a(a,d){for(var b=0;b<d.length;b++){var f=d[b];f.enumerable=f.enumerable||!1;f.configurable=!0;"value"in f&&(f.writable=!0);Object.defineProperty(a,f.key,f)}}return function(b,
d,f){d&&a(b.prototype,d);f&&a(b,f);return b}}(),t=function(a){function b(a,d){d=void 0===d?{}:d;d=void 0===d.sourceOptions?{}:d.sourceOptions;u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a.chunkManager,a.getSources(d)));c.shader=void 0;c.rpcId=null;c.shaderGetter=c.registerDisposer(new f.a(c.gl,function(a){return c.defineShader(a)},function(){return c.getShaderKey()}));return c}q(b,a);v(b,[{key:"defineShader",value:function(a){a.addFragmentCode("\nvoid emit(vec4 color) {\n  gl_FragColor = color;\n}\nvoid emitRGBA(vec4 rgba) {\n  emit(vec4(rgba.rgb, rgba.a * uOpacity));\n}\nvoid emitRGB(vec3 rgb) {\n  emit(vec4(rgb, uOpacity));\n}\nvoid emitGrayscale(float value) {\n  emit(vec4(value, value, value, uOpacity));\n}\nvoid emitTransparent() {\n  emit(vec4(0.0, 0.0, 0.0, 0.0));\n}\n")}},
{key:"beginSlice",value:function(a){a=this.shaderGetter.get();if(void 0!==a)return a.bind(),a}}]);return b}(g.a),m=function(d){function b(a,d){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));a.vertexPositions=d.vertexPositions;a.numPoints=Math.floor(a.vertexPositions.length/3);return a}q(b,d);v(b,[{key:"copyToGPU",value:function(d){l(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"copyToGPU",this).call(this,d);this.vertexBuffer=a.a.fromData(d,this.vertexPositions,
d.ARRAY_BUFFER,d.STATIC_DRAW)}},{key:"freeGPUMemory",value:function(a){l(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"freeGPUMemory",this).call(this,a);this.vertexBuffer.dispose()}}]);return b}(p.b),k=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);v(b,[{key:"getChunk",value:function(a){return new m(this,a)}},{key:"vectorGraphicsCoordinatesInVoxels",get:function(){return!0}}]);return b}(p.c)},function(p,g,c){function u(a,
c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"OpenConnectomeDataSource",function(){return a});var n=c(124),q=["http://openconnecto.me","http://www.openconnecto.me"],a=function(a){function f(){if(!(this instanceof
f))throw new TypeError("Cannot call a class as a function");var a=(f.__proto__||Object.getPrototypeOf(f)).call(this,"NDstore server hosted at openconnecto.me",q,n.a);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(f,a);return f}(c(84).SingleServerDataSource)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){return a.getChunkSource(A,{parameters:b})}function f(a,b,d){return a.memoize.getUncounted({type:"precomputed:MultiscaleVolumeChunkSource",
baseUrls:b,path:d},function(){return Object(h.e)(Object(h.c)(b,d+"/info"),"json").then(function(e){return new y(a,b,d,e)})})}function l(b,d){var e=$jscomp.makeIterator(Object(h.d)(d));d=e.next().value;e=e.next().value;return a(b,{baseUrls:d,path:e,lod:0})}function v(a,b){var d=$jscomp.makeIterator(Object(h.d)(b));b=d.next().value;d=d.next().value;return f(a,b,d)}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"getMeshSource",function(){return l});c.d(g,"getVolume",function(){return v});c.d(g,
"MultiscaleVolumeChunkSource",function(){return y});g.getShardedMeshSource=a;g.getShardedVolume=f;c.d(g,"PrecomputedDataSource",function(){return E});var t=c(22);p=c(17);g=c(37);var m=c(222),k=c(55),e=c(18),d=c(28),b=c(1),h=c(46),r=c(2),x=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),z=function(a){function b(){u(this,
b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(p.f)(d.b,m.c)),A=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(p.f)(k.b,m.a)),D=function H(a){u(this,H);Object(r.u)(a);this.resolution=Object(r.w)(a,"resolution",function(a){return Object(r.c)(b.s.create(),a,r.p)});this.voxelOffset=Object(r.w)(a,"voxel_offset",function(a){return Object(r.d)(b.s.create(),a)});
this.size=Object(r.w)(a,"size",function(a){return Object(r.c)(b.s.create(),a,r.A)});this.chunkSizes=Object(r.w)(a,"chunk_sizes",function(a){return Object(r.a)(a,function(a){return Object(r.c)(b.s.create(),a,r.A)})});if(0===this.chunkSizes.length)throw Error("No chunk sizes specified.");(this.encoding=Object(r.w)(a,"encoding",function(a){return Object(r.n)(a,m.b)}))===m.b.COMPRESSED_SEGMENTATION&&(this.compressedSegmentationBlockSize=Object(r.w)(a,"compressed_segmentation_block_size",function(a){return Object(r.c)(b.s.create(),
a,r.A)}));this.key=Object(r.w)(a,"key",r.B)},y=function(){function d(a,b,f,c){u(this,d);this.chunkManager=a;this.baseUrls=b;this.path=f;Object(r.u)(c);this.dataType=Object(r.w)(c,"data_type",function(a){return Object(r.n)(a,e.a)});this.numChannels=Object(r.w)(c,"num_channels",r.A);this.volumeType=Object(r.w)(c,"type",function(a){return Object(r.n)(a,e.c)});this.mesh=Object(r.w)(c,"mesh",r.z);this.scales=Object(r.w)(c,"scales",function(a){return Object(r.a)(a,function(a){return new D(a)})})}x(d,[{key:"getMeshSource",
value:function(){var b=this.mesh;return void 0===b?null:a(this.chunkManager,{baseUrls:this.baseUrls,path:this.path+"/"+b,lod:0})}},{key:"getSources",value:function(a){var d=this;return this.scales.map(function(f){return e.b.getDefaults({voxelSize:f.resolution,dataType:d.dataType,numChannels:d.numChannels,transform:b.k.fromTranslation(b.k.create(),b.s.multiply(b.s.create(),f.resolution,f.voxelOffset)),upperVoxelBound:f.size,volumeType:d.volumeType,chunkDataSizes:f.chunkSizes,baseVoxelOffset:f.voxelOffset,
compressedSegmentationBlockSize:f.compressedSegmentationBlockSize,volumeSourceOptions:a}).map(function(a){return d.chunkManager.getChunkSource(z,{spec:a,parameters:{baseUrls:d.baseUrls,path:d.path+"/"+f.key,encoding:f.encoding}})})})}},{key:"getStaticAnnotations",value:function(){var a=this.scales[0],d=new t.b(b.k.fromScaling(b.k.create(),a.resolution));d.readonly=!0;d.add(Object(t.h)(a.voxelOffset,a.size));return d}}]);return d}(),E=function(a){function b(){u(this,b);return n(this,(b.__proto__||
Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);x(b,[{key:"getVolume",value:function(a,b){return v(a,b)}},{key:"getMeshSource",value:function(a,b){return l(a,b)}},{key:"description",get:function(){return"Precomputed file-backed data source"}}]);return b}(g.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==
typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b,d){return a.rpc.promiseInvoke(l.a,{chunkManager:a.addCounterpartRef(),url:b},d)}function f(d,e){return d.memoize.getUncounted({type:"nifti/getVolume",
url:e},function(){return a(d,e,m.e).then(function(a){return new b(d,e,a)})})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"getVolume",function(){return f});c.d(g,"MultiscaleVolumeChunkSource",function(){return b});c.d(g,"NiftiDataSource",function(){return h});p=c(17);g=c(37);var l=c(224),v=c(18),t=c(28),m=c(34),k=c(1),e=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,
e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),d=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(p.f)(t.b,l.b)),b=function(){function a(b,d,e){u(this,a);this.chunkManager=b;this.url=d;this.info=e}e(a,[{key:"getSources",value:function(a){var b=this.info;a=v.b.withDefaultCompression({volumeType:b.volumeType,chunkDataSize:b.volumeSize,dataType:b.dataType,voxelSize:b.voxelSize,numChannels:b.numChannels,
upperVoxelBound:b.volumeSize,transform:Object(k.q)(k.k.create(),b.qoffset,b.quatern,k.g,b.qfac),volumeSourceOptions:a});return[[this.chunkManager.getChunkSource(d,{spec:a,parameters:{url:this.url}})]]}},{key:"getMeshSource",value:function(){return null}},{key:"numChannels",get:function(){return this.info.numChannels}},{key:"dataType",get:function(){return this.info.dataType}},{key:"volumeType",get:function(){return this.info.volumeType}}]);return a}(),h=function(a){function b(){u(this,b);return n(this,
(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);e(b,[{key:"getVolume",value:function(a,b){return f(a,b)}},{key:"description",get:function(){return"Single NIfTI file"}}]);return b}(g.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==
typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){return function(a){function b(a){for(var d=[],e=0;e<arguments.length;++e)d[e-0]=arguments[e];u(this,b);var f;e=n(this,(f=b.__proto__||Object.getPrototypeOf(b)).call.apply(f,[].concat([this],$jscomp.arrayFromIterable(d))));
d=d[1];f=e.dataSource=e.registerDisposer(d.dataSource.addRef());e.generation=d.generation;f.registerSource(d.parameters.key,e);return e}q(b,a);z(b,null,[{key:"encodeOptions",value:function(a){var d=A(b.__proto__||Object.getPrototypeOf(b),"encodeOptions",this).call(this,a);d.dataSource=Object(x.a)(a.dataSource);return d}}]);return b}(a)}function f(a){Object(r.u)(a);return{key:Object(r.w)(a,"key",r.B),offset:Object(r.w)(a,"offset",r.l),sizeInVoxels:Object(r.w)(a,"sizeInVoxels",r.j),voxelSize:Object(r.w)(a,
"voxelSize",r.k),chunkDataSize:Object(r.w)(a,"chunkDataSize",function(a){return void 0===a?void 0:Object(r.j)(a)})}}function l(a){Object(r.u)(a);return{dataType:Object(r.w)(a,"dataType",function(a){return Object(r.n)(a,k.c)}),numComponents:Object(r.w)(a,"numComponents",r.A)}}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"MultiscaleVolumeChunkSource",function(){return E});c.d(g,"PythonSkeletonSource",function(){return G});c.d(g,"PythonDataSource",function(){return H});p=c(17);g=c(37);var v=
c(228),t=c(55),m=c(82),k=c(31),e=c(18),d=c(28),b=c(1),h=c(46),r=c(2),x=c(24),z=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),A=function C(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return C(a,b,d)}else{if("value"in
e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},D=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(a(Object(p.f)(d.b,v.d))),y=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(a(Object(p.f)(t.b,v.a))),E=function(){function a(d,c,h,g){u(this,a);this.dataSource=d;this.chunkManager=c;this.key=h;this.response=g;Object(r.u)(g);this.dataType=
Object(r.w)(g,"dataType",function(a){return Object(r.n)(a,k.c)});this.volumeType=Object(r.w)(g,"volumeType",function(a){return Object(r.n)(a,e.c)});this.numChannels=Object(r.w)(g,"numChannels",r.A);this.encoding=Object(r.w)(g,"encoding",function(a){return Object(r.n)(a,v.c)});this.generation=Object(r.w)(g,"generation",function(a){return a});this.skeletonVertexAttributes=Object(r.w)(g,"skeletonVertexAttributes",function(a){return void 0===a?void 0:Object(r.v)(a,l)});var m=Object(r.w)(g,"maxVoxelsPerChunkLog2",
function(a){return void 0===a?k.b:Object(r.A)(a)});d=Object(r.w)(g,"threeDimensionalScales",function(a){return void 0===a?void 0:Object(r.a)(a,f)});g=Object(r.w)(g,"twoDimensionalScales",function(a){return void 0===a?void 0:Object(r.a)(a,function(a){return Object(r.c)(Array(3),a,f)})});if(void 0===g===(void 0===d))throw Error('Exactly one of "threeDimensionalScales" and "twoDimensionalScales" must be specified.');if(void 0!==g){if(0===g.length)throw Error("At least one scale must be specified.");
this.scales=g.map(function(a){return a.map(function(a,b){var d=a.voxelSize,e=a.sizeInVoxels;b=void 0===a.chunkDataSize?Object(k.p)({voxelSize:d,upperVoxelBound:e,flatDimension:2-b,maxVoxelsPerChunkLog2:m}):a.chunkDataSize;return{key:a.key,offset:a.offset,sizeInVoxels:e,voxelSize:d,chunkDataSize:b}})});if(!b.s.equals(this.scales[0][0].voxelSize,this.scales[0][1].voxelSize)||!b.s.equals(this.scales[0][0].voxelSize,this.scales[0][2].voxelSize))throw Error("Lowest scale must have uniform voxel size.");
}if(void 0!==d){if(0===d.length)throw Error("At least one scale must be specified.");this.scales=d.map(function(a){var b=a.voxelSize,d=a.sizeInVoxels,e=void 0===a.chunkDataSize?Object(k.n)({voxelSize:b,upperVoxelBound:d,maxVoxelsPerChunkLog2:m}):a.chunkDataSize;return[{key:a.key,offset:a.offset,sizeInVoxels:d,voxelSize:b,chunkDataSize:e}]})}}z(a,[{key:"getSources",value:function(a){var d=this,f=this.numChannels,c=this.dataType,h=this.volumeType,k=this.encoding,g=this.scales[0][0],l=b.s.multiply(b.s.create(),
g.voxelSize,g.sizeInVoxels);return this.scales.map(function(g){return g.map(function(g){var r=e.b.withDefaultCompression({voxelSize:g.voxelSize,dataType:c,volumeType:h,numChannels:f,transform:b.k.fromTranslation(b.k.create(),g.offset),upperVoxelBound:g.sizeInVoxels,upperClipBound:l,chunkDataSize:g.chunkDataSize,volumeSourceOptions:a});return d.chunkManager.getChunkSource(D,{spec:r,dataSource:d.dataSource,generation:d.generation,parameters:{key:d.key,scaleKey:g.key,encoding:k}})})})}},{key:"getMeshSource",
value:function(){var a=this.skeletonVertexAttributes;return void 0!==a?this.chunkManager.getChunkSource(G,{dataSource:this.dataSource,generation:this.generation,parameters:{key:this.key,vertexAttributes:a}}):this.chunkManager.getChunkSource(y,{dataSource:this.dataSource,generation:this.generation,parameters:{key:this.key}})}}]);return a}(),G=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);z(b,[{key:"skeletonVertexCoordinatesInVoxels",
get:function(){return!1}},{key:"vertexAttributes",get:function(){return this.parameters.vertexAttributes}}]);return b}(a(Object(p.f)(m.d,v.b))),H=function(a){function b(){u(this,b);var a=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));a.sources=new Map;a.sourceGenerations=new Map;return a}q(b,a);z(b,[{key:"registerSource",value:function(a,b){var d=this,e=this.sources.get(a);void 0===e&&(e=new Set,this.sources.set(a,e));var f=this.sourceGenerations.get(a);void 0!==f&&(b.generation=
f);e.add(b);b.registerDisposer(function(){e.delete(b);0===e.size&&d.sources.delete(a)})}},{key:"setSourceGeneration",value:function(a,b){var d=this.sourceGenerations;if(d.get(a)!==b&&(d.set(a,b),a=this.sources.get(a),void 0!==a))for(a=$jscomp.makeIterator(a),d=a.next();!d.done;d=a.next())d=d.value,d.generation!==b&&(d.generation=b,d.invalidateCache())}},{key:"deleteSourceGeneration",value:function(a){this.sourceGenerations.delete(a)}},{key:"getVolume",value:function(a,b){var d=this;return a.memoize.getUncounted({type:"python:MultiscaleVolumeChunkSource",
key:b},function(){return Object(h.e)(Object(h.b)("/neuroglancer/info/"+b),"json").then(function(e){return new E(d,a,b,e)})})}},{key:"getSkeletonSource",value:function(a,b){var d=b.match(/^([^\/?]+)\?(.*)$/);if(null===d)throw Error("Invalid python volume path: "+JSON.stringify(b));return a.getChunkSource(G,{dataSource:this,generation:-1,parameters:{key:d[1],vertexAttributes:Object(r.v)(JSON.parse(d[2]),l)}})}},{key:"description",get:function(){return"Python-served volume"}}]);return b}(g.a)},function(p,
g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});
b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return h});var a=c(36),f=c(31);p=c(113);g=c(64);var l=c(1),v=c(47),t=c(16),m=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),k=function x(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,
b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return x(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},e=l.k.create(),d=l.s.create(),b=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);m(b,[{key:"defineShader",value:function(a){k(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"defineShader",this).call(this,a);a.addAttribute("highp float","aVertexIndexFloat");a.addUniform("highp vec3",
"uTranslation");a.addUniform("highp mat4","uProjectionMatrix");a.addUniform("highp vec3","uChunkDataSize");a.addUniform("highp vec3","uVoxelSize");a.addUniform("highp vec3","uLowerClipBound");a.addUniform("highp vec3","uUpperClipBound");a.addVarying("highp vec3","vChunkPosition");a.setVertexMain("\nvec3 chunkSize = uChunkDataSize * uVoxelSize;\nvec3 position = getBoundingBoxPlaneIntersectionVertexPosition(chunkSize, uTranslation, uLowerClipBound, uUpperClipBound, int(aVertexIndexFloat));\ngl_Position = uProjectionMatrix * vec4(position, 1.0);\nvChunkPosition = (position - uTranslation) / uVoxelSize +\n    0.001 * abs(uPlaneNormal);\n");
a.addFragmentCode("\nvec3 getPositionWithinChunk () {\n  return floor(min(vChunkPosition, uChunkDataSize - 1.0));\n}\n")}},{key:"computeVerticesDebug",value:function(a,b,d,e,f,c,h,k){a=l.s.multiply(l.s.create(),a,b);for(var g=l.s.create(),m=l.s.create(),t=l.s.fromValues(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),n=0;6>n;++n){var v=this.computeVertexPositionDebug(a,d,e,f,c,h,n);if(void 0===v){console.log("no intersection found");break}l.s.transformMat4(g,v,k);l.s.sub(m,v,h);l.s.divide(m,m,b);l.s.scaleAndAdd(m,
m,t,.001);console.log("vertex "+n+", at "+g+", vChunkPosition = "+m)}}},{key:"beginSlice",value:function(a,b){a=b.attribute("aVertexIndexFloat");this.data.outputVertexIndices.bindToVertexAttrib(a,1)}},{key:"endSlice",value:function(a,b){b=b.attribute("aVertexIndexFloat");a.disableVertexAttribArray(b)}},{key:"beginSource",value:function(a,b,d,f,c,h){this.setViewportPlane(b,d.viewportAxes[2],d.centerDataPosition,h.invTransform);a.uniformMatrix4fv(b.uniform("uProjectionMatrix"),!1,l.k.multiply(e,f,h.transform));
a.uniform3fv(b.uniform("uVoxelSize"),c.voxelSize);a.uniform3fv(b.uniform("uLowerClipBound"),c.lowerClipBound);a.uniform3fv(b.uniform("uUpperClipBound"),c.upperClipBound)}},{key:"setupChunkDataSize",value:function(a,b,d){a.uniform3fv(b.uniform("uChunkDataSize"),d)}},{key:"drawChunk",value:function(a,b,d){a.uniform3fv(b.uniform("uTranslation"),d);a.drawArrays(a.TRIANGLE_FAN,0,6)}}],[{key:"get",value:function(a){return a.memoize.get("volume.VolumeSliceVertexComputationManager",function(){return new b(a)})}}]);
return b}(p.a),h=function(e){function c(a,e){e=void 0===e?{}:e;u(this,c);var h=e,k=void 0===h.sourceOptions?{}:h.sourceOptions;h=h.shaderError;var g=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,a.chunkManager,a.getSources(k),e));a=g.gl;g.shaderGetter=g.registerDisposer(new v.a(a,function(a){return g.defineShader(a)},function(){return g.getShaderKey()+"/"+g.chunkFormat.shaderKey},h));g.vertexComputationManager=b.get(a);e=Object(f.o)(g)[0][0];a=e.chunkLayout;e=e.source.spec;k=g.boundingBox=
new l.b(l.s.fromValues(Infinity,Infinity,Infinity),l.s.fromValues(-Infinity,-Infinity,-Infinity));h=l.s.create();for(var m=0;8>m;++m){for(var t=0;3>t;++t)d[t]=m&1<<t?e.upperClipBound[t]:e.lowerClipBound[t];a.localSpatialToGlobal(h,d);l.s.min(k.lower,k.lower,h);l.s.max(k.upper,k.upper,h)}return g}q(c,e);m(c,[{key:"getValueAt",value:function(a){for(var b=$jscomp.makeIterator(Object(f.o)(this)),d=b.next();!d.done;d=b.next()){d=$jscomp.makeIterator(d.value);for(var e=d.next();!e.done;e=d.next())if(e=
e.value,e=e.source.getValueAt(a,e.chunkLayout),null!=e)return e}return null}},{key:"getShaderKey",value:function(){return this.chunkFormat.shaderKey}},{key:"defineShader",value:function(a){this.vertexComputationManager.defineShader(a);a.addFragmentCode("\nvoid emit(vec4 color) {\n  gl_FragData[0] = color;\n}\n");this.chunkFormat.defineShader(a);a.addFragmentCode("\n"+Object(t.a)(this.dataType)+" getDataValue() { return getDataValue(0); }\n")}},{key:"beginSlice",value:function(a){a=this.gl;var b=this.shaderGetter.get();
if(void 0!==b)return b.bind(),this.vertexComputationManager.beginSlice(a,b),b}},{key:"endSlice",value:function(a){this.vertexComputationManager.endSlice(this.gl,a)}},{key:"draw",value:function(b){var d=b.visibleLayers.get(this);if(0!==d.length){var e=this.gl,f=this.beginSlice(b);if(void 0!==f){var c=l.s.create(),h=this.vertexComputationManager,k=this.chunkFormat;k.beginDrawing(e,f);var g={};d=$jscomp.makeIterator(d);for(var m=d.next();!m.done;g={chunkDataSize:g.chunkDataSize},m=d.next()){m=m.value;
var t=m.chunkLayout,n=m.source;m=n.chunks;var v=t.size;g.chunkDataSize=void 0;var q=b.visibleChunks.get(t);if(q){h.beginSource(e,f,b,b.dataToDevice,n.spec,t);t=n.chunkFormat;t.beginSource(e,f);n=function(a){return function(b){a.chunkDataSize=b;h.setupChunkDataSize(e,f,a.chunkDataSize)}}(g);q=$jscomp.makeIterator(q);for(var p=q.next();!p.done;p=q.next())if((p=m.get(p.value))&&p.state===a.d.GPU_MEMORY){var u=p.chunkDataSize;u!==g.chunkDataSize&&n(u);l.s.multiply(c,v,p.chunkGridPosition);t.bindChunk(e,
f,p);h.drawChunk(e,f,c)}}}k.endDrawing(e,f);this.endSlice(f)}}}},{key:"dataType",get:function(){return this.sources[0][0].spec.dataType}},{key:"chunkFormat",get:function(){return this.sources[0][0].chunkFormat}}]);return c}(g.a)},function(p,g,c){function u(f){if(Object(q.n)(f,a))return Object(q.B)(f);throw Error();}c.d(g,"b",function(){return a});g.c=function(a){return new n.c(void 0===a?"default":a,u)};var n=c(5),q=c(2),a;(function(a){a[a.DEFAULT=0]="DEFAULT";a[a.ADDITIVE=1]="ADDITIVE"})(a||(a={}));
p=new Map;g.a=p;p.set(a.DEFAULT,function(a){a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)});p.set(a.ADDITIVE,function(a){a.blendFunc(a.SRC_ALPHA,a.ONE)})},function(p,g,c){function u(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function n(e){return function(d){function b(){if(!(this instanceof
b))throw new TypeError("Cannot call a class as a function");var a=(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(b,d);m(b,[{key:"restoreState",value:function(d){var e=this;k(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"restoreState",this).call(this,d);d=this.volumePath=Object(t.w)(d,"source",t.z);void 0!==d&&(this.multiscaleSource=
Object(f.d)(this.manager.dataSourceProvider,this.manager.chunkManager,d,this.volumeOptions)).then(function(b){e.wasDisposed||(b=b.getStaticAnnotations&&b.getStaticAnnotations(),void 0!==b&&(e.annotationLayerState.value=new q.b({transform:e.transform,source:b,role:a.f.DEFAULT_ANNOTATION,color:e.annotationColor})))})}},{key:"toJSON",value:function(){var a=k(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"toJSON",this).call(this);a.source=this.volumePath;return a}}]);return b}(e)}g.a=function(a){return n(Object(l.a)(Object(v.a)(a)))};
var q=c(62),a=c(14),f=c(20),l=c(85),v=c(88),t=c(2),m=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}(),k=function d(a,f,c){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,f);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,f,c)}else{if("value"in b)return b.value;f=b.get;
return void 0===f?void 0:f.call(c)}}},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a){if(void 0===a[3]||1===a[3]){for(var c="#",k=0;3>k;++k)c+=Object(f.c)(Math.min(255,Math.max(0,Math.round(255*a[k]))));
return c}c="rgba(";for(k=0;3>k;++k)0!==k&&(c+=", "),c+=Math.min(255,Math.max(0,Math.round(255*a[k])));return c+=", "+Object(q.a)(a[3])+")"}c.d(g,"a",function(){return v});p=c(5);var q=c(137),a=c(1),f=c(138),l=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}(),v=function(f){function c(f){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");
var e=(c.__proto__||Object.getPrototypeOf(c)).call(this,a.s.clone(f));if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.defaultValue=f;return e}u(c,f);l(c,[{key:"toString",value:function(){return n(this.value)}},{key:"toJSON",value:function(){if(!a.s.equals(this.value,this.defaultValue))return n(this.value)}},{key:"reset",value:function(){this.value=a.s.clone(this.defaultValue)}},{key:"restoreState",
value:function(f){if(void 0===f)this.reset();else{var e=this.value;try{if("string"!==typeof f)throw Error("Expected string, but received "+JSON.stringify(f)+".");var d=document.createElement("canvas").getContext("2d");d.fillStyle=f;var b=d.fillStyle,c=b.match(/^rgba\(([0-9]+), ([0-9]+), ([0-9]+), (0(?:\.[0-9]+)?)\)$/);if(null!==c)var k=[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10),parseFloat(c[4])];else{var g=b.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);if(null!==g)k=[parseInt(g[1],
16),parseInt(g[2],16),parseInt(g[3],16),1];else throw Error("Invalid serialized color: "+JSON.stringify(b)+".");}f=k;var l=a.u.fromValues(f[0]/255,f[1]/255,f[2]/255,f[3])}catch(A){throw Error("Failed to parse color specification: "+A.message);}l=l.subarray(0,3);a.s.equals(e,l)||(this.value=l)}}}]);return c}(p.f)},function(p,g,c){g.a=function(c){c=u[0]=c;for(var g=0;9>g;++g){var a=c.toFixed(g);u[0]=parseFloat(a);if(u[0]===c)return a}return c.toString()};var u=new Float32Array(1)},function(p,g,c){function u(c){return("0"+
c.toString(16)).slice(-2)}g.c=u;g.b=function(c){return Array.prototype.map.call(c,u).join("")};g.a=function(c){if(!/^(?:[0-9a-fA-F]{2})*$/.test(c))throw Error("Invalid hex-encoded string");for(var g=c.length/2,a=new Uint8Array(g),f=0;f<g;++f)a[f]=parseInt(c.substr(2*f,2),16);return a}},function(p,g,c){function u(a){var f=Object(q.b)(a);return(a/f.lengthInNanometers).toPrecision(3)+"\u202f"+f.unit}g.c=function(a){return"("+Math.floor(a[0])+", "+Math.floor(a[1])+", "+Math.floor(a[2])+")"};g.b=function(a){for(var f=
"",c=0;3>c;++c)0!==c&&(f+=" \u00d7 "),f+=Math.round(Math.abs(a[c]));return f};g.d=u;g.a=function(a,f,c){for(var g="",l=n.s.create(),m=0;3>m;++m){n.s.set(l,0,0,0);l[m]=f[m]-a[m];var k=Object(n.p)(l,l,c);k=n.s.length(k);0!==m&&(g+=" \u00d7 ");g+=u(k)}a=Math.abs(Object(n.l)(n.s.subtract(l,f,a)));c=n.i.determinant(n.i.fromMat4(n.i.create(),c));g+="  [";c*=a;a=Object(q.c)(c);c=(c/Math.pow(a.lengthInNanometers,3)).toPrecision(6)+"\u202f"+a.unit+"\u00b3";return g+c+"]"};var n=c(1),q=c(81)},function(p,g){},
function(p,g){},function(p,g){},function(p,g){},function(p,g,c){g.a=function(c){return new u.c(void 0===c?1:c,n.o)};var u=c(5),n=c(2)},function(p,g,c){g.a=function(a){a=void 0===a?u.s.create():a;return new f(a,a)};var u=c(1),n=c(2),q=c(3),a=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),f=function(){function f(a,
c){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this.value_=a;this.defaultValue=c;this.changed=new q.a}a(f,[{key:"toJSON",value:function(){if(this.value_!==this.defaultValue)return this.value_.toString()}},{key:"restoreState",value:function(a){try{this.value=Object(n.l)(a.split(","))}catch(t){this.value=this.defaultValue}}},{key:"reset",value:function(){this.value=this.defaultValue}},{key:"value",get:function(){return this.value_},set:function(a){a!==this.value_&&
(this.value_=a,this.changed.dispatch())}}]);return f}()},function(p,g,c){function u(a,d){if(!(a instanceof d))throw new TypeError("Cannot call a class as a function");}function n(a){return a-Math.floor(a)}c.d(g,"b",function(){return m});c.d(g,"a",function(){return d});var q=c(91),a=c(147),f=c(123),l=c(3),v=c(16),t=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,
d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),m=function(){function b(a){u(this,b);this.prefix=a;this.aName=this.prefix+"_a";this.bName=this.prefix+"_b"}t(b,[{key:"defineShader",value:function(b){var d=this.aName,e=this.bName;b.addUniform("highp vec4",d,4);b.addUniform("highp float",e,4);b.addFragmentCode(v.n);b.addFragmentCode(a.d);b.addFragmentCode(v.h);for(var f="\nvec3 "+this.prefix+"(uint64_t x) {\n  vec2 v;\n  float primeModulus = float("+q.b+");\n",c=0;2>c;++c){var h=2*c,k=2*c;f+="\n  v["+
c+"] = computeHash(x,\n                        "+d+"["+k+"], "+d+"["+(k+1)+"],\n                        "+e+"["+h+"], "+e+"["+(h+1)+"],\n                        primeModulus, 1.0 / 256.0);\n"}b.addFragmentCode(f+"\n  vec3 hsv = vec3(v.x, 0.5 + v.y * 0.5, 1.0);\n  return hsvToRgb(hsv);\n}\n")}},{key:"enable",value:function(a,b,d){a.uniform4fv(b.uniform(this.aName),d.a_);a.uniform1fv(b.uniform(this.bName),d.b_)}}]);return b}(),k=new Float32Array(2),e=new Float32Array(3),d=function(){function a(b){u(this,
a);this.a_=new Float32Array(16);this.b_=new Float32Array(4);this.changed=new l.a;null==b?(this.hashFunctions=Array(2),this.randomize_()):this.hashFunctions=b;this.computeGPUCoefficients_()}t(a,[{key:"compute",value:function(a,b){var d=b.low;b=b.high;for(var e=this.hashFunctions,c=0;2>c;++c)k[c]=n(e[c].compute(d,b)/256);Object(f.a)(a,k[0],.5+.5*k[1],1);return a}},{key:"computeCssColor",value:function(a){this.compute(e,a);return"rgb("+100*e[0]+"%,"+100*e[1]+"%,"+100*e[2]+"%)"}},{key:"debugCompute",
value:function(a,b){var d=b.low;b=b.high;for(var e=this.b_,f=q.b,c=0;2>c;++c){for(var h=2*c,k=2*c,g=new Float32Array(2),l=0;4>l;++l)g[0]+=this.a_[4*k+l]*(d>>8*l&255),g[1]+=this.a_[4*(k+1)+l]*(b>>8*l&255);k=(g[0]+g[1])%f;l=k*k%f;var m=l*e[h+1]%f,r=(e[h]+k+m)%f;console.log("b = "+e[h]+", sums="+g[0]+" "+g[1]+", dotResult="+k+", "+("prod = "+k*k+" dotResult2="+l+", y="+m+", ")+("modResult="+r));a[c]=n(1/256*r)}return a}},{key:"randomize_",value:function(){for(var a=0;2>a;++a)this.hashFunctions[a]=q.a.generate()}},
{key:"randomize",value:function(){this.randomize_();this.computeGPUCoefficients_();this.changed.dispatch()}},{key:"toString",value:function(){return"new SegmentColorHash(["+this.hashFunctions+"])"}},{key:"computeGPUCoefficients_",value:function(){for(var a=this.hashFunctions,b=this.a_,d=this.b_,e=0;2>e;++e){var f=a[e],c=2*e,k=8*e;d[c]=1*f.b;d[c+1]=1*f.c;for(c=0;4>c;++c)b[k+c]=1*f.a0[c],b[k+4+c]=1*f.a1[c]}}}],[{key:"getDefault",value:function(){return new a([new q.a(Float32Array.of(609,2364,3749,2289),
Float32Array.of(2840,1186,3660,1833),1718,1109),new q.a(Float32Array.of(3466,3835,3345,2040),Float32Array.of(3382,901,18,3444),1534,1432)])}}]);return a}()},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return e});c.d(g,"c",function(){return d});c.d(g,"b",function(){return b});var a=c(91),f=c(92);p=c(0);var l=c(16),v=c(65),t=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,
e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),m=function r(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return r(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},k=[l.q,l.n,l.e,l.i,"\nfloat computeHash(uint64_t x, vec4 a0, vec4 a1, float b, float c, float modulus, float scalar) {\n  x.low = unnormalizeUint8(x.low);\n  x.high = unnormalizeUint8(x.high);\n  float dotResult = imod(exactDot(a0, x.low) + exactDot(a1, x.high), modulus);\n  float dotResult2 = imod(dotResult * dotResult, modulus);\n  float y = imod(dotResult2 * c, modulus);\n  float modResult = imod(dotResult + y + b, modulus);\n  return fract(modResult * scalar);\n}\n"];
g.d=k;var e=function(b){function d(a,b){u(this,d);var e=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.gl=a;e.hashTable=b;e.hashFunctions=null;e.generation=-1;e.texture=null;b=b.hashFunctions.length;e.a=new Float32Array(16*b);e.b=new Float32Array(4*b+5);e.texture=a.createTexture();return e}q(d,b);t(d,[{key:"computeCoefficients",value:function(){var b=this.hashTable,d=b.hashFunctions;if(this.hashFunctions!==d){this.hashFunctions=d;for(var e=this.a,f=this.b,c=d.length,k=b.width,g=[1/k,
1/b.height],l=0;2>l;++l)f[4*c+l]=a.b,f[4*c+3+l]=g[l];f[4*c+2]=1/(b.entryStride*k);for(k=0;k<c;++k)for(g=d[k],l=0;2>l;++l){var m=g[l],r=4*k+2*l,t=4*(4*k+2*l);f[r]=m.b+(0===l?.5/b.entryStride:.5);f[r+1]=m.c;for(r=0;4>r;++r)e[t+r]=m.a0[r],e[t+4+r]=m.a1[r]}}}},{key:"copyToGPU",value:function(){this.computeCoefficients();var a=this.hashTable,b=a.generation;if(this.generation!==b){this.generation=b;var d=a.width,e=a.height,f=this.gl;b=this.texture;f.activeTexture(f.TEXTURE0+f.tempTextureUnit);f.bindTexture(f.TEXTURE_2D,
b);f.pixelStorei(f.UNPACK_ALIGNMENT,1);Object(v.b)(f);var c=f.RGBA;a.tableWithMungedEmptyKey(function(b){f.texImage2D(f.TEXTURE_2D,0,c,d*a.entryStride,e,0,c,f.UNSIGNED_BYTE,new Uint8Array(b.buffer))});f.bindTexture(f.TEXTURE_2D,null)}}},{key:"disposed",value:function(){this.gl.deleteTexture(this.texture);this.texture=null;this.hashTable=this.gl=void 0;this.hashFunctions=null;m(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}}],[{key:"get",value:function(a,b){var d=
this;return a.memoize.get(b,function(){return new d(a,b)})}}]);return d}(p.a),d=function(){function a(b,d){d=void 0===d?f.c:d;u(this,a);this.prefix=b;this.numAlternatives=d;$jscomp.initSymbol();this.textureUnitSymbol=Symbol.for("gpuhashtable:"+this.prefix);this.aName=this.prefix+"_a";this.bName=this.prefix+"_b";this.samplerName=this.prefix+"_sampler"}t(a,[{key:"defineShader",value:function(a){var b=this.aName,d=this.bName,e=this.samplerName,f=this.numAlternatives;a.addUniform("highp vec4",b,4*f);
a.addUniform("highp float",d,4*f+5);a.addTextureSampler2D(e,this.textureUnitSymbol);a.addFragmentCode(k);for(var c="",g=0;g<f;++g){for(var l=0;2>l;++l){var m=4*g+2*l,r=4*g+2*l;c+="\nfloat "+this.prefix+"_computeHash_"+g+"_"+l+"(uint64_t x) {\n  float primeModulus = "+d+"["+(4*f+l)+"];\n  float scalar = "+d+"["+(4*f+3+l)+"];\n  return computeHash(x,\n                     "+b+"["+r+"], "+b+"["+(r+1)+"],\n                     "+d+"["+m+"], "+d+"["+(m+1)+"],\n                     primeModulus, scalar);\n}\n"}c+=
"\nvec2 "+this.prefix+"_computeHash_"+g+"(uint64_t x) {\n  vec2 v;\n  v[0] = "+this.prefix+"_computeHash_"+g+"_0(x);\n  v[1] = "+this.prefix+"_computeHash_"+g+"_1(x);\n  return v;\n}\n"}c+="\nbool "+this.hasFunctionName+"(uint64_t x) {\n  float highOffset = "+d+"["+(4*f+2)+"];\n";for(b=0;b<f;++b)c+="\n  {\n    vec2 v = "+this.prefix+"_computeHash_"+b+"(x);\n    vec4 lowResult = texture2D("+e+", v);\n    vec4 highResult = texture2D("+e+", vec2(v.x + highOffset, v.y));\n    if (lowResult == x.low && highResult == x.high) {\n      return true;\n    }\n  }\n";
a.addFragmentCode(c+"\n  return false;\n}\n")}},{key:"enable",value:function(a,b,d){d.copyToGPU();var e=b.textureUnit(this.textureUnitSymbol);a.activeTexture(a.TEXTURE0+e);a.bindTexture(a.TEXTURE_2D,d.texture);a.uniform4fv(b.uniform(this.aName),d.a);a.uniform1fv(b.uniform(this.bName),d.b)}},{key:"disable",value:function(a,b){b=b.textureUnit(this.textureUnitSymbol);a.activeTexture(a.TEXTURE0+b);a.bindTexture(a.TEXTURE_2D,null)}},{key:"hasFunctionName",get:function(){return this.prefix+"_has"}}]);return a}(),
b=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);t(b,[{key:"defineShader",value:function(a){m(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"defineShader",this).call(this,a);for(var d=this.samplerName,e=this.numAlternatives,f="\nbool "+this.getFunctionName+"(uint64_t x, out uint64_t value) {\n  float highOffset = "+this.bName+"["+(4*e+2)+"];\n",c=0;c<e;++c)f+="\n  {\n    vec2 v = "+this.prefix+"_computeHash_"+c+"(x);\n    vec4 lowResult = texture2D("+
d+", v);\n    vec4 highResult = texture2D("+d+", vec2(v.x + highOffset, v.y));\n    if (lowResult == x.low && highResult == x.high) {\n      value.low = texture2D("+d+", vec2(v.x + 2.0 * highOffset, v.y));\n      value.high = texture2D("+d+", vec2(v.x + 3.0 * highOffset, v.y));\n      return true;\n    }\n  }\n";a.addFragmentCode(f+"\n  return false;\n}\n")}},{key:"getFunctionName",get:function(){return this.prefix+"_get"}}]);return b}(d)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){for(var d=
$jscomp.makeIterator(R),e=d.next();!e.done;e=d.next()){e=e.value;var f=b[e];void 0!==f&&(a[e].value=f)}}function f(a){var b=new y.a,d=b.element;d.classList.add("neuroglancer-viewer-context-menu");var e=function(a,e){a=b.registerDisposer(new aa.a(e,{label:a}));a.element.classList.add("neuroglancer-viewer-context-menu-limit-widget");d.appendChild(a.element)};e("GPU memory limit",a.chunkQueueManager.capacities.gpuMemory.sizeLimit);e("System memory limit",a.chunkQueueManager.capacities.systemMemory.sizeLimit);
e("Concurrent chunk requests",a.chunkQueueManager.capacities.download.itemLimit);e=function(a,e){var f=document.createElement("label");f.textContent=a;a=b.registerDisposer(new A.c(e));f.appendChild(a.element);d.appendChild(f)};e("Show axis lines",a.showAxisLines);e("Show scale bar",a.showScaleBar);e("Show cross sections in 3-d",a.showPerspectiveSliceViews);e("Show default annotations",a.showDefaultAnnotations);return b}c.d(g,"a",function(){return na});p=c(6);var l=c.n(p),v=c(17),t=c(266);p=c(149);
var m=c(32),k=c(271),e=c(14),d=c(151),b=c(280),h=c(20),r=c(58),x=c(41),z=c(25),A=c(57),D=c(5),y=c(155),E=c(289),G=c(291),H=c(156),B=c(295),C=c(66),F=c(136);g=c(0);var M=c(10),I=c(19),P=c(1),N=c(53),U=c(3),O=c(29),T=c(26),W=c(301),aa=c(303),J=c(97),S=c(87),ha=c(12),L=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}();
c(304);c(40);c(68);var ma=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.gl=a;d.worker=new Worker("chunk_worker.bundle.js");d.chunkQueueManager=d.registerDisposer(new v.d(new ha.a(d.worker),d.gl,{gpuMemory:new v.a({defaultItemLimit:1E6,defaultSizeLimit:1E9}),systemMemory:new v.a({defaultItemLimit:1E7,defaultSizeLimit:2E9}),download:new v.a({defaultItemLimit:32,defaultSizeLimit:Number.POSITIVE_INFINITY})}));d.chunkManager=d.registerDisposer(new v.c(d.chunkQueueManager));
d.chunkQueueManager.registerDisposer(function(){return d.worker.terminate()});return d}q(b,a);L(b,[{key:"rpc",get:function(){return this.chunkQueueManager.rpc}}]);return b}(g.a);(function(a){function b(){u(this,b);var a=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));a.global=new N.a;return a}q(b,a);return b})(p.b);var X=["showHelpButton","showEditStateButton","showLayerPanel","showLocation","showAnnotationToolStatus"],R=[].concat(["showUIControls","showPanelBorders"],$jscomp.arrayFromIterable(X)),
Y=function(a){function b(){u(this,b);var a=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));a.showUIControls=new A.b(!0);a.showPanelBorders=new A.b(!0);return a}q(b,a);return b}(function La(){u(this,La);this.showHelpButton=new A.b(!0);this.showEditStateButton=new A.b(!0);this.showLayerPanel=new A.b(!0);this.showLocation=new A.b(!0);this.showAnnotationToolStatus=new A.b(!0)}),Ca={showLayerDialog:!0,resetStateWhenEmpty:!0},na=function(c){function g(b,f){f=void 0===f?{}:f;u(this,
g);var c=n(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));c.display=b;c.navigationState=c.registerDisposer(new r.e);c.perspectiveNavigationState=new r.e(new r.g(c.navigationState.position),1);c.mouseState=new e.d;c.layerManager=c.registerDisposer(new e.a);c.selectedLayer=c.registerDisposer(new e.g(c.layerManager.addRef()));c.showAxisLines=new A.b(!0,!0);c.showScaleBar=new A.b(!0,!0);c.showPerspectiveSliceViews=new A.b(!0,!0);c.visibleLayerRoles=Object(e.j)();c.showDefaultAnnotations=new A.b(!0,
!0);c.crossSectionBackgroundColor=new F.a(P.s.fromValues(.5,.5,.5));c.layerSelectedValues=c.registerDisposer(new e.b(c.layerManager,c.mouseState));c.resetInitiated=new U.a;c.state=new O.a;c.uiControlVisibility={};c.visible=!0;var k=f,v=void 0===k.dataContext?new ma(b.gl):k.dataContext,q=void 0===k.visibility?new T.b(T.b.VISIBLE):k.visibility,p=void 0===k.inputEventBindings?{global:new N.a,sliceView:new N.a,perspectiveView:new N.a}:k.inputEventBindings,z=void 0===k.element?b.makeCanvasOverlayElement():
k.element,E=void 0===k.dataSourceProvider?Object(m.a)({credentialsManager:t.a}):k.dataSourceProvider;k=void 0===k.uiConfiguration?new Y:k.uiConfiguration;c.visibility=q;c.inputEventBindings=p;c.element=z;c.dataSourceProvider=E;c.uiConfiguration=k;c.registerDisposer(function(){return Object(M.b)(c.element)});c.dataContext=c.registerDisposer(v);a(k,f);v=Object.assign({},Ca,f);f=v.resetStateWhenEmpty;v=v.showLayerDialog;q=$jscomp.makeIterator(X);for(p=q.next();!p.done;p=q.next())p=p.value,c.uiControlVisibility[p]=
c.makeUiControlVisibilityState(p);c.registerDisposer(c.uiConfiguration.showPanelBorders.changed.add(function(){c.updateShowBorders();c.display.onResize()}));c.showLayerDialog=v;c.resetStateWhenEmpty=f;c.layerSpecification=new h.c(c.dataSourceProvider,c.layerManager,c.chunkManager,c.layerSelectedValues,c.navigationState.voxelSize);c.registerDisposer(b.updateStarted.add(function(){c.onUpdateDisplay()}));c.registerDisposer(b.updateFinished.add(function(){c.onUpdateDisplayFinished()}));c.showDefaultAnnotations.changed.add(function(){c.showDefaultAnnotations.value?
c.visibleLayerRoles.add(e.f.DEFAULT_ANNOTATION):c.visibleLayerRoles.delete(e.f.DEFAULT_ANNOTATION)});f=c.state;f.add("layers",c.layerSpecification);f.add("navigation",c.navigationState);f.add("showAxisLines",c.showAxisLines);f.add("showScaleBar",c.showScaleBar);f.add("showDefaultAnnotations",c.showDefaultAnnotations);f.add("perspectiveOrientation",c.perspectiveNavigationState.pose.orientation);f.add("perspectiveZoom",c.perspectiveNavigationState.zoomFactor);f.add("showSlices",c.showPerspectiveSliceViews);
f.add("gpuMemoryLimit",c.dataContext.chunkQueueManager.capacities.gpuMemory.sizeLimit);f.add("systemMemoryLimit",c.dataContext.chunkQueueManager.capacities.systemMemory.sizeLimit);f.add("concurrentDownloads",c.dataContext.chunkQueueManager.capacities.download.itemLimit);f.add("selectedLayer",c.selectedLayer);f.add("crossSectionBackgroundColor",c.crossSectionBackgroundColor);c.registerDisposer(c.navigationState.changed.add(function(){c.handleNavigationStateChanged()}));c.layerManager.initializePosition(c.navigationState.position);
c.registerDisposer(c.layerSpecification.voxelCoordinatesSet.add(function(a){c.navigationState.position.setVoxelCoordinates(a)}));c.registerDisposer(c.layerSpecification.spatialCoordinatesSet.add(function(a){var b=c.navigationState.position;P.s.copy(b.spatialCoordinates,a);b.markSpatialCoordinatesChanged()}));v=c.registerCancellable(l()(function(){!c.wasDisposed&&0===c.layerManager.managedLayers.length&&c.resetStateWhenEmpty&&(c.navigationState.reset(),c.perspectiveNavigationState.pose.orientation.reset(),
c.perspectiveNavigationState.zoomFactor.reset(),c.resetInitiated.dispatch(),!x.b&&c.showLayerDialog&&c.visibility.visible&&new d.a(c.layerSpecification))}));c.layerManager.layersChanged.add(v);v();c.registerDisposer(c.dataContext.chunkQueueManager.visibleChunksChanged.add(function(){c.layerSelectedValues.handleLayerChange()}));c.registerDisposer(c.dataContext.chunkQueueManager.visibleChunksChanged.add(function(){c.visible&&b.scheduleRedraw()}));c.makeUI();c.updateShowBorders();f.add("layout",c.layout);
c.registerActionListeners();c.registerEventActionBindings();c.registerDisposer(Object(H.a)(z,c.navigationState.position));c.registerDisposer(new G.a(c.mouseState,c.layerManager,c.navigationState.voxelSize));return c}q(g,c);L(g,[{key:"makeUiControlVisibilityState",value:function(a){return this.registerDisposer(Object(D.g)(function(a,b){return a&&b},this.uiConfiguration.showUIControls,this.uiConfiguration[a]))}},{key:"updateShowBorders",value:function(){var a=this.element;this.uiConfiguration.showPanelBorders.value?
a.classList.add("neuroglancer-show-panel-borders"):a.classList.remove("neuroglancer-show-panel-borders")}},{key:"makeUI",value:function(){var a=this,d=this.element;d.classList.add("neuroglancer-viewer");d.classList.add("neuroglancer-noselect");d.style.display="flex";d.style.flexDirection="column";var e=document.createElement("div");e.title="Right click for settings";e.classList.add("neuroglancer-viewer-top-row");(this.contextMenu=this.registerDisposer(f(this))).registerParent(e);e.style.display="flex";
e.style.flexDirection="row";e.style.alignItems="stretch";var c=this.registerDisposer(new J.c(document.createElement("div"),this.navigationState.voxelSize));this.registerDisposer(new A.a(this.uiControlVisibility.showLocation,c.element));e.appendChild(c.element);c=this.registerDisposer(new J.b(this.navigationState.position));this.registerDisposer(new A.a(this.uiControlVisibility.showLocation,c.element));e.appendChild(c.element);c=this.registerDisposer(new J.a(document.createElement("div"),this.mouseState,
this.navigationState.voxelSize));c.element.style.flex="1";c.element.style.alignSelf="center";this.registerDisposer(new A.a(this.uiControlVisibility.showLocation,c.element));e.appendChild(c.element);c=this.registerDisposer(new W.a(this.selectedLayer));e.appendChild(c.element);this.registerDisposer(new A.a(this.uiControlVisibility.showAnnotationToolStatus,c.element));c=Object(S.a)("{}","Edit JSON state");this.registerEventListener(c,"click",function(){a.editJsonState()});this.registerDisposer(new A.a(this.uiControlVisibility.showEditStateButton,
c));e.appendChild(c);c=Object(S.a)("?","Help");this.registerEventListener(c,"click",function(){a.showHelpDialog()});this.registerDisposer(new A.a(this.uiControlVisibility.showHelpButton,c));e.appendChild(c);this.registerDisposer(new A.a(Object(D.g)(function(a){for(var b=[],d=0;d<arguments.length;++d)b[d-0]=arguments[d];return b.reduce(function(a,b){return a||b},!1)},this.uiControlVisibility.showHelpButton,this.uiControlVisibility.showEditStateButton,this.uiControlVisibility.showLocation,this.uiControlVisibility.showAnnotationToolStatus),
e));d.appendChild(e);e=document.createElement("div");e.style.display="flex";e.style.flex="1";e.style.flexDirection="row";this.layout=this.registerDisposer(new b.a(this,"4panel"));e.appendChild(this.layout.element);e.appendChild(this.registerDisposer(new E.a(this.selectedLayer.addRef())).element);this.registerDisposer(this.selectedLayer.changed.add(function(){return a.display.onResize()}));d.appendChild(e);this.display.onResize();e=function(){var b=a.visibility.visible;b!==a.visible&&(d.style.visibility=
b?"inherit":"hidden",a.visible=b)};e();this.registerDisposer(this.visibility.changed.add(e))}},{key:"registerEventActionBindings",value:function(){var a=this.element;this.registerDisposer(new N.b(a,this.inputEventMap));this.registerDisposer(new C.a(a))}},{key:"bindAction",value:function(a,b){this.registerDisposer(Object(I.c)(this.element,a,b))}},{key:"registerActionListeners",value:function(){for(var a=this,b={},d=$jscomp.makeIterator(["recolor","clear-segments"]),e=d.next();!e.done;b={action:b.action},
e=d.next())b.action=e.value,this.bindAction(b.action,function(b){return function(){a.layerManager.invokeAction(b.action)}}(b));b={};d=$jscomp.makeIterator(["select"]);for(e=d.next();!e.done;b={action$300:b.action$300},e=d.next())b.action$300=e.value,this.bindAction(b.action$300,function(b){return function(){a.mouseState.updateUnconditionally();a.layerManager.invokeAction(b.action$300)}}(b));this.bindAction("help",function(){return a.showHelpDialog()});for(e={i:1};9>=e.i;e={i:e.i},++e.i)this.bindAction("toggle-layer-"+
e.i,function(b){return function(){var d=b.i-1,e=a.layerManager.managedLayers;d<e.length&&(d=e[d],d.setVisible(!d.visible))}}(e)),this.bindAction("select-layer-"+e.i,function(b){return function(){var d=b.i-1,e=a.layerManager.managedLayers;d<e.length&&(a.selectedLayer.layer=e[d],a.selectedLayer.visible=!0)}}(e));this.bindAction("annotate",function(){var b=a.selectedLayer.layer;if(void 0===b)z.a.showTemporaryMessage("The annotate command requires a layer to be selected.");else{var d=b.layer;null===d||
void 0===d.tool.value?z.a.showTemporaryMessage("The selected layer ("+JSON.stringify(b.name)+") does not have an active annotation tool."):d.tool.value.trigger(a.mouseState)}});this.bindAction("toggle-axis-lines",function(){return a.showAxisLines.toggle()});this.bindAction("toggle-scale-bar",function(){return a.showScaleBar.toggle()});this.bindAction("toggle-default-annotations",function(){return a.showDefaultAnnotations.toggle()});this.bindAction("toggle-show-slices",function(){return a.showPerspectiveSliceViews.toggle()})}},
{key:"showHelpDialog",value:function(){var a=this.inputEventBindings;new k.a([["Global",a.global],["Slice View",a.sliceView],["Perspective View",a.perspectiveView]])}},{key:"editJsonState",value:function(){new B.a(this)}},{key:"onUpdateDisplay",value:function(){this.visible&&(this.dataContext.chunkQueueManager.chunkUpdateDeadline=null)}},{key:"onUpdateDisplayFinished",value:function(){this.visible&&this.mouseState.updateIfStale()}},{key:"handleNavigationStateChanged",value:function(){if(this.visible){var a=
this.dataContext.chunkQueueManager;null===a.chunkUpdateDeadline&&(a.chunkUpdateDeadline=Date.now()+10)}this.mouseState.stale=!0}},{key:"chunkManager",get:function(){return this.dataContext.chunkManager}},{key:"chunkQueueManager",get:function(){return this.dataContext.chunkQueueManager}},{key:"inputEventMap",get:function(){return this.inputEventBindings.global}},{key:"gl",get:function(){return this.display.gl}}]);return g}(g.a)},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function a(a,b){b=void 0===b?a.navigationState:
new x.e(new x.g(a.navigationState.pose.position,x.f.makeRelative(a.navigationState.pose.orientation,b)),a.navigationState.zoomFactor);return new A.a(a.chunkManager,a.layerManager,b)}function f(b){return new Map([["xy",a(b,N.get("xy"))],["xz",a(b,N.get("xz"))],["yz",a(b,N.get("yz"))]])}function l(a){return{crossSectionBackgroundColor:a.crossSectionBackgroundColor,mouseState:a.mouseState,layerManager:a.layerManager,showAxisLines:a.showAxisLines,visibleLayerRoles:a.visibleLayerRoles,selectedLayer:a.selectedLayer,
visibility:a.visibility}}function v(a){return Object.assign({},l(a),{navigationState:a.perspectiveNavigationState,inputEventMap:a.inputEventBindings.perspectiveView,rpc:a.chunkManager.rpc})}function t(a){return Object.assign({},l(a),{navigationState:a.navigationState,inputEventMap:a.inputEventBindings.sliceView})}function m(a,b,d){for(var e={},f=0;2>f;e={relatedLayout:e.relatedLayout},++f)e.relatedLayout=d[Math.min(d.length-1,f)],a.registerDisposer(Object(H.c)(b.element,0===f?"toggle-layout":"toggle-layout-alternative",
function(b){return function(d){a.container.name=b.relatedLayout;d.stopPropagation()}}(e)))}function k(a,b){var d=new A.a(a.chunkManager,a.layerManager,b.navigationState.addRef());a=function(){d.setViewportSizeDebounced(b.width.value,b.height.value)};d.registerDisposer(b.width.changed.add(a));d.registerDisposer(b.height.changed.add(a));a();return d}function e(a,b,d){var e=new Map,f=new Set;d=$jscomp.makeIterator(d.values());for(var c=d.next();!c.done;c=d.next())if(c=c.value,f.add(c),!e.has(c)){var h=
k(a,c);b.sliceViews.set(h,!0);e.set(c,h)}a=$jscomp.makeIterator(e);for(e=a.next();!e.done;e=a.next())d=$jscomp.makeIterator(e.value),e=d.next().value,d=d.next().value,f.has(e)||b.sliceViews.delete(d)}function d(a){var b=aa.get(a);if(void 0===b)throw Error("Invalid layout name: "+JSON.stringify(a)+".");return b}function b(a){d(a);return a}c.d(g,"b",function(){return P});c.d(g,"a",function(){return ma});p=c(6);var h=c.n(p),r=c(267),x=c(58),z=c(268),A=c(45),D=c(79),y=c(57),E=c(5);p=c(0);var G=c(10),
H=c(19),B=c(1),C=c(2),F=c(3);g=c(150);var M=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),I=function R(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return R(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===
b?void 0:b.call(d)}};c(68);var P=function Y(){q(this,Y);this.perspectiveView=new H.a;this.sliceView=new H.a},N=new Map([["xy",void 0],["xz",B.n.rotateX(B.n.create(),B.n.create(),Math.PI/2)],["yz",B.n.rotateY(B.n.create(),B.n.create(),Math.PI/2)]]),U=function(a){function b(a,d,c,k){q(this,b);var h=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));h.container=a;h.rootElement=d;h.viewer=c;var g=f(c),l=c.display,n=Object.assign({},v(c),{showSliceViews:c.showPerspectiveSliceViews,showSliceViewsCheckbox:!0}),
p=Object.assign({},t(c),{showScaleBar:c.showScaleBar}),x=Object.assign({},t(c),{showScaleBar:new y.b(!1,!1)}),A=function(a,b,d){b=h.registerDisposer(new D.a(l,b,g.get(a),d));m(h,b,[a,a+"-3d"]);return b};a=[r.b(1,r.a("column",[r.b(1,r.a("row",[r.b(1,function(a){A("xy",a,p)}),r.b(1,function(a){A("xz",a,x)})])),r.b(1,r.a("row",[r.b(1,function(a){a=h.registerDisposer(new z.a(l,a,n));for(var b=$jscomp.makeIterator(g.values()),d=b.next();!d.done;d=b.next())a.sliceViews.set(d.value.addRef(),!1);e(c,a,k);
m(h,a,["3d"])}),r.b(1,function(a){A("yz",a,x)})]))]))];r.a("row",a)(d);l.onResize();return h}n(b,a);M(b,[{key:"disposed",value:function(){Object(G.a)(this.rootElement);I(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}}]);return b}(p.a),O=function(b){function d(b,f,c,h,k,g){q(this,d);var l=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));l.container=b;l.rootElement=f;l.viewer=c;l.direction=h;var n=a(c,N.get(k)),p=c.display,x=Object.assign({},v(c),{showSliceViews:c.showPerspectiveSliceViews,
showSliceViewsCheckbox:!0}),A=Object.assign({},t(c),{showScaleBar:c.showScaleBar});r.b(1,r.a(h,[r.b(1,function(a){a=l.registerDisposer(new D.a(p,a,n,A));m(l,a,[k,"4panel"])}),r.b(1,function(a){a=l.registerDisposer(new z.a(p,a,x));a.sliceViews.set(n.addRef(),!1);e(c,a,g);m(l,a,["3d","4panel"])})]))(f);p.onResize();return l}n(d,b);M(d,[{key:"disposed",value:function(){Object(G.a)(this.rootElement);I(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}}]);return d}(p.a),
T=function(b){function d(b,e,f,c){q(this,d);var h=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));h.container=b;h.rootElement=e;h.viewer=f;var k=a(f,N.get(c)),g=Object.assign({},t(f),{showScaleBar:f.showScaleBar});r.a("row",[r.b(1,function(a){a=h.registerDisposer(new D.a(f.display,a,k,g));m(h,a,["4panel",c+"-3d"])})])(e);f.display.onResize();return h}n(d,b);M(d,[{key:"disposed",value:function(){Object(G.a)(this.rootElement);I(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",
this).call(this)}}]);return d}(p.a),W=function(a){function b(a,d,f,c){q(this,b);var h=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));h.container=a;h.rootElement=d;h.viewer=f;var k=Object.assign({},v(f),{showSliceViews:new y.b(!1,!1)});r.a("row",[r.b(1,function(a){a=h.registerDisposer(new z.a(f.display,a,k));e(f,a,c);m(h,a,["4panel"])})])(d);f.display.onResize();return h}n(b,a);M(b,[{key:"disposed",value:function(){Object(G.a)(this.rootElement);I(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),
"disposed",this).call(this)}}]);return b}(p.a),aa=new Map([["4panel",{factory:function(a,b,d,e){return new U(a,b,d,e)}}],["3d",{factory:function(a,b,d,e){return new W(a,b,d,e)}}]]);c={};B=$jscomp.makeIterator(N.keys());for(var J=B.next();!J.done;c={axes:c.axes},J=B.next())c.axes=J.value,aa.set(c.axes,{factory:function(a){return function(b,d,e){return new T(b,d,e,a.axes)}}(c)}),aa.set(c.axes+"-3d",{factory:function(a){return function(b,d,e,f){return new O(b,d,e,"row",a.axes,f)}}(c)});var S=function(a){function b(a){q(this,
b);var d=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.width=new E.c(1E3,C.A);d.height=new E.c(1E3,C.A);d.changed=new F.a;d.position=new x.b(a.position.addRef());d.position.changed.add(d.changed.dispatch);d.orientation=new x.a(a.pose.orientation.addRef());d.orientation.changed.add(d.changed.dispatch);d.width.changed.add(d.changed.dispatch);d.height.changed.add(d.changed.dispatch);d.zoom=new x.c(a.zoomFactor.addRef());d.zoom.changed.add(d.changed.dispatch);d.navigationState=d.registerDisposer(new x.e(new x.g(d.position.value,
d.orientation.value),d.zoom.value));return d}n(b,a);M(b,[{key:"restoreState",value:function(a){var b=this;Object(C.u)(a);Object(C.w)(a,"width",function(a){return void 0!==a&&b.width.restoreState(a)});Object(C.w)(a,"height",function(a){return void 0!==a&&b.height.restoreState(a)});Object(C.w)(a,"position",function(a){return void 0!==a&&b.position.restoreState(a)});Object(C.w)(a,"orientation",function(a){return void 0!==a&&b.orientation.restoreState(a)});Object(C.w)(a,"zoom",function(a){return void 0!==
a&&b.zoom.restoreState(a)})}},{key:"reset",value:function(){this.width.reset();this.height.reset();this.position.reset();this.orientation.reset();this.zoom.reset()}},{key:"toJSON",value:function(){return{width:this.width,height:this.height,position:this.position,orientation:this.orientation,zoom:this.zoom}}}]);return b}(p.a),ha=function(a){function b(a){q(this,b);var d=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,function(a){return d.registerDisposer(d.registerDisposer(a).changed.add(d.changed.dispatch))},
function(a){a.changed.remove(d.changed.dispatch);a.dispose()}));d.parentNavigationState=a;d.registerDisposer(a);return d}n(b,a);M(b,[{key:"restoreState",value:function(a){Object(C.u)(a);for(var b=$jscomp.makeIterator(Object.keys(a)),d=b.next();!d.done;d=b.next()){d=d.value;var e=new S(this.parentNavigationState);try{this.set(d,e.addRef()),e.restoreState(a[d])}finally{e.dispose()}}}},{key:"reset",value:function(){this.clear()}},{key:"toJSON",value:function(){for(var a={},b=$jscomp.makeIterator(this),
d=b.next();!d.done;d=b.next()){var e=$jscomp.makeIterator(d.value);d=e.next().value;e=e.next().value;a[d]=e}return a}}]);return b}(g.a),L=function(a){function d(a,e){q(this,d);var f=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));f.changed=new F.a;f.type=new E.c(e,b);f.type.changed.add(f.changed.dispatch);f.crossSections=f.registerDisposer(new ha(a));f.crossSections.changed.add(f.changed.dispatch);f.registerDisposer(a);return f}n(d,a);M(d,[{key:"reset",value:function(){this.crossSections.clear();
this.type.reset()}},{key:"restoreState",value:function(a){var b=this;this.crossSections.clear();"string"===typeof a?this.type.restoreState(a):(Object(C.u)(a),Object(C.w)(a,"type",function(a){return b.type.restoreState(a)}),Object(C.w)(a,"crossSections",function(a){return void 0!==a&&b.crossSections.restoreState(a)}))}},{key:"toJSON",value:function(){var a=this.type,b=this.crossSections;return 0===b.size?a.toJSON():{type:a.toJSON(),crossSections:b}}}]);return d}(p.a),ma=function(a){function b(a,d){d=
void 0===d?"xy":d;q(this,b);var e=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.viewer=a;e.element=document.createElement("div");e.specification=e.registerDisposer(new L(e.viewer.navigationState.addRef(),d));e.element.style.flex="1";var f=e.registerCancellable(h()(function(){return e.updateLayout()},0));e.specification.type.changed.add(f);e.registerDisposer(e.viewer.display.updateStarted.add(function(){return f.flush()}));f();return e}n(b,a);M(b,[{key:"toJSON",value:function(){return this.specification.toJSON()}},
{key:"restoreState",value:function(a){this.specification.restoreState(a)}},{key:"reset",value:function(){this.specification.reset()}},{key:"disposeLayout",value:function(){var a=this.layout;void 0!==a&&(a.dispose(),this.layout=void 0)}},{key:"updateLayout",value:function(){this.disposeLayout();this.layout=d(this.name).factory(this,this.element,this.viewer,this.specification.crossSections)}},{key:"disposed",value:function(){this.disposeLayout();I(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),
"disposed",this).call(this)}},{key:"name",get:function(){return this.specification.type.value},set:function(a){this.specification.type.value=a}},{key:"changed",get:function(){return this.specification.changed}}]);return b}(p.a)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,f):a.__proto__=f)}c.d(g,"a",function(){return f});p=c(0);var n=c(3),q=function(){function a(a,f){for(var c=0;c<f.length;c++){var k=f[c];k.enumerable=k.enumerable||!1;k.configurable=!0;"value"in k&&(k.writable=!0);Object.defineProperty(a,k.key,k)}}return function(f,c,g){c&&a(f.prototype,c);g&&a(f,g);return f}}(),a=function v(a,f,c){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,f);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return v(a,f,c)}else{if("value"in
e)return e.value;f=e.get;return void 0===f?void 0:f.call(c)}},f=function(f){function c(a,f,e){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var d=(c.__proto__||Object.getPrototypeOf(c)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");d=!d||"object"!==typeof d&&"function"!==typeof d?this:d;d.register=a;d.unregister=f;d.changed=new n.a;void 0===e?d.map=new Map:(d.map=new Map(e),d.map.forEach(d.register));return d}
u(c,f);$jscomp.initSymbol();$jscomp.initSymbolIterator();q(c,[{key:"set",value:function(a,f){var e=this.map,d=e.get(a);void 0!==d&&this.unregister(d,a);e.set(a,f);this.register(f,a);this.changed.dispatch();return this}},{key:"delete",value:function(a){var f=this.map.get(a);return void 0!==f?(this.unregister(f,a),this.changed.dispatch(),!0):!1}},{key:"has",value:function(a){return this.map.has(a)}},{key:Symbol.iterator,value:function(){$jscomp.initSymbol();$jscomp.initSymbolIterator();return this.map[Symbol.iterator]()}},
{key:"clear",value:function(){var a=this.map;0<a.size&&(a.forEach(this.unregister),a.clear(),this.changed.dispatch())}},{key:"values",value:function(){return this.map.values()}},{key:"keys",value:function(){return this.map.keys()}},{key:"disposed",value:function(){this.map.forEach(this.unregister);this.map.clear();a(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}},{key:"size",get:function(){return this.map.size}}]);return c}(p.a)},function(p,g,c){function u(a,
d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function n(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}c.d(g,"a",function(){return k});var q=
c(20);p=c(41);var a=c(18),f=c(34),l=c(152),v=c(273),t=c(278),m=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}();c(279);var k=function(e){function d(a,e){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");var b=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));b.manager=
a;b.existingLayer=e;b.statusElement=document.createElement("div");b.submitElement=document.createElement("button");b.namePromptElement=document.createElement("label");b.nameInputElement=document.createElement("input");b.volumeCancellationSource=void 0;b.sourceValid=!1;b.nameValid=!0;var f=b.content;f.classList.add("add-layer-overlay");var c=document.createElement("form");c.className="source-form";b.registerEventListener(c,"submit",function(a){a.preventDefault();b.validateSource(!0)});var h=document.createElement("label");
h.textContent="Source:";a=b.sourceInput=b.registerDisposer(new v.a({completer:function(a,d){return b.manager.dataSourceProvider.volumeCompleter(a,b.manager.chunkManager,d).then(function(a){return{completions:a.completions,makeElement:v.b,offset:a.offset,showSingleResult:!0}})},delay:0}));a.element.classList.add("add-layer-source");a.inputElement.addEventListener("blur",function(){b.validateSource(!1)});b.submitElement.disabled=!0;a.inputChanged.add(function(){var a=b.volumeCancellationSource;void 0!==
a&&(a.cancel(),b.volumeCancellationSource=void 0);b.sourceValid=!1;b.submitElement.disabled=!0;b.statusElement.textContent=""});c.appendChild(h);c.appendChild(a.element);Object(l.a)(h,a.inputElement);h=Object(t.a)();c.appendChild(h);f.appendChild(c);var k=b.statusElement,g=b.namePromptElement,m=b.nameInputElement;c=b.submitElement;k.className="dialog-status";h=document.createElement("form");h.className="name-form";g.textContent="Name:";m.className="add-layer-name";m.autocomplete="off";m.spellcheck=
!1;m.type="text";b.registerEventListener(m,"input",function(){b.validateName()});c.type="submit";Object(l.a)(g,m);h.appendChild(g);h.appendChild(m);h.appendChild(c);f.appendChild(h);f.appendChild(k);void 0!==e?(void 0!==e.sourceUrl?(a.value=e.sourceUrl,b.validateSource()):b.sourceValid=!0,a.disabled=!0,m.value=e.name,b.validateName(),c.textContent="Save",m.focus()):(e=b.manager.layerManager.managedLayers,0<e.length&&(e=e[e.length-1],e instanceof q.b&&(e=e.sourceUrl,void 0!==e&&(f=b.manager.dataSourceProvider.findSourceGroup(e),
a.value=e.substring(0,f),a.inputElement.setSelectionRange(0,f)))),a.inputElement.focus(),c.textContent="Add Layer");b.registerEventListener(h,"submit",function(a){a.preventDefault();b.submit()});return b}n(d,e);m(d,[{key:"isNameValid",value:function(){var a=this.nameInputElement.value;if(""===a)return!1;a=this.manager.layerManager.getLayerByName(a);return void 0===a||a===this.existingLayer}},{key:"submit",value:function(){this.sourceValid&&this.isNameValid()&&(this.existingLayer?(this.existingLayer.name=
this.nameInputElement.value,this.manager.layerManager.layersChanged.dispatch()):this.manager.add(this.manager.getLayer(this.nameInputElement.value,this.sourceInput.value)),this.dispose())}},{key:"validateName",value:function(){var a=this.nameInputElement;(this.nameValid=this.isNameValid())?(a.classList.add("valid-input"),a.classList.remove("invalid-input")):(a.classList.remove("valid-input"),a.classList.add("invalid-input"));this.validityChanged()}},{key:"validityChanged",value:function(){this.submitElement.disabled=
!(this.nameValid&&this.sourceValid)}},{key:"validateSource",value:function(b){var d=this;b=void 0===b?!1:b;var e=this.sourceInput.value;if(""!==e){try{var c=this.manager.dataSourceProvider.suggestLayerName(e),k=this.nameInputElement;if(""===this.nameInputElement.value){var g=this.manager.layerManager.getUniqueLayerName(c);k.value=g;k.setSelectionRange(0,g.length);this.validateName()}b&&k.focus()}catch(y){this.setError(y.message);return}this.setInfo("Validating volume source...");var l=this.volumeCancellationSource=
new f.b;this.manager.dataSourceProvider.getVolume(this.manager.chunkManager,e,void 0,l).then(function(b){l.isCanceled||(d.volumeCancellationSource=void 0,d.sourceValid=!0,d.setInfo(a.c[b.volumeType].toLowerCase()+": "+(b.numChannels+"-channel "+a.a[b.dataType].toLowerCase())),d.validityChanged())}).catch(function(a){l.isCanceled||(d.volumeCancellationSource=void 0,d.setError(a.message))})}}},{key:"setInfo",value:function(a){this.statusElement.className="dialog-status dialog-status-info";this.statusElement.textContent=
a}},{key:"setError",value:function(a){this.statusElement.className="dialog-status dialog-status-error";this.statusElement.textContent=a}}]);return d}(p.a)},function(p,g,c){g.a=function(c,g){""===g.id&&(g.id="unique-id-for-association-"+u++);c.setAttribute("for",g.id)};var u=0},function(p,g,c){g.a=function(c){var g=-1;return Object.assign(function(){-1===g&&(g=requestAnimationFrame(function(){g=-1;c()}))},{flush:function(){-1!==g&&(g=-1,c())},cancel:function(){-1!==g&&(cancelAnimationFrame(g),g=-1)}})}},
function(p,g,c){g.a=function(c){if(!window.getSelection().isCollapsed)return!0;c=c.target.tagName;return"TEXTAREA"===c||"INPUT"===c?!0:!1};g.b=function(c,g){g=void 0===g?"text/plain":g;var a=!1,f=Object(u.c)(document,"copy",function(f){f.clipboardData.setData(g,c);a=!0;f.stopPropagation();f.preventDefault()},!0);try{document.execCommand("copy")}finally{f()}return a};var u=c(0)},function(p,g,c){function u(a,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+
typeof f);a.prototype=Object.create(f&&f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(a,f):a.__proto__=f)}function n(a,f){var c=document.documentElement.scrollTop+Math.min(document.documentElement.clientHeight-a.offsetHeight,f.clientY);a.style.left=document.documentElement.scrollLeft+Math.min(document.documentElement.clientWidth-a.offsetWidth,f.clientX)+"px";a.style.top=c+"px";a.style.visibility=null}c.d(g,"a",function(){return v});
var q=c(0),a=c(10),f=c(3),l=function(){function a(a,f){for(var e=0;e<f.length;e++){var d=f[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(f,c,e){c&&a(f.prototype,c);e&&a(f,e);return f}}();c(285);var v=function(c){function g(a){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var e=(g.__proto__||Object.getPrototypeOf(g)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.element=document.createElement("div");e.parentDisposers=new Map;e.disabledValue=!1;e.opened=new f.a;e.closed=new f.a;var d=e.element;d.className="neuroglancer-context-menu";d.style.visibility="hidden";d.tabIndex=-1;document.body.appendChild(d);void 0!==a&&e.registerParent(a);return e}u(g,c);l(g,[{key:"registerParent",value:function(a){var e=this,d=this.parentDisposers;d.has(a)||d.set(a,Object(q.c)(a,"contextmenu",function(a){e.show(a);a.stopPropagation();
a.preventDefault()}))}},{key:"show",value:function(a){var e=this;if(!this.disabledValue){this.hide();var d=this.element,b=Object(q.c)(document,"mousedown",function(a){a.target instanceof Node&&!d.contains(a.target)&&e.hide()},!0),f=Object(q.c)(document,"keydown",function(a){"Escape"===a.code&&e.hide()},!0);d.style.display=null;d.style.visibility="hidden";this.opened.dispatch();n(d,a);this.menuDisposer=function(){f();b();d.style.display="none"}}}},{key:"unregisterParent",value:function(a){var e=this.parentDisposers,
d=e.get(a);void 0!==d&&(d(),e.delete(a))}},{key:"disposed",value:function(){for(var f=this.parentDisposers,e=$jscomp.makeIterator(f.values()),d=e.next();!d.done;d=e.next())d=d.value,d();f.clear();Object(a.b)(this.element)}},{key:"hide",value:function(){void 0!==this.menuDisposer&&(this.menuDisposer(),this.menuDisposer=void 0,this.closed.dispatch())}},{key:"disabled",get:function(){return this.disabledValue},set:function(a){this.disabledValue!==a&&(this.disabledValue=a)&&this.hide()}},{key:"open",
get:function(){return void 0!==this.menuDisposer}}]);return g}(q.a)},function(p,g,c){g.a=function(c,a){var f=Object(u.c)(c,"drop",function(f){f.preventDefault();if(-1!==f.dataTransfer.types.indexOf(n.d)){var c=JSON.parse(f.dataTransfer.getData(n.d));a.restoreState(c);f.stopPropagation()}}),g=Object(u.c)(c,"dragover",function(a){-1!==a.dataTransfer.types.indexOf(n.d)&&(a.dataTransfer.dropEffect="link",a.preventDefault(),a.stopPropagation())});return function(){g();f()}};var u=c(0),n=c(97)},function(p,
g,c){(function(c){function g(f,g,t,m){function k(a){var b=e(f,g);if(!b||b.to.line-b.from.line<d)return null;for(var c=f.findMarksAt(b.from),h=0;h<c.length;++h)if(c[h].__isFold&&"fold"!==m){if(!a)return null;b.cleared=!0;c[h].clear()}return b}if(t&&t.call){var e=t;t=null}else e=a(f,t,"rangeFinder");"number"==typeof g&&(g=c.Pos(g,0));var d=a(f,t,"minFoldSize"),b=k(!0);if(a(f,t,"scanUp"))for(;!b&&g.line>f.firstLine();)g=c.Pos(g.line-1,0),b=k(!1);if(b&&!b.cleared&&"unfold"!==m){var h=q(f,t);c.on(h,"mousedown",
function(a){l.clear();c.e_preventDefault(a)});var l=f.markText(b.from,b.to,{replacedWith:h,clearOnEnter:a(f,t,"clearOnEnter"),__isFold:!0});l.on("clear",function(a,b){c.signal(f,"unfold",f,a,b)});c.signal(f,"fold",f,b.from,b.to)}}function q(f,c){f=a(f,c,"widget");"string"==typeof f?(c=document.createTextNode(f),f=document.createElement("span"),f.appendChild(c),f.className="CodeMirror-foldmarker"):f&&(f=f.cloneNode(!0));return f}function a(a,c,g){return c&&void 0!==c[g]?c[g]:(a=a.options.foldOptions)&&
void 0!==a[g]?a[g]:f[g]}c.newFoldFunction=function(a,f){return function(c,l){g(c,l,{rangeFinder:a,widget:f})}};c.defineExtension("foldCode",function(a,f,c){g(this,a,f,c)});c.defineExtension("isFolded",function(a){a=this.findMarksAt(a);for(var f=0;f<a.length;++f)if(a[f].__isFold)return!0});c.commands.toggleFold=function(a){a.foldCode(a.getCursor())};c.commands.fold=function(a){a.foldCode(a.getCursor(),null,"fold")};c.commands.unfold=function(a){a.foldCode(a.getCursor(),null,"unfold")};c.commands.foldAll=
function(a){a.operation(function(){for(var f=a.firstLine(),g=a.lastLine();f<=g;f++)a.foldCode(c.Pos(f,0),null,"fold")})};c.commands.unfoldAll=function(a){a.operation(function(){for(var f=a.firstLine(),g=a.lastLine();f<=g;f++)a.foldCode(c.Pos(f,0),null,"unfold")})};c.registerHelper("fold","combine",function(){var a=Array.prototype.slice.call(arguments,0);return function(f,c){for(var g=0;g<a.length;++g){var k=a[g](f,c);if(k)return k}}});c.registerHelper("fold","auto",function(a,f){for(var c=a.getHelpers(f,
"fold"),g=0;g<c.length;g++){var k=c[g](a,f);if(k)return k}});var f={rangeFinder:c.fold.auto,widget:"\u2194",minFoldSize:0,scanUp:!1,clearOnEnter:!0};c.defineOption("foldOptions",null);c.defineExtension("foldOption",function(f,c){return a(this,f,c)})})(c(42))},function(p,g,c){(function(g){function n(e){e=e||g.location||{};var d={},b=typeof e,f;if("blob:"===e.protocol)d=new a(unescape(e.pathname),{});else if("string"===b)for(f in d=new a(e,{}),k)delete d[f];else if("object"===b){for(f in e)f in k||
(d[f]=e[f]);void 0===d.slashes&&(d.slashes=t.test(e.href))}return d}function q(a){a=v.exec(a);return{protocol:a[1]?a[1].toLowerCase():"",slashes:!!a[2],rest:a[3]}}function a(e,d,b){if(!(this instanceof a))return new a(e,d,b);var c=m.slice();var k=typeof d;var g=0;"object"!==k&&"string"!==k&&(b=d,d=null);b&&"function"!==typeof b&&(b=l.parse);d=n(d);var t=q(e||"");k=!t.protocol&&!t.slashes;this.slashes=t.slashes||k&&d.slashes;this.protocol=t.protocol||d.protocol||"";e=t.rest;for(t.slashes||(c[2]=[/(.*)/,
"pathname"]);g<c.length;g++){t=c[g];var v=t[0];var p=t[1];if(v!==v)this[p]=e;else if("string"===typeof v)~(v=e.indexOf(v))&&("number"===typeof t[2]?(this[p]=e.slice(0,v),e=e.slice(v+t[2])):(this[p]=e.slice(v),e=e.slice(0,v)));else if(v=v.exec(e))this[p]=v[1],e=e.slice(0,v.index);this[p]=this[p]||(k&&t[3]?d[p]||"":"");t[4]&&(this[p]=this[p].toLowerCase())}b&&(this.query=b(this.query));if(k&&d.slashes&&"/"!==this.pathname.charAt(0)&&(""!==this.pathname||""!==d.pathname)){e=this.pathname;d=(d.pathname||
"/").split("/").slice(0,-1).concat(e.split("/"));e=d.length;b=d[e-1];c=!1;for(g=0;e--;)"."===d[e]?d.splice(e,1):".."===d[e]?(d.splice(e,1),g++):g&&(0===e&&(c=!0),d.splice(e,1),g--);c&&d.unshift("");"."!==b&&".."!==b||d.push("");this.pathname=d.join("/")}f(this.port,this.protocol)||(this.host=this.hostname,this.port="");this.username=this.password="";this.auth&&(t=this.auth.split(":"),this.username=t[0]||"",this.password=t[1]||"");this.origin=this.protocol&&this.host&&"file:"!==this.protocol?this.protocol+
"//"+this.host:"null";this.href=this.toString()}var f=c(314),l=c(315),v=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,t=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,m=[["#","hash"],["?","query"],["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],k={hash:1,query:1};a.prototype={set:function(a,d,b){switch(a){case "query":"string"===typeof d&&d.length&&(d=(b||l.parse)(d));this[a]=d;break;case "port":this[a]=d;f(d,this.protocol)?d&&(this.host=this.hostname+
":"+d):(this.host=this.hostname,this[a]="");break;case "hostname":this[a]=d;this.port&&(d+=":"+this.port);this.host=d;break;case "host":this[a]=d;/:\d+$/.test(d)?(d=d.split(":"),this.port=d.pop(),this.hostname=d.join(":")):(this.hostname=d,this.port="");break;case "protocol":this.protocol=d.toLowerCase();this.slashes=!b;break;case "pathname":this.pathname=d.length&&"/"!==d.charAt(0)?"/"+d:d;break;default:this[a]=d}for(a=0;a<m.length;a++)d=m[a],d[4]&&(this[d[1]]=this[d[1]].toLowerCase());this.origin=
this.protocol&&this.host&&"file:"!==this.protocol?this.protocol+"//"+this.host:"null";this.href=this.toString();return this},toString:function(a){a&&"function"===typeof a||(a=l.stringify);var d=this.protocol;d&&":"!==d.charAt(d.length-1)&&(d+=":");d+=this.slashes?"//":"";this.username&&(d+=this.username,this.password&&(d+=":"+this.password),d+="@");d+=this.host+this.pathname;(a="object"===typeof this.query?a(this.query):this.query)&&(d+="?"!==a.charAt(0)?"?"+a:a);this.hash&&(d+=this.hash);return d}};
a.extractProtocol=q;a.location=n;a.qs=l;p.exports=a}).call(g,c(7))},function(p,g,c){function u(){this._listeners={}}u.prototype.addEventListener=function(c,g){c in this._listeners||(this._listeners[c]=[]);var a=this._listeners[c];-1===a.indexOf(g)&&(a=a.concat([g]));this._listeners[c]=a};u.prototype.removeEventListener=function(c,g){var a=this._listeners[c];a&&(g=a.indexOf(g),-1!==g&&(1<a.length?this._listeners[c]=a.slice(0,g).concat(a.slice(g+1)):delete this._listeners[c]))};u.prototype.dispatchEvent=
function(){var c=arguments[0],g=c.type;c=1===arguments.length?[c]:Array.apply(null,arguments);this["on"+g]&&this["on"+g].apply(this,c);if(g in this._listeners){g=this._listeners[g];for(var a=0;a<g.length;a++)g[a].apply(this,c)}};p.exports=u},function(p,g,c){(function(g){function n(c,g,k,e,d){g=a.addPath(c,g);v(g);var b=this;f.call(this,c,k);this.poll=new l(e,g,d);this.poll.on("message",function(a){v("poll message",a);b.emit("message",a)});this.poll.once("close",function(a,d){v("poll close",a,d);b.poll=
null;b.emit("close",a,d);b.close()})}var q=c(4),a=c(21),f=c(320),l=c(321),v=function(){};"production"!==g.env.NODE_ENV&&(v=c(9)("sockjs-client:sender-receiver"));q(n,f);n.prototype.close=function(){f.prototype.close.call(this);v("close");this.removeAllListeners();this.poll&&(this.poll.abort(),this.poll=null)};p.exports=n}).call(g,c(8))},function(p,g,c){(function(g,n){function q(e,d,b,f){m(e,d);var c=this;a.call(this);setTimeout(function(){c._start(e,d,b,f)},0)}var a=c(13).EventEmitter,f=c(4),l=c(38),
v=c(21),t=g.XMLHttpRequest,m=function(){};"production"!==n.env.NODE_ENV&&(m=c(9)("sockjs-client:browser:xhr"));f(q,a);q.prototype._start=function(a,d,b,f){var e=this;try{this.xhr=new t}catch(z){}if(this.xhr){d=v.addQuery(d,"t="+ +new Date);this.unloadRef=l.unloadAdd(function(){m("unload cleanup");e._cleanup(!0)});try{this.xhr.open(a,d,!0),this.timeout&&"timeout"in this.xhr&&(this.xhr.timeout=this.timeout,this.xhr.ontimeout=function(){m("xhr timeout");e.emit("finish",0,"");e._cleanup(!1)})}catch(z){m("exception",
z);this.emit("finish",0,"");this._cleanup(!1);return}f&&f.noCredentials||!q.supportsCORS||(m("withCredentials"),this.xhr.withCredentials="true");if(f&&f.headers)for(var c in f.headers)this.xhr.setRequestHeader(c,f.headers[c]);this.xhr.onreadystatechange=function(){if(e.xhr){var a=e.xhr;m("readyState",a.readyState);switch(a.readyState){case 3:try{var b=a.status;var d=a.responseText}catch(y){}m("status",b);1223===b&&(b=204);200===b&&d&&0<d.length&&(m("chunk"),e.emit("chunk",b,d));break;case 4:b=a.status;
m("status",b);1223===b&&(b=204);if(12005===b||12029===b)b=0;m("finish",b,a.responseText);e.emit("finish",b,a.responseText);e._cleanup(!1)}}};try{e.xhr.send(b)}catch(z){e.emit("finish",0,""),e._cleanup(!1)}}else m("no xhr"),this.emit("finish",0,"no xhr support"),this._cleanup()};q.prototype._cleanup=function(a){m("cleanup");if(this.xhr){this.removeAllListeners();l.unloadDel(this.unloadRef);this.xhr.onreadystatechange=function(){};this.xhr.ontimeout&&(this.xhr.ontimeout=null);if(a)try{this.xhr.abort()}catch(d){}this.unloadRef=
this.xhr=null}};q.prototype.close=function(){m("close");this._cleanup(!0)};q.enabled=!!t;var k=["Active"].concat("Object").join("X");!q.enabled&&k in g&&(m("overriding xmlhttprequest"),t=function(){try{return new g[k]("Microsoft.XMLHTTP")}catch(e){return null}},q.enabled=!!new t);n=!1;try{n="withCredentials"in new t}catch(e){}q.supportsCORS=n;p.exports=q}).call(g,c(7),c(8))},function(p,g,c){function u(f){if(!a.enabled)throw Error("Transport created when disabled");n.call(this,f,"/xhr_streaming",q,
a)}g=c(4);var n=c(49),q=c(69),a=c(98);g(u,n);u.enabled=function(f){return f.cookie_needed||f.nullOrigin?!1:a.enabled&&f.sameScheme};u.transportName="xdr-streaming";u.roundTrips=2;p.exports=u},function(p,g,c){function u(f){if(!u.enabled())throw Error("Transport created when disabled");n.call(this,f,"/eventsource",q,a)}g=c(4);var n=c(49),q=c(322),a=c(70),f=c(164);g(u,n);u.enabled=function(){return!!f};u.transportName="eventsource";u.roundTrips=2;p.exports=u},function(p,g,c){g=c(7);p.exports=g.EventSource},
function(p,g,c){(function(g){function n(a,b,c){if(!n.enabled())throw Error("Transport created when disabled");f.call(this);var d=this;this.origin=v.getOrigin(c);this.baseUrl=c;this.transUrl=b;this.transport=a;this.windowId=k.string(8);c=v.addPath(c,"/iframe.html")+"#"+this.windowId;e(a,b,c);this.iframeObj=t.createIframe(c,function(a){e("err callback");d.emit("close",1006,"Unable to load an iframe ("+a+")");d.close()});this.onmessageCallback=this._message.bind(this);m.attachEvent("message",this.onmessageCallback)}
var q=c(4),a=c(33),f=c(13).EventEmitter,l=c(166),v=c(21),t=c(61),m=c(38),k=c(48),e=function(){};"production"!==g.env.NODE_ENV&&(e=c(9)("sockjs-client:transport:iframe"));q(n,f);n.prototype.close=function(){e("close");this.removeAllListeners();if(this.iframeObj){m.detachEvent("message",this.onmessageCallback);try{this.postMessage("c")}catch(d){}this.iframeObj.cleanup();this.onmessageCallback=this.iframeObj=this.iframeObj=null}};n.prototype._message=function(d){e("message",d.data);if(v.isOriginEqual(d.origin,
this.origin)){try{var b=a.parse(d.data)}catch(r){e("bad json",d.data);return}if(b.windowId!==this.windowId)e("mismatched window id",b.windowId,this.windowId);else switch(b.type){case "s":this.iframeObj.loaded();this.postMessage("s",a.stringify([l,this.transport,this.transUrl,this.baseUrl]));break;case "t":this.emit("message",b.data);break;case "c":try{var f=a.parse(b.data)}catch(r){e("bad json",b.data);break}this.emit("close",f[0],f[1]);this.close()}}else e("not same origin",d.origin,this.origin)};
n.prototype.postMessage=function(d,b){e("postMessage",d,b);this.iframeObj.post(a.stringify({windowId:this.windowId,type:d,data:b||""}),this.origin)};n.prototype.send=function(a){e("send",a);this.postMessage("m",a)};n.enabled=function(){return t.iframeEnabled};n.transportName="iframe";n.roundTrips=2;p.exports=n}).call(g,c(8))},function(p,g){p.exports="1.1.4"},function(p,g,c){function u(f){if(!n.enabled)throw Error("Transport created when disabled");a.call(this,f,"/htmlfile",n,q)}g=c(4);var n=c(325),
q=c(59),a=c(49);g(u,a);u.enabled=function(a){return n.enabled&&a.sameOrigin};u.transportName="htmlfile";u.roundTrips=2;p.exports=u},function(p,g,c){function u(c){if(!f.enabled&&!a.enabled)throw Error("Transport created when disabled");n.call(this,c,"/xhr",q,a)}g=c(4);var n=c(49),q=c(69),a=c(70),f=c(59);g(u,n);u.enabled=function(c){return c.nullOrigin?!1:f.enabled&&c.sameOrigin?!0:a.enabled};u.transportName="xhr-polling";u.roundTrips=2;p.exports=u},function(p,g,c){g=c(7);p.exports=g.location||{origin:"http://localhost:80",
protocol:"http",host:"localhost",port:80,href:"http://localhost/",hash:""}},function(p,g,c){function u(c){var g=this;n.call(this);this.ir=new f(c,a);this.ir.once("finish",function(a,f){g.ir=null;g.emit("message",q.stringify([a,f]))})}g=c(4);var n=c(13).EventEmitter,q=c(33),a=c(59),f=c(171);g(u,n);u.transportName="iframe-info-receiver";u.prototype.close=function(){this.ir&&(this.ir.close(),this.ir=null);this.removeAllListeners()};p.exports=u},function(p,g,c){(function(g){function n(a,c){q.call(this);
var k=this,e=+new Date;this.xo=new c("GET",a);this.xo.once("finish",function(a,b){if(200===a){var d=+new Date-e;if(b)try{var c=f.parse(b)}catch(x){v("bad json",b)}l.isObject(c)||(c={})}k.emit("finish",c,d);k.removeAllListeners()})}var q=c(13).EventEmitter,a=c(4),f=c(33),l=c(100),v=function(){};"production"!==g.env.NODE_ENV&&(v=c(9)("sockjs-client:info-ajax"));a(n,q);n.prototype.close=function(){this.removeAllListeners();this.xo.close()};p.exports=n}).call(g,c(8))},function(p,g,c){function u(a,e){if(!(a instanceof
e))throw new TypeError("Cannot call a class as a function");}function n(a,e){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==typeof e&&"function"!==typeof e?a:e}function q(a,e){if("function"!==typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
e):a.__proto__=e)}c.d(g,"a",function(){return t});c.d(g,"b",function(){return m});p=c(28);c=c(0);var a=function e(a,b,f){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return e(a,b,f)}else{if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(f)}},f=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,
e.key,e)}}return function(d,b,e){b&&a(d.prototype,b);e&&a(d,e);return d}}();$jscomp.initSymbol();var l=Symbol("SingleTextureVolumeChunk.textureUnit");$jscomp.initSymbol();var v=Symbol("SingleTextureVolumeChunk.textureLayout"),t=function(a){function d(a){u(this,d);var b=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));b.shaderKey=a;return b}q(d,a);f(d,[{key:"defineShader",value:function(a){a.addTextureSampler2D("uVolumeChunkSampler",l)}},{key:"beginDrawing",value:function(a,d){var b=d.textureUnit(l);
a.activeTexture(a.TEXTURE0+b);d[v]=null}},{key:"endDrawing",value:function(a,d){a.bindTexture(a.TEXTURE_2D,null);d[v]=null}},{key:"bindChunk",value:function(a,d,e){var b=e.textureLayout;d[v]!==b&&(d[v]=b,this.setupTextureLayout(a,d,b));a.bindTexture(a.TEXTURE_2D,e.texture)}},{key:"beginSource",value:function(a,d){}}]);return d}(c.a),m=function(e){function d(a,e){u(this,d);a=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,a,e));a.texture=null;a.data=e.data;return a}q(d,e);f(d,[{key:"copyToGPU",
value:function(b){a(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"copyToGPU",this).call(this,b);var e=this.texture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e);this.setTextureData(b);b.bindTexture(b.TEXTURE_2D,null)}},{key:"freeGPUMemory",value:function(b){a(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"freeGPUMemory",this).call(this,b);b.deleteTexture(this.texture);this.texture=null;this.textureLayout.dispose();this.textureLayout=null}}]);return d}(p.a)},function(p,g,
c){g.a=function(c,g,q,a,f,l){for(var n=0,t=0,m=1,k=1,e=0;3>e;++e){var d=f[e],b=a[e],h=d%b;n+=Math.floor(d/b)*m;m*=Math.ceil(q[e]/b);t+=h*k;k*=b}a=g+2*n;q=c[a];a=c[a+1];f=q&16777215;q=q>>24&255;0<q&&(f+=l*(c[(g+a&16777215)+Math.floor(t*q/32)]>>t*q%32&(1<<q)-1));return f}},function(p,g,c){c(102);c(215);c(84);c(216);c(125);c(218);c(126);c(220);c(129);c(221);c(130);c(223);c(131);c(225);c(226);c(227);c(132);c(229);c(241);c(245);c(255);c(259);p.exports=c(262)},function(p,g,c){c(30)},function(p,g,c){c(30)},
function(p,g,c){function u(a,f,c){var g=f[0],l=f[1],m=f[2],k=f[3],e=f[4],d=f[5],b=f[6],h=f[7],r=f[8],n=f[9],q=f[10],p=f[11],u=f[12],y=f[13],E=f[14];f=f[15];var G=c[0],H=c[1],B=c[2],C=c[3];a[0]=G*g+H*e+B*r+C*u;a[1]=G*l+H*d+B*n+C*y;a[2]=G*m+H*b+B*q+C*E;a[3]=G*k+H*h+B*p+C*f;G=c[4];H=c[5];B=c[6];C=c[7];a[4]=G*g+H*e+B*r+C*u;a[5]=G*l+H*d+B*n+C*y;a[6]=G*m+H*b+B*q+C*E;a[7]=G*k+H*h+B*p+C*f;G=c[8];H=c[9];B=c[10];C=c[11];a[8]=G*g+H*e+B*r+C*u;a[9]=G*l+H*d+B*n+C*y;a[10]=G*m+H*b+B*q+C*E;a[11]=G*k+H*h+B*p+C*f;G=
c[12];H=c[13];B=c[14];C=c[15];a[12]=G*g+H*e+B*r+C*u;a[13]=G*l+H*d+B*n+C*y;a[14]=G*m+H*b+B*q+C*E;a[15]=G*k+H*h+B*p+C*f;return a}function n(a,f,c){a[0]=f[0]-c[0];a[1]=f[1]-c[1];a[2]=f[2]-c[2];a[3]=f[3]-c[3];a[4]=f[4]-c[4];a[5]=f[5]-c[5];a[6]=f[6]-c[6];a[7]=f[7]-c[7];a[8]=f[8]-c[8];a[9]=f[9]-c[9];a[10]=f[10]-c[10];a[11]=f[11]-c[11];a[12]=f[12]-c[12];a[13]=f[13]-c[13];a[14]=f[14]-c[14];a[15]=f[15]-c[15];return a}Object.defineProperty(g,"__esModule",{value:!0});g.create=function(){var a=new q.a(16);a[0]=
1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.clone=function(a){var f=new q.a(16);f[0]=a[0];f[1]=a[1];f[2]=a[2];f[3]=a[3];f[4]=a[4];f[5]=a[5];f[6]=a[6];f[7]=a[7];f[8]=a[8];f[9]=a[9];f[10]=a[10];f[11]=a[11];f[12]=a[12];f[13]=a[13];f[14]=a[14];f[15]=a[15];return f};g.copy=function(a,f){a[0]=f[0];a[1]=f[1];a[2]=f[2];a[3]=f[3];a[4]=f[4];a[5]=f[5];a[6]=f[6];a[7]=f[7];a[8]=f[8];a[9]=f[9];a[10]=f[10];a[11]=f[11];a[12]=f[12];a[13]=
f[13];a[14]=f[14];a[15]=f[15];return a};g.fromValues=function(a,f,c,g,t,m,k,e,d,b,h,r,n,p,u,D){var l=new q.a(16);l[0]=a;l[1]=f;l[2]=c;l[3]=g;l[4]=t;l[5]=m;l[6]=k;l[7]=e;l[8]=d;l[9]=b;l[10]=h;l[11]=r;l[12]=n;l[13]=p;l[14]=u;l[15]=D;return l};g.set=function(a,f,c,g,t,m,k,e,d,b,h,r,n,q,p,u,y){a[0]=f;a[1]=c;a[2]=g;a[3]=t;a[4]=m;a[5]=k;a[6]=e;a[7]=d;a[8]=b;a[9]=h;a[10]=r;a[11]=n;a[12]=q;a[13]=p;a[14]=u;a[15]=y;return a};g.identity=function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=
0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.transpose=function(a,f){if(a===f){var c=f[1],g=f[2],t=f[3],m=f[6],k=f[7],e=f[11];a[1]=f[4];a[2]=f[8];a[3]=f[12];a[4]=c;a[6]=f[9];a[7]=f[13];a[8]=g;a[9]=m;a[11]=f[14];a[12]=t;a[13]=k;a[14]=e}else a[0]=f[0],a[1]=f[4],a[2]=f[8],a[3]=f[12],a[4]=f[1],a[5]=f[5],a[6]=f[9],a[7]=f[13],a[8]=f[2],a[9]=f[6],a[10]=f[10],a[11]=f[14],a[12]=f[3],a[13]=f[7],a[14]=f[11],a[15]=f[15];return a};g.invert=function(a,f){var c=f[0],g=f[1],t=f[2],m=f[3],
k=f[4],e=f[5],d=f[6],b=f[7],h=f[8],r=f[9],n=f[10],q=f[11],p=f[12],u=f[13],y=f[14];f=f[15];var E=c*e-g*k,G=c*d-t*k,H=c*b-m*k,B=g*d-t*e,C=g*b-m*e,F=t*b-m*d,M=h*u-r*p,I=h*y-n*p,P=h*f-q*p,N=r*y-n*u,U=r*f-q*u,O=n*f-q*y,T=E*O-G*U+H*N+B*P-C*I+F*M;if(!T)return null;T=1/T;a[0]=(e*O-d*U+b*N)*T;a[1]=(t*U-g*O-m*N)*T;a[2]=(u*F-y*C+f*B)*T;a[3]=(n*C-r*F-q*B)*T;a[4]=(d*P-k*O-b*I)*T;a[5]=(c*O-t*P+m*I)*T;a[6]=(y*H-p*F-f*G)*T;a[7]=(h*F-n*H+q*G)*T;a[8]=(k*U-e*P+b*M)*T;a[9]=(g*P-c*U-m*M)*T;a[10]=(p*C-u*H+f*E)*T;a[11]=
(r*H-h*C-q*E)*T;a[12]=(e*I-k*N-d*M)*T;a[13]=(c*N-g*I+t*M)*T;a[14]=(u*G-p*B-y*E)*T;a[15]=(h*B-r*G+n*E)*T;return a};g.adjoint=function(a,f){var c=f[0],g=f[1],t=f[2],m=f[3],k=f[4],e=f[5],d=f[6],b=f[7],h=f[8],r=f[9],n=f[10],q=f[11],p=f[12],u=f[13],y=f[14];f=f[15];a[0]=e*(n*f-q*y)-r*(d*f-b*y)+u*(d*q-b*n);a[1]=-(g*(n*f-q*y)-r*(t*f-m*y)+u*(t*q-m*n));a[2]=g*(d*f-b*y)-e*(t*f-m*y)+u*(t*b-m*d);a[3]=-(g*(d*q-b*n)-e*(t*q-m*n)+r*(t*b-m*d));a[4]=-(k*(n*f-q*y)-h*(d*f-b*y)+p*(d*q-b*n));a[5]=c*(n*f-q*y)-h*(t*f-m*y)+
p*(t*q-m*n);a[6]=-(c*(d*f-b*y)-k*(t*f-m*y)+p*(t*b-m*d));a[7]=c*(d*q-b*n)-k*(t*q-m*n)+h*(t*b-m*d);a[8]=k*(r*f-q*u)-h*(e*f-b*u)+p*(e*q-b*r);a[9]=-(c*(r*f-q*u)-h*(g*f-m*u)+p*(g*q-m*r));a[10]=c*(e*f-b*u)-k*(g*f-m*u)+p*(g*b-m*e);a[11]=-(c*(e*q-b*r)-k*(g*q-m*r)+h*(g*b-m*e));a[12]=-(k*(r*y-n*u)-h*(e*y-d*u)+p*(e*n-d*r));a[13]=c*(r*y-n*u)-h*(g*y-t*u)+p*(g*n-t*r);a[14]=-(c*(e*y-d*u)-k*(g*y-t*u)+p*(g*d-t*e));a[15]=c*(e*n-d*r)-k*(g*n-t*r)+h*(g*d-t*e);return a};g.determinant=function(a){var f=a[0],c=a[1],g=a[2],
t=a[3],m=a[4],k=a[5],e=a[6],d=a[7],b=a[8],h=a[9],r=a[10],n=a[11],q=a[12],p=a[13],u=a[14];a=a[15];return(f*k-c*m)*(r*a-n*u)-(f*e-g*m)*(h*a-n*p)+(f*d-t*m)*(h*u-r*p)+(c*e-g*k)*(b*a-n*q)-(c*d-t*k)*(b*u-r*q)+(g*d-t*e)*(b*p-h*q)};g.multiply=u;g.translate=function(a,f,c){var g=c[0],l=c[1];c=c[2];if(f===a)a[12]=f[0]*g+f[4]*l+f[8]*c+f[12],a[13]=f[1]*g+f[5]*l+f[9]*c+f[13],a[14]=f[2]*g+f[6]*l+f[10]*c+f[14],a[15]=f[3]*g+f[7]*l+f[11]*c+f[15];else{var m=f[0];var k=f[1];var e=f[2];var d=f[3];var b=f[4];var h=f[5];
var r=f[6];var n=f[7];var q=f[8];var p=f[9];var u=f[10];var y=f[11];a[0]=m;a[1]=k;a[2]=e;a[3]=d;a[4]=b;a[5]=h;a[6]=r;a[7]=n;a[8]=q;a[9]=p;a[10]=u;a[11]=y;a[12]=m*g+b*l+q*c+f[12];a[13]=k*g+h*l+p*c+f[13];a[14]=e*g+r*l+u*c+f[14];a[15]=d*g+n*l+y*c+f[15]}return a};g.scale=function(a,f,c){var g=c[0],l=c[1];c=c[2];a[0]=f[0]*g;a[1]=f[1]*g;a[2]=f[2]*g;a[3]=f[3]*g;a[4]=f[4]*l;a[5]=f[5]*l;a[6]=f[6]*l;a[7]=f[7]*l;a[8]=f[8]*c;a[9]=f[9]*c;a[10]=f[10]*c;a[11]=f[11]*c;a[12]=f[12];a[13]=f[13];a[14]=f[14];a[15]=f[15];
return a};g.rotate=function(a,f,c,g){var l=g[0],m=g[1];g=g[2];var k=Math.sqrt(l*l+m*m+g*g);if(Math.abs(k)<q.b)return null;k=1/k;l*=k;m*=k;g*=k;var e=Math.sin(c);var d=Math.cos(c);var b=1-d;c=f[0];k=f[1];var h=f[2];var r=f[3];var n=f[4];var v=f[5];var p=f[6];var u=f[7];var y=f[8];var E=f[9];var G=f[10];var H=f[11];var B=l*l*b+d;var C=m*l*b+g*e;var F=g*l*b-m*e;var M=l*m*b-g*e;var I=m*m*b+d;var P=g*m*b+l*e;var N=l*g*b+m*e;l=m*g*b-l*e;m=g*g*b+d;a[0]=c*B+n*C+y*F;a[1]=k*B+v*C+E*F;a[2]=h*B+p*C+G*F;a[3]=
r*B+u*C+H*F;a[4]=c*M+n*I+y*P;a[5]=k*M+v*I+E*P;a[6]=h*M+p*I+G*P;a[7]=r*M+u*I+H*P;a[8]=c*N+n*l+y*m;a[9]=k*N+v*l+E*m;a[10]=h*N+p*l+G*m;a[11]=r*N+u*l+H*m;f!==a&&(a[12]=f[12],a[13]=f[13],a[14]=f[14],a[15]=f[15]);return a};g.rotateX=function(a,f,c){var g=Math.sin(c);c=Math.cos(c);var l=f[4],m=f[5],k=f[6],e=f[7],d=f[8],b=f[9],h=f[10],r=f[11];f!==a&&(a[0]=f[0],a[1]=f[1],a[2]=f[2],a[3]=f[3],a[12]=f[12],a[13]=f[13],a[14]=f[14],a[15]=f[15]);a[4]=l*c+d*g;a[5]=m*c+b*g;a[6]=k*c+h*g;a[7]=e*c+r*g;a[8]=d*c-l*g;a[9]=
b*c-m*g;a[10]=h*c-k*g;a[11]=r*c-e*g;return a};g.rotateY=function(a,f,c){var g=Math.sin(c);c=Math.cos(c);var l=f[0],m=f[1],k=f[2],e=f[3],d=f[8],b=f[9],h=f[10],r=f[11];f!==a&&(a[4]=f[4],a[5]=f[5],a[6]=f[6],a[7]=f[7],a[12]=f[12],a[13]=f[13],a[14]=f[14],a[15]=f[15]);a[0]=l*c-d*g;a[1]=m*c-b*g;a[2]=k*c-h*g;a[3]=e*c-r*g;a[8]=l*g+d*c;a[9]=m*g+b*c;a[10]=k*g+h*c;a[11]=e*g+r*c;return a};g.rotateZ=function(a,f,c){var g=Math.sin(c);c=Math.cos(c);var l=f[0],m=f[1],k=f[2],e=f[3],d=f[4],b=f[5],h=f[6],r=f[7];f!==
a&&(a[8]=f[8],a[9]=f[9],a[10]=f[10],a[11]=f[11],a[12]=f[12],a[13]=f[13],a[14]=f[14],a[15]=f[15]);a[0]=l*c+d*g;a[1]=m*c+b*g;a[2]=k*c+h*g;a[3]=e*c+r*g;a[4]=d*c-l*g;a[5]=b*c-m*g;a[6]=h*c-k*g;a[7]=r*c-e*g;return a};g.fromTranslation=function(a,f){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=f[0];a[13]=f[1];a[14]=f[2];a[15]=1;return a};g.fromScaling=function(a,f){a[0]=f[0];a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=f[1];a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=f[2];a[11]=
0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.fromRotation=function(a,f,c){var g=c[0],l=c[1];c=c[2];var m=Math.sqrt(g*g+l*l+c*c);if(Math.abs(m)<q.b)return null;m=1/m;g*=m;l*=m;c*=m;m=Math.sin(f);f=Math.cos(f);var k=1-f;a[0]=g*g*k+f;a[1]=l*g*k+c*m;a[2]=c*g*k-l*m;a[3]=0;a[4]=g*l*k-c*m;a[5]=l*l*k+f;a[6]=c*l*k+g*m;a[7]=0;a[8]=g*c*k+l*m;a[9]=l*c*k-g*m;a[10]=c*c*k+f;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.fromXRotation=function(a,f){var c=Math.sin(f);f=Math.cos(f);a[0]=1;a[1]=0;a[2]=0;a[3]=
0;a[4]=0;a[5]=f;a[6]=c;a[7]=0;a[8]=0;a[9]=-c;a[10]=f;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.fromYRotation=function(a,f){var c=Math.sin(f);f=Math.cos(f);a[0]=f;a[1]=0;a[2]=-c;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=c;a[9]=0;a[10]=f;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.fromZRotation=function(a,f){var c=Math.sin(f);f=Math.cos(f);a[0]=f;a[1]=c;a[2]=0;a[3]=0;a[4]=-c;a[5]=f;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.fromRotationTranslation=
function(a,f,c){var g=f[0],l=f[1],m=f[2],k=f[3],e=g+g,d=l+l,b=m+m;f=g*e;var h=g*d;g*=b;var r=l*d;l*=b;m*=b;e*=k;d*=k;k*=b;a[0]=1-(r+m);a[1]=h+k;a[2]=g-d;a[3]=0;a[4]=h-k;a[5]=1-(f+m);a[6]=l+e;a[7]=0;a[8]=g+d;a[9]=l-e;a[10]=1-(f+r);a[11]=0;a[12]=c[0];a[13]=c[1];a[14]=c[2];a[15]=1;return a};g.getTranslation=function(a,f){a[0]=f[12];a[1]=f[13];a[2]=f[14];return a};g.getScaling=function(a,f){var c=f[0],g=f[1],t=f[2],m=f[4],k=f[5],e=f[6],d=f[8],b=f[9];f=f[10];a[0]=Math.sqrt(c*c+g*g+t*t);a[1]=Math.sqrt(m*
m+k*k+e*e);a[2]=Math.sqrt(d*d+b*b+f*f);return a};g.getRotation=function(a,f){var c=f[0]+f[5]+f[10];0<c?(c=2*Math.sqrt(c+1),a[3]=.25*c,a[0]=(f[6]-f[9])/c,a[1]=(f[8]-f[2])/c,a[2]=(f[1]-f[4])/c):f[0]>f[5]&f[0]>f[10]?(c=2*Math.sqrt(1+f[0]-f[5]-f[10]),a[3]=(f[6]-f[9])/c,a[0]=.25*c,a[1]=(f[1]+f[4])/c,a[2]=(f[8]+f[2])/c):f[5]>f[10]?(c=2*Math.sqrt(1+f[5]-f[0]-f[10]),a[3]=(f[8]-f[2])/c,a[0]=(f[1]+f[4])/c,a[1]=.25*c,a[2]=(f[6]+f[9])/c):(c=2*Math.sqrt(1+f[10]-f[0]-f[5]),a[3]=(f[1]-f[4])/c,a[0]=(f[8]+f[2])/c,
a[1]=(f[6]+f[9])/c,a[2]=.25*c);return a};g.fromRotationTranslationScale=function(a,f,c,g){var l=f[0],m=f[1],k=f[2],e=f[3],d=l+l,b=m+m,h=k+k;f=l*d;var r=l*b;l*=h;var n=m*b;m*=h;k*=h;d*=e;b*=e;e*=h;h=g[0];var q=g[1];g=g[2];a[0]=(1-(n+k))*h;a[1]=(r+e)*h;a[2]=(l-b)*h;a[3]=0;a[4]=(r-e)*q;a[5]=(1-(f+k))*q;a[6]=(m+d)*q;a[7]=0;a[8]=(l+b)*g;a[9]=(m-d)*g;a[10]=(1-(f+n))*g;a[11]=0;a[12]=c[0];a[13]=c[1];a[14]=c[2];a[15]=1;return a};g.fromRotationTranslationScaleOrigin=function(a,f,c,g,t){var m=f[0],k=f[1],e=
f[2],d=f[3],b=m+m,h=k+k,l=e+e;f=m*b;var n=m*h;m*=l;var q=k*h;k*=l;e*=l;b*=d;h*=d;d*=l;l=g[0];var p=g[1];g=g[2];var v=t[0],u=t[1];t=t[2];a[0]=(1-(q+e))*l;a[1]=(n+d)*l;a[2]=(m-h)*l;a[3]=0;a[4]=(n-d)*p;a[5]=(1-(f+e))*p;a[6]=(k+b)*p;a[7]=0;a[8]=(m+h)*g;a[9]=(k-b)*g;a[10]=(1-(f+q))*g;a[11]=0;a[12]=c[0]+v-(a[0]*v+a[4]*u+a[8]*t);a[13]=c[1]+u-(a[1]*v+a[5]*u+a[9]*t);a[14]=c[2]+t-(a[2]*v+a[6]*u+a[10]*t);a[15]=1;return a};g.fromQuat=function(a,f){var c=f[0],g=f[1],t=f[2];f=f[3];var m=c+c,k=g+g,e=t+t;c*=m;var d=
g*m;g*=k;var b=t*m,h=t*k;t*=e;m*=f;k*=f;f*=e;a[0]=1-g-t;a[1]=d+f;a[2]=b-k;a[3]=0;a[4]=d-f;a[5]=1-c-t;a[6]=h+m;a[7]=0;a[8]=b+k;a[9]=h-m;a[10]=1-c-g;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};g.frustum=function(a,f,c,g,t,m,k){var e=1/(c-f),d=1/(t-g),b=1/(m-k);a[0]=2*m*e;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=2*m*d;a[6]=0;a[7]=0;a[8]=(c+f)*e;a[9]=(t+g)*d;a[10]=(k+m)*b;a[11]=-1;a[12]=0;a[13]=0;a[14]=k*m*2*b;a[15]=0;return a};g.perspective=function(a,f,c,g,t){f=1/Math.tan(f/2);var m=1/(g-t);a[0]=f/c;
a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=f;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=(t+g)*m;a[11]=-1;a[12]=0;a[13]=0;a[14]=2*t*g*m;a[15]=0;return a};g.perspectiveFromFieldOfView=function(a,f,c,g){var l=Math.tan(f.upDegrees*Math.PI/180),m=Math.tan(f.downDegrees*Math.PI/180),k=Math.tan(f.leftDegrees*Math.PI/180);f=Math.tan(f.rightDegrees*Math.PI/180);var e=2/(k+f),d=2/(l+m);a[0]=e;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=d;a[6]=0;a[7]=0;a[8]=-((k-f)*e*.5);a[9]=(l-m)*d*.5;a[10]=g/(c-g);a[11]=-1;a[12]=0;a[13]=0;a[14]=g*c/(c-
g);a[15]=0;return a};g.ortho=function(a,f,c,g,t,m,k){var e=1/(f-c),d=1/(g-t),b=1/(m-k);a[0]=-2*e;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=-2*d;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2*b;a[11]=0;a[12]=(f+c)*e;a[13]=(t+g)*d;a[14]=(k+m)*b;a[15]=1;return a};g.lookAt=function(a,f,c,g){var l=f[0],m=f[1];f=f[2];var k=g[0];var e=g[1];var d=g[2];var b=c[0];g=c[1];var h=c[2];if(Math.abs(l-b)<q.b&&Math.abs(m-g)<q.b&&Math.abs(f-h)<q.b)return mat4.identity(a);c=l-b;g=m-g;b=f-h;var r=1/Math.sqrt(c*c+g*g+b*b);c*=r;g*=r;b*=r;
h=e*b-d*g;d=d*c-k*b;k=k*g-e*c;(r=Math.sqrt(h*h+d*d+k*k))?(r=1/r,h*=r,d*=r,k*=r):k=d=h=0;e=g*k-b*d;var n=b*h-c*k;var p=c*d-g*h;(r=Math.sqrt(e*e+n*n+p*p))?(r=1/r,e*=r,n*=r,p*=r):p=n=e=0;a[0]=h;a[1]=e;a[2]=c;a[3]=0;a[4]=d;a[5]=n;a[6]=g;a[7]=0;a[8]=k;a[9]=p;a[10]=b;a[11]=0;a[12]=-(h*l+d*m+k*f);a[13]=-(e*l+n*m+p*f);a[14]=-(c*l+g*m+b*f);a[15]=1;return a};g.targetTo=function(a,f,c,g){var l=f[0],m=f[1];f=f[2];var k=g[0],e=g[1],d=g[2];g=l-c[0];var b=m-c[1];c=f-c[2];var h=g*g+b*b+c*c;0<h&&(h=1/Math.sqrt(h),
g*=h,b*=h,c*=h);h=e*c-d*b;d=d*g-k*c;k=k*b-e*g;a[0]=h;a[1]=d;a[2]=k;a[3]=0;a[4]=b*k-c*d;a[5]=c*h-g*k;a[6]=g*d-b*h;a[7]=0;a[8]=g;a[9]=b;a[10]=c;a[11]=0;a[12]=l;a[13]=m;a[14]=f;a[15]=1;return a};g.str=function(a){return"mat4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+")"};g.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],
2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2)+Math.pow(a[9],2)+Math.pow(a[10],2)+Math.pow(a[11],2)+Math.pow(a[12],2)+Math.pow(a[13],2)+Math.pow(a[14],2)+Math.pow(a[15],2))};g.add=function(a,f,c){a[0]=f[0]+c[0];a[1]=f[1]+c[1];a[2]=f[2]+c[2];a[3]=f[3]+c[3];a[4]=f[4]+c[4];a[5]=f[5]+c[5];a[6]=f[6]+c[6];a[7]=f[7]+c[7];a[8]=f[8]+c[8];a[9]=f[9]+c[9];a[10]=f[10]+c[10];a[11]=f[11]+c[11];a[12]=f[12]+c[12];a[13]=f[13]+c[13];a[14]=f[14]+c[14];a[15]=f[15]+c[15];return a};g.subtract=n;
g.multiplyScalar=function(a,c,g){a[0]=c[0]*g;a[1]=c[1]*g;a[2]=c[2]*g;a[3]=c[3]*g;a[4]=c[4]*g;a[5]=c[5]*g;a[6]=c[6]*g;a[7]=c[7]*g;a[8]=c[8]*g;a[9]=c[9]*g;a[10]=c[10]*g;a[11]=c[11]*g;a[12]=c[12]*g;a[13]=c[13]*g;a[14]=c[14]*g;a[15]=c[15]*g;return a};g.multiplyScalarAndAdd=function(a,c,g,n){a[0]=c[0]+g[0]*n;a[1]=c[1]+g[1]*n;a[2]=c[2]+g[2]*n;a[3]=c[3]+g[3]*n;a[4]=c[4]+g[4]*n;a[5]=c[5]+g[5]*n;a[6]=c[6]+g[6]*n;a[7]=c[7]+g[7]*n;a[8]=c[8]+g[8]*n;a[9]=c[9]+g[9]*n;a[10]=c[10]+g[10]*n;a[11]=c[11]+g[11]*n;a[12]=
c[12]+g[12]*n;a[13]=c[13]+g[13]*n;a[14]=c[14]+g[14]*n;a[15]=c[15]+g[15]*n;return a};g.exactEquals=function(a,c){return a[0]===c[0]&&a[1]===c[1]&&a[2]===c[2]&&a[3]===c[3]&&a[4]===c[4]&&a[5]===c[5]&&a[6]===c[6]&&a[7]===c[7]&&a[8]===c[8]&&a[9]===c[9]&&a[10]===c[10]&&a[11]===c[11]&&a[12]===c[12]&&a[13]===c[13]&&a[14]===c[14]&&a[15]===c[15]};g.equals=function(a,c){var f=a[0],g=a[1],t=a[2],m=a[3],k=a[4],e=a[5],d=a[6],b=a[7],h=a[8],r=a[9],n=a[10],p=a[11],u=a[12],D=a[13],y=a[14];a=a[15];var E=c[0],G=c[1],
H=c[2],B=c[3],C=c[4],F=c[5],M=c[6],I=c[7],P=c[8],N=c[9],U=c[10],O=c[11],T=c[12],W=c[13],aa=c[14];c=c[15];return Math.abs(f-E)<=q.b*Math.max(1,Math.abs(f),Math.abs(E))&&Math.abs(g-G)<=q.b*Math.max(1,Math.abs(g),Math.abs(G))&&Math.abs(t-H)<=q.b*Math.max(1,Math.abs(t),Math.abs(H))&&Math.abs(m-B)<=q.b*Math.max(1,Math.abs(m),Math.abs(B))&&Math.abs(k-C)<=q.b*Math.max(1,Math.abs(k),Math.abs(C))&&Math.abs(e-F)<=q.b*Math.max(1,Math.abs(e),Math.abs(F))&&Math.abs(d-M)<=q.b*Math.max(1,Math.abs(d),Math.abs(M))&&
Math.abs(b-I)<=q.b*Math.max(1,Math.abs(b),Math.abs(I))&&Math.abs(h-P)<=q.b*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(r-N)<=q.b*Math.max(1,Math.abs(r),Math.abs(N))&&Math.abs(n-U)<=q.b*Math.max(1,Math.abs(n),Math.abs(U))&&Math.abs(p-O)<=q.b*Math.max(1,Math.abs(p),Math.abs(O))&&Math.abs(u-T)<=q.b*Math.max(1,Math.abs(u),Math.abs(T))&&Math.abs(D-W)<=q.b*Math.max(1,Math.abs(D),Math.abs(W))&&Math.abs(y-aa)<=q.b*Math.max(1,Math.abs(y),Math.abs(aa))&&Math.abs(a-c)<=q.b*Math.max(1,Math.abs(a),Math.abs(c))};
var q=c(30);g.mul=u;g.sub=n},function(p,g,c){function u(){var a=new l.a(4);a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a}function n(a,e,d){d*=.5;var b=Math.sin(d);a[0]=b*e[0];a[1]=b*e[1];a[2]=b*e[2];a[3]=Math.cos(d);return a}function q(a,e,d){var b=e[0],c=e[1],f=e[2];e=e[3];var g=d[0],k=d[1],m=d[2];d=d[3];a[0]=b*d+e*g+c*m-f*k;a[1]=c*d+e*k+f*g-b*m;a[2]=f*d+e*m+b*k-c*g;a[3]=e*d-b*g-c*k-f*m;return a}function a(a,e,d,b){var c=e[0],f=e[1],g=e[2];e=e[3];var k=d[0],m=d[1],l=d[2];d=d[3];var t=c*k+f*m+g*l+e*d;0>t&&
(t=-t,k=-k,m=-m,l=-l,d=-d);if(1E-6<1-t){var n=Math.acos(t);var q=Math.sin(n);t=Math.sin((1-b)*n)/q;b=Math.sin(b*n)/q}else t=1-b;a[0]=t*c+b*k;a[1]=t*f+b*m;a[2]=t*g+b*l;a[3]=t*e+b*d;return a}function f(a,e){var d=e[0]+e[4]+e[8];if(0<d)d=Math.sqrt(d+1),a[3]=.5*d,d=.5/d,a[0]=(e[5]-e[7])*d,a[1]=(e[6]-e[2])*d,a[2]=(e[1]-e[3])*d;else{var b=0;e[4]>e[0]&&(b=1);e[8]>e[3*b+b]&&(b=2);var c=(b+1)%3,f=(b+2)%3;d=Math.sqrt(e[3*b+b]-e[3*c+c]-e[3*f+f]+1);a[b]=.5*d;d=.5/d;a[3]=(e[3*c+f]-e[3*f+c])*d;a[c]=(e[3*c+b]+e[3*
b+c])*d;a[f]=(e[3*f+b]+e[3*b+f])*d}return a}Object.defineProperty(g,"__esModule",{value:!0});g.create=u;g.identity=function(a){a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a};g.setAxisAngle=n;g.getAxisAngle=function(a,e){var d=2*Math.acos(e[3]),b=Math.sin(d/2);0!=b?(a[0]=e[0]/b,a[1]=e[1]/b,a[2]=e[2]/b):(a[0]=1,a[1]=0,a[2]=0);return d};g.multiply=q;g.rotateX=function(a,e,d){d*=.5;var b=e[0],c=e[1],f=e[2];e=e[3];var g=Math.sin(d);d=Math.cos(d);a[0]=b*d+e*g;a[1]=c*d+f*g;a[2]=f*d-c*g;a[3]=e*d-b*g;return a};g.rotateY=
function(a,e,d){d*=.5;var b=e[0],c=e[1],f=e[2];e=e[3];var g=Math.sin(d);d=Math.cos(d);a[0]=b*d-f*g;a[1]=c*d+e*g;a[2]=f*d+b*g;a[3]=e*d-c*g;return a};g.rotateZ=function(a,e,d){d*=.5;var b=e[0],c=e[1],f=e[2];e=e[3];var g=Math.sin(d);d=Math.cos(d);a[0]=b*d+c*g;a[1]=c*d-b*g;a[2]=f*d+e*g;a[3]=e*d-f*g;return a};g.calculateW=function(a,e){var d=e[0],b=e[1];e=e[2];a[0]=d;a[1]=b;a[2]=e;a[3]=Math.sqrt(Math.abs(1-d*d-b*b-e*e));return a};g.slerp=a;g.invert=function(a,e){var d=e[0],b=e[1],c=e[2];e=e[3];var f=d*
d+b*b+c*c+e*e;f=f?1/f:0;a[0]=-d*f;a[1]=-b*f;a[2]=-c*f;a[3]=e*f;return a};g.conjugate=function(a,e){a[0]=-e[0];a[1]=-e[1];a[2]=-e[2];a[3]=e[3];return a};g.fromMat3=f;g.fromEuler=function(a,e,d,b){var c=.5*Math.PI/180;e*=c;d*=c;b*=c;c=Math.sin(e);e=Math.cos(e);var f=Math.sin(d);d=Math.cos(d);var g=Math.sin(b);b=Math.cos(b);a[0]=c*d*b-e*f*g;a[1]=e*f*b+c*d*g;a[2]=e*d*g-c*f*b;a[3]=e*d*b+c*f*g;return a};g.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};var l=c(30),v=c(103),t=c(104);
p=c(105);g.clone=p.clone;g.fromValues=p.fromValues;g.copy=p.copy;g.set=p.set;g.add=p.add;g.mul=q;g.scale=p.scale;g.dot=p.dot;g.lerp=p.lerp;c=p.length;g.length=c;g.len=c;c=p.squaredLength;g.squaredLength=c;g.sqrLen=c;var m=p.normalize;g.normalize=m;g.exactEquals=p.exactEquals;g.equals=p.equals;p=function(){var a=t.create(),e=t.fromValues(1,0,0),d=t.fromValues(0,1,0);return function(b,c,f){var g=t.dot(c,f);if(-.999999>g)return t.cross(a,e,c),1E-6>t.len(a)&&t.cross(a,d,c),t.normalize(a,a),n(b,a,Math.PI),
b;if(.999999<g)return b[0]=0,b[1]=0,b[2]=0,b[3]=1,b;t.cross(a,c,f);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=1+g;return m(b,b)}}();g.rotationTo=p;p=function(){var c=u(),e=u();return function(d,b,f,g,k,m){a(c,b,k,m);a(e,f,g,m);a(d,c,e,2*m*(1-m));return d}}();g.sqlerp=p;p=function(){var a=v.create();return function(e,d,b,c){a[0]=b[0];a[3]=b[1];a[6]=b[2];a[1]=c[0];a[4]=c[1];a[7]=c[2];a[2]=-d[0];a[5]=-d[1];a[8]=-d[2];return m(e,f(e,a))}}();g.setAxes=p},function(p,g,c){function u(){var a=new m.a(2);a[0]=0;a[1]=
0;return a}function n(a,e,d){a[0]=e[0]-d[0];a[1]=e[1]-d[1];return a}function q(a,e,d){a[0]=e[0]*d[0];a[1]=e[1]*d[1];return a}function a(a,e,d){a[0]=e[0]/d[0];a[1]=e[1]/d[1];return a}function f(a,e){var d=e[0]-a[0];a=e[1]-a[1];return Math.sqrt(d*d+a*a)}function l(a,e){var d=e[0]-a[0];a=e[1]-a[1];return d*d+a*a}function v(a){var e=a[0];a=a[1];return Math.sqrt(e*e+a*a)}function t(a){var e=a[0];a=a[1];return e*e+a*a}Object.defineProperty(g,"__esModule",{value:!0});g.create=u;g.clone=function(a){var e=
new m.a(2);e[0]=a[0];e[1]=a[1];return e};g.fromValues=function(a,e){var d=new m.a(2);d[0]=a;d[1]=e;return d};g.copy=function(a,e){a[0]=e[0];a[1]=e[1];return a};g.set=function(a,e,d){a[0]=e;a[1]=d;return a};g.add=function(a,e,d){a[0]=e[0]+d[0];a[1]=e[1]+d[1];return a};g.subtract=n;g.multiply=q;g.divide=a;g.ceil=function(a,e){a[0]=Math.ceil(e[0]);a[1]=Math.ceil(e[1]);return a};g.floor=function(a,e){a[0]=Math.floor(e[0]);a[1]=Math.floor(e[1]);return a};g.min=function(a,e,d){a[0]=Math.min(e[0],d[0]);
a[1]=Math.min(e[1],d[1]);return a};g.max=function(a,e,d){a[0]=Math.max(e[0],d[0]);a[1]=Math.max(e[1],d[1]);return a};g.round=function(a,e){a[0]=Math.round(e[0]);a[1]=Math.round(e[1]);return a};g.scale=function(a,e,d){a[0]=e[0]*d;a[1]=e[1]*d;return a};g.scaleAndAdd=function(a,e,d,b){a[0]=e[0]+d[0]*b;a[1]=e[1]+d[1]*b;return a};g.distance=f;g.squaredDistance=l;g.length=v;g.squaredLength=t;g.negate=function(a,e){a[0]=-e[0];a[1]=-e[1];return a};g.inverse=function(a,e){a[0]=1/e[0];a[1]=1/e[1];return a};
g.normalize=function(a,e){var d=e[0],b=e[1];d=d*d+b*b;0<d&&(d=1/Math.sqrt(d),a[0]=e[0]*d,a[1]=e[1]*d);return a};g.dot=function(a,e){return a[0]*e[0]+a[1]*e[1]};g.cross=function(a,e,d){e=e[0]*d[1]-e[1]*d[0];a[0]=a[1]=0;a[2]=e;return a};g.lerp=function(a,e,d,b){var c=e[0];e=e[1];a[0]=c+b*(d[0]-c);a[1]=e+b*(d[1]-e);return a};g.random=function(a,e){e=e||1;var d=2*m.c()*Math.PI;a[0]=Math.cos(d)*e;a[1]=Math.sin(d)*e;return a};g.transformMat2=function(a,e,d){var b=e[0];e=e[1];a[0]=d[0]*b+d[2]*e;a[1]=d[1]*
b+d[3]*e;return a};g.transformMat2d=function(a,e,d){var b=e[0];e=e[1];a[0]=d[0]*b+d[2]*e+d[4];a[1]=d[1]*b+d[3]*e+d[5];return a};g.transformMat3=function(a,e,d){var b=e[0];e=e[1];a[0]=d[0]*b+d[3]*e+d[6];a[1]=d[1]*b+d[4]*e+d[7];return a};g.transformMat4=function(a,e,d){var b=e[0];e=e[1];a[0]=d[0]*b+d[4]*e+d[12];a[1]=d[1]*b+d[5]*e+d[13];return a};g.str=function(a){return"vec2("+a[0]+", "+a[1]+")"};g.exactEquals=function(a,e){return a[0]===e[0]&&a[1]===e[1]};g.equals=function(a,e){var d=a[0];a=a[1];var b=
e[0];e=e[1];return Math.abs(d-b)<=m.b*Math.max(1,Math.abs(d),Math.abs(b))&&Math.abs(a-e)<=m.b*Math.max(1,Math.abs(a),Math.abs(e))};var m=c(30);g.len=v;g.sub=n;g.mul=q;g.div=a;g.dist=f;g.sqrDist=l;g.sqrLen=t;p=function(){var a=u();return function(e,d,b,c,f,g){d||(d=2);b||(b=0);for(c=c?Math.min(c*d+b,e.length):e.length;b<c;b+=d)a[0]=e[b],a[1]=e[b+1],f(a,a,g),e[b]=a[0],e[b+1]=a[1];return e}}();g.forEach=p},function(p,g,c){c.d(g,"a",function(){return q});var u=c(1),n=function(){function a(a,c){for(var f=
0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,g,n){g&&a(c.prototype,g);n&&a(c,n);return c}}(),q=function(){function a(c,g){g=void 0===g?u.d:g;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.size=u.s.clone(c);this.transform=u.k.clone(g);this.invTransform=u.k.invert(u.k.create(),g)}n(a,[{key:"toObject",value:function(a){a.size=this.size;a.transform=this.transform}},
{key:"localSpatialToGlobal",value:function(a,c){return u.s.transformMat4(a,c,this.transform)}},{key:"globalToLocalSpatial",value:function(a,c){return u.s.transformMat4(a,c,this.invTransform)}},{key:"globalToLocalGrid",value:function(a,c){this.globalToLocalSpatial(a,c);u.s.divide(a,a,this.size);return a}},{key:"localSpatialVectorToGlobal",value:function(a,c){return Object(u.p)(a,c,this.transform)}},{key:"globalToLocalSpatialVector",value:function(a,c){return Object(u.p)(a,c,this.invTransform)}},{key:"assignLocalSpatialToGlobalMat4",
value:function(a){return u.k.copy(a,this.transform)}}],[{key:"get",value:function(c,g){g=void 0===g?u.d:g;var f=a.cache,l=JSON.stringify([Array.from(c),Array.from(g)]),m=f.get(l);void 0===m&&(m=new a(c,g),f.set(l,m));return m}},{key:"fromObject",value:function(c){return a.get(c.size,c.transform)}}]);return a}();q.cache=new Map},function(p,g,c){g.a=function(c,g){return c===g?!0:1E-6>Math.abs(c-g)/Math.min(Math.abs(c),Math.abs(g))}},function(p,g,c){function u(a,e){if(!(a instanceof e))throw new TypeError("Cannot call a class as a function");
}function n(a,e){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==typeof e&&"function"!==typeof e?a:e}function q(a,e){if("function"!==typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(a,e):a.__proto__=e)}c.d(g,"a",function(){return m});
var a=c(50),f=c(14);p=c(5);g=c(0);var l=c(1),v=function(){function a(a,d){for(var b=0;b<d.length;b++){var e=d[b];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(e,d,b){d&&a(e.prototype,d);b&&a(e,b);return e}}(),t=function(a){function e(){u(this,e);return n(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}q(e,a);return e}(p.f),m=function(c){function e(d){u(this,e);var b=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));
b.transformCacheGeneration=-1;b.cachedObjectToGlobal=l.k.create();b.cachedGlobalToObject=l.k.create();var c=void 0===d.transform?new a.a:d.transform,g=d.source,k=void 0===d.hoverState?new t(void 0):d.hoverState,m=void 0===d.role?f.f.ANNOTATION:d.role;d=d.color;b.transform=c;b.source=b.registerDisposer(g);b.hoverState=k;b.role=m;b.color=d;return b}q(e,c);v(e,[{key:"updateTransforms",value:function(){if(this.transform.changed.count!==this.transformCacheGeneration){var a=this.cachedObjectToGlobal;l.k.multiply(a,
this.transform.transform,this.source.objectToLocal);l.k.invert(this.cachedGlobalToObject,a)}}},{key:"objectToGlobal",get:function(){this.updateTransforms();return this.cachedObjectToGlobal}},{key:"globalToObject",get:function(){this.updateTransforms();return this.cachedGlobalToObject}}]);return e}(g.a)},function(p,g,c){var u=c(107);p.exports=function(){return u.Date.now()}},function(p,g,c){g=c(7);p.exports="object"==typeof g&&g&&g.Object===Object&&g},function(p,g,c){var u=c(73),n=c(186),q=0/0,a=/^\s+|\s+$/g,
f=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,v=/^0o[0-7]+$/i,t=parseInt;p.exports=function(c){if("number"==typeof c)return c;if(n(c))return q;u(c)&&(c="function"==typeof c.valueOf?c.valueOf():c,c=u(c)?c+"":c);if("string"!=typeof c)return 0===c?c:+c;c=c.replace(a,"");var g=l.test(c);return g||v.test(c)?t(c.slice(2),g?2:8):f.test(c)?q:+c}},function(p,g,c){var u=c(187),n=c(190);p.exports=function(c){return"symbol"==typeof c||n(c)&&"[object Symbol]"==u(c)}},function(p,g,c){g=c(108);var u=c(188),n=c(189),q=g?
g.toStringTag:void 0;p.exports=function(a){return null==a?void 0===a?"[object Undefined]":"[object Null]":q&&q in Object(a)?u(a):n(a)}},function(p,g,c){g=c(108);c=Object.prototype;var u=c.hasOwnProperty,n=c.toString,q=g?g.toStringTag:void 0;p.exports=function(a){var c=u.call(a,q),g=a[q];try{a[q]=void 0;var p=!0}catch(m){}var t=n.call(a);p&&(c?a[q]=g:delete a[q]);return t}},function(p,g){var c=Object.prototype.toString;p.exports=function(g){return c.call(g)}},function(p,g){p.exports=function(c){return null!=
c&&"object"==typeof c}},function(p,g,c){g.b=function(c,g){c.remove(g)};g.a=function(c,g){c.add(g)}},function(p,g){},function(p,g,c){c.d(g,"b",function(){return u});var u;(function(c){c[c.LITTLE=0]="LITTLE";c[c.BIG=1]="BIG"})(u||(u={}));p=function(){var c=Uint16Array.of(4386);return 17===(new Uint8Array(c.buffer))[0]?u.BIG:u.LITTLE}();g.a=p},function(p,g){},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){for(var b=[],d=$jscomp.makeIterator(l.e),e=d.next();!e.done;e=d.next())b[e.value]=[];d=$jscomp.makeIterator(a);for(var c=
d.next();!c.done;c=d.next())c=c.value,b[c.type].push(c.id);var f=0;d=0;c=[];var g=$jscomp.makeIterator(l.e);for(e=g.next();!e.done;e=g.next()){var h=e.value;c[h]=f;e=b[h].length;h=Object(m.b)(h);f+=e*h.bytes;d+=h.pickIdsPerInstance*e}f=new ArrayBuffer(f);g={};h=$jscomp.makeIterator(l.e);for(e=h.next();!e.done;g={serializer:g.serializer},e=h.next()){e=e.value;var k=b[e],r=Object(m.b)(e);g.serializer=r.serializer(f,c[e],k.length);k.forEach(function(b){return function(d,e){return b.serializer(a.get(d),
e)}}(g))}return{typeToIds:b,typeToOffset:c,data:f,numPickIds:d}}function f(a,b){return function(a){function e(a){for(var d=[],c=0;c<arguments.length;++c)d[c-0]=arguments[c];u(this,e);var f,g=n(this,(f=e.__proto__||Object.getPrototypeOf(e)).call.apply(f,[].concat([this],$jscomp.arrayFromIterable(d))));g.renderHelpers=[];g.isAnnotation=!0;d=g.registerDisposer(g.base);g.role=d.state.role;c=g.renderHelpers;f=g.gl;for(var h=$jscomp.makeIterator(l.e),k=h.next();!k.done;k=h.next()){var r=k.value;k=Object(m.b)(r);
r=c[r]=g.registerDisposer(new k[b](f));r.pickIdsPerInstance=k.pickIdsPerInstance;r.targetIsSliceView="sliceViewRenderHelper"===b}g.registerDisposer(d);g.registerDisposer(d.redrawNeeded.add(function(){g.redrawNeeded.dispatch()}));g.setReady(!0);return g}q(e,a);A(e,[{key:"drawChunk",value:function(a,b){var e=this.base;if(!a.bufferValid){var c=a.buffer;void 0===c&&(c=a.buffer=new x.a(this.gl));c.setData(a.data);a.bufferValid=!0}c=a.typeToIds;var f=a.typeToOffset,g=0;b.emitPickID&&(g=b.pickIDs.register(this,
a.numPickIds,0,0,a));for(var k=e.hoverState.value,r=h.k.multiply(D,b.dataToDevice,e.state.objectToGlobal),t=$jscomp.makeIterator(l.e),n=t.next();!n.done;n=t.next()){n=n.value;var q=c[n];if(0<q.length){var p=q.length,u=Object(m.b)(n),v=4294967295;void 0!==k&&(q=Object(d.a)(q,k.id,function(a,b){return a<b?-1:a===b?0:1}),0<=q&&(v=q*u.pickIdsPerInstance));this.renderHelpers[n].draw({annotationLayer:e,renderContext:b,selectedIndex:v,basePickId:g,buffer:a.buffer,bufferOffset:f[n],count:p,projectionMatrix:r});
g+=p*u.pickIdsPerInstance}}}},{key:"draw",value:function(a){var b=this.base.source;if(b instanceof l.b){b=this.base;b.updateBuffer();var d=b.typeToIds,e=b.typeToOffset,c=0;a.emitPickID&&(c=a.pickIDs.register(this,b.numPickIds));for(var f=b.hoverState.value,g=$jscomp.makeIterator(l.e),r=g.next();!r.done;r=g.next()){r=r.value;var t=d[r];if(0<t.length){var n=t.length,q=Object(m.b)(r),p=4294967295;void 0!==f&&(t=t.indexOf(f.id),-1!==t&&(p=t*q.pickIdsPerInstance));p={annotationLayer:b,renderContext:a,
selectedIndex:p,basePickId:c,buffer:b.buffer,bufferOffset:e[r],count:n,projectionMatrix:h.k.multiply(D,a.dataToDevice,b.state.objectToGlobal)};this.renderHelpers[r].draw(p);c+=n*q.pickIdsPerInstance}}}else for(this.drawChunk(b.temporary,a),b=$jscomp.makeIterator(b.sources),d=b.next();!d.done;d=b.next())for(d=$jscomp.makeIterator(d.value),e=d.next();!e.done;e=d.next())for(e=$jscomp.makeIterator(e.value.chunks.values()),c=e.next();!c.done;c=e.next())c=c.value,c.state===k.d.GPU_MEMORY&&this.drawChunk(c,
a)}},{key:"updateMouseState",value:function(a,b,d,e){if(this.base.source instanceof l.b)for(var c=this.base.typeToIds,f=$jscomp.makeIterator(l.e),g=f.next();!g.done;g=f.next()){e=g.value;b=c[e];g=Object(m.b)(e);var h=g.pickIdsPerInstance;if(d<b.length*h){c=Math.floor(d/h);d%=h;a.pickedAnnotationId=b[c];a.pickedAnnotationLayer=this.base.state;a.pickedOffset=d;g.snapPosition(a.position,this.base.state.objectToGlobal,this.base.data.buffer,this.base.data.byteOffset+this.base.typeToOffset[e]+c*g.bytes,
d);break}d-=b.length*h}else if(void 0!==e.data){h=e.typeToIds;b=e.typeToOffset;var k=$jscomp.makeIterator(l.e);for(g=k.next();!g.done;g=k.next()){g=g.value;c=h[g];f=Object(m.b)(g);var r=f.pickIdsPerInstance;if(d<c.length*r){h=Math.floor(d/r);d%=r;a.pickedAnnotationId=c[h];a.pickedAnnotationLayer=this.base.state;a.pickedOffset=d;f.snapPosition(a.position,this.base.state.objectToGlobal,e.data.buffer,e.data.byteOffset+b[g]+h*f.bytes,d);break}d-=c.length*r}}}},{key:"transformPickedValue",value:function(a,
b){}},{key:"gl",get:function(){return this.base.chunkManager.gl}}]);return e}(a)}c.d(g,"a",function(){return y});c.d(g,"b",function(){return E});c(196);c(197);c(198);c(199);var l=c(22),v=c(72),t=c(75),m=c(44),k=c(36),e=c(52);p=c(79);var d=c(39),b=c(0),h=c(1),r=c(3),x=c(15),z=c(12),A=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,
d);e&&a(b,e);return b}}(),D=h.k.create(),y=function(b){function d(a,b){u(this,d);var e=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.chunkManager=a;e.state=b;e.generation=-1;e.redrawNeeded=new r.a;e.registerDisposer(b);e.buffer=e.registerDisposer(new x.a(a.gl));e.registerDisposer(e.source.changed.add(e.redrawNeeded.dispatch));e.registerDisposer(e.hoverState.changed.add(e.redrawNeeded.dispatch));e.registerDisposer(e.transform.changed.add(e.redrawNeeded.dispatch));return e}q(d,b);A(d,
[{key:"updateBuffer",value:function(){var b=this.source;if(b instanceof l.b){var d=b.changed.count;if(this.generation!==d){this.generation=d;b=a(b);d=b.typeToIds;var e=b.typeToOffset,c=b.numPickIds;this.data=new Uint8Array(b.data);this.buffer.setData(this.data);this.typeToIds=d;this.typeToOffset=e;this.numPickIds=c}}}},{key:"source",get:function(){return this.state.source}},{key:"transform",get:function(){return this.state.transform}},{key:"hoverState",get:function(){return this.state.hoverState}},
{key:"gl",get:function(){return this.chunkManager.gl}}]);return d}(b.a);c=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.base=a;return d}q(b,a);return b}(e.a);p=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.base=a;return d}q(b,a);return b}(p.b);var E=function(a){function b(){u(this,b);var a=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));var d=a.base.source;if(d instanceof
t.b){var e=a.registerDisposer(new z.b);e.RPC_TYPE_ID=v.e;e.initializeCounterpart(d.chunkManager.rpc,{source:d.rpcId});d=e}else d=void 0;a.backend=d;return a}q(b,a);A(b,[{key:"isReady",value:function(){var a=this.base.source;return a instanceof t.b&&(a=a.sources[0][0].chunks.get("0,0,0"),void 0===a||a.state!==k.d.GPU_MEMORY)?!1:!0}}]);return b}(f(c,"perspectiveViewRenderHelper"));c=f(p,"sliceViewRenderHelper");g.c=c},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(){return Object(l.d)(new Float32Array([0,
1,2,3,4,5]),1,1,k.b)}p=c(22);g=c(44);var f=c(113),l=c(39),v=c(1),t=c(15),m=c(11),k=c(114),e=c(27),d=c(78),b=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),h=function D(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return D(a,
b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}};c=27;var r=Float32Array.from([0,0,0,0,0,1,9,1,0,0,1,0,1,10,0,1,0,0,1,1,11,1,1,0,1,1,1,12,0,0,0,0,1,0,13,0,0,1,0,1,1,14,1,0,0,1,1,0,15,1,0,1,1,1,1,16,0,0,0,1,0,0,17,0,0,1,1,0,1,18,0,1,0,1,1,0,19,0,1,1,1,1,1,20]),x=function(a){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,a);b(d,[{key:"defineShader",value:function(a){h(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),
"defineShader",this).call(this,a);a.addAttribute("highp vec3","aLower");a.addAttribute("highp vec3","aUpper")}},{key:"enable",value:function(a,b,e){h(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"enable",this).call(this,a,b,function(){var d=a.gl,c=a.attribute("aLower"),f=a.attribute("aUpper");b.buffer.bindToVertexAttrib(c,3,m.g,!1,24,b.bufferOffset);b.buffer.bindToVertexAttrib(f,3,m.g,!1,24,b.bufferOffset+12);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,1);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(f,
1);e();d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,0);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(f,0);d.disableVertexAttribArray(c);d.disableVertexAttribArray(f)})}}]);return d}(g.a),z=function(a){function c(){u(this,c);var a=n(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments));a.lineShader=a.registerDisposer(new k.a(a.gl,12));a.edgeBoxCornerOffsetsBuffer=a.registerDisposer(t.a.fromData(a.gl,Object(l.d)(r,7,1,k.b)));a.edgeShaderGetter=Object(e.b)(a,a.gl,function(b){a.defineShader(b);
a.lineShader.defineShader(b);b.addAttribute("highp vec3","aBoxCornerOffset1");b.addAttribute("highp vec4","aBoxCornerOffset2");b.setVertexMain("\nvec3 vertexPosition1 = mix(aLower, aUpper, aBoxCornerOffset1);\nvec3 vertexPosition2 = mix(aLower, aUpper, aBoxCornerOffset2.xyz);\nemitLine(uProjection, vertexPosition1, vertexPosition2);\n"+a.setPartIndex(b,"aBoxCornerOffset2.w")+";\n");b.setFragmentMain("\nemitAnnotation(vec4(vColor.rgb, getLineAlpha()));\n")});a.circleShader=a.registerDisposer(new d.a(a.gl,
8));a.boxCornerOffsetsBuffer=a.registerDisposer(t.a.fromData(a.gl,Object(l.d)(f.b,3,1,d.b)));a.cornerShaderGetter=Object(e.b)(a,a.gl,function(b){a.defineShader(b);a.circleShader.defineShader(b,a.targetIsSliceView);b.addAttribute("highp vec3","aBoxCornerOffset");b.setVertexMain("\nvec3 vertexPosition = mix(aLower, aUpper, aBoxCornerOffset);\nemitCircle(uProjection * vec4(vertexPosition, 1.0));\nfloat cornerIndex = aBoxCornerOffset.x + aBoxCornerOffset.y * 2.0 + aBoxCornerOffset.z * 4.0;\nfloat cornerPickOffset = "+
(1).toFixed(1)+" + cornerIndex;\n"+a.setPartIndex(b,"cornerPickOffset")+";\n");b.setFragmentMain("\nvec4 borderColor = vec4(0.0, 0.0, 0.0, 1.0);\nemitAnnotation(getCircleColor(vColor, borderColor));\n")});return a}q(c,a);b(c,[{key:"drawEdges",value:function(a){var b=this,d=this.edgeShaderGetter(a.renderContext.emitter),e=this.gl;this.enable(d,a,function(){var c=d.attribute("aBoxCornerOffset1"),f=d.attribute("aBoxCornerOffset2");b.edgeBoxCornerOffsetsBuffer.bindToVertexAttrib(c,3,m.g,!1,28,0);b.edgeBoxCornerOffsetsBuffer.bindToVertexAttrib(f,
4,m.g,!1,28,12);b.lineShader.draw(d,a.renderContext,a.renderContext.emitColor?1:5,1,a.count);e.disableVertexAttribArray(c);e.disableVertexAttribArray(f)})}},{key:"drawCorners",value:function(a){var b=this,d=this.cornerShaderGetter(a.renderContext.emitter),e=this.gl;this.enable(d,a,function(){var c=d.attribute("aBoxCornerOffset");b.boxCornerOffsetsBuffer.bindToVertexAttrib(c,3,m.g,!1);b.circleShader.draw(d,a.renderContext,{interiorRadiusInPixels:1,borderWidthInPixels:0,featherWidthInPixels:1},a.count);
e.disableVertexAttribArray(c)})}},{key:"draw",value:function(a){this.drawEdges(a);this.drawCorners(a)}}]);return c}(x);x=function(d){function c(b){u(this,c);var d=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b));d.gl=b;d.lineShader=new k.a(d.gl,6);d.intersectionVertexIndexBuffer=Object(t.b)(d.gl,m.a,a).value;d.boundingBoxCrossSectionHelper=d.registerDisposer(new f.a(d.gl));d.faceShaderGetter=Object(e.b)(d,d.gl,function(a){h(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"defineShader",
d).call(d,a);d.boundingBoxCrossSectionHelper.defineShader(a);d.lineShader.defineShader(a);a.addAttribute("highp float","aVertexIndexFloat");a.setVertexMain("\nint vertexIndex1 = int(aVertexIndexFloat);\nint vertexIndex2 = vertexIndex1 == 5 ? 0 : vertexIndex1 + 1;\nvec3 vertexPosition1 = getBoundingBoxPlaneIntersectionVertexPosition(aUpper - aLower, aLower, aLower, aUpper, vertexIndex1);\nvec3 vertexPosition2 = getBoundingBoxPlaneIntersectionVertexPosition(aUpper - aLower, aLower, aLower, aUpper, vertexIndex2);\nemitLine(uProjection, vertexPosition1, vertexPosition2);\n"+
d.setPartIndex(a)+";\n");a.setFragmentMain("\nemitAnnotation(vec4(vColor.rgb, vColor.a * getLineAlpha()));\n")});return d}q(c,d);b(c,[{key:"draw",value:function(a){var b=this,d=this.faceShaderGetter(a.renderContext.emitter),e=this.gl;this.enable(d,a,function(){b.boundingBoxCrossSectionHelper.setViewportPlane(d,a.renderContext.sliceView.viewportAxes[2],a.renderContext.sliceView.centerDataPosition,a.annotationLayer.state.globalToObject);var c=d.attribute("aVertexIndexFloat");b.intersectionVertexIndexBuffer.bindToVertexAttrib(c,
1,m.g,!1);b.lineShader.draw(d,a.renderContext,a.renderContext.emitColor?1:5,1,a.count);e.disableVertexAttribArray(c)})}}]);return c}(x);Object(g.c)(p.c.AXIS_ALIGNED_BOUNDING_BOX,{bytes:24,serializer:function(a,b,d){var e=new Float32Array(a,b,6*d);return function(a,b){var d=a.pointA;a=a.pointB;b*=6;e[b]=Math.min(d[0],a[0]);e[b+1]=Math.min(d[1],a[1]);e[b+2]=Math.min(d[2],a[2]);e[b+3]=Math.max(d[0],a[0]);e[b+4]=Math.max(d[1],a[1]);e[b+5]=Math.max(d[2],a[2])}},sliceViewRenderHelper:x,perspectiveViewRenderHelper:z,
pickIdsPerInstance:c,snapPosition:function(a,b,d,e,c){d=new Float32Array(d,e,6);if(1<=c&&9>c){c=3*(c-1);for(e=0;3>e;++e){var g=f.b[c+e];a[e]=(1-g)*Math.min(d[e],d[e+3])+g*Math.max(d[e],d[e+3])}v.s.transformMat4(a,a,b)}else if(9<=c&&21>c){c=7*(c-9);e=v.s.create();g=v.s.create();for(var h=0;3>h;++h){var k=r[c+h],m=r[c+h+3],l=Math.min(d[h],d[h+3]),t=Math.max(d[h],d[h+3]);e[h]=(1-k)*l+k*t;g[h]=(1-m)*l+m*t}v.s.transformMat4(e,e,b);v.s.transformMat4(g,g,b);Object(v.m)(a,e,g,a)}}})},function(p,g,c){function u(a,
d){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!d||"object"!==typeof d&&"function"!==typeof d?a:d}function n(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}function q(){return Object(a.d)(new Float32Array([0,
1]),1,1,v.b)}p=c(22);g=c(44);var a=c(39),f=c(1),l=c(15),v=c(78),t=c(11),m=c(114),k=c(27),e=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),d=function h(a,d,e){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,d);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return h(a,d,e)}else{if("value"in
c)return c.value;d=c.get;return void 0===d?void 0:d.call(e)}};c=function(a){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var a=u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments));a.lineShader=a.registerDisposer(new m.a(a.gl,1));a.circleShader=a.registerDisposer(new v.a(a.gl,2));a.edgeShaderGetter=Object(k.b)(a,a.gl,function(d){a.defineShader(d);a.lineShader.defineShader(d);d.setVertexMain("\nemitLine(uProjection, aEndpointA, aEndpointB);\n"+
a.setPartIndex(d)+";\n");d.setFragmentMain("\nemitAnnotation(vec4(vColor.rgb, vColor.a * getLineAlpha() * "+a.getCrossSectionFadeFactor()+"));\n")});a.endpointIndexBuffer=a.registerDisposer(Object(l.b)(a.gl,t.a,q)).value;a.endpointShaderGetter=Object(k.b)(a,a.gl,function(d){a.defineShader(d);a.circleShader.defineShader(d,a.targetIsSliceView);d.addAttribute("highp float","aEndpointIndex");d.setVertexMain("\nvec3 vertexPosition = mix(aEndpointA, aEndpointB, aEndpointIndex);\nemitCircle(uProjection * vec4(vertexPosition, 1.0));\n"+
a.setPartIndex(d,"aEndpointIndex + 1.0")+";\n");d.setFragmentMain("\nvec4 borderColor = vec4(0.0, 0.0, 0.0, 1.0);\nemitAnnotation(getCircleColor(vColor, borderColor));\n")});return a}n(c,a);e(c,[{key:"defineShader",value:function(a){d(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"defineShader",this).call(this,a);a.addAttribute("highp vec3","aEndpointA");a.addAttribute("highp vec3","aEndpointB")}},{key:"enable",value:function(a,e,f){d(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),
"enable",this).call(this,a,e,function(){var d=a.gl,c=a.attribute("aEndpointA"),g=a.attribute("aEndpointB");e.buffer.bindToVertexAttrib(c,3,t.g,!1,24,e.bufferOffset);e.buffer.bindToVertexAttrib(g,3,t.g,!1,24,e.bufferOffset+12);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,1);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(g,1);f();d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,0);d.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(g,0);d.disableVertexAttribArray(c);d.disableVertexAttribArray(g)})}},
{key:"drawEdges",value:function(a){var d=this,e=this.edgeShaderGetter(a.renderContext.emitter);this.enable(e,a,function(){d.lineShader.draw(e,a.renderContext,a.renderContext.emitColor?1:5,1,a.count)})}},{key:"drawEndpoints",value:function(a){var d=this,e=this.endpointShaderGetter(a.renderContext.emitter);this.enable(e,a,function(){var c=e.attribute("aEndpointIndex");d.endpointIndexBuffer.bindToVertexAttrib(c,1,t.g,!1);d.circleShader.draw(e,a.renderContext,{interiorRadiusInPixels:6,borderWidthInPixels:2,
featherWidthInPixels:1},a.count);e.gl.disableVertexAttribArray(c)})}},{key:"draw",value:function(a){this.drawEdges(a);this.drawEndpoints(a)}}]);return c}(g.a);Object(g.c)(p.c.LINE,{bytes:24,serializer:function(a,d,e){var c=new Float32Array(a,d,6*e);return function(a,d){var e=a.pointA;a=a.pointB;d*=6;c[d]=e[0];c[d+1]=e[1];c[d+2]=e[2];c[d+3]=a[0];c[d+4]=a[1];c[d+5]=a[2]}},sliceViewRenderHelper:c,perspectiveViewRenderHelper:c,pickIdsPerInstance:3,snapPosition:function(a,d,e,c,g){e=new Float32Array(e,
c,6);0===g?(g=f.s.transformMat4(f.s.create(),e.subarray(0,3),d),d=f.s.transformMat4(f.s.create(),e.subarray(3,6),d),Object(f.m)(a,g,d,a)):(g=3*(g-1),g=e.subarray(g,g+3),f.s.transformMat4(a,g,d))}})},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+
typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}p=c(22);g=c(44);var q=c(1),a=c(78),f=c(11),l=c(27),v=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),t=function k(a,d,b){null===
a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,d);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in e)return e.value;d=e.get;return void 0===d?void 0:d.call(b)}};c=function(c){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var d=u(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));d.circleShader=d.registerDisposer(new a.a(d.gl));d.shaderGetter=Object(l.b)(d,d.gl,function(a){return d.defineShader(a)});
return d}n(e,c);v(e,[{key:"defineShader",value:function(a){t(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"defineShader",this).call(this,a);this.circleShader.defineShader(a,this.targetIsSliceView);a.addAttribute("highp vec3","aVertexPosition");a.setVertexMain("\nemitCircle(uProjection * vec4(aVertexPosition, 1.0));\n"+this.setPartIndex(a)+";\n");a.setFragmentMain("\nvec4 borderColor = vec4(0.0, 0.0, 0.0, 1.0);\nemitAnnotation(getCircleColor(vColor, borderColor));\n")}},{key:"draw",value:function(a){var b=
this,d=this.shaderGetter(a.renderContext.emitter);this.enable(d,a,function(){var e=b.gl,c=d.attribute("aVertexPosition");a.buffer.bindToVertexAttrib(c,3,f.g,!1,0,a.bufferOffset);e.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,1);b.circleShader.draw(d,a.renderContext,{interiorRadiusInPixels:6,borderWidthInPixels:2,featherWidthInPixels:1},a.count);e.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(c,0);e.disableVertexAttribArray(c)})}}]);return e}(g.a);Object(g.c)(p.c.POINT,{bytes:12,serializer:function(a,
e,d){var b=new Float32Array(a,e,3*d);return function(a,d){a=a.point;d*=3;b[d]=a[0];b[d+1]=a[1];b[d+2]=a[2]}},sliceViewRenderHelper:c,perspectiveViewRenderHelper:c,pickIdsPerInstance:1,snapPosition:function(a,e,d,b){q.s.transformMat4(a,new Float32Array(d,b,3),e)}})},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==
typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}p=c(22);g=c(44);var a=c(1),f=c(11),l=c(200),v=c(77),t=c(27),m=c(201),k=c(51),e=c(202),d=function(){function a(a,b){for(var d=0;d<b.length;d++){var e=
b[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(b,d,e){d&&a(b.prototype,d);e&&a(b,e);return b}}(),b=function z(a,b,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,b);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return z(a,b,d)}else{if("value"in e)return e.value;b=e.get;return void 0===b?void 0:b.call(d)}},h=a.k.create(),r=function(a){function e(){u(this,e);return n(this,(e.__proto__||
Object.getPrototypeOf(e)).apply(this,arguments))}q(e,a);d(e,[{key:"defineShader",value:function(a){b(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"defineShader",this).call(this,a);a.addAttribute("highp vec3","aCenter");a.addAttribute("highp vec3","aRadii")}},{key:"enable",value:function(a,d,c){b(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"enable",this).call(this,a,d,function(){var b=a.attribute("aCenter"),e=a.attribute("aRadii"),g=a.gl;d.buffer.bindToVertexAttrib(b,3,f.g,
!1,24,d.bufferOffset);d.buffer.bindToVertexAttrib(e,3,f.g,!1,24,d.bufferOffset+12);g.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(b,1);g.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(e,1);c();g.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(b,0);g.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(e,0);g.disableVertexAttribArray(b);g.disableVertexAttribArray(e)})}}]);return e}(g.a);c=function(b){function e(){u(this,e);var a=n(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments));
a.sphereRenderHelper=a.registerDisposer(new m.a(a.gl,10,10));a.shaderGetter=Object(t.b)(a,a.gl,function(b){a.defineShader(b);a.sphereRenderHelper.defineShader(b);b.addUniform("highp vec4","uLightDirection");b.addUniform("highp mat4","uNormalTransform");b.setVertexMain("\nemitSphere(uProjection, uNormalTransform, aCenter, aRadii, uLightDirection);\n"+a.setPartIndex(b)+";\n");b.setFragmentMain("\nemitAnnotation(vec4(vColor.rgb * vLightingFactor, vColor.a));\n")});a.tempLightVec=new Float32Array(4);
return a}q(e,b);d(e,[{key:"draw",value:function(b){var d=this,e=this.shaderGetter(b.renderContext.emitter);this.enable(e,b,function(){var c=e.gl,f=d.tempLightVec,g=b.renderContext,h=g.ambientLighting;a.s.scale(f,g.lightDirection,g.directionalLighting);f[3]=h;c.uniform4fv(e.uniform("uLightDirection"),f);c.uniformMatrix4fv(e.uniform("uNormalTransform"),!1,a.k.transpose(a.k.create(),b.annotationLayer.state.globalToObject));d.sphereRenderHelper.draw(e,b.count)})}}]);return e}(r);r=function(b){function c(){u(this,
c);var a=n(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments));a.quadRenderHelper=a.registerDisposer(new v.a(a.gl,1));a.squareCornersBuffer=Object(k.a)(a.gl,-1,-1,1,1,1,1);a.shaderGetter=Object(t.b)(a,a.gl,function(b){a.defineShader(b);b.addUniform("highp mat4","uViewportToObject");b.addUniform("highp mat4","uObjectToViewport");b.addUniform("highp mat4","uViewportToDevice");b.addAttribute("highp vec2","aCornerOffset");b.addVarying("highp vec2","vCircleCoord");b.addVertexCode(e.a);
b.addVertexCode(l.d);b.addVertexCode(l.c);b.setVertexMain("\nmat3 Aobject = mat3(0.0);\nfor (int i = 0; i < 3; ++i) {\n  Aobject[i][i] = 1.0 / (aRadii[i] * aRadii[i]);\n}\nmat3 RviewportToObject = mat3(uViewportToObject);\nmat3 Aviewport = transpose(RviewportToObject) * Aobject * RviewportToObject;\nvec3 cViewport = (uObjectToViewport * vec4(aCenter, 1.0)).xyz;\nEllipseQuadraticForm quadraticForm = computeCrossSectionEllipse(Aviewport, cViewport);\nvec2 u1, u2;\nfloat a, b;\nCenterOrientEllipse centerOrient = computeCenterOrientEllipse(quadraticForm);\nvec2 viewportCorner = centerOrient.k +\n  centerOrient.u1 * aCornerOffset.x * centerOrient.a +\n  centerOrient.u2 * aCornerOffset.y * centerOrient.b;\ngl_Position = uViewportToDevice * vec4(viewportCorner, 0.0, 1.0);\nvCircleCoord = aCornerOffset;\n"+
a.setPartIndex(b)+";\n");b.setFragmentMain("\nif (dot(vCircleCoord, vCircleCoord) > 1.0) {\n  discard;\n}\nemitAnnotation(vec4(vColor.rgb, 0.5));\n")});return a}q(c,b);d(c,[{key:"draw",value:function(b){var d=this,e=this.shaderGetter(b.renderContext.emitter);this.enable(e,b,function(){var c=e.gl,f=e.attribute("aCornerOffset");d.squareCornersBuffer.bindToVertexAttrib(f,2);var g=a.k.multiply(h,b.annotationLayer.state.globalToObject,b.renderContext.sliceView.viewportToData);c.uniformMatrix4fv(e.uniform("uViewportToObject"),
!1,g);c.uniformMatrix4fv(e.uniform("uViewportToDevice"),!1,b.renderContext.sliceView.viewportToDevice);a.k.invert(h,g);c.uniformMatrix4fv(e.uniform("uObjectToViewport"),!1,h);d.quadRenderHelper.draw(c,b.count);e.gl.disableVertexAttribArray(f)})}}]);return c}(r);Object(g.c)(p.c.ELLIPSOID,{bytes:24,serializer:function(a,b,d){var e=new Float32Array(a,b,6*d);return function(a,b){var d=a.radii;b*=6;e.set(a.center,b);e.set(d,b+3)}},sliceViewRenderHelper:r,perspectiveViewRenderHelper:c,pickIdsPerInstance:1,
snapPosition:function(){}})},function(p,g,c){g.b=function(c,g){c=[[c[0],c[1],c[2]],[c[3],c[4],c[5]],[c[6],c[7],c[8]]];return{A:c[0][0],B:c[0][1]+c[1][0],C:c[1][1],D:-2*g[0]*c[0][0]-g[1]*(c[0][1]+c[1][0])+g[2]*(c[0][2]+c[2][0]),E:-g[0]*(c[0][1]+c[1][0])-2*g[1]*c[1][1]+g[2]*(c[1][2]+c[2][1]),F:g[0]*g[0]*c[0][0]+g[0]*g[1]*(c[0][1]+c[1][0])-g[0]*g[2]*(c[0][2]+c[2][0])+g[1]*g[1]*c[1][1]-g[1]*g[2]*(c[1][2]+c[2][1])+g[2]*g[2]*c[2][2]-1}};g.a=function(c){var g=c.A,a=c.B/2,f=c.C,l=c.D,n=c.E,t=2*(a*a-g*f),
m=(f*l-a*n)/t;l=(g*n-a*l)/t;c=1/(g*m*m+2*a*m*l+f*l*l-c.F);g*=c;a*=c;f*=c;n=g+f;t=Math.sqrt((g-f)*(g-f)+4*a*a);c=(n+t)/2;n=(n-t)/2;t=1/Math.sqrt(c);var k=1/Math.sqrt(n);var e=1E-10>Math.abs(a)?u.r.fromValues(1,0):g>=f?u.r.fromValues(c-f,a):u.r.fromValues(a,c-g);u.r.normalize(e,e);var d=u.r.fromValues(-e[1],e[0]);return{k:u.r.fromValues(m,l),u1:e,u2:d,a:t,b:k,lambda1:c,lambda2:n,m11:g,m12:a,m22:f}};var u=c(1);g.d=["\nstruct EllipseQuadraticForm {\n  highp float A;  // x*x coefficient\n  highp float B;  // x*y coefficient\n  highp float C;  // y*y coefficient\n  highp float D;  // x coefficient\n  highp float E;  // y coefficient\n  highp float F;  // 1 coefficient\n};\n",
"\nEllipseQuadraticForm computeCrossSectionEllipse(mat3 A, vec3 c) {\n  EllipseQuadraticForm p;\n  p.A = A[0][0];\n  p.B = A[0][1] + A[1][0];\n  p.C = A[1][1];\n  p.D = -2.0 * c[0] * A[0][0] - c[1] * (A[0][1] + A[1][0]) +\n        c[2] * (A[0][2] + A[2][0]);\n  p.E = -c[0] * (A[0][1] + A[1][0]) - 2.0 * c[1] * A[1][1] +\n        c[2] * (A[1][2] + A[2][1]);\n  p.F = c[0] * c[0] * A[0][0] + c[0] * c[1] * (A[0][1] + A[1][0]) -\n        c[0] * c[2] * (A[0][2] + A[2][0]) + c[1] * c[1] * A[1][1] -\n        c[1] * c[2] * (A[1][2] + A[2][1]) + c[2] * c[2] * A[2][2] - 1.0;\n  return p;\n}\n"];
g.c=["\nstruct EllipseQuadraticForm {\n  highp float A;  // x*x coefficient\n  highp float B;  // x*y coefficient\n  highp float C;  // y*y coefficient\n  highp float D;  // x coefficient\n  highp float E;  // y coefficient\n  highp float F;  // 1 coefficient\n};\n","\nstruct CenterOrientEllipse {\n  vec2 k;   // center\n  vec2 u1;  // minor axis direction\n  vec2 u2;  // major axis direction\n  float a;  // semimajor axis\n  float b;  // semiminor axis\n};\n","\nCenterOrientEllipse computeCenterOrientEllipse(EllipseQuadraticForm p) {\n  CenterOrientEllipse r;\n  float a11 = p.A;\n  float a12 = p.B / 2.0;\n  float a22 = p.C;\n  float b1 = p.D;\n  float b2 = p.E;\n  float c = p.F;\n  float kdenom = 2.0 * (a12 * a12 - a11 * a22);\n  float k1 = r.k.x = (a22 * b1 - a12 * b2) / kdenom;\n  float k2 = r.k.y = (a11 * b2 - a12 * b1) / kdenom;\n  float mu = 1.0 / (a11 * k1 * k1 + 2.0 * a12 * k1 * k2 + a22 * k2 * k2 - c);\n  float m11 = mu * a11;\n  float m12 = mu * a12;\n  float m22 = mu * a22;\n  float lambdaTerm1 = m11 + m22;\n  float lambdaTerm2 = sqrt((m11 - m22) * (m11 - m22) + 4.0 * m12 * m12);\n  float lambda1 = ((lambdaTerm1 + lambdaTerm2) / 2.0);\n  float lambda2 = ((lambdaTerm1 - lambdaTerm2) / 2.0);\n  r.a = 1.0 / sqrt(lambda1);\n  r.b = 1.0 / sqrt(lambda2);\n  if (abs(m12) < 1e-10) {\n    r.u1 = vec2(1.0, 0.0);\n  } else if (m11 >= m22) {\n    r.u1 = normalize(vec2(lambda1 - m22, m12));\n  } else {\n    r.u1 = normalize(vec2(m12, lambda1 - m11));\n  }\n  r.u2 = vec2(-r.u1.y, r.u1.x);\n  return r;\n}\n"]},
function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function n(a,c){for(var f=new Float32Array((a+1)*(c+1)*3),e=0,d=0;d<=a;++d){var b=d*Math.PI/a,g=Math.sin(b);b=Math.cos(b);for(var m=0;m<=c;++m){var l=2*m*Math.PI/c,t=Math.sin(l);
l=Math.cos(l);f[e++]=l*g;f[e++]=b;f[e++]=t*g}}return f}function q(a,c){for(var f=new Uint16Array(a*c*6),e=0,d=0;d<a;d++)for(var b=0;b<c;b++){var g=d*(c+1)+b,m=g+c+1;f[e++]=g;f[e++]=m;f[e++]=g+1;f[e++]=m;f[e++]=m+1;f[e++]=g+1}return f}c.d(g,"a",function(){return v});p=c(0);var a=c(15),f=c(11),l=function(){function a(a,c){for(var e=0;e<c.length;e++){var d=c[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,f,e){f&&a(c.prototype,
f);e&&a(c,e);return c}}(),v=function(c){function g(c,e,d){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var b=(g.__proto__||Object.getPrototypeOf(g)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");b=!b||"object"!==typeof b&&"function"!==typeof b?this:b;b.vertexBuffer=b.registerDisposer(Object(a.b)(c,f.a,n,e,d)).value;b.indexBuffer=b.registerDisposer(Object(a.b)(c,f.f,q,e,d)).value;b.numIndices=e*d*6;return b}
u(g,c);l(g,[{key:"defineShader",value:function(a){a.addAttribute("highp vec3","aSphereVertex");a.addVarying("highp float","vLightingFactor");a.addVertexCode("\nvoid emitSphere(mat4 projectionMatrix, mat4 normalTransformMatrix, vec3 centerPosition, vec3 radii, vec4 lightDirection) {\n  vec3 vertexPosition = aSphereVertex * radii + centerPosition;\n  gl_Position = projectionMatrix * vec4(vertexPosition, 1.0);\n  vec3 normal = normalize((normalTransformMatrix * vec4(aSphereVertex / radii, 0.0)).xyz);\n  vLightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w;\n}\n")}},
{key:"draw",value:function(a,e){var d=a.attribute("aSphereVertex");this.vertexBuffer.bindToVertexAttrib(d,3,f.g,!1);this.indexBuffer.bind();a.gl.ANGLE_instanced_arrays.drawElementsInstancedANGLE(f.C,this.numIndices,f.H,0,e);a.gl.disableVertexAttribArray(d)}}]);return g}(p.a)},function(p,g,c){g.a="\nmat3 transpose(mat3 m) {\n  mat3 result;\n  for (int i = 0; i < 3; ++i) {\n    for (int j = 0; j < 3; ++j) {\n      result[i][j] = m[j][i];\n    }\n  }\n  return result;\n}\n"},function(p,g,c){g.a=function(c){var g=
{antialias:!1,stencil:!0};c=c.getContext("webgl",g)||c.getContext("experimental-webgl",g);if(null==c)throw Error("WebGL not supported.");c.memoize=new u.a;c.maxTextureSize=c.getParameter(c.MAX_TEXTURE_SIZE);c.maxTextureImageUnits=c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS);c.tempTextureUnit=c.maxTextureImageUnits-1;c.WEBGL_draw_buffers=c.getExtension("WEBGL_draw_buffers");if(!c.WEBGL_draw_buffers)throw Error("WEBGL_draw_buffers extension not available");c.ANGLE_instanced_arrays=c.getExtension("ANGLE_instanced_arrays");
if(!c.ANGLE_instanced_arrays)throw Error("ANGLE_instanced_ararys extension not available");g=$jscomp.makeIterator(["OES_texture_float","OES_element_index_uint"]);for(var a=g.next();!a.done;a=g.next())if(a=a.value,!c.getExtension(a))throw Error(a+" extension not available");return c};var u=c(63)},function(p,g,c){var u=function(){function c(c,a){for(var f=0;f<a.length;f++){var g=a[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(c,g.key,g)}}return function(g,
a,f){a&&c(g.prototype,a);f&&c(g,f);return g}}();p=function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");}u(c,null,[{key:"insertAfter",value:function(c,a){var f=c.next0;a.next0=f;a.prev0=c;c.next0=a;f.prev0=a}},{key:"insertBefore",value:function(c,a){var f=c.prev0;a.prev0=f;a.next0=c;c.prev0=a;f.next0=a}},{key:"front",value:function(c){var a=c.next0;return a===c?null:a}},{key:"back",value:function(c){var a=c.prev0;return a===c?null:a}},{key:"pop",
value:function(c){var a=c.next0,f=c.prev0;a.prev0=f;f.next0=a;c.next0=null;c.prev0=null;return c}},{key:"iterator",value:function(c){function a(a,m){for(;;)switch(f){case 0:g=c.next0;case 1:if(g===c){f=3;break}f=4;return{value:g,done:!1};case 4:if(void 0===m){f=5;break}f=-1;throw m;case 5:case 2:g=g.next0;f=1;break;case 3:f=-1;default:return{value:void 0,done:!0}}}var f=0,g,n={next:function(c){return a(c,void 0)},throw:function(c){return a(void 0,c)},return:function(a){throw Error("Not yet implemented");
}};$jscomp.initSymbolIterator();n[Symbol.iterator]=function(){return this};return n}},{key:"reverseIterator",value:function(c){function a(a,m){for(;;)switch(f){case 0:g=c.prev0;case 1:if(g===c){f=3;break}f=4;return{value:g,done:!1};case 4:if(void 0===m){f=5;break}f=-1;throw m;case 5:case 2:g=g.prev0;f=1;break;case 3:f=-1;default:return{value:void 0,done:!0}}}var f=0,g,n={next:function(c){return a(c,void 0)},throw:function(c){return a(void 0,c)},return:function(a){throw Error("Not yet implemented");
}};$jscomp.initSymbolIterator();n[Symbol.iterator]=function(){return this};return n}},{key:"initializeHead",value:function(c){c.next0=c.prev0=c}}]);return c}();g.a=p},function(p,g,c){c.d(g,"a",function(){return n});var u=function(){function c(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(a,f,g){f&&c(a.prototype,f);g&&c(a,g);return a}}(),n=function(){function c(a){if(!(this instanceof
c))throw new TypeError("Cannot call a class as a function");this.parents=[];this.parentPriorities=[];this.bindings=new Map;if(void 0!==a){this.parents.push.apply(this.parents,[].concat($jscomp.arrayFromIterable(a.parents)));this.parentPriorities.push.apply(this.parentPriorities,[].concat($jscomp.arrayFromIterable(a.parentPriorities)));a=$jscomp.makeIterator(a.bindings);for(var f=a.next();!f.done;f=a.next()){var g=$jscomp.makeIterator(f.value);f=g.next().value;g=g.next().value;this.bindings.set(f,
g)}}}u(c,[{key:"addParent",value:function(a,c){for(var f=this,g=this.parents,t=this.parentPriorities,m=0,k=g.length;m<k&&c<t[m];)++m;g.splice(m,0,a);t.splice(m,0,c);return function(){f.removeParent(a)}}},{key:"removeParent",value:function(a){a=this.parents.indexOf(a);if(-1===a)throw Error("Attempt to remove non-existent parent map.");this.parents.splice(a,1);this.parentPriorities.splice(a,1)}},{key:"set",value:function(a,c){this.bindings.set(a,c)}},{key:"delete",value:function(a){this.bindings.delete(a)}},
{key:"clear",value:function(){this.bindings.clear();this.parents.length=0;this.parentPriorities.length=0}},{key:"get",value:function(a){for(var c=this.parents,g=this.parentPriorities,n=g.length,t=0,m;t<n&&0<g[t];++t)if(m=c[t].get(a),void 0!==m)return m;m=this.bindings.get(a);if(void 0!==m)return m;for(;t<n;++t)if(m=c[t].get(a),void 0!==m)return m}},{key:"getAll",value:function(a){function c(c,f){for(;;)switch(g){case 0:d=b,e=d.parents,k=d.parentPriorities,m=k.length,t=0;case 1:if(!(t<m&&0<k[t])){g=
2;break}n=e[t].get(a);if(void 0===n){g=3;break}g=4;return{value:n,done:!1};case 4:if(void 0===f){g=5;break}g=-1;throw f;case 5:case 3:g=1;break;case 2:n=b.bindings.get(a);if(void 0===n){g=6;break}g=7;return{value:n,done:!1};case 7:if(void 0===f){g=8;break}g=-1;throw f;case 8:case 6:case 9:if(!(t<m)){g=10;break}n=e[t].get(a);if(void 0===n){g=11;break}g=12;return{value:n,done:!1};case 12:if(void 0===f){g=13;break}g=-1;throw f;case 13:case 11:g=9;break;case 10:g=-1;default:return{value:void 0,done:!0}}}
var g=0,n,t,m,k,e,d,b=this,h={next:function(a){return c(a,void 0)},throw:function(a){return c(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();h[Symbol.iterator]=function(){return this};return h}}]);return c}()},function(p,g,c){g.a=function(c){var g=0;switch(c.deltaMode){case 0:g=.005;break;case 1:g=.1;break;case 2:g=2}return Math.exp(c.deltaY*g)}},function(p,g){},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+
typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function n(c,f){var g=c.memoize.get({type:"getSharedCredentialsProvider",credentialsProvider:Object(a.a)(f)},function(){return new q.a(f.addRef(),c.rpc)}),k=g.addCounterpartRef();g.dispose();return k}g.a=function(){return function(c){return function(c){function g(a){for(var e=[],d=0;d<arguments.length;++d)e[d-0]=arguments[d];
if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var b;d=(b=g.__proto__||Object.getPrototypeOf(g)).call.apply(b,[].concat([this],$jscomp.arrayFromIterable(e)));if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");b=!d||"object"!==typeof d&&"function"!==typeof d?this:d;b.credentialsProvider=e[1].credentialsProvider.addRef();return b}u(g,c);f(g,[{key:"initializeCounterpart",value:function(a,e){e.credentialsProvider=n(this.chunkManager,
this.credentialsProvider);l(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"initializeCounterpart",this).call(this,a,e)}}],[{key:"encodeOptions",value:function(c){var e=l(g.__proto__||Object.getPrototypeOf(g),"encodeOptions",this).call(this,c);e.credentialsProvider=Object(a.a)(c.credentialsProvider);return e}}]);return g}(c)}};var q=c(209),a=c(24),f=function(){function a(a,c){for(var f=0;f<c.length;f++){var e=c[f];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=
!0);Object.defineProperty(a,e.key,e)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),l=function t(a,c,e){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,c);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,c,e)}else{if("value"in d)return d.value;c=d.get;return void 0===c?void 0:c.call(e)}}},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);
a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return q});p=c(210);c=c(12);var n=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,g,n){g&&a(c.prototype,g);n&&a(c,n);return c}}();g=this&&this.__decorate||function(a,
c,g,n){var f=arguments.length,m=3>f?c:null===n?n=Object.getOwnPropertyDescriptor(c,g):n,k;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)m=Reflect.decorate(a,c,g,n);else for(var e=a.length-1;0<=e;e--)if(k=a[e])m=(3>f?k(m):3<f?k(c,g,m):k(c,g))||m;return 3<f&&m&&Object.defineProperty(c,g,m),m};var q=function(a){function c(a,f){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var g=(c.__proto__||Object.getPrototypeOf(c)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
g=!g||"object"!==typeof g&&"function"!==typeof g?this:g;g.provider=a;g.registerDisposer(a);g.initializeCounterpart(f);return g}u(c,a);n(c,[{key:"get",value:function(a,c){return this.provider.get(a,c)}}]);return c}(c.b);q=g([Object(c.g)(p.b)],q);Object(c.d)(p.a,function(a,c){return this.get(a.providerId).get(a.invalidCredentials,c).then(function(a){return{value:a}})})},function(p,g,c){g.b="CredentialsProvider";g.a="CredentialsProvider.get"},function(p,g,c){g.a=function(c){for(var g=0,p=c.length,a=
0;a<p;++a)g=31*g+c.charCodeAt(a)|0;return g}},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function n(a,c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function");}c.d(g,"d",function(){return q});
c.d(g,"e",function(){return a});c.d(g,"b",function(){return f});c.d(g,"c",function(){return l});c.d(g,"a",function(){return v});var q;(function(a){a[a.RAW=0]="RAW";a[a.JPEG=1]="JPEG";a[a.COMPRESSED_SEGMENTATION=2]="COMPRESSED_SEGMENTATION"})(q||(q={}));var a=function m(){n(this,m)};a.RPC_ID="brainmaps/VolumeChunkSource";var f=function k(){n(this,k)};f.RPC_ID="brainmaps/MeshSource";var l=function(a){function e(){n(this,e);var a=(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(e,a);return e}(f);l.RPC_ID="brainmaps/SkeletonSource";var v=function e(){n(this,e)};v.RPC_ID="brainmaps/Annotation"},function(p,g,c){g.b="mesh/MeshLayer";g.a="mesh/FragmentSource"},function(p,g,c){g.a="skeleton/SkeletonLayer"},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(102),n=c(121);p=c(32);Object(p.b)("brainmaps",function(c){return new u.BrainmapsDataSource(u.productionInstance,c.credentialsManager.getCredentialsProvider(n.a))})},
function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(84);p=c(32);Object(p.b)("ndstore",function(){return new u.NDStoreDataSource})},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&
c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function q(a,c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function");}c.d(g,"c",function(){return a});c.d(g,"d",function(){return f});c.d(g,"b",function(){return l});c.d(g,"a",function(){return v});var a;(function(a){a[a.JPEG=0]="JPEG";a[a.COMPRESSED_SEGMENTATION=1]="COMPRESSED_SEGMENTATION"})(a||(a={}));p=function m(){q(this,m)};
var f=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);f.RPC_ID="dvid/VolumeChunkSource";var l;(function(a){a[a.JPEG=0]="JPEG"})(l||(l={}));var v=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);v.RPC_ID="dvid/TileChunkSource"},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(125);p=c(32);Object(p.b)("dvid",function(){return new u.DVIDDataSource})},
function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function q(a,
c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function");}c.d(g,"b",function(){return a});c.d(g,"a",function(){return f});p=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(function v(){q(this,v)});var a=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);a.RPC_ID="render/TileChunkSource";var f=function(a){function c(){q(this,
c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);f.RPC_ID="render/PointMatchSource"},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});p=c(32);var u=c(126);Object(p.b)("render",function(){return new u.RenderDataSource})},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(129);p=c(32);Object(p.b)("openconnectome",function(){return new u.OpenConnectomeDataSource})},function(p,g,c){function u(a,c){if(!(a instanceof
c))throw new TypeError("Cannot call a class as a function");}c.d(g,"b",function(){return n});c.d(g,"c",function(){return q});c.d(g,"a",function(){return a});var n;(function(a){a[a.RAW=0]="RAW";a[a.JPEG=1]="JPEG";a[a.COMPRESSED_SEGMENTATION=2]="COMPRESSED_SEGMENTATION"})(n||(n={}));var q=function l(){u(this,l)};q.RPC_ID="precomputed/VolumeChunkSource";var a=function v(){u(this,v)};a.RPC_ID="precomputed/MeshSource"},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(130);p=c(32);
Object(p.b)("precomputed",function(){return new u.PrecomputedDataSource})},function(p,g,c){c.d(g,"b",function(){return n});g.a="nifti/getNiftiVolumeInfo";var u;(function(c){c[c.NONE=0]="NONE";c[c.BINARY=1]="BINARY";c[c.UINT8=2]="UINT8";c[c.INT16=4]="INT16";c[c.INT32=8]="INT32";c[c.FLOAT32=16]="FLOAT32";c[c.COMPLEX64=32]="COMPLEX64";c[c.FLOAT64=64]="FLOAT64";c[c.RGB24=128]="RGB24";c[c.INT8=256]="INT8";c[c.UINT16=512]="UINT16";c[c.UINT32=768]="UINT32";c[c.INT64=1024]="INT64";c[c.UINT64=1280]="UINT64";
c[c.FLOAT128=1536]="FLOAT128";c[c.COMPLEX128=1792]="COMPLEX128";c[c.COMPLEX256=2048]="COMPLEX256"})(u||(u={}));var n=function a(){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");};n.RPC_ID="nifti/VolumeChunkSource"},function(p,g,c){Object.defineProperty(g,"__esModule",{value:!0});var u=c(131);p=c(32);Object(p.b)("nifti",function(){return new u.NiftiDataSource})},function(p,g){},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function q(a,c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function");}c.d(g,"c",function(){return a});c.d(g,
"d",function(){return f});c.d(g,"a",function(){return l});c.d(g,"b",function(){return v});var a;(function(a){a[a.JPEG=0]="JPEG";a[a.NPZ=1]="NPZ";a[a.RAW=2]="RAW"})(a||(a={}));p=function m(){q(this,m)};var f=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);f.RPC_ID="python/VolumeChunkSource";var l=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);
l.RPC_ID="python/MeshSource";var v=function(a){function c(){q(this,c);return u(this,(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments))}n(c,a);return c}(p);v.RPC_ID="python/SkeletonSource"},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==
typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){return new b.a({shaderError:a.shaderError,fragmentMain:a.fragmentMain,fragmentMainStartLine:v.a})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"ImageUserLayer",function(){return z});p=c(14);g=c(20);
var f=c(41),l=c(18),v=c(231),t=c(56),m=c(134),k=c(135),e=c(47),d=c(89),b=c(90),h=c(35),r=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),x=function E(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return E(a,b,d)}else{if("value"in
c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(142);c(143);var z=function(a){function b(a,d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));c.opacity=Object(t.a)(.5);c.blendMode=Object(m.c)();c.fragmentMain=Object(v.c)();c.shaderError=Object(e.c)();c.registerDisposer(c.fragmentMain.changed.add(c.specificationChanged.dispatch));c.tabs.add("rendering",{label:"Rendering",order:-100,getter:function(){return new A(c)}});c.tabs.default="rendering";return c}
q(b,a);r(b,[{key:"restoreState",value:function(a){var d=this;x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"restoreState",this).call(this,a);this.opacity.restoreState(a.opacity);this.blendMode.restoreState(a.blend);this.fragmentMain.restoreState(a.shader);a=this.multiscaleSource;if(void 0===a)throw Error("source property must be specified");a.then(function(a){d.wasDisposed||(a=d.renderLayer=new v.b(a,{opacity:d.opacity,blendMode:d.blendMode,fragmentMain:d.fragmentMain,shaderError:d.shaderError,
transform:d.transform}),d.addRenderLayer(a),d.shaderError.changed.dispatch(),d.isReady=!0)})}},{key:"toJSON",value:function(){var a=x(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"toJSON",this).call(this);a.type="image";a.opacity=this.opacity.toJSON();a.blend=this.blendMode.toJSON();a.shader=this.fragmentMain.toJSON();return a}}]);return b}(Object(k.a)(p.h)),A=function(b){function c(b){u(this,c);var e=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));e.layer=b;e.opacityWidget=
e.registerDisposer(new d.a(e.layer.opacity));e.codeWidget=e.registerDisposer(a(e.layer));b=e.element;b.classList.add("image-dropdown");var f=e.opacityWidget,g=document.createElement("div");g.className="image-dropdown-top-row";f.promptElement.textContent="Opacity";f=document.createElement("div");f.style.flex="1";var h=document.createElement("a"),k=document.createElement("button");k.type="button";k.textContent="?";k.className="help-link";h.appendChild(k);h.title="Documentation on image layer rendering";
h.target="_blank";h.href="https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/image_layer_rendering.md";k=document.createElement("button");k.innerHTML="&square;";k.className="maximize-button";k.title="Show larger editor view";e.registerEventListener(k,"click",function(){new D(e.layer)});g.appendChild(e.opacityWidget.element);g.appendChild(f);g.appendChild(k);g.appendChild(h);b.appendChild(g);b.appendChild(e.codeWidget.element);e.codeWidget.textEditor.refresh();e.visibility.changed.add(function(){e.visible&&
e.codeWidget.textEditor.refresh()});return e}q(c,b);return c}(h.b),D=function(b){function d(b){u(this,d);var c=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));c.layer=b;c.codeWidget=c.registerDisposer(a(c.layer));c.content.classList.add("image-layer-shader-overlay");c.content.appendChild(c.codeWidget.element);c.codeWidget.textEditor.refresh();return c}q(d,b);return d}(f.a);Object(g.e)("image",z);Object(g.f)(l.c.IMAGE,z)},function(p,g){},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a){return Object(v.b)(void 0===a?"void main() {\n  emitGrayscale(toNormalized(getDataValue()));\n}\n":a)}g.c=q;c.d(g,
"b",function(){return e});p=c(133);var a=c(56),f=c(134),l=c(2),v=c(47),t=function(){function a(a,d){for(var b=0;b<d.length;b++){var c=d[b];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),m=function b(a,c,e){null===a&&(a=Function.prototype);var f=Object.getOwnPropertyDescriptor(a,c);if(void 0===f){if(a=Object.getPrototypeOf(a),null!==a)return b(a,c,e)}else{if("value"in f)return f.value;
c=f.get;return void 0===c?void 0:c.call(e)}};g.a="//NEUROGLANCER_IMAGE_RENDERLAYER_FRAGMENT_MAIN_START";var k=c(83),e=function(b){function c(b,e){e=void 0===e?{}:e;if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var g=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b,e)),h=e;b=void 0===h.opacity?Object(a.a)(.5):h.opacity;e=void 0===h.blendMode?Object(f.c)():h.blendMode;h=void 0===h.fragmentMain?q():h.fragmentMain;g.fragmentMain=h;g.opacity=b;g.blendMode=e;
g.registerDisposer(b.changed.add(function(){g.redrawNeeded.dispatch()}));g.registerDisposer(h.changed.add(function(){g.shaderGetter.invalidateShader();g.redrawNeeded.dispatch()}));return g}n(c,b);t(c,[{key:"getShaderKey",value:function(){return"volume.ImageRenderLayer:"+JSON.stringify(this.fragmentMain.value)}},{key:"defineShader",value:function(a){m(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"defineShader",this).call(this,a);a.addUniform("highp float","uOpacity");a.addFragmentCode("\nvoid emitRGBA(vec4 rgba) {\n  emit(vec4(rgba.rgb, rgba.a * uOpacity));\n}\nvoid emitRGB(vec3 rgb) {\n  emit(vec4(rgb, uOpacity));\n}\nvoid emitGrayscale(float value) {\n  emit(vec4(value, value, value, uOpacity));\n}\nvoid emitTransparent() {\n  emit(vec4(0.0, 0.0, 0.0, 0.0));\n}\n");
a.addFragmentCode(k);a.setFragmentMainFunction("//NEUROGLANCER_IMAGE_RENDERLAYER_FRAGMENT_MAIN_START\n"+this.fragmentMain.value)}},{key:"beginSlice",value:function(a){a=m(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"beginSlice",this).call(this,a);if(void 0!==a)return this.gl.uniform1f(a.uniform("uOpacity"),this.opacity.value),a}},{key:"setGLBlendMode",value:function(a,b){var c=Object(l.n)(this.blendMode.value,f.b);if(c===f.b.ADDITIVE||0<b)a.enable(a.BLEND),f.a.get(c)(a)}}]);return c}(p.a)},
function(p,g){},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
c):a.__proto__=c)}c.d(g,"a",function(){return l});p=c(0);var q=c(10),a=function(){function a(a,c){for(var f=0;f<c.length;f++){var e=c[f];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),f=function t(a,c,e){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,c);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,c,e)}else{if("value"in d)return d.value;
c=d.get;return void 0===c?void 0:c.call(e)}},l=function(c){function g(a){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var c=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));c.model=a;c.element=document.createElement("input");var d=c.element;d.classList.add("neuroglancer-color-widget");d.type="color";d.addEventListener("change",function(){return c.updateModel()});c.registerDisposer(a.changed.add(function(){return c.updateView()}));c.updateView();return c}
n(g,c);a(g,[{key:"updateView",value:function(){this.element.value=this.model.toString()}},{key:"updateModel",value:function(){this.model.restoreState(this.element.value)}},{key:"disposed",value:function(){Object(q.b)(this.element);f(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"disposed",this).call(this)}}]);return g}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==
typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return f});p=c(236);c.n(p);p=c(35);var q=c(137),a=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=
!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),f=function(c){function f(a){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var c=u(this,(f.__proto__||Object.getPrototypeOf(f)).call(this));c.transform=a;c.textArea=document.createElement("textarea");c.modelGeneration=-1;var g=c.element;g.classList.add("neuroglancer-coordinate-transform-widget");var e=c.textArea,d=document.createElement("label");
d.className="neuroglancer-coordinate-transform-widget-homogeneous";d.textContent="3\u00d74 Homogeneous transformation matrix";d.appendChild(e);g.appendChild(d);c.registerDisposer(a.changed.add(function(){return c.updateView()}));c.registerDisposer(c.visibility.changed.add(function(){return c.updateView()}));e.addEventListener("change",function(){return c.updateModel()});e.addEventListener("blur",function(){return c.updateModel()});e.title="Homogeneous transformation matrix";e.rows=3;a=document.createElement("button");
a.textContent="Reset to identity";a.addEventListener("click",function(){return c.transform.reset()});g.appendChild(a);c.updateView();return c}n(f,c);a(f,[{key:"updateView",value:function(){if(this.visible){var a=this.transform.changed.count;if(this.modelGeneration!==a){for(var c="",f=this.transform.transform,e=0;3>e;++e){0!==e&&(c+="\n");for(var d=0;4>d;++d){var b=f[4*d+e];0!==d&&(c+=" ");c+=Object(q.a)(b)}}this.textArea.value=c;this.modelGeneration=a}}}},{key:"updateModel",value:function(){var a=
this.textArea.value.split(/[\s,\[\]\(\)\{\}]/).filter(function(a){return 0<a.length});if(12===a.length){for(var c=[],f=0;12>f;++f){var e=parseFloat(a[f]);if(Number.isNaN(e))return!1;c[f]=e}a=this.transform.transform;a[3]=a[7]=a[10]=0;a[15]=1;for(f=0;4>f;++f)for(e=0;3>e;++e)a[4*f+e]=c[f+4*e];this.transform.changed.dispatch();return!0}return!1}}]);return f}(p.b)},function(p,g){},function(p,g){},function(p,g,c){(function(c){function g(a,d){function b(a){if(!e.parentNode)return c.off(document,"mousemove",
b);e.style.top=Math.max(0,a.clientY-e.offsetHeight-5)+"px";e.style.left=a.clientX+5+"px"}var e=document.createElement("div");e.className="CodeMirror-lint-tooltip";e.appendChild(d.cloneNode(!0));document.body.appendChild(e);c.on(document,"mousemove",b);b(a);null!=e.style.opacity&&(e.style.opacity=1);return e}function p(a){a.parentNode&&(null==a.style.opacity&&a.parentNode&&a.parentNode.removeChild(a),a.style.opacity=0,setTimeout(function(){a.parentNode&&a.parentNode.removeChild(a)},600))}function a(a,
d,e){function b(){c.off(e,"mouseout",b);f&&(p(f),f=null)}var f=g(a,d),h=setInterval(function(){if(f)for(var a=e;;a=a.parentNode){a&&11==a.nodeType&&(a=a.host);if(a==document.body)return;if(!a){b();break}}if(!f)return clearInterval(h)},400);c.on(e,"mouseout",b)}function f(b,d,c){this.marked=[];this.options=d;this.timeout=null;this.hasGutter=c;this.onMouseOver=function(d){var c=d.target||d.srcElement;if(/\bCodeMirror-lint-mark-/.test(c.className)){c=c.getBoundingClientRect();var e=b.findMarksAt(b.coordsChar({left:(c.left+
c.right)/2,top:(c.top+c.bottom)/2},"client"));c=[];for(var f=0;f<e.length;++f){var g=e[f].__annotation;g&&c.push(g)}if(c.length){e=d.target||d.srcElement;f=document.createDocumentFragment();for(g=0;g<c.length;g++)f.appendChild(t(c[g]));a(d,f,e)}}};this.waitingFor=0}function l(a){var b=a.state.lint;b.hasGutter&&a.clearGutter("CodeMirror-lint-markers");for(a=0;a<b.marked.length;++a)b.marked[a].clear();b.marked.length=0}function u(b,d,e,f){var g=document.createElement("div"),h=g;g.className="CodeMirror-lint-marker-"+
d;e&&(h=g.appendChild(document.createElement("div")),h.className="CodeMirror-lint-marker-multiple");if(0!=f)c.on(h,"mouseover",function(d){a(d,b,h)});return g}function t(a){var b=a.severity;b||(b="error");var d=document.createElement("div");d.className="CodeMirror-lint-message-"+b;"undefined"!=typeof a.messageHTML?d.innerHTML=a.messageHTML:d.appendChild(document.createTextNode(a.message));return d}function m(a,d,f){function b(){h=-1;a.off("change",b)}var g=a.state.lint,h=++g.waitingFor;a.on("change",
b);d(a.getValue(),function(d,f){a.off("change",b);g.waitingFor==h&&(f&&d instanceof c&&(d=f),e(a,d))},f,a)}function k(a){var b=a.state.lint.options,d=b.options||b,f=b.getAnnotations||a.getHelper(c.Pos(0,0),"lint");f&&(b.async||f.async?m(a,f,d):(b=f(a.getValue(),d,a))&&(b.then?b.then(function(b){e(a,b)}):e(a,b)))}function e(a,d){l(a);for(var b=a.state.lint,c=b.options,e=[],f=0;f<d.length;++f){var g=d[f],h=g.from.line;(e[h]||(e[h]=[])).push(g)}for(f=0;f<e.length;++f)if(g=e[f]){h=null;for(var k=b.hasGutter&&
document.createDocumentFragment(),m=0;m<g.length;++m){var n=g[m],p=n.severity;p||(p="error");"error"!=h&&(h=p);c.formatAnnotation&&(n=c.formatAnnotation(n));b.hasGutter&&k.appendChild(t(n));n.to&&b.marked.push(a.markText(n.from,n.to,{className:"CodeMirror-lint-mark-"+p,__annotation:n}))}b.hasGutter&&a.setGutterMarker(f,"CodeMirror-lint-markers",u(k,h,1<g.length,b.options.tooltips))}if(c.onUpdateLinting)c.onUpdateLinting(d,e,a)}function d(a){var b=a.state.lint;b&&(clearTimeout(b.timeout),b.timeout=
setTimeout(function(){k(a)},b.options.delay||500))}c.defineOption("lint",!1,function(a,e,g){g&&g!=c.Init&&(l(a),!1!==a.state.lint.options.lintOnChange&&a.off("change",d),c.off(a.getWrapperElement(),"mouseover",a.state.lint.onMouseOver),clearTimeout(a.state.lint.timeout),delete a.state.lint);if(e){var b=a.getOption("gutters");g=!1;for(var h=0;h<b.length;++h)"CodeMirror-lint-markers"==b[h]&&(g=!0);b=a.state;e instanceof Function?e={getAnnotations:e}:e&&!0!==e||(e={});g=b.lint=new f(a,e,g);if(!1!==g.options.lintOnChange)a.on("change",
d);if(0!=g.options.tooltips&&"gutter"!=g.options.tooltips)c.on(a.getWrapperElement(),"mouseover",g.onMouseOver);k(a)}});c.defineExtension("performLint",function(){this.state.lint&&k(this)})})(c(42))},function(p,g){},function(p,g){p.exports=function(c){function g(a){var c={};a=a.split(" ");for(var g=0;g<a.length;++g)c[a[g]]=!0;return c}c.defineMode("glsl",function(a,c){function f(a,d){var c=a.next();if(z[c]){var e=z[c](a,d);if(!1!==e)return e}if('"'==c||"'"==c)return d.tokenize=q(c),d.tokenize(a,d);
if(/[\[\]{}\(\),;\:\.]/.test(c))return y=c,"bracket";if(/\d/.test(c))return a.eatWhile(/[\w\.]/),"number";if("/"==c){if(a.eat("*"))return d.tokenize=t,t(a,d);if(a.eat("/"))return a.skipToEnd(),"comment"}if("#"==c)return a.eatWhile(/[\S]+/),a.eatWhile(/[\s]+/),a.eatWhile(/[\S]+/),a.eatWhile(/[\s]+/),"comment";if(D.test(c))return a.eatWhile(D),"operator";a.eatWhile(/[\w\$_]/);a=a.current();return b.propertyIsEnumerable(a)?(r.propertyIsEnumerable(a)&&(y="newstatement"),"keyword"):h.propertyIsEnumerable(a)?
"builtin":u.propertyIsEnumerable(a)?"atom":"word"}function q(a){return function(b,d){for(var c=!1,e,g=!1;null!=(e=b.next());){if(e==a&&!c){g=!0;break}c=!c&&"\\"==e}if(g||!c&&!A)d.tokenize=f;return"string"}}function t(a,b){for(var d=!1,c;c=a.next();){if("/"==c&&d){b.tokenize=f;break}d="*"==c}return"comment"}function m(a,b,d,c,e){this.indented=a;this.column=b;this.type=d;this.align=c;this.prev=e}function k(a,b,d){return a.context=new m(a.indented,b,d,null,a.context)}function e(a){var b=a.context.type;
if(")"==b||"]"==b||"}"==b)a.indented=a.context.indented;return a.context=a.context.prev}var d=a.indentUnit,b=c.keywords||g(n),h=c.builtins||g(p),r=c.blockKeywords||g("case do else for if switch while struct"),u=c.atoms||g("null"),z=c.hooks||{},A=c.multiLineStrings,D=/[+\-*&%=<>!?|\/]/,y;return{startState:function(a){return{tokenize:null,context:new m((a||0)-d,0,"top",!1),indented:0,startOfLine:!0}},token:function(a,b){var d=b.context;a.sol()&&(null==d.align&&(d.align=!1),b.indented=a.indentation(),
b.startOfLine=!0);if(a.eatSpace())return null;y=null;var c=(b.tokenize||f)(a,b);if("comment"==c||"meta"==c)return c;null==d.align&&(d.align=!0);if(";"!=y&&":"!=y||"statement"!=d.type)if("{"==y)k(b,a.column(),"}");else if("["==y)k(b,a.column(),"]");else if("("==y)k(b,a.column(),")");else if("}"==y){for(;"statement"==d.type;)d=e(b);for("}"==d.type&&(d=e(b));"statement"==d.type;)d=e(b)}else y==d.type?e(b):("}"==d.type||"top"==d.type||"statement"==d.type&&"newstatement"==y)&&k(b,a.column(),"statement");
else e(b);b.startOfLine=!1;return c},indent:function(a,b){if(a.tokenize!=f&&null!=a.tokenize)return 0;b=b&&b.charAt(0);a=a.context;var c=b==a.type;return"statement"==a.type?a.indented+("{"==b?0:d):a.align?a.column+(c?0:1):a.indented+(c?0:d)},electricChars:"{}"}});var n="attribute const uniform varying break continue do for while if else in out inout float int void bool true false lowp mediump highp precision invariant discard return mat2 mat3 mat4 vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 sampler2D samplerCube struct gl_FragCoord gl_FragColor",
p="radians degrees sin cos tan asin acos atan pow exp log exp2 log2 sqrt inversesqrt abs sign floor ceil fract mod min max clamp mix step smoothstep length distance dot cross normalize faceforward reflect refract matrixCompMult lessThan lessThanEqual greaterThan greaterThanEqual equal notEqual any all not dFdx dFdy fwidth texture2D texture2DProj texture2DLod texture2DProjLod textureCube textureCubeLod require export";c.defineMIME("text/x-glsl",{name:"glsl",keywords:g(n),builtins:g(p),blockKeywords:g("case do else for if switch while struct"),
atoms:g("null"),hooks:{"#":function(a,c){if(!c.startOfLine)return!1;a.skipToEnd();return"meta"}}})}},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b,d,c){c=void 0===c?{}:c;return v.a.forPromise(new Promise(function(e){e(a.getVectorGraphicsSource(b,d,c))}),{initialMessage:"Retrieving metadata for vector graphics source "+d+".",delay:!0,errorPrefix:"Error retrieving metadata for vector graphics source "+d+": "})}Object.defineProperty(g,"__esModule",
{value:!0});c.d(g,"VectorGraphicsUserLayer",function(){return A});p=c(14);g=c(20);var f=c(127),l=c(242),v=c(25),t=c(56),m=c(144),k=c(145),e=c(1),d=c(2),b=c(89),h=c(35),r=c(243),x=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),z=function G(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,
b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return G(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(142);c(143);var A=function(b){function c(b,g){u(this,c);var h=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b,g));h.opacity=Object(t.a)(.5);h.lineWidth=Object(m.a)(10);h.color=Object(k.a)(e.s.fromValues(1,1,1));h.opacity.restoreState(g.opacity);h.lineWidth.restoreState(g.linewidth);h.color.restoreState(g.color);h.lineWidth.changed.add(function(){h.specificationChanged.dispatch()});
h.color.changed.add(function(){h.specificationChanged.dispatch()});h.vectorGraphicsLayerType=Object(d.n)(g.type,f.b);g=h.vectorGraphicsPath=Object(d.z)(g.source);var r=0;void 0!==g&&(++r,h.vectorGraphicsLayerType===f.b.LINE&&a(b.dataSourceProvider,b.chunkManager,g).then(function(a){h.wasDisposed||(a=h.renderLayer=new l.a(a,{opacity:h.opacity,lineWidth:h.lineWidth,color:h.color,sourceOptions:{}}),h.addRenderLayer(a),0===--r&&(h.isReady=!0))}));h.tabs.add("rendering",{label:"Rendering",order:-100,getter:function(){return new D(h)}});
h.tabs.default="rendering";return h}q(c,b);x(c,[{key:"toJSON",value:function(){var a=z(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"toJSON",this).call(this);a.type=this.getLayerType();a.source=this.vectorGraphicsPath;a.opacity=this.opacity.toJSON();a.linewidth=this.lineWidth.toJSON();a.color=this.color.toJSON();return a}},{key:"getLayerType",value:function(){return f.b[this.vectorGraphicsLayerType].toLowerCase()}}]);return c}(p.h),D=function(a){function d(a){u(this,d);var c=n(this,(d.__proto__||
Object.getPrototypeOf(d)).call(this));c.layer=a;c.opacityWidget=c.registerDisposer(new b.a(c.layer.opacity));c.lineWidthWidget=c.registerDisposer(new b.a(c.layer.lineWidth,{min:0,max:50,step:1}));c.colorWidget=c.registerDisposer(new y(c.layer.color));a=c.element;a.classList.add("image-dropdown");var e=c.opacityWidget,f=c.lineWidthWidget,g=c.colorWidget,h=document.createElement("div");h.className="image-dropdown-top-row";e.promptElement.textContent="Opacity";f.promptElement.textContent="Line Width";
g.promptElement.textContent="Color";e=document.createElement("div");e.style.flex="1";f=document.createElement("a");g=document.createElement("button");g.type="button";g.textContent="?";g.className="help-link";f.appendChild(g);f.title="Documentation on vector graphics layer rendering";f.target="_blank";f.href="https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/vectorgraphics_layer_rendering.md";h.appendChild(e);h.appendChild(f);a.appendChild(h);a.appendChild(c.opacityWidget.element);
a.appendChild(c.lineWidthWidget.element);a.appendChild(c.colorWidget.element);return c}q(d,a);return d}(h.b),y=function(a){function b(a){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a))}q(b,a);x(b,[{key:"verifyValue",value:function(a){a=Object(d.o)(a);a/=255;return 0>a?0:1<a?1:a}},{key:"updateInput",value:function(){this.inputx.valueAsNumber=Math.round(255*this.model.value[0]);this.inputy.valueAsNumber=Math.round(255*this.model.value[1]);this.inputz.valueAsNumber=Math.round(255*
this.model.value[2])}}]);return b}(r.a);Object(g.e)("line",A)},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return b});var q=c(36);p=c(128);var a=c(56),f=c(144),l=c(145),v=c(1),t=c(15),m=c(11),k=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),e=function r(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===
c){if(a=Object.getPrototypeOf(a),null!==a)return r(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},d=v.k.create(),b=function(b){function c(b,d){var e=void 0===d?{}:d;d=void 0===e.opacity?Object(a.a)(.5):e.opacity;var g=void 0===e.lineWidth?Object(f.a)(10):e.lineWidth,k=void 0===e.color?Object(l.a)(v.s.fromValues(255,255,255)):e.color;e=void 0===e.sourceOptions?{}:e.sourceOptions;if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");
var m=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b,{sourceOptions:e}));m.opacity=d;m.registerDisposer(d.changed.add(function(){m.redrawNeeded.dispatch()}));m.lineWidth=g;m.registerDisposer(g.changed.add(function(){m.redrawNeeded.dispatch()}));m.color=k;m.registerDisposer(k.changed.add(function(){m.redrawNeeded.dispatch()}));b=m.gl;d=new Float32Array([1,0,0,1,1,0,0,1]);m.vertexIndexBuffer=m.registerDisposer(t.a.fromData(b,d,b.ARRAY_BUFFER,b.STATIC_DRAW));d=new Float32Array([1,1,-1,-1]);
m.normalDirectionBuffer=m.registerDisposer(t.a.fromData(b,d,b.ARRAY_BUFFER,b.STATIC_DRAW));return m}n(c,b);k(c,[{key:"getShaderKey",value:function(){return"vectorgraphics.VectorGraphicsLineRenderLayer"}},{key:"defineShader",value:function(a){e(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"defineShader",this).call(this,a);a.addUniform("highp float","uOpacity");a.addUniform("highp float","ulineWidth");a.addUniform("highp vec3","uColor");a.addVarying("vec3","vNormal");a.addAttribute("highp float",
"aNormalDirection");a.addAttribute("highp vec2","aVertexIndex");a.addAttribute("highp vec3","aVertexFirst");a.addAttribute("highp vec3","aVertexSecond");a.addUniform("highp mat4","uProjection");a.setFragmentMain("\nfloat distance = length(vNormal);\n\nfloat antialiasing = 0.5;\n\nif (distance >= 1.0 - antialiasing) {\n  emitRGBA(vec4(uColor, (distance - 1.0) / -antialiasing ));\n}\nelse if (distance < 1.0 - antialiasing) {\n  emitRGB(uColor);\n}\n");a.setVertexMain("\nvec3 direction = vec3(0., 0., 0.);\ndirection.z = aNormalDirection;\n\nvec3 difference = aVertexSecond - aVertexFirst;\ndifference.z = 0.;\n\nvec3 normal = cross(difference, direction);\nnormal = normalize(normal);\nvNormal = normal;\n\nvec4 delta = vec4(normal * ulineWidth, 0.0);\nvec4 pos = vec4(aVertexFirst * aVertexIndex.x + aVertexSecond * aVertexIndex.y, 1.0);\n\ngl_Position = uProjection * (pos + delta);\n")}},
{key:"beginSlice",value:function(a){e(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"beginSlice",this).call(this,a);a=this.gl;var b=this.shader;a.uniform1f(b.uniform("uOpacity"),this.opacity.value);a.uniform1f(b.uniform("ulineWidth"),this.lineWidth.value);a.uniform3fv(b.uniform("uColor"),this.color.value);this.vertexIndexBuffer.bindToVertexAttrib(b.attribute("aVertexIndex"),2);this.normalDirectionBuffer.bindToVertexAttrib(b.attribute("aNormalDirection"),1);return b}},{key:"endSlice",value:function(a){var b=
this.gl;b.disableVertexAttribArray(a.attribute("aVertexIndex"));b.disableVertexAttribArray(a.attribute("aNormalDirection"));b.disableVertexAttribArray(a.attribute("aVertexFirst"));b.disableVertexAttribArray(a.attribute("aVertexSecond"))}},{key:"draw",value:function(a){var b=a.visibleLayers.get(this);if(0!==b.length){var c=this.gl,e=this.beginSlice(a);if(void 0===e)console.log("error: shader undefined");else{b=$jscomp.makeIterator(b);for(var f=b.next();!f.done;f=b.next()){f=f.value;var g=f.chunkLayout,
k=f.source,l=k.spec.voxelSize;f=k.chunks;var r=d;v.k.identity(r);k.vectorGraphicsCoordinatesInVoxels&&v.k.scale(r,r,l);v.k.multiply(r,g.transform,r);c.uniformMatrix4fv(e.uniform("uProjection"),!1,v.k.multiply(d,a.dataToDevice,r));if(g=a.visibleChunks.get(g))for(g=$jscomp.makeIterator(g),k=g.next();!k.done;k=g.next())if((k=f.get(k.value))&&k.state===q.d.GPU_MEMORY){l=k.numPoints/2;r=e.attribute("aVertexFirst");k.vertexBuffer.bindToVertexAttrib(r,3,m.g,!1,24,0);c.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(r,
1);var n=e.attribute("aVertexSecond");k.vertexBuffer.bindToVertexAttrib(n,3,m.g,!1,24,12);c.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(n,1);c.ANGLE_instanced_arrays.drawArraysInstancedANGLE(c.TRIANGLE_STRIP,0,4,l);c.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(r,0);c.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(n,0)}}this.endSlice(e)}}}}]);return c}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||
"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return t});p=c(0);var q=c(1),a=c(2),f=c(3),l=function(){function a(a,c){for(var d=0;d<c.length;d++){var b=c[d];b.enumerable=
b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),v=function k(a,d,b){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,d);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in c)return c.value;d=c.get;return void 0===d?void 0:d.call(b)}};c(244);var t=function(c){function e(a){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");
var b=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));b.model=a;b.promptElement=document.createElement("span");b.element=document.createElement("label");b.inputx=document.createElement("input");b.inputy=document.createElement("input");b.inputz=document.createElement("input");b.valueEntered=new f.b;a=b.inputx;var d=b.inputy,c=b.inputz,g=b.element,k=b.promptElement;g.className="vec3-input-row";k.className="vec3-input-label";g.appendChild(k);g.appendChild(a);g.appendChild(d);g.appendChild(c);
a.type=d.type=c.type="number";b.updateInput();g=function(){b.model.value=b.getVec3Values()};b.registerEventListener(a,"change",g);b.registerEventListener(d,"change",g);b.registerEventListener(c,"change",g);b.model.changed.add(function(){b.updateInput()});return b}n(e,c);l(e,[{key:"getVec3Values",value:function(){var a=q.s.create();a[0]=this.verifyValue(this.inputx.valueAsNumber);a[1]=this.verifyValue(this.inputy.valueAsNumber);a[2]=this.verifyValue(this.inputz.valueAsNumber);return a}},{key:"verifyValue",
value:function(d){return Object(a.o)(d)}},{key:"updateInput",value:function(){this.inputx.valueAsNumber=this.model.value[0];this.inputy.valueAsNumber=this.model.value[1];this.inputz.valueAsNumber=this.model.value[2]}},{key:"disposed",value:function(){var a=this.inputx,b=this.inputy,c=this.inputz,f=this.element;a.parentElement&&a.parentElement.removeChild(a);b.parentElement&&b.parentElement.removeChild(b);c.parentElement&&c.parentElement.removeChild(c);f.parentElement&&f.parentElement.removeChild(f);
v(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}}]);return e}(p.a)},function(p,g){},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){return new C.a({fragmentMain:a.displayState.fragmentMain,shaderError:a.displayState.shaderError,fragmentMainStartLine:e.a})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"SegmentationUserLayer",function(){return N});p=c(14);g=c(20);var f=c(55),l=c(41),v=c(146),t=c(67),m=c(246),k=c(74),e=c(82),
d=c(18),b=c(248),h=c(56),r=c(57),x=c(5),z=c(249),A=c(135),D=c(2),y=c(3),E=c(23),G=c(47),H=c(89),B=c(250),C=c(90),F=c(35),M=c(252),I=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),P=function W(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),
null!==a)return W(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(40);c(254);var N=function(a){function c(a,b){u(this,c);var d=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,a,b));d.manager=a;d.displayState={segmentColorHash:v.a.getDefault(),segmentSelectionState:new t.a,selectedAlpha:Object(h.a)(.5),saturation:Object(h.a)(1),notSelectedAlpha:Object(h.a)(0),objectAlpha:Object(h.a)(1),clipBounds:k.a.make(d.manager.worker,void 0),hideSegmentZero:new r.b(!0,
!0),visibleSegments:z.a.makeWithCounterpart(d.manager.worker),highlightedSegments:z.a.makeWithCounterpart(d.manager.worker),segmentEquivalences:m.a.makeWithCounterpart(d.manager.worker),objectToDataTransform:d.transform,fragmentMain:Object(e.f)(),shaderError:Object(G.c)()};d.objectLayerStateChanged=new y.a;d.displayState.visibleSegments.changed.add(function(){return d.specificationChanged.dispatch()});d.displayState.segmentEquivalences.changed.add(function(){return d.specificationChanged.dispatch()});
d.displayState.segmentSelectionState.bindTo(a.layerSelectedValues,d);d.displayState.selectedAlpha.changed.add(function(){return d.specificationChanged.dispatch()});d.displayState.notSelectedAlpha.changed.add(function(){return d.specificationChanged.dispatch()});d.displayState.objectAlpha.changed.add(function(){return d.specificationChanged.dispatch()});d.displayState.hideSegmentZero.changed.add(function(){return d.specificationChanged.dispatch()});d.displayState.fragmentMain.changed.add(function(){return d.specificationChanged.dispatch()});
d.tabs.add("rendering",{label:"Rendering",order:-100,getter:function(){return new U(d)}});d.tabs.default="rendering";return d}q(c,a);I(c,[{key:"restoreState",value:function(a){var d=this;P(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"restoreState",this).call(this,a);this.displayState.selectedAlpha.restoreState(a.selectedAlpha);this.displayState.saturation.restoreState(a.saturation);this.displayState.notSelectedAlpha.restoreState(a.notSelectedAlpha);this.displayState.objectAlpha.restoreState(a.objectAlpha);
this.displayState.hideSegmentZero.restoreState(a.hideSegmentZero);this.displayState.fragmentMain.restoreState(a.skeletonShader);Object(D.w)(a,"equivalences",function(a){d.displayState.segmentEquivalences.restoreState(a)});var g=function(b,c){Object(D.w)(a,b,function(a){if(void 0!==a){var b=d.displayState.segmentEquivalences;Object(D.a)(a,function(a){a=E.a.parseString(String(a),10);c.add(b.get(a))})}})};g("segments",this.displayState.visibleSegments);g("highlights",this.displayState.highlightedSegments);
Object(D.w)(a,"clipBounds",function(a){if(void 0!==a){var b,c;Object(D.w)(a,"center",function(a){return b=Object(D.l)(a)});Object(D.w)(a,"size",function(a){return c=Object(D.l)(a)});b&&c&&(d.displayState.clipBounds.value={center:b,size:c})}});this.displayState.highlightedSegments.changed.add(function(){d.specificationChanged.dispatch()});g=this.multiscaleSource;var h=this.meshPath=null===a.mesh?null:Object(D.z)(a.mesh),k=this.skeletonsPath=Object(D.w)(a,"skeletons",D.z),m=0;null!=h&&(++m,this.manager.dataSourceProvider.getMeshSource(this.manager.chunkManager,
h).then(function(a){d.wasDisposed||(d.addMesh(a),0===--m&&(d.isReady=!0))}));void 0!==k&&(++m,this.manager.dataSourceProvider.getSkeletonSource(this.manager.chunkManager,k).then(function(a){d.wasDisposed||(d.addSkeletonSource(a),0===--m&&(d.isReady=!0))}));void 0!==g&&(++m,g.then(function(a){d.wasDisposed||(d.addRenderLayer(new b.a(a,d.displayState)),void 0===h&&void 0===k&&(++m,Promise.resolve(a.getMeshSource()).then(function(a){d.wasDisposed?null!==a&&a.dispose():(0===--m&&(d.isReady=!0),a instanceof
f.b?(d.addMesh(a),d.objectLayerStateChanged.dispatch()):a instanceof e.d&&(d.addSkeletonSource(a),d.objectLayerStateChanged.dispatch()))})),0===--m&&(d.isReady=!0))}))}},{key:"addMesh",value:function(a){this.meshLayer=new f.a(this.manager.chunkManager,a,this.displayState);this.addRenderLayer(this.meshLayer)}},{key:"addSkeletonSource",value:function(a){this.skeletonLayer=a=new e.c(this.manager.chunkManager,a,this.manager.voxelSize,this.displayState);this.addRenderLayer(new e.b(a.addRef()));this.addRenderLayer(new e.e(a))}},
{key:"toJSON",value:function(){var a=P(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"toJSON",this).call(this);a.type="segmentation";a.mesh=this.meshPath;a.skeletons=this.skeletonsPath;a.selectedAlpha=this.displayState.selectedAlpha.toJSON();a.notSelectedAlpha=this.displayState.notSelectedAlpha.toJSON();a.saturation=this.displayState.saturation.toJSON();a.objectAlpha=this.displayState.objectAlpha.toJSON();a.hideSegmentZero=this.displayState.hideSegmentZero.toJSON();var b=this.displayState.visibleSegments;
0<b.size&&(a.segments=b.toJSON());b=this.displayState.highlightedSegments;0<b.size&&(a.highlights=b.toJSON());b=this.displayState.segmentEquivalences;0<b.size&&(a.equivalences=b.toJSON());b=this.displayState.clipBounds;b.value&&(a.clipBounds={center:Array.from(b.value.center),size:Array.from(b.value.size)});a.skeletonShader=this.displayState.fragmentMain.toJSON();return a}},{key:"transformPickedValue",value:function(a){if(null==a)return a;var b=this.displayState.segmentEquivalences;if(0===b.size)return a;
"number"===typeof a&&(a=new E.a(a,0));b=b.get(a);return E.a.equal(b,a)?a:new t.c(a,b)}},{key:"handleAction",value:function(a){switch(a){case "recolor":this.displayState.segmentColorHash.randomize();break;case "clear-segments":this.displayState.visibleSegments.clear();break;case "select":a=this.displayState.segmentSelectionState;if(a.hasSelectedSegment){a=a.selectedSegment;var b=this.displayState.visibleSegments;b.has(a)?b.delete(a):b.add(a)}break;case "highlight":a=this.displayState.segmentSelectionState,
a.hasSelectedSegment&&(a=a.selectedSegment,b=this.displayState.highlightedSegments,b.has(a)?b.delete(a):b.add(a))}}},{key:"volumeOptions",get:function(){return{volumeType:d.c.SEGMENTATION}}}]);return c}(Object(A.a)(p.h)),U=function(b){function d(b){u(this,d);var c=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));c.layer=b;c.visibleSegmentWidget=c.registerDisposer(new B.a(c.layer.displayState));c.addSegmentWidget=c.registerDisposer(new M.a);c.selectedAlphaWidget=c.registerDisposer(new H.a(c.layer.displayState.selectedAlpha));
c.notSelectedAlphaWidget=c.registerDisposer(new H.a(c.layer.displayState.notSelectedAlpha));c.saturationWidget=c.registerDisposer(new H.a(c.layer.displayState.saturation));c.objectAlphaWidget=c.registerDisposer(new H.a(c.layer.displayState.objectAlpha));var e=c.element;e.classList.add("segmentation-dropdown");var f=c.notSelectedAlphaWidget,g=c.saturationWidget,h=c.objectAlphaWidget;c.selectedAlphaWidget.promptElement.textContent="Opacity (on)";f.promptElement.textContent="Opacity (off)";g.promptElement.textContent=
"Saturation";h.promptElement.textContent="Opacity (3d)";void 0!==c.layer.volumePath&&(e.appendChild(c.selectedAlphaWidget.element),e.appendChild(c.notSelectedAlphaWidget.element),e.appendChild(c.saturationWidget.element));c.registerDisposer(new r.a(c.registerDisposer(new x.a(function(){return c.layer.meshPath||c.layer.meshLayer||c.layer.skeletonsPath||c.layer.skeletonLayer?!0:!1},c.layer.objectLayerStateChanged)),c.objectAlphaWidget.element));e.appendChild(c.objectAlphaWidget.element);b=c.registerDisposer(new r.c(b.displayState.hideSegmentZero));
b.element.className="neuroglancer-segmentation-dropdown-hide-segment-zero neuroglancer-noselect";f=document.createElement("label");f.className="neuroglancer-segmentation-dropdown-hide-segment-zero neuroglancer-noselect";f.appendChild(document.createTextNode("Hide segment ID 0"));f.appendChild(b.element);e.appendChild(f);c.addSegmentWidget.element.classList.add("add-segment");c.addSegmentWidget.element.title="Add one or more segment IDs";e.appendChild(c.registerDisposer(c.addSegmentWidget).element);
c.registerDisposer(c.addSegmentWidget.valuesEntered.add(function(a){a=$jscomp.makeIterator(a);for(var b=a.next();!b.done;b=a.next())c.layer.displayState.visibleSegments.add(b.value)}));e.appendChild(c.registerDisposer(c.visibleSegmentWidget).element);b=function(){if(void 0===c.codeWidget&&null!==c.layer.skeletonsPath&&void 0!==c.layer.skeletonLayer){var b=document.createElement("div");b.className="neuroglancer-segmentation-dropdown-skeleton-shader-header";var d=document.createElement("div");d.style.flex=
"1";d.textContent="Skeleton shader:";var f=document.createElement("a"),g=document.createElement("button");g.type="button";g.textContent="?";g.className="help-link";f.appendChild(g);f.title="Documentation on skeleton rendering";f.target="_blank";f.href="https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/image_layer_rendering.md";g=document.createElement("button");g.innerHTML="&square;";g.className="maximize-button";g.title="Show larger editor view";c.registerEventListener(g,
"click",function(){new O(c.layer)});b.appendChild(d);b.appendChild(g);b.appendChild(f);e.appendChild(b);b=c.codeWidget=c.registerDisposer(a(c.layer));e.appendChild(b.element);b.textEditor.refresh()}};c.registerDisposer(c.layer.objectLayerStateChanged.add(b));b();c.visibility.changed.add(function(){c.visible&&void 0!==c.codeWidget&&c.codeWidget.textEditor.refresh()});return c}q(d,b);return d}(F.b),O=function(b){function d(b){u(this,d);var c=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));
c.layer=b;c.codeWidget=c.registerDisposer(a(c.layer));c.content.classList.add("neuroglancer-segmentation-layer-skeleton-shader-overlay");c.content.appendChild(c.codeWidget.element);c.codeWidget.textEditor.refresh();return c}q(d,b);return d}(l.a);Object(g.e)("segmentation",N);Object(g.f)(d.c.SEGMENTATION,N)},function(p,g,c){function u(a,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);a.prototype=Object.create(d&&d.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(a,d):a.__proto__=d)}c.d(g,"a",function(){return t});var n=c(247),q=c(2),a=c(3),f=c(23);p=c(12);var l=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(d,b,c){b&&a(d.prototype,b);c&&a(d,c);return d}}(),v=function d(a,c,f){null===a&&(a=Function.prototype);
var b=Object.getOwnPropertyDescriptor(a,c);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return d(a,c,f)}else{if("value"in b)return b.value;c=b.get;return void 0===c?void 0:c.call(f)}};g=this&&this.__decorate||function(a,b,c,f){var d=arguments.length,g=3>d?b:null===f?f=Object.getOwnPropertyDescriptor(b,c):f,h;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)g=Reflect.decorate(a,b,c,f);else for(var k=a.length-1;0<=k;k--)if(h=a[k])g=(3>d?h(g):3<d?h(b,c,g):h(b,c))||g;return 3<
d&&g&&Object.defineProperty(b,c,g),g};var t=function(d){function b(){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");var d=(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");d=!d||"object"!==typeof d&&"function"!==typeof d?this:d;d.disjointSets=new n.a;d.changed=new a.a;return d}u(b,d);l(b,[{key:"disposed",value:function(){this.changed=this.disjointSets=void 0;
v(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"link",value:function(a,b){if(this.disjointSets.link(a,b)){var d=this.rpc;d&&d.invoke("DisjointUint64Sets.add",{id:this.rpcId,al:a.low,ah:a.high,bl:b.low,bh:b.high});this.changed.dispatch()}}},{key:"get",value:function(a){return this.disjointSets.get(a)}},{key:"clear",value:function(){if(this.disjointSets.clear()){var a=this.rpc;a&&a.invoke("DisjointUint64Sets.clear",{id:this.rpcId});this.changed.dispatch()}}},
{key:"setElements",value:function(a){return this.disjointSets.setElements(a)}},{key:"toJSON",value:function(){return this.disjointSets.toJSON()}},{key:"restoreState",value:function(a){var b=this;this.clear();if(void 0!==a){var d=[new f.a,new f.a];Object(q.a)(a,function(a){Object(q.a)(a,function(a,c){d[c%2].parseString(String(a),10);0!==c&&b.link(d[0],d[1])})})}}},{key:"size",get:function(){return this.disjointSets.size}}],[{key:"makeWithCounterpart",value:function(a){var b=new this;b.initializeCounterpart(a);
return b}}]);return b}(p.c);t=g([Object(p.f)("DisjointUint64Sets")],t);var m=new f.a,k=new f.a;Object(p.e)("DisjointUint64Sets.add",function(a){var b=this.get(a.id);m.low=a.al;m.high=a.ah;k.low=a.bl;k.high=a.bh;b.disjointSets.link(m,k)&&b.changed.dispatch()});Object(p.e)("DisjointUint64Sets.clear",function(a){a=this.get(a.id);a.disjointSets.clear()&&a.changed.dispatch()})},function(p,g,c){function u(a){for(var d=a,b=a[l];b!==a;)a=b,b=a[l];for(a=d[l];b!==a;)d[l]=b,d=a,a=d[l];return b}function n(a){function d(d,
f){for(;;)switch(b){case 0:e=!0,c=a;case 1:if(!e&&c===a){b=3;break}b=4;return{value:c,done:!1};case 4:if(void 0===f){b=5;break}b=-1;throw f;case 5:c=c[v];case 2:e=!1;b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,c,e,f={next:function(a){return d(a,void 0)},throw:function(a){return d(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();f[Symbol.iterator]=function(){return this};return f}c.d(g,"a",function(){return k});var q=c(23),a=function(){function a(a,
b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(d,b,c){b&&a(d.prototype,b);c&&a(d,c);return d}}();$jscomp.initSymbol();var f=Symbol("disjoint_sets:rank");$jscomp.initSymbol();var l=Symbol("disjoint_sets:parent");$jscomp.initSymbol();var v=Symbol("disjoint_sets:next");$jscomp.initSymbol();var t=Symbol("disjoint_sets:prev");$jscomp.initSymbol();var m=Symbol("disjoint_sets:min"),k=
function(){function c(){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");this.map=new Map;this.generation=0}$jscomp.initSymbol();$jscomp.initSymbolIterator();a(c,[{key:"get",value:function(a){var b=this.map.get(a.toString());return void 0===b?a:u(b)[m]}},{key:"isMinElement",value:function(a){var b=this.get(a);return b===a||q.a.equal(b,a)}},{key:"makeSet",value:function(a){var b=a.toString(),d=this.map,c=d.get(b);return void 0===c?(a=c=a.clone(),a[l]=a,a[f]=0,a[v]=a[t]=
a,c[m]=c,d.set(b,c),c):u(c)}},{key:"link",value:function(a,b){a=this.makeSet(a);b=this.makeSet(b);if(a===b)return!1;this.generation++;var d=a;var c=b,e=d[f],g=c[f];e>g?c[l]=d:(d[l]=c,e===g&&(c[f]=g+1),d=c);c=a;e=b;g=c[t];var k=e[t];e[t]=g;g[v]=e;c[t]=k;k[v]=c;a=a[m];b=b[m];d[m]=q.a.less(a,b)?a:b;return!0}},{key:"setElements",value:function(a){function b(b,h){for(;;)switch(d){case 0:g=a.toString();f=k.map.get(g);if(void 0!==f){d=1;break}d=3;return{value:a,done:!1};case 3:if(void 0===h){d=4;break}d=
-1;throw h;case 4:d=2;break;case 1:e=$jscomp.makeIterator(n(f));case 5:if((c=e.next(b)).done){d=6;break}d=7;return{value:c.value,done:!1};case 7:if(void 0===h){d=8;break}d=-1;throw h;case 8:d=5;break;case 6:case 2:d=-1;default:return{value:void 0,done:!0}}}var d=0,c,e,f,g,k=this,m={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();m[Symbol.iterator]=function(){return this};return m}},{key:"clear",
value:function(){var a=this.map;if(0===a.size)return!1;++this.generation;a.clear();return!0}},{key:"mappings",value:function(a){function b(b,h){for(;;)switch(d){case 0:a=void 0===a?Array(2):a,f=$jscomp.makeIterator(g.map.values()),e=f.next();case 1:if(e.done){d=3;break}c=e.value;a[0]=c;a[1]=u(c)[m];d=4;return{value:a,done:!1};case 4:if(void 0===h){d=5;break}d=-1;throw h;case 5:case 2:e=f.next();d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,c,e,f,g=this,k={next:function(a){return b(a,
void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();k[Symbol.iterator]=function(){return this};return k}},{key:Symbol.iterator,value:function(){return this.mappings()}},{key:"toJSON",value:function(){for(var a=[],b=$jscomp.makeIterator(this.map.values()),c=b.next();!c.done;c=b.next()){var e=c.value;if(e[l]===e){c=[];e=$jscomp.makeIterator(n(e));for(var f=e.next();!f.done;f=e.next())c.push(f.value);c.sort(q.a.compare);
a.push(c)}}a.sort(function(a,b){return q.a.compare(a[0],b[0])});return a.map(function(a){return a.map(function(a){return a.toString()})})}},{key:"size",get:function(){return this.map.size}}]);return c}()},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}c.d(g,"a",function(){return b});var a=c(92),f=c(147),l=c(146),v=c(67);p=c(133);var t=c(16),m=function r(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),
null!==a)return r(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},k=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),e=new Float32Array(8),d=function(){function b(d){q(this,b);this.disjointSets=d;this.generation=Number.NaN;this.hashMap=new a.a}k(b,[{key:"update",value:function(){var a=
this.disjointSets,b=a.generation;if(this.generation!==b){this.generation=b;b=this.hashMap;b.clear();a=$jscomp.makeIterator(a.mappings());for(var d=a.next();!d.done;d=a.next()){var c=$jscomp.makeIterator(d.value);d=c.next().value;c=c.next().value;b.set(d,c)}}}}]);return b}(),b=function(a){function b(a,c){q(this,b);var e=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,{sourceOptions:c.volumeSourceOptions,transform:c.objectToDataTransform}));e.displayState=c;e.segmentColorShaderManager=new l.b("segmentColorHash");
e.hashTableManager=new f.c("visibleSegments");e.gpuHashTable=f.a.get(e.gl,e.displayState.visibleSegments.hashTable);e.hashTableManagerHighlighted=new f.c("highlightedSegments");e.gpuHashTableHighlighted=f.a.get(e.gl,e.displayState.highlightedSegments.hashTable);e.equivalencesShaderManager=new f.b("equivalences");e.equivalencesHashMap=new d(e.displayState.segmentEquivalences.disjointSets);e.gpuEquivalencesHashTable=f.a.get(e.gl,e.equivalencesHashMap.hashMap);Object(v.g)(c,e);e.registerDisposer(c.selectedAlpha.changed.add(function(){e.redrawNeeded.dispatch()}));
e.registerDisposer(c.hideSegmentZero.changed.add(function(){e.redrawNeeded.dispatch();e.shaderGetter.invalidateShader()}));e.hasEquivalences=0!==e.displayState.segmentEquivalences.size;c.segmentEquivalences.changed.add(function(){var a=0!==e.displayState.segmentEquivalences.size;a!==e.hasEquivalences&&(e.hasEquivalences=a,e.shaderGetter.invalidateShader())});e.registerDisposer(c.notSelectedAlpha.changed.add(function(){e.redrawNeeded.dispatch()}));return e}n(b,a);k(b,[{key:"getShaderKey",value:function(){return"sliceview.SegmentationRenderLayer/"+
this.hasEquivalences+"/"+this.displayState.hideSegmentZero.value}},{key:"defineShader",value:function(a){m(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"defineShader",this).call(this,a);this.hashTableManager.defineShader(a);this.hashTableManagerHighlighted.defineShader(a);a.addFragmentCode("\nuint64_t getUint64DataValue() {\n  return toUint64(getDataValue());\n}\n");this.hasEquivalences?(this.equivalencesShaderManager.defineShader(a),a.addFragmentCode("\nuint64_t getMappedObjectId() {\n  uint64_t value = getUint64DataValue();\n  uint64_t mappedValue;\n  if ("+
this.equivalencesShaderManager.getFunctionName+"(value, mappedValue)) {\n    return mappedValue;\n  }\n  return value;\n}\n")):a.addFragmentCode("\nuint64_t getMappedObjectId() {\n  return getUint64DataValue();\n}\n");this.segmentColorShaderManager.defineShader(a);a.addUniform("highp vec4","uSelectedSegment",2);a.addUniform("highp float","uShowAllSegments");a.addUniform("highp float","uSelectedAlpha");a.addUniform("highp float","uNotSelectedAlpha");a.addUniform("highp float","uSaturation");a.addFragmentCode(t.q);
var d="\n  uint64_t value = getMappedObjectId();\n\n  float alpha = uSelectedAlpha;\n  float saturation = uSaturation;\n";this.displayState.hideSegmentZero.value&&(d+="\n  if (value.low == vec4(0,0,0,0) && value.high == vec4(0,0,0,0)) {\n    emit(vec4(vec4(0, 0, 0, 0)));\n    return;\n  }\n");d+="\n  bool has = uShowAllSegments > 0.0 ? true : "+this.hashTableManager.hasFunctionName+"(value);\n  if (uSelectedSegment[0] == unnormalizeUint8(value.low) &&\n      uSelectedSegment[1] == unnormalizeUint8(value.high)) {\n    saturation = has ? 0.5 : 0.75;\n  } else if (!has) {\n    alpha = uNotSelectedAlpha;\n  }\n  vec3 rgb = segmentColorHash(value);\n  ";
d+="\n  if("+this.hashTableManagerHighlighted.hasFunctionName+"(value)) {\n    rgb = vec3(0.2,0.2,2.0);\n    saturation = 1.0;\n  };\n";a.setFragmentMain(d+"\n  emit(vec4(mix(vec3(1.0,1.0,1.0), rgb, saturation), alpha));\n")}},{key:"beginSlice",value:function(a){a=m(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"beginSlice",this).call(this,a);if(void 0!==a){var d=this.gl,c=this.displayState,f=this.displayState,g=f.segmentSelectionState;f=f.visibleSegments;if(g.hasSelectedSegment){var k=
g.selectedSegment;g=k.low;k=k.high;for(var l=0;4>l;++l)e[l]=g>>8*l&255,e[4+l]=k>>8*l&255}else e.fill(0);d.uniform1f(a.uniform("uSelectedAlpha"),this.displayState.selectedAlpha.value);d.uniform1f(a.uniform("uSaturation"),this.displayState.saturation.value);d.uniform1f(a.uniform("uNotSelectedAlpha"),this.displayState.notSelectedAlpha.value);d.uniform4fv(a.uniform("uSelectedSegment"),e);d.uniform1f(a.uniform("uShowAllSegments"),f.hashTable.size?0:1);this.hashTableManager.enable(d,a,this.gpuHashTable);
this.hashTableManagerHighlighted.enable(d,a,this.gpuHashTableHighlighted);this.hasEquivalences&&(this.equivalencesHashMap.update(),this.equivalencesShaderManager.enable(d,a,this.gpuEquivalencesHashTable));this.segmentColorShaderManager.enable(d,a,c.segmentColorHash);return a}}},{key:"endSlice",value:function(a){var d=this.gl;this.hashTableManager.disable(d,a);this.hashTableManagerHighlighted.disable(d,a);m(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"endSlice",this).call(this,a)}}]);
return b}(p.a)},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return l});var n=c(92),q=c(3);p=c(12);var a=function(){function a(a,c){for(var e=0;e<c.length;e++){var d=c[e];d.enumerable=d.enumerable||
!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,f,e){f&&a(c.prototype,f);e&&a(c,e);return c}}(),f=function m(a,c,d){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,c);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return m(a,c,d)}else{if("value"in b)return b.value;c=b.get;return void 0===c?void 0:c.call(d)}};g=this&&this.__decorate||function(a,c,e,d){var b=arguments.length,f=3>b?c:null===d?d=Object.getOwnPropertyDescriptor(c,
e):d,g;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)f=Reflect.decorate(a,c,e,d);else for(var k=a.length-1;0<=k;k--)if(g=a[k])f=(3>b?g(f):3<b?g(c,e,f):g(c,e))||f;return 3<b&&f&&Object.defineProperty(c,e,f),f};var l=v=function(c){function g(){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var a=(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
a=!a||"object"!==typeof a&&"function"!==typeof a?this:a;a.hashTable=new n.b;a.changed=new q.b;return a}u(g,c);$jscomp.initSymbol();$jscomp.initSymbolIterator();a(g,[{key:"disposed",value:function(){f(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"disposed",this).call(this);this.changed=this.hashTable=void 0}},{key:"add_",value:function(a){return this.hashTable.add(a)}},{key:"add",value:function(a){if(this.add_(a)){var d=this.rpc;d&&d.invoke("Uint64Set.add",{id:this.rpcId,value:a});this.changed.dispatch(a,
!0)}}},{key:"has",value:function(a){return this.hashTable.has(a)}},{key:Symbol.iterator,value:function(){return this.hashTable.keys()}},{key:"delete_",value:function(a){return this.hashTable.delete(a)}},{key:"delete",value:function(a){if(this.delete_(a)){var d=this.rpc;d&&d.invoke("Uint64Set.delete",{id:this.rpcId,value:a});this.changed.dispatch(a,!1)}}},{key:"clear",value:function(){if(this.hashTable.clear()){var a=this.rpc;a&&a.invoke("Uint64Set.clear",{id:this.rpcId});this.changed.dispatch(null,
!1)}}},{key:"toJSON",value:function(){for(var a=[],d=$jscomp.makeIterator(this),b=d.next();!b.done;b=d.next())a.push(b.value.toString());a.sort();return a}},{key:"size",get:function(){return this.hashTable.size}}],[{key:"makeWithCounterpart",value:function(a){var d=new v;d.initializeCounterpart(a);return d}}]);return g}(p.c);l=v=g([Object(p.f)("Uint64Set")],l);Object(p.e)("Uint64Set.add",function(a){var c=this.get(a.id);c.add_(a.value)&&c.changed.dispatch()});Object(p.e)("Uint64Set.delete",function(a){var c=
this.get(a.id);c.delete_(a.value)&&c.changed.dispatch()});Object(p.e)("Uint64Set.clear",function(a){a=this.get(a.id);a.hashTable.clear()&&a.changed.dispatch()});var v},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=
Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return l});p=c(0);g=c(23);var q=function(){function a(a,c){for(var f=0;f<c.length;f++){var e=c[f];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(a,e.key,e)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),a=function t(a,c,e){null===a&&(a=Function.prototype);
var d=Object.getOwnPropertyDescriptor(a,c);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return t(a,c,e)}else{if("value"in d)return d.value;c=d.get;return void 0===c?void 0:c.call(e)}};c(40);c(251);var f=new g.a,l=function(c){function g(a){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var c=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));c.displayState=a;c.element=document.createElement("div");c.clearButton=document.createElement("button");c.itemContainer=
document.createElement("span");c.items=new Map;var d=c.element,b=c.clearButton,f=c.itemContainer;d.className="segment-set-widget neuroglancer-noselect";b.className="clear-button";b.title="Remove all segment IDs";c.registerEventListener(b,"click",function(){c.visibleSegments.clear()});f.className="item-container";d.appendChild(f);f.appendChild(b);c.registerDisposer(a.visibleSegments.changed.add(function(a,b){c.handleSetChanged(a,b)}));c.registerDisposer(a.segmentColorHash.changed.add(function(){c.handleColorChanged()}));
a=$jscomp.makeIterator(a.visibleSegments);for(d=a.next();!d.done;d=a.next())c.addElement(d.value.toString());c.updateClearButtonVisibility();return c}n(g,c);q(g,[{key:"updateClearButtonVisibility",value:function(){this.clearButton.style.display=0<this.displayState.visibleSegments.size?"":"none"}},{key:"handleSetChanged",value:function(a,c){this.updateClearButtonVisibility();var d=this.items;if(null===a){a=this.itemContainer;for(c=this.clearButton;;){var b=a.lastElementChild;if(b===c)break;a.removeChild(b)}d.clear()}else c?
this.addElement(a.toString()):(a=a.toString(),c=d.get(a),c.parentElement.removeChild(c),d.delete(a))}},{key:"addElement",value:function(a){var c=document.createElement("button");c.className="segment-button";c.textContent=a;c.title="Remove segment ID "+a;var d=this;c.addEventListener("click",function(){f.tryParseString(this.textContent);d.visibleSegments.delete(f)});c.addEventListener("mouseenter",function(){f.tryParseString(this.textContent);d.segmentSelectionState.set(f)});c.addEventListener("mouseleave",
function(){f.tryParseString(this.textContent);d.segmentSelectionState.set(null)});this.setItemColor(c);this.itemContainer.appendChild(c);this.items.set(a,c)}},{key:"setItemColor",value:function(a){f.tryParseString(a.textContent);a.style.backgroundColor=this.segmentColorHash.computeCssColor(f)}},{key:"handleColorChanged",value:function(){var a=this;this.items.forEach(function(c){a.setItemColor(c)})}},{key:"disposed",value:function(){var c=this.element,e=c.parentElement;e&&e.removeChild(c);a(g.prototype.__proto__||
Object.getPrototypeOf(g.prototype),"disposed",this).call(this)}},{key:"visibleSegments",get:function(){return this.displayState.visibleSegments}},{key:"segmentColorHash",get:function(){return this.displayState.segmentColorHash}},{key:"segmentSelectionState",get:function(){return this.displayState.segmentSelectionState}}]);return g}(p.a)},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==
typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return t});p=c(0);var q=c(10),a=c(3),f=c(23),l=function(){function a(a,c){for(var d=0;d<c.length;d++){var b=c[d];b.enumerable=b.enumerable||
!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),v=function k(a,d,b){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,d);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return k(a,d,b)}else{if("value"in c)return c.value;d=c.get;return void 0===d?void 0:d.call(b)}};c(40);c(253);var t=function(c){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");
var d=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.element=document.createElement("form");d.label=document.createElement("label");d.input=document.createElement("input");d.valuesEntered=new a.b;var b=d.element,c=d.label,f=d.input;b.className="uint64-entry neuroglancer-noselect";b.appendChild(c);c.appendChild(f);d.registerEventListener(b,"submit",function(a){a.preventDefault();a=d.validateInput();void 0!==a&&(d.input.value="",d.input.classList.remove("valid-input","invalid-input"),
d.valuesEntered.dispatch(a))});d.registerEventListener(b,"input",function(){""===d.input.value?d.input.classList.remove("valid-input","invalid-input"):d.validateInput()?d.input.classList.remove("invalid-input"):d.input.classList.add("invalid-input")});return d}n(e,c);l(e,[{key:"validateInput",value:function(){var a=this.input.value;a=a.replace(/[\s,\(\)\[\]\{\};]+/g," ");a=a.trim();var b=a.split(" ");if(0!==b.length){a=[];b=$jscomp.makeIterator(b);for(var c=b.next();!c.done;c=b.next()){c=c.value;
var e=new f.a;if(!e.tryParseString(c))return;a.push(e)}return a}}},{key:"disposed",value:function(){Object(q.b)(this.element);v(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}}]);return e}(p.a)},function(p,g){},function(p,g){},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==
typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){return a.split(/[^a-zA-Z0-9]+/).filter(function(a){return a}).join("_")}function f(b){var d=new Set,c=[];b=$jscomp.makeIterator(b);for(var e=
b.next();!e.done;e=b.next()){e=a(e.value);for(var f="",g=0;d.has(e+f);)f=""+ ++g;c.push(e+f)}return c}function l(a){return new r.a({fragmentMain:a.displayState.fragmentMain,shaderError:a.displayState.shaderError,fragmentMainStartLine:k.a})}function v(a){return new y(a.displayState.attributeNames,function(){return a.meshSource&&a.meshSource.info.vertexAttributes})}Object.defineProperty(g,"__esModule",{value:!0});c.d(g,"SingleMeshUserLayer",function(){return D});p=c(6);var t=c.n(p);p=c(14);g=c(20);
var m=c(41),k=c(256),e=c(88),d=c(0),b=c(10),h=c(2),r=c(90),x=c(35),z=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),A=function B(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return B(a,b,d)}else{if("value"in c)return c.value;
b=c.get;return void 0===b?void 0:b.call(d)}};c(258);var D=function(a){function b(a,d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,d));c.manager=a;c.displayState=new k.b;c.displayState.objectToDataTransform=c.transform;c.parameters={meshSourceUrl:Object(h.w)(d,"source",h.B),attributeSourceUrls:Object(h.w)(d,"vertexAttributeSources",function(a){return void 0!==a?Object(h.a)(a,h.B):[]})};c.displayState.fragmentMain.restoreState(d.shader);c.userSpecifiedAttributeNames=Object(h.w)(d,
"vertexAttributeNames",function(a){if(void 0!==a)return Object(h.a)(a,function(a){if(a=Object(h.z)(a))return a})});Object(k.e)(a.chunkManager,c.parameters).then(function(a){if(!c.wasDisposed){c.meshSource=a;var b=c.defaultAttributeNames=f(a.info.vertexAttributes.map(function(a){return a.name})),d=c.userSpecifiedAttributeNames;void 0!==d&&d.length===b.length?(b=d,c.userSpecifiedAttributeNames=void 0):b=Array.from(b);c.displayState.attributeNames.value=b;c.addRenderLayer(new k.c(a,c.displayState));
c.isReady=!0}});c.registerDisposer(c.displayState.fragmentMain.changed.add(function(){c.specificationChanged.dispatch()}));c.registerDisposer(c.displayState.attributeNames.changed.add(function(){c.specificationChanged.dispatch()}));c.tabs.add("rendering",{label:"Rendering",order:-100,getter:function(){return new E(c)}});c.tabs.default="rendering";return c}q(b,a);z(b,[{key:"toJSON",value:function(){var a=A(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"toJSON",this).call(this);a.type="mesh";
var d=this.parameters.attributeSourceUrls;a.source=this.parameters.meshSourceUrl;d&&(a.vertexAttributeSources=d);a.shader=this.displayState.fragmentMain.toJSON();if(void 0===this.meshSource)d=this.userSpecifiedAttributeNames;else{d=this.defaultAttributeNames;for(var c=this.displayState.attributeNames.value,e=!0,f=c.length,g=0;g<f;++g)if(c[g]!==d[g]){e=!1;break}d=e?void 0:Array.from(c)}a.vertexAttributeNames=d;return a}}]);return b}(Object(e.a)(p.h)),y=function(a){function d(a,b){u(this,d);var c=n(this,
(d.__proto__||Object.getPrototypeOf(d)).call(this));c.attributeNames=a;c.getAttributeInfo=b;c.element=document.createElement("div");c.debouncedValueUpdater=t()(function(){c.updateAttributeNames()},500);c.element.className="neuroglancer-single-mesh-attribute-widget";c.updateInputElements();c.registerDisposer(a.changed.add(function(){c.updateInputElements()}));return c}q(d,a);z(d,[{key:"updateInputElements",value:function(){var a=this.attributeNames,b=this.attributeNameElements;if(void 0===b){var d=
this.getAttributeInfo();if(void 0===d)return;b=this.attributeNameElements=[];for(var c=void 0,e=a.value.length,f=this.element,g=0;g<e;++g){var h=d[g],l=h.source;if(l!==c&&void 0!==l){c=l;var m=document.createElement("div");m.className="neuroglancer-single-mesh-source-header";m.textContent=l;f.appendChild(m)}l=document.createElement("div");l.className="neuroglancer-single-mesh-attribute";m=document.createElement("input");m.title=h.name;this.registerEventListener(m,"input",this.debouncedValueUpdater);
m.type="text";l.textContent=Object(k.d)(h);l.appendChild(m);if(void 0!==h.min&&void 0!==h.max){var n=document.createElement("span");n.className="neuroglancer-single-mesh-attribute-range";n.textContent="["+h.min.toPrecision(6)+", "+h.max.toPrecision(6)+"]";l.appendChild(n)}b[g]=m;f.appendChild(l)}}a.value.forEach(function(a,d){b[d].value=a||""})}},{key:"disposed",value:function(){Object(b.b)(this.element)}},{key:"updateAttributeNames",value:function(){var a=this.attributeNames.value,b=this.attributeNameElements,
d=!1;a.forEach(function(c,e){var f=b[e].value;f||(f=void 0);f!==c&&(d=!0,a[e]=f)});d&&this.attributeNames.changed.dispatch()}}]);return d}(d.a),E=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.layer=a;d.attributeWidget=d.registerDisposer(v(d.layer));d.codeWidget=d.registerDisposer(l(d.layer));a=d.element;a.classList.add("neuroglancer-single-mesh-dropdown");var c=document.createElement("div");c.className="neuroglancer-single-mesh-dropdown-top-row";
var e=document.createElement("div");e.style.flex="1";var f=document.createElement("a"),g=document.createElement("button");g.type="button";g.textContent="?";g.className="help-link";f.appendChild(g);f.title="Documentation on single mesh layer rendering";f.target="_blank";f.href="https://github.com/google/neuroglancer/blob/master/src/neuroglancer/sliceview/image_layer_rendering.md";g=document.createElement("button");g.innerHTML="&square;";g.className="maximize-button";g.title="Show larger editor view";
d.registerEventListener(g,"click",function(){new G(d.layer)});c.appendChild(e);c.appendChild(g);c.appendChild(f);a.appendChild(c);a.appendChild(d.attributeWidget.element);a.appendChild(d.codeWidget.element);d.codeWidget.textEditor.refresh();d.visibility.changed.add(function(){d.visible&&d.codeWidget.textEditor.refresh()});return d}q(b,a);return b}(x.b),G=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.layer=a;d.attributeWidget=d.registerDisposer(v(d.layer));
d.codeWidget=d.registerDisposer(l(d.layer));d.content.classList.add("neuroglancer-single-mesh-layer-shader-overlay");d.content.appendChild(d.attributeWidget.element);d.content.appendChild(d.codeWidget.element);d.codeWidget.textEditor.refresh();return d}q(b,a);return b}(m.a);Object(g.e)("mesh",D)},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==
typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function a(){return new d.c([],function(a){return Object(r.a)(a,r.z)})}function f(a){return Object(G.a)(a.dataType,a.numComponents)}
function l(a){return a.map(function(a){return Object(y.c)(new y.b,a.dataType,a.numComponents)})}function v(a,b){return a.memoize.getUncounted({type:"single_mesh:getMeshInfo",parameters:b},function(){return a.rpc.promiseInvoke(e.a,{chunkManager:a.addCounterpartRef(),parameters:b})})}c.d(g,"b",function(){return M});g.d=f;c.d(g,"c",function(){return aa});g.e=function(a,b){return v(a,b).then(function(d){return a.getChunkSource(T,{parameters:Object.assign({},b,{info:d})})})};var t=c(36);p=c(17);var m=
c(50),k=c(52),e=c(257),d=c(5),b=c(43),h=c(1),r=c(2),x=c(24),z=c(26),A=c(47),D=c(111),y=c(93),E=c(27),G=c(16),H=c(12),B=function S(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return S(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},C=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=
!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}();g.a="//NEUROGLANCER_SINGLE_MESH_LAYER_FRAGMENT_MAIN_START";var F=c(83),M=function ha(){q(this,ha);this.shaderError=Object(A.c)();var b=void 0;this.fragmentMain=new d.c(void 0===b?"void main() {\n  emitGray();\n}\n":b,r.B);this.attributeNames=a();this.objectToDataTransform=new m.a};$jscomp.initSymbol();var I=Symbol("SingleMeshShaderManager.vertexAttributeTextureUnit"),P=Object(y.c)(new y.b,b.b.FLOAT32,
3),N=function(){function a(b,d,c){q(this,a);this.attributeNames=b;this.attributeInfo=d;this.fragmentMain=c;this.tempLightVec=new Float32Array(4);this.tempPickID=new Float32Array(4);this.textureAccessHelper=new y.a("vertexData");this.indexBufferHelper=new D.a("VertexIndex")}C(a,[{key:"defineAttributeAccess",value:function(a,d){var c=this.textureAccessHelper;c.defineShader(a);a.addVertexCode(c.getAccessor("readVertexPosition","uVertexAttributeSampler[0]",b.b.FLOAT32,3));a.addVertexCode(c.getAccessor("readVertexNormal",
"uVertexAttributeSampler[1]",b.b.FLOAT32,3));var e=2,g="\nvec3 vertexPosition = readVertexPosition("+d+");\nvec3 vertexNormal = readVertexNormal("+d+");\n",h=this.attributeNames;this.attributeInfo.forEach(function(b,k){if(void 0!==h[k]){var l=f(b);a.addVarying("highp "+l,"vCustom"+k);a.addFragmentCode("\n#define "+h[k]+" vCustom"+k+"\n");a.addVertexCode(c.getAccessor("readAttribute"+k,"uVertexAttributeSampler["+e+"]",b.dataType,b.numComponents));g+="vCustom"+k+" = readAttribute"+k+"("+d+");\n";e+=
1}});a.addTextureSampler2D("uVertexAttributeSampler",I,e);a.addVertexMain(g)}},{key:"defineShader",value:function(a){a.require(D.b);this.indexBufferHelper.defineShader(a);a.addVarying("highp float","vLightingFactor");a.addUniform("highp vec4","uLightDirection");a.addUniform("highp vec4","uColor");a.addUniform("highp mat4","uModelMatrix");a.addUniform("highp mat4","uProjection");a.addUniform("highp vec4","uPickID");a.addVarying("highp vec4","vPickID");a.addVertexCode(G.b);a.addVertexCode(G.c);a.addVertexMain("\nfloat vertexIndex = getVertexIndex();\nuint32_t triangleIndex;\ndivmod(getPrimitiveIndex(), 3.0, triangleIndex);\nuint32_t pickID; pickID.value = uPickID;\nvPickID = add(pickID, triangleIndex).value;\n");
a.addFragmentCode("\nvoid emitPremultipliedRGBA(vec4 color) {\n  emit(vec4(color.rgb * vLightingFactor, color.a), vPickID);\n}\nvoid emitRGBA(vec4 color) {\n  color = clamp(color, 0.0, 1.0);\n  color.xyz *= color.a;\n  emitPremultipliedRGBA(color);\n}\nvoid emitRGB(vec3 color) {\n  emitRGBA(vec4(color, 1.0));\n}\nvoid emitGray() {\n  emitRGB(vec3(1.0, 1.0, 1.0));\n}\n");a.addFragmentCode(F);this.defineAttributeAccess(a,"vertexIndex");a.addVertexMain("\ngl_Position = uProjection * (uModelMatrix * vec4(vertexPosition, 1.0));\nvec3 normal = normalize((uModelMatrix * vec4(vertexNormal, 0.0)).xyz);\nvLightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w;\n");
a.setFragmentMainFunction("//NEUROGLANCER_SINGLE_MESH_LAYER_FRAGMENT_MAIN_START\n"+this.fragmentMain)}},{key:"beginLayer",value:function(a,b,d){var c=d.dataToDevice,e=d.lightDirection,f=d.ambientLighting;d=d.directionalLighting;a.uniformMatrix4fv(b.uniform("uProjection"),!1,c);c=this.tempLightVec;h.s.scale(c,e,d);c[3]=f;a.uniform4fv(b.uniform("uLightDirection"),c)}},{key:"setPickID",value:function(a,b,d){a.uniform4fv(b.uniform("uPickID"),Object(G.r)(this.tempPickID,d))}},{key:"beginObject",value:function(a,
b,d){a.uniformMatrix4fv(b.uniform("uModelMatrix"),!1,d)}},{key:"getShader",value:function(a,b){var d=this,c={attributeNames:this.attributeNames,attributeInfo:this.attributeInfo,fragmentMain:this.fragmentMain};return a.memoize.get("single_mesh/SingleMeshShaderManager:"+Object(x.a)(b)+":"+Object(r.g)(c),function(){var c=new E.a(a);c.require(b);d.defineShader(c);return c.build()})}},{key:"bindVertexData",value:function(a,b,d){this.textureAccessHelper.setupTextureLayout(a,b,d);var c=b.textureUnit(I)+
a.TEXTURE0,e=function(b){a.activeTexture(c++);a.bindTexture(a.TEXTURE_2D,b)};e(d.vertexTexture);e(d.normalTexture);var f=this.attributeNames;d.vertexAttributeTextures.forEach(function(a,b){void 0!==f[b]&&e(a)})}},{key:"disableVertexData",value:function(a,b){for(var d=2,c=this.attributeInfo.length,e=this.attributeNames,f=0;f<c;++f)void 0!==e[f]&&++d;b=b.textureUnit(I)+a.TEXTURE0;for(c=0;c<d;++c)a.activeTexture(b++),a.bindTexture(a.TEXTURE_2D,null)}},{key:"drawFragment",value:function(a,b,d,c){c.ensure(d.numIndices).bind(b);
this.bindVertexData(a,b,d.vertexData);this.indexBufferHelper.bind(d.indexBuffer,b);a.drawArrays(a.TRIANGLES,0,d.numIndices)}},{key:"endLayer",value:function(a,b){Object(D.c)(a,b);this.indexBufferHelper.disable(b);this.disableVertexData(a,b)}}]);return a}(),U=function(){function a(){q(this,a)}C(a,[{key:"copyToGPU",value:function(a,b){var d=this;Object(y.d)(this,a,1,this.vertexPositions.length/3);var c=function(b,c){var e=a.createTexture();a.bindTexture(a.TEXTURE_2D,e);Object(y.f)(a,d,c,b);return e};
this.vertexTexture=c(this.vertexPositions,P);this.normalTexture=c(this.vertexNormals,P);this.vertexAttributeTextures=this.vertexAttributes.map(function(a,d){return c(a,b[d])});a.bindTexture(a.TEXTURE_2D,null)}},{key:"freeGPUMemory",value:function(a){a.deleteTexture(this.vertexTexture);a.deleteTexture(this.normalTexture);for(var b=this.vertexAttributeTextures,d=$jscomp.makeIterator(b),c=d.next();!c.done;c=d.next())a.deleteTexture(c.value);b.length=0}}]);return a}(),O=function(a){function b(a,d){q(this,
b);a=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));var c=a.vertexData=new U;c.vertexPositions=d.vertexPositions;c.vertexNormals=d.vertexNormals;c.vertexAttributes=d.vertexAttributes;d=a.indices=d.indices;a.numIndices=d.length;return a}n(b,a);C(b,[{key:"copyToGPU",value:function(a){B(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"copyToGPU",this).call(this,a);this.vertexData.copyToGPU(a,this.source.attributeTextureFormats);this.indexBuffer=Object(D.e)(a,this.indices)}},{key:"freeGPUMemory",
value:function(a){B(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"freeGPUMemory",this).call(this,a);this.vertexData.freeGPUMemory(a);this.indexBuffer.dispose()}}]);return b}(p.b),T=function(a){function b(){q(this,b);var a=u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));a.attributeTextureFormats=l(a.info.vertexAttributes);return a}n(b,a);C(b,[{key:"getChunk",value:function(a){return new O(this,a)}},{key:"info",get:function(){return this.parameters.info}}]);return b}(Object(p.f)(p.e,
e.d)),W=function(a){function b(){q(this,b);return u(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}n(b,a);return b}(Object(z.c)(H.b)),aa=function(a){function b(a,d){q(this,b);var c=u(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.source=a;c.displayState=d;c.shaders=new Map;c.sharedObject=c.registerDisposer(new W);c.fallbackFragmentMain="void main() {\n  emitGray();\n}\n";c.countingBuffer=c.registerDisposer(Object(D.d)(c.gl));c.displayState.shaderError.value=void 0;
var f=function(){c.shaderManager=void 0;c.displayState.shaderError.value=void 0;c.disposeShaders();c.redrawNeeded.dispatch()};c.registerDisposer(d.fragmentMain.changed.add(f));c.registerDisposer(d.attributeNames.changed.add(f));c.registerDisposer(d.objectToDataTransform.changed.add(function(){c.redrawNeeded.dispatch()}));c.displayState.shaderError.value=void 0;d=c.sharedObject;d.visibility.add(c.visibility);d.RPC_TYPE_ID=e.c;d.initializeCounterpart(a.chunkManager.rpc,{chunkManager:a.chunkManager.rpcId,
source:a.addCounterpartRef()});c.setReady(!0);return c}n(b,a);C(b,[{key:"disposeShaders",value:function(){for(var a=this.shaders,b=$jscomp.makeIterator(a.values()),d=b.next();!d.done;d=b.next())d=d.value,null!==d&&d.dispose();a.clear()}},{key:"disposed",value:function(){this.disposeShaders();B(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"makeShaderManager",value:function(a){a=void 0===a?this.displayState.fragmentMain.value:a;return new N(this.displayState.attributeNames.value,
this.source.info.vertexAttributes,a)}},{key:"getShader",value:function(a){var b=this.shaders,d=b.get(a);if(void 0===d){d=null;var c=this.shaderManager;void 0===c&&(c=this.shaderManager=this.makeShaderManager());var e=this.displayState.fragmentMain.value;try{d=c.getShader(this.gl,a),this.fallbackFragmentMain=e,this.displayState.shaderError.value=null}catch(na){if(this.displayState.shaderError.value=na,c=this.fallbackFragmentMain,c!==e){c=this.shaderManager=this.makeShaderManager(c);try{d=c.getShader(this.gl,
a)}catch(fb){}}}b.set(a,d)}return d}},{key:"draw",value:function(a){if(a.emitColor||!a.alreadyEmittedPickID){var b=this.source.chunks.get(e.b);if(void 0!==b&&b.state===t.d.GPU_MEMORY){var d=this.getShader(a.emitter);if(null!==d){var c=this.gl,f=this.shaderManager;d.bind();f.beginLayer(c,d,a);var g=a.pickIDs;f.beginObject(c,d,this.displayState.objectToDataTransform.transform);a.emitPickID&&f.setPickID(c,d,g.register(this,b.numIndices/3));f.drawFragment(c,d,b,this.countingBuffer);f.endLayer(c,d)}}}}},
{key:"drawPicking",value:function(a){this.draw(a)}},{key:"transformPickedValue",value:function(a,b){a=this.source.chunks.get(e.b);if(void 0!==a){b*=3;var d=a.indices;if(!(b>=d.length)){var c=d[b],f=[],g=this.displayState.attributeNames.value;a.vertexData.vertexAttributes.forEach(function(a,b){b=g[b];void 0!==b&&f.push(b+"="+a[c].toPrecision(6))});return f.join(", ")}}}},{key:"isTransparent",get:function(){return null!==this.displayState.fragmentMain.value.match(/emitRGBA|emitPremultipliedRGBA/)}},
{key:"gl",get:function(){return this.source.gl}}]);return b}(k.a)},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function n(a,c){if(!(a instanceof c))throw new TypeError("Cannot call a class as a function");}c.d(g,"d",
function(){return q});g.c="single_mesh/SingleMeshLayer";g.a="single_mesh/getSingleMeshInfo";g.b="";var q=function(a){function c(){n(this,c);var a=(c.__proto__||Object.getPrototypeOf(c)).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}u(c,a);return c}(function f(){n(this,f)});q.RPC_ID="single_mesh/SingleMeshSource"},function(p,g){},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(b,c){void 0!==c&&Object(d.a)(c,function(c,e){b.add({type:a.c.POINT,id:""+e,point:Object(d.l)(c)})})}Object.defineProperty(g,
"__esModule",{value:!0});c.d(g,"AnnotationUserLayer",function(){return r});var a=c(22),f=c(62),l=c(50);p=c(14);g=c(20);var v=c(58),t=c(25),m=c(85),k=c(88),e=c(1),d=c(2),b=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),h=function z(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,
b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return z(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(261);var r=function(d){function c(b,d){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var g=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,b,d));g.localAnnotations=g.registerDisposer(new a.d);g.voxelSize=new v.h;var h=g.sourceUrl=d.source;if(void 0===h){g.isReady=!0;g.voxelSize.restoreState(d.voxelSize);
g.localAnnotations.restoreState(d.annotations);q(g.localAnnotations,d.points);var k=!1;d=function(){!g.voxelSize.valid&&b.voxelSize.valid&&(e.s.copy(g.voxelSize.size,b.voxelSize.size),g.voxelSize.setValid());if(g.voxelSize.valid&&!1===k){var a=new l.a;g.registerDisposer(Object(l.b)(a,g.transform,function(a,b){var d=e.k.fromScaling(e.k.create(),g.voxelSize.size);e.k.multiply(a,b,d)}));g.annotationLayerState.value=new f.b({transform:a,source:g.localAnnotations.addRef(),color:g.annotationColor});k=!0}};
g.registerDisposer(g.localAnnotations.changed.add(g.specificationChanged.dispatch));g.registerDisposer(g.voxelSize.changed.add(g.specificationChanged.dispatch));g.registerDisposer(g.voxelSize.changed.add(d));g.registerDisposer(g.manager.voxelSize.changed.add(d));d()}else t.a.forPromise(g.manager.dataSourceProvider.getAnnotationSource(g.manager.chunkManager,h),{initialMessage:"Retrieving metadata for volume "+h+".",delay:!0,errorPrefix:"Error retrieving metadata for volume "+h+": "}).then(function(a){g.wasDisposed||
(g.annotationLayerState.value=new f.b({transform:g.transform,source:a,color:g.annotationColor}),g.isReady=!0)});g.tabs.default="annotations";return g}n(c,d);b(c,[{key:"toJSON",value:function(){var a=h(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"toJSON",this).call(this);a.type="annotation";a.source=this.sourceUrl;void 0===this.sourceUrl&&(a.annotations=this.localAnnotations.toJSON(),a.voxelSize=this.voxelSize.toJSON());return a}}]);return c}(Object(m.a)(Object(k.a)(p.h)));Object(g.e)("annotation",
r);Object(g.e)("pointAnnotation",r)},function(p,g,c){c.d(g,"a",function(){return a});var u=c(2),n=c(3),q=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),a=function(){function a(c,f,g){g=void 0===g?f:g;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.enumType=c;this.value_=
f;this.defaultValue=g;this.changed=new n.a}q(a,[{key:"reset",value:function(){this.value=this.defaultValue}},{key:"restoreState",value:function(a){this.value=Object(u.n)(a,this.enumType)}},{key:"toJSON",value:function(){return this.enumType[this.value_].toLowerCase()}},{key:"value",set:function(a){this.value_!==a&&(this.value_=a,this.changed.dispatch())},get:function(){return this.value_}}]);return a}()},function(p,g){},function(p,g,c){function u(a){var b=new y.a,d=new t.a;b.add("viewer",d);a.global.addParent(d.eventActionMap,
1E3);d=new t.a;b.add("sliceView",d);a.sliceView.addParent(d.eventActionMap,1E3);d=new t.a;b.add("perspectiveView",d);a.perspectiveView.addParent(d.eventActionMap,1E3);d=new t.a;b.add("dataView",d);a.perspectiveView.addParent(d.eventActionMap,999);a.sliceView.addParent(d.eventActionMap,999);return b}function n(a){var b=new h.c({},function(a){for(var b=$jscomp.makeIterator(Object.keys(a)),d=b.next();!d.done;d=b.next()){d=d.value;var c=a[d];if("number"!==typeof c)throw Error("Expected key "+JSON.stringify(d)+
" to have a numeric value, but received: "+JSON.stringify(c)+".");}return a});b.changed.add(q()(function(){for(var d=b.value,c=$jscomp.makeIterator(Object.keys(d)),e=c.next();!e.done;e=c.next())e=e.value,a.setSourceGeneration(e,d[e]);c=$jscomp.makeIterator(a.sourceGenerations.keys());for(e=c.next();!e.done;e=c.next())e=e.value,d.hasOwnProperty(e)||a.deleteSourceGeneration(e)},0));return b}Object.defineProperty(g,"__esModule",{value:!0});p=c(6);var q=c.n(p),a=c(94),f=c(32),l=c(132),v=c(263),t=c(264),
m=c(265),k=c(305),e=c(306),d=c(307),b=c(308),h=c(5),r=c(342),x=c(343),z=c(344),A=c(352),D=c(2),y=c(29);window.addEventListener("DOMContentLoaded",function(){var c=new y.a,g=new y.a,p=new v.a;c.add("credentials",p.inputState);g.add("credentials",p.outputState);p=Object(f.a)({credentialsManager:new a.a(p)});var t=new l.PythonDataSource;p.register("python",t);c.add("sourceGenerations",n(t));var C=window.viewer=Object(z.a)({showLayerDialog:!1,resetStateWhenEmpty:!1,dataSourceProvider:p});Object(x.a)(C.inputEventBindings);
c.add("inputEventBindings",u(C.inputEventBindings));t=new k.a(C);window.remoteActionHandler=t;c.add("actions",t.actionSet);c.add("statusMessages",new e.a);var F=new d.a(C);c.add("screenshot",F.requestState);var M=C.state;window.location.hash&&(C.registerDisposer(new A.a(C.state)).updateFromUrlHash(),M=void 0);p=new m.a(C.display,p,C.dataContext.addRef(),C.uiConfiguration);c.add("prefetch",p);c.add("showUIControls",C.uiConfiguration.showUIControls);c.add("showLayerPanel",C.uiConfiguration.showLayerPanel);
c.add("showHelpButton",C.uiConfiguration.showHelpButton);c.add("showLocation",C.uiConfiguration.showLocation);c.add("showPanelBorders",C.uiConfiguration.showPanelBorders);var I=new h.c(void 0,function(a){return null==a?void 0:Object(D.c)([0,0],a,D.s)});c.add("viewerSize",I);var P=function(){var a=C.display.container,b=I.value;void 0===b?(a.style.position="relative",a.style.width=null,a.style.height=null):(a.style.position="absolute",a.style.width=b[0]+"px",a.style.height=b[1]+"px");C.display.onResize()};
P();I.changed.add(q()(function(){return P()},0));var N=new b.a(M,g,c);t.sendActionRequested.add(function(a,b){return N.sendActionNotification(a,b)});F.sendScreenshotRequested.add(function(a){return N.sendActionNotification("screenshot",a)});Object(r.a)(C);Object(r.b)(C)})},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||
"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return e});var a=c(94),f=c(5),l=c(63),v=c(29),t=c(2),m=function(){function a(a,d){for(var b=0;b<d.length;b++){var c=d[b];
c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),k=function(d){function b(){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments));d.invalidCredentials=new f.c(void 0,function(a){return a});d.validCredentials=new f.c(void 0,function(a){return a});d.get=Object(a.d)(function(a){return new Promise(function(b){var c=d.validCredentials.value,e=void 0!==
a?a.generation:null;if(void 0!==c&&e!==c.generation)b(c);else{d.invalidCredentials.value=e;var f=d.validCredentials.changed.add(function(){var a=d.validCredentials.value;void 0!==a&&e!==a.generation&&(f(),b(a))})}})});return d}q(b,d);return b}(a.c),e=function(){function a(){u(this,a);this.inputState=new v.b;this.outputState=new v.b;this.memoize=new l.a}m(a,[{key:"getCredentialsProvider",value:function(a,d){var b=this;void 0===d&&(d=null);var c=Object(t.g)({key:a,parameters:d});return this.memoize.get(c,
function(){var a=new k;a.registerDisposer(b.inputState.add(c,a.validCredentials));a.registerDisposer(b.outputState.add(c,a.invalidCredentials));return a})}}]);return a}()},function(p,g,c){c.d(g,"a",function(){return f});var u=c(2),n=c(3),q=c(19),a=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),f=function(){function c(){if(!(this instanceof
c))throw new TypeError("Cannot call a class as a function");this.eventActionMap=new q.a;this.changed=new n.a}a(c,[{key:"reset",value:function(){this.eventActionMap.clear();this.changed.dispatch()}},{key:"restoreState",value:function(a){Object(u.u)(a);for(var c=this.eventActionMap,f=$jscomp.makeIterator(Object.keys(a)),g=f.next();!g.done;g=f.next()){g=g.value;var e=Object(u.B)(a[g]);c.set(g,e)}this.changed.dispatch()}},{key:"toJSON",value:function(){for(var a={},c=$jscomp.makeIterator(this.eventActionMap.bindings),
f=c.next();!f.done;f=c.next()){var g=$jscomp.makeIterator(f.value);f=g.next().value;g=g.next().value;a[f]=g.action}return a}}]);return c}()},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return m});p=c(6);var q=c.n(p);p=c(0);var a=c(2),f=c(3),l=c(148),v=c(26),t=function(){function a(a,d){for(var b=0;b<d.length;b++){var c=d[b];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(c,d,b){d&&a(c.prototype,d);b&&a(c,b);return c}}(),m=function(c){function e(a,
b,c,g){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var d=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.display=a;d.dataSourceProvider=b;d.dataContext=c;d.uiConfiguration=g;d.prefetchStates=new Map;d.changed=new f.a;d.specification=[];d.updatePrefetchStates=d.registerCancellable(q()(function(){var a=d.specification,b=d.prefetchStates,c=new Set;a=$jscomp.makeIterator(a);for(var e=a.next();!e.done;e=a.next()){var f=e.value;e=f.state;f=f.priority;var g=
JSON.stringify(e);c.add(g);var h=b.get(g);void 0===h?(h=d.makePrefetchState(e,f),b.set(g,h)):h.visibility.value=f}a=$jscomp.makeIterator(b);for(e=a.next();!e.done;e=a.next())f=$jscomp.makeIterator(e.value),e=f.next().value,f=f.next().value,c.has(e)||(b.delete(e),f.dispose())},0));d.registerDisposer(c);return d}n(e,c);t(e,[{key:"makePrefetchState",value:function(a,b){b=new l.a(this.display,{showLayerDialog:!1,resetStateWhenEmpty:!1,dataSourceProvider:this.dataSourceProvider,dataContext:this.dataContext.addRef(),
visibility:new v.b(b),uiConfiguration:this.uiConfiguration});try{b.state.restoreState(a)}catch(h){console.log("Error setting prefetch state: "+h.message)}return b}},{key:"reset",value:function(){this.specification=[];this.changed.dispatch();this.updatePrefetchStates()}},{key:"restoreState",value:function(d){this.specification=Object(a.a)(d,function(b){Object(a.u)(b);var d=Object(a.w)(b,"state",a.u);b=Object(a.w)(b,"priority",function(b){return void 0===b?0:Object(a.s)(b)});return{state:d,priority:b}});
this.changed.dispatch();this.updatePrefetchStates()}},{key:"toJSON",value:function(){return 0===this.specification.length?void 0:this.specification}}]);return e}(p.a)},function(p,g,c){p=new (c(94).b);g.a=p},function(p,g,c){g.b=function(c,g){return function(n){n.style.flex=c;g(n)}};g.a=function(c,g){return function(n){n.style.display="flex";n.style.flexDirection=c;for(var a=$jscomp.makeIterator(g),f=a.next();!f.done;f=a.next()){f=f.value;var l=n.ownerDocument.createElement("div");n.appendChild(l);
f(l)}}}},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,
writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){a.addFragmentExtension("GL_EXT_draw_buffers");a.addFragmentCode(C)}function f(a){a.addFragmentExtension("GL_EXT_draw_buffers");a.addFragmentCode(F)}function l(a){a.setFragmentMain("\nvec4 v0 = getValue0();\nvec4 v1 = getValue1();\nvec4 accum = vec4(v0.rgb, v1.r);\nfloat revealage = v0.a;\n\ngl_FragColor = vec4(accum.rgb / accum.a, revealage);\n")}c.d(g,"a",function(){return O});var v=c(115),
t=c(14),m=c(116),k=c(269),e=c(52);p=c(117);var d=c(45),b=c(57),h=c(19),r=c(1),x=c(120),z=c(150);g=c(26);var A=c(11),D=c(76),y=c(16),E=c(12),G=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),H=function W(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=
Object.getPrototypeOf(a),null!==a)return W(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(40);c(270);var B;(function(a){a[a.COLOR=0]="COLOR";a[a.Z=1]="Z";a[a.PICK=2]="PICK";a[a.NUM_TEXTURES=3]="NUM_TEXTURES"})(B||(B={}));var C=[y.k,"\nvoid emit(vec4 color, vec4 pickId) {\n  gl_FragData["+B.COLOR+"] = color;\n  gl_FragData["+B.Z+"] = packFloat01ToFixedPoint(1.0 - gl_FragCoord.z);\n  gl_FragData["+B.PICK+"] = pickId;\n}\n"],F=["\nfloat computeOITWeight(float alpha) {\n  float a = min(1.0, alpha) * 8.0 + 0.01;\n  float b = -gl_FragCoord.z * 0.95 + 1.0;\n  return a * a * a * b * b * b;\n}\n",
"\nvoid emit(vec4 color, vec4 pickId) {\n  float weight = computeOITWeight(color.a);\n  vec4 accum = color * weight;\n  gl_FragData[0] = vec4(accum.rgb, color.a);\n  gl_FragData[1] = vec4(accum.a, 0.0, 0.0, 0.0);\n}\n"],M=r.s.create(),I=r.s.create(),P=r.u.create(),N=r.k.create(),U=function(a){function b(){u(this,b);return n(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}q(b,a);return b}(Object(g.c)(E.b)),O=function(c){function g(c,f,p){u(this,g);var q=n(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,
c,f,p));q.sliceViews=function(){var a=new Map;return q.registerDisposer(new z.a(function(b,d){b=d.visibility.add(q.visibility);a.set(d,b);q.scheduleRedraw()},function(b,d){b=a.get(d);a.delete(d);b();d.dispose();q.scheduleRedraw()}))}();q.projectionMat=r.k.create();q.inverseProjectionMat=r.k.create();q.modelViewMat=r.k.create();q.width=0;q.height=0;q.pickIDs=new m.a;q.axesLineHelper=q.registerDisposer(v.a.get(q.gl));q.sliceViewRenderHelper=q.registerDisposer(d.d.get(q.gl,a));q.offscreenFramebuffer=
q.registerDisposer(new D.b(q.gl,{colorBuffers:Object(D.e)(q.gl,B.NUM_TEXTURES),depthBuffer:new D.a(q.gl)}));q.offscreenCopyHelper=q.registerDisposer(D.c.get(q.gl));q.transparencyCopyHelper=q.registerDisposer(D.c.get(q.gl,l,2));q.registerDisposer(q.navigationState.changed.add(function(){q.viewportChanged()}));c=q.sharedObject=q.registerDisposer(new U);c.RPC_TYPE_ID=k.c;c.initializeCounterpart(p.rpc,{});c.visibility.add(q.visibility);q.visibleLayerTracker=Object(t.k)(q.viewer.layerManager,e.a,q.viewer.visibleLayerRoles,
q,function(a){var b=a.backend;if(b)return b.rpc.invoke(k.a,{layer:b.rpcId,view:q.sharedObject.rpcId}),function(){b.rpc.invoke(k.b,{layer:b.rpcId,view:q.sharedObject.rpcId})}});Object(h.c)(f,"translate-via-mouse-drag",function(a){Object(x.a)(a.detail,function(a,b,d){a=q.width;var c=q.height,e=q.viewer.navigationState.position,f=e.spatialCoordinates;r.s.transformMat4(M,f,q.projectionMat);M[0]=2*b/a;M[1]=-2*d/c;r.s.transformMat4(f,M,q.inverseProjectionMat);e.changed.dispatch()})});Object(h.c)(f,"rotate-via-mouse-drag",
function(a){Object(x.a)(a.detail,function(a,b,d){q.navigationState.pose.rotateRelative(r.e[1],-b/4*Math.PI/180);q.navigationState.pose.rotateRelative(r.e[0],d/4*Math.PI/180);q.viewer.navigationState.changed.dispatch()})});p.showSliceViewsCheckbox&&(f=q.registerDisposer(new b.c(p.showSliceViews)),f.element.className="perspective-panel-show-slice-views neuroglancer-noselect",c=document.createElement("label"),c.className="perspective-panel-show-slice-views neuroglancer-noselect",c.appendChild(document.createTextNode("Slices")),
c.appendChild(f.element),q.element.appendChild(c));q.registerDisposer(p.showSliceViews.changed.add(function(){return q.scheduleRedraw()}));q.registerDisposer(p.showAxisLines.changed.add(function(){return q.scheduleRedraw()}));q.registerDisposer(p.crossSectionBackgroundColor.changed.add(function(){return q.scheduleRedraw()}));return q}q(g,c);G(g,[{key:"isReady",value:function(){if(!this.visible)return!1;for(var a=$jscomp.makeIterator(this.sliceViews),b=a.next();!b.done;b=a.next()){b=$jscomp.makeIterator(b.value);
var d=b.next().value;if((b.next().value||this.viewer.showSliceViews.value)&&!d.isReady())return!1}a=this.visibleLayerTracker.getVisibleLayers();a=$jscomp.makeIterator(a);for(b=a.next();!b.done;b=a.next())if(!b.value.isReady())return!1;return!0}},{key:"updateProjectionMatrix",value:function(){var a=this.projectionMat;r.k.perspective(a,Math.PI/4,this.width/this.height,10,5E3);var b=this.modelViewMat;this.navigationState.toMat4(b);r.s.set(M,1,-1,-1);r.k.scale(b,b,M);var d=r.s.set(M,0,0,100);r.k.translate(b,
b,d);r.k.invert(N,b);r.k.multiply(a,a,N);r.k.invert(this.inverseProjectionMat,a)}},{key:"viewportChanged",value:function(){this.context.scheduleRedraw()}},{key:"onResize",value:function(){var a=this.element,b=a.clientHeight;if(a.clientWidth!==this.width||b!==this.height)this.width=this.element.clientWidth,this.height=this.element.clientHeight,this.viewportChanged()}},{key:"disposed",value:function(){for(var a=$jscomp.makeIterator(this.sliceViews.keys()),b=a.next();!b.done;b=a.next())b.value.dispose();
this.sliceViews.clear();H(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"disposed",this).call(this)}},{key:"updateMouseState",value:function(a){a.pickedRenderLayer=null;if(!this.navigationState.valid)return!1;var b=a.position,d=this.offscreenFramebuffer,c=this.width,e=this.height;if(!d.hasSize(c,e))return!1;var f=this.mouseX,g=e-this.mouseY,h=d.readPixel(B.Z,f,g);h=1-Object(y.s)(h);if(1===h)return!1;b[0]=2*f/c-1;b[1]=2*g/e-1;b[2]=2*h-1;r.s.transformMat4(b,b,this.inverseProjectionMat);
this.pickIDs.setMouseState(a,d.readPixelAsUint32(B.PICK,f,g));return!0}},{key:"draw",value:function(){if(this.navigationState.valid){this.onResize();var b=this.width,d=this.height;if(0!==b&&0!==d){for(var c=this.viewer.showSliceViews.value,e=$jscomp.makeIterator(this.sliceViews),g=e.next();!g.done;g=e.next()){g=$jscomp.makeIterator(g.value);var h=g.next().value;(g.next().value||c)&&h.updateRendering()}c=this.gl;this.offscreenFramebuffer.bind(b,d);c.disable(c.SCISSOR_TEST);this.gl.clearColor(0,0,0,
0);c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);c.enable(c.DEPTH_TEST);e=this.projectionMat;this.updateProjectionMatrix();g=r.s.create();Object(r.p)(g,r.e[2],this.modelViewMat);r.s.normalize(g,g);h=this.pickIDs;h.clear();e={dataToDevice:e,lightDirection:g,ambientLighting:.2,directionalLighting:.8,pickIDs:h,emitter:a,emitColor:!0,emitPickID:!0,alreadyEmittedPickID:!1,viewportWidth:b,viewportHeight:d};g=this.visibleLayerTracker.getVisibleLayers();var k=!1,l=!1,m=$jscomp.makeIterator(g);for(h=m.next();!h.done;h=
m.next())h=h.value,h.isTransparent?k=!0:h.isAnnotation?l=!0:h.draw(e);this.drawSliceViews(e);if(l){c.enable(A.b);c.depthFunc(A.i);c.blendFunc(A.u,A.p);c.WEBGL_draw_buffers.drawBuffersWEBGL([c.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL,c.NONE,c.NONE]);e.emitPickID=!1;l=$jscomp.makeIterator(g);for(h=l.next();!h.done;h=l.next())h=h.value,h.isAnnotation&&h.draw(e);c.depthFunc(A.j);c.disable(A.b);c.WEBGL_draw_buffers.drawBuffersWEBGL([c.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL,c.WEBGL_draw_buffers.COLOR_ATTACHMENT1_WEBGL,
c.WEBGL_draw_buffers.COLOR_ATTACHMENT2_WEBGL]);e.emitPickID=!0}this.viewer.showAxisLines.value&&this.drawAxisLines();if(k){c.depthMask(!1);c.enable(A.b);k=this.transparentConfiguration;k.bind(b,d);this.gl.clearColor(0,0,0,1);c.clear(A.d);e.emitter=f;c.blendFuncSeparate(A.o,A.o,A.J,A.p);e.emitPickID=!1;l=$jscomp.makeIterator(g);for(h=l.next();!h.done;h=l.next())h=h.value,h.isTransparent&&h.draw(e);c.disable(A.e);this.offscreenFramebuffer.bindSingle(B.COLOR);c.blendFunc(A.p,A.u);this.transparencyCopyHelper.draw(k.colorBuffers[0].texture,
k.colorBuffers[1].texture);c.depthMask(!0);c.disable(A.b);c.enable(A.e);this.offscreenFramebuffer.bind(b,d)}c.WEBGL_draw_buffers.drawBuffersWEBGL([c.NONE,c.WEBGL_draw_buffers.COLOR_ATTACHMENT1_WEBGL,c.WEBGL_draw_buffers.COLOR_ATTACHMENT2_WEBGL]);e.emitter=a;e.emitPickID=!0;e.emitColor=!1;c.enable(A.q);c.polygonOffset(-1,-1);b=$jscomp.makeIterator(g);for(h=b.next();!h.done;h=b.next())d=h.value,e.alreadyEmittedPickID=!d.isTransparent&&!d.isAnnotation,d.draw(e);c.disable(A.q);this.offscreenFramebuffer.unbind();
this.setGLViewport();this.offscreenCopyHelper.draw(this.offscreenFramebuffer.colorBuffers[B.COLOR].texture)}}}},{key:"drawSliceViews",value:function(a){var b=this.sliceViewRenderHelper,d=a.lightDirection,c=a.ambientLighting,e=a.directionalLighting;a=a.dataToDevice;for(var f=this.viewer.showSliceViews.value,g=$jscomp.makeIterator(this.sliceViews),h=g.next();!h.done;h=g.next()){var k=$jscomp.makeIterator(h.value);h=k.next().value;if((k.next().value||f)&&0!==h.width&&0!==h.height&&h.hasValidViewport){k=
Math.abs(r.s.dot(d,h.viewportAxes[2]));k=c+k*e;var l=N;r.k.identity(l);l[0]=h.width/2;l[5]=-h.height/2;r.k.multiply(l,h.viewportToData,l);r.k.multiply(l,a,l);var m=P,n=this.viewer.crossSectionBackgroundColor.value;m[0]=n[0];m[1]=n[1];m[2]=n[2];m[3]=1;b.draw(h.offscreenFramebuffer.colorBuffers[0].texture,l,r.u.fromValues(k,k,k,1),P,0,0,1,1)}}}},{key:"drawAxisLines",value:function(){var a=this.viewer.navigationState.position.spatialCoordinates;r.s.transformMat4(M,a,this.projectionMat);M[0]=.5;r.s.transformMat4(I,
M,this.inverseProjectionMat);var b=r.s.distance(I,a);M[0]=0;M[1]=.5;r.s.transformMat4(I,M,this.inverseProjectionMat);var d=r.s.distance(I,a);a=this.gl;r.k.identity(N);b=Math.min(b,d);N[0]=b;N[5]=b;N[10]=b;b=this.navigationState.position.spatialCoordinates;N[12]=b[0];N[13]=b[1];N[14]=b[2];N[15]=1;r.k.multiply(N,this.projectionMat,N);a.WEBGL_draw_buffers.drawBuffersWEBGL([a.WEBGL_draw_buffers.COLOR_ATTACHMENT0_WEBGL]);this.axesLineHelper.draw(N,!1)}},{key:"zoomByMouse",value:function(a){this.navigationState.zoomBy(a)}},
{key:"navigationState",get:function(){return this.viewer.navigationState}},{key:"transparentConfiguration",get:function(){var a=this.transparentConfiguration_;void 0===a&&(a=this.transparentConfiguration_=this.registerDisposer(new D.b(this.gl,{colorBuffers:Object(D.e)(this.gl,2,this.gl.RGBA,this.gl.FLOAT),depthBuffer:this.offscreenFramebuffer.depthBuffer.addRef()})));return a}}]);return g}(p.a)},function(p,g,c){g.c="perspective_view/PerspectiveView";g.a="perspective_view/addLayer";g.b="perspective_view/removeLayer"},
function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=
c)}function q(a){return a.startsWith("key")?a.substring(3):a.startsWith("digit")||a.startsWith("arrow")?a.substring(5):a}c.d(g,"a",function(){return a});p=c(41);c(272);var a=function(a){function c(a){function f(a,b){for(var d=$jscomp.makeIterator(a.parents),c=d.next();!c.done;c=d.next())c=c.value,void 0!==c.label?g(c.label,c):f(c,b);a=$jscomp.makeIterator(a.bindings.entries());for(d=a.next();!d.done;d=a.next()){c=$jscomp.makeIterator(d.value);d=c.next().value;c=c.next().value;var e=d.indexOf(":");
d=d.substring(e+1);b.set(d,c.action)}}function g(a,d){b.has(d)||(a={label:a,entries:new Map},f(d,a.entries),b.set(d,a))}if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var k=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this)),e=k.content;e.classList.add("describe-key-bindings");var d=document.createElement("div");d.classList.add("describe-key-bindings-container");var b=new Map;a=$jscomp.makeIterator(a);for(var h=a.next();!h.done;h=a.next()){var l=$jscomp.makeIterator(h.value);
h=l.next().value;l=l.next().value;g(h,l)}a=$jscomp.makeIterator(b.values());for(h=a.next();!h.done;h=a.next()){l=h.value;h=document.createElement("h2");h.textContent=l.label;d.appendChild(h);h=document.createElement("div");h.className="dl";l=$jscomp.makeIterator(l.entries);for(var n=l.next();!n.done;n=l.next()){var p=$jscomp.makeIterator(n.value);n=p.next().value;p=p.next().value;var v=document.createElement("div"),D=document.createElement("div");D.className="definition-outer-container";v.className=
"definition-container";var y=document.createElement("div");y.className="dt";y.textContent=n.split("+").map(q).join("+");n=document.createElement("div");n.className="dd";n.textContent=p;v.appendChild(y);v.appendChild(n);h.appendChild(D);D.appendChild(v)}d.appendChild(h)}e.appendChild(d);return k}n(c,a);return c}(p.a)},function(p,g){},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==
typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function q(a){var b=document.createElement("div");b.textContent=a.value;return b}g.b=function(a){var b=document.createElement("div");b.className="autocomplete-completion-with-description";
b.textContent=a.value;var d=document.createElement("div");d.className="autocomplete-completion-description";d.textContent=a.description||"";b.appendChild(d);return b};c.d(g,"a",function(){return z});p=c(6);var a=c.n(p),f=c(34);p=c(0);var l=c(10),v=c(274),t=c(53),m=c(275),k=c(276),e=c(3),d=c(152),b=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&
a(b.prototype,d);c&&a(b,c);return b}}(),h=function D(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return D(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(277);$jscomp.initSymbol();var r=Symbol("autocompleteIndex"),x=t.a.fromObject({arrowdown:{action:"cycle-next-active-completion"},arrowup:{action:"cycle-prev-active-completion"},tab:{action:"choose-active-completion-or-prefix",
preventDefault:!1},enter:{action:"choose-active-completion",preventDefault:!1},escape:{action:"cancel",preventDefault:!1,stopPropagation:!1}}),z=function(c){function g(b){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var c=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));c.inputChanged=new e.b;c.prevInputValue="";c.completionsVisible=!1;c.activeCompletionPromise=null;c.activeCompletionCancellationToken=void 0;c.hasFocus=!1;c.completionResult=null;c.dropdownContentsStale=
!0;c.updateHintScrollPositionTimer=null;c.completionElements=null;c.hasResultForDropdown=!1;c.commonPrefix="";c.activeIndex=-1;c.dropdownStyleStale=!0;c.completer=b.completer;b=void 0===b.delay?200:b.delay;var h=c.scheduleUpdateCompletions=a()(function(){var a=c.activeCompletionCancellationToken=new f.b,b=c.activeCompletionPromise=c.completer(c.value,a);null!==b&&b.then(function(a){c.activeCompletionPromise===b&&(c.setCompletions(a),c.activeCompletionPromise=null)})},b);c.registerDisposer(function(){h.cancel()});
b=c.element=document.createElement("div");b.className="autocomplete";var k=document.createElement("div");k.className="autocomplete-dropdown-wrapper";var l=c.dropdownElement=document.createElement("div");l.className="autocomplete-dropdown";var m=c.promptElement=document.createElement("label");m.className="autocomplete-prompt";var n=c.inputWrapperElement=document.createElement("div");n.className="autocomplete-input-wrapper";b.appendChild(m);var r=c.inputElement=document.createElement("input");r.type=
"text";r.autocomplete="off";r.spellcheck=!1;r.className="autocomplete-input";Object(d.a)(m,r);m=c.hintElement=document.createElement("input");m.type="text";m.spellcheck=!1;m.className="autocomplete-hint";m.disabled=!0;n.appendChild(m);n.appendChild(r);k.appendChild(n);k.appendChild(l);b.appendChild(k);c.registerInputHandler();c.handleInputChanged("");c.registerEventListener(c.inputElement,"focus",function(){c.hasFocus||(c.hasFocus=!0,c.dropdownStyleStale=!0,c.updateDropdown())});c.registerEventListener(c.inputElement,
"blur",function(){c.hasFocus&&(c.hasFocus=!1,c.updateDropdown())});c.registerEventListener(b.ownerDocument.defaultView,"resize",function(){c.dropdownStyleStale=!0});c.registerEventListener(b.ownerDocument.defaultView,"scroll",function(){c.dropdownStyleStale=!0});c.registerEventListener(c.dropdownElement,"mousedown",c.handleDropdownMousedown.bind(c));c.registerEventListener(c.inputElement,"keydown",function(){c.hintScrollPositionMayBeStale()});c.registerEventListener(c.inputElement,"mousemove",function(a){0!==
a.buttons&&c.hintScrollPositionMayBeStale()});c.registerDisposer(new t.b(r,x)).allShortcutsAreGlobal=!0;Object(t.c)(r,"cycle-next-active-completion",function(){c.cycleActiveCompletion(1)});Object(t.c)(r,"cycle-prev-active-completion",function(){c.cycleActiveCompletion(-1)});Object(t.c)(r,"choose-active-completion-or-prefix",function(a){c.selectActiveCompletion(!0)&&a.preventDefault()});Object(t.c)(r,"choose-active-completion",function(a){c.selectActiveCompletion(!1)&&a.preventDefault()});Object(t.c)(r,
"cancel",function(a){a.stopPropagation();c.cancel()&&(a.detail.preventDefault(),a.detail.stopPropagation())});return c}n(g,c);b(g,[{key:"hintScrollPositionMayBeStale",value:function(){""!==this.hintElement.value&&this.scheduleUpdateHintScrollPosition()}},{key:"handleDropdownMousedown",value:function(a){this.inputElement.focus();for(var b=this.dropdownElement,d=a.target;d instanceof HTMLElement;d=d.parentElement){var c=d[r];if(void 0!==c){this.selectCompletion(c);break}if(d===b)break}a.preventDefault()}},
{key:"cycleActiveCompletion",value:function(a){if(null!==this.completionResult){var b=this.activeIndex,d=this.completionResult.completions.length;this.setActiveIndex(-1===b?0<a?0:d-1:(b+a+d)%d)}}},{key:"registerInputHandler",value:function(){for(var a=this,b=function(b){b=a.inputElement.value;b!==a.prevInputValue&&(a.prevInputValue=b,a.handleInputChanged(b))},d=$jscomp.makeIterator(["input"]),c=d.next();!c.done;c=d.next())this.registerEventListener(this.inputElement,c.value,b,!1)}},{key:"shouldShowDropdown",
value:function(){return null!==this.completionResult&&this.hasFocus?this.hasResultForDropdown:!1}},{key:"updateDropdownStyle",value:function(){Object(v.a)(this.dropdownElement,this.inputElement,{horizontal:!1});this.dropdownStyleStale=!1}},{key:"updateDropdown",value:function(){if(this.shouldShowDropdown()){var a=this.dropdownElement,b=this.activeIndex;if(this.dropdownContentsStale){var d=this.completionResult,c=void 0===d.makeElement?q:d.makeElement;this.completionElements=d.completions.map(function(e,
f){e=c.call(d,e);e[r]=f;e.classList.add("autocomplete-completion");b===f&&e.classList.add("autocomplete-completion-active");a.appendChild(e);return e});this.dropdownContentsStale=!1}this.dropdownStyleStale&&this.updateDropdownStyle();this.completionsVisible||(a.style.display="block",this.completionsVisible=!0);-1!==b&&Object(k.a)(this.completionElements[b])}else this.completionsVisible&&(this.dropdownElement.style.display="none",this.completionsVisible=!1)}},{key:"setCompletions",value:function(a){this.clearCompletions();
var b=a.completions;0!==b.length&&(this.completionResult=a,1===b.length?(b=b[0],a.showSingleResult?this.hasResultForDropdown=!0:b.value.startsWith(this.prevInputValue)?this.hasResultForDropdown=!1:this.hasResultForDropdown=!0,a.selectSingleResult?this.setActiveIndex(0):this.setHintValue(this.getCompletedValueByIndex(0))):(this.hasResultForDropdown=!0,b=Object(m.a)(function(){function b(b,g){for(;;)switch(d){case 0:f=$jscomp.makeIterator(a.completions),e=f.next();case 1:if(e.done){d=3;break}c=e.value;
d=4;return{value:c.value,done:!1};case 4:if(void 0===g){d=5;break}d=-1;throw g;case 5:case 2:e=f.next();d=1;break;case 3:d=-1;default:return{value:void 0,done:!0}}}var d=0,c,e,f,g={next:function(a){return b(a,void 0)},throw:function(a){return b(void 0,a)},return:function(a){throw Error("Not yet implemented");}};$jscomp.initSymbolIterator();g[Symbol.iterator]=function(){return this};return g}()),b=this.getCompletedValue(b),b.startsWith(this.prevInputValue)&&(this.commonPrefix=b,this.setHintValue(b))),
this.updateDropdown())}},{key:"scheduleUpdateHintScrollPosition",value:function(){var a=this;null===this.updateHintScrollPositionTimer&&(this.updateHintScrollPositionTimer=setTimeout(function(){a.updateHintScrollPosition()},0))}},{key:"setHintValue",value:function(a){var b=this.prevInputValue;a!==b&&a.startsWith(b)||(a="");this.hintElement.value=a;this.scheduleUpdateHintScrollPosition()}},{key:"setActiveIndex",value:function(a){if(!this.dropdownContentsStale){var b=this.activeIndex;-1!==b&&this.completionElements[b].classList.remove("autocomplete-completion-active");
-1!==a&&(b=this.completionElements[a],b.classList.add("autocomplete-completion-active"),Object(k.a)(b))}-1!==a&&this.setHintValue(this.getCompletedValueByIndex(a));this.activeIndex=a}},{key:"getCompletedValueByIndex",value:function(a){return this.getCompletedValue(this.completionResult.completions[a].value)}},{key:"getCompletedValue",value:function(a){return this.prevInputValue.substring(0,this.completionResult.offset)+a}},{key:"selectActiveCompletion",value:function(a){var b=this.activeIndex;if(-1===
b){if(!a)return!1;a=this.completionResult;if(null!==a&&1===a.completions.length)b=0;else return a=this.commonPrefix,a.length>this.value.length?(this.value=a,!0):!1}a=this.getCompletedValueByIndex(b);if(this.value===a)return!1;this.value=a;return!0}},{key:"selectCompletion",value:function(a){this.value=this.getCompletedValueByIndex(a)}},{key:"cancel",value:function(){return!1}},{key:"updateHintScrollPosition",value:function(){this.updateHintScrollPositionTimer=null;this.hintElement.scrollLeft=this.inputElement.scrollLeft}},
{key:"cancelActiveCompletion",value:function(){var a=this.activeCompletionCancellationToken;void 0!==a&&a.cancel();this.activeCompletionCancellationToken=void 0;this.activeCompletionPromise=null}},{key:"handleInputChanged",value:function(a){this.cancelActiveCompletion();this.hintElement.value="";this.clearCompletions();this.inputChanged.dispatch(a);this.scheduleUpdateCompletions()}},{key:"clearCompletions",value:function(){null!==this.completionResult&&(this.activeIndex=-1,this.completionElements=
this.completionResult=null,this.dropdownStyleStale=this.dropdownContentsStale=!0,this.commonPrefix="",Object(l.a)(this.dropdownElement),this.updateDropdown())}},{key:"disposed",value:function(){Object(l.b)(this.element);this.cancelActiveCompletion();null!==this.updateHintScrollPositionTimer&&(clearTimeout(this.updateHintScrollPositionTimer),this.updateHintScrollPositionTimer=null);h(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"disposed",this).call(this)}},{key:"disabled",get:function(){return this.inputElement.disabled},
set:function(a){this.inputElement.disabled=a}},{key:"value",get:function(){return this.prevInputValue},set:function(a){a!==this.prevInputValue&&(this.prevInputValue=this.inputElement.value=a,this.handleInputChanged(a))}}]);return g}(p.a)},function(p,g,c){g.a=function(c,g,p){var a=void 0===p?{}:p,f=void 0===a.horizontal?!1:a.horizontal,l=void 0===a.vertical?!0:a.vertical,n=void 0===a.topMargin?6:a.topMargin,t=void 0===a.bottomMargin?6:a.bottomMargin,m=void 0===a.leftMargin?6:a.leftMargin,k=void 0===
a.rightMargin?6:a.rightMargin;p=void 0===a.maxHeight?!0:a.maxHeight;a=void 0===a.maxWidth?!0:a.maxWidth;g=g.getBoundingClientRect();if(f){f=g.right;var e=c.ownerDocument.documentElement.clientHeight-g.left;f>e?(c.style.left="",c.style.right="0",a&&(c.style.maxWidth=f-m+"px")):(c.style.right="",c.style.left="0",a&&(c.style.maxWidth=e-k+"px"))}l&&(l=g.top-n,t=c.ownerDocument.documentElement.clientHeight-g.bottom-t,l>3*t?(c.style.top="",c.style.bottom="100%",p&&(c.style.maxHeight=l+"px")):(c.style.top=
"100%",c.style.bottom="",p&&(c.style.maxHeight=t+"px")))}},function(p,g,c){g.a=function(c){$jscomp.initSymbol();$jscomp.initSymbolIterator();c=c[Symbol.iterator]();var g=c.next(),p=g.value;if(g.done)return"";for(g=p.length;0<g;){var a=c.next(),f=a.value;if(a.done)break;for(a=0;a<g&&p.charCodeAt(a)===f.charCodeAt(a);++a);g=a}return p.substring(0,g)}},function(p,g,c){g.a=function(c){var g=c.parentElement,p=c.offsetLeft-g.clientLeft,a=c.offsetTop-g.clientTop,f=g.scrollLeft,l=g.scrollTop;a=Math.max(0,
a+c.offsetHeight-(l+g.clientHeight))||Math.min(0,a-l);g.scrollLeft+=Math.max(0,p+c.offsetWidth-(f+g.clientWidth))||Math.min(0,p-f);g.scrollTop+=a}},function(p,g){},function(p,g,c){g.a=function(){var c=document.createElement("button");c.type="submit";c.className="hidden-submit-button";c.style.margin="0";c.style.border="0";c.style.padding="0";c.style.width="0";c.style.height="0";c.style.overflow="hidden";c.tabIndex=-1;return c}},function(p,g){},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");
}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a){return{mouseState:a.mouseState,
showAxisLines:a.showAxisLines,showScaleBar:a.showScaleBar,showPerspectiveSliceViews:a.showPerspectiveSliceViews,inputEventBindings:a.inputEventBindings,visibility:a.visibility,selectedLayer:a.selectedLayer,visibleLayerRoles:a.visibleLayerRoles,navigationState:a.navigationState.addRef(),perspectiveNavigationState:a.perspectiveNavigationState.addRef(),crossSectionBackgroundColor:a.crossSectionBackgroundColor}}function f(a,d,c){var f=Object(e.c)(a,"dragenter",function(b){void 0!==Object(k.c)(b)&&a.classList.add("neuroglancer-drag-over")}),
g=Object(e.c)(a,"dragleave",function(){a.classList.remove("neuroglancer-drag-over")}),h=Object(e.c)(a,"dragover",function(a){Object(t.c)(a)?(Object(b.e)(a,Object(t.b)(a,d)),a.stopPropagation(),a.preventDefault()):void 0!==Object(k.c)(a)&&(Object(k.f)(a,d,!0),a.stopPropagation(),a.preventDefault())}),l=Object(e.c)(a,"drop",function(e){a.classList.remove("neuroglancer-drag-over");if(Object(t.c)(e)){e.stopPropagation();try{var f=JSON.parse(e.dataTransfer.getData(t.d))}catch(W){return}var g=Object(k.b)(e,
d,!1,!1,!0);if(void 0!==g&&g.finalize(e)){e.preventDefault();e.dataTransfer.dropEffect=Object(b.c)();Object(k.a)(e);var h=c();g=$jscomp.makeIterator(g.layers.keys());for(e=g.next();!e.done;e=g.next())h.layerSpecification.add(e.value);try{h.restoreState(f)}catch(W){}}}else if(h=Object(k.b)(e,d,"copy"===Object(b.c)(),!1,!0),void 0!==h&&h.finalize(e))for(e.preventDefault(),e.dataTransfer.dropEffect=Object(b.c)(),Object(k.a)(e),f=c(),h=$jscomp.makeIterator(h.layers.keys()),e=h.next();!e.done;e=h.next())f.layerSpecification.add(e.value)});
return function(){l();h();g();f()}}function l(b,d){var c=document.createElement("div");c.style.flex="1";c.style.width="0px";if("string"===typeof d){if(void 0!==b.parent)throw Error("Invalid layout component specification: "+JSON.stringify(d));return new y(c,d,b.viewer)}Object(h.u)(d);var e=Object(h.w)(d,"type",h.B);switch(e){case "row":case "column":return new E(c,e,Object(h.w)(d,"children",function(a){a=Object(h.a)(a,function(a){return a});if(void 0===b.parent&&0===a.length)throw Error("Stack layout requires at least one child.");
return a}),b);case "viewer":e=b.viewer;var f=new m.a(e.layerSpecification.addRef());c=new t.a(c,Object.assign({display:e.display,layerSpecification:f},a(e)),{showLayerPanel:e.uiControlVisibility.showLayerPanel,showViewerMenu:!0});try{c.restoreState(d)}catch(I){throw c.dispose(),I;}return c;default:return new y(c,d,b.viewer)}}c.d(g,"a",function(){return G});p=c(6);var v=c.n(p),t=c(281),m=c(20),k=c(95),e=c(0),d=c(10),b=c(96),h=c(2),r=c(3),x=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=
b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),z=function B(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return B(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(288);$jscomp.initSymbol();var A=Symbol("layoutComponentContainer"),D=function(a){function b(a,
d,c){u(this,b);var e=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));e.viewer=a;e.parent=c;e.changed=new r.a;e.element=document.createElement("div");var g=e.element;g.style.display="flex";g.style.flex="1";g.style.position="relative";g.style.alignItems="stretch";g.foo="hello";g[A]=e;e.setSpecification(d);var h=[];a=function(a){var b=document.createElement("div");b.className="neuroglancer-layout-split-drop-zone";b.style[a]="0";switch(a){case "left":case "right":var d="row";b.style.width=
"10px";b.style.height="100%";break;case "top":case "bottom":d="column",b.style.height="10px",b.style.width="100%"}b.style.display="none";h.push({element:b,direction:d,orientation:a});g.appendChild(b);e.registerDisposer(f(b,e.viewer.layerSpecification,function(){return e.split(a).newContainer.component}))};a("left");a("right");a("top");a("bottom");var l=!1;e.registerEventListener(g,"dragenter",function(a){if(!l&&void 0!==Object(k.c)(a)){l=!0;a=$jscomp.makeIterator(h);for(var b=a.next();!b.done;b=a.next()){var d=
b.value;b=d.element;var f=d.direction;d=d.orientation;if(void 0===c||f!==c.direction||("left"!==d&&"top"!==d||c.get(0)===e)&&("bottom"!==d&&"right"!==d||c.get(c.length-1)===e))d=e.component,d instanceof E&&d.direction===f||(b.style.display="block")}}},!0);e.registerEventListener(g,"drop",function(a){if(l){l=!1;a=$jscomp.makeIterator(h);for(var b=a.next();!b.done;b=a.next())b.value.element.style.display="none"}});e.registerEventListener(g,"dragleave",function(a){a=a.relatedTarget;if(l&&!(a instanceof
HTMLElement&&e.element.contains(a))){l=!1;a=$jscomp.makeIterator(h);for(var b=a.next();!b.done;b=a.next())b.value.element.style.display="none"}},!0);return e}q(b,a);x(b,[{key:"unsetComponent",value:function(){var a=this.componentValue;void 0!==a&&(a.changed.remove(this.changed.dispatch),this.element.removeChild(a.element),a.dispose())}},{key:"setComponent",value:function(a){var b=this;this.unsetComponent();this.componentValue=a;a.changed.add(this.changed.dispatch);this.element.appendChild(a.element);
if(a instanceof t.a){var d=a.layerManager,c=a.registerCancellable(v()(function(){0===d.managedLayers.length&&b.dispose()},0));a.registerDisposer(d.layersChanged.add(function(){0===d.managedLayers.length&&c()}));c()}else if(a instanceof E){var e=a.registerCancellable(v()(function(){var d=a.length;if(0===d&&void 0!==b.parent)b.dispose();else if(1===d){d=a.get(0).component;if(void 0===b.parent&&d instanceof t.a){var c=d.layout.specification.toJSON();d.viewerNavigationState.copyToParent();var e=new Set(d.layerManager.managedLayers),
f=d.layerSpecification;f.rootLayers.filter(function(a){return e.has(a)});f.rootLayers.managedLayers=Array.from(d.layerManager.managedLayers);f.rootLayers.layersChanged.dispatch()}else c=d.toJSON();b.setSpecification(c)}},0));a.registerDisposer(a.changed.add(function(){2>a.length&&e()}));e()}}},{key:"toJSON",value:function(){return this.component.toJSON()}},{key:"setSpecification",value:function(a){this.setComponent(l(this,a))}},{key:"disposed",value:function(){this.unsetComponent();this.componentValue=
void 0;z(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"split",value:function(a){var b={type:"viewer"},d=this.parent;if(void 0!==d){if("left"===a&&"row"===d.direction||"top"===a&&"column"===d.direction)return{newContainer:d.insertChild(b,this),existingContainer:this};if("right"===a&&"row"===d.direction||"bottom"===a&&"column"===d.direction)return{newContainer:d.insertChild(b),existingContainer:this}}d=this.component;d=d instanceof y?d.layerGroupViewer.toJSON():
d.toJSON();var c="left"===a||"right"===a?"row":"column";switch(a){case "left":case "top":var e={type:c,children:[b,d]};var f=0;break;case "right":case "bottom":e={type:c,children:[d,b]},f=1}this.setSpecification(e);a=this.component;return{newContainer:a.get(f),existingContainer:a.get(1-f)}}},{key:"component",get:function(){return this.componentValue}}],[{key:"getFromElement",value:function(a){return a[A]}}]);return b}(e.a),y=function(b){function d(b,c,e){u(this,d);var f=n(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));
f.element=b;f.layerGroupViewer=f.registerDisposer(new t.a(b,Object.assign({display:e.display,layerSpecification:e.layerSpecification.addRef()},a(e)),{showLayerPanel:e.uiControlVisibility.showLayerPanel,showViewerMenu:!1}));f.layerGroupViewer.layout.restoreState(c);return f}q(d,b);x(d,[{key:"toJSON",value:function(){return this.layerGroupViewer.layout.specification.toJSON()}},{key:"changed",get:function(){return this.layerGroupViewer.layout.changed}}]);return d}(e.a),E=function(a){function b(a,d,c,
e){u(this,b);var f=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));f.element=a;f.direction=d;f.container=e;f.changed=new r.a;a.classList.add("neuroglancer-stack-layout");a.classList.add("neuroglancer-stack-layout-"+d);a.style.display="flex";a.style.flexDirection=d;a.appendChild(f.makeDropPlaceholder(f));a=$jscomp.makeIterator(c);for(d=a.next();!d.done;d=a.next())f.insertChild(d.value);return f}q(b,a);$jscomp.initSymbol();$jscomp.initSymbolIterator();x(b,[{key:"makeDropPlaceholder",value:function(a){var b=
this,c=document.createElement("div");c.className="neuroglancer-stack-layout-drop-placeholder";a.registerDisposer(f(c,this.viewer.layerSpecification,function(){var a=c.nextElementSibling,d;null!==a&&(d=D.getFromElement(a));return b.insertChild({type:"viewer",layers:[]},d).component}));a.registerDisposer(function(){Object(d.b)(c)});return c}},{key:"get",value:function(a){return D.getFromElement(this.element.children[2*a+1])}},{key:"insertChild",value:function(a,b){var d=this,c=new D(this.viewer,a,this);
a=this.makeDropPlaceholder(c);c.element.classList.add("neuroglancer-stack-layout-child");c.registerDisposer(c.changed.add(this.changed.dispatch));c.registerDisposer(function(){d.element.removeChild(c.element);d.changed.dispatch()});b=void 0!==b?b.element:null;this.element.insertBefore(c.element,b);this.element.insertBefore(a,b);this.changed.dispatch();return c}},{key:"disposed",value:function(){this.clear();z(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},
{key:"clear",value:function(){for(;0!==this.length;)this.get(0).dispose()}},{key:Symbol.iterator,value:function(){function a(a,g){for(;;)switch(b){case 0:e=f,c=e.length,d=0;case 1:if(!(d<c)){b=3;break}b=4;return{value:f.get(d),done:!1};case 4:if(void 0===g){b=5;break}b=-1;throw g;case 5:case 2:++d;b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,f=this,g={next:function(b){return a(b,void 0)},throw:function(b){return a(void 0,b)},return:function(a){throw Error("Not yet implemented");
}};$jscomp.initSymbolIterator();g[Symbol.iterator]=function(){return this};return g}},{key:"toJSON",value:function(){return{type:this.direction,children:Array.from(this).map(function(a){return a.toJSON()})}}},{key:"length",get:function(){return(this.element.childElementCount-1)/2}},{key:"viewer",get:function(){return this.container.viewer}}]);return b}(e.a),G=function(a){function b(a,d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.viewer=a;c.defaultSpecification=d;
c.container=c.registerDisposer(new D(c.viewer,c.defaultSpecification,void 0));return c}q(b,a);x(b,[{key:"reset",value:function(){this.container.setSpecification(this.defaultSpecification)}},{key:"restoreState",value:function(a){this.container.setSpecification(a)}},{key:"disposed",value:function(){z(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}},{key:"toJSON",value:function(){var a=this.container.toJSON();if(a!==this.defaultSpecification)return a}},{key:"changed",
get:function(){return this.container.changed}},{key:"element",get:function(){return this.container.element}}]);return b}(e.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){a=new e.a(a);var d=a.element;d.classList.add("neuroglancer-layer-group-viewer-context-menu");var c=document.createElement("button");c.textContent="Remove layer group";d.appendChild(c);a.registerEventListener(c,"click",function(){b.layerSpecification.layerManager.clear()});c=b.viewerNavigationState;
c=$jscomp.makeIterator([["Position",c.position.link],["Cross-section orientation",c.crossSectionOrientation.link],["Cross-section zoom",c.crossSectionZoom.link],["Perspective orientation",c.perspectiveOrientation.link],["Perspective zoom",c.perspectiveZoom.link]]);for(var f=c.next();!f.done;f=c.next()){var g=$jscomp.makeIterator(f.value);f=g.next().value;g=g.next().value;g=a.registerDisposer(new A.a(g));var h=document.createElement("label");h.style.display="flex";h.style.flexDirection="row";h.style.whiteSpace=
"nowrap";h.textContent=f;h.appendChild(g.element);d.appendChild(h)}return a}g.c=function(a){return-1!==a.dataTransfer.types.indexOf("neuroglancer-layer-group-viewer")};g.b=function(a,b){if(a.shiftKey)return"copy";if(a.ctrlKey)return"move";a=E&&E.viewer.layerSpecification.rootLayers===b.rootLayers?E.viewer:void 0;return void 0!==a?"move":"copy"};c.d(g,"a",function(){return H});p=c(6);var f=c.n(p),l=c(149),v=c(282),t=c(20),m=c(58),k=c(57),e=c(155),d=c(95),b=c(156),h=c(66);p=c(0);var r=c(10),x=c(19),
z=c(29),A=c(286),D=function C(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return C(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},y=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}();
c(287);g.d="neuroglancer-layer-group-viewer";var E,G=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.position=new m.b(a.navigationState.position.addRef());d.crossSectionOrientation=new m.a(a.navigationState.pose.orientation.addRef());d.crossSectionZoom=new m.c(a.navigationState.zoomFactor.addRef());d.navigationState=d.registerDisposer(new m.e(new m.g(d.position.value,d.crossSectionOrientation.value),d.crossSectionZoom.value));d.perspectiveOrientation=
new m.a(a.perspectiveNavigationState.pose.orientation.addRef());d.perspectiveZoom=new m.c(a.perspectiveNavigationState.zoomFactor.addRef());d.perspectiveNavigationState=d.registerDisposer(new m.e(new m.g(d.position.value.addRef(),d.perspectiveOrientation.value),d.perspectiveZoom.value));return d}q(b,a);y(b,[{key:"copyToParent",value:function(){for(var a=$jscomp.makeIterator([this.position,this.crossSectionOrientation,this.crossSectionZoom,this.perspectiveOrientation,this.perspectiveZoom]),b=a.next();!b.done;b=
a.next())b.value.copyToPeer()}},{key:"register",value:function(a){a.add("position",this.position);a.add("crossSectionOrientation",this.crossSectionOrientation);a.add("crossSectionZoom",this.crossSectionZoom);a.add("perspectiveOrientation",this.perspectiveOrientation);a.add("perspectiveZoom",this.perspectiveZoom)}}]);return b}(p.a),H=function(c){function e(a,d,c){c=void 0===c?{}:c;u(this,e);var g=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));g.element=a;g.viewerState=d;g.state=new z.a;
g.options=Object.assign({showLayerPanel:new k.b(!0),showViewerMenu:!1},c);g.layerSpecification=g.registerDisposer(d.layerSpecification);g.viewerNavigationState=g.registerDisposer(new G(d));g.viewerNavigationState.register(g.state);g.layerSpecification instanceof t.a?g.state.add("layers",g.layerSpecification):g.state.add("layers",{changed:g.layerSpecification.changed,toJSON:function(){return g.layerSpecification.layerManager.managedLayers.map(function(a){return a.name})},reset:function(){throw Error("not implemented");
},restoreState:function(){throw Error("not implemented");}});a.classList.add("neuroglancer-layer-group-viewer");g.registerDisposer(new h.a(a));g.layout=g.registerDisposer(new l.a(g,"xy"));g.state.add("layout",g.layout);g.registerActionBindings();g.registerDisposer(g.layerManager.useDirectly());g.registerDisposer(Object(b.a)(a,g.navigationState.position));g.registerDisposer(g.options.showLayerPanel.changed.add(g.registerCancellable(f()(function(){return g.updateUI()},0))));g.makeUI();return g}q(e,
c);y(e,[{key:"bindAction",value:function(a,b){this.registerDisposer(Object(x.c)(this.element,a,b))}},{key:"registerActionBindings",value:function(){var a=this;this.bindAction("add-layer",function(){a.layerPanel&&a.layerPanel.addLayerMenu()})}},{key:"toJSON",value:function(){return Object.assign({type:"viewer"},this.state.toJSON())}},{key:"reset",value:function(){this.state.reset()}},{key:"restoreState",value:function(a){this.state.restoreState(a)}},{key:"makeUI",value:function(){this.element.style.flex=
"1";this.element.style.display="flex";this.element.style.flexDirection="column";this.element.appendChild(this.layout.element);this.updateUI()}},{key:"updateUI",value:function(){var b=this,c=this.options,e=c.showLayerPanel.value;void 0===this.layerPanel||e?e&&void 0===this.layerPanel&&(e=this.layerPanel=new v.a(this.display,this.layerSpecification,this.viewerNavigationState,this.viewerState.selectedLayer),c.showViewerMenu?(e.registerDisposer(a(e.element,this)),e.element.title="Right click for options, drag to move/copy layer group."):
e.element.title="Drag to move/copy layer group.",e.element.draggable=!0,this.registerEventListener(e.element,"dragstart",function(a){Object(d.e)(a,{manager:b.layerSpecification,layers:b.layerManager.managedLayers});var c=function(){E&&E.viewer===b&&(E=void 0);b.unregisterDisposer(c)};E={viewer:b,disposer:c};b.registerDisposer(c);var e=b.toJSON();delete e.layers;a.dataTransfer.setData("neuroglancer-layer-group-viewer",JSON.stringify(e))}),this.registerEventListener(e.element,"dragend",function(a){Object(d.a)(a);
void 0!==E&&E.viewer===b&&E.disposer()}),this.element.insertBefore(e.element,this.element.firstChild)):(this.layerPanel.dispose(),this.layerPanel=void 0)}},{key:"disposed",value:function(){Object(r.a)(this.element);var a=this.layerPanel;void 0!==a&&(a.dispose(),this.layerPanel=void 0);D(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"perspectiveNavigationState",get:function(){return this.viewerNavigationState.perspectiveNavigationState}},{key:"navigationState",
get:function(){return this.viewerNavigationState.navigationState}},{key:"display",get:function(){return this.viewerState.display}},{key:"selectedLayer",get:function(){return this.viewerState.selectedLayer}},{key:"layerManager",get:function(){return this.layerSpecification.layerManager}},{key:"chunkManager",get:function(){return this.layerSpecification.chunkManager}},{key:"mouseState",get:function(){return this.viewerState.mouseState}},{key:"showAxisLines",get:function(){return this.viewerState.showAxisLines}},
{key:"showScaleBar",get:function(){return this.viewerState.showScaleBar}},{key:"showPerspectiveSliceViews",get:function(){return this.viewerState.showPerspectiveSliceViews}},{key:"inputEventBindings",get:function(){return this.viewerState.inputEventBindings}},{key:"visibility",get:function(){return this.viewerState.visibility}},{key:"visibleLayerRoles",get:function(){return this.viewerState.visibleLayerRoles}},{key:"crossSectionBackgroundColor",get:function(){return this.viewerState.crossSectionBackgroundColor}},
{key:"changed",get:function(){return this.state.changed}}]);return e}(p.a)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=
Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function a(a,b){if("move"===a.method)return!1;a.manager.layerManager.filter(function(b){return!a.layers.has(b)});return void 0!==b&&a.layers.has(b)}function f(d,c,f){function g(c,e){var g=d.dropLayers,h=e?Object(m.d)(c,d.manager):Object(b.c)(),k=!0;if(void 0!==g&&(e&&Object(b.e)(c,h),!g.compatibleWithMethod(h)&&(d.dropLayers=void 0,a(g,
f))))return;if(void 0===g){g=d.dropLayers=Object(m.b)(c,d.manager,"copy"===h,!0,!1);if(void 0===g)return;k="move"===g.method}if(void 0!==f&&g.layers.has(f))return g;if(k){var l=d.manager.layerManager,n=new Set,r=Number.POSITIVE_INFINITY;c=l.managedLayers=l.managedLayers.filter(function(a,b){return g.layers.has(a)?(r===Number.POSITIVE_INFINITY&&(r=b),n.add(a),!1):!0});void 0!==f?(e=c.indexOf(f),r<=e&&++e):e=c.length;h=$jscomp.makeIterator(g.layers.keys());for(k=h.next();!k.done;k=h.next())k=k.value,
n.has(k)||g.layers.delete(k);c.splice.apply(c,[].concat([e,0],$jscomp.arrayFromIterable(g.layers.keys())));l.layersChanged.dispatch()}else for(void 0!==f&&(l=d.manager.layerManager.managedLayers.indexOf(f)),c=$jscomp.makeIterator(g.layers.keys()),e=c.next();!e.done;e=c.next())d.manager.add(e.value,l);return g}var h=Object(e.c)(c,"dragenter",function(a){void 0!==g(a,!0)&&a.preventDefault()}),k=Object(e.c)(c,"drop",function(c){c.preventDefault();var e=g(c,!1);void 0!==e&&(e.finalize(c)?(c.dataTransfer.dropEffect=
Object(b.c)(),Object(m.a)("move"===e.method?void 0:c)):a(e));d.dropLayers=void 0}),l=Object(e.c)(c,"dragover",function(a){void 0!==g(a,!0)&&(a.preventDefault(),a.stopPropagation())});return function(){l();k();h()}}c.d(g,"a",function(){return D});var l=c(151),v=c(20),t=c(58),m=c(95),k=c(153),e=c(0),d=c(10),b=c(96),h=c(86),r=c(97),x=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,
c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),z=function E(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return E(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}};c(40);c(284);c(68);var A=function(a){function b(a,d){u(this,b);var c=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));c.layer=a;c.panel=d;var e=c.element=document.createElement("div");
e.title="Control+click for layer options, drag to move/copy.";e.className="neuroglancer-layer-item neuroglancer-noselect";var g=c.labelElement=document.createElement("span");g.className="neuroglancer-layer-item-label";var k=c.layerNumberElement=document.createElement("span");k.className="neuroglancer-layer-item-number";var r=c.valueElement=document.createElement("span");r.className="neuroglancer-layer-item-value";var p=Object(h.a)();p.title="Delete layer";c.registerEventListener(p,"click",function(a){c.panel.layerManager.removeManagedLayer(c.layer);
a.stopPropagation()});e.appendChild(k);e.appendChild(g);e.appendChild(r);e.appendChild(p);c.registerEventListener(e,"click",function(b){b.ctrlKey?(d.selectedLayer.layer=a,d.selectedLayer.visible=!0):a.setVisible(!a.visible)});c.registerEventListener(e,"contextmenu",function(b){d.selectedLayer.layer=a;d.selectedLayer.visible=!0;b.stopPropagation();b.preventDefault()});e.draggable=!0;c.registerEventListener(e,"dragstart",function(a){Object(m.e)(a,{manager:d.manager,layers:[c.layer]});a.stopPropagation()});
c.registerEventListener(e,"dragend",function(a){Object(m.a)(a)});c.registerDisposer(f(c.panel,e,c.layer));c.registerEventListener(e,"dblclick",function(b){a instanceof v.b&&new l.a(c.panel.manager,a)});return c}q(b,a);x(b,[{key:"update",value:function(){var a=this.layer;this.labelElement.textContent=a.name;this.element.setAttribute("layer-visible",a.visible.toString());this.element.setAttribute("layer-selected",(a===this.panel.selectedLayer.layer).toString())}},{key:"disposed",value:function(){this.element.parentElement.removeChild(this.element);
z(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"disposed",this).call(this)}}]);return b}(e.a),D=function(c){function e(d,c,g,h){u(this,e);var l=n(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));l.display=d;l.manager=c;l.viewerNavigationState=g;l.selectedLayer=h;l.layerWidgets=new Map;l.element=document.createElement("div");l.layerUpdateNeeded=!0;l.valueUpdateNeeded=!1;l.layerWidgetInsertionPoint=document.createElement("div");l.positionWidget=l.registerDisposer(new r.b(l.viewerNavigationState.position.value));
l.scheduleUpdate=l.registerCancellable(Object(k.a)(function(){return l.update()}));l.registerDisposer(h);var m=l.element;m.className="neuroglancer-layer-panel";l.registerDisposer(c.layerSelectedValues.changed.add(function(){l.handleLayerValuesChanged()}));l.registerDisposer(c.layerManager.layersChanged.add(function(){l.handleLayersChanged()}));l.registerDisposer(h.changed.add(function(){l.handleLayersChanged()}));l.layerWidgetInsertionPoint.style.display="none";l.element.appendChild(l.layerWidgetInsertionPoint);
c=l.addButton=document.createElement("div");c.className="neuroglancer-layer-add-button neuroglancer-button";c.title="Click to add layer, control+click to add local annotation layer.";c.textContent="+";g=l.dropZone=document.createElement("div");g.className="neuroglancer-layer-panel-drop-zone";l.registerEventListener(c,"click",function(a){a.ctrlKey?(a=new v.b("annotation",{},l.manager),l.manager.initializeLayerFromSpec(a,{type:"annotation"}),l.manager.add(a)):l.addLayerMenu()});m.appendChild(c);m.appendChild(g);
l.registerDisposer(Object(b.d)(c));m.appendChild(l.positionWidget.element);h=function(){l.positionWidget.element.style.display=l.viewerNavigationState.position.link.value===t.d.LINKED?"none":null};l.registerDisposer(l.viewerNavigationState.position.link.changed.add(h));h();l.update();l.registerEventListener(m,"dragleave",function(b){b.relatedTarget&&m.contains(b.relatedTarget)||(b=l.dropLayers,void 0!==b&&(a(b),l.dropLayers=void 0))});l.registerDisposer(f(l,c,void 0));l.registerDisposer(f(l,g,void 0));
l.registerDisposer(d.updateStarted.add(function(){return l.updateLayers()}));return l}q(e,c);x(e,[{key:"disposed",value:function(){this.layerWidgets.forEach(function(a){return a.dispose()});this.layerWidgets=void 0;Object(d.b)(this.element);z(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"disposed",this).call(this)}},{key:"handleLayersChanged",value:function(){this.layerUpdateNeeded=!0;this.handleLayerValuesChanged()}},{key:"handleLayerValuesChanged",value:function(){this.valueUpdateNeeded||
(this.valueUpdateNeeded=!0,this.scheduleUpdate())}},{key:"update",value:function(){this.valueUpdateNeeded=!1;this.updateLayers();for(var a=this.manager.layerSelectedValues,b=$jscomp.makeIterator(this.layerWidgets),d=b.next();!d.done;d=b.next()){d=$jscomp.makeIterator(d.value);var c=d.next().value;d=d.next().value;var e=c.layer;c="";null!==e&&(e=a.get(e),void 0!==e&&(c=""+e));d.valueElement.textContent=c}}},{key:"updateLayers",value:function(){var a=this;if(this.layerUpdateNeeded){this.layerUpdateNeeded=
!1;var b=this.element,d=new Set,c=this.layerWidgetInsertionPoint.nextElementSibling;this.manager.layerManager.managedLayers.forEach(function(e){d.add(e);var f=a.layerWidgets.get(e),g=a.manager.rootLayers.managedLayers.indexOf(e);void 0===f&&(f=new A(e,a),a.layerWidgets.set(e,f));f.layerNumberElement.textContent=""+(1+g);f.update();e=f.element;e!==c&&b.insertBefore(f.element,c);c=e.nextElementSibling});for(var e=$jscomp.makeIterator(this.layerWidgets),f=e.next();!f.done;f=e.next()){var g=$jscomp.makeIterator(f.value);
f=g.next().value;g=g.next().value;d.has(f)||(this.layerWidgets.delete(f),g.dispose())}}}},{key:"addLayerMenu",value:function(){new l.a(this.manager)}},{key:"layerManager",get:function(){return this.manager.layerManager}}]);return e}(e.a)},function(p,g){},function(p,g){},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&
null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return a});p=c(0);var q=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,
f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),a=function(a){function c(a){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var f=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));f.model=a;f.element=document.createElement("select");f.valueIndexMap=new Map;for(var g=f.element,k=f.valueIndexMap,e=0,d=$jscomp.makeIterator(Object.keys(a.enumType)),b=d.next();!b.done;b=d.next())if(b=b.value,isNaN(Number(b))){var h=document.createElement("option");h.textContent=
h.value=b.toLowerCase();g.appendChild(h);k.set(a.enumType[b],e);++e}f.registerDisposer(a.changed.add(function(){return f.updateView()}));f.registerEventListener(g,"change",function(){return f.updateModel()});f.updateView();return f}n(c,a);q(c,[{key:"updateView",value:function(){this.element.selectedIndex=this.valueIndexMap.get(this.model.value)}},{key:"updateModel",value:function(){this.model.restoreState(this.element.value)}}]);return c}(p.a)},function(p,g){},function(p,g){},function(p,g,c){function u(a,
b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?
Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return b});p=c(290);c.n(p);p=c(0);var a=c(10),f=c(26),l=c(86),v=c(35),t=function r(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return r(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},m=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in
c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),k=function(a){function b(a){u(this,b);var d=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));d.layer=a;d.tabView=new v.d(d.layer.tabs.addRef(),d.visibility);d.element.appendChild(d.tabView.element);d.element.classList.add("neuroglancer-layer-side-panel-info-panel");d.tabView.element.style.flex="1";return d}q(b,a);return b}(v.b),e=function(a){function b(){u(this,b);var a=
n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));a.element.classList.add("neuroglancer-layer-side-panel-info-panel-empty");a.element.textContent="Information about this layer will be available once it finishes loading.";return a}q(b,a);m(b,[{key:"layer",get:function(){return null}}]);return b}(v.b),d=function(a){function b(a,d,c){u(this,b);var f=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));f.layer=a;f.layerManager=d;f.collapse=c;f.element=document.createElement("div");f.title=
document.createElement("div");f.layerName=document.createElement("input");f.stack=f.registerDisposer(new v.a(function(a){return null===a?new e:new k(a)},f.visibility));var g=f.element;d=f.title;c=f.layerName;var m=f.stack;g.className="neuroglancer-managed-user-layer-info-panel";d.className="neuroglancer-layer-side-panel-title";m.element.classList.add("neuroglancer-layer-side-panel-content-container");g.appendChild(d);g.appendChild(m.element);g=Object(l.a)();g.title="Close side panel";g.addEventListener("click",
function(){f.collapse()});d.appendChild(c);c.spellcheck=!1;c.title="Rename layer";d.appendChild(g);c.addEventListener("change",function(){return f.handleLayerNameViewChanged()});c.addEventListener("blur",function(){return f.handleLayerNameViewChanged()});f.registerDisposer(a.layerChanged.add(function(){return f.handleLayerNameModelChanged()}));f.handleUserLayerChanged();f.handleLayerNameModelChanged();return f}q(b,a);m(b,[{key:"handleUserLayerChanged",value:function(){this.stack.selected!==this.layer.layer&&
(this.stack.invalidateAll(),this.stack.selected=this.layer.layer)}},{key:"handleLayerNameModelChanged",value:function(){this.layerName.value=this.layer.name}},{key:"handleLayerNameViewChanged",value:function(){var a=this.layer;if(void 0!==a){var b=this.layerName.value;b!==a.name&&(b=this.layerManager.getUniqueLayerName(b),this.layerName.value=b,a.name=b,a.layerChanged.dispatch())}}}]);return b}(v.b),b=function(b){function c(a){u(this,c);var b=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));
b.state=a;b.element=document.createElement("div");b.stack=b.registerDisposer(new v.a(function(a){return new d(a,b.state.layerManager,b.collapse.bind(b))}));var e=b.element,f=b.stack;e.className="neuroglancer-layer-side-panel";f.element.classList.add("neuroglancer-layer-info-panel-container");e.appendChild(f.element);b.registerDisposer(a.changed.add(function(){return b.handleStateChanged()}));b.registerDisposer(a.layerManager.layersChanged.add(function(){return b.handleLayersChanged()}));b.handleStateChanged();
return b}q(c,b);m(c,[{key:"handleLayersChanged",value:function(){for(var a=this.state.layerManager,b=this.stack,d=$jscomp.makeIterator(b.tabs.keys()),c=d.next();!c.done;c=d.next())c=c.value,a.has(c)||b.invalidate(c)}},{key:"collapse",value:function(){!0===this.state.visible&&(this.state.visible=!1,this.state.changed.dispatch())}},{key:"handleStateChanged",value:function(){var a=this.state,b=a.visible;this.element.style.display=b?null:"none";this.stack.visibility.value=b?f.b.VISIBLE:f.b.IGNORED;this.stack.selected=
a.layer}},{key:"disposed",value:function(){Object(a.b)(this.element);t(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}}]);return c}(p.a)},function(p,g){},function(p,g,c){function u(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function n(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}c.d(g,"a",function(){return b});p=c(292);c.n(p);p=c(6);var q=c.n(p),a=c(22),f=c(80),l=c(85);p=c(0);var v=c(10),t=c(139),m=c(293),k=function(){function a(a,b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,
d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),e=function r(a,b,d){null===a&&(a=Function.prototype);var c=Object.getOwnPropertyDescriptor(a,b);if(void 0===c){if(a=Object.getPrototypeOf(a),null!==a)return r(a,b,d)}else{if("value"in c)return c.value;b=c.get;return void 0===b?void 0:b.call(d)}},d=new Map([[a.c.AXIS_ALIGNED_BOUNDING_BOX,function(a,b,d,c){c=document.createElement("div");c.className="neuroglancer-annotation-details-volume";c.textContent=Object(t.a)(a.pointA,a.pointB,d);b.appendChild(c)}]]),
b=function(b){function c(a,b,d){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var e=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));e.mouseState=a;e.layerManager=b;e.voxelSize=d;e.tooltip=void 0;e.debouncedShowTooltip=e.registerCancellable(q()(function(){return e.doCreateTooltip()},500));e.debouncedShowTooltip0=e.registerCancellable(q()(function(){return e.doCreateTooltip()},0));e.doCreateTooltip=function(){e.debouncedShowTooltip.cancel();e.debouncedShowTooltip0.cancel();
var a=e.mouseState;e.maybeCreateTooltip()?e.tooltip.updatePosition(a.pageX,a.pageY):(a=e.tooltip,void 0!==a&&(a.dispose(),e.tooltip=void 0),e.setReference(void 0))};e.registerDisposer(a.changed.add(function(){return e.mouseStateChanged()}));return e}n(c,b);k(c,[{key:"setReference",value:function(a){var b=this.reference;void 0!==b&&(b.changed.remove(this.debouncedShowTooltip0),b.dispose(),this.reference=void 0);this.reference=a;void 0!==a&&a.changed.add(this.debouncedShowTooltip0)}},{key:"maybeCreateTooltip",
value:function(){var b=Object(f.a)(this.mouseState,this.layerManager);if(void 0===b||!this.voxelSize.valid)return!1;var c=this.tooltip;void 0===c&&(c=this.tooltip=new m.a,c.element.classList.add("neuroglancer-mouse-selection-tooltip"));var e=b.annotationLayer.source.getReference(b.id);this.setReference(e);if(null===e.value)return!1;Object(v.a)(c.element);var g=document.createElement("div");g.className="neuroglancer-mouse-selection-tooltip-title";g.textContent=""+b.layer.name;var k=document.createElement("div");
k.className="neuroglancer-mouse-selection-tooltip-description";e=e.value;k.textContent=void 0===e?"Loading...":e.description||"";c.element.appendChild(g);c.element.appendChild(k);null!=e&&(b=b.annotationLayer.objectToGlobal,g=Object(a.f)(e.type),k=document.createElement("div"),k.appendChild(document.createTextNode(g.icon)),Object(l.b)(k,e,b,this.voxelSize),k.className="neuroglancer-mouse-selection-tooltip-annotation-corners",c.element.appendChild(k),g=d.get(e.type),void 0!==g&&g(e,c.element,b,this.voxelSize));
return!0}},{key:"mouseStateChanged",value:function(){var a=this.tooltip;void 0!==a&&(a.dispose(),this.tooltip=void 0);this.setReference(void 0);this.debouncedShowTooltip()}},{key:"disposed",value:function(){var a=this.tooltip;void 0!==a&&(a.dispose(),this.tooltip=void 0);this.setReference(void 0);e(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"disposed",this).call(this)}}]);return c}(p.a)},function(p,g){},function(p,g,c){function u(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+
typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return f});p=c(294);c.n(p);p=c(0);var n=c(10),q=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),a=function v(a,
c,f){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,c);if(void 0===e){if(a=Object.getPrototypeOf(a),null!==a)return v(a,c,f)}else{if("value"in e)return e.value;c=e.get;return void 0===c?void 0:c.call(f)}},f=function(c){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");var a=(f.__proto__||Object.getPrototypeOf(f)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");a=!a||"object"!==
typeof a&&"function"!==typeof a?this:a;a.element=document.createElement("div");var c=a.element;c.className="neuroglancer-tooltip";c.style.visibility="hidden";document.body.appendChild(c);return a}u(f,c);q(f,[{key:"updatePosition",value:function(a,c){var e=this.element;e.style.left=a+"px";e.style.top=c+"px";e.style.visibility="inherit"}},{key:"disposed",value:function(){Object(n.b)(this.element);a(f.prototype.__proto__||Object.getPrototypeOf(f.prototype),"disposed",this).call(this)}}]);return f}(p.a)},
function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=
c)}c.d(g,"a",function(){return v});p=c(140);c.n(p);p=c(296);c.n(p);p=c(157);c.n(p);p=c(297);c.n(p);p=c(298);c.n(p);p=c(299);c.n(p);p=c(141);c.n(p);p=c(300);c.n(p);p=c(42);var q=c.n(p);p=c(6);var a=c.n(p);p=c(41);var f=c(29),l=function(){function a(a,c){for(var e=0;e<c.length;e++){var d=c[e];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,f,e){f&&a(c.prototype,f);e&&a(c,e);return c}}(),v=function(c){function g(c){if(!(this instanceof
g))throw new TypeError("Cannot call a class as a function");var e=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));e.viewer=c;e.parsedValue=null;e.debouncedValueUpdater=a()(function(){var a=e.textEditor.getValue();try{var b=JSON.parse(a);e.parsedValue=b;e.applyButton.disabled=!1;e.textEditor.setOption("lint",void 0)}catch(z){e.parsedValue=null;e.applyButton.disabled=!0;var c=0,f=0,g="Unknown parse error";z instanceof Error&&(b=z.message.match(/^((?:.|\n)*) in JSON at position ([0-9]+)$/),
null!==b?(g=b[1],b=parseInt(b[2],10),a=a.substring(0,b).split("\n"),c=a.length-1,f=a[a.length-1].length):g=z.message);e.textEditor.setOption("lint",{getAnnotations:function(){return[{message:g,severity:"error",from:q.a.Pos(c,f)}]}})}},100);e.content.classList.add("neuroglancer-state-editor");c=e.applyButton=document.createElement("button");c.textContent="Apply changes";e.content.appendChild(c);c.addEventListener("click",function(){return e.applyChanges()});c.disabled=!0;e.textEditor=q()(function(a){},
{value:"",mode:{name:"javascript",json:!0},foldGutter:!0,gutters:["CodeMirror-lint-markers","CodeMirror-foldgutter"]});e.updateView();e.textEditor.on("change",function(){e.debouncedValueUpdater()});e.content.appendChild(e.textEditor.getWrapperElement());e.textEditor.refresh();return e}n(g,c);l(g,[{key:"applyChanges",value:function(){null!==this.parsedValue&&(console.log("applying changes"),console.log(this.parsedValue),this.viewer.state.reset(),this.viewer.state.restoreState(this.parsedValue));this.applyButton.disabled=
!0}},{key:"updateView",value:function(){this.textEditor.setValue(this.getJson());this.textEditor.execCommand("foldAll");this.textEditor.execCommand("unfold")}},{key:"getJson",value:function(){return JSON.stringify(Object(f.c)(this.viewer.state).value,null,"  ")}}]);return g}(p.a)},function(p,g,c){(function(c){c.defineMode("javascript",function(g,p){function a(a,b,c){jb=a;Va=c;return b}function f(b,c){var d=b.next();if('"'==d||"'"==d)return c.tokenize=l(d),c.tokenize(b,c);if("."==d&&b.match(/^\d+(?:[eE][+\-]?\d+)?/))return a("number",
"number");if("."==d&&b.match(".."))return a("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(d))return a(d);if("="==d&&b.eat(">"))return a("=>","operator");if("0"==d&&b.eat(/x/i))return b.eatWhile(/[\da-f]/i),a("number","number");if("0"==d&&b.eat(/o/i))return b.eatWhile(/[0-7]/i),a("number","number");if("0"==d&&b.eat(/b/i))return b.eatWhile(/[01]/i),a("number","number");if(/\d/.test(d))return b.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),a("number","number");if("/"==d){if(b.eat("*"))return c.tokenize=
n,n(b,c);if(b.eat("/"))return b.skipToEnd(),a("comment","comment");if(ac(b,c,1)){a:for(var e=c=!1;null!=(d=b.next());){if(!c){if("/"==d&&!e)break a;"["==d?e=!0:e&&"]"==d&&(e=!1)}c=!c&&"\\"==d}b.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);return a("regexp","string-2")}b.eat("=");return a("operator","operator",b.current())}if("`"==d)return c.tokenize=q,q(b,c);if("#"==d)return b.skipToEnd(),a("error","error");if(bc.test(d))return">"==d&&c.lexical&&">"==c.lexical.type||(b.eat("=")?"!"!=d&&"="!=d||b.eat("="):
/[<>*+\-]/.test(d)&&(b.eat(d),">"==d&&b.eat(d))),a("operator","operator",b.current());if(Pa.test(d)){b.eatWhile(Pa);d=b.current();if("."!=c.lastType){if(Jb.propertyIsEnumerable(d))return b=Jb[d],a(b.type,b.style,d);if("async"==d&&b.match(/^\s*[\(\w]/,!1))return a("async","keyword",d)}return a("variable","variable",d)}}function l(b){return function(c,d){var e=!1,g;if(bb&&"@"==c.peek()&&c.match(Sc))return d.tokenize=f,a("jsonld-keyword","meta");for(;null!=(g=c.next())&&(g!=b||e);)e=!e&&"\\"==g;e||(d.tokenize=
f);return a("string","string")}}function n(b,c){for(var d=!1,e;e=b.next();){if("/"==e&&d){c.tokenize=f;break}d="*"==e}return a("comment","comment")}function q(b,c){for(var d=!1,e;null!=(e=b.next());){if(!d&&("`"==e||"$"==e&&b.eat("{"))){c.tokenize=f;break}d=!d&&"\\"==e}return a("quasi","string-2",b.current())}function m(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(0>c)){if(ua){var d=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(a.string.slice(a.start,c));d&&
(c=d.index)}d=0;var e=!1;for(--c;0<=c;--c){var f=a.string.charAt(c),g="([{}])".indexOf(f);if(0<=g&&3>g){if(!d){++c;break}if(0==--d){"("==f&&(e=!0);break}}else if(3<=g&&6>g)++d;else if(Pa.test(f))e=!0;else{if(/["'\/]/.test(f))return;if(e&&!d){++c;break}}}e&&!d&&(b.fatArrowAt=c)}}function k(a,b,c,d,e,f){this.indented=a;this.column=b;this.type=c;this.prev=e;this.info=f;null!=d&&(this.align=d)}function e(){for(var a=arguments.length-1;0<=a;a--)K.cc.push(arguments[a])}function d(){e.apply(null,arguments);
return!0}function b(a){function b(b){for(;b;b=b.next)if(b.name==a)return!0;return!1}var c=K.state;K.marked="def";c.context?b(c.localVars)||(c.localVars={name:a,next:c.localVars}):!b(c.globalVars)&&p.globalVars&&(c.globalVars={name:a,next:c.globalVars})}function h(){K.state.context={prev:K.state.context,vars:K.state.localVars};K.state.localVars=dc}function r(){K.state.localVars=K.state.context.vars;K.state.context=K.state.context.prev}function u(a,b){var c=function(){var c=K.state,d=c.indented;if("stat"==
c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new k(d,K.stream.column(),a,null,c.lexical,b)};c.lex=!0;return c}function z(){var a=K.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function A(a){function b(c){return c==a?d():";"==a?e():d(b)}return b}function D(a,b){return"var"==a?d(u("vardef",b.length),Fb,A(";"),z):"keyword a"==a?d(u("form"),G,D,z):"keyword b"==a?d(u("form"),
D,z):"keyword d"==a?K.stream.match(/^\s*$/,!1)?d():d(u("stat"),B,A(";"),z):"debugger"==a?d(A(";")):"{"==a?d(u("}"),X,z):";"==a?d():"if"==a?("else"==K.state.lexical.info&&K.state.cc[K.state.cc.length-1]==z&&K.state.cc.pop()(),d(u("form"),G,D,z,Ha)):"function"==a?d(ya):"for"==a?d(u("form"),Xb,D,z):"variable"==a?ua&&"type"==b?(K.marked="keyword",d(Y,A("operator"),Y,A(";"))):ua&&"declare"==b?(K.marked="keyword",d(D)):d(u("stat"),W):"switch"==a?d(u("form"),G,A("{"),u("}","switch"),X,z,z):"case"==a?d(y,
A(":")):"default"==a?d(A(":")):"catch"==a?d(u("form"),h,A("("),ab,A(")"),D,z,r):"class"==a?d(u("form"),Ua,z):"export"==a?d(u("stat"),ja,z):"import"==a?d(u("stat"),Ea,z):"module"==a?d(u("form"),Ba,A("{"),u("}"),X,z,z):"async"==a?d(D):"@"==b?d(y,D):e(u("stat"),y,A(";"),z)}function y(a){return H(a,!1)}function E(a){return H(a,!0)}function G(a){return"("!=a?e():d(u(")"),y,A(")"),z)}function H(a,b){if(K.state.fatArrowAt==K.stream.start){var c=b?N:P;if("("==a)return d(h,u(")"),L(ab,")"),z,A("=>"),c,r);
if("variable"==a)return e(h,Ba,A("=>"),c,r)}c=b?F:C;return cc.hasOwnProperty(a)?d(c):"function"==a?d(ya,c):"class"==a?d(u("form"),Nc,z):"keyword c"==a||"async"==a?d(b?E:y):"("==a?d(u(")"),B,A(")"),z,c):"operator"==a||"spread"==a?d(b?E:y):"["==a?d(u("]"),qb,z,c):"{"==a?ma(J,"}",null,c):"quasi"==a?e(M,c):"new"==a?d(U(b)):d()}function B(a){return a.match(/[;\}\)\],]/)?e():e(y)}function C(a,b){return","==a?d(y):F(a,b,!1)}function F(a,b,c){var f=0==c?C:F,g=0==c?y:E;if("=>"==a)return d(h,c?N:P,r);if("operator"==
a)return/\+\+|--/.test(b)||ua&&"!"==b?d(f):"?"==b?d(y,A(":"),g):d(g);if("quasi"==a)return e(M,f);if(";"!=a){if("("==a)return ma(E,")","call",f);if("."==a)return d(aa,f);if("["==a)return d(u("]"),B,A("]"),z,f);if(ua&&"as"==b)return K.marked="keyword",d(Y,f);if("regexp"==a)return K.state.lastType=K.marked="operator",K.stream.backUp(K.stream.pos-K.stream.start-1),d(g)}}function M(a,b){return"quasi"!=a?e():"${"!=b.slice(b.length-2)?d(M):d(y,I)}function I(a){if("}"==a)return K.marked="string-2",K.state.tokenize=
q,d(M)}function P(a){m(K.stream,K.state);return e("{"==a?D:y)}function N(a){m(K.stream,K.state);return e("{"==a?D:E)}function U(a){return function(b){return"."==b?d(a?T:O):"variable"==b&&ua?d(qd,a?F:C):e(a?E:y)}}function O(a,b){if("target"==b)return K.marked="keyword",d(C)}function T(a,b){if("target"==b)return K.marked="keyword",d(F)}function W(a){return":"==a?d(z,D):e(C,A(";"),z)}function aa(a){if("variable"==a)return K.marked="property",d()}function J(a,b){if("async"==a)return K.marked="property",
d(J);if("variable"==a||"keyword"==K.style){K.marked="property";if("get"==b||"set"==b)return d(S);var c;ua&&K.state.fatArrowAt==K.stream.start&&(c=K.stream.match(/^\s*:\s*/,!1))&&(K.state.fatArrowAt=K.stream.pos+c[0].length);return d(ha)}if("number"==a||"string"==a)return K.marked=bb?"property":K.style+" property",d(ha);if("jsonld-keyword"==a)return d(ha);if("modifier"==a)return d(J);if("["==a)return d(y,A("]"),ha);if("spread"==a)return d(E,ha);if("*"==b)return K.marked="keyword",d(J);if(":"==a)return e(ha)}
function S(a){if("variable"!=a)return e(ha);K.marked="property";return d(ya)}function ha(a){if(":"==a)return d(E);if("("==a)return e(ya)}function L(a,b,c){function f(g,h){return(c?-1<c.indexOf(g):","==g)?(g=K.state.lexical,"call"==g.info&&(g.pos=(g.pos||0)+1),d(function(c,d){return c==b||d==b?e():e(a)},f)):g==b||h==b?d():d(A(b))}return function(c,g){return c==b||g==b?d():e(a,f)}}function ma(a,b,c){for(var e=3;e<arguments.length;e++)K.cc.push(arguments[e]);return d(u(b,c),L(a,b),z)}function X(a){return"}"==
a?d():e(D,X)}function R(a,b){if(ua){if(":"==a)return d(Y);if("?"==b)return d(R)}}function Y(a,b){if("variable"==a||"void"==b){if("keyof"==b)return K.marked="keyword",d(Y);K.marked="type";return d(La)}if("string"==a||"number"==a||"atom"==a)return d(La);if("["==a)return d(u("]"),L(Y,"]",","),z,La);if("{"==a)return d(u("}"),L(na,"}",",;"),z,La);if("("==a)return d(L(fb,")"),Ca)}function Ca(a){if("=>"==a)return d(Y)}function na(a,b){if("variable"==a||"keyword"==K.style)return K.marked="property",d(na);
if("?"==b)return d(na);if(":"==a)return d(Y);if("["==a)return d(y,R,A("]"),na)}function fb(a){if("variable"==a)return d(fb);if(":"==a)return d(Y)}function La(a,b){if("<"==b)return d(u(">"),L(Y,">"),z,La);if("|"==b||"."==a)return d(Y);if("["==a)return d(A("]"),La);if("extends"==b)return d(Y)}function qd(a,b){if("<"==b)return d(u(">"),L(Y,">"),z,La)}function Fb(){return e(Ba,R,xa,Gb)}function Ba(a,c){if("modifier"==a)return d(Ba);if("variable"==a)return b(c),d();if("spread"==a)return d(Ba);if("["==
a)return ma(Ba,"]");if("{"==a)return ma(Za,"}")}function Za(a,c){if("variable"==a&&!K.stream.match(/^\s*:/,!1))return b(c),d(xa);"variable"==a&&(K.marked="property");return"spread"==a?d(Ba):"}"==a?e():d(A(":"),Ba,xa)}function xa(a,b){if("="==b)return d(E)}function Gb(a){if(","==a)return d(Fb)}function Ha(a,b){if("keyword b"==a&&"else"==b)return d(u("form","else"),D,z)}function Xb(a){if("("==a)return d(u(")"),Mc,A(")"),z)}function Mc(a){return"var"==a?d(Fb,A(";"),eb):";"==a?d(eb):"variable"==a?d($a):
e(y,A(";"),eb)}function $a(a,b){return"in"==b||"of"==b?(K.marked="keyword",d(y)):d(C,eb)}function eb(a,b){return";"==a?d(Ia):"in"==b||"of"==b?(K.marked="keyword",d(y)):e(y,A(";"),Ia)}function Ia(a){")"!=a&&d(y)}function ya(a,c){if("*"==c)return K.marked="keyword",d(ya);if("variable"==a)return b(c),d(ya);if("("==a)return d(h,u(")"),L(ab,")"),z,R,D,r);if(ua&&"<"==c)return d(u(">"),L(Y,">"),z,ya)}function ab(a,b){"@"==b&&d(y,ab);return"spread"==a||"modifier"==a?d(ab):e(Ba,R,xa)}function Nc(a,b){return"variable"==
a?Ua(a,b):Da(a,b)}function Ua(a,c){if("variable"==a)return b(c),d(Da)}function Da(a,b){if("<"==b)return d(u(">"),L(Y,">"),z,Da);if("extends"==b||"implements"==b||ua&&","==a)return d(ua?Y:y,Da);if("{"==a)return d(u("}"),ia,z)}function ia(a,b){if("modifier"==a||"async"==a||"variable"==a&&("static"==b||"get"==b||"set"==b)&&K.stream.match(/^\s+[\w$\xa1-\uffff]/,!1))return K.marked="keyword",d(ia);if("variable"==a||"keyword"==K.style)return K.marked="property",d(ua?ea:ya,ia);if("["==a)return d(y,A("]"),
ua?ea:ya,ia);if("*"==b)return K.marked="keyword",d(ia);if(";"==a)return d(ia);if("}"==a)return d();if("@"==b)return d(y,ia)}function ea(a,b){return"?"==b?d(ea):":"==a?d(Y,xa):"="==b?d(E):e(ya)}function ja(a,b){return"*"==b?(K.marked="keyword",d(pb,A(";"))):"default"==b?(K.marked="keyword",d(y,A(";"))):"{"==a?d(L($b,"}"),pb,A(";")):e(D)}function $b(a,b){if("as"==b)return K.marked="keyword",d(A("variable"));if("variable"==a)return e(E,$b)}function Ea(a){return"string"==a?d():e(Ma,oa,pb)}function Ma(a,
c){if("{"==a)return ma(Ma,"}");"variable"==a&&b(c);"*"==c&&(K.marked="keyword");return d(Qc)}function oa(a){if(","==a)return d(Ma,oa)}function Qc(a,b){if("as"==b)return K.marked="keyword",d(Ma)}function pb(a,b){if("from"==b)return K.marked="keyword",d(y)}function qb(a){return"]"==a?d():e(L(E,"]"))}function ac(a,b,c){return b.tokenize==f&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(b.lastType)||"quasi"==b.lastType&&/\{\s*$/.test(a.string.slice(0,a.pos-(c||
0)))}var ib=g.indentUnit,Rc=p.statementIndent,bb=p.jsonld,Oa=p.json||bb,ua=p.typescript,Pa=p.wordCharacters||/[\w$\xa1-\uffff]/,Jb=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("keyword d"),f=a("operator"),g={type:"atom",style:"atom"};b={"if":a("if"),"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":e,"break":e,"continue":e,"new":a("new"),"delete":d,"void":d,"throw":d,"debugger":a("debugger"),"var":a("var"),"const":a("var"),
let:a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":f,"typeof":f,"instanceof":f,"true":g,"false":g,"null":g,undefined:g,NaN:g,Infinity:g,"this":a("this"),"class":a("class"),"super":a("atom"),yield:d,"export":a("export"),"import":a("import"),"extends":d,await:d};if(ua){c={type:"variable",style:"type"};d={"interface":a("class"),"implements":d,namespace:d,module:a("module"),"enum":a("module"),"public":a("modifier"),
"private":a("modifier"),"protected":a("modifier"),"abstract":a("modifier"),readonly:a("modifier"),string:c,number:c,"boolean":c,any:c};for(var h in d)b[h]=d[h]}return b}(),bc=/[+\-*&%=<>!?|~^@]/,Sc=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,jb,Va,cc={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},K={state:null,column:null,marked:null,cc:null},dc={name:"this",next:{name:"arguments"}};z.lex=!0;return{startState:function(a){a=
{tokenize:f,lastType:"sof",cc:[],lexical:new k((a||0)-ib,0,"block",!1),localVars:p.localVars,context:p.localVars&&{vars:p.localVars},indented:a||0};p.globalVars&&"object"==typeof p.globalVars&&(a.globalVars=p.globalVars);return a},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),m(a,b));if(b.tokenize!=n&&a.eatSpace())return null;var c=b.tokenize(a,b);if("comment"==jb)return c;b.lastType="operator"!=jb||"++"!=Va&&"--"!=Va?jb:"incdec";
a:{var d=jb,e=Va,f=b.cc;K.state=b;K.stream=a;K.marked=null;K.cc=f;K.style=c;b.lexical.hasOwnProperty("align")||(b.lexical.align=!0);for(;;)if((f.length?f.pop():Oa?y:D)(d,e)){for(;f.length&&f[f.length-1].lex;)f.pop()();if(K.marked){c=K.marked;break a}if(a="variable"==d)b:{for(a=b.localVars;a;a=a.next)if(a.name==e){a=!0;break b}for(b=b.context;b;b=b.prev)for(a=b.vars;a;a=a.next)if(a.name==e){a=!0;break b}a=void 0}if(a){c="variable-2";break a}break a}}return c},indent:function(a,b){if(a.tokenize==n)return c.Pass;
if(a.tokenize!=f)return 0;var d=b&&b.charAt(0),e=a.lexical,g;if(!/^\s*else\b/.test(b))for(var h=a.cc.length-1;0<=h;--h){var k=a.cc[h];if(k==z)e=e.prev;else if(k!=Ha)break}for(;!("stat"!=e.type&&"form"!=e.type||"}"!=d&&(!(g=a.cc[a.cc.length-1])||g!=C&&g!=F||/^[,\.=+\-*:?[\(]/.test(b)));)e=e.prev;Rc&&")"==e.type&&"stat"==e.prev.type&&(e=e.prev);g=e.type;h=d==g;return"vardef"==g?e.indented+("operator"==a.lastType||","==a.lastType?e.info+1:0):"form"==g&&"{"==d?e.indented:"form"==g?e.indented+ib:"stat"==
g?(d=e.indented,a="operator"==a.lastType||","==a.lastType||bc.test(b.charAt(0))||/[,.]/.test(b.charAt(0)),d+(a?Rc||ib:0)):"switch"!=e.info||h||0==p.doubleIndentSwitch?e.align?e.column+(h?0:1):e.indented+(h?0:ib):e.indented+(/^(?:case|default)\b/.test(b)?ib:2*ib)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Oa?null:"/*",blockCommentEnd:Oa?null:"*/",blockCommentContinue:Oa?null:" * ",lineComment:Oa?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Oa?"json":"javascript",
jsonldMode:bb,jsonMode:Oa,expressionAllowed:ac,skipExpression:function(a){var b=a.cc[a.cc.length-1];b!=y&&b!=E||a.cc.pop()}}});c.registerHelper("wordChars","javascript",/[\w$]/);c.defineMIME("text/javascript","javascript");c.defineMIME("text/ecmascript","javascript");c.defineMIME("application/javascript","javascript");c.defineMIME("application/x-javascript","javascript");c.defineMIME("application/ecmascript","javascript");c.defineMIME("application/json",{name:"javascript",json:!0});c.defineMIME("application/x-json",
{name:"javascript",json:!0});c.defineMIME("application/ld+json",{name:"javascript",jsonld:!0});c.defineMIME("text/typescript",{name:"javascript",typescript:!0});c.defineMIME("application/typescript",{name:"javascript",typescript:!0})})(c(42))},function(p,g,c){(function(c){function g(a){this.options=a;this.from=this.to=0}function p(a,b){a=a.findMarks(e(b,0),e(b+1,0));for(var c=0;c<a.length;++c)if(a[c].__isFold&&a[c].find().from.line==b)return a[c]}function a(a){if("string"==typeof a){var b=document.createElement("div");
b.className=a+" CodeMirror-guttermarker-subtle";return b}return a.cloneNode(!0)}function f(c,b,f){var d=c.state.foldGutter.options,g=b,h=c.foldOption(d,"minFoldSize"),k=c.foldOption(d,"rangeFinder");c.eachLine(b,f,function(b){var f=null;if(p(c,g))f=a(d.indicatorFolded);else{var l=e(g,0);(l=k&&k(c,l))&&l.to.line-l.from.line>=h&&(f=a(d.indicatorOpen))}c.setGutterMarker(b,d.gutter,f);++g})}function l(a){var b=a.getViewport(),c=a.state.foldGutter;c&&(a.operation(function(){f(a,b.from,b.to)}),c.from=b.from,
c.to=b.to)}function u(a,b,c){var d=a.state.foldGutter;d&&(d=d.options,c==d.gutter&&((c=p(a,b))?c.clear():a.foldCode(e(b,0),d.rangeFinder)))}function t(a){var b=a.state.foldGutter;if(b){var c=b.options;b.from=b.to=0;clearTimeout(b.changeUpdate);b.changeUpdate=setTimeout(function(){l(a)},c.foldOnChangeTimeSpan||600)}}function m(a){var b=a.state.foldGutter;if(b){var c=b.options;clearTimeout(b.changeUpdate);b.changeUpdate=setTimeout(function(){var c=a.getViewport();b.from==b.to||20<c.from-b.to||20<b.from-
c.to?l(a):a.operation(function(){c.from<b.from&&(f(a,c.from,b.from),b.from=c.from);c.to>b.to&&(f(a,b.to,c.to),b.to=c.to)})},c.updateViewportTimeSpan||400)}}function k(a,b){var c=a.state.foldGutter;c&&(b=b.line,b>=c.from&&b<c.to&&f(a,b,b+1))}c.defineOption("foldGutter",!1,function(a,b,e){e&&e!=c.Init&&(a.clearGutter(a.state.foldGutter.options.gutter),a.state.foldGutter=null,a.off("gutterClick",u),a.off("change",t),a.off("viewportChange",m),a.off("fold",k),a.off("unfold",k),a.off("swapDoc",t));b&&(e=
a.state,!0===b&&(b={}),null==b.gutter&&(b.gutter="CodeMirror-foldgutter"),null==b.indicatorOpen&&(b.indicatorOpen="CodeMirror-foldgutter-open"),null==b.indicatorFolded&&(b.indicatorFolded="CodeMirror-foldgutter-folded"),e.foldGutter=new g(b),l(a),a.on("gutterClick",u),a.on("change",t),a.on("viewportChange",m),a.on("fold",k),a.on("unfold",k),a.on("swapDoc",t))});var e=c.Pos})(c(42),c(157))},function(p,g,c){(function(c){c.registerHelper("fold","brace",function(g,p){function a(a){for(var b=p.ch,d=0;;)if(b=
0>=b?-1:l.lastIndexOf(a,b-1),-1==b){if(1==d)break;d=1;b=l.length}else{if(1==d&&b<p.ch)break;n=g.getTokenTypeAt(c.Pos(f,b+1));if(!/^(comment|string)/.test(n))return b+1;--b}}var f=p.line,l=g.getLine(f),n,q="{",m="}",k=a("{");null==k&&(q="[",m="]",k=a("["));if(null!=k){var e=1,d=g.lastLine(),b=f;a:for(;b<=d;++b)for(var h=g.getLine(b),r=b==f?k:0;;){var u=h.indexOf(q,r);r=h.indexOf(m,r);0>u&&(u=h.length);0>r&&(r=h.length);r=Math.min(u,r);if(r==h.length)break;if(g.getTokenTypeAt(c.Pos(b,r+1))==n)if(r==
u)++e;else if(!--e){var z=b;var A=r;break a}++r}if(null!=z&&(f!=z||A!=k))return{from:c.Pos(f,k),to:c.Pos(z,A)}}});c.registerHelper("fold","import",function(g,p){function a(a){if(a<g.firstLine()||a>g.lastLine())return null;var f=g.getTokenAt(c.Pos(a,1));/\S/.test(f.string)||(f=g.getTokenAt(c.Pos(a,f.end+1)));if("keyword"!=f.type||"import"!=f.string)return null;var k=a;for(a=Math.min(g.lastLine(),a+10);k<=a;++k){var e=g.getLine(k).indexOf(";");if(-1!=e)return{startCh:f.end,end:c.Pos(k,e)}}}p=p.line;
var f=a(p),l;if(!f||a(p-1)||(l=a(p-2))&&l.end.line==p-1)return null;for(l=f.end;;){var n=a(l.line+1);if(null==n)break;l=n.end}return{from:g.clipPos(c.Pos(p,f.startCh+1)),to:l}});c.registerHelper("fold","include",function(g,p){function a(a){if(a<g.firstLine()||a>g.lastLine())return null;var f=g.getTokenAt(c.Pos(a,1));/\S/.test(f.string)||(f=g.getTokenAt(c.Pos(a,f.end+1)));if("meta"==f.type&&"#include"==f.string.slice(0,8))return f.start+8}p=p.line;var f=a(p);if(null==f||null!=a(p-1))return null;for(var l=
p;null!=a(l+1);)++l;return{from:c.Pos(p,f+1),to:g.clipPos(c.Pos(l))}})})(c(42))},function(p,g){},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,
writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return a});p=c(302);c.n(p);c=c(0);var q=function(){function a(a,c){for(var f=0;f<c.length;f++){var g=c[f];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(a,g.key,g)}}return function(c,f,g){f&&a(c.prototype,f);g&&a(c,g);return c}}(),a=function(a){function c(a){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");
var f=u(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));f.selectedLayer=a;f.element=document.createElement("div");f.element.className="neuroglancer-annotation-tool-status-widget";f.registerDisposer(a.changed.add(function(){return f.selectedLayerChanged()}));f.selectedLayerChanged();return f}n(c,a);q(c,[{key:"selectedLayerChanged",value:function(){var a=this,c=this.unbindPreviousLayer;void 0!==c&&c();c=this.selectedLayer.layer;void 0!==c&&(this.unbindPreviousLayer=c.specificationChanged.add(function(){a.updateView()}));
this.updateView()}},{key:"disposed",value:function(){var a=this.unbindPreviousLayer;void 0!==a&&a();this.unbindPreviousLayer=void 0}},{key:"getDescriptionText",value:function(){var a=this.selectedLayer.layer;if(void 0!==a&&(a=a.layer,null!==a&&(a=a.tool.value,void 0!==a)))return a.description}},{key:"updateView",value:function(){this.element.textContent=this.getDescriptionText()||""}}]);return c}(c.a)},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return v});var q=c(5);p=c(0);var a=c(10),f=function(){function a(a,c){for(var e=0;e<c.length;e++){var d=c[e];
d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,f,e){f&&a(c.prototype,f);e&&a(c,e);return c}}(),l=function m(a,c,d){null===a&&(a=Function.prototype);var b=Object.getOwnPropertyDescriptor(a,c);if(void 0===b){if(a=Object.getPrototypeOf(a),null!==a)return m(a,c,d)}else{if("value"in b)return b.value;c=b.get;return void 0===c?void 0:c.call(d)}},v=function(c){function g(a,c){c=void 0===c?{}:c;if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");
var b=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));b.model=a;b.element=document.createElement("label");b.inputElement=document.createElement("input");var d=c;c=d.validator;d=d.label;var e=b.element,f=b.inputElement;void 0===c&&(c=a instanceof q.c?a.validator:function(a){return a});b.validator=c;void 0!==d&&(e.textContent=d);e.appendChild(f);e.className="neuroglancer-number-input";f.type="input";b.registerDisposer(b.model.changed.add(function(){return b.updateView()}));b.registerEventListener(f,
"change",function(){return b.updateModel()});b.updateView();return b}n(g,c);f(g,[{key:"updateView",value:function(){this.inputElement.value=""+this.model.value}},{key:"updateModel",value:function(){var a=parseFloat(this.inputElement.value.trim());if(Number.isNaN(a))this.updateView();else try{a=this.validator(a),this.model.value=a}catch(d){this.updateView()}}},{key:"disposed",value:function(){Object(a.b)(this.element);l(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"disposed",this).call(this)}}]);
return g}(p.a)},function(p,g){},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,
c):a.__proto__=c)}c.d(g,"a",function(){return d});p=c(6);var q=c.n(p),a=c(5);p=c(0);var f=c(19),l=c(1),v=c(2),t=c(3),m=c(29),k=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),e=function h(a,c,d){null===a&&(a=Function.prototype);var e=Object.getOwnPropertyDescriptor(a,c);if(void 0===e){if(a=Object.getPrototypeOf(a),
null!==a)return h(a,c,d)}else{if("value"in e)return e.value;c=e.get;return void 0===c?void 0:c.call(d)}},d=function(c){function d(c){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");var e=u(this,(d.__proto__||Object.getPrototypeOf(d)).call(this));e.viewer=c;e.actionSet=new a.c(new Set,function(a){return new Set(Object(v.C)(a))});e.actionDisposers=[];e.sendActionRequested=new t.b;e.actionSet.changed.add(q()(function(){return e.updateActions()},0));return e}n(d,c);k(d,
[{key:"clearListeners",value:function(){for(var a=$jscomp.makeIterator(this.actionDisposers),c=a.next();!c.done;c=a.next())c=c.value,c();this.actionDisposers.length=0}},{key:"disposed",value:function(){this.clearListeners();e(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"disposed",this).call(this)}},{key:"updateActions",value:function(){var a=this;this.clearListeners();for(var c={},d=$jscomp.makeIterator(this.actionSet.value),e=d.next();!e.done;c={action:c.action},e=d.next())c.action=
e.value,this.actionDisposers.push(Object(f.c)(this.viewer.element,c.action,function(c){return function(){return a.handleAction(c.action)}}(c)))}},{key:"handleAction",value:function(a){var c=this.viewer,d=c.mouseState;c=c.layerSelectedValues;var e={};if(d.updateUnconditionally()){e.mouseSpatialCoordinates=Array.prototype.slice.call(d.position);var f=this.viewer.navigationState.voxelSize;f.valid&&(e.mouseVoxelCoordinates=Array.prototype.slice.call(l.s.divide(l.s.create(),d.position,f.size)))}e.selectedValues=
c;e.viewerState=Object(m.c)(this.viewer.state).value;this.sendActionRequested.dispatch(a,JSON.parse(JSON.stringify(e)))}}]);return d}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,
{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return t});p=c(6);var q=c.n(p),a=c(25),f=c(3);p=c(0);var l=c(2),v=function(){function a(a,c){for(var d=0;d<c.length;d++){var b=c[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),t=function(c){function g(){if(!(this instanceof
g))throw new TypeError("Cannot call a class as a function");var a=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));a.existingMessages=new Map;a.changed=new f.a;a.messages=new Map;a.changed.add(a.registerCancellable(q()(function(){return a.updateMessages()},0)));return a}n(g,c);v(g,[{key:"reset",value:function(){this.messages.clear();this.changed.dispatch()}},{key:"restoreState",value:function(a){Object(l.u)(a);this.messages.clear();for(var c=$jscomp.makeIterator(Object.keys(a)),b=c.next();!b.done;b=
c.next()){b=b.value;var e=Object(l.B)(a[b]);this.messages.set(b,e)}this.changed.dispatch()}},{key:"disposed",value:function(){for(var a=$jscomp.makeIterator(this.existingMessages.values()),c=a.next();!c.done;c=a.next())c.value.dispose();this.existingMessages.clear()}},{key:"updateMessages",value:function(){for(var c=this.existingMessages,d=this.messages,b=$jscomp.makeIterator(c),f=b.next();!f.done;f=b.next()){var g=$jscomp.makeIterator(f.value);f=g.next().value;g=g.next().value;var k=d.get(f);void 0===
k?(g.dispose(),c.delete(f)):g.setText(k)}d=$jscomp.makeIterator(d);for(b=d.next();!b.done;b=d.next())f=$jscomp.makeIterator(b.value),b=f.next().value,f=f.next().value,c.has(b)||(g=new a.a,g.setText(f),c.set(b,g))}},{key:"toJSON",value:function(){for(var a={},c=$jscomp.makeIterator(this.messages),b=c.next();!b.done;b=c.next()){var f=$jscomp.makeIterator(b.value);b=f.next().value;f=f.next().value;a[b]=f}return a}}]);return g}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return m});p=c(6);var q=c.n(p),a=c(5);p=c(0);var f=c(2),l=c(3),v=c(29),t=function(){function a(a,c){for(var b=
0;b<c.length;b++){var d=c[b];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,d,b){d&&a(c.prototype,d);b&&a(c,b);return c}}(),m=function(c){function e(c){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var b=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));b.viewer=c;b.sendScreenshotRequested=new l.b;b.requestState=new a.c(void 0,f.z);b.previousRequest=void 0;var d=b.registerCancellable(q()(function(){return b.maybeSendScreenshot()},
0));b.requestState.changed.add(d);b.registerDisposer(c.display.updateFinished.add(d));return b}n(e,c);t(e,[{key:"maybeSendScreenshot",value:function(){var a=this.requestState.value,b=this.previousRequest,c=this.viewer.layerSelectedValues;if(void 0!==a&&a!==b&&(b=this.viewer,b.display.isReady())){for(var e=$jscomp.makeIterator(b.layerManager.managedLayers),f=e.next();!f.done;f=e.next())if(!f.value.isReady())return;this.previousRequest=a;b.display.draw();e=b.display.canvas.toDataURL();e.startsWith("data:image/png;base64,")?
(b="image/png",e=e.substring(22)):e=b="";a={viewerState:JSON.parse(JSON.stringify(Object(v.c)(this.viewer.state).value)),selectedValues:JSON.parse(JSON.stringify(c)),screenshot:{id:a,image:e,imageType:b}};this.sendScreenshotRequested.dispatch(a)}}}]);return e}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+
typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}function q(){var a=window.location.pathname.match(/^\/v\/([^\/]+)/);if(null===a)throw Error("Failed to determine token from URL.");return window.location.origin+"/socket/"+a[1]}c.d(g,"a",function(){return t});var a=c(309);p=c(0);g=c(310);var f=c.n(g),l=c(25),v=function(){function a(a,c){for(var d=0;d<c.length;d++){var b=
c[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),t=function(c){function g(c,d,b,f){f=void 0===f?q():f;if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var e=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));e.sharedState=c;e.privateState=d;e.configState=b;e.url=f;e.reconnectionDelay=1E3;e.waitingToReconnect=-1;e.isOpen=!1;e.updateClients=
new Map;e.status=e.registerDisposer(new l.a(!0));e.actionQueue=[];e.nextActionId=0;e.lastActionAcknowledged=-1;d=[{key:"p",state:d,receiveUpdates:!1,sendUpdates:0},{key:"c",state:b,receiveUpdates:!0,sendUpdates:null}];void 0!==c&&d.push({key:"s",state:c,receiveUpdates:!0,sendUpdates:100});c={};d=$jscomp.makeIterator(d);for(b=d.next();!b.done;c={key:c.key},b=d.next()){var h=b.value;c.key=h.key;b=h.receiveUpdates;f=h.sendUpdates;h=e.registerDisposer(new a.a(h.state,f,b));e.updateClients.set(c.key,h);
null!==f&&h.sendUpdateRequested.add(function(a){return function(b,c){return e.send("setState",{k:a.key,s:b,g:c})}}(c));b&&h.receiveUpdateRequested.add(function(a){return function(b){return e.send("getState",{g:b,k:a.key})}}(c))}e.connect();return e}n(g,c);v(g,[{key:"dispose",value:function(){void 0!==this.socket&&(this.socket.close(),this.socket=void 0);-1!==this.waitingToReconnect&&(clearInterval(this.waitingToReconnect),this.waitingToReconnect=-1)}},{key:"send",value:function(a,c){c.t=a;this.socket.send(JSON.stringify(c))}},
{key:"connect",value:function(){var a=this;this.status.setText("Connecting to Python server");this.status.setVisible(!0);var c=this.socket=new f.a(this.url,{transports:["websocket","xhr-streaming"]});c.onopen=function(){a.isOpen=!0;a.reconnectionDelay=1E3;a.status.setVisible(!1);for(var b=$jscomp.makeIterator(a.updateClients.values()),c=b.next();!c.done;c=b.next())c.value.connected=!0;a.flushActionQueue()};c.onclose=function(){a.isOpen=!1;for(var b=a.reconnectionDelay,c=$jscomp.makeIterator(a.updateClients.values()),
d=c.next();!d.done;d=c.next())d.value.connected=!1;var e=Date.now()+b;a.status.setVisible(!0);var f=function(b){a.status.setText("Disconnected from Python server.  "+("Retrying in "+Math.ceil(b/1E3)+" seconds."))};a.waitingToReconnect=setInterval(function(){var b=e-Date.now();0>b?(clearInterval(a.waitingToReconnect),a.waitingToReconnect=-1,a.connect()):f(b)},1E3);f(b);a.reconnectionDelay=Math.min(3E4,2*b)};c.onmessage=function(b){b=JSON.parse(b.data);if("object"!==typeof b||Array.isArray(b))throw Error("Invalid message received over server connection.");
switch(b.t){case "setState":var c=a.updateClients.get(b.k);if(void 0===c)throw Error("Invalid state key: "+JSON.stringify(b.k));c.setState(b.s,b.g);break;case "ackAction":b=parseInt(b.id,10);if(b<a.lastActionAcknowledged||b>=a.nextActionId)throw Error("Invalid action acknowledged message");a.actionQueue.splice(0,b-a.lastActionAcknowledged);a.lastActionAcknowledged=b}}}},{key:"flushActionQueue",value:function(){var a=this.actionQueue;0!==a.length&&this.send("action",{id:this.nextActionId-1,actions:a})}},
{key:"sendActionNotification",value:function(a,c){this.actionQueue.push({action:a,state:c});++this.nextActionId;this.isOpen&&this.flushActionQueue()}}]);return g}(p.a)},function(p,g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=
Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return m});p=c(6);var q=c.n(p);p=c(109);var a=c.n(p);p=c(0);var f=c(106),l=c(3),v=c(29),t=function(){function a(a,c){for(var b=0;b<c.length;b++){var d=c[b];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(c,d,b){d&&a(c.prototype,d);b&&a(c,
b);return c}}(),m=function(c){function e(c,b,f){b=void 0===b?100:b;f=void 0===f?!0:f;if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");var d=u(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));d.state=c;d.receiveUpdates=f;d.serverGeneration="";d.clientGeneration=-1;d.connected_=!1;d.receiveUpdateRequested=new l.b;d.sendUpdateRequested=new l.b;null!==b?(d.sendUpdates=!0,d.registerDisposer(c.changed.add(d.registerCancellable(a()(d.registerCancellable(q()(function(){return d.handleStateChanged()},
0)),b,{leading:!1}))))):d.sendUpdates=!1;return d}n(e,c);t(e,[{key:"setState",value:function(a,b){this.receiveUpdates&&b!==this.serverGeneration&&(this.lastServerState=JSON.stringify(a),this.state.reset(),this.state.restoreState(a),this.serverGeneration=b,this.clientGeneration=this.state.changed.count)}},{key:"handleStateChanged",value:function(){if(this.sendUpdates&&this.connected_&&(!this.receiveUpdates||""!==this.serverGeneration)&&this.clientGeneration!==this.state.changed.count){var a=Object(v.c)(this.state).value,
b=JSON.stringify(a);if(b===this.lastServerState)this.clientGeneration=this.state.changed.count;else{var c=Object(f.a)(160);this.serverGeneration=c;this.lastServerState=b;this.sendUpdateRequested.dispatch(a,c)}}}},{key:"connected",set:function(a){a!==this.connected_&&(this.connected_=a,!0===a&&(this.receiveUpdates&&this.receiveUpdateRequested.dispatch(this.serverGeneration),this.handleStateChanged()))},get:function(){return this.connected_}}]);return e}(p.a)},function(p,g,c){g=c(7);var u=c(311);p.exports=
c(330)(u);"_sockjs_onload"in g&&setTimeout(g._sockjs_onload,1)},function(p,g,c){p.exports=[c(312),c(319),c(162),c(163),c(99)(c(163)),c(167),c(99)(c(167)),c(168),c(326),c(99)(c(168)),c(327)]},function(p,g,c){(function(g){function n(c,f,e){if(!n.enabled())throw Error("Transport created when disabled");l.call(this);t("constructor",c);var d=this;c=a.addPath(c,"/websocket");this.url=c="https"===c.slice(0,5)?"wss"+c.slice(5):"ws"+c.slice(4);this.ws=new u(this.url,[],e);this.ws.onmessage=function(a){t("message event",
a.data);d.emit("message",a.data)};this.unloadRef=q.unloadAdd(function(){t("unload");d.ws.close()});this.ws.onclose=function(a){t("close event",a.code,a.reason);d.emit("close",a.code,a.reason);d._cleanup()};this.ws.onerror=function(a){t("error event",a);d.emit("close",1006,"WebSocket connection broken");d._cleanup()}}var q=c(38),a=c(21),f=c(4),l=c(13).EventEmitter,u=c(318),t=function(){};"production"!==g.env.NODE_ENV&&(t=c(9)("sockjs-client:websocket"));f(n,l);n.prototype.send=function(a){a="["+a+
"]";t("send",a);this.ws.send(a)};n.prototype.close=function(){t("close");var a=this.ws;this._cleanup();a&&a.close()};n.prototype._cleanup=function(){t("_cleanup");var a=this.ws;a&&(a.onmessage=a.onclose=a.onerror=null);q.unloadDel(this.unloadRef);this.unloadRef=this.ws=null;this.removeAllListeners()};n.enabled=function(){t("enabled");return!!u};n.transportName="websocket";n.roundTrips=2;p.exports=n}).call(g,c(8))},function(p,g,c){(function(c){p.exports.randomBytes=c.crypto&&c.crypto.getRandomValues?
function(g){g=new Uint8Array(g);c.crypto.getRandomValues(g);return g}:function(c){for(var g=Array(c),a=0;a<c;a++)g[a]=Math.floor(256*Math.random());return g}}).call(g,c(7))},function(p,g,c){p.exports=function(c,g){g=g.split(":")[0];c=+c;if(!c)return!1;switch(g){case "http":case "ws":return 80!==c;case "https":case "wss":return 443!==c;case "ftp":return 21!==c;case "gopher":return 70!==c;case "file":return!1}return 0!==c}},function(p,g,c){var u=Object.prototype.hasOwnProperty;g.stringify=function(c,
g){g=g||"";var a=[];"string"!==typeof g&&(g="?");for(var f in c)u.call(c,f)&&a.push(encodeURIComponent(f)+"="+encodeURIComponent(c[f]));return a.length?g+a.join("&"):""};g.parse=function(c){for(var g=/([^=?&]+)=?([^&]*)/g,a={},f;f=g.exec(c);a[decodeURIComponent(f[1].replace(/\+/g," "))]=decodeURIComponent(f[2].replace(/\+/g," ")));return a}},function(p,g,c){function u(a){var c=0,l;for(l in a)c=(c<<5)-c+a.charCodeAt(l),c|=0;return g.colors[Math.abs(c)%g.colors.length]}function n(a){function c(){if(c.enabled){var a=
+new Date;c.diff=a-(q||a);c.prev=q;q=c.curr=a;var f=Array(arguments.length);for(a=0;a<f.length;a++)f[a]=arguments[a];f[0]=g.coerce(f[0]);"string"!==typeof f[0]&&f.unshift("%O");var n=0;f[0]=f[0].replace(/%([a-zA-Z%])/g,function(a,k){if("%%"===a)return a;n++;k=g.formatters[k];"function"===typeof k&&(a=k.call(c,f[n]),f.splice(n,1),n--);return a});g.formatArgs.call(c,f);(c.log||g.log||console.log.bind(console)).apply(c,f)}}c.namespace=a;c.enabled=g.enabled(a);c.useColors=g.useColors();c.color=u(a);"function"===
typeof g.init&&g.init(c);return c}g=p.exports=n.debug=n["default"]=n;g.coerce=function(a){return a instanceof Error?a.stack||a.message:a};g.disable=function(){g.enable("")};g.enable=function(a){g.save(a);g.names=[];g.skips=[];for(var c=("string"===typeof a?a:"").split(/[\s,]+/),l=c.length,n=0;n<l;n++)c[n]&&(a=c[n].replace(/\*/g,".*?"),"-"===a[0]?g.skips.push(new RegExp("^"+a.substr(1)+"$")):g.names.push(new RegExp("^"+a+"$")))};g.enabled=function(a){var c;var l=0;for(c=g.skips.length;l<c;l++)if(g.skips[l].test(a))return!1;
l=0;for(c=g.names.length;l<c;l++)if(g.names[l].test(a))return!0;return!1};g.humanize=c(317);g.names=[];g.skips=[];g.formatters={};var q},function(p,g){function c(a){a=String(a);if(!(100<a.length)&&(a=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a))){var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case "years":case "year":case "yrs":case "yr":case "y":return c*q;case "days":case "day":case "d":return c*n;case "hours":case "hour":case "hrs":case "hr":case "h":return 36E5*
c;case "minutes":case "minute":case "mins":case "min":case "m":return 6E4*c;case "seconds":case "second":case "secs":case "sec":case "s":return 1E3*c;case "milliseconds":case "millisecond":case "msecs":case "msec":case "ms":return c}}}function u(a,c,g){if(!(a<c))return a<1.5*c?Math.floor(a/c)+" "+g:Math.ceil(a/c)+" "+g+"s"}var n=864E5,q=365.25*n;p.exports=function(a,f){f=f||{};var g=typeof a;if("string"===g&&0<a.length)return c(a);if("number"===g&&!1===isNaN(a))return f.long?u(a,n,"day")||u(a,36E5,
"hour")||u(a,6E4,"minute")||u(a,1E3,"second")||a+" ms":a>=n?Math.round(a/n)+"d":36E5<=a?Math.round(a/36E5)+"h":6E4<=a?Math.round(a/6E4)+"m":1E3<=a?Math.round(a/1E3)+"s":a+"ms";throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a));}},function(p,g,c){(function(c){var g=c.WebSocket||c.MozWebSocket;p.exports=g?function(c){return new g(c)}:void 0}).call(g,c(7))},function(p,g,c){(function(g){function n(c){if(!u.enabled&&!l.enabled)throw Error("Transport created when disabled");
a.call(this,c,"/xhr_streaming",f,l)}var q=c(4),a=c(49),f=c(69),l=c(70),u=c(59),t=c(60);q(n,a);n.enabled=function(a){return a.nullOrigin||t.isOpera()?!1:l.enabled};n.transportName="xhr-streaming";n.roundTrips=2;n.needBody=!!g.document;p.exports=n}).call(g,c(7))},function(p,g,c){(function(g){function n(c,g){f(c);a.call(this);this.sendBuffer=[];this.sender=g;this.url=c}var q=c(4),a=c(13).EventEmitter,f=function(){};"production"!==g.env.NODE_ENV&&(f=c(9)("sockjs-client:buffered-sender"));q(n,a);n.prototype.send=
function(a){f("send",a);this.sendBuffer.push(a);this.sendStop||this.sendSchedule()};n.prototype.sendScheduleWait=function(){f("sendScheduleWait");var a=this;this.sendStop=function(){f("sendStop");a.sendStop=null;clearTimeout(c)};var c=setTimeout(function(){f("timeout");a.sendStop=null;a.sendSchedule()},25)};n.prototype.sendSchedule=function(){f("sendSchedule",this.sendBuffer.length);var a=this;if(0<this.sendBuffer.length){var c="["+this.sendBuffer.join(",")+"]";this.sendStop=this.sender(this.url,
c,function(c){a.sendStop=null;c?(f("error",c),a.emit("close",c.code||1006,"Sending error: "+c),a.close()):a.sendScheduleWait()});this.sendBuffer=[]}};n.prototype._cleanup=function(){f("_cleanup");this.removeAllListeners()};n.prototype.close=function(){f("close");this._cleanup();this.sendStop&&(this.sendStop(),this.sendStop=null)};p.exports=n}).call(g,c(8))},function(p,g,c){(function(g){function n(c,g,n){f(g);a.call(this);this.Receiver=c;this.receiveUrl=g;this.AjaxObject=n;this._scheduleReceiver()}
var q=c(4),a=c(13).EventEmitter,f=function(){};"production"!==g.env.NODE_ENV&&(f=c(9)("sockjs-client:polling"));q(n,a);n.prototype._scheduleReceiver=function(){f("_scheduleReceiver");var a=this,c=this.poll=new this.Receiver(this.receiveUrl,this.AjaxObject);c.on("message",function(c){f("message",c);a.emit("message",c)});c.once("close",function(g,l){f("close",g,l,a.pollIsClosing);a.poll=c=null;a.pollIsClosing||("network"===l?a._scheduleReceiver():(a.emit("close",g||1006,l),a.removeAllListeners()))})};
n.prototype.abort=function(){f("abort");this.removeAllListeners();this.pollIsClosing=!0;this.poll&&this.poll.abort()};p.exports=n}).call(g,c(8))},function(p,g,c){(function(g){function n(c){l(c);a.call(this);var g=this,m=this.es=new f(c);m.onmessage=function(a){l("message",a.data);g.emit("message",decodeURI(a.data))};m.onerror=function(a){l("error",m.readyState,a);a=2!==m.readyState?"network":"permanent";g._cleanup();g._close(a)}}var q=c(4),a=c(13).EventEmitter,f=c(164),l=function(){};"production"!==
g.env.NODE_ENV&&(l=c(9)("sockjs-client:receiver:eventsource"));q(n,a);n.prototype.abort=function(){l("abort");this._cleanup();this._close("user")};n.prototype._cleanup=function(){l("cleanup");var a=this.es;a&&(a.onmessage=a.onerror=null,a.close(),this.es=null)};n.prototype._close=function(a){l("close",a);var c=this;setTimeout(function(){c.emit("close",null,a);c.removeAllListeners()},200)};p.exports=n}).call(g,c(8))},function(p,g){p.exports=function(c){c.webpackPolyfill||(c.deprecate=function(){},
c.paths=[],c.children||(c.children=[]),Object.defineProperty(c,"loaded",{enumerable:!0,get:function(){return c.l}}),Object.defineProperty(c,"id",{enumerable:!0,get:function(){return c.i}}),c.webpackPolyfill=1);return c}},function(p,g){p.exports={}},function(p,g,c){(function(g,n){function q(a){m(a);u.call(this);var c=this;f.polluteGlobalNamespace();this.id="a"+t.string(6);a=l.addQuery(a,"c="+decodeURIComponent(f.WPrefix+"."+this.id));m("using htmlfile",q.htmlfileEnabled);var d=q.htmlfileEnabled?f.createHtmlfile:
f.createIframe;n[f.WPrefix][this.id]={start:function(){m("start");c.iframeObj.loaded()},message:function(a){m("message",a);c.emit("message",a)},stop:function(){m("stop");c._cleanup();c._close("network")}};this.iframeObj=d(a,function(){m("callback");c._cleanup();c._close("permanent")})}var a=c(4),f=c(61),l=c(21),u=c(13).EventEmitter,t=c(48),m=function(){};"production"!==g.env.NODE_ENV&&(m=c(9)("sockjs-client:receiver:htmlfile"));a(q,u);q.prototype.abort=function(){m("abort");this._cleanup();this._close("user")};
q.prototype._cleanup=function(){m("_cleanup");this.iframeObj&&(this.iframeObj.cleanup(),this.iframeObj=null);delete n[f.WPrefix][this.id]};q.prototype._close=function(a){m("_close",a);this.emit("close",null,a);this.removeAllListeners()};q.htmlfileEnabled=!1;g=["Active"].concat("Object").join("X");if(g in n)try{q.htmlfileEnabled=!!new n[g]("htmlfile")}catch(k){}q.enabled=q.htmlfileEnabled||f.iframeEnabled;p.exports=q}).call(g,c(8),c(7))},function(p,g,c){function u(c){if(!f.enabled)throw Error("Transport created when disabled");
n.call(this,c,"/xhr",a,f)}g=c(4);var n=c(49),q=c(162),a=c(69),f=c(98);g(u,n);u.enabled=q.enabled;u.transportName="xdr-polling";u.roundTrips=2;p.exports=u},function(p,g,c){(function(g){function n(c){if(!n.enabled())throw Error("Transport created when disabled");a.call(this,c,"/jsonp",l,f)}var q=c(4),a=c(160),f=c(328),l=c(329);q(n,a);n.enabled=function(){return!!g.document};n.transportName="jsonp-polling";n.roundTrips=1;n.needBody=!0;p.exports=n}).call(g,c(7))},function(p,g,c){(function(g,n){function q(c){k(c);
var d=this;m.call(this);a.polluteGlobalNamespace();this.id="a"+f.string(6);c=u.addQuery(c,"c="+encodeURIComponent(a.WPrefix+"."+this.id));n[a.WPrefix][this.id]=this._callback.bind(this);this._createScript(c);this.timeoutId=setTimeout(function(){k("timeout");d._abort(Error("JSONP script loaded abnormally (timeout)"))},q.timeout)}var a=c(61),f=c(48),l=c(60),u=c(21),t=c(4),m=c(13).EventEmitter,k=function(){};"production"!==g.env.NODE_ENV&&(k=c(9)("sockjs-client:receiver:jsonp"));t(q,m);q.prototype.abort=
function(){k("abort");if(n[a.WPrefix][this.id]){var c=Error("JSONP user aborted read");c.code=1E3;this._abort(c)}};q.timeout=35E3;q.scriptErrorTimeout=1E3;q.prototype._callback=function(a){k("_callback",a);this._cleanup();this.aborting||(a&&(k("message",a),this.emit("message",a)),this.emit("close",null,"network"),this.removeAllListeners())};q.prototype._abort=function(a){k("_abort",a);this._cleanup();this.aborting=!0;this.emit("close",a.code,a.message);this.removeAllListeners()};q.prototype._cleanup=
function(){k("_cleanup");clearTimeout(this.timeoutId);this.script2&&(this.script2.parentNode.removeChild(this.script2),this.script2=null);if(this.script){var c=this.script;c.parentNode.removeChild(c);this.script=c.onreadystatechange=c.onerror=c.onload=c.onclick=null}delete n[a.WPrefix][this.id]};q.prototype._scriptError=function(){k("_scriptError");var a=this;this.errorTimer||(this.errorTimer=setTimeout(function(){a.loadedOkay||a._abort(Error("JSONP script loaded abnormally (onerror)"))},q.scriptErrorTimeout))};
q.prototype._createScript=function(a){k("_createScript",a);var c=this,b=this.script=n.document.createElement("script");b.id="a"+f.string(8);b.src=a;b.type="text/javascript";b.charset="UTF-8";b.onerror=this._scriptError.bind(this);b.onload=function(){k("onload");c._abort(Error("JSONP script loaded abnormally (onload)"))};b.onreadystatechange=function(){k("onreadystatechange",b.readyState);if(/loaded|closed/.test(b.readyState)){if(b&&b.htmlFor&&b.onclick){c.loadedOkay=!0;try{b.onclick()}catch(r){}}b&&
c._abort(Error("JSONP script loaded abnormally (onreadystatechange)"))}};if("undefined"===typeof b.async&&n.document.attachEvent)if(l.isOpera()){var e=this.script2=n.document.createElement("script");e.text="try{var a = document.getElementById('"+b.id+"'); if(a)a.onerror();}catch(x){};";b.async=e.async=!1}else{try{b.htmlFor=b.id,b.event="onclick"}catch(r){}b.async=!0}"undefined"!==typeof b.async&&(b.async=!0);a=n.document.getElementsByTagName("head")[0];a.insertBefore(b,a.firstChild);e&&a.insertBefore(e,
a.firstChild)};p.exports=q}).call(g,c(8),c(7))},function(p,g,c){(function(g,n){function q(a){l("createIframe",a);try{return n.document.createElement('<iframe name="'+a+'">')}catch(e){var c=n.document.createElement("iframe");c.name=a;return c}}var a=c(48),f=c(21),l=function(){};"production"!==g.env.NODE_ENV&&(l=c(9)("sockjs-client:sender:jsonp"));var u,t;p.exports=function(c,g,e){l(c,g);u||(l("createForm"),u=n.document.createElement("form"),u.style.display="none",u.style.position="absolute",u.method=
"POST",u.enctype="application/x-www-form-urlencoded",u.acceptCharset="UTF-8",t=n.document.createElement("textarea"),t.name="d",u.appendChild(t),n.document.body.appendChild(u));var d="a"+a.string(8);u.target=d;u.action=f.addQuery(f.addPath(c,"/jsonp_send"),"i="+d);var b=q(d);b.id=d;b.style.display="none";u.appendChild(b);try{t.value=g}catch(r){}u.submit();var h=function(a){l("completed",d,a);b.onerror&&(b.onreadystatechange=b.onerror=b.onload=null,setTimeout(function(){l("cleaning up",d);b.parentNode.removeChild(b);
b=null},500),t.value="",e(a))};b.onerror=function(){l("onerror",d);h()};b.onload=function(){l("onload",d);h()};b.onreadystatechange=function(a){l("onreadystatechange",d,b.readyState,a);"complete"===b.readyState&&h()};return function(){l("aborted",d);h(Error("Aborted"))}}}).call(g,c(8),c(7))},function(p,g,c){(function(g,n){function q(c,d,e){if(!(this instanceof q))return new q(c,d,e);if(1>arguments.length)throw new TypeError("Failed to construct 'SockJS: 1 argument required, but only 0 present");x.call(this);
this.readyState=q.CONNECTING;this.protocol=this.extensions="";e=e||{};e.protocols_whitelist&&h.warn("'protocols_whitelist' is DEPRECATED. Use 'transports' instead.");this._transportsWhitelist=e.transports;this._transportOptions=e.transportOptions||{};var f=e.sessionId||8;if("function"===typeof f)this._generateSessionId=f;else if("number"===typeof f)this._generateSessionId=function(){return u.string(f)};else throw new TypeError("If sessionId is used in the options, it needs to be a number or a function.");
this._server=e.server||u.numberString(1E3);var g=new a(c);if(g.host&&g.protocol){if(g.hash)throw new SyntaxError("The URL must not contain a fragment");if("http:"!==g.protocol&&"https:"!==g.protocol)throw new SyntaxError("The URL's scheme must be either 'http:' or 'https:'. '"+g.protocol+"' is not allowed.");}else throw new SyntaxError("The URL '"+c+"' is invalid");var k="https:"===g.protocol;if("https"===z.protocol&&!k)throw Error("SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS");
d?Array.isArray(d)||(d=[d]):d=[];var l=d.sort();l.forEach(function(a,b){if(!a)throw new SyntaxError("The protocols entry '"+a+"' is invalid.");if(b<l.length-1&&a===l[b+1])throw new SyntaxError("The protocols entry '"+a+"' is duplicated.");});this._origin=(k=m.getOrigin(z.href))?k.toLowerCase():null;g.set("pathname",g.pathname.replace(/\/+$/,""));this.url=g.href;E("using url",this.url);this._urlInfo={nullOrigin:!b.hasDomain(),sameOrigin:m.isOriginEqual(this.url,z.href),sameScheme:m.isSchemeEqual(this.url,
z.href)};this._ir=new y(this.url,this._urlInfo);this._ir.once("finish",this._receiveInfo.bind(this))}c(331);var a=c(158),f=c(4),l=c(33),u=c(48),t=c(332),m=c(21),k=c(38),e=c(333),d=c(100),b=c(60),h=c(334),r=c(101),x=c(159),z=c(169),A=c(335),D=c(336),y=c(337),E=function(){};"production"!==g.env.NODE_ENV&&(E=c(9)("sockjs-client:main"));var G;f(q,x);q.prototype.close=function(a,b){if(a&&!(1E3===a||3E3<=a&&4999>=a))throw Error("InvalidAccessError: Invalid code");if(b&&123<b.length)throw new SyntaxError("reason argument has an invalid length");
this.readyState!==q.CLOSING&&this.readyState!==q.CLOSED&&this._close(a||1E3,b||"Normal closure",!0)};q.prototype.send=function(a){"string"!==typeof a&&(a=""+a);if(this.readyState===q.CONNECTING)throw Error("InvalidStateError: The connection has not been established yet");this.readyState===q.OPEN&&this._transport.send(t.quote(a))};q.version=c(166);q.CONNECTING=0;q.OPEN=1;q.CLOSING=2;q.CLOSED=3;q.prototype._receiveInfo=function(a,b){E("_receiveInfo",b);this._ir=null;a?(this._rto=this.countRTO(b),this._transUrl=
a.base_url?a.base_url:this.url,a=d.extend(a,this._urlInfo),E("info",a),this._transports=G.filterToEnabled(this._transportsWhitelist,a).main,E(this._transports.length+" enabled transports"),this._connect()):this._close(1002,"Cannot connect to server")};q.prototype._connect=function(){for(var a=this._transports.shift();a;){E("attempt",a.transportName);if(a.needBody&&(!n.document.body||"undefined"!==typeof n.document.readyState&&"complete"!==n.document.readyState&&"interactive"!==n.document.readyState)){E("waiting for body");
this._transports.unshift(a);k.attachEvent("load",this._connect.bind(this));return}var b=this._rto*a.roundTrips||5E3;this._transportTimeoutId=setTimeout(this._transportTimeout.bind(this),b);E("using timeout",b);b=m.addPath(this._transUrl,"/"+this._server+"/"+this._generateSessionId());var c=this._transportOptions[a.transportName];E("transport url",b);b=new a(b,this._transUrl,c);b.on("message",this._transportMessage.bind(this));b.once("close",this._transportClose.bind(this));b.transportName=a.transportName;
this._transport=b;return}this._close(2E3,"All transports failed",!1)};q.prototype._transportTimeout=function(){E("_transportTimeout");this.readyState===q.CONNECTING&&this._transportClose(2007,"Transport timed out")};q.prototype._transportMessage=function(a){E("_transportMessage",a);var b=this,c=a.slice(0,1);a=a.slice(1);switch(c){case "o":this._open();return;case "h":this.dispatchEvent(new r("heartbeat"));E("heartbeat",this.transport);return}if(a)try{var d=l.parse(a)}catch(M){E("bad json",a)}if("undefined"===
typeof d)E("empty payload",a);else switch(c){case "a":Array.isArray(d)&&d.forEach(function(a){E("message",b.transport,a);b.dispatchEvent(new D(a))});break;case "m":E("message",this.transport,d);this.dispatchEvent(new D(d));break;case "c":Array.isArray(d)&&2===d.length&&this._close(d[0],d[1],!0)}};q.prototype._transportClose=function(a,b){E("_transportClose",this.transport,a,b);this._transport&&(this._transport.removeAllListeners(),this.transport=this._transport=null);1E3===a||3E3<=a&&4999>=a||2E3===
a||this.readyState!==q.CONNECTING?this._close(a,b):this._connect()};q.prototype._open=function(){E("_open",this._transport.transportName,this.readyState);this.readyState===q.CONNECTING?(this._transportTimeoutId&&(clearTimeout(this._transportTimeoutId),this._transportTimeoutId=null),this.readyState=q.OPEN,this.transport=this._transport.transportName,this.dispatchEvent(new r("open")),E("connected",this.transport)):this._close(1006,"Server lost session")};q.prototype._close=function(a,b,c){E("_close",
this.transport,a,b,c,this.readyState);var d=!1;this._ir&&(d=!0,this._ir.close(),this._ir=null);this._transport&&(this._transport.close(),this.transport=this._transport=null);if(this.readyState===q.CLOSED)throw Error("InvalidStateError: SockJS has already been closed");this.readyState=q.CLOSING;setTimeout(function(){this.readyState=q.CLOSED;d&&this.dispatchEvent(new r("error"));var e=new A("close");e.wasClean=c||!1;e.code=a||1E3;e.reason=b;this.dispatchEvent(e);this.onmessage=this.onclose=this.onerror=
null;E("disconnected")}.bind(this),0)};q.prototype.countRTO=function(a){return 100<a?4*a:300+a};p.exports=function(a){G=e(a);c(340)(q,a);return q}}).call(g,c(8),c(7))},function(p,g,c){function u(){}var n=Array.prototype,q=Object.prototype;g=Function.prototype;var a=String.prototype,f=n.slice,l=q.toString;if(p=Object.defineProperty)try{Object.defineProperty({},"x",{}),p=!0}catch(d){p=!1}var v=p?function(a,b,c,e){!e&&b in a||Object.defineProperty(a,b,{configurable:!0,enumerable:!1,writable:!0,value:c})}:
function(a,b,c,e){!e&&b in a||(a[b]=c)};p=function(a,b,c){for(var d in b)q.hasOwnProperty.call(b,d)&&v(a,d,b[d],c)};var t=function(a){if(null==a)throw new TypeError("can't convert "+a+" to object");return Object(a)};p(g,{bind:function(a){var b=this;if("[object Function]"!==q.toString.call(b))throw new TypeError("Function.prototype.bind called on incompatible "+b);for(var c=f.call(arguments,1),d=Math.max(0,b.length-c.length),e=[],g=0;g<d;g++)e.push("$"+g);var k=Function("binder","return function ("+
e.join(",")+"){ return binder.apply(this, arguments); }")(function(){if(this instanceof k){var d=b.apply(this,c.concat(f.call(arguments)));return Object(d)===d?d:this}return b.apply(a,c.concat(f.call(arguments)))});b.prototype&&(u.prototype=b.prototype,k.prototype=new u,u.prototype=null);return k}});p(Array,{isArray:function(a){return"[object Array]"===l.call(a)}});g=Object("a");var m="a"!==g[0]||!(0 in g);p(n,{forEach:function(a,b){var c=t(this),d=m&&"[object String]"===l.call(this)?this.split(""):
c,e=-1,f=d.length>>>0;if("[object Function]"!==q.toString.call(a))throw new TypeError;for(;++e<f;)e in d&&a.call(b,d[e],e,c)}},!function(a){var b=!0,c=!0;a&&(a.call("foo",function(a,c,d){"object"!==typeof d&&(b=!1)}),a.call([1],function(){c="string"===typeof this},"x"));return!!a&&b&&c}(n.forEach));g=Array.prototype.indexOf&&-1!==[0,1].indexOf(1,2);p(n,{indexOf:function(a){var b=m&&"[object String]"===l.call(this)?this.split(""):t(this),c=b.length>>>0;if(!c)return-1;var d=0;1<arguments.length&&(d=
+arguments[1],d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(0<d||-1)*Math.floor(Math.abs(d))));for(d=0<=d?d:Math.max(0,c+d);d<c;d++)if(d in b&&b[d]===a)return d;return-1}},g);var k=a.split;2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||"t"==="tesst".split(/(s)*/)[1]||4!=="test".split(/(?:)/,-1).length||"".split(/.?/).length||1<".".split(/()()/).length?function(){var c=void 0===/()??/.exec("")[1];a.split=function(a,d){var b=this;if(void 0===a&&0===d)return[];if("[object RegExp]"!==
l.call(a))return k.call(this,a,d);var e=[],f=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.extended?"x":"")+(a.sticky?"y":""),g=0,h,m;a=new RegExp(a.source,f+"g");b+="";c||(h=new RegExp("^"+a.source+"$(?!\\s)",f));for(d=void 0===d?4294967295:d>>>0;m=a.exec(b);){f=m.index+m[0].length;if(f>g){e.push(b.slice(g,m.index));!c&&1<m.length&&m[0].replace(h,function(){for(var a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(m[a]=void 0)});1<m.length&&m.index<b.length&&n.push.apply(e,m.slice(1));var p=m[0].length;
g=f;if(e.length>=d)break}a.lastIndex===m.index&&a.lastIndex++}g===b.length?!p&&a.test("")||e.push(""):e.push(b.slice(g));return e.length>d?e.slice(0,d):e}}():"0".split(void 0,0).length&&(a.split=function(a,b){return void 0===a&&0===b?[]:k.call(this,a,b)});var e=a.substr;g="".substr&&"b"!=="0b".substr(-1);p(a,{substr:function(a,b){return e.call(this,0>a?0>(a=this.length+a)?0:a:a,b)}},g)},function(p,g,c){var u=c(33),n=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,
q,a=function(a){var c,f={},g=[];for(c=0;65536>c;c++)g.push(String.fromCharCode(c));a.lastIndex=0;g.join("").replace(a,function(a){f[a]="\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);return""});a.lastIndex=0;return f};p.exports={quote:function(c){c=u.stringify(c);n.lastIndex=0;if(!n.test(c))return c;q||(q=a(n));return c.replace(n,function(a){return q[a]})}}},function(p,g,c){(function(g){var n=function(){};"production"!==g.env.NODE_ENV&&(n=c(9)("sockjs-client:utils:transport"));p.exports=function(c){return{filterToEnabled:function(a,
f){var g={main:[],facade:[]};a?"string"===typeof a&&(a=[a]):a=[];c.forEach(function(c){c&&("websocket"===c.transportName&&!1===f.websocket?n("disabled from server","websocket"):a.length&&-1===a.indexOf(c.transportName)?n("not in whitelist",c.transportName):c.enabled(f)?(n("enabled",c.transportName),g.main.push(c),c.facadeTransport&&g.facade.push(c.facadeTransport)):n("disabled",c.transportName))});return g}}}}).call(g,c(8))},function(p,g,c){(function(c){var g={};["log","debug","warn"].forEach(function(n){try{var a=
c.console&&c.console[n]&&c.console[n].apply}catch(f){}g[n]=a?function(){return c.console[n].apply(c.console,arguments)}:"log"===n?function(){}:g.log});p.exports=g}).call(g,c(7))},function(p,g,c){function u(){n.call(this);this.initEvent("close",!1,!1);this.wasClean=!1;this.code=0;this.reason=""}g=c(4);var n=c(101);g(u,n);p.exports=u},function(p,g,c){function u(c){n.call(this);this.initEvent("message",!1,!1);this.data=c}g=c(4);var n=c(101);g(u,n);p.exports=u},function(p,g,c){(function(g){function n(a,
c){d(a);var b=this;q.call(this);setTimeout(function(){b.doXhr(a,c)},0)}var q=c(13).EventEmitter,a=c(4),f=c(21),l=c(98),u=c(70),t=c(59),m=c(338),k=c(339),e=c(171),d=function(){};"production"!==g.env.NODE_ENV&&(d=c(9)("sockjs-client:info-receiver"));a(n,q);n._getReceiver=function(a,c,d){return d.sameOrigin?new e(c,t):u.enabled?new e(c,u):l.enabled&&d.sameScheme?new e(c,l):k.enabled()?new k(a,c):new e(c,m)};n.prototype.doXhr=function(a,c){var b=this,e=f.addPath(a,"/info");d("doXhr",e);this.xo=n._getReceiver(a,
e,c);this.timeoutRef=setTimeout(function(){d("timeout");b._cleanup(!1);b.emit("finish")},n.timeout);this.xo.once("finish",function(a,c){d("finish",a,c);b._cleanup(!0);b.emit("finish",a,c)})};n.prototype._cleanup=function(a){d("_cleanup");clearTimeout(this.timeoutRef);this.timeoutRef=null;!a&&this.xo&&this.xo.close();this.xo=null};n.prototype.close=function(){d("close");this.removeAllListeners();this._cleanup(!1)};n.timeout=8E3;p.exports=n}).call(g,c(8))},function(p,g,c){function u(){var c=this;n.call(this);
this.to=setTimeout(function(){c.emit("finish",200,"{}")},u.timeout)}var n=c(13).EventEmitter;c(4)(u,n);u.prototype.close=function(){clearTimeout(this.to)};u.timeout=2E3;p.exports=u},function(p,g,c){(function(g,n){function q(c,d){var b=this;a.call(this);var e=function(){var a=b.ifr=new t(m.transportName,d,c);a.once("message",function(a){if(a){try{var c=l.parse(a)}catch(A){k("bad json",a);b.emit("finish");b.close();return}b.emit("finish",c[0],c[1])}b.close()});a.once("close",function(){b.emit("finish");
b.close()})};n.document.body?e():u.attachEvent("load",e)}var a=c(13).EventEmitter,f=c(4),l=c(33),u=c(38),t=c(165),m=c(170),k=function(){};"production"!==g.env.NODE_ENV&&(k=c(9)("sockjs-client:info-iframe"));f(q,a);q.enabled=function(){return t.enabled()};q.prototype.close=function(){this.ifr&&this.ifr.close();this.removeAllListeners();this.ifr=null};p.exports=q}).call(g,c(8),c(7))},function(p,g,c){(function(g){var n=c(21),q=c(38),a=c(33),f=c(341),l=c(170),u=c(61),t=c(169),m=function(){};"production"!==
g.env.NODE_ENV&&(m=c(9)("sockjs-client:iframe-bootstrap"));p.exports=function(c,e){var d={};e.forEach(function(a){a.facadeTransport&&(d[a.facadeTransport.transportName]=a.facadeTransport)});d[l.transportName]=l;var b;c.bootstrap_iframe=function(){var e;u.currentWindowId=t.hash.slice(1);q.attachEvent("message",function(g){if(g.source===parent&&("undefined"===typeof b&&(b=g.origin),g.origin===b)){try{var h=a.parse(g.data)}catch(D){m("bad json",g.data);return}if(h.windowId===u.currentWindowId)switch(h.type){case "s":try{var k=
a.parse(h.data)}catch(D){m("bad json",h.data);break}g=k[0];h=k[1];var l=k[2];k=k[3];m(g,h,l,k);if(g!==c.version)throw Error('Incompatible SockJS! Main site uses: "'+g+'", the iframe: "'+c.version+'".');if(!n.isOriginEqual(l,t.href)||!n.isOriginEqual(k,t.href))throw Error("Can't connect to different domain from within an iframe. ("+t.href+", "+l+", "+k+")");e=new f(new d[h](l,k));break;case "m":e._send(h.data);break;case "c":e&&e._close(),e=null}}});u.postMessage("s")}}}).call(g,c(8))},function(p,
g,c){function u(a){this._transport=a;a.on("message",this._transportMessage.bind(this));a.on("close",this._transportClose.bind(this))}var n=c(33),q=c(61);u.prototype._transportClose=function(a,c){q.postMessage("c",n.stringify([a,c]))};u.prototype._transportMessage=function(a){q.postMessage("t",a)};u.prototype._send=function(a){this._transport.send(a)};u.prototype._close=function(){this._transport.close();this._transport.removeAllListeners()};p.exports=u},function(p,g,c){g.a=function(a){a.registerEventListener(document,
"copy",function(c){if(!Object(u.a)(c)){var f=Object(q.c)(a.state).value;c.clipboardData.setData("text/plain",JSON.stringify(f,void 0,"  "));c.preventDefault()}})};g.b=function(a){a.registerEventListener(document,"paste",function(c){if(!Object(u.a)(c)){var f=c.clipboardData.getData("text/plain").match(/^[\[\]{}()\s,]*(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[\[\]{}()\s,]*$/);f=null!==f?n.s.fromValues(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])):void 0;void 0!==f&&a.navigationState.position.setVoxelCoordinates(f);
c.preventDefault()}})};var u=c(154),n=c(1),q=c(29)},function(p,g,c){function u(){if(void 0===l){var a=new f.a;a.set("keyl","recolor");a.set("keyx","clear-segments");a.set("keys","toggle-show-slices");a.set("keyb","toggle-scale-bar");a.set("shift+keyb","toggle-default-annotations");a.set("keya","toggle-axis-lines");for(var c=1;9>=c;++c)a.set("digit"+c,"toggle-layer-"+c),a.set("control+digit"+c,"select-layer-"+c);a.set("keyn","add-layer");a.set("keyh","help");a.set("space","toggle-layout");a.set("shift+space",
"toggle-layout-alternative");l=a}return l}function n(){void 0===v&&(v=f.a.fromObject({arrowleft:"x-",arrowright:"x+",arrowup:"y-",arrowdown:"y+",comma:"z-",period:"z+",keyz:"snap","control+equal":"zoom-in","control+shift+equal":"zoom-in","control+minus":"zoom-out",keyr:"rotate-relative-z-",keye:"rotate-relative-z+","shift+arrowdown":"rotate-relative-x-","shift+arrowup":"rotate-relative-x+","shift+arrowleft":"rotate-relative-y-","shift+arrowright":"rotate-relative-y+","at:control+wheel":{action:"zoom-via-wheel",
preventDefault:!0},"at:wheel":{action:"z+1-via-wheel",preventDefault:!0},"at:shift+wheel":{action:"z+10-via-wheel",preventDefault:!0},"at:dblclick0":"select","at:control+mousedown0":"annotate","at:mousedown2":"move-to-mouse-position","at:control+mousedown2":"select-annotation"},{label:"All Data Panels"}));return v}function q(){void 0===t&&(t=f.a.fromObject({"at:mousedown0":{action:"rotate-via-mouse-drag",stopPropagation:!0},"at:shift+mousedown0":{action:"translate-via-mouse-drag",stopPropagation:!0}},
{parents:[[n(),Number.NEGATIVE_INFINITY]]}));return t}function a(){void 0===m&&(m=f.a.fromObject({"at:mousedown0":{action:"translate-via-mouse-drag",stopPropagation:!0},"at:shift+mousedown0":{action:"rotate-via-mouse-drag",stopPropagation:!0}},{parents:[[n(),Number.NEGATIVE_INFINITY]]}));return m}g.a=function(c){c.global.addParent(u(),Number.NEGATIVE_INFINITY);c.sliceView.addParent(a(),Number.NEGATIVE_INFINITY);c.perspectiveView.addParent(q(),Number.NEGATIVE_INFINITY)};var f=c(19),l,v,t,m},function(p,
g,c){g.a=function(c){Object(a.a)();Object(a.b)();try{var f=new n.a(document.getElementById("neuroglancer-container"));return new q.a(f,c)}catch(v){throw u.a.showMessage("Error: "+v.message),v;}};c(346);var u=c(25),n=c(118),q=c(148),a=c(351);c(345)},function(p,g){},function(p,g,c){c(347);c(348)},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}p=c(172);var a=c(18);g=c(28);var f=c(0),l=c(1),v=c(23),t=c(93),m=c(16),k=function z(a,b,c){null===a&&(a=Function.prototype);var d=
Object.getOwnPropertyDescriptor(a,b);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return z(a,b,c)}else{if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)}},e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),d=function(a){function b(a,c,d,e){u(this,b);var f=n(this,(b.__proto__||
Object.getPrototypeOf(b)).call(this));f.chunkDataSize=c;f.channelStride=c[0]*c[1]*c[2];Object(t.e)(f,a,d,c[0],c[1],c[2]*e);return f}q(b,a);e(b,null,[{key:"get",value:function(a,c,d,e){return a.memoize.get("sliceview.UncompressedTextureLayout:"+Object(l.t)(c)+","+(d+","+e),function(){return new b(a,c,d,e)})}}]);return b}(f.a),b=function(a){function b(a,c,d,e){u(this,b);a=n(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,e));a.dataType=c;a.numChannels=d;Object(t.c)(a,c);a.textureAccessHelper=
new t.a("chunkData");return a}q(b,a);e(b,[{key:"defineShader",value:function(a){k(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"defineShader",this).call(this,a);var c=this.textureAccessHelper;c.defineShader(a);a.addFragmentCode(c.getAccessor("readVolumeData","uVolumeChunkSampler",this.dataType));1<this.numChannels?(a.addUniform("highp float","uChannelStride"),a.addFragmentCode("\nfloat getChannelOffset(int channelIndex) {\n  return float(channelIndex) * uChannelStride;\n}\n")):a.addFragmentCode("float getChannelOffset(int channelIndex) { return 0.0; }");
a.addFragmentCode("\nfloat getIndexIntoChunk (int channelIndex) {\n  vec3 chunkDataPosition = getPositionWithinChunk();\n  return chunkDataPosition.x + uChunkDataSize.x * (chunkDataPosition.y + uChunkDataSize.y * chunkDataPosition.z) + getChannelOffset(channelIndex);\n}\n");c=Object(m.a)(this.dataType);a.addFragmentCode("\n"+c+" getDataValue (int channelIndex) {\n  return readVolumeData(getIndexIntoChunk(channelIndex));\n}\n")}},{key:"setupTextureLayout",value:function(a,b,c){1<this.numChannels&&
a.uniform1f(b.uniform("uChannelStride"),c.channelStride);this.textureAccessHelper.setupTextureLayout(a,b,c)}},{key:"getTextureLayout",value:function(a,b){return d.get(a,b,this.texelsPerElement,this.numChannels)}},{key:"setTextureData",value:function(a,b,c){Object(t.f)(a,b,this,c)}}],[{key:"get",value:function(a,c,d){var e="sliceview.UncompressedChunkFormat:"+c+":"+d;return a.memoize.get(e,function(){return new b(a,c,d,e)})}}]);return b}(p.a),h=function(b){function c(){u(this,c);return n(this,(c.__proto__||
Object.getPrototypeOf(c)).apply(this,arguments))}q(c,b);e(c,[{key:"setTextureData",value:function(a){var b=this.source,c=b.chunkFormatHandler,d=c.chunkFormat,e;this.textureLayout=this.chunkDataSize===b.spec.chunkDataSize?e=c.textureLayout.addRef():e=d.getTextureLayout(a,this.chunkDataSize);this.chunkFormat.setTextureData(a,e,this.data)}},{key:"getChannelValueAt",value:function(b,c){var d=this.chunkDataSize;c=b[0]+d[0]*(b[1]+d[1]*(b[2]+d[2]*c));d=this.chunkFormat.dataType;b=this.data;switch(d){case a.a.UINT8:case a.a.FLOAT32:case a.a.UINT16:case a.a.UINT32:return b[c];
case a.a.UINT64:return c*=2,new v.a(b[c],b[c+1])}throw Error("Invalid data type: "+d);}}]);return c}(p.b),r=function(a){function c(a,d){u(this,c);var e=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));e.chunkFormat=e.registerDisposer(b.get(a,d.dataType,d.numChannels));e.textureLayout=e.registerDisposer(e.chunkFormat.getTextureLayout(a,d.chunkDataSize));return e}q(c,a);e(c,[{key:"getChunk",value:function(a,b){return new h(a,b)}}]);return c}(f.a);Object(g.c)(function(a,b){return null==b.compressedSegmentationBlockSize?
new r(a,b):null})},function(p,g,c){function u(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}function n(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==typeof b&&"function"!==typeof b?a:b}function q(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,
writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var a=c(349),f=c(350);p=c(172);var l=c(18);g=c(28);var v=c(0),t=c(1),m=c(23),k=c(93),e=c(16),d=function y(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d){if(a=Object.getPrototypeOf(a),null!==a)return y(a,b,c)}else{if("value"in d)return d.value;b=d.get;return void 0===b?void 0:b.call(c)}},b=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=
b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),h=function(a){function c(a,b,d,e){u(this,c);var f=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));f.chunkDataSize=b;f.subchunkSize=d;Object(k.d)(f,a,1,e);a=f.subchunkGridSize=t.s.create();for(e=0;3>e;++e)a[e]=Math.ceil(b[e]/d[e]);return f}q(c,a);b(c,null,[{key:"get",value:function(a,b,d,e){return a.memoize.get("sliceview.CompressedSegmentationTextureLayout:"+
Object(t.t)(b)+","+(Object(t.t)(d)+","+e),function(){return new c(a,b,d,e)})}}]);return c}(v.a),r=Object(k.c)(new k.b,l.a.UINT32),x=function(a){function c(a,b,d,e){u(this,c);e=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this,e));e.dataType=a;e.subchunkSize=b;e.numChannels=d;e.textureAccessHelper=new k.a("chunkData");return e}q(c,a);b(c,[{key:"defineShader",value:function(a){d(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"defineShader",this).call(this,a);var b=this.textureAccessHelper;
b.defineShader(a);var f=function(a){return"compressedSegmentationChunkFormat_"+a};a.addUniform("highp vec3","uSubchunkGridSize");a.addUniform("highp vec3","uSubchunkSize");a.addFragmentCode(e.g);var g=this.dataType,h=Object(e.a)(g);g===l.a.UINT64&&a.addFragmentCode(e.n);a.addFragmentCode(b.getAccessor(f("readTextureValue"),"uVolumeChunkSampler",l.a.UINT32));a.addFragmentCode(e.q);a.addFragmentCode(e.p);b="\nfloat "+f("getChannelOffset")+"(int channelIndex) {\n  if (channelIndex == 0) {\n    return "+
this.numChannels+".0;\n  }\n  vec4 v = "+f("readTextureValue")+"(float(channelIndex)).value;\n  return uintleToFloat(v.xyz);\n}\n"+h+" getDataValue (int channelIndex) {\n  vec3 chunkPosition = getPositionWithinChunk();\n\n  // TODO: maybe premultiply this and store as uniform.\n  vec3 subchunkGridPosition = floor(chunkPosition / uSubchunkSize);\n  float subchunkGridOffset = getFortranOrderIndex(subchunkGridPosition, uSubchunkGridSize);\n\n  float channelOffset = "+f("getChannelOffset")+"(channelIndex);\n\n  // TODO: Maybe just combine this offset into subchunkGridStrides.\n  float subchunkHeaderOffset = subchunkGridOffset * 2.0 + channelOffset;\n\n  vec4 subchunkHeader0 = "+
f("readTextureValue")+"(subchunkHeaderOffset).value;\n  vec4 subchunkHeader1 = "+f("readTextureValue")+"(subchunkHeaderOffset + 1.0).value;\n\n  float outputValueOffset = uintleToFloat(subchunkHeader0.xyz) + channelOffset;\n  float encodingBits = unnormalizeUint8(subchunkHeader0[3]);\n  if (encodingBits > 0.0) {\n    vec3 subchunkPosition = floor(min(chunkPosition - subchunkGridPosition * uSubchunkSize, uSubchunkSize - 1.0));\n    float subchunkOffset = getFortranOrderIndex(subchunkPosition, uSubchunkSize);\n    highp float encodedValueBaseOffset = uintleToFloat(subchunkHeader1.xyz) + channelOffset;\n    highp float encodedValueOffset = floor(encodedValueBaseOffset + subchunkOffset * encodingBits / 32.0);\n    vec4 encodedValue = "+
f("readTextureValue")+"(encodedValueOffset).value;\n    float wordOffset = mod(subchunkOffset * encodingBits, 32.0);\n    // If the value is in the first byte, then 0 <= wordOffset < 8.\n    // We need to mod by 2**encodedBits\n    float wordShifter = pow(2.0, -wordOffset);\n    float encodedValueMod = pow(2.0, encodingBits);\n    float encodedValueShifted;\n    if (wordOffset < 16.0) {\n      encodedValueShifted = dot(unnormalizeUint8(encodedValue.xy), vec2(1.0, 256.0));\n    } else {\n      encodedValueShifted = dot(unnormalizeUint8(encodedValue.zw), vec2(256.0 * 256.0, 256.0 * 256.0 * 256.0));\n    }\n    encodedValueShifted = floor(encodedValueShifted * wordShifter);\n    float decodedValue = mod(encodedValueShifted, encodedValueMod);\n    outputValueOffset += decodedValue * "+
(this.dataType===l.a.UINT64?"2.0":"1.0")+";\n  }\n  "+h+" result;\n";b=g===l.a.UINT64?b+("\n  result.low = "+f("readTextureValue")+"(outputValueOffset).value;\n  result.high = "+f("readTextureValue")+"(outputValueOffset+1.0).value;\n"):b+("\n  result.value = "+f("readTextureValue")+"(outputValueOffset).value;\n");a.addFragmentCode(b+"\n  return result;\n}\n")}},{key:"setupTextureLayout",value:function(a,b,c){a.uniform3fv(b.uniform("uSubchunkGridSize"),c.subchunkGridSize);this.textureAccessHelper.setupTextureLayout(a,
b,c)}},{key:"setTextureData",value:function(a,b,c){Object(k.f)(a,b,r,c)}},{key:"getTextureLayout",value:function(a,b,c){return h.get(a,b,this.subchunkSize,c)}},{key:"beginSource",value:function(a,b){d(c.prototype.__proto__||Object.getPrototypeOf(c.prototype),"beginSource",this).call(this,a,b);a.uniform3fv(b.uniform("uSubchunkSize"),this.subchunkSize)}}],[{key:"get",value:function(a,b,d,e){var f="sliceview.CompressedSegmentationChunkFormat:"+b+":"+e,g=f+":"+Object(t.t)(d);return a.memoize.get(g,function(){return new c(b,
d,e,f)})}}]);return c}(p.a),z=function(c){function d(){u(this,d);return n(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}q(d,c);b(d,[{key:"setTextureData",value:function(a){var b=this.data,c=this.chunkFormat,d=this.textureLayout=c.getTextureLayout(a,this.chunkDataSize,b.length);c.setTextureData(a,d,b)}},{key:"getChannelValueAt",value:function(b,c){var d=this.chunkDataSize,e=this.chunkFormat,g=this.data;c=g[c];if(e.dataType===l.a.UINT64){var h=new m.a;Object(f.a)(h,g,c,d,e.subchunkSize,
b);return h}return Object(a.a)(g,c,d,e.subchunkSize,b)}}]);return d}(p.b),A=function(a){function c(a,b){u(this,c);var d=n(this,(c.__proto__||Object.getPrototypeOf(c)).call(this)),e=b.dataType;if(e!==l.a.UINT64&&e!==l.a.UINT32)throw Error("Unsupported compressed segmentation data type: "+l.a[e]);d.chunkFormat=d.registerDisposer(x.get(a,b.dataType,b.compressedSegmentationBlockSize,b.numChannels));return d}q(c,a);b(c,[{key:"getChunk",value:function(a,b){return new z(a,b)}}]);return c}(v.a);Object(g.c)(function(a,
b){return null!=b.compressedSegmentationBlockSize?new A(a,b):null})},function(p,g,c){g.a=function(c,g,a,f,l){g=Object(u.a)(c,g,a,f,l,1)+g;return c[g]};var u=c(173)},function(p,g,c){g.a=function(c,g,a,f,l,p){a=Object(u.a)(g,a,f,l,p,2)+a;c.low=g[a];c.high=g[a+1];return c};var u=c(173)},function(p,g,c){g.a=function(){return Object(u.c)(document,"contextmenu",function(c){c.preventDefault()})};g.b=function(){return Object(u.c)(document,"wheel",function(c){c.ctrlKey&&c.preventDefault()})};var u=c(0)},function(p,
g,c){function u(a,c){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!c||"object"!==typeof c&&"function"!==typeof c?a:c}function n(a,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);a.prototype=Object.create(c&&c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(a,c):a.__proto__=c)}c.d(g,"a",function(){return t});
p=c(6);var q=c.n(p),a=c(5);p=c(0);var f=c(2),l=c(29),v=function(){function a(a,c){for(var d=0;d<c.length;d++){var b=c[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,e,d){e&&a(c.prototype,e);d&&a(c,d);return c}}(),t=function(c){function g(c,d){d=void 0===d?200:d;if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var b=u(this,(g.__proto__||Object.getPrototypeOf(g)).call(this));b.root=c;
b.parseError=new a.f(void 0);b.registerEventListener(window,"hashchange",function(){return b.updateFromUrlHash()});var e=q()(function(){return b.setUrlHash()},d);b.registerDisposer(c.changed.add(e));b.registerDisposer(function(){return e.cancel()});return b}n(g,c);v(g,[{key:"setUrlHash",value:function(){var a=Object(l.c)(this.root);a.generation!==this.prevStateGeneration&&(this.prevStateGeneration=a.generation,a=Object(f.i)(a.value),a!==this.prevStateString&&(this.prevStateString=a,"{}"===a?history.replaceState(null,
"","#"):history.replaceState(null,"","#!"+a)))}},{key:"updateFromUrlHash",value:function(){try{var a=location.href.replace(/^[^#]+/,"");if(""===a||"#"===a||"#!"===a)a="#!{}";if(a.startsWith("#!+")){a=a.slice(3);a=decodeURI(a);var c=Object(f.h)(a);Object(f.u)(c);this.root.restoreState(c);this.prevStateString=void 0}else if(a.startsWith("#!")){a=a.slice(2);a=decodeURI(a);if(a===this.prevStateString)return;this.prevStateString=a;this.root.reset();var b=Object(f.h)(a);Object(f.u)(b);this.root.restoreState(b)}else throw Error('URL hash is expected to be of the form "#!{...}" or "#!+{...}".');
this.parseError.value=void 0}catch(h){this.parseError.value=h}}}]);return g}(p.a)}]);
