PageSourceSearch

https://www.svgai.org/_next/static/chunks/598.41ac0c98599885b0.js

js svgai.org collected 2026-10-04 08:36:59 UTC 9,988 bytes, 17 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[598],{10651:(e,t,r)=>{r.d(t,{JX:()=>c,N$:()=>s,OD:()=>o,pc:()=>n,zx:()=>a});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 o extends i{constructor(e,t="FILE_VALIDATION_FAILED"){super(e,t,400)}}class a extends i{constructor(e,t="CONVERSION_FAILED"){super(e,t,500)}}class s 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 n 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 l={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")?l.TIMEOUT:t.includes("network")||t.includes("fetch")?l.NETWORK_ERROR:t.includes("encoding")||t.includes("decode")?l.ENCODING_ERROR:e.message}return"An unexpected error occurred. Please try again."}},90598:(e,t,r)=>{r.d(t,{htmlToSvgHandler:()=>n});var i=r(10651),o=r(90816),a=r(44134).Buffer;class s extends o.k{async loadLibraries(){try{{let e=await r.e(2699).then(r.t.bind(r,52699,23));this.html2canvas=e.default}}catch(e){throw new i.zx("Failed to load html2canvas library","LIBRARY_LOAD_FAILED")}}validateHtmlInput(e){let t=("string"==typeof e?e:e.toString("utf8")).trim();if(!t.includes("<")||!t.includes(">"))throw new i.OD("Invalid HTML: Missing HTML tags");return t}normalizeInput(e){return"string"==typeof e?a.from(e,"utf8"):e}async createHtmlFrame(e,t,r){let o=document.createElement("template");for(let t of(o.innerHTML=e,o.content.querySelectorAll("script,noscript,template,iframe,object,embed,link,meta,base,animate,animateTransform,animateMotion,set").forEach(e=>e.remove()),Array.from(o.content.querySelectorAll("*"))))for(let e of Array.from(t.attributes))/^on/i.test(e.name)||["srcdoc","action","formaction","srcset","ping"].includes(e.name.toLowerCase())?t.removeAttribute(e.name):!["src","href","poster","background"].includes(e.localName.toLowerCase())||"a"!==t.localName&&("href"===e.localName&&e.value.startsWith("#")||/^data:image\/(png|jpe?g|gif|webp|svg\+xml);/i.test(e.value))||t.removeAttribute(e.name);let a=document.createElement("iframe");a.setAttribute("sandbox","allow-same-origin"),a.setAttribute("aria-hidden","true"),a.style.cssText=`position:fixed;left:-100000px;top:0;width:${t}px;height:${r}px;border:0;pointer-events:none;`;let s=new Promise((e,t)=>{let r=window.setTimeout(()=>
1{a.remove(),t(new i.zx("HTML preview took too long to load.","HTML_PREVIEW_TIMEOUT"))},1e4);a.onload=()=>{window.clearTimeout(r),e()},a.onerror=()=>{window.clearTimeout(r),a.remove(),t(new i.zx("Unable to load the isolated HTML preview.","HTML_PREVIEW_FAILED"))}});return a.srcdoc=`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; connect-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; form-action 'none'; base-uri 'none';"><style>html,body{margin:0;}</style></head><body>${o.innerHTML}</body></html>`,document.body.appendChild(a),await s,a}checkComputedResources(e){let t=e.contentDocument,r=e.contentWindow;for(let e of Array.from(t.querySelectorAll("*")))for(let t of[null,"::before","::after"]){let o=r.getComputedStyle(e,t);for(let e of["background-image","border-image-source","list-style-image","content"])for(let t of o.getPropertyValue(e).matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/gi))if(!/^data:image\//i.test(t[1]))throw new i.OD("External CSS images are not loaded. Embed images as data URLs in the HTML before converting.")}}canvasToSvg(e,t){let r=e.width,i=e.height,o=e.toDataURL("image/png");return`<svg xmlns="http://www.w3.org/2000/svg" 
2      width="${r}" 
3      height="${i}" 
4      viewBox="0 0 ${r} ${i}">
5      <defs>
6        <style>
7          @namespace svg url(http://www.w3.org/2000/svg);
8        </style>
9      </defs>
10      <image 
11        x="0" 
12        y="0" 
13        width="${r}" 
14        height="${i}" 
15        href="${o}" 
16        preserveAspectRatio="none"/>
17    </svg>`}async performConversionWithLibraries(e,t){if("undefined"==typeof document)throw new i.zx("HTML to SVG conversion requires a browser environment","BROWSER_REQUIRED");let r=this.validateHtmlInput(e),o=t.width??t.viewportWidth??800,s=t.height??t.viewportHeight??600,n=t.scale??2;if(![o,s,n].every(e=>Number.isFinite(e)&&e>0)||o*n>16384||s*n>16384||o*s*n*n>64e6)throw new i.OD("Choose positive dimensions with an output no larger than 16,384 pixels per side and 64 megapixels.");if(t.textToPaths)throw new i.OD("HTML to SVG creates an embedded PNG image; converting text to editable paths is not supported.");let l=null;try{if(l=await this.createHtmlFrame(r,o,s),!l.contentDocument?.documentElement)throw Error("The HTML preview is unavailable.");this.checkComputedResources(l),this.reportProgress(t,.5);let e={scale:n,width:o,height:s,backgroundColor:t.backgroundColor||"#ffffff",logging:t.logging||!1,useCORS:!1,allowTaint:!1,windowWidth:o,windowHeight:s,foreignObjectRendering:t.useForeignObject||!1},i=await this.html2canvas(l.contentDocument.documentElement,e);this.reportProgress(t,.8);let c=this.canvasToSvg(i,t),h=a.from(c,"utf8");return{...this.createSuccessResult(h,"image/svg+xml",{width:i.width,height:i.height,scale:n,embedMethod:"raster-image",editablePaths:!1}),warning:"This SVG contains a PNG screenshot. Text and shapes are not editable vector paths. Scripts, external images, stylesheets, and remote fonts are not loaded."}}catch(e){if(e instanceof Error)throw new i.zx(`HTML to SVG conversion failed: ${e.message}`,"HTML_TO_SVG_FAILED");throw new i.zx("An unexpected error occurred during HTML to SVG conversion","HTML_TO_SVG_UNKNOWN_ERROR")}finally{l?.remove()}}constructor(...e){super(...e),this.name="HTML to SVG",this.from="html",this.to="svg",this.description="Capture HTML as a PNG image embedded in an SVG file",this.html2canvas=null}}let n=new s().handler},90816:(e,t,r)=>{r.d(t,{I:()=>s,k:()=>n});var i=r(10651),o=r(119),a=r(44134).Buffer;class s{get handler(){return this.handleConversion.bind(this)}async handleConversion(e,t={}){let r;try{let i=this.normalizeInput(e);r=i.length,Date.now(),await this.trackConversionStart(r,t),await this.validateInput(i,t),this.reportProgress(t,.1),await this.trackConversionProgress(.1);let o=await this.performConversion(i,t);return this.reportProgress(t,1),await this.trackConversionProgress(1),await this.trackConversionComplete(!0,o,void 0,r),o}catch(e){if(await this.trackConversionComplete(!1,null,e,r),e instanceof i.zx||e instanceof i.OD)throw e;throw new i.zx((0,i.JX)(e),`${this.from.toUpperCase()}_TO_${this.to.toUpperCase()}_FAILED`)}}normalizeInput(e){return"string"==typeof e?a.from(e,"base64"):e}
17async validateInput(e,t){let r=(0,o.nJ)(e,{allowedFormats:[this.from],targetFormat:this.to});if(!r.isValid)throw new i.OD(r.error);let a=(0,o.XN)(this.from,this.to);if(!a.supported)throw new i.zx(a.reason,"UNSUPPORTED_CONVERSION");let s=(0,o.Ln)(t,this.from,this.to);if(!s.isValid)throw new i.zx(s.error,"INVALID_PARAMETERS")}reportProgress(e,t){if(e.onProgress&&"function"==typeof e.onProgress)try{e.onProgress(Math.min(1,Math.max(0,t)))}catch(e){}}async trackConversionStart(e,t){try{let{trackConversionStart:i}=await r.e(5804).then(r.bind(r,45804));i(this.name,this.from,this.to,e,t)}catch{}}async trackConversionProgress(e){try{let{trackConversionProgress:t}=await r.e(5804).then(r.bind(r,45804));t(this.name,this.from,this.to,e)}catch{}}async trackConversionComplete(e,t,i,o){try{let{trackConversionComplete:o}=await r.e(5804).then(r.bind(r,45804));o(this.name,this.from,this.to,e,t,i)}catch{}}async trackLibraryLoad(e,t,i,o){try{let{trackLibraryLoad:a}=await r.e(5804).then(r.bind(r,45804));a(this.name,e,t,i,o)}catch{}}createSuccessResult(e,t,r){return{success:!0,data:e,mimeType:t,metadata:{format:this.to,size:"string"==typeof e?a.byteLength(e,"utf8"):e.length,...r}}}getOutputMimeType(){return({png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",svg:"image/svg+xml",pdf:"application/pdf",ico:"image/x-icon",tiff:"image/tiff",eps:"application/postscript",ai:"application/illustrator",dxf:"application/dxf",stl:"model/stl",avif:"image/avif",cdr:"application/x-coreldraw",mp4:"video/mp4",html:"text/html",ttf:"font/ttf",emf:"image/x-emf",wmf:"image/x-wmf",image:"application/octet-stream"})[this.to]||"application/octet-stream"}constructor(){this.isClientSide=!0,this.isPremium=!1}}class n extends s{async ensureLibrariesLoaded(){if(this.libraryLoaded)return;if(this.loadingPromise)return void await this.loadingPromise;let e=Date.now();this.loadingPromise=this.loadLibraries().then(async()=>{this.libraryLoaded=!0;let t=Date.now()-e;await this.trackLibraryLoad("main",t,!0)}).catch(async t=>{this.loadingPromise=null;let r=Date.now()-e;throw await this.trackLibraryLoad("main",r,!1,t.message),new i.zx(`Failed to load required libraries for ${this.name}: ${t.message}`,"LIBRARY_LOAD_FAILED")}),await this.loadingPromise}async performConversion(e,t){await this.ensureLibrariesLoaded(),this.reportProgress(t,.3),await this.trackConversionProgress(.3);let r=await this.performConversionWithLibraries(e,t);return this.reportProgress(t,.9),await this.trackConversionProgress(.9),r}constructor(...e){super(...e),this.libraryLoaded=!1,this.loadingPromise=null}}}}]);

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.