drill-widgets 2.7.10 → 2.7.11

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.
@@ -1,34 +1,34 @@
1
- (function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D.Drill={}))})(this,function(D){"use strict";/**
1
+ (function(C,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(C=typeof globalThis<"u"?globalThis:C||self,M(C.Drill={}))})(this,function(C){"use strict";/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */var Oe;const A=globalThis,re=A.ShadowRoot&&(A.ShadyCSS===void 0||A.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,oe=Symbol(),xe=new WeakMap;let _e=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==oe)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(re&&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,oe),N=(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,oe)},We=(i,e)=>{if(re)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=re?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return Re(t)})(i):i;/**
5
+ */var Oe;const M=globalThis,re=M.ShadowRoot&&(M.ShadyCSS===void 0||M.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,oe=Symbol(),xe=new WeakMap;let _e=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==oe)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(re&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=xe.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&xe.set(t,e))}return e}toString(){return this.cssText}};const Re=s=>new _e(typeof s=="string"?s:s+"",void 0,oe),N=(s,...e)=>{const t=s.length===1?s[0]:e.reduce((i,n,r)=>i+(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.")})(n)+s[r+1],s[0]);return new _e(t,s,oe)},He=(s,e)=>{if(re)s.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=M.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,s.appendChild(i)}},ye=re?s=>s:s=>s instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Re(t)})(s):s;/**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:He,defineProperty:Ve,getOwnPropertyDescriptor:je,getOwnPropertyNames:Qe,getOwnPropertySymbols:Be,getPrototypeOf:Ge}=Object,M=globalThis,ye=M.trustedTypes,Ye=ye?ye.emptyScript:"",ae=M.reactiveElementPolyfillSupport,H=(i,e)=>i,K={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}},le=(i,e)=>!He(i,e),we={attribute:!0,type:String,converter:K,reflect:!1,useDefault:!1,hasChanged:le};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),M.litPropertyMetadata??(M.litPropertyMetadata=new WeakMap);let O=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(H("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(H("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(H("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:K).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),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:K;this._$Em=s,this[s]=l.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??le)(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,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}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){}};O.elementStyles=[],O.shadowRootOptions={mode:"open"},O[H("elementProperties")]=new Map,O[H("finalized")]=new Map,ae==null||ae({ReactiveElement:O}),(M.reactiveElementVersions??(M.reactiveElementVersions=[])).push("2.1.0");/**
9
+ */const{is:We,defineProperty:Ve,getOwnPropertyDescriptor:je,getOwnPropertyNames:Be,getOwnPropertySymbols:Qe,getPrototypeOf:Ge}=Object,T=globalThis,we=T.trustedTypes,Ye=we?we.emptyScript:"",ae=T.reactiveElementPolyfillSupport,W=(s,e)=>s,K={toAttribute(s,e){switch(e){case Boolean:s=s?Ye:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,e){let t=s;switch(e){case Boolean:t=s!==null;break;case Number:t=s===null?null:Number(s);break;case Object:case Array:try{t=JSON.parse(s)}catch{t=null}}return t}},le=(s,e)=>!We(s,e),Se={attribute:!0,type:String,converter:K,reflect:!1,useDefault:!1,hasChanged:le};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),T.litPropertyMetadata??(T.litPropertyMetadata=new WeakMap);let O=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=Se){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 i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&Ve(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:r}=je(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:n,set(o){const a=n==null?void 0:n.call(this);r==null||r.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Se}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,i=[...Be(t),...Qe(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(ye(n))}else e!==void 0&&t.push(ye(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i: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 i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return He(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 i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var r;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:K).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(e,t){var r,o;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const a=i.getPropertyOptions(n),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)==null?void 0:r.fromAttribute)!==void 0?a.converter:K;this._$Em=n,this[n]=l.fromAttribute(t,a.type)??((o=this._$Ej)==null?void 0:o.get(n))??null,this._$Em=null}}requestUpdate(e,t,i){var n;if(e!==void 0){const r=this.constructor,o=this[e];if(i??(i=r.getPropertyOptions(e)),!((i.hasChanged??le)(o,t)||i.useDefault&&i.reflect&&o===((n=this._$Ej)==null?void 0:n.get(e))&&!this.hasAttribute(r._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:n,wrapped:r},o){i&&!(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||i||(t=void 0),this._$AL.set(e,t)),n===!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 i;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 n=this.constructor.elementProperties;if(n.size>0)for(const[r,o]of n){const{wrapped:a}=o,l=this[r];a!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,o,l)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(n=>{var r;return(r=n.hostUpdate)==null?void 0:r.call(n)}),this.update(t)):this._$EM()}catch(n){throw e=!1,this._$EM(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),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){}};O.elementStyles=[],O.shadowRootOptions={mode:"open"},O[W("elementProperties")]=new Map,O[W("finalized")]=new Map,ae==null||ae({ReactiveElement:O}),(T.reactiveElementVersions??(T.reactiveElementVersions=[])).push("2.1.0");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const V=globalThis,J=V.trustedTypes,ke=J?J.createPolicy("lit-html",{createHTML:i=>i}):void 0,$e="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,De="?"+T,qe=`<${De}>`,F=document,j=()=>F.createComment(""),Q=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",pe=`[
14
- \f\r]`,B=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ce=/-->/g,Ee=/>/g,z=RegExp(`>|${pe}(?:([^\\s"'>=/]+)(${pe}*=${pe}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Ae=/'/g,Me=/"/g,Te=/^(?:script|style|textarea|title)$/i,Je=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),d=Je(1),I=Symbol.for("lit-noChange"),v=Symbol.for("lit-nothing"),Fe=new WeakMap,U=F.createTreeWalker(F,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=B;for(let a=0;a<t;a++){const l=i[a];let p,c,u=-1,h=0;for(;h<l.length&&(o.lastIndex=h,c=o.exec(l),c!==null);)h=o.lastIndex,o===B?c[1]==="!--"?o=Ce:c[1]!==void 0?o=Ee:c[2]!==void 0?(Te.test(c[2])&&(s=RegExp("</"+c[2],"g")),o=z):c[3]!==void 0&&(o=z):o===z?c[0]===">"?(o=s??B,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=B:(o=z,s=void 0);const f=o===z&&i[a+1].startsWith("/>")?" ":"";r+=o===B?l+qe:u>=0?(n.push(p),l.slice(0,u)+$e+l.slice(u)+T+f):l+T+(u===-2?a:f)}return[ze(i,r+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class G{constructor({strings:e,_$litType$:t},n){let s;this.parts=[];let r=0,o=0;const a=e.length-1,l=this.parts,[p,c]=Xe(e,t);if(this.el=G.createElement(p,n),U.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=U.nextNode())!==null&&l.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(T),b=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:b[2],strings:f,ctor:b[1]==="."?et:b[1]==="?"?tt:b[1]==="@"?it:X}),s.removeAttribute(u)}else u.startsWith(T)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(Te.test(s.tagName)){const u=s.textContent.split(T),h=u.length-1;if(h>0){s.textContent=J?J.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],j()),U.nextNode(),l.push({type:2,index:++r});s.append(u[h],j())}}}else if(s.nodeType===8)if(s.data===De)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(T,u+1))!==-1;)l.push({type:7,index:r}),u+=T.length-1}r++}}static createElement(e,t){const n=F.createElement("template");return n.innerHTML=e,n}}function R(i,e,t=i,n){var o,a;if(e===I)return e;let s=n!==void 0?(o=t._$Co)==null?void 0:o[n]:t._$Cl;const r=Q(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=R(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)??F).importNode(t,!0);U.currentNode=s;let r=U.nextNode(),o=0,a=0,l=n[0];for(;l!==void 0;){if(o===l.index){let p;l.type===2?p=new Y(r,r.nextSibling,this,e):l.type===1?p=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(p=new nt(r,this,e)),this._$AV.push(p),l=n[++a]}o!==(l==null?void 0:l.index)&&(r=U.nextNode(),o++)}return U.currentNode=F,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 Y{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=R(this,e,t),Q(e)?e===v||e==null||e===""?(this._$AH!==v&&this._$AR(),this._$AH=v):e!==this._$AH&&e!==I&&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&&Q(this._$AH)?this._$AA.nextSibling.data=e:this.T(F.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=G.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=Fe.get(e.strings);return t===void 0&&Fe.set(e.strings,t=new G(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 Y(this.O(j()),this.O(j()),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 X{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=R(this,e,t,0),o=!Q(e)||e!==this._$AH&&e!==I,o&&(this._$AH=e);else{const a=e;let l,p;for(e=r[0],l=0;l<r.length-1;l++)p=R(this,a[n+l],t,l),p===I&&(p=this._$AH[l]),o||(o=!Q(p)||p!==this._$AH[l]),p===v?e=v:e!==v&&(e+=(p??"")+r[l+1]),this._$AH[l]=p}o&&!s&&this.j(e)}j(e){e===v?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class et extends X{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===v?void 0:e}}class tt extends X{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==v)}}class it extends X{constructor(e,t,n,s,r){super(e,t,n,s,r),this.type=5}_$AI(e,t=this){if((e=R(this,e,t,0)??v)===I)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){R(this,e)}}const ce=V.litHtmlPolyfillSupport;ce==null||ce(G,Y),(V.litHtmlVersions??(V.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 Y(e.insertBefore(j(),r),r,void 0,t??{})}return s._$AI(i),s};/**
13
+ */const V=globalThis,J=V.trustedTypes,ke=J?J.createPolicy("lit-html",{createHTML:s=>s}):void 0,$e="$lit$",F=`lit$${Math.random().toFixed(9).slice(2)}$`,De="?"+F,qe=`<${De}>`,I=document,j=()=>I.createComment(""),B=s=>s===null||typeof s!="object"&&typeof s!="function",de=Array.isArray,Ke=s=>de(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",pe=`[
14
+ \f\r]`,Q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ce=/-->/g,Ee=/>/g,z=RegExp(`>|${pe}(?:([^\\s"'>=/]+)(${pe}*=${pe}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ae=/'/g,Me=/"/g,Te=/^(?:script|style|textarea|title)$/i,Je=s=>(e,...t)=>({_$litType$:s,strings:e,values:t}),d=Je(1),U=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),Fe=new WeakMap,P=I.createTreeWalker(I,129);function Ie(s,e){if(!de(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return ke!==void 0?ke.createHTML(e):e}const Xe=(s,e)=>{const t=s.length-1,i=[];let n,r=e===2?"<svg>":e===3?"<math>":"",o=Q;for(let a=0;a<t;a++){const l=s[a];let p,c,u=-1,h=0;for(;h<l.length&&(o.lastIndex=h,c=o.exec(l),c!==null);)h=o.lastIndex,o===Q?c[1]==="!--"?o=Ce:c[1]!==void 0?o=Ee:c[2]!==void 0?(Te.test(c[2])&&(n=RegExp("</"+c[2],"g")),o=z):c[3]!==void 0&&(o=z):o===z?c[0]===">"?(o=n??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,n=void 0);const m=o===z&&s[a+1].startsWith("/>")?" ":"";r+=o===Q?l+qe:u>=0?(i.push(p),l.slice(0,u)+$e+l.slice(u)+F+m):l+F+(u===-2?a:m)}return[Ie(s,r+(s[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class G{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let r=0,o=0;const a=e.length-1,l=this.parts,[p,c]=Xe(e,t);if(this.el=G.createElement(p,i),P.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(n=P.nextNode())!==null&&l.length<a;){if(n.nodeType===1){if(n.hasAttributes())for(const u of n.getAttributeNames())if(u.endsWith($e)){const h=c[o++],m=n.getAttribute(u).split(F),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:v[2],strings:m,ctor:v[1]==="."?et:v[1]==="?"?tt:v[1]==="@"?it:X}),n.removeAttribute(u)}else u.startsWith(F)&&(l.push({type:6,index:r}),n.removeAttribute(u));if(Te.test(n.tagName)){const u=n.textContent.split(F),h=u.length-1;if(h>0){n.textContent=J?J.emptyScript:"";for(let m=0;m<h;m++)n.append(u[m],j()),P.nextNode(),l.push({type:2,index:++r});n.append(u[h],j())}}}else if(n.nodeType===8)if(n.data===De)l.push({type:2,index:r});else{let u=-1;for(;(u=n.data.indexOf(F,u+1))!==-1;)l.push({type:7,index:r}),u+=F.length-1}r++}}static createElement(e,t){const i=I.createElement("template");return i.innerHTML=e,i}}function R(s,e,t=s,i){var o,a;if(e===U)return e;let n=i!==void 0?(o=t._$Co)==null?void 0:o[i]:t._$Cl;const r=B(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==r&&((a=n==null?void 0:n._$AO)==null||a.call(n,!1),r===void 0?n=void 0:(n=new r(s),n._$AT(s,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=n:t._$Cl=n),n!==void 0&&(e=R(s,n._$AS(s,e.values),n,i)),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:i}=this._$AD,n=((e==null?void 0:e.creationScope)??I).importNode(t,!0);P.currentNode=n;let r=P.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let p;l.type===2?p=new Y(r,r.nextSibling,this,e):l.type===1?p=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(p=new st(r,this,e)),this._$AV.push(p),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=P.nextNode(),o++)}return P.currentNode=I,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class Y{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=x,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=R(this,e,t),B(e)?e===x||e==null||e===""?(this._$AH!==x&&this._$AR(),this._$AH=x):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!==x&&B(this._$AH)?this._$AA.nextSibling.data=e:this.T(I.createTextNode(e)),this._$AH=e}$(e){var r;const{values:t,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=G.createElement(Ie(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===n)this._$AH.p(t);else{const o=new Ze(n,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=Fe.get(e.strings);return t===void 0&&Fe.set(e.strings,t=new G(e)),t}k(e){de(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const r of e)n===t.length?t.push(i=new Y(this.O(j()),this.O(j()),this,this.options)):i=t[n],i._$AI(r),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class X{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,r){this.type=1,this._$AH=x,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=x}_$AI(e,t=this,i,n){const r=this.strings;let o=!1;if(r===void 0)e=R(this,e,t,0),o=!B(e)||e!==this._$AH&&e!==U,o&&(this._$AH=e);else{const a=e;let l,p;for(e=r[0],l=0;l<r.length-1;l++)p=R(this,a[i+l],t,l),p===U&&(p=this._$AH[l]),o||(o=!B(p)||p!==this._$AH[l]),p===x?e=x:e!==x&&(e+=(p??"")+r[l+1]),this._$AH[l]=p}o&&!n&&this.j(e)}j(e){e===x?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class et extends X{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===x?void 0:e}}class tt extends X{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==x)}}class it extends X{constructor(e,t,i,n,r){super(e,t,i,n,r),this.type=5}_$AI(e,t=this){if((e=R(this,e,t,0)??x)===U)return;const i=this._$AH,n=e===x&&i!==x||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==x&&(i===x||n);n&&this.element.removeEventListener(this.name,this,i),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 st{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){R(this,e)}}const ce=V.litHtmlPolyfillSupport;ce==null||ce(G,Y),(V.litHtmlVersions??(V.litHtmlVersions=[])).push("3.3.0");const nt=(s,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let n=i._$litPart$;if(n===void 0){const r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=n=new Y(e.insertBefore(j(),r),r,void 0,t??{})}return n._$AI(s),n};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */const P=globalThis;let W=class extends O{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 I}};W._$litElement$=!0,W.finalized=!0,(Oe=P.litElementHydrateSupport)==null||Oe.call(P,{LitElement:W});const ue=P.litElementPolyfillSupport;ue==null||ue({LitElement:W}),(P.litElementVersions??(P.litElementVersions=[])).push("4.2.0");/**
19
+ */const L=globalThis;let H=class extends O{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=nt(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}};H._$litElement$=!0,H.finalized=!0,(Oe=L.litElementHydrateSupport)==null||Oe.call(L,{LitElement:H});const ue=L.litElementPolyfillSupport;ue==null||ue({LitElement:H}),(L.litElementVersions??(L.litElementVersions=[])).push("4.2.0");/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const Ie=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};/**
23
+ */const ze=s=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(s,e)}):customElements.define(s,e)};/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */const rt={attribute:!0,type:String,converter:K,reflect:!1,hasChanged:le},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 l=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,l,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 l=this[o];e.call(this,a),this.requestUpdate(o,l,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)}/**
27
+ */const rt={attribute:!0,type:String,converter:K,reflect:!1,hasChanged:le},ot=(s=rt,e,t)=>{const{kind:i,metadata:n}=t;let r=globalThis.litPropertyMetadata.get(n);if(r===void 0&&globalThis.litPropertyMetadata.set(n,r=new Map),i==="setter"&&((s=Object.create(s)).wrapped=!0),r.set(t.name,s),i==="accessor"){const{name:o}=t;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,l,s)},init(a){return a!==void 0&&this.C(o,void 0,s,a),a}}}if(i==="setter"){const{name:o}=t;return function(a){const l=this[o];e.call(this,a),this.requestUpdate(o,l,s)}}throw Error("Unsupported decorator location: "+i)};function E(s){return(e,t)=>typeof t=="object"?ot(s,e,t):((i,n,r)=>{const o=n.hasOwnProperty(r);return n.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(n,r):void 0})(s,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 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 he;const lt=new Uint8Array(16);function dt(){if(!he){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");he=crypto.getRandomValues.bind(crypto)}return he(lt)}const Ue={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function L(i,e,t){var s;if(Ue.randomUUID&&!i)return Ue.randomUUID();i=i||{};const n=i.random??((s=i.rng)==null?void 0:s.call(i))??dt();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=N`
31
+ */function b(s){return E({...s,state:!0,attribute:!1})}const y=[];for(let s=0;s<256;++s)y.push((s+256).toString(16).slice(1));function at(s,e=0){return(y[s[e+0]]+y[s[e+1]]+y[s[e+2]]+y[s[e+3]]+"-"+y[s[e+4]]+y[s[e+5]]+"-"+y[s[e+6]]+y[s[e+7]]+"-"+y[s[e+8]]+y[s[e+9]]+"-"+y[s[e+10]]+y[s[e+11]]+y[s[e+12]]+y[s[e+13]]+y[s[e+14]]+y[s[e+15]]).toLowerCase()}let he;const lt=new Uint8Array(16);function dt(){if(!he){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");he=crypto.getRandomValues.bind(crypto)}return he(lt)}const Ue={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function A(s,e,t){var n;if(Ue.randomUUID&&!s)return Ue.randomUUID();s=s||{};const i=s.random??((n=s.rng)==null?void 0:n.call(s))??dt();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,at(i)}const pt=N`
32
32
  :host {
33
33
  display: block;
34
34
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
@@ -709,6 +709,7 @@
709
709
  .step-actions {
710
710
  display: flex;
711
711
  align-items: center;
712
+ position: relative;
712
713
  }
713
714
 
714
715
  .step-menu {
@@ -726,6 +727,59 @@
726
727
  background-color: #f3f4f6;
727
728
  color: #6b7280;
728
729
  }
730
+
731
+ .step-menu-container {
732
+ position: relative;
733
+ }
734
+
735
+ .step-menu-dropdown {
736
+ position: absolute;
737
+ top: calc(100% + 4px);
738
+ right: 0;
739
+ background: white;
740
+ border: 1px solid #e5e7eb;
741
+ border-radius: 8px;
742
+ box-shadow:
743
+ 0 4px 6px -1px rgba(0, 0, 0, 0.1),
744
+ 0 2px 4px -1px rgba(0, 0, 0, 0.06);
745
+ min-width: 160px;
746
+ z-index: 100;
747
+ overflow: hidden;
748
+ }
749
+
750
+ .step-menu-item {
751
+ display: flex;
752
+ align-items: center;
753
+ gap: 12px;
754
+ padding: 10px 16px;
755
+ border: none;
756
+ background: none;
757
+ width: 100%;
758
+ text-align: left;
759
+ cursor: pointer;
760
+ font-size: 14px;
761
+ color: #374151;
762
+ transition: background 0.2s;
763
+ font-family: inherit;
764
+ }
765
+
766
+ .step-menu-item:hover {
767
+ background: #f9fafb;
768
+ }
769
+
770
+ .step-menu-item.danger {
771
+ color: #ef4444;
772
+ }
773
+
774
+ .step-menu-item.danger:hover {
775
+ background: #fef2f2;
776
+ }
777
+
778
+ .step-menu-icon {
779
+ font-size: 16px;
780
+ width: 20px;
781
+ text-align: center;
782
+ }
729
783
  .runner-layout {
730
784
  display: flex;
731
785
  width: 100%;
@@ -2355,37 +2409,60 @@
2355
2409
  line-height: 1.4;
2356
2410
  }
2357
2411
  `,ht=N`
2358
- /* Modal Styles */
2412
+ /* Modal Overlay */
2359
2413
  .modal-overlay {
2360
2414
  position: fixed;
2361
- top: 0;
2362
- left: 0;
2363
- right: 0;
2364
- bottom: 0;
2365
- background-color: rgba(0, 0, 0, 0.5);
2415
+ inset: 0;
2416
+ background: rgba(0, 0, 0, 0.5);
2417
+ backdrop-filter: blur(2px);
2366
2418
  display: flex;
2367
2419
  align-items: center;
2368
2420
  justify-content: center;
2369
2421
  z-index: 1000;
2422
+ animation: fadeIn 0.2s ease-out;
2370
2423
  }
2371
2424
 
2372
- .modal-container {
2373
- background-color: #ffffff;
2425
+ @keyframes fadeIn {
2426
+ from {
2427
+ opacity: 0;
2428
+ }
2429
+ to {
2430
+ opacity: 1;
2431
+ }
2432
+ }
2433
+
2434
+ /* Modal Container */
2435
+ .modal-content {
2436
+ background: white;
2374
2437
  border-radius: 12px;
2375
- box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
2438
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
2376
2439
  width: 90%;
2377
- max-width: 600px;
2440
+ max-width: 750px;
2378
2441
  max-height: 90vh;
2379
- overflow-y: auto;
2380
- position: relative;
2442
+ display: flex;
2443
+ flex-direction: column;
2444
+ overflow: hidden;
2445
+ animation: slideUp 0.3s ease-out;
2381
2446
  }
2382
2447
 
2448
+ @keyframes slideUp {
2449
+ from {
2450
+ transform: translateY(20px);
2451
+ opacity: 0;
2452
+ }
2453
+ to {
2454
+ transform: translateY(0);
2455
+ opacity: 1;
2456
+ }
2457
+ }
2458
+
2459
+ /* Modal Header */
2383
2460
  .modal-header {
2384
2461
  display: flex;
2385
- justify-content: space-between;
2386
2462
  align-items: center;
2387
- padding: 24px 24px 0 24px;
2388
- margin-bottom: 24px;
2463
+ justify-content: space-between;
2464
+ padding: 24px 32px;
2465
+ border-bottom: 1px solid #e5e7eb;
2389
2466
  }
2390
2467
 
2391
2468
  .modal-header h2 {
@@ -2396,121 +2473,342 @@
2396
2473
  }
2397
2474
 
2398
2475
  .modal-close {
2476
+ display: flex;
2477
+ align-items: center;
2478
+ justify-content: center;
2479
+ width: 28px;
2480
+ height: 28px;
2481
+ padding: 4px;
2399
2482
  background: none;
2400
2483
  border: none;
2401
- font-size: 24px;
2402
- color: #6b7280;
2484
+ border-radius: 6px;
2485
+ font-size: 20px;
2486
+ color: #9ca3af;
2403
2487
  cursor: pointer;
2404
- padding: 4px;
2405
- border-radius: 4px;
2406
- transition: background-color 0.2s ease;
2488
+ transition: all 0.2s;
2489
+ line-height: 1;
2407
2490
  }
2408
2491
 
2409
2492
  .modal-close:hover {
2410
- background-color: #f3f4f6;
2493
+ background: #f3f4f6;
2494
+ color: #6b7280;
2411
2495
  }
2412
2496
 
2497
+ /* Modal Body */
2413
2498
  .modal-body {
2414
- padding: 0 24px 24px 24px;
2499
+ display: flex;
2500
+ flex-direction: column;
2501
+ flex: 1;
2502
+ padding: 32px;
2503
+ overflow-y: auto;
2415
2504
  }
2416
2505
 
2417
- .modal-form-group {
2418
- margin-bottom: 20px;
2506
+ .modal-body .form-group {
2507
+ display: flex;
2508
+ flex-direction: column;
2509
+ gap: 8px;
2510
+ margin-bottom: 24px;
2419
2511
  }
2420
2512
 
2421
- .modal-form-group label {
2422
- display: block;
2513
+ .modal-body .form-group:last-child {
2514
+ margin-bottom: 0;
2515
+ }
2516
+
2517
+ .modal-body label {
2423
2518
  font-weight: 600;
2424
2519
  color: #111827;
2425
- margin-bottom: 8px;
2426
2520
  font-size: 14px;
2427
2521
  }
2428
2522
 
2429
- .modal-form-group input,
2430
- .modal-form-group textarea {
2523
+ /* Form Inputs */
2524
+ .modal-body input[type="text"],
2525
+ .modal-body input[type="email"],
2526
+ .modal-body textarea,
2527
+ .assignment-select {
2431
2528
  width: 100%;
2432
- padding: 12px;
2529
+ padding: 12px 16px;
2433
2530
  border: 1px solid #d1d5db;
2434
2531
  border-radius: 8px;
2435
- font-size: 14px;
2436
- transition: border-color 0.2s ease;
2532
+ font-size: 15px;
2533
+ font-family: inherit;
2534
+ background: white;
2535
+ color: #111827;
2536
+ transition: all 0.2s;
2437
2537
  box-sizing: border-box;
2438
2538
  }
2439
2539
 
2440
- .modal-form-group input:focus,
2441
- .modal-form-group textarea:focus {
2540
+ .modal-body input::placeholder,
2541
+ .modal-body textarea::placeholder {
2542
+ color: #9ca3af;
2543
+ }
2544
+
2545
+ .modal-body input:hover,
2546
+ .modal-body textarea:hover,
2547
+ .assignment-select:hover {
2548
+ border-color: #9ca3af;
2549
+ }
2550
+
2551
+ .modal-body input:focus,
2552
+ .modal-body textarea:focus,
2553
+ .assignment-select:focus {
2442
2554
  outline: none;
2443
2555
  border-color: #3b82f6;
2444
2556
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
2445
2557
  }
2446
2558
 
2447
- .modal-form-group textarea {
2448
- min-height: 80px;
2559
+ .modal-body textarea {
2449
2560
  resize: vertical;
2561
+ min-height: 100px;
2450
2562
  }
2451
2563
 
2452
- .modal-form-group input::placeholder,
2453
- .modal-form-group textarea::placeholder {
2454
- color: #9ca3af;
2564
+ .assignment-select {
2565
+ margin-top: 16px;
2566
+ cursor: pointer;
2567
+ }
2568
+
2569
+ /* Assignment Section */
2570
+ .assignment-section {
2571
+ display: flex;
2572
+ flex-direction: column;
2573
+ gap: 16px;
2574
+ margin-top: 32px;
2575
+ }
2576
+
2577
+ .assignment-section > label {
2578
+ font-weight: 600;
2579
+ color: #111827;
2580
+ font-size: 14px;
2581
+ }
2582
+
2583
+ /* Assignment Cards */
2584
+ .assignment-options {
2585
+ display: flex;
2586
+ gap: 12px;
2587
+ }
2588
+
2589
+ .assignment-card {
2590
+ display: flex;
2591
+ flex-direction: column;
2592
+ flex: 1;
2593
+ padding: 16px;
2594
+ border: 2px solid #e5e7eb;
2595
+ border-radius: 8px;
2596
+ cursor: pointer;
2597
+ transition: all 0.2s;
2598
+ position: relative;
2599
+ min-height: 80px;
2600
+ }
2601
+
2602
+ .assignment-card:hover {
2603
+ border-color: #3b82f6;
2604
+ background: #f0f9ff;
2605
+ }
2606
+
2607
+ .assignment-card.selected {
2608
+ border-color: #3b82f6;
2609
+ background: #eff6ff;
2610
+ }
2611
+
2612
+ /* Custom Radio in Cards */
2613
+ .assignment-card-radio {
2614
+ position: absolute;
2615
+ top: 16px;
2616
+ left: 16px;
2617
+ width: 20px;
2618
+ height: 20px;
2619
+ border: 2px solid #d1d5db;
2620
+ border-radius: 50%;
2621
+ transition: all 0.2s;
2622
+ }
2623
+
2624
+ .assignment-card.selected .assignment-card-radio {
2625
+ border-color: #3b82f6;
2626
+ background: white;
2627
+ }
2628
+
2629
+ .assignment-card.selected .assignment-card-radio::after {
2630
+ content: "";
2631
+ position: absolute;
2632
+ top: 50%;
2633
+ left: 50%;
2634
+ transform: translate(-50%, -50%);
2635
+ width: 10px;
2636
+ height: 10px;
2637
+ border-radius: 50%;
2638
+ background: #3b82f6;
2639
+ }
2640
+
2641
+ .assignment-card-content {
2642
+ display: flex;
2643
+ flex-direction: column;
2644
+ gap: 4px;
2645
+ margin-left: 32px;
2646
+ }
2647
+
2648
+ .assignment-card-title {
2649
+ font-weight: 600;
2650
+ color: #111827;
2651
+ font-size: 14px;
2652
+ }
2653
+
2654
+ .assignment-card-description {
2655
+ color: #6b7280;
2656
+ font-size: 13px;
2657
+ line-height: 1.4;
2658
+ }
2659
+
2660
+ /* Radio Options */
2661
+ .assignment-radio-group {
2662
+ display: flex;
2663
+ flex-direction: column;
2664
+ gap: 8px;
2665
+ }
2666
+
2667
+ .assignment-radio-option {
2668
+ display: flex;
2669
+ gap: 12px;
2670
+ padding: 12px;
2671
+ border-radius: 6px;
2672
+ cursor: pointer;
2673
+ transition: background 0.2s;
2455
2674
  }
2456
2675
 
2676
+ .assignment-radio-option:hover {
2677
+ background: #f9fafb;
2678
+ }
2679
+
2680
+ .assignment-radio-option input[type="radio"] {
2681
+ margin: 2px 0 0 0;
2682
+ flex-shrink: 0;
2683
+ width: 18px;
2684
+ height: 18px;
2685
+ cursor: pointer;
2686
+ accent-color: #3b82f6;
2687
+ }
2688
+
2689
+ .assignment-radio-label {
2690
+ display: flex;
2691
+ flex-direction: column;
2692
+ gap: 4px;
2693
+ flex: 1;
2694
+ min-width: 0;
2695
+ }
2696
+
2697
+ .assignment-radio-title {
2698
+ font-weight: 500;
2699
+ color: #111827;
2700
+ font-size: 14px;
2701
+ line-height: 1.3;
2702
+ }
2703
+
2704
+ .assignment-radio-description {
2705
+ color: #6b7280;
2706
+ font-size: 13px;
2707
+ line-height: 1.4;
2708
+ }
2709
+
2710
+ /* Modal Footer */
2457
2711
  .modal-footer {
2458
2712
  display: flex;
2459
2713
  justify-content: flex-end;
2460
2714
  gap: 12px;
2461
- padding: 24px;
2715
+ padding: 20px 32px;
2462
2716
  border-top: 1px solid #e5e7eb;
2463
- margin-top: 24px;
2464
2717
  }
2465
2718
 
2466
2719
  .modal-footer button {
2467
- padding: 10px 20px;
2720
+ padding: 10px 24px;
2721
+ border: none;
2468
2722
  border-radius: 8px;
2469
2723
  font-size: 14px;
2470
2724
  font-weight: 500;
2725
+ font-family: inherit;
2471
2726
  cursor: pointer;
2472
- transition: all 0.2s ease;
2727
+ transition: all 0.2s;
2473
2728
  }
2474
2729
 
2475
- .modal-cancel-button {
2476
- background-color: #ffffff;
2730
+ .modal-footer .cancel-button {
2731
+ background: white;
2477
2732
  color: #374151;
2478
- border: 1px solid #d1d5db;
2733
+ border: 1px solid #d1d5db !important;
2479
2734
  }
2480
2735
 
2481
- .modal-cancel-button:hover {
2482
- background-color: #f9fafb;
2736
+ .modal-footer .cancel-button:hover {
2737
+ background: #f9fafb;
2738
+ border-color: #9ca3af !important;
2483
2739
  }
2484
2740
 
2485
- .modal-create-button {
2486
- background-color: #3b82f6;
2487
- color: #ffffff;
2488
- border: 1px solid #3b82f6;
2741
+ .modal-footer .save-button {
2742
+ background: #111827;
2743
+ color: white;
2744
+ }
2745
+
2746
+ .modal-footer .save-button:hover {
2747
+ background: #1f2937;
2748
+ }
2749
+
2750
+ .modal-footer .save-button:disabled {
2751
+ background: #9ca3af;
2752
+ cursor: not-allowed;
2753
+ opacity: 0.6;
2489
2754
  }
2490
2755
 
2491
- .modal-create-button:hover {
2492
- background-color: #2563eb;
2756
+ /* Scrollbar */
2757
+ .modal-body::-webkit-scrollbar {
2758
+ width: 8px;
2493
2759
  }
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&&gt(e,t,s),s};let w=class extends W{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.workflow?(this._templateData={...this.workflow},this.workflow.steps&&this.workflow.steps.length>0&&(this._selectedStepId=this.workflow.steps[0].id),console.log("Builder loaded with existing workflow:",this.workflow.name)):this._templateData=this._getDefaultWorkflowData()}updated(i){i.has("workflow")&&this.workflow&&(this._templateData={...this.workflow},this.workflow.steps&&this.workflow.steps.length>0&&(this._selectedStepId=this.workflow.steps[0].id),console.log("Workflow property changed, reloading template data"))}_getDefaultWorkflowData(){const i={id:L(),title:"Step 1",description:"",order:1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};return{id:L(),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,t;if((i=this._templateData.name)!=null&&i.trim()){const n={id:this._templateData.id||L(),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(n,null,2)),this.workflow?(console.log("Calling onWorkflowUpdated callback"),(e=this.onWorkflowUpdated)==null||e.call(this,n)):(console.log("Calling onWorkflowCreated callback"),(t=this.onWorkflowCreated)==null||t.call(this,n))}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:L(),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,l)=>`${l+1}: ${a.title}`));const r=[...t],[o]=r.splice(n,1);r.splice(s,0,o),r.forEach((a,l)=>{a.order=l+1}),console.log("🔄 After reorder:",r.map((a,l)=>`${l+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:L(),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...
2495
2760
 
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:L(),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:L(),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...
2761
+ .modal-body::-webkit-scrollbar-track {
2762
+ background: #f1f5f9;
2763
+ border-radius: 4px;
2764
+ }
2765
+
2766
+ .modal-body::-webkit-scrollbar-thumb {
2767
+ background: #cbd5e1;
2768
+ border-radius: 4px;
2769
+ }
2770
+
2771
+ .modal-body::-webkit-scrollbar-thumb:hover {
2772
+ background: #94a3b8;
2773
+ }
2497
2774
 
2498
- Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r.id===this._selectedStepId?{...r,elements:[...r.elements||[],t]}:r);this._templateData={...this._templateData,steps:n},console.log("✅ Content element added to step:",this._selectedStepId)}_updateQuestion(i,e){var n;if(!this._selectedStepId)return;const t=(n=this._templateData.steps)==null?void 0:n.map(s=>{var r;return s.id===this._selectedStepId?{...s,elements:((r=s.elements)==null?void 0:r.map(o=>o.id===i?{...o,...e}:o))||[]}:s});this._templateData={...this._templateData,steps:t}}_updateContentElement(i,e){var n;if(!this._selectedStepId)return;const t=(n=this._templateData.steps)==null?void 0:n.map(s=>{var r;return s.id===this._selectedStepId?{...s,elements:((r=s.elements)==null?void 0:r.map(o=>o.id===i?{...o,...e}:o))||[]}:s});this._templateData={...this._templateData,steps:t}}_deleteQuestion(i){var t;if(!this._selectedStepId)return;const e=(t=this._templateData.steps)==null?void 0:t.map(n=>{var s;return n.id===this._selectedStepId?{...n,elements:((s=n.elements)==null?void 0:s.filter(r=>r.id!==i))||[]}:n});this._templateData={...this._templateData,steps:e},console.log("🗑️ Question deleted:",i)}_renderQuestionTypeSpecificFields(i){switch(i.type){case"select":case"radio":return d`
2775
+ /* Responsive */
2776
+ @media (max-width: 768px) {
2777
+ .modal-content {
2778
+ width: 95%;
2779
+ max-height: 95vh;
2780
+ }
2781
+
2782
+ .modal-header,
2783
+ .modal-body,
2784
+ .modal-footer {
2785
+ padding: 20px 24px;
2786
+ }
2787
+
2788
+ .assignment-options {
2789
+ flex-direction: column;
2790
+ }
2791
+ }
2792
+ `;var gt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,S=(s,e,t,i)=>{for(var n=i>1?void 0:i?mt(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&gt(e,t,n),n};let w=class extends H{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=[],this._editingStepId=null,this._stepAssignmentCategory="individual",this._stepAssignmentType="subject",this._stepAssignmentTarget="",this._openMenuStepId=null}connectedCallback(){super.connectedCallback(),this.workflow?(this._templateData={...this.workflow},this.workflow.steps&&this.workflow.steps.length>0&&(this._selectedStepId=this.workflow.steps[0].id),console.log("Builder loaded with existing workflow:",this.workflow.name)):this._templateData=this._getDefaultWorkflowData(),this._clickOutsideHandler=()=>this._closeStepMenu(),document.addEventListener("click",this._clickOutsideHandler)}disconnectedCallback(){super.disconnectedCallback(),this._clickOutsideHandler&&document.removeEventListener("click",this._clickOutsideHandler)}updated(s){s.has("workflow")&&this.workflow&&(this._templateData={...this.workflow},this.workflow.steps&&this.workflow.steps.length>0&&(this._selectedStepId=this.workflow.steps[0].id),console.log("Workflow property changed, reloading template data"))}_getDefaultWorkflowData(){const s={id:A(),title:"Step 1",description:"",order:1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};return{id:A(),name:"",description:"",steps:[s]}}_handleTitleChange(s){const e=s.target;this._templateData={...this._templateData,name:e.value}}_handleDescriptionChange(s){const e=s.target;this._templateData={...this._templateData,description:e.value}}_handleCancel(){var s;console.log("🚫 Builder Widget: Cancel button clicked"),(s=this.onCancel)==null||s.call(this)}_handleSave(){var s,e,t;if((s=this._templateData.name)!=null&&s.trim()){const i={id:this._templateData.id||A(),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(i,null,2)),this.workflow?(console.log("Calling onWorkflowUpdated callback"),(e=this.onWorkflowUpdated)==null||e.call(this,i)):(console.log("Calling onWorkflowCreated callback"),(t=this.onWorkflowCreated)==null||t.call(this,i))}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._editingStepId=null,this._stepFormData={title:"",description:""},this._stepAssignmentCategory="individual",this._stepAssignmentType="subject",this._stepAssignmentTarget=""}_handleStepFormInput(s){const e=s.target,{name:t,value:i}=e;this._stepFormData={...this._stepFormData,[t]:i}}_toggleStepMenu(s,e){s.stopPropagation(),this._openMenuStepId=this._openMenuStepId===e?null:e}_closeStepMenu(){this._openMenuStepId=null}_editStep(s){var t;const e=(t=this._templateData.steps)==null?void 0:t.find(i=>i.id===s);e&&(this._editingStepId=s,this._stepFormData={title:e.title,description:e.description},this._stepAssignmentCategory=e.assignment.category,this._stepAssignmentType=e.assignment.type,this._stepAssignmentTarget=e.assignment.email||e.assignment.targetId||"",this._showStepModal=!0,this._closeStepMenu(),console.log("Editing step:",s))}_duplicateStep(s){var n,r;const e=(n=this._templateData.steps)==null?void 0:n.find(o=>o.id===s);if(!e)return;const t=this._templateData.steps||[],i={...e,id:A(),title:`${e.title} (Copy)`,order:t.length+1,elements:((r=e.elements)==null?void 0:r.map(o=>({...o,id:A()})))||[]};this._templateData={...this._templateData,steps:[...t,i]},this._closeStepMenu(),console.log("Step duplicated:",s)}_deleteStep(s){const e=(this._templateData.steps||[]).filter(t=>t.id!==s);e.forEach((t,i)=>{t.order=i+1}),this._templateData={...this._templateData,steps:e},this._selectedStepId===s&&(this._selectedStepId=e.length>0?e[0].id:null),this._closeStepMenu(),console.log("Step deleted:",s)}_createStep(){var t,i;if(!((t=this._stepFormData.title)!=null&&t.trim())){console.log("⚠️ Step title is required");return}const s=this._templateData.steps||[],e={category:this._stepAssignmentCategory,type:this._stepAssignmentType};if(this._stepAssignmentType==="specific_user"&&this._stepAssignmentTarget?e.email=this._stepAssignmentTarget:this._stepAssignmentType==="instance_role_assignee_select"&&this._stepAssignmentTarget&&(e.targetId=this._stepAssignmentTarget),this._editingStepId){const n=s.map(r=>{var o;return r.id===this._editingStepId?{...r,title:this._stepFormData.title.trim(),description:((o=this._stepFormData.description)==null?void 0:o.trim())||"",assignment:e}:r});this._templateData={...this._templateData,steps:n},console.log("✅ Step updated:",this._editingStepId)}else{const n={id:A(),title:this._stepFormData.title.trim(),description:((i=this._stepFormData.description)==null?void 0:i.trim())||"",order:s.length+1,assignment:e,elements:[],status:"pending"};this._templateData={...this._templateData,steps:[...s,n]},this._selectedStepId=n.id,console.log("✅ Step created and selected:",n)}this._closeStepModal()}_selectStep(s){this._selectedStepId=s,console.log("🎯 Step selected:",s)}_getSelectedStep(){return!this._selectedStepId||!this._templateData.steps?null:this._templateData.steps.find(s=>s.id===this._selectedStepId)||null}_handleDragStart(s,e){this._draggedStepId=e,s.dataTransfer&&(s.dataTransfer.effectAllowed="move",s.dataTransfer.setData("text/plain",e)),console.log("🔄 Drag started for step:",e)}_handleDragEnd(s){this._draggedStepId=null,this._dragOverStepId=null,console.log("🔄 Drag ended")}_handleDragOver(s,e){s.preventDefault(),s.dataTransfer&&(s.dataTransfer.dropEffect="move"),this._dragOverStepId!==e&&(this._dragOverStepId=e)}_handleDragLeave(s){const e=s.relatedTarget;s.currentTarget.contains(e)||(this._dragOverStepId=null)}_handleDrop(s,e){if(s.preventDefault(),!this._draggedStepId||this._draggedStepId===e){this._draggedStepId=null,this._dragOverStepId=null;return}const t=this._templateData.steps||[],i=t.findIndex(a=>a.id===this._draggedStepId),n=t.findIndex(a=>a.id===e);if(i===-1||n===-1){console.error("Could not find step indices for reordering");return}console.log("🔄 Before reorder:",t.map((a,l)=>`${l+1}: ${a.title}`));const r=[...t],[o]=r.splice(i,1);r.splice(n,0,o),r.forEach((a,l)=>{a.order=l+1}),console.log("🔄 After reorder:",r.map((a,l)=>`${l+1}: ${a.title}`)),this._templateData={...this._templateData,steps:r},console.log("📝 Template updated with new step order"),this._draggedStepId=null,this._dragOverStepId=null}_addQuestion(s="text_input"){var i,n;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(s)){let r={id:A(),type:s,order:(((i=e.elements)==null?void 0:i.length)||0)+1};switch(s){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...
2793
+
2794
+ 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:A(),type:s,label:this._getQuestionTypeDisplayName(s),order:(((n=e.elements)==null?void 0:n.length)||0)+1,required:!1};["select","radio","checkbox"].includes(s)&&(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(s){var n;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:A(),type:s,order:(((n=e.elements)==null?void 0:n.length)||0)+1};switch(s){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...
2795
+
2796
+ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r.id===this._selectedStepId?{...r,elements:[...r.elements||[],t]}:r);this._templateData={...this._templateData,steps:i},console.log("✅ Content element added to step:",this._selectedStepId)}_updateQuestion(s,e){var i;if(!this._selectedStepId)return;const t=(i=this._templateData.steps)==null?void 0:i.map(n=>{var r;return n.id===this._selectedStepId?{...n,elements:((r=n.elements)==null?void 0:r.map(o=>o.id===s?{...o,...e}:o))||[]}:n});this._templateData={...this._templateData,steps:t}}_updateContentElement(s,e){var i;if(!this._selectedStepId)return;const t=(i=this._templateData.steps)==null?void 0:i.map(n=>{var r;return n.id===this._selectedStepId?{...n,elements:((r=n.elements)==null?void 0:r.map(o=>o.id===s?{...o,...e}:o))||[]}:n});this._templateData={...this._templateData,steps:t}}_deleteQuestion(s){var t;if(!this._selectedStepId)return;const e=(t=this._templateData.steps)==null?void 0:t.map(i=>{var n;return i.id===this._selectedStepId?{...i,elements:((n=i.elements)==null?void 0:n.filter(r=>r.id!==s))||[]}:i});this._templateData={...this._templateData,steps:e},console.log("🗑️ Question deleted:",s)}_renderQuestionTypeSpecificFields(s){switch(s.type){case"select":case"radio":return d`
2499
2797
  <div class="question-options-section">
2500
2798
  <label class="options-label">Options:</label>
2501
2799
  <div class="options-list">
2502
- ${(i.options||[]).map((e,t)=>d`
2800
+ ${(s.options||[]).map((e,t)=>d`
2503
2801
  <div class="option-item">
2504
2802
  <input
2505
2803
  type="text"
2506
2804
  class="option-input"
2507
2805
  placeholder="Option ${t+1}"
2508
2806
  .value=${e}
2509
- @input=${n=>{const s=n.target,r=[...i.options||[]];r[t]=s.value,this._updateQuestion(i.id,{options:r})}}
2807
+ @input=${i=>{const n=i.target,r=[...s.options||[]];r[t]=n.value,this._updateQuestion(s.id,{options:r})}}
2510
2808
  />
2511
2809
  <button
2512
2810
  class="remove-option-button"
2513
- @click=${()=>{const n=[...i.options||[]];n.splice(t,1),this._updateQuestion(i.id,{options:n})}}
2811
+ @click=${()=>{const i=[...s.options||[]];i.splice(t,1),this._updateQuestion(s.id,{options:i})}}
2514
2812
  title="Remove option"
2515
2813
  >
2516
2814
  ×
@@ -2519,9 +2817,24 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2519
2817
  `)}
2520
2818
  <button
2521
2819
  class="add-option-button"
2522
- @click=${()=>{const e=[...i.options||[],""];this._updateQuestion(i.id,{options:e})}}
2820
+ @click=${()=>{const e=[...s.options||[],""];this._updateQuestion(s.id,{options:e})}}
2523
2821
  >
2524
- + Add Option
2822
+ <svg
2823
+ xmlns="http://www.w3.org/2000/svg"
2824
+ width="16"
2825
+ height="16"
2826
+ viewBox="0 0 24 24"
2827
+ fill="none"
2828
+ stroke="currentColor"
2829
+ stroke-width="2"
2830
+ stroke-linecap="round"
2831
+ stroke-linejoin="round"
2832
+ class="lucide lucide-plus-icon lucide-plus"
2833
+ >
2834
+ <path d="M5 12h14" />
2835
+ <path d="M12 5v14" />
2836
+ </svg>
2837
+ Add Option
2525
2838
  </button>
2526
2839
  </div>
2527
2840
  </div>
@@ -2531,52 +2844,81 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2531
2844
  <label class="checkbox-type-label">
2532
2845
  <input
2533
2846
  type="radio"
2534
- name="checkbox-type-${i.id}"
2847
+ name="checkbox-type-${s.id}"
2535
2848
  value="single"
2536
- .checked=${!i.options||i.options.length===0}
2537
- @change=${e=>{e.target.checked&&this._updateQuestion(i.id,{options:void 0})}}
2849
+ .checked=${!s.options||s.options.length===0}
2850
+ @change=${e=>{e.target.checked&&this._updateQuestion(s.id,{options:void 0})}}
2538
2851
  />
2539
2852
  Single Checkbox (Yes/No)
2540
2853
  </label>
2541
2854
  <label class="checkbox-type-label">
2542
2855
  <input
2543
2856
  type="radio"
2544
- name="checkbox-type-${i.id}"
2857
+ name="checkbox-type-${s.id}"
2545
2858
  value="group"
2546
- .checked=${i.options&&i.options.length>0}
2547
- @change=${e=>{e.target.checked&&this._updateQuestion(i.id,{options:i.options&&i.options.length>0?i.options:["Option 1","Option 2"]})}}
2859
+ .checked=${s.options&&s.options.length>0}
2860
+ @change=${e=>{e.target.checked&&this._updateQuestion(s.id,{options:s.options&&s.options.length>0?s.options:["Option 1","Option 2"]})}}
2548
2861
  />
2549
2862
  Checkbox Group (Multiple selections)
2550
2863
  </label>
2551
2864
  </div>
2552
2865
 
2553
- ${i.options&&i.options.length>0?d`
2866
+ ${s.options&&s.options.length>0?d`
2554
2867
  <div class="question-options-section">
2555
2868
  <label class="options-label">Checkbox Options:</label>
2556
2869
  <div class="options-list">
2557
- ${(i.options||[]).map((e,t)=>d`
2870
+ ${(s.options||[]).map((e,t)=>d`
2558
2871
  <div class="option-item">
2559
2872
  <input
2560
2873
  type="text"
2561
2874
  class="option-input"
2562
2875
  placeholder="Option ${t+1}"
2563
2876
  .value=${e}
2564
- @input=${n=>{const s=n.target,r=[...i.options||[]];r[t]=s.value,this._updateQuestion(i.id,{options:r})}}
2877
+ @input=${i=>{const n=i.target,r=[...s.options||[]];r[t]=n.value,this._updateQuestion(s.id,{options:r})}}
2565
2878
  />
2566
2879
  <button
2567
2880
  class="remove-option-button"
2568
- @click=${()=>{const n=[...i.options||[]];n.splice(t,1),this._updateQuestion(i.id,{options:n})}}
2881
+ @click=${()=>{const i=[...s.options||[]];i.splice(t,1),this._updateQuestion(s.id,{options:i})}}
2569
2882
  title="Remove option"
2570
2883
  >
2571
- ×
2884
+ <svg
2885
+ xmlns="http://www.w3.org/2000/svg"
2886
+ width="16"
2887
+ height="16"
2888
+ viewBox="0 0 24 24"
2889
+ fill="none"
2890
+ stroke="currentColor"
2891
+ stroke-width="2"
2892
+ stroke-linecap="round"
2893
+ stroke-linejoin="round"
2894
+ class="lucide lucide-x-icon lucide-x"
2895
+ >
2896
+ <path d="M18 6 6 18" />
2897
+ <path d="m6 6 12 12" />
2898
+ </svg>
2572
2899
  </button>
2573
2900
  </div>
2574
2901
  `)}
2575
2902
  <button
2576
2903
  class="add-option-button"
2577
- @click=${()=>{const e=[...i.options||[],""];this._updateQuestion(i.id,{options:e})}}
2904
+ @click=${()=>{const e=[...s.options||[],""];this._updateQuestion(s.id,{options:e})}}
2578
2905
  >
2579
- + Add Option
2906
+ <svg
2907
+ xmlns="http://www.w3.org/2000/svg"
2908
+ width="16"
2909
+ height="16"
2910
+ viewBox="0 0 24 24"
2911
+ fill="none"
2912
+ stroke="currentColor"
2913
+ stroke-width="2"
2914
+ stroke-linecap="round"
2915
+ stroke-linejoin="round"
2916
+ class="lucide lucide-plus-icon lucide-plus"
2917
+ >
2918
+ <path d="M5 12h14" />
2919
+ <path d="M12 5v14" />
2920
+ </svg>
2921
+ Add Option
2580
2922
  </button>
2581
2923
  </div>
2582
2924
  </div>
@@ -2596,8 +2938,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2596
2938
  type="text"
2597
2939
  class="config-input"
2598
2940
  placeholder="Enter placeholder text"
2599
- .value=${i.placeholder||""}
2600
- @input=${e=>{const t=e.target;this._updateQuestion(i.id,{placeholder:t.value})}}
2941
+ .value=${s.placeholder||""}
2942
+ @input=${e=>{const t=e.target;this._updateQuestion(s.id,{placeholder:t.value})}}
2601
2943
  />
2602
2944
  </label>
2603
2945
  </div>
@@ -2609,8 +2951,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2609
2951
  type="text"
2610
2952
  class="config-input"
2611
2953
  placeholder="Enter placeholder text"
2612
- .value=${i.placeholder||""}
2613
- @input=${e=>{const t=e.target;this._updateQuestion(i.id,{placeholder:t.value})}}
2954
+ .value=${s.placeholder||""}
2955
+ @input=${e=>{const t=e.target;this._updateQuestion(s.id,{placeholder:t.value})}}
2614
2956
  />
2615
2957
  </label>
2616
2958
  </div>
@@ -2622,8 +2964,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2622
2964
  type="text"
2623
2965
  class="config-input"
2624
2966
  placeholder="Enter placeholder text"
2625
- .value=${i.placeholder||""}
2626
- @input=${e=>{const t=e.target;this._updateQuestion(i.id,{placeholder:t.value})}}
2967
+ .value=${s.placeholder||""}
2968
+ @input=${e=>{const t=e.target;this._updateQuestion(s.id,{placeholder:t.value})}}
2627
2969
  />
2628
2970
  </label>
2629
2971
  </div>
@@ -2639,15 +2981,15 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2639
2981
  <div class="question-config-section">
2640
2982
  <p class="config-note">Date picker field</p>
2641
2983
  </div>
2642
- `;default:return d``}}_renderContentTypeSpecificFields(i){switch(i.type){case"text":return d`
2984
+ `;default:return d``}}_renderContentTypeSpecificFields(s){switch(s.type){case"text":return d`
2643
2985
  <div class="content-config-section">
2644
2986
  <label class="config-label">
2645
2987
  Text Content:
2646
2988
  <textarea
2647
2989
  class="config-textarea"
2648
2990
  placeholder="Enter your text content..."
2649
- .value=${i.content||""}
2650
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{content:t.value})}}
2991
+ .value=${s.content||""}
2992
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{content:t.value})}}
2651
2993
  ></textarea>
2652
2994
  </label>
2653
2995
  </div>
@@ -2658,8 +3000,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2658
3000
  <textarea
2659
3001
  class="config-textarea"
2660
3002
  placeholder="Enter your HTML content..."
2661
- .value=${i.content||""}
2662
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{content:t.value})}}
3003
+ .value=${s.content||""}
3004
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{content:t.value})}}
2663
3005
  ></textarea>
2664
3006
  </label>
2665
3007
  </div>
@@ -2671,8 +3013,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2671
3013
  type="url"
2672
3014
  class="config-input"
2673
3015
  placeholder="https://example.com/image.jpg"
2674
- .value=${i.url||""}
2675
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{url:t.value})}}
3016
+ .value=${s.url||""}
3017
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{url:t.value})}}
2676
3018
  />
2677
3019
  </label>
2678
3020
  <label class="config-label">
@@ -2681,8 +3023,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2681
3023
  type="text"
2682
3024
  class="config-input"
2683
3025
  placeholder="Describe the image"
2684
- .value=${i.alt||""}
2685
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{alt:t.value})}}
3026
+ .value=${s.alt||""}
3027
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{alt:t.value})}}
2686
3028
  />
2687
3029
  </label>
2688
3030
  <label class="config-label">
@@ -2691,8 +3033,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2691
3033
  type="text"
2692
3034
  class="config-input"
2693
3035
  placeholder="Image caption"
2694
- .value=${i.caption||""}
2695
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{caption:t.value})}}
3036
+ .value=${s.caption||""}
3037
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{caption:t.value})}}
2696
3038
  />
2697
3039
  </label>
2698
3040
  </div>
@@ -2704,8 +3046,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2704
3046
  type="url"
2705
3047
  class="config-input"
2706
3048
  placeholder="https://example.com/video.mp4"
2707
- .value=${i.url||""}
2708
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{url:t.value})}}
3049
+ .value=${s.url||""}
3050
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{url:t.value})}}
2709
3051
  />
2710
3052
  </label>
2711
3053
  <label class="config-label">
@@ -2714,8 +3056,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2714
3056
  type="text"
2715
3057
  class="config-input"
2716
3058
  placeholder="Video caption"
2717
- .value=${i.caption||""}
2718
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{caption:t.value})}}
3059
+ .value=${s.caption||""}
3060
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{caption:t.value})}}
2719
3061
  />
2720
3062
  </label>
2721
3063
  </div>
@@ -2727,8 +3069,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2727
3069
  type="url"
2728
3070
  class="config-input"
2729
3071
  placeholder="https://example.com/document.pdf"
2730
- .value=${i.url||""}
2731
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{url:t.value})}}
3072
+ .value=${s.url||""}
3073
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{url:t.value})}}
2732
3074
  />
2733
3075
  </label>
2734
3076
  <label class="config-label">
@@ -2737,8 +3079,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2737
3079
  type="text"
2738
3080
  class="config-input"
2739
3081
  placeholder="File description"
2740
- .value=${i.caption||""}
2741
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{caption:t.value})}}
3082
+ .value=${s.caption||""}
3083
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{caption:t.value})}}
2742
3084
  />
2743
3085
  </label>
2744
3086
  </div>
@@ -2750,8 +3092,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2750
3092
  type="text"
2751
3093
  class="config-input"
2752
3094
  placeholder="Section divider caption"
2753
- .value=${i.caption||""}
2754
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{caption:t.value})}}
3095
+ .value=${s.caption||""}
3096
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{caption:t.value})}}
2755
3097
  />
2756
3098
  </label>
2757
3099
  </div>
@@ -2762,12 +3104,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2762
3104
  <textarea
2763
3105
  class="config-textarea"
2764
3106
  placeholder="Enter your markdown content..."
2765
- .value=${i.content||""}
2766
- @input=${e=>{const t=e.target;this._updateContentElement(i.id,{content:t.value})}}
3107
+ .value=${s.content||""}
3108
+ @input=${e=>{const t=e.target;this._updateContentElement(s.id,{content:t.value})}}
2767
3109
  ></textarea>
2768
3110
  </label>
2769
3111
  </div>
2770
- `;default:return d``}}_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}_showStepMenu(i,e){i.stopPropagation(),console.log("Step menu for:",e),confirm("Delete this step?")&&this._deleteStep(e)}_deleteStep(i){if(!confirm("Are you sure you want to delete this step?"))return;const e=(this._templateData.steps||[]).filter(t=>t.id!==i);e.forEach((t,n)=>{t.order=n+1}),this._templateData={...this._templateData,steps:e},this._selectedStepId===i&&(this._selectedStepId=e.length>0?e[0].id:null),console.log("Step deleted:",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(){var e;const i=this._getSelectedStep();return d`
3112
+ `;default:return d``}}_getQuestionTypeDisplayName(s){switch(s){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(s){switch(s){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(s){return s.options&&s.options.length>0?"Checkbox Group":"Single Checkbox"}_hasSteps(){const s=!!(this._templateData.steps&&this._templateData.steps.length>0);return s&&!this._selectedStepId&&this._templateData.steps&&(this._selectedStepId=this._templateData.steps[0].id,console.log("🎯 Auto-selected first step:",this._templateData.steps[0].title)),!s&&this._selectedStepId&&(this._selectedStepId=null),s}_getAssignmentDisplayText(s){switch(s.category){case"individual":switch(s.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 s.email?`Assigned to: ${s.email}`:"Assigned to: Specific user";default:return"Assigned to: Individual"}case"role":switch(s.type){case"instance_role_assignee_select":return s.targetId?`Assigned to: ${s.targetId} role`:"Assigned to: Role";default:return"Assigned to: Role"}default:return"Assignment not configured"}}render(){var e;const s=this._getSelectedStep();return d`
2771
3113
  <div class="header">
2772
3114
  <div class="header-inputs">
2773
3115
  <div class="form-group">
@@ -2797,6 +3139,185 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2797
3139
  </div>
2798
3140
 
2799
3141
  <div class="main-content">
3142
+ ${this._showStepModal?d`
3143
+ <div class="modal-overlay" @click=${this._closeStepModal}>
3144
+ <div class="modal-content" @click=${t=>t.stopPropagation()}>
3145
+ <div class="modal-header">
3146
+ <h2>${this._editingStepId?"Edit Step":"Add a Step"}</h2>
3147
+ <button class="modal-close" @click=${this._closeStepModal}>×</button>
3148
+ </div>
3149
+ <div class="modal-body">
3150
+ <div class="form-group">
3151
+ <label for="step-title">Step Title</label>
3152
+ <input
3153
+ type="text"
3154
+ id="step-title"
3155
+ name="title"
3156
+ placeholder="Enter step title"
3157
+ .value=${this._stepFormData.title||""}
3158
+ @input=${this._handleStepFormInput}
3159
+ autofocus
3160
+ />
3161
+ </div>
3162
+ <div class="form-group">
3163
+ <label for="step-description">Description</label>
3164
+ <input
3165
+ id="step-description"
3166
+ name="description"
3167
+ placeholder="Add description"
3168
+ .value=${this._stepFormData.description||""}
3169
+ @input=${this._handleStepFormInput}
3170
+ rows="3"
3171
+ />
3172
+ </div>
3173
+
3174
+ <div class="assignment-section">
3175
+ <label>Assignment</label>
3176
+ <div class="assignment-options">
3177
+ <div
3178
+ class="assignment-card ${this._stepAssignmentCategory==="individual"?"selected":""}"
3179
+ @click=${()=>{this._stepAssignmentCategory="individual",this._stepAssignmentType="subject",this._stepAssignmentTarget=""}}
3180
+ >
3181
+ <div class="assignment-card-radio"></div>
3182
+ <div class="assignment-card-content">
3183
+ <div class="assignment-card-title">Individual</div>
3184
+ <div class="assignment-card-description">
3185
+ Assign an individual user to this step.
3186
+ </div>
3187
+ </div>
3188
+ </div>
3189
+ <div
3190
+ class="assignment-card ${this._stepAssignmentCategory==="role"?"selected":""}"
3191
+ @click=${()=>{this._stepAssignmentCategory="role",this._stepAssignmentType="instance_role_assignee_select",this._stepAssignmentTarget=""}}
3192
+ >
3193
+ <div class="assignment-card-radio"></div>
3194
+ <div class="assignment-card-content">
3195
+ <div class="assignment-card-title">Groups</div>
3196
+ <div class="assignment-card-description">
3197
+ Assignment is based on individuals within a certain group.
3198
+ </div>
3199
+ </div>
3200
+ </div>
3201
+ </div>
3202
+
3203
+ ${this._stepAssignmentCategory==="individual"?d`
3204
+ <div class="assignment-radio-group">
3205
+ <label class="assignment-radio-option">
3206
+ <input
3207
+ type="radio"
3208
+ name="assignment-type"
3209
+ value="subject"
3210
+ .checked=${this._stepAssignmentType==="subject"}
3211
+ @change=${()=>{this._stepAssignmentType="subject",this._stepAssignmentTarget=""}}
3212
+ />
3213
+ <div class="assignment-radio-label">
3214
+ <div class="assignment-radio-title">Drill subject</div>
3215
+ <div class="assignment-radio-description">
3216
+ The step will be assigned to the subject of this drill.
3217
+ </div>
3218
+ </div>
3219
+ </label>
3220
+
3221
+ <label class="assignment-radio-option">
3222
+ <input
3223
+ type="radio"
3224
+ name="assignment-type"
3225
+ value="creator"
3226
+ .checked=${this._stepAssignmentType==="creator"}
3227
+ @change=${()=>{this._stepAssignmentType="creator",this._stepAssignmentTarget=""}}
3228
+ />
3229
+
3230
+ <div class="assignment-radio-label">
3231
+ <div class="assignment-radio-title">Drill creator</div>
3232
+ <div class="assignment-radio-description">
3233
+ The step will be assigned to the creator of this drill.
3234
+ </div>
3235
+ </div>
3236
+ </label>
3237
+
3238
+ <label class="assignment-radio-option">
3239
+ <input
3240
+ type="radio"
3241
+ name="assignment-type"
3242
+ value="instance_assignee_select"
3243
+ .checked=${this._stepAssignmentType==="instance_assignee_select"}
3244
+ @change=${()=>{this._stepAssignmentType="instance_assignee_select",this._stepAssignmentTarget=""}}
3245
+ />
3246
+ <div class="assignment-radio-label">
3247
+ <div class="assignment-radio-title">
3248
+ Assign at start of the Drill
3249
+ </div>
3250
+ <div class="assignment-radio-description">
3251
+ At the start of this Drill, the initiator will be able to choose
3252
+ an individual recipient.
3253
+ </div>
3254
+ </div>
3255
+ </label>
3256
+
3257
+ <label class="assignment-radio-option">
3258
+ <input
3259
+ type="radio"
3260
+ name="assignment-type"
3261
+ value="specific_user"
3262
+ .checked=${this._stepAssignmentType==="specific_user"}
3263
+ @change=${()=>{this._stepAssignmentType="specific_user"}}
3264
+ />
3265
+ <div class="assignment-radio-label">
3266
+ <div class="assignment-radio-title">Specific User</div>
3267
+ <div class="assignment-radio-description">
3268
+ Enter the email of a specific user to assign this step to.
3269
+ </div>
3270
+ </div>
3271
+ </label>
3272
+ </div>
3273
+
3274
+ ${this._stepAssignmentType==="specific_user"?d`
3275
+ <input
3276
+ type="email"
3277
+ class="assignment-select"
3278
+ placeholder="Enter user email"
3279
+ .value=${this._stepAssignmentTarget}
3280
+ @input=${t=>{const i=t.target;this._stepAssignmentTarget=i.value}}
3281
+ />
3282
+ `:""}
3283
+ `:d`
3284
+ <div class="assignment-radio-group">
3285
+ <label class="assignment-radio-option">
3286
+ <input
3287
+ type="radio"
3288
+ name="assignment-type"
3289
+ value="instance_role_assignee_select"
3290
+ checked
3291
+ />
3292
+ <div class="assignment-radio-label">
3293
+ <div class="assignment-radio-title">Select a group</div>
3294
+ <div class="assignment-radio-description">
3295
+ Members of the selected group will be eligible for assignment.
3296
+ </div>
3297
+ </div>
3298
+ </label>
3299
+ </div>
3300
+
3301
+ <select
3302
+ class="assignment-select"
3303
+ .value=${this._stepAssignmentTarget}
3304
+ @change=${t=>{const i=t.target;this._stepAssignmentTarget=i.value}}
3305
+ >
3306
+ <option value="">Select group</option>
3307
+ <option value="manager">Manager</option>
3308
+ <option value="hr">HR</option>
3309
+ <option value="admin">Admin</option>
3310
+ </select>
3311
+ `}
3312
+ </div>
3313
+ </div>
3314
+ <div class="modal-footer">
3315
+ <button class="cancel-button" @click=${this._closeStepModal}>Cancel</button>
3316
+ <button class="save-button" @click=${this._createStep}>Save</button>
3317
+ </div>
3318
+ </div>
3319
+ </div>
3320
+ `:""}
2800
3321
  <!-- Steps and Questions -->
2801
3322
  <div class="content-columns">
2802
3323
  <!-- Steps Section -->
@@ -2812,24 +3333,31 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2812
3333
  class="step-item ${this._selectedStepId===t.id?"selected":""} ${this._dragOverStepId===t.id?"drag-over":""}"
2813
3334
  @click=${()=>this._selectStep(t.id)}
2814
3335
  draggable="true"
2815
- @dragstart=${n=>this._handleDragStart(n,t.id)}
3336
+ @dragstart=${i=>this._handleDragStart(i,t.id)}
2816
3337
  @dragend=${this._handleDragEnd}
2817
- @dragover=${n=>this._handleDragOver(n,t.id)}
3338
+ @dragover=${i=>this._handleDragOver(i,t.id)}
2818
3339
  @dragleave=${this._handleDragLeave}
2819
- @drop=${n=>this._handleDrop(n,t.id)}
3340
+ @drop=${i=>this._handleDrop(i,t.id)}
2820
3341
  >
2821
3342
  <div class="step-handle">
2822
3343
  <svg
3344
+ xmlns="http://www.w3.org/2000/svg"
2823
3345
  width="16"
2824
3346
  height="16"
2825
- viewBox="0 0 16 16"
3347
+ viewBox="0 0 24 24"
2826
3348
  fill="none"
2827
3349
  stroke="currentColor"
2828
3350
  stroke-width="2"
3351
+ stroke-linecap="round"
3352
+ stroke-linejoin="round"
3353
+ class="lucide lucide-grip-vertical-icon lucide-grip-vertical"
2829
3354
  >
2830
- <line x1="4" y1="4" x2="12" y2="4" />
2831
- <line x1="4" y1="8" x2="12" y2="8" />
2832
- <line x1="4" y1="12" x2="12" y2="12" />
3355
+ <circle cx="9" cy="12" r="1" />
3356
+ <circle cx="9" cy="5" r="1" />
3357
+ <circle cx="9" cy="19" r="1" />
3358
+ <circle cx="15" cy="12" r="1" />
3359
+ <circle cx="15" cy="5" r="1" />
3360
+ <circle cx="15" cy="19" r="1" />
2833
3361
  </svg>
2834
3362
  </div>
2835
3363
  <div class="step-content">
@@ -2839,10 +3367,90 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2839
3367
  <div class="step-actions">
2840
3368
  <button
2841
3369
  class="step-menu"
2842
- @click=${n=>{n.stopPropagation(),this._showStepMenu(n,t.id)}}
3370
+ @click=${i=>{i.stopPropagation(),this._toggleStepMenu(i,t.id)}}
2843
3371
  >
2844
3372
 
2845
3373
  </button>
3374
+ ${this._openMenuStepId===t.id?d`
3375
+ <div class="step-menu-dropdown">
3376
+ <button
3377
+ class="step-menu-item"
3378
+ @click=${i=>{i.stopPropagation(),this._editStep(t.id)}}
3379
+ >
3380
+ <span class="step-menu-icon">
3381
+ <svg
3382
+ xmlns="http://www.w3.org/2000/svg"
3383
+ width="16"
3384
+ height="16"
3385
+ viewBox="0 0 24 24"
3386
+ fill="none"
3387
+ stroke="currentColor"
3388
+ stroke-width="2"
3389
+ stroke-linecap="round"
3390
+ stroke-linejoin="round"
3391
+ class="lucide lucide-pencil-icon lucide-pencil"
3392
+ >
3393
+ <path
3394
+ d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"
3395
+ />
3396
+ <path d="m15 5 4 4" />
3397
+ </svg>
3398
+ </span>
3399
+ <span>Edit</span>
3400
+ </button>
3401
+ <button
3402
+ class="step-menu-item"
3403
+ @click=${i=>{i.stopPropagation(),this._duplicateStep(t.id)}}
3404
+ >
3405
+ <span class="step-menu-icon"
3406
+ ><svg
3407
+ xmlns="http://www.w3.org/2000/svg"
3408
+ width="16"
3409
+ height="16"
3410
+ viewBox="0 0 24 24"
3411
+ fill="none"
3412
+ stroke="currentColor"
3413
+ stroke-width="2"
3414
+ stroke-linecap="round"
3415
+ stroke-linejoin="round"
3416
+ class="lucide lucide-copy-plus-icon lucide-copy-plus"
3417
+ >
3418
+ <line x1="15" x2="15" y1="12" y2="18" />
3419
+ <line x1="12" x2="18" y1="15" y2="15" />
3420
+ <rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
3421
+ <path
3422
+ d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
3423
+ /></svg
3424
+ ></span>
3425
+ <span>Duplicate</span>
3426
+ </button>
3427
+ <button
3428
+ class="step-menu-item danger"
3429
+ @click=${i=>{i.stopPropagation(),confirm("Are you sure you want to delete this step?")&&this._deleteStep(t.id)}}
3430
+ >
3431
+ <span class="step-menu-icon"
3432
+ ><svg
3433
+ xmlns="http://www.w3.org/2000/svg"
3434
+ width="16"
3435
+ height="16"
3436
+ viewBox="0 0 24 24"
3437
+ fill="none"
3438
+ stroke="currentColor"
3439
+ stroke-width="2"
3440
+ stroke-linecap="round"
3441
+ stroke-linejoin="round"
3442
+ class="lucide lucide-trash2-icon lucide-trash-2"
3443
+ >
3444
+ <path d="M10 11v6" />
3445
+ <path d="M14 11v6" />
3446
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
3447
+ <path d="M3 6h18" />
3448
+ <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /></svg
3449
+ ></span>
3450
+ <span>Delete</span>
3451
+ </button>
3452
+ </div>
3453
+ `:""}
2846
3454
  </div>
2847
3455
  </div>
2848
3456
  `))||[]}
@@ -2856,9 +3464,9 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2856
3464
  <button class="add-button" @click=${()=>this._addQuestion()}>Add</button>
2857
3465
  </div>
2858
3466
 
2859
- ${i&&i.elements&&i.elements.length>0?d`
3467
+ ${s&&s.elements&&s.elements.length>0?d`
2860
3468
  <div class="elements-list">
2861
- ${i.elements.map(t=>{const n="label"in t&&"required"in t,s="content"in t;if(n){const r=t;return d`
3469
+ ${s.elements.map(t=>{const i="label"in t&&"required"in t,n="content"in t;if(i){const r=t;return d`
2862
3470
  <div class="question-item">
2863
3471
  <div class="question-header">
2864
3472
  <h3 class="question-title">
@@ -2894,7 +3502,24 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2894
3502
  @click=${()=>this._deleteQuestion(r.id)}
2895
3503
  title="Delete question"
2896
3504
  >
2897
- 🗑️
3505
+ <svg
3506
+ xmlns="http://www.w3.org/2000/svg"
3507
+ width="16"
3508
+ height="16"
3509
+ viewBox="0 0 24 24"
3510
+ fill="none"
3511
+ stroke="currentColor"
3512
+ stroke-width="2"
3513
+ stroke-linecap="round"
3514
+ stroke-linejoin="round"
3515
+ class="lucide lucide-trash2-icon lucide-trash-2"
3516
+ >
3517
+ <path d="M10 11v6" />
3518
+ <path d="M14 11v6" />
3519
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
3520
+ <path d="M3 6h18" />
3521
+ <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
3522
+ </svg>
2898
3523
  </button>
2899
3524
  </div>
2900
3525
  </div>
@@ -2904,7 +3529,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2904
3529
  class="question-label-input"
2905
3530
  placeholder="Question label"
2906
3531
  .value=${r.label||""}
2907
- @input=${o=>{const a=o.target;this._updateQuestion(r.id,{label:a.value}),this.requestUpdate()}}
3532
+ @input=${o=>{const a=o.target;this._updateQuestion(r.id,{label:a.value})}}
2908
3533
  />
2909
3534
 
2910
3535
  ${this._renderQuestionTypeSpecificFields(r)}
@@ -2918,7 +3543,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2918
3543
  Required
2919
3544
  </label>
2920
3545
  </div>
2921
- `}else if(s){const r=t;return d`
3546
+ `}else if(n){const r=t;return d`
2922
3547
  <div class="question-item">
2923
3548
  <div class="question-header">
2924
3549
  <h3 class="question-title">
@@ -2954,7 +3579,24 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2954
3579
  @click=${()=>this._deleteQuestion(t.id)}
2955
3580
  title="Delete content"
2956
3581
  >
2957
-
3582
+ <svg
3583
+ xmlns="http://www.w3.org/2000/svg"
3584
+ width="16"
3585
+ height="16"
3586
+ viewBox="0 0 24 24"
3587
+ fill="none"
3588
+ stroke="currentColor"
3589
+ stroke-width="2"
3590
+ stroke-linecap="round"
3591
+ stroke-linejoin="round"
3592
+ class="lucide lucide-trash2-icon lucide-trash-2"
3593
+ >
3594
+ <path d="M10 11v6" />
3595
+ <path d="M14 11v6" />
3596
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
3597
+ <path d="M3 6h18" />
3598
+ <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
3599
+ </svg>
2958
3600
  </button>
2959
3601
  </div>
2960
3602
  </div>
@@ -2995,31 +3637,31 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
2995
3637
  ${ut}
2996
3638
  ${Pe}
2997
3639
  ${ht}
2998
- `,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,"workflow",2),w=E([Ie("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 l=this.validateQuestion(a,t[a.id]);l&&(s=!1,r[a.id]=l.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),l=o?{...o,currentStepId:(u=(c=o.steps)==null?void 0:c[n])==null?void 0:u.id,completedSteps:Array.from(r),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:l};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"}}/*!
3640
+ `,S([b()],w.prototype,"_templateData",2),S([b()],w.prototype,"_showStepModal",2),S([b()],w.prototype,"_stepFormData",2),S([b()],w.prototype,"_draggedStepId",2),S([b()],w.prototype,"_dragOverStepId",2),S([b()],w.prototype,"_selectedStepId",2),S([b()],w.prototype,"_questions",2),S([b()],w.prototype,"_editingStepId",2),S([b()],w.prototype,"_stepAssignmentCategory",2),S([b()],w.prototype,"_stepAssignmentType",2),S([b()],w.prototype,"_stepAssignmentTarget",2),S([E({attribute:!1})],w.prototype,"onCancel",2),S([E({attribute:!1})],w.prototype,"workflow",2),S([b()],w.prototype,"_openMenuStepId",2),w=S([ze("builder-widget")],w);class ft{constructor(e,t){this.signaturePads=e,this.savedSignatures=t}validateStep(e,t,i){if(i==="preview")return{isValid:!0,errors:{}};if(!e)return{isValid:!1,errors:{}};let n=!0;const r={};for(const o of e.elements)if(this.isQuestionElement(o)){const a=o;if(a.required){const l=this.validateQuestion(a,t[a.id]);l&&(n=!1,r[a.id]=l.message)}}return{isValid:n,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 i=this.signaturePads.get(e.id);return!i||i.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,i,n,r,o){var c,u,h;const a=this.getStorageKey(e),l=o?{...o,currentStepId:(u=(c=o.steps)==null?void 0:c[i])==null?void 0:u.id,completedSteps:Array.from(r),steps:(h=o.steps)==null?void 0:h.map(m=>({...m,responses:m.responses||[]}))}:null,p={formData:t,timestamp:new Date().toISOString(),stepIndex:i,savedSignatures:Array.from(n),completedSteps:Array.from(r),instance:l};try{localStorage.setItem(a,JSON.stringify(p))}catch(m){console.warn("Failed to save form data to localStorage:",m)}}restoreFormData(e){const t=this.getStorageKey(e);try{const i=localStorage.getItem(t);if(!i)return null;const n=JSON.parse(i);return{formData:n.formData||{},stepIndex:n.stepIndex||0,savedSignatures:new Set(n.savedSignatures||[]),completedSteps:new Set(n.completedSteps||[]),savedInstance:n.instance||null}}catch(i){return console.warn("Failed to restore form data from localStorage:",i),null}}clearFormData(e,t="completed workflow"){const i=this.getStorageKey(e);try{localStorage.removeItem(i),console.log(`Cleared saved form data for ${t}`)}catch(n){console.warn("Failed to clear saved form data:",n)}}shouldRestoreData(e){return e==="default"}}/*!
2999
3641
  * Signature Pad v5.0.10 | https://github.com/szimek/signature_pad
3000
3642
  * (c) 2025 Szymon Nowak | Released under the MIT license
3001
- */class Z{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,l={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=l.x-p.x,f=l.y-p.y,b=c+u==0?0:u/(c+u),$={x:p.x+h*b,y:p.y+f*b},ne=t.x-$.x,se=t.y-$.y;return{c1:new Z(l.x+ne,l.y+se),c2:new Z(p.x+ne,p.y+se)}}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),l=this.point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){const p=a-n,c=l-s;t+=Math.sqrt(p*p+c*c)}n=a,s=l}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 ee 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(ee.prototype._strokeUpdate,this.throttle):ee.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,l=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,l),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 l=this._addPoint(t,a);r?l&&this._drawCurve(l,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 Z(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,l=a*a,p=l*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*l*e.control2.x,f+=p*e.endPoint.x;let b=h*e.startPoint.y;b+=3*u*a*e.control1.y,b+=3*c*l*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 l=r[a],p=new Z(l.x,l.y,l.pressure,l.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,l=document.createElementNS("http://www.w3.org/2000/svg","svg");if(l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),l.setAttribute("viewBox",`${s} ${r} ${o} ${a}`),l.setAttribute("width",o.toString()),l.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),l.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"),l.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),l.appendChild(b)}),l.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 ee(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 l=a[e];if(this.isStepAssignedToUser(l)){const p=s.has(l.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(l=>t.steps.findIndex(p=>p.id===l.id)).sort((l,p)=>l-p);let o=-1;for(const l of r){const p=t.steps[l];n.has(p.id)&&(o=l)}let a=-1;for(const l of r)if(l>o){a=l;break}return a!==-1?e<=a&&this.isStepAssignedToUser(t.steps[e]):this.isStepAssignedToUser(t.steps[e])}}const te=class te{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 te.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}};te.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"];let fe=te;const ie=class ie{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 l=this.hasFileChanged(e,a,n.savedInstance);l&&n.mode!=="preview"?this.executeFileUploadCallback(e,r,a,n):this.logSkippedCallback(e,n.mode,l),(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>ie.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)}};ie.MAX_FILE_SIZE=5*1024*1024;let me=ie;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"?d`<div class="print-response-value textarea-response">
3643
+ */class Z{constructor(e,t,i,n){if(isNaN(e)||isNaN(t))throw new Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=i||0,this.time=n||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 i=this.calculateControlPoints(e[0],e[1],e[2]).c2,n=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new ge(e[1],i,n,e[2],t.start,t.end)}static calculateControlPoints(e,t,i){const n=e.x-t.x,r=e.y-t.y,o=t.x-i.x,a=t.y-i.y,l={x:(e.x+t.x)/2,y:(e.y+t.y)/2},p={x:(t.x+i.x)/2,y:(t.y+i.y)/2},c=Math.sqrt(n*n+r*r),u=Math.sqrt(o*o+a*a),h=l.x-p.x,m=l.y-p.y,v=c+u==0?0:u/(c+u),D={x:p.x+h*v,y:p.y+m*v},se=t.x-D.x,ne=t.y-D.y;return{c1:new Z(l.x+se,l.y+ne),c2:new Z(p.x+se,p.y+ne)}}constructor(e,t,i,n,r,o){this.startPoint=e,this.control2=t,this.control1=i,this.endPoint=n,this.startWidth=r,this.endWidth=o}length(){let t=0,i,n;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),l=this.point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){const p=a-i,c=l-n;t+=Math.sqrt(p*p+c*c)}i=a,n=l}return t}point(e,t,i,n,r){return t*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*n*(1-e)*e*e+r*e*e*e}}class vt{constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,i){this._et.addEventListener(e,t,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,i){this._et.removeEventListener(e,t,i)}}function xt(s,e=250){let t=0,i=null,n,r,o;const a=()=>{t=Date.now(),i=null,n=s.apply(r,o),i||(r=null,o=[])};return function(...p){const c=Date.now(),u=e-(c-t);return r=this,o=p,u<=0||u>e?(i&&(clearTimeout(i),i=null),t=c,n=s.apply(r,o),i||(r=null,o=[])):i||(i=window.setTimeout(a,u)),n}}class ee extends vt{constructor(e,t={}){var i,n,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=(i=t.throttle)!==null&&i!==void 0?i:16,this.minDistance=(n=t.minDistance)!==null&&n!==void 0?n: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(ee.prototype._strokeUpdate,this.throttle):ee.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((i,n)=>{const r=new Image,o=t.ratio||window.devicePixelRatio||1,a=t.width||this.canvas.width/o,l=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,l),i()},r.onerror=u=>{n(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:i}=this._getListenerFunctions();switch(e.event.type){case"mousedown":i("mousemove",this._handleMouseMove,{passive:!1}),i("mouseup",this._handleMouseUp,{passive:!1});break;case"touchstart":i("touchmove",this._handleTouchMove,{passive:!1}),i("touchend",this._handleTouchEnd,{passive:!1});break;case"pointerdown":i("pointermove",this._handlePointerMove,{passive:!1}),i("pointerup",this._handlePointerUp,{passive:!1});break}this._drawingStroke=!0;const n=this._getPointGroupOptions(),r=Object.assign(Object.assign({},n),{points:[]});this._data.push(r),this._reset(n),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),i=this._data[this._data.length-1],n=i.points,r=n.length>0&&n[n.length-1],o=r?t.distanceTo(r)<=this.minDistance:!1,a=this._getPointGroupOptions(i);if(!r||!(r&&o)){const l=this._addPoint(t,a);r?l&&this._drawCurve(l,a):this._drawDot(t,a),n.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,i){const n=this.canvas.getBoundingClientRect();return new Z(e-n.left,t-n.top,i,new Date().getTime())}_addPoint(e,t){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const n=this._calculateCurveWidths(i[1],i[2],t),r=ge.fromPoints(i,n);return i.shift(),r}return null}_calculateCurveWidths(e,t,i){const n=i.velocityFilterWeight*t.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(n,i),o={end:r,start:this._lastWidth};return this._lastVelocity=n,this._lastWidth=r,o}_strokeWidth(e,t){return Math.max(t.maxWidth/(e+1),t.minWidth)}_drawCurveSegment(e,t,i){const n=this._ctx;n.moveTo(e,t),n.arc(e,t,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,t){const i=this._ctx,n=e.endWidth-e.startWidth,r=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=t.penColor;for(let o=0;o<r;o+=1){const a=o/r,l=a*a,p=l*a,c=1-a,u=c*c,h=u*c;let m=h*e.startPoint.x;m+=3*u*a*e.control1.x,m+=3*c*l*e.control2.x,m+=p*e.endPoint.x;let v=h*e.startPoint.y;v+=3*u*a*e.control1.y,v+=3*c*l*e.control2.y,v+=p*e.endPoint.y;const D=Math.min(e.startWidth+p*n,t.maxWidth);this._drawCurveSegment(m,v,D)}i.closePath(),i.fill()}_drawDot(e,t){const i=this._ctx,n=t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,n),i.closePath(),i.fillStyle=t.penColor,i.fill()}_fromData(e,t,i){for(const n of e){const{points:r}=n,o=this._getPointGroupOptions(n);if(r.length>1)for(let a=0;a<r.length;a+=1){const l=r[a],p=new Z(l.x,l.y,l.pressure,l.time);a===0&&this._reset(o);const c=this._addPoint(p,o);c&&t(c,o)}else this._reset(o),i(r[0],o)}}toSVG({includeBackgroundColor:e=!1}={}){const t=this._data,i=Math.max(window.devicePixelRatio||1,1),n=0,r=0,o=this.canvas.width/i,a=this.canvas.height/i,l=document.createElementNS("http://www.w3.org/2000/svg","svg");if(l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),l.setAttribute("viewBox",`${n} ${r} ${o} ${a}`),l.setAttribute("width",o.toString()),l.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),l.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"),l.appendChild(u)}},(p,{penColor:c,dotSize:u,minWidth:h,maxWidth:m})=>{const v=document.createElement("circle"),D=u>0?u:(h+m)/2;v.setAttribute("r",D.toString()),v.setAttribute("cx",p.x.toString()),v.setAttribute("cy",p.y.toString()),v.setAttribute("fill",c),l.appendChild(v)}),l.outerHTML}}class _t{constructor(e){this.signaturePads=new Map,this.canvasElements=new Map,this.onSignatureChange=e}initializeSignaturePad(e,t){const i=t==null?void 0:t.getElementById(`signature-${e}`);if(!i)return null;this.clearSignaturePad(e),this.resizeCanvas(i);const n=new ee(i,{backgroundColor:"rgb(255, 255, 255)",penColor:"rgb(0, 0, 0)",minWidth:.5,maxWidth:2.5});return this.signaturePads.set(e,n),this.canvasElements.set(e,i),n.addEventListener("endStroke",()=>{this.handleSignatureChange(e)}),n}handleSignatureChange(e){var r;const t=this.signaturePads.get(e);if(!t)return;const i=!t.isEmpty(),n=i?t.toData():null;(r=this.onSignatureChange)==null||r.call(this,{questionId:e,hasSignature:i,signatureData:n})}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 i=t.toSVG(),n=t.toDataURL();return{questionId:e,svgData:i,dataURL:n}}restoreSignature(e,t){const i=this.signaturePads.get(e);if(!i||!t)return!1;try{return i.clear(),i.fromData(t),!0}catch(n){return console.warn(`Failed to restore signature for ${e}:`,n),!1}}handleResize(){this.signaturePads.forEach((e,t)=>{const i=this.canvasElements.get(t);if(i){this.resizeCanvas(i);const n=e.toData();e.clear(),e.fromData(n)}})}resizeCanvas(e){const t=Math.max(window.devicePixelRatio||1,1),i=window.getComputedStyle(e),n=parseFloat(i.width),r=parseFloat(i.height);e.width=n*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 yt{trackQuestionResponse(e,t,i){if(!e)return;e.responses||(e.responses=[]);const n=e.responses.findIndex(o=>o.elementId===t),r={elementId:t,value:i,answeredAt:new Date};n>=0?e.responses[n]=r:e.responses.push(r)}updateInstanceWithFormData(e,t){e!=null&&e.steps&&e.steps.forEach(i=>{i.responses||(i.responses=[]),i.elements.forEach(n=>{if(this.isQuestionElement(n.type)){const r=t[n.id];if(r!==void 0&&i.responses){let o=i.responses.find(a=>a.elementId===n.id);o?(o.value=r,o.answeredAt=new Date):(o={elementId:n.id,value:r,answeredAt:new Date},i.responses.push(o))}}})})}extractFormDataFromSteps(e){const t={};return e.forEach(i=>{i.responses&&i.responses.forEach(n=>{t[n.elementId]=n.value})}),t}hasChangedFromPrevious(e,t,i){if(!(i!=null&&i.steps))return!0;for(const n of i.steps)if(n.responses){const r=n.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 i=e+1;i<t.steps.length;i++){const n=t.steps[i];if(this.isStepAssignedToUser(n))return i}return-1}isLastAssignedStep(e,t){if(this.mode==="preview"||this.mode==="admin"||this.mode==="view-only"||this.mode==="print"){const i=t==null?void 0:t.steps;return e===((i==null?void 0:i.length)||0)-1}return this.findNextAssignedStep(e,t)===-1}canNavigateToStep(e,t,i,n,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=i.steps;return!p||e<0||e>=p.length?{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"}:{canNavigate:!0,newStepIndex:e}}const a=i.steps;if(!a||e<0||e>=a.length)return{canNavigate:!1,newStepIndex:t,reason:"Invalid step index"};const l=a[e];if(this.isStepAssignedToUser(l)){const p=n.has(l.id),c=this.isStepWithinAllowedRange(e,i,n);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,i){if(!(t!=null&&t.steps))return!1;const r=this.getAssignedSteps(t).map(l=>t.steps.findIndex(p=>p.id===l.id)).sort((l,p)=>l-p);let o=-1;for(const l of r){const p=t.steps[l];i.has(p.id)&&(o=l)}let a=-1;for(const l of r)if(l>o){a=l;break}return a!==-1?e<=a&&this.isStepAssignedToUser(t.steps[e]):this.isStepAssignedToUser(t.steps[e])}}const te=class te{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(i=>{i.responses&&i.responses.forEach(n=>{t[n.elementId]=n.value})}),this.formData=t}reset(){this.formData={},this.validationErrors={}}isQuestionElement(e){return te.QUESTION_ELEMENT_TYPES.includes(e.type)}getStepFormData(e){var i;const t={};return(i=e.elements)==null||i.forEach(n=>{if(this.isQuestionElement(n)){const r=n,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}};te.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"];let me=te;const ie=class ie{constructor(e,t){this.formStateManager=e,this.responseTracker=t}handleFileUpload(e,t,i){var p,c,u,h,m;const n=t.target,r=(p=n.files)==null?void 0:p[0];if(!r){this.clearFile(e),(c=i.onRequestUpdate)==null||c.call(i);return}const o=this.validateFileSize(r);if(o){this.handleFileValidationError(e,o,n),(u=i.onRequestUpdate)==null||u.call(i);return}this.formStateManager.clearValidationError(e);const a=this.createFileInfo(r);this.formStateManager.setFormField(e,a);const l=this.hasFileChanged(e,a,i.savedInstance);l&&i.mode!=="preview"?this.executeFileUploadCallback(e,r,a,i):this.logSkippedCallback(e,i.mode,l),(h=i.onRequestUpdate)==null||h.call(i),i.mode!=="admin"&&((m=i.onFormDataSave)==null||m.call(i))}clearFile(e){this.formStateManager.setFormField(e,null),this.formStateManager.clearValidationError(e)}validateFileSize(e){return e.size>ie.MAX_FILE_SIZE?`File size must be less than 5MB. Current size: ${(e.size/1024/1024).toFixed(2)}MB`:null}handleFileValidationError(e,t,i){this.formStateManager.setValidationError(e,t),this.formStateManager.setFormField(e,null),i.value=""}createFileInfo(e){return{name:e.name,size:e.size,type:e.type,lastModified:e.lastModified}}hasFileChanged(e,t,i){if(!(i!=null&&i.steps))return!0;for(const n of i.steps)if(n.responses){const r=n.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,i,n){var r,o;console.log("File changed, calling callback for:",e),console.log("Callback function exists:",!!n.onFileUploaded),n.onFileUploaded&&n.onFileUploaded({instanceId:(r=n.instance)==null?void 0:r.id,stepId:(o=n.currentStep)==null?void 0:o.id,questionId:e,file:t,fileName:i.name,fileSize:i.size,fileType:i.type})}logSkippedCallback(e,t,i){t==="preview"?console.log("Preview mode: skipping file upload callback for:",e):i||console.log("File unchanged, skipping callback for:",e)}};ie.MAX_FILE_SIZE=5*1024*1024;let fe=ie;class k{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,i=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+i[n]}static _extractFilenameFromUrl(e){try{return new URL(e).pathname.split("/").pop()||""||"Uploaded File"}catch{const t=e.split("/"),i=t[t.length-1];return i&&i.includes(".")?i:"Uploaded File"}}static _guessFileTypeFromUrl(e){var r;const i=(r=k._extractFilenameFromUrl(e).split(".").pop())==null?void 0:r.toLowerCase();return i?{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"}[i]||`${i.toUpperCase()} File`:"Unknown"}static renderTextArea(e,t,i){return i.mode==="print"?d`<div class="print-response-value textarea-response">
3002
3644
  ${t||d`<span class="print-no-response">No response</span>`}
3003
3645
  </div>`:d`<textarea
3004
3646
  id=${e.id}
3005
3647
  .value=${t}
3006
3648
  ?required=${e.required}
3007
- ?disabled=${this._isInputDisabled(n)}
3649
+ ?disabled=${this._isInputDisabled(i)}
3008
3650
  placeholder="Your Response"
3009
- @input=${s=>n.handlers.handleInputChange(e.id,s)}
3010
- ></textarea>`}static renderSelect(e,t,n){var s;return n.mode==="print"?d`<div class="print-response-value select-response">
3651
+ @input=${n=>i.handlers.handleInputChange(e.id,n)}
3652
+ ></textarea>`}static renderSelect(e,t,i){var n;return i.mode==="print"?d`<div class="print-response-value select-response">
3011
3653
  ${t||d`<span class="print-no-response">No selection made</span>`}
3012
3654
  </div>`:d`<select
3013
3655
  id=${e.id}
3014
3656
  .value=${t}
3015
3657
  ?required=${e.required}
3016
- ?disabled=${this._isInputDisabled(n)}
3658
+ ?disabled=${this._isInputDisabled(i)}
3017
3659
  class=${t===""?"placeholder":""}
3018
- @change=${r=>n.handlers.handleInputChange(e.id,r)}
3660
+ @change=${r=>i.handlers.handleInputChange(e.id,r)}
3019
3661
  >
3020
3662
  <option value="">Choose</option>
3021
- ${(s=e.options)==null?void 0:s.map(r=>d`<option value=${r}>${r}</option>`)}
3022
- </select>`}static renderRadio(e,t,n){var o;const s=this._isInputDisabled(n),r=n.mode==="print";return r?d`<div class="print-response-value radio-response">
3663
+ ${(n=e.options)==null?void 0:n.map(r=>d`<option value=${r}>${r}</option>`)}
3664
+ </select>`}static renderRadio(e,t,i){var o;const n=this._isInputDisabled(i),r=i.mode==="print";return r?d`<div class="print-response-value radio-response">
3023
3665
  ${t||d`<span class="print-no-response">No selection made</span>`}
3024
3666
  </div>`:d`<div class="radio-group ${r?"print-mode":""}">
3025
3667
  ${(o=e.options)==null?void 0:o.map(a=>d`
@@ -3029,13 +3671,13 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3029
3671
  name=${e.id}
3030
3672
  value=${a}
3031
3673
  .checked=${t===a}
3032
- ?disabled=${s}
3033
- @change=${r?null:l=>n.handlers.handleInputChange(e.id,l)}
3674
+ ?disabled=${n}
3675
+ @change=${r?null:l=>i.handlers.handleInputChange(e.id,l)}
3034
3676
  />
3035
3677
  <span class="radio-label">${a}</span>
3036
3678
  </label>
3037
3679
  `)}
3038
- </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 d`<div class="print-response-value checkbox-response">
3680
+ </div>`}static renderCheckbox(e,t,i){var o;const n=this._isInputDisabled(i),r=i.mode==="print";if(e.options&&e.options.length>0){if(r){const a=Array.isArray(t)?t:[];return d`<div class="print-response-value checkbox-response">
3039
3681
  ${a.length>0?a.map(l=>d`<div>• ${l}</div>`):d`<span class="print-no-response">No selections made</span>`}
3040
3682
  </div>`}return d`<div class="checkbox-group ${r?"print-mode":""}">
3041
3683
  ${(o=e.options)==null?void 0:o.map(a=>d`
@@ -3045,8 +3687,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3045
3687
  name=${e.id}
3046
3688
  value=${a}
3047
3689
  .checked=${Array.isArray(t)?t.includes(a):!1}
3048
- ?disabled=${s}
3049
- @change=${r?null:l=>n.handlers.handleCheckboxGroupChange(e.id,a,l)}
3690
+ ?disabled=${n}
3691
+ @change=${r?null:l=>i.handlers.handleCheckboxGroupChange(e.id,a,l)}
3050
3692
  />
3051
3693
  <span class="checkbox-label">${a}</span>
3052
3694
  </label>
@@ -3058,14 +3700,14 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3058
3700
  type="checkbox"
3059
3701
  id=${e.id}
3060
3702
  .checked=${!!t}
3061
- ?disabled=${s}
3062
- @change=${r?null:a=>n.handlers.handleCheckboxChange(e.id,a)}
3703
+ ?disabled=${n}
3704
+ @change=${r?null:a=>i.handlers.handleCheckboxChange(e.id,a)}
3063
3705
  />
3064
3706
  <span class="checkbox-label">${e.label}</span>
3065
- </label>`}static renderSignature(e,t,n){const s=n.formData[e.id],r=!!n.formData[e.id],o=n.savedSignatures.has(e.id),a=n.replacingSignatures.has(e.id);if(n.mode==="print")return s&&typeof s=="string"?d`
3707
+ </label>`}static renderSignature(e,t,i){const n=i.formData[e.id],r=!!i.formData[e.id],o=i.savedSignatures.has(e.id),a=i.replacingSignatures.has(e.id);if(i.mode==="print")return n&&typeof n=="string"?d`
3066
3708
  <div class="print-response-value signature-response">
3067
3709
  <img
3068
- src="${s}"
3710
+ src="${n}"
3069
3711
  alt="Digital Signature"
3070
3712
  class="signature-image"
3071
3713
  @error=${l=>{var u;const p=l.target;p.style.display="none";const c=(u=p.parentElement)==null?void 0:u.querySelector(".signature-fallback");c&&c.classList.remove("hidden")}}
@@ -3076,10 +3718,10 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3076
3718
  </div>
3077
3719
  `:d`<div class="print-response-value signature-response">
3078
3720
  <span class="print-no-response">No signature provided</span>
3079
- </div>`;if(n.mode==="view-only")return s&&typeof s=="string"?d`
3721
+ </div>`;if(i.mode==="view-only")return n&&typeof n=="string"?d`
3080
3722
  <div class="signature-view-only">
3081
3723
  <img
3082
- src="${s}"
3724
+ src="${n}"
3083
3725
  alt="Digital Signature"
3084
3726
  class="signature-image"
3085
3727
  @error=${l=>{var u;const p=l.target;p.style.display="none";const c=(u=p.parentElement)==null?void 0:u.querySelector(".signature-fallback");c&&c.classList.remove("hidden")}}
@@ -3092,12 +3734,12 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3092
3734
  <div class="signature-view-only">
3093
3735
  <span class="no-signature">No signature captured</span>
3094
3736
  </div>
3095
- `;if(n.mode==="admin"&&s&&typeof s=="string"&&!a){const l=s.trim().startsWith("<svg");return d`
3737
+ `;if(i.mode==="admin"&&n&&typeof n=="string"&&!a){const l=n.trim().startsWith("<svg");return d`
3096
3738
  <div class="signature-admin-display">
3097
3739
  <div class="signature-existing">
3098
- ${l?d` <div class="signature-svg-container" .innerHTML=${s}></div> `:d`
3740
+ ${l?d` <div class="signature-svg-container" .innerHTML=${n}></div> `:d`
3099
3741
  <img
3100
- src="${s}"
3742
+ src="${n}"
3101
3743
  alt="Digital Signature"
3102
3744
  class="signature-image"
3103
3745
  @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")}}
@@ -3111,21 +3753,21 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3111
3753
  <button
3112
3754
  type="button"
3113
3755
  class="signature-replace-btn"
3114
- @click=${()=>n.handlers.startReplaceSignature(e.id)}
3756
+ @click=${()=>i.handlers.startReplaceSignature(e.id)}
3115
3757
  >
3116
3758
  ✏️ Replace Signature
3117
3759
  </button>
3118
3760
  </div>
3119
3761
  </div>
3120
3762
  `}return d`
3121
- <div class="signature-container ${this._isInputDisabled(n)?"disabled":""}">
3763
+ <div class="signature-container ${this._isInputDisabled(i)?"disabled":""}">
3122
3764
  <canvas id="signature-${e.id}" class="signature-canvas"></canvas>
3123
3765
  <div class="signature-controls">
3124
3766
  <button
3125
3767
  type="button"
3126
3768
  class="signature-clear-btn"
3127
- ?disabled=${this._isInputDisabled(n)}
3128
- @click=${()=>n.handlers.clearSignature(e.id)}
3769
+ ?disabled=${this._isInputDisabled(i)}
3770
+ @click=${()=>i.handlers.clearSignature(e.id)}
3129
3771
  >
3130
3772
  Clear
3131
3773
  </button>
@@ -3133,41 +3775,41 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3133
3775
  <button
3134
3776
  type="button"
3135
3777
  class="signature-save-btn"
3136
- ?disabled=${this._isInputDisabled(n)}
3137
- @click=${()=>n.handlers.saveSignature(e.id)}
3778
+ ?disabled=${this._isInputDisabled(i)}
3779
+ @click=${()=>i.handlers.saveSignature(e.id)}
3138
3780
  >
3139
3781
  Save
3140
3782
  </button>
3141
3783
  `:""}
3142
3784
  ${o?d` <span class="signature-saved">✓ Saved</span> `:""}
3143
- ${n.mode==="admin"&&a?d`
3785
+ ${i.mode==="admin"&&a?d`
3144
3786
  <button
3145
3787
  type="button"
3146
3788
  class="signature-cancel-btn"
3147
- @click=${()=>n.handlers.cancelReplaceSignature(e.id)}
3789
+ @click=${()=>i.handlers.cancelReplaceSignature(e.id)}
3148
3790
  >
3149
3791
  Cancel
3150
3792
  </button>
3151
3793
  `:""}
3152
3794
  </div>
3153
3795
  </div>
3154
- `}static renderFileUpload(e,t,n){const s=n.formData[e.id];if(n.mode==="view-only"||n.mode==="print")if(s){const r=typeof s=="string",o=typeof s=="object"&&s.name;if(n.mode==="print"){if(o)return d`
3796
+ `}static renderFileUpload(e,t,i){const n=i.formData[e.id];if(i.mode==="view-only"||i.mode==="print")if(n){const r=typeof n=="string",o=typeof n=="object"&&n.name;if(i.mode==="print"){if(o)return d`
3155
3797
  <div class="print-response-value file-response">
3156
- 📎 ${s.name}
3157
- ${s.size?d` <span class="file-size"
3158
- >(${y._formatFileSize(s.size)})</span
3798
+ 📎 ${n.name}
3799
+ ${n.size?d` <span class="file-size"
3800
+ >(${k._formatFileSize(n.size)})</span
3159
3801
  >`:""}
3160
3802
  </div>
3161
- `;if(r){const a=y._extractFilenameFromUrl(s);return d` <div class="print-response-value file-response">📎 ${a}</div> `}else return d` <div class="print-response-value file-response">📎 ${s}</div> `}else{const a=r?s:"#",l=o?s.name:r?y._extractFilenameFromUrl(s):"View File";return d`
3803
+ `;if(r){const a=k._extractFilenameFromUrl(n);return d` <div class="print-response-value file-response">📎 ${a}</div> `}else return d` <div class="print-response-value file-response">📎 ${n}</div> `}else{const a=r?n:"#",l=o?n.name:r?k._extractFilenameFromUrl(n):"View File";return d`
3162
3804
  <div class="file-upload-view-only">
3163
3805
  <a href="${a}" target="_blank" class="file-link"> 📎 ${l} </a>
3164
- ${o&&s.size?d`
3806
+ ${o&&n.size?d`
3165
3807
  <span class="file-size-info"
3166
- >(${y._formatFileSize(s.size)})</span
3808
+ >(${k._formatFileSize(n.size)})</span
3167
3809
  >
3168
3810
  `:""}
3169
3811
  </div>
3170
- `}}else return n.mode==="print"?d`
3812
+ `}}else return i.mode==="print"?d`
3171
3813
  <div class="print-response-value file-response">
3172
3814
  <span class="print-no-response">No file uploaded</span>
3173
3815
  </div>
@@ -3181,41 +3823,41 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3181
3823
  type="file"
3182
3824
  id=${e.id}
3183
3825
  ?required=${e.required}
3184
- ?disabled=${this._isInputDisabled(n)}
3185
- @change=${r=>n.handlers.handleFileUpload(e.id,r)}
3826
+ ?disabled=${this._isInputDisabled(i)}
3827
+ @change=${r=>i.handlers.handleFileUpload(e.id,r)}
3186
3828
  />
3187
- ${s?d`
3829
+ ${n?d`
3188
3830
  <div class="file-preview">
3189
- <span class="file-name">${s.name||"File selected"}</span>
3831
+ <span class="file-name">${n.name||"File selected"}</span>
3190
3832
  <button
3191
3833
  type="button"
3192
3834
  class="file-clear-btn"
3193
- ?disabled=${this._isInputDisabled(n)}
3194
- @click=${()=>{n.formData[e.id]=null,n.handlers.trackQuestionResponse(e.id,null)}}
3835
+ ?disabled=${this._isInputDisabled(i)}
3836
+ @click=${()=>{i.formData[e.id]=null,i.handlers.trackQuestionResponse(e.id,null)}}
3195
3837
  >
3196
3838
 
3197
3839
  </button>
3198
3840
  </div>
3199
3841
  `:""}
3200
3842
  </div>
3201
- `}static renderDefaultInput(e,t,n){if(n.mode==="print"){const r=e.type==="date"&&t?new Date(t).toLocaleDateString():t;return d`<div class="print-response-value input-response">
3843
+ `}static renderDefaultInput(e,t,i){if(i.mode==="print"){const r=e.type==="date"&&t?new Date(t).toLocaleDateString():t;return d`<div class="print-response-value input-response">
3202
3844
  ${r||d`<span class="print-no-response">No response</span>`}
3203
- </div>`}const s=e.type==="number"?"number":e.type==="date"?"date":"text";return d`<input
3204
- type=${s}
3845
+ </div>`}const n=e.type==="number"?"number":e.type==="date"?"date":"text";return d`<input
3846
+ type=${n}
3205
3847
  id=${e.id}
3206
3848
  .value=${t}
3207
3849
  ?required=${e.required}
3208
- ?disabled=${this._isInputDisabled(n)}
3850
+ ?disabled=${this._isInputDisabled(i)}
3209
3851
  placeholder="Your Response"
3210
- @input=${r=>n.handlers.handleInputChange(e.id,r)}
3211
- />`}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"?d`
3852
+ @input=${r=>i.handlers.handleInputChange(e.id,r)}
3853
+ />`}static render(e,t){const i=t.formData[e.id]??"",n=t.validationErrors[e.id],r=()=>{switch(e.type){case"textarea":return k.renderTextArea(e,i,t);case"select":return k.renderSelect(e,i,t);case"radio":return k.renderRadio(e,i,t);case"checkbox":return k.renderCheckbox(e,i,t);case"signature":return k.renderSignature(e,i,t);case"file_upload":return k.renderFileUpload(e,i,t);default:return k.renderDefaultInput(e,i,t)}},o=e.type==="checkbox"&&(!e.options||e.options.length===0);return t.mode==="print"?d`
3212
3854
  <div class="question-print">
3213
3855
  ${o?"":d` <div class="print-question-title">${e.label}:</div> `}
3214
3856
  ${r()}
3215
3857
  <hr class="print-question-separator" />
3216
3858
  </div>
3217
3859
  `:d`
3218
- <div class="question ${s?"error":""}">
3860
+ <div class="question ${n?"error":""}">
3219
3861
  ${o?"":d`
3220
3862
  <div class="runner-question-title">
3221
3863
  ${e.label}${e.required?d`<span class="runner-question-required">*</span>`:""}
@@ -3223,24 +3865,24 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3223
3865
  <hr class="runner-question-divider" />
3224
3866
  `}
3225
3867
  ${r()}
3226
- ${s?d`<div class="error-message">${s}</div>`:""}
3868
+ ${n?d`<div class="error-message">${n}</div>`:""}
3227
3869
  </div>
3228
3870
  `}}/**
3229
3871
  * @license
3230
3872
  * Copyright 2017 Google LLC
3231
3873
  * SPDX-License-Identifier: BSD-3-Clause
3232
- */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)}}/**
3874
+ */const St={CHILD:2},kt=s=>(...e)=>({_$litDirective$:s,values:e});class $t{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
3233
3875
  * @license
3234
3876
  * Copyright 2017 Google LLC
3235
3877
  * SPDX-License-Identifier: BSD-3-Clause
3236
- */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===I)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 d`
3878
+ */class be extends $t{constructor(e){if(super(e),this.it=x,e.type!==St.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===x||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 ${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 d`
3237
3879
  <div class="content-element text-content">
3238
3880
  <p>${e.content}</p>
3239
3881
  </div>
3240
3882
  `}static renderMarkdownElement(e){return d`
3241
3883
  <div class="content-element markdown-content">
3242
3884
  <div class="markdown-text">
3243
- ${Le(k.renderMarkdown(e.content))}
3885
+ ${Le($.renderMarkdown(e.content))}
3244
3886
  </div>
3245
3887
  </div>
3246
3888
  `}static renderDivider(e){return d`
@@ -3277,21 +3919,21 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3277
3919
  <div class="content-element unknown-content">
3278
3920
  <p>⚠️ Unknown content type: ${e.type}</p>
3279
3921
  </div>
3280
- `}static render(e,t){const n=()=>{switch(e.type){case"text":return k.renderText(e);case"markdown":return k.renderMarkdownElement(e);case"divider":return k.renderDivider(e);case"html":return k.renderHtml(e);case"image":return k.renderImage(e);case"video":return k.renderVideo(e);case"file":return k.renderFile(e);default:return k.renderUnknown(e)}};return(t==null?void 0:t.mode)==="print"?d`
3922
+ `}static render(e,t){const i=()=>{switch(e.type){case"text":return $.renderText(e);case"markdown":return $.renderMarkdownElement(e);case"divider":return $.renderDivider(e);case"html":return $.renderHtml(e);case"image":return $.renderImage(e);case"video":return $.renderVideo(e);case"file":return $.renderFile(e);default:return $.renderUnknown(e)}};return(t==null?void 0:t.mode)==="print"?d`
3281
3923
  <div class="content-print">
3282
- ${n()}
3924
+ ${i()}
3283
3925
  ${e.type!=="divider"?d`<hr class="print-question-separator" />`:""}
3284
3926
  </div>
3285
- `:n()}}class Ne{static renderMobileStepsForStatus(e){const{steps:t,disabled:n=!1}=e;return d`
3927
+ `:i()}}class Ne{static renderMobileStepsForStatus(e){const{steps:t,disabled:i=!1}=e;return d`
3286
3928
  <div class="runner-mobile-steps">
3287
3929
  <nav aria-label="Workflow steps">
3288
3930
  <div class="runner-mobile-steps-container">
3289
- ${t==null?void 0:t.map(s=>{const r=e.isStepAssignedToUser(s),o=e.completedSteps.has(s.id);return d`
3931
+ ${t==null?void 0:t.map(n=>{const r=e.isStepAssignedToUser(n),o=e.completedSteps.has(n.id);return d`
3290
3932
  <div
3291
- class="runner-mobile-step-tab ${o?"completed":""} ${r?"":"unassigned"} ${n?"disabled":""}"
3292
- style="cursor: not-allowed; opacity: ${n?"0.6":r?"1":"0.6"};"
3933
+ class="runner-mobile-step-tab ${o?"completed":""} ${r?"":"unassigned"} ${i?"disabled":""}"
3934
+ style="cursor: not-allowed; opacity: ${i?"0.6":r?"1":"0.6"};"
3293
3935
  >
3294
- <span class="runner-mobile-step-title">${s.title}</span>
3936
+ <span class="runner-mobile-step-title">${n.title}</span>
3295
3937
  <span class="runner-mobile-step-badge">
3296
3938
  ${o?"Completed":r?"Your Step":"Other User"}
3297
3939
  </span>
@@ -3323,7 +3965,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3323
3965
  </p>
3324
3966
  </div>
3325
3967
  </div>
3326
- `}static renderUnifiedSubmissionView(e){var t,n,s;return d`
3968
+ `}static renderUnifiedSubmissionView(e){var t,i,n;return d`
3327
3969
  <div class="runner-layout">
3328
3970
  <!-- Mobile Steps Navigation (visible only on mobile) -->
3329
3971
  ${this.renderMobileStepsForStatus({steps:(t=e.instance)==null?void 0:t.steps,isStepAssignedToUser:e.isStepAssignedToUser,completedSteps:e.completedSteps,disabled:!0})}
@@ -3333,7 +3975,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3333
3975
  <div class="runner-sidebar-header">Steps</div>
3334
3976
  <nav aria-label="Workflow steps">
3335
3977
  <ul class="runner-steps-list">
3336
- ${(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 d`
3978
+ ${(n=(i=e.instance)==null?void 0:i.steps)==null?void 0:n.map(r=>{const o=e.isStepAssignedToUser(r),a=e.completedSteps.has(r.id);return d`
3337
3979
  <li
3338
3980
  class="runner-step-item ${a?"completed":""} ${o?"":"unassigned"}"
3339
3981
  style="opacity: ${o?"1":"0.6"}; cursor: not-allowed;"
@@ -3372,18 +4014,18 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3372
4014
  </div>
3373
4015
  </main>
3374
4016
  </div>
3375
- `}}class q{static isStepCompleted(e,t,n){return!!(t.completedSteps.has(e.id)||(t.isSubmitted||t.userStepsSubmitted)&&n)}static renderSidebar(e){const{steps:t}=e;return d`
4017
+ `}}class q{static isStepCompleted(e,t,i){return!!(t.completedSteps.has(e.id)||(t.isSubmitted||t.userStepsSubmitted)&&i)}static renderSidebar(e){const{steps:t}=e;return d`
3376
4018
  <aside class="runner-sidebar">
3377
4019
  <div class="runner-sidebar-header">Steps</div>
3378
4020
  <nav aria-label="Workflow steps">
3379
4021
  <ul class="runner-steps-list">
3380
- ${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),l=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return d`
4022
+ ${t==null?void 0:t.map((i,n)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(i),o=n===e.currentStepIndex,a=this.isStepCompleted(i,e,r),l=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return d`
3381
4023
  <li
3382
4024
  class="runner-step-item ${o?"active":""} ${a?"completed":""} ${r?"":"unassigned"} ${l?"disabled":""} ${p?"loading-disabled":""}"
3383
- @click=${()=>!p&&e.goToStep(s)}
4025
+ @click=${()=>!p&&e.goToStep(n)}
3384
4026
  style="${l?"opacity: 0.5; cursor: not-allowed;":""}"
3385
4027
  >
3386
- <span class="runner-step-title">${n.title}</span>
4028
+ <span class="runner-step-title">${i.title}</span>
3387
4029
  <span class="runner-step-badge">
3388
4030
  ${e.mode==="preview"?"Preview":e.mode==="admin"?"Admin":e.mode==="view-only"?"View Only":e.mode==="print"?"Print":l?"Submitted":a?"Completed":r?"Assigned":"Not Assigned"}
3389
4031
  </span>
@@ -3396,14 +4038,14 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3396
4038
  <div class="runner-mobile-steps">
3397
4039
  <nav aria-label="Workflow steps">
3398
4040
  <div class="runner-mobile-steps-container">
3399
- ${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),l=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return d`
4041
+ ${t==null?void 0:t.map((i,n)=>{const r=e.mode==="preview"||e.mode==="admin"||e.mode==="view-only"||e.mode==="print"||e.isStepAssignedToUser(i),o=n===e.currentStepIndex,a=this.isStepCompleted(i,e,r),l=(e.isSubmitted||e.userStepsSubmitted)&&e.mode!=="preview"&&e.mode!=="admin"&&e.mode!=="view-only"&&e.mode!=="print",p=e.isLoading;return d`
3400
4042
  <button
3401
4043
  class="runner-mobile-step-tab ${o?"active":""} ${a?"completed":""} ${r?"":"unassigned"} ${l?"disabled":""} ${p?"loading-disabled":""}"
3402
- @click=${()=>!p&&e.goToStep(s)}
4044
+ @click=${()=>!p&&e.goToStep(n)}
3403
4045
  ?disabled=${l||p}
3404
4046
  aria-current=${o?"step":"false"}
3405
4047
  >
3406
- <span class="runner-mobile-step-title">${n.title}</span>
4048
+ <span class="runner-mobile-step-title">${i.title}</span>
3407
4049
  <span class="runner-mobile-step-badge">
3408
4050
  ${e.mode==="preview"?"Preview":e.mode==="admin"?"Admin":e.mode==="view-only"?"View Only":e.mode==="print"?"Print":l?"Submitted":a?"Completed":r?"Assigned":"Not Assigned"}
3409
4051
  </span>
@@ -3412,7 +4054,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3412
4054
  </div>
3413
4055
  </nav>
3414
4056
  </div>
3415
- `}static renderStepHeader(e){const{step:t,mode:n}=e;return n==="print"?d`
4057
+ `}static renderStepHeader(e){const{step:t,mode:i}=e;return i==="print"?d`
3416
4058
  <div class="step-print-header">
3417
4059
  <div class="print-step-title">${t.title}</div>
3418
4060
  ${t.description?d`<div class="print-step-description">${t.description}</div>`:""}
@@ -3434,21 +4076,21 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3434
4076
  ${e.mode==="admin"?e.justSaved?"✓ Saved!":"Save":e.isLastStep?"Submit":"Next"}
3435
4077
  </button>
3436
4078
  </div>
3437
- `}}class ve{static handleInputChange(e,t,n,s,r,o){const a=t.target;let l;a.type==="radio"?l=a.value:a.type==="checkbox"?l=a.checked:l=a.value;const p={...n,[e]:l};s(p),o!=="preview"&&r(e,l)}static handleCheckboxChange(e,t,n,s,r,o){const l=t.target.checked,p={...n,[e]:l};s(p),o!=="preview"&&r(e,l)}static handleCheckboxGroupChange(e,t,n,s,r,o,a){const l=n.target,p=s[e];let c=Array.isArray(p)?[...p]:[];l.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 W{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):d`<div class="unknown-element">
3438
- <p>⚠️ Unknown element type: ${i.type}</p>
3439
- </div>`:this._isQuestionElement(i)?d`<div class="runner-card">${this._renderQuestion(i)}</div>`:this._isContentElement(i)?d`<div class="runner-card">${this._renderContentElement(i)}</div>`:d`<div class="runner-card">
4079
+ `}}class ve{static handleInputChange(e,t,i,n,r,o){const a=t.target;let l;a.type==="radio"?l=a.value:a.type==="checkbox"?l=a.checked:l=a.value;const p={...i,[e]:l};n(p),o!=="preview"&&r(e,l)}static handleCheckboxChange(e,t,i,n,r,o){const l=t.target.checked,p={...i,[e]:l};n(p),o!=="preview"&&r(e,l)}static handleCheckboxGroupChange(e,t,i,n,r,o,a){const l=i.target,p=n[e];let c=Array.isArray(p)?[...p]:[];l.checked?c.includes(t)||c.push(t):c=c.filter(h=>h!==t);const u={...n,[e]:c};r(u),a!=="preview"&&o(e,c)}}var Ct=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,_=(s,e,t,i)=>{for(var n=i>1?void 0:i?Et(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Ct(e,t,n),n};let f=class extends H{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(s){(s.has("mode")||s.has("currentUser"))&&this._updateNavigationService(),(s.has("instance")||s.has("workflow")||s.has("mode"))&&(this._initializeState(),this._updateValidationService())}connectedCallback(){super.connectedCallback(),this._initializeServices(),this._initializeState(),window.addEventListener("resize",this._handleResize.bind(this)),this._restoreFormData()}disconnectedCallback(){var s;super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize.bind(this)),(s=this.signatureManager)==null||s.destroy()}_initializeServices(){this.persistenceManager=new bt,this.responseTracker=new yt,this.formStateManager=new me,this.signatureManager=new _t(s=>this._handleSignatureChange(s)),this.fileUploadManager=new fe(this.formStateManager,this.responseTracker),this._updateNavigationService(),this._updateValidationService()}_updateNavigationService(){this.navigationService=new wt(this.mode||"default",this.currentUser)}_updateValidationService(){var s;this.validationService=new ft(((s=this.signatureManager)==null?void 0:s.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(s){this.formStateManager.setFormField(s.questionId,s.hasSignature),this.formStateManager.setFormField(`${s.questionId}_signatureData`,s.signatureData),this._formData=this.formStateManager.getFormData(),this._savedSignatures.has(s.questionId)&&(this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==s.questionId))),this._clearValidationError(s.questionId),this.mode!=="admin"&&this._saveFormDataToHistory()}_clearValidationError(s){this.formStateManager.clearValidationError(s),this._validationErrors=this.formStateManager.getValidationErrors()}_updateFormData(s){this.formStateManager.updateFormData(s),this._formData=this.formStateManager.getFormData(),this.mode!=="admin"&&this._saveFormDataToHistory()}_handleFormDataUpdate(s){this._clearValidationError(s)}_initializeState(){var s,e,t;if((s=this.formStateManager)==null||s.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 i=this._getAssignedSteps(),n=i.filter(r=>{var o;return(o=this.instance.completedSteps)==null?void 0:o.includes(r.id)});this._userStepsSubmitted=i.length>0&&n.length===i.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 s;if(console.log("Initializing preview mode..."),!((s=this.workflow)!=null&&s.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 s;!((s=this.instance)!=null&&s.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 s;!((s=this.instance)!=null&&s.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 s;!((s=this.instance)!=null&&s.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(s){return this.navigationService.isStepAssignedToUser(s)}_getAssignedSteps(){return this.instance?this.navigationService.getAssignedSteps(this.instance):[]}_isCurrentStepAssigned(){const s=this._currentStep;return!s||this.mode!=="default"?!0:this._isStepAssignedToUser(s)}_renderNotAssignedView(){return Ne.renderNotAssignedView()}get _currentStep(){var s,e,t;return this.mode==="preview"&&this.workflow?(s=this.workflow.steps)==null?void 0:s[this._currentStepIndex]:(t=(e=this.instance)==null?void 0:e.steps)==null?void 0:t[this._currentStepIndex]}_validateStep(){const s=this._currentStep;if(!s)return!1;const e=this.validationService.validateStep(s,this._formData,this.mode||"default");return this.formStateManager.setValidationErrors(e.errors),this._validationErrors=this.formStateManager.getValidationErrors(),e.isValid}_handleInputChange(s,e){ve.handleInputChange(s,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(s)}_handleCheckboxChange(s,e){ve.handleCheckboxChange(s,e,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(s)}_handleCheckboxGroupChange(s,e,t){ve.handleCheckboxGroupChange(s,e,t,this._formData,this._updateFormData.bind(this),this._trackQuestionResponse.bind(this),this.mode),this._handleFormDataUpdate(s)}_initializeSignaturePad(s){this.signatureManager.initializeSignaturePad(s,this.shadowRoot)&&this._updateValidationService()}_handleResize(){this.signatureManager.handleResize()}_clearSignature(s){this.signatureManager.clearSignature(s)}_startReplaceSignature(s){this._replacingSignatures=new Set([...this._replacingSignatures,s]),this.formStateManager.setFormField(s,!1),this.formStateManager.setFormField(`${s}_signatureData`,null),this._formData=this.formStateManager.getFormData(),this._savedSignatures=new Set([...this._savedSignatures].filter(e=>e!==s)),this.requestUpdate()}_cancelReplaceSignature(s){this._replacingSignatures=new Set([...this._replacingSignatures].filter(e=>e!==s))}_saveSignature(s){var i,n,r;const e=this.signatureManager.saveSignature(s);if(!e)return;const t=this._hasSignatureChanged(s,e.svgData);this._savedSignatures=new Set([...this._savedSignatures,s]),this._replacingSignatures.has(s)&&(this._replacingSignatures=new Set([...this._replacingSignatures].filter(o=>o!==s))),this._trackQuestionResponse(s,e.svgData),t&&this.mode!=="preview"?(console.log("Signature changed, calling callback for:",s),console.log("Callback function exists:",!!this.onSignatureCaptured),(r=this.onSignatureCaptured)==null||r.call(this,{instanceId:(i=this.instance)==null?void 0:i.id,stepId:(n=this._currentStep)==null?void 0:n.id,questionId:s,svgData:e.svgData,dataURL:e.dataURL})):this.mode==="preview"?console.log("Preview mode: skipping signature callback for:",s):console.log("Signature unchanged, skipping callback for:",s),this._clearValidationError(s),this.mode!=="admin"&&this._saveFormDataToHistory()}_hasSignatureChanged(s,e){return this.responseTracker.hasChangedFromPrevious(s,e,this._savedInstance)}_restoreInstanceResponses(){var s,e;!((s=this._savedInstance)!=null&&s.steps)||!((e=this.instance)!=null&&e.steps)||this._savedInstance.steps.forEach((t,i)=>{var n;(n=this.instance)!=null&&n.steps&&this.instance.steps[i]&&(this.instance.steps[i].responses=t.responses||[])})}_handleFileUpload(s,e){this.fileUploadManager.handleFileUpload(s,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[s];t&&this._trackQuestionResponse(s,t),this.requestUpdate()}})}_captureSignaturesFromStep(s){console.log("Capturing signatures from step:",s.id)}_trackQuestionResponse(s,e){this.responseTracker.trackQuestionResponse(this._currentStep,s,e)}_renderQuestion(s){return k.render(s,this._getRenderContext())}_renderContentElement(s){return $.render(s,this._getRenderContext())}_isQuestionElement(s){return f.QUESTION_ELEMENT_TYPES.includes(s.type)}_isContentElement(s){return f.CONTENT_ELEMENT_TYPES.includes(s.type)}_renderStepElement(s){return this.mode==="print"?this._isQuestionElement(s)?this._renderQuestion(s):this._isContentElement(s)?this._renderContentElement(s):d`<div class="unknown-element">
4080
+ <p>⚠️ Unknown element type: ${s.type}</p>
4081
+ </div>`:this._isQuestionElement(s)?d`<div class="runner-card">${this._renderQuestion(s)}</div>`:this._isContentElement(s)?d`<div class="runner-card">${this._renderContentElement(s)}</div>`:d`<div class="runner-card">
3440
4082
  <div class="unknown-element">
3441
- <p>⚠️ Unknown element type: ${i.type}</p>
4083
+ <p>⚠️ Unknown element type: ${s.type}</p>
3442
4084
  </div>
3443
- </div>`}_renderStepWithElements(i){return d`
4085
+ </div>`}_renderStepWithElements(s){return d`
3444
4086
  <div class="print-step">
3445
4087
  <!-- Step Header -->
3446
- ${q.renderStepHeader({step:i,mode:"print"})}
4088
+ ${q.renderStepHeader({step:s,mode:"print"})}
3447
4089
 
3448
4090
  <!-- Step Elements -->
3449
- ${i.elements.map(e=>this._renderStepElement(e))}
4091
+ ${s.elements.map(e=>this._renderStepElement(e))}
3450
4092
  </div>
3451
- `}_renderAllStepsForPrint(){var i;return!((i=this.instance)!=null&&i.steps)||this.instance.steps.length===0?d`<div class="runner-content">
4093
+ `}_renderAllStepsForPrint(){var s;return!((s=this.instance)!=null&&s.steps)||this.instance.steps.length===0?d`<div class="runner-content">
3452
4094
  No workflow instance loaded or instance has no steps.
3453
4095
  </div>`:d`
3454
4096
  <div class="print-layout">
@@ -3458,26 +4100,26 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3458
4100
 
3459
4101
  ${this.instance.steps.map(e=>this._renderStepWithElements(e))}
3460
4102
  </div>
3461
- `}_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 l=this.instance.steps.find(p=>p.id===o);l&&(l.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.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 l,p,c,u,h,f,b;i&&this._internalCompletedSteps.add(i);let n=(p=(l=this.instance)==null?void 0:l.steps)==null?void 0:p.find($=>$.id===i);if(!n&&this._internalCompletedSteps.size>0){const $=Array.from(this._internalCompletedSteps),ne=$[$.length-1];n=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(se=>se.id===ne)}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(l=>l.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?d`<div class="runner-content">
4103
+ `}_nextStep(){var t,i,n,r;if(!this._validateStep())return;const s=this._currentStep;s&&this._captureSignaturesFromStep(s);const e=this._findNextAssignedStep(this._currentStepIndex);if(e!==-1){const o=(t=this._currentStep)==null?void 0:t.id;if(this._currentStepIndex=e,o&&((i=this.instance)!=null&&i.steps)){const l=this.instance.steps.find(p=>p.id===o);l&&(l.status="completed")}const a=(r=(n=this.instance)==null?void 0:n.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(s){return this.instance?this.navigationService.findNextAssignedStep(s,this.instance):-1}_isLastAssignedStep(){return this.navigationService.isLastAssignedStep(this._currentStepIndex,this.instance)}_isLastStepInWorkflow(){var e;const s=(e=this.instance)==null?void 0:e.steps;return s?this._currentStepIndex===s.length-1:!1}_goToStep(s){var i;console.log(`🎯 _goToStep called: stepIndex=${s}, mode=${this.mode}, currentStep=${this._currentStepIndex}`);const e=this.mode==="preview"?this.workflow:this.instance;if(console.log("📊 Data source:",e?`${((i=e.steps)==null?void 0:i.length)||0} steps`:"null"),!e){console.log("❌ No data source available");return}const t=this.navigationService.canNavigateToStep(s,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 s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!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 s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!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.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 s=this._currentStep;if(s&&this._captureSignaturesFromStep(s),!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 i=this.instance.steps.find(n=>n.id===e);i&&(i.status="completed")}this._updateInstanceData(e,"admin_save",{stepId:e,adminMode:!0}),this._justSaved=!0,this.requestUpdate(),setTimeout(()=>{this._justSaved=!1,this.requestUpdate()},2e3)}_clearSavedFormData(s){var e;this.persistenceManager.clearFormData((e=this.instance)==null?void 0:e.id,s)}_scrollToTop(){requestAnimationFrame(()=>{var t,i;this.scrollIntoView({behavior:"smooth",block:"start"});const s=(t=this.shadowRoot)==null?void 0:t.querySelector(".runner-layout");s&&s.scrollTo({top:0,behavior:"smooth"});const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-main-content");e&&e.scrollTo({top:0,behavior:"smooth"})})}_updateInstanceData(s,e,t){var l,p,c,u,h,m,v;s&&this._internalCompletedSteps.add(s);let i=(p=(l=this.instance)==null?void 0:l.steps)==null?void 0:p.find(D=>D.id===s);if(!i&&this._internalCompletedSteps.size>0){const D=Array.from(this._internalCompletedSteps),se=D[D.length-1];i=(u=(c=this.instance)==null?void 0:c.steps)==null?void 0:u.find(ne=>ne.id===se)}const n=e==="submission",r=((h=this.instance)==null?void 0:h.steps)&&this._internalCompletedSteps.size>=this.instance.steps.length,o=n||r?null:this._currentStep?{id:this._currentStep.id,title:this._currentStep.title}:null,a={instanceId:(m=this.instance)==null?void 0:m.id,workflowId:(v=this.instance)==null?void 0:v.workflowId,completedStepId:s||(i?i.id:null),completedStepData:i?{id:i.id,title:i.title,responses:i.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 s=this.persistenceManager.restoreFormData((e=this.instance)==null?void 0:e.id);s?(this.formStateManager.updateFormData(s.formData),this._formData=this.formStateManager.getFormData(),this._currentStepIndex=s.stepIndex,this._savedSignatures=s.savedSignatures,this._internalCompletedSteps=s.completedSteps,this._savedInstance=s.savedInstance||void 0):this._updateCompletedStepsFromCurrentIndex()}_updateCompletedStepsFromCurrentIndex(){var s;if((s=this.instance)!=null&&s.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(([i,n])=>{var o;if(i.endsWith("_signatureData"))return;const r=(o=this.shadowRoot)==null?void 0:o.getElementById(i);if(r){if(r.type==="checkbox"){const a=r;typeof n=="boolean"?a.checked=n:Array.isArray(n)&&(a.checked=n.includes(a.value))}else if(r.type==="radio"){const a=r;a.checked=a.value===n}else if(r.type==="file"){const a=r;a.value=""}else r.value=String(n||"");console.log(`Restored value for ${i}:`,n)}}),this._restoreSignatures(),console.log("Form values restored to DOM elements"),this._updateInstanceWithFormData(!0),(t=this._savedInstance)!=null&&t.steps&&this._restoreInstanceResponses())})}_updateInstanceWithFormData(s=!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 i=t,n=this._formData[i.id];if(n!==void 0&&e.responses){let r=e.responses.find(o=>o.elementId===i.id);r?(r.value=n,r.answeredAt=new Date):(r={elementId:i.id,value:n,answeredAt:new Date},e.responses.push(r))}}})})}_restoreSignatures(){Object.entries(this._formData).forEach(([s,e])=>{if(s.endsWith("_signatureData")&&e){const t=s.replace("_signatureData",""),i=this.signatureManager.getSignaturePad(t);if(i&&e)try{i.clear(),i.fromData(e)}catch{}}})}_saveFormDataToHistory(){var s;this.persistenceManager.saveFormData((s=this.instance)==null?void 0:s.id,this._formData,this._currentStepIndex,this._savedSignatures,this._internalCompletedSteps,this.instance||null)}_extractFormDataFromDOM(){var i;const s={},e=(i=this.shadowRoot)==null?void 0:i.querySelector(".runner-step-form");if(!e)return s;const t=e.elements;for(let n=0;n<t.length;n++){const r=t[n];if(r.name||r.id){const o=r.id||r.name;if(r.type==="checkbox"){const a=r;a.name&&a.name===o?(s[o]||(s[o]=[]),a.checked&&s[o].push(a.value)):s[o]=a.checked}else if(r.type==="radio"){const a=r;a.checked&&(s[o]=a.value)}else s[o]=r.value}}return s}_updateInstanceFromFormData(s=!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(i=>{i.responses||(i.responses=[]),i.elements.forEach(n=>{if(n.type==="text_input"||n.type==="textarea"||n.type==="select"||n.type==="number"||n.type==="radio"||n.type==="checkbox"||n.type==="date"||n.type==="file_upload"||n.type==="signature"){const r=n,o=this._formData[r.id];if(o!==void 0&&i.responses){let a=i.responses.find(l=>l.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},i.responses.push(a))}}})}),console.log("Instance updated from form data:",this.instance),s&&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(s=!1){this._updateInstanceFromFormData(s)}getFormData(){return this.formStateManager.getFormData()}restoreFormData(){this._restoreFormDataFromDOM()}clearSavedFormData(s){this._clearSavedFormData(s)}_renderUnifiedSubmissionView(){const s={instance:this.instance,assignedSteps:this._getAssignedSteps(),completedSteps:this._internalCompletedSteps,isStepAssignedToUser:this._isStepAssignedToUser.bind(this)};return Ne.renderUnifiedSubmissionView(s)}_isInstanceCompleted(){var s;return((s=this.instance)==null?void 0:s.status)==="completed"}_areUserStepsCompleted(){var e;if(!((e=this.instance)!=null&&e.steps))return!1;const s=this._getAssignedSteps();return s.length===0?!1:s.every(t=>t.status==="completed")}_shouldShowCompletionView(){var s;return this.mode!=="default"?!1:!!(this._isInstanceCompleted()||((s=this.instance)==null?void 0:s.status)==="active"&&this._areUserStepsCompleted())}_renderModeBasedContent(){var e,t;if(this._shouldShowCompletionView())return this._renderUnifiedSubmissionView();if(this.mode==="print")return this._renderAllStepsForPrint();const s=this.mode==="preview"?(e=this.workflow)==null?void 0:e.steps:(t=this.instance)==null?void 0:t.steps;return!s||s.length===0?d`<div class="runner-content">
3462
4104
  ${this.mode==="preview"?"No workflow loaded or workflow has no steps.":"No workflow instance loaded or instance has no steps."}
3463
- </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 d`
4105
+ </div>`:this.mode==="default"&&this._getAssignedSteps().length===0?this._renderNotAssignedView():null}_validateCurrentStep(){return this._currentStep}_initializeStepAssets(s){this.updateComplete.then(()=>{s.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(s){var n,r;const e=this._isLastAssignedStep(),t=this._isLastStepInWorkflow(),i=this.mode==="preview"?(n=this.workflow)==null?void 0:n.steps:(r=this.instance)==null?void 0:r.steps;return d`
3464
4106
  <!-- Mobile Steps Navigation (visible only on mobile) -->
3465
- ${q.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)})}
4107
+ ${q.renderMobileSteps({steps:i,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)})}
3466
4108
 
3467
4109
  <!-- Sidebar: Steps List (hidden on mobile) -->
3468
- ${q.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)})}
4110
+ ${q.renderSidebar({steps:i,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)})}
3469
4111
 
3470
4112
  <!-- Main Content: Step Details and Questions -->
3471
4113
  <main class="runner-main-content">
3472
- ${this.mode==="print"?q.renderStepHeader({step:i,mode:this.mode}):d`<div class="runner-card">
3473
- ${q.renderStepHeader({step:i,mode:this.mode})}
4114
+ ${this.mode==="print"?q.renderStepHeader({step:s,mode:this.mode}):d`<div class="runner-card">
4115
+ ${q.renderStepHeader({step:s,mode:this.mode})}
3474
4116
  </div>`}
3475
4117
  <form class="runner-step-form" @submit=${o=>o.preventDefault()}>
3476
- ${i.elements.map(o=>this._renderStepElement(o))}
4118
+ ${s.elements.map(o=>this._renderStepElement(o))}
3477
4119
  ${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)}})}
3478
4120
  </form>
3479
4121
  </main>
3480
- `}_renderMainContent(){const i=this._renderModeBasedContent();if(i)return i;const e=this._validateCurrentStep();return e?(this._initializeStepAssets(e),this._renderCurrentStepLayout(e)):d`<div class="runner-content">Invalid current step.</div>`}render(){return d`
4122
+ `}_renderMainContent(){const s=this._renderModeBasedContent();if(s)return s;const e=this._validateCurrentStep();return e?(this._initializeStepAssets(e),this._renderCurrentStepLayout(e)):d`<div class="runner-content">Invalid current step.</div>`}render(){return d`
3481
4123
  <div class="runner-layout">
3482
4124
  ${this._renderMainContent()}
3483
4125
 
@@ -3491,56 +4133,56 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3491
4133
  </div>
3492
4134
  `:""}
3493
4135
  </div>
3494
- `}};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([Ie("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>
4136
+ `}};f.styles=[Pe],f.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"],f.CONTENT_ELEMENT_TYPES=["text","html","image","video","file","divider","markdown"],_([E({type:Object})],f.prototype,"instance",2),_([E({type:Object})],f.prototype,"workflow",2),_([E({type:String})],f.prototype,"mode",2),_([E({type:Boolean})],f.prototype,"isLoading",2),_([E({type:Object})],f.prototype,"currentUser",2),_([E({type:Function})],f.prototype,"onSignatureCaptured",2),_([E({type:Function})],f.prototype,"onFileUploaded",2),_([b()],f.prototype,"_currentStepIndex",2),_([b()],f.prototype,"_formData",2),_([b()],f.prototype,"_validationErrors",2),_([b()],f.prototype,"_internalCompletedSteps",2),_([b()],f.prototype,"_formRestorationComplete",2),_([b()],f.prototype,"_savedSignatures",2),_([b()],f.prototype,"_replacingSignatures",2),_([b()],f.prototype,"_savedInstance",2),_([b()],f.prototype,"_isSubmitted",2),_([b()],f.prototype,"_userStepsSubmitted",2),_([b()],f.prototype,"_justSaved",2),f=_([ze("runner-widget")],f);function At(s,e={}){const{title:t=s.name||"Workflow Instance",includeStyles:i=!0,customCSS:n="",showTimestamps:r=!1}=e,o=new Date;if(!(s!=null&&s.steps)||s.steps.length===0)throw new Error("Instance must have at least one step to generate HTML");return{html:`<!DOCTYPE html>
3495
4137
  <html lang="en">
3496
4138
  <head>
3497
4139
  <meta charset="UTF-8">
3498
4140
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
3499
4141
  <title>${g(t)}</title>
3500
- ${n?`<style>${Yt()}</style>`:""}
3501
- ${s?`<style>${s}</style>`:""}
4142
+ ${i?`<style>${Yt()}</style>`:""}
4143
+ ${n?`<style>${n}</style>`:""}
3502
4144
  </head>
3503
4145
  <body>
3504
4146
  <div class="print-layout">
3505
4147
  <!-- Instance Title at top -->
3506
4148
  <div class="print-instance-title">
3507
- ${g(i.name||"Untitled Form")}
4149
+ ${g(s.name||"Untitled Form")}
3508
4150
  </div>
3509
4151
  <hr class="print-question-separator" />
3510
4152
 
3511
- ${r?jt(i,o):""}
3512
- ${i.steps.map(l=>Mt(l)).join(`
4153
+ ${r?jt(s,o):""}
4154
+ ${s.steps.map(l=>Mt(l)).join(`
3513
4155
  `)}
3514
4156
  </div>
3515
4157
  </body>
3516
- </html>`,title:t,generatedAt:o}}function Mt(i){return`
4158
+ </html>`,title:t,generatedAt:o}}function Mt(s){return`
3517
4159
  <div class="print-step">
3518
4160
  <!-- Step Header -->
3519
- ${Tt(i)}
4161
+ ${Tt(s)}
3520
4162
 
3521
4163
  <!-- Step Elements -->
3522
- ${i.elements.map(e=>Ft(e,i)).join(`
4164
+ ${s.elements.map(e=>Ft(e,s)).join(`
3523
4165
  `)}
3524
4166
  </div>
3525
- `}function Tt(i){return`
4167
+ `}function Tt(s){return`
3526
4168
  <div class="step-print-header">
3527
- <div class="print-step-title">${g(i.title)}</div>
3528
- ${i.description?`<div class="print-step-description">${g(i.description)}</div>`:""}
4169
+ <div class="print-step-title">${g(s.title)}</div>
4170
+ ${s.description?`<div class="print-step-description">${g(s.description)}</div>`:""}
3529
4171
  <hr class="print-question-separator" />
3530
4172
  </div>
3531
- `}function Ft(i,e){return Ht(i)?zt(i,e):It(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)?"":`
4173
+ `}function Ft(s,e){return Wt(s)?It(s,e):zt(s)}function It(s,e){const t=Vt(s.id,e.responses),i=t==null?void 0:t.value,r=s.type==="checkbox"&&(!s.options||s.options.length===0)?"":`
3532
4174
  <div class="print-question-title">
3533
- ${g(i.label)}:
4175
+ ${g(s.label)}:
3534
4176
  </div>
3535
- `,o='<hr class="print-question-separator" />';switch(i.type){case"text_input":case"number":case"date":return r+Ut(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+`
4177
+ `,o='<hr class="print-question-separator" />';switch(s.type){case"text_input":case"number":case"date":return r+Ut(s,i)+o;case"textarea":return r+Pt(s,i)+o;case"select":return r+Lt(s,i)+o;case"radio":return r+Nt(s,i)+o;case"checkbox":return r+Ot(s,i)+o;case"file_upload":return r+Rt(s,i)+o;case"signature":return r+Ht(s,i)+o;default:return r+`
3536
4178
  <div class="unknown-element">
3537
- <p>⚠️ Unknown question type: ${g(i.type)}</p>
4179
+ <p>⚠️ Unknown question type: ${g(s.type)}</p>
3538
4180
  </div>
3539
- `+o}}function It(i){const e=i.type!=="divider"?'<hr class="print-question-separator" />':"";switch(i.type){case"text":return`
4181
+ `+o}}function zt(s){const e=s.type!=="divider"?'<hr class="print-question-separator" />':"";switch(s.type){case"text":return`
3540
4182
  <div class="content-print">
3541
4183
  <div class="content-element">
3542
4184
  <div class="text-content">
3543
- <p>${g(i.content)}</p>
4185
+ <p>${g(s.content)}</p>
3544
4186
  </div>
3545
4187
  </div>
3546
4188
  ${e}
@@ -3549,7 +4191,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3549
4191
  <div class="content-print">
3550
4192
  <div class="content-element">
3551
4193
  <div class="html-content-wrapper">
3552
- ${i.content}
4194
+ ${s.content}
3553
4195
  </div>
3554
4196
  </div>
3555
4197
  ${e}
@@ -3558,7 +4200,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3558
4200
  <div class="content-print">
3559
4201
  <div class="content-element">
3560
4202
  <div class="markdown-content">
3561
- ${Gt(i.content)}
4203
+ ${Gt(s.content)}
3562
4204
  </div>
3563
4205
  </div>
3564
4206
  ${e}
@@ -3568,7 +4210,7 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3568
4210
  <div class="content-element">
3569
4211
  <div class="divider-content">
3570
4212
  <hr class="content-divider" />
3571
- ${i.caption?`<div class="divider-caption">${g(i.caption)}</div>`:""}
4213
+ ${s.caption?`<div class="divider-caption">${g(s.caption)}</div>`:""}
3572
4214
  </div>
3573
4215
  </div>
3574
4216
  </div>
@@ -3576,8 +4218,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3576
4218
  <div class="content-print">
3577
4219
  <div class="content-element">
3578
4220
  <div class="image-placeholder">
3579
- <p>📷 Image: ${g(i.content)}</p>
3580
- ${i.caption?`<small>${g(i.caption)}</small>`:""}
4221
+ <p>📷 Image: ${g(s.content)}</p>
4222
+ ${s.caption?`<small>${g(s.caption)}</small>`:""}
3581
4223
  </div>
3582
4224
  </div>
3583
4225
  ${e}
@@ -3586,8 +4228,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3586
4228
  <div class="content-print">
3587
4229
  <div class="content-element">
3588
4230
  <div class="video-placeholder">
3589
- <p>🎥 Video: ${g(i.content)}</p>
3590
- ${i.caption?`<small>${g(i.caption)}</small>`:""}
4231
+ <p>🎥 Video: ${g(s.content)}</p>
4232
+ ${s.caption?`<small>${g(s.caption)}</small>`:""}
3591
4233
  </div>
3592
4234
  </div>
3593
4235
  ${e}
@@ -3596,8 +4238,8 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3596
4238
  <div class="content-print">
3597
4239
  <div class="content-element">
3598
4240
  <div class="file-placeholder">
3599
- <p>📎 File: ${g(i.content)}</p>
3600
- ${i.caption?`<small>${g(i.caption)}</small>`:""}
4241
+ <p>📎 File: ${g(s.content)}</p>
4242
+ ${s.caption?`<small>${g(s.caption)}</small>`:""}
3601
4243
  </div>
3602
4244
  </div>
3603
4245
  ${e}
@@ -3606,49 +4248,49 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3606
4248
  <div class="content-print">
3607
4249
  <div class="content-element">
3608
4250
  <div class="unknown-element">
3609
- <p>⚠️ Unknown content type: ${g(i.type)}</p>
4251
+ <p>⚠️ Unknown content type: ${g(s.type)}</p>
3610
4252
  </div>
3611
4253
  </div>
3612
4254
  ${e}
3613
4255
  </div>
3614
- `}}function Ut(i,e){const t=e!=null?g(String(e)):"";return`
4256
+ `}}function Ut(s,e){const t=e!=null?g(String(e)):"";return`
3615
4257
  <div class="print-response-value input-response">
3616
- ${(i.type==="date"&&e?new Date(e).toLocaleDateString():t)||'<span class="print-no-response">No response</span>'}
4258
+ ${(s.type==="date"&&e?new Date(e).toLocaleDateString():t)||'<span class="print-no-response">No response</span>'}
3617
4259
  </div>
3618
- `}function Pt(i,e){return`
4260
+ `}function Pt(s,e){return`
3619
4261
  <div class="print-response-value textarea-response">
3620
4262
  ${(e!=null?g(String(e)):"")||'<span class="print-no-response">No response</span>'}
3621
4263
  </div>
3622
- `}function Lt(i,e){const t=e!=null?String(e):"";return`
4264
+ `}function Lt(s,e){const t=e!=null?String(e):"";return`
3623
4265
  <div class="print-response-value select-response">
3624
4266
  ${t?g(t):'<span class="print-no-response">No selection made</span>'}
3625
4267
  </div>
3626
- `}function Nt(i,e){const t=e!=null?String(e):"";return`
4268
+ `}function Nt(s,e){const t=e!=null?String(e):"";return`
3627
4269
  <div class="print-response-value radio-response">
3628
4270
  ${t?g(t):'<span class="print-no-response">No selection made</span>'}
3629
4271
  </div>
3630
- `}function Ot(i,e){if((i.options||[]).length===0)return`
4272
+ `}function Ot(s,e){if((s.options||[]).length===0)return`
3631
4273
  <div class="print-response-value checkbox-response">
3632
4274
  ${e===!0||e==="true"?"Yes":"No"}
3633
4275
  </div>
3634
- `;{const n=Array.isArray(e)?e.map(String):[];return`
4276
+ `;{const i=Array.isArray(e)?e.map(String):[];return`
3635
4277
  <div class="print-response-value checkbox-response">
3636
- ${n.length>0?n.map(s=>`<div>• ${g(s)}</div>`).join(""):'<span class="print-no-response">No selections made</span>'}
4278
+ ${i.length>0?i.map(n=>`<div>• ${g(n)}</div>`).join(""):'<span class="print-no-response">No selections made</span>'}
3637
4279
  </div>
3638
- `}}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`
4280
+ `}}function Rt(s,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`
3639
4281
  <div class="print-response-value file-response">
3640
4282
  📎 ${g(e.name)}
3641
- ${e.size?` <span class="file-size">(${Qt(e.size)})</span>`:""}
4283
+ ${e.size?` <span class="file-size">(${Bt(e.size)})</span>`:""}
3642
4284
  </div>
3643
- `;if(t){const s=Bt(e);return`
4285
+ `;if(t){const n=Qt(e);return`
3644
4286
  <div class="print-response-value file-response">
3645
- 📎 ${g(s)}
4287
+ 📎 ${g(n)}
3646
4288
  </div>
3647
4289
  `}else return`
3648
4290
  <div class="print-response-value file-response">
3649
4291
  📎 ${g(String(e))}
3650
4292
  </div>
3651
- `}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?`
4293
+ `}function Ht(s,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?`
3652
4294
  <div class="print-response-value signature-response">
3653
4295
  <img
3654
4296
  src="${g(t)}"
@@ -3660,25 +4302,25 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
3660
4302
  <div class="signature-fallback">
3661
4303
  <div class="signature-error">Unable to display signature</div>
3662
4304
  </div>
3663
- `}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`
4305
+ `}function Wt(s){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(s.type)}function Vt(s,e){return e==null?void 0:e.find(t=>t.elementId===s)}function jt(s,e){return`
3664
4306
  <div class="runner-card" style="margin-bottom: 40px; border-left: 4px solid #3b82f6;">
3665
4307
  <div style="display: flex; justify-content: between; align-items: center; gap: 20px;">
3666
4308
  <div>
3667
4309
  <h3 style="margin: 0 0 8px 0; color: #111827; font-size: 1.25rem;">
3668
- ${g(i.name)}
4310
+ ${g(s.name)}
3669
4311
  </h3>
3670
4312
  <p style="margin: 0; color: #6b7280; font-size: 0.875rem;">
3671
- <strong>Status:</strong> ${g(i.status)} |
4313
+ <strong>Status:</strong> ${g(s.status)} |
3672
4314
  <strong>Generated:</strong> ${e.toLocaleString()}
3673
4315
  </p>
3674
4316
  </div>
3675
4317
  <div style="text-align: right; color: #6b7280; font-size: 0.875rem;">
3676
- <p style="margin: 0;"><strong>Instance ID:</strong> ${g(i.id)}</p>
3677
- <p style="margin: 0;"><strong>Workflow ID:</strong> ${g(i.workflowId)}</p>
4318
+ <p style="margin: 0;"><strong>Instance ID:</strong> ${g(s.id)}</p>
4319
+ <p style="margin: 0;"><strong>Workflow ID:</strong> ${g(s.workflowId)}</p>
3678
4320
  </div>
3679
4321
  </div>
3680
4322
  </div>
3681
- `}function g(i){if(i==null)return"";const e=String(i);return{innerHTML:""}.innerHTML||e.replace(/[&<>"']/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[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`
4323
+ `}function g(s){if(s==null)return"";const e=String(s);return{innerHTML:""}.innerHTML||e.replace(/[&<>"']/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[i])}function Bt(s){if(s===0)return"0 Bytes";const e=1024,t=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(s)/Math.log(e));return parseFloat((s/Math.pow(e,i)).toFixed(2))+" "+t[i]}function Qt(s){try{return new URL(s).pathname.split("/").pop()||""||"Uploaded File"}catch{const e=s.split("/"),t=e[e.length-1];return t&&t.includes(".")?t:"Uploaded File"}}function Gt(s){return s==null?"":String(s).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`
3682
4324
  /* Print Layout Styles - Extracted from step-styles.ts */
3683
4325
  .print-layout {
3684
4326
  width: 100%;
@@ -4183,4 +4825,4 @@ Use **bold** and *italic* text.`;break}const n=this._templateData.steps.map(r=>r
4183
4825
  margin: 2px 0;
4184
4826
  line-height: 1.4;
4185
4827
  }
4186
- `}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.workflow&&(n.workflow=e.workflow),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(l=>l.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"})});
4828
+ `}function qt(s,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(s);if(!t)return console.error(`Error: Target element with ID '${s}' not found.`),null;t.innerHTML="";const i=document.createElement("builder-widget");return e.workflow&&(i.workflow=e.workflow),e.onWorkflowCreated&&(i.onWorkflowCreated=e.onWorkflowCreated),e.onWorkflowDeleted&&(i.onWorkflowDeleted=e.onWorkflowDeleted),e.onWorkflowUpdated&&(i.onWorkflowUpdated=e.onWorkflowUpdated),t.appendChild(i),console.log(`Drill Builder mounted on #${s}`),i}function Kt(s,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(s);if(!t)return console.error(`Error: Target element with ID '${s}' 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 i=document.createElement("runner-widget");return e.mode==="preview"?(i.workflow=e.workflow,i.mode="preview"):(i.instance=e.instance,i.mode=e.mode||"default"),e.mode&&(i.mode=e.mode),e.isLoading!==void 0&&(i.isLoading=e.isLoading),e.onSignatureCaptured&&(i.onSignatureCaptured=e.onSignatureCaptured),e.onFileUploaded&&(i.onFileUploaded=e.onFileUploaded),e.currentUser&&(i.currentUser=e.currentUser),e.onInstanceUpdated&&i.addEventListener("instance-updated",n=>{const r=n;try{e.onInstanceUpdated(r.detail)}catch(o){console.error("Error executing onInstanceUpdated callback:",o)}}),t.appendChild(i),console.log(`Drill Runner mounted on #${s}`),i}function Jt(s,e){const t=s.getFormData(),i=JSON.parse(JSON.stringify(e));return i.steps&&i.steps.forEach(n=>{n.responses||(n.responses=[]),n.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=n.responses.find(l=>l.elementId===r.id);a?(a.value=o,a.answeredAt=new Date):(a={elementId:r.id,value:o,answeredAt:new Date},n.responses.push(a))}}})}),i}function Xt(s,e){const t={};e.steps&&e.steps.forEach(i=>{i.responses&&i.responses.forEach(n=>{t[n.elementId]=n.value})}),s.restoreFormData(),console.log("Form data restored to runner widget:",t)}C.createBuilder=qt,C.createRunner=Kt,C.generateInstanceHTML=At,C.restoreFormDataToRunner=Xt,C.updateInstanceFromRunnerForm=Jt,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});