(function(c,e){"function"===typeof define&&define.amd?define("orion/Deferred",e):"object"===typeof exports?module.exports=e():(c.orion=c.orion||{},c.orion.Deferred=e())})(this,function(){function c(){for(var n;n=a.shift();)n();b=!1}function e(n){a.push(n);b||(b=!0,f())}function g(a){return function(b){a(b)}}function d(){function a(){for(var l;l=m.shift();){var b=l.deferred,k="fulfilled"===h?"resolve":"reject";l=l[k];if("function"===typeof l)try{var d=l(q),n=d&&("object"===typeof d||"function"===typeof d)&&
d.then;if("function"===typeof n)if(d===b.promise)b.reject(new TypeError);else{var c=d.cancel;"function"===typeof c?b._parentCancel=c.bind(d):delete b._parentCancel;n.call(d,g(b.resolve),g(b.reject),g(b.progress))}else b.resolve(d)}catch(e){b.reject(e)}else b[k](q)}}function b(l){delete k._parentCancel;h="rejected";q=l;m.length&&e(a)}function c(l){function f(z){return function(b){(!h||"assumed"===h)&&z(b)}}delete k._parentCancel;try{var g=l&&("object"===typeof l||"function"===typeof l)&&l.then;if("function"===
typeof g)if(l===k)b(new TypeError);else{h="assumed";var t=l&&l.cancel;if("function"!==typeof t){var s=new d;l=s.promise;try{g(s.resolve,s.reject,s.progress)}catch(u){s.reject(u)}t=l.cancel;g=l.then}q=l;g.call(l,f(c),f(b));k._parentCancel=t.bind(l)}else h="fulfilled",q=l,m.length&&e(a)}catch(r){f(b)(r)}}function f(){var a=k._parentCancel;a?(delete k._parentCancel,a()):h||(a=Error("Cancel"),a.name="Cancel",b(a))}var q,h,m=[],k=this;this.resolve=function(a){h||c(a);return k};this.reject=function(a){h||
b(a);return k};this.progress=function(a){h||m.forEach(function(b){if(b.progress)try{b.progress(a)}catch(d){}});return k.promise};this.cancel=function(){k._parentCancel?setTimeout(f,0):f();return k};this.then=function(b,c,f){var g=new d;g._parentCancel=k.promise.cancel;m.push({resolve:b,reject:c,progress:f,deferred:g});("fulfilled"===h||"rejected"===h)&&e(a);return g.promise};this.promise={then:k.then,cancel:k.cancel}}var a=[],b=!1,f=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var a=
process.nextTick;return function(){a(c)}}if("function"===typeof MutationObserver){var b=document.createElement("div");(new MutationObserver(c)).observe(b,{attributes:!0});return function(){b.setAttribute("class","_tick")}}return function(){setTimeout(c,0)}}();d.all=function(a,b){function c(a,b){m||(e[a]=b,0===--g&&k.resolve(e))}function f(a,d){if(!m){if(b)try{c(a,b(d));return}catch(e){d=e}k.reject(d)}}var g=a.length,e=[],m=!1,k=new d;k.then(void 0,function(){m=!0;a.forEach(function(a){a.cancel&&a.cancel()})});
0===g?k.resolve(e):a.forEach(function(a,b){a.then(c.bind(void 0,b),f.bind(void 0,b))});return k.promise};d.when=function(a,b,c,e){var f;a&&"function"===typeof a.then||(f=new d,f.resolve(a),a=f.promise);return a.then(b,c,e)};return d});
define("orion/xhr",["orion/Deferred"],function(c){function e(c,d,a,b){var f="undefined"!==typeof a.response?a.response:a.responseText,e;try{e=a.status}catch(p){e=0}c={args:d,response:f,responseText:"string"===typeof f?f:null,status:e,url:c,xhr:a};"undefined"!==typeof b&&(c.error=b);return c}return function(g,d,a){a=a||{};var b=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,f=new c,n=a.headers||{},p=a.log||!1,v;"undefined"===typeof n["X-Requested-With"]&&(n["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof a.data&&("POST"===g||"PUT"===g))v=a.data;var t=!1,q=!1;f.promise.then(void 0,function(a){t=!0;!q&&a instanceof Error&&"Cancel"===a.name&&b.abort()});b.onabort=function(){q=!0;if(!t){var a=Error("Cancel");a.name="Cancel";f.reject(a)}};b.onload=function(){var c=e(d,a,b);200<=b.status&&400>b.status?f.resolve(c):(f.reject(c),p&&"undefined"!==typeof console&&console.log(Error(b.statusText)))};b.onerror=function(){var c=e(d,a,b);f.reject(c);p&&"undefined"!==typeof console&&console.log(Error(b.statusText))};
b.onprogress=function(a){a.xhr=b;f.progress(a)};try{b.open(g,d,!0);"string"===typeof a.responseType&&(b.responseType=a.responseType);if("number"===typeof a.timeout)if("number"===typeof b.timeout)b.timeout=a.timeout,b.addEventListener("timeout",function(c){f.reject(e(d,a,b,"Timeout exceeded"))});else{var h=setTimeout(function(){f.reject(e(d,a,b,"Timeout exceeded"))},a.timeout);f.promise.then(clearTimeout.bind(null,h),clearTimeout.bind(null,h))}Object.keys(n).forEach(function(a){b.setRequestHeader(a,
n[a])});b.send(v||null)}catch(m){f.reject(e(d,a,b,m))}return f.promise}});
(function(c,e){"function"===typeof define&&define.amd?define("orion/plugin",["orion/Deferred"],e):"object"===typeof exports?module.exports=e(require("orion/Deferred")):(c.orion=c.orion||{},c.orion.PluginProvider=e(c.orion.Deferred))})(this,function(c){function e(c,d){this.__objectId=c;this.__methods=d}return function(g){function d(a){m&&("undefined"===typeof ArrayBuffer&&(a=JSON.stringify(a)),m===self?m.postMessage(a):m.postMessage(a,"*"))}function a(){var a=[];Object.keys(u).forEach(function(b){var c=
u[b];a.push({serviceId:b,names:c.names,methods:c.methods,properties:c.properties})});return{headers:q||{},services:a}}function b(a,b){if(b&&b instanceof XMLHttpRequest){var c,d;try{c=b.status,d=b.statusText}catch(e){c=0,d=""}return{status:c||0,statusText:d}}return b}function f(a){var c=a?JSON.parse(JSON.stringify(a,b)):a;a instanceof Error&&(c.__isError=!0,c.message=c.message||a.message,c.name=c.name||a.name);return c}function n(a){if(!m)return(new c).reject(Error("plugin not connected"));a.id=String(k++);
var b=new c;x[a.id]=b;b.then(null,function(b){h&&b instanceof Error&&"Cancel"===b.name&&r({requestId:a.id,method:"cancel",params:b.message?[b.message]:[]})});var d=Object.prototype.toString;a.params.forEach(function(c,f){if("[object Object]"===d.call(c)&&!(c instanceof e)){var g,h;for(g in c)"[object Function]"===d.call(c[g])&&(h=h||[],h.push(g));if(h){var k=l++;s[k]=c;g=function(){delete s[k]};b.then(g,g);a.params[f]=new e(k,h)}}});r(a);return b.promise}function p(a,b){a||0===a?r({id:a,result:null,
error:b}):console.log(b)}function v(a,b,c,d){d.forEach(function(a,b){if(a&&"undefined"!==typeof a.__objectId){var c={};a.__methods.forEach(function(b){c[b]=function(){return n({objectId:a.__objectId,method:b,params:Array.prototype.slice.call(arguments)})}});d[b]=c}});var e=void 0===typeof a?null:{id:a,result:null,error:null};try{var g=c.apply(b,d);e&&(g&&"function"===typeof g.then?(w[a]=g,g.then(function(b){delete w[a];e.result=b;r(e)},function(b){w[a]&&(delete w[a],e.error=f(b),r(e))},function(){r({responseId:a,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(e.result=g,r(e)))}catch(h){e&&(e.error=f(h),r(e))}}function t(a){if(!(a.source!==m&&"undefined"!==typeof window)){a="string"!==typeof a.data?a.data:JSON.parse(a.data);try{if(a.method){var b=a.method,c=a.params||[];if("serviceId"in a){var d=u[a.serviceId];d||p(a.id,"service not found");d=d.implementation;b in d?v(a.id,d,d[b],c):p(a.id,"method not found")}else if("objectId"in a){var e=s[a.objectId];e||p(a.id,"object not found");!b in
e?v(a.id,e,e[b],c):p(a.id,"method not found")}else if("requestId"in a){var f=w[a.requestId];f&&"cancel"===b&&f.cancel&&f.cancel.apply(f,c)}else if("responseId"in a){var g=x[a.responseId];g&&"progress"===b&&g.progress&&g.progress.apply(g,c)}else throw Error("Bad method: "+a.method);}else{var h=x[String(a.id)];delete x[String(a.id)];a.error?h.reject(a.error):h.resolve(a.result)}}catch(k){console.log("Plugin._messageHandler "+k)}}}var q=g,h=!1,m=null,k=0,l=0,y=0,w={},x={},s={},u={},r=d;this.updateHeaders=
function(a){if(h)throw Error("Cannot update headers. Plugin Provider is connected");q=a};this.registerServiceProvider=this.registerService=function(a,b,c){if(h)throw Error("Cannot register service. Plugin Provider is connected");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var d=null,e=[];for(d in b)"function"===typeof b[d]&&e.push(d);u[y++]={names:a,methods:e,implementation:b,properties:c||{},listeners:{}}};this.connect=function(b,c){if(!h){if("undefined"===typeof window)m=self;else if(window!==
window.parent)m=window.parent;else if(null!==window.opener)m=window.opener;else{c&&c("No valid plugin target");return}addEventListener("message",t,!1);var e={method:"plugin",params:[a()]};d(e);h=!0}b&&b()};this.disconnect=function(){h&&(removeEventListener("message",t),m=null,h=!1)}}});
define("domReady",[],function(){function c(){if(!f){f=!0;a&&clearInterval(a);var b=p;if(f&&b.length){p=[];var c;for(c=0;c<b.length;c+=1)b[c](n)}}}function e(a){f?a(n):p.push(a);return e}var g,d,a,b="undefined"!==typeof window&&window.document,f=!b,n=b?document:null,p=[];if(b){if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(window.attachEvent){window.attachEvent("onload",c);d=document.createElement("div");try{g=null===window.frameElement}catch(v){}d.doScroll&&
g&&window.external&&(a=setInterval(function(){try{d.doScroll(),c()}catch(a){}},30))}"complete"===document.readyState&&c()}e.version="2.0.1";e.load=function(a,b,c,d){d.isBuild?c(null):e(c)};return e});
define("built-authenticationPlugin.js",["orion/xhr","orion/plugin","domReady!"],function(c,e){var g=new e({name:"Orion User Authentication",version:"1.0",description:"This plugin provides a user authentication service to support user verification and logout."}),d;g.registerService("orion.core.auth",{getUser:function(){return d?d:d=c("POST","../login",{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return d=a.response?JSON.parse(a.response):null},function(a){d=null;return a instanceof
Error&&"Cancel"===a.name?"_cancel":a.response?JSON.parse(a.response):null})},logout:function(){d=null;return c("POST","../logout",{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){d=null;return a.response?JSON.parse(a.response):null},function(a){return a.response?JSON.parse(a.response):null})},getAuthForm:function(a){a=a?"../mixloginstatic/LoginWindow.html?redirect\x3d"+encodeURIComponent(a)+"\x26key\x3dFORMOpenIdUser":"../mixloginstatic/LoginWindow.html";var b=document.createElement("a");
b.href=a;return b.href},getKey:function(){return"FORMOpenIdUser"},getLabel:function(){return"Orion workspace server"}},{name:"FORM+OpenId"});g.connect()});
//@ sourceMappingURL=built-authenticationPlugin.js.map