@verdocs/web-sdk 6.9.12 → 6.10.0

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 (113) hide show
  1. package/dist/cjs/verdocs-adopt-signature-dialog_7.cjs.entry.js +1 -1
  2. package/dist/cjs/verdocs-adopt-signature-dialog_7.cjs.entry.js.map +1 -1
  3. package/dist/cjs/verdocs-auth.cjs.entry.js +3 -0
  4. package/dist/cjs/verdocs-auth.cjs.entry.js.map +1 -1
  5. package/dist/cjs/verdocs-contact-picker.cjs.entry.js +422 -115
  6. package/dist/cjs/verdocs-contact-picker.cjs.entry.js.map +1 -1
  7. package/dist/cjs/verdocs-download-dialog_4.cjs.entry.js +6 -5
  8. package/dist/cjs/verdocs-download-dialog_4.cjs.entry.js.map +1 -1
  9. package/dist/cjs/verdocs-preview_6.cjs.entry.js +3 -0
  10. package/dist/cjs/verdocs-preview_6.cjs.entry.js.map +1 -1
  11. package/dist/cjs/verdocs-sign.cjs.entry.js +79 -20
  12. package/dist/cjs/verdocs-sign.cjs.entry.js.map +1 -1
  13. package/dist/collection/components/dialogs/verdocs-download-dialog/verdocs-download-dialog.js +6 -5
  14. package/dist/collection/components/dialogs/verdocs-download-dialog/verdocs-download-dialog.js.map +1 -1
  15. package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +3 -0
  16. package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js.map +1 -1
  17. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +3 -0
  18. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js.map +1 -1
  19. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +79 -20
  20. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js.map +1 -1
  21. package/dist/collection/components/embeds/verdocs-view/verdocs-view.js +1 -1
  22. package/dist/collection/components/embeds/verdocs-view/verdocs-view.js.map +1 -1
  23. package/dist/components/{p-Ce29XBfJ.js → p-CBKrl6B7.js} +2 -2
  24. package/dist/components/{p-Ce29XBfJ.js.map → p-CBKrl6B7.js.map} +1 -1
  25. package/dist/components/p-CPYFXW2q.js +3 -0
  26. package/dist/components/p-CPYFXW2q.js.map +1 -0
  27. package/dist/components/{p-Bpe5Awxh.js → p-CnoHN1S8.js} +2 -2
  28. package/dist/components/p-CnoHN1S8.js.map +1 -0
  29. package/dist/components/{p-BVhOFpVZ.js → p-DfaM_cug.js} +2 -2
  30. package/dist/components/p-DfaM_cug.js.map +1 -0
  31. package/dist/components/verdocs-auth.js +1 -1
  32. package/dist/components/verdocs-auth.js.map +1 -1
  33. package/dist/components/verdocs-build.js +1 -1
  34. package/dist/components/verdocs-contact-picker.js +1 -1
  35. package/dist/components/verdocs-download-dialog.js +1 -1
  36. package/dist/components/verdocs-send.js +1 -1
  37. package/dist/components/verdocs-sign.js +1 -1
  38. package/dist/components/verdocs-sign.js.map +1 -1
  39. package/dist/components/verdocs-view.js +1 -1
  40. package/dist/esm/verdocs-adopt-signature-dialog_7.entry.js +1 -1
  41. package/dist/esm/verdocs-adopt-signature-dialog_7.entry.js.map +1 -1
  42. package/dist/esm/verdocs-auth.entry.js +3 -0
  43. package/dist/esm/verdocs-auth.entry.js.map +1 -1
  44. package/dist/esm/verdocs-contact-picker.entry.js +422 -115
  45. package/dist/esm/verdocs-contact-picker.entry.js.map +1 -1
  46. package/dist/esm/verdocs-download-dialog_4.entry.js +6 -5
  47. package/dist/esm/verdocs-download-dialog_4.entry.js.map +1 -1
  48. package/dist/esm/verdocs-preview_6.entry.js +3 -0
  49. package/dist/esm/verdocs-preview_6.entry.js.map +1 -1
  50. package/dist/esm/verdocs-sign.entry.js +80 -21
  51. package/dist/esm/verdocs-sign.entry.js.map +1 -1
  52. package/dist/esm-es5/verdocs-adopt-signature-dialog_7.entry.js +1 -1
  53. package/dist/esm-es5/verdocs-adopt-signature-dialog_7.entry.js.map +1 -1
  54. package/dist/esm-es5/verdocs-auth.entry.js +1 -1
  55. package/dist/esm-es5/verdocs-auth.entry.js.map +1 -1
  56. package/dist/esm-es5/verdocs-contact-picker.entry.js +2 -2
  57. package/dist/esm-es5/verdocs-contact-picker.entry.js.map +1 -1
  58. package/dist/esm-es5/verdocs-download-dialog_4.entry.js +1 -1
  59. package/dist/esm-es5/verdocs-download-dialog_4.entry.js.map +1 -1
  60. package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
  61. package/dist/esm-es5/verdocs-preview_6.entry.js.map +1 -1
  62. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  63. package/dist/esm-es5/verdocs-sign.entry.js.map +1 -1
  64. package/dist/types/components/embeds/verdocs-sign/verdocs-sign.d.ts +5 -0
  65. package/dist/verdocs-web-sdk/p-11c3e5bb.entry.js +2 -0
  66. package/dist/verdocs-web-sdk/p-11c3e5bb.entry.js.map +1 -0
  67. package/dist/verdocs-web-sdk/p-16d655d4.system.entry.js +2 -0
  68. package/dist/verdocs-web-sdk/p-16d655d4.system.entry.js.map +1 -0
  69. package/dist/verdocs-web-sdk/p-1ce27c81.system.entry.js +4 -0
  70. package/dist/verdocs-web-sdk/p-1ce27c81.system.entry.js.map +1 -0
  71. package/dist/verdocs-web-sdk/p-2d72560a.entry.js +2 -0
  72. package/dist/verdocs-web-sdk/p-2d72560a.entry.js.map +1 -0
  73. package/dist/verdocs-web-sdk/p-33cfc977.system.entry.js +2 -0
  74. package/dist/verdocs-web-sdk/p-33cfc977.system.entry.js.map +1 -0
  75. package/dist/verdocs-web-sdk/p-43ee0267.entry.js +2 -0
  76. package/dist/verdocs-web-sdk/p-43ee0267.entry.js.map +1 -0
  77. package/dist/verdocs-web-sdk/p-4e84a5b6.entry.js +3 -0
  78. package/dist/verdocs-web-sdk/p-4e84a5b6.entry.js.map +1 -0
  79. package/dist/verdocs-web-sdk/p-BdZ5Ghsa.system.js +1 -1
  80. package/dist/verdocs-web-sdk/{p-9756028f.entry.js → p-d0e8419b.entry.js} +2 -2
  81. package/dist/verdocs-web-sdk/p-d0e8419b.entry.js.map +1 -0
  82. package/dist/verdocs-web-sdk/{p-64034b55.system.entry.js → p-d60cfa3e.system.entry.js} +2 -2
  83. package/dist/verdocs-web-sdk/{p-64034b55.system.entry.js.map → p-d60cfa3e.system.entry.js.map} +1 -1
  84. package/dist/verdocs-web-sdk/p-e608d2bc.system.entry.js +2 -0
  85. package/dist/verdocs-web-sdk/p-e608d2bc.system.entry.js.map +1 -0
  86. package/dist/verdocs-web-sdk/{p-6abf8f8f.entry.js → p-e95723ac.entry.js} +2 -2
  87. package/dist/verdocs-web-sdk/{p-6abf8f8f.entry.js.map → p-e95723ac.entry.js.map} +1 -1
  88. package/dist/verdocs-web-sdk/{p-f85f8560.system.entry.js → p-edab1fed.system.entry.js} +2 -2
  89. package/dist/verdocs-web-sdk/p-edab1fed.system.entry.js.map +1 -0
  90. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  91. package/package.json +2 -2
  92. package/dist/components/p-BVhOFpVZ.js.map +0 -1
  93. package/dist/components/p-Bpe5Awxh.js.map +0 -1
  94. package/dist/components/p-DeQsR41s.js +0 -3
  95. package/dist/components/p-DeQsR41s.js.map +0 -1
  96. package/dist/verdocs-web-sdk/p-0240a6e1.system.entry.js +0 -2
  97. package/dist/verdocs-web-sdk/p-0240a6e1.system.entry.js.map +0 -1
  98. package/dist/verdocs-web-sdk/p-12676649.entry.js +0 -2
  99. package/dist/verdocs-web-sdk/p-12676649.entry.js.map +0 -1
  100. package/dist/verdocs-web-sdk/p-1a6869c9.system.entry.js +0 -2
  101. package/dist/verdocs-web-sdk/p-1a6869c9.system.entry.js.map +0 -1
  102. package/dist/verdocs-web-sdk/p-3a542ed0.system.entry.js +0 -4
  103. package/dist/verdocs-web-sdk/p-3a542ed0.system.entry.js.map +0 -1
  104. package/dist/verdocs-web-sdk/p-3f5ad836.system.entry.js +0 -2
  105. package/dist/verdocs-web-sdk/p-3f5ad836.system.entry.js.map +0 -1
  106. package/dist/verdocs-web-sdk/p-9756028f.entry.js.map +0 -1
  107. package/dist/verdocs-web-sdk/p-9c6cca6e.entry.js +0 -2
  108. package/dist/verdocs-web-sdk/p-9c6cca6e.entry.js.map +0 -1
  109. package/dist/verdocs-web-sdk/p-ae4290c6.entry.js +0 -3
  110. package/dist/verdocs-web-sdk/p-ae4290c6.entry.js.map +0 -1
  111. package/dist/verdocs-web-sdk/p-c89d74b2.entry.js +0 -2
  112. package/dist/verdocs-web-sdk/p-c89d74b2.entry.js.map +0 -1
  113. package/dist/verdocs-web-sdk/p-f85f8560.system.entry.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{p as e,H as s,c as t,h as i,d as o,t as n}from"./p-yZBlG3YQ.js";import{getTemplate as l,getOrganizationContacts as r,isValidEmail as d,createEnvelope as a,formatFullName as c,getRGBA as p}from"@verdocs/js-sdk";import{D as h}from"./p-C_Xku1v2.js";import{V as v}from"./p-D97GxsI-.js";import{S as m}from"./p-C1sRVZWv.js";import{S as f}from"./p-C7hFgM52.js";import{d as u}from"./p-Bdf8pPWm.js";import{d as x}from"./p-REnrt0JM.js";import{d as b}from"./p-CyDWJAOZ.js";import{d as g}from"./p-DeQsR41s.js";import{d as w}from"./p-wUsR0Dpa.js";import{d as k}from"./p-B-_kYJtC.js";import{d as E}from"./p-DQTI8vRX.js";import{d as S}from"./p-BXQO5Vza.js";const C=e=>((e===null||e===void 0?void 0:e.roles)||[]).map((e=>e.name));const y=(e,s)=>Math.max(C(e).findIndex((e=>e===s)),0);const D=()=>`verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}verdocs-send .buttons .error-message{width:100%;color:#cc0000;font-size:13px;margin-bottom:10px}verdocs-send verdocs-contact-picker{left:0;top:41px;z-index:10;position:absolute;border:1px solid #dddddd;-webkit-box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1);box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1)}`;const z='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></svg>';const N='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>';const j='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>';const _='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>';const L=e(class e extends s{constructor(e){super();if(e!==false){this.__registerHost()}this.beforeSend=t(this,"beforeSend");this.send=t(this,"send");this.exit=t(this,"exit");this.sdkError=t(this,"sdkError");this.searchContacts=t(this,"searchContacts");this.templateListenerId=null;this.endpoint=h;this.templateId=null;this.environment="";this.showCancel=true;this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`;this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();f.subscribe("templates",this.templateId,(()=>l(this.endpoint,this.templateId)),true,(e=>{console.log("[SEND] Got new template",e);this.template=e;this.loading=false;this.rolesCompleted={};this.recomputeRolesCompleted()}))}unlistenToTemplate(){if(this.templateListenerId){f.store.delListener(this.templateListenerId);this.templateListenerId=null}}async reset(){this.rolesCompleted={}}onTemplateIdChanged(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()}async componentWillLoad(){var e,s,t;try{this.endpoint.onSessionChanged(((e,s,t)=>{if(!t){return}const i={id:t.id,first_name:t.first_name,last_name:t.last_name,email:t.email,phone:t.phone};if(t){this.sessionContacts=[i];r(this.endpoint).then((e=>{console.log("[SEND] Got contacts",e);this.sessionContacts=[...e,i]})).catch((e=>{console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return}if(!this.templateId){console.log(`[SEND] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(i){console.log("[SEND] Error with send session",i);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new m(i.message,(s=i.response)===null||s===void 0?void 0:s.status,(t=i.response)===null||t===void 0?void 0:t.data))}}recomputeRolesCompleted(){var e;this.rolesCompleted={};const s={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{const t=e.sequence;s[t]||(s[t]=[]);const i=`r-${t}-${s[t].length}`;s[t].push({...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name});if(e.first_name&&d(e.email)){this.rolesCompleted[i]={...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name}}}))}getSequenceNumbers(){var e;const s={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{s[e.sequence]=true}));return Object.keys(s).map((e=>+e)).sort(((e,s)=>e-s))}getRolesAtLevel(e){var s;const t=(((s=this.template)===null||s===void 0?void 0:s.roles)||[]).filter((s=>s.sequence===e)).map(((s,t)=>({...s,id:`r-${e}-${t}`,role_name:s.name,first_name:s.first_name,last_name:s.last_name})));return t}getLevelIcon(e){if(e==="start"){return i("div",{class:"level-icon",innerHTML:N})}else if(e==="end"){return i("div",{class:"level-icon",innerHTML:_})}else{return i("div",{class:"level-icon",innerHTML:j})}}handleSelectContact(e,s){e.preventDefault();this.rolesCompleted[s.id]={...s,...e.detail};this.showPickerForId=""}handleClickRole(e,s){e.stopPropagation();this.showPickerForId=s.id}handleSend(e){var s;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;const t={template_id:this.templateId,name:((s=this.template)===null||s===void 0?void 0:s.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted)};const i=this.beforeSend.emit({...t,name:t.name,template:this.template});if(i.defaultPrevented){console.log("[SEND] Send cancelled by parent",t);this.sending=false;return}console.log("[SEND] Creating envelope",t);a(this.endpoint,t).then((e=>{var s;console.log("[SEND] Send envelope",e);this.reset().catch((e=>console.log("Unknown Error",e)));this.sending=false;(s=this.send)===null||s===void 0?void 0:s.emit({...t,name:t.name,envelope_id:e.id,envelope:e})})).catch((e=>{var s,t,i;console.log("[SEND] Send error",e);v(((t=(s=e.response)===null||s===void 0?void 0:s.data)===null||t===void 0?void 0:t.error)||"Error creating envelope, please try again later.");this.sending=false;(i=this.sdkError)===null||i===void 0?void 0:i.emit(e)}))}handleCancel(e){var s;e.stopPropagation();(s=this.exit)===null||s===void 0?void 0:s.emit()}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,{style:{display:"flex"}},i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const s=this.getSequenceNumbers();const t=Object.values(this.rolesCompleted).filter((e=>d(e.email)&&e.first_name&&e.last_name));const n=t.length>=C(this.template).length;const l=t.map((e=>e.email.toLowerCase()));const r=new Set(l).size<l.length;return i(o,{class:{sendable:(e=this.template)===null||e===void 0?void 0:e.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:`level level-start`},this.getLevelIcon("start"),i("div",{class:"complete"},"Send Envelope")),s.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon("sequence"),this.getRolesAtLevel(e).map((e=>{var s,o,n;const l=!e.email||!e.first_name||!e.last_name;const r=((s=this.rolesCompleted[e.id])===null||s===void 0?void 0:s.first_name)?c(this.rolesCompleted[e.id]):l?e.role_name:c(e);const d=`verdocs-send-recipient-${e.role_name}`;const a=y(this.template,e.role_name);const h=p(a);const v=t.findIndex((s=>s.role_name===e.role_name))>-1;const m={backgroundColor:h,border:v?"2px solid #55bc81":"2px solid #dddddd"};return l?i("div",{class:"recipient","data-ri":a,"data-rn":e.role_name,style:m,onClick:s=>this.handleClickRole(s,e),id:d},r,i("div",{class:"icon",innerHTML:z}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:d,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:s=>this.handleSelectContact(s,e),contactSuggestions:this.sessionContacts,templateRole:(o=this.rolesCompleted[e.id])!==null&&o!==void 0?o:e,onSearchContacts:e=>{var s;return(s=this.searchContacts)===null||s===void 0?void 0:s.emit(e.detail)}}))):i("div",{class:"recipient","data-ri":a,"data-rn":e.role_name,style:m,onClick:s=>this.handleClickRole(s,e),id:d},r,i("div",{class:"icon",innerHTML:z}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:d,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:s=>this.handleSelectContact(s,e),contactSuggestions:this.sessionContacts,templateRole:(n=this.rolesCompleted[e.id])!==null&&n!==void 0?n:e,onSearchContacts:e=>{var s;return(s=this.searchContacts)===null||s===void 0?void 0:s.emit(e.detail)}})))}))))),i("div",{class:`level level-done`},this.getLevelIcon("end"),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},r&&i("div",{class:"error-message"},"Recipients cannot share the same email."),this.showCancel&&i("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:e=>this.handleCancel(e),disabled:this.sending}),i("verdocs-button",{label:"Send",size:"small",disabled:!n||this.sending||r,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}static get watchers(){return{templateId:[{onTemplateIdChanged:0}]}}static get style(){return D()}},[0,"verdocs-send",{endpoint:[16],templateId:[513,"template-id"],environment:[1],showCancel:[4,"show-cancel"],containerId:[32],showPickerForId:[32],sessionContacts:[32],sending:[32],rolesCompleted:[32],loading:[32],template:[32],reset:[64]},undefined,{templateId:[{onTemplateIdChanged:0}]}]);function M(){if(typeof customElements==="undefined"){return}const e=["verdocs-send","verdocs-button","verdocs-checkbox","verdocs-component-error","verdocs-contact-picker","verdocs-flag","verdocs-loader","verdocs-portal","verdocs-spinner"];e.forEach((e=>{switch(e){case"verdocs-send":if(!customElements.get(n(e))){customElements.define(n(e),L)}break;case"verdocs-button":if(!customElements.get(n(e))){u()}break;case"verdocs-checkbox":if(!customElements.get(n(e))){x()}break;case"verdocs-component-error":if(!customElements.get(n(e))){b()}break;case"verdocs-contact-picker":if(!customElements.get(n(e))){g()}break;case"verdocs-flag":if(!customElements.get(n(e))){w()}break;case"verdocs-loader":if(!customElements.get(n(e))){k()}break;case"verdocs-portal":if(!customElements.get(n(e))){E()}break;case"verdocs-spinner":if(!customElements.get(n(e))){S()}break}}))}export{L as V,M as d};
2
- //# sourceMappingURL=p-Bpe5Awxh.js.map
1
+ import{p as e,H as s,c as t,h as i,d as o,t as n}from"./p-yZBlG3YQ.js";import{getTemplate as l,getOrganizationContacts as r,isValidEmail as d,createEnvelope as a,formatFullName as c,getRGBA as p}from"@verdocs/js-sdk";import{D as h}from"./p-C_Xku1v2.js";import{V as v}from"./p-D97GxsI-.js";import{S as m}from"./p-C1sRVZWv.js";import{S as f}from"./p-C7hFgM52.js";import{d as u}from"./p-Bdf8pPWm.js";import{d as x}from"./p-REnrt0JM.js";import{d as b}from"./p-CyDWJAOZ.js";import{d as g}from"./p-CPYFXW2q.js";import{d as w}from"./p-wUsR0Dpa.js";import{d as k}from"./p-B-_kYJtC.js";import{d as E}from"./p-DQTI8vRX.js";import{d as S}from"./p-BXQO5Vza.js";const C=e=>((e===null||e===void 0?void 0:e.roles)||[]).map((e=>e.name));const y=(e,s)=>Math.max(C(e).findIndex((e=>e===s)),0);const z=()=>`verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}verdocs-send .buttons .error-message{width:100%;color:#cc0000;font-size:13px;margin-bottom:10px}verdocs-send verdocs-contact-picker{left:0;top:41px;z-index:10;position:absolute;border:1px solid #dddddd;-webkit-box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1);box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1)}`;const D='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></svg>';const N='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>';const j='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>';const _='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>';const I=e(class e extends s{constructor(e){super();if(e!==false){this.__registerHost()}this.beforeSend=t(this,"beforeSend");this.send=t(this,"send");this.exit=t(this,"exit");this.sdkError=t(this,"sdkError");this.searchContacts=t(this,"searchContacts");this.templateListenerId=null;this.endpoint=h;this.templateId=null;this.environment="";this.showCancel=true;this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`;this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();f.subscribe("templates",this.templateId,(()=>l(this.endpoint,this.templateId)),true,(e=>{console.log("[SEND] Got new template",e);this.template=e;this.loading=false;this.rolesCompleted={};this.recomputeRolesCompleted()}))}unlistenToTemplate(){if(this.templateListenerId){f.store.delListener(this.templateListenerId);this.templateListenerId=null}}async reset(){this.rolesCompleted={}}onTemplateIdChanged(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()}async componentWillLoad(){var e,s,t;try{this.endpoint.onSessionChanged(((e,s,t)=>{if(!t){return}const i={id:t.id,first_name:t.first_name,last_name:t.last_name,email:t.email,phone:t.phone};if(t){this.sessionContacts=[i];r(this.endpoint).then((e=>{console.log("[SEND] Got contacts",e);this.sessionContacts=[...e,i]})).catch((e=>{console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return}if(!this.templateId){console.log(`[SEND] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(i){console.log("[SEND] Error with send session",i);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new m(i.message,(s=i.response)===null||s===void 0?void 0:s.status,(t=i.response)===null||t===void 0?void 0:t.data))}}recomputeRolesCompleted(){var e;this.rolesCompleted={};const s={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{const t=e.sequence;s[t]||(s[t]=[]);const i=`r-${t}-${s[t].length}`;s[t].push({...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name});if(e.first_name&&d(e.email)){this.rolesCompleted[i]={...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name}}}))}getSequenceNumbers(){var e;const s={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{s[e.sequence]=true}));return Object.keys(s).map((e=>+e)).sort(((e,s)=>e-s))}getRolesAtLevel(e){var s;const t=(((s=this.template)===null||s===void 0?void 0:s.roles)||[]).filter((s=>s.sequence===e)).map(((s,t)=>({...s,id:`r-${e}-${t}`,role_name:s.name,first_name:s.first_name,last_name:s.last_name})));return t}getLevelIcon(e){if(e==="start"){return i("div",{class:"level-icon",innerHTML:N})}else if(e==="end"){return i("div",{class:"level-icon",innerHTML:_})}else{return i("div",{class:"level-icon",innerHTML:j})}}handleSelectContact(e,s){e.preventDefault();this.rolesCompleted[s.id]={...s,...e.detail};this.showPickerForId=""}handleClickRole(e,s){e.stopPropagation();this.showPickerForId=s.id}handleSend(e){var s;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;const t=Intl.DateTimeFormat().resolvedOptions();const i={template_id:this.templateId,name:((s=this.template)===null||s===void 0?void 0:s.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),timezone:t.timeZone,locale:t.locale};const o=this.beforeSend.emit({...i,name:i.name,template:this.template});if(o.defaultPrevented){console.log("[SEND] Send cancelled by parent",i);this.sending=false;return}console.log("[SEND] Creating envelope",i);a(this.endpoint,i).then((e=>{var s;console.log("[SEND] Send envelope",e);this.reset().catch((e=>console.log("Unknown Error",e)));this.sending=false;(s=this.send)===null||s===void 0?void 0:s.emit({...i,name:i.name,envelope_id:e.id,envelope:e})})).catch((e=>{var s,t,i;console.log("[SEND] Send error",e);v(((t=(s=e.response)===null||s===void 0?void 0:s.data)===null||t===void 0?void 0:t.error)||"Error creating envelope, please try again later.");this.sending=false;(i=this.sdkError)===null||i===void 0?void 0:i.emit(e)}))}handleCancel(e){var s;e.stopPropagation();(s=this.exit)===null||s===void 0?void 0:s.emit()}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,{style:{display:"flex"}},i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const s=this.getSequenceNumbers();const t=Object.values(this.rolesCompleted).filter((e=>d(e.email)&&e.first_name&&e.last_name));const n=t.length>=C(this.template).length;const l=t.map((e=>e.email.toLowerCase()));const r=new Set(l).size<l.length;return i(o,{class:{sendable:(e=this.template)===null||e===void 0?void 0:e.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:`level level-start`},this.getLevelIcon("start"),i("div",{class:"complete"},"Send Envelope")),s.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon("sequence"),this.getRolesAtLevel(e).map((e=>{var s,o,n;const l=!e.email||!e.first_name||!e.last_name;const r=((s=this.rolesCompleted[e.id])===null||s===void 0?void 0:s.first_name)?c(this.rolesCompleted[e.id]):l?e.role_name:c(e);const d=`verdocs-send-recipient-${e.role_name}`;const a=y(this.template,e.role_name);const h=p(a);const v=t.findIndex((s=>s.role_name===e.role_name))>-1;const m={backgroundColor:h,border:v?"2px solid #55bc81":"2px solid #dddddd"};return l?i("div",{class:"recipient","data-ri":a,"data-rn":e.role_name,style:m,onClick:s=>this.handleClickRole(s,e),id:d},r,i("div",{class:"icon",innerHTML:D}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:d,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:s=>this.handleSelectContact(s,e),contactSuggestions:this.sessionContacts,templateRole:(o=this.rolesCompleted[e.id])!==null&&o!==void 0?o:e,onSearchContacts:e=>{var s;return(s=this.searchContacts)===null||s===void 0?void 0:s.emit(e.detail)}}))):i("div",{class:"recipient","data-ri":a,"data-rn":e.role_name,style:m,onClick:s=>this.handleClickRole(s,e),id:d},r,i("div",{class:"icon",innerHTML:D}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:d,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:s=>this.handleSelectContact(s,e),contactSuggestions:this.sessionContacts,templateRole:(n=this.rolesCompleted[e.id])!==null&&n!==void 0?n:e,onSearchContacts:e=>{var s;return(s=this.searchContacts)===null||s===void 0?void 0:s.emit(e.detail)}})))}))))),i("div",{class:`level level-done`},this.getLevelIcon("end"),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},r&&i("div",{class:"error-message"},"Recipients cannot share the same email."),this.showCancel&&i("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:e=>this.handleCancel(e),disabled:this.sending}),i("verdocs-button",{label:"Send",size:"small",disabled:!n||this.sending||r,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}static get watchers(){return{templateId:[{onTemplateIdChanged:0}]}}static get style(){return z()}},[0,"verdocs-send",{endpoint:[16],templateId:[513,"template-id"],environment:[1],showCancel:[4,"show-cancel"],containerId:[32],showPickerForId:[32],sessionContacts:[32],sending:[32],rolesCompleted:[32],loading:[32],template:[32],reset:[64]},undefined,{templateId:[{onTemplateIdChanged:0}]}]);function L(){if(typeof customElements==="undefined"){return}const e=["verdocs-send","verdocs-button","verdocs-checkbox","verdocs-component-error","verdocs-contact-picker","verdocs-flag","verdocs-loader","verdocs-portal","verdocs-spinner"];e.forEach((e=>{switch(e){case"verdocs-send":if(!customElements.get(n(e))){customElements.define(n(e),I)}break;case"verdocs-button":if(!customElements.get(n(e))){u()}break;case"verdocs-checkbox":if(!customElements.get(n(e))){x()}break;case"verdocs-component-error":if(!customElements.get(n(e))){b()}break;case"verdocs-contact-picker":if(!customElements.get(n(e))){g()}break;case"verdocs-flag":if(!customElements.get(n(e))){w()}break;case"verdocs-loader":if(!customElements.get(n(e))){k()}break;case"verdocs-portal":if(!customElements.get(n(e))){E()}break;case"verdocs-spinner":if(!customElements.get(n(e))){S()}break}}))}export{I as V,L as d};
2
+ //# sourceMappingURL=p-CnoHN1S8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getRoleNames","template","roles","map","role","name","getRoleIndex","role_name","Math","max","findIndex","verdocsSendCss","editIcon","startIcon","stepIcon","doneIcon","VerdocsSend","__stencil_proxyCustomElement","HTMLElement","constructor","registerHost","this","templateListenerId","endpoint","DefaultEndpoint","templateId","environment","showCancel","containerId","random","toString","substring","showPickerForId","sessionContacts","sending","rolesCompleted","loading","disconnectedCallback","unlistenToTemplate","listenToTemplate","console","log","Store","subscribe","getTemplate","recomputeRolesCompleted","store","delListener","reset","onTemplateIdChanged","newTemplateId","componentWillLoad","onSessionChanged","_endpoint","_session","profile","me","id","first_name","last_name","email","phone","getOrganizationContacts","then","contacts","catch","e","loadSession","session","_a","sdkError","emit","SDKError","message","_b","response","status","_c","data","rolesAtLevel","forEach","level","sequence","length","push","isValidEmail","getSequenceNumbers","sequences","Object","keys","s","sort","a","b","getRolesAtLevel","filter","index","getLevelIcon","h","class","innerHTML","handleSelectContact","preventDefault","detail","handleClickRole","stopPropagation","handleSend","localeData","Intl","DateTimeFormat","resolvedOptions","details","template_id","initial_reminder","followup_reminders","recipients","values","timezone","timeZone","locale","beforeSendResult","beforeSend","defaultPrevented","createEnvelope","r","send","envelope_id","envelope","VerdocsToast","error","handleCancel","exit","render","Host","style","display","levels","rolesAssigned","recipient","allRolesAssigned","assignedEmails","toLowerCase","hasDuplicateEmails","Set","size","sendable","is_sendable","unknown","roleName","formatFullName","elId","roleIndex","rgba","getRGBA","completed","backgroundColor","border","onClick","anchor","onClickAway","onExit","onNext","contactSuggestions","templateRole","onSearchContacts","searchContacts","label","variant","disabled"],"sources":["src/utils/Templates.ts","src/components/embeds/verdocs-send/verdocs-send.scss?tag=verdocs-send","src/components/embeds/verdocs-send/verdocs-send.tsx"],"sourcesContent":["import {ITemplate} from '@verdocs/js-sdk';\n\nexport const getRoleNames = (template: ITemplate | null) => (template?.roles || []).map(role => role.name);\n\nexport const getRoleIndex = (template: ITemplate | null, role_name: string) =>\n Math.max(\n getRoleNames(template).findIndex(name => name === role_name),\n 0,\n );\n","@import '../../../theme.scss';\n\nverdocs-send {\n padding: 10px;\n position: relative;\n background: #ffffff;\n flex-direction: column;\n font-family: $verdocs-primary-font;\n\n &.sendable {\n display: flex;\n }\n\n .recipients {\n position: relative;\n }\n\n // To avoid the need to compute things like heights, this layer is simply displayed \"on top\" of all the level rows. Its\n // background obscures the horizontal lines.\n .left-line {\n top: 32px;\n left: 20px;\n z-index: 1;\n width: 12px;\n bottom: 30px;\n position: absolute;\n background: #ffffff;\n border-left: 3px dotted #9b9b9b;\n }\n\n .level {\n display: flex;\n column-gap: 10px;\n margin-left: 50px;\n position: relative;\n flex-direction: row;\n padding: 8px 0 4px 0;\n border-bottom: 1px solid #97979744;\n\n .level-icon {\n top: 14px;\n z-index: 2;\n left: -40px;\n width: 24px;\n height: 24px;\n position: absolute;\n background: #ffffff;\n\n svg {\n fill: #00000089;\n }\n }\n\n .recipient {\n height: 30px;\n display: flex;\n flex: 0 0 30px;\n color: #000000;\n cursor: pointer;\n font-size: 14px;\n align-items: center;\n border-radius: 30px;\n flex-direction: row;\n background: #dddddd;\n white-space: nowrap;\n border: 2px solid #dddddd;\n padding: 2px 10px 2px 14px;\n\n .icon {\n width: 22px;\n height: 22px;\n flex: 0 0 22px;\n margin: 0 0 0 10px;\n\n svg {\n width: 22px;\n height: 22px;\n fill: #333333;\n outline: none;\n }\n }\n }\n\n .complete {\n flex: 1;\n height: 30px;\n display: flex;\n color: #000000;\n font-size: 14px;\n align-items: center;\n flex-direction: row;\n padding: 3px 10px 3px 2px;\n }\n }\n\n .buttons {\n display: flex;\n margin-top: 10px;\n column-gap: 15px;\n flex-wrap: wrap;\n flex-direction: row;\n align-items: center;\n\n .error-message {\n width: 100%;\n color: #cc0000;\n font-size: 13px;\n margin-bottom: 10px;\n }\n }\n\n verdocs-contact-picker {\n left: 0;\n top: 41px;\n z-index: 10;\n position: absolute;\n border: 1px solid #dddddd;\n box-shadow: 0 0 6px 3px rgb(0 0 0 / 10%);\n }\n}\n","import {Component, Prop, State, h, Event, EventEmitter, Host, Method, Watch} from '@stencil/core';\nimport {createEnvelope, formatFullName, getTemplate, getOrganizationContacts, getRGBA, isValidEmail, VerdocsEndpoint} from '@verdocs/js-sdk';\nimport type {ICreateEnvelopeFromTemplateRequest, ICreateEnvelopeRecipientFromTemplate, IEnvelope, IRecipient, ITemplate} from '@verdocs/js-sdk';\nimport {IContactSearchEvent} from '../../envelopes/verdocs-contact-picker/verdocs-contact-picker';\nimport {getRoleIndex, getRoleNames} from '../../../utils/Templates';\nimport {DefaultEndpoint} from '../../../utils/Environment';\nimport {VerdocsToast} from '../../../utils/Toast';\nimport {SDKError} from '../../../utils/errors';\nimport {Store} from '../../../utils/Datastore';\n\nconst editIcon =\n '<svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" tabindex=\"-1\"><path d=\"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z\"></path></svg>';\n\nconst startIcon =\n '<svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" tabindex=\"-1\"><path d=\"M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z\"></path></svg>';\n\nconst stepIcon =\n '<svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" tabindex=\"-1\"><path d=\"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z\"></path></svg>';\n\nconst doneIcon =\n '<svg focusable=\"false\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" tabindex=\"-1\"><path d=\"m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z\"></path></svg>';\n\n/**\n * Display a form to send a template to one or more recipients in an envelope for signing.\n * Host applications should ensure the template is \"sendable\" before displaying this component.\n * To be sendable, a template must have at least one document attached, at least one participant\n * defined, and at least one field assigned to every \"signer\" participant. This component will\n * hide itself if the template is not sendable.\n *\n * ```ts\n * <verdocs-send\n * templateId={TEMPLATE_ID}\n * onBeforeSend={({ detail })) => { console.log('Sending... Show a spinner...', detail) }\n * onSend={({ detail }) => { console.log('Sent! Hide the spinner...', detail) }\n * onExit={({ detail }) => { console.log('Send cancelled.', detail) }\n * onSdkError={({ detail }) => { console.log('SDK error', detail) }\n * />\n * ```\n */\n@Component({\n tag: 'verdocs-send',\n styleUrl: 'verdocs-send.scss',\n shadow: false,\n})\nexport class VerdocsSend {\n private templateListenerId = null;\n\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = DefaultEndpoint;\n\n /**\n * The ID of the template to create the document from.\n */\n @Prop({reflect: true}) templateId: string | null = null;\n\n /**\n * The environment the control is being called from, e.g. 'web'. This has an impact on how certain\n * operations such as email communications are handled to ensure users receive the correct URLs for\n * their invitations. Setting this to unknown values may produce unexpected/incorrect behaviors.\n * If environment is not known, do this set this property.\n */\n @Prop() environment: string = '';\n\n /**\n * Whether to show the cancel button. It may be useful to disable this in environments where\n * the embed is shown in a non-wizard flow with its own navigation for the user to exit.\n */\n @Prop() showCancel = true;\n\n /**\n * The user is sending an envelope the form and clicked send.\n */\n @Event({composed: true}) beforeSend: EventEmitter<{recipients: ICreateEnvelopeRecipientFromTemplate[]; name: string; template_id: string; template: ITemplate}>;\n\n /**\n * The user completed the form and clicked send.\n */\n @Event({composed: true}) send: EventEmitter<{recipients: ICreateEnvelopeRecipientFromTemplate[]; name: string; template_id: string; envelope_id: string; envelope: IEnvelope}>;\n\n /**\n * Event fired when the step is cancelled. This is called exit to avoid conflicts with the JS-reserved \"cancel\" event name.\n */\n @Event({composed: true}) exit: EventEmitter;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n /**\n * Event fired when the user enters text in a search field. The parent application may use this to update\n * the `contactSuggestions` property.\n */\n @Event({composed: true}) searchContacts: EventEmitter<IContactSearchEvent>;\n\n @State() containerId = `verdocs-send-${Math.random().toString(36).substring(2, 11)}`;\n @State() showPickerForId = '';\n @State() sessionContacts = [];\n @State() sending = false;\n @State() rolesCompleted: Record<string, Partial<IRecipient>> = {};\n\n @State() loading = true;\n @State() template: ITemplate | null = null;\n\n disconnectedCallback() {\n this.unlistenToTemplate();\n }\n\n async listenToTemplate() {\n console.log('[SEND] Loading template', this.templateId);\n this.unlistenToTemplate();\n Store.subscribe(\n 'templates',\n this.templateId,\n () => getTemplate(this.endpoint, this.templateId),\n true,\n (template: ITemplate) => {\n console.log('[SEND] Got new template', template);\n this.template = template;\n this.loading = false;\n this.rolesCompleted = {};\n this.recomputeRolesCompleted();\n },\n );\n }\n\n unlistenToTemplate() {\n if (this.templateListenerId) {\n Store.store.delListener(this.templateListenerId);\n this.templateListenerId = null;\n }\n }\n\n @Method() async reset() {\n this.rolesCompleted = {};\n }\n\n @Watch('templateId')\n onTemplateIdChanged(newTemplateId: string) {\n console.log('[SEND] Template ID changed', newTemplateId);\n this.listenToTemplate();\n }\n\n async componentWillLoad() {\n try {\n this.endpoint.onSessionChanged((_endpoint, _session, profile) => {\n if (!profile) {\n return;\n }\n\n const me = {\n id: profile.id,\n first_name: profile.first_name,\n last_name: profile.last_name,\n email: profile.email,\n phone: profile.phone,\n };\n\n if (profile) {\n this.sessionContacts = [me];\n\n getOrganizationContacts(this.endpoint)\n .then(contacts => {\n console.log('[SEND] Got contacts', contacts);\n this.sessionContacts = [...contacts, me];\n })\n .catch(e => {\n console.log('[SEND] Error getting contacts', e);\n });\n }\n });\n\n this.endpoint.loadSession();\n\n if (!this.endpoint.session) {\n console.log('[SEND] Unable to start Send operation, must be authenticated');\n return;\n }\n\n if (!this.templateId) {\n console.log(`[SEND] Missing required template ID ${this.templateId}`);\n return;\n }\n\n this.listenToTemplate();\n } catch (e) {\n console.log('[SEND] Error with send session', e);\n this.sdkError?.emit(new SDKError(e.message, e.response?.status, e.response?.data));\n }\n }\n\n recomputeRolesCompleted() {\n this.rolesCompleted = {};\n\n const rolesAtLevel: Record<number, Partial<IRecipient>[]> = {};\n (this.template?.roles || []).forEach(role => {\n const level = role.sequence;\n rolesAtLevel[level] ||= [];\n const id = `r-${level}-${rolesAtLevel[level].length}`;\n rolesAtLevel[level].push({...role, id, role_name: role.name, first_name: role.first_name, last_name: role.last_name});\n\n // if (role.first_name && (isValidEmail(role.email) || isValidPhone(role.phone))) {\n if (role.first_name && isValidEmail(role.email)) {\n this.rolesCompleted[id] = {...role, id, role_name: role.name, first_name: role.first_name, last_name: role.last_name};\n }\n });\n }\n\n getSequenceNumbers() {\n // This is cleaner with a Set but we found a regression in some target environments where\n // this breaks down. Reverting to an older technique while we diagnose it.\n const sequences: Record<number, boolean> = {};\n (this.template?.roles || []).forEach(role => {\n sequences[role.sequence] = true;\n });\n return Object.keys(sequences)\n .map(s => +s)\n .sort((a, b) => a - b);\n }\n\n getRolesAtLevel(level: number) {\n const rolesAtLevel = (this.template?.roles || [])\n .filter(role => role.sequence === level)\n .map((role, index) => ({\n ...role,\n id: `r-${level}-${index}`,\n role_name: role.name,\n first_name: role.first_name,\n last_name: role.last_name,\n }));\n return rolesAtLevel as Partial<IRecipient>[];\n }\n\n getLevelIcon(level: 'start' | 'end' | 'sequence') {\n if (level === 'start') {\n return <div class=\"level-icon\" innerHTML={startIcon} />;\n } else if (level === 'end') {\n return <div class=\"level-icon\" innerHTML={doneIcon} />;\n } else {\n return <div class=\"level-icon\" innerHTML={stepIcon} />;\n }\n }\n\n handleSelectContact(e: any, role: Partial<IRecipient>) {\n e.preventDefault();\n this.rolesCompleted[role.id] = {...role, ...e.detail};\n this.showPickerForId = '';\n }\n\n handleClickRole(e: any, role: Partial<IRecipient>) {\n e.stopPropagation();\n this.showPickerForId = role.id;\n }\n\n handleSend(e: any) {\n if (this.sending) {\n console.log('[SEND] Skipping duplicate send', e);\n return;\n }\n\n console.log('[SEND] Sending', e);\n e.preventDefault();\n e.stopPropagation();\n\n this.sending = true;\n const localeData = Intl.DateTimeFormat().resolvedOptions();\n\n const details: ICreateEnvelopeFromTemplateRequest = {\n template_id: this.templateId,\n name: this.template?.name || 'New Envelope',\n environment: this.environment,\n initial_reminder: 0,\n followup_reminders: 0,\n recipients: Object.values(this.rolesCompleted) as ICreateEnvelopeRecipientFromTemplate[],\n timezone: localeData.timeZone,\n locale: localeData.locale,\n };\n\n const beforeSendResult = this.beforeSend.emit({...details, name: details.name!, template: this.template});\n if (beforeSendResult.defaultPrevented) {\n console.log('[SEND] Send cancelled by parent', details);\n this.sending = false;\n return;\n }\n\n console.log('[SEND] Creating envelope', details);\n createEnvelope(this.endpoint, details)\n .then(r => {\n console.log('[SEND] Send envelope', r);\n this.reset().catch((e: any) => console.log('Unknown Error', e));\n this.sending = false;\n this.send?.emit({...details, name: details.name!, envelope_id: r.id, envelope: r});\n })\n .catch(e => {\n console.log('[SEND] Send error', e);\n VerdocsToast(e.response?.data?.error || 'Error creating envelope, please try again later.');\n this.sending = false;\n this.sdkError?.emit(e);\n });\n }\n\n handleCancel(e: any) {\n e.stopPropagation();\n this.exit?.emit();\n }\n\n render() {\n if (this.loading) {\n return (\n <Host>\n <verdocs-loader />\n </Host>\n );\n }\n\n if (!this.endpoint.session) {\n return (\n <Host style={{display: 'flex'}}>\n <verdocs-component-error message=\"You must be authenticated to use this module.\" />\n </Host>\n );\n }\n\n const levels = this.getSequenceNumbers();\n const rolesAssigned = Object.values(this.rolesCompleted).filter(recipient => isValidEmail(recipient.email) && recipient.first_name && recipient.last_name);\n const allRolesAssigned = rolesAssigned.length >= getRoleNames(this.template).length;\n const assignedEmails = rolesAssigned.map(r => r.email.toLowerCase());\n const hasDuplicateEmails = new Set(assignedEmails).size < assignedEmails.length;\n\n return (\n <Host class={{sendable: this.template?.is_sendable}}>\n <div class=\"recipients\">\n <div class=\"left-line\" />\n <div class={`level level-start`}>\n {this.getLevelIcon('start')}\n <div class=\"complete\">Send Envelope</div>\n </div>\n\n {levels.map(level => (\n <div class={`level level-${level}`}>\n {this.getLevelIcon('sequence')}\n\n {this.getRolesAtLevel(level).map(role => {\n const unknown = !role.email || !role.first_name || !role.last_name;\n const roleName = this.rolesCompleted[role.id]?.first_name ? formatFullName(this.rolesCompleted[role.id]) : unknown ? role.role_name : formatFullName(role);\n const elId = `verdocs-send-recipient-${role.role_name}`;\n const roleIndex = getRoleIndex(this.template, role.role_name);\n const rgba = getRGBA(roleIndex);\n const completed = rolesAssigned.findIndex(r => r.role_name === role.role_name) > -1;\n\n const style = {\n backgroundColor: rgba,\n border: completed ? '2px solid #55bc81' : '2px solid #dddddd',\n };\n\n return unknown ? (\n <div class=\"recipient\" data-ri={roleIndex} data-rn={role.role_name} style={style} onClick={e => this.handleClickRole(e, role)} id={elId}>\n {roleName}\n <div class=\"icon\" innerHTML={editIcon} />\n {this.showPickerForId === role.id && (\n <verdocs-portal anchor={elId} onClickAway={() => (this.showPickerForId = '')}>\n <verdocs-contact-picker\n onExit={() => (this.showPickerForId = '')}\n onNext={e => this.handleSelectContact(e, role)}\n contactSuggestions={this.sessionContacts}\n templateRole={this.rolesCompleted[role.id] ?? role}\n onSearchContacts={e => this.searchContacts?.emit(e.detail)}\n />\n </verdocs-portal>\n )}\n </div>\n ) : (\n <div class=\"recipient\" data-ri={roleIndex} data-rn={role.role_name} style={style} onClick={e => this.handleClickRole(e, role)} id={elId}>\n {/*<div class=\"recipient\" data-ri={roleIndex} data-rn={role.role_name} style={{borderColor: rgba}} onClick={e => this.handleClickRole(e, role)} id={elId}>*/}\n {roleName}\n <div class=\"icon\" innerHTML={editIcon} />\n {this.showPickerForId === role.id && (\n <verdocs-portal anchor={elId} onClickAway={() => (this.showPickerForId = '')}>\n <verdocs-contact-picker\n onExit={() => (this.showPickerForId = '')}\n onNext={e => this.handleSelectContact(e, role)}\n contactSuggestions={this.sessionContacts}\n templateRole={(this.rolesCompleted[role.id] ?? role) as IRecipient}\n onSearchContacts={e => this.searchContacts?.emit(e.detail)}\n />\n </verdocs-portal>\n )}\n </div>\n );\n })}\n </div>\n ))}\n\n <div class={`level level-done`}>\n {this.getLevelIcon('end')}\n <div class=\"complete\">Signing Complete</div>\n </div>\n </div>\n\n <div class=\"buttons\">\n {hasDuplicateEmails && <div class=\"error-message\">Recipients cannot share the same email.</div>}\n {this.showCancel && <verdocs-button label=\"Cancel\" size=\"small\" variant=\"outline\" onClick={e => this.handleCancel(e)} disabled={this.sending} />}\n <verdocs-button label=\"Send\" size=\"small\" disabled={!allRolesAssigned || this.sending || hasDuplicateEmails} onClick={e => this.handleSend(e)} />\n {this.sending && <verdocs-spinner />}\n </div>\n </Host>\n );\n }\n}\n"],"mappings":"yoBAEO,MAAMA,EAAgBC,KAAgCA,IAAQ,MAARA,SAAQ,SAARA,EAAUC,QAAS,IAAIC,KAAIC,GAAQA,EAAKC,OAE9F,MAAMC,EAAe,CAACL,EAA4BM,IACvDC,KAAKC,IACHT,EAAaC,GAAUS,WAAUL,GAAQA,IAASE,IAClD,GCPJ,MAAMI,EAAiB,IAAM,0pECU7B,MAAMC,EACJ,2PAEF,MAAMC,EACJ,mOAEF,MAAMC,EACJ,iQAEF,MAAMC,EACJ,+P,MAwBWC,EAAWC,EAAA,MAAAD,UAAAE,EALxB,WAAAC,CAAAC,G,iNAMUC,KAAAC,mBAAqB,KAKrBD,KAAAE,SAA4BC,EAKbH,KAAAI,WAA4B,KAQ3CJ,KAAAK,YAAsB,GAMtBL,KAAAM,WAAa,KA6BZN,KAAAO,YAAc,gBAAgBpB,KAAKqB,SAASC,SAAS,IAAIC,UAAU,EAAG,MACtEV,KAAAW,gBAAkB,GAClBX,KAAAY,gBAAkB,GAClBZ,KAAAa,QAAU,MACVb,KAAAc,eAAsD,GAEtDd,KAAAe,Q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gBoE,MAAM,SAAStB,KAAK,QAAQuB,QAAQ,UAAUV,QAAS3F,GAAK7C,KAAK6G,aAAahE,GAAIsG,SAAUnJ,KAAKa,UACrIgE,EAAA,kBAAgBoE,MAAM,OAAOtB,KAAK,QAAQwB,UAAW7B,GAAoBtH,KAAKa,SAAW4G,EAAoBe,QAAS3F,GAAK7C,KAAKqF,WAAWxC,KAC1I7C,KAAKa,SAAWgE,EAAA,yB","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{p as e,H as o,c as t,h as i,t as n}from"./p-yZBlG3YQ.js";import{D as s}from"./p-17OorOnH.js";import{d as a}from"./p-DT0LGcPi.js";const d=()=>`verdocs-download-dialog{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", "Barlow", sans-serif}verdocs-download-dialog .heading-container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}verdocs-download-dialog .content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:15px;padding:0 24px 20px 24px}verdocs-download-dialog .download-option{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:12px 15px;border:1px solid #e5e7eb;border-radius:6px;cursor:pointer;-webkit-transition:all 0.2s ease;transition:all 0.2s ease;gap:15px;background:white}verdocs-download-dialog .download-option.disabled{opacity:0.5;cursor:not-allowed}verdocs-download-dialog .download-option.disabled:hover{background-color:white;border-color:#e5e7eb}verdocs-download-dialog .download-option:hover{border-color:#654dcb;background-color:#f9fafb}verdocs-download-dialog .icon-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:36px;height:36px;background-color:#f3f4f6;border-radius:50%;color:#4b5563;-ms-flex-negative:0;flex-shrink:0}verdocs-download-dialog .icon-container svg{width:18px;height:18px}verdocs-download-dialog .text-container{-ms-flex:1;flex:1}verdocs-download-dialog .text-container .label{font-weight:500;color:#111827;margin-bottom:2px}verdocs-download-dialog .text-container .description{font-size:13px;color:#6b7280}verdocs-download-dialog .status-indicator{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;gap:2px;font-size:11px;color:#9ca3af;min-width:50px}verdocs-download-dialog .status-indicator .signed{color:#10b981}verdocs-download-dialog .status-indicator .spinner-inline{display:-ms-flexbox;display:flex;color:#9ca3af;-webkit-animation:rotate 2s linear infinite;animation:rotate 2s linear infinite}verdocs-download-dialog .status-indicator svg{width:16px;height:16px}verdocs-download-dialog .info-message{font-size:13px;color:#6b7280;font-style:italic;padding:0 4px}@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}`;const r=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V9L13 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M13 2V9H20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const l=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 15C15.866 15 19 11.866 19 8C19 4.13401 15.866 1 12 1C8.13401 1 5 4.13401 5 8C5 11.866 8.13401 15 12 15Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.21 13.89L7 23L12 20L17 23L15.79 13.88" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const c=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 16V22H14V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 16H18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20 22H4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 10L12 16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 12L12 16L16 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 16V4H20V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const f=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const p=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4V10H17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.49 15A9 9 0 1 1 21.23 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const g=e(class e extends o{constructor(e){super();if(e!==false){this.__registerHost()}this.download=t(this,"download");this.exit=t(this,"exit");this.signed=false;this.polling=false;this.documents=[];this.hasCertificate=false}handleOptionClick(e,o){const t=this.documents.some((e=>e.type==="certificate"))||this.hasCertificate;const i=this.signed&&t;const n=e===s.certificate&&!i;const a=e===s.zip&&(this.polling||!i);const d=e===s.combined&&!i;if(n||a||d)return;this.download.emit({action:e,documentId:o})}render(){const e=this.documents.filter((e=>e.type==="attachment")).sort(((e,o)=>e.order!==o.order?e.order-o.order:e.created_at.localeCompare(o.created_at)));const o=this.documents.some((e=>e.type==="certificate"))||this.hasCertificate;const t=this.signed&&o;const n=this.signed&&o;const a=!this.polling&&t;const d=!this.signed;return i("verdocs-dialog",{key:"a877948153b6b0ee7eda1f2e19d4df7f061f72d5",onExit:()=>this.exit.emit()},i("div",{key:"51da52f3f20473ae1901ce60e5edafd144521478",slot:"heading",class:"heading-container"},i("h3",{key:"a68c34c0de3959409e1939aed35879402cba2b09",style:{margin:"0",fontSize:"1.25rem",fontWeight:"600",padding:"16px 24px"}},"Download")),i("div",{key:"66ccef7e477d5862f8d941ec558310aaffd9e266",slot:"content",class:"content"},e.length<=2&&e.map((e=>i("div",{class:"download-option",onClick:()=>this.handleOptionClick(s.document,e.id)},i("div",{class:"icon-container",innerHTML:r}),i("div",{class:"text-container"},i("div",{class:"label"},e.name),i("div",{class:"description"},"Download the document")),d?i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p})):i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Signed"))))),e.length>2&&i("div",{key:"6eda124edbc14116b63bb1a508d5f6ca2c4ee81d",class:"info-message"},"Multiple documents attached. Please use the ZIP option below to download all files."),i("div",{key:"c7adc5310b532cb7ca3ce64d90547c0648675af9",class:{"download-option":true,disabled:!t},onClick:()=>this.handleOptionClick(s.certificate),title:!t?"Certificate not yet available":""},i("div",{key:"099cece3ea7a1927a8b7d9632ffa8cc3e6220868",class:"icon-container",innerHTML:l}),i("div",{key:"0e09d9749a9967291fdde0a35a30287d31bedec7",class:"text-container"},i("div",{key:"3f76cc900207bf06c5207d79d68b1219c066bde8",class:"label"},"Certificate"),i("div",{key:"34fe2b37c150b66173f61f76cc5d8d77c74e61e8",class:"description"},"Download the certificate")),t?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p}))),i("div",{key:"2e1d48989564753b19f7431db7b231f1858542ce",class:{"download-option":true,disabled:!n},onClick:()=>this.handleOptionClick(s.combined),title:!n?"Waiting for all documents to be ready":""},i("div",{key:"de52875477a5f583624357061ee21ab65fbbf53a",class:"icon-container",innerHTML:c}),i("div",{key:"c7ce9b867f7e6f5eec060a65d4487e3f33814025",class:"text-container"},i("div",{key:"63ffd99d31428740c9b19ea44281a4b966c4dab8",class:"label"},"Combined"),i("div",{key:"5ff20fcacc17c4dbee9034181158a5202a3391b5",class:"description"},"Merge envelopes & certificate into a single PDF")),n?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p}))),i("div",{key:"feb5a60d1538f3367b082f5c8f2b41fde4c44997",class:{"download-option":true,disabled:!a},onClick:()=>this.handleOptionClick(s.zip),title:!a?"Waiting for all documents to be ready":""},i("div",{key:"dcad103a22173198f247005ba7cd611986865f89",class:"icon-container",innerHTML:c}),i("div",{key:"eccfb0e7f4a7aca6b180089a0b2392ec51e8a21d",class:"text-container"},i("div",{key:"94586ca4646cab77493d98e85e3f0a1bcf7cc911",class:"label"},"All Files"),i("div",{key:"2d42fa14e73f9df2e39fcd8ff8f9cb107ffd2246",class:"description"},"Download everything as a ZIP file")),a?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p})))),i("div",{key:"a087605743e0b7e7f3de01aa20dc5be28b8723d5",slot:"footer",style:{display:"none"}}))}static get style(){return d()}},[0,"verdocs-download-dialog",{signed:[4],polling:[4],documents:[16],hasCertificate:[4,"has-certificate"]}]);function b(){if(typeof customElements==="undefined"){return}const e=["verdocs-download-dialog","verdocs-dialog"];e.forEach((e=>{switch(e){case"verdocs-download-dialog":if(!customElements.get(n(e))){customElements.define(n(e),g)}break;case"verdocs-dialog":if(!customElements.get(n(e))){a()}break}}))}export{g as V,b as d};
2
- //# sourceMappingURL=p-BVhOFpVZ.js.map
1
+ import{p as e,H as o,c as t,h as i,t as n}from"./p-yZBlG3YQ.js";import{D as s}from"./p-17OorOnH.js";import{d as a}from"./p-DT0LGcPi.js";const d=()=>`verdocs-download-dialog{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", "Barlow", sans-serif}verdocs-download-dialog .heading-container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}verdocs-download-dialog .content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:15px;padding:0 24px 20px 24px}verdocs-download-dialog .download-option{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:12px 15px;border:1px solid #e5e7eb;border-radius:6px;cursor:pointer;-webkit-transition:all 0.2s ease;transition:all 0.2s ease;gap:15px;background:white}verdocs-download-dialog .download-option.disabled{opacity:0.5;cursor:not-allowed}verdocs-download-dialog .download-option.disabled:hover{background-color:white;border-color:#e5e7eb}verdocs-download-dialog .download-option:hover{border-color:#654dcb;background-color:#f9fafb}verdocs-download-dialog .icon-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:36px;height:36px;background-color:#f3f4f6;border-radius:50%;color:#4b5563;-ms-flex-negative:0;flex-shrink:0}verdocs-download-dialog .icon-container svg{width:18px;height:18px}verdocs-download-dialog .text-container{-ms-flex:1;flex:1}verdocs-download-dialog .text-container .label{font-weight:500;color:#111827;margin-bottom:2px}verdocs-download-dialog .text-container .description{font-size:13px;color:#6b7280}verdocs-download-dialog .status-indicator{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;gap:2px;font-size:11px;color:#9ca3af;min-width:50px}verdocs-download-dialog .status-indicator .signed{color:#10b981}verdocs-download-dialog .status-indicator .spinner-inline{display:-ms-flexbox;display:flex;color:#9ca3af;-webkit-animation:rotate 2s linear infinite;animation:rotate 2s linear infinite}verdocs-download-dialog .status-indicator svg{width:16px;height:16px}verdocs-download-dialog .info-message{font-size:13px;color:#6b7280;font-style:italic;padding:0 4px}@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}`;const r=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V9L13 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M13 2V9H20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const l=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 15C15.866 15 19 11.866 19 8C19 4.13401 15.866 1 12 1C8.13401 1 5 4.13401 5 8C5 11.866 8.13401 15 12 15Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.21 13.89L7 23L12 20L17 23L15.79 13.88" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const c=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 16V22H14V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 16H18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20 22H4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 10L12 16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 12L12 16L16 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 16V4H20V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const f=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const p=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4V10H17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.49 15A9 9 0 1 1 21.23 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;const b=e(class e extends o{constructor(e){super();if(e!==false){this.__registerHost()}this.download=t(this,"download");this.exit=t(this,"exit");this.signed=false;this.polling=false;this.documents=[];this.hasCertificate=false}handleOptionClick(e,o){const t=this.documents.some((e=>e.type==="certificate"))||this.hasCertificate;const i=this.signed&&t;const n=e===s.certificate&&!i;const a=e===s.zip&&(this.polling||!i);const d=e===s.combined&&(this.polling||!i||!o);if(n||a||d)return;this.download.emit({action:e,documentId:o})}render(){const e=this.documents.filter((e=>e.type==="attachment")).sort(((e,o)=>e.order!==o.order?e.order-o.order:e.created_at.localeCompare(o.created_at)));const o=this.documents.find((e=>e.type==="certificate"));const t=!!o||this.hasCertificate;const n=this.signed&&t;const a=!this.polling&&n;const d=a&&!!(o===null||o===void 0?void 0:o.id);const b=!this.signed;return i("verdocs-dialog",{key:"09670a45a18cf110462390fd0ef2f705b3577f31",onExit:()=>this.exit.emit()},i("div",{key:"2b01ee1c71aa51f80d9ecf1ec16a62af146342cd",slot:"heading",class:"heading-container"},i("h3",{key:"1ddb9cf369621aeafebc0ce3511f1e59579ee471",style:{margin:"0",fontSize:"1.25rem",fontWeight:"600",padding:"16px 24px"}},"Download")),i("div",{key:"c62c72d8eeb5bc7cde8791370bcc2f5a46978dd1",slot:"content",class:"content"},e.length<=2&&e.map((e=>i("div",{class:"download-option",onClick:()=>this.handleOptionClick(s.document,e.id)},i("div",{class:"icon-container",innerHTML:r}),i("div",{class:"text-container"},i("div",{class:"label"},e.name),i("div",{class:"description"},"Download the document")),b?i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p})):i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Signed"))))),e.length>2&&i("div",{key:"10f6f2b1a7197533e5ad1d8b00cdfb14b465eec1",class:"info-message"},"Multiple documents attached. Please use the ZIP option below to download all files."),i("div",{key:"8a0c4c5a3e7c5f99626b2f2ece050b3c66f53006",class:{"download-option":true,disabled:!n},onClick:()=>this.handleOptionClick(s.certificate),title:!n?"Certificate not yet available":""},i("div",{key:"f44f22a0655603d2af1785fd306aea4b99e168a9",class:"icon-container",innerHTML:l}),i("div",{key:"fa99982c36808621b10dd30a72412be02b2ac0c7",class:"text-container"},i("div",{key:"66d6d8d832ca66f17d2b6074fe80f0a573539aa7",class:"label"},"Certificate"),i("div",{key:"a7c6c02afdf06fb59622f41e80946e9ad0feb231",class:"description"},"Download the certificate")),n?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p}))),i("div",{key:"d6c7a9d4ffa660869730292e8981b7fca9ec2d7a",class:{"download-option":true,disabled:!d},onClick:()=>this.handleOptionClick(s.combined,o===null||o===void 0?void 0:o.id),title:!d?"Waiting for all documents to be ready":""},i("div",{key:"c49585f9f2995bf90a6a7a7f1006ff62e1c4ff75",class:"icon-container",innerHTML:c}),i("div",{key:"c886fb02b282f9e3e8bbc932652e85acadba3620",class:"text-container"},i("div",{key:"cd321c5acde3b28048549f8dfb4ae576e21b0b71",class:"label"},"Combined"),i("div",{key:"cbb9b3280585382ad606611fd07ab040b9176d69",class:"description"},"Merge envelopes & certificate into a single PDF")),d?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p}))),i("div",{key:"33e022ea22d4aa4b9e4169ec8709243d143c9320",class:{"download-option":true,disabled:!a},onClick:()=>this.handleOptionClick(s.zip),title:!a?"Waiting for all documents to be ready":""},i("div",{key:"96af105f93ed2cf4903466df246d9be3eeebbbdc",class:"icon-container",innerHTML:c}),i("div",{key:"f4ca89d84a10444d9db3b3745779a5eee05cf73d",class:"text-container"},i("div",{key:"c48b2b5a6184162b59123981ac2bdbe2d358f8b9",class:"label"},"All Files"),i("div",{key:"72620fada50c48437eaa40983f7b6e8c84e4f35a",class:"description"},"Download everything as a ZIP file")),a?i("div",{class:"status-indicator"},i("div",{class:"signed",innerHTML:f}),i("span",null,"Ready")):i("div",{class:"status-indicator"},i("div",{class:"spinner-inline",innerHTML:p})))),i("div",{key:"0f10d2c47891ad31a70d5ef412377a35c58f840d",slot:"footer",style:{display:"none"}}))}static get style(){return d()}},[0,"verdocs-download-dialog",{signed:[4],polling:[4],documents:[16],hasCertificate:[4,"has-certificate"]}]);function g(){if(typeof customElements==="undefined"){return}const e=["verdocs-download-dialog","verdocs-dialog"];e.forEach((e=>{switch(e){case"verdocs-download-dialog":if(!customElements.get(n(e))){customElements.define(n(e),b)}break;case"verdocs-dialog":if(!customElements.get(n(e))){a()}break}}))}export{b as V,g as d};
2
+ //# sourceMappingURL=p-DfaM_cug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["verdocsDownloadDialogCss","DocumentIcon","CertificateIcon","ZipIcon","CheckIcon","RefreshIcon","VerdocsDownloadDialog","__stencil_proxyCustomElement","HTMLElement","constructor","registerHost","this","signed","polling","documents","hasCertificate","handleOptionClick","action","documentId","hasCert","some","d","type","isCertReady","isCertificateDisabled","DownloadAction","certificate","isZipDisabled","zip","isCombinedDisabled","combined","download","emit","render","attachments","filter","sort","a","b","order","created_at","localeCompare","certificateDocument","find","hasCertificateDoc","certReady","allDone","isCombinedReady","id","attachmentBusy","h","key","onExit","exit","slot","class","style","margin","fontSize","fontWeight","padding","length","map","doc","onClick","document","innerHTML","name","disabled","title","display"],"sources":["src/components/dialogs/verdocs-download-dialog/verdocs-download-dialog.scss?tag=verdocs-download-dialog","src/components/dialogs/verdocs-download-dialog/verdocs-download-dialog.tsx"],"sourcesContent":["@import '../../../theme.scss';\n\nverdocs-download-dialog {\n box-sizing: border-box;\n font-family: $primary-font;\n\n .heading-container {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .content {\n display: flex;\n flex-direction: column;\n gap: 15px;\n padding: 0 24px 20px 24px;\n }\n\n .download-option {\n display: flex;\n align-items: center;\n padding: 12px 15px;\n border: 1px solid #e5e7eb;\n border-radius: 6px;\n cursor: pointer;\n transition: all 0.2s ease;\n gap: 15px;\n background: white;\n\n &.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n\n &:hover {\n background-color: white;\n border-color: #e5e7eb;\n }\n }\n\n &:hover {\n border-color: $verdocs-primary-color;\n background-color: #f9fafb;\n }\n }\n\n .icon-container {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n background-color: #f3f4f6;\n border-radius: 50%;\n color: #4b5563;\n flex-shrink: 0;\n\n svg {\n width: 18px;\n height: 18px;\n }\n }\n\n .text-container {\n flex: 1;\n\n .label {\n font-weight: 500;\n color: #111827;\n margin-bottom: 2px;\n }\n\n .description {\n font-size: 13px;\n color: #6b7280;\n }\n }\n\n .status-indicator {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2px;\n font-size: 11px;\n color: #9ca3af;\n min-width: 50px;\n\n .signed {\n color: #10b981;\n }\n\n .spinner-inline {\n display: flex;\n color: #9ca3af;\n animation: rotate 2s linear infinite;\n }\n\n svg {\n width: 16px;\n height: 16px;\n }\n }\n\n .info-message {\n font-size: 13px;\n color: #6b7280;\n font-style: italic;\n padding: 0 4px;\n }\n}\n\n@keyframes rotate {\n from {\n transform: rotate(0deg);\n }\n\n to {\n transform: rotate(360deg);\n }\n}\n","import {Component, h, Event, EventEmitter, Prop} from '@stencil/core';\nimport {DownloadAction} from '../../../utils/Types';\n\nconst DocumentIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V9L13 2Z\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M13 2V9H20\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\nconst CertificateIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 15C15.866 15 19 11.866 19 8C19 4.13401 15.866 1 12 1C8.13401 1 5 4.13401 5 8C5 11.866 8.13401 15 12 15Z\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M8.21 13.89L7 23L12 20L17 23L15.79 13.88\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\nconst ZipIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10 16V22H14V16\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M6 16H18\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M20 22H4\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M12 10L12 16\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M8 12L12 16L16 12\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M4 16V4H20V16\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\nconst CheckIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20 6L9 17L4 12\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\nconst RefreshIcon = `<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M23 4V10H17\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M20.49 15A9 9 0 1 1 21.23 8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n@Component({\n tag: 'verdocs-download-dialog',\n styleUrl: 'verdocs-download-dialog.scss',\n shadow: false,\n})\nexport class VerdocsDownloadDialog {\n /**\n * Event fired when an option is selected.\n */\n /**\n * Event fired when an option is selected.\n */\n @Event({composed: true}) download: EventEmitter<{action: DownloadAction; documentId?: string}>;\n\n /**\n * Event fired when Cancel is pressed or background is clicked.\n */\n @Event({composed: true}) exit: EventEmitter;\n\n /**\n * If true, the envelope is considered signed.\n */\n @Prop() signed = false;\n\n /**\n * If true, we are currently polling the server for updates.\n */\n @Prop() polling = false;\n\n /**\n * The list of documents in the envelope.\n */\n @Prop() documents: any[] = [];\n\n /**\n * If true, the envelope has a certificate available for download.\n */\n @Prop() hasCertificate = false;\n\n handleOptionClick(action: DownloadAction, documentId?: string) {\n const hasCert = this.documents.some(d => d.type === 'certificate') || this.hasCertificate;\n const isCertReady = this.signed && hasCert;\n const isCertificateDisabled = action === DownloadAction.certificate && !isCertReady;\n const isZipDisabled = action === DownloadAction.zip && (this.polling || !isCertReady);\n const isCombinedDisabled = action === DownloadAction.combined && (this.polling || !isCertReady || !documentId);\n\n if (isCertificateDisabled || isZipDisabled || isCombinedDisabled) return;\n this.download.emit({action, documentId});\n }\n\n render() {\n const attachments = this.documents.filter(d => d.type === 'attachment').sort((a, b) => (a.order !== b.order ? a.order - b.order : a.created_at.localeCompare(b.created_at)));\n const certificateDocument = this.documents.find(d => d.type === 'certificate');\n const hasCertificateDoc = !!certificateDocument || this.hasCertificate;\n const certReady = this.signed && hasCertificateDoc;\n const allDone = !this.polling && certReady;\n const isCombinedReady = allDone && !!certificateDocument?.id;\n const attachmentBusy = !this.signed;\n\n return (\n <verdocs-dialog onExit={() => this.exit.emit()}>\n <div slot=\"heading\" class=\"heading-container\">\n <h3 style={{margin: '0', fontSize: '1.25rem', fontWeight: '600', padding: '16px 24px'}}>Download</h3>\n </div>\n\n <div slot=\"content\" class=\"content\">\n {attachments.length <= 2 &&\n attachments.map(doc => (\n <div class=\"download-option\" onClick={() => this.handleOptionClick(DownloadAction.document, doc.id)}>\n <div class=\"icon-container\" innerHTML={DocumentIcon}></div>\n <div class=\"text-container\">\n <div class=\"label\">{doc.name}</div>\n <div class=\"description\">Download the document</div>\n </div>\n {attachmentBusy ? (\n <div class=\"status-indicator\">\n <div class=\"spinner-inline\" innerHTML={RefreshIcon}></div>\n </div>\n ) : (\n <div class=\"status-indicator\">\n <div class=\"signed\" innerHTML={CheckIcon}></div>\n <span>Signed</span>\n </div>\n )}\n </div>\n ))}\n\n {attachments.length > 2 && <div class=\"info-message\">Multiple documents attached. Please use the ZIP option below to download all files.</div>}\n\n <div\n class={{'download-option': true, 'disabled': !certReady}}\n onClick={() => this.handleOptionClick(DownloadAction.certificate)}\n title={!certReady ? 'Certificate not yet available' : ''}\n >\n <div class=\"icon-container\" innerHTML={CertificateIcon}></div>\n <div class=\"text-container\">\n <div class=\"label\">Certificate</div>\n <div class=\"description\">Download the certificate</div>\n </div>\n {certReady ? (\n <div class=\"status-indicator\">\n <div class=\"signed\" innerHTML={CheckIcon}></div>\n <span>Ready</span>\n </div>\n ) : (\n <div class=\"status-indicator\">\n <div class=\"spinner-inline\" innerHTML={RefreshIcon}></div>\n </div>\n )}\n </div>\n\n <div\n class={{'download-option': true, 'disabled': !isCombinedReady}}\n onClick={() => this.handleOptionClick(DownloadAction.combined, certificateDocument?.id)}\n title={!isCombinedReady ? 'Waiting for all documents to be ready' : ''}\n >\n <div class=\"icon-container\" innerHTML={ZipIcon}></div>\n <div class=\"text-container\">\n <div class=\"label\">Combined</div>\n <div class=\"description\">Merge envelopes & certificate into a single PDF</div>\n </div>\n {isCombinedReady ? (\n <div class=\"status-indicator\">\n <div class=\"signed\" innerHTML={CheckIcon}></div>\n <span>Ready</span>\n </div>\n ) : (\n <div class=\"status-indicator\">\n <div class=\"spinner-inline\" innerHTML={RefreshIcon}></div>\n </div>\n )}\n </div>\n\n <div\n class={{'download-option': true, 'disabled': !allDone}}\n onClick={() => this.handleOptionClick(DownloadAction.zip)}\n title={!allDone ? 'Waiting for all documents to be ready' : ''}\n >\n <div class=\"icon-container\" innerHTML={ZipIcon}></div>\n <div class=\"text-container\">\n <div class=\"label\">All Files</div>\n <div class=\"description\">Download everything as a ZIP file</div>\n </div>\n {allDone ? (\n <div class=\"status-indicator\">\n <div class=\"signed\" innerHTML={CheckIcon}></div>\n <span>Ready</span>\n </div>\n ) : (\n <div class=\"status-indicator\">\n <div class=\"spinner-inline\" innerHTML={RefreshIcon}></div>\n </div>\n )}\n </div>\n </div>\n\n <div slot=\"footer\" style={{display: 'none'}} />\n </verdocs-dialog>\n );\n }\n}\n"],"mappings":"wIAAA,MAAMA,EAA2B,IAAM,g7ECGvC,MAAMC,EAAe,khBACrB,MAAMC,EAAkB,waACxB,MAAMC,EAAU,suBAChB,MAAMC,EAAY,kMAClB,MAAMC,EAAc,2T,MAOPC,EAAqBC,EAAA,MAAAD,UAAAE,EALlC,WAAAC,CAAAC,G,sGAsBUC,KAAAC,OAAS,MAKTD,KAAAE,QAAU,MAKVF,KAAAG,UAAmB,GAKnBH,KAAAI,eAAiB,KA2H1B,CAzHC,iBAAAC,CAAkBC,EAAwBC,GACxC,MAAMC,EAAUR,KAAKG,UAAUM,MAAK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KI,MAAM,SAAO,YAClBL,EAAA,OAAAC,IAAA,2CAAKI,MAAM,eAAa,oDAEzBR,EACCG,EAAA,OAAKK,MAAM,oBACTL,EAAA,OAAKK,MAAM,SAASW,UAAW9D,IAC/B8C,EAAA,sBAGFA,EAAA,OAAKK,MAAM,oBACTL,EAAA,OAAKK,MAAM,iBAAiBW,UAAW7D,MAK7C6C,EAAA,OAAAC,IAAA,2CACEI,MAAO,CAAC,kBAAmB,KAAMa,UAAatB,GAC9CkB,QAAS,IAAMrD,KAAKK,kBAAkBS,EAAeG,KACrDyC,OAAQvB,EAAU,wCAA0C,IAE5DI,EAAA,OAAAC,IAAA,2CAAKI,MAAM,iBAAiBW,UAAW/D,IACvC+C,EAAA,OAAAC,IAAA,2CAAKI,MAAM,kBACTL,EAAA,OAAAC,IAAA,2CAAKI,MAAM,SAAO,aAClBL,EAAA,OAAAC,IAAA,2CAAKI,MAAM,eAAa,sCAEzBT,EACCI,EAAA,OAAKK,MAAM,oBACTL,EAAA,OAAKK,MAAM,SAASW,UAAW9D,IAC/B8C,EAAA,sBAGFA,EAAA,OAAKK,MAAM,oBACTL,EAAA,OAAKK,MAAM,iBAAiBW,UAAW7D,OAM/C6C,EAAA,OAAAC,IAAA,2CAAKG,KAAK,SAASE,MAAO,CAACc,QAAS,U","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{p as e,H as t,c as s,h as i,t as o}from"./p-yZBlG3YQ.js";import{VerdocsEndpoint as a,convertToE164 as r,createProfile as n,verifyEmail as l,authenticate as d,getMyUser as c,resendVerification as h,resetPassword as u}from"@verdocs/js-sdk";import{V as p}from"./p-D97GxsI-.js";import{S as f}from"./p-C1sRVZWv.js";import{d as m}from"./p-Bdf8pPWm.js";import{d as v}from"./p-CioaaWeS.js";import{d as b}from"./p-DYtSnUj9.js";const y=()=>`verdocs-auth{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{width:350px;display:-ms-flexbox;display:flex;padding:20px;max-width:90%;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-pack:center;justify-content:center;background:#ffffff}verdocs-auth .logo{width:128px;max-width:100%;margin:20px 0 30px}verdocs-auth h3{color:#092c4c;text-align:center;font-weight:400;font-size:18px;line-height:1.75;margin:0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{color:#092c4c;margin:1em 0;font-size:14px}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}verdocs-auth .already-have{color:#092c4c;margin:0.5em 0;font-size:14px;text-align:center}verdocs-auth .service-agreement{font-size:12px;color:#777}verdocs-auth .service-agreement a{color:#092c4c}`;const g=e(class e extends t{constructor(e){super();if(e!==false){this.__registerHost()}this.authenticated=s(this,"authenticated");this.sdkError=s(this,"sdkError");this.endpoint=a.getDefault();this.visible=true;this.logo="https://app.verdocs.com/assets/blue-logo.svg";this.displayMode="login";this.org_name="";this.first_name="";this.last_name="";this.email="";this.phone="";this.verificationCode="";this.newPassword="";this.password="";this.confirmpass="";this.submitting=false;this.resendDisabled=false;this.session=null;this.profile=null;this.resendDisabledTimer=null;this.tempAuthEndpoint=new a({baseURL:a.getDefault().getBaseURL(),persist:false});this.handleHashChange=()=>{this.applyHashDisplayMode()}}componentWillLoad(){this.endpoint.loadSession();this.applyHashDisplayMode();if(typeof window!=="undefined"){window.addEventListener("hashchange",this.handleHashChange)}a.getDefault().onSessionChanged(((e,t,s)=>{var i,o;this.session=t;this.profile=s;if(t){(i=this.authenticated)===null||i===void 0?void 0:i.emit({authenticated:true,session:t,profile:s})}else{(o=this.authenticated)===null||o===void 0?void 0:o.emit({authenticated:false,session:t,profile:s})}}))}disconnectedCallback(){if(typeof window!=="undefined"){window.removeEventListener("hashchange",this.handleHashChange)}}applyHashDisplayMode(){if(typeof window==="undefined"){return}const e=(window.location.hash||"").replace(/^#/,"").toLowerCase();if(e==="forgot"){this.displayMode="forgot"}}isPasswordComplex(e){const t=e=>/[A-Z]/.test(e);const s=e=>/[a-z]/.test(e);const i=e=>/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(e);let o=0,a=0,r=0;for(let n=0;n<e.length;n++){let l=e.charAt(n);if(t(l))o++;else if(s(l))a++;else if(i(l))r++}return e.length>=8&&a>0&&o>0&&r>0}handleSignup(){if(!this.isPasswordComplex(this.password)){p("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.password!==this.confirmpass){p("Passwords do not match.",{style:"error"});return}this.submitting=true;this.tempAuthEndpoint.clearSession();const e=r(this.phone);n(this.tempAuthEndpoint,{email:this.email,password:this.password,first_name:this.first_name,last_name:this.last_name,org_name:this.org_name,phone:e}).then((e=>{console.log("[AUTH] Profile creation result",e);this.tempAuthEndpoint.setToken(e.access_token);this.password="";this.phone="";this.first_name="";this.last_name="";this.org_name="";this.displayMode="verify";this.submitting=false})).catch((e=>{var t,s,i,o,a,r;console.log("[AUTH] Signup error",e.response);this.submitting=false;(t=this.authenticated)===null||t===void 0?void 0:t.emit({authenticated:false,profile:null,session:null});(s=this.sdkError)===null||s===void 0?void 0:s.emit(new f(e.message,(i=e.response)===null||i===void 0?void 0:i.status,(o=e.response)===null||o===void 0?void 0:o.data));p("Signup failed: "+((r=(a=e.response)===null||a===void 0?void 0:a.data)===null||r===void 0?void 0:r.error)||"Unknown Error",{style:"error"})}))}async handleVerification(){this.submitting=true;try{this.submitting=false;const e=await l(this.tempAuthEndpoint,{email:this.email,token:this.verificationCode});p("Thank you for verifying your email address.",{style:"success"});this.completeLogin(e)}catch(e){this.submitting=false;console.log("Verification error",e);p("Verification error, please check the code and try again.")}}completeLogin(e){this.clearForms();this.tempAuthEndpoint.clearSession();this.endpoint.setToken(e.access_token)}async loginAndCheckVerification(){var e;if(this.submitting){return}this.submitting=true;this.tempAuthEndpoint.clearSession();try{this.submitting=false;const e=await d(this.tempAuthEndpoint,{username:this.email.trim(),password:this.password,grant_type:"password"});console.log("[AUTH] Authenticated, checking email verification");this.tempAuthEndpoint.setToken(e.access_token);const t=await c(this.tempAuthEndpoint);if(!t.email_verified){console.log("[AUTH] Logged in, pending email address verification");this.displayMode="verify"}else{console.log("[AUTH] Email address is verified, completing login");this.completeLogin(e)}}catch(t){this.submitting=false;console.log("[AUTH] Auth failure",((e=t.response)===null||e===void 0?void 0:e.data)||t);p("Login failed. Please check your credentials and try again.",{style:"error"})}}clearForms(){this.submitting=false;this.resendDisabled=false;this.email="";this.phone="";this.password="";this.newPassword="";this.confirmpass="";this.verificationCode="";this.first_name="";this.last_name="";this.org_name=""}handleLogout(){console.log("logging out");this.endpoint.clearSession();this.tempAuthEndpoint.clearSession();this.clearForms();this.displayMode="login"}handleResendVerification(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);h(this.tempAuthEndpoint).then((e=>{console.log("[AUTH] Verification request resent",e);p("Please check your email for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend verification",e);p("Unable to resend code. Please try again later.",{style:"error"})}))}handleResendReset(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);u(this.tempAuthEndpoint,{email:this.email}).then((e=>{console.log("[AUTH] Resend-code request resent",e);p("Please check your email again for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend reset request",e);p("Unable to resend code. Please try again later.",{style:"error"})}))}async handleResetGetCode(){this.submitting=true;this.confirmpass="";this.newPassword="";try{this.submitting=false;const e=await u(this.endpoint,{email:this.email});console.log("[AUTH] Reset result",e);p("Please check your email inbox for a password reset code.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.displayMode="reset"}catch(e){this.submitting=false;console.log("Reset request error",e);p("Request failed. Please check your email address and try again.")}}async handleResetPassword(){if(!this.isPasswordComplex(this.newPassword)){p("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.newPassword!==this.confirmpass){p("Passwords do not match.",{style:"error"});return}this.submitting=true;try{this.submitting=false;const e=await u(this.endpoint,{email:this.email,code:this.verificationCode,new_password:this.newPassword});console.log("reset result",e);p("Your password has been reset. You may now use your new password to login.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.password="";this.displayMode="login"}catch(e){this.submitting=false;console.log("Verification error",e);p("Verification error, please check the code and try again.")}}async handleReset(){this.submitting=true;try{const e=await u(this.endpoint,{email:this.email});console.log("[AUTH] Reset sent",e);this.submitting=false;this.displayMode="login";p("If your email address is registered, you will receive instructions on resetting your password shortly.",{style:"info"})}catch(e){console.log("[AUTH] Unable to reset password",e);this.submitting=false;p("Unable to reset password. Please check your email address and try again.",{style:"error"})}}render(){if(!this.visible){return i("div",{style:{display:"none"}},"Authenticated")}if(this.session){return i("verdocs-button",{label:"Sign Out",disabled:this.submitting,onClick:()=>this.handleLogout(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})}if(this.displayMode==="signup"){const e=this.submitting||!this.first_name||!this.last_name||!this.email||!this.password||!this.confirmpass||!this.org_name;return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Sign up for a free account"),i("div",{class:"already-have"},"Already have an account?",i("verdocs-button",{label:"Log In",variant:"text",onClick:()=>this.displayMode="login",disabled:this.submitting})),i("form",{onSubmit:()=>this.handleSignup()},i("div",{style:{display:"flex",flexDirection:"row",columnGap:"20px"}},i("verdocs-text-input",{label:"First Name",autocomplete:"first",required:true,value:this.first_name,onInput:e=>this.first_name=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Last Name",autocomplete:"last",required:true,value:this.last_name,onInput:e=>this.last_name=e.target.value,disabled:this.submitting})),i("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"new-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Phone Number",type:"tel",required:true,autocomplete:"phone",value:this.phone,onInput:e=>this.phone=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Organization Name",autocomplete:"org",required:true,value:this.org_name,onInput:e=>this.org_name=e.target.value,disabled:this.submitting,style:{flex:"1"}}),i("div",{class:"service-agreement"},"By clicking the Create Account button, you agree to the"," ",i("a",{href:"https://verdocs.com/eula",target:"_blank"},"End User License Agreement"),". Learn about how we use and protect your data and how you can opt-out in our"," ",i("a",{href:"https://verdocs.com/privacy-policy",target:"_blank"},"Privacy Policy"),"."),i("div",{style:{marginTop:"30px"}}),i("verdocs-button",{label:"Next",disabled:e,onClick:e?()=>{}:()=>this.handleSignup(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})))}if(this.displayMode==="verify"){return i("div",{class:"form"},i("form",{onSubmit:()=>this.handleVerification()},i("p",null,"Please check your e-mail inbox for a verification code and enter it below."),i("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),i("div",{class:"buttons"},i("verdocs-button",{label:"Sign Out",variant:"outline",disabled:this.submitting,onClick:()=>this.handleLogout()}),i("verdocs-button",{label:"Verify",disabled:this.submitting||!this.verificationCode||this.verificationCode.length!==6,onClick:()=>this.handleVerification()})),i("div",{class:"buttons"},i("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendVerification()}))))}if(this.displayMode==="forgot"){return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Forgot your password?"),i("p",null,"Enter your e-mail address below. If the e-mail address is valid, a password reset code will be sent to your inbox. Please allow up to 15 minutes to arrive, and check your spam folder if you do not receive the message."),i("form",{onSubmit:()=>this.handleResetGetCode()},i("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("div",{style:{marginTop:"30px"}}),i("div",{class:"buttons"},i("verdocs-button",{size:"small",label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),i("verdocs-button",{size:"small",label:"Request Code",disabled:this.submitting,onClick:()=>this.handleResetGetCode()}))))}if(this.displayMode==="reset"){return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Forgot your password?"),i("p",null,"Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."),i("form",{onSubmit:()=>this.handleResetPassword()},i("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"off",value:this.newPassword,onInput:e=>this.newPassword=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),i("div",{style:{marginTop:"30px"}}),i("div",{class:"buttons"},i("verdocs-button",{label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),i("verdocs-button",{label:"Reset",disabled:this.submitting,onClick:()=>this.handleResetPassword()})),i("div",{class:"buttons"},i("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendReset()}))))}return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Log in to your account"),i("div",{class:"already-have"},"Don't have an account?",i("verdocs-button",{label:"Sign Up",variant:"text",onClick:()=>this.displayMode="signup",disabled:this.submitting})),i("form",{onSubmit:()=>this.loginAndCheckVerification()},i("verdocs-text-input",{label:"Email",autocomplete:"username",value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",autocomplete:"current-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),i("verdocs-button",{label:"Forgot Your Password?",variant:"text",onClick:()=>this.displayMode="forgot",disabled:this.submitting,style:{display:"flex",justifyContent:"center",margin:"10px auto 20px"}}),i("verdocs-button",{label:"Login",disabled:this.submitting,onClick:()=>this.loginAndCheckVerification(),style:{display:"flex",justifyContent:"center",margin:"10px auto 0"}})))}static get style(){return y()}},[0,"verdocs-auth",{endpoint:[16],visible:[4],logo:[1],displayMode:[1025,"display-mode"],org_name:[32],first_name:[32],last_name:[32],email:[32],phone:[32],verificationCode:[32],newPassword:[32],password:[32],confirmpass:[32],submitting:[32],resendDisabled:[32],session:[32],profile:[32]}]);function x(){if(typeof customElements==="undefined"){return}const e=["verdocs-auth","verdocs-button","verdocs-help-icon","verdocs-text-input"];e.forEach((e=>{switch(e){case"verdocs-auth":if(!customElements.get(o(e))){customElements.define(o(e),g)}break;case"verdocs-button":if(!customElements.get(o(e))){m()}break;case"verdocs-help-icon":if(!customElements.get(o(e))){v()}break;case"verdocs-text-input":if(!customElements.get(o(e))){b()}break}}))}const w=g;const k=x;export{w as VerdocsAuth,k as defineCustomElement};
1
+ import{p as e,H as t,c as s,h as i,t as o}from"./p-yZBlG3YQ.js";import{VerdocsEndpoint as a,convertToE164 as r,createProfile as n,verifyEmail as l,authenticate as d,getMyUser as c,resendVerification as h,resetPassword as u}from"@verdocs/js-sdk";import{V as p}from"./p-D97GxsI-.js";import{S as f}from"./p-C1sRVZWv.js";import{d as m}from"./p-Bdf8pPWm.js";import{d as v}from"./p-CioaaWeS.js";import{d as b}from"./p-DYtSnUj9.js";const y=()=>`verdocs-auth{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{width:350px;display:-ms-flexbox;display:flex;padding:20px;max-width:90%;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-pack:center;justify-content:center;background:#ffffff}verdocs-auth .logo{width:128px;max-width:100%;margin:20px 0 30px}verdocs-auth h3{color:#092c4c;text-align:center;font-weight:400;font-size:18px;line-height:1.75;margin:0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{color:#092c4c;margin:1em 0;font-size:14px}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}verdocs-auth .already-have{color:#092c4c;margin:0.5em 0;font-size:14px;text-align:center}verdocs-auth .service-agreement{font-size:12px;color:#777}verdocs-auth .service-agreement a{color:#092c4c}`;const g=e(class e extends t{constructor(e){super();if(e!==false){this.__registerHost()}this.authenticated=s(this,"authenticated");this.sdkError=s(this,"sdkError");this.endpoint=a.getDefault();this.visible=true;this.logo="https://app.verdocs.com/assets/blue-logo.svg";this.displayMode="login";this.org_name="";this.first_name="";this.last_name="";this.email="";this.phone="";this.verificationCode="";this.newPassword="";this.password="";this.confirmpass="";this.submitting=false;this.resendDisabled=false;this.session=null;this.profile=null;this.resendDisabledTimer=null;this.tempAuthEndpoint=new a({baseURL:a.getDefault().getBaseURL(),persist:false});this.handleHashChange=()=>{this.applyHashDisplayMode()}}componentWillLoad(){this.endpoint.loadSession();this.applyHashDisplayMode();if(typeof window!=="undefined"){window.addEventListener("hashchange",this.handleHashChange)}a.getDefault().onSessionChanged(((e,t,s)=>{var i,o;this.session=t;this.profile=s;if(t){(i=this.authenticated)===null||i===void 0?void 0:i.emit({authenticated:true,session:t,profile:s})}else{(o=this.authenticated)===null||o===void 0?void 0:o.emit({authenticated:false,session:t,profile:s})}}))}disconnectedCallback(){if(typeof window!=="undefined"){window.removeEventListener("hashchange",this.handleHashChange)}}applyHashDisplayMode(){if(typeof window==="undefined"){return}const e=(window.location.hash||"").replace(/^#/,"").toLowerCase();if(e==="forgot"){this.displayMode="forgot"}}isPasswordComplex(e){const t=e=>/[A-Z]/.test(e);const s=e=>/[a-z]/.test(e);const i=e=>/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(e);let o=0,a=0,r=0;for(let n=0;n<e.length;n++){let l=e.charAt(n);if(t(l))o++;else if(s(l))a++;else if(i(l))r++}return e.length>=8&&a>0&&o>0&&r>0}handleSignup(){if(!this.isPasswordComplex(this.password)){p("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.password!==this.confirmpass){p("Passwords do not match.",{style:"error"});return}this.submitting=true;this.tempAuthEndpoint.clearSession();const e=r(this.phone);const t=Intl.DateTimeFormat().resolvedOptions();n(this.tempAuthEndpoint,{email:this.email,password:this.password,first_name:this.first_name,last_name:this.last_name,org_name:this.org_name,phone:e,timezone:t.timeZone,locale:t.locale}).then((e=>{console.log("[AUTH] Profile creation result",e);this.tempAuthEndpoint.setToken(e.access_token);this.password="";this.phone="";this.first_name="";this.last_name="";this.org_name="";this.displayMode="verify";this.submitting=false})).catch((e=>{var t,s,i,o,a,r;console.log("[AUTH] Signup error",e.response);this.submitting=false;(t=this.authenticated)===null||t===void 0?void 0:t.emit({authenticated:false,profile:null,session:null});(s=this.sdkError)===null||s===void 0?void 0:s.emit(new f(e.message,(i=e.response)===null||i===void 0?void 0:i.status,(o=e.response)===null||o===void 0?void 0:o.data));p("Signup failed: "+((r=(a=e.response)===null||a===void 0?void 0:a.data)===null||r===void 0?void 0:r.error)||"Unknown Error",{style:"error"})}))}async handleVerification(){this.submitting=true;try{this.submitting=false;const e=await l(this.tempAuthEndpoint,{email:this.email,token:this.verificationCode});p("Thank you for verifying your email address.",{style:"success"});this.completeLogin(e)}catch(e){this.submitting=false;console.log("Verification error",e);p("Verification error, please check the code and try again.")}}completeLogin(e){this.clearForms();this.tempAuthEndpoint.clearSession();this.endpoint.setToken(e.access_token)}async loginAndCheckVerification(){var e;if(this.submitting){return}this.submitting=true;this.tempAuthEndpoint.clearSession();try{this.submitting=false;const e=await d(this.tempAuthEndpoint,{username:this.email.trim(),password:this.password,grant_type:"password"});console.log("[AUTH] Authenticated, checking email verification");this.tempAuthEndpoint.setToken(e.access_token);const t=await c(this.tempAuthEndpoint);if(!t.email_verified){console.log("[AUTH] Logged in, pending email address verification");this.displayMode="verify"}else{console.log("[AUTH] Email address is verified, completing login");this.completeLogin(e)}}catch(t){this.submitting=false;console.log("[AUTH] Auth failure",((e=t.response)===null||e===void 0?void 0:e.data)||t);p("Login failed. Please check your credentials and try again.",{style:"error"})}}clearForms(){this.submitting=false;this.resendDisabled=false;this.email="";this.phone="";this.password="";this.newPassword="";this.confirmpass="";this.verificationCode="";this.first_name="";this.last_name="";this.org_name=""}handleLogout(){console.log("logging out");this.endpoint.clearSession();this.tempAuthEndpoint.clearSession();this.clearForms();this.displayMode="login"}handleResendVerification(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);h(this.tempAuthEndpoint).then((e=>{console.log("[AUTH] Verification request resent",e);p("Please check your email for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend verification",e);p("Unable to resend code. Please try again later.",{style:"error"})}))}handleResendReset(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);u(this.tempAuthEndpoint,{email:this.email}).then((e=>{console.log("[AUTH] Resend-code request resent",e);p("Please check your email again for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend reset request",e);p("Unable to resend code. Please try again later.",{style:"error"})}))}async handleResetGetCode(){this.submitting=true;this.confirmpass="";this.newPassword="";try{this.submitting=false;const e=await u(this.endpoint,{email:this.email});console.log("[AUTH] Reset result",e);p("Please check your email inbox for a password reset code.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.displayMode="reset"}catch(e){this.submitting=false;console.log("Reset request error",e);p("Request failed. Please check your email address and try again.")}}async handleResetPassword(){if(!this.isPasswordComplex(this.newPassword)){p("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.newPassword!==this.confirmpass){p("Passwords do not match.",{style:"error"});return}this.submitting=true;try{this.submitting=false;const e=await u(this.endpoint,{email:this.email,code:this.verificationCode,new_password:this.newPassword});console.log("reset result",e);p("Your password has been reset. You may now use your new password to login.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.password="";this.displayMode="login"}catch(e){this.submitting=false;console.log("Verification error",e);p("Verification error, please check the code and try again.")}}async handleReset(){this.submitting=true;try{const e=await u(this.endpoint,{email:this.email});console.log("[AUTH] Reset sent",e);this.submitting=false;this.displayMode="login";p("If your email address is registered, you will receive instructions on resetting your password shortly.",{style:"info"})}catch(e){console.log("[AUTH] Unable to reset password",e);this.submitting=false;p("Unable to reset password. Please check your email address and try again.",{style:"error"})}}render(){if(!this.visible){return i("div",{style:{display:"none"}},"Authenticated")}if(this.session){return i("verdocs-button",{label:"Sign Out",disabled:this.submitting,onClick:()=>this.handleLogout(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})}if(this.displayMode==="signup"){const e=this.submitting||!this.first_name||!this.last_name||!this.email||!this.password||!this.confirmpass||!this.org_name;return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Sign up for a free account"),i("div",{class:"already-have"},"Already have an account?",i("verdocs-button",{label:"Log In",variant:"text",onClick:()=>this.displayMode="login",disabled:this.submitting})),i("form",{onSubmit:()=>this.handleSignup()},i("div",{style:{display:"flex",flexDirection:"row",columnGap:"20px"}},i("verdocs-text-input",{label:"First Name",autocomplete:"first",required:true,value:this.first_name,onInput:e=>this.first_name=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Last Name",autocomplete:"last",required:true,value:this.last_name,onInput:e=>this.last_name=e.target.value,disabled:this.submitting})),i("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"new-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Phone Number",type:"tel",required:true,autocomplete:"phone",value:this.phone,onInput:e=>this.phone=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Organization Name",autocomplete:"org",required:true,value:this.org_name,onInput:e=>this.org_name=e.target.value,disabled:this.submitting,style:{flex:"1"}}),i("div",{class:"service-agreement"},"By clicking the Create Account button, you agree to the"," ",i("a",{href:"https://verdocs.com/eula",target:"_blank"},"End User License Agreement"),". Learn about how we use and protect your data and how you can opt-out in our"," ",i("a",{href:"https://verdocs.com/privacy-policy",target:"_blank"},"Privacy Policy"),"."),i("div",{style:{marginTop:"30px"}}),i("verdocs-button",{label:"Next",disabled:e,onClick:e?()=>{}:()=>this.handleSignup(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})))}if(this.displayMode==="verify"){return i("div",{class:"form"},i("form",{onSubmit:()=>this.handleVerification()},i("p",null,"Please check your e-mail inbox for a verification code and enter it below."),i("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),i("div",{class:"buttons"},i("verdocs-button",{label:"Sign Out",variant:"outline",disabled:this.submitting,onClick:()=>this.handleLogout()}),i("verdocs-button",{label:"Verify",disabled:this.submitting||!this.verificationCode||this.verificationCode.length!==6,onClick:()=>this.handleVerification()})),i("div",{class:"buttons"},i("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendVerification()}))))}if(this.displayMode==="forgot"){return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Forgot your password?"),i("p",null,"Enter your e-mail address below. If the e-mail address is valid, a password reset code will be sent to your inbox. Please allow up to 15 minutes to arrive, and check your spam folder if you do not receive the message."),i("form",{onSubmit:()=>this.handleResetGetCode()},i("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("div",{style:{marginTop:"30px"}}),i("div",{class:"buttons"},i("verdocs-button",{size:"small",label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),i("verdocs-button",{size:"small",label:"Request Code",disabled:this.submitting,onClick:()=>this.handleResetGetCode()}))))}if(this.displayMode==="reset"){return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Forgot your password?"),i("p",null,"Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."),i("form",{onSubmit:()=>this.handleResetPassword()},i("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"off",value:this.newPassword,onInput:e=>this.newPassword=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),i("div",{style:{marginTop:"30px"}}),i("div",{class:"buttons"},i("verdocs-button",{label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),i("verdocs-button",{label:"Reset",disabled:this.submitting,onClick:()=>this.handleResetPassword()})),i("div",{class:"buttons"},i("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendReset()}))))}return i("div",{class:"form"},i("a",{href:"https://verdocs.com/en/"},i("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),i("h3",null,"Log in to your account"),i("div",{class:"already-have"},"Don't have an account?",i("verdocs-button",{label:"Sign Up",variant:"text",onClick:()=>this.displayMode="signup",disabled:this.submitting})),i("form",{onSubmit:()=>this.loginAndCheckVerification()},i("verdocs-text-input",{label:"Email",autocomplete:"username",value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),i("verdocs-text-input",{label:"Password",type:"password",autocomplete:"current-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),i("verdocs-button",{label:"Forgot Your Password?",variant:"text",onClick:()=>this.displayMode="forgot",disabled:this.submitting,style:{display:"flex",justifyContent:"center",margin:"10px auto 20px"}}),i("verdocs-button",{label:"Login",disabled:this.submitting,onClick:()=>this.loginAndCheckVerification(),style:{display:"flex",justifyContent:"center",margin:"10px auto 0"}})))}static get style(){return y()}},[0,"verdocs-auth",{endpoint:[16],visible:[4],logo:[1],displayMode:[1025,"display-mode"],org_name:[32],first_name:[32],last_name:[32],email:[32],phone:[32],verificationCode:[32],newPassword:[32],password:[32],confirmpass:[32],submitting:[32],resendDisabled:[32],session:[32],profile:[32]}]);function x(){if(typeof customElements==="undefined"){return}const e=["verdocs-auth","verdocs-button","verdocs-help-icon","verdocs-text-input"];e.forEach((e=>{switch(e){case"verdocs-auth":if(!customElements.get(o(e))){customElements.define(o(e),g)}break;case"verdocs-button":if(!customElements.get(o(e))){m()}break;case"verdocs-help-icon":if(!customElements.get(o(e))){v()}break;case"verdocs-text-input":if(!customElements.get(o(e))){b()}break}}))}const w=g;const k=x;export{w as VerdocsAuth,k as defineCustomElement};
2
2
  //# sourceMappingURL=verdocs-auth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["verdocsAuthCss","VerdocsAuth","__stencil_proxyCustomElement","HTMLElement","constructor","registerHost","this","endpoint","VerdocsEndpoint","getDefault","visible","logo","displayMode","org_name","first_name","last_name","email","phone","verificationCode","newPassword","password","confirmpass","submitting","resendDisabled","session","profile","resendDisabledTimer","tempAuthEndpoint","baseURL","getBaseURL","persist","handleHashChange","applyHashDisplayMode","componentWillLoad","loadSession","window","addEventListener","onSessionChanged","_endpoint","_a","authenticated","emit","_b","disconnectedCallback","removeEventListener","hash","location","replace","toLowerCase","isPasswordComplex","isUppercase","ch","test","isLowercase","isSpecialChar","countOfUpperCase","countOfLowerCase","countOfSpecialChar","i","length","charAt","handleSignup","VerdocsToast","style","clearSession","formattedPhone","convertToE164","createProfile","then","r","console","log","setToken","access_token","catch","e","response","sdkError","SDKError","message","_c","status","_d","data","_f","_e","error","handleVerification","verificationResult","verifyEmail","token","completeLogin","result","clearForms","loginAndCheckVerification","authResult","authenticate","username","trim","grant_type","user","getMyUser","email_verified","handleLogout","handleResendVerification","setTimeout","resendVerification","handleResendReset","resetPassword","handleResetGetCode","handleResetPassword","resetResult","code","new_password","handleReset","render","h","display","label","disabled","onClick","justifyContent","margin","invalid","class","href","src","alt","variant","onSubmit","flexDirection","columnGap","autocomplete","required","value","onInput","target","type","flex","marginTop","size"],"sources":["src/components/embeds/verdocs-auth/verdocs-auth.scss?tag=verdocs-auth","src/components/embeds/verdocs-auth/verdocs-auth.tsx"],"sourcesContent":["@import '../../../theme.scss';\n\nverdocs-auth {\n font-family: $verdocs-primary-font;\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n\n .form {\n width: 350px;\n display: flex;\n padding: 20px;\n max-width: 90%;\n align-items: center;\n flex-direction: column;\n box-sizing: border-box;\n justify-content: center;\n background: $verdocs-grey-4;\n }\n\n .logo {\n width: 128px;\n max-width: 100%;\n margin: 20px 0 30px;\n }\n\n h3 {\n color: $verdocs-grey-0;\n text-align: center;\n font-weight: 400;\n font-size: 18px;\n line-height: 1.75;\n margin: 0;\n }\n\n em {\n font-size: 14px;\n margin: 15px 0;\n }\n\n .buttons {\n gap: 20px;\n margin: 20px 0 0 0;\n display: flex;\n flex-direction: row;\n justify-content: center;\n }\n\n .status-result {\n display: none;\n\n &.debug {\n white-space: pre-wrap;\n font-size: 14px;\n background: #fff;\n padding: 10px;\n display: block;\n flex-direction: row;\n justify-content: center;\n }\n }\n\n form {\n width: 100%;\n }\n\n verdocs-text-input {\n margin-bottom: 10px;\n }\n\n .account-option {\n gap: 8px;\n margin: 20px 0 8px 0;\n display: flex;\n flex-direction: row;\n }\n\n p {\n color: $verdocs-grey-0;\n margin: 1em 0;\n font-size: 14px;\n }\n\n // Our <p>s are in a flex layout which prevents margins from collapsing because each item creates its own row\n p + p {\n margin-top: 0;\n }\n\n verdocs-help-icon {\n margin-top: 18px;\n display: flex;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n }\n\n .already-have {\n color: $verdocs-grey-0;\n margin: 0.5em 0;\n font-size: 14px;\n text-align: center;\n }\n\n .service-agreement {\n font-size: 12px;\n color: #777;\n\n a {\n color: $verdocs-grey-0;\n }\n }\n}\n","import {Component, Prop, State, h, Event, EventEmitter} from '@stencil/core';\nimport {verifyEmail, IAuthenticateResponse, getMyUser, IProfile, convertToE164} from '@verdocs/js-sdk';\nimport {TSession, VerdocsEndpoint, createProfile, authenticate, resendVerification, resetPassword} from '@verdocs/js-sdk';\nimport {VerdocsToast} from '../../../utils/Toast';\nimport {SDKError} from '../../../utils/errors';\n\nexport interface IAuthStatus {\n authenticated: boolean;\n session: TSession;\n profile: IProfile | null;\n}\n\n/**\n * Display an authentication dialog that allows the user to login or sign up. If the user is\n * already authenticated with a valid session, this component will hide itself and fire the\n * success callback immediately. It is up to the host application to render the next appropriate\n * view for the application.\n *\n * To simplify UI development, a visibility flag can force this component to never display. This\n * allows you to subscribe to notifications from client apps without calling the lower-level JS SDK.\n *\n * This embed is responsive / mobile-friendly, but the calling application should provide at\n * least a 300px wide container to allow sufficient space for the required forms.\n *\n * ```ts\n * <verdocs-auth\n * onAuthenticated={({ detail }) => console.log('Authentication state:', detail) }\n * onSdkError={({ detail }) => { console.log('SDK error', detail) }\n * />\n * ```\n */\n@Component({\n tag: 'verdocs-auth',\n styleUrl: 'verdocs-auth.scss',\n shadow: false,\n})\nexport class VerdocsAuth {\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * Normally, if the user has a valid session, this embed will be invisible, otherwise it will display\n * login / signup forms. If this is set to false, this embed will be invisible in both cases. Apps may\n * use this to verify if a user has a valid session without needing a separate call to Verdocs JS SDK.\n */\n @Prop() visible: boolean = true;\n\n /**\n * By default, a Verdocs logo will be displayed above the login/signup forms. This may be used to\n * override its source. (Alternatively, you may simply hide it via CSS overrides.) Logos should be\n * in SVG format for best results.\n */\n @Prop() logo: string = 'https://app.verdocs.com/assets/blue-logo.svg';\n\n /**\n * The display mode to start in.\n */\n @Prop({mutable: true}) displayMode: 'login' | 'forgot' | 'reset' | 'signup' | 'verify' = 'login';\n\n /**\n * Event fired when session authentication process has completed. Check the event\n * contents for completion status. This event will always be called at least once,\n * when the component is first rendered.\n */\n @Event({composed: true}) authenticated: EventEmitter<IAuthStatus>;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n @State() org_name: string = '';\n @State() first_name: string = '';\n @State() last_name: string = '';\n @State() email: string = '';\n @State() phone: string = '';\n @State() verificationCode: string = '';\n @State() newPassword: string = '';\n @State() password: string = '';\n @State() confirmpass: string = '';\n @State() submitting: boolean = false;\n @State() resendDisabled = false;\n @State() session: TSession = null;\n @State() profile: IProfile | null = null;\n\n resendDisabledTimer = null;\n\n // We can't instantly log in on the default endpoint because other listeners might see\n // its events and incorrectly trigger before we're done. So we manage our own temp\n // endpoint and pass the final tokens to the default once we're ready.\n tempAuthEndpoint = new VerdocsEndpoint({\n baseURL: VerdocsEndpoint.getDefault().getBaseURL(),\n persist: false,\n });\n\n componentWillLoad() {\n this.endpoint.loadSession();\n this.applyHashDisplayMode();\n\n // We need to listen to the hashchange to know when we're being sent to #forgot\n if (typeof window !== 'undefined') {\n window.addEventListener('hashchange', this.handleHashChange);\n }\n\n VerdocsEndpoint.getDefault().onSessionChanged((_endpoint, session, profile) => {\n this.session = session;\n this.profile = profile;\n if (session) {\n this.authenticated?.emit({authenticated: true, session, profile});\n } else {\n this.authenticated?.emit({authenticated: false, session, profile});\n }\n });\n }\n\n disconnectedCallback() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('hashchange', this.handleHashChange);\n }\n }\n\n handleHashChange = () => {\n this.applyHashDisplayMode();\n };\n\n applyHashDisplayMode() {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hash = (window.location.hash || '').replace(/^#/, '').toLowerCase();\n if (hash === 'forgot') {\n this.displayMode = 'forgot';\n }\n }\n\n isPasswordComplex(password: string) {\n const isUppercase = (ch: string) => /[A-Z]/.test(ch);\n const isLowercase = (ch: string) => /[a-z]/.test(ch);\n const isSpecialChar = (ch: string) => /[`!@#$%^&*()_\\-+=\\[\\]{};':\"\\\\|,.<>\\/?~ ]/.test(ch);\n let countOfUpperCase = 0,\n countOfLowerCase = 0,\n countOfSpecialChar = 0;\n for (let i = 0; i < password.length; i++) {\n let ch = password.charAt(i);\n if (isUppercase(ch)) countOfUpperCase++;\n else if (isLowercase(ch)) countOfLowerCase++;\n else if (isSpecialChar(ch)) countOfSpecialChar++;\n }\n return password.length >= 8 && countOfLowerCase > 0 && countOfUpperCase > 0 && countOfSpecialChar > 0;\n }\n\n handleSignup() {\n if (!this.isPasswordComplex(this.password)) {\n VerdocsToast('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.', {style: 'error'});\n return;\n }\n\n if (this.password !== this.confirmpass) {\n VerdocsToast('Passwords do not match.', {style: 'error'});\n return;\n }\n\n this.submitting = true;\n this.tempAuthEndpoint.clearSession();\n const formattedPhone = convertToE164(this.phone);\n\n createProfile(this.tempAuthEndpoint, {\n email: this.email,\n password: this.password,\n first_name: this.first_name,\n last_name: this.last_name,\n org_name: this.org_name,\n phone: formattedPhone,\n })\n .then(r => {\n console.log('[AUTH] Profile creation result', r);\n this.tempAuthEndpoint.setToken(r.access_token);\n // We can't clearForms because we need email to stick around\n this.password = '';\n this.phone = '';\n this.first_name = '';\n this.last_name = '';\n this.org_name = '';\n this.displayMode = 'verify';\n this.submitting = false;\n })\n .catch(e => {\n console.log('[AUTH] Signup error', e.response);\n this.submitting = false;\n this.authenticated?.emit({authenticated: false, profile: null, session: null});\n this.sdkError?.emit(new SDKError(e.message, e.response?.status, e.response?.data));\n\n VerdocsToast('Signup failed: ' + e.response?.data?.error || 'Unknown Error', {style: 'error'});\n });\n }\n\n async handleVerification() {\n this.submitting = true;\n\n try {\n this.submitting = false;\n const verificationResult = await verifyEmail(this.tempAuthEndpoint, {email: this.email, token: this.verificationCode});\n VerdocsToast('Thank you for verifying your email address.', {style: 'success'});\n this.completeLogin(verificationResult);\n } catch (e) {\n this.submitting = false;\n console.log('Verification error', e);\n VerdocsToast('Verification error, please check the code and try again.');\n }\n }\n\n completeLogin(result: IAuthenticateResponse) {\n this.clearForms();\n this.tempAuthEndpoint.clearSession();\n this.endpoint.setToken(result.access_token);\n }\n\n async loginAndCheckVerification() {\n if (this.submitting) {\n return;\n }\n\n this.submitting = true;\n this.tempAuthEndpoint.clearSession();\n\n try {\n this.submitting = false;\n const authResult = await authenticate(this.tempAuthEndpoint, {username: this.email.trim(), password: this.password, grant_type: 'password'});\n console.log('[AUTH] Authenticated, checking email verification');\n this.tempAuthEndpoint.setToken(authResult.access_token);\n\n const user = await getMyUser(this.tempAuthEndpoint);\n\n if (!user.email_verified) {\n console.log('[AUTH] Logged in, pending email address verification');\n this.displayMode = 'verify';\n } else {\n console.log('[AUTH] Email address is verified, completing login');\n this.completeLogin(authResult);\n }\n } catch (e) {\n this.submitting = false;\n console.log('[AUTH] Auth failure', e.response?.data || e);\n VerdocsToast('Login failed. Please check your credentials and try again.', {style: 'error'});\n }\n }\n\n clearForms() {\n this.submitting = false;\n this.resendDisabled = false;\n this.email = '';\n this.phone = '';\n this.password = '';\n this.newPassword = '';\n this.confirmpass = '';\n this.verificationCode = '';\n this.first_name = '';\n this.last_name = '';\n this.org_name = '';\n }\n\n handleLogout() {\n console.log('logging out');\n this.endpoint.clearSession();\n this.tempAuthEndpoint.clearSession();\n this.clearForms();\n this.displayMode = 'login';\n }\n\n handleResendVerification() {\n // Avoid the user just click-spamming this pathway. The server rate-limits this anyway so it's not a\n // security issue but it's a poor user experience to allow it.\n this.resendDisabled = true;\n this.resendDisabledTimer = setTimeout(() => {\n this.resendDisabled = false;\n this.resendDisabledTimer = null;\n }, 30000);\n\n resendVerification(this.tempAuthEndpoint)\n .then(r => {\n console.log('[AUTH] Verification request resent', r);\n VerdocsToast('Please check your email for a verification code.', {style: 'info'});\n })\n .catch((e: any) => {\n console.log('[AUTH] Unable to resend verification', e);\n VerdocsToast('Unable to resend code. Please try again later.', {style: 'error'});\n });\n }\n\n handleResendReset() {\n // Avoid the user just click-spamming this pathway. The server rate-limits this anyway so it's not a\n // security issue but it's a poor user experience to allow it.\n this.resendDisabled = true;\n this.resendDisabledTimer = setTimeout(() => {\n this.resendDisabled = false;\n this.resendDisabledTimer = null;\n }, 30000);\n\n resetPassword(this.tempAuthEndpoint, {email: this.email})\n .then(r => {\n console.log('[AUTH] Resend-code request resent', r);\n VerdocsToast('Please check your email again for a verification code.', {style: 'info'});\n })\n .catch((e: any) => {\n console.log('[AUTH] Unable to resend reset request', e);\n VerdocsToast('Unable to resend code. Please try again later.', {style: 'error'});\n });\n }\n\n async handleResetGetCode() {\n this.submitting = true;\n this.confirmpass = '';\n this.newPassword = '';\n\n try {\n this.submitting = false;\n const result = await resetPassword(this.endpoint, {email: this.email});\n console.log('[AUTH] Reset result', result);\n VerdocsToast('Please check your email inbox for a password reset code.', {style: 'success'});\n this.verificationCode = '';\n this.confirmpass = '';\n this.newPassword = '';\n this.displayMode = 'reset';\n } catch (e) {\n this.submitting = false;\n console.log('Reset request error', e);\n VerdocsToast('Request failed. Please check your email address and try again.');\n }\n }\n\n async handleResetPassword() {\n if (!this.isPasswordComplex(this.newPassword)) {\n VerdocsToast('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.', {style: 'error'});\n return;\n }\n\n if (this.newPassword !== this.confirmpass) {\n VerdocsToast('Passwords do not match.', {style: 'error'});\n return;\n }\n\n this.submitting = true;\n try {\n this.submitting = false;\n const resetResult = await resetPassword(this.endpoint, {email: this.email, code: this.verificationCode, new_password: this.newPassword});\n console.log('reset result', resetResult);\n VerdocsToast('Your password has been reset. You may now use your new password to login.', {style: 'success'});\n this.verificationCode = '';\n this.confirmpass = '';\n this.newPassword = '';\n this.password = '';\n this.displayMode = 'login';\n } catch (e) {\n this.submitting = false;\n console.log('Verification error', e);\n VerdocsToast('Verification error, please check the code and try again.');\n }\n }\n\n async handleReset() {\n this.submitting = true;\n\n try {\n const result = await resetPassword(this.endpoint, {email: this.email});\n console.log('[AUTH] Reset sent', result);\n this.submitting = false;\n this.displayMode = 'login';\n VerdocsToast('If your email address is registered, you will receive instructions on resetting your password shortly.', {style: 'info'});\n } catch (e) {\n console.log('[AUTH] Unable to reset password', e);\n this.submitting = false;\n VerdocsToast('Unable to reset password. Please check your email address and try again.', {style: 'error'});\n }\n }\n\n render() {\n if (!this.visible) {\n return <div style={{display: 'none'}}>Authenticated</div>;\n }\n\n if (this.session) {\n return (\n <verdocs-button\n label=\"Sign Out\"\n disabled={this.submitting}\n onClick={() => this.handleLogout()}\n style={{display: 'flex', justifyContent: 'center', margin: '30px auto 0'}}\n />\n );\n }\n\n if (this.displayMode === 'signup') {\n const invalid = this.submitting || !this.first_name || !this.last_name || !this.email || !this.password || !this.confirmpass || !this.org_name;\n\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Sign up for a free account</h3>\n <div class=\"already-have\">\n Already have an account?\n <verdocs-button label=\"Log In\" variant=\"text\" onClick={() => (this.displayMode = 'login')} disabled={this.submitting} />\n </div>\n\n <form onSubmit={() => this.handleSignup()}>\n <div style={{display: 'flex', flexDirection: 'row', columnGap: '20px'}}>\n <verdocs-text-input\n label=\"First Name\"\n autocomplete=\"first\"\n required={true}\n value={this.first_name}\n onInput={(e: any) => (this.first_name = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Last Name\"\n autocomplete=\"last\"\n required={true}\n value={this.last_name}\n onInput={(e: any) => (this.last_name = e.target.value)}\n disabled={this.submitting}\n />\n </div>\n <verdocs-text-input\n label=\"Email Address\"\n autocomplete=\"email\"\n required={true}\n value={this.email}\n onInput={(e: any) => (this.email = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n required={true}\n autocomplete=\"new-password\"\n value={this.password}\n onInput={(e: any) => (this.password = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Confirm Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.confirmpass}\n onInput={(e: any) => (this.confirmpass = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Phone Number\"\n type=\"tel\"\n required={true}\n autocomplete=\"phone\"\n value={this.phone}\n onInput={(e: any) => (this.phone = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Organization Name\"\n autocomplete=\"org\"\n required={true}\n value={this.org_name}\n onInput={(e: any) => (this.org_name = e.target.value)}\n disabled={this.submitting}\n style={{flex: '1'}}\n />\n\n <div class=\"service-agreement\">\n By clicking the Create Account button, you agree to the{' '}\n <a href=\"https://verdocs.com/eula\" target=\"_blank\">\n End User License Agreement\n </a>\n . Learn about how we use and protect your data and how you can opt-out in our{' '}\n <a href=\"https://verdocs.com/privacy-policy\" target=\"_blank\">\n Privacy Policy\n </a>\n .\n </div>\n\n <div style={{marginTop: '30px'}} />\n\n <verdocs-button\n label=\"Next\"\n disabled={invalid}\n onClick={invalid ? () => {} : () => this.handleSignup()}\n style={{display: 'flex', justifyContent: 'center', margin: '30px auto 0'}}\n />\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'verify') {\n return (\n <div class=\"form\">\n <form onSubmit={() => this.handleVerification()}>\n <p>Please check your e-mail inbox for a verification code and enter it below.</p>\n\n <verdocs-text-input\n label=\"Verification Code\"\n required={true}\n value={this.verificationCode}\n onInput={(e: any) => (this.verificationCode = e.target.value)}\n disabled={this.submitting}\n />\n\n <div class=\"buttons\">\n <verdocs-button label=\"Sign Out\" variant=\"outline\" disabled={this.submitting} onClick={() => this.handleLogout()} />\n <verdocs-button label=\"Verify\" disabled={this.submitting || !this.verificationCode || this.verificationCode.length !== 6} onClick={() => this.handleVerification()} />\n </div>\n <div class=\"buttons\">\n <verdocs-button variant=\"text\" label=\"Resend Code\" disabled={this.resendDisabled || this.submitting} onClick={() => this.handleResendVerification()} />\n </div>\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'forgot') {\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Forgot your password?</h3>\n\n <p>\n Enter your e-mail address below. If the e-mail address is valid, a password reset code will be sent to your inbox. Please allow up to 15 minutes to arrive, and check\n your spam folder if you do not receive the message.\n </p>\n\n <form onSubmit={() => this.handleResetGetCode()}>\n <verdocs-text-input\n label=\"Email Address\"\n autocomplete=\"email\"\n required={true}\n value={this.email}\n onInput={(e: any) => (this.email = e.target.value)}\n disabled={this.submitting}\n />\n\n <div style={{marginTop: '30px'}} />\n\n <div class=\"buttons\">\n <verdocs-button size=\"small\" label=\"Cancel\" variant=\"outline\" disabled={this.submitting} onClick={() => (this.displayMode = 'login')} />\n <verdocs-button size=\"small\" label=\"Request Code\" disabled={this.submitting} onClick={() => this.handleResetGetCode()} />\n </div>\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'reset') {\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Forgot your password?</h3>\n\n <p>\n Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not\n receive the message.\n </p>\n\n <form onSubmit={() => this.handleResetPassword()}>\n <verdocs-text-input\n label=\"Verification Code\"\n required={true}\n value={this.verificationCode}\n onInput={(e: any) => (this.verificationCode = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.newPassword}\n onInput={(e: any) => (this.newPassword = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Confirm Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.confirmpass}\n onInput={(e: any) => (this.confirmpass = e.target.value)}\n disabled={this.submitting}\n />\n\n <div style={{marginTop: '30px'}} />\n\n <div class=\"buttons\">\n <verdocs-button label=\"Cancel\" variant=\"outline\" disabled={this.submitting} onClick={() => (this.displayMode = 'login')} />\n <verdocs-button label=\"Reset\" disabled={this.submitting} onClick={() => this.handleResetPassword()} />\n </div>\n\n <div class=\"buttons\">\n <verdocs-button variant=\"text\" label=\"Resend Code\" disabled={this.resendDisabled || this.submitting} onClick={() => this.handleResendReset()} />\n </div>\n </form>\n </div>\n );\n }\n\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Log in to your account</h3>\n <div class=\"already-have\">\n Don't have an account?\n <verdocs-button label=\"Sign Up\" variant=\"text\" onClick={() => (this.displayMode = 'signup')} disabled={this.submitting} />\n </div>\n\n <form onSubmit={() => this.loginAndCheckVerification()}>\n <verdocs-text-input label=\"Email\" autocomplete=\"username\" value={this.email} onInput={(e: any) => (this.email = e.target.value)} disabled={this.submitting} />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n autocomplete=\"current-password\"\n value={this.password}\n onInput={(e: any) => (this.password = e.target.value)}\n disabled={this.submitting}\n />\n\n <verdocs-button\n label=\"Forgot Your Password?\"\n variant=\"text\"\n onClick={() => (this.displayMode = 'forgot')}\n disabled={this.submitting}\n style={{display: 'flex', justifyContent: 'center', margin: '10px auto 20px'}}\n />\n\n <verdocs-button\n label=\"Login\"\n disabled={this.submitting}\n onClick={() => this.loginAndCheckVerification()}\n style={{display: 'flex', justifyContent: 'center', margin: '10px auto 0'}}\n />\n </form>\n </div>\n );\n }\n}\n"],"mappings":"yaAAA,MAAMA,EAAiB,IAAM,wwD,MCoChBC,EAAWC,EAAA,MAAAD,UAAAE,EALxB,WAAAC,CAAAC,G,wHASUC,KAAAC,SAA4BC,EAAgBC,aAO5CH,KAAAI,QAAmB,KAOnBJ,KAAAK,KAAe,+CAKAL,KAAAM,YAAkE,QAehFN,KAAAO,SAAmB,GACnBP,KAAAQ,WAAqB,GACrBR,KAAAS,UAAoB,GACpBT,KAAAU,MAAgB,GAChBV,KAAAW,MAAgB,GAChBX,KAAAY,iBAA2B,GAC3BZ,KAAAa,YAAsB,GACtBb,KAAAc,SAAmB,GACnBd,KAAAe,YAAsB,GACtBf,KAAAgB,WAAsB,MACtBhB,KAAAiB,eAAiB,MACjBjB,KAAAkB,QAAoB,KACpBlB,KAAAmB,QAA2B,KAEpCnB,KAAAoB,oBAAsB,KAKtBpB,KAAAqB,iBAAmB,IAAInB,EAAgB,CACrCoB,QAASpB,EAAgBC,aAAaoB,aACtCC,QAAS,QA6BXxB,KAAAyB,iBAAmB,KACjBzB,KAAK0B,sBAAsB,CAohB9B,CA/iBC,iBAAAC,GACE3B,KAAKC,SAAS2B,cACd5B,KAAK0B,uBAGL,UAAWG,SAAW,YAAa,CACjCA,OAAOC,iBAAiB,aAAc9B,KAAKyB,iB,CAG7CvB,EAAgBC,aAAa4B,kBAAiB,CAACC,EAAWd,EAASC,K,QACjEnB,KAAKkB,QAAUA,EACflB,KAAKmB,QAAUA,EACf,GAAID,EAAS,EACXe,EAAAjC,KAAKkC,iBAAa,MAAAD,SAAA,SAAAA,EAAEE,KAAK,CAACD,cAAe,KAAMhB,UAASC,W,KACnD,EACLiB,EAAApC,KAAKkC,iBAAa,MAAAE,SAAA,SAAAA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EAAA,kBACEE,MAAM,QACNC,SAAUjH,KAAKgB,WACfkG,QAAS,IAAMlH,KAAKwF,4BACpB/B,MAAO,CAACsD,QAAS,OAAQI,eAAgB,SAAUC,OAAQ,kB","ignoreList":[]}
1
+ {"version":3,"names":["verdocsAuthCss","VerdocsAuth","__stencil_proxyCustomElement","HTMLElement","constructor","registerHost","this","endpoint","VerdocsEndpoint","getDefault","visible","logo","displayMode","org_name","first_name","last_name","email","phone","verificationCode","newPassword","password","confirmpass","submitting","resendDisabled","session","profile","resendDisabledTimer","tempAuthEndpoint","baseURL","getBaseURL","persist","handleHashChange","applyHashDisplayMode","componentWillLoad","loadSession","window","addEventListener","onSessionChanged","_endpoint","_a","authenticated","emit","_b","disconnectedCallback","removeEventListener","hash","location","replace","toLowerCase","isPasswordComplex","isUppercase","ch","test","isLowercase","isSpecialChar","countOfUpperCase","countOfLowerCase","countOfSpecialChar","i","length","charAt","handleSignup","VerdocsToast","style","clearSession","formattedPhone","convertToE164","localeData","Intl","DateTimeFormat","resolvedOptions","createProfile","timezone","timeZone","locale","then","r","console","log","setToken","access_token","catch","e","response","sdkError","SDKError","message","_c","status","_d","data","_f","_e","error","handleVerification","verificationResult","verifyEmail","token","completeLogin","result","clearForms","loginAndCheckVerification","authResult","authenticate","username","trim","grant_type","user","getMyUser","email_verified","handleLogout","handleResendVerification","setTimeout","resendVerification","handleResendReset","resetPassword","handleResetGetCode","handleResetPassword","resetResult","code","new_password","handleReset","render","h","display","label","disabled","onClick","justifyContent","margin","invalid","class","href","src","alt","variant","onSubmit","flexDirection","columnGap","autocomplete","required","value","onInput","target","type","flex","marginTop","size"],"sources":["src/components/embeds/verdocs-auth/verdocs-auth.scss?tag=verdocs-auth","src/components/embeds/verdocs-auth/verdocs-auth.tsx"],"sourcesContent":["@import '../../../theme.scss';\n\nverdocs-auth {\n font-family: $verdocs-primary-font;\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n\n .form {\n width: 350px;\n display: flex;\n padding: 20px;\n max-width: 90%;\n align-items: center;\n flex-direction: column;\n box-sizing: border-box;\n justify-content: center;\n background: $verdocs-grey-4;\n }\n\n .logo {\n width: 128px;\n max-width: 100%;\n margin: 20px 0 30px;\n }\n\n h3 {\n color: $verdocs-grey-0;\n text-align: center;\n font-weight: 400;\n font-size: 18px;\n line-height: 1.75;\n margin: 0;\n }\n\n em {\n font-size: 14px;\n margin: 15px 0;\n }\n\n .buttons {\n gap: 20px;\n margin: 20px 0 0 0;\n display: flex;\n flex-direction: row;\n justify-content: center;\n }\n\n .status-result {\n display: none;\n\n &.debug {\n white-space: pre-wrap;\n font-size: 14px;\n background: #fff;\n padding: 10px;\n display: block;\n flex-direction: row;\n justify-content: center;\n }\n }\n\n form {\n width: 100%;\n }\n\n verdocs-text-input {\n margin-bottom: 10px;\n }\n\n .account-option {\n gap: 8px;\n margin: 20px 0 8px 0;\n display: flex;\n flex-direction: row;\n }\n\n p {\n color: $verdocs-grey-0;\n margin: 1em 0;\n font-size: 14px;\n }\n\n // Our <p>s are in a flex layout which prevents margins from collapsing because each item creates its own row\n p + p {\n margin-top: 0;\n }\n\n verdocs-help-icon {\n margin-top: 18px;\n display: flex;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n }\n\n .already-have {\n color: $verdocs-grey-0;\n margin: 0.5em 0;\n font-size: 14px;\n text-align: center;\n }\n\n .service-agreement {\n font-size: 12px;\n color: #777;\n\n a {\n color: $verdocs-grey-0;\n }\n }\n}\n","import {Component, Prop, State, h, Event, EventEmitter} from '@stencil/core';\nimport {verifyEmail, IAuthenticateResponse, getMyUser, IProfile, convertToE164} from '@verdocs/js-sdk';\nimport {TSession, VerdocsEndpoint, createProfile, authenticate, resendVerification, resetPassword} from '@verdocs/js-sdk';\nimport {VerdocsToast} from '../../../utils/Toast';\nimport {SDKError} from '../../../utils/errors';\n\nexport interface IAuthStatus {\n authenticated: boolean;\n session: TSession;\n profile: IProfile | null;\n}\n\n/**\n * Display an authentication dialog that allows the user to login or sign up. If the user is\n * already authenticated with a valid session, this component will hide itself and fire the\n * success callback immediately. It is up to the host application to render the next appropriate\n * view for the application.\n *\n * To simplify UI development, a visibility flag can force this component to never display. This\n * allows you to subscribe to notifications from client apps without calling the lower-level JS SDK.\n *\n * This embed is responsive / mobile-friendly, but the calling application should provide at\n * least a 300px wide container to allow sufficient space for the required forms.\n *\n * ```ts\n * <verdocs-auth\n * onAuthenticated={({ detail }) => console.log('Authentication state:', detail) }\n * onSdkError={({ detail }) => { console.log('SDK error', detail) }\n * />\n * ```\n */\n@Component({\n tag: 'verdocs-auth',\n styleUrl: 'verdocs-auth.scss',\n shadow: false,\n})\nexport class VerdocsAuth {\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * Normally, if the user has a valid session, this embed will be invisible, otherwise it will display\n * login / signup forms. If this is set to false, this embed will be invisible in both cases. Apps may\n * use this to verify if a user has a valid session without needing a separate call to Verdocs JS SDK.\n */\n @Prop() visible: boolean = true;\n\n /**\n * By default, a Verdocs logo will be displayed above the login/signup forms. This may be used to\n * override its source. (Alternatively, you may simply hide it via CSS overrides.) Logos should be\n * in SVG format for best results.\n */\n @Prop() logo: string = 'https://app.verdocs.com/assets/blue-logo.svg';\n\n /**\n * The display mode to start in.\n */\n @Prop({mutable: true}) displayMode: 'login' | 'forgot' | 'reset' | 'signup' | 'verify' = 'login';\n\n /**\n * Event fired when session authentication process has completed. Check the event\n * contents for completion status. This event will always be called at least once,\n * when the component is first rendered.\n */\n @Event({composed: true}) authenticated: EventEmitter<IAuthStatus>;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n @State() org_name: string = '';\n @State() first_name: string = '';\n @State() last_name: string = '';\n @State() email: string = '';\n @State() phone: string = '';\n @State() verificationCode: string = '';\n @State() newPassword: string = '';\n @State() password: string = '';\n @State() confirmpass: string = '';\n @State() submitting: boolean = false;\n @State() resendDisabled = false;\n @State() session: TSession = null;\n @State() profile: IProfile | null = null;\n\n resendDisabledTimer = null;\n\n // We can't instantly log in on the default endpoint because other listeners might see\n // its events and incorrectly trigger before we're done. So we manage our own temp\n // endpoint and pass the final tokens to the default once we're ready.\n tempAuthEndpoint = new VerdocsEndpoint({\n baseURL: VerdocsEndpoint.getDefault().getBaseURL(),\n persist: false,\n });\n\n componentWillLoad() {\n this.endpoint.loadSession();\n this.applyHashDisplayMode();\n\n // We need to listen to the hashchange to know when we're being sent to #forgot\n if (typeof window !== 'undefined') {\n window.addEventListener('hashchange', this.handleHashChange);\n }\n\n VerdocsEndpoint.getDefault().onSessionChanged((_endpoint, session, profile) => {\n this.session = session;\n this.profile = profile;\n if (session) {\n this.authenticated?.emit({authenticated: true, session, profile});\n } else {\n this.authenticated?.emit({authenticated: false, session, profile});\n }\n });\n }\n\n disconnectedCallback() {\n if (typeof window !== 'undefined') {\n window.removeEventListener('hashchange', this.handleHashChange);\n }\n }\n\n handleHashChange = () => {\n this.applyHashDisplayMode();\n };\n\n applyHashDisplayMode() {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hash = (window.location.hash || '').replace(/^#/, '').toLowerCase();\n if (hash === 'forgot') {\n this.displayMode = 'forgot';\n }\n }\n\n isPasswordComplex(password: string) {\n const isUppercase = (ch: string) => /[A-Z]/.test(ch);\n const isLowercase = (ch: string) => /[a-z]/.test(ch);\n const isSpecialChar = (ch: string) => /[`!@#$%^&*()_\\-+=\\[\\]{};':\"\\\\|,.<>\\/?~ ]/.test(ch);\n let countOfUpperCase = 0,\n countOfLowerCase = 0,\n countOfSpecialChar = 0;\n for (let i = 0; i < password.length; i++) {\n let ch = password.charAt(i);\n if (isUppercase(ch)) countOfUpperCase++;\n else if (isLowercase(ch)) countOfLowerCase++;\n else if (isSpecialChar(ch)) countOfSpecialChar++;\n }\n return password.length >= 8 && countOfLowerCase > 0 && countOfUpperCase > 0 && countOfSpecialChar > 0;\n }\n\n handleSignup() {\n if (!this.isPasswordComplex(this.password)) {\n VerdocsToast('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.', {style: 'error'});\n return;\n }\n\n if (this.password !== this.confirmpass) {\n VerdocsToast('Passwords do not match.', {style: 'error'});\n return;\n }\n\n this.submitting = true;\n this.tempAuthEndpoint.clearSession();\n const formattedPhone = convertToE164(this.phone);\n const localeData = Intl.DateTimeFormat().resolvedOptions();\n\n createProfile(this.tempAuthEndpoint, {\n email: this.email,\n password: this.password,\n first_name: this.first_name,\n last_name: this.last_name,\n org_name: this.org_name,\n phone: formattedPhone,\n timezone: localeData.timeZone,\n locale: localeData.locale,\n })\n .then(r => {\n console.log('[AUTH] Profile creation result', r);\n this.tempAuthEndpoint.setToken(r.access_token);\n // We can't clearForms because we need email to stick around\n this.password = '';\n this.phone = '';\n this.first_name = '';\n this.last_name = '';\n this.org_name = '';\n this.displayMode = 'verify';\n this.submitting = false;\n })\n .catch(e => {\n console.log('[AUTH] Signup error', e.response);\n this.submitting = false;\n this.authenticated?.emit({authenticated: false, profile: null, session: null});\n this.sdkError?.emit(new SDKError(e.message, e.response?.status, e.response?.data));\n\n VerdocsToast('Signup failed: ' + e.response?.data?.error || 'Unknown Error', {style: 'error'});\n });\n }\n\n async handleVerification() {\n this.submitting = true;\n\n try {\n this.submitting = false;\n const verificationResult = await verifyEmail(this.tempAuthEndpoint, {email: this.email, token: this.verificationCode});\n VerdocsToast('Thank you for verifying your email address.', {style: 'success'});\n this.completeLogin(verificationResult);\n } catch (e) {\n this.submitting = false;\n console.log('Verification error', e);\n VerdocsToast('Verification error, please check the code and try again.');\n }\n }\n\n completeLogin(result: IAuthenticateResponse) {\n this.clearForms();\n this.tempAuthEndpoint.clearSession();\n this.endpoint.setToken(result.access_token);\n }\n\n async loginAndCheckVerification() {\n if (this.submitting) {\n return;\n }\n\n this.submitting = true;\n this.tempAuthEndpoint.clearSession();\n\n try {\n this.submitting = false;\n const authResult = await authenticate(this.tempAuthEndpoint, {username: this.email.trim(), password: this.password, grant_type: 'password'});\n console.log('[AUTH] Authenticated, checking email verification');\n this.tempAuthEndpoint.setToken(authResult.access_token);\n\n const user = await getMyUser(this.tempAuthEndpoint);\n\n if (!user.email_verified) {\n console.log('[AUTH] Logged in, pending email address verification');\n this.displayMode = 'verify';\n } else {\n console.log('[AUTH] Email address is verified, completing login');\n this.completeLogin(authResult);\n }\n } catch (e) {\n this.submitting = false;\n console.log('[AUTH] Auth failure', e.response?.data || e);\n VerdocsToast('Login failed. Please check your credentials and try again.', {style: 'error'});\n }\n }\n\n clearForms() {\n this.submitting = false;\n this.resendDisabled = false;\n this.email = '';\n this.phone = '';\n this.password = '';\n this.newPassword = '';\n this.confirmpass = '';\n this.verificationCode = '';\n this.first_name = '';\n this.last_name = '';\n this.org_name = '';\n }\n\n handleLogout() {\n console.log('logging out');\n this.endpoint.clearSession();\n this.tempAuthEndpoint.clearSession();\n this.clearForms();\n this.displayMode = 'login';\n }\n\n handleResendVerification() {\n // Avoid the user just click-spamming this pathway. The server rate-limits this anyway so it's not a\n // security issue but it's a poor user experience to allow it.\n this.resendDisabled = true;\n this.resendDisabledTimer = setTimeout(() => {\n this.resendDisabled = false;\n this.resendDisabledTimer = null;\n }, 30000);\n\n resendVerification(this.tempAuthEndpoint)\n .then(r => {\n console.log('[AUTH] Verification request resent', r);\n VerdocsToast('Please check your email for a verification code.', {style: 'info'});\n })\n .catch((e: any) => {\n console.log('[AUTH] Unable to resend verification', e);\n VerdocsToast('Unable to resend code. Please try again later.', {style: 'error'});\n });\n }\n\n handleResendReset() {\n // Avoid the user just click-spamming this pathway. The server rate-limits this anyway so it's not a\n // security issue but it's a poor user experience to allow it.\n this.resendDisabled = true;\n this.resendDisabledTimer = setTimeout(() => {\n this.resendDisabled = false;\n this.resendDisabledTimer = null;\n }, 30000);\n\n resetPassword(this.tempAuthEndpoint, {email: this.email})\n .then(r => {\n console.log('[AUTH] Resend-code request resent', r);\n VerdocsToast('Please check your email again for a verification code.', {style: 'info'});\n })\n .catch((e: any) => {\n console.log('[AUTH] Unable to resend reset request', e);\n VerdocsToast('Unable to resend code. Please try again later.', {style: 'error'});\n });\n }\n\n async handleResetGetCode() {\n this.submitting = true;\n this.confirmpass = '';\n this.newPassword = '';\n\n try {\n this.submitting = false;\n const result = await resetPassword(this.endpoint, {email: this.email});\n console.log('[AUTH] Reset result', result);\n VerdocsToast('Please check your email inbox for a password reset code.', {style: 'success'});\n this.verificationCode = '';\n this.confirmpass = '';\n this.newPassword = '';\n this.displayMode = 'reset';\n } catch (e) {\n this.submitting = false;\n console.log('Reset request error', e);\n VerdocsToast('Request failed. Please check your email address and try again.');\n }\n }\n\n async handleResetPassword() {\n if (!this.isPasswordComplex(this.newPassword)) {\n VerdocsToast('Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.', {style: 'error'});\n return;\n }\n\n if (this.newPassword !== this.confirmpass) {\n VerdocsToast('Passwords do not match.', {style: 'error'});\n return;\n }\n\n this.submitting = true;\n try {\n this.submitting = false;\n const resetResult = await resetPassword(this.endpoint, {email: this.email, code: this.verificationCode, new_password: this.newPassword});\n console.log('reset result', resetResult);\n VerdocsToast('Your password has been reset. You may now use your new password to login.', {style: 'success'});\n this.verificationCode = '';\n this.confirmpass = '';\n this.newPassword = '';\n this.password = '';\n this.displayMode = 'login';\n } catch (e) {\n this.submitting = false;\n console.log('Verification error', e);\n VerdocsToast('Verification error, please check the code and try again.');\n }\n }\n\n async handleReset() {\n this.submitting = true;\n\n try {\n const result = await resetPassword(this.endpoint, {email: this.email});\n console.log('[AUTH] Reset sent', result);\n this.submitting = false;\n this.displayMode = 'login';\n VerdocsToast('If your email address is registered, you will receive instructions on resetting your password shortly.', {style: 'info'});\n } catch (e) {\n console.log('[AUTH] Unable to reset password', e);\n this.submitting = false;\n VerdocsToast('Unable to reset password. Please check your email address and try again.', {style: 'error'});\n }\n }\n\n render() {\n if (!this.visible) {\n return <div style={{display: 'none'}}>Authenticated</div>;\n }\n\n if (this.session) {\n return (\n <verdocs-button\n label=\"Sign Out\"\n disabled={this.submitting}\n onClick={() => this.handleLogout()}\n style={{display: 'flex', justifyContent: 'center', margin: '30px auto 0'}}\n />\n );\n }\n\n if (this.displayMode === 'signup') {\n const invalid = this.submitting || !this.first_name || !this.last_name || !this.email || !this.password || !this.confirmpass || !this.org_name;\n\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Sign up for a free account</h3>\n <div class=\"already-have\">\n Already have an account?\n <verdocs-button label=\"Log In\" variant=\"text\" onClick={() => (this.displayMode = 'login')} disabled={this.submitting} />\n </div>\n\n <form onSubmit={() => this.handleSignup()}>\n <div style={{display: 'flex', flexDirection: 'row', columnGap: '20px'}}>\n <verdocs-text-input\n label=\"First Name\"\n autocomplete=\"first\"\n required={true}\n value={this.first_name}\n onInput={(e: any) => (this.first_name = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Last Name\"\n autocomplete=\"last\"\n required={true}\n value={this.last_name}\n onInput={(e: any) => (this.last_name = e.target.value)}\n disabled={this.submitting}\n />\n </div>\n <verdocs-text-input\n label=\"Email Address\"\n autocomplete=\"email\"\n required={true}\n value={this.email}\n onInput={(e: any) => (this.email = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n required={true}\n autocomplete=\"new-password\"\n value={this.password}\n onInput={(e: any) => (this.password = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Confirm Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.confirmpass}\n onInput={(e: any) => (this.confirmpass = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Phone Number\"\n type=\"tel\"\n required={true}\n autocomplete=\"phone\"\n value={this.phone}\n onInput={(e: any) => (this.phone = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Organization Name\"\n autocomplete=\"org\"\n required={true}\n value={this.org_name}\n onInput={(e: any) => (this.org_name = e.target.value)}\n disabled={this.submitting}\n style={{flex: '1'}}\n />\n\n <div class=\"service-agreement\">\n By clicking the Create Account button, you agree to the{' '}\n <a href=\"https://verdocs.com/eula\" target=\"_blank\">\n End User License Agreement\n </a>\n . Learn about how we use and protect your data and how you can opt-out in our{' '}\n <a href=\"https://verdocs.com/privacy-policy\" target=\"_blank\">\n Privacy Policy\n </a>\n .\n </div>\n\n <div style={{marginTop: '30px'}} />\n\n <verdocs-button\n label=\"Next\"\n disabled={invalid}\n onClick={invalid ? () => {} : () => this.handleSignup()}\n style={{display: 'flex', justifyContent: 'center', margin: '30px auto 0'}}\n />\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'verify') {\n return (\n <div class=\"form\">\n <form onSubmit={() => this.handleVerification()}>\n <p>Please check your e-mail inbox for a verification code and enter it below.</p>\n\n <verdocs-text-input\n label=\"Verification Code\"\n required={true}\n value={this.verificationCode}\n onInput={(e: any) => (this.verificationCode = e.target.value)}\n disabled={this.submitting}\n />\n\n <div class=\"buttons\">\n <verdocs-button label=\"Sign Out\" variant=\"outline\" disabled={this.submitting} onClick={() => this.handleLogout()} />\n <verdocs-button label=\"Verify\" disabled={this.submitting || !this.verificationCode || this.verificationCode.length !== 6} onClick={() => this.handleVerification()} />\n </div>\n <div class=\"buttons\">\n <verdocs-button variant=\"text\" label=\"Resend Code\" disabled={this.resendDisabled || this.submitting} onClick={() => this.handleResendVerification()} />\n </div>\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'forgot') {\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Forgot your password?</h3>\n\n <p>\n Enter your e-mail address below. If the e-mail address is valid, a password reset code will be sent to your inbox. Please allow up to 15 minutes to arrive, and check\n your spam folder if you do not receive the message.\n </p>\n\n <form onSubmit={() => this.handleResetGetCode()}>\n <verdocs-text-input\n label=\"Email Address\"\n autocomplete=\"email\"\n required={true}\n value={this.email}\n onInput={(e: any) => (this.email = e.target.value)}\n disabled={this.submitting}\n />\n\n <div style={{marginTop: '30px'}} />\n\n <div class=\"buttons\">\n <verdocs-button size=\"small\" label=\"Cancel\" variant=\"outline\" disabled={this.submitting} onClick={() => (this.displayMode = 'login')} />\n <verdocs-button size=\"small\" label=\"Request Code\" disabled={this.submitting} onClick={() => this.handleResetGetCode()} />\n </div>\n </form>\n </div>\n );\n }\n\n if (this.displayMode === 'reset') {\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Forgot your password?</h3>\n\n <p>\n Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not\n receive the message.\n </p>\n\n <form onSubmit={() => this.handleResetPassword()}>\n <verdocs-text-input\n label=\"Verification Code\"\n required={true}\n value={this.verificationCode}\n onInput={(e: any) => (this.verificationCode = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.newPassword}\n onInput={(e: any) => (this.newPassword = e.target.value)}\n disabled={this.submitting}\n />\n <verdocs-text-input\n label=\"Confirm Password\"\n type=\"password\"\n required={true}\n autocomplete=\"off\"\n value={this.confirmpass}\n onInput={(e: any) => (this.confirmpass = e.target.value)}\n disabled={this.submitting}\n />\n\n <div style={{marginTop: '30px'}} />\n\n <div class=\"buttons\">\n <verdocs-button label=\"Cancel\" variant=\"outline\" disabled={this.submitting} onClick={() => (this.displayMode = 'login')} />\n <verdocs-button label=\"Reset\" disabled={this.submitting} onClick={() => this.handleResetPassword()} />\n </div>\n\n <div class=\"buttons\">\n <verdocs-button variant=\"text\" label=\"Resend Code\" disabled={this.resendDisabled || this.submitting} onClick={() => this.handleResendReset()} />\n </div>\n </form>\n </div>\n );\n }\n\n return (\n <div class=\"form\">\n <a href=\"https://verdocs.com/en/\">\n <img src={this.logo} alt=\"Verdocs Logo\" class=\"logo\" />\n </a>\n\n <h3>Log in to your account</h3>\n <div class=\"already-have\">\n Don't have an account?\n <verdocs-button label=\"Sign Up\" variant=\"text\" onClick={() => (this.displayMode = 'signup')} disabled={this.submitting} />\n </div>\n\n <form onSubmit={() => this.loginAndCheckVerification()}>\n <verdocs-text-input label=\"Email\" autocomplete=\"username\" value={this.email} onInput={(e: any) => (this.email = e.target.value)} disabled={this.submitting} />\n <verdocs-text-input\n label=\"Password\"\n type=\"password\"\n autocomplete=\"current-password\"\n value={this.password}\n onInput={(e: any) => (this.password = e.target.value)}\n disabled={this.submitting}\n />\n\n <verdocs-button\n label=\"Forgot Your Password?\"\n variant=\"text\"\n onClick={() => (this.displayMode = 'forgot')}\n disabled={this.submitting}\n style={{display: 'flex', justifyContent: 'center', margin: '10px auto 20px'}}\n />\n\n <verdocs-button\n label=\"Login\"\n disabled={this.submitting}\n onClick={() => this.loginAndCheckVerification()}\n style={{display: 'flex', justifyContent: 'center', margin: '10px auto 0'}}\n />\n </form>\n </div>\n );\n }\n}\n"],"mappings":"yaAAA,MAAMA,EAAiB,IAAM,wwD,MCoChBC,EAAWC,EAAA,MAAAD,UAAAE,EALxB,WAAAC,CAAAC,G,wHASUC,KAAAC,SAA4BC,EAAgBC,aAO5CH,KAAAI,QAAmB,KAOnBJ,KAAAK,KAAe,+CAKAL,KAAAM,YAAkE,QAehFN,KAAAO,SAAmB,GACnBP,KAAAQ,WAAqB,GACrBR,KAAAS,UAAoB,GACpBT,KAAAU,MAAgB,GAChBV,KAAAW,MAAgB,GAChBX,KAAAY,iBAA2B,GAC3BZ,KAAAa,YAAsB,GACtBb,KAAAc,SAAmB,GACnBd,KAAAe,YAAsB,GACtBf,KAAAgB,WAAsB,MACtBhB,KAAAiB,eAAiB,MACjBjB,KAA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