function asyncGeneratorStep(t,e,n,r,i,a,s){try{var h=t[a](s),o=h.value}catch(t){return void n(t)}h.done?e(o):Promise.resolve(o).then(r,i)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;ne.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=t,window.SVGPathSegClosePath=e,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=r,window.SVGPathSegLinetoAbs=i,window.SVGPathSegLinetoRel=a,window.SVGPathSegCurvetoCubicAbs=s,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=o,window.SVGPathSegCurvetoQuadraticRel=_,window.SVGPathSegArcAbs=u,window.SVGPathSegArcRel=c,window.SVGPathSegLinetoHorizontalAbs=S,window.SVGPathSegLinetoHorizontalRel=g,window.SVGPathSegLinetoVerticalAbs=l,window.SVGPathSegLinetoVerticalRel=P,window.SVGPathSegCurvetoCubicSmoothAbs=p,window.SVGPathSegCurvetoCubicSmoothRel=f,window.SVGPathSegCurvetoQuadraticSmoothAbs=C,window.SVGPathSegCurvetoQuadraticSmoothRel=A}if(!("SVGPathSegList"in window)||!("appendItem"in window.SVGPathSegList.prototype)){var y=function(){function SVGPathSegList(t){_classCallCheck(this,SVGPathSegList),this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}return _createClass(SVGPathSegList,[{key:"_checkPathSynchronizedToList",value:function _checkPathSynchronizedToList(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function _updateListFromPathMutations(t){if(this._pathElement){var e=!1;t.forEach((function(t){"d"===t.attributeName&&(e=!0)})),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function _writeListToPath(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function segmentChanged(t){this._writeListToPath()}},{key:"clear",value:function clear(){this._checkPathSynchronizedToList(),this._list.forEach((function(t){t._owningPathSegList=null})),this._list=[],this._writeListToPath()}},{key:"initialize",value:function initialize(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t}},{key:"_checkValidIndex",value:function _checkValidIndex(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function getItem(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]}},{key:"insertItemBefore",value:function insertItemBefore(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t}},{key:"replaceItem",value:function replaceItem(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t}},{key:"removeItem",value:function removeItem(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e}},{key:"appendItem",value:function appendItem(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t}},{key:"_parsePath",value:function _parsePath(t){if(!t||!t.length)return[];var e=this,n=function(){function Builder(){_classCallCheck(this,Builder),this.pathSegList=[]}return _createClass(Builder,[{key:"appendSegment",value:function appendSegment(t){this.pathSegList.push(t)}}]),Builder}(),r=function(){function Source(t){_classCallCheck(this,Source),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return _createClass(Source,[{key:"_isCurrentSpace",value:function _isCurrentSpace(){var t=this._string[this._currentIndex];return t<=" "&&(" "===t||"\n"===t||"\t"===t||"\r"===t||"\f"===t)}},{key:"_skipOptionalSpaces",value:function _skipOptionalSpaces(){for(;this._currentIndex="0"&&t<="9")&&e!==SVGPathSeg.PATHSEG_CLOSEPATH?e===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:e===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:e:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function initialCommandIsMoveTo(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t===SVGPathSeg.PATHSEG_MOVETO_ABS||t===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function _parseNumber(){var t=0,e=0,n=1,r=0,i=1,a=1,s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var h=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==h)for(var o=this._currentIndex-1,_=1;o>=h;)e+=_*(this._string.charAt(o--)-"0"),_*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,r+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!==s&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=e+r;if(u*=i,t&&(u*=Math.pow(10,a*t)),s!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}}},{key:"_parseArcFlag",value:function _parseArcFlag(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"===e)t=!1;else{if("1"!==e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}}},{key:"parseSegment",value:function parseSegment(){var t=this._string[this._currentIndex],n=this._pathSegTypeFromChar(t);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(t,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(e,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(e);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(e,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(e,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var a={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(e,a.x,a.y,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var s={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(e,s.x,s.y,s.x2,s.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var h={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(e,h.x,h.y,h.x1,h.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var o={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(e,o.x,o.y,o.x1,o.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var _={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(e,_.x,_.y,_.x1,_.y1,_.arcAngle,_.arcLarge,_.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(e,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),Source}(),i=new n,a=new r(t);if(!a.initialCommandIsMoveTo())return[];for(;a.hasMoreData();){var s=a.parseSegment();if(!s)return[];i.appendSegment(s)}return i.pathSegList}}],[{key:"_pathSegArrayAsString",value:function _pathSegArrayAsString(t){var e="",n=!0;return t.forEach((function(t){n?(n=!1,e+=t._asPathString()):e+=" "+t._asPathString()})),e}}]),SVGPathSegList}();y.prototype.classname="SVGPathSegList",Object.defineProperty(y.prototype,"numberOfItems",{get:function get(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function get(){return this._pathSegList||(this._pathSegList=new y(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function get(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function get(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function get(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=y}}();var t={name:"closepath",init:function init(t){return function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function _next(t){asyncGeneratorStep(a,r,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(a,r,i,_next,_throw,"throw",t)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var e,n,r,i,a,s,h,o;return regeneratorRuntime.wrap((function _callee$(_){for(;;)switch(_.prev=_.next){case 0:return e=t.importLocale,n=t.$,_.next=3,e();case 3:return r=_.sent,a=function updateButton(t){var e=t.pathSegList,r=1===e.getItem(e.numberOfItems-1).pathSegType,i=r?"#tool_openpath":"#tool_closepath";n(r?"#tool_closepath":"#tool_openpath").hide(),n(i).show()},s=function showPanel(t){if(n("#closepath_panel").toggle(t),t){var e=i[0];e&&a(e)}},h=function toggleClosed(){var t=i[0];if(t){var e=t.pathSegList,n=e.numberOfItems-1;1===e.getItem(n).pathSegType?e.removeItem(n):e.appendItem(t.createSVGPathSegClosePath()),a(t)}},o=[{id:"tool_openpath",icon:"openpath.png",type:"context",panel:"closepath_panel",events:{click:function click(){h()}}},{id:"tool_closepath",icon:"closepath.png",type:"context",panel:"closepath_panel",events:{click:function click(){h()}}}],_.abrupt("return",{name:r.name,svgicons:"closepath_icons.svg",buttons:r.buttons.map((function(t,e){return Object.assign(o[e],t)})),callback:function callback(){n("#closepath_panel").hide()},selectedChanged:function selectedChanged(t){for(var e=(i=t.elems).length;e--;){var n=i[e];n&&"path"===n.tagName&&t.selectedElement&&!t.multiselected?s(!0):s(!1)}}});case 9:case"end":return _.stop()}}),_callee)})))()}};export default t; //# sourceMappingURL=ext-closepath.js.map