/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
class t{static{this.HEADER_SIZE=12}static{this.CHUNK_HEADER_SIZE=8}static{this.MAGIC=1179937895}static{this.VERSION=2}constructor(e,h){if(!e)throw new Error("GLB requires a JSON gltf chunk");this._length=t.HEADER_SIZE,this._length+=t.CHUNK_HEADER_SIZE;const s=i(e);if(this._length+=n(s.byteLength,4),h&&(this._length+=t.CHUNK_HEADER_SIZE,this._length+=h.byteLength,h.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 r=this._writeChunk(s,12,1313821514,32);h&&this._writeChunk(h,r,5130562)}_writeHeader(){this._outView.setUint32(0,t.MAGIC,!0),this._outView.setUint32(4,t.VERSION,!0),this._outView.setUint32(8,this._length,!0)}_writeChunk(t,i,h,s=0){const r=n(t.byteLength,4);for(this._outView.setUint32(i,r,!0),this._outView.setUint32(i+=4,h,!0),e(this._outView.buffer,t,i+=4,0,t.byteLength),i+=t.byteLength;i%4;)s&&this._outView.setUint8(i,s),i++;return i}}function e(t,e,i,n,h){new Uint8Array(t,i,h).set(new Uint8Array(e,n,h),0)}function i(t){return(new TextEncoder).encode(t).buffer}function n(t,e){return e*Math.ceil(t/e)}export{t as GLB};
