1import{_ as E}from"./index-C6-4kgOT.js";import"./vendor-react--UDKce57.js";const M=16*1024*1024,d=15*1024*1024,F=120*1024*1024,N=9e4,O=15e3,A=["-pix_fmt","yuv420p","-colorspace","bt709","-color_primaries","bt709","-color_trc","bt709","-color_range","tv"];let m=null,f=null,P=Promise.resolve(),L=0,g=0;async function S(){const{FFmpeg:e}=await E(async()=>{const{FFmpeg:o}=await import("./index-BWXEABTF.js");return{FFmpeg:o}},[]),{fetchFile:r}=await E(async()=>{const{fetchFile:o}=await import("./index-DRPQNq22.js");return{fetchFile:o}},[]);if(!m){const o=new e;f=o;let t=null;try{await Promise.race([o.load({coreURL:location.origin+"/ffmpeg-core/ffmpeg-core.js?v=esm1",wasmURL:location.origin+"/ffmpeg-core/ffmpeg-core.wasm?v=esm1"}),new Promise((a,n)=>{t=setTimeout(()=>n(new Error("failed to fetch: el conversor no llegó a tiempo")),N)})])}catch(a){try{o.terminate()}catch{}throw a}finally{t&&clearTimeout(t),f===o&&(f=null)}m=o}return{ff:m,fetchFile:r}}async function C(e){if(/quicktime|\.mov$/i.test(String(e.type||"")+" "+String(e.name||"")))return!0;try{const r=new Uint8Array(await e.slice(0,12).arrayBuffer());return String.fromCharCode(r[8],r[9],r[10],r[11]).trim().toLowerCase()==="qt"}catch{return!1}}async function T(e){try{const r=[e.slice(0,1048576)];e.size>2*1024*1024&&r.push(e.slice(e.size-1024*1024));for(const o of r){const t=new Uint8Array(await o.arrayBuffer());for(let a=0;a+4<=t.length;a++)if(t[a]===104&&t[a+3]===49&&(t[a+1]===118&&t[a+2]===99||t[a+1]===101&&t[a+2]===118))return!0}}catch{}return!1}async function x(e){const r=URL.createObjectURL(e);try{return await new Promise(o=>{const t=document.createElement("video"),a=setTimeout(()=>o(0),O),n=i=>{clearTimeout(a),o(i)};t.preload="metadata",t.onloadedmetadata=()=>n(Number.isFinite(t.duration)?t.duration:0),t.onerror=()=>n(0),t.src=r})}catch{return 0}finally{URL.revokeObjectURL(r)}}async function k(e){return e.size>d||await C(e)||await T(e)?!0:String(e.type||"").toLowerCase()!=="video/mp4"}function V(e){return(String(e.name||"").replace(/\.[\w]+$/,"").trim()||"video").slice(0,60)+".mp4"}async function B(e,r=()=>{}){const o=g,t=()=>{if(o!==g)throw new Error("cancelado")};if(!await k(e))return t(),e;if(t(),e.size>F)throw new Error("demasiado-grande:"+e.size);const a=await x(e);if(t(),e.size>M&&a>0&&d*8/a/1e3<250)throw new Error("muy-largo:"+Math.round(a));t();const n=P.then(async()=>{t();const{ff:i,fetchFile:R}=await S();t();const p="wain_"+ ++L,y=[],v=({progress:l})=>r(Math.max(1,Math.min(99,Math.round((l||0)*100))));i.on("progress",v);try{await i.writeFile(p,await R(e));const l=["-map","0:v:0","-map","0:a:0?"],h=async s=>{const u="waout_"+L+"_"+y.length+".mp4";y.push(u);const w=await i.exec(["-i",p,...l,...s,"-movflags","+faststart","-y",u]);if(t(),typeof w=="number"&&w!==0)throw new Error("ffmpeg terminó con "+w);const _=(await i.readFile(u)).slice();if(!_.byteLength)throw new Error("la conversión salió vacÃa");return _},b=(s,u)=>["-vf","scale=w="+s+":h="+s+":force_original_aspect_ratio=decrease:force_divisible_by=2","-c:v","libx264","-crf",u,"-preset","veryfast",...A,"-c:a","aac","-b:a","128k"];let c=await h(b(1280,"26"));if(c.byteLength>d)try{c=await h(b(960,"28"))}catch{t()}if(c.byteLength>d&&a>1){const s=Math.max(120,Math.floor(d*8/a/1e3)-128);try{c=await h(["-vf","scale=w=854:h=854:force_original_aspect_ratio=decrease:force_divisible_by=2","-c:v","libx264","-b:v",s+"k","-maxrate",s+"k","-bufsize",s*2+"k","-preset","veryfast",...A,"-c:a","aac","-b:a","96k"])}catch{t()}}if(c.byteLength>M)throw new Error("no-cabe:"+c.byteLength+":"+Math.round(a));return t(),new File([c],V(e),{type:"video/mp4"})}finally{i.off("progress",v);try{await i.deleteFile(p)}catch{}for(const l of y)try{await i.deleteFile(l)}catch{}}});return P=n.catch(()=>{}),n}function U(){g++;const e=m,r=f;m=null,f=null;try{e==null||e.terminate()}catch{}try{r!==e&&(r==null||r.terminate())}catch{}}function W(e){const r=String((e==null?void 0:e.message)||e||"").toLowerCase();if(/terminate|cancelad/.test(r))return"";if(r.startsWith("demasiado-grande:"))return"Ese video pesa "+Math.round(Number(r.split(":")[1]||0)/1048576)+" MB y es demasiado para prepararlo aquÃ. Mándalo más corto, o grábalo en menor resolución.";if(r.startsWith("muy-largo:")){const o=Number(r.split(":")[1]||0),t=Math.floor(o/60),a=o%60;return"Ese video dura "+(t?t+" minuto"+(t===1?"":"s")+(a?" y "+a+" segundos":""):o+" segundos")+" y WhatsApp admite 16 MB: para que quepa quedarÃa casi sin calidad. Mándalo en partes o más corto."}if(r.startsWith("no-cabe:")){const[,o,t]=r.split(":"),a=Math.round(Number(o||0)/1048576),n=Number(t||0)>0?" Dura "+t+" segundos:":"";return"Aun comprimido pesa "+a+" MB y WhatsApp admite 16."+n+" m
1ándalo en dos partes o más corto."}return/failed to import/.test(r)?"El conversor de video no arrancó bien. No es culpa de tu archivo ni de tu conexión: ya quedó reportado. Mientras tanto, manda el video ya en MP4 y de menos de 16 MB.":/failed to fetch|networkerror|load failed|importscripts|ffmpeg-core|dynamically imported/.test(r)?"No se pudo cargar el conversor de video (son unos 30 MB). Revisa tu conexión y vuelve a intentarlo; si estás en datos, intenta con wifi.":/out of memory|memory access out of bounds|allocation|maximum call stack|aborted|rangeerror/.test(r)?"A tu celular se le acabó la memoria preparando el video. Cierra otras pestañas y vuelve a intentarlo, o mándalo más corto.":/invalid data|moov atom|does not contain|no such file|unsupported|decoder|codec/.test(r)?"Ese archivo no se pudo leer como video: puede estar dañado o incompleto. Vuelve a grabarlo o elÃgelo de nuevo.":"No se pudo preparar el video en tu celular. Vuelve a intentarlo; si sigue fallando, mándalo más corto."}export{F as MAXIMO_PARA_INTENTAR,M as TOPE_WHATSAPP,U as cancelarPreparacion,x as duracionDeVideo,k as hayQueConvertir,T as pareceHEVC,C as pareceQuickTime,W as porQueNoSePudo,B as prepararVideoParaWhatsApp};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.