/*

 Copyright (c) 2011, 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). 


 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) 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, 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) 2010, 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) 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) 2010-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) 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) 2012, 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) 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
 RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 Available via the MIT or new BSD license.
 see: http://github.com/requirejs/domReady for details

 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) 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(){function a(){for(var a=navigator.userAgent,k={browser:!1,version:!1},n=[{name:"Chrome/Chromium",regExp:/(?:chrome|crios|chromium)\/(\d+)/i,minVersion:24},{name:"Firefox",regExp:/firefox\/(\d+)/i,minVersion:17},{name:"Microsoft Internet Explorer",regExp:/msie\s(\d+)/i,minVersion:10},{name:"Microsoft Internet Explorer",regExp:/Trident\/(\d+)/i,minVersion:6},{name:"Safari",regExp:/version\/(\d+).*?safari/i,minVersion:6}],e=0;e<n.length;e++){var h=n[e],g=a.match(h.regExp);if(g){k.browser=
!0;k.version=g[1]>=h.minVersion;k.name=h.name;break}}return k}function k(){try{return"localStorage"in window&&null!==window.localStorage}catch(a){return!1}}function m(a){alert(a);throw Error("unsupported browser");}var n=a();if(n.browser)n.version||m("Sorry, your browser version is not supported.\n\nTo use Orion, please upgrade to the latest version of "+n.name+".\n");else if(k()&&!localStorage.skipBrowserCheck)if(confirm("Sorry, your browser is not supported. The latest version of Chrome, Firefox or Safari web browser is recommended.\nContinue anyway?"))localStorage.skipBrowserCheck=
1;else throw"unsupported browser";else k()||m("Sorry, your browser is not supported.\n\nTo use Orion, the latest version of the Chrome, Firefox, or Safari web browser is recommended.\n");return{isSupportedBrowser:a,supportsLocalStorage:k,throwBrowserAlert:m}})();define("orion/browserCompatibility",function(){});
(function(a,k){"function"===typeof define&&define.amd?define("orion/Deferred",k):"object"===typeof exports?module.exports=k():(a.orion=a.orion||{},a.orion.Deferred=k())})(this,function(){function a(){for(var e;e=p.shift();)e();l=!1}function k(e){p.push(e);l||(l=!0,r())}function m(e){return function(h){e(h)}}function n(){function e(){for(var q;q=b.shift();){var g=q.deferred,d="fulfilled"===c?"resolve":"reject";q=q[d];if("function"===typeof q)try{var e=q(f),h=e&&("object"===typeof e||"function"===typeof e)&&
e.then;if("function"===typeof h)if(e===g.promise)g.reject(new TypeError);else{var a=e.cancel;"function"===typeof a?g._parentCancel=a.bind(e):delete g._parentCancel;h.call(e,m(g.resolve),m(g.reject),m(g.progress))}else g.resolve(e)}catch(k){g.reject(k)}else g[d](f)}}function h(g){delete q._parentCancel;c="rejected";f=g;b.length&&k(e)}function g(d){function a(b){return function(g){(!c||"assumed"===c)&&b(g)}}delete q._parentCancel;try{var m=d&&("object"===typeof d||"function"===typeof d)&&d.then;if("function"===
typeof m)if(d===q)h(new TypeError);else{c="assumed";var p=d&&d.cancel;if("function"!==typeof p){var l=new n;d=l.promise;try{m(l.resolve,l.reject,l.progress)}catch(r){l.reject(r)}p=d.cancel;m=d.then}f=d;m.call(d,a(g),a(h));q._parentCancel=p.bind(d)}else c="fulfilled",f=d,b.length&&k(e)}catch(u){a(h)(u)}}function d(){var b=q._parentCancel;b?(delete q._parentCancel,b()):c||(b=Error("Cancel"),b.name="Cancel",h(b))}var f,c,b=[],q=this;this.resolve=function(b){c||g(b);return q};this.reject=function(b){c||
h(b);return q};this.progress=function(g){c||b.forEach(function(b){if(b.progress)try{b.progress(g)}catch(c){}});return q.promise};this.cancel=function(){q._parentCancel?setTimeout(d,0):d();return q};this.then=function(g,f,d){var h=new n;h._parentCancel=q.promise.cancel;b.push({resolve:g,reject:f,progress:d,deferred:h});("fulfilled"===c||"rejected"===c)&&k(e);return h.promise};this.promise={then:q.then,cancel:q.cancel}}var p=[],l=!1,r=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var e=
process.nextTick;return function(){e(a)}}if("function"===typeof MutationObserver){var h=document.createElement("div");(new MutationObserver(a)).observe(h,{attributes:!0});return function(){h.setAttribute("class","_tick")}}return function(){setTimeout(a,0)}}();n.all=function(e,h){function g(g,d){b||(c[g]=d,0===--f&&q.resolve(c))}function d(c,d){if(!b){if(h)try{g(c,h(d));return}catch(f){d=f}q.reject(d)}}var f=e.length,c=[],b=!1,q=new n;q.then(void 0,function(){b=!0;e.forEach(function(b){b.cancel&&b.cancel()})});
0===f?q.resolve(c):e.forEach(function(b,c){b.then(g.bind(void 0,c),d.bind(void 0,c))});return q.promise};n.when=function(e,h,g,d){var f;e&&"function"===typeof e.then||(f=new n,f.resolve(e),e=f.promise);return e.then(h,g,d)};return n});
define("orion/EventTarget",[],function(){function a(){this._namedListeners={}}a.prototype={dispatchEvent:function(a){if(!a.type)throw Error("unspecified type");var m=this._namedListeners[a.type];m&&m.forEach(function(n){try{"function"===typeof n?n(a):n.handleEvent(a)}catch(m){"undefined"!==typeof console&&console.log(m)}});return!a.defaultPrevented},addEventListener:function(a,m){if("function"===typeof m||m.handleEvent)this._namedListeners[a]=this._namedListeners[a]||[],this._namedListeners[a].push(m)},
removeEventListener:function(a,m){var n=this._namedListeners[a];if(n)for(var p=0;p<n.length;p++)if(n[p]===m){1===n.length?delete this._namedListeners[a]:n.splice(p,1);break}}};a.prototype.constructor=a;a.attach=function(k){var m=new a;k.dispatchEvent=m.dispatchEvent.bind(m);k.addEventListener=m.addEventListener.bind(m);k.removeEventListener=m.removeEventListener.bind(m)};return a});
define("orion/serviceregistry",["orion/Deferred","orion/EventTarget"],function(a,k){function m(e,a,g){this._properties=g||{};this._properties["service.id"]=e;this._properties.objectClass=a;this._properties["service.names"]=a}function n(e,a,g){this._serviceId=e;this._serviceReference=a;this._internalRegistry=g}function p(e,h){function g(g){return function(){var c;try{if(!h())throw Error("Service was unregistered");var b=e[g].apply(e,Array.prototype.slice.call(arguments));if(b&&"function"===typeof b.then)return b;
c=new a;c.resolve(b)}catch(d){c=new a,c.reject(d)}return c.promise}}for(var d in e)"function"===typeof e[d]&&(this[d]=g(d))}function l(e,a){this.type=e;this.serviceReference=a}function r(){this._entries=[];this._namedReferences={};this._serviceEventTarget=new k;var e=this;this._internalRegistry={isRegistered:function(a){return e._entries[a]?!0:!1},unregisterService:function(a){var g=e._entries[a];if(!g)throw Error("Service has already been unregistered: "+a);var d=g.reference;e._serviceEventTarget.dispatchEvent(new l("unregistering",
d));e._entries[a]=null;d.getProperty("objectClass").forEach(function(g){for(var c=e._namedReferences[g],b=0;b<c.length;b++)if(c[b]===d){1===c.length?delete e._namedReferences[g]:c.splice(b,1);break}})},modifyService:function(a){var g=e._entries[a];if(!g)throw Error("Service not found while trying to send modified event: "+a);e._serviceEventTarget.dispatchEvent(new l("modified",g.reference))}}}m.prototype={getPropertyKeys:function(){var e=[],a;for(a in this._properties)this._properties.hasOwnProperty(a)&&
e.push(a);return e},getProperty:function(e){return this._properties[e]}};m.prototype.constructor=m;n.prototype={unregister:function(){this._internalRegistry.unregisterService(this._serviceId)},getReference:function(){if(!this._internalRegistry.isRegistered(this._serviceId))throw Error("Service has already been unregistered: "+this._serviceId);return this._serviceReference},setProperties:function(e){var a=this._serviceReference._properties;this._serviceReference._properties=e||{};e["service.id"]=this._serviceId;
e.objectClass=a.objectClass;e["service.names"]=a["service.names"];this._internalRegistry.modifyService(this._serviceId)}};n.prototype.constructor=n;r.prototype={getService:function(e){var a;if("string"===typeof e)(e=this._namedReferences[e])&&e.some(function(g){a=this._entries[g.getProperty("service.id")].service;return!!a},this);else if(e=this._entries[e.getProperty("service.id")])a=e.service;return a||null},getServiceReferences:function(a){if(a)return this._namedReferences[a]?this._namedReferences[a]:
[];var h=[];this._entries.forEach(function(g){g&&h.push(g.reference)});return h},registerService:function(a,h,g){if("undefined"===typeof h||null===h)throw Error("invalid service");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var d=this._entries.length,f=new m(d,a,g),c=this._namedReferences;a.forEach(function(b){c[b]=c[b]||[];c[b].push(f)});a=new p(h,this._internalRegistry.isRegistered.bind(null,d));this._entries.push({reference:f,service:a});a=this._internalRegistry;this._serviceEventTarget.dispatchEvent(new l("registered",
f));return new n(d,f,a)},addEventListener:function(a,h){this._serviceEventTarget.addEventListener(a,h)},removeEventListener:function(a,h){this._serviceEventTarget.removeEventListener(a,h)}};r.prototype.constructor=r;return{ServiceRegistry:r}});
define("orion/xhr",["orion/Deferred"],function(a){function k(a,k,p,l){var r="undefined"!==typeof p.response?p.response:p.responseText,e;try{e=p.status}catch(h){e=0}a={args:k,response:r,responseText:"string"===typeof r?r:null,status:e,url:a,xhr:p};"undefined"!==typeof l&&(a.error=l);return a}return function(m,n,p){p=p||{};var l=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,r=new a,e=p.headers||{},h=p.log||!1,g;"undefined"===typeof e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof p.data&&("POST"===m||"PUT"===m))g=p.data;var d=!1,f=!1;r.promise.then(void 0,function(b){d=!0;!f&&(b instanceof Error&&"Cancel"===b.name)&&l.abort()});l.onabort=function(){f=!0;if(!d){var b=Error("Cancel");b.name="Cancel";r.reject(b)}};l.onload=function(){var b=k(n,p,l);200<=l.status&&400>l.status?r.resolve(b):(r.reject(b),h&&"undefined"!==typeof console&&console.log(Error(l.statusText)))};l.onerror=function(){var b=k(n,p,l);r.reject(b);h&&"undefined"!==typeof console&&console.log(Error(l.statusText))};
l.onprogress=function(b){b.xhr=l;r.progress(b)};try{l.open(m,n,!0);"string"===typeof p.responseType&&(l.responseType=p.responseType);if("number"===typeof p.timeout)if("number"===typeof l.timeout)l.timeout=p.timeout,l.addEventListener("timeout",function(b){r.reject(k(n,p,l,"Timeout exceeded"))});else{var c=setTimeout(function(){r.reject(k(n,p,l,"Timeout exceeded"))},p.timeout);r.promise.then(clearTimeout.bind(null,c),clearTimeout.bind(null,c))}Object.keys(e).forEach(function(b){l.setRequestHeader(b,
e[b])});l.send(g||null)}catch(b){r.reject(k(n,p,l,b))}return r.promise}});
define("orion/preferences",["require","orion/Deferred","orion/xhr"],function(a,k,m){function n(g,a){this._name=g;this._providers=a;this._flushPending=!1;this._cached=null;this._stores=[];this._pendingDeletes=[];this._dirty=[]}function p(g,a){return{get:function(f,c){if(0===a)return null;var b=localStorage.getItem(g+f);if(null===b)return null;b=JSON.parse(b);return c||-1===a||b._expires&&b._expires>(new Date).getTime()?(delete b._expires,b):null},set:function(f,c){if(0!==a)if(-1!==a&&(c._expires=(new Date).getTime()+
1E3*a),0===Object.keys(c).length)localStorage.removeItem(g+f);else{var b=JSON.stringify(c);localStorage.setItem(g+f,b);delete c._expires}},remove:function(a){localStorage.removeItem(g+a)}}}function l(a){this._currentPromises={};this._cache=new p("/orion/preferences/user",3600);this._service=null;this.available=function(){if(!this._service){var d=a.getServiceReferences("orion.core.preference.provider");0<d.length&&(this._service=a.getService(d[0]))}return!!this._service}}function r(a){this._location=
a;this._currentPromise=null;this._cache=new p("/orion/preferences/default",3600)}function e(){this._cache=new p("/orion/preferences/local",-1)}function h(g,d){this._userProvider=new l(g);this._localProvider=new e;d=d||"defaults.pref";-1===d.indexOf("://")&&(d=a.toUrl(d));this._defaultsProvider=new r(d);this._serviceRegistration=g.registerService("orion.core.preference",this)}n.prototype={_flush:function(){for(var a=[],d=0;d<this._stores.length;++d){var f=this._stores[d];-1!==this._dirty.indexOf(f)&&
a.push(this._providers[d].put(this._name,f));if(this._pendingDeletes[d]&&0<this._pendingDeletes[d].length){for(f=0;f<this._pendingDeletes[d].length;f++)a.push(this._providers[d].remove(this._name,this._pendingDeletes[d][f]));delete this._pendingDeletes[d]}}this._dirty=[];return k.all(a)},_scheduleFlush:function(a){a&&-1===this._dirty.indexOf(a)&&this._dirty.push(a);this._flushPending||(this._flushPending=!0,window.setTimeout(function(){this._flushPending&&(this._flushPending=!1,this._flush())}.bind(this),
0))},_getCached:function(){if(!this._cached){this._cached={};for(var a=0;a<this._stores.length;++a){var d=this._stores[a],f;for(f in d)d.hasOwnProperty(f)&&"undefined"===typeof this._cached[f]&&(this._cached[f]=d[f])}}return this._cached},keys:function(){return Object.keys(this._getCached())},get:function(a){return this._getCached()[a]},put:function(a,d){if(0!==this._stores.length){var f=this._stores[0];f[a]!==d&&(f[a]=d,this._cached=null,this._scheduleFlush(f))}},remove:function(a){for(var d=0;d<
this._stores.length;++d){var f=this._stores[d];if(f.hasOwnProperty(a))return delete f[a],this._pendingDeletes[d]||(this._pendingDeletes[d]=[]),this._pendingDeletes[d].push(a),this._cached=null,this._scheduleFlush(),!0}return!1},clear:function(){for(var a=0;a<this._stores.length;++a)this._stores[a]={},this._scheduleFlush(this._stores[a]);this._cached=null},sync:function(a){if(this._flushPending)return this._flushPending=!1,this._flush();for(var d=this,f=[],c=0;c<this._providers.length;++c)f.push(this._providers[c].get(this._name,
a).then(function(b){return function(a){d._stores[b]=a}}(c)));return k.all(f).then(function(){d._cached=null;d._getCached()})},flush:function(){this._flush()}};l.prototype={get:function(a,d){if(this._currentPromises[a])return this._currentPromises[a];var f=new k,c=null;d?this._cache.remove(a):c=this._cache.get(a);if(null!==c)f.resolve(c);else{this._currentPromises[a]=f;var b=this;this._service.get(a).then(function(c){b._cache.set(a,c);delete b._currentPromises[a];f.resolve(c)},function(c){404===c.status?
(c={},b._cache.set(a,c),delete b._currentPromises[a],f.resolve(c)):(delete b._currentPromises[a],f.resolve(b._cache.get(a,!0)||{}))})}return f},put:function(a,d){this._cache.set(a,d);return this._service.put(a,d)},remove:function(a,d){var f=this._cache.get(a);delete f[d];this._cache.set(a,f);return this._service.remove(a,d)}};r.prototype={get:function(a,d){if(this._currentPromise)return this._currentPromise;var f=new k,c=null;d?this._cache.remove(a):c=this._cache.get(a);if(null!==c)f.resolve(c);else{this._currentPromise=
f;var b=this;m("GET",this._location,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(c){c=JSON.parse(c.response);b._cache.set(a,c[a]||{});b._currentPromise=null;f.resolve(c[a]||{})},function(c){401===c.xhr.status||404===c.xhr.status?(b._cache.set(a,{}),b._currentPromise=null,f.resolve({})):(b._currentPromise=null,c=b._cache.get(a,!0),null!==c?f.resolve(c[a]||{}):f.resolve({}))})}return f},put:function(a,d){var f=new k;f.resolve();return f},remove:function(a,d){var f=this._cache.get(a);
delete f[d];this.put(a,f)}};e.prototype={get:function(a){var d=new k;a=this._cache.get(a);null!==a?d.resolve(a):d.resolve({});return d},put:function(a,d){var f=new k;this._cache.set(a,d);f.resolve();return f},remove:function(a,d){var f=this._cache.get(a);delete f[d];this.put(a,f)}};h.DEFAULT_SCOPE=1;h.LOCAL_SCOPE=2;h.USER_SCOPE=4;h.prototype={listenForChangedSettings:function(a,d,f){if(!d||"number"!==typeof d||7<d||1>d)f=d,d=h.DEFAULT_SCOPE|h.LOCAL_SCOPE|h.USER_SCOPE;window.addEventListener("storage",
f,!1);return 0!==(h.USER_SCOPE&d)?"/orion/preferences/user"+a:0!==(h.LOCAL_SCOPE&d)?"/orion/preferences/local"+a:"/orion/preferences/default"+a},getPreferences:function(a,d){if(!d||"number"!==typeof d||7<d||1>d)d=h.DEFAULT_SCOPE|h.LOCAL_SCOPE|h.USER_SCOPE;var f=[];h.USER_SCOPE&d&&this._userProvider.available()&&f.push(this._userProvider);h.LOCAL_SCOPE&d&&f.push(this._localProvider);h.DEFAULT_SCOPE&d&&f.push(this._defaultsProvider);var c=new n(a,f);return c.sync().then(function(){return c})},getSetting:function(a,
d,f){for(var c,b=0;b<a.length;b++)if(a[b].label===d)for(var e=0;e<a[b].data.length;e++)if(a[b].data[e].label===f){c=a[b].data[e].value;break}return c}};return{PreferencesService:h}});
(function(){function a(a){if("string"!==typeof a)throw new TypeError;}function k(a){return a?a.split("\x26"):[]}function m(a){return 0===a.length?"":a.join("\x26")}function n(a){var b=/([^=]*)(?:=?)(.*)/.exec(a);a=b[1]?decodeURIComponent(b[1]):"";b=b[2]?decodeURIComponent(b[2]):"";return[a,b]}function p(a){var b=encodeURIComponent(a[0]);a[1]&&(b+="\x3d"+encodeURIComponent(a[1]));return b}function l(a,b){var c="",d=[],f=0;return{next:function(){c!==a.query&&(c=a.query,d=k(c));if(f<d.length){var e=
n(d[f++]);switch(b){case "keys":return e[0];case "values":return e[1];case "keys+values":return[e[0],e[1]];default:throw new TypeError;}}throw G;}}}function r(a){Object.defineProperty(this,"_url",{get:function(){return a._url}})}function e(a){return a?/[1-9]\d*$/.exec(a)[0]:""}function h(a){var b=[];a.split("/").forEach(function(a){".."===a?b.pop():"."!==a&&b.push(a)});return b.join("/")}function g(a){return a.replace(/\s/g,function(a){return"%"+a.charCodeAt(0).toString(16)})}function d(a,b){if("string"!==
typeof a)throw new TypeError;a=g(a);var c=q.exec(a);if(!c)return null;var d={};d.scheme=c[1]||"";if(d.scheme&&!M.test(d.scheme))return null;var f=c[2];if(f&&(f=P.exec(f),d.userinfo=f[1],d.host=f[2],d.port=f[3],d.port&&!N.test(d.port)))return null;d.path=c[3];d.query=c[4];d.fragment=c[5];!d.scheme&&b&&(d.scheme=b.scheme,!d.host&&b.host&&(d.userinfo=b.userinfo,d.host=b.host,d.port=b.port,d.pathRelative=!0));d.pathRelative&&(d.path?"/"!==d.path[0]&&(c=/^(.*\/)[^\/]*$/.exec(b.path)[1]||"/",d.path=c+d.path):
d.path=b.path);d.scheme&&(d.scheme=d.scheme.toLowerCase());d.port&&(d.port=e(d.port));d.host&&d.path&&(d.path=h(d.path));return d}function f(a,b){var c;if(b){b=b.href||b;c=d(b);if(!c||!c.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:c})}c=d(a,c);if(!c)throw new SyntaxError;Object.defineProperty(this,"_input",{value:a,writable:!0});Object.defineProperty(this,"_url",{value:c,writable:!0});var f=new r(this);Object.defineProperty(this,"query",{get:function(){return this._url?
f:null},enumerable:!0})}try{var c;if("function"===typeof window.URL&&0!==window.URL.length&&"http:"===(c=new window.URL("http://www.w3.org?q")).protocol&&c.query)return}catch(b){}var q=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,P=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,M=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,N=/^\d*$/,Q=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,B=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,A=/^([^?#\s]*)$/,u=/^([^\s]*)$/,z=/^\S*$/,t=/([^:]*):?(.*)/,G="undefined"!==
typeof StopIteration?StopIteration:Error("Stop Iteration"),F={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(r.prototype,{get:{value:function(b){a(b);var c;k(this._url.query).some(function(a){a=n(a);if(a[0]===b)return c=a[1],!0});return c},enumerable:!0},set:{value:function(b,c){a(b);a(c);var d=k(this._url.query);d.some(function(a,f){var e=n(a);if(e[0]===b)return e[1]=c,d[f]=p(e),!0})||d.push(p([b,c]));this._url.query=m(d)},enumerable:!0},has:{value:function(b){a(b);
return k(this._url.query).some(function(a){if(n(a)[0]===b)return!0})},enumerable:!0},"delete":{value:function(b){a(b);var c=k(this._url.query),d=c.filter(function(a){return n(a)[0]!==b});return d.length!==c.length?(this._url.query=m(d),!0):!1},enumerable:!0},clear:{value:function(){this._url.query=""},enumerable:!0},forEach:{value:function(a,b){if("function"!==typeof a)throw new TypeError;var c=l(this._url,"keys+values");try{for(;;){var d=c.next();a.call(b,d[1],d[0],this)}}catch(f){if(f!==G)throw f;
}},enumerable:!0},keys:{value:function(){return l(this._url,"keys")},enumerable:!0},values:{value:function(){return l(this._url,"values")},enumerable:!0},items:{value:function(){return l(this._url,"keys+values")}},size:{get:function(){return k(this._url.query).length},enumerable:!0},getAll:{value:function(b){a(b);var c=[];k(this._url.query).forEach(function(a){a=n(a);a[0]===b&&c.push(a[1])});return c},enumerable:!0},append:{value:function(b,c){a(b);a(c);var d=k(this._url.query);d.push(p([b,c]));this._url.query=
m(d)},enumerable:!0}});Object.defineProperties(f.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(b){a(b);this._input=b;this._url=d(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(b){a(b);if(this._url&&(b=":"===b.slice(-1)?b.substring(0,b.length-1):b,""===b||M.test(b)))this._url.scheme=b.toLowerCase()},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(b){a(b);this._url&&(this._url.userinfo=b)}},username:{get:function(){if(!this._url)return"";var a=t.exec(this._userinfo);return decodeURIComponent(a[1]||"")},set:function(b){a(b);if(this._url){var c=
t.exec(this._userinfo);b=[encodeURIComponent(b||"")];c[2]&&b.push(c[2]);this._userinfo=b.join(":")}},enumerable:!0},password:{get:function(){if(!this._url)return"";var a=t.exec(this._userinfo);return decodeURIComponent(a[2]||"")},set:function(b){a(b);if(this._url){var c=[t.exec(this._userinfo)[1]||""];b&&c.push(encodeURIComponent(b));this._userinfo=c.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(b){a(b);if(this._url&&(b=B.exec(b)))this._url.host=b[1],this._url.port=e(b[2])},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(b){a(b);this._url&&Q.exec(b)&&(this._url.host=b)},enumerable:!0},port:{get:function(){var a=this._url?this._url.port||"":"";a&&a===F[this.protocol]&&(a="");return a},set:function(b){a(b);this._url&&N.exec(b)&&(this._url.port=e(b))},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(b){a(b);
this._url&&A.exec(b)&&(this._url.host&&(b&&"/"!==b[0])&&(b="/"+b),this._url.path=b?h(b):"")},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(b){a(b);this._url&&(b&&"?"===b[0]&&(b=b.substring(1)),u.exec(b)&&(this._url.query=b))},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(b){a(b);this._url&&(b&&"#"===b[0]&&(b=b.substring(1)),z.exec(b)&&(this._url.fragment=b))},enumerable:!0}});
if((c=window.URL||window.webkitURL)&&c.createObjectURL)Object.defineProperty(f,"createObjectURL",{value:c.createObjectURL.bind(c),enumerable:!1}),Object.defineProperty(f,"revokeObjectURL",{value:c.revokeObjectURL.bind(c),enumerable:!1});window.URL=f})();define("orion/URL-shim",function(){});
define("orion/pluginregistry",["orion/Deferred","orion/EventTarget","orion/URL-shim"],function(a,k){function m(a,c){var b=Object.keys(a),d=Object.keys(c);if(b.length!==d.length)return!1;b.sort();d.sort();for(var e=0,g=b.length;e<g;e++){var h=b[e];if(h!==d[e])return!1;var k=a[h],h=c[h];if(k!==h&&JSON.stringify(k)!==JSON.stringify(h))return!1}return!0}function n(a){if(-1===a.indexOf("://"))try{return(new URL(a,location.href)).href}catch(c){}return a}function p(a){var c=null,b={key:function(b){return(c=
c||Object.keys(a))[b]},getItem:function(b){return a[b]},setItem:function(b,d){a[b]=d;c=null},removeItem:function(b){delete a[b];c=null},clear:function(){(c=c||Object.keys(a)).forEach(function(b){delete a[b]}.bind(this));c=null}};Object.defineProperty(b,"length",{get:function(){return(c=c||Object.keys(a)).length}});return b}function l(a,c){if(c&&c instanceof XMLHttpRequest){var b,d;try{b=c.status,d=c.statusText}catch(e){b=0,d=""}return{status:b||0,statusText:d}}return c}function r(a){var c=a?JSON.parse(JSON.stringify(a,
l)):a;a instanceof Error&&(c.__isError=!0,c.message=c.message||a.message,c.name=c.name||a.name);return c}function e(a,c){this.type=a;this.plugin=c}function h(a,c){this.__objectId=a;this.__methods=c}function g(d,c,b){function q(a){w&&b.postMessage(a,w)}function g(c){if(!w)return(new a).reject(Error("plugin not connected"));c.id=String(R++);var d=new a;I[c.id]=d;d.then(null,function(a){"active"===s&&(a instanceof Error&&"Cancel"===a.name)&&q({requestId:c.id,method:"cancel",params:a.message?[a.message]:
[]})});var e=Object.prototype.toString;c.params.forEach(function(a,b){if("[object Object]"===e.call(a)&&!(a instanceof h)){var f,g;for(f in a)"[object Function]"===e.call(a[f])&&(g=g||[],g.push(f));if(g){var q=O++;J[q]=a;f=function(){delete J[q]};d.then(f,f);c.params[b]=new h(q,g)}}});b.postMessage(c,w);return d.promise}function n(a,b){a||0===a?q({id:a,result:null,error:b}):console.log(b)}function l(a,b,c,d){d.forEach(function(a,b){if(a&&"undefined"!==typeof a.__objectId){var c={};a.__methods.forEach(function(b){c[b]=
function(){return g({objectId:a.__objectId,method:b,params:Array.prototype.slice.call(arguments)})}});d[b]=c}});var e=void 0===typeof a?null:{id:a,result:null,error:null};try{var f=c.apply(b,d);e&&(f&&"function"===typeof f.then?(H[a]=f,f.then(function(b){delete H[a];e.result=b;q(e)},function(b){H[a]&&(delete H[a],e.error=r(b),q(e))},function(){q({responseId:a,method:"progress",params:Array.prototype.slice.call(arguments)})})):(e.result=f,q(e)))}catch(h){e&&(e.error=r(h),q(e))}}function p(a){try{if(a.method){var c=
a.method,d=a.params||[];if("serviceId"in a){var e=S[a.serviceId];e||n(a.id,"service not found");c in e?l(a.id,e,e[c],d):n(a.id,"method not found")}else if("objectId"in a){var f=J[a.objectId];f||n(a.id,"object not found");c in f?l(a.id,f,f[c],d):n(a.id,"method not found")}else if("requestId"in a){var g=H[a.requestId];g&&("cancel"===c&&g.cancel)&&g.cancel.apply(g,d)}else if("responseId"in a){var q=I[a.responseId];q&&("progress"===c&&q.progress)&&q.progress.apply(q,d)}else if("plugin"===a.method){w.connected();
var h=a.params[0];K({headers:h.headers,services:h.services}).then(function(){y&&y.resolve(t)})}else if("timeout"===a.method)y&&y.reject(a.error);else throw Error("Bad method: "+a.method);}else{var k=I[String(a.id)];delete I[String(a.id)];if(a.error){var z=b.handleServiceError(t,a.error);k.reject(z)}else k.resolve(a.result)}}catch(m){console.log("Plugin._messageHandler "+m)}}function B(a){var b={};if(a.methods&&(a.methods.forEach(function(c){b[c]=function(){var b={serviceId:a.serviceId,method:c,params:Array.prototype.slice.call(arguments)};
return"active"===s?g(b):t.start({"transient":!0}).then(function(){return g(b)})}}),b.addEventListener&&b.removeEventListener)){var c=new k,d=O++;J[d]={handleEvent:c.dispatchEvent.bind(c)};var e=new h(d,["handleEvent"]),f=b.addEventListener;b.addEventListener=function(a,b){c._namedListeners[a]||f(a,e);c.addEventListener(a,b)};var q=b.removeEventListener;b.removeEventListener=function(a,b){c.removeEventListener(a,b);c._namedListeners[a]||q(a,e)}}return b}function A(a){var b=JSON.parse(JSON.stringify(a.properties));
b.__plugin__=d;a=a.names||a.type||[];Array.isArray(a)||(a=[a]);b.objectClass=a;return b}function u(a){var c=B(a),d=A(a),d=b.registerService(a.names||a.type,c,d);v[a.serviceId]={registration:d,proxy:c}}function z(){b.persist(d,{created:G,headers:F,services:E,autostart:x,lastModified:D})}var t=this;c=c||{};var G=c.created||(new Date).getTime(),F=c.headers||{},E=c.services||[],x=c.autostart,D=c.lastModified||0,s="installed",C,y,w,L,v={},R=0,O=0,H={},I={},J={},S={},K;this._default=!1;this._persist=z;
this._resolve=function(){s="resolved";b.dispatchEvent(new e("resolved",t))};this._getAutostart=function(){return x};this._getCreated=function(){return G};this.getLocation=function(){return d};this.getHeaders=function(){return JSON.parse(JSON.stringify(F))};this.getName=function(){var a=this.getHeaders();return a?a.name||"":null};this.getVersion=function(){var a=this.getHeaders();return a?a.version||"0.0.0":null};this.getLastModified=function(){return D};this.getServiceReferences=function(){var a=
[];Object.keys(v).forEach(function(b){a.push(v[b].registration.getReference())});return a};this.setParent=function(b){return L!==b?(L=b,t.stop({"transient":!0}).then(function(){if("started"===x)return t.start({"transient":!0});if("lazy"===x)return t.start({lazy:!0,"transient":!0})})):(new a).resolve()};this.getState=function(){return s};this.start=function(c){if("uninstalled"===s)return(new a).reject(Error("Plugin is uninstalled"));if(C)return C.promise.then(this.start.bind(this,c));if("active"===
s)return(new a).resolve();if(!c||!c.transient){var g=c&&c.lazy?"lazy":"started";g!==x&&(x=g,z())}g=b.getState();if("starting"!==g&&"active"!==g)return c.transient?(new a).reject(Error("start transient error")):(new a).resolve();if("installed"===s)try{this._resolve()}catch(q){return(new a).reject(q)}"resolved"===s&&E.forEach(function(a){u(a)});if(c&&c.lazy)return"starting"!==s&&(s="starting",b.dispatchEvent(new e("lazy activation",t))),(new a).resolve();var h=new a;C=h;s="starting";b.dispatchEvent(new e("starting",
t));y=new a;w=b.connect(d,p,L);y.then(function(){y=null;s="active";b.dispatchEvent(new e("started",t));C=null;h.resolve()},function(){y=null;s="stopping";b.dispatchEvent(new e("stopping",t));Object.keys(v).forEach(function(a){v[a].registration.unregister();delete v[a]});b.disconnect(w);w=null;s="resolved";C=null;b.dispatchEvent(new e("stopped",t));h.reject(Error("Failed to load plugin: "+d));t._default&&(D=0,z())});return h.promise};this.stop=function(c){if("uninstalled"===s)return(new a).reject(Error("Plugin is uninstalled"));
if(C)return C.promise.then(this.stop.bind(this,c));if((!c||!c.transient)&&"stopped"!==x)x="stopped",z();if("active"!==s&&"starting"!==s)return(new a).resolve();C=c=new a;s="stopping";b.dispatchEvent(new e("stopping",t));Object.keys(v).forEach(function(a){v[a].registration.unregister();delete v[a]});w&&(b.disconnect(w),w=null);s="resolved";C=null;b.dispatchEvent(new e("stopped",t));c.resolve();return c.promise};K=function(c){if("uninstalled"===s)return(new a).reject(Error("Plugin is uninstalled"));
if(!c)return 0===D&&(D=(new Date).getTime(),z()),b.loadManifest(d).then(K,function(){t._default&&(D=0,z());console.log("Failed to load plugin: "+d)});var g=F,q=E,h=x;F=c.headers||{};E=c.services||[];x=c.autostart||x;c.lastModified?D=c.lastModified:(D=(new Date).getTime(),z());if(m(F,g)&&m(E,q)&&x===h)return(new a).resolve();if("active"===s||"starting"===s){var k=[];Object.keys(E).forEach(function(a){var b=E[a];k.push(a);var c=v[a];if(c){if(m(b.methods,Object.keys(c.proxy))){a=A(b);var d=c.registration.getReference(),
e={};d.getPropertyKeys().forEach(function(a){e[a]=d.getProperty(a)});m(a,e)||c.registration.setProperties(a);return}c.registration.unregister();delete v[a]}u(b)});Object.keys(v).forEach(function(a){-1===k.indexOf(a)&&(v[a].registration.unregister(),delete v[a])})}"active"===s&&(b.disconnect(w),y=new a,w=b.connect(d,p,L),y.then(function(){y=null},function(){y=null;s="stopping";b.dispatchEvent(new e("stopping"),t);Object.keys(v).forEach(function(a){v[a].registration.unregister();delete v[a]});b.disconnect(w);
w=null;s="resolved";b.dispatchEvent(new e("stopped",t))}));return(new a).resolve()};this.update=function(a){return K(a).then(function(){b.dispatchEvent(new e("updated",t))})};this.uninstall=function(){if("uninstalled"===s)return(new a).reject(Error("Plugin is uninstalled"));if("active"===s||"starting"===s||"stopping"===s)return this.stop().then(this.uninstall.bind(this),this.uninstall.bind(this));b.removePlugin(this);s="uninstalled";b.dispatchEvent(new e("uninstalled",t));return(new a).resolve()}}
var d=/^http[s]?/i;return{Plugin:g,PluginRegistry:function(f,c){function b(a){var b=a.source;r.some(function(c){if(b===c.target){try{var d;if("undefined"===typeof c.useStructuredClone){var e="string"!==typeof a.data;d=e?a.data:JSON.parse(a.data);c.useStructuredClone=e}else d=c.useStructuredClone?a.data:JSON.parse(a.data);c.handler(d)}catch(f){}return!0}})}c=c||{};var q=c.storage||localStorage;q.getItem||(q=p(q));var h="installed",m,l=[],r=[],B=new k,A={},u={registerService:f.registerService.bind(f),
connect:function(a,b,c,d){function e(a){a=Error(a);a.name="timeout";b({method:"timeout",error:a})}var f={handler:b,url:a},h=setTimeout(e.bind(null,"Load timeout for: "+a),d||15E3),g=document.createElement("iframe");g.name=a+"_"+(new Date).getTime();g.src=a;g.onload=function(){clearTimeout(h);h=setTimeout(e.bind(null,"Plugin handshake timeout for: "+a),5E3)};g.sandbox="allow-scripts allow-same-origin";g.style.width=g.style.height="100%";g.frameBorder=0;(c||m).appendChild(g);f.target=g.contentWindow;
f.connected=function(){clearTimeout(h)};f.close=function(){clearTimeout(h);if(g){var a=g.parentNode;a&&a.removeChild(g);g=null}};r.push(f);return f},disconnect:function(a){for(var b=0;b<r.length;b++)if(a===r[b]){r.splice(b,1);try{a.close()}catch(c){}break}},removePlugin:function(a){for(var b=0;b<l.length;b++)if(a===l[b]){l.splice(b,1);break}q.removeItem("plugin."+a.getLocation())},persist:function(a,b){q.setItem("plugin."+a,JSON.stringify(b))},postMessage:function(a,b){b.target.postMessage(b.useStructuredClone?
a:JSON.stringify(a),b.url)},dispatchEvent:function(a){try{B.dispatchEvent(a)}catch(b){console&&console.log("PluginRegistry.dispatchEvent "+b)}},loadManifest:function(b){var c=new a,d=u.connect(b,function(a){d&&a.method&&("manifest"===a.method||"plugin"===a.method?(a=a.params[0],u.disconnect(d),d=null,c.resolve(a)):"timeout"===a.method&&(u.disconnect(d),d=null,c.reject(a.error)))});return c.promise},getState:function(){return h},handleServiceError:function(a,b){if(b&&401===b.status){var c=a.getHeaders(),
e=a.getName()||a.getLocation(),f=document.createElement("span");f.appendChild(document.createTextNode("Authentication required for: "+e+"."));c.login&&(f.appendChild(document.createTextNode(" ")),e=document.createElement("a"),e.target="_blank",e.textContent="Login",e.href=c.login,d.test(e.href)?(f.appendChild(e),f.appendChild(document.createTextNode(" and re-try the request."))):console.log("Illegal Login URL: "+c.login));return{Severity:"Error",HTML:!0,Message:(new XMLSerializer).serializeToString(f)}}if(b.__isError){var g=
b;b=Error(g.message);Object.keys(g).forEach(function(a){b[a]=g[a]});delete b.__isError}return b}};this.getLocation=function(){return"System"};this.getHeaders=function(){return{}};this.getName=function(){return"System"};this.getVersion=function(){return"0.0.0"};this.getLastModified=function(){return 0};this.getState=u.getState;this.init=function(){if(!("starting"===h||"active"===h||"stopping"===h)){addEventListener("message",b,!1);for(var a=[],d=0,e=q.length;d<e;d++)a.push(q.key(d));a.forEach(function(a){if(0===
a.indexOf("plugin.")){var b=a.substring(7);a=JSON.parse(q.getItem(a));a.created&&l.push(new g(b,a,u))}});l.sort(function(a,b){return a._getCreated()<b._getCreated()?-1:1});c.parent?m=c.parent:(m=document.createElement("div"),c.visible||(m.style.display="none",m.style.visibility="hidden"),document.body.appendChild(m));c.plugins&&Object.keys(c.plugins).forEach(function(a){a=n(a);var b=this.getPlugin(a);b?b._default=!0:(b=c.plugins[a],"object"!==typeof b&&(b={}),b.autostart=b.autostart||c.defaultAutostart||
"lazy",b=new g(a,b,u),b._default=!0,l.push(b))}.bind(this));h="starting"}};this.start=function(){"starting"!==h&&this.init();if("starting"!==h)return(new a).reject("Cannot start framework. Framework is already "+h+".");var b=[],c=(new Date).getTime();l.forEach(function(a){var d=a._getAutostart();0===a.getLastModified()?b.push(a.update().then(function(){if("started"===d)return a.start({"transient":!0});if("lazy"===d)return a.start({lazy:!0,"transient":!0});a._resolve()})):"started"===d?b.push(a.start({"transient":!0})):
"lazy"===d?(b.push(a.start({lazy:!0,"transient":!0})),c>a.getLastModified()+864E5&&a.update()):a._resolve()});return a.all(b,function(a){console.log("PluginRegistry.stop "+a)}).then(function(){h="active"})};this.stop=function(){if("starting"!==h&&"active"!==h)return(new a).reject("Cannot stop registry. Registry is already "+h+".");h="stopping";var d=[];l.forEach(function(a){d.push(a.stop({"transient":!0}))});return a.all(d,function(a){console.log("PluginRegistry.stop "+a)}).then(function(){if(!c.parent){var a=
m.parentNode;a&&a.removeChild(m)}m=null;removeEventListener("message",b);h="resolved"})};this.update=function(){this.stop().then(this.start.bind(this))};this.uninstall=function(){return(new a).reject("Cannot uninstall registry")};this.installPlugin=function(b,c){b=n(b);var d=this.getPlugin(b);if(d)return(new a).resolve(d);if(A[b])return A[b];if(c)return d=new g(b,c,u),l.push(d),d._persist(),u.dispatchEvent(new e("installed",d)),(new a).resolve(d);var f=u.loadManifest(b).then(function(a){d=new g(b,
a,u);l.push(d);d._persist();delete A[b];u.dispatchEvent(new e("installed",d));return d},function(a){delete A[b];throw a;});return A[b]=f};this.getPlugins=function(){return l.slice()};this.getPlugin=function(a){var b=null;a=n(a);l.some(function(c){if(a===c.getLocation())return b=c,!0});return b};this.addEventListener=B.addEventListener.bind(B);this.removeEventListener=B.removeEventListener.bind(B);this.resolvePlugins=function(){var a=!0;l.forEach(function(b){a=a&&b._resolve()});return a}}}});
define("orion/objects",[],function(){function a(a){for(var m=Object.prototype.hasOwnProperty,n=1,p=arguments.length;n<p;n++){var l=arguments[n],r;for(r in l)m.call(l,r)&&(a[r]=l[r])}return a}return{clone:function(k){if(Array.isArray(k))return Array.prototype.slice.call(k);var m=Object.create(Object.getPrototypeOf(k));a(m,k);return m},mixin:a,toArray:function(a){return Array.isArray(a)?a:[a]}}});
define("orion/serviceTracker",[],function(){function a(a,p){function l(a){var b=a.getProperty("service.id"),d=this.addingService(a);d&&(e[b]=a,h[b]=d)}function r(a){var b=a.getProperty("service.id"),d=h[b];delete e[b];delete h[b];this.removedService(a,d)}this.serviceRegistry=a;var e={},h={},g=k,d,f;this.close=function(){if(g!==m)throw"Already closed";g=k;a.removeEventListener("registered",d);a.removeEventListener("unregistering",f);f=d=null;var c=this;this.getServiceReferences().forEach(function(a){r.call(c,
a)});if("function"===typeof this.onClose)this.onClose()};this.getServiceReferences=function(){var a=Object.keys(e);return!a.length?null:a.map(function(a){return e[a]})};this.open=function(){if(g!==k)throw"Already open";g=m;var c=this;d=function(a){if(-1!==a.serviceReference.getProperty("objectClass").indexOf(p)&&(l.call(c,a.serviceReference),"function"===typeof c.onServiceAdded))return c.onServiceAdded(a.serviceReference,c.serviceRegistry.getService(a.serviceReference))};f=function(a){-1!==a.serviceReference.getProperty("objectClass").indexOf(p)&&
r.call(c,a.serviceReference)};a.addEventListener("registered",d);a.addEventListener("unregistering",f);a.getServiceReferences(p).forEach(function(b){l.call(c,b);if("function"===typeof c.onServiceAdded)return c.onServiceAdded(b,a.getService(b))});if("function"===typeof this.onOpen)this.onOpen()}}var k=0,m=1;a.prototype={addingService:function(a){return this.serviceRegistry.getService(a)},onOpen:null,onClose:null,onServiceAdded:null,removedService:function(a,k){}};return a});
define("orion/config",["orion/Deferred","orion/objects","orion/preferences","orion/serviceTracker"],function(a,k,m,n){var p=m.PreferencesService,l,r,e,h,g=p.DEFAULT_SCOPE,d="pid",f="/cm/configurations";l=function(c,b,e){function f(a,c,d){c.forEach(function(e,f){try{var g=a[f].getProperty("__plugin__"),h=g&&b.getPlugin(g);(!g||h&&"active"===h.getState())&&c[f].updated(d)}catch(q){"undefined"!==typeof console&&console.log(q)}})}n.call(this,c,"orion.cm.managedservice");var g={},h={},k=function(b){var f=
[];b.plugin.getServiceReferences().forEach(function(a){if(-1!==a.getProperty("objectClass").indexOf("orion.cm.managedservice")){var b=a.getProperty(d);a=c.getService(a);b&&a&&(b=(b=e._find(b))&&b.getProperties(),f.push(a.updated(b)))}});return a.all(f)};this.addingService=function(a){var b=a.getProperty(d),e=c.getService(a);if(!b||!e)return null;g[b]||(g[b]=[]);h[b]||(h[b]=[]);g[b].push(a);h[b].push(e);return e};this.onServiceAdded=function(a,b){var c=a.getProperty(d),c=e._find(c);f([a],[b],c&&c.getProperties())};
this.onOpen=function(){b.addEventListener("started",k)};this.onClose=function(){b.removeEventListener("started",k)};this.notifyUpdated=function(a){var b=a.getPid();f(g[b]||[],h[b]||[],a.getProperties())};this.notifyDeleted=function(a){a=a.getPid();f(g[a]||[],h[a]||[],null)};this.removedService=function(a,b){var c=a.getProperty(d),e=g[c],f=h[c];1<e.length?e.splice(e.indexOf(a),1):delete g[c];1<f.length?f.splice(f.indexOf(b),1):delete h[c]}};m=function(){function a(b,c,d){this.store=new r(this,d);this.configAdmin=
new e(this,this.store);this.tracker=new l(b,c,this.store)}a.prototype={getConfigurationAdmin:function(){var a=this;return this.configAdmin._init().then(function(c){a.tracker.open();return c})},notifyDeleted:function(a){this.tracker.notifyDeleted(a)},notifyUpdated:function(a){this.tracker.notifyUpdated(a)}};return a}();e=function(){function a(b,c){this.factory=b;this.store=c}a.prototype={_prefName:f,_init:function(){var a=this;return this.store._init().then(function(){return a})},getConfiguration:function(a){return this.store.get(a)},
getDefaultConfiguration:function(a){return this.store._find(a,g)},listConfigurations:function(){return this.store.list()}};return a}();r=function(){function c(b,c){this.factory=b;this.prefsService=c;this.pref=this.configs=this.defaultConfigs=null;var d=this;this.initPromise=a.all([this.prefsService.getPreferences(f,g),this.prefsService.getPreferences(f)]).then(function(a){var b=a[0];d.pref=a[1];d.defaultConfigs=d._toConfigs(b,!0);d.configs=d._toConfigs(d.pref,!1,b)})}c.prototype={_toConfigs:function(a,
c,e){var f=Object.create(null),g=this;a.keys().forEach(function(k){if(!f[k]){var l=a.get(k),m=e&&e.get(k);"object"===typeof l&&(null!==l&&0<Object.keys(l).length)&&(l[d]=k,f[k]=new h(g.factory,g,l,c,m))}});return f},_init:function(){return this.initPromise},_find:function(a,c){return c===p.DEFAULT_SCOPE?this.defaultConfigs[a]||null:this.configs[a]||null},get:function(a){var c=this._find(a),d=this._find(a,g);c||(c=d&&d.getProperties(!0),c=new h(this.factory,this,a,!1,c),this.configs[a]=c);return c},
list:function(){var a=this,c=[];this.pref.keys().forEach(function(d){(d=a._find(d))&&null!==d.getProperties()&&c.push(d)});return c},remove:function(a){this.pref.remove(a);delete this.configs[a]},save:function(a,c){var d=c.getProperties(!0)||{},e=this._find(a,g);if(e){var f=e.getProperties(!0);Object.keys(f).forEach(function(a){Object.prototype.hasOwnProperty.call(d,a)&&d[a]===f[a]&&delete d[a]})}this.pref.put(a,d)}};return c}();h=function(){function a(b,c){c=k.clone(c);delete c[d];b.properties=c}
function b(b,e,f,g,h){this.factory=b;this.store=e;this.readOnly=g;if(null!==f&&"object"===typeof f)this.pid=f[d],a(this,f);else if("string"===typeof f)this.pid=f,this.properties=null;else throw Error("Invalid pid/properties "+f);if(h){var k=this;Object.keys(h).forEach(function(a){a===d||Object.prototype.hasOwnProperty.call(k.properties,a)||(k.properties[a]=h[a])})}}b.prototype={_checkReadOnly:function(){if(this.readOnly)throw Error("Configuration is read only");},_checkRemoved:function(){if(this.removed)throw Error("Configuration was removed");
},getPid:function(){this._checkRemoved();return this.pid},getProperties:function(a){this._checkRemoved();var b=null;this.properties&&(b=k.clone(this.properties),a||(b[d]=this.pid));return b},remove:function(){this._checkReadOnly();this._checkRemoved();this.factory.notifyDeleted(this);this.store.remove(this.pid);this.removed=!0},update:function(b){this._checkReadOnly();this._checkRemoved();a(this,b);this.store.save(this.pid,this);this.factory.notifyUpdated(this)},toString:function(){return"[ConfigImpl pid: "+
this.pid+", properties: "+JSON.stringify(this.properties)+"]"}};return b}();return{ConfigurationAdminFactory:m}});
define("orion/bootstrap","require orion/Deferred orion/serviceregistry orion/preferences orion/pluginregistry orion/config".split(" "),function(a,k,m,n,p,l){var r;return{startup:function(){if(r)return r;r=new k;var e=new m.ServiceRegistry,h=new n.PreferencesService(e);return h.getPreferences("/plugins").then(function(g){var d={plugins:{}};g.keys().forEach(function(c){var b=a.toUrl(c);d.plugins[b]=g[c]});var f=new p.PluginRegistry(e,d);return f.start().then(function(){if(0<e.getServiceReferences("orion.core.preference.provider").length)return h.getPreferences("/plugins",
h.USER_SCOPE).then(function(c){var b=[];c.keys().forEach(function(c){c=a.toUrl(c);f.getPlugin(c)||b.push(f.installPlugin(c,{autostart:"lazy"}).then(function(a){return a.update().then(function(){return a.start({lazy:!0})})}))});return k.all(b,function(a){console.log(a)})})}).then(function(){return(new l.ConfigurationAdminFactory(e,f,h)).getConfigurationAdmin().then(e.registerService.bind(e,"orion.cm.configadmin"))}).then(function(){var a=e.getService("orion.core.auth");if(a){var b=a.getUser().then(function(b){if(b)localStorage.setItem("lastLogin",
(new Date).getTime());else return a.getAuthForm(window.location.href).then(function(a){setTimeout(function(){window.location=a},0)})}),d=localStorage.getItem("lastLogin");if(!d||d<(new Date).getTime()-9E5)return b}}).then(function(){var a={serviceRegistry:e,preferences:h,pluginRegistry:f};r.resolve(a);return a})})}}});
define("domReady",[],function(){function a(){if(!r){r=!0;p&&clearInterval(p);var a=h;if(r&&a.length){h=[];var f;for(f=0;f<a.length;f+=1)a[f](e)}}}function k(a){r?a(e):h.push(a);return k}var m,n,p,l="undefined"!==typeof window&&window.document,r=!l,e=l?document:null,h=[];if(l){if(document.addEventListener)document.addEventListener("DOMContentLoaded",a,!1),window.addEventListener("load",a,!1);else if(window.attachEvent){window.attachEvent("onload",a);n=document.createElement("div");try{m=null===window.frameElement}catch(g){}n.doScroll&&
(m&&window.external)&&(p=setInterval(function(){try{n.doScroll(),a()}catch(d){}},30))}"complete"===document.readyState&&a()}k.version="2.0.1";k.load=function(a,e,c,b){b.isBuild?c(null):k(c)};return k});define("index",["orion/browserCompatibility","orion/bootstrap","domReady!"],function(a,k){k.startup().then(function(a){window.location="edit/edit.html"})});
//@ sourceMappingURL=index.js.map