@pageproof/sdk-pr 112.0.1538690321374 → 116.0.1539574885779

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0-beta.54
4
+
5
+ Released on the 9th of October 2018.
6
+
7
+ - [[#90](https://github.com/PageProofCom/sdk/pull/90)] Added [Dashboard.briefs](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Dashboard.js~Dashboard.html#instance-method-briefs) for loading briefs. Added support for advanced filters in [Dashboard.search](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Dashboard.js~Dashboard.html#instance-method-search). The `onLoadThumbnails` option is now passed multiple thumbnails, and is throttled (see `onLoadThumbnailsThrottleMs` option), and the `onLoadThumbnail` option provides backwards compatibility. You can also receive a callback (`onLoadError`) when thumbnails fail to load (for any reason). See [Files.thumbnails](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Files.js~Files.html#instance-method-thumbnails). Team administrators can now load their team dashboard - see [TeamDashboard](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/admin/TeamDashboard.js~TeamDashboard.html). The Proof model now contains the collection ID (aka. group ID) it belongs to ([Proof.groupId](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-member-groupId)). As well as the category of file it is ([Proof.fileCategory](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-member-fileCategory)). It also contains a couple of helper methods for checking if a particular user is an editor or recipient of the proof - [Proof.isEditor](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-method-isEditor), and [Proof.isRecipient](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-method-isRecipient).
8
+
3
9
  ## 2.0.0-beta.53
4
10
 
5
11
  Released on the 5th of October 2018.
package/README.md CHANGED
@@ -269,6 +269,7 @@ Name | Namespace | Description | Admin-only | Stability
269
269
  [Workflows API](./class/src/api/Workflows.js~Workflows.html) | `workflows` | Used to create & manage workflows and workflow templates. | No | Stable
270
270
  [Workflows Steps API](./class/src/api/WorkflowsSteps.js~WorkflowsSteps.html) | `workflows.steps` | Used to manage workflow steps in workflow templates. | No | Experimental
271
271
  [Admin Team Users API](./class/src/api/admin/TeamUsers.js~TeamUsers.html) | `admin.team.users` | Administer users in a team or enterprise account. | Yes | Experimental
272
+ [Admin Team Dashboard API](./class/src/api/admin/TeamDashboard.js~TeamDashboard.html) | `admin.team.dashboard` | Used to load the authenticated user's team's dashboard & search for/filter proofs. | Yes | Experimental
272
273
  [Proofs Editors API](./class/src/api/ProofsEditors.js~ProofsEditors.html) | `proofs.editors` | Used to add & remove editors from proofs. | No | Experimental
273
274
  [Proofs Groups Owners API](./class/src/api/GroupsOwners.js~GroupsOwners.html) | `proofs.groups.owners` | Used to add owners to proofs in a group. | No | Stable
274
275
  [Proofs Groups Workflows API](./class/src/api/GroupsWorkflows.js~GroupsWorkflows.html) | `proofs.groups.workflows` | Used to add reviewers to proofs in a group. | No | Stable
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _DashboardGroups=require("./DashboardGroups");var _DashboardGroups2=_interopRequireDefault(_DashboardGroups);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var TABS={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox"};function transformTabs(data){var tabs={};Object.keys(TABS).forEach(function(name){tabs[name]=data[TABS[name]]});return tabs}function transformProofs(proofs){return(proofs||[]).map(function(proofData){return(new _Proof2.default).fromProof(proofData)})}var Dashboard=function(_API){_inherits(Dashboard,_API);function Dashboard(client){_classCallCheck(this,Dashboard);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.groups=new _DashboardGroups2.default(client);return _this}Dashboard.prototype.inbox=function inbox(){return this._loadSingleTabProofs("inbox")};Dashboard.prototype.sent=function sent(){return this._loadSingleTabProofs("sent")};Dashboard.prototype.outbox=function outbox(){return this._loadSingleTabProofs("outbox")};Dashboard.prototype._loadSingleTabProofs=function _loadSingleTabProofs(name){return this.client.request("dashboard."+name).then(function(response){return transformTabs(response.data)}).then(function(dashboard){return dashboard[name]}).then(transformProofs)};Dashboard.prototype.search=function search(query){return this._loadSearchProofs({query:query})};Dashboard.prototype.everything=function everything(){return this._loadSearchProofs({all:1})};Dashboard.prototype.approved=function approved(){return this._loadSearchProofs({filterBy:70})};Dashboard.prototype.archived=function archived(){return this._loadSearchProofs({filterBy:100})};Dashboard.prototype._loadSearchProofs=function _loadSearchProofs(params){return this.client.request("dashboard.search",params).then(function(response){return transformProofs(response.data.Proofs)})};return Dashboard}(_API3.default);exports.default=Dashboard;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _DashboardGroups=require("./DashboardGroups");var _DashboardGroups2=_interopRequireDefault(_DashboardGroups);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var TABS={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox",briefs:"AllBriefs"};function transformTabs(data){var tabs={};Object.keys(TABS).forEach(function(name){tabs[name]=data[TABS[name]]});return tabs}function transformProofs(proofs){return(proofs||[]).map(function(proofData){return(new _Proof2.default).fromProof(proofData)})}var Dashboard=function(_API){_inherits(Dashboard,_API);function Dashboard(client){_classCallCheck(this,Dashboard);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.groups=new _DashboardGroups2.default(client);return _this}Dashboard.prototype.inbox=function inbox(){return this._loadSingleTabProofs("inbox")};Dashboard.prototype.sent=function sent(){return this._loadSingleTabProofs("sent")};Dashboard.prototype.outbox=function outbox(){return this._loadSingleTabProofs("outbox")};Dashboard.prototype.briefs=function briefs(){return this._loadSingleTabProofs("briefs")};Dashboard.prototype._loadSingleTabProofs=function _loadSingleTabProofs(name){return this.client.request("dashboard."+name).then(function(response){return transformTabs(response.data)}).then(function(dashboard){return dashboard[name]}).then(transformProofs)};Dashboard.prototype.search=function search(query){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var status=options.status,everything=options.everything;return this._loadSearchProofs({query:query,filterBy:typeof status==="undefined"?undefined:[].concat(status).join(","),all:everything?1:0})};Dashboard.prototype.everything=function everything(){return this.search(undefined,{everything:true})};Dashboard.prototype.approved=function approved(){return this.search(undefined,{status:_ProofStatus2.default.APPROVED})};Dashboard.prototype.archived=function archived(){return this.search(undefined,{status:_ProofStatus2.default.ARCHIVED})};Dashboard.prototype._loadSearchProofs=function _loadSearchProofs(params){return this.client.request("dashboard.search",params).then(function(response){return transformProofs(response.data.Proofs)})};return Dashboard}(_API3.default);exports.default=Dashboard;
package/lib/api/Files.js CHANGED
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _getContentLength=require("../util/getContentLength");var _getContentLength2=_interopRequireDefault(_getContentLength);var _constants=require("../util/constants");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype.import=function _import(_ref){var _this3=this;var name=_ref.name,url=_ref.url,_ref$provider=_ref.provider,provider=_ref$provider===undefined?_ImportProvider2.default.NONE:_ref$provider,auth=_ref.auth,_ref$download=_ref.download,download=_ref$download===undefined?false:_ref$download,_ref$process=_ref.process,process=_ref$process===undefined?false:_ref$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref2){var envelope=_ref2.envelope;return _this3.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data}).then(function(token){if(process){return _this3._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this4=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this4.client.crypto().envelopeSeal(keyIV.keyIV,[_this4.client.session.serverPublicKeyPEM,_this4.client.session.publicKeyPEM])])}).then(function(_ref3){var keyIV=_ref3[0],envelope=_ref3[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(_ref4){var _this5=this;var name=_ref4.name,contents=_ref4.contents,assignedTo=_ref4.assignedTo,assignedType=_ref4.assignedType,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$async=_ref4.async,async=_ref4$async===undefined?true:_ref4$async,onProgress=_ref4.onProgress,onError=_ref4.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this5._generateKeyIVEnvelope()])}).then(function(_ref5){var token=_ref5[0],_ref5$=_ref5[1],keyIV=_ref5$.keyIV,envelope=_ref5$.envelope;var process=_this5._upload({name:name,contents:contents,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload=function _upload(_ref6){var _this6=this;var name=_ref6.name,contents=_ref6.contents,download=_ref6.download,token=_ref6.token,keyIV=_ref6.keyIV,envelope=_ref6.envelope,onProgress=_ref6.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var count=Math.ceil((0,_getContentLength2.default)(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this6.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this6.client.request("files.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this6.client.request("files.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this7=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}if(onFileDetails){onFileDetails(file)}return _this7._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this8=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this8.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this8.client.crypto().decryptFileBlock(response.data,_this8.client.session.privateKeyPEM).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this9=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this9._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this10=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this10.client.crypto().decryptImage(response.data,_this10.client.session.privateKeyPEM)}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref7){var _this11=this;var _ref7$async=_ref7.async,async=_ref7$async===undefined?false:_ref7$async,onLoadThumbnails=_ref7.onLoadThumbnails;var scheduled=[];return Promise.all(fileIds.map(function(fileId){return _this11.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref8;return thumbnail&&(_ref8={},_ref8[fileId]=thumbnail,_ref8)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref9){var fileId=_ref9.fileId,resolve=_ref9.resolve;return _this11._thumbnail(fileId).then(function(thumbnail){resolve(thumbnail);if(async){var _onLoadThumbnails;onLoadThumbnails((_onLoadThumbnails={},_onLoadThumbnails[fileId]=thumbnail,_onLoadThumbnails))}return thumbnail})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};return Files}(_API3.default);exports.default=Files;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _getContentLength=require("../util/getContentLength");var _getContentLength2=_interopRequireDefault(_getContentLength);var _constants=require("../util/constants");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype.import=function _import(_ref){var _this3=this;var name=_ref.name,url=_ref.url,_ref$provider=_ref.provider,provider=_ref$provider===undefined?_ImportProvider2.default.NONE:_ref$provider,auth=_ref.auth,_ref$download=_ref.download,download=_ref$download===undefined?false:_ref$download,_ref$process=_ref.process,process=_ref$process===undefined?false:_ref$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref2){var envelope=_ref2.envelope;return _this3.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data}).then(function(token){if(process){return _this3._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this4=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this4.client.crypto().envelopeSeal(keyIV.keyIV,[_this4.client.session.serverPublicKeyPEM,_this4.client.session.publicKeyPEM])])}).then(function(_ref3){var keyIV=_ref3[0],envelope=_ref3[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(_ref4){var _this5=this;var name=_ref4.name,contents=_ref4.contents,assignedTo=_ref4.assignedTo,assignedType=_ref4.assignedType,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$async=_ref4.async,async=_ref4$async===undefined?true:_ref4$async,onProgress=_ref4.onProgress,onError=_ref4.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this5._generateKeyIVEnvelope()])}).then(function(_ref5){var token=_ref5[0],_ref5$=_ref5[1],keyIV=_ref5$.keyIV,envelope=_ref5$.envelope;var process=_this5._upload({name:name,contents:contents,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload=function _upload(_ref6){var _this6=this;var name=_ref6.name,contents=_ref6.contents,download=_ref6.download,token=_ref6.token,keyIV=_ref6.keyIV,envelope=_ref6.envelope,onProgress=_ref6.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var count=Math.ceil((0,_getContentLength2.default)(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this6.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this6.client.request("files.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this6.client.request("files.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this7=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}if(onFileDetails){onFileDetails(file)}return _this7._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this8=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this8.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this8.client.crypto().decryptFileBlock(response.data,_this8.client.session.privateKeyPEM).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this9=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this9._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this10=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this10.client.crypto().decryptImage(response.data,_this10.client.session.privateKeyPEM)}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref7){var _this11=this;var _ref7$async=_ref7.async,async=_ref7$async===undefined?false:_ref7$async,onLoadThumbnail=_ref7.onLoadThumbnail,onLoadThumbnails=_ref7.onLoadThumbnails,_ref7$onLoadThumbnail=_ref7.onLoadThumbnailsThrottleMs,onLoadThumbnailsThrottleMs=_ref7$onLoadThumbnail===undefined?1e3:_ref7$onLoadThumbnail,onLoadError=_ref7.onLoadError;var scheduled=[];var pendingBatch={};var scheduleOnLoadThumbnails=onLoadThumbnails?(0,_throttle2.default)(function(){if(Object.keys(pendingBatch).length){onLoadThumbnails(pendingBatch);pendingBatch={}}},onLoadThumbnailsThrottleMs):function(){};return Promise.all(fileIds.map(function(fileId){return _this11.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref8;return thumbnail&&(_ref8={},_ref8[fileId]=thumbnail,_ref8)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref9){var fileId=_ref9.fileId,resolve=_ref9.resolve;return _this11._thumbnail(fileId).then(function(thumbnail){var _ref10;resolve(thumbnail);if(onLoadThumbnail){var _onLoadThumbnail;onLoadThumbnail((_onLoadThumbnail={},_onLoadThumbnail[fileId]=thumbnail,_onLoadThumbnail))}pendingBatch[fileId]=thumbnail;scheduleOnLoadThumbnails();return _ref10={},_ref10[fileId]=thumbnail,_ref10}).catch(function(err){if(onLoadError){onLoadError(err,fileId)}if(!async){return Promise.reject(err)}return{}})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};return Files}(_API3.default);exports.default=Files;
@@ -10,6 +10,10 @@ var _TeamUsers = require('./TeamUsers');
10
10
 
11
11
  var _TeamUsers2 = _interopRequireDefault(_TeamUsers);
12
12
 
13
+ var _TeamDashboard = require('./TeamDashboard');
14
+
15
+ var _TeamDashboard2 = _interopRequireDefault(_TeamDashboard);
16
+
13
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
18
 
15
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -26,6 +30,12 @@ var Team = function (_API) {
26
30
  _inherits(Team, _API);
27
31
 
28
32
  /** @private */
33
+
34
+ /**
35
+ * The Admin Team Users API.
36
+ *
37
+ * @type {TeamUsers}
38
+ */
29
39
  function Team(client) {
30
40
  _classCallCheck(this, Team);
31
41
 
@@ -33,12 +43,14 @@ var Team = function (_API) {
33
43
  var _this = _possibleConstructorReturn(this, _API.call(this, client));
34
44
 
35
45
  _this.users = new _TeamUsers2.default(client);
46
+ _this.dashboard = new _TeamDashboard2.default(client);
36
47
  return _this;
37
48
  }
49
+
38
50
  /**
39
- * The Admin Team Users API.
51
+ * The Admin Team Dashboard API.
40
52
  *
41
- * @type {TeamUsers}
53
+ * @type {TeamDashboard}
42
54
  */
43
55
 
44
56
 
@@ -0,0 +1,189 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _API2 = require('../API');
6
+
7
+ var _API3 = _interopRequireDefault(_API2);
8
+
9
+ var _Proof = require('../../models/Proof');
10
+
11
+ var _Proof2 = _interopRequireDefault(_Proof);
12
+
13
+ var _ProofStatus = require('../../enum/ProofStatus');
14
+
15
+ var _ProofStatus2 = _interopRequireDefault(_ProofStatus);
16
+
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+
19
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
+
21
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
22
+
23
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* Copyright (C) 2018 PageProof Holdings Limited - All Rights Reserved.
24
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
25
+ * Proprietary and confidential.
26
+ */
27
+
28
+
29
+ var TABS = {
30
+ inbox: 'ProofIn',
31
+ sent: 'ProofSent',
32
+ outbox: 'ProofOut',
33
+ search: 'Proofs'
34
+ };
35
+
36
+ function transformTeamTab(data, name) {
37
+ var tab = {};
38
+ tab.proofs = transformProofs(data[TABS[name]]);
39
+ tab.total = data.ProofsNumber;
40
+ return tab;
41
+ }
42
+
43
+ function transformProofs(proofs) {
44
+ return (proofs || []).map(function (proofData) {
45
+ return new _Proof2.default().fromProof(proofData);
46
+ });
47
+ }
48
+
49
+ var TeamDashboard = function (_API) {
50
+ _inherits(TeamDashboard, _API);
51
+
52
+ function TeamDashboard() {
53
+ _classCallCheck(this, TeamDashboard);
54
+
55
+ return _possibleConstructorReturn(this, _API.apply(this, arguments));
56
+ }
57
+
58
+ /**
59
+ * Loads all the proofs in the team's inbox.
60
+ *
61
+ * @since 2.0.0-beta.54
62
+ * @param {number} page The page number
63
+ * @returns {Promise<TeamDashboardPagination>}
64
+ */
65
+ TeamDashboard.prototype.inbox = function inbox(page) {
66
+ return this._loadSingleTeamTabProofs('inbox', { page: page });
67
+ };
68
+
69
+ /**
70
+ * Loads all the proofs in the team's sent box.
71
+ *
72
+ * @since 2.0.0-beta.54
73
+ * @param {number} page The page number
74
+ * @returns {Promise<TeamDashboardPagination>}
75
+ */
76
+
77
+
78
+ TeamDashboard.prototype.sent = function sent(page) {
79
+ return this._loadSingleTeamTabProofs('sent', { page: page });
80
+ };
81
+
82
+ /**
83
+ * Loads all the proofs in the team's outbox.
84
+ *
85
+ * @since 2.0.0-beta.54
86
+ * @param {number} page The page number
87
+ * @returns {Promise<TeamDashboardPagination>}
88
+ */
89
+
90
+
91
+ TeamDashboard.prototype.outbox = function outbox(page) {
92
+ return this._loadSingleTeamTabProofs('outbox', { page: page });
93
+ };
94
+
95
+ /** @private */
96
+
97
+
98
+ TeamDashboard.prototype._loadSingleTeamTabProofs = function _loadSingleTeamTabProofs(name, params) {
99
+ return this.client.request('team.dashboard.' + name, params).then(function (response) {
100
+ return transformTeamTab(response.data, name);
101
+ }).then(function (dashboard) {
102
+ return dashboard;
103
+ });
104
+ };
105
+
106
+ /**
107
+ * Loads all of the proofs in the team.
108
+ *
109
+ *
110
+ * @since 2.0.0-beta.54
111
+ * @param {number} page The page number
112
+ * @returns {Promise<TeamDashboardPagination>}
113
+ */
114
+
115
+
116
+ TeamDashboard.prototype.everything = function everything(page) {
117
+ return this.search(undefined, { everything: true, page: page });
118
+ };
119
+
120
+ /**
121
+ * Loads all the approved proofs in the team.
122
+ *
123
+ *
124
+ * @since 2.0.0-beta.54
125
+ * @param {number} page The page number
126
+ * @returns {Promise<TeamDashboardPagination>}
127
+ */
128
+
129
+
130
+ TeamDashboard.prototype.approved = function approved(page) {
131
+ return this.search(undefined, { status: _ProofStatus2.default.APPROVED, page: page });
132
+ };
133
+
134
+ /**
135
+ * Loads all the archived proofs in the team.
136
+ *
137
+ * @since 2.0.0-beta.54
138
+ * @param {number} page The page number
139
+ * @returns {Promise<TeamDashboardPagination>}
140
+ */
141
+
142
+
143
+ TeamDashboard.prototype.archived = function archived(page) {
144
+ return this.search(undefined, { status: _ProofStatus2.default.ARCHIVED, page: page });
145
+ };
146
+
147
+ /**
148
+ * Searches all the proofs in the team.
149
+ *
150
+ *
151
+ * @since 2.0.0-beta.54
152
+ * @param {string} query The search query
153
+ * @param {object} [options] Advanced options
154
+ * @param {ProofStatus|Array<ProofStatus>} [options.status] The proof status (or statuses)
155
+ * @param {boolean} [options.everything] Whether to load every proof the user has access to
156
+ * @param {number} [options.page] The page number for team dashboard
157
+ * @returns {Promise<TeamDashboardPagination>}
158
+ */
159
+
160
+
161
+ TeamDashboard.prototype.search = function search(query) {
162
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
163
+ var status = options.status,
164
+ everything = options.everything,
165
+ page = options.page;
166
+
167
+ return this._loadTeamSearchProofs({
168
+ query: query,
169
+ filterBy: typeof status === 'undefined' ? undefined // no status filter
170
+ : [].concat(status).join(','), // one or more statuses
171
+ all: everything ? 1 : 0,
172
+ page: page
173
+ });
174
+ };
175
+
176
+ /** @private */
177
+
178
+
179
+ TeamDashboard.prototype._loadTeamSearchProofs = function _loadTeamSearchProofs(params) {
180
+ return this.client.request('team.dashboard.search', params).then(function (response) {
181
+ return transformTeamTab(response.data, 'search');
182
+ });
183
+ };
184
+
185
+ return TeamDashboard;
186
+ }(_API3.default);
187
+
188
+ exports.default = TeamDashboard;
189
+ //# sourceMappingURL=TeamDashboard.js.map
@@ -0,0 +1 @@
1
+ "use strict";exports.__esModule=true;var FileCategory={STATIC:"static",VIDEO:"video",AUDIO:"audio",WEB:"web"};exports.default=FileCategory;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var ProofState={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active"};exports.default=ProofState;
1
+ "use strict";exports.__esModule=true;var ProofState={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",HAS_NEW_VERSION:"has-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active",SETUP_NEEDED:"setup-needed",BRIEFING:"briefing",AWAITING_PROOF:"awaiting-proof"};exports.default=ProofState;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var ProofStatus={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,APPROVED:70,ARCHIVED:100};exports.default=ProofStatus;
1
+ "use strict";exports.__esModule=true;var ProofStatus={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,HAS_NEW_VERSION:66,APPROVED:70,ARCHIVED:100};exports.default=ProofStatus;
@@ -0,0 +1 @@
1
+ "use strict";exports.__esModule=true;var ProofType={PROOF:1,BRIEF:2};exports.default=ProofType;
package/lib/enum/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;exports.Preference=exports.WorkflowUserState=exports.WorkflowUserRole=exports.WorkflowStepState=exports.ResponseStatus=exports.ProofStatus=exports.ProofState=exports.ImportProvider=exports.FileStatus=exports.FileAssignee=exports.CommentState=undefined;var _CommentState=require("./CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _FileAssignee=require("./FileAssignee");var _FileAssignee2=_interopRequireDefault(_FileAssignee);var _FileStatus=require("./FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("./ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _ProofState=require("./ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("./ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ResponseStatus=require("./ResponseStatus");var _ResponseStatus2=_interopRequireDefault(_ResponseStatus);var _WorkflowStepState=require("./WorkflowStepState");var _WorkflowStepState2=_interopRequireDefault(_WorkflowStepState);var _WorkflowUserRole=require("./WorkflowUserRole");var _WorkflowUserRole2=_interopRequireDefault(_WorkflowUserRole);var _WorkflowUserState=require("./WorkflowUserState");var _WorkflowUserState2=_interopRequireDefault(_WorkflowUserState);var _Preference=require("./Preference");var _Preference2=_interopRequireDefault(_Preference);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.CommentState=_CommentState2.default;exports.FileAssignee=_FileAssignee2.default;exports.FileStatus=_FileStatus2.default;exports.ImportProvider=_ImportProvider2.default;exports.ProofState=_ProofState2.default;exports.ProofStatus=_ProofStatus2.default;exports.ResponseStatus=_ResponseStatus2.default;exports.WorkflowStepState=_WorkflowStepState2.default;exports.WorkflowUserRole=_WorkflowUserRole2.default;exports.WorkflowUserState=_WorkflowUserState2.default;exports.Preference=_Preference2.default;
1
+ "use strict";exports.__esModule=true;exports.Preference=exports.FileCategory=exports.ProofType=exports.WorkflowUserState=exports.WorkflowUserRole=exports.WorkflowStepState=exports.ResponseStatus=exports.ProofStatus=exports.ProofState=exports.ImportProvider=exports.FileStatus=exports.FileAssignee=exports.CommentState=undefined;var _CommentState=require("./CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _FileAssignee=require("./FileAssignee");var _FileAssignee2=_interopRequireDefault(_FileAssignee);var _FileStatus=require("./FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("./ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _ProofState=require("./ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("./ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ResponseStatus=require("./ResponseStatus");var _ResponseStatus2=_interopRequireDefault(_ResponseStatus);var _WorkflowStepState=require("./WorkflowStepState");var _WorkflowStepState2=_interopRequireDefault(_WorkflowStepState);var _WorkflowUserRole=require("./WorkflowUserRole");var _WorkflowUserRole2=_interopRequireDefault(_WorkflowUserRole);var _WorkflowUserState=require("./WorkflowUserState");var _WorkflowUserState2=_interopRequireDefault(_WorkflowUserState);var _ProofType=require("./ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileCategory=require("./FileCategory");var _FileCategory2=_interopRequireDefault(_FileCategory);var _Preference=require("./Preference");var _Preference2=_interopRequireDefault(_Preference);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.CommentState=_CommentState2.default;exports.FileAssignee=_FileAssignee2.default;exports.FileStatus=_FileStatus2.default;exports.ImportProvider=_ImportProvider2.default;exports.ProofState=_ProofState2.default;exports.ProofStatus=_ProofStatus2.default;exports.ResponseStatus=_ResponseStatus2.default;exports.WorkflowStepState=_WorkflowStepState2.default;exports.WorkflowUserRole=_WorkflowUserRole2.default;exports.WorkflowUserState=_WorkflowUserState2.default;exports.ProofType=_ProofType2.default;exports.FileCategory=_FileCategory2.default;exports.Preference=_Preference2.default;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreatedDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,_transform.number)("Pages"),commentCount:(0,_transform.number)("ParentComments"),canDownload:(0,_transform.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",todoCommentCount:(0,_transform.number)("CountTodoComments"),doneCommentCount:(0,_transform.number)("CountDoneComments")};var Proof=function(){function Proof(){_classCallCheck(this,Proof)}Proof.prototype.getState=function getState(){var state=_ProofState2.default.ACTIVE;if(this.fileStatus===_FileStatus2.default.UPLOADING){state=_ProofState2.default.UPLOADING}else if(this.hasFileError()){state=_ProofState2.default.FILE_ERROR}else if(this.isProcessing()){state=_ProofState2.default.PROCESSING}else if(this.status===_ProofStatus2.default.ARCHIVED){state=_ProofState2.default.ARCHIVED}else if(!this.hasWorkflow()){state=_ProofState2.default.PROOFERS_NEEDED}else if(this.status===_ProofStatus2.default.TODOS_REQUESTED){state=_ProofState2.default.TODOS_REQUESTED}else if(this.status===_ProofStatus2.default.AWAITING_NEW_VERSION){state=_ProofState2.default.AWAITING_NEW_VERSION}else if(this.status===_ProofStatus2.default.APPROVED){state=_ProofState2.default.APPROVED}else if(!this.hasWorkflowStarted()){state=_ProofState2.default.NOT_STARTED}else if(this.isOverdue){state=_ProofState2.default.OVERDUE}return state};Proof.prototype.hasWorkflowStarted=function hasWorkflowStarted(){return this.hasWorkflow()&&this.status!==_ProofStatus2.default.NEW};Proof.prototype.isProcessing=function isProcessing(){return this.fileStatus===_FileStatus2.default.UPLOADING||this.fileStatus===_FileStatus2.default.QUEUED||this.fileStatus===_FileStatus2.default.RIPPING};Proof.prototype.getProcessingProgress=function getProcessingProgress(){switch(this.fileStatus){case _FileStatus2.default.UPLOADING:return.1;case _FileStatus2.default.QUEUED:return.2;case _FileStatus2.default.RIPPING:return.6;default:return-1}};Proof.prototype.hasWorkflow=function hasWorkflow(){return(0,_id.isWorkflowId)(this.workflowId)};Proof.prototype.hasFile=function hasFile(){return(0,_id.isFileId)(this.fileId)};Proof.prototype.hasFileError=function hasFileError(){return this.fileStatus===_FileStatus2.default.ERROR||!this.fileStatus||!this.hasFile()};Proof.prototype.hasEditor=function hasEditor(){return(0,_id.isUserId)(this.editorUserId)};Proof.prototype.hasThumbnail=function hasThumbnail(){return this.fileStatus===_FileStatus2.default.OK};Proof.prototype.canUserUploadNewVersion=function canUserUploadNewVersion(userId){return this.getState()===_ProofState2.default.AWAITING_NEW_VERSION&&(this.editorUserId===userId||this.isOwner(userId))};Proof.prototype.isOwner=function isOwner(userId){return this.ownerUserIds.indexOf(userId)!==-1};Proof.prototype.calculateState=function calculateState(){this.state=this.getState()};Proof.prototype.fromProof=function fromProof(proofData){(0,_transform2.default)(this,proofSchema,proofData);this.calculateState();return this};return Proof}();exports.default=Proof;
1
+ "use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ProofType=require("../enum/ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreatedDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,_transform.number)("Pages"),commentCount:(0,_transform.number)("ParentComments"),canDownload:(0,_transform.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",todoCommentCount:(0,_transform.number)("CountTodoComments"),doneCommentCount:(0,_transform.number)("CountDoneComments"),fileCategory:"FileCategory",isAdminOnProof:"IsAdminOnProof",groupId:"GroupId",canReupload:"CanReupload"};var Proof=function(){function Proof(){_classCallCheck(this,Proof)}Proof.prototype.getState=function getState(){var state=_ProofState2.default.ACTIVE;if(this.fileStatus===_FileStatus2.default.UPLOADING){state=_ProofState2.default.UPLOADING}else if(this.hasFileError()){state=_ProofState2.default.FILE_ERROR}else if(this.isProcessing()){state=_ProofState2.default.PROCESSING}else if(this.type===_ProofType2.default.BRIEF){switch(this.status){case _ProofStatus2.default.NEW:state=_ProofState2.default.SETUP_NEEDED;break;case _ProofStatus2.default.PROOFING:state=_ProofState2.default.BRIEFING;break;case _ProofStatus2.default.AWAITING_NEW_VERSION:state=_ProofState2.default.AWAITING_PROOF;break;case _ProofStatus2.default.HAS_NEW_VERSION:state=_ProofState2.default.HAS_NEW_VERSION;break;case _ProofStatus2.default.ARCHIVED:state=_ProofState2.default.ARCHIVED;break}}else if(this.status===_ProofStatus2.default.ARCHIVED){state=_ProofState2.default.ARCHIVED}else if(!this.hasWorkflow()){state=_ProofState2.default.PROOFERS_NEEDED}else if(this.status===_ProofStatus2.default.TODOS_REQUESTED){state=_ProofState2.default.TODOS_REQUESTED}else if(this.status===_ProofStatus2.default.AWAITING_NEW_VERSION){state=_ProofState2.default.AWAITING_NEW_VERSION}else if(this.status===_ProofStatus2.default.HAS_NEW_VERSION){state=_ProofState2.default.HAS_NEW_VERSION}else if(this.status===_ProofStatus2.default.APPROVED){state=_ProofState2.default.APPROVED}else if(!this.hasWorkflowStarted()){state=_ProofState2.default.NOT_STARTED}else if(this.isOverdue){state=_ProofState2.default.OVERDUE}return state};Proof.prototype.hasWorkflowStarted=function hasWorkflowStarted(){return this.hasWorkflow()&&this.status!==_ProofStatus2.default.NEW};Proof.prototype.isProcessing=function isProcessing(){return this.fileStatus===_FileStatus2.default.UPLOADING||this.fileStatus===_FileStatus2.default.QUEUED||this.fileStatus===_FileStatus2.default.RIPPING};Proof.prototype.getProcessingProgress=function getProcessingProgress(){switch(this.fileStatus){case _FileStatus2.default.UPLOADING:return.1;case _FileStatus2.default.QUEUED:return.2;case _FileStatus2.default.RIPPING:return.6;default:return-1}};Proof.prototype.hasWorkflow=function hasWorkflow(){return(0,_id.isWorkflowId)(this.workflowId)};Proof.prototype.hasFile=function hasFile(){return(0,_id.isFileId)(this.fileId)};Proof.prototype.hasFileError=function hasFileError(){return this.fileStatus===_FileStatus2.default.ERROR||!this.fileStatus||!this.hasFile()};Proof.prototype.hasEditor=function hasEditor(){return(0,_id.isUserId)(this.editorUserId)};Proof.prototype.hasThumbnail=function hasThumbnail(){return this.fileStatus===_FileStatus2.default.OK};Proof.prototype.canUserUploadNewVersion=function canUserUploadNewVersion(userId){return this.getState()===_ProofState2.default.AWAITING_NEW_VERSION&&(this.isEditor(userId)||this.isOwner(userId))||this.getState()===_ProofState2.default.AWAITING_PROOF&&(this.isEditor(userId)||this.isRecipient(userId))};Proof.prototype.isOwner=function isOwner(userId){return this.ownerUserIds.indexOf(userId)!==-1};Proof.prototype.isEditor=function isEditor(userId){return this.editorUserIds.indexOf(userId)!==-1};Proof.prototype.isRecipient=function isRecipient(userId){return this.recipient===userId};Proof.prototype.calculateState=function calculateState(){this.state=this.getState()};Proof.prototype.fromProof=function fromProof(proofData){(0,_transform2.default)(this,proofSchema,proofData);this.calculateState();return this};return Proof}();exports.default=Proof;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _Proof=require("./Proof");var _Proof2=_interopRequireDefault(_Proof);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var proofGroupSchema={id:"GroupId",name:"Name",proofs:(0,_transform.each)("ProofInfo",function(proofData){return(new _Proof2.default).fromProof(proofData)})};var ProofGroup=function(){function ProofGroup(){_classCallCheck(this,ProofGroup)}ProofGroup.prototype.fromProofGroup=function fromProofGroup(proofGroupData){(0,_transform2.default)(this,proofGroupSchema,proofGroupData);return this};return ProofGroup}();exports.default=ProofGroup;
1
+ "use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _Proof=require("./Proof");var _Proof2=_interopRequireDefault(_Proof);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var proofGroupSchema={ownerId:"CreatedBy",id:"GroupId",name:"Name",proofs:(0,_transform.each)("ProofInfo",function(proofData){return(new _Proof2.default).fromProof(proofData)})};var ProofGroup=function(){function ProofGroup(){_classCallCheck(this,ProofGroup)}ProofGroup.prototype.fromProofGroup=function fromProofGroup(proofGroupData){(0,_transform2.default)(this,proofGroupSchema,proofGroupData);return this};return ProofGroup}();exports.default=ProofGroup;
@@ -72,6 +72,11 @@
72
72
  "path": "/api/proofs/dashboard/proofoutbox",
73
73
  "trailing": true
74
74
  },
75
+ "dashboard.briefs": {
76
+ "method": "GET",
77
+ "path": "/api/briefs/dashboard",
78
+ "trailing": true
79
+ },
75
80
  "dashboard.search": {
76
81
  "method": "POST",
77
82
  "path": "/api/proofs/search",
@@ -83,6 +88,29 @@
83
88
  "chain": ["filterBy"],
84
89
  "trailing": true
85
90
  },
91
+ "team.dashboard.inbox": {
92
+ "method": "GET",
93
+ "path": "/api/admin/dashboard/proofin",
94
+ "chain": ["page"],
95
+ "trailing": true
96
+ },
97
+ "team.dashboard.sent": {
98
+ "method": "GET",
99
+ "path": "/api/admin/dashboard/proofsent",
100
+ "chain": ["page"],
101
+ "trailing": true
102
+ },
103
+ "team.dashboard.outbox": {
104
+ "method": "GET",
105
+ "path": "/api/admin/dashboard/proofout",
106
+ "chain": ["page"],
107
+ "trailing": true
108
+ },
109
+ "team.dashboard.search": {
110
+ "method": "POST",
111
+ "path": "/api/admin/search",
112
+ "body": ["query", "all", "filterBy", "page"]
113
+ },
86
114
  "users.by-id": {
87
115
  "method": "GET",
88
116
  "path": "/api/users",
package/lib/pageproof.js CHANGED
@@ -1,9 +1,9 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProof=t():e.PageProof=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=30)}([function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function e(t){o(this,e),this.client=t};t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){var o=[],r={};return Array.isArray(t)?(o=t,t.forEach(function(e){r[e]=e})):(0,y.default)(t)&&(o=Object.keys(t),r=t),o.forEach(function(t){var o=r[t],i=void 0;if("string"==typeof o)i=-1!==o.indexOf(".")?function(){for(var e=o.split("."),t=n,r=0;r<e.length;r++){var i=e[r];if(!(0,w.default)(t,i)){t=void 0;break}t=t[i]}return t}:function(){return n[o]};else{if("function"!=typeof o){if(null===o)return;throw new Error("Unknown transformer.")}i=o}var s=i.call(e,n);void 0!==s&&(e[t]=s)}),e}function i(e){return function(t){return Number(t[e])}}function s(e,t){return function(n){return t[n[e]]}}function a(e){return function(t){var n=t[e];if(n&&"0001-01-01T00:00:00"!==n)return"number"==typeof n?new Date(1e3*n):new Date(n+"Z")}}function u(e){return function(t){var n=String(t[e]);return"1"===n||"true"===n}}function f(e){return function(t){return w.default.call(t,e)}}function c(e,t){return function(n){return n[e]?n[e].map(t):[]}}function l(e,t){return function(n){return n[e]?JSON.parse(n[e]):Array.isArray(t)?[].concat(t):d({},t)}}function p(e){return function(t){return t[e]?t[e]:void 0}}t.__esModule=!0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e};t.number=i,t.enumeration=s,t.date=a,t.truthy=u,t.exists=f,t.each=c,t.json=l,t.optional=p;var h=n(16),y=o(h),m=n(9),w=o(m);t.default=r},function(e,t,n){"use strict";t.__esModule=!0;t.TOKEN_HEADER="x-authorization-token",t.HMAC_HEADER="x-authorization-hmac",t.TIMESTAMP_HEADER="x-timestamp",t.DEVICE_ID_HEADER="x-device-id",t.SUBSCRIPTION_KEY_HEADER="ocp-apim-subscription-key",t.SDK_VERSION_HEADER="x-pageproof-javascript-sdk",t.RETRY_AFTER_HEADER="retry-after",t.BYTES_PER_BLOCK=2097152,t.MENTION_REGEX=/@{(U[a-zA-Z0-9]{15}|~everyone)}{(.*?)}/g,t.ISO_REGEX=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,t.DEFAULT_ISO_DATE="0001-01-01T00:00:00",t.DAY_IN_MS=864e5,t.COMMENT_CACHE_PREFIX="comment",t.THUMBNAIL_CACHE_PREFIX="thumbnail"},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),s={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,r.date)("Registered"),lastLoginDate:(0,r.date)("LastLogin"),lastUploadDate:(0,r.date)("LastUpload"),isAdmin:"IsDomainAdmin"},a=function(){function e(){o(this,e)}return e.prototype.fromJSON=function(e){return(0,i.default)(this,Object.keys(s),e),this},e.prototype.fromUser=function(e){return(0,i.default)(this,s,e),this},e}();t.default=a},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return this.dueDate&&this.dueDate.getTime()<Date.now()}t.__esModule=!0;var s=n(1),a=o(s),u=n(18),f=o(u),c=n(19),l=o(c),p=n(5),d=o(p),h=n(20),y={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,s.date)("DueDate"),createdDate:(0,s.date)("CreatedDate"),approvedDate:(0,s.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:i,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,s.number)("Pages"),commentCount:(0,s.number)("ParentComments"),canDownload:(0,s.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",todoCommentCount:(0,s.number)("CountTodoComments"),doneCommentCount:(0,s.number)("CountDoneComments")},m=function(){function e(){r(this,e)}return e.prototype.getState=function(){var e=f.default.ACTIVE;return this.fileStatus===d.default.UPLOADING?e=f.default.UPLOADING:this.hasFileError()?e=f.default.FILE_ERROR:this.isProcessing()?e=f.default.PROCESSING:this.status===l.default.ARCHIVED?e=f.default.ARCHIVED:this.hasWorkflow()?this.status===l.default.TODOS_REQUESTED?e=f.default.TODOS_REQUESTED:this.status===l.default.AWAITING_NEW_VERSION?e=f.default.AWAITING_NEW_VERSION:this.status===l.default.APPROVED?e=f.default.APPROVED:this.hasWorkflowStarted()?this.isOverdue&&(e=f.default.OVERDUE):e=f.default.NOT_STARTED:e=f.default.PROOFERS_NEEDED,e},e.prototype.hasWorkflowStarted=function(){return this.hasWorkflow()&&this.status!==l.default.NEW},e.prototype.isProcessing=function(){return this.fileStatus===d.default.UPLOADING||this.fileStatus===d.default.QUEUED||this.fileStatus===d.default.RIPPING},e.prototype.getProcessingProgress=function(){switch(this.fileStatus){case d.default.UPLOADING:return.1;case d.default.QUEUED:return.2;case d.default.RIPPING:return.6;default:return-1}},e.prototype.hasWorkflow=function(){return(0,h.isWorkflowId)(this.workflowId)},e.prototype.hasFile=function(){return(0,h.isFileId)(this.fileId)},e.prototype.hasFileError=function(){return this.fileStatus===d.default.ERROR||!this.fileStatus||!this.hasFile()},e.prototype.hasEditor=function(){return(0,h.isUserId)(this.editorUserId)},e.prototype.hasThumbnail=function(){return this.fileStatus===d.default.OK},e.prototype.canUserUploadNewVersion=function(e){return this.getState()===f.default.AWAITING_NEW_VERSION&&(this.editorUserId===e||this.isOwner(e))},e.prototype.isOwner=function(e){return-1!==this.ownerUserIds.indexOf(e)},e.prototype.calculateState=function(){this.state=this.getState()},e.prototype.fromProof=function(e){return(0,a.default)(this,y,e),this.calculateState(),this},e}();t.default=m},function(e,t,n){"use strict";t.__esModule=!0;var o={OK:"OK",UPLOADING:"Uploading",QUEUED:"Queued",RIPPING:"Ripping",ERROR:"Error"};t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(1),s=o(i),a=n(3),u=o(a),f={userId:"UserId",token:"Token",sharedKey:"SharedKey",privateKeyPEM$:"PrivateKey",privateKeyPEM:null,publicKeyPEM:"PublicKey",serverPublicKeyPEM:"PublicServerKey"},c=function(){function e(){r(this,e)}return e.prototype.fromJSON=function(e){return(0,s.default)(this,Object.keys(f),e),this.user=(new u.default).fromJSON(e.user),this},e.prototype.fromSession=function(e){return(0,s.default)(this,f,e),this.user=(new u.default).fromUser(e),this},e}();t.default=c},function(e,t,n){"use strict";function o(){if("function"==typeof o.driver){return new(0,o.driver)}if("string"==typeof o.driver){var e=void 0;switch(o.driver){case"Blob":e=n(57).default;break;case"Buffer":e=n(58).default;break;case"String":e=n(59).default;break;default:throw new Error('Unknown Bluffer driver "'+o.driver+'".')}if(e)return new e;throw new Error('Bluffer driver "'+o.driver+'" not found.')}throw new Error('Bluffer.driver must be either "Blob", "Bluffer", or "String" or a custom constructor.')}t.__esModule=!0;var r=n(12)("bluffer");o.driver="String","undefined"!=typeof Blob?o.driver="Blob":(r("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer."),o.driver="String"),t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={ERROR_CRITICAL:3,OK:200,ERROR_INVALID:201,ERROR_NO_ACCESS:100,ERROR_NO_ACCESS_WRITE:101,ERROR_RESTRICTED:102,ERROR_SQL_ERROR:105,ERROR_OUT_SYNC:106,ERROR_STORAGE_ERROR:110,ERROR_QUEUE_ERROR:111,ERROR_SQL_DEADLOCK_ERROR:121,ERROR_BAD_REQUEST:400,ERROR_UNAUTHORISED:401,ERROR_MEDIA_PERMISSION_NO_ACCESS:402,ERROR_NOT_FOUND:1e3,ERROR_CREATE:1001,ERROR_UPDATE:1002,ERROR_DELETE:1003,ERROR_EXISTS:1004,ERROR_USER_INVALID_LOGIN:1010,ERROR_USER_INVALID_PASSWORD:1011,ERROR_USER_IS_REGISTERED:1012,ERROR_USER_INVALID_EMAIL:1013,ERROR_USER_INVALID_LOGIN_COUNT:1014,ERROR_USER_DISABLED:1015,ERROR_BAD_REQUEST_DATE:201,ERROR_THROTTLED:429,ERROR_REUSED_CREATION_TOKEN:2011,ERROR_UPGRADE_REQUIRED:3e3,ERROR_VISIBLE_WORKFLOW_USERS_EXIST:3001,ERROR_GROUP_EXISTS:3002,ERROR_GROUP_PROOFS_EXIST:3003};t.default=o},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(1),s=o(i),a=n(4),u=o(a),f={id:"GroupId",name:"Name",proofs:(0,i.each)("ProofInfo",function(e){return(new u.default).fromProof(e)})},c=function(){function e(){r(this,e)}return e.prototype.fromProofGroup=function(e){return(0,s.default)(this,f,e),this},e}();t.default=c},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),s={id:"FileId",name:"Name",blocks:"Chunks",downloadable:"Downloadable",assignedTo:"AssignedTo",assignedType:"AssignedType",status:"Status",message:"Message"},a={id:"Attachment",name:"AttachmentName",blocks:"AttachmentChunks",assignedTo:"CommentId",assignedType:function(){return"attachment"},status:"AttachmentStatus",message:function(){return""}},u=function(){function e(){o(this,e)}return e.prototype.fromFile=function(e){return(0,i.default)(this,s,e),this},e.prototype.fromCommentAttachment=function(e){return(0,i.default)(this,a,e),this},e}();t.default=u},function(e,t,n){"use strict";e.exports=function e(){return e}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(1),s=o(i),a=n(14),u=o(a),f=n(26),c=o(f),l={id:"StepId",name:"Title",position:(0,i.number)("Position"),state:function(e){return e.Complete?c.default.COMPLETE:e.Visible?c.default.VISIBLE:c.default.NOT_VISIBLE},users:(0,i.each)("Users",function(e,t){var n=(new u.default).fromWorkflowUser(e);return n._calculateState(e,t),n})},p=function(){function e(){r(this,e)}return e.prototype.fromWorkflowStep=function(e){return(0,s.default)(this,l,e),this},e}();t.default=p},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(1),u=o(a),f=n(3),c=o(f),l=n(25),p=o(l),d={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function(e){return{inviter:e.IsInviter}}},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype._calculateState=function(e,t){e.SkippedInStep?this.state=p.default.SKIPPED:e.CompleteInStep?this.state=p.default.FINISHED:e.ViewedInStep?this.state=p.default.SEEN:t.Visible?this.state=p.default.VISIBLE:this.state=p.default.NOT_VISIBLE},t.prototype.fromWorkflowUser=function(e){return this._calculateState({},{}),(0,u.default)(this,d,e),this},t}(c.default);t.default=h},function(e,t,n){"use strict";t.__esModule=!0;var o={COMMENT:"comment",TODO:"todo",DONE:"done",UNMARKED_DONE:"unmarked-done"};t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o=Object.prototype.toString;t.default=function(e){return"[object Object]"===o.call(e)}},function(e,t,n){"use strict";t.__esModule=!0;var o=void 0;o="112.0.1538690321374",t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active"};t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,APPROVED:70,ARCHIVED:100};t.default=o},function(e,t,n){"use strict";var o={Proof:"P",Workflow:"W",File:"F",User:"U",Brief:"B"},r={};Object.keys(o).forEach(function(e){r["is"+e+"Id"]=function(t){return t&&16===t.length&&t[0]===o[e]}}),e.exports=r},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),s={id:"ProofId",version:"Version"},a=function(){function e(){o(this,e)}return e.prototype.fromProofVersion=function(e){return(0,i.default)(this,s,e),this},e}();t.default=a},function(e,t,n){"use strict";function o(e,t){return r(function(t){return t[e]},t)}function r(e,t){var n=t?1:-1,o=t?-1:1;return function(t,r){var i=e(t),s=e(r);return i<s?n:i>s?o:0}}function i(e,t){var n={};t.forEach(function(e,t){n[e]=t});var o="function"==typeof e?e:function(t){return t[e]};return function(e,t){var r=n[o(e)],i=n[o(t)];return r<i?-1:r>i?1:0}}function s(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=t.length;return function(e,n){for(var r=0;r<o;r++){var i=t[r](e,n);if(i)return i}return 0}}t.__esModule=!0,t.sortObjectsByKey=o,t.sortObjectsBy=r,t.sortObjectsByValues=i,t.combineSort=s},function(e,t,n){"use strict";t.__esModule=!0;var o={NONE:"none",GOOGLE_DRIVE:"drive",DROPBOX:"dropbox",ONEDRIVE:"onedrive",BOX:"box"};t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(1),s=o(i),a=n(13),u=o(a),f={id:"WorkflowId",name:"Title",steps:(0,i.each)("WorkflowSteps",function(e){return(new u.default).fromWorkflowStep(e)})},c=function(){function e(){r(this,e)}return e.prototype.getStepByPosition=function(e){for(var t=this.steps.length,n=0;n<t;n+=1){var o=this.steps[n];if(o.position===e)return o}return null},e.prototype.getOrderedSteps=function(){return this.steps.sort(function(e,t){return e.position<t.position?-1:e.position>t.position?1:0})},e.prototype.getApproverStep=function(){return this.getStepByPosition(1e3)},e.prototype.fromWorkflow=function(e){return(0,s.default)(this,f,e),this},e}();t.default=c},function(e,t,n){"use strict";t.__esModule=!0;var o={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",SEEN:"seen",SKIPPED:"skipped",FINISHED:"finished"};t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",COMPLETE:"complete"};t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(1),s=o(i),a=n(3),u=o(a),f=n(28),c=o(f),l=n(11),p=o(l),d=n(15),h=o(d),y=n(29),m={__prepare:function(e){e._XY=c.default.parseValue(e.XY)},id:"CommentId",proofId:"ProofId",pin:function(e){return(new c.default).fromPin(e._XY)},user:function(e){return(new u.default).fromUser(e)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function(e){return e.Attachment?[(new p.default).fromCommentAttachment(e)]:[]},agreeCount:function(e){return e.Agrees.length},pageNumber:(0,i.number)("Page"),mediaTime:function(e){return null==e._XY.time?void 0:e._XY.time},mediaDuration:function(e){return null==e._XY.duration?void 0:e._XY.duration},createdDate:(0,i.date)("Timestamp"),updatedDate:(0,i.date)("Updated"),parentCommentId:(0,i.optional)("Parent"),metadata:(0,i.json)("Metadata",{}),state:function(e){return+e.Done?+e.Change?h.default.DONE:h.default.UNMARKED_DONE:+e.Change?h.default.TODO:h.default.COMMENT}},w=function(){function e(){r(this,e)}return e.prototype.fromComment=function(e){return(0,s.default)(this,m,e),this},e.prototype.fromRawComment=function(e){var t=(0,y.parseComment)(e);return this.raw=t.raw,this.text=t.text,this.html=t.html,this.tokens=t.tokens,this},e}();t.default=w},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i=n(1),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a={x:"x",y:"y",x2:(0,i.optional)("x2"),y2:(0,i.optional)("y2")},u=function(){function e(){o(this,e)}return e.prototype.fromPin=function(e){return(0,s.default)(this,a,e),this},e.parseValue=function(e){var t={x:null,y:null,x2:null,y2:null,time:null,duration:null};if("{"===e[0]){var n=JSON.parse(e);t=r({},t,n)}else if(-1!==e.indexOf(",")){var o=e.split(","),i=o[0],s=o[1];t.x=parseFloat(i),t.y=parseFloat(s)}return t},e}();t.default=u},function(e,t,n){"use strict";function o(e){return(0,c.default)(e)}function r(e){return e.replace(l.MENTION_REGEX,function(e,t,n){return n})}function i(e){var t=0;return e.replace(l.MENTION_REGEX,function(e,n,o,r){return'<span data-mention data-mention-index="'+t+++'" data-mention-user-id="'+n+'" data-mention-user-label="'+o.replace(/"/,'\\"')+'" data-mention-start-index="'+r+'" data-mention-end-index="'+(r+e.length)+'" data-mention-length="'+e.length+'">'+o+"</span>"})}function s(e){var t=[];return e.replace(l.MENTION_REGEX,function(e,n,o,r){t.push({id:n,label:o,index:r,length:e.length})}),t}function a(e){var t=s(e),n=[],o=0;t.forEach(function(t){var r=e.slice(o,t.index);o=t.index+t.length,r&&n.push({type:"text",value:r}),n.push({type:"mention",value:t})});var r=e.slice(o);return r&&n.push({type:"text",value:r}),n}function u(e){var t=o(e);return{raw:e,text:r(t),html:i(t),mentions:s(e),tokens:a(e)}}t.__esModule=!0,t.getCommentTokens=t.getCommentText=t.getCommentMentions=t.getCommentHTML=t.getCommentEscaped=t.parseComment=void 0;var f=n(70),c=function(e){return e&&e.__esModule?e:{default:e}}(f),l=n(2);t.parseComment=u,t.getCommentEscaped=o,t.getCommentHTML=i,t.getCommentMentions=s,t.getCommentText=r,t.getCommentTokens=a},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.version=t.Model=t.Enum=t.Bluffer=t.Client=void 0;var i=n(31),s=r(i),a=n(7),u=r(a),f=n(77),c=o(f),l=n(81),p=o(l),d=n(17),h=r(d);t.default=s.default,t.Client=s.default,t.Bluffer=u.default,t.Enum=c,t.Model=p,t.version=h.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(32),s=o(i),a=n(37),u=o(a),f=n(38),c=o(f),l=n(40),p=o(l),d=n(42),h=o(d),y=n(44),m=o(y),w=n(46),v=o(w),_=n(47),b=o(_),E=n(54),g=o(E),O=n(55),P=o(O),T=n(62),I=o(T),R=n(65),S=o(R),k=n(67),M=o(k),A=n(69),C=o(A),j=n(73),D=o(j),q=n(74),N=o(q),x=n(6),U=o(x),B=n(75),G=o(B),K=n(8),L=o(K),W=n(76),F=o(W),V=n(12)("PageProof"),H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.options=t,this.events=new G.default,this.adapters=new s.default(this.options.adapters),this.cache=new u.default(this),this.accounts=new h.default(this),this.comments=new C.default(this),this.dashboard=new m.default(this),this.files=new P.default(this),this.profile=new D.default(this),this.proofs=new b.default(this),this.briefs=new g.default(this),this.users=new v.default(this),this.workflows=new S.default(this),this.preferences=new M.default(this),this.sessions=new N.default(this),this._registerCoreHooks(),this._enhance()}return e.prototype._registerCoreHooks=function(){this.on("error.throttled",function(e){var t=e.data.response.data.timeout;return V("Sleeping "+t+"ms until rate limit resets"),(0,F.default)(t)})},e.prototype._enhance=function(){var e=this;this.adapters.getEnhancementAdapters().forEach(function(t){return t.onClientReady(e)})},e.prototype.setSession=function(e){return!e||e instanceof U.default?this.session=e||null:this.session=(new U.default).fromJSON(e),this.session},e.prototype.request=function(e,t,n){var o=this,r=new c.default(e,t),i=this.adapters.getRequestAdapter(),s=Promise.resolve();if(!r.endpoint.anonymous){if(!this.session)return Promise.reject(new Error("Cannot make call to endpoint ("+e+") when unauthorized."));s=this.adapters.getCryptoAdapter().generateAuthorizationHeaders(r.getMethod(),r.getPath(),this.session).then(function(e){return r.addHeaders(e)})}var a={request:r};return s.then(function(){var e=r.build();return o.events.emit("experimental.request.before",a,!0).then(function(){return e})}).then(function(e){return i.send(e,n)}).then(p.default.parse).then(function(r){if(a.response=r,o.events.emit("experimental.request.after",a),r.code===L.default.ERROR_THROTTLED){var i=o.events.emit("error.throttled",a);if(i.some(Boolean))return Promise.all(i).then(function(){return o.events.emit("experimental.request.retry",a),o.request(e,t,n)})}if(r.code===L.default.ERROR_UNAUTHORISED){var s=o.session?o.session.token:null;return o.events.emit("error.unauthorized",a,!0).then(function(){return o.session&&o.session.token!==s?o.request(e,t,n):r})}if(r.deprecated){var u="The "+e+" API has been deprecated. "+(r.deprecated||"");o.events.emit("error.deprecated",{name:e,message:u})}return r}).then(function(t){try{if(t.error){o.events.emit("error.response",a);var n=new Error(e+" request resulted in an "+t.code+" error.");return n.response=t,n.request=r,Promise.reject(n)}return o.events.emit("experimental.request.resolve",a),Promise.resolve(t)}finally{o.events.emit("experimental.request.finally",a)}})},e.prototype.admin=function(){return this.session?this.session.user.isAdmin?(this._admin||(this._admin=Promise.resolve(new I.default(this))),this._admin):Promise.reject(new Error("The current user must be an administrator of a team or enterprise account.")):Promise.reject(new Error("You must be logged in to use the Admin API."))},e.prototype.crypto=function(){return this.adapters.getCryptoAdapter()},e.prototype.on=function(e,t){return this.events.on(e,t)},e}();t.default=H},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(33),s=o(i),a=n(34),u=o(a),f=n(35),c=o(f),l=n(36),p=o(l),d=function(){function e(t){r(this,e),this.adapters=[].concat(t)}return e.prototype.getAdapterInstanceOf=function(e){return this.getAnyAdaptersInstanceOf(e)[0]||null},e.prototype.getAnyAdaptersInstanceOf=function(e){for(var t=[],n=e.__adapter__,o=0;o<this.adapters.length;o+=1){var r=this.adapters[o];Object.getPrototypeOf(Object.getPrototypeOf(r)).constructor.__adapter__===n&&t.push(r)}return t},e.prototype.getCryptoAdapter=function(){var e=this.getAdapterInstanceOf(s.default);if(!e)throw new Error("ICryptoAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getRequestAdapter=function(){var e=this.getAdapterInstanceOf(u.default);if(!e)throw new Error("IRequestAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getCacheAdapter=function(){return this.getAdapterInstanceOf(c.default)},e.prototype.getEnhancementAdapters=function(){return this.getAnyAdaptersInstanceOf(p.default)},e}();t.default=d},function(e,t,n){"use strict";function o(){}t.__esModule=!0,o.__adapter__="ICryptoAdapter",t.default=o},function(e,t,n){"use strict";function o(){}t.__esModule=!0,o.__adapter__="IRequestAdapter",t.default=o},function(e,t,n){"use strict";function o(){}t.__esModule=!0,o.__adapter__="ICacheAdapter",t.default=o},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){var o=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=o.bind.apply(o,[this].concat(t));return n(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),a=Object.getPrototypeOf(r),u=Object.keys(a).filter(function(e){return"function"==typeof a[e]&&0!==e.indexOf("_")});(i.length||n)&&u.forEach(function(e){o.push({namespace:i.join("."),name:e,api:r})}),s.forEach(function(e){t(r[e],i.concat(e))})}var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=[];return t(e),o}t.__esModule=!0;var s,a,u=(a=s=function(){function e(){o(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){r(e.api,e.name,function(n){var o={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};return t.onMethodBefore(o),function(){var e=void 0;try{e=n()}catch(e){throw o.error=e,t.onMethodThrown(o),e}finally{o.value=e,t.onMethodAfter(o),e&&"function"==typeof e.then&&e.then(function(e){o.resolved=e,t.onMethodResolve(o)},function(e){o.rejected=e,t.onMethodReject(o)}).then(function(){t.onMethodFinally(o)})}return e}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodBefore=function(){},e.prototype.onMethodAfter=function(){},e.prototype.onMethodReject=function(){},e.prototype.onMethodResolve=function(){},e.prototype.onMethodFinally=function(){},e.prototype.onMethodThrown=function(){},e.prototype.onRequestBefore=function(){},e.prototype.onRequestAfter=function(){},e.prototype.onRequestReject=function(){},e.prototype.onRequestThrottled=function(){},e.prototype.onRequestRetry=function(){},e.prototype.onRequestUnauthorized=function(){},e.prototype.onRequestDeprecated=function(){},e.prototype.onRequestResolve=function(){},e.prototype.onRequestFinally=function(){},e}(),s.__adapter__="IEnhancementAdapter",a);t.default=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(t){o(this,e),this.client=t}return e.prototype.auto=function(e,t){var n=this.client.adapters.getCacheAdapter(),o=function(){};return n?(o=function(t){void 0!==t&&n.set(e,t)},n.get(e).catch(function(){return Promise.resolve(t(o)).then(function(e){return o(e),e})})):Promise.resolve(t(o))},e}();t.default=r},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},s=n(39),a=o(s),u=n(16),f=o(u),c=n(17),l=o(c),p=n(2),d=function(){function e(t,n){if(r(this,e),this.name=t,this.endpoint=a.default[t],!this.endpoint)throw new Error('Unknown request endpoint "'+t+'".');this.params={},this.addParams(n),this.headers={}}return e.prototype.addHeaders=function(e){return this.headers=i({},this.headers,e),this},e.prototype.addHeader=function(e,t){return this.headers[e]=t,this},e.prototype.addParams=function(e){return this.params=i({},this.params,e),this},e.prototype.addParam=function(e,t){this.params[e]=t},e.prototype.getPath=function(){var e=this,t=this.endpoint,n=t.path,o=t.chain,r=t.trailing,i=n;return o&&o.forEach(function(t){"/"!==i[i.length-1]&&(i+="/"),i+=e.params[t]}),r&&"/"!==i[i.length-1]&&(i+="/"),i},e.prototype.getQuery=function(){var e=this,t=this.endpoint.query;if(t){var n=t.map(function(t){return void 0!==e.params[t]?t+"="+encodeURIComponent(e.params[t]):null}).filter(Boolean).join("&");if(n)return"?"+n}return""},e.prototype.getHeaders=function(){var e,t=i({},this.headers,(e={},e[p.SDK_VERSION_HEADER]=l.default,e));if("POST"===this.endpoint.method)switch(this.endpoint.version){case 2:t["Content-Type"]="application/json";break;case 1:default:t["Content-Type"]="application/x-www-form-urlencoded"}return t},e.prototype.getBody=function(){var e=this,t=this.endpoint;if(t.body){if("string"==typeof t.body){var n=this.params[t.body];return n=(0,f.default)(n)?JSON.stringify(n):String(n)}var o=!0===t.body?Object.keys(this.params):t.body,r={};switch(o.forEach(function(t){var n=e.params[t];void 0!==n&&(r[t]=n)}),t.version){case 2:return JSON.stringify(r);case 1:default:return Object.keys(r).map(function(t){return t+"="+encodeURIComponent(e.params[t])}).join("&")}}return null},e.prototype.getMethod=function(){return(this.endpoint.method||"GET").toUpperCase()},e.prototype.isWithCredentials=function(){return!0===this.endpoint.credentials},e.prototype.build=function(){return{method:this.getMethod(),path:this.getPath(),query:this.getQuery(),body:this.getBody(),headers:this.getHeaders(),credentials:this.isWithCredentials()}},e}();t.default=d},function(e,t){e.exports={"accounts.register":{method:"POST",path:"/api/users/register",body:["email","password","privateKey","publicKey"],anonymous:!0},"accounts.login":{method:"POST",path:"/api/users/login",body:["email","password"],anonymous:!0},"accounts.generate-activation-code":{method:"GET",path:"/api/users/auth/generate",chain:["userId"],trailing:!0},"accounts.activate":{method:"POST",path:"/api/users/auth/activate",body:["userId","authCode"],trailing:!0},"accounts.logout":{method:"GET",path:"/api/users/logout"},"profile.upload-avatar":{method:"POST",path:"/api/media/file/avatar",body:["uploadedImage"]},"profile.change-password":{method:"POST",path:"/api/users/changepassword",body:["oldPassword","newPassword","newPrivateKey"],trailing:!0},"preferences.all":{method:"GET",path:"/api/users/preferences/all"},"preferences.get":{method:"GET",path:"/api/users/preferences/get",query:["preferences"]},"preferences.update":{method:"POST",path:"/api/users/preferences/update",body:!0},"preferences.reset":{method:"POST",path:"api/users/preferences/update",body:["preferences"]},"dashboard.inbox":{method:"GET",path:"/api/proofs/dashboard/proofin",trailing:!0},"dashboard.sent":{method:"GET",path:"/api/proofs/dashboard/proofout",trailing:!0},"dashboard.outbox":{method:"GET",path:"/api/proofs/dashboard/proofoutbox",trailing:!0},"dashboard.search":{method:"POST",path:"/api/proofs/search",body:["query","all","filterBy"]},"dashboard.groups.filter-by":{method:"GET",path:"/api/proofs/dashboard/groups",chain:["filterBy"],trailing:!0},"users.by-id":{method:"GET",path:"/api/users",chain:["userId"]},"users.by-email":{method:"POST",path:"/api/users/email",body:["email"],trailing:!0},"users.invite":{method:"POST",path:"/api/users/create",body:["email"]},"proofs.create":{method:"POST",path:"/api/proofs/create",body:["title","dueDate","description","groupId"]},"proofs.normalize-workflow":{method:"POST",path:"/api/proofs/permission/check",body:["proofId","workflowId"]},"proofs.set-workflow":{method:"POST",path:"/api/proofs/update",body:["proofId","workflowId"]},"proofs.set-tags":{method:"POST",path:"/api/tags/create",body:["relatedId","tag"]},"proofs.set-file":{method:"POST",path:"/api/proofs/update",body:["proofId","fileId"]},"proofs.distribute-file":{method:"GET",path:"/api/proofs/distribute",chain:["proofId"],trailing:!0},"proofs.archive":{version:2,method:"POST",path:"/api/proofs/close",body:["proofIds"]},"proofs.unarchive":{method:"GET",path:"/api/proofs/reopen",chain:["proofId"],trailing:!0},"proofs.delete":{method:"GET",path:"/api/proofs/delete",chain:["proofId"],trailing:!0},"proofs.start":{method:"POST",path:"/api/proofs/startworkflow",body:["proofId"],trailing:!0},"proofs.editors.add":{version:2,method:"POST",path:"/api/proofs/editor/add",body:["proofId","editors","editorMessage"]},"proofs.editors.remove":{version:2,method:"POST",path:"/api/proofs/editor/remove",body:["proofId","editors"]},"proofs.editors.replace":{version:2,method:"POST",path:"/api/proofs/editor/replace",body:["proofId","oldEditors","newEditors"]},"proofs.editors.set":{version:2,method:"POST",path:"/api/proofs/editor/set",body:["proofId","editors"]},"briefs.start":{method:"POST",path:"/api/briefs/start",body:["briefId"]},"proofs.return":{method:"GET",path:"/api/proofs/returnproof",chain:["proofId"]},"proofs.groups.create":{method:"POST",path:"/api/proofs/groups/create",body:["name"]},"proofs.groups.update":{method:"POST",path:"/api/proofs/groups/update",body:["groupId","name"]},"proofs.groups.load":{method:"GET",path:"/api/proofs/group",chain:["groupId"]},"proofs.groups.ready":{method:"POST",path:"/api/proofs/groups/ready",body:["groupId"]},"proofs.groups.owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/groups/add",body:["groupId","owners"]},"proofs.groups.workflows.add-reviewers":{version:2,method:"POST",path:"/api/v2/workflows/groups/reviewers/add",body:["groupId","reviewers"]},"proofs.versions.attach":{method:"POST",path:"/api/proofs/versions/create",body:["proofId","versionId"]},"proofs.versions.list":{method:"GET",path:"/api/proofs/versions",chain:["proofId"],trailing:!0},"proofs.load":{method:"GET",path:"/api/proofs/",chain:["proofId"],trailing:!0},"proofs.request-access":{method:"GET",path:"/api/proofs/requestaccess",chain:["proofId"]},"proofs.lock":{method:"GET",path:"/api/proofs/lock/",chain:["proofId"],trailing:!0},"proofs.unlock":{method:"GET",path:"/api/proofs/unlock/",chain:["proofId"],trailing:!0},"proofs.request-unlock":{method:"GET",path:"/api/proofs/unlockemail/",chain:["proofId"],trailing:!0},"files.generate-token":{method:"GET",path:"/api/media/getfiletoken",query:["relatedId","fileType"]},"files.upload-block":{method:"POST",path:"/api/media/file",query:["block","part","token"],body:"data"},"files.upload-complete":{method:"POST",path:"/api/media/file",query:["block","blockCount","part","token","extn","pages","filename","storeoriginal"],body:"envelope"},"files.details":{method:"GET",path:"/api/media/file/details",chain:["fileId"]},"files.download-block":{method:"GET",path:"/api/media/getfilechunk",chain:["proofId","fileId","block"]},"files.thumbnail":{method:"GET",path:"/api/media/getimage/thumb",chain:["fileId"]},"files.import.generic":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal"]},"files.import.drive":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.onedrive":{method:"POST",path:"/api/media/fileonedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.box":{method:"POST",path:"/api/media/filebox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.dropbox":{method:"POST",path:"/api/media/filedropbox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"workflows.create":{version:2,method:"POST",path:"/api/v2/workflows/create",body:["title"]},"workflows.load":{version:2,method:"GET",path:"/api/v2/workflows/detail",chain:["workflowId"]},"workflows.steps.add":{version:2,method:"POST",path:"/api/v2/workflows/steps/add",body:["workflowId","title","position"]},"workflows.steps.move-before":{method:"POST",path:"/api/workflows/step/movebefore",body:["stepId","beforeStepId"]},"workflows.steps.move-after":{method:"POST",path:"/api/workflows/step/moveafter",body:["stepId","afterStepId"]},"workflows.steps.swap":{method:"POST",path:"/api/workflows/step/swap",body:["stepId","swapStepId"]},"workflows.users.set":{version:2,method:"POST",path:"/api/v2/workflows/users/set",body:["workflowId","stepId","position","users"]},"workflows.users.update":{version:2,method:"POST",path:"/api/v2/workflows/users/update",body:["workflowId","stepId","userId","role","permissions"]},"workflows.users.add":{version:2,method:"POST",path:"/api/v2/workflows/users/add",body:["workflowId","stepId","users"]},"workflows.delete":{method:"POST",path:"/api/workflows/delete",body:["workflowId"]},"workflows.duplicate":{method:"POST",path:"/api/workflows/duplicateonly",body:["workflowId"]},"workflows.owned":{method:"GET",path:"/api/workflows",trailing:!0},"workflows.shared":{method:"GET",path:"/api/workflows/share/user",trailing:!0},"comments.load-all":{method:"POST",path:"/api/proofs/recent",body:["proofId","timestamp"]},"comments.load-page":{method:"POST",path:"/api/proofs/comment/recent",body:["proofId","timestamp","page"]},"comments.state.update":{method:"POST",path:"/api/proofs/comment/updatestatus",body:["commentId","change","done"]},"comments.create":{method:"POST",path:"/api/proofs/comment/create",body:["proofId","page","envelope","encryptedComment","xy","parent","mentions","metadata","creationToken","change","done"]},"proofs-owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/add",body:["proofId","users"]},"proofs-owners.remove":{version:2,method:"POST",path:"/api/v2/proofs/owners/remove",body:["proofId","users"]},"proofs.tag-delete":{method:"POST",path:"/api/tags/delete",body:["relatedId","tag"]},"proofs.remove-editor":{method:"GET",path:"/api/proofs/deleteeditor",chain:["proofId"],trailing:!0},"briefs.create":{method:"POST",path:"/api/briefs/create",body:["title","messageToRecipient","dueDate","tag"]},"briefs.update":{method:"POST",path:"/api/briefs/update",body:["briefId","title","messageToRecipient","dueDate","tag","recipient","editorId","editorMessage"]},"admin.team.users.enabled":{method:"GET",path:"/api/admin/getusers/active",trailing:!0},"admin.team.users.disabled":{method:"GET",path:"/api/admin/getusers/inactive",trailing:!0},"admin.team.users.set-enabled":{method:"POST",path:"/api/admin/setenabled",body:["email","enabled"]},"sessions.check":{method:"GET",path:"/api/sessions/check"},"sso.get-public-key":{method:"GET",path:"/sso/public_key",anonymous:!0},"sso.get-session":{version:2,method:"POST",path:"/sso/session",body:["nonce"],anonymous:!0,credentials:!0},"sso.get-login-options":{version:2,method:"POST",path:"/sso/login_options",body:["email"],anonymous:!0}}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=n(8),s=o(i),a=n(41),u=n(2),f=n(9),c=o(f),l=function(){function e(){r(this,e),this.error=!1,this.code=-1,this.data=null,this.message=null,this.deprecated=null}return e.parse=function(t){var n=t.status,o=t.headers,r=void 0===o?{}:o,i=t.body,f=new e;if(n===a.TOO_MANY_REQUESTS_STATUS)return f.error=!0,f.message="PageProof Error #h"+a.TOO_MANY_REQUESTS_STATUS,f.code=s.default.ERROR_THROTTLED,f.data={timeout:1e3*(parseFloat(r[u.RETRY_AFTER_HEADER])||60)},f;if((0,c.default)(r,"deprecated")&&(f.deprecated=r.deprecated),n===a.OK_STATUS&&!i)return f.code=s.default.OK,f;try{var l=JSON.parse(i);"string"==typeof l||(l&&"ResponseCode"in l?(f.code=l.ResponseCode,f.code!==s.default.OK&&(f.error=!0)):l.Message&&1===Object.keys(l).length&&(f.error=!0,f.code=s.default.ERROR_CRITICAL)),f.error&&(f.message="PageProof Error #s"+f.code),f.data=l}catch(e){f.error=!0}return f},e}();t.default=l},function(e,t,n){"use strict";t.__esModule=!0;t.TOO_MANY_REQUESTS_STATUS=429,t.OK_STATUS=200},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(6),c=o(f),l=n(43),p=o(l),d=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.sso=new p.default(n),o}return s(t,e),t.prototype.register=function(e,t){var n=this;return this.client.crypto().generatePasswordHash(t).then(function(e){return Promise.all([e,n.client.crypto().generateKeyPair()])}).then(function(e){var o=e[0],r=e[1];return Promise.all([o,r,n.client.crypto().encryptPrivateKey(r.privateKeyPEM,t)])}).then(function(t){var o=t[0],r=t[1],i=t[2];return Promise.all([r,n.client.request("accounts.register",{email:e,password:o,privateKey:i,publicKey:r.publicKeyPEM})])}).then(function(o){var r=o[0];return Promise.all([r,n.login(e,t,!1)])}).then(function(e){var t=e[0],o=e[1];return Promise.all([t,o,n.generateActivationCode()])}).then(function(e){var t=e[0],n=e[1];return n.privateKeyPEM=t.privateKeyPEM,n})},t.prototype.generateActivationCode=function(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})},t.prototype.activate=function(e){var t=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:e}).then(function(){t.client.session.user.hasActivated=!0})},t.prototype.login=function(e,t){var n=this,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.client.crypto().generatePasswordHash(t).then(function(t){return n.client.request("accounts.login",{email:e,password:t})}).then(function(t){var n=(new c.default).fromSession(t.data);return n.user.email=e,n}).then(function(e){return o?n.client.crypto().decryptPrivateKey(e.privateKeyPEM$,t).then(function(t){return e.privateKeyPEM=t,e}):e}).then(function(e){return n.client.setSession(e),e})},t.prototype.logout=function(){var e=this;return this.client.request("accounts.logout").catch(function(t){return e.client.setSession(null),Promise.reject(t)}).then(function(){e.client.setSession(null)})},t}(u.default);t.default=d},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(6),c=o(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.getSession=function(){var e=this;return this.client.request("sso.get-public-key").then(function(e){return e.data.ServerPublicKey}).then(function(t){return e.client.crypto().generateWrappedSymmetricKey(t)}).then(function(t){var n=t.key,o=t.key$;return Promise.all([n,e.client.request("sso.get-session",{nonce:o})])}).then(function(t){var n=t[0],o=t[1],r=(new c.default).fromSession(o.data);return Promise.all([r,e.client.crypto().decryptManagedPrivateKey(r.privateKeyPEM$,n)])}).then(function(e){var t=e[0],n=e[1];return t.privateKeyPEM=n,t})},t.prototype.getLoginOptions=function(e){return this.client.request("sso.get-login-options",{email:e}).then(function(e){return e.data})},t}(u.default);t.default=l},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){var t={};return Object.keys(y).forEach(function(n){t[n]=e[y[n]]}),t}function u(e){return(e||[]).map(function(e){return(new p.default).fromProof(e)})}t.__esModule=!0;var f=n(0),c=o(f),l=n(4),p=o(l),d=n(45),h=o(d),y={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox"},m=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.groups=new h.default(n),o}return s(t,e),t.prototype.inbox=function(){return this._loadSingleTabProofs("inbox")},t.prototype.sent=function(){return this._loadSingleTabProofs("sent")},t.prototype.outbox=function(){return this._loadSingleTabProofs("outbox")},t.prototype._loadSingleTabProofs=function(e){return this.client.request("dashboard."+e).then(function(e){return a(e.data)}).then(function(t){return t[e]}).then(u)},t.prototype.search=function(e){return this._loadSearchProofs({query:e})},t.prototype.everything=function(){return this._loadSearchProofs({all:1})},t.prototype.approved=function(){return this._loadSearchProofs({filterBy:70})},t.prototype.archived=function(){return this._loadSearchProofs({filterBy:100})},t.prototype._loadSearchProofs=function(e){return this.client.request("dashboard.search",e).then(function(e){return u(e.data.Proofs)})},t}(c.default);t.default=m},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return(e||[]).map(function(e){return(new l.default).fromProofGroup(e)})}t.__esModule=!0;var u=n(0),f=o(u),c=n(10),l=o(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype._loadGroups=function(e){return this.client.request("dashboard.groups.filter-by",{filterBy:e}).then(function(e){return a(e.data)})},t.prototype.current=function(){return this._loadGroups("current")},t}(f.default);t.default=p},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return e.data.length>0?(new p.default).fromUser(e.data[0]):(new p.default).fromUser(e.data)}function u(e){return e.data.length?(new p.default).fromUser(e.data[0]):null}t.__esModule=!0;var f=n(0),c=o(f),l=n(3),p=o(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.byEmail=function(e){return this.client.request("users.by-email",{email:e}).then(u)},t.prototype.byId=function(e){return this.client.request("users.by-id",{userId:e}).then(a)},t.prototype.invite=function(e){return this.client.request("users.invite",{email:e}).then(a)},t}(c.default);t.default=d},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(48),c=o(f),l=n(49),p=o(l),d=n(50),h=o(d),y=n(51),m=o(y),w=n(4),v=o(w),_=n(5),b=o(_),E=n(2),g=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.owners=new c.default(n),o.editors=new p.default(n),o.versions=new h.default(n),o.groups=new m.default(n),o}return s(t,e),t.prototype.setWorkflow=function(e,t){var n=this;return this.client.request("proofs.normalize-workflow",{proofId:e,workflowId:t}).then(function(){return n.client.request("proofs.set-workflow",{proofId:e,workflowId:t})})},t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var n=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return n.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,n=e.name,o=e.tags,r=void 0===o?[]:o,i=e.dueDate,s=void 0===i?new Date(Date.now()+3*E.DAY_IN_MS):i,a=e.messageToReviewers,u=e.workflow,f=e.file,c=e.group,l=e.start,p=void 0===l||l,d=p&&!c;return this.client.request("proofs.create",{title:n,dueDate:s.toISOString(),description:a,groupId:c?c.id:void 0}).then(function(e){var n=(new v.default).fromProof(e.data);return Promise.all([n,r.length&&t.setTags(n.id,r),u&&t.setWorkflow(n.id,u.id),f&&t.setFile(n.id,f.id)])}).then(function(e){var n=e[0];return Promise.resolve(d&&t.start(n.id)).then(function(){return n})}).then(function(e){return u&&(e.workflowId=u.id),f&&(e.fileId=f.id,e.fileStatus=b.default.UPLOADING),e.calculateState(),e})},t.prototype.archive=function(e){return this.client.request("proofs.archive",{proofIds:e})},t.prototype.unarchive=function(e){return this.client.request("proofs.unarchive",{proofId:e})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.return=function(e){return this.client.request("proofs.return",{proofId:e})},t.prototype.start=function(e){return this.client.request("proofs.start",{proofId:e})},t.prototype.removeEditor=function(e){return this.client.request("proofs.remove-editor",{proofId:e})},t.prototype.load=function(e){return this.client.request("proofs.load",{proofId:e}).then(function(e){return(new v.default).fromProof(e.data)})},t.prototype.lock=function(e){return this.client.request("proofs.lock",{proofId:e})},t.prototype.unlock=function(e){return this.client.request("proofs.unlock",{proofId:e})},t.prototype.requestUnlock=function(e){return this.client.request("proofs.request-unlock",{proofId:e})},t.prototype.requestAccess=function(e){return this.client.request("proofs.request-access",{proofId:e})},t}(u.default);t.default=g},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs-owners.add",{proofId:e,users:[].concat(t)})},t.prototype.remove=function(e,t){return this.client.request("proofs-owners.remove",{proofId:e,users:[].concat(t)})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t,n){var o={proofId:e,editors:[].concat(t),editorMessage:null===n?"":n};return this.client.request("proofs.editors.add",o)},t.prototype.remove=function(e,t){return this.client.request("proofs.editors.remove",{proofId:e,editors:[].concat(t)})},t.prototype.replace=function(e,t,n){return this.client.request("proofs.editors.replace",{proofId:e,oldEditors:[].concat(t),newEditors:[].concat(n)})},t.prototype.set=function(e,t){return this.client.request("proofs.editors.set",{proofId:e,editors:[].concat(t)})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(21),c=o(f),l=n(22),p=(0,l.sortObjectsByKey)("version"),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.attach=function(e,t){return this.client.request("proofs.versions.attach",{proofId:e,versionId:t})},t.prototype.list=function(e){return this.client.request("proofs.versions.list",{proofId:e}).then(function(e){return e.data.map(function(e){return(new c.default).fromProofVersion(e)}).sort(p)})},t}(u.default);t.default=d},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return(new l.default).fromProofGroup(e.data)}t.__esModule=!0;var u=n(0),f=o(u),c=n(10),l=o(c),p=n(52),d=o(p),h=n(53),y=o(h),m=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.owners=new d.default(n),o.workflows=new y.default(n),o}return s(t,e),t.prototype.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name;return this.client.request("proofs.groups.create",{name:t}).then(a)},t.prototype.load=function(e){return this.client.request("proofs.groups.load",{groupId:e}).then(a)},t.prototype.ready=function(e){return this.client.request("proofs.groups.ready",{groupId:e})},t.prototype.update=function(e,t){var n=t.name;return this.client.request("proofs.groups.update",{groupId:e,name:n}).then(a)},t}(f.default);t.default=m},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs.groups.owners.add",{groupId:e,owners:[].concat(t)})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.addReviewers=function(e,t){return this.client.request("proofs.groups.workflows.add-reviewers",{groupId:e,reviewers:[].concat(t)})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(4),c=o(f),l=n(5),p=o(l),d=n(2),h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var n=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return n.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,n=e.name,o=e.file,r=e.tags,i=void 0===r?[]:r,s=e.dueDate,a=void 0===s?new Date(Date.now()+3*d.DAY_IN_MS):s;return this.client.request("briefs.create",{title:n,messageToRecipient:"",dueDate:a.toISOString(),tag:i.join(",")}).then(function(e){var n=(new c.default).fromProof(e.data.Brief);return Promise.all([n,o&&t.setFile(n.id,o.id)])}).then(function(e){var t=e[0];return o&&(t.fileId=o.id,t.fileStatus=p.default.UPLOADING),t.calculateState(),t})},t.prototype.update=function(e){var t=this,n=e.briefId,o=e.data,r=e.start,i=void 0!==r&&r;return this.client.request("briefs.update",{briefId:n,title:o.title,messageToRecipient:o.messageToRecipient,dueDate:o.dueDate?o.dueDate.toISOString():"",tag:o.tags?o.tags.join(","):"",recipient:o.recipient,editorId:o.editorId,editorMessage:o.editorMessage}).then(function(e){return(new c.default).fromProof(e.data.Brief)}).then(function(e){return Promise.resolve(i&&t.start(e.id)).then(function(){return e})})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.start=function(e){return this.client.request("briefs.start",{briefId:e})},t}(u.default);t.default=h},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){var t=e.lastIndexOf(".");return{name:e.substring(0,t),extension:e.substring(t+1)}}t.__esModule=!0;var u=n(0),f=o(u),c=n(11),l=o(c),p=n(5),d=o(p),h=n(23),y=o(h),m=n(56),w=o(m),v=n(7),_=o(v),b=n(61),E=o(b),g=n(2),O=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.generateToken=function(e,t){return e&&!t?Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.')):!e&&t?Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.')):this.client.request("files.generate-token",{relatedId:e,fileType:t}).then(function(e){return e.data.Token})},t.prototype._waitFileProcessed=function(e){var t=this;return new Promise(function(n,o){var r=null,i=null;!function s(){t.details(e).then(function(t){switch(r=null,t.status){case d.default.OK:n(t);break;case d.default.ERROR:o(new Error("File "+e+" encountered a processing error: "+t.message));break;default:r=setTimeout(s,5e3)}r&&t.status!==d.default.RIPPING||clearTimeout(i)}).catch(o)}(),i=setTimeout(function(){clearTimeout(r),o(new Error("File did not finish processing within specified duration."))},3e4)})},t.prototype.import=function(e){var t=this,n=e.name,o=e.url,r=e.provider,i=void 0===r?y.default.NONE:r,s=e.auth,u=e.download,f=void 0!==u&&u,c=e.process,p=void 0!==c&&c;if(!Object.keys(y.default).some(function(e){return y.default[e]===i}))return Promise.reject(new Error('Unsupported provider "'+i+'"'));var d=i;i===y.default.NONE&&(d="generic");var h=a(n),m=h.name,w=h.extension;return this._generateKeyIVEnvelope().then(function(e){var n=e.envelope;return t.client.request("files.import."+d,{extn:w,filename:m,url:o,envelope:n,accessToken:s,storeOriginal:f})}).then(function(e){return e.data}).then(function(e){if(p)return t._waitFileProcessed(e);var n=new l.default;return n.id=e,n})},t.prototype._generateKeyIVEnvelope=function(){var e=this;return this.client.crypto().generateKeyIV().then(function(t){return Promise.all([t,e.client.crypto().envelopeSeal(t.keyIV,[e.client.session.serverPublicKeyPEM,e.client.session.publicKeyPEM])])}).then(function(e){return{keyIV:e[0],envelope:e[1]}})},t.prototype.upload=function(e){var t=this,n=e.name,o=e.contents,r=e.assignedTo,i=e.assignedType,s=e.download,a=void 0!==s&&s,u=e.async,f=void 0===u||u,c=e.onProgress,p=e.onError;return this.generateToken(r,i).then(function(e){return Promise.all([e,t._generateKeyIVEnvelope()])}).then(function(e){var r=e[0],i=e[1],s=i.keyIV,u=i.envelope,l=t._upload({name:n,contents:o,download:a,token:r,keyIV:s,envelope:u,onProgress:c,onError:p});return f&&(l=Promise.resolve()),l.then(function(){return r})}).then(function(e){var t=new l.default;return t.id=e,t})},t.prototype._upload=function(e){var t=this,n=e.name,o=e.contents,r=e.download,i=e.token,s=e.keyIV,u=e.envelope,f=e.onProgress;return new Promise(function(e){function c(){y().then(function(t){if(!_)if(null===t)_=!0,e(m.then(I));else{var n=T(t,v++);m=m.then(function(){return n}),n.then(c)}})}var l=4,p=a(n),d=p.name,h=p.extension,y=(0,w.default)(o),m=Promise.resolve(),v=0,_=!1,b=Math.ceil((0,E.default)(o)/g.BYTES_PER_BLOCK),O=new Array(b),P=function(){};f&&(P=function(e,t){O[e]=Math.max(t,O[e]||0),f(O.reduce(function(e,t){return e+(t||0)},0)/b*.99)});for(var T=function(e,n){return t.client.crypto().encryptFileBlock(s,e).then(function(e){return t.client.request("files.upload-block",{block:n,part:1,token:i,data:e},{onUploadProgress:P.bind(null,n)})})},I=function(){return t.client.request("files.upload-complete",{block:0,blockCount:v,part:0,token:i,extn:h,pages:1,filename:d,storeoriginal:r?1:0,envelope:u}).then(function(){return f&&f(100)})};l--;)c()})},t.prototype.download=function(e){var t=this,n="string"==typeof e?{fileId:e}:e,o=n.fileId,r=n.onFileDetails;return this.details(o).then(function(e){if(!e.downloadable)throw new Error("File "+o+" is not downloadable.");if(e.status!==d.default.OK)throw new Error("File "+o+" cannot be download. The file may still be uploading, processing or has errored.");if(!e.blocks)throw new Error("File "+o+" is empty.");return r&&r(e),t._downloadFile(e,n)})},t.prototype._downloadFile=function(e,t){var n=this;return new Promise(function(o){function r(){if(!y)if(h<u.length){var e=h++,t=d(e);f=f.then(function(){return t.then(function(t){return c(t,e,a)})}),t.then(r)}else y=!0,o(f.then(m))}var i=4,s=new _.default,a=e.blocks,u=new Array(a),f=Promise.resolve(),c=t.onData||function(e,t){u[t]=e},l=function(){};if(t.onProgress){var p=new Array(a);l=function(e,n){p[e]=Math.max(n,p[e]||0),t.onProgress(p.reduce(function(e,t){return e+(t||0)},0)/a*.99)}}for(var d=function(t){return n.client.request("files.download-block",{proofId:e.assignedTo,fileId:e.id,block:t+1},{onDownloadProgress:l.bind(null,t)}).then(function(e){return n.client.crypto().decryptFileBlock(e.data,n.client.session.privateKeyPEM).then(function(e){return s.createBase64(e)})})},h=0,y=!1,m=function(){return t.onProgress&&t.onProgress(100),t.onData?null:s.combine.apply(s,u)};i--;)r()})},t.prototype.details=function(e){return this.client.request("files.details",{fileId:e}).then(function(e){return(new l.default).fromFile(e.data)})},t.prototype.thumbnail=function(e){var t=this;return this.client.cache.auto(g.THUMBNAIL_CACHE_PREFIX+e,function(){return t._thumbnail(e)})},t.prototype._thumbnail=function(e){var t=this;return this.client.request("files.thumbnail",{fileId:e}).then(function(e){return t.client.crypto().decryptImage(e.data,t.client.session.privateKeyPEM)}).then(function(e){return(new _.default).createBase64(e)})},t.prototype.thumbnails=function(e,t){var n=this,o=t.async,r=void 0!==o&&o,i=t.onLoadThumbnails,s=[];return Promise.all(e.map(function(e){return n.client.cache.auto(g.THUMBNAIL_CACHE_PREFIX+e,function(t){s.push({fileId:e,resolve:t})}).then(function(t){var n;return t&&(n={},n[e]=t,n)})})).then(function(e){var t=Promise.all(s.map(function(e){var t=e.fileId,o=e.resolve;return n._thumbnail(t).then(function(e){if(o(e),r){var n;i((n={},n[t]=e,n))}return e})}));return r?e:t.then(function(t){return[].concat(e,t)})}).then(function(e){return Object.assign.apply(Object,[{}].concat(e))})},t}(f.default);t.default=O},function(e,t,n){"use strict";function o(e){var t=new s.default,n=0,o=Promise.resolve(),i=t.size(e);return function(){var s=n++*r.BYTES_PER_BLOCK,a=s+r.BYTES_PER_BLOCK;return o=o.then(function(){return s>i?null:t.slice(e,s,a).then(t.readBase64).then(function(e){return"data:;base64,"+e})})}}t.__esModule=!0;var r=n(2),i=n(7),s=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=o},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=new ArrayBuffer(e.length),n=new Uint8Array(t),o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}t.__esModule=!0;var i=function(){function e(){o(this,e)}return e.prototype.create=function(e){return Promise.resolve(new Blob([r(e)]))},e.prototype.createBase64=function(e){return this.create(atob(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Promise.resolve(new Blob(t))},e.prototype.slice=function(e,t,n){return Promise.resolve(e.slice(t,n))},e.prototype.read=function(e){return new Promise(function(t,n){var o=new FileReader;o.onload=function(){t(o.result)},o.onerror=function(){n(o.error)},o.readAsText(e)})},e.prototype.readBase64=function(e){return new Promise(function(t,n){var o=new FileReader;o.onload=function(){var e=o.result;t(e.substring(e.indexOf(",")+1))},o.onerror=function(){n(o.error)},o.readAsDataURL(e)})},e.prototype.size=function(e){return e.size},e}();t.default=i},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(){o(this,e)}return e.prototype.create=function(e){return Promise.resolve(Buffer.from(e))},e.prototype.createBase64=function(e){return Promise.resolve(Buffer.from(e,"base64"))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Promise.resolve(Buffer.concat(t))},e.prototype.slice=function(e,t,n){return Promise.resolve(e.slice(t,n))},e.prototype.read=function(e){return Promise.resolve(e.toString())},e.prototype.readBase64=function(e){return Promise.resolve(e.toString("base64"))},e.prototype.size=function(e){return Buffer.byteLength(e)},e}();t.default=r},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=e.length,n=e.length-1;n>=0;n--){var o=e.charCodeAt(n);o>127&&o<=2047?t++:o>2047&&o<=65535&&(t+=2),o>=56320&&o<=57343&&n--}return t}t.__esModule=!0;var i=n(60),s=function(){function e(){o(this,e)}return e.prototype.create=function(e){return Promise.resolve(e)},e.prototype.createBase64=function(e){return Promise.resolve((0,i.atob)(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Promise.resolve(t.join(""))},e.prototype.slice=function(e,t,n){return Promise.resolve(e.slice(t,n))},e.prototype.read=function(e){return Promise.resolve(e)},e.prototype.readBase64=function(e){return Promise.resolve((0,i.btoa)(e))},e.prototype.size=function(e){return r(e)},e}();t.default=s},function(e,t,n){!function(){function e(e){this.message=e}var n=t,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.prototype=new Error,e.prototype.name="InvalidCharacterError",n.btoa||(n.btoa=function(t){for(var n,r,i=String(t),s=0,a=o,u="";i.charAt(0|s)||(a="=",s%1);u+=a.charAt(63&n>>8-s%1*8)){if((r=i.charCodeAt(s+=.75))>255)throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|r}return u}),n.atob||(n.atob=function(t){var n=String(t).replace(/[=]+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,s=0,a=0,u="";i=n.charAt(a++);~i&&(r=s%4?64*r+i:i,s++%4)?u+=String.fromCharCode(255&r>>(-2*s&6)):0)i=o.indexOf(i);return u})}()},function(e,t,n){"use strict";function o(e){return"undefined"!=typeof Blob&&e instanceof Blob?e.size:0}t.__esModule=!0,t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(63),c=o(f),l=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.team=new c.default(n),o}return s(t,e),t}(u.default);t.default=l},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(64),c=o(f),l=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.users=new c.default(n),o}return s(t,e),t}(u.default);t.default=l},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return e.data.map(function(e){return(new l.default).fromUser(e)})}t.__esModule=!0;var u=n(0),f=o(u),c=n(3),l=o(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.enabled=function(){return this.client.request("admin.team.users.enabled").then(a)},t.prototype.disabled=function(){return this.client.request("admin.team.users.disabled").then(a)},t.prototype._setEnabled=function(e,t){return this.client.request("admin.team.users.set-enabled",{email:e,enabled:t})},t.prototype.enable=function(e){return this._setEnabled(e,!0)},t.prototype.disable=function(e){return this._setEnabled(e,!1)},t}(f.default);t.default=p},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return e&&((0,w.isUserId)(e.id)||e.email)}function u(e){return(e||[]).map(function(e){return(new p.default).fromWorkflow(e)})}t.__esModule=!0;var f=n(0),c=o(f),l=n(24),p=o(l),d=n(13),h=o(d),y=n(14),m=o(y),w=n(20),v=n(66),_=o(v),b=function(e){function t(n){r(this,t);var o=i(this,e.call(this,n));return o.steps=new _.default(n),o}return s(t,e),t.prototype.create=function(e){var t=this,n=e.save,o=void 0!==n&&n,r=e.name,i=e.steps,s=void 0===i?[]:i,u=e.reviewers,f=e.approver;if(!a(f))return Promise.reject(Error("An approver is required to create a workflow."));if(o&&!r)return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."));var c=s;u&&u.length&&c.splice(0,0,{users:u}),f&&c.push({position:1e3,users:[f]});for(var l=0,p=0;p<c.length;p++){var d=c[p];if(!d.users||!d.users.length)return Promise.reject(Error("Workflow steps must contain users."));(!d.position||d.position<l)&&(d.position=l+1),l=Math.max(l,d.position);for(var h=0;h<d.users.length;h++){if(!a(d.users[h]))return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}var y=void 0;return this._createWorkflow(r).then(function(e){return y=e.id,Promise.all([e,Promise.all(c.map(function(n){var o=e.getStepByPosition(n.position);return o?t._setWorkflowStepUsersMutate(e.id,o,n.users):t._addWorkflowStepAndUsers(e.id,n)}))])}).then(function(e){var t=e[0],n=e[1];return t.steps=n,t}).then(function(e){return o?t._duplicateWorkflow(y):e}).catch(function(e){return Promise.resolve(y&&t._deleteWorkflow(y)).then(function(){return Promise.reject(e)})})},t.prototype.load=function(e){return this.client.request("workflows.load",{workflowId:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype.use=function(e){return this.duplicate(e)},t.prototype.duplicate=function(e){return this._duplicateWorkflow(e)},t.prototype.delete=function(e){return this._deleteWorkflow(e)},t.prototype.all=function(){return Promise.all([this.owned(),this.shared()]).then(function(e){return[].concat(e[0],e[1])})},t.prototype.owned=function(){return this.client.request("workflows.owned").then(function(e){return u(e.data)})},t.prototype.shared=function(){return this.client.request("workflows.shared").then(function(e){return u(e.data)})},t.prototype.setApprover=function(e,t){return this.client.request("workflows.users.set",{workflowId:e,position:1e3,users:[t]})},t.prototype._duplicateWorkflow=function(e){var t=this;return this.client.request("workflows.duplicate",{workflowId:e}).then(function(e){var n=e.data.WorkflowId;return t.load(n)})},t.prototype._deleteWorkflow=function(e){return this.client.request("workflows.delete",{workflowId:e})},t.prototype._createWorkflow=function(e){return this.client.request("workflows.create",{title:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype._addWorkflowStepAndUsers=function(e,t){var n=this;return this.client.request("workflows.steps.add",{workflowId:e,title:t.name,position:t.position}).then(function(o){var r=(new h.default).fromWorkflowStep(o.data);return n._setWorkflowStepUsersMutate(e,r,t.users)})},t.prototype._setWorkflowStepUsersMutate=function(e,t,n){return this.client.request("workflows.users.set",{workflowId:e,stepId:t.id,users:n.map(function(e){return{email:e.email,userId:e.id,role:e.role,permissions:e.permissions&&{inviter:!!e.permissions.inviter}}})}).then(function(e){var n=e.data.map(function(e){return(new m.default).fromWorkflowUser(e)});return t.users=n,t})},t}(c.default);t.default=b},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.moveBefore=function(e,t){return this.client.request("workflows.steps.move-before",{stepId:e,beforeStepId:t})},t.prototype.moveAfter=function(e,t){return this.client.request("workflows.steps.move-after",{stepId:e,afterStepId:t})},t.prototype.swap=function(e,t){return this.client.request("workflows.steps.swap",{stepId:e,swapStepId:t})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){return(new p.default).fromPreference(e)}function u(e,t){var n=new Array(e.length);return t.forEach(function(t){n[e.indexOf(t.name)]=t}),n}t.__esModule=!0;var f=n(0),c=o(f),l=n(68),p=o(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.all=function(){return this.client.request("preferences.all")},t.prototype.get=function(e){var t=[].concat(e);return this.client.request("preferences.get",{preferences:t}).then(function(e){return e.data.map(a)}).then(function(n){return"string"==typeof e?n[0]:u(t,n)})},t.prototype.update=function(e,t){var n,o=void 0!==t?(n={},n[e]=t,n):e;return this.client.request("preferences.update",o)},t.prototype.reset=function(e){return this.client.request("preferences.reset",{preferences:[].concat(e)})},t}(c.default);t.default=d},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=n(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),s={name:"Name",defaultValue:"DefaultValue",value:"Value"},a=function(){function e(){o(this,e)}return e.prototype.getValueOrDefault=function(){return null===this.value?this.defaultValue:this.value},e.prototype.fromPreference=function(e){return(0,i.default)(this,s,e),this},e}();t.default=a},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){var t=[];return Object.keys(e).forEach(function(n){e[n].Comments.forEach(function(e){t.push(e)})}),t}function u(e){var t=[],n=[];e.forEach(function(e){var o=(new p.default).fromComment(e);o.parentCommentId?n.push(o):t.push(o)}),t.sort(P);var o=t.map(function(e){return e.id}),r=(0,m.sortObjectsBy)(function(e){return o.indexOf(e.parentCommentId)},!0);return n.sort((0,m.combineSort)(T,r)),t.concat(n)}t.__esModule=!0;var f=n(0),c=o(f),l=n(27),p=o(l),d=n(15),h=o(d),y=n(2),m=n(22),w=n(29),v=n(71),_=n(72),b=o(_),E=(0,m.sortObjectsByKey)("pageNumber"),g=(0,m.sortObjectsByKey)("createdDate",!0),O=(0,m.sortObjectsByKey)("createdDate",!1),P=(0,m.combineSort)(E,g),T=(0,m.combineSort)(E,O),I=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype._mark=function(e,t,n){var o,r=void 0;switch(t){case h.default.TODO:r="change";break;case h.default.DONE:r="done";break;default:throw new Error('Cannot mark comment state "'+t+'".')}var i=(o={commentId:e},o[r]=n?1:0,o);return this.client.request("comments.state.update",i).then(function(){return null})},t.prototype.mark=function(e,t){return this._mark(e,t,!0)},t.prototype.unmark=function(e,t){return this._mark(e,t,!1)},t.prototype.load=function(e){var t=this,n="string"==typeof e?{proofId:e}:e,o=n.proofId,r=n.pageNumber,i=void 0===r?null:r,s=n.sinceDate,f=void 0===s?null:s,c=n.async,l=void 0!==c&&c,p=n.decrypt,d=void 0===p||p,h=n.onDecryptComment,m=n.onDecryptComments,w=n.onDecryptCommentsThrottleMs,v=void 0===w?1e3:w,_=n.onDecryptError,E=f?f.toISOString().match(y.ISO_REGEX)[0]:y.DEFAULT_ISO_DATE,g={proofId:o,page:i,timestamp:E};return this.client.request(null!==i?"comments.load-page":"comments.load-all",g).then(function(e){var n=u(e.data.Pages?a(e.data.Pages):e.data),o=Promise.resolve();if(d){var r=[],i=[],s=m?(0,b.default)(function(){i.length&&(m(i),i=[])},v):function(){},f=Promise.all(n.map(function(e){return t.client.cache.auto(y.COMMENT_CACHE_PREFIX+e.comment$,function(t){r.push({comment:e,resolve:t})}).then(function(t){return t&&e.fromRawComment(t),e})}));o=o.then(function(){return f}),o=o.then(function(){var e=r.map(function(e){var n=e.comment,o=e.resolve;return t.client.crypto().decryptComment(n.comment$,n.envelope,t.client.session.privateKeyPEM).then(function(e){n.fromRawComment(e),o(e),h&&h(n),i.push(n),s()}).catch(function(e){if(_&&_(e,n),!l)return Promise.reject(e)})});return l?null:Promise.all(e)})}return o.then(function(){return n})})},t.prototype.create=function(e){var t=this,n=e.raw,o=e.proofId,r=e.pageNumber,i=void 0===r?1:r,s=e.pin,a=e.mediaTime,u=e.mediaDuration,f=e.parentCommentId,c=e.metadata,l=e.state,d=e.creationToken,y=(0,w.getCommentMentions)(n),m=d||(0,v.generateCreationToken)();return this.client.crypto().encryptComment(n,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(e){var t=e.envelope,n=e.comment$;return{proofId:o,page:f?void 0:i,envelope:t,encryptedComment:n,xy:JSON.stringify({x:s&&"number"==typeof s.x?s.x:null,y:s&&"number"==typeof s.y?s.y:null,x2:s&&"number"==typeof s.x2?s.x2:null,y2:s&&"number"==typeof s.y2?s.y2:null,time:"number"==typeof a?a:null,duration:"number"==typeof u?u:null}),parent:f||void 0,mentions:y.map(function(e){return e.id}).join(","),metadata:c?JSON.stringify(c):"{}",creationToken:m,change:l===h.default.TODO?"1":void 0,done:l===h.default.DONE?"1":void 0}}).then(function(e){return t.client.request("comments.create",e).then(function(e){return(new p.default).fromComment(e.data).fromRawComment(n)})}).catch(function(e){return e&&(e.creationToken=m),Promise.reject(e)})},t}(c.default);t.default=I},function(e,t,n){"use strict";function o(e){var t=""+e,n=r.exec(t);if(!n)return t;var o,i="",s=0,a=0;for(s=n.index;s<t.length;s++){switch(t.charCodeAt(s)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 39:o="&#39;";break;case 60:o="&lt;";break;case 62:o="&gt;";break;default:continue}a!==s&&(i+=t.substring(a,s)),a=s+1,i+=o}return a!==s?i+t.substring(a,s):i}/*!
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProof=t():e.PageProof=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=32)}([function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function e(t){n(this,e),this.client=t};t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,o){var n=[],r={};return Array.isArray(t)?(n=t,t.forEach(function(e){r[e]=e})):(0,y.default)(t)&&(n=Object.keys(t),r=t),n.forEach(function(t){var n=r[t],i=void 0;if("string"==typeof n)i=-1!==n.indexOf(".")?function(){for(var e=n.split("."),t=o,r=0;r<e.length;r++){var i=e[r];if(!(0,w.default)(t,i)){t=void 0;break}t=t[i]}return t}:function(){return o[n]};else{if("function"!=typeof n){if(null===n)return;throw new Error("Unknown transformer.")}i=n}var a=i.call(e,o);void 0!==a&&(e[t]=a)}),e}function i(e){return function(t){return Number(t[e])}}function a(e,t){return function(o){return t[o[e]]}}function s(e){return function(t){var o=t[e];if(o&&"0001-01-01T00:00:00"!==o)return"number"==typeof o?new Date(1e3*o):new Date(o+"Z")}}function u(e){return function(t){var o=String(t[e]);return"1"===o||"true"===o}}function f(e){return function(t){return w.default.call(t,e)}}function c(e,t){return function(o){return o[e]?o[e].map(t):[]}}function l(e,t){return function(o){return o[e]?JSON.parse(o[e]):Array.isArray(t)?[].concat(t):d({},t)}}function p(e){return function(t){return t[e]?t[e]:void 0}}t.__esModule=!0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e};t.number=i,t.enumeration=a,t.date=s,t.truthy=u,t.exists=f,t.each=c,t.json=l,t.optional=p;var h=o(17),y=n(h),m=o(10),w=n(m);t.default=r},function(e,t,o){"use strict";t.__esModule=!0;t.TOKEN_HEADER="x-authorization-token",t.HMAC_HEADER="x-authorization-hmac",t.TIMESTAMP_HEADER="x-timestamp",t.DEVICE_ID_HEADER="x-device-id",t.SUBSCRIPTION_KEY_HEADER="ocp-apim-subscription-key",t.SDK_VERSION_HEADER="x-pageproof-javascript-sdk",t.RETRY_AFTER_HEADER="retry-after",t.BYTES_PER_BLOCK=2097152,t.MENTION_REGEX=/@{(U[a-zA-Z0-9]{15}|~everyone)}{(.*?)}/g,t.ISO_REGEX=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,t.DEFAULT_ISO_DATE="0001-01-01T00:00:00",t.DAY_IN_MS=864e5,t.COMMENT_CACHE_PREFIX="comment",t.THUMBNAIL_CACHE_PREFIX="thumbnail"},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,r.date)("Registered"),lastLoginDate:(0,r.date)("LastLogin"),lastUploadDate:(0,r.date)("LastUpload"),isAdmin:"IsDomainAdmin"},s=function(){function e(){n(this,e)}return e.prototype.fromJSON=function(e){return(0,i.default)(this,Object.keys(a),e),this},e.prototype.fromUser=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return this.dueDate&&this.dueDate.getTime()<Date.now()}t.__esModule=!0;var a=o(1),s=n(a),u=o(19),f=n(u),c=o(7),l=n(c),p=o(20),d=n(p),h=o(5),y=n(h),m=o(21),w={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,a.date)("DueDate"),createdDate:(0,a.date)("CreatedDate"),approvedDate:(0,a.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:i,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,a.number)("Pages"),commentCount:(0,a.number)("ParentComments"),canDownload:(0,a.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",todoCommentCount:(0,a.number)("CountTodoComments"),doneCommentCount:(0,a.number)("CountDoneComments"),fileCategory:"FileCategory",isAdminOnProof:"IsAdminOnProof",groupId:"GroupId",canReupload:"CanReupload"},v=function(){function e(){r(this,e)}return e.prototype.getState=function(){var e=f.default.ACTIVE;if(this.fileStatus===y.default.UPLOADING)e=f.default.UPLOADING;else if(this.hasFileError())e=f.default.FILE_ERROR;else if(this.isProcessing())e=f.default.PROCESSING;else if(this.type===d.default.BRIEF)switch(this.status){case l.default.NEW:e=f.default.SETUP_NEEDED;break;case l.default.PROOFING:e=f.default.BRIEFING;break;case l.default.AWAITING_NEW_VERSION:e=f.default.AWAITING_PROOF;break;case l.default.HAS_NEW_VERSION:e=f.default.HAS_NEW_VERSION;break;case l.default.ARCHIVED:e=f.default.ARCHIVED}else this.status===l.default.ARCHIVED?e=f.default.ARCHIVED:this.hasWorkflow()?this.status===l.default.TODOS_REQUESTED?e=f.default.TODOS_REQUESTED:this.status===l.default.AWAITING_NEW_VERSION?e=f.default.AWAITING_NEW_VERSION:this.status===l.default.HAS_NEW_VERSION?e=f.default.HAS_NEW_VERSION:this.status===l.default.APPROVED?e=f.default.APPROVED:this.hasWorkflowStarted()?this.isOverdue&&(e=f.default.OVERDUE):e=f.default.NOT_STARTED:e=f.default.PROOFERS_NEEDED;return e},e.prototype.hasWorkflowStarted=function(){return this.hasWorkflow()&&this.status!==l.default.NEW},e.prototype.isProcessing=function(){return this.fileStatus===y.default.UPLOADING||this.fileStatus===y.default.QUEUED||this.fileStatus===y.default.RIPPING},e.prototype.getProcessingProgress=function(){switch(this.fileStatus){case y.default.UPLOADING:return.1;case y.default.QUEUED:return.2;case y.default.RIPPING:return.6;default:return-1}},e.prototype.hasWorkflow=function(){return(0,m.isWorkflowId)(this.workflowId)},e.prototype.hasFile=function(){return(0,m.isFileId)(this.fileId)},e.prototype.hasFileError=function(){return this.fileStatus===y.default.ERROR||!this.fileStatus||!this.hasFile()},e.prototype.hasEditor=function(){return(0,m.isUserId)(this.editorUserId)},e.prototype.hasThumbnail=function(){return this.fileStatus===y.default.OK},e.prototype.canUserUploadNewVersion=function(e){return this.getState()===f.default.AWAITING_NEW_VERSION&&(this.isEditor(e)||this.isOwner(e))||this.getState()===f.default.AWAITING_PROOF&&(this.isEditor(e)||this.isRecipient(e))},e.prototype.isOwner=function(e){return-1!==this.ownerUserIds.indexOf(e)},e.prototype.isEditor=function(e){return-1!==this.editorUserIds.indexOf(e)},e.prototype.isRecipient=function(e){return this.recipient===e},e.prototype.calculateState=function(){this.state=this.getState()},e.prototype.fromProof=function(e){return(0,s.default)(this,w,e),this.calculateState(),this},e}();t.default=v},function(e,t,o){"use strict";t.__esModule=!0;var n={OK:"OK",UPLOADING:"Uploading",QUEUED:"Queued",RIPPING:"Ripping",ERROR:"Error"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f={userId:"UserId",token:"Token",sharedKey:"SharedKey",privateKeyPEM$:"PrivateKey",privateKeyPEM:null,publicKeyPEM:"PublicKey",serverPublicKeyPEM:"PublicServerKey"},c=function(){function e(){r(this,e)}return e.prototype.fromJSON=function(e){return(0,a.default)(this,Object.keys(f),e),this.user=(new u.default).fromJSON(e.user),this},e.prototype.fromSession=function(e){return(0,a.default)(this,f,e),this.user=(new u.default).fromUser(e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,HAS_NEW_VERSION:66,APPROVED:70,ARCHIVED:100};t.default=n},function(e,t,o){"use strict";function n(){if("function"==typeof n.driver){return new(0,n.driver)}if("string"==typeof n.driver){var e=void 0;switch(n.driver){case"Blob":e=o(59).default;break;case"Buffer":e=o(60).default;break;case"String":e=o(61).default;break;default:throw new Error('Unknown Bluffer driver "'+n.driver+'".')}if(e)return new e;throw new Error('Bluffer driver "'+n.driver+'" not found.')}throw new Error('Bluffer.driver must be either "Blob", "Bluffer", or "String" or a custom constructor.')}t.__esModule=!0;var r=o(13)("bluffer");n.driver="String","undefined"!=typeof Blob?n.driver="Blob":(r("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer."),n.driver="String"),t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={ERROR_CRITICAL:3,OK:200,ERROR_INVALID:201,ERROR_NO_ACCESS:100,ERROR_NO_ACCESS_WRITE:101,ERROR_RESTRICTED:102,ERROR_SQL_ERROR:105,ERROR_OUT_SYNC:106,ERROR_STORAGE_ERROR:110,ERROR_QUEUE_ERROR:111,ERROR_SQL_DEADLOCK_ERROR:121,ERROR_BAD_REQUEST:400,ERROR_UNAUTHORISED:401,ERROR_MEDIA_PERMISSION_NO_ACCESS:402,ERROR_NOT_FOUND:1e3,ERROR_CREATE:1001,ERROR_UPDATE:1002,ERROR_DELETE:1003,ERROR_EXISTS:1004,ERROR_USER_INVALID_LOGIN:1010,ERROR_USER_INVALID_PASSWORD:1011,ERROR_USER_IS_REGISTERED:1012,ERROR_USER_INVALID_EMAIL:1013,ERROR_USER_INVALID_LOGIN_COUNT:1014,ERROR_USER_DISABLED:1015,ERROR_BAD_REQUEST_DATE:201,ERROR_THROTTLED:429,ERROR_REUSED_CREATION_TOKEN:2011,ERROR_UPGRADE_REQUIRED:3e3,ERROR_VISIBLE_WORKFLOW_USERS_EXIST:3001,ERROR_GROUP_EXISTS:3002,ERROR_GROUP_PROOFS_EXIST:3003};t.default=n},function(e,t,o){"use strict";t.__esModule=!0,t.default=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(4),u=n(s),f={ownerId:"CreatedBy",id:"GroupId",name:"Name",proofs:(0,i.each)("ProofInfo",function(e){return(new u.default).fromProof(e)})},c=function(){function e(){r(this,e)}return e.prototype.fromProofGroup=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"FileId",name:"Name",blocks:"Chunks",downloadable:"Downloadable",assignedTo:"AssignedTo",assignedType:"AssignedType",status:"Status",message:"Message"},s={id:"Attachment",name:"AttachmentName",blocks:"AttachmentChunks",assignedTo:"CommentId",assignedType:function(){return"attachment"},status:"AttachmentStatus",message:function(){return""}},u=function(){function e(){n(this,e)}return e.prototype.fromFile=function(e){return(0,i.default)(this,a,e),this},e.prototype.fromCommentAttachment=function(e){return(0,i.default)(this,s,e),this},e}();t.default=u},function(e,t,o){"use strict";e.exports=function e(){return e}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(15),u=n(s),f=o(28),c=n(f),l={id:"StepId",name:"Title",position:(0,i.number)("Position"),state:function(e){return e.Complete?c.default.COMPLETE:e.Visible?c.default.VISIBLE:c.default.NOT_VISIBLE},users:(0,i.each)("Users",function(e,t){var o=(new u.default).fromWorkflowUser(e);return o._calculateState(e,t),o})},p=function(){function e(){r(this,e)}return e.prototype.fromWorkflowStep=function(e){return(0,a.default)(this,l,e),this},e}();t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(1),u=n(s),f=o(3),c=n(f),l=o(27),p=n(l),d={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function(e){return{inviter:e.IsInviter}}},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._calculateState=function(e,t){e.SkippedInStep?this.state=p.default.SKIPPED:e.CompleteInStep?this.state=p.default.FINISHED:e.ViewedInStep?this.state=p.default.SEEN:t.Visible?this.state=p.default.VISIBLE:this.state=p.default.NOT_VISIBLE},t.prototype.fromWorkflowUser=function(e){return this._calculateState({},{}),(0,u.default)(this,d,e),this},t}(c.default);t.default=h},function(e,t,o){"use strict";t.__esModule=!0;var n={COMMENT:"comment",TODO:"todo",DONE:"done",UNMARKED_DONE:"unmarked-done"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n=Object.prototype.toString;t.default=function(e){return"[object Object]"===n.call(e)}},function(e,t,o){"use strict";t.__esModule=!0;var n=void 0;n="116.0.1539574885779",t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",HAS_NEW_VERSION:"has-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active",SETUP_NEEDED:"setup-needed",BRIEFING:"briefing",AWAITING_PROOF:"awaiting-proof"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={PROOF:1,BRIEF:2};t.default=n},function(e,t,o){"use strict";var n={Proof:"P",Workflow:"W",File:"F",User:"U",Brief:"B"},r={};Object.keys(n).forEach(function(e){r["is"+e+"Id"]=function(t){return t&&16===t.length&&t[0]===n[e]}}),e.exports=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"ProofId",version:"Version"},s=function(){function e(){n(this,e)}return e.prototype.fromProofVersion=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e,t){return r(function(t){return t[e]},t)}function r(e,t){var o=t?1:-1,n=t?-1:1;return function(t,r){var i=e(t),a=e(r);return i<a?o:i>a?n:0}}function i(e,t){var o={};t.forEach(function(e,t){o[e]=t});var n="function"==typeof e?e:function(t){return t[e]};return function(e,t){var r=o[n(e)],i=o[n(t)];return r<i?-1:r>i?1:0}}function a(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];var n=t.length;return function(e,o){for(var r=0;r<n;r++){var i=t[r](e,o);if(i)return i}return 0}}t.__esModule=!0,t.sortObjectsByKey=n,t.sortObjectsBy=r,t.sortObjectsByValues=i,t.combineSort=a},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:"none",GOOGLE_DRIVE:"drive",DROPBOX:"dropbox",ONEDRIVE:"onedrive",BOX:"box"};t.default=n},function(e,t,o){"use strict";function n(e,t){var o=void 0;return function(){o||(o=setTimeout(function(){e(),o=null},t))}}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(14),u=n(s),f={id:"WorkflowId",name:"Title",steps:(0,i.each)("WorkflowSteps",function(e){return(new u.default).fromWorkflowStep(e)})},c=function(){function e(){r(this,e)}return e.prototype.getStepByPosition=function(e){for(var t=this.steps.length,o=0;o<t;o+=1){var n=this.steps[o];if(n.position===e)return n}return null},e.prototype.getOrderedSteps=function(){return this.steps.sort(function(e,t){return e.position<t.position?-1:e.position>t.position?1:0})},e.prototype.getApproverStep=function(){return this.getStepByPosition(1e3)},e.prototype.fromWorkflow=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",SEEN:"seen",SKIPPED:"skipped",FINISHED:"finished"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",COMPLETE:"complete"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f=o(30),c=n(f),l=o(12),p=n(l),d=o(16),h=n(d),y=o(31),m={__prepare:function(e){e._XY=c.default.parseValue(e.XY)},id:"CommentId",proofId:"ProofId",pin:function(e){return(new c.default).fromPin(e._XY)},user:function(e){return(new u.default).fromUser(e)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function(e){return e.Attachment?[(new p.default).fromCommentAttachment(e)]:[]},agreeCount:function(e){return e.Agrees.length},pageNumber:(0,i.number)("Page"),mediaTime:function(e){return null==e._XY.time?void 0:e._XY.time},mediaDuration:function(e){return null==e._XY.duration?void 0:e._XY.duration},createdDate:(0,i.date)("Timestamp"),updatedDate:(0,i.date)("Updated"),parentCommentId:(0,i.optional)("Parent"),metadata:(0,i.json)("Metadata",{}),state:function(e){return+e.Done?+e.Change?h.default.DONE:h.default.UNMARKED_DONE:+e.Change?h.default.TODO:h.default.COMMENT}},w=function(){function e(){r(this,e)}return e.prototype.fromComment=function(e){return(0,a.default)(this,m,e),this},e.prototype.fromRawComment=function(e){var t=(0,y.parseComment)(e);return this.raw=t.raw,this.text=t.text,this.html=t.html,this.tokens=t.tokens,this},e}();t.default=w},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},i=o(1),a=function(e){return e&&e.__esModule?e:{default:e}}(i),s={x:"x",y:"y",x2:(0,i.optional)("x2"),y2:(0,i.optional)("y2")},u=function(){function e(){n(this,e)}return e.prototype.fromPin=function(e){return(0,a.default)(this,s,e),this},e.parseValue=function(e){var t={x:null,y:null,x2:null,y2:null,time:null,duration:null};if("{"===e[0]){var o=JSON.parse(e);t=r({},t,o)}else if(-1!==e.indexOf(",")){var n=e.split(","),i=n[0],a=n[1];t.x=parseFloat(i),t.y=parseFloat(a)}return t},e}();t.default=u},function(e,t,o){"use strict";function n(e){return(0,c.default)(e)}function r(e){return e.replace(l.MENTION_REGEX,function(e,t,o){return o})}function i(e){var t=0;return e.replace(l.MENTION_REGEX,function(e,o,n,r){return'<span data-mention data-mention-index="'+t+++'" data-mention-user-id="'+o+'" data-mention-user-label="'+n.replace(/"/,'\\"')+'" data-mention-start-index="'+r+'" data-mention-end-index="'+(r+e.length)+'" data-mention-length="'+e.length+'">'+n+"</span>"})}function a(e){var t=[];return e.replace(l.MENTION_REGEX,function(e,o,n,r){t.push({id:o,label:n,index:r,length:e.length})}),t}function s(e){var t=a(e),o=[],n=0;t.forEach(function(t){var r=e.slice(n,t.index);n=t.index+t.length,r&&o.push({type:"text",value:r}),o.push({type:"mention",value:t})});var r=e.slice(n);return r&&o.push({type:"text",value:r}),o}function u(e){var t=n(e);return{raw:e,text:r(t),html:i(t),mentions:a(e),tokens:s(e)}}t.__esModule=!0,t.getCommentTokens=t.getCommentText=t.getCommentMentions=t.getCommentHTML=t.getCommentEscaped=t.parseComment=void 0;var f=o(73),c=function(e){return e&&e.__esModule?e:{default:e}}(f),l=o(2);t.parseComment=u,t.getCommentEscaped=n,t.getCommentHTML=i,t.getCommentMentions=a,t.getCommentText=r,t.getCommentTokens=s},function(e,t,o){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.version=t.Model=t.Enum=t.Bluffer=t.Client=void 0;var i=o(33),a=r(i),s=o(8),u=r(s),f=o(79),c=n(f),l=o(84),p=n(l),d=o(18),h=r(d);t.default=a.default,t.Client=a.default,t.Bluffer=u.default,t.Enum=c,t.Model=p,t.version=h.default},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(34),a=n(i),s=o(39),u=n(s),f=o(40),c=n(f),l=o(42),p=n(l),d=o(44),h=n(d),y=o(46),m=n(y),w=o(48),v=n(w),_=o(49),b=n(_),E=o(56),g=n(E),O=o(57),P=n(O),I=o(64),T=n(I),R=o(68),S=n(R),k=o(70),M=n(k),A=o(72),C=n(A),D=o(75),j=n(D),N=o(76),q=n(N),x=o(6),U=n(x),B=o(77),G=n(B),W=o(9),V=n(W),F=o(78),L=n(F),K=o(13)("PageProof"),H=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.options=t,this.events=new G.default,this.adapters=new a.default(this.options.adapters),this.cache=new u.default(this),this.accounts=new h.default(this),this.comments=new C.default(this),this.dashboard=new m.default(this),this.files=new P.default(this),this.profile=new j.default(this),this.proofs=new b.default(this),this.briefs=new g.default(this),this.users=new v.default(this),this.workflows=new S.default(this),this.preferences=new M.default(this),this.sessions=new q.default(this),this._registerCoreHooks(),this._enhance()}return e.prototype._registerCoreHooks=function(){this.on("error.throttled",function(e){var t=e.data.response.data.timeout;return K("Sleeping "+t+"ms until rate limit resets"),(0,L.default)(t)})},e.prototype._enhance=function(){var e=this;this.adapters.getEnhancementAdapters().forEach(function(t){return t.onClientReady(e)})},e.prototype.setSession=function(e){return!e||e instanceof U.default?this.session=e||null:this.session=(new U.default).fromJSON(e),this.session},e.prototype.request=function(e,t,o){var n=this,r=new c.default(e,t),i=this.adapters.getRequestAdapter(),a=Promise.resolve();if(!r.endpoint.anonymous){if(!this.session)return Promise.reject(new Error("Cannot make call to endpoint ("+e+") when unauthorized."));a=this.adapters.getCryptoAdapter().generateAuthorizationHeaders(r.getMethod(),r.getPath(),this.session).then(function(e){return r.addHeaders(e)})}var s={request:r};return a.then(function(){var e=r.build();return n.events.emit("experimental.request.before",s,!0).then(function(){return e})}).then(function(e){return i.send(e,o)}).then(p.default.parse).then(function(r){if(s.response=r,n.events.emit("experimental.request.after",s),r.code===V.default.ERROR_THROTTLED){var i=n.events.emit("error.throttled",s);if(i.some(Boolean))return Promise.all(i).then(function(){return n.events.emit("experimental.request.retry",s),n.request(e,t,o)})}if(r.code===V.default.ERROR_UNAUTHORISED){var a=n.session?n.session.token:null;return n.events.emit("error.unauthorized",s,!0).then(function(){return n.session&&n.session.token!==a?n.request(e,t,o):r})}if(r.deprecated){var u="The "+e+" API has been deprecated. "+(r.deprecated||"");n.events.emit("error.deprecated",{name:e,message:u})}return r}).then(function(t){try{if(t.error){n.events.emit("error.response",s);var o=new Error(e+" request resulted in an "+t.code+" error.");return o.response=t,o.request=r,Promise.reject(o)}return n.events.emit("experimental.request.resolve",s),Promise.resolve(t)}finally{n.events.emit("experimental.request.finally",s)}})},e.prototype.admin=function(){return this.session?this.session.user.isAdmin?(this._admin||(this._admin=Promise.resolve(new T.default(this))),this._admin):Promise.reject(new Error("The current user must be an administrator of a team or enterprise account.")):Promise.reject(new Error("You must be logged in to use the Admin API."))},e.prototype.crypto=function(){return this.adapters.getCryptoAdapter()},e.prototype.on=function(e,t){return this.events.on(e,t)},e}();t.default=H},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(35),a=n(i),s=o(36),u=n(s),f=o(37),c=n(f),l=o(38),p=n(l),d=function(){function e(t){r(this,e),this.adapters=[].concat(t)}return e.prototype.getAdapterInstanceOf=function(e){return this.getAnyAdaptersInstanceOf(e)[0]||null},e.prototype.getAnyAdaptersInstanceOf=function(e){for(var t=[],o=e.__adapter__,n=0;n<this.adapters.length;n+=1){var r=this.adapters[n];Object.getPrototypeOf(Object.getPrototypeOf(r)).constructor.__adapter__===o&&t.push(r)}return t},e.prototype.getCryptoAdapter=function(){var e=this.getAdapterInstanceOf(a.default);if(!e)throw new Error("ICryptoAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getRequestAdapter=function(){var e=this.getAdapterInstanceOf(u.default);if(!e)throw new Error("IRequestAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getCacheAdapter=function(){return this.getAdapterInstanceOf(c.default)},e.prototype.getEnhancementAdapters=function(){return this.getAnyAdaptersInstanceOf(p.default)},e}();t.default=d},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICryptoAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="IRequestAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICacheAdapter",t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,o){var n=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=n.bind.apply(n,[this].concat(t));return o(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),s=Object.getPrototypeOf(r),u=Object.keys(s).filter(function(e){return"function"==typeof s[e]&&0!==e.indexOf("_")});(i.length||o)&&u.forEach(function(e){n.push({namespace:i.join("."),name:e,api:r})}),a.forEach(function(e){t(r[e],i.concat(e))})}var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return t(e),n}t.__esModule=!0;var a,s,u=(s=a=function(){function e(){n(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){r(e.api,e.name,function(o){var n={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};return t.onMethodBefore(n),function(){var e=void 0;try{e=o()}catch(e){throw n.error=e,t.onMethodThrown(n),e}finally{n.value=e,t.onMethodAfter(n),e&&"function"==typeof e.then&&e.then(function(e){n.resolved=e,t.onMethodResolve(n)},function(e){n.rejected=e,t.onMethodReject(n)}).then(function(){t.onMethodFinally(n)})}return e}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodBefore=function(){},e.prototype.onMethodAfter=function(){},e.prototype.onMethodReject=function(){},e.prototype.onMethodResolve=function(){},e.prototype.onMethodFinally=function(){},e.prototype.onMethodThrown=function(){},e.prototype.onRequestBefore=function(){},e.prototype.onRequestAfter=function(){},e.prototype.onRequestReject=function(){},e.prototype.onRequestThrottled=function(){},e.prototype.onRequestRetry=function(){},e.prototype.onRequestUnauthorized=function(){},e.prototype.onRequestDeprecated=function(){},e.prototype.onRequestResolve=function(){},e.prototype.onRequestFinally=function(){},e}(),a.__adapter__="IEnhancementAdapter",s);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(t){n(this,e),this.client=t}return e.prototype.auto=function(e,t){var o=this.client.adapters.getCacheAdapter(),n=function(){};return o?(n=function(t){void 0!==t&&o.set(e,t)},o.get(e).catch(function(){return Promise.resolve(t(n)).then(function(e){return n(e),e})})):Promise.resolve(t(n))},e}();t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},a=o(41),s=n(a),u=o(17),f=n(u),c=o(18),l=n(c),p=o(2),d=function(){function e(t,o){if(r(this,e),this.name=t,this.endpoint=s.default[t],!this.endpoint)throw new Error('Unknown request endpoint "'+t+'".');this.params={},this.addParams(o),this.headers={}}return e.prototype.addHeaders=function(e){return this.headers=i({},this.headers,e),this},e.prototype.addHeader=function(e,t){return this.headers[e]=t,this},e.prototype.addParams=function(e){return this.params=i({},this.params,e),this},e.prototype.addParam=function(e,t){this.params[e]=t},e.prototype.getPath=function(){var e=this,t=this.endpoint,o=t.path,n=t.chain,r=t.trailing,i=o;return n&&n.forEach(function(t){"/"!==i[i.length-1]&&(i+="/"),i+=e.params[t]}),r&&"/"!==i[i.length-1]&&(i+="/"),i},e.prototype.getQuery=function(){var e=this,t=this.endpoint.query;if(t){var o=t.map(function(t){return void 0!==e.params[t]?t+"="+encodeURIComponent(e.params[t]):null}).filter(Boolean).join("&");if(o)return"?"+o}return""},e.prototype.getHeaders=function(){var e,t=i({},this.headers,(e={},e[p.SDK_VERSION_HEADER]=l.default,e));if("POST"===this.endpoint.method)switch(this.endpoint.version){case 2:t["Content-Type"]="application/json";break;case 1:default:t["Content-Type"]="application/x-www-form-urlencoded"}return t},e.prototype.getBody=function(){var e=this,t=this.endpoint;if(t.body){if("string"==typeof t.body){var o=this.params[t.body];return o=(0,f.default)(o)?JSON.stringify(o):String(o)}var n=!0===t.body?Object.keys(this.params):t.body,r={};switch(n.forEach(function(t){var o=e.params[t];void 0!==o&&(r[t]=o)}),t.version){case 2:return JSON.stringify(r);case 1:default:return Object.keys(r).map(function(t){return t+"="+encodeURIComponent(e.params[t])}).join("&")}}return null},e.prototype.getMethod=function(){return(this.endpoint.method||"GET").toUpperCase()},e.prototype.isWithCredentials=function(){return!0===this.endpoint.credentials},e.prototype.build=function(){return{method:this.getMethod(),path:this.getPath(),query:this.getQuery(),body:this.getBody(),headers:this.getHeaders(),credentials:this.isWithCredentials()}},e}();t.default=d},function(e,t){e.exports={"accounts.register":{method:"POST",path:"/api/users/register",body:["email","password","privateKey","publicKey"],anonymous:!0},"accounts.login":{method:"POST",path:"/api/users/login",body:["email","password"],anonymous:!0},"accounts.generate-activation-code":{method:"GET",path:"/api/users/auth/generate",chain:["userId"],trailing:!0},"accounts.activate":{method:"POST",path:"/api/users/auth/activate",body:["userId","authCode"],trailing:!0},"accounts.logout":{method:"GET",path:"/api/users/logout"},"profile.upload-avatar":{method:"POST",path:"/api/media/file/avatar",body:["uploadedImage"]},"profile.change-password":{method:"POST",path:"/api/users/changepassword",body:["oldPassword","newPassword","newPrivateKey"],trailing:!0},"preferences.all":{method:"GET",path:"/api/users/preferences/all"},"preferences.get":{method:"GET",path:"/api/users/preferences/get",query:["preferences"]},"preferences.update":{method:"POST",path:"/api/users/preferences/update",body:!0},"preferences.reset":{method:"POST",path:"api/users/preferences/update",body:["preferences"]},"dashboard.inbox":{method:"GET",path:"/api/proofs/dashboard/proofin",trailing:!0},"dashboard.sent":{method:"GET",path:"/api/proofs/dashboard/proofout",trailing:!0},"dashboard.outbox":{method:"GET",path:"/api/proofs/dashboard/proofoutbox",trailing:!0},"dashboard.briefs":{method:"GET",path:"/api/briefs/dashboard",trailing:!0},"dashboard.search":{method:"POST",path:"/api/proofs/search",body:["query","all","filterBy"]},"dashboard.groups.filter-by":{method:"GET",path:"/api/proofs/dashboard/groups",chain:["filterBy"],trailing:!0},"team.dashboard.inbox":{method:"GET",path:"/api/admin/dashboard/proofin",chain:["page"],trailing:!0},"team.dashboard.sent":{method:"GET",path:"/api/admin/dashboard/proofsent",chain:["page"],trailing:!0},"team.dashboard.outbox":{method:"GET",path:"/api/admin/dashboard/proofout",chain:["page"],trailing:!0},"team.dashboard.search":{method:"POST",path:"/api/admin/search",body:["query","all","filterBy","page"]},"users.by-id":{method:"GET",path:"/api/users",chain:["userId"]},"users.by-email":{method:"POST",path:"/api/users/email",body:["email"],trailing:!0},"users.invite":{method:"POST",path:"/api/users/create",body:["email"]},"proofs.create":{method:"POST",path:"/api/proofs/create",body:["title","dueDate","description","groupId"]},"proofs.normalize-workflow":{method:"POST",path:"/api/proofs/permission/check",body:["proofId","workflowId"]},"proofs.set-workflow":{method:"POST",path:"/api/proofs/update",body:["proofId","workflowId"]},"proofs.set-tags":{method:"POST",path:"/api/tags/create",body:["relatedId","tag"]},"proofs.set-file":{method:"POST",path:"/api/proofs/update",body:["proofId","fileId"]},"proofs.distribute-file":{method:"GET",path:"/api/proofs/distribute",chain:["proofId"],trailing:!0},"proofs.archive":{version:2,method:"POST",path:"/api/proofs/close",body:["proofIds"]},"proofs.unarchive":{method:"GET",path:"/api/proofs/reopen",chain:["proofId"],trailing:!0},"proofs.delete":{method:"GET",path:"/api/proofs/delete",chain:["proofId"],trailing:!0},"proofs.start":{method:"POST",path:"/api/proofs/startworkflow",body:["proofId"],trailing:!0},"proofs.editors.add":{version:2,method:"POST",path:"/api/proofs/editor/add",body:["proofId","editors","editorMessage"]},"proofs.editors.remove":{version:2,method:"POST",path:"/api/proofs/editor/remove",body:["proofId","editors"]},"proofs.editors.replace":{version:2,method:"POST",path:"/api/proofs/editor/replace",body:["proofId","oldEditors","newEditors"]},"proofs.editors.set":{version:2,method:"POST",path:"/api/proofs/editor/set",body:["proofId","editors"]},"briefs.start":{method:"POST",path:"/api/briefs/start",body:["briefId"]},"proofs.return":{method:"GET",path:"/api/proofs/returnproof",chain:["proofId"]},"proofs.groups.create":{method:"POST",path:"/api/proofs/groups/create",body:["name"]},"proofs.groups.update":{method:"POST",path:"/api/proofs/groups/update",body:["groupId","name"]},"proofs.groups.load":{method:"GET",path:"/api/proofs/group",chain:["groupId"]},"proofs.groups.ready":{method:"POST",path:"/api/proofs/groups/ready",body:["groupId"]},"proofs.groups.owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/groups/add",body:["groupId","owners"]},"proofs.groups.workflows.add-reviewers":{version:2,method:"POST",path:"/api/v2/workflows/groups/reviewers/add",body:["groupId","reviewers"]},"proofs.versions.attach":{method:"POST",path:"/api/proofs/versions/create",body:["proofId","versionId"]},"proofs.versions.list":{method:"GET",path:"/api/proofs/versions",chain:["proofId"],trailing:!0},"proofs.load":{method:"GET",path:"/api/proofs/",chain:["proofId"],trailing:!0},"proofs.request-access":{method:"GET",path:"/api/proofs/requestaccess",chain:["proofId"]},"proofs.lock":{method:"GET",path:"/api/proofs/lock/",chain:["proofId"],trailing:!0},"proofs.unlock":{method:"GET",path:"/api/proofs/unlock/",chain:["proofId"],trailing:!0},"proofs.request-unlock":{method:"GET",path:"/api/proofs/unlockemail/",chain:["proofId"],trailing:!0},"files.generate-token":{method:"GET",path:"/api/media/getfiletoken",query:["relatedId","fileType"]},"files.upload-block":{method:"POST",path:"/api/media/file",query:["block","part","token"],body:"data"},"files.upload-complete":{method:"POST",path:"/api/media/file",query:["block","blockCount","part","token","extn","pages","filename","storeoriginal"],body:"envelope"},"files.details":{method:"GET",path:"/api/media/file/details",chain:["fileId"]},"files.download-block":{method:"GET",path:"/api/media/getfilechunk",chain:["proofId","fileId","block"]},"files.thumbnail":{method:"GET",path:"/api/media/getimage/thumb",chain:["fileId"]},"files.import.generic":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal"]},"files.import.drive":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.onedrive":{method:"POST",path:"/api/media/fileonedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.box":{method:"POST",path:"/api/media/filebox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.dropbox":{method:"POST",path:"/api/media/filedropbox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"workflows.create":{version:2,method:"POST",path:"/api/v2/workflows/create",body:["title"]},"workflows.load":{version:2,method:"GET",path:"/api/v2/workflows/detail",chain:["workflowId"]},"workflows.steps.add":{version:2,method:"POST",path:"/api/v2/workflows/steps/add",body:["workflowId","title","position"]},"workflows.steps.move-before":{method:"POST",path:"/api/workflows/step/movebefore",body:["stepId","beforeStepId"]},"workflows.steps.move-after":{method:"POST",path:"/api/workflows/step/moveafter",body:["stepId","afterStepId"]},"workflows.steps.swap":{method:"POST",path:"/api/workflows/step/swap",body:["stepId","swapStepId"]},"workflows.users.set":{version:2,method:"POST",path:"/api/v2/workflows/users/set",body:["workflowId","stepId","position","users"]},"workflows.users.update":{version:2,method:"POST",path:"/api/v2/workflows/users/update",body:["workflowId","stepId","userId","role","permissions"]},"workflows.users.add":{version:2,method:"POST",path:"/api/v2/workflows/users/add",body:["workflowId","stepId","users"]},"workflows.delete":{method:"POST",path:"/api/workflows/delete",body:["workflowId"]},"workflows.duplicate":{method:"POST",path:"/api/workflows/duplicateonly",body:["workflowId"]},"workflows.owned":{method:"GET",path:"/api/workflows",trailing:!0},"workflows.shared":{method:"GET",path:"/api/workflows/share/user",trailing:!0},"comments.load-all":{method:"POST",path:"/api/proofs/recent",body:["proofId","timestamp"]},"comments.load-page":{method:"POST",path:"/api/proofs/comment/recent",body:["proofId","timestamp","page"]},"comments.state.update":{method:"POST",path:"/api/proofs/comment/updatestatus",body:["commentId","change","done"]},"comments.create":{method:"POST",path:"/api/proofs/comment/create",body:["proofId","page","envelope","encryptedComment","xy","parent","mentions","metadata","creationToken","change","done"]},"proofs-owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/add",body:["proofId","users"]},"proofs-owners.remove":{version:2,method:"POST",path:"/api/v2/proofs/owners/remove",body:["proofId","users"]},"proofs.tag-delete":{method:"POST",path:"/api/tags/delete",body:["relatedId","tag"]},"proofs.remove-editor":{method:"GET",path:"/api/proofs/deleteeditor",chain:["proofId"],trailing:!0},"briefs.create":{method:"POST",path:"/api/briefs/create",body:["title","messageToRecipient","dueDate","tag"]},"briefs.update":{method:"POST",path:"/api/briefs/update",body:["briefId","title","messageToRecipient","dueDate","tag","recipient","editorId","editorMessage"]},"admin.team.users.enabled":{method:"GET",path:"/api/admin/getusers/active",trailing:!0},"admin.team.users.disabled":{method:"GET",path:"/api/admin/getusers/inactive",trailing:!0},"admin.team.users.set-enabled":{method:"POST",path:"/api/admin/setenabled",body:["email","enabled"]},"sessions.check":{method:"GET",path:"/api/sessions/check"},"sso.get-public-key":{method:"GET",path:"/sso/public_key",anonymous:!0},"sso.get-session":{version:2,method:"POST",path:"/sso/session",body:["nonce"],anonymous:!0,credentials:!0},"sso.get-login-options":{version:2,method:"POST",path:"/sso/login_options",body:["email"],anonymous:!0}}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(9),a=n(i),s=o(43),u=o(2),f=o(10),c=n(f),l=function(){function e(){r(this,e),this.error=!1,this.code=-1,this.data=null,this.message=null,this.deprecated=null}return e.parse=function(t){var o=t.status,n=t.headers,r=void 0===n?{}:n,i=t.body,f=new e;if(o===s.TOO_MANY_REQUESTS_STATUS)return f.error=!0,f.message="PageProof Error #h"+s.TOO_MANY_REQUESTS_STATUS,f.code=a.default.ERROR_THROTTLED,f.data={timeout:1e3*(parseFloat(r[u.RETRY_AFTER_HEADER])||60)},f;if((0,c.default)(r,"deprecated")&&(f.deprecated=r.deprecated),o===s.OK_STATUS&&!i)return f.code=a.default.OK,f;try{var l=JSON.parse(i);"string"==typeof l||(l&&"ResponseCode"in l?(f.code=l.ResponseCode,f.code!==a.default.OK&&(f.error=!0)):l.Message&&1===Object.keys(l).length&&(f.error=!0,f.code=a.default.ERROR_CRITICAL)),f.error&&(f.message="PageProof Error #s"+f.code),f.data=l}catch(e){f.error=!0}return f},e}();t.default=l},function(e,t,o){"use strict";t.__esModule=!0;t.TOO_MANY_REQUESTS_STATUS=429,t.OK_STATUS=200},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=o(45),p=n(l),d=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.sso=new p.default(o),n}return a(t,e),t.prototype.register=function(e,t){var o=this;return this.client.crypto().generatePasswordHash(t).then(function(e){return Promise.all([e,o.client.crypto().generateKeyPair()])}).then(function(e){var n=e[0],r=e[1];return Promise.all([n,r,o.client.crypto().encryptPrivateKey(r.privateKeyPEM,t)])}).then(function(t){var n=t[0],r=t[1],i=t[2];return Promise.all([r,o.client.request("accounts.register",{email:e,password:n,privateKey:i,publicKey:r.publicKeyPEM})])}).then(function(n){var r=n[0];return Promise.all([r,o.login(e,t,!1)])}).then(function(e){var t=e[0],n=e[1];return Promise.all([t,n,o.generateActivationCode()])}).then(function(e){var t=e[0],o=e[1];return o.privateKeyPEM=t.privateKeyPEM,o})},t.prototype.generateActivationCode=function(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})},t.prototype.activate=function(e){var t=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:e}).then(function(){t.client.session.user.hasActivated=!0})},t.prototype.login=function(e,t){var o=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.client.crypto().generatePasswordHash(t).then(function(t){return o.client.request("accounts.login",{email:e,password:t})}).then(function(t){var o=(new c.default).fromSession(t.data);return o.user.email=e,o}).then(function(e){return n?o.client.crypto().decryptPrivateKey(e.privateKeyPEM$,t).then(function(t){return e.privateKeyPEM=t,e}):e}).then(function(e){return o.client.setSession(e),e})},t.prototype.logout=function(){var e=this;return this.client.request("accounts.logout").catch(function(t){return e.client.setSession(null),Promise.reject(t)}).then(function(){e.client.setSession(null)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.getSession=function(){var e=this;return this.client.request("sso.get-public-key").then(function(e){return e.data.ServerPublicKey}).then(function(t){return e.client.crypto().generateWrappedSymmetricKey(t)}).then(function(t){var o=t.key,n=t.key$;return Promise.all([o,e.client.request("sso.get-session",{nonce:n})])}).then(function(t){var o=t[0],n=t[1],r=(new c.default).fromSession(n.data);return Promise.all([r,e.client.crypto().decryptManagedPrivateKey(r.privateKeyPEM$,o)])}).then(function(e){var t=e[0],o=e[1];return t.privateKeyPEM=o,t})},t.prototype.getLoginOptions=function(e){return this.client.request("sso.get-login-options",{email:e}).then(function(e){return e.data})},t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t={};return Object.keys(w).forEach(function(o){t[o]=e[w[o]]}),t}function u(e){return(e||[]).map(function(e){return(new p.default).fromProof(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(4),p=n(l),d=o(7),h=n(d),y=o(47),m=n(y),w={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox",briefs:"AllBriefs"},v=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.groups=new m.default(o),n}return a(t,e),t.prototype.inbox=function(){return this._loadSingleTabProofs("inbox")},t.prototype.sent=function(){return this._loadSingleTabProofs("sent")},t.prototype.outbox=function(){return this._loadSingleTabProofs("outbox")},t.prototype.briefs=function(){return this._loadSingleTabProofs("briefs")},t.prototype._loadSingleTabProofs=function(e){return this.client.request("dashboard."+e).then(function(e){return s(e.data)}).then(function(t){return t[e]}).then(u)},t.prototype.search=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.status,n=t.everything;return this._loadSearchProofs({query:e,filterBy:void 0===o?void 0:[].concat(o).join(","),all:n?1:0})},t.prototype.everything=function(){return this.search(void 0,{everything:!0})},t.prototype.approved=function(){return this.search(void 0,{status:h.default.APPROVED})},t.prototype.archived=function(){return this.search(void 0,{status:h.default.ARCHIVED})},t.prototype._loadSearchProofs=function(e){return this.client.request("dashboard.search",e).then(function(e){return u(e.data.Proofs)})},t}(c.default);t.default=v},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return(e||[]).map(function(e){return(new l.default).fromProofGroup(e)})}t.__esModule=!0;var u=o(0),f=n(u),c=o(11),l=n(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._loadGroups=function(e){return this.client.request("dashboard.groups.filter-by",{filterBy:e}).then(function(e){return s(e.data)})},t.prototype.current=function(){return this._loadGroups("current")},t}(f.default);t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.length>0?(new p.default).fromUser(e.data[0]):(new p.default).fromUser(e.data)}function u(e){return e.data.length?(new p.default).fromUser(e.data[0]):null}t.__esModule=!0;var f=o(0),c=n(f),l=o(3),p=n(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.byEmail=function(e){return this.client.request("users.by-email",{email:e}).then(u)},t.prototype.byId=function(e){return this.client.request("users.by-id",{userId:e}).then(s)},t.prototype.invite=function(e){return this.client.request("users.invite",{email:e}).then(s)},t}(c.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(50),c=n(f),l=o(51),p=n(l),d=o(52),h=n(d),y=o(53),m=n(y),w=o(4),v=n(w),_=o(5),b=n(_),E=o(2),g=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new c.default(o),n.editors=new p.default(o),n.versions=new h.default(o),n.groups=new m.default(o),n}return a(t,e),t.prototype.setWorkflow=function(e,t){var o=this;return this.client.request("proofs.normalize-workflow",{proofId:e,workflowId:t}).then(function(){return o.client.request("proofs.set-workflow",{proofId:e,workflowId:t})})},t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.tags,r=void 0===n?[]:n,i=e.dueDate,a=void 0===i?new Date(Date.now()+3*E.DAY_IN_MS):i,s=e.messageToReviewers,u=e.workflow,f=e.file,c=e.group,l=e.start,p=void 0===l||l,d=p&&!c;return this.client.request("proofs.create",{title:o,dueDate:a.toISOString(),description:s,groupId:c?c.id:void 0}).then(function(e){var o=(new v.default).fromProof(e.data);return Promise.all([o,r.length&&t.setTags(o.id,r),u&&t.setWorkflow(o.id,u.id),f&&t.setFile(o.id,f.id)])}).then(function(e){var o=e[0];return Promise.resolve(d&&t.start(o.id)).then(function(){return o})}).then(function(e){return u&&(e.workflowId=u.id),f&&(e.fileId=f.id,e.fileStatus=b.default.UPLOADING),e.calculateState(),e})},t.prototype.archive=function(e){return this.client.request("proofs.archive",{proofIds:e})},t.prototype.unarchive=function(e){return this.client.request("proofs.unarchive",{proofId:e})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.return=function(e){return this.client.request("proofs.return",{proofId:e})},t.prototype.start=function(e){return this.client.request("proofs.start",{proofId:e})},t.prototype.removeEditor=function(e){return this.client.request("proofs.remove-editor",{proofId:e})},t.prototype.load=function(e){return this.client.request("proofs.load",{proofId:e}).then(function(e){return(new v.default).fromProof(e.data)})},t.prototype.lock=function(e){return this.client.request("proofs.lock",{proofId:e})},t.prototype.unlock=function(e){return this.client.request("proofs.unlock",{proofId:e})},t.prototype.requestUnlock=function(e){return this.client.request("proofs.request-unlock",{proofId:e})},t.prototype.requestAccess=function(e){return this.client.request("proofs.request-access",{proofId:e})},t}(u.default);t.default=g},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs-owners.add",{proofId:e,users:[].concat(t)})},t.prototype.remove=function(e,t){return this.client.request("proofs-owners.remove",{proofId:e,users:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t,o){var n={proofId:e,editors:[].concat(t),editorMessage:null===o?"":o};return this.client.request("proofs.editors.add",n)},t.prototype.remove=function(e,t){return this.client.request("proofs.editors.remove",{proofId:e,editors:[].concat(t)})},t.prototype.replace=function(e,t,o){return this.client.request("proofs.editors.replace",{proofId:e,oldEditors:[].concat(t),newEditors:[].concat(o)})},t.prototype.set=function(e,t){return this.client.request("proofs.editors.set",{proofId:e,editors:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(22),c=n(f),l=o(23),p=(0,l.sortObjectsByKey)("version"),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.attach=function(e,t){return this.client.request("proofs.versions.attach",{proofId:e,versionId:t})},t.prototype.list=function(e){return this.client.request("proofs.versions.list",{proofId:e}).then(function(e){return e.data.map(function(e){return(new c.default).fromProofVersion(e)}).sort(p)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return(new l.default).fromProofGroup(e.data)}t.__esModule=!0;var u=o(0),f=n(u),c=o(11),l=n(c),p=o(54),d=n(p),h=o(55),y=n(h),m=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new d.default(o),n.workflows=new y.default(o),n}return a(t,e),t.prototype.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name;return this.client.request("proofs.groups.create",{name:t}).then(s)},t.prototype.load=function(e){return this.client.request("proofs.groups.load",{groupId:e}).then(s)},t.prototype.ready=function(e){return this.client.request("proofs.groups.ready",{groupId:e})},t.prototype.update=function(e,t){var o=t.name;return this.client.request("proofs.groups.update",{groupId:e,name:o}).then(s)},t}(f.default);t.default=m},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs.groups.owners.add",{groupId:e,owners:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.addReviewers=function(e,t){return this.client.request("proofs.groups.workflows.add-reviewers",{groupId:e,reviewers:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(4),c=n(f),l=o(5),p=n(l),d=o(2),h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.file,r=e.tags,i=void 0===r?[]:r,a=e.dueDate,s=void 0===a?new Date(Date.now()+3*d.DAY_IN_MS):a;return this.client.request("briefs.create",{title:o,messageToRecipient:"",dueDate:s.toISOString(),tag:i.join(",")}).then(function(e){var o=(new c.default).fromProof(e.data.Brief);return Promise.all([o,n&&t.setFile(o.id,n.id)])}).then(function(e){var t=e[0];return n&&(t.fileId=n.id,t.fileStatus=p.default.UPLOADING),t.calculateState(),t})},t.prototype.update=function(e){var t=this,o=e.briefId,n=e.data,r=e.start,i=void 0!==r&&r;return this.client.request("briefs.update",{briefId:o,title:n.title,messageToRecipient:n.messageToRecipient,dueDate:n.dueDate?n.dueDate.toISOString():"",tag:n.tags?n.tags.join(","):"",recipient:n.recipient,editorId:n.editorId,editorMessage:n.editorMessage}).then(function(e){return(new c.default).fromProof(e.data.Brief)}).then(function(e){return Promise.resolve(i&&t.start(e.id)).then(function(){return e})})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.start=function(e){return this.client.request("briefs.start",{briefId:e})},t}(u.default);t.default=h},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.lastIndexOf(".");return{name:e.substring(0,t),extension:e.substring(t+1)}}t.__esModule=!0;var u=o(0),f=n(u),c=o(12),l=n(c),p=o(5),d=n(p),h=o(24),y=n(h),m=o(58),w=n(m),v=o(8),_=n(v),b=o(63),E=n(b),g=o(2),O=o(25),P=n(O),I=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.generateToken=function(e,t){return e&&!t?Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.')):!e&&t?Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.')):this.client.request("files.generate-token",{relatedId:e,fileType:t}).then(function(e){return e.data.Token})},t.prototype._waitFileProcessed=function(e){var t=this;return new Promise(function(o,n){var r=null,i=null;!function a(){t.details(e).then(function(t){switch(r=null,t.status){case d.default.OK:o(t);break;case d.default.ERROR:n(new Error("File "+e+" encountered a processing error: "+t.message));break;default:r=setTimeout(a,5e3)}r&&t.status!==d.default.RIPPING||clearTimeout(i)}).catch(n)}(),i=setTimeout(function(){clearTimeout(r),n(new Error("File did not finish processing within specified duration."))},3e4)})},t.prototype.import=function(e){var t=this,o=e.name,n=e.url,r=e.provider,i=void 0===r?y.default.NONE:r,a=e.auth,u=e.download,f=void 0!==u&&u,c=e.process,p=void 0!==c&&c;if(!Object.keys(y.default).some(function(e){return y.default[e]===i}))return Promise.reject(new Error('Unsupported provider "'+i+'"'));var d=i;i===y.default.NONE&&(d="generic");var h=s(o),m=h.name,w=h.extension;return this._generateKeyIVEnvelope().then(function(e){var o=e.envelope;return t.client.request("files.import."+d,{extn:w,filename:m,url:n,envelope:o,accessToken:a,storeOriginal:f})}).then(function(e){return e.data}).then(function(e){if(p)return t._waitFileProcessed(e);var o=new l.default;return o.id=e,o})},t.prototype._generateKeyIVEnvelope=function(){var e=this;return this.client.crypto().generateKeyIV().then(function(t){return Promise.all([t,e.client.crypto().envelopeSeal(t.keyIV,[e.client.session.serverPublicKeyPEM,e.client.session.publicKeyPEM])])}).then(function(e){return{keyIV:e[0],envelope:e[1]}})},t.prototype.upload=function(e){var t=this,o=e.name,n=e.contents,r=e.assignedTo,i=e.assignedType,a=e.download,s=void 0!==a&&a,u=e.async,f=void 0===u||u,c=e.onProgress,p=e.onError;return this.generateToken(r,i).then(function(e){return Promise.all([e,t._generateKeyIVEnvelope()])}).then(function(e){var r=e[0],i=e[1],a=i.keyIV,u=i.envelope,l=t._upload({name:o,contents:n,download:s,token:r,keyIV:a,envelope:u,onProgress:c,onError:p});return f&&(l=Promise.resolve()),l.then(function(){return r})}).then(function(e){var t=new l.default;return t.id=e,t})},t.prototype._upload=function(e){var t=this,o=e.name,n=e.contents,r=e.download,i=e.token,a=e.keyIV,u=e.envelope,f=e.onProgress;return new Promise(function(e){function c(){y().then(function(t){if(!_)if(null===t)_=!0,e(m.then(T));else{var o=I(t,v++);m=m.then(function(){return o}),o.then(c)}})}var l=4,p=s(o),d=p.name,h=p.extension,y=(0,w.default)(n),m=Promise.resolve(),v=0,_=!1,b=Math.ceil((0,E.default)(n)/g.BYTES_PER_BLOCK),O=new Array(b),P=function(){};f&&(P=function(e,t){O[e]=Math.max(t,O[e]||0),f(O.reduce(function(e,t){return e+(t||0)},0)/b*.99)});for(var I=function(e,o){return t.client.crypto().encryptFileBlock(a,e).then(function(e){return t.client.request("files.upload-block",{block:o,part:1,token:i,data:e},{onUploadProgress:P.bind(null,o)})})},T=function(){return t.client.request("files.upload-complete",{block:0,blockCount:v,part:0,token:i,extn:h,pages:1,filename:d,storeoriginal:r?1:0,envelope:u}).then(function(){return f&&f(100)})};l--;)c()})},t.prototype.download=function(e){var t=this,o="string"==typeof e?{fileId:e}:e,n=o.fileId,r=o.onFileDetails;return this.details(n).then(function(e){if(!e.downloadable)throw new Error("File "+n+" is not downloadable.");if(e.status!==d.default.OK)throw new Error("File "+n+" cannot be download. The file may still be uploading, processing or has errored.");if(!e.blocks)throw new Error("File "+n+" is empty.");return r&&r(e),t._downloadFile(e,o)})},t.prototype._downloadFile=function(e,t){var o=this;return new Promise(function(n){function r(){if(!y)if(h<u.length){var e=h++,t=d(e);f=f.then(function(){return t.then(function(t){return c(t,e,s)})}),t.then(r)}else y=!0,n(f.then(m))}var i=4,a=new _.default,s=e.blocks,u=new Array(s),f=Promise.resolve(),c=t.onData||function(e,t){u[t]=e},l=function(){};if(t.onProgress){var p=new Array(s);l=function(e,o){p[e]=Math.max(o,p[e]||0),t.onProgress(p.reduce(function(e,t){return e+(t||0)},0)/s*.99)}}for(var d=function(t){return o.client.request("files.download-block",{proofId:e.assignedTo,fileId:e.id,block:t+1},{onDownloadProgress:l.bind(null,t)}).then(function(e){return o.client.crypto().decryptFileBlock(e.data,o.client.session.privateKeyPEM).then(function(e){return a.createBase64(e)})})},h=0,y=!1,m=function(){return t.onProgress&&t.onProgress(100),t.onData?null:a.combine.apply(a,u)};i--;)r()})},t.prototype.details=function(e){return this.client.request("files.details",{fileId:e}).then(function(e){return(new l.default).fromFile(e.data)})},t.prototype.thumbnail=function(e){var t=this;return this.client.cache.auto(g.THUMBNAIL_CACHE_PREFIX+e,function(){return t._thumbnail(e)})},t.prototype._thumbnail=function(e){var t=this;return this.client.request("files.thumbnail",{fileId:e}).then(function(e){return t.client.crypto().decryptImage(e.data,t.client.session.privateKeyPEM)}).then(function(e){return(new _.default).createBase64(e)})},t.prototype.thumbnails=function(e,t){var o=this,n=t.async,r=void 0!==n&&n,i=t.onLoadThumbnail,a=t.onLoadThumbnails,s=t.onLoadThumbnailsThrottleMs,u=void 0===s?1e3:s,f=t.onLoadError,c=[],l={},p=a?(0,P.default)(function(){Object.keys(l).length&&(a(l),l={})},u):function(){};return Promise.all(e.map(function(e){return o.client.cache.auto(g.THUMBNAIL_CACHE_PREFIX+e,function(t){c.push({fileId:e,resolve:t})}).then(function(t){var o;return t&&(o={},o[e]=t,o)})})).then(function(e){var t=Promise.all(c.map(function(e){var t=e.fileId,n=e.resolve;return o._thumbnail(t).then(function(e){var o;if(n(e),i){var r;i((r={},r[t]=e,r))}return l[t]=e,p(),o={},o[t]=e,o}).catch(function(e){return f&&f(e,t),r?{}:Promise.reject(e)})}));return r?e:t.then(function(t){return[].concat(e,t)})}).then(function(e){return Object.assign.apply(Object,[{}].concat(e))})},t}(f.default);t.default=I},function(e,t,o){"use strict";function n(e){var t=new a.default,o=0,n=Promise.resolve(),i=t.size(e);return function(){var a=o++*r.BYTES_PER_BLOCK,s=a+r.BYTES_PER_BLOCK;return n=n.then(function(){return a>i?null:t.slice(e,a,s).then(t.readBase64).then(function(e){return"data:;base64,"+e})})}}t.__esModule=!0;var r=o(2),i=o(8),a=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=new ArrayBuffer(e.length),o=new Uint8Array(t),n=0;n<e.length;n++)o[n]=e.charCodeAt(n);return t}t.__esModule=!0;var i=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(new Blob([r(e)]))},e.prototype.createBase64=function(e){return this.create(atob(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(new Blob(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=function(){o(n.error)},n.readAsText(e)})},e.prototype.readBase64=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){var e=n.result;t(e.substring(e.indexOf(",")+1))},n.onerror=function(){o(n.error)},n.readAsDataURL(e)})},e.prototype.size=function(e){return e.size},e}();t.default=i},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(Buffer.from(e))},e.prototype.createBase64=function(e){return Promise.resolve(Buffer.from(e,"base64"))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(Buffer.concat(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e.toString())},e.prototype.readBase64=function(e){return Promise.resolve(e.toString("base64"))},e.prototype.size=function(e){return Buffer.byteLength(e)},e}();t.default=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=e.length,o=e.length-1;o>=0;o--){var n=e.charCodeAt(o);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&o--}return t}t.__esModule=!0;var i=o(62),a=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(e)},e.prototype.createBase64=function(e){return Promise.resolve((0,i.atob)(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(t.join(""))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e)},e.prototype.readBase64=function(e){return Promise.resolve((0,i.btoa)(e))},e.prototype.size=function(e){return r(e)},e}();t.default=a},function(e,t,o){!function(){function e(e){this.message=e}var o=t,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.prototype=new Error,e.prototype.name="InvalidCharacterError",o.btoa||(o.btoa=function(t){for(var o,r,i=String(t),a=0,s=n,u="";i.charAt(0|a)||(s="=",a%1);u+=s.charAt(63&o>>8-a%1*8)){if((r=i.charCodeAt(a+=.75))>255)throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|r}return u}),o.atob||(o.atob=function(t){var o=String(t).replace(/[=]+$/,"");if(o.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,a=0,s=0,u="";i=o.charAt(s++);~i&&(r=a%4?64*r+i:i,a++%4)?u+=String.fromCharCode(255&r>>(-2*a&6)):0)i=n.indexOf(i);return u})}()},function(e,t,o){"use strict";function n(e){return"undefined"!=typeof Blob&&e instanceof Blob?e.size:0}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(65),c=n(f),l=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.team=new c.default(o),n}return a(t,e),t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(66),c=n(f),l=o(67),p=n(l),d=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.users=new c.default(o),n.dashboard=new p.default(o),n}return a(t,e),t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.map(function(e){return(new l.default).fromUser(e)})}t.__esModule=!0;var u=o(0),f=n(u),c=o(3),l=n(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.enabled=function(){return this.client.request("admin.team.users.enabled").then(s)},t.prototype.disabled=function(){return this.client.request("admin.team.users.disabled").then(s)},t.prototype._setEnabled=function(e,t){return this.client.request("admin.team.users.set-enabled",{email:e,enabled:t})},t.prototype.enable=function(e){return this._setEnabled(e,!0)},t.prototype.disable=function(e){return this._setEnabled(e,!1)},t}(f.default);t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){var o={};return o.proofs=u(e[y[t]]),o.total=e.ProofsNumber,o}function u(e){return(e||[]).map(function(e){return(new p.default).fromProof(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(4),p=n(l),d=o(7),h=n(d),y={inbox:"ProofIn",sent:"ProofSent",outbox:"ProofOut",search:"Proofs"},m=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.inbox=function(e){return this._loadSingleTeamTabProofs("inbox",{page:e})},t.prototype.sent=function(e){return this._loadSingleTeamTabProofs("sent",{page:e})},t.prototype.outbox=function(e){return this._loadSingleTeamTabProofs("outbox",{page:e})},t.prototype._loadSingleTeamTabProofs=function(e,t){return this.client.request("team.dashboard."+e,t).then(function(t){return s(t.data,e)}).then(function(e){return e})},t.prototype.everything=function(e){return this.search(void 0,{everything:!0,page:e})},t.prototype.approved=function(e){return this.search(void 0,{status:h.default.APPROVED,page:e})},t.prototype.archived=function(e){return this.search(void 0,{status:h.default.ARCHIVED,page:e})},t.prototype.search=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.status,n=t.everything,r=t.page;return this._loadTeamSearchProofs({query:e,filterBy:void 0===o?void 0:[].concat(o).join(","),all:n?1:0,page:r})},t.prototype._loadTeamSearchProofs=function(e){return this.client.request("team.dashboard.search",e).then(function(e){return s(e.data,"search")})},t}(c.default);t.default=m},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e&&((0,w.isUserId)(e.id)||e.email)}function u(e){return(e||[]).map(function(e){return(new p.default).fromWorkflow(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(26),p=n(l),d=o(14),h=n(d),y=o(15),m=n(y),w=o(21),v=o(69),_=n(v),b=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.steps=new _.default(o),n}return a(t,e),t.prototype.create=function(e){var t=this,o=e.save,n=void 0!==o&&o,r=e.name,i=e.steps,a=void 0===i?[]:i,u=e.reviewers,f=e.approver;if(!s(f))return Promise.reject(Error("An approver is required to create a workflow."));if(n&&!r)return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."));var c=a;u&&u.length&&c.splice(0,0,{users:u}),f&&c.push({position:1e3,users:[f]});for(var l=0,p=0;p<c.length;p++){var d=c[p];if(!d.users||!d.users.length)return Promise.reject(Error("Workflow steps must contain users."));(!d.position||d.position<l)&&(d.position=l+1),l=Math.max(l,d.position);for(var h=0;h<d.users.length;h++){if(!s(d.users[h]))return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}var y=void 0;return this._createWorkflow(r).then(function(e){return y=e.id,Promise.all([e,Promise.all(c.map(function(o){var n=e.getStepByPosition(o.position);return n?t._setWorkflowStepUsersMutate(e.id,n,o.users):t._addWorkflowStepAndUsers(e.id,o)}))])}).then(function(e){var t=e[0],o=e[1];return t.steps=o,t}).then(function(e){return n?t._duplicateWorkflow(y):e}).catch(function(e){return Promise.resolve(y&&t._deleteWorkflow(y)).then(function(){return Promise.reject(e)})})},t.prototype.load=function(e){return this.client.request("workflows.load",{workflowId:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype.use=function(e){return this.duplicate(e)},t.prototype.duplicate=function(e){return this._duplicateWorkflow(e)},t.prototype.delete=function(e){return this._deleteWorkflow(e)},t.prototype.all=function(){return Promise.all([this.owned(),this.shared()]).then(function(e){return[].concat(e[0],e[1])})},t.prototype.owned=function(){return this.client.request("workflows.owned").then(function(e){return u(e.data)})},t.prototype.shared=function(){return this.client.request("workflows.shared").then(function(e){return u(e.data)})},t.prototype.setApprover=function(e,t){return this.client.request("workflows.users.set",{workflowId:e,position:1e3,users:[t]})},t.prototype._duplicateWorkflow=function(e){var t=this;return this.client.request("workflows.duplicate",{workflowId:e}).then(function(e){var o=e.data.WorkflowId;return t.load(o)})},t.prototype._deleteWorkflow=function(e){return this.client.request("workflows.delete",{workflowId:e})},t.prototype._createWorkflow=function(e){return this.client.request("workflows.create",{title:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype._addWorkflowStepAndUsers=function(e,t){var o=this;return this.client.request("workflows.steps.add",{workflowId:e,title:t.name,position:t.position}).then(function(n){var r=(new h.default).fromWorkflowStep(n.data);return o._setWorkflowStepUsersMutate(e,r,t.users)})},t.prototype._setWorkflowStepUsersMutate=function(e,t,o){return this.client.request("workflows.users.set",{workflowId:e,stepId:t.id,users:o.map(function(e){return{email:e.email,userId:e.id,role:e.role,permissions:e.permissions&&{inviter:!!e.permissions.inviter}}})}).then(function(e){var o=e.data.map(function(e){return(new m.default).fromWorkflowUser(e)});return t.users=o,t})},t}(c.default);t.default=b},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.moveBefore=function(e,t){return this.client.request("workflows.steps.move-before",{stepId:e,beforeStepId:t})},t.prototype.moveAfter=function(e,t){return this.client.request("workflows.steps.move-after",{stepId:e,afterStepId:t})},t.prototype.swap=function(e,t){return this.client.request("workflows.steps.swap",{stepId:e,swapStepId:t})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return(new p.default).fromPreference(e)}function u(e,t){var o=new Array(e.length);return t.forEach(function(t){o[e.indexOf(t.name)]=t}),o}t.__esModule=!0;var f=o(0),c=n(f),l=o(71),p=n(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.all=function(){return this.client.request("preferences.all")},t.prototype.get=function(e){var t=[].concat(e);return this.client.request("preferences.get",{preferences:t}).then(function(e){return e.data.map(s)}).then(function(o){return"string"==typeof e?o[0]:u(t,o)})},t.prototype.update=function(e,t){var o,n=void 0!==t?(o={},o[e]=t,o):e;return this.client.request("preferences.update",n)},t.prototype.reset=function(e){return this.client.request("preferences.reset",{preferences:[].concat(e)})},t}(c.default);t.default=d},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={name:"Name",defaultValue:"DefaultValue",value:"Value"},s=function(){function e(){n(this,e)}return e.prototype.getValueOrDefault=function(){return null===this.value?this.defaultValue:this.value},e.prototype.fromPreference=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=[];return Object.keys(e).forEach(function(o){e[o].Comments.forEach(function(e){t.push(e)})}),t}function u(e){var t=[],o=[];e.forEach(function(e){var n=(new p.default).fromComment(e);n.parentCommentId?o.push(n):t.push(n)}),t.sort(P);var n=t.map(function(e){return e.id}),r=(0,m.sortObjectsBy)(function(e){return n.indexOf(e.parentCommentId)},!0);return o.sort((0,m.combineSort)(I,r)),t.concat(o)}t.__esModule=!0;var f=o(0),c=n(f),l=o(29),p=n(l),d=o(16),h=n(d),y=o(2),m=o(23),w=o(31),v=o(74),_=o(25),b=n(_),E=(0,m.sortObjectsByKey)("pageNumber"),g=(0,m.sortObjectsByKey)("createdDate",!0),O=(0,m.sortObjectsByKey)("createdDate",!1),P=(0,m.combineSort)(E,g),I=(0,m.combineSort)(E,O),T=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._mark=function(e,t,o){var n,r=void 0;switch(t){case h.default.TODO:r="change";break;case h.default.DONE:r="done";break;default:throw new Error('Cannot mark comment state "'+t+'".')}var i=(n={commentId:e},n[r]=o?1:0,n);return this.client.request("comments.state.update",i).then(function(){return null})},t.prototype.mark=function(e,t){return this._mark(e,t,!0)},t.prototype.unmark=function(e,t){return this._mark(e,t,!1)},t.prototype.load=function(e){var t=this,o="string"==typeof e?{proofId:e}:e,n=o.proofId,r=o.pageNumber,i=void 0===r?null:r,a=o.sinceDate,f=void 0===a?null:a,c=o.async,l=void 0!==c&&c,p=o.decrypt,d=void 0===p||p,h=o.onDecryptComment,m=o.onDecryptComments,w=o.onDecryptCommentsThrottleMs,v=void 0===w?1e3:w,_=o.onDecryptError,E=f?f.toISOString().match(y.ISO_REGEX)[0]:y.DEFAULT_ISO_DATE,g={proofId:n,page:i,timestamp:E};return this.client.request(null!==i?"comments.load-page":"comments.load-all",g).then(function(e){var o=u(e.data.Pages?s(e.data.Pages):e.data),n=Promise.resolve();if(d){var r=[],i=[],a=m?(0,b.default)(function(){i.length&&(m(i),i=[])},v):function(){},f=Promise.all(o.map(function(e){return t.client.cache.auto(y.COMMENT_CACHE_PREFIX+e.comment$,function(t){r.push({comment:e,resolve:t})}).then(function(t){return t&&e.fromRawComment(t),e})}));n=n.then(function(){return f}),n=n.then(function(){var e=r.map(function(e){var o=e.comment,n=e.resolve;return t.client.crypto().decryptComment(o.comment$,o.envelope,t.client.session.privateKeyPEM).then(function(e){o.fromRawComment(e),n(e),h&&h(o),i.push(o),a()}).catch(function(e){if(_&&_(e,o),!l)return Promise.reject(e)})});return l?null:Promise.all(e)})}return n.then(function(){return o})})},t.prototype.create=function(e){var t=this,o=e.raw,n=e.proofId,r=e.pageNumber,i=void 0===r?1:r,a=e.pin,s=e.mediaTime,u=e.mediaDuration,f=e.parentCommentId,c=e.metadata,l=e.state,d=e.creationToken,y=(0,w.getCommentMentions)(o),m=d||(0,v.generateCreationToken)();return this.client.crypto().encryptComment(o,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(e){var t=e.envelope,o=e.comment$;return{proofId:n,page:f?void 0:i,envelope:t,encryptedComment:o,xy:JSON.stringify({x:a&&"number"==typeof a.x?a.x:null,y:a&&"number"==typeof a.y?a.y:null,x2:a&&"number"==typeof a.x2?a.x2:null,y2:a&&"number"==typeof a.y2?a.y2:null,time:"number"==typeof s?s:null,duration:"number"==typeof u?u:null}),parent:f||void 0,mentions:y.map(function(e){return e.id}).join(","),metadata:c?JSON.stringify(c):"{}",creationToken:m,change:l===h.default.TODO?"1":void 0,done:l===h.default.DONE?"1":void 0}}).then(function(e){return t.client.request("comments.create",e).then(function(e){return(new p.default).fromComment(e.data).fromRawComment(o)})}).catch(function(e){return e&&(e.creationToken=m),Promise.reject(e)})},t}(c.default);t.default=T},function(e,t,o){"use strict";function n(e){var t=""+e,o=r.exec(t);if(!o)return t;var n,i="",a=0,s=0;for(a=o.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:n="&quot;";break;case 38:n="&amp;";break;case 39:n="&#39;";break;case 60:n="&lt;";break;case 62:n="&gt;";break;default:continue}s!==a&&(i+=t.substring(s,a)),s=a+1,i+=n}return s!==a?i+t.substring(s,a):i}/*!
2
2
  * escape-html
3
3
  * Copyright(c) 2012-2013 TJ Holowaychuk
4
4
  * Copyright(c) 2015 Andreas Lubbe
5
5
  * Copyright(c) 2015 Tiancheng "Timothy" Gu
6
6
  * MIT Licensed
7
7
  */
8
- var r=/["'&<>]/;e.exports=o},function(e,t,n){"use strict";function o(){for(var e=(new Date).getTime(),t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#$%^&*()_+-={}[]:\";'<>?,./|\\",n="",o=r;o>0;--o)n+=t[Math.round(Math.random()*(t.length-1))];return n+"-"+e}t.__esModule=!0;var r=32;t.generateCreationToken=o},function(e,t,n){"use strict";function o(e,t){var n=void 0;return function(){n||(n=setTimeout(function(){e(),n=null},t))}}t.__esModule=!0,t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=n(0),u=o(a),f=n(7),c=o(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return s(t,e),t.prototype.uploadAvatar=function(e){var t=this;return(new c.default).readBase64(e).then(function(e){return t.client.request("profile.upload-avatar",{uploadedImage:"data:image/png;base64,"+e})})},t.prototype.changePassword=function(e,t){var n=this,o=this.client.crypto();return Promise.all([o.generatePasswordHash(e),o.generatePasswordHash(t),o.encryptPrivateKey(this.client.session.privateKeyPEM,t)]).then(function(e){var t=e[0],o=e[1],r=e[2];return n.client.request("profile.change-password",{oldPassword:t,newPassword:o,newPrivateKey:r})})},t}(u.default);t.default=l},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(s),u=function(e){function t(){return o(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.check=function(){return this.client.request("sessions.check").then(function(){return null})},t}(a.default);t.default=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(9),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a=n(12)("EventEmitter"),u=function(){function e(){o(this,e),this.handlers={}}return e.prototype.getHandlers=function(e){var t=this,n=[],o=[e];if(-1!==e.indexOf("."))for(var r=e;(r=r.substring(0,r.lastIndexOf("."))).length;)o.push(r+".*");return o.push("*"),o.forEach(function(e){(0,s.default)(t.handlers,e)&&n.push.apply(n,t.handlers[e])}),n},e.prototype.on=function(e,t){if("function"!=typeof t)return void a("Handler is not a function, got "+(void 0===t?"undefined":r(t)));(0,s.default)(this.handlers,e)||(this.handlers[e]=[]),this.handlers[e].push(t)},e.prototype.off=function(e,t){if((0,s.default)(this.handlers,e)){var n=this.handlers[e];n.splice(n.indexOf(t),1)}},e.prototype.addEventListener=function(e,t){return this.on(e,t)},e.prototype.removeEventListener=function(e,t){return this.off(e,t)},e.prototype.emit=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=this.getHandlers(e),r=new Array(o.length);a("Emitting"+(n?" async":"")+' "'+e+'" event ('+(t?"with":"without")+" data) to "+o.length+" handler(s)");var i=Object.freeze({type:e,data:t,timestamp:Date.now()});return o.forEach(function(e,t){try{r[t]=e(i)}catch(e){r[t]=e}}),n?Promise.all(r):r},e}();t.default=u},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t,n){return new Promise(function(o,r){setTimeout(function(){void 0!==n?r(n):o(t)},e)})}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.Preference=t.WorkflowUserState=t.WorkflowUserRole=t.WorkflowStepState=t.ResponseStatus=t.ProofStatus=t.ProofState=t.ImportProvider=t.FileStatus=t.FileAssignee=t.CommentState=void 0;var r=n(15),i=o(r),s=n(78),a=o(s),u=n(5),f=o(u),c=n(23),l=o(c),p=n(18),d=o(p),h=n(19),y=o(h),m=n(8),w=o(m),v=n(26),_=o(v),b=n(79),E=o(b),g=n(25),O=o(g),P=n(80),T=o(P);t.CommentState=i.default,t.FileAssignee=a.default,t.FileStatus=f.default,t.ImportProvider=l.default,t.ProofState=d.default,t.ProofStatus=y.default,t.ResponseStatus=w.default,t.WorkflowStepState=_.default,t.WorkflowUserRole=E.default,t.WorkflowUserState=O.default,t.Preference=T.default},function(e,t,n){"use strict";t.__esModule=!0;var o={PROOF:"proof",ATTACHMENT:"attachment",SNAPSHOT:"snapshot"};t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={REVIEWER:"reviewer",MANDATORY:"mandatory",GATEKEEPER:"gatekeeper",APPROVER:"approver"};t.default=o},function(e,t,n){"use strict";t.__esModule=!0;var o={DEFAULT_DUE_DATE:"dueDate",DEFAULT_MESSAGE_TO_REVIEWERS:"messageToReviewers",ENABLE_COLOR_BLIND_UI:"colorBlind"};t.default=o},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.WorkflowUser=t.WorkflowStep=t.Workflow=t.User=t.Session=t.ProofVersion=t.ProofGroup=t.Proof=t.Pin=t.File=t.Comment=void 0;var r=n(27),i=o(r),s=n(11),a=o(s),u=n(28),f=o(u),c=n(4),l=o(c),p=n(10),d=o(p),h=n(21),y=o(h),m=n(6),w=o(m),v=n(3),_=o(v),b=n(24),E=o(b),g=n(13),O=o(g),P=n(14),T=o(P);t.Comment=i.default,t.File=a.default,t.Pin=f.default,t.Proof=l.default,t.ProofGroup=d.default,t.ProofVersion=y.default,t.Session=w.default,t.User=_.default,t.Workflow=E.default,t.WorkflowStep=O.default,t.WorkflowUser=T.default}])});
8
+ var r=/["'&<>]/;e.exports=n},function(e,t,o){"use strict";function n(){for(var e=(new Date).getTime(),t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#$%^&*()_+-={}[]:\";'<>?,./|\\",o="",n=r;n>0;--n)o+=t[Math.round(Math.random()*(t.length-1))];return o+"-"+e}t.__esModule=!0;var r=32;t.generateCreationToken=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(8),c=n(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.uploadAvatar=function(e){var t=this;return(new c.default).readBase64(e).then(function(e){return t.client.request("profile.upload-avatar",{uploadedImage:"data:image/png;base64,"+e})})},t.prototype.changePassword=function(e,t){var o=this,n=this.client.crypto();return Promise.all([n.generatePasswordHash(e),n.generatePasswordHash(t),n.encryptPrivateKey(this.client.session.privateKeyPEM,t)]).then(function(e){var t=e[0],n=e[1],r=e[2];return o.client.request("profile.change-password",{oldPassword:t,newPassword:n,newPrivateKey:r})})},t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.check=function(){return this.client.request("sessions.check").then(function(){return null})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=o(10),a=function(e){return e&&e.__esModule?e:{default:e}}(i),s=o(13)("EventEmitter"),u=function(){function e(){n(this,e),this.handlers={}}return e.prototype.getHandlers=function(e){var t=this,o=[],n=[e];if(-1!==e.indexOf("."))for(var r=e;(r=r.substring(0,r.lastIndexOf("."))).length;)n.push(r+".*");return n.push("*"),n.forEach(function(e){(0,a.default)(t.handlers,e)&&o.push.apply(o,t.handlers[e])}),o},e.prototype.on=function(e,t){if("function"!=typeof t)return void s("Handler is not a function, got "+(void 0===t?"undefined":r(t)));(0,a.default)(this.handlers,e)||(this.handlers[e]=[]),this.handlers[e].push(t)},e.prototype.off=function(e,t){if((0,a.default)(this.handlers,e)){var o=this.handlers[e];o.splice(o.indexOf(t),1)}},e.prototype.addEventListener=function(e,t){return this.on(e,t)},e.prototype.removeEventListener=function(e,t){return this.off(e,t)},e.prototype.emit=function(e,t){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=this.getHandlers(e),r=new Array(n.length);s("Emitting"+(o?" async":"")+' "'+e+'" event ('+(t?"with":"without")+" data) to "+n.length+" handler(s)");var i=Object.freeze({type:e,data:t,timestamp:Date.now()});return n.forEach(function(e,t){try{r[t]=e(i)}catch(e){r[t]=e}}),o?Promise.all(r):r},e}();t.default=u},function(e,t,o){"use strict";t.__esModule=!0,t.default=function(e,t,o){return new Promise(function(n,r){setTimeout(function(){void 0!==o?r(o):n(t)},e)})}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.Preference=t.FileCategory=t.ProofType=t.WorkflowUserState=t.WorkflowUserRole=t.WorkflowStepState=t.ResponseStatus=t.ProofStatus=t.ProofState=t.ImportProvider=t.FileStatus=t.FileAssignee=t.CommentState=void 0;var r=o(16),i=n(r),a=o(80),s=n(a),u=o(5),f=n(u),c=o(24),l=n(c),p=o(19),d=n(p),h=o(7),y=n(h),m=o(9),w=n(m),v=o(28),_=n(v),b=o(81),E=n(b),g=o(27),O=n(g),P=o(20),I=n(P),T=o(82),R=n(T),S=o(83),k=n(S);t.CommentState=i.default,t.FileAssignee=s.default,t.FileStatus=f.default,t.ImportProvider=l.default,t.ProofState=d.default,t.ProofStatus=y.default,t.ResponseStatus=w.default,t.WorkflowStepState=_.default,t.WorkflowUserRole=E.default,t.WorkflowUserState=O.default,t.ProofType=I.default,t.FileCategory=R.default,t.Preference=k.default},function(e,t,o){"use strict";t.__esModule=!0;var n={PROOF:"proof",ATTACHMENT:"attachment",SNAPSHOT:"snapshot"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={REVIEWER:"reviewer",MANDATORY:"mandatory",GATEKEEPER:"gatekeeper",APPROVER:"approver"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={STATIC:"static",VIDEO:"video",AUDIO:"audio",WEB:"web"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={DEFAULT_DUE_DATE:"dueDate",DEFAULT_MESSAGE_TO_REVIEWERS:"messageToReviewers",ENABLE_COLOR_BLIND_UI:"colorBlind"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.WorkflowUser=t.WorkflowStep=t.Workflow=t.User=t.Session=t.ProofVersion=t.ProofGroup=t.Proof=t.Pin=t.File=t.Comment=void 0;var r=o(29),i=n(r),a=o(12),s=n(a),u=o(30),f=n(u),c=o(4),l=n(c),p=o(11),d=n(p),h=o(22),y=n(h),m=o(6),w=n(m),v=o(3),_=n(v),b=o(26),E=n(b),g=o(14),O=n(g),P=o(15),I=n(P);t.Comment=i.default,t.File=s.default,t.Pin=f.default,t.Proof=l.default,t.ProofGroup=d.default,t.ProofVersion=y.default,t.Session=w.default,t.User=_.default,t.Workflow=E.default,t.WorkflowStep=O.default,t.WorkflowUser=I.default}])});
9
9
  //# sourceMappingURL=pageproof.js.map
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pageproof/sdk-pr",
3
3
  "description": "The official PageProof SDK",
4
- "version": "112.0.1538690321374",
4
+ "version": "116.0.1539574885779",
5
5
  "main": "lib/index.js",
6
6
  "browser": "lib/pageproof.js",
7
7
  "dependencies": {