drill-widgets 2.7.13 → 2.7.14

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.
@@ -75,7 +75,7 @@ const { is: We, defineProperty: He, getOwnPropertyDescriptor: Ve, getOwnProperty
75
75
  return t;
76
76
  } }, me = (s, e) => !We(s, e), ye = { attribute: !0, type: String, converter: J, reflect: !1, useDefault: !1, hasChanged: me };
77
77
  Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), M.litPropertyMetadata ?? (M.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
78
- let P = class extends HTMLElement {
78
+ let U = class extends HTMLElement {
79
79
  static addInitializer(e) {
80
80
  this._$Ei(), (this.l ?? (this.l = [])).push(e);
81
81
  }
@@ -276,7 +276,7 @@ let P = class extends HTMLElement {
276
276
  firstUpdated(e) {
277
277
  }
278
278
  };
279
- P.elementStyles = [], P.shadowRootOptions = { mode: "open" }, P[H("elementProperties")] = /* @__PURE__ */ new Map(), P[H("finalized")] = /* @__PURE__ */ new Map(), ne == null || ne({ ReactiveElement: P }), (M.reactiveElementVersions ?? (M.reactiveElementVersions = [])).push("2.1.0");
279
+ U.elementStyles = [], U.shadowRootOptions = { mode: "open" }, U[H("elementProperties")] = /* @__PURE__ */ new Map(), U[H("finalized")] = /* @__PURE__ */ new Map(), ne == null || ne({ ReactiveElement: U }), (M.reactiveElementVersions ?? (M.reactiveElementVersions = [])).push("2.1.0");
280
280
  /**
281
281
  * @license
282
282
  * Copyright 2017 Google LLC
@@ -284,8 +284,8 @@ P.elementStyles = [], P.shadowRootOptions = { mode: "open" }, P[H("elementProper
284
284
  */
285
285
  const V = globalThis, X = V.trustedTypes, we = X ? X.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, ze = "$lit$", A = `lit$${Math.random().toFixed(9).slice(2)}$`, Ie = "?" + A, Ye = `<${Ie}>`, I = document, j = () => I.createComment(""), B = (s) => s === null || typeof s != "object" && typeof s != "function", fe = Array.isArray, qe = (s) => fe(s) || typeof (s == null ? void 0 : s[Symbol.iterator]) == "function", re = `[
286
286
  \f\r]`, R = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Se = /-->/g, ke = />/g, T = RegExp(`>|${re}(?:([^\\s"'>=/]+)(${re}*=${re}*(?:[^
287
- \f\r"'\`<>=]|("|')|))|$)`, "g"), $e = /'/g, De = /"/g, Ue = /^(?:script|style|textarea|title)$/i, Ke = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), d = Ke(1), U = Symbol.for("lit-noChange"), x = Symbol.for("lit-nothing"), Ce = /* @__PURE__ */ new WeakMap(), F = I.createTreeWalker(I, 129);
288
- function Pe(s, e) {
287
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), $e = /'/g, De = /"/g, Pe = /^(?:script|style|textarea|title)$/i, Ke = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), d = Ke(1), P = Symbol.for("lit-noChange"), x = Symbol.for("lit-nothing"), Ce = /* @__PURE__ */ new WeakMap(), F = I.createTreeWalker(I, 129);
288
+ function Ue(s, e) {
289
289
  if (!fe(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
290
290
  return we !== void 0 ? we.createHTML(e) : e;
291
291
  }
@@ -295,11 +295,11 @@ const Je = (s, e) => {
295
295
  for (let a = 0; a < t; a++) {
296
296
  const l = s[a];
297
297
  let p, c, u = -1, h = 0;
298
- for (; h < l.length && (o.lastIndex = h, c = o.exec(l), c !== null); ) h = o.lastIndex, o === R ? c[1] === "!--" ? o = Se : c[1] !== void 0 ? o = ke : c[2] !== void 0 ? (Ue.test(c[2]) && (n = RegExp("</" + c[2], "g")), o = T) : c[3] !== void 0 && (o = T) : o === T ? c[0] === ">" ? (o = n ?? R, u = -1) : c[1] === void 0 ? u = -2 : (u = o.lastIndex - c[2].length, p = c[1], o = c[3] === void 0 ? T : c[3] === '"' ? De : $e) : o === De || o === $e ? o = T : o === Se || o === ke ? o = R : (o = T, n = void 0);
298
+ for (; h < l.length && (o.lastIndex = h, c = o.exec(l), c !== null); ) h = o.lastIndex, o === R ? c[1] === "!--" ? o = Se : c[1] !== void 0 ? o = ke : c[2] !== void 0 ? (Pe.test(c[2]) && (n = RegExp("</" + c[2], "g")), o = T) : c[3] !== void 0 && (o = T) : o === T ? c[0] === ">" ? (o = n ?? R, u = -1) : c[1] === void 0 ? u = -2 : (u = o.lastIndex - c[2].length, p = c[1], o = c[3] === void 0 ? T : c[3] === '"' ? De : $e) : o === De || o === $e ? o = T : o === Se || o === ke ? o = R : (o = T, n = void 0);
299
299
  const g = o === T && s[a + 1].startsWith("/>") ? " " : "";
300
300
  r += o === R ? l + Ye : u >= 0 ? (i.push(p), l.slice(0, u) + ze + l.slice(u) + A + g) : l + A + (u === -2 ? a : g);
301
301
  }
302
- return [Pe(s, r + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), i];
302
+ return [Ue(s, r + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), i];
303
303
  };
304
304
  class Q {
305
305
  constructor({ strings: e, _$litType$: t }, i) {
@@ -317,7 +317,7 @@ class Q {
317
317
  const h = c[o++], g = n.getAttribute(u).split(A), v = /([.?@])?(.*)/.exec(h);
318
318
  l.push({ type: 1, index: r, name: v[2], strings: g, ctor: v[1] === "." ? Ze : v[1] === "?" ? et : v[1] === "@" ? tt : se }), n.removeAttribute(u);
319
319
  } else u.startsWith(A) && (l.push({ type: 6, index: r }), n.removeAttribute(u));
320
- if (Ue.test(n.tagName)) {
320
+ if (Pe.test(n.tagName)) {
321
321
  const u = n.textContent.split(A), h = u.length - 1;
322
322
  if (h > 0) {
323
323
  n.textContent = X ? X.emptyScript : "";
@@ -340,7 +340,7 @@ class Q {
340
340
  }
341
341
  function N(s, e, t = s, i) {
342
342
  var o, a;
343
- if (e === U) return e;
343
+ if (e === P) return e;
344
344
  let n = i !== void 0 ? (o = t._$Co) == null ? void 0 : o[i] : t._$Cl;
345
345
  const r = B(e) ? void 0 : e._$litDirective$;
346
346
  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 = N(s, n._$AS(s, e.values), n, i)), e;
@@ -393,7 +393,7 @@ class G {
393
393
  return this._$AB;
394
394
  }
395
395
  _$AI(e, t = this) {
396
- e = N(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) : qe(e) ? this.k(e) : this._(e);
396
+ e = N(this, e, t), B(e) ? e === x || e == null || e === "" ? (this._$AH !== x && this._$AR(), this._$AH = x) : e !== this._$AH && e !== P && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : qe(e) ? this.k(e) : this._(e);
397
397
  }
398
398
  O(e) {
399
399
  return this._$AA.parentNode.insertBefore(e, this._$AB);
@@ -406,7 +406,7 @@ class G {
406
406
  }
407
407
  $(e) {
408
408
  var r;
409
- const { values: t, _$litType$: i } = e, n = typeof i == "number" ? this._$AC(e) : (i.el === void 0 && (i.el = Q.createElement(Pe(i.h, i.h[0]), this.options)), i);
409
+ const { values: t, _$litType$: i } = e, n = typeof i == "number" ? this._$AC(e) : (i.el === void 0 && (i.el = Q.createElement(Ue(i.h, i.h[0]), this.options)), i);
410
410
  if (((r = this._$AH) == null ? void 0 : r._$AD) === n) this._$AH.p(t);
411
411
  else {
412
412
  const o = new Xe(n, this), a = o.u(this.options);
@@ -449,11 +449,11 @@ class se {
449
449
  _$AI(e, t = this, i, n) {
450
450
  const r = this.strings;
451
451
  let o = !1;
452
- if (r === void 0) e = N(this, e, t, 0), o = !B(e) || e !== this._$AH && e !== U, o && (this._$AH = e);
452
+ if (r === void 0) e = N(this, e, t, 0), o = !B(e) || e !== this._$AH && e !== P, o && (this._$AH = e);
453
453
  else {
454
454
  const a = e;
455
455
  let l, p;
456
- for (e = r[0], l = 0; l < r.length - 1; l++) p = N(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;
456
+ for (e = r[0], l = 0; l < r.length - 1; l++) p = N(this, a[i + l], t, l), p === P && (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;
457
457
  }
458
458
  o && !n && this.j(e);
459
459
  }
@@ -482,7 +482,7 @@ class tt extends se {
482
482
  super(e, t, i, n, r), this.type = 5;
483
483
  }
484
484
  _$AI(e, t = this) {
485
- if ((e = N(this, e, t, 0) ?? x) === U) return;
485
+ if ((e = N(this, e, t, 0) ?? x) === P) return;
486
486
  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);
487
487
  n && this.element.removeEventListener(this.name, this, i), r && this.element.addEventListener(this.name, this, e), this._$AH = e;
488
488
  }
@@ -519,7 +519,7 @@ const st = (s, e, t) => {
519
519
  * SPDX-License-Identifier: BSD-3-Clause
520
520
  */
521
521
  const z = globalThis;
522
- let L = class extends P {
522
+ let L = class extends U {
523
523
  constructor() {
524
524
  super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
525
525
  }
@@ -541,7 +541,7 @@ let L = class extends P {
541
541
  super.disconnectedCallback(), (e = this._$Do) == null || e.setConnected(!1);
542
542
  }
543
543
  render() {
544
- return U;
544
+ return P;
545
545
  }
546
546
  };
547
547
  var Te;
@@ -3006,6 +3006,31 @@ const pt = O`
3006
3006
  margin: 2px 0;
3007
3007
  line-height: 1.4;
3008
3008
  }
3009
+
3010
+ .step-edit-btn {
3011
+ display: flex;
3012
+ align-items: center;
3013
+ justify-content: center;
3014
+ width: 28px;
3015
+ height: 28px;
3016
+ border: none;
3017
+ background: transparent;
3018
+ border-radius: 4px;
3019
+ cursor: pointer;
3020
+ color: #6b7280;
3021
+ transition: all 0.2s ease;
3022
+ padding: 0;
3023
+ }
3024
+
3025
+ .step-edit-btn:hover {
3026
+ background: transparent;
3027
+ color: #374151;
3028
+ }
3029
+
3030
+ .step-edit-btn svg {
3031
+ width: 16px;
3032
+ height: 16px;
3033
+ }
3009
3034
  `, ht = O`
3010
3035
  /* Modal Overlay */
3011
3036
  .modal-overlay {
@@ -4600,6 +4625,31 @@ Use **bold** and *italic* text.`;
4600
4625
  <small>${this._getAssignmentDisplayText(t.assignment)}</small>
4601
4626
  </div>
4602
4627
  <div class="step-actions">
4628
+ <button
4629
+ class="step-edit-btn"
4630
+ @click=${(i) => {
4631
+ i.stopPropagation(), this._editStep(t.id);
4632
+ }}
4633
+ title="Edit step"
4634
+ >
4635
+ <svg
4636
+ xmlns="http://www.w3.org/2000/svg"
4637
+ width="16"
4638
+ height="16"
4639
+ viewBox="0 0 24 24"
4640
+ fill="none"
4641
+ stroke="currentColor"
4642
+ stroke-width="2"
4643
+ stroke-linecap="round"
4644
+ stroke-linejoin="round"
4645
+ class="lucide lucide-pencil-icon lucide-pencil"
4646
+ >
4647
+ <path
4648
+ 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"
4649
+ />
4650
+ <path d="m15 5 4 4" />
4651
+ </svg>
4652
+ </button>
4603
4653
  <button
4604
4654
  class="step-menu"
4605
4655
  @click=${(i) => {
@@ -6411,7 +6461,7 @@ class ue extends $t {
6411
6461
  }
6412
6462
  render(e) {
6413
6463
  if (e === x || e == null) return this._t = void 0, this.it = e;
6414
- if (e === U) return e;
6464
+ if (e === P) return e;
6415
6465
  if (typeof e != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
6416
6466
  if (e === this.it) return this._t;
6417
6467
  this.it = e;
@@ -7682,9 +7732,9 @@ function Ft(s, e) {
7682
7732
  case "date":
7683
7733
  return r + It(s, i) + o;
7684
7734
  case "textarea":
7685
- return r + Ut(s, i) + o;
7686
- case "select":
7687
7735
  return r + Pt(s, i) + o;
7736
+ case "select":
7737
+ return r + Ut(s, i) + o;
7688
7738
  case "radio":
7689
7739
  return r + Lt(s, i) + o;
7690
7740
  case "checkbox":
@@ -7805,14 +7855,14 @@ function It(s, e) {
7805
7855
  </div>
7806
7856
  `;
7807
7857
  }
7808
- function Ut(s, e) {
7858
+ function Pt(s, e) {
7809
7859
  return `
7810
7860
  <div class="print-response-value textarea-response">
7811
7861
  ${(e != null ? m(String(e)) : "") || '<span class="print-no-response">No response</span>'}
7812
7862
  </div>
7813
7863
  `;
7814
7864
  }
7815
- function Pt(s, e) {
7865
+ function Ut(s, e) {
7816
7866
  const t = e != null ? String(e) : "";
7817
7867
  return `
7818
7868
  <div class="print-response-value select-response">
@@ -10,9 +10,9 @@
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: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};/**
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}>`,z=document,j=()=>z.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,I=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=z.createTreeWalker(z,129);function ze(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=I):c[3]!==void 0&&(o=I):o===I?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?I:c[3]==='"'?Me:Ae):o===Me||o===Ae?o=I:o===Ce||o===Ee?o=Q:(o=I,n=void 0);const m=o===I&&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[ze(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=z.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)??z).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=z,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(z.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(ze(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
@@ -20,7 +20,7 @@
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const ze=s=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(s,e)}):customElements.define(s,e)};/**
23
+ */const Ie=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
@@ -2408,6 +2408,31 @@
2408
2408
  margin: 2px 0;
2409
2409
  line-height: 1.4;
2410
2410
  }
2411
+
2412
+ .step-edit-btn {
2413
+ display: flex;
2414
+ align-items: center;
2415
+ justify-content: center;
2416
+ width: 28px;
2417
+ height: 28px;
2418
+ border: none;
2419
+ background: transparent;
2420
+ border-radius: 4px;
2421
+ cursor: pointer;
2422
+ color: #6b7280;
2423
+ transition: all 0.2s ease;
2424
+ padding: 0;
2425
+ }
2426
+
2427
+ .step-edit-btn:hover {
2428
+ background: transparent;
2429
+ color: #374151;
2430
+ }
2431
+
2432
+ .step-edit-btn svg {
2433
+ width: 16px;
2434
+ height: 16px;
2435
+ }
2411
2436
  `,ht=N`
2412
2437
  /* Modal Overlay */
2413
2438
  .modal-overlay {
@@ -3365,6 +3390,29 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3365
3390
  <small>${this._getAssignmentDisplayText(t.assignment)}</small>
3366
3391
  </div>
3367
3392
  <div class="step-actions">
3393
+ <button
3394
+ class="step-edit-btn"
3395
+ @click=${i=>{i.stopPropagation(),this._editStep(t.id)}}
3396
+ title="Edit step"
3397
+ >
3398
+ <svg
3399
+ xmlns="http://www.w3.org/2000/svg"
3400
+ width="16"
3401
+ height="16"
3402
+ viewBox="0 0 24 24"
3403
+ fill="none"
3404
+ stroke="currentColor"
3405
+ stroke-width="2"
3406
+ stroke-linecap="round"
3407
+ stroke-linejoin="round"
3408
+ class="lucide lucide-pencil-icon lucide-pencil"
3409
+ >
3410
+ <path
3411
+ 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"
3412
+ />
3413
+ <path d="m15 5 4 4" />
3414
+ </svg>
3415
+ </button>
3368
3416
  <button
3369
3417
  class="step-menu"
3370
3418
  @click=${i=>{i.stopPropagation(),this._toggleStepMenu(i,t.id)}}
@@ -3637,7 +3685,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3637
3685
  ${ut}
3638
3686
  ${Pe}
3639
3687
  ${ht}
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"}}/*!
3688
+ `,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([Ie("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"}}/*!
3641
3689
  * Signature Pad v5.0.10 | https://github.com/szimek/signature_pad
3642
3690
  * (c) 2025 Szymon Nowak | Released under the MIT license
3643
3691
  */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">
@@ -4133,7 +4181,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4133
4181
  </div>
4134
4182
  `:""}
4135
4183
  </div>
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>
4184
+ `}};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=_([Ie("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>
4137
4185
  <html lang="en">
4138
4186
  <head>
4139
4187
  <meta charset="UTF-8">
@@ -4170,7 +4218,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4170
4218
  ${s.description?`<div class="print-step-description">${g(s.description)}</div>`:""}
4171
4219
  <hr class="print-question-separator" />
4172
4220
  </div>
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)?"":`
4221
+ `}function Ft(s,e){return Wt(s)?zt(s,e):It(s)}function zt(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)?"":`
4174
4222
  <div class="print-question-title">
4175
4223
  ${g(s.label)}:
4176
4224
  </div>
@@ -4178,7 +4226,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4178
4226
  <div class="unknown-element">
4179
4227
  <p>⚠️ Unknown question type: ${g(s.type)}</p>
4180
4228
  </div>
4181
- `+o}}function zt(s){const e=s.type!=="divider"?'<hr class="print-question-separator" />':"";switch(s.type){case"text":return`
4229
+ `+o}}function It(s){const e=s.type!=="divider"?'<hr class="print-question-separator" />':"";switch(s.type){case"text":return`
4182
4230
  <div class="content-print">
4183
4231
  <div class="content-element">
4184
4232
  <div class="text-content">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drill-widgets",
3
- "version": "2.7.13",
3
+ "version": "2.7.14",
4
4
  "description": "Easily embed powerful workflow building and running capabilities into your web applications with Lit-based web components. Includes HTML export for server-side PDF generation.",
5
5
  "scripts": {
6
6
  "dev": "vite",