(function(){"use strict";const ee=(e,t)=>e in t;var te=typeof global=="object"&&global&&global.Object===Object&&global,ne=typeof self=="object"&&self&&self.Object===Object&&self,I=te||ne||Function("return this")(),g=I.Symbol,D=Object.prototype,re=D.hasOwnProperty,ie=D.toString,w=g?g.toStringTag:void 0;function oe(e){var t=re.call(e,w),n=e[w];try{e[w]=void 0;var r=!0}catch{}var o=ie.call(e);return r&&(t?e[w]=n:delete e[w]),o}var ae=Object.prototype,se=ae.toString;function ce(e){return se.call(e)}var le="[object Null]",ue="[object Undefined]",H=g?g.toStringTag:void 0;function $(e){return e==null?e===void 0?ue:le:H&&H in Object(e)?oe(e):ce(e)}function A(e){return e!=null&&typeof e=="object"}var fe="[object Symbol]";function F(e){return typeof e=="symbol"||A(e)&&$(e)==fe}function he(e,t){for(var n=-1,r=e==null?0:e.length,o=Array(r);++n0){if(++t>=Ne)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function Ge(e){return function(){return e}}var P=function(){try{var e=j(Object,"defineProperty");return e({},"",{}),e}catch{}}(),De=P?function(e,t){return P(e,"toString",{configurable:!0,enumerable:!1,value:Ge(t),writable:!0})}:de,He=Re(De),Le=9007199254740991,Ue=/^(?:0|[1-9]\d*)$/;function q(e,t){var n=typeof e;return t=t??Le,!!t&&(n=="number"||n!="symbol"&&Ue.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=Je}var Ye="[object Arguments]";function J(e){return A(e)&&$(e)==Ye}var B=Object.prototype,Ze=B.hasOwnProperty,Ve=B.propertyIsEnumerable,Y=J(function(){return arguments}())?J:function(e){return A(e)&&Ze.call(e,"callee")&&!Ve.call(e,"callee")},We=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,et=/^\w*$/;function tt(e,t){if(x(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||F(e)?!0:et.test(e)||!We.test(e)||t!=null&&e in Object(t)}var O=j(Object,"create");function nt(){this.__data__=O?O(null):{},this.size=0}function rt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var it="__lodash_hash_undefined__",ot=Object.prototype,at=ot.hasOwnProperty;function st(e){var t=this.__data__;if(O){var n=t[e];return n===it?void 0:n}return at.call(t,e)?t[e]:void 0}var ct=Object.prototype,lt=ct.hasOwnProperty;function ut(e){var t=this.__data__;return O?t[e]!==void 0:lt.call(t,e)}var ft="__lodash_hash_undefined__";function ht(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=O&&t===void 0?ft:t,this}function _(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t-1}function bt(e,t){var n=this.__data__,r=E(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function v(e){var t=-1,n=e==null?0:e.length;for(this.clear();++ti,a:()=>"\x07",b:()=>"\b","e|E":()=>"\x1B",f:()=>"\f",n:()=>` `,r:()=>"\r",t:()=>" ",v:()=>"\v","([0-7]{1,3})":i=>String.fromCharCode(parseInt(i,8)),"x([0-9a-fA-F]{1,2})":i=>String.fromCharCode(parseInt(i,16)),"u([0-9a-fA-F]{1,4})":i=>String.fromCharCode(parseInt(i,16)),"U([0-9a-fA-F]{1,8})":i=>String.fromCharCode(parseInt(i,16)),"c(.)":i=>i==="?"?"":i==="@"?"\0":String.fromCharCode(i.charCodeAt(0)&31)},h=new RegExp(c+"("+Object.keys(a).join("|")+")","g");return r.replace(h,function(i,u){for(const y in a){const C=new RegExp("^"+y+"$").exec(u);if(C!==null)return a[y].apply(null,C.slice(1))}})}}*[Symbol.iterator](){let r=!1,o=!1,s=!1,c=-2,a;for(this.debug&&console.log("full input:",">"+this.string+"<");;){const h=this.i,i=this.readChar();if(this.debug&&console.log("position:",h,"input:",">"+i+"<","accumulated:",a,"inQuote:",r,"inDollarQuote:",o,"lastDollar:",c,"escaped:",s),i===""){if(r)throw new Error("Got EOF while in a quoted string");if(s)throw new Error("Got EOF while in an escape sequence");a!==void 0&&(yield a);return}if(s){i===` `||(r?a=(a||"")+s+i:a=(a||"")+i),s=!1;continue}if(this.escapes.includes(i)&&(!r||o!==!1||this.escapedQuotes.includes(r))){s=i;continue}if(r!==!1){if(i===r){a=this.processEscapes(a,r,o==="'"),r=!1,o=!1;continue}a=(a||"")+i;continue}if(this.quotes.includes(i)){r=i,c===h-1&&(i==="'"&&!this.ansiCQuotes||i==='"'&&!this.localeQuotes||(o=i)),a=a||"",o!==!1&&(a=a.slice(0,-1));continue}if(r===!1&&i==="$"&&(c=h),this.whitespace.includes(i)){a!==void 0&&(yield a),a=void 0;continue}a=(a||"")+i}}}e.split=function(n){return Array.from(new t(n))},e.quote=function(n){return n===""?"''":/[^\w@%\-+=:,./]/.test(n)?("'"+n.replace(/('+)/g,`'"$1"'`)+"'").replace(/^''|''$/g,""):n},e.join=function(n){if(!Array.isArray(n))throw new TypeError("args should be an array");return n.map(e.quote).join(" ")}})(W);var Jt=Kt(W);const Bt=e=>{const t={};for(const[,n,r]of e.matchAll(/([a-z])[ \t]*(-?(?:\d+(?:\.\d+)?|\.\d+))/ig))t[n.toLowerCase()]=+r;return t},Yt=e=>{const t={};for(const n of Jt.split(e)){const r=n.indexOf("="),o=n.substring(0,r),s=n.substring(r+1);t[o.toLowerCase()]=s}return t},Zt=e=>{const t=e.trim().split(";",2)[0],[,n,r=""]=t.split(/^([gm][0-9]+)\s*/i);if(n)return{type:"gcode",command:n.toUpperCase(),args:Bt(r)};const[,o,s=""]=t.split(/^(SET_PRINT_STATS_INFO|EXCLUDE_OBJECT_DEFINE|SET_RETRACTION)\s+/i);return o?{type:"macro",command:o.toUpperCase(),args:Yt(s)}:{type:"other"}},b=e=>Math.round(e*1e4)/1e4,Vt=(e,t)=>{const n=[],r=[],o=[],s=e.split(` `);let c=!1,a="relative",h="absolute";const i={x:0,y:0,z:0,e:0,filePosition:0},u={length:1,extrudeExtra:0,z:0};for(let y=0;y({x:tn,y:nn}))};o.push(Object.freeze(d))}break;case"SET_RETRACTION":"retract_length"in f&&(u.length=+f.retract_length),"unretract_extra_length"in f&&(u.extrudeExtra=+f.unretract_extra_length);break}else if(C==="gcode"){switch(G){case"G0":case"G1":{const p=["x","y","z","e"];p.some(d=>d in f)&&(l={...V(f,p),filePosition:i.filePosition});break}case"G2":case"G3":{const p=["x","y","z","e","i","j","k","r"];p.some(d=>d in f)&&(l={...V(f,p),direction:G==="G2"?"clockwise":"counter-clockwise",filePosition:i.filePosition});break}case"G10":l={e:-u.length,filePosition:i.filePosition},u.z!==0&&(l.z=b(i.z+u.z));break;case"G11":l={e:b(u.length+u.extrudeExtra),filePosition:i.filePosition},u.z!==0&&(l.z=b(i.z-u.z));break;case"G90":h="absolute";case"M82":a="absolute",i.e=0;break;case"G91":h="relative";case"M83":a="relative";break;case"G92":a==="absolute"&&(i.e=f.e??i.e),h==="absolute"&&(i.x=f.x??i.x,i.y=f.y??i.y,i.z=f.z??i.z);break;case"M207":u.length=f.s??u.length,u.z=f.z??u.z;break}if(l){if(a==="absolute"&&l.e!==void 0){const p=b(l.e-i.e);i.e=l.e,l.e=p}if(h==="relative"&&(l.x!==void 0&&(l.x=b(l.x+i.x)),l.y!==void 0&&(l.y=b(l.y+i.y)),l.z!==void 0&&(l.z=b(l.z+i.z))),c&&l.e&&l.e>0){const p=l;if(["x","y","i","j"].some(d=>ee(d,p)&&p[d]!==0)){const d={z:i.z,move:n.length-1,filePosition:i.filePosition};r.push(Object.freeze(d)),c=!1}}i.x=l.x??i.x,i.y=l.y??i.y,i.z=l.z??i.z,n.push(Object.freeze(l))}}y%Math.floor(s.length/100)===0&&t(i.filePosition),i.filePosition+=s[y].length+1}return t(i.filePosition),{moves:n,layers:r,parts:o}},Wt=e=>{const t={action:"progress",filePosition:e};self.postMessage(t)},en=(e,t,n)=>{const r={action:"result",moves:e,layers:t,parts:n};self.postMessage(r)};self.onmessage=e=>{const t=e.data;switch(t.action){case"parse":{const{moves:n,layers:r,parts:o}=Vt(t.gcode,Wt);en(n,r,o);break}}}})();