@verdocs/web-sdk 2.3.73 → 2.3.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Types-fb95ed6b.js → Types-f83b8488.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{utils-7cc3fe3c.js → utils-13f8ed3f.js} +2 -2
- package/dist/cjs/verdocs-contact-picker_2.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-envelope-document-page.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-field-attachment_15.cjs.entry.js +22 -22
- package/dist/cjs/verdocs-field-payment.cjs.entry.js +3 -3
- package/dist/cjs/verdocs-pagination_2.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-preview_8.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-settings-api-keys_4.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-sign.cjs.entry.js +5 -2
- package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +26 -33
- package/dist/cjs/verdocs-view.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +3 -0
- package/dist/collection/components/fields/verdocs-field-attachment/verdocs-field-attachment.css +1 -1
- package/dist/collection/components/fields/verdocs-field-checkbox/verdocs-field-checkbox.css +1 -1
- package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.css +1 -1
- package/dist/collection/components/fields/verdocs-field-dropdown/verdocs-field-dropdown.css +1 -1
- package/dist/collection/components/fields/verdocs-field-initial/verdocs-field-initial.css +1 -1
- package/dist/collection/components/fields/verdocs-field-payment/verdocs-field-payment.css +1 -1
- package/dist/collection/components/fields/verdocs-field-radio-button-group/verdocs-field-radio-button.css +1 -1
- package/dist/collection/components/fields/verdocs-field-signature/verdocs-field-signature.css +1 -1
- package/dist/collection/components/fields/verdocs-field-textarea/verdocs-field-textarea.css +1 -1
- package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.css +1 -1
- package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.js +0 -1
- package/dist/collection/components/fields/verdocs-field-timestamp/verdocs-field-timestamp.css +1 -1
- package/dist/collection/components/templates/verdocs-template-document-page/verdocs-template-document-page.js +28 -9
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +25 -32
- package/dist/collection/utils/Types.js +1 -1
- package/dist/collection/utils/utils.js +1 -1
- package/dist/components/Types2.js +1 -1
- package/dist/components/utils.js +1 -1
- package/dist/components/verdocs-field-attachment2.js +1 -1
- package/dist/components/verdocs-field-checkbox2.js +1 -1
- package/dist/components/verdocs-field-date2.js +1 -1
- package/dist/components/verdocs-field-dropdown2.js +1 -1
- package/dist/components/verdocs-field-initial2.js +1 -1
- package/dist/components/verdocs-field-payment.js +1 -1
- package/dist/components/verdocs-field-radio-button2.js +1 -1
- package/dist/components/verdocs-field-signature2.js +1 -1
- package/dist/components/verdocs-field-textarea2.js +1 -1
- package/dist/components/verdocs-field-textbox2.js +1 -2
- package/dist/components/verdocs-field-timestamp2.js +1 -1
- package/dist/components/verdocs-sign.js +3 -0
- package/dist/components/verdocs-template-document-page2.js +11 -9
- package/dist/components/verdocs-template-fields2.js +25 -32
- package/dist/custom-elements.json +2147 -0
- package/dist/docs.json +18 -1
- package/dist/esm/{Types-1628dc71.js → Types-086facf7.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{utils-36f1bbdd.js → utils-a56ee5e9.js} +3 -3
- package/dist/esm/verdocs-contact-picker_2.entry.js +2 -2
- package/dist/esm/verdocs-envelope-document-page.entry.js +2 -2
- package/dist/esm/verdocs-envelope-sidebar.entry.js +1 -1
- package/dist/esm/verdocs-envelopes-list.entry.js +2 -2
- package/dist/esm/verdocs-field-attachment_15.entry.js +22 -22
- package/dist/esm/verdocs-field-payment.entry.js +3 -3
- package/dist/esm/verdocs-pagination_2.entry.js +2 -2
- package/dist/esm/verdocs-preview_8.entry.js +2 -2
- package/dist/esm/verdocs-settings-api-keys_4.entry.js +2 -2
- package/dist/esm/verdocs-sign.entry.js +5 -2
- package/dist/esm/verdocs-template-fields_4.entry.js +26 -33
- package/dist/esm/verdocs-view.entry.js +2 -2
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/Types-086facf7.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{utils-36f1bbdd.js → utils-a56ee5e9.js} +2 -2
- package/dist/esm-es5/verdocs-contact-picker_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-document-page.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
- package/dist/esm-es5/verdocs-field-attachment_15.entry.js +1 -1
- package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
- package/dist/esm-es5/verdocs-pagination_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_8.entry.js +1 -1
- package/dist/esm-es5/verdocs-settings-api-keys_4.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-fields_4.entry.js +1 -1
- package/dist/esm-es5/verdocs-view.entry.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/templates/verdocs-template-document-page/verdocs-template-document-page.d.ts +4 -0
- package/dist/types/components/templates/verdocs-template-fields/verdocs-template-fields.d.ts +0 -1
- package/dist/types/components.d.ts +8 -0
- package/dist/types/utils/Types.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -1
- package/dist/verdocs-web-sdk/{p-cacffa79.system.js → p-0cafdb16.system.js} +2 -2
- package/dist/verdocs-web-sdk/{p-3c59911b.system.entry.js → p-0e6b2f10.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-0b0cc39b.system.entry.js → p-15c88a05.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-d8cd6b59.system.js → p-173e86c3.system.js} +1 -1
- package/dist/verdocs-web-sdk/p-1b4e7078.js +1 -0
- package/dist/verdocs-web-sdk/{p-90539070.entry.js → p-1d5f10f4.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-e0e99a5d.system.entry.js → p-28c93a3a.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-356e4c15.system.entry.js → p-320a0e0c.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-83597b2e.system.entry.js → p-4b84b04e.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-e4b14b93.system.entry.js → p-5e8e5761.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-5c306718.entry.js → p-6ca72beb.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-8f36c42a.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-501d9168.entry.js → p-91e94910.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-bea26fb0.system.entry.js → p-a12b2c26.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-5ddc43f4.entry.js → p-a9da16c6.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-d315d7ca.entry.js → p-b2d3ac44.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-a3d7cdda.js → p-b72328af.js} +2 -2
- package/dist/verdocs-web-sdk/{p-d53aec0f.entry.js → p-bbf52926.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-c179b3e4.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-08b5e01b.entry.js → p-d0140be2.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-38ea0d20.entry.js → p-d11ffc76.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-2d47c6af.entry.js → p-d151150e.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-0e4f5403.entry.js → p-d1c52218.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-f3947f39.system.entry.js → p-d61bf72b.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-a50982c8.system.entry.js → p-de5b9b23.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-f0dfd635.system.entry.js → p-e7d7bcae.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-c5fd0435.system.entry.js → p-ea2211d7.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-3fa35da3.entry.js → p-ef99042b.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-f04bf956.system.js +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/verdocs-field-textbox.cjs.entry.js +0 -146
- package/dist/esm/verdocs-field-textbox.entry.js +0 -142
- package/dist/esm-es5/Types-1628dc71.js +0 -1
- package/dist/esm-es5/verdocs-field-textbox.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-10310263.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-839f6f0d.js +0 -1
- package/dist/verdocs-web-sdk/p-b252cfb6.entry.js +0 -1
- package/dist/verdocs-web-sdk/verdocs-field-textbox.entry.js +0 -142
- package/dist/verdocs-web-sdk/verdocs-field-textbox.system.entry.js +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
import{r as e,c as t,h as s,H as i,F as o,a as l}from"./p-14b44491.js";import{i as r}from"./p-4bda4c50.js";import"./p-05788c2b.js";import{V as a,T as n,u as d}from"./p-e04d8f5d.js";import{u as p,c}from"./p-feb442b1.js";import{i as h}from"./p-5e808a0b.js";import{g as m,u as v}from"./p-ef20cb50.js";import{e as f,f as g,b as u,h as x,i as b,j as w}from"./p-b72328af.js";import{g as y,c as k,u as q,d as E,a as C}from"./p-b086f9be.js";import{g as M}from"./p-45ecd6eb.js";import{S as Z}from"./p-7a1b2643.js";import{g as L}from"./p-6de76553.js";import"./p-eab67c09.js";import"./p-7648c449.js";import"./p-dc2ad047.js";import"./p-1b4e7078.js";import"./p-c220af42.js";var z=function(e,t,s,i){return e.api.put("/templates/".concat(t,"/roles/").concat(s),i).then((function(e){return e.data}))};const S='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.707 14.707"><g><rect x="6.275" y="0" fill="#ffffff7f" width="1" height="15"/></g></svg>',H=[{id:"signature",tooltip:"Signature",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>'},{id:"initial",tooltip:"Initials",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>'},{id:"sep1",tooltip:"",icon:S},{id:"textbox",tooltip:"Text Box",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>'},{id:"textarea",tooltip:"Text Area",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z"/></svg>'},{id:"checkbox_group",tooltip:"Check Box",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z"/></svg>'},{id:"radio_button_group",tooltip:"Radio Button",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z"/></svg>'},{id:"dropdown",tooltip:"Dropdown",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="1.5" stroke="currentColor"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" /></svg>'},{id:"sep2",tooltip:"",icon:S},{id:"date",tooltip:"Date",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z"/></svg>'},{id:"timestamp",tooltip:"Timestamp",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z"></path></svg>'}],V=class{constructor(s){e(this,s),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.fieldsUpdated=t(this,"fieldsUpdated",7),this.pageHeights={},this.templateStore=null,this.fieldStore=null,this.roleStore=null,this.cachedPageInfo={},this.endpoint=a.getDefault(),this.templateId=null,this.toolbarTargetId=null,this.placing=null,this.showMustSelectRole=!1,this.selectedRoleName="",this.loading=!0}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[FIELDS] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[FIELDS] Unable to start builder session, must be authenticated");M(this.endpoint,this.templateId,!0).then((e=>{var t,s;this.templateStore=e,this.fieldStore=m(this.templateId),this.roleStore=y(this.templateId),this.selectedRoleName=(null===(s=null===(t=this.roleStore.get("roles"))||void 0===t?void 0:t[0])||void 0===s?void 0:s.name)||"",this.loading=!1,this.fieldStore.onChange("fields",(e=>{var t;console.log("[FIELDS] Fields changed",{fields:e}),null===(t=this.fieldsUpdated)||void 0===t||t.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,fields:e})}))})).catch((e=>{console.log(e)}))}catch(i){console.log("[FIELDS] Error with preview session",i),null===(e=this.sdkError)||void 0===e||e.emit(new Z(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}componentDidRender(){r.dynamicDrop(!0);const e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null,t=document.getElementById("verdocs-template-fields-toolbar");e&&t&&(console.log("[FIELDS] Moving toolbar"),t.remove(),e.append(t))}componentWillUpdate(){var e;const t=this.roleStore.get("roles");this.selectedRoleName&&t.find((e=>e&&e.name===this.selectedRoleName))||(this.selectedRoleName=(null===(e=t[0])||void 0===e?void 0:e.name)||"",console.log("[FIELDS] Selected new role",this.selectedRoleName))}handleKeyDown(e){"Escape"===e.key&&(this.placing=null)}async handleFieldChange(e,t,s){console.log("[FIELDS] handleFieldChange",e,t,s)}attachFieldAttributes(e,t,s){s.addEventListener("input",(e=>this.handleFieldChange(t,e))),s.addEventListener("settingsChanged",(e=>{var t,s;console.log("Settings changed",e.detail),null===(t=this.templateUpdated)||void 0===t||t.emit({endpoint:this.endpoint,template:null===(s=this.templateStore)||void 0===s?void 0:s.state,event:"added-field"})})),s.addEventListener("deleted",(()=>{var e,i;console.log("[FIELDS] Deleted",this,t),s.remove(),null===(e=this.templateUpdated)||void 0===e||e.emit({endpoint:this.endpoint,template:null===(i=this.templateStore)||void 0===i?void 0:i.state,event:"updated-field"})})),s.setAttribute("templateid",this.templateId),s.setAttribute("fieldname",t.name),s.setAttribute("pageNumber",e.pageNumber),s.setAttribute("xScale",e.xScale),s.setAttribute("yScale",e.yScale),s.setAttribute("name",t.name)}handlePageRendered(e){const t=e.detail;this.cachedPageInfo[t.pageNumber]=t,this.pageHeights[t.pageNumber]=t.naturalHeight,this.fieldStore.get("fields").filter((e=>e&&e.page_sequence===t.pageNumber)).forEach((e=>{switch(e.type){case"checkbox_group":case"radio_button_group":(e.settings||e.setting||{}).options.map(((t,s)=>{const i=x(e,s),o=document.getElementById(i);o&&(o.setAttribute("fieldname",e.name),o.setAttribute("pagenumber",String(e.page_sequence)),this.makeDraggable(o))}));break;default:const t=u(e),s=document.getElementById(t);s&&(s.setAttribute("fieldname",e.name),s.setAttribute("pagenumber",String(e.page_sequence)),this.makeDraggable(s))}}))}makeDraggable(e){r(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})}async handleMoveField(e){const t=+(e.target.getAttribute("posX")||0),s=+(e.target.getAttribute("posY")||0),i=+(e.target.getAttribute("xScale")||1),o=+(e.target.getAttribute("yScale")||1),l=e.dx/i+t,r=e.dy/o+s;e.target.setAttribute("posX",l),e.target.setAttribute("posy",r),f(e.target,"translate",`${l}px, ${r}px`)}async handleMoveEnd(e){var t,s;const i=e.target.getAttribute("fieldname"),o=+(e.target.getAttribute("option")||"0"),l=this.fieldStore.get("fields").find((e=>e.name===i));if(!l)return void console.log("[FIELDS] Unable to find field",i,e.target);const r=e.target.getAttribute("pagenumber"),{naturalWidth:a=612,naturalHeight:n=792,renderedHeight:d=792}=this.cachedPageInfo[r],c=e.target.getBoundingClientRect(),h=e.target.parentElement.getBoundingClientRect(),m=l.setting.width||b(l.type),f=l.setting.height||w(l.type),u=Math.max(c.left-h.left,0),x=Math.max(d-(h.bottom-c.bottom),0),{x:y,y:k}=this.viewCoordinatesToPageCoordinates(u,x,r,a-m,n-f);switch(l.type){case"attachment":case"payment":case"initial":case"signature":case"date":case"dropdown":case"textarea":case"textbox":case"timestamp":l.setting.x=y,l.setting.y=k;break;case"checkbox_group":case"radio_button_group":{const e=l.setting.options[o];e&&(e.x=y,e.y=k)}}console.log("[FIELDS] Will update",i,k,o,l);const q=await p(this.endpoint,this.templateId,i,l);v(this.fieldStore,i,q),e.target.removeAttribute("posX"),e.target.removeAttribute("posY"),g(e.target),null===(t=this.templateUpdated)||void 0===t||t.emit({endpoint:this.endpoint,template:null===(s=this.templateStore)||void 0===s?void 0:s.state,event:"updated-field"})}generateFieldName(e,t){let s,i=1;do{s=`${e}P${t}-${i}`,i++}while(this.fieldStore.get("fields").some((e=>e&&e.name===s)));return s}viewCoordinatesToPageCoordinates(e,t,s,i,o){const{xScale:l=1,yScale:r=1,renderedHeight:a=792}=this.cachedPageInfo[s];return{x:Math.floor(Math.min(e/l,i)),y:Math.floor(Math.min(Math.max(a-t,0)/r,o))}}async handleClickPage(e,t){var s,i;if(this.placing){const o=e.offsetX,l=e.offsetY,r=b(this.placing),a=w(this.placing),n=this.cachedPageInfo[t],{naturalWidth:d=612,naturalHeight:p=792}=n,h=this.viewCoordinatesToPageCoordinates(o,l,t,d-r,p-a),m=Math.floor(h.x),v=Math.floor(h.y),f={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:n.documentId,type:this.placing,required:!0,page_sequence:t,validator:null,setting:{x:m,y:v},x:m,y:v,tabindex:0,width:r,height:a};switch(console.log("[FIELDS] Will save new field",f),f.type){case"attachment":case"payment":f.setting={x:m,y:v};break;case"initial":case"signature":f.setting={x:m,y:v,result:""};break;case"checkbox_group":f.setting={minimum_checked:0,maximum_checked:1e3,options:[{id:`${f.name}-1`,value:"Option 1",checked:!1,x:m,y:v}]};break;case"date":f.setting={x:m,y:v,width:r,height:a,result:""};break;case"dropdown":f.required=!1,f.setting={x:m,y:v,width:r,height:a,value:null,placeholder:"Choose",options:[{id:"option-1",value:"Option 1"}]};break;case"radio_button_group":f.setting={options:[{id:`${f.name}-1`,value:"Option 1",selected:!1,x:m,y:v}]};break;case"textarea":case"textbox":f.setting={x:m,y:v,width:r,height:a,result:"",leading:0,alignment:0,upperCase:!1};break;case"timestamp":f.setting={x:m,y:v,width:r,height:a}}"textarea"===f.type&&(f.setting.leading=16,f.type="textbox");const g=await c(this.endpoint,this.templateId,f);console.log("[FIELDS] Saved field",g),this.fieldStore.set("fields",[...this.fieldStore.get("fields"),g]),this.placing=null,null===(s=this.templateUpdated)||void 0===s||s.emit({endpoint:this.endpoint,template:null===(i=this.templateStore)||void 0===i?void 0:i.state,event:"added-field"})}}render(){var e,t,o;if(!this.endpoint.session)return s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}));if(this.loading||!(null===(e=this.templateStore)||void 0===e?void 0:e.state.isLoaded))return s(i,null,s("verdocs-loader",null));const l=this.roleStore.get("roles").map((e=>({value:e.name,label:e.name})));return s(i,{class:this.placing?{[`placing-${this.placing}`]:!0}:{},onSubmit:()=>{}},s("div",{id:"verdocs-template-fields-toolbar"},s("div",{class:"add-for"},"Add field:"),s("verdocs-select-input",{value:this.selectedRoleName,options:l,onInput:e=>this.selectedRoleName=e.target.value}),H.map((e=>s("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,onClick:()=>{e.tooltip&&(this.selectedRoleName?this.placing=e.id:this.showMustSelectRole=!0)}})))),s("div",{class:"pages"},((null===(o=null===(t=this.templateStore)||void 0===t?void 0:t.state)||void 0===o?void 0:o.template_documents)||[]).map((e=>h(1,e.page_numbers).map((t=>s("verdocs-template-document-page",{templateId:this.templateId,documentId:e.id,pageNumber:t,virtualWidth:612,virtualHeight:792,disabled:!0,editable:!0,done:!1,onClick:e=>this.handleClickPage(e,t),onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})))))),this.showMustSelectRole&&s("verdocs-ok-dialog",{heading:"Unable to add field",message:this.roleStore.get("roles").length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:()=>this.showMustSelectRole=!1}))}};V.style="verdocs-template-fields{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;position:relative;display:block;min-height:600px}verdocs-template-fields .page-0{padding:65px 15px 0 15px;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields .page-0 .user-placed-fields{height:100px;position:relative;background:#ffffff;-webkit-box-shadow:0 0 10px 5px #0000000f;box-shadow:0 0 10px 5px #0000000f}verdocs-template-fields .page-0 .user-placed-fields .title{top:0;left:0;color:#ffffff;font-size:12px;padding:3px 6px;font-weight:bold;position:absolute;background:#46497d}verdocs-template-fields .pages{display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-template-fields .pages div,verdocs-template-fields .pages canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields #verdocs-template-fields-toolbar{height:50px;display:-ms-flexbox;display:flex;-ms-flex:0 0 50px;flex:0 0 50px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;font-weight:700;padding:0 20px 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#f5f5fa;-ms-flex-pack:center;justify-content:center;background:#46497d}verdocs-template-fields #verdocs-template-fields-toolbar>verdocs-select-input{margin:0}verdocs-template-fields #verdocs-template-fields-toolbar svg{width:24px;height:24px}verdocs-template-fields #verdocs-template-fields-toolbar .add-for{margin:0;font-weight:500;color:#f5f5fa}verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{margin:0 20px 0 0}verdocs-template-fields.placing-attachment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-checkbox_group{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-date{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-dropdown{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' stroke-width='1.5' stroke='currentColor'%3E%3Cpath stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25' /%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-initial{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-payment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-radio_button_group{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-signature{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textarea{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textbox{cursor:url(\"data:image/svg+xml,%3Csvg width='32' height='15' viewBox='0 0 32 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='path-1-inside-1_1401_24' fill='white'%3E%3Cpath d='M0 0H32V15H0V0Z'/%3E%3C/mask%3E%3Cpath d='M0 0H32V15H0V0Z' fill='%234C56CB' fill-opacity='0.1'/%3E%3Cpath d='M0 0V-1H-1V0H0ZM0 15H-1V16H0V15ZM0 1H32V-1H0V1ZM32 14H0V16H32V14ZM1 15V0H-1V15H1Z' fill='%234C56CB' mask='url(%23path-1-inside-1_1401_24)'/%3E%3Cpath d='M3 11.8V8.65H14.15V11.8H3ZM3 6.65V3.5H20.15V6.65H3Z' fill='%234C56CB'/%3E%3Cline x1='31.5' y1='1' x2='31.5' y2='14' stroke='%234C56CB' stroke-opacity='0.32' stroke-dasharray='1 1'/%3E%3C/svg%3E%0A\") 0 14, pointer}verdocs-template-fields.placing-timestamp{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z'%3E%3C/path%3E%3C/svg%3E\") 16 16, pointer}";const I=class{constructor(s){e(this,s),this.close=t(this,"close",7),this.delete=t(this,"delete",7),this.sdkError=t(this,"sdkError",7),this.templateStore=null,this.fieldStore=null,this.roleStore=null,this.endpoint=a.getDefault(),this.templateId="",this.roleName="",this.sender=n.EVERYONE,this.dirty=!1,this.saving=!1,this.name="",this.type="signer",this.full_name="",this.email="",this.phone="",this.delegator=!1}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLE_PROPERTIES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLE_PROPERTIES] Unable to start builder session, must be authenticated");this.templateStore=await M(this.endpoint,this.templateId,!1),this.fieldStore=m(this.templateId),this.roleStore=k(this.templateStore.state);const e=this.roleStore.state.roles.find((e=>e.name===this.roleName));e&&(this.name=e.name,this.type=e.type,this.full_name=e.full_name,this.email=e.email,this.phone=e.phone,this.delegator=e.delegator,console.log("[ROLE_PROPERTIES] Editing role",e))}catch(i){console.log("[ROLE_PROPERTIES Error with preview session",i),null===(e=this.sdkError)||void 0===e||e.emit(new Z(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}handleCancel(e){var t;e.stopPropagation();const s=this.roleStore.state.roles.find((e=>e.name===this.roleName));s&&(this.name=s.name,this.type=s.type,this.full_name=s.full_name,this.email=s.email,this.phone=s.phone,this.delegator=s.delegator),this.dirty=!1,null===(t=this.close)||void 0===t||t.emit()}async handleSave(e){e.stopPropagation(),this.saving=!0,z(this.endpoint,this.templateId,this.roleName,{name:this.name,type:this.type,full_name:this.full_name,email:this.email,phone:this.phone,delegator:this.delegator}).then((async e=>{var t;console.log("[ROLE_PROPERTIES] Update result",e),this.saving=!1,this.dirty=!1,q(this.roleStore,this.roleName,e),null===(t=this.close)||void 0===t||t.emit()})).catch((e=>{console.log("[ROLE_PROPERTIES Update error",e),this.saving=!1}))}async handleDelete(e){var t,s,i;e.stopPropagation(),window.confirm("Are you sure you wish to remove this role? All associated fields will be removed as well. This action cannot be undone.")&&(t=this.endpoint,s=this.templateId,i=this.roleName,t.api.delete("/templates/".concat(s,"/roles/").concat(i)).then((function(e){return e.data}))).then((()=>{var e;E(this.roleStore,this.roleName),null===(e=this.delete)||void 0===e||e.emit({templateId:this.templateId,roleName:this.roleName})})).catch((e=>{console.log("[ROLE_PROPERTIES Deletion error",e)}))}render(){const e=this.fieldStore.get("fields").some((e=>e.role_name===this.roleName));return s(i,null,s("div",{class:"background-overlay",onClick:e=>this.handleCancel(e)},s("div",{class:"dialog"},s("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},s("verdocs-text-input",{id:"verdocs-role-name",label:"Role Name",value:this.name,autocomplete:"off",disabled:e,helpText:e?"This role has fields assigned and can no longer be renamed.":"A unique name to identify the role in the workflow. Submitted data will also be tagged with this value.",placeholder:"Role Name...",onInput:e=>{this.name=e.target.value,this.dirty=!0}}),s("div",{class:"row"},s("div",{class:"input-label"},"Type:"),s("verdocs-select-input",{value:this.type,options:[{label:"Signer",value:"signer"},{label:"CC",value:"cc"},{label:"Approver",value:"approver"}],onInput:e=>{this.type=e.target.value,this.dirty=!0}}),s("verdocs-help-icon",{text:"Most participants are Signers. CC roles are notified when documents are signed, but have no other actions. Approvers get notified when signing is completed to perform a final review."})),s("verdocs-text-input",{id:"verdocs-recipient-email",label:"Full Name",value:this.full_name,autocomplete:"off",helpText:"The recipient's full name, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.",placeholder:"Full Name...",onInput:e=>{this.full_name=e.target.value,this.dirty=!0}}),s("verdocs-text-input",{id:"verdocs-recipient-email",label:"Email",value:this.email,autocomplete:"off",helpText:"The recipient's email address, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.",placeholder:"Email Address...",onInput:e=>{this.email=e.target.value,this.dirty=!0}}),s("verdocs-text-input",{id:"verdocs-recipient-phone",label:"Phone",value:this.phone,autocomplete:"off",helpText:"The recipient's phone number, if it will always stay the same. Leave blank to supply this value later, when each new envelope is created from the template.",placeholder:"Phone Number...",onInput:e=>{this.phone=e.target.value,this.dirty=!0}}),s("div",{class:"row"},s("div",{class:"input-label"},"May Delegate:"),s("div",{class:"checkbox-wrapper"},s("verdocs-checkbox",{checked:this.delegator,onInput:e=>{this.delegator=e.target.checked,this.dirty=!0}})),s("verdocs-help-icon",{text:"If enabled, this recipient may delegate their actions to another individual."})),s("div",{class:"buttons"},s("button",{class:"delete-button",disabled:this.dirty,onClick:e=>this.handleDelete(e),innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#a50021"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>'}),s("div",{style:{flex:"1"}}),s("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),s("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)}))))))}};I.style='verdocs-template-role-properties{font-family:"Inter", "Barlow", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-role-properties div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-role-properties .background-overlay{position:fixed;z-index:10000;top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background:#0000007f}verdocs-template-role-properties .dialog{width:340px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border-radius:4px;overflow:hidden;background:#ffffff;padding:16px;-webkit-box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4);box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4)}verdocs-template-role-properties .heading{display:-ms-flexbox;display:flex;font-size:20px;font-weight:500;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-role-properties .buttons verdocs-button{margin-left:16px}verdocs-template-role-properties form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;margin:0 0 10px 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties form .row .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0;-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-role-properties verdocs-select-input{-ms-flex:1;flex:1;margin:0}verdocs-template-role-properties verdocs-text-input{margin:0 0 10px 0}verdocs-template-role-properties verdocs-text-input label{margin:0;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-role-properties verdocs-text-input .input-label{-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-role-properties verdocs-text-input input{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties verdocs-text-input verdocs-text-input{margin:0}verdocs-template-role-properties .checkbox-wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-role-properties .delete-button{height:34px;display:-ms-flexbox;display:flex;padding:0 6px;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-role-properties .delete-button svg{width:24px;height:24px}verdocs-template-role-properties .delete-button:active{background:#f3f3f3}';const R={[n.EVERYONE]:"Everyone",[n.EVERYONE_AS_CREATOR]:"Everyone as Me",[n.ORGANIZATION_MEMBER]:"Organization member",[n.ORGANIZATION_MEMBER_AS_CREATOR]:"Organization Member as Me",[n.CREATOR]:"Me"},_='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>',T='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>',D='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>',O='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>',j='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z" /><path d="M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z" /></svg>',P=class{constructor(s){e(this,s),this.next=t(this,"next",7),this.exit=t(this,"exit",7),this.sdkError=t(this,"sdkError",7),this.rolesUpdated=t(this,"rolesUpdated",7),this.templateStore=null,this.roleStore=null,this.endpoint=a.getDefault(),this.templateId="",this.showingRoleDialog=null,this.showingSenderDialog=!1,this.sender=null,this.loading=!0}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");await M(this.endpoint,this.templateId,!1).then((e=>{var t;this.templateStore=e,this.roleStore=y(this.templateId),console.log("RS",null===(t=this.roleStore)||void 0===t?void 0:t.state),this.loading=!1,this.roleStore.onChange("roles",(e=>{var t;console.log("[ROLES] Roles changed",{roles:e}),null===(t=this.rolesUpdated)||void 0===t||t.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:e})}))})).catch((e=>{console.log(e)}))}catch(i){console.log("[FIELDS] Error with preview session",i),null===(e=this.sdkError)||void 0===e||e.emit(new Z(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}componentDidRender(){r.dynamicDrop(!0),r(".recipient").draggable({listeners:{start:function(e){e.target.classList.add("dragging"),this.el.classList.add("dragging")}.bind(this),move:function(e){const t=+(e.target.getAttribute("dX")||0),s=+(e.target.getAttribute("dY")||0),i=+(e.target.dataset.sequence||0),o=+(e.target.dataset.order||0),l=e.dx+t,r=e.dy+s;e.target.setAttribute("dX",l),e.target.setAttribute("dY",r);const a=e.target.getBoundingClientRect();console.log("w",a.width),e.target.style.transform=`translate(${l+a.width-(o+1)}px, ${r-a.height*i}px)`}.bind(this),end:function(e){e.target.classList.remove("dragging"),this.el.classList.remove("dragging"),e.target.removeAttribute("dX"),e.target.removeAttribute("dY"),e.target.style.transform=null}.bind(this)}}),r(".dropzone").dropzone({overlap:.05,ondrop:async function(e){var t;console.log("dropped",e.target.classList),e.target.classList.remove("active"),q(this.roleStore,e.relatedTarget.dataset.rolename,{sequence:+e.target.dataset.sequence,order:+e.target.dataset.order}),await this.renumberTemplateRoles(),console.log("[ROLES] Updated roles",this.getSortedRoles()),null===(t=this.rolesUpdated)||void 0===t||t.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}.bind(this),ondropactivate:e=>{e.target.classList.add("visible")},ondropdeactivate:e=>{e.target.classList.remove("visible")},ondragenter:e=>{e.target.classList.add("active")},ondragleave:e=>{e.target.classList.remove("active")}})}handleCancel(){var e;null===(e=this.exit)||void 0===e||e.emit()}handleSubmit(){var e;null===(e=this.next)||void 0===e||e.emit()}getSortedRoles(){return this.roleStore.state.roles.sort(((e,t)=>e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence))}getSequenceNumbers(){const e=[];return this.getSortedRoles().forEach((t=>{e.includes(t.sequence)||e.push(t.sequence)})),e.sort(((e,t)=>e-t))}getRoleNames(){return this.getSortedRoles().map((e=>e.name))}getRolesAtSequence(e){return this.roleStore.state.roles.filter((t=>t&&t.sequence===e))}renumberTemplateRoles(){console.log("Renumbering roles",this.getSequenceNumbers(),JSON.stringify(this.roleStore.state));const e=[],t=[];return this.getSequenceNumbers().forEach(((s,i)=>{this.getRolesAtSequence(s).forEach(((s,o)=>{e.includes(s.name)||(s.sequence=i+1,s.order=o+1,e.push(s.name),t.push(z(this.endpoint,this.templateId,s.name,{sequence:s.sequence,order:s.order})))}))})),Promise.all(t)}getNextRoleName(){console.log("Getting next role name",JSON.stringify(this.roleStore.state));let e="",t=Object.keys(this.roleStore.state).length-1;do{t++,e=`Recipient ${t}`}while(!e||this.roleStore.state.roles.some((t=>t&&t.name===e)));return e}callCreateRole(e,t,s){var i,o,l;console.log("[ROLES] Will create role",{name:e,sequence:t,order:s}),(i=this.endpoint,o=this.templateId,l={template_id:this.templateId,name:e,sequence:t,order:s,full_name:"",email:"",phone:"",type:"signer",delegator:!1},i.api.post("/templates/".concat(o,"/roles"),l).then((function(e){return e.data}))).then((async e=>{var t;console.log("[ROLES] Created role",e),this.roleStore.set("roles",[...this.roleStore.state.roles,e]),await this.renumberTemplateRoles(),null===(t=this.rolesUpdated)||void 0===t||t.emit({event:"added",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})})).catch((e=>{console.log("[ROLES] Error creating role",e)}))}handleAddRole(e,t){e.stopPropagation();const s=this.getRolesAtSequence(t).length+1,i=this.getNextRoleName();this.callCreateRole(i,t,s)}handleAddStep(e,t){e.stopPropagation();const s=this.getNextRoleName();this.callCreateRole(s,t,1)}render(){var e,t,l,r;if(!this.endpoint.session)return s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}));if(this.loading||!(null===(e=this.templateStore)||void 0===e?void 0:e.state.isLoaded))return console.log("Loading",this.loading,null===(t=this.templateStore)||void 0===t?void 0:t.state.isLoaded),s(i,{class:"loading"},s("verdocs-loader",null));console.log("Rendering roles",this.roleStore.get("roles"));const a=this.getRoleNames(),n=this.getSequenceNumbers();return console.log("Rendering",a,n),s(i,null,s("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},s("h5",null,"Roles and Workflow"),s("div",{class:"participants"},s("div",{class:"left-line"}),s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><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>'}),s("div",{class:"row-roles"},s("div",{class:"sender"},s("span",{class:"label"},"Sender:")," ",R[null===(r=null===(l=this.templateStore)||void 0===l?void 0:l.state)||void 0===r?void 0:r.sender]," ",s("div",{class:"settings-button",innerHTML:_,onClick:()=>this.showingSenderDialog=!0,"aria-role":"button"})))),s("div",{class:"row add-sequence","data-sequence":0},s("div",{class:"icon",innerHTML:T}),s("div",{class:"row-roles"},s("div",{class:"dropzone","data-sequence":0,"data-order":1},"Add Step"))),n.map((e=>s(o,null,s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><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>'}),s("div",{class:"row-roles"},s("div",{class:"dropzone","data-order":.5,"data-sequence":e}),this.getRolesAtSequence(e).map((t=>s(o,null,t.email?s("div",{class:"recipient",style:{borderColor:L(C(this.roleStore,t.name))},"data-rolename":t.name,"data-sequence":e,"data-order":t.order},s("span",{class:"type-icon",innerHTML:"signer"===t.type?D:"cc"===t.type?j:O}),t.full_name," ",s("div",{class:"settings-button",innerHTML:_,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"})):s("div",{class:"recipient",style:{backgroundColor:L(C(this.roleStore,t.name))},"data-rolename":t.name,"data-sequence":e,"data-order":t.order},s("span",{class:"type-icon",innerHTML:"signer"===t.type?D:"cc"===t.type?j:O}),t.name," ",s("div",{class:"settings-button",innerHTML:_,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"})),s("div",{class:"dropzone","data-order":t.order+.5,"data-sequence":e})))),s("button",{class:"add-role",innerHTML:T,onClick:t=>this.handleAddRole(t,e)}))),n.length>0&&s("div",{class:"row add-sequence","data-sequence":e},s("div",{class:"row-roles"},s("div",{class:"icon",innerHTML:T}),s("div",{class:"dropzone","data-sequence":e+1,"data-order":1},"Add Step")))))),s("div",{class:"row","data-sequence":n.length+1},s("div",{class:"row-roles"},s("div",{class:"icon",innerHTML:T}),s("button",{class:"add-step",innerHTML:T,onClick:e=>this.handleAddStep(e,n.length+1)}))),s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><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>'}),s("div",{class:"row-roles"},s("div",{class:"complete"},"Document Complete")))),a.length<1&&s("div",{class:"empty"},"You must add at least one Role before proceeding.",s("br",null)," Click the ",s("span",{innerHTML:T})," Add button above to get started."),s("div",{class:"buttons"},s("div",{class:"flex-fill"}),s("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:()=>this.handleCancel()}),s("verdocs-button",{label:"OK",size:"small",onClick:()=>this.handleSubmit(),disabled:a.length<1}))),this.showingRoleDialog&&s("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:()=>{this.showingRoleDialog=null},onDelete:async()=>{var e;this.showingRoleDialog=null,await this.renumberTemplateRoles(),null===(e=this.rolesUpdated)||void 0===e||e.emit({event:"deleted",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}}),this.showingSenderDialog&&s("verdocs-template-sender",{endpoint:this.endpoint,templateId:this.templateId,onClose:()=>this.showingSenderDialog=!1}))}get el(){return l(this)}};P.style='verdocs-template-roles{display:block;min-width:400px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-roles>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-roles>form h5{font-size:16px;font-weight:bold;color:#46497d;margin:0 0 10px 0}verdocs-template-roles>form .participants{position:relative}verdocs-template-roles>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-roles>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;min-height:35px;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-roles>form .row .row-roles{-ms-flex:1;flex:1;gap:10px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-roles>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 15px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-roles>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-roles>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-roles>form .row .settings-button{display:-ms-flexbox;display:flex;cursor:pointer;margin:0 0 0 9px}verdocs-template-roles>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;border-radius:30px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:2px solid #aeb4bf}verdocs-template-roles>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:0 12px 0 0}verdocs-template-roles>form .row .recipient.dragging{position:absolute}verdocs-template-roles>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-roles>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-roles>form .row .dropzone svg{fill:#cccccc}verdocs-template-roles>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-roles>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-roles>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-roles>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-roles>form input:focus{outline:none}verdocs-template-roles .row.add-sequence{display:none}verdocs-template-roles .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-role:hover{opacity:1}verdocs-template-roles .add-role svg{width:32px;height:32px}verdocs-template-roles .add-step{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-step:hover{opacity:1}verdocs-template-roles .add-step svg{width:32px;height:32px}verdocs-template-roles.dragging .add-role{display:none}verdocs-template-roles.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-roles.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-roles .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-roles .empty svg{width:20px;height:20px;stroke:#666666;margin-bottom:-5px}verdocs-template-roles ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-moz-placeholder{color:#aaaaaa}verdocs-template-roles :-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::placeholder{color:#aaaaaa}';const A=class{constructor(s){e(this,s),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.store=null,this.endpoint=a.getDefault(),this.templateId="",this.sender=n.EVERYONE,this.saving=!1}async componentWillLoad(){var e,t,s,i,o;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[SENDER] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[SENDER] Unable to start builder session, must be authenticated");this.store=await M(this.endpoint,this.templateId,!1),this.sender=null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.sender}catch(e){console.log("[SENDER] Error with preview session",e),null===(s=this.sdkError)||void 0===s||s.emit(new Z(e.message,null===(i=e.response)||void 0===i?void 0:i.status,null===(o=e.response)||void 0===o?void 0:o.data))}}handleClose(){this.close.emit()}handleDismiss(e){"background-overlay"===e.target.className&&(e.preventDefault(),this.handleClose())}async handleSelectSetting(e){this.saving=!0,d(this.endpoint,this.templateId,{sender:e}).then((t=>{var s;console.log("Update result",t),(null===(s=this.store)||void 0===s?void 0:s.state)&&(this.store.state.sender=e),this.saving=!1,this.sender=e})).catch((e=>{console.log("Error saving",e),this.saving=!1}))}render(){return s(i,null,s("div",{class:"background-overlay",onClick:e=>this.handleDismiss(e)},s("div",{class:"dialog"},s("div",{class:"options"},s("div",{class:"option"},s("verdocs-radio-button",{name:"template-sender",value:n.EVERYONE,checked:this.sender===n.EVERYONE,onInput:()=>this.handleSelectSetting(n.EVERYONE)}),s("div",{class:"description"},s("div",{class:"name"},"Anyone on the Web"),s("verdocs-help-icon",{text:"Anyone can use this template. (Make its visibility is set to to 'Public' or 'Shared'.)"}))),s("div",{class:"option"},s("verdocs-radio-button",{name:"template-sender",value:n.EVERYONE_AS_CREATOR,checked:this.sender===n.EVERYONE_AS_CREATOR,onInput:()=>this.handleSelectSetting(n.EVERYONE_AS_CREATOR)}),s("div",{class:"description"},s("div",{class:"name"},"Anyone on the Web as me"),s("verdocs-help-icon",{text:"Anyone can use this template on my behalf. (Make sure its visibility is set to 'Public' or 'Shared'.)"}))),s("div",{class:"option"},s("verdocs-radio-button",{name:"template-sender",value:n.ORGANIZATION_MEMBER,checked:this.sender===n.ORGANIZATION_MEMBER,onInput:()=>this.handleSelectSetting(n.ORGANIZATION_MEMBER)}),s("div",{class:"description"},s("div",{class:"name"},"Anyone in my organization"),s("verdocs-help-icon",{text:"Anyone in my organization can use this template. (Make sure its visibility is set to 'Shared')"}))),s("div",{class:"option"},s("verdocs-radio-button",{name:"template-sender",value:n.ORGANIZATION_MEMBER_AS_CREATOR,checked:this.sender===n.ORGANIZATION_MEMBER_AS_CREATOR,onInput:()=>this.handleSelectSetting(n.ORGANIZATION_MEMBER_AS_CREATOR)}),s("div",{class:"description"},s("div",{class:"name"},"Anyone in my organization as me"),s("verdocs-help-icon",{text:"Anyone in my organization can use this template on my behalf. (Make sure its visibility is set to to 'Shared'.)"}))),s("div",{class:"option"},s("verdocs-radio-button",{name:"template-sender",value:n.CREATOR,checked:this.sender===n.CREATOR,onInput:()=>this.handleSelectSetting(n.CREATOR)}),s("div",{class:"description"},s("div",{class:"name"},"Me"),s("verdocs-help-icon",{text:"Only I can use this template."})))),s("div",{class:"buttons"},s("verdocs-button",{label:"Close",onClick:()=>this.handleClose()})))))}};A.style='verdocs-template-sender{font-family:"Inter", "Barlow", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-sender div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-sender .background-overlay{position:absolute;z-index:10000;top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background:#0000007f}verdocs-template-sender .dialog{width:340px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border-radius:4px;overflow:hidden;background:#ffffff;padding:16px;-webkit-box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4);box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4)}verdocs-template-sender .heading{display:-ms-flexbox;display:flex;font-size:20px;font-weight:500;-ms-flex-direction:row;flex-direction:row}verdocs-template-sender .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-sender .buttons verdocs-button{margin-left:16px}verdocs-template-sender .options{row-gap:10px}verdocs-template-sender .options .option{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-template-sender .options .option .description{margin-left:10px}verdocs-template-sender .options .option .description .name{display:inline-block;vertical-align:top;margin-top:4px;margin-right:4px}';export{V as verdocs_template_fields,I as verdocs_template_role_properties,P as verdocs_template_roles,A as verdocs_template_sender}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as e,H as s,F as o}from"./p-14b44491.js";import{g as n}from"./p-6de76553.js";import{g as a,a as r}from"./p-b086f9be.js";import{g as d}from"./p-ef20cb50.js";import{g as p}from"./p-
|
1
|
+
import{r as t,c as i,h as e,H as s,F as o}from"./p-14b44491.js";import{g as n}from"./p-6de76553.js";import{g as a,a as r}from"./p-b086f9be.js";import{g as d}from"./p-ef20cb50.js";import{g as p}from"./p-b72328af.js";import"./p-7648c449.js";import"./p-eab67c09.js";import"./p-dc2ad047.js";import"./p-05788c2b.js";import"./p-1b4e7078.js";import"./p-c220af42.js";const l=class{constructor(e){t(this,e),this.signatureComplete=i(this,"signatureComplete",7),this.initialComplete=i(this,"initialComplete",7),this.settingsChanged=i(this,"settingsChanged",7),this.deleted=i(this,"deleted",7),this.fieldStore=null,this.roleStore=null,this.templateid="",this.fieldname="",this.disabled=!1,this.fields=void 0,this.pageNum=void 0,this.roleName=void 0,this.fieldId=void 0,this.recipients=void 0,this.selectedRoleName=void 0,this.pdfPages=void 0,this.currentSignature=void 0,this.currentSignatureId=void 0,this.currentInitial=void 0,this.currentInitialId=void 0,this.focused=!1,this.signed=!1,this.xscale=1,this.yscale=1,this.pagenumber=1,this.preparedMessage=void 0,this.signatureUrl="",this.roleindex=0,this.showingProperties=!1}componentWillLoad(){if(this.fieldStore=d(this.templateid),this.roleStore=a(this.templateid),this.recipients&&this.recipients.length>0){const t=this.recipients.find((t=>"preparer"===t.type));console.log("Found preparer",t),t&&(this.preparedMessage=`Prepared by ${t.full_name}`)}}async showSettingsPanel(){const t=document.getElementById(`verdocs-settings-panel-${this.fieldname}`);t&&t.showPanel&&t.showPanel()}async hideSettingsPanel(){const t=document.getElementById(`verdocs-settings-panel-${this.fieldname}`);t&&t.hidePanel&&t.hidePanel()}render(){var t,i;const a=this.fieldStore.get("fields").find((t=>t.name===this.fieldname)),d=r(this.roleStore,a.role_name),l=a.rgba||n(d);if(!a)return e(o,null);const c=p(a),h=null!==(i=null!==(t=this.disabled)&&void 0!==t?t:c.disabled)&&void 0!==i&&i;return e(s,{class:{focused:this.focused,disabled:h},style:{backgroundColor:l}},e("button",{class:{hide:this.signed}},"$"),e("div",this.signed?{class:"frame"}:{style:{display:"none"}}),e("img",{width:"100%",height:"100%",src:this.signatureUrl,alt:"Payment Icon"}))}};l.style='verdocs-field-payment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;position:relative;border:1px solid #cfa;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-payment.disabled{opacity:0.5}verdocs-field-payment button,verdocs-field-payment div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-field-payment button{color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-payment button.hide{display:none}verdocs-field-payment input{float:left;font-family:Arial, sans-serif}verdocs-field-payment select{position:absolute;font-family:Arial, sans-serif;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-payment .frame{width:100%;height:100%;background-size:contain;text-align:left}verdocs-field-payment .frame img{position:absolute;height:auto;width:100%}verdocs-field-payment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}verdocs-field-payment .settings-icon{position:absolute;top:-3px;left:-20px;display:inline-block;cursor:pointer;opacity:0.3}verdocs-field-payment .settings-icon svg{fill:#707ae5}verdocs-field-payment .settings-icon:hover{opacity:1}';export{l as verdocs_field_payment}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,c as i,h as o,H as t,F as s,a as n}from"./p-14b44491.js";import{t as l,k as a,c as d}from"./p-dc2ad047.js";import{b as r}from"./p-29f64c27.js";import"./p-05788c2b.js";import{V as c}from"./p-e04d8f5d.js";import{i as p}from"./p-5e808a0b.js";import{s as h}from"./p-
|
1
|
+
import{r as e,c as i,h as o,H as t,F as s,a as n}from"./p-14b44491.js";import{t as l,k as a,c as d}from"./p-dc2ad047.js";import{b as r}from"./p-29f64c27.js";import"./p-05788c2b.js";import{V as c}from"./p-e04d8f5d.js";import{i as p}from"./p-5e808a0b.js";import{s as h}from"./p-b72328af.js";import{S as v}from"./p-7a1b2643.js";import"./p-eab67c09.js";import"./p-1b4e7078.js";import"./p-c220af42.js";const x=class{constructor(o){e(this,o),this.sdkError=i(this,"sdkError",7),this.envelopeUpdated=i(this,"envelopeUpdated",7),this.another=i(this,"another",7),this.view=i(this,"view",7),this.next=i(this,"next",7),this.endpoint=c.getDefault(),this.envelopeId="",this.headerTargetId=null,this.canceling=!1,this.envelope=null,this.roleNames=[],this.showCancelDone=!1}componentWillLoad(){this.endpoint.loadSession()}async componentWillRender(){if(this.envelopeId)return this.reloadEnvelope();console.error("[VIEW] Missing required envelopeId")}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null,i=document.getElementById("verdocs-view-header");e&&i&&(console.log("[VIEW] Moving header"),i.remove(),e.append(i))}async reloadEnvelope(){var e,i,o;console.log("[VIEW] Loading envelope...");try{this.envelope=await l(this.endpoint,this.envelopeId),console.log("[VIEW] Loaded envelope",this.envelope),this.roleNames=this.envelope.recipients.map((e=>e.role_name)),setTimeout((async()=>{console.log("[VIEW] Reloading envelope..."),this.envelope=await l(this.endpoint,this.envelopeId),console.log("[VIEW] Reloaded envelope",this.envelope)}),2e3)}catch(t){null===(e=this.sdkError)||void 0===e||e.emit(new v(t.message,null===(i=t.response)||void 0===i?void 0:i.status,null===(o=t.response)||void 0===o?void 0:o.data))}}handlePageRendered(e){console.log("[VIEW] Page rendered",e.detail)}async handleOptionSelected(e){var i,o;switch(e.detail.id){case"cancel":confirm("Are you sure you wish to cancel this envelope? This action cannot be undone.")&&(this.canceling=!0,d(this.endpoint,this.envelopeId).then((e=>(this.canceling=!1,console.log("[VIEW] Envelope canceled",e),l(this.endpoint,this.envelopeId)))).then((e=>{console.log("[VIEW] Loaded new envelope details",e),this.envelope=e})).catch((e=>{var i,o,t;this.canceling=!1,console.log("[VIEW] Error canceling envelope",e),null===(i=this.sdkError)||void 0===i||i.emit(new v(e.message,null===(o=e.response)||void 0===o?void 0:o.status,null===(t=e.response)||void 0===t?void 0:t.data))})),this.showCancelDone=!0,null===(i=this.envelopeUpdated)||void 0===i||i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"canceled"}));break;case"print":window.print(),null===(o=this.envelopeUpdated)||void 0===o||o.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download-attachments":{const e=await a(this.endpoint,this.envelopeId,this.envelope.envelope_document_id);window.open(e,"_blank")}break;case"download-certificate":{const e=await a(this.endpoint,this.envelopeId,this.envelope.certificate_document_id);window.open(e,"_blank")}break;case"download-all":h(this.endpoint,[this.envelope]).then((()=>{var e;null===(e=this.envelopeUpdated)||void 0===e||e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"downloaded"})})).catch((e=>{console.log("Error downloading Zip",e)}))}}render(){var e;if(!this.envelope)return o(t,null,o("img",{src:"https://verdocs-public-assets.s3.amazonaws.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"}));const i=[{id:"print",label:"Print"}];r(this.endpoint.session,this.envelope)&&i.push({id:"cancel",label:"Cancel"});const n=this.envelope.documents.length>0,l=this.envelope.documents.filter((e=>"attachment"===e.type)).length,a=void 0!==this.envelope.documents.find((e=>"certificate"===e.type));return(n||a)&&(i.push({label:""}),n&&i.push({id:"download-attachments",label:l>1?"Download Documents":"Download Document"}),a&&i.push({id:"download-certificate",label:"Download Certificate"}),n&&a&&i.push({id:"download-all",label:"Download All Files"})),o(t,null,o("div",{id:"verdocs-view-header"},o("div",{class:"inner"},o("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),o("div",{class:"title"},this.envelope.name),o("div",{style:{flex:"1"}}),o("div",{style:{marginLeft:"10px"}}),o("verdocs-dropdown",{options:i,onOptionSelected:e=>this.handleOptionSelected(e)}))),o("div",{class:"document",style:{paddingTop:this.headerTargetId?"70px":"15px"}},((null===(e=this.envelope)||void 0===e?void 0:e.documents)||[]).filter((e=>"certificate"!==e.type)).map((e=>{const i=p(1,e.page_numbers);return o(s,null,i.map((i=>o("verdocs-envelope-document-page",{envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,type:"filled",virtualWidth:612,virtualHeight:792,pageNumber:i,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}))),this.showCancelDone&&o("verdocs-ok-dialog",{heading:"Cancelled",message:"This envelope has been cancelled successfully.",onNext:()=>{this.showCancelDone=!1}}),this.canceling&&o("div",{class:"loading-indicator"},o("verdocs-loader",null)))}get component(){return n(this)}};x.style='verdocs-view{display:-ms-flexbox;display:flex;overflow:hidden;min-height:600px;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-view div,verdocs-view canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-view .document{-ms-flex:1;flex:1;width:100%;height:100%;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;max-width:1200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-view .document .inner{width:100%;max-width:1028px}verdocs-view .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}#verdocs-view-header{width:100%;color:#fff;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;padding:0 20px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}@media all and (max-width: 500px){#verdocs-view-header{padding:0 10px}}#verdocs-view-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}@media all and (max-width: 500px){#verdocs-view-header .inner{padding:0 10px}}#verdocs-view-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-view-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}';export{x as verdocs_view}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,c as t,h as i,H as s}from"./p-14b44491.js";import"./p-05788c2b.js";import{V as o,b as l,u as a}from"./p-e04d8f5d.js";import{g as n}from"./p-ef20cb50.js";import{g as r,b as d,a as c}from"./p-b086f9be.js";import{g as h}from"./p-45ecd6eb.js";import{r as p}from"./p-a3d7cdda.js";import{S as m}from"./p-7a1b2643.js";import{j as v}from"./p-dc2ad047.js";import{a as u,i as x}from"./p-e8ce0b6f.js";import{g as f}from"./p-6de76553.js";import{c as b,d as g}from"./p-567a6e7c.js";import{D as y,P as w,J as k,a as S,F as E,b as z,T as C}from"./p-029ae656.js";import{V as T}from"./p-ed416acf.js";import"./p-7648c449.js";import"./p-eab67c09.js";import"./p-839f6f0d.js";import"./p-c220af42.js";const I=class{constructor(i){e(this,i),this.sdkError=t(this,"sdkError",7),this.templateStore=null,this.fieldStore=null,this.roleStore=null,this.endpoint=o.getDefault(),this.templateId=null,this.loading=!0}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[PREVIEW] Unable to start builder session, must be authenticated");h(this.endpoint,this.templateId,!0).then((e=>{var t,i;this.templateStore=e,console.log("[PREVIEW] Loaded Template Store",e.state),this.fieldStore=n(this.templateId),this.roleStore=r(this.templateId),console.log("RS",null===(t=this.roleStore)||void 0===t?void 0:t.state),console.log("FS",null===(i=this.fieldStore)||void 0===i?void 0:i.state),console.log("[PREVIEW] Loaded template",this.templateStore.state,this.roleStore.get("roles"),this.fieldStore.get("fields")),this.loading=!1})).catch((e=>{console.log(e)}))}catch(s){console.log("[PREVIEW] Error with preview session",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}handlePageRendered(e){var t,i;const s=e.detail,o=null===(i=null===(t=this.templateStore)||void 0===t?void 0:t.state)||void 0===i?void 0:i.fields.filter((e=>e.page_sequence===s.pageNumber));console.log("[PREVIEW] Page rendered",s,o),o.forEach((e=>p(e,s,{disabled:!0,editable:!1,draggable:!1})))}render(){var e,t;if(this.loading)return i(s,null,i("verdocs-loader",null));const o=[...null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.pages];return o.sort(((e,t)=>e.sequence-t.sequence)),i(s,null,o.map((e=>i("verdocs-template-document-page",{templateId:e.template_id,documentId:e.document_id,pageNumber:e.sequence,virtualWidth:612,virtualHeight:792,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}};I.style='verdocs-preview{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}';const L='<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>',R=class{constructor(i){e(this,i),this.send=t(this,"send",7),this.exit=t(this,"exit",7),this.sdkError=t(this,"sdkError",7),this.searchContacts=t(this,"searchContacts",7),this.levels=[],this.templateStore=null,this.roleStore=null,this.endpoint=o.getDefault(),this.templateId=null,this.environment="web",this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`,this.rolesAtLevel={},this.showPickerForId="",this.sessionContacts=[],this.sending=!1,this.rolesCompleted={}}async reset(){this.rolesCompleted={}}async componentWillLoad(){var e,t,i,s,o,l;try{const s=this.endpoint.loadSession();if(!this.templateId)return void console.log(`[SEND] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[SEND] Unable to start builder session, must be authenticated");if(this.templateStore=await h(this.endpoint,this.templateId,!1),this.roleStore=r(this.templateId),(null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_sendable)||console.warn("[SEND] Template is not sendable",this.templateId),this.roleStore.get("roles")){const e={};this.rolesCompleted={},this.roleStore.get("roles").forEach((t=>{const i=t.sequence-1;e[i]||(e[i]=[]);const s=`r-${i}-${e[i].length}`;e[i].push({...t,id:s}),t.full_name&&(t.email||t.phone)&&(this.rolesCompleted[s]={...t,id:s})})),this.rolesAtLevel=e,this.levels=Object.keys(e).map((e=>+e)),this.levels.sort(((e,t)=>e-t))}(null===(i=null==s?void 0:s.session)||void 0===i?void 0:i.profile)&&this.sessionContacts.push({id:s.session.profile.id,name:`${s.session.profile.first_name} ${s.session.profile.last_name}`,email:s.session.profile.email,phone:s.session.profile.phone})}catch(e){console.log("[SEND] Error with preview session",e),null===(s=this.sdkError)||void 0===s||s.emit(new m(e.message,null===(o=e.response)||void 0===o?void 0:o.status,null===(l=e.response)||void 0===l?void 0:l.data))}}getLevelIcon(e){return i("div",e<0?{class:"level-icon",innerHTML:'<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>'}:e>=this.levels.length?{class:"level-icon",innerHTML:'<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>'}:{class:"level-icon",innerHTML:'<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>'})}handleSelectContact(e,t){e.preventDefault(),this.rolesCompleted[t.id]={...t,...e.detail},this.showPickerForId=""}handleClickRole(e,t){e.stopPropagation(),this.showPickerForId=t.id}handleSend(e){var t,i;if(this.sending)return void console.log("Skipping duplicate send",e);console.log("Sending",e),e.preventDefault(),e.stopPropagation(),this.sending=!0;const s={template_id:this.templateId,name:null===(i=null===(t=this.templateStore)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name,environment:this.environment,roles:Object.values(this.rolesCompleted),prepared_fields:[]};console.log("[SEND] Creating envelope",s),v(this.endpoint,s).then((e=>{var t;console.log("[SEND] Send envelope",e),this.reset().catch((e=>console.log("Unknown Error",e))),this.sending=!1,null===(t=this.send)||void 0===t||t.emit({...s,envelope_id:e.id,envelope:e})})).catch((e=>{console.log("Send error",e),this.sending=!1}))}handleCancel(e){var t;e.stopPropagation(),null===(t=this.exit)||void 0===t||t.emit()}render(){var e,t;const o=d(this.roleStore),l=Object.values(this.rolesCompleted).filter((e=>u(e.email)||x(e.phone))).length>=o.length;return i(s,{class:{sendable:null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:"level level-start"},this.getLevelIcon(-1),i("div",{class:"complete"},"Send Envelope")),this.levels.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon(e),this.rolesAtLevel[e].map((e=>{var t,s,o,l,a,n;const r=`verdocs-send-recipient-${e.name}`;return e.email?i("div",{class:"recipient",style:{borderColor:f(c(this.roleStore,e.name))},onClick:t=>this.handleClickRole(t,e),id:r},null!==(a=null===(l=this.rolesCompleted[e.id])||void 0===l?void 0:l.full_name)&&void 0!==a?a:e.full_name,i("div",{class:"icon",innerHTML:L}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:r,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(n=this.rolesCompleted[e.id])&&void 0!==n?n:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}}))):i("div",{class:"recipient",style:{backgroundColor:f(c(this.roleStore,e.name))},onClick:t=>this.handleClickRole(t,e),id:r},null!==(s=null===(t=this.rolesCompleted[e.id])||void 0===t?void 0:t.full_name)&&void 0!==s?s:e.name,i("div",{class:"icon",innerHTML:L}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:r,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(o=this.rolesCompleted[e.id])&&void 0!==o?o:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}})))}))))),i("div",{class:"level level-done"},this.getLevelIcon(this.levels.length),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},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:!l||this.sending,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}};R.style='verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:none}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 #97979744}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:#00000089}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-direction:row;flex-direction:row}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 U=class{constructor(i){e(this,i),this.exit=t(this,"exit",7),this.next=t(this,"next",7),this.templateUpdated=t(this,"templateUpdated",7),this.sdkError=t(this,"sdkError",7),this.endpoint=o.getDefault(),this.templateId="",this.uploading=!1,this.progressLabel="Uploading...",this.progressPercent=0,this.showDeleteError=!1,this.confirmDeleteDocument=null,this.store=null}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1)}catch(s){console.log("[TEMPLATE ATTACHMENTS] Error loading template",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}handleCancel(e){e.stopPropagation(),this.exit.emit()}handleUploadProgress(e){e>=99?(this.progressPercent=100,this.progressLabel="Processing..."):this.progressPercent=e}async handleUpload(e){var t,i,s,o;e.stopPropagation();const l=e.detail.file;if(l){console.log("[ATTACHMENTS] Uploading...",l),this.uploading=!0,this.progressLabel="Uploading...";try{const e=await b(this.endpoint,this.templateId,l,this.handleUploadProgress.bind(this));console.log("[ATTACHMENTS] Created attachment",e),this.store=await h(this.endpoint,this.templateId,!1),console.log("[ATTACHMENTS] Updated template",this.store.state),null===(t=this.templateUpdated)||void 0===t||t.emit({endpoint:this.endpoint,template:this.store.state,event:"attachments"}),this.uploading=!1,this.progressLabel="",this.progressPercent=0}catch(e){console.log("[ATTACHMENTS] Error creating template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data)),this.uploading=!1}}}handleNext(e){var t;e.stopPropagation(),this.uploading=!1,this.progressLabel="",this.progressPercent=0,null===(t=this.next)||void 0===t||t.emit({template:this.store.state})}async confirmDelete(){await g(this.endpoint,this.templateId,this.confirmDeleteDocument.id),this.store=await h(this.endpoint,this.templateId,!1),console.log("[ATTACHMENTS] New template",this.store.state),this.confirmDeleteDocument=null}async handleDelete(e){var t;(null===(t=this.store.state)||void 0===t?void 0:t.template_documents.length)>1?this.confirmDeleteDocument=e:this.showDeleteError=!0}getFileIcon(e){switch(e.mime){case"application/pdf":return S;case"image/jpeg":return k;case"image/png":return w;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return y}return E}render(){var e,t,o;if(!this.endpoint.session)return i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}));const l=null===(e=this.store)||void 0===e?void 0:e.state;return l.isLoaded?this.endpoint.session&&l.profile_id?i(s,null,i("h5",null,"Existing Attachments"),i("div",{class:"attachments"},null===(t=this.store)||void 0===t?void 0:t.state.template_documents.map((e=>i("div",{class:"attachment"},i("div",{class:"file-icon",innerHTML:this.getFileIcon(e)}),i("div",{class:"filename",title:e.name},e.name),i("div",{class:"pages"},i("div",{class:"count"},e.page_numbers),i("div",{class:"pages-icon",innerHTML:z})),i("div",{class:"trash-icon",innerHTML:C,onClick:()=>this.handleDelete(e)}))))),i("h5",null,"Attach a New Document"),this.uploading?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:!0,percent:this.progressPercent,label:this.progressLabel}))):i("verdocs-file-chooser",{onFileSelected:e=>this.handleUpload(e)}),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.uploading}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleNext(e),disabled:!(null===(o=this.store)||void 0===o?void 0:o.state.template_documents.length)||this.uploading})),this.showDeleteError&&i("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:()=>this.showDeleteError=!1}),this.confirmDeleteDocument&&i("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:()=>this.confirmDelete(),showCancel:!0,onExit:()=>{this.confirmDeleteDocument=null}})):i(s,{class:"empty"}):i(s,{class:"loading"},i("verdocs-loader",null))}};U.style='verdocs-template-attachments{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}';const M=["attachments","roles","settings","fields","preview"],N=class{constructor(i){e(this,i),this.sdkError=t(this,"sdkError",7),this.stepChanged=t(this,"stepChanged",7),this.endpoint=o.getDefault(),this.templateId=null,this.step="preview",this.store=null}onStepChanged(){console.log("Step changed",this.step,this.templateId),this.loadTemplate().catch((e=>console.log("Unknown Error",e)))}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.endpoint.session)return void console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");if(!this.templateId)return void(this.step="preview");this.loadTemplate().catch((e=>console.log("[BUILD_TABS] Unable to load template",e)))}catch(s){console.log("[BUILD_TABS] Error loading template",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}async loadTemplate(){this.templateId&&(this.store=await h(this.endpoint,this.templateId,!1))}setStep(e){var t;console.log("Selected step",e.detail.tab.id),e.stopPropagation(),e.preventDefault(),this.step=e.detail.tab.id,null===(t=this.stepChanged)||void 0===t||t.emit(e.detail.tab.id)}render(){var e,t,o,l,a,n,r,d,c;if(!this.endpoint.session)return i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}));let h=!1,p=!1,m=!1;console.log("[BUILD_TABS] Rendering tabs",this.templateId,this.step),this.templateId&&this.store&&this.store.state&&(m=(null===(o=null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.template_documents)||void 0===o?void 0:o.length)>0,p=m&&(null===(n=null===(a=null===(l=this.store)||void 0===l?void 0:l.state)||void 0===a?void 0:a.roles)||void 0===n?void 0:n.length)>0,h=p&&(null===(c=null===(d=null===(r=this.store)||void 0===r?void 0:r.state)||void 0===d?void 0:d.fields)||void 0===c?void 0:c.length)>0);let v=Math.max(M.indexOf(this.step),0);return!h&&v>=4&&(v=3),!p&&v>=3&&(v=1),!m&&v>=1&&(v=0),console.log({selectedStepIndex:v,canPreview:h,canEditFields:p,canEditRoles:m}),i(s,null,i("verdocs-tabs",{onSelectTab:e=>this.setStep(e),selectedTab:v,tabs:[{id:"attachments",disabled:!1,label:this.templateId&&this.store?"Attachment(s)":"Upload Attachment(s)"},{id:"roles",disabled:!m,label:"Roles"},{id:"settings",disabled:!p,label:"Settings"},{id:"fields",disabled:!p,label:"Fields"},{id:"preview",disabled:!h,label:"Preview/Send"}]}))}static get watchers(){return{step:["onStepChanged"]}}};N.style='verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:20px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-build-tabs verdocs-template-attachments,verdocs-template-build-tabs verdocs-template-roles{margin:20px}verdocs-template-build-tabs verdocs-template-fields{border-top:1px solid #777777}verdocs-template-build-tabs verdocs-template-attachments{padding:20px;background:#ffffff}verdocs-template-build-tabs verdocs-template-fields{width:100%}verdocs-template-build-tabs verdocs-preview{-ms-flex:1;flex:1}';const A=class{constructor(i){e(this,i),this.exit=t(this,"exit",7),this.next=t(this,"next",7),this.sdkError=t(this,"sdkError",7),this.templateCreated=t(this,"templateCreated",7),this.endpoint=o.getDefault(),this.file=void 0,this.creating=!1,this.progressLabel="Uploading...",this.progressPercent=0}componentWillLoad(){this.endpoint.setTimeout(3e4),this.endpoint.loadSession()}handleFileChanged(e){var t;this.file=(null===(t=e.target.files)||void 0===t?void 0:t[0])||null,console.log("[CREATE] Selected file",this.file)}handleUpload(e){e.stopPropagation(),document.getElementById("verdocs-template-create-file").click()}handleCancel(e){e.stopPropagation(),this.exit.emit()}async handleSubmit(e){var t,i,s;if(e.stopPropagation(),console.log("Submitting"),this.file){this.creating=!0,this.progressLabel="Uploading...";try{const e=await l(this.endpoint,{name:this.file.name,documents:[this.file]},(e=>{e>=99?(this.progressLabel="Processing...",this.progressPercent=100):this.progressPercent=e}));console.log("[CREATE] Created template",e),h(this.endpoint,e.id,!0).then((()=>{var t,i;null===(t=this.templateCreated)||void 0===t||t.emit({endpoint:this.endpoint,template:e,templateId:e.id}),null===(i=this.next)||void 0===i||i.emit(e),this.creating=!1,this.progressLabel="",this.progressPercent=0})).catch((e=>{console.log(e)}))}catch(e){console.log("[CREATE] Error creating template",e),null===(t=this.sdkError)||void 0===t||t.emit(new m(e.message,null===(i=e.response)||void 0===i?void 0:i.status,null===(s=e.response)||void 0===s?void 0:s.data)),this.creating=!1}}}render(){return i(s,null,this.endpoint.session?i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("input",{type:"file",id:"verdocs-template-create-file",multiple:!0,accept:"application/pdf",style:{display:"none"},onChange:e=>this.handleFileChanged(e)}),this.creating?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:!0,percent:this.progressPercent,label:this.progressLabel}))):i("div",{class:"upload-box",onDrop:e=>{e.preventDefault(),e.target.classList.remove("drag-over"),this.file=e.dataTransfer.files[0]},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDragEnter:e=>e.target.classList.add("drag-over"),onDragLeave:e=>e.target.classList.remove("drag-over")},i("div",null,i("span",{innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></svg>'})),i("div",{style:{marginTop:"20px",fontSize:"20px",fontWeight:"bold",overflowWrap:"anywhere"}},this.file?this.file.name:"Drag a file here"),i("div",{style:{marginTop:"20px",marginBottom:"20px",fontSize:"16px",height:"20px"}},this.file?" ":"Or, if you prefer..."),i("verdocs-button",{label:this.file?"Select a different file":"Select a file from your computer",size:"small",onClick:e=>this.handleUpload(e)})),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.creating}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleSubmit(e),disabled:!this.file||this.creating}))):i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};A.style='verdocs-template-create{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-create form{background-color:#ffffff;padding:12px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-create form .upload-box{-webkit-box-sizing:border-box;box-sizing:border-box;width:320px;text-align:center;padding:44px 18px 66px;border:2px dashed #979797;color:rgba(0, 0, 0, 0.54)}verdocs-template-create form .upload-box.drag-over{border:2px solid #4c56cb}verdocs-template-create form .upload-box svg{width:64px;fill:#5c6575}verdocs-template-create .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .progress-wrapper{padding:20px}verdocs-template-create .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-create ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-create ::-moz-placeholder{color:#aaaaaa}verdocs-template-create :-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::placeholder{color:#aaaaaa}';const D=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.name="",this.dirty=!1}async componentWillLoad(){var e,t,i,s,o;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.name=null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.name,this.dirty=!1}catch(e){console.log("[TEMPLATE NAME] Error loading template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data))}}handleCancel(e){var t,i,s;e.stopPropagation(),this.name=null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name,this.dirty=!1,console.log("Closing"),null===(s=this.close)||void 0===s||s.emit()}async handleSave(e){var t,i,s;e.stopPropagation(),await a(this.endpoint,this.templateId,{name:this.name}),(null===(t=this.store)||void 0===t?void 0:t.state)&&(this.store.state.name=this.name),this.dirty=!1,null===(i=this.templateUpdated)||void 0===i||i.emit({endpoint:this.endpoint,template:this.store.state,event:"name"}),null===(s=this.close)||void 0===s||s.emit()}render(){var e,t;return this.endpoint.session?(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoading)?i(s,{class:"loading"},i("verdocs-loader",null)):i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("label",{htmlFor:"verdocs-template-name"},"Template Name"),i("verdocs-text-input",{id:"verdocs-template-name",value:this.name,autocomplete:"off",placeholder:"Template Name...",onInput:e=>{var t,i;this.name=e.target.value,this.dirty=this.name!==(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name)}}),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)})))):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};D.style="";const j=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.showPlanBlocker=!1,this.sendReminders=!1,this.firstReminderDays="1",this.reminderDays="1",this.dirty=!1}async componentWillLoad(){var e,t,i,s,o;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.sendReminders=!!(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.reminder_id),this.dirty=!1}catch(e){console.log("[TEMPLATE REMINDERS] Error loading template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data))}}handleCancel(e){var t,i,s;e.stopPropagation(),this.sendReminders=!!(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.reminder_id),this.dirty=!1,null===(s=this.close)||void 0===s||s.emit()}async handleSave(e){var t,i,s,o,l,a,n,r,d,c,p,v;e.stopPropagation();try{if(this.sendReminders){const e={setup_time:+this.firstReminderDays,interval_time:+this.reminderDays};(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.reminder_id)?(await function(e,t,i,s){return e.api.put("/templates/".concat(t,"/reminder/").concat(i),s).then((function(e){return e.data}))}(this.endpoint,this.templateId,null===(s=this.store)||void 0===s?void 0:s.state.reminder_id,e),this.store=await h(this.endpoint,this.templateId,!1)):(await function(e,t,i){return e.api.post("/templates/".concat(t,"/reminder/"),i).then((function(e){return e.data}))}(this.endpoint,this.templateId,e),this.store=await h(this.endpoint,this.templateId,!1))}else await(c=this.endpoint,p=this.templateId,v=null===(o=this.store)||void 0===o?void 0:o.state.reminder_id,c.api.delete("/templates/".concat(p,"/reminder/").concat(v)).then((function(e){return e.data}))),this.store=await h(this.endpoint,this.templateId,!1);null===(l=this.templateUpdated)||void 0===l||l.emit({endpoint:this.endpoint,template:this.store.state,event:"attachments"})}catch(e){console.log("[TEMPLATE REMINDERS] Unable to update reminders",e),T(e.message),null===(a=this.sdkError)||void 0===a||a.emit(new m(e.message,null===(n=e.response)||void 0===n?void 0:n.status,null===(r=e.response)||void 0===r?void 0:r.data))}this.dirty=!1,null===(d=this.close)||void 0===d||d.emit()}render(){var e,t;return this.endpoint.session?this.endpoint.session&&(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoaded)?i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("h5",null,"Reminders"),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-send-reminders"},"Send Automatic Reminders"),i("verdocs-checkbox",{id:"verdocs-send-reminders",name:"automatic-reminders",checked:this.sendReminders,value:"on",onInput:e=>{this.sendReminders=e.target.checked,this.dirty=!0}})),i("p",null,i("strong",null,"NOTE:")," Reminders will only be sent for up to 14 days."),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-first-reminder-days"},"Days Before First Reminder"),i("verdocs-text-input",{id:"verdocs-first-reminder-days",type:"number",value:this.firstReminderDays,onInput:e=>{this.firstReminderDays=e.target.value,this.dirty=!0},disabled:!this.sendReminders})),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-days-between-reminders"},"Days Between Reminders"),i("verdocs-text-input",{id:"verdocs-days-between-reminders",type:"number",value:this.reminderDays,onInput:e=>{this.reminderDays=e.target.value,this.dirty=!0},disabled:!this.sendReminders})),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)}))),this.showPlanBlocker&&i("verdocs-ok-dialog",{heading:"Upgrade to access this feature",message:"Please upgrade your plan to access this feature.",onNext:()=>this.showPlanBlocker=!1})):i(s,{class:"empty"}):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};j.style='verdocs-template-reminders{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-reminders.loading{min-height:300px;position:relative;display:block}verdocs-template-reminders.empty{display:none}verdocs-template-reminders form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-reminders form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 20px 0}verdocs-template-reminders form label{font-size:16px;font-weight:500;margin:0 0 6px 0;color:#33364b}verdocs-template-reminders form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-reminders form input:focus{outline:none}verdocs-template-reminders form .input-row{display:-ms-flexbox;display:flex;margin:0 0 10px 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-reminders form .input-row label{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-reminders form .input-row verdocs-text-input{margin:0;display:-ms-flexbox;display:flex;-ms-flex:0 0 60px;flex:0 0 60px}verdocs-template-reminders form .input-row verdocs-text-input input{text-align:center}verdocs-template-reminders form .input-row verdocs-checkbox{display:-ms-flexbox;display:flex;-ms-flex:0 0 40px;flex:0 0 40px;-ms-flex-pack:center;justify-content:center}verdocs-template-reminders .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-reminders ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::-moz-placeholder{color:#aaaaaa}verdocs-template-reminders :-ms-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::placeholder{color:#aaaaaa}';const H=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.dirty=!1,this.personal=!1,this.public=!1}async componentWillLoad(){var e,t,i,s,o,l,a;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[VISIBILITY] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[VISIBILITY] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.personal=(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_personal)||!0,this.public=(null===(s=null===(i=this.store)||void 0===i?void 0:i.state)||void 0===s?void 0:s.is_public)||!1,this.dirty=!1}catch(e){console.log("[TEMPLATE VISIBILITY] Error loading template",e),null===(o=this.sdkError)||void 0===o||o.emit(new m(e.message,null===(l=e.response)||void 0===l?void 0:l.status,null===(a=e.response)||void 0===a?void 0:a.data))}}handleCancel(e){var t,i,s,o,l;e.stopPropagation(),this.personal=null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.is_personal,this.public=null===(o=null===(s=this.store)||void 0===s?void 0:s.state)||void 0===o?void 0:o.is_public,this.dirty=!1,null===(l=this.close)||void 0===l||l.emit()}async handleSave(e){var t,i,s;e.stopPropagation(),await a(this.endpoint,this.templateId,{is_personal:this.personal,is_public:this.public}),(null===(t=this.store)||void 0===t?void 0:t.state)&&(this.store.state.is_personal=this.personal,this.store.state.is_public=this.public),this.dirty=!1,null===(i=this.templateUpdated)||void 0===i||i.emit({endpoint:this.endpoint,template:this.store.state,event:"visibility"}),null===(s=this.close)||void 0===s||s.emit()}render(){var e,t;return this.endpoint.session?this.endpoint.session&&(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoaded)?i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("h5",null,"Visibility"),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-is-shared"},"Shared"),i("verdocs-checkbox",{id:"verdocs-is-shared",name:"is-shared",checked:!this.personal,value:"on",onInput:e=>{this.personal=!e.target.checked,this.dirty=!0}})),i("div",{class:"description"},"Shared templates are visible to other members of your Organization (if any)."),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-is-public"},"Public"),i("verdocs-checkbox",{id:"verdocs-is-public",name:"is-public",checked:this.public,value:"on",onInput:e=>{this.public=e.target.checked,this.dirty=!0}})),i("div",{class:"description"},"Public templates may appear in results when any other user searches for templates. Note that a template may be both Personal and Public, which may be useful if you want your template to be found via search but not otherwise displayed to other members of your Organization (if any)."),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)})))):i(s,{class:"empty"}):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};H.style='verdocs-template-visibility{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-visibility.loading{min-height:300px;position:relative;display:block}verdocs-template-visibility.empty{display:none}verdocs-template-visibility form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-visibility form .description{font-size:14px;text-align:justify;color:#5c6575}verdocs-template-visibility form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0}verdocs-template-visibility form label{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:16px;font-weight:500;margin:0 0 4px 0;color:#33364b}verdocs-template-visibility form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-visibility form input:focus{outline:none}verdocs-template-visibility form .input-row{display:-ms-flexbox;display:flex;margin:20px 0 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility form .input-row verdocs-text-input{margin:0;display:-ms-flexbox;display:flex;-ms-flex:0 0 40px;flex:0 0 40px}verdocs-template-visibility form .input-row verdocs-text-input input{text-align:center}verdocs-template-visibility form .input-row verdocs-checkbox{-ms-flex:0;flex:0;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}verdocs-template-visibility form .input-row verdocs-checkbox label>input[type=checkbox]+*::before{margin-right:0}verdocs-template-visibility .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:25px;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-moz-placeholder{color:#aaaaaa}verdocs-template-visibility :-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::placeholder{color:#aaaaaa}';export{I as verdocs_preview,R as verdocs_send,U as verdocs_template_attachments,N as verdocs_template_build_tabs,A as verdocs_template_create,D as verdocs_template_name,j as verdocs_template_reminders,H as verdocs_template_visibility}
|
1
|
+
import{r as e,c as t,h as i,H as s}from"./p-14b44491.js";import"./p-05788c2b.js";import{V as o,b as l,u as a}from"./p-e04d8f5d.js";import{g as n}from"./p-ef20cb50.js";import{g as r,b as d,a as c}from"./p-b086f9be.js";import{g as h}from"./p-45ecd6eb.js";import{r as p}from"./p-b72328af.js";import{S as m}from"./p-7a1b2643.js";import{j as v}from"./p-dc2ad047.js";import{a as u,i as x}from"./p-e8ce0b6f.js";import{g as f}from"./p-6de76553.js";import{c as b,d as g}from"./p-567a6e7c.js";import{D as y,P as w,J as k,a as S,F as E,b as z,T as C}from"./p-029ae656.js";import{V as T}from"./p-ed416acf.js";import"./p-7648c449.js";import"./p-eab67c09.js";import"./p-1b4e7078.js";import"./p-c220af42.js";const I=class{constructor(i){e(this,i),this.sdkError=t(this,"sdkError",7),this.templateStore=null,this.fieldStore=null,this.roleStore=null,this.endpoint=o.getDefault(),this.templateId=null,this.loading=!0}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[PREVIEW] Unable to start builder session, must be authenticated");h(this.endpoint,this.templateId,!0).then((e=>{var t,i;this.templateStore=e,console.log("[PREVIEW] Loaded Template Store",e.state),this.fieldStore=n(this.templateId),this.roleStore=r(this.templateId),console.log("RS",null===(t=this.roleStore)||void 0===t?void 0:t.state),console.log("FS",null===(i=this.fieldStore)||void 0===i?void 0:i.state),console.log("[PREVIEW] Loaded template",this.templateStore.state,this.roleStore.get("roles"),this.fieldStore.get("fields")),this.loading=!1})).catch((e=>{console.log(e)}))}catch(s){console.log("[PREVIEW] Error with preview session",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}handlePageRendered(e){var t,i;const s=e.detail,o=null===(i=null===(t=this.templateStore)||void 0===t?void 0:t.state)||void 0===i?void 0:i.fields.filter((e=>e.page_sequence===s.pageNumber));console.log("[PREVIEW] Page rendered",s,o),o.forEach((e=>p(e,s,{disabled:!0,editable:!1,draggable:!1})))}render(){var e,t;if(this.loading)return i(s,null,i("verdocs-loader",null));const o=[...null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.pages];return o.sort(((e,t)=>e.sequence-t.sequence)),i(s,null,o.map((e=>i("verdocs-template-document-page",{templateId:e.template_id,documentId:e.document_id,pageNumber:e.sequence,virtualWidth:612,virtualHeight:792,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}};I.style='verdocs-preview{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}';const L='<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>',R=class{constructor(i){e(this,i),this.send=t(this,"send",7),this.exit=t(this,"exit",7),this.sdkError=t(this,"sdkError",7),this.searchContacts=t(this,"searchContacts",7),this.levels=[],this.templateStore=null,this.roleStore=null,this.endpoint=o.getDefault(),this.templateId=null,this.environment="web",this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`,this.rolesAtLevel={},this.showPickerForId="",this.sessionContacts=[],this.sending=!1,this.rolesCompleted={}}async reset(){this.rolesCompleted={}}async componentWillLoad(){var e,t,i,s,o,l;try{const s=this.endpoint.loadSession();if(!this.templateId)return void console.log(`[SEND] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[SEND] Unable to start builder session, must be authenticated");if(this.templateStore=await h(this.endpoint,this.templateId,!1),this.roleStore=r(this.templateId),(null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_sendable)||console.warn("[SEND] Template is not sendable",this.templateId),this.roleStore.get("roles")){const e={};this.rolesCompleted={},this.roleStore.get("roles").forEach((t=>{const i=t.sequence-1;e[i]||(e[i]=[]);const s=`r-${i}-${e[i].length}`;e[i].push({...t,id:s}),t.full_name&&(t.email||t.phone)&&(this.rolesCompleted[s]={...t,id:s})})),this.rolesAtLevel=e,this.levels=Object.keys(e).map((e=>+e)),this.levels.sort(((e,t)=>e-t))}(null===(i=null==s?void 0:s.session)||void 0===i?void 0:i.profile)&&this.sessionContacts.push({id:s.session.profile.id,name:`${s.session.profile.first_name} ${s.session.profile.last_name}`,email:s.session.profile.email,phone:s.session.profile.phone})}catch(e){console.log("[SEND] Error with preview session",e),null===(s=this.sdkError)||void 0===s||s.emit(new m(e.message,null===(o=e.response)||void 0===o?void 0:o.status,null===(l=e.response)||void 0===l?void 0:l.data))}}getLevelIcon(e){return i("div",e<0?{class:"level-icon",innerHTML:'<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>'}:e>=this.levels.length?{class:"level-icon",innerHTML:'<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>'}:{class:"level-icon",innerHTML:'<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>'})}handleSelectContact(e,t){e.preventDefault(),this.rolesCompleted[t.id]={...t,...e.detail},this.showPickerForId=""}handleClickRole(e,t){e.stopPropagation(),this.showPickerForId=t.id}handleSend(e){var t,i;if(this.sending)return void console.log("Skipping duplicate send",e);console.log("Sending",e),e.preventDefault(),e.stopPropagation(),this.sending=!0;const s={template_id:this.templateId,name:null===(i=null===(t=this.templateStore)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name,environment:this.environment,roles:Object.values(this.rolesCompleted),prepared_fields:[]};console.log("[SEND] Creating envelope",s),v(this.endpoint,s).then((e=>{var t;console.log("[SEND] Send envelope",e),this.reset().catch((e=>console.log("Unknown Error",e))),this.sending=!1,null===(t=this.send)||void 0===t||t.emit({...s,envelope_id:e.id,envelope:e})})).catch((e=>{console.log("Send error",e),this.sending=!1}))}handleCancel(e){var t;e.stopPropagation(),null===(t=this.exit)||void 0===t||t.emit()}render(){var e,t;const o=d(this.roleStore),l=Object.values(this.rolesCompleted).filter((e=>u(e.email)||x(e.phone))).length>=o.length;return i(s,{class:{sendable:null===(t=null===(e=this.templateStore)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:"level level-start"},this.getLevelIcon(-1),i("div",{class:"complete"},"Send Envelope")),this.levels.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon(e),this.rolesAtLevel[e].map((e=>{var t,s,o,l,a,n;const r=`verdocs-send-recipient-${e.name}`;return e.email?i("div",{class:"recipient",style:{borderColor:f(c(this.roleStore,e.name))},onClick:t=>this.handleClickRole(t,e),id:r},null!==(a=null===(l=this.rolesCompleted[e.id])||void 0===l?void 0:l.full_name)&&void 0!==a?a:e.full_name,i("div",{class:"icon",innerHTML:L}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:r,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(n=this.rolesCompleted[e.id])&&void 0!==n?n:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}}))):i("div",{class:"recipient",style:{backgroundColor:f(c(this.roleStore,e.name))},onClick:t=>this.handleClickRole(t,e),id:r},null!==(s=null===(t=this.rolesCompleted[e.id])||void 0===t?void 0:t.full_name)&&void 0!==s?s:e.name,i("div",{class:"icon",innerHTML:L}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:r,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(o=this.rolesCompleted[e.id])&&void 0!==o?o:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}})))}))))),i("div",{class:"level level-done"},this.getLevelIcon(this.levels.length),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},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:!l||this.sending,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}};R.style='verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:none}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 #97979744}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:#00000089}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-direction:row;flex-direction:row}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 U=class{constructor(i){e(this,i),this.exit=t(this,"exit",7),this.next=t(this,"next",7),this.templateUpdated=t(this,"templateUpdated",7),this.sdkError=t(this,"sdkError",7),this.endpoint=o.getDefault(),this.templateId="",this.uploading=!1,this.progressLabel="Uploading...",this.progressPercent=0,this.showDeleteError=!1,this.confirmDeleteDocument=null,this.store=null}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1)}catch(s){console.log("[TEMPLATE ATTACHMENTS] Error loading template",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}handleCancel(e){e.stopPropagation(),this.exit.emit()}handleUploadProgress(e){e>=99?(this.progressPercent=100,this.progressLabel="Processing..."):this.progressPercent=e}async handleUpload(e){var t,i,s,o;e.stopPropagation();const l=e.detail.file;if(l){console.log("[ATTACHMENTS] Uploading...",l),this.uploading=!0,this.progressLabel="Uploading...";try{const e=await b(this.endpoint,this.templateId,l,this.handleUploadProgress.bind(this));console.log("[ATTACHMENTS] Created attachment",e),this.store=await h(this.endpoint,this.templateId,!1),console.log("[ATTACHMENTS] Updated template",this.store.state),null===(t=this.templateUpdated)||void 0===t||t.emit({endpoint:this.endpoint,template:this.store.state,event:"attachments"}),this.uploading=!1,this.progressLabel="",this.progressPercent=0}catch(e){console.log("[ATTACHMENTS] Error creating template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data)),this.uploading=!1}}}handleNext(e){var t;e.stopPropagation(),this.uploading=!1,this.progressLabel="",this.progressPercent=0,null===(t=this.next)||void 0===t||t.emit({template:this.store.state})}async confirmDelete(){await g(this.endpoint,this.templateId,this.confirmDeleteDocument.id),this.store=await h(this.endpoint,this.templateId,!1),console.log("[ATTACHMENTS] New template",this.store.state),this.confirmDeleteDocument=null}async handleDelete(e){var t;(null===(t=this.store.state)||void 0===t?void 0:t.template_documents.length)>1?this.confirmDeleteDocument=e:this.showDeleteError=!0}getFileIcon(e){switch(e.mime){case"application/pdf":return S;case"image/jpeg":return k;case"image/png":return w;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return y}return E}render(){var e,t,o;if(!this.endpoint.session)return i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}));const l=null===(e=this.store)||void 0===e?void 0:e.state;return l.isLoaded?this.endpoint.session&&l.profile_id?i(s,null,i("h5",null,"Existing Attachments"),i("div",{class:"attachments"},null===(t=this.store)||void 0===t?void 0:t.state.template_documents.map((e=>i("div",{class:"attachment"},i("div",{class:"file-icon",innerHTML:this.getFileIcon(e)}),i("div",{class:"filename",title:e.name},e.name),i("div",{class:"pages"},i("div",{class:"count"},e.page_numbers),i("div",{class:"pages-icon",innerHTML:z})),i("div",{class:"trash-icon",innerHTML:C,onClick:()=>this.handleDelete(e)}))))),i("h5",null,"Attach a New Document"),this.uploading?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:!0,percent:this.progressPercent,label:this.progressLabel}))):i("verdocs-file-chooser",{onFileSelected:e=>this.handleUpload(e)}),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.uploading}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleNext(e),disabled:!(null===(o=this.store)||void 0===o?void 0:o.state.template_documents.length)||this.uploading})),this.showDeleteError&&i("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:()=>this.showDeleteError=!1}),this.confirmDeleteDocument&&i("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:()=>this.confirmDelete(),showCancel:!0,onExit:()=>{this.confirmDeleteDocument=null}})):i(s,{class:"empty"}):i(s,{class:"loading"},i("verdocs-loader",null))}};U.style='verdocs-template-attachments{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}';const M=["attachments","roles","settings","fields","preview"],N=class{constructor(i){e(this,i),this.sdkError=t(this,"sdkError",7),this.stepChanged=t(this,"stepChanged",7),this.endpoint=o.getDefault(),this.templateId=null,this.step="preview",this.store=null}onStepChanged(){console.log("Step changed",this.step,this.templateId),this.loadTemplate().catch((e=>console.log("Unknown Error",e)))}async componentWillLoad(){var e,t,i;try{if(this.endpoint.loadSession(),!this.endpoint.session)return void console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");if(!this.templateId)return void(this.step="preview");this.loadTemplate().catch((e=>console.log("[BUILD_TABS] Unable to load template",e)))}catch(s){console.log("[BUILD_TABS] Error loading template",s),null===(e=this.sdkError)||void 0===e||e.emit(new m(s.message,null===(t=s.response)||void 0===t?void 0:t.status,null===(i=s.response)||void 0===i?void 0:i.data))}}async loadTemplate(){this.templateId&&(this.store=await h(this.endpoint,this.templateId,!1))}setStep(e){var t;console.log("Selected step",e.detail.tab.id),e.stopPropagation(),e.preventDefault(),this.step=e.detail.tab.id,null===(t=this.stepChanged)||void 0===t||t.emit(e.detail.tab.id)}render(){var e,t,o,l,a,n,r,d,c;if(!this.endpoint.session)return i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}));let h=!1,p=!1,m=!1;console.log("[BUILD_TABS] Rendering tabs",this.templateId,this.step),this.templateId&&this.store&&this.store.state&&(m=(null===(o=null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.template_documents)||void 0===o?void 0:o.length)>0,p=m&&(null===(n=null===(a=null===(l=this.store)||void 0===l?void 0:l.state)||void 0===a?void 0:a.roles)||void 0===n?void 0:n.length)>0,h=p&&(null===(c=null===(d=null===(r=this.store)||void 0===r?void 0:r.state)||void 0===d?void 0:d.fields)||void 0===c?void 0:c.length)>0);let v=Math.max(M.indexOf(this.step),0);return!h&&v>=4&&(v=3),!p&&v>=3&&(v=1),!m&&v>=1&&(v=0),console.log({selectedStepIndex:v,canPreview:h,canEditFields:p,canEditRoles:m}),i(s,null,i("verdocs-tabs",{onSelectTab:e=>this.setStep(e),selectedTab:v,tabs:[{id:"attachments",disabled:!1,label:this.templateId&&this.store?"Attachment(s)":"Upload Attachment(s)"},{id:"roles",disabled:!m,label:"Roles"},{id:"settings",disabled:!p,label:"Settings"},{id:"fields",disabled:!p,label:"Fields"},{id:"preview",disabled:!h,label:"Preview/Send"}]}))}static get watchers(){return{step:["onStepChanged"]}}};N.style='verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:20px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-build-tabs verdocs-template-attachments,verdocs-template-build-tabs verdocs-template-roles{margin:20px}verdocs-template-build-tabs verdocs-template-fields{border-top:1px solid #777777}verdocs-template-build-tabs verdocs-template-attachments{padding:20px;background:#ffffff}verdocs-template-build-tabs verdocs-template-fields{width:100%}verdocs-template-build-tabs verdocs-preview{-ms-flex:1;flex:1}';const A=class{constructor(i){e(this,i),this.exit=t(this,"exit",7),this.next=t(this,"next",7),this.sdkError=t(this,"sdkError",7),this.templateCreated=t(this,"templateCreated",7),this.endpoint=o.getDefault(),this.file=void 0,this.creating=!1,this.progressLabel="Uploading...",this.progressPercent=0}componentWillLoad(){this.endpoint.setTimeout(3e4),this.endpoint.loadSession()}handleFileChanged(e){var t;this.file=(null===(t=e.target.files)||void 0===t?void 0:t[0])||null,console.log("[CREATE] Selected file",this.file)}handleUpload(e){e.stopPropagation(),document.getElementById("verdocs-template-create-file").click()}handleCancel(e){e.stopPropagation(),this.exit.emit()}async handleSubmit(e){var t,i,s;if(e.stopPropagation(),console.log("Submitting"),this.file){this.creating=!0,this.progressLabel="Uploading...";try{const e=await l(this.endpoint,{name:this.file.name,documents:[this.file]},(e=>{e>=99?(this.progressLabel="Processing...",this.progressPercent=100):this.progressPercent=e}));console.log("[CREATE] Created template",e),h(this.endpoint,e.id,!0).then((()=>{var t,i;null===(t=this.templateCreated)||void 0===t||t.emit({endpoint:this.endpoint,template:e,templateId:e.id}),null===(i=this.next)||void 0===i||i.emit(e),this.creating=!1,this.progressLabel="",this.progressPercent=0})).catch((e=>{console.log(e)}))}catch(e){console.log("[CREATE] Error creating template",e),null===(t=this.sdkError)||void 0===t||t.emit(new m(e.message,null===(i=e.response)||void 0===i?void 0:i.status,null===(s=e.response)||void 0===s?void 0:s.data)),this.creating=!1}}}render(){return i(s,null,this.endpoint.session?i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("input",{type:"file",id:"verdocs-template-create-file",multiple:!0,accept:"application/pdf",style:{display:"none"},onChange:e=>this.handleFileChanged(e)}),this.creating?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:!0,percent:this.progressPercent,label:this.progressLabel}))):i("div",{class:"upload-box",onDrop:e=>{e.preventDefault(),e.target.classList.remove("drag-over"),this.file=e.dataTransfer.files[0]},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDragEnter:e=>e.target.classList.add("drag-over"),onDragLeave:e=>e.target.classList.remove("drag-over")},i("div",null,i("span",{innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></svg>'})),i("div",{style:{marginTop:"20px",fontSize:"20px",fontWeight:"bold",overflowWrap:"anywhere"}},this.file?this.file.name:"Drag a file here"),i("div",{style:{marginTop:"20px",marginBottom:"20px",fontSize:"16px",height:"20px"}},this.file?" ":"Or, if you prefer..."),i("verdocs-button",{label:this.file?"Select a different file":"Select a file from your computer",size:"small",onClick:e=>this.handleUpload(e)})),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.creating}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleSubmit(e),disabled:!this.file||this.creating}))):i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};A.style='verdocs-template-create{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-create form{background-color:#ffffff;padding:12px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-create form .upload-box{-webkit-box-sizing:border-box;box-sizing:border-box;width:320px;text-align:center;padding:44px 18px 66px;border:2px dashed #979797;color:rgba(0, 0, 0, 0.54)}verdocs-template-create form .upload-box.drag-over{border:2px solid #4c56cb}verdocs-template-create form .upload-box svg{width:64px;fill:#5c6575}verdocs-template-create .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .progress-wrapper{padding:20px}verdocs-template-create .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-create ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-create ::-moz-placeholder{color:#aaaaaa}verdocs-template-create :-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::placeholder{color:#aaaaaa}';const D=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.name="",this.dirty=!1}async componentWillLoad(){var e,t,i,s,o;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.name=null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.name,this.dirty=!1}catch(e){console.log("[TEMPLATE NAME] Error loading template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data))}}handleCancel(e){var t,i,s;e.stopPropagation(),this.name=null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name,this.dirty=!1,console.log("Closing"),null===(s=this.close)||void 0===s||s.emit()}async handleSave(e){var t,i,s;e.stopPropagation(),await a(this.endpoint,this.templateId,{name:this.name}),(null===(t=this.store)||void 0===t?void 0:t.state)&&(this.store.state.name=this.name),this.dirty=!1,null===(i=this.templateUpdated)||void 0===i||i.emit({endpoint:this.endpoint,template:this.store.state,event:"name"}),null===(s=this.close)||void 0===s||s.emit()}render(){var e,t;return this.endpoint.session?(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoading)?i(s,{class:"loading"},i("verdocs-loader",null)):i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("label",{htmlFor:"verdocs-template-name"},"Template Name"),i("verdocs-text-input",{id:"verdocs-template-name",value:this.name,autocomplete:"off",placeholder:"Template Name...",onInput:e=>{var t,i;this.name=e.target.value,this.dirty=this.name!==(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.name)}}),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)})))):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};D.style="";const j=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.showPlanBlocker=!1,this.sendReminders=!1,this.firstReminderDays="1",this.reminderDays="1",this.dirty=!1}async componentWillLoad(){var e,t,i,s,o;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.sendReminders=!!(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.reminder_id),this.dirty=!1}catch(e){console.log("[TEMPLATE REMINDERS] Error loading template",e),null===(i=this.sdkError)||void 0===i||i.emit(new m(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(o=e.response)||void 0===o?void 0:o.data))}}handleCancel(e){var t,i,s;e.stopPropagation(),this.sendReminders=!!(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.reminder_id),this.dirty=!1,null===(s=this.close)||void 0===s||s.emit()}async handleSave(e){var t,i,s,o,l,a,n,r,d,c,p,v;e.stopPropagation();try{if(this.sendReminders){const e={setup_time:+this.firstReminderDays,interval_time:+this.reminderDays};(null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.reminder_id)?(await function(e,t,i,s){return e.api.put("/templates/".concat(t,"/reminder/").concat(i),s).then((function(e){return e.data}))}(this.endpoint,this.templateId,null===(s=this.store)||void 0===s?void 0:s.state.reminder_id,e),this.store=await h(this.endpoint,this.templateId,!1)):(await function(e,t,i){return e.api.post("/templates/".concat(t,"/reminder/"),i).then((function(e){return e.data}))}(this.endpoint,this.templateId,e),this.store=await h(this.endpoint,this.templateId,!1))}else await(c=this.endpoint,p=this.templateId,v=null===(o=this.store)||void 0===o?void 0:o.state.reminder_id,c.api.delete("/templates/".concat(p,"/reminder/").concat(v)).then((function(e){return e.data}))),this.store=await h(this.endpoint,this.templateId,!1);null===(l=this.templateUpdated)||void 0===l||l.emit({endpoint:this.endpoint,template:this.store.state,event:"attachments"})}catch(e){console.log("[TEMPLATE REMINDERS] Unable to update reminders",e),T(e.message),null===(a=this.sdkError)||void 0===a||a.emit(new m(e.message,null===(n=e.response)||void 0===n?void 0:n.status,null===(r=e.response)||void 0===r?void 0:r.data))}this.dirty=!1,null===(d=this.close)||void 0===d||d.emit()}render(){var e,t;return this.endpoint.session?this.endpoint.session&&(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoaded)?i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("h5",null,"Reminders"),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-send-reminders"},"Send Automatic Reminders"),i("verdocs-checkbox",{id:"verdocs-send-reminders",name:"automatic-reminders",checked:this.sendReminders,value:"on",onInput:e=>{this.sendReminders=e.target.checked,this.dirty=!0}})),i("p",null,i("strong",null,"NOTE:")," Reminders will only be sent for up to 14 days."),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-first-reminder-days"},"Days Before First Reminder"),i("verdocs-text-input",{id:"verdocs-first-reminder-days",type:"number",value:this.firstReminderDays,onInput:e=>{this.firstReminderDays=e.target.value,this.dirty=!0},disabled:!this.sendReminders})),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-days-between-reminders"},"Days Between Reminders"),i("verdocs-text-input",{id:"verdocs-days-between-reminders",type:"number",value:this.reminderDays,onInput:e=>{this.reminderDays=e.target.value,this.dirty=!0},disabled:!this.sendReminders})),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)}))),this.showPlanBlocker&&i("verdocs-ok-dialog",{heading:"Upgrade to access this feature",message:"Please upgrade your plan to access this feature.",onNext:()=>this.showPlanBlocker=!1})):i(s,{class:"empty"}):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};j.style='verdocs-template-reminders{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-reminders.loading{min-height:300px;position:relative;display:block}verdocs-template-reminders.empty{display:none}verdocs-template-reminders form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-reminders form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 20px 0}verdocs-template-reminders form label{font-size:16px;font-weight:500;margin:0 0 6px 0;color:#33364b}verdocs-template-reminders form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-reminders form input:focus{outline:none}verdocs-template-reminders form .input-row{display:-ms-flexbox;display:flex;margin:0 0 10px 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-reminders form .input-row label{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-reminders form .input-row verdocs-text-input{margin:0;display:-ms-flexbox;display:flex;-ms-flex:0 0 60px;flex:0 0 60px}verdocs-template-reminders form .input-row verdocs-text-input input{text-align:center}verdocs-template-reminders form .input-row verdocs-checkbox{display:-ms-flexbox;display:flex;-ms-flex:0 0 40px;flex:0 0 40px;-ms-flex-pack:center;justify-content:center}verdocs-template-reminders .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-reminders ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::-moz-placeholder{color:#aaaaaa}verdocs-template-reminders :-ms-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-reminders ::placeholder{color:#aaaaaa}';const H=class{constructor(i){e(this,i),this.close=t(this,"close",7),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.store=null,this.endpoint=o.getDefault(),this.templateId="",this.dirty=!1,this.personal=!1,this.public=!1}async componentWillLoad(){var e,t,i,s,o,l,a;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[VISIBILITY] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[VISIBILITY] Unable to start builder session, must be authenticated");this.store=await h(this.endpoint,this.templateId,!1),this.personal=(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.is_personal)||!0,this.public=(null===(s=null===(i=this.store)||void 0===i?void 0:i.state)||void 0===s?void 0:s.is_public)||!1,this.dirty=!1}catch(e){console.log("[TEMPLATE VISIBILITY] Error loading template",e),null===(o=this.sdkError)||void 0===o||o.emit(new m(e.message,null===(l=e.response)||void 0===l?void 0:l.status,null===(a=e.response)||void 0===a?void 0:a.data))}}handleCancel(e){var t,i,s,o,l;e.stopPropagation(),this.personal=null===(i=null===(t=this.store)||void 0===t?void 0:t.state)||void 0===i?void 0:i.is_personal,this.public=null===(o=null===(s=this.store)||void 0===s?void 0:s.state)||void 0===o?void 0:o.is_public,this.dirty=!1,null===(l=this.close)||void 0===l||l.emit()}async handleSave(e){var t,i,s;e.stopPropagation(),await a(this.endpoint,this.templateId,{is_personal:this.personal,is_public:this.public}),(null===(t=this.store)||void 0===t?void 0:t.state)&&(this.store.state.is_personal=this.personal,this.store.state.is_public=this.public),this.dirty=!1,null===(i=this.templateUpdated)||void 0===i||i.emit({endpoint:this.endpoint,template:this.store.state,event:"visibility"}),null===(s=this.close)||void 0===s||s.emit()}render(){var e,t;return this.endpoint.session?this.endpoint.session&&(null===(t=null===(e=this.store)||void 0===e?void 0:e.state)||void 0===t?void 0:t.isLoaded)?i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("h5",null,"Visibility"),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-is-shared"},"Shared"),i("verdocs-checkbox",{id:"verdocs-is-shared",name:"is-shared",checked:!this.personal,value:"on",onInput:e=>{this.personal=!e.target.checked,this.dirty=!0}})),i("div",{class:"description"},"Shared templates are visible to other members of your Organization (if any)."),i("div",{class:"input-row"},i("label",{htmlFor:"verdocs-is-public"},"Public"),i("verdocs-checkbox",{id:"verdocs-is-public",name:"is-public",checked:this.public,value:"on",onInput:e=>{this.public=e.target.checked,this.dirty=!0}})),i("div",{class:"description"},"Public templates may appear in results when any other user searches for templates. Note that a template may be both Personal and Public, which may be useful if you want your template to be found via search but not otherwise displayed to other members of your Organization (if any)."),i("div",{class:"buttons"},i("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:e=>this.handleCancel(e)}),i("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:e=>this.handleSave(e)})))):i(s,{class:"empty"}):i(s,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};H.style='verdocs-template-visibility{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-visibility.loading{min-height:300px;position:relative;display:block}verdocs-template-visibility.empty{display:none}verdocs-template-visibility form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-visibility form .description{font-size:14px;text-align:justify;color:#5c6575}verdocs-template-visibility form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0}verdocs-template-visibility form label{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:16px;font-weight:500;margin:0 0 4px 0;color:#33364b}verdocs-template-visibility form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-visibility form input:focus{outline:none}verdocs-template-visibility form .input-row{display:-ms-flexbox;display:flex;margin:20px 0 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility form .input-row verdocs-text-input{margin:0;display:-ms-flexbox;display:flex;-ms-flex:0 0 40px;flex:0 0 40px}verdocs-template-visibility form .input-row verdocs-text-input input{text-align:center}verdocs-template-visibility form .input-row verdocs-checkbox{-ms-flex:0;flex:0;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}verdocs-template-visibility form .input-row verdocs-checkbox label>input[type=checkbox]+*::before{margin-right:0}verdocs-template-visibility .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:25px;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-moz-placeholder{color:#aaaaaa}verdocs-template-visibility :-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::placeholder{color:#aaaaaa}';export{I as verdocs_preview,R as verdocs_send,U as verdocs_template_attachments,N as verdocs_template_build_tabs,A as verdocs_template_create,D as verdocs_template_name,j as verdocs_template_reminders,H as verdocs_template_visibility}
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,c as i,h as t,H as s,F as o}from"./p-14b44491.js";import{e as n,a,u as l,f as r,h as d,i as h}from"./p-dc2ad047.js";import{R as c}from"./p-05788c2b.js";import{e as p,a as u,b as v}from"./p-3cd894ff.js";import{V as g}from"./p-e04d8f5d.js";import{i as m,a as f}from"./p-e8ce0b6f.js";import{f as x,i as b}from"./p-5e808a0b.js";import{a as w,u as y,r as k,b as S}from"./p-a3d7cdda.js";import{a as N}from"./p-ef20cb50.js";import{V as I}from"./p-ed416acf.js";import{S as G}from"./p-7a1b2643.js";import"./p-eab67c09.js";import"./p-839f6f0d.js";import"./p-c220af42.js";import"./p-7648c449.js";const j=[{id:"later",label:"Finish Later"},{id:"decline",label:"Decline to Sign"},{id:"print",label:"Print Without Signing"},{id:"download",label:"Download"}],F=[{id:"print",label:"Print"},{id:"download",label:"Download"}],D=class{constructor(t){e(this,t),this.sdkError=i(this,"sdkError",7),this.envelopeLoaded=i(this,"envelopeLoaded",7),this.envelopeUpdated=i(this,"envelopeUpdated",7),this.endpoint=null,this.recipientIndex=-1,this.envelopeId=null,this.roleId=null,this.inviteCode=null,this.headerTargetId=null,this.envelope=null,this.roleNames=[],this.sortedRecipients=[],this.recipient=null,this.signerToken=null,this.hasSignature=!1,this.nextButtonLabel="Start",this.nextSubmits=!1,this.errorMessage="",this.focusedField="",this.submitting=!1,this.isDone=!1,this.showDone=!1,this.showLoadError=!1,this.finishLater=!1,this.showFinishLater=!1,this.agreed=!1,this.documentsSingularPlural="document"}componentWillLoad(){this.endpoint=new g({sessionType:"signing"})}async componentWillRender(){var e,i,t,s,o,l,r;if(this.envelopeId)if(this.roleId)if(this.inviteCode)try{console.log(`[SIGN] Processing invite code for ${this.envelopeId} / ${this.roleId}`);const{session:e,recipient:i,signerToken:t}=await n(this.endpoint,{envelopeId:this.envelopeId,roleId:this.roleId,inviteCode:this.inviteCode});console.log(`[SIGN] Loaded signing session ${e.email} / ${e.profile_id}`),this.recipient=i,console.log("[SIGN] We are recipient",this.recipient),this.signerToken=t,this.endpoint.setToken(t),this.agreed&&(this.nextButtonLabel="Next"),this.envelope=await a(this.endpoint,this.envelopeId),N(this.envelope),this.sortedRecipients=[...this.envelope.recipients],this.sortedRecipients.sort(((e,i)=>e.sequence===i.sequence?e.order-i.order:e.sequence-i.sequence)),this.roleNames=this.sortedRecipients.map((e=>e.role_name)),this.envelope.documents.length>0&&(this.documentsSingularPlural="document(s)"),this.recipientIndex=this.roleNames.findIndex((e=>e==this.roleId)),this.recipientIndex>-1?(this.recipient=this.sortedRecipients[this.recipientIndex],this.agreed=this.recipient.agreed,console.log("[SIGN] Found our recipient in the envelope",this.recipientIndex,this.recipient)):console.log("[SIGN] Could not find our recipient record",this.roleId,this.sortedRecipients),this.isDone=["submitted","canceled","declined"].includes(this.recipient.status),this.checkRecipientFields(),null===(s=this.envelopeLoaded)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope})}catch(e){console.log("Error with signing session",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(l=e.response)||void 0===l?void 0:l.status,null===(r=e.response)||void 0===r?void 0:r.data)),this.showLoadError=!0}else null===(t=this.sdkError)||void 0===t||t.emit(new G("[SIGN] Missing required inviteCode",500,""));else null===(i=this.sdkError)||void 0===i||i.emit(new G("[SIGN] Missing required roleId",500,""));else null===(e=this.sdkError)||void 0===e||e.emit(new G("[SIGN] Missing required envelopId",500,""))}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null,i=document.getElementById("verdocs-sign-header");e&&i&&(console.log("[SIGN] Moving header"),i.remove(),e.append(i))}handleClickAgree(){this.submitting=!0,p(this.endpoint,this.envelopeId,this.roleId,!0).then((()=>{var e;this.nextButtonLabel="Next",this.recipient.agreed=!0,this.submitting=!1,this.agreed=!0,null===(e=this.envelopeUpdated)||void 0===e||e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"agreed"})})).catch((e=>{var i,t,s;console.log("Update failure",e),this.submitting=!1,null===(i=this.sdkError)||void 0===i||i.emit(new G(e.message,null===(t=e.response)||void 0===t?void 0:t.status,null===(s=e.response)||void 0===s?void 0:s.data))}))}async handleOptionSelected(e){var i,t,s,o,n;switch(e.detail.id){case"later":this.finishLater=!0,this.showFinishLater=!0,null===(i=this.envelopeUpdated)||void 0===i||i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"later"});break;case"claim":I("This feature will be available in an upcoming release."),null===(t=this.envelopeUpdated)||void 0===t||t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"claimed"});break;case"decline":{this.submitting=!0;const e=await u(this.endpoint,this.envelopeId,this.roleId);console.log("Decline result",e),null===(s=this.envelopeUpdated)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope,event:"declined"}),this.submitting=!1,this.isDone=!0}break;case"print":window.print(),null===(o=this.envelopeUpdated)||void 0===o||o.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download":w(this.endpoint,this.envelope,this.envelope.envelope_document_id).catch((e=>{console.log("Error downloading PDF",e)})),null===(n=this.envelopeUpdated)||void 0===n||n.emit({endpoint:this.endpoint,envelope:this.envelope,event:"downloaded"})}}updateRecipientFieldValue(e,i){console.log("[SIGN] updateRecipientFieldValue",e),this.getRecipientFields().forEach((t=>{t.name===e&&(t.settings=i.settings,y(t),this.checkRecipientFields())}))}saveFieldChange(e,i){console.log("[SIGN] updateRecipientFieldValue",e),l(this.endpoint,this.envelopeId,e,i).then((i=>this.updateRecipientFieldValue(e,i))).catch((e=>{var i,t,s,o,n,a;401===(null===(i=e.response)||void 0===i?void 0:i.status)&&"jwt expired"===(null===(s=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===s?void 0:s.error)?(console.log("[SIGN] Signing session expired"),this.errorMessage="Signing session expired. Please reload your browser to continue."):console.log("[SIGN] Server error",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(n=e.response)||void 0===n?void 0:n.status,null===(a=e.response)||void 0===a?void 0:a.data))}))}async handleFieldChange(e,i){const{value:t,checked:s}=i.target;switch(e.type){case"textbox":return this.saveFieldChange(e.name,{prepared:!1,value:t});case"checkbox_group":{const t=e.settings.options.map((e=>({id:e.id,checked:i.target.checked})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"radio_button_group":{const t=e.settings.options.map((e=>({id:e.id,selected:i.target.value===e.id})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"dropdown":return this.saveFieldChange(e.name,{prepared:!1,value:i.detail});case"initial":if(!i.detail)return;const l=await(await fetch(i.detail)).blob();return(o=this.endpoint,"initial",n=l,a=new FormData,a.append("initial",n,"initial"),o.api.post("/initials",a).then((function(e){return e.data}))).then((async i=>{const t=await d(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)}));case"signature":if(!i.detail)return;const h=await(await fetch(i.detail)).blob();return function(e,i,t){var s=new FormData;return s.append("signature",t,"signature"),e.api.post("/signatures",s).then((function(e){return e.data}))}(this.endpoint,0,h).then((async i=>{console.log("Signature update result",i);const t=await r(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)})).catch((e=>{console.warn("Error updating signature",e)}));case"date":const{date:c,formattedDate:p}=i.detail;if(p)return console.log("dt",{date:c,formattedDate:p}),this.saveFieldChange(e.name,{prepared:!1,value:p});break;case"timestamp":console.log("Updating timestamp",{value:t,ts:i.target.getAttribute("timestamp")});break;default:console.log("Unhandled field update",{value:t,checked:s},e)}var o,n,a}isFieldValid(e){var i,t,s,o,n,a,l;const{required:r=!1}=e,{result:d="",value:h="",base64:c=""}=e.settings||{};switch(e.type){case"textbox":switch((null===(i=e.settings)||void 0===i?void 0:i.validator)||""){case"email":return f(d);case"phone":return m(d);default:return!r||""!==d}case"signature":case"initial":return!r||""!==c;case"timestamp":return!0;case"textarea":case"date":case"attachment":return!r||""!==d;case"dropdown":return!r||""!==h;case"checkbox_group":const p=((null===(s=null===(t=e.settings)||void 0===t?void 0:t.options)||void 0===s?void 0:s.filter((e=>e.checked)))||[]).length;return!r||p>=((null===(o=e.settings)||void 0===o?void 0:o.minimum_checked)||0)&&p<=((null===(n=e.settings)||void 0===n?void 0:n.maximum_checked)||999);case"radio_button_group":return!r||((null===(l=null===(a=e.settings)||void 0===a?void 0:a.options)||void 0===l?void 0:l.filter((e=>e.selected)))||[]).length>0;default:return!1}}async handleNext(){var e;if(this.nextSubmits){try{this.submitting=!0;const e=await v(this.endpoint,this.envelopeId,this.roleId);console.log("[SIGN] Submitted successfully",e),this.recipient.status="submitted",this.showDone=!0,this.isDone=!0}catch(e){console.log("[SIGN] Error submitting",e)}return void(this.submitting=!1)}const i=this.getRecipientFields().filter((e=>e.required));let t=i.findIndex((e=>e.name===this.focusedField))+1;t>=i.length&&(t=0);let s=i[t],o=0;if(o<i.length&&["signature","initial"].includes(s.type)&&"signed"===(null===(e=s.settings)||void 0===e?void 0:e.result)&&(o++,t++,t>=i.length&&(t=0),s=i[t]),o>=i.length&&(s=null),s){const e=S(s),i=document.getElementById(e);null==i||i.focusField(),this.focusedField=s.name}}getRecipientFields(){return this.envelope.fields.filter((e=>e.recipient_role===this.recipient.role_name))}checkRecipientFields(){const e=this.getRecipientFields().filter((e=>!this.isFieldValid(e)));e.length<1?(this.nextButtonLabel="Finish",this.nextSubmits||(this.nextSubmits=!0)):(console.log("[SIGN] c invalid fields",e),this.nextButtonLabel="Next",this.nextSubmits=!1)}attachFieldAttributes(e,i,t){var s;t.addEventListener("input",(e=>{console.log("[SIGN] onfieldInput",e.detail,e.target.value),e.target.name.includes("checkbox_group")||e.target.name.includes("radio_button_group")?this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())):this.checkRecipientFields()})),t.addEventListener("attached",(async e=>{console.log("[SIGN] onAttached",e.detail,e.target.value);const t=await h(this.endpoint,this.envelopeId,this.roleId,i.name,e.detail);console.log("upload result",t),this.checkRecipientFields()})),t.addEventListener("removed",(e=>{console.log("[SIGN] onRemoved",e.detail,e.target.value)})),t.addEventListener("focusout",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.addEventListener("fieldChange",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.setAttribute("templateid",this.envelope.template_id),t.setAttribute("fieldname",i.name),t.setAttribute("page",e.pageNumber),t.setAttribute("xScale",e.xScale),t.setAttribute("yScale",e.yScale),t.setAttribute("initials",this.recipient?x(this.recipient.full_name):""),t.setAttribute("name",(null===(s=this.recipient)||void 0===s?void 0:s.full_name)||"")}handlePageRendered(e){const i=e.detail;this.getRecipientFields().filter((e=>e.page===i.pageNumber)).filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!1,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))})),this.sortedRecipients.filter((e=>e.role_name!==this.recipient.role_name&&(e.status===c.INVITED||e.status===c.OPENED||e.status===c.PENDING))).forEach((()=>{this.getRecipientFields().filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!0,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))}))})),this.checkRecipientFields()}render(){return this.envelope?this.isDone?t(s,{class:{agreed:this.agreed}},t("verdocs-view",{endpoint:this.endpoint,envelopeId:this.envelopeId,onSdkError:e=>{var i;return null===(i=this.sdkError)||void 0===i?void 0:i.emit(e.detail)}}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null))):t(s,{class:{agreed:this.agreed}},t("div",{id:"verdocs-sign-header"},t("div",{class:"inner"},t("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),t("div",{class:"title"},this.envelope.name),t("div",{style:{flex:"1"}}),!this.finishLater&&t("verdocs-button",{size:"small",label:this.nextButtonLabel,disabled:!this.agreed,onClick:()=>this.handleNext()}),t("div",{style:{marginLeft:"10px"}}),t("verdocs-dropdown",{options:this.isDone||this.finishLater?F:j,onOptionSelected:e=>this.handleOptionSelected(e)}))),t("div",{class:"document",style:{paddingTop:"15px"}},(this.envelope.documents||[]).map((e=>{const i=b(1,e.page_numbers);return t(o,null,i.map((i=>t("verdocs-envelope-document-page",{envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,virtualWidth:612,virtualHeight:792,pageNumber:i,onPageRendered:e=>this.handlePageRendered(e),type:"filled",layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}))),this.showFinishLater&&t("verdocs-ok-dialog",{heading:"You've saved your document to finish later.",message:`To complete the ${this.documentsSingularPlural}, use the link in the original email notification inviting you to review and finish the document.`,onNext:()=>this.showFinishLater=!1}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.showLoadError&&t("verdocs-ok-dialog",{heading:"Error Loading Document",message:"Please check with the sender to ensure it has not been canceled, and try again later.",buttonLabel:"Retry",onNext:()=>{this.showLoadError=!1,window.location.reload()}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null)),!this.agreed&&t("div",{class:"cover"},t("div",{class:"agree"},t("verdocs-checkbox",{name:"agree",label:"By checking this box, you:",onInput:()=>this.handleClickAgree()}),t("ul",null,t("li",null,"Agree to use electronic records and signatures, and confirm you have read the"," ",t("a",{href:"https://verdocs.com/en/electronic-record-signature-disclosure/",target:"_blank"},"Electronic Record and Signatures Disclosure"),"."),t("li",null,"Agree to Verdocs"," ",t("a",{href:"https://verdocs.com/en/eula",target:"_blank"},"End User License Agreement")," ","and confirm you have read Verdocs'"," ",t("a",{href:"https://verdocs.com/en/privacy-policy/",target:"_blank"},"Privacy Policy"),"."))))):t(s,null,t("verdocs-loader",null))}};D.style='verdocs-sign{display:-ms-flexbox;display:flex;overflow:hidden;position:relative;min-height:600px;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-sign div{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-sign input{vertical-align:top}verdocs-sign>.document{-ms-flex:1;flex:1;width:100%;height:100%;-ms-flex-item-align:center;align-self:center;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;max-width:1200px;min-height:200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-sign>.document .inner{width:100%;max-width:1028px}verdocs-sign .cover{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:5000;position:absolute;padding-top:100px;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;background:rgba(0, 0, 0, 0.5)}verdocs-sign .agree{-ms-flex:0;flex:0;width:600px;display:-ms-flexbox;display:flex;max-width:90%;padding:30px 15px;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff}verdocs-sign .agree .header{-ms-flex:0 0 56px;flex:0 0 56px}verdocs-sign .agree li{margin:0.5em 0}verdocs-sign verdocs-ok-dialog .background-overlay{-ms-flex-align:start;align-items:flex-start;padding-top:100px}verdocs-sign .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}@media print{verdocs-sign .header{display:none}}#verdocs-sign-header{color:#fff;width:100%;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}#verdocs-sign-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}#verdocs-sign-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-sign-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;padding:0 10px 0 0;text-overflow:ellipsis}';export{D as verdocs_sign}
|
1
|
+
import{r as e,c as i,h as t,H as s,F as o}from"./p-14b44491.js";import{e as n,a,u as l,f as r,h as d,i as h}from"./p-dc2ad047.js";import{R as c}from"./p-05788c2b.js";import{e as p,a as u,b as v}from"./p-3cd894ff.js";import{V as g}from"./p-e04d8f5d.js";import{i as m,a as f}from"./p-e8ce0b6f.js";import{f as x,i as b}from"./p-5e808a0b.js";import{a as w,u as y,r as k,b as S}from"./p-b72328af.js";import{a as N}from"./p-ef20cb50.js";import{V as I}from"./p-ed416acf.js";import{S as G}from"./p-7a1b2643.js";import"./p-eab67c09.js";import"./p-1b4e7078.js";import"./p-c220af42.js";import"./p-7648c449.js";const j=[{id:"later",label:"Finish Later"},{id:"decline",label:"Decline to Sign"},{id:"print",label:"Print Without Signing"},{id:"download",label:"Download"}],F=[{id:"print",label:"Print"},{id:"download",label:"Download"}],D=class{constructor(t){e(this,t),this.sdkError=i(this,"sdkError",7),this.envelopeLoaded=i(this,"envelopeLoaded",7),this.envelopeUpdated=i(this,"envelopeUpdated",7),this.endpoint=null,this.recipientIndex=-1,this.envelopeId=null,this.roleId=null,this.inviteCode=null,this.headerTargetId=null,this.envelope=null,this.roleNames=[],this.sortedRecipients=[],this.recipient=null,this.signerToken=null,this.hasSignature=!1,this.nextButtonLabel="Start",this.nextSubmits=!1,this.errorMessage="",this.focusedField="",this.submitting=!1,this.isDone=!1,this.showDone=!1,this.showLoadError=!1,this.finishLater=!1,this.showFinishLater=!1,this.agreed=!1,this.documentsSingularPlural="document"}componentWillLoad(){this.endpoint=new g({sessionType:"signing"})}async componentWillRender(){var e,i,t,s,o,l,r;if(this.envelopeId)if(this.roleId)if(this.inviteCode)try{console.log(`[SIGN] Processing invite code for ${this.envelopeId} / ${this.roleId}`);const{session:e,recipient:i,signerToken:t}=await n(this.endpoint,{envelopeId:this.envelopeId,roleId:this.roleId,inviteCode:this.inviteCode});console.log(`[SIGN] Loaded signing session ${e.email} / ${e.profile_id}`),this.recipient=i,console.log("[SIGN] We are recipient",this.recipient),this.signerToken=t,this.endpoint.setToken(t),this.agreed&&(this.nextButtonLabel="Next"),this.envelope=await a(this.endpoint,this.envelopeId),N(this.envelope),this.sortedRecipients=[...this.envelope.recipients],this.sortedRecipients.sort(((e,i)=>e.sequence===i.sequence?e.order-i.order:e.sequence-i.sequence)),this.roleNames=this.sortedRecipients.map((e=>e.role_name)),this.envelope.documents.length>0&&(this.documentsSingularPlural="document(s)"),this.recipientIndex=this.roleNames.findIndex((e=>e==this.roleId)),this.recipientIndex>-1?(this.recipient=this.sortedRecipients[this.recipientIndex],this.agreed=this.recipient.agreed,console.log("[SIGN] Found our recipient in the envelope",this.recipientIndex,this.recipient)):console.log("[SIGN] Could not find our recipient record",this.roleId,this.sortedRecipients),this.isDone=["submitted","canceled","declined"].includes(this.recipient.status),this.checkRecipientFields(),null===(s=this.envelopeLoaded)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope})}catch(e){console.log("Error with signing session",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(l=e.response)||void 0===l?void 0:l.status,null===(r=e.response)||void 0===r?void 0:r.data)),this.showLoadError=!0}else null===(t=this.sdkError)||void 0===t||t.emit(new G("[SIGN] Missing required inviteCode",500,""));else null===(i=this.sdkError)||void 0===i||i.emit(new G("[SIGN] Missing required roleId",500,""));else null===(e=this.sdkError)||void 0===e||e.emit(new G("[SIGN] Missing required envelopId",500,""))}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null,i=document.getElementById("verdocs-sign-header");e&&i&&(console.log("[SIGN] Moving header"),i.remove(),e.append(i))}handleClickAgree(){this.submitting=!0,p(this.endpoint,this.envelopeId,this.roleId,!0).then((()=>{var e;this.nextButtonLabel="Next",this.recipient.agreed=!0,this.submitting=!1,this.agreed=!0,null===(e=this.envelopeUpdated)||void 0===e||e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"agreed"})})).catch((e=>{var i,t,s;console.log("Update failure",e),this.submitting=!1,null===(i=this.sdkError)||void 0===i||i.emit(new G(e.message,null===(t=e.response)||void 0===t?void 0:t.status,null===(s=e.response)||void 0===s?void 0:s.data))}))}async handleOptionSelected(e){var i,t,s,o,n;switch(e.detail.id){case"later":this.finishLater=!0,this.showFinishLater=!0,null===(i=this.envelopeUpdated)||void 0===i||i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"later"});break;case"claim":I("This feature will be available in an upcoming release."),null===(t=this.envelopeUpdated)||void 0===t||t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"claimed"});break;case"decline":{this.submitting=!0;const e=await u(this.endpoint,this.envelopeId,this.roleId);console.log("Decline result",e),null===(s=this.envelopeUpdated)||void 0===s||s.emit({endpoint:this.endpoint,envelope:this.envelope,event:"declined"}),this.submitting=!1,this.isDone=!0}break;case"print":window.print(),null===(o=this.envelopeUpdated)||void 0===o||o.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download":w(this.endpoint,this.envelope,this.envelope.envelope_document_id).catch((e=>{console.log("Error downloading PDF",e)})),null===(n=this.envelopeUpdated)||void 0===n||n.emit({endpoint:this.endpoint,envelope:this.envelope,event:"downloaded"})}}updateRecipientFieldValue(e,i){console.log("[SIGN] updateRecipientFieldValue",e),this.getRecipientFields().forEach((t=>{t.name===e&&(t.settings=i.settings,y(t),this.checkRecipientFields())}))}saveFieldChange(e,i){console.log("[SIGN] updateRecipientFieldValue",e),l(this.endpoint,this.envelopeId,e,i).then((i=>this.updateRecipientFieldValue(e,i))).catch((e=>{var i,t,s,o,n,a;401===(null===(i=e.response)||void 0===i?void 0:i.status)&&"jwt expired"===(null===(s=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===s?void 0:s.error)?(console.log("[SIGN] Signing session expired"),this.errorMessage="Signing session expired. Please reload your browser to continue."):console.log("[SIGN] Server error",e),null===(o=this.sdkError)||void 0===o||o.emit(new G(e.message,null===(n=e.response)||void 0===n?void 0:n.status,null===(a=e.response)||void 0===a?void 0:a.data))}))}async handleFieldChange(e,i){const{value:t,checked:s}=i.target;switch(e.type){case"textbox":return this.saveFieldChange(e.name,{prepared:!1,value:t});case"checkbox_group":{const t=e.settings.options.map((e=>({id:e.id,checked:i.target.checked})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"radio_button_group":{const t=e.settings.options.map((e=>({id:e.id,selected:i.target.value===e.id})));return this.saveFieldChange(e.name,{prepared:!1,value:{options:t}})}case"dropdown":return this.saveFieldChange(e.name,{prepared:!1,value:i.detail});case"initial":if(!i.detail)return;const l=await(await fetch(i.detail)).blob();return(o=this.endpoint,"initial",n=l,a=new FormData,a.append("initial",n,"initial"),o.api.post("/initials",a).then((function(e){return e.data}))).then((async i=>{const t=await d(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)}));case"signature":if(!i.detail)return;const h=await(await fetch(i.detail)).blob();return function(e,i,t){var s=new FormData;return s.append("signature",t,"signature"),e.api.post("/signatures",s).then((function(e){return e.data}))}(this.endpoint,0,h).then((async i=>{console.log("Signature update result",i);const t=await r(this.endpoint,this.envelopeId,e.name,i.id);this.updateRecipientFieldValue(e.name,t)})).catch((e=>{console.warn("Error updating signature",e)}));case"date":const{date:c,formattedDate:p}=i.detail;if(p)return console.log("dt",{date:c,formattedDate:p}),this.saveFieldChange(e.name,{prepared:!1,value:p});break;case"timestamp":console.log("Updating timestamp",{value:t,ts:i.target.getAttribute("timestamp")});break;default:console.log("Unhandled field update",{value:t,checked:s},e)}var o,n,a}isFieldValid(e){var i,t,s,o,n,a,l;const{required:r=!1}=e,{result:d="",value:h="",base64:c=""}=e.settings||{};switch(e.type){case"textbox":switch((null===(i=e.settings)||void 0===i?void 0:i.validator)||""){case"email":return f(d);case"phone":return m(d);default:return!r||""!==d}case"signature":case"initial":return!r||""!==c;case"timestamp":return!0;case"textarea":case"date":case"attachment":return!r||""!==d;case"dropdown":return!r||""!==h;case"checkbox_group":const p=((null===(s=null===(t=e.settings)||void 0===t?void 0:t.options)||void 0===s?void 0:s.filter((e=>e.checked)))||[]).length;return!r||p>=((null===(o=e.settings)||void 0===o?void 0:o.minimum_checked)||0)&&p<=((null===(n=e.settings)||void 0===n?void 0:n.maximum_checked)||999);case"radio_button_group":return!r||((null===(l=null===(a=e.settings)||void 0===a?void 0:a.options)||void 0===l?void 0:l.filter((e=>e.selected)))||[]).length>0;default:return!1}}async handleNext(){var e;if(this.nextSubmits){try{this.submitting=!0;const e=await v(this.endpoint,this.envelopeId,this.roleId);console.log("[SIGN] Submitted successfully",e),this.recipient.status="submitted",this.showDone=!0,this.isDone=!0}catch(e){console.log("[SIGN] Error submitting",e)}return void(this.submitting=!1)}const i=this.getRecipientFields().filter((e=>e.required));let t=i.findIndex((e=>e.name===this.focusedField))+1;t>=i.length&&(t=0);let s=i[t],o=0;if(o<i.length&&["signature","initial"].includes(s.type)&&"signed"===(null===(e=s.settings)||void 0===e?void 0:e.result)&&(o++,t++,t>=i.length&&(t=0),s=i[t]),o>=i.length&&(s=null),s){const e=S(s),i=document.getElementById(e);null==i||i.focusField(),this.focusedField=s.name}}getRecipientFields(){return this.envelope.fields.filter((e=>e.recipient_role===this.recipient.role_name))}checkRecipientFields(){const e=this.getRecipientFields().filter((e=>!this.isFieldValid(e)));e.length<1?(this.nextButtonLabel="Finish",this.nextSubmits||(this.nextSubmits=!0)):(console.log("[SIGN] c invalid fields",e),this.nextButtonLabel="Next",this.nextSubmits=!1)}attachFieldAttributes(e,i,t){var s;t.addEventListener("input",(e=>{console.log("[SIGN] onfieldInput",e.detail,e.target.value),e.target.name.includes("checkbox_group")||e.target.name.includes("radio_button_group")?this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())):this.checkRecipientFields()})),t.addEventListener("attached",(async e=>{console.log("[SIGN] onAttached",e.detail,e.target.value);const t=await h(this.endpoint,this.envelopeId,this.roleId,i.name,e.detail);console.log("upload result",t),this.checkRecipientFields()})),t.addEventListener("removed",(e=>{console.log("[SIGN] onRemoved",e.detail,e.target.value)})),t.addEventListener("focusout",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.addEventListener("fieldChange",(e=>this.handleFieldChange(i,e).finally((()=>this.checkRecipientFields())))),t.setAttribute("templateid",this.envelope.template_id),t.setAttribute("fieldname",i.name),t.setAttribute("page",e.pageNumber),t.setAttribute("xScale",e.xScale),t.setAttribute("yScale",e.yScale),t.setAttribute("initials",this.recipient?x(this.recipient.full_name):""),t.setAttribute("name",(null===(s=this.recipient)||void 0===s?void 0:s.full_name)||"")}handlePageRendered(e){const i=e.detail;this.getRecipientFields().filter((e=>e.page===i.pageNumber)).filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!1,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))})),this.sortedRecipients.filter((e=>e.role_name!==this.recipient.role_name&&(e.status===c.INVITED||e.status===c.OPENED||e.status===c.PENDING))).forEach((()=>{this.getRecipientFields().filter((e=>e.page===i.pageNumber)).forEach((e=>{const t=k(e,i,{disabled:!0,editable:!1,draggable:!1,done:this.isDone});t&&(Array.isArray(t)?t.map((t=>this.attachFieldAttributes(i,e,t))):this.attachFieldAttributes(i,e,t))}))})),this.checkRecipientFields()}render(){return this.envelope?this.isDone?t(s,{class:{agreed:this.agreed}},t("verdocs-view",{endpoint:this.endpoint,envelopeId:this.envelopeId,onSdkError:e=>{var i;return null===(i=this.sdkError)||void 0===i?void 0:i.emit(e.detail)}}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null))):t(s,{class:{agreed:this.agreed}},t("div",{id:"verdocs-sign-header"},t("div",{class:"inner"},t("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),t("div",{class:"title"},this.envelope.name),t("div",{style:{flex:"1"}}),!this.finishLater&&t("verdocs-button",{size:"small",label:this.nextButtonLabel,disabled:!this.agreed,onClick:()=>this.handleNext()}),t("div",{style:{marginLeft:"10px"}}),t("verdocs-dropdown",{options:this.isDone||this.finishLater?F:j,onOptionSelected:e=>this.handleOptionSelected(e)}))),t("div",{class:"document",style:{paddingTop:"15px"}},(this.envelope.documents||[]).map((e=>{const i=b(1,e.page_numbers);return t(o,null,i.map((i=>t("verdocs-envelope-document-page",{envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,virtualWidth:612,virtualHeight:792,pageNumber:i,onPageRendered:e=>this.handlePageRendered(e),type:"filled",layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))))}))),this.showFinishLater&&t("verdocs-ok-dialog",{heading:"You've saved your document to finish later.",message:`To complete the ${this.documentsSingularPlural}, use the link in the original email notification inviting you to review and finish the document.`,onNext:()=>this.showFinishLater=!1}),this.errorMessage&&t("verdocs-ok-dialog",{heading:"Network Error",message:this.errorMessage,onNext:()=>this.errorMessage=""}),this.showDone&&t("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=!1,this.isDone=!0}}),this.showLoadError&&t("verdocs-ok-dialog",{heading:"Error Loading Document",message:"Please check with the sender to ensure it has not been canceled, and try again later.",buttonLabel:"Retry",onNext:()=>{this.showLoadError=!1,window.location.reload()}}),this.submitting&&t("div",{class:"loading-indicator"},t("verdocs-loader",null)),!this.agreed&&t("div",{class:"cover"},t("div",{class:"agree"},t("verdocs-checkbox",{name:"agree",label:"By checking this box, you:",onInput:()=>this.handleClickAgree()}),t("ul",null,t("li",null,"Agree to use electronic records and signatures, and confirm you have read the"," ",t("a",{href:"https://verdocs.com/en/electronic-record-signature-disclosure/",target:"_blank"},"Electronic Record and Signatures Disclosure"),"."),t("li",null,"Agree to Verdocs"," ",t("a",{href:"https://verdocs.com/en/eula",target:"_blank"},"End User License Agreement")," ","and confirm you have read Verdocs'"," ",t("a",{href:"https://verdocs.com/en/privacy-policy/",target:"_blank"},"Privacy Policy"),"."))))):t(s,null,t("verdocs-loader",null))}};D.style='verdocs-sign{display:-ms-flexbox;display:flex;overflow:hidden;position:relative;min-height:600px;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-sign div{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-sign input{vertical-align:top}verdocs-sign>.document{-ms-flex:1;flex:1;width:100%;height:100%;-ms-flex-item-align:center;align-self:center;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;max-width:1200px;min-height:200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-sign>.document .inner{width:100%;max-width:1028px}verdocs-sign .cover{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:5000;position:absolute;padding-top:100px;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;background:rgba(0, 0, 0, 0.5)}verdocs-sign .agree{-ms-flex:0;flex:0;width:600px;display:-ms-flexbox;display:flex;max-width:90%;padding:30px 15px;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff}verdocs-sign .agree .header{-ms-flex:0 0 56px;flex:0 0 56px}verdocs-sign .agree li{margin:0.5em 0}verdocs-sign verdocs-ok-dialog .background-overlay{-ms-flex-align:start;align-items:flex-start;padding-top:100px}verdocs-sign .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}@media print{verdocs-sign .header{display:none}}#verdocs-sign-header{color:#fff;width:100%;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}#verdocs-sign-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}#verdocs-sign-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-sign-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;padding:0 10px 0 0;text-overflow:ellipsis}';export{D as verdocs_sign}
|
@@ -1 +1 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,t,o){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function l(e){try{a(o["throw"](e))}catch(e){r(e)}}function a(e){e.done?t(e.value):i(e.value).then(s,l)}a((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(n){return a([e,n])}}function a(s){if(o)throw new TypeError("Generator is already executing.");while(t)try{if(o=1,i&&(r=s[0]&2?i["return"]:s[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;if(i=0,r)s=[s[0]&2,r.value];switch(s[0]){case 0:case 1:r=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){t.label=s[1];break}if(s[0]===6&&t.label<r[1]){t.label=r[1];r=s;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(s);break}if(r[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];i=0}finally{o=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-fbb8023f.system.js","./p-8aae8d16.system.js","./p-1d60151a.system.js","./p-54498887.system.js","./p-f246348c.system.js","./p-3bcd86ea.system.js","./p-cacffa79.system.js","./p-187b20b7.system.js","./p-bbee73c8.system.js","./p-d8cd6b59.system.js","./p-dc9c4361.system.js"],(function(e){"use strict";var n,t,o,i,r,s,l,a,d,c,p,u,h,v;return{setters:[function(e){n=e.r;t=e.c;o=e.h;i=e.H;r=e.F;s=e.a},function(e){l=e.t;a=e.k;d=e.c},function(e){c=e.b},function(){},function(e){p=e.V},function(e){u=e.i},function(e){h=e.s},function(e){v=e.S},function(){},function(){},function(){}],execute:function(){var f='verdocs-view{display:-ms-flexbox;display:flex;overflow:hidden;min-height:600px;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-view div,verdocs-view canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-view .document{-ms-flex:1;flex:1;width:100%;height:100%;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;max-width:1200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-view .document .inner{width:100%;max-width:1028px}verdocs-view .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}#verdocs-view-header{width:100%;color:#fff;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;padding:0 20px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}@media all and (max-width: 500px){#verdocs-view-header{padding:0 10px}}#verdocs-view-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}@media all and (max-width: 500px){#verdocs-view-header .inner{padding:0 10px}}#verdocs-view-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-view-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}';var g=e("verdocs_view",function(){function e(e){n(this,e);this.sdkError=t(this,"sdkError",7);this.envelopeUpdated=t(this,"envelopeUpdated",7);this.another=t(this,"another",7);this.view=t(this,"view",7);this.next=t(this,"next",7);this.endpoint=p.getDefault();this.envelopeId="";this.headerTargetId=null;this.canceling=false;this.envelope=null;this.roleNames=[];this.showCancelDone=false}e.prototype.componentWillLoad=function(){this.endpoint.loadSession()};e.prototype.componentWillRender=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!this.envelopeId){console.error("[VIEW] Missing required envelopeId");return[2]}return[2,this.reloadEnvelope()]}))}))};e.prototype.componentDidRender=function(){var e=this.headerTargetId?document.getElementById(this.headerTargetId):null;var n=document.getElementById("verdocs-view-header");if(e&&n){console.log("[VIEW] Moving header");n.remove();e.append(n)}};e.prototype.reloadEnvelope=function(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,o,i;var r=this;return __generator(this,(function(s){switch(s.label){case 0:console.log("[VIEW] Loading envelope...");s.label=1;case 1:s.trys.push([1,3,,4]);o=this;return[4,l(this.endpoint,this.envelopeId)];case 2:o.envelope=s.sent();console.log("[VIEW] Loaded envelope",this.envelope);this.roleNames=this.envelope.recipients.map((function(e){return e.role_name}));setTimeout((function(){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(n){switch(n.label){case 0:console.log("[VIEW] Reloading envelope...");e=this;return[4,l(this.endpoint,this.envelopeId)];case 1:e.envelope=n.sent();console.log("[VIEW] Reloaded envelope",this.envelope);return[2]}}))}))}),2e3);return[3,4];case 3:i=s.sent();(e=this.sdkError)===null||e===void 0?void 0:e.emit(new v(i.message,(n=i.response)===null||n===void 0?void 0:n.status,(t=i.response)===null||t===void 0?void 0:t.data));return[3,4];case 4:return[2]}}))}))};e.prototype.handlePageRendered=function(e){var n=e.detail;console.log("[VIEW] Page rendered",n)};e.prototype.handleOptionSelected=function(e){return __awaiter(this,void 0,void 0,(function(){var n,t,o,i,i;var r=this;return __generator(this,(function(s){switch(s.label){case 0:o=e.detail.id;switch(o){case"cancel":return[3,1];case"print":return[3,2];case"download-attachments":return[3,3];case"download-certificate":return[3,5];case"download-all":return[3,7]}return[3,8];case 1:if(confirm("Are you sure you wish to cancel this envelope? This action cannot be undone.")){this.canceling=true;d(this.endpoint,this.envelopeId).then((function(e){r.canceling=false;console.log("[VIEW] Envelope canceled",e);return l(r.endpoint,r.envelopeId)})).then((function(e){console.log("[VIEW] Loaded new envelope details",e);r.envelope=e})).catch((function(e){var n,t,o;r.canceling=false;console.log("[VIEW] Error canceling envelope",e);(n=r.sdkError)===null||n===void 0?void 0:n.emit(new v(e.message,(t=e.response)===null||t===void 0?void 0:t.status,(o=e.response)===null||o===void 0?void 0:o.data))}));this.showCancelDone=true;(n=this.envelopeUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,envelope:this.envelope,event:"canceled"})}return[3,8];case 2:window.print();(t=this.envelopeUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});return[3,8];case 3:return[4,a(this.endpoint,this.envelopeId,this.envelope.envelope_document_id)];case 4:i=s.sent();window.open(i,"_blank");return[3,8];case 5:return[4,a(this.endpoint,this.envelopeId,this.envelope.certificate_document_id)];case 6:i=s.sent();window.open(i,"_blank");return[3,8];case 7:h(this.endpoint,[this.envelope]).then((function(){var e;(e=r.envelopeUpdated)===null||e===void 0?void 0:e.emit({endpoint:r.endpoint,envelope:r.envelope,event:"downloaded"})})).catch((function(e){console.log("Error downloading Zip",e)}));return[3,8];case 8:return[2]}}))}))};e.prototype.render=function(){var e=this;var n;if(!this.envelope){return o(i,null,o("img",{src:"https://verdocs-public-assets.s3.amazonaws.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"}))}var t=[{id:"print",label:"Print"}];if(c(this.endpoint.session,this.envelope)){t.push({id:"cancel",label:"Cancel"})}var s=this.envelope.documents.length>0;var l=this.envelope.documents.filter((function(e){return e.type==="attachment"})).length;var a=this.envelope.documents.find((function(e){return e.type==="certificate"}))!==undefined;if(s||a){t.push({label:""});if(s){t.push({id:"download-attachments",label:l>1?"Download Documents":"Download Document"})}if(a){t.push({id:"download-certificate",label:"Download Certificate"})}if(s&&a){t.push({id:"download-all",label:"Download All Files"})}}return o(i,null,o("div",{id:"verdocs-view-header"},o("div",{class:"inner"},o("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),o("div",{class:"title"},this.envelope.name),o("div",{style:{flex:"1"}}),o("div",{style:{marginLeft:"10px"}}),o("verdocs-dropdown",{options:t,onOptionSelected:function(n){return e.handleOptionSelected(n)}}))),o("div",{class:"document",style:{paddingTop:this.headerTargetId?"70px":"15px"}},(((n=this.envelope)===null||n===void 0?void 0:n.documents)||[]).filter((function(e){return e.type!=="certificate"})).map((function(n){var t=u(1,n.page_numbers);return o(r,null,t.map((function(t){return o("verdocs-envelope-document-page",{envelopeId:e.envelopeId,documentId:n.id,endpoint:e.endpoint,type:"filled",virtualWidth:612,virtualHeight:792,pageNumber:t,onPageRendered:function(n){return e.handlePageRendered(n)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))}))),this.showCancelDone&&o("verdocs-ok-dialog",{heading:"Cancelled",message:"This envelope has been cancelled successfully.",onNext:function(){e.showCancelDone=false}}),this.canceling&&o("div",{class:"loading-indicator"},o("verdocs-loader",null)))};Object.defineProperty(e.prototype,"component",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());g.style=f}}}));
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,n,t,o){function i(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function l(e){try{a(o["throw"](e))}catch(e){r(e)}}function a(e){e.done?t(e.value):i(e.value).then(s,l)}a((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(n){return a([e,n])}}function a(s){if(o)throw new TypeError("Generator is already executing.");while(t)try{if(o=1,i&&(r=s[0]&2?i["return"]:s[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;if(i=0,r)s=[s[0]&2,r.value];switch(s[0]){case 0:case 1:r=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;i=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){t.label=s[1];break}if(s[0]===6&&t.label<r[1]){t.label=r[1];r=s;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(s);break}if(r[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];i=0}finally{o=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-fbb8023f.system.js","./p-8aae8d16.system.js","./p-1d60151a.system.js","./p-54498887.system.js","./p-f246348c.system.js","./p-3bcd86ea.system.js","./p-0cafdb16.system.js","./p-187b20b7.system.js","./p-bbee73c8.system.js","./p-173e86c3.system.js","./p-dc9c4361.system.js"],(function(e){"use strict";var n,t,o,i,r,s,l,a,d,c,p,u,h,v;return{setters:[function(e){n=e.r;t=e.c;o=e.h;i=e.H;r=e.F;s=e.a},function(e){l=e.t;a=e.k;d=e.c},function(e){c=e.b},function(){},function(e){p=e.V},function(e){u=e.i},function(e){h=e.s},function(e){v=e.S},function(){},function(){},function(){}],execute:function(){var f='verdocs-view{display:-ms-flexbox;display:flex;overflow:hidden;min-height:600px;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-view div,verdocs-view canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-view .document{-ms-flex:1;flex:1;width:100%;height:100%;display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;max-width:1200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-view .document .inner{width:100%;max-width:1028px}verdocs-view .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}#verdocs-view-header{width:100%;color:#fff;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 56px;flex:0 0 56px;padding:0 20px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}@media all and (max-width: 500px){#verdocs-view-header{padding:0 10px}}#verdocs-view-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 20px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}@media all and (max-width: 500px){#verdocs-view-header .inner{padding:0 10px}}#verdocs-view-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-view-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}';var g=e("verdocs_view",function(){function e(e){n(this,e);this.sdkError=t(this,"sdkError",7);this.envelopeUpdated=t(this,"envelopeUpdated",7);this.another=t(this,"another",7);this.view=t(this,"view",7);this.next=t(this,"next",7);this.endpoint=p.getDefault();this.envelopeId="";this.headerTargetId=null;this.canceling=false;this.envelope=null;this.roleNames=[];this.showCancelDone=false}e.prototype.componentWillLoad=function(){this.endpoint.loadSession()};e.prototype.componentWillRender=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!this.envelopeId){console.error("[VIEW] Missing required envelopeId");return[2]}return[2,this.reloadEnvelope()]}))}))};e.prototype.componentDidRender=function(){var e=this.headerTargetId?document.getElementById(this.headerTargetId):null;var n=document.getElementById("verdocs-view-header");if(e&&n){console.log("[VIEW] Moving header");n.remove();e.append(n)}};e.prototype.reloadEnvelope=function(){return __awaiter(this,void 0,void 0,(function(){var e,n,t,o,i;var r=this;return __generator(this,(function(s){switch(s.label){case 0:console.log("[VIEW] Loading envelope...");s.label=1;case 1:s.trys.push([1,3,,4]);o=this;return[4,l(this.endpoint,this.envelopeId)];case 2:o.envelope=s.sent();console.log("[VIEW] Loaded envelope",this.envelope);this.roleNames=this.envelope.recipients.map((function(e){return e.role_name}));setTimeout((function(){return __awaiter(r,void 0,void 0,(function(){var e;return __generator(this,(function(n){switch(n.label){case 0:console.log("[VIEW] Reloading envelope...");e=this;return[4,l(this.endpoint,this.envelopeId)];case 1:e.envelope=n.sent();console.log("[VIEW] Reloaded envelope",this.envelope);return[2]}}))}))}),2e3);return[3,4];case 3:i=s.sent();(e=this.sdkError)===null||e===void 0?void 0:e.emit(new v(i.message,(n=i.response)===null||n===void 0?void 0:n.status,(t=i.response)===null||t===void 0?void 0:t.data));return[3,4];case 4:return[2]}}))}))};e.prototype.handlePageRendered=function(e){var n=e.detail;console.log("[VIEW] Page rendered",n)};e.prototype.handleOptionSelected=function(e){return __awaiter(this,void 0,void 0,(function(){var n,t,o,i,i;var r=this;return __generator(this,(function(s){switch(s.label){case 0:o=e.detail.id;switch(o){case"cancel":return[3,1];case"print":return[3,2];case"download-attachments":return[3,3];case"download-certificate":return[3,5];case"download-all":return[3,7]}return[3,8];case 1:if(confirm("Are you sure you wish to cancel this envelope? This action cannot be undone.")){this.canceling=true;d(this.endpoint,this.envelopeId).then((function(e){r.canceling=false;console.log("[VIEW] Envelope canceled",e);return l(r.endpoint,r.envelopeId)})).then((function(e){console.log("[VIEW] Loaded new envelope details",e);r.envelope=e})).catch((function(e){var n,t,o;r.canceling=false;console.log("[VIEW] Error canceling envelope",e);(n=r.sdkError)===null||n===void 0?void 0:n.emit(new v(e.message,(t=e.response)===null||t===void 0?void 0:t.status,(o=e.response)===null||o===void 0?void 0:o.data))}));this.showCancelDone=true;(n=this.envelopeUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,envelope:this.envelope,event:"canceled"})}return[3,8];case 2:window.print();(t=this.envelopeUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});return[3,8];case 3:return[4,a(this.endpoint,this.envelopeId,this.envelope.envelope_document_id)];case 4:i=s.sent();window.open(i,"_blank");return[3,8];case 5:return[4,a(this.endpoint,this.envelopeId,this.envelope.certificate_document_id)];case 6:i=s.sent();window.open(i,"_blank");return[3,8];case 7:h(this.endpoint,[this.envelope]).then((function(){var e;(e=r.envelopeUpdated)===null||e===void 0?void 0:e.emit({endpoint:r.endpoint,envelope:r.envelope,event:"downloaded"})})).catch((function(e){console.log("Error downloading Zip",e)}));return[3,8];case 8:return[2]}}))}))};e.prototype.render=function(){var e=this;var n;if(!this.envelope){return o(i,null,o("img",{src:"https://verdocs-public-assets.s3.amazonaws.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"}))}var t=[{id:"print",label:"Print"}];if(c(this.endpoint.session,this.envelope)){t.push({id:"cancel",label:"Cancel"})}var s=this.envelope.documents.length>0;var l=this.envelope.documents.filter((function(e){return e.type==="attachment"})).length;var a=this.envelope.documents.find((function(e){return e.type==="certificate"}))!==undefined;if(s||a){t.push({label:""});if(s){t.push({id:"download-attachments",label:l>1?"Download Documents":"Download Document"})}if(a){t.push({id:"download-certificate",label:"Download Certificate"})}if(s&&a){t.push({id:"download-all",label:"Download All Files"})}}return o(i,null,o("div",{id:"verdocs-view-header"},o("div",{class:"inner"},o("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),o("div",{class:"title"},this.envelope.name),o("div",{style:{flex:"1"}}),o("div",{style:{marginLeft:"10px"}}),o("verdocs-dropdown",{options:t,onOptionSelected:function(n){return e.handleOptionSelected(n)}}))),o("div",{class:"document",style:{paddingTop:this.headerTargetId?"70px":"15px"}},(((n=this.envelope)===null||n===void 0?void 0:n.documents)||[]).filter((function(e){return e.type!=="certificate"})).map((function(n){var t=u(1,n.page_numbers);return o(r,null,t.map((function(t){return o("verdocs-envelope-document-page",{envelopeId:e.envelopeId,documentId:n.id,endpoint:e.endpoint,type:"filled",virtualWidth:612,virtualHeight:792,pageNumber:t,onPageRendered:function(n){return e.handlePageRendered(n)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))}))),this.showCancelDone&&o("verdocs-ok-dialog",{heading:"Cancelled",message:"This envelope has been cancelled successfully.",onNext:function(){e.showCancelDone=false}}),this.canceling&&o("div",{class:"loading-indicator"},o("verdocs-loader",null)))};Object.defineProperty(e.prototype,"component",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());g.style=f}}}));
|