!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(x){"use strict";x.registerHelper("wordChars","r",/[\w.]/),x.defineMode("r",function(a){function e(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=!0;return t}var t=["NULL","NA","Inf","NaN","NA_integer_","NA_real_","NA_complex_","NA_character_","TRUE","FALSE"],r=["list","quote","bquote","eval","return","call","parse","deparse"],n=["if","else","repeat","while","function","for","in","next","break"];x.registerHelper("hintWords","r",t.concat(r,n));var i,o=e(t),c=e(r),f=e(n),l=e(["if","else","repeat","while","function","for"]),u=/[+\-*\/^<>=!&|~$:]/;function d(e,t){i=null;var r=e.next();if("#"==r)return e.skipToEnd(),"comment";if("0"==r&&e.eat("x"))return e.eatWhile(/[\da-f]/i),"number";if("."==r&&e.eat(/\d/))return e.match(/\d*(?:e[+\-]?\d+)?/),"number";if(/\d/.test(r))return e.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/),"number";if("'"==r||'"'==r)return t.tokenize=function(i){return function(e,t){if(e.eat("\\")){var r=e.next();return"x"==r?e.match(/^[a-f0-9]{2}/i):("u"==r||"U"==r)&&e.eat("{")&&e.skipTo("}")?e.next():"u"==r?e.match(/^[a-f0-9]{4}/i):"U"==r?e.match(/^[a-f0-9]{8}/i):/[0-7]/.test(r)&&e.match(/^[0-7]{1,2}/),"string-2"}for(var n;null!=(n=e.next());){if(n==i){t.tokenize=d;break}if("\\"==n){e.backUp(1);break}}return"string"}}(r),"string";if("`"==r)return e.match(/[^`]+`/),"variable-3";if("."==r&&e.match(/.[.\d]+/))return"keyword";if(/[\w\.]/.test(r)&&"_"!=r){e.eatWhile(/[\w\.]/);var n=e.current();return o.propertyIsEnumerable(n)?"atom":f.propertyIsEnumerable(n)?(l.propertyIsEnumerable(n)&&!e.match(/\s*if(\s+|$)/,!1)&&(i="block"),"keyword"):c.propertyIsEnumerable(n)?"builtin":"variable"}return"%"==r?(e.skipTo("%")&&e.next(),"operator variable-2"):"<"==r&&e.eat("-")||"<"==r&&e.match("<-")||"-"==r&&e.match(/>>?/)?"operator arrow":"="==r&&t.ctx.argList?"arg-is":u.test(r)?"$"==r?"operator dollar":(e.eatWhile(u),"operator"):/[\(\){}\[\];]/.test(r)&&";"==(i=r)?"semi":null}function s(e,t,r){e.ctx={type:t,indent:e.indent,flags:0,column:r.column(),prev:e.ctx}}function p(e,t){var r=e.ctx;e.ctx={type:r.type,indent:r.indent,flags:r.flags|t,column:r.column,prev:r.prev}}function m(e){e.indent=e.ctx.indent,e.ctx=e.ctx.prev}return{startState:function(){return{tokenize:d,ctx:{type:"top",indent:-a.indentUnit,flags:2},indent:0,afterIdent:!1}},token:function(e,t){if(e.sol()&&(0==(3&t.ctx.flags)&&(t.ctx.flags|=2),4&t.ctx.flags&&m(t),t.indent=e.indentation()),e.eatSpace())return null;var r=t.tokenize(e,t);return"comment"!=r&&0==(2&t.ctx.flags)&&p(t,1),";"!=i&&"{"!=i&&"}"!=i||"block"!=t.ctx.type||m(t),"{"==i?s(t,"}",e):"("==i?(s(t,")",e),t.afterIdent&&(t.ctx.argList=!0)):"["==i?s(t,"]",e):"block"==i?s(t,"block",e):i==t.ctx.type?m(t):"block"==t.ctx.type&&"comment"!=r&&p(t,4),t.afterIdent="variable"==r||"keyword"==r,r},indent:function(e,t){if(e.tokenize!=d)return 0;var r=t&&t.charAt(0),n=e.ctx,i=r==n.type;return 4&n.flags&&(n=n.prev),"block"==n.type?n.indent+("{"==r?0:a.indentUnit):1&n.flags?n.column+(i?0:1):n.indent+(i?0:a.indentUnit)},lineComment:"#"}}),x.defineMIME("text/x-rsrc","r")});