/*

 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) 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, 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

 Copyright (c) 2010, 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) 2010, 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) 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,h){"function"===typeof define&&define.amd?define("orion/Deferred",h):"object"===typeof exports?module.exports=h():(c.orion=c.orion||{},c.orion.Deferred=h())})(this,function(){function c(){for(var c;c=f.shift();)c();d=!1}function h(c){f.push(c);d||(d=!0,e())}function m(d){return function(c){d(c)}}function l(){function d(){for(var g;g=a.shift();){var c=g.deferred,f="fulfilled"===b?"resolve":"reject";g=g[f];if("function"===typeof g)try{var e=g(r),h=e&&("object"===typeof e||"function"===typeof e)&&
e.then;if("function"===typeof h)if(e===c.promise)c.reject(new TypeError);else{var k=e.cancel;"function"===typeof k?c._parentCancel=k.bind(e):delete c._parentCancel;h.call(e,m(c.resolve),m(c.reject),m(c.progress))}else c.resolve(e)}catch(n){c.reject(n)}else c[f](r)}}function c(q){delete g._parentCancel;b="rejected";r=q;a.length&&h(d)}function f(q){function e(a){return function(g){(!b||"assumed"===b)&&a(g)}}delete g._parentCancel;try{var m=q&&("object"===typeof q||"function"===typeof q)&&q.then;if("function"===
typeof m)if(q===g)c(new TypeError);else{b="assumed";var s=q&&q.cancel;if("function"!==typeof s){var v=new l;q=v.promise;try{m(v.resolve,v.reject,v.progress)}catch(x){v.reject(x)}s=q.cancel;m=q.then}r=q;m.call(q,e(f),e(c));g._parentCancel=s.bind(q)}else b="fulfilled",r=q,a.length&&h(d)}catch(u){e(c)(u)}}function e(){var a=g._parentCancel;a?(delete g._parentCancel,a()):b||(a=Error("Cancel"),a.name="Cancel",c(a))}var r,b,a=[],g=this;this.resolve=function(a){b||f(a);return g};this.reject=function(a){b||
c(a);return g};this.progress=function(d){b||a.forEach(function(a){if(a.progress)try{a.progress(d)}catch(b){}});return g.promise};this.cancel=function(){g._parentCancel?setTimeout(e,0):e();return g};this.then=function(c,e,f){var k=new l;k._parentCancel=g.promise.cancel;a.push({resolve:c,reject:e,progress:f,deferred:k});("fulfilled"===b||"rejected"===b)&&h(d);return k.promise};this.promise={then:g.then,cancel:g.cancel}}var f=[],d=!1,e=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var d=
process.nextTick;return function(){d(c)}}if("function"===typeof MutationObserver){var e=document.createElement("div");(new MutationObserver(c)).observe(e,{attributes:!0});return function(){e.setAttribute("class","_tick")}}return function(){setTimeout(c,0)}}();l.all=function(d,c){function e(d,c){a||(b[d]=c,0===--h&&g.resolve(b))}function f(b,d){if(!a){if(c)try{e(b,c(d));return}catch(h){d=h}g.reject(d)}}var h=d.length,b=[],a=!1,g=new l;g.then(void 0,function(){a=!0;d.forEach(function(a){a.cancel&&a.cancel()})});
0===h?g.resolve(b):d.forEach(function(a,b){a.then(e.bind(void 0,b),f.bind(void 0,b))});return g.promise};l.when=function(d,c,e,f){var h;d&&"function"===typeof d.then||(h=new l,h.resolve(d),d=h.promise);return d.then(c,e,f)};return l});
(function(c,h){"function"===typeof define&&define.amd?define("orion/plugin",["orion/Deferred"],h):"object"===typeof exports?module.exports=h(require("orion/Deferred")):(c.orion=c.orion||{},c.orion.PluginProvider=h(c.orion.Deferred))})(this,function(c){function h(c,h){this.__objectId=c;this.__methods=h}return function(m){function l(b){a&&("undefined"===typeof ArrayBuffer&&(b=JSON.stringify(b)),a===self?a.postMessage(b):a.postMessage(b,"*"))}function f(){var a=[];Object.keys(x).forEach(function(b){var g=
x[b];a.push({serviceId:b,names:g.names,methods:g.methods,properties:g.properties})});return{headers:r||{},services:a}}function d(a,b){if(b&&b instanceof XMLHttpRequest){var g,d;try{g=b.status,d=b.statusText}catch(p){g=0,d=""}return{status:g||0,statusText:d}}return b}function e(a){var b=a?JSON.parse(JSON.stringify(a,d)):a;a instanceof Error&&(b.__isError=!0,b.message=b.message||a.message,b.name=b.name||a.name);return b}function n(d){if(!a)return(new c).reject(Error("plugin not connected"));d.id=String(g++);
var e=new c;y[d.id]=e;e.then(null,function(a){b&&(a instanceof Error&&"Cancel"===a.name)&&u({requestId:d.id,method:"cancel",params:a.message?[a.message]:[]})});var f=Object.prototype.toString;d.params.forEach(function(a,p){if("[object Object]"===f.call(a)&&!(a instanceof h)){var b,g;for(b in a)"[object Function]"===f.call(a[b])&&(g=g||[],g.push(b));if(g){var c=q++;v[c]=a;b=function(){delete v[c]};e.then(b,b);d.params[p]=new h(c,g)}}});u(d);return e.promise}function k(a,b){a||0===a?u({id:a,result:null,
error:b}):console.log(b)}function t(a,b,g,d){d.forEach(function(a,p){if(a&&"undefined"!==typeof a.__objectId){var b={};a.__methods.forEach(function(p){b[p]=function(){return n({objectId:a.__objectId,method:p,params:Array.prototype.slice.call(arguments)})}});d[p]=b}});var p=void 0===typeof a?null:{id:a,result:null,error:null};try{var c=g.apply(b,d);p&&(c&&"function"===typeof c.then?(w[a]=c,c.then(function(b){delete w[a];p.result=b;u(p)},function(b){w[a]&&(delete w[a],p.error=e(b),u(p))},function(){u({responseId:a,
method:"progress",params:Array.prototype.slice.call(arguments)})})):(p.result=c,u(p)))}catch(f){p&&(p.error=e(f),u(p))}}function s(b){if(!(b.source!==a&&"undefined"!==typeof window)){b="string"!==typeof b.data?b.data:JSON.parse(b.data);try{if(b.method){var g=b.method,d=b.params||[];if("serviceId"in b){var c=x[b.serviceId];c||k(b.id,"service not found");c=c.implementation;g in c?t(b.id,c,c[g],d):k(b.id,"method not found")}else if("objectId"in b){var p=v[b.objectId];p||k(b.id,"object not found");!g in
p?t(b.id,p,p[g],d):k(b.id,"method not found")}else if("requestId"in b){var e=w[b.requestId];e&&("cancel"===g&&e.cancel)&&e.cancel.apply(e,d)}else if("responseId"in b){var f=y[b.responseId];f&&("progress"===g&&f.progress)&&f.progress.apply(f,d)}else throw Error("Bad method: "+b.method);}else{var q=y[String(b.id)];delete y[String(b.id)];b.error?q.reject(b.error):q.resolve(b.result)}}catch(h){console.log("Plugin._messageHandler "+h)}}}var r=m,b=!1,a=null,g=0,q=0,z=0,w={},y={},v={},x={},u=l;this.updateHeaders=
function(a){if(b)throw Error("Cannot update headers. Plugin Provider is connected");r=a};this.registerServiceProvider=this.registerService=function(a,g,d){if(b)throw Error("Cannot register service. Plugin Provider is connected");"string"===typeof a?a=[a]:Array.isArray(a)||(a=[]);var c=null,p=[];for(c in g)"function"===typeof g[c]&&p.push(c);x[z++]={names:a,methods:p,implementation:g,properties:d||{},listeners:{}}};this.connect=function(g,d){if(!b){if("undefined"===typeof window)a=self;else if(window!==
window.parent)a=window.parent;else if(null!==window.opener)a=window.opener;else{d&&d("No valid plugin target");return}addEventListener("message",s,!1);var c={method:"plugin",params:[f()]};l(c);b=!0}g&&g()};this.disconnect=function(){b&&(removeEventListener("message",s),a=null,b=!1)}}});
define("orion/xhr",["orion/Deferred"],function(c){function h(c,h,f,d){var e="undefined"!==typeof f.response?f.response:f.responseText,n;try{n=f.status}catch(k){n=0}c={args:h,response:e,responseText:"string"===typeof e?e:null,status:n,url:c,xhr:f};"undefined"!==typeof d&&(c.error=d);return c}return function(m,l,f){f=f||{};var d=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,e=new c,n=f.headers||{},k=f.log||!1,t;"undefined"===typeof n["X-Requested-With"]&&(n["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof f.data&&("POST"===m||"PUT"===m))t=f.data;var s=!1,r=!1;e.promise.then(void 0,function(a){s=!0;!r&&(a instanceof Error&&"Cancel"===a.name)&&d.abort()});d.onabort=function(){r=!0;if(!s){var a=Error("Cancel");a.name="Cancel";e.reject(a)}};d.onload=function(){var a=h(l,f,d);200<=d.status&&400>d.status?e.resolve(a):(e.reject(a),k&&"undefined"!==typeof console&&console.log(Error(d.statusText)))};d.onerror=function(){var a=h(l,f,d);e.reject(a);k&&"undefined"!==typeof console&&console.log(Error(d.statusText))};
d.onprogress=function(a){a.xhr=d;e.progress(a)};try{d.open(m,l,!0);"string"===typeof f.responseType&&(d.responseType=f.responseType);if("number"===typeof f.timeout)if("number"===typeof d.timeout)d.timeout=f.timeout,d.addEventListener("timeout",function(a){e.reject(h(l,f,d,"Timeout exceeded"))});else{var b=setTimeout(function(){e.reject(h(l,f,d,"Timeout exceeded"))},f.timeout);e.promise.then(clearTimeout.bind(null,b),clearTimeout.bind(null,b))}Object.keys(n).forEach(function(a){d.setRequestHeader(a,
n[a])});d.send(t||null)}catch(a){e.reject(h(l,f,d,a))}return e.promise}});
(function(){function c(a){if("string"!==typeof a)throw new TypeError;}function h(a){return a?a.split("\x26"):[]}function m(a){return 0===a.length?"":a.join("\x26")}function l(a){var b=/([^=]*)(?:=?)(.*)/.exec(a);a=b[1]?decodeURIComponent(b[1]):"";b=b[2]?decodeURIComponent(b[2]):"";return[a,b]}function f(a){var b=encodeURIComponent(a[0]);a[1]&&(b+="\x3d"+encodeURIComponent(a[1]));return b}function d(a,b){var d="",g=[],c=0;return{next:function(){d!==a.query&&(d=a.query,g=h(d));if(c<g.length){var e=
l(g[c++]);switch(b){case "keys":return e[0];case "values":return e[1];case "keys+values":return[e[0],e[1]];default:throw new TypeError;}}throw B;}}}function e(a){Object.defineProperty(this,"_url",{get:function(){return a._url}})}function n(a){return a?/[1-9]\d*$/.exec(a)[0]:""}function k(a){var b=[];a.split("/").forEach(function(a){".."===a?b.pop():"."!==a&&b.push(a)});return b.join("/")}function t(a){return a.replace(/\s/g,function(a){return"%"+a.charCodeAt(0).toString(16)})}function s(a,b){if("string"!==
typeof a)throw new TypeError;a=t(a);var d=g.exec(a);if(!d)return null;var c={};c.scheme=d[1]||"";if(c.scheme&&!z.test(c.scheme))return null;var e=d[2];if(e&&(e=q.exec(e),c.userinfo=e[1],c.host=e[2],c.port=e[3],c.port&&!w.test(c.port)))return null;c.path=d[3];c.query=d[4];c.fragment=d[5];!c.scheme&&b&&(c.scheme=b.scheme,!c.host&&b.host&&(c.userinfo=b.userinfo,c.host=b.host,c.port=b.port,c.pathRelative=!0));c.pathRelative&&(c.path?"/"!==c.path[0]&&(d=/^(.*\/)[^\/]*$/.exec(b.path)[1]||"/",c.path=d+c.path):
c.path=b.path);c.scheme&&(c.scheme=c.scheme.toLowerCase());c.port&&(c.port=n(c.port));c.host&&c.path&&(c.path=k(c.path));return c}function r(a,b){var c;if(b){b=b.href||b;c=s(b);if(!c||!c.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:c})}c=s(a,c);if(!c)throw new SyntaxError;Object.defineProperty(this,"_input",{value:a,writable:!0});Object.defineProperty(this,"_url",{value:c,writable:!0});var d=new e(this);Object.defineProperty(this,"query",{get:function(){return this._url?
d:null},enumerable:!0})}try{var b;if("function"===typeof window.URL&&0!==window.URL.length&&"http:"===(b=new window.URL("http://www.w3.org?q")).protocol&&b.query)return}catch(a){}var g=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,q=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,z=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,w=/^\d*$/,y=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,v=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,x=/^([^?#\s]*)$/,u=/^([^\s]*)$/,C=/^\S*$/,A=/([^:]*):?(.*)/,B="undefined"!==
typeof StopIteration?StopIteration:Error("Stop Iteration"),D={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(e.prototype,{get:{value:function(a){c(a);var b;h(this._url.query).some(function(c){c=l(c);if(c[0]===a)return b=c[1],!0});return b},enumerable:!0},set:{value:function(a,b){c(a);c(b);var d=h(this._url.query);d.some(function(c,g){var e=l(c);if(e[0]===a)return e[1]=b,d[g]=f(e),!0})||d.push(f([a,b]));this._url.query=m(d)},enumerable:!0},has:{value:function(a){c(a);
return h(this._url.query).some(function(b){if(l(b)[0]===a)return!0})},enumerable:!0},"delete":{value:function(a){c(a);var b=h(this._url.query),d=b.filter(function(b){return l(b)[0]!==a});return d.length!==b.length?(this._url.query=m(d),!0):!1},enumerable:!0},clear:{value:function(){this._url.query=""},enumerable:!0},forEach:{value:function(a,b){if("function"!==typeof a)throw new TypeError;var c=d(this._url,"keys+values");try{for(;;){var g=c.next();a.call(b,g[1],g[0],this)}}catch(e){if(e!==B)throw e;
}},enumerable:!0},keys:{value:function(){return d(this._url,"keys")},enumerable:!0},values:{value:function(){return d(this._url,"values")},enumerable:!0},items:{value:function(){return d(this._url,"keys+values")}},size:{get:function(){return h(this._url.query).length},enumerable:!0},getAll:{value:function(a){c(a);var b=[];h(this._url.query).forEach(function(c){c=l(c);c[0]===a&&b.push(c[1])});return b},enumerable:!0},append:{value:function(a,b){c(a);c(b);var d=h(this._url.query);d.push(f([a,b]));this._url.query=
m(d)},enumerable:!0}});Object.defineProperties(r.prototype,{href:{get:function(){var a;if(this._url){a=this._url;var b=a.scheme?a.scheme+":":"";a.host&&(b+="//",a.userinfo&&(b+=a.userinfo+"@"),b+=a.host,a.port&&(b+=":"+a.port));b+=a.path;a.query&&(b+="?"+a.query);a.fragment&&(b+="#"+a.fragment);a=b}else a=this._input;return a},set:function(a){c(a);this._input=a;this._url=s(this._input,this._baseURL)},enumerable:!0},origin:{get:function(){return this._url&&this._url.host?this.protocol+"//"+this.host:
""},enumerable:!0},protocol:{get:function(){return this._url?this._url.scheme+":":":"},set:function(a){c(a);if(this._url&&(a=":"===a.slice(-1)?a.substring(0,a.length-1):a,""===a||z.test(a)))this._url.scheme=a.toLowerCase()},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(a){c(a);this._url&&(this._url.userinfo=a)}},username:{get:function(){if(!this._url)return"";var a=A.exec(this._userinfo);return decodeURIComponent(a[1]||"")},set:function(a){c(a);if(this._url){var b=
A.exec(this._userinfo);a=[encodeURIComponent(a||"")];b[2]&&a.push(b[2]);this._userinfo=a.join(":")}},enumerable:!0},password:{get:function(){if(!this._url)return"";var a=A.exec(this._userinfo);return decodeURIComponent(a[2]||"")},set:function(a){c(a);if(this._url){var b=[A.exec(this._userinfo)[1]||""];a&&b.push(encodeURIComponent(a));this._userinfo=b.join(":")}},enumerable:!0},host:{get:function(){var a="";this._url&&this._url.host&&(a+=this._url.host,this._url.port&&(a+=":"+this._url.port));return a},
set:function(a){c(a);if(this._url&&(a=v.exec(a)))this._url.host=a[1],this._url.port=n(a[2])},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(a){c(a);this._url&&y.exec(a)&&(this._url.host=a)},enumerable:!0},port:{get:function(){var a=this._url?this._url.port||"":"";a&&a===D[this.protocol]&&(a="");return a},set:function(a){c(a);this._url&&w.exec(a)&&(this._url.port=n(a))},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(a){c(a);
this._url&&x.exec(a)&&(this._url.host&&(a&&"/"!==a[0])&&(a="/"+a),this._url.path=a?k(a):"")},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(a){c(a);this._url&&(a&&"?"===a[0]&&(a=a.substring(1)),u.exec(a)&&(this._url.query=a))},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(a){c(a);this._url&&(a&&"#"===a[0]&&(a=a.substring(1)),C.exec(a)&&(this._url.fragment=a))},enumerable:!0}});
if((b=window.URL||window.webkitURL)&&b.createObjectURL)Object.defineProperty(r,"createObjectURL",{value:b.createObjectURL.bind(b),enumerable:!1}),Object.defineProperty(r,"revokeObjectURL",{value:b.revokeObjectURL.bind(b),enumerable:!1});window.URL=r})();define("orion/URL-shim",function(){});
define("orion/operation",["orion/xhr","orion/Deferred"],function(c,h){function m(f,d,e,h){c("GET",f,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(k){k=k.response?JSON.parse(k.response):null;d.progress(k);!k.type||"loadstart"===k.type||"progress"===k.type?setTimeout(function(){m(f,d,e,h)},2E3):("error"===k.type||"abort"===k.type?d.reject(h?h(k):k.Result):d.resolve(e?e(k):k.Result.JsonData),k.Location||c("DELETE",f,{headers:{"Orion-Version":"1"},timeout:15E3}))},function(c){var e=c;if(void 0!==
c.responseText){e=c.responseText;try{e=JSON.parse(c.responseText)}catch(f){}}void 0!==e.Message?(e.HttpCode=void 0===e.HttpCode?c.status:e.HttpCode,e.Severity=void 0===e.Severity?"Error":e.Severity,d.reject(e)):d.reject({Severity:"Error",Message:e,HttpCode:c.status})})}function l(f,d){d.then(null,function(d){d instanceof Error&&"Cancel"===d.name&&c("PUT",f,{headers:{"Orion-Version":"1"},data:JSON.stringify({abort:!0}),timeout:15E3})})}return{handle:function(c,d,e){var n=new h;l(c,n);m(c,n,d,e);return n}}});
define("orion/form",[],function(){function c(c){return encodeURIComponent(c).replace(/[!'()*]/g,escape).replace("%20","+")}return{encodeFormData:function(h){h=h||{};for(var m=Object.keys(h),l=[],f=0;f<m.length;f++){var d=m[f],e=h[d];l.push(c(d)+"\x3d"+c(e))}return l.join("\x26")},encodeSlug:function(c){return c.replace(/([^\u0020-\u007e]|%)+/g,encodeURIComponent)}}});
define("plugins/filePlugin/fileImpl",["orion/Deferred","orion/xhr","orion/URL-shim","orion/operation","orion/form"],function(c,h,m,l,f){function d(b){b&&"object"===typeof b&&Object.keys(b).forEach(function(a){var c=b[a];-1!==a.indexOf("Location")?(r.href=c,b[a]=r.href):d(c)});return b}function e(b,a,c){var d=h;a&&(a=a.replace(";","%3B"));return d(b,a,c)}function n(){return e.apply(null,Array.prototype.slice.call(arguments)).then(function(b){if(b.xhr&&202===b.xhr.status){b=b.response?JSON.parse(b.response):
null;var a=new c;l.handle(b.Location,function(a){return a.Result}).then(a.resolve,a.reject,a.progress);return a}return b.response?JSON.parse(b.response):null})}function k(b){var a;a=b.keyword;for(var c="",d=0;d<a.length;d++){var e=a.charAt(d);0<='+-\x26|!(){}[]^"~:\\'.indexOf(e)&&(c+="\\");c+=e}a=c;c=b.sort;b.nameSearch?(d=/\*$/.test(b.keyword)?"":"*",a="NameLower:"+a+d):b.fileType&&"*.*"!==b.fileType?""!==a?(0<=a.indexOf(" ")&&(a='"'+a+'"'),a=encodeURIComponent(a)+"+NameLower:*."+b.fileType):(a=
"NameLower:*."+b.fileType,c=c.replace("Path","NameLower")):b.fileNamePatterns&&0<b.fileNamePatterns.length?""!==a?(0<=a.indexOf(" ")&&(a='"'+a+'"'),a=encodeURIComponent(a)+"+Name:"+b.fileNamePatterns.join("/")):(a="Name:"+b.fileNamePatterns.join("/"),c=c.replace("Path","Name")):a=0<=a.indexOf(" ")?encodeURIComponent('"'+a+'"'):encodeURIComponent(a);return"?sort\x3d"+c+"\x26rows\x3d"+b.rows+"\x26start\x3d"+b.start+"\x26q\x3d"+a+"+Location:"+b.resource+"*"}function t(b,a){this.fileBase=b;this.makeAbsolute=
(this.workspaceBase=a)&&-1!==a.indexOf("://")}function s(b,a,g,f){return e(b,a,{responseType:"arraybuffer",headers:g?g:{"Orion-Version":"1"},data:f,log:!1}).then(function(a){return a.response},function(a){var b="Unknown Error";a.status&&404===a.status?b="File not found.":a.xhr&&a.xhr.statusText&&(b=a.xhr.statusText);a.responseText=JSON.stringify({Severity:"Error",Message:b});return(new c).reject(a)}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))}var r=document.createElement("a");
t.prototype={fetchChildren:function(b){if(b===this.fileBase)return this.loadWorkspace(b).then(function(a){return a.Children||[]});-1===b.indexOf("?depth\x3d")&&(b+="?depth\x3d1");return e("GET",b,{headers:{"Orion-Version":"1","Content-Type":"charset\x3dUTF-8"},timeout:15E3}).then(function(a){return(a.response?JSON.parse(a.response):{}).Children||[]}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},_createWorkspace:function(b){return e("POST",this.workspaceBase,{headers:{"Orion-Version":"1",
Slug:f.encodeSlug(b)},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):{}})},loadWorkspaces:function(){return e("GET",this.workspaceBase,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){return(b.response?JSON.parse(b.response):{}).Workspaces}).then(function(b){this.makeAbsolute&&d(b);return b}.bind(this))},loadWorkspace:function(b){b===this.fileBase&&(b=null);return e("GET",b?b:this.workspaceBase,{headers:{"Orion-Version":"1"},timeout:15E3,log:!1}).then(function(a){a=
a.response?JSON.parse(a.response):{};return b?a:0<a.Workspaces.length?this.loadWorkspace(a.Workspaces[0].Location):this._createWorkspace("Orion Content")}.bind(this)).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},createProject:function(b,a,c,f){if(b)return a={Name:a},c&&(a.ContentLocation=c),f&&(a.CreateIfDoesntExist=f),e("POST",b,{headers:{"Orion-Version":"1","Content-Type":"application/json;charset\x3dUTF-8"},timeout:15E3,data:JSON.stringify(a)}).then(function(a){return a.response?
JSON.parse(a.response):null}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this));console.error("url is undefined, make sure you're signed in before creating a project")},createFolder:function(b,a){return e("POST",b,{headers:{"Orion-Version":"1","X-Create-Options":"no-overwrite",Slug:f.encodeSlug(a),"Content-Type":"application/json;charset\x3dUTF-8"},data:JSON.stringify({Name:a,LocalTimeStamp:"0",Directory:"true"}),timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):
null}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},createFile:function(b,a){return e("POST",b,{headers:{"Orion-Version":"1","X-Create-Options":"no-overwrite",Slug:f.encodeSlug(a),"Content-Type":"application/json;charset\x3dUTF-8"},data:JSON.stringify({Name:a,LocalTimeStamp:"0",Directory:"false"}),timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},deleteFile:function(b){return e("DELETE",
b,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},moveFile:function(b,a,c){return this._doCopyMove(b,a,!0,c).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},copyFile:function(b,a,c){return this._doCopyMove(b,a,!1,c).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},_doCopyMove:function(b,a,c,d){d||(d=b.split("/"),d=d.pop()||d.pop());return e("POST",
a,{headers:{"Orion-Version":"1",Slug:f.encodeSlug(d),"X-Create-Options":"no-overwrite,"+(c?"move":"copy"),"Content-Type":"application/json;charset\x3dUTF-8"},data:JSON.stringify({Location:b,Name:d}),timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):null})},read:function(b,a,c){b=new URL(b,window.location);a&&b.query.set("parts","meta");return e("GET",b.href,{timeout:15E3,headers:{"Orion-Version":"1"},log:!1}).then(function(b){return a?b.response?JSON.parse(b.response):null:
c?{result:b.response,acceptPatch:b.xhr.getResponseHeader("Accept-Patch")}:b.response}).then(function(a){this.makeAbsolute&&d(c?a.result:a);return a}.bind(this))},write:function(b,a,c){b=new URL(b,window.location);var f={"Orion-Version":"1","Content-Type":"text/plain;charset\x3dUTF-8"};c&&c.ETag&&(f["If-Match"]=c.ETag);c={timeout:15E3,headers:f,data:a,log:!1};var h="PUT";"string"!==typeof a&&(a.sourceLocation?(c.query={source:a.sourceLocation},c.data=null):a.diff?(h="POST",f["X-HTTP-Method-Override"]=
"PATCH",c.data=JSON.stringify(c.data)):b.query.set("parts","meta"));return e(h,b.href,c).then(function(a){return a.response?JSON.parse(a.response):null}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},remoteImport:function(b,a){var c={"Orion-Version":"1"};a.OptionHeader&&(c["X-Xfer-Options"]=a.OptionHeader,delete a.OptionHeader);return n("POST",b,{headers:c,data:JSON.stringify(a),timeout:15E3}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},remoteExport:function(b,
a){var c={"Orion-Version":"1"};a.OptionHeader&&(c["X-Xfer-Options"]=a.OptionHeader,delete a.OptionHeader);return n("POST",b,{headers:c,data:JSON.stringify(a),timeout:15E3}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))},search:function(b){b=k(b);return e("GET",this.fileBase+"/../filesearch"+b,{headers:{Accept:"application/json","Orion-Version":"1"},timeout:6E4}).then(function(a){return a.response?JSON.parse(a.response):{}}).then(function(a){this.makeAbsolute&&d(a);return a}.bind(this))}};
window.Blob&&(t.prototype.readBlob=function(b){return s("GET",b).then(function(a){return a})},t.prototype.writeBlob=function(b,a,c){var d={};c&&c.ETag&&(d["If-Match"]=c.ETag);return s("PUT",b,d,a)});return t});
define("domReady",[],function(){function c(){if(!e){e=!0;f&&clearInterval(f);var c=k;if(e&&c.length){k=[];var d;for(d=0;d<c.length;d+=1)c[d](n)}}}function h(c){e?c(n):k.push(c);return h}var m,l,f,d="undefined"!==typeof window&&window.document,e=!d,n=d?document:null,k=[];if(d){if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(window.attachEvent){window.attachEvent("onload",c);l=document.createElement("div");try{m=null===window.frameElement}catch(t){}l.doScroll&&
(m&&window.external)&&(f=setInterval(function(){try{l.doScroll(),c()}catch(d){}},30))}"complete"===document.readyState&&c()}h.version="2.0.1";h.load=function(c,d,b,a){a.isBuild?b(null):h(b)};return h});
define("plugins/fileClientPlugin",["orion/Deferred","orion/plugin","plugins/filePlugin/fileImpl","domReady!"],function(c,h,m){function l(c){if(f)try{if(window.location.host===parent.location.host&&window.location.protocol===parent.location.protocol)return c.substring(parent.location.href.indexOf(parent.location.host)+parent.location.host.length);f=!1}catch(d){f=!1}return c}var f=!0,d=document.createElement("a");d.href="../mixloginstatic/LoginWindow.html";h=new h({name:"Orion File Service",version:"1.0",
description:"This plugin provides file access to a user's workspace.",login:d.href});d.href="../file";c=l(d.href);d.href="../workspace";var e=l(d.href);d.href="..";d=l(d.href);m=new m(c,e);h.registerService("orion.core.file",m,{Name:"Orion Content",NameKey:"Orion Content",nls:"orion/navigate/nls/messages",top:c,pattern:d});h.connect()});
//@ sourceMappingURL=fileClientPlugin.js.map