drill-widgets 2.7.4 → 2.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/dist/drill-widgets.es.js +276 -688
- package/dist/drill-widgets.umd.js +103 -185
- package/package.json +14 -2
|
@@ -2,37 +2,36 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/var
|
|
5
|
+
*/var Oe;const A=globalThis,se=A.ShadowRoot&&(A.ShadyCSS===void 0||A.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,re=Symbol(),xe=new WeakMap;let _e=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==re)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(se&&e===void 0){const n=t!==void 0&&t.length===1;n&&(e=xe.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&xe.set(t,e))}return e}toString(){return this.cssText}};const Re=i=>new _e(typeof i=="string"?i:i+"",void 0,re),L=(i,...e)=>{const t=i.length===1?i[0]:e.reduce((n,s,r)=>n+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+i[r+1],i[0]);return new _e(t,i,re)},We=(i,e)=>{if(se)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const n=document.createElement("style"),s=A.litNonce;s!==void 0&&n.setAttribute("nonce",s),n.textContent=t.cssText,i.appendChild(n)}},Se=se?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return Re(t)})(i):i;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:
|
|
9
|
+
*/const{is:He,defineProperty:Ve,getOwnPropertyDescriptor:je,getOwnPropertyNames:Qe,getOwnPropertySymbols:Be,getPrototypeOf:Ge}=Object,M=globalThis,ye=M.trustedTypes,Ye=ye?ye.emptyScript:"",oe=M.reactiveElementPolyfillSupport,W=(i,e)=>i,q={toAttribute(i,e){switch(e){case Boolean:i=i?Ye:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},ae=(i,e)=>!He(i,e),we={attribute:!0,type:String,converter:q,reflect:!1,useDefault:!1,hasChanged:ae};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),M.litPropertyMetadata??(M.litPropertyMetadata=new WeakMap);let N=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=we){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),s=this.getPropertyDescriptor(e,n,t);s!==void 0&&Ve(this.prototype,e,s)}}static getPropertyDescriptor(e,t,n){const{get:s,set:r}=je(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){const a=s==null?void 0:s.call(this);r==null||r.call(this,o),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??we}static _$Ei(){if(this.hasOwnProperty(W("elementProperties")))return;const e=Ge(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(W("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(W("properties"))){const t=this.properties,n=[...Qe(t),...Be(t)];for(const s of n)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[n,s]of t)this.elementProperties.set(n,s)}this._$Eh=new Map;for(const[t,n]of this.elementProperties){const s=this._$Eu(t,n);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const s of n)t.unshift(Se(s))}else e!==void 0&&t.push(Se(e));return t}static _$Eu(e,t){const n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return We(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostConnected)==null?void 0:n.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var n;return(n=t.hostDisconnected)==null?void 0:n.call(t)})}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){var r;const n=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,n);if(s!==void 0&&n.reflect===!0){const o=(((r=n.converter)==null?void 0:r.toAttribute)!==void 0?n.converter:q).toAttribute(t,n.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var r,o;const n=this.constructor,s=n._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const a=n.getPropertyOptions(s),d=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:q;this._$Em=s,this[s]=d.fromAttribute(t,a.type)??((o=this._$Ej)==null?void 0:o.get(s))??null,this._$Em=null}}requestUpdate(e,t,n){var s;if(e!==void 0){const r=this.constructor,o=this[e];if(n??(n=r.getPropertyOptions(e)),!((n.hasChanged??ae)(o,t)||n.useDefault&&n.reflect&&o===((s=this._$Ej)==null?void 0:s.get(e))&&!this.hasAttribute(r._$Eu(e,n))))return;this.C(e,t,n)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:s,wrapped:r},o){n&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),r!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var n;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:a}=o,d=this[r];a!==!0||this._$AL.has(r)||d===void 0||this.C(r,void 0,o,d)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(n=this._$EO)==null||n.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(n=>{var s;return(s=n.hostUpdated)==null?void 0:s.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};N.elementStyles=[],N.shadowRootOptions={mode:"open"},N[W("elementProperties")]=new Map,N[W("finalized")]=new Map,oe==null||oe({ReactiveElement:N}),(M.reactiveElementVersions??(M.reactiveElementVersions=[])).push("2.1.0");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const H=globalThis,
|
|
13
|
+
*/const H=globalThis,K=H.trustedTypes,ke=K?K.createPolicy("lit-html",{createHTML:i=>i}):void 0,$e="$lit$",F=`lit$${Math.random().toFixed(9).slice(2)}$`,De="?"+F,qe=`<${De}>`,T=document,V=()=>T.createComment(""),j=i=>i===null||typeof i!="object"&&typeof i!="function",de=Array.isArray,Ke=i=>de(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",le=`[
|
|
14
14
|
\f\r]`,Q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ce=/-->/g,Ee=/>/g,z=RegExp(`>|${le}(?:([^\\s"'>=/]+)(${le}*=${le}*(?:[^
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ae=/'/g,Me=/"/g,
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ae=/'/g,Me=/"/g,Fe=/^(?:script|style|textarea|title)$/i,Je=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),l=Je(1),U=Symbol.for("lit-noChange"),v=Symbol.for("lit-nothing"),Te=new WeakMap,I=T.createTreeWalker(T,129);function ze(i,e){if(!de(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return ke!==void 0?ke.createHTML(e):e}const Xe=(i,e)=>{const t=i.length-1,n=[];let s,r=e===2?"<svg>":e===3?"<math>":"",o=Q;for(let a=0;a<t;a++){const d=i[a];let p,c,u=-1,h=0;for(;h<d.length&&(o.lastIndex=h,c=o.exec(d),c!==null);)h=o.lastIndex,o===Q?c[1]==="!--"?o=Ce:c[1]!==void 0?o=Ee:c[2]!==void 0?(Fe.test(c[2])&&(s=RegExp("</"+c[2],"g")),o=z):c[3]!==void 0&&(o=z):o===z?c[0]===">"?(o=s??Q,u=-1):c[1]===void 0?u=-2:(u=o.lastIndex-c[2].length,p=c[1],o=c[3]===void 0?z:c[3]==='"'?Me:Ae):o===Me||o===Ae?o=z:o===Ce||o===Ee?o=Q:(o=z,s=void 0);const f=o===z&&i[a+1].startsWith("/>")?" ":"";r+=o===Q?d+qe:u>=0?(n.push(p),d.slice(0,u)+$e+d.slice(u)+F+f):d+F+(u===-2?a:f)}return[ze(i,r+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class B{constructor({strings:e,_$litType$:t},n){let s;this.parts=[];let r=0,o=0;const a=e.length-1,d=this.parts,[p,c]=Xe(e,t);if(this.el=B.createElement(p,n),I.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=I.nextNode())!==null&&d.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith($e)){const h=c[o++],f=s.getAttribute(u).split(F),b=/([.?@])?(.*)/.exec(h);d.push({type:1,index:r,name:b[2],strings:f,ctor:b[1]==="."?et:b[1]==="?"?tt:b[1]==="@"?it:J}),s.removeAttribute(u)}else u.startsWith(F)&&(d.push({type:6,index:r}),s.removeAttribute(u));if(Fe.test(s.tagName)){const u=s.textContent.split(F),h=u.length-1;if(h>0){s.textContent=K?K.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],V()),I.nextNode(),d.push({type:2,index:++r});s.append(u[h],V())}}}else if(s.nodeType===8)if(s.data===De)d.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(F,u+1))!==-1;)d.push({type:7,index:r}),u+=F.length-1}r++}}static createElement(e,t){const n=T.createElement("template");return n.innerHTML=e,n}}function O(i,e,t=i,n){var o,a;if(e===U)return e;let s=n!==void 0?(o=t._$Co)==null?void 0:o[n]:t._$Cl;const r=j(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(i),s._$AT(i,t,n)),n!==void 0?(t._$Co??(t._$Co=[]))[n]=s:t._$Cl=s),s!==void 0&&(e=O(i,s._$AS(i,e.values),s,n)),e}class Ze{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:n}=this._$AD,s=((e==null?void 0:e.creationScope)??T).importNode(t,!0);I.currentNode=s;let r=I.nextNode(),o=0,a=0,d=n[0];for(;d!==void 0;){if(o===d.index){let p;d.type===2?p=new G(r,r.nextSibling,this,e):d.type===1?p=new d.ctor(r,d.name,d.strings,this,e):d.type===6&&(p=new nt(r,this,e)),this._$AV.push(p),d=n[++a]}o!==(d==null?void 0:d.index)&&(r=I.nextNode(),o++)}return I.currentNode=T,s}p(e){let t=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class G{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,n,s){this.type=2,this._$AH=v,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=O(this,e,t),j(e)?e===v||e==null||e===""?(this._$AH!==v&&this._$AR(),this._$AH=v):e!==this._$AH&&e!==U&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ke(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==v&&j(this._$AH)?this._$AA.nextSibling.data=e:this.T(T.createTextNode(e)),this._$AH=e}$(e){var r;const{values:t,_$litType$:n}=e,s=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=B.createElement(ze(n.h,n.h[0]),this.options)),n);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{const o=new Ze(s,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Te.get(e.strings);return t===void 0&&Te.set(e.strings,t=new B(e)),t}k(e){de(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,s=0;for(const r of e)s===t.length?t.push(n=new G(this.O(V()),this.O(V()),this,this.options)):n=t[s],n._$AI(r),s++;s<t.length&&(this._$AR(n&&n._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,t);e&&e!==this._$AB;){const s=e.nextSibling;e.remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class J{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,s,r){this.type=1,this._$AH=v,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=v}_$AI(e,t=this,n,s){const r=this.strings;let o=!1;if(r===void 0)e=O(this,e,t,0),o=!j(e)||e!==this._$AH&&e!==U,o&&(this._$AH=e);else{const a=e;let d,p;for(e=r[0],d=0;d<r.length-1;d++)p=O(this,a[n+d],t,d),p===U&&(p=this._$AH[d]),o||(o=!j(p)||p!==this._$AH[d]),p===v?e=v:e!==v&&(e+=(p??"")+r[d+1]),this._$AH[d]=p}o&&!s&&this.j(e)}j(e){e===v?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class et extends J{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===v?void 0:e}}class tt extends J{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==v)}}class it extends J{constructor(e,t,n,s,r){super(e,t,n,s,r),this.type=5}_$AI(e,t=this){if((e=O(this,e,t,0)??v)===U)return;const n=this._$AH,s=e===v&&n!==v||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,r=e!==v&&(n===v||s);s&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class nt{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){O(this,e)}}const pe=H.litHtmlPolyfillSupport;pe==null||pe(B,G),(H.litHtmlVersions??(H.litHtmlVersions=[])).push("3.3.0");const st=(i,e,t)=>{const n=(t==null?void 0:t.renderBefore)??e;let s=n._$litPart$;if(s===void 0){const r=(t==null?void 0:t.renderBefore)??null;n._$litPart$=s=new G(e.insertBefore(V(),r),r,void 0,t??{})}return s._$AI(i),s};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/const P=globalThis;let R=class extends N{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=
|
|
19
|
+
*/const P=globalThis;let R=class extends N{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=st(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return U}};R._$litElement$=!0,R.finalized=!0,(Oe=P.litElementHydrateSupport)==null||Oe.call(P,{LitElement:R});const ce=P.litElementPolyfillSupport;ce==null||ce({LitElement:R}),(P.litElementVersions??(P.litElementVersions=[])).push("4.2.0");/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const
|
|
23
|
+
*/const Ue=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/const
|
|
27
|
+
*/const rt={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:ae},ot=(i=rt,e,t)=>{const{kind:n,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),n==="setter"&&((i=Object.create(i)).wrapped=!0),r.set(t.name,i),n==="accessor"){const{name:o}=t;return{set(a){const d=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,d,i)},init(a){return a!==void 0&&this.C(o,void 0,i,a),a}}}if(n==="setter"){const{name:o}=t;return function(a){const d=this[o];e.call(this,a),this.requestUpdate(o,d,i)}}throw Error("Unsupported decorator location: "+n)};function C(i){return(e,t)=>typeof t=="object"?ot(i,e,t):((n,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,n),o?Object.getOwnPropertyDescriptor(s,r):void 0})(i,e,t)}/**
|
|
28
28
|
* @license
|
|
29
29
|
* Copyright 2017 Google LLC
|
|
30
30
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
-
*/function _(i){return C({...i,state:!0,attribute:!1})}const
|
|
31
|
+
*/function _(i){return C({...i,state:!0,attribute:!1})}const S=[];for(let i=0;i<256;++i)S.push((i+256).toString(16).slice(1));function at(i,e=0){return(S[i[e+0]]+S[i[e+1]]+S[i[e+2]]+S[i[e+3]]+"-"+S[i[e+4]]+S[i[e+5]]+"-"+S[i[e+6]]+S[i[e+7]]+"-"+S[i[e+8]]+S[i[e+9]]+"-"+S[i[e+10]]+S[i[e+11]]+S[i[e+12]]+S[i[e+13]]+S[i[e+14]]+S[i[e+15]]).toLowerCase()}let ue;const dt=new Uint8Array(16);function lt(){if(!ue){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ue=crypto.getRandomValues.bind(crypto)}return ue(dt)}const Ie={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function he(i,e,t){var s;if(Ie.randomUUID&&!i)return Ie.randomUUID();i=i||{};const n=i.random??((s=i.rng)==null?void 0:s.call(i))??lt();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,at(n)}const pt=L`
|
|
32
32
|
:host {
|
|
33
33
|
display: block;
|
|
34
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
35
|
-
sans-serif;
|
|
34
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
36
35
|
background-color: #f9fafb; /* Lighter gray background */
|
|
37
36
|
border-radius: 8px;
|
|
38
37
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
@@ -101,7 +100,7 @@
|
|
|
101
100
|
padding: 0;
|
|
102
101
|
background-color: #f9fafb; /* Lighter gray background continues */
|
|
103
102
|
}
|
|
104
|
-
`,
|
|
103
|
+
`,ct=L`
|
|
105
104
|
.form-group {
|
|
106
105
|
display: flex;
|
|
107
106
|
flex-direction: column;
|
|
@@ -296,7 +295,7 @@
|
|
|
296
295
|
border-color: #3b82f6;
|
|
297
296
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
298
297
|
}
|
|
299
|
-
`,
|
|
298
|
+
`,ut=L`
|
|
300
299
|
/* Steps and Questions Sections */
|
|
301
300
|
.section {
|
|
302
301
|
padding: 16px;
|
|
@@ -758,7 +757,8 @@
|
|
|
758
757
|
background: white;
|
|
759
758
|
border-radius: 8px;
|
|
760
759
|
padding: 24px 48px;
|
|
761
|
-
box-shadow:
|
|
760
|
+
box-shadow:
|
|
761
|
+
0 1px 3px 0 rgba(0, 0, 0, 0.1),
|
|
762
762
|
0 1px 2px -1px rgba(0, 0, 0, 0.1);
|
|
763
763
|
display: flex;
|
|
764
764
|
flex-direction: row;
|
|
@@ -834,7 +834,9 @@
|
|
|
834
834
|
margin-bottom: 0;
|
|
835
835
|
cursor: pointer;
|
|
836
836
|
border: 2px solid transparent;
|
|
837
|
-
transition:
|
|
837
|
+
transition:
|
|
838
|
+
border 0.2s,
|
|
839
|
+
box-shadow 0.2s;
|
|
838
840
|
gap: 12px;
|
|
839
841
|
}
|
|
840
842
|
.runner-step-item.active {
|
|
@@ -1640,7 +1642,9 @@
|
|
|
1640
1642
|
background: #fff;
|
|
1641
1643
|
border-radius: 16px;
|
|
1642
1644
|
padding: 48px 40px;
|
|
1643
|
-
box-shadow:
|
|
1645
|
+
box-shadow:
|
|
1646
|
+
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
1647
|
+
0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
1644
1648
|
}
|
|
1645
1649
|
|
|
1646
1650
|
.not-assigned-icon {
|
|
@@ -1821,8 +1825,7 @@
|
|
|
1821
1825
|
background: #fff;
|
|
1822
1826
|
padding: 40px;
|
|
1823
1827
|
box-sizing: border-box;
|
|
1824
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
1825
|
-
sans-serif;
|
|
1828
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1826
1829
|
}
|
|
1827
1830
|
|
|
1828
1831
|
.print-step {
|
|
@@ -1964,8 +1967,7 @@
|
|
|
1964
1967
|
color: #fff;
|
|
1965
1968
|
}
|
|
1966
1969
|
|
|
1967
|
-
.runner-mobile-step-tab:not(.active):not(.completed)
|
|
1968
|
-
.runner-mobile-step-badge {
|
|
1970
|
+
.runner-mobile-step-tab:not(.active):not(.completed) .runner-mobile-step-badge {
|
|
1969
1971
|
background: rgba(0, 0, 0, 0.1);
|
|
1970
1972
|
color: inherit;
|
|
1971
1973
|
}
|
|
@@ -2352,7 +2354,7 @@
|
|
|
2352
2354
|
margin: 2px 0;
|
|
2353
2355
|
line-height: 1.4;
|
|
2354
2356
|
}
|
|
2355
|
-
`,
|
|
2357
|
+
`,ht=L`
|
|
2356
2358
|
/* Modal Styles */
|
|
2357
2359
|
.modal-overlay {
|
|
2358
2360
|
position: fixed;
|
|
@@ -2489,27 +2491,7 @@
|
|
|
2489
2491
|
.modal-create-button:hover {
|
|
2490
2492
|
background-color: #2563eb;
|
|
2491
2493
|
}
|
|
2492
|
-
`;var
|
|
2493
|
-
|
|
2494
|
-
After completing this form, you'll receive:
|
|
2495
|
-
|
|
2496
|
-
* **Welcome email** with your login credentials
|
|
2497
|
-
* **Schedule** for your orientation meeting
|
|
2498
|
-
* **Access** to company resources
|
|
2499
|
-
|
|
2500
|
-
### Important Notes
|
|
2501
|
-
|
|
2502
|
-
Please ensure all information is *accurate* before proceeding. If you need to make changes later, contact your HR representative.
|
|
2503
|
-
|
|
2504
|
-
### What to Expect
|
|
2505
|
-
|
|
2506
|
-
1. **Immediate**: Confirmation email
|
|
2507
|
-
2. **Within 24 hours**: Welcome package
|
|
2508
|
-
3. **This week**: Orientation meeting
|
|
2509
|
-
|
|
2510
|
-
> **Pro tip**: Save this information for future reference!
|
|
2511
|
-
|
|
2512
|
-
You can use \`code snippets\` like this for technical details.`,order:5}],status:"pending"},{id:"step-2",title:"Department Setup",description:"",order:2,assignment:{category:"individual",type:"instance_assignee_select"},elements:[{id:"c4",type:"text",content:"Now let's set up your department and role information. This will help us assign you to the right teams and provide appropriate access.",order:1},{id:"q3",type:"select",label:"Department",order:2,required:!0,options:["Engineering","Sales","Marketing","HR"]},{id:"q4",type:"text_input",label:"Role/Title",order:3,required:!0},{id:"c5",type:"divider",content:"",order:4},{id:"c6",type:"html",content:"<div style='background: #f0f9ff; padding: 16px; border-radius: 8px; border-left: 4px solid #3b82f6;'><strong>Note:</strong> Your department assignment will determine your initial access permissions and team assignments. You can request changes through your manager after onboarding.</div>",order:5}],status:"pending"},{id:"step-3",title:"Feedback",description:"Any initial comments?",order:3,assignment:{category:"individual",type:"subject"},elements:[{id:"c7",type:"text",content:"We'd love to hear your feedback about the onboarding process. Your input helps us improve the experience for future team members.",order:1},{id:"q5",type:"textarea",label:"Comments",order:2,required:!1},{id:"c8",type:"image",content:"",url:"https://example.com/onboarding-complete.jpg",alt:"Onboarding Complete",caption:"Congratulations on completing your onboarding!",order:3}],status:"pending"}]},{id:"wf-2",name:"IT Asset Request",description:"Request new hardware or software.",steps:[{id:"s1",title:"Request Details",order:1,assignment:{category:"individual",type:"subject"},elements:[{id:"itq1",type:"select",label:"Asset Type",order:1,required:!1,options:["Laptop","Monitor","Software License"]}],status:"pending"},{id:"s2",title:"Justification",order:2,assignment:{category:"role",type:"instance_role_assignee_select",targetId:"manager"},elements:[{id:"itq2",type:"textarea",label:"Reason",order:1,required:!0}],status:"pending"}]}];JSON.parse(JSON.stringify(Le[0].steps)),JSON.parse(JSON.stringify(Le[1].steps));let w=class extends R{constructor(){super(...arguments),this._templateData={name:"",description:"",steps:[]},this._showStepModal=!1,this._stepFormData={title:"",description:""},this._draggedStepId=null,this._dragOverStepId=null,this._selectedStepId=null,this._questions=[]}connectedCallback(){super.connectedCallback(),this._templateData=this._getDefaultWorkflowData()}_getDefaultWorkflowData(){const i={id:"step-1",title:"Step 1",description:"",order:1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};return{id:he(),name:"",description:"",steps:[i]}}_handleTitleChange(i){const e=i.target;this._templateData={...this._templateData,name:e.value}}_handleDescriptionChange(i){const e=i.target;this._templateData={...this._templateData,description:e.value}}_handleCancel(){var i;console.log("🚫 Builder Widget: Cancel button clicked"),(i=this.onCancel)==null||i.call(this)}_handleSave(){var i,e;if((i=this._templateData.name)!=null&&i.trim()){const t={id:this._templateData.id||he(),name:this._templateData.name,description:this._templateData.description||"",steps:this._templateData.steps||[]};console.log("💾 Builder Widget: Save button clicked"),console.log("📄 Workflow Template:",JSON.stringify(t,null,2)),console.log("🔄 Calling onSave callback with workflow template"),(e=this.onSave)==null||e.call(this,t)}else console.log("⚠️ Builder Widget: Save attempted but no title provided")}_addStep(){console.log("🔹 Opening step creation modal"),this._stepFormData={title:"",description:""},this._showStepModal=!0}_closeStepModal(){console.log("🔹 Closing step creation modal"),this._showStepModal=!1,this._stepFormData={title:"",description:""}}_handleStepFormInput(i){const e=i.target,{name:t,value:n}=e;this._stepFormData={...this._stepFormData,[t]:n}}_createStep(){var t,n;if(!((t=this._stepFormData.title)!=null&&t.trim())){console.log("⚠️ Step title is required");return}const i=this._templateData.steps||[],e={id:he(),title:this._stepFormData.title.trim(),description:((n=this._stepFormData.description)==null?void 0:n.trim())||"",order:i.length+1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};this._templateData={...this._templateData,steps:[...i,e]},this._selectedStepId=e.id,console.log("✅ Step created and selected:",e),this._closeStepModal()}_selectStep(i){this._selectedStepId=i,console.log("🎯 Step selected:",i)}_getSelectedStep(){return!this._selectedStepId||!this._templateData.steps?null:this._templateData.steps.find(i=>i.id===this._selectedStepId)||null}_handleDragStart(i,e){this._draggedStepId=e,i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",e)),console.log("🔄 Drag started for step:",e)}_handleDragEnd(i){this._draggedStepId=null,this._dragOverStepId=null,console.log("🔄 Drag ended")}_handleDragOver(i,e){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move"),this._dragOverStepId!==e&&(this._dragOverStepId=e)}_handleDragLeave(i){const e=i.relatedTarget;i.currentTarget.contains(e)||(this._dragOverStepId=null)}_handleDrop(i,e){if(i.preventDefault(),!this._draggedStepId||this._draggedStepId===e){this._draggedStepId=null,this._dragOverStepId=null;return}const t=this._templateData.steps||[],n=t.findIndex(a=>a.id===this._draggedStepId),s=t.findIndex(a=>a.id===e);if(n===-1||s===-1){console.error("Could not find step indices for reordering");return}console.log("🔄 Before reorder:",t.map((a,d)=>`${d+1}: ${a.title}`));const r=[...t],[o]=r.splice(n,1);r.splice(s,0,o),r.forEach((a,d)=>{a.order=d+1}),console.log("🔄 After reorder:",r.map((a,d)=>`${d+1}: ${a.title}`)),this._templateData={...this._templateData,steps:r},console.log("📝 Template updated with new step order"),this._draggedStepId=null,this._dragOverStepId=null}_addQuestion(i="text_input"){var n,s;if(!this._templateData.steps||this._templateData.steps.length===0||!this._selectedStepId){console.log("⚠️ Cannot add questions without steps or selected step");return}const e=this._getSelectedStep();if(!e){console.log("⚠️ No step selected");return}if(["text","html","divider","markdown"].includes(i)){let r={id:`c-${Date.now()}`,type:i,order:(((n=e.elements)==null?void 0:n.length)||0)+1};switch(i){case"text":r.content="Enter your text content here...";break;case"html":r.content="<p>Enter your HTML content here...</p>";break;case"divider":r.content="",r.caption="Section Divider";break;case"markdown":r.content=`## Enter your markdown content here...
|
|
2494
|
+
`;var gt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,E=(i,e,t,n)=>{for(var s=n>1?void 0:n?ft(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&>(e,t,s),s};let w=class extends R{constructor(){super(...arguments),this._templateData={name:"",description:"",steps:[]},this._showStepModal=!1,this._stepFormData={title:"",description:""},this._draggedStepId=null,this._dragOverStepId=null,this._selectedStepId=null,this._questions=[]}connectedCallback(){super.connectedCallback(),this._templateData=this._getDefaultWorkflowData()}_getDefaultWorkflowData(){const i={id:"step-1",title:"Step 1",description:"",order:1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};return{id:he(),name:"",description:"",steps:[i]}}_handleTitleChange(i){const e=i.target;this._templateData={...this._templateData,name:e.value}}_handleDescriptionChange(i){const e=i.target;this._templateData={...this._templateData,description:e.value}}_handleCancel(){var i;console.log("🚫 Builder Widget: Cancel button clicked"),(i=this.onCancel)==null||i.call(this)}_handleSave(){var i,e;if((i=this._templateData.name)!=null&&i.trim()){const t={id:this._templateData.id||he(),name:this._templateData.name,description:this._templateData.description||"",steps:this._templateData.steps||[]};console.log("💾 Builder Widget: Save button clicked"),console.log("📄 Workflow Template:",JSON.stringify(t,null,2)),console.log("🔄 Calling onWorkflow updated callback with workflow template"),(e=this.onWorkflowUpdated)==null||e.call(this,t)}else console.log("⚠️ Builder Widget: Save attempted but no title provided")}_addStep(){console.log("🔹 Opening step creation modal"),this._stepFormData={title:"",description:""},this._showStepModal=!0}_closeStepModal(){console.log("🔹 Closing step creation modal"),this._showStepModal=!1,this._stepFormData={title:"",description:""}}_handleStepFormInput(i){const e=i.target,{name:t,value:n}=e;this._stepFormData={...this._stepFormData,[t]:n}}_createStep(){var t,n;if(!((t=this._stepFormData.title)!=null&&t.trim())){console.log("⚠️ Step title is required");return}const i=this._templateData.steps||[],e={id:he(),title:this._stepFormData.title.trim(),description:((n=this._stepFormData.description)==null?void 0:n.trim())||"",order:i.length+1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};this._templateData={...this._templateData,steps:[...i,e]},this._selectedStepId=e.id,console.log("✅ Step created and selected:",e),this._closeStepModal()}_selectStep(i){this._selectedStepId=i,console.log("🎯 Step selected:",i)}_getSelectedStep(){return!this._selectedStepId||!this._templateData.steps?null:this._templateData.steps.find(i=>i.id===this._selectedStepId)||null}_handleDragStart(i,e){this._draggedStepId=e,i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",e)),console.log("🔄 Drag started for step:",e)}_handleDragEnd(i){this._draggedStepId=null,this._dragOverStepId=null,console.log("🔄 Drag ended")}_handleDragOver(i,e){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move"),this._dragOverStepId!==e&&(this._dragOverStepId=e)}_handleDragLeave(i){const e=i.relatedTarget;i.currentTarget.contains(e)||(this._dragOverStepId=null)}_handleDrop(i,e){if(i.preventDefault(),!this._draggedStepId||this._draggedStepId===e){this._draggedStepId=null,this._dragOverStepId=null;return}const t=this._templateData.steps||[],n=t.findIndex(a=>a.id===this._draggedStepId),s=t.findIndex(a=>a.id===e);if(n===-1||s===-1){console.error("Could not find step indices for reordering");return}console.log("🔄 Before reorder:",t.map((a,d)=>`${d+1}: ${a.title}`));const r=[...t],[o]=r.splice(n,1);r.splice(s,0,o),r.forEach((a,d)=>{a.order=d+1}),console.log("🔄 After reorder:",r.map((a,d)=>`${d+1}: ${a.title}`)),this._templateData={...this._templateData,steps:r},console.log("📝 Template updated with new step order"),this._draggedStepId=null,this._dragOverStepId=null}_addQuestion(i="text_input"){var n,s;if(!this._templateData.steps||this._templateData.steps.length===0||!this._selectedStepId){console.log("⚠️ Cannot add questions without steps or selected step");return}const e=this._getSelectedStep();if(!e){console.log("⚠️ No step selected");return}if(["text","html","divider","markdown"].includes(i)){let r={id:`c-${Date.now()}`,type:i,order:(((n=e.elements)==null?void 0:n.length)||0)+1};switch(i){case"text":r.content="Enter your text content here...";break;case"html":r.content="<p>Enter your HTML content here...</p>";break;case"divider":r.content="",r.caption="Section Divider";break;case"markdown":r.content=`## Enter your markdown content here...
|
|
2513
2495
|
|
|
2514
2496
|
Use **bold** and *italic* text.`;break}const o=this._templateData.steps.map(a=>a.id===this._selectedStepId?{...a,elements:[...a.elements||[],r]}:a);this._templateData={...this._templateData,steps:o},console.log("✅ Content element added to step:",this._selectedStepId)}else{const r={id:`q-${Date.now()}`,type:i,label:this._getQuestionTypeDisplayName(i),order:(((s=e.elements)==null?void 0:s.length)||0)+1,required:!1};["select","radio","checkbox"].includes(i)&&(r.options=["Option 1","Option 2"]);const o=this._templateData.steps.map(a=>a.id===this._selectedStepId?{...a,elements:[...a.elements||[],r]}:a);this._templateData={...this._templateData,steps:o},console.log("✅ Question added to step:",this._selectedStepId)}}_addContentElement(i){var s;if(!this._templateData.steps||this._templateData.steps.length===0||!this._selectedStepId){console.log("⚠️ Cannot add content without steps or selected step");return}const e=this._getSelectedStep();if(!e){console.log("⚠️ No step selected");return}let t={id:`c-${Date.now()}`,type:i,order:(((s=e.elements)==null?void 0:s.length)||0)+1};switch(i){case"text":t.content="Enter your text content here...";break;case"html":t.content="<p>Enter your HTML content here...</p>";break;case"image":t.content="",t.url="",t.alt="",t.caption="";break;case"video":t.content="",t.url="",t.caption="";break;case"file":t.content="",t.url="",t.caption="";break;case"divider":t.content="",t.caption="Section Divider";break;case"markdown":t.content=`## Enter your markdown content here...
|
|
2515
2497
|
|
|
@@ -2601,8 +2583,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2601
2583
|
`:l`
|
|
2602
2584
|
<div class="single-checkbox-info">
|
|
2603
2585
|
<p class="config-note">
|
|
2604
|
-
Single checkbox - users can check/uncheck for Yes/No
|
|
2605
|
-
response
|
|
2586
|
+
Single checkbox - users can check/uncheck for Yes/No response
|
|
2606
2587
|
</p>
|
|
2607
2588
|
</div>
|
|
2608
2589
|
`}
|
|
@@ -2648,15 +2629,11 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2648
2629
|
</div>
|
|
2649
2630
|
`;case"file_upload":return l`
|
|
2650
2631
|
<div class="question-config-section">
|
|
2651
|
-
<p class="config-note">
|
|
2652
|
-
File upload field - users can upload files
|
|
2653
|
-
</p>
|
|
2632
|
+
<p class="config-note">File upload field - users can upload files</p>
|
|
2654
2633
|
</div>
|
|
2655
2634
|
`;case"signature":return l`
|
|
2656
2635
|
<div class="question-config-section">
|
|
2657
|
-
<p class="config-note">
|
|
2658
|
-
Digital signature pad - users can sign with mouse/touch
|
|
2659
|
-
</p>
|
|
2636
|
+
<p class="config-note">Digital signature pad - users can sign with mouse/touch</p>
|
|
2660
2637
|
</div>
|
|
2661
2638
|
`;case"date":return l`
|
|
2662
2639
|
<div class="question-config-section">
|
|
@@ -2790,7 +2767,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2790
2767
|
></textarea>
|
|
2791
2768
|
</label>
|
|
2792
2769
|
</div>
|
|
2793
|
-
`;default:return l``}}_getQuestionTypeDisplayName(i){switch(i){case"text_input":return"Text Input";case"textarea":return"Long Text";case"select":return"Select";case"radio":return"Radio";case"checkbox":return"Checkbox";case"number":return"Number";case"date":return"Date";case"file_upload":return"File Upload";case"signature":return"Signature";default:return"Question"}}_getContentTypeDisplayName(i){switch(i){case"text":return"Text";case"html":return"HTML";case"image":return"Image";case"video":return"Video";case"file":return"File";case"divider":return"Divider";case"markdown":return"Markdown";default:return"Content"}}_getCheckboxTypeDisplayName(i){return i.options&&i.options.length>0?"Checkbox Group":"Single Checkbox"}_hasSteps(){const i=!!(this._templateData.steps&&this._templateData.steps.length>0);return i&&!this._selectedStepId&&this._templateData.steps&&(this._selectedStepId=this._templateData.steps[0].id,console.log("🎯 Auto-selected first step:",this._templateData.steps[0].title)),!i&&this._selectedStepId&&(this._selectedStepId=null),i}_getAssignmentDisplayText(i){switch(i.category){case"individual":switch(i.type){case"subject":return"Assigned to: Subject";case"creator":return"Assigned to: Creator";case"instance_assignee_select":return"Assigned to: To be selected";case"specific_user":return i.email?`Assigned to: ${i.email}`:"Assigned to: Specific user";default:return"Assigned to: Individual"}case"role":switch(i.type){case"instance_role_assignee_select":return i.targetId?`Assigned to: ${i.targetId} role`:"Assigned to: Role";default:return"Assigned to: Role"}default:return"Assignment not configured"}}render(){
|
|
2770
|
+
`;default:return l``}}_getQuestionTypeDisplayName(i){switch(i){case"text_input":return"Text Input";case"textarea":return"Long Text";case"select":return"Select";case"radio":return"Radio";case"checkbox":return"Checkbox";case"number":return"Number";case"date":return"Date";case"file_upload":return"File Upload";case"signature":return"Signature";default:return"Question"}}_getContentTypeDisplayName(i){switch(i){case"text":return"Text";case"html":return"HTML";case"image":return"Image";case"video":return"Video";case"file":return"File";case"divider":return"Divider";case"markdown":return"Markdown";default:return"Content"}}_getCheckboxTypeDisplayName(i){return i.options&&i.options.length>0?"Checkbox Group":"Single Checkbox"}_hasSteps(){const i=!!(this._templateData.steps&&this._templateData.steps.length>0);return i&&!this._selectedStepId&&this._templateData.steps&&(this._selectedStepId=this._templateData.steps[0].id,console.log("🎯 Auto-selected first step:",this._templateData.steps[0].title)),!i&&this._selectedStepId&&(this._selectedStepId=null),i}_getAssignmentDisplayText(i){switch(i.category){case"individual":switch(i.type){case"subject":return"Assigned to: Subject";case"creator":return"Assigned to: Creator";case"instance_assignee_select":return"Assigned to: To be selected";case"specific_user":return i.email?`Assigned to: ${i.email}`:"Assigned to: Specific user";default:return"Assigned to: Individual"}case"role":switch(i.type){case"instance_role_assignee_select":return i.targetId?`Assigned to: ${i.targetId} role`:"Assigned to: Role";default:return"Assigned to: Role"}default:return"Assignment not configured"}}render(){const i=this._getSelectedStep();return l`
|
|
2794
2771
|
<div class="header">
|
|
2795
2772
|
<div class="header-inputs">
|
|
2796
2773
|
<div class="form-group">
|
|
@@ -2815,9 +2792,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2815
2792
|
</div>
|
|
2816
2793
|
</div>
|
|
2817
2794
|
<div class="header-actions">
|
|
2818
|
-
<button class="save-button" @click=${this._handleSave}>
|
|
2819
|
-
Save template
|
|
2820
|
-
</button>
|
|
2795
|
+
<button class="save-button" @click=${this._handleSave}>Save template</button>
|
|
2821
2796
|
</div>
|
|
2822
2797
|
</div>
|
|
2823
2798
|
|
|
@@ -2832,10 +2807,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2832
2807
|
</div>
|
|
2833
2808
|
|
|
2834
2809
|
<div class="steps-list">
|
|
2835
|
-
<div
|
|
2836
|
-
class="step-item selected"
|
|
2837
|
-
@click=${()=>this._selectStep("step-1")}
|
|
2838
|
-
>
|
|
2810
|
+
<div class="step-item selected" @click=${()=>this._selectStep("step-1")}>
|
|
2839
2811
|
<div class="step-handle">⋮⋮</div>
|
|
2840
2812
|
<div class="step-content">
|
|
2841
2813
|
<strong>Step 1</strong>
|
|
@@ -2851,9 +2823,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2851
2823
|
<div class="section">
|
|
2852
2824
|
<div class="section-header">
|
|
2853
2825
|
<h2>Questions</h2>
|
|
2854
|
-
<button class="add-button" @click=${()=>this._addQuestion()}>
|
|
2855
|
-
Add
|
|
2856
|
-
</button>
|
|
2826
|
+
<button class="add-button" @click=${()=>this._addQuestion()}>Add</button>
|
|
2857
2827
|
</div>
|
|
2858
2828
|
|
|
2859
2829
|
${i&&i.elements&&i.elements.length>0?l`
|
|
@@ -2872,18 +2842,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2872
2842
|
@change=${r=>{const a=r.target.value;if(["text","html","divider","markdown"].includes(a)){this._addQuestion(a),this._deleteQuestion(s.id);return}const p={type:a};["select","radio","checkbox"].includes(a)&&!s.options&&(p.options=["Option 1","Option 2"]);const c=this._getQuestionTypeDisplayName(s.type);(!s.label||s.label===c)&&(p.label=this._getQuestionTypeDisplayName(a)),this._updateQuestion(s.id,p)}}
|
|
2873
2843
|
>
|
|
2874
2844
|
<optgroup label="Questions">
|
|
2875
|
-
<option value="text_input">
|
|
2876
|
-
|
|
2877
|
-
</option>
|
|
2878
|
-
<option value="textarea">
|
|
2879
|
-
Text Input (long)
|
|
2880
|
-
</option>
|
|
2845
|
+
<option value="text_input">Text Input (short)</option>
|
|
2846
|
+
<option value="textarea">Text Input (long)</option>
|
|
2881
2847
|
<option value="select">Select</option>
|
|
2882
2848
|
<option value="radio">Radio</option>
|
|
2883
2849
|
<option value="checkbox">Checkbox</option>
|
|
2884
|
-
<option value="file_upload">
|
|
2885
|
-
File Upload
|
|
2886
|
-
</option>
|
|
2850
|
+
<option value="file_upload">File Upload</option>
|
|
2887
2851
|
<option value="signature">Signature</option>
|
|
2888
2852
|
<option value="number">Number</option>
|
|
2889
2853
|
<option value="date">Date</option>
|
|
@@ -2938,18 +2902,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2938
2902
|
@change=${r=>{const a=r.target.value;if(!["text","html","divider","markdown"].includes(a)){this._addQuestion(a),this._deleteQuestion(e.id);return}this._addQuestion(a),this._deleteQuestion(e.id)}}
|
|
2939
2903
|
>
|
|
2940
2904
|
<optgroup label="Questions">
|
|
2941
|
-
<option value="text_input">
|
|
2942
|
-
|
|
2943
|
-
</option>
|
|
2944
|
-
<option value="textarea">
|
|
2945
|
-
Text Input (long)
|
|
2946
|
-
</option>
|
|
2905
|
+
<option value="text_input">Text Input (short)</option>
|
|
2906
|
+
<option value="textarea">Text Input (long)</option>
|
|
2947
2907
|
<option value="select">Select</option>
|
|
2948
2908
|
<option value="radio">Radio</option>
|
|
2949
2909
|
<option value="checkbox">Checkbox</option>
|
|
2950
|
-
<option value="file_upload">
|
|
2951
|
-
File Upload
|
|
2952
|
-
</option>
|
|
2910
|
+
<option value="file_upload">File Upload</option>
|
|
2953
2911
|
<option value="signature">Signature</option>
|
|
2954
2912
|
<option value="number">Number</option>
|
|
2955
2913
|
<option value="date">Date</option>
|
|
@@ -2995,24 +2953,22 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
2995
2953
|
<div class="empty-state">
|
|
2996
2954
|
<h3>Add questions</h3>
|
|
2997
2955
|
<p>Use the add button to start building your workflow</p>
|
|
2998
|
-
<button class="add-button" @click=${()=>this._addQuestion()}>
|
|
2999
|
-
Add
|
|
3000
|
-
</button>
|
|
2956
|
+
<button class="add-button" @click=${()=>this._addQuestion()}>Add</button>
|
|
3001
2957
|
</div>
|
|
3002
2958
|
`}
|
|
3003
2959
|
</div>
|
|
3004
2960
|
</div>
|
|
3005
2961
|
</div>
|
|
3006
2962
|
`}};w.styles=L`
|
|
2963
|
+
${pt}
|
|
3007
2964
|
${ct}
|
|
3008
2965
|
${ut}
|
|
3009
|
-
${ht}
|
|
3010
2966
|
${Pe}
|
|
3011
|
-
${
|
|
3012
|
-
`,E([_()],w.prototype,"_templateData",2),E([_()],w.prototype,"_showStepModal",2),E([_()],w.prototype,"_stepFormData",2),E([_()],w.prototype,"_draggedStepId",2),E([_()],w.prototype,"_dragOverStepId",2),E([_()],w.prototype,"_selectedStepId",2),E([_()],w.prototype,"_questions",2),E([C({attribute:!1})],w.prototype,"onCancel",2),E([C({attribute:!1})],w.prototype,"onSave",2),w=E([
|
|
2967
|
+
${ht}
|
|
2968
|
+
`,E([_()],w.prototype,"_templateData",2),E([_()],w.prototype,"_showStepModal",2),E([_()],w.prototype,"_stepFormData",2),E([_()],w.prototype,"_draggedStepId",2),E([_()],w.prototype,"_dragOverStepId",2),E([_()],w.prototype,"_selectedStepId",2),E([_()],w.prototype,"_questions",2),E([C({attribute:!1})],w.prototype,"onCancel",2),E([C({attribute:!1})],w.prototype,"onSave",2),w=E([Ue("builder-widget")],w);class mt{constructor(e,t){this.signaturePads=e,this.savedSignatures=t}validateStep(e,t,n){if(n==="preview")return{isValid:!0,errors:{}};if(!e)return{isValid:!1,errors:{}};let s=!0;const r={};for(const o of e.elements)if(this.isQuestionElement(o)){const a=o;if(a.required){const d=this.validateQuestion(a,t[a.id]);d&&(s=!1,r[a.id]=d.message)}}return{isValid:s,errors:r}}validateQuestion(e,t){switch(e.type){case"checkbox":return this.validateCheckbox(e,t);case"signature":return this.validateSignature(e,t);case"file_upload":return this.validateFileUpload(e,t);default:return this.validateBasicField(e,t)}}validateCheckbox(e,t){if(e.options&&e.options.length>0){if(!Array.isArray(t)||t.length===0)return{questionId:e.id,message:`${e.label} is required.`}}else if(t!==!0)return{questionId:e.id,message:`${e.label} is required.`};return null}validateSignature(e,t){const n=this.signaturePads.get(e.id);return!n||n.isEmpty()?{questionId:e.id,message:`${e.label} is required.`}:this.savedSignatures.has(e.id)?null:{questionId:e.id,message:`Please save your ${e.label} before continuing.`}}validateFileUpload(e,t){return!t||t===null||t===void 0?{questionId:e.id,message:`${e.label} is required.`}:null}validateBasicField(e,t){return t==null||t===""?{questionId:e.id,message:`${e.label} is required.`}:null}isQuestionElement(e){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(e.type)}}class bt{getStorageKey(e){return`runner-form-data-${e||"default"}`}saveFormData(e,t,n,s,r,o){var c,u,h;const a=this.getStorageKey(e),d=o?{...o,currentStepId:(u=(c=o.steps)==null?void 0:c[n])==null?void 0:u.id,completedSteps:Array.from(r),updatedAt:new Date,steps:(h=o.steps)==null?void 0:h.map(f=>({...f,responses:f.responses||[]}))}:null,p={formData:t,timestamp:new Date().toISOString(),stepIndex:n,savedSignatures:Array.from(s),completedSteps:Array.from(r),instance:d};try{localStorage.setItem(a,JSON.stringify(p))}catch(f){console.warn("Failed to save form data to localStorage:",f)}}restoreFormData(e){const t=this.getStorageKey(e);try{const n=localStorage.getItem(t);if(!n)return null;const s=JSON.parse(n);return{formData:s.formData||{},stepIndex:s.stepIndex||0,savedSignatures:new Set(s.savedSignatures||[]),completedSteps:new Set(s.completedSteps||[]),savedInstance:s.instance||null}}catch(n){return console.warn("Failed to restore form data from localStorage:",n),null}}clearFormData(e,t="completed workflow"){const n=this.getStorageKey(e);try{localStorage.removeItem(n),console.log(`Cleared saved form data for ${t}`)}catch(s){console.warn("Failed to clear saved form data:",s)}}shouldRestoreData(e){return e==="default"}}/*!
|
|
3013
2969
|
* Signature Pad v5.0.10 | https://github.com/szimek/signature_pad
|
|
3014
2970
|
* (c) 2025 Szymon Nowak | Released under the MIT license
|
|
3015
|
-
*/class X{constructor(e,t,n,s){if(isNaN(e)||isNaN(t))throw new Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=n||0,this.time=s||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class ge{static fromPoints(e,t){const n=this.calculateControlPoints(e[0],e[1],e[2]).c2,s=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new ge(e[1],n,s,e[2],t.start,t.end)}static calculateControlPoints(e,t,n){const s=e.x-t.x,r=e.y-t.y,o=t.x-n.x,a=t.y-n.y,d={x:(e.x+t.x)/2,y:(e.y+t.y)/2},p={x:(t.x+n.x)/2,y:(t.y+n.y)/2},c=Math.sqrt(s*s+r*r),u=Math.sqrt(o*o+a*a),h=d.x-p.x,f=d.y-p.y,b=c+u==0?0:u/(c+u),$={x:p.x+h*b,y:p.y+f*b},ie=t.x-$.x,ne=t.y-$.y;return{c1:new X(d.x+ie,d.y+ne),c2:new X(p.x+ie,p.y+ne)}}constructor(e,t,n,s,r,o){this.startPoint=e,this.control2=t,this.control1=n,this.endPoint=s,this.startWidth=r,this.endWidth=o}length(){let t=0,n,s;for(let r=0;r<=10;r+=1){const o=r/10,a=this.point(o,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this.point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){const p=a-n,c=d-s;t+=Math.sqrt(p*p+c*c)}n=a,s=d}return t}point(e,t,n,s,r){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*s*(1-e)*e*e+r*e*e*e}}class xt{constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,n){this._et.addEventListener(e,t,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,n){this._et.removeEventListener(e,t,n)}}function _t(i,e=250){let t=0,n=null,s,r,o;const a=()=>{t=Date.now(),n=null,s=i.apply(r,o),n||(r=null,o=[])};return function(...p){const c=Date.now(),u=e-(c-t);return r=this,o=p,u<=0||u>e?(n&&(clearTimeout(n),n=null),t=c,s=i.apply(r,o),n||(r=null,o=[])):n||(n=window.setTimeout(a,u)),s}}class Z extends xt{constructor(e,t={}){var n,s,r;super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this.velocityFilterWeight=t.velocityFilterWeight||.7,this.minWidth=t.minWidth||.5,this.maxWidth=t.maxWidth||2.5,this.throttle=(n=t.throttle)!==null&&n!==void 0?n:16,this.minDistance=(s=t.minDistance)!==null&&s!==void 0?s:5,this.dotSize=t.dotSize||0,this.penColor=t.penColor||"black",this.backgroundColor=t.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=t.compositeOperation||"source-over",this.canvasContextOptions=(r=t.canvasContextOptions)!==null&&r!==void 0?r:{},this._strokeMoveUpdate=this.throttle?_t(Z.prototype._strokeUpdate,this.throttle):Z.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:t}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._strokePointerId=void 0}fromDataURL(e,t={}){return new Promise((n,s)=>{const r=new Image,o=t.ratio||window.devicePixelRatio||1,a=t.width||this.canvas.width/o,d=t.height||this.canvas.height/o,p=t.xOffset||0,c=t.yOffset||0;this._reset(this._getPointGroupOptions()),r.onload=()=>{this._ctx.drawImage(r,p,c,a,d),n()},r.onerror=u=>{s(u)},r.crossOrigin="anonymous",r.src=e,this._isEmpty=!1})}toDataURL(e="image/png",t){switch(e){case"image/svg+xml":return typeof t!="object"&&(t=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(t))}`;default:return typeof t!="number"&&(t=void 0),this.canvas.toDataURL(e,t)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerDown),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){var e;const t=window.document===this.canvas.ownerDocument?window:(e=this.canvas.ownerDocument.defaultView)!==null&&e!==void 0?e:this.canvas.ownerDocument;return{addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}_removeMoveUpEventListeners(){const{removeEventListener:e}=this._getListenerFunctions();e("pointermove",this._handlePointerMove),e("pointerup",this._handlePointerUp),e("mousemove",this._handleMouseMove),e("mouseup",this._handleMouseUp),e("touchmove",this._handleTouchMove),e("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:t=!0}={}){t&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_isLeftButtonPressed(e,t){return t?e.buttons===1:(e.buttons&1)===1}_pointerEventToSignatureEvent(e){return{event:e,type:e.type,x:e.clientX,y:e.clientY,pressure:"pressure"in e?e.pressure:0}}_touchEventToSignatureEvent(e){const t=e.changedTouches[0];return{event:e,type:e.type,x:t.clientX,y:t.clientY,pressure:t.force}}_handleMouseDown(e){!this._isLeftButtonPressed(e,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(e))}_handleMouseMove(e){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}_handleMouseUp(e){this._isLeftButtonPressed(e)||this._strokeEnd(this._pointerEventToSignatureEvent(e))}_handleTouchStart(e){e.targetTouches.length!==1||this._drawingStroke||(e.cancelable&&e.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(e)))}_handleTouchMove(e){if(e.targetTouches.length===1){if(e.cancelable&&e.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(e))}}_handleTouchEnd(e){e.targetTouches.length===0&&(e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e)))}_getPointerId(e){return e.persistentDeviceId||e.pointerId}_allowPointerId(e,t=!1){return typeof this._strokePointerId>"u"?t:this._getPointerId(e)===this._strokePointerId}_handlePointerDown(e){this._drawingStroke||!this._isLeftButtonPressed(e)||!this._allowPointerId(e,!0)||(this._strokePointerId=this._getPointerId(e),e.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(e)))}_handlePointerMove(e){if(this._allowPointerId(e)){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}e.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}}_handlePointerUp(e){this._isLeftButtonPressed(e)||!this._allowPointerId(e)||(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e)))}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;const{addEventListener:n}=this._getListenerFunctions();switch(e.event.type){case"mousedown":n("mousemove",this._handleMouseMove,{passive:!1}),n("mouseup",this._handleMouseUp,{passive:!1});break;case"touchstart":n("touchmove",this._handleTouchMove,{passive:!1}),n("touchend",this._handleTouchEnd,{passive:!1});break;case"pointerdown":n("pointermove",this._handlePointerMove,{passive:!1}),n("pointerup",this._handlePointerUp,{passive:!1});break}this._drawingStroke=!0;const s=this._getPointGroupOptions(),r=Object.assign(Object.assign({},s),{points:[]});this._data.push(r),this._reset(s),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const t=this._createPoint(e.x,e.y,e.pressure),n=this._data[this._data.length-1],s=n.points,r=s.length>0&&s[s.length-1],o=r?t.distanceTo(r)<=this.minDistance:!1,a=this._getPointGroupOptions(n);if(!r||!(r&&o)){const d=this._addPoint(t,a);r?d&&this._drawCurve(d,a):this._drawDot(t,a),s.push({time:t.time,x:t.x,y:t.y,pressure:t.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e,t=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(t&&this._strokeUpdate(e),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart,{passive:!1})}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,t,n){const s=this.canvas.getBoundingClientRect();return new X(e-s.left,t-s.top,n,new Date().getTime())}_addPoint(e,t){const{_lastPoints:n}=this;if(n.push(e),n.length>2){n.length===3&&n.unshift(n[0]);const s=this._calculateCurveWidths(n[1],n[2],t),r=ge.fromPoints(n,s);return n.shift(),r}return null}_calculateCurveWidths(e,t,n){const s=n.velocityFilterWeight*t.velocityFrom(e)+(1-n.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(s,n),o={end:r,start:this._lastWidth};return this._lastVelocity=s,this._lastWidth=r,o}_strokeWidth(e,t){return Math.max(t.maxWidth/(e+1),t.minWidth)}_drawCurveSegment(e,t,n){const s=this._ctx;s.moveTo(e,t),s.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,t){const n=this._ctx,s=e.endWidth-e.startWidth,r=Math.ceil(e.length())*2;n.beginPath(),n.fillStyle=t.penColor;for(let o=0;o<r;o+=1){const a=o/r,d=a*a,p=d*a,c=1-a,u=c*c,h=u*c;let f=h*e.startPoint.x;f+=3*u*a*e.control1.x,f+=3*c*d*e.control2.x,f+=p*e.endPoint.x;let b=h*e.startPoint.y;b+=3*u*a*e.control1.y,b+=3*c*d*e.control2.y,b+=p*e.endPoint.y;const $=Math.min(e.startWidth+p*s,t.maxWidth);this._drawCurveSegment(f,b,$)}n.closePath(),n.fill()}_drawDot(e,t){const n=this._ctx,s=t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2;n.beginPath(),this._drawCurveSegment(e.x,e.y,s),n.closePath(),n.fillStyle=t.penColor,n.fill()}_fromData(e,t,n){for(const s of e){const{points:r}=s,o=this._getPointGroupOptions(s);if(r.length>1)for(let a=0;a<r.length;a+=1){const d=r[a],p=new X(d.x,d.y,d.pressure,d.time);a===0&&this._reset(o);const c=this._addPoint(p,o);c&&t(c,o)}else this._reset(o),n(r[0],o)}}toSVG({includeBackgroundColor:e=!1}={}){const t=this._data,n=Math.max(window.devicePixelRatio||1,1),s=0,r=0,o=this.canvas.width/n,a=this.canvas.height/n,d=document.createElementNS("http://www.w3.org/2000/svg","svg");if(d.setAttribute("xmlns","http://www.w3.org/2000/svg"),d.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),d.setAttribute("viewBox",`${s} ${r} ${o} ${a}`),d.setAttribute("width",o.toString()),d.setAttribute("height",a.toString()),e&&this.backgroundColor){const p=document.createElement("rect");p.setAttribute("width","100%"),p.setAttribute("height","100%"),p.setAttribute("fill",this.backgroundColor),d.appendChild(p)}return this._fromData(t,(p,{penColor:c})=>{const u=document.createElement("path");if(!isNaN(p.control1.x)&&!isNaN(p.control1.y)&&!isNaN(p.control2.x)&&!isNaN(p.control2.y)){const h=`M ${p.startPoint.x.toFixed(3)},${p.startPoint.y.toFixed(3)} C ${p.control1.x.toFixed(3)},${p.control1.y.toFixed(3)} ${p.control2.x.toFixed(3)},${p.control2.y.toFixed(3)} ${p.endPoint.x.toFixed(3)},${p.endPoint.y.toFixed(3)}`;u.setAttribute("d",h),u.setAttribute("stroke-width",(p.endWidth*2.25).toFixed(3)),u.setAttribute("stroke",c),u.setAttribute("fill","none"),u.setAttribute("stroke-linecap","round"),d.appendChild(u)}},(p,{penColor:c,dotSize:u,minWidth:h,maxWidth:f})=>{const b=document.createElement("circle"),$=u>0?u:(h+f)/2;b.setAttribute("r",$.toString()),b.setAttribute("cx",p.x.toString()),b.setAttribute("cy",p.y.toString()),b.setAttribute("fill",c),d.appendChild(b)}),d.outerHTML}}class yt{constructor(e){this.signaturePads=new Map,this.canvasElements=new Map,this.onSignatureChange=e}initializeSignaturePad(e,t){const n=t==null?void 0:t.getElementById(`signature-${e}`);if(!n)return null;this.clearSignaturePad(e),this.resizeCanvas(n);const s=new Z(n,{backgroundColor:"rgb(255, 255, 255)",penColor:"rgb(0, 0, 0)",minWidth:.5,maxWidth:2.5});return this.signaturePads.set(e,s),this.canvasElements.set(e,n),s.addEventListener("endStroke",()=>{this.handleSignatureChange(e)}),s}handleSignatureChange(e){var r;const t=this.signaturePads.get(e);if(!t)return;const n=!t.isEmpty(),s=n?t.toData():null;(r=this.onSignatureChange)==null||r.call(this,{questionId:e,hasSignature:n,signatureData:s})}clearSignature(e){const t=this.signaturePads.get(e);t&&(t.clear(),this.handleSignatureChange(e))}saveSignature(e){const t=this.signaturePads.get(e);if(!t||t.isEmpty())return null;const n=t.toSVG(),s=t.toDataURL();return{questionId:e,svgData:n,dataURL:s}}restoreSignature(e,t){const n=this.signaturePads.get(e);if(!n||!t)return!1;try{return n.clear(),n.fromData(t),!0}catch(s){return console.warn(`Failed to restore signature for ${e}:`,s),!1}}handleResize(){this.signaturePads.forEach((e,t)=>{const n=this.canvasElements.get(t);if(n){this.resizeCanvas(n);const s=e.toData();e.clear(),e.fromData(s)}})}resizeCanvas(e){const t=Math.max(window.devicePixelRatio||1,1),n=window.getComputedStyle(e),s=parseFloat(n.width),r=parseFloat(n.height);e.width=s*t,e.height=r*t;const o=e.getContext("2d");o&&o.scale(t,t)}clearSignaturePad(e){var t;this.signaturePads.has(e)&&((t=this.signaturePads.get(e))==null||t.off(),this.signaturePads.delete(e),this.canvasElements.delete(e))}getSignaturePad(e){return this.signaturePads.get(e)}hasSignaturePads(){return this.signaturePads.size>0}getAllSignaturePads(){return new Map(this.signaturePads)}destroy(){this.signaturePads.forEach(e=>{e.off()}),this.signaturePads.clear(),this.canvasElements.clear()}}class St{trackQuestionResponse(e,t,n){if(!e)return;e.responses||(e.responses=[]);const s=e.responses.findIndex(o=>o.elementId===t),r={elementId:t,value:n,answeredAt:new Date};s>=0?e.responses[s]=r:e.responses.push(r)}updateInstanceWithFormData(e,t){e!=null&&e.steps&&e.steps.forEach(n=>{n.responses||(n.responses=[]),n.elements.forEach(s=>{if(this.isQuestionElement(s.type)){const r=t[s.id];if(r!==void 0&&n.responses){let o=n.responses.find(a=>a.elementId===s.id);o?(o.value=r,o.answeredAt=new Date):(o={elementId:s.id,value:r,answeredAt:new Date},n.responses.push(o))}}})})}extractFormDataFromSteps(e){const t={};return e.forEach(n=>{n.responses&&n.responses.forEach(s=>{t[s.elementId]=s.value})}),t}hasChangedFromPrevious(e,t,n){if(!(n!=null&&n.steps))return!0;for(const s of n.steps)if(s.responses){const r=s.responses.find(o=>o.elementId===e);if(r)return r.value!==t}return!0}isQuestionElement(e){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(e)}}class wt{constructor(e,t){this.mode=e,this.currentUser=t}updateMode(e){this.mode=e}updateCurrentUser(e){this.currentUser=e}isStepAssignedToUser(e){if(!this.currentUser)return!1;const t=e.assignment;return!!(this.currentUser.targetId&&t.targetId&&this.currentUser.targetId===t.targetId||this.currentUser.email&&t.email&&this.currentUser.email===t.email)}getAssignedSteps(e){return e!=null&&e.steps?e.steps.filter(t=>this.isStepAssignedToUser(t)):[]}findNextAssignedStep(e,t){if(!(t!=null&&t.steps))return-1;if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print")return e+1<t.steps.length?e+1:-1;for(let n=e+1;n<t.steps.length;n++){const s=t.steps[n];if(this.isStepAssignedToUser(s))return n}return-1}isLastAssignedStep(e,t){if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print"){const n=t==null?void 0:t.steps;return e===((n==null?void 0:n.length)||0)-1}return this.findNextAssignedStep(e,t)===-1}canNavigateToStep(e,t,n,s,r,o){if((r||o)&&this.mode!=="admin"&&this.mode!=="view-only"&&this.mode!=="print")return{canNavigate:!1,newStepIndex:t,reason:"Navigation blocked: workflow submitted"};if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print"){const p=n.steps;return!p||e<0||e>=p.length?{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"}:{canNavigate:!0,newStepIndex:e}}const a=n.steps;if(!a||e<0||e>=a.length)return{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"};const d=a[e];if(this.isStepAssignedToUser(d)){const p=s.has(d.id),c=this.isStepWithinAllowedRange(e,n,s);return p||c?{canNavigate:!0,newStepIndex:e}:{canNavigate:!1,newStepIndex:t,reason:"Step not accessible yet"}}else return{canNavigate:!0,newStepIndex:e}}isStepWithinAllowedRange(e,t,n){if(!(t!=null&&t.steps))return!1;const r=this.getAssignedSteps(t).map(d=>t.steps.findIndex(p=>p.id===d.id)).sort((d,p)=>d-p);let o=-1;for(const d of r){const p=t.steps[d];n.has(p.id)&&(o=d)}let a=-1;for(const d of r)if(d>o){a=d;break}return a!==-1?e<=a&&this.isStepAssignedToUser(t.steps[e]):this.isStepAssignedToUser(t.steps[e])}}const ee=class ee{constructor(){this.formData={},this.validationErrors={}}updateFormData(e){this.formData={...e}}mergeFormData(e){this.formData={...this.formData,...e}}setFormField(e,t){this.formData={...this.formData,[e]:t}}removeFormField(e){const t={...this.formData};delete t[e],this.formData=t}getFormData(){return{...this.formData}}getFormField(e){return this.formData[e]}hasFormField(e){return e in this.formData}setValidationErrors(e){this.validationErrors={...e}}getValidationErrors(){return{...this.validationErrors}}clearValidationError(e){if(this.validationErrors[e]){const t={...this.validationErrors};delete t[e],this.validationErrors=t}}hasValidationError(e){return!!this.validationErrors[e]}setValidationError(e,t){this.validationErrors={...this.validationErrors,[e]:t}}clearAllValidationErrors(){this.validationErrors={}}initializeFromResponses(e){const t={};e.forEach(n=>{n.responses&&n.responses.forEach(s=>{t[s.elementId]=s.value})}),this.formData=t}reset(){this.formData={},this.validationErrors={}}isQuestionElement(e){return ee.QUESTION_ELEMENT_TYPES.includes(e.type)}getStepFormData(e){var n;const t={};return(n=e.elements)==null||n.forEach(s=>{if(this.isQuestionElement(s)){const r=s,o=this.formData[r.id];o!==void 0&&(t[r.id]=o)}}),t}hasFormData(){return Object.keys(this.formData).length>0}getFormFieldIds(){return Object.keys(this.formData)}getValidationErrorCount(){return Object.keys(this.validationErrors).length}};ee.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"];let fe=ee;const te=class te{constructor(e,t){this.formStateManager=e,this.responseTracker=t}handleFileUpload(e,t,n){var p,c,u,h,f;const s=t.target,r=(p=s.files)==null?void 0:p[0];if(!r){this.clearFile(e),(c=n.onRequestUpdate)==null||c.call(n);return}const o=this.validateFileSize(r);if(o){this.handleFileValidationError(e,o,s),(u=n.onRequestUpdate)==null||u.call(n);return}this.formStateManager.clearValidationError(e);const a=this.createFileInfo(r);this.formStateManager.setFormField(e,a);const d=this.hasFileChanged(e,a,n.savedInstance);d&&n.mode!=="preview"?this.executeFileUploadCallback(e,r,a,n):this.logSkippedCallback(e,n.mode,d),(h=n.onRequestUpdate)==null||h.call(n),n.mode!=="admin"&&((f=n.onFormDataSave)==null||f.call(n))}clearFile(e){this.formStateManager.setFormField(e,null),this.formStateManager.clearValidationError(e)}validateFileSize(e){return e.size>te.MAX_FILE_SIZE?`File size must be less than 5MB. Current size: ${(e.size/1024/1024).toFixed(2)}MB`:null}handleFileValidationError(e,t,n){this.formStateManager.setValidationError(e,t),this.formStateManager.setFormField(e,null),n.value=""}createFileInfo(e){return{name:e.name,size:e.size,type:e.type,lastModified:e.lastModified}}hasFileChanged(e,t,n){if(!(n!=null&&n.steps))return!0;for(const s of n.steps)if(s.responses){const r=s.responses.find(o=>o.elementId===e);if(r&&r.value&&typeof r.value=="object"){const o=r.value;return o.name!==t.name||o.size!==t.size||o.type!==t.type||o.lastModified!==t.lastModified}}return!0}executeFileUploadCallback(e,t,n,s){var r,o;console.log("File changed, calling callback for:",e),console.log("Callback function exists:",!!s.onFileUploaded),s.onFileUploaded&&s.onFileUploaded({instanceId:(r=s.instance)==null?void 0:r.id,stepId:(o=s.currentStep)==null?void 0:o.id,questionId:e,file:t,fileName:n.name,fileSize:n.size,fileType:n.type})}logSkippedCallback(e,t,n){t==="preview"?console.log("Preview mode: skipping file upload callback for:",e):n||console.log("File unchanged, skipping callback for:",e)}};te.MAX_FILE_SIZE=5*1024*1024;let me=te;class S{static _isInputDisabled(e){return(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="admin"||e.mode==="view-only"||e.mode==="print"||e.mode==="default"&&!e.handlers.isCurrentStepAssigned()}static _formatFileSize(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,s)).toFixed(2))+" "+n[s]}static _extractFilenameFromUrl(e){try{return new URL(e).pathname.split("/").pop()||""||"Uploaded File"}catch{const t=e.split("/"),n=t[t.length-1];return n&&n.includes(".")?n:"Uploaded File"}}static _guessFileTypeFromUrl(e){var r;const n=(r=S._extractFilenameFromUrl(e).split(".").pop())==null?void 0:r.toLowerCase();return n?{pdf:"PDF Document",doc:"Word Document",docx:"Word Document",xls:"Excel Spreadsheet",xlsx:"Excel Spreadsheet",png:"PNG Image",jpg:"JPEG Image",jpeg:"JPEG Image",gif:"GIF Image",svg:"SVG Image",txt:"Text File",csv:"CSV File",zip:"ZIP Archive",mp4:"MP4 Video",mp3:"MP3 Audio"}[n]||`${n.toUpperCase()} File`:"Unknown"}static renderTextArea(e,t,n){return n.mode==="print"?l`<div class="print-response-value textarea-response">
|
|
2971
|
+
*/class X{constructor(e,t,n,s){if(isNaN(e)||isNaN(t))throw new Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=n||0,this.time=s||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class ge{static fromPoints(e,t){const n=this.calculateControlPoints(e[0],e[1],e[2]).c2,s=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new ge(e[1],n,s,e[2],t.start,t.end)}static calculateControlPoints(e,t,n){const s=e.x-t.x,r=e.y-t.y,o=t.x-n.x,a=t.y-n.y,d={x:(e.x+t.x)/2,y:(e.y+t.y)/2},p={x:(t.x+n.x)/2,y:(t.y+n.y)/2},c=Math.sqrt(s*s+r*r),u=Math.sqrt(o*o+a*a),h=d.x-p.x,f=d.y-p.y,b=c+u==0?0:u/(c+u),$={x:p.x+h*b,y:p.y+f*b},ie=t.x-$.x,ne=t.y-$.y;return{c1:new X(d.x+ie,d.y+ne),c2:new X(p.x+ie,p.y+ne)}}constructor(e,t,n,s,r,o){this.startPoint=e,this.control2=t,this.control1=n,this.endPoint=s,this.startWidth=r,this.endWidth=o}length(){let t=0,n,s;for(let r=0;r<=10;r+=1){const o=r/10,a=this.point(o,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),d=this.point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){const p=a-n,c=d-s;t+=Math.sqrt(p*p+c*c)}n=a,s=d}return t}point(e,t,n,s,r){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*s*(1-e)*e*e+r*e*e*e}}class vt{constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,n){this._et.addEventListener(e,t,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,n){this._et.removeEventListener(e,t,n)}}function xt(i,e=250){let t=0,n=null,s,r,o;const a=()=>{t=Date.now(),n=null,s=i.apply(r,o),n||(r=null,o=[])};return function(...p){const c=Date.now(),u=e-(c-t);return r=this,o=p,u<=0||u>e?(n&&(clearTimeout(n),n=null),t=c,s=i.apply(r,o),n||(r=null,o=[])):n||(n=window.setTimeout(a,u)),s}}class Z extends vt{constructor(e,t={}){var n,s,r;super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this.velocityFilterWeight=t.velocityFilterWeight||.7,this.minWidth=t.minWidth||.5,this.maxWidth=t.maxWidth||2.5,this.throttle=(n=t.throttle)!==null&&n!==void 0?n:16,this.minDistance=(s=t.minDistance)!==null&&s!==void 0?s:5,this.dotSize=t.dotSize||0,this.penColor=t.penColor||"black",this.backgroundColor=t.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=t.compositeOperation||"source-over",this.canvasContextOptions=(r=t.canvasContextOptions)!==null&&r!==void 0?r:{},this._strokeMoveUpdate=this.throttle?xt(Z.prototype._strokeUpdate,this.throttle):Z.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:t}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._strokePointerId=void 0}fromDataURL(e,t={}){return new Promise((n,s)=>{const r=new Image,o=t.ratio||window.devicePixelRatio||1,a=t.width||this.canvas.width/o,d=t.height||this.canvas.height/o,p=t.xOffset||0,c=t.yOffset||0;this._reset(this._getPointGroupOptions()),r.onload=()=>{this._ctx.drawImage(r,p,c,a,d),n()},r.onerror=u=>{s(u)},r.crossOrigin="anonymous",r.src=e,this._isEmpty=!1})}toDataURL(e="image/png",t){switch(e){case"image/svg+xml":return typeof t!="object"&&(t=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(t))}`;default:return typeof t!="number"&&(t=void 0),this.canvas.toDataURL(e,t)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerDown),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){var e;const t=window.document===this.canvas.ownerDocument?window:(e=this.canvas.ownerDocument.defaultView)!==null&&e!==void 0?e:this.canvas.ownerDocument;return{addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}_removeMoveUpEventListeners(){const{removeEventListener:e}=this._getListenerFunctions();e("pointermove",this._handlePointerMove),e("pointerup",this._handlePointerUp),e("mousemove",this._handleMouseMove),e("mouseup",this._handleMouseUp),e("touchmove",this._handleTouchMove),e("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:t=!0}={}){t&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_isLeftButtonPressed(e,t){return t?e.buttons===1:(e.buttons&1)===1}_pointerEventToSignatureEvent(e){return{event:e,type:e.type,x:e.clientX,y:e.clientY,pressure:"pressure"in e?e.pressure:0}}_touchEventToSignatureEvent(e){const t=e.changedTouches[0];return{event:e,type:e.type,x:t.clientX,y:t.clientY,pressure:t.force}}_handleMouseDown(e){!this._isLeftButtonPressed(e,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(e))}_handleMouseMove(e){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}_handleMouseUp(e){this._isLeftButtonPressed(e)||this._strokeEnd(this._pointerEventToSignatureEvent(e))}_handleTouchStart(e){e.targetTouches.length!==1||this._drawingStroke||(e.cancelable&&e.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(e)))}_handleTouchMove(e){if(e.targetTouches.length===1){if(e.cancelable&&e.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(e))}}_handleTouchEnd(e){e.targetTouches.length===0&&(e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e)))}_getPointerId(e){return e.persistentDeviceId||e.pointerId}_allowPointerId(e,t=!1){return typeof this._strokePointerId>"u"?t:this._getPointerId(e)===this._strokePointerId}_handlePointerDown(e){this._drawingStroke||!this._isLeftButtonPressed(e)||!this._allowPointerId(e,!0)||(this._strokePointerId=this._getPointerId(e),e.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(e)))}_handlePointerMove(e){if(this._allowPointerId(e)){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}e.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}}_handlePointerUp(e){this._isLeftButtonPressed(e)||!this._allowPointerId(e)||(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e)))}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;const{addEventListener:n}=this._getListenerFunctions();switch(e.event.type){case"mousedown":n("mousemove",this._handleMouseMove,{passive:!1}),n("mouseup",this._handleMouseUp,{passive:!1});break;case"touchstart":n("touchmove",this._handleTouchMove,{passive:!1}),n("touchend",this._handleTouchEnd,{passive:!1});break;case"pointerdown":n("pointermove",this._handlePointerMove,{passive:!1}),n("pointerup",this._handlePointerUp,{passive:!1});break}this._drawingStroke=!0;const s=this._getPointGroupOptions(),r=Object.assign(Object.assign({},s),{points:[]});this._data.push(r),this._reset(s),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const t=this._createPoint(e.x,e.y,e.pressure),n=this._data[this._data.length-1],s=n.points,r=s.length>0&&s[s.length-1],o=r?t.distanceTo(r)<=this.minDistance:!1,a=this._getPointGroupOptions(n);if(!r||!(r&&o)){const d=this._addPoint(t,a);r?d&&this._drawCurve(d,a):this._drawDot(t,a),s.push({time:t.time,x:t.x,y:t.y,pressure:t.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e,t=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(t&&this._strokeUpdate(e),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart,{passive:!1})}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,t,n){const s=this.canvas.getBoundingClientRect();return new X(e-s.left,t-s.top,n,new Date().getTime())}_addPoint(e,t){const{_lastPoints:n}=this;if(n.push(e),n.length>2){n.length===3&&n.unshift(n[0]);const s=this._calculateCurveWidths(n[1],n[2],t),r=ge.fromPoints(n,s);return n.shift(),r}return null}_calculateCurveWidths(e,t,n){const s=n.velocityFilterWeight*t.velocityFrom(e)+(1-n.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(s,n),o={end:r,start:this._lastWidth};return this._lastVelocity=s,this._lastWidth=r,o}_strokeWidth(e,t){return Math.max(t.maxWidth/(e+1),t.minWidth)}_drawCurveSegment(e,t,n){const s=this._ctx;s.moveTo(e,t),s.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,t){const n=this._ctx,s=e.endWidth-e.startWidth,r=Math.ceil(e.length())*2;n.beginPath(),n.fillStyle=t.penColor;for(let o=0;o<r;o+=1){const a=o/r,d=a*a,p=d*a,c=1-a,u=c*c,h=u*c;let f=h*e.startPoint.x;f+=3*u*a*e.control1.x,f+=3*c*d*e.control2.x,f+=p*e.endPoint.x;let b=h*e.startPoint.y;b+=3*u*a*e.control1.y,b+=3*c*d*e.control2.y,b+=p*e.endPoint.y;const $=Math.min(e.startWidth+p*s,t.maxWidth);this._drawCurveSegment(f,b,$)}n.closePath(),n.fill()}_drawDot(e,t){const n=this._ctx,s=t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2;n.beginPath(),this._drawCurveSegment(e.x,e.y,s),n.closePath(),n.fillStyle=t.penColor,n.fill()}_fromData(e,t,n){for(const s of e){const{points:r}=s,o=this._getPointGroupOptions(s);if(r.length>1)for(let a=0;a<r.length;a+=1){const d=r[a],p=new X(d.x,d.y,d.pressure,d.time);a===0&&this._reset(o);const c=this._addPoint(p,o);c&&t(c,o)}else this._reset(o),n(r[0],o)}}toSVG({includeBackgroundColor:e=!1}={}){const t=this._data,n=Math.max(window.devicePixelRatio||1,1),s=0,r=0,o=this.canvas.width/n,a=this.canvas.height/n,d=document.createElementNS("http://www.w3.org/2000/svg","svg");if(d.setAttribute("xmlns","http://www.w3.org/2000/svg"),d.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),d.setAttribute("viewBox",`${s} ${r} ${o} ${a}`),d.setAttribute("width",o.toString()),d.setAttribute("height",a.toString()),e&&this.backgroundColor){const p=document.createElement("rect");p.setAttribute("width","100%"),p.setAttribute("height","100%"),p.setAttribute("fill",this.backgroundColor),d.appendChild(p)}return this._fromData(t,(p,{penColor:c})=>{const u=document.createElement("path");if(!isNaN(p.control1.x)&&!isNaN(p.control1.y)&&!isNaN(p.control2.x)&&!isNaN(p.control2.y)){const h=`M ${p.startPoint.x.toFixed(3)},${p.startPoint.y.toFixed(3)} C ${p.control1.x.toFixed(3)},${p.control1.y.toFixed(3)} ${p.control2.x.toFixed(3)},${p.control2.y.toFixed(3)} ${p.endPoint.x.toFixed(3)},${p.endPoint.y.toFixed(3)}`;u.setAttribute("d",h),u.setAttribute("stroke-width",(p.endWidth*2.25).toFixed(3)),u.setAttribute("stroke",c),u.setAttribute("fill","none"),u.setAttribute("stroke-linecap","round"),d.appendChild(u)}},(p,{penColor:c,dotSize:u,minWidth:h,maxWidth:f})=>{const b=document.createElement("circle"),$=u>0?u:(h+f)/2;b.setAttribute("r",$.toString()),b.setAttribute("cx",p.x.toString()),b.setAttribute("cy",p.y.toString()),b.setAttribute("fill",c),d.appendChild(b)}),d.outerHTML}}class _t{constructor(e){this.signaturePads=new Map,this.canvasElements=new Map,this.onSignatureChange=e}initializeSignaturePad(e,t){const n=t==null?void 0:t.getElementById(`signature-${e}`);if(!n)return null;this.clearSignaturePad(e),this.resizeCanvas(n);const s=new Z(n,{backgroundColor:"rgb(255, 255, 255)",penColor:"rgb(0, 0, 0)",minWidth:.5,maxWidth:2.5});return this.signaturePads.set(e,s),this.canvasElements.set(e,n),s.addEventListener("endStroke",()=>{this.handleSignatureChange(e)}),s}handleSignatureChange(e){var r;const t=this.signaturePads.get(e);if(!t)return;const n=!t.isEmpty(),s=n?t.toData():null;(r=this.onSignatureChange)==null||r.call(this,{questionId:e,hasSignature:n,signatureData:s})}clearSignature(e){const t=this.signaturePads.get(e);t&&(t.clear(),this.handleSignatureChange(e))}saveSignature(e){const t=this.signaturePads.get(e);if(!t||t.isEmpty())return null;const n=t.toSVG(),s=t.toDataURL();return{questionId:e,svgData:n,dataURL:s}}restoreSignature(e,t){const n=this.signaturePads.get(e);if(!n||!t)return!1;try{return n.clear(),n.fromData(t),!0}catch(s){return console.warn(`Failed to restore signature for ${e}:`,s),!1}}handleResize(){this.signaturePads.forEach((e,t)=>{const n=this.canvasElements.get(t);if(n){this.resizeCanvas(n);const s=e.toData();e.clear(),e.fromData(s)}})}resizeCanvas(e){const t=Math.max(window.devicePixelRatio||1,1),n=window.getComputedStyle(e),s=parseFloat(n.width),r=parseFloat(n.height);e.width=s*t,e.height=r*t;const o=e.getContext("2d");o&&o.scale(t,t)}clearSignaturePad(e){var t;this.signaturePads.has(e)&&((t=this.signaturePads.get(e))==null||t.off(),this.signaturePads.delete(e),this.canvasElements.delete(e))}getSignaturePad(e){return this.signaturePads.get(e)}hasSignaturePads(){return this.signaturePads.size>0}getAllSignaturePads(){return new Map(this.signaturePads)}destroy(){this.signaturePads.forEach(e=>{e.off()}),this.signaturePads.clear(),this.canvasElements.clear()}}class St{trackQuestionResponse(e,t,n){if(!e)return;e.responses||(e.responses=[]);const s=e.responses.findIndex(o=>o.elementId===t),r={elementId:t,value:n,answeredAt:new Date};s>=0?e.responses[s]=r:e.responses.push(r)}updateInstanceWithFormData(e,t){e!=null&&e.steps&&e.steps.forEach(n=>{n.responses||(n.responses=[]),n.elements.forEach(s=>{if(this.isQuestionElement(s.type)){const r=t[s.id];if(r!==void 0&&n.responses){let o=n.responses.find(a=>a.elementId===s.id);o?(o.value=r,o.answeredAt=new Date):(o={elementId:s.id,value:r,answeredAt:new Date},n.responses.push(o))}}})})}extractFormDataFromSteps(e){const t={};return e.forEach(n=>{n.responses&&n.responses.forEach(s=>{t[s.elementId]=s.value})}),t}hasChangedFromPrevious(e,t,n){if(!(n!=null&&n.steps))return!0;for(const s of n.steps)if(s.responses){const r=s.responses.find(o=>o.elementId===e);if(r)return r.value!==t}return!0}isQuestionElement(e){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(e)}}class yt{constructor(e,t){this.mode=e,this.currentUser=t}updateMode(e){this.mode=e}updateCurrentUser(e){this.currentUser=e}isStepAssignedToUser(e){if(!this.currentUser)return!1;const t=e.assignment;return!!(this.currentUser.targetId&&t.targetId&&this.currentUser.targetId===t.targetId||this.currentUser.email&&t.email&&this.currentUser.email===t.email)}getAssignedSteps(e){return e!=null&&e.steps?e.steps.filter(t=>this.isStepAssignedToUser(t)):[]}findNextAssignedStep(e,t){if(!(t!=null&&t.steps))return-1;if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print")return e+1<t.steps.length?e+1:-1;for(let n=e+1;n<t.steps.length;n++){const s=t.steps[n];if(this.isStepAssignedToUser(s))return n}return-1}isLastAssignedStep(e,t){if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print"){const n=t==null?void 0:t.steps;return e===((n==null?void 0:n.length)||0)-1}return this.findNextAssignedStep(e,t)===-1}canNavigateToStep(e,t,n,s,r,o){if((r||o)&&this.mode!=="admin"&&this.mode!=="view-only"&&this.mode!=="print")return{canNavigate:!1,newStepIndex:t,reason:"Navigation blocked: workflow submitted"};if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print"){const p=n.steps;return!p||e<0||e>=p.length?{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"}:{canNavigate:!0,newStepIndex:e}}const a=n.steps;if(!a||e<0||e>=a.length)return{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"};const d=a[e];if(this.isStepAssignedToUser(d)){const p=s.has(d.id),c=this.isStepWithinAllowedRange(e,n,s);return p||c?{canNavigate:!0,newStepIndex:e}:{canNavigate:!1,newStepIndex:t,reason:"Step not accessible yet"}}else return{canNavigate:!0,newStepIndex:e}}isStepWithinAllowedRange(e,t,n){if(!(t!=null&&t.steps))return!1;const r=this.getAssignedSteps(t).map(d=>t.steps.findIndex(p=>p.id===d.id)).sort((d,p)=>d-p);let o=-1;for(const d of r){const p=t.steps[d];n.has(p.id)&&(o=d)}let a=-1;for(const d of r)if(d>o){a=d;break}return a!==-1?e<=a&&this.isStepAssignedToUser(t.steps[e]):this.isStepAssignedToUser(t.steps[e])}}const ee=class ee{constructor(){this.formData={},this.validationErrors={}}updateFormData(e){this.formData={...e}}mergeFormData(e){this.formData={...this.formData,...e}}setFormField(e,t){this.formData={...this.formData,[e]:t}}removeFormField(e){const t={...this.formData};delete t[e],this.formData=t}getFormData(){return{...this.formData}}getFormField(e){return this.formData[e]}hasFormField(e){return e in this.formData}setValidationErrors(e){this.validationErrors={...e}}getValidationErrors(){return{...this.validationErrors}}clearValidationError(e){if(this.validationErrors[e]){const t={...this.validationErrors};delete t[e],this.validationErrors=t}}hasValidationError(e){return!!this.validationErrors[e]}setValidationError(e,t){this.validationErrors={...this.validationErrors,[e]:t}}clearAllValidationErrors(){this.validationErrors={}}initializeFromResponses(e){const t={};e.forEach(n=>{n.responses&&n.responses.forEach(s=>{t[s.elementId]=s.value})}),this.formData=t}reset(){this.formData={},this.validationErrors={}}isQuestionElement(e){return ee.QUESTION_ELEMENT_TYPES.includes(e.type)}getStepFormData(e){var n;const t={};return(n=e.elements)==null||n.forEach(s=>{if(this.isQuestionElement(s)){const r=s,o=this.formData[r.id];o!==void 0&&(t[r.id]=o)}}),t}hasFormData(){return Object.keys(this.formData).length>0}getFormFieldIds(){return Object.keys(this.formData)}getValidationErrorCount(){return Object.keys(this.validationErrors).length}};ee.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"];let fe=ee;const te=class te{constructor(e,t){this.formStateManager=e,this.responseTracker=t}handleFileUpload(e,t,n){var p,c,u,h,f;const s=t.target,r=(p=s.files)==null?void 0:p[0];if(!r){this.clearFile(e),(c=n.onRequestUpdate)==null||c.call(n);return}const o=this.validateFileSize(r);if(o){this.handleFileValidationError(e,o,s),(u=n.onRequestUpdate)==null||u.call(n);return}this.formStateManager.clearValidationError(e);const a=this.createFileInfo(r);this.formStateManager.setFormField(e,a);const d=this.hasFileChanged(e,a,n.savedInstance);d&&n.mode!=="preview"?this.executeFileUploadCallback(e,r,a,n):this.logSkippedCallback(e,n.mode,d),(h=n.onRequestUpdate)==null||h.call(n),n.mode!=="admin"&&((f=n.onFormDataSave)==null||f.call(n))}clearFile(e){this.formStateManager.setFormField(e,null),this.formStateManager.clearValidationError(e)}validateFileSize(e){return e.size>te.MAX_FILE_SIZE?`File size must be less than 5MB. Current size: ${(e.size/1024/1024).toFixed(2)}MB`:null}handleFileValidationError(e,t,n){this.formStateManager.setValidationError(e,t),this.formStateManager.setFormField(e,null),n.value=""}createFileInfo(e){return{name:e.name,size:e.size,type:e.type,lastModified:e.lastModified}}hasFileChanged(e,t,n){if(!(n!=null&&n.steps))return!0;for(const s of n.steps)if(s.responses){const r=s.responses.find(o=>o.elementId===e);if(r&&r.value&&typeof r.value=="object"){const o=r.value;return o.name!==t.name||o.size!==t.size||o.type!==t.type||o.lastModified!==t.lastModified}}return!0}executeFileUploadCallback(e,t,n,s){var r,o;console.log("File changed, calling callback for:",e),console.log("Callback function exists:",!!s.onFileUploaded),s.onFileUploaded&&s.onFileUploaded({instanceId:(r=s.instance)==null?void 0:r.id,stepId:(o=s.currentStep)==null?void 0:o.id,questionId:e,file:t,fileName:n.name,fileSize:n.size,fileType:n.type})}logSkippedCallback(e,t,n){t==="preview"?console.log("Preview mode: skipping file upload callback for:",e):n||console.log("File unchanged, skipping callback for:",e)}};te.MAX_FILE_SIZE=5*1024*1024;let me=te;class y{static _isInputDisabled(e){return(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="admin"||e.mode==="view-only"||e.mode==="print"||e.mode==="default"&&!e.handlers.isCurrentStepAssigned()}static _formatFileSize(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,s)).toFixed(2))+" "+n[s]}static _extractFilenameFromUrl(e){try{return new URL(e).pathname.split("/").pop()||""||"Uploaded File"}catch{const t=e.split("/"),n=t[t.length-1];return n&&n.includes(".")?n:"Uploaded File"}}static _guessFileTypeFromUrl(e){var r;const n=(r=y._extractFilenameFromUrl(e).split(".").pop())==null?void 0:r.toLowerCase();return n?{pdf:"PDF Document",doc:"Word Document",docx:"Word Document",xls:"Excel Spreadsheet",xlsx:"Excel Spreadsheet",png:"PNG Image",jpg:"JPEG Image",jpeg:"JPEG Image",gif:"GIF Image",svg:"SVG Image",txt:"Text File",csv:"CSV File",zip:"ZIP Archive",mp4:"MP4 Video",mp3:"MP3 Audio"}[n]||`${n.toUpperCase()} File`:"Unknown"}static renderTextArea(e,t,n){return n.mode==="print"?l`<div class="print-response-value textarea-response">
|
|
3016
2972
|
${t||l`<span class="print-no-response">No response</span>`}
|
|
3017
2973
|
</div>`:l`<textarea
|
|
3018
2974
|
id=${e.id}
|
|
@@ -3051,9 +3007,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3051
3007
|
`)}
|
|
3052
3008
|
</div>`}static renderCheckbox(e,t,n){var o;const s=this._isInputDisabled(n),r=n.mode==="print";if(e.options&&e.options.length>0){if(r){const a=Array.isArray(t)?t:[];return l`<div class="print-response-value checkbox-response">
|
|
3053
3009
|
${a.length>0?a.map(d=>l`<div>• ${d}</div>`):l`<span class="print-no-response">No selections made</span>`}
|
|
3054
|
-
</div>`}return l`<div
|
|
3055
|
-
class="checkbox-group ${r?"print-mode":""}"
|
|
3056
|
-
>
|
|
3010
|
+
</div>`}return l`<div class="checkbox-group ${r?"print-mode":""}">
|
|
3057
3011
|
${(o=e.options)==null?void 0:o.map(a=>l`
|
|
3058
3012
|
<label class="checkbox-option">
|
|
3059
3013
|
<input
|
|
@@ -3069,9 +3023,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3069
3023
|
`)}
|
|
3070
3024
|
</div>`}else return r?l`<div class="print-response-value checkbox-response">
|
|
3071
3025
|
${t?"Yes":"No"}
|
|
3072
|
-
</div>`:l`<label
|
|
3073
|
-
class="checkbox-single ${r?"print-mode":""}"
|
|
3074
|
-
>
|
|
3026
|
+
</div>`:l`<label class="checkbox-single ${r?"print-mode":""}">
|
|
3075
3027
|
<input
|
|
3076
3028
|
type="checkbox"
|
|
3077
3029
|
id=${e.id}
|
|
@@ -3113,12 +3065,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3113
3065
|
`;if(n.mode==="admin"&&s&&typeof s=="string"&&!a){const d=s.trim().startsWith("<svg");return l`
|
|
3114
3066
|
<div class="signature-admin-display">
|
|
3115
3067
|
<div class="signature-existing">
|
|
3116
|
-
${d?l`
|
|
3117
|
-
<div
|
|
3118
|
-
class="signature-svg-container"
|
|
3119
|
-
.innerHTML=${s}
|
|
3120
|
-
></div>
|
|
3121
|
-
`:l`
|
|
3068
|
+
${d?l` <div class="signature-svg-container" .innerHTML=${s}></div> `:l`
|
|
3122
3069
|
<img
|
|
3123
3070
|
src="${s}"
|
|
3124
3071
|
alt="Digital Signature"
|
|
@@ -3126,9 +3073,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3126
3073
|
@error=${p=>{var h;const c=p.target;c.style.display="none";const u=(h=c.parentElement)==null?void 0:h.querySelector(".signature-fallback");u&&u.classList.remove("hidden")}}
|
|
3127
3074
|
/>
|
|
3128
3075
|
<div class="signature-fallback hidden">
|
|
3129
|
-
<span class="signature-error"
|
|
3130
|
-
>Unable to display signature</span
|
|
3131
|
-
>
|
|
3076
|
+
<span class="signature-error">Unable to display signature</span>
|
|
3132
3077
|
</div>
|
|
3133
3078
|
`}
|
|
3134
3079
|
</div>
|
|
@@ -3143,9 +3088,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3143
3088
|
</div>
|
|
3144
3089
|
</div>
|
|
3145
3090
|
`}return l`
|
|
3146
|
-
<div
|
|
3147
|
-
class="signature-container ${this._isInputDisabled(n)?"disabled":""}"
|
|
3148
|
-
>
|
|
3091
|
+
<div class="signature-container ${this._isInputDisabled(n)?"disabled":""}">
|
|
3149
3092
|
<canvas id="signature-${e.id}" class="signature-canvas"></canvas>
|
|
3150
3093
|
<div class="signature-controls">
|
|
3151
3094
|
<button
|
|
@@ -3182,25 +3125,15 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3182
3125
|
<div class="print-response-value file-response">
|
|
3183
3126
|
📎 ${s.name}
|
|
3184
3127
|
${s.size?l` <span class="file-size"
|
|
3185
|
-
>(${
|
|
3128
|
+
>(${y._formatFileSize(s.size)})</span
|
|
3186
3129
|
>`:""}
|
|
3187
3130
|
</div>
|
|
3188
|
-
`;if(r){const a=
|
|
3189
|
-
<div class="print-response-value file-response">
|
|
3190
|
-
📎 ${a}
|
|
3191
|
-
</div>
|
|
3192
|
-
`}else return l`
|
|
3193
|
-
<div class="print-response-value file-response">
|
|
3194
|
-
📎 ${s}
|
|
3195
|
-
</div>
|
|
3196
|
-
`}else{const a=r?s:"#",d=o?s.name:r?S._extractFilenameFromUrl(s):"View File";return l`
|
|
3131
|
+
`;if(r){const a=y._extractFilenameFromUrl(s);return l` <div class="print-response-value file-response">📎 ${a}</div> `}else return l` <div class="print-response-value file-response">📎 ${s}</div> `}else{const a=r?s:"#",d=o?s.name:r?y._extractFilenameFromUrl(s):"View File";return l`
|
|
3197
3132
|
<div class="file-upload-view-only">
|
|
3198
|
-
<a href="${a}" target="_blank" class="file-link">
|
|
3199
|
-
📎 ${d}
|
|
3200
|
-
</a>
|
|
3133
|
+
<a href="${a}" target="_blank" class="file-link"> 📎 ${d} </a>
|
|
3201
3134
|
${o&&s.size?l`
|
|
3202
3135
|
<span class="file-size-info"
|
|
3203
|
-
>(${
|
|
3136
|
+
>(${y._formatFileSize(s.size)})</span
|
|
3204
3137
|
>
|
|
3205
3138
|
`:""}
|
|
3206
3139
|
</div>
|
|
@@ -3223,9 +3156,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3223
3156
|
/>
|
|
3224
3157
|
${s?l`
|
|
3225
3158
|
<div class="file-preview">
|
|
3226
|
-
<span class="file-name"
|
|
3227
|
-
>${s.name||"File selected"}</span
|
|
3228
|
-
>
|
|
3159
|
+
<span class="file-name">${s.name||"File selected"}</span>
|
|
3229
3160
|
<button
|
|
3230
3161
|
type="button"
|
|
3231
3162
|
class="file-clear-btn"
|
|
@@ -3247,7 +3178,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3247
3178
|
?disabled=${this._isInputDisabled(n)}
|
|
3248
3179
|
placeholder="Your Response"
|
|
3249
3180
|
@input=${r=>n.handlers.handleInputChange(e.id,r)}
|
|
3250
|
-
/>`}static render(e,t){const n=t.formData[e.id]??"",s=t.validationErrors[e.id],r=()=>{switch(e.type){case"textarea":return
|
|
3181
|
+
/>`}static render(e,t){const n=t.formData[e.id]??"",s=t.validationErrors[e.id],r=()=>{switch(e.type){case"textarea":return y.renderTextArea(e,n,t);case"select":return y.renderSelect(e,n,t);case"radio":return y.renderRadio(e,n,t);case"checkbox":return y.renderCheckbox(e,n,t);case"signature":return y.renderSignature(e,n,t);case"file_upload":return y.renderFileUpload(e,n,t);default:return y.renderDefaultInput(e,n,t)}},o=e.type==="checkbox"&&(!e.options||e.options.length===0);return t.mode==="print"?l`
|
|
3251
3182
|
<div class="question-print">
|
|
3252
3183
|
${o?"":l` <div class="print-question-title">${e.label}:</div> `}
|
|
3253
3184
|
${r()}
|
|
@@ -3268,18 +3199,18 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3268
3199
|
* @license
|
|
3269
3200
|
* Copyright 2017 Google LLC
|
|
3270
3201
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3271
|
-
*/const
|
|
3202
|
+
*/const wt={CHILD:2},kt=i=>(...e)=>({_$litDirective$:i,values:e});class $t{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
|
|
3272
3203
|
* @license
|
|
3273
3204
|
* Copyright 2017 Google LLC
|
|
3274
3205
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3275
|
-
*/class be extends
|
|
3206
|
+
*/class be extends $t{constructor(e){if(super(e),this.it=v,e.type!==wt.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===v||e==null)return this._t=void 0,this.it=e;if(e===U)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}be.directiveName="unsafeHTML",be.resultType=1;const Le=kt(be);class k{static renderMarkdown(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*?)\*/gim,"<em>$1</em>").replace(/`(.*?)`/gim,"<code>$1</code>").replace(/^> (.*$)/gim,"<blockquote>$1</blockquote>").replace(/\n/gim,"<br>")}static renderText(e){return l`
|
|
3276
3207
|
<div class="content-element text-content">
|
|
3277
3208
|
<p>${e.content}</p>
|
|
3278
3209
|
</div>
|
|
3279
3210
|
`}static renderMarkdownElement(e){return l`
|
|
3280
3211
|
<div class="content-element markdown-content">
|
|
3281
3212
|
<div class="markdown-text">
|
|
3282
|
-
${
|
|
3213
|
+
${Le(k.renderMarkdown(e.content))}
|
|
3283
3214
|
</div>
|
|
3284
3215
|
</div>
|
|
3285
3216
|
`}static renderDivider(e){return l`
|
|
@@ -3289,7 +3220,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3289
3220
|
</div>
|
|
3290
3221
|
`}static renderHtml(e){return l`
|
|
3291
3222
|
<div class="content-element html-content">
|
|
3292
|
-
<div class="html-content-wrapper">${
|
|
3223
|
+
<div class="html-content-wrapper">${Le(e.content)}</div>
|
|
3293
3224
|
</div>
|
|
3294
3225
|
`}static renderImage(e){return l`
|
|
3295
3226
|
<div class="content-element image-content">
|
|
@@ -3321,18 +3252,18 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3321
3252
|
${n()}
|
|
3322
3253
|
${e.type!=="divider"?l`<hr class="print-question-separator" />`:""}
|
|
3323
3254
|
</div>
|
|
3324
|
-
`:n()}}class
|
|
3255
|
+
`:n()}}class Ne{static renderMobileStepsForStatus(e){const{steps:t,disabled:n=!1}=e;return l`
|
|
3325
3256
|
<div class="runner-mobile-steps">
|
|
3326
3257
|
<nav aria-label="Workflow steps">
|
|
3327
3258
|
<div class="runner-mobile-steps-container">
|
|
3328
|
-
${t==null?void 0:t.map(
|
|
3259
|
+
${t==null?void 0:t.map(s=>{const r=e.isStepAssignedToUser(s),o=e.completedSteps.has(s.id);return l`
|
|
3329
3260
|
<div
|
|
3330
|
-
class="runner-mobile-step-tab ${
|
|
3331
|
-
style="cursor: not-allowed; opacity: ${n?"0.6":
|
|
3261
|
+
class="runner-mobile-step-tab ${o?"completed":""} ${r?"":"unassigned"} ${n?"disabled":""}"
|
|
3262
|
+
style="cursor: not-allowed; opacity: ${n?"0.6":r?"1":"0.6"};"
|
|
3332
3263
|
>
|
|
3333
3264
|
<span class="runner-mobile-step-title">${s.title}</span>
|
|
3334
3265
|
<span class="runner-mobile-step-badge">
|
|
3335
|
-
${
|
|
3266
|
+
${o?"Completed":r?"Your Step":"Other User"}
|
|
3336
3267
|
</span>
|
|
3337
3268
|
</div>
|
|
3338
3269
|
`})}
|
|
@@ -3355,12 +3286,10 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3355
3286
|
<path d="m7 11V7a5 5 0 0 1 10 0v4"></path>
|
|
3356
3287
|
</svg>
|
|
3357
3288
|
</div>
|
|
3358
|
-
<h2 class="not-assigned-title">
|
|
3359
|
-
This workflow is not assigned to you
|
|
3360
|
-
</h2>
|
|
3289
|
+
<h2 class="not-assigned-title">This workflow is not assigned to you</h2>
|
|
3361
3290
|
<p class="not-assigned-description">
|
|
3362
|
-
You don't have any steps assigned in this workflow. Please contact
|
|
3363
|
-
|
|
3291
|
+
You don't have any steps assigned in this workflow. Please contact your administrator if
|
|
3292
|
+
you believe this is an error.
|
|
3364
3293
|
</p>
|
|
3365
3294
|
</div>
|
|
3366
3295
|
</div>
|
|
@@ -3374,14 +3303,14 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3374
3303
|
<div class="runner-sidebar-header">Steps</div>
|
|
3375
3304
|
<nav aria-label="Workflow steps">
|
|
3376
3305
|
<ul class="runner-steps-list">
|
|
3377
|
-
${(s=(n=e.instance)==null?void 0:n.steps)==null?void 0:s.map(
|
|
3306
|
+
${(s=(n=e.instance)==null?void 0:n.steps)==null?void 0:s.map(r=>{const o=e.isStepAssignedToUser(r),a=e.completedSteps.has(r.id);return l`
|
|
3378
3307
|
<li
|
|
3379
|
-
class="runner-step-item ${
|
|
3380
|
-
style="opacity: ${
|
|
3308
|
+
class="runner-step-item ${a?"completed":""} ${o?"":"unassigned"}"
|
|
3309
|
+
style="opacity: ${o?"1":"0.6"}; cursor: not-allowed;"
|
|
3381
3310
|
>
|
|
3382
3311
|
<span class="runner-step-title">${r.title}</span>
|
|
3383
3312
|
<span class="runner-step-badge">
|
|
3384
|
-
${
|
|
3313
|
+
${a?"Submitted":o?"Your Step":"Other User"}
|
|
3385
3314
|
</span>
|
|
3386
3315
|
</li>
|
|
3387
3316
|
`})}
|
|
@@ -3413,12 +3342,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3413
3342
|
</div>
|
|
3414
3343
|
</main>
|
|
3415
3344
|
</div>
|
|
3416
|
-
`}}class
|
|
3345
|
+
`}}class Y{static isStepCompleted(e,t,n){return!!(t.completedSteps.has(e.id)||(t.isSubmitted||t.userStepsSubmitted)&&n)}static renderSidebar(e){const{steps:t}=e;return l`
|
|
3417
3346
|
<aside class="runner-sidebar">
|
|
3418
3347
|
<div class="runner-sidebar-header">Steps</div>
|
|
3419
3348
|
<nav aria-label="Workflow steps">
|
|
3420
3349
|
<ul class="runner-steps-list">
|
|
3421
|
-
${t==null?void 0:t.map((n,s)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(n),o=s===e.currentStepIndex,a=this.isStepCompleted(n,e,r),d=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print"
|
|
3350
|
+
${t==null?void 0:t.map((n,s)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(n),o=s===e.currentStepIndex,a=this.isStepCompleted(n,e,r),d=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return l`
|
|
3422
3351
|
<li
|
|
3423
3352
|
class="runner-step-item ${o?"active":""} ${a?"completed":""} ${r?"":"unassigned"} ${d?"disabled":""} ${p?"loading-disabled":""}"
|
|
3424
3353
|
@click=${()=>!p&&e.goToStep(s)}
|
|
@@ -3437,7 +3366,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3437
3366
|
<div class="runner-mobile-steps">
|
|
3438
3367
|
<nav aria-label="Workflow steps">
|
|
3439
3368
|
<div class="runner-mobile-steps-container">
|
|
3440
|
-
${t==null?void 0:t.map((n,s)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(n),o=s===e.currentStepIndex,a=this.isStepCompleted(n,e,r),d=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print"
|
|
3369
|
+
${t==null?void 0:t.map((n,s)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(n),o=s===e.currentStepIndex,a=this.isStepCompleted(n,e,r),d=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return l`
|
|
3441
3370
|
<button
|
|
3442
3371
|
class="runner-mobile-step-tab ${o?"active":""} ${a?"completed":""} ${r?"":"unassigned"} ${d?"disabled":""} ${p?"loading-disabled":""}"
|
|
3443
3372
|
@click=${()=>!p&&e.goToStep(s)}
|
|
@@ -3456,9 +3385,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3456
3385
|
`}static renderStepHeader(e){const{step:t,mode:n}=e;return n==="print"?l`
|
|
3457
3386
|
<div class="step-print-header">
|
|
3458
3387
|
<div class="print-step-title">${t.title}</div>
|
|
3459
|
-
${t.description?l`<div class="print-step-description"
|
|
3460
|
-
${t.description}
|
|
3461
|
-
</div>`:""}
|
|
3388
|
+
${t.description?l`<div class="print-step-description">${t.description}</div>`:""}
|
|
3462
3389
|
<hr class="print-question-separator" />
|
|
3463
3390
|
</div>
|
|
3464
3391
|
`:l`
|
|
@@ -3467,7 +3394,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3467
3394
|
<hr class="runner-step-divider" />
|
|
3468
3395
|
${t.description?l`<p class="runner-step-desc">${t.description}</p>`:""}
|
|
3469
3396
|
</section>
|
|
3470
|
-
`}}class
|
|
3397
|
+
`}}class Dt{static renderFormActions(e){return e.mode==="preview"||e.mode==="view-only"||e.mode==="print"||!e.isCurrentStepAssigned?l``:l`
|
|
3471
3398
|
<div class="runner-form-actions">
|
|
3472
3399
|
<button
|
|
3473
3400
|
class="next-button ${e.mode==="admin"&&e.justSaved?"saved-state":""}"
|
|
@@ -3477,20 +3404,16 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3477
3404
|
${e.mode==="admin"?e.justSaved?"✓ Saved!":"Save":e.isLastStep?"Submit":"Next"}
|
|
3478
3405
|
</button>
|
|
3479
3406
|
</div>
|
|
3480
|
-
`}}class ve{static handleInputChange(e,t,n,s,r,o){const a=t.target;let d;a.type==="radio"?d=a.value:a.type==="checkbox"?d=a.checked:d=a.value;const p={...n,[e]:d};s(p),o!=="preview"&&r(e,d)}static handleCheckboxChange(e,t,n,s,r,o){const d=t.target.checked,p={...n,[e]:d};s(p),o!=="preview"&&r(e,d)}static handleCheckboxGroupChange(e,t,n,s,r,o,a){const d=n.target,p=s[e];let c=Array.isArray(p)?[...p]:[];d.checked?c.includes(t)||c.push(t):c=c.filter(h=>h!==t);const u={...s,[e]:c};r(u),a!=="preview"&&o(e,c)}}var Et=Object.defineProperty,At=Object.getOwnPropertyDescriptor,x=(i,e,t,n)=>{for(var s=n>1?void 0:n?At(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&Et(e,t,s),s};let m=class extends R{constructor(){super(...arguments),this.mode="default",this.isLoading=!1,this._currentStepIndex=0,this._formData={},this._validationErrors={},this._internalCompletedSteps=new Set,this._formRestorationComplete=!1,this._savedSignatures=new Set,this._replacingSignatures=new Set,this._isSubmitted=!1,this._userStepsSubmitted=!1,this._justSaved=!1}willUpdate(i){(i.has("mode")||i.has("currentUser"))&&this._updateNavigationService(),(i.has("instance")||i.has("workflow")||i.has("mode"))&&(this._initializeState(),this._updateValidationService())}connectedCallback(){super.connectedCallback(),this._initializeServices(),this._initializeState(),window.addEventListener("resize",this._handleResize.bind(this)),this._restoreFormData()}disconnectedCallback(){var i;super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize.bind(this)),(i=this.signatureManager)==null||i.destroy()}_initializeServices(){this.persistenceManager=new vt,this.responseTracker=new St,this.formStateManager=new fe,this.signatureManager=new yt(i=>this._handleSignatureChange(i)),this.fileUploadManager=new me(this.formStateManager,this.responseTracker),this._updateNavigationService(),this._updateValidationService()}_updateNavigationService(){this.navigationService=new wt(this.mode||"default",this.currentUser)}_updateValidationService(){var i;this.validationService=new bt(((i=this.signatureManager)==null?void 0:i.getAllSignaturePads())||new Map,this._savedSignatures)}_getRenderContext(){return{formData:this._formData,validationErrors:this._validationErrors,currentStepIndex:this._currentStepIndex,internalCompletedSteps:this._internalCompletedSteps,savedSignatures:this._savedSignatures,replacingSignatures:this._replacingSignatures,isSubmitted:this._isSubmitted,userStepsSubmitted:this._userStepsSubmitted,justSaved:this._justSaved,validationService:this.validationService,persistenceManager:this.persistenceManager,signatureManager:this.signatureManager,responseTracker:this.responseTracker,navigationService:this.navigationService,formStateManager:this.formStateManager,fileUploadManager:this.fileUploadManager,mode:this.mode||"default",instance:this.instance,workflow:this.workflow,currentUser:this.currentUser,isLoading:this.isLoading,handlers:{handleInputChange:this._handleInputChange.bind(this),handleCheckboxChange:this._handleCheckboxChange.bind(this),handleCheckboxGroupChange:this._handleCheckboxGroupChange.bind(this),startReplaceSignature:this._startReplaceSignature.bind(this),cancelReplaceSignature:this._cancelReplaceSignature.bind(this),clearSignature:this._clearSignature.bind(this),saveSignature:this._saveSignature.bind(this),handleFileUpload:this._handleFileUpload.bind(this),trackQuestionResponse:this._trackQuestionResponse.bind(this),isCurrentStepAssigned:this._isCurrentStepAssigned.bind(this)}}}_handleSignatureChange(i){this.formStateManager.setFormField(i.questionId,i.hasSignature),this.formStateManager.setFormField(`${i.questionId}_signatureData`,i.signatureData),this._formData=this.formStateManager.getFormData(),this._savedSignatures.has(i.questionId)&&(this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==i.questionId))),this._clearValidationError(i.questionId),this.mode!=="admin"&&this._saveFormDataToHistory()}_clearValidationError(i){this.formStateManager.clearValidationError(i),this._validationErrors=this.formStateManager.getValidationErrors()}_updateFormData(i){this.formStateManager.updateFormData(i),this._formData=this.formStateManager.getFormData(),this.mode!=="admin"&&this._saveFormDataToHistory()}_handleFormDataUpdate(i){this._clearValidationError(i)}_initializeState(){var i,e,t;if((i=this.formStateManager)==null||i.reset(),this._validationErrors={},this._formData={},this._formRestorationComplete=!1,this._savedSignatures=new Set,this._replacingSignatures=new Set,this._savedInstance=void 0,this._justSaved=!1,this._isSubmitted=((e=this.instance)==null?void 0:e.status)==="completed"||!1,this.instance&&this.instance.status!=="completed"){const n=this._getAssignedSteps(),s=n.filter(r=>{var o;return(o=this.instance.completedSteps)==null?void 0:o.includes(r.id)});this._userStepsSubmitted=n.length>0&&s.length===n.length}else this._userStepsSubmitted=((t=this.instance)==null?void 0:t.status)==="completed"||!1;this.mode==="preview"&&this.workflow?this._initializePreviewMode():this.mode==="view-only"&&this.instance?this._initializeViewOnlyMode():this.mode==="print"&&this.instance?this._initializePrintMode():this.instance&&this._initializeDefaultMode()}_initializePreviewMode(){var i;if(console.log("Initializing preview mode..."),!((i=this.workflow)!=null&&i.steps)||this.workflow.steps.length===0){console.warn("Workflow has no steps in preview mode.");return}this.formStateManager.reset(),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this._internalCompletedSteps=new Set,console.log("Preview mode initialized with empty form data.")}_initializeDefaultMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.instance.completedSteps?this._internalCompletedSteps=new Set(this.instance.completedSteps):this._internalCompletedSteps=new Set(this.instance.steps.filter(e=>e.status==="completed").map(e=>e.id)),this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=this.instance.steps.findIndex(e=>{var t;return e.id===((t=this.instance)==null?void 0:t.currentStepId)}),this._currentStepIndex<0&&(this._currentStepIndex=0),this.instance.steps.forEach((e,t)=>{this._internalCompletedSteps.has(e.id)?e.status="completed":t===this._currentStepIndex?e.status="active":e.status="pending"}))}_initializeViewOnlyMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this.instance.steps.forEach(e=>{e.responses&&e.responses.length>0?(e.status="completed",this._internalCompletedSteps.add(e.id)):e.status="pending"}),console.log("View-only mode initialized with existing responses:",this._formData))}_initializePrintMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this.instance.steps.forEach(e=>{e.responses&&e.responses.length>0?(e.status="completed",this._internalCompletedSteps.add(e.id)):e.status="pending"}),console.log("Print mode initialized with existing responses:",this._formData))}_isStepAssignedToUser(i){return this.navigationService.isStepAssignedToUser(i)}_getAssignedSteps(){return this.instance?this.navigationService.getAssignedSteps(this.instance):[]}_isCurrentStepAssigned(){const i=this._currentStep;return!i||this.mode!=="default"?!0:this._isStepAssignedToUser(i)}_renderNotAssignedView(){return Oe.renderNotAssignedView()}get _currentStep(){var i,e,t;return this.mode==="preview"&&this.workflow?(i=this.workflow.steps)==null?void 0:i[this._currentStepIndex]:(t=(e=this.instance)==null?void 0:e.steps)==null?void 0:t[this._currentStepIndex]}_validateStep(){const i=this._currentStep;if(!i)return!1;const e=this.validationService.validateStep(i,this._formData,this.mode||"default");return this.formStateManager.setValidationErrors(e.errors),this._validationErrors=this.formStateManager.getValidationErrors(),e.isValid}_handleInputChange(i,e){ve.handleInputChange(i,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_handleCheckboxChange(i,e){ve.handleCheckboxChange(i,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_handleCheckboxGroupChange(i,e,t){ve.handleCheckboxGroupChange(i,e,t,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_initializeSignaturePad(i){this.signatureManager.initializeSignaturePad(i,this.shadowRoot)&&this._updateValidationService()}_handleResize(){this.signatureManager.handleResize()}_clearSignature(i){this.signatureManager.clearSignature(i)}_startReplaceSignature(i){this._replacingSignatures=new Set([...this._replacingSignatures,i]),this.formStateManager.setFormField(i,!1),this.formStateManager.setFormField(`${i}_signatureData`,null),this._formData=this.formStateManager.getFormData(),this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==i)),this.requestUpdate()}_cancelReplaceSignature(i){this._replacingSignatures=new Set([...this._replacingSignatures].filter(e=>e!==i))}_saveSignature(i){var n,s,r;const e=this.signatureManager.saveSignature(i);if(!e)return;const t=this._hasSignatureChanged(i,e.svgData);this._savedSignatures=new Set([...this._savedSignatures,i]),this._replacingSignatures.has(i)&&(this._replacingSignatures=new Set([...this._replacingSignatures].filter(o=>o!==i))),this._trackQuestionResponse(i,e.svgData),t&&this.mode!=="preview"?(console.log("Signature changed, calling callback for:",i),console.log("Callback function exists:",!!this.onSignatureCaptured),(r=this.onSignatureCaptured)==null||r.call(this,{instanceId:(n=this.instance)==null?void 0:n.id,stepId:(s=this._currentStep)==null?void 0:s.id,questionId:i,svgData:e.svgData,dataURL:e.dataURL})):this.mode==="preview"?console.log("Preview mode: skipping signature callback for:",i):console.log("Signature unchanged, skipping callback for:",i),this._clearValidationError(i),this.mode!=="admin"&&this._saveFormDataToHistory()}_hasSignatureChanged(i,e){return this.responseTracker.hasChangedFromPrevious(i,e,this._savedInstance)}_restoreInstanceResponses(){var i,e;!((i=this._savedInstance)!=null&&i.steps)||!((e=this.instance)!=null&&e.steps)||this._savedInstance.steps.forEach((t,n)=>{var s;(s=this.instance)!=null&&s.steps&&this.instance.steps[n]&&(this.instance.steps[n].responses=t.responses||[])})}_handleFileUpload(i,e){this.fileUploadManager.handleFileUpload(i,e,{instance:this.instance,currentStep:this._currentStep,mode:this.mode||"default",savedInstance:this._savedInstance,onFileUploaded:this.onFileUploaded,onFormDataSave:()=>this._saveFormDataToHistory(),onRequestUpdate:()=>{this._formData=this.formStateManager.getFormData(),this._validationErrors=this.formStateManager.getValidationErrors();const t=this._formData[i];t&&this._trackQuestionResponse(i,t),this.requestUpdate()}})}_captureSignaturesFromStep(i){console.log("Capturing signatures from step:",i.id)}_trackQuestionResponse(i,e){this.responseTracker.trackQuestionResponse(this._currentStep,i,e)}_renderQuestion(i){return S.render(i,this._getRenderContext())}_renderContentElement(i){return k.render(i,this._getRenderContext())}_isQuestionElement(i){return m.QUESTION_ELEMENT_TYPES.includes(i.type)}_isContentElement(i){return m.CONTENT_ELEMENT_TYPES.includes(i.type)}_renderStepElement(i){return this.mode==="print"?this._isQuestionElement(i)?this._renderQuestion(i):this._isContentElement(i)?this._renderContentElement(i):l`<div class="unknown-element">
|
|
3407
|
+
`}}class ve{static handleInputChange(e,t,n,s,r,o){const a=t.target;let d;a.type==="radio"?d=a.value:a.type==="checkbox"?d=a.checked:d=a.value;const p={...n,[e]:d};s(p),o!=="preview"&&r(e,d)}static handleCheckboxChange(e,t,n,s,r,o){const d=t.target.checked,p={...n,[e]:d};s(p),o!=="preview"&&r(e,d)}static handleCheckboxGroupChange(e,t,n,s,r,o,a){const d=n.target,p=s[e];let c=Array.isArray(p)?[...p]:[];d.checked?c.includes(t)||c.push(t):c=c.filter(h=>h!==t);const u={...s,[e]:c};r(u),a!=="preview"&&o(e,c)}}var Ct=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,x=(i,e,t,n)=>{for(var s=n>1?void 0:n?Et(e,t):e,r=i.length-1,o;r>=0;r--)(o=i[r])&&(s=(n?o(e,t,s):o(s))||s);return n&&s&&Ct(e,t,s),s};let m=class extends R{constructor(){super(...arguments),this.mode="default",this.isLoading=!1,this._currentStepIndex=0,this._formData={},this._validationErrors={},this._internalCompletedSteps=new Set,this._formRestorationComplete=!1,this._savedSignatures=new Set,this._replacingSignatures=new Set,this._isSubmitted=!1,this._userStepsSubmitted=!1,this._justSaved=!1}willUpdate(i){(i.has("mode")||i.has("currentUser"))&&this._updateNavigationService(),(i.has("instance")||i.has("workflow")||i.has("mode"))&&(this._initializeState(),this._updateValidationService())}connectedCallback(){super.connectedCallback(),this._initializeServices(),this._initializeState(),window.addEventListener("resize",this._handleResize.bind(this)),this._restoreFormData()}disconnectedCallback(){var i;super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize.bind(this)),(i=this.signatureManager)==null||i.destroy()}_initializeServices(){this.persistenceManager=new bt,this.responseTracker=new St,this.formStateManager=new fe,this.signatureManager=new _t(i=>this._handleSignatureChange(i)),this.fileUploadManager=new me(this.formStateManager,this.responseTracker),this._updateNavigationService(),this._updateValidationService()}_updateNavigationService(){this.navigationService=new yt(this.mode||"default",this.currentUser)}_updateValidationService(){var i;this.validationService=new mt(((i=this.signatureManager)==null?void 0:i.getAllSignaturePads())||new Map,this._savedSignatures)}_getRenderContext(){return{formData:this._formData,validationErrors:this._validationErrors,currentStepIndex:this._currentStepIndex,internalCompletedSteps:this._internalCompletedSteps,savedSignatures:this._savedSignatures,replacingSignatures:this._replacingSignatures,isSubmitted:this._isSubmitted,userStepsSubmitted:this._userStepsSubmitted,justSaved:this._justSaved,validationService:this.validationService,persistenceManager:this.persistenceManager,signatureManager:this.signatureManager,responseTracker:this.responseTracker,navigationService:this.navigationService,formStateManager:this.formStateManager,fileUploadManager:this.fileUploadManager,mode:this.mode||"default",instance:this.instance,workflow:this.workflow,currentUser:this.currentUser,isLoading:this.isLoading,handlers:{handleInputChange:this._handleInputChange.bind(this),handleCheckboxChange:this._handleCheckboxChange.bind(this),handleCheckboxGroupChange:this._handleCheckboxGroupChange.bind(this),startReplaceSignature:this._startReplaceSignature.bind(this),cancelReplaceSignature:this._cancelReplaceSignature.bind(this),clearSignature:this._clearSignature.bind(this),saveSignature:this._saveSignature.bind(this),handleFileUpload:this._handleFileUpload.bind(this),trackQuestionResponse:this._trackQuestionResponse.bind(this),isCurrentStepAssigned:this._isCurrentStepAssigned.bind(this)}}}_handleSignatureChange(i){this.formStateManager.setFormField(i.questionId,i.hasSignature),this.formStateManager.setFormField(`${i.questionId}_signatureData`,i.signatureData),this._formData=this.formStateManager.getFormData(),this._savedSignatures.has(i.questionId)&&(this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==i.questionId))),this._clearValidationError(i.questionId),this.mode!=="admin"&&this._saveFormDataToHistory()}_clearValidationError(i){this.formStateManager.clearValidationError(i),this._validationErrors=this.formStateManager.getValidationErrors()}_updateFormData(i){this.formStateManager.updateFormData(i),this._formData=this.formStateManager.getFormData(),this.mode!=="admin"&&this._saveFormDataToHistory()}_handleFormDataUpdate(i){this._clearValidationError(i)}_initializeState(){var i,e,t;if((i=this.formStateManager)==null||i.reset(),this._validationErrors={},this._formData={},this._formRestorationComplete=!1,this._savedSignatures=new Set,this._replacingSignatures=new Set,this._savedInstance=void 0,this._justSaved=!1,this._isSubmitted=((e=this.instance)==null?void 0:e.status)==="completed"||!1,this.instance&&this.instance.status!=="completed"){const n=this._getAssignedSteps(),s=n.filter(r=>{var o;return(o=this.instance.completedSteps)==null?void 0:o.includes(r.id)});this._userStepsSubmitted=n.length>0&&s.length===n.length}else this._userStepsSubmitted=((t=this.instance)==null?void 0:t.status)==="completed"||!1;this.mode==="preview"&&this.workflow?this._initializePreviewMode():this.mode==="view-only"&&this.instance?this._initializeViewOnlyMode():this.mode==="print"&&this.instance?this._initializePrintMode():this.instance&&this._initializeDefaultMode()}_initializePreviewMode(){var i;if(console.log("Initializing preview mode..."),!((i=this.workflow)!=null&&i.steps)||this.workflow.steps.length===0){console.warn("Workflow has no steps in preview mode.");return}this.formStateManager.reset(),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this._internalCompletedSteps=new Set,console.log("Preview mode initialized with empty form data.")}_initializeDefaultMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.instance.completedSteps?this._internalCompletedSteps=new Set(this.instance.completedSteps):this._internalCompletedSteps=new Set(this.instance.steps.filter(e=>e.status==="completed").map(e=>e.id)),this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=this.instance.steps.findIndex(e=>{var t;return e.id===((t=this.instance)==null?void 0:t.currentStepId)}),this._currentStepIndex<0&&(this._currentStepIndex=0),this.instance.steps.forEach((e,t)=>{this._internalCompletedSteps.has(e.id)?e.status="completed":t===this._currentStepIndex?e.status="active":e.status="pending"}))}_initializeViewOnlyMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this.instance.steps.forEach(e=>{e.responses&&e.responses.length>0?(e.status="completed",this._internalCompletedSteps.add(e.id)):e.status="pending"}),console.log("View-only mode initialized with existing responses:",this._formData))}_initializePrintMode(){var i;!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0||(this.formStateManager.initializeFromResponses(this.instance.steps),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=0,this.instance.steps.forEach(e=>{e.responses&&e.responses.length>0?(e.status="completed",this._internalCompletedSteps.add(e.id)):e.status="pending"}),console.log("Print mode initialized with existing responses:",this._formData))}_isStepAssignedToUser(i){return this.navigationService.isStepAssignedToUser(i)}_getAssignedSteps(){return this.instance?this.navigationService.getAssignedSteps(this.instance):[]}_isCurrentStepAssigned(){const i=this._currentStep;return!i||this.mode!=="default"?!0:this._isStepAssignedToUser(i)}_renderNotAssignedView(){return Ne.renderNotAssignedView()}get _currentStep(){var i,e,t;return this.mode==="preview"&&this.workflow?(i=this.workflow.steps)==null?void 0:i[this._currentStepIndex]:(t=(e=this.instance)==null?void 0:e.steps)==null?void 0:t[this._currentStepIndex]}_validateStep(){const i=this._currentStep;if(!i)return!1;const e=this.validationService.validateStep(i,this._formData,this.mode||"default");return this.formStateManager.setValidationErrors(e.errors),this._validationErrors=this.formStateManager.getValidationErrors(),e.isValid}_handleInputChange(i,e){ve.handleInputChange(i,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_handleCheckboxChange(i,e){ve.handleCheckboxChange(i,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_handleCheckboxGroupChange(i,e,t){ve.handleCheckboxGroupChange(i,e,t,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(i)}_initializeSignaturePad(i){this.signatureManager.initializeSignaturePad(i,this.shadowRoot)&&this._updateValidationService()}_handleResize(){this.signatureManager.handleResize()}_clearSignature(i){this.signatureManager.clearSignature(i)}_startReplaceSignature(i){this._replacingSignatures=new Set([...this._replacingSignatures,i]),this.formStateManager.setFormField(i,!1),this.formStateManager.setFormField(`${i}_signatureData`,null),this._formData=this.formStateManager.getFormData(),this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==i)),this.requestUpdate()}_cancelReplaceSignature(i){this._replacingSignatures=new Set([...this._replacingSignatures].filter(e=>e!==i))}_saveSignature(i){var n,s,r;const e=this.signatureManager.saveSignature(i);if(!e)return;const t=this._hasSignatureChanged(i,e.svgData);this._savedSignatures=new Set([...this._savedSignatures,i]),this._replacingSignatures.has(i)&&(this._replacingSignatures=new Set([...this._replacingSignatures].filter(o=>o!==i))),this._trackQuestionResponse(i,e.svgData),t&&this.mode!=="preview"?(console.log("Signature changed, calling callback for:",i),console.log("Callback function exists:",!!this.onSignatureCaptured),(r=this.onSignatureCaptured)==null||r.call(this,{instanceId:(n=this.instance)==null?void 0:n.id,stepId:(s=this._currentStep)==null?void 0:s.id,questionId:i,svgData:e.svgData,dataURL:e.dataURL})):this.mode==="preview"?console.log("Preview mode: skipping signature callback for:",i):console.log("Signature unchanged, skipping callback for:",i),this._clearValidationError(i),this.mode!=="admin"&&this._saveFormDataToHistory()}_hasSignatureChanged(i,e){return this.responseTracker.hasChangedFromPrevious(i,e,this._savedInstance)}_restoreInstanceResponses(){var i,e;!((i=this._savedInstance)!=null&&i.steps)||!((e=this.instance)!=null&&e.steps)||this._savedInstance.steps.forEach((t,n)=>{var s;(s=this.instance)!=null&&s.steps&&this.instance.steps[n]&&(this.instance.steps[n].responses=t.responses||[])})}_handleFileUpload(i,e){this.fileUploadManager.handleFileUpload(i,e,{instance:this.instance,currentStep:this._currentStep,mode:this.mode||"default",savedInstance:this._savedInstance,onFileUploaded:this.onFileUploaded,onFormDataSave:()=>this._saveFormDataToHistory(),onRequestUpdate:()=>{this._formData=this.formStateManager.getFormData(),this._validationErrors=this.formStateManager.getValidationErrors();const t=this._formData[i];t&&this._trackQuestionResponse(i,t),this.requestUpdate()}})}_captureSignaturesFromStep(i){console.log("Capturing signatures from step:",i.id)}_trackQuestionResponse(i,e){this.responseTracker.trackQuestionResponse(this._currentStep,i,e)}_renderQuestion(i){return y.render(i,this._getRenderContext())}_renderContentElement(i){return k.render(i,this._getRenderContext())}_isQuestionElement(i){return m.QUESTION_ELEMENT_TYPES.includes(i.type)}_isContentElement(i){return m.CONTENT_ELEMENT_TYPES.includes(i.type)}_renderStepElement(i){return this.mode==="print"?this._isQuestionElement(i)?this._renderQuestion(i):this._isContentElement(i)?this._renderContentElement(i):l`<div class="unknown-element">
|
|
3481
3408
|
<p>⚠️ Unknown element type: ${i.type}</p>
|
|
3482
|
-
</div>`:this._isQuestionElement(i)?l`<div class="runner-card">
|
|
3483
|
-
${this._renderQuestion(i)}
|
|
3484
|
-
</div>`:this._isContentElement(i)?l`<div class="runner-card">
|
|
3485
|
-
${this._renderContentElement(i)}
|
|
3486
|
-
</div>`:l`<div class="runner-card">
|
|
3409
|
+
</div>`:this._isQuestionElement(i)?l`<div class="runner-card">${this._renderQuestion(i)}</div>`:this._isContentElement(i)?l`<div class="runner-card">${this._renderContentElement(i)}</div>`:l`<div class="runner-card">
|
|
3487
3410
|
<div class="unknown-element">
|
|
3488
3411
|
<p>⚠️ Unknown element type: ${i.type}</p>
|
|
3489
3412
|
</div>
|
|
3490
3413
|
</div>`}_renderStepWithElements(i){return l`
|
|
3491
3414
|
<div class="print-step">
|
|
3492
3415
|
<!-- Step Header -->
|
|
3493
|
-
${
|
|
3416
|
+
${Y.renderStepHeader({step:i,mode:"print"})}
|
|
3494
3417
|
|
|
3495
3418
|
<!-- Step Elements -->
|
|
3496
3419
|
${i.elements.map(e=>this._renderStepElement(e))}
|
|
@@ -3500,33 +3423,28 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3500
3423
|
</div>`:l`
|
|
3501
3424
|
<div class="print-layout">
|
|
3502
3425
|
<!-- Instance Title at top -->
|
|
3503
|
-
<div class="print-instance-title">
|
|
3504
|
-
${this.instance.name||"Untitled Form"}
|
|
3505
|
-
</div>
|
|
3426
|
+
<div class="print-instance-title">${this.instance.name||"Untitled Form"}</div>
|
|
3506
3427
|
<hr class="print-question-separator" />
|
|
3507
3428
|
|
|
3508
3429
|
${this.instance.steps.map(e=>this._renderStepWithElements(e))}
|
|
3509
3430
|
</div>
|
|
3510
|
-
`}_nextStep(){var t,n,s,r;if(!this._validateStep())return;const i=this._currentStep;i&&this._captureSignaturesFromStep(i);const e=this._findNextAssignedStep(this._currentStepIndex);if(e!==-1){const o=(t=this._currentStep)==null?void 0:t.id;if(this._currentStepIndex=e,o&&((n=this.instance)!=null&&n.steps)){const d=this.instance.steps.find(p=>p.id===o);d&&(d.status="completed")}const a=(r=(s=this.instance)==null?void 0:s.steps)==null?void 0:r[this._currentStepIndex];a&&(a.status="active"),this._updateInstanceData(o,"step_navigation",{direction:"next",fromStepIndex:this._currentStepIndex-1,toStepIndex:this._currentStepIndex,completedStepId:o}),this.mode!=="admin"&&this._saveFormDataToHistory(),this._scrollToTop()}}_findNextAssignedStep(i){return this.instance?this.navigationService.findNextAssignedStep(i,this.instance):-1}_isLastAssignedStep(){return this.navigationService.isLastAssignedStep(this._currentStepIndex,this.instance)}_isLastStepInWorkflow(){var e;const i=(e=this.instance)==null?void 0:e.steps;return i?this._currentStepIndex===i.length-1:!1}_goToStep(i){var n;console.log(`🎯 _goToStep called: stepIndex=${i}, mode=${this.mode}, currentStep=${this._currentStepIndex}`);const e=this.mode==="preview"?this.workflow:this.instance;if(console.log("📊 Data source:",e?`${((n=e.steps)==null?void 0:n.length)||0} steps`:"null"),!e){console.log("❌ No data source available");return}const t=this.navigationService.canNavigateToStep(i,this._currentStepIndex,e,this._internalCompletedSteps,this._isSubmitted,this._userStepsSubmitted);console.log("🚦 Navigation result:",t),t.canNavigate?(this._currentStepIndex=t.newStepIndex,console.log(`✅ Navigated to step ${t.newStepIndex}`),this._scrollToTop()):console.log("❌ Navigation blocked:",t.reason)}_submitUserSteps(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("User completing their assigned steps:",this.instance.id),console.log("Form data:",this._formData),this._userStepsSubmitted=!0,this._clearSavedFormData("user steps submission"),this._updateInstanceData(e,"user_steps_submission"),this._scrollToTop()}_submit(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("Submitting entire workflow:",this.instance.id),console.log("Final form data:",this._formData),this.instance&&(this.instance.status="completed",this.instance.updatedAt=new Date,this.instance.currentStepId=void 0,this.instance.completedSteps=Array.from(this._internalCompletedSteps)),this._isSubmitted=!0,this._clearSavedFormData("full workflow submission"),this._scrollToTop(),this._updateInstanceData(e,"submission")}_saveStep(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot save, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;if(e&&(this._internalCompletedSteps.add(e),this.instance.steps)){const n=this.instance.steps.find(s=>s.id===e);n&&(n.status="completed")}this._updateInstanceData(e,"admin_save",{stepId:e,adminMode:!0}),this._justSaved=!0,this.requestUpdate(),setTimeout(()=>{this._justSaved=!1,this.requestUpdate()},2e3)}_clearSavedFormData(i){var e;this.persistenceManager.clearFormData((e=this.instance)==null?void 0:e.id,i)}_scrollToTop(){requestAnimationFrame(()=>{var t,n;this.scrollIntoView({behavior:"smooth",block:"start"});const i=(t=this.shadowRoot)==null?void 0:t.querySelector(".runner-layout");i&&i.scrollTo({top:0,behavior:"smooth"});const e=(n=this.shadowRoot)==null?void 0:n.querySelector(".runner-main-content");e&&e.scrollTo({top:0,behavior:"smooth"})})}_updateInstanceData(i,e,t){var d,p,c,u,h,f,b;i&&this._internalCompletedSteps.add(i);let n=(p=(d=this.instance)==null?void 0:d.steps)==null?void 0:p.find($=>$.id===i);if(!n&&this._internalCompletedSteps.size>0){const $=Array.from(this._internalCompletedSteps),ie=$[$.length-1];n=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(ne=>ne.id===ie)}const s=e==="submission",r=((h=this.instance)==null?void 0:h.steps)&&this._internalCompletedSteps.size>=this.instance.steps.length,o=s||r?null:this._currentStep?{id:this._currentStep.id,title:this._currentStep.title}:null,a={instanceId:(f=this.instance)==null?void 0:f.id,workflowId:(b=this.instance)==null?void 0:b.workflowId,completedStepId:i||(n?n.id:null),completedStepData:n?{id:n.id,title:n.title,responses:n.responses||[]}:null,completedSteps:Array.from(this._internalCompletedSteps),currentStep:o,mode:this.mode};this.dispatchEvent(new CustomEvent("instance-updated",{detail:a,bubbles:!0,composed:!0}))}_restoreFormData(){var e;if(!this.persistenceManager.shouldRestoreData(this.mode||"default")){console.log("Skipping form data restoration - showing official instance data");return}const i=this.persistenceManager.restoreFormData((e=this.instance)==null?void 0:e.id);i?(this.formStateManager.updateFormData(i.formData),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=i.stepIndex,this._savedSignatures=i.savedSignatures,this._internalCompletedSteps=i.completedSteps,this._savedInstance=i.savedInstance||void 0):this._updateCompletedStepsFromCurrentIndex()}_updateCompletedStepsFromCurrentIndex(){var i;if((i=this.instance)!=null&&i.steps){this._internalCompletedSteps=new Set(this.instance.completedSteps||[]);for(let e=0;e<this._currentStepIndex;e++)this.instance.steps[e]&&this._internalCompletedSteps.add(this.instance.steps[e].id)}}_restoreFormDataFromDOM(){this._restoreFormData(),this._restoreFormValuesToDOM()}_restoreFormValuesToDOM(){this.updateComplete.then(()=>{var e,t;(e=this.shadowRoot)!=null&&e.querySelector(".runner-step-form")&&(Object.entries(this._formData).forEach(([n,s])=>{var o;if(n.endsWith("_signatureData"))return;const r=(o=this.shadowRoot)==null?void 0:o.getElementById(n);if(r){if(r.type==="checkbox"){const a=r;typeof s=="boolean"?a.checked=s:Array.isArray(s)&&(a.checked=s.includes(a.value))}else if(r.type==="radio"){const a=r;a.checked=a.value===s}else if(r.type==="file"){const a=r;a.value=""}else r.value=String(s||"");console.log(`Restored value for ${n}:`,s)}}),this._restoreSignatures(),console.log("Form values restored to DOM elements"),this._updateInstanceWithFormData(!0),(t=this._savedInstance)!=null&&t.steps&&this._restoreInstanceResponses())})}_updateInstanceWithFormData(i=!1){this.instance&&this.instance.steps&&this.instance.steps.forEach(e=>{e.responses||(e.responses=[]),e.elements.forEach(t=>{if(t.type==="text_input"||t.type==="textarea"||t.type==="select"||t.type==="number"||t.type==="radio"||t.type==="checkbox"||t.type==="date"||t.type==="file_upload"||t.type==="signature"){const n=t,s=this._formData[n.id];if(s!==void 0&&e.responses){let r=e.responses.find(o=>o.elementId===n.id);r?(r.value=s,r.answeredAt=new Date):(r={elementId:n.id,value:s,answeredAt:new Date},e.responses.push(r))}}})})}_restoreSignatures(){Object.entries(this._formData).forEach(([i,e])=>{if(i.endsWith("_signatureData")&&e){const t=i.replace("_signatureData",""),n=this.signatureManager.getSignaturePad(t);if(n&&e)try{n.clear(),n.fromData(e)}catch{}}})}_saveFormDataToHistory(){var i;this.persistenceManager.saveFormData((i=this.instance)==null?void 0:i.id,this._formData,this._currentStepIndex,this._savedSignatures,this._internalCompletedSteps,this.instance||null)}_extractFormDataFromDOM(){var n;const i={},e=(n=this.shadowRoot)==null?void 0:n.querySelector(".runner-step-form");if(!e)return i;const t=e.elements;for(let s=0;s<t.length;s++){const r=t[s];if(r.name||r.id){const o=r.id||r.name;if(r.type==="checkbox"){const a=r;a.name&&a.name===o?(i[o]||(i[o]=[]),a.checked&&i[o].push(a.value)):i[o]=a.checked}else if(r.type==="radio"){const a=r;a.checked&&(i[o]=a.value)}else i[o]=r.value}}return i}_updateInstanceFromFormData(i=!1){const e=this._extractFormDataFromDOM();Object.keys(e).length>0?(this.formStateManager.mergeFormData(e),this._formData=this.formStateManager.getFormData(),this.instance&&this.instance.steps&&this.instance.steps.forEach(n=>{n.responses||(n.responses=[]),n.elements.forEach(s=>{if(s.type==="text_input"||s.type==="textarea"||s.type==="select"||s.type==="number"||s.type==="radio"||s.type==="checkbox"||s.type==="date"||s.type==="file_upload"||s.type==="signature"){const r=s,o=this._formData[r.id];if(o!==void 0&&n.responses){let a=n.responses.find(d=>d.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},n.responses.push(a))}}})}),console.log("Instance updated from form data:",this.instance),i&&this._updateInstanceData(void 0,"form_data_update",{updatedFormDataKeys:Object.keys(this._formData),updatedCompletedSteps:Array.from(this._internalCompletedSteps)})):console.log("No new form data to update instance with")}updateInstanceFromFormData(i=!1){this._updateInstanceFromFormData(i)}getFormData(){return this.formStateManager.getFormData()}restoreFormData(){this._restoreFormDataFromDOM()}clearSavedFormData(i){this._clearSavedFormData(i)}_renderUnifiedSubmissionView(){const i={instance:this.instance,assignedSteps:this._getAssignedSteps(),completedSteps:this._internalCompletedSteps,isStepAssignedToUser:this._isStepAssignedToUser.bind(this)};return Oe.renderUnifiedSubmissionView(i)}_isInstanceCompleted(){var i;return((i=this.instance)==null?void 0:i.status)==="completed"}_areUserStepsCompleted(){var e;if(!((e=this.instance)!=null&&e.steps))return!1;const i=this._getAssignedSteps();return i.length===0?!1:i.every(t=>t.status==="completed")}_shouldShowCompletionView(){var i;return this.mode!=="default"?!1:!!(this._isInstanceCompleted()||((i=this.instance)==null?void 0:i.status)==="active"&&this._areUserStepsCompleted())}_renderModeBasedContent(){var e,t;if(this._shouldShowCompletionView())return this._renderUnifiedSubmissionView();if(this.mode==="print")return this._renderAllStepsForPrint();const i=this.mode==="preview"?(e=this.workflow)==null?void 0:e.steps:(t=this.instance)==null?void 0:t.steps;return!i||i.length===0?l`<div class="runner-content">
|
|
3431
|
+
`}_nextStep(){var t,n,s,r;if(!this._validateStep())return;const i=this._currentStep;i&&this._captureSignaturesFromStep(i);const e=this._findNextAssignedStep(this._currentStepIndex);if(e!==-1){const o=(t=this._currentStep)==null?void 0:t.id;if(this._currentStepIndex=e,o&&((n=this.instance)!=null&&n.steps)){const d=this.instance.steps.find(p=>p.id===o);d&&(d.status="completed")}const a=(r=(s=this.instance)==null?void 0:s.steps)==null?void 0:r[this._currentStepIndex];a&&(a.status="active"),this._updateInstanceData(o,"step_navigation",{direction:"next",fromStepIndex:this._currentStepIndex-1,toStepIndex:this._currentStepIndex,completedStepId:o}),this.mode!=="admin"&&this._saveFormDataToHistory(),this._scrollToTop()}}_findNextAssignedStep(i){return this.instance?this.navigationService.findNextAssignedStep(i,this.instance):-1}_isLastAssignedStep(){return this.navigationService.isLastAssignedStep(this._currentStepIndex,this.instance)}_isLastStepInWorkflow(){var e;const i=(e=this.instance)==null?void 0:e.steps;return i?this._currentStepIndex===i.length-1:!1}_goToStep(i){var n;console.log(`🎯 _goToStep called: stepIndex=${i}, mode=${this.mode}, currentStep=${this._currentStepIndex}`);const e=this.mode==="preview"?this.workflow:this.instance;if(console.log("📊 Data source:",e?`${((n=e.steps)==null?void 0:n.length)||0} steps`:"null"),!e){console.log("❌ No data source available");return}const t=this.navigationService.canNavigateToStep(i,this._currentStepIndex,e,this._internalCompletedSteps,this._isSubmitted,this._userStepsSubmitted);console.log("🚦 Navigation result:",t),t.canNavigate?(this._currentStepIndex=t.newStepIndex,console.log(`✅ Navigated to step ${t.newStepIndex}`),this._scrollToTop()):console.log("❌ Navigation blocked:",t.reason)}_submitUserSteps(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("User completing their assigned steps:",this.instance.id),console.log("Form data:",this._formData),this._userStepsSubmitted=!0,this._clearSavedFormData("user steps submission"),this._updateInstanceData(e,"user_steps_submission"),this._scrollToTop()}_submit(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot submit, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;e&&this._internalCompletedSteps.add(e),console.log("Submitting entire workflow:",this.instance.id),console.log("Final form data:",this._formData),this.instance&&(this.instance.status="completed",this.instance.updatedAt=new Date,this.instance.currentStepId=void 0,this.instance.completedSteps=Array.from(this._internalCompletedSteps)),this._isSubmitted=!0,this._clearSavedFormData("full workflow submission"),this._scrollToTop(),this._updateInstanceData(e,"submission")}_saveStep(){var t;if(!this._validateStep())return;const i=this._currentStep;if(i&&this._captureSignaturesFromStep(i),!this.instance){console.error("Cannot save, instance data is missing.");return}const e=(t=this._currentStep)==null?void 0:t.id;if(e&&(this._internalCompletedSteps.add(e),this.instance.steps)){const n=this.instance.steps.find(s=>s.id===e);n&&(n.status="completed")}this._updateInstanceData(e,"admin_save",{stepId:e,adminMode:!0}),this._justSaved=!0,this.requestUpdate(),setTimeout(()=>{this._justSaved=!1,this.requestUpdate()},2e3)}_clearSavedFormData(i){var e;this.persistenceManager.clearFormData((e=this.instance)==null?void 0:e.id,i)}_scrollToTop(){requestAnimationFrame(()=>{var t,n;this.scrollIntoView({behavior:"smooth",block:"start"});const i=(t=this.shadowRoot)==null?void 0:t.querySelector(".runner-layout");i&&i.scrollTo({top:0,behavior:"smooth"});const e=(n=this.shadowRoot)==null?void 0:n.querySelector(".runner-main-content");e&&e.scrollTo({top:0,behavior:"smooth"})})}_updateInstanceData(i,e,t){var d,p,c,u,h,f,b;i&&this._internalCompletedSteps.add(i);let n=(p=(d=this.instance)==null?void 0:d.steps)==null?void 0:p.find($=>$.id===i);if(!n&&this._internalCompletedSteps.size>0){const $=Array.from(this._internalCompletedSteps),ie=$[$.length-1];n=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(ne=>ne.id===ie)}const s=e==="submission",r=((h=this.instance)==null?void 0:h.steps)&&this._internalCompletedSteps.size>=this.instance.steps.length,o=s||r?null:this._currentStep?{id:this._currentStep.id,title:this._currentStep.title}:null,a={instanceId:(f=this.instance)==null?void 0:f.id,workflowId:(b=this.instance)==null?void 0:b.workflowId,completedStepId:i||(n?n.id:null),completedStepData:n?{id:n.id,title:n.title,responses:n.responses||[]}:null,completedSteps:Array.from(this._internalCompletedSteps),currentStep:o,mode:this.mode};this.dispatchEvent(new CustomEvent("instance-updated",{detail:a,bubbles:!0,composed:!0}))}_restoreFormData(){var e;if(!this.persistenceManager.shouldRestoreData(this.mode||"default")){console.log("Skipping form data restoration - showing official instance data");return}const i=this.persistenceManager.restoreFormData((e=this.instance)==null?void 0:e.id);i?(this.formStateManager.updateFormData(i.formData),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=i.stepIndex,this._savedSignatures=i.savedSignatures,this._internalCompletedSteps=i.completedSteps,this._savedInstance=i.savedInstance||void 0):this._updateCompletedStepsFromCurrentIndex()}_updateCompletedStepsFromCurrentIndex(){var i;if((i=this.instance)!=null&&i.steps){this._internalCompletedSteps=new Set(this.instance.completedSteps||[]);for(let e=0;e<this._currentStepIndex;e++)this.instance.steps[e]&&this._internalCompletedSteps.add(this.instance.steps[e].id)}}_restoreFormDataFromDOM(){this._restoreFormData(),this._restoreFormValuesToDOM()}_restoreFormValuesToDOM(){this.updateComplete.then(()=>{var e,t;(e=this.shadowRoot)!=null&&e.querySelector(".runner-step-form")&&(Object.entries(this._formData).forEach(([n,s])=>{var o;if(n.endsWith("_signatureData"))return;const r=(o=this.shadowRoot)==null?void 0:o.getElementById(n);if(r){if(r.type==="checkbox"){const a=r;typeof s=="boolean"?a.checked=s:Array.isArray(s)&&(a.checked=s.includes(a.value))}else if(r.type==="radio"){const a=r;a.checked=a.value===s}else if(r.type==="file"){const a=r;a.value=""}else r.value=String(s||"");console.log(`Restored value for ${n}:`,s)}}),this._restoreSignatures(),console.log("Form values restored to DOM elements"),this._updateInstanceWithFormData(!0),(t=this._savedInstance)!=null&&t.steps&&this._restoreInstanceResponses())})}_updateInstanceWithFormData(i=!1){this.instance&&this.instance.steps&&this.instance.steps.forEach(e=>{e.responses||(e.responses=[]),e.elements.forEach(t=>{if(t.type==="text_input"||t.type==="textarea"||t.type==="select"||t.type==="number"||t.type==="radio"||t.type==="checkbox"||t.type==="date"||t.type==="file_upload"||t.type==="signature"){const n=t,s=this._formData[n.id];if(s!==void 0&&e.responses){let r=e.responses.find(o=>o.elementId===n.id);r?(r.value=s,r.answeredAt=new Date):(r={elementId:n.id,value:s,answeredAt:new Date},e.responses.push(r))}}})})}_restoreSignatures(){Object.entries(this._formData).forEach(([i,e])=>{if(i.endsWith("_signatureData")&&e){const t=i.replace("_signatureData",""),n=this.signatureManager.getSignaturePad(t);if(n&&e)try{n.clear(),n.fromData(e)}catch{}}})}_saveFormDataToHistory(){var i;this.persistenceManager.saveFormData((i=this.instance)==null?void 0:i.id,this._formData,this._currentStepIndex,this._savedSignatures,this._internalCompletedSteps,this.instance||null)}_extractFormDataFromDOM(){var n;const i={},e=(n=this.shadowRoot)==null?void 0:n.querySelector(".runner-step-form");if(!e)return i;const t=e.elements;for(let s=0;s<t.length;s++){const r=t[s];if(r.name||r.id){const o=r.id||r.name;if(r.type==="checkbox"){const a=r;a.name&&a.name===o?(i[o]||(i[o]=[]),a.checked&&i[o].push(a.value)):i[o]=a.checked}else if(r.type==="radio"){const a=r;a.checked&&(i[o]=a.value)}else i[o]=r.value}}return i}_updateInstanceFromFormData(i=!1){const e=this._extractFormDataFromDOM();Object.keys(e).length>0?(this.formStateManager.mergeFormData(e),this._formData=this.formStateManager.getFormData(),this.instance&&this.instance.steps&&this.instance.steps.forEach(n=>{n.responses||(n.responses=[]),n.elements.forEach(s=>{if(s.type==="text_input"||s.type==="textarea"||s.type==="select"||s.type==="number"||s.type==="radio"||s.type==="checkbox"||s.type==="date"||s.type==="file_upload"||s.type==="signature"){const r=s,o=this._formData[r.id];if(o!==void 0&&n.responses){let a=n.responses.find(d=>d.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},n.responses.push(a))}}})}),console.log("Instance updated from form data:",this.instance),i&&this._updateInstanceData(void 0,"form_data_update",{updatedFormDataKeys:Object.keys(this._formData),updatedCompletedSteps:Array.from(this._internalCompletedSteps)})):console.log("No new form data to update instance with")}updateInstanceFromFormData(i=!1){this._updateInstanceFromFormData(i)}getFormData(){return this.formStateManager.getFormData()}restoreFormData(){this._restoreFormDataFromDOM()}clearSavedFormData(i){this._clearSavedFormData(i)}_renderUnifiedSubmissionView(){const i={instance:this.instance,assignedSteps:this._getAssignedSteps(),completedSteps:this._internalCompletedSteps,isStepAssignedToUser:this._isStepAssignedToUser.bind(this)};return Ne.renderUnifiedSubmissionView(i)}_isInstanceCompleted(){var i;return((i=this.instance)==null?void 0:i.status)==="completed"}_areUserStepsCompleted(){var e;if(!((e=this.instance)!=null&&e.steps))return!1;const i=this._getAssignedSteps();return i.length===0?!1:i.every(t=>t.status==="completed")}_shouldShowCompletionView(){var i;return this.mode!=="default"?!1:!!(this._isInstanceCompleted()||((i=this.instance)==null?void 0:i.status)==="active"&&this._areUserStepsCompleted())}_renderModeBasedContent(){var e,t;if(this._shouldShowCompletionView())return this._renderUnifiedSubmissionView();if(this.mode==="print")return this._renderAllStepsForPrint();const i=this.mode==="preview"?(e=this.workflow)==null?void 0:e.steps:(t=this.instance)==null?void 0:t.steps;return!i||i.length===0?l`<div class="runner-content">
|
|
3511
3432
|
${this.mode==="preview"?"No workflow loaded or workflow has no steps.":"No workflow instance loaded or instance has no steps."}
|
|
3512
3433
|
</div>`:this.mode==="default"&&this._getAssignedSteps().length===0?this._renderNotAssignedView():null}_validateCurrentStep(){return this._currentStep}_initializeStepAssets(i){this.updateComplete.then(()=>{i.elements.forEach(e=>{var t;e.type==="signature"&&((t=this.shadowRoot)!=null&&t.getElementById(`signature-${e.id}`))&&this._initializeSignaturePad(e.id)}),this._restoreSignatures(),setTimeout(()=>{this._formRestorationComplete||(this._restoreFormDataFromDOM(),this._formRestorationComplete=!0)},100)})}_renderCurrentStepLayout(i){var s,r;const e=this._isLastAssignedStep(),t=this._isLastStepInWorkflow(),n=this.mode==="preview"?(s=this.workflow)==null?void 0:s.steps:(r=this.instance)==null?void 0:r.steps;return l`
|
|
3513
3434
|
<!-- Mobile Steps Navigation (visible only on mobile) -->
|
|
3514
|
-
${
|
|
3435
|
+
${Y.renderMobileSteps({steps:n,currentStepIndex:this._currentStepIndex,mode:this.mode||"default",isSubmitted:this._isSubmitted,userStepsSubmitted:this._userStepsSubmitted,completedSteps:this._internalCompletedSteps,isLoading:this.isLoading,isStepAssignedToUser:this._isStepAssignedToUser.bind(this),goToStep:this._goToStep.bind(this)})}
|
|
3515
3436
|
|
|
3516
3437
|
<!-- Sidebar: Steps List (hidden on mobile) -->
|
|
3517
|
-
${
|
|
3438
|
+
${Y.renderSidebar({steps:n,currentStepIndex:this._currentStepIndex,mode:this.mode||"default",isSubmitted:this._isSubmitted,userStepsSubmitted:this._userStepsSubmitted,completedSteps:this._internalCompletedSteps,isLoading:this.isLoading,isStepAssignedToUser:this._isStepAssignedToUser.bind(this),goToStep:this._goToStep.bind(this)})}
|
|
3518
3439
|
|
|
3519
3440
|
<!-- Main Content: Step Details and Questions -->
|
|
3520
3441
|
<main class="runner-main-content">
|
|
3521
|
-
${this.mode==="print"?
|
|
3522
|
-
${
|
|
3442
|
+
${this.mode==="print"?Y.renderStepHeader({step:i,mode:this.mode}):l`<div class="runner-card">
|
|
3443
|
+
${Y.renderStepHeader({step:i,mode:this.mode})}
|
|
3523
3444
|
</div>`}
|
|
3524
|
-
<form
|
|
3525
|
-
class="runner-step-form"
|
|
3526
|
-
@submit=${o=>o.preventDefault()}
|
|
3527
|
-
>
|
|
3445
|
+
<form class="runner-step-form" @submit=${o=>o.preventDefault()}>
|
|
3528
3446
|
${i.elements.map(o=>this._renderStepElement(o))}
|
|
3529
|
-
${
|
|
3447
|
+
${Dt.renderFormActions({mode:this.mode||"default",isLastStep:e,isLastStepInWorkflow:t,justSaved:this._justSaved,isCurrentStepAssigned:this._isCurrentStepAssigned(),handlers:{saveStep:this._saveStep.bind(this),nextStep:this._nextStep.bind(this),submitUserSteps:this._submitUserSteps.bind(this),submit:this._submit.bind(this)}})}
|
|
3530
3448
|
</form>
|
|
3531
3449
|
</main>
|
|
3532
3450
|
`}_renderMainContent(){const i=this._renderModeBasedContent();if(i)return i;const e=this._validateCurrentStep();return e?(this._initializeStepAssets(e),this._renderCurrentStepLayout(e)):l`<div class="runner-content">Invalid current step.</div>`}render(){return l`
|
|
@@ -3543,7 +3461,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3543
3461
|
</div>
|
|
3544
3462
|
`:""}
|
|
3545
3463
|
</div>
|
|
3546
|
-
`}};m.styles=[Pe],m.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"],m.CONTENT_ELEMENT_TYPES=["text","html","image","video","file","divider","markdown"],x([C({type:Object})],m.prototype,"instance",2),x([C({type:Object})],m.prototype,"workflow",2),x([C({type:String})],m.prototype,"mode",2),x([C({type:Boolean})],m.prototype,"isLoading",2),x([C({type:Object})],m.prototype,"currentUser",2),x([C({type:Function})],m.prototype,"onSignatureCaptured",2),x([C({type:Function})],m.prototype,"onFileUploaded",2),x([_()],m.prototype,"_currentStepIndex",2),x([_()],m.prototype,"_formData",2),x([_()],m.prototype,"_validationErrors",2),x([_()],m.prototype,"_internalCompletedSteps",2),x([_()],m.prototype,"_formRestorationComplete",2),x([_()],m.prototype,"_savedSignatures",2),x([_()],m.prototype,"_replacingSignatures",2),x([_()],m.prototype,"_savedInstance",2),x([_()],m.prototype,"_isSubmitted",2),x([_()],m.prototype,"_userStepsSubmitted",2),x([_()],m.prototype,"_justSaved",2),m=x([
|
|
3464
|
+
`}};m.styles=[Pe],m.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"],m.CONTENT_ELEMENT_TYPES=["text","html","image","video","file","divider","markdown"],x([C({type:Object})],m.prototype,"instance",2),x([C({type:Object})],m.prototype,"workflow",2),x([C({type:String})],m.prototype,"mode",2),x([C({type:Boolean})],m.prototype,"isLoading",2),x([C({type:Object})],m.prototype,"currentUser",2),x([C({type:Function})],m.prototype,"onSignatureCaptured",2),x([C({type:Function})],m.prototype,"onFileUploaded",2),x([_()],m.prototype,"_currentStepIndex",2),x([_()],m.prototype,"_formData",2),x([_()],m.prototype,"_validationErrors",2),x([_()],m.prototype,"_internalCompletedSteps",2),x([_()],m.prototype,"_formRestorationComplete",2),x([_()],m.prototype,"_savedSignatures",2),x([_()],m.prototype,"_replacingSignatures",2),x([_()],m.prototype,"_savedInstance",2),x([_()],m.prototype,"_isSubmitted",2),x([_()],m.prototype,"_userStepsSubmitted",2),x([_()],m.prototype,"_justSaved",2),m=x([Ue("runner-widget")],m);function At(i,e={}){const{title:t=i.name||"Workflow Instance",includeStyles:n=!0,customCSS:s="",showTimestamps:r=!1}=e,o=new Date;if(!(i!=null&&i.steps)||i.steps.length===0)throw new Error("Instance must have at least one step to generate HTML");return{html:`<!DOCTYPE html>
|
|
3547
3465
|
<html lang="en">
|
|
3548
3466
|
<head>
|
|
3549
3467
|
<meta charset="UTF-8">
|
|
@@ -3560,18 +3478,18 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3560
3478
|
</div>
|
|
3561
3479
|
<hr class="print-question-separator" />
|
|
3562
3480
|
|
|
3563
|
-
${r?
|
|
3564
|
-
${i.steps.map(d=>
|
|
3481
|
+
${r?jt(i,o):""}
|
|
3482
|
+
${i.steps.map(d=>Mt(d)).join(`
|
|
3565
3483
|
`)}
|
|
3566
3484
|
</div>
|
|
3567
3485
|
</body>
|
|
3568
|
-
</html>`,title:t,generatedAt:o}}function
|
|
3486
|
+
</html>`,title:t,generatedAt:o}}function Mt(i){return`
|
|
3569
3487
|
<div class="print-step">
|
|
3570
3488
|
<!-- Step Header -->
|
|
3571
3489
|
${Ft(i)}
|
|
3572
3490
|
|
|
3573
3491
|
<!-- Step Elements -->
|
|
3574
|
-
${i.elements.map(e=>
|
|
3492
|
+
${i.elements.map(e=>Tt(e,i)).join(`
|
|
3575
3493
|
`)}
|
|
3576
3494
|
</div>
|
|
3577
3495
|
`}function Ft(i){return`
|
|
@@ -3580,11 +3498,11 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3580
3498
|
${i.description?`<div class="print-step-description">${g(i.description)}</div>`:""}
|
|
3581
3499
|
<hr class="print-question-separator" />
|
|
3582
3500
|
</div>
|
|
3583
|
-
`}function
|
|
3501
|
+
`}function Tt(i,e){return Ht(i)?zt(i,e):Ut(i)}function zt(i,e){const t=Vt(i.id,e.responses),n=t==null?void 0:t.value,r=i.type==="checkbox"&&(!i.options||i.options.length===0)?"":`
|
|
3584
3502
|
<div class="print-question-title">
|
|
3585
3503
|
${g(i.label)}:
|
|
3586
3504
|
</div>
|
|
3587
|
-
`,o='<hr class="print-question-separator" />';switch(i.type){case"text_input":case"number":case"date":return r+
|
|
3505
|
+
`,o='<hr class="print-question-separator" />';switch(i.type){case"text_input":case"number":case"date":return r+It(i,n)+o;case"textarea":return r+Pt(i,n)+o;case"select":return r+Lt(i,n)+o;case"radio":return r+Nt(i,n)+o;case"checkbox":return r+Ot(i,n)+o;case"file_upload":return r+Rt(i,n)+o;case"signature":return r+Wt(i,n)+o;default:return r+`
|
|
3588
3506
|
<div class="unknown-element">
|
|
3589
3507
|
<p>⚠️ Unknown question type: ${g(i.type)}</p>
|
|
3590
3508
|
</div>
|
|
@@ -3663,23 +3581,23 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3663
3581
|
</div>
|
|
3664
3582
|
${e}
|
|
3665
3583
|
</div>
|
|
3666
|
-
`}}function
|
|
3584
|
+
`}}function It(i,e){const t=e!=null?g(String(e)):"";return`
|
|
3667
3585
|
<div class="print-response-value input-response">
|
|
3668
3586
|
${(i.type==="date"&&e?new Date(e).toLocaleDateString():t)||'<span class="print-no-response">No response</span>'}
|
|
3669
3587
|
</div>
|
|
3670
|
-
`}function
|
|
3588
|
+
`}function Pt(i,e){return`
|
|
3671
3589
|
<div class="print-response-value textarea-response">
|
|
3672
3590
|
${(e!=null?g(String(e)):"")||'<span class="print-no-response">No response</span>'}
|
|
3673
3591
|
</div>
|
|
3674
|
-
`}function
|
|
3592
|
+
`}function Lt(i,e){const t=e!=null?String(e):"";return`
|
|
3675
3593
|
<div class="print-response-value select-response">
|
|
3676
3594
|
${t?g(t):'<span class="print-no-response">No selection made</span>'}
|
|
3677
3595
|
</div>
|
|
3678
|
-
`}function
|
|
3596
|
+
`}function Nt(i,e){const t=e!=null?String(e):"";return`
|
|
3679
3597
|
<div class="print-response-value radio-response">
|
|
3680
3598
|
${t?g(t):'<span class="print-no-response">No selection made</span>'}
|
|
3681
3599
|
</div>
|
|
3682
|
-
`}function
|
|
3600
|
+
`}function Ot(i,e){if((i.options||[]).length===0)return`
|
|
3683
3601
|
<div class="print-response-value checkbox-response">
|
|
3684
3602
|
${e===!0||e==="true"?"Yes":"No"}
|
|
3685
3603
|
</div>
|
|
@@ -3687,12 +3605,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3687
3605
|
<div class="print-response-value checkbox-response">
|
|
3688
3606
|
${n.length>0?n.map(s=>`<div>• ${g(s)}</div>`).join(""):'<span class="print-no-response">No selections made</span>'}
|
|
3689
3607
|
</div>
|
|
3690
|
-
`}}function
|
|
3608
|
+
`}}function Rt(i,e){if(!e)return'<div class="print-response-value file-response"><span class="print-no-response">No file uploaded</span></div>';const t=typeof e=="string";if(typeof e=="object"&&e.name)return`
|
|
3691
3609
|
<div class="print-response-value file-response">
|
|
3692
3610
|
📎 ${g(e.name)}
|
|
3693
|
-
${e.size?` <span class="file-size">(${
|
|
3611
|
+
${e.size?` <span class="file-size">(${Qt(e.size)})</span>`:""}
|
|
3694
3612
|
</div>
|
|
3695
|
-
`;if(t){const s=
|
|
3613
|
+
`;if(t){const s=Bt(e);return`
|
|
3696
3614
|
<div class="print-response-value file-response">
|
|
3697
3615
|
📎 ${g(s)}
|
|
3698
3616
|
</div>
|
|
@@ -3700,7 +3618,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3700
3618
|
<div class="print-response-value file-response">
|
|
3701
3619
|
📎 ${g(String(e))}
|
|
3702
3620
|
</div>
|
|
3703
|
-
`}function
|
|
3621
|
+
`}function Wt(i,e){if(!e)return'<div class="print-response-value signature-response"><span class="print-no-response">No signature provided</span></div>';const t=typeof e=="string"?e:e.url||e.dataURL;return t?`
|
|
3704
3622
|
<div class="print-response-value signature-response">
|
|
3705
3623
|
<img
|
|
3706
3624
|
src="${g(t)}"
|
|
@@ -3712,7 +3630,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3712
3630
|
<div class="signature-fallback">
|
|
3713
3631
|
<div class="signature-error">Unable to display signature</div>
|
|
3714
3632
|
</div>
|
|
3715
|
-
`}function
|
|
3633
|
+
`}function Ht(i){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(i.type)}function Vt(i,e){return e==null?void 0:e.find(t=>t.elementId===i)}function jt(i,e){return`
|
|
3716
3634
|
<div class="runner-card" style="margin-bottom: 40px; border-left: 4px solid #3b82f6;">
|
|
3717
3635
|
<div style="display: flex; justify-content: between; align-items: center; gap: 20px;">
|
|
3718
3636
|
<div>
|
|
@@ -3730,7 +3648,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
3730
3648
|
</div>
|
|
3731
3649
|
</div>
|
|
3732
3650
|
</div>
|
|
3733
|
-
`}function g(i){if(i==null)return"";const e=String(i);return{innerHTML:""}.innerHTML||e.replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n])}function
|
|
3651
|
+
`}function g(i){if(i==null)return"";const e=String(i);return{innerHTML:""}.innerHTML||e.replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n])}function Qt(i){if(i===0)return"0 Bytes";const e=1024,t=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(i)/Math.log(e));return parseFloat((i/Math.pow(e,n)).toFixed(2))+" "+t[n]}function Bt(i){try{return new URL(i).pathname.split("/").pop()||""||"Uploaded File"}catch{const e=i.split("/"),t=e[e.length-1];return t&&t.includes(".")?t:"Uploaded File"}}function Gt(i){return i==null?"":String(i).replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`(.*)`/gim,"<code>$1</code>").replace(/\n/gim,"<br>")}function Yt(){return`
|
|
3734
3652
|
/* Print Layout Styles - Extracted from step-styles.ts */
|
|
3735
3653
|
.print-layout {
|
|
3736
3654
|
width: 100%;
|
|
@@ -4235,4 +4153,4 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
|
|
|
4235
4153
|
margin: 2px 0;
|
|
4236
4154
|
line-height: 1.4;
|
|
4237
4155
|
}
|
|
4238
|
-
`}function
|
|
4156
|
+
`}function qt(i,e={}){if(!customElements.get("builder-widget"))return console.error("Error: <builder-widget> is not defined. Make sure it was imported."),null;const t=document.getElementById(i);if(!t)return console.error(`Error: Target element with ID '${i}' not found.`),null;t.innerHTML="";const n=document.createElement("builder-widget");return e.onWorkflowCreated&&(n.onWorkflowCreated=e.onWorkflowCreated),e.onWorkflowDeleted&&(n.onWorkflowDeleted=e.onWorkflowDeleted),e.onWorkflowUpdated&&(n.onWorkflowUpdated=e.onWorkflowUpdated),t.appendChild(n),console.log(`Drill Builder mounted on #${i}`),n}function Kt(i,e){if(!customElements.get("runner-widget"))return console.error("Error: <runner-widget> is not defined. Make sure it was imported."),null;const t=document.getElementById(i);if(!t)return console.error(`Error: Target element with ID '${i}' not found.`),null;if(e.mode==="preview"){if(!e||!e.workflow)return console.error("Error: Workflow data must be provided for preview mode."),t.innerHTML='<p style="color: red;">Error: Workflow data required for preview mode.</p>',null;if(!e.workflow.steps||e.workflow.steps.length===0)return console.error("Error: Workflow provided to runner has no steps defined."),t.innerHTML='<p style="color: red;">Error: Workflow has no steps.</p>',null}else{if(!e||!e.instance)return console.error("Error: Instance data must be provided in runner config."),t.innerHTML='<p style="color: red;">Error: Instance data required.</p>',null;if(!e.instance.steps||e.instance.steps.length===0)return console.error("Error: Instance provided to runner has no steps defined."),t.innerHTML='<p style="color: red;">Error: Instance has no steps.</p>',null}t.innerHTML="";const n=document.createElement("runner-widget");return e.mode==="preview"?(n.workflow=e.workflow,n.mode="preview"):(n.instance=e.instance,n.mode=e.mode||"default"),e.mode&&(n.mode=e.mode),e.isLoading!==void 0&&(n.isLoading=e.isLoading),e.onSignatureCaptured&&(n.onSignatureCaptured=e.onSignatureCaptured),e.onFileUploaded&&(n.onFileUploaded=e.onFileUploaded),e.currentUser&&(n.currentUser=e.currentUser),e.onInstanceUpdated&&n.addEventListener("instance-updated",s=>{const r=s;try{e.onInstanceUpdated(r.detail)}catch(o){console.error("Error executing onInstanceUpdated callback:",o)}}),t.appendChild(n),console.log(`Drill Runner mounted on #${i}`),n}function Jt(i,e){const t=i.getFormData(),n=JSON.parse(JSON.stringify(e));return n.steps&&n.steps.forEach(s=>{s.responses||(s.responses=[]),s.elements.forEach(r=>{if(r.type==="text_input"||r.type==="textarea"||r.type==="select"||r.type==="number"||r.type==="radio"||r.type==="checkbox"||r.type==="date"||r.type==="file_upload"||r.type==="signature"){const o=t[r.id];if(o!==void 0){let a=s.responses.find(d=>d.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},s.responses.push(a))}}})}),n}function Xt(i,e){const t={};e.steps&&e.steps.forEach(n=>{n.responses&&n.responses.forEach(s=>{t[s.elementId]=s.value})}),i.restoreFormData(),console.log("Form data restored to runner widget:",t)}D.createBuilder=qt,D.createRunner=Kt,D.generateInstanceHTML=At,D.restoreFormDataToRunner=Xt,D.updateInstanceFromRunnerForm=Jt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|