@cling-se/widget 0.0.15 → 0.0.16

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.
Files changed (99) hide show
  1. package/dist/{DocFormSend.fab0db95.js → DocFormSend.146e1e16.js} +1 -1
  2. package/dist/{index.da173865.js → index.018bcde0.js} +1 -1
  3. package/dist/{index.002adb3a.js → index.03356fd7.js} +1 -1
  4. package/dist/{index.f8e8515a.js → index.051212c5.js} +1 -1
  5. package/dist/{index.0bd25620.js → index.07e9c76e.js} +1 -1
  6. package/dist/{index.0f3533bd.js → index.08043666.js} +1 -1
  7. package/dist/{index.13a4e089.js → index.081bba10.js} +1 -1
  8. package/dist/{index.4ac6093c.js → index.0ae17dcb.js} +1 -1
  9. package/dist/{index.a8f77d0e.js → index.0c08b3f0.js} +1 -1
  10. package/dist/{index.92f2d18b.js → index.0fada95d.js} +1 -1
  11. package/dist/{index.1607f562.js → index.102c79e8.js} +1 -1
  12. package/dist/{index.30463086.js → index.1202fb34.js} +1 -1
  13. package/dist/{index.74cd1f0a.js → index.1be68b49.js} +1 -1
  14. package/dist/{index.a954036f.js → index.1d79e678.js} +1 -1
  15. package/dist/{index.37a7c40c.js → index.1dc177f3.js} +1 -1
  16. package/dist/{index.0269c226.js → index.247defaa.js} +1 -1
  17. package/dist/{index.3f829d3f.js → index.25a5c48d.js} +1 -1
  18. package/dist/{index.8cccb479.js → index.2823a203.js} +1 -1
  19. package/dist/{index.83730c12.js → index.32afdcf8.js} +1 -1
  20. package/dist/{index.cbf91433.js → index.33d8fe27.js} +1 -1
  21. package/dist/{index.1859ff1c.js → index.37ff495e.js} +1 -1
  22. package/dist/{index.a74f7c69.js → index.383ea1c7.js} +1 -1
  23. package/dist/{index.115440bb.js → index.386c7f0e.js} +1 -1
  24. package/dist/{index.120c24c7.js → index.39a15cc9.js} +1 -1
  25. package/dist/{index.15ea4c94.js → index.40264a45.js} +1 -1
  26. package/dist/{index.ef909fba.js → index.43c4bced.js} +1 -1
  27. package/dist/{index.883aa3a7.js → index.444594b8.js} +1 -1
  28. package/dist/{index.072366fb.js → index.467cc391.js} +1 -1
  29. package/dist/{index.0448cba8.js → index.49f7e34a.js} +1 -1
  30. package/dist/{index.dd81af88.js → index.4b8d1006.js} +1 -1
  31. package/dist/{index.968dec5b.js → index.4f2c402b.js} +1 -1
  32. package/dist/{index.5161945f.js → index.53777c2a.js} +1 -1
  33. package/dist/{index.b8c2f7b3.js → index.5a395ccf.js} +1 -1
  34. package/dist/{index.d718ea89.js → index.5a7cd4bb.js} +2 -2
  35. package/dist/{index.69b6e780.js → index.5c35982d.js} +1 -1
  36. package/dist/{index.4e0ebe32.js → index.5dce3cb1.js} +1 -1
  37. package/dist/{index.bf11228d.js → index.621449aa.js} +1 -1
  38. package/dist/{index.20b360f8.js → index.62f2826e.js} +1 -1
  39. package/dist/{index.fbf57932.js → index.67e5f00c.js} +1 -1
  40. package/dist/{index.6547f272.js → index.687565a7.js} +1 -1
  41. package/dist/{index.89a267e0.js → index.6a36f841.js} +1 -1
  42. package/dist/{index.129d1e89.js → index.6d893672.js} +1 -1
  43. package/dist/{index.0a774335.js → index.732327a4.js} +1 -1
  44. package/dist/{index.24ecf76e.js → index.73e3c460.js} +1 -1
  45. package/dist/{index.37fa365a.js → index.75369c93.js} +1 -1
  46. package/dist/{index.fe63166e.js → index.75d48b3e.js} +1 -1
  47. package/dist/{index.f77cbece.js → index.7697d049.js} +1 -1
  48. package/dist/{index.89c158a3.js → index.76c771a3.js} +1 -1
  49. package/dist/{index.275542ad.js → index.7ba3d22b.js} +1 -1
  50. package/dist/{index.687d00bc.js → index.81a3a9ef.js} +1 -1
  51. package/dist/{index.6668ef12.js → index.82cd9ab9.js} +1 -1
  52. package/dist/{index.a5d19876.js → index.8713a090.js} +1 -1
  53. package/dist/{index.f0a4f485.js → index.90631bc6.js} +1 -1
  54. package/dist/{index.07faa6ae.js → index.96ea8a8b.js} +1 -1
  55. package/dist/{index.ee7579e7.js → index.9abaf586.js} +1 -1
  56. package/dist/{index.36a1e6e8.js → index.9cdbca13.js} +1 -1
  57. package/dist/{index.73796320.js → index.9d42cdd9.js} +2 -2
  58. package/dist/{index.a0f06128.js → index.9fcd4b85.js} +1 -1
  59. package/dist/{index.da128092.js → index.a016cbd3.js} +1 -1
  60. package/dist/{index.9efa3660.js → index.a87914c9.js} +1 -1
  61. package/dist/{index.8ac65cd2.js → index.aa4fa28d.js} +1 -1
  62. package/dist/{index.3ee3b535.js → index.aabb6466.js} +1 -1
  63. package/dist/{index.f7aa6060.js → index.ada9ad3e.js} +1 -1
  64. package/dist/{index.8cefd23c.js → index.aeada667.js} +1 -1
  65. package/dist/{index.86cfbb4c.js → index.b5897528.js} +1 -1
  66. package/dist/{index.88a5805c.js → index.b649dd2c.js} +1 -1
  67. package/dist/{index.eade4ee0.js → index.b67b6727.js} +1 -1
  68. package/dist/{index.05f6f7e3.js → index.b95b65d8.js} +1 -1
  69. package/dist/{index.2f98273b.js → index.ba9f0f1a.js} +1 -1
  70. package/dist/{index.4bcda3c8.js → index.bb7f8a9a.js} +1 -1
  71. package/dist/{index.c75ec2b2.js → index.c1ed79ce.js} +1 -1
  72. package/dist/{index.4a993f7c.js → index.c240ffc3.js} +1 -1
  73. package/dist/{index.515f6834.js → index.c2cbd189.js} +1 -1
  74. package/dist/{index.d46cd762.js → index.c7b41b94.js} +1 -1
  75. package/dist/{index.fca169c1.js → index.ca539b00.js} +1 -1
  76. package/dist/{index.19e0a2ac.js → index.cdaeecb9.js} +1 -1
  77. package/dist/{index.b620efd8.js → index.cf134421.js} +1 -1
  78. package/dist/{index.9dcc3046.js → index.d16f33bd.js} +1 -1
  79. package/dist/{index.e41b148b.js → index.d23735aa.js} +1 -1
  80. package/dist/{index.9d64834c.js → index.d265ad3e.js} +1 -1
  81. package/dist/{index.e7134942.js → index.d270a23f.js} +1 -1
  82. package/dist/{index.c83672f5.js → index.d43cd57e.js} +1 -1
  83. package/dist/{index.117e8ced.js → index.dba55186.js} +1 -1
  84. package/dist/{index.a0020c2c.js → index.df99b2b1.js} +1 -1
  85. package/dist/{index.68828618.js → index.e465269c.js} +1 -1
  86. package/dist/{index.ba7c37b6.js → index.e47037c8.js} +2 -2
  87. package/dist/{index.d08a3824.js → index.e9bf5f85.js} +1 -1
  88. package/dist/{index.83407a97.js → index.ec5059f8.js} +1 -1
  89. package/dist/{index.4f8bfe22.js → index.ed0f159a.js} +1 -1
  90. package/dist/{index.6e07bb5d.js → index.f5017410.js} +1 -1
  91. package/dist/{index.2fcc2a5e.js → index.f5cebd6f.js} +1 -1
  92. package/dist/{index.763325b8.js → index.f71e177a.js} +1 -1
  93. package/dist/{index.94d1683c.js → index.fa32f36a.js} +1 -1
  94. package/dist/{index.aa278a78.js → index.fefc9b20.js} +1 -1
  95. package/dist/{index.4081eb3b.js → index.ffa959b0.js} +1 -1
  96. package/dist/{main.7ec116b8.js → main.4de86d1b.js} +4 -4
  97. package/dist/main.es.js +1 -1
  98. package/dist/main.umd.js +2 -2
  99. package/package.json +1 -1
package/dist/main.umd.js CHANGED
@@ -345,7 +345,7 @@ In order to facilitate your application for deduction, {{company.name}} needs yo
345
345
  `+o+O.join(`,
346
346
  `+o)+`
347
347
  `+P+"}":"{"+O.join(",")+"}",o=P,x}}("",{"":T})}),typeof a.parse!="function"&&(a.parse=(p={"\\":"\\",'"':'"',"/":"/",t:" ",n:`
348
- `,r:"\r",f:"\f",b:"\b"},h={go:function(){l="ok"},firstokey:function(){m=c,l="colon"},okey:function(){m=c,l="colon"},ovalue:function(){l="ocomma"},firstavalue:function(){l="acomma"},avalue:function(){l="acomma"}},v={go:function(){l="ok"},ovalue:function(){l="ocomma"},firstavalue:function(){l="acomma"},avalue:function(){l="acomma"}},g={"{":{go:function(){d.push({state:"ok"}),f={},l="firstokey"},ovalue:function(){d.push({container:f,state:"ocomma",key:m}),f={},l="firstokey"},firstavalue:function(){d.push({container:f,state:"acomma"}),f={},l="firstokey"},avalue:function(){d.push({container:f,state:"acomma"}),f={},l="firstokey"}},"}":{firstokey:function(){var T=d.pop();c=f,f=T.container,m=T.key,l=T.state},ocomma:function(){var T=d.pop();f[m]=c,c=f,f=T.container,m=T.key,l=T.state}},"[":{go:function(){d.push({state:"ok"}),f=[],l="firstavalue"},ovalue:function(){d.push({container:f,state:"ocomma",key:m}),f=[],l="firstavalue"},firstavalue:function(){d.push({container:f,state:"acomma"}),f=[],l="firstavalue"},avalue:function(){d.push({container:f,state:"acomma"}),f=[],l="firstavalue"}},"]":{firstavalue:function(){var T=d.pop();c=f,f=T.container,m=T.key,l=T.state},acomma:function(){var T=d.pop();f.push(c),c=f,f=T.container,m=T.key,l=T.state}},":":{colon:function(){if(Object.hasOwnProperty.call(f,m))throw new SyntaxError("Duplicate key '"+m+'"');l="ovalue"}},",":{ocomma:function(){f[m]=c,l="okey"},acomma:function(){f.push(c),l="avalue"}},true:{go:function(){c=!0,l="ok"},ovalue:function(){c=!0,l="ocomma"},firstavalue:function(){c=!0,l="acomma"},avalue:function(){c=!0,l="acomma"}},false:{go:function(){c=!1,l="ok"},ovalue:function(){c=!1,l="ocomma"},firstavalue:function(){c=!1,l="acomma"},avalue:function(){c=!1,l="acomma"}},null:{go:function(){c=null,l="ok"},ovalue:function(){c=null,l="ocomma"},firstavalue:function(){c=null,l="acomma"},avalue:function(){c=null,l="acomma"}}},function(T,D){var F,M,N=/^[\u0020\t\n\r]*(?:([,:\[\]{}]|true|false|null)|(-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)|"((?:[^\r\n\t\\\"]|\\(?:["\\\/trnfb]|u[0-9a-fA-F]{4}))*)")/;l="go",d=[];try{for(;F=N.exec(T);)F[1]?g[F[1]][l]():F[2]?(c=+F[2],v[l]()):(M=F[3],c=M.replace(/\\(?:u(.{4})|([^u]))/g,function(W,$,E){return $?String.fromCharCode(parseInt($,16)):p[E]}),h[l]()),T=T.slice(F[0].length)}catch(W){l=W}if(l!=="ok"||/[^\u0020\t\n\r]/.test(T))throw l instanceof SyntaxError?l:new SyntaxError("JSON");return typeof D=="function"?function W($,E){var L,x,S=$[E];if(S&&typeof S=="object")for(L in c)Object.prototype.hasOwnProperty.call(S,L)&&((x=W(S,L))!==void 0?S[L]=x:delete S[L]);return D.call($,E,S)}({"":c},""):c}))}},function(r,n,a){function o(i,s,u){if(s.hasOwnProperty&&s.hasOwnProperty("addEventListener")){for(var l=s.addEventListener;l._rollbarOldAdd&&l.belongsToShim;)l=l._rollbarOldAdd;var d=function(c,p,h){l.call(this,c,i.wrap(p),h)};d._rollbarOldAdd=l,d.belongsToShim=u,s.addEventListener=d;for(var f=s.removeEventListener;f._rollbarOldRemove&&f.belongsToShim;)f=f._rollbarOldRemove;var m=function(c,p,h){f.call(this,c,p&&p._rollbar_wrapped||p,h)};m._rollbarOldRemove=f,m.belongsToShim=u,s.removeEventListener=m}}r.exports=function(i,s,u){if(i){var l,d,f="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(l=0;l<f.length;++l)i[d=f[l]]&&i[d].prototype&&o(s,i[d].prototype,u)}}},function(r,n,a){var o=a(0),i=a(5);function s(h,v){return[h,o.stringify(h,v)]}function u(h,v){var g=h.length;return g>2*v?h.slice(0,v).concat(h.slice(g-v)):h}function l(h,v,g){g=g===void 0?30:g;var _,y=h.data.body;if(y.trace_chain)for(var b=y.trace_chain,k=0;k<b.length;k++)_=u(_=b[k].frames,g),b[k].frames=_;else y.trace&&(_=u(_=y.trace.frames,g),y.trace.frames=_);return[h,o.stringify(h,v)]}function d(h,v){return v&&v.length>h?v.slice(0,h-3).concat("..."):v}function f(h,v,g){return[v=i(v,function _(y,b,k){switch(o.typeName(b)){case"string":return d(h,b);case"object":case"array":return i(b,_,k);default:return b}}),o.stringify(v,g)]}function m(h){return h.exception&&(delete h.exception.description,h.exception.message=d(255,h.exception.message)),h.frames=u(h.frames,1),h}function c(h,v){var g=h.data.body;if(g.trace_chain)for(var _=g.trace_chain,y=0;y<_.length;y++)_[y]=m(_[y]);else g.trace&&(g.trace=m(g.trace));return[h,o.stringify(h,v)]}function p(h,v){return o.maxByteSize(h)>v}r.exports={truncate:function(h,v,g){g=g===void 0?524288:g;for(var _,y,b,k=[s,l,f.bind(null,1024),f.bind(null,512),f.bind(null,256),c];_=k.shift();)if(h=(y=_(h,v))[0],(b=y[1]).error||!p(b.value,g))return b;return b},raw:s,truncateFrames:l,truncateStrings:f,maybeTruncateValue:d}}])})})(BV);const J1e=ae(BV.exports),Q1e=Me.rollbar.clientToken,Z1e=new J1e({accessToken:Q1e,captureUncaught:!0,captureUnhandledRejections:!0,source_map_enabled:!0,environment:Me.rollbar.environment||Me.environment,enabled:!1,ignoredMessages:["The operation is insecure","Script error.","null is not an object (evaluating 'localStorage.getItem')","Unexpected token '<'","expected expression, got '<'","ChunkLoadError","Loading chunk","ResizeObserver loop limit exceeded","Failed to update a ServiceWorker for scope","Object Not Found Matching Id","newestWorker is null"],payload:{client:{javascript:{code_version:"0.0.15",source_map_enabled:!0,guess_uncaught_frames:!0}}},transform:t=>{const{trace:e}=t.body;if(e&&e.frames)for(let r=0;r<e.frames.length;r++){const{filename:n}=e.frames[r];n&&(e.frames[r].filename=e.frames[r].filename.replace(Me.baseUrl,"https://dynamichost"))}}}),{UPDATE_VIEW_SETTINGS:Hs,LOAD_USER_POSITION:exe,LOAD_USER:qs,LOGIN_USER:fm,LOGIN_AUTH_TOKEN:YV,AUTH_3RD_PARTY_USER:GV,SWITCH_CONNECTED_USER:KV,LOGOUT_USER:mm,REGISTER_USER:XV,RESET_USER_PASSWORD:JV}=Yl,{DO_LOAD_CURRENT_COMPANY:txe,DO_LOAD_ALL_SETTINGS:rxe,DO_NORMALIZE_COMPANY_USERS:nxe,LOAD_UNREAD_NOTIFICATIONS:axe}=Oe,{SET_USER_LOCATION:ixe,SET_USER:Kt}=It,QV=t=>be.te(`errors:${t}`)&&be.t(`errors:${t}`),oxe={async[qs]({commit:t,getters:e,dispatch:r}){var n,a,o;try{if(!Xe.getItem("token")){Xe.removeItem("tokenExpire"),Xe.removeItem("refreshToken"),t(Kt,{userId:null,companyId:null,crispUserHash:null}),this.$router.push({name:"Login"});return}const[{data:i},{data:s=[]}]=await Promise.all([fr.get("/companyUser/self"),N3.getConnectedUsers()]),{id:u,CompanyId:l,crispUserHash:d,language:f,locale:m}=i;f&&be.i18next.changeLanguage(f),m&&be.l10n.changeLocale(m),await this.dispatch(nxe,{companyUsers:[{...i,connectedUsers:s}]}),t(Kt,{userId:u,companyId:l,crispUserHash:d}),await this.dispatch(txe),await this.dispatch(rxe),this._vm.$cookiePreference!=="all"&&(this._vm.$cookiePreference="all"),this.hasModule("notifications")&&!this.getters["notifications/isFetching"]&&this.dispatch(axe,{throttleTime:5});const{user:c,company:p,isQualified:h}=e;if(c){let v="";(c.firstname||c.lastname)&&(v=c.fullName),Z1e.configure({payload:{person:{id:c.id,username:v||null,email:c.email||null}}}),(n=this.$supportChat)==null||n.syncData(),(a=this.$trackevent)==null||a.call(this,"loadUser",{companyUserId:c.id}),(o=this.$segment)==null||o.identifyCompanyUser()}}catch(i){this.handleError(i,{action:qs,actionPayload:null}),r(mm)}},async[fm]({commit:t,dispatch:e},{email:r,password:n,doRedirect:a=!0,doLoadUser:o=!0,superUserId:i=null,responseType:s=null,code:u=null}){try{t(Kt,{isLoggingIn:!0}),e(Hs,{view:"login",settings:{error:null}});let l;if(i?({data:l}=await fr.post("/auth/employee",{email:r,password:n,CompanyUserId:i}),Xe.setItem("isClingEmployee",!0)):u?({data:l}=await fr.post("/oauth2/token",{code:u,client_id:Me.clientId,grant_type:"authorization_code",brand:this._vm.$brand,...Wf(this._vm.$view)}),l={token:l.access_token,tokenExpires:l.expires_in,refreshToken:l.refresh_token}):{data:l}=await fr.post("/auth/companyUser",{email:r,password:n,response_type:s,...Wf(this._vm.$view)}),s==="code"&&l.code)return t(Kt,{isLoggingIn:!1}),l;const{token:d,tokenExpires:f,refreshToken:m}=l;if(Xe.setItem("token",d),Xe.setItem("tokenExpires",f),Xe.setItem("refreshToken",m),t(Kt,{isLoggingIn:!1}),o&&await e(qs),!a)return!0;const{redirect:c}=this.state.route.query||{};return c?(this.$router.push(c),!0):(this.$router.push({name:"account"}),!0)}catch(l){let d=be.t("errors:fallback"),f=!1;if(l&&typeof l.getPayload=="function"){const m=l.getPayload();m&&m.axios&&m.axios.status===401&&(f=!0)}return f&&(d=be.t("actions:loginUser.wrongCredentials")),e(Hs,{view:"login",settings:{error:d}}),t(Kt,{isLoggingIn:!1}),f||this.handleError(l,{action:fm,actionPayload:null}),!1}},async[YV]({commit:t,dispatch:e},{authToken:r,to:n}){let a={};try{if(!r)throw new Error("Missing param authToken");if(!n)throw new Error("Missing param to");t(Kt,{isLoggingIn:!0}),a=Object.assign({},n.query),delete a.authtoken;const{data:o}=await qpe(r,{...Wf(this._vm.$view)}),{token:i,tokenExpires:s,refreshToken:u}=o;Xe.setItem("token",i),Xe.setItem("tokenExpires",s),Xe.setItem("refreshToken",u),await e(qs),this.$router.push({path:n.path,query:a})}catch(o){const i=n.path;await e(mm,{next:{name:"Login",query:{redirect:i}}}),this.handleError(o,{action:YV,actionPayload:null})}finally{t(Kt,{isLoggingIn:!1})}},async[GV]({commit:t,dispatch:e},{service:r,code:n}){t(Kt,{isLoggingIn:!0});const a={isAuth:!1,isVerify:!1,company:null,companyUser:null,addedToExistingCompanyId:null,error:null};try{const{data:o}=await m1.signupWithCrm(r,{code:n,doLogin:!0,...Wf(this._vm.$view),brand:this._vm.$brand}),{addedToExistingCompanyId:i,authenticate:s}=o,{token:u,tokenExpires:l,refreshToken:d,company:f,companyUser:m}=s;return Xe.setItem("token",u),Xe.setItem("tokenExpires",l),Xe.setItem("refreshToken",d),m&&m.isSlave&&!m.verifiedEmailAt?(a.companyUser=m,a.isVerify=!0,a):(await e(qs),i&&(a.addedToExistingCompanyId=i),a.company=f,a.isAuth=!0,a)}catch(o){return this.handleError(o,{action:GV,actionPayload:null}),{isAuth:!1,isVerify:!1,company:null,companyUser:null,addedToExistingCompanyId:null,error:o.message}}finally{t(Kt,{isLoggingIn:!1})}},async[KV]({commit:t,dispatch:e},{companyUserId:r,doRedirect:n=!0}){try{if(typeof r>"u")throw new Error("Missing param companyUserId");t(Kt,{isLoggingIn:!0});const{data:a}=await N3.getConnectedUserAuth(r),{token:o,tokenExpires:i,refreshToken:s}=a;Xe.setItem("token",o),Xe.setItem("tokenExpires",i),Xe.setItem("refreshToken",s),this.commit("reset"),await e(qs),n?this.$router.push({name:"account"}):window.reloadApp(!0)}catch(a){this.handleError(a,{action:KV,actionPayload:null})}finally{t(Kt,{isLoggingIn:!1})}},async[XV]({commit:t,dispatch:e},{company:r,companyUser:n,termsVersion:a,voucherCode:o=null,source:i=null,region:s,language:u,currency:l,throwIfSlaveUser:d}){var f,m;try{const c={isAuth:!1,isVerify:!1,didNavigate:!1};if(e(Hs,{view:"register",settings:{error:null}}),t(Kt,{isRegistering:!0}),!r)throw new Error("Missing param company");if(!n)throw new Error("Missing param companyUser");if(!a)throw new Error("Missing param termsVersion");const{data:p}=await Bpe({Company:r,CompanyUser:n,voucherCode:o,source:i,region:s,language:u,currency:l,throwIfSlaveUser:d}),{CompanyUser:h}=p,v={type:"terms",version:a,identifier:h.email,object:"CompanyUser",objectId:h.id};if(await Gpe(v),h.isSlave)return c.isVerify=!0,c;const g=await e(fm,{email:n.email,password:n.password,doRedirect:!1});return c.isAuth=g,g&&((f=this.$trackevent)==null||f.call(this,"register")),(m=this.$segment)==null||m.track("Register Documents Viewed",JSON.parse(Xe.getItem("documentsViewed"))||[]),c}catch(c){if(te(c,"payload.code")===4008&&d)throw c;if(c&&c.code){const p=QV(c.code);p&&e(Hs,{view:"register",settings:{error:p}})}return this.handleError(c,{action:XV,actionPayload:null}),{isAuth:!1,isVerify:!1,didNavigate:!1}}finally{t(Kt,{isRegistering:!1})}},async[JV]({commit:t,dispatch:e},{password:r,token:n,doRedirect:a=!0}){try{if(e(Hs,{view:"register",settings:{error:null}}),t(Kt,{isResettingPassword:!0}),!r)throw new Error("Missing param password");if(!n)throw new Error("Missing param token");const{data:o}=await Ype(r,n),{email:i}=o;return await e(fm,{email:i,password:r,doRedirect:a}),!0}catch(o){if(o&&o.code){const i=QV(o.code);i&&e(Hs,{view:"register",settings:{error:i}})}return this.handleError(o,{action:JV,actionPayload:null}),!1}finally{t(Kt,{isResettingPassword:!1})}},[mm]({commit:t},{next:e}={}){try{Xe.removeItem("token"),Xe.removeItem("tokenExpires"),Xe.removeItem("refreshToken"),this.commit("reset")}finally{t(Kt,{isLoggingIn:!1,userId:null,companyId:null,crispUserHash:null})}if(e)try{return this.$router.replace(e)}catch(r){this.handleError(r,{action:mm,actionPayload:null})}return this.$router.replace({name:"Login"})},[exe]({commit:t}){navigator.geolocation.getCurrentPosition(({coords:e})=>{t(ixe,[e.longitude,e.latitude])})}},ux=new Map,{PUSH_MODAL:sxe,POP_MODAL:uxe,SET_CAN_CLOSE_MODAL:lxe,SHOW_MESSAGE:dxe,CLEAR_MESSAGE:cxe,CLEAR_MESSAGE_BY_ID:fxe,MESSAGE_ACTION:ZV,UPDATE_VIEW_SETTINGS:mxe,RESET_VIEW_SETTINGS:pxe,SHOW_ERROR:hxe,RESET_ERROR:vxe}=Yl,gxe={...oxe,[sxe]({commit:t,state:e},r){const n={...r,_uniqueId:Cn.exports()};t(It.SET_MODALS,[...e.modals,n])},[uxe]({commit:t,state:e}){t(It.SET_MODALS,e.modals.slice(0,-1))},[lxe]({commit:t},e){t(It.SET_CAN_CLOSE_MODAL,e)},[dxe]({commit:t,state:e},r){const{type:n,displayType:a="notification",time:o=5e3,title:i,message:s,closeButton:u,omit:l=""}=r,d={},f={};if((p=>{const[h="foo",v="bar"]=p.split(":");return this._vm[h]===v})(l))return;r.actions&&Object.keys(r.actions).forEach(p=>{const h=r.actions[p];if(typeof h=="object"&&!Array.isArray(h)){if(!h.fn&&!h.callback)throw Error(`No callback function provided for action ${p}`);d[p]=h.fn||h.callback,delete h.fn,delete h.callback,f[p]=h}else if(typeof h=="string")d[p]=h,f[p]={};else if(typeof h=="function")d[p]=h,f[p]={};else throw Error(`Action, ${p} , must be one of: object|string|function`)}),t(It.ADD_MESSAGE,{actions:f,title:i,message:s,type:n,displayType:a,time:o,closeButton:u});const c=e.messages.slice(-1)[0];return ux.set(c._uniqueId,d),c._uniqueId},[cxe]({commit:t,state:e},r){const n=e.messages[r]||{};t(It.REMOVE_MESSAGE,r),ux.delete(n._uniqueId)},[fxe]({dispatch:t,state:e},r){const n=e.messages.findIndex(a=>a._uniqueId===r);t(Yl.CLEAR_MESSAGE,n)},[ZV]({state:t,dispatch:e},{index:r,type:n}){try{const a={cancel:()=>e(Yl.CLEAR_MESSAGE,r)},o=t.messages[r]||{};if(!o||!o._uniqueId)throw Error("message not found, failed to trigger action");const i=ux.get(o._uniqueId);if(!i)throw Error("message has no actions, failed to trigger action");const s=i[n];if(!s)throw Error(`message has no action of type ${n}`);let u=s;if(typeof s=="string"&&(u=a[s],!u))throw Error(`No predefined action of type ${s}`);if(typeof u!="function")throw Error("Unable to extract function from message action");return u(o)}catch(a){return this.handleError(a,{action:ZV,actionPayload:arguments[1],retries:0})}},[mxe]({commit:t},{view:e,settings:r}){t(It.SET_VIEW_SETTINGS,{view:e,settings:r})},[pxe]({commit:t}){t(It.RESET_VIEW_SETTINGS)},[hxe]({commit:t},e){t(It.SET_ERROR,e)},[vxe]({commit:t}){t(It.RESET_ERROR)}};function pm(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yxe(t,e){return _xe(t)||bxe(t,e)||wxe(t,e)||xxe()}function _xe(t){if(Array.isArray(t))return t}function bxe(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var i=t[Symbol.iterator](),s;!(n=(s=i.next()).done)&&(r.push(s.value),!(e&&r.length===e));n=!0);}catch(u){a=!0,o=u}finally{try{!n&&i.return!=null&&i.return()}finally{if(a)throw o}}return r}}function wxe(t,e){if(!!t){if(typeof t=="string")return ez(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ez(t,e)}}function ez(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function xxe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
348
+ `,r:"\r",f:"\f",b:"\b"},h={go:function(){l="ok"},firstokey:function(){m=c,l="colon"},okey:function(){m=c,l="colon"},ovalue:function(){l="ocomma"},firstavalue:function(){l="acomma"},avalue:function(){l="acomma"}},v={go:function(){l="ok"},ovalue:function(){l="ocomma"},firstavalue:function(){l="acomma"},avalue:function(){l="acomma"}},g={"{":{go:function(){d.push({state:"ok"}),f={},l="firstokey"},ovalue:function(){d.push({container:f,state:"ocomma",key:m}),f={},l="firstokey"},firstavalue:function(){d.push({container:f,state:"acomma"}),f={},l="firstokey"},avalue:function(){d.push({container:f,state:"acomma"}),f={},l="firstokey"}},"}":{firstokey:function(){var T=d.pop();c=f,f=T.container,m=T.key,l=T.state},ocomma:function(){var T=d.pop();f[m]=c,c=f,f=T.container,m=T.key,l=T.state}},"[":{go:function(){d.push({state:"ok"}),f=[],l="firstavalue"},ovalue:function(){d.push({container:f,state:"ocomma",key:m}),f=[],l="firstavalue"},firstavalue:function(){d.push({container:f,state:"acomma"}),f=[],l="firstavalue"},avalue:function(){d.push({container:f,state:"acomma"}),f=[],l="firstavalue"}},"]":{firstavalue:function(){var T=d.pop();c=f,f=T.container,m=T.key,l=T.state},acomma:function(){var T=d.pop();f.push(c),c=f,f=T.container,m=T.key,l=T.state}},":":{colon:function(){if(Object.hasOwnProperty.call(f,m))throw new SyntaxError("Duplicate key '"+m+'"');l="ovalue"}},",":{ocomma:function(){f[m]=c,l="okey"},acomma:function(){f.push(c),l="avalue"}},true:{go:function(){c=!0,l="ok"},ovalue:function(){c=!0,l="ocomma"},firstavalue:function(){c=!0,l="acomma"},avalue:function(){c=!0,l="acomma"}},false:{go:function(){c=!1,l="ok"},ovalue:function(){c=!1,l="ocomma"},firstavalue:function(){c=!1,l="acomma"},avalue:function(){c=!1,l="acomma"}},null:{go:function(){c=null,l="ok"},ovalue:function(){c=null,l="ocomma"},firstavalue:function(){c=null,l="acomma"},avalue:function(){c=null,l="acomma"}}},function(T,D){var F,M,N=/^[\u0020\t\n\r]*(?:([,:\[\]{}]|true|false|null)|(-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)|"((?:[^\r\n\t\\\"]|\\(?:["\\\/trnfb]|u[0-9a-fA-F]{4}))*)")/;l="go",d=[];try{for(;F=N.exec(T);)F[1]?g[F[1]][l]():F[2]?(c=+F[2],v[l]()):(M=F[3],c=M.replace(/\\(?:u(.{4})|([^u]))/g,function(W,$,E){return $?String.fromCharCode(parseInt($,16)):p[E]}),h[l]()),T=T.slice(F[0].length)}catch(W){l=W}if(l!=="ok"||/[^\u0020\t\n\r]/.test(T))throw l instanceof SyntaxError?l:new SyntaxError("JSON");return typeof D=="function"?function W($,E){var L,x,S=$[E];if(S&&typeof S=="object")for(L in c)Object.prototype.hasOwnProperty.call(S,L)&&((x=W(S,L))!==void 0?S[L]=x:delete S[L]);return D.call($,E,S)}({"":c},""):c}))}},function(r,n,a){function o(i,s,u){if(s.hasOwnProperty&&s.hasOwnProperty("addEventListener")){for(var l=s.addEventListener;l._rollbarOldAdd&&l.belongsToShim;)l=l._rollbarOldAdd;var d=function(c,p,h){l.call(this,c,i.wrap(p),h)};d._rollbarOldAdd=l,d.belongsToShim=u,s.addEventListener=d;for(var f=s.removeEventListener;f._rollbarOldRemove&&f.belongsToShim;)f=f._rollbarOldRemove;var m=function(c,p,h){f.call(this,c,p&&p._rollbar_wrapped||p,h)};m._rollbarOldRemove=f,m.belongsToShim=u,s.removeEventListener=m}}r.exports=function(i,s,u){if(i){var l,d,f="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(l=0;l<f.length;++l)i[d=f[l]]&&i[d].prototype&&o(s,i[d].prototype,u)}}},function(r,n,a){var o=a(0),i=a(5);function s(h,v){return[h,o.stringify(h,v)]}function u(h,v){var g=h.length;return g>2*v?h.slice(0,v).concat(h.slice(g-v)):h}function l(h,v,g){g=g===void 0?30:g;var _,y=h.data.body;if(y.trace_chain)for(var b=y.trace_chain,k=0;k<b.length;k++)_=u(_=b[k].frames,g),b[k].frames=_;else y.trace&&(_=u(_=y.trace.frames,g),y.trace.frames=_);return[h,o.stringify(h,v)]}function d(h,v){return v&&v.length>h?v.slice(0,h-3).concat("..."):v}function f(h,v,g){return[v=i(v,function _(y,b,k){switch(o.typeName(b)){case"string":return d(h,b);case"object":case"array":return i(b,_,k);default:return b}}),o.stringify(v,g)]}function m(h){return h.exception&&(delete h.exception.description,h.exception.message=d(255,h.exception.message)),h.frames=u(h.frames,1),h}function c(h,v){var g=h.data.body;if(g.trace_chain)for(var _=g.trace_chain,y=0;y<_.length;y++)_[y]=m(_[y]);else g.trace&&(g.trace=m(g.trace));return[h,o.stringify(h,v)]}function p(h,v){return o.maxByteSize(h)>v}r.exports={truncate:function(h,v,g){g=g===void 0?524288:g;for(var _,y,b,k=[s,l,f.bind(null,1024),f.bind(null,512),f.bind(null,256),c];_=k.shift();)if(h=(y=_(h,v))[0],(b=y[1]).error||!p(b.value,g))return b;return b},raw:s,truncateFrames:l,truncateStrings:f,maybeTruncateValue:d}}])})})(BV);const J1e=ae(BV.exports),Q1e=Me.rollbar.clientToken,Z1e=new J1e({accessToken:Q1e,captureUncaught:!0,captureUnhandledRejections:!0,source_map_enabled:!0,environment:Me.rollbar.environment||Me.environment,enabled:!1,ignoredMessages:["The operation is insecure","Script error.","null is not an object (evaluating 'localStorage.getItem')","Unexpected token '<'","expected expression, got '<'","ChunkLoadError","Loading chunk","ResizeObserver loop limit exceeded","Failed to update a ServiceWorker for scope","Object Not Found Matching Id","newestWorker is null"],payload:{client:{javascript:{code_version:"0.0.16",source_map_enabled:!0,guess_uncaught_frames:!0}}},transform:t=>{const{trace:e}=t.body;if(e&&e.frames)for(let r=0;r<e.frames.length;r++){const{filename:n}=e.frames[r];n&&(e.frames[r].filename=e.frames[r].filename.replace(Me.baseUrl,"https://dynamichost"))}}}),{UPDATE_VIEW_SETTINGS:Hs,LOAD_USER_POSITION:exe,LOAD_USER:qs,LOGIN_USER:fm,LOGIN_AUTH_TOKEN:YV,AUTH_3RD_PARTY_USER:GV,SWITCH_CONNECTED_USER:KV,LOGOUT_USER:mm,REGISTER_USER:XV,RESET_USER_PASSWORD:JV}=Yl,{DO_LOAD_CURRENT_COMPANY:txe,DO_LOAD_ALL_SETTINGS:rxe,DO_NORMALIZE_COMPANY_USERS:nxe,LOAD_UNREAD_NOTIFICATIONS:axe}=Oe,{SET_USER_LOCATION:ixe,SET_USER:Kt}=It,QV=t=>be.te(`errors:${t}`)&&be.t(`errors:${t}`),oxe={async[qs]({commit:t,getters:e,dispatch:r}){var n,a,o;try{if(!Xe.getItem("token")){Xe.removeItem("tokenExpire"),Xe.removeItem("refreshToken"),t(Kt,{userId:null,companyId:null,crispUserHash:null}),this.$router.push({name:"Login"});return}const[{data:i},{data:s=[]}]=await Promise.all([fr.get("/companyUser/self"),N3.getConnectedUsers()]),{id:u,CompanyId:l,crispUserHash:d,language:f,locale:m}=i;f&&be.i18next.changeLanguage(f),m&&be.l10n.changeLocale(m),await this.dispatch(nxe,{companyUsers:[{...i,connectedUsers:s}]}),t(Kt,{userId:u,companyId:l,crispUserHash:d}),await this.dispatch(txe),await this.dispatch(rxe),this._vm.$cookiePreference!=="all"&&(this._vm.$cookiePreference="all"),this.hasModule("notifications")&&!this.getters["notifications/isFetching"]&&this.dispatch(axe,{throttleTime:5});const{user:c,company:p,isQualified:h}=e;if(c){let v="";(c.firstname||c.lastname)&&(v=c.fullName),Z1e.configure({payload:{person:{id:c.id,username:v||null,email:c.email||null}}}),(n=this.$supportChat)==null||n.syncData(),(a=this.$trackevent)==null||a.call(this,"loadUser",{companyUserId:c.id}),(o=this.$segment)==null||o.identifyCompanyUser()}}catch(i){this.handleError(i,{action:qs,actionPayload:null}),r(mm)}},async[fm]({commit:t,dispatch:e},{email:r,password:n,doRedirect:a=!0,doLoadUser:o=!0,superUserId:i=null,responseType:s=null,code:u=null}){try{t(Kt,{isLoggingIn:!0}),e(Hs,{view:"login",settings:{error:null}});let l;if(i?({data:l}=await fr.post("/auth/employee",{email:r,password:n,CompanyUserId:i}),Xe.setItem("isClingEmployee",!0)):u?({data:l}=await fr.post("/oauth2/token",{code:u,client_id:Me.clientId,grant_type:"authorization_code",brand:this._vm.$brand,...Wf(this._vm.$view)}),l={token:l.access_token,tokenExpires:l.expires_in,refreshToken:l.refresh_token}):{data:l}=await fr.post("/auth/companyUser",{email:r,password:n,response_type:s,...Wf(this._vm.$view)}),s==="code"&&l.code)return t(Kt,{isLoggingIn:!1}),l;const{token:d,tokenExpires:f,refreshToken:m}=l;if(Xe.setItem("token",d),Xe.setItem("tokenExpires",f),Xe.setItem("refreshToken",m),t(Kt,{isLoggingIn:!1}),o&&await e(qs),!a)return!0;const{redirect:c}=this.state.route.query||{};return c?(this.$router.push(c),!0):(this.$router.push({name:"account"}),!0)}catch(l){let d=be.t("errors:fallback"),f=!1;if(l&&typeof l.getPayload=="function"){const m=l.getPayload();m&&m.axios&&m.axios.status===401&&(f=!0)}return f&&(d=be.t("actions:loginUser.wrongCredentials")),e(Hs,{view:"login",settings:{error:d}}),t(Kt,{isLoggingIn:!1}),f||this.handleError(l,{action:fm,actionPayload:null}),!1}},async[YV]({commit:t,dispatch:e},{authToken:r,to:n}){let a={};try{if(!r)throw new Error("Missing param authToken");if(!n)throw new Error("Missing param to");t(Kt,{isLoggingIn:!0}),a=Object.assign({},n.query),delete a.authtoken;const{data:o}=await qpe(r,{...Wf(this._vm.$view)}),{token:i,tokenExpires:s,refreshToken:u}=o;Xe.setItem("token",i),Xe.setItem("tokenExpires",s),Xe.setItem("refreshToken",u),await e(qs),this.$router.push({path:n.path,query:a})}catch(o){const i=n.path;await e(mm,{next:{name:"Login",query:{redirect:i}}}),this.handleError(o,{action:YV,actionPayload:null})}finally{t(Kt,{isLoggingIn:!1})}},async[GV]({commit:t,dispatch:e},{service:r,code:n}){t(Kt,{isLoggingIn:!0});const a={isAuth:!1,isVerify:!1,company:null,companyUser:null,addedToExistingCompanyId:null,error:null};try{const{data:o}=await m1.signupWithCrm(r,{code:n,doLogin:!0,...Wf(this._vm.$view),brand:this._vm.$brand}),{addedToExistingCompanyId:i,authenticate:s}=o,{token:u,tokenExpires:l,refreshToken:d,company:f,companyUser:m}=s;return Xe.setItem("token",u),Xe.setItem("tokenExpires",l),Xe.setItem("refreshToken",d),m&&m.isSlave&&!m.verifiedEmailAt?(a.companyUser=m,a.isVerify=!0,a):(await e(qs),i&&(a.addedToExistingCompanyId=i),a.company=f,a.isAuth=!0,a)}catch(o){return this.handleError(o,{action:GV,actionPayload:null}),{isAuth:!1,isVerify:!1,company:null,companyUser:null,addedToExistingCompanyId:null,error:o.message}}finally{t(Kt,{isLoggingIn:!1})}},async[KV]({commit:t,dispatch:e},{companyUserId:r,doRedirect:n=!0}){try{if(typeof r>"u")throw new Error("Missing param companyUserId");t(Kt,{isLoggingIn:!0});const{data:a}=await N3.getConnectedUserAuth(r),{token:o,tokenExpires:i,refreshToken:s}=a;Xe.setItem("token",o),Xe.setItem("tokenExpires",i),Xe.setItem("refreshToken",s),this.commit("reset"),await e(qs),n?this.$router.push({name:"account"}):window.reloadApp(!0)}catch(a){this.handleError(a,{action:KV,actionPayload:null})}finally{t(Kt,{isLoggingIn:!1})}},async[XV]({commit:t,dispatch:e},{company:r,companyUser:n,termsVersion:a,voucherCode:o=null,source:i=null,region:s,language:u,currency:l,throwIfSlaveUser:d}){var f,m;try{const c={isAuth:!1,isVerify:!1,didNavigate:!1};if(e(Hs,{view:"register",settings:{error:null}}),t(Kt,{isRegistering:!0}),!r)throw new Error("Missing param company");if(!n)throw new Error("Missing param companyUser");if(!a)throw new Error("Missing param termsVersion");const{data:p}=await Bpe({Company:r,CompanyUser:n,voucherCode:o,source:i,region:s,language:u,currency:l,throwIfSlaveUser:d}),{CompanyUser:h}=p,v={type:"terms",version:a,identifier:h.email,object:"CompanyUser",objectId:h.id};if(await Gpe(v),h.isSlave)return c.isVerify=!0,c;const g=await e(fm,{email:n.email,password:n.password,doRedirect:!1});return c.isAuth=g,g&&((f=this.$trackevent)==null||f.call(this,"register")),(m=this.$segment)==null||m.track("Register Documents Viewed",JSON.parse(Xe.getItem("documentsViewed"))||[]),c}catch(c){if(te(c,"payload.code")===4008&&d)throw c;if(c&&c.code){const p=QV(c.code);p&&e(Hs,{view:"register",settings:{error:p}})}return this.handleError(c,{action:XV,actionPayload:null}),{isAuth:!1,isVerify:!1,didNavigate:!1}}finally{t(Kt,{isRegistering:!1})}},async[JV]({commit:t,dispatch:e},{password:r,token:n,doRedirect:a=!0}){try{if(e(Hs,{view:"register",settings:{error:null}}),t(Kt,{isResettingPassword:!0}),!r)throw new Error("Missing param password");if(!n)throw new Error("Missing param token");const{data:o}=await Ype(r,n),{email:i}=o;return await e(fm,{email:i,password:r,doRedirect:a}),!0}catch(o){if(o&&o.code){const i=QV(o.code);i&&e(Hs,{view:"register",settings:{error:i}})}return this.handleError(o,{action:JV,actionPayload:null}),!1}finally{t(Kt,{isResettingPassword:!1})}},[mm]({commit:t},{next:e}={}){try{Xe.removeItem("token"),Xe.removeItem("tokenExpires"),Xe.removeItem("refreshToken"),this.commit("reset")}finally{t(Kt,{isLoggingIn:!1,userId:null,companyId:null,crispUserHash:null})}if(e)try{return this.$router.replace(e)}catch(r){this.handleError(r,{action:mm,actionPayload:null})}return this.$router.replace({name:"Login"})},[exe]({commit:t}){navigator.geolocation.getCurrentPosition(({coords:e})=>{t(ixe,[e.longitude,e.latitude])})}},ux=new Map,{PUSH_MODAL:sxe,POP_MODAL:uxe,SET_CAN_CLOSE_MODAL:lxe,SHOW_MESSAGE:dxe,CLEAR_MESSAGE:cxe,CLEAR_MESSAGE_BY_ID:fxe,MESSAGE_ACTION:ZV,UPDATE_VIEW_SETTINGS:mxe,RESET_VIEW_SETTINGS:pxe,SHOW_ERROR:hxe,RESET_ERROR:vxe}=Yl,gxe={...oxe,[sxe]({commit:t,state:e},r){const n={...r,_uniqueId:Cn.exports()};t(It.SET_MODALS,[...e.modals,n])},[uxe]({commit:t,state:e}){t(It.SET_MODALS,e.modals.slice(0,-1))},[lxe]({commit:t},e){t(It.SET_CAN_CLOSE_MODAL,e)},[dxe]({commit:t,state:e},r){const{type:n,displayType:a="notification",time:o=5e3,title:i,message:s,closeButton:u,omit:l=""}=r,d={},f={};if((p=>{const[h="foo",v="bar"]=p.split(":");return this._vm[h]===v})(l))return;r.actions&&Object.keys(r.actions).forEach(p=>{const h=r.actions[p];if(typeof h=="object"&&!Array.isArray(h)){if(!h.fn&&!h.callback)throw Error(`No callback function provided for action ${p}`);d[p]=h.fn||h.callback,delete h.fn,delete h.callback,f[p]=h}else if(typeof h=="string")d[p]=h,f[p]={};else if(typeof h=="function")d[p]=h,f[p]={};else throw Error(`Action, ${p} , must be one of: object|string|function`)}),t(It.ADD_MESSAGE,{actions:f,title:i,message:s,type:n,displayType:a,time:o,closeButton:u});const c=e.messages.slice(-1)[0];return ux.set(c._uniqueId,d),c._uniqueId},[cxe]({commit:t,state:e},r){const n=e.messages[r]||{};t(It.REMOVE_MESSAGE,r),ux.delete(n._uniqueId)},[fxe]({dispatch:t,state:e},r){const n=e.messages.findIndex(a=>a._uniqueId===r);t(Yl.CLEAR_MESSAGE,n)},[ZV]({state:t,dispatch:e},{index:r,type:n}){try{const a={cancel:()=>e(Yl.CLEAR_MESSAGE,r)},o=t.messages[r]||{};if(!o||!o._uniqueId)throw Error("message not found, failed to trigger action");const i=ux.get(o._uniqueId);if(!i)throw Error("message has no actions, failed to trigger action");const s=i[n];if(!s)throw Error(`message has no action of type ${n}`);let u=s;if(typeof s=="string"&&(u=a[s],!u))throw Error(`No predefined action of type ${s}`);if(typeof u!="function")throw Error("Unable to extract function from message action");return u(o)}catch(a){return this.handleError(a,{action:ZV,actionPayload:arguments[1],retries:0})}},[mxe]({commit:t},{view:e,settings:r}){t(It.SET_VIEW_SETTINGS,{view:e,settings:r})},[pxe]({commit:t}){t(It.RESET_VIEW_SETTINGS)},[hxe]({commit:t},e){t(It.SET_ERROR,e)},[vxe]({commit:t}){t(It.RESET_ERROR)}};function pm(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yxe(t,e){return _xe(t)||bxe(t,e)||wxe(t,e)||xxe()}function _xe(t){if(Array.isArray(t))return t}function bxe(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var i=t[Symbol.iterator](),s;!(n=(s=i.next()).done)&&(r.push(s.value),!(e&&r.length===e));n=!0);}catch(u){a=!0,o=u}finally{try{!n&&i.return!=null&&i.return()}finally{if(a)throw o}}return r}}function wxe(t,e){if(!!t){if(typeof t=="string")return ez(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ez(t,e)}}function ez(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function xxe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
349
349
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tz(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return t.reduce(function(e,r){var n=r.split(".").slice(-1)[0];if(e[n])throw new Error("The key `".concat(n,"` is already in use."));return e[n]=r,e},{})}function kxe(t){return Object.keys(t).map(function(e){return[e,t[e]]})}function hm(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=typeof r[0]=="string"?[].concat(r):[""].concat(r),o=yxe(a,4),i=o[0],s=o[1],u=o[2],l=o[3];return i.length&&i.charAt(i.length-1)!=="/"&&(i+="/"),u="".concat(i).concat(u||"getField"),l="".concat(i).concat(l||"updateField"),t(i,s,u,l)}}function vm(t){return function(e){return e.split(/[.[\]]+/).reduce(function(r,n){return r[n]},t)}}function Gl(t,e){var r=e.path,n=e.value;r.split(/[.[\]]+/).reduce(function(a,o,i,s){return s.length===i+1&&(a[o]=n),a[o]},t)}var Pxe=hm(function(t,e,r,n){var a=Array.isArray(e)?tz(e):e;return Object.keys(a).reduce(function(o,i){var s=a[i],u={get:function(){return this.$store.getters[r](s)},set:function(d){this.$store.commit(n,{path:s,value:d})}};return o[i]=u,o},{})}),Txe=hm(function(t,e,r,n){var a=Array.isArray(e)?tz(e):e;return Object.keys(a).reduce(function(o,i){var s=a[i];return o[i]={get:function(){var l=this.$store,d=kxe(l.getters[r](s));return d.map(function(f){return Object.keys(f[1]).reduce(function(m,c){var p="".concat(s,"[").concat(f[0],"].").concat(c);return Object.defineProperty(m,c,{get:function(){return l.getters[r](p)},set:function(v){l.commit(n,{path:p,value:v})}})},{})})}},o},{})}),rz=function(e){var r,n=e.getterType,a=e.mutationType;return r={},pm(r,n,vm),pm(r,a,Gl),pm(r,"mapFields",hm(function(o,i){return Pxe(o,i,n,a)})),pm(r,"mapMultiRowFields",hm(function(o,i){return Txe(o,i,n,a)})),r};const{SET_USER_LOCATION:Mxe,SET_USER:Sxe}=It,Oxe={...{[Mxe](t,e){t.user.position=e},[Sxe](t,e){Object.keys(e).forEach(r=>{t.user[r]=e[r]})}},updateField:Gl,[It.SET_MODALS](t,e){ce.set(t,"modals",e)},[It.SET_CAN_CLOSE_MODAL](t,e){ce.set(t,"canCloseModal",e)},[It.ADD_MESSAGE](t,e){t.messages.push(Ts(e))},[It.REMOVE_MESSAGE](t,e){ce.delete(t.messages,e)},[It.SET_VIEW_SETTINGS](t,{view:e,settings:r}){Object.keys(r).forEach(n=>{ce.set(t.viewSettings[e],n,r[n])})},[It.RESET_VIEW_SETTINGS](t,e){ce.set(t.viewSettings,e,JSON.parse(SV.viewSettings[e]))},[It.SET_ERROR](t,e){t.error=e},[It.RESET_ERROR](t){t.error=null},[It.SET_SOCKET_CONNECTED](t,e){t.isSocketConnected=e}};var lx={exports:{}},Exe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function dx(t){this.message=t}dx.prototype=new Error,dx.prototype.name="InvalidCharacterError";function Dxe(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new dx("'atob' failed: The string to be decoded is not correctly encoded.");for(var r=0,n,a,o=0,i="";a=e.charAt(o++);~a&&(n=r%4?n*64+a:a,r++%4)?i+=String.fromCharCode(255&n>>(-2*r&6)):0)a=Exe.indexOf(a);return i}var Cxe=typeof window<"u"&&window.atob&&window.atob.bind(window)||Dxe,nz=Cxe;function $xe(t){return decodeURIComponent(nz(t).replace(/(.)/g,function(e,r){var n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}var Axe=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return $xe(e)}catch{return nz(e)}},Rxe=Axe;function Kl(t){this.message=t}Kl.prototype=new Error,Kl.prototype.name="InvalidTokenError",lx.exports=function(t,e){if(typeof t!="string")throw new Kl("Invalid token specified");e=e||{};var r=e.header===!0?0:1;try{return JSON.parse(Rxe(t.split(".")[r]))}catch(n){throw new Kl("Invalid token specified: "+n.message)}},lx.exports.InvalidTokenError=Kl;const Jb=class{init({store:e}){this.store=e}getValidFeatures(){return Object.keys(Jb.schema)}_isValidAccountType(e){if(!e||ot(e)!=="array")throw new Error("Invalid param accountTypes");const{accountType:r}=this.store.getters["application/companyAccount"]||{};return e.includes(r)}_isValidFeatureKey(e){if(!e||ot(e)!=="string")throw new Error("Invalid param featureKey");const{CompanyFeatures:r}=this.store.getters["application/company"]||{};return r?r[e]:!1}_isValidCompanySetting(e){if(!e||ot(e)!=="string")throw new Error("Invalid param settingKey");return e.split("||").some(n=>{const a=this.store.getters["settings/getCompanySetting"](n);return typeof a=="boolean"&&a})}_isValidCompanyUserSettingFn({name:e,fn:r}){if(!e||ot(e)!=="string")throw new Error("Invalid param name");if(!r||ot(r)!=="function")throw new Error("Invalid param fn");const n=this.store.getters["settings/getCompanyUserSetting"](e);return!!r(n)}_isValidRegion(e){if(!e||ot(e)!=="string")throw new Error("Invalid param requiredRegion");const{region:r}=this.store.getters["application/company"]||{};return r?e===r:!1}_isValidBrand(e){if(!e||ot(e)!=="string")throw new Error("Invalid param requiredBrand");const r=this.store.$brand;return r?e===r:!1}_isCreatedBefore(e){if(!e||ot(e)!=="string")throw new Error("Invalid param feature dateString");const{createdAt:r}=this.store.getters["application/company"]||{};return r?Que(r,e):!1}_evaluateFeature(e,{returnType:r="boolean"}={}){const n=Jb.schema[e];if(!n||ot(n)!=="object")throw Error(`No rules for feature '${e}' has been defined!`);if(!["boolean","array"].includes(r))throw Error("Invalid param returnType");const a=[];return n.accountTypes&&!this._isValidAccountType(n.accountTypes)&&(a.push("accountTypes"),r==="boolean")||n.featureKey&&!this._isValidFeatureKey(n.featureKey)&&(a.push("featureKey"),r==="boolean")||n.companySetting&&!this._isValidCompanySetting(n.companySetting)&&(a.push("companySetting"),r==="boolean")||n.companyUserSettingFn&&!this._isValidCompanyUserSettingFn(n.companyUserSettingFn)&&(a.push("companyUserSettingFn"),r==="boolean")||n.region&&!this._isValidRegion(n.region)&&(a.push("region"),r==="boolean")||n.brand&&!this._isValidBrand(n.brand)&&(a.push("brand"),r==="boolean")||n.createdBefore&&!this._isCreatedBefore(n.createdBefore)&&(a.push("preDynDoc2"),r==="boolean")?!1:r==="array"?a:!0}checkFeature(e){return this._evaluateFeature(e)}checkFeatureUpgrade(e){const r=this._evaluateFeature(e,{returnType:"array"});return r.length===1&&r.includes("accountTypes")}};let gm=Jb;Ut(gm,"schema",{personalMessage:{},unlimitedCertificates:{},companyAboutUs:{},winProfile:{},templates:{},invoice:{featureKey:"invoice"},sellInvoice:{featureKey:"sellInvoice"},timeTrack:{featureKey:"timeTrack"},task:{featureKey:"task"},reverseVat:{featureKey:"reverseVat"},ataSetting:{featureKey:"ataSetting"},propertyDesignation:{companySetting:"showRot||showGreenRot"},openAccConstruction:{featureKey:"openAccConstruction"},docChapterIsBinding:{companySetting:"showIsBinding"},projectSettingHideAllArticles:{companySetting:"allowHideAllArticles"},docAtaDateDelay:{companySetting:"docAtaShowDateDelay"},docAtaNotIncluded:{companySetting:"docAtaShowNotIncluded"},docAtaPayment:{companySetting:"docAtaShowPayment"},sms:{featureKey:"sms"},smsSenderName:{featureKey:"smsSenderName"},regionSE:{region:"SE"},bankId:{region:"SE",companySetting:"enableBankId"},templateGallery:{companyUserSettingFn:{name:"defaultLanguage",fn:e=>e==="sv"}},clientReview:{brand:"cling"},upgradeSignatureBankId:{companySetting:"upgradeSignatureBankId"},preDynDoc2:{createdBefore:"2020-11-05T00:00:00.000Z"},emailDomain:{featureKey:"emailDomain"},subdomain:{featureKey:"subdomain"},stats:{featureKey:"stats"},api:{featureKey:"api"},fortnox:{featureKey:"fortnox"},inviteCreators:{accountTypes:["base","pro"]}});const Un=new gm,Va=class{init({store:e}){this.store=e}_getObjectById(e,r){const n=(Va.schema[r]||{}).$module,{data:a}=this.store.state[n]||{};if(!a)throw Error(`No module for ${r} has been defined!`);return a[e]}_getIdPath(e){return(Va.schema[e]||{}).$id}_getAllowNullOwner(e){return!!(Va.schema[e]||{}).$allowNullOwner}_getScopeKey(e){return(Va.schema[e]||{}).$scopeKey}_getUserId(){const{user:e={}}=this.store.state.application;return e.userId}getValidScopes(){return Object.keys(Va.schema)}getRequiredCompanyUserPermission(e,r){const n=Va.schema[e];return!n||!n[r]?[]:Array.isArray(n[r])?n[r]:[n[r]]}hasFeature(e){const r=Va.featureSchema[e];return r?Un.checkFeature(r):!0}checkPermission(e,r,n=void 0){const{getters:a}=this.store,{CompanyUserPermission:o}=a["application/user"]||{};if(!o||!this.hasFeature(e))return!1;let s=this.getRequiredCompanyUserPermission(e,r);if(!s||s.length===0)return console.warn(`Permission ${r} in scope ${e} has not been implemented`),!1;let u=s.some(d=>o[d]===!0);if(u)return!0;if(!n)return!1;const l=this._getScopeKey(e);if(s=s.map(d=>d.includes("Own")?d:d.replace(`${l[0].toUpperCase()}${l.slice(1)}`,`Own${l[0].toUpperCase()}${l.slice(1)}`)),u=s.some(d=>o[d]===!0),u){const d=this._getObjectById(n,e);if(!d)return!1;if(e==="documents")return this.checkPermission("projects",r,d.projectId);const f=cpe(d,this._getIdPath(e)),m=this._getAllowNullOwner(e);return f===this._getUserId()||m&&f===null}return!1}getScope(e={}){return this.getValidScopes().find(a=>e[a])}};let Xl=Va;Ut(Xl,"schema",{projects:{read:"manageProjects",modify:"manageProjects",create:["manageProjects","manageOwnProjects"],delete:"manageProjects",readPrice:["manageProjects","showPrices"],$scopeKey:"projects",$module:"projects",$id:"CompanyUserId"},users:{modify:"manageUsers",create:"manageUsers",$scopeKey:"users",$module:"companyUsers",$id:"id"},documents:{create:["manageProjects","manageOwnProjects"],read:"manageProjects",modify:"manageProjects",delete:"manageProjects",readPrice:["manageProjects","showPrices"],$scopeKey:"projects",$module:"documents2",$id:"companyUserId"},atas:{create:["manageAtas","manageOwnAtas"],read:"manageAtas",modify:"manageAtas",delete:"manageAtas",readPrice:["manageAtas","showPrices"],$scopeKey:"atas",$module:"documents",$id:"data.CompanyUserId"},company:{create:"manageCompany",read:"manageCompany",modify:"manageCompany",$scopeKey:"company",$module:"companies",$id:"id"},articles:{create:["manageProjects","manageOwnProjects"],modify:["manageProjects","manageOwnProjects"],delete:["manageProjects","manageOwnProjects"],readPrice:["manageOwnAtas","manageAtas","manageProjects","manageOwnProjects","showPrices"],$scopeKey:"projects",$module:"articles",$id:"id"},invoices:{read:["readInvoices","readOwnInvoices"],modify:"modifyInvoices",create:"createInvoices",delete:"deleteInvoices",attest:"attestInvoices",$scopeKey:"invoices",$module:"invoices",$id:"CompanyUserId"},bookkeeping:{modify:"modifyBookkeepingSettings",export:"exportInvoices"},prices:{read:"showPrices"},timeTracks:{read:["readTimeTracks","readOwnTimeTracks"],modify:"modifyTimeTracks",create:"createTimeTracks",delete:["deleteTimeTracks","deleteOwnTimeTracks"],attest:"attestTimeTracks",$scopeKey:"timeTracks",$module:"timeTracks",$id:"CompanyUserId"},templates:{create:"createTemplates",read:"readTemplates",modify:"modifyTemplates",delete:"deleteTemplates"},endCustomers:{read:["readEndCustomers","readOwnEndCustomers"],modify:"modifyEndCustomers",create:"createEndCustomers",delete:"deleteEndCustomers",$scopeKey:"endCustomers",$module:"endCustomers",$id:"CompanyUserId",$allowNullOwner:!0},fortnox:{export:"modifyBookkeepingSettings"}}),Ut(Xl,"featureSchema",{invoices:"invoice",bookkeeping:"invoice",timeTracks:"timeTrack"});const lo=new Xl,Ixe={...{userPosition:t=>t.user.position,isLoggingIn:t=>t.user.isLoggingIn,isSuperUser:()=>()=>{const t=Xe.getItem("token");if(!t)return!1;const{employee:e}=lx.exports(t);return!!e},isRegistering:t=>t.user.isRegistering,isResettingPassword:t=>t.user.isResettingPassword,crispUserHash:t=>t.user.crispUserHash,isUserLoaded:({user:t})=>t.userId&&t.companyId&&!0||!1,company:({user:t},e,r,n)=>n["companies/companyById"](t.companyId),companyAccount:({user:t},e,r,n)=>(n["companies/companyById"](t.companyId)||{}).CompanyAccount||null,companyAccountType:(t,e)=>(e.companyAccount||{}).accountType||null,companyRegion:(t,e)=>(e.company||{}).region||(Me.brand==="docspo"?"US":"SE"),subscription:(t,e)=>{const{companyAccount:r={}}=e;if(!r)return{};const{freePremiumDays:n=null,accountType:a=null,maxProjectManagers:o=null,freeDocumentsLeft:i=null,paymentMethod:s,billingCycleInterval:u,billingCycleCount:l,showCalloutConvertStripe:d,hasExceededQuota:f,StripeSubscriptions:m,mrr:c,hasFailedPayments:p,allowFailedPaymentToConvertStripe:h}=r,v=[...new Set([...m.map(b=>b.status)])],g=m.some(b=>(b.stripeItems||[]).some(k=>k.stripePriceStripeId.startsWith("plan_"))),_=X0.includes(a)&&d&&s==="invoice"&&te(r,"documentQuota.newCount")===1e3&&!te(r,"premiumEndAt");return{type:a,trialDaysLeft:n,maxProjectManagers:o,freeDocumentsLeft:i,paymentMethod:s,billingCycleInterval:u,billingCycleCount:l,showCalloutConvertStripe:X0.includes(a)&&d&&s==="invoice",stripeStatuses:v,isPaying:X0.includes(a),hasExceededQuota:f,isStripeLegacy:g,isInvoiceLegacy:_,mrr:c,hasFailedPayments:p,allowFailedPaymentToConvertStripe:h}},user:({user:t},e,r,n)=>n["companyUsers/referenceById"](t.userId),isQualified:(t,{user:e,companyAccount:r})=>!r||!e||typeof e.isQualified!="boolean"?!0:e.isQualified||!["free","trial","premiumTrial"].includes(r.accountType),feature:()=>Un.checkFeature.bind(Un),can:()=>lo.checkPermission.bind(lo)},getField:vm,modals:t=>t.modals,messages:t=>t.messages,isIncVat:t=>t.priceInputVat==="incVat",viewSettings:t=>e=>t.viewSettings[e],showSearch:t=>t.viewSettings.search.show,error:t=>t.error,isSocketConnected:t=>t.isSocketConnected},Nxe={namespaced:!0,state:SV,getters:Ixe,actions:gxe,mutations:Oxe},Lxe={data:{},ids:[],isFetching:!1,isPosting:!1},De={application:It,projects:Fr,forms:zn,files:ix,settings:UV,certificates:E1e,companies:rx,companyReferences:C1e,companyReferenceItems:A1e,documents2:ax,invoices:z1e,timeTracks:H1e,templates:sx,publicDocuments:B1e,documentTerms:G1e,notifications:N1e,unitTypes:X1e,CLEAR_FORM:"CLEAR_FORM",DELETE_ARTICLE:"DELETE_ARTICLE",DELETE_COMPANY_USER:"DELETE_COMPANY_USER",DELETE_CONTRACT:"DELETE_CONTRACT",DELETE_ENDCUSTOMER:"DELETE_ENDCUSTOMER",DELETE_PROJECT:"DELETE_PROJECT",DELETE_PROJECT_FILE:"DELETE_PROJECT_FILE",DELETE_TEMPLATE_MESSAGE:"DELETE_TEMPLATE_MESSAGE",SET_ARTICLES:"SET_ARTICLES",SET_ATAS:"SET_ATAS",SET_COMPANY_USERS:"SET_COMPANY_USERS",SET_CONTRACTS:"SET_CONTRACTS",SET_ENDCUSTOMERS:"SET_ENDCUSTOMERS",SET_FORM:"SET_FORM",SET_NOTIFICATIONS:"SET_NOTIFICATIONS",SET_OFFERS:"SET_OFFERS",SET_PROJECTS:"SET_PROJECTS",SET_PROJECT_FILES:"SET_PROJECT_FILES",UPDATE_COMPANY:"UPDATE_COMPANY"};function az(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function iz(t,e,r){return e&&az(t.prototype,e),r&&az(t,r),t}function Hn(){return Hn=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Hn.apply(this,arguments)}function cx(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function Jl(t){return!!(t&&typeof t.hasOwnProperty=="function"&&(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))}function oz(t,e,r){return Object.keys(t).reduce(function(n,a){var o=""+a;return n.has(o)?n.set(o,r(n.get(o),t[o])):n},e)}var Wxe=function(e){return function(r){return Jl(r)?r.get(e):r[e]}},Fxe=function(){function t(r,n,a){if(n===void 0&&(n={}),a===void 0&&(a={}),!r||typeof r!="string")throw new Error("Expected a string key for Entity, but found "+r+".");var o=a,i=o.idAttribute,s=i===void 0?"id":i,u=o.mergeStrategy,l=u===void 0?function(p,h){return Hn({},p,h)}:u,d=o.processStrategy,f=d===void 0?function(p){return Hn({},p)}:d,m=o.fallbackStrategy,c=m===void 0?function(p,h){}:m;this._key=r,this._getId=typeof s=="function"?s:Wxe(s),this._idAttribute=s,this._mergeStrategy=l,this._processStrategy=f,this._fallbackStrategy=c,this.define(n)}var e=t.prototype;return e.define=function(n){this.schema=Object.keys(n).reduce(function(a,o){var i,s=n[o];return Hn({},a,(i={},i[o]=s,i))},this.schema||{})},e.getId=function(n,a,o){return this._getId(n,a,o)},e.merge=function(n,a){return this._mergeStrategy(n,a)},e.fallback=function(n,a){return this._fallbackStrategy(n,a)},e.normalize=function(n,a,o,i,s,u){var l=this,d=this.getId(n,a,o),f=this.key;if(f in u||(u[f]={}),d in u[f]||(u[f][d]=[]),u[f][d].some(function(c){return c===n}))return d;u[f][d].push(n);var m=this._processStrategy(n,a,o);return Object.keys(this.schema).forEach(function(c){if(m.hasOwnProperty(c)&&typeof m[c]=="object"){var p=l.schema[c],h=typeof p=="function"?p(n):p;m[c]=i(m[c],m,c,h,s,u)}}),s(this,m,n,a,o),d},e.denormalize=function(n,a){var o=this;return Jl(n)?oz(this.schema,n,a):(Object.keys(this.schema).forEach(function(i){if(n.hasOwnProperty(i)){var s=o.schema[i];n[i]=a(n[i],s)}}),n)},iz(t,[{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),t}(),fx=function(){function t(r,n){n&&(this._schemaAttribute=typeof n=="string"?function(a){return a[n]}:n),this.define(r)}var e=t.prototype;return e.define=function(n){this.schema=n},e.getSchemaAttribute=function(n,a,o){return!this.isSingleSchema&&this._schemaAttribute(n,a,o)},e.inferSchema=function(n,a,o){if(this.isSingleSchema)return this.schema;var i=this.getSchemaAttribute(n,a,o);return this.schema[i]},e.normalizeValue=function(n,a,o,i,s,u){var l=this.inferSchema(n,a,o);if(!l)return n;var d=i(n,a,o,l,s,u);return this.isSingleSchema||d===void 0||d===null?d:{id:d,schema:this.getSchemaAttribute(n,a,o)}},e.denormalizeValue=function(n,a){var o=Jl(n)?n.get("schema"):n.schema;if(!this.isSingleSchema&&!o)return n;var i=this.isSingleSchema?void 0:Jl(n)?n.get("id"):n.id,s=this.isSingleSchema?this.schema:this.schema[o];return a(i||n,s)},iz(t,[{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),t}(),jxe=function(t){cx(e,t);function e(n,a){if(!a)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return t.call(this,n,a)||this}var r=e.prototype;return r.normalize=function(a,o,i,s,u,l){return this.normalizeValue(a,o,i,s,u,l)},r.denormalize=function(a,o){return this.denormalizeValue(a,o)},e}(fx),Vxe=function(t){cx(e,t);function e(){return t.apply(this,arguments)||this}var r=e.prototype;return r.normalize=function(a,o,i,s,u,l){var d=this;return Object.keys(a).reduce(function(f,m,c){var p,h=a[m];return h!=null?Hn({},f,(p={},p[m]=d.normalizeValue(h,a,m,s,u,l),p)):f},{})},r.denormalize=function(a,o){var i=this;return Object.keys(a).reduce(function(s,u){var l,d=a[u];return Hn({},s,(l={},l[u]=i.denormalizeValue(d,o),l))},{})},e}(fx),zxe=function(e){var r=Array.isArray(e);if(r&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},sz=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(r){return e[r]})},Uxe=function(e,r,n,a,o,i,s){e=zxe(e);var u=sz(r);return u.map(function(l,d){return o(l,n,a,e,i,s)})},Hxe=function(t){cx(e,t);function e(){return t.apply(this,arguments)||this}var r=e.prototype;return r.normalize=function(a,o,i,s,u,l){var d=this,f=sz(a);return f.map(function(m,c){return d.normalizeValue(m,o,i,s,u,l)}).filter(function(m){return m!=null})},r.denormalize=function(a,o){var i=this;return a&&a.map?a.map(function(s){return i.denormalizeValue(s,o)}):a},e}(fx),uz=function(e,r,n,a,o,i,s){var u=Hn({},r);return Object.keys(e).forEach(function(l){var d=e[l],f=typeof d=="function"?d(r):d,m=o(r[l],r,l,f,i,s);m==null?delete u[l]:u[l]=m}),u},qxe=function(e,r,n){if(Jl(r))return oz(e,r,n);var a=Hn({},r);return Object.keys(e).forEach(function(o){a[o]!=null&&(a[o]=n(a[o],e[o]))}),a},Bxe=function(){function t(r){this.define(r)}var e=t.prototype;return e.define=function(n){this.schema=Object.keys(n).reduce(function(a,o){var i,s=n[o];return Hn({},a,(i={},i[o]=s,i))},this.schema||{})},e.normalize=function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return uz.apply(void 0,[this.schema].concat(a))},e.denormalize=function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return qxe.apply(void 0,[this.schema].concat(a))},t}(),Yxe=function t(e,r,n,a,o,i){if(typeof e!="object"||!e)return e;if(typeof a=="object"&&(!a.normalize||typeof a.normalize!="function")){var s=Array.isArray(a)?Uxe:uz;return s(a,e,r,n,t,o,i)}return a.normalize(e,r,n,t,o,i)},Gxe=function(e){return function(r,n,a,o,i){var s=r.key,u=r.getId(a,o,i);s in e||(e[s]={});var l=e[s][u];l?e[s][u]=r.merge(l,n):e[s][u]=n}},Se={Array:Hxe,Entity:Fxe,Object:Bxe,Union:jxe,Values:Vxe},lz=function(e,r){if(!e||typeof e!="object")throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+(e===null?"null":typeof e)+'".');var n={},a=Gxe(n),o={},i=Yxe(e,e,null,r,a,o);return{entities:n,result:i}};const Bs=new Se.Entity("files");new Se.Array(Bs);const dz=new Se.Entity("projectFiles",{File:Bs});new Se.Array(dz);const mx=new Se.Entity("companyUsers");new Se.Array(mx);const px=new Se.Entity("offers",{Files:[Bs]});new Se.Array(px);const cz=new Se.Entity("atas",{Files:[Bs]});new Se.Array(cz);const hx=new Se.Entity("projects",{CompanyUser:mx,ProjectMembers:[mx],ProjectFiles:[dz]});cz.define({Project:hx});const Kxe=new Se.Array(hx),Xxe=new Se.Entity("articles");new Se.Array(Xxe);const fz=new Se.Entity("certificates");new Se.Array(fz);const Jxe=new Se.Entity("companies",{CompanyCertificates:[fz]}),Qxe=new Se.Array(Jxe),mz=new Se.Entity("companyReferenceItems",{Image:Bs,Thumbnail:Bs});new Se.Array(mz);const Zxe=new Se.Entity("companyReferences",{CompanyReferenceItems:[mz]});new Se.Array(Zxe);const pz=new Se.Entity("contracts",{Offer:px});new Se.Array(pz),px.define({Contract:pz}),new Se.Entity("endCustomers");const eke=new Se.Entity("notifications",{Project:hx});new Se.Array(eke);const tke=new Se.Entity("propertyDesignations");new Se.Array(tke);const rke=new Se.Entity("templateMessages");new Se.Array(rke);const Ql="companies",{LOAD_FILE:Apt,FORM_RESET_OLD:hz}=Oe,{SET_FORM:vx}=De.forms,{DO_LOAD_CURRENT_COMPANY:ym,DO_NORMALIZE_COMPANIES:vz,DO_UPDATE_CURRENT_COMPANY:gz,FORM_EDIT_COMPANY:nke,FORM_SUBMIT_COMPANY:yz,FORM_NEW_COMPANY_BRANDING:_z,FORM_EDIT_COMPANY_BRANDING:gx,FORM_SUBMIT_COMPANY_BRANDING:bz,UPDATE_COMPANY_ACCOUNT_TYPE:wz}=IV,{SET_COMPANIES_FETCHING:yx,SET_COMPANIES_POSTING:wa}=rx,ake={async[vz](t,{companies:e=[]}){if(!e||!Array.isArray(e)||!e.length)throw new Error("Missing param companies");await this.dispatch(uo,{data:e,schema:Qxe})},async[ym]({commit:t,dispatch:e}){var r;try{t(yx,!0);const{data:n}=await fr.get("/company");return await e(vz,{companies:[n]}),await((r=this.$supportChat)==null?void 0:r.syncData()),t(yx,!1),n}catch(n){throw t(yx,!1),n}},async[gz]({dispatch:t,commit:e},{body:r}){try{e(wa,!0),await fr.put("/company",r);const n=await t(ym);return e(wa,!1),n}catch(n){throw e(wa,!1),n}},async[wz]({dispatch:t,commit:e},{accountType:r,billingCycleCost:n,billingCycleInterval:a,billingCycleCount:o,premiumSource:i=null,quantity:s}){try{if(e(wa,!0),!r)throw new Error("Missing parameter accountType");if(a&&!o)throw new Error("Param billingCycleCount is required if billingCycleInterval is used");if(!a&&o)throw new Error("Param billingCycleInterval is required if billingCycleCount is used");if((a||o)&&typeof n>"u")throw new Error("Param billingCycleCost is missing");const u={premiumSource:i};return a&&o&&n&&(u.billingCycleInterval=a,u.billingCycleCount=o,u.billingCycleCost=n),typeof s<"u"&&(u.quantity=s),await bhe(r,u),await t(ym),e(wa,!1),!0}catch(u){return this.handleError(u,{object:"companyAccount",action:`${Ql}/${wz}`}),!1}finally{e(wa,!1)}},async[nke]({rootGetters:t},{props:e=[]}={}){try{const r=ya(t["application/company"],e);return this.commit(`forms/${vx}`,{key:"company",formData:r}),!0}catch(r){return this.handleError(r),!1}},async[yz]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("company");return await e(gz,{body:r}),await this.dispatch(hz,"company"),!0}catch(r){return this.handleError(r,{object:"companies",fallbackCode:"companies.submit",action:`${Ql}/${yz}`}),!1}},async[_z]({rootGetters:t,dispatch:e}){try{const{CompanyBranding:r}=t["application/company"];if(r&&r.id)return e(gx);const n={about:""};return this.commit(`forms/${vx}`,{key:"companyBranding",formData:n}),!0}catch(r){return this.handleError(r,{object:"companies",action:`${Ql}/${_z}`}),!1}},async[gx]({rootGetters:t}){try{const{CompanyBranding:e}=t["application/company"],r=e;return this.commit(`forms/${vx}`,{key:"companyBranding",formData:r}),!0}catch(e){return this.handleError(e,{object:"companies",action:`${Ql}/${gx}`}),!1}},async[bz]({rootGetters:t,dispatch:e,commit:r}){try{r(wa,!0);const n=t["forms/getFormByKey"]("companyBranding");let{id:a}=n;return a?await fr.put("/companyBranding",n):{id:a}=await fr.post("/companyBranding",n),e(ym),r(wa,!1),await this.dispatch(hz,"companyBranding"),a}catch(n){return r(wa,!1),this.handleError(n,{object:"companies",fallbackCode:"companies.submit",action:`${Ql}/${bz}`}),!1}}},si=new Se.Entity("files"),ike=new Se.Array(si),_m=new Se.Entity("companyUsers"),xz=new Se.Array(_m),kz=new Se.Entity("companies"),oke=new Se.Array(kz),co=new Se.Entity("invoices");co.define({InvoiceFiles:[{File:si,Thumbnail:si}],creditInvoices:[co],creditsInvoice:co,interestInvoices:[co],interestForInvoice:co});const _x=new Se.Array(co),ske=new Se.Entity("documents",{data:{Files:ike,Invoices:_x}}),uke=new Se.Array(ske),Pz=new Se.Entity("projectFiles",{File:si}),lke=new Se.Array(Pz),bx=new Se.Entity("projects",{ProjectMembers:xz,ProjectFiles:[{File:si}],Invoices:_x,CompanyUser:_m}),dke=new Se.Array(bx),cke=new Se.Entity("timeTracks",{CompanyUser:_m,Project:bx}),fke=new Se.Array(cke),Tz=new Se.Entity("companyReference",{CompanyReferenceItem:{Image:si,Thumbnail:si}}),mke=new Se.Array(Tz),Mz=new Se.Entity("documentTerms",{File:si}),pke=new Se.Array(Mz),hke={project:bx,projects:dke,invoice:co,invoices:_x,companyReference:Tz,companyReferences:mke,projectFile:Pz,projectFiles:lke,documents:uke,companyUser:_m,companyUsers:xz,company:kz,companies:oke,timeTracks:fke,documentTerm:Mz,documentTerms:pke},vke=(t,e)=>{const r=hke[e];return r||console.warn(`No schema found for type: '${e}'`),lz(t,r)};function fo(t,e,r=!1){let n=e.replace(/\[(\d*)\]/ig,(i,s)=>`.${s}`);n=n.split(".");let a=t;const o=n.pop();return n.length>0&&(a=n.reduce((i,s)=>{let u=i[s];return r&&(ot(u)==="undefined"||ot(u)==="null")&&(ce.set(i,s,{}),u=i[s]),u},t)),{root:a,prop:o}}function Ys(t,e){function r(n,a){Object.keys(a).forEach(o=>{const i=n[o]instanceof Object&&!Array.isArray(n[o]),s=a[o]instanceof Object&&!Array.isArray(a[o]);if(i&&s){Ys(n[o],a[o]);return}ce.set(n,o,a[o])})}r(t,e)}function Zl(t,{keyId:e="id"}={}){const r=[],n={};return t.forEach(a=>{n[a[e]]=a,r.push(a[e])}),{ids:r,values:n}}function Sz({schema:t,getters:e,data:r,scope:n=null,instance:a=null}){let o=n;typeof o=="string"&&(o=[o]);const i={};return t&&Object.keys(t).map(s=>(t[s].$virtual&&t[s].$virtual.map(u=>{const{name:l,set:d}=u;let f={};if(r&&typeof r[s]<"u"?f=r[s]:typeof t[s].$default<"u"&&(f=t[s].$default),typeof f>"u")return!1;const m=a||this;return i[l]=d.call(m,f,{getters:e}),!0}),!0)),t&&o&&Array.isArray(o)&&Object.keys(t).map(s=>t[s].$scope?(o.some(l=>t[s].$scope.indexOf(l)>=0)||delete i[s],!0):(delete i[s],!0)),JSON.parse(JSON.stringify(i))}function gke({schema:t,data:e,getters:r,scope:n=null,includeVirtual:a=!1,instance:o=null}){let i=n;if(typeof i=="string"&&(i=[i]),!t)throw new Error("Missing parameter schema");const s={};Object.keys(t).map(l=>(t[l].$default!=="undefined"&&(s[l]=t[l].$default),!0));let u=Object.assign({},s,e);return a&&(u={...u,...Sz({schema:t,getters:r,data:e,scope:n,instance:o})}),t&&i&&Array.isArray(i)&&Object.keys(t).map(l=>t[l].$scope?(i.some(f=>t[l].$scope.indexOf(f)>=0)||delete u[l],!0):(delete u[l],!0)),JSON.parse(JSON.stringify(u))}function Oz({next:t=null,projectId:e,docType:r,docId:n,invoiceId:a}={},o,i=void 0){if(!t||!o)return!1;switch(t){case"project":{if(!e)throw new ji(`Cannot redirect user on next: '${t}' as no projectId is defined`);o.push({name:"project",params:{id:e,modal:!1}},i);break}case"invoice":{if(!a)throw new ji(`Cannot redirect user on next: '${t}' as no invoiceId is defined`);o.push({name:"invoice",params:{id:a,modal:!1}},i);break}case"preview":{if(a){o.push({name:"previewInvoice",params:{id:a}},i);break}if(!e)throw new ji(`Cannot redirect user on next: '${t}' as no projectId is defined`);if(!r)throw new ji(`Cannot redirect user on next: '${t}' as no docType is defined`);if(!n)throw new ji(`Cannot redirect user on next: '${t}' as no docId is defined`);o.push({name:"Preview",params:{projectId:e,docType:r,docId:n}},i);break}default:throw new ji(`Cannot redirect user on next: '${t}' as it is not implemented`)}return!0}const{SET_COMPANIES:yke,CLEAR_COMPANIES:_ke,SET_COMPANIES_FETCHING:bke,SET_COMPANIES_POSTING:wke}=rx,xke={[yke](t,{data:e}){if(typeof e!="object")throw Error("Data must be a company or an array of companies!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[_ke](t){ce.set(t,"data",{}),ce.set(t,"ids",[])},[bke](t,e){t.isFetching=e},[wke](t,e){t.isPosting=e}},kke={namespaced:!0,state:Lxe,getters:{companyById:t=>e=>t.data[e],certificateIdListForCurrentCompany:(t,e,r)=>()=>e.certificateIdListForCompany(r.application.user.companyId),certificateIdListForCompany:t=>e=>{const r=t.data[e].CompanyCertificates;return r||[]},isFetching:t=>t.isFetching,isPosting:t=>t.isPosting},actions:ake,mutations:xke},Pke={data:{},ids:[],isFetching:!1,isPosting:!1},ui="companyUsers",{LOAD_COMPANY_USERS:Ez,LOAD_COMPANY_USER:bm,DO_NORMALIZE_COMPANY_USERS:wm,UPDATE_COMPANY_USER:wx,CREATE_COMPANY_USER:xx,DELETE_COMPANY_USER:Dz,PATCH_COMPANY_USER:kx,FORM_NEW_COMPANY_USER:Tke,FORM_EDIT_COMPANY_USER:Mke,FORM_SUBMIT_COMPANY_USER:Cz}=NV,{SET_AS_NORMALIZED_DATA:Ske,FORM_RESET_OLD:Oke,DELETE_FILE:Eke}=Oe,{SET_COMPANY_USERS_FETCHING:xm,SET_COMPANY_USERS_POSTING:li}=nx,Dke={async[wm](t,{companyUsers:e=[]}){if(!e||!Array.isArray(e)||!e.length)throw new Error("Missing param companyUsers");await this.dispatch(Ske,{data:e,schema:"companyUsers"})},async[Ez]({dispatch:t,commit:e}){try{e(xm,!0);const{data:r}=await phe();await t(wm,{companyUsers:r})}catch(r){this.handleError(r,{object:"companyUser",fallbackCode:"companyUser.getAll",action:`${ui}/${Ez}`})}finally{e(xm,!1)}},async[bm]({commit:t,dispatch:e,rootGetters:r},{id:n}){try{t(xm,!0);const{data:a}=await hhe(n);await e(wm,{companyUsers:[a]});const{id:o}=r["application/user"]||{};return n===o&&(be.locale!==a.locale&&be.l10n.changeLocale(a.locale),be.lang!==a.language&&(be.i18next.changeLanguage(a.language),location&&location.reload())),n}catch(a){return this.handleError(a,{object:"companyUser",objectId:n,fallbackCode:"companyUser.get",action:`${ui}/${bm}`,actionPayload:arguments[1]}),null}finally{t(xm,!1)}},async[xx]({commit:t,dispatch:e,rootGetters:r},{body:n}){try{const{language:a,locale:o}=r["application/user"]||{},i={language:a||"en",locale:o||"en-US",...n};t(li,!0);const{data:s}=await vhe(i);return await e(wm,{companyUsers:[s]}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("sentThingTo",{thing:be.t("invitation"),recipient:s.email})}),s.id}catch(a){return this.handleError(a,{object:"companyUser",fallbackCode:"companyUser.post",action:`${ui}/${xx}`,actionPayload:arguments[1]}),null}finally{t(li,!1)}},async[wx]({dispatch:t,commit:e,getters:r},{id:n,body:a}){var o;try{e(li,!0);const{AvatarPublicId:i}=a,{AvatarPublicId:s}=r.byId(n);return i&&i!==s&&this.dispatch(Eke,{id:s}),await ghe(n,a),await t(bm,{id:n}),(o=this.$supportChat)==null||o.syncData(),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("user")})}),n}catch(i){return this.handleError(i,{object:"companyUser",objectId:n,fallbackCode:"companyUser.put",action:`${ui}/${wx}`,actionPayload:arguments[1]}),null}finally{e(li,!1)}},async[Dz]({commit:t},{id:e}){try{return t(li,!0),await yhe(e),t(nx.DELETE_COMPANY_USER,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("user")}),actions:{undo:()=>{this.dispatch(`${ui}/${kx}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"companyUser",objectId:e,fallbackCode:"companyUser.delete",action:`${ui}/${Dz}`,actionPayload:arguments[1]}),null}finally{t(li,!1)}},async[kx]({dispatch:t,commit:e},{id:r}){try{return e(li,!0),await _he(r),await t(bm,{id:r}),r}catch(n){return this.handleError(n,{object:"companyUser",objectId:r,fallbackCode:"companyUser.patch",action:`${ui}/${kx}`,actionPayload:arguments[1]}),null}finally{e(li,!1)}},[Tke]({commit:t,rootGetters:e}){let r="en";const n=e["application/user"];n.language&&({language:r}=n);const a={AvatarPublicId:null,CompanyId:null,CompanyUserPermission:{manageCompany:!1,manageUsers:!1,manageProjects:!1,manageOwnProjects:!1,showPrices:!1,manageAtas:!1,manageOwnAtas:!1,createTimeTracks:!0,readTimeTracks:!1,readOwnTimeTracks:!0,modifyTimeTracks:!1,modifyOwnTimeTracks:!0,deleteTimeTracks:!1,deleteOwnTimeTracks:!0,attestTimeTracks:!1,createInvoices:!1,readInvoices:!1,readOwnInvoices:!1,modifyInvoices:!1,modifyOwnInvoices:!1,deleteInvoices:!1,deleteOwnInvoices:!1,attestInvoices:!1,attestOwnInvoices:!1,exportInvoices:!1,modifyBookkeepingSettings:!1},cellphone:null,email:null,finishedGuide:!1,firstname:null,id:null,language:r,lastActive:null,lastname:null,resetPasswordExpires:null,resetPasswordToken:null};return t(`forms/${De.SET_FORM}`,{key:"companyUser",formData:a},{root:!0})},[Mke]({commit:t,getters:e},{id:r,props:n=[]}){const a=ya(e.byId(r),n);return t(`forms/${De.SET_FORM}`,{key:"companyUser",formData:a},{root:!0})},async[Cz]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("companyUser");let{id:n}=r;return n?await e(wx,{id:r.id,body:r}):n=await e(xx,{body:r}),await this.dispatch(Oke,"companyUser"),!0}catch(r){return this.handleError(r,{object:"companyUser",action:`${ui}/${Cz}`,actionPayload:arguments[1]}),!1}}},{SET_COMPANY_USERS:Cke,DELETE_COMPANY_USER:$ke,CLEAR_COMPANY_USERS:Ake,SET_COMPANY_USERS_FETCHING:Rke,SET_COMPANY_USERS_POSTING:Ike}=nx,Nke={[Cke](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a company user or an array of company users!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[$ke](t,e){ce.delete(t.data,e);const r=t.ids.indexOf(e);r!==-1&&t.ids.splice(r,1)},[Ake](t){ce.set(t,"data",{}),ce.set(t,"ids",[])},[Rke](t,e){t.isFetching=e},[Ike](t,e){t.isPosting=e}},Lke={namespaced:!0,state:Pke,getters:{referenceById:t=>e=>t.data[e],byId:t=>e=>{const r=t.data[e];if(!r)return null;const{firstname:n,lastname:a}=r;return{...r,fullName:`${n||""} ${a||""}`.trim(),role:bpe(r.CompanyUserPermission),avatarUrl:`${Me.api.baseUrl}/file/${r.AvatarPublicId}/download`}},all:(t,e)=>{const r={};return t.ids.forEach(n=>{r[n]=e.byId(n)}),r},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching},actions:Dke,mutations:Nke},Wke={...{invoice:{},isFetchingInvoice:!1,isPostingInvoice:!1},companyUser:{},company:{},isFetching:!1,isPosting:!1},km="settings",{FORM_RESET_OLD:Fke}=Oe,{DO_LOAD_INVOICE_SETTINGS:Px,LOAD_INVOICE_SETTINGS:$z,DO_UPDATE_INVOICE_SETTINGS:Tx,UPDATE_INVOICE_SETTINGS:Az,FORM_EDIT_INVOICE_SETTINGS:Rz,FORM_SUBMIT_INVOICE_SETTINGS:Iz}=VV,{SET_INVOICE_SETTINGS_FETCHING:Nz,SET_INVOICE_SETTINGS_POSTING:Lz}=ox,{SET_SETTINGS:jke}=De.settings,{SET_FORM:Vke}=De.forms,zke={async[Px]({commit:t}){try{t(Nz,!0);const{data:e}=await khe();t(jke,{key:"invoice",settings:e})}catch(e){throw e}finally{t(Nz,!1)}},async[$z]({dispatch:t}){try{await t(Px)}catch(e){this.handleError(e,{object:"companySettings",fallbackCode:"settings.get",action:`${km}/${$z}`})}},async[Tx]({dispatch:t,commit:e},{data:r}){try{e(Lz,!0),await Phe(r),t(Px)}catch(n){throw n}finally{e(Lz,!1)}},async[Az]({dispatch:t},{data:e}){try{return await t(Tx,{data:e}),!0}catch(r){return this.handleError(r,{object:"setting",fallbackCode:"settings.put",action:`${km}/${Az}`,actionPayload:arguments[1]}),!1}},async[Rz]({commit:t,state:e},{props:r=[]}={}){try{const n=ya(e.invoice,r);return t(`forms/${Vke}`,{key:"companyInvoiceSettings",formData:n},{root:!0}),!0}catch(n){return this.handleError(n,{object:"setting",fallbackCode:"setting.editInvoice",action:`${km}/${Rz}`,actionPayload:arguments[1]}),!1}},async[Iz]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("companyInvoiceSettings"),{invoicePaymentAccountType:n}=r;return n==="bankgiro"?(r.invoicePaymentDomesticClearingNo=null,r.invoicePaymentDomesticAccountNo=null):n==="domesticBankAcc"&&(r.invoicePaymentBankGiro=null),await e(Tx,{data:r}),await this.dispatch(Fke,"companyInvoiceSettings"),!0}catch(r){return this.handleError(r,{object:"setting",fallbackCode:"setting.submitInvoice",action:`${km}/${Iz}`}),!1}}},di="settings",{FORM_RESET_OLD:Wz,DO_LOAD_INVOICE_SETTINGS:Uke}=Oe,{DO_LOAD_ALL_SETTINGS:Fz,LOAD_ALL_SETTINGS:jz,DO_LOAD_SETTINGS_COMPANY:Pm,LOAD_SETTINGS_COMPANY:Vz,LOAD_SETTINGS_COMPANYUSER:zz,UPDATE_SETTINGS:Uz,DO_UPDATE_SETTINGS:ed,FORM_EDIT_COMPANY_SETTINGS:Hz,DO_LOAD_SETTINGS_COMPANYUSER:Tm,FORM_SUBMIT_COMPANY_SETTINGS:qz,FORM_EDIT_COMPANY_USER_SETTINGS:Bz,FORM_SUBMIT_COMPANY_USER_SETTINGS:Yz}=zV,{SET_SETTINGS:Mx,SET_SETTINGS_FETCHING:Mm,SET_SETTINGS_POSTING:Gz}=De.settings,{SET_FORM:Kz}=De.forms,Xz=["ataTravel"],Hke=["extraWorkPrice","extraWorkManagementPrice","extraEntrepreneurPercentage","extraOtherPercentage"],Jz=t=>{const e=t;return Object.keys(e).forEach(r=>{Xz.includes(r)&&e[r]==="0"?e[r]="":e[r]==="true"?e[r]=!0:e[r]==="false"?e[r]=!1:e[r]==="null"?e[r]=null:typeof e[r]!="boolean"&&!Number.isNaN(Number(e[r]))&&e[r]!==""&&(e[r]=Number(e[r]))}),e},Sm=t=>{const e=[];return Object.keys(t).forEach(r=>{let n=t[r];t[r]===!0?n="true":t[r]===!1&&(n="false"),Hke.includes(r)&&(n=Number(n)),Xz.includes(r)&&(t[r]===!1||t[r]==="")?e.push({name:r,value:!1,type:"string"}):e.push({name:r,value:n})}),e},qke={...zke,async[Fz]({dispatch:t}){await t(Pm),await t(Tm),await this.dispatch(Uke)},async[jz]({dispatch:t}){try{await t(Fz)}catch(e){this.handleError(e,{object:"settings",fallbackCode:"settings.get",action:`${di}/${jz}`})}},async[Pm]({commit:t}){try{t(Mm,!0);const{data:e}=await fr.get("/companySetting"),r=Jz(e);t(Mx,{key:"company",settings:r});const{ataTitleKey:n}=e;n&&n!=="ata"&&be.i18next.addResources(be.i18next.language,"_common",{ata:`$t(${n})`,ataThe:`$t(${n}The)`})}catch(e){throw e}finally{t(Mm,!1)}},async[Vz]({dispatch:t}){try{await t(Pm)}catch(e){this.handleError(e,{object:"companySettings",fallbackCode:"settings.get",action:`${di}/${Vz}`})}},async[Tm]({dispatch:t,commit:e}){var r;try{e(Mm,!0);const{data:n}=await fr.get("/companyUserSetting"),a=Jz(n);e(Mx,{key:"companyUser",settings:a});const{autoTriggerPurchaseEvent:o}=a;if(o){const{currency:i,amount:s,accountType:u}=o||{};(r=this.$trackevent)==null||r.call(this,"purchase",{currency:i,amount:s,accountType:u}),await t(ed,{key:"companyUser",settings:Sm({autoTriggerPurchaseEvent:null})})}}catch(n){throw n}finally{e(Mm,!1)}},async[zz]({dispatch:t}){try{await t(Tm)}catch(e){this.handleError(e,{object:"companyUserSettings",fallbackCode:"settings.get",action:`${di}/${zz}`})}},async[Uz]({dispatch:t,commit:e},{key:r,settings:n}){try{if(!r)throw new Error("Missing valid parameter key");const a=Sm(n);return e(Mx,{key:r,settings:n}),await t(ed,{key:r,settings:a}),!0}catch(a){return this.handleError(a,{object:"setting",fallbackCode:"settings.put",action:`${di}/${Uz}`,actionPayload:arguments[1]}),!1}},async[ed]({dispatch:t,commit:e},{key:r,settings:n}){try{if(e(Gz,!0),r==="company")await fr.post("/companySetting",n),t(Pm);else if(r==="companyUser")await fr.post("/companyUserSetting",n),t(Tm);else throw new Error(`Setting key: '${r}' is not valid, cannot update settings.`)}catch(a){throw a}finally{e(Gz,!1)}},async[Hz]({commit:t,state:e},{props:r=[]}={}){try{const n=ya(e.company,r);return t(`forms/${Kz}`,{key:"companySettings",formData:n},{root:!0}),!0}catch(n){return this.handleError(n,{object:"setting",fallbackCode:"setting.editCompany",action:`${di}/${Hz}`,actionPayload:arguments[1]}),!1}},async[qz]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("companySettings"),n=Sm(r);return await e(ed,{key:"company",settings:n}),await this.dispatch(Wz,"companySettings"),!0}catch(r){return this.handleError(r,{object:"setting",fallbackCode:"setting.submitCompany",action:`${di}/${qz}`}),!1}},async[Bz]({commit:t,state:e},{props:r=[]}={}){try{const n=ya(e.companyUser,r);return t(`forms/${Kz}`,{key:"companyUserSettings",formData:n},{root:!0}),!0}catch(n){return this.handleError(n,{object:"setting",fallbackCode:"setting.editCompanyUser",action:`${di}/${Bz}`,actionPayload:arguments[1]}),!1}},async[Yz]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("companyUserSettings"),n=Sm(r);return await e(ed,{key:"companyUser",settings:n}),await this.dispatch(Wz,"companyUserSettings"),!0}catch(r){return this.handleError(r,{object:"setting",fallbackCode:"setting.submitCompanyUser",action:`${di}/${Yz}`}),!1}}},{SET_INVOICE_SETTINGS_FETCHING:Bke,SET_INVOICE_SETTINGS_POSTING:Yke}=ox,Gke={[Bke](t,e){t.isFetchingInvoice=e},[Yke](t,e){t.isPostingInvoice=e}},{SET_SETTINGS:Kke,CLEAR_SETTINGS:Xke,SET_SETTINGS_FETCHING:Jke,SET_SETTINGS_POSTING:Qke}=UV,Zke={...Gke,[Kke](t,{key:e,settings:r={}}){if(!t[e])throw Error(`${e} is not a valid key/type`);Object.keys(r).forEach(n=>{const a=r[n];ce.set(t[e],n,a)})},[Xke](t,{key:e,name:r=null}){r?ce.delete(t[e],r):ce.set(t,e,{})},[Jke](t,e){t.isFetching=e},[Qke](t,e){t.isPosting=e}},ePe={...{allInvoiceSettings:t=>t.invoice,getInvoiceSetting:t=>e=>{const r=t.invoice[e];return typeof r<"u"?r:null},isFetchingInvoice:t=>t.isFetchingInvoice,isPostingInvoice:t=>t.isPostingInvoice,isRegisteredForInvoicing:(t,e)=>e.getInvoiceSetting("isRegisteredForInvoicing")},allCompanySettings:t=>t.company,getCompanySetting:t=>e=>{const r=t.company[e];return typeof r<"u"?r:null},getCompanyUserSetting:t=>e=>{const r=t.companyUser[e];return typeof r<"u"?r:null},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,allowHidePrice:(t,e)=>e.getCompanySetting("work_allowHidePrice"),hidePriceOnNewlyAddedArticles:(t,e)=>e.allowHidePrice&&e.getCompanySetting("work_default_hidePrice"),allowDocumentCustomSender:(t,e)=>e.getCompanySetting("allowProjectCustomSender"),allowHideDocArticlePriceInput:(t,e)=>e.getCompanySetting("allowHideDocArticlePriceInput"),defaultHideDocArticlePriceInput:(t,e)=>e.getCompanySetting("hideDocArticlePriceInput"),defaultVatRate:(t,e)=>e.getCompanySetting("defaultVatRate"),defaultCurrency:(t,e)=>e.getCompanyUserSetting("defaultCurrency"),documentSenderSign:(t,e)=>e.getCompanyUserSetting("documentSenderSign"),showOverviewOnboardingOverlay:(t,e)=>e.getCompanyUserSetting("showOverviewOnboardingOverlay"),reminderSettings:t=>{const e=t.company||{};return{notAnswered:e.defaultReminderRemindDays,notViewed:e.defaultReminderViewedDays,expires:e.defaultReminderExpireDays}},defaultDocumentTheme:t=>{const{documentThemeBackgroundFilter:e,documentThemePriceBackground:r,documentThemePrimaryColor:n,offerBrandingBackgroundUrl:a}=t.company||{};return{...e&&e!=="hsla(239,71%,89%,0)"&&{backgroundFilter:e},...r&&r!=="hsla(249,60%,34%,1)"&&{priceSummaryBackground:r},...n&&n!=="hsla(271,100%,38%,1)"&&{headingColor:n},...n&&n!=="hsla(271,100%,38%,1)"&&{headingColor:n},...a&&{background:a}}},isAuthenticatedCRM:(t,e)=>(r,n=null)=>({hubspot:[{key:"hubspotNativeTokens",type:"getCompanyUserSetting",appType:"native"},{key:"hubspotTokens",type:"getCompanyUserSetting",appType:"extension"}],upsales:[{key:"upsalesApiKey",type:"getCompanySetting"}],salesforce:[{key:"salesforceTokens",type:"getCompanyUserSetting"}],pipedrive:[{key:"pipedriveTokens",type:"getCompanyUserSetting"}]}[r]||[]).filter(o=>!n||o.appType===n).some(({key:o,type:i})=>{var s;return!!((s=e[i])!=null&&s.call(e,o))}),allAuthenticatedCRMs:(t,e)=>["hubspot","salesforce","pipedrive"].filter(r=>!!e.isAuthenticatedCRM(r)),isFortnoxInstalled:(t,e)=>!!e.getCompanySetting("fortnoxTokens")&&Un.checkFeature("fortnox")},tPe={namespaced:!0,state:Wke,getters:ePe,actions:qke,mutations:Zke},rPe={...(()=>({isUploading:!1,article:{},document:{},document2:{},projectNote:{},company:{},companyBranding:{},companyUser:{},companyInvoiceSettings:{},companySettings:{},companyUserSettings:{},moduleArticles:[],modulePrices:{},file:{},invoice:{},invoiceNote:{},companyReference:{},companyReferenceItems:[],endCustomer:{},timeline:{},timeTrack:{TimeTrackSlots:[]},documentTerm:{},kycForm:{}}))()},{FORM_DOCUMENT_SET_CLIENT:Qz,FORM_DOCUMENT_SUBMIT_CLIENT:nPe}=Vn,{SET_FORM_VALUE:mo,REMOVE_FORM_VALUE:Zz}=zn,aPe={async[Qz]({commit:t,getters:e,rootGetters:r},{formData:n}){if(!n)return t(mo,{key:"document.ModuleEndCustomer",value:null}),t(Zz,"document.ModuleExtraCustomers"),!0;const a=Object.assign({},n);a.id=null,a.EndCustomerId=n.id,t(mo,{key:"document.ModuleEndCustomer",value:a});const o=e.documentField("ModuleExtraCustomers");a.customerType==="company"&&a.reference&&o&&o.length===0&&t(mo,{key:"document.ModuleExtraCustomers",value:{name:a.reference}});const i=r["settings/getCompanySetting"]("priceInputCompany"),s=r["settings/getCompanySetting"]("priceInputDefault");return a.customerType==="company"&&i?t("application/updateField",{path:"priceInputVat",value:i},{root:!0}):a.customerType==="individual"&&s&&t("application/updateField",{path:"priceInputVat",value:s},{root:!0}),!0},async[nPe]({commit:t,dispatch:e,rootGetters:r},{mode:n="create"}={}){let a=null;if(n==="edit"){const o=r["forms/documentField"]("ModuleEndCustomer"),i=r["forms/getFormByKey"]("endCustomer");if(!o)throw new Error("Could not find the old client");if(!i)throw new Error("Could not find the new client");if(o.customerType==="individual"&&i.customerType==="company")t(Zz,"document.ModuleExtraCustomers"),t(mo,{key:"document.ModuleExtraCustomers",value:{name:i.reference}});else if(i.customerType==="company"){const s=r["forms/documentField"]("ModuleExtraCustomers");s&&s[0]?t(mo,{key:"document.ModuleExtraCustomers[0]",value:{name:i.reference}}):t(mo,{key:"document.ModuleExtraCustomers",value:{name:i.reference}})}a=Object.assign({},i,{id:i.EndCustomerId}),i.doUpdateEndCustomer&&(t(mo,{key:"endCustomer",value:a}),await e(`endCustomers/${ba.FORM_SUBMIT_ENDCUSTOMER}`,{},{root:!0}))}else{const o=await e(`endCustomers/${ba.FORM_SUBMIT_ENDCUSTOMER}`,{},{root:!0}),i=r["endCustomers/endCustomerById"](o);if(!i)throw new Error("Could not find the endCustomer");a=Object.assign({},i)}return await e(Qz,{formData:a}),!0}};var eU={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(ct,function(){Array.isArray||(Array.isArray=function(o){return Object.prototype.toString.call(o)==="[object Array]"});function r(o){for(var i=[],s=0,u=o.length;s<u;s++)i.indexOf(o[s])===-1&&i.push(o[s]);return i}var n={},a={"==":function(o,i){return o==i},"===":function(o,i){return o===i},"!=":function(o,i){return o!=i},"!==":function(o,i){return o!==i},">":function(o,i){return o>i},">=":function(o,i){return o>=i},"<":function(o,i,s){return s===void 0?o<i:o<i&&i<s},"<=":function(o,i,s){return s===void 0?o<=i:o<=i&&i<=s},"!!":function(o){return n.truthy(o)},"!":function(o){return!n.truthy(o)},"%":function(o,i){return o%i},log:function(o){return console.log(o),o},in:function(o,i){return!i||typeof i.indexOf>"u"?!1:i.indexOf(o)!==-1},cat:function(){return Array.prototype.join.call(arguments,"")},substr:function(o,i,s){if(s<0){var u=String(o).substr(i);return u.substr(0,u.length+s)}return String(o).substr(i,s)},"+":function(){return Array.prototype.reduce.call(arguments,function(o,i){return parseFloat(o,10)+parseFloat(i,10)},0)},"*":function(){return Array.prototype.reduce.call(arguments,function(o,i){return parseFloat(o,10)*parseFloat(i,10)})},"-":function(o,i){return i===void 0?-o:o-i},"/":function(o,i){return o/i},min:function(){return Math.min.apply(this,arguments)},max:function(){return Math.max.apply(this,arguments)},merge:function(){return Array.prototype.reduce.call(arguments,function(o,i){return o.concat(i)},[])},var:function(o,i){var s=i===void 0?null:i,u=this;if(typeof o>"u"||o===""||o===null)return u;for(var l=String(o).split("."),d=0;d<l.length;d++)if(u==null||(u=u[l[d]],u===void 0))return s;return u},missing:function(){for(var o=[],i=Array.isArray(arguments[0])?arguments[0]:arguments,s=0;s<i.length;s++){var u=i[s],l=n.apply({var:u},this);(l===null||l==="")&&o.push(u)}return o},missing_some:function(o,i){var s=n.apply({missing:i},this);return i.length-s.length>=o?[]:s}};return n.is_logic=function(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.keys(o).length===1},n.truthy=function(o){return Array.isArray(o)&&o.length===0?!1:!!o},n.get_operator=function(o){return Object.keys(o)[0]},n.get_values=function(o){return o[n.get_operator(o)]},n.apply=function(o,i){if(Array.isArray(o))return o.map(function(v){return n.apply(v,i)});if(!n.is_logic(o))return o;var s=n.get_operator(o),u=o[s],l,d,f,m,c;if(Array.isArray(u)||(u=[u]),s==="if"||s=="?:"){for(l=0;l<u.length-1;l+=2)if(n.truthy(n.apply(u[l],i)))return n.apply(u[l+1],i);return u.length===l+1?n.apply(u[l],i):null}else if(s==="and"){for(l=0;l<u.length;l+=1)if(d=n.apply(u[l],i),!n.truthy(d))return d;return d}else if(s==="or"){for(l=0;l<u.length;l+=1)if(d=n.apply(u[l],i),n.truthy(d))return d;return d}else{if(s==="filter")return m=n.apply(u[0],i),f=u[1],Array.isArray(m)?m.filter(function(v){return n.truthy(n.apply(f,v))}):[];if(s==="map")return m=n.apply(u[0],i),f=u[1],Array.isArray(m)?m.map(function(v){return n.apply(f,v)}):[];if(s==="reduce")return m=n.apply(u[0],i),f=u[1],c=typeof u[2]<"u"?u[2]:null,Array.isArray(m)?m.reduce(function(v,g){return n.apply(f,{current:g,accumulator:v})},c):c;if(s==="all"){if(m=n.apply(u[0],i),f=u[1],!Array.isArray(m)||!m.length)return!1;for(l=0;l<m.length;l+=1)if(!n.truthy(n.apply(f,m[l])))return!1;return!0}else if(s==="none"){if(m=n.apply(u[0],i),f=u[1],!Array.isArray(m)||!m.length)return!0;for(l=0;l<m.length;l+=1)if(n.truthy(n.apply(f,m[l])))return!1;return!0}else if(s==="some"){if(m=n.apply(u[0],i),f=u[1],!Array.isArray(m)||!m.length)return!1;for(l=0;l<m.length;l+=1)if(n.truthy(n.apply(f,m[l])))return!0;return!1}}if(u=u.map(function(v){return n.apply(v,i)}),a.hasOwnProperty(s)&&typeof a[s]=="function")return a[s].apply(i,u);if(s.indexOf(".")>0){var p=String(s).split("."),h=a;for(l=0;l<p.length;l++){if(!h.hasOwnProperty(p[l]))throw new Error("Unrecognized operation "+s+" (failed at "+p.slice(0,l+1).join(".")+")");h=h[p[l]]}return h.apply(i,u)}throw new Error("Unrecognized operation "+s)},n.uses_data=function(o){var i=[];if(n.is_logic(o)){var s=n.get_operator(o),u=o[s];Array.isArray(u)||(u=[u]),s==="var"?i.push(u[0]):u.forEach(function(l){i.push.apply(i,n.uses_data(l))})}return r(i)},n.add_operation=function(o,i){a[o]=i},n.rm_operation=function(o){delete a[o]},n.rule_like=function(o,i){if(i===o||i==="@")return!0;if(i==="number")return typeof o=="number";if(i==="string")return typeof o=="string";if(i==="array")return Array.isArray(o)&&!n.is_logic(o);if(n.is_logic(i)){if(n.is_logic(o)){var s=n.get_operator(i),u=n.get_operator(o);if(s==="@"||s===u)return n.rule_like(n.get_values(o,!1),n.get_values(i,!1))}return!1}if(Array.isArray(i))if(Array.isArray(o)){if(i.length!==o.length)return!1;for(var l=0;l<i.length;l+=1)if(!n.rule_like(o[l],i[l]))return!1;return!0}else return!1;return!1},n})})(eU);var iPe=D0,oPe=lm,sPe=$0,tU=fa,uPe=zs;function lPe(t,e,r,n){if(!tU(t))return t;e=oPe(e,t);for(var a=-1,o=e.length,i=o-1,s=t;s!=null&&++a<o;){var u=uPe(e[a]),l=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var d=s[u];l=n?n(d,u,s):void 0,l===void 0&&(l=tU(d)?d:sPe(e[a+1])?[]:{})}iPe(s,u,l),s=s[u]}return t}var dPe=lPe,cPe=dPe;function fPe(t,e,r){return t==null?t:cPe(t,e,r)}var Xt=fPe;function mPe(t,e){let r=0;const n=[];for(const[a,o]of t.entries()){const{code:i,data:s}=o;if(i===e){const u=n.slice(r).find(({code:l,data:d})=>{if(l!==i)return!1;const f=te(d,"client.id"),m=te(s,"client.id"),c=te(d,"email"),p=te(s,"email");return f===m&&m!==void 0||c===p&&p!==void 0});u?(u.children=[...u.children,o],u.createdAt=o.createdAt):n.push({...o,children:[]})}else i==="sent"&&(r=a?a-1:0),n.push(o)}return n}const rU=({nodes:t,data:e})=>{const r=[];return t.forEach(n=>{const a=n.isVisible?mpe(n.isVisible,["_uniqueId"]):!1;(!a||eU.exports.apply(a,e))&&r.push(n),n&&Array.isArray(n.children)&&n.children.length&&(n.children=rU({nodes:n.children,data:e}))}),r},nU={rot:{max:5e4*100,ratio:.3},rut:{max:75e3*100,ratio:.5},greenRot15:{max:5e4*100,ratio:.15},greenRot50:{max:5e4*100,ratio:.5}},aU=(t,e,r)=>{if(!nU[t])throw new Error("Missing param type");const{max:n,ratio:a}=nU[t];return Math.min(r*n,e*a)},Om=({type:t="fixed",currency:e,maxTotal:r=null,articles:n=[],clients:a=[],region:o={},useVat:i,rounding:s})=>{if(typeof i>"u")throw new Error("Missing param useVat");if(typeof i!="boolean")throw new Error("Param useVat must be a boolean");if(typeof s!="object"||s===null)throw new Error("Param rounding must be a object");if(typeof s.enabled>"u")throw new Error("Missing param rounding.enabled");if(typeof s.enabled!="boolean")throw new Error("Param rounding.enabled must be a boolean");if(typeof s.interval>"u")throw new Error("Missing param rounding.interval");if(typeof s.interval!="number")throw new Error("Param rounding.interval must be a number");if(typeof s.show>"u")throw new Error("Missing param rounding.show");if(typeof s.show!="boolean")throw new Error("Param rounding.show must be a boolean");const u={type:t,subTotal:0,taxAmount:0,roundingAmount:0,total:0,currency:e,maxTotal:t==="openAccMaxPrice"?r||0:null,region:{country:"sweden",houseWorkType:null,reverseVat:!!a.find(f=>te(f,"region.reverseVat")),houseWorkManualAmount:o.houseWorkManualAmount||null,houseWorkWork:0,houseWorkAmount:o.houseWorkManualAmount||o.houseWorkAmount||null},helpers:{discount:0,isIndivid:!a.find(f=>f.type==="company"),noOfClients:a.length||1},useVat:i,rounding:{enabled:s.enabled,interval:s.interval,show:s.show}},l=f=>f/100;if(u.helpers.isIndivid&&!u.region.reverseVat){const f=[...n].sort((m,c)=>new Date(c.updatedAt).getTime()-new Date(m.updatedAt).getTime()).find(d1);f&&!u.region.houseWorkType&&(u.region.houseWorkType=E3(f))}for(let f of n){f=Zi(f);const{totalAmount:m,currency:c,priceType:p,discount:h,discountType:v}=f;let{vat:g}=f;i||(g=0),["fixed","approx"].includes(p)&&(u.currency=c,u.subTotal+=m,u.taxAmount+=m*l(g),u.helpers.discount+=v==="percentage"?m/((100-h/100)/100)-m:h,u.region.houseWorkType&&d1(f)&&(u.region.houseWorkWork+=m*((100+g)/100)))}!u.helpers.isIndivid&&u.region.reverseVat&&(u.taxAmount=0),u.region.houseWorkType&&u.region.houseWorkAmount===null&&(u.region.houseWorkAmount=aU(u.region.houseWorkType,u.region.houseWorkWork,u.helpers.noOfClients));const d=u.subTotal+u.taxAmount-u.region.houseWorkAmount;return u.roundingAmount=s.enabled&&s.interval?Math.round(d/s.interval)*s.interval-d:0,u.total=d+u.roundingAmount,l1(u),u},pPe=t=>{if(!t)return null;const{currency:e,clients:r=[],articles:n=[]}=t,a=te(t,"data.packageGroups",{}),o=te(t,"data.formSettings.useVat",!0),i={enabled:te(t,"data.formSettings.rounding.enabled",!1),interval:te(t,"data.formSettings.rounding.interval",1),show:te(t,"data.formSettings.rounding.show",!0)},s=[],u=[];let l=null,d=null,f=null;if(Object.keys(a).forEach(h=>{const v=a[h].packages.filter(({isSelected:_})=>_);u.push(...v.map(({packageId:_})=>_));const g=te(v,"[0].data.prices.type","fixed");s.push(...Array.isArray(g)?g:[g]),v.forEach(_=>{const{maxTotal:y=null,region:b}=te(_,"data.prices")||{};g==="openAccMaxPrice"&&!Number.isNaN(Number.parseInt(y,10))&&(l+=y),b&&!Number.isNaN(Number.parseInt(b.houseWorkManualAmount,10))&&(d+=b.houseWorkManualAmount)})}),!s.length){const h=te(t,"data.prices.type","fixed");s.push(...Array.isArray(h)?h:[h])}const m=n.filter(({packageId:h})=>!h||u.includes(h)),c=m.filter(d1),p={};for(let h of c){h=Zi(h);const v=E3(h),g=o?h.vat:0;p[v]||(p[v]=null),p[v]+=h.totalAmount*((100+g)/100)}for(const[h,v]of Object.entries(p))v&&(f+=aU(h,v,r.length||1));return{...Om({currency:e,articles:m,clients:r,region:{country:"sweden",houseWorkManualAmount:d,houseWorkAmount:f},useVat:o,rounding:i}),type:s,maxTotal:l}},hPe=t=>{const e=a=>be.t(`_common:documentMentions.${a}`),r=!!te(t,"clients.0"),n={clientName:{key:"clients.0.name",meta:{inputDisabled:!r,virtual:!0}},clientEmail:{key:"clients.0.email",meta:{inputDisabled:!r,virtual:!0}},clientPhone:{key:"clients.0.cellphone",meta:{inputDisabled:!r,virtual:!0}},clientCompany:{key:"clients.0.companyName",meta:{inputDisabled:!r,virtual:!0}},clientAddress:{key:"clients.0.addresses.standard.street",meta:{inputDisabled:!r,virtual:!0}},clientZip:{key:"clients.0.addresses.standard.zip",meta:{inputDisabled:!r,virtual:!0}},clientCity:{key:"clients.0.addresses.standard.city",meta:{inputDisabled:!r,virtual:!0}},clientSocialNo:{key:"clients.0.socialNo",meta:{inputDisabled:!0,virtual:!0}},clientOrgNo:{key:"clients.0.orgNo",meta:{inputDisabled:!0,virtual:!0}},senderName:{key:"companyUser.fullName",meta:{inputDisabled:!0,virtual:!0}},senderEmail:{key:"companyUser.email",meta:{inputDisabled:!0,virtual:!0}},senderPhone:{key:"companyUser.cellphone",meta:{inputDisabled:!0,virtual:!0}},senderCompany:{key:"company.name",meta:{inputDisabled:!0,virtual:!0}},senderAddress:{key:"company.street",meta:{inputDisabled:!0,virtual:!0}},senderZip:{key:"company.zip",meta:{inputDisabled:!0,virtual:!0}},senderCity:{key:"company.city",meta:{inputDisabled:!0,virtual:!0}},documentName:{key:"data.name",meta:{inputDisabled:!1,virtual:!0}}};for(const a of Object.keys(n))n[a].label=e(a),n[a].value=te(t,n[a].key)||"";return n},td=t=>t?Object.keys(t).reduce((e,r)=>t[r]||t[r]===!1?{...e,[r]:t[r]}:e,{}):{};function vPe(t,e){if(typeof e!="object"||e===null)throw Error("Param pdfFile must be an object");const{name:r,url:n,mime:a,fileId:o}=e;if(!r||!n||!a||!o)throw Error("Param pdfFile must include name, url, mime and fileId");if(!t)return null;const i=te(t,"template.views.read.nodes")||[],s=Cn.exports(),u=Array(2).fill().map(()=>Cn.exports());return i.push({itemId:"sectionPdf",itemType:"section",value:null,parentId:"0",nodeId:u[0]},{itemId:"pdf",itemType:"pdf",value:{file:`data.pdf-file-${s}`},parentId:u[0],nodeId:u[1]}),Xt(t,`data.pdf-file-${s}`,e),Xt(t,`template.validationSchema.properties.data.properties.pdf-file-${s}`,{anyOf:[{$ref:`${Me.api.baseUrl}/schemas/file/1.json`},{type:"null"}]}),t}function gPe(t){if(!t)return null;const e=te(t,"template.views.read.nodes")||[];if(e.find(n=>n.itemType==="answer"))return t;e.push({itemId:"answer",itemType:"answer",value:{defaultAnswerMethod:"data.defaultAnswerMethod"},parentId:"0",nodeId:Cn.exports()}),Xt(t,"template.views.read.nodes",e);const r="template.validationSchema.properties.data.properties.defaultAnswerMethod";return te(t,r)||Xt(t,r,{default:{accept:"signature",deny:"button"},$ref:`${Me.api.baseUrl}/schemas/answer/1.json`}),t}const yPe=t=>{if(!t)return null;let e=(t||"").replace(/^SE|[-]/g,"").trim();return e.length===12&&(e=e.substring(2)),`SE${e}01`},Sx=()=>{const t=["email"];return Un.checkFeature("sms")&&Un._isValidCompanySetting("deliveryDefaultSms")&&t.push("sms"),{region:{country:"sweden"},permissions:{write:["clients[*].socialNo","clients[0].region.propertyDesignation","data.rejectReasons","data.packageGroups[*].packages[*].isSelected"]},answer:null,deliveryTypes:t,documentRole:"signee",answerMethod:{accept:"signature",deny:"button"},signOrder:0,_uniqueId:Cn.exports()}},Ox=(t,e)=>{const r={endCustomerId:t.id,type:t.customerType,name:t.customerType==="individual"?t.name:t.reference,socialNo:t.customerType==="individual"?t.org_no:null,companyName:t.customerType==="company"?t.name:null,orgNo:t.customerType==="company"?t.org_no:null,email:t.email,cellphone:t.cellphone,cellphoneRegion:t.cellphoneRegion,addresses:{...t.street||t.zip||t.city?{standard:{street:t.street,zip:`${t.zip||""}`,city:t.city,country:t.country,latitude:t.latitude?`${t.latitude}`:null,longitude:t.longitude?`${t.longitude}`:null}}:{},...t.workStreet||t.workZip||t.workCity?{work:{street:t.workStreet,zip:`${t.workZip||""}`,city:t.workCity,country:t.country,latitude:t.latitude?`${t.latitude}`:null,longitude:t.longitude?`${t.longitude}`:null}}:{}},vatNumber:t.vatNumber,region:{...e&&e.region,reverseVat:t.reverseVat&&t.customerType==="company"},documentRole:te(e,"documentRole","signee"),signOrder:te(e,"signOrder",0)};return{...Sx(),...e,...r}},Ex=(t={})=>{const e=t,r=te(e,"addresses.standard",{}),n=te(e,"addresses.work",{});return{id:e.endCustomerId,EndCustomerId:e.endCustomerId,customerType:e.type||"individual",name:e.type==="individual"?e.name:e.companyName,email:e.email,cellphone:e.cellphone,cellphoneRegion:e.cellphoneRegion,org_no:e.type==="individual"?e.socialNo:e.orgNo,street:r.street,zip:r.zip,city:r.city,workStreet:n.street,workZip:n.zip,workCity:n.city,vatNumber:e.vatNumber||yPe(e.orgNo)||"",separateWorkAddress:!!Object.keys(n).length,reverseVat:te(e,"region.reverseVat",!1),longitude:te(e,"addresses[0].longitude",null),latitude:te(e,"addresses[0].latitude",null),reference:e.type==="company"?e.name:null}},_Pe=({background:t,backgroundFilter:e,priceSummaryBackground:r,showPriceSummary:n})=>({resourceUrl:t,overlayColor:e,backgroundColor:r,showPriceSummary:n}),bPe=({header:t={},theme:e={}})=>{const{resourceUrl:r="",title:n="",backgroundColor:a="",overlayColor:o="",showPriceSummary:i}={..._Pe(e),...t};return{layout:"price",baseStyle:{textColor:"",textAlign:"left"},items:[{type:"content",size:50,media:{type:"color",backgroundColor:a},value:{preText:"",documentName:n?`<h1>${n}</h1>`:"",postText:"",showLogo:!0,logotype:""}},{type:"media",size:50,media:{type:"image",resourceUrl:r,overlay:!0,overlayColor:o}}],...typeof i=="boolean"&&{showPriceSummary:i}}},wPe=(t,e={})=>(!t||!t.data||te(t,"template.views.read.nodes",[]).filter(n=>n.itemType==="header"&&!!n.value.header).map(n=>n.value.header.substring(5)).forEach(n=>{if(t.data[n]&&t.data[n].layout==="legacy"){const a={...e,...td(t.data.theme)};t.data[n]=bPe({header:{...t.data[n],title:te(t,"data.name","")},theme:a})}}),t),xPe={isHouseWorkAuto:!0,rotAmount:null,rutAmount:null,persons:[],propertyType:null,realEstateId:null,condominiumId:null,condominiumOrgNo:null,isExported:!1,isProcessed:!1},rd={id:{$default:null,$type:Number,$scope:["invoice"]},publicId:{$default:null,$type:String},status:{$default:"draft",$type:String,$scope:["invoice"]},subStatus:{$default:null,$type:String},type:{$default:"invoice",$type:String,$scope:["invoice"]},invoiceNumber:{$default:null,$type:String,$scope:["invoice"]},ocr:{$default:null,$type:Number},ourReference:{$default:null,$type:String,$scope:["invoice"]},yourReference:{$default:null,$type:String,$scope:["invoice"]},invoiceDate:{$default:d5(new Date).toISOString(),$type:Date,$scope:["invoice"]},dueDays:{$default:null,$type:Number,$scope:["invoice"],$virtual:[{name:"dueDays",set(t,{getters:e}){return t!==null?t:e["settings/getInvoiceSetting"]("invoiceDueDays")||null}}]},dueDate:{$default:null,$type:Date,$scope:["invoice"],$virtual:[{name:"dueDate",set(t,{getters:e}){if(t!==null)return t;const r=e["settings/getInvoiceSetting"]("invoiceDueDays")||1;return rf(Zue(dl(rd.invoiceDate.$default),r)).toISOString()}}]},deliveryDate:{$default:null,$type:Date,$scope:["invoice"]},sentAt:{$default:null,$type:Date},attestedAt:{$default:null,$type:Date},disputedAt:{$default:null,$type:Date},salesRequestedAt:{$default:null,$type:Date},pausedAt:{$default:null,$type:Date},interestType:{$default:"noInterest",$type:String,$scope:["invoice"],$virtual:[{name:"interestType",set(t,{getters:e}){return e["settings/getInvoiceSetting"]("invoiceInterestPercentage")?"fixed":"noInterest"}}]},interestPercentage:{$default:null,$type:Number,$scope:["invoice"],$virtual:[{name:"interestPercentage",set(t,{getters:e}){return t!==null?t:e["settings/getInvoiceSetting"]("invoiceInterestPercentage")||null}}]},interestStartInDaysAfterDueDate:{$default:0,$type:Number,$scope:["invoice"]},invoiceFee:{$default:null,$type:Number,$scope:["invoice"],$virtual:[{name:"invoiceFee",set(t,{getters:e}){return t!==null?t:e["settings/getInvoiceSetting"]("invoiceFee")||null}}]},reminderFee:{$default:null,$type:Number,$scope:["invoice"],$virtual:[{name:"reminderFee",set(t,{getters:e}){return t!==null?t:e["settings/getInvoiceSetting"]("invoiceReminderFee")||null}}]},deliveryTypes:{$default:["email"],$type:Array,$scope:["invoice"]},totalAmount:{$default:0,$type:Number},remainingAmount:{$default:0,$type:Number},paidAmount:{$default:0,$type:Number},creditedAmount:{$default:0,$type:Number},writeOffAmount:{$default:0,$type:Number},reminderAmount:{$default:0,$type:Number},totalVatAmount:{$default:0,$type:Number},centRoundingAmount:{$default:0,$type:Number},transferAmount:{$default:0,$type:Number},currency:{$default:"SEK",$type:String},partnerPdfId:{$default:null,$type:String},ModuleArticles:{$default:[],$type:Array,$scope:["invoice"]},ModuleEndCustomer:{$default:null,$type:Object,$scope:["invoice"]},ModuleBranding:{$scope:["invoice"],$type:Object,$default:{message:null,useMessageEmail:!0}},InvoiceFiles:{$scope:["invoice"],$type:Array,$default:[]},InvoiceRegionSweden:{$default:xPe,$type:Object,$scope:["invoice"]},ModuleScheduledDeliveries:{$scope:["invoice"],$type:Array,$default:[{type:"viewed",sendDays:null,sendType:"email",sendAt:null,status:"new"}],$virtual:[{name:"ModuleScheduledDeliveries",set(t,{getters:e}){return this.type==="credit"?[]:e["settings/getCompanySetting"]("invoiceReminderActive")?t.map(a=>{const o=a;if(o.sendDays!==null)return o;let i=null;return o.type==="viewed"&&(i=e["settings/getCompanySetting"]("invoiceReminderDefaultViewedDays")),i!==null&&(o.sendDays=i),o}):[]}}]},CompanyId:{$default:null,$type:"ref",$ref:"companies",$scope:["invoice"]},CompanyUserId:{$default:null,$type:"ref",$ref:"companyUsers",$scope:["invoice"]},creditsInvoiceId:{$default:null,$type:"ref",$ref:"invoices",$scope:["invoice"]},object:{$default:null,$type:String,$scope:["invoice"]},objectId:{$default:null,$type:Number,$scope:["invoice"]},documentId:{$default:null,$type:String,$scope:["invoice"]},projectId:{$default:null,$type:Number,$scope:["invoice"]},createdAt:{$default:null,$type:Date},updatedAt:{$default:null,$type:Date},deletedAt:{$default:null,$type:Date}};class Dx{constructor(e,r){if(!e)throw Error("Missing argument invoice");if(!r)throw Error("Missing argument getters");this._getters=r,this._invoice=e}get id(){return this.getProperty("id")||null}get publicId(){return this.getProperty("publicId")||null}get pdfPath(){if(this.status==="draft"||this.isSale)return null;const e=this.latestReminder;if(e){const{id:r}=e;return`${Me.api.baseUrl}/public/invoice/${this.publicId}/pdf/reminder/${r}`}return`${Me.api.baseUrl}/public/invoice/${this.publicId}/pdf`}getCompany(){const{_getters:e}=this,r=this.getProperty("CompanyId")||{};return e["companies/companyById"](r)}getCompanyUser(){const{_getters:e}=this,r=this.getProperty("CompanyUserId")||{};return e["companyUsers/byId"](r)}get status(){return this.getProperty("status")}get visualStatus(){return this.getProperty("transferAmount")?"paying":this.status}get subStatus(){return this.getProperty("subStatus")}get type(){return this.getProperty("type")}get projectId(){return this.getProperty("projectId")||null}get document(){return this.documentId?this._getters["documents2/byId"](this.documentId):null}get documentId(){return this.getProperty("documentId")}get client(){return this.getProperty("ModuleEndCustomer")||null}get files(){return this.getProperty("InvoiceFiles")}get totalAmount(){return this.getProperty("totalAmount")}get totalVatAmount(){return this.getProperty("totalVatAmount")}get totalExVat(){return this.totalAmount-this.totalVatAmount}get paidAmount(){return this.getProperty("paidAmount")}get sentAt(){return this.getProperty("sentAt")}get dueDate(){const e=this.latestReminder;return e?e.dueDate:this.getProperty("dueDate")}get invoiceDate(){const e=this.latestReminder;return e?e.invoiceDate:this.getProperty("invoiceDate")}get invoiceNumber(){return this.getProperty("invoiceNumber")}get reminders(){return this.getProperty("InvoiceReminders")||[]}get latestReminder(){const e=this.reminders;return e.length?e[e.length-1]:null}get canDispute(){return this.getProperty("id")&&!["draft","salesRequest","sold","completed"].includes(this.status)&&!this.isDisputed}get canRegisterPayment(){return this.getProperty("id")&&!["draft","salesRequest","sold","completed"].includes(this.status)}get canRegisterWriteOff(){return this.getProperty("id")&&!["draft","salesRequest","sold","completed"].includes(this.status)}get canSendReminder(){return this.getProperty("id")&&!["draft","salesRequest","sold","completed"].includes(this.status)}get canCredit(){const e=this.getProperty("id"),r=this.getProperty("type")==="credit";return e&&this.isAttested&&!r&&!["draft","salesRequest"].includes(this.status)}get canSell(){return this.id&&!this.isAttested&&!["salesRequest"].includes(this.status)}get canCancelSell(){return this.id&&this.isAttested&&["salesRequest"].includes(this.status)}get creditsInvoice(){const{_getters:e}=this,r=this.getProperty("creditsInvoice")||null;return e["invoices/byId"](r)}get creditInvoices(){const{_getters:e}=this;return(this.getProperty("creditInvoices")||[]).map(a=>e["invoices/byId"](a))}get interestInvoiceTo(){const{_getters:e}=this,r=this.getProperty("interestForInvoiceId")||null;return e["invoices/byId"](r)}get interestInvoices(){const{_getters:e}=this;return(this.getProperty("interestInvoices")||[]).map(a=>e["invoices/byId"](a))}get isDisputed(){return!!this.getProperty("disputedAt")}get isAttested(){return!!this.getProperty("attestedAt")}get isReverseVat(){const e=this.getProperty("ModuleEndCustomer")||null;return e?e.reverseVat:!1}get events(){const e=this.getProperty("Events")||[],r=[];return e.forEach(n=>{const a={type:n.type};n.EventData.forEach(o=>{a[o.name]=o.value}),r.push({name:n.code==="sentSms"?"sent":n.code,timestamp:n.createdAt,data:a,counter:n.counter})}),r}get articles(){return Zi(this.getProperty("ModuleArticles")||[])}get totalNetAmount(){const{articles:e}=this;return e.reduce((n,a)=>n+a.totalAmount,0)}get currency(){return"SEK"}get invoiceRegionSweden(){return this.getProperty("InvoiceRegionSweden")||{}}get rotAmount(){const e=this.getProperty("InvoiceRegionSweden")||{},{rotAmount:r}=e;return r||0}get rutAmount(){const e=this.getProperty("InvoiceRegionSweden")||{},{rutAmount:r}=e;return r||0}get invoiceFee(){return this.getProperty("invoiceFee")||0}get isSale(){return!!(["salesRequest","sold"].includes(this.status)||this.getProperty("salesRequestAcceptedAt"))}getScheduledDeliveries({type:e,status:r}={}){let n=this.getProperty("ModuleScheduledDeliveries")||null;return!n||!n.length?[]:(e&&(n=n.filter(a=>a.type===e)),r&&(n=n.filter(a=>a.status===r)),n)}getProperty(e=""){return e.replace(/\[(.*)\]/ig,(a,o)=>`.${o}`).split(".").reduce((a,o)=>a&&(typeof a[o]!="object",a[o]),this._invoice)}getProperties({scope:e=null,includeVirtual:r=!1}={}){const n=rd,{_getters:a}=this;return gke({schema:n,getters:a,data:this._invoice,scope:e,includeVirtual:r,instance:this})}getVirtualProperties({scope:e=null}={}){const r=rd,{_getters:n}=this;return Sz({schema:r,getters:n,data:this._invoice,scope:e,instance:this})}}Ut(Dx,"schema",rd);const{DO_LOAD_INVOICE:iU,DO_UPDATE_INVOICE:kPe,DO_CREATE_INVOICE:PPe,DO_ATTEST_INVOICE:TPe,DO_SELL_INVOICE:MPe,LOAD_FILE:SPe,FORM_CLEAR_FORM:OPe,FORM_RESET_OLD:EPe,DO_LOAD_DOCUMENT2:oU,UPDATE_VIEW_SETTINGS:DPe,LOAD_INVOICE_SETTINGS:CPe}=Oe,{SET_FORM:nd,SET_FORM_VALUE:$Pe}=De.forms,{DELETE_MANY_INVOICES:APe}=De.invoices,{LOAD_INVOICE_FORM:RPe,LOAD_CREDIT_INVOICE_FORM:IPe,LOAD_DOCUMENT2_INVOICE_FORM:NPe,LOAD_CAMPAIGN_INVOICE_FORM:LPe,SUBMIT_INVOICE_FORM:WPe,SET_KYC_FORM:FPe,DO_SAVE_KYC_FORM:jPe}=WV,ci=(t,e)=>{t(DPe,{view:"newInvoice",settings:{isLoading:e}})};async function Cx({id:t=null,rootState:e,state:r,rootGetters:n,dispatch:a,projectId:o=null,documentId:i=null}){if(!e)throw new Error("Missing parameter rootState");if(!r)throw new Error("Missing parameter state");if(!n)throw new Error("Missing parameter rootGetters");if(!a)throw new Error("Missing parameter dispatch");let s=!1;const u=r.document;if(Object.keys(u).length!==0){const{name:l,params:d}=e.route||{};let{id:f}=d||{};f=Number.parseInt(f,10);const m=n["forms/documentField"]("id"),c=n["forms/documentField"]("documentType"),p=n["forms/documentField"]("type"),h=n["forms/documentField"]("projectId"),v=n["forms/documentField"]("documentId");if(c||(l==="invoiceNew"?!m&&!t&&p!=="credit"&&o===h&&(Tt.debug("INVOICE_FORM: Using existing store data as no ids was found"),s=!0):l==="invoiceEdit"?m&&m===f&&m===t&&p!=="credit"&&(Tt.debug("INVOICE_FORM: Using existing store data existing id match route"),s=!0):l==="invoiceCredit"?p==="credit"&&!t&&!m&&(Tt.debug("INVOICE_FORM: Using existing store data existing id match route"),s=!0):l==="invoiceDocument"&&v&&v===i&&(Tt.debug("INVOICE_FORM: Using existing store data as existing documentId match"),s=!0)),s){Tt.debug("INVOICE_FORM: Dont reload as forms/document is already defined");const g=n["forms/documentField"]("InvoiceFiles");g&&ot(g)==="array"&&g.forEach(_=>a(SPe,{id:_.FileId},{root:!0}))}}return s}function ad({rootState:t,rootGetters:e},r={}){const n=new Dx(r,e).getProperties({includeVirtual:!0}),a={ModuleArticles:[e["articles/getNewArticle"]({name:"",price:0})]};return{...n,...a,CompanyId:t.application.user.companyId,CompanyUserId:t.application.user.userId}}const VPe={async[IPe]({state:t,rootGetters:e,rootState:r,dispatch:n},{creditsInvoiceId:a}){try{if(ci(this.dispatch,!0),await Cx({id:null,rootState:r,state:t,rootGetters:e,dispatch:n}))return;let i=ad({rootState:this.state,rootGetters:e},{type:"credit"});if(!a)throw new Error("Missing parameter creditsInvoiceId");await this.dispatch(iU,{id:a});const s=this.getters["invoices/byId"](a);if(!s)throw Tt.event({type:"invoiceCredit",status:"failed",data:{id:a},error:"Tried to load invoice to credit that does not exist!"}),new Error(`Could not find original invoice by id: '${a}'`);s.documentId&&!this.getters["documents2/byId"](s.documentId)&&await this.dispatch(oU,{id:s.documentId});const u=ya(s.getProperties({scope:"invoice",includeVirtual:!0}),["ModuleArticles","ModuleBranding","ourReference","yourReference","invoiceFee","deliveryTypes","ModuleEndCustomer","InvoiceRegionSweden","object","objectId","documentId","projectId"]);i={...i,...u,type:"credit",creditsInvoiceId:a,invoiceDate:rf(new Date).toISOString(),dueDate:rf(new Date).toISOString()},i.invoiceFee&&(i.invoiceFee=-i.invoiceFee),i.ModuleArticles&&(i.ModuleArticles=i.ModuleArticles.map(l=>{const d=ni(l,["id","createdAt","updatedAt","deletedAt","object","ObjectId"]);return d.price=-d.price,d.houseWorkHoursToReport&&(d.houseWorkHoursToReport*=-1),d})),i.ModuleBranding&&(i.ModuleBranding=ni(i.ModuleBranding,["id","createdAt","updatedAt","deletedAt","object","ObjectId"])),i.ModuleEndCustomer&&(i.ModuleEndCustomer=ni(i.ModuleEndCustomer,["id","createdAt","updatedAt","deletedAt","object","ObjectId"])),i.InvoiceRegionSweden&&(i.InvoiceRegionSweden=ya(i.InvoiceRegionSweden,["condominiumId","condominiumOrgNo","isHouseWorkAuto","persons","propertyType","realEstateId"]),i.InvoiceRegionSweden&&!i.InvoiceRegionSweden.isHouseWorkAuto&&(i.InvoiceRegionSweden.persons=(i.InvoiceRegionSweden.persons||[]).map(l=>({...l,amount:-l.amount})))),this.commit(`forms/${nd}`,{key:"document",formData:i}),Tt.event({type:"invoiceCredit",status:"success",data:{id:a}}),Tt.debug("Credit invoice form loaded")}catch(o){this.handleError(o)}finally{ci(this.dispatch,!1)}},async[NPe]({state:t,rootGetters:e,rootState:r,dispatch:n},{docId:a}){try{if(!a)throw new Error("Missing parameter docId");ci(this.dispatch,!0);let o=ad({rootState:this.state,rootGetters:e});await this.dispatch(oU,{id:a});const i=this.getters["documents2/byId"](a);if(!i)throw new Error("Missing document");const{projectId:s}=i;if(await Cx({id:null,rootState:r,state:t,rootGetters:e,dispatch:n,documentId:a,projectId:s}))return;o={...o,documentId:i.id,...s&&{projectId:s}},i.clients&&i.clients.length&&(o.ModuleEndCustomer=Ex(ni(i.clients[0],["id","createdAt","updatedAt","deletedAt","object","ObjectId"]))),this.commit(`forms/${nd}`,{key:"document",formData:o})}catch(o){this.handleError(o)}finally{ci(this.dispatch,!1)}},async[RPe]({state:t,rootState:e,dispatch:r,rootGetters:n},{id:a=null,projectId:o=null}={}){try{if(ci(this.dispatch,!0),await Cx({id:a,rootState:e,state:t,rootGetters:n,dispatch:r,projectId:o}))return;let s={},u;if(a){if(await this.dispatch(iU,{id:a}),u=this.getters["invoices/byId"](a),!u)throw Tt.event({type:"editInvoice",status:"failed",data:{id:a},error:"Tried to edit invoice that does not exist!"}),new Error(`Could not find invoice by id: '${a}'`);s={...s,...u.getProperties({scope:"invoice"})}}else if(s={...ad({rootState:this.state,rootGetters:n})},o){s.projectId=o;const f=n["projects/byId"](o);f&&f.clients[0]&&(s.ModuleEndCustomer=Ex(ni(f.clients[0],["id","createdAt","updatedAt","deletedAt","object","ObjectId"])))}const{object:l,objectId:d}=s;this.commit(`forms/${nd}`,{key:"document",formData:s}),Tt.event({type:a?"editInvoice":"newInvoice",status:"success",data:{id:a}}),Tt.debug("Invoice form loaded")}catch(i){Tt.event({type:a?"editInvoice":"newInvoice",status:"failed",data:{id:a},error:i})}finally{ci(this.dispatch,!1)}},async[WPe]({getters:t,commit:e},{next:r=null,doAttest:n=!1,doSell:a=!1}={}){let o=!1;try{let i=!1,s;const{invoice:u,hasChanged:l}=t,d=t.getInvoicePrices;let{id:f}=u;r==="invoice"&&(s={...u.getProperties(),ModuleArticles:u.articles,...d,id:0},this.dispatch(uo,{data:[s],schema:"invoices"}),o=!0,this.$router.push({name:"invoice",params:{id:s.id,modal:!1}}));const m={...u.getProperties(),...d};return l("document")&&(f?await this.dispatch(kPe,{id:f,body:m}):(i=!0,f=await this.dispatch(PPe,{body:m}),e($Pe,{key:"document.id",value:f}))),o&&this.$router.replace({name:"invoice",params:{id:f,modal:!1}}),a?await this.dispatch(MPe,{id:f}):n&&await this.dispatch(TPe,{id:f}),await this.dispatch(EPe,"document"),o||Oz({next:r,invoiceId:f},this.$router),await this.dispatch(OPe,{key:"document"}),o&&this.commit(`invoices/${APe}`,s.id),{id:f,isNew:i}}catch(i){return this.handleError(i),o&&this.$router.currentRoute.name!=="invoiceNew"&&this.$router.go(-1),null}},async[LPe]({state:t,rootGetters:e},{name:r=null}){if(!["100kr"].includes(r))throw Error("Missing valid param name");try{ci(this.dispatch,!0);let a={...ad({rootState:this.state,rootGetters:e})};if(r==="100kr"){let o;const{data:i}=await mhe("info@cling.se");i[0]?([o]=i,o.EndCustomerId=o.id):(await this.dispatch(Oe.FORM_NEW_ENDCUSTOMER),o=Object.assign(t.endCustomer,{name:"Cling Group AB",org_no:"559070-0273",email:"info@cling.se",customerType:"company",cellphone:"0850119885",street:"Kund-id WIN3890, FE nr 160",zip:"10569",city:"Stockholm"}),this.commit(Oe.SET_FORM_VALUE,{key:"endCustomer",value:o}),o.EndCustomerId=await this.dispatch(Oe.FORM_SUBMIT_ENDCUSTOMER,{showNotification:!1})),o.id=null,a={...ad({rootState:this.state,rootGetters:e}),ModuleEndCustomer:{...o},ModuleArticles:[ype({name:"\u{1F4B0} Ge mig 100kr! \u{1F4B0}",price:1e4})]}}this.commit(`forms/${nd}`,{key:"document",formData:a}),Tt.event({type:"campaignInvoice",status:"success",data:{name:r}}),Tt.debug("Invoice form loaded")}catch(a){Tt.event({type:"campaignInvoice",status:"failed",data:{name:r},error:a})}finally{ci(this.dispatch,!1)}},async[FPe]({rootGetters:t},{formData:e={}}={}){await this.dispatch(CPe),t["application/company"],t["settings/allInvoiceSettings"];let r={};r={...r,...e,company:{...r.company,...e.company},contact:{...r.contact,...e.contact}},this.commit(`forms/${nd}`,{key:"kycForm",formData:r})},async[jPe]({getters:t}){const{kycForm:e}=t||{};if(!e)throw Error("Kyc Form missing in store");return["ownersWithMoreThan25Percent","beneficialOwners"].forEach(n=>{e[n]=(e[n]||[]).map(a=>({...a,address:a.address||"Sverige",country:a.country||"Sverige"}))}),await The.post({form:e})}},{SET_FORM_VALUE:zPe,REMOVE_FORM_VALUE:UPe}=De.forms,HPe={async[Vn.SET_FORM_ARTICLE]({commit:t},{index:e=null,data:r}){let n="document.ModuleArticles";e!==null&&(n=`document.ModuleArticles[${e}]`);const a=Zi(r);return t(zPe,{key:n,value:a})},async[Vn.REMOVE_FORM_ARTICLE]({commit:t},e){return t(UPe,e)}},id=t=>typeof t=="object"&&t!==null&&t.toString()==={}.toString(),Em=t=>JSON.parse(JSON.stringify(t)),$x=(t,e)=>{t=Em(t);for(const r in e)e.hasOwnProperty(r)&&(id(t[r])&&id(e[r])?t[r]=$x(t[r],e[r]):t[r]=e[r]);return t},sU=(t,e)=>{t=t.replace(/^#\/definitions\//,"").split("/");const r=(a,o)=>{const i=a.shift();if(o[i]){if(!a.length)return o[i]}else return{};return r(t,o[i])},n=r(t,e);return id(n)?Em(n):n},qPe=(t,e)=>{const{length:r}=t;let n=-1,a={};for(;++n<r;){let o=t[n];o=typeof o.$ref<"u"?sU(o.$ref,e):o,a=$x(a,o)}return a},Gs=(t,e)=>{if(typeof t.default<"u")return t.default;if(typeof t.allOf<"u"){const r=qPe(t.allOf,e);return Gs(r,e)}else if(typeof t.$ref<"u"){const r=sU(t.$ref,e);return Gs(r,e)}else if(t.type==="object"){if(!t.properties)return{};for(const r in t.properties)t.properties.hasOwnProperty(r)&&(t.properties[r]=Gs(t.properties[r],e),(typeof t.properties[r]>"u"||id(t.properties[r])&&!Array.isArray(t.properties[r])&&!Object.keys(t.properties[r]).length)&&delete t.properties[r]);return t.properties}else if(t.type==="array"){if(!t.items)return[];const r=t.minItems||0;if(t.items.constructor===Array){const o=t.items.map(i=>Gs(i,e));for(let i=o.length-1;i>=0&&!(typeof o[i]<"u");i--)i+1>r&&o.pop();return o}const n=Gs(t.items,e);if(typeof n>"u")return[];const a=[];for(let o=0;o<Math.max(1,r);o++)a.push(Em(n));return a}},BPe=(t,e)=>(typeof e>"u"?e=t.definitions||{}:id(t.definitions)&&(e=$x(e,t.definitions)),Gs(Em(t),e));class fi{constructor(e){if(!e)throw new Error("Missing param data");const{validationSchema:r,views:n}=e;if(!r)throw new Error("Missing param validationSchema in template data");if(!n)throw new Error("Missing param views in template data");this._data=e}get data(){return this._data}get id(){return this.data.id||null}get companyId(){return this.data.companyId||null}get name(){return this.data.name||null}get isNew(){return!this.id}get validationSchema(){return this.data.validationSchema}get views(){return this.data.views||{}}get language(){return this.data.language}get theme(){return te(this,"_data.validationSchema.properties.data.properties.theme.default",{})||{}}get thumbnailUrl(){return this.data.thumbnailUrl}get defaultMedia(){if(this.thumbnailUrl)return{type:"image",resourceUrl:this.thumbnailUrl};const{defaultData:e}=this,r=(te(this,"_data.views.read.nodes")||[]).filter(a=>["header","coverBlock"].includes(a.itemType));let n=null;for(const a of r)if(a){if(n)break;let o=a.value[a.itemType];if(!o)continue;if(a.itemType==="header"){o+=".items";const i=(te(e,o)||[]).find(({type:s})=>s==="media");i&&i.media&&({media:n}=i)}else if(a.itemType==="coverBlock"){const{type:i,cover:s}=te(e,o)||{};s&&(n={...i&&{type:i},...s})}}if(!n){const a=te(this,"theme.background");a&&(n={type:"image",resourceUrl:a})}return n}get reminders(){const e=this.getDefaultData({path:"properties.data.properties.reminders"});return e&&Array.isArray(e)?e:[]}get defaultData(){return this.getDefaultData()}get categoryTags(){return te(this.defaultData,"tags",[]).reduce((e,r)=>[...e,r.name],[])}get type(){return this.categoryTags[0]}getDefaultData({path:e=""}={}){let r=this.validationSchema;return e&&(r=e.split(".").reduce((n,a)=>n[a],r)),BPe(r)||{}}}const YPe=Me.brand.charAt(0).toUpperCase()+Me.brand.slice(1),GPe={accept:"acceptera",address:"adress",and:"and",answerFeedback:{intermediate:{title:"Tack f\xF6r att du delar dina tankar."},no:{start:{action:"Skicka in",placeholder:"Vad b\xF6r vi f\xF6rb\xE4ttra?",text:"Finns det n\xE5got specifikt du \xF6nskar vi b\xF6r f\xF6rb\xE4ttra?",title:"Tack f\xF6r att du delar med dig av dina tankar."},success:{action:"L\xE4s mer om $t(appBrand)",secondary:"Tillbaka till dokumentet",text:"Din feedback togs emot helt perfekt. V\xE5rt team kommer att ta del av din feedback med stor lyh\xF6rdhet.",title:"Tack."}},start:{no:"Nej",title:"Tyckte du om att anv\xE4nda $t(appBrand) f\xF6r att visa det h\xE4r dokumentet?",yes:"Ja"},yes:{action:"S\xE4tt ig\xE5ng gratis",secondary:"L\xE4s mer om $t(appBrand)",text:"Skapa och skicka snygga dokument med $t(appBrand). Uppt\xE4ck alla f\xF6rdelar med att skicka webbaserade dokument med e-signering.",title:"B\xF6rja anv\xE4nda $t(appBrand) du med."}},answerModal:{answerSuccess:"Ditt svar togs emot helt perfekt.",bankId:{component:{defaultError:"N\xE5got gick fel. Se till att du har matat in r\xE4tt personnummer och f\xF6rs\xF6k igen.",signingInterrupted:"Signeringen avbr\xF6ts, f\xF6rs\xF6k igen...",validations:{socialNo:{personalNumber:"Personnumret \xE4r inte giltigt",required:"Skriv in ditt personnummer"}},viewText:{canceled:{text:"Signeringen avbr\xF6ts. Var god och f\xF6rs\xF6k igen.",title:"Signeringen avbr\xF6ts"},error:{text:"Ett fel intr\xE4ffa. Var god och f\xF6rs\xF6k igen.",title:"Ett fel intr\xE4ffa"},form:{text:"Skriv in ditt personnummer f\xF6r att p\xE5b\xF6rja signeringen.",title:"Signera dokumentet med BankID"},new:{spinnerText:"\xD6ppna BankID p\xE5 din enhet.",text:"\xD6ppna BankID p\xE5 din enhet f\xF6r att signera dokumentet.",title:"Signera dokument"},signing:{spinnerText:"Var god signera dokumentet.",text:"\xD6ppna BankID p\xE5 din enhet f\xF6r att signera dokumentet.",title:"Signering p\xE5g\xE5r"},waiting:{spinnerText:"V\xE4ntar p\xE5 att du ska \xF6ppna BankID.",text:"\xD6ppna BankID p\xE5 din enhet f\xF6r att signera dokumentet.",title:"Signera dokument"}}},start:{action:"Signera med BankID",text:"Acceptera och signera dokumentet med BankID.",title:"Signera med BankID"},success:{text:"$t(answerModal.successText)",textFallback:"$t(answerModal.successTextFallback)",title:"$t(answerModal.successTitle)"}},decline:{component:{inputPlaceholder:"Frivilligt. L\xE4mna en kommentar om varf\xF6r du v\xE4ljer att neka."},start:{action:"Neka",text:"F\xF6r att neka dokumentet var god och bekr\xE4fta genom att klicka p\xE5 knappen nedanf\xF6r.",title:"Neka dokumentet"},success:{text:"Tack f\xF6r att du l\xE4mna ett svar.",title:"Du har nekat dokumentet."}},signature:{component:{draw:{canvasLabel:"Rita signatur",tab:"Rita"},subTitle:"Hur vill du signera?",terms:"Genom att signera dokumentet godk\xE4nner jag att den elektroniska signaturen \xE4r en representation av min handskrivna signatur och att den \xE4r lika giltig.",text:{canvasLabel:"F\xF6rhandsgranskning",nameLabel:"Signerad av",namePlaceholder:"Skriv ditt namn",tab:"Skriv"}},start:{action:"Signera & acceptera",text:"",title:"Acceptera dokumentet"},success:{text:"$t(answerModal.successText)",textFallback:"$t(answerModal.successTextFallback)",title:"$t(answerModal.successTitle)"}},versionError:{accept:{title:"Gick inte att signera dokumentet"},decline:{title:"Gick inte att neka dokumentet"},text:"Dokumentet har modifierats medan du har l\xE4st den. V\xE4nligen ladda om och ta del av det nya dokumentet f\xF6r att l\xE4mna svar.",btn:"Ladda om"},successText:"N\xE4r dokumentet har blivit signerat av alla parter kommer du f\xE5 en kopia skickat till din e-post {{email}} med en l\xE5st version av dokumentet.",successTextFallback:"N\xE4r dokumentet har blivit signerat av alla parter kommer du p\xE5 den h\xE4r webbsidan kunna ladda ner en l\xE5st version av dokumentet.",successTextFallbackSingle:"Dokumentet \xE4r nu signerat och komplett.",successTextSingle:"En bekr\xE4ftelse har skickats till e-posten {{email}} med en l\xE5st version av dokumentet.",successTitle:"Du har signerat dokumentet."},appBrand:YPe,approved:"godk\xE4nt",approx:"ca",cancel:"Avbryt",chapters:{answerButtons:{approveDescription:"Vi har meddelat {{- sender}} att dokumentet \xE4r godk\xE4nt.",approveTitle:"Dokumentet \xE4r godk\xE4nt!",denyDescription:"Vi har meddelat {{- sender}} att du inte \xE4r intresserad.",denyTitle:"Dokumentet \xE4r nekat",editPropDes:"Redigera fastighetsbeteckning",enterPropDes:"Ange fastighetsbeteckning",inPersonSignatureHint:"Du har blivit markerad f\xF6r att skriva under en fysisk kopia av detta dokument. Om du ist\xE4llet vill skriva under digitalt, kontakta",waitingDescription:"V\xE4ntar p\xE5 {{remaining}} st fler ska l\xE4mna svar.",youHave:"Du har "},articleItem:{eligibleForDeduction:"Ber\xE4ttigad f\xF6r {{type,deepNested:deduction}}-avdrag"},articleList:{changeShowVatTooltip:"\xC4ndra till att visa {{type}}",title:"Arbetsmoment / varor"},packageGroup:{errorCallout:"V\xE4lj minst ett alternativ",selectableOptions:"Valbara alternativ"},packageItem:{add:"L\xE4gg till paket",select:"V\xE4lj paket",selected:"Valt paket"},parties:{allRiskAndLiability:"Har allrisk- och ansvarsf\xF6rs\xE4kring",fTax:"Har F-skatt"},pricingSummary:{blocks:{approx:"Ungef\xE4rligt pris",deductionSubValue:"Totalpris utan avdrag {{price}}",maxPrice:"Maxpris",maxPriceVat:"Maxpris {{vat}}",net:"Netto",price:"Pris",rounding:"\xD6resavrundning",subTitleArticles:"Varav varor / moment med fast pris",summary:"Sammanst\xE4llning",total:"Total",typeDeduction:"Efter {{type,deepNested:deduction}}-avdrag"},placeholder:{description:"V\xE4lj vilket paket som passar dig b\xE4st genom att klicka p\xE5 ",descriptionBold:"V\xE4lj-knappen",title:"V\xE4lj ett paket"},terms:{houseWork:"Totalpriset efter skattereduktion f\xF6r {{type,deepNested:deduction}}-arbete f\xF6ruts\xE4tter att arbetet kvalificerar f\xF6r skattereduktion, att best\xE4llaren har det angivna utrymmet f\xF6r skattereduktion samt att det inte redan har utnyttjats f\xF6r annat {{type,deepNested:deduction}}-arbete. Best\xE4llaren ansvarar sj\xE4lv f\xF6r att kontrollera dess uppgifter.",houseWorkApprox:"Priset f\xF6r arbetet \xE4r ungef\xE4rligt. T\xE4nk p\xE5 att priset kan skilja sig med 15%. Om det g\xE4ller markarbeten rivningsarbeten eller lik. kan priset skilja sig med 25%. L\xE4s mer om detta i de allm\xE4nna best\xE4mmelserna.",reverseVat:"Notera att omv\xE4nd skattskyldighet g\xE4ller."}},termsDisclaimer:{description:"Genom att godk\xE4nna dokumentet accepterar du de ",termsAndConditions:"allm\xE4nna villkoren",title:"Villkor"}},close:"St\xE4ng",company:"f\xF6retag",deduction:$l.deduction,denied:"nekat",deny:"Neka",denyModal:{denyButton:"Neka dokument",helpfulInformation:"Vi meddelar {{- senderName}} p\xE5 {{- senderCompany}} att du har valt att neka dokumentet.",otherPlaceholder:"Frivilligt. L\xE4mna en kommentar om varf\xF6r du v\xE4ljer att neka dokumentet.",subTitle:"Bekr\xE4fta ditt svar genom att klicka p\xE5 Neka.",successTitle:"Du har nekat dokumentet",thanksAnswer:"Tack f\xF6r ditt svar!",title:"Neka dokument"},detail_plural:"detaljer",document:"Dokument",document_plural:"Dokument",documentDetails:{subTitle:"Information om dokumentet."},documentTemplateView:{emailTemplate:{expires:{content:"$t(documentTemplateView.reminder) $t(documentTemplateView.emailTemplate.first.content)",subject:"$t(documentTemplateView.reminder) $t(documentTemplateView.sharedSubject)",text:`$t(documentTemplateView.emailTemplate.expires.title) $t(documentTemplateView.emailTemplate.expires.subject). $t(documentTemplateView.readMoreAndReply)
350
350
 
351
351
  {{docLink}}`,title:"$t(documentTemplateView.emailTemplate.first.title)"},first:{content:"Du har f\xE5tt ett dokument fr\xE5n {{company.name}}. Klicka p\xE5 knappen f\xF6r att l\xE4sa mer och l\xE4mna ett svar.",subject:"$t(documentTemplateView.sharedSubject)",text:`$t(documentTemplateView.emailTemplate.first.title) $t(documentTemplateView.emailTemplate.first.subject). $t(documentTemplateView.readMoreAndReply)
@@ -536,7 +536,7 @@ Gl\xF6m inte bort att l\xE4sa dokumentet fr\xE5n {{company.name}}. L\xE4s mer oc
536
536
 
537
537
  {{docLink}}`}}},expires:{type:"object",required:["subject","title","content"],properties:{subject:{type:"string",default:"P\xE5minnelse! Dokumentet - {{document.data.name}} - beh\xF6ver ditt svar"},title:{type:"string",default:"Hej{{clientFirstName}}!"},content:{type:"string",default:"Dokumentet fr\xE5n {{company.name}} l\xF6per snart ut, l\xE4mna ett svar innan det \xE4r f\xF6r sent. Klicka p\xE5 knappen f\xF6r att l\xE4sa mer och l\xE4mna ett svar."},text:{type:"string",default:`Hej{{clientFirstName}}! Du har ett dokument fr\xE5n {{company.name}} d\xE4r giltighetstiden snart g\xE5r ut. L\xE4mna ett svar innan det blir f\xF6r sent p\xE5:
538
538
 
539
- {{docLink}}`}}}}},Wm={isEditable:!1,nodes:[{itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.first.subject",text:"data.emailTemplate.first.text",title:"data.emailTemplate.first.title",content:"data.emailTemplate.first.content"}}]},Fm={isEditable:!1,nodes:[{itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.first.text"}}]},uk={type:"object",default:{useVat:Me.brand==="cling",vatType:"vat",rounding:{enabled:Me.brand==="cling",interval:Me.brand==="cling"?100:1,show:Me.brand==="cling"}}},lk={$ref:`${Me.api.baseUrl}/schemas/css/1.json`,default:{'[data-typography="title"]':{fontFamily:"Inter",fontSize:"56px",fontWeight:800},h1:{fontFamily:"Inter",fontSize:"48px",fontWeight:800},h2:{fontFamily:"Inter",fontSize:"36px",fontWeight:700},h3:{fontFamily:"Inter",fontSize:"21px",fontWeight:600},blockquote:{fontFamily:"Inter",fontSize:"18px",borderLeftStyle:"solid",borderLeftWidth:"3px",borderColor:"currentColor"},p:{fontFamily:"Inter",fontSize:"16px"}}},dk={type:"object",default:{}},ck={anyOf:[{type:"string"},{type:"null"}]},fk={anyOf:[{type:"string"},{type:"null"}]},mk={anyOf:[{type:"string"},{type:"null"}]},pk={$ref:`${Me.api.baseUrl}/schemas/price/1.json`},hk={type:"string",format:"date-time"},vk={type:"object"},KU={reminders:ld,smsTemplate:ok,emailTemplate:sk,emailView:Wm,smsView:Fm,formSettings:uk,sender:dk,name:ck,senderString:fk,receiverString:mk,prices:pk,css:lk,expiresAt:hk,fields:vk};class KOe{constructor({data:e,clients:r=[],useVat:n,rounding:a,currency:o}){if(!e)throw new Error("Missing param data");this._data=e,this._clients=r,this._useVat=n,this._rounding=a,this._currency=o}get data(){return this._data}get useVat(){return this._useVat}get rounding(){return this._rounding}get title(){return this._data.title}get type(){return this._data.type}get selectedPackages(){return this.packages.filter(e=>e.isSelected)||[]}get selectedArticles(){return this.selectedPackages.reduce((e,{articles:r})=>[...e,...r],[])}get priceType(){return te(this,"selectedPackages[0].prices.type","fixed")}get currency(){return te(this,"selectedPackages[0].prices.currency")||this._currency}get maxTotal(){return this.priceType==="openAccMaxPrice"?this.selectedPackages.reduce((e,{prices:r})=>e+r.maxTotal,0):null}get houseWorkManualAmount(){return this.selectedPackages.some(({prices:e})=>te(e,"region.houseWorkManualAmount",null)!==null)?this.selectedPackages.reduce((e,{prices:r})=>{const{houseWorkManualAmount:n}=r.region||{};return n?e+n:e},0):null}get prices(){return Om({type:this.priceType,currency:this.currency,articles:this.selectedArticles,clients:this._clients,maxTotal:this.maxTotal,region:{country:"sweden",houseWorkManualAmount:this.houseWorkManualAmount},useVat:this._useVat,rounding:this._rounding})}get packages(){return this._data.packages.map(e=>({...e,type:this.type,prices:Om({type:te(e,"data.prices.type","fixed"),currency:te(e,"data.prices.currency")||this.currency,articles:e.articles,clients:e.clients,maxTotal:te(e,"data.prices.maxTotal",null),region:{country:"sweden",houseWorkManualAmount:te(e,"data.prices.region.houseWorkManualAmount",null)},useVat:this._useVat,rounding:this._rounding})}))||[]}get articles(){return this.packages.reduce((e,{articles:r})=>[...e,...r],[])}getPackageById(e){return this.packages.find(({packageId:r})=>r===e)}}class XOe{constructor({data:e={},articles:r=[],clients:n=[],useVat:a,rounding:o,currency:i}){if(!e)throw new Error("Missing param data");this._data=Object.keys(e||{}).reduce((s,u)=>({...s,[u]:new KOe({data:{...e[u],packages:e[u].packages.map(l=>({...l,articles:r.filter(({packageId:d})=>d===l.packageId),clients:n}))},clients:n,useVat:a,rounding:o,currency:i})}),{})}get packages(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].packages],[])}get selectedPackages(){return this.packages.filter(({isSelected:e})=>e)}get selectedArticles(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].selectedArticles],[])}get selectedIds(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].packages.filter(({isSelected:n})=>n).map(({packageId:n})=>n)],[])}get groups(){return Object.keys(this._data).map(e=>this._data[e])}get groupsPrices(){return(this.groups||[]).map(({prices:e})=>e)}getPackageGroupById(e){const r=Object.keys(this._data).find(n=>this._data[n].packages.find(({packageId:a})=>a===e));return this._data[r]}getPackageGroupUniqId(e){return this._data[e]||{}}getPackageById(e){const r=this.getPackageGroupById(e);return r?r.getPackageById(e):{}}}function JOe(t){if(!t||!t.data)return t;const{brand:e}=Me,r={useVat:e==="cling",vatType:"vat",rounding:{enabled:e==="cling",interval:e==="cling"?100:1,show:e==="cling"}};t.data.formSettings||(t.data.formSettings={});const n=D3(r);return Object.keys(n).forEach(a=>{function o(i,s,u){_Te(i[s])?Object.keys(i[s]).forEach(l=>{o(i[s],l,u)}):Array.isArray(i[s])?i[s].forEach((l,d)=>{o(i[s],d,u)}):typeof te(i,s)>"u"&&Xt(i,s,u)}o(t.data.formSettings,a,n[a])}),t}class QOe{constructor(e,{computedPricing:r=!0,isPreview:n=!1,readPrices:a=!0,props:o={},settingsTheme:i={}}={}){if(!e)throw new Error("Missing param data");this._doc=e,this._doc=wPe(this._doc,i),this._doc=JOe(this._doc),this._computedPricing=r,this._theme=i,this._props=o,this._readPrices=a,this._isPreview=n,this._pdfOptions={},this._template=this._doc.template?new fi(this._doc.template):null,this._dirtyKeys={}}get data(){return this._doc.data}deleteProperty(e){ITe(this,`_doc.${e}`)}get receiverString(){return te(this._doc,"data.receiverString")||te(this._props,"defaultReceiverString")||be.t("_common:receiver",{lng:this.language,postProcess:"capitalize"})}get senderString(){return te(this._doc,"data.senderString")||te(this._props,"defaultSenderString")||be.t("_common:sender",{lng:this.language,postProcess:"capitalize"})}get sender(){const e=te(this._doc,"data.sender",{});return{company:{...this._doc.company&&{publicId:this._doc.company.publicId,name:this._doc.company.name,orgNo:this._doc.company.organisationNumber,phone:this._doc.company.phone,logotype:this._doc.company.LogotypePublicId?`${Me.api.baseUrl}/file/${this._doc.company.LogotypePublicId}/download`:null,hasFSkatt:this._doc.company.fSkatt,hasInsurance:this._doc.company.insurance,region:this._doc.company.region},...td(e.company)},user:{...this._doc.companyUser&&{name:`${this._doc.companyUser.firstname||""} ${this._doc.companyUser.lastname||""}`.trim(),email:this._doc.companyUser.email,cellphone:this._doc.companyUser.cellphone,avatar:this._doc.companyUser.AvatarPublicId?`${Me.api.baseUrl}/file/${this._doc.companyUser.AvatarPublicId}/download`:null},...td(e.user)}}}set sender(e){e.company&&(this._doc.company=e.company),e.user&&(this._doc.companyUser=e.user)}get senderClient(){return this._doc.senderClient?{...this._doc.senderClient,isSender:!0}:null}get viewer(){return this._doc.viewerId?this.clients.find(({publicDocumentId:r})=>r===this._doc.viewerId):null}get remainingSignatures(){return this.clients.filter(({documentRole:e})=>["signee","approver"].includes(e)).reduce((e,r)=>te(r,"answer.didAccept")?e:e+1,0)}get answerActions(){const e={canAnswer:!1,hasAnswered:!1,showActions:!1,waitingForOthers:!1},r=!!te(this.viewer,"answer"),n=!!te(this.viewer,"answerMethod.accept",!1)&&["signee","approver"].includes(te(this.viewer,"documentRole")),a=["sent","draft"].includes(this.status);return n&&a&&!r&&(e.canAnswer=!0),e.showActions=n||this.isPreview,e.hasAnswered=r,e.waitingForOthers=r&&a,e}get id(){return this._doc.id||null}set id(e){this._doc.id=e}get publicId(){return this._doc.publicId||null}get name(){return this.data.name||null}set name(e){this.data.name=e}get articles(){return[...this.packageGroups.selectedArticles,...this.allArticles.filter(({packageId:e})=>!e)]}get allArticles(){return this._doc.articles||[]}set allArticles(e){this._doc.articles=e}get createdAt(){return this._doc.createdAt}get sentAt(){return this._doc.sentAt||null}get lastSentAt(){return this._doc.lastSentAt||null}get expiresAt(){return this.data.expiresAt||null}set expiresAt(e){this.data.expiresAt=e}get acceptedAt(){return this._doc.acceptedAt||null}get projectId(){return this._doc.projectId||null}get docNumber(){return this._doc.docNumber||{series:"document",value:null}}set docNumber(e){this._doc.docNumber=e}get status(){return this._doc.status||null}get useSignOrder(){return this._doc.useSignOrder||!1}get clients(){return this._doc.clients||[]}set clients(e){this._doc.clients=e}get recipients(){return[...this.senderClient?[this.senderClient]:[],...this.clients]}get template(){return this._template}get isPreview(){return this._isPreview||!1}get isHidden(){return this._doc.isHidden||!1}get excludeFromStats(){return this._doc.excludeFromStats||!1}get setPricesIncVat(){return te(this,"data.formSettings.setPricesIncVat",null)&&this.useVat}get formSettings(){return te(this,"data.formSettings")}get useVat(){return this.formSettings.useVat}get rounding(){return this.formSettings.rounding}get vatType(){return this.formSettings.vatType}get rejectReasons(){const{rejectReasons:e}=this.data;if(!e)return null;const r=ot(e);return r==="array"?e:r==="object"?Object.keys(e).map(n=>e[n]):null}get personalMessage(){return this.data.personalMessage||null}get sourceDocument(){return this.data.sourceDocument||null}get reminders(){return this._doc.data.reminders||[]}set reminders(e){this._doc.data.reminders=e}set packageGroups(e){this._doc.data.packageGroups=e}get packageGroups(){return new XOe({data:this._doc.data.packageGroups,articles:this.allArticles,clients:this.clients,useVat:this.useVat,rounding:this.rounding,currency:this.currency})}get events(){const{events:e=[]}=this._doc,r=e.filter(a=>a.code!=="statusChanged"||["accepted","denied"].includes(a.data.status)),n=this.clients.filter(a=>["signee","approver"].includes(a.documentRole)).length;for(const[a,o]of r.entries()){const i=r[a+1];!i||i.code==="statusChanged"&&(i.data.status!==o.code||n<=1)&&r.splice(a+1,1)}return["viewed","mailOpened"].reduce((a,o)=>mPe(a,o),r)}get scheduledFirstDelivery(){const{reminders:e=[]}=this.data;return e.length&&e.find(r=>r.type==="first")||null}get type(){return this.categoryTags[0]}get categoryTags(){return te(this._doc,"tags",[]).reduce((e,r)=>[...e,r.name],[])}get language(){return te(this,"_doc.language","en")}set language(e){return Xt(this,"_doc.language",e)}get externalReferences(){return te(this,"_doc.externalReferences",[])}set externalReferences(e){return Xt(this,"_doc.externalReferences",e)}get currency(){return te(this,"_doc.currency")}get tags(){return te(this,"_doc.tags",[])}set tags(e){return Xt(this,"_doc.tags",e)}setTag(e,r){const n=this.tags.find(a=>a.type===e);n?n.name=r:this.tags.push({type:e,name:r})}get readPrices(){return this._readPrices}get prices(){return pPe(this._doc)}get dynamicPrices(){const{groups:e}=this.packageGroups,r={min:0,max:0};return(e||[]).forEach(({type:n,prices:a={},packages:o,articles:i,useVat:s,rounding:u})=>{const{total:l,type:d}=a;let f={min:l,max:l};if(o&&o.length){if(n==="radio")f=o.reduce((m,{prices:c})=>(m.min===null&&(m.min=c.total),c.total>m.max&&(m.max=c.total),c.total<m.min&&(m.min=c.total),m),{...f,min:null});else if(n==="checkbox"){const[m,c]=o.reduce(([p,h],v)=>v.toggable?[[...p,v],h]:[p,[...h,v]],[[],[]]);if(m.length){const{maxTotal:p,houseWorkManualAmount:h}=o.reduce((g,{prices:_})=>(g.maxTotal+=_.maxTotal,g.houseWorkManualAmount+=te(_,"region.houseWorkManualAmount",0),g),{maxTotal:0,houseWorkManualAmount:0}),{total:v}=Om({type:d,articles:i,currency:this.currency,clients:this.clients,maxTotal:p,region:{country:"sweden",houseWorkManualAmount:h},useVat:s,rounding:u});f.max=v}c.length?f.min=c[0].prices.total:f.min=m.reduce((p,h)=>((p===null||p>h.prices.total)&&(p=h.prices.total),p),null)}}r.min+=f.min,r.max+=f.max}),r}get cachedInvoices(){const{cachedInvoices:e}=this._doc;return!e||!e.invoices?[]:Object.keys(e.invoices).map(r=>e.invoices[r])}get invoiceIds(){const{cachedInvoices:e}=this._doc;return!e||!e.invoices?[]:Object.keys(e.invoices)}get invoicedAmount(){const{cachedInvoices:e}=this._doc;if(!e||!e.invoices)return 0;const r=e.invoices;return Object.keys(r).reduce((n,a)=>r[a]&&r[a].totalAmount?n+r[a].totalAmount:n,0)}set props(e){this._props=e}get theme(){const e={background:"https://images.unsplash.com/photo-1468233748640-b31327627610?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&w=1280&q=80",backgroundFilter:null,showClingLogo:null,showPriceSummary:!0,priceSummaryBackground:"hsl(217, 95%, 39%)",headingColor:"hsl(231, 100%, 50%)",fontFamily:null},r=te(this._doc,"data.theme",{});return{...e,...this._theme,...td(r)}}set theme(e){this._theme=e}set pdfOptions(e){this._pdfOptions=e}getAllNodesWithType(e){return(te(this,"template.views.read.nodes")||[]).filter(({itemType:n})=>n===e)}get attachedFiles(){const e=[];return this.getAllNodesWithType("attachments").forEach(r=>{const n=r.value.attachments;if(!n)return;const a=te(this,n);a&&Array.isArray(a)&&e.push(...a)}),e}get readLayout(){return this.getReadLayout()}getReadLayout({showHiddenNodes:e=!1}={}){if(!this.template)return[];const r={...this.template.defaultData,...this._doc,data:{...this._doc.data,...this.clients.length&&{clients:this.clients.filter(o=>o.documentRole!=="recipient")},...this._computedPricing&&{prices:this.prices},sender:{...this.sender.company,...this.sender.user,name:this.sender.user.name,avatar:this.sender.user.avatar,...this.sender.user.email&&{email:this.sender.user.email},...this.sender.user.cellphone&&{cellphone:this.sender.user.cellphone},type:"company",companyName:this.sender.company.name},receiverString:this.receiverString,senderString:this.senderString}},a=[...GOe({data:r,tree:this.template.views.read.nodes,bindData:!0,customProps:this._props,pdfOptions:this._pdfOptions})];return e?a:rU({nodes:a,data:r})}get fields(){return{...hPe(this._doc),...this._doc.data.fields}}get textTemplateMap(){const{fields:e}=this;return Object.keys(e).reduce((r,n)=>({...r,[e[n].key]:e[n].label}),{})}get textTemplateItems(){const e=this.textTemplateMap||{};return Object.keys(e).reduce((r,n)=>[...r,{id:n,label:e[n],tooltip:te(this._doc,n)}],[])}get usedFields(){return ak(this.data)}get hasAnswers(){return this.clients.filter(({documentRole:e})=>["signee","approver"].includes(e)).some(({answer:e})=>!!e)}removeAnswer(){this._doc.acceptedAt=null,this._doc.status="draft",this.clients.forEach(e=>{e.answer=null})}setAnswerMethod({accept:e,deny:r}){if(typeof e>"u"&&typeof r>"u")throw new Error("Missing param accept or deny");this.removeAnswer(),e&&(Xt(this,"_doc.data.defaultAnswerMethod.accept",e),Xt(this,"_doc.template.defaultAnswerMethod.accept",e)),r&&(Xt(this,"_doc.data.defaultAnswerMethod.deny",r),Xt(this,"_doc.template.defaultAnswerMethod.deny",r)),this.clients.filter(({documentRole:n})=>["signee","approver"].includes(n)).forEach(n=>{n.answer=null,e&&(n.answerMethod.accept=e),r&&(n.answerMethod.accept=e)})}resetReminders(){const{template:e}=this,{reminders:r}=e;this.reminders=r}resetDefaultSelected(){const e=this._doc.data.packageGroups;!e||(this.packageGroups=Object.keys(e).reduce((r,n)=>({...r,[n]:{...e[n],packages:(e[n].packages||[]).map(a=>({...a,isSelected:a.isSelectedDefault||e[n].type==="single"}))}}),{}))}clone(){const e=this;return Object.assign(Object.create(Object.getPrototypeOf(e)),JSON.parse(JSON.stringify(e)))}duplicate(){const e=this.clone();return e.id=null,e._doc._id=null,e.deleteProperty("data.expiresAt"),e.deleteProperty("data.rejectReasons"),e.deleteProperty("company"),e.deleteProperty("companyUser"),e.deleteProperty("senderClient"),e.clients=e.clients.map(r=>ni(r,["id","_id","publicDocumentId","answer"])),e.allArticles=e.allArticles.map(r=>ni(r,["id","_id","createdAt","updatedAt","deletedAt"])),e.resetReminders(),e.resetDefaultSelected(),e}copyTemplateDocDefault({keepClients:e=!1}={}){const{template:r,articles:n,data:a,tags:o,docNumber:i,language:s,currency:u,clients:l,useSignOrder:d}=this.duplicate().getRawData();Object.keys(a).forEach(m=>{te(r,`validationSchema.properties.data.properties.${m}`)?Xt(r,`validationSchema.properties.data.properties.${m}.default`,a[m]):Object.keys(KU).includes(m)&&Xt(r,`validationSchema.properties.data.properties.${m}`,{...KU[m],default:a[m]})});const f={articles:n,tags:o,docNumber:i,currency:u,useSignOrder:d};return delete i.value,e&&(f.clients=l),Object.keys(f).forEach(m=>{f[m]&&Xt(r,`validationSchema.properties.${m}.default`,f[m])}),r.language=s,r}getRawData(){return{...this._doc,data:{...this._doc.data,prices:this.prices,name:this.name||""}}}get allowVerification(){return this.status==="accepted"||this.clients.some(({answerMethod:e})=>e&&e.accept==="inPerson")}async formatPhone(e,{defaultRegion:r}={}){return Epe(e,{defaultRegion:r||this.sender.company.region})}setDirty(e){this._dirtyKeys[e]=!0}isDirty(e){return!!this._dirtyKeys[e]}$t(e,r={},{fnType:n="t"}={}){const a={lng:this.language,...r},o=["exVat","incVat","vat.exVat","vat.incVat"],i=e&&e.includes(":")?e.split(":")[1]:e;return i==="vat"?od[n](`vat.${this.vatType}`,{...a}):(o.includes(i)&&(a.thing=od[n](`vat.${this.vatType}`)),od[n](e,{...a}))}$tc(e,r={}){return this.$t(e,r,{fnType:"tc"})}}const ZOe=t=>t.map(e=>({...e,price:0,totalAmount:0,invoicedAmount:0,showPrice:!1}));class Js extends QOe{constructor({data:e,documentOptions:r={},can:n,getters:a,updateSender:o=!1}){if(!a)throw new Error("Missing param getters");let i=e;n&&!n("prices","read")&&te(e,"articles",[]).length&&(i={...e,articles:ZOe(e.articles)});const{senderString:s,receiverString:u,fSkatt:l,insurance:d,offerBrandingBackgroundUrl:f,documentThemeBackgroundFilter:m,documentShowPriceSummary:c,documentThemePriceBackground:p,documentThemePrimaryColor:h,presentationFontFamily:v,showClingLogo:g}=a["settings/allCompanySettings"]||{};super(i,{...r,props:{defaultSenderString:s,defaultReceiverString:u,...r.props},readPrices:n?n("prices","read"):!0,isPreview:!0,settingsTheme:td({background:f,backgroundFilter:m,showPriceSummary:c,priceSummaryBackground:p,headingColor:h,fontFamily:v,showClingLogo:g})}),this._documentOptions=r,this._can=n,this._defaultScope="documents",this._getters=a;const _=o||!Object.keys(te(this,"_doc.company",{})).length||!Object.keys(te(this,"_doc.companyUser",{})).length,y=_?this._doc.companyId?a["companies/companyById"](this._doc.companyId):a["application/company"]:this._doc.company;y&&_&&(y.fSkatt=l,y.insurance=d);const b=_?this._doc.companyUserId?a["companyUsers/referenceById"](this._doc.companyUserId):a["application/user"]:this._doc.companyUser;this.sender=this._documentOptions.sender||{company:y,user:b}}can(e,r=null,n=null){if(!this._can)return!0;if(typeof e!="string")throw new Error("Permission must be of type String");return this._can(r||this._defaultScope,e,n||this.id)}get companyId(){return this._doc.companyId}get companyUserId(){return this._doc.companyUserId}resetReminders(){super.resetReminders();let{reminders:e}=this;if(!e.length)return;const{_getters:r}=this,n=r["settings/reminderSettings"],a=(o,i)=>e.filter(({type:s})=>s===o).map(s=>(s.sendDays=i,!0));typeof n.notAnswered<"u"&&a("reminder",n.notAnswered),typeof n.notViewed<"u"&&a("viewed",n.notViewed),typeof n.expires<"u"&&a("expires",n.expires),e=e.filter(({type:o,sendDays:i})=>o==="first"||i),this.reminders=e}clone(){return new Js({data:JSON.parse(JSON.stringify(this._doc)),documentOptions:this._documentOptions,can:this._can,getters:this._getters})}async isValid(){const e=this.getRawData();try{return await Kr.validate(e),!0}catch{return!1}}}const eEe=t=>({id:null,name:"Default Empty",validationSchema:{type:"object",required:["clients","data"],properties:{tags:{type:"array",default:[{name:"document",type:"category"}]},docNumber:{type:"object",properties:{series:{type:"string",default:"document"}}},clients:{type:"array",default:[]},data:{type:"object",required:["name"],properties:{partiesString:{anyOf:[{type:"string"},{type:"null"}],default:be.t("components:document.chapters.parties.title",{lng:t})},"header-kh0loiq7":{default:{layout:"vertical",baseStyle:{textAlign:"left",textColor:"#f0ce84"},items:[{type:"media",size:35,media:{type:"image",resourceUrl:"https://images.unsplash.com/photo-1581660545544-83b8812f9516?ixlib=rb-1.2.1&auto=format&fit=crop&w=1800&q=80"}},{type:"content",size:65,media:{type:"color",backgroundColor:"#17346e"},value:{preText:"",documentName:'<p data-typography="title"></p>',postText:"<p></p>",showLogo:!0,logotype:""}}]},$ref:`${Me.api.baseUrl}/schemas/header/2.json`},packageGroups:{default:{kh0lol91:{type:"",title:be.t("components:document.chapters.packageGroup.title",{lng:t}),hideGroupPrice:!1,packages:[]}},$ref:`${Me.api.baseUrl}/schemas/packageGroups/1.json`},"title-kh0los53":{anyOf:[{type:"string"},{type:"null"}]},"content-kh0los54":{anyOf:[{type:"string"},{type:"null"}]},defaultAnswerMethod:{default:{accept:"signature",deny:"button"},$ref:`${Me.api.baseUrl}/schemas/answer/1.json`},name:ck,sender:dk,senderString:fk,receiverString:mk,prices:pk,css:lk,fields:vk,expiresAt:hk,formSettings:uk,reminders:ld,smsTemplate:ok,emailTemplate:sk}}}},views:{edit:{isEditable:!0,nodes:[]},read:{isEditable:!0,nodes:[{itemId:"header-kh0loiq7",itemType:"header",value:{header:"data.header-kh0loiq7"}},{itemId:"parties",itemType:"section",value:{title:"data.partiesString"},children:[{itemId:"clients",itemType:"subSection",value:{title:"data.receiverString"},children:[{itemId:"clientsList",itemType:"party",value:{parties:"clients"}}]},{itemId:"sender",itemType:"subSection",value:{title:"data.senderString"},children:[{itemId:"senderList",itemType:"party",value:{parties:"data.sender"}}]}]},{itemId:"packageGroup-kh0lol91",itemType:"section",value:{title:"data.packageGroups.kh0lol91.title"},children:[{itemId:"group",itemType:"selectionGroup",value:{groupId:"kh0lol91",type:"data.packageGroups.kh0lol91.type",packages:"data.packageGroups.kh0lol91.packages"}}]},{itemId:"titleAndText2",itemType:"section",value:{title:"data.title-kh0los53"},children:[{itemId:"kh0los52",itemType:"html",value:{content:"data.content-kh0los54"}}]},{itemId:"answer",itemType:"answer",value:{defaultAnswerMethod:"data.defaultAnswerMethod"}}]},email:Wm,sms:Fm},isVisible:!0,language:t}),XU={default:t=>{const e=eEe(t);return{...e,views:Object.keys(e.views).reduce((r,n)=>({...r,[n]:{...e.views[n],nodes:ik(e.views[n].nodes,{setId:!0})}}),{})}},empty:t=>({id:null,name:"Empty",validationSchema:{type:"object",required:["clients","data"],properties:{tags:{type:"array",default:[{name:"document",type:"category"}]},docNumber:{type:"object",properties:{series:{type:"string",default:"document"}}},clients:{type:"array",default:[]},data:{type:"object",required:["name"],properties:{name:ck,sender:dk,senderString:fk,receiverString:mk,prices:pk,css:lk,fields:vk,expiresAt:hk,formSettings:uk,reminders:ld,smsTemplate:ok,emailTemplate:sk}}}},views:{edit:{isEditable:!0,nodes:[]},read:{isEditable:!0,nodes:[]},email:{...Wm,nodes:ik(Wm.nodes,{setId:!0})},sms:{...Fm,nodes:ik(Fm.nodes,{setId:!0})}},isVisible:!0,language:t})},{FORM_CLEAR_FORM:jm,CLEAR_DOCUMENT2_ANSWERS:JU,DO_SEND_DOCUMENT2:tEe,SHOW_MESSAGE:rEe,LOAD_ENDCUSTOMER:nEe,UPDATE_TEMPLATE:aEe,DO_CREATE_TEMPLATE:iEe}=Oe,{LOAD_DOCUMENT2_FORM:oEe,LOAD_DOCUMENT2_PUBLIC_FORM:sEe,LOAD_DUPLICATE_DOCUMENT2_FORM:QU,SAVE_DYNDOC_FORM:uEe,CLEAR_DYNDOC_FORM:ZU,DO_SAVE_DYNDOC:eH,HANDLE_DOCUMENT2_EDIT:lEe,SAVE_TEMPLATE_FORM:dEe,LOAD_EXTERNAL_FORM_FIELDS:gk}=FV,{SET_FORM:yk,SET_FORM_VALUE:tH}=De.forms;async function cEe({id:t=null,templateId:e=null,rootState:r,state:n,rootGetters:a,dispatch:o}){if(!r)throw new Error("Missing parameter rootState");if(!n)throw new Error("Missing parameter state");if(!a)throw new Error("Missing parameter rootGetters");if(!o)throw new Error("Missing parameter dispatch");let i=!1;const s=a["forms/document"];if(!s)return!1;const{name:u,params:{id:l}}=r.route||{},{id:d,template:{id:f}}=s;return["documentForm"].includes(u)&&(t?d&&d===l&&d===t&&(Tt.debug("DYNDOC_FORM: Using existing store data existing id match route"),i=!0):!d&&!t&&(e==="default"&&!f||e===f)&&(Tt.debug("DYNDOC_FORM: Using existing store data as no ids was found"),i=!0)),i&&Tt.debug("DYNDOC_FORM: Dont reload as forms/document2 is already defined"),i}const fEe={async[oEe]({commit:t,rootState:e,rootGetters:r,state:n,dispatch:a},{documentId:o=null,templateId:i=null,addonDocumentSourceId:s=null,projectId:u=null,clientId:l=null,formData:d=null,_formData:f=null,dummyClient:m=!1}={}){if(await cEe({id:o,templateId:i,rootState:e,state:n,rootGetters:r,dispatch:a})&&!s)return;let p={id:null,companyUserId:this.getters["application/user"].id,language:this.getters["settings/getCompanyUserSetting"]("defaultLanguage")||"en",currency:this.getters["settings/getCompanyUserSetting"]("defaultCurrency"),data:{},template:null,articles:[],clients:[],...f&&{...f},...d};if(!d){if(o){await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:o});const g=this.getters["documents2/byId"](o);p={...p,...g.getRawData()}}else if(i){let g=["default","empty"].includes(i)?new fi(XU[i](p.language)):this.getters["templates/byId"](i);if(i==="onboardingTemplate"){const{data:_}=await to.get(i);g=new fi(_)}if(g||(await this.dispatch(Oe.LOAD_TEMPLATE,{id:i}),g=this.getters["templates/byId"](i)),!g)throw new Error(`Could not find template by id: '${i}'`);p.template={...g._data,defaultData:g.defaultData}}const v=te(p,"template.defaultData",{});if(p={...p,...v,clients:[...(v==null?void 0:v.clients)||[],...p.clients]},Object.keys(e.settings.company).length||await this.dispatch(Oe.LOAD_SETTINGS_COMPANY),s){await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:s});const g=this.getters["documents2/byId"](s),{publicId:_,clients:y}=g.duplicate();p={...p,projectId:g.projectId,clients:y,data:{...p.data,sourceDocument:{id:s,publicId:_}}}}}if(u&&(p.projectId=u),l){await this.dispatch(nEe,{id:l});const v=r["endCustomers/endCustomerById"](l),g=te(p,"template.defaultData.data.defaultAnswerMethod"),_=Ox(v,{...g&&{answerMethod:g}});p.clients=[...p.clients,_]}if(m){const v=["email"];Un.checkFeature("sms")&&v.push("sms"),p.clients=[...p.clients,{name:"Pernilla P.",email:"pernilla@mail.se",cellphone:"073 123 56 78",documentRole:"signee",type:"individual",deliveryTypes:v}]}if(i==="onboardingTemplate"){const v=r["application/user"]||{},g=r["application/company"]||{},_={type:"company",email:v.email,companyName:g.name||(p.language==="sv"?"Konsulterna AB":"The consultants Corp."),name:v.fullName||(p.language==="sv"?"Test Testson":"John Doe"),...v.cellphone?{cellphone:v.cellphone}:{},...g.region&&{cellphoneRegion:g.region}};p.clients=[...p.clients,Ts({...Sx(),..._})]}const h=te(p,"data.defaultAnswerMethod",null);h&&(p.clients=p.clients.map(v=>te(v,"answerMethod.accept")!=="inPerson"?{...v,answerMethod:h}:v)||[]),t(yk,{key:"document2",formData:{...p,data:{...p.data,...!o&&{reminders:this.getters["forms/getDocumentAccountDefault"]("reminders",{template:new fi(p.template)})}}}}),a(gk)},async[sEe]({commit:t},{formData:e=null}={}){let r={id:null,language:be.lang,currency:this.$brand==="cling"?"SEK":"USD",data:{},template:null,articles:[],clients:[],...e};if(!e){if(!r.template){const o=new fi(XU.default(r.language));r.template={...o._data,defaultData:o.defaultData}}const a=te(r,"template.defaultData",{});r={...r,...a}}r.language==="sv"&&r.data.defaultAnswerMethod&&(r.data.defaultAnswerMethod.accept="bankId");const n=te(r,"data.defaultAnswerMethod",null);n&&(r.clients=r.clients.map(a=>te(a,"answerMethod.accept")!=="inPerson"?{...a,answerMethod:n}:a)||[]),t(yk,{key:"document2",formData:{...r,data:{...r.data}}})},async[QU]({commit:t,dispatch:e},{id:r,publicDocId:n,projectId:a=null,keepClients:o=!1,isPublicForm:i=!1}){if(!r&&!n)throw new Error("Missing parameter id");let s;if(n){const{data:_}=await L3.get(n,{preview:!0});s=new Js({data:_,can:i?null:lo.checkPermission.bind(lo),getters:this.getters})}else await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:r}),s=this.getters["documents2/byId"](r);if(!s)throw new Error("Could not find document to duplicate");const u=s.duplicate(),{defaultData:l}=u.template,{template:d,data:f,articles:m,clients:c,language:p,currency:h,externalReferences:v}=u.getRawData(),g={...l,template:d,articles:m,clients:o?c:[],language:p,currency:h,externalReferences:v,data:{...l.data,...f}};a&&(g.projectId=a),t(yk,{key:"document2",formData:g}),e(gk)},async[dEe](t,{body:e}){try{if(!e)throw new Error("Missing param body");e.id?await this.dispatch(aEe,{id:e.id,body:e}):await this.dispatch(iEe,{body:e}),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!0),this.$router.push({name:"documentFormSelect"}),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!1),await this.dispatch(jm,{key:"_old_document2"}),await this.dispatch(jm,{key:"document2"})}catch(r){this.handleError(r)}},async[uEe]({dispatch:t},{doRedirect:e=!0,doSend:r=!1}={}){try{const n=await t(eH),a=this.getters["documents2/byId"](n),o=!!te(a,"senderClient");return r&&!o&&await this.dispatch(tEe,{id:n}),e?(this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!0),r?this.$router.push({name:"postDocumentSend",params:{id:n}}):Oz({next:"project",projectId:a.projectId},this.$router),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!1)):await t(ZU),n}catch(n){return this.handleError(n),null}},async[ZU](){try{await this.dispatch(jm,{key:"_old_document2"}),await this.dispatch(jm,{key:"document2"})}catch(t){this.handleError(t)}},async[eH]({rootGetters:t,getters:e,commit:r},{showMessage:n=!0}={}){const{document:a}=e;let{id:o}=a;const i=l=>od.t(`documentTemplateView.${l}`,{lng:a.language,interpolation:{prefix:"__",suffix:"__"}}),s=te(a,"data.defaultAnswerMethod",null);s&&(a.clients=a.clients.map(l=>te(l,"answerMethod.accept")!=="inPerson"?{...l,answerMethod:s}:l));const u={...a,data:{...a.data,name:a.data.name||"",smsTemplate:{first:{text:i("smsTemplate.first.text")},reminder:{text:i("smsTemplate.reminder.text")},expires:{text:i("smsTemplate.expires.text")},viewed:{text:i("smsTemplate.viewed.text")}},emailTemplate:{first:{subject:i("emailTemplate.first.subject"),title:i("emailTemplate.first.title"),content:i("emailTemplate.first.content"),text:i("emailTemplate.first.text")},viewed:{subject:i("emailTemplate.viewed.subject"),title:i("emailTemplate.viewed.title"),content:i("emailTemplate.viewed.content"),text:i("emailTemplate.viewed.text")},reminder:{subject:i("emailTemplate.reminder.subject"),title:i("emailTemplate.reminder.title"),content:i("emailTemplate.reminder.content"),text:i("emailTemplate.reminder.text")},expires:{subject:i("emailTemplate.expires.subject"),title:i("emailTemplate.expires.title"),content:i("emailTemplate.expires.content"),text:i("emailTemplate.expires.text")}}},pdfConfig:{locale:od.locale,timeZone:te(Intl.DateTimeFormat().resolvedOptions(),"timeZone")||""}};return delete u.company,delete u.companyUser,o?(a.clearAnswerBeforePut&&(await this.dispatch(JU,{id:o,doFetch:!1}),await this.dispatch(Oe.DO_UPDATE_DOCUMENT2,{id:o,body:{status:"draft"},showMessage:n})),await this.dispatch(Oe.DO_UPDATE_DOCUMENT2,{id:o,body:u,showMessage:n})):(o=await this.dispatch(Oe.DO_CREATE_DOCUMENT2,{body:u}),r(tH,{key:"document2.id",value:o})),t["settings/showOverviewOnboardingOverlay"]&&this.dispatch("settings/UPDATE_SETTINGS",{key:"companyUser",settings:{showOverviewOnboardingOverlay:!1}}),o},async[lEe]({getters:t,dispatch:e},{documentId:r=null}={}){let n;if(r?(await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:r}),n=this.getters["documents2/byId"](r)):{document:n}=t,!n)throw new Error("Missing document");const a=n.id?n.can("modify"):n.can("create"),{id:o,status:i,projectId:s,hasAnswers:u}=n;if(a&&(i==="accepted"||u)){const l=i==="accepted"?"accepted":"hasAnswers";this.dispatch(rEe,{displayType:"dialog",type:"primary",title:be.t(`actions:editDocumentDialog.${l}.title`),message:be.t(`actions:editDocumentDialog.${l}.message`),actions:{cancel:{text:be.t("_common:cancel"),callback:"cancel"},submit:{text:be.t(`actions:editDocumentDialog.${l}.submit`),callback:async()=>{if(l==="accepted")await e(QU,{id:o,projectId:s,keepClients:!0}),this.$router.push({name:"documentForm"});else if(l==="hasAnswers"){await this.dispatch(JU,{id:o,doFetch:!0});const d={name:"documentForm",params:o?{id:o}:{}};this.$router.push(d)}}}}})}else if(a){const l={name:"documentForm",params:o?{id:o}:{}};return this.$router.push(l)}return null},async[gk]({rootGetters:t,getters:e,commit:r}){const{document:n}=e;if((n==null?void 0:n.externalReferences)&&n.externalReferences.length)try{await Promise.all((n.externalReferences||[]).map(async({service:a,type:o,typeId:i})=>{if(o&&i&&a&&t["settings/isAuthenticatedCRM"](a)){const{data:s}=await m1.getFields(a,{type:o,typeId:i,populated:!0});r(tH,{key:"document2.data.fields",value:{...te(n,"data.fields"),...s}})}}))}catch(a){this.handleError(a)}}},mEe={...aPe,...VPe,...HPe,...fEe,async[Vn.FORM_CLEAR_FORM]({commit:t},{key:e}){return t(zn.CLEAR_FORM,{key:e})},async[Vn.SET_FORM]({commit:t},{key:e,formData:r}){return t(zn.SET_FORM,{key:e,formData:r})},async[Vn.SET_FORM_VALUE]({commit:t},{key:e,value:r}){return t(zn.SET_FORM_VALUE,{key:e,value:r})},async[Vn.REMOVE_FORM_VALUE]({commit:t},e){return t(zn.REMOVE_FORM_VALUE,e)},async[Vn.REMOVE_FORM_KEY_VALUE]({commit:t},e){return t(zn.REMOVE_FORM_KEY_VALUE,e)},async[Vn.FORM_RESET_OLD]({commit:t,rootGetters:e},r){const n=e["forms/getFormByKey"](r);return t(zn.SET_FORM,{key:r,formData:n})}},pEe={},hEe={setDocumentField(t,e){const{path:r,value:n}=e,{root:a,prop:o}=fo(t.document,r,!0);Gl(a,{path:o,value:n})}},{SET_FORM:vEe,CLEAR_FORM:gEe,SET_FORM_VALUE:yEe,REMOVE_FORM_VALUE:_Ee,REMOVE_FORM_KEY_VALUE:bEe}=zn,wEe={updateField:Gl,...pEe,...hEe,[vEe](t,{key:e,formData:r}){if(ot(r)==="undefined"){console.warn("FormData was undefined!");return}const n=JSON.parse(JSON.stringify(r)),{root:a,prop:o}=fo(t,e,!0);if(Array.isArray(n))ce.set(a,o,n);else if(typeof n=="object"&&n!==null){const i=Object.assign({},n);ce.set(a,o,i)}else ce.set(a,o,n);if(e.split(".").length!==1){console.warn("Using SET_FORM to set individual values");return}t[`_old_${e}`]=JSON.parse(JSON.stringify(t[e]||{}))},[gEe](t,{key:e}){const{root:r,prop:n}=fo(t,e);ce.set(r,n,{})},[_Ee](t,e){const{root:r,prop:n}=fo(t,e);if(Array.isArray(r)){ce.delete(r,n);return}if(r[n]&&Array.isArray(r[n])){ce.set(r,n,[]);return}if(r[n]&&typeof r[n]=="object"){ce.set(r,n,{});return}r[n]=void 0},[bEe](t,e){const{root:r,prop:n}=fo(t,e);r&&n in r&&delete r[n]},[yEe](t,{key:e,value:r}){const{root:n,prop:a}=fo(t,e,!0),o=ot(r)==="null",i=ot(r)==="array"&&!r.length;if(!o&&n[a]&&ot(n[a])==="array"&&!i&&ot(r)!=="array"){n[a].push(Ts(r));return}if(!o&&ot(n)==="array"&&!i){let s=Ts(r);typeof n[a]=="object"&&n[a]._uniqueId&&(s={...s,_uniqueId:n[a]._uniqueId}),ce.set(n,a,s);return}ce.set(n,a,r)}};function xEe(t){const e={email:!1,sms:!1};return te(t,"clients",[]).forEach(r=>{r.deliveryTypes.indexOf("sms")>-1&&(e.sms=!0),r.deliveryTypes.indexOf("email")>-1&&(e.email=!0)}),e.sms&&!Un.checkFeature("sms")&&(e.sms=!1),e}const kEe={getField:vm,...{document:({document2:t})=>Object.keys(t).length?t:null,deliveryTypes:t=>xEe(t.document2),getDocumentAccountDefault:(t,e,r,n)=>(a,{template:o})=>{let i;if(a==="reminders"){if(i=[],!o)return i;i.push(...o.reminders);const s=(l,d)=>i.filter(({type:f})=>f===l).forEach(f=>{f.sendDays=d}),u=n["settings/reminderSettings"];u.notAnswered!==void 0&&s("reminder",u.notAnswered),u.notViewed!==void 0&&s("viewed",u.notViewed),u.expires!==void 0&&s("expires",u.expires),i=i.filter(({type:l,sendDays:d})=>l==="first"||d)}return i}},...{documentField:t=>e=>{const{document:r={}}=t;let n=e.split(".");n[0]==="document"&&(n=[...n.slice(1)]);let a=r[n[0]];return n.length>1&&(a=n.reduce((o,i)=>o&&o[i],r)),a},isIndivid:t=>{try{return t.document.ModuleEndCustomer.customerType!=="company"}catch{return!0}},isReverseVat:t=>{try{return Un.checkFeature("reverseVat")&&t.document.ModuleEndCustomer.reverseVat===!0}catch{return!1}},getInvoicePrices:({document:t={}},e,r,n)=>{const a={invoiceFee:t.invoiceFee||0,invoiceFeeVat:0,centRoundingAmount:0,totalPriceExVat:0,totalVatAmount:0,totalAmount:0,visualPricing:{},regionPricing:[],reverseVat:e.isReverseVat||!1,type:t.type,paidAmount:0,remainingAmount:0,totalPriceIncVat:0,creditedAmount:0,currency:"SEK"};(t.ModuleArticles||[]).forEach(l=>{const d=Zi(l);if(!d.price||!d.quantity)return;const{totalAmount:f}=d;a.totalPriceExVat+=f,a.totalVatAmount+=f*(d.vat/100),d.vat>a.invoiceFeeVat&&!a.reverseVat&&(a.invoiceFeeVat=d.vat)}),a.totalPriceExVat+=a.invoiceFee,a.totalVatAmount+=a.invoiceFee*a.invoiceFeeVat*.01,a.reverseVat&&(a.totalVatAmount=0),a.regionPricing=e.invoiceRegion.regionPricing;const o=a.regionPricing.reduce((l,d)=>l+d.value,0),i=a.totalPriceExVat+a.totalVatAmount,s=(i+o)*.01,u=Math.round(s)-s;return a.centRoundingAmount=u*100,a.totalAmount=i+o+a.centRoundingAmount,a.type==="credit"&&(a.creditedAmount=a.totalAmount),a.remainingAmount=a.totalAmount,a},invoice:(t,e,r,n)=>{const a={};return Object.keys(rd).map(i=>(a[i]=n["forms/documentField"](i),i==="ModuleArticles"&&ot(a[i])==="array"&&(a[i]=a[i].filter(s=>s.name),a[i]=a[i].map((s,u)=>({...s,position:u}))),!0)),new Dx(a,n)},invoiceRegion:({document:t={}},e,r,n)=>{const a=Zi(t.ModuleArticles||[]),o=t.InvoiceRegionSweden||{},i={applicants:te(o,"persons",[]),houseWorkType:null,houseWorkAmount:null,houseWorkMaterial:null,allowRot:!1,allowRut:!1,regionPricing:[],requirePropertyDesignation:!1},s=a.find(m=>m.isDeductable||m.isRut)||{};s.isDeductable?i.houseWorkType="rot":s.isRut&&(i.houseWorkType="rut"),i.requirePropertyDesignation=i.houseWorkType==="rot";const u=a.reduce((m,c)=>m+c.houseWorkDeductionAmount,0),l=a.reduce((m,c)=>!c.isDeductable&&!c.isRut?m:m+c.totalAmount*(100+c.vat)/100,0),d=a.reduce((m,c)=>m+c.houseWorkMaterialCostToReport,0);i.houseWorkAmount=u,i.houseWorkMaterialAmount=d,i.houseWorkDuration=a.reduce((m,c)=>m+c.houseWorkHoursToReport,0),i._totalPriceDeductionArticles=l;const f=o.propertyType==="realEstate";return i.isRealEstate=f,i.propertyId=f?o.realEstateId:o.condominiumId,i.condominiumOrgNo=o.condominiumOrgNo,e.isIndivid&&(i.allowRot=n["settings/getCompanySetting"]("showRot")||!!i.houseWorkAmount,i.allowRut=n["settings/getCompanySetting"]("showRut")||!!i.houseWorkAmount),i.regionPricing=[...i.houseWorkType==="rot"?[{label:"ROT-avdrag",key:"rot",value:-i.houseWorkAmount}]:[],...i.houseWorkType==="rut"?[{label:"RUT-avdrag",key:"rut",value:-i.houseWorkAmount}]:[]],i},kycForm:t=>t.kycForm||null},hasChanged:t=>e=>JSON.stringify(t[e])!==JSON.stringify(t[`_old_${e}`]),getFormByKey:t=>e=>{const r=e.split(".");let n=t;const a=r.pop();return r.length>0&&(n=r.reduce((o,i)=>o[i],t)),n[a]},getArrayElement:t=>(e,r)=>{const{root:n,prop:a}=fo(t,e),o=n[a];if(!Array.isArray(o))throw new Error(`${a} is not an array`);return o.find(s=>s.uniqueId===r)}},PEe={namespaced:!0,state:rPe,getters:kEe,actions:mEe,mutations:wEe},TEe={data:{},ids:[],filePublicIdToId:{},isFetching:!1,isPosting:!1},Qs="files",{LOAD_FILE:rH,CREATE_FILE:_k,UPDATE_FILE:bk,DELETE_FILE:nH,PATCH_FILE:aH,FORM_NEW_FILE:MEe,FORM_EDIT_FILE:SEe,FORM_SUBMIT_FILE:iH}=cm,{UPDATE_MANY_FILES:oH,DELETE_ONE_FILE:OEe,SET_FILES_FETCHING:sH,SET_FILES_POSTING:hi}=ix,{SET_FORM:uH,CLEAR_FORM:EEe}=De.forms,DEe={async[rH]({commit:t},{id:e}){try{t(sH,!0);const{data:r}=await nhe(e);return t(oH,{data:r}),!0}catch(r){return this.handleError(r,{object:"file",objectId:e,fallbackCode:"file.get",action:`${Qs}/${rH}`,actionPayload:arguments[1]}),!1}finally{t(sH,!1)}},async[_k]({commit:t},{body:e}){try{t(hi,!0);const r=e.fileName||"";let n=null;if(e.blob){const a=new FormData;a.append("file",e.blob,r),{data:n}=await I3(a)}else({data:n}=await I3(e));if(!n)throw new Error("No file was uploaded");return t(oH,{data:n}),n.id}catch(r){return this.handleError(r,{object:"file",fallbackCode:"file.post",action:`${Qs}/${_k}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[bk]({commit:t,dispatch:e},{id:r,body:n}){try{return t(hi,!0),await ahe(r,n),await e(cm.LOAD_FILE,{id:r}),r}catch(a){return this.handleError(a,{object:"file",objectId:r,fallbackCode:"file.put",action:`${Qs}/${bk}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[nH]({commit:t},{id:e}){try{return t(hi,!0),await ihe(e),t(OEe,e),e}catch(r){return this.handleError(r,{object:"file",objectId:e,fallbackCode:"file.delete",action:`${Qs}/${nH}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[aH]({commit:t,dispatch:e},{id:r}){try{return t(hi,!0),await ohe(r),await e(cm.LOAD_FILE,{id:r}),r}catch(n){return this.handleError(n,{object:"file",objectId:r,fallbackCode:"file.patch",action:`${Qs}/${aH}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},[MEe]({commit:t}){const e={blob:null,fileName:null};return t(`forms/${uH}`,{key:"file",formData:e},{root:!0})},[SEe]({commit:t,state:e},{id:r,props:n=[]}){const a={...ya(e.data[r],n),id:r};return t(`forms/${uH}`,{key:"file",formData:a},{root:!0})},async[iH]({commit:t,rootGetters:e,dispatch:r}){try{const n=e["forms/getFormByKey"]("file");let{id:a}=n;return a?await r(bk,{id:n.id,body:n}):a=await r(_k,{body:n}),t(`forms/${EEe}`,{key:"file"},{root:!0}),a}catch(n){return this.handleError(n,{object:"file",action:`${Qs}/${iH}`}),null}}},{UPDATE_MANY_FILES:CEe,DELETE_ONE_FILE:$Ee,CLEAR_FILES:AEe,SET_FILES_FETCHING:REe,SET_FILES_POSTING:IEe}=ix,NEe={[CEe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a company user or an array of company users!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r),o=n.reduce((i,s)=>!a[s]||!a[s].publicId?i:{...i,[a[s].publicId]:a[s].id},{});Ys(t.data,a),t.ids=eo([...n,...t.ids]),t.filePublicIdToId={...t.filePublicIdToId,...o}},[$Ee](t,e){t.data[e]&&(ce.delete(t.filePublicIdToId,t.data[e].publicId),ce.delete(t.data,e));const n=t.ids.indexOf(e);n!==-1&&t.ids.splice(n,1)},[AEe](t){ce.set(t,"data",{}),ce.set(t,"ids",[]),ce.set(t,"filePublicIdToId",[])},[REe](t,e){t.isFetching=e},[IEe](t,e){t.isPosting=e}},LEe={namespaced:!0,state:TEe,getters:{fileById:t=>e=>t.data[e],fileByPublicId:(t,e)=>r=>{const n=t.filePublicIdToId[r];return e.fileById(n)}},actions:DEe,mutations:NEe},WEe={data:{},ids:[],projectPublicIdToId:{},isFetching:!1,isPosting:!1,canFetchMore:!0,count:{},searchWord:"",isFetchingProjectNotes:!1,isPostingProjectNotes:!1};var FEe="__lodash_hash_undefined__";function jEe(t){return this.__data__.set(t,FEe),this}var VEe=jEe;function zEe(t){return this.__data__.has(t)}var UEe=zEe,HEe=O0,qEe=VEe,BEe=UEe;function Vm(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new HEe;++e<r;)this.add(t[e])}Vm.prototype.add=Vm.prototype.push=qEe,Vm.prototype.has=BEe;var lH=Vm;function YEe(t,e,r,n){for(var a=t.length,o=r+(n?1:-1);n?o--:++o<a;)if(e(t[o],o,t))return o;return-1}var GEe=YEe;function KEe(t){return t!==t}var XEe=KEe;function JEe(t,e,r){for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}var QEe=JEe,ZEe=GEe,eDe=XEe,tDe=QEe;function rDe(t,e,r){return e===e?tDe(t,e,r):ZEe(t,eDe,r)}var nDe=rDe,aDe=nDe;function iDe(t,e){var r=t==null?0:t.length;return!!r&&aDe(t,e,0)>-1}var oDe=iDe;function sDe(t,e,r){for(var n=-1,a=t==null?0:t.length;++n<a;)if(r(e,t[n]))return!0;return!1}var uDe=sDe;function lDe(t,e){return t.has(e)}var dH=lDe,dDe=lH,cDe=oDe,fDe=uDe,mDe=EV,pDe=Bc,hDe=dH,vDe=200;function gDe(t,e,r,n){var a=-1,o=cDe,i=!0,s=t.length,u=[],l=e.length;if(!s)return u;r&&(e=mDe(e,pDe(r))),n?(o=fDe,i=!1):e.length>=vDe&&(o=hDe,i=!1,e=new dDe(e));e:for(;++a<s;){var d=t[a],f=r==null?d:r(d);if(d=n||d!==0?d:0,i&&f===f){for(var m=l;m--;)if(e[m]===f)continue e;u.push(d)}else o(e,f,n)||u.push(d)}return u}var yDe=gDe,cH=as,_De=C0,bDe=Dn,fH=cH?cH.isConcatSpreadable:void 0;function wDe(t){return bDe(t)||_De(t)||!!(fH&&t&&t[fH])}var xDe=wDe,kDe=F0,PDe=xDe;function mH(t,e,r,n,a){var o=-1,i=t.length;for(r||(r=PDe),a||(a=[]);++o<i;){var s=t[o];e>0&&r(s)?e>1?mH(s,e-1,r,n,a):kDe(a,s):n||(a[a.length]=s)}return a}var TDe=mH;function MDe(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var SDe=MDe,ODe=lH,EDe=SDe,DDe=dH,CDe=1,$De=2;function ADe(t,e,r,n,a,o){var i=r&CDe,s=t.length,u=e.length;if(s!=u&&!(i&&u>s))return!1;var l=o.get(t),d=o.get(e);if(l&&d)return l==e&&d==t;var f=-1,m=!0,c=r&$De?new ODe:void 0;for(o.set(t,e),o.set(e,t);++f<s;){var p=t[f],h=e[f];if(n)var v=i?n(h,p,f,e,t,o):n(p,h,f,t,e,o);if(v!==void 0){if(v)continue;m=!1;break}if(c){if(!EDe(e,function(g,_){if(!DDe(c,_)&&(p===g||a(p,g,r,n,o)))return c.push(_)})){m=!1;break}}else if(!(p===h||a(p,h,r,n,o))){m=!1;break}}return o.delete(t),o.delete(e),m}var pH=ADe;function RDe(t){var e=-1,r=Array(t.size);return t.forEach(function(n,a){r[++e]=[a,n]}),r}var IDe=RDe;function NDe(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var LDe=NDe,hH=as,vH=wF,WDe=T0,FDe=pH,jDe=IDe,VDe=LDe,zDe=1,UDe=2,HDe="[object Boolean]",qDe="[object Date]",BDe="[object Error]",YDe="[object Map]",GDe="[object Number]",KDe="[object RegExp]",XDe="[object Set]",JDe="[object String]",QDe="[object Symbol]",ZDe="[object ArrayBuffer]",eCe="[object DataView]",gH=hH?hH.prototype:void 0,wk=gH?gH.valueOf:void 0;function tCe(t,e,r,n,a,o,i){switch(r){case eCe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ZDe:return!(t.byteLength!=e.byteLength||!o(new vH(t),new vH(e)));case HDe:case qDe:case GDe:return WDe(+t,+e);case BDe:return t.name==e.name&&t.message==e.message;case KDe:case JDe:return t==e+"";case YDe:var s=jDe;case XDe:var u=n&zDe;if(s||(s=VDe),t.size!=e.size&&!u)return!1;var l=i.get(t);if(l)return l==e;n|=UDe,i.set(t,e);var d=FDe(s(t),s(e),n,a,o,i);return i.delete(t),d;case QDe:if(wk)return wk.call(t)==wk.call(e)}return!1}var rCe=tCe,yH=pF,nCe=1,aCe=Object.prototype,iCe=aCe.hasOwnProperty;function oCe(t,e,r,n,a,o){var i=r&nCe,s=yH(t),u=s.length,l=yH(e),d=l.length;if(u!=d&&!i)return!1;for(var f=u;f--;){var m=s[f];if(!(i?m in e:iCe.call(e,m)))return!1}var c=o.get(t),p=o.get(e);if(c&&p)return c==e&&p==t;var h=!0;o.set(t,e),o.set(e,t);for(var v=i;++f<u;){m=s[f];var g=t[m],_=e[m];if(n)var y=i?n(_,g,m,e,t,o):n(g,_,m,t,e,o);if(!(y===void 0?g===_||a(g,_,r,n,o):y)){h=!1;break}v||(v=m=="constructor")}if(h&&!v){var b=t.constructor,k=e.constructor;b!=k&&"constructor"in t&&"constructor"in e&&!(typeof b=="function"&&b instanceof b&&typeof k=="function"&&k instanceof k)&&(h=!1)}return o.delete(t),o.delete(e),h}var sCe=oCe,xk=E0,uCe=pH,lCe=rCe,dCe=sCe,_H=Gc,bH=Dn,wH=el.exports,cCe=sF,fCe=1,xH="[object Arguments]",kH="[object Array]",zm="[object Object]",mCe=Object.prototype,PH=mCe.hasOwnProperty;function pCe(t,e,r,n,a,o){var i=bH(t),s=bH(e),u=i?kH:_H(t),l=s?kH:_H(e);u=u==xH?zm:u,l=l==xH?zm:l;var d=u==zm,f=l==zm,m=u==l;if(m&&wH(t)){if(!wH(e))return!1;i=!0,d=!1}if(m&&!d)return o||(o=new xk),i||cCe(t)?uCe(t,e,r,n,a,o):lCe(t,e,u,r,n,a,o);if(!(r&fCe)){var c=d&&PH.call(t,"__wrapped__"),p=f&&PH.call(e,"__wrapped__");if(c||p){var h=c?t.value():t,v=p?e.value():e;return o||(o=new xk),a(h,v,r,n,o)}}return m?(o||(o=new xk),dCe(t,e,r,n,a,o)):!1}var hCe=pCe,vCe=hCe,TH=ma;function MH(t,e,r,n,a){return t===e?!0:t==null||e==null||!TH(t)&&!TH(e)?t!==t&&e!==e:vCe(t,e,r,n,MH,a)}var SH=MH,gCe=E0,yCe=SH,_Ce=1,bCe=2;function wCe(t,e,r,n){var a=r.length,o=a,i=!n;if(t==null)return!o;for(t=Object(t);a--;){var s=r[a];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++a<o;){s=r[a];var u=s[0],l=t[u],d=s[1];if(i&&s[2]){if(l===void 0&&!(u in t))return!1}else{var f=new gCe;if(n)var m=n(l,d,u,t,e,f);if(!(m===void 0?yCe(d,l,_Ce|bCe,n,f):m))return!1}}return!0}var xCe=wCe,kCe=fa;function PCe(t){return t===t&&!kCe(t)}var OH=PCe,TCe=OH,MCe=Yc;function SCe(t){for(var e=MCe(t),r=e.length;r--;){var n=e[r],a=t[n];e[r]=[n,a,TCe(a)]}return e}var OCe=SCe;function ECe(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var EH=ECe,DCe=xCe,CCe=OCe,$Ce=EH;function ACe(t){var e=CCe(t);return e.length==1&&e[0][2]?$Ce(e[0][0],e[0][1]):function(r){return r===t||DCe(r,t,e)}}var RCe=ACe;function ICe(t,e){return t!=null&&e in Object(t)}var NCe=ICe,LCe=lm,WCe=C0,FCe=Dn,jCe=$0,VCe=A0,zCe=zs;function UCe(t,e,r){e=LCe(e,t);for(var n=-1,a=e.length,o=!1;++n<a;){var i=zCe(e[n]);if(!(o=t!=null&&r(t,i)))break;t=t[i]}return o||++n!=a?o:(a=t==null?0:t.length,!!a&&VCe(a)&&jCe(i,a)&&(FCe(t)||WCe(t)))}var HCe=UCe,qCe=NCe,BCe=HCe;function YCe(t,e){return t!=null&&BCe(t,e,qCe)}var GCe=YCe,KCe=SH,XCe=te,JCe=GCe,QCe=Z1,ZCe=OH,e$e=EH,t$e=zs,r$e=1,n$e=2;function a$e(t,e){return QCe(t)&&ZCe(e)?e$e(t$e(t),e):function(r){var n=XCe(r,t);return n===void 0&&n===e?JCe(r,t):KCe(e,n,r$e|n$e)}}var i$e=a$e;function o$e(t){return t}var kk=o$e;function s$e(t){return function(e){return e==null?void 0:e[t]}}var u$e=s$e,l$e=tx;function d$e(t){return function(e){return l$e(e,t)}}var c$e=d$e,f$e=u$e,m$e=c$e,p$e=Z1,h$e=zs;function v$e(t){return p$e(t)?f$e(h$e(t)):m$e(t)}var g$e=v$e,y$e=RCe,_$e=i$e,b$e=kk,w$e=Dn,x$e=g$e;function k$e(t){return typeof t=="function"?t:t==null?b$e:typeof t=="object"?w$e(t)?_$e(t[0],t[1]):y$e(t):x$e(t)}var P$e=k$e;function T$e(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var M$e=T$e,S$e=M$e,DH=Math.max;function O$e(t,e,r){return e=DH(e===void 0?t.length-1:e,0),function(){for(var n=arguments,a=-1,o=DH(n.length-e,0),i=Array(o);++a<o;)i[a]=n[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=n[a];return s[e]=r(i),S$e(t,this,s)}}var E$e=O$e;function D$e(t){return function(){return t}}var C$e=D$e,$$e=C$e,CH=eF,A$e=kk,R$e=CH?function(t,e){return CH(t,"toString",{configurable:!0,enumerable:!1,value:$$e(e),writable:!0})}:A$e,I$e=R$e,N$e=800,L$e=16,W$e=Date.now;function F$e(t){var e=0,r=0;return function(){var n=W$e(),a=L$e-(n-r);if(r=n,a>0){if(++e>=N$e)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var j$e=F$e,V$e=I$e,z$e=j$e,U$e=z$e(V$e),H$e=U$e,q$e=kk,B$e=E$e,Y$e=H$e;function G$e(t,e){return Y$e(B$e(t,e,q$e),t+"")}var K$e=G$e,X$e=I0,J$e=ma;function Q$e(t){return J$e(t)&&X$e(t)}var Z$e=Q$e,e2e=yDe,t2e=TDe,r2e=P$e,n2e=K$e,Pk=Z$e,a2e=lU,i2e=n2e(function(t,e){var r=a2e(e);return Pk(r)&&(r=void 0),Pk(t)?e2e(t,t2e(e,1,Pk,!0),r2e(r)):[]}),o2e=i2e;const Tk="projects",{LOAD_PROJECT_NOTE:Mk,DO_CREATE_PROJECT_NOTE:$H,DO_UPDATE_PROJECT_NOTE:AH,FORM_NEW_PROJECT_NOTE:s2e,FORM_EDIT_PROJECT_NOTE:RH,FORM_SUBMIT_PROJECT_NOTE:IH}=jn,{SET_PROJECT_NOTES:NH,SET_PROJECT_NOTES_FETCHING:LH,SET_PROJECT_NOTES_POSTING:Um}=Fr,{SET_FORM:WH}=zn,u2e={async[Mk]({commit:t},{id:e}){try{if(t(LH,!0),!e)return;const{data:r}=await ehe(e);if(!r)return;t(NH,{projectNotes:[r]})}catch(r){this.handleError(r,{object:"projectNote",objectId:e,fallbackCode:"projectNote.get",action:`${Tk}/${Mk}`,actionPayload:arguments[1]})}finally{t(LH,!1)}},async[$H]({commit:t},{body:e}){try{t(Um,!0);const{data:r}=await the(e);return t(NH,{projectNotes:[r]}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("note")})}),r.id}catch(r){throw r}finally{t(Um,!1)}},async[AH]({commit:t,dispatch:e},{id:r,body:n}){try{return t(Um,!0),await rhe(r,n),await e(Mk,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("note")})}),r}catch(a){throw a}finally{t(Um,!1)}},[s2e]({commit:t},{projectId:e=null}){const r={ProjectId:e,text:""};t(`forms/${WH}`,{key:"projectNote",formData:r},{root:!0})},async[RH]({commit:t,state:e},{projectId:r}){try{const n=e.data[r].ProjectNote;t(`forms/${WH}`,{key:"projectNote",formData:n},{root:!0})}catch(n){this.handleError(n,{object:"projectNote",fallbackCode:"projectNote.edit",action:`${Tk}/${RH}`,actionPayload:arguments[1]})}},async[IH]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("projectNote");let{id:n}=r;return n?await e(AH,{id:r.id,body:r}):n=await e($H,{body:r}),n}catch(r){return this.handleError(r,{object:"projectNote",fallbackCode:"projectNote.submit",action:`${Tk}/${IH}`}),null}}},dd="projects",{LOAD_PROJECT_FILE:Hm,CREATE_PROJECT_FILE:FH,UPDATE_PROJECT_FILE:jH,DELETE_PROJECT_FILE:VH,PATCH_PROJECT_FILE:Sk}=LV,l2e={async[Hm](t,{id:e}){try{const{data:r}=await Kpe(e);return await this.dispatch(Oe.SET_AS_NORMALIZED_DATA,{data:[r],schema:"projectFiles"}),!0}catch(r){return this.handleError(r,{object:"projectFile",objectId:e,fallbackCode:"projectFile.get",action:`${dd}/${Hm}`,actionPayload:arguments[1]}),!1}},async[FH](t,{projectId:e,fileId:r}){try{if(typeof e>"u")throw new Error("Missing parameter projectId");if(typeof r>"u")throw new Error("Missing parameter fileId");const{data:n}=await Xpe({ProjectId:e,FileId:r});return await this.dispatch(Oe.SET_AS_NORMALIZED_DATA,{data:[n],schema:"projectFiles"}),n.id}catch(n){return this.handleError(n,{object:"projectFile",fallbackCode:"projectFile.post",action:`${dd}/${FH}`,actionPayload:arguments[1]}),null}},async[jH]({dispatch:t},{id:e,body:r}){try{return await Jpe(e,r),await t(Hm,{id:e}),e}catch(n){return this.handleError(n,{object:"projectFile",objectId:e,fallbackCode:"projectFile.put",action:`${dd}/${jH}`,actionPayload:arguments[1]}),null}},async[VH]({commit:t,getters:e},{projectId:r,id:n}){try{const a=e.byId(r);if(a){const o=a.files.find(s=>s.id===n),{FileId:i}=o;this.dispatch(Oe.DELETE_FILE,{id:i})}return await Qpe(n),t(dm.DELETE_PROJECT_FILE,{projectId:r,id:n}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("file")}),actions:{undo:()=>{this.dispatch(`projects/${Sk}`,{id:n,projectId:r})}}}),n}catch(a){return this.handleError(a,{object:"projectFile",objectId:n,fallbackCode:"projectFile.delete",action:`${dd}/${VH}`,actionPayload:arguments[1]}),null}},async[Sk]({dispatch:t,getters:e},{projectId:r,id:n}){try{await Zpe(n),await t(Hm,{id:n});const a=e.byId(r);if(a){const o=a.files.find(s=>s.id===n),{FileId:i}=o;await this.dispatch(Oe.PATCH_FILE,{id:i})}return n}catch(a){return this.handleError(a,{object:"file",objectId:n,fallbackCode:"file.patch",action:`${dd}/${Sk}`,actionPayload:arguments[1]}),null}}},{LOAD_EVENTS_FOR_PROJECT:d2e}=jn,{SET_EVENTS:c2e}=Fr,f2e={async[d2e]({commit:t},{id:e}){const{data:r}=await fr.get(`/project/${e}/event`);return!r||r.length<=0?!1:(t(c2e,{events:r}),!0)}},zr="projects",{LOAD_PROJECT:Ok,LOAD_PROJECTS:zH,DO_LOAD_PROJECT:UH,DO_LOAD_PROJECTS:qm,DO_LOAD_PROJECTS_COUNT:m2e,LOAD_PROJECTS_FOR_CLIENT:HH,LOAD_PROJECTS_FOR_USER:qH,LOAD_PUBLIC_PROJECT:BH,CREATE_PROJECT:p2e,CREATE_DEMOPROJECT:YH,UPDATE_PROJECT:GH,DELETE_PROJECT:KH,PATCH_PROJECT:Ek,DO_SUBMIT_PROJECT:XH,SUBMIT_PROJECT:JH,SUBMIT_PROJECT_MEMBER:Dk,DELETE_PROJECT_MEMBER:Ck,SET_PROJECT_LEADER:QH,SET_PROJECT_FILTER:h2e,SET_PROJECT_SORT:v2e,SET_QUICKVIEW_PROJECT:$k,CLEAR_PROJECTS:g2e}=jn,{UPDATE_VIEW_SETTINGS:y2e,DO_UPDATE_SETTINGS:Ak,DO_LOAD_CURRENT_COMPANY:_2e}=Oe,{CLEAR_PROJECT_DATA:b2e,SET_PROJECTS_POSTING:Rt,SET_PROJECTS_FETCHING:bo,DELETE_MANY_PROJECTS:w2e}=Fr,x2e={...u2e,...f2e,...l2e,async[qm]({commit:t,state:e,rootState:r},n={}){try{const a={clearOld:!1,start:n.end?0:void 0,end:void 0,sort:void 0,order:void 0,force:!1,filter:void 0,...n},{canFetchMore:o}=e;let i=!!o;if(a.clearOld&&(i=!0),e.isFetching&&!a.force||ot(a.start)==="number"&&ot(a.end)==="number"&&!i&&!a.force)return;t(bo,!0);const{data:s}=await R3({start:a.start,end:a.end,sort:a.sort,order:a.order,filter:a.filter});let u={};s.forEach(({cachedDocuments:m})=>{if(m){const c=Object.keys(m.documents).reduce((p,h)=>({...p,[h]:{id:h,data:{name:m.documents[h].name,clients:[{name:te(m,`documents[${h}].firstClient.name`,""),type:te(m,`documents[${h}].firstClient.type`),addresses:te(m,`documents[${h}].firstClient.addresses`)}]},status:m.documents[h].status}}),{});u={...u,...c}}});const l=r.documents2.ids,d=o2e(Object.keys(u),l);this.commit("documents2/SET_DOCUMENTS2",{data:d.map(m=>u[m])}),a.clearOld&&t(b2e),this.dispatch(uo,{data:s,schema:"projects"}),i=!((ot(a.start)==="number"&&ot(a.end)==="number"?a.end-a.start:0)>s.length),t(Fr.SET_PROJECTS_CAN_FETCH_MORE,i)}catch(a){throw a}finally{t(bo,!1)}},async[m2e]({commit:t}){try{t(bo,!0);const{data:e}=await fr.get("/project/counts");t(Fr.SET_PROJECTS_COUNT,{data:e})}catch(e){throw e}finally{t(bo,!1)}},async[zH]({dispatch:t},e={}){try{await t(qm,e)}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${zH}`,actionPayload:arguments[1]})}},async[Ok]({dispatch:t},{id:e}){try{await t(UH,{id:e})}catch(r){this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.get",action:`${zr}/${Ok}`,actionPayload:arguments[1]})}},async[UH]({commit:t},{id:e}){try{t(bo,!0);const r=[],{data:n}=await jpe(e);return n&&r.push(n),this.dispatch(uo,{data:r,schema:"projects"}),t(bo,!1),n}catch(r){throw t(bo,!1),r}},async[HH]({dispatch:t},{id:e}){try{await t(qm,{filter:{clientEndCustomerIds:{[e]:"contains"}}})}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${HH}`,actionPayload:arguments[1]})}},async[qH]({dispatch:t},{id:e}){try{await t(qm,{filter:{CompanyUserId:{[e]:!0}}})}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${qH}`,actionPayload:arguments[1]})}},async[BH](t,e){try{const{data:r}=await fr.get(`/project/public/${e}`);this.dispatch(uo,{data:r,schema:Kxe})}catch(r){this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.get",action:`${zr}/${BH}`,actionPayload:arguments[1]})}},async[p2e]({dispatch:t,commit:e,rootGetters:r},{body:n}){try{e(Rt,!0);const{data:a}=await Fpe(n);return await t(jn.LOAD_PROJECT,{id:a.id}),r["application/companyAccountType"]==="free"&&this.dispatch(_2e),e(Rt,!1),Promise.resolve(a.id)}catch(a){return e(Rt,!1),Promise.reject(a)}},async[YH]({dispatch:t,commit:e}){try{e(Rt,!0);const{data:r}=await Hpe(),{id:n}=r;return this.dispatch(Ak,{key:"company",settings:[{name:"demoProjectId",value:n}]}),await t(jn.LOAD_PROJECT,{id:n}),e(Rt,!1),n}catch(r){return this.handleError(r,{object:"project",fallbackCode:"project.demo",action:`${zr}/${YH}`,actionPayload:arguments[1]}),null}finally{e(Rt,!1)}},async[GH]({dispatch:t,commit:e},{id:r,body:n}){try{return e(Rt,!0),await Vpe(r,n),await t(jn.LOAD_PROJECT,{id:r}),e(Rt,!1),r}catch(a){throw e(Rt,!1),a}},async[KH]({commit:t,dispatch:e},{id:r}){try{return t(Rt,!0),await Upe(r),t(w2e,r),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("project")}),actions:{undo:()=>{this.dispatch(`projects/${Ek}`,{id:r})}}}),e($k,{id:null}),t(Rt,!1),!0}catch(n){return t(Rt,!1),this.handleError(n,{object:"project",objectId:r,fallbackCode:"project.delete",action:`${zr}/${KH}`,actionPayload:arguments[1]}),!1}},async[Ek]({dispatch:t},{id:e}){try{return await zpe(e),await t(Ok,{id:e}),e}catch(r){return this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.patch",action:`${zr}/${Ek}`,actionPayload:arguments[1]}),!1}},async[$k]({commit:t},{id:e}){try{return this.dispatch(y2e,{view:"projectList",settings:{quickViewProjectId:e}}),e}catch(r){return t(Rt,!1),this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.quickview",action:`${zr}/${$k}`,actionPayload:arguments[1]}),!1}},async[QH]({dispatch:t,commit:e,getters:r},{projectId:n,companyUserId:a}){var o;try{e(Rt,!0);const i=r.byId(n).getProperty("CompanyUserId");return await t(GH,{id:n,body:{CompanyUserId:a}}),await t(Ck,{projectId:n,companyUserId:a}),await t(Dk,{projectId:n,companyUserId:i}),(o=this.$segment)==null||o.track("Project Leader Changed",{projectId:n,companyUserId:a}),e(Rt,!1),!0}catch(i){return e(Rt,!1),this.handleError(i,{object:"project",objectId:n,fallbackCode:"project.projectLeader",action:`${zr}/${QH}`,actionPayload:arguments[1]}),!1}},async[XH]({dispatch:t},{data:e}){let{id:r}=e;return r?await t(jn.UPDATE_PROJECT,{id:e.id,body:e}):r=await t(jn.CREATE_PROJECT,{body:e}),await t(jn.LOAD_PROJECT,{id:r}),r},async[JH]({dispatch:t},e){try{await t(XH,e)}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.post",action:`${zr}/${JH}`,actionPayload:arguments[1]})}return!0},async[Dk]({commit:t},{projectId:e,companyUserId:r}){var n;try{return t(Rt,!0),await whe(e,r),t(Fr.ADD_PROJECT_MEMBER,{projectId:e,companyUserId:r}),(n=this.$segment)==null||n.track("Project Member Added",{projectId:e,companyUserId:r}),t(Rt,!1),!0}catch(a){return t(Rt,!1),this.handleError(a,{object:"project",objectId:e,fallbackCode:"project.member.post",action:`${zr}/${Dk}`,actionPayload:arguments[1]}),!1}},async[Ck]({commit:t},{projectId:e,companyUserId:r}){var n;try{return t(Rt,!0),await xhe(e,r),t(Fr.DELETE_PROJECT_MEMBER,{projectId:e,companyUserId:r}),(n=this.$segment)==null||n.track("Project Member Removed",{projectId:e,companyUserId:r}),t(Rt,!1),!0}catch(a){return t(Rt,!1),this.handleError(a,{object:"project",objectId:e,fallbackCode:"project.member.delete",action:`${zr}/${Ck}`,actionPayload:arguments[1]}),!1}},async[h2e](t,e){const r=JSON.stringify(e);await this.dispatch(Ak,{key:"companyUser",settings:[{name:"projectListFilter",value:r}]})},async[v2e](t,e){const r=JSON.stringify(e);await this.dispatch(Ak,{key:"companyUser",settings:[{name:"projectListSort",value:r}]})},[g2e]({commit:t}){t(Fr.CLEAR_PROJECT_DATA),t(Fr.SET_PROJECTS_CAN_FETCH_MORE,!0)}},{SET_PROJECT_NOTES:k2e,SET_PROJECT_NOTES_FETCHING:P2e,SET_PROJECT_NOTES_POSTING:T2e}=Fr,M2e={[k2e](t,{projectNotes:e=[]}){e.forEach(r=>{const{ProjectId:n}=r;return!n||!t.data[n]?!1:(ce.set(t.data[n],"ProjectNote",r),!0)})},[P2e](t,e){t.isFetchingProjectNotes=e},[T2e](t,e){t.isPostingProjectNotes=e}},{SET_EVENTS:S2e}=Fr,O2e={[S2e](t,{events:e=[]}){e.forEach(r=>{const{ProjectId:n}=r;if(!n||!t.data[n])return!1;let a=[];t.data[n].Events?a=t.data[n].Events:ce.set(t.data[n],"Events",a);const o=a.findIndex(i=>i.id===r.id);return o!==-1?a[o]=Object.assign(a[o],r):a.push(r),!0})}},E2e={[dm.SET_PROJECT_FILES](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a projectFile or an array of projectFiles!");(Array.isArray(e)?e:[e]).forEach(n=>{const{ProjectId:a}=n;if(!a||!t.data[a])return!1;let o=[];t.data[a].ProjectFiles?o=t.data[a].ProjectFiles:ce.set(t.data[a],"ProjectFiles",o);const i=o.findIndex(s=>s.id===n.id);return i!==-1?o[i]=Object.assign(o[i],n):o.push(n),!0})},[dm.DELETE_PROJECT_FILE](t,{projectId:e,id:r}){if(!e||!t.data[e])return!1;const n=t.data[e].ProjectFiles;if(n&&Array.isArray(n)){const a=n.findIndex(o=>o.id===r);a!==-1&&n.splice(a,1)}return!0}},{SET_PROJECTS:D2e,CLEAR_PROJECT_DATA:C2e,DELETE_MANY_PROJECTS:$2e,ADD_PROJECT_MEMBER:A2e,DELETE_PROJECT_MEMBER:R2e,SET_PROJECTS_FETCHING:I2e,SET_PROJECTS_POSTING:N2e,SET_PROJECTS_CAN_FETCH_MORE:L2e,SET_PROJECTS_COUNT:W2e}=Fr,F2e={...M2e,...O2e,...E2e,updateField:Gl,[D2e](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a project or an array of projects!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[C2e](t){Object.assign(t,{data:{},ids:[],projectPublicIdToId:{}})},[$2e](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{if(!t.data[n])return;const{publicId:a}=t.data[n];ce.delete(t.data,n),t.ids=t.ids.filter(o=>o!==n),ce.delete(t.projectPublicIdToId,a)})},[A2e](t,{projectId:e,companyUserId:r}){if(!e)throw Error("Cannot add member as no projectId is defined");if(!r)throw Error("Cannot add member as no companyUserId is defined");if(!t.data[e])return!1;let n=[];t.data[e].ProjectMembers?n=t.data[e].ProjectMembers:ce.set(t.data[e],"ProjectMembers",n);const a=n.findIndex(o=>o===r);return a!==-1?n[a]=r:n.push(r),!0},[R2e](t,{projectId:e,companyUserId:r}){if(!e)throw Error("Cannot delete member as no projectId is defined");if(!r)throw Error("Cannot delete member as no companyUserId is defined");if(!t.data[e])return!1;let n=[];t.data[e].ProjectMembers?n=t.data[e].ProjectMembers:ce.set(t.data[e],"ProjectMembers",n);const a=n.findIndex(o=>o===r);return a!==-1&&n.splice(a,1),!0},[I2e](t,e){t.isFetching=e},[N2e](t,e){t.isPosting=e},[L2e](t,e){t.canFetchMore=e},[W2e](t,{data:e={}}){if(typeof e!="object"||Array.isArray(e))throw Error("Data must be an object!");const r={};Object.keys(e).forEach(n=>{r[n]=e[n]||0}),t.count=r}},j2e={id:{$default:null,$type:Number,$scope:["project","offer","contract"]},name:{$default:"",$type:String,$scope:["project","offer","contract"]},isDemo:{$default:!1,$type:Boolean,$scope:["project"]},externalId:{$default:"",$type:Number},publicId:{$default:null,$type:String},projectNumber:{$default:null,$type:Number},CompanyId:{$default:null,$type:"ref",$ref:"companies"},CompanyUserId:{$default:null,$type:"ref",$ref:"companyUsers"},ProjectMembers:[{$type:"ref",$ref:"companyUsers"}],ProjectSettings:{$default:[],$type:Array,$scope:["project","offer","contract"]},frontend:{$default:"vue",$type:String,$scope:["project","offer","contract"]},status:{$default:"new",$type:String},createdAt:{$default:null,$type:Date},updatedAt:{$default:null,$type:Date},deletedAt:{$default:null,$type:Date}},uW=class{constructor(e,r,n){if(!e)throw Error("First arg. id is required");if(!r)throw Error("Seccond arg. getters is required");this._getters=r,this._project=e,this._documents=[]}get id(){return this._project.id}getId(){const{id:e}=this.getProject()||{};return e||null}getProject(){const{_project:e}=this;return e||null}get documents(){if(!this.documentIds.length)return[];let e=[];const r=te(this._project,"cachedDocuments.mainDocument.id");return this.documentIds.forEach(n=>{const a=this._getters["documents2/byId"](n);a&&(a.id===r?e=[a,...e]:e.push(a))}),e}get cachedDocumentsInfo(){let e=[];const{cachedDocuments:r}=this._project;if(!r)return[];const{documents:n={},mainDocument:a={}}=r;return Object.keys(n).forEach(o=>{const i=n[o];i&&(i.id===a.id?e=[i,...e]:e.push(i))}),e}get documentIds(){const{cachedDocuments:e}=this._project;if(!e)return[];const{documents:r}=e;return r?Object.keys(r):[]}get invoices(){return this._getters["invoices/byProjectId"](this.getId())||[]}get events(){return this._project.Events||[]}get creatorId(){return this._project.CompanyUser}get creator(){const{_getters:e}=this,{CompanyUser:r}=this.getProject()||{};return e["companyUsers/byId"](r)}get name(){return this._project.name}get status(){return this._project.status}get subStatus(){const{status:e,mainDocument:r}=this;return["offer","contract"].includes(e)&&r?r.status:null}get clients(){const e=[];return this.documents.reduce((n,a)=>(a.clients.forEach(o=>{e.includes(o.endCustomerId)||(e.push(o.endCustomerId),n.push(o))}),n),[])}get mainDocument(){return this.documents[0]}get currency(){return te(this,"mainDocument.currency",null)}get members(){const{_getters:e}=this,{ProjectMembers:r=[]}=this.getProject()||{};return r.map(a=>e["companyUsers/byId"](a))}get projectNumber(){return this._project.projectNumber}get note(){return this._project.ProjectNote}get files(){return this._project.ProjectFiles}get firstClientName(){return this._project.firstClientName}get firstClientStreet(){return this._project.firstClientStreet}get prices(){const e={types:[],subTotal:0,taxAmount:0,total:0,maxTotal:0,invoicedAmount:0,paidAmount:0,hasDeductions:!1,currency:this.currency};if(!this.documents.length)return e;this.documents.forEach(n=>{e.types=[...new Set([...e.types,...n.prices.type])],!(e.currency&&e.currency!==n.currency)&&(e.subTotal+=n.prices.subTotal,e.taxAmount+=n.prices.taxAmount,e.total+=n.prices.total,e.maxTotal+=n.prices.maxTotal,n.prices.region&&n.prices.region.houseWorkAmount&&(e.hasDeductions=!0))});const{invoices:r}=this;return r.forEach(n=>{e.invoicedAmount+=n.totalAmount,e.paidAmount+=n.paidAmount}),e}get isDemo(){return this.getProperty("isDemo")}getProperty(e=""){return e.replace(/\[(.*)\]/ig,(a,o)=>`.${o}`).split(".").reduce((a,o)=>a&&(typeof a[o]!="object",a[o]),this._project)}getProperties({scope:e=null}={}){let r=e;typeof r=="string"&&(r=[r]);const{schema:n}=uW,a={};n&&Object.keys(n).map(i=>(n[i].$default!=="undefined"&&(a[i]=n[i].$default),!0));const o=Object.assign({},a,this._project);return n&&r&&Array.isArray(r)&&Object.keys(n).map(i=>n[i].$scope?(r.some(u=>n[i].$scope.indexOf(u)>=0)||delete o[i],!0):(delete o[i],!0)),JSON.parse(JSON.stringify(o))}};let wo=uW;Ut(wo,"schema",j2e),Ut(wo,"statuses",{new:{statusText:"Utkast",statusClass:"draft"},sent:{statusText:"Skickad",statusClass:"sent"},denied:{statusText:"Nekad",statusClass:"denied"},accepted:{statusText:"Accepterad",statusClass:"accepted"},signed:{statusText:"Signerad",statusClass:"accepted"},semiSigned:{statusText:"Delsignerad",statusClass:"accepted"},active:{statusText:"P\xE5g\xE5ende",statusClass:"active"},completed:{statusText:"Klar",statusClass:"completed"},archived:{statusText:"Arkiverad",statusClass:"archived"}});const V2e={getField:vm,...{isPostingProjectNote:t=>t.isPostingProjectNotes,isFetchingProjectNote:t=>t.isFetchingProjectNotes},byId:(t,e,r,n)=>a=>t.data[a]?new wo(t.data[a],n):null,projectIdsByClientId:t=>e=>t.ids.filter(r=>{const n=te(t.data[r],"clientEndCustomerIds","");return n?n.split(",").includes(`${e}`):!1}),projectIdsOwnedByUserId:(t,e)=>r=>t.ids.filter(n=>{const a=e.byId(n);if(!a)return!1;const o=a.getProperty("CompanyUserId");return o?o===r:!1}),projects:(t,e,r,n)=>t.ids.map(a=>new wo(t.data[a],n)),projectByPublicId:(t,e,r,n)=>a=>{const o=t.projectPublicIdToId[a];return o?new wo(t.data[o],n):null},projectsByStatus:(t,{projects:e})=>r=>e.filter(n=>n.status===r),filter:(t,e,r,n)=>{const a=n["settings/getCompanyUserSetting"]("projectListFilter");return a?JSON.parse(a):{or:{docStatuses:{draft:"contains",sent:"contains",accepted:"contains",denied:"contains"},status:{active:!0,completed:!0}}}},sort:(t,e,r,n)=>{const a=n["settings/getCompanyUserSetting"]("projectListSort");return a?JSON.parse(a):{sort:"updatedAt",order:"DESC"}},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,canFetchMore:t=>t.canFetchMore,count:t=>t.count},z2e={namespaced:!0,state:WEe,getters:V2e,actions:x2e,mutations:F2e},U2e={data:{},ids:[],isPosting:!1,isFetching:!1},cd="templates",{DO_LOAD_TEMPLATE:fd,DO_LOAD_TEMPLATES:ZH,LOAD_TEMPLATE:e7,LOAD_TEMPLATES:t7,DO_UPDATE_TEMPLATE:r7,DO_CREATE_TEMPLATE:n7,UPDATE_TEMPLATE:a7,DELETE_TEMPLATE:i7,PATCH_TEMPLATE:Rk,HIDE_TEMPLATE:o7,DUPLICATE_PROTECTED_TEMPLATE:s7}=qV,{SET_TEMPLATE_POSTING:Bn,SET_TEMPLATE_FETCHING:Bm,SET_TEMPLATES:u7,DELETE_MANY_TEMPLATES:H2e}=sx,q2e={async[fd]({commit:t},{id:e,params:r={}}){try{t(Bm,!0);const{data:n}=await to.get(e,r);t(u7,{data:[n]})}catch(n){throw n}finally{t(Bm,!1)}},async[ZH]({commit:t},e={}){try{t(Bm,!0);const{data:r}=await to.get(null,e),{items:n}=r;t(u7,{data:n})}catch(r){throw r}finally{t(Bm,!1)}},async[t7]({dispatch:t},e={}){try{await t(ZH,e)}catch(r){this.handleError(r,{object:"template",fallbackCode:"template.getMany",action:`${cd}/${t7}`})}},async[e7]({dispatch:t},{id:e}){try{await t(fd,{id:e})}catch(r){this.handleError(r,{object:"template",fallbackCode:"template.getOne",action:`${cd}/${e7}`,actionPayload:arguments[1]})}},async[n7]({commit:t,dispatch:e},{body:r,showMessage:n=!0}){try{t(Bn,!0);const{data:a}=await to.post(r),{id:o}=a;return await e(fd,{id:o}),n&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("template")})}),o}catch(a){throw a}finally{t(Bn,!1)}},async[r7]({dispatch:t,commit:e},{id:r,body:n}){try{return e(Bn,!0),await to.put(r,n),await t(fd,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("template")})}),r}catch(a){throw a}finally{e(Bn,!1)}},async[a7]({dispatch:t},{id:e,body:r}){try{return r.companyId?(await t(r7,{id:e,body:r}),e):t(s7,{body:r})}catch(n){return this.handleError(n,{object:"template",objectId:e,fallbackCode:"template.put",action:`${cd}/${a7}`,actionPayload:arguments[1]}),null}},async[i7]({commit:t},{id:e}){try{return t(Bn,!0),await to.delete(e),t(H2e,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("template")}),actions:{undo:()=>{this.dispatch(`templates/${Rk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"templates",objectId:e,fallbackCode:"documentTemplate.delete",action:`${cd}/${i7}`,actionPayload:arguments[1]}),null}finally{t(Bn,!1)}},async[Rk]({commit:t,dispatch:e},{id:r}){try{return t(Bn,!0),await to.patch(r),await e(fd,{id:r}),r}catch(n){return this.handleError(n,{object:"templates",objectId:r,fallbackCode:"documentTemplate.patch",action:`${cd}/${Rk}`,actionPayload:arguments[1]}),null}finally{t(Bn,!1)}},async[o7]({rootGetters:t},{id:e}){if(!e)return;const r=t["settings/getCompanySetting"]("templateHiddenIds")||[];r.push(e),await this.dispatch(Oe.UPDATE_SETTINGS,{key:"company",settings:{templateHiddenIds:r}})},async[s7]({commit:t,dispatch:e,rootGetters:r},{body:n}){try{t(Bn,!0);const a=ni(n,["_id","id","companyId"]),o=await e(n7,{body:a});return await e(o7,{id:n.id}),o}catch(a){throw a}finally{t(Bn,!1)}}},{SET_TEMPLATES:B2e,SET_TEMPLATE_FETCHING:Y2e,SET_TEMPLATE_POSTING:G2e,DELETE_MANY_TEMPLATES:K2e}=sx,X2e={[B2e](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a template or an array of templates!");const r=Array.isArray(e)?e:[e],n=[];r.forEach(a=>{!a.id||(t.ids.includes(a.id)||n.push(a.id),ce.set(t.data,a.id,a))}),t.ids=eo([...n,...t.ids])},[Y2e](t,e){t.isFetching=e},[G2e](t,e){t.isPosting=e},[K2e](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{!t.data[n]||(ce.delete(t.data,n),t.ids=t.ids.filter(a=>a!==n))})}},J2e={namespaced:!0,state:U2e,getters:{byId:t=>e=>t.data[e]?new fi(t.data[e]):null,idList:t=>t.ids,isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,hiddenTemplateIds:(t,e,r,n)=>n["settings/getCompanySetting"]("templateHiddenIds")||[],availableTemplates:(t,e)=>{const{idList:r,hiddenTemplateIds:n}=e;return r.filter(o=>!n.includes(o)).map(o=>new fi(t.data[o]))},hiddenTemplates:(t,e)=>{const{idList:r,hiddenTemplateIds:n}=e;return n.filter(o=>r.includes(o)).map(o=>new fi(t.data[o]))}},actions:q2e,mutations:X2e},Q2e={data:{},ids:[],isFetching:!1,isPosting:!1},Zs="documents2",{DELETE_DOCUMENT2:l7,DO_CREATE_DOCUMENT2:Z2e,DO_LOAD_DOCUMENT2:xo,DO_LOAD_DOCUMENTS2:d7,DO_UPDATE_DOCUMENT2:Ym,LOAD_DOCUMENT2:c7,LOAD_DOCUMENTS2:Ik,LOAD_DOCUMENTS2_EXTERNAL:eAe,PATCH_DOCUMENT2:Nk,UPDATE_DOCUMENT2:f7,UPDATE_DOCUMENT2_STATUS:m7,DO_SEND_DOCUMENT2:tAe,SEND_REMINDER_DOCUMENT2:rAe,REQUEST_PROPERTY_DOCUMENT2:nAe,CLEAR_DOCUMENT2_ANSWERS:p7,ANSWER_OWN_DOCUMENT2:aAe}=jV,{DELETE_MANY_DOCUMENTS2:iAe,SET_DOCUMENT2_POSTING:ar,SET_DOCUMENT2_FETCHING:Gm,SET_DOCUMENTS2:h7}=ax,{SHOW_MESSAGE:oAe,DO_LOAD_CURRENT_COMPANY:sAe}=Oe,uAe={async[xo]({commit:t},{id:e}){try{t(Gm,!0);const{data:r}=await Kr.get(e);t(h7,{data:[r]})}catch(r){throw r}finally{t(Gm,!1)}},async[d7]({commit:t},e={}){try{t(Gm,!0);const{data:r}=await Kr.getAll(e),{items:n}=r;t(h7,{data:n})}catch(r){throw r}finally{t(Gm,!1)}},async[Ik]({dispatch:t},e={isHidden:!1}){try{await t(d7,e)}catch(r){this.handleError(r,{object:"document2",fallbackCode:"document2.getMany",action:`${Zs}/${Ik}`})}},async[eAe]({dispatch:t},{service:e,type:r=null,typeId:n=null}){if(typeof e>"u")throw new Error("Missing param service");await t(Ik,{isHidden:!1,returnType:"template","externalReferences.service":e,...r&&{"externalReferences.type":r},...n&&{"externalReferences.typeId":n}})},async[c7]({dispatch:t},{id:e}){try{await t(xo,{id:e})}catch(r){this.handleError(r,{object:"document2",fallbackCode:"document2.getOne",action:`${Zs}/${c7}`,actionPayload:arguments[1]})}},async[Z2e]({rootGetters:t,commit:e,dispatch:r},{body:n}){try{e(ar,!0);const{data:a}=await Kr.post(n),{id:o}=a;return await r(xo,{id:o}),t["application/companyAccountType"]==="free"&&await this.dispatch(sAe),o}catch(a){throw a}finally{e(ar,!1)}},async[tAe]({commit:t},{id:e}){try{t(ar,!0),await Kr.send(e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("sentThing",{thing:be.t("document")}),omit:"$view:extension"})}catch(r){throw r}finally{t(ar,!1)}},async[rAe]({commit:t},{id:e,body:r={}}){try{const n={views:{sms:{nodes:[{nodeId:1,parentId:null,itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.reminder.text"}}]},email:{nodes:[{nodeId:1,parentId:null,itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.reminder.subject",title:"data.emailTemplate.reminder.title",content:"data.emailTemplate.reminder.content",text:"data.emailTemplate.reminder.text"}}]}}};t(ar,!0),await Kr.send(e,{...n,...r,sendSource:"reminder"}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("sentThing",{thing:be.t("reminder")})})}catch(n){throw n}finally{t(ar,!1)}},async[nAe]({commit:t},{id:e,body:r={}}){try{const n={views:{sms:{nodes:[{nodeId:1,parentId:null,itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.propertyDesignation.text"}}]},email:{nodes:[{nodeId:1,parentId:null,itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.propertyDesignation.subject",title:"data.emailTemplate.propertyDesignation.title",content:"data.emailTemplate.propertyDesignation.content",text:"data.emailTemplate.propertyDesignation.text",actionUrl:"data.emailTemplate.propertyDesignation.actionUrl"}}]}}},{data:a}=await Kr.get(e),o=s=>be.t(`propertyDesignationRequest.${s}`,{ns:"actions",interpolation:{prefix:"__",suffix:"__"}});Xt(a,"data.smsTemplate.propertyDesignation",{text:o("smsTemplate.text")}),Xt(a,"data.emailTemplate.propertyDesignation",{subject:o("emailTemplate.subject"),title:o("emailTemplate.title"),content:o("emailTemplate.content"),text:o("emailTemplate.text"),actionUrl:o("emailTemplate.actionUrl")});const i={...n,document:a,clients:[a.clients[0]]};t(ar,!0),await Kr.send(e,{...i,...r,sendSource:"propertyDesignation"}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("actions:propertyDesignationRequest.successMessage")})}catch(n){throw n}finally{t(ar,!1)}},async[Ym]({dispatch:t,commit:e},{id:r,body:n,params:a={},showMessage:o=!0}){try{return e(ar,!0),await Kr.put(r,n,a),await t(xo,{id:r}),o&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("document")}),omit:"$view:extension"}),r}catch(i){throw i}finally{e(ar,!1)}},async[f7]({dispatch:t},{id:e,body:r,params:n={}}){try{return await t(Ym,{id:e,body:r,params:n}),e}catch(a){return this.handleError(a,{object:"document2",objectId:e,fallbackCode:"document2.put",action:`${Zs}/${f7}`,actionPayload:arguments[1]}),null}},async[l7]({commit:t},{id:e}){try{return t(ar,!0),await Kr.delete(e),t(iAe,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("document")}),actions:{undo:()=>{this.dispatch(`documents2/${Nk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"document2",objectId:e,fallbackCode:"document2.delete",action:`${Zs}/${l7}`,actionPayload:arguments[1]}),null}finally{t(ar,!1)}},async[Nk]({commit:t,dispatch:e},{id:r}){try{return t(ar,!0),await Kr.patch(r),await e(xo,{id:r}),r}catch(n){return this.handleError(n,{object:"document2",objectId:r,fallbackCode:"document2.patch",action:`${Zs}/${Nk}`,actionPayload:arguments[1]}),null}finally{t(ar,!1)}},async[m7]({dispatch:t,getters:e},{id:r,status:n}){try{const{hasAnswers:a}=e.byId(r)||{};return a&&!["accepted","denied"].includes(n)?await this.dispatch(oAe,{displayType:"dialog",type:"warning",title:be.t("actions:updateDocumentDialog.title"),message:be.t("actions:updateDocumentDialog.message"),actions:{cancel:{text:be.t("actions:updateDocumentDialog.cancel"),callback:"cancel"},submit:{text:be.t("actions:updateDocumentDialog.submit"),callback:async()=>{await t(p7,{id:r,doFetch:!1}),await t(Ym,{id:r,body:{status:n}})}}}}):await t(Ym,{id:r,body:{status:n}}),r}catch(a){return this.handleError(a,{object:"document2",objectId:r,fallbackCode:"document2.updateStatus",action:`${Zs}/${m7}`,actionPayload:arguments[1]}),null}},async[p7]({dispatch:t},{id:e,doFetch:r=!0}){await Kr.clearAnswers(e),r&&await t(xo,{id:e})},async[aAe]({commit:t,dispatch:e},{id:r,publicId:n,body:a,checksum:o}){try{t(ar,!0);const i={docChecksum:o},{data:s}=await L3.answer(n,a,{},i);return await e(xo,{id:r}),s}catch(i){throw i}finally{t(ar,!1)}}},{DELETE_MANY_DOCUMENTS2:lAe,SET_DOCUMENTS2:dAe,SET_DOCUMENT2_FETCHING:cAe,SET_DOCUMENT2_POSTING:fAe}=ax,mAe={[dAe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a document2 or an array of documents2!");const r=Array.isArray(e)?e:[e],n=[];r.forEach(a=>{!a.id||(t.ids.includes(a.id)||n.push(a.id),ce.set(t.data,a.id,a))}),t.ids=eo([...n,...t.ids])},[lAe](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{!t.data[n]||(ce.delete(t.data,n),t.ids=t.ids.filter(a=>a!==n))})},[cAe](t,e){t.isFetching=e},[fAe](t,e){t.isPosting=e}},pAe={namespaced:!0,state:Q2e,getters:{byData:(t,e,r,n)=>({data:a,documentOptions:o})=>new Js({data:a,documentOptions:o,can:lo.checkPermission.bind(lo),getters:n}),byId:(t,e)=>r=>{const n=t.data[r];return n?e.byData({data:n}):null},byExternalReference:(t,e)=>({service:r,type:n=null,typeId:a=null})=>{if(typeof r>"u")throw new Error("Missing param service");if(typeof r!="string")throw new Error("Param service must be a string");return t.ids.filter(i=>{const s=t.data[i],{externalReferences:u=[]}=s;return u.some(l=>l.service===r&&(!n||l.type===n)&&(!a||l.typeId===a))}).map(i=>e.byId(i))},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching},actions:uAe,mutations:mAe},hAe={data:{},ids:[],isFetching:!1,isPosting:!1},vi="endCustomers",{SET_ENDCUSTOMER_FETCHING:Km,SET_ENDCUSTOMER_POSTING:gi,CLEAR_END_CUSTOMER:vAe}=Us,{LOAD_ENDCUSTOMERS:v7,LOAD_ENDCUSTOMER:Xm,UPDATE_ENDCUSTOMER:Lk,CREATE_ENDCUSTOMER:Wk,DELETE_ENDCUSTOMER:g7,PATCH_ENDCUSTOMER:Fk,FORM_NEW_ENDCUSTOMER:y7,FORM_EDIT_ENDCUSTOMER:gAe,FORM_SUBMIT_ENDCUSTOMER:_7}=HV,yAe={async[v7]({commit:t},{options:e={}}={}){try{t(Km,!0);const r={...typeof e.start=="number"&&{_start:e.start},...e.end&&{_end:e.end},...e.sort&&{_sort:e.sort},...e.order&&{_order:e.order}};if(e.searchQuery.trim()){const a=encodeURIComponent(e.searchQuery);r._where=`or(name*=${a},email*=${a},cellphone*=${a})`}e.clearOld&&t(vAe);const{data:n}=await she(r);return t(Us.SET_ENDCUSTOMERS,{data:n}),n.length}catch(r){return this.handleError(r,{object:"endCustomer",fallbackCode:"endCustomer.getAll",action:`${vi}/${v7}`}),!1}finally{t(Km,!1)}},async[Xm]({commit:t},{id:e}){try{t(Km,!0);const{data:r}=await uhe(e);t(Us.SET_ENDCUSTOMERS,{data:r})}catch(r){this.handleError(r,{object:"endCustomer",objectId:e,fallbackCode:"endCustomer.get",action:`${vi}/${Xm}`,actionPayload:arguments[1]})}finally{t(Km,!1)}},async[Wk]({commit:t},{body:e,showNotification:r=!0}){try{t(gi,!0);const{data:n}=await lhe(e);return t(Us.SET_ENDCUSTOMERS,{data:n}),r&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("client")})}),n.id}catch(n){return this.handleError(n,{object:"endCustomer",fallbackCode:"endCustomer.post",action:`${vi}/${Wk}`,actionPayload:arguments[1]}),null}finally{t(gi,!1)}},async[Lk]({dispatch:t,commit:e},{id:r,body:n}){try{return e(gi,!0),await dhe(r,n),await t(Xm,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("client")})}),!0}catch(a){return this.handleError(a,{object:"endCustomer",objectId:r,fallbackCode:"endCustomer.put",action:`${vi}/${Lk}`,actionPayload:arguments[1]}),null}finally{e(gi,!1)}},async[g7]({commit:t},{id:e}){try{return t(gi,!0),await che(e),t(Us.DELETE_ENDCUSTOMER,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("client")}),actions:{undo:()=>{this.dispatch(`endCustomers/${Fk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"endCustomer",objectId:e,fallbackCode:"endCustomer.delete",action:`${vi}/${g7}`,actionPayload:arguments[1]}),null}finally{t(gi,!1)}},async[Fk]({dispatch:t,commit:e},{id:r}){try{return e(gi,!0),await fhe(r),await t(Xm,{id:r}),r}catch(n){return this.handleError(n,{object:"endCustomer",objectId:r,fallbackCode:"endCustomer.patch",action:`${vi}/${Fk}`,actionPayload:arguments[1]}),null}finally{e(gi,!1)}},async[y7](){try{const t={id:null,customerType:"individual",org_no:null,name:null,reference:null,email:null,street:null,zip:null,city:null,cellphone:null,cellphoneRegion:null,separateWorkAddress:!1,workStreet:null,workZip:null,workCity:null,reverseVat:!1,vatNumber:null,externalId:null,note:null};return this.commit(`forms/${De.SET_FORM}`,{key:"endCustomer",formData:t}),!0}catch(t){return this.handleError(t,{object:"endCustomer",action:`${vi}/${y7}`}),!1}},async[gAe]({getters:t},{id:e,props:r=[]}){const n=ya(t.endCustomerById(e),r);this.dispatch(`forms/${De.forms.SET_FORM_VALUE}`,{key:"endCustomer",value:n})},async[_7]({rootGetters:t,dispatch:e},{showNotification:r=!0}={}){try{const n=t["forms/getFormByKey"]("endCustomer");let{id:a}=n;return a?await e(Lk,{id:n.id,body:n}):a=await e(Wk,{body:n,showNotification:r}),a}catch(n){return this.handleError(n,{object:"endCustomer",fallbackCode:"endCustomer.submit",action:`${vi}/${_7}`}),null}}},{CLEAR_END_CUSTOMER:_Ae,SET_ENDCUSTOMERS:bAe,DELETE_ENDCUSTOMER:wAe,SET_ENDCUSTOMER_FETCHING:xAe,SET_ENDCUSTOMER_POSTING:kAe}=Us,PAe={[bAe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a company user or an array of company users!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[wAe](t,e){ce.delete(t.data,e);const r=t.ids.indexOf(e);r!==-1&&t.ids.splice(r,1)},[_Ae](t){ce.set(t,"data",{}),ce.set(t,"ids",[])},[xAe](t,e){t.isFetching=e},[kAe](t,e){t.isPosting=e}},TAe={namespaced:!0,state:hAe,getters:{endCustomerById:t=>e=>t.data[e],isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,idList:t=>t.ids,clients:t=>t.data},actions:yAe,mutations:PAe},Yn=Object.create(null);Yn.open="0",Yn.close="1",Yn.ping="2",Yn.pong="3",Yn.message="4",Yn.upgrade="5",Yn.noop="6";const Jm=Object.create(null);Object.keys(Yn).forEach(t=>{Jm[Yn[t]]=t});const MAe={type:"error",data:"parser error"},SAe=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",OAe=typeof ArrayBuffer=="function",EAe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,b7=({type:t,data:e},r,n)=>SAe&&e instanceof Blob?r?n(e):w7(e,n):OAe&&(e instanceof ArrayBuffer||EAe(e))?r?n(e):w7(new Blob([e]),n):n(Yn[t]+(e||"")),w7=(t,e)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];e("b"+n)},r.readAsDataURL(t)},x7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",md=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<x7.length;t++)md[x7.charCodeAt(t)]=t;const DAe=t=>{let e=t.length*.75,r=t.length,n,a=0,o,i,s,u;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),d=new Uint8Array(l);for(n=0;n<r;n+=4)o=md[t.charCodeAt(n)],i=md[t.charCodeAt(n+1)],s=md[t.charCodeAt(n+2)],u=md[t.charCodeAt(n+3)],d[a++]=o<<2|i>>4,d[a++]=(i&15)<<4|s>>2,d[a++]=(s&3)<<6|u&63;return l},CAe=typeof ArrayBuffer=="function",k7=(t,e)=>{if(typeof t!="string")return{type:"message",data:P7(t,e)};const r=t.charAt(0);return r==="b"?{type:"message",data:$Ae(t.substring(1),e)}:Jm[r]?t.length>1?{type:Jm[r],data:t.substring(1)}:{type:Jm[r]}:MAe},$Ae=(t,e)=>{if(CAe){const r=DAe(t);return P7(r,e)}else return{base64:!0,data:t}},P7=(t,e)=>{switch(e){case"blob":return t instanceof ArrayBuffer?new Blob([t]):t;case"arraybuffer":default:return t}},T7=String.fromCharCode(30),AAe=(t,e)=>{const r=t.length,n=new Array(r);let a=0;t.forEach((o,i)=>{b7(o,!1,s=>{n[i]=s,++a===r&&e(n.join(T7))})})},RAe=(t,e)=>{const r=t.split(T7),n=[];for(let a=0;a<r.length;a++){const o=k7(r[a],e);if(n.push(o),o.type==="error")break}return n},M7=4;function jt(t){if(t)return IAe(t)}function IAe(t){for(var e in jt.prototype)t[e]=jt.prototype[e];return t}jt.prototype.on=jt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},jt.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},jt.prototype.off=jt.prototype.removeListener=jt.prototype.removeAllListeners=jt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,a=0;a<r.length;a++)if(n=r[a],n===e||n.fn===e){r.splice(a,1);break}return r.length===0&&delete this._callbacks["$"+t],this},jt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,a=r.length;n<a;++n)r[n].apply(this,e)}return this},jt.prototype.emitReserved=jt.prototype.emit,jt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},jt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const yi=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function S7(t,...e){return e.reduce((r,n)=>(t.hasOwnProperty(n)&&(r[n]=t[n]),r),{})}const NAe=setTimeout,LAe=clearTimeout;function Qm(t,e){e.useNativeTimers?(t.setTimeoutFn=NAe.bind(yi),t.clearTimeoutFn=LAe.bind(yi)):(t.setTimeoutFn=setTimeout.bind(yi),t.clearTimeoutFn=clearTimeout.bind(yi))}const WAe=1.33;function FAe(t){return typeof t=="string"?jAe(t):Math.ceil((t.byteLength||t.size)*WAe)}function jAe(t){let e=0,r=0;for(let n=0,a=t.length;n<a;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}class VAe extends Error{constructor(e,r,n){super(e),this.description=r,this.context=n,this.type="TransportError"}}class O7 extends jt{constructor(e){super(),this.writable=!1,Qm(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,r,n){return super.emitReserved("error",new VAe(e,r,n)),this}open(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const r=k7(e,this.socket.binaryType);this.onPacket(r)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}}const E7="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),jk=64,zAe={};let D7=0,Zm=0,C7;function $7(t){let e="";do e=E7[t%jk]+e,t=Math.floor(t/jk);while(t>0);return e}function A7(){const t=$7(+new Date);return t!==C7?(D7=0,C7=t):t+"."+$7(D7++)}for(;Zm<jk;Zm++)zAe[E7[Zm]]=Zm;function R7(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}function UAe(t){let e={},r=t.split("&");for(let n=0,a=r.length;n<a;n++){let o=r[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}let I7=!1;try{I7=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const HAe=I7;function N7(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||HAe))return new XMLHttpRequest}catch{}if(!e)try{return new yi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function qAe(){}const BAe=function(){return new N7({xdomain:!1}).responseType!=null}();class YAe extends O7{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const n=location.protocol==="https:";let a=location.port;a||(a=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||a!==e.port,this.xs=e.secure!==n}const r=e&&e.forceBase64;this.supportsBinary=BAe&&!r}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const r=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};RAe(e,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,AAe(e,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const r=this.opts.secure?"https":"http";let n="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=A7()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(r==="https"&&Number(this.opts.port)!==443||r==="http"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port);const a=R7(e),o=this.opts.hostname.indexOf(":")!==-1;return r+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(a.length?"?"+a:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new Gn(this.uri(),e)}doWrite(e,r){const n=this.request({method:"POST",data:e});n.on("success",r),n.on("error",(a,o)=>{this.onError("xhr post error",a,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=e}}class Gn extends jt{constructor(e,r){super(),Qm(this,r),this.opts=r,this.method=r.method||"GET",this.uri=e,this.async=r.async!==!1,this.data=r.data!==void 0?r.data:null,this.create()}create(){const e=S7(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const r=this.xhr=new N7(e);try{r.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document<"u"&&(this.index=Gn.requestsCount++,Gn.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=qAe,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Gn.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Gn.requestsCount=0,Gn.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",L7);else if(typeof addEventListener=="function"){const t="onpagehide"in yi?"pagehide":"unload";addEventListener(t,L7,!1)}}function L7(){for(let t in Gn.requests)Gn.requests.hasOwnProperty(t)&&Gn.requests[t].abort()}const W7=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,r)=>r(e,0))(),ep=yi.WebSocket||yi.MozWebSocket,F7=!0,GAe="arraybuffer",j7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class KAe extends O7{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),r=this.opts.protocols,n=j7?{}:S7(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=F7&&!j7?r?new ep(e,r):new ep(e):new ep(e,r,n)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType||GAe,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],a=r===e.length-1;b7(n,this.supportsBinary,o=>{const i={};try{F7&&this.ws.send(o)}catch{}a&&W7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const r=this.opts.secure?"wss":"ws";let n="";this.opts.port&&(r==="wss"&&Number(this.opts.port)!==443||r==="ws"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=A7()),this.supportsBinary||(e.b64=1);const a=R7(e),o=this.opts.hostname.indexOf(":")!==-1;return r+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(a.length?"?"+a:"")}check(){return!!ep}}const XAe={websocket:KAe,polling:YAe},JAe=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,QAe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Vk(t){const e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let a=JAe.exec(t||""),o={},i=14;for(;i--;)o[QAe[i]]=a[i]||"";return r!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=ZAe(o,o.path),o.queryKey=eRe(o,o.query),o}function ZAe(t,e){const r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function eRe(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,a,o){a&&(r[a]=o)}),r}class _i extends jt{constructor(e,r={}){super(),e&&typeof e=="object"&&(r=e,e=null),e?(e=Vk(e),r.hostname=e.host,r.secure=e.protocol==="https"||e.protocol==="wss",r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=Vk(r.host).host),Qm(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=r.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},r),this.opts.path=this.opts.path.replace(/\/$/,"")+"/",typeof this.opts.query=="string"&&(this.opts.query=UAe(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const r=Object.assign({},this.opts.query);r.EIO=M7,r.transport=e,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new XAe[e](n)}open(){let e;if(this.opts.rememberUpgrade&&_i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",r=>this.onClose("transport close",r))}probe(e){let r=this.createTransport(e),n=!1;_i.priorWebsocketSuccess=!1;const a=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;_i.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(d(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=r.name,this.emitReserved("upgradeError",m)}}))};function o(){n||(n=!0,d(),r.close(),r=null)}const i=f=>{const m=new Error("probe error: "+f);m.transport=r.name,o(),this.emitReserved("upgradeError",m)};function s(){i("transport closed")}function u(){i("socket closed")}function l(f){r&&f.name!==r.name&&o()}const d=()=>{r.removeListener("open",a),r.removeListener("error",i),r.removeListener("close",s),this.off("close",u),this.off("upgrading",l)};r.once("open",a),r.once("error",i),r.once("close",s),this.once("close",u),this.once("upgrading",l),r.open()}onOpen(){if(this.readyState="open",_i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade&&this.transport.pause){let e=0;const r=this.upgrades.length;for(;e<r;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const r=new Error("server error");r.code=e.data,this.onError(r);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let n=0;n<this.writeBuffer.length;n++){const a=this.writeBuffer[n].data;if(a&&(r+=FAe(a)),n>0&&r>this.maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}write(e,r,n){return this.sendPacket("message",e,r,n),this}send(e,r,n){return this.sendPacket("message",e,r,n),this}sendPacket(e,r,n,a){if(typeof r=="function"&&(a=r,r=void 0),typeof n=="function"&&(a=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:e,data:r,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),a&&this.once("flush",a),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),e()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){_i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,r){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,r),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const r=[];let n=0;const a=e.length;for(;n<a;n++)~this.transports.indexOf(e[n])&&r.push(e[n]);return r}}_i.protocol=M7;function tRe(t,e="",r){let n=t;r=r||typeof location<"u"&&location,t==null&&(t=r.protocol+"//"+r.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=r.protocol+t:t=r.host+t),/^(https?|wss?):\/\//.test(t)||(typeof r<"u"?t=r.protocol+"//"+t:t="https://"+t),n=Vk(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+e,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}const rRe=typeof ArrayBuffer=="function",nRe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,V7=Object.prototype.toString,aRe=typeof Blob=="function"||typeof Blob<"u"&&V7.call(Blob)==="[object BlobConstructor]",iRe=typeof File=="function"||typeof File<"u"&&V7.call(File)==="[object FileConstructor]";function zk(t){return rRe&&(t instanceof ArrayBuffer||nRe(t))||aRe&&t instanceof Blob||iRe&&t instanceof File}function tp(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(tp(t[r]))return!0;return!1}if(zk(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return tp(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&tp(t[r]))return!0;return!1}function oRe(t){const e=[],r=t.data,n=t;return n.data=Uk(r,e),n.attachments=e.length,{packet:n,buffers:e}}function Uk(t,e){if(!t)return t;if(zk(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=Uk(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=Uk(t[n],e));return r}return t}function sRe(t,e){return t.data=Hk(t.data,e),t.attachments=void 0,t}function Hk(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=Hk(t[r],e);else if(typeof t=="object")for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=Hk(t[r],e));return t}const uRe=5;var Je;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Je||(Je={}));class lRe{constructor(e){this.replacer=e}encode(e){return(e.type===Je.EVENT||e.type===Je.ACK)&&tp(e)?(e.type=e.type===Je.EVENT?Je.BINARY_EVENT:Je.BINARY_ACK,this.encodeAsBinary(e)):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===Je.BINARY_EVENT||e.type===Je.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),r}encodeAsBinary(e){const r=oRe(e),n=this.encodeAsString(r.packet),a=r.buffers;return a.unshift(n),a}}class qk extends jt{constructor(e){super(),this.reviver=e}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e),r.type===Je.BINARY_EVENT||r.type===Je.BINARY_ACK?(this.reconstructor=new dRe(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(zk(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0;const n={type:Number(e.charAt(0))};if(Je[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Je.BINARY_EVENT||n.type===Je.BINARY_ACK){const o=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);const i=e.substring(o,r);if(i!=Number(i)||e.charAt(r)!=="-")throw new Error("Illegal attachments");n.attachments=Number(i)}if(e.charAt(r+1)==="/"){const o=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(o,r)}else n.nsp="/";const a=e.charAt(r+1);if(a!==""&&Number(a)==a){const o=r+1;for(;++r;){const i=e.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===e.length)break}n.id=Number(e.substring(o,r+1))}if(e.charAt(++r)){const o=this.tryParse(e.substr(r));if(qk.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case Je.CONNECT:return typeof r=="object";case Je.DISCONNECT:return r===void 0;case Je.CONNECT_ERROR:return typeof r=="string"||typeof r=="object";case Je.EVENT:case Je.BINARY_EVENT:return Array.isArray(r)&&r.length>0;case Je.ACK:case Je.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class dRe{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const r=sRe(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cRe=Object.freeze(Object.defineProperty({__proto__:null,protocol:uRe,get PacketType(){return Je},Encoder:lRe,Decoder:qk},Symbol.toStringTag,{value:"Module"}));function hn(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const fRe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class z7 extends jt{constructor(e,r,n){super(),this.connected=!1,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[hn(e,"open",this.onopen.bind(this)),hn(e,"packet",this.onpacket.bind(this)),hn(e,"error",this.onerror.bind(this)),hn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...r){if(fRe.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');r.unshift(e);const n={type:Je.EVENT,data:r};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const i=this.ids++,s=r.pop();this._registerAckCallback(i,s),n.id=i}const a=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!a||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,r){const n=this.flags.timeout;if(n===void 0){this.acks[e]=r;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);r.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(a),r.apply(this,[null,...o])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this.packet({type:Je.CONNECT,data:e})}):this.packet({type:Je.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,r)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Je.CONNECT:if(e.data&&e.data.sid){const a=e.data.sid;this.onconnect(a)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Je.EVENT:case Je.BINARY_EVENT:this.onevent(e);break;case Je.ACK:case Je.BINARY_ACK:this.onack(e);break;case Je.DISCONNECT:this.ondisconnect();break;case Je.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const r=e.data||[];e.id!=null&&r.push(this.ack(e.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,e)}super.emit.apply(this,e)}ack(e){const r=this;let n=!1;return function(...a){n||(n=!0,r.packet({type:Je.ACK,id:e,data:a}))}}onack(e){const r=this.acks[e.id];typeof r=="function"&&(r.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Je.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,e.data)}}}function eu(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}eu.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-r:t+r}return Math.min(t,this.max)|0},eu.prototype.reset=function(){this.attempts=0},eu.prototype.setMin=function(t){this.ms=t},eu.prototype.setMax=function(t){this.max=t},eu.prototype.setJitter=function(t){this.jitter=t};class Bk extends jt{constructor(e,r){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(r=e,e=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Qm(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new eu({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=e;const a=r.parser||cRe;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var r;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(r=this.backoff)===null||r===void 0||r.setMin(e),this)}randomizationFactor(e){var r;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(r=this.backoff)===null||r===void 0||r.setJitter(e),this)}reconnectionDelayMax(e){var r;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(r=this.backoff)===null||r===void 0||r.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new _i(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const a=hn(r,"open",function(){n.onopen(),e&&e()}),o=hn(r,"error",i=>{n.cleanup(),n._readyState="closed",this.emitReserved("error",i),e?e(i):n.maybeReconnectOnOpen()});if(this._timeout!==!1){const i=this._timeout;i===0&&a();const s=this.setTimeoutFn(()=>{a(),r.close(),r.emit("error",new Error("timeout"))},i);this.opts.autoUnref&&s.unref(),this.subs.push(function(){clearTimeout(s)})}return this.subs.push(a),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(hn(e,"ping",this.onping.bind(this)),hn(e,"data",this.ondata.bind(this)),hn(e,"error",this.onerror.bind(this)),hn(e,"close",this.onclose.bind(this)),hn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(r){this.onclose("parse error",r)}}ondecoded(e){W7(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,r){let n=this.nsps[e];return n||(n=new z7(this,e,r),this.nsps[e]=n),n}_destroy(e){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(e){const r=this.encoder.encode(e);for(let n=0;n<r.length;n++)this.engine.write(r[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,r){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(a=>{a?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",a)):e.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const pd={};function rp(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const r=tRe(t,e.path||"/socket.io"),n=r.source,a=r.id,o=r.path,i=pd[a]&&o in pd[a].nsps,s=e.forceNew||e["force new connection"]||e.multiplex===!1||i;let u;return s?u=new Bk(n,e):(pd[a]||(pd[a]=new Bk(n,e)),u=pd[a]),r.query&&!e.query&&(e.query=r.queryKey),u.socket(r.path,e)}Object.assign(rp,{Manager:Bk,Socket:z7,io:rp,connect:rp});class mRe{constructor({apiUrl:e,apiPath:r,logger:n=console,getTokenFn:a}){Ut(this,"_socket",null);Ut(this,"_isConnected",!1);Ut(this,"_autoReconnect",!1);Ut(this,"_localAutoReconnect",!1);Ut(this,"_listeners",[]);Ut(this,"_connectionChangedListener",[]);Ut(this,"_retryCount",0);this.rootUrl=e,this.path=r,this.logger=n,this.getTokenFn=a}set autoReconnect(e){this._autoReconnect=!!e}onConnectionChanged(e){this._connectionChangedListener.push(e)}_onConnectionChanged(e){this._connectionChangedListener.forEach(r=>{try{r(e)}catch(n){console.error(n)}})}setConnected(e){e||(this._retryCount=this._retryCount+1),this.logger.debug(`Socket: isConnected changed to ${e}`);const r=this._isConnected!==e;this._isConnected=e,r&&this._onConnectionChanged(e)}_onConnected(){const e=this.getTokenFn();e&&this._socket.emit("authenticate",{token:e})}on(e,r){this._listeners.push({type:e,fn:r}),this._socket&&this._socket.on(e,r)}async connect(){await(r=>new Promise(n=>setTimeout(n,r*2*1e3)))(this._retryCount),this._socket&&(this._localAutoReconnect=!1,this.disconnect(),this._localAutoReconnect=!0),this._socket=rp(this.apiUrl,{path:this.apiPath}),this._socket.on("connect",this._onConnected.bind(this)),this._socket.on("event",r=>this.logger.debug("Socket: Event:",r)),this._listeners.forEach(({type:r,fn:n})=>{this._socket.on(r,n)}),this._socket.on("disconnect",()=>{this.setConnected(!1),this._localAutoReconnect&&this._autoReconnect&&this.connect()}),this._socket.on("authenticated",()=>{this._retryCount=0,this.setConnected(!0)}),this._socket.on("unauthorized",()=>{this.setConnected(!1)})}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const hd=new mRe({rootUrl:Me.api.socket.rootUrl,path:Me.api.socket.path,logger:Tt,getTokenFn:()=>Xe.getItem("token")}),pRe=t=>{hd.onConnectionChanged(e=>{t.commit(`application/${De.application.SET_SOCKET_CONNECTED}`,e)}),hd.on("event",({type:e,action:r,id:n})=>{e==="document"?t.getters["documents2/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`documents2/${De.documents2.DELETE_MANY_DOCUMENTS2}`,n):t.dispatch(Oe.LOAD_DOCUMENT2,{id:n})},1):e==="template"?t.getters["templates/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`templates/${De.templates.DELETE_MANY_TEMPLATES}`,n):t.dispatch(Oe.LOAD_TEMPLATE,{id:n})},1):e==="notification"?setTimeout(()=>{r==="deleted"?t.commit(`notifications/${De.notifications.DELETE_MANY_NOTIFICATIONS}`,n):t.dispatch(Oe.LOAD_NOTIFICATION,{id:n})},1):e==="project"?t.getters["projects/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`projects/${De.projects.DELETE_MANY_PROJECTS}`,n):t.dispatch(Oe.LOAD_PROJECT,{id:n})},1):e==="companyUser"?t.getters["companyUsers/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`companyUsers/${De.DELETE_COMPANY_USER}`,n):t.dispatch(Oe.LOAD_COMPANY_USER,{id:n})},1):e==="companyAccount"?setTimeout(()=>{t.dispatch(Oe.DO_LOAD_CURRENT_COMPANY)},1):e==="companySetting"?setTimeout(()=>{r==="deleted"?t.commit(`settings/${De.settings.CLEAR_SETTINGS}`,{key:"company",name:n}):t.dispatch(Oe.LOAD_SETTINGS_COMPANY)},1):e==="companyUserSetting"?setTimeout(()=>{r==="deleted"?t.commit(`settings/${De.settings.CLEAR_SETTINGS}`,{key:"companyUser",name:n}):t.dispatch(Oe.LOAD_SETTINGS_COMPANYUSER)},1):e==="systemClient"&&r==="refreshToken"&&setTimeout(()=>{Wpe()},1)}),t.subscribe(async e=>{const{type:r,payload:n}=e;r==="application/SET_USER"&&n&&typeof n.userId<"u"&&(hd.autoReconnect=!!n.userId,n.userId?await hd.connect():n.userId===null&&await hd.disconnect())})},U7={projectFiles:"projects",certificates:"certificates",companies:"companies",companyUsers:"companyUsers",projects:"projects",invoices:"invoices",companyReferences:"companyReferences",companyReferenceItems:"companyReferenceItems",files:"files",documents:"documents",timeTracks:"timeTracks",documentTerms:"documentTerms"},H7={projects:De.SET_PROJECTS,invoices:De.invoices.SET_INVOICES,offers:De.SET_OFFERS,companyUsers:De.SET_COMPANY_USERS,companies:De.companies.SET_COMPANIES,events:De.SET_EVENTS,atas:De.SET_ATAS,contracts:De.SET_CONTRACTS,projectNotes:De.SET_PROJECT_NOTES,projectFiles:De.SET_PROJECT_FILES,articles:De.SET_ARTICLES,certificates:De.certificates.SET_CERTIFICATES,companyReferenceItems:De.companyReferenceItems.SET_COMPANY_REFERENCE_ITEMS,companyReferences:De.companyReferences.SET_COMPANY_REFERENCES,files:De.files.UPDATE_MANY_FILES,notifications:De.SET_NOTIFICATIONS,templateMessages:De.SET_TEMPLATE_MESSAGES,timeTracks:De.timeTracks.SET_TIME_TRACKS,documentTerms:De.documentTerms.SET_DOCUMENT_TERMS},hRe={[uo](t,e){const r={includedModules:void 0,excludedModules:void 0,schema:void 0,data:void 0,moduleOpts:{},...e};if(!r.schema||!r.data)throw Error("Unable to normalize data, missing schema or data");const n=Array.isArray(r.data)?r.data:[r.data];let a;typeof r.schema=="string"?{entities:a}=vke(n,r.schema):(console.warn(`Calling normalize with old schema for ${r.schema.schema.key}`),{entities:a}=lz(n,r.schema));let o=Object.keys(a);o=o.filter(i=>(!r.includedModules||r.includedModules.includes(i))&&(!r.excludedModules||!r.excludedModules.includes(i))),o.forEach(i=>{if(!H7[i]){Tt.warn(`setActions: '${i}', does not exist`);return}if(!U7[i]){Tt.warn(`moduleKeys: '${i}', does not exist`);return}const s={doClearOld:!1,...r.moduleOpts[i]||{}};this.commit(`${U7[i]}/${H7[i]}`,{data:Object.keys(a[i]).map(u=>a[i][u]),...s})})}};/**
539
+ {{docLink}}`}}}}},Wm={isEditable:!1,nodes:[{itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.first.subject",text:"data.emailTemplate.first.text",title:"data.emailTemplate.first.title",content:"data.emailTemplate.first.content"}}]},Fm={isEditable:!1,nodes:[{itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.first.text"}}]},uk={type:"object",default:{useVat:Me.brand==="cling",vatType:"vat",rounding:{enabled:Me.brand==="cling",interval:Me.brand==="cling"?100:1,show:Me.brand==="cling"}}},lk={$ref:`${Me.api.baseUrl}/schemas/css/1.json`,default:{'[data-typography="title"]':{fontFamily:"Inter",fontSize:"56px",fontWeight:800},h1:{fontFamily:"Inter",fontSize:"48px",fontWeight:800},h2:{fontFamily:"Inter",fontSize:"36px",fontWeight:700},h3:{fontFamily:"Inter",fontSize:"21px",fontWeight:600},blockquote:{fontFamily:"Inter",fontSize:"18px",borderLeftStyle:"solid",borderLeftWidth:"3px",borderColor:"currentColor"},p:{fontFamily:"Inter",fontSize:"16px"}}},dk={type:"object",default:{}},ck={anyOf:[{type:"string"},{type:"null"}]},fk={anyOf:[{type:"string"},{type:"null"}]},mk={anyOf:[{type:"string"},{type:"null"}]},pk={$ref:`${Me.api.baseUrl}/schemas/price/1.json`},hk={type:"string",format:"date-time"},vk={type:"object"},KU={reminders:ld,smsTemplate:ok,emailTemplate:sk,emailView:Wm,smsView:Fm,formSettings:uk,sender:dk,name:ck,senderString:fk,receiverString:mk,prices:pk,css:lk,expiresAt:hk,fields:vk};class KOe{constructor({data:e,clients:r=[],useVat:n,rounding:a,currency:o}){if(!e)throw new Error("Missing param data");this._data=e,this._clients=r,this._useVat=n,this._rounding=a,this._currency=o}get data(){return this._data}get useVat(){return this._useVat}get rounding(){return this._rounding}get title(){return this._data.title}get type(){return this._data.type}get selectedPackages(){return this.packages.filter(e=>e.isSelected)||[]}get selectedArticles(){return this.selectedPackages.reduce((e,{articles:r})=>[...e,...r],[])}get priceType(){return te(this,"selectedPackages[0].prices.type","fixed")}get currency(){return te(this,"selectedPackages[0].prices.currency")||this._currency}get maxTotal(){return this.priceType==="openAccMaxPrice"?this.selectedPackages.reduce((e,{prices:r})=>e+r.maxTotal,0):null}get houseWorkManualAmount(){return this.selectedPackages.some(({prices:e})=>te(e,"region.houseWorkManualAmount",null)!==null)?this.selectedPackages.reduce((e,{prices:r})=>{const{houseWorkManualAmount:n}=r.region||{};return n?e+n:e},0):null}get prices(){return Om({type:this.priceType,currency:this.currency,articles:this.selectedArticles,clients:this._clients,maxTotal:this.maxTotal,region:{country:"sweden",houseWorkManualAmount:this.houseWorkManualAmount},useVat:this._useVat,rounding:this._rounding})}get packages(){return this._data.packages.map(e=>({...e,type:this.type,prices:Om({type:te(e,"data.prices.type","fixed"),currency:te(e,"data.prices.currency")||this.currency,articles:e.articles,clients:e.clients,maxTotal:te(e,"data.prices.maxTotal",null),region:{country:"sweden",houseWorkManualAmount:te(e,"data.prices.region.houseWorkManualAmount",null)},useVat:this._useVat,rounding:this._rounding})}))||[]}get articles(){return this.packages.reduce((e,{articles:r})=>[...e,...r],[])}getPackageById(e){return this.packages.find(({packageId:r})=>r===e)}}class XOe{constructor({data:e={},articles:r=[],clients:n=[],useVat:a,rounding:o,currency:i}){if(!e)throw new Error("Missing param data");this._data=Object.keys(e||{}).reduce((s,u)=>({...s,[u]:new KOe({data:{...e[u],packages:e[u].packages.map(l=>({...l,articles:r.filter(({packageId:d})=>d===l.packageId),clients:n}))},clients:n,useVat:a,rounding:o,currency:i})}),{})}get packages(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].packages],[])}get selectedPackages(){return this.packages.filter(({isSelected:e})=>e)}get selectedArticles(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].selectedArticles],[])}get selectedIds(){return Object.keys(this._data).reduce((e,r)=>[...e,...this._data[r].packages.filter(({isSelected:n})=>n).map(({packageId:n})=>n)],[])}get groups(){return Object.keys(this._data).map(e=>this._data[e])}get groupsPrices(){return(this.groups||[]).map(({prices:e})=>e)}getPackageGroupById(e){const r=Object.keys(this._data).find(n=>this._data[n].packages.find(({packageId:a})=>a===e));return this._data[r]}getPackageGroupUniqId(e){return this._data[e]||{}}getPackageById(e){const r=this.getPackageGroupById(e);return r?r.getPackageById(e):{}}}function JOe(t){if(!t||!t.data)return t;const{brand:e}=Me,r={useVat:e==="cling",vatType:"vat",rounding:{enabled:e==="cling",interval:e==="cling"?100:1,show:e==="cling"}};t.data.formSettings||(t.data.formSettings={});const n=D3(r);return Object.keys(n).forEach(a=>{function o(i,s,u){_Te(i[s])?Object.keys(i[s]).forEach(l=>{o(i[s],l,u)}):Array.isArray(i[s])?i[s].forEach((l,d)=>{o(i[s],d,u)}):typeof te(i,s)>"u"&&Xt(i,s,u)}o(t.data.formSettings,a,n[a])}),t}class QOe{constructor(e,{computedPricing:r=!0,isPreview:n=!1,readPrices:a=!0,props:o={},settingsTheme:i={}}={}){if(!e)throw new Error("Missing param data");this._doc=e,this._doc=wPe(this._doc,i),this._doc=JOe(this._doc),this._computedPricing=r,this._theme=i,this._props=o,this._readPrices=a,this._isPreview=n,this._pdfOptions={},this._template=this._doc.template?new fi(this._doc.template):null,this._dirtyKeys={}}get data(){return this._doc.data}deleteProperty(e){ITe(this,`_doc.${e}`)}get receiverString(){return te(this._doc,"data.receiverString")||te(this._props,"defaultReceiverString")||be.t("_common:receiver",{lng:this.language,postProcess:"capitalize"})}get senderString(){return te(this._doc,"data.senderString")||te(this._props,"defaultSenderString")||be.t("_common:sender",{lng:this.language,postProcess:"capitalize"})}get sender(){const e=te(this._doc,"data.sender",{});return{company:{...this._doc.company&&{publicId:this._doc.company.publicId,name:this._doc.company.name,orgNo:this._doc.company.organisationNumber,phone:this._doc.company.phone,logotype:this._doc.company.LogotypePublicId?`${Me.api.baseUrl}/file/${this._doc.company.LogotypePublicId}/download`:null,hasFSkatt:this._doc.company.fSkatt,hasInsurance:this._doc.company.insurance,region:this._doc.company.region},...td(e.company)},user:{...this._doc.companyUser&&{name:`${this._doc.companyUser.firstname||""} ${this._doc.companyUser.lastname||""}`.trim(),email:this._doc.companyUser.email,cellphone:this._doc.companyUser.cellphone,avatar:this._doc.companyUser.AvatarPublicId?`${Me.api.baseUrl}/file/${this._doc.companyUser.AvatarPublicId}/download`:null},...td(e.user)}}}set sender(e){e.company&&(this._doc.company=e.company),e.user&&(this._doc.companyUser=e.user)}get senderClient(){return this._doc.senderClient?{...this._doc.senderClient,isSender:!0}:null}get viewer(){return this._doc.viewerId?this.clients.find(({publicDocumentId:r})=>r===this._doc.viewerId):null}get remainingSignatures(){return this.clients.filter(({documentRole:e})=>["signee","approver"].includes(e)).reduce((e,r)=>te(r,"answer.didAccept")?e:e+1,0)}get answerActions(){const e={canAnswer:!1,hasAnswered:!1,showActions:!1,waitingForOthers:!1},r=!!te(this.viewer,"answer"),n=!!te(this.viewer,"answerMethod.accept",!1)&&["signee","approver"].includes(te(this.viewer,"documentRole")),a=["sent","draft"].includes(this.status);return n&&a&&!r&&(e.canAnswer=!0),e.showActions=n||this.isPreview,e.hasAnswered=r,e.waitingForOthers=r&&a,e}get id(){return this._doc.id||null}set id(e){this._doc.id=e}get publicId(){return this._doc.publicId||null}get name(){return this.data.name||null}set name(e){this.data.name=e}get articles(){return[...this.packageGroups.selectedArticles,...this.allArticles.filter(({packageId:e})=>!e)]}get allArticles(){return this._doc.articles||[]}set allArticles(e){this._doc.articles=e}get createdAt(){return this._doc.createdAt}get sentAt(){return this._doc.sentAt||null}get lastSentAt(){return this._doc.lastSentAt||null}get expiresAt(){return this.data.expiresAt||null}set expiresAt(e){this.data.expiresAt=e}get acceptedAt(){return this._doc.acceptedAt||null}get projectId(){return this._doc.projectId||null}get docNumber(){return this._doc.docNumber||{series:"document",value:null}}set docNumber(e){this._doc.docNumber=e}get status(){return this._doc.status||null}get useSignOrder(){return this._doc.useSignOrder||!1}get clients(){return this._doc.clients||[]}set clients(e){this._doc.clients=e}get recipients(){return[...this.senderClient?[this.senderClient]:[],...this.clients]}get template(){return this._template}get isPreview(){return this._isPreview||!1}get isHidden(){return this._doc.isHidden||!1}get excludeFromStats(){return this._doc.excludeFromStats||!1}get setPricesIncVat(){return te(this,"data.formSettings.setPricesIncVat",null)&&this.useVat}get formSettings(){return te(this,"data.formSettings")}get useVat(){return this.formSettings.useVat}get rounding(){return this.formSettings.rounding}get vatType(){return this.formSettings.vatType}get rejectReasons(){const{rejectReasons:e}=this.data;if(!e)return null;const r=ot(e);return r==="array"?e:r==="object"?Object.keys(e).map(n=>e[n]):null}get personalMessage(){return this.data.personalMessage||null}get sourceDocument(){return this.data.sourceDocument||null}get reminders(){return this._doc.data.reminders||[]}set reminders(e){this._doc.data.reminders=e}set packageGroups(e){this._doc.data.packageGroups=e}get packageGroups(){return new XOe({data:this._doc.data.packageGroups,articles:this.allArticles,clients:this.clients,useVat:this.useVat,rounding:this.rounding,currency:this.currency})}get events(){const{events:e=[]}=this._doc,r=e.filter(a=>a.code!=="statusChanged"||["accepted","denied"].includes(a.data.status)),n=this.clients.filter(a=>["signee","approver"].includes(a.documentRole)).length;for(const[a,o]of r.entries()){const i=r[a+1];!i||i.code==="statusChanged"&&(i.data.status!==o.code||n<=1)&&r.splice(a+1,1)}return["viewed","mailOpened"].reduce((a,o)=>mPe(a,o),r)}get scheduledFirstDelivery(){const{reminders:e=[]}=this.data;return e.length&&e.find(r=>r.type==="first")||null}get type(){return this.categoryTags[0]}get categoryTags(){return te(this._doc,"tags",[]).reduce((e,r)=>[...e,r.name],[])}get language(){return te(this,"_doc.language","en")}set language(e){return Xt(this,"_doc.language",e)}get externalReferences(){return te(this,"_doc.externalReferences",[])}set externalReferences(e){return Xt(this,"_doc.externalReferences",e)}get currency(){return te(this,"_doc.currency")}get tags(){return te(this,"_doc.tags",[])}set tags(e){return Xt(this,"_doc.tags",e)}setTag(e,r){const n=this.tags.find(a=>a.type===e);n?n.name=r:this.tags.push({type:e,name:r})}get readPrices(){return this._readPrices}get prices(){return pPe(this._doc)}get dynamicPrices(){const{groups:e}=this.packageGroups,r={min:0,max:0};return(e||[]).forEach(({type:n,prices:a={},packages:o,articles:i,useVat:s,rounding:u})=>{const{total:l,type:d}=a;let f={min:l,max:l};if(o&&o.length){if(n==="radio")f=o.reduce((m,{prices:c})=>(m.min===null&&(m.min=c.total),c.total>m.max&&(m.max=c.total),c.total<m.min&&(m.min=c.total),m),{...f,min:null});else if(n==="checkbox"){const[m,c]=o.reduce(([p,h],v)=>v.toggable?[[...p,v],h]:[p,[...h,v]],[[],[]]);if(m.length){const{maxTotal:p,houseWorkManualAmount:h}=o.reduce((g,{prices:_})=>(g.maxTotal+=_.maxTotal,g.houseWorkManualAmount+=te(_,"region.houseWorkManualAmount",0),g),{maxTotal:0,houseWorkManualAmount:0}),{total:v}=Om({type:d,articles:i,currency:this.currency,clients:this.clients,maxTotal:p,region:{country:"sweden",houseWorkManualAmount:h},useVat:s,rounding:u});f.max=v}c.length?f.min=c[0].prices.total:f.min=m.reduce((p,h)=>((p===null||p>h.prices.total)&&(p=h.prices.total),p),null)}}r.min+=f.min,r.max+=f.max}),r}get cachedInvoices(){const{cachedInvoices:e}=this._doc;return!e||!e.invoices?[]:Object.keys(e.invoices).map(r=>e.invoices[r])}get invoiceIds(){const{cachedInvoices:e}=this._doc;return!e||!e.invoices?[]:Object.keys(e.invoices)}get invoicedAmount(){const{cachedInvoices:e}=this._doc;if(!e||!e.invoices)return 0;const r=e.invoices;return Object.keys(r).reduce((n,a)=>r[a]&&r[a].totalAmount?n+r[a].totalAmount:n,0)}set props(e){this._props=e}get theme(){const e={background:"https://images.unsplash.com/photo-1468233748640-b31327627610?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&w=1280&q=80",backgroundFilter:null,showClingLogo:null,showPriceSummary:!0,priceSummaryBackground:"hsl(217, 95%, 39%)",headingColor:"hsl(231, 100%, 50%)",fontFamily:null},r=te(this._doc,"data.theme",{});return{...e,...this._theme,...td(r)}}set theme(e){this._theme=e}set pdfOptions(e){this._pdfOptions=e}getAllNodesWithType(e){return(te(this,"template.views.read.nodes")||[]).filter(({itemType:n})=>n===e)}get attachedFiles(){const e=[];return this.getAllNodesWithType("attachments").forEach(r=>{const n=r.value.attachments;if(!n)return;const a=te(this,n);a&&Array.isArray(a)&&e.push(...a)}),e}get readLayout(){return this.getReadLayout()}getReadLayout({showHiddenNodes:e=!1}={}){if(!this.template)return[];const r={...this.template.defaultData,...this._doc,data:{...this._doc.data,...this.clients.length&&{clients:this.clients.filter(o=>o.documentRole!=="recipient")},...this._computedPricing&&{prices:this.prices},sender:{...this.sender.company,...this.sender.user,name:this.sender.user.name,avatar:this.sender.user.avatar,...this.sender.user.email&&{email:this.sender.user.email},...this.sender.user.cellphone&&{cellphone:this.sender.user.cellphone},type:"company",companyName:this.sender.company.name},receiverString:this.receiverString,senderString:this.senderString}},a=[...GOe({data:r,tree:this.template.views.read.nodes,bindData:!0,customProps:this._props,pdfOptions:this._pdfOptions})];return e?a:rU({nodes:a,data:r})}get fields(){return{...hPe(this._doc),...this._doc.data.fields}}get textTemplateMap(){const{fields:e}=this;return Object.keys(e).reduce((r,n)=>({...r,[e[n].key]:e[n].label}),{})}get textTemplateItems(){const e=this.textTemplateMap||{};return Object.keys(e).reduce((r,n)=>[...r,{id:n,label:e[n],tooltip:te(this._doc,n)}],[])}get usedFields(){return ak(this.data)}get hasAnswers(){return this.clients.filter(({documentRole:e})=>["signee","approver"].includes(e)).some(({answer:e})=>!!e)}removeAnswer(){this._doc.acceptedAt=null,this._doc.status="draft",this.clients.forEach(e=>{e.answer=null})}setAnswerMethod({accept:e,deny:r}){if(typeof e>"u"&&typeof r>"u")throw new Error("Missing param accept or deny");this.removeAnswer(),e&&(Xt(this,"_doc.data.defaultAnswerMethod.accept",e),Xt(this,"_doc.template.defaultAnswerMethod.accept",e)),r&&(Xt(this,"_doc.data.defaultAnswerMethod.deny",r),Xt(this,"_doc.template.defaultAnswerMethod.deny",r)),this.clients.filter(({documentRole:n})=>["signee","approver"].includes(n)).forEach(n=>{n.answer=null,e&&(n.answerMethod.accept=e),r&&(n.answerMethod.accept=e)})}resetReminders(){const{template:e}=this,{reminders:r}=e;this.reminders=r}resetDefaultSelected(){const e=this._doc.data.packageGroups;!e||(this.packageGroups=Object.keys(e).reduce((r,n)=>({...r,[n]:{...e[n],packages:(e[n].packages||[]).map(a=>({...a,isSelected:a.isSelectedDefault||e[n].type==="single"}))}}),{}))}clone(){const e=this;return Object.assign(Object.create(Object.getPrototypeOf(e)),JSON.parse(JSON.stringify(e)))}duplicate(){const e=this.clone();return e.id=null,e._doc._id=null,e.deleteProperty("data.expiresAt"),e.deleteProperty("data.rejectReasons"),e.deleteProperty("company"),e.deleteProperty("companyUser"),e.deleteProperty("senderClient"),e.clients=e.clients.map(r=>ni(r,["id","_id","publicDocumentId","answer"])),e.allArticles=e.allArticles.map(r=>ni(r,["id","_id","createdAt","updatedAt","deletedAt"])),e.resetReminders(),e.resetDefaultSelected(),e}copyTemplateDocDefault({keepClients:e=!1}={}){const{template:r,articles:n,data:a,tags:o,docNumber:i,language:s,currency:u,clients:l,useSignOrder:d}=this.duplicate().getRawData();Object.keys(a).forEach(m=>{te(r,`validationSchema.properties.data.properties.${m}`)?Xt(r,`validationSchema.properties.data.properties.${m}.default`,a[m]):Object.keys(KU).includes(m)&&Xt(r,`validationSchema.properties.data.properties.${m}`,{...KU[m],default:a[m]})});const f={articles:n,tags:o,docNumber:i,currency:u,useSignOrder:d};return delete i.value,e&&(f.clients=l),Object.keys(f).forEach(m=>{f[m]&&Xt(r,`validationSchema.properties.${m}.default`,f[m])}),r.language=s,r}getRawData(){return{...this._doc,data:{...this._doc.data,prices:this.prices,name:this.name||""}}}get allowVerification(){return this.status==="accepted"||this.clients.some(({answerMethod:e})=>e&&e.accept==="inPerson")}async formatPhone(e,{defaultRegion:r}={}){return Epe(e,{defaultRegion:r||this.sender.company.region})}setDirty(e){this._dirtyKeys[e]=!0}isDirty(e){return!!this._dirtyKeys[e]}$t(e,r={},{fnType:n="t"}={}){const a={lng:this.language,...r},o=["exVat","incVat","vat.exVat","vat.incVat"],i=e&&e.includes(":")?e.split(":")[1]:e;return i==="vat"?od[n](`vat.${this.vatType}`,{...a}):(o.includes(i)&&(a.thing=od[n](`vat.${this.vatType}`)),od[n](e,{...a}))}$tc(e,r={}){return this.$t(e,r,{fnType:"tc"})}}const ZOe=t=>t.map(e=>({...e,price:0,totalAmount:0,invoicedAmount:0,showPrice:!1}));class Js extends QOe{constructor({data:e,documentOptions:r={},can:n,getters:a,updateSender:o=!1}){if(!a)throw new Error("Missing param getters");let i=e;n&&!n("prices","read")&&te(e,"articles",[]).length&&(i={...e,articles:ZOe(e.articles)});const{senderString:s,receiverString:u,fSkatt:l,insurance:d,offerBrandingBackgroundUrl:f,documentThemeBackgroundFilter:m,documentShowPriceSummary:c,documentThemePriceBackground:p,documentThemePrimaryColor:h,presentationFontFamily:v,showClingLogo:g}=a["settings/allCompanySettings"]||{};super(i,{...r,props:{defaultSenderString:s,defaultReceiverString:u,...r.props},readPrices:n?n("prices","read"):!0,isPreview:!0,settingsTheme:td({background:f,backgroundFilter:m,showPriceSummary:c,priceSummaryBackground:p,headingColor:h,fontFamily:v,showClingLogo:g})}),this._documentOptions=r,this._can=n,this._defaultScope="documents",this._getters=a;const _=o||!Object.keys(te(this,"_doc.company",{})).length||!Object.keys(te(this,"_doc.companyUser",{})).length,y=_?this._doc.companyId?a["companies/companyById"](this._doc.companyId):a["application/company"]:this._doc.company;y&&_&&(y.fSkatt=l,y.insurance=d);const b=_?this._doc.companyUserId?a["companyUsers/referenceById"](this._doc.companyUserId):a["application/user"]:this._doc.companyUser;this.sender=this._documentOptions.sender||{company:y,user:b}}can(e,r=null,n=null){if(!this._can)return!0;if(typeof e!="string")throw new Error("Permission must be of type String");return this._can(r||this._defaultScope,e,n||this.id)}get companyId(){return this._doc.companyId}get companyUserId(){return this._doc.companyUserId}resetReminders(){super.resetReminders();let{reminders:e}=this;if(!e.length)return;const{_getters:r}=this,n=r["settings/reminderSettings"],a=(o,i)=>e.filter(({type:s})=>s===o).map(s=>(s.sendDays=i,!0));typeof n.notAnswered<"u"&&a("reminder",n.notAnswered),typeof n.notViewed<"u"&&a("viewed",n.notViewed),typeof n.expires<"u"&&a("expires",n.expires),e=e.filter(({type:o,sendDays:i})=>o==="first"||i),this.reminders=e}clone(){return new Js({data:JSON.parse(JSON.stringify(this._doc)),documentOptions:this._documentOptions,can:this._can,getters:this._getters})}async isValid(){const e=this.getRawData();try{return await Kr.validate(e),!0}catch{return!1}}}const eEe=t=>({id:null,name:"Default Empty",validationSchema:{type:"object",required:["clients","data"],properties:{tags:{type:"array",default:[{name:"document",type:"category"}]},docNumber:{type:"object",properties:{series:{type:"string",default:"document"}}},clients:{type:"array",default:[]},data:{type:"object",required:["name"],properties:{partiesString:{anyOf:[{type:"string"},{type:"null"}],default:be.t("components:document.chapters.parties.title",{lng:t})},"header-kh0loiq7":{default:{layout:"vertical",baseStyle:{textAlign:"left",textColor:"#f0ce84"},items:[{type:"media",size:35,media:{type:"image",resourceUrl:"https://images.unsplash.com/photo-1581660545544-83b8812f9516?ixlib=rb-1.2.1&auto=format&fit=crop&w=1800&q=80"}},{type:"content",size:65,media:{type:"color",backgroundColor:"#17346e"},value:{preText:"",documentName:'<p data-typography="title"></p>',postText:"<p></p>",showLogo:!0,logotype:""}}]},$ref:`${Me.api.baseUrl}/schemas/header/2.json`},packageGroups:{default:{kh0lol91:{type:"",title:be.t("components:document.chapters.packageGroup.title",{lng:t}),hideGroupPrice:!1,packages:[]}},$ref:`${Me.api.baseUrl}/schemas/packageGroups/1.json`},"title-kh0los53":{anyOf:[{type:"string"},{type:"null"}]},"content-kh0los54":{anyOf:[{type:"string"},{type:"null"}]},defaultAnswerMethod:{default:{accept:"signature",deny:"button"},$ref:`${Me.api.baseUrl}/schemas/answer/1.json`},name:ck,sender:dk,senderString:fk,receiverString:mk,prices:pk,css:lk,fields:vk,expiresAt:hk,formSettings:uk,reminders:ld,smsTemplate:ok,emailTemplate:sk}}}},views:{edit:{isEditable:!0,nodes:[]},read:{isEditable:!0,nodes:[{itemId:"header-kh0loiq7",itemType:"header",value:{header:"data.header-kh0loiq7"}},{itemId:"parties",itemType:"section",value:{title:"data.partiesString"},children:[{itemId:"clients",itemType:"subSection",value:{title:"data.receiverString"},children:[{itemId:"clientsList",itemType:"party",value:{parties:"clients"}}]},{itemId:"sender",itemType:"subSection",value:{title:"data.senderString"},children:[{itemId:"senderList",itemType:"party",value:{parties:"data.sender"}}]}]},{itemId:"packageGroup-kh0lol91",itemType:"section",value:{title:"data.packageGroups.kh0lol91.title"},children:[{itemId:"group",itemType:"selectionGroup",value:{groupId:"kh0lol91",type:"data.packageGroups.kh0lol91.type",packages:"data.packageGroups.kh0lol91.packages"}}]},{itemId:"titleAndText2",itemType:"section",value:{title:"data.title-kh0los53"},children:[{itemId:"kh0los52",itemType:"html",value:{content:"data.content-kh0los54"}}]},{itemId:"answer",itemType:"answer",value:{defaultAnswerMethod:"data.defaultAnswerMethod"}}]},email:Wm,sms:Fm},isVisible:!0,language:t}),XU={default:t=>{const e=eEe(t);return{...e,views:Object.keys(e.views).reduce((r,n)=>({...r,[n]:{...e.views[n],nodes:ik(e.views[n].nodes,{setId:!0})}}),{})}},empty:t=>({id:null,name:"Empty",validationSchema:{type:"object",required:["clients","data"],properties:{tags:{type:"array",default:[{name:"document",type:"category"}]},docNumber:{type:"object",properties:{series:{type:"string",default:"document"}}},clients:{type:"array",default:[]},data:{type:"object",required:["name"],properties:{name:ck,sender:dk,senderString:fk,receiverString:mk,prices:pk,css:lk,fields:vk,expiresAt:hk,formSettings:uk,reminders:ld,smsTemplate:ok,emailTemplate:sk}}}},views:{edit:{isEditable:!0,nodes:[]},read:{isEditable:!0,nodes:[]},email:{...Wm,nodes:ik(Wm.nodes,{setId:!0})},sms:{...Fm,nodes:ik(Fm.nodes,{setId:!0})}},isVisible:!0,language:t})},{FORM_CLEAR_FORM:jm,CLEAR_DOCUMENT2_ANSWERS:JU,DO_SEND_DOCUMENT2:tEe,SHOW_MESSAGE:rEe,LOAD_ENDCUSTOMER:nEe,UPDATE_TEMPLATE:aEe,DO_CREATE_TEMPLATE:iEe}=Oe,{LOAD_DOCUMENT2_FORM:oEe,LOAD_DOCUMENT2_PUBLIC_FORM:sEe,LOAD_DUPLICATE_DOCUMENT2_FORM:QU,SAVE_DYNDOC_FORM:uEe,CLEAR_DYNDOC_FORM:ZU,DO_SAVE_DYNDOC:eH,HANDLE_DOCUMENT2_EDIT:lEe,SAVE_TEMPLATE_FORM:dEe,LOAD_EXTERNAL_FORM_FIELDS:gk}=FV,{SET_FORM:yk,SET_FORM_VALUE:tH}=De.forms;async function cEe({id:t=null,templateId:e=null,rootState:r,state:n,rootGetters:a,dispatch:o}){if(!r)throw new Error("Missing parameter rootState");if(!n)throw new Error("Missing parameter state");if(!a)throw new Error("Missing parameter rootGetters");if(!o)throw new Error("Missing parameter dispatch");let i=!1;const s=a["forms/document"];if(!s)return!1;const{name:u,params:{id:l}}=r.route||{},{id:d,template:{id:f}}=s;return["documentForm"].includes(u)&&(t?d&&d===l&&d===t&&(Tt.debug("DYNDOC_FORM: Using existing store data existing id match route"),i=!0):!d&&!t&&(e==="default"&&!f||e===f)&&(Tt.debug("DYNDOC_FORM: Using existing store data as no ids was found"),i=!0)),i&&Tt.debug("DYNDOC_FORM: Dont reload as forms/document2 is already defined"),i}const fEe={async[oEe]({commit:t,rootState:e,rootGetters:r,state:n,dispatch:a},{documentId:o=null,templateId:i=null,addonDocumentSourceId:s=null,projectId:u=null,clientId:l=null,formData:d=null,_formData:f=null,dummyClient:m=!1}={}){if(await cEe({id:o,templateId:i,rootState:e,state:n,rootGetters:r,dispatch:a})&&!s)return;let p={id:null,companyUserId:this.getters["application/user"].id,language:this.getters["settings/getCompanyUserSetting"]("defaultLanguage")||"en",currency:this.getters["settings/getCompanyUserSetting"]("defaultCurrency"),data:{},template:null,articles:[],clients:[],...f&&{...f},...d};if(!d){if(o){await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:o});const g=this.getters["documents2/byId"](o);p={...p,...g.getRawData()}}else if(i){let g=["default","empty"].includes(i)?new fi(XU[i](p.language)):this.getters["templates/byId"](i);if(i==="onboardingTemplate"){const{data:_}=await to.get(i);g=new fi(_)}if(g||(await this.dispatch(Oe.LOAD_TEMPLATE,{id:i}),g=this.getters["templates/byId"](i)),!g)throw new Error(`Could not find template by id: '${i}'`);p.template={...g._data,defaultData:g.defaultData}}const v=te(p,"template.defaultData",{});if(p={...p,...v,clients:[...(v==null?void 0:v.clients)||[],...p.clients]},Object.keys(e.settings.company).length||await this.dispatch(Oe.LOAD_SETTINGS_COMPANY),s){await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:s});const g=this.getters["documents2/byId"](s),{publicId:_,clients:y}=g.duplicate();p={...p,projectId:g.projectId,clients:y,data:{...p.data,sourceDocument:{id:s,publicId:_}}}}}if(u&&(p.projectId=u),l){await this.dispatch(nEe,{id:l});const v=r["endCustomers/endCustomerById"](l),g=te(p,"template.defaultData.data.defaultAnswerMethod"),_=Ox(v,{...g&&{answerMethod:g}});p.clients=[...p.clients,_]}if(m){const v=["email"];Un.checkFeature("sms")&&v.push("sms"),p.clients=[...p.clients,{name:"Pernilla P.",email:"pernilla@mail.se",cellphone:"073 123 56 78",documentRole:"signee",type:"individual",deliveryTypes:v}]}if(i==="onboardingTemplate"){const v=r["application/user"]||{},g=r["application/company"]||{},_={type:"company",email:v.email,companyName:g.name||(p.language==="sv"?"Konsulterna AB":"The consultants Corp."),name:v.fullName||(p.language==="sv"?"Test Testson":"John Doe"),...v.cellphone?{cellphone:v.cellphone}:{},...g.region&&{cellphoneRegion:g.region}};p.clients=[...p.clients,Ts({...Sx(),..._})]}const h=te(p,"data.defaultAnswerMethod",null);h&&(p.clients=p.clients.map(v=>te(v,"answerMethod.accept")!=="inPerson"?{...v,answerMethod:h}:v)||[]),t(yk,{key:"document2",formData:{...p,data:{...p.data,...!o&&{reminders:this.getters["forms/getDocumentAccountDefault"]("reminders",{template:new fi(p.template)})}}}}),a(gk)},async[sEe]({commit:t},{formData:e=null}={}){let r={id:null,language:be.lang,currency:this.$brand==="cling"?"SEK":"USD",data:{},template:null,articles:[],clients:[],...e};if(!e){if(!r.template){const o=new fi(XU.default(r.language));r.template={...o._data,defaultData:o.defaultData}}const a=te(r,"template.defaultData",{});r={...r,...a}}r.language==="sv"&&r.data.defaultAnswerMethod&&(r.data.defaultAnswerMethod.accept="bankId");const n=te(r,"data.defaultAnswerMethod",null);n&&(r.clients=r.clients.map(a=>te(a,"answerMethod.accept")!=="inPerson"?{...a,answerMethod:n}:a)||[]),t(yk,{key:"document2",formData:{...r,data:{...r.data}}})},async[QU]({commit:t,dispatch:e},{id:r,publicDocId:n,projectId:a=null,keepClients:o=!1,isPublicForm:i=!1}){if(!r&&!n)throw new Error("Missing parameter id");let s;if(n){const{data:_}=await L3.get(n,{preview:!0});s=new Js({data:_,can:i?null:lo.checkPermission.bind(lo),getters:this.getters})}else await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:r}),s=this.getters["documents2/byId"](r);if(!s)throw new Error("Could not find document to duplicate");const u=s.duplicate(),{defaultData:l}=u.template,{template:d,data:f,articles:m,clients:c,language:p,currency:h,externalReferences:v}=u.getRawData(),g={...l,template:d,articles:m,clients:o?c:[],language:p,currency:h,externalReferences:v,data:{...l.data,...f}};a&&(g.projectId=a),t(yk,{key:"document2",formData:g}),e(gk)},async[dEe](t,{body:e}){try{if(!e)throw new Error("Missing param body");e.id?await this.dispatch(aEe,{id:e.id,body:e}):await this.dispatch(iEe,{body:e}),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!0),this.$router.push({name:"documentFormSelect"}),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!1),await this.dispatch(jm,{key:"_old_document2"}),await this.dispatch(jm,{key:"document2"})}catch(r){this.handleError(r)}},async[uEe]({dispatch:t},{doRedirect:e=!0,doSend:r=!1}={}){try{const n=await t(eH),a=this.getters["documents2/byId"](n),o=!!te(a,"senderClient");return r&&!o&&await this.dispatch(tEe,{id:n}),e?(this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!0),r?this.$router.push({name:"postDocumentSend",params:{id:n}}):Oz({next:"project",projectId:a.projectId},this.$router),this.commit(`documents2/${De.documents2.SET_DOCUMENT2_POSTING}`,!1)):await t(ZU),n}catch(n){return this.handleError(n),null}},async[ZU](){try{await this.dispatch(jm,{key:"_old_document2"}),await this.dispatch(jm,{key:"document2"})}catch(t){this.handleError(t)}},async[eH]({rootGetters:t,getters:e,commit:r},{showMessage:n=!0}={}){const{document:a}=e;let{id:o}=a;const i=l=>od.t(`documentTemplateView.${l}`,{lng:a.language,interpolation:{prefix:"__",suffix:"__"}}),s=te(a,"data.defaultAnswerMethod",null);s&&(a.clients=a.clients.map(l=>te(l,"answerMethod.accept")!=="inPerson"?{...l,answerMethod:s}:l));const u={...a,data:{...a.data,name:a.data.name||"",smsTemplate:{first:{text:i("smsTemplate.first.text")},reminder:{text:i("smsTemplate.reminder.text")},expires:{text:i("smsTemplate.expires.text")},viewed:{text:i("smsTemplate.viewed.text")}},emailTemplate:{first:{subject:i("emailTemplate.first.subject"),title:i("emailTemplate.first.title"),content:i("emailTemplate.first.content"),text:i("emailTemplate.first.text")},viewed:{subject:i("emailTemplate.viewed.subject"),title:i("emailTemplate.viewed.title"),content:i("emailTemplate.viewed.content"),text:i("emailTemplate.viewed.text")},reminder:{subject:i("emailTemplate.reminder.subject"),title:i("emailTemplate.reminder.title"),content:i("emailTemplate.reminder.content"),text:i("emailTemplate.reminder.text")},expires:{subject:i("emailTemplate.expires.subject"),title:i("emailTemplate.expires.title"),content:i("emailTemplate.expires.content"),text:i("emailTemplate.expires.text")}}},pdfConfig:{locale:od.locale,timeZone:te(Intl.DateTimeFormat().resolvedOptions(),"timeZone")||""}};return delete u.company,delete u.companyUser,o?(a.clearAnswerBeforePut&&(await this.dispatch(JU,{id:o,doFetch:!1}),await this.dispatch(Oe.DO_UPDATE_DOCUMENT2,{id:o,body:{status:"draft"},showMessage:n})),await this.dispatch(Oe.DO_UPDATE_DOCUMENT2,{id:o,body:u,showMessage:n})):(o=await this.dispatch(Oe.DO_CREATE_DOCUMENT2,{body:u}),r(tH,{key:"document2.id",value:o})),t["settings/showOverviewOnboardingOverlay"]&&this.dispatch("settings/UPDATE_SETTINGS",{key:"companyUser",settings:{showOverviewOnboardingOverlay:!1}}),o},async[lEe]({getters:t,dispatch:e},{documentId:r=null}={}){let n;if(r?(await this.dispatch(Oe.DO_LOAD_DOCUMENT2,{id:r}),n=this.getters["documents2/byId"](r)):{document:n}=t,!n)throw new Error("Missing document");const a=n.id?n.can("modify"):n.can("create"),{id:o,status:i,projectId:s,hasAnswers:u}=n;if(a&&(i==="accepted"||u)){const l=i==="accepted"?"accepted":"hasAnswers";this.dispatch(rEe,{displayType:"dialog",type:"primary",title:be.t(`actions:editDocumentDialog.${l}.title`),message:be.t(`actions:editDocumentDialog.${l}.message`),actions:{cancel:{text:be.t("_common:cancel"),callback:"cancel"},submit:{text:be.t(`actions:editDocumentDialog.${l}.submit`),callback:async()=>{if(l==="accepted")await e(QU,{id:o,projectId:s,keepClients:!0}),this.$router.push({name:"documentForm"});else if(l==="hasAnswers"){await this.dispatch(JU,{id:o,doFetch:!0});const d={name:"documentForm",params:o?{id:o}:{}};this.$router.push(d)}}}}})}else if(a){const l={name:"documentForm",params:o?{id:o}:{}};return this.$router.push(l)}return null},async[gk]({rootGetters:t,getters:e,commit:r}){const{document:n}=e;if((n==null?void 0:n.externalReferences)&&n.externalReferences.length)try{await Promise.all((n.externalReferences||[]).map(async({service:a,type:o,typeId:i})=>{if(o&&i&&a&&t["settings/isAuthenticatedCRM"](a)){const{data:s}=await m1.getFields(a,{type:o,typeId:i,populated:!0});r(tH,{key:"document2.data.fields",value:{...te(n,"data.fields"),...s}})}}))}catch(a){this.handleError(a)}}},mEe={...aPe,...VPe,...HPe,...fEe,async[Vn.FORM_CLEAR_FORM]({commit:t},{key:e}){return t(zn.CLEAR_FORM,{key:e})},async[Vn.SET_FORM]({commit:t},{key:e,formData:r}){return t(zn.SET_FORM,{key:e,formData:r})},async[Vn.SET_FORM_VALUE]({commit:t},{key:e,value:r}){return t(zn.SET_FORM_VALUE,{key:e,value:r})},async[Vn.REMOVE_FORM_VALUE]({commit:t},e){return t(zn.REMOVE_FORM_VALUE,e)},async[Vn.REMOVE_FORM_KEY_VALUE]({commit:t},e){return t(zn.REMOVE_FORM_KEY_VALUE,e)},async[Vn.FORM_RESET_OLD]({commit:t,rootGetters:e},r){const n=e["forms/getFormByKey"](r);return t(zn.SET_FORM,{key:r,formData:n})}},pEe={},hEe={setDocumentField(t,e){const{path:r,value:n}=e,{root:a,prop:o}=fo(t.document,r,!0);Gl(a,{path:o,value:n})}},{SET_FORM:vEe,CLEAR_FORM:gEe,SET_FORM_VALUE:yEe,REMOVE_FORM_VALUE:_Ee,REMOVE_FORM_KEY_VALUE:bEe}=zn,wEe={updateField:Gl,...pEe,...hEe,[vEe](t,{key:e,formData:r}){if(ot(r)==="undefined"){console.warn("FormData was undefined!");return}const n=JSON.parse(JSON.stringify(r)),{root:a,prop:o}=fo(t,e,!0);if(Array.isArray(n))ce.set(a,o,n);else if(typeof n=="object"&&n!==null){const i=Object.assign({},n);ce.set(a,o,i)}else ce.set(a,o,n);if(e.split(".").length!==1){console.warn("Using SET_FORM to set individual values");return}t[`_old_${e}`]=JSON.parse(JSON.stringify(t[e]||{}))},[gEe](t,{key:e}){const{root:r,prop:n}=fo(t,e);ce.set(r,n,{})},[_Ee](t,e){const{root:r,prop:n}=fo(t,e);if(Array.isArray(r)){ce.delete(r,n);return}if(r[n]&&Array.isArray(r[n])){ce.set(r,n,[]);return}if(r[n]&&typeof r[n]=="object"){ce.set(r,n,{});return}r[n]=void 0},[bEe](t,e){const{root:r,prop:n}=fo(t,e);r&&n in r&&delete r[n]},[yEe](t,{key:e,value:r}){const{root:n,prop:a}=fo(t,e,!0),o=ot(r)==="null",i=ot(r)==="array"&&!r.length;if(!o&&n[a]&&ot(n[a])==="array"&&!i&&ot(r)!=="array"){n[a].push(Ts(r));return}if(!o&&ot(n)==="array"&&!i){let s=Ts(r);typeof n[a]=="object"&&n[a]._uniqueId&&(s={...s,_uniqueId:n[a]._uniqueId}),ce.set(n,a,s);return}ce.set(n,a,r)}};function xEe(t){const e={email:!1,sms:!1};return te(t,"clients",[]).forEach(r=>{r.deliveryTypes.indexOf("sms")>-1&&(e.sms=!0),r.deliveryTypes.indexOf("email")>-1&&(e.email=!0)}),e.sms&&!Un.checkFeature("sms")&&(e.sms=!1),e}const kEe={getField:vm,...{document:({document2:t})=>Object.keys(t).length?t:null,deliveryTypes:t=>xEe(t.document2),getDocumentAccountDefault:(t,e,r,n)=>(a,{template:o})=>{let i;if(a==="reminders"){if(i=[],!o)return i;i.push(...o.reminders);const s=(l,d)=>i.filter(({type:f})=>f===l).forEach(f=>{f.sendDays=d}),u=n["settings/reminderSettings"];u.notAnswered!==void 0&&s("reminder",u.notAnswered),u.notViewed!==void 0&&s("viewed",u.notViewed),u.expires!==void 0&&s("expires",u.expires),i=i.filter(({type:l,sendDays:d})=>l==="first"||d)}return i}},...{documentField:t=>e=>{const{document:r={}}=t;let n=e.split(".");n[0]==="document"&&(n=[...n.slice(1)]);let a=r[n[0]];return n.length>1&&(a=n.reduce((o,i)=>o&&o[i],r)),a},isIndivid:t=>{try{return t.document.ModuleEndCustomer.customerType!=="company"}catch{return!0}},isReverseVat:t=>{try{return Un.checkFeature("reverseVat")&&t.document.ModuleEndCustomer.reverseVat===!0}catch{return!1}},getInvoicePrices:({document:t={}},e,r,n)=>{const a={invoiceFee:t.invoiceFee||0,invoiceFeeVat:0,centRoundingAmount:0,totalPriceExVat:0,totalVatAmount:0,totalAmount:0,visualPricing:{},regionPricing:[],reverseVat:e.isReverseVat||!1,type:t.type,paidAmount:0,remainingAmount:0,totalPriceIncVat:0,creditedAmount:0,currency:"SEK"};(t.ModuleArticles||[]).forEach(l=>{const d=Zi(l);if(!d.price||!d.quantity)return;const{totalAmount:f}=d;a.totalPriceExVat+=f,a.totalVatAmount+=f*(d.vat/100),d.vat>a.invoiceFeeVat&&!a.reverseVat&&(a.invoiceFeeVat=d.vat)}),a.totalPriceExVat+=a.invoiceFee,a.totalVatAmount+=a.invoiceFee*a.invoiceFeeVat*.01,a.reverseVat&&(a.totalVatAmount=0),a.regionPricing=e.invoiceRegion.regionPricing;const o=a.regionPricing.reduce((l,d)=>l+d.value,0),i=a.totalPriceExVat+a.totalVatAmount,s=(i+o)*.01,u=Math.round(s)-s;return a.centRoundingAmount=u*100,a.totalAmount=i+o+a.centRoundingAmount,a.type==="credit"&&(a.creditedAmount=a.totalAmount),a.remainingAmount=a.totalAmount,a},invoice:(t,e,r,n)=>{const a={};return Object.keys(rd).map(i=>(a[i]=n["forms/documentField"](i),i==="ModuleArticles"&&ot(a[i])==="array"&&(a[i]=a[i].filter(s=>s.name),a[i]=a[i].map((s,u)=>({...s,position:u}))),!0)),new Dx(a,n)},invoiceRegion:({document:t={}},e,r,n)=>{const a=Zi(t.ModuleArticles||[]),o=t.InvoiceRegionSweden||{},i={applicants:te(o,"persons",[]),houseWorkType:null,houseWorkAmount:null,houseWorkMaterial:null,allowRot:!1,allowRut:!1,regionPricing:[],requirePropertyDesignation:!1},s=a.find(m=>m.isDeductable||m.isRut)||{};s.isDeductable?i.houseWorkType="rot":s.isRut&&(i.houseWorkType="rut"),i.requirePropertyDesignation=i.houseWorkType==="rot";const u=a.reduce((m,c)=>m+c.houseWorkDeductionAmount,0),l=a.reduce((m,c)=>!c.isDeductable&&!c.isRut?m:m+c.totalAmount*(100+c.vat)/100,0),d=a.reduce((m,c)=>m+c.houseWorkMaterialCostToReport,0);i.houseWorkAmount=u,i.houseWorkMaterialAmount=d,i.houseWorkDuration=a.reduce((m,c)=>m+c.houseWorkHoursToReport,0),i._totalPriceDeductionArticles=l;const f=o.propertyType==="realEstate";return i.isRealEstate=f,i.propertyId=f?o.realEstateId:o.condominiumId,i.condominiumOrgNo=o.condominiumOrgNo,e.isIndivid&&(i.allowRot=n["settings/getCompanySetting"]("showRot")||!!i.houseWorkAmount,i.allowRut=n["settings/getCompanySetting"]("showRut")||!!i.houseWorkAmount),i.regionPricing=[...i.houseWorkType==="rot"?[{label:"ROT-avdrag",key:"rot",value:-i.houseWorkAmount}]:[],...i.houseWorkType==="rut"?[{label:"RUT-avdrag",key:"rut",value:-i.houseWorkAmount}]:[]],i},kycForm:t=>t.kycForm||null},hasChanged:t=>e=>JSON.stringify(t[e])!==JSON.stringify(t[`_old_${e}`]),getFormByKey:t=>e=>{const r=e.split(".");let n=t;const a=r.pop();return r.length>0&&(n=r.reduce((o,i)=>o[i],t)),n[a]},getArrayElement:t=>(e,r)=>{const{root:n,prop:a}=fo(t,e),o=n[a];if(!Array.isArray(o))throw new Error(`${a} is not an array`);return o.find(s=>s.uniqueId===r)}},PEe={namespaced:!0,state:rPe,getters:kEe,actions:mEe,mutations:wEe},TEe={data:{},ids:[],filePublicIdToId:{},isFetching:!1,isPosting:!1},Qs="files",{LOAD_FILE:rH,CREATE_FILE:_k,UPDATE_FILE:bk,DELETE_FILE:nH,PATCH_FILE:aH,FORM_NEW_FILE:MEe,FORM_EDIT_FILE:SEe,FORM_SUBMIT_FILE:iH}=cm,{UPDATE_MANY_FILES:oH,DELETE_ONE_FILE:OEe,SET_FILES_FETCHING:sH,SET_FILES_POSTING:hi}=ix,{SET_FORM:uH,CLEAR_FORM:EEe}=De.forms,DEe={async[rH]({commit:t},{id:e}){try{t(sH,!0);const{data:r}=await nhe(e);return t(oH,{data:r}),!0}catch(r){return this.handleError(r,{object:"file",objectId:e,fallbackCode:"file.get",action:`${Qs}/${rH}`,actionPayload:arguments[1]}),!1}finally{t(sH,!1)}},async[_k]({commit:t},{body:e}){try{t(hi,!0);const r=e.fileName||"";let n=null;if(e.blob){const a=new FormData;a.append("file",e.blob,r),{data:n}=await I3(a)}else({data:n}=await I3(e));if(!n)throw new Error("No file was uploaded");return t(oH,{data:n}),n.id}catch(r){return this.handleError(r,{object:"file",fallbackCode:"file.post",action:`${Qs}/${_k}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[bk]({commit:t,dispatch:e},{id:r,body:n}){try{return t(hi,!0),await ahe(r,n),await e(cm.LOAD_FILE,{id:r}),r}catch(a){return this.handleError(a,{object:"file",objectId:r,fallbackCode:"file.put",action:`${Qs}/${bk}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[nH]({commit:t},{id:e}){try{return t(hi,!0),await ihe(e),t(OEe,e),e}catch(r){return this.handleError(r,{object:"file",objectId:e,fallbackCode:"file.delete",action:`${Qs}/${nH}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},async[aH]({commit:t,dispatch:e},{id:r}){try{return t(hi,!0),await ohe(r),await e(cm.LOAD_FILE,{id:r}),r}catch(n){return this.handleError(n,{object:"file",objectId:r,fallbackCode:"file.patch",action:`${Qs}/${aH}`,actionPayload:arguments[1]}),null}finally{t(hi,!1)}},[MEe]({commit:t}){const e={blob:null,fileName:null};return t(`forms/${uH}`,{key:"file",formData:e},{root:!0})},[SEe]({commit:t,state:e},{id:r,props:n=[]}){const a={...ya(e.data[r],n),id:r};return t(`forms/${uH}`,{key:"file",formData:a},{root:!0})},async[iH]({commit:t,rootGetters:e,dispatch:r}){try{const n=e["forms/getFormByKey"]("file");let{id:a}=n;return a?await r(bk,{id:n.id,body:n}):a=await r(_k,{body:n}),t(`forms/${EEe}`,{key:"file"},{root:!0}),a}catch(n){return this.handleError(n,{object:"file",action:`${Qs}/${iH}`}),null}}},{UPDATE_MANY_FILES:CEe,DELETE_ONE_FILE:$Ee,CLEAR_FILES:AEe,SET_FILES_FETCHING:REe,SET_FILES_POSTING:IEe}=ix,NEe={[CEe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a company user or an array of company users!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r),o=n.reduce((i,s)=>!a[s]||!a[s].publicId?i:{...i,[a[s].publicId]:a[s].id},{});Ys(t.data,a),t.ids=eo([...n,...t.ids]),t.filePublicIdToId={...t.filePublicIdToId,...o}},[$Ee](t,e){t.data[e]&&(ce.delete(t.filePublicIdToId,t.data[e].publicId),ce.delete(t.data,e));const n=t.ids.indexOf(e);n!==-1&&t.ids.splice(n,1)},[AEe](t){ce.set(t,"data",{}),ce.set(t,"ids",[]),ce.set(t,"filePublicIdToId",[])},[REe](t,e){t.isFetching=e},[IEe](t,e){t.isPosting=e}},LEe={namespaced:!0,state:TEe,getters:{fileById:t=>e=>t.data[e],fileByPublicId:(t,e)=>r=>{const n=t.filePublicIdToId[r];return e.fileById(n)}},actions:DEe,mutations:NEe},WEe={data:{},ids:[],projectPublicIdToId:{},isFetching:!1,isPosting:!1,canFetchMore:!0,count:{},searchWord:"",isFetchingProjectNotes:!1,isPostingProjectNotes:!1};var FEe="__lodash_hash_undefined__";function jEe(t){return this.__data__.set(t,FEe),this}var VEe=jEe;function zEe(t){return this.__data__.has(t)}var UEe=zEe,HEe=O0,qEe=VEe,BEe=UEe;function Vm(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new HEe;++e<r;)this.add(t[e])}Vm.prototype.add=Vm.prototype.push=qEe,Vm.prototype.has=BEe;var lH=Vm;function YEe(t,e,r,n){for(var a=t.length,o=r+(n?1:-1);n?o--:++o<a;)if(e(t[o],o,t))return o;return-1}var GEe=YEe;function KEe(t){return t!==t}var XEe=KEe;function JEe(t,e,r){for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1}var QEe=JEe,ZEe=GEe,eDe=XEe,tDe=QEe;function rDe(t,e,r){return e===e?tDe(t,e,r):ZEe(t,eDe,r)}var nDe=rDe,aDe=nDe;function iDe(t,e){var r=t==null?0:t.length;return!!r&&aDe(t,e,0)>-1}var oDe=iDe;function sDe(t,e,r){for(var n=-1,a=t==null?0:t.length;++n<a;)if(r(e,t[n]))return!0;return!1}var uDe=sDe;function lDe(t,e){return t.has(e)}var dH=lDe,dDe=lH,cDe=oDe,fDe=uDe,mDe=EV,pDe=Bc,hDe=dH,vDe=200;function gDe(t,e,r,n){var a=-1,o=cDe,i=!0,s=t.length,u=[],l=e.length;if(!s)return u;r&&(e=mDe(e,pDe(r))),n?(o=fDe,i=!1):e.length>=vDe&&(o=hDe,i=!1,e=new dDe(e));e:for(;++a<s;){var d=t[a],f=r==null?d:r(d);if(d=n||d!==0?d:0,i&&f===f){for(var m=l;m--;)if(e[m]===f)continue e;u.push(d)}else o(e,f,n)||u.push(d)}return u}var yDe=gDe,cH=as,_De=C0,bDe=Dn,fH=cH?cH.isConcatSpreadable:void 0;function wDe(t){return bDe(t)||_De(t)||!!(fH&&t&&t[fH])}var xDe=wDe,kDe=F0,PDe=xDe;function mH(t,e,r,n,a){var o=-1,i=t.length;for(r||(r=PDe),a||(a=[]);++o<i;){var s=t[o];e>0&&r(s)?e>1?mH(s,e-1,r,n,a):kDe(a,s):n||(a[a.length]=s)}return a}var TDe=mH;function MDe(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var SDe=MDe,ODe=lH,EDe=SDe,DDe=dH,CDe=1,$De=2;function ADe(t,e,r,n,a,o){var i=r&CDe,s=t.length,u=e.length;if(s!=u&&!(i&&u>s))return!1;var l=o.get(t),d=o.get(e);if(l&&d)return l==e&&d==t;var f=-1,m=!0,c=r&$De?new ODe:void 0;for(o.set(t,e),o.set(e,t);++f<s;){var p=t[f],h=e[f];if(n)var v=i?n(h,p,f,e,t,o):n(p,h,f,t,e,o);if(v!==void 0){if(v)continue;m=!1;break}if(c){if(!EDe(e,function(g,_){if(!DDe(c,_)&&(p===g||a(p,g,r,n,o)))return c.push(_)})){m=!1;break}}else if(!(p===h||a(p,h,r,n,o))){m=!1;break}}return o.delete(t),o.delete(e),m}var pH=ADe;function RDe(t){var e=-1,r=Array(t.size);return t.forEach(function(n,a){r[++e]=[a,n]}),r}var IDe=RDe;function NDe(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var LDe=NDe,hH=as,vH=wF,WDe=T0,FDe=pH,jDe=IDe,VDe=LDe,zDe=1,UDe=2,HDe="[object Boolean]",qDe="[object Date]",BDe="[object Error]",YDe="[object Map]",GDe="[object Number]",KDe="[object RegExp]",XDe="[object Set]",JDe="[object String]",QDe="[object Symbol]",ZDe="[object ArrayBuffer]",eCe="[object DataView]",gH=hH?hH.prototype:void 0,wk=gH?gH.valueOf:void 0;function tCe(t,e,r,n,a,o,i){switch(r){case eCe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ZDe:return!(t.byteLength!=e.byteLength||!o(new vH(t),new vH(e)));case HDe:case qDe:case GDe:return WDe(+t,+e);case BDe:return t.name==e.name&&t.message==e.message;case KDe:case JDe:return t==e+"";case YDe:var s=jDe;case XDe:var u=n&zDe;if(s||(s=VDe),t.size!=e.size&&!u)return!1;var l=i.get(t);if(l)return l==e;n|=UDe,i.set(t,e);var d=FDe(s(t),s(e),n,a,o,i);return i.delete(t),d;case QDe:if(wk)return wk.call(t)==wk.call(e)}return!1}var rCe=tCe,yH=pF,nCe=1,aCe=Object.prototype,iCe=aCe.hasOwnProperty;function oCe(t,e,r,n,a,o){var i=r&nCe,s=yH(t),u=s.length,l=yH(e),d=l.length;if(u!=d&&!i)return!1;for(var f=u;f--;){var m=s[f];if(!(i?m in e:iCe.call(e,m)))return!1}var c=o.get(t),p=o.get(e);if(c&&p)return c==e&&p==t;var h=!0;o.set(t,e),o.set(e,t);for(var v=i;++f<u;){m=s[f];var g=t[m],_=e[m];if(n)var y=i?n(_,g,m,e,t,o):n(g,_,m,t,e,o);if(!(y===void 0?g===_||a(g,_,r,n,o):y)){h=!1;break}v||(v=m=="constructor")}if(h&&!v){var b=t.constructor,k=e.constructor;b!=k&&"constructor"in t&&"constructor"in e&&!(typeof b=="function"&&b instanceof b&&typeof k=="function"&&k instanceof k)&&(h=!1)}return o.delete(t),o.delete(e),h}var sCe=oCe,xk=E0,uCe=pH,lCe=rCe,dCe=sCe,_H=Gc,bH=Dn,wH=el.exports,cCe=sF,fCe=1,xH="[object Arguments]",kH="[object Array]",zm="[object Object]",mCe=Object.prototype,PH=mCe.hasOwnProperty;function pCe(t,e,r,n,a,o){var i=bH(t),s=bH(e),u=i?kH:_H(t),l=s?kH:_H(e);u=u==xH?zm:u,l=l==xH?zm:l;var d=u==zm,f=l==zm,m=u==l;if(m&&wH(t)){if(!wH(e))return!1;i=!0,d=!1}if(m&&!d)return o||(o=new xk),i||cCe(t)?uCe(t,e,r,n,a,o):lCe(t,e,u,r,n,a,o);if(!(r&fCe)){var c=d&&PH.call(t,"__wrapped__"),p=f&&PH.call(e,"__wrapped__");if(c||p){var h=c?t.value():t,v=p?e.value():e;return o||(o=new xk),a(h,v,r,n,o)}}return m?(o||(o=new xk),dCe(t,e,r,n,a,o)):!1}var hCe=pCe,vCe=hCe,TH=ma;function MH(t,e,r,n,a){return t===e?!0:t==null||e==null||!TH(t)&&!TH(e)?t!==t&&e!==e:vCe(t,e,r,n,MH,a)}var SH=MH,gCe=E0,yCe=SH,_Ce=1,bCe=2;function wCe(t,e,r,n){var a=r.length,o=a,i=!n;if(t==null)return!o;for(t=Object(t);a--;){var s=r[a];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++a<o;){s=r[a];var u=s[0],l=t[u],d=s[1];if(i&&s[2]){if(l===void 0&&!(u in t))return!1}else{var f=new gCe;if(n)var m=n(l,d,u,t,e,f);if(!(m===void 0?yCe(d,l,_Ce|bCe,n,f):m))return!1}}return!0}var xCe=wCe,kCe=fa;function PCe(t){return t===t&&!kCe(t)}var OH=PCe,TCe=OH,MCe=Yc;function SCe(t){for(var e=MCe(t),r=e.length;r--;){var n=e[r],a=t[n];e[r]=[n,a,TCe(a)]}return e}var OCe=SCe;function ECe(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var EH=ECe,DCe=xCe,CCe=OCe,$Ce=EH;function ACe(t){var e=CCe(t);return e.length==1&&e[0][2]?$Ce(e[0][0],e[0][1]):function(r){return r===t||DCe(r,t,e)}}var RCe=ACe;function ICe(t,e){return t!=null&&e in Object(t)}var NCe=ICe,LCe=lm,WCe=C0,FCe=Dn,jCe=$0,VCe=A0,zCe=zs;function UCe(t,e,r){e=LCe(e,t);for(var n=-1,a=e.length,o=!1;++n<a;){var i=zCe(e[n]);if(!(o=t!=null&&r(t,i)))break;t=t[i]}return o||++n!=a?o:(a=t==null?0:t.length,!!a&&VCe(a)&&jCe(i,a)&&(FCe(t)||WCe(t)))}var HCe=UCe,qCe=NCe,BCe=HCe;function YCe(t,e){return t!=null&&BCe(t,e,qCe)}var GCe=YCe,KCe=SH,XCe=te,JCe=GCe,QCe=Z1,ZCe=OH,e$e=EH,t$e=zs,r$e=1,n$e=2;function a$e(t,e){return QCe(t)&&ZCe(e)?e$e(t$e(t),e):function(r){var n=XCe(r,t);return n===void 0&&n===e?JCe(r,t):KCe(e,n,r$e|n$e)}}var i$e=a$e;function o$e(t){return t}var kk=o$e;function s$e(t){return function(e){return e==null?void 0:e[t]}}var u$e=s$e,l$e=tx;function d$e(t){return function(e){return l$e(e,t)}}var c$e=d$e,f$e=u$e,m$e=c$e,p$e=Z1,h$e=zs;function v$e(t){return p$e(t)?f$e(h$e(t)):m$e(t)}var g$e=v$e,y$e=RCe,_$e=i$e,b$e=kk,w$e=Dn,x$e=g$e;function k$e(t){return typeof t=="function"?t:t==null?b$e:typeof t=="object"?w$e(t)?_$e(t[0],t[1]):y$e(t):x$e(t)}var P$e=k$e;function T$e(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var M$e=T$e,S$e=M$e,DH=Math.max;function O$e(t,e,r){return e=DH(e===void 0?t.length-1:e,0),function(){for(var n=arguments,a=-1,o=DH(n.length-e,0),i=Array(o);++a<o;)i[a]=n[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=n[a];return s[e]=r(i),S$e(t,this,s)}}var E$e=O$e;function D$e(t){return function(){return t}}var C$e=D$e,$$e=C$e,CH=eF,A$e=kk,R$e=CH?function(t,e){return CH(t,"toString",{configurable:!0,enumerable:!1,value:$$e(e),writable:!0})}:A$e,I$e=R$e,N$e=800,L$e=16,W$e=Date.now;function F$e(t){var e=0,r=0;return function(){var n=W$e(),a=L$e-(n-r);if(r=n,a>0){if(++e>=N$e)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var j$e=F$e,V$e=I$e,z$e=j$e,U$e=z$e(V$e),H$e=U$e,q$e=kk,B$e=E$e,Y$e=H$e;function G$e(t,e){return Y$e(B$e(t,e,q$e),t+"")}var K$e=G$e,X$e=I0,J$e=ma;function Q$e(t){return J$e(t)&&X$e(t)}var Z$e=Q$e,e2e=yDe,t2e=TDe,r2e=P$e,n2e=K$e,Pk=Z$e,a2e=lU,i2e=n2e(function(t,e){var r=a2e(e);return Pk(r)&&(r=void 0),Pk(t)?e2e(t,t2e(e,1,Pk,!0),r2e(r)):[]}),o2e=i2e;const Tk="projects",{LOAD_PROJECT_NOTE:Mk,DO_CREATE_PROJECT_NOTE:$H,DO_UPDATE_PROJECT_NOTE:AH,FORM_NEW_PROJECT_NOTE:s2e,FORM_EDIT_PROJECT_NOTE:RH,FORM_SUBMIT_PROJECT_NOTE:IH}=jn,{SET_PROJECT_NOTES:NH,SET_PROJECT_NOTES_FETCHING:LH,SET_PROJECT_NOTES_POSTING:Um}=Fr,{SET_FORM:WH}=zn,u2e={async[Mk]({commit:t},{id:e}){try{if(t(LH,!0),!e)return;const{data:r}=await ehe(e);if(!r)return;t(NH,{projectNotes:[r]})}catch(r){this.handleError(r,{object:"projectNote",objectId:e,fallbackCode:"projectNote.get",action:`${Tk}/${Mk}`,actionPayload:arguments[1]})}finally{t(LH,!1)}},async[$H]({commit:t},{body:e}){try{t(Um,!0);const{data:r}=await the(e);return t(NH,{projectNotes:[r]}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("note")})}),r.id}catch(r){throw r}finally{t(Um,!1)}},async[AH]({commit:t,dispatch:e},{id:r,body:n}){try{return t(Um,!0),await rhe(r,n),await e(Mk,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("note")})}),r}catch(a){throw a}finally{t(Um,!1)}},[s2e]({commit:t},{projectId:e=null}){const r={ProjectId:e,text:""};t(`forms/${WH}`,{key:"projectNote",formData:r},{root:!0})},async[RH]({commit:t,state:e},{projectId:r}){try{const n=e.data[r].ProjectNote;t(`forms/${WH}`,{key:"projectNote",formData:n},{root:!0})}catch(n){this.handleError(n,{object:"projectNote",fallbackCode:"projectNote.edit",action:`${Tk}/${RH}`,actionPayload:arguments[1]})}},async[IH]({rootGetters:t,dispatch:e}){try{const r=t["forms/getFormByKey"]("projectNote");let{id:n}=r;return n?await e(AH,{id:r.id,body:r}):n=await e($H,{body:r}),n}catch(r){return this.handleError(r,{object:"projectNote",fallbackCode:"projectNote.submit",action:`${Tk}/${IH}`}),null}}},dd="projects",{LOAD_PROJECT_FILE:Hm,CREATE_PROJECT_FILE:FH,UPDATE_PROJECT_FILE:jH,DELETE_PROJECT_FILE:VH,PATCH_PROJECT_FILE:Sk}=LV,l2e={async[Hm](t,{id:e}){try{const{data:r}=await Kpe(e);return await this.dispatch(Oe.SET_AS_NORMALIZED_DATA,{data:[r],schema:"projectFiles"}),!0}catch(r){return this.handleError(r,{object:"projectFile",objectId:e,fallbackCode:"projectFile.get",action:`${dd}/${Hm}`,actionPayload:arguments[1]}),!1}},async[FH](t,{projectId:e,fileId:r}){try{if(typeof e>"u")throw new Error("Missing parameter projectId");if(typeof r>"u")throw new Error("Missing parameter fileId");const{data:n}=await Xpe({ProjectId:e,FileId:r});return await this.dispatch(Oe.SET_AS_NORMALIZED_DATA,{data:[n],schema:"projectFiles"}),n.id}catch(n){return this.handleError(n,{object:"projectFile",fallbackCode:"projectFile.post",action:`${dd}/${FH}`,actionPayload:arguments[1]}),null}},async[jH]({dispatch:t},{id:e,body:r}){try{return await Jpe(e,r),await t(Hm,{id:e}),e}catch(n){return this.handleError(n,{object:"projectFile",objectId:e,fallbackCode:"projectFile.put",action:`${dd}/${jH}`,actionPayload:arguments[1]}),null}},async[VH]({commit:t,getters:e},{projectId:r,id:n}){try{const a=e.byId(r);if(a){const o=a.files.find(s=>s.id===n),{FileId:i}=o;this.dispatch(Oe.DELETE_FILE,{id:i})}return await Qpe(n),t(dm.DELETE_PROJECT_FILE,{projectId:r,id:n}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("file")}),actions:{undo:()=>{this.dispatch(`projects/${Sk}`,{id:n,projectId:r})}}}),n}catch(a){return this.handleError(a,{object:"projectFile",objectId:n,fallbackCode:"projectFile.delete",action:`${dd}/${VH}`,actionPayload:arguments[1]}),null}},async[Sk]({dispatch:t,getters:e},{projectId:r,id:n}){try{await Zpe(n),await t(Hm,{id:n});const a=e.byId(r);if(a){const o=a.files.find(s=>s.id===n),{FileId:i}=o;await this.dispatch(Oe.PATCH_FILE,{id:i})}return n}catch(a){return this.handleError(a,{object:"file",objectId:n,fallbackCode:"file.patch",action:`${dd}/${Sk}`,actionPayload:arguments[1]}),null}}},{LOAD_EVENTS_FOR_PROJECT:d2e}=jn,{SET_EVENTS:c2e}=Fr,f2e={async[d2e]({commit:t},{id:e}){const{data:r}=await fr.get(`/project/${e}/event`);return!r||r.length<=0?!1:(t(c2e,{events:r}),!0)}},zr="projects",{LOAD_PROJECT:Ok,LOAD_PROJECTS:zH,DO_LOAD_PROJECT:UH,DO_LOAD_PROJECTS:qm,DO_LOAD_PROJECTS_COUNT:m2e,LOAD_PROJECTS_FOR_CLIENT:HH,LOAD_PROJECTS_FOR_USER:qH,LOAD_PUBLIC_PROJECT:BH,CREATE_PROJECT:p2e,CREATE_DEMOPROJECT:YH,UPDATE_PROJECT:GH,DELETE_PROJECT:KH,PATCH_PROJECT:Ek,DO_SUBMIT_PROJECT:XH,SUBMIT_PROJECT:JH,SUBMIT_PROJECT_MEMBER:Dk,DELETE_PROJECT_MEMBER:Ck,SET_PROJECT_LEADER:QH,SET_PROJECT_FILTER:h2e,SET_PROJECT_SORT:v2e,SET_QUICKVIEW_PROJECT:$k,CLEAR_PROJECTS:g2e}=jn,{UPDATE_VIEW_SETTINGS:y2e,DO_UPDATE_SETTINGS:Ak,DO_LOAD_CURRENT_COMPANY:_2e}=Oe,{CLEAR_PROJECT_DATA:b2e,SET_PROJECTS_POSTING:Rt,SET_PROJECTS_FETCHING:bo,DELETE_MANY_PROJECTS:w2e}=Fr,x2e={...u2e,...f2e,...l2e,async[qm]({commit:t,state:e,rootState:r},n={}){try{const a={clearOld:!1,start:n.end?0:void 0,end:void 0,sort:void 0,order:void 0,force:!1,filter:void 0,...n},{canFetchMore:o}=e;let i=!!o;if(a.clearOld&&(i=!0),e.isFetching&&!a.force||ot(a.start)==="number"&&ot(a.end)==="number"&&!i&&!a.force)return;t(bo,!0);const{data:s}=await R3({start:a.start,end:a.end,sort:a.sort,order:a.order,filter:a.filter});let u={};s.forEach(({cachedDocuments:m})=>{if(m){const c=Object.keys(m.documents).reduce((p,h)=>({...p,[h]:{id:h,data:{name:m.documents[h].name,clients:[{name:te(m,`documents[${h}].firstClient.name`,""),type:te(m,`documents[${h}].firstClient.type`),addresses:te(m,`documents[${h}].firstClient.addresses`)}]},status:m.documents[h].status}}),{});u={...u,...c}}});const l=r.documents2.ids,d=o2e(Object.keys(u),l);this.commit("documents2/SET_DOCUMENTS2",{data:d.map(m=>u[m])}),a.clearOld&&t(b2e),this.dispatch(uo,{data:s,schema:"projects"}),i=!((ot(a.start)==="number"&&ot(a.end)==="number"?a.end-a.start:0)>s.length),t(Fr.SET_PROJECTS_CAN_FETCH_MORE,i)}catch(a){throw a}finally{t(bo,!1)}},async[m2e]({commit:t}){try{t(bo,!0);const{data:e}=await fr.get("/project/counts");t(Fr.SET_PROJECTS_COUNT,{data:e})}catch(e){throw e}finally{t(bo,!1)}},async[zH]({dispatch:t},e={}){try{await t(qm,e)}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${zH}`,actionPayload:arguments[1]})}},async[Ok]({dispatch:t},{id:e}){try{await t(UH,{id:e})}catch(r){this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.get",action:`${zr}/${Ok}`,actionPayload:arguments[1]})}},async[UH]({commit:t},{id:e}){try{t(bo,!0);const r=[],{data:n}=await jpe(e);return n&&r.push(n),this.dispatch(uo,{data:r,schema:"projects"}),t(bo,!1),n}catch(r){throw t(bo,!1),r}},async[HH]({dispatch:t},{id:e}){try{await t(qm,{filter:{clientEndCustomerIds:{[e]:"contains"}}})}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${HH}`,actionPayload:arguments[1]})}},async[qH]({dispatch:t},{id:e}){try{await t(qm,{filter:{CompanyUserId:{[e]:!0}}})}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.get",action:`${zr}/${qH}`,actionPayload:arguments[1]})}},async[BH](t,e){try{const{data:r}=await fr.get(`/project/public/${e}`);this.dispatch(uo,{data:r,schema:Kxe})}catch(r){this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.get",action:`${zr}/${BH}`,actionPayload:arguments[1]})}},async[p2e]({dispatch:t,commit:e,rootGetters:r},{body:n}){try{e(Rt,!0);const{data:a}=await Fpe(n);return await t(jn.LOAD_PROJECT,{id:a.id}),r["application/companyAccountType"]==="free"&&this.dispatch(_2e),e(Rt,!1),Promise.resolve(a.id)}catch(a){return e(Rt,!1),Promise.reject(a)}},async[YH]({dispatch:t,commit:e}){try{e(Rt,!0);const{data:r}=await Hpe(),{id:n}=r;return this.dispatch(Ak,{key:"company",settings:[{name:"demoProjectId",value:n}]}),await t(jn.LOAD_PROJECT,{id:n}),e(Rt,!1),n}catch(r){return this.handleError(r,{object:"project",fallbackCode:"project.demo",action:`${zr}/${YH}`,actionPayload:arguments[1]}),null}finally{e(Rt,!1)}},async[GH]({dispatch:t,commit:e},{id:r,body:n}){try{return e(Rt,!0),await Vpe(r,n),await t(jn.LOAD_PROJECT,{id:r}),e(Rt,!1),r}catch(a){throw e(Rt,!1),a}},async[KH]({commit:t,dispatch:e},{id:r}){try{return t(Rt,!0),await Upe(r),t(w2e,r),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("project")}),actions:{undo:()=>{this.dispatch(`projects/${Ek}`,{id:r})}}}),e($k,{id:null}),t(Rt,!1),!0}catch(n){return t(Rt,!1),this.handleError(n,{object:"project",objectId:r,fallbackCode:"project.delete",action:`${zr}/${KH}`,actionPayload:arguments[1]}),!1}},async[Ek]({dispatch:t},{id:e}){try{return await zpe(e),await t(Ok,{id:e}),e}catch(r){return this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.patch",action:`${zr}/${Ek}`,actionPayload:arguments[1]}),!1}},async[$k]({commit:t},{id:e}){try{return this.dispatch(y2e,{view:"projectList",settings:{quickViewProjectId:e}}),e}catch(r){return t(Rt,!1),this.handleError(r,{object:"project",objectId:e,fallbackCode:"project.quickview",action:`${zr}/${$k}`,actionPayload:arguments[1]}),!1}},async[QH]({dispatch:t,commit:e,getters:r},{projectId:n,companyUserId:a}){var o;try{e(Rt,!0);const i=r.byId(n).getProperty("CompanyUserId");return await t(GH,{id:n,body:{CompanyUserId:a}}),await t(Ck,{projectId:n,companyUserId:a}),await t(Dk,{projectId:n,companyUserId:i}),(o=this.$segment)==null||o.track("Project Leader Changed",{projectId:n,companyUserId:a}),e(Rt,!1),!0}catch(i){return e(Rt,!1),this.handleError(i,{object:"project",objectId:n,fallbackCode:"project.projectLeader",action:`${zr}/${QH}`,actionPayload:arguments[1]}),!1}},async[XH]({dispatch:t},{data:e}){let{id:r}=e;return r?await t(jn.UPDATE_PROJECT,{id:e.id,body:e}):r=await t(jn.CREATE_PROJECT,{body:e}),await t(jn.LOAD_PROJECT,{id:r}),r},async[JH]({dispatch:t},e){try{await t(XH,e)}catch(r){this.handleError(r,{object:"project",fallbackCode:"project.post",action:`${zr}/${JH}`,actionPayload:arguments[1]})}return!0},async[Dk]({commit:t},{projectId:e,companyUserId:r}){var n;try{return t(Rt,!0),await whe(e,r),t(Fr.ADD_PROJECT_MEMBER,{projectId:e,companyUserId:r}),(n=this.$segment)==null||n.track("Project Member Added",{projectId:e,companyUserId:r}),t(Rt,!1),!0}catch(a){return t(Rt,!1),this.handleError(a,{object:"project",objectId:e,fallbackCode:"project.member.post",action:`${zr}/${Dk}`,actionPayload:arguments[1]}),!1}},async[Ck]({commit:t},{projectId:e,companyUserId:r}){var n;try{return t(Rt,!0),await xhe(e,r),t(Fr.DELETE_PROJECT_MEMBER,{projectId:e,companyUserId:r}),(n=this.$segment)==null||n.track("Project Member Removed",{projectId:e,companyUserId:r}),t(Rt,!1),!0}catch(a){return t(Rt,!1),this.handleError(a,{object:"project",objectId:e,fallbackCode:"project.member.delete",action:`${zr}/${Ck}`,actionPayload:arguments[1]}),!1}},async[h2e](t,e){const r=JSON.stringify(e);await this.dispatch(Ak,{key:"companyUser",settings:[{name:"projectListFilter",value:r}]})},async[v2e](t,e){const r=JSON.stringify(e);await this.dispatch(Ak,{key:"companyUser",settings:[{name:"projectListSort",value:r}]})},[g2e]({commit:t}){t(Fr.CLEAR_PROJECT_DATA),t(Fr.SET_PROJECTS_CAN_FETCH_MORE,!0)}},{SET_PROJECT_NOTES:k2e,SET_PROJECT_NOTES_FETCHING:P2e,SET_PROJECT_NOTES_POSTING:T2e}=Fr,M2e={[k2e](t,{projectNotes:e=[]}){e.forEach(r=>{const{ProjectId:n}=r;return!n||!t.data[n]?!1:(ce.set(t.data[n],"ProjectNote",r),!0)})},[P2e](t,e){t.isFetchingProjectNotes=e},[T2e](t,e){t.isPostingProjectNotes=e}},{SET_EVENTS:S2e}=Fr,O2e={[S2e](t,{events:e=[]}){e.forEach(r=>{const{ProjectId:n}=r;if(!n||!t.data[n])return!1;let a=[];t.data[n].Events?a=t.data[n].Events:ce.set(t.data[n],"Events",a);const o=a.findIndex(i=>i.id===r.id);return o!==-1?a[o]=Object.assign(a[o],r):a.push(r),!0})}},E2e={[dm.SET_PROJECT_FILES](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a projectFile or an array of projectFiles!");(Array.isArray(e)?e:[e]).forEach(n=>{const{ProjectId:a}=n;if(!a||!t.data[a])return!1;let o=[];t.data[a].ProjectFiles?o=t.data[a].ProjectFiles:ce.set(t.data[a],"ProjectFiles",o);const i=o.findIndex(s=>s.id===n.id);return i!==-1?o[i]=Object.assign(o[i],n):o.push(n),!0})},[dm.DELETE_PROJECT_FILE](t,{projectId:e,id:r}){if(!e||!t.data[e])return!1;const n=t.data[e].ProjectFiles;if(n&&Array.isArray(n)){const a=n.findIndex(o=>o.id===r);a!==-1&&n.splice(a,1)}return!0}},{SET_PROJECTS:D2e,CLEAR_PROJECT_DATA:C2e,DELETE_MANY_PROJECTS:$2e,ADD_PROJECT_MEMBER:A2e,DELETE_PROJECT_MEMBER:R2e,SET_PROJECTS_FETCHING:I2e,SET_PROJECTS_POSTING:N2e,SET_PROJECTS_CAN_FETCH_MORE:L2e,SET_PROJECTS_COUNT:W2e}=Fr,F2e={...M2e,...O2e,...E2e,updateField:Gl,[D2e](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a project or an array of projects!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[C2e](t){Object.assign(t,{data:{},ids:[],projectPublicIdToId:{}})},[$2e](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{if(!t.data[n])return;const{publicId:a}=t.data[n];ce.delete(t.data,n),t.ids=t.ids.filter(o=>o!==n),ce.delete(t.projectPublicIdToId,a)})},[A2e](t,{projectId:e,companyUserId:r}){if(!e)throw Error("Cannot add member as no projectId is defined");if(!r)throw Error("Cannot add member as no companyUserId is defined");if(!t.data[e])return!1;let n=[];t.data[e].ProjectMembers?n=t.data[e].ProjectMembers:ce.set(t.data[e],"ProjectMembers",n);const a=n.findIndex(o=>o===r);return a!==-1?n[a]=r:n.push(r),!0},[R2e](t,{projectId:e,companyUserId:r}){if(!e)throw Error("Cannot delete member as no projectId is defined");if(!r)throw Error("Cannot delete member as no companyUserId is defined");if(!t.data[e])return!1;let n=[];t.data[e].ProjectMembers?n=t.data[e].ProjectMembers:ce.set(t.data[e],"ProjectMembers",n);const a=n.findIndex(o=>o===r);return a!==-1&&n.splice(a,1),!0},[I2e](t,e){t.isFetching=e},[N2e](t,e){t.isPosting=e},[L2e](t,e){t.canFetchMore=e},[W2e](t,{data:e={}}){if(typeof e!="object"||Array.isArray(e))throw Error("Data must be an object!");const r={};Object.keys(e).forEach(n=>{r[n]=e[n]||0}),t.count=r}},j2e={id:{$default:null,$type:Number,$scope:["project","offer","contract"]},name:{$default:"",$type:String,$scope:["project","offer","contract"]},isDemo:{$default:!1,$type:Boolean,$scope:["project"]},externalId:{$default:"",$type:Number},publicId:{$default:null,$type:String},projectNumber:{$default:null,$type:Number},CompanyId:{$default:null,$type:"ref",$ref:"companies"},CompanyUserId:{$default:null,$type:"ref",$ref:"companyUsers"},ProjectMembers:[{$type:"ref",$ref:"companyUsers"}],ProjectSettings:{$default:[],$type:Array,$scope:["project","offer","contract"]},frontend:{$default:"vue",$type:String,$scope:["project","offer","contract"]},status:{$default:"new",$type:String},createdAt:{$default:null,$type:Date},updatedAt:{$default:null,$type:Date},deletedAt:{$default:null,$type:Date}},uW=class{constructor(e,r,n){if(!e)throw Error("First arg. id is required");if(!r)throw Error("Seccond arg. getters is required");this._getters=r,this._project=e,this._documents=[]}get id(){return this._project.id}getId(){const{id:e}=this.getProject()||{};return e||null}getProject(){const{_project:e}=this;return e||null}get documents(){if(!this.documentIds.length)return[];let e=[];const r=te(this._project,"cachedDocuments.mainDocument.id");return this.documentIds.forEach(n=>{const a=this._getters["documents2/byId"](n);a&&(a.id===r?e=[a,...e]:e.push(a))}),e}get cachedDocumentsInfo(){let e=[];const{cachedDocuments:r}=this._project;if(!r)return[];const{documents:n={},mainDocument:a={}}=r;return Object.keys(n).forEach(o=>{const i=n[o];i&&(i.id===a.id?e=[i,...e]:e.push(i))}),e}get documentIds(){const{cachedDocuments:e}=this._project;if(!e)return[];const{documents:r}=e;return r?Object.keys(r):[]}get invoices(){return this._getters["invoices/byProjectId"](this.getId())||[]}get events(){return this._project.Events||[]}get creatorId(){return this._project.CompanyUser}get creator(){const{_getters:e}=this,{CompanyUser:r}=this.getProject()||{};return e["companyUsers/byId"](r)}get name(){return this._project.name}get status(){return this._project.status}get subStatus(){const{status:e,mainDocument:r}=this;return["offer","contract"].includes(e)&&r?r.status:null}get clients(){const e=[];return this.documents.reduce((n,a)=>(a.clients.forEach(o=>{e.includes(o.endCustomerId)||(e.push(o.endCustomerId),n.push(o))}),n),[])}get mainDocument(){return this.documents[0]}get currency(){return te(this,"mainDocument.currency",null)}get members(){const{_getters:e}=this,{ProjectMembers:r=[]}=this.getProject()||{};return r.map(a=>e["companyUsers/byId"](a))}get projectNumber(){return this._project.projectNumber}get note(){return this._project.ProjectNote}get files(){return this._project.ProjectFiles}get firstClientName(){return this._project.firstClientName}get firstClientStreet(){return this._project.firstClientStreet}get prices(){const e={types:[],subTotal:0,taxAmount:0,total:0,maxTotal:0,invoicedAmount:0,paidAmount:0,hasDeductions:!1,currency:this.currency};if(!this.documents.length)return e;this.documents.forEach(n=>{e.types=[...new Set([...e.types,...n.prices.type])],!(e.currency&&e.currency!==n.currency)&&(e.subTotal+=n.prices.subTotal,e.taxAmount+=n.prices.taxAmount,e.total+=n.prices.total,e.maxTotal+=n.prices.maxTotal,n.prices.region&&n.prices.region.houseWorkAmount&&(e.hasDeductions=!0))});const{invoices:r}=this;return r.forEach(n=>{e.invoicedAmount+=n.totalAmount,e.paidAmount+=n.paidAmount}),e}get isDemo(){return this.getProperty("isDemo")}getProperty(e=""){return e.replace(/\[(.*)\]/ig,(a,o)=>`.${o}`).split(".").reduce((a,o)=>a&&(typeof a[o]!="object",a[o]),this._project)}getProperties({scope:e=null}={}){let r=e;typeof r=="string"&&(r=[r]);const{schema:n}=uW,a={};n&&Object.keys(n).map(i=>(n[i].$default!=="undefined"&&(a[i]=n[i].$default),!0));const o=Object.assign({},a,this._project);return n&&r&&Array.isArray(r)&&Object.keys(n).map(i=>n[i].$scope?(r.some(u=>n[i].$scope.indexOf(u)>=0)||delete o[i],!0):(delete o[i],!0)),JSON.parse(JSON.stringify(o))}};let wo=uW;Ut(wo,"schema",j2e),Ut(wo,"statuses",{new:{statusText:"Utkast",statusClass:"draft"},sent:{statusText:"Skickad",statusClass:"sent"},denied:{statusText:"Nekad",statusClass:"denied"},accepted:{statusText:"Accepterad",statusClass:"accepted"},signed:{statusText:"Signerad",statusClass:"accepted"},semiSigned:{statusText:"Delsignerad",statusClass:"accepted"},active:{statusText:"P\xE5g\xE5ende",statusClass:"active"},completed:{statusText:"Klar",statusClass:"completed"},archived:{statusText:"Arkiverad",statusClass:"archived"}});const V2e={getField:vm,...{isPostingProjectNote:t=>t.isPostingProjectNotes,isFetchingProjectNote:t=>t.isFetchingProjectNotes},byId:(t,e,r,n)=>a=>t.data[a]?new wo(t.data[a],n):null,projectIdsByClientId:t=>e=>t.ids.filter(r=>{const n=te(t.data[r],"clientEndCustomerIds","");return n?n.split(",").includes(`${e}`):!1}),projectIdsOwnedByUserId:(t,e)=>r=>t.ids.filter(n=>{const a=e.byId(n);if(!a)return!1;const o=a.getProperty("CompanyUserId");return o?o===r:!1}),projects:(t,e,r,n)=>t.ids.map(a=>new wo(t.data[a],n)),projectByPublicId:(t,e,r,n)=>a=>{const o=t.projectPublicIdToId[a];return o?new wo(t.data[o],n):null},projectsByStatus:(t,{projects:e})=>r=>e.filter(n=>n.status===r),filter:(t,e,r,n)=>{const a=n["settings/getCompanyUserSetting"]("projectListFilter");return a?JSON.parse(a):{or:{docStatuses:{draft:"contains",sent:"contains",accepted:"contains",denied:"contains"},status:{active:!0,completed:!0}}}},sort:(t,e,r,n)=>{const a=n["settings/getCompanyUserSetting"]("projectListSort");return a?JSON.parse(a):{sort:"updatedAt",order:"DESC"}},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,canFetchMore:t=>t.canFetchMore,count:t=>t.count},z2e={namespaced:!0,state:WEe,getters:V2e,actions:x2e,mutations:F2e},U2e={data:{},ids:[],isPosting:!1,isFetching:!1},cd="templates",{DO_LOAD_TEMPLATE:fd,DO_LOAD_TEMPLATES:ZH,LOAD_TEMPLATE:e7,LOAD_TEMPLATES:t7,DO_UPDATE_TEMPLATE:r7,DO_CREATE_TEMPLATE:n7,UPDATE_TEMPLATE:a7,DELETE_TEMPLATE:i7,PATCH_TEMPLATE:Rk,HIDE_TEMPLATE:o7,DUPLICATE_PROTECTED_TEMPLATE:s7}=qV,{SET_TEMPLATE_POSTING:Bn,SET_TEMPLATE_FETCHING:Bm,SET_TEMPLATES:u7,DELETE_MANY_TEMPLATES:H2e}=sx,q2e={async[fd]({commit:t},{id:e,params:r={}}){try{t(Bm,!0);const{data:n}=await to.get(e,r);t(u7,{data:[n]})}catch(n){throw n}finally{t(Bm,!1)}},async[ZH]({commit:t},e={}){try{t(Bm,!0);const{data:r}=await to.get(null,e),{items:n}=r;t(u7,{data:n})}catch(r){throw r}finally{t(Bm,!1)}},async[t7]({dispatch:t},e={}){try{await t(ZH,e)}catch(r){this.handleError(r,{object:"template",fallbackCode:"template.getMany",action:`${cd}/${t7}`})}},async[e7]({dispatch:t},{id:e}){try{await t(fd,{id:e})}catch(r){this.handleError(r,{object:"template",fallbackCode:"template.getOne",action:`${cd}/${e7}`,actionPayload:arguments[1]})}},async[n7]({commit:t,dispatch:e},{body:r,showMessage:n=!0}){try{t(Bn,!0);const{data:a}=await to.post(r),{id:o}=a;return await e(fd,{id:o}),n&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("template")})}),o}catch(a){throw a}finally{t(Bn,!1)}},async[r7]({dispatch:t,commit:e},{id:r,body:n}){try{return e(Bn,!0),await to.put(r,n),await t(fd,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("template")})}),r}catch(a){throw a}finally{e(Bn,!1)}},async[a7]({dispatch:t},{id:e,body:r}){try{return r.companyId?(await t(r7,{id:e,body:r}),e):t(s7,{body:r})}catch(n){return this.handleError(n,{object:"template",objectId:e,fallbackCode:"template.put",action:`${cd}/${a7}`,actionPayload:arguments[1]}),null}},async[i7]({commit:t},{id:e}){try{return t(Bn,!0),await to.delete(e),t(H2e,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("template")}),actions:{undo:()=>{this.dispatch(`templates/${Rk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"templates",objectId:e,fallbackCode:"documentTemplate.delete",action:`${cd}/${i7}`,actionPayload:arguments[1]}),null}finally{t(Bn,!1)}},async[Rk]({commit:t,dispatch:e},{id:r}){try{return t(Bn,!0),await to.patch(r),await e(fd,{id:r}),r}catch(n){return this.handleError(n,{object:"templates",objectId:r,fallbackCode:"documentTemplate.patch",action:`${cd}/${Rk}`,actionPayload:arguments[1]}),null}finally{t(Bn,!1)}},async[o7]({rootGetters:t},{id:e}){if(!e)return;const r=t["settings/getCompanySetting"]("templateHiddenIds")||[];r.push(e),await this.dispatch(Oe.UPDATE_SETTINGS,{key:"company",settings:{templateHiddenIds:r}})},async[s7]({commit:t,dispatch:e,rootGetters:r},{body:n}){try{t(Bn,!0);const a=ni(n,["_id","id","companyId"]),o=await e(n7,{body:a});return await e(o7,{id:n.id}),o}catch(a){throw a}finally{t(Bn,!1)}}},{SET_TEMPLATES:B2e,SET_TEMPLATE_FETCHING:Y2e,SET_TEMPLATE_POSTING:G2e,DELETE_MANY_TEMPLATES:K2e}=sx,X2e={[B2e](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a template or an array of templates!");const r=Array.isArray(e)?e:[e],n=[];r.forEach(a=>{!a.id||(t.ids.includes(a.id)||n.push(a.id),ce.set(t.data,a.id,a))}),t.ids=eo([...n,...t.ids])},[Y2e](t,e){t.isFetching=e},[G2e](t,e){t.isPosting=e},[K2e](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{!t.data[n]||(ce.delete(t.data,n),t.ids=t.ids.filter(a=>a!==n))})}},J2e={namespaced:!0,state:U2e,getters:{byId:t=>e=>t.data[e]?new fi(t.data[e]):null,idList:t=>t.ids,isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,hiddenTemplateIds:(t,e,r,n)=>n["settings/getCompanySetting"]("templateHiddenIds")||[],availableTemplates:(t,e)=>{const{idList:r,hiddenTemplateIds:n}=e;return r.filter(o=>!n.includes(o)).map(o=>new fi(t.data[o]))},hiddenTemplates:(t,e)=>{const{idList:r,hiddenTemplateIds:n}=e;return n.filter(o=>r.includes(o)).map(o=>new fi(t.data[o]))}},actions:q2e,mutations:X2e},Q2e={data:{},ids:[],isFetching:!1,isPosting:!1},Zs="documents2",{DELETE_DOCUMENT2:l7,DO_CREATE_DOCUMENT2:Z2e,DO_LOAD_DOCUMENT2:xo,DO_LOAD_DOCUMENTS2:d7,DO_UPDATE_DOCUMENT2:Ym,LOAD_DOCUMENT2:c7,LOAD_DOCUMENTS2:Ik,LOAD_DOCUMENTS2_EXTERNAL:eAe,PATCH_DOCUMENT2:Nk,UPDATE_DOCUMENT2:f7,UPDATE_DOCUMENT2_STATUS:m7,DO_SEND_DOCUMENT2:tAe,SEND_REMINDER_DOCUMENT2:rAe,REQUEST_PROPERTY_DOCUMENT2:nAe,CLEAR_DOCUMENT2_ANSWERS:p7,ANSWER_OWN_DOCUMENT2:aAe}=jV,{DELETE_MANY_DOCUMENTS2:iAe,SET_DOCUMENT2_POSTING:ar,SET_DOCUMENT2_FETCHING:Gm,SET_DOCUMENTS2:h7}=ax,{SHOW_MESSAGE:oAe,DO_LOAD_CURRENT_COMPANY:sAe}=Oe,uAe={async[xo]({commit:t},{id:e}){try{t(Gm,!0);const{data:r}=await Kr.get(e);t(h7,{data:[r]})}catch(r){throw r}finally{t(Gm,!1)}},async[d7]({commit:t},e={}){try{t(Gm,!0);const{data:r}=await Kr.getAll(e),{items:n}=r;t(h7,{data:n})}catch(r){throw r}finally{t(Gm,!1)}},async[Ik]({dispatch:t},e={isHidden:!1}){try{await t(d7,e)}catch(r){this.handleError(r,{object:"document2",fallbackCode:"document2.getMany",action:`${Zs}/${Ik}`})}},async[eAe]({dispatch:t},{service:e,type:r=null,typeId:n=null}){if(typeof e>"u")throw new Error("Missing param service");await t(Ik,{isHidden:!1,returnType:"template","externalReferences.service":e,...r&&{"externalReferences.type":r},...n&&{"externalReferences.typeId":n}})},async[c7]({dispatch:t},{id:e}){try{await t(xo,{id:e})}catch(r){this.handleError(r,{object:"document2",fallbackCode:"document2.getOne",action:`${Zs}/${c7}`,actionPayload:arguments[1]})}},async[Z2e]({rootGetters:t,commit:e,dispatch:r},{body:n}){try{e(ar,!0);const{data:a}=await Kr.post(n),{id:o}=a;return await r(xo,{id:o}),t["application/companyAccountType"]==="free"&&await this.dispatch(sAe),o}catch(a){throw a}finally{e(ar,!1)}},async[tAe]({commit:t},{id:e}){try{t(ar,!0),await Kr.send(e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("sentThing",{thing:be.t("document")}),omit:"$view:extension"})}catch(r){throw r}finally{t(ar,!1)}},async[rAe]({commit:t},{id:e,body:r={}}){try{const n={views:{sms:{nodes:[{nodeId:1,parentId:null,itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.reminder.text"}}]},email:{nodes:[{nodeId:1,parentId:null,itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.reminder.subject",title:"data.emailTemplate.reminder.title",content:"data.emailTemplate.reminder.content",text:"data.emailTemplate.reminder.text"}}]}}};t(ar,!0),await Kr.send(e,{...n,...r,sendSource:"reminder"}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("sentThing",{thing:be.t("reminder")})})}catch(n){throw n}finally{t(ar,!1)}},async[nAe]({commit:t},{id:e,body:r={}}){try{const n={views:{sms:{nodes:[{nodeId:1,parentId:null,itemId:"smsText",itemType:"smsText",value:{text:"data.smsTemplate.propertyDesignation.text"}}]},email:{nodes:[{nodeId:1,parentId:null,itemId:"emailTemplate",itemType:"emailTemplate",value:{subject:"data.emailTemplate.propertyDesignation.subject",title:"data.emailTemplate.propertyDesignation.title",content:"data.emailTemplate.propertyDesignation.content",text:"data.emailTemplate.propertyDesignation.text",actionUrl:"data.emailTemplate.propertyDesignation.actionUrl"}}]}}},{data:a}=await Kr.get(e),o=s=>be.t(`propertyDesignationRequest.${s}`,{ns:"actions",interpolation:{prefix:"__",suffix:"__"}});Xt(a,"data.smsTemplate.propertyDesignation",{text:o("smsTemplate.text")}),Xt(a,"data.emailTemplate.propertyDesignation",{subject:o("emailTemplate.subject"),title:o("emailTemplate.title"),content:o("emailTemplate.content"),text:o("emailTemplate.text"),actionUrl:o("emailTemplate.actionUrl")});const i={...n,document:a,clients:[a.clients[0]]};t(ar,!0),await Kr.send(e,{...i,...r,sendSource:"propertyDesignation"}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("actions:propertyDesignationRequest.successMessage")})}catch(n){throw n}finally{t(ar,!1)}},async[Ym]({dispatch:t,commit:e},{id:r,body:n,params:a={},showMessage:o=!0}){try{return e(ar,!0),await Kr.put(r,n,a),await t(xo,{id:r}),o&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("document")}),omit:"$view:extension"}),r}catch(i){throw i}finally{e(ar,!1)}},async[f7]({dispatch:t},{id:e,body:r,params:n={}}){try{return await t(Ym,{id:e,body:r,params:n}),e}catch(a){return this.handleError(a,{object:"document2",objectId:e,fallbackCode:"document2.put",action:`${Zs}/${f7}`,actionPayload:arguments[1]}),null}},async[l7]({commit:t},{id:e}){try{return t(ar,!0),await Kr.delete(e),t(iAe,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("document")}),actions:{undo:()=>{this.dispatch(`documents2/${Nk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"document2",objectId:e,fallbackCode:"document2.delete",action:`${Zs}/${l7}`,actionPayload:arguments[1]}),null}finally{t(ar,!1)}},async[Nk]({commit:t,dispatch:e},{id:r}){try{return t(ar,!0),await Kr.patch(r),await e(xo,{id:r}),r}catch(n){return this.handleError(n,{object:"document2",objectId:r,fallbackCode:"document2.patch",action:`${Zs}/${Nk}`,actionPayload:arguments[1]}),null}finally{t(ar,!1)}},async[m7]({dispatch:t,getters:e},{id:r,status:n}){try{const{hasAnswers:a}=e.byId(r)||{};return a&&!["accepted","denied"].includes(n)?await this.dispatch(oAe,{displayType:"dialog",type:"warning",title:be.t("actions:updateDocumentDialog.title"),message:be.t("actions:updateDocumentDialog.message"),actions:{cancel:{text:be.t("actions:updateDocumentDialog.cancel"),callback:"cancel"},submit:{text:be.t("actions:updateDocumentDialog.submit"),callback:async()=>{await t(p7,{id:r,doFetch:!1}),await t(Ym,{id:r,body:{status:n}})}}}}):await t(Ym,{id:r,body:{status:n}}),r}catch(a){return this.handleError(a,{object:"document2",objectId:r,fallbackCode:"document2.updateStatus",action:`${Zs}/${m7}`,actionPayload:arguments[1]}),null}},async[p7]({dispatch:t},{id:e,doFetch:r=!0}){await Kr.clearAnswers(e),r&&await t(xo,{id:e})},async[aAe]({commit:t,dispatch:e},{id:r,publicId:n,body:a,checksum:o}){try{t(ar,!0);const i={docChecksum:o},{data:s}=await L3.answer(n,a,{},i);return await e(xo,{id:r}),s}catch(i){throw i}finally{t(ar,!1)}}},{DELETE_MANY_DOCUMENTS2:lAe,SET_DOCUMENTS2:dAe,SET_DOCUMENT2_FETCHING:cAe,SET_DOCUMENT2_POSTING:fAe}=ax,mAe={[dAe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a document2 or an array of documents2!");const r=Array.isArray(e)?e:[e],n=[];r.forEach(a=>{!a.id||(t.ids.includes(a.id)||n.push(a.id),ce.set(t.data,a.id,a))}),t.ids=eo([...n,...t.ids])},[lAe](t,e){(Array.isArray(e)?e:[e]).forEach(n=>{!t.data[n]||(ce.delete(t.data,n),t.ids=t.ids.filter(a=>a!==n))})},[cAe](t,e){t.isFetching=e},[fAe](t,e){t.isPosting=e}},pAe={namespaced:!0,state:Q2e,getters:{byData:(t,e,r,n)=>({data:a,documentOptions:o})=>new Js({data:a,documentOptions:o,can:lo.checkPermission.bind(lo),getters:n}),byId:(t,e)=>r=>{const n=t.data[r];return n?e.byData({data:n}):null},byExternalReference:(t,e)=>({service:r,type:n=null,typeId:a=null})=>{if(typeof r>"u")throw new Error("Missing param service");if(typeof r!="string")throw new Error("Param service must be a string");return t.ids.filter(i=>{const s=t.data[i],{externalReferences:u=[]}=s;return u.some(l=>l.service===r&&(!n||l.type===n)&&(!a||l.typeId===a))}).map(i=>e.byId(i))},isPosting:t=>t.isPosting,isFetching:t=>t.isFetching},actions:uAe,mutations:mAe},hAe={data:{},ids:[],isFetching:!1,isPosting:!1},vi="endCustomers",{SET_ENDCUSTOMER_FETCHING:Km,SET_ENDCUSTOMER_POSTING:gi,CLEAR_END_CUSTOMER:vAe}=Us,{LOAD_ENDCUSTOMERS:v7,LOAD_ENDCUSTOMER:Xm,UPDATE_ENDCUSTOMER:Lk,CREATE_ENDCUSTOMER:Wk,DELETE_ENDCUSTOMER:g7,PATCH_ENDCUSTOMER:Fk,FORM_NEW_ENDCUSTOMER:y7,FORM_EDIT_ENDCUSTOMER:gAe,FORM_SUBMIT_ENDCUSTOMER:_7}=HV,yAe={async[v7]({commit:t},{options:e={}}={}){try{t(Km,!0);const r={...typeof e.start=="number"&&{_start:e.start},...e.end&&{_end:e.end},...e.sort&&{_sort:e.sort},...e.order&&{_order:e.order}};if(e.searchQuery.trim()){const a=encodeURIComponent(e.searchQuery);r._where=`or(name*=${a},email*=${a},cellphone*=${a})`}e.clearOld&&t(vAe);const{data:n}=await she(r);return t(Us.SET_ENDCUSTOMERS,{data:n}),n.length}catch(r){return this.handleError(r,{object:"endCustomer",fallbackCode:"endCustomer.getAll",action:`${vi}/${v7}`}),!1}finally{t(Km,!1)}},async[Xm]({commit:t},{id:e}){try{t(Km,!0);const{data:r}=await uhe(e);t(Us.SET_ENDCUSTOMERS,{data:r})}catch(r){this.handleError(r,{object:"endCustomer",objectId:e,fallbackCode:"endCustomer.get",action:`${vi}/${Xm}`,actionPayload:arguments[1]})}finally{t(Km,!1)}},async[Wk]({commit:t},{body:e,showNotification:r=!0}){try{t(gi,!0);const{data:n}=await lhe(e);return t(Us.SET_ENDCUSTOMERS,{data:n}),r&&this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("createdThing",{thing:be.t("client")})}),n.id}catch(n){return this.handleError(n,{object:"endCustomer",fallbackCode:"endCustomer.post",action:`${vi}/${Wk}`,actionPayload:arguments[1]}),null}finally{t(gi,!1)}},async[Lk]({dispatch:t,commit:e},{id:r,body:n}){try{return e(gi,!0),await dhe(r,n),await t(Xm,{id:r}),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("updatedThing",{thing:be.t("client")})}),!0}catch(a){return this.handleError(a,{object:"endCustomer",objectId:r,fallbackCode:"endCustomer.put",action:`${vi}/${Lk}`,actionPayload:arguments[1]}),null}finally{e(gi,!1)}},async[g7]({commit:t},{id:e}){try{return t(gi,!0),await che(e),t(Us.DELETE_ENDCUSTOMER,e),this.dispatch("application/SHOW_MESSAGE",{type:"success",message:be.t("removedThing",{thing:be.t("client")}),actions:{undo:()=>{this.dispatch(`endCustomers/${Fk}`,{id:e})}}}),e}catch(r){return this.handleError(r,{object:"endCustomer",objectId:e,fallbackCode:"endCustomer.delete",action:`${vi}/${g7}`,actionPayload:arguments[1]}),null}finally{t(gi,!1)}},async[Fk]({dispatch:t,commit:e},{id:r}){try{return e(gi,!0),await fhe(r),await t(Xm,{id:r}),r}catch(n){return this.handleError(n,{object:"endCustomer",objectId:r,fallbackCode:"endCustomer.patch",action:`${vi}/${Fk}`,actionPayload:arguments[1]}),null}finally{e(gi,!1)}},async[y7](){try{const t={id:null,customerType:"individual",org_no:null,name:null,reference:null,email:null,street:null,zip:null,city:null,cellphone:null,cellphoneRegion:null,separateWorkAddress:!1,workStreet:null,workZip:null,workCity:null,reverseVat:!1,vatNumber:null,externalId:null,note:null};return this.commit(`forms/${De.SET_FORM}`,{key:"endCustomer",formData:t}),!0}catch(t){return this.handleError(t,{object:"endCustomer",action:`${vi}/${y7}`}),!1}},async[gAe]({getters:t},{id:e,props:r=[]}){const n=ya(t.endCustomerById(e),r);this.dispatch(`forms/${De.forms.SET_FORM_VALUE}`,{key:"endCustomer",value:n})},async[_7]({rootGetters:t,dispatch:e},{showNotification:r=!0}={}){try{const n=t["forms/getFormByKey"]("endCustomer");let{id:a}=n;return a?await e(Lk,{id:n.id,body:n}):a=await e(Wk,{body:n,showNotification:r}),a}catch(n){return this.handleError(n,{object:"endCustomer",fallbackCode:"endCustomer.submit",action:`${vi}/${_7}`}),null}}},{CLEAR_END_CUSTOMER:_Ae,SET_ENDCUSTOMERS:bAe,DELETE_ENDCUSTOMER:wAe,SET_ENDCUSTOMER_FETCHING:xAe,SET_ENDCUSTOMER_POSTING:kAe}=Us,PAe={[bAe](t,{data:e=[]}){if(typeof e!="object")throw Error("Data must be a company user or an array of company users!");const r=Array.isArray(e)?e:[e],{ids:n,values:a}=Zl(r);Ys(t.data,a),t.ids=eo([...n,...t.ids])},[wAe](t,e){ce.delete(t.data,e);const r=t.ids.indexOf(e);r!==-1&&t.ids.splice(r,1)},[_Ae](t){ce.set(t,"data",{}),ce.set(t,"ids",[])},[xAe](t,e){t.isFetching=e},[kAe](t,e){t.isPosting=e}},TAe={namespaced:!0,state:hAe,getters:{endCustomerById:t=>e=>t.data[e],isPosting:t=>t.isPosting,isFetching:t=>t.isFetching,idList:t=>t.ids,clients:t=>t.data},actions:yAe,mutations:PAe},Yn=Object.create(null);Yn.open="0",Yn.close="1",Yn.ping="2",Yn.pong="3",Yn.message="4",Yn.upgrade="5",Yn.noop="6";const Jm=Object.create(null);Object.keys(Yn).forEach(t=>{Jm[Yn[t]]=t});const MAe={type:"error",data:"parser error"},SAe=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",OAe=typeof ArrayBuffer=="function",EAe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,b7=({type:t,data:e},r,n)=>SAe&&e instanceof Blob?r?n(e):w7(e,n):OAe&&(e instanceof ArrayBuffer||EAe(e))?r?n(e):w7(new Blob([e]),n):n(Yn[t]+(e||"")),w7=(t,e)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];e("b"+n)},r.readAsDataURL(t)},x7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",md=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<x7.length;t++)md[x7.charCodeAt(t)]=t;const DAe=t=>{let e=t.length*.75,r=t.length,n,a=0,o,i,s,u;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),d=new Uint8Array(l);for(n=0;n<r;n+=4)o=md[t.charCodeAt(n)],i=md[t.charCodeAt(n+1)],s=md[t.charCodeAt(n+2)],u=md[t.charCodeAt(n+3)],d[a++]=o<<2|i>>4,d[a++]=(i&15)<<4|s>>2,d[a++]=(s&3)<<6|u&63;return l},CAe=typeof ArrayBuffer=="function",k7=(t,e)=>{if(typeof t!="string")return{type:"message",data:P7(t,e)};const r=t.charAt(0);return r==="b"?{type:"message",data:$Ae(t.substring(1),e)}:Jm[r]?t.length>1?{type:Jm[r],data:t.substring(1)}:{type:Jm[r]}:MAe},$Ae=(t,e)=>{if(CAe){const r=DAe(t);return P7(r,e)}else return{base64:!0,data:t}},P7=(t,e)=>{switch(e){case"blob":return t instanceof ArrayBuffer?new Blob([t]):t;case"arraybuffer":default:return t}},T7=String.fromCharCode(30),AAe=(t,e)=>{const r=t.length,n=new Array(r);let a=0;t.forEach((o,i)=>{b7(o,!1,s=>{n[i]=s,++a===r&&e(n.join(T7))})})},RAe=(t,e)=>{const r=t.split(T7),n=[];for(let a=0;a<r.length;a++){const o=k7(r[a],e);if(n.push(o),o.type==="error")break}return n},M7=4;function jt(t){if(t)return IAe(t)}function IAe(t){for(var e in jt.prototype)t[e]=jt.prototype[e];return t}jt.prototype.on=jt.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},jt.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},jt.prototype.off=jt.prototype.removeListener=jt.prototype.removeAllListeners=jt.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var n,a=0;a<r.length;a++)if(n=r[a],n===e||n.fn===e){r.splice(a,1);break}return r.length===0&&delete this._callbacks["$"+t],this},jt.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,a=r.length;n<a;++n)r[n].apply(this,e)}return this},jt.prototype.emitReserved=jt.prototype.emit,jt.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},jt.prototype.hasListeners=function(t){return!!this.listeners(t).length};const yi=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function S7(t,...e){return e.reduce((r,n)=>(t.hasOwnProperty(n)&&(r[n]=t[n]),r),{})}const NAe=setTimeout,LAe=clearTimeout;function Qm(t,e){e.useNativeTimers?(t.setTimeoutFn=NAe.bind(yi),t.clearTimeoutFn=LAe.bind(yi)):(t.setTimeoutFn=setTimeout.bind(yi),t.clearTimeoutFn=clearTimeout.bind(yi))}const WAe=1.33;function FAe(t){return typeof t=="string"?jAe(t):Math.ceil((t.byteLength||t.size)*WAe)}function jAe(t){let e=0,r=0;for(let n=0,a=t.length;n<a;n++)e=t.charCodeAt(n),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}class VAe extends Error{constructor(e,r,n){super(e),this.description=r,this.context=n,this.type="TransportError"}}class O7 extends jt{constructor(e){super(),this.writable=!1,Qm(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,r,n){return super.emitReserved("error",new VAe(e,r,n)),this}open(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const r=k7(e,this.socket.binaryType);this.onPacket(r)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}}const E7="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),jk=64,zAe={};let D7=0,Zm=0,C7;function $7(t){let e="";do e=E7[t%jk]+e,t=Math.floor(t/jk);while(t>0);return e}function A7(){const t=$7(+new Date);return t!==C7?(D7=0,C7=t):t+"."+$7(D7++)}for(;Zm<jk;Zm++)zAe[E7[Zm]]=Zm;function R7(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}function UAe(t){let e={},r=t.split("&");for(let n=0,a=r.length;n<a;n++){let o=r[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}let I7=!1;try{I7=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const HAe=I7;function N7(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||HAe))return new XMLHttpRequest}catch{}if(!e)try{return new yi[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function qAe(){}const BAe=function(){return new N7({xdomain:!1}).responseType!=null}();class YAe extends O7{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const n=location.protocol==="https:";let a=location.port;a||(a=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||a!==e.port,this.xs=e.secure!==n}const r=e&&e.forceBase64;this.supportsBinary=BAe&&!r}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const r=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};RAe(e,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,AAe(e,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const r=this.opts.secure?"https":"http";let n="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=A7()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(r==="https"&&Number(this.opts.port)!==443||r==="http"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port);const a=R7(e),o=this.opts.hostname.indexOf(":")!==-1;return r+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(a.length?"?"+a:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new Gn(this.uri(),e)}doWrite(e,r){const n=this.request({method:"POST",data:e});n.on("success",r),n.on("error",(a,o)=>{this.onError("xhr post error",a,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=e}}class Gn extends jt{constructor(e,r){super(),Qm(this,r),this.opts=r,this.method=r.method||"GET",this.uri=e,this.async=r.async!==!1,this.data=r.data!==void 0?r.data:null,this.create()}create(){const e=S7(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const r=this.xhr=new N7(e);try{r.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch{}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document<"u"&&(this.index=Gn.requestsCount++,Gn.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=qAe,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Gn.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(Gn.requestsCount=0,Gn.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",L7);else if(typeof addEventListener=="function"){const t="onpagehide"in yi?"pagehide":"unload";addEventListener(t,L7,!1)}}function L7(){for(let t in Gn.requests)Gn.requests.hasOwnProperty(t)&&Gn.requests[t].abort()}const W7=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,r)=>r(e,0))(),ep=yi.WebSocket||yi.MozWebSocket,F7=!0,GAe="arraybuffer",j7=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class KAe extends O7{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),r=this.opts.protocols,n=j7?{}:S7(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=F7&&!j7?r?new ep(e,r):new ep(e):new ep(e,r,n)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType||GAe,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let r=0;r<e.length;r++){const n=e[r],a=r===e.length-1;b7(n,this.supportsBinary,o=>{const i={};try{F7&&this.ws.send(o)}catch{}a&&W7(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const r=this.opts.secure?"wss":"ws";let n="";this.opts.port&&(r==="wss"&&Number(this.opts.port)!==443||r==="ws"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=A7()),this.supportsBinary||(e.b64=1);const a=R7(e),o=this.opts.hostname.indexOf(":")!==-1;return r+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(a.length?"?"+a:"")}check(){return!!ep}}const XAe={websocket:KAe,polling:YAe},JAe=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,QAe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Vk(t){const e=t,r=t.indexOf("["),n=t.indexOf("]");r!=-1&&n!=-1&&(t=t.substring(0,r)+t.substring(r,n).replace(/:/g,";")+t.substring(n,t.length));let a=JAe.exec(t||""),o={},i=14;for(;i--;)o[QAe[i]]=a[i]||"";return r!=-1&&n!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=ZAe(o,o.path),o.queryKey=eRe(o,o.query),o}function ZAe(t,e){const r=/\/{2,9}/g,n=e.replace(r,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function eRe(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,a,o){a&&(r[a]=o)}),r}class _i extends jt{constructor(e,r={}){super(),e&&typeof e=="object"&&(r=e,e=null),e?(e=Vk(e),r.hostname=e.host,r.secure=e.protocol==="https"||e.protocol==="wss",r.port=e.port,e.query&&(r.query=e.query)):r.host&&(r.hostname=Vk(r.host).host),Qm(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=r.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},r),this.opts.path=this.opts.path.replace(/\/$/,"")+"/",typeof this.opts.query=="string"&&(this.opts.query=UAe(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const r=Object.assign({},this.opts.query);r.EIO=M7,r.transport=e,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new XAe[e](n)}open(){let e;if(this.opts.rememberUpgrade&&_i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",r=>this.onClose("transport close",r))}probe(e){let r=this.createTransport(e),n=!1;_i.priorWebsocketSuccess=!1;const a=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;_i.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(d(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=r.name,this.emitReserved("upgradeError",m)}}))};function o(){n||(n=!0,d(),r.close(),r=null)}const i=f=>{const m=new Error("probe error: "+f);m.transport=r.name,o(),this.emitReserved("upgradeError",m)};function s(){i("transport closed")}function u(){i("socket closed")}function l(f){r&&f.name!==r.name&&o()}const d=()=>{r.removeListener("open",a),r.removeListener("error",i),r.removeListener("close",s),this.off("close",u),this.off("upgrading",l)};r.once("open",a),r.once("error",i),r.once("close",s),this.once("close",u),this.once("upgrading",l),r.open()}onOpen(){if(this.readyState="open",_i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade&&this.transport.pause){let e=0;const r=this.upgrades.length;for(;e<r;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const r=new Error("server error");r.code=e.data,this.onError(r);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let n=0;n<this.writeBuffer.length;n++){const a=this.writeBuffer[n].data;if(a&&(r+=FAe(a)),n>0&&r>this.maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}write(e,r,n){return this.sendPacket("message",e,r,n),this}send(e,r,n){return this.sendPacket("message",e,r,n),this}sendPacket(e,r,n,a){if(typeof r=="function"&&(a=r,r=void 0),typeof n=="function"&&(a=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:e,data:r,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),a&&this.once("flush",a),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),e()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){_i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,r){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,r),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const r=[];let n=0;const a=e.length;for(;n<a;n++)~this.transports.indexOf(e[n])&&r.push(e[n]);return r}}_i.protocol=M7;function tRe(t,e="",r){let n=t;r=r||typeof location<"u"&&location,t==null&&(t=r.protocol+"//"+r.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=r.protocol+t:t=r.host+t),/^(https?|wss?):\/\//.test(t)||(typeof r<"u"?t=r.protocol+"//"+t:t="https://"+t),n=Vk(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+e,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}const rRe=typeof ArrayBuffer=="function",nRe=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,V7=Object.prototype.toString,aRe=typeof Blob=="function"||typeof Blob<"u"&&V7.call(Blob)==="[object BlobConstructor]",iRe=typeof File=="function"||typeof File<"u"&&V7.call(File)==="[object FileConstructor]";function zk(t){return rRe&&(t instanceof ArrayBuffer||nRe(t))||aRe&&t instanceof Blob||iRe&&t instanceof File}function tp(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let r=0,n=t.length;r<n;r++)if(tp(t[r]))return!0;return!1}if(zk(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return tp(t.toJSON(),!0);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&tp(t[r]))return!0;return!1}function oRe(t){const e=[],r=t.data,n=t;return n.data=Uk(r,e),n.attachments=e.length,{packet:n,buffers:e}}function Uk(t,e){if(!t)return t;if(zk(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}else if(Array.isArray(t)){const r=new Array(t.length);for(let n=0;n<t.length;n++)r[n]=Uk(t[n],e);return r}else if(typeof t=="object"&&!(t instanceof Date)){const r={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=Uk(t[n],e));return r}return t}function sRe(t,e){return t.data=Hk(t.data,e),t.attachments=void 0,t}function Hk(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=Hk(t[r],e);else if(typeof t=="object")for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=Hk(t[r],e));return t}const uRe=5;var Je;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Je||(Je={}));class lRe{constructor(e){this.replacer=e}encode(e){return(e.type===Je.EVENT||e.type===Je.ACK)&&tp(e)?(e.type=e.type===Je.EVENT?Je.BINARY_EVENT:Je.BINARY_ACK,this.encodeAsBinary(e)):[this.encodeAsString(e)]}encodeAsString(e){let r=""+e.type;return(e.type===Je.BINARY_EVENT||e.type===Je.BINARY_ACK)&&(r+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(r+=e.nsp+","),e.id!=null&&(r+=e.id),e.data!=null&&(r+=JSON.stringify(e.data,this.replacer)),r}encodeAsBinary(e){const r=oRe(e),n=this.encodeAsString(r.packet),a=r.buffers;return a.unshift(n),a}}class qk extends jt{constructor(e){super(),this.reviver=e}add(e){let r;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(e),r.type===Je.BINARY_EVENT||r.type===Je.BINARY_ACK?(this.reconstructor=new dRe(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(zk(e)||e.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(e),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let r=0;const n={type:Number(e.charAt(0))};if(Je[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Je.BINARY_EVENT||n.type===Je.BINARY_ACK){const o=r+1;for(;e.charAt(++r)!=="-"&&r!=e.length;);const i=e.substring(o,r);if(i!=Number(i)||e.charAt(r)!=="-")throw new Error("Illegal attachments");n.attachments=Number(i)}if(e.charAt(r+1)==="/"){const o=r+1;for(;++r&&!(e.charAt(r)===","||r===e.length););n.nsp=e.substring(o,r)}else n.nsp="/";const a=e.charAt(r+1);if(a!==""&&Number(a)==a){const o=r+1;for(;++r;){const i=e.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===e.length)break}n.id=Number(e.substring(o,r+1))}if(e.charAt(++r)){const o=this.tryParse(e.substr(r));if(qk.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,r){switch(e){case Je.CONNECT:return typeof r=="object";case Je.DISCONNECT:return r===void 0;case Je.CONNECT_ERROR:return typeof r=="string"||typeof r=="object";case Je.EVENT:case Je.BINARY_EVENT:return Array.isArray(r)&&r.length>0;case Je.ACK:case Je.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class dRe{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const r=sRe(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cRe=Object.freeze(Object.defineProperty({__proto__:null,protocol:uRe,get PacketType(){return Je},Encoder:lRe,Decoder:qk},Symbol.toStringTag,{value:"Module"}));function hn(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const fRe=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class z7 extends jt{constructor(e,r,n){super(),this.connected=!1,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[hn(e,"open",this.onopen.bind(this)),hn(e,"packet",this.onpacket.bind(this)),hn(e,"error",this.onerror.bind(this)),hn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...r){if(fRe.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');r.unshift(e);const n={type:Je.EVENT,data:r};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const i=this.ids++,s=r.pop();this._registerAckCallback(i,s),n.id=i}const a=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!a||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,r){const n=this.flags.timeout;if(n===void 0){this.acks[e]=r;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);r.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(a),r.apply(this,[null,...o])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this.packet({type:Je.CONNECT,data:e})}):this.packet({type:Je.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,r)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Je.CONNECT:if(e.data&&e.data.sid){const a=e.data.sid;this.onconnect(a)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Je.EVENT:case Je.BINARY_EVENT:this.onevent(e);break;case Je.ACK:case Je.BINARY_ACK:this.onack(e);break;case Je.DISCONNECT:this.ondisconnect();break;case Je.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const r=e.data||[];e.id!=null&&r.push(this.ack(e.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,e)}super.emit.apply(this,e)}ack(e){const r=this;let n=!1;return function(...a){n||(n=!0,r.packet({type:Je.ACK,id:e,data:a}))}}onack(e){const r=this.acks[e.id];typeof r=="function"&&(r.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Je.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(e===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,e.data)}}}function eu(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}eu.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-r:t+r}return Math.min(t,this.max)|0},eu.prototype.reset=function(){this.attempts=0},eu.prototype.setMin=function(t){this.ms=t},eu.prototype.setMax=function(t){this.max=t},eu.prototype.setJitter=function(t){this.jitter=t};class Bk extends jt{constructor(e,r){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(r=e,e=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Qm(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new eu({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=e;const a=r.parser||cRe;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var r;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(r=this.backoff)===null||r===void 0||r.setMin(e),this)}randomizationFactor(e){var r;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(r=this.backoff)===null||r===void 0||r.setJitter(e),this)}reconnectionDelayMax(e){var r;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(r=this.backoff)===null||r===void 0||r.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new _i(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const a=hn(r,"open",function(){n.onopen(),e&&e()}),o=hn(r,"error",i=>{n.cleanup(),n._readyState="closed",this.emitReserved("error",i),e?e(i):n.maybeReconnectOnOpen()});if(this._timeout!==!1){const i=this._timeout;i===0&&a();const s=this.setTimeoutFn(()=>{a(),r.close(),r.emit("error",new Error("timeout"))},i);this.opts.autoUnref&&s.unref(),this.subs.push(function(){clearTimeout(s)})}return this.subs.push(a),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(hn(e,"ping",this.onping.bind(this)),hn(e,"data",this.ondata.bind(this)),hn(e,"error",this.onerror.bind(this)),hn(e,"close",this.onclose.bind(this)),hn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(r){this.onclose("parse error",r)}}ondecoded(e){W7(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,r){let n=this.nsps[e];return n||(n=new z7(this,e,r),this.nsps[e]=n),n}_destroy(e){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(e){const r=this.encoder.encode(e);for(let n=0;n<r.length;n++)this.engine.write(r[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,r){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(a=>{a?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",a)):e.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const pd={};function rp(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const r=tRe(t,e.path||"/socket.io"),n=r.source,a=r.id,o=r.path,i=pd[a]&&o in pd[a].nsps,s=e.forceNew||e["force new connection"]||e.multiplex===!1||i;let u;return s?u=new Bk(n,e):(pd[a]||(pd[a]=new Bk(n,e)),u=pd[a]),r.query&&!e.query&&(e.query=r.queryKey),u.socket(r.path,e)}Object.assign(rp,{Manager:Bk,Socket:z7,io:rp,connect:rp});class mRe{constructor({apiUrl:e,apiPath:r,logger:n=console,getTokenFn:a}){Ut(this,"_socket",null);Ut(this,"_isConnected",!1);Ut(this,"_autoReconnect",!1);Ut(this,"_localAutoReconnect",!1);Ut(this,"_listeners",[]);Ut(this,"_connectionChangedListener",[]);Ut(this,"_retryCount",0);this.rootUrl=e,this.path=r,this.logger=n,this.getTokenFn=a}set autoReconnect(e){this._autoReconnect=!!e}onConnectionChanged(e){this._connectionChangedListener.push(e)}_onConnectionChanged(e){this._connectionChangedListener.forEach(r=>{try{r(e)}catch(n){console.error(n)}})}setConnected(e){e||(this._retryCount=this._retryCount+1),this.logger.debug(`Socket: isConnected changed to ${e}`);const r=this._isConnected!==e;this._isConnected=e,r&&this._onConnectionChanged(e)}_onConnected(){const e=this.getTokenFn();e&&this._socket.emit("authenticate",{token:e})}on(e,r){this._listeners.push({type:e,fn:r}),this._socket&&this._socket.on(e,r)}async connect(){await(r=>new Promise(n=>setTimeout(n,r*2*1e3)))(this._retryCount),this._socket&&(this._localAutoReconnect=!1,this.disconnect(),this._localAutoReconnect=!0),this._socket=rp(this.rootUrl,{path:this.path}),this._socket.on("connect",this._onConnected.bind(this)),this._socket.on("event",r=>this.logger.debug("Socket: Event:",r)),this._listeners.forEach(({type:r,fn:n})=>{this._socket.on(r,n)}),this._socket.on("disconnect",()=>{this.setConnected(!1),this._localAutoReconnect&&this._autoReconnect&&this.connect()}),this._socket.on("authenticated",()=>{this._retryCount=0,this.setConnected(!0)}),this._socket.on("unauthorized",()=>{this.setConnected(!1)})}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const hd=new mRe({rootUrl:Me.api.socket.rootUrl,path:Me.api.socket.path,logger:Tt,getTokenFn:()=>Xe.getItem("token")}),pRe=t=>{hd.onConnectionChanged(e=>{t.commit(`application/${De.application.SET_SOCKET_CONNECTED}`,e)}),hd.on("event",({type:e,action:r,id:n})=>{e==="document"?t.getters["documents2/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`documents2/${De.documents2.DELETE_MANY_DOCUMENTS2}`,n):t.dispatch(Oe.LOAD_DOCUMENT2,{id:n})},1):e==="template"?t.getters["templates/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`templates/${De.templates.DELETE_MANY_TEMPLATES}`,n):t.dispatch(Oe.LOAD_TEMPLATE,{id:n})},1):e==="notification"?setTimeout(()=>{r==="deleted"?t.commit(`notifications/${De.notifications.DELETE_MANY_NOTIFICATIONS}`,n):t.dispatch(Oe.LOAD_NOTIFICATION,{id:n})},1):e==="project"?t.getters["projects/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`projects/${De.projects.DELETE_MANY_PROJECTS}`,n):t.dispatch(Oe.LOAD_PROJECT,{id:n})},1):e==="companyUser"?t.getters["companyUsers/byId"](n)&&setTimeout(()=>{r==="deleted"?t.commit(`companyUsers/${De.DELETE_COMPANY_USER}`,n):t.dispatch(Oe.LOAD_COMPANY_USER,{id:n})},1):e==="companyAccount"?setTimeout(()=>{t.dispatch(Oe.DO_LOAD_CURRENT_COMPANY)},1):e==="companySetting"?setTimeout(()=>{r==="deleted"?t.commit(`settings/${De.settings.CLEAR_SETTINGS}`,{key:"company",name:n}):t.dispatch(Oe.LOAD_SETTINGS_COMPANY)},1):e==="companyUserSetting"?setTimeout(()=>{r==="deleted"?t.commit(`settings/${De.settings.CLEAR_SETTINGS}`,{key:"companyUser",name:n}):t.dispatch(Oe.LOAD_SETTINGS_COMPANYUSER)},1):e==="systemClient"&&r==="refreshToken"&&setTimeout(()=>{Wpe()},1)}),t.subscribe(async e=>{const{type:r,payload:n}=e;r==="application/SET_USER"&&n&&typeof n.userId<"u"&&(hd.autoReconnect=!!n.userId,n.userId?await hd.connect():n.userId===null&&await hd.disconnect())})},U7={projectFiles:"projects",certificates:"certificates",companies:"companies",companyUsers:"companyUsers",projects:"projects",invoices:"invoices",companyReferences:"companyReferences",companyReferenceItems:"companyReferenceItems",files:"files",documents:"documents",timeTracks:"timeTracks",documentTerms:"documentTerms"},H7={projects:De.SET_PROJECTS,invoices:De.invoices.SET_INVOICES,offers:De.SET_OFFERS,companyUsers:De.SET_COMPANY_USERS,companies:De.companies.SET_COMPANIES,events:De.SET_EVENTS,atas:De.SET_ATAS,contracts:De.SET_CONTRACTS,projectNotes:De.SET_PROJECT_NOTES,projectFiles:De.SET_PROJECT_FILES,articles:De.SET_ARTICLES,certificates:De.certificates.SET_CERTIFICATES,companyReferenceItems:De.companyReferenceItems.SET_COMPANY_REFERENCE_ITEMS,companyReferences:De.companyReferences.SET_COMPANY_REFERENCES,files:De.files.UPDATE_MANY_FILES,notifications:De.SET_NOTIFICATIONS,templateMessages:De.SET_TEMPLATE_MESSAGES,timeTracks:De.timeTracks.SET_TIME_TRACKS,documentTerms:De.documentTerms.SET_DOCUMENT_TERMS},hRe={[uo](t,e){const r={includedModules:void 0,excludedModules:void 0,schema:void 0,data:void 0,moduleOpts:{},...e};if(!r.schema||!r.data)throw Error("Unable to normalize data, missing schema or data");const n=Array.isArray(r.data)?r.data:[r.data];let a;typeof r.schema=="string"?{entities:a}=vke(n,r.schema):(console.warn(`Calling normalize with old schema for ${r.schema.schema.key}`),{entities:a}=lz(n,r.schema));let o=Object.keys(a);o=o.filter(i=>(!r.includedModules||r.includedModules.includes(i))&&(!r.excludedModules||!r.excludedModules.includes(i))),o.forEach(i=>{if(!H7[i]){Tt.warn(`setActions: '${i}', does not exist`);return}if(!U7[i]){Tt.warn(`moduleKeys: '${i}', does not exist`);return}const s={doClearOld:!1,...r.moduleOpts[i]||{}};this.commit(`${U7[i]}/${H7[i]}`,{data:Object.keys(a[i]).map(u=>a[i][u]),...s})})}};/**
540
540
  * vue-router v3.0.1
541
541
  * (c) 2017 Evan You
542
542
  * @license MIT