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

/*

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

 Copyright (c) 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(c,d){typeof define==="function"&&define.amd?define("orion/Deferred",d):typeof exports==="object"?module.exports=d():(c.orion=c.orion||{},c.orion.Deferred=d())})(this,function(){function c(){for(var a;a=f.shift()||h.shift();)a();i=!1}function d(a,b){(b?h:f).push(a);i||(i=!0,b?setTimeout(c,0):c())}function j(a){return function(){a.apply(null,arguments)}}function g(){}function a(){var a=Error("Cancel");a.name="Cancel";return a}function b(){function c(){for(var a;a=e.shift();){var b=a.deferred,
l=m==="resolved"?"resolve":"reject";if(typeof a[l]==="function")try{var d=a[l](k);d&&typeof d.then==="function"?(b.cancel=d.cancel||g,d.then(j(b.resolve),j(b.reject),b.progress)):b.resolve(d)}catch(f){b.reject(f)}else b[l](k)}}var k,m,e=[],l=this;this.reject=function(a){m||(m="rejected",k=a,e.length&&d(c));return l.promise};this.resolve=function(a){m||(m="resolved",k=a,e.length&&d(c));return l.promise};this.progress=function(a){m||e.forEach(function(e){e.progress&&e.progress(a)});return l.promise};
this.cancel=function(){m||l.reject(a())};this.then=function(a,k,f){var a={resolve:a,reject:k,progress:f,deferred:new b},g=a.deferred,h=!1,j=function(){h||(h=!0,d(function(){var a=g.cancel===j?l.cancel:g.cancel;typeof a==="function"&&a()},!0))};g.cancel=j;e.push(a);m&&d(c,!0);return g.promise};this.promise=Object.create(Object.prototype,{then:{value:l.then},cancel:{get:function(){return l.cancel},set:function(a){l.cancel=a}}})}var f=[],h=[],i=!1;b.all=function(a,d){function m(a,e){g||(c[a]=e,--l===
0&&f.resolve(c))}function e(a,e){if(!g){if(d)try{m(a,d(e));return}catch(b){e=b}f.reject(e)}}var l=a.length,c=[],g=!1,f=new b;f.then(null,function(){g=!0;a.forEach(function(a){a.cancel&&a.cancel()})});l===0?f.resolve(c):a.forEach(function(a,b){a.then(m.bind(null,b),e.bind(null,b))});return f.promise};b.when=function(a,d,m,e){var l;if(!(a&&typeof a.then==="function"))l=new b,l.resolve(a),a=l.promise;return a.then(d,m,e)};return b});
define("orion/xhr",["orion/Deferred"],function(c){function d(d,c,a,b){var f=typeof a.response!=="undefined"?a.response:a.responseText,h;try{h=a.status}catch(i){h=0}d={args:c,response:f,responseText:typeof f==="string"?f:null,status:h,url:d,xhr:a};if(typeof b!=="undefined")d.error=b;return d}return function(j,g,a){var a=a||{},b=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,f=new c,h=a.headers||{},i=a.log||!1,n;typeof h["X-Requested-With"]==="undefined"&&(h["X-Requested-With"]="XMLHttpRequest");
if(typeof a.data!=="undefined"&&(j==="POST"||j==="PUT"))n=a.data;b.onprogress=function(a){a.xhr=b;f.progress(a)};b.onreadystatechange=function(){if(b.readyState===4){var e=d(g,a,b),m=b.status;200<=m&&m<400?f.resolve(e):(i&&typeof console!=="undefined"&&console.log(Error(b.statusText)),f.reject(e))}};try{b.open(j,g,!0);if(typeof a.responseType==="string")b.responseType=a.responseType;if(typeof a.timeout==="number")if(typeof b.timeout==="number")b.timeout=a.timeout,b.addEventListener("timeout",function(){f.reject(d(g,
a,b,"Timeout exceeded"))});else{var k=setTimeout(function(){f.reject(d(g,a,b,"Timeout exceeded"))},a.timeout);f.then(clearTimeout.bind(null,k),clearTimeout.bind(null,k))}Object.keys(h).forEach(function(a){b.setRequestHeader(a,h[a])});b.send(n)}catch(m){f.reject(d(g,a,b,m))}return f.promise}});(function(){var c=this;if(!c.define)c.define=function(d){c.orion=c.orion||{};c.orion.PluginProvider=d();c.eclipse=c.orion;delete c.define}})();
define("orion/plugin",[],function(){return function(c){function d(a){k&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),k===self?k.postMessage(a):k.postMessage(a,"*"))}function j(a,e){if(e&&e instanceof XMLHttpRequest){var b,d;try{b=e.status,d=e.statusText}catch(c){b=0,d=""}return{status:b||0,statusText:d}}return e}function g(a){var e=a?JSON.parse(JSON.stringify(a,j)):a;if(a instanceof Error)e.__isError=!0,e.message=e.message||a.message,e.name=e.name||a.name;return e}function a(a){return function(e){i&&
d({serviceId:a,method:"dispatchEvent",params:[e]})}}function b(b){if(b.source===k){var e=typeof b.data!=="string"?b.data:JSON.parse(b.data);if(typeof e.cancel==="string"){var c=n[e.id];c&&(delete n[e.id],c.cancel&&c.cancel(e.cancel))}else{var b=e.serviceId,f=e.method,i=e.params,j=h[b],p=j.implementation,q=p[f];f==="addEventListener"?(f=i[0],j.listeners[f]=j.listeners[f]||a(b),i=[f,j.listeners[f]]):f==="removeEventListener"&&(f=i[0],i=[f,j.listeners[f]],delete j.listeners[f]);var o={id:e.id,result:null,
error:null};try{(c=q.apply(p,i))&&typeof c.then==="function"?(n[e.id]=c,c.then(function(a){delete n[e.id];o.result=a;d(o)},function(a){if(n[e.id])delete n[e.id],o.error=g(a),d(o)},function(){d({requestId:e.id,method:"progress",params:Array.prototype.slice.call(arguments)})})):(o.result=c,d(o))}catch(r){o.error=g(r),d(o)}}}}var f=c,h=[],i=!1,n={},k=null;this.updateHeaders=function(a){if(i)throw Error("Cannot update headers. Plugin Provider is connected");f=a};this.registerServiceProvider=this.registerService=
function(a,b,d){if(i)throw Error("Cannot register service. Plugin Provider is connected");typeof a==="string"?a=[a]:Array.isArray(a)||(a=[]);var c=null,f=[];for(c in b)typeof b[c]==="function"&&f.push(c);h[h.length]={names:a,methods:f,implementation:b,properties:d||{},listeners:{}}};this.connect=function(a,e){if(!i){if(typeof window==="undefined")k=self;else if(window!==window.parent)k=window.parent;else if(window.opener!==null)k=window.opener;else{e&&e("No valid plugin target");return}addEventListener("message",
b,!1);for(var c=[],g=0;g<h.length;g++)c.push({serviceId:g,names:h[g].names,methods:h[g].methods,properties:h[g].properties});d({method:"plugin",params:[{headers:f||{},services:c}]});i=!0}a&&a()};this.disconnect=function(){i&&(removeEventListener("message",b),k=null,i=!1)}}});
define("domReady",[],function(){function c(){if(!f){f=!0;a&&clearInterval(a);var b=i;if(f&&b.length){i=[];var c;for(c=0;c<b.length;c+=1)b[c](h)}}}function d(a){f?a(h):i.push(a);return d}var j,g,a,b=typeof window!=="undefined"&&window.document,f=!b,h=b?document:null,i=[];if(b){if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(window.attachEvent){window.attachEvent("onload",c);g=document.createElement("div");try{j=window.frameElement===
null}catch(n){}g.doScroll&&j&&window.external&&(a=setInterval(function(){try{g.doScroll(),c()}catch(a){}},30))}document.readyState==="complete"&&c()}d.version="2.0.1";d.load=function(a,b,c,f){f.isBuild?c(null):d(c)};return d});
define('built-authenticationPlugin.js',["orion/xhr","orion/plugin","domReady!"],function(c,d){var j=new d({name:"Orion User Authentication",version:"1.0",description:"This plugin provides a user authentication service to support user verification and logout."}),g;j.registerService("orion.core.auth",{getUser:function(){return g?g:g=c("POST","../login",{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return g=a.response?JSON.parse(a.response):null},function(a){g=null;return a.response?
JSON.parse(a.response):null})},logout:function(){g=null;return c("POST","../logout",{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){g=null;return a.response?JSON.parse(a.response):null},function(a){return a.response?JSON.parse(a.response):null})},getAuthForm:function(a){var a=a?"../mixloginstatic/LoginWindow.html?redirect="+encodeURIComponent(a)+"&key=FORMOpenIdUser":"../mixloginstatic/LoginWindow.html",b=document.createElement("a");b.href=a;return b.href},getKey:function(){return"FORMOpenIdUser"},
getLabel:function(){return"Orion workspace server"}},{name:"FORM+OpenId"});j.connect()});