PageSourceSearch

https://www.svgai.org/_next/static/chunks/6554.414b5c09985099f4.js

js svgai.org collected 2026-10-04 08:38:11 UTC 11,462 bytes, 9 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6554],{10651:(e,t,r)=>{r.d(t,{JX:()=>c,N$:()=>a,OD:()=>o,pc:()=>n,zx:()=>s});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 s extends i{constructor(e,t="CONVERSION_FAILED"){super(e,t,500)}}class a 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."}},90816:(e,t,r)=>{r.d(t,{I:()=>a,k:()=>n});var i=r(10651),o=r(119),s=r(44134).Buffer;class a{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?s.from(e,"base64"):e}async 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 s=(0,o.XN)(this.from,this.to);if(!s.supported)throw new i.zx(s.reason,"UNSUPPORTED_CONVERSION");let a=(0,o.Ln)(t,this.from,this.to);if(!a.isValid)throw new i.zx(a.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:s}=await r.e(5804).then(r.bind(r,45804));s(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?s.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 a{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}}},96554:(e,t,r)=>{r.d(t,{stlToSvgHandler:()=>h});var i=r(10651),o=r(90816),s=r(44134).Buffer;function a(e,t){let{x:r,y:i,z:o}=e;if(t.x){let e=t.x*Math.PI/180,r=i*Math.cos(e)-o*Math.sin(e),s=i*Math.sin(e)+o*Math.cos(e);i=r,o=s}if(t.y){let e=t.y*Math.PI/180,i=r*Math.cos(e)+o*Math.sin(e),s=-r*Math.sin(e)+o*Math.cos(e);r=i,o=s}if(t.z){let e=t.z*Math.PI/180,o=r*Math.cos(e)-i*Math.sin(e),s=r*Math.sin(e)+i*Math.cos(e);r=o,i=s}return{x:r,y:i,z:o}}function n(e){if("string"==typeof e){if(!e.includes("solid")&&!e.includes("facet"))throw new i.OD("Invalid STL: Missing STL markers");return{content:e,isBinary:!1}}let t=e.length>=84?e.readUInt32LE(80):0;if(84+50*t===e.length&&t>0)return{content:e,isBinary:!0};let r=e.toString("utf8",0,Math.min(e.length,100)).trimStart();if(/^solid\b/i.test(r))return{content:e.toString("utf8"),isBinary:!1};throw new i.OD("Invalid STL: provide a complete ASCII STL or a binary STL with a matching triangle count.")}class l extends o.I{normalizeInput(e){return"string"==typeof e?s.from(e,"utf8"):e}async validateInput(e){if(e.length>524288e3)throw new i.OD("STL files must be 500 MiB or smaller.");n(e)}async performConversion(e,t={}){let r;if(void 0!==t.view&&!["front","top","side","isometric"].includes(t.view))throw new i.OD("Choose Front, Top, Side, or Isometric view.");if(void 0!==t.projection&&"orthographic"!==t.projection)throw new i.OD("Only orthographic projections are supported.");for(let e of[t.scale,t.strokeWidth])if(void 0!==e&&(!Number.isFinite(e)||e<=0))throw new i.OD("Scale and stroke width must be positive and finite.");if(t.rotation&&Object.values(t.rotation).some(e=>void 0!==e&&!Number.isFinite(e)))throw new i.OD("Rotation angles must be finite.");if(!1===t.wireframe&&!0!==t.fill)throw new i.OD("Enable wireframe or fill to produce visible geometry.");if(void 0!==t.width||void 0!==t.height)throw new i.OD("This projection fits the mesh automatically. Resize the resulting SVG in y
1our editor.");let{content:o,isBinary:l}=n(e);if(0===(r=l?function(e){let t=[],r=80,o=e.readUInt32LE(r);if(0===o||e.length!==84+50*o)throw new i.OD("Invalid binary STL: triangle count does not match the file length.");r+=4;for(let i=0;i<o;i++){let i={x:e.readFloatLE(r),y:e.readFloatLE(r+4),z:e.readFloatLE(r+8)};r+=12;let o=[];for(let t=0;t<3;t++)o.push({x:e.readFloatLE(r),y:e.readFloatLE(r+4),z:e.readFloatLE(r+8)}),r+=12;t.push({normal:i,vertices:o}),r+=2}return t}(o):function(e){let t=[],r=e.match(/^\s*solid[^\r\n]*\r?\n([\s\S]*?)\bendsolid[^\r\n]*\s*$/i)?.[1];if(void 0===r)throw new i.OD("Invalid ASCII STL: expected solid and endsolid markers.");let o="([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)",s=`${o}\\s+${o}\\s+${o}`,a=RegExp(`facet\\s+normal\\s+${s}\\s+outer\\s+loop\\s+vertex\\s+${s}\\s+vertex\\s+${s}\\s+vertex\\s+${s}\\s+endloop\\s+endfacet`,"gi");for(let e of r.matchAll(a)){let r=e.slice(1).map(Number),i=e=>({x:r[e],y:r[e+1],z:r[e+2]});t.push({normal:i(0),vertices:[i(3),i(6),i(9)]})}if(r.replace(a,"").trim())throw new i.OD("Invalid ASCII STL facet: each face must contain three finite vertices.");return t}(o)).length)throw new i.zx("No faces found in STL file","STL_NO_FACES");for(let e of r){if([e.normal,...e.vertices].some(e=>![e.x,e.y,e.z].every(Number.isFinite)))throw new i.OD("STL normals and vertices must be finite numbers.");let[t,r,o]=e.vertices,s={x:(r.y-t.y)*(o.z-t.z)-(r.z-t.z)*(o.y-t.y),y:(r.z-t.z)*(o.x-t.x)-(r.x-t.x)*(o.z-t.z),z:(r.x-t.x)*(o.y-t.y)-(r.y-t.y)*(o.x-t.x)},a=Math.hypot(s.x,s.y,s.z);if(!Number.isFinite(a)||0===a)throw new i.OD("STL contains a degenerate triangle. Repair the mesh before projecting it.");e.normal={x:s.x/a,y:s.y/a,z:s.z/a}}this.reportProgress(t,.5);let c=function(e,t){let r=t.view||"front",o=t.strokeWidth??1,s=!1!==t.wireframe,n=t.fill||!1;t.rotation&&(e=e.map(e=>({normal:a(e.normal,t.rotation),vertices:e.vertices.map(e=>a(e,t.rotation))})));let l=e.map(e=>{let t,i=e.vertices.map(e=>(function(e,t){switch(t){case"front":default:return{x:e.x,y:-e.y};case"top":return{x:e.x,y:-e.z};case"side":return{x:e.z,y:-e.y};case"isometric":let r=Math.PI/6;return{x:(e.x-e.z)*Math.cos(r),y:-e.y+(e.x+e.z)*Math.sin(r)}}})(e,r)),o=e.vertices;switch(r){case"top":t=-(o[0].y+o[1].y+o[2].y)/3;break;case"side":t=-(o[0].x+o[1].x+o[2].x)/3;break;case"isometric":t=(o[0].x+o[0].y+o[0].z+o[1].x+o[1].y+o[1].z+o[2].x+o[2].y+o[2].z)/3;break;default:t=(o[0].z+o[1].z+o[2].z)/3}return{projected:i,normal:e.normal,depth:t}});if(n&&(l=l.filter(e=>{let[t,r,i]=e.projected;return(r.x-t.x)*(i.y-t.y)-(r.y-t.y)*(i.x-t.x)<0})),0===l.length)throw new i.OD("No visible filled faces in this view. Choose another view or turn Solid fill off.");l.sort((e,t)=>e.depth-t.depth);let c=1/0,h=1/0,d=-1/0,f=-1/0;if(l.forEach(e=>{e.projected.forEach(e=>{c=Math.min(c,e.x),h=Math.min(h,e.y),d=Math.max(d,e.x),f=Math.max(f,e.y)})}),!(d>c)||!(f>h))throw new i.OD("This view has no two-dimensional extent. Choose a different view.");let m=t.scale??Math.min(500/(d-c),500/(f-h)),p=(d-c)*m,u=(f-h)*m;if(!Number.isFinite(p)||!Number.isFinite(u)||p<=0||u<=0)throw new i.OD("Projection dimensions must be positive and finite.");let w=`<?xml version="1.0" encoding="UTF-8"?>
2<svg xmlns="http://www.w3.org/2000/svg" 
3     width="${p}" 
4     height="${u}" 
5     viewBox="0 0 ${p} ${u}">
6  <g transform="translate(${-c*m}, ${-h*m}) scale(${m})">
7`;return l.forEach(e=>{let t=`M ${e.projected[0].x} ${e.projected[0].y} L ${e.projected[1].x} ${e.projected[1].y} L ${e.projected[2].x} ${e.projected[2].y} Z`,i="#cccccc";if(n){let t;switch(r){case"top":t=-e.normal.y;break;case"side":t=-e.normal.x;break;case"isometric":t=(e.normal.x+e.normal.y+e.normal.z)/Math.sqrt(3);break;default:t=e.normal.z}let o=Math.floor(255*Math.max(.3,Math.min(1,(t+1)/2)));i=`rgb(${o}, ${o}, ${o})`}w+=`    <path d="${t}" `,n?w+=`fill="${i}" `:w+='fill="none" ',s&&(w+=`stroke="#000000" stroke-width="${o/m}" `),w+=`/>
8`}),w+=`  </g>
9</svg>`}(r,t),h=s.from(c,"utf8"),d=c.match(/width="([^"]+)"/),f=c.match(/height="([^"]+)"/);return this.reportProgress(t,.9),this.createSuccessResult(h,"image/svg+xml",{width:d?parseFloat(d[1]):void 0,height:f?parseFloat(f[1]):void 0,faceCount:r.length,method:"orthographic triangle projection",view:t.view??"front",preserves3d:!1,physicalScale:!1})}constructor(...e){super(...e),this.name="STL to SVG",this.from="stl",this.to="svg",this.description="Convert 3D STL (STereoLithography) files to 2D SVG projections with customizable views"}}let c=new l,h=c.handler;c.name,c.from,c.to,c.description}}]);

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.