PageSourceSearch

https://erobella.com/_nuxt/DPW9WYez.js

js erobella.com collected 2026-09-24 10:05:47 UTC 7,241 bytes, 1 lines download raw bytes

1import{P as A,E as u,$ as O}from"./-6Lls737.js";const c=5*1024*1024,D=3,M=1e3,N=()=>{const y=A().public.apiOriginUrl,R=async(t={})=>{try{const{page:o=1,perPage:s=50,mediaType:n}=t;let l=`${u.MEDIA_REPOSITORY.LIST}?page=${o}&per_page=${s}`;n&&(l+=`&media_type=${n}`);const e=await O(l,{method:"GET"});return e.error?{response:null,error:e.error}:{response:e.response,error:null}}catch(o){return console.error("Get repository media error:",o),{response:null,error:{message:(o==null?void 0:o.message)||"Failed to fetch media repository",status:(o==null?void 0:o.status)||(o==null?void 0:o.statusCode)}}}},T=async t=>{var o,s;try{t.name,t.type,t.size;const n=new FormData;n.append("image",t);const l=await $fetch(`${y}${u.MEDIA_REPOSITORY.UPLOAD_IMAGE}`,{method:"POST",body:n,credentials:"include"});return{response:l.data,error:null}}catch(n){return console.error("Image upload error:",n),{response:null,error:{message:((o=n==null?void 0:n.data)==null?void 0:o.message)||(n==null?void 0:n.message)||"Failed to upload image",errors:(s=n==null?void 0:n.data)==null?void 0:s.errors,status:(n==null?void 0:n.status)||(n==null?void 0:n.statusCode)}}}},$=async t=>{var o;try{const s=Math.ceil(t.size/c);return t.name,t.size,{response:(await $fetch(`${y}${u.MEDIA_REPOSITORY.INIT_CHUNKED}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t.name,fileSize:t.size,mimeType:t.type,totalChunks:s,chunkSize:c})})).data,error:null}}catch(s){return console.error("Init chunked upload error:",s),{response:null,error:{message:((o=s==null?void 0:s.data)==null?void 0:o.message)||(s==null?void 0:s.message)||"Failed to initialize upload",status:(s==null?void 0:s.status)||(s==null?void 0:s.statusCode)}}}},f=async(t,o,s,n=0)=>{var l;try{const e=new FormData;return e.append("chunk",s),e.append("chunkIndex",o.toString()),e.append("sessionId",t),{response:await $fetch(`${y}${u.MEDIA_REPOSITORY.UPLOAD_CHUNK}`,{method:"POST",credentials:"include",body:e}),error:null}}catch(e){return console.error(`Chunk ${o} upload error (attempt ${n+1}):`,e),n<D?(await new Promise(a=>setTimeout(a,M*(n+1))),f(t,o,s,n+1)):{response:null,error:{message:((l=e==null?void 0:e.data)==null?void 0:l.message)||(e==null?void 0:e.message)||`Failed to upload chunk ${o}`,status:(e==null?void 0:e.status)||(e==null?void 0:e.statusCode),chunkIndex:o}}}},_=async t=>{var o;try{return{response:(await $fetch(`${y}${u.MEDIA_REPOSITORY.FINALIZE}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t})})).data,error:null}}catch(s){return console.error("Finalize chunked upload error:",s),{response:null,error:{message:((o=s==null?void 0:s.data)==null?void 0:o.message)||(s==null?void 0:s.message)||"Failed to finalize upload",status:(s==null?void 0:s.status)||(s==null?void 0:s.statusCode)}}}};return{getRepositoryMedia:R,uploadImageToRepository:T,uploadVideoToRepository:async(t,o,s)=>{if(s!=null&&s.aborted)return{response:null,error:{message:"Upload cancelled"}};if(t.size<=10485760)try{return t.name,t.size,await new Promise(e=>{const a=new XMLHttpRequest,d=new FormData;d.append("video",t),s&&s.addEventListener("abort",()=>{a.abort(),e({response:null,error:{message:"Upload cancelled"}})}),a.upload.addEventListener("progress",r=>{if(r.lengthComputable&&o){const h=Math.round(r.loaded/r.total*100);o(h)}}),a.addEventListener("abort",()=>{e({response:null,error:{message:"Upload cancelled"}})}),a.addEventListener("load",()=>{if(a.status>=200&&a.status<300)try{const r=JSON.parse(a.responseText);e({response:r.data,error:null})}catch{e({response:null,error:{message:"Failed to parse server response",status:a.status}})}else{const r=a.responseText?JSON.parse(a.responseText):{};e({response:null,error:{message:(r==null?void 0:r.message)||"Failed to upload video",errors:r==null?void 0:r.errors,status:a.status}})}}),a.addEventListener("error",()=>{e({response:null,error:{message:"Network error occurred",status:0}})}),a.open("POST",`${y}${u.MEDIA_REPOSITORY.UPLOAD_VIDEO}`),a.withCredentials=!0,a.send(d)})}catch(e){return console.error("Video upload error:",e),{response:null,error:{message:(e==null?void 0:e.message)||"Failed to upload video",status:0}}}try{t.name,t.size,t.type;const e=await $(t);if(e.error||!e.response)return{response:null,error:e.error};const a=e.response,d=Math.ceil(t.size/c),r=new Set,h=new Map;`${a.upload_session_id}${d}`;const z=async i=>{const p=i*c,m=Math.min(p+c,t.size),S=t.slice(p,m),E=await f(a.upload_session_id,i,S);if(E.error)h.set(i,E.error);
1else if(r.add(i),o){const C=Math.round(r.size/d*90);o(C)}};for(let i=0;i<d;i+=3){if(s!=null&&s.aborted)return{response:null,error:{message:"Upload cancelled"}};const p=[];for(let m=0;m<3&&i+m<d;m++)p.push(i+m);await Promise.all(p.map(z))}if(h.size>0){if(s!=null&&s.aborted)return{response:null,error:{message:"Upload cancelled"}};console.warn(`${h.size} chunks failed, retrying...`);for(const i of Array.from(h.keys())){const p=i*c,m=Math.min(p+c,t.size),S=t.slice(p,m),E=await f(a.upload_session_id,i,S);if(E.error)return{response:null,error:{message:`Upload failed at chunk ${i+1}/${d}`,details:E.error}};r.add(i),o&&o(Math.round(r.size/d*90))}}if(r.size!==d)return{response:null,error:{message:`Only ${r.size}/${d} chunks uploaded`}};o&&o(95);const g=await _(a.upload_session_id);return g.error||!g.response?{response:null,error:g.error}:(o&&o(100),g.response,{response:g.response,error:null})}catch(e){return console.error("Chunked upload error:",e),{response:null,error:{message:(e==null?void 0:e.message)||"Chunked upload failed",status:0}}}},deleteFromRepository:async t=>{var o;try{return{response:await $fetch(`${y}${u.MEDIA_REPOSITORY.DELETE(t)}`,{method:"DELETE",credentials:"include"}),error:null}}catch(s){return console.error("Delete from repository error:",s),{response:null,error:{message:((o=s==null?void 0:s.data)==null?void 0:o.message)||(s==null?void 0:s.message)||"Failed to delete media",status:(s==null?void 0:s.status)||(s==null?void 0:s.statusCode)}}}},sendRepositoryMedia:async(t,o,s=0,n="")=>{var l;try{const e=await O(u.MEDIA_REPOSITORY.SEND_TO_CONVERSATION(t),{method:"POST",body:JSON.stringify({repositoryMediaIds:o,price:s,content:n}),headers:{"Content-Type":"application/json"}});return e.error?{response:null,error:e.error}:(e.response,{response:(l=e.response)==null?void 0:l.data,error:null})}catch(e){return console.error("Send repository media error:",e),{response:null,error:{message:(e==null?void 0:e.message)||"Failed to send media from repository",status:(e==null?void 0:e.status)||(e==null?void 0:e.statusCode)}}}},sendMediaToUsers:async(t,o,s=0,n="")=>{var l;try{const e=await $fetch(`${y}${u.MEDIA_REPOSITORY.SEND_TO_USERS}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({repositoryMediaIds:t,recipientUserIds:o,price:s,content:n})});return{response:e,error:null}}catch(e){return console.error("Send media to users error:",e),{response:null,error:{message:((l=e==null?void 0:e.data)==null?void 0:l.message)||(e==null?void 0:e.message)||"Failed to send media to users",status:(e==null?void 0:e.status)||(e==null?void 0:e.statusCode)}}}},CHUNK_SIZE:c}};export{N as useMediaRepository};

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.