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