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