(function(d,a){"function"===typeof define&&define.amd?define("orion/Deferred",a):"object"===typeof exports?module.exports=a():(d.orion=d.orion||{},d.orion.Deferred=a())})(this,function(){function d(){for(var b;b=f.shift();)b();k=!1}function a(b){f.push(b);k||(k=!0,n())}function m(b){return function(e){b(e)}}function l(){function b(){for(var g;g=s.shift();){var b=g.deferred,h="fulfilled"===p?"resolve":"reject";g=g[h];if("function"===typeof g)try{var e=g(c),q=e&&("object"===typeof e||"function"===typeof e)&&
e.then;if("function"===typeof q)if(e===b.promise)b.reject(new TypeError);else{var a=e.cancel;"function"===typeof a?b._parentCancel=a.bind(e):delete b._parentCancel;q.call(e,m(b.resolve),m(b.reject),m(b.progress))}else b.resolve(e)}catch(f){b.reject(f)}else b[h](c)}}function e(g){delete q._parentCancel;p="rejected";c=g;s.length&&a(b)}function g(h){function f(c){return function(h){(!p||"assumed"===p)&&c(h)}}delete q._parentCancel;try{var n=h&&("object"===typeof h||"function"===typeof h)&&h.then;if("function"===
typeof n)if(h===q)e(new TypeError);else{p="assumed";var m=h&&h.cancel;if("function"!==typeof m){var d=new l;h=d.promise;try{n(d.resolve,d.reject,d.progress)}catch(k){d.reject(k)}m=h.cancel;n=h.then}c=h;n.call(h,f(g),f(e));q._parentCancel=m.bind(h)}else p="fulfilled",c=h,s.length&&a(b)}catch(u){f(e)(u)}}function h(){var c=q._parentCancel;c?(delete q._parentCancel,c()):p||(c=Error("Cancel"),c.name="Cancel",e(c))}var c,p,s=[],q=this;this.resolve=function(c){p||g(c);return q};this.reject=function(c){p||
e(c);return q};this.progress=function(c){p||s.forEach(function(h){if(h.progress)try{h.progress(c)}catch(g){}});return q.promise};this.cancel=function(){q._parentCancel?setTimeout(h,0):h();return q};this.then=function(c,h,g){var e=new l;e._parentCancel=q.promise.cancel;s.push({resolve:c,reject:h,progress:g,deferred:e});("fulfilled"===p||"rejected"===p)&&a(b);return e.promise};this.promise={then:q.then,cancel:q.cancel}}var f=[],k=!1,n=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var b=
process.nextTick;return function(){b(d)}}if("function"===typeof MutationObserver){var e=document.createElement("div");(new MutationObserver(d)).observe(e,{attributes:!0});return function(){e.setAttribute("class","_tick")}}return function(){setTimeout(d,0)}}();l.all=function(b,e){function g(h,g){s||(p[h]=g,0===--c&&q.resolve(p))}function h(c,h){if(!s){if(e)try{g(c,e(h));return}catch(b){h=b}q.reject(h)}}var c=b.length,p=[],s=!1,q=new l;q.then(void 0,function(){s=!0;b.forEach(function(c){c.cancel&&c.cancel()})});
0===c?q.resolve(p):b.forEach(function(c,b){c.then(g.bind(void 0,b),h.bind(void 0,b))});return q.promise};l.when=function(b,e,g,h){var c;b&&"function"===typeof b.then||(c=new l,c.resolve(b),b=c.promise);return b.then(e,g,h)};return l});
define("orion/xhr",["orion/Deferred"],function(d){function a(a,d,f,k){var n="undefined"!==typeof f.response?f.response:f.responseText,b;try{b=f.status}catch(e){b=0}a={args:d,response:n,responseText:"string"===typeof n?n:null,status:b,url:a,xhr:f};"undefined"!==typeof k&&(a.error=k);return a}return function(m,l,f){f=f||{};var k=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,n=new d,b=f.headers||{},e=f.log||!1,g;"undefined"===typeof b["X-Requested-With"]&&(b["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof f.data&&("POST"===m||"PUT"===m))g=f.data;var h=!1,c=!1;n.promise.then(void 0,function(g){h=!0;!c&&g instanceof Error&&"Cancel"===g.name&&k.abort()});k.onabort=function(){c=!0;if(!h){var g=Error("Cancel");g.name="Cancel";n.reject(g)}};k.onload=function(){var c=a(l,f,k);200<=k.status&&400>k.status?n.resolve(c):(n.reject(c),e&&"undefined"!==typeof console&&console.log(Error(k.statusText)))};k.onerror=function(){var c=a(l,f,k);n.reject(c);e&&"undefined"!==typeof console&&console.log(Error(k.statusText))};
k.onprogress=function(c){c.xhr=k;n.progress(c)};try{k.open(m,l,!0);"string"===typeof f.responseType&&(k.responseType=f.responseType);if("number"===typeof f.timeout)if("number"===typeof k.timeout)k.timeout=f.timeout,k.addEventListener("timeout",function(c){n.reject(a(l,f,k,"Timeout exceeded"))});else{var p=setTimeout(function(){n.reject(a(l,f,k,"Timeout exceeded"))},f.timeout);n.promise.then(clearTimeout.bind(null,p),clearTimeout.bind(null,p))}Object.keys(b).forEach(function(c){k.setRequestHeader(c,
b[c])});k.send(g||null)}catch(s){n.reject(a(l,f,k,s))}return n.promise}});
define("orion/operation",["orion/xhr","orion/Deferred"],function(d,a){function m(a,k,n,b){d("GET",a,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(e){e=e.response?JSON.parse(e.response):null;k.progress(e);!e.type||"loadstart"===e.type||"progress"===e.type?setTimeout(function(){m(a,k,n,b)},2E3):("error"===e.type||"abort"===e.type?k.reject(b?b(e):e.Result):k.resolve(n?n(e):e.Result.JsonData),e.Location||d("DELETE",a,{headers:{"Orion-Version":"1"},timeout:15E3}))},function(b){var g=b;if(void 0!==
b.responseText){g=b.responseText;try{g=JSON.parse(b.responseText)}catch(h){}}void 0!==g.Message?(g.HttpCode=void 0===g.HttpCode?b.status:g.HttpCode,g.Severity=void 0===g.Severity?"Error":g.Severity,k.reject(g)):k.reject({Severity:"Error",Message:g,HttpCode:b.status})})}function l(a,m){m.then(null,function(n){n instanceof Error&&"Cancel"===n.name&&d("PUT",a,{headers:{"Orion-Version":"1"},data:JSON.stringify({abort:!0}),timeout:15E3})})}return{handle:function(f,d,n){var b=new a;l(f,b);m(f,b,d,n);return b}}});
define("orion/cfui/cFClient",["require","orion/xhr","orion/Deferred","orion/operation"],function(d,a,m,l){var f=f||{};f.CFService=function(){function f(a){a&&(this._serviceRegistry=a,this._serviceRegistration=a.registerService("orion.cf.service",this))}f.prototype={_getServiceResponse:function(a,b){var e=b.response?JSON.parse(b.response):null;if(b.xhr&&202===b.xhr.status){var g=l.handle(e.Location);g.then(function(h){try{a.resolve(JSON.parse(h))}catch(c){a.resolve(h)}},function(h){h.failedOperation=
e.Location;a.reject(h)},a.progress);a.then(null,function(h){g.reject(h)})}else a.resolve(e)},_handleServiceResponseError:function(a,b){a.reject(this._translateResponseToStatus(b))},_translateResponseToStatus:function(a){var b;try{b=JSON.parse(a.responseText)}catch(e){b={Message:messages["Problem while performing the action"]}}b.HttpCode=a.status;return b},_xhrV1:function(f,b,e){var g=this,h=new m;a(f,b,{headers:{"CF-Version":"1","Content-Type":"application/json; charset\x3dUTF-8"},timeout:15E3,handleAs:"json",
data:JSON.stringify(e)}).then(function(c){g._getServiceResponse(h,c)},function(c){g._handleServiceResponseError(h,c)});return h},setTarget:function(a,b,e){a={Url:a};b&&(a.Org=b);e&&(a.Space=e);return this._xhrV1("POST",d.toUrl("cfapi/target"),a)},login:function(a,b,e,g,h){g={};a&&(g.Url=a);b&&(g.Username=b,g.Password=e);return this._xhrV1("POST",d.toUrl("cfapi/target"),g)},logout:function(){return this._xhrV1("DELETE",d.toUrl("cfapi/target"))},getLogs:function(a,b,e,g){b||(new m).reject("Application name not set");
b=d.toUrl("cfapi/logs/"+b);e&&(b+="/"+e);g&&(b+="/"+g);a&&(b+="?Target\x3d"+JSON.stringify(a));return this._xhrV1("GET",b)},getTarget:function(){return this._xhrV1("GET",d.toUrl("cfapi/target"))},getInfo:function(){return this._xhrV1("GET",d.toUrl("cfapi/info"))},pushApp:function(a,b,e){b={Name:b,ContentLocation:e};a&&(b.Target=a);return this._xhrV1("PUT",d.toUrl("cfapi/apps"),b)},getApp:function(a,b,e){var g=d.toUrl("cfapi/apps");b?g+="?Name\x3d"+b:location&&(g+="?ContentLocation\x3d"+e);a&&(g+=
"\x26Target\x3d"+JSON.stringify(a));return this._xhrV1("GET",g)},getApps:function(){return this._xhrV1("GET",d.toUrl("cfapi/apps"))},startApp:function(a,b,e,g){b={Name:b,ContentLocation:e,Timeout:g,State:"Started"};a&&(b.Target=a);return this._xhrV1("PUT",d.toUrl("cfapi/apps"),b)},stopApp:function(a,b,e){b={Name:b,ContentLocation:e,State:"Stopped"};a&&(b.Target=a);return this._xhrV1("PUT",d.toUrl("cfapi/apps"),b)},getOrgs:function(a){var b=d.toUrl("cfapi/orgs");a&&(b+="?Target\x3d"+JSON.stringify(a));
return this._xhrV1("GET",b)}};return f}();return f});
define("orion/URITemplate",[],function(){function d(h){this._text=h}function a(h){return h.replace("%25","%")}function m(h,c){if("U"===c)return encodeURIComponent(h).replace(/[!'()*]/g,function(c){return"%"+c.charCodeAt(0).toString(16).toUpperCase()});if("U+R"===c)return encodeURI(h).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(g,a);if("U+R-,"===c)return encodeURI(h).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/,/g,"%2C");throw Error("Unknown allowed character set: "+c);}function l(h,c,g){for(var b=
[],a=0;a<h.length;a++)"undefined"!==typeof h[a]&&b.push(m(h[a],c));return b.join(g)}function f(h,c,b,g){for(var a=Object.keys(h),e=[],f=0;f<a.length;f++)"undefined"!==typeof h[a[f]]&&e.push(m(a[f],c)+b+m(h[a[f]],c));return e.join(g)}function k(g){if(0===g.length)throw Error("Invalid Expression: 0 length expression");(this._operator=b[g[0]])?g=g.substring(1):this._operator=b.NUL;for(var c=[],a=g.split(","),s=0;s<a.length;s++){var f=a[s].match(e);if(null===f)throw Error("Bad VarSpec: "+g);c.push({name:f[1],
explode:!!f[2],prefix:f[3]?parseInt(f[3],10):-1})}this._varSpecList=c}function n(g){for(var c=[],b=0,a=g.indexOf("{",b);-1!==a;){c.push(new d(g.substring(b,a)));b=g.indexOf("}",a+1);if(-1===b)throw Error("Invalid template: "+g);c.push(new k(g.substring(a+1,b)));b+=1;a=g.indexOf("{",b)}c.push(new d(g.substring(b)));this._templateComponents=c}var b={NUL:{first:"",sep:",",named:!1,ifemp:"",allow:"U"},"+":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R"},".":{first:".",sep:",",named:!1,ifemp:"",allow:"U"},
"/":{first:"/",sep:"/",named:!1,ifemp:"",allow:"U"},";":{first:";",sep:";",named:!0,ifemp:"",allow:"U"},"?":{first:"?",sep:"\x26",named:!0,ifemp:"\x3d",allow:"U"},"\x26":{first:"\x26",sep:"\x26",named:!0,ifemp:"\x3d",allow:"U"},"#":{first:"#",sep:",",named:!1,ifemp:"",allow:"U+R"},",":{first:"",sep:",",named:!1,ifemp:"",allow:"U+R-,"}},e=/^((?:(?:[a-zA-Z0-9_])|(?:%[0-9A-F][0-9A-F]))(?:(?:[a-zA-Z0-9_.])|(?:%[0-9A-F][0-9A-F]))*)(?:(\*)|:([0-9]+))?$/,g=/%25[0-9A-F][0-9A-F]/g;d.prototype={expand:function(g){return encodeURI(this._text)}};
k.prototype={expand:function(g){for(var c=[],b=0;b<this._varSpecList.length;b++){var a=this._varSpecList[b],e=a.name,d=g[e],k=typeof d;if("undefined"!==k&&null!==d){var r=0===c.length?this._operator.first:this._operator.sep;if("string"===k)this._operator.named&&(r+=m(e,"U+R"),r+=0===d.length?this._operator.ifemp:"\x3d"),-1!==a.prefix&&a.prefix<d.length&&(d=d.substring(0,a.prefix)),r+=m(d,this._operator.allow);else if(Array.isArray(d)){if(0===d.length)continue;a.explode?r+=l(d,this._operator.allow,
this._operator.sep):(a=l(d,this._operator.allow,","),this._operator.named&&(r+=m(e,"U+R"),r+=0===a.length?this._operator.ifemp:"\x3d"),r+=a)}else if("object"===k){if(0===Object.keys(d).length)continue;a.explode?r+=f(d,this._operator.allow,"\x3d",this._operator.sep):(a=f(d,this._operator.allow,",",","),this._operator.named&&(r+=m(e,"U+R"),r+=0===a.length?this._operator.ifemp:"\x3d"),r+=a)}else throw Error("bad param type: "+e+" : "+k);c.push(r)}}return c.join("")}};n.prototype={expand:function(g){for(var c=
[],b=0;b<this._templateComponents.length;b++)c.push(this._templateComponents[b].expand(g));return c.join("")}};return n});
define("orion/EventTarget",[],function(){function d(){this._namedListeners={}}d.prototype={dispatchEvent:function(a){if(!a.type)throw Error("unspecified type");var d=this._namedListeners[a.type];d&&d.forEach(function(d){try{"function"===typeof d?d(a):d.handleEvent(a)}catch(f){"undefined"!==typeof console&&console.log(f)}});return!a.defaultPrevented},addEventListener:function(a,d){if("function"===typeof d||d.handleEvent)this._namedListeners[a]=this._namedListeners[a]||[],this._namedListeners[a].push(d)},
removeEventListener:function(a,d){var l=this._namedListeners[a];if(l)for(var f=0;f<l.length;f++)if(l[f]===d){1===l.length?delete this._namedListeners[a]:l.splice(f,1);break}}};d.prototype.constructor=d;d.attach=function(a){var m=new d;a.dispatchEvent=m.dispatchEvent.bind(m);a.addEventListener=m.addEventListener.bind(m);a.removeEventListener=m.removeEventListener.bind(m)};return d});
define("orion/serviceregistry",["orion/Deferred","orion/EventTarget"],function(d,a){function m(b,a,g){this._properties=g||{};this._properties["service.id"]=b;this._properties.objectClass=a;this._properties["service.names"]=a}function l(b,a,g){this._serviceId=b;this._serviceReference=a;this._internalRegistry=g}function f(b,a){function g(c){return function(){var g;try{if(!a())throw Error("Service was unregistered");var h=b[c].apply(b,Array.prototype.slice.call(arguments));if(h&&"function"===typeof h.then)return h;
g=new d;g.resolve(h)}catch(f){g=new d,g.reject(f)}return g.promise}}for(var h in b)"function"===typeof b[h]&&(this[h]=g(h))}function k(b,a){this.type=b;this.serviceReference=a}function n(){this._entries=[];this._namedReferences={};this._serviceEventTarget=new a;var b=this;this._internalRegistry={isRegistered:function(a){return b._entries[a]?!0:!1},unregisterService:function(a){var g=b._entries[a];if(!g)throw Error("Service has already been unregistered: "+a);var h=g.reference;b._serviceEventTarget.dispatchEvent(new k("unregistering",
h));b._entries[a]=null;h.getProperty("objectClass").forEach(function(c){for(var g=b._namedReferences[c],a=0;a<g.length;a++)if(g[a]===h){1===g.length?delete b._namedReferences[c]:g.splice(a,1);break}})},modifyService:function(a){var g=b._entries[a];if(!g)throw Error("Service not found while trying to send modified event: "+a);b._serviceEventTarget.dispatchEvent(new k("modified",g.reference))}}}m.prototype={getPropertyKeys:function(){var b=[],a;for(a in this._properties)this._properties.hasOwnProperty(a)&&
b.push(a);return b},getProperty:function(b){return this._properties[b]}};m.prototype.constructor=m;l.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(b){var a=this._serviceReference._properties;this._serviceReference._properties=b||{};b["service.id"]=this._serviceId;
b.objectClass=a.objectClass;b["service.names"]=a["service.names"];this._internalRegistry.modifyService(this._serviceId)}};l.prototype.constructor=l;n.prototype={getService:function(b){var a;if("string"===typeof b)(b=this._namedReferences[b])&&b.some(function(g){a=this._entries[g.getProperty("service.id")].service;return!!a},this);else if(b=this._entries[b.getProperty("service.id")])a=b.service;return a||null},getServiceReferences:function(a){if(a)return this._namedReferences[a]?this._namedReferences[a]:
[];var e=[];this._entries.forEach(function(g){g&&e.push(g.reference)});return e},registerService:function(a,e,g){if("undefined"===typeof e||null===e)throw Error("invalid service");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var h=this._entries.length,c=new m(h,a,g),d=this._namedReferences;a.forEach(function(a){d[a]=d[a]||[];d[a].push(c)});a=new f(e,this._internalRegistry.isRegistered.bind(null,h));this._entries.push({reference:c,service:a});a=this._internalRegistry;this._serviceEventTarget.dispatchEvent(new k("registered",
c));return new l(h,c,a)},addEventListener:function(a,e){this._serviceEventTarget.addEventListener(a,e)},removeEventListener:function(a,e){this._serviceEventTarget.removeEventListener(a,e)}};n.prototype.constructor=n;return{ServiceRegistry:n}});
define("orion/preferences",["require","orion/Deferred","orion/xhr"],function(d,a,m){function l(a,b){this._name=a;this._providers=b;this._flushPending=!1;this._cached=null;this._stores=[];this._pendingDeletes=[];this._dirty=[]}function f(a,b){return{get:function(c,e){if(0===b)return null;var d=localStorage.getItem(a+c);if(null===d)return null;d=JSON.parse(d);return e||-1===b||d._expires&&d._expires>(new Date).getTime()?(delete d._expires,d):null},set:function(c,d){if(0!==b)if(-1!==b&&(d._expires=(new Date).getTime()+
1E3*b),0===Object.keys(d).length)localStorage.removeItem(a+c);else{var e=JSON.stringify(d);localStorage.setItem(a+c,e);delete d._expires}},remove:function(c){localStorage.removeItem(a+c)}}}function k(a){this._currentPromises={};this._cache=new f("/orion/preferences/user",3600);this._service=null;this.available=function(){if(!this._service){var b=a.getServiceReferences("orion.core.preference.provider");0<b.length&&(this._service=a.getService(b[0]))}return!!this._service}}function n(a){this._location=
a;this._currentPromise=null;this._cache=new f("/orion/preferences/default",3600)}function b(){this._cache=new f("/orion/preferences/local",-1)}function e(a,h){this._userProvider=new k(a);this._localProvider=new b;h=h||"defaults.pref";-1===h.indexOf("://")&&(h=d.toUrl(h));this._defaultsProvider=new n(h);this._serviceRegistration=a.registerService("orion.core.preference",this)}l.prototype={_flush:function(){for(var g=[],b=0;b<this._stores.length;++b){var c=this._stores[b];-1!==this._dirty.indexOf(c)&&
g.push(this._providers[b].put(this._name,c));if(this._pendingDeletes[b]&&0<this._pendingDeletes[b].length){for(c=0;c<this._pendingDeletes[b].length;c++)g.push(this._providers[b].remove(this._name,this._pendingDeletes[b][c]));delete this._pendingDeletes[b]}}this._dirty=[];return a.all(g)},_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 b=this._stores[a],c;for(c in b)b.hasOwnProperty(c)&&"undefined"===typeof this._cached[c]&&(this._cached[c]=b[c])}}return this._cached},keys:function(){return Object.keys(this._getCached())},get:function(a){return this._getCached()[a]},put:function(a,b){if(0!==this._stores.length){var c=this._stores[0];c[a]!==b&&(c[a]=b,this._cached=null,this._scheduleFlush(c))}},remove:function(a){for(var b=0;b<
this._stores.length;++b){var c=this._stores[b];if(c.hasOwnProperty(a))return delete c[a],this._pendingDeletes[b]||(this._pendingDeletes[b]=[]),this._pendingDeletes[b].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(b){if(this._flushPending)return this._flushPending=!1,this._flush();for(var h=this,c=[],d=0;d<this._providers.length;++d)c.push(this._providers[d].get(this._name,
b).then(function(a){return function(b){h._stores[a]=b}}(d)));return a.all(c).then(function(){h._cached=null;h._getCached()})},flush:function(){this._flush()}};k.prototype={get:function(b,h){if(this._currentPromises[b])return this._currentPromises[b];var c=new a,d=null;h?this._cache.remove(b):d=this._cache.get(b);if(null!==d)c.resolve(d);else{this._currentPromises[b]=c;var e=this;this._service.get(b).then(function(a){e._cache.set(b,a);delete e._currentPromises[b];c.resolve(a)},function(a){404===a.status?
(a={},e._cache.set(b,a),delete e._currentPromises[b],c.resolve(a)):(delete e._currentPromises[b],c.resolve(e._cache.get(b,!0)||{}))})}return c},put:function(a,b){this._cache.set(a,b);return this._service.put(a,b)},remove:function(a,b){var c=this._cache.get(a);delete c[b];this._cache.set(a,c);return this._service.remove(a,b)}};n.prototype={get:function(b,h){if(this._currentPromise)return this._currentPromise;var c=new a,d=null;h?this._cache.remove(b):d=this._cache.get(b);if(null!==d)c.resolve(d);else{this._currentPromise=
c;var e=this;m("GET",this._location,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){a=JSON.parse(a.response);e._cache.set(b,a[b]||{});e._currentPromise=null;c.resolve(a[b]||{})},function(a){401===a.xhr.status||404===a.xhr.status?(e._cache.set(b,{}),e._currentPromise=null,c.resolve({})):(e._currentPromise=null,a=e._cache.get(b,!0),null!==a?c.resolve(a[b]||{}):c.resolve({}))})}return c},put:function(b,d){var c=new a;c.resolve();return c},remove:function(a,b){var c=this._cache.get(a);
delete c[b];this.put(a,c)}};b.prototype={get:function(b){var d=new a;b=this._cache.get(b);null!==b?d.resolve(b):d.resolve({});return d},put:function(b,d){var c=new a;this._cache.set(b,d);c.resolve();return c},remove:function(a,b){var c=this._cache.get(a);delete c[b];this.put(a,c)}};e.DEFAULT_SCOPE=1;e.LOCAL_SCOPE=2;e.USER_SCOPE=4;e.prototype={listenForChangedSettings:function(a,b,c){if(!b||"number"!==typeof b||7<b||1>b)c=b,b=e.DEFAULT_SCOPE|e.LOCAL_SCOPE|e.USER_SCOPE;window.addEventListener("storage",
c,!1);return 0!==(e.USER_SCOPE&b)?"/orion/preferences/user"+a:0!==(e.LOCAL_SCOPE&b)?"/orion/preferences/local"+a:"/orion/preferences/default"+a},getPreferences:function(a,b){if(!b||"number"!==typeof b||7<b||1>b)b=e.DEFAULT_SCOPE|e.LOCAL_SCOPE|e.USER_SCOPE;var c=[];e.USER_SCOPE&b&&this._userProvider.available()&&c.push(this._userProvider);e.LOCAL_SCOPE&b&&c.push(this._localProvider);e.DEFAULT_SCOPE&b&&c.push(this._defaultsProvider);var d=new l(a,c);return d.sync().then(function(){return d})},getSetting:function(a,
b,c){for(var d,e=0;e<a.length;e++)if(a[e].label===b)for(var f=0;f<a[e].data.length;f++)if(a[e].data[f].label===c){d=a[e].data[f].value;break}return d}};return{PreferencesService:e}});
define("orion/PageUtil",[],function(){var d=/^http[s]?/i;return{hash:function(){var a=window.location.href.split("#")[1];return a?"#"+a:""},matchResourceParameters:function(a){a=a||window.location.toString();var d={resource:""},l=a.indexOf("#");if(-1!==l&&(a=a.substring(l+1),0!==a.length)){a=a.split(",");d.resource=decodeURIComponent(a[0]);for(l=1;l<a.length;l++){var f=/([^=]*)(=?)(.*)/.exec(a[l]),k=decodeURIComponent(f[1]||""),f=decodeURIComponent(f[3]||"");""!==k&&"resource"!==k&&(d[k]=f)}}return d},
validateURLScheme:function(a,m){var l=a;if(-1===a.indexOf("://")){var f=document.createElement("a");f.href=a;l=f.href}f=!1;if(f=m?m.some(function(a){return RegExp("^"+a+":","i").test(l)}):d.test(l))return a;console.log("Illegal URL Scheme: '"+a+"'");return""}}});
define("orion/i18nUtil",["require","orion/Deferred"],function(d,a){function m(a){if(a=localStorage.getItem("orion/messageBundle/"+a))if(a=JSON.parse(a),a._expires&&a._expires>(new Date).getTime())return delete a._expires,a;return null}var l={};return{getMessageBundle:function(f){function k(a){a?d(["i18n!"+f],function(a){if(a){var d=f;a._expires=(new Date).getTime()+9E5;localStorage.setItem("orion/messageBundle/"+d,JSON.stringify(a));delete a._expires}b.resolve(a)}):n(Error(f))}function n(a){b.reject(a)}
if(l[f])return l[f];var b=new a;l[f]=b;var e=m(f);if(e)return b.resolve(e),b;try{d([f],k,n)}catch(g){d(["orion/i18n!"+f],k,n)}return b},formatMessage:function(a){var d=arguments;return a.replace(/\$\{([^\}]+)\}/g,function(a,b){return d[(b<<0)+1]})}}});
define("orion/objects",[],function(){function d(a){for(var d=1;d<arguments.length;d++){var l=arguments[d],f;for(f in l)Object.prototype.hasOwnProperty.call(l,f)&&(a[f]=l[f])}return a}return{clone:function(a){if(Array.isArray(a))return Array.prototype.slice.call(a);var m=Object.create(Object.getPrototypeOf(a));d(m,a);return m},mixin:d,toArray:function(a){return Array.isArray(a)?a:[a]}}});
(function(){function d(a){if("string"!==typeof a)throw new TypeError;}function a(a){return a?a.split("\x26"):[]}function m(a){return 0===a.length?"":a.join("\x26")}function l(a){var b=/([^=]*)(?:=?)(.*)/.exec(a);a=b[1]?decodeURIComponent(b[1]):"";b=b[2]?decodeURIComponent(b[2]):"";return[a,b]}function f(a){var b=encodeURIComponent(a[0]);a[1]&&(b+="\x3d"+encodeURIComponent(a[1]));return b}function k(b,c){var d="",e=[],g=0;return{next:function(){d!==b.query&&(d=b.query,e=a(d));if(g<e.length){var f=
l(e[g++]);switch(c){case "keys":return f[0];case "values":return f[1];case "keys+values":return[f[0],f[1]];default:throw new TypeError;}}throw w;}}}function n(a){Object.defineProperty(this,"_url",{get:function(){return a._url}})}function b(a){return a?/[1-9]\d*$/.exec(a)[0]:""}function e(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 h(a,c){if("string"!==
typeof a)throw new TypeError;a=g(a);var d=q.exec(a);if(!d)return null;var f={};f.scheme=d[1]||"";if(f.scheme&&!v.test(f.scheme))return null;var h=d[2];if(h&&(h=x.exec(h),f.userinfo=h[1],f.host=h[2],f.port=h[3],f.port&&!r.test(f.port)))return null;f.path=d[3];f.query=d[4];f.fragment=d[5];!f.scheme&&c&&(f.scheme=c.scheme,!f.host&&c.host&&(f.userinfo=c.userinfo,f.host=c.host,f.port=c.port,f.pathRelative=!0));f.pathRelative&&(f.path?"/"!==f.path[0]&&(d=/^(.*\/)[^\/]*$/.exec(c.path)[1]||"/",f.path=d+f.path):
f.path=c.path);f.scheme&&(f.scheme=f.scheme.toLowerCase());f.port&&(f.port=b(f.port));f.host&&f.path&&(f.path=e(f.path));return f}function c(a,b){var c;if(b){b=b.href||b;c=h(b);if(!c||!c.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:c})}c=h(a,c);if(!c)throw new SyntaxError;Object.defineProperty(this,"_input",{value:a,writable:!0});Object.defineProperty(this,"_url",{value:c,writable:!0});var d=new n(this);Object.defineProperty(this,"query",{get:function(){return this._url?
d:null},enumerable:!0})}try{var p;if("function"===typeof window.URL&&0!==window.URL.length&&"http:"===(p=new window.URL("http://www.w3.org?q")).protocol&&p.query)return}catch(s){}var q=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,x=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,v=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,r=/^\d*$/,y=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,z=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,A=/^([^?#\s]*)$/,u=/^([^\s]*)$/,B=/^\S*$/,t=/([^:]*):?(.*)/,w="undefined"!==
typeof StopIteration?StopIteration:Error("Stop Iteration"),C={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(n.prototype,{get:{value:function(b){d(b);var c;a(this._url.query).some(function(a){a=l(a);if(a[0]===b)return c=a[1],!0});return c},enumerable:!0},set:{value:function(b,c){d(b);d(c);var e=a(this._url.query);e.some(function(a,d){var g=l(a);if(g[0]===b)return g[1]=c,e[d]=f(g),!0})||e.push(f([b,c]));this._url.query=m(e)},enumerable:!0},has:{value:function(b){d(b);
return a(this._url.query).some(function(a){if(l(a)[0]===b)return!0})},enumerable:!0},"delete":{value:function(b){d(b);var c=a(this._url.query),e=c.filter(function(a){return l(a)[0]!==b});return e.length!==c.length?(this._url.query=m(e),!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=k(this._url,"keys+values");try{for(;;){var d=c.next();a.call(b,d[1],d[0],this)}}catch(e){if(e!==w)throw e;
}},enumerable:!0},keys:{value:function(){return k(this._url,"keys")},enumerable:!0},values:{value:function(){return k(this._url,"values")},enumerable:!0},items:{value:function(){return k(this._url,"keys+values")}},size:{get:function(){return a(this._url.query).length},enumerable:!0},getAll:{value:function(b){d(b);var c=[];a(this._url.query).forEach(function(a){a=l(a);a[0]===b&&c.push(a[1])});return c},enumerable:!0},append:{value:function(b,c){d(b);d(c);var e=a(this._url.query);e.push(f([b,c]));this._url.query=
m(e)},enumerable:!0}});Object.defineProperties(c.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){d(a);this._input=a;this._url=h(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){d(a);if(this._url&&(a=":"===a.slice(-1)?a.substring(0,a.length-1):a,""===a||v.test(a)))this._url.scheme=a.toLowerCase()},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(a){d(a);this._url&&(this._url.userinfo=a)}},username:{get:function(){if(!this._url)return"";var a=t.exec(this._userinfo);return decodeURIComponent(a[1]||"")},set:function(a){d(a);if(this._url){var b=
t.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=t.exec(this._userinfo);return decodeURIComponent(a[2]||"")},set:function(a){d(a);if(this._url){var b=[t.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){d(a);if(this._url&&(a=z.exec(a)))this._url.host=a[1],this._url.port=b(a[2])},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(a){d(a);this._url&&y.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){d(a);this._url&&r.exec(a)&&(this._url.port=b(a))},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(a){d(a);
this._url&&A.exec(a)&&(this._url.host&&a&&"/"!==a[0]&&(a="/"+a),this._url.path=a?e(a):"")},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(a){d(a);this._url&&(a&&"?"===a[0]&&(a=a.substring(1)),u.exec(a)&&(this._url.query=a))},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(a){d(a);this._url&&(a&&"#"===a[0]&&(a=a.substring(1)),B.exec(a)&&(this._url.fragment=a))},enumerable:!0}});
if((p=window.URL||window.webkitURL)&&p.createObjectURL)Object.defineProperty(c,"createObjectURL",{value:p.createObjectURL.bind(p),enumerable:!1}),Object.defineProperty(c,"revokeObjectURL",{value:p.revokeObjectURL.bind(p),enumerable:!1});window.URL=c})();define("orion/URL-shim",[],function(){});
define("orion/PageLinks","require orion/Deferred orion/PageUtil orion/URITemplate orion/i18nUtil orion/objects orion/URL-shim".split(" "),function(d,a,m,l,f,k,n){function b(){return d.toUrl?(new URL(d.toUrl("orion/../"),window.location.href)).href.slice(0,-1):(new URL("/",window.location.href)).href.slice(0,-1)}function e(a){var b={};a.getPropertyKeys().forEach(function(c){"objectClass"!==c&&"service.names"!==c&&"service.id"!==c&&"__plugin__"!==c&&(b[c]=a.getProperty(c))});return b}function g(a){return f.getMessageBundle(a.nls).then(function(b){a.textContent=
a.nameKey?b[a.nameKey]:a.name;return a},function(b){a.textContent=a.nameKey||a.name;return a})}function h(c,d){var f=c.getServiceReferences(d||"orion.page.link"),h=m.matchResourceParameters(window.location.href),p={OrionHome:b(),Location:h.resource},k=[];f.forEach(function(b){b=e(b);if(b.uriTemplate&&(b.nls||b.name)){var c=(new l(b.uriTemplate)).expand(p),c=m.validateURLScheme(c);b.href=c;b.nls?k.push(g(b)):(b.textContent=b.name,k.push((new a).resolve(b)))}});return a.all(k)}function c(a){var b=this.categories=
Object.create(null);a.forEach(function(a){b[a.id]=a})}function p(a){this.allPageLinks=a;this.allPageLinks.sort(s)}function s(a,b){var c=a.textContent&&a.textContent.toLowerCase(),d=b.textContent&&b.textContent.toLowerCase();return c<d?-1:c>d?1:0}var q;k.mixin(c.prototype,{getCategoryIDs:function(){return Object.keys(this.categories)},getCategory:function(a){return this.categories[a]||null}});k.mixin(p.prototype,{createLinkElements:function(){return this.allPageLinks.map(function(a){var b=a.href;a=
a.textContent;var c=document.createElement("a");c.href=b;c.target="_self";c.classList.add("targetSelector");c.textContent=a;return c})},getAllLinks:function(){return this.allPageLinks}});return{getCategoriesInfo:function(b){var d;return!q?(d=[],b.getServiceReferences("orion.page.link.category").forEach(function(b){b=e(b);if(b.id&&(b.name||b.nameKey))b.nls?d.push(g(b)):(b.textContent=b.name,d.push((new a).resolve(b)))}),a.all(d).then(function(a){return q=new c(a)})):(new a).resolve(q)},getPageLinksInfo:function(a,
b){return h(a,b).then(function(a){return new p(a)})},getOrionHome:b}});
define("built-cFDeployService.js","orion/Deferred orion/cfui/cFClient orion/URITemplate orion/serviceregistry orion/preferences orion/PageLinks orion/xhr".split(" "),function(d,a,m,l,f,k,n){function b(a){this.location=a}function e(){}var g=new a.CFService;a=new l.ServiceRegistry;m=document.createElement("a");m.href="../../prefs/user";m=m.href;b.prototype={get:function(a){return n("GET",this.location+a,{headers:{"Orion-Version":"1"},timeout:15E3,log:!1}).then(function(a){return a.response?JSON.parse(a.response):
null})},put:function(a,b){return n("PUT",this.location+a,{data:JSON.stringify(b),headers:{"Orion-Version":"1"},contentType:"application/json;charset\x3dUTF-8",timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},remove:function(a,b){return n("DELETE",this.location+a+"?key\x3d"+b,{headers:{"Orion-Version":"1"},contentType:"application/json;charset\x3dUTF-8",timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})}};m=new b(m);a.registerService("orion.core.preference.provider",
m,{});var h=new f.PreferencesService(a);e.prototype={constructor:e,_getDefaultTarget:function(){var a=new d;h.getPreferences("/cm/configurations").then(function(b){if((b=b.get("org.eclipse.orion.client.cf.settings"))&&b.targetUrl){var d={};d.Url=b.targetUrl;b.manageUrl&&(d.ManageUrl=b.manageUrl);b.org&&(d.Org=b.org);b.space&&(d.Space=b.space);a.resolve(d)}else h.getPreferences("/settingsCF",1).then(function(b){if(b&&b.get("targetUrl")){var d={};d.Url=b.get("targetUrl");b.get("manageUrl")&&(d.ManageUrl=
b.get("manageUrl"));a.resolve(d)}else a.resolve(null)},function(b){a.resolve(null)})},function(b){a.resolve(null)});return a},deploy:function(a,b){var e=this,f=new d;this._getDefaultTarget().then(function(d){var h=b.Params||{},k=h.Target||d,l=h.Name,m=b.Path;h.user&&h.password?g.login(k.Url,h.user,h.password).then(function(b){e._deploy(a,k,l,m,f)},function(a){a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]};f.reject(a)}):e._deploy(a,k,l,
m,f)});return f},_deploy:function(a,b,d,e,f){b&&d?g.pushApp(b,d,decodeURIComponent(a.ContentLocation+e)).then(function(a){f.resolve({CheckState:!0})},function(a){404===a.HttpCode?f.resolve({State:"NOT_DEPLOYED",Message:a.Message}):(a.JsonData&&a.JsonData.error_code&&"CF-InvalidAuthToken"===a.JsonData.error_code&&(a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]}),f.reject(a))}):f.resolve({UriTemplate:"{+OrionHome}/cfui/deploy.html#"+encodeURIComponent(JSON.stringify({ContentLocation:a.ContentLocation,
AppPath:e})),Width:"400px",Height:"270px",UriTemplateId:"org.eclipse.orion.client.cf.deploy.uritemplate"})},_retryWithLogin:function(a,b){var e=new d;a.user&&a.password?g.login(a.Target.Url,a.user,a.password).then(function(d){b(a,e)},function(a){a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]};e.reject(a)}):b(a,e);return e},getState:function(a){return this._retryWithLogin(a,this._getState)},_getState:function(a,b){if(a.Target&&a.Name)return g.getApp(a.Target,
a.Name).then(function(a){b.resolve({State:0<a.running_instances?"STARTED":"STOPPED",Message:a.running_instances+" of "+a.instances+" instance(s) running"})},function(a){404===a.HttpCode?b.resolve({State:"NOT_DEPLOYED",Message:a.Message}):(a.JsonData&&a.JsonData.error_code&&"CF-InvalidAuthToken"===a.JsonData.error_code&&(a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]}),b.reject(a))}),b},start:function(a){return this._retryWithLogin(a,this._start.bind(this))},
_start:function(a,b){var d=this;if(a.Target&&a.Name)return g.startApp(a.Target,a.Name,void 0,a.Timeout).then(function(a){b.resolve(d._prepareAppStateMessage(a))},function(a){404===a.HttpCode?b.resolve({State:"NOT_DEPLOYED",Message:a.Message}):(a.JsonData&&a.JsonData.error_code&&"CF-InvalidAuthToken"===a.JsonData.error_code&&(a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]}),b.reject(a))}),b},stop:function(a){return this._retryWithLogin(a,
this._stop)},_stop:function(a,b){if(a.Target&&a.Name)return g.stopApp(a.Target,a.Name).then(function(a){b.resolve({State:"STARTED"===a.entity.state?"STARTED":"STOPPED",Message:"Application is not running"})},function(a){404===a.HttpCode?b.resolve({State:"NOT_DEPLOYED",Message:a.Message}):(a.JsonData&&a.JsonData.error_code&&"CF-InvalidAuthToken"===a.JsonData.error_code&&(a.Retry={parameters:[{id:"user",type:"text",name:"User:"},{id:"password",type:"password",name:"Password:"}]}),b.reject(a))}),b},
_prepareAppStateMessage:function(a){var b=0,d=0,e=0,f;for(f in a){var g=a[f];b++;"RUNNING"===g.state?d++:"FLAPPING"===g.state&&e++}return{State:0<d?"STARTED":"STOPPED",Message:d+"/"+b+" instance(s) running"+(0<e?" : "+e+" flapping":"")}}};return{DeployService:e}});
//@ sourceMappingURL=built-cFDeployService.js.map