UNPKG

@liascript/editor

Version:

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

1 lines 200 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,r,n,a){postMessage({type:"error",data:{message:e,data:a&&a.data,file:t,line:r,col:n,stack:a&&a.stack}})},e.normalizeModule=function(t,r){if(-1!==r.indexOf("!")){var n=r.split("!");return e.normalizeModule(t,n[0])+"!"+e.normalizeModule(t,n[1])}if("."==r.charAt(0)){var a=t.split("/").slice(0,-1).join("/");for(r=(a?a+"/":"")+r;-1!==r.indexOf(".")&&o!=r;){var o=r;r=r.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return r},e.require=function(t,r){if(r||(r=t,t=null),!r.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");r=e.normalizeModule(t,r);var n=e.require.modules[r];if(n)return n.initialized||(n.initialized=!0,n.exports=n.factory().exports),n.exports;if(!e.require.tlns)return console.log("unable to load "+r);var a=function(e,t){for(var r=e,n="";r;){var a=t[r];if("string"==typeof a)return a+n;if(a)return a.location.replace(/\/*$/,"/")+(n||a.main||a.name);if(!1===a)return"";var o=r.lastIndexOf("/");if(-1===o)break;n=r.substr(o)+n,r=r.slice(0,o)}return e}(r,e.require.tlns);return".js"!=a.slice(-3)&&(a+=".js"),e.require.id=r,e.require.modules[r]={},importScripts(a),e.require(t,r)},e.require.modules={},e.require.tlns={},e.define=function(t,r,n){if(2==arguments.length?(n=r,"string"!=typeof t&&(r=t,t=e.require.id)):1==arguments.length&&(n=t,r=[],t=e.require.id),"function"==typeof n){r.length||(r=["require","exports","module"]);var a=function(r){return e.require(t,r)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=n.apply(this,r.slice(0,n.length).map((function(t){switch(t){case"require":return a;case"exports":return e.exports;case"module":return e;default:return a(t)}})));return t&&(e.exports=t),e}}}else e.require.modules[t]={exports:n,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,r=e.require("ace/lib/oop"),n=function(){};return function(){r.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(n.prototype),new n};var t=e.main=null,r=e.sender=null;e.onmessage=function(n){var a=n.data;if(a.event&&r)r._signal(a.event,a.data);else if(a.command)if(t[a.command])t[a.command].apply(t,a.args);else{if(!e[a.command])throw new Error("Unknown command:"+a.command);e[a.command].apply(e,a.args)}else if(a.init){e.initBaseUrls(a.tlns),r=e.sender=e.initSender();var o=this.require(a.module)[a.classname];t=e.main=new o(r)}}}}(this),ace.define("ace/lib/oop",[],(function(e,t,r){"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 r in t)e[r]=t[r];return e},t.implement=function(e,r){t.mixin(e,r)}})),ace.define("ace/lib/deep_copy",[],(function(e,t,r){t.deepCopy=function e(t){if("object"!=typeof t||!t)return t;var r;if(Array.isArray(t)){r=[];for(var n=0;n<t.length;n++)r[n]=e(t[n]);return r}if("[object Object]"!==Object.prototype.toString.call(t))return t;for(var n in r={},t)r[n]=e(t[n]);return r}})),ace.define("ace/lib/lang",[],(function(e,t,r){"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 r="";t>0;)1&t&&(r+=e),(t>>=1)&&(e+=e);return r};var n=/^\s\s*/,a=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(n,"")},t.stringTrimRight=function(e){return e.replace(a,"")},t.copyObject=function(e){var t={};for(var r in e)t[r]=e[r];return t},t.copyArray=function(e){for(var t=[],r=0,n=e.length;r<n;r++)e[r]&&"object"==typeof e[r]?t[r]=this.copyObject(e[r]):t[r]=e[r];return t},t.deepCopy=e("./deep_copy").deepCopy,t.arrayToMap=function(e){for(var t={},r=0;r<e.length;r++)t[e[r]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var r in e)t[r]=e[r];return t},t.arrayRemove=function(e,t){for(var r=0;r<=e.length;r++)t===e[r]&&e.splice(r,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 r=[];return e.replace(t,(function(e){r.push({offset:arguments[arguments.length-2],length:e.length})})),r},t.deferredCall=function(e){var t=null,r=function(){t=null,e()},n=function(e){return n.cancel(),t=setTimeout(r,e||0),n};return n.schedule=n,n.call=function(){return this.cancel(),e(),n},n.cancel=function(){return clearTimeout(t),t=null,n},n.isPending=function(){return t},n},t.delayedCall=function(e,t){var r=null,n=function(){r=null,e()},a=function(e){null==r&&(r=setTimeout(n,e||t))};return a.delay=function(e){r&&clearTimeout(r),r=setTimeout(n,e||t)},a.schedule=a,a.call=function(){this.cancel(),e()},a.cancel=function(){r&&clearTimeout(r),r=null},a.isPending=function(){return r},a},t.supportsLookbehind=function(){try{new RegExp("(?<=.)")}catch(e){return!1}return!0},t.skipEmptyMatch=function(e,t,r){return r&&e.codePointAt(t)>65535?2:1}})),ace.define("ace/apply_delta",[],(function(e,t,r){"use strict";t.applyDelta=function(e,t,r){var n=t.start.row,a=t.start.column,o=e[n]||"";switch(t.action){case"insert":if(1===t.lines.length)e[n]=o.substring(0,a)+t.lines[0]+o.substring(a);else{var i=[n,1].concat(t.lines);e.splice.apply(e,i),e[n]=o.substring(0,a)+e[n],e[n+t.lines.length-1]+=o.substring(a)}break;case"remove":var s=t.end.column,c=t.end.row;n===c?e[n]=o.substring(0,a)+o.substring(s):e.splice(n,c-n+1,o.substring(0,a)+e[c].substring(s))}}})),ace.define("ace/lib/event_emitter",[],(function(e,t,r){"use strict";var n={},a=function(){this.propagationStopped=!0},o=function(){this.defaultPrevented=!0};n._emit=n._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var r=this._eventRegistry[e]||[],n=this._defaultHandlers[e];if(r.length||n){"object"==typeof t&&t||(t={}),t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=a),t.preventDefault||(t.preventDefault=o),r=r.slice();for(var i=0;i<r.length&&(r[i](t,this),!t.propagationStopped);i++);return n&&!t.defaultPrevented?n(t,this):void 0}},n._signal=function(e,t){var r=(this._eventRegistry||{})[e];if(r){r=r.slice();for(var n=0;n<r.length;n++)r[n](t,this)}},n.once=function(e,t){var r=this;if(this.on(e,(function n(){r.off(e,n),t.apply(null,arguments)})),!t)return new Promise((function(e){t=e}))},n.setDefaultHandler=function(e,t){var r=this._defaultHandlers;if(r||(r=this._defaultHandlers={_disabled_:{}}),r[e]){var n=r[e],a=r._disabled_[e];a||(r._disabled_[e]=a=[]),a.push(n);var o=a.indexOf(t);-1!=o&&a.splice(o,1)}r[e]=t},n.removeDefaultHandler=function(e,t){var r=this._defaultHandlers;if(r){var n=r._disabled_[e];if(r[e]==t)n&&this.setDefaultHandler(e,n.pop());else if(n){var a=n.indexOf(t);-1!=a&&n.splice(a,1)}}},n.on=n.addEventListener=function(e,t,r){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];return n||(n=this._eventRegistry[e]=[]),-1==n.indexOf(t)&&n[r?"unshift":"push"](t),t},n.off=n.removeListener=n.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];if(r){var n=r.indexOf(t);-1!==n&&r.splice(n,1)}},n.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=n})),ace.define("ace/range",[],(function(e,t,r){"use strict";var n=function(){function e(e,t,r,n){this.start={row:e,column:t},this.end={row:r,column:n}}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,r=e.end,n=e.start;return 1==(t=this.compare(r.row,r.column))?1==(t=this.compare(n.row,n.column))?2:0==t?1:0:-1==t?-2:-1==(t=this.compare(n.row,n.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,r){if(this.end.row>r)var n={row:r+1,column:0};else if(this.end.row<t)n={row:t,column:0};if(this.start.row>r)var a={row:r+1,column:0};else if(this.start.row<t)a={row:t,column:0};return e.fromPoints(a||this.start,n||this.end)},e.prototype.extend=function(t,r){var n=this.compare(t,r);if(0==n)return this;if(-1==n)var a={row:t,column:r};else var o={row:t,column:r};return e.fromPoints(a||this.start,o||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 r=t.documentToScreenPosition(this.start),n=t.documentToScreenPosition(this.end);return new e(r.row,r.column,n.row,n.column)},e.prototype.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t},e}();n.fromPoints=function(e,t){return new n(e.row,e.column,t.row,t.column)},n.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=n})),ace.define("ace/anchor",[],(function(e,t,r){"use strict";function n(e,t,r){var n=r?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&n}var a=e("./lib/oop"),o=e("./lib/event_emitter").EventEmitter,i=function(){function e(e,t,r){this.$onChange=this.onChange.bind(this),this.attach(e),"number"!=typeof t?this.setPosition(t.row,t.column):this.setPosition(t,r)}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,r){var a="insert"==e.action,o=(a?1:-1)*(e.end.row-e.start.row),i=(a?1:-1)*(e.end.column-e.start.column),s=e.start,c=a?s:e.end;return n(t,s,r)?{row:t.row,column:t.column}:n(c,t,!r)?{row:t.row+o,column:t.column+(t.row==c.row?i:0)}:{row:s.row,column:s.column}}(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(t.row,t.column,!0)}},e.prototype.setPosition=function(e,t,r){var n;if(n=r?{row:e,column:t}:this.$clipPositionToDocument(e,t),this.row!=n.row||this.column!=n.column){var a={row:this.row,column:this.column};this.row=n.row,this.column=n.column,this._signal("change",{old:a,value:n})}},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 r={};return e>=this.document.getLength()?(r.row=Math.max(0,this.document.getLength()-1),r.column=this.document.getLine(r.row).length):e<0?(r.row=0,r.column=0):(r.row=e,r.column=Math.min(this.document.getLine(r.row).length,Math.max(0,t))),t<0&&(r.column=0),r},e}();i.prototype.$insertRight=!1,a.implement(i.prototype,o),t.Anchor=i})),ace.define("ace/document",[],(function(e,t,r){"use strict";var n=e("./lib/oop"),a=e("./apply_delta").applyDelta,o=e("./lib/event_emitter").EventEmitter,i=e("./range").Range,s=e("./anchor").Anchor,c=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 i(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 s(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 r=t.length-1;e.end.row-e.start.row==r&&(t[r]=t[r].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 r=this.clippedPos(e.row,e.column),n=this.pos(e.row,e.column+t.length);return this.applyDelta({start:r,end:n,action:"insert",lines:[t]},!0),this.clonePos(n)},e.prototype.clippedPos=function(e,t){var r=this.getLength();void 0===e?e=r:e<0?e=0:e>=r&&(e=r-1,t=void 0);var n=this.getLine(e);return null==t&&(t=n.length),{row:e,column:t=Math.min(Math.max(t,0),n.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 r=0;(e=Math.min(Math.max(e,0),this.getLength()))<this.getLength()?(t=t.concat([""]),r=0):(t=[""].concat(t),e--,r=this.$lines[e].length),this.insertMergedLines({row:e,column:r},t)},e.prototype.insertMergedLines=function(e,t){var r=this.clippedPos(e.row,e.column),n={row:r.row+t.length-1,column:(1==t.length?r.column:0)+t[t.length-1].length};return this.applyDelta({start:r,end:n,action:"insert",lines:t}),this.clonePos(n)},e.prototype.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),r=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:r,action:"remove",lines:this.getLinesForRange({start:t,end:r})}),this.clonePos(t)},e.prototype.removeInLine=function(e,t,r){var n=this.clippedPos(e,t),a=this.clippedPos(e,r);return this.applyDelta({start:n,end:a,action:"remove",lines:this.getLinesForRange({start:n,end:a})},!0),this.clonePos(n)},e.prototype.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1);var r=(t=Math.min(Math.max(0,t),this.getLength()-1))==this.getLength()-1&&e>0,n=t<this.getLength()-1,a=r?e-1:e,o=r?this.getLine(a).length:0,s=n?t+1:t,c=n?0:this.getLine(s).length,l=new i(a,o,s,c),p=this.$lines.slice(e,t+1);return this.applyDelta({start:l.start,end:l.end,action:"remove",lines:this.getLinesForRange(l)}),p},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 i||(e=i.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 r="insert"==e.action;(r?e.lines.length<=1&&!e.lines[0]:!i.comparePoints(e.start,e.end))||(r&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(a(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 r=e.lines,n=r.length-t+1,a=e.start.row,o=e.start.column,i=0,s=0;i<n;i=s){s+=t-1;var c=r.slice(i,s);c.push(""),this.applyDelta({start:this.pos(a+i,o),end:this.pos(a+s,o=0),action:e.action,lines:c},!0)}e.lines=r.slice(i),e.start.row=a+i,e.start.column=o,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 r=this.$lines||this.getAllLines(),n=this.getNewLineCharacter().length,a=t||0,o=r.length;a<o;a++)if((e-=r[a].length+n)<0)return{row:a,column:e+r[a].length+n};return{row:o-1,column:e+r[o-1].length+n}},e.prototype.positionToIndex=function(e,t){for(var r=this.$lines||this.getAllLines(),n=this.getNewLineCharacter().length,a=0,o=Math.min(e.row,r.length),i=t||0;i<o;++i)a+=r[i].length+n;return a+e.column},e.prototype.$split=function(e){return e.split(/\r\n|\r|\n/)},e}();c.prototype.$autoNewLine="",c.prototype.$newLineMode="auto",n.implement(c.prototype,o),t.Document=c})),ace.define("ace/worker/mirror",[],(function(e,t,r){"use strict";var n=e("../document").Document,a=e("../lib/lang"),o=t.Mirror=function(e){this.sender=e;var t=this.doc=new n(""),r=this.deferredUpdate=a.delayedCall(this.onUpdate.bind(this)),o=this;e.on("change",(function(e){var n=e.data;if(n[0].start)t.applyDeltas(n);else for(var a=0;a<n.length;a+=2){var i,s;if(("insert"==(i=Array.isArray(n[a+1])?{action:"insert",start:n[a],lines:n[a+1]}:{action:"remove",start:n[a],end:n[a+1]}).action?i.start:i.end).row>=t.$lines.length)throw(s=new Error("Invalid delta")).data={path:o.$path,linesLength:t.$lines.length,start:i.start,end:i.end},s;t.applyDelta(i,!0)}if(o.$timeout)return r.schedule(o.$timeout);o.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(o.prototype)})),ace.define("ace/mode/html/saxparser",[],(function(e,t,r){r.exports=function t(r,n,a){function o(s,c){if(!n[s]){if(!r[s]){var l="function"==typeof e&&e;if(!c&&l)return l(s,!0);if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}var p=n[s]={exports:{}};r[s][0].call(p.exports,(function(e){var t=r[s][1][e];return o(t||e)}),p,p.exports,t,r,n,a)}return n[s].exports}for(var i="function"==typeof e&&e,s=0;s<a.length;s++)o(a[s]);return o}({1:[function(e,t,r){function n(e){return"http://www.w3.org/1999/xhtml"===e.namespaceURI?"applet"===e.localName||"caption"===e.localName||"marquee"===e.localName||"object"===e.localName||"table"===e.localName||"td"===e.localName||"th"===e.localName:"http://www.w3.org/1998/Math/MathML"===e.namespaceURI?"mi"===e.localName||"mo"===e.localName||"mn"===e.localName||"ms"===e.localName||"mtext"===e.localName||"annotation-xml"===e.localName:"http://www.w3.org/2000/svg"===e.namespaceURI?"foreignObject"===e.localName||"desc"===e.localName||"title"===e.localName:void 0}function a(e){return n(e)||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"ol"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"ul"===e.localName}function o(e){return"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"table"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"html"===e.localName}function i(e){return"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"tbody"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"tfoot"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"thead"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"html"===e.localName}function s(e){return"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"tr"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"html"===e.localName}function c(e){return n(e)||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"button"===e.localName}function l(e){return!("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"optgroup"===e.localName||"http://www.w3.org/1999/xhtml"===e.namespaceURI&&"option"===e.localName)}function p(){this.elements=[],this.rootNode=null,this.headElement=null,this.bodyElement=null}p.prototype._inScope=function(e,t){for(var r=this.elements.length-1;r>=0;r--){var n=this.elements[r];if(n.localName===e)return!0;if(t(n))return!1}},p.prototype.push=function(e){this.elements.push(e)},p.prototype.pushHtmlElement=function(e){this.rootNode=e.node,this.push(e)},p.prototype.pushHeadElement=function(e){this.headElement=e.node,this.push(e)},p.prototype.pushBodyElement=function(e){this.bodyElement=e.node,this.push(e)},p.prototype.pop=function(){return this.elements.pop()},p.prototype.remove=function(e){this.elements.splice(this.elements.indexOf(e),1)},p.prototype.popUntilPopped=function(e){var t;do{t=this.pop()}while(t.localName!=e)},p.prototype.popUntilTableScopeMarker=function(){for(;!o(this.top);)this.pop()},p.prototype.popUntilTableBodyScopeMarker=function(){for(;!i(this.top);)this.pop()},p.prototype.popUntilTableRowScopeMarker=function(){for(;!s(this.top);)this.pop()},p.prototype.item=function(e){return this.elements[e]},p.prototype.contains=function(e){return-1!==this.elements.indexOf(e)},p.prototype.inScope=function(e){return this._inScope(e,n)},p.prototype.inListItemScope=function(e){return this._inScope(e,a)},p.prototype.inTableScope=function(e){return this._inScope(e,o)},p.prototype.inButtonScope=function(e){return this._inScope(e,c)},p.prototype.inSelectScope=function(e){return this._inScope(e,l)},p.prototype.hasNumberedHeaderElementInScope=function(){for(var e=this.elements.length-1;e>=0;e--){var t=this.elements[e];if(t.isNumberedHeader())return!0;if(n(t))return!1}},p.prototype.furthestBlockForFormattingElement=function(e){for(var t=null,r=this.elements.length-1;r>=0;r--){var n=this.elements[r];if(n.node===e)break;n.isSpecial()&&(t=n)}return t},p.prototype.findIndex=function(e){for(var t=this.elements.length-1;t>=0;t--)if(this.elements[t].localName==e)return t;return-1},p.prototype.remove_openElements_until=function(e){for(var t,r=!1;!r;)r=e(t=this.elements.pop());return t},Object.defineProperty(p.prototype,"top",{get:function(){return this.elements[this.elements.length-1]}}),Object.defineProperty(p.prototype,"length",{get:function(){return this.elements.length}}),r.ElementStack=p},{}],2:[function(e,t,r){function n(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"}function a(e){return e>="0"&&e<="9"}var o=e("html5-entities"),i=e("./InputStream").InputStream,s={};Object.keys(o).forEach((function(e){for(var t=0;t<e.length;t++)s[e.substring(0,t+1)]=!0}));var c={consumeEntity:function(e,t,r){var c="",l="",p=e.char();if(p===i.EOF)return!1;if(l+=p,"\t"==p||"\n"==p||"\v"==p||" "==p||"<"==p||"&"==p)return e.unget(l),!1;if(r===p)return e.unget(l),!1;if("#"==p){if((p=e.shift(1))===i.EOF)return t._parseError("expected-numeric-entity-but-got-eof"),e.unget(l),!1;l+=p;var d=10,u=a;if("x"==p||"X"==p){if(d=16,u=n,(p=e.shift(1))===i.EOF)return t._parseError("expected-numeric-entity-but-got-eof"),e.unget(l),!1;l+=p}if(u(p)){for(var m="";p!==i.EOF&&u(p);)m+=p,p=e.char();m=parseInt(m,d);var h=this.replaceEntityNumbers(m);if(h&&(t._parseError("invalid-numeric-entity-replaced"),m=h),m>65535&&m<=1114111){var g=55296+((1047552&(m-=65536))>>10),f=56320+(1023&m);c=String.fromCharCode(g,f)}else c=String.fromCharCode(m);return";"!==p&&(t._parseError("numeric-entity-without-semicolon"),e.unget(p)),c}return e.unget(l),t._parseError("expected-numeric-entity"),!1}if(p>="a"&&p<="z"||p>="A"&&p<="Z"){for(var T="";s[l]&&(o[l]&&(T=l),";"!=p)&&(p=e.char())!==i.EOF;)l+=p;return T?(c=o[T],";"===p||!r||!function(e){return e>="0"&&e<="9"||e>="a"&&e<="z"||e>="A"&&e<="Z"}(p)&&"="!==p?(l.length>T.length&&e.unget(l.substring(T.length)),";"!==p&&t._parseError("named-entity-without-semicolon"),c):(e.unget(l),!1)):(t._parseError("expected-named-entity"),e.unget(l),!1)}},replaceEntityNumbers:function(e){switch(e){case 0:return 65533;case 19:return 16;case 128:return 8364;case 129:return 129;case 130:return 8218;case 131:return 402;case 132:return 8222;case 133:return 8230;case 134:return 8224;case 135:return 8225;case 136:return 710;case 137:return 8240;case 138:return 352;case 139:return 8249;case 140:return 338;case 141:return 141;case 142:return 381;case 143:return 143;case 144:return 144;case 145:return 8216;case 146:return 8217;case 147:return 8220;case 148:return 8221;case 149:return 8226;case 150:return 8211;case 151:return 8212;case 152:return 732;case 153:return 8482;case 154:return 353;case 155:return 8250;case 156:return 339;case 157:return 157;case 158:return 382;case 159:return 376;default:if(e>=55296&&e<=57343||e>1114111)return 65533;if(e>=1&&e<=8||e>=14&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||11==e||65534==e||131070==e||3145726==e||196607==e||262142==e||262143==e||327678==e||327679==e||393214==e||393215==e||458750==e||458751==e||524286==e||524287==e||589822==e||589823==e||655358==e||655359==e||720894==e||720895==e||786430==e||786431==e||851966==e||851967==e||917502==e||917503==e||983038==e||983039==e||1048574==e||1048575==e||1114110==e||1114111==e)return e}}};r.EntityParser=c},{"./InputStream":3,"html5-entities":12}],3:[function(e,t,r){function n(){this.data="",this.start=0,this.committed=0,this.eof=!1,this.lastLocation={line:0,column:0}}n.EOF=-1,n.DRAIN=-2,n.prototype={slice:function(){if(this.start>=this.data.length){if(!this.eof)throw n.DRAIN;return n.EOF}return this.data.slice(this.start,this.data.length)},char:function(){if(!this.eof&&this.start>=this.data.length-1)throw n.DRAIN;if(this.start>=this.data.length)return n.EOF;var e=this.data[this.start++];return"\r"===e&&(e="\n"),e},advance:function(e){if(this.start+=e,this.start>=this.data.length){if(!this.eof)throw n.DRAIN;return n.EOF}this.committed>this.data.length/2&&(this.lastLocation=this.location(),this.data=this.data.slice(this.committed),this.start=this.start-this.committed,this.committed=0)},matchWhile:function(e){if(this.eof&&this.start>=this.data.length)return"";var t=new RegExp("^"+e+"+").exec(this.slice());if(t){if(!this.eof&&t[0].length==this.data.length-this.start)throw n.DRAIN;return this.advance(t[0].length),t[0]}return""},matchUntil:function(e){var t,r;if((r=this.slice())===n.EOF)return"";if(t=new RegExp(e+(this.eof?"|$":"")).exec(r)){var a=this.data.slice(this.start,this.start+t.index);return this.advance(t.index),a.replace(/\r/g,"\n").replace(/\n{2,}/g,"\n")}throw n.DRAIN},append:function(e){this.data+=e},shift:function(e){if(!this.eof&&this.start+e>=this.data.length)throw n.DRAIN;if(this.eof&&this.start>=this.data.length)return n.EOF;var t=this.data.slice(this.start,this.start+e).toString();return this.advance(Math.min(e,this.data.length-this.start)),t},peek:function(e){if(!this.eof&&this.start+e>=this.data.length)throw n.DRAIN;return this.eof&&this.start>=this.data.length?n.EOF:this.data.slice(this.start,Math.min(this.start+e,this.data.length)).toString()},length:function(){return this.data.length-this.start-1},unget:function(e){e!==n.EOF&&(this.start-=e.length)},undo:function(){this.start=this.committed},commit:function(){this.committed=this.start},location:function(){var e=this.lastLocation.line,t=this.lastLocation.column,r=this.data.slice(0,this.committed),n=r.match(/\n/g);return{line:n?e+n.length:e,column:n?r.length-r.lastIndexOf("\n")-1:t+r.length}}},r.InputStream=n},{}],4:[function(e,t,r){function n(e,t,r,n){this.localName=t,this.namespaceURI=e,this.attributes=r,this.node=n}var a={"http://www.w3.org/1999/xhtml":["address","applet","area","article","aside","base","basefont","bgsound","blockquote","body","br","button","caption","center","col","colgroup","dd","details","dir","div","dl","dt","embed","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","isindex","li","link","listing","main","marquee","menu","menuitem","meta","nav","noembed","noframes","noscript","object","ol","p","param","plaintext","pre","script","section","select","source","style","summary","table","tbody","td","textarea","tfoot","th","thead","title","tr","track","ul","wbr","xmp"],"http://www.w3.org/1998/Math/MathML":["mi","mo","mn","ms","mtext","annotation-xml"],"http://www.w3.org/2000/svg":["foreignObject","desc","title"]};n.prototype.isSpecial=function(){return this.namespaceURI in a&&a[this.namespaceURI].indexOf(this.localName)>-1},n.prototype.isFosterParenting=function(){return"http://www.w3.org/1999/xhtml"===this.namespaceURI&&("table"===this.localName||"tbody"===this.localName||"tfoot"===this.localName||"thead"===this.localName||"tr"===this.localName)},n.prototype.isNumberedHeader=function(){return"http://www.w3.org/1999/xhtml"===this.namespaceURI&&("h1"===this.localName||"h2"===this.localName||"h3"===this.localName||"h4"===this.localName||"h5"===this.localName||"h6"===this.localName)},n.prototype.isForeign=function(){return"http://www.w3.org/1999/xhtml"!=this.namespaceURI},n.prototype.isHtmlIntegrationPoint=function(){if("http://www.w3.org/1998/Math/MathML"===this.namespaceURI){if("annotation-xml"!==this.localName)return!1;var e=function(e,t){for(var r=0;r<e.attributes.length;r++)if(e.attributes[r].nodeName==t)return e.attributes[r].nodeValue;return null}(this,"encoding");return!!e&&("text/html"===(e=e.toLowerCase())||"application/xhtml+xml"===e)}return"http://www.w3.org/2000/svg"===this.namespaceURI&&("foreignObject"===this.localName||"desc"===this.localName||"title"===this.localName)},n.prototype.isMathMLTextIntegrationPoint=function(){return"http://www.w3.org/1998/Math/MathML"===this.namespaceURI&&("mi"===this.localName||"mo"===this.localName||"mn"===this.localName||"ms"===this.localName||"mtext"===this.localName)},r.StackItem=n},{}],5:[function(e,t,r){function n(e){return" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e}function a(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function o(e){this._tokenHandler=e,this._state=o.DATA,this._inputStream=new i,this._currentToken=null,this._temporaryBuffer="",this._additionalAllowedCharacter=""}var i=e("./InputStream").InputStream,s=e("./EntityParser").EntityParser;o.prototype._parseError=function(e,t){this._tokenHandler.parseError(e,t)},o.prototype._emitToken=function(e){if("StartTag"===e.type)for(var t=1;t<e.data.length;t++)e.data[t].nodeName||e.data.splice(t--,1);else"EndTag"===e.type&&(e.selfClosing&&this._parseError("self-closing-flag-on-end-tag"),0!==e.data.length&&this._parseError("attributes-in-end-tag"));this._tokenHandler.processToken(e),"StartTag"===e.type&&e.selfClosing&&!this._tokenHandler.isSelfClosingFlagAcknowledged()&&this._parseError("non-void-element-with-trailing-solidus",{name:e.name})},o.prototype._emitCurrentToken=function(){this._state=o.DATA,this._emitToken(this._currentToken)},o.prototype._currentAttribute=function(){return this._currentToken.data[this._currentToken.data.length-1]},o.prototype.setState=function(e){this._state=e},o.prototype.tokenize=function(e){function t(e){var t=e.char();if(t===i.EOF)return be._emitToken({type:"EOF",data:null}),!1;if("&"===t)be.setState(r);else if("<"===t)be.setState(B);else if("\0"===t)be._emitToken({type:"Characters",data:t}),e.commit();else{var n=e.matchUntil("&|<|\0");be._emitToken({type:"Characters",data:t+n}),e.commit()}return!0}function r(e){var r=s.consumeEntity(e,be);return be.setState(t),be._emitToken({type:"Characters",data:r||"&"}),!0}function c(e){var t=e.char();if(t===i.EOF)return be._emitToken({type:"EOF",data:null}),!1;if("&"===t)be.setState(l);else if("<"===t)be.setState(u);else if("\0"===t)be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),e.commit();else{var r=e.matchUntil("&|<|\0");be._emitToken({type:"Characters",data:t+r}),e.commit()}return!0}function l(e){var t=s.consumeEntity(e,be);return be.setState(c),be._emitToken({type:"Characters",data:t||"&"}),!0}function p(e){var t=e.char();if(t===i.EOF)return be._emitToken({type:"EOF",data:null}),!1;if("<"===t)be.setState(g);else if("\0"===t)be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),e.commit();else{var r=e.matchUntil("<|\0");be._emitToken({type:"Characters",data:t+r})}return!0}function d(e){var t=e.char();if(t===i.EOF)return be._emitToken({type:"EOF",data:null}),!1;if("<"===t)be.setState(y);else if("\0"===t)be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),e.commit();else{var r=e.matchUntil("<|\0");be._emitToken({type:"Characters",data:t+r})}return!0}function u(e){var t=e.char();return"/"===t?(this._temporaryBuffer="",be.setState(m)):(be._emitToken({type:"Characters",data:"<"}),e.unget(t),be.setState(c)),!0}function m(e){var t=e.char();return a(t)?(this._temporaryBuffer+=t,be.setState(h)):(be._emitToken({type:"Characters",data:"</"}),e.unget(t),be.setState(c)),!0}function h(e){var r=be._currentToken&&be._currentToken.name===this._temporaryBuffer.toLowerCase(),o=e.char();return n(o)&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be.setState(D)):"/"===o&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be.setState(Q)):">"===o&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be._emitCurrentToken(),be.setState(t)):a(o)?(this._temporaryBuffer+=o,e.commit()):(be._emitToken({type:"Characters",data:"</"+this._temporaryBuffer}),e.unget(o),be.setState(c)),!0}function g(e){var t=e.char();return"/"===t?(this._temporaryBuffer="",be.setState(f)):(be._emitToken({type:"Characters",data:"<"}),e.unget(t),be.setState(p)),!0}function f(e){var t=e.char();return a(t)?(this._temporaryBuffer+=t,be.setState(T)):(be._emitToken({type:"Characters",data:"</"}),e.unget(t),be.setState(p)),!0}function T(e){var r=be._currentToken&&be._currentToken.name===this._temporaryBuffer.toLowerCase(),o=e.char();return n(o)&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be.setState(D)):"/"===o&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be.setState(Q)):">"===o&&r?(be._currentToken={type:"EndTag",name:this._temporaryBuffer,data:[],selfClosing:!1},be._emitCurrentToken(),be.setState(t)):a(o)?(this._temporaryBuffer+=o,e.commit()):(be._emitToken({type:"Characters",data:"</"+this._temporaryBuffer}),e.unget(o),be.setState(p)),!0}function y(e){var t=e.char();return"/"===t?(this._temporaryBuffer="",be.setState(b)):"!"===t?(be._emitToken({type:"Characters",data:"<!"}),be.setState(w)):(be._emitToken({type:"Characters",data:"<"}),e.unget(t),be.setState(d)),!0}function b(e){var t=e.char();return a(t)?(this._temporaryBuffer+=t,be.setState(E)):(be._emitToken({type:"Characters",data:"</"}),e.unget(t),be.setState(d)),!0}function E(e){var t=be._currentToken&&be._currentToken.name===this._temporaryBuffer.toLowerCase(),r=e.char();return n(r)&&t?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be.setState(D)):"/"===r&&t?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be.setState(Q)):">"===r&&t?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be._emitCurrentToken()):a(r)?(this._temporaryBuffer+=r,e.commit()):(be._emitToken({type:"Characters",data:"</"+this._temporaryBuffer}),e.unget(r),be.setState(d)),!0}function w(e){var t=e.char();return"-"===t?(be._emitToken({type:"Characters",data:"-"}),be.setState(v)):(e.unget(t),be.setState(d)),!0}function v(e){var t=e.char();return"-"===t?(be._emitToken({type:"Characters",data:"-"}),be.setState(k)):(e.unget(t),be.setState(d)),!0}function x(e){var r=e.char();if(r===i.EOF)e.unget(r),be.setState(t);else if("-"===r)be._emitToken({type:"Characters",data:"-"}),be.setState(S);else if("<"===r)be.setState(_);else if("\0"===r)be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),e.commit();else{var n=e.matchUntil("<|-|\0");be._emitToken({type:"Characters",data:r+n})}return!0}function S(e){var r=e.char();return r===i.EOF?(e.unget(r),be.setState(t)):"-"===r?(be._emitToken({type:"Characters",data:"-"}),be.setState(k)):"<"===r?be.setState(_):"\0"===r?(be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),be.setState(x)):(be._emitToken({type:"Characters",data:r}),be.setState(x)),!0}function k(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-script"),e.unget(r),be.setState(t)):"<"===r?be.setState(_):">"===r?(be._emitToken({type:"Characters",data:">"}),be.setState(d)):"\0"===r?(be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),be.setState(x)):(be._emitToken({type:"Characters",data:r}),be.setState(x)),!0}function _(e){var t=e.char();return"/"===t?(this._temporaryBuffer="",be.setState(C)):a(t)?(be._emitToken({type:"Characters",data:"<"+t}),this._temporaryBuffer=t,be.setState(I)):(be._emitToken({type:"Characters",data:"<"}),e.unget(t),be.setState(x)),!0}function C(e){var t=e.char();return a(t)?(this._temporaryBuffer=t,be.setState(N)):(be._emitToken({type:"Characters",data:"</"}),e.unget(t),be.setState(x)),!0}function N(e){var r=be._currentToken&&be._currentToken.name===this._temporaryBuffer.toLowerCase(),o=e.char();return n(o)&&r?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be.setState(D)):"/"===o&&r?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be.setState(Q)):">"===o&&r?(be._currentToken={type:"EndTag",name:"script",data:[],selfClosing:!1},be.setState(t),be._emitCurrentToken()):a(o)?(this._temporaryBuffer+=o,e.commit()):(be._emitToken({type:"Characters",data:"</"+this._temporaryBuffer}),e.unget(o),be.setState(x)),!0}function I(e){var t=e.char();return n(t)||"/"===t||">"===t?(be._emitToken({type:"Characters",data:t}),"script"===this._temporaryBuffer.toLowerCase()?be.setState(O):be.setState(x)):a(t)?(be._emitToken({type:"Characters",data:t}),this._temporaryBuffer+=t,e.commit()):(e.unget(t),be.setState(x)),!0}function O(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-script"),e.unget(r),be.setState(t)):"-"===r?(be._emitToken({type:"Characters",data:"-"}),be.setState(M)):"<"===r?(be._emitToken({type:"Characters",data:"<"}),be.setState(F)):"\0"===r?(be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),e.commit()):(be._emitToken({type:"Characters",data:r}),e.commit()),!0}function M(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-script"),e.unget(r),be.setState(t)):"-"===r?(be._emitToken({type:"Characters",data:"-"}),be.setState(A)):"<"===r?(be._emitToken({type:"Characters",data:"<"}),be.setState(F)):"\0"===r?(be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),be.setState(O)):(be._emitToken({type:"Characters",data:r}),be.setState(O)),!0}function A(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-script"),e.unget(r),be.setState(t)):"-"===r?(be._emitToken({type:"Characters",data:"-"}),e.commit()):"<"===r?(be._emitToken({type:"Characters",data:"<"}),be.setState(F)):">"===r?(be._emitToken({type:"Characters",data:">"}),be.setState(d)):"\0"===r?(be._parseError("invalid-codepoint"),be._emitToken({type:"Characters",data:"�"}),be.setState(O)):(be._emitToken({type:"Characters",data:r}),be.setState(O)),!0}function F(e){var t=e.char();return"/"===t?(be._emitToken({type:"Characters",data:"/"}),this._temporaryBuffer="",be.setState(L)):(e.unget(t),be.setState(O)),!0}function L(e){var t=e.char();return n(t)||"/"===t||">"===t?(be._emitToken({type:"Characters",data:t}),"script"===this._temporaryBuffer.toLowerCase()?be.setState(x):be.setState(O)):a(t)?(be._emitToken({type:"Characters",data:t}),this._temporaryBuffer+=t,e.commit()):(e.unget(t),be.setState(O)),!0}function B(e){var r=e.char();return r===i.EOF?(be._parseError("bare-less-than-sign-at-eof"),be._emitToken({type:"Characters",data:"<"}),e.unget(r),be.setState(t)):a(r)?(be._currentToken={type:"StartTag",name:r.toLowerCase(),data:[]},be.setState(H)):"!"===r?be.setState(W):"/"===r?be.setState(q):">"===r?(be._parseError("expected-tag-name-but-got-right-bracket"),be._emitToken({type:"Characters",data:"<>"}),be.setState(t)):"?"===r?(be._parseError("expected-tag-name-but-got-question-mark"),e.unget(r),be.setState(Y)):(be._parseError("expected-tag-name"),be._emitToken({type:"Characters",data:"<"}),e.unget(r),be.setState(t)),!0}function q(e){var r=e.char();return r===i.EOF?(be._parseError("expected-closing-tag-but-got-eof"),be._emitToken({type:"Characters",data:"</"}),e.unget(r),be.setState(t)):a(r)?(be._currentToken={type:"EndTag",name:r.toLowerCase(),data:[]},be.setState(H)):">"===r?(be._parseError("expected-closing-tag-but-got-right-bracket"),be.setState(t)):(be._parseError("expected-closing-tag-but-got-char",{data:r}),e.unget(r),be.setState(Y)),!0}function H(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-tag-name"),e.unget(r),be.setState(t)):n(r)?be.setState(D):a(r)?be._currentToken.name+=r.toLowerCase():">"===r?be._emitCurrentToken():"/"===r?be.setState(Q):"\0"===r?(be._parseError("invalid-codepoint"),be._currentToken.name+="�"):be._currentToken.name+=r,e.commit(),!0}function D(e){var r=e.char();if(r===i.EOF)be._parseError("expected-attribute-name-but-got-eof"),e.unget(r),be.setState(t);else{if(n(r))return!0;a(r)?(be._currentToken.data.push({nodeName:r.toLowerCase(),nodeValue:""}),be.setState(R)):">"===r?be._emitCurrentToken():"/"===r?be.setState(Q):"'"===r||'"'===r||"="===r||"<"===r?(be._parseError("invalid-character-in-attribute-name"),be._currentToken.data.push({nodeName:r,nodeValue:""}),be.setState(R)):"\0"===r?(be._parseError("invalid-codepoint"),be._currentToken.data.push({nodeName:"�",nodeValue:""})):(be._currentToken.data.push({nodeName:r,nodeValue:""}),be.setState(R))}return!0}function R(e){var r=e.char(),o=!0,s=!1;if(r===i.EOF?(be._parseError("eof-in-attribute-name"),e.unget(r),be.setState(t),s=!0):"="===r?be.setState(P):a(r)?(be._currentAttribute().nodeName+=r.toLowerCase(),o=!1):">"===r?s=!0:n(r)?be.setState(U):"/"===r?be.setState(Q):"'"===r||'"'===r?(be._parseError("invalid-character-in-attribute-name"),be._currentAttribute().nodeName+=r,o=!1):"\0"===r?(be._parseError("invalid-codepoint"),be._currentAttribute().nodeName+="�"):(be._currentAttribute().nodeName+=r,o=!1),o){for(var c=be._currentToken.data,l=c[c.length-1],p=c.length-2;p>=0;p--)if(l.nodeName===c[p].nodeName){be._parseError("duplicate-attribute",{name:l.nodeName}),l.nodeName=null;break}s&&be._emitCurrentToken()}else e.commit();return!0}function U(e){var r=e.char();if(r===i.EOF)be._parseError("expected-end-of-tag-but-got-eof"),e.unget(r),be.setState(t);else{if(n(r))return!0;"="===r?be.setState(P):">"===r?be._emitCurrentToken():a(r)?(be._currentToken.data.push({nodeName:r,nodeValue:""}),be.setState(R)):"/"===r?be.setState(Q):"'"===r||'"'===r||"<"===r?(be._parseError("invalid-character-after-attribute-name"),be._currentToken.data.push({nodeName:r,nodeValue:""}),be.setState(R)):"\0"===r?(be._parseError("invalid-codepoint"),be._currentToken.data.push({nodeName:"�",nodeValue:""})):(be._currentToken.data.push({nodeName:r,nodeValue:""}),be.setState(R))}return!0}function P(e){var r=e.char();if(r===i.EOF)be._parseError("expected-attribute-value-but-got-eof"),e.unget(r),be.setState(t);else{if(n(r))return!0;'"'===r?be.setState(j):"&"===r?(be.setState(V),e.unget(r)):"'"===r?be.setState(G):">"===r?(be._parseError("expected-attribute-value-but-got-right-bracket"),be._emitCurrentToken()):"="===r||"<"===r||"`"===r?(be._parseError("unexpected-character-in-unquoted-attribute-value"),be._currentAttribute().nodeValue+=r,be.setState(V)):"\0"===r?(be._parseError("invalid-codepoint"),be._currentAttribute().nodeValue+="�"):(be._currentAttribute().nodeValue+=r,be.setState(V))}return!0}function j(e){var r=e.char();if(r===i.EOF)be._parseError("eof-in-attribute-value-double-quote"),e.unget(r),be.setState(t);else if('"'===r)be.setState($);else if("&"===r)this._additionalAllowedCharacter='"',be.setState(z);else if("\0"===r)be._parseError("invalid-codepoint"),be._currentAttribute().nodeValue+="�";else{r+=e.matchUntil('[\0"&]'),be._currentAttribute().nodeValue+=r}return!0}function G(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-attribute-value-single-quote"),e.unget(r),be.setState(t)):"'"===r?be.setState($):"&"===r?(this._additionalAllowedCharacter="'",be.setState(z)):"\0"===r?(be._parseError("invalid-codepoint"),be._currentAttribute().nodeValue+="�"):be._currentAttribute().nodeValue+=r+e.matchUntil("\0|['&]"),!0}function V(e){var r=e.char();if(r===i.EOF)be._parseError("eof-after-attribute-value"),e.unget(r),be.setState(t);else if(n(r))be.setState(D);else if("&"===r)this._additionalAllowedCharacter=">",be.setState(z);else if(">"===r)be._emitCurrentToken();else if('"'===r||"'"===r||"="===r||"`"===r||"<"===r)be._parseError("unexpected-character-in-unquoted-attribute-value"),be._currentAttribute().nodeValue+=r,e.commit();else if("\0"===r)be._parseError("invalid-codepoint"),be._currentAttribute().nodeValue+="�";else{var a=e.matchUntil("\0|[\t\n\v\f \r&<>\"'=`]");a===i.EOF&&(be._parseError("eof-in-attribute-value-no-quotes"),be._emitCurrentToken()),e.commit(),be._currentAttribute().nodeValue+=r+a}return!0}function z(e){var t=s.consumeEntity(e,be,this._additionalAllowedCharacter);return this._currentAttribute().nodeValue+=t||"&",'"'===this._additionalAllowedCharacter?be.setState(j):"'"===this._additionalAllowedCharacter?be.setState(G):">"===this._additionalAllowedCharacter&&be.setState(V),!0}function $(e){var r=e.char();return r===i.EOF?(be._parseError("eof-after-attribute-value"),e.unget(r),be.setState(t)):n(r)?be.setState(D):">"===r?(be.setState(t),be._emitCurrentToken()):"/"===r?be.setState(Q):(be._parseError("unexpected-character-after-attribute-value"),e.unget(r),be.setState(D)),!0}function Q(e){var r=e.char();return r===i.EOF?(be._parseError("unexpected-eof-after-solidus-in-tag"),e.unget(r),be.setState(t)):">"===r?(be._currentToken.selfClosing=!0,be.setState(t),be._emitCurrentToken()):(be._parseError("unexpected-character-after-solidus-in-tag"),e.unget(r),be.setState(D)),!0}function Y(e){var r=e.matchUntil(">");return r=r.replace(/\u0000/g,"�"),e.char(),be._emitToken({type:"Comment",data:r}),be.setState(t),!0}function W(e){var t=e.shift(2);if("--"===t)be._currentToken={type:"Comment",data:""},be.setState(J);else{var r=e.shift(5);if(r===i.EOF||t===i.EOF)return be._parseError("expected-dashes-or-doctype"),be.setState(Y),e.unget(t),!0;"DOCTYPE"===(t+=r).toUpperCase()?(be._currentToken={type:"Doctype",name:"",publicId:null,systemId:null,forceQuirks:!1},be.setState(ne)):be._tokenHandler.isCdataSectionAllowed()&&"[CDATA["===t?be.setState(X):(be._parseError("expected-dashes-or-doctype"),e.unget(t),be.setState(Y))}return!0}function X(e){var r=e.matchUntil("]]>");return e.shift(3),r&&be._emitToken({type:"Characters",data:r}),be.setState(t),!0}function J(e){var r=e.char();return r===i.EOF?(be._parseError("eof-in-comment"),be._emitToken(be._currentToken),e.un