From b47fd09a33562f123b4fc41b9a0a124dacc16f35 Mon Sep 17 00:00:00 2001 From: github-actions-bot Date: Fri, 6 Sep 2024 10:43:33 +0000 Subject: [PATCH] Updates --- index.html | 37 +++++++- script.js | 10 ++- style.css | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 279 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 15fc5c2..d62ce52 100644 --- a/index.html +++ b/index.html @@ -43,6 +43,9 @@

Zoom: 1.0x

+
+

To move nodes on touchscreen, lock the canvas first

+
+ +
@@ -229,10 +257,15 @@

Overclock (every machine)

-
+
+ Reset +
+
Restore
-
+
Apply
diff --git a/script.js b/script.js index 6664e40..6ab8d61 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,5 @@ -"use strict";(()=>{var ji=Object.create;var Mt=Object.defineProperty;var Xi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var Qi=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty;var j=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Ji=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Yi(e))!Ki.call(n,a)&&a!==t&&Mt(n,a,{get:()=>e[a],enumerable:!(i=Xi(e,a))||i.enumerable});return n};var en=(n,e,t)=>(t=n!=null?ji(Qi(n)):{},Ji(e||!n||!n.__esModule?Mt(t,"default",{value:n,enumerable:!0}):t,n));var qt=j((ta,He)=>{He.exports=It;He.exports.addWheelListener=It;He.exports.removeWheelListener=nn;function It(n,e,t){n.addEventListener("wheel",e,t)}function nn(n,e,t){n.removeEventListener("wheel",e,t)}});var Zt=j((ia,Bt)=>{var an=4,on=.001,rn=1e-7,sn=10,Ee=11,Oe=1/(Ee-1),cn=typeof Float32Array=="function";function Ft(n,e){return 1-3*e+3*n}function Gt(n,e){return 3*e-6*n}function Ht(n){return 3*n}function Be(n,e,t){return((Ft(e,t)*n+Gt(e,t))*n+Ht(e))*n}function Ot(n,e,t){return 3*Ft(e,t)*n*n+2*Gt(e,t)*n+Ht(e)}function un(n,e,t,i,a){var r,o,c=0;do o=e+(t-e)/2,r=Be(o,i,a)-n,r>0?t=o:e=o;while(Math.abs(r)>rn&&++c=on?ln(p,C,e,i):b===0?C:un(p,u,u+Oe,e,i)}return function(u){return u===0?0:u===1?1:Be(c(u),t,a)}}});var Vt=j((na,Ze)=>{var Ae=Zt(),zt={ease:Ae(.25,.1,.25,1),easeIn:Ae(.42,0,1,1),easeOut:Ae(0,0,.58,1),easeInOut:Ae(.42,0,.58,1),linear:Ae(0,0,1,1)};Ze.exports=pn;Ze.exports.makeAggregateRaf=Ut;Ze.exports.sharedScheduler=Ut();function pn(n,e,t){var i=Object.create(null),a=Object.create(null);t=t||{};var r=typeof t.easing=="function"?t.easing:zt[t.easing];r||(t.easing&&console.warn("Unknown easing function in amator: "+t.easing),r=zt.ease);var o=typeof t.step=="function"?t.step:Wt,c=typeof t.done=="function"?t.done:Wt,p=mn(t.scheduler),u=Object.keys(e);u.forEach(function(f){i[f]=n[f],a[f]=e[f]-n[f]});var h=typeof t.duration=="number"?t.duration:400,y=Math.max(1,h*.06),v,C=0;return v=p.next(_),{cancel:b};function b(){p.cancel(v),v=0}function _(){var f=r(C/y);C+=1,D(f),C<=y?(v=p.next(_),o(n)):(v=0,setTimeout(function(){c(n)},0))}function D(f){u.forEach(function(G){n[G]=a[G]*f+i[G]})}}function Wt(){}function mn(n){if(!n){var e=typeof window<"u"&&window.requestAnimationFrame;return e?_n():hn()}if(typeof n.next!="function")throw new Error("Scheduler is supposed to have next(cb) function");if(typeof n.cancel!="function")throw new Error("Scheduler is supposed to have cancel(handle) function");return n}function _n(){return{next:window.requestAnimationFrame.bind(window),cancel:window.cancelAnimationFrame.bind(window)}}function hn(){return{next:function(n){return setTimeout(n,1e3/60)},cancel:function(n){return clearTimeout(n)}}}function Ut(){var n=new Set,e=new Set,t=0;return{next:a,cancel:a,clearAll:i};function i(){n.clear(),e.clear(),cancelAnimationFrame(t),t=0}function a(p){e.add(p),r()}function r(){t||(t=requestAnimationFrame(o))}function o(){t=0;var p=e;e=n,n=p,n.forEach(function(u){u()}),n.clear()}function c(p){e.delete(p)}}});var jt=j((aa,$t)=>{$t.exports=function(e){Cn(e);var t=gn(e);return e.on=t.on,e.off=t.off,e.fire=t.fire,e};function gn(n){var e=Object.create(null);return{on:function(t,i,a){if(typeof i!="function")throw new Error("callback is expected to be a function");var r=e[t];return r||(r=e[t]=[]),r.push({callback:i,ctx:a}),n},off:function(t,i){var a=typeof t>"u";if(a)return e=Object.create(null),n;if(e[t]){var r=typeof i!="function";if(r)delete e[t];else for(var o=e[t],c=0;c1&&(a=Array.prototype.splice.call(arguments,1));for(var r=0;r{Xt.exports=fn;function fn(n,e,t){typeof t!="object"&&(t={});var i=typeof t.minVelocity=="number"?t.minVelocity:5,a=typeof t.amplitude=="number"?t.amplitude:.25,r=typeof t.cancelAnimationFrame=="function"?t.cancelAnimationFrame:vn(),o=typeof t.requestAnimationFrame=="function"?t.requestAnimationFrame:yn(),c,p,u=342,h,y,v,C,b,_,D,f;return{start:H,stop:K,cancel:G};function G(){r(h),r(f)}function H(){c=n(),C=D=y=b=0,p=new Date,r(h),r(f),h=o(V)}function V(){var q=Date.now(),x=q-p;p=q;var O=n(),B=O.x-c.x,ae=O.y-c.y;c=O;var L=1e3/(1+x);y=.8*B*L+.2*y,b=.8*ae*L+.2*b,h=o(V)}function K(){r(h),r(f);var q=n();v=q.x,_=q.y,p=Date.now(),(y<-i||y>i)&&(C=a*y,v+=C),(b<-i||b>i)&&(D=a*b,_+=D),f=o($)}function $(){var q=Date.now()-p,x=!1,O=0,B=0;C&&(O=-C*Math.exp(-q/u),O>.5||O<-.5?x=!0:O=C=0),D&&(B=-D*Math.exp(-q/u),B>.5||B<-.5?x=!0:B=D=0),x&&(e(v+O,_+B),f=o($))}}function vn(){return typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout}function yn(){return typeof requestAnimationFrame=="function"?requestAnimationFrame:function(n){return setTimeout(n,16)}}});var ei=j((ra,Jt)=>{Jt.exports=Dn;function Dn(n){if(n)return{capture:Kt,release:Kt};var e,t,i,a=!1;return{capture:r,release:o};function r(c){a=!0,t=window.document.onselectstart,i=window.document.ondragstart,window.document.onselectstart=Qt,e=c,e.ondragstart=Qt}function o(){a&&(a=!1,window.document.onselectstart=t,e&&(e.ondragstart=i))}}function Qt(n){return n.stopPropagation(),!1}function Kt(){}});var ii=j((sa,ti)=>{ti.exports=Sn;function Sn(){this.x=0,this.y=0,this.scale=1}});var ai=j((ca,nt)=>{nt.exports=bn;nt.exports.canAttach=ni;function bn(n,e){if(!ni(n))throw new Error("svg element is required for svg.panzoom to work");var t=n.ownerSVGElement;if(!t)throw new Error("Do not apply panzoom to the root element. Use its child instead (e.g. ). As of March 2016 only FireFox supported transform on the root element");e.disableKeyboardInteraction||t.setAttribute("tabindex",0);var i={getBBox:r,getScreenCTM:o,getOwner:a,applyTransform:p,initTransform:c};return i;function a(){return t}function r(){var u=n.getBBox();return{left:u.x,top:u.y,width:u.width,height:u.height}}function o(){var u=t.getCTM();return u||t.getScreenCTM()}function c(u){var h=n.getCTM();h===null&&(h=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix()),u.x=h.e,u.y=h.f,u.scale=h.a,t.removeAttributeNS(null,"viewBox")}function p(u){n.setAttribute("transform","matrix("+u.scale+" 0 0 "+u.scale+" "+u.x+" "+u.y+")")}}function ni(n){return n&&n.ownerSVGElement&&n.getCTM}});var ri=j((ua,at)=>{at.exports=Pn;at.exports.canAttach=oi;function Pn(n,e){var t=oi(n);if(!t)throw new Error("panzoom requires DOM element to be attached to the DOM tree");var i=n.parentElement;n.scrollTop=0,e.disableKeyboardInteraction||i.setAttribute("tabindex",0);var a={getBBox:o,getOwner:r,applyTransform:c};return a;function r(){return i}function o(){return{left:0,top:0,width:n.clientWidth,height:n.clientHeight}}function c(p){n.style.transformOrigin="0 0 0",n.style.transform="matrix("+p.scale+", 0, 0, "+p.scale+", "+p.x+", "+p.y+")"}}function oi(n){return n&&n.parentElement&&n.style}});var Ci=j((la,gi)=>{"use strict";var si=qt(),ot=Vt(),Rn=jt(),En=Yt(),_i=ei(),An=_i(),wn=_i(!0),Tn=ii(),ci=ai(),ui=ri(),kn=1,Nn=1.75,li=300,di=200;gi.exports=hi;function hi(n,e){e=e||{};var t=e.controller;if(t||(ci.canAttach(n)?t=ci(n,e):ui.canAttach(n)&&(t=ui(n,e))),!t)throw new Error("Cannot create panzoom for the current type of dom element");var i=t.getOwner(),a={x:0,y:0},r=!1,o=new Tn;t.initTransform&&t.initTransform(o);var c=typeof e.filterKey=="function"?e.filterKey:Ce,p=typeof e.pinchSpeed=="number"?e.pinchSpeed:1,u=e.bounds,h=typeof e.maxZoom=="number"?e.maxZoom:Number.POSITIVE_INFINITY,y=typeof e.minZoom=="number"?e.minZoom:0,v=typeof e.boundsPadding=="number"?e.boundsPadding:.05,C=typeof e.zoomDoubleClickSpeed=="number"?e.zoomDoubleClickSpeed:Nn,b=e.beforeWheel||Ce,_=e.beforeMouseDown||Ce,D=typeof e.zoomSpeed=="number"?e.zoomSpeed:kn,f=pi(e.transformOrigin),G=e.enableTextSelection?wn:An;Mn(u),e.autocenter&&bi();var H,V=0,K=0,$=0,q=null,x=new Date,O,B=!1,ae=!1,L,Z,Xe,Ye,Qe,W;"smoothScroll"in e&&!e.smoothScroll?W=xn():W=En(xi,Gi,e.smoothScroll);var Ke,De,ke,Ne=!1;mt();var Me={dispose:Hi,moveBy:de,moveTo:Je,smoothMoveTo:Fi,centerOn:qi,zoomTo:qe,zoomAbs:xe,smoothZoom:Ie,smoothZoomAbs:Vi,showRectangle:Si,pause:vi,resume:yi,isPaused:Di,getTransform:Pi,getMinZoom:Ri,setMinZoom:Ei,getMaxZoom:Ai,setMaxZoom:wi,getTransformOrigin:Ti,setTransformOrigin:ki,getZoomSpeed:Ni,setZoomSpeed:Mi};Rn(Me);var st=typeof e.initialX=="number"?e.initialX:o.x,ct=typeof e.initialY=="number"?e.initialY:o.y,ut=typeof e.initialZoom=="number"?e.initialZoom:o.scale;return(st!=o.x||ct!=o.y||ut!=o.scale)&&xe(st,ct,ut),Me;function vi(){_t(),Ne=!0}function yi(){Ne&&(mt(),Ne=!1)}function Di(){return Ne}function Si(s){var l=i.getBoundingClientRect(),d=oe(l.width,l.height),m=s.right-s.left,S=s.bottom-s.top;if(!Number.isFinite(m)||!Number.isFinite(S))throw new Error("Invalid rectangle");var A=d.x/m,w=d.y/S,N=Math.min(A,w);o.x=-(s.left+m/2)*N+d.x/2,o.y=-(s.top+S/2)*N+d.y/2,o.scale=N}function oe(s,l){if(t.getScreenCTM){var d=t.getScreenCTM(),m=d.a,S=d.d,A=d.e,w=d.f;a.x=s*m-A,a.y=l*S-w}else a.x=s,a.y=l;return a}function bi(){var s,l,d=0,m=0,S=dt();if(S)d=S.left,m=S.top,s=S.right-S.left,l=S.bottom-S.top;else{var A=i.getBoundingClientRect();s=A.width,l=A.height}var w=t.getBBox();if(!(w.width===0||w.height===0)){var N=l/w.height,me=s/w.width,re=Math.min(me,N);o.x=-(w.left+w.width/2)*re+s/2+d,o.y=-(w.top+w.height/2)*re+l/2+m,o.scale=re}}function Pi(){return o}function Ri(){return y}function Ei(s){y=s}function Ai(){return h}function wi(s){h=s}function Ti(){return f}function ki(s){f=pi(s)}function Ni(){return D}function Mi(s){if(!Number.isFinite(s))throw new Error("Zoom speed should be a number");D=s}function xi(){return{x:o.x,y:o.y}}function Je(s,l){o.x=s,o.y=l,et(),pe("pan"),tt()}function lt(s,l){Je(o.x+s,o.y+l)}function et(){var s=dt();if(s){var l=!1,d=Li(),m=s.left-d.right;return m>0&&(o.x+=m,l=!0),m=s.right-d.left,m<0&&(o.x+=m,l=!0),m=s.top-d.bottom,m>0&&(o.y+=m,l=!0),m=s.bottom-d.top,m<0&&(o.y+=m,l=!0),l}}function dt(){if(u){if(typeof u=="boolean"){var s=i.getBoundingClientRect(),l=s.width,d=s.height;return{left:l*v,top:d*v,right:l*(1-v),bottom:d*(1-v)}}return u}}function Li(){var s=t.getBBox(),l=Ii(s.left,s.top);return{left:l.x,top:l.y,right:s.width*o.scale+l.x,bottom:s.height*o.scale+l.y}}function Ii(s,l){return{x:s*o.scale+o.x,y:l*o.scale+o.y}}function tt(){r=!0,H=window.requestAnimationFrame(Oi)}function pt(s,l,d){if(rt(s)||rt(l)||rt(d))throw new Error("zoom requires valid numbers");var m=o.scale*d;if(mh){if(o.scale===h)return;d=h/o.scale}var S=oe(s,l);if(o.x=S.x-d*(S.x-o.x),o.y=S.y-d*(S.y-o.y),u&&v===1&&y===1)o.scale*=d,et();else{var A=et();A||(o.scale*=d)}pe("zoom"),tt()}function xe(s,l,d){var m=d/o.scale;pt(s,l,m)}function qi(s){var l=s.ownerSVGElement;if(!l)throw new Error("ui element is required to be within the scene");var d=s.getBoundingClientRect(),m=d.left+d.width/2,S=d.top+d.height/2,A=l.getBoundingClientRect(),w=A.width/2-m,N=A.height/2-S;de(w,N,!0)}function Fi(s,l){de(s-o.x,l-o.y,!0)}function de(s,l,d){if(!d)return lt(s,l);Ke&&Ke.cancel();var m={x:0,y:0},S={x:s,y:l},A=0,w=0;Ke=ot(m,S,{step:function(N){lt(N.x-A,N.y-w),A=N.x,w=N.y}})}function Gi(s,l){Fe(),Je(s,l)}function Hi(){_t()}function mt(){i.addEventListener("mousedown",St,{passive:!1}),i.addEventListener("dblclick",Dt,{passive:!1}),i.addEventListener("touchstart",gt,{passive:!1}),i.addEventListener("keydown",ht,{passive:!1}),si.addWheelListener(i,At,{passive:!1}),tt()}function _t(){si.removeWheelListener(i,At),i.removeEventListener("mousedown",St),i.removeEventListener("keydown",ht),i.removeEventListener("dblclick",Dt),i.removeEventListener("touchstart",gt),H&&(window.cancelAnimationFrame(H),H=0),W.cancel(),Rt(),Et(),G.release(),it()}function Oi(){r&&Bi()}function Bi(){r=!1,t.applyTransform(o),pe("transform"),H=0}function ht(s){var l=0,d=0,m=0;if(s.keyCode===38?d=1:s.keyCode===40?d=-1:s.keyCode===37?l=1:s.keyCode===39?l=-1:s.keyCode===189||s.keyCode===109?m=1:(s.keyCode===187||s.keyCode===107)&&(m=-1),!c(s,l,d,m)){if(l||d){s.preventDefault(),s.stopPropagation();var S=i.getBoundingClientRect(),A=Math.min(S.width,S.height),w=.05,N=A*w*l,me=A*w*d;de(N,me)}if(m){var re=wt(m*100),A=f?be():Zi();qe(A.x,A.y,re)}}}function Zi(){var s=i.getBoundingClientRect();return{x:s.width/2,y:s.height/2}}function gt(s){if(zi(s),Se(),s.touches.length===1)return Ui(s,s.touches[0]);s.touches.length===2&&(Qe=yt(s.touches[0],s.touches[1]),ke=!0,Ct())}function zi(s){e.onTouch&&!e.onTouch(s)||(s.stopPropagation(),s.preventDefault())}function Wi(s){Se(),!(e.onDoubleClick&&!e.onDoubleClick(s))&&(s.preventDefault(),s.stopPropagation())}function Ui(s){K=new Date;var l=s.touches[0],d=J(l);O=d;var m=oe(d.x,d.y);L=m.x,Z=m.y,Xe=L,Ye=Z,W.cancel(),Ct()}function Ct(){B||(B=!0,document.addEventListener("touchmove",ft),document.addEventListener("touchend",Le),document.addEventListener("touchcancel",Le))}function ft(s){if(s.touches.length===1){s.stopPropagation();var l=s.touches[0],d=J(l),m=oe(d.x,d.y),S=m.x-L,A=m.y-Z;S!==0&&A!==0&&Tt(),L=m.x,Z=m.y,de(S,A)}else if(s.touches.length===2){ke=!0;var w=s.touches[0],N=s.touches[1],me=yt(w,N),re=1+(me/Qe-1)*p,kt=J(w),Nt=J(N);if(L=(kt.x+Nt.x)/2,Z=(kt.y+Nt.y)/2,f){var d=be();L=d.x,Z=d.y}qe(L,Z,re),Qe=me,s.stopPropagation(),s.preventDefault()}}function Se(){$&&(clearTimeout($),$=0)}function vt(s){if(e.onClick){Se();var l=L-Xe,d=Z-Ye,m=Math.sqrt(l*l+d*d);m>5||($=setTimeout(function(){$=0,e.onClick(s)},li))}}function Le(s){if(Se(),s.touches.length>0){var l=J(s.touches[0]),d=oe(l.x,l.y);L=d.x,Z=d.y}else{var m=new Date;if(m-V0&&(l*=100);var d=wt(l);if(d!==1){var m=f?be():J(s);qe(m.x,m.y,d),s.preventDefault()}}}function J(s){var l,d,m=i.getBoundingClientRect();return l=s.clientX-m.left,d=s.clientY-m.top,{x:l,y:d}}function Ie(s,l,d){var m=o.scale,S={scale:m},A={scale:d*m};W.cancel(),Fe(),De=ot(S,A,{step:function(w){xe(s,l,w.scale)},done:$i})}function Vi(s,l,d){var m=o.scale,S={scale:m},A={scale:d};W.cancel(),Fe(),De=ot(S,A,{step:function(w){xe(s,l,w.scale)}})}function be(){var s=i.getBoundingClientRect();return{x:s.width*f.x,y:s.height*f.y}}function qe(s,l,d){return W.cancel(),Fe(),pt(s,l,d)}function Fe(){De&&(De.cancel(),De=null)}function wt(s){var l=Math.sign(s),d=Math.min(.25,Math.abs(D*s/128));return 1-l*d}function Tt(){ae||(pe("panstart"),ae=!0,W.start())}function it(){ae&&(ke||W.stop(),pe("panend"))}function $i(){pe("zoomend")}function pe(s){Me.fire(s,Me)}}function pi(n){if(n){if(typeof n=="object")return(!ge(n.x)||!ge(n.y))&&mi(n),n;mi()}}function mi(n){throw console.error(n),new Error(["Cannot parse transform origin.","Some good examples:",' "center center" can be achieved with {x: 0.5, y: 0.5}',' "top center" can be achieved with {x: 0.5, y: 0}',' "bottom right" can be achieved with {x: 1, y: 1}'].join(` -`))}function Ce(){}function Mn(n){var e=typeof n;if(!(e==="undefined"||e==="boolean")){var t=ge(n.left)&&ge(n.top)&&ge(n.bottom)&&ge(n.right);if(!t)throw new Error("Bounds object is not valid. It can be: undefined, boolean (true|false) or an object {left, top, right, bottom}")}}function ge(n){return Number.isFinite(n)}function rt(n){return Number.isNaN?Number.isNaN(n):n!==n}function xn(){return{start:Ce,stop:Ce,cancel:Ce}}function Ln(){if(typeof document>"u")return;var n=document.getElementsByTagName("script");if(!n)return;for(var e,t=0;t{let t=this._nodes.findIndex(i=>Object.is(e,i));this._nodes.splice(t,1)}),this.saveToUrl()}static get nodes(){return this._nodes}static objToArray(e){return Object.keys(e).map(function(t){let i=e[t];return i!==Object(i)?i:n.objToArray(i)})}static objFromArray(e,t){let i={...t},a=0;return Object.keys(i).map(function(r){i[r]=e[a++]}),i}static _nodes=[];static _savingLocks=0};var k=class{static createSvgGroup(e,...t){let i=this.createSvgElement("g",...t);return i.setAttribute("transform",`translate(${e.x}, ${e.y})`),i}static createSvgRect(e,...t){let i=this.createSvgElement("rect",...t);return i.setAttribute("width",`${e.width}`),i.setAttribute("height",`${e.height}`),i.setAttribute("x",`${e.x}`),i.setAttribute("y",`${e.y}`),i}static createSvgLine(e,t,...i){let a=this.createSvgElement("line",...i);return a.setAttribute("x1",`${e.x}`),a.setAttribute("y1",`${e.y}`),a.setAttribute("x2",`${t.x}`),a.setAttribute("y2",`${t.y}`),a}static createSvgPath(...e){let t=this.createSvgElement("path",...e);return t.setAttribute("g",""),t}static createSvgForeignObject(...e){return this.createSvgElement("foreignObject",...e)}static createSvgElement(e,...t){let i=document.createElementNS("http://www.w3.org/2000/svg",e);return i.classList.add(...t),i}};var T=class n extends EventTarget{static slotWidth=10;static boundsChangedEvent="bounds-changed";static deletionEvent="deleted";static resourcesAmountChangedEvent="resources-amount-changed";constructor(e,t,i,...a){super(),this._resource={...i},this._parentGroup=e;let r={width:n.slotWidth,height:0,x:0,y:0};this._slotSvgRect=k.createSvgRect(r,...a),t.appendChild(this.slotSvgRect),this.updateHeight()}setYPosition(e){this.slotSvgRect.setAttribute("y",`${e}`),this.dispatchEvent(new Event(n.boundsChangedEvent))}delete(){R.lockSaving(),this.dispatchEvent(new Event(n.deletionEvent)),this.slotSvgRect.remove(),R.unlockSaving(),R.saveToUrl()}get resourcesAmount(){return this._resource.amount}set resourcesAmount(e){this._resource.amount!=e&&(this._resource.amount=e,this.updateHeight(),this.dispatchEvent(new Event(n.resourcesAmountChangedEvent)))}get resourceId(){return this._resource.id}get slotSvgRect(){return this._slotSvgRect}updateHeight(){let e=this.resourcesAmount/this._parentGroup.resourcesAmount;this.slotSvgRect.setAttribute("height",`${this._parentGroup.height*e}`),this.dispatchEvent(new Event(n.boundsChangedEvent))}toSerializable(){return{connectedTo:this.connectedTo?._parentGroup.parentNode.id??-1,resourcesAmount:this.resourcesAmount}}get connectedTo(){return this._connectedTo}set connectedTo(e){this._connectedTo=e}get parentGroup(){return this._parentGroup}_connectedTo;_resource;_slotSvgRect;_parentGroup};var _e=class extends T{constructor(e,t,i,...a){super(e,t,i,"output-slot",...a)}};var te=class{startPoint={x:0,y:0};startDeviationPoint={x:0,y:0};endDeviationPoint={x:0,y:0};endPoint={x:0,y:0};static fromTwoPoints(e,t){return{startPoint:e,endPoint:t,startDeviationPoint:{x:(e.x+t.x)/2,y:e.y},endDeviationPoint:{x:(e.x+t.x)/2,y:t.y}}}};var Pe=class n{constructor(e,t,i,a){this.x=e;this.y=t;this.width=i;this.height=a}static fromSvgRect(e){return new n(+e.getAttribute("x"),+e.getAttribute("y"),+e.getAttribute("width"),+e.getAttribute("height"))}static fromSvgBounds(e,t){let i=t.getTransform().scale,a=e.getBoundingClientRect();return a={x:(a.x-t.getTransform().x)/i,y:(a.y-t.getTransform().y)/i,width:a.width/i,height:a.height/i},a}};var se=class{path="";startAt(e){return this.pointAt(e)}pointAt(e){return this.path+=`M ${e.x} ${e.y} `,this}curve(e){return this.path+=`C ${e.startDeviationPoint.x} ${e.startDeviationPoint.y} ${e.endDeviationPoint.x} ${e.endDeviationPoint.y} ${e.endPoint.x} ${e.endPoint.y} `,this}verticalLineTo(e){return this.path+=`V ${e} `,this}build(){return this.path}};var ce={gameVersion:"0.8.3.3",machines:[{id:"Build_SmelterMk1_C",displayName:"Smelter",description:`Smelts ore into ingots. +"use strict";(()=>{var Xi=Object.create;var Lt=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var Qi=Object.getOwnPropertyNames;var Ki=Object.getPrototypeOf,Ji=Object.prototype.hasOwnProperty;var j=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var en=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Qi(e))!Ji.call(n,a)&&a!==t&&Lt(n,a,{get:()=>e[a],enumerable:!(i=Yi(e,a))||i.enumerable});return n};var tn=(n,e,t)=>(t=n!=null?Xi(Ki(n)):{},en(e||!n||!n.__esModule?Lt(t,"default",{value:n,enumerable:!0}):t,n));var Ft=j((ia,He)=>{He.exports=qt;He.exports.addWheelListener=qt;He.exports.removeWheelListener=an;function qt(n,e,t){n.addEventListener("wheel",e,t)}function an(n,e,t){n.removeEventListener("wheel",e,t)}});var zt=j((na,Zt)=>{var on=4,rn=.001,sn=1e-7,cn=10,Ae=11,Oe=1/(Ae-1),un=typeof Float32Array=="function";function Gt(n,e){return 1-3*e+3*n}function Ht(n,e){return 3*e-6*n}function Ot(n){return 3*n}function Be(n,e,t){return((Gt(e,t)*n+Ht(e,t))*n+Ot(e))*n}function Bt(n,e,t){return 3*Gt(e,t)*n*n+2*Ht(e,t)*n+Ot(e)}function ln(n,e,t,i,a){var o,r,c=0;do r=e+(t-e)/2,o=Be(r,i,a)-n,o>0?t=r:e=r;while(Math.abs(o)>sn&&++c=rn?dn(p,C,e,i):b===0?C:ln(p,u,u+Oe,e,i)}return function(u){return u===0?0:u===1?1:Be(c(u),t,a)}}});var $t=j((aa,Ze)=>{var we=zt(),Wt={ease:we(.25,.1,.25,1),easeIn:we(.42,0,1,1),easeOut:we(0,0,.58,1),easeInOut:we(.42,0,.58,1),linear:we(0,0,1,1)};Ze.exports=mn;Ze.exports.makeAggregateRaf=Vt;Ze.exports.sharedScheduler=Vt();function mn(n,e,t){var i=Object.create(null),a=Object.create(null);t=t||{};var o=typeof t.easing=="function"?t.easing:Wt[t.easing];o||(t.easing&&console.warn("Unknown easing function in amator: "+t.easing),o=Wt.ease);var r=typeof t.step=="function"?t.step:Ut,c=typeof t.done=="function"?t.done:Ut,p=_n(t.scheduler),u=Object.keys(e);u.forEach(function(v){i[v]=n[v],a[v]=e[v]-n[v]});var _=typeof t.duration=="number"?t.duration:400,D=Math.max(1,_*.06),f,C=0;return f=p.next(k),{cancel:b};function b(){p.cancel(f),f=0}function k(){var v=o(C/D);C+=1,g(v),C<=D?(f=p.next(k),r(n)):(f=0,setTimeout(function(){c(n)},0))}function g(v){u.forEach(function(R){n[R]=a[R]*v+i[R]})}}function Ut(){}function _n(n){if(!n){var e=typeof window<"u"&&window.requestAnimationFrame;return e?hn():gn()}if(typeof n.next!="function")throw new Error("Scheduler is supposed to have next(cb) function");if(typeof n.cancel!="function")throw new Error("Scheduler is supposed to have cancel(handle) function");return n}function hn(){return{next:window.requestAnimationFrame.bind(window),cancel:window.cancelAnimationFrame.bind(window)}}function gn(){return{next:function(n){return setTimeout(n,1e3/60)},cancel:function(n){return clearTimeout(n)}}}function Vt(){var n=new Set,e=new Set,t=0;return{next:a,cancel:a,clearAll:i};function i(){n.clear(),e.clear(),cancelAnimationFrame(t),t=0}function a(p){e.add(p),o()}function o(){t||(t=requestAnimationFrame(r))}function r(){t=0;var p=e;e=n,n=p,n.forEach(function(u){u()}),n.clear()}function c(p){e.delete(p)}}});var Xt=j((oa,jt)=>{jt.exports=function(e){vn(e);var t=Cn(e);return e.on=t.on,e.off=t.off,e.fire=t.fire,e};function Cn(n){var e=Object.create(null);return{on:function(t,i,a){if(typeof i!="function")throw new Error("callback is expected to be a function");var o=e[t];return o||(o=e[t]=[]),o.push({callback:i,ctx:a}),n},off:function(t,i){var a=typeof t>"u";if(a)return e=Object.create(null),n;if(e[t]){var o=typeof i!="function";if(o)delete e[t];else for(var r=e[t],c=0;c1&&(a=Array.prototype.splice.call(arguments,1));for(var o=0;o{Yt.exports=fn;function fn(n,e,t){typeof t!="object"&&(t={});var i=typeof t.minVelocity=="number"?t.minVelocity:5,a=typeof t.amplitude=="number"?t.amplitude:.25,o=typeof t.cancelAnimationFrame=="function"?t.cancelAnimationFrame:yn(),r=typeof t.requestAnimationFrame=="function"?t.requestAnimationFrame:Dn(),c,p,u=342,_,D,f,C,b,k,g,v;return{start:z,stop:K,cancel:R};function R(){o(_),o(v)}function z(){c=n(),C=g=D=b=0,p=new Date,o(_),o(v),_=r(W)}function W(){var O=Date.now(),U=O-p;p=O;var N=n(),B=N.x-c.x,ae=N.y-c.y;c=N;var I=1e3/(1+U);D=.8*B*I+.2*D,b=.8*ae*I+.2*b,_=r(W)}function K(){o(_),o(v);var O=n();f=O.x,k=O.y,p=Date.now(),(D<-i||D>i)&&(C=a*D,f+=C),(b<-i||b>i)&&(g=a*b,k+=g),v=r(H)}function H(){var O=Date.now()-p,U=!1,N=0,B=0;C&&(N=-C*Math.exp(-O/u),N>.5||N<-.5?U=!0:N=C=0),g&&(B=-g*Math.exp(-O/u),B>.5||B<-.5?U=!0:B=g=0),U&&(e(f+N,k+B),v=r(H))}}function yn(){return typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout}function Dn(){return typeof requestAnimationFrame=="function"?requestAnimationFrame:function(n){return setTimeout(n,16)}}});var ti=j((sa,ei)=>{ei.exports=Sn;function Sn(n){if(n)return{capture:Jt,release:Jt};var e,t,i,a=!1;return{capture:o,release:r};function o(c){a=!0,t=window.document.onselectstart,i=window.document.ondragstart,window.document.onselectstart=Kt,e=c,e.ondragstart=Kt}function r(){a&&(a=!1,window.document.onselectstart=t,e&&(e.ondragstart=i))}}function Kt(n){return n.stopPropagation(),!1}function Jt(){}});var ni=j((ca,ii)=>{ii.exports=bn;function bn(){this.x=0,this.y=0,this.scale=1}});var oi=j((ua,at)=>{at.exports=Pn;at.exports.canAttach=ai;function Pn(n,e){if(!ai(n))throw new Error("svg element is required for svg.panzoom to work");var t=n.ownerSVGElement;if(!t)throw new Error("Do not apply panzoom to the root element. Use its child instead (e.g. ). As of March 2016 only FireFox supported transform on the root element");e.disableKeyboardInteraction||t.setAttribute("tabindex",0);var i={getBBox:o,getScreenCTM:r,getOwner:a,applyTransform:p,initTransform:c};return i;function a(){return t}function o(){var u=n.getBBox();return{left:u.x,top:u.y,width:u.width,height:u.height}}function r(){var u=t.getCTM();return u||t.getScreenCTM()}function c(u){var _=n.getCTM();_===null&&(_=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix()),u.x=_.e,u.y=_.f,u.scale=_.a,t.removeAttributeNS(null,"viewBox")}function p(u){n.setAttribute("transform","matrix("+u.scale+" 0 0 "+u.scale+" "+u.x+" "+u.y+")")}}function ai(n){return n&&n.ownerSVGElement&&n.getCTM}});var si=j((la,ot)=>{ot.exports=Rn;ot.exports.canAttach=ri;function Rn(n,e){var t=ri(n);if(!t)throw new Error("panzoom requires DOM element to be attached to the DOM tree");var i=n.parentElement;n.scrollTop=0,e.disableKeyboardInteraction||i.setAttribute("tabindex",0);var a={getBBox:r,getOwner:o,applyTransform:c};return a;function o(){return i}function r(){return{left:0,top:0,width:n.clientWidth,height:n.clientHeight}}function c(p){n.style.transformOrigin="0 0 0",n.style.transform="matrix("+p.scale+", 0, 0, "+p.scale+", "+p.x+", "+p.y+")"}}function ri(n){return n&&n.parentElement&&n.style}});var vi=j((da,Ci)=>{"use strict";var ci=Ft(),rt=$t(),En=Xt(),An=Qt(),hi=ti(),wn=hi(),Tn=hi(!0),kn=ni(),ui=oi(),li=si(),Nn=1,Mn=1.75,di=300,pi=200;Ci.exports=gi;function gi(n,e){e=e||{};var t=e.controller;if(t||(ui.canAttach(n)?t=ui(n,e):li.canAttach(n)&&(t=li(n,e))),!t)throw new Error("Cannot create panzoom for the current type of dom element");var i=t.getOwner(),a={x:0,y:0},o=!1,r=new kn;t.initTransform&&t.initTransform(r);var c=typeof e.filterKey=="function"?e.filterKey:Ce,p=typeof e.pinchSpeed=="number"?e.pinchSpeed:1,u=e.bounds,_=typeof e.maxZoom=="number"?e.maxZoom:Number.POSITIVE_INFINITY,D=typeof e.minZoom=="number"?e.minZoom:0,f=typeof e.boundsPadding=="number"?e.boundsPadding:.05,C=typeof e.zoomDoubleClickSpeed=="number"?e.zoomDoubleClickSpeed:Mn,b=e.beforeWheel||Ce,k=e.beforeMouseDown||Ce,g=typeof e.zoomSpeed=="number"?e.zoomSpeed:Nn,v=mi(e.transformOrigin),R=e.enableTextSelection?Tn:wn;Ln(u),e.autocenter&&Pi();var z,W=0,K=0,H=0,O=null,U=new Date,N,B=!1,ae=!1,I,Z,Ye,Qe,Ke,V;"smoothScroll"in e&&!e.smoothScroll?V=xn():V=An(xi,Hi,e.smoothScroll);var Je,Se,ke,Ne=!1;_t();var Me={dispose:Oi,moveBy:de,moveTo:et,smoothMoveTo:Gi,centerOn:Fi,zoomTo:qe,zoomAbs:Le,smoothZoom:Ie,smoothZoomAbs:$i,showRectangle:bi,pause:yi,resume:Di,isPaused:Si,getTransform:Ri,getMinZoom:Ei,setMinZoom:Ai,getMaxZoom:wi,setMaxZoom:Ti,getTransformOrigin:ki,setTransformOrigin:Ni,getZoomSpeed:Mi,setZoomSpeed:Li};En(Me);var ct=typeof e.initialX=="number"?e.initialX:r.x,ut=typeof e.initialY=="number"?e.initialY:r.y,lt=typeof e.initialZoom=="number"?e.initialZoom:r.scale;return(ct!=r.x||ut!=r.y||lt!=r.scale)&&Le(ct,ut,lt),Me;function yi(){ht(),Ne=!0}function Di(){Ne&&(_t(),Ne=!1)}function Si(){return Ne}function bi(s){var l=i.getBoundingClientRect(),d=oe(l.width,l.height),m=s.right-s.left,S=s.bottom-s.top;if(!Number.isFinite(m)||!Number.isFinite(S))throw new Error("Invalid rectangle");var A=d.x/m,w=d.y/S,L=Math.min(A,w);r.x=-(s.left+m/2)*L+d.x/2,r.y=-(s.top+S/2)*L+d.y/2,r.scale=L}function oe(s,l){if(t.getScreenCTM){var d=t.getScreenCTM(),m=d.a,S=d.d,A=d.e,w=d.f;a.x=s*m-A,a.y=l*S-w}else a.x=s,a.y=l;return a}function Pi(){var s,l,d=0,m=0,S=pt();if(S)d=S.left,m=S.top,s=S.right-S.left,l=S.bottom-S.top;else{var A=i.getBoundingClientRect();s=A.width,l=A.height}var w=t.getBBox();if(!(w.width===0||w.height===0)){var L=l/w.height,me=s/w.width,re=Math.min(me,L);r.x=-(w.left+w.width/2)*re+s/2+d,r.y=-(w.top+w.height/2)*re+l/2+m,r.scale=re}}function Ri(){return r}function Ei(){return D}function Ai(s){D=s}function wi(){return _}function Ti(s){_=s}function ki(){return v}function Ni(s){v=mi(s)}function Mi(){return g}function Li(s){if(!Number.isFinite(s))throw new Error("Zoom speed should be a number");g=s}function xi(){return{x:r.x,y:r.y}}function et(s,l){r.x=s,r.y=l,tt(),pe("pan"),it()}function dt(s,l){et(r.x+s,r.y+l)}function tt(){var s=pt();if(s){var l=!1,d=Ii(),m=s.left-d.right;return m>0&&(r.x+=m,l=!0),m=s.right-d.left,m<0&&(r.x+=m,l=!0),m=s.top-d.bottom,m>0&&(r.y+=m,l=!0),m=s.bottom-d.top,m<0&&(r.y+=m,l=!0),l}}function pt(){if(u){if(typeof u=="boolean"){var s=i.getBoundingClientRect(),l=s.width,d=s.height;return{left:l*f,top:d*f,right:l*(1-f),bottom:d*(1-f)}}return u}}function Ii(){var s=t.getBBox(),l=qi(s.left,s.top);return{left:l.x,top:l.y,right:s.width*r.scale+l.x,bottom:s.height*r.scale+l.y}}function qi(s,l){return{x:s*r.scale+r.x,y:l*r.scale+r.y}}function it(){o=!0,z=window.requestAnimationFrame(Bi)}function mt(s,l,d){if(st(s)||st(l)||st(d))throw new Error("zoom requires valid numbers");var m=r.scale*d;if(m_){if(r.scale===_)return;d=_/r.scale}var S=oe(s,l);if(r.x=S.x-d*(S.x-r.x),r.y=S.y-d*(S.y-r.y),u&&f===1&&D===1)r.scale*=d,tt();else{var A=tt();A||(r.scale*=d)}pe("zoom"),it()}function Le(s,l,d){var m=d/r.scale;mt(s,l,m)}function Fi(s){var l=s.ownerSVGElement;if(!l)throw new Error("ui element is required to be within the scene");var d=s.getBoundingClientRect(),m=d.left+d.width/2,S=d.top+d.height/2,A=l.getBoundingClientRect(),w=A.width/2-m,L=A.height/2-S;de(w,L,!0)}function Gi(s,l){de(s-r.x,l-r.y,!0)}function de(s,l,d){if(!d)return dt(s,l);Je&&Je.cancel();var m={x:0,y:0},S={x:s,y:l},A=0,w=0;Je=rt(m,S,{step:function(L){dt(L.x-A,L.y-w),A=L.x,w=L.y}})}function Hi(s,l){Fe(),et(s,l)}function Oi(){ht()}function _t(){i.addEventListener("mousedown",bt,{passive:!1}),i.addEventListener("dblclick",St,{passive:!1}),i.addEventListener("touchstart",Ct,{passive:!1}),i.addEventListener("keydown",gt,{passive:!1}),ci.addWheelListener(i,wt,{passive:!1}),it()}function ht(){ci.removeWheelListener(i,wt),i.removeEventListener("mousedown",bt),i.removeEventListener("keydown",gt),i.removeEventListener("dblclick",St),i.removeEventListener("touchstart",Ct),z&&(window.cancelAnimationFrame(z),z=0),V.cancel(),Et(),At(),R.release(),nt()}function Bi(){o&&Zi()}function Zi(){o=!1,t.applyTransform(r),pe("transform"),z=0}function gt(s){var l=0,d=0,m=0;if(s.keyCode===38?d=1:s.keyCode===40?d=-1:s.keyCode===37?l=1:s.keyCode===39?l=-1:s.keyCode===189||s.keyCode===109?m=1:(s.keyCode===187||s.keyCode===107)&&(m=-1),!c(s,l,d,m)){if(l||d){s.preventDefault(),s.stopPropagation();var S=i.getBoundingClientRect(),A=Math.min(S.width,S.height),w=.05,L=A*w*l,me=A*w*d;de(L,me)}if(m){var re=Tt(m*100),A=v?Pe():zi();qe(A.x,A.y,re)}}}function zi(){var s=i.getBoundingClientRect();return{x:s.width/2,y:s.height/2}}function Ct(s){if(Wi(s),be(),s.touches.length===1)return Vi(s,s.touches[0]);s.touches.length===2&&(Ke=Dt(s.touches[0],s.touches[1]),ke=!0,vt())}function Wi(s){e.onTouch&&!e.onTouch(s)||(s.stopPropagation(),s.preventDefault())}function Ui(s){be(),!(e.onDoubleClick&&!e.onDoubleClick(s))&&(s.preventDefault(),s.stopPropagation())}function Vi(s){K=new Date;var l=s.touches[0],d=J(l);N=d;var m=oe(d.x,d.y);I=m.x,Z=m.y,Ye=I,Qe=Z,V.cancel(),vt()}function vt(){B||(B=!0,document.addEventListener("touchmove",ft),document.addEventListener("touchend",xe),document.addEventListener("touchcancel",xe))}function ft(s){if(s.touches.length===1){s.stopPropagation();var l=s.touches[0],d=J(l),m=oe(d.x,d.y),S=m.x-I,A=m.y-Z;S!==0&&A!==0&&kt(),I=m.x,Z=m.y,de(S,A)}else if(s.touches.length===2){ke=!0;var w=s.touches[0],L=s.touches[1],me=Dt(w,L),re=1+(me/Ke-1)*p,Nt=J(w),Mt=J(L);if(I=(Nt.x+Mt.x)/2,Z=(Nt.y+Mt.y)/2,v){var d=Pe();I=d.x,Z=d.y}qe(I,Z,re),Ke=me,s.stopPropagation(),s.preventDefault()}}function be(){H&&(clearTimeout(H),H=0)}function yt(s){if(e.onClick){be();var l=I-Ye,d=Z-Qe,m=Math.sqrt(l*l+d*d);m>5||(H=setTimeout(function(){H=0,e.onClick(s)},di))}}function xe(s){if(be(),s.touches.length>0){var l=J(s.touches[0]),d=oe(l.x,l.y);I=d.x,Z=d.y}else{var m=new Date;if(m-W0&&(l*=100);var d=Tt(l);if(d!==1){var m=v?Pe():J(s);qe(m.x,m.y,d),s.preventDefault()}}}function J(s){var l,d,m=i.getBoundingClientRect();return l=s.clientX-m.left,d=s.clientY-m.top,{x:l,y:d}}function Ie(s,l,d){var m=r.scale,S={scale:m},A={scale:d*m};V.cancel(),Fe(),Se=rt(S,A,{step:function(w){Le(s,l,w.scale)},done:ji})}function $i(s,l,d){var m=r.scale,S={scale:m},A={scale:d};V.cancel(),Fe(),Se=rt(S,A,{step:function(w){Le(s,l,w.scale)}})}function Pe(){var s=i.getBoundingClientRect();return{x:s.width*v.x,y:s.height*v.y}}function qe(s,l,d){return V.cancel(),Fe(),mt(s,l,d)}function Fe(){Se&&(Se.cancel(),Se=null)}function Tt(s){var l=Math.sign(s),d=Math.min(.25,Math.abs(g*s/128));return 1-l*d}function kt(){ae||(pe("panstart"),ae=!0,V.start())}function nt(){ae&&(ke||V.stop(),pe("panend"))}function ji(){pe("zoomend")}function pe(s){Me.fire(s,Me)}}function mi(n){if(n){if(typeof n=="object")return(!ge(n.x)||!ge(n.y))&&_i(n),n;_i()}}function _i(n){throw console.error(n),new Error(["Cannot parse transform origin.","Some good examples:",' "center center" can be achieved with {x: 0.5, y: 0.5}',' "top center" can be achieved with {x: 0.5, y: 0}',' "bottom right" can be achieved with {x: 1, y: 1}'].join(` +`))}function Ce(){}function Ln(n){var e=typeof n;if(!(e==="undefined"||e==="boolean")){var t=ge(n.left)&&ge(n.top)&&ge(n.bottom)&&ge(n.right);if(!t)throw new Error("Bounds object is not valid. It can be: undefined, boolean (true|false) or an object {left, top, right, bottom}")}}function ge(n){return Number.isFinite(n)}function st(n){return Number.isNaN?Number.isNaN(n):n!==n}function xn(){return{start:Ce,stop:Ce,cancel:Ce}}function In(){if(typeof document>"u")return;var n=document.getElementsByTagName("script");if(!n)return;for(var e,t=0;t{let t=this._nodes.findIndex(i=>Object.is(e,i));this._nodes.splice(t,1)}),this.save()}loadDatabasePlan(e){this.currentPlanName=e;for(let t in this._database.plans){let i=this._database.plans[e];if(t===e){this.loadFromEncoded(i);return}}e!==""&&this.loadDatabasePlan("")}deleteDatabasePlan(e){delete this._database.plans[e],this.currentPlanName===e&&this.loadDatabasePlan(""),n.pushToDatabase(this._database)}createAndSelectDatabasePlan(e){let t=this._database.plans[this.currentPlanName]??"";this.saveToDatabasePlan(e,t),this.currentPlanName=e}get nodes(){return this._nodes}get databasePlanNames(){return Object.keys(this._database.plans)}get currentPlanName(){return this._database.currentPlan}serialize(){let e={nodes:[]};for(let t of this._nodes)e.nodes.push(t.toSerializable());return JSON.stringify(n.objToArray(e))}saveToUrl(e){location.hash=e}loadFromJson(e){let t=JSON.parse(e),i=n.dataFromArray(t),a=new Map;for(let o of i.nodes){let r=q.fromSerializable(o);this.addNode(r),a.set(o.id,r)}for(let o=0;ot.id===n);if(e==null)throw Error(`Couldn't find resource "${n}"`);return e}function Ge(n){for(let e of ce.machines){let t=e.recipes.find(a=>a.id===n);if(t!=null)return{recipe:t,machine:e};let i=e.alternateRecipes.find(a=>a.id===n);if(i!=null)return{recipe:i,machine:e}}throw Error(`Couldn't find recipe "${n}"`)}function Lt(n){let e,t,i=0;for(let a of ce.machines){let r=(o,c)=>{let p=c.find(u=>u.id===n.id);if(p!=null){if(e!=null||t!=null)return!1;e=o,t=a,i=p.amount}return!0};for(let o of a.recipes)if(n.type==="input"&&!r(o,o.ingredients)||n.type==="output"&&!r(o,o.products))return;for(let o of a.alternateRecipes)if(n.type==="input"&&!r(o,o.ingredients)||n.type==="output"&&!r(o,o.products))return}if(!(e==null||t==null))return{recipe:e,machine:t,resourceAmount:i}}var Y=class n extends EventTarget{static menuOpenedEvent="menu-opened";static menuClosedEvent="menu-closed";constructor(e,t){super(),this._menuContainer=document.querySelector(`#${t}-context-menu-container`),this._menuContainer.addEventListener("mousedown",()=>{this.closeMenu()}),window.addEventListener("keydown",i=>{i.code==="Escape"&&this._isMenuOpened&&(i.preventDefault(),i.stopPropagation(),this.closeMenu())}),this.addMenuTo(e)}openMenu(){this._isMenuOpened=!0,this._menuContainer.classList.remove("hidden"),this.dispatchEvent(new Event(n.menuOpenedEvent))}closeMenu(){this._isMenuOpened=!1,this._menuContainer.classList.add("hidden"),this.dispatchEvent(new Event(n.menuClosedEvent))}addMenuTo(e){let t=document.querySelector(`#${this.containerId}>.context-menu`);e.addEventListener("contextmenu",i=>{let a=i;i.preventDefault(),this._openingPosition={x:a.clientX,y:a.clientY},t.style.top=`${a.pageY+5}px`,t.style.left=`${a.pageX+5}px`,this.openMenu(),i.stopPropagation()}),this.addEventListener(n.menuOpenedEvent,function(){e.classList.add("selected")}),this.addEventListener(n.menuClosedEvent,function(){e.classList.remove("selected")})}get isMenuOpened(){return this._isMenuOpened}get openingPosition(){return this._openingPosition}get containerId(){return this._menuContainer.id}setupMenuOption(e,t){e.addEventListener("mousedown",i=>{i.stopPropagation()}),e.addEventListener("click",()=>{this._isMenuOpened&&(this.dispatchEvent(new Event(t)),this.closeMenu())})}static setSwitchState(e,t){t?e.classList.add("enabled"):e.classList.remove("enabled")}_menuContainer;_isMenuOpened=!1;_openingPosition};var Re=class n extends Y{static deleteLinkOptionClickedEvent="delete-node-option-clicked";constructor(e){super(e,"link"),this._deleteLinkOption=document.querySelector(`#${this.containerId} #delete-link-option`),this.setupMenuOption(this._deleteLinkOption,n.deleteLinkOptionClickedEvent)}_deleteLinkOption};var fi=en(Ci());var g=class n extends EventTarget{static isCanvasLockedChangedEvent="canvas-locked-changed";static isGridEnabledChangedEvent="grid-enabled-changed";static zoomChangedEvent="canvas-locked-changed";static connectingResourceIdChangedEvent="connecting-resource-id-changed";static get instance(){return this._instance}get isCanvasLocked(){return this._isCanvasLocked}set isCanvasLocked(e){e?E.context.pause():E.context.resume(),this._isCanvasLocked=e,this.dispatchEvent(new Event(n.isCanvasLockedChangedEvent))}get isGridEnabled(){return this._isGridEnabled}set isGridEnabled(e){this._isGridEnabled=e,this.dispatchEvent(new Event(n.isGridEnabledChangedEvent))}get zoom(){return this._zoom}set zoom(e){this._zoom=e,this.dispatchEvent(new Event(n.zoomChangedEvent))}get connectingResource(){return this._connectingResource}set connectingResource(e){this._connectingResource=e,this.dispatchEvent(new Event(n.connectingResourceIdChangedEvent))}constructor(){super()}static _instance=new n;_isCanvasLocked=!1;_isGridEnabled=!1;_zoom=1;_connectingResource};var E=class{static configurePanContext(e){this._panContext=(0,fi.default)(document.querySelector("#viewport"),{zoomDoubleClickSpeed:1,minZoom:.05,maxZoom:25,beforeMouseDown:()=>!this._isPanning,beforeWheel:t=>(t.preventDefault(),!this._isZooming&&!t.ctrlKey)}),e.addEventListener("wheel",t=>{let i={x:t.deltaX,y:t.deltaY};i.x===0&&t.shiftKey&&(i.x=i.y,i.y=0),!this._isZooming&&!t.ctrlKey&&this.context.moveTo(this.context.getTransform().x-i.x,this.context.getTransform().y-i.y)},{passive:!0}),this._panContext.on("zoom",()=>{g.instance.zoom=this._panContext.getTransform().scale??1}),window.addEventListener("focusout",()=>{this.stopPanning(),this.stopZooming()}),window.addEventListener("blur",()=>{this.stopPanning(),this.stopZooming()})}static setPanningButtons(e,t){window.addEventListener("keydown",i=>{if(i.repeat)return;let a=e.includes(i.code),r=t.includes(i.key);(a||r)&&(i.preventDefault(),this.startPanning())}),window.addEventListener("keyup",i=>{if(i.repeat)return;let a=e.includes(i.code),r=t.includes(i.key);(a||r)&&(i.preventDefault(),this.stopPanning())})}static setZoomingButtons(e,t){window.addEventListener("keydown",i=>{if(i.repeat)return;let a=e.includes(i.code),r=t.includes(i.key);(a||r)&&(i.preventDefault(),this.startZooming())}),window.addEventListener("keyup",i=>{if(i.repeat)return;let a=e.includes(i.code),r=t.includes(i.key);(a||r)&&(i.preventDefault(),this.stopZooming())})}static get context(){if(this._panContext==null)throw Error("Pan context is not defined");return this._panContext}static get isPanning(){return this._isPanning}static get isZooming(){return this._isZooming}static startPanning(){this._isPanning=!0,this._container.classList.add("move")}static stopPanning(){this._isPanning=!1,this._container.classList.remove("move")}static startZooming(){this._isZooming=!0}static stopZooming(){this._isZooming=!1}constructor(){}static _panContext;static _isPanning=!1;static _isZooming=!1;static _container=document.querySelector("#container")};var Q=class n{static connect(e,t){let i=new n(e,t,E.context),a=document.querySelector("#viewport>g.links");a.appendChild(i._svgPath),a.appendChild(i._resourceDisplay),R.saveToUrl()}constructor(e,t,i){this._firstSlot=e,this._secondSlot=t,this._panContext=i,e.connectedTo=t,t.connectedTo=e;let a=(c,p)=>{if(p.resourcesAmount>=c.resourcesAmount)p.resourcesAmount=c.resourcesAmount,this._resourceAmountDisplay.innerText=`${+p.resourcesAmount.toFixed(4)}/min`;else throw Error("Increasing link's resources amount not yet implemented.")};e.addEventListener(T.boundsChangedEvent,this.recalculate.bind(this)),t.addEventListener(T.boundsChangedEvent,this.recalculate.bind(this)),e.addEventListener(T.deletionEvent,this.delete.bind(this,t)),t.addEventListener(T.deletionEvent,this.delete.bind(this,e)),e.addEventListener(T.resourcesAmountChangedEvent,()=>a(e,t)),t.addEventListener(T.resourcesAmountChangedEvent,()=>a(t,e)),this._svgPath=k.createSvgPath("link","animate-appearance"),this._resourceDisplay=this.createResourceDisplay({id:e.resourceId,amount:e.resourcesAmount}),this.recalculate();let r=new Re(this._svgPath);r.addMenuTo(e.slotSvgRect),r.addMenuTo(t.slotSvgRect),r.addEventListener(Re.deleteLinkOptionClickedEvent,()=>{e.delete()});let o=c=>{r.isMenuOpened||(c?(this._svgPath.classList.add("selected"),e.slotSvgRect.classList.add("selected"),t.slotSvgRect.classList.add("selected")):(this._svgPath.classList.remove("selected"),e.slotSvgRect.classList.remove("selected"),t.slotSvgRect.classList.remove("selected")))};e.slotSvgRect.addEventListener("mouseenter",()=>o(!0)),t.slotSvgRect.addEventListener("mouseenter",()=>o(!0)),this._svgPath.addEventListener("mouseenter",()=>o(!0)),e.slotSvgRect.addEventListener("mouseleave",()=>o(!1)),t.slotSvgRect.addEventListener("mouseleave",()=>o(!1)),this._svgPath.addEventListener("mouseleave",()=>o(!1))}recalculate(){let e=Pe.fromSvgBounds(this._firstSlot.slotSvgRect,this._panContext),t=Pe.fromSvgBounds(this._secondSlot.slotSvgRect,this._panContext),i=te.fromTwoPoints({x:e.x+e.width,y:e.y},{x:t.x,y:t.y}),a=te.fromTwoPoints({x:t.x,y:t.y+t.height},{x:e.x+e.width,y:e.y+e.height}),r=new se().startAt(i.startPoint).curve(i).verticalLineTo(i.endPoint.y+t.height).curve(a).verticalLineTo(i.startPoint.y).build();this._svgPath.setAttribute("d",r),this._svgPath.style.clipPath=`view-box path("${r}")`;let o=e.height/2+t.height/2,c=Math.abs(i.startPoint.x-i.endPoint.x),p=50,u=90,h=Math.max(p,Math.min(u,Math.min(o,c)-16)),y={x:i.startDeviationPoint.x,y:(i.startPoint.y+i.endPoint.y)/2+o/2},v=h+100;this._resourceDisplay.setAttribute("x",`${y.x-v/2}`),this._resourceDisplay.setAttribute("y",`${y.y-h/2}`),this._resourceDisplay.setAttribute("width",`${v}`),this._resourceDisplay.setAttribute("height",`${h}`);let C=this._resourceDisplay.querySelector("div.resource-amount");C.style.fontSize=`${h/u*18}px`}createResourceDisplay(e){let t=k.createSvgForeignObject("resource-display"),i=document.createElement("div");i.classList.add("container");let a=document.createElement("img");a.classList.add("icon");let r=M(e.id);return a.src=I(r.iconPath),a.alt=r.displayName,this._resourceAmountDisplay=document.createElement("div"),this._resourceAmountDisplay.classList.add("resource-amount"),this._resourceAmountDisplay.innerText=`${+e.amount.toFixed(3)}/min`,i.appendChild(a),i.appendChild(this._resourceAmountDisplay),t.appendChild(i),t}delete(e){this._isDeleted||(this._isDeleted=!0,e.delete(),this._svgPath.remove(),this._resourceDisplay.remove())}_firstSlot;_secondSlot;_panContext;_svgPath;_resourceDisplay;_resourceAmountDisplay;_isDeleted=!1};var P=class n extends EventTarget{static startedConnectingSlotsEvent="started-connecting-slots";static finishedConnectingSlotsEvent="finished-connecting-slots";static getInstance(){return this._instance!=null?this._instance:(this._instance=new this,this._instance)}handleMouseMove(e){if(this._mouseStatus===n.MouseStatus.DraggingNode)this.dragNodeTo({x:e.clientX,y:e.clientY});else if(this._mouseStatus===n.MouseStatus.ConnectingInputSlot||this._mouseStatus===n.MouseStatus.ConnectingOutputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._slotConnectingLine==null||this._slotConnectingCurve==null)throw Error("Slot connecting line wasn't created.");let t=n.clientToCanvasPosition({x:e.clientX,y:e.clientY});this._slotConnectingCurve=te.fromTwoPoints(this._slotConnectingCurve.startPoint,t);let i=new se().startAt(this._slotConnectingCurve.startPoint).curve(this._slotConnectingCurve).build();this._slotConnectingLine.setAttribute("d",i)}}handleTouchMove(e){if(this._mouseStatus===n.MouseStatus.DraggingNode&&e.touches.length===1){let t=e.touches[0];this.dragNodeTo({x:t.clientX,y:t.clientY})}}handleMouseUp(){this._mouseStatus===n.MouseStatus.DraggingNode&&(this._mouseStatus=n.MouseStatus.Free,this._draggedNode=void 0,this._lastMousePos.x=0,this._lastMousePos.y=0,R.saveToUrl())}cancelConnectingSlots(){(this._mouseStatus==n.MouseStatus.ConnectingInputSlot||this._mouseStatus==n.MouseStatus.ConnectingOutputSlot)&&(this._firstConnectingSlot=void 0,this._slotConnectingLine?.remove(),this._slotConnectingLine=void 0,this._slotConnectingCurve=void 0,this._mouseStatus=n.MouseStatus.Free,g.instance.connectingResource=void 0,document.querySelector(".controls #cancel-linking").classList.add("hidden"),document.querySelector("#canvas-context-menu-container #cancel-linking-option").classList.add("hidden"),this.dispatchEvent(new Event(n.finishedConnectingSlotsEvent)))}inputSlotClicked(e,t){if(this._mouseStatus===n.MouseStatus.Free)this._mouseStatus=n.MouseStatus.ConnectingInputSlot,this.startConnectingSlot(e,t,!0),g.instance.connectingResource={type:"input",id:t.resourceId};else if(this._mouseStatus===n.MouseStatus.ConnectingOutputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._firstConnectingSlot.resourceId!=t.resourceId)return;let i=Math.min(t.resourcesAmount,this._firstConnectingSlot.resourcesAmount),a=this._firstConnectingSlot.splitOffSlot(i),r=t.splitOffSlot(i);Q.connect(a,r),this.cancelConnectingSlots()}}outputSlotClicked(e,t){if(this._mouseStatus===n.MouseStatus.Free)this._mouseStatus=n.MouseStatus.ConnectingOutputSlot,this.startConnectingSlot(e,t,!1),g.instance.connectingResource={type:"output",id:t.resourceId};else if(this._mouseStatus===n.MouseStatus.ConnectingInputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._firstConnectingSlot.resourceId!=t.resourceId)return;let i=Math.min(t.resourcesAmount,this._firstConnectingSlot.resourcesAmount),a=this._firstConnectingSlot.splitOffSlot(i),r=t.splitOffSlot(i);Q.connect(a,r),this.cancelConnectingSlots()}}dragNodeTo(e){if(this._draggedNode==null)throw Error("Dragged node wasn't saved.");let t=this._draggedNode.position,i=E.context.getTransform().scale,a={x:e.x-this._lastMousePos.x,y:e.y-this._lastMousePos.y};this._draggedNode.position={x:t.x+a.x/i,y:t.y+a.y/i},this._lastMousePos.x=e.x,this._lastMousePos.y=e.y}startConnectingSlot(e,t,i){this._firstConnectingSlot=t;let a=E.context.getTransform().scale,r=t.slotSvgRect.getBoundingClientRect();r={x:(r.x-E.context.getTransform().x)/a,y:(r.y-E.context.getTransform().y)/a,width:r.width/a,height:r.height/a};let o={x:r.x+(i?0:r.width),y:r.y+r.height/2},c=n.clientToCanvasPosition({x:e.clientX,y:e.clientY});this._slotConnectingCurve=te.fromTwoPoints(o,c);let p=new se().startAt(this._slotConnectingCurve.startPoint).curve(this._slotConnectingCurve).build();this._slotConnectingLine=k.createSvgPath("link-hint"),this._slotConnectingLine.classList.add(i?"from-input":"from-output"),this._slotConnectingLine.setAttribute("d",p),this._viewport.appendChild(this._slotConnectingLine),document.querySelector(".controls #cancel-linking").classList.remove("hidden"),document.querySelector("#canvas-context-menu-container #cancel-linking-option").classList.remove("hidden"),this.dispatchEvent(new Event(n.startedConnectingSlotsEvent))}startDraggingNode(e,t){this._mouseStatus===n.MouseStatus.Free&&(this._mouseStatus=n.MouseStatus.DraggingNode,this._draggedNode=e,this._lastMousePos.x=t.x,this._lastMousePos.y=t.y)}get firstConnectingSlot(){return this._firstConnectingSlot}get mouseStatus(){return this._mouseStatus}static clientToCanvasPosition(e){let t=document.querySelector("#viewport");return new DOMPointReadOnly(e.x,e.y).matrixTransform(t.getScreenCTM().inverse())}constructor(){super()}static _instance;_firstConnectingSlot;_draggedNode;_slotConnectingLine;_slotConnectingCurve;_mouseStatus=n.MouseStatus.Free;_lastMousePos=new X(0,0);_viewport=document.querySelector("#viewport")};(e=>{let n;(o=>(o[o.Free=0]="Free",o[o.DraggingNode=1]="DraggingNode",o[o.ConnectingInputSlot=2]="ConnectingInputSlot",o[o.ConnectingOutputSlot=3]="ConnectingOutputSlot"))(n=e.MouseStatus||={})})(P||={});var fe=class n{constructor(e,t,i){this._relatedSlot=e,this._slotsGroup=t,this._type=i,this._resourcesDisplay=k.createSvgForeignObject("resources-display"),this._resourcesAmountDisplay=document.createElement("div"),this.createResourceDisplay(),this._relatedSlot.addEventListener(T.boundsChangedEvent,this.update.bind(this))}createResourceDisplay(){let e=document.createElement("div"),t=M(this._relatedSlot.resourceId),i=document.createElement("img");i.classList.add("icon"),i.src=I(t.iconPath),i.title=t.displayName,i.alt=t.displayName,this._resourcesAmountDisplay.classList.add("amount"),e.appendChild(i),e.appendChild(this._resourcesAmountDisplay),this._resourcesDisplay.appendChild(e),this._slotsGroup.appendChild(this._resourcesDisplay);let a=()=>{let r=Math.max(n._minZoomMultiplier,Math.min(n._maxZoomMultiplier,g.instance.zoom));e.style.padding=`0 ${10/r}px`,e.style.gap=`${4/r}px`,this.update()};a(),g.instance.addEventListener(g.zoomChangedEvent,a),g.instance.addEventListener(g.connectingResourceIdChangedEvent,()=>{let r=g.instance.connectingResource;this._resourcesDisplay.classList.remove("correct"),this._resourcesDisplay.classList.remove("wrong"),r!=null&&(r.id===this._relatedSlot.resourceId&&r.type!==this._type?(this._resourcesDisplay.classList.add("correct"),this._resourcesDisplay.classList.remove("wrong")):(this._resourcesDisplay.classList.add("wrong"),this._resourcesDisplay.classList.remove("correct")))})}update(){let e=+this._relatedSlot.resourcesAmount.toFixed(3);if(e===0)this._resourcesDisplay.classList.add("hidden");else{this._resourcesDisplay.classList.remove("hidden");let i=24/Math.max(n._minZoomMultiplier,Math.min(n._maxZoomMultiplier,g.instance.zoom));this._resourcesAmountDisplay.style.fontSize=`${i*.6}px`,this._resourcesAmountDisplay.innerText=`${e}`;let a=+this._relatedSlot.slotSvgRect.getAttribute("height"),r=+this._relatedSlot.slotSvgRect.getAttribute("y"),o=this._type==="input"?0:T.slotWidth;this._resourcesDisplay.setAttribute("height",`${i}`),this._resourcesDisplay.setAttribute("width","1"),this._resourcesDisplay.setAttribute("x",`${o}`),this._resourcesDisplay.setAttribute("y",`${r+a/2-i/2}`)}}_relatedSlot;_type;_slotsGroup;_resourcesDisplay;_resourcesAmountDisplay;static _minZoomMultiplier=.5;static _maxZoomMultiplier=1.5};var ze=class extends _e{constructor(e,t,i){super(e,t,i,"exceeding"),this._resourcesDisplay=new fe(this,t,"output"),this.slotSvgRect.addEventListener("click",a=>{!E.isPanning&&!E.isZooming&&P.getInstance().outputSlotClicked(a,this)}),this.slotSvgRect.addEventListener("dblclick",a=>{a.stopPropagation()})}splitOffSlot(e){return this.parentGroup.addSlot(e)}_resourcesDisplay};var ve=class extends T{constructor(e,t,i,...a){super(e,t,i,"input-slot",...a)}};var We=class extends ve{constructor(e,t,i){super(e,t,i,"missing"),this._resourcesDisplay=new fe(this,t,"input"),this.slotSvgRect.addEventListener("click",a=>{!E.isPanning&&!E.isZooming&&P.getInstance().inputSlotClicked(a,this)}),this.slotSvgRect.addEventListener("dblclick",a=>{a.stopPropagation()})}splitOffSlot(e){return this.parentGroup.addSlot(e)}_resourcesDisplay};var ue=class n extends EventTarget{static boundsChangedEvent="bounds-changed";static changedVacantResourcesAmountEvent="changed-vacant-resources-amount";constructor(e,t,i,a){super(),this._type=t,this._resource={...i},this._parentNode=e;let r=t==="input"?new X(0,a):new X(F.nodeWidth+T.slotWidth,a);this._groupSvg=k.createSvgGroup(r,`${t}-slots`,"slots-group"),this._lastSlot=this.initializeLastSlot(i),e.nodeSvgGroup.appendChild(this._groupSvg),this.addEventListener(n.boundsChangedEvent,()=>{for(let o of this._slots)o.dispatchEvent(new Event(T.boundsChangedEvent))})}addSlot(e){e=Math.min(e,this._lastSlot.resourcesAmount),this._lastSlot.resourcesAmount-=e;let t;if(this._type==="input")t=new ve(this,this._groupSvg,{id:this.resourceId,amount:e});else if(this._type==="output")t=new _e(this,this._groupSvg,{id:this.resourceId,amount:e});else throw Error("Unexpected slots group type");return this._slots.push(t),t.addEventListener(T.deletionEvent,()=>{let i=this._slots.findIndex(a=>Object.is(a,t));this._slots.splice(i,1),this.updateSlotPositions()}),t.addEventListener(T.resourcesAmountChangedEvent,()=>{this.updateSlotPositions()}),this.updateSlotPositions(),t}delete(){for(R.lockSaving();this._slots.length!==0;)this._slots[0].delete();this._groupSvg.remove(),R.unlockSaving(),R.saveToUrl()}toSerializable(){let e=[];for(let t of this._slots)e.push(t.toSerializable());return{resourceId:this.resourceId,connectedOutputs:e}}get height(){let e;return this._type=="input"?e=this._parentNode.inputResourcesAmount:e=this._parentNode.outputResourcesAmount,this._parentNode.height*(this.resourcesAmount/e)}get resourcesAmount(){return this._resource.amount}get vacantResourcesAmount(){return this._lastSlot.resourcesAmount}set resourcesAmount(e){let t=this._resource.amount-e;if(t>0){{let i=Math.min(t,this._lastSlot.resourcesAmount);t-=i,this._lastSlot.resourcesAmount-=i}for(let i=this._slots.length-1;i>=0&&t>0;--i){let a=this._slots[i],r=Math.min(t,a.resourcesAmount);t-=r,a.resourcesAmount-=r,a.resourcesAmount===0&&a.delete()}}this._resource.amount=e,this.updateSlotPositions(),this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent))}get resourceId(){return this._resource.id}get parentNode(){return this._parentNode}updateSlotPositions(){let e=this.resourcesAmount,t=0;for(let i of this._slots)i.setYPosition(t),i.updateHeight(),e-=i.resourcesAmount,t+=+(i.slotSvgRect.getAttribute("height")??0);this._lastSlot.setYPosition(t),this._lastSlot.resourcesAmount=e,this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent))}initializeLastSlot(e){if(this._type==="input")return new We(this,this._groupSvg,{...e});if(this._type==="output")return new ze(this,this._groupSvg,{...e});throw Error("Unexpected slots group type")}_type;_resource;_slots=[];_lastSlot;_groupSvg;_parentNode};var ye=class n extends Y{static deleteNodeOptionClickedEvent="delete-node-option-clicked";static configureNodeOptionClickedEvent="configure-node-option-clicked";constructor(e){super(e,"node"),this._deleteNodeOption=document.querySelector(`#${this.containerId} #delete-node-option`),this.setupMenuOption(this._deleteNodeOption,n.deleteNodeOptionClickedEvent),this._configureNodeOption=document.querySelector(`#${this.containerId} #configure-node-option`),this.setupMenuOption(this._configureNodeOption,n.configureNodeOptionClickedEvent)}_deleteNodeOption;_configureNodeOption};var we=class{inputsConfigurators=new Array;outputsConfigurators=new Array;powerConfigurator;removeFromDom(){for(let e of this.inputsConfigurators)e.remove();for(let e of this.outputsConfigurators)e.remove();this.powerConfigurator!=null&&this.powerConfigurator.remove()}};var z=class{static replaceAllPlaceholders(){for(let e in this._icons){let t=`svg.${e}_icon-placeholder`;document.querySelectorAll(t).forEach(i=>{this.placeIcon(i,this._icons[e]),i.classList.remove(t)})}}static createIcon(e){let t=k.createSvgElement("svg");return this.placeIcon(t,this._icons[e]),t}static placeIcon(e,t){e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("viewBox","0 -960 960 960");let i=k.createSvgPath();i.setAttribute("d",t),e.appendChild(i)}static _icons={plus:"M440-440H240q-17 0-28.5-11.5T200-480q0-17 11.5-28.5T240-520h200v-200q0-17 11.5-28.5T480-760q17 0 28.5 11.5T520-720v200h200q17 0 28.5 11.5T760-480q0 17-11.5 28.5T720-440H520v200q0 17-11.5 28.5T480-200q-17 0-28.5-11.5T440-240v-200Z","locked-lock":"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm240-200q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Z","unlocked-lock":"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h360v-80q0-50-35-85t-85-35q-42 0-73.5 25.5T364-751q-4 14-16.5 22.5T320-720q-17 0-28.5-11t-8.5-26q14-69 69-116t128-47q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM240-160v-400 400Z",unlink:"m625-449-71-71h46q17 0 28.5 11.5T640-480q0 10-4 18t-11 13ZM820-84q-11 11-28 11t-28-11L84-764q-11-11-11-28t11-28q11-11 28-11t28 11l680 680q11 11 11 28t-11 28ZM280-280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h120q17 0 28.5 11.5T440-320q0 17-11.5 28.5T400-280H280Zm80-160q-17 0-28.5-11.5T320-480q0-17 11.5-28.5T360-520h25l79 80H360Zm380 112q-9-14-6.5-30t16.5-25q23-17 36.5-42t13.5-55q0-50-35-85t-85-35H560q-17 0-28.5-11.5T520-640q0-17 11.5-28.5T560-680h120q83 0 141.5 58.5T880-480q0 49-22.5 91.5T795-318q-14 9-30 6.5T740-328Z","chevron-up":"M480-555.69 310.15-385.85q-5.61 5.62-13.77 6-8.15.39-14.53-6-6.39-6.38-6.39-14.15 0-7.77 6.39-14.15l175.53-175.54q9.7-9.69 22.62-9.69 12.92 0 22.62 9.69l175.53 175.54q5.62 5.61 6 13.77.39 8.15-6 14.53-6.38 6.39-14.15 6.39-7.77 0-14.15-6.39L480-555.69Z",cross:"M480-424 284-228q-11 11-28 11t-28-11q-11-11-11-28t11-28l196-196-196-196q-11-11-11-28t11-28q11-11 28-11t28 11l196 196 196-196q11-11 28-11t28 11q11 11 11 28t-11 28L536-480l196 196q11 11 11 28t-11 28q-11 11-28 11t-28-11L480-424Z",trash:"M280-120q-33 0-56.5-23.5T200-200v-520q-17 0-28.5-11.5T160-760q0-17 11.5-28.5T200-800h160q0-17 11.5-28.5T400-840h160q17 0 28.5 11.5T600-800h160q17 0 28.5 11.5T800-760q0 17-11.5 28.5T760-720v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM400-280q17 0 28.5-11.5T440-320v-280q0-17-11.5-28.5T400-640q-17 0-28.5 11.5T360-600v280q0 17 11.5 28.5T400-280Zm160 0q17 0 28.5-11.5T600-320v-280q0-17-11.5-28.5T560-640q-17 0-28.5 11.5T520-600v280q0 17 11.5 28.5T560-280ZM280-720v520-520Z",configuration:"M480-120q-17 0-28.5-11.5T440-160v-160q0-17 11.5-28.5T480-360q17 0 28.5 11.5T520-320v40h280q17 0 28.5 11.5T840-240q0 17-11.5 28.5T800-200H520v40q0 17-11.5 28.5T480-120Zm-320-80q-17 0-28.5-11.5T120-240q0-17 11.5-28.5T160-280h160q17 0 28.5 11.5T360-240q0 17-11.5 28.5T320-200H160Zm160-160q-17 0-28.5-11.5T280-400v-40H160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520h120v-40q0-17 11.5-28.5T320-600q17 0 28.5 11.5T360-560v160q0 17-11.5 28.5T320-360Zm160-80q-17 0-28.5-11.5T440-480q0-17 11.5-28.5T480-520h320q17 0 28.5 11.5T840-480q0 17-11.5 28.5T800-440H480Zm160-160q-17 0-28.5-11.5T600-640v-160q0-17 11.5-28.5T640-840q17 0 28.5 11.5T680-800v40h120q17 0 28.5 11.5T840-720q0 17-11.5 28.5T800-680H680v40q0 17-11.5 28.5T640-600Zm-480-80q-17 0-28.5-11.5T120-720q0-17 11.5-28.5T160-760h320q17 0 28.5 11.5T520-720q0 17-11.5 28.5T480-680H160Z",power:"M420-412H302q-14 0-20-12t2-23l203-295q5-7 12-9t15 1q8 3 11.5 9.5T528-726l-27 218h140q14 0 20 13t-3 24L431-199q-5 6-12 7.5t-14-1.5q-7-3-10.5-9t-2.5-14l28-196Z",mouse:"M480-80q-116 0-198-82t-82-198v-240q0-116 82-198t198-82q116 0 198 82t82 198v240q0 116-82 198T480-80Zm40-520h160q0-72-45.5-127T520-796v196Zm-240 0h160v-196q-69 14-114.5 69T280-600Zm200 440q83 0 141.5-58.5T680-360v-160H280v160q0 83 58.5 141.5T480-160Zm0-360Zm40-80Zm-80 0Zm40 80Z","mouse-left":"M 480 -80 a 269.6 269.6 90 0 1 -198 -82 A 269.6 269.6 90 0 1 200 -360 V -600 c 0 -77.2 27.2 -143.2 82 -198 A 269.6 269.6 90 0 1 480 -880 c 77.2 0 143.2 27.2 198 82 A 269.6 269.6 90 0 1 760 -600 v 240 c 0 77.2 -27.2 143.2 -82 198 A 269.6 269.6 90 0 1 480 -80 Z m 40 -520 h 160 c 0 -48 -15.2 -90.4 -45.6 -126.8 A 195.2 195.2 90 0 0 520 -796 V -600 Z m -40 440 c 55.2 0 102.4 -19.6 141.6 -58.4 A 192.8 192.8 90 0 0 680 -360 v -160 H 280 v 160 c 0 55.2 19.6 102.4 58.4 141.6 A 192.8 192.8 90 0 0 480 -160 Z","mouse-right":"M 480 -80 a 269.6 269.6 90 0 1 -198 -82 A 269.6 269.6 90 0 1 200 -360 V -600 c 0 -77.2 27.2 -143.2 82 -198 A 269.6 269.6 90 0 1 480 -880 c 77.2 0 143.2 27.2 198 82 A 269.6 269.6 90 0 1 760 -600 v 240 c 0 77.2 -27.2 143.2 -82 198 A 269.6 269.6 90 0 1 480 -80 Z M 280 -600 h 160 V -796 c -46 9.2 -84 32 -114.4 69.2 A 193.6 193.6 90 0 0 280 -600 Z m 200 440 c 55.2 0 102.4 -19.6 141.6 -58.4 A 192.8 192.8 90 0 0 680 -360 v -160 H 280 v 160 c 0 55.2 19.6 102.4 58.4 141.6 A 192.8 192.8 90 0 0 480 -160 Z","mouse-drag":"M 699.11 -179.11 H 592.06 l 22.98 22.45 a 20.63 20.63 0 0 1 6.26 15.15 c 0 5.91 -2.08 10.96 -6.26 15.14 a 20.63 20.63 0 0 1 -15.14 6.27 a 20.63 20.63 0 0 1 -15.15 -6.27 l -59 -59 a 18.32 18.32 0 0 1 -4.45 -6.8 A 23.13 23.13 0 0 1 520 -200 c 0 -2.78 0.43 -5.4 1.3 -7.83 c 0.88 -2.44 2.36 -4.7 4.44 -6.8 l 59.01 -59 a 20.33 20.33 0 0 1 14.88 -6.27 c 5.75 0 10.7 2.1 14.89 6.27 a 20.33 20.33 0 0 1 6.26 14.88 c 0 5.75 -2.09 10.7 -6.26 14.89 l -22.98 22.97 h 107.57 V -328.46 l -23.5 23.5 c -4.17 4.18 -9.05 6.18 -14.62 6 c -5.57 -0.17 -10.44 -2.34 -14.62 -6.52 a 20.33 20.33 0 0 1 -6.27 -14.89 c 0 -5.74 2.1 -10.7 6.27 -14.88 l 59 -59 a 18.32 18.32 0 0 1 6.8 -4.45 c 2.43 -0.87 5.05 -1.3 7.83 -1.3 c 2.78 0 5.4 0.43 7.83 1.3 c 2.44 0.88 4.7 2.36 6.8 4.44 l 59.52 59.53 c 4.18 4.18 6.27 9.06 6.27 14.63 s -2.1 10.44 -6.27 14.62 a 20.33 20.33 0 0 1 -14.88 6.26 c -5.75 0 -10.7 -2.08 -14.88 -6.26 l -23.5 -22.98 v 107.57 h 107.05 l -22.98 -22.45 a 20.63 20.63 0 0 1 -6.27 -15.15 c 0 -5.91 2.1 -10.96 6.27 -15.14 a 20.63 20.63 0 0 1 15.14 -6.27 c 5.92 0 10.97 2.1 15.15 6.27 l 59 59 a 18.3 18.3 0 0 1 4.44 6.8 A 23.1 23.1 0 0 1 920 -200 c 0 2.78 -0.43 5.4 -1.3 7.83 a 18.3 18.3 0 0 1 -4.44 6.8 l -59.53 59.52 c -4.18 4.18 -9.06 6.18 -14.63 6 c -5.57 -0.17 -10.44 -2.34 -14.62 -6.52 a 20.33 20.33 0 0 1 -6.26 -14.88 c 0 -5.75 2.08 -10.7 6.26 -14.89 l 22.98 -22.97 H 740.89 v 107.05 l 22.45 -22.98 a 20.63 20.63 0 0 1 15.15 -6.26 c 5.91 0 10.96 2.08 15.14 6.26 a 20.63 20.63 0 0 1 6.26 15.14 c 0 5.92 -2.08 10.97 -6.26 15.15 l -59 59 a 18.3 18.3 0 0 1 -6.8 4.44 A 23.1 23.1 0 0 1 720 0 c -2.78 0 -5.4 -0.43 -7.83 -1.3 a 18.3 18.3 0 0 1 -6.8 -4.44 l -59.52 -59.53 a 19.44 19.44 0 0 1 -6 -14.89 a 21.3 21.3 0 0 1 6.52 -14.88 a 20.33 20.33 0 0 1 14.88 -6.26 c 5.75 0 10.7 2.08 14.89 6.26 l 22.97 23.5 V -179.11 Z M 320 -160 c -77.33 0 -143.33 -27.33 -198 -82 c -54.67 -54.67 -82 -120.67 -82 -198 V -680 c 0 -77.33 27.33 -143.33 82 -198 C 176.67 -932.67 242.67 -960 320 -960 s 143.33 27.33 198 82 c 54.67 54.67 82 120.67 82 198 v 240 c 0 77.33 -27.33 143.33 -82 198 c -54.67 54.67 -120.67 82 -198 82 Z m 40 -520 h 160 c 0 -48 -15.17 -90.33 -45.5 -127 S 406 -866.67 360 -876 v 196 Z m -39 440 c 55.33 0 102.5 -19.5 141.5 -58.5 S 520.67 -384.67 520 -440 V -600 H 120 v 160 c 0 55.33 19.5 102.5 58.5 141.5 S 264.67 -240 320 -240 h 1 Z","mac-command":"M260-120q-58 0-99-41t-41-99q0-58 41-99t99-41h60v-160h-60q-58 0-99-41t-41-99q0-58 41-99t99-41q58 0 99 41t41 99v60h160v-60q0-58 41-99t99-41q58 0 99 41t41 99q0 58-41 99t-99 41h-60v160h60q58 0 99 41t41 99q0 58-41 99t-99 41q-58 0-99-41t-41-99v-60H400v60q0 58-41 99t-99 41Zm0-80q25 0 42.5-17.5T320-260v-60h-60q-25 0-42.5 17.5T200-260q0 25 17.5 42.5T260-200Zm440 0q25 0 42.5-17.5T760-260q0-25-17.5-42.5T700-320h-60v60q0 25 17.5 42.5T700-200ZM400-400h160v-160H400v160ZM260-640h60v-60q0-25-17.5-42.5T260-760q-25 0-42.5 17.5T200-700q0 25 17.5 42.5T260-640Zm380 0h60q25 0 42.5-17.5T760-700q0-25-17.5-42.5T700-760q-25 0-42.5 17.5T640-700v60Z","question-mark":"M584-637q0-43-28.5-69T480-732q-29 0-52.5 12.5T387-683q-16 23-43.5 26.5T296-671q-14-13-15.5-32t9.5-36q32-48 81.5-74.5T480-840q97 0 157.5 55T698-641q0 45-19 81t-70 85q-37 35-50 54.5T542-376q-4 24-20.5 40T482-320q-23 0-39.5-15.5T426-374q0-39 17-71.5t57-68.5q51-45 67.5-69.5T584-637ZM480-80q-33 0-56.5-23.5T400-160q0-33 23.5-56.5T480-240q33 0 56.5 23.5T560-160q0 33-23.5 56.5T480-80Z",touchpad:"M593-80q-24 0-46-9t-39-26L332-292q-11-11-11.5-27.5T331-348l6-6q14-14 34-19t40 0l69 20v-287q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v340q0 20-15.5 31.5T509-262l-47-13 103 103q6 6 13 9t15 3h167q33 0 56.5-23.5T840-240v-160q0-17 11.5-28.5T880-440q17 0 28.5 11.5T920-400v160q0 66-47 113T760-80H593Zm47-280q-17 0-28.5-11.5T600-400v-120q0-17 11.5-28.5T640-560q17 0 28.5 11.5T680-520v120q0 17-11.5 28.5T640-360Zm120 0q-17 0-28.5-11.5T720-400v-80q0-17 11.5-28.5T760-520q17 0 28.5 11.5T800-480v80q0 17-11.5 28.5T760-360Zm0 200H565h195Zm-600-40q-33 0-56.5-23.5T80-280v-480q0-33 23.5-56.5T160-840h600q33 0 56.5 23.5T840-760v120q0 17-11.5 28.5T800-600q-17 0-28.5-11.5T760-640v-120H160v480h72q17 0 28.5 11.5T272-240q0 17-11.5 28.5T232-200h-72Z","touchpad-two":"M160-200q-33 0-56.5-23.5T80-280v-480q0-33 23.5-56.5T160-840h600q33 0 56.5 23.5T840-760v120q0 17-11.5 28.5T800-600q-17 0-28.5-11.5T760-640v-120H160v480h72q17 0 28.5 11.5T272-240q0 17-11.5 28.5T232-200h-72Zm560-200v-80q0-17 11.5-28.5T760-520q17 0 28.5 11.5T800-480v80q0 17-11.5 28.5T760-360q-17 0-28.5-11.5T720-400Zm40 240H565h195ZM593-80q-24 0-46-9t-39-26L332-292q-11-11-11.5-27.5T331-348l6-6q14-14 34-19t40 0l69 20v-287q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v340q0 20-15.5 31.5T509-262l-47-13 103 103q6 6 13 9t15 3h167q33 0 56.5-23.5T840-240v-160q0-17 11.5-28.5T880-440q17 0 28.5 11.5T920-400v160q0 66-47 113T760-80H593Zm7-320v-280q0-17 11.5-28.5T640-720q17 0 28.5 11.5T680-680v280q0 17-11.5 28.5T640-360q-17 0-28.5-11.5T600-400Z","touch-move":"M 592.8 -40 a 120 120 90 0 1 -84.8 -35.2 L 332 -252 a 36.8 36.8 90 0 1 -11.2 -29.6 c 0.8 -11.6 5.2 -21.6 13.2 -29.2 a 80 80 90 0 1 80 -21.2 l 66 19.2 V -640 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 380 c 0 13.2 -5.2 24 -16 32 a 39.2 39.2 90 0 1 -35.2 7.2 l -46 -13.2 l 102 102 c 3.6 3.2 8 6 12.8 8.4 a 36 36 90 0 0 15.2 3.6 H 760 c 22 0 40.8 -8 56.4 -23.6 c 16 -15.6 23.6 -34.4 23.6 -56.4 v -160 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 160 c 0 44 -16 81.6 -47.2 112.8 A 154 154 90 0 1 760 -40 h -167.2 Z M 640 -520 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 120 c 0 11.2 -4 20.8 -11.6 28.4 c -7.6 8 -17.2 11.6 -28.4 11.6 a 38.8 38.8 90 0 1 -28.4 -11.6 A 38.8 38.8 90 0 1 600 -360 v -120 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 Z m 120 40 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 80 c 0 11.2 -4 20.8 -11.6 28.4 c -7.6 8 -17.2 11.6 -28.4 11.6 a 38.8 38.8 90 0 1 -28.4 -11.6 A 38.8 38.8 90 0 1 720 -360 v -80 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 Z M 225.6 -579.2 v -68 c 0 -6.4 2.4 -12 6.4 -16 c 4 -4 9.2 -6 15.6 -6 c 6 0 11.2 2 15.2 6.4 c 4 4 6.4 9.2 6.4 15.2 v 68 l 23.2 -24 c 4 -4.4 9.6 -6.4 16 -6.4 c 6 0 11.2 2 15.6 6.4 c 4 4 6.4 9.6 6.4 16 c 0 5.6 -2.4 11.2 -6.4 15.2 l -61.2 61.2 a 19.2 19.2 90 0 1 -7.2 4.8 a 24 24 90 0 1 -16 0 a 19.2 19.2 90 0 1 -7.2 -4.8 L 170.4 -572.8 a 20 20 90 0 1 -6 -15.6 c 0 -5.6 2.4 -10.8 6.8 -15.2 c 4 -4.4 9.2 -6.4 15.2 -6.4 s 11.2 2 15.6 6.4 l 24 24 Z m -110.8 -112 l 24 23.6 c 4 4 6.4 9.6 6.4 16 c 0 6 -2.4 11.2 -6.8 15.6 c -4 4 -9.2 6.4 -15.6 6.4 a 21.2 21.2 90 0 1 -16 -6.4 L 46.4 -697.2 a 19.2 19.2 90 0 1 -4.8 -7.2 a 24 24 90 0 1 -1.2 -8 a 24 24 90 0 1 1.2 -8 a 19.2 19.2 90 0 1 4.8 -7.2 l 61.2 -61.2 c 4 -4.4 9.6 -6.8 15.6 -6.8 c 5.6 0 10.8 2.4 15.2 6.8 c 4 4 6.4 9.2 6.4 15.2 s -2 11.2 -6.4 15.6 l -24 24 h 68.4 c 6 0 11.2 2 15.6 6 c 4 4 6 9.2 6 15.6 a 20.8 20.8 90 0 1 -21.6 21.6 h -68 Z m 266 0 h -68 a 20.8 20.8 90 0 1 -16 -6 a 20.8 20.8 90 0 1 -6 -15.2 c 0 -6.4 2 -11.6 6.4 -15.6 c 4 -4 9.2 -6.4 15.2 -6.4 h 68 l -24 -23.2 a 21.6 21.6 90 0 1 -6.4 -15.6 c 0 -6 2 -11.2 6.4 -16 c 4 -4 9.6 -6.4 16 -6.4 c 5.6 0 11.2 2.4 15.2 6.8 l 61.2 61.2 c 2.4 2 4 4.4 4.8 6.8 a 24 24 90 0 1 0 16.4 a 19.2 19.2 90 0 1 -4.8 7.2 L 387.2 -636 a 20 20 90 0 1 -15.2 6.4 a 22 22 90 0 1 -15.2 -6.8 a 21.2 21.2 90 0 1 -6.4 -15.6 c 0 -6 2 -11.2 6.4 -15.6 l 24 -24 Z M 225.6 -845.2 l -24 24 a 20.8 20.8 90 0 1 -30.4 0 a 21.2 21.2 90 0 1 -6.8 -15.2 c 0 -6 2.4 -11.2 6.8 -15.6 L 232 -914 c 2 -2.4 4.4 -4 6.8 -4.8 a 24 24 90 0 1 8 -1.2 a 24 24 90 0 1 8.4 1.2 c 2.4 1.2 4.8 2.4 7.2 4.8 L 324 -852.4 a 20.8 20.8 90 0 1 0 30.4 c -4 4 -9.6 6.4 -15.6 6.4 a 21.2 21.2 90 0 1 -15.2 -6.4 l -24.4 -24 v 68.4 c 0 6 -2 11.2 -6.4 15.6 c -4 4 -9.2 6 -15.2 6 a 20.8 20.8 90 0 1 -15.6 -6 a 20.8 20.8 90 0 1 -6.4 -15.6 v -68 Z",touch:"M419-80q-28 0-52.5-12T325-126L124-381q-8-9-7-21.5t9-20.5q20-21 48-25t52 11l74 45v-328q0-17 11.5-28.5T340-760q17 0 29 11.5t12 28.5v400q0 23-20.5 34.5T320-286l-36-22 104 133q6 7 14 11t17 4h221q33 0 56.5-23.5T720-240v-160q0-17-11.5-28.5T680-440H501q-17 0-28.5-11.5T461-480q0-17 11.5-28.5T501-520h179q50 0 85 35t35 85v160q0 66-47 113T640-80H419Zm83-260Zm-23-260q-17 0-28.5-11.5T439-640q0-2 5-20 8-14 12-28.5t4-31.5q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 17 4 31.5t12 28.5q3 5 4 10t1 10q0 17-11 28.5T202-600q-11 0-20.5-6T167-621q-13-22-20-47t-7-52q0-83 58.5-141.5T340-920q83 0 141.5 58.5T540-720q0 27-7 52t-20 47q-5 9-14 15t-20 6Z",pinch:"M593-40q-24 0-46-9t-39-26L332-252q-12-12-11-29.5t13-29.5q16-16 37.5-21.5t42.5.5l66 19v-327q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v380q0 20-16 32t-35 7l-46-13 102 102q5 5 12.5 8.5T593-120h167q33 0 56.5-23.5T840-200v-160q0-17 11.5-28.5T880-400q17 0 28.5 11.5T920-360v160q0 66-47 113T760-40H593Zm109-200ZM380-818 142-580h68q13 0 21.5 8.5T240-550q0 13-8.5 21.5T210-520H80q-17 0-28.5-11.5T40-560v-130q0-13 8.5-21.5T70-720q13 0 21.5 8.5T100-690v68l238-238h-68q-13 0-21.5-8.5T240-890q0-13 8.5-21.5T270-920h130q17 0 28.5 11.5T440-880v130q0 13-8.5 21.5T410-720q-13 0-21.5-8.5T380-750v-68Zm260 298q17 0 28.5 11.5T680-480v120q0 17-11.5 28.5T640-320q-17 0-28.5-11.5T600-360v-120q0-17 11.5-28.5T640-520Zm120 40q17 0 28.5 11.5T800-440v80q0 17-11.5 28.5T760-320q-17 0-28.5-11.5T720-360v-80q0-17 11.5-28.5T760-480Z",search:"M380-320q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l224 224q11 11 11 28t-11 28q-11 11-28 11t-28-11L532-372q-30 24-69 38t-83 14Zm0-80q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z",tick:"m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z","three-dots":"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z",grid:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z","disable-grid":"M333-200v-133H200v133h133Zm214 0v-100l-33-33H413v133h134Zm80 0Zm116-133Zm-410-80v-101l-33-33H200v134h133Zm80 0Zm347 0v-134H627v99l35 35h98ZM529-547Zm-329-80Zm347 0v-133H413v98l35 35h99Zm213 0v-133H627v133h133ZM316-760Zm524 525L235-840h525q33 0 56.5 23.5T840-760v525ZM200-120q-33 0-56.5-23.5T120-200v-640l720 720H200Zm591 64L56-792q-11-11-11.5-27.5T56-848q11-11 28-11t28 11l736 736q12 12 11.5 28T847-56q-12 11-28 11.5T791-56Z",github:"M 478.5698 -960 C 213.9331 -960 0 -744.4898 0 -477.8743 c 0 213.12 137.0743 393.5216 327.2327 457.3714 c 23.7747 4.8 32.4833 -10.3739 32.4833 -23.138 c 0 -11.1771 -0.7837 -49.489 -0.7837 -89.4073 c -133.1265 28.7412 -160.849 -57.4727 -160.849 -57.4727 c -21.3943 -55.8759 -53.0939 -70.2367 -53.0939 -70.2367 c -43.5722 -29.5347 3.1739 -29.5347 3.1739 -29.5347 c 48.3331 3.1935 73.6947 49.489 73.6947 49.489 c 42.7788 73.4302 111.7127 52.6824 139.4449 39.9086 c 3.9576 -31.1314 16.6433 -52.6824 30.1127 -64.6531 c -106.178 -11.1771 -217.8906 -52.6824 -217.8906 -237.8743 c 0 -52.6824 19.0041 -95.7845 49.1167 -129.3061 c -4.751 -11.9706 -21.3943 -61.4694 4.7608 -127.7192 c 0 0 40.4082 -12.7739 131.52 49.489 a 460.1143 460.1143 90 0 1 119.6473 -15.9673 c 40.4082 0 81.6 5.5935 119.6376 15.9673 c 91.1216 -62.2629 131.5298 -49.489 131.5298 -49.489 c 26.1551 66.2498 9.502 115.7486 4.751 127.7192 c 30.9061 33.5216 49.1265 76.6237 49.1265 129.3061 c 0 185.1918 -111.7127 225.8939 -218.6841 237.8743 c 17.4367 15.1641 32.4833 43.8955 32.4833 89.3976 c 0 64.6531 -0.7837 116.542 -0.7837 132.4996 c 0 12.7739 8.7184 27.9478 32.4833 23.1576 c 190.1584 -63.8694 327.2327 -244.2612 327.2327 -457.3812 C 957.1298 -744.4898 742.4131 -960 478.5698 -960 z","buy-me-a-coffee":"M 502.983 -516.5235 c -34.4819 14.7565 -73.61 31.4946 -124.3271 31.4946 a 235.3689 235.3689 90 0 1 -62.7715 -8.6543 l 35.0824 360.1389 a 60.1745 60.1745 90 0 0 59.9719 55.2206 s 49.7339 2.582 66.3368 2.582 c 17.864 0 71.4183 -2.582 71.4183 -2.582 a 60.167 60.167 90 0 0 59.9643 -55.2206 l 37.5668 -397.9609 c -16.7906 -5.7345 -33.7314 -9.5475 -52.8413 -9.5475 c -33.0258 -0.015 -59.6491 11.3639 -90.4006 24.5292 Z M 808.4341 -703.412 l -5.2841 -26.6458 c -4.7362 -23.9062 -15.4996 -46.4913 -40.0363 -55.1306 c -7.8661 -2.7697 -16.7906 -3.9556 -22.8178 -9.6751 c -6.0347 -5.7195 -7.8136 -14.6064 -9.2097 -22.8478 c -2.582 -15.1243 -5.0139 -30.2561 -7.656 -45.3579 c -2.2893 -12.9776 -4.0982 -27.5615 -10.0579 -39.4658 c -7.7461 -15.9875 -23.8236 -25.3398 -39.8111 -31.5246 a 229.3041 229.3041 90 0 0 -25.0396 -7.7461 C 608.5754 -952.3515 566.5726 -956.217 525.478 -958.4313 a 1033.0095 1033.0095 90 0 0 -147.9931 2.4544 c -36.6286 3.3326 -75.2088 7.3557 -110.0059 20.0332 c -12.7224 4.6311 -25.8352 10.2005 -35.5027 20.0256 c -11.8743 12.0844 -15.7473 30.7515 -7.078 45.8158 c 6.1548 10.6884 16.588 18.2392 27.6666 23.2457 a 224.3878 224.3878 90 0 0 44.9151 14.6139 c 43.0086 9.5099 87.5484 13.2403 131.4877 14.8316 c 48.698 1.9665 97.4711 0.3753 145.9365 -4.7662 a 830.8991 830.8991 90 0 0 35.893 -4.7437 c 14.066 -2.1542 23.088 -20.5435 18.9448 -33.3561 c -4.9539 -15.312 -18.2918 -21.2566 -33.3636 -18.9448 c -2.2142 0.3453 -4.4285 0.6755 -6.6502 0.9908 l -1.5987 0.2327 a 812.9301 812.9301 90 0 1 -47.0392 4.6011 a 1051.9468 1051.9468 90 0 1 -71.3282 2.4544 c -23.3733 0 -46.7615 -0.6605 -70.0898 -2.1992 c -10.6433 -0.698 -21.2566 -1.5762 -31.8474 -2.6571 c -4.8188 -0.5029 -9.6225 -1.0358 -14.4263 -1.6288 l -4.5711 -0.5855 l -0.9908 -0.1351 l -4.7437 -0.6905 a 499.4027 499.4027 90 0 1 -28.9576 -5.164 a 4.3534 4.3534 90 0 1 0 -8.4966 h 0.1876 a 469.9647 469.9647 90 0 1 25.0696 -4.6011 l 8.4141 -1.291 h 0.0751 c 5.2541 -0.3453 10.5457 -1.291 15.7698 -1.9065 c 45.5081 -4.7362 91.2863 -6.35 137.0195 -4.8338 c 22.1948 0.6455 44.3897 1.9515 66.4869 4.2033 c 4.7512 0.4879 9.4799 1.0058 14.2011 1.5837 c 1.8089 0.2252 3.6328 0.4804 5.4493 0.698 l 3.6779 0.5254 a 508.9426 508.9426 90 0 1 31.8999 5.802 c 15.6873 3.4077 35.818 4.5185 42.7909 21.6919 c 2.2217 5.4568 3.2275 11.514 4.4585 17.2335 l 1.5612 7.2957 a 115281.889 115281.889 90 0 0 11.1837 52.0607 a 9.4574 9.4574 90 0 1 -7.9562 11.3564 h -0.0976 l -2.2668 0.3002 l -2.2292 0.3002 a 1373.0477 1373.0477 90 0 1 -63.2444 6.7177 a 1505.5562 1505.5562 90 0 1 -126.4663 5.089 a 1482.9636 1482.9636 90 0 1 -169.625 -9.8627 c -6.0948 -0.7281 -12.1895 -1.5012 -18.2843 -2.2893 c 4.7287 0.6005 -3.4377 -0.4654 -5.089 -0.698 c -3.873 -0.5404 -7.7461 -1.1034 -11.6266 -1.6888 c -13.0002 -1.9515 -25.9328 -4.3534 -38.9104 -6.455 c -15.6873 -2.5895 -30.699 -1.2985 -44.8851 6.455 a 65.301 65.301 90 0 0 -27.0361 28.0269 c -6.1248 12.6549 -7.9412 26.4357 -10.6808 40.0288 C 151.2432 -703.1493 146.9798 -688.5129 148.5936 -674.552 c 3.4752 30.1285 24.5442 54.6127 54.8378 60.0919 a 1554.9673 1554.9673 90 0 0 85.8971 12.9101 a 1587.3401 1587.3401 90 0 0 367.7798 2.1242 a 19.3726 19.3726 90 0 1 21.3917 21.2341 l -2.8747 27.8693 l -17.331 168.9345 a 134235.3364 134235.3364 90 0 1 -23.3582 227.3301 c -1.6513 16.3928 -1.8915 33.296 -4.9989 49.4937 c -4.9088 25.4674 -22.1498 41.1096 -47.3095 46.8291 a 329.635 329.635 90 0 1 -70.2324 8.2114 c -26.203 0.1426 -52.3909 -1.0208 -78.6014 -0.8782 c -27.9744 0.1576 -62.2386 -2.4244 -83.8255 -23.2457 c -18.9748 -18.2843 -21.5944 -46.9192 -24.1839 -71.681 c -3.4377 -32.7781 -6.8529 -65.5487 -10.238 -98.3193 l -18.9898 -182.2124 l -12.2796 -117.9021 c -0.2027 -1.9515 -0.4128 -3.873 -0.6005 -5.8396 c -1.4787 -14.066 -11.4314 -27.8317 -27.1262 -27.1187 c -13.4355 0.593 -28.6949 12.0094 -27.1187 27.1187 l 9.1046 87.4058 l 18.8247 180.8163 c 5.3667 51.3551 10.7184 102.7177 16.0625 154.0954 c 1.0283 9.8402 1.9966 19.7104 3.0774 29.5506 c 5.9071 53.7795 46.9792 82.7597 97.8314 90.9185 c 29.7082 4.7812 60.137 5.7645 90.2805 6.2524 c 38.6402 0.623 77.6707 2.1091 115.6804 -4.8938 c 56.3165 -10.3356 98.5745 -47.94 104.6092 -106.2755 l 5.164 -50.537 c 5.727 -55.7235 11.4464 -111.4546 17.1509 -167.1856 l 18.6746 -182.0923 l 8.5567 -83.4652 a 19.3651 19.3651 90 0 1 15.6122 -17.0383 c 16.1001 -3.1299 31.4946 -8.4891 42.9486 -20.7462 c 18.2392 -19.5152 21.8646 -44.9601 15.4246 -70.6077 Z M 202.6058 -685.413 c 0.2477 -0.1126 -0.2102 1.9891 -0.3978 2.9723 c -0.0375 -1.4862 0.0375 -2.7997 0.3978 -2.9723 Z m 1.5612 12.0919 c 0.1276 -0.0901 0.5179 0.4278 0.9157 1.0508 c -0.6005 -0.5704 -0.9908 -0.9983 -0.9307 -1.0508 h 0.015 Z m 1.5387 2.0266 c 0.5554 0.9457 0.8557 1.5387 0 0 Z m 3.0849 2.507 h 0.0751 c 0 0.0901 0.1501 0.1801 0.1952 0.2702 a 2.0041 2.0041 90 0 0 -0.2852 -0.2702 h 0.015 Z m 540.5198 -3.7529 c -5.787 5.5093 -14.5088 8.0688 -23.1181 9.3448 c -96.6005 14.3362 -194.6195 21.5944 -292.2783 18.3894 c -69.8946 -2.3869 -139.0536 -10.1479 -208.2577 -19.9281 c -6.7778 -0.9532 -14.126 -2.1917 -18.7872 -7.1906 c -8.7819 -9.4274 -4.4735 -28.4172 -2.1842 -39.8036 c 2.0941 -10.4332 6.0948 -24.349 18.5095 -25.8277 c 19.3651 -2.2743 41.8677 5.8996 61.0377 8.8044 c 23.073 3.5278 46.2361 6.3425 69.4743 8.4591 c 99.22 9.0371 200.0988 7.6335 298.8685 -5.5919 c 18.0066 -2.4169 35.9381 -5.2316 53.817 -8.4366 c 15.9274 -2.8522 33.5812 -8.2114 43.1962 8.279 c 6.6052 11.2363 7.4833 26.2705 6.455 38.9704 a 21.722 21.722 90 0 1 -6.7553 14.5389 h 0.0225 Z",clear:"M280-120q-33 0-56.5-23.5T200-200v-520q-17 0-28.5-11.5T160-760q0-17 11.5-28.5T200-800h160q0-17 11.5-28.5T400-840h160q17 0 28.5 11.5T600-800h160q17 0 28.5 11.5T800-760q0 17-11.5 28.5T760-720v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520Zm-400 0v520-520Zm200 316 76 76q11 11 28 11t28-11q11-11 11-28t-11-28l-76-76 76-76q11-11 11-28t-11-28q-11-11-28-11t-28 11l-76 76-76-76q-11-11-28-11t-28 11q-11 11-11 28t11 28l76 76-76 76q-11 11-11 28t11 28q11 11 28 11t28-11l76-76Z"}};var ee=class n{constructor(e){this._nodeConfig=e,this._editElement=document.createElement("div"),this._editElement.classList.add("edit"),this._iconContainer=document.createElement("div"),this._iconContainer.classList.add("icon-container"),this._inputElement=document.createElement("input"),this._unitsElement=document.createElement("div"),this._unitsElement.classList.add("units"),this._editElement.appendChild(this._iconContainer),this._editElement.appendChild(this._inputElement),this._editElement.appendChild(this._unitsElement)}build(){if(this._minimumGetter==null||this._maximumGetter==null||this._relatedPropertyGetter==null||this._relatedPropertySetter==null)throw Error("Configurator builder can't build without required fields");let e=a=>{let r=this._minimumGetter();return r==null||a>=r},t=a=>{let r=this._maximumGetter();return r==null||a<=r},i=n.configuratorToFixed;return this._inputElement.addEventListener("input",()=>{let a=n.numberParser(this._inputElement.value);a!=null&&e(a)&&t(a)?(this._inputElement.classList.remove("error"),this._relatedPropertySetter(i(a))):this._inputElement.classList.add("error")}),this._inputElement.addEventListener("blur",()=>{this._inputElement.classList.remove("error");let a=n.numberParser(this._inputElement.value);a!=null&&(e(a)?t(a)||this._relatedPropertySetter(this._maximumGetter()):this._relatedPropertySetter(this._minimumGetter())),this._inputElement.value=`${i(this._relatedPropertyGetter())}`}),this._inputElement.addEventListener("keydown",a=>{a.repeat||(a.key==="Enter"&&this._inputElement.blur(),a.stopPropagation())}),this._editElement}subscribeToMachinesAmount(){return this._nodeConfig.addEventListener(ne.machinesAmountChangedEvent,this.updateInputValue.bind(this)),this}subscribeToOverclock(){return this._nodeConfig.addEventListener(ne.overclockChangedEvent,this.updateInputValue.bind(this)),this}setMinimum(e){return this._minimumGetter=e,this}setMaximum(e){return this._maximumGetter=e,this}setRelatedProperty(e,t){return this._relatedPropertyGetter=e,this._relatedPropertySetter=t,this}setInitialValue(e){return this._inputElement.value=`${e}`,this}setUnits(e){return this._unitsElement.innerText=e,this}setIconImage(e,t){let i=document.createElement("img");return i.src=I(t),i.alt=e,this._iconContainer.title=e,this._iconContainer.appendChild(i),this}setPowerSvgIcon(){let e=z.createIcon("power");return this._iconContainer.title="Power consumption",this._iconContainer.appendChild(e),this}updateInputValue(){if(this._relatedPropertyGetter==null)throw Error("Configurator builder can't build without required fields");if(!Object.is(document.activeElement,this._inputElement)){let e=n.configuratorToFixed;this._inputElement.value=`${e(this._relatedPropertyGetter())}`}}static configuratorToFixed(e){return+e.toFixed(4)}static numberParser(e){let t=+e,i=Number.parseFloat(e);if(!(Number.isNaN(t)||Number.isNaN(i)))return t}_nodeConfig;_editElement;_iconContainer;_inputElement;_unitsElement;_minimumGetter;_maximumGetter;_relatedPropertyGetter;_relatedPropertySetter};var ne=class n extends EventTarget{static machinesAmountChangedEvent="machines-amount-changed";static overclockChangedEvent="overclock-changed";static configurationUpdatedEvent="configuration-updated";constructor(e,t){super();let i=`#${n._modalContainer.id} .title-row .close`;document.querySelector(i).addEventListener("click",o=>{this._isOpened&&(o.stopPropagation(),this.closeConfigurationWindow())}),window.addEventListener("keydown",o=>{this._isOpened&&o.code==="Escape"&&(o.preventDefault(),o.stopPropagation(),this.closeConfigurationWindow()),o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.confirmConfiguration())}),this.setupTableElements(e,t);let r=()=>{this._isOpened&&(this.machinesAmount!==this._openingMachinesAmount||this.overclockRatio!==this._openingOverclockRatio?n._restoreButton.classList.remove("disabled"):n._restoreButton.classList.add("disabled"))};this.addEventListener(n.machinesAmountChangedEvent,r),this.addEventListener(n.overclockChangedEvent,r),n._restoreButton.addEventListener("click",()=>{this._isOpened&&(this.machinesAmount=this._openingMachinesAmount,this.overclockRatio=this._openingOverclockRatio)}),n._applyButton.addEventListener("click",()=>{this._isOpened&&this.confirmConfiguration()}),n._modalContainer.querySelector(".modal-window").addEventListener("click",o=>{o.stopPropagation()}),n._modalContainer.addEventListener("click",o=>{o.stopPropagation(),this.closeConfigurationWindow()})}openConfigurationWindow(e,t){this._openingMachinesAmount=e,this._openingOverclockRatio=t,this.machinesAmount=this._openingMachinesAmount,this.overclockRatio=this._openingOverclockRatio,n._machinesColumn.appendChild(this._machineConfigurator);for(let i of this._amountConfigurators.inputsConfigurators)n._amountInputsColumn.appendChild(i);for(let i of this._amountConfigurators.outputsConfigurators)n._amountOutputsColumn.appendChild(i);n._amountPowerColumn.appendChild(this._amountConfigurators.powerConfigurator),n._multipliersColumn.appendChild(this._overclockConfigurator);for(let i of this._overclockConfigurators.inputsConfigurators)n._overclockInputsColumn.appendChild(i);for(let i of this._overclockConfigurators.outputsConfigurators)n._overclockOutputsColumn.appendChild(i);n._overclockPowerColumn.appendChild(this._overclockConfigurators.powerConfigurator),n._restoreButton.classList.add("disabled"),n._modalContainer.classList.remove("hidden"),this._isOpened=!0}closeConfigurationWindow(){this._machineConfigurator.remove(),this._overclockConfigurator.remove(),this._amountConfigurators.removeFromDom(),this._overclockConfigurators.removeFromDom(),n._modalContainer.classList.add("hidden"),this._isOpened=!1}confirmConfiguration(){this.dispatchEvent(new Event(n.configurationUpdatedEvent)),this.closeConfigurationWindow()}setupTableElements(e,t){let i=n._minOverclockRatio,a=n._maxOverclockRatio;this._machineConfigurator=new ee(this).setIconImage(t.displayName,t.iconPath).setInitialValue(1).setUnits("").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>this.machinesAmount,u=>this.machinesAmount=u).subscribeToMachinesAmount().build(),this._overclockConfigurator=new ee(this).setIconImage("Overclock","Resource/Environment/Crystal/PowerShard.png").setInitialValue(100).setUnits("%").setMinimum(()=>i*100).setMaximum(()=>a*100).setRelatedProperty(()=>this.overclockRatio*100,u=>this.overclockRatio=u/100).subscribeToOverclock().build();let r=(u,h,y)=>{let v=M(u.id);if(v==null)throw Error(`Couldn't find resource descriptor for "${u.id}"`);let C=ie(u.amount,e.manufacturingDuration),b=new ee(this).setIconImage(v.displayName,v.iconPath).setInitialValue(C).setUnits("/min").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>C*this.overclockRatio*this.machinesAmount,D=>this.machinesAmount=D/C/this.overclockRatio).subscribeToMachinesAmount().subscribeToOverclock().build(),_=new ee(this).setIconImage(v.displayName,v.iconPath).setInitialValue(C).setUnits("/min").setMinimum(()=>C*i).setMaximum(()=>C*a).setRelatedProperty(()=>C*this.overclockRatio,D=>this.overclockRatio=D/C).subscribeToOverclock().build();h.push(b),y.push(_)};e.ingredients.forEach(u=>r(u,this._amountConfigurators.inputsConfigurators,this._overclockConfigurators.inputsConfigurators)),e.products.forEach(u=>r(u,this._amountConfigurators.outputsConfigurators,this._overclockConfigurators.outputsConfigurators));let o=(u,h)=>he(u,h,t.powerConsumptionExponent),c=u=>Math.pow(u/t.powerConsumption,1/t.powerConsumptionExponent),p=()=>o(t.powerConsumption,this.overclockRatio);this._amountConfigurators.powerConfigurator=new ee(this).setPowerSvgIcon().setInitialValue(t.powerConsumption).setUnits("MW").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>p()*this.machinesAmount,u=>this.machinesAmount=u/p()).subscribeToMachinesAmount().subscribeToOverclock().build(),this._overclockConfigurators.powerConfigurator=new ee(this).setPowerSvgIcon().setInitialValue(t.powerConsumption).setUnits("MW").setMinimum(()=>o(t.powerConsumption,i)).setMaximum(()=>o(t.powerConsumption,a)).setRelatedProperty(()=>o(t.powerConsumption,this.overclockRatio),u=>this.overclockRatio=c(u)).subscribeToOverclock().build()}get machinesAmount(){return this._machinesAmount}set machinesAmount(e){e!==this._machinesAmount&&(this._machinesAmount=e,this.dispatchEvent(new Event(n.machinesAmountChangedEvent)))}get overclockRatio(){return this._overclockRatio}set overclockRatio(e){if(e!==this._overclockRatio){let t=n._minOverclockRatio,i=n._maxOverclockRatio;e=Math.min(i,Math.max(t,e)),this._overclockRatio=e,this.dispatchEvent(new Event(n.overclockChangedEvent))}}static queryModalSuccessor(e){let t=`#${n._modalContainer.id} ${e}`,i=document.querySelector(t);if(i==null)throw Error(`Couldn't find required element: ${t}`);return i}static getColumn(e,t){let i=`.table.${e}>.column.${t}`;return n.queryModalSuccessor(i)}_isOpened=!1;_machinesAmount=1;_overclockRatio=1;_openingMachinesAmount=this._machinesAmount;_openingOverclockRatio=this._overclockRatio;_machineConfigurator;_overclockConfigurator;_amountConfigurators=new we;_overclockConfigurators=new we;static _minOverclockRatio=.01;static _maxOverclockRatio=2.5;static _modalContainer=document.querySelector("#machine-configuration-container");static _machinesColumn=n.getColumn("amount","machines");static _amountInputsColumn=n.getColumn("amount","inputs");static _amountOutputsColumn=n.getColumn("amount","outputs");static _amountPowerColumn=n.getColumn("amount","power");static _multipliersColumn=n.getColumn("overclock","multipliers");static _overclockInputsColumn=n.getColumn("overclock","inputs");static _overclockOutputsColumn=n.getColumn("overclock","outputs");static _overclockPowerColumn=n.getColumn("overclock","power");static _restoreButton=n.queryModalSuccessor(".restore-button");static _applyButton=n.queryModalSuccessor(".apply-button")};var Ue=class{constructor(e,t,i){this._recipe=t,this._machine=i,this._displayContainer=k.createSvgForeignObject();let a=this.createHtmlElement("div","recipe-container");this.createMachineDisplay(a,i),this.createOverclockDisplay(a),this.createInputsDisplay(a,t),this.createOutputsDisplay(a,t),this.createPowerDisplay(a,i.powerConsumption),this._displayContainer.appendChild(a),e.addEventListener(F.resourcesAmountChangedEvent,()=>{this.updateDisplays(e)})}setBounds(e){this._displayContainer.setAttribute("x",`${e.x}`),this._displayContainer.setAttribute("y",`${e.y}`),this._displayContainer.setAttribute("width",`${e.width}`),this._displayContainer.setAttribute("height",`${e.height}`)}appendTo(e){e.appendChild(this._displayContainer)}createMachineDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Machines",i.appendChild(a),this._machinesAmountDisplay=this.createAmountDisplay(i,t.displayName,1,t.iconPath),e.appendChild(i)}createInputsDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Input/min",i.appendChild(a),t.ingredients.forEach(r=>{this._inputDisplays.push({htmlElement:this.createResourceDisplay(i,r),initialAmount:r.amount})}),e.appendChild(i)}createOutputsDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Output/min",i.appendChild(a),t.products.forEach(r=>{this._outputDisplays.push({htmlElement:this.createResourceDisplay(i,r),initialAmount:r.amount})}),e.appendChild(i)}createPowerDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Power",this._powerDisplay=this.createHtmlElement("div","text"),this._powerDisplay.innerText=`${t} MW`,i.appendChild(a),i.appendChild(this._powerDisplay),e.appendChild(i)}createOverclockDisplay(e){let t=this.createHtmlElement("div","property"),i=this.createHtmlElement("div","title");i.innerText="Overclock",this._overclockDisplay=this.createHtmlElement("div","text"),this._overclockDisplay.innerText="100%",t.appendChild(i),t.appendChild(this._overclockDisplay),e.appendChild(t)}createResourceDisplay(e,t){let i=M(t.id),a=+this.toItemsInMinute(t.amount).toFixed(4);return this.createAmountDisplay(e,i.displayName,a,i.iconPath)}createAmountDisplay(e,t,i,a){let r=document.createElement("div");r.classList.add("resource");let o=this.createHtmlElement("img","icon");o.loading="lazy",o.src=I(a),o.title=t,o.alt=t;let c=this.createHtmlElement("p","amount");return c.classList.add("amount"),c.innerText=`${i}`,r.appendChild(o),r.appendChild(c),e.appendChild(r),c}toItemsInMinute(e){return ie(e,this._recipe.manufacturingDuration)}createHtmlElement(e,...t){let i=document.createElement(e);return i.classList.add(...t),i}updateDisplays(e){let t=a=>+a.toFixed(2);this._machinesAmountDisplay.innerText=`${t(e.machinesAmount)}`,this._overclockDisplay.innerText=`${t(e.overclockRatio*100)}%`;for(let a of this._inputDisplays){let r=a.initialAmount*e.overclockRatio*e.machinesAmount;a.htmlElement.innerText=`${t(this.toItemsInMinute(r))}`}for(let a of this._outputDisplays){let r=a.initialAmount*e.overclockRatio*e.machinesAmount;a.htmlElement.innerText=`${t(this.toItemsInMinute(r))}`}let i=he(this._machine.powerConsumption,e.overclockRatio,this._machine.powerConsumptionExponent);this._powerDisplay.innerText=`${t(i*e.machinesAmount)} MW`}_recipe;_machine;_displayContainer;_machinesAmountDisplay;_overclockDisplay;_inputDisplays=[];_outputDisplays=[];_powerDisplay};var le=class n{static alignPoint(e){let t=(r,o,c)=>Math.round((r-c)/o)*o+c,i=t(e.x,n.smallGridSize,n.smallGridSize/2),a=t(e.y,n.smallGridSize,n.smallGridSize/2);return{x:i,y:a}}constructor(){n._smallGridPattern.setAttribute("width",`${n.smallGridSize}`),n._smallGridPattern.setAttribute("height",`${n.smallGridSize}`),n._bigGridPattern.setAttribute("width",`${n.bigGridSize}`),n._bigGridPattern.setAttribute("height",`${n.bigGridSize}`),n._smallGridCircle.setAttribute("cx",`${n.smallGridSize/2}`),n._smallGridCircle.setAttribute("cy",`${n.smallGridSize/2}`),n._bigGridCircle.setAttribute("cx",`${n.smallGridSize/2}`),n._bigGridCircle.setAttribute("cy",`${n.smallGridSize/2}`),n._bigGridRect.setAttribute("width",`${n.bigGridSize}`),n._bigGridRect.setAttribute("height",`${n.bigGridSize}`),this.updateGridSize(),this.updateGridPosition(),g.instance.addEventListener(g.isGridEnabledChangedEvent,()=>{g.instance.isGridEnabled?this.showGrid():this.hideGrid()})}updateGridSize(){let e=g.instance.zoom,t={width:n._canvas.clientWidth/e+n.bigGridSize*2,height:n._canvas.clientHeight/e+n.bigGridSize*2};n._gridRect.setAttribute("width",`${t.width}`),n._gridRect.setAttribute("height",`${t.height}`),n._smallGridCircle.setAttribute("r",`${1/g.instance.zoom}`),g.instance.zoom<.35?(n._bigGridRect.classList.add("hidden"),n._bigGridCircle.setAttribute("r",`${1/g.instance.zoom}`)):g.instance.zoom>3?(n._bigGridRect.classList.remove("hidden"),n._smallGridCircle.setAttribute("r",`${2/g.instance.zoom}`),n._bigGridCircle.setAttribute("r",`${4/g.instance.zoom}`)):(n._bigGridRect.classList.remove("hidden"),n._bigGridCircle.setAttribute("r",`${2/g.instance.zoom}`))}updateGridPosition(){let e={x:E.context.getTransform().x/g.instance.zoom,y:E.context.getTransform().y/g.instance.zoom};n._gridRect.setAttribute("x",`${-e.x-n.bigGridSize}`),n._gridRect.setAttribute("y",`${-e.y-n.bigGridSize}`)}hideGrid(){n._gridGroup.classList.add("hidden")}showGrid(){n._gridGroup.classList.remove("hidden")}static smallGridSize=20;static bigGridSize=100;static _canvas=document.querySelector("#canvas");static _gridGroup=document.querySelector("#canvas .grid");static _gridRect=document.querySelector("#canvas .grid>rect");static _smallGridPattern=this._gridGroup.querySelector("#small-grid-pattern");static _bigGridPattern=this._gridGroup.querySelector("#big-grid-pattern");static _smallGridCircle=this._gridGroup.querySelector("#small-grid-pattern circle");static _bigGridCircle=this._gridGroup.querySelector("#big-grid-pattern circle");static _bigGridRect=this._gridGroup.querySelector("#big-grid-pattern>rect")};var F=class n extends EventTarget{static resourcesAmountChangedEvent="resources-amount-changed";static changedVacantResourcesAmountEvent="changed-vacant-resources-amount";static deletionEvent="deleted";nodeSvg;nodeSvgGroup;static nodeWidth=80;id;constructor(e,t,i){super(),this.id=n.acquireId(),this._recipe={...t},this._machine={...i},this._height=n._nodeHeight;let a=(r,o)=>r+this.toItemsInMinute(o.amount);this._inputResourcesAmount=this._recipe.ingredients.reduce(a,0),this._outputResourcesAmount=this._recipe.products.reduce(a,0),this.nodeSvgGroup=k.createSvgGroup(new X(0,0),"node","animate-appearance"),this.centerPosition=e,this.nodeSvg=k.createSvgRect({width:n.nodeWidth,height:this.height,x:T.slotWidth,y:0},"machine"),this._inputSlotGroups=this.createGroups("input",t.ingredients),this._outputSlotGroups=this.createGroups("output",t.products),this.configureContextMenu(t,i),this._resourceDisplay=new Ue(this,t,i),this._resourceDisplay.setBounds({x:T.slotWidth,y:0,width:n.nodeWidth,height:this.height}),this.nodeSvgGroup.appendChild(this.nodeSvg),this._resourceDisplay.appendTo(this.nodeSvgGroup),document.querySelector("#viewport>g.nodes").appendChild(this.nodeSvgGroup)}delete(){R.lockSaving();for(let e of this._inputSlotGroups)e.delete();for(let e of this._outputSlotGroups)e.delete();this.nodeSvgGroup.remove(),this.dispatchEvent(new Event(n.deletionEvent)),R.unlockSaving(),R.saveToUrl()}toSerializable(){let e=[];for(let a of this._outputSlotGroups)e.push(a.toSerializable());let t={...this.position};return g.instance.isGridEnabled&&(t=le.alignPoint(t)),{id:this.id,recipeId:this._recipe.id,machinesAmount:this.machinesAmount,overclockRatio:this.overclockRatio,positionX:t.x,positionY:t.y,outputsGroups:e}}static fromSerializable(e){let t=Ge(e.recipeId),i=new n({x:e.positionX,y:e.positionY},t.recipe,t.machine);return i.position={x:e.positionX,y:e.positionY},i.machinesAmount=e.machinesAmount,i.overclockRatio=e.overclockRatio,i}connectDeserializedSlots(e,t){for(let i of e.outputsGroups)for(let a of i.connectedOutputs){let r=t.get(a.connectedTo);if(r==null)throw Error("Error loading connected slot");let o=this.addOutputSlot(i.resourceId,a.resourcesAmount),c=r.addInputSlot(i.resourceId,a.resourcesAmount);Q.connect(o,c)}}get recipe(){return this._recipe}addInputSlot(e,t){let i=this._inputSlotGroups.find(a=>a.resourceId===e);if(i==null)throw Error(`Error finding group with ${e}`);return i.addSlot(t)}addOutputSlot(e,t){let i=this._outputSlotGroups.find(a=>a.resourceId===e);if(i==null)throw Error(`Error finding group with ${e}`);return i.addSlot(t)}get position(){return this._position}set position(e){this._position={...e},g.instance.isGridEnabled&&(e=le.alignPoint(e)),this.nodeSvgGroup.setAttribute("transform",`translate(${e.x}, ${e.y})`);for(let t of this._inputSlotGroups)t.dispatchEvent(new Event(ue.boundsChangedEvent));for(let t of this._outputSlotGroups)t.dispatchEvent(new Event(ue.boundsChangedEvent))}set centerPosition(e){this.position={x:e.x-n.nodeWidth/2-T.slotWidth,y:e.y-this.height/2}}get height(){return this._height}get missingResources(){let e=[];for(let t of this._inputSlotGroups){let i=t.vacantResourcesAmount;i>0&&e.push({amount:i,id:t.resourceId})}return e}get exceedingResources(){let e=[];for(let t of this._outputSlotGroups){let i=t.vacantResourcesAmount;i>0&&e.push({amount:i,id:t.resourceId})}return e}get powerConsumption(){return he(this._machine.powerConsumption,this.overclockRatio,this._machine.powerConsumptionExponent)*this.machinesAmount}get requiredPowerShards(){return xt(this.overclockRatio)}get inputResourcesAmount(){return this._inputResourcesAmount}set inputResourcesAmount(e){this._inputResourcesAmount=e,this.dispatchEvent(new Event(n.resourcesAmountChangedEvent))}get outputResourcesAmount(){return this._outputResourcesAmount}get inputSlotGroups(){return this._inputSlotGroups}get outputSlotGroups(){return this._outputSlotGroups}set outputResourcesAmount(e){this._outputResourcesAmount=e,this.dispatchEvent(new Event(n.resourcesAmountChangedEvent))}configureContextMenu(e,t){let i=new ye(this.nodeSvg);i.addEventListener(ye.deleteNodeOptionClickedEvent,()=>{this.delete()});let a=new ne(e,t),r=o=>{a.openConfigurationWindow(this.machinesAmount,this.overclockRatio),o.stopPropagation()};i.addEventListener(ye.configureNodeOptionClickedEvent,r),this.nodeSvg.addEventListener("dblclick",r),a.addEventListener(ne.configurationUpdatedEvent,()=>{this.machinesAmount=a.machinesAmount,this.overclockRatio=a.overclockRatio,R.saveToUrl()})}createGroups(e,t){let i=[],a=0;for(let r of t){let o=new ue(this,e,{id:r.id,amount:this.toItemsInMinute(r.amount)},a);i.push(o),a+=o.height,o.addEventListener(ue.changedVacantResourcesAmountEvent,()=>this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent)))}return i}toItemsInMinute(e){return ie(e,this._recipe.manufacturingDuration)}multiplyResourcesAmount(e){this.inputResourcesAmount*=e,this.outputResourcesAmount*=e;for(let t of this._inputSlotGroups)t.resourcesAmount*=e;for(let t of this._outputSlotGroups)t.resourcesAmount*=e}get machinesAmount(){return this._machinesAmount}set machinesAmount(e){let t=e/this._machinesAmount;this._machinesAmount=e,this.multiplyResourcesAmount(t)}get overclockRatio(){return this._overclockRatio}set overclockRatio(e){let t=e/this._overclockRatio;this._overclockRatio=e,this.multiplyResourcesAmount(t)}static acquireId(){return n._nextId++}_recipe;_machine;_inputResourcesAmount;_outputResourcesAmount;_machinesAmount=1;_overclockRatio=1;_height;_position=new X(0,0);_inputSlotGroups=[];_outputSlotGroups=[];_resourceDisplay;static _nextId=0;static _nodeHeight=300};var U=class n extends Y{static createNodeOptionClickedEvent="create-node-option-clicked";static lockCanvasSwitchClickedEvent="lock-canvas-switch-clicked";static toggleGridSwitchClickedEvent="toggle-grid-switch-clicked";static cancelLinkingOptionClickedEvent="cancel-linking-option-clicked";static showHelpOptionClickedEvent="show-help-option-clicked";static clearCanvasOptionClickedEvent="clear-canvas-option-clicked";static nodeFromLinkOptionClickedEvent="node-from-link-option-clicked";constructor(e){super(e,"canvas"),this._lockCanvasSwitch=document.querySelector(`#${this.containerId} #lock-canvas-switch`),this._createNodeOption=document.querySelector(`#${this.containerId} #create-node-option`),this._toggleGridSwitch=document.querySelector(`#${this.containerId} #toggle-grid-switch`),this._cancelLinkingOption=document.querySelector(`#${this.containerId} #cancel-linking-option`),this._showHelpOption=document.querySelector(`#${this.containerId} #show-help-option`),this._clearCanvasOption=document.querySelector(`#${this.containerId} #clear-canvas-option`),this._nodeFromLink=document.querySelector(`#${this.containerId} #node-from-link-option`),this.setupMenuOption(this._createNodeOption,n.createNodeOptionClickedEvent),this.setupMenuOption(this._lockCanvasSwitch,n.lockCanvasSwitchClickedEvent),this.setupMenuOption(this._toggleGridSwitch,n.toggleGridSwitchClickedEvent),this.setupMenuOption(this._cancelLinkingOption,n.cancelLinkingOptionClickedEvent),this.setupMenuOption(this._showHelpOption,n.showHelpOptionClickedEvent),this.setupMenuOption(this._clearCanvasOption,n.clearCanvasOptionClickedEvent),this.setupMenuOption(this._nodeFromLink,n.nodeFromLinkOptionClickedEvent),P.getInstance().addEventListener(P.startedConnectingSlotsEvent,()=>{this._nodeFromLink.classList.remove("hidden")}),P.getInstance().addEventListener(P.finishedConnectingSlotsEvent,()=>{this._nodeFromLink.classList.add("hidden")})}setCanvasLockedSwitchState(e){Y.setSwitchState(this._lockCanvasSwitch,e)}setGridSwitchState(e){Y.setSwitchState(this._toggleGridSwitch,e)}_lockCanvasSwitch;_createNodeOption;_toggleGridSwitch;_cancelLinkingOption;_showHelpOption;_clearCanvasOption;_nodeFromLink};var Ve=class n{constructor(){n._collapseButton.addEventListener("click",()=>{this._isCollapsed?this.open():this.close()}),this.recalculateInputs(),this.recalculateOutputs()}registerNode(e){this._nodes.push(e),this.recalculateInputs(),this.recalculateOutputs(),e.addEventListener(F.changedVacantResourcesAmountEvent,()=>{this.recalculateInputs(),this.recalculateOutputs()}),e.addEventListener(F.deletionEvent,()=>{let t=this._nodes.findIndex(i=>Object.is(e,i));this._nodes.splice(t,1),this.recalculateInputs(),this.recalculateOutputs()})}recalculateInputs(){let e=new Map,t=0,i=0;for(let a of this._nodes){for(let r of a.missingResources)+r.amount.toFixed(3)>0&&e.set(r.id,(e.get(r.id)??0)+r.amount);+a.powerConsumption.toFixed(3)>0&&(t+=a.powerConsumption),i+=a.requiredPowerShards}this.recalculate(n._inputsColumn,e,t,i)}recalculateOutputs(){let e=new Map;for(let t of this._nodes)for(let i of t.exceedingResources)+i.amount.toFixed(3)>0&&e.set(i.id,(e.get(i.id)??0)+i.amount);this.recalculate(n._outputsColumn,e,0,0)}recalculate(e,t,i,a){e.querySelectorAll(".resource").forEach(o=>{o.remove()});let r=!1;i!==0&&(e.appendChild(this.createPowerDisplay(i)),r=!0),a!==0&&(e.appendChild(this.createResourceDisplay("Desc_CrystalShard_C",a,"")),r=!0);for(let[o,c]of t)e.appendChild(this.createResourceDisplay(o,c,"/min")),r=!0;if(!r){let o=document.createElement("div");o.classList.add("resource","none"),o.innerText="None",e.appendChild(o)}this._isCollapsed&&(n.setCollapsingAnimationEnabled(!1),this.hideContent(),n.setCollapsingAnimationEnabled(!0))}open(){n._summaryContainer.classList.remove("collapsed"),n._summaryContainer.style.top="0",this._isCollapsed=!1}close(){n._summaryContainer.classList.add("collapsed"),this.hideContent(),this._isCollapsed=!0}hideContent(){let e=n.querySuccessor(".content").clientHeight;n._summaryContainer.style.top=`${-e}px`}createResourceDisplay(e,t,i){let a=M(e),r=document.createElement("div");r.classList.add("resource");let o=document.createElement("img");o.classList.add("icon"),o.src=I(a.iconPath),o.title=a.displayName,o.alt=a.displayName;let c=document.createElement("div");return c.classList.add("amount"),c.innerText=`${+t.toFixed(3)}${i}`,r.appendChild(o),r.appendChild(c),r}createPowerDisplay(e){let t=document.createElement("div");t.classList.add("resource");let i=z.createIcon("power");i.classList.add("icon");let a=document.createElement("div");return a.classList.add("amount"),a.innerText=`${+e.toFixed(3)} MW`,t.appendChild(i),t.appendChild(a),t}static querySuccessor(e){let t=n._summaryContainer.querySelector(`${e}`);if(t==null)throw Error(`Couldn't find required element: ${e} of summary container`);return t}static setCollapsingAnimationEnabled(e){e?this._summaryContainer.classList.add("animate-collapsing"):this._summaryContainer.classList.remove("animate-collapsing")}_isCollapsed=!1;_nodes=[];static _summaryContainer=document.querySelector("#resources-summary");static _inputsColumn=n.querySuccessor(".column.inputs");static _outputsColumn=n.querySuccessor(".column.outputs");static _collapseButton=n.querySuccessor(".collapse-button")};var $e=class{static parsePlaceholder(e){let t=[],i,a=0,r=o=>{o!=""&&t.push(document.createTextNode(o))};for(let o=0;o{this._isOpened||(e.stopPropagation(),this.openModal())}),n._closeButton.addEventListener("click",e=>{this._isOpened&&(e.stopPropagation(),this.closeModal())}),window.addEventListener("keydown",e=>{e.code==="Escape"&&this._isOpened&&(e.stopPropagation(),e.preventDefault(),this.closeModal())}),n._modalContainer.querySelector(".modal-window").addEventListener("click",e=>{e.stopPropagation()}),n._modalContainer.addEventListener("click",e=>{e.stopPropagation(),this.closeModal()})}openModal(){n._modalContainer.classList.remove("hidden"),n._modalContent.scrollTop=0,this._isOpened=!0}closeModal(){n._modalContainer.classList.add("hidden"),this._isOpened=!1}replaceHelpPlaceholders(){let e=document.querySelectorAll("tr.help-placeholder");for(let t of e)this.replacePlaceholder(t)}replacePlaceholder(e){let t=e.querySelector("td");t.remove(),e.append(...$e.parsePlaceholder(t.innerText)),e.classList.remove("help-placeholder")}_isOpened=!1;static _modalContainer=document.querySelector("#help-modal-container");static _modalContent=this._modalContainer.querySelector(".content");static _closeButton=this._modalContainer.querySelector(".title-row .close");static _openModalButton=document.querySelector("#open-help")};var Te=class n extends EventTarget{static recipeConfirmedEvent="recipe-confirmed";static recipeSelectedEvent="recipe-selected";static recipesTabSwitchedEvent="recipes-tab-switched";constructor(){super(),this._gameVersionText.innerText=`game version: ${ce.gameVersion}`,this._closeButton.addEventListener("click",this.closeModal.bind(this)),this.setupTabs(),this._confirmRecipeButton.addEventListener("click",this.confirmRecipe.bind(this)),this._recipeTabs.addEventListener("click",this.discardSelectedRecipe.bind(this)),this._discardRecipeButton.addEventListener("click",this.discardSelectedRecipe.bind(this)),this.addEventListener(n.recipeSelectedEvent,()=>{this._selectedRecipe==null?this._selectedRecipeDisplay.classList.add("hidden"):this.updateResourceDisplay()}),this.openFirstTab(),this._modalContainer.querySelector(".modal-window").addEventListener("click",e=>{e.stopPropagation()}),this._modalContainer.addEventListener("click",e=>{e.stopPropagation(),this.closeModal()}),window.addEventListener("keydown",e=>{e.code==="Escape"&&this._isOpened&&(e.preventDefault(),e.stopPropagation(),this.closeModal()),e.key==="Enter"&&this._isOpened&&this.selectedRecipe!=null&&(e.preventDefault(),e.stopPropagation(),this.confirmRecipe())}),this.configureSearchField()}openModal(){this._modalContainer.classList.remove("hidden"),this._isOpened=!0}openWithSearch(e,t){this._rememberedSearch={query:this._searchInputField.value,flags:{...this._searchFlags}},this.openModal(),this.openFirstTab(),this._searchFlags=t,this.updateAllFlagElements(),this._searchInputField.value=e,this.searchRecipes(e)}get selectedRecipe(){return this._selectedRecipe}setupTabs(){let e=this.createHtmlElement("div","tab-selector");e.title="All";let t=z.createIcon("three-dots"),i=this.createHtmlElement("div","recipes-tab"),a=this.createRecipesGroup("Basic recipes"),r=this.createRecipesGroup("Alternate recipes"),o=this.createRecipesGroup("Events recipes");e.appendChild(t),this._tabSelectors.appendChild(e),this._recipeTabs.appendChild(i);let c=(p,u)=>{p.div.childElementCount!==0&&(u.append(p.title),u.appendChild(p.div))};for(let p of ce.machines){let u=this.createHtmlElement("div","tab-selector");u.title=p.displayName;let h=this.createHtmlElement("img","machine-icon");h.src=I(p.iconPath),h.alt=p.displayName,h.loading="lazy";let y=this.createHtmlElement("div","recipes-tab"),v=this.createRecipesGroup("Basic recipes"),C=this.createRecipesGroup("Alternate recipes"),b=this.createRecipesGroup("Events recipes");p.recipes.forEach(_=>{this.appendRecipes(v.div,b.div,_,p),this.appendRecipes(a.div,o.div,_,p)}),p.alternateRecipes.forEach(_=>{this.appendRecipes(C.div,b.div,_,p),this.appendRecipes(r.div,o.div,_,p)}),c(v,y),c(C,y),c(b,y),u.addEventListener("click",()=>{this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),y.classList.add("active"),u.classList.add("active")}),this.addEventListener(n.recipesTabSwitchedEvent,()=>{y.classList.remove("active"),u.classList.remove("active"),this.discardSelectedRecipe()}),u.appendChild(h),this._tabSelectors.appendChild(u),this._recipeTabs.appendChild(y)}c(a,i),c(r,i),c(o,i),e.addEventListener("click",()=>{this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),i.classList.add("active"),e.classList.add("active")}),this.addEventListener(n.recipesTabSwitchedEvent,()=>{i.classList.remove("active"),e.classList.remove("active"),this.discardSelectedRecipe()})}openFirstTab(){this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),this._tabSelectors.children[0].classList.add("active"),this._recipeTabs.children[0].classList.add("active")}createRecipesGroup(e){let t=this.createHtmlElement("h3","group-title");return t.innerText=e,{div:this.createHtmlElement("div","group"),title:t}}appendRecipes(e,t,i,a){let r=document.createElement("div");r.classList.add("recipe"),r.title=i.displayName,r.dataset.recipeId=i.id;let o=!1;for(let c of i.products){let p=this.createHtmlElement("div","progress-bar"),u=document.createElement("img");u.classList.add("item-icon");let h=M(c.id);u.src=I(h.iconPath),o||(o=h.iconPath.startsWith("Events")),u.alt=i.displayName,u.loading="lazy",r.appendChild(p),r.appendChild(u)}r.addEventListener("click",c=>{c.stopPropagation(),this._selectedRecipe?.recipe===i?this.discardSelectedRecipeDelayed(r):this.selectRecipeDelayed(i,a,r)}),r.addEventListener("dblclick",c=>{c.stopPropagation(),this.selectRecipe(i,a,r),this.confirmRecipe()}),this.addEventListener(n.recipeSelectedEvent,()=>{r.classList.remove("selected")}),o?t.appendChild(r):e.appendChild(r)}createResourceDisplay(e,t,i){let a=M(i.id),r=this.createHtmlElement("div","resource"),o=this.createHtmlElement("img","icon");o.src=I(a.iconPath),o.title=a.displayName,o.alt=a.displayName,o.loading="lazy";let c=this.createHtmlElement("p","amount");c.innerText=`${+ie(i.amount,t).toFixed(3)}`,r.appendChild(o),r.appendChild(c),e.appendChild(r)}updateResourceDisplay(){if(this._selectedRecipe==null)throw Error("Recipe isn't selected.");this._selectedRecipeName.innerText=this._selectedRecipe.recipe.displayName,this._selectedRecipeMachine.src=I(this._selectedRecipe.madeIn.iconPath),this._selectedRecipeMachine.title=this._selectedRecipe.madeIn.displayName,this.updateResources(this._selectedRecipeInput,this._selectedRecipe.recipe.ingredients),this.updateResources(this._selectedRecipeOutput,this._selectedRecipe.recipe.products),this._selectedRecipePower.innerText=`${this._selectedRecipe.madeIn.powerConsumption} MW`,this._selectedRecipeDisplay.classList.remove("hidden"),this._selectedRecipeDisplay.scrollTop=this._selectedRecipeDisplay.scrollHeight}updateResources(e,t){e.querySelectorAll(".resource").forEach(i=>i.remove()),t.forEach(i=>this.createResourceDisplay(e,this._selectedRecipe.recipe.manufacturingDuration,i))}selectRecipe(e,t,i){this.stopProgressBar!=null&&this.stopProgressBar(),i.classList.remove("animate-progress"),this._selectedRecipe={recipe:e,madeIn:t},this.dispatchEvent(new Event(n.recipeSelectedEvent)),i.classList.add("selected")}selectRecipeDelayed(e,t,i){this.stopProgressBar!=null&&this.stopProgressBar(),i.classList.add("animate-progress");let a=setTimeout(()=>{this._selectedRecipe={recipe:e,madeIn:t},this.dispatchEvent(new Event(n.recipeSelectedEvent)),i.classList.add("selected"),i.classList.remove("animate-progress"),this.stopProgressBar=void 0},200);this.stopProgressBar=()=>{clearTimeout(a),i.classList.remove("animate-progress"),this.stopProgressBar=void 0}}discardSelectedRecipe(){this.stopProgressBar!=null&&this.stopProgressBar(),this._selectedRecipe=void 0,this.dispatchEvent(new Event(n.recipeSelectedEvent))}discardSelectedRecipeDelayed(e){this.stopProgressBar!=null&&this.stopProgressBar(),e.classList.add("animate-progress");let t=setTimeout(()=>{this._selectedRecipe=void 0,this.dispatchEvent(new Event(n.recipeSelectedEvent)),e.classList.remove("animate-progress"),this.stopProgressBar=void 0},200);this.stopProgressBar=()=>{clearTimeout(t),e.classList.remove("animate-progress"),this.stopProgressBar=void 0}}updateFlagElement(e,t){this._searchFlags[e]?t.classList.add("checked"):t.classList.remove("checked"),this.searchRecipes(this._searchInputField.value)}updateAllFlagElements(){this.updateFlagElement("recipeNames",this._searchRecipeNamesFlag),this.updateFlagElement("ingredients",this._searchIngredientsFlag),this.updateFlagElement("products",this._searchProductsFlag),this.updateFlagElement("exactMatch",this._exactMatchProductsFlag)}configureSearchField(){this._searchInputField.value="",this.updateAllFlagElements(),this._searchRecipeNamesFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.recipeNames=!this._searchFlags.recipeNames,this.updateFlagElement("recipeNames",this._searchRecipeNamesFlag)}),this._searchIngredientsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.ingredients=!this._searchFlags.ingredients,this.updateFlagElement("ingredients",this._searchIngredientsFlag)}),this._searchProductsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.products=!this._searchFlags.products,this.updateFlagElement("products",this._searchProductsFlag)}),this._exactMatchProductsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.exactMatch=!this._searchFlags.exactMatch,this.updateFlagElement("exactMatch",this._exactMatchProductsFlag)}),this._searchInputField.addEventListener("input",()=>{this.searchRecipes(this._searchInputField.value)}),this._searchInputField.addEventListener("keydown",e=>{e.stopPropagation()}),this._clearSearchButton.addEventListener("click",()=>{this._searchInputField.value="",this.searchRecipes(this._searchInputField.value)})}searchRecipes(e){let t=this._recipeTabs.querySelectorAll(".recipe");for(let i of t){if(e===""){i.classList.remove("filtered-out");continue}let a=Ge(i.dataset.recipeId),r=o=>{this._searchFlags.exactMatch&&o.toLowerCase()===e.toLowerCase()&&i.classList.remove("filtered-out"),!this._searchFlags.exactMatch&&o.toLowerCase().includes(e.toLowerCase())&&i.classList.remove("filtered-out")};if(i.classList.add("filtered-out"),this._searchFlags.recipeNames&&r(a.recipe.displayName),this._searchFlags.ingredients)for(let o of a.recipe.ingredients){let c=M(o.id);r(c.displayName)}if(this._searchFlags.products)for(let o of a.recipe.products){let c=M(o.id);r(c.displayName)}}}confirmRecipe(){this._selectedRecipe!=null&&(this.closeModal(),this.dispatchEvent(new Event(n.recipeConfirmedEvent)))}closeModal(){this._modalContainer.classList.add("hidden"),this._isOpened=!1,this._rememberedSearch!=null&&(this._searchFlags={...this._rememberedSearch.flags},this.updateAllFlagElements(),this._searchInputField.value=this._rememberedSearch.query,this.searchRecipes(this._rememberedSearch.query),this._rememberedSearch=void 0)}createHtmlElement(e,...t){let i=document.createElement(e);return i.classList.add(...t),i}_isOpened=!1;_selectedRecipe;_modalContainer=document.querySelector("#node-creation-container");_closeButton=this._modalContainer.querySelector(".title-row .close");_gameVersionText=this._modalContainer.querySelector("h2.title span.game-version");_tabSelectors=this._modalContainer.querySelector("#tab-selectors");_recipeTabs=this._modalContainer.querySelector("#recipe-tabs");_selectedRecipeDisplay=this._modalContainer.querySelector("#selected-recipe");_selectedRecipeName=this._selectedRecipeDisplay.querySelector("#selected-recipe-name>.text");_selectedRecipeMachine=this._selectedRecipeDisplay.querySelector("#selected-recipe-machine>.machine>img.icon");_selectedRecipeInput=this._selectedRecipeDisplay.querySelector("#selected-recipe-input");_selectedRecipeOutput=this._selectedRecipeDisplay.querySelector("#selected-recipe-output");_selectedRecipePower=this._selectedRecipeDisplay.querySelector("#selected-recipe-power>.text");_confirmRecipeButton=this._modalContainer.querySelector("#confirm-recipe");_discardRecipeButton=this._modalContainer.querySelector("#discard-recipe");stopProgressBar;_searchInputField=this._modalContainer.querySelector(".search-field input");_clearSearchButton=this._modalContainer.querySelector(".search-field .clear-button");_searchRecipeNamesFlag=this._modalContainer.querySelector(".search-container #recipe-names-flag");_searchIngredientsFlag=this._modalContainer.querySelector(".search-container #ingredients-flag");_searchProductsFlag=this._modalContainer.querySelector(".search-container #products-flag");_exactMatchProductsFlag=this._modalContainer.querySelector(".search-container #exact-match-flag");_searchFlags={recipeNames:!0,ingredients:!0,products:!0,exactMatch:!1};_rememberedSearch};async function In(){z.replaceAllPlaceholders();let n=document.querySelector("p#ratio-display"),e=document.querySelector("#canvas"),t=new je;E.setPanningButtons(["Space"],["Meta"]),E.setZoomingButtons([],["Control"]),E.configurePanContext(e);let i=new le;n.textContent=`Zoom: ${g.instance.zoom.toFixed(2)}x`,g.instance.addEventListener(g.zoomChangedEvent,()=>{n.textContent=`Zoom: ${g.instance.zoom.toFixed(2)}x`,i.updateGridSize(),i.updateGridPosition()}),E.context.on("pan",()=>{i.updateGridPosition()});let a=new Ve,r=new Te,o,c=_=>{_.nodeSvg.onmousedown=D=>{D.buttons===1&&!E.isPanning&&!E.isZooming&&P.getInstance().startDraggingNode(_,{x:D.clientX,y:D.clientY})},_.nodeSvg.addEventListener("touchstart",D=>{if(D.touches.length===1&&g.instance.isCanvasLocked){let f=D.touches[0];P.getInstance().startDraggingNode(_,{x:f.clientX,y:f.clientY})}}),a.registerNode(_)},p;function u(_,D){let f=new F(o,_,D);return c(f),R.addNode(f),p!=null&&(p(f),p=void 0),f}r.addEventListener(Te.recipeConfirmedEvent,()=>{let _=r.selectedRecipe;u(_.recipe,_.madeIn)});function h(_){let D={x:document.documentElement.clientWidth/2,y:document.documentElement.clientHeight/2};o=_??P.clientToCanvasPosition(D),r.openModal()}document.querySelector("div.button#create-node").onclick=()=>{h()},document.querySelector("div.button#cancel-linking").onclick=()=>{P.getInstance().cancelConnectingSlots()};let y=()=>{confirm(`Are you sure that you want to clear canvas? +`,iconPath:"Resource/Parts/NobeliskExplosive/Nuke.png"},{id:"Desc_NobeliskShockwave_C",displayName:"Pulse Nobelisk",description:"Instead of a regular explosion, this Nobelisk generates a powerful shockwave.",iconPath:"Resource/Parts/NobeliskExplosive/Shock.png"},{id:"Desc_Fireworks_Projectile_01_C",displayName:"Sweet Fireworks",description:"Merry FICSMAS and a Happy New Year!",iconPath:"Events/Christmas/Fireworks/Rocket01.png"},{id:"Desc_Fireworks_Projectile_02_C",displayName:"Fancy Fireworks",description:"Fireworks are produced from random ingredients. Primarily used for having a good time.",iconPath:"Events/Christmas/Fireworks/Rocket02.png"},{id:"Desc_Fireworks_Projectile_03_C",displayName:"Sparkly Fireworks",description:"Goes Pfffeeeeew... BOOM! *Sparkle*",iconPath:"Events/Christmas/Fireworks/Rocket03.png"},{id:"Desc_SnowballProjectile_C",displayName:"Snowball",description:"Compressed dihydrogen monoxide crystals.",iconPath:"Events/Christmas/Parts/SnowballProjectile.png"},{id:"Desc_Rebar_Spreadshot_C",displayName:"Shatter Rebar",description:"This rebar fractures when shot, launching deadly debris in a wide spread but with limited range.",iconPath:"Equipment/RebarGun/ScatterRebar.png"},{id:"Desc_CartridgeChaos_C",displayName:"Turbo Rifle Ammo",description:"Lightweight, compact, and volatile. These rounds provide extreme capacity and fire rates, at the cost of accuracy.",iconPath:"Equipment/Rifle/TurboRifle.png"},{id:"Desc_CartridgeStandard_C",displayName:"Rifle Ammo",description:"Standard issue Rifle ammunition, useful for establishing dominance.",iconPath:"Equipment/Rifle/Rifle.png"}]};function F(n){return`GameData/SatisfactoryIcons/${n}`}function ie(n,e){return 60/e*n}function he(n,e,t){return n*Math.pow(e,t)}function xt(n){return n<=1?0:Math.ceil((n-1)/.5)}function x(n){let e=ce.resources.find(t=>t.id===n);if(e==null)throw Error(`Couldn't find resource "${n}"`);return e}function Ge(n){for(let e of ce.machines){let t=e.recipes.find(a=>a.id===n);if(t!=null)return{recipe:t,machine:e};let i=e.alternateRecipes.find(a=>a.id===n);if(i!=null)return{recipe:i,machine:e}}throw Error(`Couldn't find recipe "${n}"`)}function It(n){let e,t,i=0;for(let a of ce.machines){let o=(r,c)=>{let p=c.find(u=>u.id===n.id);if(p!=null){if(e!=null||t!=null)return!1;e=r,t=a,i=p.amount}return!0};for(let r of a.recipes)if(n.type==="input"&&!o(r,r.ingredients)||n.type==="output"&&!o(r,r.products))return;for(let r of a.alternateRecipes)if(n.type==="input"&&!o(r,r.ingredients)||n.type==="output"&&!o(r,r.products))return}if(!(e==null||t==null))return{recipe:e,machine:t,resourceAmount:i}}var Y=class n extends EventTarget{static menuOpenedEvent="menu-opened";static menuClosedEvent="menu-closed";constructor(e,t){super(),this._menuContainer=document.querySelector(`#${t}-context-menu-container`),this._menuContainer.addEventListener("mousedown",()=>{this.closeMenu()}),window.addEventListener("keydown",i=>{i.code==="Escape"&&this._isMenuOpened&&(i.preventDefault(),i.stopPropagation(),this.closeMenu())}),this.addMenuTo(e)}openMenu(){this._isMenuOpened=!0,this._menuContainer.classList.remove("hidden"),this.dispatchEvent(new Event(n.menuOpenedEvent))}closeMenu(){this._isMenuOpened=!1,this._menuContainer.classList.add("hidden"),this.dispatchEvent(new Event(n.menuClosedEvent))}addMenuTo(e){let t=document.querySelector(`#${this.containerId}>.context-menu`);e.addEventListener("contextmenu",i=>{let a=i;i.preventDefault(),this._openingPosition={x:a.clientX,y:a.clientY},t.style.top=`${a.pageY+5}px`,t.style.left=`${a.pageX+5}px`,this.openMenu(),i.stopPropagation()}),this.addEventListener(n.menuOpenedEvent,function(){e.classList.add("selected")}),this.addEventListener(n.menuClosedEvent,function(){e.classList.remove("selected")})}get isMenuOpened(){return this._isMenuOpened}get openingPosition(){return this._openingPosition}get containerId(){return this._menuContainer.id}setupMenuOption(e,t){e.addEventListener("mousedown",i=>{i.stopPropagation()}),e.addEventListener("click",()=>{this._isMenuOpened&&(this.dispatchEvent(new Event(t)),this.closeMenu())})}static setSwitchState(e,t){t?e.classList.add("enabled"):e.classList.remove("enabled")}_menuContainer;_isMenuOpened=!1;_openingPosition};var Ee=class n extends Y{static deleteLinkOptionClickedEvent="delete-node-option-clicked";constructor(e){super(e,"link"),this._deleteLinkOption=document.querySelector(`#${this.containerId} #delete-link-option`),this.setupMenuOption(this._deleteLinkOption,n.deleteLinkOptionClickedEvent)}_deleteLinkOption};var fi=tn(vi());var h=class n extends EventTarget{static isCanvasLockedChangedEvent="canvas-locked-changed";static isGridEnabledChangedEvent="grid-enabled-changed";static zoomChangedEvent="canvas-locked-changed";static connectingResourceIdChangedEvent="connecting-resource-id-changed";static get instance(){return this._instance}get isCanvasLocked(){return this._isCanvasLocked}set isCanvasLocked(e){e?E.context.pause():E.context.resume(),this._isCanvasLocked=e,this.dispatchEvent(new Event(n.isCanvasLockedChangedEvent))}get isGridEnabled(){return this._isGridEnabled}set isGridEnabled(e){this._isGridEnabled=e,this.dispatchEvent(new Event(n.isGridEnabledChangedEvent))}get zoom(){return this._zoom}set zoom(e){this._zoom=e,this.dispatchEvent(new Event(n.zoomChangedEvent))}get connectingResource(){return this._connectingResource}set connectingResource(e){this._connectingResource=e,this.dispatchEvent(new Event(n.connectingResourceIdChangedEvent))}constructor(){super()}static _instance=new n;_isCanvasLocked=!1;_isGridEnabled=!1;_zoom=1;_connectingResource};var E=class{static configurePanContext(e){this._panContext=(0,fi.default)(document.querySelector("#viewport"),{zoomDoubleClickSpeed:1,minZoom:.05,maxZoom:25,beforeMouseDown:()=>!this._isPanning,beforeWheel:t=>(t.preventDefault(),!this._isZooming&&!t.ctrlKey)}),e.addEventListener("wheel",t=>{let i={x:t.deltaX,y:t.deltaY};i.x===0&&t.shiftKey&&(i.x=i.y,i.y=0),!this._isZooming&&!t.ctrlKey&&this.context.moveTo(this.context.getTransform().x-i.x,this.context.getTransform().y-i.y)},{passive:!0}),this._panContext.on("zoom",()=>{h.instance.zoom=this._panContext.getTransform().scale??1}),window.addEventListener("focusout",()=>{this.stopPanning(),this.stopZooming()}),window.addEventListener("blur",()=>{this.stopPanning(),this.stopZooming()})}static setPanningButtons(e,t){window.addEventListener("keydown",i=>{if(i.repeat||document.activeElement?.tagName==="input")return;let o=e.includes(i.code),r=t.includes(i.key);(o||r)&&(i.preventDefault(),this.startPanning())}),window.addEventListener("keyup",i=>{if(i.repeat)return;let a=e.includes(i.code),o=t.includes(i.key);(a||o)&&(i.preventDefault(),this.stopPanning())})}static setZoomingButtons(e,t){window.addEventListener("keydown",i=>{if(i.repeat)return;let a=e.includes(i.code),o=t.includes(i.key);(a||o)&&(i.preventDefault(),this.startZooming())}),window.addEventListener("keyup",i=>{if(i.repeat)return;let a=e.includes(i.code),o=t.includes(i.key);(a||o)&&(i.preventDefault(),this.stopZooming())})}static get context(){if(this._panContext==null)throw Error("Pan context is not defined");return this._panContext}static get isPanning(){return this._isPanning}static get isZooming(){return this._isZooming}static startPanning(){this._isPanning=!0,this._container.classList.add("move")}static stopPanning(){this._isPanning=!1,this._container.classList.remove("move")}static startZooming(){this._isZooming=!0}static stopZooming(){this._isZooming=!1}constructor(){}static _panContext;static _isPanning=!1;static _isZooming=!1;static _container=document.querySelector("#container")};var Q=class n{static connect(e,t){let i=new n(e,t,E.context),a=document.querySelector("#viewport>g.links");a.appendChild(i._svgPath),a.appendChild(i._resourceDisplay),y.instance.save()}constructor(e,t,i){this._firstSlot=e,this._secondSlot=t,this._panContext=i,e.connectedTo=t,t.connectedTo=e;let a=(c,p)=>{if(p.resourcesAmount>=c.resourcesAmount)p.resourcesAmount=c.resourcesAmount,this._resourceAmountDisplay.innerText=`${+p.resourcesAmount.toFixed(4)}/min`;else throw Error("Increasing link's resources amount not yet implemented.")};e.addEventListener(T.boundsChangedEvent,this.recalculate.bind(this)),t.addEventListener(T.boundsChangedEvent,this.recalculate.bind(this)),e.addEventListener(T.deletionEvent,this.delete.bind(this,t)),t.addEventListener(T.deletionEvent,this.delete.bind(this,e)),e.addEventListener(T.resourcesAmountChangedEvent,()=>a(e,t)),t.addEventListener(T.resourcesAmountChangedEvent,()=>a(t,e)),this._svgPath=M.createSvgPath("link","animate-appearance"),this._resourceDisplay=this.createResourceDisplay({id:e.resourceId,amount:e.resourcesAmount}),this.recalculate();let o=new Ee(this._svgPath);o.addMenuTo(e.slotSvgRect),o.addMenuTo(t.slotSvgRect),o.addEventListener(Ee.deleteLinkOptionClickedEvent,()=>{e.delete()});let r=c=>{o.isMenuOpened||(c?(this._svgPath.classList.add("selected"),e.slotSvgRect.classList.add("selected"),t.slotSvgRect.classList.add("selected")):(this._svgPath.classList.remove("selected"),e.slotSvgRect.classList.remove("selected"),t.slotSvgRect.classList.remove("selected")))};e.slotSvgRect.addEventListener("mouseenter",()=>r(!0)),t.slotSvgRect.addEventListener("mouseenter",()=>r(!0)),this._svgPath.addEventListener("mouseenter",()=>r(!0)),e.slotSvgRect.addEventListener("mouseleave",()=>r(!1)),t.slotSvgRect.addEventListener("mouseleave",()=>r(!1)),this._svgPath.addEventListener("mouseleave",()=>r(!1))}recalculate(){let e=Re.fromSvgBounds(this._firstSlot.slotSvgRect,this._panContext),t=Re.fromSvgBounds(this._secondSlot.slotSvgRect,this._panContext),i=te.fromTwoPoints({x:e.x+e.width,y:e.y},{x:t.x,y:t.y}),a=te.fromTwoPoints({x:t.x,y:t.y+t.height},{x:e.x+e.width,y:e.y+e.height}),o=new se().startAt(i.startPoint).curve(i).verticalLineTo(i.endPoint.y+t.height).curve(a).verticalLineTo(i.startPoint.y).build();this._svgPath.setAttribute("d",o),this._svgPath.style.clipPath=`view-box path("${o}")`;let r=e.height/2+t.height/2,c=Math.abs(i.startPoint.x-i.endPoint.x),p=50,u=90,_=Math.max(p,Math.min(u,Math.min(r,c)-16)),D={x:i.startDeviationPoint.x,y:(i.startPoint.y+i.endPoint.y)/2+r/2},f=_+100;this._resourceDisplay.setAttribute("x",`${D.x-f/2}`),this._resourceDisplay.setAttribute("y",`${D.y-_/2}`),this._resourceDisplay.setAttribute("width",`${f}`),this._resourceDisplay.setAttribute("height",`${_}`);let C=this._resourceDisplay.querySelector("div.resource-amount");C.style.fontSize=`${_/u*18}px`}createResourceDisplay(e){let t=M.createSvgForeignObject("resource-display"),i=document.createElement("div");i.classList.add("container");let a=document.createElement("img");a.classList.add("icon");let o=x(e.id);return a.src=F(o.iconPath),a.alt=o.displayName,this._resourceAmountDisplay=document.createElement("div"),this._resourceAmountDisplay.classList.add("resource-amount"),this._resourceAmountDisplay.innerText=`${+e.amount.toFixed(3)}/min`,i.appendChild(a),i.appendChild(this._resourceAmountDisplay),t.appendChild(i),t}delete(e){this._isDeleted||(this._isDeleted=!0,e.delete(),this._svgPath.remove(),this._resourceDisplay.remove())}_firstSlot;_secondSlot;_panContext;_svgPath;_resourceDisplay;_resourceAmountDisplay;_isDeleted=!1};var P=class n extends EventTarget{static startedConnectingSlotsEvent="started-connecting-slots";static finishedConnectingSlotsEvent="finished-connecting-slots";static getInstance(){return this._instance!=null?this._instance:(this._instance=new this,this._instance)}handleMouseMove(e){if(this._mouseStatus===n.MouseStatus.DraggingNode)this.dragNodeTo({x:e.clientX,y:e.clientY});else if(this._mouseStatus===n.MouseStatus.ConnectingInputSlot||this._mouseStatus===n.MouseStatus.ConnectingOutputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._slotConnectingLine==null||this._slotConnectingCurve==null)throw Error("Slot connecting line wasn't created.");let t=n.clientToCanvasPosition({x:e.clientX,y:e.clientY});this._slotConnectingCurve=te.fromTwoPoints(this._slotConnectingCurve.startPoint,t);let i=new se().startAt(this._slotConnectingCurve.startPoint).curve(this._slotConnectingCurve).build();this._slotConnectingLine.setAttribute("d",i)}}handleTouchMove(e){if(this._mouseStatus===n.MouseStatus.DraggingNode&&e.touches.length===1){let t=e.touches[0];this.dragNodeTo({x:t.clientX,y:t.clientY})}}handleMouseUp(){this._mouseStatus===n.MouseStatus.DraggingNode&&(this._mouseStatus=n.MouseStatus.Free,this._draggedNode=void 0,this._lastMousePos.x=0,this._lastMousePos.y=0,y.instance.save())}cancelConnectingSlots(){(this._mouseStatus==n.MouseStatus.ConnectingInputSlot||this._mouseStatus==n.MouseStatus.ConnectingOutputSlot)&&(this._firstConnectingSlot=void 0,this._slotConnectingLine?.remove(),this._slotConnectingLine=void 0,this._slotConnectingCurve=void 0,this._mouseStatus=n.MouseStatus.Free,h.instance.connectingResource=void 0,document.querySelector(".controls #cancel-linking").classList.add("hidden"),document.querySelector("#canvas-context-menu-container #cancel-linking-option").classList.add("hidden"),this.dispatchEvent(new Event(n.finishedConnectingSlotsEvent)))}inputSlotClicked(e,t){if(this._mouseStatus===n.MouseStatus.Free)this._mouseStatus=n.MouseStatus.ConnectingInputSlot,this.startConnectingSlot(e,t,!0),h.instance.connectingResource={type:"input",id:t.resourceId};else if(this._mouseStatus===n.MouseStatus.ConnectingOutputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._firstConnectingSlot.resourceId!=t.resourceId)return;let i=Math.min(t.resourcesAmount,this._firstConnectingSlot.resourcesAmount),a=this._firstConnectingSlot.splitOffSlot(i),o=t.splitOffSlot(i);Q.connect(a,o),this.cancelConnectingSlots()}}outputSlotClicked(e,t){if(this._mouseStatus===n.MouseStatus.Free)this._mouseStatus=n.MouseStatus.ConnectingOutputSlot,this.startConnectingSlot(e,t,!1),h.instance.connectingResource={type:"output",id:t.resourceId};else if(this._mouseStatus===n.MouseStatus.ConnectingInputSlot){if(this._firstConnectingSlot==null)throw Error("First connecting slot wasn't saved.");if(this._firstConnectingSlot.resourceId!=t.resourceId)return;let i=Math.min(t.resourcesAmount,this._firstConnectingSlot.resourcesAmount),a=this._firstConnectingSlot.splitOffSlot(i),o=t.splitOffSlot(i);Q.connect(a,o),this.cancelConnectingSlots()}}dragNodeTo(e){if(this._draggedNode==null)throw Error("Dragged node wasn't saved.");let t=this._draggedNode.position,i=E.context.getTransform().scale,a={x:e.x-this._lastMousePos.x,y:e.y-this._lastMousePos.y};this._draggedNode.position={x:t.x+a.x/i,y:t.y+a.y/i},this._lastMousePos.x=e.x,this._lastMousePos.y=e.y}startConnectingSlot(e,t,i){this._firstConnectingSlot=t;let a=E.context.getTransform().scale,o=t.slotSvgRect.getBoundingClientRect();o={x:(o.x-E.context.getTransform().x)/a,y:(o.y-E.context.getTransform().y)/a,width:o.width/a,height:o.height/a};let r={x:o.x+(i?0:o.width),y:o.y+o.height/2},c=n.clientToCanvasPosition({x:e.clientX,y:e.clientY});this._slotConnectingCurve=te.fromTwoPoints(r,c);let p=new se().startAt(this._slotConnectingCurve.startPoint).curve(this._slotConnectingCurve).build();this._slotConnectingLine=M.createSvgPath("link-hint"),this._slotConnectingLine.classList.add(i?"from-input":"from-output"),this._slotConnectingLine.setAttribute("d",p),this._viewport.appendChild(this._slotConnectingLine),document.querySelector(".controls #cancel-linking").classList.remove("hidden"),document.querySelector("#canvas-context-menu-container #cancel-linking-option").classList.remove("hidden"),this.dispatchEvent(new Event(n.startedConnectingSlotsEvent))}startDraggingNode(e,t){this._mouseStatus===n.MouseStatus.Free&&(this._mouseStatus=n.MouseStatus.DraggingNode,this._draggedNode=e,this._lastMousePos.x=t.x,this._lastMousePos.y=t.y)}get firstConnectingSlot(){return this._firstConnectingSlot}get mouseStatus(){return this._mouseStatus}static clientToCanvasPosition(e){let t=document.querySelector("#viewport");return new DOMPointReadOnly(e.x,e.y).matrixTransform(t.getScreenCTM().inverse())}constructor(){super()}static _instance;_firstConnectingSlot;_draggedNode;_slotConnectingLine;_slotConnectingCurve;_mouseStatus=n.MouseStatus.Free;_lastMousePos=new X(0,0);_viewport=document.querySelector("#viewport")};(e=>{let n;(r=>(r[r.Free=0]="Free",r[r.DraggingNode=1]="DraggingNode",r[r.ConnectingInputSlot=2]="ConnectingInputSlot",r[r.ConnectingOutputSlot=3]="ConnectingOutputSlot"))(n=e.MouseStatus||={})})(P||={});var ve=class n{constructor(e,t,i){this._relatedSlot=e,this._slotsGroup=t,this._type=i,this._resourcesDisplay=M.createSvgForeignObject("resources-display"),this._resourcesAmountDisplay=document.createElement("div"),this.createResourceDisplay(),this._relatedSlot.addEventListener(T.boundsChangedEvent,this.update.bind(this))}createResourceDisplay(){let e=document.createElement("div"),t=x(this._relatedSlot.resourceId),i=document.createElement("img");i.classList.add("icon"),i.src=F(t.iconPath),i.title=t.displayName,i.alt=t.displayName,this._resourcesAmountDisplay.classList.add("amount"),e.appendChild(i),e.appendChild(this._resourcesAmountDisplay),this._resourcesDisplay.appendChild(e),this._slotsGroup.appendChild(this._resourcesDisplay);let a=()=>{let o=Math.max(n._minZoomMultiplier,Math.min(n._maxZoomMultiplier,h.instance.zoom));e.style.padding=`0 ${10/o}px`,e.style.gap=`${4/o}px`,this.update()};a(),h.instance.addEventListener(h.zoomChangedEvent,a),h.instance.addEventListener(h.connectingResourceIdChangedEvent,()=>{let o=h.instance.connectingResource;this._resourcesDisplay.classList.remove("correct"),this._resourcesDisplay.classList.remove("wrong"),o!=null&&(o.id===this._relatedSlot.resourceId&&o.type!==this._type?(this._resourcesDisplay.classList.add("correct"),this._resourcesDisplay.classList.remove("wrong")):(this._resourcesDisplay.classList.add("wrong"),this._resourcesDisplay.classList.remove("correct")))})}update(){let e=+this._relatedSlot.resourcesAmount.toFixed(3);if(e===0)this._resourcesDisplay.classList.add("hidden");else{this._resourcesDisplay.classList.remove("hidden");let i=24/Math.max(n._minZoomMultiplier,Math.min(n._maxZoomMultiplier,h.instance.zoom));this._resourcesAmountDisplay.style.fontSize=`${i*.6}px`,this._resourcesAmountDisplay.innerText=`${e}`;let a=+this._relatedSlot.slotSvgRect.getAttribute("height"),o=+this._relatedSlot.slotSvgRect.getAttribute("y"),r=this._type==="input"?0:T.slotWidth;this._resourcesDisplay.setAttribute("height",`${i}`),this._resourcesDisplay.setAttribute("width","1"),this._resourcesDisplay.setAttribute("x",`${r}`),this._resourcesDisplay.setAttribute("y",`${o+a/2-i/2}`)}}_relatedSlot;_type;_slotsGroup;_resourcesDisplay;_resourcesAmountDisplay;static _minZoomMultiplier=.5;static _maxZoomMultiplier=1.5};var ze=class extends _e{constructor(e,t,i){super(e,t,i,"exceeding"),this._resourcesDisplay=new ve(this,t,"output"),this.slotSvgRect.addEventListener("click",a=>{!E.isPanning&&!E.isZooming&&P.getInstance().outputSlotClicked(a,this)}),this.slotSvgRect.addEventListener("dblclick",a=>{a.stopPropagation()})}splitOffSlot(e){return this.parentGroup.addSlot(e)}_resourcesDisplay};var fe=class extends T{constructor(e,t,i,...a){super(e,t,i,"input-slot",...a)}};var We=class extends fe{constructor(e,t,i){super(e,t,i,"missing"),this._resourcesDisplay=new ve(this,t,"input"),this.slotSvgRect.addEventListener("click",a=>{!E.isPanning&&!E.isZooming&&P.getInstance().inputSlotClicked(a,this)}),this.slotSvgRect.addEventListener("dblclick",a=>{a.stopPropagation()})}splitOffSlot(e){return this.parentGroup.addSlot(e)}_resourcesDisplay};var ue=class n extends EventTarget{static boundsChangedEvent="bounds-changed";static changedVacantResourcesAmountEvent="changed-vacant-resources-amount";constructor(e,t,i,a){super(),this._type=t,this._resource={...i},this._parentNode=e;let o=t==="input"?new X(0,a):new X(q.nodeWidth+T.slotWidth,a);this._groupSvg=M.createSvgGroup(o,`${t}-slots`,"slots-group"),this._lastSlot=this.initializeLastSlot(i),e.nodeSvgGroup.appendChild(this._groupSvg),this.addEventListener(n.boundsChangedEvent,()=>{for(let r of this._slots)r.dispatchEvent(new Event(T.boundsChangedEvent))})}addSlot(e){e=Math.min(e,this._lastSlot.resourcesAmount),this._lastSlot.resourcesAmount-=e;let t;if(this._type==="input")t=new fe(this,this._groupSvg,{id:this.resourceId,amount:e});else if(this._type==="output")t=new _e(this,this._groupSvg,{id:this.resourceId,amount:e});else throw Error("Unexpected slots group type");return this._slots.push(t),t.addEventListener(T.deletionEvent,()=>{let i=this._slots.findIndex(a=>Object.is(a,t));this._slots.splice(i,1),this.updateSlotPositions()}),t.addEventListener(T.resourcesAmountChangedEvent,()=>{this.updateSlotPositions()}),this.updateSlotPositions(),t}delete(){for(y.instance.lockSaving();this._slots.length!==0;)this._slots[0].delete();this._groupSvg.remove(),y.instance.unlockSaving(),y.instance.save()}toSerializable(){let e=[];for(let t of this._slots)e.push(t.toSerializable());return{resourceId:this.resourceId,connectedOutputs:e}}get height(){let e;return this._type=="input"?e=this._parentNode.inputResourcesAmount:e=this._parentNode.outputResourcesAmount,this._parentNode.height*(this.resourcesAmount/e)}get resourcesAmount(){return this._resource.amount}get vacantResourcesAmount(){return this._lastSlot.resourcesAmount}set resourcesAmount(e){let t=this._resource.amount-e;if(t>0){{let i=Math.min(t,this._lastSlot.resourcesAmount);t-=i,this._lastSlot.resourcesAmount-=i}for(let i=this._slots.length-1;i>=0&&t>0;--i){let a=this._slots[i],o=Math.min(t,a.resourcesAmount);t-=o,a.resourcesAmount-=o,a.resourcesAmount===0&&a.delete()}}this._resource.amount=e,this.updateSlotPositions(),this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent))}get resourceId(){return this._resource.id}get parentNode(){return this._parentNode}updateSlotPositions(){let e=this.resourcesAmount,t=0;for(let i of this._slots)i.setYPosition(t),i.updateHeight(),e-=i.resourcesAmount,t+=+(i.slotSvgRect.getAttribute("height")??0);this._lastSlot.setYPosition(t),this._lastSlot.resourcesAmount=e,this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent))}initializeLastSlot(e){if(this._type==="input")return new We(this,this._groupSvg,{...e});if(this._type==="output")return new ze(this,this._groupSvg,{...e});throw Error("Unexpected slots group type")}_type;_resource;_slots=[];_lastSlot;_groupSvg;_parentNode};var ye=class n extends Y{static deleteNodeOptionClickedEvent="delete-node-option-clicked";static configureNodeOptionClickedEvent="configure-node-option-clicked";constructor(e){super(e,"node"),this._deleteNodeOption=document.querySelector(`#${this.containerId} #delete-node-option`),this.setupMenuOption(this._deleteNodeOption,n.deleteNodeOptionClickedEvent),this._configureNodeOption=document.querySelector(`#${this.containerId} #configure-node-option`),this.setupMenuOption(this._configureNodeOption,n.configureNodeOptionClickedEvent)}_deleteNodeOption;_configureNodeOption};var Te=class{inputsConfigurators=new Array;outputsConfigurators=new Array;powerConfigurator;removeFromDom(){for(let e of this.inputsConfigurators)e.remove();for(let e of this.outputsConfigurators)e.remove();this.powerConfigurator!=null&&this.powerConfigurator.remove()}};var G=class{static replaceAllPlaceholders(){for(let e in this._icons){let t=`svg.${e}_icon-placeholder`;document.querySelectorAll(t).forEach(i=>{this.placeIcon(i,this._icons[e]),i.classList.remove(t)})}}static createIcon(e){let t=M.createSvgElement("svg");return this.placeIcon(t,this._icons[e]),t}static placeIcon(e,t){e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("viewBox","0 -960 960 960");let i=M.createSvgPath();i.setAttribute("d",t),e.appendChild(i)}static _icons={plus:"M440-440H240q-17 0-28.5-11.5T200-480q0-17 11.5-28.5T240-520h200v-200q0-17 11.5-28.5T480-760q17 0 28.5 11.5T520-720v200h200q17 0 28.5 11.5T760-480q0 17-11.5 28.5T720-440H520v200q0 17-11.5 28.5T480-200q-17 0-28.5-11.5T440-240v-200Z","locked-lock":"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm240-200q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Z","unlocked-lock":"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h360v-80q0-50-35-85t-85-35q-42 0-73.5 25.5T364-751q-4 14-16.5 22.5T320-720q-17 0-28.5-11t-8.5-26q14-69 69-116t128-47q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM240-160v-400 400Z",unlink:"m625-449-71-71h46q17 0 28.5 11.5T640-480q0 10-4 18t-11 13ZM820-84q-11 11-28 11t-28-11L84-764q-11-11-11-28t11-28q11-11 28-11t28 11l680 680q11 11 11 28t-11 28ZM280-280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h120q17 0 28.5 11.5T440-320q0 17-11.5 28.5T400-280H280Zm80-160q-17 0-28.5-11.5T320-480q0-17 11.5-28.5T360-520h25l79 80H360Zm380 112q-9-14-6.5-30t16.5-25q23-17 36.5-42t13.5-55q0-50-35-85t-85-35H560q-17 0-28.5-11.5T520-640q0-17 11.5-28.5T560-680h120q83 0 141.5 58.5T880-480q0 49-22.5 91.5T795-318q-14 9-30 6.5T740-328Z","chevron-up":"M 480 -579 L 186 -285 q -15 15 -35.5 14.5 T 115 -286 q -15 -15 -15 -35.5 t 15 -35.5 l 308 -307 q 12 -12 27 -18 t 30 -6 q 15 -0 30 6 t 27 18 L 845 -356 q 15 15 14.5 35 T 844 -286 q -15 15 -35.5 15 t -35.5 -15 l -293 -293 Z",cross:"M480-424 284-228q-11 11-28 11t-28-11q-11-11-11-28t11-28l196-196-196-196q-11-11-11-28t11-28q11-11 28-11t28 11l196 196 196-196q11-11 28-11t28 11q11 11 11 28t-11 28L536-480l196 196q11 11 11 28t-11 28q-11 11-28 11t-28-11L480-424Z",trash:"M280-120q-33 0-56.5-23.5T200-200v-520q-17 0-28.5-11.5T160-760q0-17 11.5-28.5T200-800h160q0-17 11.5-28.5T400-840h160q17 0 28.5 11.5T600-800h160q17 0 28.5 11.5T800-760q0 17-11.5 28.5T760-720v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM400-280q17 0 28.5-11.5T440-320v-280q0-17-11.5-28.5T400-640q-17 0-28.5 11.5T360-600v280q0 17 11.5 28.5T400-280Zm160 0q17 0 28.5-11.5T600-320v-280q0-17-11.5-28.5T560-640q-17 0-28.5 11.5T520-600v280q0 17 11.5 28.5T560-280ZM280-720v520-520Z",configuration:"M480-120q-17 0-28.5-11.5T440-160v-160q0-17 11.5-28.5T480-360q17 0 28.5 11.5T520-320v40h280q17 0 28.5 11.5T840-240q0 17-11.5 28.5T800-200H520v40q0 17-11.5 28.5T480-120Zm-320-80q-17 0-28.5-11.5T120-240q0-17 11.5-28.5T160-280h160q17 0 28.5 11.5T360-240q0 17-11.5 28.5T320-200H160Zm160-160q-17 0-28.5-11.5T280-400v-40H160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520h120v-40q0-17 11.5-28.5T320-600q17 0 28.5 11.5T360-560v160q0 17-11.5 28.5T320-360Zm160-80q-17 0-28.5-11.5T440-480q0-17 11.5-28.5T480-520h320q17 0 28.5 11.5T840-480q0 17-11.5 28.5T800-440H480Zm160-160q-17 0-28.5-11.5T600-640v-160q0-17 11.5-28.5T640-840q17 0 28.5 11.5T680-800v40h120q17 0 28.5 11.5T840-720q0 17-11.5 28.5T800-680H680v40q0 17-11.5 28.5T640-600Zm-480-80q-17 0-28.5-11.5T120-720q0-17 11.5-28.5T160-760h320q17 0 28.5 11.5T520-720q0 17-11.5 28.5T480-680H160Z",power:"M420-412H302q-14 0-20-12t2-23l203-295q5-7 12-9t15 1q8 3 11.5 9.5T528-726l-27 218h140q14 0 20 13t-3 24L431-199q-5 6-12 7.5t-14-1.5q-7-3-10.5-9t-2.5-14l28-196Z",mouse:"M480-80q-116 0-198-82t-82-198v-240q0-116 82-198t198-82q116 0 198 82t82 198v240q0 116-82 198T480-80Zm40-520h160q0-72-45.5-127T520-796v196Zm-240 0h160v-196q-69 14-114.5 69T280-600Zm200 440q83 0 141.5-58.5T680-360v-160H280v160q0 83 58.5 141.5T480-160Zm0-360Zm40-80Zm-80 0Zm40 80Z","mouse-left":"M 480 -80 a 269.6 269.6 90 0 1 -198 -82 A 269.6 269.6 90 0 1 200 -360 V -600 c 0 -77.2 27.2 -143.2 82 -198 A 269.6 269.6 90 0 1 480 -880 c 77.2 0 143.2 27.2 198 82 A 269.6 269.6 90 0 1 760 -600 v 240 c 0 77.2 -27.2 143.2 -82 198 A 269.6 269.6 90 0 1 480 -80 Z m 40 -520 h 160 c 0 -48 -15.2 -90.4 -45.6 -126.8 A 195.2 195.2 90 0 0 520 -796 V -600 Z m -40 440 c 55.2 0 102.4 -19.6 141.6 -58.4 A 192.8 192.8 90 0 0 680 -360 v -160 H 280 v 160 c 0 55.2 19.6 102.4 58.4 141.6 A 192.8 192.8 90 0 0 480 -160 Z","mouse-right":"M 480 -80 a 269.6 269.6 90 0 1 -198 -82 A 269.6 269.6 90 0 1 200 -360 V -600 c 0 -77.2 27.2 -143.2 82 -198 A 269.6 269.6 90 0 1 480 -880 c 77.2 0 143.2 27.2 198 82 A 269.6 269.6 90 0 1 760 -600 v 240 c 0 77.2 -27.2 143.2 -82 198 A 269.6 269.6 90 0 1 480 -80 Z M 280 -600 h 160 V -796 c -46 9.2 -84 32 -114.4 69.2 A 193.6 193.6 90 0 0 280 -600 Z m 200 440 c 55.2 0 102.4 -19.6 141.6 -58.4 A 192.8 192.8 90 0 0 680 -360 v -160 H 280 v 160 c 0 55.2 19.6 102.4 58.4 141.6 A 192.8 192.8 90 0 0 480 -160 Z","mouse-drag":"M 699.11 -179.11 H 592.06 l 22.98 22.45 a 20.63 20.63 0 0 1 6.26 15.15 c 0 5.91 -2.08 10.96 -6.26 15.14 a 20.63 20.63 0 0 1 -15.14 6.27 a 20.63 20.63 0 0 1 -15.15 -6.27 l -59 -59 a 18.32 18.32 0 0 1 -4.45 -6.8 A 23.13 23.13 0 0 1 520 -200 c 0 -2.78 0.43 -5.4 1.3 -7.83 c 0.88 -2.44 2.36 -4.7 4.44 -6.8 l 59.01 -59 a 20.33 20.33 0 0 1 14.88 -6.27 c 5.75 0 10.7 2.1 14.89 6.27 a 20.33 20.33 0 0 1 6.26 14.88 c 0 5.75 -2.09 10.7 -6.26 14.89 l -22.98 22.97 h 107.57 V -328.46 l -23.5 23.5 c -4.17 4.18 -9.05 6.18 -14.62 6 c -5.57 -0.17 -10.44 -2.34 -14.62 -6.52 a 20.33 20.33 0 0 1 -6.27 -14.89 c 0 -5.74 2.1 -10.7 6.27 -14.88 l 59 -59 a 18.32 18.32 0 0 1 6.8 -4.45 c 2.43 -0.87 5.05 -1.3 7.83 -1.3 c 2.78 0 5.4 0.43 7.83 1.3 c 2.44 0.88 4.7 2.36 6.8 4.44 l 59.52 59.53 c 4.18 4.18 6.27 9.06 6.27 14.63 s -2.1 10.44 -6.27 14.62 a 20.33 20.33 0 0 1 -14.88 6.26 c -5.75 0 -10.7 -2.08 -14.88 -6.26 l -23.5 -22.98 v 107.57 h 107.05 l -22.98 -22.45 a 20.63 20.63 0 0 1 -6.27 -15.15 c 0 -5.91 2.1 -10.96 6.27 -15.14 a 20.63 20.63 0 0 1 15.14 -6.27 c 5.92 0 10.97 2.1 15.15 6.27 l 59 59 a 18.3 18.3 0 0 1 4.44 6.8 A 23.1 23.1 0 0 1 920 -200 c 0 2.78 -0.43 5.4 -1.3 7.83 a 18.3 18.3 0 0 1 -4.44 6.8 l -59.53 59.52 c -4.18 4.18 -9.06 6.18 -14.63 6 c -5.57 -0.17 -10.44 -2.34 -14.62 -6.52 a 20.33 20.33 0 0 1 -6.26 -14.88 c 0 -5.75 2.08 -10.7 6.26 -14.89 l 22.98 -22.97 H 740.89 v 107.05 l 22.45 -22.98 a 20.63 20.63 0 0 1 15.15 -6.26 c 5.91 0 10.96 2.08 15.14 6.26 a 20.63 20.63 0 0 1 6.26 15.14 c 0 5.92 -2.08 10.97 -6.26 15.15 l -59 59 a 18.3 18.3 0 0 1 -6.8 4.44 A 23.1 23.1 0 0 1 720 0 c -2.78 0 -5.4 -0.43 -7.83 -1.3 a 18.3 18.3 0 0 1 -6.8 -4.44 l -59.52 -59.53 a 19.44 19.44 0 0 1 -6 -14.89 a 21.3 21.3 0 0 1 6.52 -14.88 a 20.33 20.33 0 0 1 14.88 -6.26 c 5.75 0 10.7 2.08 14.89 6.26 l 22.97 23.5 V -179.11 Z M 320 -160 c -77.33 0 -143.33 -27.33 -198 -82 c -54.67 -54.67 -82 -120.67 -82 -198 V -680 c 0 -77.33 27.33 -143.33 82 -198 C 176.67 -932.67 242.67 -960 320 -960 s 143.33 27.33 198 82 c 54.67 54.67 82 120.67 82 198 v 240 c 0 77.33 -27.33 143.33 -82 198 c -54.67 54.67 -120.67 82 -198 82 Z m 40 -520 h 160 c 0 -48 -15.17 -90.33 -45.5 -127 S 406 -866.67 360 -876 v 196 Z m -39 440 c 55.33 0 102.5 -19.5 141.5 -58.5 S 520.67 -384.67 520 -440 V -600 H 120 v 160 c 0 55.33 19.5 102.5 58.5 141.5 S 264.67 -240 320 -240 h 1 Z","mac-command":"M260-120q-58 0-99-41t-41-99q0-58 41-99t99-41h60v-160h-60q-58 0-99-41t-41-99q0-58 41-99t99-41q58 0 99 41t41 99v60h160v-60q0-58 41-99t99-41q58 0 99 41t41 99q0 58-41 99t-99 41h-60v160h60q58 0 99 41t41 99q0 58-41 99t-99 41q-58 0-99-41t-41-99v-60H400v60q0 58-41 99t-99 41Zm0-80q25 0 42.5-17.5T320-260v-60h-60q-25 0-42.5 17.5T200-260q0 25 17.5 42.5T260-200Zm440 0q25 0 42.5-17.5T760-260q0-25-17.5-42.5T700-320h-60v60q0 25 17.5 42.5T700-200ZM400-400h160v-160H400v160ZM260-640h60v-60q0-25-17.5-42.5T260-760q-25 0-42.5 17.5T200-700q0 25 17.5 42.5T260-640Zm380 0h60q25 0 42.5-17.5T760-700q0-25-17.5-42.5T700-760q-25 0-42.5 17.5T640-700v60Z","question-mark":"M584-637q0-43-28.5-69T480-732q-29 0-52.5 12.5T387-683q-16 23-43.5 26.5T296-671q-14-13-15.5-32t9.5-36q32-48 81.5-74.5T480-840q97 0 157.5 55T698-641q0 45-19 81t-70 85q-37 35-50 54.5T542-376q-4 24-20.5 40T482-320q-23 0-39.5-15.5T426-374q0-39 17-71.5t57-68.5q51-45 67.5-69.5T584-637ZM480-80q-33 0-56.5-23.5T400-160q0-33 23.5-56.5T480-240q33 0 56.5 23.5T560-160q0 33-23.5 56.5T480-80Z",touchpad:"M593-80q-24 0-46-9t-39-26L332-292q-11-11-11.5-27.5T331-348l6-6q14-14 34-19t40 0l69 20v-287q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v340q0 20-15.5 31.5T509-262l-47-13 103 103q6 6 13 9t15 3h167q33 0 56.5-23.5T840-240v-160q0-17 11.5-28.5T880-440q17 0 28.5 11.5T920-400v160q0 66-47 113T760-80H593Zm47-280q-17 0-28.5-11.5T600-400v-120q0-17 11.5-28.5T640-560q17 0 28.5 11.5T680-520v120q0 17-11.5 28.5T640-360Zm120 0q-17 0-28.5-11.5T720-400v-80q0-17 11.5-28.5T760-520q17 0 28.5 11.5T800-480v80q0 17-11.5 28.5T760-360Zm0 200H565h195Zm-600-40q-33 0-56.5-23.5T80-280v-480q0-33 23.5-56.5T160-840h600q33 0 56.5 23.5T840-760v120q0 17-11.5 28.5T800-600q-17 0-28.5-11.5T760-640v-120H160v480h72q17 0 28.5 11.5T272-240q0 17-11.5 28.5T232-200h-72Z","touchpad-two":"M160-200q-33 0-56.5-23.5T80-280v-480q0-33 23.5-56.5T160-840h600q33 0 56.5 23.5T840-760v120q0 17-11.5 28.5T800-600q-17 0-28.5-11.5T760-640v-120H160v480h72q17 0 28.5 11.5T272-240q0 17-11.5 28.5T232-200h-72Zm560-200v-80q0-17 11.5-28.5T760-520q17 0 28.5 11.5T800-480v80q0 17-11.5 28.5T760-360q-17 0-28.5-11.5T720-400Zm40 240H565h195ZM593-80q-24 0-46-9t-39-26L332-292q-11-11-11.5-27.5T331-348l6-6q14-14 34-19t40 0l69 20v-287q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v340q0 20-15.5 31.5T509-262l-47-13 103 103q6 6 13 9t15 3h167q33 0 56.5-23.5T840-240v-160q0-17 11.5-28.5T880-440q17 0 28.5 11.5T920-400v160q0 66-47 113T760-80H593Zm7-320v-280q0-17 11.5-28.5T640-720q17 0 28.5 11.5T680-680v280q0 17-11.5 28.5T640-360q-17 0-28.5-11.5T600-400Z","touch-move":"M 592.8 -40 a 120 120 90 0 1 -84.8 -35.2 L 332 -252 a 36.8 36.8 90 0 1 -11.2 -29.6 c 0.8 -11.6 5.2 -21.6 13.2 -29.2 a 80 80 90 0 1 80 -21.2 l 66 19.2 V -640 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 380 c 0 13.2 -5.2 24 -16 32 a 39.2 39.2 90 0 1 -35.2 7.2 l -46 -13.2 l 102 102 c 3.6 3.2 8 6 12.8 8.4 a 36 36 90 0 0 15.2 3.6 H 760 c 22 0 40.8 -8 56.4 -23.6 c 16 -15.6 23.6 -34.4 23.6 -56.4 v -160 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 160 c 0 44 -16 81.6 -47.2 112.8 A 154 154 90 0 1 760 -40 h -167.2 Z M 640 -520 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 120 c 0 11.2 -4 20.8 -11.6 28.4 c -7.6 8 -17.2 11.6 -28.4 11.6 a 38.8 38.8 90 0 1 -28.4 -11.6 A 38.8 38.8 90 0 1 600 -360 v -120 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 Z m 120 40 c 11.2 0 20.8 4 28.4 11.6 c 8 7.6 11.6 17.2 11.6 28.4 v 80 c 0 11.2 -4 20.8 -11.6 28.4 c -7.6 8 -17.2 11.6 -28.4 11.6 a 38.8 38.8 90 0 1 -28.4 -11.6 A 38.8 38.8 90 0 1 720 -360 v -80 c 0 -11.2 4 -20.8 11.6 -28.4 c 7.6 -8 17.2 -11.6 28.4 -11.6 Z M 225.6 -579.2 v -68 c 0 -6.4 2.4 -12 6.4 -16 c 4 -4 9.2 -6 15.6 -6 c 6 0 11.2 2 15.2 6.4 c 4 4 6.4 9.2 6.4 15.2 v 68 l 23.2 -24 c 4 -4.4 9.6 -6.4 16 -6.4 c 6 0 11.2 2 15.6 6.4 c 4 4 6.4 9.6 6.4 16 c 0 5.6 -2.4 11.2 -6.4 15.2 l -61.2 61.2 a 19.2 19.2 90 0 1 -7.2 4.8 a 24 24 90 0 1 -16 0 a 19.2 19.2 90 0 1 -7.2 -4.8 L 170.4 -572.8 a 20 20 90 0 1 -6 -15.6 c 0 -5.6 2.4 -10.8 6.8 -15.2 c 4 -4.4 9.2 -6.4 15.2 -6.4 s 11.2 2 15.6 6.4 l 24 24 Z m -110.8 -112 l 24 23.6 c 4 4 6.4 9.6 6.4 16 c 0 6 -2.4 11.2 -6.8 15.6 c -4 4 -9.2 6.4 -15.6 6.4 a 21.2 21.2 90 0 1 -16 -6.4 L 46.4 -697.2 a 19.2 19.2 90 0 1 -4.8 -7.2 a 24 24 90 0 1 -1.2 -8 a 24 24 90 0 1 1.2 -8 a 19.2 19.2 90 0 1 4.8 -7.2 l 61.2 -61.2 c 4 -4.4 9.6 -6.8 15.6 -6.8 c 5.6 0 10.8 2.4 15.2 6.8 c 4 4 6.4 9.2 6.4 15.2 s -2 11.2 -6.4 15.6 l -24 24 h 68.4 c 6 0 11.2 2 15.6 6 c 4 4 6 9.2 6 15.6 a 20.8 20.8 90 0 1 -21.6 21.6 h -68 Z m 266 0 h -68 a 20.8 20.8 90 0 1 -16 -6 a 20.8 20.8 90 0 1 -6 -15.2 c 0 -6.4 2 -11.6 6.4 -15.6 c 4 -4 9.2 -6.4 15.2 -6.4 h 68 l -24 -23.2 a 21.6 21.6 90 0 1 -6.4 -15.6 c 0 -6 2 -11.2 6.4 -16 c 4 -4 9.6 -6.4 16 -6.4 c 5.6 0 11.2 2.4 15.2 6.8 l 61.2 61.2 c 2.4 2 4 4.4 4.8 6.8 a 24 24 90 0 1 0 16.4 a 19.2 19.2 90 0 1 -4.8 7.2 L 387.2 -636 a 20 20 90 0 1 -15.2 6.4 a 22 22 90 0 1 -15.2 -6.8 a 21.2 21.2 90 0 1 -6.4 -15.6 c 0 -6 2 -11.2 6.4 -15.6 l 24 -24 Z M 225.6 -845.2 l -24 24 a 20.8 20.8 90 0 1 -30.4 0 a 21.2 21.2 90 0 1 -6.8 -15.2 c 0 -6 2.4 -11.2 6.8 -15.6 L 232 -914 c 2 -2.4 4.4 -4 6.8 -4.8 a 24 24 90 0 1 8 -1.2 a 24 24 90 0 1 8.4 1.2 c 2.4 1.2 4.8 2.4 7.2 4.8 L 324 -852.4 a 20.8 20.8 90 0 1 0 30.4 c -4 4 -9.6 6.4 -15.6 6.4 a 21.2 21.2 90 0 1 -15.2 -6.4 l -24.4 -24 v 68.4 c 0 6 -2 11.2 -6.4 15.6 c -4 4 -9.2 6 -15.2 6 a 20.8 20.8 90 0 1 -15.6 -6 a 20.8 20.8 90 0 1 -6.4 -15.6 v -68 Z",touch:"M419-80q-28 0-52.5-12T325-126L124-381q-8-9-7-21.5t9-20.5q20-21 48-25t52 11l74 45v-328q0-17 11.5-28.5T340-760q17 0 29 11.5t12 28.5v400q0 23-20.5 34.5T320-286l-36-22 104 133q6 7 14 11t17 4h221q33 0 56.5-23.5T720-240v-160q0-17-11.5-28.5T680-440H501q-17 0-28.5-11.5T461-480q0-17 11.5-28.5T501-520h179q50 0 85 35t35 85v160q0 66-47 113T640-80H419Zm83-260Zm-23-260q-17 0-28.5-11.5T439-640q0-2 5-20 8-14 12-28.5t4-31.5q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 17 4 31.5t12 28.5q3 5 4 10t1 10q0 17-11 28.5T202-600q-11 0-20.5-6T167-621q-13-22-20-47t-7-52q0-83 58.5-141.5T340-920q83 0 141.5 58.5T540-720q0 27-7 52t-20 47q-5 9-14 15t-20 6Z",pinch:"M593-40q-24 0-46-9t-39-26L332-252q-12-12-11-29.5t13-29.5q16-16 37.5-21.5t42.5.5l66 19v-327q0-17 11.5-28.5T520-680q17 0 28.5 11.5T560-640v380q0 20-16 32t-35 7l-46-13 102 102q5 5 12.5 8.5T593-120h167q33 0 56.5-23.5T840-200v-160q0-17 11.5-28.5T880-400q17 0 28.5 11.5T920-360v160q0 66-47 113T760-40H593Zm109-200ZM380-818 142-580h68q13 0 21.5 8.5T240-550q0 13-8.5 21.5T210-520H80q-17 0-28.5-11.5T40-560v-130q0-13 8.5-21.5T70-720q13 0 21.5 8.5T100-690v68l238-238h-68q-13 0-21.5-8.5T240-890q0-13 8.5-21.5T270-920h130q17 0 28.5 11.5T440-880v130q0 13-8.5 21.5T410-720q-13 0-21.5-8.5T380-750v-68Zm260 298q17 0 28.5 11.5T680-480v120q0 17-11.5 28.5T640-320q-17 0-28.5-11.5T600-360v-120q0-17 11.5-28.5T640-520Zm120 40q17 0 28.5 11.5T800-440v80q0 17-11.5 28.5T760-320q-17 0-28.5-11.5T720-360v-80q0-17 11.5-28.5T760-480Z",search:"M380-320q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l224 224q11 11 11 28t-11 28q-11 11-28 11t-28-11L532-372q-30 24-69 38t-83 14Zm0-80q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z",tick:"m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z","three-dots":"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z",grid:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z","disable-grid":"M333-200v-133H200v133h133Zm214 0v-100l-33-33H413v133h134Zm80 0Zm116-133Zm-410-80v-101l-33-33H200v134h133Zm80 0Zm347 0v-134H627v99l35 35h98ZM529-547Zm-329-80Zm347 0v-133H413v98l35 35h99Zm213 0v-133H627v133h133ZM316-760Zm524 525L235-840h525q33 0 56.5 23.5T840-760v525ZM200-120q-33 0-56.5-23.5T120-200v-640l720 720H200Zm591 64L56-792q-11-11-11.5-27.5T56-848q11-11 28-11t28 11l736 736q12 12 11.5 28T847-56q-12 11-28 11.5T791-56Z",github:"M 478.5698 -960 C 213.9331 -960 0 -744.4898 0 -477.8743 c 0 213.12 137.0743 393.5216 327.2327 457.3714 c 23.7747 4.8 32.4833 -10.3739 32.4833 -23.138 c 0 -11.1771 -0.7837 -49.489 -0.7837 -89.4073 c -133.1265 28.7412 -160.849 -57.4727 -160.849 -57.4727 c -21.3943 -55.8759 -53.0939 -70.2367 -53.0939 -70.2367 c -43.5722 -29.5347 3.1739 -29.5347 3.1739 -29.5347 c 48.3331 3.1935 73.6947 49.489 73.6947 49.489 c 42.7788 73.4302 111.7127 52.6824 139.4449 39.9086 c 3.9576 -31.1314 16.6433 -52.6824 30.1127 -64.6531 c -106.178 -11.1771 -217.8906 -52.6824 -217.8906 -237.8743 c 0 -52.6824 19.0041 -95.7845 49.1167 -129.3061 c -4.751 -11.9706 -21.3943 -61.4694 4.7608 -127.7192 c 0 0 40.4082 -12.7739 131.52 49.489 a 460.1143 460.1143 90 0 1 119.6473 -15.9673 c 40.4082 0 81.6 5.5935 119.6376 15.9673 c 91.1216 -62.2629 131.5298 -49.489 131.5298 -49.489 c 26.1551 66.2498 9.502 115.7486 4.751 127.7192 c 30.9061 33.5216 49.1265 76.6237 49.1265 129.3061 c 0 185.1918 -111.7127 225.8939 -218.6841 237.8743 c 17.4367 15.1641 32.4833 43.8955 32.4833 89.3976 c 0 64.6531 -0.7837 116.542 -0.7837 132.4996 c 0 12.7739 8.7184 27.9478 32.4833 23.1576 c 190.1584 -63.8694 327.2327 -244.2612 327.2327 -457.3812 C 957.1298 -744.4898 742.4131 -960 478.5698 -960 z","buy-me-a-coffee":"M 502.983 -516.5235 c -34.4819 14.7565 -73.61 31.4946 -124.3271 31.4946 a 235.3689 235.3689 90 0 1 -62.7715 -8.6543 l 35.0824 360.1389 a 60.1745 60.1745 90 0 0 59.9719 55.2206 s 49.7339 2.582 66.3368 2.582 c 17.864 0 71.4183 -2.582 71.4183 -2.582 a 60.167 60.167 90 0 0 59.9643 -55.2206 l 37.5668 -397.9609 c -16.7906 -5.7345 -33.7314 -9.5475 -52.8413 -9.5475 c -33.0258 -0.015 -59.6491 11.3639 -90.4006 24.5292 Z M 808.4341 -703.412 l -5.2841 -26.6458 c -4.7362 -23.9062 -15.4996 -46.4913 -40.0363 -55.1306 c -7.8661 -2.7697 -16.7906 -3.9556 -22.8178 -9.6751 c -6.0347 -5.7195 -7.8136 -14.6064 -9.2097 -22.8478 c -2.582 -15.1243 -5.0139 -30.2561 -7.656 -45.3579 c -2.2893 -12.9776 -4.0982 -27.5615 -10.0579 -39.4658 c -7.7461 -15.9875 -23.8236 -25.3398 -39.8111 -31.5246 a 229.3041 229.3041 90 0 0 -25.0396 -7.7461 C 608.5754 -952.3515 566.5726 -956.217 525.478 -958.4313 a 1033.0095 1033.0095 90 0 0 -147.9931 2.4544 c -36.6286 3.3326 -75.2088 7.3557 -110.0059 20.0332 c -12.7224 4.6311 -25.8352 10.2005 -35.5027 20.0256 c -11.8743 12.0844 -15.7473 30.7515 -7.078 45.8158 c 6.1548 10.6884 16.588 18.2392 27.6666 23.2457 a 224.3878 224.3878 90 0 0 44.9151 14.6139 c 43.0086 9.5099 87.5484 13.2403 131.4877 14.8316 c 48.698 1.9665 97.4711 0.3753 145.9365 -4.7662 a 830.8991 830.8991 90 0 0 35.893 -4.7437 c 14.066 -2.1542 23.088 -20.5435 18.9448 -33.3561 c -4.9539 -15.312 -18.2918 -21.2566 -33.3636 -18.9448 c -2.2142 0.3453 -4.4285 0.6755 -6.6502 0.9908 l -1.5987 0.2327 a 812.9301 812.9301 90 0 1 -47.0392 4.6011 a 1051.9468 1051.9468 90 0 1 -71.3282 2.4544 c -23.3733 0 -46.7615 -0.6605 -70.0898 -2.1992 c -10.6433 -0.698 -21.2566 -1.5762 -31.8474 -2.6571 c -4.8188 -0.5029 -9.6225 -1.0358 -14.4263 -1.6288 l -4.5711 -0.5855 l -0.9908 -0.1351 l -4.7437 -0.6905 a 499.4027 499.4027 90 0 1 -28.9576 -5.164 a 4.3534 4.3534 90 0 1 0 -8.4966 h 0.1876 a 469.9647 469.9647 90 0 1 25.0696 -4.6011 l 8.4141 -1.291 h 0.0751 c 5.2541 -0.3453 10.5457 -1.291 15.7698 -1.9065 c 45.5081 -4.7362 91.2863 -6.35 137.0195 -4.8338 c 22.1948 0.6455 44.3897 1.9515 66.4869 4.2033 c 4.7512 0.4879 9.4799 1.0058 14.2011 1.5837 c 1.8089 0.2252 3.6328 0.4804 5.4493 0.698 l 3.6779 0.5254 a 508.9426 508.9426 90 0 1 31.8999 5.802 c 15.6873 3.4077 35.818 4.5185 42.7909 21.6919 c 2.2217 5.4568 3.2275 11.514 4.4585 17.2335 l 1.5612 7.2957 a 115281.889 115281.889 90 0 0 11.1837 52.0607 a 9.4574 9.4574 90 0 1 -7.9562 11.3564 h -0.0976 l -2.2668 0.3002 l -2.2292 0.3002 a 1373.0477 1373.0477 90 0 1 -63.2444 6.7177 a 1505.5562 1505.5562 90 0 1 -126.4663 5.089 a 1482.9636 1482.9636 90 0 1 -169.625 -9.8627 c -6.0948 -0.7281 -12.1895 -1.5012 -18.2843 -2.2893 c 4.7287 0.6005 -3.4377 -0.4654 -5.089 -0.698 c -3.873 -0.5404 -7.7461 -1.1034 -11.6266 -1.6888 c -13.0002 -1.9515 -25.9328 -4.3534 -38.9104 -6.455 c -15.6873 -2.5895 -30.699 -1.2985 -44.8851 6.455 a 65.301 65.301 90 0 0 -27.0361 28.0269 c -6.1248 12.6549 -7.9412 26.4357 -10.6808 40.0288 C 151.2432 -703.1493 146.9798 -688.5129 148.5936 -674.552 c 3.4752 30.1285 24.5442 54.6127 54.8378 60.0919 a 1554.9673 1554.9673 90 0 0 85.8971 12.9101 a 1587.3401 1587.3401 90 0 0 367.7798 2.1242 a 19.3726 19.3726 90 0 1 21.3917 21.2341 l -2.8747 27.8693 l -17.331 168.9345 a 134235.3364 134235.3364 90 0 1 -23.3582 227.3301 c -1.6513 16.3928 -1.8915 33.296 -4.9989 49.4937 c -4.9088 25.4674 -22.1498 41.1096 -47.3095 46.8291 a 329.635 329.635 90 0 1 -70.2324 8.2114 c -26.203 0.1426 -52.3909 -1.0208 -78.6014 -0.8782 c -27.9744 0.1576 -62.2386 -2.4244 -83.8255 -23.2457 c -18.9748 -18.2843 -21.5944 -46.9192 -24.1839 -71.681 c -3.4377 -32.7781 -6.8529 -65.5487 -10.238 -98.3193 l -18.9898 -182.2124 l -12.2796 -117.9021 c -0.2027 -1.9515 -0.4128 -3.873 -0.6005 -5.8396 c -1.4787 -14.066 -11.4314 -27.8317 -27.1262 -27.1187 c -13.4355 0.593 -28.6949 12.0094 -27.1187 27.1187 l 9.1046 87.4058 l 18.8247 180.8163 c 5.3667 51.3551 10.7184 102.7177 16.0625 154.0954 c 1.0283 9.8402 1.9966 19.7104 3.0774 29.5506 c 5.9071 53.7795 46.9792 82.7597 97.8314 90.9185 c 29.7082 4.7812 60.137 5.7645 90.2805 6.2524 c 38.6402 0.623 77.6707 2.1091 115.6804 -4.8938 c 56.3165 -10.3356 98.5745 -47.94 104.6092 -106.2755 l 5.164 -50.537 c 5.727 -55.7235 11.4464 -111.4546 17.1509 -167.1856 l 18.6746 -182.0923 l 8.5567 -83.4652 a 19.3651 19.3651 90 0 1 15.6122 -17.0383 c 16.1001 -3.1299 31.4946 -8.4891 42.9486 -20.7462 c 18.2392 -19.5152 21.8646 -44.9601 15.4246 -70.6077 Z M 202.6058 -685.413 c 0.2477 -0.1126 -0.2102 1.9891 -0.3978 2.9723 c -0.0375 -1.4862 0.0375 -2.7997 0.3978 -2.9723 Z m 1.5612 12.0919 c 0.1276 -0.0901 0.5179 0.4278 0.9157 1.0508 c -0.6005 -0.5704 -0.9908 -0.9983 -0.9307 -1.0508 h 0.015 Z m 1.5387 2.0266 c 0.5554 0.9457 0.8557 1.5387 0 0 Z m 3.0849 2.507 h 0.0751 c 0 0.0901 0.1501 0.1801 0.1952 0.2702 a 2.0041 2.0041 90 0 0 -0.2852 -0.2702 h 0.015 Z m 540.5198 -3.7529 c -5.787 5.5093 -14.5088 8.0688 -23.1181 9.3448 c -96.6005 14.3362 -194.6195 21.5944 -292.2783 18.3894 c -69.8946 -2.3869 -139.0536 -10.1479 -208.2577 -19.9281 c -6.7778 -0.9532 -14.126 -2.1917 -18.7872 -7.1906 c -8.7819 -9.4274 -4.4735 -28.4172 -2.1842 -39.8036 c 2.0941 -10.4332 6.0948 -24.349 18.5095 -25.8277 c 19.3651 -2.2743 41.8677 5.8996 61.0377 8.8044 c 23.073 3.5278 46.2361 6.3425 69.4743 8.4591 c 99.22 9.0371 200.0988 7.6335 298.8685 -5.5919 c 18.0066 -2.4169 35.9381 -5.2316 53.817 -8.4366 c 15.9274 -2.8522 33.5812 -8.2114 43.1962 8.279 c 6.6052 11.2363 7.4833 26.2705 6.455 38.9704 a 21.722 21.722 90 0 1 -6.7553 14.5389 h 0.0225 Z",clear:"M280-120q-33 0-56.5-23.5T200-200v-520q-17 0-28.5-11.5T160-760q0-17 11.5-28.5T200-800h160q0-17 11.5-28.5T400-840h160q17 0 28.5 11.5T600-800h160q17 0 28.5 11.5T800-760q0 17-11.5 28.5T760-720v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520Zm-400 0v520-520Zm200 316 76 76q11 11 28 11t28-11q11-11 11-28t-11-28l-76-76 76-76q11-11 11-28t-11-28q-11-11-28-11t-28 11l-76 76-76-76q-11-11-28-11t-28 11q-11 11-11 28t11 28l76 76-76 76q-11 11-11 28t11 28q11 11 28 11t28-11l76-76Z",delete:"M280-120q-33 0-56.5-23.5T200-200v-520q-17 0-28.5-11.5T160-760q0-17 11.5-28.5T200-800h160q0-17 11.5-28.5T400-840h160q17 0 28.5 11.5T600-800h160q17 0 28.5 11.5T800-760q0 17-11.5 28.5T760-720v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM400-280q17 0 28.5-11.5T440-320v-280q0-17-11.5-28.5T400-640q-17 0-28.5 11.5T360-600v280q0 17 11.5 28.5T400-280Zm160 0q17 0 28.5-11.5T600-320v-280q0-17-11.5-28.5T560-640q-17 0-28.5 11.5T520-600v280q0 17 11.5 28.5T560-280ZM280-720v520-520Z"}};var ee=class n{constructor(e){this._nodeConfig=e,this._editElement=document.createElement("div"),this._editElement.classList.add("edit"),this._iconContainer=document.createElement("div"),this._iconContainer.classList.add("icon-container"),this._inputElement=document.createElement("input"),this._unitsElement=document.createElement("div"),this._unitsElement.classList.add("units"),this._editElement.appendChild(this._iconContainer),this._editElement.appendChild(this._inputElement),this._editElement.appendChild(this._unitsElement)}build(){if(this._minimumGetter==null||this._maximumGetter==null||this._relatedPropertyGetter==null||this._relatedPropertySetter==null)throw Error("Configurator builder can't build without required fields");let e=a=>{let o=this._minimumGetter();return o==null||a>=o},t=a=>{let o=this._maximumGetter();return o==null||a<=o},i=n.configuratorToFixed;return this._inputElement.addEventListener("input",()=>{let a=n.numberParser(this._inputElement.value);a!=null&&e(a)&&t(a)?(this._inputElement.classList.remove("error"),this._relatedPropertySetter(i(a))):this._inputElement.classList.add("error")}),this._inputElement.addEventListener("blur",()=>{this._inputElement.classList.remove("error");let a=n.numberParser(this._inputElement.value);a!=null&&(e(a)?t(a)||this._relatedPropertySetter(this._maximumGetter()):this._relatedPropertySetter(this._minimumGetter())),this._inputElement.value=`${i(this._relatedPropertyGetter())}`}),this._inputElement.addEventListener("keydown",a=>{a.repeat||(a.key==="Enter"&&this._inputElement.blur(),a.stopPropagation())}),this._editElement}subscribeToMachinesAmount(){return this._nodeConfig.addEventListener(ne.machinesAmountChangedEvent,this.updateInputValue.bind(this)),this}subscribeToOverclock(){return this._nodeConfig.addEventListener(ne.overclockChangedEvent,this.updateInputValue.bind(this)),this}setMinimum(e){return this._minimumGetter=e,this}setMaximum(e){return this._maximumGetter=e,this}setRelatedProperty(e,t){return this._relatedPropertyGetter=e,this._relatedPropertySetter=t,this}setInitialValue(e){return this._inputElement.value=`${e}`,this}setUnits(e){return this._unitsElement.innerText=e,this}setIconImage(e,t){let i=document.createElement("img");return i.src=F(t),i.alt=e,this._iconContainer.title=e,this._iconContainer.appendChild(i),this}setPowerSvgIcon(){let e=G.createIcon("power");return this._iconContainer.title="Power consumption",this._iconContainer.appendChild(e),this}updateInputValue(){if(this._relatedPropertyGetter==null)throw Error("Configurator builder can't build without required fields");if(!Object.is(document.activeElement,this._inputElement)){let e=n.configuratorToFixed;this._inputElement.value=`${e(this._relatedPropertyGetter())}`}}static configuratorToFixed(e){return+e.toFixed(4)}static numberParser(e){let t=+e,i=Number.parseFloat(e);if(!(Number.isNaN(t)||Number.isNaN(i)))return t}_nodeConfig;_editElement;_iconContainer;_inputElement;_unitsElement;_minimumGetter;_maximumGetter;_relatedPropertyGetter;_relatedPropertySetter};var ne=class n extends EventTarget{static machinesAmountChangedEvent="machines-amount-changed";static overclockChangedEvent="overclock-changed";static configurationUpdatedEvent="configuration-updated";constructor(e,t){super();let i=`#${n._modalContainer.id} .title-row .close`;document.querySelector(i).addEventListener("click",o=>{this._isOpened&&(o.stopPropagation(),this.closeConfigurationWindow())}),window.addEventListener("keydown",o=>{this._isOpened&&o.code==="Escape"&&(o.preventDefault(),o.stopPropagation(),this.closeConfigurationWindow()),o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),this.confirmConfiguration())}),this.setupTableElements(e,t),this.addEventListener(n.machinesAmountChangedEvent,()=>{this.updateResetButton(),this.updateRestoreButton()}),this.addEventListener(n.overclockChangedEvent,()=>{this.updateResetButton(),this.updateRestoreButton()}),n._restoreButton.addEventListener("click",()=>{this._isOpened&&(this.machinesAmount=this._openingMachinesAmount,this.overclockRatio=this._openingOverclockRatio)}),n._resetButton.addEventListener("click",()=>{this._isOpened&&(this.machinesAmount=1,this.overclockRatio=1)}),n._applyButton.addEventListener("click",()=>{this._isOpened&&this.confirmConfiguration()}),n._modalContainer.querySelector(".modal-window").addEventListener("click",o=>{o.stopPropagation()}),n._modalContainer.addEventListener("click",o=>{o.stopPropagation(),this.closeConfigurationWindow()})}openConfigurationWindow(e,t){this._openingMachinesAmount=e,this._openingOverclockRatio=t,this.machinesAmount=this._openingMachinesAmount,this.overclockRatio=this._openingOverclockRatio,n._machinesColumn.appendChild(this._machineConfigurator);for(let i of this._amountConfigurators.inputsConfigurators)n._amountInputsColumn.appendChild(i);for(let i of this._amountConfigurators.outputsConfigurators)n._amountOutputsColumn.appendChild(i);n._amountPowerColumn.appendChild(this._amountConfigurators.powerConfigurator),n._multipliersColumn.appendChild(this._overclockConfigurator);for(let i of this._overclockConfigurators.inputsConfigurators)n._overclockInputsColumn.appendChild(i);for(let i of this._overclockConfigurators.outputsConfigurators)n._overclockOutputsColumn.appendChild(i);n._overclockPowerColumn.appendChild(this._overclockConfigurators.powerConfigurator),n._modalContainer.classList.remove("hidden"),this._isOpened=!0,this.updateResetButton(),this.updateRestoreButton()}closeConfigurationWindow(){this._machineConfigurator.remove(),this._overclockConfigurator.remove(),this._amountConfigurators.removeFromDom(),this._overclockConfigurators.removeFromDom(),n._modalContainer.classList.add("hidden"),this._isOpened=!1}confirmConfiguration(){this.dispatchEvent(new Event(n.configurationUpdatedEvent)),this.closeConfigurationWindow()}setupTableElements(e,t){let i=n._minOverclockRatio,a=n._maxOverclockRatio;this._machineConfigurator=new ee(this).setIconImage(t.displayName,t.iconPath).setInitialValue(1).setUnits("").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>this.machinesAmount,u=>this.machinesAmount=u).subscribeToMachinesAmount().build(),this._overclockConfigurator=new ee(this).setIconImage("Overclock","Resource/Environment/Crystal/PowerShard.png").setInitialValue(100).setUnits("%").setMinimum(()=>i*100).setMaximum(()=>a*100).setRelatedProperty(()=>this.overclockRatio*100,u=>this.overclockRatio=u/100).subscribeToOverclock().build();let o=(u,_,D)=>{let f=x(u.id);if(f==null)throw Error(`Couldn't find resource descriptor for "${u.id}"`);let C=ie(u.amount,e.manufacturingDuration),b=new ee(this).setIconImage(f.displayName,f.iconPath).setInitialValue(C).setUnits("/min").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>C*this.overclockRatio*this.machinesAmount,g=>this.machinesAmount=g/C/this.overclockRatio).subscribeToMachinesAmount().subscribeToOverclock().build(),k=new ee(this).setIconImage(f.displayName,f.iconPath).setInitialValue(C).setUnits("/min").setMinimum(()=>C*i).setMaximum(()=>C*a).setRelatedProperty(()=>C*this.overclockRatio,g=>this.overclockRatio=g/C).subscribeToOverclock().build();_.push(b),D.push(k)};e.ingredients.forEach(u=>o(u,this._amountConfigurators.inputsConfigurators,this._overclockConfigurators.inputsConfigurators)),e.products.forEach(u=>o(u,this._amountConfigurators.outputsConfigurators,this._overclockConfigurators.outputsConfigurators));let r=(u,_)=>he(u,_,t.powerConsumptionExponent),c=u=>Math.pow(u/t.powerConsumption,1/t.powerConsumptionExponent),p=()=>r(t.powerConsumption,this.overclockRatio);this._amountConfigurators.powerConfigurator=new ee(this).setPowerSvgIcon().setInitialValue(t.powerConsumption).setUnits("MW").setMinimum(()=>1e-4).setMaximum(()=>{}).setRelatedProperty(()=>p()*this.machinesAmount,u=>this.machinesAmount=u/p()).subscribeToMachinesAmount().subscribeToOverclock().build(),this._overclockConfigurators.powerConfigurator=new ee(this).setPowerSvgIcon().setInitialValue(t.powerConsumption).setUnits("MW").setMinimum(()=>r(t.powerConsumption,i)).setMaximum(()=>r(t.powerConsumption,a)).setRelatedProperty(()=>r(t.powerConsumption,this.overclockRatio),u=>this.overclockRatio=c(u)).subscribeToOverclock().build()}updateRestoreButton(){this._isOpened&&(this.machinesAmount!==this._openingMachinesAmount||this.overclockRatio!==this._openingOverclockRatio?n._restoreButton.classList.remove("disabled"):n._restoreButton.classList.add("disabled"))}updateResetButton(){this._isOpened&&(this.machinesAmount!==1||this.overclockRatio!==1?n._resetButton.classList.remove("disabled"):n._resetButton.classList.add("disabled"))}get machinesAmount(){return this._machinesAmount}set machinesAmount(e){e!==this._machinesAmount&&(this._machinesAmount=e,this.dispatchEvent(new Event(n.machinesAmountChangedEvent)))}get overclockRatio(){return this._overclockRatio}set overclockRatio(e){if(e!==this._overclockRatio){let t=n._minOverclockRatio,i=n._maxOverclockRatio;e=Math.min(i,Math.max(t,e)),this._overclockRatio=e,this.dispatchEvent(new Event(n.overclockChangedEvent))}}static queryModalSuccessor(e){let t=`#${n._modalContainer.id} ${e}`,i=document.querySelector(t);if(i==null)throw Error(`Couldn't find required element: ${t}`);return i}static getColumn(e,t){let i=`.table.${e}>.column.${t}`;return n.queryModalSuccessor(i)}_isOpened=!1;_machinesAmount=1;_overclockRatio=1;_openingMachinesAmount=this._machinesAmount;_openingOverclockRatio=this._overclockRatio;_machineConfigurator;_overclockConfigurator;_amountConfigurators=new Te;_overclockConfigurators=new Te;static _minOverclockRatio=.01;static _maxOverclockRatio=2.5;static _modalContainer=document.querySelector("#machine-configuration-container");static _machinesColumn=n.getColumn("amount","machines");static _amountInputsColumn=n.getColumn("amount","inputs");static _amountOutputsColumn=n.getColumn("amount","outputs");static _amountPowerColumn=n.getColumn("amount","power");static _multipliersColumn=n.getColumn("overclock","multipliers");static _overclockInputsColumn=n.getColumn("overclock","inputs");static _overclockOutputsColumn=n.getColumn("overclock","outputs");static _overclockPowerColumn=n.getColumn("overclock","power");static _resetButton=n.queryModalSuccessor(".reset-button");static _restoreButton=n.queryModalSuccessor(".restore-button");static _applyButton=n.queryModalSuccessor(".apply-button")};var Ue=class{constructor(e,t,i){this._recipe=t,this._machine=i,this._displayContainer=M.createSvgForeignObject();let a=this.createHtmlElement("div","recipe-container");this.createMachineDisplay(a,i),this.createOverclockDisplay(a),this.createInputsDisplay(a,t),this.createOutputsDisplay(a,t),this.createPowerDisplay(a,i.powerConsumption),this._displayContainer.appendChild(a),e.addEventListener(q.resourcesAmountChangedEvent,()=>{this.updateDisplays(e)})}setBounds(e){this._displayContainer.setAttribute("x",`${e.x}`),this._displayContainer.setAttribute("y",`${e.y}`),this._displayContainer.setAttribute("width",`${e.width}`),this._displayContainer.setAttribute("height",`${e.height}`)}appendTo(e){e.appendChild(this._displayContainer)}createMachineDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Machines",i.appendChild(a),this._machinesAmountDisplay=this.createAmountDisplay(i,t.displayName,1,t.iconPath),e.appendChild(i)}createInputsDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Input/min",i.appendChild(a),t.ingredients.forEach(o=>{this._inputDisplays.push({htmlElement:this.createResourceDisplay(i,o),initialAmount:o.amount})}),e.appendChild(i)}createOutputsDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Output/min",i.appendChild(a),t.products.forEach(o=>{this._outputDisplays.push({htmlElement:this.createResourceDisplay(i,o),initialAmount:o.amount})}),e.appendChild(i)}createPowerDisplay(e,t){let i=this.createHtmlElement("div","property"),a=this.createHtmlElement("div","title");a.innerText="Power",this._powerDisplay=this.createHtmlElement("div","text"),this._powerDisplay.innerText=`${t} MW`,i.appendChild(a),i.appendChild(this._powerDisplay),e.appendChild(i)}createOverclockDisplay(e){let t=this.createHtmlElement("div","property"),i=this.createHtmlElement("div","title");i.innerText="Overclock",this._overclockDisplay=this.createHtmlElement("div","text"),this._overclockDisplay.innerText="100%",t.appendChild(i),t.appendChild(this._overclockDisplay),e.appendChild(t)}createResourceDisplay(e,t){let i=x(t.id),a=+this.toItemsInMinute(t.amount).toFixed(4);return this.createAmountDisplay(e,i.displayName,a,i.iconPath)}createAmountDisplay(e,t,i,a){let o=document.createElement("div");o.classList.add("resource");let r=this.createHtmlElement("img","icon");r.loading="lazy",r.src=F(a),r.title=t,r.alt=t;let c=this.createHtmlElement("p","amount");return c.classList.add("amount"),c.innerText=`${i}`,o.appendChild(r),o.appendChild(c),e.appendChild(o),c}toItemsInMinute(e){return ie(e,this._recipe.manufacturingDuration)}createHtmlElement(e,...t){let i=document.createElement(e);return i.classList.add(...t),i}updateDisplays(e){let t=a=>+a.toFixed(2);this._machinesAmountDisplay.innerText=`${t(e.machinesAmount)}`,this._overclockDisplay.innerText=`${t(e.overclockRatio*100)}%`;for(let a of this._inputDisplays){let o=a.initialAmount*e.overclockRatio*e.machinesAmount;a.htmlElement.innerText=`${t(this.toItemsInMinute(o))}`}for(let a of this._outputDisplays){let o=a.initialAmount*e.overclockRatio*e.machinesAmount;a.htmlElement.innerText=`${t(this.toItemsInMinute(o))}`}let i=he(this._machine.powerConsumption,e.overclockRatio,this._machine.powerConsumptionExponent);this._powerDisplay.innerText=`${t(i*e.machinesAmount)} MW`}_recipe;_machine;_displayContainer;_machinesAmountDisplay;_overclockDisplay;_inputDisplays=[];_outputDisplays=[];_powerDisplay};var le=class n{static alignPoint(e){let t=(o,r,c)=>Math.round((o-c)/r)*r+c,i=t(e.x,n.smallGridSize,n.smallGridSize/2),a=t(e.y,n.smallGridSize,n.smallGridSize/2);return{x:i,y:a}}constructor(){n._smallGridPattern.setAttribute("width",`${n.smallGridSize}`),n._smallGridPattern.setAttribute("height",`${n.smallGridSize}`),n._bigGridPattern.setAttribute("width",`${n.bigGridSize}`),n._bigGridPattern.setAttribute("height",`${n.bigGridSize}`),n._smallGridCircle.setAttribute("cx",`${n.smallGridSize/2}`),n._smallGridCircle.setAttribute("cy",`${n.smallGridSize/2}`),n._bigGridCircle.setAttribute("cx",`${n.smallGridSize/2}`),n._bigGridCircle.setAttribute("cy",`${n.smallGridSize/2}`),n._bigGridRect.setAttribute("width",`${n.bigGridSize}`),n._bigGridRect.setAttribute("height",`${n.bigGridSize}`),this.updateGridSize(),this.updateGridPosition(),h.instance.addEventListener(h.isGridEnabledChangedEvent,()=>{h.instance.isGridEnabled?this.showGrid():this.hideGrid()})}updateGridSize(){let e=h.instance.zoom,t={width:n._canvas.clientWidth/e+n.bigGridSize*2,height:n._canvas.clientHeight/e+n.bigGridSize*2};n._gridRect.setAttribute("width",`${t.width}`),n._gridRect.setAttribute("height",`${t.height}`),n._smallGridCircle.setAttribute("r",`${1/h.instance.zoom}`),h.instance.zoom<.35?(n._bigGridRect.classList.add("hidden"),n._bigGridCircle.setAttribute("r",`${1/h.instance.zoom}`)):h.instance.zoom>3?(n._bigGridRect.classList.remove("hidden"),n._smallGridCircle.setAttribute("r",`${2/h.instance.zoom}`),n._bigGridCircle.setAttribute("r",`${4/h.instance.zoom}`)):(n._bigGridRect.classList.remove("hidden"),n._bigGridCircle.setAttribute("r",`${2/h.instance.zoom}`))}updateGridPosition(){let e={x:E.context.getTransform().x/h.instance.zoom,y:E.context.getTransform().y/h.instance.zoom};n._gridRect.setAttribute("x",`${-e.x-n.bigGridSize}`),n._gridRect.setAttribute("y",`${-e.y-n.bigGridSize}`)}hideGrid(){n._gridGroup.classList.add("hidden")}showGrid(){n._gridGroup.classList.remove("hidden")}static smallGridSize=20;static bigGridSize=100;static _canvas=document.querySelector("#canvas");static _gridGroup=document.querySelector("#canvas .grid");static _gridRect=document.querySelector("#canvas .grid>rect");static _smallGridPattern=this._gridGroup.querySelector("#small-grid-pattern");static _bigGridPattern=this._gridGroup.querySelector("#big-grid-pattern");static _smallGridCircle=this._gridGroup.querySelector("#small-grid-pattern circle");static _bigGridCircle=this._gridGroup.querySelector("#big-grid-pattern circle");static _bigGridRect=this._gridGroup.querySelector("#big-grid-pattern>rect")};var q=class n extends EventTarget{static resourcesAmountChangedEvent="resources-amount-changed";static changedVacantResourcesAmountEvent="changed-vacant-resources-amount";static deletionEvent="deleted";nodeSvg;nodeSvgGroup;static nodeWidth=80;id;constructor(e,t,i){super(),this.id=n.acquireId(),this._recipe={...t},this._machine={...i},this._height=n._nodeHeight;let a=(o,r)=>o+this.toItemsInMinute(r.amount);this._inputResourcesAmount=this._recipe.ingredients.reduce(a,0),this._outputResourcesAmount=this._recipe.products.reduce(a,0),this.nodeSvgGroup=M.createSvgGroup(new X(0,0),"node","animate-appearance"),this.centerPosition=e,this.nodeSvg=M.createSvgRect({width:n.nodeWidth,height:this.height,x:T.slotWidth,y:0},"machine"),this._inputSlotGroups=this.createGroups("input",t.ingredients),this._outputSlotGroups=this.createGroups("output",t.products),this.configureContextMenu(t,i),this._resourceDisplay=new Ue(this,t,i),this._resourceDisplay.setBounds({x:T.slotWidth,y:0,width:n.nodeWidth,height:this.height}),this.nodeSvgGroup.appendChild(this.nodeSvg),this._resourceDisplay.appendTo(this.nodeSvgGroup),document.querySelector("#viewport>g.nodes").appendChild(this.nodeSvgGroup)}delete(){y.instance.lockSaving();for(let e of this._inputSlotGroups)e.delete();for(let e of this._outputSlotGroups)e.delete();this.nodeSvgGroup.remove(),this.dispatchEvent(new Event(n.deletionEvent)),y.instance.unlockSaving(),y.instance.save()}toSerializable(){let e=[];for(let a of this._outputSlotGroups)e.push(a.toSerializable());let t={...this.position};return h.instance.isGridEnabled&&(t=le.alignPoint(t)),{id:this.id,recipeId:this._recipe.id,machinesAmount:this.machinesAmount,overclockRatio:this.overclockRatio,positionX:t.x,positionY:t.y,outputsGroups:e}}static fromSerializable(e){let t=Ge(e.recipeId),i=new n({x:e.positionX,y:e.positionY},t.recipe,t.machine);return i.position={x:e.positionX,y:e.positionY},i.machinesAmount=e.machinesAmount,i.overclockRatio=e.overclockRatio,i}connectDeserializedSlots(e,t){for(let i of e.outputsGroups)for(let a of i.connectedOutputs){let o=t.get(a.connectedTo);if(o==null)throw Error("Error loading connected slot");let r=this.addOutputSlot(i.resourceId,a.resourcesAmount),c=o.addInputSlot(i.resourceId,a.resourcesAmount);Q.connect(r,c)}}get recipe(){return this._recipe}addInputSlot(e,t){let i=this._inputSlotGroups.find(a=>a.resourceId===e);if(i==null)throw Error(`Error finding group with ${e}`);return i.addSlot(t)}addOutputSlot(e,t){let i=this._outputSlotGroups.find(a=>a.resourceId===e);if(i==null)throw Error(`Error finding group with ${e}`);return i.addSlot(t)}get position(){return this._position}set position(e){this._position={...e},h.instance.isGridEnabled&&(e=le.alignPoint(e)),this.nodeSvgGroup.setAttribute("transform",`translate(${e.x}, ${e.y})`);for(let t of this._inputSlotGroups)t.dispatchEvent(new Event(ue.boundsChangedEvent));for(let t of this._outputSlotGroups)t.dispatchEvent(new Event(ue.boundsChangedEvent))}set centerPosition(e){this.position={x:e.x-n.nodeWidth/2-T.slotWidth,y:e.y-this.height/2}}get height(){return this._height}get missingResources(){let e=[];for(let t of this._inputSlotGroups){let i=t.vacantResourcesAmount;i>0&&e.push({amount:i,id:t.resourceId})}return e}get exceedingResources(){let e=[];for(let t of this._outputSlotGroups){let i=t.vacantResourcesAmount;i>0&&e.push({amount:i,id:t.resourceId})}return e}get powerConsumption(){return he(this._machine.powerConsumption,this.overclockRatio,this._machine.powerConsumptionExponent)*this.machinesAmount}get requiredPowerShards(){return xt(this.overclockRatio)}get inputResourcesAmount(){return this._inputResourcesAmount}set inputResourcesAmount(e){this._inputResourcesAmount=e,this.dispatchEvent(new Event(n.resourcesAmountChangedEvent))}get outputResourcesAmount(){return this._outputResourcesAmount}get inputSlotGroups(){return this._inputSlotGroups}get outputSlotGroups(){return this._outputSlotGroups}set outputResourcesAmount(e){this._outputResourcesAmount=e,this.dispatchEvent(new Event(n.resourcesAmountChangedEvent))}configureContextMenu(e,t){let i=new ye(this.nodeSvg);i.addEventListener(ye.deleteNodeOptionClickedEvent,()=>{this.delete()});let a=new ne(e,t),o=r=>{a.openConfigurationWindow(this.machinesAmount,this.overclockRatio),r.stopPropagation()};i.addEventListener(ye.configureNodeOptionClickedEvent,o),this.nodeSvg.addEventListener("dblclick",o),a.addEventListener(ne.configurationUpdatedEvent,()=>{this.machinesAmount=a.machinesAmount,this.overclockRatio=a.overclockRatio,y.instance.save()})}createGroups(e,t){let i=[],a=0;for(let o of t){let r=new ue(this,e,{id:o.id,amount:this.toItemsInMinute(o.amount)},a);i.push(r),a+=r.height,r.addEventListener(ue.changedVacantResourcesAmountEvent,()=>this.dispatchEvent(new Event(n.changedVacantResourcesAmountEvent)))}return i}toItemsInMinute(e){return ie(e,this._recipe.manufacturingDuration)}multiplyResourcesAmount(e){this.inputResourcesAmount*=e,this.outputResourcesAmount*=e;for(let t of this._inputSlotGroups)t.resourcesAmount*=e;for(let t of this._outputSlotGroups)t.resourcesAmount*=e}get machinesAmount(){return this._machinesAmount}set machinesAmount(e){let t=e/this._machinesAmount;this._machinesAmount=e,this.multiplyResourcesAmount(t)}get overclockRatio(){return this._overclockRatio}set overclockRatio(e){let t=e/this._overclockRatio;this._overclockRatio=e,this.multiplyResourcesAmount(t)}static acquireId(){return n._nextId++}static setNextId(e){n._nextId=e}_recipe;_machine;_inputResourcesAmount;_outputResourcesAmount;_machinesAmount=1;_overclockRatio=1;_height;_position=new X(0,0);_inputSlotGroups=[];_outputSlotGroups=[];_resourceDisplay;static _nextId=0;static _nodeHeight=300};var $=class n extends Y{static createNodeOptionClickedEvent="create-node-option-clicked";static lockCanvasSwitchClickedEvent="lock-canvas-switch-clicked";static toggleGridSwitchClickedEvent="toggle-grid-switch-clicked";static cancelLinkingOptionClickedEvent="cancel-linking-option-clicked";static showHelpOptionClickedEvent="show-help-option-clicked";static clearCanvasOptionClickedEvent="clear-canvas-option-clicked";static nodeFromLinkOptionClickedEvent="node-from-link-option-clicked";constructor(e){super(e,"canvas"),this._lockCanvasSwitch=document.querySelector(`#${this.containerId} #lock-canvas-switch`),this._createNodeOption=document.querySelector(`#${this.containerId} #create-node-option`),this._toggleGridSwitch=document.querySelector(`#${this.containerId} #toggle-grid-switch`),this._cancelLinkingOption=document.querySelector(`#${this.containerId} #cancel-linking-option`),this._showHelpOption=document.querySelector(`#${this.containerId} #show-help-option`),this._clearCanvasOption=document.querySelector(`#${this.containerId} #clear-canvas-option`),this._nodeFromLink=document.querySelector(`#${this.containerId} #node-from-link-option`),this.setupMenuOption(this._createNodeOption,n.createNodeOptionClickedEvent),this.setupMenuOption(this._lockCanvasSwitch,n.lockCanvasSwitchClickedEvent),this.setupMenuOption(this._toggleGridSwitch,n.toggleGridSwitchClickedEvent),this.setupMenuOption(this._cancelLinkingOption,n.cancelLinkingOptionClickedEvent),this.setupMenuOption(this._showHelpOption,n.showHelpOptionClickedEvent),this.setupMenuOption(this._clearCanvasOption,n.clearCanvasOptionClickedEvent),this.setupMenuOption(this._nodeFromLink,n.nodeFromLinkOptionClickedEvent),P.getInstance().addEventListener(P.startedConnectingSlotsEvent,()=>{this._nodeFromLink.classList.remove("hidden")}),P.getInstance().addEventListener(P.finishedConnectingSlotsEvent,()=>{this._nodeFromLink.classList.add("hidden")})}setCanvasLockedSwitchState(e){Y.setSwitchState(this._lockCanvasSwitch,e)}setGridSwitchState(e){Y.setSwitchState(this._toggleGridSwitch,e)}_lockCanvasSwitch;_createNodeOption;_toggleGridSwitch;_cancelLinkingOption;_showHelpOption;_clearCanvasOption;_nodeFromLink};var Ve=class n{constructor(){n._collapseButton.addEventListener("click",()=>{this._isCollapsed?this.open():this.close()}),this.recalculateInputs(),this.recalculateOutputs()}registerNode(e){this._nodes.push(e),this.recalculateInputs(),this.recalculateOutputs(),e.addEventListener(q.changedVacantResourcesAmountEvent,()=>{this.recalculateInputs(),this.recalculateOutputs()}),e.addEventListener(q.deletionEvent,()=>{let t=this._nodes.findIndex(i=>Object.is(e,i));this._nodes.splice(t,1),this.recalculateInputs(),this.recalculateOutputs()})}recalculateInputs(){let e=new Map,t=0,i=0;for(let a of this._nodes){for(let o of a.missingResources)+o.amount.toFixed(3)>0&&e.set(o.id,(e.get(o.id)??0)+o.amount);+a.powerConsumption.toFixed(3)>0&&(t+=a.powerConsumption),i+=a.requiredPowerShards}this.recalculate(n._inputsColumn,e,t,i)}recalculateOutputs(){let e=new Map;for(let t of this._nodes)for(let i of t.exceedingResources)+i.amount.toFixed(3)>0&&e.set(i.id,(e.get(i.id)??0)+i.amount);this.recalculate(n._outputsColumn,e,0,0)}recalculate(e,t,i,a){e.querySelectorAll(".resource").forEach(r=>{r.remove()});let o=!1;i!==0&&(e.appendChild(this.createPowerDisplay(i)),o=!0),a!==0&&(e.appendChild(this.createResourceDisplay("Desc_CrystalShard_C",a,"")),o=!0);for(let[r,c]of t)e.appendChild(this.createResourceDisplay(r,c,"/min")),o=!0;if(!o){let r=document.createElement("div");r.classList.add("resource","none"),r.innerText="None",e.appendChild(r)}this._isCollapsed&&(n.setCollapsingAnimationEnabled(!1),this.hideContent(),n.setCollapsingAnimationEnabled(!0))}open(){n._summaryContainer.classList.remove("collapsed"),n._summaryContainer.style.top="0",this._isCollapsed=!1}close(){n._summaryContainer.classList.add("collapsed"),this.hideContent(),this._isCollapsed=!0}hideContent(){let e=n.querySuccessor(".content").clientHeight;n._summaryContainer.style.top=`${-e}px`}createResourceDisplay(e,t,i){let a=x(e),o=document.createElement("div");o.classList.add("resource");let r=document.createElement("img");r.classList.add("icon"),r.src=F(a.iconPath),r.title=a.displayName,r.alt=a.displayName;let c=document.createElement("div");return c.classList.add("amount"),c.innerText=`${+t.toFixed(3)}${i}`,o.appendChild(r),o.appendChild(c),o}createPowerDisplay(e){let t=document.createElement("div");t.classList.add("resource");let i=G.createIcon("power");i.classList.add("icon");let a=document.createElement("div");return a.classList.add("amount"),a.innerText=`${+e.toFixed(3)} MW`,t.appendChild(i),t.appendChild(a),t}static querySuccessor(e){let t=n._summaryContainer.querySelector(`${e}`);if(t==null)throw Error(`Couldn't find required element: ${e} of summary container`);return t}static setCollapsingAnimationEnabled(e){e?this._summaryContainer.classList.add("animate-collapsing"):this._summaryContainer.classList.remove("animate-collapsing")}_isCollapsed=!1;_nodes=[];static _summaryContainer=document.querySelector("#resources-summary");static _inputsColumn=n.querySuccessor(".column.inputs");static _outputsColumn=n.querySuccessor(".column.outputs");static _collapseButton=n.querySuccessor(".collapse-button")};var $e=class{static parsePlaceholder(e){let t=[],i,a=0,o=r=>{r!=""&&t.push(document.createTextNode(r))};for(let r=0;r{this._isOpened||(e.stopPropagation(),this.openModal())}),n._closeButton.addEventListener("click",e=>{this._isOpened&&(e.stopPropagation(),this.closeModal())}),window.addEventListener("keydown",e=>{e.code==="Escape"&&this._isOpened&&(e.stopPropagation(),e.preventDefault(),this.closeModal())}),n._modalContainer.querySelector(".modal-window").addEventListener("click",e=>{e.stopPropagation()}),n._modalContainer.addEventListener("click",e=>{e.stopPropagation(),this.closeModal()})}openModal(){n._modalContainer.classList.remove("hidden"),n._modalContent.scrollTop=0,this._isOpened=!0}closeModal(){n._modalContainer.classList.add("hidden"),this._isOpened=!1}replaceHelpPlaceholders(){let e=document.querySelectorAll("tr.help-placeholder");for(let t of e)this.replacePlaceholder(t)}replacePlaceholder(e){let t=e.querySelector("td");t.remove(),e.append(...$e.parsePlaceholder(t.innerText)),e.classList.remove("help-placeholder")}_isOpened=!1;static _modalContainer=document.querySelector("#help-modal-container");static _modalContent=this._modalContainer.querySelector(".content");static _closeButton=this._modalContainer.querySelector(".title-row .close");static _openModalButton=document.querySelector("#open-help")};var De=class n extends EventTarget{static recipeConfirmedEvent="recipe-confirmed";static recipeSelectedEvent="recipe-selected";static recipesTabSwitchedEvent="recipes-tab-switched";static modalClosedEvent="modal-closed";constructor(){super(),this._gameVersionText.innerText=`game version: ${ce.gameVersion}`,this._closeButton.addEventListener("click",this.closeModal.bind(this)),this.setupTabs(),this._confirmRecipeButton.addEventListener("click",this.confirmRecipe.bind(this)),this._recipeTabs.addEventListener("click",this.discardSelectedRecipe.bind(this)),this._discardRecipeButton.addEventListener("click",this.discardSelectedRecipe.bind(this)),this.addEventListener(n.recipeSelectedEvent,()=>{this._selectedRecipe==null?this._selectedRecipeDisplay.classList.add("hidden"):this.updateResourceDisplay()}),this.openFirstTab(),this._modalContainer.querySelector(".modal-window").addEventListener("click",e=>{e.stopPropagation()}),this._modalContainer.addEventListener("click",e=>{e.stopPropagation(),this.closeModal()}),window.addEventListener("keydown",e=>{e.code==="Escape"&&this._isOpened&&(e.preventDefault(),e.stopPropagation(),this.closeModal()),e.key==="Enter"&&this._isOpened&&this.selectedRecipe!=null&&(e.preventDefault(),e.stopPropagation(),this.confirmRecipe())}),this.configureSearchField()}openModal(){this._modalContainer.classList.remove("hidden"),this._isOpened=!0}openWithSearch(e,t){this._rememberedSearch={query:this._searchInputField.value,flags:{...this._searchFlags}},this.openModal(),this.openFirstTab(),this._searchFlags=t,this.updateAllFlagElements(),this._searchInputField.value=e,this.searchRecipes(e)}get selectedRecipe(){return this._selectedRecipe}setupTabs(){let e=this.createHtmlElement("div","tab-selector");e.title="All";let t=G.createIcon("three-dots"),i=this.createHtmlElement("div","recipes-tab"),a=this.createRecipesGroup("Basic recipes"),o=this.createRecipesGroup("Alternate recipes"),r=this.createRecipesGroup("Events recipes");e.appendChild(t),this._tabSelectors.appendChild(e),this._recipeTabs.appendChild(i);let c=(p,u)=>{p.div.childElementCount!==0&&(u.append(p.title),u.appendChild(p.div))};for(let p of ce.machines){let u=this.createHtmlElement("div","tab-selector");u.title=p.displayName;let _=this.createHtmlElement("img","machine-icon");_.src=F(p.iconPath),_.alt=p.displayName,_.loading="lazy";let D=this.createHtmlElement("div","recipes-tab"),f=this.createRecipesGroup("Basic recipes"),C=this.createRecipesGroup("Alternate recipes"),b=this.createRecipesGroup("Events recipes");p.recipes.forEach(k=>{this.appendRecipes(f.div,b.div,k,p),this.appendRecipes(a.div,r.div,k,p)}),p.alternateRecipes.forEach(k=>{this.appendRecipes(C.div,b.div,k,p),this.appendRecipes(o.div,r.div,k,p)}),c(f,D),c(C,D),c(b,D),u.addEventListener("click",()=>{this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),D.classList.add("active"),u.classList.add("active")}),this.addEventListener(n.recipesTabSwitchedEvent,()=>{D.classList.remove("active"),u.classList.remove("active"),this.discardSelectedRecipe()}),u.appendChild(_),this._tabSelectors.appendChild(u),this._recipeTabs.appendChild(D)}c(a,i),c(o,i),c(r,i),e.addEventListener("click",()=>{this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),i.classList.add("active"),e.classList.add("active")}),this.addEventListener(n.recipesTabSwitchedEvent,()=>{i.classList.remove("active"),e.classList.remove("active"),this.discardSelectedRecipe()})}openFirstTab(){this.dispatchEvent(new Event(n.recipesTabSwitchedEvent)),this._tabSelectors.children[0].classList.add("active"),this._recipeTabs.children[0].classList.add("active")}createRecipesGroup(e){let t=this.createHtmlElement("h3","group-title");return t.innerText=e,{div:this.createHtmlElement("div","group"),title:t}}appendRecipes(e,t,i,a){let o=document.createElement("div");o.classList.add("recipe"),o.title=i.displayName,o.dataset.recipeId=i.id;let r=!1;for(let c of i.products){let p=this.createHtmlElement("div","progress-bar"),u=document.createElement("img");u.classList.add("item-icon");let _=x(c.id);u.src=F(_.iconPath),r||(r=_.iconPath.startsWith("Events")),u.alt=i.displayName,u.loading="lazy",o.appendChild(p),o.appendChild(u)}o.addEventListener("click",c=>{c.stopPropagation(),this._selectedRecipe?.recipe===i?this.discardSelectedRecipeDelayed(o):this.selectRecipeDelayed(i,a,o)}),o.addEventListener("dblclick",c=>{c.stopPropagation(),this.selectRecipe(i,a,o),this.confirmRecipe()}),this.addEventListener(n.recipeSelectedEvent,()=>{o.classList.remove("selected")}),r?t.appendChild(o):e.appendChild(o)}createResourceDisplay(e,t,i){let a=x(i.id),o=this.createHtmlElement("div","resource"),r=this.createHtmlElement("img","icon");r.src=F(a.iconPath),r.title=a.displayName,r.alt=a.displayName,r.loading="lazy";let c=this.createHtmlElement("p","amount");c.innerText=`${+ie(i.amount,t).toFixed(3)}`,o.appendChild(r),o.appendChild(c),e.appendChild(o)}updateResourceDisplay(){if(this._selectedRecipe==null)throw Error("Recipe isn't selected.");this._selectedRecipeName.innerText=this._selectedRecipe.recipe.displayName,this._selectedRecipeMachine.src=F(this._selectedRecipe.madeIn.iconPath),this._selectedRecipeMachine.title=this._selectedRecipe.madeIn.displayName,this.updateResources(this._selectedRecipeInput,this._selectedRecipe.recipe.ingredients),this.updateResources(this._selectedRecipeOutput,this._selectedRecipe.recipe.products),this._selectedRecipePower.innerText=`${this._selectedRecipe.madeIn.powerConsumption} MW`,this._selectedRecipeDisplay.classList.remove("hidden"),this._selectedRecipeDisplay.scrollTop=this._selectedRecipeDisplay.scrollHeight}updateResources(e,t){e.querySelectorAll(".resource").forEach(i=>i.remove()),t.forEach(i=>this.createResourceDisplay(e,this._selectedRecipe.recipe.manufacturingDuration,i))}selectRecipe(e,t,i){this.stopProgressBar!=null&&this.stopProgressBar(),i.classList.remove("animate-progress"),this._selectedRecipe={recipe:e,madeIn:t},this.dispatchEvent(new Event(n.recipeSelectedEvent)),i.classList.add("selected")}selectRecipeDelayed(e,t,i){this.stopProgressBar!=null&&this.stopProgressBar(),i.classList.add("animate-progress");let a=setTimeout(()=>{this._selectedRecipe={recipe:e,madeIn:t},this.dispatchEvent(new Event(n.recipeSelectedEvent)),i.classList.add("selected"),i.classList.remove("animate-progress"),this.stopProgressBar=void 0},200);this.stopProgressBar=()=>{clearTimeout(a),i.classList.remove("animate-progress"),this.stopProgressBar=void 0}}discardSelectedRecipe(){this.stopProgressBar!=null&&this.stopProgressBar(),this._selectedRecipe=void 0,this.dispatchEvent(new Event(n.recipeSelectedEvent))}discardSelectedRecipeDelayed(e){this.stopProgressBar!=null&&this.stopProgressBar(),e.classList.add("animate-progress");let t=setTimeout(()=>{this._selectedRecipe=void 0,this.dispatchEvent(new Event(n.recipeSelectedEvent)),e.classList.remove("animate-progress"),this.stopProgressBar=void 0},200);this.stopProgressBar=()=>{clearTimeout(t),e.classList.remove("animate-progress"),this.stopProgressBar=void 0}}updateFlagElement(e,t){this._searchFlags[e]?t.classList.add("checked"):t.classList.remove("checked"),this.searchRecipes(this._searchInputField.value)}updateAllFlagElements(){this.updateFlagElement("recipeNames",this._searchRecipeNamesFlag),this.updateFlagElement("ingredients",this._searchIngredientsFlag),this.updateFlagElement("products",this._searchProductsFlag),this.updateFlagElement("exactMatch",this._exactMatchProductsFlag)}configureSearchField(){this._searchInputField.value="",this.updateAllFlagElements(),this._searchRecipeNamesFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.recipeNames=!this._searchFlags.recipeNames,this.updateFlagElement("recipeNames",this._searchRecipeNamesFlag)}),this._searchIngredientsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.ingredients=!this._searchFlags.ingredients,this.updateFlagElement("ingredients",this._searchIngredientsFlag)}),this._searchProductsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.products=!this._searchFlags.products,this.updateFlagElement("products",this._searchProductsFlag)}),this._exactMatchProductsFlag.addEventListener("click",e=>{e.stopPropagation(),this._searchFlags.exactMatch=!this._searchFlags.exactMatch,this.updateFlagElement("exactMatch",this._exactMatchProductsFlag)}),this._searchInputField.addEventListener("input",()=>{this.searchRecipes(this._searchInputField.value)}),this._searchInputField.addEventListener("keydown",e=>{e.stopPropagation()}),this._clearSearchButton.addEventListener("click",()=>{this._searchInputField.value="",this.searchRecipes(this._searchInputField.value)})}searchRecipes(e){let t=this._recipeTabs.querySelectorAll(".recipe");for(let i of t){if(e===""){i.classList.remove("filtered-out");continue}let a=Ge(i.dataset.recipeId),o=r=>{this._searchFlags.exactMatch&&r.toLowerCase()===e.toLowerCase()&&i.classList.remove("filtered-out"),!this._searchFlags.exactMatch&&r.toLowerCase().includes(e.toLowerCase())&&i.classList.remove("filtered-out")};if(i.classList.add("filtered-out"),this._searchFlags.recipeNames&&o(a.recipe.displayName),this._searchFlags.ingredients)for(let r of a.recipe.ingredients){let c=x(r.id);o(c.displayName)}if(this._searchFlags.products)for(let r of a.recipe.products){let c=x(r.id);o(c.displayName)}}}confirmRecipe(){this._selectedRecipe!=null&&(this.dispatchEvent(new Event(n.recipeConfirmedEvent)),this.closeModal())}closeModal(){this._modalContainer.classList.add("hidden"),this._isOpened=!1,this._rememberedSearch!=null&&(this._searchFlags={...this._rememberedSearch.flags},this.updateAllFlagElements(),this._searchInputField.value=this._rememberedSearch.query,this.searchRecipes(this._rememberedSearch.query),this._rememberedSearch=void 0),this.dispatchEvent(new Event(n.modalClosedEvent))}createHtmlElement(e,...t){let i=document.createElement(e);return i.classList.add(...t),i}_isOpened=!1;_selectedRecipe;_modalContainer=document.querySelector("#node-creation-container");_closeButton=this._modalContainer.querySelector(".title-row .close");_gameVersionText=this._modalContainer.querySelector("h2.title span.game-version");_tabSelectors=this._modalContainer.querySelector("#tab-selectors");_recipeTabs=this._modalContainer.querySelector("#recipe-tabs");_selectedRecipeDisplay=this._modalContainer.querySelector("#selected-recipe");_selectedRecipeName=this._selectedRecipeDisplay.querySelector("#selected-recipe-name>.text");_selectedRecipeMachine=this._selectedRecipeDisplay.querySelector("#selected-recipe-machine>.machine>img.icon");_selectedRecipeInput=this._selectedRecipeDisplay.querySelector("#selected-recipe-input");_selectedRecipeOutput=this._selectedRecipeDisplay.querySelector("#selected-recipe-output");_selectedRecipePower=this._selectedRecipeDisplay.querySelector("#selected-recipe-power>.text");_confirmRecipeButton=this._modalContainer.querySelector("#confirm-recipe");_discardRecipeButton=this._modalContainer.querySelector("#discard-recipe");stopProgressBar;_searchInputField=this._modalContainer.querySelector(".search-field input");_clearSearchButton=this._modalContainer.querySelector(".search-field .clear-button");_searchRecipeNamesFlag=this._modalContainer.querySelector(".search-container #recipe-names-flag");_searchIngredientsFlag=this._modalContainer.querySelector(".search-container #ingredients-flag");_searchProductsFlag=this._modalContainer.querySelector(".search-container #products-flag");_exactMatchProductsFlag=this._modalContainer.querySelector(".search-container #exact-match-flag");_searchFlags={recipeNames:!0,ingredients:!0,products:!0,exactMatch:!1};_rememberedSearch};var Xe=class{constructor(){this.configurePlanCreationInput(),this.configureLoadedPlanElement(),this.updatePlanSelectors(),this._loadedPlanElement.addEventListener("click",t=>{t.stopPropagation(),this._isOpened?this.close():this.open()}),this._nonePlanSelector.addEventListener("click",t=>{t.stopPropagation(),y.instance.loadDatabasePlan(""),this.close()});let e=()=>{y.instance.currentPlanName===""?this._nonePlanSelector.classList.add("selected"):this._nonePlanSelector.classList.remove("selected")};e(),y.instance.addEventListener(y.databasePlanSelectionChangedEvent,()=>{e()}),this._savesLoaderElement.addEventListener("click",t=>t.stopPropagation()),window.addEventListener("click",()=>this.close()),window.addEventListener("keydown",t=>{t.key==="Escape"&&this._isOpened&&(t.stopPropagation(),t.preventDefault(),this.close())})}open(){this._isOpened||(this._savesLoaderElement.classList.remove("collapsed"),this._savesLoaderElement.classList.add("expanded"),this._isOpened=!0)}close(){this._isOpened&&(this._savesLoaderElement.classList.remove("expanded"),this._savesLoaderElement.classList.add("collapsed"),this._isOpened=!1)}updatePlanSelectors(){let e=this._planSelectors.querySelectorAll(".plan-selector");for(let t of e)t.id!=="none-plan-selector"&&t.remove();for(let t of y.instance.databasePlanNames)t!==""&&this._planSelectors.appendChild(this.createPlanSelector(t))}configurePlanCreationInput(){this._savesLoaderElement.querySelector(".create-new .clear-button").addEventListener("click",()=>{this._planCreationInput.value=""}),this._planCreationInput.value="";let t=()=>{let i=this._planCreationInput.value;y.instance.createAndSelectDatabasePlan(i),this._planSelectors.appendChild(this.createPlanSelector(i)),this._planCreationInput.value="",this.close()};this._planCreationButton.addEventListener("click",()=>{t()}),this._planCreationInput.addEventListener("keydown",i=>{i.stopPropagation(),i.key==="Enter"&&t(),i.key==="Escape"&&this._isOpened&&(i.stopPropagation(),i.preventDefault(),this.close())}),this._planCreationInput.addEventListener("keypress",i=>i.stopPropagation())}configureLoadedPlanElement(){let e=this._loadedPlanElement.querySelector(".plan-name"),t=()=>{let i=y.instance.currentPlanName;i===""?(e.innerText="Load plan",e.classList.add("placeholder")):(e.innerText=i,e.classList.remove("placeholder"))};t(),y.instance.addEventListener(y.databasePlanSelectionChangedEvent,()=>{t()})}createPlanSelector(e){let t=(c,...p)=>{let u=document.createElement(c);return u.classList.add(...p),u},i=t("div","plan-selector"),a=t("div","plan-name"),o=t("div","delete-button");a.innerText=e,o.appendChild(G.createIcon("delete")),i.appendChild(a),i.appendChild(o),a.addEventListener("click",c=>{c.stopPropagation(),y.instance.loadDatabasePlan(e),this.close()}),o.addEventListener("click",c=>{c.stopPropagation(),confirm(`Are you sure that you want to delete this factory plan? +This will delete all nodes and connections from it. +All data of the plan will be lost.`)&&(y.instance.deleteDatabasePlan(e),i.remove(),this.close())});let r=()=>{e===y.instance.currentPlanName?i.classList.add("selected"):i.classList.remove("selected")};return r(),y.instance.addEventListener(y.databasePlanSelectionChangedEvent,()=>{r()}),i}_isOpened=!1;_savesLoaderElement=document.querySelector("#saves-loader");_loadedPlanElement=this._savesLoaderElement.querySelector(".loaded-plan");_nonePlanSelector=this._savesLoaderElement.querySelector("#none-plan-selector");_planSelectors=this._savesLoaderElement.querySelector(".plan-selectors");_planCreationInput=this._savesLoaderElement.querySelector(".create-new input");_planCreationButton=this._savesLoaderElement.querySelector(".create-new .create-button")};async function qn(){G.replaceAllPlaceholders();let n=document.querySelector("p#ratio-display"),e=document.querySelector("#canvas"),t=new je;E.setPanningButtons(["Space"],["Meta"]),E.setZoomingButtons([],["Control"]),E.configurePanContext(e);let i=new le;n.textContent=`Zoom: ${h.instance.zoom.toFixed(2)}x`,h.instance.addEventListener(h.zoomChangedEvent,()=>{n.textContent=`Zoom: ${h.instance.zoom.toFixed(2)}x`,i.updateGridSize(),i.updateGridPosition()}),E.context.on("pan",()=>{i.updateGridPosition()});let a=new Ve,o=new De,r,c=g=>{g.nodeSvg.onmousedown=v=>{v.buttons===1&&!E.isPanning&&!E.isZooming&&P.getInstance().startDraggingNode(g,{x:v.clientX,y:v.clientY})},g.nodeSvg.addEventListener("touchstart",v=>{if(v.touches.length===1&&h.instance.isCanvasLocked){let R=v.touches[0];P.getInstance().startDraggingNode(g,{x:R.clientX,y:R.clientY})}}),a.registerNode(g)},p;function u(g,v){let R=new q(r,g,v);return c(R),y.instance.addNode(R),p!=null&&(p(R),p=void 0),R}o.addEventListener(De.recipeConfirmedEvent,()=>{let g=o.selectedRecipe;u(g.recipe,g.madeIn)}),o.addEventListener(De.modalClosedEvent,()=>{p=void 0});function _(g){let v={x:document.documentElement.clientWidth/2,y:document.documentElement.clientHeight/2};r=g??P.clientToCanvasPosition(v),o.openModal()}document.querySelector("div.button#create-node").onclick=()=>{_()},document.querySelector("div.button#cancel-linking").onclick=()=>{P.getInstance().cancelConnectingSlots()};let D=()=>{confirm(`Are you sure that you want to clear canvas? This will delete all nodes and connections. -Save the page link if you don't want to lose the data.`)&&(R.lockSaving(),R.deleteAllNodes(),R.unlockSaving(),R.saveToUrl())};document.querySelector("div.button#clear-canvas").onclick=()=>{y()};let v=document.querySelector("div.button#lock-viewport");v.onclick=()=>{g.instance.isCanvasLocked=!g.instance.isCanvasLocked},g.instance.addEventListener(g.isCanvasLockedChangedEvent,()=>{g.instance.isCanvasLocked?(v.classList.add("on"),v.classList.remove("off")):(v.classList.remove("on"),v.classList.add("off"))});let C=document.querySelector("#container div.controls #grid-toggle");C.onclick=()=>{g.instance.isGridEnabled=!g.instance.isGridEnabled},g.instance.addEventListener(g.isGridEnabledChangedEvent,()=>{g.instance.isGridEnabled?(C.classList.add("on"),C.classList.remove("off")):(C.classList.remove("on"),C.classList.add("off"))}),R.onDataLoad=()=>{for(let _ of R.nodes)c(_)},window.addEventListener("keydown",_=>{_.repeat||_.key==="Escape"&&(_.preventDefault(),P.getInstance().cancelConnectingSlots())}),e.addEventListener("dblclick",_=>{let D={x:_.clientX,y:_.clientY};h(P.clientToCanvasPosition(D))});let b=new U(e);b.addEventListener(U.createNodeOptionClickedEvent,()=>{let _=b.openingPosition;_!=null&&(_=P.clientToCanvasPosition(_)),h(_)}),b.addEventListener(U.cancelLinkingOptionClickedEvent,()=>{P.getInstance().cancelConnectingSlots()}),b.addEventListener(U.showHelpOptionClickedEvent,()=>{t.openModal()}),b.addEventListener(U.lockCanvasSwitchClickedEvent,()=>{g.instance.isCanvasLocked=!g.instance.isCanvasLocked}),g.instance.addEventListener(g.isCanvasLockedChangedEvent,()=>{b.setCanvasLockedSwitchState(g.instance.isCanvasLocked)}),b.addEventListener(U.toggleGridSwitchClickedEvent,()=>{g.instance.isGridEnabled=!g.instance.isGridEnabled}),g.instance.addEventListener(g.isGridEnabledChangedEvent,()=>{b.setGridSwitchState(g.instance.isGridEnabled)}),b.addEventListener(U.clearCanvasOptionClickedEvent,()=>{y()}),b.addEventListener(U.nodeFromLinkOptionClickedEvent,()=>{let _=P.getInstance().firstConnectingSlot;if(_==null)return;let D=b.openingPosition;if(D==null)throw Error("Context menu position undefined");D=P.clientToCanvasPosition(D);let f;if(P.getInstance().mouseStatus===P.MouseStatus.ConnectingInputSlot)f="output";else if(P.getInstance().mouseStatus===P.MouseStatus.ConnectingOutputSlot)f="input";else return;o=D;let G=Lt({id:_.resourceId,type:f});p=H=>{let V=_.resourcesAmount,K;if(f==="input"?K=H.inputSlotGroups.find(x=>x.resourceId===_.resourceId):K=H.outputSlotGroups.find(x=>x.resourceId===_.resourceId),K==null)return;let $=V/K.resourcesAmount;H.machinesAmount=$;let q=_.splitOffSlot(V);if(f==="input"){let x=H.addInputSlot(_.resourceId,V);Q.connect(q,x)}else{let x=H.addOutputSlot(_.resourceId,V);Q.connect(q,x)}},G!=null?u(G.recipe,G.machine):r.openWithSearch(M(_.resourceId).displayName,{ingredients:f==="input",products:f==="output",recipeNames:!1,exactMatch:!0}),P.getInstance().cancelConnectingSlots()}),window.addEventListener("keypress",_=>{let D=!1;document.querySelectorAll(".modal-window-container").forEach(f=>{f.classList.contains("hidden")||(D=!0)}),document.querySelectorAll(".context-menu-container").forEach(f=>{f.classList.contains("hidden")||(D=!0)}),_.code==="KeyN"&&!D&&h(),_.code==="KeyL"&&(g.instance.isCanvasLocked=!g.instance.isCanvasLocked)}),window.onmouseup=()=>{P.getInstance().handleMouseUp()},window.addEventListener("touchend",()=>{P.getInstance().handleMouseUp()}),window.onmousemove=_=>{P.getInstance().handleMouseMove(_)},window.addEventListener("touchmove",_=>{P.getInstance().handleTouchMove(_)}),R.loadFromUrl()}In().catch(n=>{console.error(n)});})(); +Save the page link if you don't want to lose the data.`)&&(y.instance.deleteAllNodes(),y.instance.save())};document.querySelector("div.button#clear-canvas").onclick=()=>{D()};let f=document.querySelector("div.button#lock-viewport");f.onclick=()=>{h.instance.isCanvasLocked=!h.instance.isCanvasLocked},h.instance.addEventListener(h.isCanvasLockedChangedEvent,()=>{h.instance.isCanvasLocked?(f.classList.add("on"),f.classList.remove("off")):(f.classList.remove("on"),f.classList.add("off"))});let C=document.querySelector("#container div.controls #grid-toggle");C.onclick=()=>{h.instance.isGridEnabled=!h.instance.isGridEnabled},h.instance.addEventListener(h.isGridEnabledChangedEvent,()=>{h.instance.isGridEnabled?(C.classList.add("on"),C.classList.remove("off")):(C.classList.remove("on"),C.classList.add("off"))}),window.addEventListener("keydown",g=>{g.repeat||g.key==="Escape"&&(g.preventDefault(),P.getInstance().cancelConnectingSlots())}),e.addEventListener("dblclick",g=>{let v={x:g.clientX,y:g.clientY};_(P.clientToCanvasPosition(v))});let b=new $(e);b.addEventListener($.createNodeOptionClickedEvent,()=>{let g=b.openingPosition;g!=null&&(g=P.clientToCanvasPosition(g)),_(g)}),b.addEventListener($.cancelLinkingOptionClickedEvent,()=>{P.getInstance().cancelConnectingSlots()}),b.addEventListener($.showHelpOptionClickedEvent,()=>{t.openModal()}),b.addEventListener($.lockCanvasSwitchClickedEvent,()=>{h.instance.isCanvasLocked=!h.instance.isCanvasLocked}),h.instance.addEventListener(h.isCanvasLockedChangedEvent,()=>{b.setCanvasLockedSwitchState(h.instance.isCanvasLocked)}),b.addEventListener($.toggleGridSwitchClickedEvent,()=>{h.instance.isGridEnabled=!h.instance.isGridEnabled}),h.instance.addEventListener(h.isGridEnabledChangedEvent,()=>{b.setGridSwitchState(h.instance.isGridEnabled)}),b.addEventListener($.clearCanvasOptionClickedEvent,()=>{D()}),b.addEventListener($.nodeFromLinkOptionClickedEvent,()=>{let g=P.getInstance().firstConnectingSlot;if(g==null)return;let v=b.openingPosition;if(v==null)throw Error("Context menu position undefined");v=P.clientToCanvasPosition(v);let R;if(P.getInstance().mouseStatus===P.MouseStatus.ConnectingInputSlot)R="output";else if(P.getInstance().mouseStatus===P.MouseStatus.ConnectingOutputSlot)R="input";else return;r=v;let z=It({id:g.resourceId,type:R});p=W=>{let K=g.resourcesAmount,H;if(R==="input"?H=W.inputSlotGroups.find(N=>N.resourceId===g.resourceId):H=W.outputSlotGroups.find(N=>N.resourceId===g.resourceId),H==null)return;let O=K/H.resourcesAmount;W.machinesAmount=O;let U=g.splitOffSlot(K);if(R==="input"){let N=W.addInputSlot(g.resourceId,K);Q.connect(U,N)}else{let N=W.addOutputSlot(g.resourceId,K);Q.connect(U,N)}},z!=null?u(z.recipe,z.machine):o.openWithSearch(x(g.resourceId).displayName,{ingredients:R==="input",products:R==="output",recipeNames:!1,exactMatch:!0}),P.getInstance().cancelConnectingSlots()}),window.addEventListener("keypress",g=>{let v=!1;document.querySelectorAll(".modal-window-container").forEach(R=>{R.classList.contains("hidden")||(v=!0)}),document.querySelectorAll(".context-menu-container").forEach(R=>{R.classList.contains("hidden")||(v=!0)}),g.code==="KeyN"&&!v&&_(),g.code==="KeyL"&&(h.instance.isCanvasLocked=!h.instance.isCanvasLocked)}),window.addEventListener("mouseup",()=>P.getInstance().handleMouseUp()),window.addEventListener("touchend",()=>P.getInstance().handleMouseUp()),window.addEventListener("mousemove",g=>P.getInstance().handleMouseMove(g)),window.addEventListener("touchmove",g=>P.getInstance().handleTouchMove(g)),y.instance.addEventListener(y.dataLoadedEvent,()=>{for(let g of y.instance.nodes)c(g)}),y.instance.loadFromUrl();let k=new Xe}qn().catch(n=>{console.error(n)});})(); diff --git a/style.css b/style.css index ead6652..3619864 100644 --- a/style.css +++ b/style.css @@ -166,7 +166,8 @@ svg#canvas, #node-creation-modal div.content, div.context-menu, #machine-configuration-container, -#node-creation-modal .search-container div.flags { +#node-creation-modal .search-container div.flags, +#saves-loader { user-select: none; -moz-user-select: none; -webkit-user-select: none; @@ -484,6 +485,22 @@ g.links .resource-display img.icon { padding-right: 8px; } +@media (pointer: fine) { + #container #mobile-controls-hint { + display: none; + } +} + +#container>.controls .mobile-hint { + margin: 0; + + font-size: 12px; + + padding: 2px 8px; + + max-width: min(300px, 100%); +} + /* Modal windows */ div.modal-window { @@ -1385,7 +1402,9 @@ div#resources-summary div.content { #resources-summary div.collapse-button { display: flex; - gap: 4px; + height: 36px; + + gap: 8px; padding-right: 36px; @@ -1393,8 +1412,9 @@ div#resources-summary div.content { } #resources-summary .collapse-button svg { - width: 36px; - height: 36px; + width: 20px; + height: 20px; + fill: var(--foreground); } @@ -1566,3 +1586,217 @@ div#resources-summary div.content { #canvas .grid pattern circle { fill: var(--grid); } + +/* Saves loader */ + +#saves-loader { + display: flex; + flex-direction: column; + + position: absolute; + top: 16px; + right: 16px; + + width: 300px; + max-height: calc(100% - 32px); + max-width: calc(100% - 32px); +} + +@media screen and (max-width: 700px) { + #saves-loader { + /* If screen is too narrow, the loader should appear under resources summary */ + top: 56px; + } +} + +#saves-loader div.loaded-plan { + display: flex; + align-items: center; + + box-sizing: border-box; + + max-width: 100%; + height: 48px; + + padding-left: 16px; + border-radius: 8px; + + background-color: var(--background-lv1); + + cursor: pointer; +} + +#saves-loader.collapsed .loaded-plan svg { + scale: 1 -1; +} + +#saves-loader .loaded-plan svg { + height: 20px; + fill: white; +} + +#saves-loader div.loaded-plan:hover, +#saves-loader .plan-selector div.plan-name:hover, +#saves-loader .plan-selector div.delete-button:hover, +#saves-loader .plan-selector.selected div.plan-name { + background-color: var(--background-lv2); +} + +#saves-loader.expanded div.loaded-plan { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +#saves-loader .loaded-plan div.plan-name { + flex-grow: 1; +} + +#saves-loader .loaded-plan div.plan-name.placeholder { + color: var(--dim-foreground); +} + +#saves-loader .loaded-plan div.icon-container, +#saves-loader .plan-selector div.delete-button { + display: flex; + align-items: center; + justify-content: center; + + min-width: 48px; + min-height: 48px; +} + +#saves-loader div.collapsible-container { + display: flex; + flex-direction: column; + + min-height: 0; +} + +#saves-loader.collapsed div.collapsible-container { + display: none; +} + +#saves-loader .collapsible-container svg { + height: 22px; + fill: white; +} + +#saves-loader div.plan-selectors { + overflow-y: auto; +} + +#saves-loader div.plan-selector { + display: flex; + align-items: stretch; + + height: 48px; + + background-color: var(--background-lv1); +} + +#saves-loader .plan-selector div.plan-name { + display: flex; + align-items: center; + + flex-grow: 1; + + padding-left: 16px; + + cursor: pointer; +} + +#saves-loader .plan-selector div.delete-button { + cursor: pointer; +} + +#saves-loader div.create-new { + display: flex; + align-items: stretch; + + height: 48px; + + border-radius: 0 0 8px 8px; +} + +#saves-loader .create-new input { + flex-grow: 1; + + box-sizing: border-box; + + border: 2px solid var(--border); + border-right: none; + outline: none; + + border-bottom-left-radius: 8px; + padding-left: 16px; + + font-size: 16px; + + background-color: var(--background-lv0); +} + +#saves-loader .create-new div.create-button { + display: flex; + align-items: center; + justify-content: center; + + border-bottom-right-radius: 8px; + + border: 2px solid var(--button-border); + + min-width: 44px; + min-height: 44px; + + background-color: var(--button-background); + + cursor: pointer; +} + +#saves-loader .create-new div.create-button:hover { + background-color: var(--active-button-background); + border-color: var(--active-button-border); +} + +#saves-loader .create-new input:placeholder-shown~div.create-button { + background-color: var(--disabled-button-background); + border-color: var(--border); + + cursor: default; +} + +#saves-loader .create-new input:placeholder-shown~div.create-button svg { + fill: var(--disabled-button-foreground); +} + +#saves-loader .create-new div.clear-button { + display: flex; + align-items: center; + justify-content: center; + + min-width: 48px; + + fill: var(--foreground); + + border-top: 2px solid var(--border); + border-bottom: 2px solid var(--border); + + background-color: var(--background-lv0); + + cursor: pointer; +} + +#saves-loader .create-new div.clear-button:hover { + background-color: var(--background-lv1); +} + +#saves-loader .create-new div.clear-button svg { + height: 20px; +} + +#saves-loader .create-new input:placeholder-shown~div.clear-button { + display: none; +} + +#saves-loader .create-new input { + min-width: 0; +}