PageSourceSearch

https://www.svgai.org/_next/static/chunks/1766.68814bcf009dc1f3.js

js svgai.org collected 2026-10-04 08:37:17 UTC 4,536 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1766],{10651:(e,t,r)=>{r.d(t,{JX:()=>c,N$:()=>o,OD:()=>s,pc:()=>a,zx:()=>n});class i extends Error{constructor(e,t,r=400){super(e),this.name=this.constructor.name,this.code=t,this.statusCode=r,Object.setPrototypeOf(this,new.target.prototype)}}class s extends i{constructor(e,t="FILE_VALIDATION_FAILED"){super(e,t,400)}}class n extends i{constructor(e,t="CONVERSION_FAILED"){super(e,t,500)}}class o extends i{constructor(e,t,r){super(r||(e?`Format '${e}' is not supported`:"Unsupported file format"),"UNSUPPORTED_FORMAT",400),this.format=e,this.supportedFormats=t}}class a extends i{constructor(e,t){super(e?`The ${e.toUpperCase()} file appears to be corrupted or invalid. ${t||"Please try with a different file."}`:`The file appears to be corrupted or invalid. ${t||"Please try with a different file."}`,"CORRUPTED_FILE",400)}}let h={NETWORK_ERROR:"Network error occurred during conversion",TIMEOUT:"Conversion timed out. Please try with a smaller file",ENCODING_ERROR:"Unable to process the file encoding. Please ensure the file is not corrupted."};function c(e){if(e instanceof i)return e.message;if(e instanceof Error){let t=e.message.toLowerCase();return t.includes("memory")||t.includes("heap")?"The file is too large to process. Please try with a smaller file or reduce its dimensions.":t.includes("timeout")?h.TIMEOUT:t.includes("network")||t.includes("fetch")?h.NETWORK_ERROR:t.includes("encoding")||t.includes("decode")?h.ENCODING_ERROR:e.message}return"An unexpected error occurred. Please try again."}},51766:(e,t,r)=>{r.d(t,{svgToPngHandler:()=>a});var i=r(10651),s=r(119),n=r(44134).Buffer;let o="undefined"!=typeof document,a=async(e,t={})=>{if(o)try{let{svgToPngHandler:i}=await r.e(2481).then(r.bind(r,27243));return i(e,t)}catch(e){throw new i.zx("Failed to load browser-based SVG to PNG converter","BROWSER_HANDLER_LOAD_FAILED")}try{let r=await Promise.resolve().then(function(){var e=Error("Cannot find module 'sharp'");throw e.code="MODULE_NOT_FOUND",e}).then(e=>e.default).catch(e=>{throw new i.zx("This conversion requires server-side processing. Please use the API endpoint.","SERVER_ONLY_CONVERSION")}),o=function(e){if("string"==typeof e){let t=e.trim();if(!t.includes("<svg")&&!t.includes("<?xml"))throw new i.OD("Invalid SVG: Missing SVG tag");return t}let t=(0,s.ST)(e);if("svg"!==t)throw new i.N$(t||"unknown",["svg"],`Expected SVG format but received ${t||"unknown format"}`);return e.toString("utf8")}(e);t.onProgress&&t.onProgress(.1);let{svg:a,metadata:h}=function(e,t){let r={},i=e.match(/width="([^"]+)"/),s=e.match(/height="([^"]+)"/),n=e.match(/viewBox="([^"]+)"/),o=e;if(i){let e=parseFloat(i[1]);isNaN(e)||(r.width=e)}if(s){let e=parseFloat(s[1]);isNaN(e)||(r.height=e)}if(!r.width&&!r.height&&n){let[,,e,t]=n[1].split(" ").map(parseFloat);isNaN(e)||isNaN(t)||(r.width=e,r.height=t)}if(t.width||t.height){let e=t.width||r.width,n=t.height||r.height;e&&n&&(o=i?o.replace(/width="[^"]+"/,`width="${e}"`):o.replace("<svg",`<svg width="${e}"`),o=s?o.replace(/height="[^"]+"/,`height="${n}"`):o.replace("<svg",`<svg height="${n}"`),r.width=e,r.height=n)}return r.width&&r.height||(r.width=r.width||512,r.height=r.height||512,i||(o=o.replace("<svg",`<svg width="${r.width}"`)),s||(o=o.replace("<svg",`<svg height="${r.height}"`))),{svg:o,metadata:r}}(o,t),c=n.from(a,"utf8");t.onProgress&&t.onProgress(.3);let d=t.dpi||96,l=r(c,{density:d});if(t.background){let e=t.background.toLowerCase();"transparent"!==e&&(l=l.flatten({background:t.background}))}(t.width||t.height)&&!1!==t.preserveAspectRatio&&(l=l.resize(t.width||null,t.height||null,{fit:"inside",withoutEnlargement:!1})),t.onProgress&&t.onProgress(.7);let u=t.compressionLevel??6,g=t.quality??90,f=await l.png({compressionLevel:Math.min(9,Math.max(0,u)),quality:g,adaptiveFiltering:!0,palette:g<100}).toBuffer(),p=await r(f).metadata();return t.onProgress&&t.onProgress(1),{success:!0,data:f,mimeType:"image/png",metadata:{width:p.width,height:p.height,format:"png",size:f.length}}}catch(e){if(e instanceof i.OD||e instanceof i.N$)throw e;if(e instanceof Error){if(e.message.includes("Input buffer contains unsupported image format"))throw new i.OD("Invalid SVG format or corrupted file");if(e.message.includes("Input file is missing"))throw new i.OD("SVG input is empty or invalid");throw new i.zx(`SVG to PNG conversion failed: ${e.message}`,"SVG_TO_PNG_FAILED")}throw new i.zx("An unexpected error occurred during SVG to PNG conversion","SVG_TO_PNG_UNKNOWN_ERROR")}}}}]);

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.