/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports"],(function(t){"use strict";var e;!function(t){t[t.JSON=1313821514]="JSON",t[t.BIN=5130562]="BIN"}(e||(e={}));let i=function(){function t(i,n){if(!i)throw new Error("GLB requires a JSON gltf chunk");this.length=t.HEADER_SIZE,this.length+=t.CHUNK_HEADER_SIZE;const r=this._textToArrayBuffer(i);if(this.length+=this._alignTo(r.byteLength,4),n&&(this.length+=t.CHUNK_HEADER_SIZE,this.length+=n.byteLength,n.byteLength%4))throw new Error("Expected BIN chunk length to be divisible by 4 at this point");this.buffer=new ArrayBuffer(this.length),this.outView=new DataView(this.buffer),this._writeHeader();const h=this._writeChunk(r,12,e.JSON,32);n&&this._writeChunk(n,h,e.BIN)}var i=t.prototype;return i._writeHeader=function(){this.outView.setUint32(0,t.MAGIC,!0),this.outView.setUint32(4,t.VERSION,!0),this.outView.setUint32(8,this.length,!0)},i._writeChunk=function(t,e,i,n=0){const r=this._alignTo(t.byteLength,4);for(this.outView.setUint32(e,r,!0),this.outView.setUint32(e+=4,i,!0),this._writeArrayBuffer(this.outView.buffer,t,e+=4,0,t.byteLength),e+=t.byteLength;e%4;)n&&this.outView.setUint8(e,n),e++;return e},i._writeArrayBuffer=function(t,e,i,n,r){new Uint8Array(t,i,r).set(new Uint8Array(e,n,r),0)},i._textToArrayBuffer=function(t){return(new TextEncoder).encode(t).buffer},i._alignTo=function(t,e){return e*Math.ceil(t/e)},t}();i.HEADER_SIZE=12,i.CHUNK_HEADER_SIZE=8,i.MAGIC=1179937895,i.VERSION=2,t.GLB=i,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
