"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[8790],{78790(e,t,a){a.r(t),a.d(t,{AIFFParser:()=>k});var s=a(4017),i=a(17833),n=a(10718),r=a(80400),o=a(5031),h=a(74604),m=a(63324);const c={NONE:"not compressed\tPCM\tApple Computer",sowt:"PCM (byte swapped)",fl32:"32-bit floating point IEEE 32-bit float",fl64:"64-bit floating point IEEE 64-bit float\tApple Computer",alaw:"ALaw 2:1\t8-bit ITU-T G.711 A-law",ulaw:"µLaw 2:1\t8-bit ITU-T G.711 µ-law\tApple Computer",ULAW:"CCITT G.711 u-law 8-bit ITU-T G.711 µ-law",ALAW:"CCITT G.711 A-law 8-bit ITU-T G.711 A-law",FL32:"Float 32\tIEEE 32-bit float "};class l extends((0,m.fO)("AIFF")){}class p{constructor(e,t){this.isAifc=t;const a=t?22:18;if(e.chunkSize<a)throw new l(`COMMON CHUNK size should always be at least ${a}`);this.len=e.chunkSize}get(e,t){const a=s.UINT16_BE.get(e,t+8)-16398,i=s.UINT16_BE.get(e,t+8+2),n={numChannels:s.UINT16_BE.get(e,t),numSampleFrames:s.UINT32_BE.get(e,t+2),sampleSize:s.UINT16_BE.get(e,t+6),sampleRate:a<0?i>>Math.abs(a):i<<a};if(this.isAifc){if(n.compressionType=o.e.get(e,t+18),this.len>22){const a=s.UINT8.get(e,t+22);if(a>0){if(23+a+(a+1)%2!==this.len)throw new l("Illegal pstring length");n.compressionName=new s.StringType(a,"latin1").get(e,t+23)}else n.compressionName=void 0}}else n.compressionName="PCM";return n}}const u={len:8,get:(e,t)=>({chunkID:o.e.get(e,t),chunkSize:Number(BigInt(s.UINT32_BE.get(e,t+4)))})},d=i("music-metadata:parser:aiff");class k extends h.s{constructor(){super(...arguments),this.isCompressed=null}async parse(){if("FORM"!==(await this.tokenizer.readToken(u)).chunkID)throw new l("Invalid Chunk-ID, expected 'FORM'");const e=await this.tokenizer.readToken(o.e);switch(e){case"AIFF":this.metadata.setFormat("container",e),this.isCompressed=!1;break;case"AIFC":this.metadata.setFormat("container","AIFF-C"),this.isCompressed=!0;break;default:throw new l(`Unsupported AIFF type: ${e}`)}this.metadata.setFormat("lossless",!this.isCompressed),this.metadata.setAudioOnly();try{for(;!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=u.len;){d(`Reading AIFF chunk at offset=${this.tokenizer.position}`);const e=await this.tokenizer.readToken(u),t=2*Math.round(e.chunkSize/2),a=await this.readData(e);await this.tokenizer.ignore(t-a)}}catch(e){if(!(e instanceof n.d1))throw e;d("End-of-stream")}}async readData(e){switch(e.chunkID){case"COMM":{if(null===this.isCompressed)throw new l("Failed to parse AIFF.COMM chunk when compression type is unknown");const t=await this.tokenizer.readToken(new p(e,this.isCompressed));return this.metadata.setFormat("bitsPerSample",t.sampleSize),this.metadata.setFormat("sampleRate",t.sampleRate),this.metadata.setFormat("numberOfChannels",t.numChannels),this.metadata.setFormat("numberOfSamples",t.numSampleFrames),this.metadata.setFormat("duration",t.numSampleFrames/t.sampleRate),(t.compressionName||t.compressionType)&&this.metadata.setFormat("codec",t.compressionName??c[t.compressionType]),e.chunkSize}case"ID3 ":{const t=await this.tokenizer.readToken(new s.Uint8ArrayType(e.chunkSize)),a=n.vY(t);return await(new r.S).parse(this.metadata,a,this.options),e.chunkSize}case"SSND":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*e.chunkSize/this.metadata.format.duration),0;case"NAME":case"AUTH":case"(c) ":case"ANNO":return this.readTextChunk(e);default:return d(`Ignore chunk id=${e.chunkID}, size=${e.chunkSize}`),0}}async readTextChunk(e){const t=(await this.tokenizer.readToken(new s.StringType(e.chunkSize,"ascii"))).split("\0").map(e=>e.trim()).filter(e=>e?.length);return await Promise.all(t.map(t=>this.metadata.addTag("AIFF",e.chunkID,t))),e.chunkSize}}}}]);
//# sourceMappingURL=8790.c92e30e08632e5c366f4.js.map