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