PageSourceSearch

https://www.svgai.org/_next/static/chunks/4863.613009d187f64511.js

js svgai.org collected 2026-10-04 08:37:58 UTC 5,402 bytes, 16 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4863],{10651:(e,t,r)=>{r.d(t,{JX:()=>d,N$:()=>n,OD:()=>i,pc:()=>a,zx:()=>o});class s 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 i extends s{constructor(e,t="FILE_VALIDATION_FAILED"){super(e,t,400)}}class o extends s{constructor(e,t="CONVERSION_FAILED"){super(e,t,500)}}class n extends s{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 s{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 d(e){if(e instanceof s)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."}},34863:(e,t,r)=>{r.d(t,{pdfToSvgHandler:()=>h});var s=r(10651),i=r(119),o=r(44134).Buffer;let n=null;async function a(){if(n)return n;try{let e=await r.e(3824).then(r.bind(r,13824));return e.GlobalWorkerOptions.workerSrc="/pdf.worker.min.js?v=5.3.93-ff6f6b3f",n=e}catch(e){throw new s.zx("Failed to load PDF.js library. Please try again or use server-side conversion.","PDFJS_LOAD_FAILED")}}let h=async(e,t={})=>{let r;try{let n,h,d="string"==typeof e?o.from(e,"base64"):e;if(!function(e){let t=(0,i.ST)(e);if(!t)throw new s.OD("Unable to detect file format. Make sure the file is a valid PDF.");if("pdf"!==t)throw new s.N$(t,["pdf"],`Expected PDF format but received ${t}. Please upload a valid PDF file.`);if(!e.toString("utf8",0,Math.min(1024,e.length)).match(/%PDF-\d\.\d/))throw new s.OD("Invalid PDF file structure. Missing PDF version header.")}(d),t.onProgress&&t.onProgress(.1),t.extractText)throw new s.OD("PDF to SVG embeds a PNG image of the selected page; editable text extraction is not supported.");let l=t.page??1,c=t.scale??2;if(!Number.isInteger(l)||l<1)throw new s.OD("Choose a whole page number starting at 1.");if(!Number.isFinite(c)||c<=0)throw new s.OD("PDF render scale must be a positive number.");for(let e of[t.width,t.height])if(void 0!==e&&(!Number.isFinite(e)||e<=0))throw new s.OD("Output dimensions must be positive numbers.");r=(await a()).getDocument({data:new Uint8Array(d)}),t.onProgress&&t.onProgress(.2);let u=await r.promise;if(l<1||l>u.numPages)throw new s.zx(`Invalid page number ${l}. PDF has ${u.numPages} pages.`,"INVALID_PAGE_NUMBER");let g=await u.getPage(l);t.onProgress&&t.onProgress(.4);let f=g.getViewport({scale:c});if(f.width>16384||f.height>16384||f.width*f.height>64e6)throw new s.OD("This page is too large to render. Reduce the scale to stay within 16,384 pixels per side and 64 megapixels.");if(!(h=(n=document.createElement("canvas")).getContext("2d")))throw new s.zx("Failed to get canvas context","CANVAS_CONTEXT_ERROR");n.width=f.width,n.height=f.height,t.onProgress&&t.onProgress(.6),await g.render({canvasContext:h,viewport:f}).promise,t.onProgress&&t.onProgress(.8);let p=function(e){let t=e.width,r=e.height,s=e.toDataURL("image/png");return`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg 
3  width="${t}" 
4  height="${r}" 
5  viewBox="0 0 ${t} ${r}"
6  version="1.1"
7  xmlns="http://www.w3.org/2000/svg"
8  xmlns:xlink="http://www.w3.org/1999/xlink">
9  <image 
10    x="0" 
11    y="0" 
12    width="${t}" 
13    height="${r}" 
14    preserveAspectRatio="none"
15    xlink:href="${s}" />
16</svg>`}(n);return(t.width||t.height)&&(p=function(e,t,r,s=!0){let i=e.match(/width="(\d+)"/),o=e.match(/height="(\d+)"/);if(!i||!o)return e;let n=parseInt(i[1]),a=parseInt(o[1]),h=t||n,d=r||a;if(s){let e=n/a;if(t&&!r)d=Math.round(t/e);else if(!t&&r)h=Math.round(r*e);else if(t&&r){let e=Math.min(t/n,r/a);h=Math.round(n*e),d=Math.round(a*e)}}return e.replace(/width="[^"]+"/,`width="${h}"`).replace(/height="[^"]+"/,`height="${d}"`).replace(/viewBox="[^"]+"/,`viewBox="0 0 ${n} ${a}"`)}(p,t.width,t.height,t.preserveAspectRatio??!0)),g.cleanup(),t.onProgress&&t.onProgress(1),{success:!0,data:p,mimeType:"image/svg+xml",warning:"This SVG contains a PNG image of the selected PDF page. Text and shapes are not editable vector paths.",metadata:{width:Number(p.match(/width="([^"]+)"/)?.[1]),height:Number(p.match(/height="([^"]+)"/)?.[1]),page:l,pageCount:u.numPages,embedMethod:"raster-image",editablePaths:!1,format:"svg",size:o.byteLength(p,"utf8")}}}catch(e){if(e instanceof s.OD||e instanceof s.N$||e instanceof s.zx)throw e;if(e instanceof Error)throw new s.zx(`PDF to SVG conversion failed: ${e.message}`,"PDF_TO_SVG_FAILED");throw new s.zx("An unexpected error occurred during PDF to SVG conversion","PDF_TO_SVG_UNKNOWN_ERROR")}finally{await r?.destroy()}}}}]);

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.