drill-widgets 2.7.13 → 2.7.15

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,16 +276,16 @@ 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
283
283
  * SPDX-License-Identifier: BSD-3-Clause
284
284
  */
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 = `[
285
+ const V = globalThis, X = V.trustedTypes, we = X ? X.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, ze = "$lit$", E = `lit$${Math.random().toFixed(9).slice(2)}$`, Ie = "?" + E, 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
- 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);
300
+ r += o === R ? l + Ye : u >= 0 ? (i.push(p), l.slice(0, u) + ze + l.slice(u) + E + g) : l + E + (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) {
@@ -314,11 +314,11 @@ class Q {
314
314
  for (; (n = F.nextNode()) !== null && l.length < a; ) {
315
315
  if (n.nodeType === 1) {
316
316
  if (n.hasAttributes()) for (const u of n.getAttributeNames()) if (u.endsWith(ze)) {
317
- const h = c[o++], g = n.getAttribute(u).split(A), v = /([.?@])?(.*)/.exec(h);
317
+ const h = c[o++], g = n.getAttribute(u).split(E), 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
- } else u.startsWith(A) && (l.push({ type: 6, index: r }), n.removeAttribute(u));
320
- if (Ue.test(n.tagName)) {
321
- const u = n.textContent.split(A), h = u.length - 1;
319
+ } else u.startsWith(E) && (l.push({ type: 6, index: r }), n.removeAttribute(u));
320
+ if (Pe.test(n.tagName)) {
321
+ const u = n.textContent.split(E), h = u.length - 1;
322
322
  if (h > 0) {
323
323
  n.textContent = X ? X.emptyScript : "";
324
324
  for (let g = 0; g < h; g++) n.append(u[g], j()), F.nextNode(), l.push({ type: 2, index: ++r });
@@ -328,7 +328,7 @@ class Q {
328
328
  } else if (n.nodeType === 8) if (n.data === Ie) l.push({ type: 2, index: r });
329
329
  else {
330
330
  let u = -1;
331
- for (; (u = n.data.indexOf(A, u + 1)) !== -1; ) l.push({ type: 7, index: r }), u += A.length - 1;
331
+ for (; (u = n.data.indexOf(E, u + 1)) !== -1; ) l.push({ type: 7, index: r }), u += E.length - 1;
332
332
  }
333
333
  r++;
334
334
  }
@@ -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;
@@ -599,11 +599,11 @@ function C(s) {
599
599
  function b(s) {
600
600
  return C({ ...s, state: !0, attribute: !1 });
601
601
  }
602
- const y = [];
602
+ const w = [];
603
603
  for (let s = 0; s < 256; ++s)
604
- y.push((s + 256).toString(16).slice(1));
604
+ w.push((s + 256).toString(16).slice(1));
605
605
  function ot(s, e = 0) {
606
- 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();
606
+ return (w[s[e + 0]] + w[s[e + 1]] + w[s[e + 2]] + w[s[e + 3]] + "-" + w[s[e + 4]] + w[s[e + 5]] + "-" + w[s[e + 6]] + w[s[e + 7]] + "-" + w[s[e + 8]] + w[s[e + 9]] + "-" + w[s[e + 10]] + w[s[e + 11]] + w[s[e + 12]] + w[s[e + 13]] + w[s[e + 14]] + w[s[e + 15]]).toLowerCase();
607
607
  }
608
608
  let le;
609
609
  const at = new Uint8Array(16);
@@ -615,11 +615,11 @@ function lt() {
615
615
  }
616
616
  return le(at);
617
617
  }
618
- const dt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ee = { randomUUID: dt };
619
- function E(s, e, t) {
618
+ const dt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ae = { randomUUID: dt };
619
+ function A(s, e, t) {
620
620
  var n;
621
- if (Ee.randomUUID && !s)
622
- return Ee.randomUUID();
621
+ if (Ae.randomUUID && !s)
622
+ return Ae.randomUUID();
623
623
  s = s || {};
624
624
  const i = s.random ?? ((n = s.rng) == null ? void 0 : n.call(s)) ?? lt();
625
625
  if (i.length < 16)
@@ -3006,6 +3006,51 @@ 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
+ }
3034
+
3035
+ .assignment-name-fields {
3036
+ display: flex;
3037
+ gap: 8px;
3038
+ margin-top: 8px;
3039
+ }
3040
+
3041
+ .assignment-name-input {
3042
+ flex: 1;
3043
+ padding: 8px 12px;
3044
+ border: 1px solid #d1d5db;
3045
+ border-radius: 6px;
3046
+ font-size: 14px;
3047
+ }
3048
+
3049
+ .assignment-name-input:focus {
3050
+ outline: none;
3051
+ border-color: #3b82f6;
3052
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
3053
+ }
3009
3054
  `, ht = O`
3010
3055
  /* Modal Overlay */
3011
3056
  .modal-overlay {
@@ -3393,7 +3438,7 @@ var gt = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, S = (s, e,
3393
3438
  (o = s[r]) && (n = (i ? o(e, t, n) : o(n)) || n);
3394
3439
  return i && n && gt(e, t, n), n;
3395
3440
  };
3396
- let w = class extends L {
3441
+ let _ = class extends L {
3397
3442
  constructor() {
3398
3443
  super(...arguments), this._templateData = {
3399
3444
  name: "",
@@ -3402,7 +3447,7 @@ let w = class extends L {
3402
3447
  }, this._showStepModal = !1, this._stepFormData = {
3403
3448
  title: "",
3404
3449
  description: ""
3405
- }, 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;
3450
+ }, this._draggedStepId = null, this._dragOverStepId = null, this._selectedStepId = null, this._questions = [], this._editingStepId = null, this._stepAssignmentCategory = "individual", this._stepAssignmentType = "subject", this._stepAssignmentTarget = "", this._stepAssignmentFirstName = "", this._stepAssignmentLastName = "", this._openMenuStepId = null;
3406
3451
  }
3407
3452
  connectedCallback() {
3408
3453
  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);
@@ -3416,7 +3461,7 @@ let w = class extends L {
3416
3461
  }
3417
3462
  _getDefaultWorkflowData() {
3418
3463
  const s = {
3419
- id: E(),
3464
+ id: A(),
3420
3465
  title: "Step 1",
3421
3466
  description: "",
3422
3467
  order: 1,
@@ -3428,7 +3473,7 @@ let w = class extends L {
3428
3473
  status: "pending"
3429
3474
  };
3430
3475
  return {
3431
- id: E(),
3476
+ id: A(),
3432
3477
  name: "",
3433
3478
  description: "",
3434
3479
  steps: [s]
@@ -3456,7 +3501,7 @@ let w = class extends L {
3456
3501
  var s, e, t;
3457
3502
  if ((s = this._templateData.name) != null && s.trim()) {
3458
3503
  const i = {
3459
- id: this._templateData.id || E(),
3504
+ id: this._templateData.id || A(),
3460
3505
  name: this._templateData.name,
3461
3506
  description: this._templateData.description || "",
3462
3507
  steps: this._templateData.steps || []
@@ -3475,7 +3520,7 @@ let w = class extends L {
3475
3520
  console.log("🔹 Closing step creation modal"), this._showStepModal = !1, this._editingStepId = null, this._stepFormData = {
3476
3521
  title: "",
3477
3522
  description: ""
3478
- }, this._stepAssignmentCategory = "individual", this._stepAssignmentType = "subject", this._stepAssignmentTarget = "";
3523
+ }, this._stepAssignmentCategory = "individual", this._stepAssignmentType = "subject", this._stepAssignmentTarget = "", this._stepAssignmentFirstName = "", this._stepAssignmentLastName = "";
3479
3524
  }
3480
3525
  _handleStepFormInput(s) {
3481
3526
  const e = s.target, { name: t, value: i } = e;
@@ -3493,10 +3538,17 @@ let w = class extends L {
3493
3538
  _editStep(s) {
3494
3539
  var t;
3495
3540
  const e = (t = this._templateData.steps) == null ? void 0 : t.find((i) => i.id === s);
3496
- e && (this._editingStepId = s, this._stepFormData = {
3497
- title: e.title,
3498
- description: e.description
3499
- }, 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));
3541
+ if (e) {
3542
+ if (this._editingStepId = s, this._stepFormData = {
3543
+ title: e.title,
3544
+ description: e.description
3545
+ }, this._stepAssignmentCategory = e.assignment.category, this._stepAssignmentType = e.assignment.type, this._stepAssignmentTarget = e.assignment.email || e.assignment.targetId || "", this._stepAssignmentType === "specific_user") {
3546
+ const n = (e.assignment.targetName || "").split(" ");
3547
+ this._stepAssignmentFirstName = n[0] || "", this._stepAssignmentLastName = n.slice(1).join(" ") || "";
3548
+ } else
3549
+ this._stepAssignmentFirstName = "", this._stepAssignmentLastName = "";
3550
+ this._showStepModal = !0, this._closeStepMenu(), console.log("Editing step:", s);
3551
+ }
3500
3552
  }
3501
3553
  _duplicateStep(s) {
3502
3554
  var n, r;
@@ -3504,12 +3556,12 @@ let w = class extends L {
3504
3556
  if (!e) return;
3505
3557
  const t = this._templateData.steps || [], i = {
3506
3558
  ...e,
3507
- id: E(),
3559
+ id: A(),
3508
3560
  title: `${e.title} (Copy)`,
3509
3561
  order: t.length + 1,
3510
3562
  elements: ((r = e.elements) == null ? void 0 : r.map((o) => ({
3511
3563
  ...o,
3512
- id: E()
3564
+ id: A()
3513
3565
  }))) || []
3514
3566
  };
3515
3567
  this._templateData = {
@@ -3536,7 +3588,7 @@ let w = class extends L {
3536
3588
  category: this._stepAssignmentCategory,
3537
3589
  type: this._stepAssignmentType
3538
3590
  };
3539
- 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) {
3591
+ if (this._stepAssignmentType === "specific_user" && this._stepAssignmentTarget ? (e.email = this._stepAssignmentTarget, this._stepAssignmentFirstName || this._stepAssignmentLastName ? e.targetName = `${this._stepAssignmentFirstName} ${this._stepAssignmentLastName}`.trim() : e.targetName = this._stepAssignmentTarget) : this._stepAssignmentType === "instance_role_assignee_select" && this._stepAssignmentTarget && (e.targetId = this._stepAssignmentTarget), this._editingStepId) {
3540
3592
  const n = s.map((r) => {
3541
3593
  var o;
3542
3594
  return r.id === this._editingStepId ? {
@@ -3552,7 +3604,7 @@ let w = class extends L {
3552
3604
  }, console.log("✅ Step updated:", this._editingStepId);
3553
3605
  } else {
3554
3606
  const n = {
3555
- id: E(),
3607
+ id: A(),
3556
3608
  title: this._stepFormData.title.trim(),
3557
3609
  description: ((i = this._stepFormData.description) == null ? void 0 : i.trim()) || "",
3558
3610
  order: s.length + 1,
@@ -3626,7 +3678,7 @@ let w = class extends L {
3626
3678
  }
3627
3679
  if (["text", "html", "divider", "markdown"].includes(s)) {
3628
3680
  let r = {
3629
- id: E(),
3681
+ id: A(),
3630
3682
  type: s,
3631
3683
  order: (((i = e.elements) == null ? void 0 : i.length) || 0) + 1
3632
3684
  };
@@ -3656,7 +3708,7 @@ Use **bold** and *italic* text.`;
3656
3708
  }, console.log("✅ Content element added to step:", this._selectedStepId);
3657
3709
  } else {
3658
3710
  const r = {
3659
- id: E(),
3711
+ id: A(),
3660
3712
  // Simple ID generation
3661
3713
  type: s,
3662
3714
  // Default type
@@ -3687,7 +3739,7 @@ Use **bold** and *italic* text.`;
3687
3739
  return;
3688
3740
  }
3689
3741
  let t = {
3690
- id: E(),
3742
+ id: A(),
3691
3743
  type: s,
3692
3744
  order: (((n = e.elements) == null ? void 0 : n.length) || 0) + 1
3693
3745
  };
@@ -4500,6 +4552,28 @@ Use **bold** and *italic* text.`;
4500
4552
  </div>
4501
4553
 
4502
4554
  ${this._stepAssignmentType === "specific_user" ? d`
4555
+ <div class="assignment-name-fields">
4556
+ <input
4557
+ type="text"
4558
+ class="assignment-name-input"
4559
+ placeholder="First name"
4560
+ .value=${this._stepAssignmentFirstName}
4561
+ @input=${(t) => {
4562
+ const i = t.target;
4563
+ this._stepAssignmentFirstName = i.value;
4564
+ }}
4565
+ />
4566
+ <input
4567
+ type="text"
4568
+ class="assignment-name-input"
4569
+ placeholder="Last name"
4570
+ .value=${this._stepAssignmentLastName}
4571
+ @input=${(t) => {
4572
+ const i = t.target;
4573
+ this._stepAssignmentLastName = i.value;
4574
+ }}
4575
+ />
4576
+ </div>
4503
4577
  <input
4504
4578
  type="email"
4505
4579
  class="assignment-select"
@@ -4600,6 +4674,31 @@ Use **bold** and *italic* text.`;
4600
4674
  <small>${this._getAssignmentDisplayText(t.assignment)}</small>
4601
4675
  </div>
4602
4676
  <div class="step-actions">
4677
+ <button
4678
+ class="step-edit-btn"
4679
+ @click=${(i) => {
4680
+ i.stopPropagation(), this._editStep(t.id);
4681
+ }}
4682
+ title="Edit step"
4683
+ >
4684
+ <svg
4685
+ xmlns="http://www.w3.org/2000/svg"
4686
+ width="16"
4687
+ height="16"
4688
+ viewBox="0 0 24 24"
4689
+ fill="none"
4690
+ stroke="currentColor"
4691
+ stroke-width="2"
4692
+ stroke-linecap="round"
4693
+ stroke-linejoin="round"
4694
+ class="lucide lucide-pencil-icon lucide-pencil"
4695
+ >
4696
+ <path
4697
+ 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"
4698
+ />
4699
+ <path d="m15 5 4 4" />
4700
+ </svg>
4701
+ </button>
4603
4702
  <button
4604
4703
  class="step-menu"
4605
4704
  @click=${(i) => {
@@ -4929,7 +5028,7 @@ Use **bold** and *italic* text.`;
4929
5028
  `;
4930
5029
  }
4931
5030
  };
4932
- w.styles = O`
5031
+ _.styles = O`
4933
5032
  ${pt}
4934
5033
  ${ct}
4935
5034
  ${ut}
@@ -4938,49 +5037,55 @@ w.styles = O`
4938
5037
  `;
4939
5038
  S([
4940
5039
  b()
4941
- ], w.prototype, "_templateData", 2);
5040
+ ], _.prototype, "_templateData", 2);
4942
5041
  S([
4943
5042
  b()
4944
- ], w.prototype, "_showStepModal", 2);
5043
+ ], _.prototype, "_showStepModal", 2);
4945
5044
  S([
4946
5045
  b()
4947
- ], w.prototype, "_stepFormData", 2);
5046
+ ], _.prototype, "_stepFormData", 2);
4948
5047
  S([
4949
5048
  b()
4950
- ], w.prototype, "_draggedStepId", 2);
5049
+ ], _.prototype, "_draggedStepId", 2);
4951
5050
  S([
4952
5051
  b()
4953
- ], w.prototype, "_dragOverStepId", 2);
5052
+ ], _.prototype, "_dragOverStepId", 2);
4954
5053
  S([
4955
5054
  b()
4956
- ], w.prototype, "_selectedStepId", 2);
5055
+ ], _.prototype, "_selectedStepId", 2);
4957
5056
  S([
4958
5057
  b()
4959
- ], w.prototype, "_questions", 2);
5058
+ ], _.prototype, "_questions", 2);
4960
5059
  S([
4961
5060
  b()
4962
- ], w.prototype, "_editingStepId", 2);
5061
+ ], _.prototype, "_editingStepId", 2);
4963
5062
  S([
4964
5063
  b()
4965
- ], w.prototype, "_stepAssignmentCategory", 2);
5064
+ ], _.prototype, "_stepAssignmentCategory", 2);
4966
5065
  S([
4967
5066
  b()
4968
- ], w.prototype, "_stepAssignmentType", 2);
5067
+ ], _.prototype, "_stepAssignmentType", 2);
4969
5068
  S([
4970
5069
  b()
4971
- ], w.prototype, "_stepAssignmentTarget", 2);
5070
+ ], _.prototype, "_stepAssignmentTarget", 2);
5071
+ S([
5072
+ b()
5073
+ ], _.prototype, "_stepAssignmentFirstName", 2);
5074
+ S([
5075
+ b()
5076
+ ], _.prototype, "_stepAssignmentLastName", 2);
4972
5077
  S([
4973
5078
  C({ attribute: !1 })
4974
- ], w.prototype, "onCancel", 2);
5079
+ ], _.prototype, "onCancel", 2);
4975
5080
  S([
4976
5081
  C({ attribute: !1 })
4977
- ], w.prototype, "workflow", 2);
5082
+ ], _.prototype, "workflow", 2);
4978
5083
  S([
4979
5084
  b()
4980
- ], w.prototype, "_openMenuStepId", 2);
4981
- w = S([
5085
+ ], _.prototype, "_openMenuStepId", 2);
5086
+ _ = S([
4982
5087
  Le("builder-widget")
4983
- ], w);
5088
+ ], _);
4984
5089
  class ft {
4985
5090
  constructor(e, t) {
4986
5091
  this.signaturePads = e, this.savedSignatures = t;
@@ -6411,7 +6516,7 @@ class ue extends $t {
6411
6516
  }
6412
6517
  render(e) {
6413
6518
  if (e === x || e == null) return this._t = void 0, this.it = e;
6414
- if (e === U) return e;
6519
+ if (e === P) return e;
6415
6520
  if (typeof e != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
6416
6521
  if (e === this.it) return this._t;
6417
6522
  this.it = e;
@@ -6420,7 +6525,7 @@ class ue extends $t {
6420
6525
  }
6421
6526
  }
6422
6527
  ue.directiveName = "unsafeHTML", ue.resultType = 1;
6423
- const Ae = kt(ue);
6528
+ const Ee = kt(ue);
6424
6529
  class D {
6425
6530
  static renderMarkdown(e) {
6426
6531
  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>");
@@ -6436,7 +6541,7 @@ class D {
6436
6541
  return d`
6437
6542
  <div class="content-element markdown-content">
6438
6543
  <div class="markdown-text">
6439
- ${Ae(D.renderMarkdown(e.content))}
6544
+ ${Ee(D.renderMarkdown(e.content))}
6440
6545
  </div>
6441
6546
  </div>
6442
6547
  `;
@@ -6452,7 +6557,7 @@ class D {
6452
6557
  static renderHtml(e) {
6453
6558
  return d`
6454
6559
  <div class="content-element html-content">
6455
- <div class="html-content-wrapper">${Ae(e.content)}</div>
6560
+ <div class="html-content-wrapper">${Ee(e.content)}</div>
6456
6561
  </div>
6457
6562
  `;
6458
6563
  }
@@ -6768,8 +6873,8 @@ class de {
6768
6873
  r(u), a !== "preview" && o(e, c);
6769
6874
  }
6770
6875
  }
6771
- var Ct = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, _ = (s, e, t, i) => {
6772
- for (var n = i > 1 ? void 0 : i ? Et(e, t) : e, r = s.length - 1, o; r >= 0; r--)
6876
+ var Ct = Object.defineProperty, At = Object.getOwnPropertyDescriptor, y = (s, e, t, i) => {
6877
+ for (var n = i > 1 ? void 0 : i ? At(e, t) : e, r = s.length - 1, o; r >= 0; r--)
6773
6878
  (o = s[r]) && (n = (i ? o(e, t, n) : o(n)) || n);
6774
6879
  return i && n && Ct(e, t, n), n;
6775
6880
  };
@@ -7552,61 +7657,61 @@ f.CONTENT_ELEMENT_TYPES = [
7552
7657
  "divider",
7553
7658
  "markdown"
7554
7659
  ];
7555
- _([
7660
+ y([
7556
7661
  C({ type: Object })
7557
7662
  ], f.prototype, "instance", 2);
7558
- _([
7663
+ y([
7559
7664
  C({ type: Object })
7560
7665
  ], f.prototype, "workflow", 2);
7561
- _([
7666
+ y([
7562
7667
  C({ type: String })
7563
7668
  ], f.prototype, "mode", 2);
7564
- _([
7669
+ y([
7565
7670
  C({ type: Boolean })
7566
7671
  ], f.prototype, "isLoading", 2);
7567
- _([
7672
+ y([
7568
7673
  C({ type: Object })
7569
7674
  ], f.prototype, "currentUser", 2);
7570
- _([
7675
+ y([
7571
7676
  C({ type: Function })
7572
7677
  ], f.prototype, "onSignatureCaptured", 2);
7573
- _([
7678
+ y([
7574
7679
  C({ type: Function })
7575
7680
  ], f.prototype, "onFileUploaded", 2);
7576
- _([
7681
+ y([
7577
7682
  b()
7578
7683
  ], f.prototype, "_currentStepIndex", 2);
7579
- _([
7684
+ y([
7580
7685
  b()
7581
7686
  ], f.prototype, "_formData", 2);
7582
- _([
7687
+ y([
7583
7688
  b()
7584
7689
  ], f.prototype, "_validationErrors", 2);
7585
- _([
7690
+ y([
7586
7691
  b()
7587
7692
  ], f.prototype, "_internalCompletedSteps", 2);
7588
- _([
7693
+ y([
7589
7694
  b()
7590
7695
  ], f.prototype, "_formRestorationComplete", 2);
7591
- _([
7696
+ y([
7592
7697
  b()
7593
7698
  ], f.prototype, "_savedSignatures", 2);
7594
- _([
7699
+ y([
7595
7700
  b()
7596
7701
  ], f.prototype, "_replacingSignatures", 2);
7597
- _([
7702
+ y([
7598
7703
  b()
7599
7704
  ], f.prototype, "_savedInstance", 2);
7600
- _([
7705
+ y([
7601
7706
  b()
7602
7707
  ], f.prototype, "_isSubmitted", 2);
7603
- _([
7708
+ y([
7604
7709
  b()
7605
7710
  ], f.prototype, "_userStepsSubmitted", 2);
7606
- _([
7711
+ y([
7607
7712
  b()
7608
7713
  ], f.prototype, "_justSaved", 2);
7609
- f = _([
7714
+ f = y([
7610
7715
  Le("runner-widget")
7611
7716
  ], f);
7612
7717
  function Jt(s, e = {}) {
@@ -7637,7 +7742,7 @@ function Jt(s, e = {}) {
7637
7742
  <hr class="print-question-separator" />
7638
7743
 
7639
7744
  ${r ? Vt(s, o) : ""}
7640
- ${s.steps.map((l) => At(l)).join(`
7745
+ ${s.steps.map((l) => Et(l)).join(`
7641
7746
  `)}
7642
7747
  </div>
7643
7748
  </body>
@@ -7646,7 +7751,7 @@ function Jt(s, e = {}) {
7646
7751
  generatedAt: o
7647
7752
  };
7648
7753
  }
7649
- function At(s) {
7754
+ function Et(s) {
7650
7755
  return `
7651
7756
  <div class="print-step">
7652
7757
  <!-- Step Header -->
@@ -7682,9 +7787,9 @@ function Ft(s, e) {
7682
7787
  case "date":
7683
7788
  return r + It(s, i) + o;
7684
7789
  case "textarea":
7685
- return r + Ut(s, i) + o;
7686
- case "select":
7687
7790
  return r + Pt(s, i) + o;
7791
+ case "select":
7792
+ return r + Ut(s, i) + o;
7688
7793
  case "radio":
7689
7794
  return r + Lt(s, i) + o;
7690
7795
  case "checkbox":
@@ -7805,14 +7910,14 @@ function It(s, e) {
7805
7910
  </div>
7806
7911
  `;
7807
7912
  }
7808
- function Ut(s, e) {
7913
+ function Pt(s, e) {
7809
7914
  return `
7810
7915
  <div class="print-response-value textarea-response">
7811
7916
  ${(e != null ? m(String(e)) : "") || '<span class="print-no-response">No response</span>'}
7812
7917
  </div>
7813
7918
  `;
7814
7919
  }
7815
- function Pt(s, e) {
7920
+ function Ut(s, e) {
7816
7921
  const t = e != null ? String(e) : "";
7817
7922
  return `
7818
7923
  <div class="print-response-value select-response">
@@ -6,29 +6,29 @@
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
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");/**
9
+ */const{is:We,defineProperty:je,getOwnPropertyDescriptor:Ve,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&&je(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:r}=Ve(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: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 j=globalThis,J=j.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,V=()=>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,Ae=/>/g,I=RegExp(`>|${pe}(?:([^\\s"'>=/]+)(${pe}*=${pe}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Ee=/'/g,Me=/"/g,Te=/^(?:script|style|textarea|title)$/i,Je=s=>(e,...t)=>({_$litType$:s,strings:e,values:t}),d=Je(1),P=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),Fe=new WeakMap,U=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=Ae: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:Ee):o===Me||o===Ee?o=I:o===Ce||o===Ae?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),U.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(n=U.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],V()),U.nextNode(),l.push({type:2,index:++r});n.append(u[h],V())}}}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===P)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);U.currentNode=n;let r=U.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=U.nextNode(),o++)}return U.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!==P&&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(V()),this.O(V()),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!==P,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===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}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)===P)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=j.litHtmlPolyfillSupport;ce==null||ce(G,Y),(j.litHtmlVersions??(j.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(V(),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 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");/**
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 P}};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 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
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)}/**
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 A(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 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`
31
+ */function f(s){return A({...s,state:!0,attribute:!1})}const w=[];for(let s=0;s<256;++s)w.push((s+256).toString(16).slice(1));function at(s,e=0){return(w[s[e+0]]+w[s[e+1]]+w[s[e+2]]+w[s[e+3]]+"-"+w[s[e+4]]+w[s[e+5]]+"-"+w[s[e+6]]+w[s[e+7]]+"-"+w[s[e+8]]+w[s[e+9]]+"-"+w[s[e+10]]+w[s[e+11]]+w[s[e+12]]+w[s[e+13]]+w[s[e+14]]+w[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 Pe={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function E(s,e,t){var n;if(Pe.randomUUID&&!s)return Pe.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;
@@ -652,7 +652,7 @@
652
652
  border-radius: 4px;
653
653
  border-left: 3px solid #e5e7eb;
654
654
  }
655
- `,Pe=N`
655
+ `,Ue=N`
656
656
  /* Builder Step Styles */
657
657
  .steps-list {
658
658
  display: flex;
@@ -2408,6 +2408,51 @@
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
+ }
2436
+
2437
+ .assignment-name-fields {
2438
+ display: flex;
2439
+ gap: 8px;
2440
+ margin-top: 8px;
2441
+ }
2442
+
2443
+ .assignment-name-input {
2444
+ flex: 1;
2445
+ padding: 8px 12px;
2446
+ border: 1px solid #d1d5db;
2447
+ border-radius: 6px;
2448
+ font-size: 14px;
2449
+ }
2450
+
2451
+ .assignment-name-input:focus {
2452
+ outline: none;
2453
+ border-color: #3b82f6;
2454
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
2455
+ }
2411
2456
  `,ht=N`
2412
2457
  /* Modal Overlay */
2413
2458
  .modal-overlay {
@@ -2789,9 +2834,9 @@
2789
2834
  flex-direction: column;
2790
2835
  }
2791
2836
  }
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...
2837
+ `;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 _=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._stepAssignmentFirstName="",this._stepAssignmentLastName="",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:E(),title:"Step 1",description:"",order:1,assignment:{category:"individual",type:"subject"},elements:[],status:"pending"};return{id:E(),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||E(),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="",this._stepAssignmentFirstName="",this._stepAssignmentLastName=""}_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);if(e){if(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._stepAssignmentType==="specific_user"){const n=(e.assignment.targetName||"").split(" ");this._stepAssignmentFirstName=n[0]||"",this._stepAssignmentLastName=n.slice(1).join(" ")||""}else this._stepAssignmentFirstName="",this._stepAssignmentLastName="";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:E(),title:`${e.title} (Copy)`,order:t.length+1,elements:((r=e.elements)==null?void 0:r.map(o=>({...o,id:E()})))||[]};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._stepAssignmentFirstName||this._stepAssignmentLastName?e.targetName=`${this._stepAssignmentFirstName} ${this._stepAssignmentLastName}`.trim():e.targetName=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:E(),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:E(),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
2838
 
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...
2839
+ 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:E(),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:E(),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
2840
 
2796
2841
  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`
2797
2842
  <div class="question-options-section">
@@ -3272,6 +3317,22 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3272
3317
  </div>
3273
3318
 
3274
3319
  ${this._stepAssignmentType==="specific_user"?d`
3320
+ <div class="assignment-name-fields">
3321
+ <input
3322
+ type="text"
3323
+ class="assignment-name-input"
3324
+ placeholder="First name"
3325
+ .value=${this._stepAssignmentFirstName}
3326
+ @input=${t=>{const i=t.target;this._stepAssignmentFirstName=i.value}}
3327
+ />
3328
+ <input
3329
+ type="text"
3330
+ class="assignment-name-input"
3331
+ placeholder="Last name"
3332
+ .value=${this._stepAssignmentLastName}
3333
+ @input=${t=>{const i=t.target;this._stepAssignmentLastName=i.value}}
3334
+ />
3335
+ </div>
3275
3336
  <input
3276
3337
  type="email"
3277
3338
  class="assignment-select"
@@ -3365,6 +3426,29 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3365
3426
  <small>${this._getAssignmentDisplayText(t.assignment)}</small>
3366
3427
  </div>
3367
3428
  <div class="step-actions">
3429
+ <button
3430
+ class="step-edit-btn"
3431
+ @click=${i=>{i.stopPropagation(),this._editStep(t.id)}}
3432
+ title="Edit step"
3433
+ >
3434
+ <svg
3435
+ xmlns="http://www.w3.org/2000/svg"
3436
+ width="16"
3437
+ height="16"
3438
+ viewBox="0 0 24 24"
3439
+ fill="none"
3440
+ stroke="currentColor"
3441
+ stroke-width="2"
3442
+ stroke-linecap="round"
3443
+ stroke-linejoin="round"
3444
+ class="lucide lucide-pencil-icon lucide-pencil"
3445
+ >
3446
+ <path
3447
+ 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"
3448
+ />
3449
+ <path d="m15 5 4 4" />
3450
+ </svg>
3451
+ </button>
3368
3452
  <button
3369
3453
  class="step-menu"
3370
3454
  @click=${i=>{i.stopPropagation(),this._toggleStepMenu(i,t.id)}}
@@ -3631,13 +3715,13 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3631
3715
  </div>
3632
3716
  </div>
3633
3717
  </div>
3634
- `}};w.styles=N`
3718
+ `}};_.styles=N`
3635
3719
  ${pt}
3636
3720
  ${ct}
3637
3721
  ${ut}
3638
- ${Pe}
3722
+ ${Ue}
3639
3723
  ${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"}}/*!
3724
+ `,S([f()],_.prototype,"_templateData",2),S([f()],_.prototype,"_showStepModal",2),S([f()],_.prototype,"_stepFormData",2),S([f()],_.prototype,"_draggedStepId",2),S([f()],_.prototype,"_dragOverStepId",2),S([f()],_.prototype,"_selectedStepId",2),S([f()],_.prototype,"_questions",2),S([f()],_.prototype,"_editingStepId",2),S([f()],_.prototype,"_stepAssignmentCategory",2),S([f()],_.prototype,"_stepAssignmentType",2),S([f()],_.prototype,"_stepAssignmentTarget",2),S([f()],_.prototype,"_stepAssignmentFirstName",2),S([f()],_.prototype,"_stepAssignmentLastName",2),S([A({attribute:!1})],_.prototype,"onCancel",2),S([A({attribute:!1})],_.prototype,"workflow",2),S([f()],_.prototype,"_openMenuStepId",2),_=S([Ie("builder-widget")],_);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
3725
  * Signature Pad v5.0.10 | https://github.com/szimek/signature_pad
3642
3726
  * (c) 2025 Szymon Nowak | Released under the MIT license
3643
3727
  */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">
@@ -3875,7 +3959,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
3875
3959
  * @license
3876
3960
  * Copyright 2017 Google LLC
3877
3961
  * SPDX-License-Identifier: BSD-3-Clause
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`
3962
+ */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===P)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`
3879
3963
  <div class="content-element text-content">
3880
3964
  <p>${e.content}</p>
3881
3965
  </div>
@@ -4076,7 +4160,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4076
4160
  ${e.mode==="admin"?e.justSaved?"✓ Saved!":"Save":e.isLastStep?"Submit":"Next"}
4077
4161
  </button>
4078
4162
  </div>
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">
4163
+ `}}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,At=Object.getOwnPropertyDescriptor,y=(s,e,t,i)=>{for(var n=i>1?void 0:i?At(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 b=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 b.QUESTION_ELEMENT_TYPES.includes(s.type)}_isContentElement(s){return b.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
4164
  <p>⚠️ Unknown element type: ${s.type}</p>
4081
4165
  </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">
4082
4166
  <div class="unknown-element">
@@ -4133,7 +4217,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4133
4217
  </div>
4134
4218
  `:""}
4135
4219
  </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>
4220
+ `}};b.styles=[Ue],b.QUESTION_ELEMENT_TYPES=["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"],b.CONTENT_ELEMENT_TYPES=["text","html","image","video","file","divider","markdown"],y([A({type:Object})],b.prototype,"instance",2),y([A({type:Object})],b.prototype,"workflow",2),y([A({type:String})],b.prototype,"mode",2),y([A({type:Boolean})],b.prototype,"isLoading",2),y([A({type:Object})],b.prototype,"currentUser",2),y([A({type:Function})],b.prototype,"onSignatureCaptured",2),y([A({type:Function})],b.prototype,"onFileUploaded",2),y([f()],b.prototype,"_currentStepIndex",2),y([f()],b.prototype,"_formData",2),y([f()],b.prototype,"_validationErrors",2),y([f()],b.prototype,"_internalCompletedSteps",2),y([f()],b.prototype,"_formRestorationComplete",2),y([f()],b.prototype,"_savedSignatures",2),y([f()],b.prototype,"_replacingSignatures",2),y([f()],b.prototype,"_savedInstance",2),y([f()],b.prototype,"_isSubmitted",2),y([f()],b.prototype,"_userStepsSubmitted",2),y([f()],b.prototype,"_justSaved",2),b=y([Ie("runner-widget")],b);function Et(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
4221
  <html lang="en">
4138
4222
  <head>
4139
4223
  <meta charset="UTF-8">
@@ -4150,7 +4234,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4150
4234
  </div>
4151
4235
  <hr class="print-question-separator" />
4152
4236
 
4153
- ${r?jt(s,o):""}
4237
+ ${r?Vt(s,o):""}
4154
4238
  ${s.steps.map(l=>Mt(l)).join(`
4155
4239
  `)}
4156
4240
  </div>
@@ -4170,15 +4254,15 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4170
4254
  ${s.description?`<div class="print-step-description">${g(s.description)}</div>`:""}
4171
4255
  <hr class="print-question-separator" />
4172
4256
  </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)?"":`
4257
+ `}function Ft(s,e){return Wt(s)?zt(s,e):It(s)}function zt(s,e){const t=jt(s.id,e.responses),i=t==null?void 0:t.value,r=s.type==="checkbox"&&(!s.options||s.options.length===0)?"":`
4174
4258
  <div class="print-question-title">
4175
4259
  ${g(s.label)}:
4176
4260
  </div>
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+`
4261
+ `,o='<hr class="print-question-separator" />';switch(s.type){case"text_input":case"number":case"date":return r+Pt(s,i)+o;case"textarea":return r+Ut(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+`
4178
4262
  <div class="unknown-element">
4179
4263
  <p>⚠️ Unknown question type: ${g(s.type)}</p>
4180
4264
  </div>
4181
- `+o}}function zt(s){const e=s.type!=="divider"?'<hr class="print-question-separator" />':"";switch(s.type){case"text":return`
4265
+ `+o}}function It(s){const e=s.type!=="divider"?'<hr class="print-question-separator" />':"";switch(s.type){case"text":return`
4182
4266
  <div class="content-print">
4183
4267
  <div class="content-element">
4184
4268
  <div class="text-content">
@@ -4253,11 +4337,11 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4253
4337
  </div>
4254
4338
  ${e}
4255
4339
  </div>
4256
- `}}function Ut(s,e){const t=e!=null?g(String(e)):"";return`
4340
+ `}}function Pt(s,e){const t=e!=null?g(String(e)):"";return`
4257
4341
  <div class="print-response-value input-response">
4258
4342
  ${(s.type==="date"&&e?new Date(e).toLocaleDateString():t)||'<span class="print-no-response">No response</span>'}
4259
4343
  </div>
4260
- `}function Pt(s,e){return`
4344
+ `}function Ut(s,e){return`
4261
4345
  <div class="print-response-value textarea-response">
4262
4346
  ${(e!=null?g(String(e)):"")||'<span class="print-no-response">No response</span>'}
4263
4347
  </div>
@@ -4302,7 +4386,7 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4302
4386
  <div class="signature-fallback">
4303
4387
  <div class="signature-error">Unable to display signature</div>
4304
4388
  </div>
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`
4389
+ `}function Wt(s){return["text_input","textarea","select","number","radio","checkbox","date","file_upload","signature"].includes(s.type)}function jt(s,e){return e==null?void 0:e.find(t=>t.elementId===s)}function Vt(s,e){return`
4306
4390
  <div class="runner-card" style="margin-bottom: 40px; border-left: 4px solid #3b82f6;">
4307
4391
  <div style="display: flex; justify-content: between; align-items: center; gap: 20px;">
4308
4392
  <div>
@@ -4825,4 +4909,4 @@ Use **bold** and *italic* text.`;break}const i=this._templateData.steps.map(r=>r
4825
4909
  margin: 2px 0;
4826
4910
  line-height: 1.4;
4827
4911
  }
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"})});
4912
+ `}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=Et,C.restoreFormDataToRunner=Xt,C.updateInstanceFromRunnerForm=Jt,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/dist/lib.d.ts CHANGED
@@ -34,6 +34,8 @@ export declare class BuilderWidget extends LitElement {
34
34
  private _stepAssignmentCategory;
35
35
  private _stepAssignmentType;
36
36
  private _stepAssignmentTarget;
37
+ private _stepAssignmentFirstName;
38
+ private _stepAssignmentLastName;
37
39
  onCancel?: () => void;
38
40
  onWorkflowCreated?: (workflow: Workflow) => void;
39
41
  onWorkflowDeleted?: (workflowId: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drill-widgets",
3
- "version": "2.7.13",
3
+ "version": "2.7.15",
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",