PageSourceSearch

https://pixpal.ai/assets/upload-errors-C4nBwGZC.js

js pixpal.ai collected 2026-10-05 13:25:48 UTC 4,603 bytes, 1 lines download raw bytes

1import{$c as e,Dn as t,Qc as n,Tn as r,Zc as i,r_ as a}from"./messages-UbiuFgSo.js";import{Bt as o}from"./index-BWXA-IcU.js";var s=new Set([`svg`,`webp`,`png`,`jpg`,`jpeg`,`gif`,`avif`]),c=new Set([`mp4`,`webm`,`mov`,`avi`,`mkv`,`m4v`]);function l(e){return e.split(`.`).pop()?.toLowerCase()??``}function u(e){return(e.split(`?`)[0]??e).split(`.`).pop()?.toLowerCase()??``}function d(e){return!!e?.startsWith(`video/`)}function f(e,t){return d(t)?!0:c.has(u(e))}function p(e){if(e.type.startsWith(`image/`)||e.type.startsWith(`video/`))return!0;let t=l(e.name);return s.has(t)||c.has(t)}function m(e){return e.type.startsWith(`video/`)?!0:c.has(l(e.name))}var h=`image/*,.svg,video/mp4,video/webm,video/quicktime,video/x-msvideo`,g=new Set([`image/gif`,`image/svg+xml`]),_=new Set([`image/jpeg`,`image/jpg`]),v={maxSizeMB:1,maxWidthOrHeight:1024,useWebWorker:!0,fileType:`image/jpeg`},y={maxSizeMB:.35,maxWidthOrHeight:1024,initialQuality:.82,useWebWorker:!1,fileType:`image/webp`},b=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/avif`,`image/heic`,`image/heif`]),x={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,webp:`image/webp`,gif:`image/gif`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`};function S(e){if(e.type.startsWith(`image/`))return e;let t=e.name.split(`.`).pop()?.toLowerCase(),n=t?x[t]:void 0;return n?new File([e],e.name,{type:n,lastModified:e.lastModified}):e}async function C(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e),{width:n,height:r}=t;return t.close(),{width:n,height:r}}return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`Failed to load image`))},i.src=r})}async function w(e,t){let n=(t.maxSizeMB??1)*1024*1024,r=t.maxWidthOrHeight??1024;if(e.size>n)return!1;try{let{width:t,height:n}=await C(e);return t<=r&&n<=r}catch{return!1}}async function T(e){return g.has(e.type)||!_.has(e.type)?!1:w(e,v)}async function E(e,t){if(g.has(e.type))return e;let n=(await o(async()=>{let{default:e}=await import(`./browser-image-compression-20VQwcnM.js`);return{default:e}},[])).default;return n(e,t)}async function D(e){if(g.has(e.type)||await T(e))return{uploadFile:e,nsfwFile:e};let t=await E(e,v).catch(()=>e);return{uploadFile:t,nsfwFile:t}}function O(e){let t=e.trim(),n=t.lastIndexOf(`.`);return n>0?t.slice(0,n):t}async function k(e){if(e=S(e),g.has(e.type)||!b.has(e.type)||e.size<=524288)return e;try{let t=await E(e,y);if(t.size>=e.size&&e.type===`image/webp`)return e;let n=t.type===`image/webp`?`.webp`:``,r=n?`${O(e.name)}${n}`:e.name;return new File([t],r,{type:t.type||`image/webp`,lastModified:e.lastModified})}catch{return e}}var A=3e4;function j(e){return e.map(e=>e instanceof File?{file:e}:e)}async function M(e){try{return await Promise.race([k(e),new Promise((e,t)=>{setTimeout(()=>t(Error(`compress_timeout`)),A)})])}catch{return S(e)}}async function N(e,t,n){let r=j(t),i=new FormData;for(let{file:t,compressed:a}of r){let r=t,o=a;if(n?.compressForNsfw&&e.includes(`upload-image`)&&!o){let e=await D(t);r=e.uploadFile,o=e.nsfwFile===e.uploadFile?void 0:e.nsfwFile}i.append(`files`,r),o&&i.append(`compressed`,o)}let a=await fetch(e,{method:`POST`,body:i,credentials:`include`}),o=await a.json().catch(()=>({}));if(!a.ok||o.code!==0)throw Error(o.message||`Upload failed (${a.status})`);let s=o.data?.urls;if(!s?.length)throw Error(`Upload failed: empty response`);return s}async function P(e){let t=await Promise.all(e.map(e=>m(e)?Promise.resolve(e):M(e))),n=new FormData;for(let e of t)n.append(`files`,e);let r=await fetch(`/api/admin/media-library?upload=1`,{method:`POST`,body:n,credentials:`include`}),i=await r.json().catch(()=>({}));if(!r.ok||i.code!==0)throw Error(i.message||`Upload failed (${r.status})`);let a=i.data?.items;if(!a?.length)throw Error(i.message||`Upload failed: empty response`);return a}async function F(e){let t=await Promise.all(e.map(e=>M(e)));return{urls:await N(`/api/admin/upload-image`,t),files:t}}async function I(e,t){let n=await Promise.all(t.map(e=>k(e)));return{urls:await N(e,n),files:n}}var L=new Set([`nsfw_image_rejected`,`content_policy_violation`]);function R(o){return o===`network_error`||/failed to fetch/i.test(o)||/networkerror/i.test(o)?r():L.has(o)||/inappropriate content/i.test(o)?t():o===`Unauthorized`||o===`auth_required`?a():o===`Forbidden`?e():o===`compress_timeout`?n():/configure storage/i.test(o)?i():o}export{F as a,f as c,N as i,P as n,h as o,I as r,p as s,R as t};

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.