/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../core/promiseUtils","../../../../Point","./glb","./gltf","./types","./imageutils","./asset","./scene","./node"],(function(e,t,r,u,n,p,o,a,i,f){"use strict";const s="model.gltf",y="model.glb";function c(e,a,i){a=a||{};const f=new n.GLTF(e,a,i);let c=f.params;c?c.origin||(c.origin=new r({x:-1,y:-1,z:-1})):c={origin:new r({x:-1,y:-1,z:-1})};const l=c.origin,g=f.gltf,d=g.extras.promises;let O=1,b=1,m=null;return t.eachAlways(d).then((()=>{const e={origin:l};delete g.extras;const t="number"==typeof a.jsonSpacing?a.jsonSpacing:4,r=JSON.stringify(g,((t,r)=>{if("extras"!==t){if(r instanceof ArrayBuffer){if(o.isArrayBufferPNG(r))switch(a.imageOutputType){case p.ImageOutputType.DataURI:case p.ImageOutputType.GLB:break;case p.ImageOutputType.External:default:{const t=`img${b}.png`;return b++,e[t]=r,t}}switch(a.bufferOutputType){case p.BufferOutputType.DataURI:return o.encodeBase64DataUri(r);case p.BufferOutputType.GLB:if(m)throw new Error("Already encountered an ArrayBuffer, there should only be one in the GLB format.");return void(m=r);case p.BufferOutputType.External:default:{const t=`data${O}.bin`;return O++,e[t]=r,t}}}return r}}),t);return a.bufferOutputType===p.BufferOutputType.GLB||a.imageOutputType===p.ImageOutputType.GLB?e[y]=new u.GLB(r,m).buffer:e[s]=r,e}))}function l(e,t){return c(e,{bufferOutputType:p.BufferOutputType.GLB,imageOutputType:p.ImageOutputType.GLB,jsonSpacing:0},t)}Object.defineProperty(e,"AlphaMode",{enumerable:!0,get:()=>p.AlphaMode}),Object.defineProperty(e,"AttributeType",{enumerable:!0,get:()=>p.AttributeType}),Object.defineProperty(e,"BufferOutputType",{enumerable:!0,get:()=>p.BufferOutputType}),Object.defineProperty(e,"ColorMode",{enumerable:!0,get:()=>p.ColorMode}),Object.defineProperty(e,"ImageOutputType",{enumerable:!0,get:()=>p.ImageOutputType}),Object.defineProperty(e,"MeshMode",{enumerable:!0,get:()=>p.MeshMode}),e.Asset=a.Asset,e.Scene=i.Scene,e.Node=f.Node,e.MODEL_NAME_GLB=y,e.MODEL_NAME_GLTF=s,e.exportGLB=l,e.exportGLTF=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
