(function(Y,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(Y=typeof globalThis<"u"?globalThis:Y||self,I(Y.trame_rca={}))})(this,function(Y){"use strict";class I{constructor(e){this.vueComponent=e,this.img=new Image,this.url="",this.blob=null,this.img.addEventListener("load",()=>{this.vueComponent.displayURL=this.url,this.vueComponent.hasContent=!0})}update(e,r){window.URL.revokeObjectURL(this.url),this.blob=new Blob([r],{type:e}),this.url=URL.createObjectURL(this.blob),this.img.src=this.url}}const _e={props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"},poolSize:{type:Number,default:4},imageStyle:{type:Object,default:()=>({width:"100%"})}},watch:{poolSize(){this.updatePoolSize()}},data(){return{hasContent:!1,displayURL:""}},expose:["resetContent","updatePoolSize"],methods:{resetContent(){this.hasContent=!1},updatePoolSize(){for(;this.frames.length<this.poolSize;)this.frames.push(new I(this));for(;this.frames.length>this.poolSize;)this.frames.pop()},cleanup(){this.wslinkSubscription&&this.trame&&(this.trame.client.getConnection().getSession().unsubscribe(this.wslinkSubscription),this.wslinkSubscription=null)}},created(){this.frames=[],this.nextFrameIndex=0,this.updatePoolSize(),this.wslinkSubscription=null,this.onImage=([{name:t,meta:e,content:r}])=>{const n=["image/apng","image/avif","image/gif","image/jpeg","image/png","image/svg+xml","image/webp"];this.name===t&&(n.includes(e.type)?(this.nextFrameIndex=(this.nextFrameIndex+1)%this.frames.length,this.frames[this.nextFrameIndex].update(e.type,r)):this.hasContent=!1)},this.trame&&(this.wslinkSubscription=this.trame.client.getConnection().getSession().subscribe("trame.rca.topic.stream",this.onImage))},beforeDestroy(){this.cleanup()},beforeUnmount(){this.cleanup()},inject:["trame"],template:'<img :style="imageStyle" :src="displayURL" v-show="hasContent" draggable="false" />'};class Ft{constructor(e,r="video/webm; codecs=vp09.00.10.08"){this.videoElement=e,this.mime=r,this.sourceBuffer=null,this.mediaSource=null,this.initSegment=null,this.mediaSegments=[],this.loaded=0,"MediaSource"in window?(this.mediaSource=new MediaSource,this.videoElement.src=URL.createObjectURL(this.mediaSource),this.mediaSource.addEventListener("sourceopen",()=>{MediaSource.isTypeSupported(this.mime)?this.initSourceBuffer():console.error(`Unsupported MIME type or codec: ${this.mime}`)})):console.error("The Media Source Extensions API is not supported.")}initSourceBuffer(){this.sourceBuffer=this.mediaSource.addSourceBuffer(this.mime),this.sourceBuffer.mode="sequence",this.initSegment?this.sourceBuffer.appendBuffer(this.initSegment):console.error("Need initialization segment"),this.sourceBuffer.onupdateend=()=>{if(this.mediaSegments.length)this.sourceBuffer.updating===!1&&(this.sourceBuffer.appendBuffer(this.mediaSegments.shift()),this.loaded+=1);else return}}queueChunk(e){this.mediaSource.readyState==="open"&&this.sourceBuffer&&this.sourceBuffer.updating===!1?(this.sourceBuffer.appendBuffer(e),this.loaded+=1):this.mediaSegments.push(e)}exit(){this.sourceBuffer.abort(),this.mediaSource.endOfStream(),this.videoElement.play(),URL.revokeObjectURL(this.videoElement.src)}}const ze={props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"}},data(){return{hasContent:!1,loaded:0,received:0}},expose:["requestInitializationSegment"],methods:{requestInitializationSegment(){this.rcaPushSize&&this.rcaPushSize({videoHeader:1})},cleanup(){this.wslinkSubscription&&this.trame&&(this.trame.client.getConnection().getSession().unsubscribe(this.wslinkSubscription),this.wslinkSubscription=null,this.decoder.exit())}},created(){this.pushChunk=(t,e)=>{Array.from(new Uint8Array(t).slice(0,4)).map(n=>n.toString(16)).join("")=="1a45dfa3"&&e.includes("webm")?(console.log("detected ebml fourcc"),this.decoder&&this.decoder.exit(),this.decoder=new Ft(this.$el),this.decoder.initSegment=new Uint8Array(t)):this.decoder.mime!==e?(console.log("detected mime change"),this.requestInitializationSegment()):(this.decoder.queueChunk(t),this.loaded=this.decoder.loaded,this.hasContent=!0)}},mounted(){this.onChunkAvailable=async([{name:t,meta:e,content:r}])=>{if(!e.type.includes("video/")){this.hasContent=!1;return}if(this.name===t){this.received+=1;const n=r.buffer?r:new Uint8Array(await r.arrayBuffer());this.pushChunk(n,e.type),this.hasContent=!0}},this.trame&&(this.wslinkSubscription=this.trame.client.getConnection().getSession().subscribe("trame.rca.topic.stream",this.onChunkAvailable),this.requestInitializationSegment())},beforeUnmount(){this.cleanup()},beforeDestroy(){this.cleanup()},inject:["trame","rcaPushSize"],template:`
    <video autoplay="autoplay" muted="muted" v-show="hasContent">
      Your browser does not support the video tag.
    </video>
  `},_t=1,zt=2,Wt=3,Gt=4,Nt=5,Kt=6,Vt=`

function reportError(e) {
  console.log(e.message);
  postMessage(e.message);
}

function createDecoder(canvas) {
  const ctx = canvas.getContext('2d');
  const ready_frames = [];
  let underflow = true;

  function renderFrame() {
    if (ready_frames.length === 0) {
      underflow = true;
      return;
    }
    const frame = ready_frames.shift();
    underflow = false;
    ctx.drawImage(frame, 0, 0);
    frame.close();
    setTimeout(renderFrame, 0);
  }

  function handleFrame(frame) {
    ready_frames.push(frame);
    if (underflow) {
      underflow = false;
      setTimeout(renderFrame, 0);
    }
  }

  const init = {
    output: handleFrame,
    error: reportError,
  };

  return new VideoDecoder(init);
}

onmessage = async function({ data: msg }) {
  switch(msg.action) {
    case 1: // init
      this.canvas = msg.canvas;
      this.decoder = createDecoder(this.canvas);
      break;
    case 2: // config
      this.canvas.width = msg.config.codedWidth;
      this.canvas.height = msg.config.codedHeight;
      this.decoder.configure(msg.config);
      break;
    case 3: // chunk
      this.decoder.decode(new EncodedVideoChunk({
        timestamp: msg.timestamp,
        type: msg.type,
        data: msg.data,
      }));
      break;
    case 4: // flush
      this.decoder.flush();
      break;
    case 5: // reset
      this.decoder.reset();
      break;
    case 6: // close
      // flush before close() to avoid currepoted state.
      // calling postMessage(flush)
      //         postMessage(close) is not enough since the second
      // abort the first before it finishes.
      await this.decoder.flush();
      this.decoder.close();
      break;
  }
}
`,qt=URL.createObjectURL(new Blob([Vt]));function Xt(){const t=new Worker(qt);return t.addEventListener("error",()=>console.error("worker failed"),!1),t.onmessage=e=>{console.log(`Worker message: ${e.data}`),console.log(">>> FIXME .....")},t}class Yt{constructor(){this.worker=Xt(),this.codec="",this.width=0,this.height=0}bindCanvas(e){const r=_t,n=e.transferControlToOffscreen();this.worker.postMessage({action:r,canvas:n},[n])}setContentType(e,r,n){if(this.codec!==e||this.width!==r||this.height!==n){const i=zt;this.codec=e,this.width=r,this.height=n,this.worker.postMessage({action:i,config:{codec:e,codedWidth:r,codedHeight:n}})}}pushChunk(e,r,n){const i=Wt;this.worker.postMessage({action:i,timestamp:e,type:r,data:n},[n.buffer])}flush(){this.worker.postMessage({action:Gt})}reset(){this.worker.postMessage({action:Nt})}terminate(){this.worker.postMessage({action:Kt})}}const We={props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"}},data(){return{isSupported:"VideoFrame"in window}},expose:[""],methods:{cleanup(){this.worker&&this.worker.terminate(),this.wslinkSubscription&&this.trame&&(this.trame.client.getConnection().getSession().unsubscribe(this.wslinkSubscription),this.wslinkSubscription=null)}},mounted(){if(this.worker=new Yt,this.isSupported){const t=this.$el.querySelector(".js-canvas");this.worker.bindCanvas(t),this.onChunkAvailable=async([{name:e,meta:r,content:n}])=>{if(!(!r.type.includes("application/octet-stream")||!r.codec.length||r.codec.includes("unknown"))&&this.name===e&&r.codec.length){this.worker.setContentType(r.codec,r.w,r.h);const i=n.buffer?n:new Uint8Array(await n.arrayBuffer());this.worker.pushChunk(r.st,r.key,i)}},this.trame&&(this.wslinkSubscription=this.trame.client.getConnection().getSession().subscribe("trame.rca.topic.stream",this.onChunkAvailable))}},beforeUnmount(){this.cleanup()},beforeDestroy(){this.cleanup()},inject:["trame","rcaPushSize"],template:`
    <div>
      <h1 v-if="!isSupported">WebCodecs API is not supported.</h1>
      <canvas class="js-canvas"></canvas>
    </div>
  `},Ge={props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"},imageStyle:{type:Object,default:()=>({width:"100%"})}},data(){return{hasContent:!1}},methods:{cleanup(){this.wslinkSubscription&&this.trame&&(this.trame.client.getConnection().getSession().unsubscribe(this.wslinkSubscription),this.wslinkSubscription=null)}},mounted(){this.wslinkSubscription=null;const t=this.$el,e=t.getContext("2d");this.onImage=async([{name:r,meta:n,content:i}])=>{if(this.name===r)if(n.type.includes("image/rgb24")){const u=i.buffer?i:new Uint8Array(await i.arrayBuffer());t.width=n.w,t.height=n.h;const y=e.createImageData(n.w,n.h),c=y.data;let o=0,s=0;for(;s<c.length;)c[s++]=u[o++],c[s++]=u[o++],c[s++]=u[o++],c[s++]=255;e.putImageData(y,0,0),this.hasContent=!0}else if(n.type.includes("image/rgba32")){const u=new Uint8ClampedArray(i.buffer?i:await i.arrayBuffer());t.width=n.w,t.height=n.h;const y=new ImageData(u,n.w,n.h);e.putImageData(y,0,0),this.hasContent=!0}else this.hasContent=!1},this.trame&&(this.wslinkSubscription=this.trame.client.getConnection().getSession().subscribe("trame.rca.topic.stream",this.onImage))},beforeDestroy(){this.cleanup()},beforeUnmount(){this.cleanup()},inject:["trame"],template:'<canvas class="js-canvas" :style="imageStyle" v-show="hasContent"></canvas>'},Ht={components:{ImageDisplayArea:_e,MediaSourceDisplayArea:ze,VideoDecoderDisplayArea:We,RawImageDisplayArea:Ge},props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"},display:{type:String,default:"image"},imageStyle:{type:Object,default:()=>({width:"100%"})}},template:`
    <div style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;">
      <image-display-area v-if="display === 'image'" :name="name" :origin="origin" :poolSize="4" :imageStyle="imageStyle" />
      <media-source-display-area v-if="display === 'media-source'" :name="name" :origin="origin" />
      <video-decoder-display-area v-if="display === 'video-decoder'" :name="name" :origin="origin" />
      <raw-image-display-area v-if="display === 'raw-image'" :name="name" :origin="origin" :imageStyle="imageStyle" />
    </div>
  `},Jt=["B/s","KB/s","MB/s"];class Qt{constructor(e=255,r=10,n=1e3){this.windowSize=e,this.windowStatSize=r,this.newInteractionThreshold=n,this.lastTS=0,this.serverTime=[],this.clientTimes=[],this.packetSizes=[],this.statWindow=[]}trim(){for(;this.serverTime.length>this.windowSize;)this.serverTime.shift(),this.clientTimes.shift(),this.packetSizes.shift();for(;this.statWindow.length>this.windowStatSize;)this.statWindow.shift()}compute(){if(this.statWindow.length<2)return null;const e=this.statWindow[0],n=(this.statWindow[this.statWindow.length-1]-e)/(this.statWindow.length-1),i=1e3/n,u=[],y=[],c=[0,0];let o=this.clientTimes[0],s=this.serverTime[0],l=0;for(let f=0;f<this.clientTimes.length;f++){const h=this.clientTimes[f]-o,p=this.serverTime[f]-s;l+=this.packetSizes[f],u.push(h),y.push(p),o+=n,s+=n;const d=h<p?h:p,a=h>p?h:p;c[0]>d&&(c[0]=d),c[1]<a&&(c[1]=a)}return l*=i/this.packetSizes.length,{avgFps:i,client:u,server:y,minMax:c,totalSize:l}}addEntry(e,r){const n=Date.now();return this.packetSizes.push(r),this.serverTime.push(e),this.clientTimes.push(n),n-this.lastTS<this.newInteractionThreshold?this.statWindow.push(n):this.statWindow.length=0,this.lastTS=n,this.trim(),this.compute()}}const Zt={props:{name:{type:String,default:"default"},fpsDelta:{type:Number,default:4},statWindowSize:{type:Number,default:10},historyWindowSize:{type:Number,default:255},resetMsThreshold:{type:Number,default:255},wsLinkTopic:{type:String,default:"trame.rca.topic.stream"},packetDecorator:{type:Function,default:({name:t,meta:e,content:r})=>({name:t,serverTime:e.st,contentSize:r.length})}},data(){return{cw:200,ch:200,avg:30,delta:2,totalSize:0}},watch:{statWindowSize(t){this.monitor.windowStatSize=t},historyWindowSize(t){this.monitor.windowSize=t},resetMsThreshold(t){this.monitor.newInteractionThreshold=t}},expose:["sizeUnit"],methods:{sizeUnit(t){let e=t;for(let r=0;r<3;r++){if(e<1e3)return`${e.toFixed(1)} ${Jt[r]}`;e/=1e3}},cleanup(){this.observer.unobserve(this.$el),this.wslinkSubscription&&this.trame&&(this.trame.client.getConnection().getSession().unsubscribe(this.wslinkSubscription),this.wslinkSubscription=null)},draw(t,e,r="#1DE9B688",n="#EF9A9A"){if(!this.$el)return;const{cw:i,ch:u}=this,c=this.$el.querySelector(".js-canvas").getContext("2d"),o=Math.floor(u*.5+.5),s=o/(1001*this.fpsDelta),l=i/(t.length-2);c.clearRect(0,0,i,u),c.strokeStyle="black",c.beginPath(),c.moveTo(0,o),c.lineTo(i,o),c.stroke(),c.strokeStyle="#eee";for(let f=0;f<this.fpsDelta;f++)c.beginPath(),c.moveTo(0,o+1e3*(f+1)*s),c.lineTo(i,o+1e3*(f+1)*s),c.stroke(),c.beginPath(),c.moveTo(0,o-1e3*(f+1)*s),c.lineTo(i,o-1e3*(f+1)*s),c.stroke();c.strokeStyle=r,c.lineWidth=8,c.beginPath(),c.moveTo(0,o-s*t[1]);for(let f=2;f<t.length;f++)c.lineTo((f-1)*l,o-s*t[f]);c.stroke(),c.strokeStyle=n,c.lineWidth=2,c.beginPath(),c.moveTo(0,o-s*e[1]);for(let f=2;f<e.length;f++)c.lineTo((f-1)*l,o-s*e[f]);c.stroke()}},created(){this.monitor=new Qt(this.historyWindowSize,this.statWindowSize),this.wslinkSubscription=null,this.onStreamPacket=([t])=>{const{name:e,serverTime:r,contentSize:n}=this.packetDecorator(t);if(this.name===e){const i=this.monitor.addEntry(r,n);i&&(this.avg=i.avgFps,this.totalSize=i.totalSize,this.delta=1e3/(i.minMax[1]-i.minMax[0]),this.draw(i.client,i.server))}},this.trame&&(this.wslinkSubscription=this.trame.client.getConnection().getSession().subscribe(this.wsLinkTopic,this.onStreamPacket)),this.observer=new ResizeObserver(()=>{if(!this.$el)return;const{width:t,height:e}=this.$el.getBoundingClientRect();this.cw=t,this.ch=e})},mounted(){this.observer.observe(this.$el)},beforeDestroy(){this.cleanup()},beforeUnmount(){this.cleanup()},inject:["trame"],template:`
    <v-col style="width: 100%; height: 100%; position: relative;">
      <v-row class="text-subtitle-2" style="position: absolute; top: 0; left: 0; width: 100%; z-index: 1;">
        <v-icon>mdi-gauge</v-icon>
        <v-spacer />
        <div>
          {{ avg.toFixed(1) }} fps
        </div>
        <v-spacer />
        <v-icon>mdi-database-import</v-icon>
        <v-spacer />
        <div>
          {{ sizeUnit(totalSize) }}
        </div>
      </v-row>
      <canvas style="position: absolute; left: 0; top: 0;" class="js-canvas" :width="cw" :height="ch">
      </canvas>
    </v-col>
  `};var _=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ne(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function At(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Pt=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,u;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(u=Object.keys(e),n=u.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,u[i]))return!1;for(i=n;i--!==0;){var y=u[i];if(!t(e[y],r[y]))return!1}return!0}return e!==e&&r!==r};const It=Ne(Pt);var Ke=Object.prototype.toString,Ve=function(e){var r=Ke.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Ke.call(e.callee)==="[object Function]"),n},de,qe;function en(){if(qe)return de;qe=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Ve,i=Object.prototype.propertyIsEnumerable,u=!i.call({toString:null},"toString"),y=i.call(function(){},"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=function(h){var p=h.constructor;return p&&p.prototype===h},s={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if(typeof window>"u")return!1;for(var h in window)try{if(!s["$"+h]&&e.call(window,h)&&window[h]!==null&&typeof window[h]=="object")try{o(window[h])}catch{return!0}}catch{return!0}return!1}(),f=function(h){if(typeof window>"u"||!l)return o(h);try{return o(h)}catch{return!1}};t=function(p){var d=p!==null&&typeof p=="object",a=r.call(p)==="[object Function]",g=n(p),v=d&&r.call(p)==="[object String]",S=[];if(!d&&!a&&!g)throw new TypeError("Object.keys called on a non-object");var T=y&&a;if(v&&p.length>0&&!e.call(p,0))for(var w=0;w<p.length;++w)S.push(String(w));if(g&&p.length>0)for(var m=0;m<p.length;++m)S.push(String(m));else for(var k in p)!(T&&k==="prototype")&&e.call(p,k)&&S.push(String(k));if(u)for(var E=f(p),x=0;x<c.length;++x)!(E&&c[x]==="constructor")&&e.call(p,c[x])&&S.push(c[x]);return S}}return de=t,de}var tn=Array.prototype.slice,nn=Ve,Xe=Object.keys,ie=Xe?function(e){return Xe(e)}:en(),Ye=Object.keys;ie.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return nn(n)?Ye(tn.call(n)):Ye(n)})}else Object.keys=ie;return Object.keys||ie};var rn=ie,on=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var y=Object.getOwnPropertyDescriptor(e,r);if(y.value!==i||y.enumerable!==!0)return!1}return!0},He=typeof Symbol<"u"&&Symbol,an=on,sn=function(){return typeof He!="function"||typeof Symbol!="function"||typeof He("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:an()},Je={foo:{}},un=Object,cn=function(){return{__proto__:Je}.foo===Je.foo&&!({__proto__:null}instanceof un)},fn="Function.prototype.bind called on incompatible ",ve=Array.prototype.slice,ln=Object.prototype.toString,hn="[object Function]",pn=function(e){var r=this;if(typeof r!="function"||ln.call(r)!==hn)throw new TypeError(fn+r);for(var n=ve.call(arguments,1),i,u=function(){if(this instanceof i){var l=r.apply(this,n.concat(ve.call(arguments)));return Object(l)===l?l:this}else return r.apply(e,n.concat(ve.call(arguments)))},y=Math.max(0,r.length-n.length),c=[],o=0;o<y;o++)c.push("$"+o);if(i=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var s=function(){};s.prototype=r.prototype,i.prototype=new s,s.prototype=null}return i},yn=pn,Qe=Function.prototype.bind||yn,gn=Qe,dn=gn.call(Function.call,Object.prototype.hasOwnProperty),R,H=SyntaxError,Ze=Function,J=TypeError,me=function(t){try{return Ze('"use strict"; return ('+t+").constructor;")()}catch{}},N=Object.getOwnPropertyDescriptor;if(N)try{N({},"")}catch{N=null}var we=function(){throw new J},vn=N?function(){try{return arguments.callee,we}catch{try{return N(arguments,"callee").get}catch{return we}}}():we,Q=sn(),mn=cn(),b=Object.getPrototypeOf||(mn?function(t){return t.__proto__}:null),Z={},wn=typeof Uint8Array>"u"||!b?R:b(Uint8Array),K={"%AggregateError%":typeof AggregateError>"u"?R:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?R:ArrayBuffer,"%ArrayIteratorPrototype%":Q&&b?b([][Symbol.iterator]()):R,"%AsyncFromSyncIteratorPrototype%":R,"%AsyncFunction%":Z,"%AsyncGenerator%":Z,"%AsyncGeneratorFunction%":Z,"%AsyncIteratorPrototype%":Z,"%Atomics%":typeof Atomics>"u"?R:Atomics,"%BigInt%":typeof BigInt>"u"?R:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?R:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?R:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?R:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?R:Float32Array,"%Float64Array%":typeof Float64Array>"u"?R:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?R:FinalizationRegistry,"%Function%":Ze,"%GeneratorFunction%":Z,"%Int8Array%":typeof Int8Array>"u"?R:Int8Array,"%Int16Array%":typeof Int16Array>"u"?R:Int16Array,"%Int32Array%":typeof Int32Array>"u"?R:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Q&&b?b(b([][Symbol.iterator]())):R,"%JSON%":typeof JSON=="object"?JSON:R,"%Map%":typeof Map>"u"?R:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Q||!b?R:b(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?R:Promise,"%Proxy%":typeof Proxy>"u"?R:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?R:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?R:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Q||!b?R:b(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?R:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Q&&b?b(""[Symbol.iterator]()):R,"%Symbol%":Q?Symbol:R,"%SyntaxError%":H,"%ThrowTypeError%":vn,"%TypedArray%":wn,"%TypeError%":J,"%Uint8Array%":typeof Uint8Array>"u"?R:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?R:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?R:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?R:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?R:WeakMap,"%WeakRef%":typeof WeakRef>"u"?R:WeakRef,"%WeakSet%":typeof WeakSet>"u"?R:WeakSet};if(b)try{null.error}catch(t){var Sn=b(b(t));K["%Error.prototype%"]=Sn}var En=function t(e){var r;if(e==="%AsyncFunction%")r=me("async function () {}");else if(e==="%GeneratorFunction%")r=me("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=me("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&b&&(r=b(i.prototype))}return K[e]=r,r},Ae={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ee=Qe,ae=dn,xn=ee.call(Function.call,Array.prototype.concat),kn=ee.call(Function.apply,Array.prototype.splice),Pe=ee.call(Function.call,String.prototype.replace),se=ee.call(Function.call,String.prototype.slice),Tn=ee.call(Function.call,RegExp.prototype.exec),Rn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,On=/\\(\\)?/g,Mn=function(e){var r=se(e,0,1),n=se(e,-1);if(r==="%"&&n!=="%")throw new H("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new H("invalid intrinsic syntax, expected opening `%`");var i=[];return Pe(e,Rn,function(u,y,c,o){i[i.length]=c?Pe(o,On,"$1"):y||u}),i},Dn=function(e,r){var n=e,i;if(ae(Ae,n)&&(i=Ae[n],n="%"+i[0]+"%"),ae(K,n)){var u=K[n];if(u===Z&&(u=En(n)),typeof u>"u"&&!r)throw new J("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:u}}throw new H("intrinsic "+e+" does not exist!")},Cn=function(e,r){if(typeof e!="string"||e.length===0)throw new J("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new J('"allowMissing" argument must be a boolean');if(Tn(/^%?[^%]*%?$/,e)===null)throw new H("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Mn(e),i=n.length>0?n[0]:"",u=Dn("%"+i+"%",r),y=u.name,c=u.value,o=!1,s=u.alias;s&&(i=s[0],kn(n,xn([0,1],s)));for(var l=1,f=!0;l<n.length;l+=1){var h=n[l],p=se(h,0,1),d=se(h,-1);if((p==='"'||p==="'"||p==="`"||d==='"'||d==="'"||d==="`")&&p!==d)throw new H("property names with quotes must have matching quotes");if((h==="constructor"||!f)&&(o=!0),i+="."+h,y="%"+i+"%",ae(K,y))c=K[y];else if(c!=null){if(!(h in c)){if(!r)throw new J("base intrinsic for "+e+" exists, but the property is not available.");return}if(N&&l+1>=n.length){var a=N(c,h);f=!!a,f&&"get"in a&&!("originalValue"in a.get)?c=a.get:c=c[h]}else f=ae(c,h),c=c[h];f&&!o&&(K[y]=c)}}return c},bn=Cn,Se=bn("%Object.defineProperty%",!0),Ee=function(){if(Se)try{return Se({},"a",{value:1}),!0}catch{return!1}return!1};Ee.hasArrayLengthDefineBug=function(){if(!Ee())return null;try{return Se([],"length",{value:1}).length!==1}catch{return!0}};var $n=Ee,jn=rn,Ln=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Un=Object.prototype.toString,Bn=Array.prototype.concat,Ie=Object.defineProperty,Fn=function(t){return typeof t=="function"&&Un.call(t)==="[object Function]"},_n=$n(),et=Ie&&_n,zn=function(t,e,r,n){if(e in t){if(n===!0){if(t[e]===r)return}else if(!Fn(n)||!n())return}et?Ie(t,e,{configurable:!0,enumerable:!1,value:r,writable:!0}):t[e]=r},tt=function(t,e){var r=arguments.length>2?arguments[2]:{},n=jn(e);Ln&&(n=Bn.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)zn(t,n[i],e[n[i]],r[n[i]])};tt.supportsDescriptors=!!et;var nt=tt,ue={exports:{}};typeof self<"u"?ue.exports=self:typeof window<"u"?ue.exports=window:ue.exports=Function("return this")();var rt=ue.exports,Wn=rt,ot=function(){return typeof _!="object"||!_||_.Math!==Math||_.Array!==Array?Wn:_},Gn=nt,Nn=ot,Kn=function(){var e=Nn();if(Gn.supportsDescriptors){var r=Object.getOwnPropertyDescriptor(e,"globalThis");(!r||r.configurable&&(r.enumerable||!r.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},Vn=nt,qn=rt,it=ot,Xn=Kn,Yn=it(),at=function(){return Yn};Vn(at,{getPolyfill:it,implementation:qn,shim:Xn});var Hn=at;const z=Ne(Hn)(),st={vtkObject:()=>null};function V(t){if(t==null||t.isA)return t;if(!t.vtkClass)return z.console&&z.console.error&&z.console.error("Invalid VTK object"),null;const e=st[t.vtkClass];if(!e)return z.console&&z.console.error&&z.console.error(`No vtk class found for Object of type ${t.vtkClass}`),null;const r={...t};Object.keys(r).forEach(i=>{r[i]&&typeof r[i]=="object"&&r[i].vtkClass&&(r[i]=V(r[i]))});const n=e(r);return n&&n.modified&&n.modified(),n}function Jn(t,e){st[t]=e}V.register=Jn;class xe extends Array{push(){for(let e=0;e<arguments.length;e++)this.includes(arguments[e])||super.push(arguments[e]);return this.length}}let ke=0;const Qn=t=>{throw new Error(`Named parameter '${t}' is missing`)},Zn=Symbol("void");function An(){return ke}const ut={};function q(){}["log","debug","info","warn","error","time","timeEnd","group","groupEnd"].forEach(t=>{ut[t]=q}),z.console=console.hasOwnProperty("log")?console:ut;const G={debug:q,error:z.console.error||q,info:z.console.info||q,log:z.console.log||q,warn:z.console.warn||q};function Pn(t,e){G[t]&&(G[t]=e||q)}function In(){G.log(...arguments)}function er(){G.info(...arguments)}function Te(){G.debug(...arguments)}function $(){G.error(...arguments)}function Re(){G.warn(...arguments)}const ct={};function tr(t){ct[t]||(G.error(t),ct[t]=!0)}const L=Object.create(null);L.Float32Array=Float32Array,L.Float64Array=Float64Array,L.Uint8Array=Uint8Array,L.Int8Array=Int8Array,L.Uint16Array=Uint16Array,L.Int16Array=Int16Array,L.Uint32Array=Uint32Array,L.Int32Array=Int32Array,L.Uint8ClampedArray=Uint8ClampedArray;try{L.BigInt64Array=BigInt64Array,L.BigUint64Array=BigUint64Array}catch{}function nr(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new(L[t]||Float64Array)(...r)}function rr(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return(L[t]||Float64Array).from(...r)}function Oe(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){return Oe(t[0]==="_"?t.slice(1):t)}function or(t){return t.charAt(0).toLowerCase()+t.slice(1)}function ir(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e3;const n=["TB","GB","MB","KB"];let i=Number(t),u="B";for(;i>r;)i/=r,u=n.pop();return`${i.toFixed(e)} ${u}`}function ar(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ";const r=[];let n=t;for(;n>1e3;)r.push(`000${n%1e3}`.slice(-3)),n=Math.floor(n/1e3);return n>0&&r.push(n),r.reverse(),r.join(e)}function ft(t){Object.keys(t).forEach(e=>{Array.isArray(t[e])&&(t[e]=[].concat(t[e]))})}function sr(t){return Object.values(L).some(e=>t instanceof e)}function ur(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}return!1}function cr(t,e){return Object.keys(t).find(r=>t[r]===e)}function lt(t){return t&&t.isA?t.getState():t}function ht(t){setTimeout(t,0)}function fr(t,e){const r=performance.now();t.finally(()=>{const n=performance.now()-r;e(n)})}function lr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ft(e);const r=[];if(Number.isInteger(e.mtime)||(e.mtime=++ke),!("classHierarchy"in e))e.classHierarchy=new xe("vtkObject");else if(!(e.classHierarchy instanceof xe)){const u=new xe;for(let y=0;y<e.classHierarchy.length;y++)u.push(e.classHierarchy[y]);e.classHierarchy=u}function n(u){r[u]=null}function i(u){function y(){n(u)}return Object.freeze({unsubscribe:y})}return t.isDeleted=()=>!!e.deleted,t.modified=u=>{if(e.deleted){$("instance deleted - cannot call any method");return}u&&u<t.getMTime()||(e.mtime=++ke,r.forEach(y=>y&&y(t)))},t.onModified=u=>{if(e.deleted)return $("instance deleted - cannot call any method"),null;const y=r.length;return r.push(u),i(y)},t.getMTime=()=>e.mtime,t.isA=u=>{let y=e.classHierarchy.length;for(;y--;)if(e.classHierarchy[y]===u)return!0;return!1},t.getClassName=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.classHierarchy[e.classHierarchy.length-1-u]},t.set=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,o=!1;return Object.keys(u).forEach(s=>{const l=c?null:t[`set${Oe(s)}`];l&&Array.isArray(u[s])&&l.length>1?o=l(...u[s])||o:l?o=l(u[s])||o:(["mtime"].indexOf(s)===-1&&!y&&Re(`Warning: Set value to model directly ${s}, ${u[s]}`),o=e[s]!==u[s]||o,e[s]=u[s])}),o},t.get=function(){for(var u=arguments.length,y=new Array(u),c=0;c<u;c++)y[c]=arguments[c];if(!y.length)return e;const o={};return y.forEach(s=>{o[s]=e[s]}),o},t.getReferenceByName=u=>e[u],t.delete=()=>{Object.keys(e).forEach(u=>delete e[u]),r.forEach((u,y)=>n(y)),e.deleted=!0},t.getState=()=>{if(e.deleted)return null;const u={...e,vtkClass:t.getClassName()};Object.keys(u).forEach(c=>{u[c]===null||u[c]===void 0||c[0]==="_"?delete u[c]:u[c].isA?u[c]=u[c].getState():Array.isArray(u[c])?u[c]=u[c].map(lt):sr(u[c])&&(u[c]=Array.from(u[c]))});const y={};return Object.keys(u).sort().forEach(c=>{y[c]=u[c]}),y.mtime&&delete y.mtime,y},t.shallowCopy=function(u){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(u.getClassName()!==t.getClassName())throw new Error(`Cannot ShallowCopy ${u.getClassName()} into ${t.getClassName()}`);const c=u.get(),o=Object.keys(e).sort();Object.keys(c).sort().forEach(l=>{const f=o.indexOf(l);f===-1?y&&Te(`add ${l} in shallowCopy`):o.splice(f,1),e[l]=c[l]}),o.length&&y&&Te(`Untouched keys: ${o.join(", ")}`),t.modified()},t.toJSON=function(){return t.getState()},t}const hr={object(t,e,r){return function(){return{...e[r.name]}}}};function ce(t,e,r){r.forEach(n=>{if(typeof n=="object"){const i=hr[n.type];i?t[`get${C(n.name)}`]=i(t,e,n):t[`get${C(n.name)}`]=()=>e[n.name]}else t[`get${C(n)}`]=()=>e[n]})}const pt={enum(t,e,r){const n=`_on${C(r.name)}Changed`;return i=>{var u;if(typeof i=="string"){if(r.enum[i]!==void 0)return e[r.name]!==r.enum[i]?(e[r.name]=r.enum[i],t.modified(),!0):!1;throw $(`Set Enum with invalid argument ${r}, ${i}`),new RangeError("Set Enum with invalid string argument")}if(typeof i=="number"){if(e[r.name]!==i){if(Object.keys(r.enum).map(y=>r.enum[y]).indexOf(i)!==-1){const y=e[r.name];return e[r.name]=i,(u=e[n])==null||u.call(e,t,e,i,y),t.modified(),!0}throw $(`Set Enum outside numeric range ${r}, ${i}`),new RangeError("Set Enum outside numeric range")}return!1}throw $(`Set Enum with invalid argument (String/Number) ${r}, ${i}`),new TypeError("Set Enum with invalid argument (String/Number)")}},object(t,e,r){var i;((i=r.params)==null?void 0:i.length)===1&&Re('Setter of type "object" with a single "param" field is not supported');const n=`_on${C(r.name)}Changed`;return function(){var s,l;for(var u=arguments.length,y=new Array(u),c=0;c<u;c++)y[c]=arguments[c];let o;if(y.length>1&&((s=r.params)!=null&&s.length)?o=r.params.reduce((f,h,p)=>Object.assign(f,{[h]:y[p]}),{}):o=y[0],!It(e[r.name],o)){const f=e[r.name];return e[r.name]=o,(l=e[n])==null||l.call(e,t,e,o,f),t.modified(),!0}return!1}}};function yt(t){if(typeof t=="object"){const e=pt[t.type];if(e)return(r,n)=>e(r,n,t);throw $(`No setter for field ${t}`),new TypeError("No setter for field")}return function(r,n){const i=`_on${C(t)}Changed`;return function(y){var c;if(n.deleted)return $("instance deleted - cannot call any method"),!1;if(n[t]!==y){const o=n[t.name];return n[t]=y,(c=n[i])==null||c.call(n,r,n,y,o),r.modified(),!0}return!1}}}function gt(t,e,r){r.forEach(n=>{typeof n=="object"?t[`set${C(n.name)}`]=yt(n)(t,e):t[`set${C(n)}`]=yt(n)(t,e)})}function dt(t,e,r){ce(t,e,r),gt(t,e,r)}function vt(t,e,r){r.forEach(n=>{t[`get${C(n)}`]=()=>e[n]?Array.from(e[n]):e[n],t[`get${C(n)}ByReference`]=()=>e[n]})}function mt(t,e,r,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:void 0;r.forEach(u=>{if(e[u]&&n&&e[u].length!==n)throw new RangeError(`Invalid initial number of values for array (${u})`);const y=`_on${C(u)}Changed`;t[`set${C(u)}`]=function(){var p;if(e.deleted)return $("instance deleted - cannot call any method"),!1;for(var c=arguments.length,o=new Array(c),s=0;s<c;s++)o[s]=arguments[s];let l=o,f,h=!1;if(l.length===1&&(l[0]==null||l[0].length>=0)&&(l=l[0],h=!0),l==null)f=e[u]!==l;else{if(n&&l.length!==n)if(l.length<n&&i!==void 0)for(l=Array.from(l),h=!1;l.length<n;)l.push(i);else throw new RangeError(`Invalid number of values for array setter (${u})`);f=e[u]==null||e[u].length!==l.length;for(let d=0;!f&&d<l.length;++d)f=e[u][d]!==l[d];f&&h&&(l=Array.from(l))}if(f){const d=e[u.name];e[u]=l,(p=e[y])==null||p.call(e,t,e,l,d),t.modified()}return f},t[`set${C(u)}From`]=c=>{const o=e[u];c.forEach((s,l)=>{o[l]=s})}})}function pr(t,e,r,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:void 0;vt(t,e,r),mt(t,e,r,n,i)}function yr(t,e,r){for(let n=0;n<r.length;n++){const i=r[n];e[i]!==void 0&&(e[`_${i}`]=e[i],delete e[i])}}function gr(t,e,r,n){e.inputData?e.inputData=e.inputData.map(V):e.inputData=[],e.inputConnection?e.inputConnection=e.inputConnection.map(V):e.inputConnection=[],e.output?e.output=e.output.map(V):e.output=[],e.inputArrayToProcess?e.inputArrayToProcess=e.inputArrayToProcess.map(V):e.inputArrayToProcess=[],e.numberOfInputs=r;function i(p){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e.deleted){$("instance deleted - cannot call any method");return}if(d>=e.numberOfInputs){$(`algorithm ${t.getClassName()} only has ${e.numberOfInputs} input ports. To add more input ports, use addInputData()`);return}(e.inputData[d]!==p||e.inputConnection[d])&&(e.inputData[d]=p,e.inputConnection[d]=null,t.modified&&t.modified())}function u(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.inputConnection[p]&&(e.inputData[p]=e.inputConnection[p]()),e.inputData[p]}function y(p){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e.deleted){$("instance deleted - cannot call any method");return}if(d>=e.numberOfInputs){let a=`algorithm ${t.getClassName()} only has `;a+=`${e.numberOfInputs}`,a+=" input ports. To add more input ports, use addInputConnection()",$(a);return}e.inputData[d]=null,e.inputConnection[d]=p}function c(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.inputConnection[p]}function o(){let p=e.numberOfInputs;for(;p&&!e.inputData[p-1]&&!e.inputConnection[p-1];)p--;return p===e.numberOfInputs&&e.numberOfInputs++,p}function s(p){if(e.deleted){$("instance deleted - cannot call any method");return}y(p,o())}function l(p){if(e.deleted){$("instance deleted - cannot call any method");return}i(p,o())}function f(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.deleted?($("instance deleted - cannot call any method"),null):(t.shouldUpdate()&&t.update(),e.output[p])}t.shouldUpdate=()=>{var g,v;const p=t.getMTime();let d=1/0,a=n;for(;a--;){if(!e.output[a]||e.output[a].isDeleted())return!0;const S=e.output[a].getMTime();if(S<p)return!0;S<d&&(d=S)}for(a=e.numberOfInputs;a--;)if((g=e.inputConnection[a])!=null&&g.filter.shouldUpdate()||((v=t.getInputData(a))==null?void 0:v.getMTime())>d)return!0;return!1};function h(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;const d=()=>f(p);return d.filter=t,d}if(e.numberOfInputs){let p=e.numberOfInputs;for(;p--;)e.inputData.push(null),e.inputConnection.push(null);t.setInputData=i,t.setInputConnection=y,t.addInputData=l,t.addInputConnection=s,t.getInputData=u,t.getInputConnection=c}n&&(t.getOutputData=f,t.getOutputPort=h),t.update=()=>{const p=[];if(e.numberOfInputs){let d=0;for(;d<e.numberOfInputs;)p[d]=t.getInputData(d),d++}t.requestData&&!t.isDeleted()&&t.shouldUpdate()&&t.requestData(p,e.output)},t.getNumberOfInputPorts=()=>e.numberOfInputs,t.getNumberOfOutputPorts=()=>n||e.output.length,t.getInputArrayToProcess=p=>{const d=e.inputArrayToProcess[p],a=e.inputData[p];return d&&a?a[`get${d.fieldAssociation}`]().getArray(d.arrayName):null},t.setInputArrayToProcess=function(p,d,a){let g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"Scalars";for(;e.inputArrayToProcess.length<p;)e.inputArrayToProcess.push(null);e.inputArrayToProcess[p]={arrayName:d,fieldAssociation:a,attributeType:g}}}const wt=Symbol("Event abort");function dr(t,e,r){const n=[],i=t.delete;let u=1;function y(s){for(let l=0;l<n.length;++l){const[f]=n[l];if(f===s){n.splice(l,1);return}}}function c(s){function l(){y(s)}return Object.freeze({unsubscribe:l})}function o(){if(e.deleted){$("instance deleted - cannot call any method");return}const s=n.slice();for(let l=0;l<s.length;++l){const[,f,h]=s[l];if(f){if(h<0)setTimeout(()=>f.apply(t,arguments),1-h);else if(f.apply(t,arguments)===wt)break}}}t[`invoke${C(r)}`]=o,t[`on${C(r)}`]=function(s){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!s.apply)return console.error(`Invalid callback for event ${r}`),null;if(e.deleted)return $("instance deleted - cannot call any method"),null;const f=u++;return n.push([f,s,l]),n.sort((h,p)=>p[2]-h[2]),c(f)},t.delete=()=>{i(),n.forEach(s=>{let[l]=s;return y(l)})}}function vr(t,e){const r=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i={},u={};return t(u,i,n),Object.freeze(u)};return e&&V.register(e,r),r}function mr(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(){for(var n=arguments.length,i=new Array(n),u=0;u<n;u++)i[u]=arguments[u];return e.filter(y=>!!y).map(y=>y(...i))}}function St(t){return t&&t.isA&&t.isA("vtkObject")}function Me(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[];if(St(t)){if(n.indexOf(t)>=0)return r;n.push(t);const i=e(t);i!==void 0&&r.push(i);const u=t.get();Object.keys(u).forEach(y=>{const c=u[y];Array.isArray(c)?c.forEach(o=>{Me(o,e,r,n)}):Me(c,e,r,n)})}return r}function wr(t,e,r){var n=this;let i;const u=function(){for(var y=arguments.length,c=new Array(y),o=0;o<y;o++)c[o]=arguments[o];const s=n,l=()=>{i=null,r||t.apply(s,c)},f=r&&!i;clearTimeout(i),i=setTimeout(l,e),f&&t.apply(s,c)};return u.cancel=()=>clearTimeout(i),u}function Sr(t,e){let r=!1,n=null;function i(){r=!1,n!==null&&(u(...n),n=null)}function u(){for(var y=arguments.length,c=new Array(y),o=0;o<y;o++)c[o]=arguments[o];if(r){n=c;return}r=!0,t(...c),setTimeout(i,e)}return u}function Et(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e.keystore=Object.assign(e.keystore||{},r),t.setKey=(n,i)=>{e.keystore[n]=i},t.getKey=n=>e.keystore[n],t.getAllKeys=()=>Object.keys(e.keystore),t.deleteKey=n=>delete e.keystore[n],t.clearKeystore=()=>t.getAllKeys().forEach(n=>delete e.keystore[n])}let Er=1;const fe="__root__";function xr(t,e){Et(t,e);const r=t.delete;e.proxyId=`${Er++}`,e.ui=JSON.parse(JSON.stringify(e.ui||[])),ce(t,e,["proxyId","proxyGroup","proxyName"]),dt(t,e,["proxyManager"]);const n={},i={};function u(s,l){i[l]||(i[l]=[]);const f=i[l];for(let h=0;h<s.length;h++)f.push(s[h].name),n[s[h].name]=s[h],s[h].children&&s[h].children.length&&u(s[h].children,s[h].name)}u(e.ui,fe),t.updateUI=s=>{e.ui=JSON.parse(JSON.stringify(s||[])),Object.keys(n).forEach(l=>delete n[l]),Object.keys(i).forEach(l=>delete i[l]),u(e.ui,fe),t.modified()};function y(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fe;return i[s]}t.updateProxyProperty=(s,l)=>{const f=n[s];f?Object.assign(f,l):n[s]={...l}},t.activate=()=>{if(e.proxyManager){const s=`setActive${C(t.getProxyGroup().slice(0,-1))}`;e.proxyManager[s]&&e.proxyManager[s](t)}},e.propertyLinkSubscribers={},t.registerPropertyLinkForGC=(s,l)=>{l in e.propertyLinkSubscribers||(e.propertyLinkSubscribers[l]=[]),e.propertyLinkSubscribers[l].push(s)},t.gcPropertyLinks=s=>{const l=e.propertyLinkSubscribers[s]||[];for(;l.length;)l.pop().unbind(t)},e.propertyLinkMap={},t.getPropertyLink=function(s){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.propertyLinkMap[s])return e.propertyLinkMap[s];let f=null;const h=[];let p=0,d=!1;function a(w){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(d)return null;const k=[];let E=null;for(p=h.length;p--;){const O=h[p];O.instance===w?E=O:k.push(O)}if(!E)return null;const x=E.instance[`get${C(E.propertyName)}`]();if(!ur(x,f)||m){for(f=x,d=!0;k.length;){const O=k.pop();O.instance.set({[O.propertyName]:f})}d=!1}return e.propertyLinkMap[s].persistent&&(e.propertyLinkMap[s].value=x),x}function g(w,m){const k=[];for(p=h.length;p--;){const E=h[p];E.instance===w&&(E.propertyName===m||m===void 0)&&(E.subscription.unsubscribe(),k.push(p))}for(;k.length;)h.splice(k.pop(),1)}function v(w,m){let k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const E=w.onModified(a),x=h[0];return h.push({instance:w,propertyName:m,subscription:E}),k&&(e.propertyLinkMap[s].persistent&&e.propertyLinkMap[s].value!==void 0?w.set({[m]:e.propertyLinkMap[s].value}):x&&a(x.instance,!0)),{unsubscribe:()=>g(w,m)}}function S(){for(;h.length;)h.pop().subscription.unsubscribe()}const T={bind:v,unbind:g,unsubscribe:S,persistent:l};return e.propertyLinkMap[s]=T,T};function c(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fe;const l=[],f=e.proxyId,h=y(s)||[];for(let p=0;p<h.length;p++){const d=h[p],a=t[`get${C(d)}`],g=a?a():void 0,v={id:f,name:d,value:g},S=c(d);S.length&&(v.children=S),l.push(v)}return l}t.listPropertyNames=()=>c().map(s=>s.name),t.getPropertyByName=s=>c().find(l=>l.name===s),t.getPropertyDomainByName=s=>(n[s]||{}).domain,t.getProxySection=()=>({id:e.proxyId,name:e.proxyGroup,ui:e.ui,properties:c()}),t.delete=()=>{const s=Object.keys(e.propertyLinkMap);let l=s.length;for(;l--;)e.propertyLinkMap[s[l]].unsubscribe();Object.keys(e.propertyLinkSubscribers).forEach(t.gcPropertyLinks),r()},t.getState=()=>null;function o(){if(e.links)for(let s=0;s<e.links.length;s++){const{link:l,property:f,persistent:h,updateOnBind:p,type:d}=e.links[s];if(d==="application"){const a=e.proxyManager.getPropertyLink(l,h);t.registerPropertyLinkForGC(a,"application"),a.bind(t,f,p)}}}ht(o)}function kr(t,e,r){const n=t.delete,i=[],u=Object.keys(r);let y=u.length;for(;y--;){const c=u[y],{modelKey:o,property:s,modified:l=!0}=r[c],f=C(s),h=C(c);t[`get${h}`]=e[o][`get${f}`],t[`set${h}`]=e[o][`set${f}`],l&&i.push(e[o].onModified(t.modified))}t.delete=()=>{for(;i.length;)i.pop().unsubscribe();n()}}function Tr(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};e.this=t;function i(c){const o=Object.keys(c);let s=o.length;for(;s--;){const l=o[s];e[l].set(c[l])}}const u=Object.keys(n);let y=u.length;for(;y--;){const c=u[y];e[c]=n[c];const o=r[c];t[`set${C(c)}`]=s=>{if(s!==e[c]){e[c]=s;const l=o[s];i(l),t.modified()}}}u.length&&ce(t,e,u)}const xt=10,kt=40,Tt=800;function Rr(t){let e=0,r=0,n=0,i=0;return"detail"in t&&(r=t.detail),"wheelDelta"in t&&(r=-t.wheelDelta/120),"wheelDeltaY"in t&&(r=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=r,r=0),n=e*xt,i=r*xt,"deltaY"in t&&(i=t.deltaY),"deltaX"in t&&(n=t.deltaX),(n||i)&&t.deltaMode&&(t.deltaMode===1?(n*=kt,i*=kt):(n*=Tt,i*=Tt)),n&&!e&&(e=n<1?-1:1),i&&!r&&(r=i<1?-1:1),{spinX:e,spinY:r||e,pixelX:n,pixelY:i||n}}var D={algo:gr,capitalize:Oe,chain:mr,debounce:wr,enumToString:cr,event:dr,EVENT_ABORT:wt,formatBytesToProperUnit:ir,formatNumbersWithThousandSeparator:ar,get:ce,getArray:vt,getCurrentGlobalMTime:An,getStateArrayMapFunc:lt,isVtkObject:St,keystore:Et,measurePromiseExecution:fr,moveToProtected:yr,newInstance:vr,newTypedArray:nr,newTypedArrayFrom:rr,normalizeWheel:Rr,obj:lr,proxy:xr,proxyPropertyMapping:kr,proxyPropertyState:Tr,safeArrays:ft,set:gt,setArray:mt,setGet:dt,setGetArray:pr,setImmediate:ht,setLoggerFunction:Pn,throttle:Sr,traverseInstanceTree:Me,TYPED_ARRAYS:L,uncapitalize:or,VOID:Zn,vtkDebugMacro:Te,vtkErrorMacro:$,vtkInfoMacro:er,vtkLogMacro:In,vtkOnceErrorMacro:tr,vtkWarningMacro:Re,objectSetterMap:pt,requiredParam:Qn},De={exports:{}};De.exports,function(t){(function(e,r,n){function i(o){var s=this,l=c();s.next=function(){var f=2091639*s.s0+s.c*23283064365386963e-26;return s.s0=s.s1,s.s1=s.s2,s.s2=f-(s.c=f|0)},s.c=1,s.s0=l(" "),s.s1=l(" "),s.s2=l(" "),s.s0-=l(o),s.s0<0&&(s.s0+=1),s.s1-=l(o),s.s1<0&&(s.s1+=1),s.s2-=l(o),s.s2<0&&(s.s2+=1),l=null}function u(o,s){return s.c=o.c,s.s0=o.s0,s.s1=o.s1,s.s2=o.s2,s}function y(o,s){var l=new i(o),f=s&&s.state,h=l.next;return h.int32=function(){return l.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,f&&(typeof f=="object"&&u(f,l),h.state=function(){return u(l,{})}),h}function c(){var o=4022871197,s=function(l){l=String(l);for(var f=0;f<l.length;f++){o+=l.charCodeAt(f);var h=.02519603282416938*o;o=h>>>0,h-=o,h*=o,o=h>>>0,h-=o,o+=h*4294967296}return(o>>>0)*23283064365386963e-26};return s}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.alea=y})(_,t,!1)}(De);var Or=De.exports,Ce={exports:{}};Ce.exports,function(t){(function(e,r,n){function i(c){var o=this,s="";o.x=0,o.y=0,o.z=0,o.w=0,o.next=function(){var f=o.x^o.x<<11;return o.x=o.y,o.y=o.z,o.z=o.w,o.w^=o.w>>>19^f^f>>>8},c===(c|0)?o.x=c:s+=c;for(var l=0;l<s.length+64;l++)o.x^=s.charCodeAt(l)|0,o.next()}function u(c,o){return o.x=c.x,o.y=c.y,o.z=c.z,o.w=c.w,o}function y(c,o){var s=new i(c),l=o&&o.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var h=s.next()>>>11,p=(s.next()>>>0)/4294967296,d=(h+p)/(1<<21);while(d===0);return d},f.int32=s.next,f.quick=f,l&&(typeof l=="object"&&u(l,s),f.state=function(){return u(s,{})}),f}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.xor128=y})(_,t,!1)}(Ce);var Mr=Ce.exports,be={exports:{}};be.exports,function(t){(function(e,r,n){function i(c){var o=this,s="";o.next=function(){var f=o.x^o.x>>>2;return o.x=o.y,o.y=o.z,o.z=o.w,o.w=o.v,(o.d=o.d+362437|0)+(o.v=o.v^o.v<<4^(f^f<<1))|0},o.x=0,o.y=0,o.z=0,o.w=0,o.v=0,c===(c|0)?o.x=c:s+=c;for(var l=0;l<s.length+64;l++)o.x^=s.charCodeAt(l)|0,l==s.length&&(o.d=o.x<<10^o.x>>>4),o.next()}function u(c,o){return o.x=c.x,o.y=c.y,o.z=c.z,o.w=c.w,o.v=c.v,o.d=c.d,o}function y(c,o){var s=new i(c),l=o&&o.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var h=s.next()>>>11,p=(s.next()>>>0)/4294967296,d=(h+p)/(1<<21);while(d===0);return d},f.int32=s.next,f.quick=f,l&&(typeof l=="object"&&u(l,s),f.state=function(){return u(s,{})}),f}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.xorwow=y})(_,t,!1)}(be);var Dr=be.exports,$e={exports:{}};$e.exports,function(t){(function(e,r,n){function i(c){var o=this;o.next=function(){var l=o.x,f=o.i,h,p;return h=l[f],h^=h>>>7,p=h^h<<24,h=l[f+1&7],p^=h^h>>>10,h=l[f+3&7],p^=h^h>>>3,h=l[f+4&7],p^=h^h<<7,h=l[f+7&7],h=h^h<<13,p^=h^h<<9,l[f]=p,o.i=f+1&7,p};function s(l,f){var h,p=[];if(f===(f|0))p[0]=f;else for(f=""+f,h=0;h<f.length;++h)p[h&7]=p[h&7]<<15^f.charCodeAt(h)+p[h+1&7]<<13;for(;p.length<8;)p.push(0);for(h=0;h<8&&p[h]===0;++h);for(h==8?p[7]=-1:p[h],l.x=p,l.i=0,h=256;h>0;--h)l.next()}s(o,c)}function u(c,o){return o.x=c.x.slice(),o.i=c.i,o}function y(c,o){c==null&&(c=+new Date);var s=new i(c),l=o&&o.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var h=s.next()>>>11,p=(s.next()>>>0)/4294967296,d=(h+p)/(1<<21);while(d===0);return d},f.int32=s.next,f.quick=f,l&&(l.x&&u(l,s),f.state=function(){return u(s,{})}),f}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.xorshift7=y})(_,t,!1)}($e);var Cr=$e.exports,je={exports:{}};je.exports,function(t){(function(e,r,n){function i(c){var o=this;o.next=function(){var l=o.w,f=o.X,h=o.i,p,d;return o.w=l=l+1640531527|0,d=f[h+34&127],p=f[h=h+1&127],d^=d<<13,p^=p<<17,d^=d>>>15,p^=p>>>12,d=f[h]=d^p,o.i=h,d+(l^l>>>16)|0};function s(l,f){var h,p,d,a,g,v=[],S=128;for(f===(f|0)?(p=f,f=null):(f=f+"\0",p=0,S=Math.max(S,f.length)),d=0,a=-32;a<S;++a)f&&(p^=f.charCodeAt((a+32)%f.length)),a===0&&(g=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,a>=0&&(g=g+1640531527|0,h=v[a&127]^=p+g,d=h==0?d+1:0);for(d>=128&&(v[(f&&f.length||0)&127]=-1),d=127,a=4*128;a>0;--a)p=v[d+34&127],h=v[d=d+1&127],p^=p<<13,h^=h<<17,p^=p>>>15,h^=h>>>12,v[d]=p^h;l.w=g,l.X=v,l.i=d}s(o,c)}function u(c,o){return o.i=c.i,o.w=c.w,o.X=c.X.slice(),o}function y(c,o){c==null&&(c=+new Date);var s=new i(c),l=o&&o.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var h=s.next()>>>11,p=(s.next()>>>0)/4294967296,d=(h+p)/(1<<21);while(d===0);return d},f.int32=s.next,f.quick=f,l&&(l.X&&u(l,s),f.state=function(){return u(s,{})}),f}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.xor4096=y})(_,t,!1)}(je);var br=je.exports,Le={exports:{}};Le.exports,function(t){(function(e,r,n){function i(c){var o=this,s="";o.next=function(){var f=o.b,h=o.c,p=o.d,d=o.a;return f=f<<25^f>>>7^h,h=h-p|0,p=p<<24^p>>>8^d,d=d-f|0,o.b=f=f<<20^f>>>12^h,o.c=h=h-p|0,o.d=p<<16^h>>>16^d,o.a=d-f|0},o.a=0,o.b=0,o.c=-1640531527,o.d=1367130551,c===Math.floor(c)?(o.a=c/4294967296|0,o.b=c|0):s+=c;for(var l=0;l<s.length+20;l++)o.b^=s.charCodeAt(l)|0,o.next()}function u(c,o){return o.a=c.a,o.b=c.b,o.c=c.c,o.d=c.d,o}function y(c,o){var s=new i(c),l=o&&o.state,f=function(){return(s.next()>>>0)/4294967296};return f.double=function(){do var h=s.next()>>>11,p=(s.next()>>>0)/4294967296,d=(h+p)/(1<<21);while(d===0);return d},f.int32=s.next,f.quick=f,l&&(typeof l=="object"&&u(l,s),f.state=function(){return u(s,{})}),f}r&&r.exports?r.exports=y:n&&n.amd?n(function(){return y}):this.tychei=y})(_,t,!1)}(Le);var $r=Le.exports,Rt={exports:{}};const jr=At(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(t){(function(e,r,n){var i=256,u=6,y=52,c="random",o=n.pow(i,u),s=n.pow(2,y),l=s*2,f=i-1,h;function p(w,m,k){var E=[];m=m==!0?{entropy:!0}:m||{};var x=v(g(m.entropy?[w,T(r)]:w??S(),3),E),O=new d(E),M=function(){for(var j=O.g(u),F=o,U=0;j<s;)j=(j+U)*i,F*=i,U=O.g(1);for(;j>=l;)j/=2,F/=2,U>>>=1;return(j+U)/F};return M.int32=function(){return O.g(4)|0},M.quick=function(){return O.g(4)/4294967296},M.double=M,v(T(O.S),r),(m.pass||k||function(j,F,U,B){return B&&(B.S&&a(B,O),j.state=function(){return a(O,{})}),U?(n[c]=j,F):j})(M,x,"global"in m?m.global:this==n,m.state)}function d(w){var m,k=w.length,E=this,x=0,O=E.i=E.j=0,M=E.S=[];for(k||(w=[k++]);x<i;)M[x]=x++;for(x=0;x<i;x++)M[x]=M[O=f&O+w[x%k]+(m=M[x])],M[O]=m;(E.g=function(j){for(var F,U=0,B=E.i,ge=E.j,oe=E.S;j--;)F=oe[B=f&B+1],U=U*i+oe[f&(oe[B]=oe[ge=f&ge+F])+(oe[ge]=F)];return E.i=B,E.j=ge,U})(i)}function a(w,m){return m.i=w.i,m.j=w.j,m.S=w.S.slice(),m}function g(w,m){var k=[],E=typeof w,x;if(m&&E=="object")for(x in w)try{k.push(g(w[x],m-1))}catch{}return k.length?k:E=="string"?w:w+"\0"}function v(w,m){for(var k=w+"",E,x=0;x<k.length;)m[f&x]=f&(E^=m[f&x]*19)+k.charCodeAt(x++);return T(m)}function S(){try{var w;return h&&(w=h.randomBytes)?w=w(i):(w=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(w)),T(w)}catch{var m=e.navigator,k=m&&m.plugins;return[+new Date,e,k,e.screen,T(r)]}}function T(w){return String.fromCharCode.apply(0,w)}if(v(n.random(),r),t.exports){t.exports=p;try{h=jr}catch{}}else n["seed"+c]=p})(typeof self<"u"?self:_,[],Math)})(Rt);var Lr=Rt.exports,Ur=Or,Br=Mr,Fr=Dr,_r=Cr,zr=br,Wr=$r,A=Lr;A.alea=Ur,A.xor128=Br,A.xorwow=Fr,A.xorshift7=_r,A.xor4096=zr,A.tychei=Wr;function Ot(t){return t*180/Math.PI}var Mt={Device:{Unknown:0,LeftController:1,RightController:2},Input:{Unknown:0,Trigger:1,TrackPad:2,Grip:3,Thumbstick:4,A:5,B:6,ApplicationMenu:7},Axis:{Unknown:0,TouchpadX:1,TouchpadY:2,ThumbstickX:3,ThumbstickY:4},MouseButton:{LeftButton:1,MiddleButton:2,RightButton:3}};const{Device:le,Input:X}=Mt,{vtkWarningMacro:he,vtkErrorMacro:pe,normalizeWheel:Gr,vtkOnceErrorMacro:Nr}=D,P={ctrlKey:!1,altKey:!1,shiftKey:!1},Ue={"xr-standard":[X.Trigger,X.Grip,X.TrackPad,X.Thumbstick,X.A,X.B]},Be=["StartAnimation","Animation","EndAnimation","PointerEnter","PointerLeave","MouseEnter","MouseLeave","StartMouseMove","MouseMove","EndMouseMove","LeftButtonPress","LeftButtonRelease","MiddleButtonPress","MiddleButtonRelease","RightButtonPress","RightButtonRelease","KeyPress","KeyDown","KeyUp","StartMouseWheel","MouseWheel","EndMouseWheel","StartPinch","Pinch","EndPinch","StartPan","Pan","EndPan","StartRotate","Rotate","EndRotate","Button3D","Move3D","StartPointerLock","EndPointerLock","StartInteraction","Interaction","EndInteraction","AnimationFrameRateUpdate"];function te(t){t.cancelable&&t.preventDefault()}function ye(t){const e=Object.create(null);return t.forEach(r=>{let{pointerId:n,position:i}=r;e[n]=i}),e}function Kr(t,e){e.classHierarchy.push("vtkRenderWindowInteractor");const r={...t},n=new Set,i=new Map;let u=1;t.start=()=>{!e.initialized&&(t.initialize(),!e.initialized)||t.startEventLoop()},t.setRenderWindow=a=>{pe("you want to call setView(view) instead of setRenderWindow on a vtk.js interactor")},t.setInteractorStyle=a=>{e.interactorStyle!==a&&(e.interactorStyle!=null&&e.interactorStyle.setInteractor(null),e.interactorStyle=a,e.interactorStyle!=null&&e.interactorStyle.getInteractor()!==t&&e.interactorStyle.setInteractor(t))},t.initialize=()=>{e.initialized=!0,t.enable(),t.render()},t.enable=()=>t.setEnabled(!0),t.disable=()=>t.setEnabled(!1),t.startEventLoop=()=>he("empty event loop");function y(a,g){e._forcedRenderer||(e.currentRenderer=t.findPokedRenderer(a,g))}t.getCurrentRenderer=()=>(e.currentRenderer||y(0,0),e.currentRenderer);function c(a){const g=e._view.getCanvas(),v=g.getBoundingClientRect(),S=g.width/v.width,T=g.height/v.height,w={x:S*(a.clientX-v.left),y:T*(v.height-a.clientY+v.top),z:0,movementX:S*a.movementX,movementY:T*a.movementY};return(i.size<=1||!e.currentRenderer)&&y(w.x,w.y),w}const o=e._getScreenEventPositionFor||c;function s(a){return{controlKey:a.ctrlKey,altKey:a.altKey,shiftKey:a.shiftKey}}function l(a){const g=s(a);return{key:a.key,keyCode:a.charCode,...g}}function f(a){return a.pointerType||""}const h=()=>{if(e.container===null)return;const{container:a}=e;a.addEventListener("contextmenu",te),a.addEventListener("wheel",t.handleWheel),a.addEventListener("DOMMouseScroll",t.handleWheel),a.addEventListener("pointerenter",t.handlePointerEnter),a.addEventListener("pointerleave",t.handlePointerLeave),a.addEventListener("pointermove",t.handlePointerMove,{passive:!1}),a.addEventListener("pointerdown",t.handlePointerDown,{passive:!1}),a.addEventListener("pointerup",t.handlePointerUp),a.addEventListener("pointercancel",t.handlePointerCancel),a.addEventListener("keypress",t.handleKeyPress),a.addEventListener("keydown",t.handleKeyDown),document.addEventListener("keyup",t.handleKeyUp),document.addEventListener("pointerlockchange",t.handlePointerLockChange),a.tabIndex=0,a.style.touchAction="none",a.style.userSelect="none",a.style.webkitTapHighlightColor="rgba(0,0,0,0)"};t.bindEvents=a=>{if(a===null)return;r.setContainer(a)&&h()};const p=()=>{clearTimeout(e.moveTimeoutID),clearTimeout(e.wheelTimeoutID),e.moveTimeoutID=0,e.wheelTimeoutID=0,u=1;const{container:a}=e;a&&(a.removeEventListener("contextmenu",te),a.removeEventListener("wheel",t.handleWheel),a.removeEventListener("DOMMouseScroll",t.handleWheel),a.removeEventListener("pointerenter",t.handlePointerEnter),a.removeEventListener("pointerleave",t.handlePointerLeave),a.removeEventListener("pointermove",t.handlePointerMove,{passive:!1}),a.removeEventListener("pointerdown",t.handlePointerDown,{passive:!1}),a.removeEventListener("pointerup",t.handlePointerUp),a.removeEventListener("pointercancel",t.handlePointerCancel),a.removeEventListener("keypress",t.handleKeyPress),a.removeEventListener("keydown",t.handleKeyDown)),document.removeEventListener("keyup",t.handleKeyUp),document.removeEventListener("pointerlockchange",t.handlePointerLockChange),i.clear()};t.unbindEvents=()=>{p(),r.setContainer(null)},t.handleKeyPress=a=>{const g=l(a);t.keyPressEvent(g)},t.handleKeyDown=a=>{const g=l(a);t.keyDownEvent(g)},t.handleKeyUp=a=>{const g=l(a);t.keyUpEvent(g)},t.handlePointerEnter=a=>{const g={...s(a),position:o(a),deviceType:f(a)};t.pointerEnterEvent(g),g.deviceType==="mouse"&&t.mouseEnterEvent(g)},t.handlePointerLeave=a=>{const g={...s(a),position:o(a),deviceType:f(a)};t.pointerLeaveEvent(g),g.deviceType==="mouse"&&t.mouseLeaveEvent(g)},t.handlePointerDown=a=>{if(!(a.button>2||t.isPointerLocked()))switch(e.preventDefaultOnPointerDown&&te(a),a.target.hasPointerCapture(a.pointerId)&&a.target.releasePointerCapture(a.pointerId),e.container.setPointerCapture(a.pointerId),i.has(a.pointerId)&&he("[RenderWindowInteractor] duplicate pointerId detected"),i.set(a.pointerId,{pointerId:a.pointerId,position:o(a)}),a.pointerType){case"pen":case"touch":t.handleTouchStart(a);break;case"mouse":default:t.handleMouseDown(a);break}},t.handlePointerUp=a=>{if(i.has(a.pointerId))switch(e.preventDefaultOnPointerUp&&te(a),i.delete(a.pointerId),e.container.releasePointerCapture(a.pointerId),a.pointerType){case"pen":case"touch":t.handleTouchEnd(a);break;case"mouse":default:t.handleMouseUp(a);break}},t.handlePointerCancel=a=>{if(i.has(a.pointerId))switch(i.delete(a.pointerId),a.pointerType){case"pen":case"touch":t.handleTouchEnd(a);break;case"mouse":default:t.handleMouseUp(a);break}},t.handlePointerMove=a=>{if(i.has(a.pointerId)){const g=i.get(a.pointerId);g.position=o(a)}switch(a.pointerType){case"pen":case"touch":t.handleTouchMove(a);break;case"mouse":default:t.handleMouseMove(a);break}},t.handleMouseDown=a=>{const g={...s(a),position:o(a),deviceType:f(a)};switch(a.button){case 0:t.leftButtonPressEvent(g);break;case 1:t.middleButtonPressEvent(g);break;case 2:t.rightButtonPressEvent(g);break;default:pe(`Unknown mouse button pressed: ${a.button}`);break}},t.requestPointerLock=()=>{e.container&&e.container.requestPointerLock()},t.exitPointerLock=()=>{var a;return(a=document.exitPointerLock)==null?void 0:a.call(document)},t.isPointerLocked=()=>!!e.container&&document.pointerLockElement===e.container,t.handlePointerLockChange=()=>{t.isPointerLocked()?t.startPointerLockEvent():t.endPointerLockEvent()};function d(){e._view&&e.enabled&&e.enableRender&&(e.inRender=!0,e._view.traverseAllPasses(),e.inRender=!1),t.invokeRenderEvent()}t.requestAnimation=a=>{if(a===void 0){pe("undefined requester, can not start animating");return}if(n.has(a)){he("requester is already registered for animating");return}n.add(a),!e.animationRequest&&n.size===1&&!e.xrAnimation&&(e._animationStartTime=Date.now(),e._animationFrameCount=0,e.animationRequest=requestAnimationFrame(t.handleAnimation),t.startAnimationEvent())},t.extendAnimation=a=>{const g=Date.now()+a;e._animationExtendedEnd=Math.max(e._animationExtendedEnd,g),!e.animationRequest&&n.size===0&&!e.xrAnimation&&(e._animationStartTime=Date.now(),e._animationFrameCount=0,e.animationRequest=requestAnimationFrame(t.handleAnimation),t.startAnimationEvent())},t.isAnimating=()=>e.xrAnimation||e.animationRequest!==null,t.cancelAnimation=function(a){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!n.has(a)){if(!g){const v=a&&a.getClassName?a.getClassName():a;he(`${v} did not request an animation`)}return}n.delete(a),e.animationRequest&&n.size===0&&Date.now()>e._animationExtendedEnd&&(cancelAnimationFrame(e.animationRequest),e.animationRequest=null,t.endAnimationEvent(),t.render())},t.switchToXRAnimation=()=>{e.animationRequest&&(cancelAnimationFrame(e.animationRequest),e.animationRequest=null),e.xrAnimation=!0},t.returnFromXRAnimation=()=>{e.xrAnimation=!1,n.size!==0&&(e.recentAnimationFrameRate=10,e.animationRequest=requestAnimationFrame(t.handleAnimation))},t.updateXRGamepads=(a,g,v)=>{a.inputSources.forEach(S=>{const T=S.gripSpace==null?null:g.getPose(S.gripSpace,v),w=S.gripSpace==null?null:g.getPose(S.targetRaySpace,v),m=S.gamepad,k=S.handedness;if(m){m.index in e.lastGamepadValues||(e.lastGamepadValues[m.index]={left:{buttons:{}},right:{buttons:{}},none:{buttons:{}}});for(let E=0;E<m.buttons.length;++E)E in e.lastGamepadValues[m.index][k].buttons||(e.lastGamepadValues[m.index][k].buttons[E]=!1),e.lastGamepadValues[m.index][k].buttons[E]!==m.buttons[E].pressed&&T!=null&&(t.button3DEvent({gamepad:m,position:T.transform.position,orientation:T.transform.orientation,targetPosition:w.transform.position,targetOrientation:w.transform.orientation,pressed:m.buttons[E].pressed,device:S.handedness==="left"?le.LeftController:le.RightController,input:Ue[m.mapping]&&Ue[m.mapping][E]?Ue[m.mapping][E]:X.Trigger}),e.lastGamepadValues[m.index][k].buttons[E]=m.buttons[E].pressed),e.lastGamepadValues[m.index][k].buttons[E]&&T!=null&&t.move3DEvent({gamepad:m,position:T.transform.position,orientation:T.transform.orientation,targetPosition:w.transform.position,targetOrientation:w.transform.orientation,device:S.handedness==="left"?le.LeftController:le.RightController})}})},t.handleMouseMove=a=>{const g={...s(a),position:o(a),deviceType:f(a)};e.moveTimeoutID===0?t.startMouseMoveEvent(g):(t.mouseMoveEvent(g),clearTimeout(e.moveTimeoutID)),e.moveTimeoutID=setTimeout(()=>{t.endMouseMoveEvent(),e.moveTimeoutID=0},200)},t.handleAnimation=()=>{const a=Date.now();e._animationFrameCount++,a-e._animationStartTime>1e3&&e._animationFrameCount>1&&(e.recentAnimationFrameRate=1e3*(e._animationFrameCount-1)/(a-e._animationStartTime),e.lastFrameTime=1/e.recentAnimationFrameRate,t.animationFrameRateUpdateEvent(),e._animationStartTime=a,e._animationFrameCount=1),t.animationEvent(),d(),n.size>0||Date.now()<e._animationExtendedEnd?e.animationRequest=requestAnimationFrame(t.handleAnimation):(cancelAnimationFrame(e.animationRequest),e.animationRequest=null,t.endAnimationEvent(),t.render())},t.handleWheel=a=>{te(a);const g={...Gr(a),...s(a),position:o(a),deviceType:f(a)};e.wheelTimeoutID===0&&(Math.abs(g.spinY)>=.3?u=Math.abs(g.spinY):u=1),g.spinY/=u,e.wheelTimeoutID===0?(t.startMouseWheelEvent(g),t.mouseWheelEvent(g)):(t.mouseWheelEvent(g),clearTimeout(e.wheelTimeoutID)),e.mouseScrollDebounceByPass?(t.extendAnimation(600),t.endMouseWheelEvent(),e.wheelTimeoutID=0):e.wheelTimeoutID=setTimeout(()=>{t.extendAnimation(600),t.endMouseWheelEvent(),e.wheelTimeoutID=0},200)},t.handleMouseUp=a=>{const g={...s(a),position:o(a),deviceType:f(a)};switch(a.button){case 0:t.leftButtonReleaseEvent(g);break;case 1:t.middleButtonReleaseEvent(g);break;case 2:t.rightButtonReleaseEvent(g);break;default:pe(`Unknown mouse button released: ${a.button}`);break}},t.handleTouchStart=a=>{const g=[...i.values()];if(e.recognizeGestures&&g.length>1){const v=ye(i);if(g.length===2){const S={...s(P),position:g[0].position,deviceType:f(a)};t.leftButtonReleaseEvent(S)}t.recognizeGesture("TouchStart",v)}else if(g.length===1){const v={...s(P),position:o(a),deviceType:f(a)};t.leftButtonPressEvent(v)}},t.handleTouchMove=a=>{const g=[...i.values()];if(e.recognizeGestures&&g.length>1){const v=ye(i);t.recognizeGesture("TouchMove",v)}else if(g.length===1){const v={...s(P),position:g[0].position,deviceType:f(a)};t.mouseMoveEvent(v)}},t.handleTouchEnd=a=>{const g=[...i.values()];if(e.recognizeGestures)if(g.length===0){const v={...s(P),position:o(a),deviceType:f(a)};t.leftButtonReleaseEvent(v)}else if(g.length===1){const v=ye(i);t.recognizeGesture("TouchEnd",v);const S={...s(P),position:g[0].position,deviceType:f(a)};t.leftButtonPressEvent(S)}else{const v=ye(i);t.recognizeGesture("TouchMove",v)}else if(g.length===1){const v={...s(P),position:g[0].position,deviceType:f(a)};t.leftButtonReleaseEvent(v)}},t.setView=a=>{e._view!==a&&(e._view=a,e._view.getRenderable().setInteractor(t),t.modified())},t.getFirstRenderer=()=>{var a,g,v;return(v=(g=(a=e._view)==null?void 0:a.getRenderable())==null?void 0:g.getRenderersByReference())==null?void 0:v[0]},t.findPokedRenderer=function(){var k,E;let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!e._view)return null;const v=(E=(k=e._view)==null?void 0:k.getRenderable())==null?void 0:E.getRenderers();if(!v||v.length===0)return null;v.sort((x,O)=>x.getLayer()-O.getLayer());let S=null,T=null,w=null,m=v.length;for(;m--;){const x=v[m];if(e._view.isInViewport(a,g,x)&&x.getInteractive()){w=x;break}S===null&&x.getInteractive()&&(S=x),T===null&&e._view.isInViewport(a,g,x)&&(T=x)}return w===null&&(w=S),w===null&&(w=T),w==null&&(w=v[0]),w},t.render=()=>{!t.isAnimating()&&!e.inRender&&d()},Be.forEach(a=>{const g=a.charAt(0).toLowerCase()+a.slice(1);t[`${g}Event`]=v=>{if(!e.enabled)return;if(!t.getCurrentRenderer()){Nr(`
          Can not forward events without a current renderer on the interactor.
        `);return}const T={type:a,pokedRenderer:e.currentRenderer,firstRenderer:t.getFirstRenderer(),...v};t[`invoke${a}`](T)}}),t.recognizeGesture=(a,g)=>{if(Object.keys(g).length>2)return;if(e.startingEventPositions||(e.startingEventPositions={}),a==="TouchStart"){Object.keys(g).forEach(M=>{e.startingEventPositions[M]=g[M]}),e.currentGesture="Start";return}if(a==="TouchEnd"){e.currentGesture==="Pinch"&&(t.render(),t.endPinchEvent()),e.currentGesture==="Rotate"&&(t.render(),t.endRotateEvent()),e.currentGesture==="Pan"&&(t.render(),t.endPanEvent()),e.currentGesture="Start",e.startingEventPositions={};return}let v=0;const S=[],T=[];Object.keys(g).forEach(M=>{S[v]=g[M],T[v]=e.startingEventPositions[M],v++});const w=Math.sqrt((T[0].x-T[1].x)*(T[0].x-T[1].x)+(T[0].y-T[1].y)*(T[0].y-T[1].y)),m=Math.sqrt((S[0].x-S[1].x)*(S[0].x-S[1].x)+(S[0].y-S[1].y)*(S[0].y-S[1].y));let k=Ot(Math.atan2(T[1].y-T[0].y,T[1].x-T[0].x)),E=Ot(Math.atan2(S[1].y-S[0].y,S[1].x-S[0].x)),x=E-k;E=E+180>=360?E-180:E+180,k=k+180>=360?k-180:k+180,Math.abs(E-k)<Math.abs(x)&&(x=E-k);const O=[];if(O[0]=(S[0].x-T[0].x+S[1].x-T[1].x)/2,O[1]=(S[0].y-T[0].y+S[1].y-T[1].y)/2,a==="TouchMove")if(e.currentGesture==="Start"){let M=.01*Math.sqrt(e.container.clientWidth*e.container.clientWidth+e.container.clientHeight*e.container.clientHeight);M<15&&(M=15);const j=Math.abs(m-w),F=m*3.1415926*Math.abs(x)/360,U=Math.sqrt(O[0]*O[0]+O[1]*O[1]);if(j>M&&j>F&&j>U){e.currentGesture="Pinch";const B={scale:1,touches:g};t.startPinchEvent(B)}else if(F>M&&F>U){e.currentGesture="Rotate";const B={rotation:0,touches:g};t.startRotateEvent(B)}else if(U>M){e.currentGesture="Pan";const B={translation:[0,0],touches:g};t.startPanEvent(B)}}else{if(e.currentGesture==="Rotate"){const M={rotation:x,touches:g};t.rotateEvent(M)}if(e.currentGesture==="Pinch"){const M={scale:m/w,touches:g};t.pinchEvent(M)}if(e.currentGesture==="Pan"){const M={translation:O,touches:g};t.panEvent(M)}}},t.handleVisibilityChange=()=>{e._animationStartTime=Date.now(),e._animationFrameCount=0},t.setCurrentRenderer=a=>{e._forcedRenderer=!!a,e.currentRenderer=a},t.setContainer=a=>{p();const g=r.setContainer(a??null);return g&&h(),g},t.delete=()=>{for(;n.size;)t.cancelAnimation(n.values().next().value);typeof document.hidden<"u"&&document.removeEventListener("visibilitychange",t.handleVisibilityChange),e.container&&t.setContainer(null),r.delete()},typeof document.hidden<"u"&&document.addEventListener("visibilitychange",t.handleVisibilityChange,!1)}const Vr={renderWindow:null,interactorStyle:null,picker:null,pickingManager:null,initialized:!1,enabled:!1,enableRender:!0,currentRenderer:null,lightFollowCamera:!0,desiredUpdateRate:30,stillUpdateRate:2,container:null,recognizeGestures:!0,currentGesture:"Start",animationRequest:null,lastFrameTime:.1,recentAnimationFrameRate:10,wheelTimeoutID:0,moveTimeoutID:0,lastGamepadValues:{},preventDefaultOnPointerDown:!1,preventDefaultOnPointerUp:!1,mouseScrollDebounceByPass:!1};function Dt(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Vr,r),D.obj(t,e),e._animationExtendedEnd=0,D.event(t,e,"RenderEvent"),Be.forEach(n=>D.event(t,e,n)),D.get(t,e,["initialized","interactorStyle","lastFrameTime","recentAnimationFrameRate","_view"]),D.setGet(t,e,["container","lightFollowCamera","enabled","enableRender","recognizeGestures","desiredUpdateRate","stillUpdateRate","picker","preventDefaultOnPointerDown","preventDefaultOnPointerUp","mouseScrollDebounceByPass"]),D.moveToProtected(t,e,["view"]),Kr(t,e)}var Ct={newInstance:D.newInstance(Dt,"vtkRenderWindowInteractor"),extend:Dt,handledEvents:Be,...Mt};const{vtkErrorMacro:qr,VOID:Xr}=D;function Yr(t,e,r,n){return t.getRenderWindow().getViews()[0].worldToDisplay(e,r,n,t)}function Hr(t,e,r,n){return t.getRenderWindow().getViews()[0].displayToWorld(e,r,n,t)}const Jr={computeWorldToDisplay:Yr,computeDisplayToWorld:Hr};function Qr(t,e){e.classHierarchy.push("vtkInteractorObserver");const r={...t};function n(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function i(){Ct.handledEvents.forEach(u=>{t[`handle${u}`]&&e.subscribedEvents.push(e._interactor[`on${u}`](y=>e.processEvents?t[`handle${u}`](y):Xr,e.priority))})}t.setInteractor=u=>{u!==e._interactor&&(n(),e._interactor=u,u&&e.enabled&&i(),t.modified())},t.setEnabled=u=>{u!==e.enabled&&(n(),u&&(e._interactor?i():qr(`
          The interactor must be set before subscribing to events
        `)),e.enabled=u,t.modified())},t.computeDisplayToWorld=(u,y,c,o)=>u?e._interactor.getView().displayToWorld(y,c,o,u):null,t.computeWorldToDisplay=(u,y,c,o)=>u?e._interactor.getView().worldToDisplay(y,c,o,u):null,t.setPriority=u=>{r.setPriority(u)&&e._interactor&&(n(),i())}}const Zr={enabled:!0,priority:0,processEvents:!0,subscribedEvents:[]};function bt(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Zr,r),D.obj(t,e),D.event(t,e,"InteractionEvent"),D.event(t,e,"StartInteractionEvent"),D.event(t,e,"EndInteractionEvent"),D.get(t,e,["_interactor","enabled"]),D.setGet(t,e,["priority","processEvents"]),D.moveToProtected(t,e,["interactor"]),Qr(t,e)}var Ar={newInstance:D.newInstance(bt,"vtkInteractorObserver"),extend:bt,...Jr},$t={States:{IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025}};const{States:W}=$t,Fe={Rotate:W.IS_ROTATE,Pan:W.IS_PAN,Spin:W.IS_SPIN,Dolly:W.IS_DOLLY,CameraPose:W.IS_CAMERA_POSE,WindowLevel:W.IS_WINDOW_LEVEL,Slice:W.IS_SLICE};function Pr(t,e){e.classHierarchy.push("vtkInteractorStyle"),Object.keys(Fe).forEach(r=>{D.event(t,e,`Start${r}Event`),t[`start${r}`]=()=>{e.state===W.IS_NONE&&(e.state=Fe[r],e._interactor.requestAnimation(t),t.invokeStartInteractionEvent({type:"StartInteractionEvent"}),t[`invokeStart${r}Event`]({type:`Start${r}Event`}))},D.event(t,e,`End${r}Event`),t[`end${r}`]=()=>{e.state===Fe[r]&&(e.state=W.IS_NONE,e._interactor.cancelAnimation(t),t.invokeEndInteractionEvent({type:"EndInteractionEvent"}),t[`invokeEnd${r}Event`]({type:`End${r}Event`}),e._interactor.render())}}),e.getRenderer=r=>e.focusedRenderer||r.pokedRenderer,t.handleKeyPress=r=>{const n=e._interactor;let i=null;switch(r.key){case"r":case"R":e.getRenderer(r).resetCamera(),n.render();break;case"w":case"W":i=e.getRenderer(r).getActors(),i.forEach(u=>{const y=u.getProperty();y.setRepresentationToWireframe&&y.setRepresentationToWireframe()}),n.render();break;case"s":case"S":i=e.getRenderer(r).getActors(),i.forEach(u=>{const y=u.getProperty();y.setRepresentationToSurface&&y.setRepresentationToSurface()}),n.render();break;case"v":case"V":i=e.getRenderer(r).getActors(),i.forEach(u=>{const y=u.getProperty();y.setRepresentationToPoints&&y.setRepresentationToPoints()}),n.render();break}}}const Ir={state:W.IS_NONE,handleObservers:1,autoAdjustCameraClippingRange:1};function jt(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Ir,r),Ar.extend(t,e,r),D.setGet(t,e,["focusedRenderer"]),Pr(t,e)}var eo={newInstance:D.newInstance(jt,"vtkInteractorStyle"),extend:jt,...$t};const ne={type:"StartInteractionEvent"},Lt={type:"InteractionEvent"},re={type:"EndInteractionEvent"};function to(t,e){e.classHierarchy.push("vtkInteractorStyleRemoteMouse");function r(n){const{buttonLeft:i,buttonMiddle:u,buttonRight:y}=e,c=n.shiftKey?1:0,o=n.controlKey?1:0,s=n.altKey?1:0,l=n.metaKey?1:0,f=i||u||y?"down":"up";let{x:h,y:p}=n.position;return{action:f,x:h,y:p,buttonLeft:i,buttonMiddle:u,buttonRight:y,shiftKey:c,altKey:s,ctrlKey:o,metaKey:l,...e.remoteEventAddOn}}t.handleLeftButtonPress=n=>{e.previousPosition=n.position,e.buttonLeft=1,t.onButtonDown(1,n)},t.handleMiddleButtonPress=n=>{e.previousPosition=n.position,e.buttonMiddle=1,t.onButtonDown(2,n)},t.handleRightButtonPress=n=>{e.previousPosition=n.position,e.buttonRight=1,t.onButtonDown(3,n)},t.handleLeftButtonRelease=n=>{e.buttonLeft=0,t.onButtonUp(1,n)},t.handleMiddleButtonRelease=n=>{e.buttonMiddle=0,t.onButtonUp(2,n)},t.handleRightButtonRelease=n=>{e.buttonRight=0,t.onButtonUp(3,n)},t.onButtonDown=(n,i)=>{t.invokeStartInteractionEvent(ne);let u="";n==1?u="LeftButtonPress":n==2?u="MiddleButtonPress":n==3&&(u="RightButtonPress"),t.invokeRemoteMouseEvent({type:u,...r(i)})},t.onButtonUp=(n,i)=>{let u="";n==1?u="LeftButtonRelease":n==2?u="MiddleButtonRelease":n==3&&(u="RightButtonRelease"),t.invokeRemoteMouseEvent({type:u,...r(i)}),t.invokeEndInteractionEvent(re)},t.handleStartMouseWheel=n=>{t.invokeStartInteractionEvent(ne),t.invokeRemoteWheelEvent({type:"StartMouseWheel",...r(n),spinY:n.spinY})},t.handleMouseWheel=n=>{let i=!0;if(e.wheelThrottleDelay){const u=Date.now();i=e.wheelThrottleDelay<u-e.wheelLastThrottleTime,i&&(e.wheelLastThrottleTime=u)}i&&(t.invokeRemoteWheelEvent({type:"MouseWheel",...r(n),spinY:n.spinY}),t.invokeInteractionEvent(Lt))},t.handleEndMouseWheel=()=>{t.invokeRemoteWheelEvent({type:"EndMouseWheel",...e.remoteEventAddOn}),t.invokeEndInteractionEvent(re)},t.handleMouseMove=n=>{const i=Date.now();e.throttleDelay<i-e.lastThrottleTime&&(e.sendMouseMove||e.buttonLeft||e.buttonMiddle||e.buttonRight)&&(e.lastThrottleTime=i,t.invokeRemoteMouseEvent({type:"MouseMove",...r(n)})),t.invokeInteractionEvent(Lt)},t.handleKeyPress=()=>{},t.handleStartPinch=n=>{t.startDolly();const{scale:i}=n;t.invokeStartInteractionEvent(ne),t.invokeRemoteGestureEvent({type:"StartPinch",scale:i,...e.remoteEventAddOn})},t.handlePinch=n=>{const{scale:i}=n;t.invokeRemoteGestureEvent({type:"Pinch",scale:i,...e.remoteEventAddOn})},t.handleEndPinch=()=>{t.endDolly(),t.invokeRemoteGestureEvent({type:"EndPinch",...e.remoteEventAddOn}),t.invokeEndInteractionEvent(re)},t.handleStartRotate=n=>{t.startRotate();const{rotation:i}=n;t.invokeStartInteractionEvent(ne),t.invokeRemoteGestureEvent({type:"StartRotate",rotation:i,...e.remoteEventAddOn})},t.handleRotate=n=>{const{rotation:i}=n;t.invokeRemoteGestureEvent({type:"Rotate",rotation:i,...e.remoteEventAddOn})},t.handleEndRotate=()=>{t.endRotate(),t.invokeRemoteGestureEvent({type:"EndRotate",...e.remoteEventAddOn}),t.invokeEndInteractionEvent(re)},t.handleStartPan=n=>{t.startPan();const{translation:i}=n;t.invokeStartInteractionEvent(ne),t.invokeRemoteGestureEvent({type:"StartPan",translation:i,...e.remoteEventAddOn})},t.handlePan=n=>{const{translation:i}=n;t.invokeRemoteGestureEvent({type:"Pan",translation:i,...e.remoteEventAddOn})},t.handleEndPan=()=>{t.endPan(),t.invokeRemoteGestureEvent({type:"EndPan",...e.remoteEventAddOn}),t.invokeEndInteractionEvent(re)},t.handleKeyPress=n=>{t.invokeRemoteKeyEvent({type:"keyPress",...n})},t.handleKeyDown=n=>{t.invokeRemoteKeyEvent({type:"keyDown",...n})},t.handleKeyUp=n=>{t.invokeRemoteKeyEvent({type:"keyUp",...n})}}const no={buttonLeft:0,buttonMiddle:0,buttonRight:0,sendMouseMove:!1,throttleDelay:33.3,lastThrottleTime:0,wheelThrottleDelay:0,wheelLastThrottleTime:0};function Ut(t,e,r={}){Object.assign(e,no,r),eo.extend(t,e,r),D.setGet(t,e,["sendMouseMove","remoteEventAddOn","throttleDelay","wheelThrottleDelay"]),D.event(t,e,"RemoteMouseEvent"),D.event(t,e,"RemoteWheelEvent"),D.event(t,e,"RemoteGestureEvent"),D.event(t,e,"RemoteKeyEvent"),to(t,e)}const ro={newInstance:D.newInstance(Ut,"vtkInteractorStyleRemoteMouse"),extend:Ut};function oo(){return new Promise(t=>setTimeout(t,0))}async function io(t){if(!(t<0))return new Promise(e=>setTimeout(e,t))}class ao{constructor(e,r=100){this.eventQueue=[],this.processing=!1,this.throttleTimeMs=r,this.processCallback=e,this.eventKeysToIgnore=new Set(["x","y"])}compressEvents(e){if(e.length<2)return[...e];const r=[];for(let n=0;n<e.length;n++){const i=e[n],u=e[n+1];u&&this.canCompressEvents(i,u)||r.push(i)}return r}canCompressEvents(e,r){if(e.type==="MouseWheel"||r.type==="MouseWheel"||Object.keys(e).length!==Object.keys(r).length)return!1;for(let n in e)if(!this.eventKeysToIgnore.has(n)&&e[n]!==r[n])return!1;return!0}sendEvent(e){this.eventQueue.push(e),this.processing||(this.processing=!0,this._processEventQueue().catch(r=>{console.error("Error in _processEventQueue:",r),this.processing=!1}))}async _processEventQueue(){const e=this.compressEvents(this.eventQueue);this.eventQueue.length=0;const r=Date.now();for(const n of e)await this.processCallback(n),await oo();await io(this.throttleTimeMs-Date.now()+r),this.eventQueue.length>0?await this._processEventQueue():this.processing=!1}}const{inject:so,provide:uo,ref:co,toRefs:fo,onMounted:lo,onBeforeUnmount:ho}=window.Vue,po=Promise.resolve(!0),Bt={DisplayArea:Ht,StatisticsDisplay:Zt,ImageDisplayArea:_e,RemoteControlledArea:{props:{name:{type:String,default:"default"},origin:{type:String,default:"anonymous"},display:{type:String,default:"image"},sendMouseMove:{type:Boolean,default:!1},eventThrottleMs:{type:Number,default:25},imageStyle:{type:Object,default:()=>({width:"100%"})}},setup(t){const e=co(null),r=so("trame"),n=new ao(g=>r.client.getConnection().getSession().call("trame.rca.event",[t.name,t.origin,g]),t.eventThrottleMs);let i=[0,0],u={w:10,h:10,p:window.devicePixelRatio},y=!0,c=po,o=0;function s(g){return{x:g.clientX-i[0],y:u.h-g.clientY+i[1],z:0}}const l=Ct.newInstance({_getScreenEventPositionFor:s,currentRenderer:1}),f=ro.newInstance();l.setInteractorStyle(f),f.setSendMouseMove(t.sendMouseMove),f.onRemoteMouseEvent(g=>{h(Object.assign({w:u.w,h:u.h},g))}),f.onRemoteWheelEvent(g=>{h(Object.assign({w:u.w,h:u.h},g))}),f.onRemoteGestureEvent(g=>{h(Object.assign({w:u.w,h:u.h},g))}),f.onRemoteKeyEvent(g=>{h(Object.assign({w:u.w,h:u.h},g))}),f.onStartInteractionEvent(g=>{h(g)}),f.onEndInteractionEvent(g=>{h(g)});function h(g){r&&n.sendEvent(g)}function p(){y=!0,o&&(o=0,a())}const d=new ResizeObserver(()=>{if(!e.value)return;const g=e.value.getBoundingClientRect(),{top:v,left:S}=g;u.w=g.width,u.h=g.height,u.p=window.devicePixelRatio,i=[S,v],a()});function a(g){r&&(y?(y=!1,g?c=r.client.getConnection().getSession().call("trame.rca.size",[t.name,t.origin,{...u,...g}]):c=r.client.getConnection().getSession().call("trame.rca.size",[t.name,t.origin,u]),c.finally(p)):o++)}return uo("rcaPushSize",a),lo(()=>{d.observe(e.value),l.initialize(),l.bindEvents(e.value)}),ho(()=>{d.unobserve(e.value),l.unbindEvents(e.value)}),{rootElem:e,...fo(t)}},template:`
    <div ref="rootElem" style="margin: 0; padding: 0; position: relative; width: 100%; height: 100%;">
      <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
        <display-area :display="display" :name="name" :origin="origin" :imageStyle="imageStyle" />
        <slot></slot>
      </div>
    </div>
  `},MediaSourceDisplayArea:ze,VideoDecoderDisplayArea:We,RawImageDisplayArea:Ge};function yo(t){Object.keys(Bt).forEach(e=>{t.component(e,Bt[e])})}Y.install=yo,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
