/*!
 * monaco-ace-tokenizer
 * Version - 0.2.1
 * Author - Brijesh Bittu <brijesh@bitwiser.in> (http://bitwiser.in/)
 */
/*!
 * For files in src/ace/
 * 
 * Copyright (c) 2010, Ajax.org B.V.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Ajax.org B.V. nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("monaco-editor")):"function"==typeof define&&define.amd?define(["vs/editor/editor.main"],t):"object"==typeof exports?exports.MonacoAceTokenizer=t(require("monaco-editor")):e.MonacoAceTokenizer=t(e.monaco)}(self,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){if("object"!==r(e)||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=o(e[n]);return t}if("[object Object]"!==Object.prototype.toString.call(e))return e;for(var n in t={},e)t[n]=o(e[n]);return t}n.r(t),n.d(t,"TextHighlightRules",(function(){return i}));var i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(t)for(var n in e){for(var r=e[n],o=0;o<r.length;o++){var i=r[o];(i.next||i.onMatch)&&("string"==typeof i.next&&0!==i.next.indexOf(t)&&(i.next=t+i.next),i.nextState&&0!==i.nextState.indexOf(t)&&(i.nextState=t+i.nextState))}this.$rules[t+n]=r}else for(var n in e)this.$rules[n]=e[n]},this.getRules=function(){return this.$rules},this.embedRules=function(e,t,n,r,i){var s="function"==typeof e?(new e).getRules():e;if(r)for(var a=0;a<r.length;a++)r[a]=t+r[a];else for(var u in r=[],s)r.push(t+u);if(this.addRules(s,t),n){var l=Array.prototype[i?"push":"unshift"];for(a=0;a<r.length;a++)l.apply(this.$rules[r[a]],o(n))}this.$embeds||(this.$embeds=[]),this.$embeds.push(t)},this.getEmbeds=function(){return this.$embeds};var e=function(e,t){return("start"!=e||t.length)&&t.unshift(this.nextState,e),this.nextState},t=function(e,t){return t.shift(),t.shift()||"start"};this.normalizeRules=function(){var n=0,r=this.$rules;Object.keys(r).forEach((function o(i){var s=r[i];s.processed=!0;for(var a=0;a<s.length;a++){var u=s[a],l=null;Array.isArray(u)&&(l=u,u={}),!u.regex&&u.start&&(u.regex=u.start,u.next||(u.next=[]),u.next.push({defaultToken:u.token},{token:u.token+".end",regex:u.end||u.start,next:"pop"}),u.token=u.token+".start",u.push=!0);var c=u.next||u.push;if(c&&Array.isArray(c)){var f=u.stateName;f||("string"!=typeof(f=u.token)&&(f=f[0]||""),r[f]&&(f+=n++)),r[f]=c,u.next=f,o(f)}else"pop"==c&&(u.next=t);if(u.push&&(u.nextState=u.next||u.push,u.next=e,delete u.push),u.rules)for(var p in u.rules)r[p]?r[p].push&&r[p].push.apply(r[p],u.rules[p]):r[p]=u.rules[p];var h="string"==typeof u?u:u.include;if(h&&(l=Array.isArray(h)?h.map((function(e){return r[e]})):r[h]),l){var g=[a,1].concat(l);u.noEscape&&(g=g.filter((function(e){return!e.next}))),s.splice.apply(s,g),a--}u.keywordMap&&(u.token=this.createKeywordMapper(u.keywordMap,u.defaultToken||"text",u.caseInsensitive),delete u.defaultToken)}}),this)},this.createKeywordMapper=function(e,t,n,r){var o=Object.create(null);return Object.keys(e).forEach((function(t){var i=e[t];n&&(i=i.toLowerCase());for(var s=i.split(r||"|"),a=s.length;a--;)o[s[a]]=t})),Object.getPrototypeOf(o)&&(o.__proto__=null),this.$keywordList=Object.keys(o),e=null,n?function(e){return o[e.toLowerCase()]||t}:function(e){return o[e]||t}},this.getKeywords=function(){return this.$keywords}}).call(i.prototype)},function(e,t,n){"use strict";n.r(t),n.d(t,"inherits",(function(){return r}));var r=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},function(t,n){t.exports=e},function(e,t,n){"use strict";n.r(t),n.d(t,"Tokenizer",(function(){return i})),n.d(t,"TextHighlightRules",(function(){return s.TextHighlightRules})),n.d(t,"DocCommentHighlightRules",(function(){return l})),n.d(t,"AVAILABLE_LANGUAGES",(function(){return h})),n.d(t,"registerRulesForLanguage",(function(){return g})),n.d(t,"oop",(function(){return y}));var r=2e3,o=function(e){for(var t in this.states=e,this.regExps={},this.matchMappings={},this.states){for(var n=this.states[t],r=[],o=0,i=this.matchMappings[t]={defaultToken:"text"},s="g",a=[],u=0;u<n.length;u++){var l=n[u];if(l.defaultToken&&(i.defaultToken=l.defaultToken),l.caseInsensitive&&(s="gi"),null!=l.regex){l.regex instanceof RegExp&&(l.regex=l.regex.toString().slice(1,-1));var c=l.regex,f=new RegExp("(?:("+c+")|(.))").exec("a").length-2;Array.isArray(l.token)?1==l.token.length||1==f?l.token=l.token[0]:f-1!=l.token.length?(this.reportError("number of classes and regexp groups doesn't match",{rule:l,groupCount:f-1}),l.token=l.token[0]):(l.tokenArray=l.token,l.token=null,l.onMatch=this.$arrayTokens):"function"!=typeof l.token||l.onMatch||(l.onMatch=f>1?this.$applyToken:l.token),f>1&&(/\\\d/.test(l.regex)?c=l.regex.replace(/\\([0-9]+)/g,(function(e,t){return"\\"+(parseInt(t,10)+o+1)})):(f=1,c=this.removeCapturingGroups(l.regex)),l.splitRegex||"string"==typeof l.token||a.push(l)),i[o]=u,o+=f,r.push(c),l.onMatch||(l.onMatch=null)}}r.length||(i[0]=0,r.push("$")),a.forEach((function(e){e.splitRegex=this.createSplitterRegexp(e.regex,s)}),this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",s)}};(function(){this.$setMaxTokenCount=function(e){r=0|e},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if("string"==typeof n)return[{type:n,value:e}];for(var r=[],o=0,i=n.length;o<i;o++)t[o]&&(r[r.length]={type:n[o],value:t[o]});return r},this.$arrayTokens=function(e){if(!e)return[];var t=this.splitRegex.exec(e);if(!t)return"text";for(var n=[],r=this.tokenArray,o=0,i=r.length;o<i;o++)t[o+1]&&(n[n.length]={type:r[o],value:t[o+1]});return n},this.removeCapturingGroups=function(e){return e.replace(/\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!]|(\()/g,(function(e,t){return t?"(?:":e}))},this.createSplitterRegexp=function(e,t){if(-1!=e.indexOf("(?=")){var n=0,r=!1,o={};e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g,(function(e,t,i,s,a,u){return r?r="]"!=a:a?r=!0:s?(n==o.stack&&(o.end=u+1,o.stack=-1),n--):i&&(n++,1!=i.length&&(o.stack=n,o.start=u)),e})),null!=o.end&&/^\)*$/.test(e.substr(o.end))&&(e=e.substring(0,o.start)+e.substr(o.end))}return"^"!=e.charAt(0)&&(e="^"+e),"$"!=e.charAt(e.length-1)&&(e+="$"),new RegExp(e,(t||"").replace("g",""))},this.getLineTokens=function(e,t){if(t&&"string"!=typeof t){var n=t.slice(0);"#tmp"===(t=n[0])&&(n.shift(),t=n.shift())}else n=[];var o=t||"start",i=this.states[o];i||(o="start",i=this.states[o]);var s=this.matchMappings[o],a=this.regExps[o];a.lastIndex=0;for(var u,l=[],c=0,f=0,p={type:null,value:""};u=a.exec(e);){var h=s.defaultToken,g=null,y=u[0],d=a.lastIndex;if(d-y.length>c){var x=e.substring(c,d-y.length);p.type==h?p.value+=x:(p.type&&l.push(p),p={type:h,value:x})}for(var v=0;v<u.length-2;v++)if(void 0!==u[v+1]){h=(g=i[s[v]]).onMatch?g.onMatch(y,o,n,e):g.token,g.next&&(o="string"==typeof g.next?g.next:g.next(o,n),(i=this.states[o])||(this.reportError("state doesn't exist",o),o="start",i=this.states[o]),s=this.matchMappings[o],c=d,(a=this.regExps[o]).lastIndex=d),g.consumeLineEnd&&(c=d);break}if(y)if("string"==typeof h)g&&!1===g.merge||p.type!==h?(p.type&&l.push(p),p={type:h,value:y}):p.value+=y;else if(h){p.type&&l.push(p),p={type:null,value:""};for(v=0;v<h.length;v++)l.push(h[v])}if(c==e.length)break;if(c=d,f++>r){for(f>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});c<e.length;)p.type&&l.push(p),p={value:e.substring(c,c+=2e3),type:"overflow"};o="start",n=[];break}}return p.type&&l.push(p),n.length>1&&n[0]!==o&&n.unshift("#tmp",o),{tokens:l,state:n.length?n:o}},this.reportError=function(){console.log(arguments)}}).call(o.prototype);var i=o,s=n(0),a=n(1),u=n(0).TextHighlightRules,l=function e(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},e.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};a.inherits(l,u),l.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},l.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},l.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}};var c=n(2);function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var p=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.state=t}var t,n,r;return t=e,(n=[{key:"equals",value:function(e){return e===this||e.state===this.state}},{key:"clone",value:function(){return new e(this.state)}}])&&f(t.prototype,n),r&&f(t,r),e}(),h=["ada","cobol","d","dart","elixir","erlang","fortran","groovy","haskell","julia","ocaml","racket","sbcl","scala"];function g(e,t){var n=new i(t.getRules());return c.languages.setTokensProvider(e,{getInitialState:function(){return new p("")},tokenize:function(e,t){var r=n.getLineTokens(e,t.state),o=r.tokens,i=r.state,s=0,a=o.map((function(e){var t={startIndex:s,scopes:e.type};return s+=e.value.length,t}));return{endState:new p(i),tokens:a}}})}var y=n(1)}])}));