!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("three"),require("rxjs/operators"),require("three/src/math/Matrix4"),require("uuid"),require("pistore"),require("@angular/common/http"),require("rxjs/webSocket"),require("@angular/flex-layout")):"function"==typeof define&&define.amd?define("image-w",["exports","@angular/core","@angular/common","rxjs","three","rxjs/operators","three/src/math/Matrix4","uuid","pistore","@angular/common/http","rxjs/webSocket","@angular/flex-layout"],t):t((e=e||self)["image-w"]={},e.ng.core,e.ng.common,e.rxjs,e.three,e.rxjs.operators,e.Matrix4,e.uuid,e.pistore,e.ng.common.http,e.rxjs.webSocket,e.ng["flex-layout"])}(this,function(e,t,n,i,o,r,a,s,c,u,l,p){"use strict";var h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function d(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function m(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(s){o={error:s}}finally{try{i&&!i.done&&(n=r["return"])&&n.call(r)}finally{if(o)throw o.error}}return a}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}var y=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),g=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"lib-image-w",template:"\n    <p>\n      image-w works!\n    </p>\n  "}]}],e.ctorParameters=function(){return[]},e}(),b=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[],imports:[n.CommonModule],exports:[]}]}],e}(),x=function(){function e(){this.canvas_width=300,this.canvas_height=300,this.infoSubject=new i.BehaviorSubject(["hello","ok"]),this.positionSubject=new i.BehaviorSubject("bottom-left"),this.info$=this.infoSubject.asObservable(),this.position$=this.positionSubject.asObservable()}return Object.defineProperty(e.prototype,"info",{get:function(){return this.infoSubject.value},set:function(e){this.infoSubject.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.positionSubject.value},set:function(e){this.positionSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"corner-info",template:'<div [ngClass]="[position,\'point-event\']"  *ngIf="(info$ | async) as infos" >\n    <p *ngFor="let i of infos" >{{i}}</p>\n</div>\n\n\n\x3c!-- [ngClass]="{position: true}" --\x3e\n',styles:["p{line-height:.5em;color:red;font-size:10px;z-index:10}.top-left{position:absolute;top:5%;left:5%}.top-right{position:absolute;top:5%;left:80%}.bottom-left{position:absolute;top:75%;left:5%;z-index:1}.bottom-right{position:absolute;top:75%;left:80%;z-index:1}.point-event{pointer-events:none}"]}]}],e.ctorParameters=function(){return[]},e.propDecorators={info:[{type:t.Input}],position:[{type:t.Input}]},e}(),w=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[x],imports:[n.CommonModule],exports:[x]}]}],e}(),_=function(){function e(e,t,n,i){this.meta={center:e,size:t,shape:n},this.data=i}return e.prototype.pixel=function(e){return this.data[e]},e.prototype.pixel3=function(e,t,n){return this.data[e*this.meta.shape.y*this.meta.shape.z+t*this.meta.shape.z+n]},e}(),S=function(){function e(e,t,n,i){this.meta={center:e,size:t,shape:n},this.data=i}return e.prototype.pixel=function(e){return this.data[e]},e.prototype.min=function(){return C(this.data,Math.min,NaN)},e.prototype.max=function(){return C(this.data,Math.max,NaN)},e}();function C(e,t,n){if(0===e.length)return n;for(var i=e[0],o=1;o<e.length;o++)i=t(i,e[o]);return i}var I=function(){function e(e,t,n,i,o,r){this.r=i,this.g=o,this.b=r,this.meta={center:e,size:t,shape:n},this.r=i,this.g=o,this.b=r}return e.prototype.pixel=function(e){return{r:this.r[e],g:this.g[e],b:this.b[e]}},e}(),P=function(){return function(e,t,n,i,r,a,s,c){void 0===t&&(t=10),void 0===i&&(i=new o.Vector3(0,0,0)),void 0===r&&(r=!1),void 0===a&&(a=1),void 0===s&&(s=!1),this.box=e,this.z=t,this.textureData=n,this.rotation=i,this.transparent=r,this.opacity=a,this.wireFrame=s,this.color=c,this.type="plane2"}}(),z=function(){return function(e,t,n,i,o,r){void 0===t&&(t=15),void 0===i&&(i=!1),void 0===o&&(o=1),void 0===r&&(r=!1),this.box=e,this.z=t,this.texture=n,this.transparent=i,this.opacity=o,this.wireFrame=r,this.type="infoplane"}}(),D=function(){return function(e,t,n){this.size=e,this.center=t,this.rotate=n,this.type="cube"}}(),V=function(){return function(e,t,n,i,o,r,a,s){void 0===n&&(n=32),void 0===i&&(i=32),void 0===o&&(o=0),void 0===r&&(r=2*Math.PI),void 0===a&&(a=0),void 0===s&&(s=0),this.center=e,this.radius=t,this.widthSegments=n,this.heightSegments=i,this.phiStart=o,this.phiLength=r,this.thetaStart=a,this.thetaLength=s,this.type="sphere"}}(),O=function(){return function(e,t,n,i,o){void 0===n&&(n=32),void 0===i&&(i=0),void 0===o&&(o=2*Math.PI),this.center=e,this.radius=t,this.segments=n,this.thetaStart=i,this.thetaLength=o,this.type="circle"}}(),M=function(){return function(e,t,n,i,o,r,a){void 0===t&&(t=10),void 0===n&&(n=50),void 0===i&&(i=32),void 0===o&&(o=32),void 0===r&&(r=0),void 0===a&&(a=2*Math.PI),this.center=e,this.innerRadius=t,this.outerRadius=n,this.thetaSegments=i,this.phiSegments=o,this.thetaStart=r,this.thetaLength=a,this.type="ring"}}(),j=function(){return function(e){this.shapes=e,this.type="user-defined"}}(),L=function(){return function(e){this.points=e,this.type="profile1d"}}(),T=function(){return function(e,t,n,i){void 0===n&&(n="Solid"),void 0===i&&(i=new o.Color(0,.2,1)),this.start=e,this.end=t,this.style=n,this.color=i,this.type="line"}}(),F=function(){return function(e){this.center=e,this.type="obj"}}(),E=function(){return function(e){this.center=e,this.type="vrml"}}(),k=function(){return function(e,t,n){void 0===n&&(n=1.5),this.position=e,this.view=t,this.lineWidth=n,this.type="crossline"}}(),B=function(){return function(e){this.box=e,this.type="fov"}}(),A=function(){return function(e,t,n,i,r){var a,s;void 0===e&&(e="red"),void 0===t&&(t="bandpass"),void 0===n&&(n=0),void 0===i&&(i=.25),void 0===r&&(r=new _(new o.Vector3(0,0,0),new o.Vector3(190,256,151),new o.Vector3(190,256,151),(a=new Float32Array(7344640),s=10,a.map(function(e,t,n){return s})))),this.color=e,this.opacity=t,this.algorithm=n,this.alphaCorrection=i,this.volume=r,this.type="volume"}}();var R=function(){return function(e,t){this.min=e,this.max=t}}(),$={Up:1,Down:2,Left:3,Right:4};function U(e,t){return t.box.containsPoint(e)}$[$.Up]="Up",$[$.Down]="Down",$[$.Left]="Left",$[$.Right]="Right";var G=function(){function e(e){this.box=e}return Object.defineProperty(e.prototype,"center",{get:function(){return new o.Vector2((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2)},set:function(e){var t=new o.Vector2(e.x-this.center.x,e.y-this.center.y);this.box.min.add(t),this.box.max.add(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return new o.Vector2(this.box.max.x-this.box.min.x,this.box.max.y-this.box.min.y)},set:function(e){this.update(new W(this.center,e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this.box.min.x},set:function(e){this.box.min.x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this.box.max.x},set:function(e){this.box.max.x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.box.min.y},set:function(e){this.box.min.x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this.box.max.y},set:function(e){this.box.max.x=e},enumerable:!0,configurable:!0}),e.prototype.update=function(e){this.box=e.box.clone()},e}(),W=function(){function e(e,t){this.center=e.clone(),this.size=t.clone()}return Object.defineProperty(e.prototype,"box",{get:function(){return new o.Box2(new o.Vector2(this.left,this.top),new o.Vector2(this.right,this.bottom))},set:function(e){this.copy(new G(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this.center.x-this.size.x/2},set:function(e){var t=new N(e,this.right,this.top,this.bottom);this.copy(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this.center.x+this.size.x/2},set:function(e){this.copy(new N(this.left,e,this.top,this.bottom))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.center.y-this.size.y/2},set:function(e){this.copy(new N(this.left,this.right,e,this.bottom))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this.center.y+this.size.y/2},set:function(e){this.copy(new N(this.left,this.right,this.top,e))},enumerable:!0,configurable:!0}),e.prototype.updateRight=function(e){return new N(this.left,e,this.top,this.bottom)},e.prototype.updateLeft=function(e){return new N(e,this.right,this.top,this.bottom)},e.prototype.updateBottom=function(e){return new N(this.left,this.right,this.top,e)},e.prototype.updateTop=function(e){return new N(this.left,this.right,e,this.bottom)},e.prototype.copy=function(e){this.center=e.center.clone(),this.size=e.size.clone()},e}(),N=function(){function e(e,t,n,i){this.left=e,this.right=t,this.top=n,this.bottom=i}return Object.defineProperty(e.prototype,"box",{get:function(){return new o.Box2(new o.Vector2(this.left,this.top),new o.Vector2(this.right,this.bottom))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"center",{get:function(){return new o.Vector2((this.left+this.right)/2,(this.top+this.bottom)/2)},set:function(e){this.copy(new W(e,this.size))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return new o.Vector2(this.right-this.left,this.bottom-this.top)},set:function(e){this.copy(new W(this.center,e))},enumerable:!0,configurable:!0}),e.prototype.copy=function(e){this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom},e}(),H=function(){function e(e,t){this.box=e,this.scale=t}return e.prototype.leftController=function(){return new N(this.box.left-this.box.size.x*this.scale,this.box.left,this.box.top,this.box.bottom)},e.prototype.rightController=function(){return new N(this.box.right,this.box.right+this.box.size.x*this.scale,this.box.top,this.box.bottom)},e.prototype.bottomController=function(){return new N(this.box.left,this.box.right,this.box.bottom,this.box.bottom+this.box.size.y*this.scale)},e.prototype.topController=function(){return new N(this.box.left,this.box.right,this.box.top-this.box.size.y*this.scale,this.box.top)},e.prototype.anyController=function(){return new N(this.box.left*this.scale,this.box.left,this.box.top,this.box.bottom)},e.prototype.onWhichAreabox=function(e){return U(e,this.leftController())?"left":U(e,this.rightController())?"right":U(e,this.topController())?"top":U(e,this.bottomController())?"bottom":U(e,this.box)?"inside":"none"},e}();function q(e,t){for(var n=t.x*t.y,i=new Float32Array(n),r=0;r<t.x;r++)for(var a=0;a<t.y;a++){var s=Math.sin(r/t.x*Math.PI*2+Math.PI/4),c=(Math.cos(a/t.y*Math.PI*2)*s+1)/2;i[r*t.y+a]=255*c}return new S(new o.Vector2(0,0),e,t,i)}function Y(e,t){for(var n=t.x*t.y*t.z,i=new Float32Array(n),r=0;r<t.x;r++)for(var a=0;a<t.y;a++)for(var s=0;s<t.z;s++){var c=Math.sin(r/t.x*Math.PI*2+Math.PI*s/t.z),u=(Math.cos(a/t.y*Math.PI*2)*c+1)/2;i[r*t.y*t.z+a*t.z+s]=u}return new _(new o.Vector3(0,0,0),e,t,i)}function J(e,t,n,i){return i.pipe(r.map(function(){return new S(n,e,t,new Float32Array(t.x*t.y).fill(Math.random()))}))}var K=function(){function e(){this.imageSubject=new i.BehaviorSubject(q(new o.Vector2(60,60),new o.Vector2(60,120))),this.image$=this.imageSubject.asObservable(),this.z=0,this.scroll=new t.EventEmitter,this.drag=new t.EventEmitter,this.model$=this.image$.pipe(r.map(function(e){return new P(new W(e.meta.center,e.meta.size),10,{r:new Uint8Array(e.data),g:new Uint8Array(e.data),b:new Uint8Array(e.data),shape:new o.Vector2(e.meta.shape.x,e.meta.shape.y)})})),this.model$.subscribe(i.noop,function(e){return console.error(e)})}return Object.defineProperty(e.prototype,"image",{get:function(){return this.imageSubject.value},set:function(e){if(e===undefined||null===e)throw Error("Can not set Display2DProperty with null");this.imageSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.onWheelEvent=function(e){this.scroll.emit(e)},e.prototype.onDragEvent=function(e){this.drag.emit(e)},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"app-image2d-gray",template:'<ng3-plane [model]="model$ | async" [z]="z">\n    <ng3-mouse-entity\n      (wheel)="onWheelEvent($event)"\n      (drag)="onDragEvent($event)"\n    ></ng3-mouse-entity>\n  </ng3-plane>',styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={image:[{type:t.Input}],z:[{type:t.Input}],scroll:[{type:t.Output}],drag:[{type:t.Output}]},e}(),X=function(){function e(e,t){var n=this;this.render=e,this._dom=t,this.sizeSubject=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(300,300))),this.size$=this.sizeSubject.asObservable(),this.domElement=this.render.createElement("canvas"),this.domElement.addEventListener("resize",function(e){return console.log(e)}),this.subscription=i.interval(100).subscribe(function(){var e=n.domElement.getBoundingClientRect(),t=new N(e.left,e.right,e.top,e.bottom);t.left===n.size.left&&t.right===n.size.right&&t.top===n.size.top&&t.bottom===n.size.bottom||(n.size=t)})}return Object.defineProperty(e.prototype,"size",{get:function(){return this.sizeSubject.value},set:function(e){this.sizeSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.subscription.unsubscribe()},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:t.Renderer2},{type:undefined,decorators:[{type:t.Inject,args:[n.DOCUMENT]}]}]},e}(),Z=function(){function e(e){this.canvas=e,this.scene=new o.Scene,this.renders=new i.Subject,this.render$=this.renders.asObservable(),this.sizes=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(10,10))),this.size$=this.sizes.asObservable()}return Object.defineProperty(e.prototype,"size",{get:function(){return this.sizes.value},enumerable:!0,configurable:!0}),e.prototype.add=function(e){this.scene.add(e)},e.prototype.remove=function(e){this.scene.remove(e)},e.prototype.resize=function(e){this.sizes.next(e)},e.prototype.ngOnDestroy=function(){this.renders.complete(),this.sizes.complete()},e.prototype.clientSize2SceneSize=function(e){return new o.Vector2(e.x/this.canvas.size.size.x*this.size.size.x,e.y/this.canvas.size.size.y*this.size.size.y)},e.prototype.clientPosition2ScenePosition=function(e){return Q(this.canvas.size,this.size,new o.Vector2(e.x,e.y))},e.prototype.scenePosition2ClientPotision=function(e){return Q(this.size,this.canvas.size,new o.Vector2(e.x,e.y))},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:X}]},e}();function Q(e,t,n){return new o.Vector2(ee(n.x,e.box.min.x,e.box.max.x,t.box.min.x,t.box.max.x),ee(n.y,e.box.min.y,e.box.max.y,t.box.min.y,t.box.max.y))}function ee(e,t,n,i,o){return(e-t)/(n-t)*(o-i)+i}var te=function(){function e(e,t){var n=this;this.sceneService=e,this.canvas=t,this.verbose=0,this.renderer=new o.WebGLRenderer({canvas:this.canvas.domElement,antialias:!0}),this.subject=new i.Subject,this.render$=this.subject.asObservable(),this.isPushbasedRender=!0,this.canvas.size$.subscribe(function(e){var t=n.renderer.getSize();e.size.x===t.width&&e.size.y===t.height||(n.renderer.setSize(e.size.x,e.size.y),n.render())},function(e){return console.error(e)}),this.isPushbasedRender?this.render$.subscribe(function(){n.doRender()},function(e){return console.error(e)}):this.animation()}return e.prototype.doRender=function(){this.camera!==undefined?this.renderer.render(this.sceneService.scene,this.camera):this.verbose>0&&console.warn("Failed to render:\ncamera: ",this.camera,"\ncanvas",this.canvas,"\nrenderer:",this.renderer,"\n")},e.prototype.setCamera=function(e){this.camera=e},e.prototype.animation=function(){var e=this;requestAnimationFrame(function(){return e.animation()}),this.doRender()},e.prototype.render=function(){this.subject.next()},Object.defineProperty(e.prototype,"domElement",{get:function(){return this.renderer.domElement},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.subject.complete()},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:Z},{type:X}]},e}(),ne=function(){function e(){}return e.uniforms=function(){return{uTextureSize:{type:"i",value:0,typeGLSL:"int"},uTextureContainer:{type:"tv",value:[],typeGLSL:"sampler2D",length:7},uDataDimensions:{type:"iv",value:[0,0,0],typeGLSL:"ivec3"},uWorldToData:{type:"m4",value:new a.Matrix4,typeGLSL:"mat4"},uWindowCenterWidth:{type:"fv1",value:[0,0],typeGLSL:"float",length:2},uRescaleSlopeIntercept:{type:"fv1",value:[0,0],typeGLSL:"float",length:2},uNumberOfChannels:{type:"i",value:1,typeGLSL:"int"},uBitsAllocated:{type:"i",value:8,typeGLSL:"int"},uInvert:{type:"i",value:0,typeGLSL:"int"},uLut:{type:"i",value:0,typeGLSL:"int"},uTextureLUT:{type:"t",value:new o.Texture,typeGLSL:"sampler2D"},uPixelType:{type:"i",value:0,typeGLSL:"int"},uPackedPerPixel:{type:"i",value:1,typeGLSL:"int"},uInterpolation:{type:"i",value:1,typeGLSL:"int"},uWorldBBox:{type:"fv1",value:[0,0,0,0,0,0],typeGLSL:"float",length:6},uSteps:{type:"i",value:256,typeGLSL:"int"},uAlphaCorrection:{type:"f",value:.5,typeGLSL:"float"},uFrequence:{type:"f",value:0,typeGLSL:"float"},uAmplitude:{type:"f",value:0,typeGLSL:"float"},uShading:{type:"i",value:1,typeGLSL:"int"},uAmbient:{type:"f",value:.1,typeGLSL:"float"},uAmbientColor:{type:"v3",value:[1,1,0],typeGLSL:"vec3"},uSampleColorToAmbient:{type:"i",value:1,typeGLSL:"int"},uSpecular:{type:"f",value:1,typeGLSL:"float"},uSpecularColor:{type:"v3",value:[1,1,1],typeGLSL:"vec3"},uDiffuse:{type:"f",value:.3,typeGLSL:"float"},uDiffuseColor:{type:"v3",value:[1,1,0],typeGLSL:"vec3"},uSampleColorToDiffuse:{type:"i",value:1,typeGLSL:"int"},uShininess:{type:"f",value:5,typeGLSL:"float"},uLightPosition:{type:"v3",value:[0,0,0],typeGLSL:"vec3"},uLightPositionInCamera:{type:"i",value:1,typeGLSL:"int"},uIntensity:{type:"v3",value:[.8,.8,.8],typeGLSL:"vec3"},uAlgorithm:{type:"i",value:0,typeGLSL:"int"}}},e}(),ie=function(){function e(){}return e.prototype.compute=function(){return"\nvarying vec4 vPos;\n\n//\n// main\n//\nvoid main() {\n  vPos = modelMatrix * vec4(position, 1.0 );\n  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );\n\n}\n        "},e}(),oe=function(){function e(){this._name="shadersBase",this._base={_functions:{},_uniforms:{}},this._definition=""}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!0,configurable:!0}),e}(),re=new(function(e){function t(){var t=e.call(this)||this;return t._packedData="packedData",t._offset="offset",t._unpackedData="unpackedData",t.name="unpack",t._base._uniforms={uNumberOfChannels:{value:1},uBitsAllocated:{value:16},uPixelType:{value:0}},t}return d(t,e),t.prototype.api=function(e,t,n,i){return void 0===e&&(e=this._base),void 0===t&&(t=this._packedData),void 0===n&&(n=this._offset),void 0===i&&(i=this._unpackedData),this._base=e,this.compute(t,n,i)},t.prototype.compute=function(e,t,n){return this.computeDefinition(),this._base._functions[this._name]=this._definition,this._name+"("+e+", "+t+", "+n+");"},t.prototype.computeDefinition=function(){var e="";if(1===this._base._uniforms.uNumberOfChannels.value)switch(this._base._uniforms.uBitsAllocated.value){case 1:case 8:e=this.upack8();break;case 16:e=this.upack16();break;case 32:e=this.upack32();break;default:e=this.upackIdentity()}else e=this.upackIdentity();this._definition="\nvoid "+this._name+"(in vec4 packedData, in int offset, out vec4 unpackedData){\n\n"+e+"\n\n}\n    "},t.prototype.upack8=function(){return this._base._functions.uInt8=this.uInt8(),"\nfloat floatedOffset = float(offset);\nfloat floatedOffsetSquared = floatedOffset * floatedOffset;\nuInt8(\n  step( floatedOffsetSquared , 0.0 ) * packedData.r +\n  step( floatedOffsetSquared - 2. * floatedOffset + 1., 0.0 ) * packedData.g +\n  step( floatedOffsetSquared - 2. * 2. *  floatedOffset + 4., 0.0 ) * packedData.b +\n  step( floatedOffsetSquared - 2. * 3. *  floatedOffset + 9., 0.0 ) * packedData.a\n  ,\n  unpackedData.x);\n    "},t.prototype.upack16=function(){return this._base._functions.uInt16=this.uInt16(),"\nfloat floatedOffset = float(offset);\nuInt16(\n  packedData.r * (1. - floatedOffset) + packedData.b * floatedOffset,\n  packedData.g * (1. - floatedOffset) + packedData.a * floatedOffset,\n  unpackedData.x);\n    "},t.prototype.upack32=function(){return 0===this._base._uniforms.uPixelType.value?(this._base._functions.uInt32=this.uInt32(),"\nuInt32(\n  packedData.r,\n  packedData.g,\n  packedData.b,\n  packedData.a,\n  unpackedData.x);\n      "):(this._base._functions.uFloat32=this.uFloat32(),"\nuFloat32(\n  packedData.r,\n  packedData.g,\n  packedData.b,\n  packedData.a,\n  unpackedData.x);\n      ")},t.prototype.upackIdentity=function(){return"\nunpackedData = packedData;\n      "},t.prototype.uInt8=function(){return"\nvoid uInt8(in float r, out float value){\n  value = r * 255.;\n}\n    "},t.prototype.uInt16=function(){return"\nvoid uInt16(in float r, in float a, out float value){\n  value = r * 255. + a * 255. * 256.;\n}\n    "},t.prototype.uInt32=function(){return"\nvoid uInt32(in float r, in float g, in float b, in float a, out float value){\n  value = r * 255. + g * 255. * 256. + b * 255. * 256. * 256. + a * 255. * 256. * 256. * 256.;\n  // value = r * 255. + g * 65025. + b * 16581375. + a * 4228250625.;\n}\n    "},t.prototype.uFloat32=function(){return"\nvoid uFloat32(in float r, in float g, in float b, in float a, out float value){\n\n  // create arrays containing bits for rgba values\n  // value between 0 and 255\n  value = r * 255.;\n  int bytemeR[8];\n  bytemeR[0] = int(floor(value / 128.));\n  value -= float(bytemeR[0] * 128);\n  bytemeR[1] = int(floor(value / 64.));\n  value -= float(bytemeR[1] * 64);\n  bytemeR[2] = int(floor(value / 32.));\n  value -= float(bytemeR[2] * 32);\n  bytemeR[3] = int(floor(value / 16.));\n  value -= float(bytemeR[3] * 16);\n  bytemeR[4] = int(floor(value / 8.));\n  value -= float(bytemeR[4] * 8);\n  bytemeR[5] = int(floor(value / 4.));\n  value -= float(bytemeR[5] * 4);\n  bytemeR[6] = int(floor(value / 2.));\n  value -= float(bytemeR[6] * 2);\n  bytemeR[7] = int(floor(value));\n\n  value = g * 255.;\n  int bytemeG[8];\n  bytemeG[0] = int(floor(value / 128.));\n  value -= float(bytemeG[0] * 128);\n  bytemeG[1] = int(floor(value / 64.));\n  value -= float(bytemeG[1] * 64);\n  bytemeG[2] = int(floor(value / 32.));\n  value -= float(bytemeG[2] * 32);\n  bytemeG[3] = int(floor(value / 16.));\n  value -= float(bytemeG[3] * 16);\n  bytemeG[4] = int(floor(value / 8.));\n  value -= float(bytemeG[4] * 8);\n  bytemeG[5] = int(floor(value / 4.));\n  value -= float(bytemeG[5] * 4);\n  bytemeG[6] = int(floor(value / 2.));\n  value -= float(bytemeG[6] * 2);\n  bytemeG[7] = int(floor(value));\n\n  value = b * 255.;\n  int bytemeB[8];\n  bytemeB[0] = int(floor(value / 128.));\n  value -= float(bytemeB[0] * 128);\n  bytemeB[1] = int(floor(value / 64.));\n  value -= float(bytemeB[1] * 64);\n  bytemeB[2] = int(floor(value / 32.));\n  value -= float(bytemeB[2] * 32);\n  bytemeB[3] = int(floor(value / 16.));\n  value -= float(bytemeB[3] * 16);\n  bytemeB[4] = int(floor(value / 8.));\n  value -= float(bytemeB[4] * 8);\n  bytemeB[5] = int(floor(value / 4.));\n  value -= float(bytemeB[5] * 4);\n  bytemeB[6] = int(floor(value / 2.));\n  value -= float(bytemeB[6] * 2);\n  bytemeB[7] = int(floor(value));\n\n  value = a * 255.;\n  int bytemeA[8];\n  bytemeA[0] = int(floor(value / 128.));\n  value -= float(bytemeA[0] * 128);\n  bytemeA[1] = int(floor(value / 64.));\n  value -= float(bytemeA[1] * 64);\n  bytemeA[2] = int(floor(value / 32.));\n  value -= float(bytemeA[2] * 32);\n  bytemeA[3] = int(floor(value / 16.));\n  value -= float(bytemeA[3] * 16);\n  bytemeA[4] = int(floor(value / 8.));\n  value -= float(bytemeA[4] * 8);\n  bytemeA[5] = int(floor(value / 4.));\n  value -= float(bytemeA[5] * 4);\n  bytemeA[6] = int(floor(value / 2.));\n  value -= float(bytemeA[6] * 2);\n  bytemeA[7] = int(floor(value));\n\n  // compute float32 value from bit arrays\n\n  // sign\n  int issigned = 1 - 2 * bytemeR[0];\n  //   issigned = int(pow(-1., float(bytemeR[0])));\n\n  // exponent\n  int exponent = 0;\n\n  exponent += bytemeR[1] * int(pow(2., 7.));\n  exponent += bytemeR[2] * int(pow(2., 6.));\n  exponent += bytemeR[3] * int(pow(2., 5.));\n  exponent += bytemeR[4] * int(pow(2., 4.));\n  exponent += bytemeR[5] * int(pow(2., 3.));\n  exponent += bytemeR[6] * int(pow(2., 2.));\n  exponent += bytemeR[7] * int(pow(2., 1.));\n\n  exponent += bytemeG[0];\n\n\n  // fraction\n  float fraction = 0.;\n\n  fraction = float(bytemeG[1]) * pow(2., -1.);\n  fraction += float(bytemeG[2]) * pow(2., -2.);\n  fraction += float(bytemeG[3]) * pow(2., -3.);\n  fraction += float(bytemeG[4]) * pow(2., -4.);\n  fraction += float(bytemeG[5]) * pow(2., -5.);\n  fraction += float(bytemeG[6]) * pow(2., -6.);\n  fraction += float(bytemeG[7]) * pow(2., -7.);\n\n  fraction += float(bytemeB[0]) * pow(2., -8.);\n  fraction += float(bytemeB[1]) * pow(2., -9.);\n  fraction += float(bytemeB[2]) * pow(2., -10.);\n  fraction += float(bytemeB[3]) * pow(2., -11.);\n  fraction += float(bytemeB[4]) * pow(2., -12.);\n  fraction += float(bytemeB[5]) * pow(2., -13.);\n  fraction += float(bytemeB[6]) * pow(2., -14.);\n  fraction += float(bytemeB[7]) * pow(2., -15.);\n\n  fraction += float(bytemeA[0]) * pow(2., -16.);\n  fraction += float(bytemeA[1]) * pow(2., -17.);\n  fraction += float(bytemeA[2]) * pow(2., -18.);\n  fraction += float(bytemeA[3]) * pow(2., -19.);\n  fraction += float(bytemeA[4]) * pow(2., -20.);\n  fraction += float(bytemeA[5]) * pow(2., -21.);\n  fraction += float(bytemeA[6]) * pow(2., -22.);\n  fraction += float(bytemeA[7]) * pow(2., -23.);\n\n  value = float(issigned) * pow( 2., float(exponent - 127)) * (1. + fraction);\n}\n    "},t}(oe)),ae=new(function(e){function t(){var t=e.call(this)||this;return t._dataCoordinates="dataCoordinates",t._dataValue="dataValue",t._offset="offset",t.name="texture3d",t}return d(t,e),t.prototype.api=function(e,t,n,i){return void 0===e&&(e=this._base),void 0===t&&(t=this._dataCoordinates),void 0===n&&(n=this._dataValue),void 0===i&&(i=this._offset),this._base=e,this.compute(t,n,i)},t.prototype.compute=function(e,t,n){return this.computeDefinition(),this._base._functions[this._name]=this._definition,this._name+"("+e+", "+t+", "+n+");"},t.prototype.computeDefinition=function(){var e="\n      step( abs( textureIndexF - 0.0 ), 0.0 ) * texture2D(uTextureContainer[0], uv) +\n      step( abs( textureIndexF - 1.0 ), 0.0 ) * texture2D(uTextureContainer[1], uv) +\n      step( abs( textureIndexF - 2.0 ), 0.0 ) * texture2D(uTextureContainer[2], uv) +\n      step( abs( textureIndexF - 3.0 ), 0.0 ) * texture2D(uTextureContainer[3], uv) +\n      step( abs( textureIndexF - 4.0 ), 0.0 ) * texture2D(uTextureContainer[4], uv) +\n      step( abs( textureIndexF - 5.0 ), 0.0 ) * texture2D(uTextureContainer[5], uv) +\n      step( abs( textureIndexF - 6.0 ), 0.0 ) * texture2D(uTextureContainer[6], uv)";14===this._base._uniforms.uTextureContainer.length&&(e+=" +\n      step( abs( textureIndexF - 7.0 ), 0.0 ) * texture2D(uTextureContainer[7], uv) +\n      step( abs( textureIndexF - 8.0 ), 0.0 ) * texture2D(uTextureContainer[8], uv) +\n      step( abs( textureIndexF - 9.0 ), 0.0 ) * texture2D(uTextureContainer[9], uv) +\n      step( abs( textureIndexF - 10.0 ), 0.0 ) * texture2D(uTextureContainer[10], uv) +\n      step( abs( textureIndexF - 11.0 ), 0.0 ) * texture2D(uTextureContainer[11], uv) +\n      step( abs( textureIndexF - 12.0 ), 0.0 ) * texture2D(uTextureContainer[12], uv) +\n      step( abs( textureIndexF - 13.0 ), 0.0 ) * texture2D(uTextureContainer[13], uv)"),this._definition="\nvoid "+this._name+"(in ivec3 dataCoordinates, out vec4 dataValue, out int offset){\n  float textureSizeF = float(uTextureSize);\n  int voxelsPerTexture = uTextureSize*uTextureSize;\n\n  int index = dataCoordinates.x\n            + dataCoordinates.y * uDataDimensions.x\n            + dataCoordinates.z * uDataDimensions.y * uDataDimensions.x;\n\n  // dividing an integer by an integer will give you an integer result, rounded down\n  // can not get float numbers to work :(\n  int packedIndex = index/uPackedPerPixel;\n  offset = index - uPackedPerPixel*packedIndex;\n\n  // Map data index to right sampler2D texture\n  int textureIndex = packedIndex/voxelsPerTexture;\n  int inTextureIndex = packedIndex - voxelsPerTexture*textureIndex;\n\n  // Get row and column in the texture\n  int rowIndex = inTextureIndex/uTextureSize;\n  float rowIndexF = float(rowIndex);\n  float colIndex = float(inTextureIndex - uTextureSize * rowIndex);\n\n  // Map row and column to uv\n  vec2 uv = vec2(0,0);\n  uv.x = (0.5 + colIndex) / textureSizeF;\n  uv.y = 1. - (0.5 + rowIndexF) / textureSizeF;\n\n  float textureIndexF = float(textureIndex);\n  dataValue = vec4(0.) + "+e+";\n}\n    "},t}(oe)),se=new(function(e){function t(){var t=e.call(this)||this;return t._currentVoxel="currentVoxel",t._dataValue="dataValue",t.name="interpolationIdentity",t}return d(t,e),t.prototype.api=function(e,t,n){return void 0===e&&(e=this._base),void 0===t&&(t=this._currentVoxel),void 0===n&&(n=this._dataValue),this._base=e,this.compute(t,n)},t.prototype.compute=function(e,t){return this.computeDefinition(),this._base._functions[this._name]=this._definition,this._name+"("+e+", "+t+");"},t.prototype.computeDefinition=function(){this._definition="\nvoid "+this._name+"(in vec3 currentVoxel, out vec4 dataValue){\n  // lower bound\n  vec3 rcurrentVoxel = vec3(floor(currentVoxel.x + 0.5 ), floor(currentVoxel.y + 0.5 ), floor(currentVoxel.z + 0.5 ));\n  ivec3 voxel = ivec3(int(rcurrentVoxel.x), int(rcurrentVoxel.y), int(rcurrentVoxel.z));\n\n  vec4 tmp = vec4(0., 0., 0., 0.);\n  int offset = 0;\n\n  "+ae.api(this._base,"voxel","tmp","offset")+"\n  "+re.api(this._base,"tmp","offset","dataValue")+"\n}\n    "},t}(oe)),ce=new(function(e){function t(){var t=e.call(this)||this;return t._currentVoxel="currentVoxel",t._dataValue="dataValue",t._gradient="gradient",t.name="interpolationTrilinear",t}return d(t,e),t.prototype.api=function(e,t,n,i){return void 0===e&&(e=this._base),void 0===t&&(t=this._currentVoxel),void 0===n&&(n=this._dataValue),void 0===i&&(i=this._gradient),this._base=e,this.compute(t,n,i)},t.prototype.compute=function(e,t,n){return this.computeDefinition(),this._base._functions[this._name]=this._definition,this._name+"("+e+", "+t+", "+n+");"},t.prototype.computeDefinition=function(){this._definition="\nvoid trilinearInterpolation(\n  in vec3 normalizedPosition,\n  out vec4 interpolatedValue,\n  in vec4 v000, in vec4 v100,\n  in vec4 v001, in vec4 v101,\n  in vec4 v010, in vec4 v110,\n  in vec4 v011, in vec4 v111) {\n  // https://en.wikipedia.org/wiki/Trilinear_interpolation\n  vec4 c00 = v000 * ( 1.0 - normalizedPosition.x ) + v100 * normalizedPosition.x;\n  vec4 c01 = v001 * ( 1.0 - normalizedPosition.x ) + v101 * normalizedPosition.x;\n  vec4 c10 = v010 * ( 1.0 - normalizedPosition.x ) + v110 * normalizedPosition.x;\n  vec4 c11 = v011 * ( 1.0 - normalizedPosition.x ) + v111 * normalizedPosition.x;\n\n  // c0 and c1\n  vec4 c0 = c00 * ( 1.0 - normalizedPosition.y) + c10 * normalizedPosition.y;\n  vec4 c1 = c01 * ( 1.0 - normalizedPosition.y) + c11 * normalizedPosition.y;\n\n  // c\n  vec4 c = c0 * ( 1.0 - normalizedPosition.z) + c1 * normalizedPosition.z;\n  interpolatedValue = c;\n}\n\nvoid "+this._name+"(in vec3 currentVoxel, out vec4 dataValue, out vec3 gradient){\n\n  vec3 lower_bound = floor(currentVoxel);\n  lower_bound = max(vec3(0.), lower_bound);\n\n  vec3 higher_bound = lower_bound + vec3(1.);\n\n  vec3 normalizedPosition = (currentVoxel - lower_bound);\n  normalizedPosition =  max(vec3(0.), normalizedPosition);\n\n  vec4 interpolatedValue = vec4(0.);\n\n  //\n  // fetch values required for interpolation\n  //\n  vec4 v000 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c000 = vec3(lower_bound.x, lower_bound.y, lower_bound.z);\n  "+se.api(this._base,"c000","v000")+"\n\n  //\n  vec4 v100 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c100 = vec3(higher_bound.x, lower_bound.y, lower_bound.z);\n  "+se.api(this._base,"c100","v100")+"\n\n  //\n  vec4 v001 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c001 = vec3(lower_bound.x, lower_bound.y, higher_bound.z);\n  "+se.api(this._base,"c001","v001")+"\n\n  //\n  vec4 v101 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c101 = vec3(higher_bound.x, lower_bound.y, higher_bound.z);\n  "+se.api(this._base,"c101","v101")+"\n\n  //\n  vec4 v010 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c010 = vec3(lower_bound.x, higher_bound.y, lower_bound.z);\n  "+se.api(this._base,"c010","v010")+"\n\n  vec4 v110 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c110 = vec3(higher_bound.x, higher_bound.y, lower_bound.z);\n  "+se.api(this._base,"c110","v110")+"\n\n  //\n  vec4 v011 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c011 = vec3(lower_bound.x, higher_bound.y, higher_bound.z);\n  "+se.api(this._base,"c011","v011")+"\n\n  vec4 v111 = vec4(0.0, 0.0, 0.0, 0.0);\n  vec3 c111 = vec3(higher_bound.x, higher_bound.y, higher_bound.z);\n  "+se.api(this._base,"c111","v111")+"\n\n  // compute interpolation at position\n  trilinearInterpolation(normalizedPosition, interpolatedValue ,v000, v100, v001, v101, v010,v110, v011,v111);\n  dataValue = interpolatedValue;\n\n  // That breaks shading in volume rendering\n  // if (gradient.x == 1.) { // skip gradient calculation for slice helper\n  //  return;\n  // }\n\n  // compute gradient\n  float gradientStep = 0.005;\n\n  // x axis\n  vec3 g100 = vec3(1., 0., 0.);\n  vec3 ng100 = normalizedPosition + g100 * gradientStep;\n  ng100.x = min(1., ng100.x);\n\n  vec4 vg100 = vec4(0.);\n  trilinearInterpolation(ng100, vg100 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  vec3 go100 = -g100;\n  vec3 ngo100 = normalizedPosition + go100 * gradientStep;\n  ngo100.x = max(0., ngo100.x);\n\n  vec4 vgo100 = vec4(0.);\n  trilinearInterpolation(ngo100, vgo100 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  gradient.x = (g100.x * vg100.x + go100.x * vgo100.x);\n\n  // y axis\n  vec3 g010 = vec3(0., 1., 0.);\n  vec3 ng010 = normalizedPosition + g010 * gradientStep;\n  ng010.y = min(1., ng010.y);\n\n  vec4 vg010 = vec4(0.);\n  trilinearInterpolation(ng010, vg010 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  vec3 go010 = -g010;\n  vec3 ngo010 = normalizedPosition + go010 * gradientStep;\n  ngo010.y = max(0., ngo010.y);\n\n  vec4 vgo010 = vec4(0.);\n  trilinearInterpolation(ngo010, vgo010 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  gradient.y = (g010.y * vg010.x + go010.y * vgo010.x);\n\n  // z axis\n  vec3 g001 = vec3(0., 0., 1.);\n  vec3 ng001 = normalizedPosition + g001 * gradientStep;\n  ng001.z = min(1., ng001.z);\n\n  vec4 vg001 = vec4(0.);\n  trilinearInterpolation(ng001, vg001 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  vec3 go001 = -g001;\n  vec3 ngo001 = normalizedPosition + go001 * gradientStep;\n  ngo001.z = max(0., ngo001.z);\n\n  vec4 vgo001 = vec4(0.);\n  trilinearInterpolation(ngo001, vgo001 ,v000, v100, v001, v101, v010,v110, v011,v111);\n\n  gradient.z = (g001.z * vg001.x + go001.z * vgo001.x);\n\n  // normalize gradient\n  // +0.0001  instead of if?\n  float gradientMagnitude = length(gradient);\n  if (gradientMagnitude > 0.0) {\n    gradient = -(1. / gradientMagnitude) * gradient;\n  }\n}\n    "},t}(oe));function ue(e,t,n,i){switch(e._uniforms.uInterpolation.value){case 0:return se.api(e,t,n);case 1:return ce.api(e,t,n,i);default:return se.api(e,t,n)}}var le=new(function(e){function t(){var t=e.call(this)||this;return t._rayOrigin="rayOrigin",t._rayDirection="rayDirection",t._aabbMin="aabbMin",t._aabbMax="aabbMax",t._tNear="tNear",t._tFar="tFar",t._intersect="intersect",t.name="intersectBox",t}return d(t,e),t.prototype.api=function(e,t,n,i,o,r,a,s){return void 0===e&&(e=this._base),void 0===t&&(t=this._rayOrigin),void 0===n&&(n=this._rayDirection),void 0===i&&(i=this._aabbMin),void 0===o&&(o=this._aabbMax),void 0===r&&(r=this._tNear),void 0===a&&(a=this._tFar),void 0===s&&(s=this._intersect),this._base=e,this.compute(t,n,i,o,r,a,s)},t.prototype.compute=function(e,t,n,i,o,r,a){return this.computeDefinition(),this._base._functions[this._name]=this._definition,this._name+"("+e+", "+t+", "+n+", "+i+", "+o+", "+r+", "+a+");"},t.prototype.computeDefinition=function(){this._definition="\nvoid "+this._name+"(vec3 rayOrigin, vec3 rayDirection, vec3 boxMin, vec3 boxMax, out float tNear, out float tFar, out bool intersect){\n  // compute intersection of ray with all six bbox planes\n  vec3 invRay = vec3(1.) / rayDirection;\n  vec3 tBot = invRay * (boxMin - rayOrigin);\n  vec3 tTop = invRay * (boxMax - rayOrigin);\n  // re-order intersections to find smallest and largest on each axis\n  vec3 tMin = min(tTop, tBot);\n  vec3 tMax = max(tTop, tBot);\n  // find the largest tMin and the smallest tMax\n  float largest_tMin = max(max(tMin.x, tMin.y), max(tMin.x, tMin.z));\n  float smallest_tMax = min(min(tMax.x, tMax.y), min(tMax.x, tMax.z));\n  tNear = largest_tMin;\n  tFar = smallest_tMax;\n  intersect = smallest_tMax > largest_tMin;\n}\n\n    "},t}(oe)),pe=function(){function e(e){this._functions={},this._main="",this._uniforms=e,this._functions={},this._main=""}return e.prototype.functions=function(){""===this._main&&this.main();var e="";for(var t in this._functions)e+=this._functions[t]+"\n";return e},e.prototype.uniforms=function(){var e="";for(var t in this._uniforms){var n=this._uniforms[t];e+="uniform "+n.typeGLSL+" "+t,n&&n.length&&(e+="["+n.length+"]"),e+=";\n"}return e},e.prototype.main=function(){this._main="\nvoid getIntensity(in vec3 dataCoordinates, out float intensity, out vec3 gradient){\n\n  vec4 dataValue = vec4(0., 0., 0., 0.);\n  "+ue(this,"dataCoordinates","dataValue","gradient")+"\n\n  intensity = dataValue.r;\n\n  // rescale/slope\n  intensity = intensity*uRescaleSlopeIntercept[0] + uRescaleSlopeIntercept[1];\n  // window level\n  float windowMin = uWindowCenterWidth[0] - uWindowCenterWidth[1] * 0.5;\n  intensity = ( intensity - windowMin ) / uWindowCenterWidth[1];\n}\n\nmat4 inverse(mat4 m) {\n  float\n    a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n    a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n    a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n    a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n    b00 = a00 * a11 - a01 * a10,\n    b01 = a00 * a12 - a02 * a10,\n    b02 = a00 * a13 - a03 * a10,\n    b03 = a01 * a12 - a02 * a11,\n    b04 = a01 * a13 - a03 * a11,\n    b05 = a02 * a13 - a03 * a12,\n    b06 = a20 * a31 - a21 * a30,\n    b07 = a20 * a32 - a22 * a30,\n    b08 = a20 * a33 - a23 * a30,\n    b09 = a21 * a32 - a22 * a31,\n    b10 = a21 * a33 - a23 * a31,\n    b11 = a22 * a33 - a23 * a32,\n\n    det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n  return mat4(\n    a11 * b11 - a12 * b10 + a13 * b09,\n    a02 * b10 - a01 * b11 - a03 * b09,\n    a31 * b05 - a32 * b04 + a33 * b03,\n    a22 * b04 - a21 * b05 - a23 * b03,\n    a12 * b08 - a10 * b11 - a13 * b07,\n    a00 * b11 - a02 * b08 + a03 * b07,\n    a32 * b02 - a30 * b05 - a33 * b01,\n    a20 * b05 - a22 * b02 + a23 * b01,\n    a10 * b10 - a11 * b08 + a13 * b06,\n    a01 * b08 - a00 * b10 - a03 * b06,\n    a30 * b04 - a31 * b02 + a33 * b00,\n    a21 * b02 - a20 * b04 - a23 * b00,\n    a11 * b07 - a10 * b09 - a12 * b06,\n    a00 * b09 - a01 * b07 + a02 * b06,\n    a31 * b01 - a30 * b03 - a32 * b00,\n    a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n/**\n * Adapted from original sources\n *\n * Original code:\n * http://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/\n * https://www.shadertoy.com/view/lt33z7\n *\n * The vec3 returned is the RGB color of the light's contribution.\n *\n * k_a: Ambient color\n * k_d: Diffuse color\n * k_s: Specular color\n * alpha: Shininess coefficient\n * p: position of point being lit\n * eye: the position of the camera\n * lightPos: the position of the light\n * lightIntensity: color/intensity of the light\n *\n * See https://en.wikipedia.org/wiki/Phong_reflection_model#Description\n */\nvec3 phongShading(vec3 k_a, vec3 k_d, vec3 k_s, float shininess, vec3 p, vec3 eye,\n  vec3 lightPos, vec3 lightIntensity, vec3 normal) {\n  vec3 N = normal;\n  vec3 L = lightPos - p;\n  if (length(L) > 0.) {\n    L = L / length(L);\n  }\n  vec3 V = eye - p;\n  if (length(V) > 0.) {\n    V = V / length(V);\n  }\n  vec3 R = reflect(-L, N);\n  if (length(R) > 0.) {\n    R = R / length(R);\n  }\n\n  // https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model\n  vec3 h = L + V;\n  vec3 H = h;\n  if (length(h) > 0.) {\n    H = H / length(h);\n  }\n\n  float dotLN = dot(L, N);\n  float dotRV = dot(R, V);\n\n  if (dotLN < 0.) {\n    // Light not visible from this point on the surface\n    return k_a;\n  }\n\n  if (dotRV < 0.) {\n    // Light reflection in opposite direction as viewer, apply only diffuse\n    // component\n    return k_a + lightIntensity * (k_d * dotLN);\n  }\n\n  float specAngle = max(dot(H, normal), 0.0);\n  float specular = pow(dotRV, shininess); //pow(specAngle, shininess); //\n  return k_a + lightIntensity * (k_d * dotLN  + k_s * specular);\n}\n\nfloat PI = 3.14159265358979323846264 * 00000.1; // PI\n\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv) {\n  const highp float a = 12.9898;\n  const highp float b = 78.233;\n  const highp float c = 43758.5453;\n  highp float dt = dot(uv.xy, vec2(a, b)), sn = mod(dt, PI);\n  return fract(sin(sn) * c);\n}\n\nvoid main(void) {\n  const int maxSteps = 1024;\n\n  // the ray\n  vec3 rayOrigin = cameraPosition;\n  vec3 rayDirection = normalize(vPos.xyz - rayOrigin);\n\n  vec3 lightOrigin = uLightPositionInCamera == 1 ? cameraPosition : uLightPosition;\n\n  // vec3 lightOrigin = cameraPosition;\n  // the Axe-Aligned B-Box\n  vec3 AABBMin = vec3(uWorldBBox[0], uWorldBBox[2], uWorldBBox[4]);\n  vec3 AABBMax = vec3(uWorldBBox[1], uWorldBBox[3], uWorldBBox[5]);\n\n  // Intersection ray/bbox\n  float tNear, tFar;\n  bool intersect = false;\n  "+le.api(this,"rayOrigin","rayDirection","AABBMin","AABBMax","tNear","tFar","intersect")+'\n  if (tNear < 0.0) tNear = 0.0;\n\n  // x / y should be within o-1\n  // should\n  float offset = rand(gl_FragCoord.xy);\n\n  // init the ray marching\n  float tStep = (tFar - tNear) / float(uSteps);\n  float tCurrent = tNear + offset * tStep;\n  vec4 accumulatedColor = vec4(0.0);\n  float accumulatedAlpha = 0.0;\n\n  // MIP volume rendering\n  float maxIntensity = 0.0;\n\n  mat4 dataToWorld = inverse(uWorldToData);\n\n  // rayOrigin -= rayDirection * 0.1; // gold_noise(vPos.xz, vPos.y) / 100.;\n\n  for(int rayStep = 0; rayStep < maxSteps; rayStep++){\n    vec3 currentPosition = rayOrigin + rayDirection * tCurrent;\n    // some non-linear FUN\n    // some occlusion issue to be fixed\n    vec3 transformedPosition = currentPosition; //transformPoint(currentPosition, uAmplitude, uFrequence);\n    // world to data coordinates\n    // rounding trick\n    // first center of first voxel in data space is CENTERED on (0,0,0)\n    vec4 dataCoordinatesRaw = uWorldToData * vec4(transformedPosition, 1.0);\n    vec3 currentVoxel = vec3(dataCoordinatesRaw.x, dataCoordinatesRaw.y, dataCoordinatesRaw.z);\n    float intensity = 0.0;\n    vec3 gradient = vec3(0., 0., 0.);\n    getIntensity(currentVoxel, intensity, gradient);\n    // map gradient to world space and normalize before using\n    // we avoid to call "normalize" as it may be undefined if vector length == 0.\n    gradient = (vec3(dataToWorld * vec4(gradient, 0.)));\n    if (length(gradient) > 0.0) {\n      gradient = normalize(gradient);\n    }\n\n    vec4 colorSample;\n    float alphaSample;\n    if(uLut == 1){\n      vec4 colorFromLUT = texture2D( uTextureLUT, vec2( intensity, 1.0) );\n      // 256 colors\n      colorSample = colorFromLUT;\n      alphaSample = colorFromLUT.a;\n    }\n    else{\n      alphaSample = intensity;\n      colorSample.r = colorSample.g = colorSample.b = intensity;\n    }\n\n    // ray marching algorithm\n    // shading on\n    // interpolation on\n    if (uAlgorithm == 0 && uShading == 1 && uInterpolation != 0) {\n      //  && alphaSample > .3\n      vec3 ambientComponent = uSampleColorToAmbient == 1 ? colorSample.xyz : uAmbientColor;\n      ambientComponent *= uAmbient;\n      vec3 diffuseComponent = uSampleColorToDiffuse == 1 ? colorSample.xyz : uDiffuseColor;\n      diffuseComponent *= uDiffuse;\n      vec3 specularComponent = uSpecular * uSpecularColor;\n      float shininess = uShininess;\n      vec3 vIntensity = uIntensity;\n\n      colorSample.xyz += phongShading(\n        ambientComponent,\n        diffuseComponent,\n        specularComponent,\n        shininess,\n        currentPosition.xyz,\n        rayOrigin.xyz,\n        lightOrigin.xyz,\n        vIntensity,\n        gradient);\n    }\n\n    alphaSample = 1.0 - pow((1.0- alphaSample),tStep*uAlphaCorrection);\n    alphaSample *= (1.0 - accumulatedAlpha);\n\n    accumulatedColor += alphaSample * colorSample;\n    accumulatedAlpha += alphaSample;\n\n    tCurrent += tStep;\n\n    if (tCurrent > tFar || (uAlgorithm == 0 && accumulatedAlpha >= 1.0)) break;\n\n    if (uAlgorithm == 1 && (intensity >= maxIntensity)) {\n      maxIntensity = intensity;\n      accumulatedColor = colorSample;\n      accumulatedAlpha = 1.;\n    }\n  }\n\n  gl_FragColor = vec4(accumulatedColor.xyz, accumulatedAlpha);\n  // gl_FragColor = gl_Color;\n}\n   '},e.prototype.compute=function(){return"\n// uniforms\n"+this.uniforms()+"\n\n// varying (should fetch it from vertex directly)\nvarying vec4      vPos;\n\n// tailored functions\n"+this.functions()+"\n\n// main loop\n"+this._main+"\n      "},e}(),he=function(e){function t(t){var n=e.call(this)||this;return n._textures=[],n._shadersFragment=pe,n._shadersVertex=ie,n._uniforms=ne.uniforms(),n._material=null,n._geometry=null,n._mesh=null,n._algorithm=0,n._alphaCorrection=.5,n._interpolation=1,n._shading=1,n._shininess=10,n._steps=256,n._offset=0,n._windowCenter=0,n._windowWidth=1,n._stack=t,n._textures=[],n._shadersFragment=pe,n._shadersVertex=ie,n._uniforms=ne.uniforms(),n._material=null,n._geometry=null,n._mesh=null,n._algorithm=0,n._alphaCorrection=.5,n._interpolation=1,n._shading=1,n._shininess=10,n._steps=256,n._offset=0,n._windowCenter=0,n._windowWidth=1,n._create(),n}return d(t,e),t.prototype._create=function(){this._prepareStack(),this._prepareTexture(),this._prepareMaterial(),this._prepareGeometry(),this._mesh=new o.Mesh(this._geometry,this._material),this.add(this._mesh)},t.prototype._prepareStack=function(){this._stack.prepared||this._stack.prepare(),this._stack.packed||this._stack.pack(),this._offset=Math.min(0,this._stack._minMax[0]),this._windowCenter=this._stack.windowCenter,this._windowWidth=.8*this._stack.windowWidth},t.prototype._prepareMaterial=function(){this._uniforms=ne.uniforms(),this._uniforms.uWorldBBox.value=this._stack.worldBoundingBox(),this._uniforms.uTextureSize.value=this._stack.textureSize,this._uniforms.uTextureContainer.value=this._textures,this._stack.textureUnits>8&&(this._uniforms.uTextureContainer.length=14),this._uniforms.uWorldToData.value=this._stack.lps2IJK,this._uniforms.uNumberOfChannels.value=this._stack.numberOfChannels,this._uniforms.uPixelType.value=this._stack.pixelType,this._uniforms.uBitsAllocated.value=this._stack.bitsAllocated,this._uniforms.uPackedPerPixel.value=this._stack.packedPerPixel,this._uniforms.uWindowCenterWidth.value=[this._windowCenter-this._offset,this._windowWidth],this._uniforms.uRescaleSlopeIntercept.value=[this._stack.rescaleSlope,this._stack.rescaleIntercept],this._uniforms.uDataDimensions.value=[this._stack.dimensionsIJK.x,this._stack.dimensionsIJK.y,this._stack.dimensionsIJK.z],this._uniforms.uAlphaCorrection.value=this._alphaCorrection,this._uniforms.uInterpolation.value=this._interpolation,this._uniforms.uShading.value=this._shading,this._uniforms.uShininess.value=this._shininess,this._uniforms.uSteps.value=this._steps,this._uniforms.uAlgorithm.value=this._algorithm,this._createMaterial({side:o.DoubleSide,transparent:!0})},t.prototype._prepareGeometry=function(){var e=this._stack.worldBoundingBox(),t=this._stack.worldCenter();this._geometry=new o.BoxGeometry(e[1]-e[0],e[3]-e[2],e[5]-e[4]),this._geometry.applyMatrix((new o.Matrix4).makeTranslation(t.x,t.y,t.z))},Object.defineProperty(t.prototype,"uniforms",{get:function(){return this._uniforms},set:function(e){this._uniforms=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stack",{get:function(){return this._stack},set:function(e){this._stack=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowCenter",{get:function(){return this._windowCenter},set:function(e){this._windowCenter=e,this._uniforms.uWindowCenterWidth.value[0]=this._windowCenter-this._offset},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowWidth",{get:function(){return this._windowWidth},set:function(e){this._windowWidth=Math.max(1,e),this._uniforms.uWindowCenterWidth.value[1]=this._windowWidth},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"steps",{get:function(){return this._steps},set:function(e){this._steps=e,this._uniforms.uSteps.value=this._steps},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaCorrection",{get:function(){return this._alphaCorrection},set:function(e){this._alphaCorrection=e,this._uniforms.uAlphaCorrection.value=this._alphaCorrection},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"interpolation",{get:function(){return this._interpolation},set:function(e){this._interpolation=e,this._uniforms.uInterpolation.value=this._interpolation,this._updateMaterial()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shading",{get:function(){return this._shading},set:function(e){this._shading=e,this._uniforms.uShading.value=this._shading},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shininess",{get:function(){return this._shininess},set:function(e){this._shininess=e,this._uniforms.uShininess.value=this._shininess},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"algorithm",{get:function(){return this._algorithm},set:function(e){this._algorithm=e,this._uniforms.uAlgorithm.value=this._algorithm},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){for(var e=0;e<this._textures.length;e++)this._textures[e].dispose(),this._textures[e]=null;this._textures=null,this._shadersFragment=null,this._shadersVertex=null,this._uniforms.uTextureContainer=null,this._uniforms.uTextureLUT=null,this._uniforms=null,this.remove(this._mesh),this._mesh.geometry.dispose(),this._mesh.geometry=null,this._mesh.material.dispose(),this._mesh.material=null,this._mesh=null,this._geometry.dispose(),this._geometry=null,this._material.vertexShader=null,this._material.fragmentShader=null,this._material.uniforms=null,this._material.dispose(),this._material=null,this._stack=null},t.prototype._createMaterial=function(e){var t=new pe(this._uniforms),n=new ie,i={uniforms:this._uniforms,vertexShader:n.compute(),fragmentShader:t.compute()},r=Object.assign(e,i);this._material=new o.ShaderMaterial(r),this._material.needsUpdate=!0},t.prototype._updateMaterial=function(){var e=new pe(this._uniforms),t=new ie;this._material.vertexShader=t.compute(),this._material.fragmentShader=e.compute(),this._material.needsUpdate=!0},t.prototype._prepareTexture=function(){this._textures=[];for(var e=0;e<this._stack.rawData.length;e++){var t=new o.DataTexture(this._stack.rawData[e],this._stack.textureSize,this._stack.textureSize,this._stack.textureType,o.UnsignedByteType,o.UVMapping,o.ClampToEdgeWrapping,o.ClampToEdgeWrapping,o.NearestFilter,o.NearestFilter);t.needsUpdate=!0,t.flipY=!0,this._textures.push(t)}},t}(o.Object3D),de=function(){function e(e,n){this.sceneService=e,this.rendererService=n,this.changeSubject=new i.Subject,this.changed$=this.changeSubject.pipe(r.mapTo(this.entity)),this._model=this.defaultModel(),this.changed=new t.EventEmitter}return Object.defineProperty(e.prototype,"model",{get:function(){return this._model},set:function(e){if(e!==undefined){if(this.entity===undefined){if(this.entity=this.createEntity(this.model),this.sceneService.add(this.entity),this.rendererService.render(),this.entity===undefined)throw Error("Can not update undefined entity");this.updateEntity(e,this.entity),this.rendererService.render()}else{if(this.entity===undefined)throw Error("Can not update undefined entity");this.updateEntity(e,this.entity),this.rendererService.render()}this.changed.emit(this.model)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{get:function(){return this.entity},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.entity!==undefined&&(this.sceneService.remove(this.entity),this.rendererService.render()),this.changeSubject.complete()},e.prototype.canvasReady=function(){},e.prototype.ngOnInit=function(){},e.prototype.ngAfterViewInit=function(){},e.propDecorators={changed:[{type:t.Output}],model:[{type:t.Input}]},e}(),fe=function(){function e(){}return e.matrix4=function(e){return!(null==e||!e.hasOwnProperty("elements")||16!==e.elements.length||"function"!=typeof e.identity||"function"!=typeof e.copy||"function"!=typeof e.determinant)},e.vector3=function(e){return!(!(null!=e&&e.hasOwnProperty("x")&&e.hasOwnProperty("y")&&e.hasOwnProperty("z"))||e.hasOwnProperty("w"))},e.box=function(e){return!!(null!=e&&e.hasOwnProperty("center")&&this.vector3(e.center)&&e.hasOwnProperty("halfDimensions")&&this.vector3(e.halfDimensions)&&e.halfDimensions.x>=0&&e.halfDimensions.y>=0&&e.halfDimensions.z>=0)},e.ray=function(e){return!!(null!=e&&e.hasOwnProperty("position")&&this.vector3(e.position)&&e.hasOwnProperty("direction")&&this.vector3(e.direction))},e}(),me=function(){function e(){}return e.bbox=function(e,t){return fe.vector3(e)&&fe.vector3(t)?t.x>=0&&t.y>=0&&t.z>=0?{min:e.clone().sub(t),max:e.clone().add(t)}:(window.console.log("halfDimensions must be >= 0."),window.console.log(t),!1):(console.log("Invalid center or plane halfDimensions."),!1)},e.minMax=function(e){void 0===e&&(e=[]);for(var t=[65535,-32768],n=e.length,i=0;i<n;i++){var o=e[i];t[0]=Math.min(t[0],o),t[1]=Math.max(t[1],o)}return t},e.isElement=function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},e.isString=function(e){return"string"==typeof e||e instanceof String},e.parseUrl=function(e){var t=new URL(e,"http://fix.me"),n={filename:t.searchParams.get("filename"),extension:"",pathname:t.pathname,query:t.search};n.filename||(n.filename=n.pathname.split("/").pop());var i=n.filename.split(".");n.extension=i.length>1?i.pop():"dicom";return(-1!==["asp","aspx","go","gs","hs","jsp","js","php","pl","py","rb","htm","html"].indexOf(n.extension)||n.query&&n.query.includes("contentType=application%2Fdicom"))&&(n.extension="dicom"),n},e.ijk2LPS=function(e,t,n,i,r,a){void 0===a&&(a=new o.Matrix4);var s=new o.Matrix4;return s.set(e.x*i.y,t.x*i.x,n.x*i.z,r.x,e.y*i.y,t.y*i.x,n.y*i.z,r.y,e.z*i.y,t.z*i.x,n.z*i.z,r.z,0,0,0,1),s.premultiply(a),s},e.aabb2LPS=function(e,t,n,i){var r=new o.Matrix4;return r.set(e.x,t.x,n.x,i.x,e.y,t.y,n.y,i.y,e.z,t.z,n.z,i.z,0,0,0,1),r},e.worldToData=function(e,t){var n=(new o.Vector3).copy(t).applyMatrix4(e);return n.addScalar(.5).floor(),n},e.value=function(e,t){window.console.warn("value is deprecated, please use getPixelData instead"),this.getPixelData(e,t)},e.getPixelData=function(e,t){return t.z>=0&&t.z<e._frame.length?e._frame[t.z].getPixelData(t.x,t.y):null},e.setPixelData=function(e,t,n){if(!(t.z>=0&&t.z<e._frame.length))return null;e._frame[t.z].setPixelData(t.x,t.y,n)},e.rescaleSlopeIntercept=function(e,t,n){return e*t+n},e.centerOfMass=function(e){for(var t=new o.Vector3(0,0,0),n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y,t.z+=e[n].z;return t.divideScalar(e.length),t},e.getRoI=function(t,n,i){var r,a;t.geometry.computeBoundingBox();var s=(new o.Box3).setFromObject(t),c=s.min.clone().project(n),u=s.max.clone().project(n),l=n.controls.domElement.offsetWidth,p=n.controls.domElement.offsetHeight,h=new o.Raycaster,d=[];c.x=Math.round((c.x+1)*l/2),c.y=Math.round((1-c.y)*p/2),u.x=Math.round((u.x+1)*l/2),u.y=Math.round((1-u.y)*p/2),r=m([Math.min(c.x,u.x),Math.max(c.x,u.x)],2),c.x=r[0],u.x=r[1],a=m([Math.min(c.y,u.y),Math.max(c.y,u.y)],2),c.y=a[0],u.y=a[1];for(var f=[],v=null,y=c.x;y<=u.x;y++)for(var g=c.y;g<=u.y;g++)h.setFromCamera({x:y/l*2-1,y:-g/p*2+1},n),0!==(f=h.intersectObject(t)).length&&null!==(v=e.getPixelData(i,e.worldToData(i.lps2IJK,f[0].point)))&&1===i.numberOfChannels&&d.push(e.rescaleSlopeIntercept(v,i.rescaleSlope,i.rescaleIntercept));if(0===d.length)return null;var b=d.reduce(function(e,t){return e+t})/d.length;return{min:d.reduce(function(e,t){return e<t?e:t}),max:d.reduce(function(e,t){return e>t?e:t}),mean:b,sd:Math.sqrt(d.reduce(function(e,t){return e+Math.pow(t-b,2)},0)/d.length)}},e.getGeometryArea=function(e){if(e.faces.length<1)return 0;var t=0,n=e.vertices;return e.faces.forEach(function(e){t+=new o.Triangle(n[e.a],n[e.b],n[e.c]).getArea()}),t},e.stringToNumber=function(e){var t=Number(e);if(t!=t){var n=(e.match(/\./g)||[]).length;if(1===(e.match(/\,/g)||[]).length&&n<2){var i=0===n?".":"",o=e.replace(/,/g,i);t=Number(o)}t!=t&&(console.error("String could not be converted to number ("+e+'). Setting value to "1.0".'),t=1)}return t},e}(),ve=function(e){function t(t,n,i,o,r,a){var s,c;void 0===n&&(n="default"),void 0===i&&(i="linear"),void 0===o&&(o=[[0,0,0,0],[1,1,1,1]]),void 0===r&&(r=[[0,0],[1,1]]),void 0===a&&(a=!1);var u=e.call(this)||this;return me.isString(t)?u._dom=document.getElementById(t):u._dom=t,u._discrete=a,u._color=o,u._lut=n,u._luts=((s={})[n]=o,s),u._opacity=r,u._lutO=i,u._lutsO=((c={})[i]=r,c),u.initCanvas(),u.paintCanvas(),u}return d(t,e),t.prototype.initCanvas=function(){this._canvasContainer=this.initCanvasContainer(this._dom),this._canvasBg=this.createCanvas(),this._canvasContainer.appendChild(this._canvasBg),this._canvas=this.createCanvas(),this._canvasContainer.appendChild(this._canvas)},t.prototype.initCanvasContainer=function(e){var t=e;return t.style.border="1px solid #F9F9F9",t},t.prototype.createCanvas=function(){var e=document.createElement("canvas");return e.height=1,e.width=256,e.style.width="256px",e.style.height="16px",e},t.prototype.paintCanvas=function(){var e=this._canvas.getContext("2d");if(e.clearRect(0,0,this._canvas.width,this._canvas.height),e.globalCompositeOperation="source-over",this._discrete){e.lineWidth=2*this._canvas.height;for(s=0;s<this._color.length;s++){var t=this._color[s][0],n=1;s<this._color.length-1&&(n=this._color[s+1][0]);var i=0;s>0&&(i=this._color[s-1][0]);var o=i+(t-i)/2,r=t+(n-t)/2;a=this._color[s],c=this._opacity[s]?this._opacity[s][1]:1;e.beginPath(),e.strokeStyle="rgba( "+Math.round(255*a[1])+", "+Math.round(255*a[2])+", "+Math.round(255*a[3])+", "+c+")",e.moveTo(o*this._canvas.width,0),e.lineTo(r*this._canvas.width,0),e.stroke(),e.closePath()}}else{for(var a=e.createLinearGradient(0,0,this._canvas.width,0),s=0;s<this._color.length;s++)a.addColorStop(this._color[s][0],"rgba( "+Math.round(255*this._color[s][1])+", "+Math.round(255*this._color[s][2])+", "+Math.round(255*this._color[s][3])+", 1)");e.fillStyle=a,e.fillRect(0,0,this._canvas.width,this._canvas.height),e.globalCompositeOperation="destination-in";for(var c=e.createLinearGradient(0,0,this._canvas.width,0),s=0;s<this._opacity.length;s++)c.addColorStop(this._opacity[s][0],"rgba(255, 255, 255, "+this._opacity[s][1]+")");e.fillStyle=c,e.fillRect(0,0,this._canvas.width,this._canvas.height)}},Object.defineProperty(t.prototype,"texture",{get:function(){var e=new o.Texture(this._canvas);return e.mapping=o.UVMapping,e.wrapS=e.wrapT=o.ClampToEdgeWrapping,e.magFilter=e.minFilter=o.NearestFilter,e.premultiplyAlpha=!0,e.needsUpdate=!0,e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lut",{get:function(){return this._lut},set:function(e){this._color=this._luts[e],this._lut=e,this.paintCanvas()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"luts",{get:function(){return this._luts},set:function(e){this._luts=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lutO",{get:function(){return this._lutO},set:function(e){this._opacity=this._lutsO[e],this._lutO=e,this.paintCanvas()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lutsO",{get:function(){return this._lutsO},set:function(e){this._lutsO=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"discrete",{get:function(){return this._discrete},set:function(e){this._discrete=e,this.paintCanvas()},enumerable:!0,configurable:!0}),t.prototype.lutsAvailable=function(e){void 0===e&&(e="color");var t=[],n=this._luts;for(var i in"color"!==e&&(n=this._lutsO),n)t.push(i);return t},t.presetLuts=function(){return{"default":[[0,0,0,0],[1,1,1,1]],spectrum:[[0,0,0,0],[.1,0,0,1],[.33,0,1,1],[.5,0,1,0],[.66,1,1,0],[.9,1,0,0],[1,1,1,1]],hot_and_cold:[[0,0,0,1],[.15,0,1,1],[.3,0,1,0],[.45,0,0,0],[.5,0,0,0],[.55,0,0,0],[.7,1,1,0],[.85,1,0,0],[1,1,1,1]],gold:[[0,0,0,0],[.13,.19,.03,0],[.25,.39,.12,0],[.38,.59,.26,0],[.5,.8,.46,.08],[.63,.99,.71,.21],[.75,.99,.88,.34],[.88,.99,.99,.48],[1,.9,.95,.61]],red:[[0,.75,0,0],[.5,1,.5,0],[.95,1,1,0],[1,1,1,1]],green:[[0,0,.75,0],[.5,.5,1,0],[.95,1,1,0],[1,1,1,1]],blue:[[0,0,0,1],[.5,0,.5,1],[.95,0,1,1],[1,1,1,1]],walking_dead:[[0,.1,1,1],[1,1,1,1]],random:[[0,0,0,0],[.27,.18,.18,.18],[.41,1,1,1],[.7,1,0,0],[1,1,1,1]],muscle_bone:[[0,0,0,0],[.00392156862745098,.00784313725490196,0,0],[.00784313725490196,.0196078431372549,0,0],[.011764705882352941,.03137254901960784,0,0],[.01568627450980392,.0392156862745098,0,.00392156862745098],[.0196078431372549,.050980392156862744,.00392156862745098,.00392156862745098],[.023529411764705882,.06274509803921569,.00392156862745098,.00392156862745098],[.027450980392156862,.07058823529411765,.00392156862745098,.00784313725490196],[.03137254901960784,.08235294117647059,.00392156862745098,.00784313725490196],[.03529411764705882,.09411764705882353,.00784313725490196,.00784313725490196],[.0392156862745098,.10196078431372549,.00784313725490196,.00784313725490196],[.043137254901960784,.11372549019607843,.00784313725490196,.011764705882352941],[.047058823529411764,.12549019607843137,.00784313725490196,.011764705882352941],[.050980392156862744,.13333333333333333,.011764705882352941,.011764705882352941],[.054901960784313725,.1450980392156863,.011764705882352941,.01568627450980392],[.058823529411764705,.1568627450980392,.011764705882352941,.01568627450980392],[.06274509803921569,.16470588235294117,.011764705882352941,.01568627450980392],[.06666666666666667,.17647058823529413,.011764705882352941,.0196078431372549],[.07058823529411765,.18823529411764706,.01568627450980392,.0196078431372549],[.07450980392156863,.2,.01568627450980392,.0196078431372549],[.0784313725490196,.20784313725490197,.01568627450980392,.0196078431372549],[.08235294117647059,.2196078431372549,.01568627450980392,.023529411764705882],[.08627450980392157,.23137254901960785,.0196078431372549,.023529411764705882],[.09019607843137255,.23921568627450981,.0196078431372549,.023529411764705882],[.09411764705882353,.25098039215686274,.0196078431372549,.027450980392156862],[.09803921568627451,.2627450980392157,.0196078431372549,.027450980392156862],[.10196078431372549,.27058823529411763,.023529411764705882,.027450980392156862],[.10588235294117647,.2823529411764706,.023529411764705882,.027450980392156862],[.10980392156862745,.29411764705882354,.023529411764705882,.03137254901960784],[.11372549019607843,.30196078431372547,.023529411764705882,.03137254901960784],[.11764705882352941,.3137254901960784,.023529411764705882,.03137254901960784],[.12156862745098039,.3254901960784314,.027450980392156862,.03529411764705882],[.12549019607843137,.3333333333333333,.027450980392156862,.03529411764705882],[.12941176470588237,.34509803921568627,.027450980392156862,.03529411764705882],[.13333333333333333,.3568627450980392,.027450980392156862,.0392156862745098],[.13725490196078433,.36470588235294116,.03137254901960784,.0392156862745098],[.1411764705882353,.3764705882352941,.03137254901960784,.0392156862745098],[.1450980392156863,.38823529411764707,.03137254901960784,.0392156862745098],[.14901960784313725,.4,.03137254901960784,.043137254901960784],[.15294117647058825,.40784313725490196,.03529411764705882,.043137254901960784],[.1568627450980392,.4196078431372549,.03529411764705882,.043137254901960784],[.1607843137254902,.43137254901960786,.03529411764705882,.047058823529411764],[.16470588235294117,.4392156862745098,.03529411764705882,.047058823529411764],[.16862745098039217,.45098039215686275,.03529411764705882,.047058823529411764],[.17254901960784313,.4627450980392157,.0392156862745098,.047058823529411764],[.17647058823529413,.47058823529411764,.0392156862745098,.050980392156862744],[.1803921568627451,.4823529411764706,.0392156862745098,.050980392156862744],[.1843137254901961,.49411764705882355,.0392156862745098,.050980392156862744],[.18823529411764706,.5019607843137255,.043137254901960784,.054901960784313725],[.19215686274509805,.5137254901960784,.043137254901960784,.054901960784313725],[.19607843137254902,.5254901960784314,.043137254901960784,.054901960784313725],[.2,.5333333333333333,.043137254901960784,.058823529411764705],[.20392156862745098,.5450980392156862,.047058823529411764,.058823529411764705],[.20784313725490197,.5568627450980392,.047058823529411764,.058823529411764705],[.21176470588235294,.5647058823529412,.047058823529411764,.058823529411764705],[.21568627450980393,.5764705882352941,.047058823529411764,.06274509803921569],[.2196078431372549,.5882352941176471,.047058823529411764,.06274509803921569],[.2235294117647059,.6,.050980392156862744,.06274509803921569],[.22745098039215686,.6078431372549019,.050980392156862744,.06666666666666667],[.23137254901960785,.6196078431372549,.050980392156862744,.06666666666666667],[.23529411764705882,.6313725490196078,.050980392156862744,.06666666666666667],[.23921568627450981,.6392156862745098,.054901960784313725,.06666666666666667],[.24313725490196078,.6509803921568628,.054901960784313725,.07058823529411765],[.24705882352941178,.6627450980392157,.054901960784313725,.07058823529411765],[.25098039215686274,.6705882352941176,.054901960784313725,.07058823529411765],[.2549019607843137,.6823529411764706,.058823529411764705,.07450980392156863],[.25882352941176473,.6941176470588235,.058823529411764705,.07450980392156863],[.2627450980392157,.7019607843137254,.058823529411764705,.07450980392156863],[.26666666666666666,.7137254901960784,.058823529411764705,.0784313725490196],[.27058823529411763,.7254901960784313,.058823529411764705,.0784313725490196],[.27450980392156865,.7333333333333333,.06274509803921569,.0784313725490196],[.2784313725490196,.7450980392156863,.06274509803921569,.0784313725490196],[.2823529411764706,.7568627450980392,.06274509803921569,.08235294117647059],[.28627450980392155,.7647058823529411,.06274509803921569,.08235294117647059],[.2901960784313726,.7764705882352941,.06666666666666667,.08235294117647059],[.29411764705882354,.788235294117647,.06666666666666667,.08627450980392157],[.2980392156862745,.8,.06666666666666667,.08627450980392157],[.30196078431372547,.807843137254902,.06666666666666667,.08627450980392157],[.3058823529411765,.8196078431372549,.07058823529411765,.08627450980392157],[.30980392156862746,.8313725490196079,.07058823529411765,.09019607843137255],[.3137254901960784,.8392156862745098,.07058823529411765,.09019607843137255],[.3176470588235294,.8509803921568627,.07058823529411765,.09019607843137255],[.3215686274509804,.8627450980392157,.07058823529411765,.09411764705882353],[.3254901960784314,.8705882352941177,.07450980392156863,.09411764705882353],[.32941176470588235,.8823529411764706,.07450980392156863,.09411764705882353],[.3333333333333333,.8941176470588236,.07450980392156863,.09803921568627451],[.33725490196078434,.9019607843137255,.07450980392156863,.09803921568627451],[.3411764705882353,.9137254901960784,.0784313725490196,.09803921568627451],[.34509803921568627,.9254901960784314,.0784313725490196,.09803921568627451],[.34901960784313724,.9333333333333333,.0784313725490196,.10196078431372549],[.35294117647058826,.9450980392156862,.0784313725490196,.10196078431372549],[.3568627450980392,.9568627450980393,.08235294117647059,.10196078431372549],[.3607843137254902,.9647058823529412,.08235294117647059,.10588235294117647],[.36470588235294116,.9764705882352941,.08235294117647059,.10588235294117647],[.3686274509803922,.9882352941176471,.08235294117647059,.10588235294117647],[.37254901960784315,1,.08235294117647059,.10588235294117647],[.3764705882352941,1,.09411764705882353,.10588235294117647],[.3803921568627451,1,.10588235294117647,.10588235294117647],[.3843137254901961,1,.11764705882352941,.10196078431372549],[.38823529411764707,1,.12941176470588237,.10196078431372549],[.39215686274509803,1,.1411764705882353,.10196078431372549],[.396078431372549,1,.15294117647058825,.09803921568627451],[.4,1,.16470588235294117,.09803921568627451],[.403921568627451,1,.17647058823529413,.09803921568627451],[.40784313725490196,1,.18823529411764706,.09411764705882353],[.4117647058823529,1,.2,.09411764705882353],[.41568627450980394,1,.21176470588235294,.09411764705882353],[.4196078431372549,1,.2235294117647059,.09019607843137255],[.4235294117647059,1,.23529411764705882,.09019607843137255],[.42745098039215684,1,.24705882352941178,.08627450980392157],[.43137254901960786,1,.25882352941176473,.08627450980392157],[.43529411764705883,1,.27058823529411763,.08627450980392157],[.4392156862745098,1,.2823529411764706,.08235294117647059],[.44313725490196076,1,.29411764705882354,.08235294117647059],[.4470588235294118,1,.3058823529411765,.08235294117647059],[.45098039215686275,1,.3176470588235294,.0784313725490196],[.4549019607843137,1,.32941176470588235,.0784313725490196],[.4588235294117647,1,.3411764705882353,.0784313725490196],[.4627450980392157,1,.35294117647058826,.07450980392156863],[.4666666666666667,1,.36470588235294116,.07450980392156863],[.47058823529411764,1,.3764705882352941,.07450980392156863],[.4745098039215686,1,.38823529411764707,.07058823529411765],[.47843137254901963,1,.4,.07058823529411765],[.4823529411764706,1,.4117647058823529,.07058823529411765],[.48627450980392156,1,.4235294117647059,.06666666666666667],[.49019607843137253,1,.43529411764705883,.06666666666666667],[.49411764705882355,1,.4470588235294118,.06274509803921569],[.4980392156862745,1,.4588235294117647,.06274509803921569],[.5019607843137255,1,.47058823529411764,.06274509803921569],[.5058823529411764,1,.4823529411764706,.058823529411764705],[.5098039215686274,1,.49411764705882355,.058823529411764705],[.5137254901960784,1,.5058823529411764,.058823529411764705],[.5176470588235295,1,.5137254901960784,.054901960784313725],[.5215686274509804,1,.5254901960784314,.054901960784313725],[.5254901960784314,1,.5372549019607843,.054901960784313725],[.5294117647058824,1,.5490196078431373,.050980392156862744],[.5333333333333333,1,.5607843137254902,.050980392156862744],[.5372549019607843,1,.5725490196078431,.050980392156862744],[.5411764705882353,1,.5843137254901961,.047058823529411764],[.5450980392156862,1,.596078431372549,.047058823529411764],[.5490196078431373,1,.6078431372549019,.043137254901960784],[.5529411764705883,1,.6196078431372549,.043137254901960784],[.5568627450980392,1,.6313725490196078,.043137254901960784],[.5607843137254902,1,.6431372549019608,.0392156862745098],[.5647058823529412,1,.6549019607843137,.0392156862745098],[.5686274509803921,1,.6666666666666666,.0392156862745098],[.5725490196078431,1,.6784313725490196,.03529411764705882],[.5764705882352941,1,.6901960784313725,.03529411764705882],[.5803921568627451,1,.6941176470588235,.0392156862745098],[.5843137254901961,1,.7019607843137254,.0392156862745098],[.5882352941176471,1,.7058823529411765,.043137254901960784],[.592156862745098,1,.7098039215686275,.043137254901960784],[.596078431372549,1,.7137254901960784,.047058823529411764],[.6,1,.7176470588235294,.047058823529411764],[.6039215686274509,1,.7254901960784313,.050980392156862744],[.6078431372549019,1,.7294117647058823,.050980392156862744],[.611764705882353,1,.7333333333333333,.054901960784313725],[.615686274509804,1,.7372549019607844,.058823529411764705],[.6196078431372549,1,.7411764705882353,.058823529411764705],[.6235294117647059,1,.7490196078431373,.06274509803921569],[.6274509803921569,1,.7529411764705882,.06274509803921569],[.6313725490196078,1,.7568627450980392,.06666666666666667],[.6352941176470588,1,.7607843137254902,.06666666666666667],[.6392156862745098,1,.7647058823529411,.07058823529411765],[.6431372549019608,1,.7725490196078432,.07058823529411765],[.6470588235294118,1,.7764705882352941,.07450980392156863],[.6509803921568628,1,.7803921568627451,.07450980392156863],[.6549019607843137,1,.7843137254901961,.0784313725490196],[.6588235294117647,1,.788235294117647,.08235294117647059],[.6627450980392157,1,.796078431372549,.08235294117647059],[.6666666666666666,1,.8,.08627450980392157],[.6705882352941176,1,.803921568627451,.08627450980392157],[.6745098039215687,1,.807843137254902,.09019607843137255],[.6784313725490196,1,.8117647058823529,.09019607843137255],[.6823529411764706,1,.8196078431372549,.09411764705882353],[.6862745098039216,1,.8235294117647058,.09411764705882353],[.6901960784313725,1,.8274509803921568,.09803921568627451],[.6941176470588235,1,.8313725490196079,.10196078431372549],[.6980392156862745,1,.8352941176470589,.10196078431372549],[.7019607843137254,1,.8431372549019608,.10588235294117647],[.7058823529411765,1,.8470588235294118,.10588235294117647],[.7098039215686275,1,.8509803921568627,.10980392156862745],[.7137254901960784,1,.8549019607843137,.10980392156862745],[.7176470588235294,1,.8627450980392157,.11372549019607843],[.7215686274509804,1,.8666666666666667,.11372549019607843],[.7254901960784313,1,.8705882352941177,.11764705882352941],[.7294117647058823,1,.8745098039215686,.12156862745098039],[.7333333333333333,1,.8784313725490196,.12156862745098039],[.7372549019607844,1,.8862745098039215,.12549019607843137],[.7411764705882353,1,.8901960784313725,.12549019607843137],[.7450980392156863,1,.8941176470588236,.12941176470588237],[.7490196078431373,1,.8980392156862745,.12941176470588237],[.7529411764705882,1,.9019607843137255,.13333333333333333],[.7568627450980392,1,.9098039215686274,.13333333333333333],[.7607843137254902,1,.9137254901960784,.13725490196078433],[.7647058823529411,1,.9176470588235294,.1411764705882353],[.7686274509803922,1,.9215686274509803,.1411764705882353],[.7725490196078432,1,.9254901960784314,.1450980392156863],[.7764705882352941,1,.9333333333333333,.1450980392156863],[.7803921568627451,1,.9372549019607843,.14901960784313725],[.7843137254901961,1,.9411764705882353,.14901960784313725],[.788235294117647,1,.9450980392156862,.15294117647058825],[.792156862745098,1,.9450980392156862,.16862745098039217],[.796078431372549,1,.9490196078431372,.1843137254901961],[.8,1,.9490196078431372,.2],[.803921568627451,1,.9490196078431372,.21568627450980393],[.807843137254902,1,.9490196078431372,.22745098039215686],[.8117647058823529,1,.9529411764705882,.24313725490196078],[.8156862745098039,1,.9529411764705882,.25882352941176473],[.8196078431372549,1,.9529411764705882,.27450980392156865],[.8235294117647058,1,.9529411764705882,.2901960784313726],[.8274509803921568,1,.9568627450980393,.3058823529411765],[.8313725490196079,1,.9568627450980393,.3215686274509804],[.8352941176470589,1,.9568627450980393,.33725490196078434],[.8392156862745098,1,.9568627450980393,.35294117647058826],[.8431372549019608,1,.9607843137254902,.3686274509803922],[.8470588235294118,1,.9607843137254902,.3843137254901961],[.8509803921568627,1,.9607843137254902,.4],[.8549019607843137,1,.9607843137254902,.4117647058823529],[.8588235294117647,1,.9647058823529412,.42745098039215684],[.8627450980392157,1,.9647058823529412,.44313725490196076],[.8666666666666667,1,.9647058823529412,.4588235294117647],[.8705882352941177,1,.9647058823529412,.4745098039215686],[.8745098039215686,1,.9686274509803922,.49019607843137253],[.8784313725490196,1,.9686274509803922,.5058823529411764],[.8823529411764706,1,.9686274509803922,.5215686274509804],[.8862745098039215,1,.9686274509803922,.5372549019607843],[.8901960784313725,1,.9725490196078431,.5529411764705883],[.8941176470588236,1,.9725490196078431,.5686274509803921],[.8980392156862745,1,.9725490196078431,.5843137254901961],[.9019607843137255,1,.9725490196078431,.6],[.9058823529411765,1,.9725490196078431,.611764705882353],[.9098039215686274,1,.9764705882352941,.6274509803921569],[.9137254901960784,1,.9764705882352941,.6431372549019608],[.9176470588235294,1,.9764705882352941,.6588235294117647],[.9215686274509803,1,.9764705882352941,.6745098039215687],[.9254901960784314,1,.9803921568627451,.6901960784313725],[.9294117647058824,1,.9803921568627451,.7058823529411765],[.9333333333333333,1,.9803921568627451,.7215686274509804],[.9372549019607843,1,.9803921568627451,.7372549019607844],[.9411764705882353,1,.984313725490196,.7529411764705882],[.9450980392156862,1,.984313725490196,.7686274509803922],[.9490196078431372,1,.984313725490196,.7843137254901961],[.9529411764705882,1,.984313725490196,.8],[.9568627450980393,1,.9882352941176471,.8117647058823529],[.9607843137254902,1,.9882352941176471,.8274509803921568],[.9647058823529412,1,.9882352941176471,.8431372549019608],[.9686274509803922,1,.9882352941176471,.8588235294117647],[.9725490196078431,1,.9921568627450981,.8745098039215686],[.9764705882352941,1,.9921568627450981,.8901960784313725],[.9803921568627451,1,.9921568627450981,.9058823529411765],[.984313725490196,1,.9921568627450981,.9215686274509803],[.9882352941176471,1,.996078431372549,.9372549019607843],[.9921568627450981,1,.996078431372549,.9529411764705882],[.996078431372549,1,.996078431372549,.9686274509803922],[1,1,.996078431372549,.984313725490196]]}},t.presetLutsO=function(){return{linear:[[0,0],[1,1]],lowpass:[[0,.8],[.2,.6],[.3,.1],[1,0]],bandpass:[[0,0],[.4,.8],[.6,.8],[1,0]],highpass:[[0,0],[.7,.1],[.8,.6],[1,.8]],flat:[[0,.7],[1,1]],random:[[0,0],[.38,0],[.55,1],[.72,1],[1,.05]],linear_full:[[0,0],[.00392156862745098,.00392156862745098],[.00784313725490196,.00784313725490196],[.011764705882352941,.011764705882352941],[.01568627450980392,.01568627450980392],[.0196078431372549,.0196078431372549],[.023529411764705882,.023529411764705882],[.027450980392156862,.027450980392156862],[.03137254901960784,.03137254901960784],[.03529411764705882,.03529411764705882],[.0392156862745098,.0392156862745098],[.043137254901960784,.043137254901960784],[.047058823529411764,.047058823529411764],[.050980392156862744,.050980392156862744],[.054901960784313725,.054901960784313725],[.058823529411764705,.058823529411764705],[.06274509803921569,.06274509803921569],[.06666666666666667,.06666666666666667],[.07058823529411765,.07058823529411765],[.07450980392156863,.07450980392156863],[.0784313725490196,.0784313725490196],[.08235294117647059,.08235294117647059],[.08627450980392157,.08627450980392157],[.09019607843137255,.09019607843137255],[.09411764705882353,.09411764705882353],[.09803921568627451,.09803921568627451],[.10196078431372549,.10196078431372549],[.10588235294117647,.10588235294117647],[.10980392156862745,.10980392156862745],[.11372549019607843,.11372549019607843],[.11764705882352941,.11764705882352941],[.12156862745098039,.12156862745098039],[.12549019607843137,.12549019607843137],[.12941176470588237,.12941176470588237],[.13333333333333333,.13333333333333333],[.13725490196078433,.13725490196078433],[.1411764705882353,.1411764705882353],[.1450980392156863,.1450980392156863],[.14901960784313725,.14901960784313725],[.15294117647058825,.15294117647058825],[.1568627450980392,.1568627450980392],[.1607843137254902,.1607843137254902],[.16470588235294117,.16470588235294117],[.16862745098039217,.16862745098039217],[.17254901960784313,.17254901960784313],[.17647058823529413,.17647058823529413],[.1803921568627451,.1803921568627451],[.1843137254901961,.1843137254901961],[.18823529411764706,.18823529411764706],[.19215686274509805,.19215686274509805],[.19607843137254902,.19607843137254902],[.2,.2],[.20392156862745098,.20392156862745098],[.20784313725490197,.20784313725490197],[.21176470588235294,.21176470588235294],[.21568627450980393,.21568627450980393],[.2196078431372549,.2196078431372549],[.2235294117647059,.2235294117647059],[.22745098039215686,.22745098039215686],[.23137254901960785,.23137254901960785],[.23529411764705882,.23529411764705882],[.23921568627450981,.23921568627450981],[.24313725490196078,.24313725490196078],[.24705882352941178,.24705882352941178],[.25098039215686274,.25098039215686274],[.2549019607843137,.2549019607843137],[.25882352941176473,.25882352941176473],[.2627450980392157,.2627450980392157],[.26666666666666666,.26666666666666666],[.27058823529411763,.27058823529411763],[.27450980392156865,.27450980392156865],[.2784313725490196,.2784313725490196],[.2823529411764706,.2823529411764706],[.28627450980392155,.28627450980392155],[.2901960784313726,.2901960784313726],[.29411764705882354,.29411764705882354],[.2980392156862745,.2980392156862745],[.30196078431372547,.30196078431372547],[.3058823529411765,.3058823529411765],[.30980392156862746,.30980392156862746],[.3137254901960784,.3137254901960784],[.3176470588235294,.3176470588235294],[.3215686274509804,.3215686274509804],[.3254901960784314,.3254901960784314],[.32941176470588235,.32941176470588235],[.3333333333333333,.3333333333333333],[.33725490196078434,.33725490196078434],[.3411764705882353,.3411764705882353],[.34509803921568627,.34509803921568627],[.34901960784313724,.34901960784313724],[.35294117647058826,.35294117647058826],[.3568627450980392,.3568627450980392],[.3607843137254902,.3607843137254902],[.36470588235294116,.36470588235294116],[.3686274509803922,.3686274509803922],[.37254901960784315,.37254901960784315],[.3764705882352941,.3764705882352941],[.3803921568627451,.3803921568627451],[.3843137254901961,.3843137254901961],[.38823529411764707,.38823529411764707],[.39215686274509803,.39215686274509803],[.396078431372549,.396078431372549],[.4,.4],[.403921568627451,.403921568627451],[.40784313725490196,.40784313725490196],[.4117647058823529,.4117647058823529],[.41568627450980394,.41568627450980394],[.4196078431372549,.4196078431372549],[.4235294117647059,.4235294117647059],[.42745098039215684,.42745098039215684],[.43137254901960786,.43137254901960786],[.43529411764705883,.43529411764705883],[.4392156862745098,.4392156862745098],[.44313725490196076,.44313725490196076],[.4470588235294118,.4470588235294118],[.45098039215686275,.45098039215686275],[.4549019607843137,.4549019607843137],[.4588235294117647,.4588235294117647],[.4627450980392157,.4627450980392157],[.4666666666666667,.4666666666666667],[.47058823529411764,.47058823529411764],[.4745098039215686,.4745098039215686],[.47843137254901963,.47843137254901963],[.4823529411764706,.4823529411764706],[.48627450980392156,.48627450980392156],[.49019607843137253,.49019607843137253],[.49411764705882355,.49411764705882355],[.4980392156862745,.4980392156862745],[.5019607843137255,.5019607843137255],[.5058823529411764,.5058823529411764],[.5098039215686274,.5098039215686274],[.5137254901960784,.5137254901960784],[.5176470588235295,.5176470588235295],[.5215686274509804,.5215686274509804],[.5254901960784314,.5254901960784314],[.5294117647058824,.5294117647058824],[.5333333333333333,.5333333333333333],[.5372549019607843,.5372549019607843],[.5411764705882353,.5411764705882353],[.5450980392156862,.5450980392156862],[.5490196078431373,.5490196078431373],[.5529411764705883,.5529411764705883],[.5568627450980392,.5568627450980392],[.5607843137254902,.5607843137254902],[.5647058823529412,.5647058823529412],[.5686274509803921,.5686274509803921],[.5725490196078431,.5725490196078431],[.5764705882352941,.5764705882352941],[.5803921568627451,.5803921568627451],[.5843137254901961,.5843137254901961],[.5882352941176471,.5882352941176471],[.592156862745098,.592156862745098],[.596078431372549,.596078431372549],[.6,.6],[.6039215686274509,.6039215686274509],[.6078431372549019,.6078431372549019],[.611764705882353,.611764705882353],[.615686274509804,.615686274509804],[.6196078431372549,.6196078431372549],[.6235294117647059,.6235294117647059],[.6274509803921569,.6274509803921569],[.6313725490196078,.6313725490196078],[.6352941176470588,.6352941176470588],[.6392156862745098,.6392156862745098],[.6431372549019608,.6431372549019608],[.6470588235294118,.6470588235294118],[.6509803921568628,.6509803921568628],[.6549019607843137,.6549019607843137],[.6588235294117647,.6588235294117647],[.6627450980392157,.6627450980392157],[.6666666666666666,.6666666666666666],[.6705882352941176,.6705882352941176],[.6745098039215687,.6745098039215687],[.6784313725490196,.6784313725490196],[.6823529411764706,.6823529411764706],[.6862745098039216,.6862745098039216],[.6901960784313725,.6901960784313725],[.6941176470588235,.6941176470588235],[.6980392156862745,.6980392156862745],[.7019607843137254,.7019607843137254],[.7058823529411765,.7058823529411765],[.7098039215686275,.7098039215686275],[.7137254901960784,.7137254901960784],[.7176470588235294,.7176470588235294],[.7215686274509804,.7215686274509804],[.7254901960784313,.7254901960784313],[.7294117647058823,.7294117647058823],[.7333333333333333,.7333333333333333],[.7372549019607844,.7372549019607844],[.7411764705882353,.7411764705882353],[.7450980392156863,.7450980392156863],[.7490196078431373,.7490196078431373],[.7529411764705882,.7529411764705882],[.7568627450980392,.7568627450980392],[.7607843137254902,.7607843137254902],[.7647058823529411,.7647058823529411],[.7686274509803922,.7686274509803922],[.7725490196078432,.7725490196078432],[.7764705882352941,.7764705882352941],[.7803921568627451,.7803921568627451],[.7843137254901961,.7843137254901961],[.788235294117647,.788235294117647],[.792156862745098,.792156862745098],[.796078431372549,.796078431372549],[.8,.8],[.803921568627451,.803921568627451],[.807843137254902,.807843137254902],[.8117647058823529,.8117647058823529],[.8156862745098039,.8156862745098039],[.8196078431372549,.8196078431372549],[.8235294117647058,.8235294117647058],[.8274509803921568,.8274509803921568],[.8313725490196079,.8313725490196079],[.8352941176470589,.8352941176470589],[.8392156862745098,.8392156862745098],[.8431372549019608,.8431372549019608],[.8470588235294118,.8470588235294118],[.8509803921568627,.8509803921568627],[.8549019607843137,.8549019607843137],[.8588235294117647,.8588235294117647],[.8627450980392157,.8627450980392157],[.8666666666666667,.8666666666666667],[.8705882352941177,.8705882352941177],[.8745098039215686,.8745098039215686],[.8784313725490196,.8784313725490196],[.8823529411764706,.8823529411764706],[.8862745098039215,.8862745098039215],[.8901960784313725,.8901960784313725],[.8941176470588236,.8941176470588236],[.8980392156862745,.8980392156862745],[.9019607843137255,.9019607843137255],[.9058823529411765,.9058823529411765],[.9098039215686274,.9098039215686274],[.9137254901960784,.9137254901960784],[.9176470588235294,.9176470588235294],[.9215686274509803,.9215686274509803],[.9254901960784314,.9254901960784314],[.9294117647058824,.9294117647058824],[.9333333333333333,.9333333333333333],[.9372549019607843,.9372549019607843],[.9411764705882353,.9411764705882353],[.9450980392156862,.9450980392156862],[.9490196078431372,.9490196078431372],[.9529411764705882,.9529411764705882],[.9568627450980393,.9568627450980393],[.9607843137254902,.9607843137254902],[.9647058823529412,.9647058823529412],[.9686274509803922,.9686274509803922],[.9725490196078431,.9725490196078431],[.9764705882352941,.9764705882352941],[.9803921568627451,.9803921568627451],[.984313725490196,.984313725490196],[.9882352941176471,.9882352941176471],[.9921568627450981,.9921568627450981],[.996078431372549,.996078431372549],[1,1]]}},t}(o.Object3D),ye=function(){function e(){}return e.cielab2XYZ=function(e,t,n){var i=(e+16)/116,o=t/500+i,r=i-n/200;return i=Math.pow(i,3)>.008856?Math.pow(i,3):(i-16/116)/7.787,[95.047*(o=Math.pow(o,3)>.008856?Math.pow(o,3):(o-16/116)/7.787),100*i,108.883*(r=Math.pow(r,3)>.008856?Math.pow(r,3):(r-16/116)/7.787)]},e.xyz2RGB=function(e,t,n){var i=3.2406*(e/=100)+-1.5372*(t/=100)+-.4986*(n/=100),o=-.9689*e+1.8758*t+.0415*n,r=.0557*e+-.204*t+1.057*n;return i>.0031308?i=1.055*Math.pow(i,1/2.4)-.055:i*=12.92,o>.0031308?o=1.055*Math.pow(o,1/2.4)-.055:o*=12.92,r>.0031308?r=1.055*Math.pow(r,1/2.4)-.055:r*=12.92,[i*=255,o*=255,r*=255]},e.cielab2RGB=function(e,t,n){if(void 0===e&&(e=50),void 0===t&&(t=0),void 0===n&&(n=0),!(e>=0&&e<=100))return null;var i=m(this.cielab2XYZ(e,t,n),3),o=i[0],r=i[1],a=i[2];return this.xyz2RGB(o,r,a)},e}(),ge=function(){function e(){this._id=-1}return e.prototype.mergeModels=function(e,t){if(!this._validateModelArray(e)||!this._validateModelArray(t))return window.console.log("invalid inputs provided."),!1;for(var n=0,i=t.length;n<i;n++)for(var o=0,r=e.length;o<r&&!e[o].merge(t[n]);o++)o===e.length-1&&e.push(t[n]);return!0},e.prototype.merge=function(e){return!!this.validate(e)&&this._id===e._id},e.prototype.validate=function(e){return!(!e||null===e||"function"!=typeof e.merge)},e.prototype._validateModelArray=function(e){if(null===e||Array!==e.constructor)return window.console.log("invalid model array provided."),!1;for(var t=0;t<e.length;t++)if(!e[t]||null===e[t]||"function"!=typeof e[t].validate||!e[t].validate(e[t]))return!1;return!0},e}(),be=function(e){function t(){var t=e.call(this)||this;return t._uid=null,t._stackID=-1,t._frame=[],t._numberOfFrames=0,t._rows=0,t._columns=0,t._numberOfChannels=1,t._bitsAllocated=8,t._pixelType=0,t._pixelRepresentation=0,t._textureSize=4096,t._textureUnits=7,t._textureType=1023,t._rawData=[],t._windowCenter=0,t._windowWidth=0,t._rescaleSlope=1,t._rescaleIntercept=0,t._minMax=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY],t._regMatrix=new o.Matrix4,t._ijk2LPS=null,t._lps2IJK=null,t._aabb2LPS=null,t._lps2AABB=null,t._dimensionsIJK=null,t._halfDimensionsIJK=null,t._spacing=new o.Vector3(1,1,1),t._spacingBetweenSlices=0,t._sliceThickness=0,t._origin=null,t._rightHanded=!0,t._xCosine=new o.Vector3(1,0,0),t._yCosine=new o.Vector3(0,1,0),t._zCosine=new o.Vector3(0,0,1),t._prepared=!1,t._packed=!1,t._packedPerPixel=1,t._modality="Modality not set",t._segmentationType=null,t._segmentationSegments=[],t._segmentationDefaultColor=[63,174,128],t._frameSegment=[],t._segmentationLUT=[],t._segmentationLUTO=[],t._invert=!1,t._uid=null,t._stackID=-1,t._frame=[],t._numberOfFrames=0,t._rows=0,t._columns=0,t._numberOfChannels=1,t._bitsAllocated=8,t._pixelType=0,t._pixelRepresentation=0,t._textureSize=4096,t._textureUnits=7,t._rawData=[],t._windowCenter=0,t._windowWidth=0,t._rescaleSlope=1,t._rescaleIntercept=0,t._minMax=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY],t._regMatrix=new o.Matrix4,t._ijk2LPS=null,t._lps2IJK=null,t._aabb2LPS=null,t._lps2AABB=null,t._dimensionsIJK=null,t._halfDimensionsIJK=null,t._spacing=new o.Vector3(1,1,1),t._spacingBetweenSlices=0,t._sliceThickness=0,t._origin=null,t._rightHanded=!0,t._xCosine=new o.Vector3(1,0,0),t._yCosine=new o.Vector3(0,1,0),t._zCosine=new o.Vector3(0,0,1),t._prepared=!1,t._packed=!1,t._packedPerPixel=1,t._modality="Modality not set",t._segmentationType=null,t._segmentationSegments=[],t._segmentationDefaultColor=[63,174,128],t._frameSegment=[],t._segmentationLUT=[],t._segmentationLUTO=[],t._invert=!1,t}return d(t,e),t.prototype.prepareSegmentation=function(){this._frameSegment=this._frame;var e=[];this.computeCosines(),this._frame.map(this._computeDistanceArrayMap.bind(null,this._zCosine)),this._frame.sort(this._sortDistanceArraySort);for(var t=-1,n=0;n<this._frame.length;n++){if(e[t]&&e[t]._dist==this._frame[n]._dist)for(i=0;i<e[t]._rows*e[t]._columns;i++)e[t]._pixelData[i]+=this._frame[n].pixelData[i]*this._frame[n]._referencedSegmentNumber;else{e.push(this._frame[n]),t++;for(var i=0;i<e[t]._rows*e[t]._columns;i++)e[t]._pixelData[i]*=this._frame[n]._referencedSegmentNumber}e[t].minMax=me.minMax(e[t]._pixelData)}var o={},r=0;for(n=0;n<this._segmentationSegments.length;n++){r=Math.max(r,parseInt(this._segmentationSegments[n].segmentNumber,10));var a=this._segmentationSegments[n].recommendedDisplayCIELab;o[this._segmentationSegments[n].segmentNumber]=null===a?this._segmentationDefaultColor:ye.cielab2RGB.apply(ye,v(a))}for(n=0;n<=r;n++){var s=n/r,c=n?1:0,u=[0,0,0];o.hasOwnProperty(n.toString())&&(u=o[n.toString()]),u[0]/=255,u[1]/=255,u[2]/=255,this._segmentationLUT.push(v([s],u)),this._segmentationLUTO.push([s,c])}this._frame=e},t.prototype.prepare=function(){"SEG"===this._modality&&this.prepareSegmentation(),this.computeNumberOfFrames(),this._rows=this._frame[0].rows,this._columns=this._frame[0].columns,this._dimensionsIJK=new o.Vector3(this._columns,this._rows,this._numberOfFrames),this._halfDimensionsIJK=new o.Vector3(this._dimensionsIJK.x/2,this._dimensionsIJK.y/2,this._dimensionsIJK.z/2),this._spacingBetweenSlices=this._frame[0].spacingBetweenSlices,this._sliceThickness=this._frame[0].sliceThickness,this.computeCosines(),this._numberOfFrames>1&&this.orderFrames(),this.computeSpacing(),this._frame[0].imagePosition||(this._frame[0].imagePosition=[0,0,0]),this._frame[0].imageOrientation||(this._frame[0].imageOrientation=[1,0,0,0,1,0]),this._origin=this._arrayToVector3(this._frame[0].imagePosition,0),this.computeIJK2LPS(),this.computeLPS2AABB();var e=Math.floor(this._frame.length/2),t=this._frame[e];this._rescaleSlope=t.rescaleSlope||1,this._rescaleIntercept=t.rescaleIntercept||0,this.computeMinMaxIntensities(),this._minMax[0]=me.rescaleSlopeIntercept(this._minMax[0],this._rescaleSlope,this._rescaleIntercept),this._minMax[1]=me.rescaleSlopeIntercept(this._minMax[1],this._rescaleSlope,this._rescaleIntercept),this._windowWidth=t.windowWidth||this._minMax[1]-this._minMax[0],this._windowCenter=t.windowCenter||this._minMax[0]+this._windowWidth/2,this._bitsAllocated=t.bitsAllocated,this._prepared=!0},t.prototype.packEchos=function(){for(var e=[],t=0;t<this._frame.length;t+=4){for(var n=this._frame[t],i=0;i<this._rows*this._columns;i++){for(var r=1;r<4;r++)n.pixelData[i]+=this._frame[t+r].pixelData[i];n.pixelData[i]/=4}e.push(n)}this._frame=e,this._numberOfFrames=this._frame.length,this._dimensionsIJK=new o.Vector3(this._columns,this._rows,this._numberOfFrames),this._halfDimensionsIJK=new o.Vector3(this._dimensionsIJK.x/2,this._dimensionsIJK.y/2,this._dimensionsIJK.z/2)},t.prototype.computeNumberOfFrames=function(){if(!(this._frame&&this._frame.length>0))return window.console.warn("_frame doesn't contain anything...."),window.console.warn(this._frame),!1;this._numberOfFrames=this._frame.length},t.prototype.computeCosines=function(){if(this._frame&&this._frame[0]){var e=this._frame[0].cosines();this._xCosine=e[0],this._yCosine=e[1],this._zCosine=e[2]}},t.prototype.orderFrames=function(){this._frame[0].dimensionIndexValues?this._frame.sort(this._orderFrameOnDimensionIndicesArraySort):this._frame[0].imagePosition&&this._frame[0].imageOrientation&&this._frame[1]&&this._frame[1].imagePosition&&this._frame[1].imageOrientation&&this._frame[0].imagePosition.join()!==this._frame[1].imagePosition.join()?(this._frame.map(this._computeDistanceArrayMap.bind(null,this._zCosine)),this._frame.sort(this._sortDistanceArraySort)):null!==this._frame[0].instanceNumber&&this._frame[1]&&null!==this._frame[1].instanceNumber&&this._frame[0].instanceNumber!==this._frame[1].instanceNumber?this._frame.sort(this._sortInstanceNumberArraySort):this._frame[0].sopInstanceUID&&this._frame[1]&&this._frame[1].sopInstanceUID&&this._frame[0].sopInstanceUID!==this._frame[1].sopInstanceUID?this._frame.sort(this._sortSopInstanceUIDArraySort):this._frame[0].imagePosition&&window.console.warn("do not know how to order the frames...")},t.prototype.computeSpacing=function(){this.xySpacing(),this.zSpacing()},t.prototype.zSpacing=function(){this._numberOfFrames>1&&(this._frame[0].pixelSpacing&&this._frame[0].pixelSpacing[2]?this._spacing.z=this._frame[0].pixelSpacing[2]:(this._frame.map(this._computeDistanceArrayMap.bind(null,this._zCosine)),this._frame[1].dist!==this._frame[0].dist?(this._frame.sort(this._sortDistanceArraySort),this._spacing.z=this._frame[1].dist-this._frame[0].dist):this._spacingBetweenSlices?this._spacing.z=this._spacingBetweenSlices:this._frame[0].sliceThickness&&(this._spacing.z=this._frame[0].sliceThickness))),0===this._spacing.z&&(this._spacing.z=1)},t.prototype.xySpacing=function(){if(this._frame&&this._frame[0]){var e=this._frame[0].spacingXY();this._spacing.x=e[0],this._spacing.y=e[1]}},t.prototype.computeMinMaxIntensities=function(){for(var e=0;e<this._frame.length;e++){var t=this._frame[e].minMax[0];Number.isNaN(t)||(this._minMax[0]=Math.min(this._minMax[0],t));var n=this._frame[e].minMax[1];Number.isNaN(n)||(this._minMax[1]=Math.max(this._minMax[1],n))}},t.prototype.computeIJK2LPS=function(){this._ijk2LPS=me.ijk2LPS(this._xCosine,this._yCosine,this._zCosine,this._spacing,this._origin,this._regMatrix),this._lps2IJK=new o.Matrix4,this._lps2IJK.getInverse(this._ijk2LPS)},t.prototype.computeLPS2AABB=function(){this._aabb2LPS=me.aabb2LPS(this._xCosine,this._yCosine,this._zCosine,this._origin),this._lps2AABB=new o.Matrix4,this._lps2AABB.getInverse(this._aabb2LPS)},t.prototype.merge=function(e){return!!(this._stackID===e.stackID&&1===this._numberOfFrames&&1===e._numberOfFrames&&this._frame[0].columns===e.frame[0].columns&&this._frame[0].rows===e.frame[0].rows&&this._xCosine.equals(e.xCosine)&&this._yCosine.equals(e.yCosine)&&this._zCosine.equals(e.zCosine))&&this.mergeModels(this._frame,e.frame)},t.prototype.pack=function(){var e=this._dimensionsIJK.x*this._dimensionsIJK.y*this._dimensionsIJK.z;(8===this._bitsAllocated&&1===this._numberOfChannels||1===this._bitsAllocated)&&(this._packedPerPixel=4),16===this._bitsAllocated&&1===this._numberOfChannels&&(this._packedPerPixel=2);var t=this._textureSize*this._textureSize,n=Math.ceil(e/(t*this._packedPerPixel)),i=0,o=this._packedPerPixel*t;o>e&&(o=e),this._textureUnits<n&&(console.warn("Insufficient number of supported textures. Some frames will not be packed."),n=this._textureUnits);for(var r=0;r<n;r++){var a=this._packTo8Bits(this._numberOfChannels,this._frame,this._textureSize,i,o);this._textureType=a.textureType,this._rawData.push(a.data),i+=this._packedPerPixel*t,(o+=this._packedPerPixel*t)>e&&(o=e)}this._packed=!0},t.prototype._packTo8Bits=function(e,t,n,i,r){var a={textureType:null,data:null},s=t[0].bitsAllocated,c=t[0].pixelType,u=0;this._minMax[0]<0&&(u-=this._minMax[0]);var l=0,p=0,h=0,d=t[0].rows*t[0].columns;if(8===s&&1===e||1===s){for(var f=new Uint8Array(n*n*4),m=0,v=0,y=i;y<r;y++){h=y%d;var g=t[p=~~(y/d)].pixelData[h]+u;Number.isNaN(g)||(f[4*m+v]=g),l++,m=Math.floor(l/4),v=l%4}a.textureType=o.RGBAFormat,a.data=f}else if(16===s&&1===e){for(f=new Uint8Array(n*n*4),m=0,v=0,y=i;y<r;y++){h=y%d;g=t[p=~~(y/d)].pixelData[h]+u;Number.isNaN(g)||(f[4*m+2*v]=255&g,f[4*m+2*v+1]=g>>>8&255),l++,m=Math.floor(l/2),v=l%2}a.textureType=o.RGBAFormat,a.data=f}else if(32===s&&1===e&&0===c){for(f=new Uint8Array(n*n*4),y=i;y<r;y++){h=y%d;g=t[p=~~(y/d)].pixelData[h]+u;Number.isNaN(g)||(f[4*l]=255&g,f[4*l+1]=g>>>8&255,f[4*l+2]=g>>>16&255,f[4*l+3]=g>>>24&255),l++}a.textureType=o.RGBAFormat,a.data=f}else if(32===s&&1===e&&1===c){for(f=new Uint8Array(n*n*4),y=i;y<r;y++){h=y%d;g=t[p=~~(y/d)].pixelData[h]+u;if(!Number.isNaN(g)){var b="01111111110000000000000000000000".match(/.{1,8}/g);f[4*l]=parseInt(b[0],2),f[4*l+1]=parseInt(b[1],2),f[4*l+2]=parseInt(b[2],2),f[4*l+3]=parseInt(b[3],2)}l++}a.textureType=o.RGBAFormat,a.data=f}else if(8===s&&3===e){for(f=new Uint8Array(n*n*3),y=i;y<r;y++)p=~~(y/d),h=y%d,f[3*l]=t[p].pixelData[3*h],f[3*l+1]=t[p].pixelData[3*h+1],f[3*l+2]=t[p].pixelData[3*h+2],l++;a.textureType=o.RGBFormat,a.data=f}return a},t.prototype.worldCenter=function(){return this._halfDimensionsIJK.clone().addScalar(-.5).applyMatrix4(this._ijk2LPS)},t.prototype.worldBoundingBox=function(){for(var e=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY],t=this._dimensionsIJK,n=0;n<=t.x;n+=t.x)for(var i=0;i<=t.y;i+=t.y)for(var r=0;r<=t.z;r+=t.z){var a=new o.Vector3(n,i,r).applyMatrix4(this._ijk2LPS);e=[Math.min(e[0],a.x),Math.max(e[1],a.x),Math.min(e[2],a.y),Math.max(e[3],a.y),Math.min(e[4],a.z),Math.max(e[5],a.z)]}return e},t.prototype.AABBox=function(){var e=(new o.Vector3).addScalar(-.5).applyMatrix4(this._ijk2LPS).applyMatrix4(this._lps2AABB),t=this._dimensionsIJK.clone().addScalar(-.5).applyMatrix4(this._ijk2LPS).applyMatrix4(this._lps2AABB);return new o.Vector3(Math.abs(e.x-t.x),Math.abs(e.y-t.y),Math.abs(e.z-t.z))},t.prototype.centerAABBox=function(){var e=this.worldCenter();return e.applyMatrix4(this._lps2AABB),e},t.indexInDimensions=function(e,t){return e.x>=0&&e.y>=0&&e.z>=0&&e.x<t.x&&e.y<t.y&&e.z<t.z},t.prototype._arrayToVector3=function(e,t){return new o.Vector3(e[t],e[t+1],e[t+2])},t.prototype._orderFrameOnDimensionIndicesArraySort=function(e,t){if("dimensionIndexValues"in e&&"[object Array]"===Object.prototype.toString.call(e.dimensionIndexValues)&&"dimensionIndexValues"in t&&"[object Array]"===Object.prototype.toString.call(t.dimensionIndexValues))for(var n=0;n<e.dimensionIndexValues.length;n++){if(parseInt(e.dimensionIndexValues[n],10)>parseInt(t.dimensionIndexValues[n],10))return 1;if(parseInt(e.dimensionIndexValues[n],10)<parseInt(t.dimensionIndexValues[n],10))return-1}else window.console.warn("One of the frames doesn't have a dimensionIndexValues array."),window.console.warn(e),window.console.warn(t);return 0},t.prototype._computeDistanceArrayMap=function(e,t){return t.imagePosition&&(t.dist=t.imagePosition[0]*e.x+t.imagePosition[1]*e.y+t.imagePosition[2]*e.z),t},t.prototype._sortDistanceArraySort=function(e,t){return e.dist-t.dist},t.prototype._sortInstanceNumberArraySort=function(e,t){return e.instanceNumber-t.instanceNumber},t.prototype._sortSopInstanceUIDArraySort=function(e,t){return e.sopInstanceUID-t.sopInstanceUID},Object.defineProperty(t.prototype,"numberOfChannels",{get:function(){return this._numberOfChannels},set:function(e){this._numberOfChannels=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frame",{get:function(){return this._frame},set:function(e){this._frame=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"prepared",{get:function(){return this._prepared},set:function(e){this._prepared=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"packed",{get:function(){return this._packed},set:function(e){this._packed=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"packedPerPixel",{get:function(){return this._packedPerPixel},set:function(e){this._packedPerPixel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dimensionsIJK",{get:function(){return this._dimensionsIJK},set:function(e){this._dimensionsIJK=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"halfDimensionsIJK",{get:function(){return this._halfDimensionsIJK},set:function(e){this._halfDimensionsIJK=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"regMatrix",{get:function(){return this._regMatrix},set:function(e){this._regMatrix=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ijk2LPS",{get:function(){return this._ijk2LPS},set:function(e){this._ijk2LPS=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lps2IJK",{get:function(){return this._lps2IJK},set:function(e){this._lps2IJK=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lps2AABB",{get:function(){return this._lps2AABB},set:function(e){this._lps2AABB=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureSize",{get:function(){return this._textureSize},set:function(e){this._textureSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureUnits",{get:function(){return this._textureUnits},set:function(e){this._textureUnits=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureType",{get:function(){return this._textureType},set:function(e){this._textureType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bitsAllocated",{get:function(){return this._bitsAllocated},set:function(e){this._bitsAllocated=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rawData",{get:function(){return this._rawData},set:function(e){this._rawData=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowWidth",{get:function(){return this._windowWidth},set:function(e){this._windowWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowCenter",{get:function(){return this._windowCenter},set:function(e){this._windowCenter=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rescaleSlope",{get:function(){return this._rescaleSlope},set:function(e){this._rescaleSlope=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rescaleIntercept",{get:function(){return this._rescaleIntercept},set:function(e){this._rescaleIntercept=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"xCosine",{get:function(){return this._xCosine},set:function(e){this._xCosine=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"yCosine",{get:function(){return this._yCosine},set:function(e){this._yCosine=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zCosine",{get:function(){return this._zCosine},set:function(e){this._zCosine=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minMax",{get:function(){return this._minMax},set:function(e){this._minMax=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stackID",{get:function(){return this._stackID},set:function(e){this._stackID=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelType",{get:function(){return this._pixelType},set:function(e){this._pixelType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelRepresentation",{get:function(){return this._pixelRepresentation},set:function(e){this._pixelRepresentation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invert",{get:function(){return this._invert},set:function(e){this._invert=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"modality",{get:function(){return this._modality},set:function(e){this._modality=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHanded",{get:function(){return this._rightHanded},set:function(e){this._rightHanded=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"spacingBetweenSlices",{get:function(){return this._spacingBetweenSlices},set:function(e){this._spacingBetweenSlices=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"segmentationSegments",{get:function(){return this._segmentationSegments},set:function(e){this._segmentationSegments=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"segmentationType",{get:function(){return this._segmentationType},set:function(e){this._segmentationType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"segmentationLUT",{get:function(){return this._segmentationLUT},set:function(e){this._segmentationLUT=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"segmentationLUTO",{get:function(){return this._segmentationLUTO},set:function(e){this._segmentationLUTO=e},enumerable:!0,configurable:!0}),t.value=function(e,t){return window.console.warn("models.stack.value is deprecated.\n       Please use core.utils.value instead."),me.value(e,t)},t.valueRescaleSlopeIntercept=function(e,t,n){return window.console.warn("models.stack.valueRescaleSlopeIntercept is deprecated.\n       Please use core.utils.rescaleSlopeIntercept instead."),me.rescaleSlopeIntercept(e,t,n)},t.worldToData=function(e,t){return window.console.warn("models.stack.worldToData is deprecated.\n       Please use core.utils.worldToData instead."),me.worldToData(e._lps2IJK,t)},t}(ge),xe=function(e){function t(){var t=e.call(this)||this;return t._sopInstanceUID=null,t._url=null,t._stackID=-1,t._invert=!1,t._frameTime=null,t._ultrasoundRegions=[],t._rows=0,t._columns=0,t._dimensionIndexValues=[],t._imagePosition=null,t._imageOrientation=null,t._rightHanded=!0,t._sliceThickness=1,t._spacingBetweenSlices=null,t._pixelPaddingValue=null,t._pixelRepresentation=0,t._pixelType=0,t._pixelSpacing=null,t._pixelAspectRatio=null,t._pixelData=null,t._instanceNumber=null,t._windowCenter=null,t._windowWidth=null,t._rescaleSlope=null,t._rescaleIntercept=null,t._bitsAllocated=8,t._numberOfChannels=1,t._minMax=null,t._dist=null,t._index=-1,t._referencedSegmentNumber=-1,t._sopInstanceUID=null,t._url=null,t._stackID=-1,t._invert=!1,t._frameTime=null,t._ultrasoundRegions=[],t._rows=0,t._columns=0,t._dimensionIndexValues=[],t._imagePosition=null,t._imageOrientation=null,t._rightHanded=!0,t._sliceThickness=1,t._spacingBetweenSlices=null,t._pixelPaddingValue=null,t._pixelRepresentation=0,t._pixelType=0,t._pixelSpacing=null,t._pixelAspectRatio=null,t._pixelData=null,t._instanceNumber=null,t._windowCenter=null,t._windowWidth=null,t._rescaleSlope=null,t._rescaleIntercept=null,t._bitsAllocated=8,t._numberOfChannels=1,t._minMax=null,t._dist=null,t._index=-1,t._referencedSegmentNumber=-1,t}return d(t,e),t.prototype.validate=function(t){return!!(e.prototype.validate.call(this,t)&&"function"==typeof t.cosines&&"function"==typeof t.spacingXY&&t.hasOwnProperty("_sopInstanceUID")&&t.hasOwnProperty("_dimensionIndexValues")&&t.hasOwnProperty("_imageOrientation")&&t.hasOwnProperty("_imagePosition"))},t.prototype.merge=function(e){return!!this.validate(e)&&!!(this._compareArrays(this._dimensionIndexValues,e.dimensionIndexValues)&&this._compareArrays(this._imageOrientation,e.imageOrientation)&&this._compareArrays(this._imagePosition,e.imagePosition)&&this._instanceNumber===e.instanceNumber&&this._sopInstanceUID===e.sopInstanceUID)},t.prototype.cosines=function(){var e=[new o.Vector3(1,0,0),new o.Vector3(0,1,0),new o.Vector3(0,0,1)];if(this._imageOrientation&&6===this._imageOrientation.length){var t=new o.Vector3(this._imageOrientation[0],this._imageOrientation[1],this._imageOrientation[2]),n=new o.Vector3(this._imageOrientation[3],this._imageOrientation[4],this._imageOrientation[5]);t.length()>0&&n.length()>0&&(e[0]=t,e[1]=n,e[2]=new o.Vector3(0,0,0).crossVectors(e[0],e[1]).normalize())}else window.console.log("No valid image orientation for frame"),window.console.log(this),window.console.log("Returning default orientation.");return this._rightHanded||e[2].negate(),e},t.prototype.spacingXY=function(){var e=[1,1];return this.pixelSpacing?(e[0]=this.pixelSpacing[0],e[1]=this.pixelSpacing[1]):this.pixelAspectRatio&&(e[0]=1,e[1]=1*this.pixelAspectRatio[1]/this.pixelAspectRatio[0]),e},t.prototype.getPixelData=function(e,t){return e>=0&&e<this._columns&&t>=0&&t<this._rows?this.pixelData[e+this._columns*t]:null},t.prototype.setPixelData=function(e,t,n){this.pixelData[e+this._columns*t]=n},t.prototype.getImageDataUrl=function(){var e=document.createElement("canvas");e.width=this._columns,e.height=this._rows;var t=e.getContext("2d"),n=t.createImageData(e.width,e.height);return n.data.set(this._frameToCanvas()),t.putImageData(n,0,0),e.toDataURL()},t.prototype._frameToCanvas=function(){var e=this._columns*this._rows,t={invert:this._invert,min:this._minMax[0],padding:this._pixelPaddingValue,max:this._minMax[1],range:this._minMax[1]-this._minMax[0]},n=new Uint8Array(4*e);if(null!==t.padding){t.min=this._minMax[1];for(var i=0,o=this._pixelData.length;i<o;i++)this._pixelData[i]!==t.padding&&(t.min=Math.min(t.min,this._pixelData[i]))}if(this._windowWidth&&null!==this._windowCenter){var r=this._rescaleIntercept||0,a=this._rescaleSlope||1;t.min=Math.max((this._windowCenter-this._windowWidth/2-r)/a,t.min),t.max=Math.min((this._windowCenter+this._windowWidth/2-r)/a,this._minMax[1])}else t.max=this._minMax[1];if(t.range=t.max-t.min||255,1===this._numberOfChannels)for(var s=0;s<e;s++){var c=this._pixelTo8Bit(this._pixelData[s],t);n[4*s]=c,n[4*s+1]=c,n[4*s+2]=c,n[4*s+3]=255}else if(3===this._numberOfChannels)for(s=0;s<e;s++)n[4*s]=this._pixelTo8Bit(this._pixelData[3*s],t),n[4*s+1]=this._pixelTo8Bit(this._pixelData[3*s+1],t),n[4*s+2]=this._pixelTo8Bit(this._pixelData[3*s+2],t),n[4*s+3]=255;return n},t.prototype._pixelTo8Bit=function(e,t){var n=e<=t.min||e===t.padding?0:255;return e>t.min&&e<t.max&&(n=Math.round(255*(e-t.min)/t.range)),Number.isNaN(n)?0:t.invert?255-n:n},t.prototype._compareArrays=function(e,t){return e===t||!(!e||!t||e.join()!==t.join())},Object.defineProperty(t.prototype,"frameTime",{get:function(){return this._frameTime},set:function(e){this._frameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ultrasoundRegions",{get:function(){return this._ultrasoundRegions},set:function(e){this._ultrasoundRegions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._rows},set:function(e){this._rows=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},set:function(e){this._columns=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"spacingBetweenSlices",{get:function(){return this._spacingBetweenSlices},set:function(e){this._spacingBetweenSlices=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sliceThickness",{get:function(){return this._sliceThickness},set:function(e){this._sliceThickness=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imagePosition",{get:function(){return this._imagePosition},set:function(e){this._imagePosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageOrientation",{get:function(){return this._imageOrientation},set:function(e){this._imageOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowWidth",{get:function(){return this._windowWidth},set:function(e){this._windowWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"windowCenter",{get:function(){return this._windowCenter},set:function(e){this._windowCenter=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rescaleSlope",{get:function(){return this._rescaleSlope},set:function(e){this._rescaleSlope=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rescaleIntercept",{get:function(){return this._rescaleIntercept},set:function(e){this._rescaleIntercept=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bitsAllocated",{get:function(){return this._bitsAllocated},set:function(e){this._bitsAllocated=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dist",{get:function(){return this._dist},set:function(e){this._dist=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelSpacing",{get:function(){return this._pixelSpacing},set:function(e){this._pixelSpacing=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelAspectRatio",{get:function(){return this._pixelAspectRatio},set:function(e){this._pixelAspectRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minMax",{get:function(){return this._minMax},set:function(e){this._minMax=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dimensionIndexValues",{get:function(){return this._dimensionIndexValues},set:function(e){this._dimensionIndexValues=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instanceNumber",{get:function(){return this._instanceNumber},set:function(e){this._instanceNumber=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelData",{get:function(){return this._pixelData},set:function(e){this._pixelData=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sopInstanceUID",{get:function(){return this._sopInstanceUID},set:function(e){this._sopInstanceUID=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelPaddingValue",{get:function(){return this._pixelPaddingValue},set:function(e){this._pixelPaddingValue=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelRepresentation",{get:function(){return this._pixelRepresentation},set:function(e){this._pixelRepresentation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pixelType",{get:function(){return this._pixelType},set:function(e){this._pixelType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._url},set:function(e){this._url=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"referencedSegmentNumber",{get:function(){return this._referencedSegmentNumber},set:function(e){this._referencedSegmentNumber=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHanded",{get:function(){return this._rightHanded},set:function(e){this._rightHanded=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"index",{get:function(){return this._index},set:function(e){this._index=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invert",{get:function(){return this._invert},set:function(e){this._invert=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numberOfChannels",{get:function(){return this._numberOfChannels},set:function(e){this._numberOfChannels=e},enumerable:!0,configurable:!0}),t}(ge),we=function(e){function n(t,n,i){var o=e.call(this,t,n)||this;return o.ef=i.nativeElement,o.lut=new ve(o.ef),o.lut.luts=ve.presetLuts(),o.lut.lutsO=ve.presetLutsO(),n.renderer.setClearColor(15658734),o}return d(n,e),n.prototype.createEntity=function(e){var t=this.getStack(e.volume),n=new he(t);return this.lut.lut=e.color,this.lut.lutO=e.opacity,n.uniforms.uTextureLUT.value.dispose(),n.uniforms.uTextureLUT.value=this.lut.texture,n.uniforms.uLut.value=1,n.algorithm=e.algorithm,n.alphaCorrection=e.alphaCorrection,n},n.prototype.updateEntity=function(e,t){var n=this.getStack(e.volume),i=new he(n);return this.lut.lut=e.color,this.lut.lutO=e.opacity,i.uniforms.uTextureLUT.value.dispose(),i.uniforms.uTextureLUT.value=this.lut.texture,i.uniforms.uLut.value=1,i.algorithm=e.algorithm,i.alphaCorrection=e.alphaCorrection,i},n.prototype.getStack=function(e){var t=new be,n=e.meta.shape.x,i=e.meta.shape.y,o=e.meta.shape.z;t._numberOfFrames=o,t.modality="unknown";for(var r=1;r<=t._numberOfFrames;r++){var a=new xe;a.sopInstanceUID=r,a.index=r,a.instanceNumber=r,a.rows=n,a.columns=i,a.pixelSpacing=[1,1,1],a.imagePosition=[127,118,-57],a.pixelData=this.getFrame(r,e),a.imageOrientation=[-1,-0,0,-0,-1,0],a.rescaleSlope=1,a.rescaleIntercept=0,a.minMax=this.getMinMax(a.pixelData),null===a.imageOrientation&&(a.imageOrientation=[1,0,0,0,1,0]),t.frame.push(a)}return t},n.prototype.getFrame=function(e,t){for(var n=new Uint8Array(t.meta.shape.x*t.meta.shape.y),i=1;i<=n.length;i++)n[i]=t.pixel(i+e*t.meta.shape.x*t.meta.shape.y);return n},n.prototype.getData=function(e,t,n){for(var i=new Uint8Array(t*n),o=1;o<=i.length;o++)i[o]=0;return i},n.prototype.getMinMax=function(e){var t=e.sort();return[t[0],t[t.length-1]]},n.prototype.defaultModel=function(){return new A("red","bandpass",0,.25,new _(new o.Vector3(0,0,0),new o.Vector3(190,256,151),new o.Vector3(190,256,151),new Float32Array(7344640)))},n.decorators=[{type:t.Component,args:[{selector:"ng3-volume-rendering",template:"<p>\n  volume-rendering works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te},{type:t.ElementRef}]},n}(de);function _e(){return{canvasId:s.v4(),id:s.v4(),model:new M(new o.Vector3(0,0,0),29.9,30),color:new o.Color(60,179,113)}}var Se=function(){function e(){this.toSearch=function(e){return e},this.updateEqualCanvasRing=function(e,t){return e.canvasId===t.canvasId&&"ring"===t.model.type},this.updateEqualCanvasLine=function(e,t){return e.canvasId===t.canvasId&&"line"===t.model.type},this.updateEqualCanvasCrossLine=function(e,t){return e.canvasId===t.canvasId&&"crossline"===t.model.type},this.updateEqualFov=function(e,t){return e.id===t.id&&"fov"===t.model.type},this.fromUpdateModelId=function(e,t){return f({},t,{model:e.model})},this.fromUpdateModel=function(e,t){return f({},t,{model:e.model})},this.updateEqualCrosslines=function(e,t){return!0},this.fromUpdateCrosslines=function(e,t){return f({},t,{model:f({},t.model,{position:e.model.position})})},this.removeEqual=function(e,t){return e.canvasId===t.canvasId},this.updateEqualAll=function(e,t){return!0},this.fromUpdateId=function(e,t){return f({},t,{canvasId:e.canvasId,id:s.v4()})},this.whichDraging$=new i.Observable,this.entityArrayCollectionOf=new c.ArrayCollectionOf(new Array(_e())),this.entityStateStore=new c.ItemStore(this.entityArrayCollectionOf,!0),this.entityRingDatabase=new c.Database(this.entityStateStore,this.updateEqualCanvasRing,this.removeEqual,this.toSearch,this.fromUpdateModel),this.entityCrossLineDatabase=new c.Database(this.entityStateStore,this.updateEqualCanvasCrossLine,this.removeEqual,this.toSearch,this.fromUpdateModel),this.entityCrossLinesDatabase=new c.Database(this.entityStateStore,this.updateEqualCrosslines,this.removeEqual,this.toSearch,this.fromUpdateCrosslines),this.fovDatabese=new c.Database(this.entityStateStore,this.updateEqualFov,this.removeEqual,this.toSearch,this.fromUpdateModelId),this.imageDatabase=new c.Database(this.entityStateStore),this.selectedEntityStateStore=new c.ItemStore(new c.ArrayCollectionOf(new Array(_e())),!0),this.selectedEntityDatabase=new c.Database(this.selectedEntityStateStore),this.clipBoardStore=new c.ItemStore(new c.ArrayCollectionOf(new Array(_e())),!0),this.clipBoardDatabase=new c.Database(this.clipBoardStore,this.updateEqualAll,this.removeEqual,this.toSearch,this.fromUpdateId),this.clearSelected(),this.clearClipBoard(),this.clear()}return e.prototype.updateFunction=function(e,t){return!1},e.prototype.addEntity=function(e){this.entityRingDatabase.insert(e).subscribe(i.noop,console.error)},e.prototype.selectEntity=function(e){this.selectedEntityDatabase.insert(e).subscribe(i.noop,console.error)},e.prototype.selectEntities=function(e){this.selectedEntityDatabase.insertMany(e).subscribe(i.noop,console.error)},e.prototype.clearSelected=function(){this.selectedEntityStateStore.filter(function(e){return!1}).subscribe(i.noop,console.error)},e.prototype.clearClipBoard=function(){this.clipBoardStore.filter(function(e){return!1}).subscribe(i.noop,console.error)},e.prototype.clear=function(){this.entityStateStore.filter(function(e){return!1}).subscribe(i.noop,console.error)},e.prototype.updateRingEntity=function(e){this.entityRingDatabase.update(e).subscribe(i.noop,console.error)},e.prototype.updateCrosslineEntity=function(e){this.entityCrossLineDatabase.update(e).subscribe(i.noop,console.error)},e.prototype.updateCrosslines=function(e){this.entityCrossLinesDatabase.updateMany(e).subscribe(i.noop,console.error)},e.prototype.updateRings=function(e){var t;(t=this.entityRingDatabase).updateMany.apply(t,v(e)).subscribe(i.noop,console.error)},e.prototype.updateFov=function(e){this.fovDatabese.update(e).subscribe(i.noop,console.error)},e.prototype.removeEntity=function(e){this.entityRingDatabase.remove(e).subscribe(i.noop,console.error)},e.prototype.removeEntities=function(e){var t;(t=this.entityRingDatabase).removeMany.apply(t,v(e)).subscribe(i.noop,console.error)},e.prototype.removeEntityWithCanvasId=function(e){this.entityRingDatabase.remove({canvasId:e}).subscribe(i.noop,console.error)},e.prototype.addRing=function(e){this.entityRingDatabase.insert({canvasId:e,id:s.v4(),model:new M(new o.Vector3(0,0,0),3,3.0001),color:new o.Color(60,179,113)}).subscribe(i.noop,console.error)},e.prototype.addLine=function(e){this.entityRingDatabase.insert({canvasId:e,id:s.v4(),model:new T(new o.Vector3(0,0,0),new o.Vector3(10,0,0)),color:new o.Color(60,179,113)}).subscribe(i.noop,console.error)},e.prototype.addCrossLine=function(e){this.entityRingDatabase.insert({canvasId:e,id:s.v4(),model:new k(new o.Vector3(0,0,0),"z"),color:new o.Color(60,179,113)}).subscribe(i.noop,console.error)},e.prototype.addFov=function(e,t,n){void 0===t&&(t=new o.Vector2(0,0)),void 0===n&&(n=new o.Vector2(30,10)),this.fovDatabese.insert({canvasId:e,id:s.v4(),model:new B(new W(t,n)),color:new o.Color(60,179,113)}).subscribe(i.noop,console.error)},e.prototype.cutEntity=function(e){this.clearClipBoard(),this.copyEntity(e),this.removeEntityWithCanvasId(e)},e.prototype.copyEntity=function(e){var t=this;this.clearClipBoard(),this.entitiesOfCanvas(e).pipe(r.map(function(e){var n;return(n=t.clipBoardDatabase).insertMany.apply(n,v(e)).subscribe(i.noop,console.error)})).subscribe(i.noop,console.error)},e.prototype.pasteEntity=function(e){var t=this;this.clipBoardDatabase.update({canvasId:e}).subscribe(i.noop,console.error),this.clipBoardDatabase.searchMany(function(e){return!0}).pipe(r.map(function(e){var n;return(n=t.entityRingDatabase).insertMany.apply(n,v(e)).subscribe(function(e){return console.log(e)},console.error)})).subscribe(i.noop,console.error)},e.prototype.entitiesOfCanvas=function(e){return this.entityRingDatabase.searchMany(function(t){return t.canvasId===e})},e.prototype.crosslineOnCanvas=function(e,t){var n;this.getCrossline(e).pipe(r.map(function(e){if(e!==undefined)return n=e.model,t(n)})).subscribe(i.noop,console.error)},e.prototype.ringOnCanvas=function(e,t){var n;return this.getRing(e).pipe(r.map(function(e){return n=e.model})).subscribe(i.noop,console.error),t(n)},e.prototype.fovOnCanvas=function(e,t){var n;return this.getFov(e).pipe(r.map(function(e){return n=e})).subscribe(i.noop,console.error),t(n)},e.prototype.fovsOnCanvas=function(e,t){var n;return this.getFovs(e).pipe(r.map(function(e){return n=e})).subscribe(i.noop,console.error),t(n)},e.prototype.showEntities=function(){return this.entityRingDatabase.searchMany(function(e){return!0})},e.prototype.showClipBoard=function(){return this.clipBoardDatabase.searchMany(function(e){return!0})},e.prototype.getRings=function(){return this.entityRingDatabase.searchMany(function(e){return"ring"===e.model.type})},e.prototype.getRing=function(e){return this.entityRingDatabase.search(function(t){return t.canvasId===e&&"ring"===t.model.type})},e.prototype.getCircles=function(){return this.entityRingDatabase.searchMany(function(e){return"circle"===e.model.type})},e.prototype.getFov=function(e){return this.fovDatabese.search(function(t){return t.canvasId===e&&"fov"===t.model.type})},e.prototype.getFovs=function(e){return this.fovDatabese.searchMany(function(t){return t.canvasId===e&&"fov"===t.model.type})},e.prototype.getCrossline=function(e){return this.entityCrossLineDatabase.search(function(t){return t.canvasId===e&&"crossline"===t.model.type})},e.prototype.getROI=function(){},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),Ce=function(){function e(){var e=this;this.lineTest=new T(new o.Vector3(0,0,0),new o.Vector3(10,10,0)),this.models={Right:this.lineTest,Left:this.lineTest,Top:this.lineTest,Bottom:this.lineTest,Up:this.lineTest,Down:this.lineTest},this.leftTop=new o.Vector3(0,0,0),this.leftBottom=new o.Vector3(0,10,0),this.rightTop=new o.Vector3(10,0,0),this.rightBottom=new o.Vector3(10,10,0),this.right=10,this.top=20,this.bottom=10,this.currentColor=new o.Color(.5,.5,.5),this.boxSubject=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(1,1))),this.box$=this.boxSubject.asObservable(),this.fovSubject=new i.BehaviorSubject(new B(new W(new o.Vector2(0,0),new o.Vector2(60,60)))),this.fov$=this.fovSubject.asObservable(),this.z=20,this.isActive=!0,this.upAndDownShow=!1,this.models$=this.fov$.pipe(r.filter(function(e){return e!==undefined}),r.map(function(t){return e.addLines(t.box,!0)}))}return Object.defineProperty(e.prototype,"model",{get:function(){return this.fovSubject.value},set:function(e){this.fovSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.addLines=function(e,t){return void 0===t&&(t=!1),e!==undefined&&(this.setCurrentColor(t),this.setCurrentPos(e),this.models.Top=new T(this.leftTop,this.rightTop,"Dashed",this.currentColor),this.models.Bottom=new T(this.leftBottom,this.rightBottom,"Dashed",this.currentColor),this.models.Left=new T(this.leftTop,this.leftBottom,"Dashed",this.currentColor),this.models.Right=new T(this.rightTop,this.rightBottom,"Dashed",this.currentColor),this.models.Up=new T(new o.Vector3(-1e3,this.leftTop.y-.2,this.z),new o.Vector3(1e3,this.leftTop.y-.2,this.z),"Dashed",new o.Color(1,1,0)),this.models.Down=new T(new o.Vector3(-1e3,this.leftBottom.y+.15,this.z),new o.Vector3(1e3,this.leftBottom.y+.15,this.z),"Dashed",new o.Color(1,1,0))),this.models},e.prototype.setCurrentColor=function(e){void 0===e&&(e=!1),this.currentColor=!0===e?new o.Color(1,0,0):new o.Color(.5,.5,.5)},e.prototype.setCurrentPos=function(e){if(e!==undefined){var t=e.center.x-e.size.x/2,n=e.center.x+e.size.x/2,i=e.center.y-e.size.y/2,r=e.center.y+e.size.y/2;this.leftTop=new o.Vector3(t,i,this.z),this.leftBottom=new o.Vector3(t,r,this.z),this.rightTop=new o.Vector3(n,i,this.z),this.rightBottom=new o.Vector3(n,r,this.z)}},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-fov",template:'<ng-container *ngIf="(models$ | async) as models">\n  <ng3-line [model]="models.Bottom"></ng3-line>\n  <ng3-line [model]="models.Left"></ng3-line>\n  <ng3-line [model]="models.Right"></ng3-line>\n  <ng3-line [model]="models.Top"></ng3-line>\n  <ng3-line *ngIf="upAndDownShow" [model]="models.Up"></ng3-line>\n  <ng3-line *ngIf="upAndDownShow" [model]="models.Down"></ng3-line>\n</ng-container>\n\n',styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={model:[{type:t.Input}],z:[{type:t.Input}],isActive:[{type:t.Input}],upAndDownShow:[{type:t.Input}]},e}(),Ie=function(){function e(){var e=this;this.model$=new i.Observable,this.posX=0,this.posY=0,this.imageSubject=new i.BehaviorSubject(new P(new W(new o.Vector2(0,0),new o.Vector2(200,200)),10,undefined,new o.Vector3(0,0,0),!0,0,!0)),this.image$=this.imageSubject.asObservable(),this.lineTest=new T(new o.Vector3(0,0,0),new o.Vector3(10,10,0)),this.models={vertical:this.lineTest,horizontal:this.lineTest},this.crosslineSubject=new i.BehaviorSubject(new k(new o.Vector3(0,2,30),"z",1.5)),this.crossline$=this.crosslineSubject.asObservable(),this.drag=new t.EventEmitter,this.z=0,this.models$=this.crossline$.pipe(r.filter(function(e){return e!==undefined}),r.map(function(t){return e.plotCrossLine(t)}))}return Object.defineProperty(e.prototype,"model",{get:function(){return this.crosslineSubject.value},set:function(e){this.crosslineSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.plotCrossLine=function(e){var t=this;return this.updatePos(e),this.model$=this.image$.pipe(r.map(function(){return new P(new W(new o.Vector2(t.posX,t.posY),new o.Vector2(5*e.lineWidth,5*e.lineWidth)))})),this.models.vertical=new T(new o.Vector3(this.posX+80,this.posY,this.z),new o.Vector3(this.posX-80,this.posY,this.z),"Solid"),this.models.horizontal=new T(new o.Vector3(this.posX,this.posY-80,this.z),new o.Vector3(this.posX,this.posY+80,this.z),"Solid"),this.models},e.prototype.onDragEvent=function(e){this.drag.emit(e)},e.prototype.ngOnDestroy=function(){this.imageSubject.complete(),this.crosslineSubject.complete()},e.prototype.updatePos=function(e){switch(e.view){case"x":this.posX=e.position.y,this.posY=e.position.z;break;case"y":this.posX=e.position.x,this.posY=e.position.z;break;case"z":this.posX=e.position.x,this.posY=e.position.y;break;default:this.posX=e.position.y,this.posY=e.position.z}},e.decorators=[{type:t.Component,args:[{selector:"ng3-cross-line",template:'<ng-container *ngIf="(models$ | async) as models">\n  <ng3-line [model]="models.vertical"></ng3-line>\n  <ng3-line [model]="models.horizontal"></ng3-line>\n</ng-container>\n\x3c!-- <ng3-line [model]="models"></ng3-line>\n  <ng3-line [model]="models.v"></ng3-line> --\x3e\n\x3c!-- <ng-template #test> <ng3-line [model]="models.Vertical"></ng3-line>\n        <ng3-line [model]="models.Horizontal"></ng3-line> --\x3e\n\x3c!-- <p>{{models|json}}</p> </ng-template> --\x3e\n\n\x3c!-- <ng3-line [model]="(models$ | async)"></ng3-line> --\x3e\n\x3c!-- <ng-container *ngIf="(model$ | async) as model">\n  <ng3-plane [model]="model" ></ng3-plane>\n</ng-container> --\x3e\n\n\x3c!-- <ng3-plane [model]="model$ | async" [z]="z">\n  <ng3-mouse-entity (drag)="onDragEvent($event)"></ng3-mouse-entity>\n</ng3-plane> --\x3e\n\x3c!-- <ng3-line [model]="lineTest"></ng3-line> --\x3e\n',providers:[Se],styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={drag:[{type:t.Output}],z:[{type:t.Input}],model:[{type:t.Input}]},e}();var Pe=function(){function e(e,t,n,i){void 0===e&&(e="x"),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1e3),this.direction=e,this.index=t,this.min=n,this.max=i,this.min=Math.floor(this.min),this.max=Math.floor(this.max),this.index=Math.max(Math.min(Math.floor(this.index),this.max),this.min)}return e.prototype.updateBoundmax=function(t){return new e(this.direction,this.index,this.min,t)},e.prototype.updateBoundmin=function(t){return new e(this.direction,this.index,t,this.max)},e.prototype.updateIndex=function(t){return t>=this.min&&t<this.max?new e(this.direction,t,this.min,this.max):this},e.prototype.addIndex=function(e){return this.updateIndex(this.index+e)},e.prototype.updateDirection=function(t,n){return new e(t,this.index,this.min,n===undefined?this.max:ze(n,t))},e.prototype.shapeOfDirection=function(e){return ze(e,this.direction)},e.prototype.slice=function(e){var t=this,n=e.meta;switch(this.direction){case"x":return new S(new o.Vector2(n.center.y,n.center.z),new o.Vector2(n.size.y,n.size.z),new o.Vector2(n.shape.y,n.shape.z),De(n.shape.y,n.shape.z,function(n,i){return e.pixel3(t.index,n,i)}));case"y":return new S(new o.Vector2(n.center.x,n.center.z),new o.Vector2(n.size.x,n.size.z),new o.Vector2(n.shape.x,n.shape.z),De(n.shape.x,n.shape.z,function(n,i){return e.pixel3(n,t.index,i)}));case"z":return new S(new o.Vector2(n.center.x,n.center.y),new o.Vector2(n.size.x,n.size.y),new o.Vector2(n.shape.x,n.shape.y),De(n.shape.x,n.shape.y,function(n,i){return e.pixel3(n,i,t.index)}))}},e}();function ze(e,t){switch(t){case"x":return e.meta.shape.x;case"y":return e.meta.shape.y;case"z":return e.meta.shape.z}}function De(e,t,n){for(var i=new Float32Array(e*t),o=0;o<e;o++)for(var r=0;r<t;r++)i[o*t+r]=n(o,r);return i}function Ve(e,t){for(var n=e.meta.shape.x*e.meta.shape.y,i=new Uint8Array(n),o=new Uint8Array(n),r=new Uint8Array(n),a=0;a<n;a++)i[a]=t.r(e.data[a]),o[a]=t.g(e.data[a]),r[a]=t.b(e.data[a]);return new I(e.meta.center,e.meta.size,e.meta.shape,i,o,r)}!function(e){function t(e){return Math.max(Math.min(e,1),0)}e.GRAY={name:"gray",r:function(e){return 255*t(e)},g:function(e){return 255*t(e)},b:function(e){return 255*t(e)}};e.HOT={name:"hot",r:function(e){var n=t(e);return n<.3671875?n/.3671875*255:255},g:function(e){var n=t(e);return n<.7460938?n>.3671875?(n-.3671875)/(.7460938-.3671875)*255:0:255},b:function(e){var n=t(e);return n<.7460938?0:(n-.7460938)/(1-.7460938)*255}}}(e.Colormaps||(e.Colormaps={}));var Oe=function(){function e(e){this.f=e}return e.prototype.filter=function(e){var t=this,n=e.max(),i=e.min();return new S(e.meta.center,e.meta.size,e.meta.shape,e.data.map(function(e){return(e-i)/(n-i)}).map(function(e){return t.f(e)}))},e}(),Me=function(e){function t(t,n){return e.call(this,function(e){return e*t+n})||this}return d(t,e),t}(Oe),je=function(e){function t(t,n){var i=e.call(this,function(e){return Math.min(Math.max(e,n-t/2),n+t/2)})||this;return i.width=t,i.level=n,i}return d(t,e),t.prototype.updateLevel=function(e){return new t(this.width,e)},t.prototype.updataWidth=function(e){return new t(e,this.level)},t.prototype.addWidth=function(e){return new t(this.width+e,this.level)},t.prototype.addLevel=function(e){return new t(this.width,this.level+e)},t.prototype.addWidthLevel=function(e,t){return this.addWidth(e).addLevel(t)},t}(Oe);function Le(e){var t=new i.Subject,n=new i.BehaviorSubject(e);return t.pipe(r.scan(function(e,t,n){return t(e,n)},e),r.startWith(e),r.distinctUntilChanged()).subscribe(n),{dispatch:function(e){return new i.Observable(function(n){t.next(e),n.complete()})},state$:n.asObservable(),currentState:function(){return n.value},complete:function(){t.complete(),n.complete()}}}var Te=function(e){return function(t){return e.id===t.id}},Fe=function(){function e(e){void 0===e&&(e=Te),this.equalTo=e,this.s=Le([]),this.state$=this.s.state$}return e.prototype.dispatch=function(e){return this.s.dispatch(e)},e.prototype.currentState=function(){return this.s.currentState()},e.prototype.complete=function(){this.s.complete()},e.prototype.get$=function(e){var t=this;return this.state$.pipe(r.map(function(n){return n.find(t.equalTo(e))}),r.filter(function(e){return e!==undefined}),r.distinctUntilChanged())},e.prototype.filter$=function(e){return this.state$.pipe(r.map(function(t){return t.filter(e)}))},e.prototype.setState=function(e){return this.dispatch(function(){return e})},e.prototype.insert=function(e){var t=this;return this.dispatch(function(n){if(n.find(t.equalTo(e))!==undefined)throw Error("Item with id: "+e.id+" already exists.");return v(n,[e])})},e.prototype.remove=function(e){var t=this;return this.dispatch(function(n){return n.filter(t.equalTo(e))})},e.prototype.update=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this.dispatch(function(n){return function(e,t,n){return t.forEach(function(t){if(e.find(function(e){return n(t)(e)})===undefined)throw Error("Item with id: "+t.id+" not exists.")}),e.map(function(e){var i=t.find(function(t){return n(e)(t)});return i===undefined?e:i})}(n,t,e.equalTo)})},e.prototype.clear=function(){return this.setState([])},e}();function Ee(e){for(var t=0,n=new Float32Array(e.length/Float32Array.BYTES_PER_ELEMENT),i=new DataView(new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT)),o=0;o<e.length/Float32Array.BYTES_PER_ELEMENT;o++){t=4*o;for(var r=0;r<Float32Array.BYTES_PER_ELEMENT;++r)i.setUint8(r,e.charCodeAt(t+r));n[o]=i.getFloat32(0,!0)}return n}function ke(e,t){return new i.Observable(function(n){var i=new FileReader;i.onload=function(e){n.next(e.target.result)},i.onabort=function(e){n.error(e)},i.onerror=function(e){n.error(e)},i.onloadend=function(){n.complete()},t(i,e)})}var Be=function(){function e(){}return e.prototype.loadHead=function(e){return ke(e,function(e,t){e.readAsText(t)}).pipe(r.map(function(e){return JSON.parse(e)}),r.map(function(e){return{shape:e.shape,size:e.size}}),r.tap(function(e){return console.log(e)}))},e.prototype.loadImage=function(e,t,n){return void 0===n&&(n=new o.Vector3(0,0,0)),ke(e,function(e,t){e.readAsBinaryString(t)}).pipe(r.map(Ee),r.map(function(e){return new _(n,t.size,t.shape,e)}))},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[]},e}(),Ae=function(){function e(e){this.loaderService=e,this.isHeadLoaded=!1,this.isImageLoaded=!1,this.imageLoad=new t.EventEmitter}return e.prototype.ngOnInit=function(){},e.prototype.loadLocalImage=function(){var e=this;if(this.imageHead===undefined||this.imageFile===undefined)throw Error("Head or imageFile is undefined");this.loaderService.loadImage(this.imageFile,this.imageHead).subscribe(function(t){return e.imageLoad.emit(t)},function(e){return console.error(e)})},e.prototype.markImageLoaded=function(e){this.imageFile=e[0],this.isImageLoaded=!0},e.prototype.markHeadLoaded=function(e){var t=this;this.loaderService.loadHead(e[0]).subscribe({next:function(e){t.imageHead=e,t.isHeadLoaded=!0},error:function(e){return console.log(e)}})},e.decorators=[{type:t.Component,args:[{selector:"app-local-image-loader",template:'<div>\n  <div>Load image from local filesystem</div>\n  <label for="head">Head File</label>\n  <input\n    type="file"\n    id="head"\n    #headFiles\n    (change)="markHeadLoaded(headFiles.files)"\n  />\n  <div *ngIf="isHeadLoaded">\n  </div>\n  <br />\n  <label for="file">Image File</label>\n  <input\n    type="file"\n    id="file"\n    #imageFiles\n    (change)="markImageLoaded(imageFiles.files)"\n  />\n  <br />\n  <button\n    [disabled]="!isHeadLoaded || !isImageLoaded"\n    (click)="loadLocalImage()"\n  >\n    Load\n  </button>\n</div>\n',providers:[Be],styles:[".triple{display:flex}.numberInput{width:20%}.divC{white-space:nowrap;display:inline}.window{display:inline;white-space:nowrap}.inputValue{width:350px}.labelLength{width:100px}"]}]}],e.ctorParameters=function(){return[{type:Be}]},e.propDecorators={imageLoad:[{type:t.Output}]},e}(),Re=function(){function e(e){this.http=e,this.isLoadDummyData=!0,this.image3Input=Y(new o.Vector3(5,5,5),new o.Vector3(20,20,20)),this.isLoadDummyData&&console.warn("Http image loader is set to load dummy data")}return e.prototype.getImageHttp=function(e){return e||(e="666"),this.isLoadDummyData?i.of(Y(new o.Vector3(100,100,100),new o.Vector3(100,100,100))):(this.http.post(e,{a:2,b:3}).subscribe(function(e){return console.log(e)}),this.http.get(e).pipe(r.tap(function(e){return console.log(e)})).pipe(r.map($e)).pipe(r.map(Ge)))},e.prototype.getImage2Websocket=function(){return new l.WebSocketSubject("ws://127.0.0.1:8081/CT/image").pipe(r.map(function(e){return{image:Ue(t=e),vmin:t.vmin,vmax:t.vmax};var t}))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:u.HttpClient}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(u.HttpClient))},token:e,providedIn:"root"}),e}();function $e(e){return new _(new(o.Vector3.bind.apply(o.Vector3,v([void 0],e.center))),new(o.Vector3.bind.apply(o.Vector3,v([void 0],e.size))),new(o.Vector3.bind.apply(o.Vector3,v([void 0],e.shape))),Ee(e.values))}function Ue(e){return new S(new(o.Vector2.bind.apply(o.Vector2,v([void 0],e.center))),new(o.Vector2.bind.apply(o.Vector2,v([void 0],e.size))),new(o.Vector2.bind.apply(o.Vector2,v([void 0],e.shape))),Ee(e.values))}function Ge(e){for(var t=new Float32Array(e.data.length),n=0;n<e.meta.shape.x;n++)for(var i=0;i<e.meta.shape.y;i++)for(var o=0;o<e.meta.shape.z;o++){var r=n+i*e.meta.shape.y+o*e.meta.shape.x*e.meta.shape.y;t[n*e.meta.shape.y*e.meta.shape.z+i*e.meta.shape.z+o]=e.data[r]}return new _(e.meta.center,e.meta.size,e.meta.shape,t)}var We=function(){function e(e){this.loaderService=e,this.inputId=s.v4(),this.urlPlaceHolder="http://192.168.1.33:5006/api/v1/CT/file?recon_id=25",this.HttpURL="http://192.168.1.33:5006/api/v1/CT/file?recon_id=25",this.imageLoad=new t.EventEmitter}return e.prototype.ngOnInit=function(){},e.prototype.getDummyData=function(e){var t=this;this.loaderService.isLoadDummyData=!0,this.loaderService.getImageHttp(e).subscribe(function(e){return t.imageLoad.emit(e)},function(e){return console.error(e)})},e.prototype.getHttpImage=function(e){var t=this;this.loaderService.isLoadDummyData=!1,this.loaderService.getImageHttp(e).subscribe(function(e){return t.imageLoad.emit(e)},function(e){return console.error(e)})},e.decorators=[{type:t.Component,args:[{selector:"app-http-image-loader",template:'\x3c!-- <div><h2>Load image from http</h2></div> --\x3e\n<div>\n  <label [for]="inputId">Url</label>\n  <input #http type="text" [id]="inputId" [placeholder]="urlPlaceHolder" />\n  <button (click)="getHttpImage(http.value)">LoadHttp</button>\n  <button (click)="getDummyData(http.value)">loadDummy</button>\n  \x3c!-- <button (click)="getImage()">LoadInput</button> --\x3e\n</div>\n',providers:[Re],styles:[""]}]}],e.ctorParameters=function(){return[{type:Re}]},e.propDecorators={HttpURL:[{type:t.Input}],imageLoad:[{type:t.Output}]},e}(),Ne=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[Ae,We],imports:[n.CommonModule],providers:[],exports:[Ae,We]}]}],e}();function He(){return{image:new _(new o.Vector3(0,0,0),new o.Vector3(1,2,3),new o.Vector3(1,2,3),new Float32Array([1,2,3,4,5,6])),slicer:new Pe("x",0,0,1),colormap:e.Colormaps.HOT,filter:new je(6,3),minMax:new o.Vector2(0,.1),id:s.v4(),rotation:new o.Vector3(0,0,0)}}var qe=function(){function n(){this.imageStateStore=new Fe,this.selectedIdsSubject=new i.BehaviorSubject([]),this.selected$=i.combineLatest(this.imageStateStore.state$,this.selectedIdsSubject).pipe(r.map(function(e){var t=m(e,2),n=t[0];return t[1].map(function(e){return n.find(function(t){return t.id===e})}).filter(function(e){return e!==undefined})})),this.imageStateStore.insert(He()).subscribe(i.noop,function(e){return console.log(e)}),this.imageStateStore.insert({image:new _(new o.Vector3(0,0,0),new o.Vector3(1,1,0),new o.Vector3(1,1,0),new Float32Array([1])),slicer:new Pe("z",0,1),colormap:e.Colormaps.GRAY,filter:new je(1,.5),minMax:new o.Vector2(0,1),id:s.v4(),rotation:new o.Vector3(0,0,0)}).subscribe(i.noop,function(e){return console.log(e)})}return n.prototype.image$=function(e){return this.imageStateStore.state$.pipe(r.map(function(t){return t.find(function(t){return t.id===e})}),r.filter(function(e){return e!==undefined}),r.distinctUntilChanged())},n.prototype.currentImage=function(e){return this.imageStateStore.currentState().find(function(t){return t.id===e})},n.prototype.addImage=function(t){var n=this;return new i.Observable(function(r){var a=s.v4(),c={image:t,slicer:new Pe("z",0,0,t.meta.shape.z),colormap:e.Colormaps.GRAY,filter:new je(1,.5),minMax:new o.Vector2(0,1),id:a,rotation:new o.Vector3(0,0,0)};n.imageStateStore.insert(c).subscribe(i.noop,function(e){return console.log(e)},function(){return r.next(a)})})},n.prototype.select=function(e){this.selectedIdsSubject.value.includes(e.id)||this.imageStateStore.currentState().find(function(t){return t.id===e.id})!==undefined&&this.selectedIdsSubject.next(v(this.selectedIdsSubject.value,[e.id]))},n.prototype.clearAllSelect=function(){this.selectedIdsSubject.next([])},n.prototype.updateImage=function(e,t){this.imageStateStore.update(f({},e,{image:t})).subscribe(i.noop,console.error)},n.prototype.updateColormap=function(e,t){this.imageStateStore.update(f({},e,{colormap:t})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.updateAllSelectedColormap=function(e){var t=this;this.mapToAllSelected(function(n){return t.updateColormap(n,e)})},n.prototype.updateWidthLevelFilter=function(e,t,n){this.imageStateStore.update(f({},e,{filter:new je(t,n)})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.addWidthByStep=function(e,t){this.imageStateStore.update(f({},e,{filter:e.filter.addWidth(.05*t)})).subscribe(i.noop,function(e){return console.error(e)})},n.prototype.addLevelByStep=function(e,t){this.imageStateStore.update(f({},e,{filter:e.filter.addLevel(.05*t)})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.addWidthLevelFilterByStep=function(e,t,n){this.imageStateStore.update(f({},e,{filter:e.filter.addWidthLevel(.05*t,.05*n)})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.updateDirection=function(e,t){this.imageStateStore.update(f({},e,{slicer:e.slicer.updateDirection(t,e.image)})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.updateIndex=function(e,t){this.imageStateStore.update(f({},e,{slicer:e.slicer.updateIndex(t)})).subscribe(i.noop,function(e){return console.log(e)})},n.prototype.addIndex=function(e,t){this.imageStateStore.update(f({},e,{slicer:e.slicer.addIndex(t)})).subscribe(i.noop,function(e){return console.error(e)})},n.prototype.updateMinMax=function(e,t){console.warn("Min max will be deprecated")},n.prototype.updateRotation=function(e,t){this.imageStateStore.update(f({},e,{rotation:t})).subscribe(i.noop,function(e){return console.error(e)})},n.prototype.addRotation=function(e,t){this.imageStateStore.update(f({},e,{rotation:new o.Vector3(e.rotation.x+t.x,e.rotation.y+t.y,e.rotation.z+t.z)})).subscribe(i.noop,function(e){return console.error(e)})},n.prototype.mapToAllSelected=function(e){var t=this;this.selectedIdsSubject.value.forEach(function(n){var i=t.imageStateStore.currentState().find(function(e){return e.id===n});return i===undefined?void 0:e(i)})},n.prototype.mapById=function(e,t){var n=this.imageStateStore.currentState().find(function(t){return t.id===e});if(n!==undefined)return t(n)},n.decorators=[{type:t.Injectable,args:[{providedIn:Ne}]}],n.ctorParameters=function(){return[]},n.ngInjectableDef=t.defineInjectable({factory:function(){return new n},token:n,providedIn:Ne}),n}(),Ye=function(){function e(e){var t=this;this.imageStoreService=e,this.selectedSubject=new i.BehaviorSubject([]),this.selected$=this.selectedSubject.asObservable(),this.imageCanvasBindsSubject=new i.BehaviorSubject([]),this.imageCanvas$=this.imageCanvasBindsSubject.asObservable(),this.componentCanvasSubject=new i.BehaviorSubject([]),this.componentCanvas$=this.componentCanvasSubject.asObservable(),this.withCrossLineCanvasSubject=new i.BehaviorSubject([]),this.withCrossLineCanvas$=this.withCrossLineCanvasSubject.asObservable(),this.selectedImageIds$=i.combineLatest(this.imageCanvas$,this.selected$).pipe(r.map(function(e){var n=m(e,2),i=n[0];return n[1].map(function(e){return t.imageIdOf(i,e)}).filter(function(e){return e!==undefined})}),r.distinctUntilChanged()),this.selectedImages$=this.selectedImageIds$.pipe(r.startWith([]),r.map(function(e){return e.map(function(e){return t.imageStoreService.currentImage(e)})}),r.distinctUntilChanged())}return e.prototype.isSelected$=function(e){return this.selected$.pipe(r.map(function(t){return t.includes(e)}))},e.prototype.isWithCanvas$=function(e){return this.withCrossLineCanvas$.pipe(r.map(function(t){return t.includes(e)}))},e.prototype.addCanvasTo=function(e){var t=s.v4();return this.componentCanvasSubject.next(v(this.componentCanvasSubject.value,[{component:e,canvas:t}])),t},e.prototype.canvasOf=function(e){return this.componentCanvas$.pipe(r.map(function(t){return t.filter(function(t){return t.component===e})}),r.map(function(e){return e.map(function(e){return e.canvas})}),r.distinctUntilChanged())},e.prototype.imageOf$=function(e){var t=this;return this.imageCanvas$.pipe(r.map(function(t){return t.find(function(t){return t.canvas===e})}),r.filter(function(e){return e!==undefined}),r.switchMap(function(e){return t.imageStoreService.image$(e.image)}))},e.prototype.viewOf$=function(e){var t=this;return this.imageCanvas$.pipe(r.map(function(t){return t.find(function(t){return t.canvas===e})}),r.filter(function(e){return e!==undefined}),r.switchMap(function(e){return t.imageStoreService.image$(e.image)}),r.map(function(e){return e.slicer.direction}))},e.prototype.select=function(e){this.selectedSubject.next([e])},e.prototype.imageIdOf=function(e,t){var n=e.find(function(e){return e.canvas===t});return n===undefined?undefined:n.image},e.prototype.mapOnCanvas=function(e,t){var n=this.imageIdOf(this.imageCanvasBindsSubject.value,e);if(n!==undefined){var i=this.imageStoreService.currentImage(n);if(i!==undefined)return t(i)}},e.prototype.loadToCanvas=function(e,t){var n=this;this.imageIdOf(this.imageCanvasBindsSubject.value,e)===undefined?this.imageStoreService.addImage(t).subscribe(function(t){return n.imageCanvasBindsSubject.next(v(n.imageCanvasBindsSubject.value,[{canvas:e,image:t}]))},function(e){return console.error(e)}):console.warn("Canvas "+e+" is already occupied, ignore new loads")},e.prototype.mapSelectedCanvas=function(e){this.selectedSubject.value.forEach(function(t){return e(t)})},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:qe}]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e(t.inject(qe))},token:e,providedIn:"root"}),e}(),Je=function(){function e(){this.zToolEntityDrag$=new i.Observable,this.zToolEntityDragSubject=new i.BehaviorSubject(10),this.whichDraging={ring:!1,line:!1,crossline:!1},this.zToolEntityDrag$=this.zToolEntityDragSubject.asObservable()}return e.prototype.zIncrease=function(){this.zToolEntityDragSubject.next(100)},e.prototype.zDecrease=function(){this.zToolEntityDragSubject.next(-100)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),Ke=function(){function e(e,n,a){this.zStoreService=e,this.entityStoreService=n,this.multiCanvasService=a,this.toolEntitySubject=new i.BehaviorSubject(new M(new o.Vector3(0,0,0),29.9,30)),this.toolModel$=this.toolEntitySubject.asObservable(),this.drag=new t.EventEmitter,this.scroll=new t.EventEmitter,this.plane$=new i.Observable,this.z$=new i.Observable,this.imageSubject=new i.BehaviorSubject(new P(new W(new o.Vector2(0,0),new o.Vector2(200,200)))),this.image$=this.imageSubject.asObservable(),this.z$=this.zStoreService.zToolEntityDrag$,this.plane$=this.image$.pipe(r.map(function(){return new P(new W(new o.Vector2(0,0),new o.Vector2(200,200)))}))}return Object.defineProperty(e.prototype,"model",{get:function(){return this.toolEntitySubject.value},set:function(e){this.toolEntitySubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.onWheelEvent=function(e){this.scroll.emit(e)},e.prototype.onDragEvent=function(e){this.drag.emit(e),console.log("drag success")},e.prototype.dragRing=function(e){var t=this;this.multiCanvasService.mapSelectedCanvas(function(n){t.entityStoreService.updateRingEntity({canvasId:n,model:new M(new o.Vector3(e.origin.x,e.origin.y,0),Math.sqrt(Math.pow(e.current.x-e.origin.x,2)+Math.pow(e.current.y-e.origin.y,2)),Math.sqrt(Math.pow(e.current.x-e.origin.x,2)+Math.pow(e.current.y-e.origin.y,2))+.001)})})},e.prototype.dragLine=function(){},e.prototype.dragCrossline=function(e){var t=this;this.multiCanvasService.mapSelectedCanvas(function(n){t.entityStoreService.crosslineOnCanvas(n,function(n){var i;switch(n.view){case"x":i=new o.Vector3(n.position.x,e.current.x,e.current.y);break;case"y":i=new o.Vector3(e.current.x,n.position.y,e.current.y);break;case"z":i=new o.Vector3(e.current.x,e.current.y,n.position.z)}t.entityStoreService.updateCrosslines({model:f({},n,{position:i})})})})},e.decorators=[{type:t.Component,args:[{selector:"ng3-tool-entity",template:'<ng-container [ngSwitch]="model.type">\n  \x3c!-- <div>\n      <ng3-ring id=\'ring\' *ngSwitchCase="\'ring\'" [model]="toolModel$ | async"></ng3-ring>\n      <p>oooooooooooooooo</p>\n  </div> --\x3e\n  <ng3-ring\n    id="ring"\n    *ngSwitchCase="\'ring\'"\n    [model]="toolModel$ | async"\n  ></ng3-ring>\n  \x3c!-- <ng3-plane *ngSwitchCase="\'ring\'" [model]="plane$ | async" [z]="z$ | async">\n    <ng3-mouse-entity (drag)="dragRing($event)"></ng3-mouse-entity>\n  </ng3-plane> --\x3e\n  <ng3-line *ngSwitchCase="\'line\'" [model]="toolModel$ | async"></ng3-line>\n  <ng3-cross-line\n    *ngSwitchCase="\'crossline\'"\n    [model]="toolModel$ | async"\n    (drag)="dragCrossline($event)"\n  ></ng3-cross-line>\n  <ng3-fov\n    *ngSwitchCase="\'fov\'"\n    [model]="toolModel$ | async"\n    [isActive]="true"\n  ></ng3-fov>\n</ng-container>\n\n\x3c!-- <ng3-ring [model]="model"></ng3-ring> --\x3e\n',styles:["p{position:absolute;line-height:.5em;color:red;font-size:10px;z-index:100}div{position:relative;z-index:10}#ring{position:absolute}"]}]}],e.ctorParameters=function(){return[{type:Je},{type:Se},{type:Ye}]},e.propDecorators={model:[{type:t.Input}],drag:[{type:t.Output}],scroll:[{type:t.Output}]},e}(),Xe=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createTexture=function(){for(var e=new Uint8Array(7500),t=new o.DataTexture(e,50,50,o.RGBFormat),n=1;n<50;n++)for(var i=1;i<50;i++){var r=3*(n+50*i);e[r]=30,e[r+1]=20,e[r+2]=20}return t.needsUpdate=!0,t},n.prototype.createEntity=function(e){var t=new o.Mesh(new o.CircleGeometry(e.radius,e.segments),new o.MeshBasicMaterial({color:16711680,wireframe:!0}));return t.name="circle",t.position.copy(e.center),t},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t.geometry=new o.CircleGeometry(e.radius,e.segments),t},n.prototype.defaultModel=function(){return new O(new o.Vector3(0,0,0),30)},n.decorators=[{type:t.Component,args:[{selector:"ng3-circle",template:"<p>\n  circle works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),Ze=function(){function e(e,t){var n=this;this.canvas=e,this.sceneService=t,this.ray=new o.Raycaster,this.stop=new i.Subject,this.hover$=this.createHover$(),this.position$=this.fromEventCurrentPosition("mousemove"),this.down$=this.fromEventCurrentPosition("mousedown"),this.downWithButton$=i.fromEvent(this.canvas.domElement,"mousedown").pipe(r.map(function(e){return{position:n.sceneService.clientPosition2ScenePosition(new o.Vector2(e.clientX,e.clientY)),original:e}})),this.up$=this.fromEventCurrentPosition("mouseup"),this.leave$=this.fromEventCurrentPosition("mouseleave"),this.wheel$=i.fromEvent(this.canvas.domElement,"mousewheel").pipe(r.map(function(e){return e.preventDefault(),{position:n.sceneService.clientPosition2ScenePosition(new o.Vector2(e.clientX,e.clientY)),delta:e.deltaY,event:e}},r.takeUntil(this.stop)))}return e.prototype.ngOnDestroy=function(){this.stop.next(),this.stop.complete()},e.prototype.fromEventCurrentPosition=function(e){var t=this;return i.fromEvent(this.canvas.domElement,e).pipe(r.map(function(e){return new o.Vector2(e.clientX,e.clientY)}),r.map(function(e){return t.sceneService.clientPosition2ScenePosition(e)}),r.takeUntil(this.stop))},e.prototype.createHover$=function(){return i.merge(i.fromEvent(this.canvas.domElement,"mouseenter").pipe(r.mapTo(!0)),i.fromEvent(this.canvas.domElement,"mouseleave").pipe(r.mapTo(!1))).pipe(r.takeUntil(this.stop))},e.prototype.intersectObject=function(e,t,n){return this.ray.set(e,t),this.ray.intersectObjects(n!==undefined?[n]:this.sceneService.scene.children)},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:X},{type:Z}]},e}();function Qe(e,t){return Math.max(t.min,Math.min(t.max,e))}function et(e,t,n,i){return e instanceof o.OrthographicCamera?t(e):e instanceof o.PerspectiveCamera?n(e):i(e)}var tt={LEFT:o.MOUSE.LEFT,MIDDLE:o.MOUSE.MIDDLE,RIGHT:o.MOUSE.RIGHT},nt=function(){function e(e,n,a){var s=this;this.canvasService=e,this.rendererService=n,this.mouse=a,this.enabled=!0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.change=new t.EventEmitter,this.zoomRange={min:0,max:Infinity},this.domElement=this.canvasService.domElement,this.rotate=new ot(this,this.rotateSpeed,this.autoRotateSpeed),this.dolly=new at(this),this.pan=new rt(this,this.panSpeed),this.target=new o.Vector3,this.state="none",this.scale=1,this.zoomChanged=!1,this.position=new o.Vector3,this.zoom=1,this.target0=this.target.clone(),this.position0=this.position.clone(),this.zoom0=1,this.stop=new i.Subject,this.mouse.downWithButton$.pipe(r.takeUntil(this.stop)).subscribe(function(e){switch(console.log(s.camera.position),e.original.preventDefault(),e.original.button){case tt.LEFT:if(!1===s.enableRotate)return;s.rotate.activate(),s.rotate.onMouseDown(e.position),s.state="busy";break;case o.MOUSE.RIGHT:s.pan.activate(),s.pan.onMouseDown(e.position),s.state="busy";case o.MOUSE.MIDDLE:s.dolly.activate(),s.dolly.onMouseDown(e.position),s.state="busy"}},function(e){return console.error(e)}),this.mouse.position$.pipe(r.takeUntil(this.stop)).subscribe(function(e){s.rotate.onMouseMove(e),s.pan.onMouseMove(e),s.dolly.onMouseMove(e)},function(e){return console.error(e)}),this.mouse.up$.pipe(r.takeUntil(this.stop)).subscribe(function(){s.rotate.deactivate(),s.pan.deactivate(),s.dolly.deactivate(),s.state="none"},function(e){return console.error(e)}),this.mouse.wheel$.pipe(r.takeUntil(this.stop)).subscribe(function(e){s.dolly.activate(),s.dolly.onMOuseWheel(),s.state="dolly"},function(e){return console.log(e)})}return Object.defineProperty(e.prototype,"camera",{get:function(){var e=this.rendererService.camera;if(e===undefined)throw Error("Camera is not exist");return e},enumerable:!0,configurable:!0}),e.prototype.saveState=function(){this.target0.copy(this.target),this.position0.copy(this.camera.position),this.zoom0=this.zoom},e.prototype.reset=function(){this.target.copy(this.target0),this.camera.position.copy(this.position0),this.camera.zoom=this.zoom0,this.camera.updateProjectionMatrix(),this.update()},e.prototype.update=function(){var e=new o.Vector3,t=(new o.Quaternion).setFromUnitVectors(this.camera.up,new o.Vector3(0,1,0)),n=t.clone().inverse(),i=new o.Vector3,r=new o.Quaternion,a=this.camera.position;return e.copy(a).sub(this.target),e.applyQuaternion(t),this.rotate.update(e,this.target),this.pan.update(e,this.target),e.applyQuaternion(n),a.copy(this.target).add(e),this.camera.lookAt(this.target),this.scale=1,this.rendererService.setCamera(this.camera),this.rendererService.render(),!!(this.zoomChanged||i.distanceToSquared(this.camera.position)>1e-6||8*(1-r.dot(this.camera.quaternion))>1e-6)&&(this.change.emit(),i.copy(this.camera.position),r.copy(this.camera.quaternion),this.zoomChanged=!1,!0)},Object.defineProperty(e.prototype,"autoRotationAngle",{get:function(){return 2*Math.PI/60/60*this.autoRotateSpeed},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngOnDestroy=function(){},e.prototype.ngAfterViewInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-orbit-controls",template:"",styles:[""]}]}],e.ctorParameters=function(){return[{type:X},{type:te},{type:Ze}]},e.propDecorators={enabled:[{type:t.Input}],enableDamping:[{type:t.Input}],dampingFactor:[{type:t.Input}],enableZoom:[{type:t.Input}],zoomSpeed:[{type:t.Input}],enableRotate:[{type:t.Input}],rotateSpeed:[{type:t.Input}],enablePan:[{type:t.Input}],panSpeed:[{type:t.Input}],screenSpacePanning:[{type:t.Input}],keyPanSpeed:[{type:t.Input}],autoRotate:[{type:t.Input}],autoRotateSpeed:[{type:t.Input}],enableKeys:[{type:t.Input}],change:[{type:t.Output}]},e}(),it=function(){function e(e){this.controller=e,this._activated=!1,this.start=new o.Vector2,this.end=new o.Vector2,this.delta=new o.Vector2}return Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!0,configurable:!0}),e.prototype.activate=function(){this._activated=!0},e.prototype.deactivate=function(){this._activated=!1},e.prototype.onMouseDown=function(e){this.activated&&this.start.set(e.x,e.y)},e.prototype.onMouseUp=function(){this.deactivate()},e}(),ot=function(e){function t(t,n,i){var r=e.call(this,t)||this;return r.speed=n,r.autoRotateSpeed=i,r.polarAngleRange={min:0,max:Math.PI},r.azimuthAngleRange={min:-Infinity,max:Infinity},r.distanceRange={min:0,max:Infinity},r.spherical=new o.Spherical,r.sphericalDelta=new o.Spherical,r}return d(t,e),Object.defineProperty(t.prototype,"polarAngle",{get:function(){return this.spherical.phi},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"azimuthalAngle",{get:function(){return this.spherical.theta},enumerable:!0,configurable:!0}),t.prototype.update=function(e,t){this.spherical.setFromVector3(e),this.autoRotate&&"none"===this.controller.state&&this.autoRotate(),this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi,this.spherical.theta=Qe(this.spherical.theta,this.azimuthAngleRange),this.spherical.phi=Qe(this.spherical.phi,this.polarAngleRange),this.spherical.makeSafe(),this.spherical.radius*=this.controller.scale,this.spherical.radius=Qe(this.spherical.radius,this.distanceRange),e.setFromSpherical(this.spherical),this.controller.enableDamping?(this.sphericalDelta.theta*=1-this.controller.dampingFactor,this.sphericalDelta.phi*=1-this.controller.dampingFactor):this.sphericalDelta.set(0,0,0)},t.prototype.autoRotate=function(){this.rotateLeft(this.autoRotateSpeed)},t.prototype.onMouseMove=function(e){if(this.activated){this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.start).multiplyScalar(this.speed);var t=this.controller.domElement;this.rotateLeft(2*Math.PI*this.delta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.delta.y/t.clientHeight),this.start.copy(this.end),this.controller.update()}},t.prototype.rotateLeft=function(e){this.sphericalDelta.theta-=e},t.prototype.rotateUp=function(e){this.sphericalDelta.phi-=e},t}(it),rt=function(e){function t(t,n){var i=e.call(this,t)||this;return i.speed=n,i.offset=new o.Vector3,i}return d(t,e),t.prototype.update=function(e,t){t.add(this.offset),!0===this.controller.enableDamping?this.offset.multiplyScalar(1-this.controller.dampingFactor):this.offset.set(0,0,0)},t.prototype.onMouseWheel=function(){},t.prototype.onMouseMove=function(e){this.activated&&(this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.start).multiplyScalar(this.speed),this.pan(this.delta.x,this.delta.y),this.start.copy(this.end),this.controller.update())},t.prototype.panLeft=function(e,t){var n=new o.Vector3;n.setFromMatrixColumn(t,0),n.multiplyScalar(-e),this.offset.add(n)},t.prototype.panUp=function(e,t){var n=new o.Vector3;!0===this.controller.screenSpacePanning?n.setFromMatrixColumn(t,1):(n.setFromMatrixColumn(t,0),n.crossVectors(this.controller.camera.up,n)),n.multiplyScalar(e),this.offset.add(n)},t.prototype.pan=function(e,t){var n=this,i=new o.Vector3,r=this.controller.domElement;et(this.controller.camera,function(i){n.panLeft(e*(i.right-i.left)/i.zoom/r.clientWidth,i.matrix),n.panUp(t*(i.top-i.bottom)/i.zoom/r.clientHeight,i.matrix)},function(o){var a=o.position;i.copy(a).sub(n.controller.target);var s=i.length();s*=Math.tan(o.fov/2*Math.PI/180),n.panLeft(2*e*s/r.clientHeight,o.matrix),n.panUp(2*t*s/r.clientHeight,o.matrix)},function(){console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.controller.enablePan=!1})},t}(it),at=function(e){function t(t){var n=e.call(this,t)||this;return n.range={min:0,max:Infinity},n.changed=!1,n}return d(t,e),Object.defineProperty(t.prototype,"zoomChanged",{get:function(){return this.changed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomScale",{get:function(){return Math.pow(.95,this.controller.zoomSpeed)},enumerable:!0,configurable:!0}),t.prototype.onMouseMove=function(e){this.activated&&(this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.start),this.delta.y>0?this.dollyIn(this.zoomScale):this.delta.y<0&&this.dollyOut(this.zoomScale),this.start.copy(this.end),this.controller.update())},t.prototype.onMOuseWheel=function(){this.activated&&(this.delta.subVectors(this.end,this.start),this.delta.x>0?this.dollyIn(this.zoomScale):this.delta.x<0&&this.dollyOut(this.zoomScale),this.controller.update())},t.prototype.dollyIn=function(e){var t=this;et(this.controller.camera,function(n){n.zoom=Qe(n.zoom*e,t.range),n.updateProjectionMatrix(),t.changed=!0},function(){t.controller.scale/=e},function(){console.warn("WARNING: OrbitControls encountered an unknown camera type - dolly/zoom disabled."),t.controller.enableZoom=!1})},t.prototype.dollyOut=function(e){var t=this;et(this.controller.camera,function(n){n.zoom=Qe(n.zoom/e,t.range),n.updateProjectionMatrix(),t.changed=!0},function(){t.controller.scale*=e},function(){console.warn("WARNING: OrbitControls encountered an unknown camera type - dolly/zoom disabled."),t.controller.enableZoom=!1})},t}(it),st=function(){function e(e,n){var i=this;this.scene=e,this.renderer=n,this.camera=new o.PerspectiveCamera(45,this.size.left/this.size.bottom,.01,1e10),this.changed=new t.EventEmitter,this.z=100,this.camera.position.z=this.z,this.camera.lookAt(this.scene.scene.position),this.scene.size$.subscribe(function(e){return i.updateCameraFov(e)},function(e){return console.error(e)})}return Object.defineProperty(e.prototype,"size",{get:function(){return this.scene.size},set:function(e){this.scene.resize(e)},enumerable:!0,configurable:!0}),e.prototype.updateCameraFov=function(e){this.camera.fov=50,this.camera.aspect=e.left/e.bottom,this.camera.near=1,this.camera.far=1,this.changed.emit(),this.renderer.render()},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-perspective-camera",template:"<p>\n  perspective-camera works!\n</p>\n",styles:[""]}]}],e.ctorParameters=function(){return[{type:Z},{type:te}]},e.propDecorators={changed:[{type:t.Output}],size:[{type:t.Input}],z:[{type:t.Input}]},e}(),ct=function(){function e(e,n){var i=this;this.scene=e,this.renderer=n,this.camera=new o.OrthographicCamera(this.size.left,this.size.right,this.size.top,this.size.bottom),this.changed=new t.EventEmitter,this.z=100,console.log(this.x),this.camera.position.z=this.z,this.scene.size$.subscribe(function(e){return i.updateCameraSize(e)},function(e){return console.error(e)})}return Object.defineProperty(e.prototype,"size",{get:function(){return this.scene.size},set:function(e){this.scene.resize(e)},enumerable:!0,configurable:!0}),e.prototype.updateCameraSize=function(e){this.camera.bottom=e.bottom,this.camera.top=e.top,this.camera.left=e.left,this.camera.right=e.right,this.camera.zoom=1,this.camera.updateProjectionMatrix(),this.changed.emit(),this.renderer.render()},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-orthographic-camera",template:""}]}],e.ctorParameters=function(){return[{type:Z},{type:te}]},e.propDecorators={changed:[{type:t.Output}],size:[{type:t.Input}],z:[{type:t.Input}],x:[{type:t.Input}]},e}(),ut=function(){function e(e,t,n,i,o){this.elRef=e,this.scene=t,this.canvasService=n,this.renderer=i,this.mouse=o,this.debug=!1,this.diagnosis=!1,this.elRef.nativeElement.appendChild(this.renderer.domElement)}return Object.defineProperty(e.prototype,"size",{get:function(){return this.canvasService.size.size},set:function(e){this.canvasService.size=new W(new o.Vector2(0,0),e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"camera",{get:function(){return this.perspectiveCamera!==undefined?this.perspectiveCamera.camera:this.orthographicCamera!==undefined?this.orthographicCamera.camera:undefined},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controls",{get:function(){return this.orbitControls!==undefined?this.orbitControls.camera:undefined},enumerable:!0,configurable:!0}),e.prototype.render=function(){this.renderer.render()},e.prototype.ngOnInit=function(){if(this.debug){var e=new o.AxesHelper(1);this.scene.add(e),this.render()}},e.prototype.ngOnDestroy=function(){},e.prototype.ngAfterViewInit=function(){if(this.camera===undefined)throw Error("Camera is undefined");this.renderer.setCamera(this.camera),this.render()},e.prototype.logScene=function(){console.log(this.scene),console.log(this.camera),console.log(this.renderer.domElement),console.log(this.renderer.domElement.getBoundingClientRect())},e.decorators=[{type:t.Component,args:[{selector:"ng3-canvas",template:'\x3c!--<div class="canvas">--\x3e\n  \x3c!-- <canvas #canvas></canvas> --\x3e\n  \x3c!-- <div [hidden]="!debug"></div>\n  <div class="patient"><ng-content select=".patient"></ng-content></div>\n  <div class="hospital"><ng-content select=".hospital"></ng-content></div>\n  <div class="physics"><ng-content select=".physics"></ng-content></div>\n  <div class="scale"><ng-content select=".scale"></ng-content></div>\n  <div class="zoom"><ng-content select=".zoom"></ng-content></div> --\x3e\n  \x3c!-- <ng-content id="patient" select=".patient"></ng-content>\n  <ng-content id="hospital" select=".hospital"></ng-content>\n  <ng-content id="physics" select=".physics"></ng-content>\n  <ng-content id"scale" select=".scale"></ng-content>\n  <ng-content id="zoom" select=".zoom"></ng-content> --\x3e\n  <div *ngIf="debug">\n    <button (click)="render()">forceRender</button>\n    <button (click)="logScene()">Log Scene</button>\n  </div>\n\x3c!--</div>--\x3e\n',providers:[Z,X,te,Ze],styles:[".wrap{position:relative;top:0;left:0;width:300px;height:300px;z-index:0}#ct,#patient{position:absolute;top:5%;left:5%;z-index:1}#hospital{position:absolute;top:5%;left:80%;width:15%;z-index:1}#scale{position:absolute;top:40%;left:25%;height:20%;z-index:1}#physics{position:absolute;top:75%;left:5%;width:15%;height:20%;z-index:1}#zoom{position:absolute;top:75%;left:80%;width:15%;height:20%}"]}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:Z},{type:X},{type:te},{type:Ze}]},e.propDecorators={size:[{type:t.Input}],htmlCanvas:[{type:t.ViewChild,args:["canvas"]}],orthographicCamera:[{type:t.ContentChild,args:[ct]}],perspectiveCamera:[{type:t.ContentChild,args:[st]}],orbitControls:[{type:t.ContentChild,args:[nt]}]},e}(),lt=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){var t=new o.Geometry;if(t.vertices.push(e.start),t.vertices.push(e.end),"Dashed"===e.style){var n=new o.LineDashedMaterial({color:e.color,linewidth:2,scale:1,dashSize:.5,gapSize:.25}),i=new o.Line(t,n);return i.computeLineDistances(),i}n=new o.LineBasicMaterial({color:e.color});return new o.Line(t,n)},n.prototype.defaultModel=function(){return new T(new o.Vector3(0,0,0),new o.Vector3(100,100,100))},n.prototype.updateEntity=function(e,t){var n;return(n=t.geometry).vertices[0].copy(e.start),n.vertices[1].copy(e.end),n.verticesNeedUpdate=!0,t},n.decorators=[{type:t.Component,args:[{selector:"ng3-line",template:"<ng-content></ng-content>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),pt=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i.rotationSpeed=.02,i.bouncingSpeed=.03,i}return d(n,e),n.prototype.createEntity=function(e){var t=new o.Mesh(new o.CubeGeometry(1,1,1),new o.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.5,wireframe:!0}));return t.name="Cube",t.position.copy(e.center),t.scale.copy(e.size),t.rotation.x=Math.PI/4,t.rotation.y=Math.PI/4,t.rotation.z=Math.PI/4,t},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t.scale.copy(e.size),t},n.prototype.defaultModel=function(){return new D(new o.Vector3(100,100,100),new o.Vector3(0,0,0),new o.Vector3(0,0,0))},n.decorators=[{type:t.Component,args:[{selector:"ng3-cube",template:"<ng-content></ng-content>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de);function ht(e){return{provide:de,useExisting:t.forwardRef(function(){return e})}}var dt=function(e){function n(t,n){var o=e.call(this,t,n)||this;return o.zSubject=new i.BehaviorSubject(-100),o}return d(n,e),Object.defineProperty(n.prototype,"z",{get:function(){return this.zSubject.value},set:function(e){this.zSubject.next(e)},enumerable:!0,configurable:!0}),n.prototype.createTexture=function(e){for(var t=new Uint8Array(3*e.shape.x*e.shape.y),n=new o.DataTexture(t,e.shape.x,e.shape.y,o.RGBFormat),i=0;i<e.shape.x;i++)for(var r=0;r<e.shape.y;r++){var a=i*e.shape.y+r,s=3*(i+r*e.shape.x);t[s]=e.r[a],t[s+1]=e.g[a],t[s+2]=e.b[a]}return n.needsUpdate=!0,n},n.prototype.createEntity=function(e){var t=e.textureData===undefined?undefined:this.createTexture(e.textureData),n=t!==undefined?undefined:e.color!==undefined?e.color:new o.Color(.5,.5,.5),i={side:o.DoubleSide,wireframe:e.wireFrame!==undefined&&e.wireFrame,opacity:e.opacity===undefined?1:e.opacity,transparent:e.transparent!==undefined&&e.transparent},r=e.rotation===undefined?new o.Vector3(0,0,0):e.rotation,a=new o.Mesh(new o.PlaneGeometry(1,1,1,1),new o.MeshBasicMaterial(t!==undefined?f({},i,{map:t}):f({},i,{color:n})));return a.position.set(e.box.center.x,e.box.center.y,this.z),a.scale.set(e.box.size.x,e.box.size.y,1),a.rotation.set(r.x,r.y,r.z),a.renderOrder=this.z,a},n.prototype.updateEntity=function(e,t){return e.textureData!==undefined&&this.changeTexture(t,e.textureData),t.material.setValues({wireframe:e.wireFrame,transparent:e.transparent,opacity:e.opacity}),t.material.needsUpdate=!0,t.position.set(e.box.center.x,e.box.center.y,this.z),t.scale.set(e.box.size.x,e.box.size.y,1),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.renderOrder=this.z,t},n.prototype.changeTexture=function(e,t){e.material.setValues({map:this.createTexture(t)})},n.prototype.defaultModel=function(){return new P(new W(new o.Vector2(0,0),new o.Vector2(100,100)),10,{r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)})},n.decorators=[{type:t.Component,args:[{selector:"ng3-plane",template:"<ng-content></ng-content>\n",providers:[ht(n)],styles:["./plane.component.css"]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n.propDecorators={z:[{type:t.Input}]},n}(de),ft=function(){function e(e,t){var n=this;this.mouseCanvas=e,this.entity2=t,this.stop=new i.Subject,this.cameraDirection=new o.Vector3,this.down$=this.createDown$(),this.click$=this.createClick$(),this.drag$=this.createDrag$(),this.hover$=this.mouseCanvas.position$.pipe(r.map(function(e){return n.isOnThisEntity(e)}),r.distinctUntilChanged(),r.takeUntil(this.stop)),this.wheel$=this.createWheel$()}return e.prototype.createClick$=function(){var e=this;return this.down$.pipe(r.switchMap(function(){return i.merge(e.mouseCanvas.up$,e.mouseCanvas.leave$).pipe(r.map(function(t){return!!e.isOnThisEntity(t)}))}),r.filter(function(e){return!!e}),r.map(i.noop))},e.prototype.createDown$=function(){var e=this;return this.mouseCanvas.down$.pipe(r.filter(function(t){return e.isOnThisEntity(t)}),r.takeUntil(this.stop))},e.prototype.createWheel$=function(){var e=this;return this.mouseCanvas.wheel$.pipe(r.filter(function(t){return e.isOnThisEntity(t.position)}),r.takeUntil(this.stop))},e.prototype.isOnThisEntity=function(e){if(this.entity2.entity===undefined)return!1;var t;this.camera===undefined?t=new o.Vector3(0,0,-1):(this.camera.getWorldDirection(this.cameraDirection),t=this.cameraDirection);var n=this.mouseCanvas.intersectObject(new o.Vector3(e.x,e.y,100),t);return 0!==n.length&&n[0].object.uuid===this.entity2.entity.uuid},e.prototype.createDrag$=function(){var e=this,t=i.merge(this.mouseCanvas.up$,this.mouseCanvas.leave$);return this.down$.pipe(r.switchMap(function(n){var i=e.entity2.entity===undefined?new o.Vector2(0,0):new o.Vector2(e.entity2.entity.position.x,e.entity2.entity.position.y),a=new o.Vector2(n.x-i.x,n.y-i.y);return e.mouseCanvas.position$.pipe(r.map(function(e){return{origin:n,current:e,relativeCenter:new o.Vector2(e.x-a.x,e.y-a.y)}}),r.takeUntil(t))}),r.takeUntil(this.stop))},e.prototype.ngOnDestroy=function(){this.stop.next(),this.stop.complete()},e.prototype.setCamera=function(e){this.camera=e},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:Ze},{type:de,decorators:[{type:t.Optional}]}]},e}(),mt=function(){function e(e,n){var i=this;this.mouse=e,this.entity2=n,this.click=new t.EventEmitter,this.drag=new t.EventEmitter,this.hover=new t.EventEmitter,this.wheel=new t.EventEmitter,this.mouse.click$.subscribe(function(){i.entity2.entity!==undefined&&i.click.emit(i.entity2.entity)},function(e){return console.error(e)}),this.mouse.drag$.subscribe(function(e){i.drag.emit(e)},function(e){return console.error(e)}),this.mouse.hover$.pipe().subscribe(function(e){i.hover.emit(e)},function(e){return console.error(e)}),this.mouse.wheel$.subscribe(function(e){return i.wheel.emit(e)},function(e){return console.error(e)})}return e.prototype.ngOnInit=function(){},e.prototype.ngOnDestroy=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-mouse-entity",template:"",providers:[ft],styles:[""]}]}],e.ctorParameters=function(){return[{type:ft},{type:de,decorators:[{type:t.Optional}]}]},e.propDecorators={click:[{type:t.Output}],drag:[{type:t.Output}],hover:[{type:t.Output}],wheel:[{type:t.Output}]},e}(),vt=function(){function e(){}return e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"ng3-controls",template:"<ng-content></ng-content>\n",providers:[ft],styles:[""]}]}],e.ctorParameters=function(){return[]},e}(),yt=function(){function e(){var e=this;this.edgeDirections=["left","right","top","bottom"],this.cornerDirections=[{x:"left",y:"top"},{x:"right",y:"top"},{x:"left",y:"bottom"},{x:"right",y:"bottom"}],this.modelSubject=new i.BehaviorSubject(wt),this.model$=this.modelSubject.asObservable(),this.models$=this.model$.pipe(r.map(function(t){return{main:t,bars:e.createBars(t),corners:e.createCorners(t)}})),this.initialied=!1,this.z=1,this.mainTexture=_t,this.barTexture=St,this.resizeEdge=new t.EventEmitter,this.resizeCorner=new t.EventEmitter}return Object.defineProperty(e.prototype,"model",{get:function(){return this.modelSubject.value},set:function(e){this.modelSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.createBars=function(e){var t=this,n={};return this.edgeDirections.forEach(function(i){var r,a,s,c;n[i]=(r=e,a=i,s=t.barTexture,c=function(e){return gt(a,e,r)},new P(new W(new o.Vector2(r.box.center.x+c("x"),r.box.center.y+c("y")),bt(a,r,"edge")),10,s,new o.Vector3(0,0,0),!0,1))}),n},e.prototype.createCorners=function(e){return this.cornerDirections.map(function(t){return{direction:t,model:xt(e,t,Ct)}})},e.prototype.onDragBar=function(e,t){this.resizeEdge.emit({type:"edge",direction:t,to:"left"===t||"right"===t?e.relativeCenter.x:e.relativeCenter.y})},e.prototype.onResizeEdge=function(e){this.resizeEdge.emit(e)},e.prototype.onResizeCorner=function(e){this.resizeCorner.emit(e)},e.prototype.onDragCorner=function(e,t){this.resizeCorner.emit({type:"corner",direction:t,to:e.relativeCenter})},e.prototype.modelOf=function(e,t){var n=t.find(function(t){return t.direction===e});if(n===undefined)throw Error("Can not find corner model of direction: "+e.x+" "+e.y);return n.model},e.decorators=[{type:t.Component,args:[{selector:"ng3-resize-plane",template:'<ng-container *ngIf="(models$ | async) as models">\n  <ng3-resize-plane-edge\n    *ngFor="let d of edgeDirections"\n    [model]="models.bars[d]"\n    [direction]="d"\n    [z]="z + 1"\n    (resize)="onResizeEdge($event)"\n  >\n  </ng3-resize-plane-edge>\n  <ng3-resize-plane-corner\n    *ngFor="let d of cornerDirections"\n    [model]="modelOf(d, models.corners)"\n    [direction]="d"\n    [z]="z + 2"\n    (resize)="onResizeCorner($event)"\n  >\n  </ng3-resize-plane-corner>\n</ng-container>\n',changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={model:[{type:t.Input}],z:[{type:t.Input}],mainTexture:[{type:t.Input}],barTexture:[{type:t.Input}],resizeEdge:[{type:t.Output}],resizeCorner:[{type:t.Output}]},e}();function gt(e,t,n){switch(e){case"left":return"x"===t?-n.box.size.x/2:0;case"right":return"x"===t?n.box.size.x/2:0;case"top":return"y"===t?-n.box.size.y/2:0;case"bottom":return"y"===t?n.box.size.y/2:0}}function bt(e,t,n){if("edge"===n)switch(e){case"left":case"right":return new o.Vector2(.2*t.box.size.x,t.box.size.y);case"top":case"bottom":return new o.Vector2(t.box.size.x,.2*t.box.size.y)}return new o.Vector2(.2*t.box.size.x,.2*t.box.size.y)}function xt(e,t,n){return new P(new W(new o.Vector2(e.box.center.x+gt(t.x,"x",e),e.box.center.y+gt(t.y,"y",e)),bt(t.x,e,"corner")),10,n,new o.Vector3(0,0,0),!0,.8)}var wt=new P(new W(new o.Vector2(0,0),new o.Vector2(10,10)),10,{r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)}),_t={r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)},St={r:new Uint8Array([128]),g:new Uint8Array([128]),b:new Uint8Array([128]),shape:new o.Vector2(1,1)},Ct={r:new Uint8Array([64]),g:new Uint8Array([64]),b:new Uint8Array([64]),shape:new o.Vector2(1,1)},It=function(){function e(e){this.canvas=e,this.model=zt,this.drag=new t.EventEmitter}return e.prototype.ngOnInit=function(){},e.prototype.onDrag=function(e){this.drag.emit(e)},e.prototype.setStyle=function(e){this.canvas.domElement.style.cursor=e?"move":"auto"},e.decorators=[{type:t.Component,args:[{selector:"ng3-move-plane",template:'<ng3-plane #main [model]="model">\n  <ng-content></ng-content>\n  <ng3-mouse-entity\n    (drag)="onDrag($event)"\n    (hover)="setStyle($event)"\n  ></ng3-mouse-entity>\n</ng3-plane>\n\n\x3c!-- app.html --\x3e\n\x3c!-- <move-plane>\n  <ng3-mouse-entity (drag)=""></ng3-mouse-entity>\n<move-plane>\n\n\n    <move-plane>\n      <ng3-plane>\n          <ng3-mouse-entity (drag)=""></ng3-mouse-entity>\n      </ng3-plane>\n\n    <move-plane> --\x3e\n\x3c!-- app.html --\x3e\n\x3c!-- <ng3-plane (drag)=""></ng3-plane> --\x3e\n',styles:[""]}]}],e.ctorParameters=function(){return[{type:X}]},e.propDecorators={model:[{type:t.Input}],drag:[{type:t.Output}]},e}(),Pt={r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)},zt=new P(new W(new o.Vector2(0,0),new o.Vector2(10,10)),10,Pt),Dt=function(){function e(e){this.canvas=e,this.direction="top",this.z=1,this.resize=new t.EventEmitter}return e.prototype.ngOnInit=function(){if(this.model===undefined)throw Error("Model is not provided")},e.prototype.ngOnDestroy=function(){},e.prototype.setStyle=function(e){this.canvas.domElement.style.cursor=e?this.cursorStyle():"auto"},e.prototype.cursorStyle=function(){switch(this.direction){case"top":case"bottom":return"ns-resize";case"left":case"right":return"ew-resize"}},e.prototype.onDrag=function(e,t){this.resize.emit({type:"edge",direction:this.direction,to:"left"===this.direction||"right"===this.direction?e.relativeCenter.x:e.relativeCenter.y})},e.decorators=[{type:t.Component,args:[{selector:"ng3-resize-plane-edge",template:'<ng3-plane [model]="model" [z]="z">\n  <ng3-mouse-entity\n    (drag)="onDrag($event, direction)"\n    (hover)="setStyle($event)"\n  ></ng3-mouse-entity>\n</ng3-plane>\n',styles:[""]}]}],e.ctorParameters=function(){return[{type:X}]},e.propDecorators={model:[{type:t.Input}],direction:[{type:t.Input}],z:[{type:t.Input}],resize:[{type:t.Output}]},e}(),Vt=function(){function e(e){this.canvas=e,this.direction={x:"right",y:"top"},this.z=1,this.resize=new t.EventEmitter}return e.prototype.ngOnInit=function(){if(this.model===undefined)throw Error("Model is not provided")},e.prototype.ngOnDestroy=function(){},e.prototype.setStyle=function(e){this.canvas.domElement.style.cursor=e?this.cursorStyle():"auto"},e.prototype.cursorStyle=function(){if("left"===this.direction.x&&"top"===this.direction.y)return"nwse-resize";if("right"===this.direction.x&&"top"===this.direction.y)return"nesw-resize";if("left"===this.direction.x&&"bottom"===this.direction.y)return"nesw-resize";if("right"===this.direction.x&&"bottom"===this.direction.y)return"nwse-resize";throw Error("Invalid corner direction")},e.prototype.onDrag=function(e,t){this.resize.emit({type:"corner",direction:this.direction,to:e.relativeCenter})},e.decorators=[{type:t.Component,args:[{selector:"ng3-resize-plane-corner",template:'<ng3-plane [model]="model" [z]="z" *ngIf="model">\n  <ng3-mouse-entity\n    (drag)="onDrag($event, direction)"\n    (hover)="setStyle($event)"\n  ></ng3-mouse-entity>\n</ng3-plane>\n',styles:[""]}]}],e.ctorParameters=function(){return[{type:X}]},e.propDecorators={model:[{type:t.Input}],direction:[{type:t.Input}],z:[{type:t.Input}],resize:[{type:t.Output}]},e}(),Ot=[{id:"testLine",model:new T(new o.Vector3(0,0,0),new o.Vector3(40,0,0))},{id:"testPlane",model:new P(new W(new o.Vector2(0,0),new o.Vector2(10,10)),10,{r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)})},{id:"testImage",model:new P(new W(new o.Vector2(0,0),new o.Vector2(10,10)),10,{r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)})}],Mt=function(){function e(e){var t=this;this.nextImage$=new i.Subject,this.models=new Fe,Ot.forEach(function(e){return t.models.insert(f({id:e.id},e.model)).subscribe()})}return e.prototype.currentModels=function(){return this.models.currentState()},e.prototype.getModel$=function(e,t){return this.models.get$({id:t}).pipe(r.filter(function(t){return t.type===e}),r.map(function(e){return e}))},e.prototype.addModel=function(e,t){var n,o=this;return console.log("add model",e),n=t===undefined?s.v4():t,new i.Observable(function(t){o.models.insert(f({id:n},e)).subscribe(i.noop,t.error,function(){return t.next(n)})}).pipe(r.first(),r.share())},e.prototype.update=function(e){return this.models.update(e)},e.prototype.testLine=function(){var e=this;function t(e){return new T(new o.Vector3(-10,e,0),new o.Vector3(10,e,0))}return this.addModel(t(0)).pipe(r.switchMap(function(n){return i.interval(100).pipe(r.map(function(e){return 30*Math.sin(e/20)}),r.map(function(e){return f({id:n},t(e))},r.switchMap(function(t){return e.update(t)})))}))},e.prototype.testSequenceImage=function(){return J(new o.Vector2(10,20),new o.Vector2(10,20),new o.Vector2(0,0),this.nextImage$)},e.prototype.testWebSocketLine=function(){},e.ctorParameters=function(){return[{type:ut,decorators:[{type:t.Optional}]}]},e}(),jt=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){var t=new o.Mesh(new o.SphereGeometry(e.radius,e.widthSegments,e.heightSegments),new o.MeshBasicMaterial({color:16711680}));return t.name="Sphere",t.position.copy(e.center),t},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t},n.prototype.defaultModel=function(){return new V(new o.Vector3(0,0,0),20,32,32,0,2*Math.PI,0,0)},n.decorators=[{type:t.Component,args:[{selector:"ng3-sphere",template:"<p>\n  sphere works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),Lt=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){var t=new o.Mesh(new o.RingGeometry(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments),new o.MeshNormalMaterial({side:o.DoubleSide,wireframe:!0}));return t.name="ring",t.position.copy(e.center),t},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t.geometry=new o.RingGeometry(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments),t},n.prototype.defaultModel=function(){return new M(new o.Vector3(0,0,0),29.9,30)},n.decorators=[{type:t.Component,args:[{selector:"ng3-ring",template:"<ng-content></ng-content>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),Tt=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){var t=new o.OBJLoader,n=new o.Group;return t.load("../../../../../resource/ceberus/Cebrus.obj",function(t){t.position.copy(e.center),n=t}),n},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t},n.prototype.defaultModel=function(){return new F(new o.Vector3(0,0,0))},n.decorators=[{type:t.Component,args:[{selector:"ng3-obj-loader",template:"<p>\n  obj-loader works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),Ft=function(){function e(e){this.isRecordingPoints=!1,this.isRecordingFaces=!1,this.points=[],this.indexes=[],this.isRecordingAngles=!1,this.isRecordingColors=!1,this.angles=[],this.colors=[],this.crossOrigin="anonymous",this.defines={},this.index=[],this.float_pattern=/(\b|\-|\+)([\d\.e]+)/,this.float2_pattern=/([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g,this.float3_pattern=/([\d\.\+\-e]+)\s+([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g,this.textureLoader=new o.TextureLoader(this.manager),this.manager=o.DefaultLoadingManager}return e.prototype.load=function(e,t,n,i){var r=this,a=this.path===undefined?o.LoaderUtils.extractUrlBase(e):this.path,s=new o.FileLoader(this.manager);s.setPath(this.path),s.load(e,function(e){t(r.parse(e,a))},n,i)},e.prototype.setPath=function(e){this.path=e},e.prototype.parse=function(e,t){console.log("run parse"),this.textureLoader.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),this.scene=new o.Scene,this.lines=e.split("\n");for(var n=this.lines.length-1;n>-1;n--){var i=this.lines[n];if(i=i.replace(/(#.*)/,""),/{.*[{\[]/.test(i)){var r=v([1,n],a=i.split("{").join("{\n").split("\n"));console.log("parts: ",a),this.lines.splice.apply(this.lines,r)}else if(/\].*}/.test(i)){r=v([1,n],a=i.split("]").join("]\n").split("\n"));console.log("parts: ",a),this.lines.splice.apply(this.lines,r)}if(/}.*}/.test(i)){var a;r=v([1,n],a=i.split("}").join("}\n").split("\n"));console.log("parts: ",a),this.lines.splice.apply(this.lines,r)}/^\b[^\s]+\b$/.test(i.trim())?(this.lines[n+1]=i+" "+this.lines[n+1].trim(),this.lines.splice(n,1)):i.indexOf("coord")>-1&&i.indexOf("[")<0&&i.indexOf("{")<0&&(this.lines[n]+="Coordinate {}")}var s=this.lines.shift();return/V1.0/.exec(s)?console.warn("THREE.VRMLLoader: V1.0 not supported yet."):/V2.0/.exec(s)&&this.parseV2(this.lines,this.scene),this.scene},e.prototype.setResuorcePath=function(e){this.resourcePath=e},e.prototype.setCrossOrigin=function(e){this.crossOrigin=e},e.prototype.setMaterials=function(e){},e.prototype._createParserState=function(){},e.prototype.parseV2=function(e,t){console.log("run parseV2"),this.parseNode(this.getTree(e),t)},e.prototype.paintFaces=function(e,t,n,i,r){for(var a=!0===r?1:-1,s=[],c=new o.Vector2,u=new o.Vector2,l=0;l<n.length;l++){var p={x:a*(Math.cos(n[l])*t),y:a*(Math.sin(n[l])*t)};s.push(p)}for(var h=e.index,d=e.attributes.position,f=new o.BufferAttribute(new Float32Array(3*e.attributes.position.count),3),m=new o.Vector3,v=new o.Color,y=0;y<h.count;y++){var g=h.getX(y);m.fromBufferAttribute(d,g);for(var b=0;b<i.length;b++)if(0===b?(c.x=0,c.y=!0===r?t:-1*t):(c.x=s[b-1].x,c.y=s[b-1].y),(u=s[b])!==undefined)if(!0===(!0===r?m.y<=c.y&&m.y>u.y:m.y>=c.y&&m.y<u.y)){var x=i[b],w=i[b+1],_=Math.abs(m.y-c.y)/(c.y-u.y);v.copy(x).lerp(w,_),f.setXYZ(g,v.r,v.g,v.b)}else{var S=i[!0===r?i.length-1:0];f.setXYZ(g,S.r,S.g,S.b)}}e.addAttribute("color",f)},e.prototype.parseProperty=function(e,t){for(var n,i,o,r=[],a={},s=/[^\s,\[\]]+/g;null!==(n=s.exec(t));)r.push(n[0]);switch(i=r[0]){case"skyAngle":case"groundAngle":this.recordingFieldname=i,this.isRecordingAngles=!0,this.angles=[];break;case"color":case"skyColor":case"groundColor":this.recordingFieldname=i,this.isRecordingColors=!0,this.colors=[];break;case"point":case"vector":this.recordingFieldname=i,this.isRecordingPoints=!0,this.points=[];break;case"colorIndex":case"coordIndex":case"normalIndex":case"texCoordIndex":this.recordingFieldname=i,this.isRecordingFaces=!0,this.indexes=[]}if(this.isRecordingFaces){if(r.length>0)for(var c=0;c>r.length;c++)/(-?\d+)/.test(r[c])&&("-1"===r[c]?(this.index.length>0&&this.indexes.push(this.index),this.index=[]):this.index.push(parseInt(r[c])));/]/.exec(t)&&(this.index.length>0&&this.indexes.push(this.index),this.index=[],this.isRecordingFaces=!1,e[this.recordingFieldname]=this.indexes)}else if(this.isRecordingPoints){if("Coordinate"===e.nodeType)for(;null!==(r=this.float3_pattern.exec(t));)o={x:parseFloat(r[1]),y:parseFloat(r[2]),z:parseFloat(r[3])},this.points.push(o);if("Normal"===e.nodeType)for(;null!==(r=this.float3_pattern.exec(t));)o={x:parseFloat(r[1]),y:parseFloat(r[2]),z:parseFloat(r[3])},this.points.push(o);if("TextureCoordinate"===e.nodeType)for(;null!==(r=this.float2_pattern.exec(t));)o={x:parseFloat(r[1]),y:parseFloat(r[2])},this.points.push(o);/]/.exec(t)&&(this.isRecordingPoints=!1,e.points=this.points)}else if(this.isRecordingAngles){if(r.length>0)for(c=0;c<r.length;c++)this.float_pattern.test(r[c])&&this.angles.push(parseFloat(r[c]));/]/.exec(t)&&(this.isRecordingAngles=!1,e[this.recordingFieldname]=this.angles)}else if(this.isRecordingColors){for(;null!==(r=this.float3_pattern.exec(t));){var u={r:parseFloat(r[1]),g:parseFloat(r[2]),b:parseFloat(r[3])};this.colors.push(u)}/]/.exec(t)&&(this.isRecordingColors=!1,e[this.recordingFieldname]=this.colors)}else if("NULL"!==r[r.length-1]&&"children"!==i){switch(i){case"duffuseColor":case"emissiveColor":case"specularColor":case"color":if(4!==r.length){console.warn("Three.VRMLLoader: Invalid color format detected for %s",i);break}a={r:parseFloat(r[1]),g:parseFloat(r[2]),b:parseFloat(r[3])};break;case"location":case"direction":case"translation":case"scale":case"size":if(4!==r.length){console.warn("THREE.VRMLLoader: Invalid vector format detected for %s",i);break}a={x:parseFloat(r[1]),y:parseFloat(r[2]),z:parseFloat(r[3])};break;case"intensity":case"cutOffAngle":case"radius":case"topRadius":case"height":case"transparency":case"shininess":case"ambientIntensity":case"creaseAngle":if(2!==r.length){console.warn("THREE.VRMLLoader: Invalid single float value specification detected for %s.",i);break}a=parseFloat(r[1]);break;case"rotation":if(5!==r.length){console.warn("THREE.VEMLLoader: Invalid quaternion format detected for %s.",i);break}a=parseFloat(r[1]);break;case"rotation":if(5!==r.length){console.warn("THREE.VRMLLoader: Invalid quaternion format detected for %s.",i);break}a={x:parseFloat(r[1]),y:parseFloat(r[2]),z:parseFloat(r[3]),w:parseFloat(r[4])};break;case"on":case"ccw":case"solid":case"colorPerVertex":case"convex":if(2!==r.length){console.warn("THREE.VRMLLoader: Invalid format detected for %s.",i);break}a="TRUE"===r[1]}e[i]=a}return a},e.prototype.getTree=function(e){console.log("run getTree");for(var t,n,i={string:"Scene",children:[]},o=i,r=0;r<e.length;r++){var a="",s=e[r];if(null===/^\s+?$/g.exec(s)&&""!==(s=s.trim())){if(/#/.exec(s)){var c=s.split("#");s=c[0],a=c[1]}if(t=/([^\s]*){1}(?:\s+)?{/.exec(s)){var u={nodeType:t[1],string:s,parent:o,children:[],comment:a};o.children.push(u),o=u,/}/.exec(s)&&(n=/{(.*)}/.exec(s)[1],u.children.push(n),this.parseProperty(o,n),o=o.parent)}else/}/.exec(s)?o=o.parent:""!==s&&(console.log("reg6"),this.parseProperty(o,s),o.children.push(s))}}return console.log("tree: ",i),i},e.prototype.parseNode=function(e,t){var n;if(console.log("run parseNode"),"string"!=typeof e){n=t,e.string.indexOf("AmbientLight")>-1&&"PointLight"===e.nodeType&&(e.nodeType="AmbientLight");var i=e.on===undefined||e.on,r=e.intensity!==undefined?e.intensity:1,a=new o.Color;if(e.color&&a.copy(e.color),"AmbientLight"===e.nodeType)(n=new o.AmbientLight(a,r)).visible=i,t.add(n);else if("PointLight"===e.nodeType){var s=0;e.radius!==undefined&&e.radius<1e3&&(s=e.radius),(n=new o.PointLight(a,r,s)).visible=i,t.add(n)}else if("SpotLight"===e.nodeType){s=0;var c=Math.PI/3;e.radius!==undefined&&e.radius<1e3&&(s=e.radius),e.cutOffAngle!==undefined&&(c=e.cutOffAngle),(n=new o.SpotLight(a,1,s,c,0)).visible=!0,t.add(n)}else if("Transform"===e.nodeType||"Group"===e.nodeType){if(n=new o.Object3D,/DEF/.exec(e.string)&&(n.name=/DEF\s+([^\s]+)/.exec(e.string)[1],this.defines[n.name]=n),e.translation!==undefined){var u=e.translation;n.position.set(u.x,u.y,u.z)}if(e.rotation!==undefined){var l=e.rotation;n.quaternion.setFromAxisAngle(new o.Vector3(l.x,l.y,l.z),l.w)}if(e.scale!==undefined){var p=e.scale;n.scale.set(p.x,p.y,p.z)}t.add(n)}else if("Shape"===e.nodeType)n=new o.Mesh,/DEF/.exec(e.string)&&(n.name=/DEF\s+([^\s]+)/.exec(e.string)[1],this.defines[n.name]=n),t.add(n);else if("Background"===e.nodeType){var h=2e4,d=new o.SphereBufferGeometry(h,20,20),f=new o.MeshBasicMaterial({fog:!1,side:o.BackSide});if(e.skyColor.length>1)this.paintFaces(d,h,e.skyAngle,e.skyColor,!0),f.vertexColors=o.VertexColors;else{var m=e.skyColor[0];f.color.setRGB(m.r,m.g,m.b)}if(this.scene.add(new o.Mesh(d,f)),e.groundColor!==undefined){h=12e3;var v=new o.SphereBufferGeometry(h,20,20,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),y=new o.MeshBasicMaterial({fog:!1,side:o.BackSide,vertexColors:o.VertexColors});this.paintFaces(v,h,e.groundAngle,e.groundColor,!1),this.scene.add(new o.Mesh(v,y))}}else{if(/geometry/.exec(e.string)){if("Box"===e.nodeType){p=e.size;t.geometry=new o.BoxBufferGeometry(p.x,p.y,p.z)}else if("Cylinder"===e.nodeType)console.log("Cylinder"),t.geometry=new o.CylinderBufferGeometry(e.radius,e.radius,e.heigjt);else if("Cone"===e.nodeType)console.log("Cone"),t.geometry=new o.CylinderBufferGeometry(e.topRadius,e.bottomRadius,e.height);else if("Sphere"===e.nodeType)t.geometry,new o.SphereBufferGeometry(e.radius);else if("IndexedFaceSet1"===e.nodeType){var g,b=new o.BufferGeometry,x=[],w=[],_=[],S=[],C=void 0,I=(m=void 0,void 0),P=void 0,z=void 0,D=void 0,V=void 0;for(z=0,g=e.children.length;z<g;z++){if("TextureCoordinate"===(Y=e.children[z]).nodeType&&Y.points)for(D=0,V=Y.points.length;D<V;D++)P=Y.points[D],S.push(P.x,P.y);if("Normal"===Y.nodeType&&Y.points)for(D=0,V=Y.points.length;D<V;D++)I=Y.points[D],_.push(I.x,I.y,I.z);if("Color"===Y.nodeType&&Y.color)for(D=0,V=Y.color.length;D<V;D++)m=Y.color[D],w.push(m.r,m.g,m.b);if("Coordinate"===Y.nodeType){if(Y.points)for(D=0,V=Y.points.length;D<V;D++)C=Y.points[D],x.push(C.x,C.y,C.z);if(Y.string.indexOf("DEF")>-1){var O=/DEF\s+([^\s]+)/.exec(Y.string)[1];this.defines[O]=x.slice(0)}if(Y.string.indexOf("USE")>-1){ee=/USE\s+([^\s]+)/.exec(Y.string)[1];x=this.defines[ee]}}}if(e.coordIndex){var M=e.coordIndex?this.triangulateIndexArray(e.coordIndex,e.ccw):[],j=e.normalIndex?this.triangulateIndexArray(e.normalIndex,e.ccw):M,L=e.colorIndex?this.triangulateIndexArray(e.texCoordIndex,e.ccw):M,T=e.texCoordIndex?this.triangulateIndexArray(e.texCoordIndex,e.ccw):M,F=[],E=[],k=[],B=[],A=[],R=Object.create(null);for(z=0;z<M.length;z++){var $=[],U=M[z],G=j[z],W=L[z],N=T[z];$.push(U.toString(10)),G!==undefined&&$.push(G.toString(10)),W!==undefined&&$.push(W.toString(10)),N!==undefined&&$.push(N.toString(10));var H=$.join("."),q=R[H];q===undefined&&(q=E.length/3,R[H]=q,E.push(x[3*U],x[3*U+1],x[3*U+2]),G!==undefined&&_.length>0&&k.push(_[3*G],_[3*G+1],_[3*G+2]),W!==undefined&&w.length>0&&B.push(w[3*W],w[3*W+1],w[3*W+2]),N!==undefined&&S.length>0&&A.push(S[2*N],S[2*N+1])),F.push(q)}x=E,_=k,w=B,S=A,b.setIndex(F)}else t.parent.remove(t);!1===e.solid&&(t.material.side=o.DoubleSide),b.addAttribute("position",new o.Float32BufferAttribute(C,3)),w.length>0&&(b.addAttribute("color",new o.Float32BufferAttribute(w,3)),t.material.VertexColors=o.VertexColors),S.length>0&&b.addAttribute("uv",new o.Float32BufferAttribute(S,2)),_.length>0?b.addAttribute("normal",new o.Float32BufferAttribute(I,3)):(b=b.toNonIndexed()).computeVertexNormals(),b.computeBoundingSphere(),/DEF/.exec(e.string)&&(b.name=/DEF ([^\s]+)/.exec(e.string)[1],this.defines[b.name]=b),t.geometry=b}return}if(/appearance/.exec(e.string)){for(z=0;z<e.children.length;z++){var Y;if("Material"===(Y=e.children[z]).nodeType){var J=new o.MeshPhongMaterial;if(Y.diffuseColor!==undefined){var K=Y.diffuseColor;J.color.setRGB(K.r,K.g,K.b)}if(Y.emissiveColor!==undefined){var X=Y.emissiveColor;J.emissive.setRGB(X.r,X.g,X.b)}if(Y.specularColor!==undefined){p=Y.specularColor;J.specular.setRGB(p.r,p.g,p.b)}if(Y.transparency!==undefined){u=Y.transparency;J.opacity=Math.abs(1-u),J.transparent=!0}/DEF/.exec(e.string)&&(J.name=/DEF ([^\s]+)/.exec(e.string)[1],this.defines[J.name]=J),t.material=J}if("ImageTexture"===Y.nodeType){var Z=/"([^"]+)"/.exec(Y.children[0]);Z&&(t.material.name=Z[1],t.material.map=this.textureLoader.load(Z[1]))}}return}}z=0;for(var Q=e.children.length;z<Q;z++)this.parseNode(e.children[z],n)}else if(/USE/.exec(e)){var ee=/USE\s+?([^\s]+)/.exec(e)[1];undefined===this.defines[ee]?console.warn("THREE.VRMLLoader: %s is not defined",ee):/appearance/.exec(e)&&ee?t.material=this.defines[ee].clone():/geometry/.exec(e)&&ee?(t.geometry=this.defines[ee].clone(),this.defines[ee].solid!==undefined&&!1===this.defines[ee].solid&&(t.geometry.solid=!1,t.material.side=o.DoubleSide)):ee&&(n=this.defines[ee].clone(),t.add(n))}},e.prototype.triangulateIndexArray=function(e,t,n){void 0===n&&(n=!0),t===undefined&&(t=!0);for(var i=[],o=0,r=0;r<e.length;r++)if(!1===n)for(var a=e[r],s=0;s<a.length;s++){var c=a[s];i.push(c,c,c)}else{var u=e[r];for(o=0;u.length>=3&&o<u.length-2;){var l=u[0],p=u[o+(t?1:2)],h=u[o+(t?2:1)];i.push(l,p,h),o++}}return i},e}(),Et=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){var t=new Ft,n=new o.Scene;return t.load("/home/vince/source/imageW/ImageW/projects/image-w/resource/MedicalShow2.vrml",function(t){t.position.copy(e.center),n=t}),n},n.prototype.updateEntity=function(e,t){return t.position.copy(e.center),t},n.prototype.defaultModel=function(){return new E(new o.Vector3(0,0,0))},n.decorators=[{type:t.Component,args:[{selector:"ng3-vrml-loader",template:"<p>\n  vrml-loader works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),kt=function(e){function n(t,n){return e.call(this,t,n)||this}return d(n,e),n.prototype.createEntity=function(e){for(var t=new o.Geometry,n=0;n<e.shapes.length;n++){var i=this.sceneService.clientPosition2ScenePosition(e.shapes[n]);t.vertices.push(new o.Vector3(i.x,i.y,0))}t.vertices.push(new o.Vector3(this.sceneService.clientPosition2ScenePosition(e.shapes[0]).x,this.sceneService.clientPosition2ScenePosition(e.shapes[0]).y,0));var r=new o.Line(t,new o.LineBasicMaterial({color:16776960,linewidth:1}));return r.name="user-defined",r},n.prototype.updateEntity=function(e,t){for(var n=new o.Geometry,i=0;i<e.shapes.length;i++){var r=this.sceneService.clientPosition2ScenePosition(e.shapes[i]);n.vertices.push(new o.Vector3(r.x,r.y,0))}return n.vertices.push(new o.Vector3(this.sceneService.clientPosition2ScenePosition(e.shapes[0]).x,this.sceneService.clientPosition2ScenePosition(e.shapes[0]).y,0)),t.geometry=n,t},n.prototype.defaultModel=function(){var e=[];return e.push(new o.Vector2(-5,5)),e.push(new o.Vector2(-5,-5)),e.push(new o.Vector2(5,-5)),e.push(new o.Vector2(5,5)),e.push(new o.Vector2(-5,5)),new j(e)},n.decorators=[{type:t.Component,args:[{selector:"ng3-shape",template:"<p>\n  shape works!\n</p>\n",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n}(de),Bt=function(e){function n(t,n){var i=e.call(this,t,n)||this;return i._increment=10,i.start=0,i}return d(n,e),Object.defineProperty(n.prototype,"increment",{get:function(){return this._increment},set:function(e){this._increment=e},enumerable:!0,configurable:!0}),n.prototype.createEntity=function(e){for(var t=new o.Geometry,n=0;n<e.points.length;n++)t.vertices.push(new o.Vector3(this.start+n*this._increment,e.points[n],0));var i=new o.Line(t,new o.LineBasicMaterial({color:"red"}));return i.name="profile1d",i},n.prototype.updateEntity=function(e,t){for(var n=new o.Geometry,i=0;i<e.points.length;i++)n.vertices.push(new o.Vector3(this.start+i*this._increment,e.points[i],0));return t.geometry=n,t},n.prototype.defaultModel=function(){return new L([0,5,10,15,20,15,10,5,0])},n.decorators=[{type:t.Component,args:[{selector:"ng3-profile",template:"",styles:[""]}]}],n.ctorParameters=function(){return[{type:Z},{type:te}]},n.propDecorators={increment:[{type:t.Input}],start:[{type:t.Input}]},n}(de);function At(e,t,n,i,o,r,a){void 0===i&&(i=30),void 0===o&&(o=10),void 0===r&&(r=1),void 0===a&&(a="red");var s,c,u=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,l=(u+i)*Math.PI/180,p=(u-i)*Math.PI/180,h=o*Math.cos(l),d=o*Math.sin(l),f=o*Math.cos(p),m=o*Math.sin(p);e.save(),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),s=n.x+h,c=n.y+d,e.moveTo(s,c),e.lineTo(n.x,n.y),s=n.x+f,c=n.y+m,e.lineTo(s,c),e.strokeStyle=a,e.lineWidth=r,e.stroke(),e.restore()}var Rt=function(){function e(e,t){var n=this;this.renderer=e,this.el=t,this.canvas_width=300,this.canvas_height=300,this.infoSubject=new i.BehaviorSubject(["hello"]),this.positionSubject=new i.BehaviorSubject(new o.Vector2(this.canvas_width/2,this.canvas_height/2)),this.distance=10,this.info$=this.infoSubject.asObservable(),this.position$=this.positionSubject.asObservable(),this.arrow_enable=!0,this.cans=this.renderer.createElement("canvas"),this.cans.height=this.canvas_height,this.cans.width=this.canvas_width,this.ctx=this.cans.getContext("2d"),this.ctx.fillStyle="red",this.ctx.fillText("txt",100,100),this.renderer.appendChild(this.el.nativeElement,this.cans);i.combineLatest(this.info$,this.position$).pipe(r.map(function(e){var t=n.getDirection(e[1]);if(n.arrow_enable){var i=new o.Vector2((e[1].x+40)/80*300,(e[1].y+30)/60*300),r=new o.Vector2(t.x-5,t.y-5);n.ctx.clearRect(0,0,n.canvas_width,n.canvas_height),At(n.ctx,i,r)}for(var a=0;a<e[0].length;)n.ctx.fillText(e[0][a],t.x,t.y+a*n.distance),a++})).subscribe(function(){return n.renderer.appendChild(n.el.nativeElement,n.cans)},console.error)}return Object.defineProperty(e.prototype,"info",{get:function(){return this.infoSubject.value},set:function(e){this.infoSubject.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.positionSubject.value},set:function(e){this.positionSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngAfterViewInit=function(){},e.prototype.getDirection=function(e){var t,n=this.canvas_width,i=this.canvas_height,r=(e.x+40)/80*300,a=(e.y+30)/60*300;return a<=i/6&&r<=n/6||a>=i/6&&a<=i/2&&r>=i/6&&r<=i/2?(this.info_position=new o.Vector2(r+n/6,a+i/6),this.arrow_position=new o.Vector2(r+n/6,a+i/6),t=new o.Vector2(r+n/6,a+i/6)):a<=i/6&&r>=n/6*5||a>=i/6&&a<=i/2&&r>n/2&&r<=n/6*5?(this.info_position=new o.Vector2(r-n/6,a+i/6),this.arrow_position=new o.Vector2(r-n/6,a+i/6),t=new o.Vector2(r-n/6,a+i/6)):a>=i/6*5&&r<=n/6||a>i/2&&a<=i/6*5&&r>=i/6&&r<=i/2?(this.info_position=new o.Vector2(r+n/6,a-i/6),this.arrow_position=new o.Vector2(r+n/6,a-i/6),t=new o.Vector2(r+n/6,a-i/6)):a>=i/6*5&&r>=n/6*5||a>=i/2&&a<i/6*5&&r>=n/2&&r<n/6*5?(this.info_position=new o.Vector2(r-n/6,a-i/6),this.arrow_position=new o.Vector2(r-n/6,a-i/6),t=new o.Vector2(r-n/6,a-i/6)):a>i/6&&a<i/6*5&&r<=n/6?(this.info_position=new o.Vector2(r+n/6,a),this.arrow_position=new o.Vector2(r+n/6,a),t=new o.Vector2(r+n/6,a)):a>i/6&&a<i/6*5&&r>=n/6*5?(this.info_position=new o.Vector2(r-n/6,a),this.arrow_position=new o.Vector2(r-n/6,a),t=new o.Vector2(r-n/6,a)):a>=i/6*5&&r>n/6&&r<n/6*5?(this.info_position=new o.Vector2(r,a-i/6),this.arrow_position=new o.Vector2(r,a-i/6),t=new o.Vector2(r,a-i/6)):a<=i/6&&r>n/6&&r<n/6*5&&(this.info_position=new o.Vector2(r,a+i/6),this.arrow_position=new o.Vector2(r,a+i/6),t=new o.Vector2(r,a+i/6)),t},e.decorators=[{type:t.Component,args:[{selector:"app-info",template:'\x3c!-- <div> --\x3e\n  \x3c!-- <p>000000000000000000000000000000</p> --\x3e\n  \x3c!-- <ng3-ring id = "border" [model]=\'model\'></ng3-ring> --\x3e\n  \x3c!-- <canvas id = "border"></canvas> --\x3e\n\x3c!-- </div> --\x3e\n',styles:["canvas{position:absolute;width:100;height:100;z-index:15;pointer-events:none}"]}]}],e.ctorParameters=function(){return[{type:t.Renderer2},{type:t.ElementRef}]},e.propDecorators={info:[{type:t.Input}],position:[{type:t.Input}],arrow_enable:[{type:t.Input}],info_style:[{type:t.Input}]},e}(),$t=function(){function e(e,n){var o=this;this.canvasService=e,this.mouse=n,this.stop=new i.Subject,this.fovs=new t.EventEmitter,this.domElement=this.canvasService.domElement,this.eventHandler={ring:{enable:!1,tag:"drag"},line:{enable:!1,tag:"drag"},crossline:{enable:!1,tag:"drag"},fov:{enable:!0,tag:"stop drag"}},this.fovHandler={fov1:{enable:!1,tag:"drag"},fov2:{enable:!1,tag:"drag"},fov3:{enable:!1,tag:"drag"}},this.crossline=new Wt(this.eventHandler.crossline.enable,this.multiCanvas,this.entityStore),this.ring=new Nt(this.eventHandler.ring.enable,this.multiCanvas,this.entityStore),this.mouse.downWithButton$.pipe(r.takeUntil(this.stop)).subscribe(function(e){e.original.preventDefault(),o.eventHandler.crossline.enable&&(o.crossline.activate(),o.crossline.onMouseDown(e.position)),o.eventHandler.ring.enable&&(o.ring.activate(),o.ring.onMouseDown(e.position)),o.eventHandler.fov.enable&&(o.fov.activate(),o.fov.onMouseDown(e.position,o.fovHandler))},console.error),this.mouse.position$.pipe(r.takeUntil(this.stop)).subscribe(function(e){o.crossline.onMouseMove(e),o.ring.onMouseMove(e),o.fov.onMouseMove(e);var t={fov1:o.fov.fovs[0],fov2:o.fov.fovs[1],fov3:o.fov.fovs[2]};o.fovs.emit(t)},console.error),this.mouse.up$.pipe(r.takeUntil(this.stop)).subscribe(function(e){o.crossline.deactivate(),o.ring.deactivate(),o.fov.deactivate()},console.error)}return e.prototype.ngOnInit=function(){},e.prototype.ngAfterContentInit=function(){this.fov=new Gt(this.eventHandler.fov.enable,this.multiCanvas,this.entityStore),this.crossline=new Wt(this.eventHandler.crossline.enable,this.multiCanvas,this.entityStore),this.ring=new Nt(this.eventHandler.ring.enable,this.multiCanvas,this.entityStore)},e.decorators=[{type:t.Component,args:[{selector:"ng3-event-distribute",template:"<p>\n  event-distribute works!\n</p>\n",styles:[""]}]}],e.ctorParameters=function(){return[{type:X},{type:Ze}]},e.propDecorators={fovs:[{type:t.Output}],eventHandler:[{type:t.Input}],fovHandler:[{type:t.Input}],entityStore:[{type:t.Input}],multiCanvas:[{type:t.Input}]},e}(),Ut=function(){function e(e){this.eventEnbable=e,this._activated=!1,this.origin=new o.Vector2,this.start=new o.Vector2,this.end=new o.Vector2,this.delta=new o.Vector2,this.delta2=new o.Vector2}return Object.defineProperty(e.prototype,"activated",{get:function(){return this.eventEnbable,this._activated},enumerable:!0,configurable:!0}),e.prototype.activate=function(){this._activated=!0},e.prototype.deactivate=function(){this._activated=!1},e.prototype.onMouseUp=function(){this.deactivate()},e}(),Gt=function(e){function t(t,n,i){var r=e.call(this,t)||this;return r.multiCanvas=n,r.entityStore=i,r.onBox="inside",r.fovs=[new W(new o.Vector2(0,0),new o.Vector2(20,20)),new W(new o.Vector2(0,0),new o.Vector2(20,20)),new W(new o.Vector2(0,0),new o.Vector2(20,20))],r}return d(t,e),t.prototype.onMouseWheel=function(){},t.prototype.onMouseDown=function(e,t){var n=this;this.activated&&(this.start.set(e.x,e.y),this.origin.set(e.x,e.y)),this.fovHandler=t;var i=0;t.fov3.enable&&(i=2),t.fov2.enable&&(i=1),t.fov1.enable&&(i=0),this.multiCanvas.mapSelectedCanvas(function(t){n.entityStore.fovsOnCanvas(t,function(t){t[i]!==undefined&&(n.boxController=new H(t[i].model.box,.1),n.onBox=n.boxController.onWhichAreabox(e))})})},t.prototype.onMouseMove=function(e){this.activated&&(this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.start),this.delta2.subVectors(this.end,this.origin),this.fovHandler.fov1.enable&&this.fovEvent(this.origin,this.delta,this.end,0),this.fovHandler.fov2.enable&&this.fovEvent(this.origin,this.delta,this.end,1),this.fovHandler.fov3.enable&&this.fovEvent(this.origin,this.delta,this.end,2),this.start.copy(this.end))},t.prototype.dragFov=function(e){var t=this;this.multiCanvas.mapSelectedCanvas(function(n){t.entityStore.fovOnCanvas(n,function(n){t.entityStore.updateFov({id:n.id,model:f({},n.model,{box:new W(e,n.model.box.size)})})})})},t.prototype.fovEvent=function(e,t,n,i){var o=this;this.multiCanvas.mapSelectedCanvas(function(e){o.entityStore.fovsOnCanvas(e,function(e){if(e[i]!==undefined){var r=e[i].model;switch(o.fovs[i]=r.box,o.onBox){case"inside":o.entityStore.updateFov({id:e[i].id,model:f({},r,{box:new W(n,r.box.size)})});break;case"left":o.entityStore.updateFov({id:e[i].id,model:f({},r,{box:new N(r.box.left+t.x,r.box.right,r.box.top,r.box.bottom)})});break;case"right":o.entityStore.updateFov({id:e[i].id,model:f({},r,{box:new N(r.box.left,r.box.right+t.x,r.box.top,r.box.bottom)})});break;case"top":o.entityStore.updateFov({id:e[i].id,model:f({},r,{box:new N(r.box.left,r.box.right,r.box.top+t.y,r.box.bottom)})});break;case"bottom":o.entityStore.updateFov({id:e[i].id,model:f({},r,{box:new N(r.box.left,r.box.right,r.box.top,r.box.bottom+t.y)})})}}})})},t}(Ut),Wt=function(e){function t(t,n,i){var o=e.call(this,t)||this;return o.multiCanvas=n,o.entityStore=i,o}return d(t,e),t.prototype.onMouseDown=function(e){this.activated&&(this.start.set(e.x,e.y),this.origin.set(e.x,e.y))},t.prototype.onMouseWheel=function(){},t.prototype.onMouseMove=function(e){this.activated&&(this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.start),this.dragCrossline(this.start),this.start.copy(this.end))},t.prototype.dragCrossline=function(e){var t=this;this.multiCanvas.mapSelectedCanvas(function(n){n!==undefined&&t.entityStore.crosslineOnCanvas(n,function(n){if(n!==undefined){var i;switch(n.view){case"x":i=new o.Vector3(n.position.x,e.x,e.y);break;case"y":i=new o.Vector3(e.x,n.position.y,e.y);break;case"z":i=new o.Vector3(e.x,e.y,n.position.z)}t.entityStore.updateCrosslines({model:f({},n,{position:i})})}})})},t}(Ut),Nt=function(e){function t(t,n,i){var o=e.call(this,t)||this;return o.multiCanvas=n,o.entityStore=i,o.onBox="inside",o}return d(t,e),t.prototype.onMouseDown=function(e){var t=this;this.activated&&(this.start.set(e.x,e.y),this.origin.set(e.x,e.y)),this.multiCanvas.mapSelectedCanvas(function(n){t.entityStore.ringOnCanvas(n,function(n){n!==undefined&&(t.boxController=new H(new W(new o.Vector2(n.center.x,n.center.y),new o.Vector2(2*n.outerRadius,2*n.outerRadius)),.1),t.onBox=t.boxController.onWhichAreabox(e))})})},t.prototype.onMouseWheel=function(){},t.prototype.onMouseMove=function(e){this.activated&&(this.end.set(e.x,e.y),this.delta.subVectors(this.end,this.origin),this.dragRing(this.origin,this.delta,this.end),this.start.copy(this.end))},t.prototype.dragRing=function(e,t,n){var i=this;this.multiCanvas.mapSelectedCanvas(function(e){return i.entityStore.ringOnCanvas(e,function(t){switch(i.onBox){case"inside":i.entityStore.updateRingEntity({canvasId:e,model:f({},t,{center:new o.Vector3(n.x,n.y,0)})});break;case"left":case"right":case"top":case"bottom":case"none":var r=new o.Vector2;r.subVectors(new o.Vector2(t.center.x,t.center.y),n);var a=Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2));i.entityStore.updateRingEntity({canvasId:e,model:new M(new o.Vector3(t.center.x,t.center.y,0),a,a+.001)})}})})},t.prototype.ResizeRing=function(e,t){var n=this;this.multiCanvas.mapSelectedCanvas(function(i){var r=Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2));n.entityStore.updateRingEntity({canvasId:i,model:new M(new o.Vector3(e.x,e.y,0),r,r+.001)})})},t}(Ut),Ht=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[ut,lt,pt,dt,ct,mt,vt,yt,It,Dt,Vt,nt,st,jt,Xe,Lt,Tt,Bt,Et,kt,Ke,Ie,Rt,$t,Ce,we],providers:[Mt,Se],imports:[n.CommonModule],exports:[ut,pt,lt,dt,ct,mt,yt,It,nt,st,jt,Xe,Lt,Tt,Et,kt,Bt,Ke,Ie,Rt,$t,Ce,we]}]}],e}();function qt(e,t){return 0===e.length?undefined:1===e.length?t(e[0]):t(e[0])!==t(e[1])?undefined:qt(e.slice(1,e.length),t)}var Yt=function(){function e(){this.width=1,this.widthChange=new t.EventEmitter,this.level=.5,this.levelChange=new t.EventEmitter,this.widthlevelChange=new t.EventEmitter}return Object.defineProperty(e.prototype,"related",{set:function(e){this.setInputToDefault(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngOnDestroy=function(){},e.prototype.updateWidth=function(e){this.width=e,this.width!==undefined&&this.widthChange.emit(this.width)},e.prototype.updateLevel=function(e){this.level=e,this.level!==undefined&&this.levelChange.emit(this.level)},e.prototype.updateWidthLevel=function(e,t){this.width=e,this.level=t,this.width&&this.level!==undefined&&this.widthlevelChange.emit({width:this.width,level:this.level})},e.prototype.parse=function(e){return parseFloat(e)},e.prototype.setInputToDefault=function(e){0!==e.length&&(this.updateWidth(qt(e,function(e){return e.filter.width})),this.updateLevel(qt(e,function(e){return e.filter.level})),this.updateWidthLevel(qt(e,function(e){return e.filter}).width,qt(e,function(e){return e.filter}).level))},e.decorators=[{type:t.Component,args:[{selector:"app-window",template:'\x3c!--<div (click)="changeValue()">--\x3e\n<div class="window">\n  <div>\n    <label for="width" class="labelLength">Width:</label>\n    <input\n      type="number"\n      id="width"\n      class="inputValue"\n      step="0.05"\n      #widthInput\n      (change)="updateWidthLevel(parse(levelInput.value),parse(widthInput.value))"\n      [value]="width"\n    />\n  </div>\n  <div>\n    <label for="level" class="labelLength">Level:</label>\n    <input\n      type="number"\n      id="level"\n      class="inputValue"\n      [step]="0.05"\n      #levelInput\n      (change)="updateWidthLevel(parse(widthInput.value),parse(levelInput.value))"\n      [value]="level"\n    />\n  </div>\n</div>\n\n',styles:[".window{display:flex}.inputValue{width:80px}.labelLength{width:50px}"]}]}],e.ctorParameters=function(){return[]},e.propDecorators={width:[{type:t.Input}],widthChange:[{type:t.Output}],level:[{type:t.Input}],levelChange:[{type:t.Output}],widthlevelChange:[{type:t.Output}],related:[{type:t.Input}]},e}(),Jt=function(){function e(){this.maxFrame="100",this.choseFrame="1",this.choseFrame$=new i.Subject,this.direction="z",this.directionChange=new t.EventEmitter,this.sliceIndex=1,this.sliceIndexChange=new t.EventEmitter}return Object.defineProperty(e.prototype,"related",{set:function(e){this.setInputToDefault(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.ngOnDestroy=function(){},e.prototype.setInputToDefault=function(e){0!==e.length&&(this.changeDirection(qt(e,function(e){return e.slicer.direction})),this.changeSliceIndex(qt(e,function(e){return e.slicer.index})),this.setDefaultFrame(qt(e,function(e){return e.slicer.max}),qt(e,function(e){return e.slicer.index})))},e.prototype.changeDirection=function(e){e!==this.direction&&(this.direction=e,e!==undefined&&this.directionChange.emit(e))},e.prototype.parse=function(e){return parseInt(e,10)},e.prototype.changeSliceIndex=function(e){e!==this.sliceIndex&&(this.sliceIndex=e,e!==undefined&&this.sliceIndexChange.emit(e))},e.prototype.setDefaultFrame=function(e,t){this.maxFrame=e.toString(),this.choseFrame=t.toString()},e.decorators=[{type:t.Component,args:[{selector:"app-direction",template:'<div class="divC">\n  <label>Slice direction</label>\n  <select\n    #directionSelect\n    (change)="changeDirection(directionSelect.value)"\n    [value]="direction"\n  >\n    <option value="x">Transverse</option>\n    <option value="y">Coronal</option>\n    <option value="z">Sagittal</option>\n  </select>\n</div>\n\n<div class="slidecontainer">\n  <label for="myRange">Frame: {{sliceIndex}}</label>\n  <input\n    type="range"\n    class="slider"\n    id="myRange"\n    min="0"\n    [max]="maxFrame"\n    step="1"\n    #input\n    [value]="choseFrame"\n    (change)="\n      changeSliceIndex(parse(input.value))\n    "\n  />\n</div>\n',styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={direction:[{type:t.Input}],directionChange:[{type:t.Output}],sliceIndex:[{type:t.Input}],sliceIndexChange:[{type:t.Output}],related:[{type:t.Input}]},e}(),Kt=function(){function n(){var n=this;this.colormapSubject=new i.BehaviorSubject(e.Colormaps.GRAY),this.colormap$=this.colormapSubject.asObservable(),this.colormapName$=this.colormap$.pipe(r.map(function(e){return e===undefined?undefined:e.name})),this.colormapChange=new t.EventEmitter,this.colormap$.pipe(r.filter(function(e){return e!==undefined})).subscribe(function(e){return n.colormapChange.emit(e)},function(e){return console.error(e)})}return Object.defineProperty(n.prototype,"colormap",{get:function(){return this.colormapSubject.value},set:function(e){this.colormapSubject.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"related",{set:function(e){this.setInputToDefault(e)},enumerable:!0,configurable:!0}),n.prototype.ngOnDestroy=function(){this.colormapSubject.complete()},n.prototype.ngOnInit=function(){},n.prototype.onChangeSelect=function(t){switch(t){case"gray":this.colormap=e.Colormaps.GRAY;break;case"hot":this.colormap=e.Colormaps.HOT;break;default:this.colormap=undefined}},n.prototype.setInputToDefault=function(e){0!==e.length&&(this.colormap=qt(e,function(e){return e.colormap}))},n.decorators=[{type:t.Component,args:[{selector:"app-colormap",template:'<div class="divC">\n  <label>colormap</label>\n  <select\n    #colormapSelect\n    [value]="colormapName$ | async"\n    (change)="onChangeSelect(colormapSelect.value)"\n  >\n    <option value="gray">Gray</option>\n    <option value="hot">Hot</option>\n  </select>\n</div>\n',styles:[".divC{white-space:nowrap;display:inline}.window{display:inline;white-space:nowrap}.inputValue{width:80px}.labelLength{width:50px}"]}]}],n.ctorParameters=function(){return[]},n.propDecorators={colormap:[{type:t.Input}],colormapChange:[{type:t.Output}],related:[{type:t.Input}]},n}(),Xt=function(){function e(){this.imageSubject=new i.BehaviorSubject({image:new I(new o.Vector2(0,0),new o.Vector2(10,10),new o.Vector2(1,1),new Uint8Array([255]),new Uint8Array([255]),new Uint8Array([255])),rotation:new o.Vector3(0,0,0)}),this.image$=this.imageSubject.asObservable(),this.z=0,this.scroll=new t.EventEmitter,this.drag=new t.EventEmitter,this.model$=this.image$.pipe(r.map(function(e){return new P(new W(e.image.meta.center,e.image.meta.size),10,{r:new Uint8Array(e.image.r),g:new Uint8Array(e.image.g),b:new Uint8Array(e.image.b),shape:new o.Vector2(e.image.meta.shape.x,e.image.meta.shape.y)},e.rotation)})),this.model$.subscribe(i.noop,function(e){return console.error(e)})}return Object.defineProperty(e.prototype,"image",{get:function(){return this.imageSubject.value},set:function(e){if(e===undefined||null===e)throw Error("Can not set Display2DProperty with null");this.imageSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.onWheelEvent=function(e){this.scroll.emit(e)},e.prototype.onDragEvent=function(e){this.drag.emit(e)},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"app-image2d",template:'<ng3-plane [model]="model$ | async" [z]="z">\n  <ng3-mouse-entity\n    (wheel)="onWheelEvent($event)"\n    (drag)="onDragEvent($event)"\n  ></ng3-mouse-entity>\n</ng3-plane>\n',styles:[""]}]}],e.ctorParameters=function(){return[]},e.propDecorators={image:[{type:t.Input}],z:[{type:t.Input}],scroll:[{type:t.Output}],drag:[{type:t.Output}]},e}(),Zt=function(){return function(t,n,i,r,a,s,c){void 0===n&&(n=new _(new o.Vector3(0,0,0),new o.Vector3(1,1,0),new o.Vector3(1,1,0),new Float32Array([1]))),void 0===i&&(i=e.Colormaps.GRAY),void 0===r&&(r=new Pe),void 0===a&&(a=new je(1,0)),void 0===s&&(s=new o.Vector2(0,1)),void 0===c&&(c=new o.Vector3(0,0,0)),this.id=t,this.image=n,this.colormap=i,this.slicer=r,this.filter=a,this.minMax=s,this.rotation=c}}(),Qt=function(){return function(e,t,n,i){void 0===i&&(i=new o.Color(60,179,113)),this.canvasId=e,this.id=t,this.model=n,this.color=i}}(),en=function(){return function(e){this.id=e}}(),tn=function(){function e(e){var n=this;this.sceneService=e,this.boxSubject=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(1,1))),this.box$=this.boxSubject.asObservable(),this.resize="canvas",this.pos=new o.Vector3(0,0,0),this.scroll=new t.EventEmitter,this.drag=new t.EventEmitter,this.stateSubject=new i.BehaviorSubject(He()),this.state$=this.stateSubject.asObservable(),this.z=0,this.image$=i.combineLatest(this.state$,this.box$).pipe(r.map(function(e){return n.getDisplay2DProperty(e[0],e[1])}))}return Object.defineProperty(e.prototype,"box",{get:function(){return this.boxSubject.value},set:function(e){this.boxSubject.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this.stateSubject.value},set:function(e){this.stateSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.onScroll=function(e){this.scroll.emit(e)},e.prototype.onDrag=function(e){this.drag.emit(e)},e.prototype.getDisplay2DProperty=function(e,t){var n=Ve(e.filter.filter(e.slicer.slice(e.image)),e.colormap),i=this.imageBox(n,t);return{image:new I(i.center,i.size,n.meta.shape,n.r,n.g,n.b),rotation:e.rotation}},e.prototype.getImage=function(e,t){var n=Ve(e.filter.filter(e.slicer.slice(e.image)),e.colormap),i=this.imageBox(n,t);return new I(i.center,i.size,n.meta.shape,n.r,n.g,n.b)},e.prototype.imageBox=function(e,t){switch(this.resize){case"image":return new W(e.meta.center,e.meta.size);case"fix":return t;case"canvas":var n=this.sceneService.size,i=Math.min(n.size.x/e.meta.size.x,n.size.y/e.meta.size.y);return new W(new o.Vector2(0,0),new o.Vector2(e.meta.size.x*i,e.meta.size.y*i))}},e.decorators=[{type:t.Component,args:[{selector:"app-image3d",template:'<app-image2d\n  [image]="image$ | async"\n  [z]="z"\n  (scroll)="onScroll($event)"\n  (drag)="onDrag($event)"\n></app-image2d>\n',styles:["#topo{position:absolute;top:10px;left:10px;width:600px;height:800px}#topoplaceholder{width:620px;height:820px}#slice{position:absolute;top:10px;left:10px;width:600px;height:600px}.image-viewers-container{flex-wrap:wrap;display:flex}.container{display:-ms-grid;display:grid;-ms-grid-columns:(20%)[5];grid-template-columns:repeat(5,20%);width:100%;height:100%}.header-container{grid-area:head;display:flex;height:50}.utilities-container{background-color:#eee;-ms-grid-column:1;grid-column-start:1;-ms-grid-column-span:1;grid-column-end:2}.viewers-container{grid-column:2/-1;background-color:azure}"]}]}],e.ctorParameters=function(){return[{type:Z}]},e.propDecorators={box:[{type:t.Input}],resize:[{type:t.Input}],pos:[{type:t.Input}],scroll:[{type:t.Output}],drag:[{type:t.Output}],image:[{type:t.Input}],z:[{type:t.Input}]},e}(),nn=function(){function e(){this.crosslineSubject=new i.BehaviorSubject([{id:"testLine",position:new o.Vector3(10,10,10),view:"x",crosslineLength:2}]),this.crosslineMain$=this.crosslineSubject.asObservable(),this.tempV3=new o.Vector3(0,0,0)}return e.prototype.addCrossLine=function(e){void 0===e&&(e=0);var t=s.v4();return this.crosslineSubject.next(v(this.crosslineSubject.value,[{id:t,position:new o.Vector3(10,10,e),view:"x",crosslineLength:2}])),t},e.prototype.updatePosition=function(e,t,n,i){var o=this;void 0===i&&(i=2),this.crosslineMain$.pipe(r.map(function(i){o.tempV3=o.updateViewPos(t,i[o.lastIndex(i,e)].position,n)})).subscribe(),this.crosslineSubject.next(v(this.crosslineSubject.value,[{id:e,position:this.tempV3,view:n,crosslineLength:i}]))},e.prototype.position$=function(e,t){var n=this;return this.crosslineMain$.pipe(r.map(function(i){return n.getPos(i[n.lastIndex(i,e)].position,t)}))},e.prototype.position3$=function(e){var t=this;return this.crosslineMain$.pipe(r.map(function(n){return n[t.lastIndex(n,e)].position}))},e.prototype.getPos=function(e,t){switch(t){case"x":return new o.Vector2(e.y,e.x);case"y":return new o.Vector2(e.x,e.z);case"z":return new o.Vector2(e.x,e.y)}},e.prototype.lastIndex=function(e,t){for(var n=0,i=0;i<e.length;i++)e[i].id===t&&(n=i);return n},e.prototype.updateViewPos=function(e,t,n){var i=t;switch(n){case"x":i=new o.Vector3(t.x,e.x,e.y);break;case"y":i=new o.Vector3(e.x,t.y,e.y);break;case"z":i=new o.Vector3(e.x,e.y,t.z);break;default:i=new o.Vector3(t.x,e.x,e.y)}return i},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),on=function(){function e(e,t){var n=this;this.sceneService=e,this.groupCrossLineService=t,this.view="x",this.boxSubject=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(1,1))),this.box$=this.boxSubject.asObservable(),this.resize="canvas",this.stateSubject=new i.BehaviorSubject(He()),this.state$=this.stateSubject.asObservable(),this.image$=i.combineLatest(this.state$,this.box$,this.groupCrossLineService.crosslineMain$).pipe(r.map(function(e){return n.getImage(e[0],e[1],e[2])}))}return Object.defineProperty(e.prototype,"box",{get:function(){return this.boxSubject.value},set:function(e){this.boxSubject.next(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"image",{get:function(){return this.stateSubject.value},set:function(e){this.stateSubject.next(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){},e.prototype.getImage=function(e,t,n){var i=Ve((e=this.stateUpdate(e,t,n)).filter.filter(e.slicer.slice(e.image)),e.colormap),o=this.imageBox(i,t);return new I(o.center,o.size,i.meta.shape,i.r,i.g,i.b)},e.prototype.stateUpdate=function(e,t,n){switch(this.resize){case"image":e.slicer=new Pe(this.view,this.indexUpdate(e.image.meta.size,e.image.meta.size.x,n[n.length-1].position));break;case"fix":e.slicer=new Pe(this.view,this.indexUpdate(e.image.meta.size,t.size.x,n[n.length-1].position));break;case"canvas":var i=this.sceneService.size;e.slicer=new Pe(this.view,this.indexUpdate(e.image.meta.size,i.size.x,n[n.length-1].position))}return e},e.prototype.indexUpdate=function(e,t,n){var i=0;switch(this.view){case"x":i=Math.floor((n.z+t/2)/t*e.z),i=Math.max(Math.min(0,i),e.z);break;case"y":i=Math.floor((n.x+t/2)/t*e.x),i=Math.max(Math.min(0,i),e.x);break;case"z":i=Math.floor((n.y+t/2)/t*e.y),i=Math.max(Math.min(0,i),e.y)}return i},e.prototype.imageBox=function(e,t){switch(this.resize){case"image":return new W(e.meta.center,e.meta.size);case"fix":return t;case"canvas":var n=this.sceneService.size,i=Math.min(n.size.x/e.meta.size.x,n.size.y/e.meta.size.y);return new W(new o.Vector2(0,0),new o.Vector2(e.meta.size.x*i,e.meta.size.y*i))}},e.decorators=[{type:t.Component,args:[{selector:"app-imagecrossline",template:'<app-image2d\n  [image]="image$ | async"\n></app-image2d>\n',styles:[""]}]}],e.ctorParameters=function(){return[{type:Z},{type:nn}]},e.propDecorators={view:[{type:t.Input}],box:[{type:t.Input}],resize:[{type:t.Input}],image:[{type:t.Input}]},e}(),rn=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[Kt,Jt,Yt,tn,Xt,on,K],imports:[n.CommonModule,Ht],exports:[Kt,Jt,Yt,tn,Xt,Ht,on,K]}]}],e}(),an=function(){function e(){this.eventHandler={ring:{enable:!1,tag:"drag"},line:{enable:!1,tag:"drag"},crossline:{enable:!1,tag:"drag"},fov:{enable:!0,tag:"stop drag"}},this.fovHandler={fov1:{enable:!1,tag:"drag"},fov2:{enable:!1,tag:"drag"},fov3:{enable:!1,tag:"drag"}}}return e.prototype.doDrag=function(){},e.prototype.noDrag=function(){},e.prototype.ifDrag=function(){this.eventHandler.ring.enable||this.eventHandler.line.enable||this.eventHandler.crossline.enable||this.eventHandler.fov.enable?this.doDrag():this.noDrag()},e.prototype.drag=function(e){e.enable?(e.enable=!1,this.ifDrag(),e.tag="drag"):(e.enable=!0,this.ifDrag(),e.tag="stop drag")},e.prototype.dragRing=function(){this.drag(this.eventHandler.ring)},e.prototype.dragLine=function(){this.drag(this.eventHandler.line)},e.prototype.dragCrossline=function(){this.drag(this.eventHandler.crossline)},e.prototype.dragFov=function(){this.drag(this.eventHandler.fov)},e.prototype.dragFov1=function(){this.drag(this.fovHandler.fov1)},e.prototype.dragFov2=function(){this.drag(this.fovHandler.fov2)},e.prototype.dragFov3=function(){this.drag(this.fovHandler.fov3)},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),sn=function(){return function(e,t,n,i,o,r,a,s){this.name=e,this.imageId=t,this.birthday=n,this.sex=i,this.age=o,this.description=r,this.ima=a,this.position=s,this.type="patient"}}(),cn=function(){return function(e,t,n,i){this.name=e,this.device=t,this.model=n,this.patientPosition=i,this.type="hospital"}}(),un=function(){return function(e,t){this.scale=e,this.direction=t,this.type="scale"}}(),ln=function(){return function(e,t,n,i){this.voltage=e,this.current=t,this.angle=n,this.depth=i,this.type="physics"}}(),pn=function(){return function(e,t,n){this.window=e,this.level=t,this.zoom=n,this.type="zoom"}}(),hn=function(){return function(e,t){this.center=e,this.Radius=t,this.type="ring",this.area=Math.PI*t*t}}(),dn=function(){function e(){this.info=new i.BehaviorSubject(new hn(new o.Vector3(0,0,0),20)),this.info$=this.info.asObservable()}return e.prototype.top_left_info=function(){return["AAA",123,new Date(Date.now()),"F",40,"CT",30,-20.3]},e.prototype.top_right_info=function(){return["x HSP","PET-CT","Pi-16","HFS"]},e.prototype.bottom_left_info=function(){return[100,10,30,200]},e.prototype.bottom_right_info=function(){return["W 350","C 50","Zoom: 1.00"]},e.prototype.updateInfo=function(e){this.info.next(e)},e.prototype.getPatient=function(e){return i.of(new sn("AAA",123,new Date(Date.now()),"F",40,"CT",30,-20.3))},e.prototype.currentPatient=function(){return i.of(new sn("AAA",123,new Date(Date.now()),"F",40,"CT",30,-20.3))},e.prototype.currentHospital=function(){return i.of(new cn("x HSP","PET-CT","Pi-16","HFS"))},e.prototype.currentScale=function(){return i.of(new un(10,"R"))},e.prototype.currentPhysics=function(){return i.of(new ln(100,10,30,200))},e.prototype.currentZoom=function(){return i.of(new pn("W 350","C 50","Zoom: 1.00"))},e.prototype.ROI_info=function(){return i.of(["area:100","value:100"])},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),fn=function(){function e(e,n,a,c,u,l,p){var h=this;this.service=e,this.imageStoreService=n,this.infoService=a,this.crosslineService=c,this.entityStoreService=u,this.loadService=l,this.distributionService=p,this.image3Subject=new i.BehaviorSubject(Y(new o.Vector3(100,100,100),new o.Vector3(100,100,100))),this.image3$=this.image3Subject.asObservable(),this.fovs=new t.EventEmitter,this.image2=q(new o.Vector2(10,10),new o.Vector2(10,20)),this.tomoSize=new o.Vector2(500,752),this.normalSize=new o.Vector2(500,375),this.threeDSize=new o.Vector2(500,375),this.tomoCameraSize=new o.Vector2(80,60),this.normalCameraSize=new o.Vector2(80,60),this.threeDCameraSize=new o.Vector2(400,400),this.tomoCamera=new W(new o.Vector2(0,0),this.tomoCameraSize),this.normalCamera=new W(new o.Vector2(0,0),this.normalCameraSize),this.threeDCamera=new W(new o.Vector2(0,0),this.threeDCameraSize),this.id=s.v4(),this.canvasSelected="testCanvas",this.viewSelected="x",this.circleSubject=new i.BehaviorSubject(new O(new o.Vector3(0,0,0),10)),this.ringSubject=new i.BehaviorSubject(new M(new o.Vector3(0,0,0),5,5.001)),this.circleMain=this.circleSubject.asObservable(),this.ringMain=this.ringSubject.asObservable(),this.planeSubject=new i.BehaviorSubject(new W(new o.Vector2(0,0),new o.Vector2(20,20))),this.planeMain=this.planeSubject.asObservable(),this.ringModelTemp=new M(new o.Vector3(0,0,0),3,3.0001),this.shapePos=[],this.shapeSubject=new i.BehaviorSubject(undefined),this.shapeMain=this.shapeSubject.asObservable(),this.canvas$=this.service.canvasOf(this.id),this.profile=[],this.profileSubject=new i.BehaviorSubject(undefined),this.profileMain=this.profileSubject.asObservable(),this.profileTest=new L([0,50,100,50,0]),this.imageInfo={pos:new o.Vector3(0,0,0),index:new o.Vector3(1,1,1),intensity:0},this.cube=new D(new o.Vector3(50,50,50),new o.Vector3(0,0,0),new o.Vector3(0,0,0)),this.sphere=new V(new o.Vector3(10,10,10),30),this.plane=new P(new W(new o.Vector2(0,0),new o.Vector2(10,10)),10,{r:new Uint8Array([255]),g:new Uint8Array([255]),b:new Uint8Array([255]),shape:new o.Vector2(1,1)},new o.Vector3(0,0,0),!0,.5,!0),this.obj=new F(new o.Vector3(0,0,0)),this.vrml=new E(new o.Vector3(0,0,0)),this.circle=new O(new o.Vector3(0,0,10),10),this.ring=new M(new o.Vector3(10,0,0),30,30),this.volume=new A("red","bandpass",0,.25,new _(new o.Vector3(0,0,0),new o.Vector3(190,256,151),new o.Vector3(190,256,151),new Float32Array(7344640))),this.imageCanvasSubject=new i.BehaviorSubject([]),this.imageCanvas$=this.imageCanvasSubject.asObservable(),this.lineSubject=new i.BehaviorSubject({id:"testLine",position:new o.Vector3(10,10,10),view:"x",crosslineLength:2}),this.lineMain$=this.lineSubject.asObservable(),this.outPost=new o.Vector3(10,10,10),this.imgBoundingBox=new W(new o.Vector2(0,0),new o.Vector2(60,60)),this.cameraSize=new W(new o.Vector2(0,0),new o.Vector2(80,60)),this.info=new i.Observable,this.info2=["hhhhh","sssss"],this.position2=new o.Vector2(100,100),this.a=10,this.crossline=new k(new o.Vector3(this.a,10,0),"x"),this.s=10,this.selecteImages=new t.EventEmitter,this.eventHandler=this.distributionService.eventHandler,this.fovHandler=this.distributionService.fovHandler,console.log(this.s);for(var d=0;d<5;)this.addCanvas(),d++;var f=new o.Vector2(0,-20),m=new o.Vector2(0,0),v=new o.Vector2(0,20);this.canvas$.subscribe(function(e){h.canvasTo=e[0],h.canvasVolume=[e[1],e[2],e[3]],h.canvas3D=e[4],h.entityStoreService.addFov(h.canvasTo,f),h.entityStoreService.addFov(h.canvasTo,m),h.entityStoreService.addFov(h.canvasTo,v)}),this.image3$.pipe(r.map(function(e){h.updateToCanvas(h.canvasVolume[0],e),h.updateToCanvas(h.canvasVolume[1],e),h.updateToCanvas(h.canvasVolume[2],e)})).subscribe(i.noop,console.error)}return Object.defineProperty(e.prototype,"image3",{get:function(){return this.image3Subject.value},set:function(e){this.image3Subject.next(e),this.loadService.image3Input=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tomo",{get:function(){return this.image2},set:function(e){this.image2=e},enumerable:!0,configurable:!0}),e.prototype.updateToCanvas=function(e,t){var n=this;this.service.mapOnCanvas(e,function(e){n.imageStoreService.updateImage(e,t)})},e.prototype.resize=function(){var e=document.getElementById("canvasTo");document.getElementById("canvas3D");console.log(e.onresize)},e.prototype.select=function(e,t){var n=this;this.canvasSelected=e,this.viewOf$(e).pipe(r.map(function(e){return n.viewSelected=e})).subscribe(i.noop,function(e){return console.error(e)}),this.service.select(e)},e.prototype.addCanvas=function(){this.service.addCanvasTo(this.id)},e.prototype.imageOf$=function(e){return this.service.imageOf$(e)},e.prototype.viewOf$=function(e){return this.service.viewOf$(e)},e.prototype.scrollImageOfCanvas=function(e,t){var n=this;this.service.mapOnCanvas(e,function(e){return n.imageStoreService.addIndex(e,t.delta/Math.abs(t.delta))}),t.event.preventDefault()},e.prototype.dragWidthOfImage=function(e,t){var n=this;this.service.mapOnCanvas(e,function(e){return n.imageStoreService.addWidthByStep(e,t.current.x-t.origin.x==0?0:Math.abs(t.current.x-t.origin.x)/(t.current.x-t.origin.x))})},e.prototype.entitiesOfCanvas=function(e){return this.entityStoreService.entitiesOfCanvas(e)},e.prototype.dragRing=function(e,t){this.position2=e.origin;var n=Math.sqrt(Math.pow(e.current.x-e.origin.x,2)+Math.pow(e.current.y-e.origin.y,2));this.entityStoreService.updateRingEntity({canvasId:t,model:new M(new o.Vector3(e.origin.x,e.origin.y,0),n,n+.001)})},e.prototype.getPointPos=function(e){this.shapePos.push(new o.Vector2(e.clientX,e.clientY))},e.prototype.getPointPos2=function(){this.shapePos.length>2&&(this.shapePos.pop(),this.shapePos.pop(),this.shapeSubject.next(new j(this.shapePos))),this.shapePos=[],this.profileSubject.next(new L([20*Math.random(),30*Math.random(),50*Math.random()]))},e.prototype.dragPlane=function(e){this.planeSubject.next(new W(new o.Vector2((e.current.x+e.origin.x)/2,(e.current.y+e.origin.y)/2),new o.Vector2(Math.abs(e.current.x-e.origin.x),Math.abs(e.current.y-e.origin.y))))},e.prototype.dragLine=function(e,t){var n=this,a=new o.Vector3(0,0,0);this.crosslineService.updatePosition("testLine",new o.Vector2(t.current.x,t.current.y),this.viewSelected),this.crosslineService.position3$("testLine").subscribe(function(e){return a=e}),this.lineSubject.next({id:"testLine",position:a,view:this.viewSelected,crosslineLength:2}),this.service.mapOnCanvas(e,function(e){return n.crosslineService.crosslineMain$.pipe(r.map(function(t){return n.getImageInfo(e,n.imgBoundingBox,t)})).subscribe(i.noop)})},e.prototype.dragCrossline=function(e,t){this.entityStoreService.updateCrosslineEntity({canvasId:t,model:new k(new o.Vector3(e.current.x,e.current.y,0),"z")})},e.prototype.getImageInfo=function(e,t,n){var i=new o.Vector3(Math.ceil(Math.ceil(n[n.length-1].position.x+t.size.x/2)/t.size.x*e.image.meta.size.x),Math.ceil(Math.ceil(n[n.length-1].position.y+t.size.x/2)/t.size.x*e.image.meta.size.y),Math.ceil(Math.ceil(n[n.length-1].position.z+t.size.x/2)/t.size.x*e.image.meta.size.z));switch(e.slicer.direction){case"x":this.imageStoreService.updateIndex(e,i.x);break;case"y":this.imageStoreService.updateIndex(e,i.y);break;case"z":this.imageStoreService.updateIndex(e,i.z)}this.imageInfo={pos:n[n.length-1].position,index:i,intensity:e.image.pixel3(i.x,i.y,i.z)}},e.prototype.setOutPos=function(e){this.outPost=e},e.prototype.setImageInfo=function(e){this.imageInfo=e},e.prototype.isSelected$=function(e){return this.service.isSelected$(e)},e.prototype.isWithCanvas=function(e){return this.service.isWithCanvas$(e)},e.prototype.dragLevelOfImage=function(e,t){var n=this;this.service.mapOnCanvas(e,function(e){return n.imageStoreService.addLevelByStep(e,t.current.y-t.origin.y==0?0:Math.abs(t.current.y-t.origin.y)/(t.current.y-t.origin.y))})},e.prototype.dragWidthLevelOfImage=function(e,t){var n=this;this.service.mapOnCanvas(e,function(e){return n.imageStoreService.addWidthLevelFilterByStep(e,t.current.x-t.origin.x==0?0:Math.abs(t.current.x-t.origin.x)/(t.current.x-t.origin.x),t.current.y-t.origin.y==0?0:Math.abs(t.current.y-t.origin.y)/(t.current.y-t.origin.y))})},e.prototype.displayFovs=function(e){this.fovs.emit(e)},e.prototype.ngOnInit=function(){this.top_left_info=this.infoService.top_left_info(),this.top_right_info=this.infoService.top_right_info(),this.bottom_left_info=this.infoService.bottom_left_info(),this.bottom_right_info=this.infoService.bottom_right_info()},e.prototype.ngAfterContentInit=function(){},e.prototype.ngOnDestroy=function(){this.ringSubject.complete(),this.circleSubject.complete()},e.decorators=[{type:t.Component,args:[{selector:"app-multi-slice-canvas",template:'\x3c!-- <div class="image-show" gdGap="1px" gdColumns="auto auto auto" fxFlexFill>\n  <div class="box" gdRow="auto / span 2"><canvas></canvas></div>\n  <div class="box" *ngFor="let x of [0, 1, 2, 3]"><canvas></canvas></div>\n</div> --\x3e\n\n\n<div gdGap="2px" gdColumns="auto auto auto" fxFlexFill>\n  <div id="canvasTo" class="box" gdRow="auto / span 2" >\n        <ng3-canvas (click)="select(canvasTo, 0)" [size]="tomoSize">\n          <ng3-event-distribute (fovs)="displayFovs($event)" [eventHandler]="eventHandler" [fovHandler]="fovHandler" [entityStore]="entityStoreService" [multiCanvas]="service"></ng3-event-distribute>\n          <ng3-orthographic-camera [size]="tomoCamera"></ng3-orthographic-camera>\n          <ng-container *ngFor="let t of entitiesOfCanvas(canvasTo) | async">\n              <ng3-tool-entity [model]="t.model"></ng3-tool-entity>\n          </ng-container>\n          <app-image3d\n        *ngIf="imageOf$(canvasTo) | async as image"\n        [image]="image"\n        [box]="imgBoundingBox"\n        resize="canvas"\n        [z]="-80"\n        (scroll)="scrollImageOfCanvas(canvasTo, $event)"\n        (drag)="dragWidthOfImage(canvasTo, $event); dragPlane($event)"\n      ></app-image3d>\n          <app-image2d-gray [image]="image2"></app-image2d-gray>\n        </ng3-canvas>\n      </div>\n  <div id="wrap" gdGap="2px" class="box" *ngFor="let c of canvasVolume; let indexV = index">\n    <ng3-canvas (click)="select(c, indexV + 1)" [size]="normalSize">\n      <ng3-event-distribute (fovs)="displayFovs($event)" [eventHandler]="eventHandler" [fovHandler]="fovHandler" [entityStore]="entityStoreService" [multiCanvas]="service"></ng3-event-distribute>\n      <ng3-orthographic-camera [size]="normalCamera"></ng3-orthographic-camera>\n      <app-image3d\n        *ngIf="imageOf$(c) | async as image"\n        [image]="image"\n        [box]="imgBoundingBox"\n        resize="canvas"\n        [z]="-80"\n        (scroll)="scrollImageOfCanvas(c, $event)"\n        (drag)="dragWidthOfImage(c, $event); dragPlane($event)"\n      ></app-image3d>\n      <ng-container *ngFor="let t of entitiesOfCanvas(c) | async">\n        <ng3-tool-entity [model]="t.model"></ng3-tool-entity>\n      </ng-container>\n    </ng3-canvas>\n    <corner-info [info]="top_left_info" [position]="\'top-left\'"></corner-info>\n    <corner-info [info]="top_right_info" [position]="\'top-right\'"></corner-info>\n    <corner-info\n      [info]="bottom_left_info"\n      [position]="\'bottom-left\'"\n    ></corner-info>\n    <corner-info\n      [info]="bottom_right_info"\n      [position]="\'bottom-right\'"\n    ></corner-info>\n    <app-info [info]="info2" [position]="position2"></app-info>\n  </div>\n  <div id="canvas3D" class = "box">\n    <ng3-canvas (click)="select(canvas3D, 4)" [size]="threeDSize">\n      <ng3-orthographic-camera [size]="threeDCamera"></ng3-orthographic-camera>\n      <ng3-orbit-controls [enabled]="true"></ng3-orbit-controls>\n      \x3c!-- <ng3-cube [model]="cube"></ng3-cube> --\x3e\n      <ng3-volume-rendering [model]="volume"></ng3-volume-rendering>\n    </ng3-canvas>\n  </div>\n</div>\n',styles:["#wrap{position:relative;width:500px;height:375px}.box1{width:270px;height:540px}.box2{width:270px;height:270px}#father{display:flex;flex-wrap:wrap}#grand{display:flex}:host{box-sizing:border-box;width:100%;height:100%;padding:2px}"]}]}],e.ctorParameters=function(){return[{type:Ye},{type:qe},{type:dn},{type:nn},{type:Se},{type:Re},{type:an}]},e.propDecorators={fovs:[{type:t.Output}],image3:[{type:t.Input}],tomo:[{type:t.Input}],tomoSize:[{type:t.Input}],normalSize:[{type:t.Input}],threeDSize:[{type:t.Input}],tomoCameraSize:[{type:t.Input}],normalCameraSize:[{type:t.Input}],threeDCameraSize:[{type:t.Input}],selecteImages:[{type:t.Output}]},e}(),mn=function(){function e(e,t,n,i,r,a){this.service=e,this.imageStoreService=t,this.entityStoreService=n,this.renderer=i,this.eventDistribution=r,this.loadService=a,this.selectedImages$=this.service.selectedImages$,this.whichDraging=this.eventDistribution.eventHandler,this.fovHnadler=this.eventDistribution.fovHandler,this.camera=new o.PerspectiveCamera}return e.prototype.loadInput=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.service.loadToCanvas(t,e.loadService.image3Input)})},e.prototype.updateCamera=function(){console.log("show the renderer",this.renderer)},e.prototype.updateCamera2=function(){this.renderer.camera.scale.set(1,1,1.1),this.renderer.render()},e.prototype.updateCamera3=function(){this.camera.scale.set(.5,.5,1)},e.prototype.changeDirection=function(e){var t=this;this.service.mapSelectedCanvas(function(n){t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateDirection(n,e)}),t.entityStoreService.crosslineOnCanvas(n,function(i){t.entityStoreService.updateCrosslineEntity({canvasId:n,model:f({},i,{view:e})})})})},e.prototype.dragRing=function(){this.eventDistribution.dragRing()},e.prototype.dragLine=function(){this.eventDistribution.dragLine()},e.prototype.dragCrossline=function(){this.eventDistribution.dragCrossline()},e.prototype.dragFov=function(){this.eventDistribution.dragFov()},e.prototype.dragFov1=function(){this.eventDistribution.dragFov1()},e.prototype.dragFov2=function(){this.eventDistribution.dragFov2()},e.prototype.dragFov3=function(){this.eventDistribution.dragFov3()},e.prototype.addToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addRing(t)})},e.prototype.copyToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.copyEntity(t)})},e.prototype.cutToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.cutEntity(t)})},e.prototype.pasteToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.pasteEntity(t)})},e.prototype.removeToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.removeEntityWithCanvasId(t)})},e.prototype.addLine=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addLine(t)})},e.prototype.addCrossLine=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addCrossLine(t)})},e.prototype.addFov=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addFov(t)})},e.prototype.changeIndex=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateIndex(n,e)})})},e.prototype.changeColormap=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateColormap(n,e)})})},e.prototype.changeWidthLevel=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateWidthLevelFilter(n,e.width,e.level)})})},e.prototype.imageLoad=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.loadToCanvas(n,e)})},e.prototype.rotate_plane=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.service.mapOnCanvas(t,function(t){return e.imageStoreService.addRotation(t,new o.Vector3(0,0,Math.PI/2))})})},e.prototype.showEntitiesofCanva=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.entitiesOfCanvas(t).subscribe(function(e){return console.log(e)})})},e.prototype.showEntities=function(){var e=this;this.entityStoreService.showEntities().subscribe(function(e){return console.log("all",e)}),this.entityStoreService.showClipBoard().subscribe(function(e){return console.log("clip board",e)}),this.service.mapSelectedCanvas(function(t){return e.entityStoreService.entitiesOfCanvas(t).subscribe(function(e){return console.log("entitiesOfCanvas",e)})})},e.prototype.showCanvas=function(){console.log(this.service.componentCanvasSubject.value)},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"app-multi-canvas-controller",template:'\x3c!-- <app-local-image-loader\n  (imageLoad)="imageLoad($event)"\n></app-local-image-loader> --\x3e\n<app-http-image-loader (imageLoad)="imageLoad($event)"></app-http-image-loader>\n\n<app-window\n  (widthlevelChange)="changeWidthLevel($event)"\n  [related]="selectedImages$ | async"\n></app-window>\n<app-direction\n  (directionChange)="changeDirection($event)"\n  (sliceIndexChange)="changeIndex($event)"\n  [related]="selectedImages$ | async"\n></app-direction>\n<app-colormap\n  (colormapChange)="changeColormap($event)"\n  [related]="selectedImages$ | async"\n></app-colormap>\n<br />\n<button (click)="rotate_plane()">rotate</button>\n<br />\n<button (click)="addToolRing()">addToolRing</button>\n<button (click)="addLine()">addLine</button>\n<button (click)="addCrossLine()">addCrossLine</button>\n<button (click)="addFov()">addFov</button>\n<br />\n<button (click)="dragRing()">{{ whichDraging.ring.tag }} ring</button>\n<button (click)="dragLine()">{{ whichDraging.line.tag }} line</button>\n<button (click)="dragCrossline()">{{ whichDraging.crossline.tag }} crossline</button>\n<button (click)="dragFov()">{{whichDraging.fov.tag}} fov</button>\n<br />\n<button (click)="dragFov1()">{{ fovHnadler.fov1.tag }} fov1</button>\n<button (click)="dragFov2()">{{ fovHnadler.fov2.tag }} fov2</button>\n<button (click)="dragFov3()">{{ fovHnadler.fov3.tag }} fov3</button>\n\n<button (click)="copyToolRing()">copyToolRing</button>\n<button (click)="cutToolRing()">cutToolRing</button>\n<button (click)="pasteToolRing()">pasteToolRing</button>\n<button (click)="removeToolRing()">removeToolRing</button>\n<br />\n<button (click)="showEntities()">showEntities</button>\n<button (click)="showCanvas()">showCanvas</button>\n\x3c!-- <button (click)="updateCamera()">update camera</button>\n<button (click)="updateCamera2()">update camera2</button>\n<button (click)="updateCamera3()">update camera3</button> --\x3e\n<button (click)="loadInput()" >loadInput</button>\n',providers:[te,Z,X],styles:[""]}]}],e.ctorParameters=function(){return[{type:Ye},{type:qe},{type:Se},{type:te},{type:an},{type:Re}]},e}(),vn=function(){function e(e,t,n,i,r,a){this.service=e,this.imageStoreService=t,this.entityStoreService=n,this.renderer=i,this.eventDistribution=r,this.loadService=a,this.selectedImages$=this.service.selectedImages$,this.whichDraging=this.eventDistribution.eventHandler,this.fovHnadler=this.eventDistribution.fovHandler,this.camera=new o.PerspectiveCamera}return e.prototype.loadInput=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.service.loadToCanvas(t,e.loadService.image3Input)})},e.prototype.loadTomo=function(){},e.prototype.changeDirection=function(e){var t=this;this.service.mapSelectedCanvas(function(n){t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateDirection(n,e)}),t.entityStoreService.crosslineOnCanvas(n,function(i){t.entityStoreService.updateCrosslineEntity({canvasId:n,model:f({},i,{view:e})})})})},e.prototype.dragRing=function(){this.eventDistribution.dragRing()},e.prototype.dragLine=function(){this.eventDistribution.dragLine()},e.prototype.dragCrossline=function(){this.eventDistribution.dragCrossline()},e.prototype.dragFov1=function(){this.eventDistribution.dragFov1()},e.prototype.dragFov2=function(){this.eventDistribution.dragFov2()},e.prototype.dragFov3=function(){this.eventDistribution.dragFov3()},e.prototype.addToolRing=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addRing(t)})},e.prototype.copyTool=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.copyEntity(t)})},e.prototype.cutTool=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.cutEntity(t)})},e.prototype.pasteTool=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.pasteEntity(t)})},e.prototype.removeTool=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.removeEntityWithCanvasId(t)})},e.prototype.addCrossLine=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addCrossLine(t)})},e.prototype.addFov=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.addFov(t)})},e.prototype.changeIndex=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateIndex(n,e)})})},e.prototype.changeColormap=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateColormap(n,e)})})},e.prototype.changeWidthLevel=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.mapOnCanvas(n,function(n){return t.imageStoreService.updateWidthLevelFilter(n,e.width,e.level)})})},e.prototype.imageLoad=function(e){var t=this;this.service.mapSelectedCanvas(function(n){return t.service.loadToCanvas(n,e)})},e.prototype.rotate_plane=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.service.mapOnCanvas(t,function(t){return e.imageStoreService.addRotation(t,new o.Vector3(0,0,Math.PI/2))})})},e.prototype.showEntitiesofCanva=function(){var e=this;this.service.mapSelectedCanvas(function(t){return e.entityStoreService.entitiesOfCanvas(t).subscribe(function(e){return console.log(e)})})},e.prototype.showEntities=function(){var e=this;this.entityStoreService.showEntities().subscribe(function(e){return console.log("all",e)}),this.entityStoreService.showClipBoard().subscribe(function(e){return console.log("clip board",e)}),this.service.mapSelectedCanvas(function(t){return e.entityStoreService.entitiesOfCanvas(t).subscribe(function(e){return console.log("entitiesOfCanvas",e)})})},e.prototype.showCanvas=function(){console.log(this.service.componentCanvasSubject.value)},e.prototype.ngOnInit=function(){},e.decorators=[{type:t.Component,args:[{selector:"app-toolbox",template:'<app-http-image-loader (imageLoad)="imageLoad($event)"></app-http-image-loader>\n<button (click)="loadInput()" >loadInput</button>\n\x3c!-- <app-window\n  (widthlevelChange)="changeWidthLevel($event)"\n  [related]="selectedImages$ | async"\n></app-window> --\x3e\n<app-direction\n  (directionChange)="changeDirection($event)"\n  (sliceIndexChange)="changeIndex($event)"\n  [related]="selectedImages$ | async"\n></app-direction>\n<app-colormap\n  (colormapChange)="changeColormap($event)"\n  [related]="selectedImages$ | async"\n></app-colormap>\n\n<button (click)="addToolRing()">addToolRing</button>\n<button (click)="addCrossLine()">addCrossLine</button>\n<button (click)="addFov()">addFov</button>\n<button (click)="dragRing()">{{ whichDraging.ring.tag }} ring</button>\n<button (click)="dragCrossline()">{{ whichDraging.crossline.tag }} crossline</button>\n<button (click)="dragFov1()">{{ fovHnadler.fov1.tag }} fov1</button>\n<button (click)="dragFov2()">{{ fovHnadler.fov2.tag }} fov2</button>\n<button (click)="dragFov3()">{{ fovHnadler.fov3.tag }} fov3</button>\n<button (click)="copyTool()">copyTool</button>\n<button (click)="cutTool()">cutTool</button>\n<button (click)="pasteTool()">pasteTool</button>\n<button (click)="removeTool()">removeTool</button>\n',providers:[te,Z,X],styles:[""]}]}],e.ctorParameters=function(){return[{type:Ye},{type:qe},{type:Se},{type:te},{type:an},{type:Re}]},e}(),yn=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[fn,mn,vn],imports:[n.CommonModule,rn,Ne,w,p.FlexLayoutModule],providers:[Ye],exports:[fn,mn,vn]}]}],e}(),gn=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[g],imports:[n.CommonModule,u.HttpClientModule,Ht,rn,Ne,yn,w,b],exports:[g,Ne,yn,rn,Ht,w,b]}]}],e}();function bn(e,t,n){switch(e){case"left":return new N(t,n.right,n.top,n.bottom);case"right":return new N(n.left,t,n.top,n.bottom);case"top":return new N(n.left,n.right,t,n.bottom);case"bottom":return new N(n.left,n.right,n.top,t)}}!function(){function e(){this._id=-1,this._worldCoordinates=null,this._dataCoordinates=null,this._screenCoordinates=null,this._value=null,this._id=-1,this._worldCoordinates=null,this._dataCoordinates=null,this._screenCoordinates=null,this._value=null}Object.defineProperty(e.prototype,"worldCoordinates",{get:function(){return this._worldCoordinates},set:function(e){this._worldCoordinates=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataCoordinates",{get:function(){return this._dataCoordinates},set:function(e){this._dataCoordinates=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"screenCoordinates",{get:function(){return this._screenCoordinates},set:function(e){this._screenCoordinates=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this._value=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this._id},set:function(e){this._id=e},enumerable:!0,configurable:!0})}();var xn=function(){function e(){}return e.uniforms=function(){return{uCanvasWidth:{type:"f",value:0,typeGLSL:"float"},uCanvasHeight:{type:"f",value:0,typeGLSL:"float"},uWidth:{type:"f",value:1,typeGLSL:"float"},uOpacity:{type:"f",value:1,typeGLSL:"float"},uTextureFilled:{type:"t",value:[],typeGLSL:"sampler2D"}}},e}(),wn=function(){function e(e){this._functions={},this._main="",this._uniforms=e,this._functions={},this._main=""}return e.prototype.functions=function(){""===this._main&&this.main();var e="";for(var t in this._functions)e+=this._functions[t]+"\n";return e},e.prototype.uniforms=function(){var e="";for(var t in this._uniforms){var n=this._uniforms[t];e+="uniform "+n.typeGLSL+" "+t,n&&n.length&&(e+="["+n.length+"]"),e+=";\n"}return e},e.prototype.main=function(){this._main="\n\nfloat luma (vec3 rgb) {\n  return (rgb.r + rgb.g + rgb.b)/3.0;\n}\n\nconst float T = 0.04;\nconst float M = 1.0;\nconst float L = 0.002;\n\nvoid main(void) {\n\n  vec2 texCoord = vec2(((vProjectedCoords.x / vProjectedCoords.w) + 1.0 ) / 2.0,\n                ((vProjectedCoords.y / vProjectedCoords.w) + 1.0 ) / 2.0 );\n\n  float borderWidth = uWidth; // in px\n  float step_u = borderWidth * 1.0 / uCanvasWidth;\n  float step_v = borderWidth * 1.0 / uCanvasHeight;\n  vec4 centerPixel = texture2D(uTextureFilled, texCoord);\n\n  vec4 rightPixel  = texture2D(uTextureFilled, texCoord + vec2(step_u, 0.0));\n  vec4 bottomPixel = texture2D(uTextureFilled, texCoord + vec2(0.0, step_v));\n\n  // now manually compute the derivatives\n  float _dFdX = length(rightPixel - centerPixel) / step_u;\n  float _dFdY = length(bottomPixel - centerPixel) / step_v;\n\n  // gl_FragColor.r = _dFdX;\n  // gl_FragColor.g = _dFdY;\n  gl_FragColor.r = max(max(centerPixel.r, rightPixel.r), bottomPixel.r);\n  gl_FragColor.g = max(max(centerPixel.g, rightPixel.g), bottomPixel.g);\n  gl_FragColor.b = max(max(centerPixel.b, rightPixel.b), bottomPixel.b);\n  float maxDerivative = max(_dFdX, _dFdY);\n  float clampedDerivative = clamp(maxDerivative, 0., 1.);\n  gl_FragColor.a = uOpacity * clampedDerivative;\n\n  return;\n  // float h = 1./uCanvasHeight;\n  // float w = 1./uCanvasWidth;\n  // vec4 n[9];\n  // n[0] = texture2D(uTextureFilled, vProjectedTextCoords + vec2( -w, -h));\n  // n[1] = texture2D(uTextureFilled, vProjectedTextCoords + vec2(0.0, -h));\n  // n[2] = texture2D(uTextureFilled, vProjectedTextCoords + vec2(  w, -h));\n  // n[3] = texture2D(uTextureFilled, vProjectedTextCoords + vec2( -w, 0.0));\n  // n[4] = texture2D(uTextureFilled, vProjectedTextCoords);\n  // n[5] = texture2D(uTextureFilled, texCoord + vec2(  w, 0.0));\n  // n[6] = texture2D(uTextureFilled, texCoord + vec2( -w, h));\n  // n[7] = texture2D(uTextureFilled, texCoord + vec2(0.0, h));\n  // n[8] = texture2D(uTextureFilled, texCoord + vec2(  w, h));\n  // vec4 sobel_horizEdge = n[2] + (2.0*n[5]) + n[8] - (n[0] + (2.0*n[3]) + n[6]);\n  // vec4 sobel_vertEdge  = n[0] + (2.0*n[1]) + n[2] - (n[6] + (2.0*n[7]) + n[8]);\n  // vec3 sobel = sqrt((sobel_horizEdge.rgb * sobel_horizEdge.rgb) + (sobel_vertEdge.rgb * sobel_vertEdge.rgb));\n  // gl_FragColor = vec4( sobel, max(max(sobel.r, sobel.g), sobel.b) );\n\n  // return;\n}\n   "},e.prototype.compute=function(){return"\n// uniforms\n"+this.uniforms()+"\n\n// varying (should fetch it from vertex directly)\nvarying vec4      vProjectedCoords;\n\n// tailored functions\n"+this.functions()+"\n\n// main loop\n"+this._main+"\n      "},e}(),_n=function(){function e(){}return e.prototype.compute=function(){return"\nvarying vec4 vProjectedCoords;\n\n//\n// main\n//\nvoid main() {\n\n  vec4 vPos = modelMatrix * vec4(position, 1.0 );\n  mat4 vProjectionViewMatrix = projectionMatrix * viewMatrix;\n  vProjectedCoords =  projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );\n\n}\n        "},e}(),Sn=function(){function e(){}return e.uniforms=function(){return{uTextureSize:{type:"i",value:0,typeGLSL:"int"},uTextureContainer:{type:"tv",value:[],typeGLSL:"sampler2D",length:7},uDataDimensions:{type:"iv",value:[0,0,0],typeGLSL:"ivec3"},uWorldToData:{type:"m4",value:new o.Matrix4,typeGLSL:"mat4"},uWindowCenterWidth:{type:"fv1",value:[0,0],typeGLSL:"float",length:2},uLowerUpperThreshold:{type:"fv1",value:[0,0],typeGLSL:"float",length:2},uRescaleSlopeIntercept:{type:"fv1",value:[0,0],typeGLSL:"float",length:2},uNumberOfChannels:{type:"i",value:1,typeGLSL:"int"},uBitsAllocated:{type:"i",value:8,typeGLSL:"int"},uInvert:{type:"i",value:0,typeGLSL:"int"},uLut:{type:"i",value:0,typeGLSL:"int"},uTextureLUT:{type:"t",value:[],typeGLSL:"sampler2D"},uLutSegmentation:{type:"i",value:0,typeGLSL:"int"},uTextureLUTSegmentation:{type:"t",value:[],typeGLSL:"sampler2D"},uPixelType:{type:"i",value:0,typeGLSL:"int"},uPackedPerPixel:{type:"i",value:1,typeGLSL:"int"},uInterpolation:{type:"i",value:1,typeGLSL:"int"},uCanvasWidth:{type:"f",value:0,typeGLSL:"float"},uCanvasHeight:{type:"f",value:0,typeGLSL:"float"},uBorderColor:{type:"v3",value:[1,0,.5],typeGLSL:"vec3"},uBorderWidth:{type:"f",value:2,typeGLSL:"float"},uBorderMargin:{type:"f",value:2,typeGLSL:"float"},uBorderDashLength:{type:"f",value:10,typeGLSL:"float"},uOpacity:{type:"f",value:1,typeGLSL:"float"},uSpacing:{type:"f",value:0,typeGLSL:"float"},uThickness:{type:"f",value:0,typeGLSL:"float"},uThicknessMethod:{type:"i",value:0,typeGLSL:"int"}}},e}(),Cn=function(){function e(e){this._functions={},this._main="",this._uniforms=e,this._functions={},this._main=""}return e.prototype.functions=function(){""===this._main&&this.main();var e="";for(var t in this._functions)e+=this._functions[t]+"\n";return e},e.prototype.uniforms=function(){var e="";for(var t in this._uniforms){var n=this._uniforms[t];e+="uniform "+n.typeGLSL+" "+t,n&&n.length&&(e+="["+n.length+"]"),e+=";\n"}return e},e.prototype.main=function(){this._main="\nvoid main(void) {\n\n  // draw border if slice is cropped\n  // float uBorderDashLength = 10.;\n\n  if( uCanvasWidth > 0. &&\n      ((gl_FragCoord.x > uBorderMargin && (gl_FragCoord.x - uBorderMargin) < uBorderWidth) ||\n       (gl_FragCoord.x < (uCanvasWidth - uBorderMargin) && (gl_FragCoord.x + uBorderMargin) > (uCanvasWidth - uBorderWidth) ))){\n    float valueY = mod(gl_FragCoord.y, 2. * uBorderDashLength);\n    if( valueY < uBorderDashLength && gl_FragCoord.y > uBorderMargin && gl_FragCoord.y < (uCanvasHeight - uBorderMargin) ){\n      gl_FragColor = vec4(uBorderColor, 1.);\n      return;\n    }\n  }\n\n  if( uCanvasHeight > 0. &&\n      ((gl_FragCoord.y > uBorderMargin && (gl_FragCoord.y - uBorderMargin) < uBorderWidth) ||\n       (gl_FragCoord.y < (uCanvasHeight - uBorderMargin) && (gl_FragCoord.y + uBorderMargin) > (uCanvasHeight - uBorderWidth) ))){\n    float valueX = mod(gl_FragCoord.x, 2. * uBorderDashLength);\n    if( valueX < uBorderDashLength && gl_FragCoord.x > uBorderMargin && gl_FragCoord.x < (uCanvasWidth - uBorderMargin) ){\n      gl_FragColor = vec4(uBorderColor, 1.);\n      return;\n    }\n  }\n\n  // get texture coordinates of current pixel\n  vec4 dataValue = vec4(0.);\n  vec3 gradient = vec3(1.); // gradient calculations will be skipped if it is equal to vec3(1.)\n  float steps = floor(uThickness / uSpacing + 0.5);\n\n  if (steps > 1.) {\n    vec3 origin = vPos - uThickness * 0.5 * vNormal;\n    vec4 dataValueAcc = vec4(0.);\n    for (float step = 0.; step < 128.; step++) {\n      if (step >= steps) {\n        break;\n      }\n\n      vec4 dataCoordinates = uWorldToData * vec4(origin + step * uSpacing * vNormal, 1.);\n      vec3 currentVoxel = dataCoordinates.xyz;\n      "+ue(this,"currentVoxel","dataValueAcc","gradient")+";\n\n      if (step == 0.) {\n        dataValue.r = dataValueAcc.r;\n        continue;\n      }\n\n      if (uThicknessMethod == 0) {\n        dataValue.r = max(dataValueAcc.r, dataValue.r);\n      }\n      if (uThicknessMethod == 1) {\n        dataValue.r += dataValueAcc.r;\n      }\n      if (uThicknessMethod == 2) {\n        dataValue.r = min(dataValueAcc.r, dataValue.r);\n      }\n    }\n\n    if (uThicknessMethod == 1) {\n      dataValue.r /= steps;\n    }\n  } else {\n    vec4 dataCoordinates = uWorldToData * vec4(vPos, 1.);\n    vec3 currentVoxel = dataCoordinates.xyz;\n    "+ue(this,"currentVoxel","dataValue","gradient")+"\n  }\n\n  if(uNumberOfChannels == 1){\n    // rescale/slope\n    float realIntensity = dataValue.r * uRescaleSlopeIntercept[0] + uRescaleSlopeIntercept[1];\n\n    // threshold\n    if (realIntensity < uLowerUpperThreshold[0] || realIntensity > uLowerUpperThreshold[1]) {\n      discard;\n    }\n\n    // normalize\n    float windowMin = uWindowCenterWidth[0] - uWindowCenterWidth[1] * 0.5;\n    float normalizedIntensity =\n      ( realIntensity - windowMin ) / uWindowCenterWidth[1];\n    dataValue.r = dataValue.g = dataValue.b = normalizedIntensity;\n    dataValue.a = 1.;\n\n    // apply LUT\n    if(uLut == 1){\n      // should opacity be grabbed there?\n      dataValue = texture2D( uTextureLUT, vec2( normalizedIntensity , 1.0) );\n    }\n\n    // apply segmentation\n    if(uLutSegmentation == 1){\n      // should opacity be grabbed there?\n      //\n      float textureWidth = 256.;\n      float textureHeight = 128.;\n      float min = 0.;\n      // start at 0!\n      int adjustedIntensity = int(floor(realIntensity + 0.5));\n\n      // Get row and column in the texture\n      int colIndex = int(mod(float(adjustedIntensity), textureWidth));\n      int rowIndex = int(floor(float(adjustedIntensity)/textureWidth));\n\n      float texWidth = 1./textureWidth;\n      float texHeight = 1./textureHeight;\n\n      // Map row and column to uv\n      vec2 uv = vec2(0,0);\n      uv.x = 0.5 * texWidth + (texWidth * float(colIndex));\n      uv.y = 1. - (0.5 * texHeight + float(rowIndex) * texHeight);\n\n      dataValue = texture2D( uTextureLUTSegmentation, uv );\n    }\n  }\n\n  if(uInvert == 1){\n    dataValue.xyz = vec3(1.) - dataValue.xyz;\n  }\n\n  dataValue.a = dataValue.a*uOpacity;\n\n  gl_FragColor = dataValue;\n}\n   "},e.prototype.compute=function(){return"\n// uniforms\n"+this.uniforms()+"\n\n// varying (should fetch it from vertex directly)\nvarying vec3 vPos;\nvarying vec3 vNormal;\n\n// tailored functions\n"+this.functions()+"\n\n// main loop\n"+this._main+"\n      "},e}(),In=function(){function e(){}return e.prototype.compute=function(){return"\nvarying vec3 vPos;\nvarying vec3 vNormal;\n\nvoid main() {\n  vNormal = normal;\n  vPos = (modelMatrix * vec4(position, 1.0 )).xyz;\n  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );\n\n}\n        "},e}(),Pn=function(){function e(){}return e.uniforms=function(){return{uTextureBackTest0:{type:"t",value:[],typeGLSL:"sampler2D"},uTextureBackTest1:{type:"t",value:[],typeGLSL:"sampler2D"},uOpacity0:{type:"f",value:1,typeGLSL:"float"},uOpacity1:{type:"f",value:1,typeGLSL:"float"},uType0:{type:"i",value:0,typeGLSL:"int"},uType1:{type:"i",value:1,typeGLSL:"int"},uTrackMouse:{type:"i",value:0,typeGLSL:"int"},uMouse:{type:"v2",value:new o.Vector2,typeGLSL:"vec2"}}},e}(),zn=function(){function e(e){this._functions={},this._main="",this._uniforms=e,this._functions={},this._main=""}return e.prototype.functions=function(){""===this._main&&this.main();var e="";for(var t in this._functions)e+=this._functions[t]+"\n";return e},e.prototype.uniforms=function(){var e="";for(var t in this._uniforms){var n=this._uniforms[t];e+="uniform "+n.typeGLSL+" "+t,n&&n.length&&(e+="["+n.length+"]"),e+=";\n"}return e},e.prototype.main=function(){this._main="\nvoid main(void) {\n\n  vec2 texc = vec2(((vProjectedCoords.x / vProjectedCoords.w) + 1.0 ) / 2.0,\n                ((vProjectedCoords.y / vProjectedCoords.w) + 1.0 ) / 2.0 );\n\n  // just silence warning for\n  // vec4 dummy = vPos;\n\n  //The back position is the world space position stored in the texture.\n  vec4 baseColor0 = texture2D(uTextureBackTest0, texc);\n  vec4 baseColor1 = texture2D(uTextureBackTest1, texc);\n\n  if( uTrackMouse == 1 ){\n\n      if( vProjectedCoords.x < uMouse.x ){\n\n        gl_FragColor = baseColor0;\n\n      }\n      else{\n\n        gl_FragColor = mix( baseColor0, baseColor1, uOpacity1 );\n\n      }\n\n  }\n  else{\n\n    if( uType1 == 0 ){\n\n      //merge an image into\n      gl_FragColor = mix( baseColor0, baseColor1, uOpacity1 );\n\n    }\n    else{\n\n      float opacity = baseColor1.a;\n      gl_FragColor = mix( baseColor0, baseColor1, opacity * uOpacity1 );\n\n    }\n\n  }\n\n  return;\n}\n   "},e.prototype.compute=function(){return"\n// uniforms\n"+this.uniforms()+"\n\n// varying (should fetch it from vertex directly)\n// varying vec4      vPos;\nvarying vec4      vProjectedCoords;\n\n// tailored functions\n"+this.functions()+"\n\n// main loop\n"+this._main+"\n      "},e}(),Dn=function(){function e(){}return e.prototype.compute=function(){return"\n// varying vec4 vPos;\nvarying vec4 vProjectedCoords;\n\n//\n// main\n//\nvoid main() {\n\n  vec4 vPos = modelMatrix * vec4(position, 1.0 );\n  vProjectedCoords =  projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );\n\n}\n        "},e}(),Vn=function(){function e(){}return e.uniforms=function(){return{uCanvasWidth:{type:"f",value:0,typeGLSL:"float"},uCanvasHeight:{type:"f",value:0,typeGLSL:"float"},uSlice:{type:"v4",value:[0,0,0,0],typeGLSL:"vec4"},uPlane1:{type:"v4",value:[0,0,0,0],typeGLSL:"vec4"},uPlaneColor1:{type:"v3",value:[1,1,0],typeGLSL:"vec3"},uPlane2:{type:"v4",value:[0,0,0,0],typeGLSL:"vec4"},uPlaneColor2:{type:"v3",value:[1,1,0],typeGLSL:"vec3"},uPlane3:{type:"v4",value:[0,0,0,0],typeGLSL:"vec4"},uPlaneColor3:{type:"v3",value:[1,1,0],typeGLSL:"vec3"}}},e}(),On=function(){function e(e){this._functions={},this._main="",this._uniforms=e,this._functions={},this._main=""}return e.prototype.functions=function(){""===this._main&&this.main();var e="";for(var t in this._functions)e+=this._functions[t]+"\n";return e},e.prototype.uniforms=function(){var e="";for(var t in this._uniforms){var n=this._uniforms[t];e+="uniform "+n.typeGLSL+" "+t,n&&n.length&&(e+="["+n.length+"]"),e+=";\n"}return e},e.prototype.main=function(){this._main="\nvoid intersectionProjection(\n  in vec4 plane,\n  in vec4 slice,\n  out vec3 intersectionProjection){\n\n      vec3 intersectionDirection = normalize(cross(plane.xyz, slice.xyz));\n      vec3 intersectionPoint =\n        cross(intersectionDirection,slice.xyz) * plane.w +\n        cross(plane.xyz, intersectionDirection) * slice.w;\n\n      intersectionProjection =\n        intersectionPoint.xyz +\n        (dot(vPos.xyz - intersectionPoint, intersectionDirection)\n          * intersectionDirection);\n\n}\n\nvoid main(void) {\n      vec4 c1 = vec4(0., 0., 0., 0.);\n      vec4 c2 = vec4(0., 0., 0., 0.);\n      vec4 c3 = vec4(0., 0., 0., 0.);\n\n      // localizer #1\n      // must be normalized!\n      if(length(uPlane1.xyz) > 0.5) {\n        vec3 projection1 = vec3(1.);\n        intersectionProjection(\n          uPlane1,\n          uSlice,\n          projection1\n        );\n\n        vec4 projInter1 = (vProjectionViewMatrix * vec4(projection1, 1.));\n        vec3 ndc1 = projInter1.xyz / projInter1.w;\n        vec2 screenSpace1 = (ndc1.xy * .5 + .5) * vec2(uCanvasWidth, uCanvasHeight);\n\n        float d1 = distance(gl_FragCoord.xy, screenSpace1.xy);\n        c1 = vec4(uPlaneColor1, 1. - smoothstep(.5, .7, d1));\n      }\n\n      // localizer #2\n      if(length(uPlane2.xyz) > 0.5) {\n        vec3 projection2 = vec3(1.);\n        intersectionProjection(\n          uPlane2,\n          uSlice,\n          projection2\n        );\n\n        vec4 projInter2 = (vProjectionViewMatrix * vec4(projection2, 1.));\n        vec3 ndc2 = projInter2.xyz / projInter2.w;\n        vec2 screenSpace2 = (ndc2.xy * .5 + .5) * vec2(uCanvasWidth, uCanvasHeight);\n\n        float d2 = distance(gl_FragCoord.xy, screenSpace2.xy);\n        c2 = vec4(uPlaneColor2, 1. - smoothstep(.5, .7, d2));\n      }\n\n      // localizer #3\n      if(length(uPlane3.xyz) > 0.5) {\n        vec3 projection3 = vec3(1.);\n        intersectionProjection(\n          uPlane3,\n          uSlice,\n          projection3\n        );\n\n        vec4 projInter3 = (vProjectionViewMatrix * vec4(projection3, 1.));\n        vec3 ndc3 = projInter3.xyz / projInter3.w;\n        vec2 screenSpace3 = (ndc3.xy * .5 + .5) * vec2(uCanvasWidth, uCanvasHeight);\n\n        float d3 = distance(gl_FragCoord.xy, screenSpace3.xy);\n        c3 = vec4(uPlaneColor3, 1. - smoothstep(.5, .7, d3));\n      }\n\n      // float uBorderDashLength = 10.0;\n      // float uBorderWidth = 2.0;\n      // float valueX = mod(gl_FragCoord.x, 2. * uBorderDashLength);\n      // float valueY = mod(gl_FragCoord.y, 2. * uBorderDashLength);\n      // if( valueX < uBorderDashLength || valueY < uBorderDashLength ){\n        vec3 colorMix = c1.xyz*c1.w + c2.xyz*c2.w + c3.xyz*c3.w;\n        gl_FragColor = vec4(colorMix, max(max(c1.w, c2.w),c3.w)*0.5);\n        return;\n      // }\n\n      // gl_FragColor = vec4(0., 0., 0., 0.);\n      // return;\n}\n   "},e.prototype.compute=function(){return"\n// uniforms\n"+this.uniforms()+"\n\n// varying (should fetch it from vertex directly)\nvarying vec4 vPos;\nvarying mat4 vProjectionViewMatrix;\n\n// tailored functions\n"+this.functions()+"\n\n// main loop\n"+this._main+"\n      "},e}(),Mn=function(){function e(){}return e.prototype.compute=function(){return"\nvarying vec4 vPos;\nvarying mat4 vProjectionViewMatrix;\n\n//\n// main\n//\nvoid main() {\n\n  vPos = modelMatrix * vec4(position, 1.0 );\n  vProjectionViewMatrix = projectionMatrix * viewMatrix;\n  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );\n\n}\n        "},e}();e.BoundingBox2FromBox2=G,e.BoundingBox2FromCenterSize=W,e.BoundingBox2FromLRTB=N,e.Boundingbox2Controller=H,e.COLORS={blue:"#00B0FF",yellow:"#FFEB3B",red:"#F50057",green:"#76FF03",white:"#FFF",lightRed:"#F77"},e.CanvasState=en,e.CircleModel=O,e.ContourFragmentShader=wn,e.ContourUniformShader=xn,e.ContourVertexShader=_n,e.CrossLineModel=k,e.CubeModel=D,e.DataFragmentShader=Cn,e.DataUniformShader=Sn,e.DataVertexShader=In,e.Direction=$,e.EntityComponent=de,e.EntityState=Qt,e.FovModel=B,e.GrayImage2=S,e.GrayImage2PixelwiseFilter=Oe,e.GrayImage2ScaleOffsetFilter=Me,e.GrayImage2WindowFilter=je,e.GrayImage3=_,e.HelperLut=ve,e.HelpersVolumeRendering=he,e.Hospital=cn,e.ImageState=Zt,e.ImageWComponent=g,e.ImageWModule=gn,e.ImageWService=y,e.InfoPlanceModel=z,e.LayerFragmentShader=zn,e.LayerUniformShader=Pn,e.LayerVertexShader=Dn,e.LineModel=T,e.LocalizerFragmentShader=On,e.LocalizerUniformShader=Vn,e.LocalizerVertexShader=Mn,e.OBJModel=F,e.Patient=sn,e.Physics=ln,e.Plane2Model=P,e.ProfileModel=L,e.RGBImage2=I,e.Range2=R,e.Ring=hn,e.RingModel=M,e.Scale=un,e.Slicer=Pe,e.SphereModel=V,e.StoreByArray=Fe,e.TEST_MODELS=Ot,e.UserDefinedModel=j,e.VRFragmentShader=pe,e.VRMLLoader=Ft,e.VRMLModel=E,e.VRUniformShader=ne,e.VRVertexShader=ie,e.VolumeModel=A,e.Zoom=pn,e.applyColormap=Ve,e.applyColormapObservable=function(e,t){return i.combineLatest(e,t).pipe(r.map(function(e){return Ve(e[0],e[1])}))},e.applyFilters=function(e,t){return i.combineLatest(t,e).pipe(r.map(function(e){var t=e[0],n=e[1];return t.forEach(function(e){n=e.filter(n)}),n}))},e.applySlicer=function(e,t){return i.combineLatest(t,e).pipe(r.map(function(e){var t=e[0],n=e[1];return t.slice(n)}))},e.b64ToFloat32Array=Ee,e.drawArrow=At,e.dummyGrayImage=q,e.dummyGrayImage3=Y,e.dummyRGBImage=function(e,t){for(var n=t.x*t.y,i=new Uint8Array(n),r=new Uint8Array(n),a=new Uint8Array(n),s=0;s<t.x;s++)for(var c=0;c<t.y;c++){var u=Math.sin(s/t.x*Math.PI*2+Math.PI/4),l=(Math.cos(c/t.y*Math.PI*2)*u+1)/2;i[s*t.y+c]=255*l,r[s*t.y+c]=255*l,a[s*t.y+c]=255*l}return new I(new o.Vector2(0,0),e,t,i,r,a)},e.eqId=Te,e.fetchCommonValue=qt,e.imageMinMax=function(e,t,n){for(var i=e.meta.shape.x*e.meta.shape.y,o=0;o<i;o++)e.data[o]=Math.max(Math.min(e.data[o],n),t);return e},e.imageShapeOfDirection=ze,e.intersectBoundingBox2=U,e.moveBoundingBox2By=function(e,t){return new W(new o.Vector2(e.center.x+t.x,e.center.y+t.y),e.size)},e.moveBoundingBox2To=function(e,t){return new W(t,e.size)},e.provideParent=ht,e.resizePlane2ModelByCorner=function(e,t){var n=bn(e.direction.x,e.to.x,t.box),i=bn(e.direction.y,e.to.y,n);return new P(i,10,t.textureData)},e.resizePlane2ModelByEdge=function(e,t){return new P(bn(e.direction,e.to,t.box),10,t.textureData)},e.sequenceDummyGrayImage2=J,e.store=Le,e.updateBoxByDirection=bn,e.ɵa=Ht,e.ɵb=ut,e.ɵba=Ke,e.ɵbb=Je,e.ɵbc=Se,e.ɵbd=Ye,e.ɵbe=qe,e.ɵbf=Ne,e.ɵbg=Ae,e.ɵbh=Be,e.ɵbi=We,e.ɵbj=Re,e.ɵbl=Ie,e.ɵbm=Rt,e.ɵbn=$t,e.ɵbo=Ce,e.ɵbp=we,e.ɵbq=Mt,e.ɵbr=rn,e.ɵbs=Kt,e.ɵbt=Jt,e.ɵbu=Yt,e.ɵbv=tn,e.ɵbw=Xt,e.ɵbx=on,e.ɵby=nn,e.ɵbz=K,e.ɵc=Z,e.ɵca=yn,e.ɵcb=fn,e.ɵcc=dn,e.ɵcd=an,e.ɵce=mn,e.ɵcf=vn,e.ɵcg=w,e.ɵch=x,e.ɵci=b,e.ɵd=X,e.ɵe=te,e.ɵf=Ze,e.ɵg=ct,e.ɵh=st,e.ɵi=nt,e.ɵj=lt,e.ɵk=pt,e.ɵl=dt,e.ɵm=mt,e.ɵn=ft,e.ɵo=vt,e.ɵp=yt,e.ɵq=It,e.ɵr=Dt,e.ɵs=Vt,e.ɵt=jt,e.ɵu=Xe,e.ɵv=Lt,e.ɵw=Tt,e.ɵx=Bt,e.ɵy=Et,e.ɵz=kt,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=image-w.umd.min.js.map