@verdocs/web-sdk 5.0.29 → 5.0.30
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +16 -0
- package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-preview_6.cjs.entry.js +13 -3
- package/dist/cjs/verdocs-preview_6.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-sign.cjs.entry.js +9 -2
- package/dist/cjs/verdocs-sign.cjs.entry.js.map +1 -1
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +13 -3
- package/dist/collection/components/embeds/verdocs-send/verdocs-send.js.map +1 -1
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +9 -2
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js.map +1 -1
- package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js +17 -0
- package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js.map +1 -1
- package/dist/components/{p-27a8eef0.js → p-c4368d04.js} +14 -4
- package/dist/components/p-c4368d04.js.map +1 -0
- package/dist/components/verdocs-build.js +1 -1
- package/dist/components/verdocs-envelope-sidebar.js +17 -0
- package/dist/components/verdocs-envelope-sidebar.js.map +1 -1
- package/dist/components/verdocs-send.js +1 -1
- package/dist/components/verdocs-sign.js +9 -2
- package/dist/components/verdocs-sign.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/verdocs-envelope-sidebar.entry.js +16 -0
- package/dist/esm/verdocs-envelope-sidebar.entry.js.map +1 -1
- package/dist/esm/verdocs-preview_6.entry.js +13 -3
- package/dist/esm/verdocs-preview_6.entry.js.map +1 -1
- package/dist/esm/verdocs-sign.entry.js +9 -2
- package/dist/esm/verdocs-sign.entry.js.map +1 -1
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelope-sidebar.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_6.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js.map +1 -1
- package/dist/types/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.d.ts +1 -0
- package/dist/verdocs-web-sdk/{p-4ae786e9.system.entry.js → p-022110a8.system.entry.js} +3 -3
- package/dist/verdocs-web-sdk/p-022110a8.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-a285560f.entry.js → p-2d0bd50f.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-a285560f.entry.js.map → p-2d0bd50f.entry.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-1f2c019d.system.entry.js → p-3d7d95b0.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-3d7d95b0.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-b7799ec0.entry.js → p-6ff5cab7.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-6ff5cab7.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-70247599.system.entry.js → p-9d538cb1.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-70247599.system.entry.js.map → p-9d538cb1.system.entry.js.map} +1 -1
- package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -1
- package/dist/verdocs-web-sdk/p-e2b70dfb.system.js.map +1 -1
- package/dist/verdocs-web-sdk/{p-6369fc93.entry.js → p-e5470d18.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-e5470d18.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/p-27a8eef0.js.map +0 -1
- package/dist/verdocs-web-sdk/p-1f2c019d.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-4ae786e9.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-6369fc93.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-b7799ec0.entry.js.map +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++){t=arguments[o];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,o,n){function r(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function l(e){try{a(n["throw"](e))}catch(e){i(e)}}function a(e){e.done?o(e.value):r(e.value).then(s,l)}a((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,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(t){return a([e,t])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(o=0)),o)try{if(n=1,r&&(i=l[0]&2?r["return"]:l[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;if(r=0,i)l=[l[0]&2,i.value];switch(l[0]){case 0:case 1:i=l;break;case 4:o.label++;return{value:l[1],done:false};case 5:o.label++;r=l[1];l=[0];continue;case 7:l=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){o=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(l[0]===6&&o.label<i[1]){o.label=i[1];i=l;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(l);break}if(i[2])o.ops.pop();o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e];r=0}finally{n=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var n=0,r=t.length,i;n<r;n++){if(i||!(n in t)){if(!i)i=Array.prototype.slice.call(t,0,n);i[n]=t[n]}}return e.concat(i||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-272d51a4.js";import{VerdocsEndpoint,getTemplate,integerSequence,getOrganizationContacts,isValidEmail,createEnvelope,formatFullName,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole}from"@verdocs/js-sdk";import{S as SDKError}from"./errors-887f1e88.js";import{S as Store}from"./Datastore-77cb8d9c.js";import{V as VerdocsToast}from"./Toast-c4843828.js";import{D as DocIcon,P as PngIcon,J as JpgIcon,a as PdfIcon,F as FileIcon,b as PageCountIcon,T as TrashIcon}from"./Icons-faf0377f.js";import{f as format}from"./format-b8602175.js";import{i as interact}from"./interact.min-a71beb3d.js";import{b as updateCssTransform,c as removeCssTransform,d as setControlStyles,g as getFieldId,e as defaultWidth,f as defaultHeight}from"./utils-bd656c37.js";import"./_commonjsHelpers-bdec4bbd.js";import"./Types-95d86a44.js";var verdocsPreviewCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}';var VerdocsPreviewStyle0=verdocsPreviewCss;var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(n){console.log("[PREVIEW] Error with preview session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.handlePageRendered=function(e){};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var o=integerSequence(1,t.pages);return h(Fragment,null,o.map((function(o){var n;var r=((n=t.page_sizes)===null||n===void 0?void 0:n[o])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:o,disabled:true,editable:false,done:false,virtualWidth:r.width,virtualHeight:r.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=VerdocsPreviewStyle0;var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-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)}';var VerdocsSendStyle0=verdocsSendCss;var editIcon='<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>';var startIcon='<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>';var stepIcon='<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>';var doneIcon='<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>';var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend",7);this.send=createEvent(this,"send",7);this.exit=createEvent(this,"exit",7);this.sdkError=createEvent(this,"sdkError",7);this.searchContacts=createEvent(this,"searchContacts",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.environment="";this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false;e.rolesCompleted={};e.recomputeRolesCompleted()}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};return[2]}))}))};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;var n=this;return __generator(this,(function(r){try{this.endpoint.onSessionChanged((function(e,t,o){if(!o){return}var r={id:o.id,first_name:o.first_name,last_name:o.last_name,email:o.email,phone:o.phone};if(o){n.sessionContacts=[r];getOrganizationContacts(n.endpoint).then((function(e){console.log("[SEND] Got contacts",e);n.sessionContacts=__spreadArray(__spreadArray([],e,true),[r],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(n){console.log("[SEND] Error with send session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var o={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var n=t.sequence-1;o[n]||(o[n]=[]);var r="r-".concat(n,"-").concat(o[n].length);o[n].push(__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[r]=__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getLevels=function(){var e;var t=__spreadArray([],new Set((((e=this.template)===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.sequence-1}))),true);t.sort((function(e,t){return e-t}));return t};e.prototype.getRolesAtLevel=function(e){var t;var o=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence-1===e})).map((function(t,o){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(o),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return o};e.prototype.getLevelIcon=function(e){var t=this.getLevels();if(e<0){return h("div",{class:"level-icon",innerHTML:startIcon})}else if(e>=t.length){return h("div",{class:"level-icon",innerHTML:doneIcon})}else{return h("div",{class:"level-icon",innerHTML:stepIcon})}};e.prototype.handleSelectContact=function(e,t){e.preventDefault();this.rolesCompleted[t.id]=__assign(__assign({},t),e.detail);this.showPickerForId=""};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.showPickerForId=t.id};e.prototype.handleSend=function(e){var t=this;var o;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var n={template_id:this.templateId,name:((o=this.template)===null||o===void 0?void 0:o.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),fields:[]};var r=this.beforeSend.emit(__assign(__assign({},n),{name:n.name}));if(r.defaultPrevented){console.log("[SEND] Send cancelled by parent",n);this.sending=false;return}console.log("[SEND] Creating envelope",n);createEnvelope(this.endpoint,n).then((function(e){var o;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(o=t.send)===null||o===void 0?void 0:o.emit(__assign(__assign({},n),{name:n.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var o,n,r;console.log("[SEND] Send error",e);VerdocsToast(((n=(o=e.response)===null||o===void 0?void 0:o.data)===null||n===void 0?void 0:n.error)||"Error creating envelope, please try again later.");t.sending=false;(r=t.sdkError)===null||r===void 0?void 0:r.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var o=this.getLevels();var n=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var r=n.length>=getRoleNames(this.template).length;return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable}},h("div",{class:"recipients"},h("div",{class:"left-line"}),h("div",{class:"level level-start"},this.getLevelIcon(-1),h("div",{class:"complete"},"Send Envelope")),o.map((function(t){return h("div",{class:"level level-".concat(t)},e.getLevelIcon(t),e.getRolesAtLevel(t).map((function(t){var o,r,i;var s=!t.email||!t.first_name||!t.last_name;var l=((o=e.rolesCompleted[t.id])===null||o===void 0?void 0:o.first_name)?formatFullName(e.rolesCompleted[t.id]):s?t.role_name:formatFullName(t);var a="verdocs-send-recipient-".concat(t.role_name);var c=getRoleIndex(e.template,t.role_name);var d=getRGBA(c);var u=n.findIndex((function(e){return e.role_name===t.role_name}))>-1;var f={backgroundColor:d,border:u?"2px solid #55bc81":"2px solid #dddddd"};return s?h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(o){return e.handleClickRole(o,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(o){return e.handleSelectContact(o,t)},contactSuggestions:e.sessionContacts,templateRole:(r=e.rolesCompleted[t.id])!==null&&r!==void 0?r:t,onSearchContacts:function(t){var o;return(o=e.searchContacts)===null||o===void 0?void 0:o.emit(t.detail)}}))):h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(o){return e.handleClickRole(o,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(o){return e.handleSelectContact(o,t)},contactSuggestions:e.sessionContacts,templateRole:(i=e.rolesCompleted[t.id])!==null&&i!==void 0?i:t,onSearchContacts:function(t){var o;return(o=e.searchContacts)===null||o===void 0?void 0:o.emit(t.detail)}})))})))})),h("div",{class:"level level-done"},this.getLevelIcon(o.length),h("div",{class:"complete"},"Signing Complete"))),h("div",{class:"buttons"},h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!r||this.sending,onClick:function(t){return e.handleSend(t)}}),this.sending&&h("verdocs-spinner",null)))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=VerdocsSendStyle0;var verdocsTemplateAttachmentsCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}';var VerdocsTemplateAttachmentsStyle0=verdocsTemplateAttachmentsCss;var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit",7);this.next=createEvent(this,"next",7);this.templateUpdated=createEvent(this,"templateUpdated",7);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(n){console.log("[TEMPLATE ATTACHMENTS] Error loading template",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s,l,a;return __generator(this,(function(c){switch(c.label){case 0:e.stopPropagation();i=e.detail.file;if(!i){return[2]}console.log("[ATTACHMENTS] Uploading...",i);this.uploading=true;this.progressLabel="Uploading...";c.label=1;case 1:c.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,i,this.handleUploadProgress.bind(this))];case 2:s=c.sent();console.log("[ATTACHMENTS] Created attachment",s);l=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:l.template=c.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:a=c.sent();console.log("[ATTACHMENTS] Error creating template",a);(o=this.sdkError)===null||o===void 0?void 0:o.emit(new SDKError(a.message,(n=a.response)===null||n===void 0?void 0:n.status,(r=a.response)===null||r===void 0?void 0:r.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.templateId,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(o){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,o;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected:function(t){return e.handleUpload(t)}}),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("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:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=VerdocsTemplateAttachmentsStyle0;var verdocsTemplateBuildTabsCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-build-tabs verdocs-button-panel svg{-webkit-transform:scale(0.8);transform:scale(0.8)}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}.template-details-panel .row{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:8px;margin:10px 0}.template-details-panel label{-ms-flex:0 0 70px;flex:0 0 70px}.template-details-panel .value{-ms-flex:1;flex:1;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-details-panel .icon-button{cursor:pointer;opacity:0.8;-ms-flex:0;flex:0;width:18px;height:18px}.template-details-panel .icon-button svg{stroke:#000000;width:18px;height:18px}.template-details-panel .icon-button:hover{opacity:1}';var VerdocsTemplateBuildTabsStyle0=verdocsTemplateBuildTabsCss;var HelpIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="#5c6575"><path d="M11.925 18q.55 0 .938-.387.387-.388.387-.938 0-.55-.387-.925-.388-.375-.938-.375-.55 0-.925.375t-.375.925q0 .55.375.938.375.387.925.387Zm-.95-3.85h1.95q0-.8.2-1.287.2-.488 1.025-1.288.65-.625 1.025-1.213.375-.587.375-1.437 0-1.425-1.025-2.175Q13.5 6 12.1 6q-1.425 0-2.35.775t-1.275 1.85l1.775.7q.125-.45.55-.975.425-.525 1.275-.525.725 0 1.1.412.375.413.375.888 0 .475-.287.9-.288.425-.713.775-1.075.95-1.325 1.475-.25.525-.25 1.875ZM12 22.2q-2.125 0-3.988-.8-1.862-.8-3.237-2.175Q3.4 17.85 2.6 15.988 1.8 14.125 1.8 12t.8-3.988q.8-1.862 2.175-3.237Q6.15 3.4 8.012 2.6 9.875 1.8 12 1.8t3.988.8q1.862.8 3.237 2.175Q20.6 6.15 21.4 8.012q.8 1.863.8 3.988t-.8 3.988q-.8 1.862-2.175 3.237Q17.85 20.6 15.988 21.4q-1.863.8-3.988.8Zm0-2.275q3.325 0 5.625-2.3t2.3-5.625q0-3.325-2.3-5.625T12 4.075q-3.325 0-5.625 2.3T4.075 12q0 3.325 2.3 5.625t5.625 2.3ZM12 12Z"/></svg>';var CopyIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" /></svg>';var STEPS=["attachments","roles","settings","fields","preview"];var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.stepChanged=createEvent(this,"stepChanged",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(n){console.log("[BUILD_TABS] Error loading template",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.setStep=function(e){var t;console.log("[BUILD_TABS] Selected step",e.detail.tab.id);e.stopPropagation();e.preventDefault();this.step=e.detail.tab.id;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.detail.tab.id)};e.prototype.copyTemplateId=function(){var e=this;navigator.clipboard.writeText(this.templateId).then((function(){VerdocsToast("Template ID copied",{style:"success",duration:3e3})})).catch((function(t){var o;console.warn("[BUILD_TABS] Error copying to clipboard",t);(o=e.sdkError)===null||o===void 0?void 0:o.emit(t)}))};e.prototype.render=function(){var e=this;var t,o,n,r,i,s,l,a,c;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var d=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var u=d&&(((o=this.template)===null||o===void 0?void 0:o.roles)||[]).length>0;var f=u&&(((n=this.template)===null||n===void 0?void 0:n.fields)||[]).length>0;var v=Math.max(STEPS.indexOf(this.step),0);if(!f&&v>=4){v=3}if(!u&&v>=3){v=1}if(!d&&v>=1){v=0}return h(Host,null,h("verdocs-tabs",{onSelectTab:function(t){return e.setStep(t)},selectedTab:v,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!d,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&h("div",{class:"info"},h("verdocs-button-panel",{icon:HelpIcon},h("div",{class:"template-details-panel"},h("h6",null,"Template Details"),h("div",{class:"row"},h("label",null,"ID:"),h("div",{class:"value"},this.templateId),h("div",{class:"icon-button",innerHTML:CopyIcon,onClick:function(){return e.copyTemplateId()}})),h("div",{class:"row"},h("label",null,"Name:"),h("div",{class:"value"},(r=this.template)===null||r===void 0?void 0:r.name)),h("div",{class:"row"},h("label",null,"Visibility:"),h("div",{class:"value"},((i=this.template)===null||i===void 0?void 0:i.is_public)?"Public":((s=this.template)===null||s===void 0?void 0:s.is_personal)?"Private":"Shared")),h("div",{class:"row"},h("label",null,"Created:"),h("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.counter)?format(new Date((a=this.template)===null||a===void 0?void 0:a.created_at),"P p"):"")),h("div",{class:"row"},h("label",null,"Used:"),h("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=VerdocsTemplateBuildTabsStyle0;var verdocsTemplateFieldsCss="@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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 rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}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{width:100%;height:50px;display:-ms-flexbox;display:flex;-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}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}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{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{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}";var VerdocsTemplateFieldsStyle0=verdocsTemplateFieldsCss;var iconTextbox='<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>';var iconCheck='<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>';var iconRadio='<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>';var iconDatepicker='<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>';var iconSignature='<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>';var iconInitial='<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>';var iconTimestamp='<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>';var iconDropdown='<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>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13" /></svg>';var separator='<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>';var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"timestamp",tooltip:"Timestamp",icon:iconTimestamp,class:"timestamp"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.templateUpdated=createEvent(this,"templateUpdated",7);this.fieldsUpdated=createEvent(this,"fieldsUpdated",7);this.templateListenerId=null;this.pageHeights={};this.cachedPageInfo={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){if(e.key==="Escape"){this.placing=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(n){console.log("[FIELDS] Error with fields session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);var e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){console.log("[FIELDS] Moving toolbar");t.remove();e.append(t)}};e.prototype.componentWillUpdate=function(){var e=this;var t,o;var n=((t=this.template)===null||t===void 0?void 0:t.roles)||[];if(!this.selectedRoleName||!n.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((o=n[0])===null||o===void 0?void 0:o.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var o,n;e.template=t;e.loading=false;if(!e.selectedRoleName){e.selectedRoleName=((n=(o=t.roles)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.attachFieldAttributes=function(e,t,o){var n=this;o.addEventListener("settingsChanged",(function(){var e;(e=n.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:n.endpoint,template:n.template,event:"added-field"})}));o.addEventListener("deleted",(function(){var e;o.remove();(e=n.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:n.endpoint,template:n.template,event:"updated-field"})}));o.setAttribute("templateid",this.templateId);o.setAttribute("fieldname",t.name);o.setAttribute("pageNumber",String(e.pageNumber));o.setAttribute("xScale",String(e.xScale));o.setAttribute("yScale",String(e.yScale));o.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var o;var n=e.detail;this.cachedPageInfo[n.pageNumber]=n;this.pageHeights[n.pageNumber]=n.naturalHeight;(((o=this.template)===null||o===void 0?void 0:o.fields)||[]).filter((function(e){return e&&e.page===n.pageNumber})).forEach((function(e){var o=getFieldId(e);var n=document.getElementById(o);if(n){n.setAttribute("fieldname",e.name);n.setAttribute("pagenumber",String(e.page));t.makeDraggable(n)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s;return __generator(this,(function(l){t=+(e.target.getAttribute("posX")||0);o=+(e.target.getAttribute("posY")||0);n=+(e.target.getAttribute("xScale")||1);r=+(e.target.getAttribute("yScale")||1);i=e.dx/n+t;s=e.dy/r+o;e.target.setAttribute("posX",i);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(i,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s,l,a,c,d,u,f,h,v,p,g,m,b,x,E,w,S,_,y,I,C,k,T,D,q,M,R,A,H,O,P,V,L,Z;return __generator(this,(function(z){switch(z.label){case 0:c=e.target.getAttribute("fieldname");d=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===c}));if(!d){console.log("[FIELDS] Unable to find field",c,e.target);return[2]}u=e.target.getAttribute("pagenumber");f=this.cachedPageInfo[u],h=f.naturalWidth,v=h===void 0?612:h,p=f.naturalHeight,g=p===void 0?792:p,m=f.renderedHeight,b=m===void 0?792:m;x=e.target.getBoundingClientRect();E=e.target.parentElement;w=E.getBoundingClientRect();S=d.width||defaultWidth(d.type);_=d.height||defaultHeight(d.type);y=Math.max(x.left-w.left,0);I=Math.max(b-(w.bottom-x.bottom),0);C=parseInt(u);if(I>b){C=Math.min(C+1,((r=(n=((o=this.template)===null||o===void 0?void 0:o.documents)||[])===null||n===void 0?void 0:n[0])===null||r===void 0?void 0:r.pages)||1);I-=b;b=this.cachedPageInfo[C].renderedHeight;console.log("Next page",{newPageNumber:C,newY:I,renderedHeight:b})}else if(I<0){C=Math.max(C-1,1);b=this.cachedPageInfo[C].renderedHeight;I+=b;console.log("[FIELDS] Next page",{newPageNumber:C,newY:I,renderedHeight:b})}k=this.viewCoordinatesToPageCoordinates(y,I,u,v-S,g-_),T=k.x,D=k.y;z.label=1;case 1:z.trys.push([1,3,,4]);q={x:T,y:D,page:C};return[4,updateField(this.endpoint,this.templateId,c,q)];case 2:M=z.sent();console.log("[FIELDS] Updated",M);R=JSON.parse(JSON.stringify(this.template));A=R.fields.findIndex((function(e){return e.name===c}));if(A>-1){R.fields[A]=M}Store.updateTemplate(this.templateId,R);e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);H=this.cachedPageInfo[u],O=H.xScale,P=O===void 0?1:O,V=H.yScale,L=V===void 0?1:V;setControlStyles(e.target,M,P,L);(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:R,event:"updated-field"});return[3,4];case 3:Z=z.sent();VerdocsToast("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",Z);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(Z.message,(l=Z.response)===null||l===void 0?void 0:l.status,(a=Z.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);return[3,4];case 4:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var o;var n=1;var r;do{r="".concat(e,"P").concat(t,"-").concat(n);n++}while((((o=this.template)===null||o===void 0?void 0:o.fields)||[]).some((function(e){return e&&e.name===r})));return r};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,o,n,r){var i=this.cachedPageInfo[o],s=i.xScale,l=s===void 0?1:s,a=i.yScale,c=a===void 0?1:a,d=i.renderedHeight,u=d===void 0?792:d;var f=Math.floor(Math.min(e/l,n));var h=Math.floor(Math.min(Math.max(u-t,0)/c,r));return{x:f,y:h}};e.prototype.handleClickPage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var o,n,r,i,s,l,a,c,d,u,f,h,v,p,g,m;return __generator(this,(function(b){switch(b.label){case 0:if(!this.placing)return[3,2];n=e.offsetX;r=e.offsetY;i=defaultWidth(this.placing);s=defaultHeight(this.placing);l=this.cachedPageInfo[t];a=l.naturalWidth,c=a===void 0?612:a,d=l.naturalHeight,u=d===void 0?792:d;f=this.viewCoordinatesToPageCoordinates(n,r,t,c-i,u-s);h=Math.floor(f.x);v=Math.floor(f.y);p={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:l.documentId,type:this.placing,required:this.placing!=="radio",page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:h,y:v,width:i,height:s,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",p);return[4,createField(this.endpoint,this.templateId,p)];case 1:g=b.sent();console.log("[FIELDS] Saved field",g);m=JSON.parse(JSON.stringify(this.template));m.fields.push(g);Store.updateTemplate(this.templateId,m);(o=this.templateUpdated)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,template:m,event:"added-field"});this.placing=null;b.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var o,n,r;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var i=(((o=this.template)===null||o===void 0?void 0:o.roles)||[]).map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:i,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).map((function(e){var o=integerSequence(1,e.pages);return o.map((function(o){var n=e.page_sizes[o];return h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:o,virtualWidth:(n===null||n===void 0?void 0:n.width)||612,virtualHeight:(n===null||n===void 0?void 0:n.height)||792,disabled:true,editable:true,done:false,onClick:function(e){return t.handleClickPage(e,o)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((r=this.template)===null||r===void 0?void 0:r.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=VerdocsTemplateFieldsStyle0;
|
1
|
+
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++){t=arguments[o];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,o,n){function r(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function l(e){try{a(n["throw"](e))}catch(e){i(e)}}function a(e){e.done?o(e.value):r(e.value).then(s,l)}a((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,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(t){return a([e,t])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(o=0)),o)try{if(n=1,r&&(i=l[0]&2?r["return"]:l[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;if(r=0,i)l=[l[0]&2,i.value];switch(l[0]){case 0:case 1:i=l;break;case 4:o.label++;return{value:l[1],done:false};case 5:o.label++;r=l[1];l=[0];continue;case 7:l=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(l[0]===6||l[0]===2)){o=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]<i[3])){o.label=l[1];break}if(l[0]===6&&o.label<i[1]){o.label=i[1];i=l;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(l);break}if(i[2])o.ops.pop();o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e];r=0}finally{n=i=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var n=0,r=t.length,i;n<r;n++){if(i||!(n in t)){if(!i)i=Array.prototype.slice.call(t,0,n);i[n]=t[n]}}return e.concat(i||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-272d51a4.js";import{VerdocsEndpoint,getTemplate,integerSequence,getOrganizationContacts,isValidEmail,createEnvelope,formatFullName,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole}from"@verdocs/js-sdk";import{S as SDKError}from"./errors-887f1e88.js";import{S as Store}from"./Datastore-77cb8d9c.js";import{V as VerdocsToast}from"./Toast-c4843828.js";import{D as DocIcon,P as PngIcon,J as JpgIcon,a as PdfIcon,F as FileIcon,b as PageCountIcon,T as TrashIcon}from"./Icons-faf0377f.js";import{f as format}from"./format-b8602175.js";import{i as interact}from"./interact.min-a71beb3d.js";import{b as updateCssTransform,c as removeCssTransform,d as setControlStyles,g as getFieldId,e as defaultWidth,f as defaultHeight}from"./utils-bd656c37.js";import"./_commonjsHelpers-bdec4bbd.js";import"./Types-95d86a44.js";var verdocsPreviewCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}';var VerdocsPreviewStyle0=verdocsPreviewCss;var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(n){console.log("[PREVIEW] Error with preview session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.handlePageRendered=function(e){};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var o=integerSequence(1,t.pages);return h(Fragment,null,o.map((function(o){var n;var r=((n=t.page_sizes)===null||n===void 0?void 0:n[o])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:o,disabled:true,editable:false,done:false,virtualWidth:r.width,virtualHeight:r.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=VerdocsPreviewStyle0;var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-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)}';var VerdocsSendStyle0=verdocsSendCss;var editIcon='<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>';var startIcon='<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>';var stepIcon='<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>';var doneIcon='<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>';var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend",7);this.send=createEvent(this,"send",7);this.exit=createEvent(this,"exit",7);this.sdkError=createEvent(this,"sdkError",7);this.searchContacts=createEvent(this,"searchContacts",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.environment="";this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false;e.rolesCompleted={};e.recomputeRolesCompleted()}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};return[2]}))}))};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;var n=this;return __generator(this,(function(r){try{this.endpoint.onSessionChanged((function(e,t,o){if(!o){return}var r={id:o.id,first_name:o.first_name,last_name:o.last_name,email:o.email,phone:o.phone};if(o){n.sessionContacts=[r];getOrganizationContacts(n.endpoint).then((function(e){console.log("[SEND] Got contacts",e);n.sessionContacts=__spreadArray(__spreadArray([],e,true),[r],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(n){console.log("[SEND] Error with send session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var o={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var n=t.sequence-1;o[n]||(o[n]=[]);var r="r-".concat(n,"-").concat(o[n].length);o[n].push(__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[r]=__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getLevels=function(){var e;var t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((function(e){t[e.sequence]=true}));console.log("[SEND] Sequences",t);return Object.keys(t).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRolesAtLevel=function(e){var t;var o=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence-1===e})).map((function(t,o){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(o),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return o};e.prototype.getLevelIcon=function(e){var t=this.getLevels();if(e<0){return h("div",{class:"level-icon",innerHTML:startIcon})}else if(e>=t.length){return h("div",{class:"level-icon",innerHTML:doneIcon})}else{return h("div",{class:"level-icon",innerHTML:stepIcon})}};e.prototype.handleSelectContact=function(e,t){e.preventDefault();this.rolesCompleted[t.id]=__assign(__assign({},t),e.detail);this.showPickerForId=""};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.showPickerForId=t.id};e.prototype.handleSend=function(e){var t=this;var o;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var n={template_id:this.templateId,name:((o=this.template)===null||o===void 0?void 0:o.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),fields:[]};var r=this.beforeSend.emit(__assign(__assign({},n),{name:n.name}));if(r.defaultPrevented){console.log("[SEND] Send cancelled by parent",n);this.sending=false;return}console.log("[SEND] Creating envelope",n);createEnvelope(this.endpoint,n).then((function(e){var o;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(o=t.send)===null||o===void 0?void 0:o.emit(__assign(__assign({},n),{name:n.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var o,n,r;console.log("[SEND] Send error",e);VerdocsToast(((n=(o=e.response)===null||o===void 0?void 0:o.data)===null||n===void 0?void 0:n.error)||"Error creating envelope, please try again later.");t.sending=false;(r=t.sdkError)===null||r===void 0?void 0:r.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var o=this.getLevels();var n=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var r=n.length>=getRoleNames(this.template).length;return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable}},h("div",{class:"recipients"},h("div",{class:"left-line"}),h("div",{class:"level level-start"},this.getLevelIcon(-1),h("div",{class:"complete"},"Send Envelope")),o.map((function(t){return h("div",{class:"level level-".concat(t)},e.getLevelIcon(t),e.getRolesAtLevel(t).map((function(t){var o,r,i;var s=!t.email||!t.first_name||!t.last_name;var l=((o=e.rolesCompleted[t.id])===null||o===void 0?void 0:o.first_name)?formatFullName(e.rolesCompleted[t.id]):s?t.role_name:formatFullName(t);var a="verdocs-send-recipient-".concat(t.role_name);var c=getRoleIndex(e.template,t.role_name);var d=getRGBA(c);var u=n.findIndex((function(e){return e.role_name===t.role_name}))>-1;var f={backgroundColor:d,border:u?"2px solid #55bc81":"2px solid #dddddd"};return s?h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(o){return e.handleClickRole(o,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(o){return e.handleSelectContact(o,t)},contactSuggestions:e.sessionContacts,templateRole:(r=e.rolesCompleted[t.id])!==null&&r!==void 0?r:t,onSearchContacts:function(t){var o;return(o=e.searchContacts)===null||o===void 0?void 0:o.emit(t.detail)}}))):h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(o){return e.handleClickRole(o,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(o){return e.handleSelectContact(o,t)},contactSuggestions:e.sessionContacts,templateRole:(i=e.rolesCompleted[t.id])!==null&&i!==void 0?i:t,onSearchContacts:function(t){var o;return(o=e.searchContacts)===null||o===void 0?void 0:o.emit(t.detail)}})))})))})),h("div",{class:"level level-done"},this.getLevelIcon(o.length),h("div",{class:"complete"},"Signing Complete"))),h("div",{class:"buttons"},h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!r||this.sending,onClick:function(t){return e.handleSend(t)}}),this.sending&&h("verdocs-spinner",null)))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=VerdocsSendStyle0;var verdocsTemplateAttachmentsCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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}';var VerdocsTemplateAttachmentsStyle0=verdocsTemplateAttachmentsCss;var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit",7);this.next=createEvent(this,"next",7);this.templateUpdated=createEvent(this,"templateUpdated",7);this.sdkError=createEvent(this,"sdkError",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(n){console.log("[TEMPLATE ATTACHMENTS] Error loading template",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s,l,a;return __generator(this,(function(c){switch(c.label){case 0:e.stopPropagation();i=e.detail.file;if(!i){return[2]}console.log("[ATTACHMENTS] Uploading...",i);this.uploading=true;this.progressLabel="Uploading...";c.label=1;case 1:c.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,i,this.handleUploadProgress.bind(this))];case 2:s=c.sent();console.log("[ATTACHMENTS] Created attachment",s);l=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:l.template=c.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:a=c.sent();console.log("[ATTACHMENTS] Error creating template",a);(o=this.sdkError)===null||o===void 0?void 0:o.emit(new SDKError(a.message,(n=a.response)===null||n===void 0?void 0:n.status,(r=a.response)===null||r===void 0?void 0:r.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.templateId,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(o){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,o;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected:function(t){return e.handleUpload(t)}}),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("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:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=VerdocsTemplateAttachmentsStyle0;var verdocsTemplateBuildTabsCss='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-build-tabs verdocs-button-panel svg{-webkit-transform:scale(0.8);transform:scale(0.8)}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}.template-details-panel .row{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:8px;margin:10px 0}.template-details-panel label{-ms-flex:0 0 70px;flex:0 0 70px}.template-details-panel .value{-ms-flex:1;flex:1;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-details-panel .icon-button{cursor:pointer;opacity:0.8;-ms-flex:0;flex:0;width:18px;height:18px}.template-details-panel .icon-button svg{stroke:#000000;width:18px;height:18px}.template-details-panel .icon-button:hover{opacity:1}';var VerdocsTemplateBuildTabsStyle0=verdocsTemplateBuildTabsCss;var HelpIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="#5c6575"><path d="M11.925 18q.55 0 .938-.387.387-.388.387-.938 0-.55-.387-.925-.388-.375-.938-.375-.55 0-.925.375t-.375.925q0 .55.375.938.375.387.925.387Zm-.95-3.85h1.95q0-.8.2-1.287.2-.488 1.025-1.288.65-.625 1.025-1.213.375-.587.375-1.437 0-1.425-1.025-2.175Q13.5 6 12.1 6q-1.425 0-2.35.775t-1.275 1.85l1.775.7q.125-.45.55-.975.425-.525 1.275-.525.725 0 1.1.412.375.413.375.888 0 .475-.287.9-.288.425-.713.775-1.075.95-1.325 1.475-.25.525-.25 1.875ZM12 22.2q-2.125 0-3.988-.8-1.862-.8-3.237-2.175Q3.4 17.85 2.6 15.988 1.8 14.125 1.8 12t.8-3.988q.8-1.862 2.175-3.237Q6.15 3.4 8.012 2.6 9.875 1.8 12 1.8t3.988.8q1.862.8 3.237 2.175Q20.6 6.15 21.4 8.012q.8 1.863.8 3.988t-.8 3.988q-.8 1.862-2.175 3.237Q17.85 20.6 15.988 21.4q-1.863.8-3.988.8Zm0-2.275q3.325 0 5.625-2.3t2.3-5.625q0-3.325-2.3-5.625T12 4.075q-3.325 0-5.625 2.3T4.075 12q0 3.325 2.3 5.625t5.625 2.3ZM12 12Z"/></svg>';var CopyIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" /></svg>';var STEPS=["attachments","roles","settings","fields","preview"];var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.stepChanged=createEvent(this,"stepChanged",7);this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(n){console.log("[BUILD_TABS] Error loading template",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.setStep=function(e){var t;console.log("[BUILD_TABS] Selected step",e.detail.tab.id);e.stopPropagation();e.preventDefault();this.step=e.detail.tab.id;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.detail.tab.id)};e.prototype.copyTemplateId=function(){var e=this;navigator.clipboard.writeText(this.templateId).then((function(){VerdocsToast("Template ID copied",{style:"success",duration:3e3})})).catch((function(t){var o;console.warn("[BUILD_TABS] Error copying to clipboard",t);(o=e.sdkError)===null||o===void 0?void 0:o.emit(t)}))};e.prototype.render=function(){var e=this;var t,o,n,r,i,s,l,a,c;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var d=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var u=d&&(((o=this.template)===null||o===void 0?void 0:o.roles)||[]).length>0;var f=u&&(((n=this.template)===null||n===void 0?void 0:n.fields)||[]).length>0;var v=Math.max(STEPS.indexOf(this.step),0);if(!f&&v>=4){v=3}if(!u&&v>=3){v=1}if(!d&&v>=1){v=0}return h(Host,null,h("verdocs-tabs",{onSelectTab:function(t){return e.setStep(t)},selectedTab:v,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!d,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&h("div",{class:"info"},h("verdocs-button-panel",{icon:HelpIcon},h("div",{class:"template-details-panel"},h("h6",null,"Template Details"),h("div",{class:"row"},h("label",null,"ID:"),h("div",{class:"value"},this.templateId),h("div",{class:"icon-button",innerHTML:CopyIcon,onClick:function(){return e.copyTemplateId()}})),h("div",{class:"row"},h("label",null,"Name:"),h("div",{class:"value"},(r=this.template)===null||r===void 0?void 0:r.name)),h("div",{class:"row"},h("label",null,"Visibility:"),h("div",{class:"value"},((i=this.template)===null||i===void 0?void 0:i.is_public)?"Public":((s=this.template)===null||s===void 0?void 0:s.is_personal)?"Private":"Shared")),h("div",{class:"row"},h("label",null,"Created:"),h("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.counter)?format(new Date((a=this.template)===null||a===void 0?void 0:a.created_at),"P p"):"")),h("div",{class:"row"},h("label",null,"Used:"),h("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=VerdocsTemplateBuildTabsStyle0;var verdocsTemplateFieldsCss="@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}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 rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}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{width:100%;height:50px;display:-ms-flexbox;display:flex;-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}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}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{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{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}";var VerdocsTemplateFieldsStyle0=verdocsTemplateFieldsCss;var iconTextbox='<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>';var iconCheck='<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>';var iconRadio='<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>';var iconDatepicker='<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>';var iconSignature='<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>';var iconInitial='<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>';var iconTimestamp='<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>';var iconDropdown='<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>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13" /></svg>';var separator='<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>';var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"timestamp",tooltip:"Timestamp",icon:iconTimestamp,class:"timestamp"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError",7);this.templateUpdated=createEvent(this,"templateUpdated",7);this.fieldsUpdated=createEvent(this,"fieldsUpdated",7);this.templateListenerId=null;this.pageHeights={};this.cachedPageInfo={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){if(e.key==="Escape"){this.placing=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(n){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(n){console.log("[FIELDS] Error with fields session",n);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(n.message,(t=n.response)===null||t===void 0?void 0:t.status,(o=n.response)===null||o===void 0?void 0:o.data))}return[2]}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);var e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){console.log("[FIELDS] Moving toolbar");t.remove();e.append(t)}};e.prototype.componentWillUpdate=function(){var e=this;var t,o;var n=((t=this.template)===null||t===void 0?void 0:t.roles)||[];if(!this.selectedRoleName||!n.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((o=n[0])===null||o===void 0?void 0:o.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var o,n;e.template=t;e.loading=false;if(!e.selectedRoleName){e.selectedRoleName=((n=(o=t.roles)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.attachFieldAttributes=function(e,t,o){var n=this;o.addEventListener("settingsChanged",(function(){var e;(e=n.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:n.endpoint,template:n.template,event:"added-field"})}));o.addEventListener("deleted",(function(){var e;o.remove();(e=n.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:n.endpoint,template:n.template,event:"updated-field"})}));o.setAttribute("templateid",this.templateId);o.setAttribute("fieldname",t.name);o.setAttribute("pageNumber",String(e.pageNumber));o.setAttribute("xScale",String(e.xScale));o.setAttribute("yScale",String(e.yScale));o.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var o;var n=e.detail;this.cachedPageInfo[n.pageNumber]=n;this.pageHeights[n.pageNumber]=n.naturalHeight;(((o=this.template)===null||o===void 0?void 0:o.fields)||[]).filter((function(e){return e&&e.page===n.pageNumber})).forEach((function(e){var o=getFieldId(e);var n=document.getElementById(o);if(n){n.setAttribute("fieldname",e.name);n.setAttribute("pagenumber",String(e.page));t.makeDraggable(n)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s;return __generator(this,(function(l){t=+(e.target.getAttribute("posX")||0);o=+(e.target.getAttribute("posY")||0);n=+(e.target.getAttribute("xScale")||1);r=+(e.target.getAttribute("yScale")||1);i=e.dx/n+t;s=e.dy/r+o;e.target.setAttribute("posX",i);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(i,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,o,n,r,i,s,l,a,c,d,u,f,h,v,p,g,m,b,x,E,w,S,_,y,I,C,k,T,D,q,M,R,A,H,O,P,V,L,Z;return __generator(this,(function(z){switch(z.label){case 0:c=e.target.getAttribute("fieldname");d=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===c}));if(!d){console.log("[FIELDS] Unable to find field",c,e.target);return[2]}u=e.target.getAttribute("pagenumber");f=this.cachedPageInfo[u],h=f.naturalWidth,v=h===void 0?612:h,p=f.naturalHeight,g=p===void 0?792:p,m=f.renderedHeight,b=m===void 0?792:m;x=e.target.getBoundingClientRect();E=e.target.parentElement;w=E.getBoundingClientRect();S=d.width||defaultWidth(d.type);_=d.height||defaultHeight(d.type);y=Math.max(x.left-w.left,0);I=Math.max(b-(w.bottom-x.bottom),0);C=parseInt(u);if(I>b){C=Math.min(C+1,((r=(n=((o=this.template)===null||o===void 0?void 0:o.documents)||[])===null||n===void 0?void 0:n[0])===null||r===void 0?void 0:r.pages)||1);I-=b;b=this.cachedPageInfo[C].renderedHeight;console.log("Next page",{newPageNumber:C,newY:I,renderedHeight:b})}else if(I<0){C=Math.max(C-1,1);b=this.cachedPageInfo[C].renderedHeight;I+=b;console.log("[FIELDS] Next page",{newPageNumber:C,newY:I,renderedHeight:b})}k=this.viewCoordinatesToPageCoordinates(y,I,u,v-S,g-_),T=k.x,D=k.y;z.label=1;case 1:z.trys.push([1,3,,4]);q={x:T,y:D,page:C};return[4,updateField(this.endpoint,this.templateId,c,q)];case 2:M=z.sent();console.log("[FIELDS] Updated",M);R=JSON.parse(JSON.stringify(this.template));A=R.fields.findIndex((function(e){return e.name===c}));if(A>-1){R.fields[A]=M}Store.updateTemplate(this.templateId,R);e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);H=this.cachedPageInfo[u],O=H.xScale,P=O===void 0?1:O,V=H.yScale,L=V===void 0?1:V;setControlStyles(e.target,M,P,L);(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:R,event:"updated-field"});return[3,4];case 3:Z=z.sent();VerdocsToast("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",Z);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(Z.message,(l=Z.response)===null||l===void 0?void 0:l.status,(a=Z.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);return[3,4];case 4:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var o;var n=1;var r;do{r="".concat(e,"P").concat(t,"-").concat(n);n++}while((((o=this.template)===null||o===void 0?void 0:o.fields)||[]).some((function(e){return e&&e.name===r})));return r};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,o,n,r){var i=this.cachedPageInfo[o],s=i.xScale,l=s===void 0?1:s,a=i.yScale,c=a===void 0?1:a,d=i.renderedHeight,u=d===void 0?792:d;var f=Math.floor(Math.min(e/l,n));var h=Math.floor(Math.min(Math.max(u-t,0)/c,r));return{x:f,y:h}};e.prototype.handleClickPage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var o,n,r,i,s,l,a,c,d,u,f,h,v,p,g,m;return __generator(this,(function(b){switch(b.label){case 0:if(!this.placing)return[3,2];n=e.offsetX;r=e.offsetY;i=defaultWidth(this.placing);s=defaultHeight(this.placing);l=this.cachedPageInfo[t];a=l.naturalWidth,c=a===void 0?612:a,d=l.naturalHeight,u=d===void 0?792:d;f=this.viewCoordinatesToPageCoordinates(n,r,t,c-i,u-s);h=Math.floor(f.x);v=Math.floor(f.y);p={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:l.documentId,type:this.placing,required:this.placing!=="radio",page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:h,y:v,width:i,height:s,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",p);return[4,createField(this.endpoint,this.templateId,p)];case 1:g=b.sent();console.log("[FIELDS] Saved field",g);m=JSON.parse(JSON.stringify(this.template));m.fields.push(g);Store.updateTemplate(this.templateId,m);(o=this.templateUpdated)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,template:m,event:"added-field"});this.placing=null;b.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var o,n,r;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var i=(((o=this.template)===null||o===void 0?void 0:o.roles)||[]).map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:i,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).map((function(e){var o=integerSequence(1,e.pages);return o.map((function(o){var n=e.page_sizes[o];return h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:o,virtualWidth:(n===null||n===void 0?void 0:n.width)||612,virtualHeight:(n===null||n===void 0?void 0:n.height)||792,disabled:true,editable:true,done:false,onClick:function(e){return t.handleClickPage(e,o)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((r=this.template)===null||r===void 0?void 0:r.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=VerdocsTemplateFieldsStyle0;
|
2
2
|
/**!
|
3
3
|
* Sortable 1.15.6
|
4
4
|
* @author RubaXa <trash@rubaxa.org>
|