text: !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.LC=t()}}(function(){return function t(e,n,i){function r(s,a){if(!n[s]){if(!e[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return r(n?n:t)},c,c.exports,t,e,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(t,e,n){"use strict";function i(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(var o=r.bind(e),s=0;s<n.length;s++)if(!o(n[s])||t[n[s]]!==e[n[s]])return!1;return!0}var r=Object.prototype.hasOwnProperty;e.exports=i},{}],2:[function(t,e,n){e.exports=t("react/lib/ReactComponentWithPureRenderMixin")},{"react/lib/ReactComponentWithPureRenderMixin":3}],3:[function(t,e,n){"use strict";var i=t("./shallowCompare"),r={shouldComponentUpdate:function(t,e){return i(this,t,e)}};e.exports=r},{"./shallowCompare":4}],4:[function(t,e,n){"use strict";function i(t,e,n){return!r(t.props,e)||!r(t.state,n)}var r=t("fbjs/lib/shallowEqual");e.exports=i},{"fbjs/lib/shallowEqual":1}],5:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d,f,g,m,y,S=function(t,e){return function(){return t.apply(e,arguments)}},v=[].slice,x=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};a=t("./actions"),h=t("./bindEvents"),c=t("./math"),u=t("./shapes"),l=u.createShape,m=u.shapeToJSON,r=u.JSONToShape,p=t("./canvasRenderer").renderShapeToContext,d=t("./svgRenderer").renderShapeToSVG,f=t("./renderSnapshotToImage"),g=t("./renderSnapshotToSVG"),s=t("../tools/Pencil"),y=t("./util"),i="infinite",e.exports=o=function(){function t(t,e){this.setImageSize=S(this.setImageSize,this);var n,r;r=null,n=null,t instanceof HTMLElement?(n=t,r=e):r=t,this.opts=r||{},this.config={zoomMin:r.zoomMin||.2,zoomMax:r.zoomMax||4,zoomStep:r.zoomStep||.2},this.colors={primary:r.primaryColor||"#000",secondary:r.secondaryColor||"#fff",background:r.backgroundColor||"transparent"},this.watermarkImage=r.watermarkImage,this.watermarkScale=r.watermarkScale||1,this.backgroundCanvas=document.createElement("canvas"),this.backgroundCtx=this.backgroundCanvas.getContext("2d"),this.canvas=document.createElement("canvas"),this.canvas.style["background-color"]="transparent",this.buffer=document.createElement("canvas"),this.buffer.style["background-color"]="transparent",this.ctx=this.canvas.getContext("2d"),this.bufferCtx=this.buffer.getContext("2d"),this.backingScale=y.getBackingScale(this.ctx),this.backgroundShapes=r.backgroundShapes||[],this._shapesInProgress=[],this.shapes=[],this.undoStack=[],this.redoStack=[],this.isDragging=!1,this.position={x:0,y:0},this.scale=1,this.setTool(new this.opts.tools[0](this)),this.width=r.imageSize.width||i,this.height=r.imageSize.height||i,this.setZoom(this.scale),r.snapshot&&this.loadSnapshot(r.snapshot),this.isBound=!1,n&&this.bindToElement(n),this.respondToSizeChange=function(){}}return t.prototype.bindToElement=function(t){var e,n;return this.containerEl?void console.warn("Trying to bind Literally Canvas to a DOM element more than once is unsupported."):(this.containerEl=t,this._unsubscribeEvents=h(this,this.containerEl,this.opts.keyboardShortcuts),this.containerEl.style["background-color"]=this.colors.background,this.containerEl.appendChild(this.backgroundCanvas),this.containerEl.appendChild(this.canvas),this.isBound=!0,n=function(t){return function(){return t.keepPanInImageBounds(),t.repaintAllLayers()}}(this),this.respondToSizeChange=y.matchElementSize(this.containerEl,[this.backgroundCanvas,this.canvas],this.backingScale,n),this.watermarkImage&&(this.watermarkImage.onload=function(t){return function(){return t.repaintLayer("background")}}(this)),null!=(e=this.tool)&&e.didBecomeActive(this),n())},t.prototype._teardown=function(){var t;return null!=(t=this.tool)&&t.willBecomeInactive(this),"function"==typeof this._unsubscribeEvents&&this._unsubscribeEvents(),this.tool=null,this.containerEl=null,this.isBound=!1},t.prototype.trigger=function(t,e){return this.canvas.dispatchEvent(new CustomEvent(t,{detail:e})),null},t.prototype.on=function(t,e){var n;return n=function(t){return e(t.detail)},this.canvas.addEventListener(t,n),function(e){return function(){return e.canvas.removeEventListener(t,n)}}(this)},t.prototype.getRenderScale=function(){return this.scale*this.backingScale},t.prototype.clientCoordsToDrawingCoords=function(t,e){return{x:(t*this.backingScale-this.position.x)/this.getRenderScale(),y:(e*this.backingScale-this.position.y)/this.getRenderScale()}},t.prototype.drawingCoordsToClientCoords=function(t,e){return{x:t*this.getRenderScale()+this.position.x,y:e*this.getRenderScale()+this.position.y}},t.prototype.setImageSize=function(t,e){return this.width=t||i,this.height=e||i,this.keepPanInImageBounds(),this.repaintAllLayers(),this.trigger("imageSizeChange",{width:this.width,height:this.height})},t.prototype.setTool=function(t){var e;return this.isBound&&null!=(e=this.tool)&&e.willBecomeInactive(this),this.tool=t,this.trigger("toolChange",{tool:t}),this.isBound?this.tool.didBecomeActive(this):void 0},t.prototype.setShapesInProgress=function(t){return this._shapesInProgress=t},t.prototype.pointerDown=function(t,e){var n;return n=this.clientCoordsToDrawingCoords(t,e),this.tool.usesSimpleAPI?(this.tool.begin(n.x,n.y,this),this.isDragging=!0,this.trigger("drawStart",{tool:this.tool})):(this.isDragging=!0,this.trigger("lc-pointerdown",{tool:this.tool,x:n.x,y:n.y,rawX:t,rawY:e}))},t.prototype.pointerMove=function(t,e){return y.requestAnimationFrame(function(n){return function(){var i,r;return i=n.clientCoordsToDrawingCoords(t,e),(null!=(r=n.tool)?r.usesSimpleAPI:0)?n.isDragging?(n.tool["continue"](i.x,i.y,n),n.trigger("drawContinue",{tool:n.tool})):void 0:n.isDragging?n.trigger("lc-pointerdrag",{tool:n.tool,x:i.x,y:i.y,rawX:t,rawY:e}):n.trigger("lc-pointermove",{tool:n.tool,x:i.x,y:i.y,rawX:t,rawY:e})}}(this))},t.prototype.pointerUp=function(t,e){var n;return n=this.clientCoordsToDrawingCoords(t,e),this.tool.usesSimpleAPI?this.isDragging?(this.tool.end(n.x,n.y,this),this.isDragging=!1,this.trigger("drawEnd",{tool:this.tool})):void 0:(this.isDragging=!1,this.trigger("lc-pointerup",{tool:this.tool,x:n.x,y:n.y,rawX:t,rawY:e}))},t.prototype.setColor=function(t,e){if(this.colors[t]=e,this.isBound){switch(t){case"background":this.containerEl.style.backgroundColor=this.colors.background,this.repaintLayer("background");break;case"primary":this.repaintLayer("main");break;case"secondary":this.repaintLayer("main")}return this.trigger(t+"ColorChange",this.colors[t]),"background"===t?this.trigger("drawingChange"):void 0}},t.prototype.getColor=function(t){return this.colors[t]},t.prototype.saveShape=function(t,e,n){return null==e&&(e=!0),null==n&&(n=null),n||(n=this.shapes.length?this.shapes[this.shapes.length-1].id:null),this.execute(new a.AddShapeAction(this,t,n)),e&&this.trigger("shapeSave",{shape:t,previousShapeId:n}),this.trigger("drawingChange")},t.prototype.pan=function(t,e){return this.setPan(this.position.x-t,this.position.y-e)},t.prototype.keepPanInImageBounds=function(){var t,e,n,r;return e=this.getRenderScale(),t=this.position,n=t.x,r=t.y,this.width!==i&&(n=this.canvas.width>this.width*e?(this.canvas.width-this.width*e)/2:Math.max(Math.min(0,n),this.canvas.width-this.width*e)),this.height!==i&&(r=this.canvas.height>this.height*e?(this.canvas.height-this.height*e)/2:Math.max(Math.min(0,r),this.canvas.height-this.height*e)),this.position={x:n,y:r}},t.prototype.setPan=function(t,e){return this.position={x:t,y:e},this.keepPanInImageBounds(),this.repaintAllLayers(),this.trigger("pan",{x:this.position.x,y:this.position.y})},t.prototype.zoom=function(t){var e;return e=this.scale+t,e=Math.max(e,this.config.zoomMin),e=Math.min(e,this.config.zoomMax),e=Math.round(100*e)/100,this.setZoom(e)},t.prototype.setZoom=function(t){var e;return e=this.scale,this.scale=t,this.position.x=c.scalePositionScalar(this.position.x,this.canvas.width,e,this.scale),this.position.y=c.scalePositionScalar(this.position.y,this.canvas.height,e,this.scale),this.keepPanInImageBounds(),this.repaintAllLayers(),this.trigger("zoom",{oldScale:e,newScale:this.scale})},t.prototype.setWatermarkImage=function(t){return this.watermarkImage=t,y.addImageOnload(t,function(t){return function(){return t.repaintLayer("background")}}(this)),t.width?this.repaintLayer("background"):void 0},t.prototype.repaintAllLayers=function(){var t,e,n,i;for(i=["background","main"],t=0,n=i.length;n>t;t++)e=i[t],this.repaintLayer(e);return null},t.prototype.repaintLayer=function(t,e){var n;if(null==e&&(e="main"===t),this.isBound){switch(t){case"background":this.backgroundCtx.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height),n=function(t){return function(){return t.repaintLayer("background")}}(this),this.watermarkImage&&this._renderWatermark(this.backgroundCtx,!0,n),this.draw(this.backgroundShapes,this.backgroundCtx,n);break;case"main":n=function(t){return function(){return t.repaintLayer("main",!0)}}(this),e&&(this.buffer.width=this.canvas.width,this.buffer.height=this.canvas.height,this.bufferCtx.clearRect(0,0,this.buffer.width,this.buffer.height),this.draw(this.shapes,this.bufferCtx,n)),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.canvas.width>0&&this.canvas.height>0&&(this.ctx.fillStyle="#ccc",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.clipped(function(t){return function(){return t.ctx.clearRect(0,0,t.canvas.width,t.canvas.height),t.ctx.drawImage(t.buffer,0,0)}}(this),this.ctx),this.clipped(function(t){return function(){return t.transformed(function(){var e,n,i,r,o;for(i=t._shapesInProgress,r=[],e=0,n=i.length;n>e;e++)o=i[e],r.push(p(t.ctx,o,{bufferCtx:t.bufferCtx,shouldOnlyDrawLatest:!0}));return r},t.ctx,t.bufferCtx)}}(this),this.ctx,this.bufferCtx))}return this.trigger("repaint",{layerKey:t})}},t.prototype._renderWatermark=function(t,e,n){return null==e&&(e=!0),this.watermarkImage.width?(t.save(),t.translate(t.canvas.width/2,t.canvas.height/2),t.scale(this.watermarkScale,this.watermarkScale),e&&t.scale(this.backingScale,this.backingScale),t.drawImage(this.watermarkImage,-this.watermarkImage.width/2,-this.watermarkImage.height/2),t.restore()):void(this.watermarkImage.onload=n)},t.prototype.drawShapeInProgress=function(t){return this.repaintLayer("main",!1),this.clipped(function(e){return function(){return e.transformed(function(){return p(e.ctx,t,{bufferCtx:e.bufferCtx,shouldOnlyDrawLatest:!0})},e.ctx,e.bufferCtx)}}(this),this.ctx,this.bufferCtx)},t.prototype.draw=function(t,e,n){var i;if(t.length)return i=function(i){return function(){var i,r,o,s;for(o=[],i=0,r=t.length;r>i;i++)s=t[i],o.push(p(e,s,{retryCallback:n}));return o}}(this),this.clipped(function(t){return function(){return t.transformed(i,e)}}(this),e)},t.prototype.clipped=function(){var t,e,n,r,o,s,a,h,l,c,u,p;for(n=arguments[0],t=2<=arguments.length?v.call(arguments,1):[],u=this.width===i?0:this.position.x,p=this.height===i?0:this.position.y,c=function(){switch(this.width){case i:return this.canvas.width;default:return this.width*this.getRenderScale()}}.call(this),r=function(){switch(this.height){case i:return this.canvas.height;default:return this.height*this.getRenderScale()}}.call(this),o=0,a=t.length;a>o;o++)e=t[o],e.save(),e.beginPath(),e.rect(u,p,c,r),e.clip();for(n(),l=[],s=0,h=t.length;h>s;s++)e=t[s],l.push(e.restore());return l},t.prototype.transformed=function(){var t,e,n,i,r,o,s,a,h;for(n=arguments[0],t=2<=arguments.length?v.call(arguments,1):[],i=0,o=t.length;o>i;i++)e=t[i],e.save(),e.translate(Math.floor(this.position.x),Math.floor(this.position.y)),h=this.getRenderScale(),e.scale(h,h);for(n(),a=[],r=0,s=t.length;s>r;r++)e=t[r],a.push(e.restore());return a},t.prototype.clear=function(t){var e,n;return null==t&&(t=!0),n=this.shapes,e=[],this.setShapesInProgress([]),this.execute(new a.ClearAction(this,n,e)),this.repaintLayer("main"),t&&this.trigger("clear",null),this.trigger("drawingChange",{})},t.prototype.execute=function(t){return this.undoStack.push(t),t["do"](),this.redoStack=[]},t.prototype.undo=function(){var t;if(this.undoStack.length)return t=this.undoStack.pop(),t.undo(),this.redoStack.push(t),this.trigger("undo",{action:t}),this.trigger("drawingChange",{})},t.prototype.redo=function(){var t;if(this.redoStack.length)return t=this.redoStack.pop(),this.undoStack.push(t),t["do"](),this.trigger("redo",{action:t}),this.trigger("drawingChange",{})},t.prototype.canUndo=function(){return!!this.undoStack.length},t.prototype.canRedo=function(){return!!this.redoStack.length},t.prototype.getPixel=function(t,e){var n,i;return n=this.drawingCoordsToClientCoords(t,e),i=this.ctx.getImageData(n.x,n.y,1,1).data,i[3]?"rgb("+i[0]+", "+i[1]+", "+i[2]+")":null},t.prototype.getContentBounds=function(){return y.getBoundingRect(this.shapes.concat(this.backgroundShapes).map(function(t){return t.getBoundingRect()}),this.width===i?0:this.width,this.height===i?0:this.height)},t.prototype.getDefaultImageRect=function(t,e){var n;return null==t&&(t={width:0,height:0}),null==e&&(e={top:0,right:0,bottom:0,left:0}),y.getDefaultImageRect(function(){var t,e,i,r;for(i=this.shapes.concat(this.backgroundShapes),r=[],t=0,e=i.length;e>t;t++)n=i[t],r.push(n.getBoundingRect(this.ctx));return r}.call(this),t,e)},t.prototype.getImage=function(t){return null==t&&(t={}),null==t.includeWatermark&&(t.includeWatermark=!0),null==t.scaleDownRetina&&(t.scaleDownRetina=!0),null==t.scale&&(t.scale=1),t.scaleDownRetina||(t.scale*=this.backingScale),t.includeWatermark&&(t.watermarkImage=this.watermarkImage,t.watermarkScale=this.watermarkScale,t.scaleDownRetina||(t.watermarkScale*=this.backingScale)),f(this.getSnapshot(),t)},t.prototype.canvasForExport=function(){return this.repaintAllLayers(),y.combineCanvases(this.backgroundCanvas,this.canvas)},t.prototype.canvasWithBackground=function(t){return y.combineCanvases(t,this.canvasForExport())},t.prototype.getSnapshot=function(t){var e,n,i,r,o,s;for(null==t&&(t=null),null==t&&(t=["shapes","imageSize","colors","position","scale","backgroundShapes"]),s={},r=["colors","position","scale"],e=0,i=r.length;i>e;e++)n=r[e],x.call(t,n)>=0&&(s[n]=this[n]);return x.call(t,"shapes")>=0&&(s.shapes=function(){var t,e,n,i;for(n=this.shapes,i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(m(o));return i}.call(this)),x.call(t,"backgroundShapes")>=0&&(s.backgroundShapes=function(){var t,e,n,i;for(n=this.backgroundShapes,i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(m(o));return i}.call(this)),x.call(t,"imageSize")>=0&&(s.imageSize={width:this.width,height:this.height}),s},t.prototype.getSnapshotJSON=function(){return console.warn("lc.getSnapshotJSON() is deprecated. use JSON.stringify(lc.getSnapshot()) instead."),JSON.stringify(this.getSnapshot())},t.prototype.getSVGString=function(t){return null==t&&(t={}),g(this.getSnapshot(),t)},t.prototype.loadSnapshot=function(t){var e,n,i,o,s,h,l,c,u,p;if(t){if(t.colors)for(h=["primary","secondary","background"],e=0,o=h.length;o>e;e++)i=h[e],this.setColor(i,t.colors[i]);if(t.shapes)for(this.shapes=[],l=t.shapes,n=0,s=l.length;s>n;n++)p=l[n],u=r(p),u&&this.execute(new a.AddShapeAction(this,u));return t.backgroundShapes&&(this.backgroundShapes=function(){var e,n,i,o;for(i=t.backgroundShapes,o=[],e=0,n=i.length;n>e;e++)c=i[e],o.push(r(c));return o}()),t.imageSize&&(this.width=t.imageSize.width,this.height=t.imageSize.height),t.position&&(this.position=t.position),t.scale&&(this.scale=t.scale),this.repaintAllLayers(),this.trigger("snapshotLoad"),this.trigger("drawingChange",{})}},t.prototype.loadSnapshotJSON=function(t){return console.warn("lc.loadSnapshotJSON() is deprecated. use lc.loadSnapshot(JSON.parse(snapshot)) instead."),this.loadSnapshot(JSON.parse(t))},t}()},{"../tools/Pencil":48,"./actions":7,"./bindEvents":8,"./canvasRenderer":9,"./math":14,"./renderSnapshotToImage":15,"./renderSnapshotToSVG":16,"./shapes":17,"./svgRenderer":18,"./util":19}],6:[function(t,e,n){var i,r,o,s;t("./fontmetrics.js"),s=function(t){var e,n,i,r,o,s,a,h;for(n=t.split(" "),i=0,o=0,s=n.length;s>o;o++)r=n[o],a=parseInt(r.replace("px",""),10),isNaN(a)||(i=a);if(!i)throw"Font size not found";return h=t.substring(n[0].length+1).replace("bold ","").replace("italic ","").replace("underline ",""),e=h,{fontSize:i,fontFamily:e}},o=function(t,e,n){var i,r,o,s,a,h,l,c,u,p;if(!e.length)return["",""];for(r=0,h=0,l=0,p=!1;;)if(r+=1,o=r>=e.length,a=!o&&e[r].match(/\s/),s=a||o,u=e.substring(0,r),i=n?t.measureTextWidth(u).width<=n:!0,i&&(l=r),s&&p&&(p=!1,i&&(h=r)),p=!a,o||!i){if(i)return[e,""];if(h>0){for(c=h+1;c<e.length&&e[c].match("/s/");)c+=1;return[e.substring(0,h),e.substring(c)]}return[e.substring(0,l),e.substring(l)]}},r=function(t,e,n){var i,r,s,a,h,l,c,u,p;for(p=e.split(/\r\n|\r|\n/g),s=[],i=0,r=p.length;r>i;i++)if(u=p[i],h=o(t,u,n),a=h[0],c=h[1],a)for(;a;)s.push(a),l=o(t,c,n),a=l[0],c=l[1];else s.push(u);return s},i=function(){function t(t,e,n,i,o){var a,h,l;this.text=e,this.font=n,this.forcedWidth=i,this.forcedHeight=o,l=s(this.font),a=l.fontFamily,h=l.fontSize,t.font=this.font,t.textBaseline="baseline",this.emDashWidth=t.measureTextWidth("—",h,a).width,this.caratWidth=t.measureTextWidth("|",h,a).width,this.lines=r(t,this.text,this.forcedWidth),this.metricses=this.lines.map(function(e){return function(n){return t.measureText2(n||"X",h,e.font)}}(this)),this.metrics={ascent:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.ascent})),descent:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.descent})),fontsize:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.fontsize})),leading:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.leading})),width:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.width})),height:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.height})),bounds:{minx:Math.min.apply(Math,this.metricses.map(function(t){var e;return e=t.bounds,e.minx})),miny:Math.min.apply(Math,this.metricses.map(function(t){var e;return e=t.bounds,e.miny})),maxx:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.bounds,e.maxx})),maxy:Math.max.apply(Math,this.metricses.map(function(t){var e;return e=t.bounds,e.maxy}))}},this.boundingBoxWidth=Math.ceil(this.metrics.width)}return t.prototype.draw=function(t,e,n){var i,r,o,s,a,h;for(t.textBaseline="top",t.font=this.font,i=0,a=this.lines,h=[],r=0,o=a.length;o>r;r++)s=a[r],t.fillText(s,e,n+i*this.metrics.leading),h.push(i+=1);return h},t.prototype.getWidth=function(t){return null==t&&(t=!1),this.forcedWidth?this.forcedWidth:t?this.metrics.bounds.maxx+this.caratWidth:this.metrics.bounds.maxx},t.prototype.getHeight=function(){return this.forcedHeight||this.metrics.leading*this.lines.length},t}(),e.exports=i},{"./fontmetrics.js":11}],7:[function(t,e,n){var i,r;r=function(){function t(t,e,n){this.lc=t,this.oldShapes=e,this.newShapes=n}return t.prototype["do"]=function(){return this.lc.shapes=this.newShapes,this.lc.repaintLayer("main")},t.prototype.undo=function(){return this.lc.shapes=this.oldShapes,this.lc.repaintLayer("main")},t}(),i=function(){function t(t,e,n){this.lc=t,this.shape=e,this.previousShapeId=null!=n?n:null}return t.prototype["do"]=function(){var t,e,n,i,r,o;if(this.lc.shapes.length&&this.lc.shapes[this.lc.shapes.length-1].id!==this.previousShapeId&&null!==this.previousShapeId){for(i=[],t=!1,r=this.lc.shapes,e=0,n=r.length;n>e;e++)o=r[e],i.push(o),o.id===this.previousShapeId&&(i.push(this.shape),t=!0);t||i.push(this.shape),this.lc.shapes=i}else this.lc.shapes.push(this.shape);return this.lc.repaintLayer("main")},t.prototype.undo=function(){var t,e,n,i,r;if(this.lc.shapes[this.lc.shapes.length-1].id===this.shape.id)this.lc.shapes.pop();else{for(n=[],i=this.lc.shapes,t=0,e=i.length;e>t;t++)r=i[t],r.id!==this.shape.id&&n.push(r);lc.shapes=n}return this.lc.repaintLayer("main")},t}(),e.exports={ClearAction:r,AddShapeAction:i}},{}],8:[function(t,e,n){var i,r,o,s;o=function(t,e){var n,i,r;return i=e.changedTouches[0].clientX,r=e.changedTouches[0].clientY,n=t.getBoundingClientRect(),[i-n.left,r-n.top]},s=function(t,e){var n;return n=t.getBoundingClientRect(),{left:e.clientX-n.left,top:e.clientY-n.top}},r=function(t){return null!=t.buttons?1===t.buttons:t.which>0},e.exports=i=function(t,e,n){var i,r,a,h,l,c;return null==n&&(n=!1),c=[],r=function(n){return function(n){var i;return n.preventDefault(),i=s(e,n),t.pointerMove(i.left,i.top)}}(this),a=function(n){return function(n){var i;return n.preventDefault(),e.onselectstart=function(){return!0},i=s(e,n),t.pointerUp(i.left,i.top),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",a),e.addEventListener("mousemove",r)}}(this),e.addEventListener("mousedown",function(n){return function(n){var i,o;if("canvas"===n.target.tagName.toLowerCase())return i=!0,n.preventDefault(),e.onselectstart=function(){return!1},o=s(e,n),t.pointerDown(o.left,o.top),e.removeEventListener("mousemove",r),document.addEventListener("mousemove",r),document.addEventListener("mouseup",a)}}(this)),l=function(n){return n.preventDefault(),t.pointerMove.apply(t,o(e,n))},h=function(n){return n.preventDefault(),t.pointerUp.apply(t,o(e,n)),document.removeEventListener("touchmove",l),document.removeEventListener("touchend",h),document.removeEventListener("touchcancel",h)},e.addEventListener("touchstart",function(n){return"canvas"===n.target.tagName.toLowerCase()?(n.preventDefault(),1===n.touches.length?(t.pointerDown.apply(t,o(e,n)),document.addEventListener("touchmove",l),document.addEventListener("touchend",h),document.addEventListener("touchcancel",h)):t.pointerMove.apply(t,o(e,n))):void 0}),n&&(console.warn("Keyboard panning is deprecated."),i=function(e){switch(e.keyCode){case 37:t.pan(-10,0);break;case 38:t.pan(0,-10);break;case 39:t.pan(10,0);break;case 40:t.pan(0,10)}return t.repaintAllLayers()},document.addEventListener("keydown",i),c.push(function(){return document.removeEventListener(i)})),function(){var t,e,n,i;for(i=[],e=0,n=c.length;n>e;e++)t=c[e],i.push(t());return i}}},{}],9:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d;l=t("./lineEndCapShapes"),d={},r=function(t,e,n){return d[t]={drawFunc:e,drawLatestFunc:n}},c=function(){},p=function(t,e,n){var i;if(null==n&&(n={}),null==n.shouldIgnoreUnsupportedShapes&&(n.shouldIgnoreUnsupportedShapes=!1),null==n.retryCallback&&(n.retryCallback=c),null==n.shouldOnlyDrawLatest&&(n.shouldOnlyDrawLatest=!1),null==n.bufferCtx&&(n.bufferCtx=null),i=n.bufferCtx,d[e.className])return n.shouldOnlyDrawLatest&&d[e.className].drawLatestFunc?d[e.className].drawLatestFunc(t,i,e,n.retryCallback):d[e.className].drawFunc(t,e,n.retryCallback);if(n.shouldIgnoreUnsupportedShapes)return console.warn("Can't render shape of type "+e.className+" to canvas");throw"Can't render shape of type "+e.className+" to canvas"},u=function(t,e,n){return p(t.getContext("2d"),e,n)},r("Rectangle",function(t,e){var n,i;return n=e.x,i=e.y,e.strokeWidth%2!==0&&(n+=.5,i+=.5),t.fillStyle=e.fillColor,t.fillRect(n,i,e.width,e.height),t.lineWidth=e.strokeWidth,t.strokeStyle=e.strokeColor,t.strokeRect(n,i,e.width,e.height)}),r("Ellipse",function(t,e){var n,i,r,o;return t.save(),o=Math.floor(e.width/2),r=Math.floor(e.height/2),n=e.x+o,i=e.y+r,t.translate(n,i),t.scale(1,Math.abs(e.height/e.width)),t.beginPath(),t.arc(0,0,Math.abs(o),0,2*Math.PI),t.closePath(),t.restore(),t.fillStyle=e.fillColor,t.fill(),t.lineWidth=e.strokeWidth,t.strokeStyle=e.strokeColor,t.stroke()}),r("SelectionBox",function(){var t;return t=function(t,e,n){var i,r;return i=e.x,r=e.y,0!==n?(t.fillStyle="#fff",t.fillRect(i,r,n,n),t.strokeStyle="#000",t.strokeRect(i,r,n,n)):void 0},function(e,n){return t(e,n.getTopLeftHandleRect(),n.handleSize),t(e,n.getTopRightHandleRect(),n.handleSize),t(e,n.getBottomLeftHandleRect(),n.handleSize),t(e,n.getBottomRightHandleRect(),n.handleSize),n.backgroundColor&&(e.fillStyle=n.backgroundColor,e.fillRect(n._br.x-n.margin,n._br.y-n.margin,n._br.width+2*n.margin,n._br.height+2*n.margin)),e.lineWidth=1,e.strokeStyle="#000",e.setLineDash([2,4]),e.strokeRect(n._br.x-n.margin,n._br.y-n.margin,n._br.width+2*n.margin,n._br.height+2*n.margin),e.setLineDash([])}}()),r("Image",function(t,e,n){return e.image.width?1===e.scale?t.drawImage(e.image,e.x,e.y):t.drawImage(e.image,e.x,e.y,e.image.width*e.scale,e.image.height*e.scale):n?e.image.onload=n:void 0}),r("Line",function(t,e){var n,i,r,o,s;if(e.x1!==e.x2||e.y1!==e.y2)return i=e.x1,r=e.x2,o=e.y1,s=e.y2,e.strokeWidth%2!==0&&(i+=.5,r+=.5,o+=.5,s+=.5),t.lineWidth=e.strokeWidth,t.strokeStyle=e.color,t.lineCap=e.capStyle,e.dash&&t.setLineDash(e.dash),t.beginPath(),t.moveTo(i,o),t.lineTo(r,s),t.stroke(),e.dash&&t.setLineDash([]),n=Math.max(2.2*e.strokeWidth,5),e.endCapShapes[0]&&l[e.endCapShapes[0]].drawToCanvas(t,i,o,Math.atan2(o-s,i-r),n,e.color),e.endCapShapes[1]?l[e.endCapShapes[1]].drawToCanvas(t,r,s,Math.atan2(s-o,r-i),n,e.color):void 0}),i=function(t,e,n,i){var r,o,s,a;if(null==n&&(n=!1),null==i&&(i="round"),e.length){for(t.lineCap=i,t.strokeStyle=e[0].color,t.lineWidth=e[0].size,t.beginPath(),e[0].size%2===0?t.moveTo(e[0].x,e[0].y):t.moveTo(e[0].x+.5,e[0].y+.5),a=e.slice(1),r=0,o=a.length;o>r;r++)s=a[r],e[0].size%2===0?t.lineTo(s.x,s.y):t.lineTo(s.x+.5,s.y+.5);return n?t.closePath():void 0}},a=function(t,e){return i(t,e.smoothedPoints),t.stroke()},h=function(t,e,n){var r,o,s;return n.tail?(s=n.smoothedPoints.length-n.segmentSize*n.tailSize,o=s<2*n.segmentSize?0:s,r=s+n.segmentSize+1,i(e,n.smoothedPoints.slice(o,r)),e.stroke()):(i(e,n.smoothedPoints),e.stroke())},r("LinePath",a,h),o=function(t,e){return t.save(),t.globalCompositeOperation="destination-out",a(t,e),t.restore()},s=function(t,e,n){return t.save(),t.globalCompositeOperation="destination-out",e.save(),e.globalCompositeOperation="destination-out",h(t,e,n),t.restore(),e.restore()},r("ErasedLinePath",o,s),r("Text",function(t,e){return e.renderer||e._makeRenderer(t),t.fillStyle=e.color,e.renderer.draw(t,e.x,e.y)}),r("Polygon",function(t,e){return t.fillStyle=e.fillColor,i(t,e.points,e.isClosed,"butt"),t.fill(),t.stroke()}),e.exports={defineCanvasRenderer:r,renderShapeToCanvas:u,renderShapeToContext:p}},{"./lineEndCapShapes":12}],10:[function(t,e,n){"use strict";e.exports={imageURLPrefix:"lib/img",primaryColor:"hsla(0, 0%, 0%, 1)",secondaryColor:"hsla(0, 0%, 100%, 1)",backgroundColor:"transparent",strokeWidths:[1,2,5,10,20,30],defaultStrokeWidth:5,toolbarPosition:"top",keyboardShortcuts:!1,imageSize:{width:"infinite",height:"infinite"},backgroundShapes:[],watermarkImage:null,watermarkScale:1,zoomMin:.2,zoomMax:4,zoomStep:.2,snapshot:null,onInit:function(){},tools:[t("../tools/Pencil"),t("../tools/Eraser"),t("../tools/Line"),t("../tools/Rectangle"),t("../tools/Ellipse"),t("../tools/Text"),t("../tools/Polygon"),t("../tools/Pan"),t("../tools/Eyedropper")]}},{"../tools/Ellipse":43,"../tools/Eraser":44,"../tools/Eyedropper":45,"../tools/Line":46,"../tools/Pan":47,"../tools/Pencil":48,"../tools/Polygon":49,"../tools/Rectangle":50,"../tools/Text":52}],11:[function(t,e,n){"use strict";!function(){if(!document.defaultView.getComputedStyle)throw"ERROR: 'document.defaultView.getComputedStyle' not found. This library only works in browsers that can report computed CSS values.";CanvasRenderingContext2D.prototype.measureTextWidth=CanvasRenderingContext2D.prototype.measureText;var t=function(t,e){return document.defaultView.getComputedStyle(t,null).getPropertyValue(e)};CanvasRenderingContext2D.prototype.measureText2=function(e,n,i){var r=this.measureTextWidth(e),o=!/\S/.test(e);r.fontsize=n;var s=document.createElement("div");s.style.position="absolute",s.style.opacity=0,s.style.font=i,s.innerHTML=e+"<br/>"+e,document.body.appendChild(s),r.leading=1.2*n;var a=t(s,"height");if(a=a.replace("px",""),a>=2*n&&(r.leading=a/2|0),document.body.removeChild(s),o)r.ascent=0,r.descent=0,r.bounds={minx:0,maxx:r.width,miny:0,maxy:0},r.height=0;else{var h=document.createElement("canvas"),l=100;h.width=r.width+l,h.height=3*n,h.style.opacity=1,h.style.font=i;var c=h.getContext("2d");c.font=i;var u=h.width,p=h.height,d=p/2;c.fillStyle="white",c.fillRect(-1,-1,u+2,p+2),c.fillStyle="black",c.fillText(e,l/2,d);for(var f=c.getImageData(0,0,u,p).data,g=0,m=4*u,y=f.length;++g<y&&255===f[g];);var S=g/m|0;for(g=y-1;--g>0&&255===f[g];);var v=g/m|0;for(g=0;y>g&&255===f[g];)g+=m,g>=y&&(g=g-y+4);var x=g%m/4|0,w=1;for(g=y-3;g>=0&&255===f[g];)g-=m,0>g&&(g=y-3-4*w++);var k=g%m/4+1|0;r.ascent=d-S,r.descent=v-d,r.bounds={minx:x-l/2,maxx:k-l/2,miny:0,maxy:v-S},r.height=1+(v-S)}return r}}()},{}],12:[function(t,e,n){e.exports={arrow:function(){var t;return t=function(t,e,n,i,r){return[{x:t+Math.cos(n+Math.PI/2)*i/2,y:e+Math.sin(n+Math.PI/2)*i/2},{x:t+Math.cos(n)*r,y:e+Math.sin(n)*r},{x:t+Math.cos(n-Math.PI/2)*i/2,y:e+Math.sin(n-Math.PI/2)*i/2}]},{drawToCanvas:function(e,n,i,r,o,s,a){var h;return null==a&&(a=0),a=a||o,e.fillStyle=s,e.lineWidth=0,e.strokeStyle="transparent",e.beginPath(),h=t(n,i,r,o,a),e.moveTo(h[0].x,h[0].y),e.lineTo(h[1].x,h[1].y),e.lineTo(h[2].x,h[2].y),e.fill()},svg:function(e,n,i,r,o,s){var a;return null==s&&(s=0),s=s||r,a=t(e,n,i,r,s),"<polygon fill='"+o+"' stroke='none' points='"+a.map(function(t){return t.x+","+t.y})+"' />"}}}()}},{}],13:[function(t,e,n){var i,r,o;o={},r=function(t){return o=t},i=function(t){var e;return e=o[t],e||t},e.exports={localize:r,_:i}},{}],14:[function(t,e,n){var i,r,o,s,a,h;i=t("./shapes").Point,h=t("./util"),o={},o.toPoly=function(t){var e,n,i,o,a,h,l;for(h=[],l=[],n=0,e=0,i=t.length;i>e;e++)a=t[e],o=s(a,r(t,n)),h=h.concat([o[0]]),l=[o[1]].concat(l),n+=1;return h.concat(l)},r=function(t,e){var n;return t.length<3&&(n={x:0,y:0}),n=0===e?r(t,e+1):e===t.length-1?r(t,e-1):o.diff(t[e-1],t[e+1])},o.diff=function(t,e){return{x:e.x-t.x,y:e.y-t.y}},a=function(t){var e;return e=o.len(t),{x:t.x/e,y:t.y/e}},s=function(t,e){return e=a(e),e.x=e.x*t.size/2,e.y=e.y*t.size/2,[{x:t.x-e.y,y:t.y+e.x,color:t.color},{x:t.x+e.y,y:t.y-e.x,color:t.color}]},o.len=function(t){return Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2))},o.scalePositionScalar=function(t,e,n,i){var r,o;return o=e*n,r=e*i,t+(o-r)/2},e.exports=o},{"./shapes":17,"./util":19}],15:[function(t,e,n){var i,r,o,s;s=t("./util"),r=t("./shapes").JSONToShape,i="infinite",o=function(t,e,n){return e.width?(t.save(),t.translate(t.canvas.width/2,t.canvas.height/2),t.scale(n,n),t.drawImage(e,-e.width/2,-e.height/2),t.restore()):void 0},e.exports=function(t,e){var n,a,h,l,c,u,p,d;return null==e&&(e={}),null==e.scale&&(e.scale=1),u=function(){var e,n,i,o;for(i=t.shapes,o=[],e=0,n=i.length;n>e;e++)c=i[e],o.push(r(c));return o}(),a=[],t.backgroundShapes&&(a=function(){var e,n,i,o;for(i=t.backgroundShapes,o=[],e=0,n=i.length;n>e;e++)c=i[e],o.push(r(c));return o}()),null==e.margin&&(e.margin={top:0,right:0,bottom:0,left:0}),l=t.imageSize||{width:i,height:i},h=t.colors||{background:"transparent"},n=u.concat(a),p=document.createElement("canvas"),d=p.getContext("2d"),e.rect?(e.rect.x-=e.margin.left,e.rect.y-=e.margin.top,e.rect.width+=e.margin.left+e.margin.right,e.rect.height+=e.margin.top+e.margin.bottom):e.rect=s.getDefaultImageRect(function(){var t,e,i;for(i=[],t=0,e=n.length;e>t;t++)c=n[t],i.push(c.getBoundingRect(d));return i}(),l,e.margin),p.width=e.rect.width*e.scale,p.height=e.rect.height*e.scale,d.fillStyle=h.background,d.fillRect(0,0,p.width,p.height),e.rect.width&&e.rect.height?(e.watermarkImage&&o(d,e.watermarkImage,e.watermarkScale),s.combineCanvases(p,s.renderShapes(a,e.rect,e.scale),s.renderShapes(u,e.rect,e.scale))):null}},{"./shapes":17,"./util":19}],16:[function(t,e,n){
  var i,r,o;o=t("./util"),r=t("./shapes").JSONToShape,i="infinite",e.exports=function(t,e){var n,s,a,h,l,c,u,p;return null==e&&(e={}),p=function(){var e,n,i,o;for(i=t.shapes,o=[],e=0,n=i.length;n>e;e++)u=i[e],o.push(r(u));return o}(),s=[],t.backgroundShapes&&(s=function(){var e,n,i,o;for(i=t.backgroundShapes,o=[],e=0,n=i.length;n>e;e++)u=i[e],o.push(r(u));return o}()),null==e.margin&&(e.margin={top:0,right:0,bottom:0,left:0}),c=t.imageSize||{width:i,height:i},a=t.colors||{background:"transparent"},n=p.concat(s),l=document.createElement("canvas"),h=l.getContext("2d"),e.rect?(e.rect.x-=e.margin.left,e.rect.y-=e.margin.top,e.rect.width+=e.margin.left+e.margin.right,e.rect.height+=e.margin.top+e.margin.bottom):e.rect=o.getDefaultImageRect(function(){var t,e,i;for(i=[],t=0,e=n.length;e>t;t++)u=n[t],i.push(u.getBoundingRect(h));return i}(),c,e.margin),LC.renderShapesToSVG(s.concat(p),e.rect,a.background)}},{"./shapes":17,"./util":19}],17:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d,f,g,m,y,S,v,x,w,k,b,C;C=t("./util"),o=t("./TextRenderer"),m=t("./lineEndCapShapes"),S=t("./canvasRenderer"),d=S.defineCanvasRenderer,x=S.renderShapeToContext,v=t("./svgRenderer"),f=v.defineSVGRenderer,w=v.renderShapeToSVG,b={},g=function(t,e){var n,i,r,o,s,a,h,l;n=function(t,n,i,r,o,s,a,h,l,c,u,p,d,f,g,m){return e.constructor.call(this,t,n,i,r,o,s,a,h,l,c,u,p,d,f,g,m),this},n.prototype.className=t,n.fromJSON=e.fromJSON,e.draw&&(s=e.draw,a=e.draw||function(t,e,n){return this.draw(t,e,n)},i=function(t,e,n){return s.call(e,t,n)},r=function(t,e,n,i){return a.call(n,t,e,i)},delete e.draw,e.drawLatest&&delete e.drawLatest,d(t,i,r)),e.toSVG&&(h=e.toSVG,l=function(t){return h.call(t)},delete e.toSVG,f(t,l)),n.prototype.draw=function(t,e){return x(t,this,{retryCallback:e})},n.prototype.drawLatest=function(t,e,n){return x(t,this,{retryCallback:n,bufferCtx:e,shouldOnlyDrawLatest:!0})},n.prototype.toSVG=function(){return w(this)};for(o in e)"fromJSON"!==o&&(n.prototype[o]=e[o]);return b[t]=n,n},p=function(t,e,n,i,r,o,s,a,h,l,c,u,p,d,f,g,m){var y;return y=new b[t](e,n,i,r,o,s,a,h,l,c,u,p,d,f,g,m),y.id=C.getGUID(),y},i=function(t){var e,n,i,r;return e=t.className,n=t.data,i=t.id,e in b?(r=b[e].fromJSON(n),r?(i&&(r.id=i),r):(console.log("Unreadable shape:",e,n),null)):(console.log("Unknown shape:",e,n),null)},k=function(t){return{className:t.className,data:t.toJSON(),id:t.id}},u=function(t,e){return e?u(h(h(c(t))),e-1):t},c=function(t){var e,n,i,r,o;for(t=[t[0]].concat(t).concat(C.last(t)),o=[],e=0,r=0,n=t.length;n>r;r++)i=t[r],o[2*e]=i,t[e+1]&&(o[2*e+1]=l(i,t[e+1])),e+=1;return o},h=function(t){var e,n,i,r,o;for(e=[],n=0,o=0,i=t.length;i>o;o++)r=t[o],t[n+1]&&(e[n]=l(r,t[n+1])),n+=1;return e},l=function(t,e){return p("Point",{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2,size:t.size+(e.size-t.size)/2,color:t.color})},g("Image",{constructor:function(t){return null==t&&(t={}),this.x=t.x||0,this.y=t.y||0,this.scale=t.scale||1,this.image=t.image||null},getBoundingRect:function(){return{x:this.x,y:this.y,width:this.image.width*this.scale,height:this.image.height*this.scale}},toJSON:function(){return{x:this.x,y:this.y,imageSrc:this.image.src,imageObject:this.image,scale:this.scale}},fromJSON:function(t){var e,n;return e=null,(null!=(n=t.imageObject)?n.width:void 0)?e=t.imageObject:(e=new Image,e.src=t.imageSrc),p("Image",{x:t.x,y:t.y,image:e,scale:t.scale})},move:function(t){return null==t&&(t={}),this.x=this.x-t.xDiff,this.y=this.y-t.yDiff},setUpperLeft:function(t){return null==t&&(t={}),this.x=t.x,this.y=t.y}}),g("Rectangle",{constructor:function(t){return null==t&&(t={}),this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.strokeWidth=t.strokeWidth||1,this.strokeColor=t.strokeColor||"black",this.fillColor=t.fillColor||"transparent"},getBoundingRect:function(){return{x:this.x-this.strokeWidth/2,y:this.y-this.strokeWidth/2,width:this.width+this.strokeWidth,height:this.height+this.strokeWidth}},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height,strokeWidth:this.strokeWidth,strokeColor:this.strokeColor,fillColor:this.fillColor}},fromJSON:function(t){return p("Rectangle",t)},move:function(t){return null==t&&(t={}),this.x=this.x-t.xDiff,this.y=this.y-t.yDiff},setUpperLeft:function(t){return null==t&&(t={}),this.x=t.x,this.y=t.y}}),g("Ellipse",{constructor:function(t){return null==t&&(t={}),this.x=t.x||0,this.y=t.y||0,this.width=t.width||0,this.height=t.height||0,this.strokeWidth=t.strokeWidth||1,this.strokeColor=t.strokeColor||"black",this.fillColor=t.fillColor||"transparent"},getBoundingRect:function(){return{x:this.x-this.strokeWidth/2,y:this.y-this.strokeWidth/2,width:this.width+this.strokeWidth,height:this.height+this.strokeWidth}},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height,strokeWidth:this.strokeWidth,strokeColor:this.strokeColor,fillColor:this.fillColor}},fromJSON:function(t){return p("Ellipse",t)},move:function(t){return null==t&&(t={}),this.x=this.x-t.xDiff,this.y=this.y-t.yDiff},setUpperLeft:function(t){return null==t&&(t={}),this.x=t.x,this.y=t.y}}),g("Line",{constructor:function(t){return null==t&&(t={}),this.x1=t.x1||0,this.y1=t.y1||0,this.x2=t.x2||0,this.y2=t.y2||0,this.strokeWidth=t.strokeWidth||1,this.color=t.color||"black",this.capStyle=t.capStyle||"round",this.endCapShapes=t.endCapShapes||[null,null],this.dash=t.dash||null},getBoundingRect:function(){return{x:Math.min(this.x1,this.x2)-this.strokeWidth/2,y:Math.min(this.y1,this.y2)-this.strokeWidth/2,width:Math.abs(this.x2-this.x1)+this.strokeWidth/2,height:Math.abs(this.y2-this.y1)+this.strokeWidth/2}},toJSON:function(){return{x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,strokeWidth:this.strokeWidth,color:this.color,capStyle:this.capStyle,dash:this.dash,endCapShapes:this.endCapShapes}},fromJSON:function(t){return p("Line",t)},move:function(t){return null==t&&(t={}),this.x1=this.x1-t.xDiff,this.y1=this.y1-t.yDiff,this.x2=this.x2-t.xDiff,this.y2=this.y2-t.yDiff},setUpperLeft:function(t){var e,n,i;return null==t&&(t={}),e=this.getBoundingRect(),n=e.x-t.x,i=e.y-t.y,this.move({xDiff:n,yDiff:i})}}),a=function(t){var e,n,i,r,o;if(!t.length)return!1;for(o=t[0].size,e=t[0].color,r=0,n=t.length;n>r;r++)if(i=t[r],i.size===o&&i.color===e||console.log(o,e,i.size,i.color),i.size!==o||i.color!==e)return!1;return!0},s=function(t,e){var n,r,o,s,a;return r=null,e.points?r=function(){var t,r,o,s;for(o=e.points,s=[],r=0,t=o.length;t>r;r++)n=o[r],s.push(i(n));return s}():e.pointCoordinatePairs&&(r=function(){var t,n,r,o,h;for(r=e.pointCoordinatePairs,h=[],n=0,t=r.length;t>n;n++)o=r[n],s=o[0],a=o[1],h.push(i({className:"Point",data:{x:s,y:a,size:e.pointSize,color:e.pointColor,smooth:e.smooth}}));return h}()),o=null,e.smoothedPointCoordinatePairs&&(o=function(){var t,n,r,o,h;for(r=e.smoothedPointCoordinatePairs,h=[],n=0,t=r.length;t>n;n++)o=r[n],s=o[0],a=o[1],h.push(i({className:"Point",data:{x:s,y:a,size:e.pointSize,color:e.pointColor,smooth:e.smooth}}));return h}()),r[0]?p(t,{points:r,smoothedPoints:o,order:e.order,tailSize:e.tailSize,smooth:e.smooth}):null},y={constructor:function(t){var e,n,i,r,o;if(null==t&&(t={}),i=t.points||[],this.order=t.order||3,this.tailSize=t.tailSize||3,this.smooth="smooth"in t?t.smooth:!0,this.segmentSize=Math.pow(2,this.order),this.sampleSize=this.tailSize+1,t.smoothedPoints)return this.points=t.points,this.smoothedPoints=t.smoothedPoints;for(this.points=[],o=[],r=0,e=i.length;e>r;r++)n=i[r],o.push(this.addPoint(n));return o},getBoundingRect:function(){return C.getBoundingRect(this.points.map(function(t){return{x:t.x-t.size/2,y:t.y-t.size/2,width:t.size,height:t.size}}))},toJSON:function(){var t,e;return a(this.points)?{order:this.order,tailSize:this.tailSize,smooth:this.smooth,pointCoordinatePairs:function(){var t,n,i,r;for(i=this.points,r=[],n=0,t=i.length;t>n;n++)e=i[n],r.push([e.x,e.y]);return r}.call(this),smoothedPointCoordinatePairs:function(){var t,n,i,r;for(i=this.smoothedPoints,r=[],n=0,t=i.length;t>n;n++)e=i[n],r.push([e.x,e.y]);return r}.call(this),pointSize:this.points[0].size,pointColor:this.points[0].color}:{order:this.order,tailSize:this.tailSize,smooth:this.smooth,points:function(){var e,n,i,r;for(i=this.points,r=[],n=0,e=i.length;e>n;n++)t=i[n],r.push(k(t));return r}.call(this)}},fromJSON:function(t){return s("LinePath",t)},addPoint:function(t){return this.points.push(t),this.smooth?!this.smoothedPoints||this.points.length<this.sampleSize?this.smoothedPoints=u(this.points,this.order):(this.tail=C.last(u(C.last(this.points,this.sampleSize),this.order),this.segmentSize*this.tailSize),this.smoothedPoints=this.smoothedPoints.slice(0,this.smoothedPoints.length-this.segmentSize*(this.tailSize-1)).concat(this.tail)):void(this.smoothedPoints=this.points)},move:function(t){var e,n,i,r;for(null==t&&(t={}),i=this.smooth?this.smoothedPoints:this.points,r=0,e=i.length;e>r;r++)n=i[r],n.move(t);return this.points=this.smoothedPoints},setUpperLeft:function(t){var e,n,i;return null==t&&(t={}),e=this.getBoundingRect(),n=e.x-t.x,i=e.y-t.y,this.move({xDiff:n,yDiff:i})}},r=g("LinePath",y),g("ErasedLinePath",{constructor:y.constructor,toJSON:y.toJSON,addPoint:y.addPoint,getBoundingRect:y.getBoundingRect,fromJSON:function(t){return s("ErasedLinePath",t)}}),g("Point",{constructor:function(t){return null==t&&(t={}),this.x=t.x||0,this.y=t.y||0,this.size=t.size||0,this.color=t.color||""},getBoundingRect:function(){return{x:this.x-this.size/2,y:this.y-this.size/2,width:this.size,height:this.size}},toJSON:function(){return{x:this.x,y:this.y,size:this.size,color:this.color}},fromJSON:function(t){return p("Point",t)},move:function(t){return null==t&&(t={}),this.x=this.x-t.xDiff,this.y=this.y-t.yDiff},setUpperLeft:function(t){return null==t&&(t={}),this.x=t.x,this.y=t.y}}),g("Polygon",{constructor:function(t){var e,n,i,r,o;for(null==t&&(t={}),this.points=t.points,this.fillColor=t.fillColor||"white",this.strokeColor=t.strokeColor||"black",this.strokeWidth=t.strokeWidth,this.dash=t.dash||null,null==t.isClosed&&(t.isClosed=!0),this.isClosed=t.isClosed,r=this.points,o=[],i=0,e=r.length;e>i;i++)n=r[i],n.color=this.strokeColor,o.push(n.size=this.strokeWidth);return o},addPoint:function(t,e){return this.points.push(LC.createShape("Point",{x:t,y:e}))},getBoundingRect:function(){return C.getBoundingRect(this.points.map(function(t){return t.getBoundingRect()}))},toJSON:function(){return{strokeWidth:this.strokeWidth,fillColor:this.fillColor,strokeColor:this.strokeColor,dash:this.dash,isClosed:this.isClosed,pointCoordinatePairs:this.points.map(function(t){return[t.x,t.y]})}},fromJSON:function(t){return t.points=t.pointCoordinatePairs.map(function(e){var n,i;return n=e[0],i=e[1],p("Point",{x:n,y:i,size:t.strokeWidth,color:t.strokeColor})}),p("Polygon",t)},move:function(t){var e,n,i,r,o;for(null==t&&(t={}),r=this.points,o=[],i=0,e=r.length;e>i;i++)n=r[i],o.push(n.move(t));return o},setUpperLeft:function(t){var e,n,i;return null==t&&(t={}),e=this.getBoundingRect(),n=e.x-t.x,i=e.y-t.y,this.move({xDiff:n,yDiff:i})}}),g("Text",{constructor:function(t){return null==t&&(t={}),this.x=t.x||0,this.y=t.y||0,this.v=t.v||0,this.text=t.text||"",this.color=t.color||"black",this.font=t.font||"18px sans-serif",this.forcedWidth=t.forcedWidth||null,this.forcedHeight=t.forcedHeight||null},_makeRenderer:function(t){return t.lineHeight=1.2,this.renderer=new o(t,this.text,this.font,this.forcedWidth,this.forcedHeight),this.v<1?(console.log("repairing baseline"),this.v=1,this.x-=this.renderer.metrics.bounds.minx,this.y-=this.renderer.metrics.leading-this.renderer.metrics.descent):void 0},setText:function(t){return this.text=t,this.renderer=null},setFont:function(t){return this.font=t,this.renderer=null},setPosition:function(t,e){return this.x=t,this.y=e},setSize:function(t,e){return this.forcedWidth=Math.max(t,0),this.forcedHeight=Math.max(e,0),this.renderer=null},enforceMaxBoundingRect:function(t){var e,n,i;return e=this.getBoundingRect(t.ctx),i={x:-t.position.x/t.scale,y:-t.position.y/t.scale,width:t.canvas.width/t.scale,height:t.canvas.height/t.scale},e.x+e.width>i.x+i.width?(n=e.x-i.x,this.forcedWidth=i.width-n-10,this.renderer=null):void 0},getBoundingRect:function(t,e){if(null==e&&(e=!1),!this.renderer){if(!t)throw"Must pass ctx if text hasn't been rendered yet";this._makeRenderer(t)}return{x:Math.floor(this.x),y:Math.floor(this.y),width:Math.ceil(this.renderer.getWidth(!0)),height:Math.ceil(this.renderer.getHeight())}},toJSON:function(){return{x:this.x,y:this.y,text:this.text,color:this.color,font:this.font,forcedWidth:this.forcedWidth,forcedHeight:this.forcedHeight,v:this.v}},fromJSON:function(t){return p("Text",t)},move:function(t){return null==t&&(t={}),this.x=this.x-t.xDiff,this.y=this.y-t.yDiff},setUpperLeft:function(t){return null==t&&(t={}),this.x=t.x,this.y=t.y}}),g("SelectionBox",{constructor:function(t){return null==t&&(t={}),this.shape=t.shape,null!=t.handleSize?this.handleSize=t.handleSize:this.handleSize=10,this.margin=4,this.backgroundColor=t.backgroundColor||null,this._br=this.shape.getBoundingRect(t.ctx)},toJSON:function(){return{shape:k(this.shape),backgroundColor:this.backgroundColor}},fromJSON:function(t){var e,n,r,o;return o=t.shape,n=t.handleSize,r=t.margin,e=t.backgroundColor,p("SelectionBox",{shape:i(o),backgroundColor:e})},getTopLeftHandleRect:function(){return{x:this._br.x-this.handleSize-this.margin,y:this._br.y-this.handleSize-this.margin,width:this.handleSize,height:this.handleSize}},getBottomLeftHandleRect:function(){return{x:this._br.x-this.handleSize-this.margin,y:this._br.y+this._br.height+this.margin,width:this.handleSize,height:this.handleSize}},getTopRightHandleRect:function(){return{x:this._br.x+this._br.width+this.margin,y:this._br.y-this.handleSize-this.margin,width:this.handleSize,height:this.handleSize}},getBottomRightHandleRect:function(){return{x:this._br.x+this._br.width+this.margin,y:this._br.y+this._br.height+this.margin,width:this.handleSize,height:this.handleSize}},getBoundingRect:function(){return{x:this._br.x-this.margin,y:this._br.y-this.margin,width:this._br.width+2*this.margin,height:this._br.height+2*this.margin}}}),e.exports={defineShape:g,createShape:p,JSONToShape:i,shapeToJSON:k}},{"./TextRenderer":6,"./canvasRenderer":9,"./lineEndCapShapes":12,"./svgRenderer":18,"./util":19}],18:[function(t,e,n){var i,r,o,s;r=t("./lineEndCapShapes"),s={},i=function(t,e){return s[t]=e},o=function(t,e){if(null==e&&(e={}),null==e.shouldIgnoreUnsupportedShapes&&(e.shouldIgnoreUnsupportedShapes=!1),s[t.className])return s[t.className](t);if(e.shouldIgnoreUnsupportedShapes)return console.warn("Can't render shape of type "+t.className+" to SVG"),"";throw"Can't render shape of type "+t.className+" to SVG"},i("Rectangle",function(t){var e,n,i,r,o,s,a,h;return r=t.x,a=t.y,o=t.x+t.width,h=t.y+t.height,i=Math.min(r,o),s=Math.min(a,h),n=Math.max(r,o)-i,e=Math.max(a,h)-s,t.strokeWidth%2!==0&&(i+=.5,s+=.5),"<rect x='"+i+"' y='"+s+"' width='"+n+"' height='"+e+"' stroke='"+t.strokeColor+"' fill='"+t.fillColor+"' stroke-width='"+t.strokeWidth+"' />"}),i("SelectionBox",function(t){return""}),i("Ellipse",function(t){var e,n,i,r;return r=Math.floor(t.width/2),i=Math.floor(t.height/2),e=t.x+r,n=t.y+i,"<ellipse cx='"+e+"' cy='"+n+"' rx='"+Math.abs(r)+"' ry='"+Math.abs(i)+"' stroke='"+t.strokeColor+"' fill='"+t.fillColor+"' stroke-width='"+t.strokeWidth+"' />"}),i("Image",function(t){return"<image x='"+t.x+"' y='"+t.y+"' width='"+t.image.naturalWidth*t.scale+"' height='"+t.image.naturalHeight*t.scale+"' xlink:href='"+t.image.src+"' />"}),i("Line",function(t){var e,n,i,o,s,a,h;return i=t.dash?"stroke-dasharray='"+t.dash.join(", ")+"'":"",n="",e=Math.max(2.2*t.strokeWidth,5),o=t.x1,s=t.x2,a=t.y1,h=t.y2,t.strokeWidth%2!==0&&(o+=.5,s+=.5,a+=.5,h+=.5),t.endCapShapes[0]&&(n+=r[t.endCapShapes[0]].svg(o,a,Math.atan2(a-h,o-s),e,t.color)),t.endCapShapes[1]&&(n+=r[t.endCapShapes[1]].svg(s,h,Math.atan2(h-a,s-o),e,t.color)),"<g> <line x1='"+o+"' y1='"+a+"' x2='"+s+"' y2='"+h+"' "+i+" stroke-linecap='"+t.capStyle+"' stroke='"+t.color+" 'stroke-width='"+t.strokeWidth+"' /> "+n+" </g>"}),i("LinePath",function(t){return"<polyline fill='none' points='"+t.smoothedPoints.map(function(t){var e;return e=t.strokeWidth%2===0?0:.5,t.x+e+","+(t.y+e)}).join(" ")+"' stroke='"+t.points[0].color+"' stroke-linecap='round' stroke-width='"+t.points[0].size+"' />"}),i("ErasedLinePath",function(t){return""}),i("Polygon",function(t){return t.isClosed?"<polygon fill='"+t.fillColor+"' points='"+t.points.map(function(t){var e;return e=t.strokeWidth%2===0?0:.5,t.x+e+","+(t.y+e)}).join(" ")+"' stroke='"+t.strokeColor+"' stroke-width='"+t.strokeWidth+"' />":"<polyline fill='"+t.fillColor+"' points='"+t.points.map(function(t){var e;return e=t.strokeWidth%2===0?0:.5,t.x+e+","+(t.y+e)}).join(" ")+"' stroke='none' /> <polyline fill='none' points='"+t.points.map(function(t){var e;return e=t.strokeWidth%2===0?0:.5,t.x+e+","+(t.y+e)}).join(" ")+"' stroke='"+t.strokeColor+"' stroke-width='"+t.strokeWidth+"' />"}),i("Text",function(t){var e,n,i;return i=t.forcedWidth?"width='"+t.forcedWidth+"px'":"",e=t.forcedHeight?"height='"+t.forcedHeight+"px'":"",n=t.text.split(/\r\n|\r|\n/g),t.renderer&&(n=t.renderer.lines),"<text x='"+t.x+"' y='"+t.y+"' "+i+" "+e+" fill='"+t.color+"' style='font: "+t.font+";'> "+n.map(function(e){return function(e,n){var i;return i=0===n?0:"1.2em","<tspan x='"+t.x+"' dy='"+i+"' alignment-baseline='text-before-edge'> "+e+" </tspan>"}}(this)).join("")+" </text>"}),e.exports={defineSVGRenderer:i,renderShapeToSVG:o}},{"./lineEndCapShapes":12}],19:[function(t,e,n){var i,r,o,s,a=[].slice;o=Array.prototype.slice,i=t("./canvasRenderer").renderShapeToContext,r=t("./svgRenderer").renderShapeToSVG,s={addImageOnload:function(t,e){var n;return n=t.onload,t.onload=function(){return"function"==typeof n&&n(),e()},t},last:function(t,e){return null==e&&(e=null),e?o.call(t,Math.max(t.length-e,0)):t[t.length-1]},classSet:function(t){var e,n;e=[];for(n in t)t[n]&&e.push(n);return e.join(" ")},matchElementSize:function(t,e,n,i){var r;return null==i&&(i=function(){}),r=function(r){return function(){var r,o,s;for(o=0,s=e.length;s>o;o++)r=e[o],r.style.width=t.offsetWidth+"px",r.style.height=t.offsetHeight+"px",null!=r.width&&(r.setAttribute("width",r.offsetWidth*n),r.setAttribute("height",r.offsetHeight*n));return i()}}(this),t.addEventListener("resize",r),window.addEventListener("resize",r),window.addEventListener("orientationchange",r),r(),r},combineCanvases:function(){var t,e,n,i,r,o,s,h;for(n=1<=arguments.length?a.call(arguments,0):[],t=document.createElement("canvas"),t.width=n[0].width,t.height=n[0].height,r=0,s=n.length;s>r;r++)e=n[r],t.width=Math.max(e.width,t.width),t.height=Math.max(e.height,t.height);for(i=t.getContext("2d"),o=0,h=n.length;h>o;o++)e=n[o],i.drawImage(e,0,0);return t},renderShapes:function(t,e,n,r){var o,s,a,h;for(null==n&&(n=1),null==r&&(r=null),r=r||document.createElement("canvas"),r.width=e.width*n,r.height=e.height*n,o=r.getContext("2d"),o.translate(-e.x*n,-e.y*n),o.scale(n,n),s=0,a=t.length;a>s;s++)h=t[s],i(o,h);return r},renderShapesToSVG:function(t,e,n){var i,o,s,a;return s=e.x,a=e.y,o=e.width,i=e.height,("<svg xmlns='http://www.w3.org/2000/svg' width='"+o+"' height='"+i+"' viewBox='0 0 "+o+" "+i+"'> <rect width='"+o+"' height='"+i+"' x='0' y='0' fill='"+n+"' /> <g transform='translate("+-s+", "+-a+")'> "+t.map(r).join("")+" </g> </svg>").replace(/(\r\n|\n|\r)/gm,"")},getBoundingRect:function(t,e,n){var i,r,o,s,a,h,l;if(!t.length)return{x:0,y:0,width:e,height:n};for(a=t[0].x,h=t[0].y,o=t[0].x+t[0].width,s=t[0].y+t[0].height,i=0,r=t.length;r>i;i++)l=t[i],a=Math.floor(Math.min(l.x,a)),h=Math.floor(Math.min(l.y,h)),o=Math.ceil(Math.max(o,l.x+l.width)),s=Math.ceil(Math.max(s,l.y+l.height));return a=e?0:a,h=n?0:h,o=e||o,s=n||s,{x:a,y:h,width:o-a,height:s-h}},getDefaultImageRect:function(t,e,n){var i,r,o;return null==e&&(e={width:0,height:0}),null==n&&(n={top:0,right:0,bottom:0,left:0}),o=e.width,i=e.height,r=s.getBoundingRect(t,"infinite"===o?0:o,"infinite"===i?0:i),r.x-=n.left,r.y-=n.top,r.width+=n.left+n.right,r.height+=n.top+n.bottom,r},getBackingScale:function(t){return null==window.devicePixelRatio?1:window.devicePixelRatio>1?window.devicePixelRatio:1},requestAnimationFrame:(window.requestAnimationFrame||window.setTimeout).bind(window),getGUID:function(){var t;return t=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)},function(){return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}}(),requestAnimationFrame:function(t){return window.requestAnimationFrame?window.requestAnimationFrame(t):window.webkitRequestAnimationFrame?window.webkitRequestAnimationFrame(t):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame(t):setTimeout(t,0)},cancelAnimationFrame:function(t){return window.cancelAnimationFrame?window.cancelAnimationFrame(t):window.webkitCancelRequestAnimationFrame?window.webkitCancelRequestAnimationFrame(t):window.webkitCancelAnimationFrame?window.webkitCancelAnimationFrame(t):window.mozCancelAnimationFrame?window.mozCancelAnimationFrame(t):clearTimeout(t)}},e.exports=s},{"./canvasRenderer":9,"./svgRenderer":18}],20:[function(t,e,n){"use strict";!function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}t.prototype=window.CustomEvent.prototype,window.CustomEvent=t}()},{}],21:[function(t,e,n){"use strict";var i=!1;CanvasRenderingContext2D.prototype.setLineDash||(CanvasRenderingContext2D.prototype.setLineDash=function(){i||(console.warn("context2D.setLineDash is a no-op in this browser."),i=!0)}),e.exports=null},{}],22:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d,f,g,m,y,S,v,x,w,k,b;t("./ie_customevent"),t("./ie_setLineDash"),i=t("./core/LiterallyCanvas"),l=t("./core/defaultOptions"),s=t("./core/canvasRenderer"),w=t("./core/svgRenderer"),x=t("./core/shapes"),b=t("./core/util"),y=t("./core/renderSnapshotToImage"),S=t("./core/renderSnapshotToSVG"),g=t("./core/localization").localize,r=t("./reactGUI/LiterallyCanvas"),d=t("./reactGUI/initDOM"),t("./optionsStyles/font"),t("./optionsStyles/stroke-width"),t("./optionsStyles/line-options-and-stroke-width"),t("./optionsStyles/polygon-and-stroke-width"),t("./optionsStyles/stroke-or-fill"),t("./optionsStyles/null"),u=t("./optionsStyles/optionsStyles").defineOptionsStyle,a={snapshotToShapes:function(t){var e,n,i,r,o;for(i=t.shapes,r=[],e=0,n=i.length;n>e;e++)o=i[e],r.push(x.JSONToShape(o));return r},snapshotJSONToShapes:function(t){return a.snapshotToShapes(JSON.parse(t))}},o=t("./tools/base"),k={Pencil:t("./tools/Pencil"),Eraser:t("./tools/Eraser"),Line:t("./tools/Line"),Rectangle:t("./tools/Rectangle"),Ellipse:t("./tools/Ellipse"),Text:t("./tools/Text"),Polygon:t("./tools/Polygon"),Pan:t("./tools/Pan"),Eyedropper:t("./tools/Eyedropper"),SelectShape:t("./tools/SelectShape"),Tool:o.Tool,ToolWithStroke:o.ToolWithStroke},c=l.tools,h=l.imageURLPrefix,v=function(t){return h=t,l.imageURLPrefix=t},p=function(e,n){var i,r,o,s,a;null==n&&(n={});for(s in l)s in n||(n[s]=l[s]);for(a=e.children,r=0,o=a.length;o>r;r++)i=a[r],e.removeChild(i);return t("./reactGUI/initDOM")(e,n)},f=function(t,e){var n,r,o;return o=t.className,-1===[" "," "].join(t.className).indexOf(" literally ")&&(t.className=t.className+" literally"),t.className=t.className+" toolbar-hidden",n=document.createElement("div"),n.className="lc-drawing",t.appendChild(n),r=new i(n,e),r.teardown=function(){var e,n,i,s;for(r._teardown(),s=t.children,n=0,i=s.length;i>n;n++)e=s[n],t.removeChild(e);return t.className=o},"onInit"in e&&e.onInit(r),r},m=function(t){return t.fn.literallycanvas=function(t){return null==t&&(t={}),this.each(function(e){return function(e,n){return n.literallycanvas=p(n,t)}}(this)),this}},"undefined"!=typeof window&&(window.LC={init:p},window.$&&m(window.$)),e.exports={init:p,registerJQueryPlugin:m,util:b,tools:k,setDefaultImageURLPrefix:v,defaultTools:c,defineOptionsStyle:u,LiterallyCanvasReactComponent:r,defineShape:x.defineShape,createShape:x.createShape,JSONToShape:x.JSONToShape,shapeToJSON:x.shapeToJSON,defineCanvasRenderer:s.defineCanvasRenderer,renderShapeToContext:s.renderShapeToContext,renderShapeToCanvas:s.renderShapeToCanvas,renderShapesToCanvas:b.renderShapes,defineSVGRenderer:w.defineSVGRenderer,renderShapeToSVG:w.renderShapeToSVG,renderShapesToSVG:b.renderShapesToSVG,snapshotToShapes:a.snapshotToShapes,snapshotJSONToShapes:a.snapshotJSONToShapes,renderSnapshotToImage:y,renderSnapshotToSVG:S,localize:g}},{"./core/LiterallyCanvas":5,"./core/canvasRenderer":9,"./core/defaultOptions":10,"./core/localization":13,"./core/renderSnapshotToImage":15,"./core/renderSnapshotToSVG":16,"./core/shapes":17,"./core/svgRenderer":18,"./core/util":19,"./ie_customevent":20,"./ie_setLineDash":21,"./optionsStyles/font":23,"./optionsStyles/line-options-and-stroke-width":24,"./optionsStyles/null":25,"./optionsStyles/optionsStyles":26,"./optionsStyles/polygon-and-stroke-width":27,"./optionsStyles/stroke-or-fill":28,"./optionsStyles/stroke-width":29,"./reactGUI/LiterallyCanvas":32,"./reactGUI/initDOM":42,"./tools/Ellipse":43,"./tools/Eraser":44,"./tools/Eyedropper":45,"./tools/Line":46,"./tools/Pan":47,"./tools/Pencil":48,"./tools/Polygon":49,"./tools/Rectangle":50,"./tools/SelectShape":51,"./tools/Text":52,"./tools/base":53}],23:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d,f,g,m,y,S,v,x,w,k,b,C,P;for(a=t("../reactGUI/React-shim"),u=t("./optionsStyles").defineOptionsStyle,c=t("../core/localization")._,h=[["Arial",'Arial,"Helvetica Neue",Helvetica,sans-serif'],["Arial Black",'"Arial Black","Arial Bold",Gadget,sans-serif'],["Arial Narrow",'"Arial Narrow",Arial,sans-serif'],["Gill Sans",'"Gill Sans","Gill Sans MT",Calibri,sans-serif'],["Helvetica",'"Helvetica Neue",Helvetica,Arial,sans-serif'],["Impact",'Impact,Haettenschweiler,"Franklin Gothic Bold",Charcoal,"Helvetica Inserat","Bitstream Vera Sans Bold","Arial Black",sans-serif'],["Tahoma","Tahoma,Verdana,Segoe,sans-serif"],["Trebuchet MS",'"Trebuchet MS","Lucida Grande","Lucida Sans Unicode","Lucida Sans",Tahoma,sans-serif'],["Verdana","Verdana,Geneva,sans-serif"]].map(function(t){var e,n;return e=t[0],n=t[1],{name:c(e),value:n}}),l=[["Baskerville",'Baskerville,"Baskerville Old Face","Hoefler Text",Garamond,"Times New Roman",serif'],["Garamond",'Garamond,Baskerville,"Baskerville Old Face","Hoefler Text","Times New Roman",serif'],["Georgia",'Georgia,Times,"Times New Roman",serif'],["Hoefler Text",'"Hoefler Text","Baskerville Old Face",Garamond,"Times New Roman",serif'],["Lucida Bright",'"Lucida Bright",Georgia,serif'],["Palatino",'Palatino,"Palatino Linotype","Palatino LT STD","Book Antiqua",Georgia,serif'],["Times New Roman",'TimesNewRoman,"Times New Roman",Times,Baskerville,Georgia,serif']].map(function(t){var e,n;return e=t[0],n=t[1],{name:c(e),value:n}}),o=[["Consolas/Monaco",'Consolas,monaco,"Lucida Console",monospace'],["Courier New",'"Courier New",Courier,"Lucida Sans Typewriter","Lucida Typewriter",monospace'],["Lucida Sans Typewriter",'"Lucida Sans Typewriter","Lucida Console",monaco,"Bitstream Vera Sans Mono",monospace']].map(function(t){var e,n;return e=t[0],n=t[1],{name:c(e),value:n}}),s=[["Copperplate",'Copperplate,"Copperplate Gothic Light",fantasy'],["Papyrus","Papyrus,fantasy"],["Script",'"Brush Script MT",cursive']].map(function(t){var e,n;return e=t[0],n=t[1],{name:c(e),value:n}}),i=[[c("Sans Serif"),h],[c("Serif"),l],[c("Monospace"),o],[c("Other"),s]],r={},p=0,g=h.length;g>p;p++)w=h[p],x=w.name,P=w.value,r[x]=P;for(d=0,m=l.length;m>d;d++)k=l[d],x=k.name,P=k.value,r[x]=P;for(f=0,y=o.length;y>f;f++)b=o[f],x=b.name,P=b.value,r[x]=P;for(v=0,S=s.length;S>v;v++)C=s[v],x=C.name,P=C.value,r[x]=P;u("font",a.createClass({displayName:"FontOptions",getInitialState:function(){return{isItalic:!1,isBold:!1,fontName:"Helvetica",fontSizeIndex:4}},getFontSizes:function(){return[9,10,12,14,18,24,36,48,64,72,96,144,288]},updateTool:function(t){var e,n,i;null==t&&(t={});for(i in this.state)i in t||(t[i]=this.state[i]);return e=this.getFontSizes()[t.fontSizeIndex],n=[],t.isItalic&&n.push("italic"),t.isBold&&n.push("bold"),n.push(e+"px"),n.push(r[t.fontName]),this.props.lc.tool.font=n.join(" "),this.props.lc.trigger("setFont",n.join(" "))},handleFontSize:function(t){var e;return e={fontSizeIndex:t.target.value},this.setState(e),this.updateTool(e)},handleFontFamily:function(t){var e;return e={fontName:t.target.selectedOptions[0].innerHTML},this.setState(e),this.updateTool(e)},handleItalic:function(t){var e;return e={isItalic:!this.state.isItalic},this.setState(e),this.updateTool(e)},handleBold:function(t){var e;return e={isBold:!this.state.isBold},this.setState(e),this.updateTool(e)},componentDidMount:function(){return this.updateTool()},render:function(){var t,e,n,r,o,s,h,l,u,p;return o=this.props.lc,l=a.DOM,e=l.div,n=l.input,u=l.select,h=l.option,t=l.br,r=l.label,p=l.span,s=l.optgroup,e({className:"lc-font-settings"},u({value:this.state.fontSizeIndex,onChange:this.handleFontSize},this.getFontSizes().map(function(t){return function(t,e){return h({value:e,key:e},t+"px")}}(this))),u({value:this.state.fontName,onChange:this.handleFontFamily},i.map(function(t){return function(t){var e,n;return n=t[0],e=t[1],s({key:n,label:n},e.map(function(t,e){return h({value:t.name,key:e},t.name)}))}}(this))),p({},r({htmlFor:"italic"},c("italic")),n({type:"checkbox",id:"italic",checked:this.state.isItalic,onChange:this.handleItalic})),p({},r({htmlFor:"bold"},c("bold")),n({type:"checkbox",id:"bold",checked:this.state.isBold,onChange:this.handleBold})))}})),e.exports={}},{"../core/localization":13,"../reactGUI/React-shim":35,"./optionsStyles":26}],24:[function(t,e,n){var i,r,o,s,a;i=t("../reactGUI/React-shim"),a=t("./optionsStyles").defineOptionsStyle,r=i.createFactory(t("../reactGUI/StrokeWidthPicker")),s=t("../reactGUI/createSetStateOnEventMixin"),o=t("../core/util").classSet,a("line-options-and-stroke-width",i.createClass({displayName:"LineOptionsAndStrokeWidth",getState:function(){return{strokeWidth:this.props.tool.strokeWidth,isDashed:this.props.tool.isDashed,hasEndArrow:this.props.tool.hasEndArrow}},getInitialState:function(){return this.getState()},mixins:[s("toolChange")],render:function(){var t,e,n,s,a,h,l,c,u,p;return h=i.DOM,n=h.div,p=h.ul,a=h.li,s=h.img,c=function(t){return function(){return t.props.tool.isDashed=!t.props.tool.isDashed,t.setState(t.getState())}}(this),u=function(t){return function(){return t.props.tool.hasEndArrow=!t.props.tool.hasEndArrow,t.setState(t.getState())}}(this),e=o({"square-toolbar-button":!0,selected:this.state.isDashed}),t=o({"square-toolbar-button":!0,selected:this.state.hasEndArrow}),l={"float":"left",margin:1},n({},n({className:e,onClick:c,style:l},s({src:this.props.imageURLPrefix+"/dashed-line.png"})),n({className:t,onClick:u,style:l},s({src:this.props.imageURLPrefix+"/line-with-arrow.png"})),r({tool:this.props.tool,lc:this.props.lc}))}})),e.exports={}},{"../core/util":19,"../reactGUI/React-shim":35,"../reactGUI/StrokeWidthPicker":37,"../reactGUI/createSetStateOnEventMixin":40,"./optionsStyles":26}],25:[function(t,e,n){var i,r;i=t("../reactGUI/React-shim"),r=t("./optionsStyles").defineOptionsStyle,r("null",i.createClass({displayName:"NoOptions",render:function(){return i.DOM.div()}})),e.exports={}},{"../reactGUI/React-shim":35,"./optionsStyles":26}],26:[function(t,e,n){var i,r,o;i=t("../reactGUI/React-shim"),o={},r=function(t,e){return o[t]=i.createFactory(e)},e.exports={optionsStyles:o,defineOptionsStyle:r}},{"../reactGUI/React-shim":35}],27:[function(t,e,n){var i,r,o,s;i=t("../reactGUI/React-shim"),s=t("./optionsStyles").defineOptionsStyle,r=i.createFactory(t("../reactGUI/StrokeWidthPicker")),o=t("../reactGUI/createSetStateOnEventMixin"),s("polygon-and-stroke-width",i.createClass({displayName:"PolygonAndStrokeWidth",getState:function(){return{strokeWidth:this.props.tool.strokeWidth,inProgress:!1}},getInitialState:function(){return this.getState()},mixins:[o("toolChange")],componentDidMount:function(){var t,e,n;
  return n=[],this.unsubscribe=function(t){return function(){var t,e,i,r;for(r=[],e=0,i=n.length;i>e;e++)t=n[e],r.push(t());return r}}(this),e=function(t){return function(){return t.state.inProgress?void 0:t.setState({inProgress:!0})}}(this),t=function(t){return function(){return t.setState({inProgress:!1})}}(this),n.push(this.props.lc.on("lc-polygon-started",e)),n.push(this.props.lc.on("lc-polygon-stopped",t))},componentWillUnmount:function(){return this.unsubscribe()},render:function(){var t,e,n,o,s,a,h,l;return n=this.props.lc,l=i.DOM,t=l.div,e=l.img,a=function(t){return function(){return n.trigger("lc-polygon-finishopen")}}(this),s=function(t){return function(){return n.trigger("lc-polygon-finishclosed")}}(this),o=function(t){return function(){return n.trigger("lc-polygon-cancel")}}(this),h={},this.state.inProgress||(h={display:"none"}),t({},t({className:"polygon-toolbar horz-toolbar",style:h},t({className:"square-toolbar-button",onClick:a},e({src:this.props.imageURLPrefix+"/polygon-open.png"})),t({className:"square-toolbar-button",onClick:s},e({src:this.props.imageURLPrefix+"/polygon-closed.png"})),t({className:"square-toolbar-button",onClick:o},e({src:this.props.imageURLPrefix+"/polygon-cancel.png"}))),t({},r({tool:this.props.tool,lc:this.props.lc})))}})),e.exports={}},{"../reactGUI/React-shim":35,"../reactGUI/StrokeWidthPicker":37,"../reactGUI/createSetStateOnEventMixin":40,"./optionsStyles":26}],28:[function(t,e,n){"use strict";var i=t("../reactGUI/React-shim"),r=t("./optionsStyles"),o=r.defineOptionsStyle,s=t("../reactGUI/createSetStateOnEventMixin"),a=t("../core/localization")._;o("stroke-or-fill",i.createClass({displayName:"StrokeOrFillPicker",getState:function(){return{strokeOrFill:"stroke"}},getInitialState:function(){return this.getState()},mixins:[s("toolChange")],onChange:function(t){"stroke-or-fill-stroke"==t.target.id?this.props.lc.tool.strokeOrFill="stroke":this.props.lc.tool.strokeOrFill="fill",this.setState(this.getState())},render:function(){var t=this.props.lc;return i.createElement("form",null,i.createElement("span",null," ",a("Color to change:")," "),i.createElement("span",null,i.createElement("input",{type:"radio",name:"stroke-or-fill",value:"stroke",id:"stroke-or-fill-stroke",onChange:this.onChange,checked:"stroke"==t.tool.strokeOrFill}),i.createElement("label",{htmlFor:"stroke-or-fill-stroke",className:"label"}," ",a("stroke"))),i.createElement("span",null,i.createElement("input",{type:"radio",name:"stroke-or-fill",value:"fill",id:"stroke-or-fill-fill",onChange:this.onChange,checked:"fill"==t.tool.strokeOrFill}),i.createElement("label",{htmlFor:"stroke-or-fill-fill",className:"label"}," ",a("fill"))))}})),e.exports={}},{"../core/localization":13,"../reactGUI/React-shim":35,"../reactGUI/createSetStateOnEventMixin":40,"./optionsStyles":26}],29:[function(t,e,n){var i,r;r=t("./optionsStyles").defineOptionsStyle,i=t("../reactGUI/StrokeWidthPicker"),r("stroke-width",i),e.exports={}},{"../reactGUI/StrokeWidthPicker":37,"./optionsStyles":26}],30:[function(t,e,n){var i,r,o,s,a;r=t("./React-shim"),a=t("./createSetStateOnEventMixin"),o=t("../core/localization")._,s=t("../core/util").classSet,i=r.createClass({displayName:"ClearButton",getState:function(){return{isEnabled:this.props.lc.canUndo()}},getInitialState:function(){return this.getState()},mixins:[a("drawingChange")],render:function(){var t,e,n,i;return e=r.DOM.div,n=this.props.lc,t=s({"lc-clear":!0,"toolbar-button":!0,"fat-button":!0,disabled:!this.state.isEnabled}),i=n.canUndo()?function(t){return function(){return n.clear()}}(this):function(){},e({className:t,onClick:i},o("Clear"))}}),e.exports=i},{"../core/localization":13,"../core/util":19,"./React-shim":35,"./createSetStateOnEventMixin":40}],31:[function(t,e,n){var i,r,o,s,a,h,l,c,u,p,d,f;s=t("./React-shim"),o=t("react-addons-pure-render-mixin"),d=t("../core/util"),l=d.classSet,f=d.requestAnimationFrame,h=d.cancelAnimationFrame,a=t("../core/localization")._,p=function(t){var e,n,i,r;return"transparent"===t?{hue:0,sat:0,light:0,alpha:0}:"hsla"!==(null!=t?t.substring(0,4):void 0)?null:(n=t.indexOf("("),r=t.indexOf(")"),i=t.substring(n+1,r-n+4),e=function(){var e,n,r,o;for(r=i.split(","),o=[],e=0,n=r.length;n>e;e++)t=r[e],o.push(t.trim());return o}(),{hue:parseInt(e[0],10),sat:parseInt(e[1].substring(0,e[1].length-1),10),light:parseInt(e[2].substring(0,e[2].length-1),10),alpha:parseFloat(e[3])})},c=function(t){var e,n,i,r;return n=t.hue,r=t.sat,i=t.light,e=t.alpha,"hsla("+n+", "+r+"%, "+i+"%, "+e+")"},u=function(t){var e,n,i;return e=t.hue,i=t.sat,n=t.light,"hsl("+e+", "+i+"%, "+n+"%)"},i=s.createFactory(s.createClass({displayName:"ColorGrid",mixins:[o],render:function(){var t;return(t=s.DOM.div)({},this.props.rows.map(function(e){return function(n,i){return t({className:"color-row",key:i,style:{width:20*n.length}},n.map(function(n,i){var r,o,s,a,h,u,p,d;return h=n.hue,p=n.sat,u=n.light,r=n.alpha,s=c(n),a="hsl("+h+", "+p+"%, "+u+"%)",o=l({"color-cell":!0,selected:e.props.selectedColor===s}),d=function(t){return e.props.onChange(n,s),t.stopPropagation(),t.preventDefault()},t({className:o,onTouchStart:d,onTouchMove:d,onClick:d,style:{backgroundColor:a},key:i})}))}}(this)))}})),r=s.createClass({displayName:"ColorWell",mixins:[o],getInitialState:function(){var t,e;return t=this.props.lc.colors[this.props.colorName],e=p(t),null==e&&(e={}),null==e.alpha&&(e.alpha=1),null==e.sat&&(e.sat=100),null==e.hue&&(e.hue=0),null==e.light&&(e.light=50),{colorString:t,alpha:e.alpha,sat:0===e.sat?100:e.sat,isPickerVisible:!1,hsla:e}},componentDidMount:function(){return this.unsubscribe=this.props.lc.on(this.props.colorName+"ColorChange",function(t){return function(){var e;return e=t.props.lc.colors[t.props.colorName],t.setState({colorString:e}),t.setHSLAFromColorString(e)}}(this))},componentWillUnmount:function(){return this.unsubscribe()},setHSLAFromColorString:function(t){var e;return e=p(t),e?this.setState({hsla:e,alpha:e.alpha,sat:e.sat}):this.setState({hsla:null,alpha:1,sat:100})},closePicker:function(){return this.setState({isPickerVisible:!1})},togglePicker:function(){var t,e;return t=!this.state.isPickerVisible,e=t&&0===this.state.sat,this.setHSLAFromColorString(this.state.colorString),this.setState({isPickerVisible:t,sat:e?100:this.state.sat})},setColor:function(t){return this.setState({colorString:t}),this.setHSLAFromColorString(t),this.props.lc.setColor(this.props.colorName,t)},setAlpha:function(t){var e;return this.setState({alpha:t}),this.state.hsla?(e=this.state.hsla,e.alpha=t,this.setState({hsla:e}),this.setColor(c(e))):void 0},setSat:function(t){var e;if(this.setState({sat:t}),isNaN(t))throw"SAT";return this.state.hsla?(e=this.state.hsla,e.sat=t,this.setState({hsla:e}),this.setColor(c(e))):void 0},render:function(){var t,e,n,i;return i=s.DOM,e=i.div,n=i.label,t=i.br,e({className:l({"color-well":!0,open:this.state.isPickerVisible}),onMouseLeave:this.closePicker,style:{"float":"left",textAlign:"center"}},n({"float":"left"},this.props.label),t({}),e({className:l({"color-well-color-container":!0,selected:this.state.isPickerVisible}),style:{backgroundColor:"white"},onClick:this.togglePicker},e({className:"color-well-checker color-well-checker-top-left"}),e({className:"color-well-checker color-well-checker-bottom-right",style:{left:"50%",top:"50%"}}),e({className:"color-well-color",style:{backgroundColor:this.state.colorString}}," ")),this.renderPicker())},renderPicker:function(){var t,e,n,r,o,h,l,c,u,p,d,f,g;if(u=s.DOM,t=u.div,h=u.label,r=u.input,!this.state.isPickerVisible)return null;for(f=function(e){return function(e){return t({className:"color-row label",key:e,style:{lineHeight:"20px",height:16}},e)}}(this),d=function(e){return function(){var n;return n=e.props.lc.opts.imageURLPrefix+"/checkerboard-8x8.png",t({className:"color-row",key:"color",style:{position:"relative",backgroundImage:"url("+n+")",backgroundRepeat:"repeat",height:24}},t({style:{position:"absolute",top:0,right:0,bottom:0,left:0,backgroundColor:e.state.colorString}}))}}(this),g=[],g.push(function(){var t,e;for(e=[],n=t=0;100>=t;n=t+=10)e.push({hue:0,sat:0,light:n,alpha:this.state.alpha});return e}.call(this)),p=[0,30,60,90,120,150,180,210,240,270,300,330],o=0,l=p.length;l>o;o++)e=p[o],g.push(function(){var t,i;for(i=[],n=t=10;90>=t;n=t+=8)i.push({hue:e,sat:this.state.sat,light:n,alpha:this.state.alpha});return i}.call(this));return c=function(t){return function(e,n){return t.setColor(n)}}(this),t({className:"color-picker-popup"},d(),f(a("alpha")),r({type:"range",min:0,max:1,step:.01,value:this.state.alpha,onChange:function(t){return function(e){return t.setAlpha(parseFloat(e.target.value))}}(this)}),f(a("saturation")),r({type:"range",min:0,max:100,value:this.state.sat,max:100,onChange:function(t){return function(e){return t.setSat(parseInt(e.target.value,10))}}(this)}),i({rows:g,selectedColor:this.state.colorString,onChange:c}))}}),e.exports=r},{"../core/localization":13,"../core/util":19,"./React-shim":35,"react-addons-pure-render-mixin":2}],32:[function(t,e,n){"use strict";var i=t("../reactGUI/React-shim"),r=t("../reactGUI/ReactDOM-shim"),o=r.findDOMNode,s=t("../core/util"),a=s.classSet,h=t("./Picker"),l=t("./Options"),c=t("./createToolButton"),u=t("../core/LiterallyCanvas"),p=t("../core/defaultOptions");t("../optionsStyles/font"),t("../optionsStyles/stroke-width"),t("../optionsStyles/line-options-and-stroke-width"),t("../optionsStyles/polygon-and-stroke-width"),t("../optionsStyles/null");var d=i.createClass({displayName:"CanvasContainer",shouldComponentUpdate:function(){return!1},render:function(){return i.createElement("div",{key:"literallycanvas",className:"lc-drawing with-gui"})}}),f=i.createClass({displayName:"LiterallyCanvas",getDefaultProps:function(){return p},bindToModel:function(){var t=o(this.canvas);this.props;this.lc.bindToElement(t),"function"==typeof this.lc.opts.onInit&&this.lc.opts.onInit(this.lc)},componentWillMount:function(){var t=this;this.lc||(this.props.lc?this.lc=this.props.lc:this.lc=new u(this.props),this.toolButtonComponents=this.lc.opts.tools.map(function(e){return c(new e(t.lc))}))},componentDidMount:function(){this.lc.isBound||this.bindToModel()},componentWillUnmount:function(){this.lc&&this.lc._teardown()},render:function(){var t=this,e=this.lc,n=this.toolButtonComponents,r=(this.props,this.lc.opts),o=r.imageURLPrefix,s=r.toolbarPosition,c={lc:e,toolButtonComponents:n,imageURLPrefix:o},u=a({"toolbar-at-top":"top"===s,"toolbar-at-bottom":"bottom"===s,"toolbar-hidden":"hidden"===s});return i.createElement("div",{className:"literally "+u},i.createElement(d,{ref:function(e){return t.canvas=e}}),i.createElement(h,c),i.createElement(l,{lc:e,imageURLPrefix:o}))}});e.exports=f},{"../core/LiterallyCanvas":5,"../core/defaultOptions":10,"../core/util":19,"../optionsStyles/font":23,"../optionsStyles/line-options-and-stroke-width":24,"../optionsStyles/null":25,"../optionsStyles/polygon-and-stroke-width":27,"../optionsStyles/stroke-width":29,"../reactGUI/React-shim":35,"../reactGUI/ReactDOM-shim":36,"./Options":33,"./Picker":34,"./createToolButton":41}],33:[function(t,e,n){var i,r,o,s;r=t("./React-shim"),o=t("./createSetStateOnEventMixin"),s=t("../optionsStyles/optionsStyles").optionsStyles,i=r.createClass({displayName:"Options",getState:function(){var t;return{style:null!=(t=this.props.lc.tool)?t.optionsStyle:void 0,tool:this.props.lc.tool}},getInitialState:function(){return this.getState()},mixins:[o("toolChange")],renderBody:function(){var t;return t=""+this.state.style,s[t]&&s[t]({lc:this.props.lc,tool:this.state.tool,imageURLPrefix:this.props.imageURLPrefix})},render:function(){var t;return(t=r.DOM.div)({className:"lc-options horz-toolbar"},this.renderBody())}}),e.exports=i},{"../optionsStyles/optionsStyles":26,"./React-shim":35,"./createSetStateOnEventMixin":40}],34:[function(t,e,n){var i,r,o,s,a,h,l,c;a=t("./React-shim"),i=a.createFactory(t("./ClearButton")),h=a.createFactory(t("./UndoRedoButtons")),l=a.createFactory(t("./ZoomButtons")),c=t("../core/localization")._,o=a.createFactory(t("./ColorWell")),r=a.createFactory(a.createClass({displayName:"ColorPickers",render:function(){var t,e;return e=this.props.lc,(t=a.DOM.div)({className:"lc-color-pickers"},o({lc:e,colorName:"primary",label:c("stroke")}),o({lc:e,colorName:"secondary",label:c("fill")}),o({lc:e,colorName:"background",label:c("bg")}))}})),s=a.createClass({displayName:"Picker",getInitialState:function(){return{selectedToolIndex:0}},renderBody:function(){var t,e,n,o,s;return t=a.DOM.div,o=this.props,s=o.toolButtonComponents,n=o.lc,e=o.imageURLPrefix,t({className:"lc-picker-contents"},s.map(function(t){return function(i,r){return i({lc:n,imageURLPrefix:e,key:r,isSelected:r===t.state.selectedToolIndex,onSelect:function(e){return n.setTool(e),t.setState({selectedToolIndex:r})}})}}(this)),s.length%2!==0?t({className:"toolbar-button thin-button disabled"}):void 0,t({style:{position:"absolute",bottom:0,left:0,right:0}},r({lc:this.props.lc}),h({lc:n,imageURLPrefix:e}),l({lc:n,imageURLPrefix:e}),i({lc:n})))},render:function(){var t;return(t=a.DOM.div)({className:"lc-picker"},this.renderBody())}}),e.exports=s},{"../core/localization":13,"./ClearButton":30,"./ColorWell":31,"./React-shim":35,"./UndoRedoButtons":38,"./ZoomButtons":39}],35:[function(t,e,n){var i;try{i=t("react")}catch(r){i=window.React}if(null==i)throw"Can't find React";e.exports=i},{react:"react"}],36:[function(t,e,n){var i;try{i=t("react-dom")}catch(r){i=window.ReactDOM}if(null==i)try{i=t("react")}catch(o){i=window.React}if(null==i)throw"Can't find ReactDOM";e.exports=i},{react:"react","react-dom":"react-dom"}],37:[function(t,e,n){var i,r,o;i=t("./React-shim"),o=t("../reactGUI/createSetStateOnEventMixin"),r=t("../core/util").classSet,e.exports=i.createClass({displayName:"StrokeWidthPicker",getState:function(t){return null==t&&(t=this.props.tool),{strokeWidth:t.strokeWidth}},getInitialState:function(){return this.getState()},mixins:[o("toolDidUpdateOptions")],componentWillReceiveProps:function(t){return this.setState(this.getState(t.tool))},render:function(){var t,e,n,o,s,a,h;return o=i.DOM,h=o.ul,n=o.li,a=o.svg,t=o.circle,e=o.div,s=this.props.lc.opts.strokeWidths,e({},s.map(function(n){return function(i,o){var s,h;return s=r({"square-toolbar-button":!0,selected:i===n.state.strokeWidth}),h=28,e({key:i},e({className:s,onClick:function(){return n.props.lc.trigger("setStrokeWidth",i)}},a({width:h-2,height:h-2,viewPort:"0 0 "+i+" "+i,version:"1.1",xmlns:"http://www.w3.org/2000/svg"},t({cx:Math.ceil(h/2-1),cy:Math.ceil(h/2-1),r:i/2}))))}}(this)))}})},{"../core/util":19,"../reactGUI/createSetStateOnEventMixin":40,"./React-shim":35}],38:[function(t,e,n){var i,r,o,s,a,h,l;i=t("./React-shim"),h=t("./createSetStateOnEventMixin"),a=t("../core/util").classSet,l=function(t){return i.createClass({displayName:"undo"===t?"UndoButton":"RedoButton",getState:function(){return{isEnabled:function(){switch(!1){case"undo"!==t:return this.props.lc.canUndo();case"redo"!==t:return this.props.lc.canRedo()}}.call(this)}},getInitialState:function(){return this.getState()},mixins:[h("drawingChange")],render:function(){var e,n,r,o,s,h,l,c,u,p,d;return l=i.DOM,n=l.div,o=l.img,c=this.props,s=c.lc,r=c.imageURLPrefix,d="undo"===t?"Undo":"Redo",e="lc-"+t+" "+a({"toolbar-button":!0,"thin-button":!0,disabled:!this.state.isEnabled}),h=function(){switch(!1){case!!this.state.isEnabled:return function(){};case"undo"!==t:return function(){return s.undo()};case"redo"!==t:return function(){return s.redo()}}}.call(this),u=r+"/"+t+".png",p={backgroundImage:"url("+u+")"},n({className:e,onClick:h,title:d,style:p})}})},o=i.createFactory(l("undo")),r=i.createFactory(l("redo")),s=i.createClass({displayName:"UndoRedoButtons",render:function(){var t;return(t=i.DOM.div)({className:"lc-undo-redo"},o(this.props),r(this.props))}}),e.exports=s},{"../core/util":19,"./React-shim":35,"./createSetStateOnEventMixin":40}],39:[function(t,e,n){var i,r,o,s,a,h,l;i=t("./React-shim"),h=t("./createSetStateOnEventMixin"),a=t("../core/util").classSet,l=function(t){return i.createClass({displayName:"in"===t?"ZoomInButton":"ZoomOutButton",getState:function(){return{isEnabled:function(){switch(!1){case"in"!==t:return this.props.lc.scale<this.props.lc.config.zoomMax;case"out"!==t:return this.props.lc.scale>this.props.lc.config.zoomMin}}.call(this)}},getInitialState:function(){return this.getState()},mixins:[h("zoom")],render:function(){var e,n,r,o,s,h,l,c,u,p,d;return l=i.DOM,n=l.div,o=l.img,c=this.props,s=c.lc,r=c.imageURLPrefix,d="in"===t?"Zoom in":"Zoom out",e="lc-zoom-"+t+" "+a({"toolbar-button":!0,"thin-button":!0,disabled:!this.state.isEnabled}),h=function(){switch(!1){case!!this.state.isEnabled:return function(){};case"in"!==t:return function(){return s.zoom(s.config.zoomStep)};case"out"!==t:return function(){return s.zoom(-s.config.zoomStep)}}}.call(this),u=r+"/zoom-"+t+".png",p={backgroundImage:"url("+u+")"},n({className:e,onClick:h,title:d,style:p})}})},s=i.createFactory(l("out")),o=i.createFactory(l("in")),r=i.createClass({displayName:"ZoomButtons",render:function(){var t;return(t=i.DOM.div)({className:"lc-zoom"},s(this.props),o(this.props))}}),e.exports=r},{"../core/util":19,"./React-shim":35,"./createSetStateOnEventMixin":40}],40:[function(t,e,n){var i,r;i=t("./React-shim"),e.exports=r=function(t){return{componentDidMount:function(){return this.unsubscribe=this.props.lc.on(t,function(t){return function(){return t.setState(t.getState())}}(this))},componentWillUnmount:function(){return this.unsubscribe()}}}},{"./React-shim":35}],41:[function(t,e,n){var i,r,o,s;i=t("./React-shim"),o=t("../core/util").classSet,r=t("../core/localization")._,s=function(t){var e,n;return e=t.name,n=t.iconName,i.createFactory(i.createClass({displayName:e,getDefaultProps:function(){return{isSelected:!1,lc:null}},componentWillMount:function(){return this.props.isSelected?this.props.lc.setTool(t):void 0},render:function(){var s,a,h,l,c,u,p,d,f;return p=i.DOM,a=p.div,l=p.img,d=this.props,h=d.imageURLPrefix,c=d.isSelected,u=d.onSelect,s=o({"lc-pick-tool":!0,"toolbar-button":!0,"thin-button":!0,selected:c}),f=h+"/"+n+".png",a({className:s,style:{backgroundImage:"url("+f+")"},onClick:function(){return u(t)},title:r(e)})}}))},e.exports=s},{"../core/localization":13,"../core/util":19,"./React-shim":35}],42:[function(t,e,n){"use strict";function i(t,e){var n=t.className,i=new s(e);return o.render(r.createElement(a,{lc:i}),t),i.teardown=function(){i._teardown();for(var e=0;e<t.children.length;e++)t.removeChild(t.children[e]);t.className=n},i}var r=t("./React-shim"),o=t("./ReactDOM-shim"),s=t("../core/LiterallyCanvas"),a=t("./LiterallyCanvas");e.exports=i},{"../core/LiterallyCanvas":5,"./LiterallyCanvas":32,"./React-shim":35,"./ReactDOM-shim":36}],43:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").ToolWithStroke,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Ellipse",e.prototype.iconName="ellipse",e.prototype.begin=function(t,e,n){return this.currentShape=o("Ellipse",{x:t,y:e,strokeWidth:this.strokeWidth,strokeColor:n.getColor("primary"),fillColor:n.getColor("secondary")})},e.prototype["continue"]=function(t,e,n){return this.currentShape.width=t-this.currentShape.x,this.currentShape.height=e-this.currentShape.y,n.drawShapeInProgress(this.currentShape)},e.prototype.end=function(t,e,n){return n.saveShape(this.currentShape)},e}(r)},{"../core/shapes":17,"./base":53}],44:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./Pencil"),o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Eraser",e.prototype.iconName="eraser",e.prototype.makePoint=function(t,e,n){return o("Point",{x:t,y:e,size:this.strokeWidth,color:"#000"})},e.prototype.makeShape=function(){return o("ErasedLinePath")},e}(r)},{"../core/shapes":17,"./Pencil":48}],45:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").Tool,o=function(t,e){var n,i,r;return i=e.x,r=e.y,n=t.getImageData(i,r,1,1).data,n[3]?"rgb("+n[0]+", "+n[1]+", "+n[2]+")":null},e.exports=i=function(t){function e(t){e.__super__.constructor.call(this,t),this.strokeOrFill="stroke"}return s(e,t),e.prototype.name="Eyedropper",e.prototype.iconName="eyedropper",e.prototype.optionsStyle="stroke-or-fill",e.prototype.readColor=function(t,e,n){var i,r,s,a;return a=n.getDefaultImageRect(),i=n.getImage(),s=o(i.getContext("2d"),{x:t-a.x,y:e-a.y}),r=s||n.getColor("background"),"stroke"===this.strokeOrFill?n.setColor("primary",s):n.setColor("secondary",s)},e.prototype.begin=function(t,e,n){return this.readColor(t,e,n)},e.prototype["continue"]=function(t,e,n){return this.readColor(t,e,n)},e}(r)},{"./base":53}],46:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").ToolWithStroke,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Line",e.prototype.iconName="line",e.prototype.optionsStyle="line-options-and-stroke-width",e.prototype.begin=function(t,e,n){return this.currentShape=o("Line",{x1:t,y1:e,x2:t,y2:e,strokeWidth:this.strokeWidth,dash:function(){switch(!1){case!this.isDashed:return[2*this.strokeWidth,4*this.strokeWidth];default:return null}}.call(this),endCapShapes:this.hasEndArrow?[null,"arrow"]:null,color:n.getColor("primary")})},e.prototype["continue"]=function(t,e,n){return this.currentShape.x2=t,this.currentShape.y2=e,n.drawShapeInProgress(this.currentShape)},e.prototype.end=function(t,e,n){return n.saveShape(this.currentShape)},e}(r)},{"../core/shapes":17,"./base":53}],47:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").Tool,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Pan",e.prototype.iconName="pan",e.prototype.usesSimpleAPI=!1,e.prototype.didBecomeActive=function(t){var e;return e=[],this.unsubscribe=function(t){return function(){var t,n,i,r;for(r=[],n=0,i=e.length;i>n;n++)t=e[n],r.push(t());return r}}(this),e.push(t.on("lc-pointerdown",function(e){return function(n){var i,r;return i=n.rawX,r=n.rawY,e.oldPosition=t.position,e.pointerStart={x:i,y:r}}}(this))),e.push(t.on("lc-pointerdrag",function(e){return function(n){var i,r,o;return r=n.rawX,o=n.rawY,i={x:(r-e.pointerStart.x)*t.backingScale,y:(o-e.pointerStart.y)*t.backingScale},t.setPan(e.oldPosition.x+i.x,e.oldPosition.y+i.y)}}(this)))},e.prototype.willBecomeInactive=function(t){return this.unsubscribe()},e}(r)},{"../core/shapes":17,"./base":53}],48:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").ToolWithStroke,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Pencil",e.prototype.iconName="pencil",e.prototype.eventTimeThreshold=10,e.prototype.begin=function(t,e,n){return this.color=n.getColor("primary"),this.currentShape=this.makeShape(),this.currentShape.addPoint(this.makePoint(t,e,n)),this.lastEventTime=Date.now()},e.prototype["continue"]=function(t,e,n){var i;return i=Date.now()-this.lastEventTime,i>this.eventTimeThreshold?(this.lastEventTime+=i,this.currentShape.addPoint(this.makePoint(t,e,n)),n.drawShapeInProgress(this.currentShape)):void 0},e.prototype.end=function(t,e,n){return n.saveShape(this.currentShape),this.currentShape=void 0},e.prototype.makePoint=function(t,e,n){return o("Point",{x:t,y:e,size:this.strokeWidth,color:this.color})},e.prototype.makeShape=function(){return o("LinePath")},e}(r)},{"../core/shapes":17,"./base":53}],49:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").ToolWithStroke,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Polygon",e.prototype.iconName="polygon",e.prototype.usesSimpleAPI=!1,e.prototype.didBecomeActive=function(t){var n,i,r,o,s,a,h;return e.__super__.didBecomeActive.call(this,t),h=[],this.polygonUnsubscribe=function(t){return function(){var t,e,n,i;for(i=[],e=0,n=h.length;n>e;e++)t=h[e],i.push(t());return i}}(this),this.points=null,this.maybePoint=null,r=function(e){return function(){return e._getWillFinish()?e._close(t):(t.trigger("lc-polygon-started"),e.points?e.points.push(e.maybePoint):e.points=[e.maybePoint],e.maybePoint={x:e.maybePoint.x,y:e.maybePoint.y},t.setShapesInProgress(e._getShapes(t)),t.repaintLayer("main"))}}(this),i=function(e){return function(n){var i,r;return i=n.x,r=n.y,e.maybePoint?(e.maybePoint.x=i,e.maybePoint.y=r,t.setShapesInProgress(e._getShapes(t)),t.repaintLayer("main")):void 0}}(this),n=function(e){return function(n){var i,r;return i=n.x,r=n.y,e.maybePoint={x:i,y:r},t.setShapesInProgress(e._getShapes(t)),t.repaintLayer("main")}}(this),a=function(e){return function(){return e.maybePoint={x:1/0,y:1/0},e._close(t)}}(this),s=function(e){return function(){return e.maybePoint=e.points[0],e._close(t)}}(this),o=function(e){return function(){return e._cancel(t)}}(this),h.push(t.on("drawingChange",function(e){return function(){return e._cancel(t)}}(this))),h.push(t.on("lc-pointerdown",n)),h.push(t.on("lc-pointerdrag",i)),h.push(t.on("lc-pointermove",i)),h.push(t.on("lc-pointerup",r)),h.push(t.on("lc-polygon-finishopen",a)),h.push(t.on("lc-polygon-finishclosed",s)),h.push(t.on("lc-polygon-cancel",o))},e.prototype.willBecomeInactive=function(t){return e.__super__.willBecomeInactive.call(this,t),(this.points||this.maybePoint)&&this._cancel(t),this.polygonUnsubscribe()},e.prototype._getArePointsClose=function(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)<10},e.prototype._getWillClose=function(){return this.points&&this.points.length>1&&this.maybePoint?this._getArePointsClose(this.points[0],this.maybePoint):!1},e.prototype._getWillFinish=function(){return this.points&&this.points.length>1&&this.maybePoint?this._getArePointsClose(this.points[0],this.maybePoint)||this._getArePointsClose(this.points[this.points.length-1],this.maybePoint):!1},e.prototype._cancel=function(t){return t.trigger("lc-polygon-stopped"),this.maybePoint=null,this.points=null,t.setShapesInProgress([]),t.repaintLayer("main")},e.prototype._close=function(t){return t.trigger("lc-polygon-stopped"),t.setShapesInProgress([]),this.points.length>2&&t.saveShape(this._getShape(t,!1)),this.maybePoint=null,this.points=null},e.prototype._getShapes=function(t,e){var n;return null==e&&(e=!0),n=this._getShape(t,e),n?[n]:[]},e.prototype._getShape=function(t,e){var n;return null==e&&(e=!0),n=[],this.points&&(n=n.concat(this.points)),!e&&n.length<3?null:(e&&this.maybePoint&&n.push(this.maybePoint),n.length>1?o("Polygon",{isClosed:this._getWillClose(),strokeColor:t.getColor("primary"),fillColor:t.getColor("secondary"),strokeWidth:this.strokeWidth,points:n.map(function(t){return o("Point",t)})}):null)},e.prototype.optionsStyle="polygon-and-stroke-width",e}(r)},{"../core/shapes":17,"./base":53}],50:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").ToolWithStroke,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.name="Rectangle",e.prototype.iconName="rectangle",e.prototype.begin=function(t,e,n){return this.currentShape=o("Rectangle",{x:t,y:e,strokeWidth:this.strokeWidth,strokeColor:n.getColor("primary"),fillColor:n.getColor("secondary")})},e.prototype["continue"]=function(t,e,n){return this.currentShape.width=t-this.currentShape.x,this.currentShape.height=e-this.currentShape.y,n.drawShapeInProgress(this.currentShape)},e.prototype.end=function(t,e,n){return n.saveShape(this.currentShape)},e}(r)},{"../core/shapes":17,"./base":53}],51:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;r=t("./base").Tool,o=t("../core/shapes").createShape,e.exports=i=function(t){function e(t){this.selectCanvas=document.createElement("canvas"),this.selectCanvas.style["background-color"]="transparent",this.selectCtx=this.selectCanvas.getContext("2d")}return s(e,t),e.prototype.name="SelectShape",e.prototype.usesSimpleAPI=!1,e.prototype.didBecomeActive=function(t){var e,n,i,r;return r=[],this._selectShapeUnsubscribe=function(t){return function(){var t,e,n,i;for(i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(t());return i}}(this),e=function(e){return function(n){var i,r,s,a;return s=n.x,a=n.y,e.didDrag=!1,r=e._getPixel(s,a,t,e.selectCtx),e.selectedShape=t.shapes[r],null!=e.selectedShape?(t.trigger("shapeSelected",{selectedShape:e.selectedShape}),t.setShapesInProgress([e.selectedShape,o("SelectionBox",{shape:e.selectedShape,handleSize:0})]),t.repaintLayer("main"),i=e.selectedShape.getBoundingRect(),e.dragOffset={x:s-i.x,y:a-i.y}):void 0}}(this),n=function(e){return function(n){var i,r;return i=n.x,r=n.y,null!=e.selectedShape?(e.didDrag=!0,e.selectedShape.setUpperLeft({x:i-e.dragOffset.x,y:r-e.dragOffset.y}),t.setShapesInProgress([e.selectedShape,o("SelectionBox",{shape:e.selectedShape,handleSize:0})]),t.repaintLayer("main")):void 0}}(this),i=function(e){return function(n){var i,r;return i=n.x,r=n.y,e.didDrag?(e.didDrag=!1,t.trigger("shapeMoved",{shape:e.selectedShape}),t.trigger("drawingChange",{}),t.repaintLayer("main"),e._drawSelectCanvas(t)):void 0}}(this),r.push(t.on("lc-pointerdown",e)),r.push(t.on("lc-pointerdrag",n)),r.push(t.on("lc-pointerup",i)),this._drawSelectCanvas(t)},e.prototype.willBecomeInactive=function(t){return this._selectShapeUnsubscribe(),t.setShapesInProgress([])},e.prototype._drawSelectCanvas=function(t){var e;return this.selectCanvas.width=t.canvas.width,this.selectCanvas.height=t.canvas.height,this.selectCtx.clearRect(0,0,this.selectCanvas.width,this.selectCanvas.height),e=t.shapes.map(function(t){return function(e,n){return o("SelectionBox",{shape:e,handleSize:0,backgroundColor:"#"+t._intToHex(n)})}}(this)),t.draw(e,this.selectCtx)},e.prototype._intToHex=function(t){return("000000"+t.toString(16)).slice(-6)},e.prototype._getPixel=function(t,e,n,i){var r,o;return r=n.drawingCoordsToClientCoords(t,e),o=i.getImageData(r.x,r.y,1,1).data,o[3]?parseInt(this._rgbToHex(o[0],o[1],o[2]),16):null},e.prototype._componentToHex=function(t){var e;return e=t.toString(16),("0"+e).slice(-2)},e.prototype._rgbToHex=function(t,e,n){return""+this._componentToHex(t)+this._componentToHex(e)+this._componentToHex(n)},e}(r)},{"../core/shapes":17,"./base":53}],52:[function(t,e,n){var i,r,o,s,a=function(t,e){function n(){this.constructor=t}for(var i in e)h.call(e,i)&&(t[i]=e[i]);
  return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},h={}.hasOwnProperty;r=t("./base").Tool,o=t("../core/shapes").createShape,s=function(t,e){return t.x<e.x?!1:t.y<e.y?!1:t.x>e.x+e.width?!1:!(t.y>e.y+e.height)},e.exports=i=function(t){function e(){this.text="",this.font="bold 18px sans-serif",this.currentShape=null,this.currentShapeState=null,this.initialShapeBoundingRect=null,this.dragAction=null,this.didDrag=!1}return a(e,t),e.prototype.name="Text",e.prototype.iconName="text",e.prototype.didBecomeActive=function(t){var e,n,i;return n=[],this.unsubscribe=function(t){return function(){var t,e,i,r;for(r=[],e=0,i=n.length;i>e;e++)t=n[e],r.push(t());return r}}(this),e=function(e){return function(){return e._ensureNotEditing(t),e._clearCurrentShape(t),t.repaintLayer("main")}}(this),i=function(e){return function(){return e._updateInputEl(t)}}(this),n.push(t.on("drawingChange",e)),n.push(t.on("zoom",i)),n.push(t.on("imageSizeChange",i)),n.push(t.on("snapshotLoad",function(e){return function(){return e._clearCurrentShape(t),t.repaintLayer("main")}}(this))),n.push(t.on("primaryColorChange",function(e){return function(n){return e.currentShape?(e.currentShape.color=n,e._updateInputEl(t),t.repaintLayer("main")):void 0}}(this))),n.push(t.on("setFont",function(e){return function(n){return e.currentShape?(e.font=n,e.currentShape.setFont(n),e._setShapesInProgress(t),e._updateInputEl(t),t.repaintLayer("main")):void 0}}(this)))},e.prototype.willBecomeInactive=function(t){return this.currentShape&&(this._ensureNotEditing(t),this.commit(t)),this.unsubscribe()},e.prototype.setText=function(t){return this.text=t},e.prototype._ensureNotEditing=function(t){return"editing"===this.currentShapeState?this._exitEditingState(t):void 0},e.prototype._clearCurrentShape=function(t){return this.currentShape=null,this.initialShapeBoundingRect=null,this.currentShapeState=null,t.setShapesInProgress([])},e.prototype.commit=function(t){return this.currentShape.text&&t.saveShape(this.currentShape),this._clearCurrentShape(t),t.repaintLayer("main")},e.prototype._getSelectionShape=function(t,e){return null==e&&(e=null),o("SelectionBox",{shape:this.currentShape,ctx:t,backgroundColor:e})},e.prototype._setShapesInProgress=function(t){switch(this.currentShapeState){case"selected":return t.setShapesInProgress([this._getSelectionShape(t.ctx),this.currentShape]);case"editing":return t.setShapesInProgress([this._getSelectionShape(t.ctx,"#fff")]);default:return t.setShapesInProgress([this.currentShape])}},e.prototype.begin=function(t,e,n){var i,r,a,h;return this.dragAction="none",this.didDrag=!1,"selected"===this.currentShapeState||"editing"===this.currentShapeState?(i=this.currentShape.getBoundingRect(n.ctx),h=this._getSelectionShape(n.ctx),a=h.getBoundingRect(),r={x:t,y:e},s(r,i)&&(this.dragAction="move"),s(r,h.getBottomRightHandleRect())&&(this.dragAction="resizeBottomRight"),s(r,h.getTopLeftHandleRect())&&(this.dragAction="resizeTopLeft"),s(r,h.getBottomLeftHandleRect())&&(this.dragAction="resizeBottomLeft"),s(r,h.getTopRightHandleRect())&&(this.dragAction="resizeTopRight"),"none"===this.dragAction&&"editing"===this.currentShapeState&&(this.dragAction="stop-editing",this._exitEditingState(n))):(this.color=n.getColor("primary"),this.currentShape=o("Text",{x:t,y:e,text:this.text,color:this.color,font:this.font,v:1}),this.dragAction="place",this.currentShapeState="selected"),"none"===this.dragAction?void this.commit(n):(this.initialShapeBoundingRect=this.currentShape.getBoundingRect(n.ctx),this.dragOffset={x:t-this.initialShapeBoundingRect.x,y:e-this.initialShapeBoundingRect.y},this._setShapesInProgress(n),n.repaintLayer("main"))},e.prototype["continue"]=function(t,e,n){var i,r,o;if("none"!==this.dragAction){switch(i=this.initialShapeBoundingRect,o=i.x+i.width,r=i.y+i.height,this.dragAction){case"place":this.currentShape.x=t,this.currentShape.y=e,this.didDrag=!0;break;case"move":this.currentShape.x=t-this.dragOffset.x,this.currentShape.y=e-this.dragOffset.y,this.didDrag=!0;break;case"resizeBottomRight":this.currentShape.setSize(t-(this.dragOffset.x-this.initialShapeBoundingRect.width)-i.x,e-(this.dragOffset.y-this.initialShapeBoundingRect.height)-i.y);break;case"resizeTopLeft":this.currentShape.setSize(o-t+this.dragOffset.x,r-e+this.dragOffset.y),this.currentShape.setPosition(t-this.dragOffset.x,e-this.dragOffset.y);break;case"resizeBottomLeft":this.currentShape.setSize(o-t+this.dragOffset.x,e-(this.dragOffset.y-this.initialShapeBoundingRect.height)-i.y),this.currentShape.setPosition(t-this.dragOffset.x,this.currentShape.y);break;case"resizeTopRight":this.currentShape.setSize(t-(this.dragOffset.x-this.initialShapeBoundingRect.width)-i.x,r-e+this.dragOffset.y),this.currentShape.setPosition(this.currentShape.x,e-this.dragOffset.y)}return this._setShapesInProgress(n),n.repaintLayer("main"),this._updateInputEl(n)}},e.prototype.end=function(t,e,n){return this.currentShape?(this.currentShape.setSize(this.currentShape.forcedWidth,0),"selected"===this.currentShapeState&&("place"===this.dragAction||"move"===this.dragAction&&!this.didDrag)&&this._enterEditingState(n),this._setShapesInProgress(n),n.repaintLayer("main"),this._updateInputEl(n)):void 0},e.prototype._enterEditingState=function(t){var e;if(this.currentShapeState="editing",this.inputEl)throw"State error";return this.inputEl=document.createElement("textarea"),this.inputEl.className="text-tool-input",this.inputEl.style.position="absolute",this.inputEl.style.transformOrigin="0px 0px",this.inputEl.style.backgroundColor="transparent",this.inputEl.style.border="none",this.inputEl.style.outline="none",this.inputEl.style.margin="0",this.inputEl.style.padding="4px",this.inputEl.style.zIndex="1000",this.inputEl.style.overflow="hidden",this.inputEl.style.resize="none",this.inputEl.value=this.currentShape.text,this.inputEl.addEventListener("mousedown",function(t){return t.stopPropagation()}),this.inputEl.addEventListener("touchstart",function(t){return t.stopPropagation()}),e=function(e){return function(n){return e.currentShape.setText(n.target.value),e.currentShape.enforceMaxBoundingRect(t),e._setShapesInProgress(t),t.repaintLayer("main"),e._updateInputEl(t),n.stopPropagation()}}(this),this.inputEl.addEventListener("keydown",function(e){return function(){return e._updateInputEl(t,!0)}}(this)),this.inputEl.addEventListener("keyup",e),this.inputEl.addEventListener("change",e),this._updateInputEl(t),t.containerEl.appendChild(this.inputEl),this.inputEl.focus(),this._setShapesInProgress(t)},e.prototype._exitEditingState=function(t){return this.currentShapeState="selected",t.containerEl.removeChild(this.inputEl),this.inputEl=null,this._setShapesInProgress(t),t.repaintLayer("main")},e.prototype._updateInputEl=function(t,e){var n,i;return null==e&&(e=!1),this.inputEl?(n=this.currentShape.getBoundingRect(t.ctx,!0),this.inputEl.style.font=this.currentShape.font,this.inputEl.style.color=this.currentShape.color,this.inputEl.style.left=t.position.x/t.backingScale+n.x*t.scale-4+"px",this.inputEl.style.top=t.position.y/t.backingScale+n.y*t.scale-4+"px",e&&!this.currentShape.forcedWidth?this.inputEl.style.width=n.width+10+this.currentShape.renderer.emDashWidth+"px":this.inputEl.style.width=n.width+12+"px",e?this.inputEl.style.height=n.height+10+this.currentShape.renderer.metrics.leading+"px":this.inputEl.style.height=n.height+10+"px",i="scale("+t.scale+")",this.inputEl.style.transform=i,this.inputEl.style.webkitTransform=i,this.inputEl.style.MozTransform=i,this.inputEl.style.msTransform=i,this.inputEl.style.OTransform=i):void 0},e.prototype.optionsStyle="font",e}(r)},{"../core/shapes":17,"./base":53}],53:[function(t,e,n){var i,r,o,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;o={},o.Tool=i=function(){function t(){}return t.prototype.name=null,t.prototype.iconName=null,t.prototype.usesSimpleAPI=!0,t.prototype.begin=function(t,e,n){},t.prototype["continue"]=function(t,e,n){},t.prototype.end=function(t,e,n){},t.prototype.optionsStyle=null,t.prototype.didBecomeActive=function(t){},t.prototype.willBecomeInactive=function(t){},t}(),o.ToolWithStroke=r=function(t){function e(t){this.strokeWidth=t.opts.defaultStrokeWidth}return s(e,t),e.prototype.optionsStyle="stroke-width",e.prototype.didBecomeActive=function(t){var e;return e=[],this.unsubscribe=function(t){return function(){var t,n,i,r;for(r=[],n=0,i=e.length;i>n;n++)t=e[n],r.push(t());return r}}(this),e.push(t.on("setStrokeWidth",function(e){return function(n){return e.strokeWidth=n,t.trigger("toolDidUpdateOptions")}}(this)))},e.prototype.willBecomeInactive=function(t){return this.unsubscribe()},e}(i),e.exports=o},{}]},{},[22])(22)});