-
Notifications
You must be signed in to change notification settings - Fork 22
/
dropbox.min.js
3 lines (3 loc) · 58.5 KB
/
dropbox.min.js
1
2
3
(function(){var t,e,r,n,i,o,s,a,u,h,l,p={}.hasOwnProperty,c=[].indexOf||function(t){for(var e=0,r=this.length;r>e;e++)if(e in this&&this[e]===t)return e;return-1},d=function(t,e){function r(){this.constructor=t}for(var n in e)p.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};if(l=function(){function t(){throw new Error("Not implemented. Did you mean to use Dropbox.Client?")}return t}(),l.Util=function(){function t(){}return t}(),l.Http=function(){function t(){}return t}(),l.File=function(){function t(){}return t}(),"undefined"!=typeof global&&"undefined"!=typeof module&&"exports"in module)e=global,r=module.require.bind(module),module.exports=l;else if("undefined"!=typeof window&&"undefined"!=typeof navigator)e=window,r=null,window.Dropbox&&!function(){var t,e,r,n;r=window.Dropbox,n=[];for(t in r)p.call(r,t)&&(e=r[t],n.push(l[t]=e));return n}(),window.Dropbox=l;else{if("undefined"==typeof self||"undefined"==typeof navigator)throw new Error("dropbox.js loaded in an unsupported JavaScript environment.");e=self,r=self.importScripts.bind(self),self.Dropbox=l}if(l.Env=function(){function t(){}return t.global=e,t.require=r,t}(),l.Util.EventSource=function(){function t(t){this._cancelable=t&&t.cancelable,this._listeners=[]}return t.prototype.addListener=function(t){if("function"!=typeof t)throw new TypeError("Invalid listener type; expected function");return c.call(this._listeners,t)<0&&this._listeners.push(t),this},t.prototype.removeListener=function(t){var e,r,n,i,o,s;if(this._listeners.indexOf)r=this._listeners.indexOf(t),-1!==r&&this._listeners.splice(r,1);else for(s=this._listeners,e=i=0,o=s.length;o>i;e=++i)if(n=s[e],n===t){this._listeners.splice(e,1);break}return this},t.prototype.dispatch=function(t){var e,r,n,i,o;for(o=this._listeners,n=0,i=o.length;i>n;n++)if(e=o[n],r=e(t),this._cancelable&&r===!1)return!1;return!0},t}(),l.AccountInfo=function(){function t(t){var e;this._json=t,this.name=t.display_name,this.email=t.email,this.countryCode=t.country||null,this.uid=t.uid.toString(),t.public_app_url?(this.publicAppUrl=t.public_app_url,e=this.publicAppUrl.length-1,e>=0&&"/"===this.publicAppUrl.substring(e)&&(this.publicAppUrl=this.publicAppUrl.substring(0,e))):this.publicAppUrl=null,this.referralUrl=t.referral_link,this.quota=t.quota_info.quota,this.privateBytes=t.quota_info.normal||0,this.sharedBytes=t.quota_info.shared||0,this.usedQuota=this.privateBytes+this.sharedBytes}return t.parse=function(t){return t&&"object"==typeof t?new l.AccountInfo(t):t},t.prototype.name=null,t.prototype.email=null,t.prototype.countryCode=null,t.prototype.uid=null,t.prototype.referralUrl=null,t.prototype.publicAppUrl=null,t.prototype.quota=null,t.prototype.usedQuota=null,t.prototype.privateBytes=null,t.prototype.sharedBytes=null,t.prototype.json=function(){return this._json},t}(),l.ApiError=function(){function t(t,e,r){var n,i;if(this.method=e,this.url=r,this.status=t.status,t.responseType)try{n=t.response||t.responseText}catch(o){i=o;try{n=t.responseText}catch(o){i=o,n=null}}else try{n=t.responseText}catch(o){i=o,n=null}if(n)try{this.responseText=n.toString(),this.response=JSON.parse(n)}catch(o){i=o,this.response=null}else this.responseText="(no response)",this.response=null}return t.prototype.status=null,t.prototype.method=null,t.prototype.url=null,t.prototype.responseText=null,t.prototype.response=null,t.NETWORK_ERROR=0,t.NO_CONTENT=304,t.INVALID_PARAM=400,t.INVALID_TOKEN=401,t.OAUTH_ERROR=403,t.NOT_FOUND=404,t.INVALID_METHOD=405,t.NOT_ACCEPTABLE=406,t.CONFLICT=409,t.RATE_LIMITED=429,t.SERVER_ERROR=503,t.OVER_QUOTA=507,t.prototype.toString=function(){return"Dropbox API error "+this.status+" from "+this.method+" "+this.url+" :: "+this.responseText},t.prototype.inspect=function(){return this.toString()},t}(),l.AuthDriver=function(){function t(){}return t.prototype.authType=function(){return"code"},t.prototype.url=function(){return"https://some.url"},t.prototype.doAuthorize=function(t,e,r,n){return n({code:"access-code"})},t.prototype.getStateParam=function(t,e){return e(l.Util.Oauth.randomAuthStateParam())},t.prototype.resumeAuthorize=function(t,e,r){return r({code:"access-code"})},t.prototype.onAuthStateChange=function(t,e){return e()},t.oauthQueryParams=["access_token","expires_in","scope","token_type","code","error","error_description","error_uri","mac_key","mac_algorithm"].sort(),t}(),l.AuthDriver.autoConfigure=function(t){if("undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.id)return chrome.tabs&&chrome.tabs.create?t.authDriver(new l.AuthDriver.ChromeExtension):t.authDriver(new l.AuthDriver.ChromeApp),void 0;if("undefined"!=typeof window){if(window.cordova)return t.authDriver(new l.AuthDriver.Cordova),void 0;window&&window.navigator&&t.authDriver(new l.AuthDriver.Redirect)}},l.AuthDriver.BrowserBase=function(){function t(t){t?(this.rememberUser="rememberUser"in t?t.rememberUser:!0,this.scope=t.scope||"default"):(this.rememberUser=!0,this.scope="default"),this.storageKey=null,this.storage=l.AuthDriver.BrowserBase.localStorage(),this.stateRe=/^[^#]+\#(.*&)?state=([^&]+)(&|$)/}return t.prototype.authType=function(){return"token"},t.prototype.onAuthStepChange=function(t,e){var r=this;switch(this.setStorageKey(t),t.authStep){case l.Client.RESET:return this.loadCredentials(function(n){return n?(t.setCredentials(n),t.authStep!==l.Client.DONE?e():r.rememberUser?(t.setCredentials(n),e()):r.forgetCredentials(e)):e()});case l.Client.DONE:return this.rememberUser?this.storeCredentials(t.credentials(),e):this.forgetCredentials(e);case l.Client.SIGNED_OUT:return this.forgetCredentials(e);case l.Client.ERROR:return this.forgetCredentials(e);default:return e(),this}},t.prototype.setStorageKey=function(t){return this.storageKey="dropbox-auth:"+this.scope+":"+t.appHash(),this},t.prototype.storeCredentials=function(t,e){var r,n,i,o;r=JSON.stringify(t);try{this.storage.setItem(this.storageKey,r)}catch(s){i=s,n=encodeURIComponent(this.storageKey),o=encodeURIComponent(r),document.cookie=""+n+"="+o+"; path=/"}return e(),this},t.prototype.loadCredentials=function(t){var e,r,n,i,o,s,a;try{n=this.storage.getItem(this.storageKey)}catch(u){a=u,n=null}if(null===n&&(o=encodeURIComponent(this.storageKey),s=o.replace(/[.*+()]/g,"\\$&"),e=new RegExp("(^|(;\\s*))"+o+"=([^;]*)(;|$)"),(i=e.exec(document.cookie))&&(n=decodeURIComponent(i[3]))),!n)return t(null),this;try{t(JSON.parse(n))}catch(u){r=u,t(null)}return this},t.prototype.forgetCredentials=function(t){var e,r,n;try{this.storage.removeItem(this.storageKey)}catch(i){n=i,r=encodeURIComponent(this.storageKey),e=new Date(0).toGMTString(),document.cookie=""+r+"={}; expires="+e+"; path=/"}return t(),this},t.prototype.locationStateParam=function(t){var e,r;return e=t||l.AuthDriver.BrowserBase.currentLocation(),r=this.stateRe.exec(e),r?decodeURIComponent(r[2]):null},t.prototype.replaceUrlBasename=function(t,e){var r,n,i;return n=t.indexOf("#"),-1!==n&&(t=t.substring(0,n)),i=t.indexOf("?"),-1!==i&&(t=t.substring(0,i)),r=t.split("/"),r[r.length-1]=e,r.join("/")},t.localStorage=function(){return"undefined"!=typeof window?window.localStorage:null},t.currentLocation=function(){return window.location.href},t.cleanupLocation=function(){var t,e;window.history&&window.history.replaceState?(e=this.currentLocation(),t=e.indexOf("#"),window.history.replaceState({},document.title,e.substring(0,t))):window.location.hash=""},t}(),l.AuthDriver.Redirect=function(t){function e(t){e.__super__.constructor.call(this,t),this.receiverUrl=this.baseUrl(t)}return d(e,t),e.prototype.baseUrl=function(t){var e,r;if(r=l.AuthDriver.BrowserBase.currentLocation(),t){if(t.redirectUrl)return t.redirectUrl;if(t.redirectFile)return this.replaceUrlBasename(r,t.redirectFile)}return e=r.indexOf("#"),-1!==e&&(r=r.substring(0,e)),r},e.prototype.url=function(){return this.receiverUrl},e.prototype.doAuthorize=function(t,e,r){return this.storeCredentials(r.credentials(),function(){return window.location.assign(t)})},e.prototype.resumeAuthorize=function(t,e,r){var n;return this.locationStateParam()===t?(n=l.AuthDriver.BrowserBase.currentLocation(),l.AuthDriver.BrowserBase.cleanupLocation(),r(l.Util.Oauth.queryParamsFromUrl(n))):this.forgetCredentials(function(){return r({error:"Authorization error"})})},e}(l.AuthDriver.BrowserBase),l.AuthDriver.Popup=function(t){function e(t){e.__super__.constructor.call(this,t),this.receiverUrl=this.baseUrl(t)}return d(e,t),e.prototype.url=function(){return this.receiverUrl},e.prototype.doAuthorize=function(t,e,r,n){return this.listenForMessage(e,n),this.openWindow(t)},e.prototype.baseUrl=function(t){var e;if(e=l.AuthDriver.BrowserBase.currentLocation(),t){if(t.receiverUrl)return t.receiverUrl;if(t.receiverFile)return this.replaceUrlBasename(e,t.receiverFile)}return e},e.prototype.openWindow=function(t){return window.open(t,"_dropboxOauthSigninWindow",this.popupWindowSpec(980,700))},e.prototype.popupWindowSpec=function(t,e){var r,n,i,o,s,a,u,h,l,p;return s=null!=(u=window.screenX)?u:window.screenLeft,a=null!=(h=window.screenY)?h:window.screenTop,o=null!=(l=window.outerWidth)?l:document.documentElement.clientWidth,r=null!=(p=window.outerHeight)?p:document.documentElement.clientHeight,n=Math.round(s+(o-t)/2),i=Math.round(a+(r-e)/2.5),s>n&&(n=s),a>i&&(i=a),"width="+t+",height="+e+","+("left="+n+",top="+i)+"dialog=yes,dependent=yes,scrollbars=yes,location=yes"},e.prototype.listenForMessage=function(t,e){var r,n=this;return r=function(i){var o,s,a;o=i.data?i.data:i;try{a=JSON.parse(o)._dropboxjs_oauth_info}catch(u){return s=u,void 0}if(a)return n.locationStateParam(a)===t?(t=!1,window.removeEventListener("message",r),l.AuthDriver.Popup.onMessage.removeListener(r),e(l.Util.Oauth.queryParamsFromUrl(o))):void 0},window.addEventListener("message",r,!1),l.AuthDriver.Popup.onMessage.addListener(r)},e.locationOrigin=function(t){var e;return(e=/^(file:\/\/[^\?\#]*)(\?|\#|$)/.exec(t))?e[1]:(e=/^([^\:]+\:\/\/[^\/\?\#]*)(\/|\?|\#|$)/.exec(t),e?e[1]:t)},e.oauthReceiver=function(){window.addEventListener("load",function(){var t,e,r,n,i,o;if(o=window.location.href,r=JSON.stringify({_dropboxjs_oauth_info:o}),l.AuthDriver.BrowserBase.cleanupLocation(),n=window.opener,window.parent!==window.top&&(n||(n=window.parent)),n){try{i=window.location.origin||locationOrigin(o),n.postMessage(r,i),window.close()}catch(s){e=s}try{return n.Dropbox.AuthDriver.Popup.onMessage.dispatch(r),window.close()}catch(s){t=s}}})},e.onMessage=new l.Util.EventSource,e}(l.AuthDriver.BrowserBase),l.AuthDriver.ChromeBase=function(t){function e(t){e.__super__.constructor.call(this,t),this.storageKey="dropbox_js_"+this.scope+"_credentials"}return d(e,t),e.prototype.onAuthStepChange=function(t,e){switch(t.authStep){case l.Client.RESET:return this.loadCredentials(function(r){return r&&t.setCredentials(r),e()});case l.Client.DONE:return this.storeCredentials(t.credentials(),e);case l.Client.SIGNED_OUT:return this.forgetCredentials(e);case l.Client.ERROR:return this.forgetCredentials(e);default:return e()}},e.prototype.url=function(){return this.receiverUrl},e.prototype.storeCredentials=function(t,e){var r;return r={},r[this.storageKey]=t,chrome.storage.local.set(r,e),this},e.prototype.loadCredentials=function(t){var e=this;return chrome.storage.local.get(this.storageKey,function(r){return t(r[e.storageKey]||null)}),this},e.prototype.forgetCredentials=function(t){return chrome.storage.local.remove(this.storageKey,t),this},e}(l.AuthDriver.BrowserBase),l.AuthDriver.ChromeApp=function(t){function e(t){e.__super__.constructor.call(this,t),this.receiverUrl="https://"+chrome.runtime.id+".chromiumapp.org/"}return d(e,t),e.prototype.doAuthorize=function(t,e,r,n){var i=this;return chrome.identity.launchWebAuthFlow({url:t,interactive:!0},function(t){return i.locationStateParam(t)===e?(e=!1,n(l.Util.Oauth.queryParamsFromUrl(t))):void 0})},e}(l.AuthDriver.ChromeBase),l.AuthDriver.ChromeExtension=function(t){function e(t){var r;e.__super__.constructor.call(this,t),r=t&&t.receiverPath||"chrome_oauth_receiver.html",this.receiverUrl=chrome.runtime.getURL(r)}return d(e,t),e.prototype.doAuthorize=function(t,e,r,n){var i,o,s=this;return o=null,i=function(t,r){var a;if((!r||!r.tab||r.tab.url.substring(0,s.receiverUrl.length)===s.receiverUrl)&&t.dropbox_oauth_receiver_href)return a=t.dropbox_oauth_receiver_href,s.locationStateParam(a)===e?(e=!1,o&&chrome.tabs.remove(o.id),chrome.runtime.onMessage.removeListener(i),n(l.Util.Oauth.queryParamsFromUrl(a))):void 0},chrome.runtime.onMessage.addListener(i),chrome.tabs.create({url:t,active:!0,pinned:!1},function(t){return o=t})},e.oauthReceiver=function(){return window.addEventListener("load",function(){var t;return t=window.location.href,window.location.hash="",chrome.runtime.sendMessage({dropbox_oauth_receiver_href:t}),window.close?window.close():void 0})},e}(l.AuthDriver.ChromeBase),l.AuthDriver.Cordova=function(t){function e(t){e.__super__.constructor.call(this,t)}return d(e,t),e.prototype.url=function(){return"https://www.dropbox.com/1/oauth2/redirect_receiver"},e.prototype.doAuthorize=function(t,e,r,n){var i,o,s,a,u,h=this;return o=window.open(t,"_blank","location=yes,closebuttoncaption=Cancel"),a=!1,i=/^[^/]*\/\/[^/]*\//.exec(t)[0],u=!1,s=function(t){if(t.url&&h.locationStateParam(t.url)===e){if(u)return;return o.removeEventListener("loadstart",s),o.removeEventListener("loaderror",s),o.removeEventListener("loadstop",s),o.removeEventListener("exit",s),u=!0,window.setTimeout(function(){return o.close()},10),n(l.Util.Oauth.queryParamsFromUrl(t.url)),void 0}if("exit"===t.type){if(u)return;o.removeEventListener("loadstart",s),o.removeEventListener("loaderror",s),o.removeEventListener("loadstop",s),o.removeEventListener("exit",s),u=!0,n(new AuthError("error=access_denied&error_description=User+closed+browser+window"))}},o.addEventListener("loadstart",s),o.addEventListener("loaderror",s),o.addEventListener("loadstop",s),o.addEventListener("exit",s)},e}(l.AuthDriver.BrowserBase),l.AuthDriver.NodeServer=function(){function t(t){this._port=(null!=t?t.port:void 0)||8912,(null!=t?t.tls:void 0)?(this._tlsOptions=t.tls,("string"==typeof this._tlsOptions||this._tlsOptions instanceof Buffer)&&(this._tlsOptions={key:this._tlsOptions,cert:this._tlsOptions})):this._tlsOptions=null,this._fs=l.Env.require("fs"),this._http=l.Env.require("http"),this._https=l.Env.require("https"),this._open=l.Env.require("open"),this._callbacks={},this._nodeUrl=l.Env.require("url"),this.createApp()}return t.prototype.authType=function(){return"code"},t.prototype.url=function(){var t;return t=null===this._tlsOptions?"http":"https",""+t+"://localhost:"+this._port+"/oauth_callback"},t.prototype.doAuthorize=function(t,e,r,n){return this._callbacks[e]=n,this.openBrowser(t)},t.prototype.openBrowser=function(t){if(!t.match(/^https?:\/\//))throw new Error("Not a http/https URL: "+t);return"BROWSER"in process.env?this._open(t,process.env.BROWSER):this._open(t)},t.prototype.createApp=function(){var t=this;return this._app=this._tlsOptions?this._https.createServer(this._tlsOptions,function(e,r){return t.doRequest(e,r)}):this._http.createServer(function(e,r){return t.doRequest(e,r)}),this._app.listen(this._port)},t.prototype.closeServer=function(){return this._app.close()},t.prototype.doRequest=function(t,e){var r,n,i,o=this;return i=this._nodeUrl.parse(t.url,!0),"/oauth_callback"===i.pathname&&(n=i.query.state,this._callbacks[n]&&(this._callbacks[n](i.query),delete this._callbacks[n])),r="",t.on("data",function(t){return r+=t}),t.on("end",function(){return o.closeBrowser(e)})},t.prototype.closeBrowser=function(t){var e;return e='<!doctype html>\n<script type="text/javascript">window.close();</script>\n<p>Please close this window.</p>',t.writeHead(200,{"Content-Length":e.length,"Content-Type":"text/html"}),t.write(e),t.end()},t}(),l.AuthError=function(){function t(t){var e;if(!t.error)throw new Error("Not an OAuth 2.0 error: "+JSON.stringify(t));e="object"==typeof t.error&&t.error.error?t.error:t,this.code=e.error,this.description=e.error_description||null,this.uri=e.error_uri||null}return t.prototype.code=null,t.prototype.description=null,t.prototype.uri=null,t.ACCESS_DENIED="access_denied",t.INVALID_REQUEST="invalid_request",t.UNAUTHORIZED_CLIENT="unauthorized_client",t.INVALID_GRANT="invalid_grant",t.INVALID_SCOPE="invalid_scope",t.UNSUPPORTED_GRANT_TYPE="unsupported_grant_type",t.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",t.SERVER_ERROR="server_error",t.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",t.prototype.toString=function(){return"Dropbox OAuth error "+this.code+" :: "+this.description},t.prototype.inspect=function(){return this.toString()},t}(),l.Client=function(){function e(t){var e=this;this._serverRoot=t.server||this._defaultServerRoot(),this._maxApiServer="maxApiServer"in t?t.maxApiServer:this._defaultMaxApiServer(),this._authServer=t.authServer||this._defaultAuthServer(),this._fileServer=t.fileServer||this._defaultFileServer(),this._downloadServer=t.downloadServer||this._defaultDownloadServer(),this._notifyServer=t.notifyServer||this._defaultNotifyServer(),this.onXhr=new l.Util.EventSource({cancelable:!0}),this.onError=new l.Util.EventSource,this.onAuthStepChange=new l.Util.EventSource,this._xhrOnErrorHandler=function(t,r){return e._handleXhrError(t,r)},this._oauth=new l.Util.Oauth(t),this._uid=t.uid||null,this.authStep=this._oauth.step(),this._driver=null,this.authError=null,this._credentials=null,this.setupUrls()}return e.prototype.onXhr=null,e.prototype.onError=null,e.prototype.onAuthStepChange=null,e.prototype.authDriver=function(t){return this._driver=t,this},e.prototype.dropboxUid=function(){return this._uid},e.prototype.credentials=function(){return this._credentials||this._computeCredentials(),this._credentials},e.prototype.authenticate=function(e,r){var n,i,o,s,a,u=this;if(r||"function"!=typeof e||(r=e,e=null),n=e&&"interactive"in e?e.interactive:!0,!this._driver&&this.authStep!==t.DONE&&(l.AuthDriver.autoConfigure(this),!this._driver))throw new Error("OAuth driver auto-configuration failed. Call authDriver.");if(this.authStep===t.ERROR)throw new Error("Client got in an error state. Call reset() to reuse it!");return s=function(){return u.authStep=u._oauth.step(),u.authStep===t.ERROR&&(u.authError=u._oauth.error()),u._credentials=null,u.onAuthStepChange.dispatch(u),a()},o=function(){return u.authStep=t.ERROR,u._credentials=null,u.onAuthStepChange.dispatch(u),a()},i=null,a=function(){var e;if(i!==u.authStep&&(i=u.authStep,u._driver&&u._driver.onAuthStepChange))return u._driver.onAuthStepChange(u,a),void 0;switch(u.authStep){case t.RESET:return n?(u._driver.getStateParam&&u._driver.getStateParam(function(e){return u.client.authStep===t.RESET&&u._oauth.setAuthStateParam(e),s()}),u._oauth.setAuthStateParam(l.Util.Oauth.randomAuthStateParam()),s()):(r&&r(null,u),void 0);case t.PARAM_SET:return n?(e=u.authorizeUrl(),u._driver.doAuthorize(e,u._oauth.authStateParam(),u,function(t){return u._oauth.processRedirectParams(t),t.uid&&(u._uid=t.uid),s()})):(r&&r(null,u),void 0);case t.PARAM_LOADED:return u._driver.resumeAuthorize?u._driver.resumeAuthorize(u._oauth.authStateParam(),u,function(t){return u._oauth.processRedirectParams(t),t.uid&&(u._uid=t.uid),s()}):(u._oauth.setAuthStateParam(u._oauth.authStateParam()),s(),void 0);case t.AUTHORIZED:return u.getAccessToken(function(t,e){return t?(u.authError=t,o()):(u._oauth.processRedirectParams(e),u._uid=e.uid,s())});case t.DONE:r&&r(null,u);break;case t.SIGNED_OUT:return u.authStep=t.RESET,u.reset(),a();case t.ERROR:r&&r(u.authError,u)}},a(),this},e.prototype.isAuthenticated=function(){return this.authStep===t.DONE},e.prototype.signOut=function(e,r){var n,i,o=this;if(r||"function"!=typeof e||(r=e,e=null),n=e&&e.mustInvalidate,this.authStep!==t.DONE)throw new Error("This client doesn't have a user's token");return i=new l.Util.Xhr("POST",this._urls.signOut),i.signWithOauth(this._oauth),this._dispatchXhr(i,function(e){if(e)if(e.status===l.ApiError.INVALID_TOKEN)e=null;else if(n)return r&&r(e),void 0;return o.authStep=t.RESET,o.reset(),o.authStep=t.SIGNED_OUT,o.onAuthStepChange.dispatch(o),o._driver&&o._driver.onAuthStepChange?o._driver.onAuthStepChange(o,function(){return r?r(null):void 0}):r?r(null):void 0})},e.prototype.signOff=function(t,e){return this.signOut(t,e)},e.prototype.getAccountInfo=function(t,e){var r,n;return e||"function"!=typeof t||(e=t,t=null),r=!1,t&&t.httpCache&&(r=!0),n=new l.Util.Xhr("GET",this._urls.accountInfo),n.signWithOauth(this._oauth,r),this._dispatchXhr(n,function(t,r){return e(t,l.AccountInfo.parse(r),r)})},e.prototype.getUserInfo=function(t,e){return this.getAccountInfo(t,e)},e.prototype.readFile=function(t,e,r){var n,i,o,s,a,u,h;return r||"function"!=typeof e||(r=e,e=null),i={},u="text",s=null,n=!1,e&&(e.versionTag?i.rev=e.versionTag:e.rev&&(i.rev=e.rev),e.arrayBuffer?u="arraybuffer":e.blob?u="blob":e.buffer?u="buffer":e.binary&&(u="b"),e.length?(null!=e.start?(a=e.start,o=e.start+e.length-1):(a="",o=e.length),s="bytes="+a+"-"+o):null!=e.start&&(s="bytes="+e.start+"-"),e.httpCache&&(n=!0)),h=new l.Util.Xhr("GET",""+this._urls.getFile+"/"+this._urlEncodePath(t)),h.setParams(i).signWithOauth(this._oauth,n),h.setResponseType(u),s&&(s&&h.setHeader("Range",s),h.reportResponseHeaders()),this._dispatchXhr(h,function(t,e,n,i){var o;return o=i?l.Http.RangeInfo.parse(i["content-range"]):null,r(t,e,l.File.Stat.parse(n),o)})},e.prototype.writeFile=function(t,e,r,n){var i;return n||"function"!=typeof r||(n=r,r=null),i=l.Util.Xhr.canSendForms&&"object"==typeof e,i?this._writeFileUsingForm(t,e,r,n):this._writeFileUsingPut(t,e,r,n)},e.prototype._writeFileUsingForm=function(t,e,r,n){var i,o,s,a;return s=t.lastIndexOf("/"),-1===s?(i=t,t=""):(i=t.substring(s),t=t.substring(0,s)),o={file:i},r&&(r.noOverwrite&&(o.overwrite="false"),r.lastVersionTag?o.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(o.parent_rev=r.parentRev||r.parent_rev)),a=new l.Util.Xhr("POST",""+this._urls.postFile+"/"+this._urlEncodePath(t)),a.setParams(o).signWithOauth(this._oauth).setFileField("file",i,e,"application/octet-stream"),delete o.file,this._dispatchXhr(a,function(t,e){return n?n(t,l.File.Stat.parse(e)):void 0})},e.prototype._writeFileUsingPut=function(t,e,r,n){var i,o;return i={},r&&(r.noOverwrite&&(i.overwrite="false"),r.lastVersionTag?i.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(i.parent_rev=r.parentRev||r.parent_rev)),o=new l.Util.Xhr("POST",""+this._urls.putFile+"/"+this._urlEncodePath(t)),o.setBody(e).setParams(i).signWithOauth(this._oauth),this._dispatchXhr(o,function(t,e){return n?n(t,l.File.Stat.parse(e)):void 0})},e.prototype.resumableUploadStep=function(t,e,r){var n,i;return e?(n={offset:e.offset},e.tag&&(n.upload_id=e.tag)):n={offset:0},i=new l.Util.Xhr("POST",this._urls.chunkedUpload),i.setBody(t).setParams(n).signWithOauth(this._oauth),this._dispatchXhr(i,function(t,e){return t&&t.status===l.ApiError.INVALID_PARAM&&t.response&&t.response.upload_id&&t.response.offset?r(null,l.Http.UploadCursor.parse(t.response)):r(t,l.Http.UploadCursor.parse(e))})},e.prototype.resumableUploadFinish=function(t,e,r,n){var i,o;return n||"function"!=typeof r||(n=r,r=null),i={upload_id:e.tag},r&&(r.lastVersionTag?i.parent_rev=r.lastVersionTag:(r.parentRev||r.parent_rev)&&(i.parent_rev=r.parentRev||r.parent_rev),r.noOverwrite&&(i.overwrite="false")),o=new l.Util.Xhr("POST",""+this._urls.commitChunkedUpload+"/"+this._urlEncodePath(t)),o.setParams(i).signWithOauth(this._oauth),this._dispatchXhr(o,function(t,e){return n?n(t,l.File.Stat.parse(e)):void 0})},e.prototype.stat=function(t,e,r){var n,i,o;return r||"function"!=typeof e||(r=e,e=null),i={},n=!1,e&&(e.versionTag?i.rev=e.versionTag:e.rev&&(i.rev=e.rev),e.contentHash?i.hash=e.contentHash:e.hash&&(i.hash=e.hash),(e.removed||e.deleted)&&(i.include_deleted="true"),e.readDir&&(i.list="true",e.readDir!==!0&&(i.file_limit=e.readDir.toString())),e.cacheHash&&(i.hash=e.cacheHash),e.httpCache&&(n=!0)),i.include_deleted||(i.include_deleted="false"),i.list||(i.list="false"),o=new l.Util.Xhr("GET",""+this._urls.metadata+"/"+this._urlEncodePath(t)),o.setParams(i).signWithOauth(this._oauth,n),this._dispatchXhr(o,function(t,e){var n,i,o;return o=l.File.Stat.parse(e),n=(null!=e?e.contents:void 0)?function(){var t,r,n,o;for(n=e.contents,o=[],t=0,r=n.length;r>t;t++)i=n[t],o.push(l.File.Stat.parse(i));return o}():void 0,r(t,o,n)})},e.prototype.readdir=function(t,e,r){var n;return r||"function"!=typeof e||(r=e,e=null),n={readDir:!0},e&&(null!=e.limit&&(n.readDir=e.limit),e.versionTag?n.versionTag=e.versionTag:e.rev&&(n.versionTag=e.rev),e.contentHash?n.contentHash=e.contentHash:e.hash&&(n.contentHash=e.hash),(e.removed||e.deleted)&&(n.removed=e.removed||e.deleted),e.httpCache&&(n.httpCache=e.httpCache)),this.stat(t,n,function(t,e,n){var i,o;return i=n?function(){var t,e,r;for(r=[],t=0,e=n.length;e>t;t++)o=n[t],r.push(o.name);return r}():null,r(t,i,e,n)})},e.prototype.metadata=function(t,e,r){return this.stat(t,e,r)},e.prototype.makeUrl=function(t,e,r){var n,i,o,s,a,u=this;return r||"function"!=typeof e||(r=e,e=null),i=e&&(e["long"]||e.longUrl||e.downloadHack)?{short_url:"false"}:{},t=this._urlEncodePath(t),o=""+this._urls.shares+"/"+t,n=!1,s=!1,e&&(e.downloadHack?(n=!0,s=!0):e.download&&(n=!0,o=""+this._urls.media+"/"+t)),a=new l.Util.Xhr("POST",o).setParams(i).signWithOauth(this._oauth),this._dispatchXhr(a,function(t,e){return s&&(null!=e?e.url:void 0)&&(e.url=e.url.replace(u._authServer,u._downloadServer)),r(t,l.File.ShareUrl.parse(e,n))})},e.prototype.history=function(t,e,r){var n,i,o;return r||"function"!=typeof e||(r=e,e=null),i={},n=!1,e&&(null!=e.limit&&(i.rev_limit=e.limit),e.httpCache&&(n=!0)),o=new l.Util.Xhr("GET",""+this._urls.revisions+"/"+this._urlEncodePath(t)),o.setParams(i).signWithOauth(this._oauth,n),this._dispatchXhr(o,function(t,e){var n,i;return i=e?function(){var t,r,i;for(i=[],t=0,r=e.length;r>t;t++)n=e[t],i.push(l.File.Stat.parse(n));return i}():void 0,r(t,i)})},e.prototype.revisions=function(t,e,r){return this.history(t,e,r)},e.prototype.thumbnailUrl=function(t,e){var r;return r=this.thumbnailXhr(t,e),r.paramsToUrl().url},e.prototype.readThumbnail=function(t,e,r){var n,i;return r||"function"!=typeof e||(r=e,e=null),n="b",e&&(e.blob&&(n="blob"),e.arrayBuffer&&(n="arraybuffer"),e.buffer&&(n="buffer")),i=this.thumbnailXhr(t,e),i.setResponseType(n),this._dispatchXhr(i,function(t,e,n){return r(t,e,l.File.Stat.parse(n))})},e.prototype.thumbnailXhr=function(t,e){var r,n;return r={},e&&(e.format?r.format=e.format:e.png&&(r.format="png"),e.size&&(r.size=e.size)),n=new l.Util.Xhr("GET",""+this._urls.thumbnails+"/"+this._urlEncodePath(t)),n.setParams(r).signWithOauth(this._oauth)},e.prototype.revertFile=function(t,e,r){var n;return n=new l.Util.Xhr("POST",""+this._urls.restore+"/"+this._urlEncodePath(t)),n.setParams({rev:e}).signWithOauth(this._oauth),this._dispatchXhr(n,function(t,e){return r?r(t,l.File.Stat.parse(e)):void 0})},e.prototype.restore=function(t,e,r){return this.revertFile(t,e,r)},e.prototype.findByName=function(t,e,r,n){var i,o,s;return n||"function"!=typeof r||(n=r,r=null),o={query:e},i=!1,r&&(null!=r.limit&&(o.file_limit=r.limit),(r.removed||r.deleted)&&(o.include_deleted=!0),r.httpCache&&(i=!0)),s=new l.Util.Xhr("GET",""+this._urls.search+"/"+this._urlEncodePath(t)),s.setParams(o).signWithOauth(this._oauth,i),this._dispatchXhr(s,function(t,e){var r,i;return i=e?function(){var t,n,i;for(i=[],t=0,n=e.length;n>t;t++)r=e[t],i.push(l.File.Stat.parse(r));return i}():void 0,n(t,i)})},e.prototype.search=function(t,e,r,n){return this.findByName(t,e,r,n)},e.prototype.makeCopyReference=function(t,e){var r;return r=new l.Util.Xhr("GET",""+this._urls.copyRef+"/"+this._urlEncodePath(t)),r.signWithOauth(this._oauth),this._dispatchXhr(r,function(t,r){return e(t,l.File.CopyReference.parse(r))})},e.prototype.copyRef=function(t,e){return this.makeCopyReference(t,e)},e.prototype.pullChanges=function(t,e){var r,n;return e||"function"!=typeof t||(e=t,t=null),r=t?t.cursorTag?{cursor:t.cursorTag}:{cursor:t}:{},n=new l.Util.Xhr("POST",this._urls.delta),n.setParams(r).signWithOauth(this._oauth),this._dispatchXhr(n,function(t,r){return e(t,l.Http.PulledChanges.parse(r))})},e.prototype.delta=function(t,e){return this.pullChanges(t,e)},e.prototype.pollForChanges=function(t,e,r){var n,i;return r||"function"!=typeof e||(r=e,e=null),n=t.cursorTag?{cursor:t.cursorTag}:{cursor:t},e&&"timeout"in e&&(n.timeout=e.timeout),i=new l.Util.Xhr("GET",this._urls.longpollDelta),i.setParams(n),this._dispatchXhr(i,function(t,e){var n;if("string"==typeof e)try{e=JSON.parse(e)}catch(i){n=i,e=null}return r(t,l.Http.PollResult.parse(e))})},e.prototype.mkdir=function(t,e){var r;return r=new l.Util.Xhr("POST",this._urls.fileopsCreateFolder),r.setParams({root:"auto",path:this._normalizePath(t)}).signWithOauth(this._oauth),this._dispatchXhr(r,function(t,r){return e?e(t,l.File.Stat.parse(r)):void 0})},e.prototype.remove=function(t,e){var r;return r=new l.Util.Xhr("POST",this._urls.fileopsDelete),r.setParams({root:"auto",path:this._normalizePath(t)}).signWithOauth(this._oauth),this._dispatchXhr(r,function(t,r){return e?e(t,l.File.Stat.parse(r)):void 0})},e.prototype.unlink=function(t,e){return this.remove(t,e)},e.prototype["delete"]=function(t,e){return this.remove(t,e)},e.prototype.copy=function(t,e,r){var n,i,o;return r||"function"!=typeof n||(r=n,n=null),i={root:"auto",to_path:this._normalizePath(e)},t instanceof l.File.CopyReference?i.from_copy_ref=t.tag:i.from_path=this._normalizePath(t),o=new l.Util.Xhr("POST",this._urls.fileopsCopy),o.setParams(i).signWithOauth(this._oauth),this._dispatchXhr(o,function(t,e){return r?r(t,l.File.Stat.parse(e)):void 0})},e.prototype.move=function(t,e,r){var n,i;return r||"function"!=typeof n||(r=n,n=null),i=new l.Util.Xhr("POST",this._urls.fileopsMove),i.setParams({root:"auto",from_path:this._normalizePath(t),to_path:this._normalizePath(e)}).signWithOauth(this._oauth),this._dispatchXhr(i,function(t,e){return r?r(t,l.File.Stat.parse(e)):void 0})},e.prototype.appInfo=function(t,e){var r;return e||"function"!=typeof t||(e=t,t=this._oauth.credentials().key),r=new l.Util.Xhr("GET",this._urls.appsInfo),r.setParams({app_key:t}),this._dispatchXhr(r,function(r,n){return e(r,l.Http.AppInfo.parse(n,t))})},e.prototype.isAppDeveloper=function(t,e,r){var n;return"object"==typeof t&&"uid"in t&&(t=t.uid),r||"function"!=typeof e?"object"==typeof e&&"key"in e&&(e=e.key):(r=e,e=this._oauth.credentials().key),n=new l.Util.Xhr("GET",this._urls.appsCheckDeveloper),n.setParams({app_key:e,uid:t}),this._dispatchXhr(n,function(t,e){return e?r(t,e.is_developer):r(t)})},e.prototype.hasOauthRedirectUri=function(t,e,r){var n;return r||"function"!=typeof e?"object"==typeof e&&"key"in e&&(e=e.key):(r=e,e=this._oauth.credentials().key),n=new l.Util.Xhr("GET",this._urls.appsCheckRedirectUri),n.setParams({app_key:e,redirect_uri:t}),this._dispatchXhr(n,function(t,e){return e?r(t,e.has_redirect_uri):r(t)})},e.prototype.reset=function(){var t;return this._uid=null,this._oauth.reset(),t=this.authStep,this.authStep=this._oauth.step(),t!==this.authStep&&this.onAuthStepChange.dispatch(this),this.authError=null,this._credentials=null,this},e.prototype.setCredentials=function(t){var e;return e=this.authStep,this._oauth.setCredentials(t),this.authStep=this._oauth.step(),this._uid=t.uid||null,this.authError=null,this._credentials=null,e!==this.authStep&&this.onAuthStepChange.dispatch(this),this},e.prototype.appHash=function(){return this._oauth.appHash()},e.prototype.setupUrls=function(){return this._apiServer=this._chooseApiServer(),this._urls={authorize:""+this._authServer+"/1/oauth2/authorize",token:""+this._apiServer+"/1/oauth2/token",signOut:""+this._apiServer+"/1/unlink_access_token",accountInfo:""+this._apiServer+"/1/account/info",getFile:""+this._fileServer+"/1/files/auto",postFile:""+this._fileServer+"/1/files/auto",putFile:""+this._fileServer+"/1/files_put/auto",metadata:""+this._apiServer+"/1/metadata/auto",delta:""+this._apiServer+"/1/delta",longpollDelta:""+this._notifyServer+"/1/longpoll_delta",revisions:""+this._apiServer+"/1/revisions/auto",restore:""+this._apiServer+"/1/restore/auto",search:""+this._apiServer+"/1/search/auto",shares:""+this._apiServer+"/1/shares/auto",media:""+this._apiServer+"/1/media/auto",copyRef:""+this._apiServer+"/1/copy_ref/auto",thumbnails:""+this._fileServer+"/1/thumbnails/auto",chunkedUpload:""+this._fileServer+"/1/chunked_upload",commitChunkedUpload:""+this._fileServer+"/1/commit_chunked_upload/auto",fileopsCopy:""+this._apiServer+"/1/fileops/copy",fileopsCreateFolder:""+this._apiServer+"/1/fileops/create_folder",fileopsDelete:""+this._apiServer+"/1/fileops/delete",fileopsMove:""+this._apiServer+"/1/fileops/move",appsInfo:""+this._apiServer+"/1/apps/info",appsCheckDeveloper:""+this._apiServer+"/1/apps/check_developer",appsCheckRedirectUri:""+this._apiServer+"/1/apps/check_redirect_uri"}
},e.prototype._chooseApiServer=function(){var t,e;return e=Math.floor(Math.random()*(this._maxApiServer+1)),t=0===e?"":e.toString(),this._serverRoot.replace("$",t)},e.prototype.authStep=null,e.ERROR=0,e.RESET=1,e.PARAM_SET=2,e.PARAM_LOADED=3,e.AUTHORIZED=4,e.DONE=5,e.SIGNED_OUT=6,e.prototype._urlEncodePath=function(t){return l.Util.Xhr.urlEncodeValue(this._normalizePath(t)).replace(/%2F/gi,"/")},e.prototype._normalizePath=function(t){var e;if("/"===t.substring(0,1)){for(e=1;"/"===t.substring(e,e+1);)e+=1;return t.substring(e)}return t},e.prototype.authorizeUrl=function(){var t;return t=this._oauth.authorizeUrlParams(this._driver.authType(),this._driver.url()),this._urls.authorize+"?"+l.Util.Xhr.urlEncode(t)},e.prototype.getAccessToken=function(t){var e,r;return e=this._oauth.accessTokenParams(this._driver.url()),r=new l.Util.Xhr("POST",this._urls.token).setParams(e).addOauthParams(this._oauth),this._dispatchXhr(r,function(e,r){return e&&e.status===l.ApiError.INVALID_PARAM&&e.response&&e.response.error&&(e=new l.AuthError(e.response)),t(e,r)})},e.prototype._dispatchXhr=function(t,e){var r;return t.setCallback(e),t.onError=this._xhrOnErrorHandler,t.prepare(),r=t.xhr,this.onXhr.dispatch(t)&&t.send(),r},e.prototype._handleXhrError=function(e,r){var n=this;return e.status===l.ApiError.INVALID_TOKEN&&this.authStep===t.DONE&&(this.authError=e,this.authStep=t.ERROR,this.onAuthStepChange.dispatch(this),this._driver&&this._driver.onAuthStepChange)?(this._driver.onAuthStepChange(this,function(){return n.onError.dispatch(e),r(e)}),null):(this.onError.dispatch(e),r(e),void 0)},e.prototype._defaultServerRoot=function(){return"https://api$.dropbox.com"},e.prototype._defaultAuthServer=function(){return this._serverRoot.replace("api$","www")},e.prototype._defaultFileServer=function(){return this._serverRoot.replace("api$","api-content")},e.prototype._defaultDownloadServer=function(){return"https://dl.dropboxusercontent.com"},e.prototype._defaultNotifyServer=function(){return this._serverRoot.replace("api$","api-notify")},e.prototype._defaultMaxApiServer=function(){return 30},e.prototype._computeCredentials=function(){var t;t=this._oauth.credentials(),this._uid&&(t.uid=this._uid),this._serverRoot!==this._defaultServerRoot()&&(t.server=this._serverRoot),this._maxApiServer!==this._defaultMaxApiServer()&&(t.maxApiServer=this._maxApiServer),this._authServer!==this._defaultAuthServer()&&(t.authServer=this._authServer),this._fileServer!==this._defaultFileServer()&&(t.fileServer=this._fileServer),this._downloadServer!==this._defaultDownloadServer()&&(t.downloadServer=this._downloadServer),this._notifyServer!==this._defaultNotifyServer()&&(t.notifyServer=this._notifyServer),this._credentials=t},e}(),t=l.Client,l.File.ShareUrl=function(){function t(t,e){this.url=t.url,this.expiresAt=l.Util.parseDate(t.expires),this.isDirect=e===!0?!0:e===!1?!1:"direct"in t?t.direct:Date.now()-this.expiresAt<=864e5,this.isPreview=!this.isDirect,this._json=null}return t.parse=function(t,e){return t&&"object"==typeof t?new l.File.ShareUrl(t,e):t},t.prototype.url=null,t.prototype.expiresAt=null,t.prototype.isDirect=null,t.prototype.isPreview=null,t.prototype.json=function(){return this._json||(this._json={url:this.url,expires:this.expiresAt.toUTCString(),direct:this.isDirect})},t}(),l.File.CopyReference=function(){function t(t){"object"==typeof t?(this.tag=t.copy_ref,this.expiresAt=l.Util.parseDate(t.expires),this._json=t):(this.tag=t,this.expiresAt=new Date(1e3*Math.ceil(Date.now()/1e3)),this._json=null)}return t.parse=function(t){return!t||"object"!=typeof t&&"string"!=typeof t?t:new l.File.CopyReference(t)},t.prototype.tag=null,t.prototype.expiresAt=null,t.prototype.json=function(){return this._json||(this._json={copy_ref:this.tag,expires:this.expiresAt.toUTCString()})},t}(),l.File.Stat=function(){function t(t){var e,r,n,i;switch(this._json=t,this.path=t.path,"/"!==this.path.substring(0,1)&&(this.path="/"+this.path),e=this.path.length-1,e>=0&&"/"===this.path.substring(e)&&(this.path=this.path.substring(0,e)),r=this.path.lastIndexOf("/"),this.name=this.path.substring(r+1),this.isFolder=t.is_dir||!1,this.isFile=!this.isFolder,this.isRemoved=t.is_deleted||!1,this.typeIcon=t.icon,this.modifiedAt=(null!=(n=t.modified)?n.length:void 0)?l.Util.parseDate(t.modified):null,this.clientModifiedAt=(null!=(i=t.client_mtime)?i.length:void 0)?l.Util.parseDate(t.client_mtime):null,t.root){case"dropbox":this.inAppFolder=!1;break;case"app_folder":this.inAppFolder=!0;break;default:this.inAppFolder=null}this.size=t.bytes||0,this.humanSize=t.size||"",this.hasThumbnail=t.thumb_exists||!1,this.versionTag=t.rev,this.contentHash=t.hash||null,this.mimeType=this.isFolder?t.mime_type||"inode/directory":t.mime_type||"application/octet-stream"}return t.parse=function(t){return t&&"object"==typeof t?new l.File.Stat(t):t},t.prototype.path=null,t.prototype.name=null,t.prototype.inAppFolder=null,t.prototype.isFolder=null,t.prototype.isFile=null,t.prototype.isRemoved=null,t.prototype.typeIcon=null,t.prototype.versionTag=null,t.prototype.contentHash=null,t.prototype.mimeType=null,t.prototype.size=null,t.prototype.humanSize=null,t.prototype.hasThumbnail=null,t.prototype.modifiedAt=null,t.prototype.clientModifiedAt=null,t.prototype.json=function(){return this._json},t}(),l.Http.AppInfo=function(){function t(t,e){var r;this.name=t.name,this._icons=t.icons,r=t.permissions||{},this.canUseDatastores=!!r.datastores,this.canUseFiles=!!r.files,this.canUseFullDropbox="full_dropbox"===r.files,this.hasAppFolder="app_folder"===r.files,this.key=e?e:t.key||null}return t.parse=function(t,e){return t?new l.Http.AppInfo(t,e):t},t.prototype.name=void 0,t.prototype.key=void 0,t.prototype.canUseDatastores=void 0,t.prototype.canUseFiles=void 0,t.prototype.hasAppFolder=void 0,t.prototype.canUseFullDropbox=void 0,t.prototype.icon=function(t,e){return e||(e=t),this._icons[""+t+"x"+e]||null},t.ICON_SMALL=64,t.ICON_LARGE=256,t}(),l.Http.PulledChanges=function(){function t(t){var e;this.blankSlate=t.reset||!1,this.cursorTag=t.cursor,this.shouldPullAgain=t.has_more,this.shouldBackOff=!this.shouldPullAgain,this.changes=t.cursor&&t.cursor.length?function(){var r,n,i,o;for(i=t.entries,o=[],r=0,n=i.length;n>r;r++)e=i[r],o.push(l.Http.PulledChange.parse(e));return o}():[]}return t.parse=function(t){return t&&"object"==typeof t?new l.Http.PulledChanges(t):t},t.prototype.blankSlate=void 0,t.prototype.cursorTag=void 0,t.prototype.changes=void 0,t.prototype.shouldPullAgain=void 0,t.prototype.shouldBackOff=void 0,t.prototype.cursor=function(){return this.cursorTag},t}(),l.Http.PulledChange=function(){function t(t){this.path=t[0],this.stat=l.File.Stat.parse(t[1]),this.stat?this.wasRemoved=!1:(this.stat=null,this.wasRemoved=!0)}return t.parse=function(t){return t&&"object"==typeof t?new l.Http.PulledChange(t):t},t.prototype.path=void 0,t.prototype.wasRemoved=void 0,t.prototype.stat=void 0,t}(),l.Http.PollResult=function(){function t(t){this.hasChanges=t.changes,this.retryAfter=t.backoff||0}return t.parse=function(t){return t?new l.Http.PollResult(t):t},t.prototype.hasChanges=void 0,t.prototype.retryAfter=void 0,t}(),l.Http.RangeInfo=function(){function t(t){var e;(e=/^bytes (\d*)-(\d*)\/(.*)$/.exec(t))?(this.start=parseInt(e[1]),this.end=parseInt(e[2]),this.size="*"===e[3]?null:parseInt(e[3])):(this.start=0,this.end=0,this.size=null)}return t.parse=function(t){return"string"==typeof t?new l.Http.RangeInfo(t):t},t.prototype.start=null,t.prototype.size=null,t.prototype.end=null,t}(),l.Http.UploadCursor=function(){function t(t){this.replace(t)}return t.parse=function(t){return!t||"object"!=typeof t&&"string"!=typeof t?t:new l.Http.UploadCursor(t)},t.prototype.tag=null,t.prototype.offset=null,t.prototype.expiresAt=null,t.prototype.json=function(){return this._json||(this._json={upload_id:this.tag,offset:this.offset,expires:this.expiresAt.toUTCString()})},t.prototype.replace=function(t){return"object"==typeof t?(this.tag=t.upload_id||null,this.offset=t.offset||0,this.expiresAt=l.Util.parseDate(t.expires)||Date.now(),this._json=t):(this.tag=t||null,this.offset=0,this.expiresAt=new Date(1e3*Math.floor(Date.now()/1e3)),this._json=null),this},t}(),"function"==typeof l.Env.global.atob&&"function"==typeof l.Env.global.btoa?(l.Util.atob=function(t){return l.Env.global.atob(t)},l.Util.btoa=function(t){return l.Env.global.btoa(t)}):l.Env.global.require&&l.Env.global.Buffer?(l.Util.atob=function(t){var e,r;return e=new Buffer(t,"base64"),function(){var t,n,i;for(i=[],r=t=0,n=e.length;n>=0?n>t:t>n;r=n>=0?++t:--t)i.push(String.fromCharCode(e[r]));return i}().join("")},l.Util.btoa=function(t){var e,r;return e=new Buffer(function(){var e,n,i;for(i=[],r=e=0,n=t.length;n>=0?n>e:e>n;r=n>=0?++e:--e)i.push(t.charCodeAt(r));return i}()),e.toString("base64")}):!function(){var t,e,r;return e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=function(t,r,n){var i,o;for(o=3-r,t<<=8*o,i=3;i>=o;)n.push(e.charAt(63&t>>6*i)),i-=1;for(i=r;3>i;)n.push("="),i+=1;return null},t=function(t,e,r){var n,i;for(i=4-e,t<<=6*i,n=2;n>=i;)r.push(String.fromCharCode(255&t>>8*n)),n-=1;return null},l.Util.btoa=function(t){var e,n,i,o,s,a;for(o=[],e=0,n=0,i=s=0,a=t.length;a>=0?a>s:s>a;i=a>=0?++s:--s)e=e<<8|t.charCodeAt(i),n+=1,3===n&&(r(e,n,o),e=n=0);return n>0&&r(e,n,o),o.join("")},l.Util.atob=function(r){var n,i,o,s,a,u,h;for(a=[],n=0,o=0,s=u=0,h=r.length;(h>=0?h>u:u>h)&&(i=r.charAt(s),"="!==i);s=h>=0?++u:--u)n=n<<6|e.indexOf(i),o+=1,4===o&&(t(n,o,a),n=o=0);return o>0&&t(n,o,a),a.join("")}}(),function(){var t,e,r,n,i,o,s,a,u,h,p;if(l.Util.hmac=function(e,n){return t(r(u(e),u(n),e.length,n.length))},l.Util.sha1=function(e){return t(i(u(e),e.length))},l.Util.sha256=function(e){return t(o(u(e),e.length))},l.Env.require)try{e=l.Env.require("crypto"),e.createHmac&&e.createHash&&(l.Util.hmac=function(t,r){var n;return n=e.createHmac("sha1",r),n.update(t),n.digest("base64")},l.Util.sha1=function(t){var r;return r=e.createHash("sha1"),r.update(t),r.digest("base64")},l.Util.sha256=function(t){var r;return r=e.createHash("sha256"),r.update(t),r.digest("base64")})}catch(c){n=c}return r=function(t,e,r,n){var o,s,a,u;return e.length>16&&(e=i(e,n)),a=function(){var t,r;for(r=[],s=t=0;16>t;s=++t)r.push(909522486^e[s]);return r}(),u=function(){var t,r;for(r=[],s=t=0;16>t;s=++t)r.push(1549556828^e[s]);return r}(),o=i(a.concat(t),64+r),i(u.concat(o),84)},i=function(t,e){var r,n,i,o,s,a,u,h,l,p,c,d,f,_,y,v,m;for(t[e>>2]|=1<<31-((3&e)<<3),t[(e+8>>6<<4)+15]=e<<3,y=Array(80),r=1732584193,i=4023233417,s=2562383102,u=271733878,l=3285377520,c=0,f=t.length;f>c;){for(n=r,o=i,a=s,h=u,p=l,d=m=0;80>m;d=++m)16>d?y[d]=0|t[c+d<<2>>2]:(_=(0|y[d-3<<2>>2])^(0|y[d-8<<2>>2])^(0|y[d-14<<2>>2])^(0|y[d-16<<2>>2]),y[d]=_<<1|_>>>31),v=0|(0|(r<<5|r>>>27)+l)+y[d<<2>>2],v=20>d?0|v+(0|(i&s|~i&u)+1518500249):40>d?0|v+(0|(i^s^u)+1859775393):60>d?0|(0|v+((i&s|i&u|s&u)-1894007588)):0|v+(0|(i^s^u)-899497514),l=u,u=s,s=i<<30|i>>>2,i=r,r=v;r=0|n+r,i=0|o+i,s=0|a+s,u=0|h+u,l=0|p+l,c=0|c+16}return[r,i,s,u,l]},o=function(t,e){var r,n,i,o,u,h,l,p,c,d,f,_,y,v,m,g,w,S,b,A,E,U,C,O,R,P,T,x,k,D,F,B;for(t[e>>2]|=1<<31-((3&e)<<3),t[(e+8>>6<<4)+15]=e<<3,k=Array(80),r=s[0],i=s[1],u=s[2],p=s[3],d=s[4],_=s[5],v=s[6],A=s[7],U=0,O=t.length;O>U;){for(n=r,o=i,h=u,c=p,f=d,y=_,m=v,E=A,C=B=0;64>B;C=++B)16>C?x=k[C]=0|t[U+C<<2>>2]:(w=0|k[C-15<<2>>2],g=(w<<25|w>>>7)^(w<<14|w>>>18)^w>>>3,b=0|k[C-2<<2>>2],S=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10,x=k[C]=0|(0|g+(0|k[C-7<<2>>2]))+(0|S+(0|k[C-16<<2>>2]))),l=d&_^~d&v,R=r&i^r&u^i&u,P=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),T=(d<<26|d>>>6)^(d<<21|d>>>11)^(d<<7|d>>>25),D=0|(0|(0|A+T)+(0|l+x))+(0|a[C<<2>>2]),F=0|P+R,A=v,v=_,_=d,d=0|p+D,p=u,u=i,i=r,r=0|D+F;r=0|n+r,i=0|o+i,u=0|h+u,p=0|c+p,d=0|f+d,_=0|y+_,v=0|m+v,A=0|E+A,U+=16}return[r,i,u,p,d,_,v,A]},h=function(t){return 0>t&&(t=4*(1<<30)+t),t.toString(16)},s=[],a=[],function(){var t,e,r,n,i,o,u;for(e=function(t){return 0|4294967296*(t-Math.floor(t))},i=2,u=[],r=o=0;64>o;r=++o){for(;;){for(n=!0,t=2;i>=t*t;){if(0===i%t){n=!1;break}t+=1}if(n)break;i+=1}8>r&&(s[r]=e(Math.pow(i,.5))),a[r]=e(Math.pow(i,1/3)),u.push(i+=1)}return u}(),t=function(t){var e,r,n,i,o;for(i="",e=0,n=4*t.length;n>e;)r=e,o=(255&t[r>>2]>>(3-(3&r)<<3))<<16,r+=1,o|=(255&t[r>>2]>>(3-(3&r)<<3))<<8,r+=1,o|=255&t[r>>2]>>(3-(3&r)<<3),i+=p[63&o>>18],i+=p[63&o>>12],e+=1,i+=e>=n?"=":p[63&o>>6],e+=1,i+=e>=n?"=":p[63&o],e+=1;return i},p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=function(t){var e,r,n,i,o;for(e=[],n=255,r=i=0,o=t.length;o>=0?o>i:i>o;r=o>=0?++i:--i)e[r>>2]|=(t.charCodeAt(r)&n)<<(3-(3&r)<<3);return e}}(),l.Util.Oauth=function(){function t(t){this._id=null,this._secret=null,this._stateParam=null,this._authCode=null,this._token=null,this._tokenKey=null,this._tokenKid=null,this._error=null,this._appHash=null,this._loaded=null,this.setCredentials(t)}return t.prototype.setCredentials=function(t){if(t.key)this._id=t.key;else{if(!t.token)throw new Error("No API key supplied");this._id=null}return this._secret=t.secret||null,this._appHash=null,this._error=null,this._loaded=!0,this.reset(),t.token?(this._token=t.token,t.tokenKey&&(this._tokenKey=t.tokenKey,this._tokenKid=t.tokenKid)):t.oauthCode?this._authCode=t.oauthCode:t.oauthStateParam&&(this._stateParam=t.oauthStateParam),this},t.prototype.credentials=function(){var t;return t={},this._id&&(t.key=this._id),this._secret&&(t.secret=this._secret),null!==this._token?(t.token=this._token,this._tokenKey&&(t.tokenKey=this._tokenKey,t.tokenKid=this._tokenKid)):null!==this._authCode?t.oauthCode=this._authCode:null!==this._stateParam&&(t.oauthStateParam=this._stateParam),t},t.prototype.step=function(){return null!==this._token?l.Client.DONE:null!==this._authCode?l.Client.AUTHORIZED:null!==this._stateParam?this._loaded?l.Client.PARAM_LOADED:l.Client.PARAM_SET:null!==this._error?l.Client.ERROR:l.Client.RESET},t.prototype.setAuthStateParam=function(t){if(null===this._id)throw new Error("No API key supplied, cannot do authorization");return this.reset(),this._loaded=!1,this._stateParam=t,this},t.prototype.checkAuthStateParam=function(t){return this._stateParam===t&&null!==this._stateParam},t.prototype.authStateParam=function(){return this._stateParam},t.prototype.error=function(){return this._error},t.prototype.processRedirectParams=function(t){var e;if(t.error){if(null===this._id)throw new Error("No API key supplied, cannot process errors");return this.reset(),this._error=new l.AuthError(t),!0}if(t.code){if(null===this._id)throw new Error("No API key supplied, cannot do Authorization Codes");return this.reset(),this._loaded=!1,this._authCode=t.code,!0}if(e=t.token_type){if(e=e.toLowerCase(),"bearer"!==e&&"mac"!==e)throw new Error("Unimplemented token type "+e);if(this.reset(),this._loaded=!1,"mac"===e){if("hmac-sha-1"!==t.mac_algorithm)throw new Error("Unimplemented MAC algorithms "+t.mac_algorithm);this._tokenKey=t.mac_key,this._tokenKid=t.kid}return this._token=t.access_token,!0}return!1},t.prototype.authHeader=function(t,e,r){var n,i;return null===this._token?(i=null===this._secret?l.Util.btoa(""+this._id+":"):l.Util.btoa(""+this._id+":"+this._secret),"Basic "+i):null===this._tokenKey?"Bearer "+this._token:(n=this.macParams(t,e,r),"MAC kid="+n.kid+" ts="+n.ts+" "+("access_token="+this._token+" mac="+n.mac))},t.prototype.addAuthParams=function(t,e,r){var n;return null===this._token?(r.client_id=this._id,null!==this._secret&&(r.client_secret=this._secret)):(null!==this._tokenKey&&(n=this.macParams(t,e,r),r.kid=n.kid,r.ts=n.ts,r.mac=n.mac),r.access_token=this._token),r},t.prototype.authorizeUrlParams=function(t,e){var r;if("token"!==t&&"code"!==t)throw new Error("Unimplemented /authorize response type "+t);return r={client_id:this._id,state:this._stateParam,response_type:t},e&&(r.redirect_uri=e),r},t.prototype.accessTokenParams=function(t){var e;return e={grant_type:"authorization_code",code:this._authCode},t&&(e.redirect_uri=t),e},t.queryParamsFromUrl=function(t){var e,r,n,i,o,s,a,u,h,l;if(i=/^[^?#]+(\?([^\#]*))?(\#(.*))?$/.exec(t),!i)return{};for(a=i[2]||"","/"===a.substring(0,1)&&(a=a.substring(1)),e=i[4]||"",r=e.indexOf("?"),-1!==r&&(e=e.substring(r+1)),"/"===e.substring(0,1)&&(e=e.substring(1)),s={},l=a.split("&").concat(e.split("&")),u=0,h=l.length;h>u;u++)n=l[u],o=n.indexOf("="),-1!==o&&(s[decodeURIComponent(n.substring(0,o))]=decodeURIComponent(n.substring(o+1)));return s},t.prototype.macParams=function(t,e,r){var n,i;return n={kid:this._tokenKid,ts:l.Util.Oauth.timestamp()},i=t.toUpperCase()+"&"+l.Util.Xhr.urlEncodeValue(e)+"&"+l.Util.Xhr.urlEncodeValue(l.Util.Xhr.urlEncode(r)),n.mac=l.Util.hmac(i,this._tokenKey),n},t.prototype.appHash=function(){return this._appHash?this._appHash:this._appHash=l.Util.sha1("oauth2-"+this._id).replace(/[\/+=]/g,"")},t.prototype.reset=function(){return this._stateParam=null,this._authCode=null,this._token=null,this._tokenKey=null,this._tokenKid=null,this._error=null,this},t.timestamp=function(){return Math.floor(Date.now()/1e3)},t.randomAuthStateParam=function(){return["oas",Date.now().toString(36),Math.random().toString(36)].join("_")},t}(),null==Date.now&&(l.Util.Oauth.timestamp=function(){return Math.floor((new Date).getTime()/1e3)}),2274814865e3===new Date("Fri, 31 Jan 2042 21:01:05 +0000").valueOf()?l.Util.parseDate=function(t){return new Date(t)}:2274814865e3===Date.parse("Fri, 31 Jan 2042 21:01:05 +0000")?l.Util.parseDate=function(t){return new Date(Date.parse(t))}:!function(){var t,e;return e=/^\w+\, (\d+) (\w+) (\d+) (\d+)\:(\d+)\:(\d+) (\+\d+|UTC|GMT)$/,t={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11},l.Util.parseDate=function(r){var n;return(n=e.exec(r))?new Date(Date.UTC(parseInt(n[3]),t[n[2]],parseInt(n[1]),parseInt(n[4]),parseInt(n[5]),parseInt(n[6]),0)):0/0}}(),l.Env.global.XMLHttpRequest?(!l.Env.global.XDomainRequest||"withCredentials"in new XMLHttpRequest?(a=XMLHttpRequest,s=!1,i="undefined"!=typeof FormData&&-1===navigator.userAgent.indexOf("Firefox")):(a=XDomainRequest,s=!0,i=!1),o=!0):(a=l.Env.require("xhr2"),s=!1,i=!1,o=!1),l.Env.global.Uint8Array)if(Object.getPrototypeOf?n=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array(0))).constructor:Object.__proto__&&(n=new Uint8Array(0).__proto__.__proto__.constructor),l.Env.global.Blob){try{!function(){return 2===new Blob([new Uint8Array(2)]).size?(h=!0,u=!0):(u=!1,h=2===new Blob([new ArrayBuffer(2)]).size)}()}catch(f){u=!1,h=!1,l.Env.global.WebKitBlobBuilder&&-1!==navigator.userAgent.indexOf("Android")&&(i=!1)}n===Object&&(u=!1)}else h=!1,u=!0;else n=null,h=!1,u=!1;l.Util.Xhr=function(){function t(t,e){this.method=t,this.isGet="GET"===this.method,this.url=e,this.wantHeaders=!1,this.headers={},this.params=null,this.body=null,this.preflight=!(this.isGet||"POST"===this.method),this.signed=!1,this.completed=!1,this.responseType=null,this.callback=null,this.xhr=null,this.onError=null}return t.Request=a,t.ieXdr=s,t.canSendForms=i,t.doesPreflight=o,t.ArrayBufferView=n,t.sendArrayBufferView=u,t.wrapBlob=h,t.prototype.xhr=null,t.prototype.onError=null,t.prototype.setParams=function(t){if(this.signed)throw new Error("setParams called after addOauthParams or addOauthHeader");if(this.params)throw new Error("setParams cannot be called twice");return this.params=t,this},t.prototype.setCallback=function(t){return this.callback=t,this},t.prototype.signWithOauth=function(t,e){return l.Util.Xhr.ieXdr?this.addOauthParams(t):this.preflight||!l.Util.Xhr.doesPreflight?this.addOauthHeader(t):this.isGet&&e?this.addOauthHeader(t):this.addOauthParams(t)},t.prototype.addOauthParams=function(t){if(this.signed)throw new Error("Request already has an OAuth signature");return this.params||(this.params={}),t.addAuthParams(this.method,this.url,this.params),this.signed=!0,this},t.prototype.addOauthHeader=function(t){if(this.signed)throw new Error("Request already has an OAuth signature");return this.params||(this.params={}),this.signed=!0,this.setHeader("Authorization",t.authHeader(this.method,this.url,this.params))},t.prototype.setBody=function(t){if(this.isGet)throw new Error("setBody cannot be called on GET requests");if(null!==this.body)throw new Error("Request already has a body");return"string"==typeof t||"undefined"!=typeof FormData&&t instanceof FormData||(this.headers["Content-Type"]="application/octet-stream",this.preflight=!0),this.body=t,this},t.prototype.setResponseType=function(t){return this.responseType=t,this},t.prototype.setHeader=function(t,e){var r;if(this.headers[t])throw r=this.headers[t],new Error("HTTP header "+t+" already set to "+r);if("Content-Type"===t)throw new Error("Content-Type is automatically computed based on setBody");return this.preflight=!0,this.headers[t]=e,this},t.prototype.reportResponseHeaders=function(){return this.wantHeaders=!0},t.prototype.setFileField=function(t,e,r,n){var i,o,s,a,u;if(null!==this.body)throw new Error("Request already has a body");if(this.isGet)throw new Error("setFileField cannot be called on GET requests");if("object"==typeof r){"undefined"!=typeof ArrayBuffer&&(r instanceof ArrayBuffer?l.Util.Xhr.sendArrayBufferView&&(r=new Uint8Array(r)):!l.Util.Xhr.sendArrayBufferView&&0===r.byteOffset&&r.buffer instanceof ArrayBuffer&&(r=r.buffer)),n||(n="application/octet-stream");try{r=new Blob([r],{type:n})}catch(h){o=h,window.WebKitBlobBuilder&&(a=new WebKitBlobBuilder,a.append(r),(i=a.getBlob(n))&&(r=i))}"undefined"!=typeof File&&r instanceof File&&(r=new Blob([r],{type:r.type})),u=r instanceof Blob}else u=!1;return u?(this.body=new FormData,this.body.append(t,r,e)):(n||(n="application/octet-stream"),s=this.multipartBoundary(),this.headers["Content-Type"]="multipart/form-data; boundary="+s,this.body=["--",s,"\r\n",'Content-Disposition: form-data; name="',t,'"; filename="',e,'"\r\n',"Content-Type: ",n,"\r\n","Content-Transfer-Encoding: binary\r\n\r\n",r,"\r\n","--",s,"--","\r\n"].join(""))},t.prototype.multipartBoundary=function(){return[Date.now().toString(36),Math.random().toString(36)].join("----")},t.prototype.paramsToUrl=function(){var t;return this.params&&(t=l.Util.Xhr.urlEncode(this.params),0!==t.length&&(this.url=[this.url,"?",t].join("")),this.params=null),this},t.prototype.paramsToBody=function(){if(this.params){if(null!==this.body)throw new Error("Request already has a body");if(this.isGet)throw new Error("paramsToBody cannot be called on GET requests");this.headers["Content-Type"]="application/x-www-form-urlencoded",this.body=l.Util.Xhr.urlEncode(this.params),this.params=null}return this},t.prototype.prepare=function(){var t,e,r,n,i=this;if(e=l.Util.Xhr.ieXdr,this.isGet||null!==this.body||e?(this.paramsToUrl(),null!==this.body&&"string"==typeof this.body&&(this.headers["Content-Type"]="text/plain; charset=utf8")):this.paramsToBody(),this.xhr=new l.Util.Xhr.Request,e?(this.xhr.onload=function(){return i.onXdrLoad()},this.xhr.onerror=function(){return i.onXdrError()},this.xhr.ontimeout=function(){return i.onXdrError()},this.xhr.onprogress=function(){}):this.xhr.onreadystatechange=function(){return i.onReadyStateChange()},this.xhr.open(this.method,this.url,!0),!e){n=this.headers;for(t in n)p.call(n,t)&&(r=n[t],this.xhr.setRequestHeader(t,r))}return this.responseType&&("b"===this.responseType?this.xhr.overrideMimeType&&this.xhr.overrideMimeType("text/plain; charset=x-user-defined"):this.xhr.responseType=this.responseType),this},t.prototype.send=function(t){var e,r;if(this.callback=t||this.callback,null!==this.body){e=this.body,l.Util.Xhr.sendArrayBufferView?e instanceof ArrayBuffer&&(e=new Uint8Array(e)):0===e.byteOffset&&e.buffer instanceof ArrayBuffer&&(e=e.buffer);try{this.xhr.send(e)}catch(n){if(r=n,l.Util.Xhr.sendArrayBufferView||!l.Util.Xhr.wrapBlob)throw r;e=new Blob([e],{type:"application/octet-stream"}),this.xhr.send(e)}}else this.xhr.send();return this},t.urlEncode=function(t){var e,r,n;e=[];for(r in t)n=t[r],e.push(this.urlEncodeValue(r)+"="+this.urlEncodeValue(n));return e.sort().join("&")},t.urlEncodeValue=function(t){return encodeURIComponent(t.toString()).replace(/\!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")},t.urlDecode=function(t){var e,r,n,i,o,s;for(r={},s=t.split("&"),i=0,o=s.length;o>i;i++)n=s[i],e=n.split("="),r[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return r},t.prototype.onReadyStateChange=function(){var t,e,r,n,i,o,s,a,u,h,p,c,d,f,_;if(4!==this.xhr.readyState)return!0;if(this.completed)return!0;if(this.completed=!0,this.xhr.status<200||this.xhr.status>=300)return e=new l.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(e,this.callback):this.callback(e),!0;if(this.wantHeaders?(t=this.xhr.getAllResponseHeaders(),s=t?l.Util.Xhr.parseResponseHeaders(t):this.guessResponseHeaders(),p=s["x-dropbox-metadata"]):(s=void 0,p=this.xhr.getResponseHeader("x-dropbox-metadata")),null!=p?p.length:void 0)try{h=JSON.parse(p)}catch(y){if(u=y,o=p.search(/\}\,\s*\{/),-1!==o)try{p=p.substring(0,o+1),h=JSON.parse(p)}catch(y){u=y,h=void 0}else h=void 0}else h=void 0;if(this.responseType){if("b"===this.responseType){for(i=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,r=[],a=f=0,_=i.length;_>=0?_>f:f>_;a=_>=0?++f:--f)r.push(String.fromCharCode(255&i.charCodeAt(a)));d=r.join(""),this.callback(null,d,h,s)}else this.callback(null,this.xhr.response,h,s);return!0}switch(d=null!=this.xhr.responseText?this.xhr.responseText:this.xhr.response,n=this.xhr.getResponseHeader("Content-Type"),n&&(c=n.indexOf(";"),-1!==c&&(n=n.substring(0,c))),n){case"application/x-www-form-urlencoded":this.callback(null,l.Util.Xhr.urlDecode(d),h,s);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(d),h,s);break;default:this.callback(null,d,h,s)}return!0},t.parseResponseHeaders=function(t){var e,r,n,i,o,s,a,u;for(n={},r=t.split("\n"),a=0,u=r.length;u>a;a++)i=r[a],e=i.indexOf(":"),o=i.substring(0,e).trim().toLowerCase(),s=i.substring(e+1).trim(),n[o]=s;return n},t.prototype.guessResponseHeaders=function(){var t,e,r,n,i,o;for(t={},o=["cache-control","content-language","content-range","content-type","expires","last-modified","pragma","x-dropbox-metadata"],n=0,i=o.length;i>n;n++)e=o[n],r=this.xhr.getResponseHeader(e),r&&(t[e]=r);return t},t.prototype.onXdrLoad=function(){var t,e,r;if(this.completed)return!0;if(this.completed=!0,r=this.xhr.responseText,t=this.wantHeaders?{"content-type":this.xhr.contentType}:void 0,e=void 0,this.responseType)return this.callback(null,r,e,t),!0;switch(this.xhr.contentType){case"application/x-www-form-urlencoded":this.callback(null,l.Util.Xhr.urlDecode(r),e,t);break;case"application/json":case"text/javascript":this.callback(null,JSON.parse(r),e,t);break;default:this.callback(null,r,e,t)}return!0},t.prototype.onXdrError=function(){var t;return this.completed?!0:(this.completed=!0,t=new l.ApiError(this.xhr,this.method,this.url),this.onError?this.onError(t,this.callback):this.callback(t),!0)},t}()}).call(this);
//# sourceMappingURL=dropbox.min.map