UNPKG

@liascript/editor

Version:

An extended Markdown interpreter for the creation of interactive online courses.

1 lines 318 kB
!function(e){if(!(void 0!==e.window&&e.document||e.require&&e.define)){e.console||(e.console=function(){var e=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:e})},e.console.error=e.console.warn=e.console.log=e.console.trace=e.console),e.window=e,e.ace=e,e.onerror=function(e,t,n,i,r){postMessage({type:"error",data:{message:e,data:r&&r.data,file:t,line:n,col:i,stack:r&&r.stack}})},e.normalizeModule=function(t,n){if(-1!==n.indexOf("!")){var i=n.split("!");return e.normalizeModule(t,i[0])+"!"+e.normalizeModule(t,i[1])}if("."==n.charAt(0)){var r=t.split("/").slice(0,-1).join("/");for(n=(r?r+"/":"")+n;-1!==n.indexOf(".")&&s!=n;){var s=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(t,n){if(n||(n=t,t=null),!n.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");n=e.normalizeModule(t,n);var i=e.require.modules[n];if(i)return i.initialized||(i.initialized=!0,i.exports=i.factory().exports),i.exports;if(!e.require.tlns)return console.log("unable to load "+n);var r=function(e,t){for(var n=e,i="";n;){var r=t[n];if("string"==typeof r)return r+i;if(r)return r.location.replace(/\/*$/,"/")+(i||r.main||r.name);if(!1===r)return"";var s=n.lastIndexOf("/");if(-1===s)break;i=n.substr(s)+i,n=n.slice(0,s)}return e}(n,e.require.tlns);return".js"!=r.slice(-3)&&(r+=".js"),e.require.id=n,e.require.modules[n]={},importScripts(r),e.require(t,n)},e.require.modules={},e.require.tlns={},e.define=function(t,n,i){if(2==arguments.length?(i=n,"string"!=typeof t&&(n=t,t=e.require.id)):1==arguments.length&&(i=t,n=[],t=e.require.id),"function"==typeof i){n.length||(n=["require","exports","module"]);var r=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=i.apply(this,n.slice(0,i.length).map((function(t){switch(t){case"require":return r;case"exports":return e.exports;case"module":return e;default:return r(t)}})));return t&&(e.exports=t),e}}}else e.require.modules[t]={exports:i,initialized:!0}},e.define.amd={},e.require.tlns={},e.initBaseUrls=function(e){for(var t in e)this.require.tlns[t]=e[t]},e.initSender=function(){var t=e.require("ace/lib/event_emitter").EventEmitter,n=e.require("ace/lib/oop"),i=function(){};return function(){n.implement(this,t),this.callback=function(e,t){postMessage({type:"call",id:t,data:e})},this.emit=function(e,t){postMessage({type:"event",name:e,data:t})}}.call(i.prototype),new i};var t=e.main=null,n=e.sender=null;e.onmessage=function(i){var r=i.data;if(r.event&&n)n._signal(r.event,r.data);else if(r.command)if(t[r.command])t[r.command].apply(t,r.args);else{if(!e[r.command])throw new Error("Unknown command:"+r.command);e[r.command].apply(e,r.args)}else if(r.init){e.initBaseUrls(r.tlns),n=e.sender=e.initSender();var s=this.require(r.module)[r.classname];t=e.main=new s(n)}}}}(this),ace.define("ace/lib/oop",[],(function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}})),ace.define("ace/apply_delta",[],(function(e,t,n){"use strict";t.applyDelta=function(e,t,n){var i=t.start.row,r=t.start.column,s=e[i]||"";switch(t.action){case"insert":if(1===t.lines.length)e[i]=s.substring(0,r)+t.lines[0]+s.substring(r);else{var o=[i,1].concat(t.lines);e.splice.apply(e,o),e[i]=s.substring(0,r)+e[i],e[i+t.lines.length-1]+=s.substring(r)}break;case"remove":var a=t.end.column,l=t.end.row;i===l?e[i]=s.substring(0,r)+s.substring(a):e.splice(i,l-i+1,s.substring(0,r)+e[l].substring(a))}}})),ace.define("ace/lib/event_emitter",[],(function(e,t,n){"use strict";var i={},r=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};i._emit=i._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],i=this._defaultHandlers[e];if(n.length||i){"object"==typeof t&&t||(t={}),t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=r),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length&&(n[o](t,this),!t.propagationStopped);o++);return i&&!t.defaultPrevented?i(t,this):void 0}},i._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(n){n=n.slice();for(var i=0;i<n.length;i++)n[i](t,this)}},i.once=function(e,t){var n=this;if(this.on(e,(function i(){n.off(e,i),t.apply(null,arguments)})),!t)return new Promise((function(e){t=e}))},i.setDefaultHandler=function(e,t){var n=this._defaultHandlers;if(n||(n=this._defaultHandlers={_disabled_:{}}),n[e]){var i=n[e],r=n._disabled_[e];r||(n._disabled_[e]=r=[]),r.push(i);var s=r.indexOf(t);-1!=s&&r.splice(s,1)}n[e]=t},i.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(n){var i=n._disabled_[e];if(n[e]==t)i&&this.setDefaultHandler(e,i.pop());else if(i){var r=i.indexOf(t);-1!=r&&i.splice(r,1)}}},i.on=i.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var i=this._eventRegistry[e];return i||(i=this._eventRegistry[e]=[]),-1==i.indexOf(t)&&i[n?"unshift":"push"](t),t},i.off=i.removeListener=i.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(n){var i=n.indexOf(t);-1!==i&&n.splice(i,1)}},i.removeAllListeners=function(e){e||(this._eventRegistry=this._defaultHandlers=void 0),this._eventRegistry&&(this._eventRegistry[e]=void 0),this._defaultHandlers&&(this._defaultHandlers[e]=void 0)},t.EventEmitter=i})),ace.define("ace/range",[],(function(e,t,n){"use strict";var i=function(){function e(e,t,n,i){this.start={row:e,column:t},this.end={row:n,column:i}}return e.prototype.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},e.prototype.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},e.prototype.contains=function(e,t){return 0==this.compare(e,t)},e.prototype.compareRange=function(e){var t,n=e.end,i=e.start;return 1==(t=this.compare(n.row,n.column))?1==(t=this.compare(i.row,i.column))?2:0==t?1:0:-1==t?-2:-1==(t=this.compare(i.row,i.column))?-1:1==t?42:0},e.prototype.comparePoint=function(e){return this.compare(e.row,e.column)},e.prototype.containsRange=function(e){return 0==this.comparePoint(e.start)&&0==this.comparePoint(e.end)},e.prototype.intersects=function(e){var t=this.compareRange(e);return-1==t||0==t||1==t},e.prototype.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},e.prototype.isStart=function(e,t){return this.start.row==e&&this.start.column==t},e.prototype.setStart=function(e,t){"object"==typeof e?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},e.prototype.setEnd=function(e,t){"object"==typeof e?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},e.prototype.inside=function(e,t){return 0==this.compare(e,t)&&(!this.isEnd(e,t)&&!this.isStart(e,t))},e.prototype.insideStart=function(e,t){return 0==this.compare(e,t)&&!this.isEnd(e,t)},e.prototype.insideEnd=function(e,t){return 0==this.compare(e,t)&&!this.isStart(e,t)},e.prototype.compare=function(e,t){return this.isMultiLine()||e!==this.start.row?e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0:t<this.start.column?-1:t>this.end.column?1:0},e.prototype.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},e.prototype.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},e.prototype.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},e.prototype.clipRows=function(t,n){if(this.end.row>n)var i={row:n+1,column:0};else if(this.end.row<t)i={row:t,column:0};if(this.start.row>n)var r={row:n+1,column:0};else if(this.start.row<t)r={row:t,column:0};return e.fromPoints(r||this.start,i||this.end)},e.prototype.extend=function(t,n){var i=this.compare(t,n);if(0==i)return this;if(-1==i)var r={row:t,column:n};else var s={row:t,column:n};return e.fromPoints(r||this.start,s||this.end)},e.prototype.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},e.prototype.isMultiLine=function(){return this.start.row!==this.end.row},e.prototype.clone=function(){return e.fromPoints(this.start,this.end)},e.prototype.collapseRows=function(){return 0==this.end.column?new e(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new e(this.start.row,0,this.end.row,0)},e.prototype.toScreenRange=function(t){var n=t.documentToScreenPosition(this.start),i=t.documentToScreenPosition(this.end);return new e(n.row,n.column,i.row,i.column)},e.prototype.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t},e}();i.fromPoints=function(e,t){return new i(e.row,e.column,t.row,t.column)},i.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=i})),ace.define("ace/anchor",[],(function(e,t,n){"use strict";function i(e,t,n){var i=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&i}var r=e("./lib/oop"),s=e("./lib/event_emitter").EventEmitter,o=function(){function e(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),"number"!=typeof t?this.setPosition(t.row,t.column):this.setPosition(t,n)}return e.prototype.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},e.prototype.getDocument=function(){return this.document},e.prototype.onChange=function(e){if(!(e.start.row==e.end.row&&e.start.row!=this.row||e.start.row>this.row)){var t=function(e,t,n){var r="insert"==e.action,s=(r?1:-1)*(e.end.row-e.start.row),o=(r?1:-1)*(e.end.column-e.start.column),a=e.start,l=r?a:e.end;return i(t,a,n)?{row:t.row,column:t.column}:i(l,t,!n)?{row:t.row+s,column:t.column+(t.row==l.row?o:0)}:{row:a.row,column:a.column}}(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(t.row,t.column,!0)}},e.prototype.setPosition=function(e,t,n){var i;if(i=n?{row:e,column:t}:this.$clipPositionToDocument(e,t),this.row!=i.row||this.column!=i.column){var r={row:this.row,column:this.column};this.row=i.row,this.column=i.column,this._signal("change",{old:r,value:i})}},e.prototype.detach=function(){this.document.off("change",this.$onChange)},e.prototype.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},e.prototype.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n},e}();o.prototype.$insertRight=!1,r.implement(o.prototype,s),t.Anchor=o})),ace.define("ace/document",[],(function(e,t,n){"use strict";var i=e("./lib/oop"),r=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,a=e("./anchor").Anchor,l=function(){function e(e){this.$lines=[""],0===e.length?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)}return e.prototype.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e||"")},e.prototype.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},e.prototype.createAnchor=function(e,t){return new a(this,e,t)},e.prototype.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},e.prototype.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},e.prototype.setNewLineMode=function(e){this.$newLineMode!==e&&(this.$newLineMode=e,this._signal("changeNewLineMode"))},e.prototype.getNewLineMode=function(){return this.$newLineMode},e.prototype.isNewLine=function(e){return"\r\n"==e||"\r"==e||"\n"==e},e.prototype.getLine=function(e){return this.$lines[e]||""},e.prototype.getLines=function(e,t){return this.$lines.slice(e,t+1)},e.prototype.getAllLines=function(){return this.getLines(0,this.getLength())},e.prototype.getLength=function(){return this.$lines.length},e.prototype.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},e.prototype.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{(t=this.getLines(e.start.row,e.end.row))[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},e.prototype.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},e.prototype.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},e.prototype.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},e.prototype.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},e.prototype.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),i=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:i,action:"insert",lines:[t]},!0),this.clonePos(i)},e.prototype.clippedPos=function(e,t){var n=this.getLength();void 0===e?e=n:e<0?e=0:e>=n&&(e=n-1,t=void 0);var i=this.getLine(e);return null==t&&(t=i.length),{row:e,column:t=Math.min(Math.max(t,0),i.length)}},e.prototype.clonePos=function(e){return{row:e.row,column:e.column}},e.prototype.pos=function(e,t){return{row:e,column:t}},e.prototype.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},e.prototype.insertFullLines=function(e,t){var n=0;(e=Math.min(Math.max(e,0),this.getLength()))<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},e.prototype.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),i={row:n.row+t.length-1,column:(1==t.length?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:i,action:"insert",lines:t}),this.clonePos(i)},e.prototype.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},e.prototype.removeInLine=function(e,t,n){var i=this.clippedPos(e,t),r=this.clippedPos(e,n);return this.applyDelta({start:i,end:r,action:"remove",lines:this.getLinesForRange({start:i,end:r})},!0),this.clonePos(i)},e.prototype.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1);var n=(t=Math.min(Math.max(0,t),this.getLength()-1))==this.getLength()-1&&e>0,i=t<this.getLength()-1,r=n?e-1:e,s=n?this.getLine(r).length:0,a=i?t+1:t,l=i?0:this.getLine(a).length,c=new o(r,s,a,l),u=this.$lines.slice(e,t+1);return this.applyDelta({start:c.start,end:c.end,action:"remove",lines:this.getLinesForRange(c)}),u},e.prototype.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},e.prototype.replace=function(e,t){return e instanceof o||(e=o.fromPoints(e.start,e.end)),0===t.length&&e.isEmpty()?e.start:t==this.getTextRange(e)?e.end:(this.remove(e),t?this.insert(e.start,t):e.start)},e.prototype.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},e.prototype.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},e.prototype.applyDelta=function(e,t){var n="insert"==e.action;(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))||(n&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(r(this.$lines,e,t),this._signal("change",e)))},e.prototype.$safeApplyDelta=function(e){var t=this.$lines.length;("remove"==e.action&&e.start.row<t&&e.end.row<t||"insert"==e.action&&e.start.row<=t)&&this.applyDelta(e)},e.prototype.$splitAndapplyLargeDelta=function(e,t){for(var n=e.lines,i=n.length-t+1,r=e.start.row,s=e.start.column,o=0,a=0;o<i;o=a){a+=t-1;var l=n.slice(o,a);l.push(""),this.applyDelta({start:this.pos(r+o,s),end:this.pos(r+a,s=0),action:e.action,lines:l},!0)}e.lines=n.slice(o),e.start.row=r+o,e.start.column=s,this.applyDelta(e,!0)},e.prototype.revertDelta=function(e){this.$safeApplyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:"insert"==e.action?"remove":"insert",lines:e.lines.slice()})},e.prototype.indexToPosition=function(e,t){for(var n=this.$lines||this.getAllLines(),i=this.getNewLineCharacter().length,r=t||0,s=n.length;r<s;r++)if((e-=n[r].length+i)<0)return{row:r,column:e+n[r].length+i};return{row:s-1,column:e+n[s-1].length+i}},e.prototype.positionToIndex=function(e,t){for(var n=this.$lines||this.getAllLines(),i=this.getNewLineCharacter().length,r=0,s=Math.min(e.row,n.length),o=t||0;o<s;++o)r+=n[o].length+i;return r+e.column},e.prototype.$split=function(e){return e.split(/\r\n|\r|\n/)},e}();l.prototype.$autoNewLine="",l.prototype.$newLineMode="auto",i.implement(l.prototype,s),t.Document=l})),ace.define("ace/lib/deep_copy",[],(function(e,t,n){t.deepCopy=function e(t){if("object"!=typeof t||!t)return t;var n;if(Array.isArray(t)){n=[];for(var i=0;i<t.length;i++)n[i]=e(t[i]);return n}if("[object Object]"!==Object.prototype.toString.call(t))return t;for(var i in n={},t)n[i]=e(t[i]);return n}})),ace.define("ace/lib/lang",[],(function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){for(var n="";t>0;)1&t&&(n+=e),(t>>=1)&&(e+=e);return n};var i=/^\s\s*/,r=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(i,"")},t.stringTrimRight=function(e){return e.replace(r,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){for(var t=[],n=0,i=e.length;n<i;n++)e[n]&&"object"==typeof e[n]?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=e("./deep_copy").deepCopy,t.arrayToMap=function(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return(""+e).replace(/&/g,"&#38;").replace(/"/g,"&#34;").replace(/'/g,"&#39;").replace(/</g,"&#60;")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,(function(e){n.push({offset:arguments[arguments.length-2],length:e.length})})),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},i=function(e){return i.cancel(),t=setTimeout(n,e||0),i};return i.schedule=i,i.call=function(){return this.cancel(),e(),i},i.cancel=function(){return clearTimeout(t),t=null,i},i.isPending=function(){return t},i},t.delayedCall=function(e,t){var n=null,i=function(){n=null,e()},r=function(e){null==n&&(n=setTimeout(i,e||t))};return r.delay=function(e){n&&clearTimeout(n),n=setTimeout(i,e||t)},r.schedule=r,r.call=function(){this.cancel(),e()},r.cancel=function(){n&&clearTimeout(n),n=null},r.isPending=function(){return n},r},t.supportsLookbehind=function(){try{new RegExp("(?<=.)")}catch(e){return!1}return!0},t.skipEmptyMatch=function(e,t,n){return n&&e.codePointAt(t)>65535?2:1}})),ace.define("ace/worker/mirror",[],(function(e,t,n){"use strict";var i=e("../document").Document,r=e("../lib/lang"),s=t.Mirror=function(e){this.sender=e;var t=this.doc=new i(""),n=this.deferredUpdate=r.delayedCall(this.onUpdate.bind(this)),s=this;e.on("change",(function(e){var i=e.data;if(i[0].start)t.applyDeltas(i);else for(var r=0;r<i.length;r+=2){var o,a;if(("insert"==(o=Array.isArray(i[r+1])?{action:"insert",start:i[r],lines:i[r+1]}:{action:"remove",start:i[r],end:i[r+1]}).action?o.start:o.end).row>=t.$lines.length)throw(a=new Error("Invalid delta")).data={path:s.$path,linesLength:t.$lines.length,start:o.start,end:o.end},a;t.applyDelta(o,!0)}if(s.$timeout)return n.schedule(s.$timeout);s.onUpdate()}))};(function(){this.$timeout=500,this.setTimeout=function(e){this.$timeout=e},this.setValue=function(e){this.doc.setValue(e),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(e){this.sender.callback(this.doc.getValue(),e)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(s.prototype)})),ace.define("ace/mode/coffee/coffee",[],(function(require,exports,module){function define(e){module.exports=e()}function _toArray(e){return Array.isArray(e)?e:Array.from(e)}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}define.amd={};var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_get=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,n,i)}if("value"in r)return r.value;var o=r.get;return void 0===o?void 0:o.call(i)},_slicedToArray=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],i=!0,r=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(i=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);i=!0);}catch(e){r=!0,s=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw s}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},_createClass=function(){function e(e,t){for(var n,i=0;i<t.length;i++)(n=t[i]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();(function(root){var CoffeeScript=function(){function require(e){return require[e]}var _Mathabs=Math.abs,_StringfromCharCode=String.fromCharCode,_Mathfloor=Math.floor,e,t,n;return require["../../package.json"]={name:"coffeescript",description:"Unfancy JavaScript",keywords:["javascript","language","coffeescript","compiler"],author:"Jeremy Ashkenas",version:"2.2.1",license:"MIT",engines:{node:">=6"},directories:{lib:"./lib/coffeescript"},main:"./lib/coffeescript/index",browser:"./lib/coffeescript/browser",bin:{coffee:"./bin/coffee",cake:"./bin/cake"},files:["bin","lib","register.js","repl.js"],scripts:{test:"node ./bin/cake test","test-harmony":"node --harmony ./bin/cake test"},homepage:"http://coffeescript.org",bugs:"https://github.com/jashkenas/coffeescript/issues",repository:{type:"git",url:"git://github.com/jashkenas/coffeescript.git"},devDependencies:{"babel-core":"~6.26.0","babel-preset-babili":"~0.1.4","babel-preset-env":"~1.6.1","babel-preset-minify":"^0.3.0",codemirror:"^5.32.0",docco:"~0.8.0","highlight.js":"~9.12.0",jison:">=0.4.18","markdown-it":"~8.4.0",underscore:"~1.8.3",webpack:"~3.10.0"},dependencies:{}},require["./helpers"]=function(){var e={};return function(){var t,n,i,r,s,o,a,l;e.starts=function(e,t,n){return t===e.substr(n,t.length)},e.ends=function(e,t,n){var i;return i=t.length,t===e.substr(e.length-i-(n||0),i)},e.repeat=a=function(e,t){var n;for(n="";0<t;)1&t&&(n+=e),t>>>=1,e+=e;return n},e.compact=function(e){var t,n,i,r;for(r=[],t=0,i=e.length;t<i;t++)(n=e[t])&&r.push(n);return r},e.count=function(e,t){var n,i;if(n=i=0,!t.length)return 1/0;for(;i=1+e.indexOf(t,i);)n++;return n},e.merge=function(e,t){return r(r({},e),t)},r=e.extend=function(e,t){var n,i;for(n in t)i=t[n],e[n]=i;return e},e.flatten=s=function(e){var t,n,i,r;for(n=[],i=0,r=e.length;i<r;i++)t=e[i],"[object Array]"===Object.prototype.toString.call(t)?n=n.concat(s(t)):n.push(t);return n},e.del=function(e,t){var n;return n=e[t],delete e[t],n},e.some=null==(o=Array.prototype.some)?function(e){var t,n;for(this,t=0,n=this.length;t<n;t++)if(e(this[t]))return!0;return!1}:o,e.invertLiterate=function(e){var t,n,i,r,s,o,a,l,c;for(l=[],t=/^\s*$/,i=/^[\t ]/,a=/^(?:\t?| {0,3})(?:[\*\-\+]|[0-9]{1,9}\.)[ \t]/,r=!1,n=0,s=(c=e.split("\n")).length;n<s;n++)o=c[n],t.test(o)?(r=!1,l.push(o)):r||a.test(o)?(r=!0,l.push("# "+o)):!r&&i.test(o)?l.push(o):(r=!0,l.push("# "+o));return l.join("\n")},n=function(e,t){return t?{first_line:e.first_line,first_column:e.first_column,last_line:t.last_line,last_column:t.last_column}:e},i=function(e){return e.first_line+"x"+e.first_column+"-"+e.last_line+"x"+e.last_column},e.addDataToNode=function(e,r,s){return function(o){var a,l,c,u,h,p;if(null!=(null==o?void 0:o.updateLocationDataIfMissing)&&null!=r&&o.updateLocationDataIfMissing(n(r,s)),!e.tokenComments)for(e.tokenComments={},a=0,l=(u=e.parser.tokens).length;a<l;a++)if((h=u[a]).comments)if(p=i(h[2]),null==e.tokenComments[p])e.tokenComments[p]=h.comments;else{var d;(d=e.tokenComments[p]).push.apply(d,_toConsumableArray(h.comments))}return null!=o.locationData&&(c=i(o.locationData),null!=e.tokenComments[c]&&t(e.tokenComments[c],o)),o}},e.attachCommentsToNode=t=function(e,t){var n;if(null!=e&&0!==e.length)return null==t.comments&&(t.comments=[]),(n=t.comments).push.apply(n,_toConsumableArray(e))},e.locationDataToString=function(e){var t;return"2"in e&&"first_line"in e[2]?t=e[2]:"first_line"in e&&(t=e),t?t.first_line+1+":"+(t.first_column+1)+"-"+(t.last_line+1)+":"+(t.last_column+1):"No location data"},e.baseFileName=function(e){var t,n,i=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return n=2<arguments.length&&void 0!==arguments[2]&&arguments[2]?/\\|\//:/\//,t=e.split(n),e=t[t.length-1],i&&0<=e.indexOf(".")?((t=e.split(".")).pop(),"coffee"===t[t.length-1]&&1<t.length&&t.pop(),t.join(".")):e},e.isCoffee=function(e){return/\.((lit)?coffee|coffee\.md)$/.test(e)},e.isLiterate=function(e){return/\.(litcoffee|coffee\.md)$/.test(e)},e.throwSyntaxError=function(e,t){var n;throw(n=new SyntaxError(e)).location=t,n.toString=l,n.stack=n.toString(),n},e.updateSyntaxError=function(e,t,n){return e.toString===l&&(e.code||(e.code=t),e.filename||(e.filename=n),e.stack=e.toString()),e},l=function(){var e,t,n,i,r,s,o,l,c,u,h,p,d,f;if(!this.code||!this.location)return Error.prototype.toString.call(this);var m=this.location;return o=m.first_line,s=m.first_column,null==(c=m.last_line)&&(c=o),null==(l=m.last_column)&&(l=s),r=this.filename||"[stdin]",e=this.code.split("\n")[o],f=s,i=o===c?l+1:e.length,u=e.slice(0,f).replace(/[^\s]/g," ")+a("^",i-f),"undefined"!=typeof process&&null!==process&&(n=(null==(h=process.stdout)?void 0:h.isTTY)&&(null==(p=process.env)||!p.NODE_DISABLE_COLORS)),(null==(d=this.colorful)?n:d)&&(t=function(e){return""+e+""},e=e.slice(0,f)+t(e.slice(f,i))+e.slice(i),u=t(u)),r+":"+(o+1)+":"+(s+1)+": error: "+this.message+"\n"+e+"\n"+u},e.nameWhitespaceCharacter=function(e){return" "===e?"space":"\n"===e?"newline":"\r"===e?"carriage return":"\t"===e?"tab":e}}.call(this),{exports:e}.exports}(),require["./rewriter"]=function(){var e={};return function(){var t,n,i,r,s,o,a,l,c,u,h,p,d,f,m,v,g,y,b,k,_,w,T=[].indexOf,C=require("./helpers");for(w=C.throwSyntaxError,k=function(e,t){var n,i,r,s,o;if(e.comments){if(t.comments&&0!==t.comments.length){for(o=[],i=0,r=(s=e.comments).length;i<r;i++)(n=s[i]).unshift?o.push(n):t.comments.push(n);t.comments=o.concat(t.comments)}else t.comments=e.comments;return delete e.comments}},v=function(e,t,n,i){var r;return(r=[e,t]).generated=!0,n&&(r.origin=n),i&&k(i,r),r},e.Rewriter=function(){var e=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"rewrite",value:function(e){var t,n,i;return this.tokens=e,("undefined"!=typeof process&&null!==process?null==(t=process.env)?void 0:t.DEBUG_TOKEN_STREAM:void 0)&&(process.env.DEBUG_REWRITTEN_TOKEN_STREAM&&console.log("Initial token stream:"),console.log(function(){var e,t,n,r;for(r=[],e=0,t=(n=this.tokens).length;e<t;e++)i=n[e],r.push(i[0]+"/"+i[1]+(i.comments?"*":""));return r}.call(this).join(" "))),this.removeLeadingNewlines(),this.closeOpenCalls(),this.closeOpenIndexes(),this.normalizeLines(),this.tagPostfixConditionals(),this.addImplicitBracesAndParens(),this.addParensToChainedDoIife(),this.rescueStowawayComments(),this.addLocationDataToGeneratedTokens(),this.enforceValidCSXAttributes(),this.fixOutdentLocationData(),("undefined"!=typeof process&&null!==process?null==(n=process.env)?void 0:n.DEBUG_REWRITTEN_TOKEN_STREAM:void 0)&&(process.env.DEBUG_TOKEN_STREAM&&console.log("Rewritten token stream:"),console.log(function(){var e,t,n,r;for(r=[],e=0,t=(n=this.tokens).length;e<t;e++)i=n[e],r.push(i[0]+"/"+i[1]+(i.comments?"*":""));return r}.call(this).join(" "))),this.tokens}},{key:"scanTokens",value:function(e){var t,n,i;for(i=this.tokens,t=0;n=i[t];)t+=e.call(this,n,t,i);return!0}},{key:"detectEnd",value:function(e,t,n){var i,r,s,l,c,u=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};for(c=this.tokens,i=0;l=c[e];){if(0===i&&t.call(this,l,e))return n.call(this,l,e);if(r=l[0],0<=T.call(a,r)?i+=1:(s=l[0],0<=T.call(o,s)&&(i-=1)),0>i)return u.returnOnNegativeLevel?void 0:n.call(this,l,e);e+=1}return e-1}},{key:"removeLeadingNewlines",value:function(){var e,t,n,i,r,s,o,a;for(e=t=0,r=(o=this.tokens).length;t<r;e=++t){if("TERMINATOR"!==_slicedToArray(o[e],1)[0])break}if(0!==e){for(n=0,s=(a=this.tokens.slice(0,e)).length;n<s;n++)i=a[n],k(i,this.tokens[e]);return this.tokens.splice(0,e)}}},{key:"closeOpenCalls",value:function(){var e,t;return t=function(e){var t;return")"===(t=e[0])||"CALL_END"===t},e=function(e){return e[0]="CALL_END"},this.scanTokens((function(n,i){return"CALL_START"===n[0]&&this.detectEnd(i+1,t,e),1}))}},{key:"closeOpenIndexes",value:function(){var e,t;return t=function(e){var t;return"]"===(t=e[0])||"INDEX_END"===t},e=function(e){return e[0]="INDEX_END"},this.scanTokens((function(n,i){return"INDEX_START"===n[0]&&this.detectEnd(i+1,t,e),1}))}},{key:"indexOfTag",value:function(e){var t,n,i,r;for(var s=arguments.length,o=Array(1<s?s-1:0),a=1;a<s;a++)o[a-1]=arguments[a];for(t=n=0,i=o.length;0<=i?0<=n&&n<i:0>=n&&n>i;t=0<=i?++n:--n)if(null!=o[t]&&("string"==typeof o[t]&&(o[t]=[o[t]]),r=this.tag(e+t+0),0>T.call(o[t],r)))return-1;return e+t+0-1}},{key:"looksObjectish",value:function(e){var t,n;return-1!==this.indexOfTag(e,"@",null,":")||-1!==this.indexOfTag(e,null,":")||-1!==(n=this.indexOfTag(e,a))&&(t=null,this.detectEnd(n+1,(function(e){var t;return t=e[0],0<=T.call(o,t)}),(function(e,n){return t=n})),":"===this.tag(t+1))}},{key:"findTagsBackwards",value:function(e,t){var n,i,r,s,l,c,u;for(n=[];0<=e&&(n.length||(s=this.tag(e),0>T.call(t,s)&&(l=this.tag(e),0>T.call(a,l)||this.tokens[e].generated)&&(c=this.tag(e),0>T.call(d,c))));)i=this.tag(e),0<=T.call(o,i)&&n.push(this.tag(e)),r=this.tag(e),0<=T.call(a,r)&&n.length&&n.pop(),e-=1;return u=this.tag(e),0<=T.call(t,u)}},{key:"addImplicitBracesAndParens",value:function(){var e,t;return e=[],t=null,this.scanTokens((function(r,s,p){var f,m,g,y,b,k,_,w,C,N,A,E,D,R,x,O,S,L,I,F,P,j,$,M,U,V,B,H,G,W,X,q,Y,z=this;Y=_slicedToArray(r,1)[0];var J=I=0<s?p[s-1]:[],K=_slicedToArray(J,1);L=K[0];var Q=O=s<p.length-1?p[s+1]:[];if(x=_slicedToArray(Q,1)[0],H=function(){return e[e.length-1]},G=s,g=function(e){return s-G+e},N=function(e){var t;return null==e||null==(t=e[2])?void 0:t.ours},E=function(e){return N(e)&&"{"===(null==e?void 0:e[0])},A=function(e){return N(e)&&"("===(null==e?void 0:e[0])},k=function(){return N(H())},C=function(){return E(H())},w=function(){var e;return k()&&"CONTROL"===(null==(e=H())?void 0:e[0])},W=function(t){return e.push(["(",t,{ours:!0}]),p.splice(t,0,v("CALL_START","(",["","implicit function call",r[2]],I))},f=function(){return e.pop(),p.splice(s,0,v("CALL_END",")",["","end of input",r[2]],I)),s+=1},X=function(t){var n,i=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];return e.push(["{",t,{sameLine:!0,startsLine:i,ours:!0}]),(n=new String("{")).generated=!0,p.splice(t,0,v("{",n,r,I))},m=function(t){return t=null==t?s:t,e.pop(),p.splice(t,0,v("}","}",r,I)),s+=1},y=function(e){var t;return t=null,z.detectEnd(e,(function(e){return"TERMINATOR"===e[0]}),(function(e,n){return t=n}),{returnOnNegativeLevel:!0}),null!=t&&z.looksObjectish(t+1)},((_=function(){return A(H())})()||C())&&0<=T.call(i,Y)||C()&&":"===L&&"FOR"===Y)return e.push(["CONTROL",s,{ours:!0}]),g(1);if("INDENT"===Y&&k()){if("=>"!==L&&"->"!==L&&"["!==L&&"("!==L&&","!==L&&"{"!==L&&"ELSE"!==L&&"="!==L)for(;_()||C()&&":"!==L;)_()?f():m();return w()&&e.pop(),e.push([Y,s]),g(1)}if(0<=T.call(a,Y))return e.push([Y,s]),g(1);if(0<=T.call(o,Y)){for(;k();)_()?f():C()?m():e.pop();t=e.pop()}if(b=function(){var e,t;return!!(z.findTagsBackwards(s,["FOR"])&&z.findTagsBackwards(s,["FORIN","FOROF","FORFROM"])||z.findTagsBackwards(s,["WHILE","UNTIL","LOOP","LEADING_WHEN"]))&&(e=!1,t=r[2].first_line,z.detectEnd(s,(function(e){var t;return t=e[0],0<=T.call(d,t)}),(function(n,i){var r,s=p[i-1]||[],o=_slicedToArray(s,3);return L=o[0],r=o[2].first_line,e=t===r&&("->"===L||"=>"===L)}),{returnOnNegativeLevel:!0}),e)},(0<=T.call(u,Y)&&r.spaced||"?"===Y&&0<s&&!p[s-1].spaced)&&(0<=T.call(l,x)||"..."===x&&(F=this.tag(s+2),0<=T.call(l,F))&&!this.findTagsBackwards(s,["INDEX_START","["])||0<=T.call(h,x)&&!O.spaced&&!O.newLine)&&!b())return"?"===Y&&(Y=r[0]="FUNC_EXIST"),W(s+1),g(2);if(0<=T.call(u,Y)&&-1<this.indexOfTag(s+1,"INDENT")&&this.looksObjectish(s+2)&&!this.findTagsBackwards(s,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"]))return W(s+1),e.push(["INDENT",s+2]),g(3);if(":"===Y){if($=function(){var e;switch(!1){case e=this.tag(s-1),0>T.call(o,e):return t[1];case"@"!==this.tag(s-2):return s-2;default:return s-1}}.call(this),q=0>=$||(P=this.tag($-1),0<=T.call(d,P))||p[$-1].newLine,H()){var Z=H(),ee=_slicedToArray(Z,2);if(B=ee[0],U=ee[1],("{"===B||"INDENT"===B&&"{"===this.tag(U-1))&&(q||","===this.tag($-1)||"{"===this.tag($-1)))return g(1)}return X($,!!q),g(2)}if(0<=T.call(d,Y))for(D=e.length-1;0<=D&&(V=e[D],N(V));D+=-1)E(V)&&(V[2].sameLine=!1);if(R="OUTDENT"===L||I.newLine,0<=T.call(c,Y)||0<=T.call(n,Y)&&R||(".."===Y||"..."===Y)&&this.findTagsBackwards(s,["INDEX_START"]))for(;k();){var te=H(),ne=_slicedToArray(te,3);B=ne[0],U=ne[1];var ie=ne[2];if(M=ie.sameLine,q=ie.startsLine,_()&&","!==L||","===L&&"TERMINATOR"===Y&&null==x)f();else if(C()&&M&&"TERMINATOR"!==Y&&":"!==L&&("POST_IF"!==Y&&"FOR"!==Y&&"WHILE"!==Y&&"UNTIL"!==Y||!q||!y(s+1)))m();else{if(!C()||"TERMINATOR"!==Y||","===L||q&&this.looksObjectish(s+1))break;m()}}if(","===Y&&!this.looksObjectish(s+1)&&C()&&"FOROF"!==(j=this.tag(s+2))&&"FORIN"!==j&&("TERMINATOR"!==x||!this.looksObjectish(s+2)))for(S="OUTDENT"===x?1:0;C();)m(s+S);return g(1)}))}},{key:"enforceValidCSXAttributes",value:function(){return this.scanTokens((function(e,t,n){var i,r;return e.csxColon&&("STRING_START"!==(r=(i=n[t+1])[0])&&"STRING"!==r&&"("!==r&&w("expected wrapped or quoted JSX attribute",i[2])),1}))}},{key:"rescueStowawayComments",value:function(){var e,t,n;return e=function(e,t,n,i){return"TERMINATOR"!==n[t][0]&&n[i](v("TERMINATOR","\n",n[t])),n[i](v("JS","",n[t],e))},n=function(t,n,i){var s,o,a,l,c,u;for(s=n;s!==i.length&&(l=i[s][0],0<=T.call(r,l));)s++;if(s===i.length||(c=i[s][0],0<=T.call(r,c)))return s=i.length-1,e(t,s,i,"push"),1;for(o=0,a=(u=t.comments).length;o<a;o++)u[o].unshift=!0;return k(t,i[s]),1},t=function(t,n,i){var s,o,a;for(s=n;-1!==s&&(o=i[s][0],0<=T.call(r,o));)s--;return-1===s||(a=i[s][0],0<=T.call(r,a))?(e(t,0,i,"unshift"),3):(k(t,i[s]),1)},this.scanTokens((function(e,i,s){var o,a,l,c,u;if(!e.comments)return 1;if(u=1,l=e[0],0<=T.call(r,l)){for(o={comments:[]},a=e.comments.length-1;-1!==a;)!1===e.comments[a].newLine&&!1===e.comments[a].here&&(o.comments.unshift(e.comments[a]),e.comments.splice(a,1)),a--;0!==o.comments.length&&(u=t(o,i-1,s)),0!==e.comments.length&&n(e,i,s)}else{for(o={comments:[]},a=e.comments.length-1;-1!==a;)!e.comments[a].newLine||e.comments[a].unshift||"JS"===e[0]&&e.generated||(o.comments.unshift(e.comments[a]),e.comments.splice(a,1)),a--;0!==o.comments.length&&(u=n(o,i+1,s))}return 0===(null==(c=e.comments)?void 0:c.length)&&delete e.comments,u}))}},{key:"addLocationDataToGeneratedTokens",value:function(){return this.scanTokens((function(e,t,n){var i,r,s,o,a,l;if(e[2])return 1;if(!e.generated&&!e.explicit)return 1;if("{"===e[0]&&(s=null==(a=n[t+1])?void 0:a[2])){var c=s;r=c.first_line,i=c.first_column}else if(o=null==(l=n[t-1])?void 0:l[2]){var u=o;r=u.last_line,i=u.last_column}else r=i=0;return e[2]={first_line:r,first_column:i,last_line:r,last_column:i},1}))}},{key:"fixOutdentLocationData",value:function(){return this.scanTokens((function(e,t,n){var i;return"OUTDENT"===e[0]||e.generated&&"CALL_END"===e[0]||e.generated&&"}"===e[0]?(i=n[t-1][2],e[2]={first_line:i.last_line,first_column:i.last_column,last_line:i.last_line,last_column:i.last_column},1):1}))}},{key:"addParensToChainedDoIife",value:function(){var e,t,i;return t=function(e,t){return"OUTDENT"===this.tag(t-1)},e=function(e,t){var r;if(r=e[0],!(0>T.call(n,r)))return this.tokens.splice(i,0,v("(","(",this.tokens[i])),this.tokens.splice(t+1,0,v(")",")",this.tokens[t]))},i=null,this.scanTokens((function(n,r){var s,o;return"do"===n[1]?(i=r,s=r+1,"PARAM_START"===this.tag(r+1)&&(s=null,this.detectEnd(r+1,(function(e,t){return"PARAM_END"===this.tag(t-1)}),(function(e,t){return s=t}))),null==s||"->"!==(o=this.tag(s))&&"=>"!==o||"INDENT"!==this.tag(s+1)?1:(this.detectEnd(s+1,t,e),2)):1}))}},{key:"normalizeLines",value:function(){var e,t,i,r,o,a,l,c,u,h=this;return u=o=c=null,l=null,a=null,r=[],i=function(e,t){var i,r,o,c;return";"!==e[1]&&(i=e[0],0<=T.call(f,i))&&!("TERMINATOR"===e[0]&&(r=this.tag(t+1),0<=T.call(s,r)))&&("ELSE"!==e[0]||"THEN"===u&&!a&&!l)&&("CATCH"!==(o=e[0])&&"FINALLY"!==o||"->"!==u&&"=>"!==u)||(c=e[0],0<=T.call(n,c)&&(this.tokens[t-1].newLine||"OUTDENT"===this.tokens[t-1][0]))},e=function(e,t){return"ELSE"===e[0]&&"THEN"===u&&r.pop(),this.tokens.splice(","===this.tag(t-1)?t-1:t,0,c)},t=function(e,t){var n,i,s;if(0<(s=r.length)){n=r.pop();var o=h.indentation(e[n]);return(i=_slicedToArray(o,2)[1])[1]=2*s,e.splice(t,0,i),i[1]=2,e.splice(t+1,0,i),h.detectEnd(t+2,(function(e){var t;return"OUTDENT"===(t=e[0])||"TERMINATOR"===t}),(function(t,n){if("OUTDENT"===this.tag(n)&&"OUTDENT"===this.tag(n+1))return e.splice(n,2)})),t+2}return t},this.scanTokens((function(n,h,p){var d,f,v,g,y,b;if(d=("->"===(b=_slicedToArray(n,1)[0])||"=>"===b)&&this.findTagsBackwards(h,["IF","WHILE","FOR","UNTIL","SWITCH","WHEN","LEADING_WHEN","[","INDEX_START"])&&!this.findTagsBackwards(h,["THEN","..","..."]),"TERMINATOR"===b){if("ELSE"===this.tag(h+1)&&"OUTDENT"!==this.tag(h-1))return p.splice.apply(p,[h,1].concat(_toConsumableArray(this.indentation()))),1;if(g=this.tag(h+1),0<=T.call(s,g))return p.splice(h,1),0}if("CATCH"===b)for(f=v=1;2>=v;f=++v)if("OUTDENT"===(y=this.tag(h+f))||"TERMINATOR"===y||"FINALLY"===y)return p.splice.apply(p,[h+f,0].concat(_toConsumableArray(this.indentation()))),2+f;if("->"!==b&&"=>"!==b||!(","===this.tag(h+1)||"."===this.tag(h+1)&&n.newLine)){if(0<=T.call(m,b)&&"INDENT"!==this.tag(h+1)&&("ELSE"!==b||"IF"!==this.tag(h+1))&&!d){u=b;var k=this.indentation(p[h]),_=_slicedToArray(k,2);return o=_[0],c=_[1],"THEN"===u&&(o.fromThen=!0),"THEN"===b&&(l=this.findTagsBackwards(h,["LEADING_WHEN"])&&"IF"===this.tag(h+1),a=this.findTagsBackwards(h,["IF"])&&"IF"===this.tag(h+1)),"THEN"===b&&this.findTagsBackwards(h,["IF"])&&r.push(h),"ELSE"===b&&"OUTDENT"!==this.tag(h-1)&&(h=t(p,h)),p.splice(h+1,0,o),this.detectEnd(h+2,i,e),"THEN"===b&&p.splice(h,1),1}return 1}var w=this.indentation(p[h]),C=_slicedToArray(w,2);return o=C[0],c=C[1],p.splice(h+1,0,o,c),1}))}},{key:"tagPostfixConditionals",value:function(){var e,t,n;return n=null,t=function(e,t){var n,i;return i=_slicedToArray(e,1)[0],n=_slicedToArray(this.tokens[t-1],1)[0],"TERMINATOR"===i||"INDENT"===i&&0>T.call(m,n)},e=function(e){if("INDENT"!==e[0]||e.generated&&!e.fromThen)return n[0]="POST_"+n[0]},this.scanTokens((function(i,r){return"IF"===i[0]?(n=i,this.detectEnd(r+1,t,e),1):1}))}},{key:"indentation",value:function(e){var t,n;return t=["INDENT",2],n=["OUTDENT",2],e?(t.generated=n.generated=!0,t.origin=n.origin=e):t.explicit=n.explicit=!0,[t,n]}},{key:"tag",value:function(e){var t;return null==(t=this.tokens[e])?void 0:t[0]}}]),e}();return e.prototype.generate=v,e}.call(this),t=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],["REGEX_START","REGEX_END"]],e.INVERSES=p={},a=[],o=[],g=0,b=t.length;g<b;g++){var N=_slicedToArray(t[g],2);y=N[0],_=N[1],a.push(p[_]=y),o.push(p[y]=_)}s=["CATCH","THEN","ELSE","FINALLY"].concat(o),u=["IDENTIFIER","PROPERTY","SUPER",")","CALL_END","]","INDEX_END","@","THIS"],l=["IDENTIFIER","CSX_TAG","PROPERTY","NUMBER","INFINITY","NAN","STRING","STRING_START","REGEX","REGEX_START","JS","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","UNDEFINED","NULL","BOOL","UNARY","YIELD","AWAIT","UNARY_MATH","SUPER","THROW","@","->","=>","[","(","{","--","++"],m=["ELSE","->","=>","TRY","FINALLY","THEN"],f=["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"],d=["TERMINATOR","INDENT","OUTDENT"],r=["(",")","[","]","{","}",".","..","...",",","=","++","--","?","AS","AWAIT","CALL_START","CALL_END","DEFAULT","ELSE","EXTENDS","EXPORT","FORIN","FOROF","FORFROM","IMPORT","INDENT","INDEX_SOAK","LEADING_WHEN","OUTDENT","PARAM_END","REGEX_START","REGEX_END","RETURN","STRING_END","THROW","UNARY","YIELD"].concat((h=["+","-"]).concat((c=["POST_IF","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR"]).concat((n=[".","?.","::","?::"]).concat(i=["IF","TRY","FINALLY","CATCH","CLASS","SWITCH"]))))}.call(this),{exports:e}.exports}(),require["./lexer"]=function(){var e={};return function(){var t,n,i,r,s,o,a,l,c,u,h,p,d,f,m,v,g,y,b,k,_,w,T,C,N,A,E,D,R,x,O,S,L,I,F,P,j,$,M,U,V,B,H,G,W,X,q,Y,z,J,K,Q,Z,ee,te,ne,ie,re,se,oe,ae,le,ce,ue,he,pe,de,fe,me,ve=[].indexOf,ge=[].slice,ye=require("./rewriter");G=ye.Rewriter,A=ye.INVERSES;var be=require("./helpers");le=be.count,be.starts,be.compact,fe=be.repeat,ce=be.invertLiterate,de=be.merge,ae=be.attachCommentsToNode,be.locationDataToString,me=be.throwSyntaxError,e.Lexer=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"tokenize",value:function(e){var t,n,i,r,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};for(this.literate=s.literate,this.indent=0,this.baseIndent=0,this.indebt=0,this.outdebt=0,this.indents=[],this.indentLiteral="",this.ends=[],this.tokens=[],this.seenFor=!1,this.seenImport=!1,this.seenExport=!1,this.importSpecifierList=!1,this.exportSpecifierList=!1,this.csxDepth=0,this.csxObjAttribute={},this.chunkLine=s.line||0,this.chunkColumn=s.column||0,e=this.clean(e),i=0;this.chunk=e.slice(i);){t=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.csxToken()||this.regexToken()||this.jsToken()||this.literalToken();var o=this.getLineAndColumnFromChunk(t),a=_slicedToArray(o,2);if(this.chunkLine=a[0],this.chunkColumn=a[1],i+=t,s.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:i}}return this.closeIndentation(),(n=this.ends.pop())&&this.error("missing "+n.tag,(null==(r=n.origin)?n:r)[2]),!1===s.rewrite?this.tokens:(new G).rewrite(this.tokens)}},{key:"clean",value:function(e){return e.charCodeAt(0)===t&&(e=e.slice(1)),e=e.replace(/\r/g,"").replace(ee,""),oe.test(e)&&(e="\n"+e,this.chunkLine--),this.literate&&(e=ce(e)),e}},{key:"identifierToken",value:function(){var e,t,i,a,l,c,u,p,d,f,m,v,g,y,b,k,_,T,C,N,A,E,R,O,S,L;if(!(d=((u=this.atCSXTag())?h:w).exec(this.chunk)))return 0;var I=_slicedToArray(d,3);if(p=I[0],l=I[1],t=I[2],c=l.length,f=void 0,"own"===l&&"FOR"===this.tag())return this.token("OWN",l),l.length;if("from"===l&&"YIELD"===this.tag())return this.token("FROM",l),l.length;if("as"===l&&this.seenImport){if("*"===this.value())this.tokens[this.tokens.length-1][0]="IMPORT_ALL";else if(g=this.value(!0),0<=ve.call(o,g)){m=this.prev();var F=["IDENTIFIER",this.value(!0)];m[0]=F[0],m[1]=F[1]}if("DEFAULT"===(y=this.tag())||"IMPORT_ALL"===y||"IDENTIFIER"===y)return this.token("AS",l),l.length}if("as"===l&&this.seenExport){if("IDENTIFIER"===(k=this.tag())||"DEFAULT"===k)return this.token("AS",l),l.length;if(_=this.value(!0),0<=ve.call(o,_)){m=this.prev();var P=["IDENTIFIER",this.value(!0)];return m[0]=P[0],m[1]=P[1],this.token("AS",l),l.length}}if("default"!==l||!this.seenExport||"EXPORT"!==(T=this.tag())&&"AS"!==T){if("do"===l&&(O=/^(\s*super)(?!\(\))/.exec(this.chunk.slice(3)))){this.token("SUPER","super"),this.token("CALL_START","("),this.token("CALL_END",")");var j=_slicedToArray(O,2);return p=j[0],j[1].length+3}if(m=this.prev(),"IDENTIFIER"!==(S=t||null!=m&&("."===(C=m[0])||"?."===C||"::"===C||"?::"===C||!m.spaced&&"@"===m[0])?"PROPERTY":"IDENTIFIER")||!(0<=ve.call(D,l)||0<=ve.call(o,l))||this.exportSpecifierList&&0<=ve.call(o,l)?"IDENTIFIER"===S&&this.seenFor&&"from"===l&&ue(m)?(S="FORFROM",this.seenFor=!1):"PROPERTY"===S&&m&&(m.spaced&&(A=m[0],0<=ve.call(n,A))&&/^[gs]et$/.test(m[1])&&1<this.tokens.length&&"."!==(E=this.tokens[this.tokens.length-2][0])&&"?."!==E&&"@"!==E?this.error("'"+m[1]+"' cannot be used as a keyword, or as a function call without parentheses",m[2]):2<this.tokens.length&&(v=this.tokens[this.tokens.length-2],("@"===(R=m[0])||"THIS"===R)&&v&&v.spaced&&/^[gs]et$/.test(v[1])&&"."!==(b=this.tokens[this.tokens.length-3][0])&&"?."!==b&&"@"!==b&&this.error("'"+v[1]+"' cannot be used as a keyword, or as a function call without parentheses",v[2]))):"WHEN"===(S=l.toUpperCase())&&(N=this.tag(),0<=ve.call(x,N))?S="LEADING_WHEN":"FOR"===S?this.seenFor=!0:"UNLESS"===S?S="IF":"IMPORT"===S?this.seenImport=!0:"EXPORT"===S?this.seenExport=!0:0<=ve.call(te,S)?S="UNARY":0<=ve.call(B,S)&&("INSTANCEOF"!==S&&this.seenFor?(S="FOR"+S,this.seenFor=!1):(S="RELATION","!"===this.value()&&(f=this.tokens.pop(),l="!"+l))),"IDENTIFIER"===S&&0<=ve.call(H,l)&&this.error("reserved word '"+l+"'",{length:l.length}),"PROPERTY"===S||this.exportSpecifierList||(0<=ve.call(r,l)&&(e=l,l=s[l]),S="!"===l?"UNARY":"=="===l||"!="===l?"COMPARE":"true"===l||"false"===l?"BOOL":"break"===l||"continue"===l||"debugger"===l?"STATEMENT":"&&"===l||"||"===l?l:S),L=this.token(S,l,0,c),e&&(L.origin=[S,e,L[2]]),f){var $=[f[2].first_line,f[2].first_column];L[2].first_line=$[0],L[2].first_column=$[1]}return t&&(i=p.lastIndexOf(u?"=":":"),a=this.token(":",":",i,t.length),u&&(a.csxColon=!0)),u&&"IDENTIFIER"===S&&":"!==m[0]&&this.token(",",",",0,0,L),p.length}return this.token("DEFAULT",l),l.length}},{key:"numberToken",value:function(){var e,t,n,i,r;if(!(n=F.exec(this.chunk)))return 0;switch(t=(i=n[0]).length,!1){case!/^0[BOX]/.test(i):this.error("radix prefix in '"+i+"' must be lowercase",{offset:1});break;case!/^(?!0x).*E/.test(i):this.error("exponential notation in '"+i+"' must be indicated with a lowercase 'e'",{offset:i.indexOf("E")});break;case!/^0\d*[89]/.test(i):this.error("decimal literal '"+i+"' must not be prefixed with '0'",{length:t});break;case!/^0\d+/.test(i):this.error("octal literal '"+i+"' must be prefixed with '0o'",{length:t})}return r=1/0===(null==(e=function(){switch(i.charAt(1)){case"b":return 2;case"o":return 8;case"x":return 16;default:return null}}())?parseFloat(i):parseInt(i.slice(2),e))?"INFINITY":"NUMBER",this.token(r,i,0,t),t}},{key:"stringToken",value:function(){var e,t,n,i,r,s,o,a,l,c,u,h,p,d,f,m,b=this,k=Q.exec(this.chunk)||[],_=_slicedToArray(k,1);if(!(h=_[0]))return 0;(u=this.prev())&&"from"===this.value()&&(this.seenImport||this.seenExport)&&(u[0]="FROM"),d="'"===h?K:'"'===h?Y:"'''"===h?y:'"""'===h?v:void 0,s=3===h.length;var w=this.matchWithInterpolations(d,h);if(m=w.tokens,r=w.index,e=m.length-1,n=h.charAt(0),s){for(a=null,i=function(){var e,t,n;for(n=[],o=e=0,t=m.length;e<t;o=++e)"NEOSTRING"===(f=m[o])[0]&&n.push(f[1]);return n}().join("#{}");c=g.exec(i);)t=c[1],(null===a||0<(p=t.length)&&p<a.length)&&(a=t);a&&(l=RegExp("\\n"+a,"g")),this.mergeInterpolationTokens(m,{delimiter:n},(function(t,n){return t=b.formatString(t,{delimiter:h}),l&&(t=t.replace(l,"\n")),0===n&&(t=t.replace(R,"")),n===e&&(t=t.replace(Z,"")),t}))}else this.mergeInterpolationTokens(m,{delimiter:n},(function(t,n){return t=(t=b.formatString(t,{delimiter:h})).replace(X,(function(i,r){return 0===n&&0===r||n===e&&r+i.length===t.length?"":" "})),t}));return this.atCSXTag()&&this.token(",",",",0,0,this.prev),r}},{key:"commentToken",value:function(){var e,t,n,i,r,s,o,l,c,u,h,p=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.chunk;if(!(o=p.match(a)))return 0;var d=_slicedToArray(o,2);return e=d[0],r=d[1],i=null,c=/^\s*\n+\s*#/.test(e),r?((l=m.exec(e)