/*

 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, 2014 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) 2013 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(b,d){"function"===typeof define&&define.amd?define("orion/Deferred",d):"object"===typeof exports?module.exports=d():(b.orion=b.orion||{},b.orion.Deferred=d())})(this,function(){function b(){for(var c;c=w.shift();)c();u=!1}function d(c){w.push(c);u||(u=!0,x())}function s(c){return function(b){c(b)}}function n(){function c(){for(var a;a=h.shift();){var m=a.deferred,b="fulfilled"===g?"resolve":"reject";a=a[b];if("function"===typeof a)try{var c=a(l),e=c&&("object"===typeof c||"function"===typeof c)&&
c.then;if("function"===typeof e)if(c===m.promise)m.reject(new TypeError);else{var d=c.cancel;"function"===typeof d?m._parentCancel=d.bind(c):delete m._parentCancel;e.call(c,s(m.resolve),s(m.reject),s(m.progress))}else m.resolve(c)}catch(t){m.reject(t)}else m[b](l)}}function b(a){delete e._parentCancel;g="rejected";l=a;h.length&&d(c)}function v(a){function m(f){return function(a){(!g||"assumed"===g)&&f(a)}}delete e._parentCancel;try{var p=a&&("object"===typeof a||"function"===typeof a)&&a.then;if("function"===
typeof p)if(a===e)b(new TypeError);else{g="assumed";var r=a&&a.cancel;if("function"!==typeof r){var k=new n;a=k.promise;try{p(k.resolve,k.reject,k.progress)}catch(s){k.reject(s)}r=a.cancel;p=a.then}l=a;p.call(a,m(v),m(b));e._parentCancel=r.bind(a)}else g="fulfilled",l=a,h.length&&d(c)}catch(q){m(b)(q)}}function k(){var a=e._parentCancel;a?(delete e._parentCancel,a()):g||(a=Error("Cancel"),a.name="Cancel",b(a))}var l,g,h=[],e=this;this.resolve=function(a){g||v(a);return e};this.reject=function(a){g||
b(a);return e};this.progress=function(a){g||h.forEach(function(c){if(c.progress)try{c.progress(a)}catch(b){}});return e.promise};this.cancel=function(){e._parentCancel?setTimeout(k,0):k();return e};this.then=function(a,b,l){var k=new n;k._parentCancel=e.promise.cancel;h.push({resolve:a,reject:b,progress:l,deferred:k});("fulfilled"===g||"rejected"===g)&&d(c);return k.promise};this.promise={then:e.then,cancel:e.cancel}}var w=[],u=!1,x=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var c=
process.nextTick;return function(){c(b)}}if("function"===typeof MutationObserver){var d=document.createElement("div");(new MutationObserver(b)).observe(d,{attributes:!0});return function(){d.setAttribute("class","_tick")}}return function(){setTimeout(b,0)}}();n.all=function(c,b){function d(a,b){h||(g[a]=b,0===--l&&e.resolve(g))}function k(a,c){if(!h){if(b)try{d(a,b(c));return}catch(g){c=g}e.reject(c)}}var l=c.length,g=[],h=!1,e=new n;e.then(void 0,function(){h=!0;c.forEach(function(a){a.cancel&&a.cancel()})});
0===l?e.resolve(g):c.forEach(function(a,c){a.then(d.bind(void 0,c),k.bind(void 0,c))});return e.promise};n.when=function(c,b,d,k){var l;c&&"function"===typeof c.then||(l=new n,l.resolve(c),c=l.promise);return c.then(b,d,k)};return n});
(function(b,d){"function"===typeof define&&define.amd?define("orion/plugin",["orion/Deferred"],d):"object"===typeof exports?module.exports=d(require("orion/Deferred")):(b.orion=b.orion||{},b.orion.PluginProvider=d(b.orion.Deferred))})(this,function(b){function d(b,d){this.__objectId=b;this.__methods=d}return function(s){function n(f){h&&("undefined"===typeof ArrayBuffer&&(f=JSON.stringify(f)),h===self?h.postMessage(f):h.postMessage(f,"*"))}function w(){var f=[];Object.keys(y).forEach(function(a){var b=
y[a];f.push({serviceId:a,names:b.names,methods:b.methods,properties:b.properties})});return{headers:l||{},services:f}}function u(f,a){if(a&&a instanceof XMLHttpRequest){var b,c;try{b=a.status,c=a.statusText}catch(d){b=0,c=""}return{status:b||0,statusText:c}}return a}function x(f){var a=f?JSON.parse(JSON.stringify(f,u)):f;f instanceof Error&&(a.__isError=!0,a.message=a.message||f.message,a.name=a.name||f.name);return a}function c(f){if(!h)return(new b).reject(Error("plugin not connected"));f.id=String(e++);
var c=new b;r[f.id]=c;c.then(null,function(a){g&&(a instanceof Error&&"Cancel"===a.name)&&q({requestId:f.id,method:"cancel",params:a.message?[a.message]:[]})});var k=Object.prototype.toString;f.params.forEach(function(b,g){if("[object Object]"===k.call(b)&&!(b instanceof d)){var e,h;for(e in b)"[object Function]"===k.call(b[e])&&(h=h||[],h.push(e));if(h){var l=a++;z[l]=b;e=function(){delete z[l]};c.then(e,e);f.params[g]=new d(l,h)}}});q(f);return c.promise}function t(f,a){f||0===f?q({id:f,result:null,
error:a}):console.log(a)}function v(f,a,b,e){e.forEach(function(f,a){if(f&&"undefined"!==typeof f.__objectId){var b={};f.__methods.forEach(function(a){b[a]=function(){return c({objectId:f.__objectId,method:a,params:Array.prototype.slice.call(arguments)})}});e[a]=b}});var d=void 0===typeof f?null:{id:f,result:null,error:null};try{var g=b.apply(a,e);d&&(g&&"function"===typeof g.then?(p[f]=g,g.then(function(a){delete p[f];d.result=a;q(d)},function(a){p[f]&&(delete p[f],d.error=x(a),q(d))},function(){q({responseId:f,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(d.result=g,q(d)))}catch(h){d&&(d.error=x(h),q(d))}}function k(a){if(!(a.source!==h&&"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=y[a.serviceId];d||t(a.id,"service not found");d=d.implementation;b in d?v(a.id,d,d[b],c):t(a.id,"method not found")}else if("objectId"in a){var e=z[a.objectId];e||t(a.id,"object not found");!b in
e?v(a.id,e,e[b],c):t(a.id,"method not found")}else if("requestId"in a){var g=p[a.requestId];g&&("cancel"===b&&g.cancel)&&g.cancel.apply(g,c)}else if("responseId"in a){var k=r[a.responseId];k&&("progress"===b&&k.progress)&&k.progress.apply(k,c)}else throw Error("Bad method: "+a.method);}else{var l=r[String(a.id)];delete r[String(a.id)];a.error?l.reject(a.error):l.resolve(a.result)}}catch(m){console.log("Plugin._messageHandler "+m)}}}var l=s,g=!1,h=null,e=0,a=0,m=0,p={},r={},z={},y={},q=n;this.updateHeaders=
function(a){if(g)throw Error("Cannot update headers. Plugin Provider is connected");l=a};this.registerServiceProvider=this.registerService=function(a,b,c){if(g)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);y[m++]={names:a,methods:e,implementation:b,properties:c||{},listeners:{}}};this.connect=function(a,b){if(!g){if("undefined"===typeof window)h=self;else if(window!==
window.parent)h=window.parent;else if(null!==window.opener)h=window.opener;else{b&&b("No valid plugin target");return}addEventListener("message",k,!1);var c={method:"plugin",params:[w()]};n(c);g=!0}a&&a()};this.disconnect=function(){g&&(removeEventListener("message",k),h=null,g=!1)}}});
define("shell/plugins/shellPagePlugin",["orion/plugin"],function(b){b=new b({name:"Orion Shell Page Service",version:"1.0",description:"This plugin integrates access to Orion's Shell page into other Orion pages."});b.registerService("orion.navigate.command",{},{nameKey:"Shell",id:"eclipse.shell.open",tooltipKey:"Open Shell page",nls:"orion/shell/nls/messages",validationProperties:[{source:"ChildrenLocation|ContentLocation",variableName:"ShellLocation",replacements:[{pattern:"\\?depth\x3d1$",replacement:""}]}],
uriTemplate:"{+OrionHome}/shell/shellPage.html#{,ShellLocation}",forceSingleItem:!0});b.registerService("orion.page.link.related",null,{id:"eclipse.shell.open",category:"shell",order:10});b.connect()});
//@ sourceMappingURL=shellPagePlugin.js.map