/*******************************************************************************
 * @license
 * 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
 ******************************************************************************/

/*******************************************************************************
 * @license
 * Copyright (c) 2011, 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
 *******************************************************************************/

/*******************************************************************************
 * @license
 * 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
 *******************************************************************************/

/*******************************************************************************
 * @license
 * 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
 *******************************************************************************/

/*******************************************************************************
 * @license
 * 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
 *******************************************************************************/

/*******************************************************************************
 * @license
 * 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
 ******************************************************************************/

/*******************************************************************************
 * @license
 * 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) 2011, 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

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