import{_ as p,$ as d,iv as mt,dN as dt,cK as yt,a0 as ee,cp as xe,jl as He,dM as Te,b1 as Qe,a as c,s as $,co as W,aY as _,hH as xt,kY as N,E as M,eb as Ee,al as he,a7 as D,hx as wt,kZ as vt,gL as $t,bV as bt,l as At,t as se,g as Me,fA as De,fI as et,fH as Ie,fP as tt,dZ as fe,fy as Tt,G as nt,fx as ge,h9 as Mt,fG as Ft,kO as rt,a5 as ot,Y as Rt,hW as Lt,cI as Ct,cE as Ot,R as _t,cA as Fe,ar as Et,ab as ve,cL as Dt,cJ as It}from"./index.6c049565.js";import{r as we,b as Pt,x as St,M as Pe,j as Se,a as je,O as Ne,h as ze,L as We,_ as jt,c as ae,v as Re,g as Le,d as Nt,e as ue,f as me}from"./georeference.11d1c93a.js";import{r as zt}from"./imageUtils.753f41b1.js";import{x as Wt}from"./earcut.afc1d357.js";import{n as kt}from"./deduplicate.b87c02b8.js";import{e as ke}from"./mat3f64.6d32a1d7.js";import{e as st}from"./mat4f64.ff2a477c.js";var Z;const $e=new WeakMap;let Ut=0,E=Z=class extends xe{constructor(e){super(e),this.wrap="repeat"}get url(){return this._get("url")||null}set url(e){this._set("url",e),e&&this._set("data",null)}get data(){return this._get("data")||null}set data(e){this._set("data",e),e&&this._set("url",null)}writeData(e,t,n,r){if(e instanceof HTMLImageElement){const o={type:"image-element",src:He(e.src,r),crossOrigin:e.crossOrigin};t[n]=o}else if(e instanceof HTMLCanvasElement){const o=e.getContext("2d").getImageData(0,0,e.width,e.height),a={type:"canvas-element",imageData:this._encodeImageData(o)};t[n]=a}else if(e instanceof HTMLVideoElement){const o={type:"video-element",src:He(e.src,r),autoplay:e.autoplay,loop:e.loop,muted:e.muted,crossOrigin:e.crossOrigin,preload:e.preload};t[n]=o}else{const o={type:"image-data",imageData:this._encodeImageData(e)};t[n]=o}}readData(e){switch(e.type){case"image-element":{const t=new Image;return t.src=e.src,t.crossOrigin=e.crossOrigin,t}case"canvas-element":{const t=this._decodeImageData(e.imageData),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,n.getContext("2d").putImageData(t,0,0),n}case"image-data":return this._decodeImageData(e.imageData);case"video-element":{const t=document.createElement("video");return t.src=e.src,t.crossOrigin=e.crossOrigin,t.autoplay=e.autoplay,t.loop=e.loop,t.muted=e.muted,t.preload=e.preload,t}default:return}}get transparent(){const e=this.data,t=this.url;if(e instanceof HTMLCanvasElement)return this._imageDataContainsTransparent(e.getContext("2d").getImageData(0,0,e.width,e.height));if(e instanceof ImageData)return this._imageDataContainsTransparent(e);if(t){const n=t.substr(t.length-4,4).toLowerCase(),r=t.substr(0,15).toLocaleLowerCase();if(n===".png"||r==="data:image/png;")return!0}return!1}set transparent(e){this._overrideIfSome("transparent",e)}get contentHash(){const e=typeof this.wrap=="string"?this.wrap:typeof this.wrap=="object"?`${this.wrap.horizontal}/${this.wrap.vertical}`:"",t=(n="")=>`d:${n},t:${this.transparent},w:${e}`;return this.url!=null?t(this.url):this.data!=null?this.data instanceof HTMLImageElement||this.data instanceof HTMLVideoElement?t(this.data.src):($e.has(this.data)||$e.set(this.data,++Ut),t($e.get(this.data))):t()}clone(){const e={url:this.url,data:this.data,wrap:this._cloneWrap()};return new Z(e)}cloneWithDeduplication(e){const t=e.get(this);if(t)return t;const n=this.clone();return e.set(this,n),n}_cloneWrap(){return typeof this.wrap=="string"?this.wrap:{horizontal:this.wrap.horizontal,vertical:this.wrap.vertical}}_encodeImageData(e){let t="";for(let n=0;ng-u),f=new Uint32Array(Wt(h,m,3));n.push({position:h,faces:f}),r+=h.length,o+=f.length}const a=Zt(n,r,o),s=kt(a.position.buffer,6,{originalIndices:a.faces});return a.position=new Float64Array(s.buffer),a.faces=s.indices,a}function Zt(e,t,n){if(e.length===1)return e[0];const r=new Float64Array(t),o=new Uint32Array(n);let a=0,s=0,i=0;for(const l of e){for(let u=0;u=0;g--){const y=e[g],R=n===de.CCW_IS_HOLE&&Jt(y);if(R&&r!==1)o[i++]=y;else{let v=y.length;for(let x=0;x0&&(s[u++]={index:f,count:y.length}),f=R?ie(y,y.length-1,-1,m,f,y.length,t):ie(y,0,1,m,f,y.length,t);for(let x=0;x0&&(s[u++]={index:f,count:A.length}),f=ie(A,0,1,m,f,A.length,t)}i=0,b.count>0&&(a[l++]=b)}}for(let g=0;g0&&(s[u++]={index:f,count:y.length}),f=ie(y,0,1,m,f,y.length,t)}return a.length=l,s.length=u,{position:m,polygons:a,outlines:s}}function ie(e,t,n,r,o,a,s){o*=3;for(let i=0;iimport("./loadGLTFMesh.92c8be7c.js"),["assets/loadGLTFMesh.92c8be7c.js","assets/index.6c049565.js","assets/index.cf071e35.css","assets/mat3f64.6d32a1d7.js","assets/BufferView.f5101c27.js","assets/vec33.9bd40b84.js","assets/DefaultMaterial_COLOR_GAMMA.54ecca40.js","assets/types.44c7402c.js","assets/mat4f64.ff2a477c.js","assets/enums.2d9e6f64.js","assets/quat.4f976512.js","assets/quatf64.4ae3e6f1.js","assets/georeference.11d1c93a.js","assets/imageUtils.753f41b1.js","assets/earcut.afc1d357.js","assets/deduplicate.b87c02b8.js"]),n),o=await lt(t,n),a=r(new D({x:0,y:0,z:0,spatialReference:e.spatialReference}),o.url,{resolveFile:on(o),useTransform:!0,signal:c(n)?n.signal:null});a.then(()=>o.dispose(),()=>o.dispose());const{vertexAttributes:s,components:i}=await a;e.vertexAttributes=s,e.components=i}function on(e){const t=wt(e.url);return n=>{var a;const r=vt(n,t,t),o=r?r.replace(/^ *\.\//,""):null;return(a=o?e.files.get(o):null)!=null?a:n}}async function lt(e,t){return e instanceof Blob?Q.fromBlob(e):typeof e=="string"?new Q(e):Array.isArray(e)?sn(e,t):an(e,t)}async function sn(e,t){const n=new Map;let r=null;const o=await $t(e.map(async s=>({name:s.name,source:await lt(s instanceof Blob?s:s.source,t)}))),a=[];for(const s of o)s&&(bt(t)?s.source.dispose():a.push(s));At(t);for(const{name:s,source:i}of a)(se(r)||/\.(gltf|glb)/i.test(s))&&(r=i.url),n.set(s,i.url),i.files&&i.files.forEach((l,u)=>n.set(u,l));if(se(r))throw new Me("mesh-load-external:missing-files","Missing files to load external mesh source");return new Q(r,()=>a.forEach(({source:s})=>s.dispose()),n)}async function an(e,t){const{default:n}=await Ee(he(()=>import("./index.6c049565.js").then(function(o){return o.l1}),["assets/index.6c049565.js","assets/index.cf071e35.css"]),t),r=typeof e.multipart[0]=="string"?await Promise.all(e.multipart.map(async o=>(await n(o,{responseType:"array-buffer"})).data)):e.multipart;return Q.fromBlob(new Blob(r))}class Q{constructor(t,n=()=>{},r=new Map){this.url=t,this.dispose=n,this.files=r}static fromBlob(t){const n=URL.createObjectURL(t);return new Q(n,()=>URL.revokeObjectURL(n))}}function ln(e,t,n){e.vertexAttributes&&e.vertexAttributes.position&&(c(e.transform)?((n==null?void 0:n.geographic)!=null&&n.geographic!==e.transform.geographic&&$.getLogger("esri.geometry.support.meshUtils.offset").warn(`Specifying the 'geographic' parameter (${n.geographic}) different from the Mesh transform setting (${e.transform.geographic}) is not supported`),cn(e.transform,t)):we(e.spatialReference,n)?un(e,t):pn(e,t))}function cn(e,t){const n=e.origin;e.origin=De(M(),n,t)}function un(e,t){const n=e.spatialReference,r=e.vertexAttributes.position,o=e.vertexAttributes.normal,a=e.vertexAttributes.tangent,s=new Float64Array(r.length),i=c(o)?new Float32Array(o.length):null,l=c(a)?new Float32Array(a.length):null,u=e.extent.center,h=hn;et(n,[u.x,u.y,u.z],Be,Ie(n)),tt(Ge,Be),fe(h,t,Ge),Pe(r,n,s),c(o)&&c(i)&&Se(o,r,s,n,i),c(a)&&c(l)&&je(a,r,s,n,l),ct(s,h),Ne(s,r,n),c(o)&&c(i)&&ze(i,r,s,n,o),c(a)&&c(l)&&We(l,r,s,n,a),e.vertexAttributesChanged()}function pn(e,t){ct(e.vertexAttributes.position,t),e.vertexAttributesChanged()}function ct(e,t){if(e)for(let n=0;n=a&&h=5-1,v=g===2||g===4,b=y?n-1:n;for(let x=0;x<=b;x++){const A=x/b*2*Math.PI,P=y?0:.5;w[0]=P*Math.sin(A),w[1]=P*-Math.cos(A),w[2]=g<=2?.5:-.5;for(let k=0;k<3;k++)o[l++]=w[k],a[u++]=R?k===2?g<=1?1:-1:0:k===2?0:w[k]/P;s[h++]=(x+(y?.5:0))/n,s[h++]=g<=1?1*g/3:g<=3?1*(g-2)/3+1/3:1*(g-4)/3+2/3,v||g===0||x===n||(g!==5&&(i[m++]=f,i[m++]=f+1,i[m++]=f-n),g!==1&&(i[m++]=f,i[m++]=f-n,i[m++]=f-n-1)),f++}}return{position:o,normal:a,uv:s,faces:i}}function yn(e,t){const n=typeof t=="number"?t:t!=null?t.width:1,r=typeof t=="number"?t:t!=null?t.height:1;switch(e){case"up":case"down":return{width:n,depth:r};case"north":case"south":return{width:n,height:r};case"east":case"west":return{depth:n,height:r}}}function xn(e){const t=ne.facingAxisOrderSwap[e],n=ne.position,r=ne.normal,o=new Float64Array(n.length),a=new Float32Array(r.length);let s=0;for(let i=0;i<4;i++){const l=s;for(let u=0;u<3;u++){const h=t[u],m=Math.abs(h)-1,f=h>=0?1:-1;o[s]=n[l+m]*f,a[s]=r[l+m]*f,s++}}return{position:o,normal:a,uv:new Float32Array(ne.uv),faces:new Uint32Array(ne.faces),isPlane:!0}}const H=1,B=2,G=3,ne={position:[-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0],normal:[0,0,1,0,0,1,0,0,1,0,0,1],uv:[0,1,1,1,1,0,0,0],faces:[0,1,2,0,2,3],facingAxisOrderSwap:{east:[G,H,B],west:[-G,-H,B],north:[-H,G,B],south:[H,-G,B],up:[H,B,G],down:[H,-B,-G]}};function le(e,t,n){e.isPlane||wn(e),vn(e,n==null?void 0:n.size);const{vertexAttributes:r,transform:o}=jt(e,t,n);return{vertexAttributes:new T({...r,uv:e.uv}),transform:o,components:[new q({faces:e.faces,material:n&&n.material||null})],spatialReference:t.spatialReference}}function wn(e){for(let t=0;t{this.handles.add(_t(()=>{var e;return{vertexAttributes:this.vertexAttributes,components:(e=this.components)==null?void 0:e.map(t=>t.clone())}},()=>this._set("external",null),{once:!0,sync:!0}))})}get hasExtent(){return!this.loaded&&c(this.external)&&c(this.external.extent)||this.loaded&&this.vertexAttributes.position.length>0&&(!this.components||this.components.length>0)}get _boundingInfo(){const e=this.vertexAttributes.position,t=this.spatialReference;if(e.length===0||this.components&&this.components.length===0)return{extent:new Fe({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0,spatialReference:t}),center:new D({x:0,y:0,z:0,spatialReference:t})};const n=c(this.transform)?this.transform.project(e,t):e;let r=1/0,o=1/0,a=1/0,s=-1/0,i=-1/0,l=-1/0,u=0,h=0,m=0;const f=n.length,g=1/(f/3);let y=0;for(;yo.cloneWithDeduplication(n,r))}const t={components:e,spatialReference:this.spatialReference,vertexAttributes:this.vertexAttributes.clone(),transform:c(this.transform)?this.transform.clone():null,external:c(this.external)?{source:this.external.source,extent:c(this.external.extent)?this.external.extent.clone():null}:null};return new O(t)}vertexAttributesChanged(){this.notifyChange("vertexAttributes")}async toBinaryGLTF(e){const t=he(()=>import("./gltfexport.2da147f8.js"),["assets/gltfexport.2da147f8.js","assets/index.6c049565.js","assets/index.cf071e35.css","assets/quat.4f976512.js","assets/mat3f64.6d32a1d7.js","assets/quatf64.4ae3e6f1.js","assets/georeference.11d1c93a.js","assets/mat4f64.ff2a477c.js","assets/BufferView.f5101c27.js","assets/vec33.9bd40b84.js","assets/enums.2d9e6f64.js","assets/imageutils.2ce8d042.js","assets/imageUtils.753f41b1.js","assets/earcut.afc1d357.js","assets/deduplicate.b87c02b8.js"]),n=this.load(),r=await Promise.all([t,n]),{toBinaryGLTF:o}=r[0];return o(this,e)}static createBox(e,t){if(!(e instanceof D))return $.getLogger(z).error(".createBox()","expected location to be a Point instance"),null;const n=new O(le(fn(),e,t));return t&&t.imageFace&&t.imageFace!=="all"?gn(n,t.imageFace):n}static createSphere(e,t){return e instanceof D?new O(le(mn(t&&t.densificationFactor||0),e,t)):($.getLogger(z).error(".createSphere()","expected location to be a Point instance"),null)}static createCylinder(e,t){return e instanceof D?new O(le(dn(t&&t.densificationFactor||0),e,t)):($.getLogger(z).error(".createCylinder()","expected location to be a Point instance"),null)}static createPlane(e,t){var o;if(!(e instanceof D))return $.getLogger(z).error(".createPlane()","expected location to be a Point instance"),null;const n=(o=t==null?void 0:t.facing)!=null?o:"up",r=yn(n,t==null?void 0:t.size);return new O(le(xn(n),e,{...t,size:r}))}static createFromPolygon(e,t){var r;if(!(e instanceof Et))return $.getLogger(z).error(".createFromPolygon()","expected polygon to be a Polygon instance"),null;const n=Vt(e);return new O({vertexAttributes:new T({position:n.position}),components:[new q({faces:n.faces,shading:"flat",material:(r=t==null?void 0:t.material)!=null?r:null})],spatialReference:e.spatialReference})}static async createFromGLTF(e,t,n){if(!(e instanceof D))throw $.getLogger(z).error(".createfromGLTF()","expected location to be a Point instance"),new Me("invalid-input","Expected location to be a Point instance");const{loadGLTFMesh:r}=await Ee(he(()=>import("./loadGLTFMesh.92c8be7c.js"),["assets/loadGLTFMesh.92c8be7c.js","assets/index.6c049565.js","assets/index.cf071e35.css","assets/mat3f64.6d32a1d7.js","assets/BufferView.f5101c27.js","assets/vec33.9bd40b84.js","assets/DefaultMaterial_COLOR_GAMMA.54ecca40.js","assets/types.44c7402c.js","assets/mat4f64.ff2a477c.js","assets/enums.2d9e6f64.js","assets/quat.4f976512.js","assets/quatf64.4ae3e6f1.js","assets/georeference.11d1c93a.js","assets/imageUtils.753f41b1.js","assets/earcut.afc1d357.js","assets/deduplicate.b87c02b8.js"]),n);return new O(await r(e,t,n))}static createWithExternalSource(e,t,n){var s,i,l,u;const r=(s=n==null?void 0:n.extent)!=null?s:null,o=(l=(i=n==null?void 0:n.transform)==null?void 0:i.clone())!=null?l:new me;o.origin=[e.x,e.y,(u=e.z)!=null?u:0];const a=e.spatialReference;return new O({external:{source:t,extent:r},transform:o,spatialReference:a})}static createIncomplete(e,t){var a,s,i;const n=(s=(a=t==null?void 0:t.transform)==null?void 0:a.clone())!=null?s:new me;n.origin=[e.x,e.y,(i=e.z)!=null?i:0];const r=e.spatialReference,o=new O({transform:n,spatialReference:r});return o.addResolvingPromise(Promise.reject(new Me("mesh-incomplete","Mesh resources are not complete"))),o}};p([d({type:[q],json:{write:!0}})],F.prototype,"components",void 0),p([d({type:me,json:{write:!0}})],F.prototype,"transform",void 0),p([d({constructOnly:!0})],F.prototype,"external",void 0),p([d({readOnly:!0})],F.prototype,"hasExtent",null),p([d({readOnly:!0})],F.prototype,"_boundingInfo",null),p([d({readOnly:!0})],F.prototype,"anchor",null),p([d({readOnly:!0})],F.prototype,"origin",null),p([d({readOnly:!0,json:{read:!1}})],F.prototype,"extent",null),p([d({readOnly:!0,json:{read:!1,write:!0,default:!0}})],F.prototype,"hasZ",void 0),p([d({readOnly:!0,json:{read:!1,write:!0,default:!1}})],F.prototype,"hasM",void 0),p([d({type:T,nonNullable:!0,json:{write:!0}})],F.prototype,"vertexAttributes",void 0),F=O=p([ee(z)],F);const Ae={x:ve(1,0,0),y:ve(0,1,0),z:ve(0,0,1)},V=ae(),Xe=ae(),Ke=ae(),ce=M(),qe=F;function _n(e,t,n){const r=n.features;n.features=[],delete n.geometryType;const o=Dt.fromJSON(n);if(o.geometryType="mesh",!n.assetMaps)return o;const a=Sn(t,n.assetMaps),s=o.spatialReference,i=n.globalIdFieldName,l=se(e.outFields)||!e.outFields.length?()=>({}):En(e.outFields.includes("*")?null:new Set(e.outFields));for(const u of r){const h=Dn(u,i,s,t,a);c(h)&&o.features.push(new It({geometry:h,attributes:l(u)}))}return o}function En(e){return({attributes:t})=>{if(!t)return{};if(!e)return t;for(const n in t)e.has(n)||delete t[n];return t}}function Dn(e,t,n,r,o){const a=e.attributes[t],s=o.get(a);if(s==null||s.status===j.FAILED||s.url==null)return null;const i=In(e,n,r),l=Fe.fromJSON(e.geometry);l.spatialReference=n;const u=Pn(e.attributes,r,s.geographic);return s.status===j.PENDING?qe.createIncomplete(i,{extent:l,transform:u}):qe.createWithExternalSource(i,[{name:s.name,source:s.url}],{extent:l,transform:u})}function In({attributes:e},t,{transformFieldRoles:n}){return new D({x:e[n.originX],y:e[n.originY],z:e[n.originZ],spatialReference:t})}function Pn(e,{transformFieldRoles:t},n){return new me({translation:[e[t.translationX],e[t.translationY],e[t.translationZ]],rotation:ue([e[t.rotationX],e[t.rotationY],e[t.rotationZ]],e[t.rotationDeg]),scale:[e[t.scaleX],e[t.scaleY],e[t.scaleZ]],geographic:n})}var j;function Sn(e,t){const n=new Map;for(const r of t){const o=r.parentGlobalId;if(o==null)continue;const a=r.assetName,s=r.assetURL,i=r.conversionStatus;let l=n.get(o);if(l!=null)throw new Error("multiple asset parts not expected.");switch(l={name:a,status:j.FAILED,url:s,geographic:jn(r.flags).projectVertices},n.set(o,l),i){case"COMPLETED":case"SUBMITTED":l.status=j.COMPLETED;break;case"INPROGRESS":l.status=j.PENDING;break;default:l.status=j.FAILED}}return n}function jn(e){return{projectVertices:e.includes("PROJECT_VERTICES")}}(function(e){e[e.FAILED=0]="FAILED",e[e.PENDING=1]="PENDING",e[e.COMPLETED=2]="COMPLETED"})(j||(j={}));var Gn=Object.freeze(Object.defineProperty({__proto__:null,meshFeatureSetFromJSON:_n},Symbol.toStringTag,{value:"Module"}));export{Gn as a,Ht as c,q as g,oe as m,T as p};