var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])})(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();import CanvasBuilder from"./Builder.js";import CanvasInstruction,{beginPathInstruction,strokeInstruction}from"./Instruction.js";import{defaultLineDash,defaultLineDashOffset}from"../canvas.js";var CanvasLineStringBuilder=function(s){function t(t,n,i,e){return s.call(this,t,n,i,e)||this}return __extends(t,s),t.prototype.drawFlatCoordinates_=function(t,n,i,e){var s=this.coordinates.length,t=this.appendFlatLineCoordinates(t,n,i,e,!1,!1),n=[CanvasInstruction.MOVE_TO_LINE_TO,s,t];return this.instructions.push(n),this.hitDetectionInstructions.push(n),i},t.prototype.drawLineString=function(t,n){var i=this.state,e=i.strokeStyle,s=i.lineWidth;void 0!==e&&void 0!==s&&(this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,n),this.hitDetectionInstructions.push([CanvasInstruction.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,defaultLineDash,defaultLineDashOffset],beginPathInstruction),e=t.getFlatCoordinates(),s=t.getStride(),this.drawFlatCoordinates_(e,0,e.length,s),this.hitDetectionInstructions.push(strokeInstruction),this.endGeometry(n))},t.prototype.drawMultiLineString=function(t,n){var i=this.state,e=i.strokeStyle,s=i.lineWidth;if(void 0!==e&&void 0!==s){this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,n),this.hitDetectionInstructions.push([CanvasInstruction.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset],beginPathInstruction);for(var o=t.getEnds(),r=t.getFlatCoordinates(),a=t.getStride(),u=0,h=0,l=o.length;h<l;++h)u=this.drawFlatCoordinates_(r,u,o[h],a);this.hitDetectionInstructions.push(strokeInstruction),this.endGeometry(n)}},t.prototype.finish=function(){var t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(strokeInstruction),this.reverseHitDetectionInstructions(),this.state=null,s.prototype.finish.call(this)},t.prototype.applyStroke=function(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(strokeInstruction),t.lastStroke=this.coordinates.length),t.lastStroke=0,s.prototype.applyStroke.call(this,t),this.instructions.push(beginPathInstruction)},t}(CanvasBuilder);export default CanvasLineStringBuilder;