@liascript/editor
Version:
An extended Markdown interpreter for the creation of interactive online courses.
1 lines • 150 kB
JavaScript
!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,i){postMessage({type:"error",data:{message:e,data:i&&i.data,file:t,line:r,col:n,stack:i&&i.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 i=t.split("/").slice(0,-1).join("/");for(r=(i?i+"/":"")+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 i=function(e,t){for(var r=e,n="";r;){var i=t[r];if("string"==typeof i)return i+n;if(i)return i.location.replace(/\/*$/,"/")+(n||i.main||i.name);if(!1===i)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"!=i.slice(-3)&&(i+=".js"),e.require.id=r,e.require.modules[r]={},importScripts(i),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 i=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 i;case"exports":return e.exports;case"module":return e;default:return i(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 i=n.data;if(i.event&&r)r._signal(i.event,i.data);else if(i.command)if(t[i.command])t[i.command].apply(t,i.args);else{if(!e[i.command])throw new Error("Unknown command:"+i.command);e[i.command].apply(e,i.args)}else if(i.init){e.initBaseUrls(i.tlns),r=e.sender=e.initSender();var o=this.require(i.module)[i.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*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(n,"")},t.stringTrimRight=function(e){return e.replace(i,"")},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,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<")},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()},i=function(e){null==r&&(r=setTimeout(n,e||t))};return i.delay=function(e){r&&clearTimeout(r),r=setTimeout(n,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){r&&clearTimeout(r),r=null},i.isPending=function(){return r},i},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,i=t.start.column,o=e[n]||"";switch(t.action){case"insert":if(1===t.lines.length)e[n]=o.substring(0,i)+t.lines[0]+o.substring(i);else{var a=[n,1].concat(t.lines);e.splice.apply(e,a),e[n]=o.substring(0,i)+e[n],e[n+t.lines.length-1]+=o.substring(i)}break;case"remove":var s=t.end.column,l=t.end.row;n===l?e[n]=o.substring(0,i)+o.substring(s):e.splice(n,l-n+1,o.substring(0,i)+e[l].substring(s))}}})),ace.define("ace/lib/event_emitter",[],(function(e,t,r){"use strict";var n={},i=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=i),t.preventDefault||(t.preventDefault=o),r=r.slice();for(var a=0;a<r.length&&(r[a](t,this),!t.propagationStopped);a++);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],i=r._disabled_[e];i||(r._disabled_[e]=i=[]),i.push(n);var o=i.indexOf(t);-1!=o&&i.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 i=n.indexOf(t);-1!=i&&n.splice(i,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 i={row:r+1,column:0};else if(this.start.row<t)i={row:t,column:0};return e.fromPoints(i||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 i={row:t,column:r};else var o={row:t,column:r};return e.fromPoints(i||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 i=e("./lib/oop"),o=e("./lib/event_emitter").EventEmitter,a=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 i="insert"==e.action,o=(i?1:-1)*(e.end.row-e.start.row),a=(i?1:-1)*(e.end.column-e.start.column),s=e.start,l=i?s:e.end;return n(t,s,r)?{row:t.row,column:t.column}:n(l,t,!r)?{row:t.row+o,column:t.column+(t.row==l.row?a: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 i={row:this.row,column:this.column};this.row=n.row,this.column=n.column,this._signal("change",{old:i,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}();a.prototype.$insertRight=!1,i.implement(a.prototype,o),t.Anchor=a})),ace.define("ace/document",[],(function(e,t,r){"use strict";var n=e("./lib/oop"),i=e("./apply_delta").applyDelta,o=e("./lib/event_emitter").EventEmitter,a=e("./range").Range,s=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 a(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),i=this.clippedPos(e,r);return this.applyDelta({start:n,end:i,action:"remove",lines:this.getLinesForRange({start:n,end:i})},!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,i=r?e-1:e,o=r?this.getLine(i).length:0,s=n?t+1:t,l=n?0:this.getLine(s).length,c=new a(i,o,s,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 a||(e=a.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]:!a.comparePoints(e.start,e.end))||(r&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(i(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,i=e.start.row,o=e.start.column,a=0,s=0;a<n;a=s){s+=t-1;var l=r.slice(a,s);l.push(""),this.applyDelta({start:this.pos(i+a,o),end:this.pos(i+s,o=0),action:e.action,lines:l},!0)}e.lines=r.slice(a),e.start.row=i+a,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,i=t||0,o=r.length;i<o;i++)if((e-=r[i].length+n)<0)return{row:i,column:e+r[i].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,i=0,o=Math.min(e.row,r.length),a=t||0;a<o;++a)i+=r[a].length+n;return i+e.column},e.prototype.$split=function(e){return e.split(/\r\n|\r|\n/)},e}();l.prototype.$autoNewLine="",l.prototype.$newLineMode="auto",n.implement(l.prototype,o),t.Document=l})),ace.define("ace/worker/mirror",[],(function(e,t,r){"use strict";var n=e("../document").Document,i=e("../lib/lang"),o=t.Mirror=function(e){this.sender=e;var t=this.doc=new n(""),r=this.deferredUpdate=i.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 i=0;i<n.length;i+=2){var a,s;if(("insert"==(a=Array.isArray(n[i+1])?{action:"insert",start:n[i],lines:n[i+1]}:{action:"remove",start:n[i],end:n[i+1]}).action?a.start:a.end).row>=t.$lines.length)throw(s=new Error("Invalid delta")).data={path:o.$path,linesLength:t.$lines.length,start:a.start,end:a.end},s;t.applyDelta(a,!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/css/csslint",[],(function(e,t,r){var n=function(){function e(e,t,r,n){"use strict";this.messages=[],this.stats=[],this.lines=e,this.ruleset=t,this.allow=r,this.allow||(this.allow={}),this.ignore=n,this.ignore||(this.ignore=[])}var t=t||{},r=function(){var e;return e=function t(r,n,i){function o(s,l){if(!n[s]){if(!r[s]){var c="function"==typeof e&&e;if(!l&&c)return c(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[s]={exports:{}};r[s][0].call(h.exports,(function(e){return o(r[s][1][e]||e)}),h,h.exports,t,r,n,i)}return n[s].exports}for(var a="function"==typeof e&&e,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(e,t,r){"use strict";t.exports={__proto__:null,aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",currentColor:"The value of the 'color' property.",activeborder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",greytext:"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."}},{}],2:[function(e,t,r){"use strict";function n(e,t,r){i.call(this,e,t,r,o.COMBINATOR_TYPE),this.type="unknown",/^\s+$/.test(e)?this.type="descendant":">"===e?this.type="child":"+"===e?this.type="adjacent-sibling":"~"===e&&(this.type="sibling")}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(e,t,r){"use strict";function n(e,t){this.match=function(t){var r;return t.mark(),(r=e(t))?t.drop():t.restore(),r},this.toString="function"==typeof t?t:function(){return t}}t.exports=n;var i=e("../util/StringReader"),o=e("../util/SyntaxError");n.prec={MOD:5,SEQ:4,ANDAND:3,OROR:2,ALT:1},n.parse=function(e){var t,r,a,s,l,c,u,h,d;if(t=new i(e),r=function(e){var r=t.readMatch(e);if(null===r)throw new o("Expected "+e,t.getLine(),t.getCol());return r},a=function(){for(var e=[s()];null!==t.readMatch(" | ");)e.push(s());return 1===e.length?e[0]:n.alt.apply(n,e)},s=function(){for(var e=[l()];null!==t.readMatch(" || ");)e.push(l());return 1===e.length?e[0]:n.oror.apply(n,e)},l=function(){for(var e=[c()];null!==t.readMatch(" && ");)e.push(c());return 1===e.length?e[0]:n.andand.apply(n,e)},c=function(){for(var e=[u()];null!==t.readMatch(/^ (?![&|\]])/);)e.push(u());return 1===e.length?e[0]:n.seq.apply(n,e)},u=function(){var e=h();if(null!==t.readMatch("?"))return e.question();if(null!==t.readMatch("*"))return e.star();if(null!==t.readMatch("+"))return e.plus();if(null!==t.readMatch("#"))return e.hash();if(null!==t.readMatch(/^\{\s*/)){var n=r(/^\d+/);r(/^\s*,\s*/);var i=r(/^\d+/);return r(/^\s*\}/),e.braces(Number(n),Number(i))}return e},h=function(){if(null!==t.readMatch("[ ")){var e=a();return r(" ]"),e}return n.fromType(r(/^[^ ?*+#{]+/))},d=a(),!t.eof())throw new o("Expected end of string",t.getLine(),t.getCol());return d},n.cast=function(e){return e instanceof n?e:n.parse(e)},n.fromType=function(t){var r=e("./ValidationTypes");return new n((function(e){return e.hasNext()&&r.isType(e,t)}),t)},n.seq=function(){var e=Array.prototype.slice.call(arguments).map(n.cast);return 1===e.length?e[0]:new n((function(t){var r,n=!0;for(r=0;n&&r<e.length;r++)n=e[r].match(t);return n}),(function(t){var r=n.prec.SEQ,i=e.map((function(e){return e.toString(r)})).join(" ");return t>r&&(i="[ "+i+" ]"),i}))},n.alt=function(){var e=Array.prototype.slice.call(arguments).map(n.cast);return 1===e.length?e[0]:new n((function(t){var r,n=!1;for(r=0;!n&&r<e.length;r++)n=e[r].match(t);return n}),(function(t){var r=n.prec.ALT,i=e.map((function(e){return e.toString(r)})).join(" | ");return t>r&&(i="[ "+i+" ]"),i}))},n.many=function(t){var r=Array.prototype.slice.call(arguments,1).reduce((function(t,r){if(r.expand){var i=e("./ValidationTypes");t.push.apply(t,i.complex[r.expand].options)}else t.push(n.cast(r));return t}),[]);!0===t&&(t=r.map((function(){return!0})));var i=new n((function(e){var n=[],i=0,o=0,a=function(e){return 0===o?(i=Math.max(e,i),e===r.length):e===i},s=function(i){for(var o=0;o<r.length;o++)if(!n[o])if(e.mark(),r[o].match(e)){if(n[o]=!0,s(i+(!1===t||t[o]?1:0)))return e.drop(),!0;e.restore(),n[o]=!1}else e.drop();return a(i)};if(s(0)||(o++,s(0)),!1===t)return i>0;for(var l=0;l<r.length;l++)if(t[l]&&!n[l])return!1;return!0}),(function(e){var i=!1===t?n.prec.OROR:n.prec.ANDAND,o=r.map((function(e,r){return!1===t||t[r]?e.toString(i):e.toString(n.prec.MOD)+"?"})).join(!1===t?" || ":" && ");return e>i&&(o="[ "+o+" ]"),o}));return i.options=r,i},n.andand=function(){var e=Array.prototype.slice.call(arguments);return e.unshift(!0),n.many.apply(n,e)},n.oror=function(){var e=Array.prototype.slice.call(arguments);return e.unshift(!1),n.many.apply(n,e)},n.prototype={constructor:n,match:function(){throw new Error("unimplemented")},toString:function(){throw new Error("unimplemented")},func:function(){return this.match.bind(this)},then:function(e){return n.seq(this,e)},or:function(e){return n.alt(this,e)},andand:function(e){return n.many(!0,this,e)},oror:function(e){return n.many(!1,this,e)},star:function(){return this.braces(0,1/0,"*")},plus:function(){return this.braces(1,1/0,"+")},question:function(){return this.braces(0,1,"?")},hash:function(){return this.braces(1,1/0,"#",n.cast(","))},braces:function(e,t,r,i){var o=this,a=i?i.then(this):this;return r||(r="{"+e+","+t+"}"),new n((function(r){var n;for(n=0;n<t&&(n>0&&i?a.match(r):o.match(r));n++);return n>=e}),(function(){return o.toString(n.prec.MOD)+r}))}}},{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(e,t,r){"use strict";function n(e,t){i.call(this,"("+e+(null!==t?":"+t:"")+")",e.startLine,e.startCol,o.MEDIA_FEATURE_TYPE),this.name=e,this.value=t}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(e,t,r){"use strict";function n(e,t,r,n,a){i.call(this,(e?e+" ":"")+(t||"")+(t&&r.length>0?" and ":"")+r.join(" and "),n,a,o.MEDIA_QUERY_TYPE),this.modifier=e,this.mediaType=t,this.features=r}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(e,t,r){"use strict";function n(e){i.call(this),this.options=e||{},this._tokenStream=null}t.exports=n;var i=e("../util/EventTarget"),o=e("../util/SyntaxError"),a=e("../util/SyntaxUnit"),s=e("./Combinator"),l=e("./MediaFeature"),c=e("./MediaQuery"),u=e("./PropertyName"),h=e("./PropertyValue"),d=e("./PropertyValuePart"),p=e("./Selector"),f=e("./SelectorPart"),m=e("./SelectorSubPart"),g=e("./TokenStream"),b=e("./Tokens"),w=e("./Validation");n.DEFAULT_TYPE=0,n.COMBINATOR_TYPE=1,n.MEDIA_FEATURE_TYPE=2,n.MEDIA_QUERY_TYPE=3,n.PROPERTY_NAME_TYPE=4,n.PROPERTY_VALUE_TYPE=5,n.PROPERTY_VALUE_PART_TYPE=6,n.SELECTOR_TYPE=7,n.SELECTOR_PART_TYPE=8,n.SELECTOR_SUB_PART_TYPE=9,n.prototype=function(){var e,t=new i,r={__proto__:null,constructor:n,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var e,t,r,n=this._tokenStream;for(this.fire("startstylesheet"),this._charset(),this._skipCruft();n.peek()===b.IMPORT_SYM;)this._import(),this._skipCruft();for(;n.peek()===b.NAMESPACE_SYM;)this._namespace(),this._skipCruft();for(r=n.peek();r>b.EOF;){try{switch(r){case b.MEDIA_SYM:this._media(),this._skipCruft();break;case b.PAGE_SYM:this._page(),this._skipCruft();break;case b.FONT_FACE_SYM:this._font_face(),this._skipCruft();break;case b.KEYFRAMES_SYM:this._keyframes(),this._skipCruft();break;case b.VIEWPORT_SYM:this._viewport(),this._skipCruft();break;case b.DOCUMENT_SYM:this._document(),this._skipCruft();break;case b.SUPPORTS_SYM:this._supports(),this._skipCruft();break;case b.UNKNOWN_SYM:if(n.get(),this.options.strict)throw new o("Unknown @ rule.",n.LT(0).startLine,n.LT(0).startCol);for(this.fire({type:"error",error:null,message:"Unknown @ rule: "+n.LT(0).value+".",line:n.LT(0).startLine,col:n.LT(0).startCol}),e=0;n.advance([b.LBRACE,b.RBRACE])===b.LBRACE;)e++;for(;e;)n.advance([b.RBRACE]),e--;break;case b.S:this._readWhitespace();break;default:if(!this._ruleset())switch(r){case b.CHARSET_SYM:throw t=n.LT(1),this._charset(!1),new o("@charset not allowed here.",t.startLine,t.startCol);case b.IMPORT_SYM:throw t=n.LT(1),this._import(!1),new o("@import not allowed here.",t.startLine,t.startCol);case b.NAMESPACE_SYM:throw t=n.LT(1),this._namespace(!1),new o("@namespace not allowed here.",t.startLine,t.startCol);default:n.get(),this._unexpectedToken(n.token())}}}catch(e){if(!(e instanceof o)||this.options.strict)throw e;this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col})}r=n.peek()}r!==b.EOF&&this._unexpectedToken(n.token()),this.fire("endstylesheet")},_charset:function(e){var t,r,n,i=this._tokenStream;i.match(b.CHARSET_SYM)&&(r=i.token().startLine,n=i.token().startCol,this._readWhitespace(),i.mustMatch(b.STRING),t=i.token().value,this._readWhitespace(),i.mustMatch(b.SEMICOLON),!1!==e&&this.fire({type:"charset",charset:t,line:r,col:n}))},_import:function(e){var t,r,n,i=this._tokenStream;i.mustMatch(b.IMPORT_SYM),r=i.token(),this._readWhitespace(),i.mustMatch([b.STRING,b.URI]),t=i.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/,"$1"),this._readWhitespace(),n=this._media_query_list(),i.mustMatch(b.SEMICOLON),this._readWhitespace(),!1!==e&&this.fire({type:"import",uri:t,media:n,line:r.startLine,col:r.startCol})},_namespace:function(e){var t,r,n,i,o=this._tokenStream;o.mustMatch(b.NAMESPACE_SYM),t=o.token().startLine,r=o.token().startCol,this._readWhitespace(),o.match(b.IDENT)&&(n=o.token().value,this._readWhitespace()),o.mustMatch([b.STRING,b.URI]),i=o.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),o.mustMatch(b.SEMICOLON),this._readWhitespace(),!1!==e&&this.fire({type:"namespace",prefix:n,uri:i,line:t,col:r})},_supports:function(e){var t,r,n=this._tokenStream;if(n.match(b.SUPPORTS_SYM)){for(t=n.token().startLine,r=n.token().startCol,this._readWhitespace(),this._supports_condition(),this._readWhitespace(),n.mustMatch(b.LBRACE),this._readWhitespace(),!1!==e&&this.fire({type:"startsupports",line:t,col:r});this._ruleset(););n.mustMatch(b.RBRACE),this._readWhitespace(),this.fire({type:"endsupports",line:t,col:r})}},_supports_condition:function(){var e,t=this._tokenStream;if(t.match(b.IDENT))"not"===(e=t.token().value.toLowerCase())?(t.mustMatch(b.S),this._supports_condition_in_parens()):t.unget();else for(this._supports_condition_in_parens(),this._readWhitespace();t.peek()===b.IDENT;)"and"!==(e=t.LT(1).value.toLowerCase())&&"or"!==e||(t.mustMatch(b.IDENT),this._readWhitespace(),this._supports_condition_in_parens(),this._readWhitespace())},_supports_condition_in_parens:function(){var e=this._tokenStream;e.match(b.LPAREN)?(this._readWhitespace(),e.match(b.IDENT)?"not"===e.token().value.toLowerCase()?(this._readWhitespace(),this._supports_condition(),this._readWhitespace(),e.mustMatch(b.RPAREN)):(e.unget(),this._supports_declaration_condition(!1)):(this._supports_condition(),this._readWhitespace(),e.mustMatch(b.RPAREN))):this._supports_declaration_condition()},_supports_declaration_condition:function(e){var t=this._tokenStream;!1!==e&&t.mustMatch(b.LPAREN),this._readWhitespace(),this._declaration(),t.mustMatch(b.RPAREN)},_media:function(){var e,t,r,n=this._tokenStream;for(n.mustMatch(b.MEDIA_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),r=this._media_query_list(),n.mustMatch(b.LBRACE),this._readWhitespace(),this.fire({type:"startmedia",media:r,line:e,col:t});;)if(n.peek()===b.PAGE_SYM)this._page();else if(n.peek()===b.FONT_FACE_SYM)this._font_face();else if(n.peek()===b.VIEWPORT_SYM)this._viewport();else if(n.peek()===b.DOCUMENT_SYM)this._document();else if(n.peek()===b.SUPPORTS_SYM)this._supports();else if(n.peek()===b.MEDIA_SYM)this._media();else if(!this._ruleset())break;n.mustMatch(b.RBRACE),this._readWhitespace(),this.fire({type:"endmedia",media:r,line:e,col:t})},_media_query_list:function(){var e=this._tokenStream,t=[];for(this._readWhitespace(),(e.peek()===b.IDENT||e.peek()===b.LPAREN)&&t.push(this._media_query());e.match(b.COMMA);)this._readWhitespace(),t.push(this._media_query());return t},_media_query:function(){var e=this._tokenStream,t=null,r=null,n=null,i=[];if(e.match(b.IDENT)&&("only"!==(r=e.token().value.toLowerCase())&&"not"!==r?(e.unget(),r=null):n=e.token()),this._readWhitespace(),e.peek()===b.IDENT?(t=this._media_type(),null===n&&(n=e.token())):e.peek()===b.LPAREN&&(null===n&&(n=e.LT(1)),i.push(this._media_expression())),null===t&&0===i.length)return null;for(this._readWhitespace();e.match(b.IDENT);)"and"!==e.token().value.toLowerCase()&&this._unexpectedToken(e.token()),this._readWhitespace(),i.push(this._media_expression());return new c(r,t,i,n.startLine,n.startCol)},_media_type:function(){return this._media_feature()},_media_expression:function(){var e,t,r=this._tokenStream,n=null;return r.mustMatch(b.LPAREN),this._readWhitespace(),e=this._media_feature(),this._readWhitespace(),r.match(b.COLON)&&(this._readWhitespace(),t=r.LT(1),n=this._expression()),r.mustMatch(b.RPAREN),this._readWhitespace(),new l(e,n?new a(n,t.startLine,t.startCol):null)},_media_feature:function(){var e=this._tokenStream;return this._readWhitespace(),e.mustMatch(b.IDENT),a.fromToken(e.token())},_page:function(){var e,t,r=this._tokenStream,n=null,i=null;r.mustMatch(b.PAGE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),r.match(b.IDENT)&&("auto"===(n=r.token().value).toLowerCase()&&this._unexpectedToken(r.token())),r.peek()===b.COLON&&(i=this._pseudo_page()),this._readWhitespace(),this.fire({type:"startpage",id:n,pseudo:i,line:e,col:t}),this._readDeclarations(!0,!0),this.fire({type:"endpage",id:n,pseudo:i,line:e,col:t})},_margin:function(){var e,t,r=this._tokenStream,n=this._margin_sym();return!!n&&(e=r.token().startLine,t=r.token().startCol,this.fire({type:"startpagemargin",margin:n,line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endpagemargin",margin:n,line:e,col:t}),!0)},_margin_sym:function(){var e=this._tokenStream;return e.match([b.TOPLEFTCORNER_SYM,b.TOPLEFT_SYM,b.TOPCENTER_SYM,b.TOPRIGHT_SYM,b.TOPRIGHTCORNER_SYM,b.BOTTOMLEFTCORNER_SYM,b.BOTTOMLEFT_SYM,b.BOTTOMCENTER_SYM,b.BOTTOMRIGHT_SYM,b.BOTTOMRIGHTCORNER_SYM,b.LEFTTOP_SYM,b.LEFTMIDDLE_SYM,b.LEFTBOTTOM_SYM,b.RIGHTTOP_SYM,b.RIGHTMIDDLE_SYM,b.RIGHTBOTTOM_SYM])?a.fromToken(e.token()):null},_pseudo_page:function(){var e=this._tokenStream;return e.mustMatch(b.COLON),e.mustMatch(b.IDENT),e.token().value},_font_face:function(){var e,t,r=this._tokenStream;r.mustMatch(b.FONT_FACE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startfontface",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endfontface",line:e,col:t})},_viewport:function(){var e,t,r=this._tokenStream;r.mustMatch(b.VIEWPORT_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startviewport",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endviewport",line:e,col:t})},_document:function(){var e,t=this._tokenStream,r=[],n="";for(t.mustMatch(b.DOCUMENT_SYM),e=t.token(),/^@-([^-]+)-/.test(e.value)&&(n=RegExp.$1),this._readWhitespace(),r.push(this._document_function());t.match(b.COMMA);)this._readWhitespace(),r.push(this._document_function());t.mustMatch(b.LBRACE),this._readWhitespace(),this.fire({type:"startdocument",functions:r,prefix:n,line:e.startLine,col:e.startCol});for(var i=!0;i;)switch(t.peek()){case b.PAGE_SYM:this._page();break;case b.FONT_FACE_SYM:this._font_face();break;case b.VIEWPORT_SYM:this._viewport();break;case b.MEDIA_SYM:this._media();break;case b.KEYFRAMES_SYM:this._keyframes();break;case b.DOCUMENT_SYM:this._document();break;default:i=Boolean(this._ruleset())}t.mustMatch(b.RBRACE),e=t.token(),this._readWhitespace(),this.fire({type:"enddocument",functions:r,prefix:n,line:e.startLine,col:e.startCol})},_document_function:function(){var e,t=this._tokenStream;return t.match(b.URI)?(e=t.token().value,this._readWhitespace()):e=this._function(),e},_operator:function(e){var t=this._tokenStream,r=null;return(t.match([b.SLASH,b.COMMA])||e&&t.match([b.PLUS,b.STAR,b.MINUS]))&&(r=t.token(),this._readWhitespace()),r?d.fromToken(r):null},_combinator:function(){var e,t=this._tokenStream,r=null;return t.match([b.PLUS,b.GREATER,b.TILDE])&&(e=t.token(),r=new s(e.value,e.startLine,e.startCol),this._readWhitespace()),r},_unary_operator:function(){var e=this._tokenStream;return e.match([b.MINUS,b.PLUS])?e.token().value:null},_property:function(){var e,t,r,n=this._tokenStream,i=null,o=null,a="";if(n.peek()===b.STAR&&this.options.starHack&&(n.get(),o=(e=n.token()).value,t=e.startLine,r=e.startCol),n.peek()===b.MINUS&&(n.get(),a=(e=n.token()).value,t=e.startLine,r=e.startCol),n.match(b.IDENT))"_"===(a+=(e=n.token()).value).charAt(0)&&this.options.underscoreHack&&(o="_",a=a.substring(1)),i=new u(a,o,t||e.startLine,r||e.startCol),this._readWhitespace();else{var s=n.peek();s!==b.EOF&&s!==b.RBRACE&&this._unexpectedToken(n.LT(1))}return i},_ruleset:function(){var e,t=this._tokenStream;try{e=this._selectors_group()}catch(e){if(e instanceof o&&!this.options.strict){if(this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col}),t.advance([b.RBRACE])!==b.RBRACE)throw e;return!0}throw e}return e&&(this.fire({type:"startrule",selectors:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endrule",selectors:e,line:e[0].line,col:e[0].col})),e},_selectors_group:function(){var e,t=this._tokenStream,r=[];if(null!==(e=this._selector()))for(r.push(e);t.match(b.COMMA);)this._readWhitespace(),null!==(e=this._selector())?r.push(e):this._unexpectedToken(t.LT(1));return r.length?r:null},_selector:function(){var e=this._tokenStream,t=[],r=null,n=null,i=null;if(null===(r=this._simple_selector_sequence()))return null;for(t.push(r);;)if(null!==(n=this._combinator()))t.push(n),null===(r=this._simple_selector_sequence())?this._unexpectedToken(e.LT(1)):t.push(r);else{if(!this._readWhitespace())break;i=new s(e.token().value,e.token().startLine,e.token().startCol),n=this._combinator(),null===(r=this._simple_selector_sequence())?null!==n&&this._unexpectedToken(e.LT(1)):(null!==n?t.push(n):t.push(i),t.push(r))}return new p(t,t[0].line,t[0].col)},_simple_selector_sequence:function(){var e,t,r=this._tokenStream,n=null,i=[],o="",a=[function(){return r.match(b.HASH)?new m(r.token().value,"id",r.token().startLine,r.token().startCol):null},this._class,this._attrib,this._pseudo,this._negation],s=0,l=a.length,c=null;for(e=r.LT(1).startLine,t=r.LT(1).startCol,(n=this._type_selector())||(n=this._universal()),null!==n&&(o+=n);r.peek()!==b.S;){for(;s<l&&null===c;)c=a[s++].call(this);if(null===c){if(""===o)return null;break}s=0,i.push(c),o+=c.toString(),c=null}return""!==o?new f(n,i,o,e,t):null},_type_selector:function(){var e=this._tokenStream,t=this._namespace_prefix(),r=this._element_name();return r?(t&&(r.text=t+r.text,r.col-=t.length),r):(t&&(e.unget(),t.length>1&&e.unget()),null)},_class:function(){var e,t=this._tokenStream;return t.match(b.DOT)?(t.mustMatch(b.IDENT),e=t.token(),new m("."+e.value,"class",e.startLine,e.startCol-1)):null},_element_name:function(){var e,t=this._tokenStream;return t.match(b.IDENT)?(e=t.token(),new m(e.value,"elementName",e.startLine,e.startCol)):null},_namespace_prefix:function(){var e=this._tokenStream,t="";return e.LA(1)!==b.PIPE&&e.LA(2)!==b.PIPE||(e.match([b.IDENT,b.STAR])&&(t+=e.token().value),e.mustMatch(b.PIPE),t+="|"),t.length?t:null},_universal:function(){var e,t=this._tokenStream,r="";return(e=this._namespace_prefix())&&(r+=e),t.match(b.STAR)&&(r+="*"),r.length?r:null},_attrib:function(){var e,t,r=this._tokenStream,n=null;return r.match(b.LBRACKET)?(n=(t=r.token()).value,n+=this._readWhitespace(),(e=this._namespace_prefix())&&(n+=e),r.mustMatch(b.IDENT),n+=r.token().value,n+=this._readWhitespace(),r.match([b.PREFIXMATCH,b.SUFFIXMATCH,b.SUBSTRINGMATCH,b.EQUALS,b.INCLUDES,b.DASHMATCH])&&(n+=r.token().value,n+=this._readWhitespace(),r.mustMatch([b.IDENT,b.STRING]),n+=r.token().value,n+=this._readWhitespace()),r.mustMatch(b.RBRACKET),new m(n+"]","attribute",t.startLine,t.startCol)):null},_pseudo:function(){var e,t,r=this._tokenStream,n=null,i=":";if(r.match(b.COLON)){if(r.match(b.COLON)&&(i+=":"),r.match(b.IDENT)?(n=r.token().value,e=r.token().startLine,t=r.token().startCol-i.length):r.peek()===b.FUNCTION&&(e=r.LT(1).startLine,t=r.LT(1).startCol-i.length,n=this._functional_pseudo()),!n){var a=r.LT(1).startLine,s=r.LT(0).startCol;throw new o("Expected a `FUNCTION` or `IDENT` after colon at line "+a+", col "+s+".",a,s)}n=new m(i+n,"pseudo",e,t)}return n},_functional_pseudo:function(){var e=this._tokenStream,t=null;return e.match(b.FUNCTION)&&(t=e.token().value,t+=this._readWhitespace(),t+=this._expression(),e.mustMatch(b.RPAREN),t+=")"),t},_expression:function(){for(var e=this._tokenStream,t="";e.match([b.PLUS,b.MINUS,b.DIMENSION,b.NUMBER,b.STRING,b.IDENT,b.LENGTH,b.FREQ,b.ANGLE,b.TIME,b.RESOLUTION,b.SLASH]);)t+=e.token().value,t+=this._readWhitespace();return t.length?t:null},_negation:function(){var e,t,r,n=this._tokenStream,i="",o=null;return n.match(b.NOT)&&(i=n.token().value,e=n.token().startLine,t=n.token().startCol,i+=this._readWhitespace(),i+=r=this._negation_arg(),i+=this._readWhitespace(),n.match(b.RPAREN),i+=n.token().value,(o=new m(i,"not",e,t)).args.push(r)),o},_negation_arg:function(){var e,t,r=this._tokenStream,n=[this._type_selector,this._universal,function(){return r.match(b.HASH)?new m(r.token().value,"id",r.token().startLine,r.token().startCol):null},this._class,this._attrib,this._pseudo],i=null,o=0,a=n.length;for(e=r.LT(1).startLine,t=r.LT(1).startCol;o<a&&null===i;)i=n[o].call(this),o++;return null===i&&this._unexpectedToken(r.LT(1)),"elementName"===i.type?new f(i,[],i.toString(),e,t):new f(null,[i],i.toString(),e,t)},_declaration:function(){var e=this._tokenStream,t=null,r=null,n=null,i=null,o="";if(null!==(t=this._property())){e.mustMatch(b.COLON),this._readWhitespace(),(!(r=this._expr())||0===r.length)&&this._unexpectedToken(e.LT(1)),n=this._prio(),o=t.toString(),(this.options.starHack&&"*"===t.hack||this.options.underscoreHack&&"_"===t.hack)&&(o=t.text);try{this._validateProperty(o,r)}catch(e){i=e}return this.fire({type:"property",property:t,value:r,important:n,line:t.line,col:t.col,invalid:i}),!0}return!1},_prio:function(){var e=this._tokenStream.match(b.IMPORTANT_SYM);return this._readWhitespace(),e},_expr:function(e){var t=[],r=null,n=null;if(null!==(r=this._term(e)))for(t.push(r);;){if((n=this._operator(e))&&t.push(n),null===(r=this._term(e)))break;t.push(r)}return t.length>0?new h(t,t[0].line,t[0].col):null},_term:function(e){var t,r,n,i,o=this._tokenStream,a=null,s=null,l=null;return null!==(t=this._unary_operator())&&(n=o.token().startLine,i=o.token().startCol),o.peek()===b.IE_FUNCTION&&this.options.ieFilters?(a=this._ie_function(),null===t&&(n=o.token().startLine,i=o.token().startCol)):e&&o.match([b.LPAREN,b.LBRACE,b.LBRACKET])?(s=(r=o.token()).endChar,a=r.value+this._expr(e).text,null===t&&(n=o.token().startLine,i=o.token().startCol),o.mustMatch(b.type(s)),a+=s,this._readWhitespace()):o.match([b.NUMBER,b.PERCENTAGE,b.LENGTH,b.ANGLE,b.TIME,b.FREQ,b.STRING,b.IDENT,b.URI,b.UNICODE_RANGE])?(a=o.token().value,null===t&&(n=o.token().startLine,i=o.token().startCol,l=d.fromToken(o.token())),this._readWhitespace()):null===(r=this._hexcolor())?(null===t&&(n=o.LT(1).startLine,i=o.LT(1).startCol),null===a&&(a=o.LA(3)===b.EQUALS&&this.options.ieFilters?this._ie_function():this._function())):(a=r.value,null===t&&(n=r.startLine,i=r.startCol)),null!==l?l:null!==a?new d(null!==t?t+a:a,n,i)