text: Object.create||(Object.create=function(){function t(){}return function(e){if(1!=arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return t.prototype=e,new t}}()),Object.keys||(Object.keys=function(e,t,n){for(t in n=[],e)n.hasOwnProperty.call(e,t)&&n.push(t);return n}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(e){if(null==this)throw new TypeError;var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=2<=arguments.length?arguments[1]:void 0,o=0;o<n;o++)o in t&&e.call(r,t[o],o,t);return this}),Array.prototype.filter||(Array.prototype.filter=function(r,o){var i=[];return this.forEach(function(e,t,n){r.call(o||void 0,e,t,n)&&i.push(e)}),i}),Array.prototype.map||(Array.prototype.map=function(r,o){var i=[];return this.forEach(function(e,t,n){i.push(r.call(o||void 0,e,t,n))}),i}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),"object"!=typeof window||"object"!=typeof window.location||window.location.assign||(window.location.assign=function(e){window.location=e}),Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");function t(){}var n=[].slice,r=n.call(arguments,1),o=this,i=function(){return o.apply(this instanceof t?this:e||window,r.concat(n.call(arguments)))};return t.prototype=this.prototype,i.prototype=new t,i});var hello=function(e){return hello.use(e)};hello.utils={extend:function(n){return Array.prototype.slice.call(arguments,1).forEach(function(e){if(Array.isArray(n)&&Array.isArray(e))Array.prototype.push.apply(n,e);else if(n instanceof Object&&e instanceof Object&&n!==e)for(var t in e)n[t]=hello.utils.extend(n[t],e[t]);else Array.isArray(e)&&(e=e.slice(0)),n=e}),n}},hello.utils.extend(hello,{settings:{redirect_uri:window.location.href.split("#")[0],response_type:"token",display:"popup",state:"",oauth_proxy:"https://auth-server.herokuapp.com/proxy",timeout:2e4,popup:{resizable:1,scrollbars:1,width:500,height:550},scope:["basic"],scope_map:{basic:""},default_service:null,force:null,page_uri:window.location.href},services:{},use:function(e){var t=Object.create(this);return t.settings=Object.create(this.settings),e&&(t.settings.default_service=e),t.utils.Event.call(t),t},init:function(e,t){var n=this.utils;if(!e)return this.services;for(var r in e)e.hasOwnProperty(r)&&"object"!=typeof e[r]&&(e[r]={id:e[r]});return n.extend(this.services,e),t&&(n.extend(this.settings,t),"redirect_uri"in t&&(this.settings.redirect_uri=n.url(t.redirect_uri).href)),this},login:function(){var e,t=this,n=t.utils,r=n.error,o=n.Promise(),i=n.args({network:"s",options:"o",callback:"f"},arguments),s=n.diffKey(i.options,t.settings),a=i.options=n.merge(t.settings,i.options||{});function c(e,t){hello.emit(e,t)}if(a.popup=n.merge(t.settings.popup,i.options.popup||{}),i.network=i.network||t.settings.default_service,o.proxy.then(i.callback,i.callback),o.proxy.then(c.bind(this,"auth.login auth"),c.bind(this,"auth.failed auth")),"string"!=typeof i.network||!(i.network in t.services))return o.reject(r("invalid_network","The provided network was not recognized"));var l=t.services[i.network],u=n.globalEvent(function(e){var t;(t=e?JSON.parse(e):r("cancelled","The authentication was not completed")).error?o.reject(t):(n.store(t.network,t),o.fulfill({network:t.network,authResponse:t}))}),p=n.url(a.redirect_uri).href,f=l.oauth.response_type||a.response_type;/\bcode\b/.test(f)&&!l.oauth.grant&&(f=f.replace(/\bcode\b/,"token")),i.qs=n.merge(s,{client_id:encodeURIComponent(l.id),response_type:encodeURIComponent(f),redirect_uri:encodeURIComponent(p),state:{client_id:l.id,network:i.network,display:a.display,callback:u,state:a.state,redirect_uri:p}});var h=n.store(i.network),d=/[,\s]+/,m=t.settings.scope?[t.settings.scope.toString()]:[],y=n.merge(t.settings.scope_map,l.scope||{});if((a.scope&&m.push(a.scope.toString()),h&&"scope"in h&&h.scope instanceof String&&m.push(h.scope),m=m.join(",").split(d),m=n.unique(m).filter(b),i.qs.state.scope=m.join(","),m=(m=m.map(function(e){return e in y?y[e]:e})).join(",").split(d),m=n.unique(m).filter(b),i.qs.scope=m.join(l.scope_delim||","),!1===a.force)&&(h&&"access_token"in h&&h.access_token&&"expires"in h&&h.expires>(new Date).getTime()/1e3&&0===n.diff((h.scope||"").split(d),(i.qs.state.scope||"").split(d)).length))return o.fulfill({unchanged:!0,network:i.network,authResponse:h}),o;if("page"===a.display&&a.page_uri&&(i.qs.state.page_uri=n.url(a.page_uri).href),"login"in l&&"function"==typeof l.login&&l.login(i),(!/\btoken\b/.test(f)||parseInt(l.oauth.version,10)<2||"none"===a.display&&l.oauth.grant&&h&&h.refresh_token)&&(i.qs.state.oauth=l.oauth,i.qs.state.oauth_proxy=a.oauth_proxy),i.qs.state=encodeURIComponent(JSON.stringify(i.qs.state)),1===parseInt(l.oauth.version,10)?e=n.qs(a.oauth_proxy,i.qs,w):"none"===a.display&&l.oauth.grant&&h&&h.refresh_token?(i.qs.refresh_token=h.refresh_token,e=n.qs(a.oauth_proxy,i.qs,w)):e=n.qs(l.oauth.auth,i.qs,w),c("auth.init",i),"none"===a.display)n.iframe(e,p);else if("popup"===a.display)var v=n.popup(e,p,a.popup),g=setInterval(function(){if((!v||v.closed)&&(clearInterval(g),!o.state)){var e=r("cancelled","Login has been cancelled");v||(e=r("blocked","Popup was blocked")),e.network=i.network,o.reject(e)}},100);else window.location=e;return o.proxy;function w(e){return e}function b(e){return!!e}},logout:function(){var t=this.utils,e=t.error,n=t.Promise(),r=t.args({name:"s",options:"o",callback:"f"},arguments);function o(e,t){hello.emit(e,t)}if(r.options=r.options||{},n.proxy.then(r.callback,r.callback),n.proxy.then(o.bind(this,"auth.logout auth"),o.bind(this,"error")),r.name=r.name||this.settings.default_service,r.authResponse=t.store(r.name),!r.name||r.name in this.services)if(r.name&&r.authResponse){var i=function(e){t.store(r.name,null),n.fulfill(hello.utils.merge({network:r.name},e||{}))},s={};if(r.options.force){var a=this.services[r.name].logout;if(a)if("function"==typeof a&&(a=a(i,r)),"string"==typeof a)t.iframe(a),s.force=null,s.message="Logout success on providers site was indeterminate";else if(void 0===a)return n.proxy}i(s)}else n.reject(e("invalid_session","There was no session to remove"));else n.reject(e("invalid_network","The network was unrecognized"));return n.proxy},getAuthResponse:function(e){return(e=e||this.settings.default_service)&&e in this.services&&this.utils.store(e)||null},events:{}}),hello.utils.extend(hello.utils,{error:function(e,t){return{error:{code:e,message:t}}},qs:function(e,t,n){if(t)for(var r in n=n||encodeURIComponent,t){var o=new RegExp("([\\?\\&])"+r+"=[^\\&]*");e.match(o)&&(e=e.replace(o,"$1"+r+"="+n(t[r])),delete t[r])}return this.isEmpty(t)?e:e+(-1<e.indexOf("?")?"&":"?")+this.param(t,n)},param:function(e,t){var n,r,o={};if("string"==typeof e){if(t=t||decodeURIComponent,r=e.replace(/^[\#\?]/,"").match(/([^=\/\&]+)=([^\&]+)/g))for(var i=0;i<r.length;i++)o[(n=r[i].match(/([^=]+)=(.*)/))[1]]=t(n[2]);return o}t=t||encodeURIComponent;var s=e;for(var a in o=[],s)s.hasOwnProperty(a)&&s.hasOwnProperty(a)&&o.push([a,"?"===s[a]?"?":t(s[a])].join("="));return o.join("&")},store:function(){for(var i,e=["localStorage","sessionStorage"],t=-1;e[++t];)try{(i=window[e[t]]).setItem("test"+t,t),i.removeItem("test"+t);break}catch(e){i=null}if(!i){var o=null;o=(i={getItem:function(e){e+="=";for(var t=document.cookie.split(";"),n=0;n<t.length;n++){var r=t[n].replace(/(^\s+|\s+$)/,"");if(r&&0===r.indexOf(e))return r.substr(e.length)}return o},setItem:function(e,t){o=t,document.cookie=e+"="+t}}).getItem("hello")}return function(t,e,n){var r,o=function(){var e={};try{e=JSON.parse(i.getItem("hello"))||{}}catch(e){}return e}();if(t&&void 0===e)return o[t]||null;if(t&&null===e)try{delete o[t]}catch(e){o[t]=null}else{if(!t)return o;o[t]=e}return r=o,i.setItem("hello",JSON.stringify(r)),o||null}}(),append:function(e,t,n){var r="string"==typeof e?document.createElement(e):e;if("object"==typeof t)if("tagName"in t)n=t;else for(var o in t)if(t.hasOwnProperty(o))if("object"==typeof t[o])for(var i in t[o])t[o].hasOwnProperty(i)&&(r[o][i]=t[o][i]);else"html"===o?r.innerHTML=t[o]:/^on/.test(o)?r[o]=t[o]:r.setAttribute(o,t[o]);return"body"===n?function e(){document.body?document.body.appendChild(r):setTimeout(e,16)}():"object"==typeof n?n.appendChild(r):"string"==typeof n&&document.getElementsByTagName(n)[0].appendChild(r),r},iframe:function(e){this.append("iframe",{src:e,style:{position:"absolute",left:"-1000px",bottom:0,height:"1px",width:"1px"}},"body")},merge:function(){var e=Array.prototype.slice.call(arguments);return e.unshift({}),this.extend.apply(null,e)},args:function(e,t){var n={},r=0,o=null,i=null;for(i in e)if(e.hasOwnProperty(i))break;if(1===t.length&&"object"==typeof t[0]&&"o!"!=e[i])for(i in t[0])if(e.hasOwnProperty(i)&&i in e)return t[0];for(i in e)if(e.hasOwnProperty(i))if(o=typeof t[r],"function"==typeof e[i]&&e[i].test(t[r])||"string"==typeof e[i]&&(-1<e[i].indexOf("s")&&"string"===o||-1<e[i].indexOf("o")&&"object"===o||-1<e[i].indexOf("i")&&"number"===o||-1<e[i].indexOf("a")&&"object"===o||-1<e[i].indexOf("f")&&"function"===o))n[i]=t[r++];else if("string"==typeof e[i]&&-1<e[i].indexOf("!"))return!1;return n},url:function(e){if(e){if(window.URL&&URL instanceof Function&&0!==URL.length)return new URL(e,window.location);var t=document.createElement("a");return t.href=e,t.cloneNode(!1)}return window.location},diff:function(t,e){return e.filter(function(e){return-1===t.indexOf(e)})},diffKey:function(e,t){if(e||!t){var n={};for(var r in e)r in t||(n[r]=e[r]);return n}return e},unique:function(n){return Array.isArray(n)?n.filter(function(e,t){return n.indexOf(e)===t}):[]},isEmpty:function(e){if(!e)return!0;if(Array.isArray(e))return!e.length;if("object"==typeof e)for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},Promise:function(){var r=function(e){if(!(this instanceof r))return new r(e);this.id="Thenable/1.0.6",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};r.prototype={fulfill:function(e){return t(this,1,"fulfillValue",e)},reject:function(e){return t(this,2,"rejectReason",e)},then:function(e,t){var n=new r;return this.onFulfilled.push(i(e,n,"fulfill")),this.onRejected.push(i(t,n,"reject")),o(this),n.proxy}};var t=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,o(e)),e},o=function(e){1===e.state?n(e,"onFulfilled",e.fulfillValue):2===e.state&&n(e,"onRejected",e.rejectReason)},n=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var o=function(){for(var e=0;e<r.length;e++)r[e](n)};"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick(o):"function"==typeof setImmediate?setImmediate(o):setTimeout(o,0)}},i=function(n,r,o){return function(e){if("function"!=typeof n)r[o].call(r,e);else{var t;try{t=n(e)}catch(e){return void r.reject(e)}s(r,t)}}},s=function(t,n){if(t!==n&&t.proxy!==n){var e;if("object"==typeof n&&null!==n||"function"==typeof n)try{e=n.then}catch(e){return void t.reject(e)}if("function"!=typeof e)t.fulfill(n);else{var r=!1;try{e.call(n,function(e){r||(r=!0,e===n?t.reject(new TypeError("circular thenable chain")):s(t,e))},function(e){r||(r=!0,t.reject(e))})}catch(e){r||t.reject(e)}}}else t.reject(new TypeError("cannot resolve promise with itself"))};return r}(),Event:function(){var i=/[\s\,]+/;return this.parent={events:this.events,findEvents:this.findEvents,parent:this.parent,utils:this.utils},this.events={},this.on=function(e,t){if(t&&"function"==typeof t)for(var n=e.split(i),r=0;r<n.length;r++)this.events[n[r]]=[t].concat(this.events[n[r]]||[]);return this},this.off=function(e,n){return this.findEvents(e,function(e,t){n&&this.events[e][t]!==n||(this.events[e][t]=null)}),this},this.emit=function(n){var r=Array.prototype.slice.call(arguments,1);r.push(n);for(var e=function(e,t){r[r.length-1]="*"===e?n:e,this.events[e][t].apply(this,r)},t=this;t&&t.findEvents;)t.findEvents(n+",*",e),t=t.parent;return this},this.emitAfter=function(){var e=this,t=arguments;return setTimeout(function(){e.emit.apply(e,t)},0),this},this.findEvents=function(e,t){var n=e.split(i);for(var r in this.events)if(this.events.hasOwnProperty(r)&&-1<n.indexOf(r))for(var o=0;o<this.events[r].length;o++)this.events[r][o]&&t.call(this,r,o)},this},globalEvent:function(e,t){return t=t||"_hellojs_"+parseInt(1e12*Math.random(),10).toString(36),window[t]=function(){try{e.apply(this,arguments)&&delete window[t]}catch(e){console.error(e)}},t},popup:function(e,t,n){var r=document.documentElement;if(n.height){var o=void 0!==window.screenTop?window.screenTop:screen.top,i=screen.height||window.innerHeight||r.clientHeight;n.top=parseInt((i-n.height)/2,10)+o}if(n.width){var s=void 0!==window.screenLeft?window.screenLeft:screen.left,a=screen.width||window.innerWidth||r.clientWidth;n.left=parseInt((a-n.width)/2,10)+s}var c=[];Object.keys(n).forEach(function(e){var t=n[e];c.push(e+(null!==t?"="+t:""))}),-1!==navigator.userAgent.indexOf("Safari")&&-1===navigator.userAgent.indexOf("Chrome")&&(e=t+"#oauth_redirect="+encodeURIComponent(encodeURIComponent(e)));var l=window.open(e,"_blank",c.join(","));return l&&l.focus&&l.focus(),l},responseHandler:function(e,t){var n,s=this,r=e.location;if((n=s.param(r.search))&&n.state&&(n.code||n.oauth_token)){var o=JSON.parse(n.state);n.redirect_uri=o.redirect_uri||r.href.replace(/[\?\#].*$/,"");var i=o.oauth_proxy+"?"+s.param(n);r.assign(i)}else if((n=s.merge(s.param(r.search||""),s.param(r.hash||"")))&&"state"in n){try{var a=JSON.parse(n.state);s.extend(n,a)}catch(e){console.error("Could not decode state parameter")}if("access_token"in n&&n.access_token&&n.network)n.expires_in&&0!==parseInt(n.expires_in,10)||(n.expires_in=0),n.expires_in=parseInt(n.expires_in,10),n.expires=(new Date).getTime()/1e3+(n.expires_in||31536e3),l(n,e,t);else if("error"in n&&n.error&&n.network)n.error={code:n.error,message:n.error_message||n.error_description},l(n,e,t);else if(n.callback&&n.callback in t){var c=!!("result"in n&&n.result)&&JSON.parse(n.result);t[n.callback](c),u()}n.page_uri&&r.assign(n.page_uri)}else if("oauth_redirect"in n)return void r.assign(decodeURIComponent(n.oauth_redirect));function l(e,t,n){var r=e.callback,o=e.network;if(s.store(o,e),!("display"in e&&"page"===e.display)){if(n&&r&&r in n){try{delete e.callback}catch(e){}s.store(o,e);var i=JSON.stringify(e);try{n[r](i)}catch(e){}}u()}}function u(){if(e.frameElement)t.document.body.removeChild(e.frameElement);else{try{e.close()}catch(e){}e.addEventListener&&e.addEventListener("load",function(){e.close()})}}}}),hello.utils.Event.call(hello),function(l){var u={},p={};l.on("auth.login, auth.logout",function(e){e&&"object"==typeof e&&e.network&&(u[e.network]=l.utils.store(e.network)||{})}),function e(){var t=(new Date).getTime()/1e3,n=function(e){l.emit("auth."+e,{network:r,authResponse:o})};for(var r in l.services)if(l.services.hasOwnProperty(r)){if(!l.services[r].id)continue;var o=l.utils.store(r)||{},i=l.services[r],s=u[r]||{};if(o&&"callback"in o){var a=o.callback;try{delete o.callback}catch(e){}l.utils.store(r,o);try{window[a](o)}catch(e){}}if(o&&"expires"in o&&o.expires<t){var c=i.refresh||o.refresh_token;!c||r in p&&!(p[r]<t)?c||r in p||(n("expired"),p[r]=!0):(l.emit("notice",r+" has expired trying to resignin"),l.login(r,{display:"none",force:!1}),p[r]=t+600);continue}if(s.access_token===o.access_token&&s.expires===o.expires)continue;!o.access_token&&s.access_token?n("logout"):o.access_token&&!s.access_token?n("login"):o.expires!==s.expires&&n("update"),u[r]=o,r in p&&delete p[r]}setTimeout(e,1e3)}()}(hello),hello.api=function(){var e=this,o=e.utils,i=o.error,s=o.Promise(),a=o.args({path:"s!",query:"o",method:"s",data:"o",timeout:"i",callback:"f"},arguments);a.method=(a.method||"get").toLowerCase(),a.headers=a.headers||{},a.query=a.query||{},"get"!==a.method&&"delete"!==a.method||(o.extend(a.query,a.data),a.data={});var t=a.data=a.data||{};if(s.then(a.callback,a.callback),!a.path)return s.reject(i("invalid_path","Missing the path parameter from the request"));a.path=a.path.replace(/^\/+/,"");var n=(a.path.split(/[\/\:]/,2)||[])[0].toLowerCase();if(n in e.services){a.network=n;var r=new RegExp("^"+n+":?/?");a.path=a.path.replace(r,"")}a.network=e.settings.default_service=a.network||e.settings.default_service;var c=e.services[a.network];if(!c)return s.reject(i("invalid_network","Could not match the service requested: "+a.network));if(a.method in c&&a.path in c[a.method]&&!1===c[a.method][a.path])return s.reject(i("invalid_path","The provided path is not available on the selected network"));a.oauth_proxy||(a.oauth_proxy=e.settings.oauth_proxy),"proxy"in a||(a.proxy=a.oauth_proxy&&c.oauth&&1===parseInt(c.oauth.version,10)),"timeout"in a||(a.timeout=e.settings.timeout),"formatResponse"in a||(a.formatResponse=!0),a.authResponse=e.getAuthResponse(a.network),a.authResponse&&a.authResponse.access_token&&(a.query.access_token=a.authResponse.access_token);var l,u=a.path;a.options=o.clone(a.query),a.data=o.clone(t);var p=c[{delete:"del"}[a.method]||a.method]||{};if("get"===a.method){var f=u.split(/[\?#]/)[1];f&&(o.extend(a.query,o.param(f)),u=u.replace(/\?.*?(#|$)/,"$1"))}return(l=u.match(/#(.+)/,""))?(u=u.split("#")[0],a.path=l[1]):u in p?u=p[a.path=u]:"default"in p&&(u=p.default),a.redirect_uri=e.settings.redirect_uri,a.xhr=c.xhr,a.jsonp=c.jsonp,a.form=c.form,"function"==typeof u?u(a,h):h(u),s.proxy;function h(e){(e=e.replace(/\@\{([a-z\_\-]+)(\|.*?)?\}/gi,function(e,t,n){var r=n?n.replace(/^\|/,""):"";return t in a.query?(r=a.query[t],delete a.query[t]):a.data&&t in a.data?(r=a.data[t],delete a.data[t]):n||s.reject(i("missing_attribute","The attribute "+t+" is missing from the request")),r})).match(/^https?:\/\//)||(e=c.base+e),a.url=e,o.request(a,function(e,t){if(a.formatResponse){if(!0===e?e={success:!0}:e||(e={}),"delete"===a.method&&(e=!e||o.isEmpty(e)?{success:!0}:e),c.wrap&&(a.path in c.wrap||"default"in c.wrap)){var n=a.path in c.wrap?a.path:"default",r=((new Date).getTime(),c.wrap[n](e,t,a));r&&(e=r)}e&&"paging"in e&&e.paging.next&&("?"===e.paging.next[0]?e.paging.next=a.path+e.paging.next:e.paging.next+="#"+a.path),!e||"error"in e?s.reject(e):s.fulfill(e)}else("object"==typeof t?400<=t.statusCode:"object"==typeof e&&"error"in e)?s.reject(e):s.fulfill(e)})}},hello.utils.extend(hello.utils,{request:function(n,r){var o=this,e=o.error;if(o.isEmpty(n.data)||"FileList"in window||!o.hasBinary(n.data)||(n.xhr=!1,n.jsonp=!1),this.request_cors(function(){return void 0===n.xhr||n.xhr&&("function"!=typeof n.xhr||n.xhr(n,n.query))}))s(n,function(e){var t=o.xhr(n.method,e,n.headers,n.data,r);t.onprogress=n.onprogress||null,t.upload&&n.onuploadprogress&&(t.upload.onprogress=n.onuploadprogress)});else{var t,i=n.query;if(n.query=o.clone(n.query),n.callbackID=o.globalEvent(),!1!==n.jsonp){if(n.query.callback=n.callbackID,"function"==typeof n.jsonp&&n.jsonp(n,n.query),"get"===n.method)return void s(n,function(e){o.jsonp(e,r,n.callbackID,n.timeout)});n.query=i}if(!1!==n.form&&(n.query.redirect_uri=n.redirect_uri,n.query.state=JSON.stringify({callback:n.callbackID}),"function"==typeof n.form&&(t=n.form(n,n.query)),"post"===n.method&&!1!==t))return void s(n,function(e){o.post(e,n.data,t,r,n.callbackID,n.timeout)});r(e("invalid_request","There was no mechanism for handling this request"))}function s(e,t){var n;e.authResponse&&e.authResponse.oauth&&1===parseInt(e.authResponse.oauth.version,10)&&(n=e.query.access_token,delete e.query.access_token,e.proxy=!0),!e.data||"get"!==e.method&&"delete"!==e.method||(o.extend(e.query,e.data),e.data=null);var r=o.qs(e.url,e.query);e.proxy&&(r=o.qs(e.oauth_proxy,{path:r,access_token:n||"",then:e.proxy_response_type||("get"===e.method.toLowerCase()?"redirect":"proxy"),method:e.method.toLowerCase(),suppress_response_codes:!0})),t(r)}},request_cors:function(e){return"withCredentials"in new XMLHttpRequest&&e()},domInstance:function(e,t){var n="HTML"+(e||"").replace(/^[a-z]/,function(e){return e.toUpperCase()})+"Element";return!!t&&(window[n]?t instanceof window[n]:window.Element?t instanceof window.Element&&(!e||t.tagName&&t.tagName.toLowerCase()===e):!(t instanceof Object||t instanceof Array||t instanceof String||t instanceof Number)&&t.tagName&&t.tagName.toLowerCase()===e)},clone:function(e){if(null===e||"object"!=typeof e||e instanceof Date||"nodeName"in e||this.isBinary(e)||"function"==typeof FormData&&e instanceof FormData)return e;if(Array.isArray(e))return e.map(this.clone.bind(this));var t={};for(var n in e)t[n]=this.clone(e[n]);return t},xhr:function(r,e,t,n,o){var i,s=new XMLHttpRequest,a=this.error,c=!1;if("blob"===r&&(c=r,r="GET"),r=r.toUpperCase(),s.onload=function(e){var t=s.response;try{t=JSON.parse(s.responseText)}catch(e){401===s.status&&(t=a("access_denied",s.statusText))}var n=function(e){var t,n={},r=/([a-z\-]+):\s?(.*);?/gi;for(;t=r.exec(e);)n[t[1]]=t[2];return n}(s.getAllResponseHeaders());n.statusCode=s.status,o(t||("GET"===r?a("empty_response",JSON.stringify(e)):{}),n)},s.onerror=function(e){var t=s.responseText;try{t=JSON.parse(s.responseText)}catch(e){}o(t||a("access_denied",JSON.stringify(e)))},"GET"===r||"DELETE"===r)n=null;else if(n&&"string"!=typeof n&&!(n instanceof FormData)&&!(n instanceof File)&&!(n instanceof Blob)){var l=new FormData;for(i in n)n.hasOwnProperty(i)&&(n[i]instanceof HTMLInputElement?"files"in n[i]&&0<n[i].files.length&&l.append(i,n[i].files[0]):n[i]instanceof Blob?l.append(i,n[i],n.name):l.append(i,n[i]));n=l}if(s.open(r,e,!0),c&&("responseType"in s?s.responseType=c:s.overrideMimeType("text/plain; charset=x-user-defined")),t)for(i in t)s.setRequestHeader(i,t[i]);return s.send(n),s},jsonp:function(e,t,n,r){var o,i=this.error,s=0,a=document.getElementsByTagName("head")[0],c=i("server_error","server_error"),l=function(){s++||window.setTimeout(function(){t(c),a.removeChild(u)},0)};n=this.globalEvent(function(e){return c=e,!0},n),e=e.replace(new RegExp("=\\?(&|$)"),"="+n+"$1");var u=this.append("script",{id:n,name:n,src:e,async:!0,onload:l,onerror:l,onreadystatechange:function(){/loaded|complete/i.test(this.readyState)&&l()}});-1<window.navigator.userAgent.toLowerCase().indexOf("opera")&&(o=this.append("script",{text:"document.getElementById('"+n+"').onerror();"}),u.async=!1),r&&window.setTimeout(function(){c=i("timeout","timeout"),l()},r),a.appendChild(u),o&&a.appendChild(o)},post:function(e,t,n,r,o,i){var s,a,c=this,l=c.error,u=document,p=null,f=[],h=0,d=null,m=0,y=function(e){m++||r(e)};c.globalEvent(y,o);try{a=u.createElement('<iframe name="'+o+'">')}catch(e){a=u.createElement("iframe")}if(a.name=o,a.id=o,a.style.display="none",n&&n.callbackonload&&(a.onload=function(){y({response:"posted",message:"Content was posted"})}),i&&setTimeout(function(){y(l("timeout","The post operation timed out"))},i),u.body.appendChild(a),c.domInstance("form",t)){for(p=t.form,h=0;h<p.elements.length;h++)p.elements[h]!==t&&p.elements[h].setAttribute("disabled",!0);t=p}if(c.domInstance("form",t))for(p=t,h=0;h<p.elements.length;h++)p.elements[h].disabled||"file"!==p.elements[h].type||(p.encoding=p.enctype="multipart/form-data",p.elements[h].setAttribute("name","file"));else{for(d in t)t.hasOwnProperty(d)&&c.domInstance("input",t[d])&&"file"===t[d].type&&((p=t[d].form).encoding=p.enctype="multipart/form-data");var v;for(d in p||(p=u.createElement("form"),u.body.appendChild(p),s=p),t)if(t.hasOwnProperty(d)){var g=c.domInstance("input",t[d])||c.domInstance("textArea",t[d])||c.domInstance("select",t[d]);if(g&&t[d].form===p)g&&t[d].name!==d&&(t[d].setAttribute("name",d),t[d].name=d);else{var w=p.elements[d];if(v)for(w instanceof NodeList||(w=[w]),h=0;h<w.length;h++)w[h].parentNode.removeChild(w[h]);(v=u.createElement("input")).setAttribute("type","hidden"),v.setAttribute("name",d),g?v.value=t[d].value:c.domInstance(null,t[d])?v.value=t[d].innerHTML||t[d].innerText:v.value=t[d],p.appendChild(v)}}for(h=0;h<p.elements.length;h++)(v=p.elements[h]).name in t||!0===v.getAttribute("disabled")||(v.setAttribute("disabled",!0),f.push(v))}p.setAttribute("method","POST"),p.setAttribute("target",o),p.target=o,p.setAttribute("action",e),setTimeout(function(){p.submit(),setTimeout(function(){try{s&&s.parentNode.removeChild(s)}catch(e){try{console.error("HelloJS: could not remove iframe")}catch(e){}}for(var e=0;e<f.length;e++)f[e]&&(f[e].setAttribute("disabled",!1),f[e].disabled=!1)},0)},100)},hasBinary:function(e){for(var t in e)if(e.hasOwnProperty(t)&&this.isBinary(e[t]))return!0;return!1},isBinary:function(e){return e instanceof Object&&(this.domInstance("input",e)&&"file"===e.type||"FileList"in window&&e instanceof window.FileList||"File"in window&&e instanceof window.File||"Blob"in window&&e instanceof window.Blob)},toBlob:function(e){var t=/^data\:([^;,]+(\;charset=[^;,]+)?)(\;base64)?,/i,n=e.match(t);if(!n)return e;for(var r=atob(e.replace(t,"")),o=[],i=0;i<r.length;i++)o.push(r.charCodeAt(i));return new Blob([new Uint8Array(o)],{type:n[1]})}}),function(e){var t=e.api,n=e.utils;n.extend(n,{dataToJSON:function(e){var t=this,n=window,r=e.data;if(t.domInstance("form",r)?r=t.nodeListToJSON(r.elements):"NodeList"in n&&r instanceof NodeList?r=t.nodeListToJSON(r):t.domInstance("input",r)&&(r=t.nodeListToJSON([r])),("File"in n&&r instanceof n.File||"Blob"in n&&r instanceof n.Blob||"FileList"in n&&r instanceof n.FileList)&&(r={file:r}),!("FormData"in n&&r instanceof n.FormData))for(var o in r)if(r.hasOwnProperty(o))if("FileList"in n&&r[o]instanceof n.FileList)1===r[o].length&&(r[o]=r[o][0]);else{if(t.domInstance("input",r[o])&&"file"===r[o].type)continue;t.domInstance("input",r[o])||t.domInstance("select",r[o])||t.domInstance("textArea",r[o])?r[o]=r[o].value:t.domInstance(null,r[o])&&(r[o]=r[o].innerHTML||r[o].innerText)}return e.data=r},nodeListToJSON:function(e){for(var t={},n=0;n<e.length;n++){var r=e[n];!r.disabled&&r.name&&("file"===r.type?t[r.name]=r:t[r.name]=r.value||r.innerHTML)}return t}}),e.api=function(){var e=n.args({path:"s!",method:"s",data:"o",timeout:"i",callback:"f"},arguments);return e.data&&n.dataToJSON(e),t.call(this,e)}}(hello),hello.utils.responseHandler(window,window.opener||window.parent),"function"==typeof define&&define.amd&&define(function(){return hello}),"object"==typeof module&&module.exports&&(module.exports=hello);