UNPKG

ace-builds

Version:
1 lines 1.62 MB
"no use strict";!function(e){function t(e,t){var n=e,r="";while(n){var i=t[n];if(typeof i=="string")return i+r;if(i)return i.location.replace(/\/*$/,"/")+(r||i.main||i.name);if(i===!1)return"";var s=n.lastIndexOf("/");if(s===-1)break;r=n.substr(s)+r,n=n.slice(0,s)}return e}if(typeof e.window!="undefined"&&e.document)return;if(e.require&&e.define)return;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,n,r,i){postMessage({type:"error",data:{message:e,data:i&&i.data,file:t,line:n,col:r,stack:i&&i.stack}})},e.normalizeModule=function(t,n){if(n.indexOf("!")!==-1){var r=n.split("!");return e.normalizeModule(t,r[0])+"!"+e.normalizeModule(t,r[1])}if(n.charAt(0)=="."){var i=t.split("/").slice(0,-1).join("/");n=(i?i+"/":"")+n;while(n.indexOf(".")!==-1&&s!=n){var s=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(r,i){i||(i=r,r=null);if(!i.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");i=e.normalizeModule(r,i);var s=e.require.modules[i];if(s)return s.initialized||(s.initialized=!0,s.exports=s.factory().exports),s.exports;if(!e.require.tlns)return console.log("unable to load "+i);var o=t(i,e.require.tlns);return o.slice(-3)!=".js"&&(o+=".js"),e.require.id=i,e.require.modules[i]={},importScripts(o),e.require(r,i)},e.require.modules={},e.require.tlns={},e.define=function(t,n,r){arguments.length==2?(r=n,typeof t!="string"&&(n=t,t=e.require.id)):arguments.length==1&&(r=t,n=[],t=e.require.id);if(typeof r!="function"){e.require.modules[t]={exports:r,initialized:!0};return}n.length||(n=["require","exports","module"]);var i=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=r.apply(this,n.slice(0,r.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}}},e.define.amd={},e.require.tlns={},e.initBaseUrls=function(t){for(var n in t)this.require.tlns[n]=t[n]},e.initSender=function(){var n=e.require("ace/lib/event_emitter").EventEmitter,r=e.require("ace/lib/oop"),i=function(){};return function(){r.implement(this,n),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(i.prototype),new i};var n=e.main=null,r=e.sender=null;e.onmessage=function(t){var i=t.data;if(i.event&&r)r._signal(i.event,i.data);else if(i.command)if(n[i.command])n[i.command].apply(n,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 s=this.require(i.module)[i.classname];n=e.main=new s(r)}}}(this),ace.define("ace/lib/oop",[],function(e,t,n){"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 n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/apply_delta",[],function(e,t,n){"use strict";function r(e,t){throw console.log("Invalid Delta:",e),"Invalid Delta: "+t}function i(e,t){return t.row>=0&&t.row<e.length&&t.column>=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/lib/event_emitter",[],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length;o++){n[o](t,this);if(t.propagationStopped)break}if(r&&!t.defaultPrevented)return r(t,this)},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(!n)return;n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)},r.once=function(e,t){var n=this;this.on(e,function r(){n.off(e,r),t.apply(null,arguments)});if(!t)return new Promise(function(e){t=e})},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;n||(n=this._defaultHandlers={_disabled_:{}});if(n[e]){var r=n[e],i=n._disabled_[e];i||(n._disabled_[e]=i=[]),i.push(r);var s=i.indexOf(t);s!=-1&&i.splice(s,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(!n)return;var r=n._disabled_[e];if(n[e]==t)r&&this.setDefaultHandler(e,r.pop());else if(r){var i=r.indexOf(t);i!=-1&&r.splice(i,1)}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),r.indexOf(t)==-1&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(!n)return;var r=n.indexOf(t);r!==-1&&n.splice(r,1)},r.removeAllListeners=function(e){e||(this._eventRegistry=this._defaultHandlers=undefined),this._eventRegistry&&(this._eventRegistry[e]=undefined),this._defaultHandlers&&(this._defaultHandlers[e]=undefined)},t.EventEmitter=r}),ace.define("ace/range",[],function(e,t,n){"use strict";var r=function(){function e(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}}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 this.compare(e,t)==0},e.prototype.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},e.prototype.comparePoint=function(e){return this.compare(e.row,e.column)},e.prototype.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},e.prototype.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},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){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},e.prototype.setEnd=function(e,t){typeof e=="object"?(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 this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},e.prototype.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},e.prototype.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},e.prototype.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?t<this.start.column?-1:t>this.end.column?1:0: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},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,n){if(this.end.row>n)var r={row:n+1,column:0};else if(this.end.row<t)var r={row:t,column:0};if(this.start.row>n)var i={row:n+1,column:0};else if(this.start.row<t)var i={row:t,column:0};return e.fromPoints(i||this.start,r||this.end)},e.prototype.extend=function(t,n){var r=this.compare(t,n);if(r==0)return this;if(r==-1)var i={row:t,column:n};else var s={row:t,column:n};return e.fromPoints(i||this.start,s||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 this.end.column==0?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 n=t.documentToScreenPosition(this.start),r=t.documentToScreenPosition(this.end);return new e(n.row,n.column,r.row,r.column)},e.prototype.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t},e}();r.fromPoints=function(e,t){return new r(e.row,e.column,t.row,t.column)},r.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=r}),ace.define("ace/anchor",[],function(e,t,n){"use strict";function o(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}function u(e,t,n){var r=e.action=="insert",i=(r?1:-1)*(e.end.row-e.start.row),s=(r?1:-1)*(e.end.column-e.start.column),u=e.start,a=r?u:e.end;return o(t,u,n)?{row:t.row,column:t.column}:o(a,t,!n)?{row:t.row+i,column:t.column+(t.row==a.row?s:0)}:{row:u.row,column:u.column}}var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=function(){function e(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),typeof t!="number"?this.setPosition(t.row,t.column):this.setPosition(t,n)}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)return;if(e.start.row>this.row)return;var t=u(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(t.row,t.column,!0)},e.prototype.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},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 n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n},e}();s.prototype.$insertRight=!1,r.implement(s.prototype,i),t.Anchor=s}),ace.define("ace/document",[],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(){function e(e){this.$lines=[""],e.length===0?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 o(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 u(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){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},e.prototype.getNewLineMode=function(){return this.$newLineMode},e.prototype.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},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),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].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 n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},e.prototype.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},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){e=Math.min(Math.max(e,0),this.getLength());var n=0;e<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},e.prototype.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(t.length==1?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},e.prototype.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},e.prototype.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),i=this.clippedPos(e,n);return this.applyDelta({start:r,end:i,action:"remove",lines:this.getLinesForRange({start:r,end:i})},!0),this.clonePos(r)},e.prototype.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1),t=Math.min(Math.max(0,t),this.getLength()-1);var n=t==this.getLength()-1&&e>0,r=t<this.getLength()-1,i=n?e-1:e,s=n?this.getLine(i).length:0,u=r?t+1:t,a=r?0:this.getLine(u).length,f=new o(i,s,u,a),l=this.$lines.slice(e,t+1);return this.applyDelta({start:f.start,end:f.end,action:"remove",lines:this.getLinesForRange(f)}),l},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){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},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 n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&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;(e.action=="remove"&&e.start.row<t&&e.end.row<t||e.action=="insert"&&e.start.row<=t)&&this.applyDelta(e)},e.prototype.$splitAndapplyLargeDelta=function(e,t){var n=e.lines,r=n.length-t+1,i=e.start.row,s=e.start.column;for(var o=0,u=0;o<r;o=u){u+=t-1;var a=n.slice(o,u);a.push(""),this.applyDelta({start:this.pos(i+o,s),end:this.pos(i+u,s=0),action:e.action,lines:a},!0)}e.lines=n.slice(o),e.start.row=i+o,e.start.column=s,this.applyDelta(e,!0)},e.prototype.revertDelta=function(e){this.$safeApplyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:e.action=="insert"?"remove":"insert",lines:e.lines.slice()})},e.prototype.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i<s;i++){e-=n[i].length+r;if(e<0)return{row:i,column:e+n[i].length+r}}return{row:s-1,column:e+n[s-1].length+r}},e.prototype.positionToIndex=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,i=0,s=Math.min(e.row,n.length);for(var o=t||0;o<s;++o)i+=n[o].length+r;return i+e.column},e.prototype.$split=function(e){return e.split(/\r\n|\r|\n/)},e}();a.prototype.$autoNewLine="",a.prototype.$newLineMode="auto",r.implement(a.prototype,s),t.Document=a}),ace.define("ace/lib/deep_copy",[],function(e,t,n){t.deepCopy=function r(e){if(typeof e!="object"||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=r(e[n]);return t}if(Object.prototype.toString.call(e)!=="[object Object]")return e;t={};for(var n in e)t[n]=r(e[n]);return t}}),ace.define("ace/lib/lang",[],function(e,t,n){"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){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)e[n]&&typeof e[n]=="object"?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=e("./deep_copy").deepCopy,t.arrayToMap=function(e){var t={};for(var n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,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 n=[];return e.replace(t,function(e){n.push({offset:arguments[arguments.length-2],length:e.length})}),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},i=function(e){n==null&&(n=setTimeout(r,e||t))};return i.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){n&&clearTimeout(n),n=null},i.isPending=function(){return n},i},t.supportsLookbehind=function(){try{new RegExp("(?<=.)")}catch(e){return!1}return!0},t.skipEmptyMatch=function(e,t,n){return n&&e.codePointAt(t)>65535?2:1}}),ace.define("ace/worker/mirror",[],function(e,t,n){"use strict";var r=e("../document").Document,i=e("../lib/lang"),s=t.Mirror=function(e){this.sender=e;var t=this.doc=new r(""),n=this.deferredUpdate=i.delayedCall(this.onUpdate.bind(this)),s=this;e.on("change",function(e){var r=e.data;if(r[0].start)t.applyDeltas(r);else for(var i=0;i<r.length;i+=2){var o,u;Array.isArray(r[i+1])?o={action:"insert",start:r[i],lines:r[i+1]}:o={action:"remove",start:r[i],end:r[i+1]};if((o.action=="insert"?o.start:o.end).row>=t.$lines.length)throw u=new Error("Invalid delta"),u.data={path:s.$path,linesLength:t.$lines.length,start:o.start,end:o.end},u;t.applyDelta(o,!0)}if(s.$timeout)return n.schedule(s.$timeout);s.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(s.prototype)}),ace.define("ace/mode/xquery/xqlint",[],function(e,t,n){n.exports=function r(t,n,i){function o(u,a){if(!n[u]){if(!t[u]){var f=typeof e=="function"&&e;if(!a&&f)return f(u,!0);if(s)return s(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[u]={exports:{}};t[u][0].call(c.exports,function(e){var n=t[u][1][e];return o(n?n:e)},c,c.exports,r,t,n,i)}return n[u].exports}var s=typeof e=="function"&&e;for(var u=0;u<i.length;u++)o(i[u]);return o(i[0])}({"/node_modules/xqlint/lib/compiler/errors.js":[function(e,t,n){"use strict";var r=function(e,t,n,r,i){if(!t)throw new Error(i+" code is missing.");if(!n)throw new Error(i+" message is missing.");if(!r)throw new Error(i+" position is missing.");e.getCode=function(){return t},e.getMessage=function(){return n},e.getPos=function(){return r}},i={},s={};i.prototype=new Error,s.prototype=new Error,n.StaticError=i.prototype.constructor=function(e,t,n){r(this,e,t,n,"Error")},n.StaticWarning=s.prototype.constructor=function(e,t,n){r(this,e,t,n,"Warning")}},{}],"/node_modules/xqlint/lib/compiler/handlers.js":[function(e,t,n){"use strict";var r=e("../tree_ops").TreeOps,i=e("./errors"),s=i.StaticWarning;n.ModuleDecl=function(e,t,n){var i="";return{NCName:function(e){i=r.flatten(e)},URILiteral:function(s){s=r.flatten(s),s=s.substring(1,s.length-1),e.apply(function(){t.moduleNamespace=s,t.addNamespace(s,i,n.pos,"moduleDecl")})}}},n.ModuleImport=function(e,t,n){var i="",s;return{NCName:function(e){i=r.flatten(e)},URILiteral:function(o){if(s!==undefined)return;o=r.flatten(o),o=o.substring(1,o.length-1),s=o,e.apply(function(){t.importModule(o,i,n.pos)})}}},n.SchemaImport=function(e,t,n){var i="",s;return{SchemaPrefix:function(t){var n=function(){this.NCName=function(e){i=r.flatten(e)}};e.visitChildren(t,new n)},URILiteral:function(o){if(s!==undefined)return;o=r.flatten(o),o=o.substring(1,o.length-1),s=o,e.apply(function(){t.addNamespace(o,i,n.pos,"schema")})}}},n.DefaultNamespaceDecl=function(e,t,n){var i=!1,o="";return{TOKEN:function(e){i=i?!0:e.value==="function"},URILiteral:function(u){o=r.flatten(u),o=o.substring(1,o.length-1),i?t.defaultFunctionNamespace=o:(e.apply(function(){throw new s("W06","Avoid default element namespace declarations.",n.pos)}),t.defaultElementNamespace=o)}}},n.NamespaceDecl=function(e,t,n){var i="";return{NCName:function(e){i=r.flatten(e)},URILiteral:function(s){s=r.flatten(s),s=s.substring(1,s.length-1),e.apply(function(){t.addNamespace(s,i,n.pos,"declare")})}}},n.VarHandler=function(e,t,n){var i=function(i){var s=r.flatten(i);e.apply(function(){var e=t.resolveQName(s,i.pos);t.addVariable(e,n.name,i.pos)})};return{ExprSingle:function(){return!0},VarValue:function(){return!0},VarDefaultValue:function(){return!0},VarName:i,EQName:i}},n.VarRefHandler=function(e,t,n){return{VarName:function(i){var s=r.flatten(i);e.apply(function(){var e=t.resolveQName(s,n.pos);e.uri!==""&&(t.root.namespaces[e.uri].used=!0),t.addVarRef(e,i.pos)})}}}},{"../tree_ops":"/node_modules/xqlint/lib/tree_ops.js","./errors":"/node_modules/xqlint/lib/compiler/errors.js"}],"/node_modules/xqlint/lib/compiler/schema_built-in_types.js":[function(e,t,n){"use strict";n.getSchemaBuiltinTypes=function(){var e="http://www.w3.org/2001/XMLSchema",t={};return t[e]={variables:{},functions:{}},t[e].functions[e+"#string#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"string",arity:1,eqname:{uri:e,name:"string"}},t[e].functions[e+"#boolean#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"boolean",arity:1,eqname:{uri:e,name:"boolean"}},t[e].functions[e+"#decimal#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"decimal",arity:1,eqname:{uri:e,name:"decimal"}},t[e].functions[e+"#float#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"float",arity:1,eqname:{uri:e,name:"float"}},t[e].functions[e+"#double#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"double",arity:1,eqname:{uri:e,name:"double"}},t[e].functions[e+"#duration#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"duration",arity:1,eqname:{uri:e,name:"duration"}},t[e].functions[e+"#dateTime#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"dateTime",arity:1,eqname:{uri:e,name:"dateTime"}},t[e].functions[e+"#time#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"time",arity:1,eqname:{uri:e,name:"time"}},t[e].functions[e+"#date#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"date",arity:1,eqname:{uri:e,name:"date"}},t[e].functions[e+"#gYearMonth#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"gYearMonth",arity:1,eqname:{uri:e,name:"gYearMonth"}},t[e].functions[e+"#gYear#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"gYear",arity:1,eqname:{uri:e,name:"gYear"}},t[e].functions[e+"#gMonthDay#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"gMonthDay",arity:1,eqname:{uri:e,name:"gMonthDay"}},t[e].functions[e+"#gDay#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"gDay",arity:1,eqname:{uri:e,name:"gDay"}},t[e].functions[e+"#gMonth#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"gMonth",arity:1,eqname:{uri:e,name:"gMonth"}},t[e].functions[e+"#hexBinary#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"hexBinary",arity:1,eqname:{uri:e,name:"hexBinary"}},t[e].functions[e+"#base64Binary#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"base64Binary",arity:1,eqname:{uri:e,name:"base64Binary"}},t[e].functions[e+"#anyURI#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"anyURI",arity:1,eqname:{uri:e,name:"anyURI"}},t[e].functions[e+"#QName#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"QName",arity:1,eqname:{uri:e,name:"QName"}},t[e].functions[e+"#normalizedString#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"normalizedString",arity:1,eqname:{uri:e,name:"normalizedString"}},t[e].functions[e+"#token#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"token",arity:1,eqname:{uri:e,name:"token"}},t[e].functions[e+"#language#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"language",arity:1,eqname:{uri:e,name:"language"}},t[e].functions[e+"#NMTOKEN#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"NMTOKEN",arity:1,eqname:{uri:e,name:"NMTOKEN"}},t[e].functions[e+"#Name#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"Name",arity:1,eqname:{uri:e,name:"Name"}},t[e].functions[e+"#NCName#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"NCName",arity:1,eqname:{uri:e,name:"NCName"}},t[e].functions[e+"#ID#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"ID",arity:1,eqname:{uri:e,name:"ID"}},t[e].functions[e+"#IDREF#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"IDREF",arity:1,eqname:{uri:e,name:"IDREF"}},t[e].functions[e+"#ENTITY#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"ENTITY",arity:1,eqname:{uri:e,name:"ENTITY"}},t[e].functions[e+"#integer#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"integer",arity:1,eqname:{uri:e,name:"integer"}},t[e].functions[e+"#nonPositiveInteger#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"nonPositiveInteger",arity:1,eqname:{uri:e,name:"nonPositiveInteger"}},t[e].functions[e+"#negativeInteger#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"negativeInteger",arity:1,eqname:{uri:e,name:"negativeInteger"}},t[e].functions[e+"#long#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"long",arity:1,eqname:{uri:e,name:"long"}},t[e].functions[e+"#int#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"int",arity:1,eqname:{uri:e,name:"int"}},t[e].functions[e+"#short#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"short",arity:1,eqname:{uri:e,name:"short"}},t[e].functions[e+"#byte#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"byte",arity:1,eqname:{uri:e,name:"byte"}},t[e].functions[e+"#nonNegativeInteger#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"nonNegativeInteger",arity:1,eqname:{uri:e,name:"nonNegativeInteger"}},t[e].functions[e+"#unsignedLong#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"unsignedLong",arity:1,eqname:{uri:e,name:"unsignedLong"}},t[e].functions[e+"#unsignedInt#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"unsignedInt",arity:1,eqname:{uri:e,name:"unsignedInt"}},t[e].functions[e+"#unsignedShort#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"unsignedShort",arity:1,eqname:{uri:e,name:"unsignedShort"}},t[e].functions[e+"#unsignedByte#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"unsignedByte",arity:1,eqname:{uri:e,name:"unsignedByte"}},t[e].functions[e+"#positiveInteger#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"positiveInteger",arity:1,eqname:{uri:e,name:"positiveInteger"}},t[e].functions[e+"#yearMonthDuration#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"yearMonthDuration",arity:1,eqname:{uri:e,name:"yearMonthDuration"}},t[e].functions[e+"#dayTimeDuration#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"dayTimeDuration",arity:1,eqname:{uri:e,name:"dayTimeDuration"}},t[e].functions[e+"#untypedAtomic#1"]={params:["$arg as xs:anyAtomicType?"],annotations:[],name:"untypedAtomic",arity:1,eqname:{uri:e,name:"untypedAtomic"}},t}},{}],"/node_modules/xqlint/lib/compiler/static_context.js":[function(e,t,n){n.StaticContext=function(t,n){"use strict";var r=e("../tree_ops").TreeOps,i=e("./errors"),s=i.StaticError,o=i.StaticWarning,u=e("./schema_built-in_types").getSchemaBuiltinTypes,a={sl:0,sc:0,el:0,ec:0},f={},l=function(e){return e.uri+"#"+e.name},c=function(e,t){return l(e)+"#"+t};t||(f["http://jsoniq.org/functions"]={prefixes:["jn"],pos:a,type:"module",override:!0},f["http://www.28msec.com/modules/collections"]={prefixes:["db"],pos:a,type:"module",override:!0},f["http://www.28msec.com/modules/store"]={prefixes:["store"],pos:a,type:"module",override:!0},f["http://jsoniq.org/function-library"]={prefixes:["libjn"],pos:a,type:"module",override:!0},f["http://www.w3.org/2005/xpath-functions"]={prefixes:["fn"],pos:a,type:"module",override:!0},f["http://www.w3.org/2005/xquery-local-functions"]={prefixes:["local"],pos:a,type:"declare",override:!0},f["http://www.w3.org/2001/XMLSchema-instance"]={prefixes:["xsi"],pos:a,type:"declare"},f["http://www.w3.org/2001/XMLSchema"]={prefixes:["xs"],pos:a,type:"declare"},f["http://www.w3.org/XML/1998/namespace"]={prefixes:["xml"],pos:a,type:"declare"},f["http://zorba.io/annotations"]={prefixes:["an"],pos:a,type:"declare",override:!0},f["http://www.28msec.com/annotations/rest"]={prefixes:["rest"],pos:a,type:"declare",override:!0},f["http://www.w3.org/2005/xqt-errors"]={prefixes:["err"],pos:a,type:"declare",override:!0},f["http://zorba.io/errors"]={prefixes:["zerr"],pos:a,type:"declare",override:!0});var h={parent:t,children:[],pos:n,setModuleResolver:function(e){return this.root.moduleResolver=e,this},setModules:function(e){if(this!==this.root)throw new Error("setModules() not invoked from the root static context.");this.moduleResolver=function(t){return e[t]};var t=this;return Object.keys(this.namespaces).forEach(function(e){var n=t.namespaces[e];if(n.type==="module"){var i=t.moduleResolver(e);i.variables&&r.concat(t.variables,i.variables),i.functions&&r.concat(t.functions,i.functions)}}),this},setModulesFromXQDoc:function(e){if(this!==this.root)throw new Error("setModulesFromXQDoc() not invoked from the root static context.");var t={};Object.keys(e).forEach(function(n){var r=e[n],i={},s={};r.functions.forEach(function(e){s[n+"#"+e.name+"#"+e.arity]={params:[],annotations:[],name:e.name,arity:e.arity,eqname:{uri:n,name:e.name}},e.parameters.forEach(function(t){s[n+"#"+e.name+"#"+e.arity].params.push("$"+t.name)})}),r.variables.forEach(function(e){var t=e.name.substring(e.name.indexOf(":")+1);i[n+"#"+t]={type:"VarDecl",annotations:[],eqname:{uri:n,name:t}}}),t[n]={variables:i,functions:s}}),this.root.moduleResolver=function(e){return t[e]};var n=this;return Object.keys(this.namespaces).forEach(function(e){var t=n.namespaces[e];if(t.type==="module"){var i=n.moduleResolver(e);i.variables&&r.concat(n.variables,i.variables),i.functions&&r.concat(n.functions,i.functions)}}),this},moduleNamespace:"",description:"",defaultFunctionNamespace:"http://www.w3.org/2005/xpath-functions",defaultFunctionNamespaces:["http://www.28msec.com/modules/collections","http://www.28msec.com/modules/store","http://jsoniq.org/functions","http://jsoniq.org/function-library","http://www.w3.org/2001/XMLSchema"],defaultElementNamespace:"",namespaces:f,availableModuleNamespaces:[],importModule:function(e,t,n){if(this!==this.root)throw new Error("Function not invoked from the root static context.");this.addNamespace(e,t,n,"module");if(this.moduleResolver)try{var i=this.moduleResolver(e,[]);i.variables&&r.concat(this.variables,i.variables),i.functions&&r.concat(this.functions,i.functions)}catch(o){throw new s("XQST0059",'module "'+e+'" not found',n)}return this},getAvailableModuleNamespaces:function(){return this.root.availableModuleNamespaces},getPrefixesByNamespace:function(e){return this.root.namespaces[e].prefixes},addNamespace:function(e,t,n,r){if(t===""&&r==="module")throw new o("W01","Avoid this type of import. Use import module namespace instead",n);if(e==="")throw new s("XQST0088","empty target namespace in module import or module declaration",n);var i=this.getNamespace(e);if(i&&i.type===r&&r!=="declare"&&!i.override)throw new s("XQST0047",'"'+e+'": duplicate target namespace',n);i=this.getNamespaceByPrefix(t);if(i&&!i.override)throw new s("XQST0033",'"'+t+'": namespace prefix already bound to "'+i.uri+'"',n);i=this.namespaces[e];var u=[t];i&&(u=u.concat(this.namespaces[e].prefixes)),this.namespaces[e]={prefixes:u,pos:n,type:r};if(i)throw new o("W02",'"'+e+'" already bound to the "'+i.prefixes.join(", ")+'" prefix',n)},getNamespaces:function(){return this.root.namespaces},getNamespace:function(e){var t=this;while(t){var n=t.namespaces[e];if(n)return n;t=t.parent}},getNamespaceByPrefix:function(e){var t=[],n=function(n){var i=r.namespaces[n];i.prefixes.indexOf(e)!==-1&&(i.uri=n,t.push(i))},r=this;while(r)Object.keys(r.namespaces).forEach(n),r=r.parent;var i;return t.forEach(function(e){e.type==="moduleDecl"&&(i=e)}),i?i:t[0]},resolveQName:function(e,t){var n={uri:"",prefix:"",name:""},r;if(e.substring(0,2)==="Q{")r=e.indexOf("}"),n.uri=e.substring(2,r),n.name=e.substring(r+1);else{r=e.indexOf(":"),n.prefix=e.substring(0,r);var i=this.getNamespaceByPrefix(n.prefix);if(!i&&n.prefix!==""&&["fn","jn"].indexOf(n.prefix)===-1)throw new s("XPST0081",'"'+n.prefix+'": can not expand prefix of lexical QName to namespace URI',t);i&&(n.uri=i.uri),n.name=e.substring(r+1)}return n},variables:{},varRefs:{},functionCalls:{},addVariable:function(e,t,n){if(t==="VarDecl"&&this.moduleNamespace!==""&&this.moduleNamespace!==e.uri&&e.uri!=="")throw new s("XQST0048",'"'+e.prefix+":"+e.name+'": Qname not library namespace',n);var r=l(e);if(t==="VarDecl"&&this.variables[r])throw new s("XQST0049",'"'+e.name+'": duplicate variable declaration',n);return this.variables[r]={type:t,pos:n,qname:e,annotations:{}},this},getVariables:function(){var e={},t=this,n=function(n){e[n]||(e[n]=t.variables[n])};while(t)Object.keys(t.variables).forEach(n),t=t.parent;return e},getVariable:function(e){var t=l(e),n=this;while(n){if(n.variables[t])return n.variables[t];n=n.parent}},addVarRef:function(e,t){var n=this.getVariable(e);if(!n&&(e.uri===""||this.root.moduleResolver))throw new s("XPST0008",'"'+e.name+'": undeclared variable',t);var r=l(e);this.varRefs[r]=!0},addFunctionCall:function(e,t,n){var r=this.getFunction(e,t);if(!(!!r||e.uri!=="http://www.w3.org/2005/xquery-local-functions"&&!this.root.moduleResolver||(e.uri==="http://www.w3.org/2005/xpath-functions"||e.uri===""&&this.root.defaultFunctionNamespaces.concat(this.root.defaultFunctionNamespace).indexOf("http://www.w3.org/2005/xpath-functions")!==-1)&&e.name==="concat")&&!r)throw new s("XPST0008",'"'+e.name+"#"+t+'": undeclared function',n);var i=c(e,t);this.functionCalls[i]=!0},functions:u()["http://www.w3.org/2001/XMLSchema"].functions,getFunctions:function(){return this.root.functions},getFunction:function(e,t){var n=c(e,t),r;if(e.uri===""){var i=this;return this.root.defaultFunctionNamespaces.concat([this.root.defaultFunctionNamespace]).forEach(function(n){if(!!r)return!1;r=i.getFunction({uri:n,prefix:e.prefix,name:e.name},t)}),r}return this.root.functions[n]},addFunction:function(e,t,n){if(this!==this.root)throw new Error("addFunction() not invoked from the root static context.");var r=n.length;if(this.moduleNamespace===""||this.moduleNamespace===e.uri||e.uri===""&&this.defaultFunctionNamespace===this.moduleNamespace){var i=c(e,r);if(this.functions[i])throw new s("XQST0034",'"'+e.name+'": duplicate function declaration',t);return this.functions[i]={pos:t,params:n},this}throw new s("XQST0048",'"'+e.prefix+":"+e.name+'": Qname not library namespace',t)}};return h.root=t?t.root:h,h}},{"../tree_ops":"/node_modules/xqlint/lib/tree_ops.js","./errors":"/node_modules/xqlint/lib/compiler/errors.js","./schema_built-in_types":"/node_modules/xqlint/lib/compiler/schema_built-in_types.js"}],"/node_modules/xqlint/lib/compiler/translator.js":[function(e,t,n){n.Translator=function(t,n){"use strict";var r=e("./errors"),i=r.StaticError,s=r.StaticWarning,o=e("../tree_ops").TreeOps,u=e("./static_context").StaticContext,a=e("./handlers"),f=function(e,t){var n=[];return t.length===0?e:(e.children.forEach(function(e){e.name===t[0]&&t.length>1?n=f(e,t.slice(1)):e.name===t[0]&&n.push(e)}),n)},l=[];this.apply=function(e){try{e()}catch(t){if(t instanceof i)c(t);else{if(!(t instanceof s))throw t;h(t.getCode(),t.getMessage(),t.getPos())}}};var c=function(e){l.push({pos:e.getPos(),type:"error",level:"error",message:"["+e.getCode()+"] "+e.getMessage()})},h=function(e,t,n){l.push({pos:n,type:"warning",level:"warning",message:"["+e+"] "+t})};this.getMarkers=function(){return l};var p=this;t.pos=n.pos;var d=t,v=function(e){d=new u(d,e),d.parent.children.push(d)},m=function(e){e!==undefined&&(d.pos.el=e.el,d.pos.ec=e.ec),Object.keys(d.varRefs).forEach(function(e){d.variables[e]||(d.parent.varRefs[e]=!0)}),Object.keys(d.variables).forEach(function(e){!d.varRefs[e]&&d.variables[e].type!=="GroupingVariable"&&d.variables[e].type!=="CatchVar"&&h("W03",'Unused variable "$'+d.variables[e].qname.name+'"',d.variables[e].pos)}),d=d.parent};this.visitOnly=function(e,t){e.children.forEach(function(e){t.indexOf(e.name)!==-1&&p.visit(e)})},this.getFirstChild=function(e,t){var n;return e.children.forEach(function(e){e.name===t&&n===undefined&&(n=e)}),n},this.XQuery=function(e){t.description=e.comment?e.comment.description:undefined},this.ModuleDecl=function(e){return this.visitChildren(e,a.ModuleDecl(p,t,e)),!0},this.Prolog=function(e){return this.visitOnly(e,["DefaultNamespaceDecl","Setter","NamespaceDecl","Import"]),n.index.forEach(function(e){if(e.name==="VarDecl")e.children.forEach(function(n){n.name==="VarName"&&p.apply(function(){var r=o.flatten(n),i=t.resolveQName(r,n.pos);t.addVariable(i,e.name,n.pos)})});else if(e.name==="FunctionDecl"){var n,r,i=[];e.children.forEach(function(e){e.name==="EQName"?(n=e,r=e.pos):e.name==="ParamList"&&e.children.forEach(function(e){e.name==="Param"&&i.push(o.flatten(e))})}),p.apply(function(){n=o.flatten(n),n=t.resolveQName(n,r),t.addFunction(n,r,i)})}}),this.visitOnly(e,["ContextItemDecl","AnnotatedDecl","OptionDecl"]),!0},this.ModuleImport=function(e){return this.visitChildren(e,a.ModuleImport(p,t,e)),!0},this.SchemaImport=function(e){return this.visitChildren(e,a.SchemaImport(p,t,e)),!0},this.DefaultNamespaceDecl=function(e){return this.visitChildren(e,a.DefaultNamespaceDecl(p,t,e)),!0},this.NamespaceDecl=function(e){return this.visitChildren(e,a.NamespaceDecl(p,t,e)),!0};var g={};this.AnnotatedDecl=function(e){return g={},this.visitChildren(e,a.NamespaceDecl(p,t,e)),!0},this.CompatibilityAnnotation=function(){return g["http://www.w3.org/2012/xquery#updating"]=[],!0},this.Annotation=function(e){return this.visitChildren(e,{EQName:function(e){var t=o.flatten(e);p.apply(function(){var n=d.resolveQName(t,e.pos);g[n.uri+"#"+n.name]=[]})}}),!0},this.VarDecl=function(e){try{var n=p.getFirstChild(e,"VarName"),r=o.flatten(n),i=d.resolveQName(r,n.pos),s=t.getVariable(i);if(s){s.annotations=g,s.description=e.getParent.comment?e.getParent.comment.description:undefined,s.type=o.flatten(f(e,["TypeDeclaration"])[0]).substring(2).trim();var u=s.type.substring(s.type.length-1);u==="?"?(s.occurrence=0,s.type=s.type.substring(0,s.type.length-1)):u==="*"?(s.occurrence=-1,s.type=s.type.substring(0,s.type.length-1)):u==="+"?(s.occurrence=2,s.type=s.type.substring(0,s.type.length-1)):s.occurrence=1}}catch(a){}return this.visitOnly(e,["ExprSingle","VarValue","VarDefaultValue"]),!0},this.FunctionDecl=function(e){var t=g["http://www.w3.org/2012/xquery#updating"]!==undefined,n=f(e,["ReturnType"])[0],r=f(e,["EQName"])[0];!n&&!t&&h("W05","Untyped return value",r.pos);var i=!1;return e.children.forEach(function(e){if(e.name==="TOKEN"&&e.value==="external")return i=!0,!1}),i||(v(e.pos),this.visitChildren(e),m()),!0},this.VarRef=function(e){return this.visitChildren(e,a.VarRefHandler(p,d,e)),!0},this.Param=function(e){var t=f(e,["TypeDeclaration"])[0];return t||h("W05","Untyped function parameter",e.pos),this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.InlineFunctionExpr=function(e){return v(e.pos),this.visitChildren(e),m(),!0};var y=[],b=function(e){v(e.pos),y.push(0),p.visitChildren(e);for(var t=1;t<=y[y.length-1];t++)m(e.pos);y.pop(),m()};this.StatementsAndOptionalExpr=function(e){return b(e),!0},this.StatementsAndExpr=function(e){return b(e),!0},this.BlockStatement=function(e){return b(e),!0},this.VarDeclStatement=function(e){v(e.pos),y[y.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e))};var w=[];this.FLWORExpr=this.FLWORStatement=function(e){v(e.pos),w.push(0),this.visitChildren(e);for(var t=1;t<=w[w.length-1];t++)m(e.pos);return w.pop(),m(),!0},this.ForBinding=function(e){return this.visitOnly(e,["ExprSingle","VarValue","VarDefaultValue"]),v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.LetBinding=function(e){return this.visitOnly(e,["ExprSingle","VarValue","VarDefaultValue"]),v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.GroupingSpec=function(e){var t=!1;e.children.forEach(function(e){if(e.value===":=")return t=!0,!1});if(t){var n=e.children[0];return this.visitOnly(e,["ExprSingle","VarValue","VarDefaultValue"]),v(e.pos),w[w.length-1]++,this.visitChildren(n,a.VarHandler(p,d,n)),!0}},this.TumblingWindowClause=function(e){return this.visitOnly(e,["ExprSingle"]),v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),this.visitOnly(e,["WindowStartCondition","WindowEndCondition"]),!0},this.WindowVars=function(e){return v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.SlidingWindowClause=function(e){return this.visitOnly(e,["ExprSingle","VarValue","VarDefaultValue"]),v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),this.visitOnly(e,["WindowStartCondition","WindowEndCondition"]),!0},this.PositionalVar=function(e){return this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.PositionalVar=function(e){return this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.CurrentItem=function(e){return this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.PreviousItem=function(e){return this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.NextItem=function(e){return this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.CountClause=function(e){return v(e.pos),w[w.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.CaseClause=function(e){return v(e.pos),this.visitChildren(e,a.VarHandler(p,d,e)),this.visitOnly(e,["ExprSingle"]),m(),!0};var E=[];this.TransformExpr=function(e){v(e.pos),E.push(0),this.visitChildren(e);for(var t=1;t<=E[E.length-1];t++)m(e.pos);return E.pop(),m(),!0},this.TransformSpec=function(e){return this.visitOnly(e,["ExprSingle"]),v(e.pos),E[E.length-1]+=1,this.visitChildren(e,a.VarHandler(p,d,e)),!0};var S=[];this.QuantifiedExpr=function(e){v(e.pos),S.push(0),this.visitChildren(e);for(var t=1;t<=S[S.length-1];t++)m(e.pos);return S.pop(),m(),!0},this.QuantifiedVarDecl=function(e){return this.visitOnly(e,["ExprSingle"]),v(e.pos),S[S.length-1]++,this.visitChildren(e,a.VarHandler(p,d,e)),!0},this.FunctionCall=function(e){this.visitOnly(e,["ArgumentList"]);var t=p.getFirstChild(e,"EQName"),n=o.flatten(t),r=f(e,["ArgumentList","Argument"]).length;return p.apply(function(){var i=d.resolveQName(n,e.pos);try{i.uri!==""&&(d.root.namespaces[i.uri].used=!0)}catch(s){}d.addFunctionCall(i,r,t.pos)}),!0},this.TryClause=function(e){return v(e.pos),this.visitChildren(e),m(),!0},this.CatchClause=function(e){v(e.pos);var t="err",n="http://www.w3.org/2005/xqt-errors",r={sl:0,sc:0,el:0,ec:0};return d.addVariable({prefix:t,uri:n,name:"code"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"description"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"value"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"module"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"line-number"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"column-number"},"CatchVar",r),d.addVariable({prefix:t,uri:n,name:"additional"},"CatchVar",r),this.visitChildren(e),m(),!0},this.Pragma=function(e){var n=o.flatten(f(e,["EQName"])[0]);n=t.resolveQName(n,e);var r=o.flatten(f(e,["PragmaContents"])[0]);if(n.name==="xqlint"&&n.uri==="http://xqlint.io"){v(e.pos);var i=r.match(/[a-zA-Z]+\(([^)]+)\)/g);return i.forEach(function(t){var n=t.substring(0,t.indexOf("(")),r=t.substring(0,t.length-1).substring(t.indexOf("(")+1).split(",").map(function(e){return e.trim()});n==="varrefs"&&r.forEach(function(t){var n=d.resolveQName(t.substring(1),e.pos);n.uri!==""&&(d.root.namespaces[n.uri].used=!0),d.addVarRef(n,e.pos)})}),this.visitChildren(e),m(),!0}},this.visit=function(e){var t=e.name,n=!1;typeof this[t]=="function"&&(n=this[t](e)===!0),n||this.visitChildren(e)},this.visitChildren=function(e,t){for(var n=0;n<e.children.length;n++){var r=e.children[n];t!==undefined&&typeof t[r.name]=="function"?t[r.name](r):this.visit(r)}},this.visit(n),Object.keys(t.variables).forEach(function(e){!t.varRefs[e]&&(t.variables[e].annotations["http://www.w3.org/2005/xpath-functions#private"]||t.moduleNamespace==="")&&t.variables[e].pos&&h("W03",'Unused variable "'+t.variables[e].qname.name+'"',t.variables[e].pos)}),Object.keys(t.namespaces).forEach(function(e){var n=t.namespaces[e];n.used===undefined&&!n.override&&n.type==="module"&&h("W04",'Unused module "'+e+'"',n.pos)})}},{"../tree_ops":"/node_modules/xqlint/lib/tree_ops.js","./errors":"/node_modules/xqlint/lib/compiler/errors.js","./handlers":"/node_modules/xqlint/lib/compiler/handlers.js","./static_context":"/node_modules/xqlint/lib/compiler/static_context.js"}],"/node_modules/xqlint/lib/completion/completer.js":[function(e,t,n){"use strict";function s(e,t,n){n=n||i;var r=[];for(var s=t-1;s>=0;s--){if(!n.test(e[s]))break;r.push(e[s])}return r.reverse().join("")}function o(e,t){var n=0,r=e.length-1,i=Math.floor((r+n)/2);while(r>n&&i>=0&&e[i].indexOf(t)!==0)t<e[i]?r=i-1:t>e[i]&&(n=i+1),i=Math.floor((r+n)/2);while(i>0&&e[i-1].indexOf(t)===0)i--;return i>=0?i:0}var r=e("../tree_ops").TreeOps,i=/[a-zA-Z_0-9\$]/,u=/[a-zA-Z_0-9\/\.:\-#]/,a="-._A-Za-z0-9:\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0300-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd",f="["+a+"]",l="["+a+"\\$]",c=new RegExp(f),h=new RegExp(l),p={LetBinding:"Let binding",Param:"Function parameter",QuantifiedExpr:"Quantified expression binding",VarDeclStatement:"Local variable",ForBinding:"For binding",TumblingWindowClause:"Tumbl