0&&g.bitrate_table[t][r]==e)return r;return -1}function P(e,t){e.lowerlimit=[new E(8,2e3),new E(16,3700),new E(24,3900),new E(32,5500),new E(40,7e3),new E(48,7500),new E(56,1e4),new E(64,11e3),new E(80,13500),new E(96,15100),new E(112,15600),new E(128,17e3),new E(160,17500),new E(192,18600),new E(224,19400),new E(256,19700),new E(320,20500)][R.nearestBitrateFullIndex(t)].lowpass}function I(e){var t=v.BLKSIZE+e.framesize-v.FFTOFFSET;return t=Math.max(t,512+e.framesize-32),u(p.MFSIZE>=t),t}function C(){this.n_in=0,this.n_out=0}function q(){this.num_used=0}this.enc=new v,this.setModules=function(s,n,i,o,l,c,u,_,d){e=s,t=n,a=i,r=o,w=l,y=c,S=_,A=d,this.enc.setModules(t,M,r,y)},this.lame_init=function(){var e,t=new d;return t.class_id=0xfff88e3b,e=t.internal_flags=new p,t.mode=MPEGMode.NOT_SET,t.original=1,t.in_samplerate=44100,t.num_channels=2,t.num_samples=-1,t.bWriteVbrTag=!0,t.quality=-1,t.short_blocks=null,e.subblock_gain=-1,t.lowpassfreq=0,t.highpassfreq=0,t.lowpasswidth=-1,t.highpasswidth=-1,t.VBR=n.vbr_off,t.VBR_q=4,t.ATHcurve=-1,t.VBR_mean_bitrate_kbps=128,t.VBR_min_bitrate_kbps=0,t.VBR_max_bitrate_kbps=0,t.VBR_hard_min=0,e.VBR_min_bitrate=1,e.VBR_max_bitrate=13,t.quant_comp=-1,t.quant_comp_short=-1,t.msfix=-1,e.resample_ratio=1,e.OldValue[0]=180,e.OldValue[1]=180,e.CurrentStep[0]=4,e.CurrentStep[1]=4,e.masking_lower=1,e.nsPsy.attackthre=-1,e.nsPsy.attackthre_s=-1,t.scale=-1,t.athaa_type=-1,t.ATHtype=-1,t.athaa_loudapprox=-1,t.athaa_sensitivity=0,t.useTemporal=null,t.interChRatio=-1,e.mf_samples_to_encode=v.ENCDELAY+v.POSTDELAY,t.encoder_padding=0,e.mf_size=v.ENCDELAY-v.MDCTDELAY,t.findReplayGain=!1,t.decode_on_the_fly=!1,e.decode_on_the_fly=!1,e.findReplayGain=!1,e.findPeakSample=!1,e.RadioGain=0,e.AudiophileGain=0,e.noclipGainChange=0,e.noclipScale=-1,t.preset=0,t.write_id3tag_automatic=!0,t.lame_allocated_gfp=1,t},this.nearestBitrateFullIndex=function(e){var t=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],a=0,r=0,s=0,n=0;n=t[16],s=16,r=t[16],a=16;for(var i=0;i<16;i++)if(Math.max(e,t[i+1])!=e){n=t[i+1],s=i+1,r=t[i],a=i;break}return n-e>e-r?a:s},this.lame_init_params=function(o){var c,d,p,x,R,E,I=o.internal_flags;if(I.Class_ID=0,null==I.ATH&&(I.ATH=new f),null==I.PSY&&(I.PSY=new k),null==I.rgdata&&(I.rgdata=new h),I.channels_in=o.num_channels,1==I.channels_in&&(o.mode=MPEGMode.MONO),I.channels_out=o.mode==MPEGMode.MONO?1:2,I.mode_ext=v.MPG_MD_MS_LR,o.mode==MPEGMode.MONO&&(o.force_ms=!1),o.VBR==n.vbr_off&&128!=o.VBR_mean_bitrate_kbps&&0==o.brate&&(o.brate=o.VBR_mean_bitrate_kbps),o.VBR==n.vbr_off||o.VBR==n.vbr_mtrh||o.VBR==n.vbr_mt||(o.free_format=!1),o.VBR==n.vbr_off&&0==o.brate&&b.EQ(o.compression_ratio,0)&&(o.compression_ratio=11.025),o.VBR==n.vbr_off&&o.compression_ratio>0&&(0==o.out_samplerate&&(o.out_samplerate=map2MP3Frequency(int(.97*o.in_samplerate))),o.brate=0|16*o.out_samplerate*I.channels_out/(1e3*o.compression_ratio),I.samplerate_index=T(o.out_samplerate,o),o.free_format||(o.brate=j(o.brate,o.version,o.out_samplerate))),0!=o.out_samplerate&&(o.out_samplerate<16e3?(o.VBR_mean_bitrate_kbps=Math.max(o.VBR_mean_bitrate_kbps,8),o.VBR_mean_bitrate_kbps=Math.min(o.VBR_mean_bitrate_kbps,64)):o.out_samplerate<32e3?(o.VBR_mean_bitrate_kbps=Math.max(o.VBR_mean_bitrate_kbps,8),o.VBR_mean_bitrate_kbps=Math.min(o.VBR_mean_bitrate_kbps,160)):(o.VBR_mean_bitrate_kbps=Math.max(o.VBR_mean_bitrate_kbps,32),o.VBR_mean_bitrate_kbps=Math.min(o.VBR_mean_bitrate_kbps,320))),0==o.lowpassfreq){var C=16e3;switch(o.VBR){case n.vbr_off:var q=new B;P(q,o.brate),C=q.lowerlimit;break;case n.vbr_abr:var q=new B;P(q,o.VBR_mean_bitrate_kbps),C=q.lowerlimit;break;case n.vbr_rh:var D=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=o.VBR_q&&o.VBR_q<=9){var O=D[o.VBR_q],V=D[o.VBR_q+1],H=o.VBR_q_frac;C=linear_int(O,V,H)}else C=19500;break;default:var D=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=o.VBR_q&&o.VBR_q<=9){var O=D[o.VBR_q],V=D[o.VBR_q+1],H=o.VBR_q_frac;C=linear_int(O,V,H)}else C=19500}o.mode==MPEGMode.MONO&&(o.VBR==n.vbr_off||o.VBR==n.vbr_abr)&&(C*=1.5),o.lowpassfreq=0|C}if(0==o.out_samplerate&&(2*o.lowpassfreq>o.in_samplerate&&(o.lowpassfreq=o.in_samplerate/2),c=0|o.lowpassfreq,d=o.in_samplerate,p=44100,d>=48e3?p=48e3:d>=44100?p=44100:d>=32e3?p=32e3:d>=24e3?p=24e3:d>=22050?p=22050:d>=16e3?p=16e3:d>=12e3?p=12e3:d>=11025?p=11025:d>=8e3&&(p=8e3),o.out_samplerate=-1==c?p:(c<=15960&&(p=44100),c<=15250&&(p=32e3),c<=11220&&(p=24e3),c<=9970&&(p=22050),c<=7230&&(p=16e3),c<=5420&&(p=12e3),c<=4510&&(p=11025),c<=3970&&(p=8e3),d44100?48e3:d>32e3?44100:d>24e3?32e3:d>22050?24e3:d>16e3?22050:d>12e3?16e3:d>11025?12e3:d>8e3?11025:8e3:p),o.lowpassfreq=Math.min(20500,o.lowpassfreq),o.lowpassfreq=Math.min(o.out_samplerate/2,o.lowpassfreq),o.VBR==n.vbr_off&&(o.compression_ratio=16*o.out_samplerate*I.channels_out/(1e3*o.brate)),o.VBR==n.vbr_abr&&(o.compression_ratio=16*o.out_samplerate*I.channels_out/(1e3*o.VBR_mean_bitrate_kbps)),o.bWriteVbrTag||(o.findReplayGain=!1,o.decode_on_the_fly=!1,I.findPeakSample=!1),I.findReplayGain=o.findReplayGain,I.decode_on_the_fly=o.decode_on_the_fly,I.decode_on_the_fly&&(I.findPeakSample=!0),I.findReplayGain&&e.InitGainAnalysis(I.rgdata,o.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return o.internal_flags=null,-6;switch(I.decode_on_the_fly&&!o.decode_only&&(null!=I.hip&&A.hip_decode_exit(I.hip),I.hip=A.hip_decode_init()),I.mode_gr=o.out_samplerate<=24e3?1:2,o.framesize=576*I.mode_gr,o.encoder_delay=v.ENCDELAY,I.resample_ratio=o.in_samplerate/o.out_samplerate,o.VBR){case n.vbr_mt:case n.vbr_rh:case n.vbr_mtrh:o.compression_ratio=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5][o.VBR_q];break;case n.vbr_abr:o.compression_ratio=16*o.out_samplerate*I.channels_out/(1e3*o.VBR_mean_bitrate_kbps);break;default:o.compression_ratio=16*o.out_samplerate*I.channels_out/(1e3*o.brate)}if(o.mode==MPEGMode.NOT_SET&&(o.mode=MPEGMode.JOINT_STEREO),o.highpassfreq>0?(I.highpass1=2*o.highpassfreq,o.highpasswidth>=0?I.highpass2=2*(o.highpassfreq+o.highpasswidth):I.highpass2=2*o.highpassfreq,I.highpass1/=o.out_samplerate,I.highpass2/=o.out_samplerate):(I.highpass1=0,I.highpass2=0),o.lowpassfreq>0?(I.lowpass2=2*o.lowpassfreq,o.lowpasswidth>=0?(I.lowpass1=2*(o.lowpassfreq-o.lowpasswidth),I.lowpass1<0&&(I.lowpass1=0)):I.lowpass1=2*o.lowpassfreq,I.lowpass1/=o.out_samplerate,I.lowpass2/=o.out_samplerate):(I.lowpass1=0,I.lowpass2=0),!function(e){var t=e.internal_flags,a=32,r=-1;if(t.lowpass1>0){for(var n=999,i=0;i<=31;i++){var o=i/31;o>=t.lowpass2&&(a=Math.min(a,i)),t.lowpass10&&t.highpass2<.75/31*.9&&(t.highpass1=0,t.highpass2=0,s.err.println("Warning: highpass filter disabled. highpass frequency too small\n")),t.highpass2>0){for(var l=-1,i=0;i<=31;i++){var o=i/31;o<=t.highpass1&&(r=Math.max(r,i)),t.highpass1t.highpass1?N((t.highpass2-o)/(t.highpass2-t.highpass1+1e-20)):1,u=t.lowpass2>t.lowpass1?N((o-t.lowpass1)/(t.lowpass2-t.lowpass1+1e-20)):1,t.amp_filter[i]=c*u}}(o),I.samplerate_index=T(o.out_samplerate,o),I.samplerate_index<0)return o.internal_flags=null,-1;if(o.VBR==n.vbr_off){if(o.free_format)I.bitrate_index=0;else if(o.brate=j(o.brate,o.version,o.out_samplerate),I.bitrate_index=L(o.brate,o.version,o.out_samplerate),I.bitrate_index<=0)return o.internal_flags=null,-1}else I.bitrate_index=1;o.analysis&&(o.bWriteVbrTag=!1),null!=I.pinfo&&(o.bWriteVbrTag=!1),t.init_bit_stream_w(I);for(var F=I.samplerate_index+3*o.version+6*(o.out_samplerate<16e3),X=0;X=0),o.VBR){case n.vbr_mt:o.VBR=n.vbr_mtrh;case n.vbr_mtrh:null==o.useTemporal&&(o.useTemporal=!1),a.apply_preset(o,500-10*o.VBR_q,0),o.quality<0&&(o.quality=LAME_DEFAULT_QUALITY),o.quality<5&&(o.quality=0),o.quality>5&&(o.quality=5),I.PSY.mask_adjust=o.maskingadjust,I.PSY.mask_adjust_short=o.maskingadjust_short,o.experimentalY?I.sfb21_extra=!1:I.sfb21_extra=o.out_samplerate>44e3,I.iteration_loop=new VBRNewIterationLoop(w);break;case n.vbr_rh:a.apply_preset(o,500-10*o.VBR_q,0),I.PSY.mask_adjust=o.maskingadjust,I.PSY.mask_adjust_short=o.maskingadjust_short,o.experimentalY?I.sfb21_extra=!1:I.sfb21_extra=o.out_samplerate>44e3,o.quality>6&&(o.quality=6),o.quality<0&&(o.quality=LAME_DEFAULT_QUALITY),I.iteration_loop=new VBROldIterationLoop(w);break;default:I.sfb21_extra=!1,o.quality<0&&(o.quality=LAME_DEFAULT_QUALITY),(E=o.VBR)==n.vbr_off&&(o.VBR_mean_bitrate_kbps=o.brate),a.apply_preset(o,o.VBR_mean_bitrate_kbps,0),o.VBR=E,I.PSY.mask_adjust=o.maskingadjust,I.PSY.mask_adjust_short=o.maskingadjust_short,E==n.vbr_off?I.iteration_loop=new m(w):I.iteration_loop=new ABRIterationLoop(w)}if(u(o.scale>=0),o.VBR!=n.vbr_off){if(I.VBR_min_bitrate=1,I.VBR_max_bitrate=14,o.out_samplerate<16e3&&(I.VBR_max_bitrate=8),0!=o.VBR_min_bitrate_kbps&&(o.VBR_min_bitrate_kbps=j(o.VBR_min_bitrate_kbps,o.version,o.out_samplerate),I.VBR_min_bitrate=L(o.VBR_min_bitrate_kbps,o.version,o.out_samplerate),I.VBR_min_bitrate<0)||0!=o.VBR_max_bitrate_kbps&&(o.VBR_max_bitrate_kbps=j(o.VBR_max_bitrate_kbps,o.version,o.out_samplerate),I.VBR_max_bitrate=L(o.VBR_max_bitrate_kbps,o.version,o.out_samplerate),I.VBR_max_bitrate<0))return -1;o.VBR_min_bitrate_kbps=g.bitrate_table[o.version][I.VBR_min_bitrate],o.VBR_max_bitrate_kbps=g.bitrate_table[o.version][I.VBR_max_bitrate],o.VBR_mean_bitrate_kbps=Math.min(g.bitrate_table[o.version][I.VBR_max_bitrate],o.VBR_mean_bitrate_kbps),o.VBR_mean_bitrate_kbps=Math.max(g.bitrate_table[o.version][I.VBR_min_bitrate],o.VBR_mean_bitrate_kbps)}o.tune&&(I.PSY.mask_adjust+=o.tune_value_a,I.PSY.mask_adjust_short+=o.tune_value_a);var G=o.internal_flags;switch(o.quality){default:case 9:G.psymodel=0,G.noise_shaping=0,G.noise_shaping_amp=0,G.noise_shaping_stop=0,G.use_best_huffman=0,G.full_outer_loop=0;break;case 8:o.quality=7;case 7:G.psymodel=1,G.noise_shaping=0,G.noise_shaping_amp=0,G.noise_shaping_stop=0,G.use_best_huffman=0,G.full_outer_loop=0;break;case 6:case 5:G.psymodel=1,0==G.noise_shaping&&(G.noise_shaping=1),G.noise_shaping_amp=0,G.noise_shaping_stop=0,-1==G.subblock_gain&&(G.subblock_gain=1),G.use_best_huffman=0,G.full_outer_loop=0;break;case 4:G.psymodel=1,0==G.noise_shaping&&(G.noise_shaping=1),G.noise_shaping_amp=0,G.noise_shaping_stop=0,-1==G.subblock_gain&&(G.subblock_gain=1),G.use_best_huffman=1,G.full_outer_loop=0;break;case 3:G.psymodel=1,0==G.noise_shaping&&(G.noise_shaping=1),G.noise_shaping_amp=1,G.noise_shaping_stop=1,-1==G.subblock_gain&&(G.subblock_gain=1),G.use_best_huffman=1,G.full_outer_loop=0;break;case 2:G.psymodel=1,0==G.noise_shaping&&(G.noise_shaping=1),0==G.substep_shaping&&(G.substep_shaping=2),G.noise_shaping_amp=1,G.noise_shaping_stop=1,-1==G.subblock_gain&&(G.subblock_gain=1),G.use_best_huffman=1,G.full_outer_loop=0;break;case 1:case 0:G.psymodel=1,0==G.noise_shaping&&(G.noise_shaping=1),0==G.substep_shaping&&(G.substep_shaping=2),G.noise_shaping_amp=2,G.noise_shaping_stop=1,-1==G.subblock_gain&&(G.subblock_gain=1),G.use_best_huffman=1,G.full_outer_loop=0}return u(o.scale>=0),o.athaa_type<0?I.ATH.useAdjust=3:I.ATH.useAdjust=o.athaa_type,I.ATH.aaSensitivityP=Math.pow(10,-(o.athaa_sensitivity/10)),null==o.short_blocks&&(o.short_blocks=i.short_block_allowed),o.short_blocks==i.short_block_allowed&&(o.mode==MPEGMode.JOINT_STEREO||o.mode==MPEGMode.STEREO)&&(o.short_blocks=i.short_block_coupled),o.quant_comp<0&&(o.quant_comp=1),o.quant_comp_short<0&&(o.quant_comp_short=0),o.msfix<0&&(o.msfix=0),o.exp_nspsytune=1|o.exp_nspsytune,o.internal_flags.nsPsy.attackthre<0&&(o.internal_flags.nsPsy.attackthre=_.NSATTACKTHRE),o.internal_flags.nsPsy.attackthre_s<0&&(o.internal_flags.nsPsy.attackthre_s=_.NSATTACKTHRE_S),u(o.scale>=0),o.scale<0&&(o.scale=1),o.ATHtype<0&&(o.ATHtype=4),o.ATHcurve<0&&(o.ATHcurve=4),o.athaa_loudapprox<0&&(o.athaa_loudapprox=2),o.interChRatio<0&&(o.interChRatio=0),null==o.useTemporal&&(o.useTemporal=!0),I.slot_lag=I.frac_SpF=0,o.VBR==n.vbr_off&&(I.slot_lag=I.frac_SpF=(o.version+1)*72e3*o.brate%o.out_samplerate|0),r.iteration_init(o),M.psymodel_init(o),u(o.scale>=0),0},this.lame_encode_flush=function(e,a,r,s){var n,i,o,l,u=e.internal_flags,_=c([2,1152]),d=0,p=u.mf_samples_to_encode-v.POSTDELAY,f=I(e);if(u.mf_samples_to_encode<1)return 0;for(o=0,e.in_samplerate!=e.out_samplerate&&(p+=16*e.out_samplerate/e.in_samplerate),(n=e.framesize-p%e.framesize)<576&&(n+=e.framesize),e.encoder_padding=n,i=(p+n)/e.framesize;i>0&&d>=0;){var h=f-u.mf_size,m=e.frameNum;h*=e.in_samplerate,(h/=e.out_samplerate)>1152&&(h=1152),h<1&&(h=1),l=s-o,0==s&&(l=0),d=this.lame_encode_buffer(e,_[0],_[1],h,a,r,l),r+=d,o+=d,i-=m!=e.frameNum}if(u.mf_samples_to_encode=0,d<0||(l=s-o,0==s&&(l=0),t.flush_bitstream(e),(d=t.copy_buffer(u,a,r,l,1))<0))return d;if(r+=d,o+=d,l=s-o,0==s&&(l=0),e.write_id3tag_automatic){if(S.id3tag_write_v1(e),(d=t.copy_buffer(u,a,r,l,0))<0)return d;o+=d}return o},this.lame_encode_buffer=function(a,r,s,n,i,l,c){var _=a.internal_flags,d=[null,null];if(0xfff88e3b!=_.Class_ID)return -3;if(0==n)return 0;(null==_.in_buffer_0||_.in_buffer_nsamples1&&(d[1][f]=s[f]);return function(a,r,s,n,i,l,c){var _,d,f,h,m,g=a.internal_flags,x=0,w=[null,null],y=[null,null];if(0xfff88e3b!=g.Class_ID)return -3;if(0==n)return 0;if((_=t.copy_buffer(g,i,l,c,0))<0)return _;if(l+=_,x+=_,y[0]=r,y[1]=s,b.NEQ(a.scale,0)&&b.NEQ(a.scale,1))for(f=0;f0;){var A=[null,null],M=0,k=0;A[0]=y[0],A[1]=y[1];var B=new C;if(function(e,t,a,r,s,n){var i=e.internal_flags;if(i.resample_ratio<.9999||i.resample_ratio>1.0001)for(var l=0;lp.BPC&&(m=p.BPC);var b=+(1e-4>Math.abs(f.resample_ratio-Math.floor(.5+f.resample_ratio))),g=1/f.resample_ratio;g>1&&(g=1);var v=(A=31+b)+1;if(0==f.fill_buffer_resample_init){for(_=0,f.inbuf_old[0]=o(v),f.inbuf_old[1]=o(v);_<=2*m;++_)f.blackfilt[_]=o(v);for(h=0,f.itime[0]=0,f.itime[1]=0;h<=2*m;h++){var x=0,w=(h-m)/(2*m);for(_=0;_<=A;_++)x+=f.blackfilt[h][_]=function(e,t,a){var r=Math.PI*t;(e/=a)<0&&(e=0),e>1&&(e=1);var s=e-.5,n=.42-.5*Math.cos(2*e*Math.PI)+.08*Math.cos(4*e*Math.PI);return 1e-9>Math.abs(s)?r/Math.PI:n*Math.sin(a*r*s)/(Math.PI*a*s)}(_-w,g,A);for(_=0;_<=A;_++)f.blackfilt[h][_]/=x}f.fill_buffer_resample_init=1}var y=f.inbuf_old[c];for(d=0;d=i);d++){var w=R-f.itime[c]-(h+A%2*.5);u(.501>=Math.abs(w)),M=0|Math.floor(2*w*m+m+.5);var S=0;for(_=0;_<=A;++_){var A,R,M,k=0|_+h-A/2;u(k=0),S+=(k<0?y[v+k]:s[n+k])*f.blackfilt[M][_]}t[a+d]=S}if(l.num_used=Math.min(i,A+h-A/2),f.itime[c]+=l.num_used-d*f.resample_ratio,l.num_used>=v)for(_=0;_=m){var E=c-x;if(0==c&&(E=0),(d=function(e,t,a,r,s,n){var i=R.enc.lame_encode_mp3_frame(e,t,a,r,s,n);return e.frameNum++,i}(a,w[0],w[1],i,l,E))<0)return d;for(l+=d,x+=d,g.mf_size-=a.framesize,g.mf_samples_to_encode-=a.framesize,h=0;h{var r=e.r(725090);r.System;var s=r.VbrMode;r.Float,r.ShortBlock,r.Util,r.Arrays,r.new_array_n,r.new_byte,r.new_double,r.new_float,r.new_float_n,r.new_int,r.new_int_n,r.assert,t.exports=function(){function e(e,t,a,r,s,n,i,o,l,c,u,_,d,p,f){this.vbr_q=e,this.quant_comp=t,this.quant_comp_s=a,this.expY=r,this.st_lrm=s,this.st_s=n,this.masking_adj=i,this.masking_adj_short=o,this.ath_lower=l,this.ath_curve=c,this.ath_sensitivity=u,this.interch=_,this.safejoint=d,this.sfb21mod=p,this.msfix=f}function t(e,t,a,r,s,n,i,o,l,c,u,_,d,p){this.quant_comp=t,this.quant_comp_s=a,this.safejoint=r,this.nsmsfix=s,this.st_lrm=n,this.st_s=i,this.nsbass=o,this.scale=l,this.masking_adj=c,this.ath_lower=u,this.ath_curve=_,this.interch=d,this.sfscale=p}this.setModules=function(e){a=e};var a,r=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],n=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function i(e,t,a){var i,o,l=e.VBR==s.vbr_rh?r:n,c=e.VBR_q_frac,u=l[t],_=l[t+1];u.st_lrm=u.st_lrm+c*(_.st_lrm-u.st_lrm),u.st_s=u.st_s+c*(_.st_s-u.st_s),u.masking_adj=u.masking_adj+c*(_.masking_adj-u.masking_adj),u.masking_adj_short=u.masking_adj_short+c*(_.masking_adj_short-u.masking_adj_short),u.ath_lower=u.ath_lower+c*(_.ath_lower-u.ath_lower),u.ath_curve=u.ath_curve+c*(_.ath_curve-u.ath_curve),u.ath_sensitivity=u.ath_sensitivity+c*(_.ath_sensitivity-u.ath_sensitivity),u.interch=u.interch+c*(_.interch-u.interch),u.msfix=u.msfix+c*(_.msfix-u.msfix),i=e,o=u.vbr_q,0>o&&(o=0),90||(e.quant_comp=u.quant_comp),0!=a?e.quant_comp_short=u.quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=u.quant_comp_s),0!=u.expY&&(e.experimentalY=0!=u.expY),0!=a?e.internal_flags.nsPsy.attackthre=u.st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=u.st_lrm),0!=a?e.internal_flags.nsPsy.attackthre_s=u.st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=u.st_s),0!=a?e.maskingadjust=u.masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=u.masking_adj),0!=a?e.maskingadjust_short=u.masking_adj_short:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=u.masking_adj_short),0!=a?e.ATHlower=-u.ath_lower/10:Math.abs(-(10*e.ATHlower)-0)>0||(e.ATHlower=-u.ath_lower/10),0!=a?e.ATHcurve=u.ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=u.ath_curve),0!=a?e.athaa_sensitivity=u.ath_sensitivity:Math.abs(e.athaa_sensitivity- -1)>0||(e.athaa_sensitivity=u.ath_sensitivity),u.interch>0&&(0!=a?e.interChRatio=u.interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=u.interch)),u.safejoint>0&&(e.exp_nspsytune=e.exp_nspsytune|u.safejoint),u.sfb21mod>0&&(e.exp_nspsytune=e.exp_nspsytune|u.sfb21mod<<20),0!=a?e.msfix=u.msfix:Math.abs(e.msfix- -1)>0||(e.msfix=u.msfix),0==a&&(e.VBR_q=t,e.VBR_q_frac=c)}var o=[new t(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new t(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new t(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new t(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new t(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new t(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new t(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new t(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new t(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new t(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new t(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new t(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new t(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new t(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new t(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new t(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function l(e,t,r){var n=a.nearestBitrateFullIndex(t);if(e.VBR=s.vbr_abr,e.VBR_mean_bitrate_kbps=t,e.VBR_mean_bitrate_kbps=Math.min(e.VBR_mean_bitrate_kbps,320),e.VBR_mean_bitrate_kbps=Math.max(e.VBR_mean_bitrate_kbps,8),e.brate=e.VBR_mean_bitrate_kbps,e.VBR_mean_bitrate_kbps>320&&(e.disable_reservoir=!0),o[n].safejoint>0&&(e.exp_nspsytune=2|e.exp_nspsytune),o[n].sfscale>0&&(e.internal_flags.noise_shaping=2),Math.abs(o[n].nsbass)>0){var i=int(4*o[n].nsbass);i<0&&(i+=64),e.exp_nspsytune=e.exp_nspsytune|i<<2}return 0!=r?e.quant_comp=o[n].quant_comp:Math.abs(e.quant_comp- -1)>0||(e.quant_comp=o[n].quant_comp),0!=r?e.quant_comp_short=o[n].quant_comp_s:Math.abs(e.quant_comp_short- -1)>0||(e.quant_comp_short=o[n].quant_comp_s),0!=r?e.msfix=o[n].nsmsfix:Math.abs(e.msfix- -1)>0||(e.msfix=o[n].nsmsfix),0!=r?e.internal_flags.nsPsy.attackthre=o[n].st_lrm:Math.abs(e.internal_flags.nsPsy.attackthre- -1)>0||(e.internal_flags.nsPsy.attackthre=o[n].st_lrm),0!=r?e.internal_flags.nsPsy.attackthre_s=o[n].st_s:Math.abs(e.internal_flags.nsPsy.attackthre_s- -1)>0||(e.internal_flags.nsPsy.attackthre_s=o[n].st_s),0!=r?e.scale=o[n].scale:Math.abs(e.scale- -1)>0||(e.scale=o[n].scale),0!=r?e.maskingadjust=o[n].masking_adj:Math.abs(e.maskingadjust-0)>0||(e.maskingadjust=o[n].masking_adj),o[n].masking_adj>0?0!=r?e.maskingadjust_short=.9*o[n].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=.9*o[n].masking_adj):0!=r?e.maskingadjust_short=1.1*o[n].masking_adj:Math.abs(e.maskingadjust_short-0)>0||(e.maskingadjust_short=1.1*o[n].masking_adj),0!=r?e.ATHlower=-o[n].ath_lower/10:Math.abs(-(10*e.ATHlower)-0)>0||(e.ATHlower=-o[n].ath_lower/10),0!=r?e.ATHcurve=o[n].ath_curve:Math.abs(e.ATHcurve- -1)>0||(e.ATHcurve=o[n].ath_curve),0!=r?e.interChRatio=o[n].interch:Math.abs(e.interChRatio- -1)>0||(e.interChRatio=o[n].interch),t}this.apply_preset=function(e,t,a){switch(t){case Lame.R3MIX:t=Lame.V3,e.VBR=s.vbr_mtrh;break;case Lame.MEDIUM:t=Lame.V4,e.VBR=s.vbr_rh;break;case Lame.MEDIUM_FAST:t=Lame.V4,e.VBR=s.vbr_mtrh;break;case Lame.STANDARD:t=Lame.V2,e.VBR=s.vbr_rh;break;case Lame.STANDARD_FAST:t=Lame.V2,e.VBR=s.vbr_mtrh;break;case Lame.EXTREME:t=Lame.V0,e.VBR=s.vbr_rh;break;case Lame.EXTREME_FAST:t=Lame.V0,e.VBR=s.vbr_mtrh;break;case Lame.INSANE:return e.preset=t=320,l(e,t,a),e.VBR=s.vbr_off,t}switch(e.preset=t,t){case Lame.V9:return i(e,9,a),t;case Lame.V8:return i(e,8,a),t;case Lame.V7:return i(e,7,a),t;case Lame.V6:return i(e,6,a),t;case Lame.V5:return i(e,5,a),t;case Lame.V4:return i(e,4,a),t;case Lame.V3:return i(e,3,a),t;case Lame.V2:return i(e,2,a),t;case Lame.V1:return i(e,1,a),t;case Lame.V0:return i(e,0,a),t}return 8<=t&&t<=320?l(e,t,a):(e.preset=0,t)}}},281549,(e,t,a)=>{t.exports=function(){this.setModules=function(e,t){}}},215810,(e,t,a)=>{t.exports=function(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}},480147,(e,t,a)=>{var r=e.r(725090),s=r.new_float,n=r.new_int;r.assert,t.exports=function(){this.global_gain=0,this.sfb_count1=0,this.step=n(39),this.noise=s(39),this.noise_log=s(39)}},802621,(e,t,a)=>{var r=e.r(725090),s=r.System,n=r.VbrMode;r.Float,r.ShortBlock;var i=r.Util,o=r.Arrays;r.new_array_n,r.new_byte,r.new_double;var l=r.new_float;r.new_float_n,r.new_int,r.new_int_n;var c=r.assert,u=e.r(281549),_=e.r(215810),d=e.r(480147),p=e.r(927304),f=e.r(89298),h=e.r(440823);t.exports=function(){this.rv=null,this.qupvt=null;var e,t,a,r,m=new u;function b(e){this.ordinal=e}function g(e){for(var t=0;te.xrpow_max&&(e.xrpow_max=t[s])}return r}(t,a,s,r))>1e-20){var n=0;(2&e.substep_shaping)!=0&&(n=1);for(var i=0;i=0&&!n;i--){var o=e.scalefac_band.psfb21[i],l=e.scalefac_band.psfb21[i+1],c=a.athAdjust(r.adjust,r.psfb21[i],r.floor);e.nsPsy.longfact[21]>1e-12&&(c*=e.nsPsy.longfact[21]);for(var u=l-1;u>=o;u--)if(Math.abs(s[u])=0&&!n;i--){var o=3*e.scalefac_band.s[12]+(e.scalefac_band.s[13]-e.scalefac_band.s[12])*_+(e.scalefac_band.psfb12[i]-e.scalefac_band.psfb12[0]),l=o+(e.scalefac_band.psfb12[i+1]-e.scalefac_band.psfb12[i]),d=a.athAdjust(r.adjust,r.psfb12[i],r.floor);e.nsPsy.shortfact[12]>1e-12&&(d*=e.nsPsy.shortfact[12]);for(var u=l-1;u>=o;u--)if(Math.abs(s[u])=1||(o.sort(n,c-x,x),BitStream.EQ(n[c-1],0)))continue;f=(1-i[d])*s[d],m=0,g=0;do{for(b=1;g+b0)}while(++da?(d==b.BINSEARCH_DOWN&&(u=!0),u&&(l/=2),d=b.BINSEARCH_UP,o=l):(d==b.BINSEARCH_UP&&(u=!0),u&&(l/=2),d=b.BINSEARCH_DOWN,o=-l),t.global_gain+=o,t.global_gain<0&&(t.global_gain=0,u=!0),t.global_gain>255&&(t.global_gain=255,u=!0);for(c(t.global_gain>=0),c(t.global_gain<256);i>a&&t.global_gain<255;)t.global_gain++,i=r.count_bits(e,n,t,null);e.CurrentStep[s]=_-t.global_gain>=4?4:2,e.OldValue[s]=t.global_gain,t.part2_3_length=i}(w,t,x,v,m),0==w.noise_shaping)return 100;a.calc_noise(t,u,A,R,M),R.bits=t.part2_3_length,y.assign(t);var T=0;for(s.arraycopy(m,0,S,0,576);!B;){do{var j,L=new _,P=255;if(j=(2&w.substep_shaping)!=0?20:3,w.sfb21_extra&&(A[y.sfbmax]>1||y.block_type==p.SHORT_TYPE&&(A[y.sfbmax+1]>1||A[y.sfbmax+2]>1))||!function(e,t,s,n,i){var l=e.internal_flags;!function(e,t,a,r,s){var n=e.internal_flags;u=0==t.scalefac_scale?1.2968395546510096:1.6817928305074292;for(var i=0,o=0;o1?i=Math.pow(i,.5):i*=.95;break;default:i>1?i=1:i*=.95}for(var c=0,o=0;ot.xrpow_max&&(t.xrpow_max=r[c+_]);if(2==n.noise_shaping_amp)return}}}(e,t,s,n,i);var u=g(t);return!u&&(!(u=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t))||(l.noise_shaping>1&&(o.fill(l.pseudohalf,0),0==t.scalefac_scale?(!function(e,t){for(var r=0,s=0;se.xrpow_max&&(e.xrpow_max=t[r+o])}e.scalefac[s]=i>>1}e.preflag=0,e.scalefac_scale=1}(t,n),u=!1):t.block_type==p.SHORT_TYPE&&l.subblock_gain>0&&(u=function(e,t,r){var s=t.scalefac;for(u=0;u=16)return!0;for(var n=0;n<3;n++){var i=0,o=0;for(u=t.sfb_lmax+n;u=7)return!0;t.subblock_gain[n]++;var l=e.scalefac_band.l[t.sfb_lmax];for(u=t.sfb_lmax+n;u=0),(p-=4>>t.scalefac_scale)>=0){s[u]=p,l+=3*d;continue}s[u]=0;var f=210+(p<t.xrpow_max&&(t.xrpow_max=r[l+h]);l+=d*(3-n-1)}var _=a.IPOW20(202);l+=t.width[u]*(n+1);for(var h=-t.width[u];h<0;h++)r[l+h]*=_,r[l+h]>t.xrpow_max&&(t.xrpow_max=r[l+h])}}return!1}(l,t,n)||g(t))),u||(u=2==l.mode_gr?r.scale_bitcount(t):r.scale_bitcount_lsf(l,t)),!u))}(e,y,A,m,E))break;0!=y.scalefac_scale&&(P=254);var I=x-y.part2_length;if(I<=0)break;for(;(y.part2_3_length=r.count_bits(w,m,y,M))>I&&y.global_gain<=P;)y.global_gain++;if(y.global_gain>P)break;if(0==R.over_count){for(;(y.part2_3_length=r.count_bits(w,m,y,M))>k&&y.global_gain<=P;)y.global_gain++;if(y.global_gain>P)break}if(a.calc_noise(y,u,A,L,M),L.bits=y.part2_3_length,0!=+!!function(e,t,a,r,s){var n;switch(e){default:case 9:t.over_count>0?(n=a.over_SSD<=t.over_SSD,a.over_SSD==t.over_SSD&&(n=a.bits.2||a.max_noise<=0&&t.max_noise<0&&t.max_noise>a.max_noise-.2&&a.tot_noise0&&t.max_noise>a.max_noise-.2&&a.tot_noise0&&t.max_noise>-.05&&t.max_noise>a.max_noise-.1&&a.tot_noise+a.over_noise0&&t.max_noise>-.1&&t.max_noise>a.max_noise-.15&&a.tot_noise+a.over_noise+a.over_noisej&&0==R.over_count||3==w.noise_shaping_amp&&E&&T>30||3==w.noise_shaping_amp&&E&&y.global_gain-N>15))break}while(y.global_gain+y.scalefac_scale<255)3==w.noise_shaping_amp?E?B=!0:(y.assign(t),s.arraycopy(S,0,m,0,576),T=0,N=y.global_gain,E=!0):B=!0}return c(t.global_gain+t.scalefac_scale<=255),e.VBR==n.vbr_rh||e.VBR==n.vbr_mtrh?s.arraycopy(S,0,m,0,576):(1&w.substep_shaping)!=0&&trancate_smallspectrums(w,t,u,m),R.over_count},this.iteration_finish_one=function(e,a,s){var n=e.l3_side,i=n.tt[a][s];r.best_scalefac_store(e,a,s,n),1==e.use_best_huffman&&r.best_huffman_divide(e,i),t.ResvAdjust(e,i)},this.VBR_encode_granule=function(e,t,a,r,n,i,u){var _,d=e.internal_flags,p=new f,h=l(576),m=u,b=u+1,g=(u+i)/2,v=0,x=d.sfb21_extra;c(m<=LameInternalFlags.MAX_BITS_PER_CHANNEL),o.fill(p.l3_enc,0);do c(g>=i),c(g<=u),c(i<=u),g>m-42?d.sfb21_extra=!1:d.sfb21_extra=x,0>=outer_loop(e,t,a,r,n,g)?(v=1,b=t.part2_3_length,p.assign(t),s.arraycopy(r,0,h,0,576),_=(u=b-32)-i,g=(u+i)/2):(_=u-(i=g+32),g=(u+i)/2,0!=v&&(v=2,t.assign(p),s.arraycopy(h,0,r,0,576)));while(_>12)d.sfb21_extra=x,2==v&&s.arraycopy(p.l3_enc,0,t.l3_enc,0,576),c(t.part2_3_length<=m)},this.get_framebits=function(a,r){var s=a.internal_flags;s.bitrate_index=s.VBR_min_bitrate;var n=e.getframebits(a);s.bitrate_index=1,n=e.getframebits(a);for(var i=1;i<=s.VBR_max_bitrate;i++){s.bitrate_index=i;var o=new MeanBits(n);r[i]=t.ResvFrameBegin(a,o),n=o.bits}},this.VBR_old_prepare=function(e,r,s,n,i,o,l,c,u){var _,d=e.internal_flags,f=0,h=1,m=0;d.bitrate_index=d.VBR_max_bitrate;var b=t.ResvFrameBegin(e,new MeanBits(0))/d.mode_gr;get_framebits(e,o);for(var g=0;go[d.VBR_max_bitrate]&&(c[g][x]*=o[d.VBR_max_bitrate],c[g][x]/=m),l[g][x]>c[g][x]&&(l[g][x]=c[g][x]);return h},this.bitpressure_strategy=function(e,t,a,r){for(var s=0;sl&&(o[h][m]*=l,o[h][m]/=d);return u},this.calc_target_bits=function(r,s,n,i,o,l){var c,u,_,d,f=r.internal_flags,h=f.l3_side,m=0;f.bitrate_index=f.VBR_max_bitrate;var b=new MeanBits(m);for(l[0]=t.ResvFrameBegin(r,b),m=b.bits,f.bitrate_index=1,m=e.getframebits(r)-8*f.sideinfo_len,o[0]=m/(f.mode_gr*f.channels_out),m=r.VBR_mean_bitrate_kbps*r.framesize*1e3,(1&f.substep_shaping)!=0&&(m*=1.09),m/=r.out_samplerate,m-=8*f.sideinfo_len,m/=f.mode_gr*f.channels_out,(c=.93+.07*(11-r.compression_ratio)/5.5)<.9&&(c=.9),c>1&&(c=1),u=0;u700){var v=int((s[u][_]-700)/1.4),x=h.tt[u][_];i[u][_]=int(c*m),x.block_type==p.SHORT_TYPE&&v3*m/2?v=3*m/2:v<0&&(v=0),i[u][_]+=v}i[u][_]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(i[u][_]=LameInternalFlags.MAX_BITS_PER_CHANNEL),g+=i[u][_]}if(g>LameInternalFlags.MAX_BITS_PER_GRANULE)for(_=0;_LameInternalFlags.MAX_BITS_PER_CHANNEL&&(i[u][_]=LameInternalFlags.MAX_BITS_PER_CHANNEL),d+=i[u][_];if(d>l[0])for(u=0;u{var r=e.r(725090).assert;t.exports=function(){var e;this.setModules=function(t){e=t},this.ResvFrameBegin=function(t,a){var s,n=t.internal_flags,i=n.l3_side,o=e.getframebits(t);a.bits=(o-8*n.sideinfo_len)/n.mode_gr;var l=2048*n.mode_gr-8;t.brate>320?s=8*int(1e3*t.brate/(t.out_samplerate/1152)/8+.5):(s=11520,t.strict_ISO&&(s=8*int(32e4/(t.out_samplerate/1152)/8+.5))),n.ResvMax=s-o,n.ResvMax>l&&(n.ResvMax=l),(n.ResvMax<0||t.disable_reservoir)&&(n.ResvMax=0);var c=a.bits*n.mode_gr+Math.min(n.ResvSize,n.ResvMax);return c>s&&(c=s),r(0==n.ResvMax%8),r(n.ResvMax>=0),i.resvDrain_pre=0,null!=n.pinfo&&(n.pinfo.mean_bits=a.bits/2,n.pinfo.resvsize=n.ResvSize),c},this.ResvMaxBits=function(e,t,a,r){var s,n=e.internal_flags,i=n.ResvSize,o=n.ResvMax;0!=r&&(i+=t),(1&n.substep_shaping)!=0&&(o*=.9),a.bits=t,10*i>9*o?(s=i-9*o/10,a.bits+=s,n.substep_shaping|=128):(s=0,n.substep_shaping&=127,e.disable_reservoir||0!=(1&n.substep_shaping)||(a.bits-=.1*t));var l=i<6*n.ResvMax/10?i:6*n.ResvMax/10;return(l-=s)<0&&(l=0),l},this.ResvAdjust=function(e,t){e.ResvSize-=t.part2_3_length+t.part2_length},this.ResvFrameEnd=function(e,t){var a,s=e.l3_side;e.ResvSize+=t*e.mode_gr;var n=0;s.resvDrain_post=0,s.resvDrain_pre=0,0!=(a=e.ResvSize%8)&&(n+=a),(a=e.ResvSize-n-e.ResvMax)>0&&(r(0==a%8),r(a>=0),n+=a);var i=Math.min(8*s.main_data_begin,n)/8;s.resvDrain_pre+=8*i,n-=8*i,e.ResvSize-=8*i,s.main_data_begin-=i,s.resvDrain_post+=n,e.ResvSize-=n}}},540396,(e,t,a)=>{t.exports=function(){this.getLameVersion=function(){return"3.98.4"},this.getLameShortVersion=function(){return"3.98.4"},this.getLameVeryShortVersion=function(){return"LAME3.98r"},this.getPsyVersion=function(){return"0.93"},this.getLameUrl=function(){return"http://www.mp3dev.org/"},this.getLameOsBitness=function(){return"32bits"}}},10615,(e,t,a)=>{var r=e.r(725090),s=r.System,n=r.VbrMode;r.Float;var i=r.ShortBlock;r.Util;var o=r.Arrays;r.new_array_n;var l=r.new_byte;r.new_double,r.new_float,r.new_float_n,r.new_int,r.new_int_n;var c=r.assert;function u(){this.setModules=function(r,s,n){e=r,t=s,a=n};var e,t,a,r=u.NUMTOCENTRIES,_=u.MAXFRAMESIZE,d=r+4+4+4+4+4+9+1+1+8+1+1+3+1+1+2+4+2+2,p="Xing",f="Info",h=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function m(e,t){var a=255&e[t+0];return a<<=8,a|=255&e[t+1],a<<=8,a|=255&e[t+2],a<<=8,a|=255&e[t+3]}function b(e,t,a){e[t+0]=a>>24&255,e[t+1]=a>>16&255,e[t+2]=a>>8&255,e[t+3]=255&a&255}function g(e,t,a){e[t+0]=a>>8&255,e[t+1]=255&a&255}function v(e,t,a){return 255&(e<>8^h[255&a]}this.addVbrFrame=function(e){var t=e.internal_flags,a=Tables.bitrate_table[e.version][t.bitrate_index];c(null!=t.VBR_seek_table.bag);var r=t.VBR_seek_table;if(r.nVbrNumFrames++,r.sum+=a,r.seen++,!(r.seen>3&1,i=e[s+2]>>2&3,o=e[s+3]>>6&3,l=e[s+2]>>4&15;if(l=Tables.bitrate_table[n][l],e[s+1]>>4==14?a.samprate=Tables.samplerate_table[2][i]:a.samprate=Tables.samplerate_table[n][i],0!=n?3!=o?s+=36:s+=21:3!=o?s+=21:s+=13,!(new String(e,t=s,p.length(),null).equals(p)||new String(e,t,f.length(),null).equals(f)))return null;s+=4,a.hId=n;var c=a.flags=m(e,s);if(s+=4,(1&c)!=0&&(a.frames=m(e,s),s+=4),(2&c)!=0&&(a.bytes=m(e,s),s+=4),(4&c)!=0){if(null!=a.toc)for(var u=0;u>4;var d=(15&e[s+1])<<8;return d+=255&e[s+2],(_<0||_>3e3)&&(_=-1),(d<0||d>3e3)&&(d=-1),a.encDelay=_,a.encPadding=d,a},this.InitVbrTag=function(e){var a,r=e.internal_flags;a=1==e.version?128:e.out_samplerate<16e3?32:64,e.VBR==n.vbr_off&&(a=e.brate);var s=(e.version+1)*72e3*a/e.out_samplerate,i=r.sideinfo_len+d;if(r.VBR_seek_table.TotalFrameSize=s,s_){e.bWriteVbrTag=!1;return}r.VBR_seek_table.nVbrNumFrames=0,r.VBR_seek_table.nBytesWritten=0,r.VBR_seek_table.sum=0,r.VBR_seek_table.seen=0,r.VBR_seek_table.want=1,r.VBR_seek_table.pos=0,null==r.VBR_seek_table.bag&&(r.VBR_seek_table.bag=new int[400],r.VBR_seek_table.size=400);var o=l(_);x(e,o);for(var c=r.VBR_seek_table.TotalFrameSize,u=0;ue.pos-1&&(s=e.pos-1);var n=0|256*e.bag[s]/e.sum;n>255&&(n=255),t[a]=255&n}}(u.VBR_seek_table,_);var h=u.sideinfo_len;e.error_protection&&(h-=2),e.VBR==n.vbr_off?(c[h++]=255&f.charAt(0),c[h++]=255&f.charAt(1),c[h++]=255&f.charAt(2),c[h++]=255&f.charAt(3)):(c[h++]=255&p.charAt(0),c[h++]=255&p.charAt(1),c[h++]=255&p.charAt(2),c[h++]=255&p.charAt(3)),b(c,h,15),b(c,h+=4,u.VBR_seek_table.nVbrNumFrames),h+=4;var m=u.VBR_seek_table.nBytesWritten+u.VBR_seek_table.TotalFrameSize;b(c,h,0|m),h+=4,s.arraycopy(_,0,c,h,_.length),h+=_.length,e.error_protection&&t.CRC_writeheader(u,c);for(var v=0,d=0;d255?255:e.lowpassfreq/100+.5),v=0,x=0,y=e.internal_flags.noise_shaping,S=0,A=0,R=0,M=0,k=0,B=(1&e.exp_nspsytune)!=0,E=(2&e.exp_nspsytune)!=0,N=!1,T=!1,j=e.internal_flags.nogap_total,L=e.internal_flags.nogap_current,P=e.ATHtype,I=0;switch(e.VBR){case vbr_abr:l=e.VBR_mean_bitrate_kbps;break;case vbr_off:l=e.brate;break;default:l=e.VBR_min_bitrate_kbps}switch(o=0+(e.VBR.ordinal()510&&(c.RadioGain=510),c.RadioGain<-510&&(c.RadioGain=-510),x=11264,c.RadioGain>=0?x|=c.RadioGain:(x|=512,x|=-c.RadioGain)),c.findPeakSample&&(v=Math.abs(0|c.PeakSample/32767*8388608+.5)),-1!=j&&(L>0&&(T=!0),L48e3?3:1,(e.short_blocks==i.short_block_forced||e.short_blocks==i.short_block_dispensed||-1==e.lowpassfreq&&-1==e.highpassfreq||e.scale_lefte.scale_right||e.disable_reservoir&&e.brate<320||e.noATH||e.ATHonly||0==P||e.in_samplerate<=32e3)&&(A=1),M=y+(S<<2)+(A<<5)+(R<<6),k=c.nMusicCRC,b(r,s+u,p),u+=4;for(var C=0;C<9;C++)r[s+u+C]=255&f.charAt(C);r[s+(u+=9)]=255&o,r[s+ ++u]=255&m,b(r,s+ ++u,v),g(r,s+(u+=4),x),g(r,s+(u+=2),0),r[s+(u+=2)]=255&I,u++,l>=255?r[s+u]=255:r[s+u]=255&l,r[s+ ++u]=255&_>>4,r[s+u+1]=255&(_<<4)+(d>>8),r[s+u+2]=255&d,r[s+(u+=3)]=255&M,u++,r[s+u++]=0,g(r,s+u,e.preset),b(r,s+(u+=2),t),g(r,s+(u+=4),k),u+=2;for(var q=0;qs.length?-1:(n<1||t.write(s,0,n),0)}}u.NUMTOCENTRIES=100,u.MAXFRAMESIZE=2880,t.exports=u},681167,(e,t,a)=>{var r=e.r(725090);r.System,r.VbrMode,r.Float,r.ShortBlock,r.Util,r.Arrays,r.new_array_n;var s=r.new_byte;r.new_double,r.new_float,r.new_float_n,r.new_int,r.new_int_n;var n=r.assert,i=e.r(221272),o=e.r(228830),l=e.r(900947),c=e.r(94915),u=e.r(802621),_=e.r(414828),d=e.r(647502),p=e.r(575486),f=e.r(757268);e.r(927304);var h=e.r(540396),m=e.r(10615);function b(){this.setModules=function(e,t){}}function g(){this.setModules=function(e,t,a){}}function v(){}function x(){this.setModules=function(e,t){}}function w(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function y(e){return e.charCodeAt(0)<<24|e.charCodeAt(1)<<16|e.charCodeAt(2)<<8|e.charCodeAt(3)}w.RIFF=y("RIFF"),w.WAVE=y("WAVE"),w.fmt_=y("fmt "),w.data=y("data"),w.readHeader=function(e){var t=new w,a=e.getUint32(0,!1);if(w.RIFF==a){if((e.getUint32(4,!0),w.WAVE==e.getUint32(8,!1))&&w.fmt_==e.getUint32(12,!1)){var r=e.getUint32(16,!0),s=20;switch(r){case 16:case 18:t.channels=e.getUint16(s+2,!0),t.sampleRate=e.getUint32(s+4,!0);break;default:throw"extended fmt chunk not implemented"}s+=r;for(var n=w.data,i=0;n!=a&&(a=e.getUint32(s,!1),i=e.getUint32(s+4,!0),n!=a);)s+=i+8;return t.dataLen=i,t.dataOffset=s+8,t}}},t.exports.Mp3Encoder=function(e,t,a){3!=arguments.length&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),e=1,t=44100,a=128);var r=new i,w=new b,y=new l,S=new f,A=new o,R=new c,M=new u,k=new m,B=new h,E=new x,N=new d,T=new _,j=new g,L=new v;r.setModules(y,S,A,R,M,k,B,E,L),S.setModules(y,L,B,k),E.setModules(S,B),A.setModules(r),M.setModules(S,N,R,T),R.setModules(T,N,r.enc.psy),N.setModules(S),T.setModules(R),k.setModules(r,S,B),w.setModules(j,L),j.setModules(B,E,A);var P=r.lame_init();P.num_channels=e,P.in_samplerate=t,P.brate=a,P.mode=p.STEREO,P.quality=3,P.bWriteVbrTag=!1,P.disable_reservoir=!0,P.write_id3tag_automatic=!1,n(0==r.lame_init_params(P));var I=1152,C=8640,q=s(8640);this.encodeBuffer=function(t,a){1==e&&(a=t),n(t.length==a.length),t.length>I&&(q=s(C=0|1.25*(I=t.length)+7200));var i=r.lame_encode_buffer(P,t,a,t.length,q,0,C);return new Int8Array(q.subarray(0,i))},this.flush=function(){var e=r.lame_encode_flush(P,q,0,C);return new Int8Array(q.subarray(0,e))}},t.exports.WavHeader=w},336282,e=>{"use strict";var t=e.i(162115),a=e.i(220365),r=e.i(843039),s=e.i(226491),n=e.i(942347);e.i(816688);var i=e.i(675066),o=e.i(528704),l=e.i(958572);e.i(237855);var c=e.i(297162),u=e.i(773934),_=e.i(59101),d=e.i(734962),p=e.i(750407),f=e.i(183683),h=function(e,t){if(void 0===t&&(t=0),"u"=t&&(e(),a=Date.now()),r.id=requestAnimationFrame(s)};return r.id=requestAnimationFrame(s),r},m=function(e){if(e.id,"u"{let{onCancel:a,onConverted:r,wordTimestamps:o}=e,{t:l}=(0,i.useTranslation)(),c=(0,n.useRef)(new s.default({sampleBits:16,sampleRate:16e3,numChannels:1,compiling:!1})),u=(0,n.useRef)(null),_=(0,n.useRef)(null),d=(0,n.useRef)(null),[p,f]=(0,n.useState)(0),[h,m]=(0,n.useState)(!1),[S,A]=(0,n.useState)(!1),R=(0,g.usePathname)(),M=(0,g.useParams)(),k=b(()=>{f(p+1)},1e3),B=(0,n.useCallback)(()=>{d.current=requestAnimationFrame(B);let e=u.current,t=_.current,a=c.current.getRecordAnalyseData(),r=[].slice.call(a),s=Number.parseInt(`${e.width/3}`),n=Number.parseInt(`${1024/s}`);t.clearRect(0,0,e.width,e.height),t.beginPath();let i=0;for(let a=0;ae+t,0)/n;s<128&&(s=128),s>178&&(s=178);let o=(s-128)/50*e.height;t.moveTo(i,16),t.roundRect?t.roundRect(i,16-o,2,o,[1,1,0,0]):t.rect(i,16-o,2,o),t.fill(),i+=3}t.closePath()},[]),E=(0,n.useCallback)(async()=>{k(),m(!1),A(!0),c.current.stop(),d.current&&cancelAnimationFrame(d.current),d.current=null;let e=u.current;_.current.clearRect(0,0,e.width,e.height);let t=new File([(e=>{let{channels:t,sampleRate:a}=y.default.WavHeader.readHeader(e.getWAV()),r=new y.default.Mp3Encoder(t,a,128),s=e.getChannelData(),n=[],i=s.left&&new Int16Array(s.left.buffer,0,s.left.byteLength/2),o=s.right&&new Int16Array(s.right.buffer,0,s.right.byteLength/2),l=i.length+(o?o.length:0),c=e=>{let t=new ArrayBuffer(e.length);return new Uint8Array(t).set(e),t};for(let e=0;e0&&n.push(c(l))}let u=r.flush();return u.length>0&&n.push(c(u)),new Blob(n,{type:"audio/mp3"})})(c.current)],"temp.mp3",{type:"audio/mp3"}),s=new FormData;s.append("file",t),s.append("word_timestamps",o||"disabled");let n="",i=!1;M.token?(n="/audio-to-text",i=!0):M.appId&&(n=R.search("explore/installed")>-1?`/installed-apps/${M.appId}/audio-to-text`:`/apps/${M.appId}/audio-to-text`);try{let e=await (0,v.audioToText)(n,i?v.AppSourceType.webApp:v.AppSourceType.installedApp,s);r(e.text),a()}catch{r(""),a()}},[k,a,r,M.appId,M.token,R,o]),N=(0,n.useCallback)(async()=>{try{await c.current.start(),m(!0),A(!1),u.current&&_.current&&B()}catch{a()}},[B,a,m,A]),T=(0,n.useCallback)(()=>{let e=window.devicePixelRatio||1,t=document.getElementById("voice-input-record");if(t){let{width:a,height:r}=t.getBoundingClientRect();t.width=e*a,t.height=e*r,u.current=t;let s=t.getContext("2d");s&&(s.scale(e,e),s.fillStyle="rgba(209, 224, 255, 1)",_.current=s)}},[]);p>=600&&h&&E(),(0,n.useEffect)(()=>{T(),N();let e=c?.current;return()=>{e?.stop()}},[N,T]);let j=Number.parseInt(`${Number.parseInt(`${p}`)/60}`),L=Number.parseInt(`${p}`)%60;return(0,t.jsx)("div",{className:(0,x.cn)(w.default.wrapper,"absolute inset-0 rounded-xl"),children:(0,t.jsxs)("div",{className:"absolute inset-[1.5px] flex items-center overflow-hidden rounded-[10.5px] bg-primary-25 py-[14px] pl-[14.5px] pr-[6.5px]",children:[(0,t.jsx)("canvas",{id:"voice-input-record",className:"absolute bottom-0 left-0 h-4 w-full"}),S&&(0,t.jsx)("div",{className:"i-ri-loader-2-line mr-2 h-4 w-4 animate-spin text-primary-700","data-testid":"voice-input-loader"}),(0,t.jsxs)("div",{className:"grow",children:[h&&(0,t.jsx)("div",{className:"text-sm text-gray-500",children:l("voiceInput.speaking",{ns:"common"})}),S&&(0,t.jsx)("div",{className:(0,x.cn)(w.default.convert,"text-sm"),"data-testid":"voice-input-converting-text",children:l("voiceInput.converting",{ns:"common"})})]}),h&&(0,t.jsx)("div",{className:"mr-1 flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg hover:bg-primary-100",onClick:E,"data-testid":"voice-input-stop",children:(0,t.jsx)("div",{className:"i-ri-stop-circle-line h-5 w-5 text-primary-600"})}),S&&(0,t.jsx)("div",{className:"mr-1 flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg hover:bg-gray-200",onClick:a,"data-testid":"voice-input-cancel",children:(0,t.jsx)("div",{className:"i-ri-close-line h-4 w-4 text-gray-500"})}),(0,t.jsx)("div",{className:`w-[45px] pl-1 text-xs font-medium ${p>500?"text-[#F04438]":"text-gray-700"}`,"data-testid":"voice-input-timer",children:`0${j.toFixed(0)}:${L>=10?L:`0${L}`}`})]})})};var k=e.i(648404),B=e.i(913978),E=e.i(869931),N=e.i(654313),T=e.i(151094),j=e.i(33199),j=j;let L=e=>{let{readonly:r,ref:s,fileConfig:n,speechToTextConfig:i,onShowVoiceInput:o,onSend:l,theme:c}=e;return(0,t.jsx)("div",{className:(0,x.cn)("flex shrink-0 items-center justify-end"),children:(0,t.jsxs)("div",{className:"flex items-center pl-1",ref:s,children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1",children:[n?.enabled&&(0,t.jsx)(j.default,{readonly:r,fileConfig:n}),i?.enabled&&(0,t.jsx)(N.default,{size:"l",disabled:r,onClick:o,"data-testid":"voice-input-button",children:(0,t.jsx)(E.RiMicLine,{className:"h-5 w-5"})})]}),(0,t.jsx)(T.default,{className:"ml-3 w-8 px-0",variant:"primary",onClick:r?a.noop:l,"data-testid":"send-button",style:c?{backgroundColor:c.primaryColor}:{},children:(0,t.jsx)(E.RiSendPlane2Fill,{className:"h-4 w-4"})})]})})};L.displayName="Operation";let P=(0,n.memo)(L),I=e=>{let{readonly:p,botName:f,showFeatureBar:h,showFileUpload:m,featureBarDisabled:b,onFeatureBarClick:g,visionConfig:v,speechToTextConfig:w={enabled:!0},onSend:y,inputs:S={},inputsForm:A=[],theme:R,isResponding:E,disabled:N,sendOnEnter:T=!0}=e,{t:j}=(0,i.useTranslation)(),{notify:L}=(0,d.useToastContext)(),{wrapperRef:I,textareaRef:C,textValueRef:q,holdSpaceRef:D,handleTextareaResize:O,isMultipleLine:V}=(()=>{let e=(0,n.useRef)(null),t=(0,n.useRef)(void 0),a=(0,n.useRef)(null),r=(0,n.useRef)(null),[s,i]=(0,n.useState)(!1),o=(0,n.useCallback)(()=>{let s=t.current;if(e.current&&s&&a.current&&r.current){let{width:t}=e.current.getBoundingClientRect(),{height:n}=s.getBoundingClientRect(),{width:o}=a.current.getBoundingClientRect(),{width:l}=r.current.getBoundingClientRect();n>32||o+l>=t?i(!0):i(!1)}},[]);return{wrapperRef:e,textareaRef:t,textValueRef:a,holdSpaceRef:r,handleTextareaResize:(0,n.useCallback)(()=>{o()},[o]),isMultipleLine:s}})(),[H,F]=(0,n.useState)(""),[X,U]=(0,n.useState)(!1),Y=(0,_.useFileStore)(),{handleDragFileEnter:G,handleDragFileLeave:z,handleDragFileOver:K,handleDropFile:Z,handleClipboardPasteFile:W,isDragActive:Q}=(0,u.useFile)(v,!1),{checkInputsForm:$}=(0,B.useCheckInputsForms)(),J=(0,n.useRef)([""]),[ee,et]=(0,n.useState)(-1),ea=(0,n.useRef)(!1),er=(0,n.useCallback)(e=>{F(e),setTimeout(O,0)},[O]),es=()=>{if(E)return void L({type:"info",message:j("errorMessage.waitForResponse",{ns:"appDebug"})});if(y){let{files:e,setFiles:t}=Y.getState();if(e.some(e=>e.transferMethod===k.TransferMethod.local_file&&!e.uploadedId))return void L({type:"info",message:j("errorMessage.waitForFileUpload",{ns:"appDebug"})});if(!H||!H.trim())return void L({type:"info",message:j("errorMessage.queryRequired",{ns:"appAnnotation"})});$(S,A)&&(y(H,e),er(""),t([]))}},en=(0,n.useCallback)(()=>{s.default.getPermission().then(()=>{U(!0)},()=>{L({type:"error",message:j("voiceInput.notAllow",{ns:"common"})})})},[j,L]),ei=(0,t.jsx)(P,{ref:D,readonly:p,fileConfig:v,speechToTextConfig:w,onShowVoiceInput:en,onSend:es,theme:R});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:(0,x.cn)("relative z-10 overflow-hidden rounded-xl border border-components-chat-input-border bg-components-panel-bg-blur pb-[9px] shadow-md",Q&&"border border-dashed border-components-option-card-option-selected-border",N&&"pointer-events-none border-components-panel-border opacity-50 shadow-none"),children:[(0,t.jsxs)("div",{className:"relative max-h-[158px] overflow-y-auto overflow-x-hidden px-[9px] pt-[9px]",children:[(0,t.jsx)(c.FileListInChatInput,{fileConfig:v}),(0,t.jsxs)("div",{ref:I,className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"relative flex w-full grow items-center",children:[(0,t.jsx)("div",{ref:q,className:"pointer-events-none invisible absolute h-auto w-auto whitespace-pre p-1 leading-6 body-lg-regular",children:H}),(0,t.jsx)(o.default,{ref:e=>C.current=e,className:(0,x.cn)("w-full resize-none bg-transparent p-1 leading-6 text-text-primary outline-none body-lg-regular"),placeholder:(0,r.decode)(j(p?"chat.inputDisabledPlaceholder":"chat.inputPlaceholder",{ns:"common",botName:f})||""),autoFocus:!0,minRows:1,value:H,onChange:e=>er(e.target.value),onKeyDown:e=>{(T?"Enter"!==e.key||e.shiftKey:"Enter"!==e.key||!e.shiftKey)||e.nativeEvent.isComposing?"ArrowUp"!==e.key||e.shiftKey||e.nativeEvent.isComposing||!e.metaKey?"ArrowDown"!==e.key||e.shiftKey||e.nativeEvent.isComposing||!e.metaKey||(ee0&&(et(ee-1),er(J.current[ee-1])):ea.current||(e.preventDefault(),F(H.replace(/\n$/,"")),J.current.push(H),et(J.current.length),es())},onCompositionStart:()=>{ea.current=!0},onCompositionEnd:()=>{setTimeout(()=>{ea.current=!1},50)},onPaste:W,onDragEnter:G,onDragLeave:z,onDragOver:K,onDrop:Z,readOnly:p})]}),!V&&ei]}),X&&(0,t.jsx)(M,{onCancel:()=>U(!1),onConverted:e=>er(e)})]}),V&&(0,t.jsx)("div",{className:"px-[9px]",children:ei})]}),h&&(0,t.jsx)(l.default,{showFileUpload:m,disabled:b,onFeatureBarClick:p?a.noop:g,hideEditEntrance:p})]})};e.s(["default",0,e=>(0,t.jsx)(_.FileContextProvider,{children:(0,t.jsx)(I,{...e})})],336282)},34510,e=>{"use strict";var t=e.i(162115),a=e.i(328817),r=e.i(942347);e.i(816688);var s=e.i(675066),n=e.i(786514),i=e.i(189299),o=e.i(708486),l=e.i(151094),c=e.i(83451),u=e.i(935139),_=e.i(127762),d=e.i(336282),p=e.i(432961);let f=e=>{let{children:a,readonly:r=!1,config:s,isResponding:n,chatList:i,showPromptLog:o,questionIcon:l,answerIcon:c,onSend:u,onRegenerate:_,onAnnotationEdited:d,onAnnotationAdded:f,onAnnotationRemoved:h,disableFeedback:m,onFeedback:b,getHumanInputNodeData:g}=e;return(0,t.jsx)(p.ChatContext.Provider,{value:{config:s,readonly:r,isResponding:n,chatList:i||[],showPromptLog:o,questionIcon:l,answerIcon:c,onSend:u,onRegenerate:_,onAnnotationEdited:d,onAnnotationAdded:f,onAnnotationRemoved:h,disableFeedback:m,onFeedback:b,getHumanInputNodeData:g},children:a})};var h=e.i(26012),m=e.i(528704);e.i(237855);var b=e.i(297162),g=e.i(379415),v=e.i(654313),x=e.i(137667),w=e.i(167362),y=e.i(546220);let S=(0,r.memo)(e=>{let{item:a,questionIcon:n,theme:i,enableEdit:o=!0,switchSibling:c,hideAvatar:_}=e,{t:d}=(0,s.useTranslation)(),{content:f,message_files:S}=a,{onRegenerate:A}=(0,p.useChatContext)(),[R,M]=(0,r.useState)(!1),[k,B]=(0,r.useState)(f),[E,N]=(0,r.useState)(0),T=(0,r.useRef)(null),j=(0,r.useRef)(!1),L=(0,r.useRef)(null),P=(0,r.useCallback)(()=>{M(!0),B(f)},[f]),I=(0,r.useCallback)(()=>{L.current&&(clearTimeout(L.current),L.current=null),j.current=!1,M(!1),A?.(a,{message:k,files:S})},[k,S,a,A]),C=(0,r.useCallback)(()=>{L.current&&(clearTimeout(L.current),L.current=null),j.current=!1,M(!1),B(f)},[f]),q=(0,r.useCallback)(e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing){if(j.current)return void e.preventDefault();e.preventDefault(),I()}},[I]),D=(0,r.useCallback)(()=>{L.current&&(clearTimeout(L.current),L.current=null)},[]),O=(0,r.useCallback)(()=>{D(),j.current=!0},[D]),V=(0,r.useCallback)(()=>{D(),L.current=setTimeout(()=>{j.current=!1,L.current=null},50)},[D]),H=(0,r.useCallback)(e=>{"prev"===e?a.prevSibling&&c?.(a.prevSibling):a.nextSibling&&c?.(a.nextSibling)},[c,a.prevSibling,a.nextSibling]);return(0,r.useEffect)(()=>{if(!T.current)return;let e=new ResizeObserver(()=>{T.current&&N(T.current?.clientWidth)});return e.observe(T.current),()=>{e.disconnect()}},[]),(0,r.useEffect)(()=>()=>{D()},[D]),(0,t.jsxs)("div",{className:"mb-2 flex justify-end last:mb-0",children:[(0,t.jsxs)("div",{className:(0,u.cn)("group relative mr-4 flex max-w-full items-start overflow-x-hidden pl-14",R&&"flex-1"),children:[(0,t.jsx)("div",{className:(0,u.cn)("mr-2 gap-1",R?"hidden":"flex"),children:(0,t.jsxs)("div",{"data-testid":"action-container",className:"absolute hidden gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-sm group-hover:flex",style:{right:E+8},children:[(0,t.jsx)(v.default,{"data-testid":"copy-btn",onClick:()=>{(0,h.default)(f),x.default.notify({type:"success",message:d("actionMsg.copySuccessfully",{ns:"common"})})},children:(0,t.jsx)("div",{className:"i-ri-clipboard-line h-4 w-4"})}),o&&(0,t.jsx)(v.default,{"data-testid":"edit-btn",onClick:P,children:(0,t.jsx)("div",{className:"i-ri-edit-line h-4 w-4"})})]})}),(0,t.jsxs)("div",{ref:T,"data-testid":"question-content",className:(0,u.cn)("w-full px-4 py-3 text-sm",!R&&"rounded-2xl bg-background-gradient-bg-fill-chat-bubble-bg-3 text-text-primary",R&&"rounded-[24px] border-[3px] border-components-option-card-option-selected-border bg-components-panel-bg-blur shadow-lg"),style:!R&&i?.chatBubbleColorStyle?(0,w.CssTransform)(i.chatBubbleColorStyle):{},children:[!!S?.length&&(0,t.jsx)(b.FileList,{className:(0,u.cn)(R?"mb-3":"mb-2"),files:S,showDeleteAction:!1,showDownloadAction:!0}),R?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("div",{className:"max-h-[158px] overflow-y-auto overflow-x-hidden pr-1",children:(0,t.jsx)(m.default,{className:(0,u.cn)("w-full resize-none bg-transparent p-0 leading-7 text-text-primary outline-none body-lg-regular"),autoFocus:!0,minRows:1,value:k,onChange:e=>B(e.target.value),onKeyDown:q,onCompositionStart:O,onCompositionEnd:V})}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)(l.default,{className:"min-w-24",onClick:C,"data-testid":"cancel-edit-btn",children:d("operation.cancel",{ns:"common"})}),(0,t.jsx)(l.default,{className:"min-w-24",variant:"primary",onClick:I,"data-testid":"save-edit-btn",children:d("operation.save",{ns:"common"})})]})]}):(0,t.jsx)(g.Markdown,{content:f}),!R&&(0,t.jsx)(y.default,{count:a.siblingCount,currentIndex:a.siblingIndex,prevDisabled:!a.prevSibling,nextDisabled:!a.nextSibling,switchSibling:H})]}),(0,t.jsx)("div",{className:"mt-1 h-[18px]"})]}),!_&&(0,t.jsx)("div",{className:"h-10 w-10 shrink-0",children:n||(0,t.jsx)("div",{className:"h-full w-full rounded-full border-[0.5px] border-black/5",children:(0,t.jsx)("div",{className:"i-custom-public-avatar-user h-full w-full"})})})]})});var A=e.i(757198);let R=(0,r.memo)(e=>{let{suggestedQuestions:a,onSend:r}=e,{t:n}=(0,s.useTranslation)();return(0,t.jsxs)("div",{className:"mb-2 py-2",children:[(0,t.jsxs)("div",{className:"mb-2.5 flex items-center justify-between gap-2",children:[(0,t.jsx)(A.default,{bgStyle:"gradient",className:"h-px !w-auto grow rotate-180"}),(0,t.jsx)("div",{className:"system-xs-medium-uppercase shrink-0 text-text-tertiary",children:n("feature.suggestedQuestionsAfterAnswer.tryToAsk",{ns:"appDebug"})}),(0,t.jsx)(A.default,{bgStyle:"gradient",className:"h-px !w-auto grow"})]}),(0,t.jsx)("div",{className:"flex flex-wrap justify-center",children:a.map((e,a)=>(0,t.jsx)(l.default,{size:"small",variant:"secondary-accent",className:"mb-1 mr-1 last:mr-0",onClick:()=>r(e),children:e},a))})]})}),M=(0,r.memo)(e=>{let{isTryApp:p,readonly:h=!1,appData:m,config:b,onSend:g,inputs:v,inputsForm:x,onRegenerate:w,chatList:y,isResponding:A,noStopResponding:M,onStopResponding:k,noChatInput:B,chatContainerClassName:E,chatContainerInnerClassName:N,chatFooterClassName:T,chatFooterInnerClassName:j,suggestedQuestions:L,showPromptLog:P,questionIcon:I,answerIcon:C,onAnnotationAdded:q,onAnnotationEdited:D,onAnnotationRemoved:O,chatNode:V,disableFeedback:H,onFeedback:F,chatAnswerContainerInner:X,hideProcessDetail:U,hideLogModal:Y,themeBuilder:G,switchSibling:z,showFeatureBar:K,showFileUpload:Z,onFeatureBarClick:W,noSpacing:Q,inputDisabled:$,sidebarCollapseState:J,hideAvatar:ee,sendOnEnter:et,onHumanInputFormSubmit:ea,getHumanInputNodeData:er}=e,{t:es}=(0,s.useTranslation)(),{currentLogItem:en,setCurrentLogItem:ei,showPromptLogModal:eo,setShowPromptLogModal:el,showAgentLogModal:ec,setShowAgentLogModal:eu}=(0,i.useStore)((0,n.useShallow)(e=>({currentLogItem:e.currentLogItem,setCurrentLogItem:e.setCurrentLogItem,showPromptLogModal:e.showPromptLogModal,setShowPromptLogModal:e.setShowPromptLogModal,showAgentLogModal:e.showAgentLogModal,setShowAgentLogModal:e.setShowAgentLogModal}))),[e_,ed]=(0,r.useState)(0),ep=(0,r.useRef)(null),ef=(0,r.useRef)(null),eh=(0,r.useRef)(null),em=(0,r.useRef)(null),eb=(0,r.useRef)(!1),eg=(0,r.useRef)(!1),ev=(0,r.useCallback)(()=>{y.length>1&&ep.current&&!eb.current&&(eg.current=!0,ep.current.scrollTop=ep.current.scrollHeight,requestAnimationFrame(()=>{eg.current=!1}))},[y.length]),ex=(0,r.useCallback)(()=>{ep.current&&ed(document.body.clientWidth-(ep.current?.clientWidth+16)-8),ep.current&&eh.current&&(eh.current.style.width=`${ep.current.clientWidth}px`),ef.current&&em.current&&(em.current.style.width=`${ef.current.clientWidth}px`)},[]);(0,r.useEffect)(()=>{ev(),ex()},[ev,ex]),(0,r.useEffect)(()=>{ep.current&&requestAnimationFrame(()=>{ev(),ex()})}),(0,r.useEffect)(()=>{let e=(0,a.debounce)(ex,200);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),e.cancel()}},[ex]),(0,r.useEffect)(()=>{if(eh.current&&ep.current){let e=new ResizeObserver(e=>{for(let t of e){let{blockSize:e}=t.borderBoxSize[0];ep.current.style.paddingBottom=`${e}px`,ev()}});e.observe(eh.current);let t=new ResizeObserver(e=>{for(let t of e){let{inlineSize:e}=t.borderBoxSize[0];eh.current.style.width=`${e}px`}});return t.observe(ep.current),()=>{e.disconnect(),t.disconnect()}}},[ev]),(0,r.useEffect)(()=>{let e=()=>{let e=ep.current;!e||eg.current||(eb.current=e.scrollHeight-e.clientHeight-e.scrollTop>100)},t=ep.current;if(t)return t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)},[]);let ew=(0,r.useRef)(void 0);(0,r.useEffect)(()=>{let e=y[0]?.id;(y.length<=1||e&&ew.current!==e)&&(eb.current=!1),ew.current=e},[y]),(0,r.useEffect)(()=>{if(!J){let e=setTimeout(ex,200);return()=>clearTimeout(e)}},[ex,J]);let ey=b?.suggested_questions_after_answer?.enabled&&!!L?.length&&g;return(0,t.jsx)(f,{readonly:h,config:b,chatList:y,isResponding:A,showPromptLog:P,questionIcon:I,answerIcon:C,onSend:g,onRegenerate:w,onAnnotationAdded:q,onAnnotationEdited:D,onAnnotationRemoved:O,disableFeedback:H,onFeedback:F,getHumanInputNodeData:er,children:(0,t.jsxs)("div",{"data-testid":"chat-root",className:(0,u.cn)("relative h-full",p&&"flex flex-col"),children:[(0,t.jsxs)("div",{"data-testid":"chat-container",ref:ep,className:(0,u.cn)("relative h-full overflow-y-auto overflow-x-hidden",p&&"h-0 grow",E),children:[V,(0,t.jsx)("div",{ref:ef,className:(0,u.cn)("w-full",!Q&&"px-8",N,p&&"px-0"),children:y.map((e,a)=>{if(e.isAnswer){let r=e.id===y.at(-1)?.id;return(0,t.jsx)(_.default,{appData:m,item:e,question:y[a-1]?.content,index:a,config:b,answerIcon:C,responding:r&&A,showPromptLog:P,chatAnswerContainerInner:X,hideProcessDetail:U,noChatInput:B,switchSibling:z,hideAvatar:ee,onHumanInputFormSubmit:ea},e.id)}return(0,t.jsx)(S,{item:e,questionIcon:I,theme:G?.theme,enableEdit:b?.questionEditEnable,switchSibling:z,hideAvatar:ee},e.id)})})]}),(0,t.jsx)("div",{"data-testid":"chat-footer",className:`absolute bottom-0 z-10 flex justify-center bg-chat-input-mask ${(ey||!B||!M)&&T}`,ref:eh,children:(0,t.jsxs)("div",{ref:em,className:(0,u.cn)("relative",j,p&&"px-0"),children:[!M&&A&&(0,t.jsx)("div",{"data-testid":"stop-responding-container",className:"mb-2 flex justify-center",children:(0,t.jsxs)(l.default,{className:"border-components-panel-border bg-components-panel-bg text-components-button-secondary-text",onClick:k,children:[(0,t.jsx)("div",{className:"i-custom-vender-solid-mediaAndDevices-stop-circle mr-[5px] h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-xs font-normal",children:es("operation.stopResponding",{ns:"appDebug"})})]})}),ey&&(0,t.jsx)(R,{suggestedQuestions:L,onSend:g}),!B&&(0,t.jsx)(d.default,{botName:m?.site?.title||"Bot",disabled:$,showFeatureBar:K,showFileUpload:Z,featureBarDisabled:A,onFeatureBarClick:W,visionConfig:b?.file_upload,speechToTextConfig:b?.speech_to_text,onSend:g,inputs:v,inputsForm:x,theme:G?.theme,isResponding:A,readonly:h,sendOnEnter:et})]})}),eo&&!Y&&(0,t.jsx)(c.default,{width:e_,currentLogItem:en,onCancel:()=>{ei(),el(!1)}}),ec&&!Y&&(0,t.jsx)(o.default,{width:e_,currentLogItem:en,onCancel:()=>{ei(),eu(!1)}})]})})});e.s(["default",0,M],34510)}]);