/*******************************************************************************
 * @license
 * Copyright (c) 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials are made 
 * available under the terms of the Eclipse Public License v1.0 
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
 * 
 * Contributors: IBM Corporation - initial API and implementation
 ******************************************************************************/
/*******************************************************************************
 * @license
 * Copyright (c) 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials are made 
 * available under the terms of the Eclipse Public License v1.0 
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
/*******************************************************************************
 * @license
 * Copyright (c) 2011, 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials are made 
 * available under the terms of the Eclipse Public License v1.0 
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
/**
 * @license RequireJS domReady 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/requirejs for details
 */
/*******************************************************************************
 * @license
 * Copyright (c) 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials are made 
 * available under the terms of the Eclipse Public License v1.0 
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
 * 
 * Contributors: IBM Corporation - initial API and implementation
 ******************************************************************************/
/*

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2011, 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
 IBM Corporation - initial API and implementation
 RequireJS domReady 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
 Available via the MIT or new BSD license.
 see: http://github.com/jrburke/requirejs for details

 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(f,k){typeof define==="function"&&define.amd?define("orion/Deferred",[],k):typeof exports==="object"?module.exports=k():(f.orion=f.orion||{},f.orion.Deferred=k())})(this,function(){function f(l){if(g)e?(b.next={fn:l,next:null},b=b.next):b=e={fn:l,next:null};else{g=!0;do{for(;l;){l();if(a)e?b.next=a:e=a,b=d;e?(a=e.next,d=b,l=e.fn,e=b=null):l=null}g=!1}while(g)}}function k(a){return function(){a.apply(null,arguments)}}function j(a){function d(){for(;h;){var a=h;h=h.next;var c=a.deferred,n=
g.isResolved()?"resolve":"reject";if(a[n])try{var b=a[n](i);b&&typeof b.then==="function"?(a.cancel=b.cancel,b.then(k(c.resolve),k(c.reject),c.progress)):c.resolve(b)}catch(l){c.reject(l)}else c[n](i)}h=e=null}function n(a){if(c){if(a)throw Error("already "+c);return!0}return!1}var i,c,h,e,b=!1,g=this;this.reject=function(a,b){n(b)||(c="rejected",i=a,h&&f(d));return g.promise};this.resolve=function(a,b){n(b)||(c="resolved",i=a,h&&f(d));return g.promise};this.progress=function(a,c){if(!n(c))for(var d=
h;d;)d.progress&&d.progress(a),d=d.next;return g.promise};this.cancel=function(c,i){if(!n(i))return b=!0,a&&(c=a(c)||c),c=c||Error("canceled"),f(g.reject.bind(g,c)),c;for(var e=h;e;){if(e.canceling)return delete e.canceling,d(),e.cancel&&e.cancel(c);e=e.next}};this.then=function(a,i,n){var b={resolve:a,reject:i,progress:n,cancel:this.cancel,deferred:new j(function(a){b.canceling=!0;return b.cancel&&b.cancel(a)})};h?e.next=b:h=b;e=b;c&&f(d);return b.deferred.promise};this.isResolved=function(){return c===
"resolved"};this.isRejected=function(){return c==="rejected"};this.isFulfilled=function(){return!!c};this.isCanceled=function(){return b};this.promise={then:this.then,cancel:this.cancel,isResolved:this.isResolved,isRejected:this.isRejected,isFulfilled:this.isFulfilled,isCanceled:this.isCanceled};this.notify=this.progress;this.state=function(){return c||"pending"};this.promise.state=this.state}var e,b,a,d,g=!1;j.all=function(a,d){function b(a,d){e.isFulfilled()||(h[a]=d,--c===0&&e.resolve(h))}function i(a,
c){if(!e.isFulfilled()){if(d)try{b(a,d(c));return}catch(i){c=i}e.reject(c)}}var c=a.length,h=[],e=new j(function(c){a.forEach(function(a){a.cancel&&a.cancel(c)})});c===0?e.resolve(h):a.forEach(function(a,c){a.then(b.bind(null,c),i.bind(null,c))});return e.promise};j.when=function(a,d,b,i){var c;if(!(a&&typeof a.then==="function"))c=new j,c.resolve(a),a=c.promise;return a.then(d,b,i)};return j});
define("orion/xhr",["orion/Deferred"],function(f){function k(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(b){return"%"+b.charCodeAt(0).toString(16).toUpperCase()})}function j(e,b,a,d){var g=typeof a.response!=="undefined"?a.response:a.responseText,e={args:b,response:g,responseText:typeof g==="string"?g:null,status:a.status,url:e,xhr:a};if(typeof d!=="undefined")e.error=d;return e}return function(e,b,a){var a=a||{},d=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,g=
new f,l=a.headers||{},m=a.log||!1,n,i;typeof l["X-Requested-With"]==="undefined"&&(l["X-Requested-With"]="XMLHttpRequest");if(a.query&&typeof a.query==="object"){var c=a.query,h=Object.keys(c),s=[];for(i=0;i<h.length;i++){var t=h[i],r=c[t];s.push(k(t)+"="+k(r))}s.length&&(c=b.split("#"),c[0]+=(c[0].indexOf("?")===-1?"?":"&")+s.join("&"),b=c.join("#"))}if(typeof a.data!=="undefined"&&(e==="POST"||e==="PUT"))n=a.data;if(typeof a.responseType==="string")d.responseType=a.responseType;d.onreadystatechange=
function(){if(d.readyState===4){var c=j(b,a,d),i=d.status;200<=i&&i<400?g.resolve(c):(m&&typeof console!=="undefined"&&console.log(Error(d.statusText)),g.reject(c))}};try{d.open(e,b,!0);if(typeof a.timeout==="number")typeof d.timeout==="number"?(d.timeout=a.timeout,d.addEventListener("timeout",function(){g.reject(j(b,a,d,"Timeout exceeded"))})):setTimeout(function(){g.state()!=="resolved"&&g.state()!=="rejected"&&g.reject(j(b,a,d,"Timeout exceeded"))},a.timeout);var q=Object.keys(l);for(i=0;i<q.length;i++){var o=
q[i];d.setRequestHeader(o,l[o])}d.send(n)}catch(p){g.reject(j(b,a,d,p))}return g}});(function(){var f=this;if(!f.define)f.define=function(k){f.orion=f.orion||{};f.orion.PluginProvider=k();f.eclipse=f.orion;delete f.define}})();
define("orion/plugin",[],function(){return function(f){function k(a){m&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),m===self?m.postMessage(a):m.postMessage(a,"*"))}function j(a,d){return d&&d instanceof XMLHttpRequest?{status:d.status,statusText:d.statusText}:d}function e(a){return function(d){g&&k({serviceId:a,method:"dispatchEvent",params:[d]})}}function b(a){if(a.source===m){var b=typeof a.data!=="string"?a.data:JSON.parse(a.data);if(typeof b.cancel==="string"){var c=l[b.id];c&&(delete l[b.id],
c.cancel&&c.cancel(b.cancel))}else{var a=b.serviceId,h=b.method,g=b.params,f=d[a],r=f.implementation,q=r[h];h==="addEventListener"?(h=g[0],f.listeners[h]=f.listeners[h]||e(a),g=[h,f.listeners[h]]):h==="removeEventListener"&&(h=g[0],g=[h,f.listeners[h]],delete f.listeners[h]);var o={id:b.id,result:null,error:null};try{(c=q.apply(r,g))&&typeof c.then==="function"?(l[b.id]=c,c.then(function(a){delete l[b.id];o.result=a;k(o)},function(a){if(l[b.id])delete l[b.id],o.error=a?JSON.parse(JSON.stringify(a,
j)):a,k(o)},function(){k({requestId:b.id,method:"progress",params:Array.prototype.slice.call(arguments)})})):(o.result=c,k(o))}catch(p){o.error=p?JSON.parse(JSON.stringify(p,j)):p,k(o)}}}}var a=f,d=[],g=!1,l={},m=null;this.updateHeaders=function(d){if(g)throw Error("Cannot update headers. Plugin Provider is connected");a=d};this.registerServiceProvider=this.registerService=function(a,b,c){if(g)throw Error("Cannot register service. Plugin Provider is connected");typeof a==="string"?a=[a]:Array.isArray(a)||
(a=[]);var e=null,f=[];for(e in b)typeof b[e]==="function"&&f.push(e);d[d.length]={names:a,methods:f,implementation:b,properties:c||{},listeners:{}}};this.connect=function(e,f){if(!g){if(typeof window==="undefined")m=self;else if(window!==window.parent)m=window.parent;else if(window.opener!==null)m=window.opener;else{f&&f("No valid plugin target");return}addEventListener("message",b,!1);for(var c=[],h=0;h<d.length;h++)c.push({serviceId:h,names:d[h].names,methods:d[h].methods,properties:d[h].properties});
k({method:"plugin",params:[{headers:a||{},services:c}]});g=!0}e&&e()};this.disconnect=function(){g&&(removeEventListener("message",b),m=null,g=!1)}}});
define("domReady",[],function(){function f(a){for(var b=0,e;e=a[b];b++)e(d)}function k(){var c=g,b=l;a&&(c.length&&(g=[],f(c)),m.resourcesDone&&b.length&&(l=[],f(b)))}function j(){a||(a=!0,i&&clearInterval(i),k())}function e(b){a?b(d):g.push(b);return e}var b=typeof window!=="undefined"&&window.document,a=!b,d=b?document:null,g=[],l=[],m=requirejs||require||{},n=m.resourcesReady,i;if("resourcesReady"in m)m.resourcesReady=function(a){n&&n(a);a&&k()};b&&(document.addEventListener?(document.addEventListener("DOMContentLoaded",
j,!1),window.addEventListener("load",j,!1)):window.attachEvent&&(window.attachEvent("onload",j),self===self.top&&(i=setInterval(function(){try{document.body&&(document.documentElement.doScroll("left"),j())}catch(a){}},30))),document.readyState==="complete"&&j());e.withResources=function(b){a&&m.resourcesDone?b(d):l.push(b);return e};e.version="1.0.0";e.load=function(a,b,d,f){f.isBuild?d(null):e(d)};return e});
define("plugins/taskPlugin",["orion/xhr","orion/plugin","domReady!"],function(f,k){var j=document.createElement("a");j.href="../mixloginstatic/LoginWindow.html";var e=new k({name:"Orion Task Management Service",version:"1.0",description:"This plugin provides access to and supports management of the tasks a user is currently running or ran recently.",login:j.href});j.href="../task";var b=function(a){try{if(window.location.host===parent.location.host&&window.location.protocol===parent.location.protocol)return a.substring(parent.location.href.indexOf(parent.location.host)+
parent.location.host.length)}catch(b){}return a}(j.href);e.registerService("orion.core.operation",{getOperations:function(a){return f("GET",b,{headers:{"Orion-Version":"1"},query:a,timeout:a.Longpolling?7E4:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},getOperation:function(a){return f("GET",a,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},removeCompletedOperations:function(){return f("DELETE",b,{headers:{"Orion-Version":"1"},
timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},removeOperation:function(a){return f("DELETE",a,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},cancelOperation:function(a){return f("PUT",a,{data:JSON.stringify({Cancel:!0}),headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})}},{name:"Tasks",pattern:b});e.connect()});