1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9358],{49358:(e,t,r)=>{r.d(t,{svgToPdfHandler:()=>i});var a=r(10651),n=r(44134).Buffer;async function o(e,t,r){return new Promise((n,o)=>{let i=document.createElement("canvas");i.width=t,i.height=r;let s=i.getContext("2d");if(!s)return void o(new a.zx("Failed to create canvas context"));let g=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(g),c=new Image;c.onload=()=>{try{s.fillStyle="white",s.fillRect(0,0,t,r),s.drawImage(c,0,0,t,r),URL.revokeObjectURL(l),n(i)}catch(e){URL.revokeObjectURL(l),o(e)}},c.onerror=()=>{URL.revokeObjectURL(l),o(new a.zx("Failed to load SVG image"))},c.crossOrigin="anonymous",c.src=l})}let i=async(e,t={})=>{try{let i=function(e){if("string"==typeof e){let t=e.trim();if(!t.includes("<svg")&&!t.includes("<?xml"))throw new a.OD("Invalid SVG: Missing SVG tag");return t}let t=n.from(e).toString("utf-8").trim();if(!t.includes("<svg")&&!t.includes("<?xml"))throw new a.OD("Invalid SVG: Missing SVG tag");return t}(e);t.onProgress&&t.onProgress(.1);let{jsPDF:s}=await Promise.all([r.e(1260),r.e(6597)]).then(r.bind(r,26597)),g=function(e){let t=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;if("parsererror"===t.tagName)throw new a.OD("Invalid SVG: Parse error");let r=parseInt(t.getAttribute("width")||"0"),n=parseInt(t.getAttribute("height")||"0");if(!r||!n){let e=t.getAttribute("viewBox");if(e){let[,,t,a]=e.split(" ").map(Number);r=r||t,n=n||a}}return r&&n||(r=r||800,n=n||600),{width:r,height:n}}(i),l=t.orientation||"portrait",c=t.pageFormat||"a4",d=t.margin||10,m=t.scale||1;t.onProgress&&t.onProgress(.3);let h=new s({orientation:l,unit:"mm",format:c}),u=h.internal.pageSize.getWidth(),f=h.internal.pageSize.getHeight(),w=u-2*d,p=f-2*d,P=w/g.width,v=p/g.height,b=Math.min(P,v)*m,S=g.width*b,x=g.height*b,y=Math.round(2*S*3.78),O=Math.round(2*x*3.78);t.onProgress&&t.onProgress(.5);let D=await o(i,y,O);t.onProgress&&t.onProgress(.7);let F=D.toDataURL("image/png",t.quality||.95);h.addImage(F,"PNG",d+(w-S)/2,d+(p-x)/2,S,x),t.onProgress&&t.onProgress(.9);let G=h.output("arraybuffer"),L=n.from(G);return t.onProgress&&t.onProgress(1),{success:!0,data:L,mimeType:"application/pdf",warning:"This PDF contains a raster image of your SVG. Text and shapes are not preserved as editable vector objects.",metadata:{width:Math.round(S),height:Math.round(x),format:"pdf",size:L.length,pageFormat:c,orientation:l,originalFormat:"svg",embedMethod:"raster-image",editablePaths:!1,scale:b}}}catch(e){if(e instanceof a.zx||e instanceof a.OD)throw e;throw new a.zx(`SVG to PDF conversion failed: ${e instanceof Error?e.message:"Unknown error"}`,"SVG_TO_PDF_FAILED")}}}}]);
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.