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

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

 Copyright (c) 2011 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(){var g=this;if(!g.define)g.define=function(c){g.orion=g.orion||{};g.orion.Deferred=c();delete g.define}})();
define("orion/Deferred",[],function(){function g(c){if(j)f?(d.next={notify:c,next:null},d=d.next):d=f={notify:c,next:null};else{j=!0;do{for(;c;){c();if(b)f?d.next=b:f=b,d=a;f?(b=f.next,a=d,c=f.notify,f=d=null):c=null}j=!1}while(j)}}function c(){function b(){for(;i;){var l=i;i=i.next;var c=l.deferred;if(l[h])try{var d=l[h](a);d&&typeof d.then==="function"?d.then(c.resolve,c.reject,c.update):c.resolve(d)}catch(f){c.reject(f)}else c[h](a)}i=e=null}var a,h,i,e;this.resolve=function(l){if(h)throw Error("'"+
h+"' already called");h="resolve";a=l;g(b)};this.reject=function(l){if(h)throw Error("'"+h+"' already called");h="reject";a=l;g(b)};this.update=this.progress=this.notify=function(b){for(var a=i;a;){if(a.update)try{a.update(b)}catch(h){}a=a.next}};this.then=function(a,d,f){a={resolve:a,reject:d,update:f,deferred:new c};i?e.next=a:i=a;e=a;h&&g(b);return a.deferred.promise};this.promise={then:this.then};this.state=function(){return h||"wait"};this.all=function(a,b){function e(a,b){h||(f[a]=b,--d===0&&
i.resolve(f))}function c(a,d){if(!h){if(b)try{e(a,b(d));return}catch(f){d=f}i.reject(d)}}var d=a.length,f=[],i=this;d===0?this.resolve(f):a.forEach(function(a,b){a.then(e.bind(null,b),c.bind(null,b))});return this.promise}}var f,d,b,a,j=!1;c.when=function(a,b,h,d){var e;if(!(a&&typeof a.then==="function"))e=new c,e.resolve(a),a=e.promise;return a.then(b,h,d)};return c});
define("orion/xhr",["orion/Deferred"],function(g){function c(c){return encodeURIComponent(c).replace(/[!'()*]/g,function(d){return"%"+d.charCodeAt(0).toString(16).toUpperCase()})}return function(f,d,b){var b=b||{},a=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,j=new g,k=b.headers||{},m=b.log||!1,h,i;typeof k["X-Requested-With"]==="undefined"&&(k["X-Requested-With"]="XMLHttpRequest");if(b.query&&typeof b.query==="object"){var e=b.query,l=Object.keys(e),n=[];for(i=0;i<l.length;i++){var o=
l[i],r=e[o];n.push(c(o)+"="+c(r))}n.length&&(e=d.split("#"),e[0]+=(e[0].indexOf("?")===-1?"?":"&")+n.join("&"),d=e.join("#"))}if(typeof b.data!=="undefined"&&(f==="POST"||f==="PUT"))h=b.data;if(typeof b.responseType==="string")a.responseType=b.responseType;a.onreadystatechange=function(){if(a.readyState===4){var h=a.status,c=typeof a.response!=="undefined"?a.response:a.responseText,c={args:b,response:c,responseText:typeof c==="string"?c:null,status:h,url:d,xhr:a};200<=h&&h<400?j.resolve(c):(m&&console&&
console.log(Error(a.statusText)),j.reject(c))}};try{a.open(f,d,!0);if(typeof b.timeout==="number")a.timeout=b.timeout,a.addEventListener("timeout",function(a){j.reject("Timeout exceeded: "+a)});var q=Object.keys(k);for(i=0;i<q.length;i++){var p=q[i];a.setRequestHeader(p,k[p])}a.send(h)}catch(s){j.reject(s)}return j}});
define("domReady",[],function(){function g(a){for(var b=0,c;c=a[b];b++)c(j)}function c(){var b=k,c=m;a&&(b.length&&(k=[],g(b)),h.resourcesDone&&c.length&&(m=[],g(c)))}function f(){a||(a=!0,e&&clearInterval(e),c())}function d(b){a?b(j):k.push(b);return d}var b=typeof window!=="undefined"&&window.document,a=!b,j=b?document:null,k=[],m=[],h=requirejs||require||{},i=h.resourcesReady,e;if("resourcesReady"in h)h.resourcesReady=function(a){i&&i(a);a&&c()};b&&(document.addEventListener?(document.addEventListener("DOMContentLoaded",
f,!1),window.addEventListener("load",f,!1)):window.attachEvent&&(window.attachEvent("onload",f),self===self.top&&(e=setInterval(function(){try{document.body&&(document.documentElement.doScroll("left"),f())}catch(a){}},30))),document.readyState==="complete"&&f());d.withResources=function(b){a&&h.resourcesDone?b(j):m.push(b);return d};d.version="1.0.0";d.load=function(a,b,c,h){h.isBuild?c(null):d(c)};return d});var eclipse=eclipse||{};
eclipse.ServiceProvider=function(g,c){this.dispatchEvent=function(f){c.dispatchEvent.apply(c,[g,f].concat(Array.prototype.slice.call(arguments,1)))};this.unregister=function(){c.unregisterServiceProvider(g)}};
eclipse.PluginProvider=function(g){function c(a){j&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),j===self?j.postMessage(a):j.postMessage(a,"*"))}function f(a,b){return b&&b instanceof XMLHttpRequest?{status:b.status,statusText:b.statusText}:b}function d(a){if(a.source===j){var d=typeof a.data!=="string"?a.data:JSON.parse(a.data),a=b[d.serviceId].implementation,i=a[d.method],e={id:d.id,result:null,error:null};try{var g=i.apply(a,d.params);g&&typeof g.then==="function"?g.then(function(a){e.result=
a;c(e)},function(a){e.error=a?JSON.parse(JSON.stringify(a,f)):a;c(e)},function(){c({requestId:d.id,method:"progress",params:Array.prototype.slice.call(arguments)})}):(e.result=g,c(e))}catch(k){e.error=k?JSON.parse(JSON.stringify(k,f)):k,c(e)}}}var b=[],a=!1,j=null,k={dispatchEvent:function(b,d){if(!a)throw Error("Cannot dispatchEvent. Plugin Provider not connected");var f={serviceId:b,method:"dispatchEvent",params:[d].concat(Array.prototype.slice.call(arguments,2))};c(f)},unregisterServiceProvider:function(c){if(a)throw Error("Cannot unregister. Plugin Provider is connected");
b[c]=null}};this.registerServiceProvider=function(c,d,f){if(a)throw Error("Cannot register. Plugin Provider is connected");var e=null,g=[];for(e in d)typeof d[e]==="function"&&g.push(e);e=b.length;b[e]={type:c,methods:g,implementation:d,properties:f||{}};return new eclipse.ServiceProvider(e,k)};this.connect=function(f,h){if(!a){if(typeof window==="undefined")j=self;else if(window!==window.parent)j=window.parent;else if(window.opener!==null)j=window.opener;else{h&&h("No valid plugin target");return}addEventListener("message",
d,!1);for(var i=[],e=0;e<b.length;e++)b[e]&&i.push({serviceId:e,type:b[e].type,methods:b[e].methods,properties:b[e].properties});c({method:"plugin",params:[{services:i,metadata:g||{}}]});a=!0}f&&f()};this.disconnect=function(){a&&(removeEventListener("message",d),j=null,a=!1)}};define("orion/plugin",function(){});
define("plugins/taskPlugin",["orion/xhr","domReady!","orion/plugin"],function(g){var c=new eclipse.PluginProvider,f=document.createElement("a");f.href="../task";var d=function(b){try{if(window.location.host===parent.location.host&&window.location.protocol===parent.location.protocol)return b.substring(parent.location.href.indexOf(parent.location.host)+parent.location.host.length)}catch(a){}return b}(f.href);c.registerServiceProvider("orion.core.operation",{getOperations:function(b){return g("GET",
d,{headers:{"Orion-Version":"1"},query:b,timeout:b.Longpolling?7E4:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},getOperation:function(b){return g("GET",b,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},removeCompletedOperations:function(){return g("DELETE",d,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){return b.response?JSON.parse(b.response):null})},removeOperation:function(b){return g("DELETE",
b,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},cancelOperation:function(b){return g("PUT",b,{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:d});c.connect()});