/*******************************************************************************
 * @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 f;f=a.shift();)f();b=!1}function d(f){a.push(f);b||(b=!0,setTimeout(c,0))}function h(a){return function(){a.apply(void 0,arguments)}}function g(){function f(){for(var t;t=i.shift();){var b=t.deferred,f=k==="fulfilled"?"resolve":"reject";if(typeof t[f]==="function")try{var j=(0,t[f])(l),g=j&&(typeof j===
"object"||typeof j==="function")&&j.then;if(typeof g==="function")if(j===b.promise)b.reject(new TypeError);else{var e=j.cancel;typeof e==="function"?b._protected(a).parentCancel=e.bind(j):delete b._protected(a).parentCancel;g.call(j,h(b.resolve),h(b.reject),h(b.progress))}else b.resolve(j)}catch(d){b.reject(d)}else b[f](l)}}function b(a){delete j.parentCancel;k="rejected";l=a;i.length&&d(f)}function c(a){function h(v){return function(a){n||(n=!0,v(a))}}var n=!1;delete j.parentCancel;try{var q=a&&
(typeof a==="object"||typeof a==="function")&&a.then;if(typeof q==="function")if(a===e)b(new TypeError);else{k="assumed";var s=a&&a.cancel;if(typeof s!=="function"){var o=new g,a=o.promise;try{q(o.resolve,o.reject,o.progress)}catch(p){o.reject(p)}s=a.cancel;q=a.then}l=a;q.call(a,h(c),h(b));j.parentCancel=s.bind(a)}else k="fulfilled",l=a,i.length&&d(f)}catch(v){h(b)(v)}}function n(){var a=j.parentCancel;if(a)delete j.parentCancel,a();else if(!k)a=Error("Cancel"),a.name="Cancel",b(a)}var l,k,i=[],e=
this,j={};Object.defineProperty(this,"_protected",{value:function(b){if(b!==a)throw Error("protected");return j}});this.resolve=function(a){k||c(a);return e};this.reject=function(a){k||b(a);return e};this.progress=function(a){k||i.forEach(function(b){if(b.progress)try{b.progress(a)}catch(f){}});return e.promise};this.cancel=function(){j.parentCancel?setTimeout(n,0):n();return e};this.then=function(b,j,c){b={resolve:b,reject:j,progress:c,deferred:new g};i.push(b);b.deferred._protected(a).parentCancel=
e.promise.cancel.bind(e);(k==="fulfilled"||k==="rejected")&&d(f);return b.deferred.promise};this.promise={then:e.then,cancel:e.cancel}}var a=[],b=!1;g.all=function(a,b){function d(a,b){i||(h[a]=b,--l===0&&e.resolve(h))}function c(a,f){if(!i){if(b)try{d(a,b(f));return}catch(g){f=g}e.reject(f)}}var l=a.length,h=[],i=!1,e=new g;e.then(void 0,function(){i=!0;a.forEach(function(a){a.cancel&&a.cancel()})});l===0?e.resolve(h):a.forEach(function(a,b){a.then(d.bind(void 0,b),c.bind(void 0,b))});return e.promise};
g.when=function(a,b,d,c){var h;if(!(a&&typeof a.then==="function"))h=new g,h.resolve(a),a=h.promise;return a.then(b,d,c)};return g});
define("orion/xhr",["orion/Deferred"],function(c){function d(d,g,a,b){var f=typeof a.response!=="undefined"?a.response:a.responseText,c;try{c=a.status}catch(m){c=0}d={args:g,response:f,responseText:typeof f==="string"?f:null,status:c,url:d,xhr:a};if(typeof b!=="undefined")d.error=b;return d}return function(h,g,a){var a=a||{},b=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,f=new c,r=a.headers||{},m=a.log||!1,n;typeof r["X-Requested-With"]==="undefined"&&(r["X-Requested-With"]="XMLHttpRequest");
if(typeof a.data!=="undefined"&&(h==="POST"||h==="PUT"))n=a.data;var l=!1,k=!1;f.promise.then(void 0,function(a){l=!0;!k&&a instanceof Error&&a.name==="Cancel"&&b.abort()});b.onabort=function(){k=!0;if(!l){var a=Error("Cancel");a.name="Cancel";f.reject(a)}};b.onload=function(){var c=d(g,a,b);200<=b.status&&b.status<400?f.resolve(c):(f.reject(c),m&&typeof console!=="undefined"&&console.log(Error(b.statusText)))};b.onerror=function(){var c=d(g,a,b);f.reject(c);m&&typeof console!=="undefined"&&console.log(Error(b.statusText))};
b.onprogress=function(a){a.xhr=b;f.progress(a)};try{b.open(h,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 i=setTimeout(function(){f.reject(d(g,a,b,"Timeout exceeded"))},a.timeout);f.promise.then(clearTimeout.bind(null,i),clearTimeout.bind(null,i))}Object.keys(r).forEach(function(a){b.setRequestHeader(a,
r[a])});b.send(n||null)}catch(e){f.reject(d(g,a,b,e))}return f.promise}});
(function(c,d){typeof define==="function"&&define.amd?define("orion/plugin",["orion/Deferred"],d):typeof exports==="object"?module.exports=d(require("orion/Deferred")):(c.orion=c.orion||{},c.orion.PluginProvider=d(c.orion.Deferred))})(this,function(c){function d(c,d){this.__objectId=c;this.__methods=d}return function(h){function g(a){e&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),e===self?e.postMessage(a):e.postMessage(a,"*"))}function a(){var a=[];Object.keys(o).forEach(function(b){var c=
o[b];a.push({serviceId:b,names:c.names,methods:c.methods,properties:c.properties})});return{headers:k||{},services:a}}function b(a,b){if(b&&b instanceof XMLHttpRequest){var c,d;try{c=b.status,d=b.statusText}catch(f){c=0,d=""}return{status:c||0,statusText:d}}return b}function f(a){var c=a?JSON.parse(JSON.stringify(a,b)):a;if(a instanceof Error)c.__isError=!0,c.message=c.message||a.message,c.name=c.name||a.name;return c}function r(a){if(!e)return(new c).reject(Error("plugin not connected"));a.id=String(j++);
var b=new c;q[a.id]=b;b.then(null,function(b){i&&b instanceof Error&&b.name==="Cancel"&&p({requestId:a.id,method:"cancel",params:b.message?[b.message]:[]})});var f=Object.prototype.toString;a.params.forEach(function(c,g){if(f.call(c)==="[object Object]"&&!(c instanceof d)){var e,h;for(e in c)f.call(c[e])==="[object Function]"&&(h=h||[],h.push(e));if(h){var i=t++;s[i]=c;e=function(){delete s[i]};b.then(e,e);a.params[g]=new d(i,h)}}});p(a);return b.promise}function m(a,b){a||a===0?p({id:a,result:null,
error:b}):console.log(b)}function n(a,b,c,d){d.forEach(function(a,b){if(a&&typeof a.__objectId!=="undefined"){var c={};a.__methods.forEach(function(b){c[b]=function(){return r({objectId:a.__objectId,method:b,params:Array.prototype.slice.call(arguments)})}});d[b]=c}});var e=typeof a===void 0?null:{id:a,result:null,error:null};try{var g=c.apply(b,d);if(e)g&&typeof g.then==="function"?(u[a]=g,g.then(function(b){delete u[a];e.result=b;p(e)},function(b){if(u[a])delete u[a],e.error=f(b),p(e)},function(){p({responseId:a,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(e.result=g,p(e))}catch(h){if(e)e.error=f(h),p(e)}}function l(a){if(a.source===e){a=typeof a.data!=="string"?a.data:JSON.parse(a.data);try{if(a.method){var b=a.method,c=a.params||[];if("serviceId"in a){var d=o[a.serviceId];d||m(a.id,"service not found");d=d.implementation;b in d?n(a.id,d,d[b],c):m(a.id,"method not found")}else if("objectId"in a){var f=s[a.objectId];f||m(a.id,"object not found");!b in f?n(a.id,f,f[b],c):m(a.id,"method not found")}else if("requestId"in
a){var g=u[a.requestId];g&&b==="cancel"&&g.cancel&&g.cancel.apply(g,c)}else if("responseId"in a){var h=q[a.responseId];h&&b==="progress"&&h.progress&&h.progress.apply(h,c)}else throw Error("Bad method: "+a.method);}else{var i=q[String(a.id)];delete q[String(a.id)];a.error?i.reject(a.error):i.resolve(a.result)}}catch(l){console.log("Plugin._messageHandler "+l)}}}var k=h,i=!1,e=null,j=0,t=0,w=0,u={},q={},s={},o={},p=g;this.updateHeaders=function(a){if(i)throw Error("Cannot update headers. Plugin Provider is connected");
k=a};this.registerServiceProvider=this.registerService=function(a,b,c){if(i)throw Error("Cannot register service. Plugin Provider is connected");typeof a==="string"?a=[a]:Array.isArray(a)||(a=[]);var d=null,e=[];for(d in b)typeof b[d]==="function"&&e.push(d);o[w++]={names:a,methods:e,implementation:b,properties:c||{},listeners:{}}};this.connect=function(b,c){if(!i){if(typeof window==="undefined")e=self;else if(window!==window.parent)e=window.parent;else if(window.opener!==null)e=window.opener;else{c&&
c("No valid plugin target");return}addEventListener("message",l,!1);var d={method:"plugin",params:[a()]};g(d);i=!0}b&&b()};this.disconnect=function(){i&&(removeEventListener("message",l),e=null,i=!1)}}});
define("domReady",[],function(){function c(){if(!f){f=!0;a&&clearInterval(a);var b=m;if(f&&b.length){m=[];var c;for(c=0;c<b.length;c+=1)b[c](r)}}}function d(a){f?a(r):m.push(a);return d}var h,g,a,b=typeof window!=="undefined"&&window.document,f=!b,r=b?document:null,m=[];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{h=window.frameElement===
null}catch(n){}g.doScroll&&h&&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,e){e.isBuild?c(null):d(c)};return d});
define('built-authenticationPlugin.js',["orion/xhr","orion/plugin","domReady!"],function(c,d){var h=new d({name:"Orion User Authentication",version:"1.0",description:"This plugin provides a user authentication service to support user verification and logout."}),g;h.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 instanceof
Error&&a.name==="Cancel"?"_cancel":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"});h.connect()});