/*

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2011, 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2013 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2013 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation
*/
(function(e,f){"function"===typeof define&&define.amd?define("orion/Deferred",f):"object"===typeof exports?module.exports=f():(e.orion=e.orion||{},e.orion.Deferred=f())})(this,function(){function e(){for(var b;b=d.shift();)b();a=!1}function f(b){d.push(b);a||(a=!0,c())}function n(a){return function(c){a(c)}}function l(){function a(){for(var b;b=p.shift();){var c=b.deferred,g="fulfilled"===h?"resolve":"reject";b=b[g];if("function"===typeof b)try{var k=b(e),d=k&&("object"===typeof k||"function"===typeof k)&&
k.then;if("function"===typeof d)if(k===c.promise)c.reject(new TypeError);else{var m=k.cancel;"function"===typeof m?c._parentCancel=m.bind(k):delete c._parentCancel;d.call(k,n(c.resolve),n(c.reject),n(c.progress))}else c.resolve(k)}catch(f){c.reject(f)}else c[g](e)}}function c(g){delete m._parentCancel;h="rejected";e=g;p.length&&f(a)}function k(d){function n(a){return function(b){(!h||"assumed"===h)&&a(b)}}delete m._parentCancel;try{var t=d&&("object"===typeof d||"function"===typeof d)&&d.then;if("function"===
typeof t)if(d===m)c(new TypeError);else{h="assumed";var w=d&&d.cancel;if("function"!==typeof w){var v=new l;d=v.promise;try{t(v.resolve,v.reject,v.progress)}catch(y){v.reject(y)}w=d.cancel;t=d.then}e=d;t.call(d,n(k),n(c));m._parentCancel=w.bind(d)}else h="fulfilled",e=d,p.length&&f(a)}catch(u){n(c)(u)}}function d(){var a=m._parentCancel;a?(delete m._parentCancel,a()):h||(a=Error("Cancel"),a.name="Cancel",c(a))}var e,h,p=[],m=this;this.resolve=function(a){h||k(a);return m};this.reject=function(a){h||
c(a);return m};this.progress=function(a){h||p.forEach(function(b){if(b.progress)try{b.progress(a)}catch(c){}});return m.promise};this.cancel=function(){m._parentCancel?setTimeout(d,0):d();return m};this.then=function(c,g,k){var d=new l;d._parentCancel=m.promise.cancel;p.push({resolve:c,reject:g,progress:k,deferred:d});("fulfilled"===h||"rejected"===h)&&f(a);return d.promise};this.promise={then:m.then,cancel:m.cancel}}var d=[],a=!1,c=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var a=
process.nextTick;return function(){a(e)}}if("function"===typeof MutationObserver){var c=document.createElement("div");(new MutationObserver(e)).observe(c,{attributes:!0});return function(){c.setAttribute("class","_tick")}}return function(){setTimeout(e,0)}}();l.all=function(a,c){function k(a,b){f||(h[a]=b,0===--e&&m.resolve(h))}function d(a,b){if(!f){if(c)try{k(a,c(b));return}catch(e){b=e}m.reject(b)}}var e=a.length,h=[],f=!1,m=new l;m.then(void 0,function(){f=!0;a.forEach(function(a){a.cancel&&a.cancel()})});
0===e?m.resolve(h):a.forEach(function(a,b){a.then(k.bind(void 0,b),d.bind(void 0,b))});return m.promise};l.when=function(a,c,d,e){var f;a&&"function"===typeof a.then||(f=new l,f.resolve(a),a=f.promise);return a.then(c,d,e)};return l});
(function(e,f){"function"===typeof define&&define.amd?define("orion/plugin",["orion/Deferred"],f):"object"===typeof exports?module.exports=f(require("orion/Deferred")):(e.orion=e.orion||{},e.orion.PluginProvider=f(e.orion.Deferred))})(this,function(e){function f(e,f){this.__objectId=e;this.__methods=f}return function(n){function l(a){p&&("undefined"===typeof ArrayBuffer&&(a=JSON.stringify(a)),p===self?p.postMessage(a):p.postMessage(a,"*"))}function d(){var a=[];Object.keys(y).forEach(function(b){var c=
y[b];a.push({serviceId:b,names:c.names,methods:c.methods,properties:c.properties})});return{headers:s||{},services:a}}function a(a,b){if(b&&b instanceof XMLHttpRequest){var c,d;try{c=b.status,d=b.statusText}catch(q){c=0,d=""}return{status:c||0,statusText:d}}return b}function c(b){var c=b?JSON.parse(JSON.stringify(b,a)):b;b instanceof Error&&(c.__isError=!0,c.message=c.message||b.message,c.name=c.name||b.name);return c}function b(a){if(!p)return(new e).reject(Error("plugin not connected"));a.id=String(m++);
var b=new e;w[a.id]=b;b.then(null,function(b){h&&(b instanceof Error&&"Cancel"===b.name)&&u({requestId:a.id,method:"cancel",params:b.message?[b.message]:[]})});var c=Object.prototype.toString;a.params.forEach(function(d,q){if("[object Object]"===c.call(d)&&!(d instanceof f)){var k,g;for(k in d)"[object Function]"===c.call(d[k])&&(g=g||[],g.push(k));if(g){var e=B++;v[e]=d;k=function(){delete v[e]};b.then(k,k);a.params[q]=new f(e,g)}}});u(a);return b.promise}function g(a,b){a||0===a?u({id:a,result:null,
error:b}):console.log(b)}function k(a,d,k,g){g.forEach(function(a,q){if(a&&"undefined"!==typeof a.__objectId){var c={};a.__methods.forEach(function(q){c[q]=function(){return b({objectId:a.__objectId,method:q,params:Array.prototype.slice.call(arguments)})}});g[q]=c}});var q=void 0===typeof a?null:{id:a,result:null,error:null};try{var x=k.apply(d,g);q&&(x&&"function"===typeof x.then?(r[a]=x,x.then(function(b){delete r[a];q.result=b;u(q)},function(b){r[a]&&(delete r[a],q.error=c(b),u(q))},function(){u({responseId:a,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(q.result=x,u(q)))}catch(e){q&&(q.error=c(e),u(q))}}function t(a){if(!(a.source!==p&&"undefined"!==typeof window)){a="string"!==typeof a.data?a.data:JSON.parse(a.data);try{if(a.method){var b=a.method,c=a.params||[];if("serviceId"in a){var d=y[a.serviceId];d||g(a.id,"service not found");d=d.implementation;b in d?k(a.id,d,d[b],c):g(a.id,"method not found")}else if("objectId"in a){var q=v[a.objectId];q||g(a.id,"object not found");!b in
q?k(a.id,q,q[b],c):g(a.id,"method not found")}else if("requestId"in a){var x=r[a.requestId];x&&("cancel"===b&&x.cancel)&&x.cancel.apply(x,c)}else if("responseId"in a){var e=w[a.responseId];e&&("progress"===b&&e.progress)&&e.progress.apply(e,c)}else throw Error("Bad method: "+a.method);}else{var m=w[String(a.id)];delete w[String(a.id)];a.error?m.reject(a.error):m.resolve(a.result)}}catch(f){console.log("Plugin._messageHandler "+f)}}}var s=n,h=!1,p=null,m=0,B=0,z=0,r={},w={},v={},y={},u=l;this.updateHeaders=
function(a){if(h)throw Error("Cannot update headers. Plugin Provider is connected");s=a};this.registerServiceProvider=this.registerService=function(a,b,c){if(h)throw Error("Cannot register service. Plugin Provider is connected");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var d=null,q=[];for(d in b)"function"===typeof b[d]&&q.push(d);y[z++]={names:a,methods:q,implementation:b,properties:c||{},listeners:{}}};this.connect=function(a,b){if(!h){if("undefined"===typeof window)p=self;else if(window!==
window.parent)p=window.parent;else if(null!==window.opener)p=window.opener;else{b&&b("No valid plugin target");return}addEventListener("message",t,!1);var c={method:"plugin",params:[d()]};l(c);h=!0}a&&a()};this.disconnect=function(){h&&(removeEventListener("message",t),p=null,h=!1)}}});
define("orion/xhr",["orion/Deferred"],function(e){function f(e,f,d,a){var c="undefined"!==typeof d.response?d.response:d.responseText,b;try{b=d.status}catch(g){b=0}e={args:f,response:c,responseText:"string"===typeof c?c:null,status:b,url:e,xhr:d};"undefined"!==typeof a&&(e.error=a);return e}return function(n,l,d){d=d||{};var a=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,c=new e,b=d.headers||{},g=d.log||!1,k;"undefined"===typeof b["X-Requested-With"]&&(b["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof d.data&&("POST"===n||"PUT"===n))k=d.data;var t=!1,s=!1;c.promise.then(void 0,function(b){t=!0;!s&&(b instanceof Error&&"Cancel"===b.name)&&a.abort()});a.onabort=function(){s=!0;if(!t){var a=Error("Cancel");a.name="Cancel";c.reject(a)}};a.onload=function(){var b=f(l,d,a);200<=a.status&&400>a.status?c.resolve(b):(c.reject(b),g&&"undefined"!==typeof console&&console.log(Error(a.statusText)))};a.onerror=function(){var b=f(l,d,a);c.reject(b);g&&"undefined"!==typeof console&&console.log(Error(a.statusText))};
a.onprogress=function(b){b.xhr=a;c.progress(b)};try{a.open(n,l,!0);"string"===typeof d.responseType&&(a.responseType=d.responseType);if("number"===typeof d.timeout)if("number"===typeof a.timeout)a.timeout=d.timeout,a.addEventListener("timeout",function(b){c.reject(f(l,d,a,"Timeout exceeded"))});else{var h=setTimeout(function(){c.reject(f(l,d,a,"Timeout exceeded"))},d.timeout);c.promise.then(clearTimeout.bind(null,h),clearTimeout.bind(null,h))}Object.keys(b).forEach(function(c){a.setRequestHeader(c,
b[c])});a.send(k||null)}catch(p){c.reject(f(l,d,a,p))}return c.promise}});
define("orion/Base64",[],function(){var e;try{e=atob("AA\x3d\x3d")===atob("A A \x3d \x3d")}catch(f){e=!1}return{encode:function(e){e=e instanceof Uint8Array?e:new Uint8Array(e);for(var f=[],d=0,a=e.length;d<a;d+=65536)f.push(String.fromCharCode.apply(null,e.subarray(d,Math.min(a,d+65536))));return btoa(f.join(""))},decode:function(f){f=String(void 0!==f?f:"");e||(f=f.replace(/\s/g,""));f=atob(f);for(var l=f.length,d=new Uint8Array(l),a=0;a<l;a++)d[a]=f.charCodeAt(a);return d}}});
(function(e){function f(){Error.apply(this,arguments)}function n(d,a){var c=d||"utf-8";if("utf-8"!==c&&"utf8"!==c&&"unicode-1-1-utf-8"!==c)throw new TypeError("only utf-8 supported");Object.defineProperties(this,{encoding:{value:c,enumerable:!0},_fatal:{value:a&&a.fatal},_saved:{value:[],writable:!0},_checkBOM:{value:!0,writable:!0}})}function l(d){d=d||"utf-8";if("utf-8"!==d&&"utf8"!==d&&"unicode-1-1-utf-8"!==d)throw new TypeError("only utf-8 supported");Object.defineProperties(this,{encoding:{value:d,
enumerable:!0},_saved:{value:null,writable:!0}})}f.prototype=Error();f.prototype.constructor=f;f.prototype.name="EncodingError";n.prototype.decode=function(d,a){function c(){if(this._fatal)throw this._saved.length=h=0,l=m,this._checkBOM=this._checkBOM||!s,new f;n[r++]=65533}d=d instanceof Uint8Array?d:new Uint8Array(d);var b,g,k,e,s=a&&a.stream,h=this._saved.length,p=d.length,m=0,l=0,n=new Uint16Array(p+h),r=0;if(this._checkBOM&&p)if(2<h+p){for(b=h;3>b;b++)this._saved.push(d[m++]);239!==this._saved[0]||
187!==this._saved[1]||191!==this._saved[2]?(m=0,this._saved.length=h):h=this._saved.length-=3;this._checkBOM=!1}else if(s)for(;m<p;)this._saved.push(d[m++]);for(;m<p;){b=0<h?this._saved[0]:d[m++];if(128>b)n[r++]=b;else if(194<=b&&223>=b){if(m===p)break;g=1<h?this._saved[1]:d[m++];if(!(128<=g&&191>=g)){c();continue}n[r++]=(b&31)<<6|g&63}else if(224<=b&&239>=b){if(m===p)break;g=1<h?this._saved[1]:d[m++];if(224===b&&!(160<=g&&191>=g)||237===b&&!(128<=g&&159>=g)||!(128<=g&&191>=g)){c();continue}if(m===
p)break;k=2<h?this._saved[2]:d[m++];if(!(128<=k&&191>=k)){c();continue}n[r++]=(b&15)<<12|(g&63)<<6|k&63}else if(240<=b&&244>=b){if(m===p)break;g=1<h?this._saved[1]:d[m++];if(240===b&&!(144<=g&&191>=g)||244===b&&!(128<=g&&143>=g)||!(128<=g&&191>=g)){c();continue}if(m===p)break;k=2<h?this._saved[2]:d[m++];if(!(128<=k&&191>=k)){c();continue}if(m===p)break;e=d[m++];if(!(128<=e&&191>=e)){c();continue}b=((b&7)<<18|(g&63)<<12|(k&63)<<6|e&63)&65535;n[r++]=b>>10|55296;n[r++]=b&1023|56320}else c();l=m;h&&(this._saved.length=
h=0)}for(;l!==m;)this._saved.push(d[l++]);this._checkBOM=this._checkBOM||!s;if(!s&&0!==this._saved.length)throw new f;p=[];for(b=0;b<r;b+=65536)p.push(String.fromCharCode.apply(null,n.subarray(b,Math.min(r,b+65536))));return p.join("")};l.prototype.encode=function(d,a){d=String(void 0!==d?d:"");for(var c,b,g=a&&a.stream,k=d.length,e=0,l=new Uint8Array(3*(k+(null===this._saved?0:1))),h=0;e<k;)if(null===this._saved?c=d.charCodeAt(e++):(c=this._saved,this._saved=null),128>c)l[h++]=c;else{if(2048>c)l[h++]=
192|c>>6;else{if(55296>c||56319<c)l[h++]=224|c>>12;else{if(e<k)b=d.charCodeAt(e++);else if(g){this._saved=c;break}else throw new f;if(!(56320<=b&&57343>=b))throw new f;c=65536|(c&1023)<<10|b&1023;l[h++]=240|c>>18;l[h++]=128|c>>12&63}l[h++]=128|c>>6&63}l[h++]=128|c&63}if(!g&&null!==this._saved)throw new f;return l.buffer.slice?new Uint8Array(l.buffer.slice(0,h)):l.subarray(0,h)};e.TextDecoder=e.TextDecoder||n;e.TextEncoder=e.TextEncoder||l})("undefined"===typeof global?this||self:global);
define("orion/encoding-shim",function(){});
(function(){function e(a){if("string"!==typeof a)throw new TypeError;}function f(a){return a?a.split("\x26"):[]}function n(a){return 0===a.length?"":a.join("\x26")}function l(a){var b=/([^=]*)(?:=?)(.*)/.exec(a);a=b[1]?decodeURIComponent(b[1]):"";b=b[2]?decodeURIComponent(b[2]):"";return[a,b]}function d(a){var b=encodeURIComponent(a[0]);a[1]&&(b+="\x3d"+encodeURIComponent(a[1]));return b}function a(a,b){var c="",d=[],k=0;return{next:function(){c!==a.query&&(c=a.query,d=f(c));if(k<d.length){var g=
l(d[k++]);switch(b){case "keys":return g[0];case "values":return g[1];case "keys+values":return[g[0],g[1]];default:throw new TypeError;}}throw C;}}}function c(a){Object.defineProperty(this,"_url",{get:function(){return a._url}})}function b(a){return a?/[1-9]\d*$/.exec(a)[0]:""}function g(a){var b=[];a.split("/").forEach(function(a){".."===a?b.pop():"."!==a&&b.push(a)});return b.join("/")}function k(a){return a.replace(/\s/g,function(a){return"%"+a.charCodeAt(0).toString(16)})}function t(a,c){if("string"!==
typeof a)throw new TypeError;a=k(a);var d=m.exec(a);if(!d)return null;var e={};e.scheme=d[1]||"";if(e.scheme&&!z.test(e.scheme))return null;var f=d[2];if(f&&(f=B.exec(f),e.userinfo=f[1],e.host=f[2],e.port=f[3],e.port&&!r.test(e.port)))return null;e.path=d[3];e.query=d[4];e.fragment=d[5];!e.scheme&&c&&(e.scheme=c.scheme,!e.host&&c.host&&(e.userinfo=c.userinfo,e.host=c.host,e.port=c.port,e.pathRelative=!0));e.pathRelative&&(e.path?"/"!==e.path[0]&&(d=/^(.*\/)[^\/]*$/.exec(c.path)[1]||"/",e.path=d+e.path):
e.path=c.path);e.scheme&&(e.scheme=e.scheme.toLowerCase());e.port&&(e.port=b(e.port));e.host&&e.path&&(e.path=g(e.path));return e}function s(a,b){var d;if(b){b=b.href||b;d=t(b);if(!d||!d.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:d})}d=t(a,d);if(!d)throw new SyntaxError;Object.defineProperty(this,"_input",{value:a,writable:!0});Object.defineProperty(this,"_url",{value:d,writable:!0});var e=new c(this);Object.defineProperty(this,"query",{get:function(){return this._url?
e:null},enumerable:!0})}try{var h;if("function"===typeof window.URL&&0!==window.URL.length&&"http:"===(h=new window.URL("http://www.w3.org?q")).protocol&&h.query)return}catch(p){}var m=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,B=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,z=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,r=/^\d*$/,w=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,v=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,y=/^([^?#\s]*)$/,u=/^([^\s]*)$/,D=/^\S*$/,A=/([^:]*):?(.*)/,C="undefined"!==
typeof StopIteration?StopIteration:Error("Stop Iteration"),E={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(c.prototype,{get:{value:function(a){e(a);var b;f(this._url.query).some(function(c){c=l(c);if(c[0]===a)return b=c[1],!0});return b},enumerable:!0},set:{value:function(a,b){e(a);e(b);var c=f(this._url.query);c.some(function(e,k){var g=l(e);if(g[0]===a)return g[1]=b,c[k]=d(g),!0})||c.push(d([a,b]));this._url.query=n(c)},enumerable:!0},has:{value:function(a){e(a);
return f(this._url.query).some(function(b){if(l(b)[0]===a)return!0})},enumerable:!0},"delete":{value:function(a){e(a);var b=f(this._url.query),c=b.filter(function(b){return l(b)[0]!==a});return c.length!==b.length?(this._url.query=n(c),!0):!1},enumerable:!0},clear:{value:function(){this._url.query=""},enumerable:!0},forEach:{value:function(b,c){if("function"!==typeof b)throw new TypeError;var d=a(this._url,"keys+values");try{for(;;){var e=d.next();b.call(c,e[1],e[0],this)}}catch(g){if(g!==C)throw g;
}},enumerable:!0},keys:{value:function(){return a(this._url,"keys")},enumerable:!0},values:{value:function(){return a(this._url,"values")},enumerable:!0},items:{value:function(){return a(this._url,"keys+values")}},size:{get:function(){return f(this._url.query).length},enumerable:!0},getAll:{value:function(a){e(a);var b=[];f(this._url.query).forEach(function(c){c=l(c);c[0]===a&&b.push(c[1])});return b},enumerable:!0},append:{value:function(a,b){e(a);e(b);var c=f(this._url.query);c.push(d([a,b]));this._url.query=
n(c)},enumerable:!0}});Object.defineProperties(s.prototype,{href:{get:function(){var a;if(this._url){a=this._url;var b=a.scheme?a.scheme+":":"";a.host&&(b+="//",a.userinfo&&(b+=a.userinfo+"@"),b+=a.host,a.port&&(b+=":"+a.port));b+=a.path;a.query&&(b+="?"+a.query);a.fragment&&(b+="#"+a.fragment);a=b}else a=this._input;return a},set:function(a){e(a);this._input=a;this._url=t(this._input,this._baseURL)},enumerable:!0},origin:{get:function(){return this._url&&this._url.host?this.protocol+"//"+this.host:
""},enumerable:!0},protocol:{get:function(){return this._url?this._url.scheme+":":":"},set:function(a){e(a);if(this._url&&(a=":"===a.slice(-1)?a.substring(0,a.length-1):a,""===a||z.test(a)))this._url.scheme=a.toLowerCase()},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(a){e(a);this._url&&(this._url.userinfo=a)}},username:{get:function(){if(!this._url)return"";var a=A.exec(this._userinfo);return decodeURIComponent(a[1]||"")},set:function(a){e(a);if(this._url){var b=
A.exec(this._userinfo);a=[encodeURIComponent(a||"")];b[2]&&a.push(b[2]);this._userinfo=a.join(":")}},enumerable:!0},password:{get:function(){if(!this._url)return"";var a=A.exec(this._userinfo);return decodeURIComponent(a[2]||"")},set:function(a){e(a);if(this._url){var b=[A.exec(this._userinfo)[1]||""];a&&b.push(encodeURIComponent(a));this._userinfo=b.join(":")}},enumerable:!0},host:{get:function(){var a="";this._url&&this._url.host&&(a+=this._url.host,this._url.port&&(a+=":"+this._url.port));return a},
set:function(a){e(a);if(this._url&&(a=v.exec(a)))this._url.host=a[1],this._url.port=b(a[2])},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(a){e(a);this._url&&w.exec(a)&&(this._url.host=a)},enumerable:!0},port:{get:function(){var a=this._url?this._url.port||"":"";a&&a===E[this.protocol]&&(a="");return a},set:function(a){e(a);this._url&&r.exec(a)&&(this._url.port=b(a))},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(a){e(a);
this._url&&y.exec(a)&&(this._url.host&&(a&&"/"!==a[0])&&(a="/"+a),this._url.path=a?g(a):"")},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(a){e(a);this._url&&(a&&"?"===a[0]&&(a=a.substring(1)),u.exec(a)&&(this._url.query=a))},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(a){e(a);this._url&&(a&&"#"===a[0]&&(a=a.substring(1)),D.exec(a)&&(this._url.fragment=a))},enumerable:!0}});
if((h=window.URL||window.webkitURL)&&h.createObjectURL)Object.defineProperty(s,"createObjectURL",{value:h.createObjectURL.bind(h),enumerable:!1}),Object.defineProperty(s,"revokeObjectURL",{value:h.revokeObjectURL.bind(h),enumerable:!1});window.URL=s})();define("orion/URL-shim",function(){});
define("plugins/filePlugin/GitHubFileImpl",["orion/Deferred","orion/xhr","orion/Base64","orion/encoding-shim","orion/URL-shim"],function(e,f,n){function l(a,c){this._originalRepoURL=a;var b=a.match(/https\:\/\/github\.com(?:\:443)?\/([^/]+)\/([^/]+).git$/);if(!b)throw"Bad Github repository url "+a;this._repoURL=new URL("https://api.github.com/repos/"+b[1]+"/"+b[2]);this._commitURLBase="https://github.com/"+b[1]+"/"+b[2]+"/commit/";this._contentsPath=this._repoURL.pathname+"/contents";this._headers=
{Accept:"application/vnd.github.v3+json"};c?(this._headers.Authorization="token "+c,d=3):d=2}var d=1;l.prototype={_getBranchName:function(a){a=(new URL(a)).pathname;return 0===a.indexOf(this._contentsPath)&&(a=a.substring(this._contentsPath.length).match(/\!([^\/]+)(.*)/))&&a[1]?a[1]:"master"},_refPathToQuery:function(a){var c=new URL(a),b=c.pathname;if(0===b.indexOf(this._contentsPath)&&(b=b.substring(this._contentsPath.length).match(/\!([^\/]+)(.*)/)))c.query.set("ref",decodeURIComponent(b[1])),
c.pathname=this._contentsPath+b[2],a=c.href;return a},_refQueryToPath:function(a){var c=new URL(a),b=c.pathname,d=c.query.get("ref")||"master";d&&0===b.indexOf(this._contentsPath)&&(a=b.substring(this._contentsPath.length),c.query.delete("ref"),c.pathname=this._contentsPath+"!"+encodeURIComponent(d)+a,a=c.href);return a},_handleError:function(a,c){var b="Unknown";if("Cancel"===a.name)return(new e).reject(a);b=a.status&&404===a.status?c?"This is a private GitHub project. Authorized users can view the source on the [GitHub repository page]("+
this._originalRepoURL+").":"Bad URL("+(a.url?a.url:"")+").":a.status&&403===a.status?"GitHub is currently limiting our ability to display repository contents. Wait a while and then refresh the browser to try again or go to the [GitHub repository page]("+this._originalRepoURL+").":"Unable to display repository contents at this time. Refresh the browser to try again.";a.responseText=JSON.stringify({Severity:"Warning",Message:b});return(new e).reject(a)},_getBranches:function(){var a=this;return f("GET",
this._repoURL.href+"/branches?per_page\x3d1000",{headers:this._headers,timeout:15E3}).then(function(c){return JSON.parse(c.response).map(function(b){var c=a._repoURL.href+"/contents!"+encodeURIComponent(b.name);return{Attributes:{Archive:!1,Hidden:!1,ReadOnly:!0,SymLink:!1},Location:c,Name:b.name,Length:0,LocalTimeStamp:0,Directory:!0,ChildrenLocation:c,Sha:b.commit?b.commit.sha:null}})},function(c){return a._handleError(c,!0)})},_getChildren:function(a){a=this._refPathToQuery(a);var c=this;return f("GET",
a,{headers:this._headers,timeout:15E3}).then(function(a){return JSON.parse(a.response).map(function(a){var b=c._refQueryToPath(a.url),d={Attributes:{Archive:!1,Hidden:!1,ReadOnly:!0,SymLink:!1},Location:b,Name:a.name,Length:a.size,LocalTimeStamp:0,Directory:!1,Sha:a.sha,CommitPath:a.path};"dir"===a.type&&(d.Directory=!0,d.ChildrenLocation=b);return d})},function(a){return c._handleError(a)})},_getParents:function(a){if(a===this._repoURL.href)return null;a=new URL(a);var c=[],b=a.pathname.substring(this._contentsPath.length).split("/");
b.pop();if(0===b.length)return c;var d=b.shift();a.pathname=this._contentsPath+d;c.push({Name:decodeURIComponent(d.substring(1)),Location:a.href,ChildrenLocation:a.href});for(d=0;d<b.length;++d){var e=b[d],f=decodeURIComponent(b[d]);a.pathname+="/"+e;c.push({Name:f,Location:a.href,ChildrenLocation:a.href})}return c.reverse()},_readGitBlob:function(a,c){var b=this;return a&&a.Sha&&!a.Directory&&(!a.Length||"number"===typeof a.Length&&1048576<=a.Length)?f("GET",b._repoURL.href+"/git/blobs/"+a.Sha,{headers:this._headers,
timeout:15E3}).then(function(a){return JSON.parse(a.response)},function(a){return b._handleError(a)}):c?b._handleError(c):a},_retryBlob:function(a,c){var b=this;return this.read(a,!0).then(function(a){return b._readGitBlob(a,c).then(function(a){if(a.content&&a.size)return n.decode(a.content);b._handleError(c)})})},_getSHAObject:function(a){var c=this._getParents(a);return c?0===c.length?this._getBranches().then(function(b){var c;b.some(function(b){if(b.Location===a)return c=b,!0});return c}):this.read(a,
!0).then(function(a){return a}):(new e).resolve()},_injectCommitInfo:function(a,c,b){var d=this;return f("GET",d._repoURL.href+"/commits?sha\x3d"+(b?c:c+"\x26path\x3d"+a.CommitPath)+"\x26per_page\x3d1",{headers:this._headers,timeout:15E3}).then(function(b){b=JSON.parse(b.response);0<b.length&&(b[0].commit&&b[0].commit.author&&b[0].commit.author.date)&&(a.LocalTimeStamp=b[0].commit.author.date,a.LastCommit={},a.LastCommit.Author={},a.LastCommit.Author.Date=b[0].commit.author.date,a.LastCommit.Author.Name=
b[0].commit.author.name?b[0].commit.author.name:"",a.LastCommit.Author.Email=b[0].commit.author.email?b[0].commit.author.email:"",b[0].commit.committer&&(a.LastCommit.Committer={},a.LastCommit.Committer.Date=b[0].commit.committer.date?b[0].commit.committer.date:"",a.LastCommit.Committer.Name=b[0].commit.committer.name?b[0].commit.committer.name:"",a.LastCommit.Committer.Email=b[0].commit.committer.email?b[0].commit.committer.email:""),a.LastCommit.Message=b[0].commit.message?b[0].commit.message:"",
a.LastCommit.URL=b[0].sha?d._commitURLBase+b[0].sha:null,b[0].author&&b[0].author.gravatar_id?a.LastCommit.AvatarURL="https://www.gravatar.com/avatar/"+b[0].author.gravatar_id+"?d\x3dmm":b[0].author&&b[0].author.avatar_url&&(a.LastCommit.AvatarURL=b[0].author.avatar_url));return a},function(a){return d._handleError(a)})},_refineFetchedChildren:function(a,c){var b=this,g=[],k=[];if(2<d){var l=this._getBranchName(a);c.forEach(function(a){k.push(b._injectCommitInfo(a,l));!a.Directory&&!a.Length&&g.push(a)})}return e.all(k).then(function(){return 0<
g.length?b._getSHAObject(a).then(function(a){return a&&a.Sha?f("GET",b._repoURL.href+"/git/trees/"+a.Sha,{headers:this._headers,timeout:15E3}).then(function(a){var b=JSON.parse(a.response);b&&b.tree&&g.forEach(function(a){b.tree.forEach(function(b){b.sha===a.Sha&&(a.Length=b.size)})});return c},function(a){return b._handleError(a)}):c}):c})},fetchChildren:function(a){var c=this;return a===this._repoURL.href?this._getBranches():this._getChildren(a).then(function(b){return c._refineFetchedChildren(a,
b)})},loadWorkspaces:function(){return this.loadWorkspace(this._repoURL)},loadWorkspace:function(a){var c=this;return this.fetchChildren(a).then(function(b){b={Attributes:{Archive:!1,Hidden:!1,ReadOnly:!0,SymLink:!1},Location:a,Name:null,Length:0,LocalTimeStamp:0,Directory:!0,ChildrenLocation:a,Children:b};if(a===c._repoURL.href)b.Name="repo_root";else{var d=(new URL(a)).pathname.substring(c.contentsPath.length+1);b.Name=decodeURIComponent(d.split("/").pop());b.Parents=c._getParents(a)}return b},
function(a){return c._handleError(a,!0)})},createProject:function(a,c,b,d){throw"Not supported";},createFolder:function(a,c){throw"Not supported";},createFile:function(a,c){throw"Not supported";},deleteFile:function(a){throw"Not supported";},moveFile:function(a,c,b){throw"Not supported";},copyFile:function(a,c,b){throw"Not supported";},read:function(a,c){if(c){var b=this,e=this._getParents(a);return null===e?{Attributes:{Archive:!1,Hidden:!1,ReadOnly:!0,SymLink:!1},Name:null===e?"":decodeURIComponent((new URL(a)).pathname.substring(this._contentsPath.length+
1)),Location:a,Length:0,LocalTimeStamp:0,Parents:e,Directory:!0,ChildrenLocation:a}:0===e.length?b._getSHAObject(a).then(function(a){a.Parents=e;return a&&a.Sha&&0<d?b._injectCommitInfo(a,a.Sha,!0).then(function(){return a}):a}):this._getChildren(e[0].Location).then(function(c){var e;c.some(function(c){if(c.Location===a)return e=c,e.Parents=b._getParents(a),!0});return e?1<d?b._injectCommitInfo(e,b._getBranchName(e.Location)).then(function(){return e}):e:b._handleError({status:404,url:a})})}return this.readBlob(a).then(function(a){return(new TextDecoder).decode(a)})},
write:function(a,c,b){throw"Not supported";},remoteImport:function(a,c){throw"Not supported";},remoteExport:function(a,c){throw"Not supported";},readBlob:function(a){var c=this,b=this._refPathToQuery(a);return f("GET",b,{headers:this._headers,timeout:15E3}).then(function(a){a=JSON.parse(a.response);return a.content&&a.size?n.decode(a.content):f("GET",a.git_url,{headers:this._headers,timeout:15E3}).then(function(a){a=JSON.parse(a.response);return n.decode(a.content)},function(a){return c._handleError(a)})},
function(b){return c._retryBlob(a,b)})},writeBlob:function(a,c,b){throw"Not supported";}};return l.prototype.constructor=l});
define("plugins/GitHubFilePlugin",["orion/plugin","orion/Deferred","plugins/filePlugin/GitHubFileImpl","orion/URL-shim"],function(e,f,n){e=new e({name:"GitHub File Plugin",version:"1.0",description:"GitHub File Plugin"});f=new URL(window.location.href);n=new n(f.query.get("repo"),f.query.get("token"));f=n._repoURL.href;e.registerService("orion.core.file",n,{Name:"GitHub File contents",top:f,pattern:f.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")});e.connect()});
//@ sourceMappingURL=GitHubFilePlugin.js.map