ace.define("ace/mode/xquery",["require","exports","module","ace/worker/worker_client","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/xquery_highlight_rules","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],(function(e,t,n){var r=e("../worker/worker_client").WorkerClient,o=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,a=e("./xquery_highlight_rules").XQueryHighlightRules,c=e("../range").Range,l=e("./behaviour/cstyle").CstyleBehaviour,u=e("./folding/cstyle").FoldMode,g=function(e){this.$tokenizer=new s((new a).getRules()),this.$behaviour=new l(e),this.foldingRules=new u};o.inherits(g,i),function(){this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);return t.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/)&&(r+=n),r},this.checkOutdent=function(e,t,n){return!!/^\s+$/.test(t)&&/^\s*[\}\)]/.test(n)},this.autoOutdent=function(e,t,n){var r=t.getLine(n).match(/^(\s*[\}\)])/);if(!r)return 0;var o=r[1].length,i=t.findMatchingBracket({row:n,column:o});if(!i||i.row==n)return 0;var s=this.$getIndent(t.getLine(i.row));t.replace(new c(n,0,n,o-1),s)},this.$getIndent=function(e){var t=e.match(/^(\s+)/);return t?t[1]:""},this.toggleCommentLines=function(e,t,n,r){var o,i,s=!0,a=/^\s*\(:(.*):\)/;for(o=n;o<=r;o++)if(!a.test(t.getLine(o))){s=!1;break}var l=new c(0,0,0,0);for(o=n;o<=r;o++)i=t.getLine(o),l.start.row=o,l.end.row=o,l.end.column=i.length,t.replace(l,s?i.match(a)[1]:"(:"+i+":)")},this.createWorker=function(e){this.$deltas=[];var t=new r(["ace"],"ace/mode/xquery_worker","XQueryWorker"),n=this;return e.getDocument().on("change",(function(e){n.$deltas.push(e.data)})),t.attachToDocument(e.getDocument()),t.on("start",(function(e){n.$deltas=[]})),t.on("error",(function(t){e.setAnnotations([t.data])})),t.on("ok",(function(t){e.clearAnnotations()})),t.on("highlight",(function(t){for(var r=e.getLength()-1,o=t.data.lines,i=t.data.states,s=0;s<n.$deltas.length;s++){var a=n.$deltas[s];if("insertLines"===a.action){var c=a.lines.length;for(s=0;s<c;s++)o.splice(a.range.start.row+s,0,void 0),i.splice(a.range.start.row+s,0,void 0)}else if("insertText"===a.action)e.getDocument().isNewLine(a.text)?(o.splice(a.range.end.row,0,void 0),i.splice(a.range.end.row,0,void 0)):(o[a.range.start.row]=void 0,i[a.range.start.row]=void 0);else if("removeLines"===a.action){var l=a.lines.length;o.splice(a.range.start.row,l),i.splice(a.range.start.row,l)}else"removeText"===a.action&&(e.getDocument().isNewLine(a.text)?(o[a.range.start.row]=void 0,o.splice(a.range.end.row,1),i[a.range.start.row]=void 0,i.splice(a.range.end.row,1)):(o[a.range.start.row]=void 0,i[a.range.start.row]=void 0))}e.bgTokenizer.lines=o,e.bgTokenizer.states=i,e.bgTokenizer.fireUpdateEvent(0,r)})),t}}.call(g.prototype),t.Mode=g})),ace.define("ace/mode/xquery_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],(function(e,t,n){var r=e("../lib/oop"),o=e("./text_highlight_rules").TextHighlightRules,i=function(){var e=this.createKeywordMapper({keyword:"after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position"},"identifier");this.$rules={start:[{token:"text",regex:"<\\!\\[CDATA\\[",next:"cdata"},{token:"xml-pe",regex:"<\\?.*?\\?>"},{token:"comment",regex:"<\\!--",next:"comment"},{token:"comment",regex:"\\(:",next:"comment"},{token:"text",regex:"<\\/?",next:"tag"},{token:"constant",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"variable",regex:"\\$[a-zA-Z_][a-zA-Z0-9_\\-:]*\\b"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"},{token:"text",regex:"\\s+"},{token:"support.function",regex:"\\w[\\w+_\\-:]+(?=\\()"},{token:e,regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"\\*|=|<|>|\\-|\\+"},{token:"lparen",regex:"[[({]"},{token:"rparen",regex:"[\\])}]"}],tag:[{token:"text",regex:">",next:"start"},{token:"meta.tag",regex:"[-_a-zA-Z0-9:]+"},{token:"text",regex:"\\s+"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"}],cdata:[{token:"comment",regex:"\\]\\]>",next:"start"},{token:"comment",regex:"\\s+"},{token:"comment",regex:"(?:[^\\]]|\\](?!\\]>))+"}],comment:[{token:"comment",regex:".*?--\x3e",next:"start"},{token:"comment",regex:".*:\\)",next:"start"},{token:"comment",regex:".+"}]}};r.inherits(i,o),t.XQueryHighlightRules=i})),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],(function(e,t,n){var r=e("../../lib/oop"),o=e("../behaviour").Behaviour,i=e("../../token_iterator").TokenIterator,s=e("../../lib/lang"),a=["text","paren.rparen","punctuation.operator"],c=["text","paren.rparen","punctuation.operator","comment"],l=0,u=-1,g="",d=0,m=-1,f="",h="",x=function(){x.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new i(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",a)){var o=new i(t,n.row,n.column+1);if(!this.$matchTokenType(o.getCurrentToken()||"text",a))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",c)},x.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},x.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),o=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,o,g[0])||(l=0),u=r.row,g=n+o.substr(r.column),l++},x.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),o=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,o)||(d=0),m=r.row,f=o.substr(0,r.column)+n,h=o.substr(r.column),d++},x.isAutoInsertedClosing=function(e,t,n){return l>0&&e.row===u&&n===g[0]&&t.substr(e.column)===g},x.isMaybeInsertedClosing=function(e,t){return d>0&&e.row===m&&t.substr(e.column)===h&&t.substr(0,e.column)==f},x.popAutoInsertedClosing=function(){g=g.substr(1),l--},x.clearMaybeInsertedClosing=function(){d=0,m=-1},this.add("braces","insertion",(function(e,t,n,r,o){var i=n.getCursorPosition(),a=r.doc.getLine(i.row);if("{"==o){var c=n.getSelectionRange(),l=r.doc.getTextRange(c);if(""!==l&&"{"!==l&&n.getWrapBehavioursEnabled())return{text:"{"+l+"}",selection:!1};if(x.isSaneInsertion(n,r))return/[\]\}\)]/.test(a[i.column])?(x.recordAutoInsert(n,r,"}"),{text:"{}",selection:[1,1]}):(x.recordMaybeInsert(n,r,"{"),{text:"{",selection:[1,1]})}else if("}"==o){if("}"==a.substring(i.column,i.column+1))if(null!==r.$findOpeningBracket("}",{column:i.column+1,row:i.row})&&x.isAutoInsertedClosing(i,a,o))return x.popAutoInsertedClosing(),{text:"",selection:[1,1]}}else if("\n"==o||"\r\n"==o){var u="";if(x.isMaybeInsertedClosing(i,a)&&(u=s.stringRepeat("}",d),x.clearMaybeInsertedClosing()),"}"==a.substring(i.column,i.column+1)||""!==u){if(!r.findMatchingBracket({row:i.row,column:i.column},"}"))return null;var g=this.getNextLineIndent(e,a.substring(0,i.column),r.getTabString());return{text:"\n"+g+"\n"+this.$getIndent(a)+u,selection:[1,g.length,1,g.length]}}}})),this.add("braces","deletion",(function(e,t,n,r,o){var i=r.doc.getTextRange(o);if(!o.isMultiLine()&&"{"==i){if("}"==r.doc.getLine(o.start.row).substring(o.end.column,o.end.column+1))return o.end.column++,o;d--}})),this.add("parens","insertion",(function(e,t,n,r,o){if("("==o){var i=n.getSelectionRange(),s=r.doc.getTextRange(i);if(""!==s&&n.getWrapBehavioursEnabled())return{text:"("+s+")",selection:!1};if(x.isSaneInsertion(n,r))return x.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(")"==o){var a=n.getCursorPosition(),c=r.doc.getLine(a.row);if(")"==c.substring(a.column,a.column+1))if(null!==r.$findOpeningBracket(")",{column:a.column+1,row:a.row})&&x.isAutoInsertedClosing(a,c,o))return x.popAutoInsertedClosing(),{text:"",selection:[1,1]}}})),this.add("parens","deletion",(function(e,t,n,r,o){var i=r.doc.getTextRange(o);if(!o.isMultiLine()&&"("==i&&")"==r.doc.getLine(o.start.row).substring(o.start.column+1,o.start.column+2))return o.end.column++,o})),this.add("brackets","insertion",(function(e,t,n,r,o){if("["==o){var i=n.getSelectionRange(),s=r.doc.getTextRange(i);if(""!==s&&n.getWrapBehavioursEnabled())return{text:"["+s+"]",selection:!1};if(x.isSaneInsertion(n,r))return x.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if("]"==o){var a=n.getCursorPosition(),c=r.doc.getLine(a.row);if("]"==c.substring(a.column,a.column+1))if(null!==r.$findOpeningBracket("]",{column:a.column+1,row:a.row})&&x.isAutoInsertedClosing(a,c,o))return x.popAutoInsertedClosing(),{text:"",selection:[1,1]}}})),this.add("brackets","deletion",(function(e,t,n,r,o){var i=r.doc.getTextRange(o);if(!o.isMultiLine()&&"["==i&&"]"==r.doc.getLine(o.start.row).substring(o.start.column+1,o.start.column+2))return o.end.column++,o})),this.add("string_dquotes","insertion",(function(e,t,n,r,o){if('"'==o||"'"==o){var i=o,s=n.getSelectionRange(),a=r.doc.getTextRange(s);if(""!==a&&"'"!==a&&'"'!=a&&n.getWrapBehavioursEnabled())return{text:i+a+i,selection:!1};var c=n.getCursorPosition(),l=r.doc.getLine(c.row);if("\\"==l.substring(c.column-1,c.column))return null;for(var u,g=r.getTokens(s.start.row),d=0,m=-1,f=0;f<g.length&&("string"==(u=g[f]).type?m=-1:m<0&&(m=u.value.indexOf(i)),!(u.value.length+d>s.start.column));f++)d+=g[f].value.length;if(!u||m<0&&"comment"!==u.type&&("string"!==u.type||s.start.column!==u.value.length+d-1&&u.value.lastIndexOf(i)===u.value.length-1)){if(!x.isSaneInsertion(n,r))return;return{text:i+i,selection:[1,1]}}if(u&&"string"===u.type)if(l.substring(c.column,c.column+1)==i)return{text:"",selection:[1,1]}}})),this.add("string_dquotes","deletion",(function(e,t,n,r,o){var i=r.doc.getTextRange(o);if(!o.isMultiLine()&&('"'==i||"'"==i)&&'"'==r.doc.getLine(o.start.row).substring(o.start.column+1,o.start.column+2))return o.end.column++,o}))};r.inherits(x,o),t.CstyleBehaviour=x})),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],(function(e,t,n){var r=e("../../lib/oop"),o=(e("../../range").Range,e("./fold_mode").FoldMode),i=t.FoldMode=function(){};r.inherits(i,o),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.getFoldWidgetRange=function(e,t,n){var r,o=e.getLine(n);if(r=o.match(this.foldingStartMarker)){var i=r.index;return r[1]?this.openingBracketBlock(e,r[1],n,i):e.getCommentFoldRange(n,i+r[0].length,1)}if("markbeginend"===t&&(r=o.match(this.foldingStopMarker))){i=r.index+r[0].length;return r[1]?this.closingBracketBlock(e,r[1],n,i):e.getCommentFoldRange(n,i,-1)}}}.call(i.prototype)}));