From e43d128a2f9f848b26ac82a0be5be17354d1d682 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 29 Apr 2020 13:07:22 +0800 Subject: [PATCH] - Docs: Mention lack of relative repo maintenance in issue template - Linting (ESLint): As per latest ash-nazg - npm: Update devDeps. --- .github/ISSUE_TEMPLATE/bug_report.md | 1 + dist/index-es.js | 21 +- dist/index-es.min.js | 6 +- dist/index-es.min.js.map | 2 +- dist/index-umd.js | 21 +- dist/index-umd.min.js | 6 +- dist/index-umd.min.js.map | 2 +- dist/svgcanvas-iife.js | 9 +- dist/svgcanvas-iife.min.js | 2 +- dist/svgcanvas-iife.min.js.map | 2 +- editor/contextmenu/jQuery.contextMenu.js | 2 + editor/draw.js | 1 + editor/history.js | 4 +- editor/jgraduate/jQuery.jPicker.js | 1 + editor/layer.js | 3 +- editor/svg-editor.js | 2 + editor/utilities.js | 1 + editor/xdomain-svgedit-config-iife.js | 21 +- package-lock.json | 5794 +--------------------- package.json | 26 +- svgedit-config-iife.js | 21 +- 21 files changed, 269 insertions(+), 5679 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7dd770c3..49cd8337 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,6 +3,7 @@ name: Bug report about: Create a report in case we may be able to help --- +**PLEASE NOTE: This project is not currently being actively developed due to the core developers having moved on, and the only remaining maintainer merely applying occasional minor PRs or tweaks to keep the project alive. While you can file an issue, you should not expect any action, even if we label the issue.** **Describe the bug** A clear and concise description of what the bug is. diff --git a/dist/index-es.js b/dist/index-es.js index 6efa76e1..88bf681b 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -4113,7 +4113,7 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) { } this.parent = this.elem.parentNode; - this.elem = this.elem.parentNode.removeChild(this.elem); + this.elem = this.elem.remove(); if (handler) { handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this); @@ -4190,7 +4190,7 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) { removeElementFromListMap(this.elem); this.parent = this.elem.parentNode; - this.elem = this.parent.removeChild(this.elem); + this.elem = this.elem.remove(); if (handler) { handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this); @@ -9252,6 +9252,7 @@ var getElem = supportsSelectors() ? function (id) { }, 9, null).singleNodeValue; } : function (id) { // jQuery lookup: twice as slow as xpath in FF + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator return $$2(svgroot_).find('[id=' + id + ']')[0]; }; /** @@ -10245,8 +10246,7 @@ var Layer = /*#__PURE__*/function () { }, { key: "removeGroup", value: function removeGroup() { - var parent = this.group_.parentNode; - var group = parent.removeChild(this.group_); + var group = this.group_.remove(); this.group_ = undefined; return group; } @@ -10619,6 +10619,7 @@ var Drawing = /*#__PURE__*/function () { // querySelector lookup return this.svgElem_.querySelector('#' + id); } // jQuery lookup: twice as slow as xpath in FF + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator return $$5(this.svgElem_).find('[id=' + id + ']')[0]; @@ -24643,6 +24644,7 @@ function jQueryContextMenu($) { try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var href = _step.value; + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator $(this).find('A[href="' + href + '"]').parent().addClass('disabled'); } } catch (err) { @@ -24678,6 +24680,7 @@ function jQueryContextMenu($) { try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var href = _step2.value; + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator $(this).find('A[href="' + href + '"]').parent().removeClass('disabled'); } } catch (err) { @@ -27051,6 +27054,7 @@ var jPicker = function jPicker($) { function radioClicked(e) { + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator $(this).parents('tbody:first').find('input:radio[value!="' + e.target.value + '"]').removeAttr('checked'); setColorMode.call(that, e.target.value); } @@ -34527,7 +34531,7 @@ editor.init = function () { { this._paintOpacity = Number.parseFloat(selectedElement.getAttribute(type + '-opacity')); - if (isNaN(this._paintOpacity)) { + if (Number.isNaN(this._paintOpacity)) { this._paintOpacity = 1.0; } @@ -35670,8 +35674,11 @@ editor.init = function () { var tool; var itool = curConfig.initTool, container = $$b('#tools_left, #svg_editor .tools_flyout'), - preTool = container.find('#tool_' + itool), + + /* eslint-disable unicorn/no-fn-reference-in-iterator */ + preTool = container.find('#tool_' + itool), regTool = container.find('#' + itool); + /* eslint-enable unicorn/no-fn-reference-in-iterator */ if (preTool.length) { tool = preTool; @@ -36336,7 +36343,7 @@ editor.ready = function (cb) { return new Promise(function (resolve, reject) { // eslint-disable-line promise/avoid-new if (isReady) { - resolve(cb()); // eslint-disable-line callback-return, promise/prefer-await-to-callbacks + resolve(cb()); // eslint-disable-line node/callback-return, promise/prefer-await-to-callbacks return; } diff --git a/dist/index-es.min.js b/dist/index-es.min.js index 74488930..8b68d253 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -10,13 +10,13 @@ var _={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/Mat * @module jQueryAttr * @license MIT */ -function X(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}},{key:"insertItemBefore",value:function(e,t){var n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}},{key:"removeItem",value:function(e){if(e=0){var t,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(he.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),n}();ye.type=ye.prototype.type;var _e,be,xe,we,Se,ke=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];ln(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new ye("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!ln(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new ve(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),Ce=Object.freeze({__proto__:null,HistoryEventTypes:he,MoveElementCommand:pe,InsertElementCommand:ge,RemoveElementCommand:me,ChangeElementCommand:ve,BatchCommand:ye,UndoManager:ke}),Ae=document.createElementNS(_.SVG,"svg"),Ee=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ge=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Pe=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=Number.parseInt(n))){var r=n;n=t,t=r}for(var a=Ae.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},je=jQuery,Ve={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},Re={},Be=function(e){Object.assign(Re,e.ui)},Ue=[],Fe=!0,De={},He=null,ze=null,qe=function(e){ze=e,Ue=[0,"ClosePath"];je.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Ue.push(t+"Abs"),Ue.push(t+"Rel")}))},Ye=function(e,t,n){var r=e.pathSegList;if(O)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(f=g element");this.elem=t,this.segs=[],this.selected_pts=[],He=this,this.init()}return i(e,[{key:"init",value:function(){je(Ze()).find("*").each((function(){je(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[s+1],u=s-1<0?null:i[s-1];if(2===l.type){if(u&&1!==u.type){var d=i[o];d.next=i[o+1],d.next.prev=d,d.addGrip()}o=s}else if(c&&1===c.type)l.next=i[o+1],l.next.prev=l,l.mate=i[o],l.addGrip(),ln(this.first_seg)&&(this.first_seg=l);else if(c)1!==l.type&&(l.addGrip(),c&&2!==c.type&&(l.next=c,l.next.prev=l));else if(1!==l.type){var h=i[o];h.next=i[o+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);ze.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return He.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),ot=function(e){var t=De[e.id];return t||(t=De[e.id]=new it(e)),t},st=function(e){e in De&&delete De[e]},lt=function(e,t){var n=e-xe,r=t-we,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+Se;return n=a*Math.cos(i)+xe,r=a*Math.sin(i)+we,n-=_e,r-=be,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-Se,{x:a*Math.cos(i)+_e,y:a*Math.sin(i)+be}},ct=function(){var e=He.elem;if(Se=en(e,!0)){var t=He.oldbbox;xe=t.x+t.width/2,we=t.y+t.height/2;var n=Ht(e);_e=n.x+n.width/2,be=n.y+n.height/2;var r=_e-xe,a=be-we,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+Se;_e=i*Math.cos(o)+xe,be=i*Math.sin(o)+we;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=lt(c.x,c.y),h=[d.x,d.y];if(!ln(c.x1)&&!ln(c.x2)){var f=lt(c.x1,c.y1),p=lt(c.x2,c.y2);h.splice(h.length,0,f.x,f.y,p.x,p.y)}tt(u,l,h)}}Ht(e);var g=ze.getSVGRoot().createSVGTransform(),m=te(e);g.setRotate(180*Se/Math.PI,_e,be),m.replaceItem(g,0)}},ut=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],dt=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=k-x&&f<=k+x&&p>=C-x&&p<=C+x){w=!0;break}}a=ze.getId(),st(a);var A,E,G=nn(a),P=y.numberOfItems;if(w){if(b<=1&&P>=2){var N=y.getItem(0).x,I=y.getItem(0).y;A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(N,I):v.createSVGPathSegCurvetoCubicAbs(N,I,E.x1/u,E.y1/u,N,I);var T=v.createSVGPathSegClosePath();y.appendItem(A),y.appendItem(T)}else if(P<3)return!1;if(je(g).remove(),ze.setDrawnPath(null),ze.setStarted(!1),gt){He.matrix&&ze.remapElement(G,{},He.matrix.inverse());var L=G.getAttribute("d"),M=je(He.elem).attr("d");return je(He.elem).attr("d",M+L),je(G).remove(),He.matrix&&ct(),qe(),yt.toEditMode(He.elem),He.selectPt(),!1}}else{if(!je.contains(ze.getContainer(),ze.getMouseTarget(e)))return!1;var O=v.pathSegList.numberOfItems,j=v.pathSegList.getItem(O-1),V=j.x,R=j.y;if(e.shiftKey){var B=Me(V,R,f,p);f=B.x,p=B.y}A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(ze.round(f),ze.round(p)):v.createSVGPathSegCurvetoCubicAbs(ze.round(f),ze.round(p),E.x1/u,E.y1/u,E.x2/u,E.y2/u),v.pathSegList.appendItem(A),f*=u,p*=u,g.setAttribute("d",["M",f,p,f,p].join(" ")),m=O,gt&&(m+=He.segs.length),Ke(m,f,p)}}else{var U="M"+f+","+p+" ";ze.setDrawnPath(ze.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:ze.getNextId(),opacity:ze.getOpacity()/2}})),g.setAttribute("d",["M",d,h,d,h].join(" ")),m=gt?He.segs.length:0,Ke(m,d,h)}}},mouseMove:function(e,t){var n=ze.getCurrentZoom();vt=!0;var r=ze.getDrawnPath();if("path"!==ze.getCurrentMode())if(He.dragging){var a=Qe({x:He.dragging[0],y:He.dragging[1]},He),i=Qe({x:e,y:t},He),o=i.x-a.x,s=i.y-a.y;He.dragging=[e,t],He.dragctrl?He.moveCtrl(o,s):He.movePts(o,s)}else He.selected_pts=[],He.eachSeg((function(e){if(this.next||this.prev){var t=ze.getRubberBox().getBBox(),n=Xe(this),r={x:n.x,y:n.y,width:0,height:0},a=Oe(t,r);this.select(a),a&&He.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(ft){var u=$e("1c1"),d=$e("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ft[0],f=ft[1],p=h+(h-e/n),g=f+(f-t/n);d.setAttribute("cx",p*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=Je(1);if(rn(m,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===c)pt=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):pt&&(y=pt[0]/n,_=pt[1]/n),tt(6,c,[h,f,y,_,p,g],r)}}else{var b=nn("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);tt(6,1,[e,t,w*n,S*n,e,t],b)}else pt?tt(6,1,[e,t,pt[0],pt[1],e,t],b):tt(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=ze.getDrawnPath();if("path"===ze.getCurrentMode())return ft=null,a||(t=nn(ze.getId()),ze.setStarted(!1),pt=null),{keep:!0,element:t};var i=ze.getRubberBox();if(He.dragging){var o=He.cur_pt;He.dragging=!1,He.dragctrl=!1,He.update(),vt&&He.endChanges("Move path point(s)"),e.shiftKey||vt||He.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&yt.toSelectMode(e.target)):yt.toSelectMode(e.target);vt=!1},toEditMode:function(e){He=ot(e),ze.setCurrentMode("pathedit"),ze.clearSelection(),He.show(!0).update(),He.oldbbox=Ht(He.elem),gt=!1},toSelectMode:function(e){var t=e===He.elem;ze.setCurrentMode("select"),He.show(!1),mt=!1,ze.clearSelection(),He.matrix&&ct(),t&&(ze.call("selected",[e]),ze.addToSelection([e],!0))},addSubPath:function(e){e?(ze.setCurrentMode("path"),gt=!0):(yt.clear(!0),yt.toEditMode(He.elem))},select:function(e){mt===e?(yt.toEditMode(e),ze.setCurrentMode("pathedit")):mt=e},reorient:function(){var e=ze.getSelectedElements()[0];if(e&&0!==en(e)){var t=new ye("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ve(e,n)),ze.clearSelection(),this.resetOrientation(e),ze.addCommandToHistory(t),ot(e).show(!1).matrix=null,this.clear(),ze.addToSelection([e],!0),ze.call("changed",ze.getSelectedElements())}},clear:function(e){var t=ze.getDrawnPath();if(mt=null,t){var n=nn(ze.getId());je(nn("path_stretch_line")).remove(),je(n).remove(),je(nn("pathpointgrip_container")).find("*").attr("display","none"),pt=null,ze.setDrawnPath(null),ze.setStarted(!1)}else"pathedit"===ze.getCurrentMode()&&this.toSelectMode();He&&He.init().show(!1)},resetOrientation:function(e){if(ln(e)||"path"!==e.nodeName)return!1;var t=te(e),n=Te(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];je.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=Ee(r,i,n);o.splice(o.length,0,s.x,s.y)}})),tt(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),He.elem.pathSegList.numberOfItems<=1)return yt.toSelectMode(He.elem),void ze.canvas.deleteSelectedElements();if(He.init(),He.clearSelection(),window.opera){var r=je(He.elem);r.attr("d",r.attr("d"))}He.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=rt(i,s,a);if(u&&2===u.length){var d=o[o.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,o[o.length-1]=d.join(","),s=u[1]}}o.push([s.x,s.y,l.x,l.y,c.x,c.y].join(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},Et=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function Gt(e){if(e=It(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;Number.isNaN(i)?(c=64,u=64):Number.isNaN(o)&&(u=64),t[r++]=bt.charAt(s),t[r++]=bt.charAt(l),t[r++]=bt.charAt(c),t[r++]=bt.charAt(u)}while(n>4,l=(15&a)<<4|i>>2,c=(3&i)<<6|o;t+=String.fromCharCode(s),64!==i&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return Lt(e)}(),Ot=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(_.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Ft=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(f(y));var _=(-p-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(f(_))}}else{if(0===p)continue;var b=-m/p;b>0&&b<1&&r[h].push(f(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Dt(e){if(R)try{return e.getBBox()}catch(e){}var t,n,r=_t.data(e,"ref"),a=null;r?(n=_t(r).children().clone().attr("visibility","hidden"),_t(Ct).append(n),a=n.filter("line, path")):a=_t(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:_t(e).children();t=Kt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Ht=function(e){var t=e||wt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":V?t.getBBox&&(a=t.getBBox()):a=Ft(t);break;case"g":case"a":a=Dt(t);break;default:if("use"===r&&(a=Dt(t)),"use"===r||"foreignObject"===r&&F()){if(a||(a=t.getBBox()),!F()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+Number.parseFloat(t.getAttribute("x")||0),y:s+Number.parseFloat(t.getAttribute("y")||0)}}}else if(xt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=_t(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},zt=function(e){var t="";return _t.each(e,(function(e,n){var r=f(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Wt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Wt(e,t,n))}}if(!s){var u=Te(a).matrix;r=Ie(r.x,r.y,r.width,r.height,u).aabox}}return r};function Qt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Kt=function(e,t,n){if(!e||!e.length)return!1;var r;if(_t.each(e,(function(){r||this.parentNode&&(r=Xt(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=Qt(e[0]);o-=l,s-=l,a+=l,i+=l}else _t.each(e,(function(e,r){var l=Xt(r,t,n);if(l){var c=Qt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Zt=function(e){e||(e=_t(wt.getSVGContent()).children());var t=[];return _t(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},$t=function(e){return e||(e=Zt()),Kt(e,wt.addSVGElementFromJson,wt.pathActions)},Jt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";cn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; +function X(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}},{key:"insertItemBefore",value:function(e,t){var n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}},{key:"removeItem",value:function(e){if(e=0){var t,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(he.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),n}();ye.type=ye.prototype.type;var _e,be,xe,we,Se,ke=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];ln(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new ye("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!ln(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new ve(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),Ce=Object.freeze({__proto__:null,HistoryEventTypes:he,MoveElementCommand:pe,InsertElementCommand:ge,RemoveElementCommand:me,ChangeElementCommand:ve,BatchCommand:ye,UndoManager:ke}),Ae=document.createElementNS(_.SVG,"svg"),Ee=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ge=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Pe=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=Number.parseInt(n))){var r=n;n=t,t=r}for(var a=Ae.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},je=jQuery,Ve={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},Re={},Be=function(e){Object.assign(Re,e.ui)},Ue=[],Fe=!0,De={},He=null,ze=null,qe=function(e){ze=e,Ue=[0,"ClosePath"];je.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Ue.push(t+"Abs"),Ue.push(t+"Rel")}))},Ye=function(e,t,n){var r=e.pathSegList;if(O)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(f=g element");this.elem=t,this.segs=[],this.selected_pts=[],He=this,this.init()}return i(e,[{key:"init",value:function(){je(Ze()).find("*").each((function(){je(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[s+1],u=s-1<0?null:i[s-1];if(2===l.type){if(u&&1!==u.type){var d=i[o];d.next=i[o+1],d.next.prev=d,d.addGrip()}o=s}else if(c&&1===c.type)l.next=i[o+1],l.next.prev=l,l.mate=i[o],l.addGrip(),ln(this.first_seg)&&(this.first_seg=l);else if(c)1!==l.type&&(l.addGrip(),c&&2!==c.type&&(l.next=c,l.next.prev=l));else if(1!==l.type){var h=i[o];h.next=i[o+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);ze.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return He.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),ot=function(e){var t=De[e.id];return t||(t=De[e.id]=new it(e)),t},st=function(e){e in De&&delete De[e]},lt=function(e,t){var n=e-xe,r=t-we,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+Se;return n=a*Math.cos(i)+xe,r=a*Math.sin(i)+we,n-=_e,r-=be,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-Se,{x:a*Math.cos(i)+_e,y:a*Math.sin(i)+be}},ct=function(){var e=He.elem;if(Se=en(e,!0)){var t=He.oldbbox;xe=t.x+t.width/2,we=t.y+t.height/2;var n=Ht(e);_e=n.x+n.width/2,be=n.y+n.height/2;var r=_e-xe,a=be-we,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+Se;_e=i*Math.cos(o)+xe,be=i*Math.sin(o)+we;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=lt(c.x,c.y),h=[d.x,d.y];if(!ln(c.x1)&&!ln(c.x2)){var f=lt(c.x1,c.y1),p=lt(c.x2,c.y2);h.splice(h.length,0,f.x,f.y,p.x,p.y)}tt(u,l,h)}}Ht(e);var g=ze.getSVGRoot().createSVGTransform(),m=te(e);g.setRotate(180*Se/Math.PI,_e,be),m.replaceItem(g,0)}},ut=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],dt=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=k-x&&f<=k+x&&p>=C-x&&p<=C+x){w=!0;break}}a=ze.getId(),st(a);var A,E,G=nn(a),P=y.numberOfItems;if(w){if(b<=1&&P>=2){var N=y.getItem(0).x,I=y.getItem(0).y;A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(N,I):v.createSVGPathSegCurvetoCubicAbs(N,I,E.x1/u,E.y1/u,N,I);var T=v.createSVGPathSegClosePath();y.appendItem(A),y.appendItem(T)}else if(P<3)return!1;if(je(g).remove(),ze.setDrawnPath(null),ze.setStarted(!1),gt){He.matrix&&ze.remapElement(G,{},He.matrix.inverse());var L=G.getAttribute("d"),M=je(He.elem).attr("d");return je(He.elem).attr("d",M+L),je(G).remove(),He.matrix&&ct(),qe(),yt.toEditMode(He.elem),He.selectPt(),!1}}else{if(!je.contains(ze.getContainer(),ze.getMouseTarget(e)))return!1;var O=v.pathSegList.numberOfItems,j=v.pathSegList.getItem(O-1),V=j.x,R=j.y;if(e.shiftKey){var B=Me(V,R,f,p);f=B.x,p=B.y}A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(ze.round(f),ze.round(p)):v.createSVGPathSegCurvetoCubicAbs(ze.round(f),ze.round(p),E.x1/u,E.y1/u,E.x2/u,E.y2/u),v.pathSegList.appendItem(A),f*=u,p*=u,g.setAttribute("d",["M",f,p,f,p].join(" ")),m=O,gt&&(m+=He.segs.length),Ke(m,f,p)}}else{var U="M"+f+","+p+" ";ze.setDrawnPath(ze.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:ze.getNextId(),opacity:ze.getOpacity()/2}})),g.setAttribute("d",["M",d,h,d,h].join(" ")),m=gt?He.segs.length:0,Ke(m,d,h)}}},mouseMove:function(e,t){var n=ze.getCurrentZoom();vt=!0;var r=ze.getDrawnPath();if("path"!==ze.getCurrentMode())if(He.dragging){var a=Qe({x:He.dragging[0],y:He.dragging[1]},He),i=Qe({x:e,y:t},He),o=i.x-a.x,s=i.y-a.y;He.dragging=[e,t],He.dragctrl?He.moveCtrl(o,s):He.movePts(o,s)}else He.selected_pts=[],He.eachSeg((function(e){if(this.next||this.prev){var t=ze.getRubberBox().getBBox(),n=Xe(this),r={x:n.x,y:n.y,width:0,height:0},a=Oe(t,r);this.select(a),a&&He.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(ft){var u=$e("1c1"),d=$e("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ft[0],f=ft[1],p=h+(h-e/n),g=f+(f-t/n);d.setAttribute("cx",p*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=Je(1);if(rn(m,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===c)pt=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):pt&&(y=pt[0]/n,_=pt[1]/n),tt(6,c,[h,f,y,_,p,g],r)}}else{var b=nn("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);tt(6,1,[e,t,w*n,S*n,e,t],b)}else pt?tt(6,1,[e,t,pt[0],pt[1],e,t],b):tt(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=ze.getDrawnPath();if("path"===ze.getCurrentMode())return ft=null,a||(t=nn(ze.getId()),ze.setStarted(!1),pt=null),{keep:!0,element:t};var i=ze.getRubberBox();if(He.dragging){var o=He.cur_pt;He.dragging=!1,He.dragctrl=!1,He.update(),vt&&He.endChanges("Move path point(s)"),e.shiftKey||vt||He.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&yt.toSelectMode(e.target)):yt.toSelectMode(e.target);vt=!1},toEditMode:function(e){He=ot(e),ze.setCurrentMode("pathedit"),ze.clearSelection(),He.show(!0).update(),He.oldbbox=Ht(He.elem),gt=!1},toSelectMode:function(e){var t=e===He.elem;ze.setCurrentMode("select"),He.show(!1),mt=!1,ze.clearSelection(),He.matrix&&ct(),t&&(ze.call("selected",[e]),ze.addToSelection([e],!0))},addSubPath:function(e){e?(ze.setCurrentMode("path"),gt=!0):(yt.clear(!0),yt.toEditMode(He.elem))},select:function(e){mt===e?(yt.toEditMode(e),ze.setCurrentMode("pathedit")):mt=e},reorient:function(){var e=ze.getSelectedElements()[0];if(e&&0!==en(e)){var t=new ye("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ve(e,n)),ze.clearSelection(),this.resetOrientation(e),ze.addCommandToHistory(t),ot(e).show(!1).matrix=null,this.clear(),ze.addToSelection([e],!0),ze.call("changed",ze.getSelectedElements())}},clear:function(e){var t=ze.getDrawnPath();if(mt=null,t){var n=nn(ze.getId());je(nn("path_stretch_line")).remove(),je(n).remove(),je(nn("pathpointgrip_container")).find("*").attr("display","none"),pt=null,ze.setDrawnPath(null),ze.setStarted(!1)}else"pathedit"===ze.getCurrentMode()&&this.toSelectMode();He&&He.init().show(!1)},resetOrientation:function(e){if(ln(e)||"path"!==e.nodeName)return!1;var t=te(e),n=Te(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];je.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=Ee(r,i,n);o.splice(o.length,0,s.x,s.y)}})),tt(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),He.elem.pathSegList.numberOfItems<=1)return yt.toSelectMode(He.elem),void ze.canvas.deleteSelectedElements();if(He.init(),He.clearSelection(),window.opera){var r=je(He.elem);r.attr("d",r.attr("d"))}He.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=rt(i,s,a);if(u&&2===u.length){var d=o[o.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,o[o.length-1]=d.join(","),s=u[1]}}o.push([s.x,s.y,l.x,l.y,c.x,c.y].join(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},Et=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function Gt(e){if(e=It(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;Number.isNaN(i)?(c=64,u=64):Number.isNaN(o)&&(u=64),t[r++]=bt.charAt(s),t[r++]=bt.charAt(l),t[r++]=bt.charAt(c),t[r++]=bt.charAt(u)}while(n>4,l=(15&a)<<4|i>>2,c=(3&i)<<6|o;t+=String.fromCharCode(s),64!==i&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(c))}while(nSVG-edit "],{type:"text/html"});return Lt(e)}(),Ot=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(_.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Ft=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(f(y));var _=(-p-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(f(_))}}else{if(0===p)continue;var b=-m/p;b>0&&b<1&&r[h].push(f(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Dt(e){if(R)try{return e.getBBox()}catch(e){}var t,n,r=_t.data(e,"ref"),a=null;r?(n=_t(r).children().clone().attr("visibility","hidden"),_t(Ct).append(n),a=n.filter("line, path")):a=_t(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:_t(e).children();t=Kt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Ht=function(e){var t=e||wt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":V?t.getBBox&&(a=t.getBBox()):a=Ft(t);break;case"g":case"a":a=Dt(t);break;default:if("use"===r&&(a=Dt(t)),"use"===r||"foreignObject"===r&&F()){if(a||(a=t.getBBox()),!F()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+Number.parseFloat(t.getAttribute("x")||0),y:s+Number.parseFloat(t.getAttribute("y")||0)}}}else if(xt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=_t(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},zt=function(e){var t="";return _t.each(e,(function(e,n){var r=f(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Wt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Wt(e,t,n))}}if(!s){var u=Te(a).matrix;r=Ie(r.x,r.y,r.width,r.height,u).aabox}}return r};function Qt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Kt=function(e,t,n){if(!e||!e.length)return!1;var r;if(_t.each(e,(function(){r||this.parentNode&&(r=Xt(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=Qt(e[0]);o-=l,s-=l,a+=l,i+=l}else _t.each(e,(function(e,r){var l=Xt(r,t,n);if(l){var c=Qt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Zt=function(e){e||(e=_t(wt.getSVGContent()).children());var t=[];return _t(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},$t=function(e){return e||(e=Zt()),Kt(e,wt.addSVGElementFromJson,wt.pathActions)},Jt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";cn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; /** * Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}. * @module importModule * @license MIT */ -function hn(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function fn(e,t){["id","class","type"].forEach((function(n){n in t&&(e[n]=t[n])}))}function pn(e,t){return gn(e,o({},t,{returnDefault:!0}))}function gn(e,t){return mn.apply(this,arguments)}function mn(){return(mn=n(regeneratorRuntime.mark((function e(t,n){var r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.global,a=n.returnDefault,!(!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules)){e.next=4;break}return e.abrupt("return",yn(t,void 0,{returnDefault:a}));case 4:return e.next=6,vn(t);case 6:return e.abrupt("return",window[r]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function vn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return vn(e,t)}))):new Promise((function(n,r){var a=document.createElement("script");function i(){r(new Error("Failed to import: ".concat(e))),s()}function o(){n(),s()}var s=function(){a.removeEventListener("error",i),a.removeEventListener("load",o),a.remove(),a.src=""};a.defer="defer",fn(a,t),a.addEventListener("error",i),a.addEventListener("load",o),a.src=e,document.head.append(a)}))}function yn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.returnDefault,a=void 0!==r&&r;return Array.isArray(e)?Promise.all(e.map((function(e){return yn(e,t)}))):new Promise((function(n,r){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script");function s(){r(new Error("Failed to import: ".concat(e))),c()}function l(){n(window[i]),c()}var c=function(){delete window[i],o.removeEventListener("error",s),o.removeEventListener("load",l),o.remove(),URL.revokeObjectURL(o.src),o.src=""};fn(o,t),o.defer="defer",o.type="module",o.addEventListener("error",s),o.addEventListener("load",l);var u=hn(e),d="import * as m from '".concat(u.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(a?"m.default || ":"","m;"),h=new Blob([d],{type:"text/javascript"});o.src=URL.createObjectURL(h),document.head.append(o)}))}var _n={true:!0,false:!1,null:null};function bn(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ok:"Ok",cancel:"Cancel"};t("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var r=t("#dialog_box"),a=t("#dialog_buttons"),i=t("#dialog_content");function o(o,s,l,c,u,d){i.html("

    "+s.replace(/\n/g,"

    ")+"

    ").toggleClass("prompt","prompt"===o),a.empty();var h=t('').appendTo(a);return new Promise((function(f,p){var g,m;if("alert"!==o&&t('').appendTo(a).click((function(){r.hide(),f(!1)})),"prompt"===o)(g=t('').prependTo(a)).val(l||""),g.bind("keydown","return",(function(){h.click()}));else if("select"===o){var v=t('
    ');if(g=t('').appendTo(y)).val(d.value),d.tooltip&&y.attr("title",d.tooltip),m.prop("checked",Boolean(d.checked)),v.append(t("
    ").append(y))}t.each(c||[],(function(n,r){"object"===e(r)?g.append(t("