/*

 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) 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

 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) 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, 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). 


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