text: import t from"@babel/runtime/regenerator";import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import a from"@babel/runtime/helpers/defineProperty";import u from"axios";import o from"query-string";export var APIClient=function(){function c(t){r(this,c),a(this,"conf",void 0),a(this,"jwt",""),a(this,"loginPromise",Promise.resolve({})),this.conf="string"==typeof t?{root:t,auth:void 0}:Object.assign({},t)}return n(c,[{key:"waitForLogin",value:function(){var r=e(t.mark(function e(){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.loginPromise);case 1:case"end":return t.stop()}},e,this)}));return function(){return r.apply(this,arguments)}}()},{key:"postCall",value:function(){var r=e(t.mark(function e(r,n,a){var c=this;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.waitForLogin().then(function(){var t=Object.assign({},a);t["Content-Type"]=t["Content-Type"]||"application/x-www-form-urlencoded",c.jwt&&(t.OPENLAW_JWT=c.jwt);var e="string"==typeof n?n:o.stringify(n),s={method:"post",url:c.conf.root+r,data:e,headers:t,auth:void 0};return c.conf.auth&&(s.auth=Object.assign({},c.conf.auth)),new RegExp(/contract\/docx|contract\/pdf/).test(r)&&(s.responseType="blob"),u(s).then(function(t){return t.headers.openlaw_jwt&&(c.jwt=t.headers.openlaw_jwt),t}).catch(function(t){throw t})}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"getCall",value:function(){var r=e(t.mark(function e(r,n,a){var c=this;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.waitForLogin().then(function(){var t=Object.assign({},a),e="";n&&(e="?"+o.stringify(n)),c.jwt&&(t.OPENLAW_JWT=c.jwt);var s={headers:t,auth:void 0};return c.conf.auth&&(s.auth=Object.assign({},c.conf.auth)),new RegExp(/templates\/json|draft\/json|contract\/docx|contract\/pdf|contract\/json/).test(r)&&(s.responseType="blob"),u.get(c.conf.root+r+e,s).then(function(t){return t.headers.openlaw_jwt&&(c.jwt=t.headers.openlaw_jwt),t}).catch(function(t){if(t.data)throw t.data;throw t})}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"login",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.loginPromise=this.postCall("/app/login",{userId:r,password:n}),t.abrupt("return",this.loginPromise);case 2:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"uploadContract",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n={"Content-Type":"text/plain;charset=UTF-8"},t.abrupt("return",this.postCall("/upload/contract",JSON.stringify(r),n).then(function(t){return t.data}));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"uploadDraft",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n={"Content-Type":"text/plain;charset=UTF-8"},t.abrupt("return",this.postCall("/upload/draft",JSON.stringify(r),n).then(function(t){return t.data}));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"uploadFlow",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n={"Content-Type":"text/plain;charset=UTF-8"},t.abrupt("return",this.postCall("/upload/flow",JSON.stringify(r),n).then(function(t){return t.data}));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"uploadContractToGoogle",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n={Origin:"location.hostname","Access-Control-Allow-Origin":"*"},t.abrupt("return",this.getCall("/driveAuthPage/"+r,n));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"sendDraft",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.postCall("/send/draft",{readonlyEmails:r,editEmails:n,id:a}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"prepareSignature",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/prepareSignature/contract/"+r,{fullName:n,accessToken:a}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"getAccessToken",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/token/"+r));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getFlowAccessToken",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/flow/token/"+r).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"generateFlowAccessToken",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.postCall("/flow/updateToken/"+r).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"disableFlowAccessToken",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.postCall("/flow/disableToken/"+r).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"signContract",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/sign/contract/"+r,{fullName:n,accessToken:a}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"loadContractStatus",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/sign/status",{id:r,accessToken:n}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"stopContract",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/stop/"+r));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"resumeContract",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/resume/"+r));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"sendContract",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.postCall("/send/contract",{readonlyEmails:r,editEmails:n,id:a}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"changeEthereumNetwork",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/ethereum/changeEthereumNetwork/"+r));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getCurrentNetwork",value:function(){var r=e(t.mark(function e(){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/network").then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(){return r.apply(this,arguments)}}()},{key:"saveTemplate",value:function(){var r=e(t.mark(function e(r,n){var a;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a={"Content-Type":"text/plain;charset=UTF-8"},t.abrupt("return",this.postCall("/upload/template/"+r,n,a));case 2:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"getTemplateVersions",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/version",{title:r,pageSize:n,page:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"getDraftVersions",value:function(){var r=e(t.mark(function e(r,n,a,u){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/drafts/version",{draftId:r,pageSize:n,page:a,accessToken:u}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n,a){return r.apply(this,arguments)}}()},{key:"getTemplate",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/template/raw/"+r).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getTemplateById",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/template/id/raw/"+r).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getTemplateVersion",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/template/raw/"+r+"/"+n).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"getDraftVersion",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/draft/raw/"+r+"/"+n,{accessToken:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"getContract",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/raw/"+r,{accessToken:n}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"getFlow",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/flow/raw/"+r,{accessToken:n}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"searchUsers",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/users/search",{keyword:r,page:n,pageSize:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"deleteUser",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/users/delete",{userId:r}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"toAdminUser",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/users/toadmin",{userId:r}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"toRestricted",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/users/torestricted",{userId:r}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"toStandardUser",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/users/touser",{userId:r}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"templateSearch",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/search",{keyword:r,page:n,pageSize:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"searchDeletedTemplates",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/searchDeleted",{keyword:r,page:n,pageSize:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"deleteTemplate",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/delete",{name:r}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"restoreTemplate",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/restore",{name:r}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"renameTemplate",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/rename",{name:r,newName:n}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"sendTxHash",value:function(){var r=e(t.mark(function e(r,n,a,u){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/signature/sendTxHash",{contractId:r,network:n,txHash:a,accessToken:u}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n,a){return r.apply(this,arguments)}}()},{key:"sendTxHashForCall",value:function(){var r=e(t.mark(function e(r,n,a,u,o){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/call/sendTxHash",{contractId:r,userAccount:n,smartContractAddress:a,network:u,txHash:o}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n,a,u){return r.apply(this,arguments)}}()},{key:"changeContractAlias",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/alias/"+r,{contractId:r,newName:n}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"changeDraftAlias",value:function(){var r=e(t.mark(function e(r,n){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/draft/alias/"+r,{draftId:r,newName:n}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e){return r.apply(this,arguments)}}()},{key:"searchContracts",value:function(){var r=e(t.mark(function e(r,n,a,u){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contracts/search",{keyword:r,page:n,pageSize:a,sortBy:u}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n,a){return r.apply(this,arguments)}}()},{key:"searchDrafts",value:function(){var r=e(t.mark(function e(r,n,a,u){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/drafts/search",{keyword:r,page:n,pageSize:a,sortBy:u}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n,a){return r.apply(this,arguments)}}()},{key:"searchAddress",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/address/search",{term:r}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getAddressDetails",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/address/details",{placeId:r}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"getStripeAccounts",value:function(){var r=e(t.mark(function e(){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/user/getStripeAccounts").then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(){return r.apply(this,arguments)}}()},{key:"getCommunityActivity",value:function(){var r=e(t.mark(function e(r,n,a){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/recentActivity",{filter:r,page:n,pageSize:a}).then(function(t){return t.data}));case 1:case"end":return t.stop()}},e,this)}));return function(t,e,n){return r.apply(this,arguments)}}()},{key:"downloadAsDocx",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=JSON.stringify(r),t.abrupt("return",this.postCall("/download/contract/docx",{data:n}).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename="(.+)"/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadAsPdf",value:function(){var r=e(t.mark(function e(r){var n;return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=JSON.stringify(r),t.abrupt("return",this.postCall("/download/contract/pdf",{data:n}).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename="(.+)"/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 2:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadTemplateAsJson",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/templates/json/"+r).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename=(.+)/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadDraftAsJson",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/draft/json/"+r).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename=(.+)/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadContractAsDocx",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/docx/"+r).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename="(.+)"/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadContractAsPdf",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/pdf/"+r).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename="(.+)"/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()},{key:"downloadContractAsJson",value:function(){var r=e(t.mark(function e(r){return t.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getCall("/contract/json/"+r).then(function(t){var e=new Blob([t.data],{type:t.data.type}),r=window.URL.createObjectURL(e),n=document.createElement("a");n.href=r;var a=t.headers["content-disposition"],u="unknown";if(a){var o=a.match(/filename=(.+)/);2===o.length&&(u=o[1])}n.setAttribute("download",u),document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(r)}));case 1:case"end":return t.stop()}},e,this)}));return function(t){return r.apply(this,arguments)}}()}]),c}();