/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../Graphic","../../core/maybe","../../geometry/Extent","../../geometry/Mesh","../../geometry/Point","../../geometry/support/axisAngleDegrees","../../geometry/support/MeshTransform","../../layers/support/infoFor3D","./FeatureSet"],(function(e,t,s,r,n,o,a,i,u,l){"use strict";function c(e,r,n){const o=n.features;n.features=[],delete n.geometryType;const a=l.fromJSON(n);a.geometryType="mesh";const i=a.spatialReference,u=s.isNone(e.outFields)||!e.outFields.length?()=>({}):f(e.outFields.includes("*")?null:new Set(e.outFields));for(const l of o){const e=p(l,i,r);s.isSome(e)&&a.features.push(new t({geometry:e,attributes:u(l)}))}return a}function f(e){return({attributes:t})=>{if(!t)return{};if(!e)return t;for(const s in t)e.has(s)||delete t[s];return t}}function p(e,t,s){const{status:o,source:a}=E(e);if(o===F.FAILED)return null;const i=m(e,t,s),u=r.fromJSON(e.geometry);u.spatialReference=t;const l=g(e,s);return o===F.PENDING?n.createIncomplete(i,{extent:u,transform:l}):n.createWithExternalSource(i,a,{extent:u,transform:l})}function m({attributes:e},t,{transformFieldRoles:s}){return new o({x:e[s.originX],y:e[s.originY],z:e[s.originZ],spatialReference:t})}function g({attributes:e,assetMappings:t},{transformFieldRoles:s}){var r;return new i({translation:[e[s.translationX],e[s.translationY],e[s.translationZ]],rotation:a.fromAxisAndAngle([e[s.rotationX],e[s.rotationY],e[s.rotationZ]],e[s.rotationDeg]),scale:[e[s.scaleX],e[s.scaleY],e[s.scaleZ]],geographic:!(null!=(r=t[u.AssetMapFieldRole.flags])&&r.includes("PROJECT_VERTICES"))})}function E(e){if(!e.assetMappings)return{status:F.FAILED};const t=[],s=new Map;for(const r of e.assetMappings){const e=r[u.AssetMapFieldRole.seqNo],n=r[u.AssetMapFieldRole.assetName],o=r[u.AssetMapFieldRole.assetURL],a=r[u.AssetMapFieldRole.conversionStatus];if(a===u.Status.FAILED)return{status:F.FAILED};if(a!==u.Status.COMPLETED)return{status:F.PENDING};if(null==e)t.push({name:n,source:o});else{const r=s.get(n);let a;r?a=r.multipart:(a=[],t.push({name:n,source:{multipart:a}}),s.set(n,{multipart:a})),a[e]=o}}return{status:F.COMPLETED,source:t}}var F;!function(e){e[e.FAILED=0]="FAILED",e[e.PENDING=1]="PENDING",e[e.COMPLETED=2]="COMPLETED"}(F||(F={})),e.meshFeatureSetFromJSON=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
