import{fs as we,fy as de,gW as Ve,kj as he,E as Pe,L as me,e2 as D,iy as $,iz as z,_ as t,$ as o,co as K,a0 as v,cp as g,iu as Ee,gX as j,b1 as E,ct as c,cF as Q,V as Y,kk as G,aY as X,s as je,aL as $e,bC as Be,ab as ze,fx as ke,kl as Ce,a7 as oe,km as Oe,kn as We,fA as Ue,eB as Je,eC as Xe,eD as Ye,ih as Ge,eE as He,ii as Ke,jf as Qe,a as T,aM as Ze,g as re,cA as Re,ib as et,iI as tt,eH as it,cK as ve,cu as ot}from"./index.6c049565.js";import{N as rt}from"./SceneService.54334498.js";import{g as st}from"./persistable.1b6e46c5.js";import{v as se,y as nt}from"./quat.4f976512.js";import{e as te}from"./quatf64.4ae3e6f1.js";import"./originUtils.2d0aad75.js";import"./multiOriginJSONSupportUtils.38b69b9c.js";import"./resourceUtils.60052bdf.js";import"./mat3f64.6d32a1d7.js";const f=Pe(),ge=te(),fe=te(),be=te(),Ie=new Float64Array([0,0,1]),lt=new Float64Array([0,1,0]),at=new Float64Array([1,0,0]);function B(e){we(f,e),de(f,f);const i=Math.atan2(f[1],f[0]),r=se(te(),Ie,-i);Ve(f,f,r);const s=-1*Math.atan2(f[2],f[0]);return[he(i)+270,he(s)+90]}function Z(e,i){return se(fe,Ie,me(e-270)),se(be,lt,me(i-90)),nt(ge,fe,be),we(f,at),Ve(f,f,ge),de(f,f),[f[0],f[1],f[2]]}let R=class extends D(g){constructor(e){super(e),this.enabled=!0,this.label="",this.normal=null,this.point=null}get orientation(){if(!Array.isArray(this.normal)||this.normal.length!==3)return 0;const[e,i]=B(this.normal);return $.normalize(z(e),0,!0)}set orientation(e){const i=Z(e,this.tilt);this._set("normal",i),this._set("orientation",e)}get tilt(){if(!Array.isArray(this.normal)||this.normal.length!==3)return 0;const[e,i]=B(this.normal);return $.normalize(z(i),0,!0)}set tilt(e){const i=Z(this.orientation,e);this._set("normal",i),this._set("tilt",e)}};t([o({type:Boolean,json:{write:!0}})],R.prototype,"enabled",void 0),t([o({type:String,json:{write:!0}})],R.prototype,"label",void 0),t([o({type:Number,json:{read:!1},clonable:!1,range:{min:0,max:360}}),K(e=>$.normalize(z(e),0,!0))],R.prototype,"orientation",null),t([o({type:Number,json:{read:!1},clonable:!1,range:{min:0,max:360}}),K(e=>$.normalize(z(e),0,!0))],R.prototype,"tilt",null),t([o({type:[Number],json:{write:!0}})],R.prototype,"normal",void 0),t([o({type:[Number],json:{write:!0}})],R.prototype,"point",void 0),R=t([v("esri.layers.voxel.VoxelSlice")],R);const ee=R;let b=class extends D(g){constructor(){super(...arguments),this.enabled=!0,this.href=null,this.id=null,this.label="",this.normal=null,this.point=null,this.sizeInPixel=null,this.slices=null,this.timeId=0,this.variableId=null}get orientation(){if(!Array.isArray(this.normal)||this.normal.length!==3)return 0;const[e,i]=B(this.normal);return $.normalize(z(e),0,!0)}get tilt(){if(!Array.isArray(this.normal)||this.normal.length!==3)return 0;const[e,i]=B(this.normal);return $.normalize(z(i),0,!0)}};t([o({type:Boolean,json:{default:!0,write:!0}})],b.prototype,"enabled",void 0),t([o({type:String,json:{origins:{service:{read:Ee}},write:{enabled:!0,isRequired:!0}}}),st({origins:["web-scene"],type:"resource",prefix:"sections",compress:!0})],b.prototype,"href",void 0),t([o({type:j,json:{write:{enabled:!0,isRequired:!0}}})],b.prototype,"id",void 0),t([o({type:String,json:{write:!0}})],b.prototype,"label",void 0),t([o({type:Number,clonable:!1,readOnly:!0,range:{min:0,max:360}})],b.prototype,"orientation",null),t([o({type:Number,clonable:!1,readOnly:!0,range:{min:0,max:360}})],b.prototype,"tilt",null),t([o({type:[Number],json:{write:{enabled:!0,isRequired:!0}}})],b.prototype,"normal",void 0),t([o({type:[Number],json:{write:{enabled:!0,isRequired:!0}}})],b.prototype,"point",void 0),t([o({type:[j],json:{write:{enabled:!0,isRequired:!0}}})],b.prototype,"sizeInPixel",void 0),t([o({type:[ee],json:{write:!0}})],b.prototype,"slices",void 0),t([o({type:j,json:{default:0,write:!0}})],b.prototype,"timeId",void 0),t([o({type:j,json:{write:{enabled:!0,isRequired:!0}}})],b.prototype,"variableId",void 0),b=t([v("esri.layers.voxel.VoxelSection")],b);const ne=b;let C=class extends g{constructor(){super(...arguments),this.diffuseFactor=.5,this.specularFactor=.5}};t([o({type:Number,range:{min:0,max:1},json:{default:.5,write:!0}})],C.prototype,"diffuseFactor",void 0),t([o({type:Number,range:{min:0,max:1},json:{default:.5,write:!0}})],C.prototype,"specularFactor",void 0),C=t([v("esri.layers.voxel.VoxelSimpleShading")],C);const Ne=C;let I=class extends g{constructor(){super(...arguments),this.continuity=null,this.hasNoData=!1,this.noData=0,this.offset=0,this.scale=1,this.type=null}};t([o({type:["discrete","continuous"],json:{write:!0}})],I.prototype,"continuity",void 0),t([o({type:Boolean,json:{write:!0}})],I.prototype,"hasNoData",void 0),t([o({type:Number,json:{write:!0}})],I.prototype,"noData",void 0),t([o({type:Number,json:{write:!0}})],I.prototype,"offset",void 0),t([o({type:Number,json:{write:!0}})],I.prototype,"scale",void 0),t([o({type:String,json:{write:{enabled:!0,isRequired:!0}}})],I.prototype,"type",void 0),I=t([v("esri.layers.voxel.VoxelFormat")],I);const Se=I;let V=class extends g{constructor(){super(...arguments),this.id=null,this.description="",this.name=null,this.originalFormat=null,this.renderingFormat=null,this.unit="",this.volumeId=0,this.type=null}};t([o({type:Number,json:{write:{enabled:!0,isRequired:!0}}})],V.prototype,"id",void 0),t([o({type:String,json:{write:!0}})],V.prototype,"description",void 0),t([o({type:String,json:{write:{enabled:!0,isRequired:!0}}})],V.prototype,"name",void 0),t([o({type:Se,json:{write:!0}})],V.prototype,"originalFormat",void 0),t([o({type:Se,json:{write:{enabled:!0,isRequired:!0}}})],V.prototype,"renderingFormat",void 0),t([o({type:String,json:{write:!0}})],V.prototype,"unit",void 0),t([o({type:Number,json:{write:!0}})],V.prototype,"volumeId",void 0),t([o({type:["stc-hot-spot-results","stc-cluster-outlier-results","stc-estimated-bin","generic-nearest-interpolated"],json:{write:!0}})],V.prototype,"type",void 0),V=t([v("esri.layers.voxel.VoxelVariable")],V);const pt=V;let F=class extends D(g){constructor(){super(...arguments),this.color=E.fromArray([0,0,0,0]),this.value=0,this.enabled=!0,this.label="",this.colorLocked=!0}};t([o({type:E,json:{type:[j],write:{enabled:!0,isRequired:!0}}})],F.prototype,"color",void 0),t([o({type:Number,json:{write:{enabled:!0,isRequired:!0}}})],F.prototype,"value",void 0),t([o({type:Boolean,json:{default:!0,write:!0}})],F.prototype,"enabled",void 0),t([o({type:String,json:{write:!0}})],F.prototype,"label",void 0),t([o({type:Boolean,json:{default:!1}})],F.prototype,"colorLocked",void 0),F=t([v("esri.layers.voxel.VoxelIsosurface")],F);const Ae=F;let O=class extends D(g){constructor(){super(...arguments),this.color=null,this.position=0}};t([o({type:E,json:{type:[j],write:{enabled:!0,isRequired:!0}}})],O.prototype,"color",void 0),t([o({type:Number,json:{write:{enabled:!0,isRequired:!0}}})],O.prototype,"position",void 0),O=t([v("esri.layers.voxel.VoxelColorStop")],O);const le=O;let W=class extends D(g){constructor(){super(...arguments),this.opacity=1,this.position=0}};t([o({type:Number,json:{name:"alpha",write:{enabled:!0,isRequired:!0}}})],W.prototype,"opacity",void 0),t([o({type:Number,json:{write:{enabled:!0,isRequired:!0}}})],W.prototype,"position",void 0),W=t([v("esri.layers.voxel.VoxelOpacityStop")],W);const ae=W;let U=class extends D(g){constructor(){super(...arguments),this.enabled=!1,this.range=null}};t([o({type:Boolean,json:{default:!1,write:!0}})],U.prototype,"enabled",void 0),t([o({type:[Number],json:{write:!0}})],U.prototype,"range",void 0),U=t([v("esri.layers.voxel.VoxelRangeFilter")],U);const ut=U;var w;(function(e){e[e.Color=1]="Color",e[e.Alpha=2]="Alpha",e[e.Both=3]="Both"})(w||(w={}));let N=class extends D(g){constructor(e){super(e),this.interpolation=null,this.stretchRange=null,this.rangeFilter=null,this._colorMapSize=256,this.colorStops=new(c.ofType(le)),this.opacityStops=new(c.ofType(ae))}set colorStops(e){this._set("colorStops",Q(e,this._get("colorStops"),c.ofType(le)))}set opacityStops(e){this._set("opacityStops",Q(e,this._get("opacityStops"),c.ofType(ae)))}getPreviousNext(e,i,r){let s=e;for(;--s>0&&i[s].type!==r&&i[s].type!==w.Both;);let n=e;const l=i.length;for(;++nu.position{d.color[ie]=Math.round(G(k[ie],_e[ie],m))})}else["r","g","b"].forEach(h!==-1?m=>{d.color[m]=r[h][m]}:m=>{d.color[m]=r[y][m]})}}for(const u of r)i.push({color:u.color,position:u.position})}i[0].position=0,i[i.length-1].position=1;let n=0,l=1;for(let a=0;ai[l].position;)n=l++;const d=(u-i[n].position)/(i[l].position-i[n].position),h=i[n].color,y=i[l].color,m=new E;["r","g","b"].forEach(k=>{m[k]=Math.round(G(h[k],y[k],d))}),m.a=Y(1-G(h.a,y.a,d)/255,0,1),e.push(m)}return e}getColorForContinuousDataValue(e,i){const r=this.rasterizedTransferFunction;if(this.colorStops.length<2||!Array.isArray(this.stretchRange)||this.stretchRange.length<2||r.length<256)return null;let s=this.stretchRange[0],n=this.stretchRange[1];if(s>n){const a=s;s=n,n=a}e=Y(e,s,n);const l=r[Math.round((e-s)/(n-s)*(this._colorMapSize-1))].clone();return i||(l.a=1),l}};t([o({type:["linear","nearest"],json:{write:!0}})],N.prototype,"interpolation",void 0),t([o({type:[Number],json:{write:{enabled:!0,isRequired:!0}}})],N.prototype,"stretchRange",void 0),t([o({type:c.ofType(le),json:{write:{enabled:!0,overridePolicy(){return{enabled:!!this.colorStops&&this.colorStops.length>0}}}}})],N.prototype,"colorStops",null),t([o({type:c.ofType(ae),json:{read:{source:"alphaStops"},write:{enabled:!0,target:"alphaStops",overridePolicy(){return{enabled:!!this.opacityStops&&this.opacityStops.length>0}}}}})],N.prototype,"opacityStops",null),t([o({type:ut,json:{write:!0}})],N.prototype,"rangeFilter",void 0),t([o({type:[E],clonable:!1,json:{read:!1}})],N.prototype,"rasterizedTransferFunction",null),N=t([v("esri.layers.voxel.VoxelTransferFunctionStyle")],N);const ct=N;let _=class extends D(g){constructor(){super(...arguments),this.color=E.fromArray([0,0,0,0]),this.value=0,this.enabled=!0,this.label=""}};t([o({type:E,json:{type:[j],write:{enabled:!0,isRequired:!0}}})],_.prototype,"color",void 0),t([o({type:j,json:{write:{enabled:!0,isRequired:!0}}})],_.prototype,"value",void 0),t([o({type:Boolean,json:{default:!0,write:!0}})],_.prototype,"enabled",void 0),t([o({type:String,json:{write:!0}})],_.prototype,"label",void 0),_=t([v("esri.layers.voxel.VoxelUniqueValue")],_);const qe=_;var pe;let L=pe=class extends g{constructor(e){super(e),this.variableId=0,this.label="",this.transferFunction=null,this.uniqueValues=null,this.isosurfaces=null,this.uniqueValues=new(c.ofType(qe)),this.isosurfaces=new(c.ofType(Ae))}clone(){return new pe({variableId:this.variableId,label:this.label,transferFunction:X(this.transferFunction),uniqueValues:X(this.uniqueValues),isosurfaces:X(this.isosurfaces)})}};t([o({type:j,json:{write:{enabled:!0,isRequired:!0}}})],L.prototype,"variableId",void 0),t([o({type:String,json:{write:!0}})],L.prototype,"label",void 0),t([o({type:ct,json:{write:{enabled:!0,overridePolicy(){return{enabled:!this.uniqueValues||this.uniqueValues.length<1}}}}})],L.prototype,"transferFunction",void 0),t([o({type:c.ofType(qe),json:{write:{enabled:!0,overridePolicy(){return{enabled:!!this.uniqueValues&&this.uniqueValues.length>0}}}}})],L.prototype,"uniqueValues",void 0),t([o({type:c.ofType(Ae),json:{write:{enabled:!0,overridePolicy(){const e=!this.uniqueValues||this.uniqueValues.length<1,i=!!this.isosurfaces&&this.isosurfaces.length>0;return{enabled:e&&i}}}}})],L.prototype,"isosurfaces",void 0),L=pe=t([v("esri.layers.voxel.VoxelVariableStyle")],L);const De=L;let H=class extends g{constructor(){super(...arguments),this.values=null}};t([o({type:[Number],json:{write:!0}})],H.prototype,"values",void 0),H=t([v("esri.layers.voxel.VoxelIrregularSpacing")],H);const yt=H;let J=class extends g{constructor(){super(...arguments),this.scale=1,this.offset=0}};t([o({type:Number,json:{write:!0}})],J.prototype,"scale",void 0),t([o({type:Number,json:{write:!0}})],J.prototype,"offset",void 0),J=t([v("esri.layers.voxel.VoxelRegularSpacing")],J);const dt=J;let S=class extends g{constructor(){super(...arguments),this.irregularSpacing=null,this.isPositiveUp=!0,this.isWrappedDateLine=!1,this.label=null,this.name=null,this.quantity=null,this.regularSpacing=null,this.size=0,this.unit=null}get isRegular(){return(this.irregularSpacing==null||this.irregularSpacing===void 0)&&this.regularSpacing!==null}getRange(){var e;return this.isRegular?[this.regularSpacing.offset,this.regularSpacing.offset+this.regularSpacing.scale*(this.size-1)]:Array.isArray((e=this.irregularSpacing)==null?void 0:e.values)&&this.irregularSpacing.values.length>1?[this.irregularSpacing.values[0],this.irregularSpacing.values[this.irregularSpacing.values.length-1]]:[0,0]}};t([o({type:yt,json:{write:!0}})],S.prototype,"irregularSpacing",void 0),t([o({type:Boolean,json:{write:!0}})],S.prototype,"isPositiveUp",void 0),t([o({type:Boolean,json:{write:!0}})],S.prototype,"isWrappedDateLine",void 0),t([o({type:String,json:{write:!0}})],S.prototype,"label",void 0),t([o({type:String,json:{write:!0}})],S.prototype,"name",void 0),t([o({type:String,json:{write:!0}})],S.prototype,"quantity",void 0),t([o({type:dt,json:{write:!0}})],S.prototype,"regularSpacing",void 0),t([o({type:Number,json:{write:!0}})],S.prototype,"size",void 0),t([o({type:String,json:{write:!0}})],S.prototype,"unit",void 0),t([o({type:Boolean,json:{read:!1}})],S.prototype,"isRegular",null),S=t([v("esri.layers.voxel.VoxelDimension")],S);const ht=S,Te="esri.layers.voxel.VoxelVolume",xe=je.getLogger(Te);let x=class extends g{constructor(e){super(e),this.id=0,this.dimensions=null,this.spatialReference=$e.WGS84}get zDimension(){if(!this.dimensions||!Array.isArray(this.dimensions)||this.dimensions.length!==4)return-1;for(let e=2;e<4;++e)if(this.dimensions[e].size>0)return e;return-1}get isValid(){return!!this.dimensions&&!!Array.isArray(this.dimensions)&&this.dimensions.length===4&&!(this.dimensions[0].size<1||this.dimensions[1].size<1)&&!(this.zDimension===-1||this.dimensions[this.zDimension].size<1)}get originInLayerSpace3D(){if(!this.isValid||this.volumeType==="xyt")return[0,0,0];const e=this.dimensions[0].getRange(),i=this.dimensions[1].getRange(),r=this.dimensions[2],s=r.isRegular?r.getRange():[0,r.size];return[e[0],i[0],s[0]]}get voxelSizeInLayerSpaceSigned(){if(!this.isValid||this.volumeType==="xyt")return[0,0,0];const e=this.dimensions[0].getRange(),i=this.dimensions[1].getRange(),r=this.dimensions[2],s=r.isRegular?r.getRange():[0,r.size],n=[this.sizeInVoxels[0],this.sizeInVoxels[1],this.sizeInVoxels[2]];for(let l=0;l<3;++l)n[l]<2?n[l]=1:n[l]-=1;return r.isRegular&&!r.isPositiveUp&&(n[2]*=-1),[(e[1]-e[0])/n[0],(i[1]-i[0])/n[1],(s[1]-s[0])/n[2]]}get volumeType(){if(this.isValid){const e=this.dimensions[2].size>0,i=this.dimensions[3].size>0;if(!e&&i)return"xyt";if(e&&i)return"xyzt"}return"xyz"}get sizeInVoxels(){if(!this.isValid)return[0,0,0];const e=this.zDimension;return[this.dimensions[0].size,this.dimensions[1].size,this.dimensions[e].size]}computeVoxelSpaceLocation(e){var s,n,l;if(!this.isValid)return[0,0,0];if(this.volumeType==="xyt")return xe.error("computeVoxelSpacePosition cannot be used with XYT volumes."),[0,0,0];if(!Be(this.spatialReference,e.spatialReference))return xe.error("pos argument should have the same spatial reference as the VoxelLayer."),[0,0,0];const i=ze(e.x,e.y,(s=e.z)!=null?s:0);ke(i,i,this.originInLayerSpace3D),Ce(i,i,this.voxelSizeInLayerSpaceSigned);const r=this.dimensions[this.zDimension];if(!r.isRegular&&Array.isArray((n=r.irregularSpacing)==null?void 0:n.values)&&r.irregularSpacing.values.length>1){const a=(l=e.z)!=null?l:0,u=r.irregularSpacing.values,d=r.isPositiveUp?1:-1,h=u.reduce((y,m)=>Math.abs(d*m-a)$.normalize(z(e),0,!0))],A.prototype,"orientation",null),t([o({type:Number,json:{read:!1},clonable:!1,range:{min:0,max:360}}),K(e=>$.normalize(z(e),0,!0))],A.prototype,"tilt",null),t([o({type:[Number],json:{write:!0}})],A.prototype,"normal",void 0),t([o({type:[Number],json:{write:!0}})],A.prototype,"point",void 0),A=t([v("esri.layers.voxel.VoxelDynamicSection")],A);const ce=A;var ye;let q=ye=class extends g{constructor(e){super(e),this.volumeId=0,this.verticalExaggeration=1,this.exaggerationMode="scale-height",this.verticalOffset=0,this.slices=new(c.ofType(ee)),this.dynamicSections=new(c.ofType(ce))}set slices(e){this._set("slices",Q(e,this._get("slices"),c.ofType(ee)))}set dynamicSections(e){this._set("dynamicSections",Q(e,this._get("dynamicSections"),c.ofType(ce)))}clone(){return new ye({volumeId:this.volumeId,verticalExaggeration:this.verticalExaggeration,exaggerationMode:this.exaggerationMode,verticalOffset:this.verticalOffset,slices:X(this.slices),dynamicSections:X(this.dynamicSections)})}};t([o({type:j,json:{write:{enabled:!0,isRequired:!0}}})],q.prototype,"volumeId",void 0),t([o({type:Number,json:{default:1,write:!0}})],q.prototype,"verticalExaggeration",void 0),t([o({type:["scale-position","scale-height"],json:{default:"scale-height",write:!0}})],q.prototype,"exaggerationMode",void 0),t([o({type:Number,json:{default:0,write:!0}})],q.prototype,"verticalOffset",void 0),t([o({type:c.ofType(ee),json:{write:{enabled:!0,overridePolicy(){return{enabled:!!this.slices&&this.slices.length>0}}}}})],q.prototype,"slices",null),t([o({type:c.ofType(ce),json:{write:{enabled:!0,overridePolicy(){return{enabled:!!this.dynamicSections&&this.dynamicSections.length>0}}}}})],q.prototype,"dynamicSections",null),q=ye=t([v("esri.layers.voxel.VoxelVolumeStyle")],q);const Le=q,Me="esri.layers.VoxelLayer",M=je.getLogger(Me);let p=class extends rt(Je(Xe(Ye(Ge(He(Ke(ot))))))){constructor(e){super(e),this.serviceRoot="",this.popupEnabled=!0,this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=null,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.shading=new Ne,this.opacity=1,this.variables=new c,this.volumes=new c,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.fullExtent=null,this.volumeStyles=new(c.ofType(Le)),this.variableStyles=new(c.ofType(De)),this.sections=new(c.ofType(ne))}set url(e){this._set("url",Qe(e,M))}load(e){const i=T(e)?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(Ze).then(()=>this._fetchService(i)).then(()=>this.serviceRoot=this.url);return this.addResolvingPromise(r),Promise.resolve(this)}read(e,i){super.read(e,i);for(const r of this.volumes)r.spatialReference=this.spatialReference}readVersion(e,i){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new re("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new re("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new re("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}readFullExtent(e,i,r){if(e!=null&&typeof e=="object"){const s=Re.fromJSON(e,r);if(s.zmin===0&&s.zmax===0&&Array.isArray(i.volumes)){const n=Fe.fromJSON(i.volumes[0]);if(n.isValid&&n.volumeType!=="xyt"){const l=n.dimensions[2];if(l.isRegular){let a=l.regularSpacing.offset,u=l.regularSpacing.offset+l.regularSpacing.scale*(l.size-1);if(a>u){const d=a;a=u,u=d}s.zmin=a,s.zmax=u}}}return s}return null}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index.toJSON(),sections:this.getSections(),style:{volumeStyles:this.getVolumeStyles(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.getVariableStyles(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index.isValid()?JSON.stringify(e):""}getVariableStyle(e){let i=-1;if(i=T(e)?e:this.currentVariableId,!this.variableStyles||i===-1)return null;const r=this.variableStyles.findIndex(s=>s.variableId===i);return r<0?null:this.variableStyles.getItemAt(r)}getVariable(e){let i=-1;if(i=T(e)?e:this.currentVariableId,!this.variables||i===-1)return null;const r=this.variables.findIndex(s=>s.id===i);return r<0?null:this.variables.getItemAt(r)}getVolume(e){const i=this.getVariable(e);return T(i)?this.volumes.find(({id:r})=>r===i.volumeId):null}getVolumeStyle(e){const i=this.getVariable(e);return T(i)?this.volumeStyles.find(({volumeId:r})=>r===i.volumeId):null}getColorForContinuousDataValue(e,i,r){const s=this.getVariable(e);if(!T(s)||s.renderingFormat.continuity!=="continuous"||!this.variableStyles)return null;const n=this.variableStyles.findIndex(a=>a.variableId===e);if(n<0)return null;const l=this.variableStyles.getItemAt(n);return l.transferFunction?l.transferFunction.getColorForContinuousDataValue(i,r):null}getSections(){const e=[];for(const i of this.sections)e.push(new ne({enabled:i.enabled,href:i.href,id:i.id,label:i.label,normal:i.normal,point:i.point,sizeInPixel:i.sizeInPixel,slices:i.slices,timeId:i.timeId,variableId:i.variableId}));return e}getVariableStyles(){const e=[];for(const i of this.variableStyles){const r=this._getVariable(i);if(T(r)){const s=i.clone();s.isosurfaces.length>4&&(s.isosurfaces=s.isosurfaces.slice(0,3),M.error("A maximum of 4 isosurfaces are supported for Voxel Layers."));for(const n of s.isosurfaces)if(n.colorLocked){const l=this.getColorForContinuousDataValue(s.variableId,n.value,!1);l===null||l.equals(n.color)||(n.color=l)}if(r.renderingFormat.continuity==="continuous")(s.transferFunction===null||s.transferFunction.colorStops.length<2)&&M.error(`VoxelVariableStyle for variable ${r.id} is invalid. At least 2 color stops are required in the transferFunction for continuous Voxel Layer variables.`),s.transferFunction!==null&&(Array.isArray(s.transferFunction.stretchRange)&&s.transferFunction.stretchRange.length===2||(M.error(`VoxelVariableStyle for variable ${r.id} is invalid. The stretchRange of the transferFunction for continuous Voxel Layer variables must be of the form [minimumDataValue, maximumDataValue].`),s.transferFunction.stretchRange=[0,1],s.transferFunction.colorStops.removeAll()));else if(r.renderingFormat.continuity==="discrete")if(i.uniqueValues.length===0)M.error(`VoxelVariableStyle for variable ${r.id} is invalid. Unique values are required for discrete Voxel Layer variables.`);else for(const n of i.uniqueValues)n.label!==null&&n.label!==void 0||n.value===null||n.value===void 0||(n.label=n.value.toString());e.push(s)}else M.error(`VoxelVariable ID=${i.variableId} doesn't exist, VoxelVariableStyle for this VoxelVariable will be ignored.`)}return e}getVolumeStyles(){const e=[];for(const i of this.volumeStyles){const r=this._getVolumeFromVolumeId(i.volumeId);if(T(r)){const s=i.clone();for(const n of s.slices)this._isPlaneValid(n,[0,1,r.zDimension],r.dimensions)||(n.enabled=!1,n.label="invalid");for(const n of s.dynamicSections)this._isPlaneValid(n,[0,1,r.zDimension],r.dimensions)||(n.enabled=!1,n.label="invalid");e.push(s)}else M.error(`VoxelVolume ID=${i.volumeId} doesn't exist, VoxelVolumeStyle for this VoxelVolume will be ignored.`)}return e}_getVariable(e){const i=e.variableId;for(const r of this.variables)if(r.id===i)return r;return null}_getVolumeFromVolumeId(e){for(const i of this.volumes)if(i.id===e)return i;return null}_isPlaneValid(e,i,r){if(!e.point||!Array.isArray(e.point)||e.point.length!==3||!e.normal||!Array.isArray(e.normal)||e.normal.length!==3)return!1;for(let l=0;l<3;++l){const a=e.point[l];if(a<0||a>=r[i[l]].size)return!1}const s=ze(e.normal[0],e.normal[1],e.normal[2]);de(s,s);const n=1e-6;return!(Math.abs(s[0])+Math.abs(s[1])+Math.abs(s[2])