@iyulab/lowline-form 0.4.0 → 0.6.0

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.
@@ -171,13 +171,22 @@ var s = class extends Error {
171
171
  values: n
172
172
  });
173
173
  }
174
- async post(e, t, n) {
175
- let r = `${this.src.replace(/\/+$/, "")}/${encodeURIComponent(e)}/${t}`, i = await this.fetcher(r, {
174
+ report(e) {
175
+ return this.send(e, "report", {
176
+ method: "GET",
177
+ credentials: "same-origin"
178
+ });
179
+ }
180
+ post(e, t, n) {
181
+ return this.send(e, t, {
176
182
  method: "POST",
177
183
  headers: { "content-type": "application/json" },
178
184
  body: JSON.stringify(n),
179
185
  credentials: "same-origin"
180
186
  });
187
+ }
188
+ async send(e, t, n) {
189
+ let r = `${this.src.replace(/\/+$/, "")}/${encodeURIComponent(e)}/${t}`, i = await this.fetcher(r, n);
181
190
  if (!i.ok) {
182
191
  let e = await i.json().catch(() => void 0);
183
192
  throw new s(i.status, e?.detail ?? `${t} answered ${i.status}`);
@@ -8122,9 +8131,9 @@ var Is = (e, t) => {
8122
8131
  this.parser = new on({ frontMatter: Is });
8123
8132
  }
8124
8133
  extractSchema(e) {
8125
- let t = {};
8126
- return (typeof e == "string" ? this.parser.parseFormdown(e) : e).forms.forEach((e, n) => {
8127
- t[e.name] = this.convertFieldToSchema(e, n);
8134
+ let t = {}, n = typeof e == "string" ? this.parser.parseFormdown(e) : e, r = /* @__PURE__ */ new Set();
8135
+ return n.forms.forEach((e, n) => {
8136
+ r.has(e.name) || (r.add(e.name), t[e.name] = this.convertFieldToSchema(e, n));
8128
8137
  }), t;
8129
8138
  }
8130
8139
  convertFieldToSchema(e, t) {
@@ -8205,8 +8214,13 @@ function Vs(e, t) {
8205
8214
  required: r && i && n(e?.requiredIf, !1)
8206
8215
  };
8207
8216
  }
8217
+ function Hs(e, t) {
8218
+ let n = {};
8219
+ for (let [r, i] of Object.entries(e)) n[r] = Vs(i.conditions, t);
8220
+ return n;
8221
+ }
8208
8222
  // node_modules/@formdown/core/dist/constraints.js
8209
- var Hs = Object.freeze({
8223
+ var Us = Object.freeze({
8210
8224
  required: "{label} is required",
8211
8225
  minLength: "Must be at least {min} characters",
8212
8226
  maxLength: "Must be at most {max} characters",
@@ -8220,24 +8234,24 @@ var Hs = Object.freeze({
8220
8234
  dateMin: "Date must be on or after {min}",
8221
8235
  dateMax: "Date must be on or before {max}",
8222
8236
  pattern: "Value does not match required format"
8223
- }), Us = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Ws = /^[\d\s\-+()]+$/, Gs = /^\d{4}-\d{2}-\d{2}$/;
8224
- function Ks(e) {
8237
+ }), Ws = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Gs = /^[\d\s\-+()]+$/, Ks = /^\d{4}-\d{2}-\d{2}$/;
8238
+ function qs(e) {
8225
8239
  return e == null || e === !1 ? !0 : Array.isArray(e) ? e.length === 0 : String(e).trim() === "";
8226
8240
  }
8227
- function qs(e, t, n = {}) {
8241
+ function Js(e, t, n = {}) {
8228
8242
  return e.replace(/\{(label|min|max)\}/g, (e, r) => {
8229
8243
  if (r === "label") return t.label || t.name || "Field";
8230
8244
  let i = n[r];
8231
8245
  return i === void 0 ? "" : String(i);
8232
8246
  });
8233
8247
  }
8234
- function Js(e) {
8248
+ function Ys(e) {
8235
8249
  if (e === void 0 || e === "") return;
8236
8250
  let t = Number(e);
8237
8251
  return Number.isFinite(t) ? t : void 0;
8238
8252
  }
8239
- function Ys(e, t, n = {}) {
8240
- let r = Xs(e, t, n);
8253
+ function Xs(e, t, n = {}) {
8254
+ let r = Zs(e, t, n);
8241
8255
  if (r.length === 0 || !t.errorMessage) return r;
8242
8256
  let [i] = r, a = i.rule === "required" ? t.requiredMessage : i.rule === "pattern" ? t.patternMessage : void 0;
8243
8257
  return [{
@@ -8245,17 +8259,17 @@ function Ys(e, t, n = {}) {
8245
8259
  message: a || t.errorMessage
8246
8260
  }];
8247
8261
  }
8248
- function Xs(e, t, n) {
8262
+ function Zs(e, t, n) {
8249
8263
  let r = {
8250
- ...Hs,
8264
+ ...Us,
8251
8265
  ...n
8252
8266
  }, i = (e, n) => ({
8253
8267
  rule: e,
8254
- message: qs(r[e], t, n)
8268
+ message: Js(r[e], t, n)
8255
8269
  });
8256
- if (Ks(e)) return t.required ? [{
8270
+ if (qs(e)) return t.required ? [{
8257
8271
  rule: "required",
8258
- message: t.requiredMessage || qs(r.required, t)
8272
+ message: t.requiredMessage || Js(r.required, t)
8259
8273
  }] : [];
8260
8274
  let a = t.validation ?? {}, o = [], s = Array.isArray(e) ? "" : String(e);
8261
8275
  switch (t.type) {
@@ -8263,12 +8277,12 @@ function Xs(e, t, n) {
8263
8277
  case "range": {
8264
8278
  let t = typeof e == "number" ? e : Number(s.trim());
8265
8279
  if (!Number.isFinite(t)) return [i("number")];
8266
- let n = Js(a.min), r = Js(a.max);
8280
+ let n = Ys(a.min), r = Ys(a.max);
8267
8281
  n !== void 0 && t < n && o.push(i("min", { min: n })), r !== void 0 && t > r && o.push(i("max", { max: r }));
8268
8282
  break;
8269
8283
  }
8270
8284
  case "email":
8271
- if (!Us.test(s)) return [i("email")];
8285
+ if (!Ws.test(s)) return [i("email")];
8272
8286
  break;
8273
8287
  case "url":
8274
8288
  try {
@@ -8278,11 +8292,11 @@ function Xs(e, t, n) {
8278
8292
  }
8279
8293
  break;
8280
8294
  case "tel":
8281
- if (!Ws.test(s)) return [i("tel")];
8295
+ if (!Gs.test(s)) return [i("tel")];
8282
8296
  break;
8283
8297
  case "date": {
8284
- if (!Gs.test(s) || Number.isNaN(Date.parse(s))) return [i("date")];
8285
- let e = typeof a.min == "string" && Gs.test(a.min) ? a.min : void 0, t = typeof a.max == "string" && Gs.test(a.max) ? a.max : void 0;
8298
+ if (!Ks.test(s) || Number.isNaN(Date.parse(s))) return [i("date")];
8299
+ let e = typeof a.min == "string" && Ks.test(a.min) ? a.min : void 0, t = typeof a.max == "string" && Ks.test(a.max) ? a.max : void 0;
8286
8300
  e !== void 0 && s < e && o.push(i("dateMin", { min: e })), t !== void 0 && s > t && o.push(i("dateMax", { max: t }));
8287
8301
  break;
8288
8302
  }
@@ -8291,14 +8305,14 @@ function Xs(e, t, n) {
8291
8305
  let n = [...e].length;
8292
8306
  a.minlength !== void 0 && n < a.minlength && o.push(i("minLength", { min: a.minlength })), a.maxlength !== void 0 && n > a.maxlength && o.push(i("maxLength", { max: a.maxlength }));
8293
8307
  let s = t.pattern ?? a.pattern;
8294
- s && !Zs(s, e) && o.push({
8308
+ s && !Qs(s, e) && o.push({
8295
8309
  rule: "pattern",
8296
- message: t.patternMessage || qs(r.pattern, t)
8310
+ message: t.patternMessage || Js(r.pattern, t)
8297
8311
  });
8298
8312
  }
8299
8313
  return o;
8300
8314
  }
8301
- function Zs(e, t) {
8315
+ function Qs(e, t) {
8302
8316
  try {
8303
8317
  return RegExp(`^(?:${e})$`, "v").test(t);
8304
8318
  } catch {
@@ -8310,19 +8324,19 @@ function Zs(e, t) {
8310
8324
  }
8311
8325
  }
8312
8326
  // node_modules/@formdown/core/dist/validate.js
8313
- function Qs(e, t, n = {}) {
8327
+ function $s(e, t, n = {}) {
8314
8328
  let r = t.name || "field";
8315
- return Ys(e, t, n.messages).map(({ message: e }) => ({
8329
+ return Xs(e, t, n.messages).map(({ message: e }) => ({
8316
8330
  field: r,
8317
8331
  message: e
8318
8332
  }));
8319
8333
  }
8320
- function $s(e, t, n = {}) {
8334
+ function ec(e, t, n = {}) {
8321
8335
  let r = [];
8322
8336
  return Object.entries(t).forEach(([t, i]) => {
8323
8337
  let a = Vs(i.conditions, e);
8324
8338
  if (a.visible && a.enabled) {
8325
- r.push(...Qs(e[t], {
8339
+ r.push(...$s(e[t], {
8326
8340
  ...i,
8327
8341
  name: t,
8328
8342
  required: i.required || a.required
@@ -8341,7 +8355,7 @@ function $s(e, t, n = {}) {
8341
8355
  };
8342
8356
  }
8343
8357
  // node_modules/@formdown/core/dist/form-data-binding.js
8344
- var ec = class {
8358
+ var tc = class {
8345
8359
  constructor(e = null, t = {}) {
8346
8360
  this.schema = e, this.data = {}, this.changeListeners = /* @__PURE__ */ new Set(), this.fieldChangeListeners = /* @__PURE__ */ new Set(), this.validationListeners = /* @__PURE__ */ new Set(), this.isUpdating = !1, this.initializeFromSchema(), this.updateInternal(t, !1);
8347
8361
  }
@@ -8389,7 +8403,7 @@ var ec = class {
8389
8403
  }
8390
8404
  validateField(e, t, n) {
8391
8405
  if (!this.schema || !this.schema[e]) return [];
8392
- let r = Qs(t === void 0 ? this.get(e) : t, {
8406
+ let r = $s(t === void 0 ? this.get(e) : t, {
8393
8407
  ...this.schema[e],
8394
8408
  name: e
8395
8409
  }, n);
@@ -8400,7 +8414,7 @@ var ec = class {
8400
8414
  isValid: !0,
8401
8415
  errors: []
8402
8416
  };
8403
- let t = $s(this.getAll(), this.schema, e), n = /* @__PURE__ */ new Map();
8417
+ let t = ec(this.getAll(), this.schema, e), n = /* @__PURE__ */ new Map();
8404
8418
  return t.errors.forEach((e) => {
8405
8419
  n.has(e.field) || n.set(e.field, []), n.get(e.field).push(e);
8406
8420
  }), n.forEach((e, t) => {
@@ -8499,7 +8513,7 @@ var ec = class {
8499
8513
  }
8500
8514
  });
8501
8515
  }
8502
- }, tc = class {
8516
+ }, nc = class {
8503
8517
  processCheckboxGroup(e, t) {
8504
8518
  try {
8505
8519
  let n = t.querySelectorAll(`input[type="checkbox"][name="${e}"]`);
@@ -8584,7 +8598,7 @@ var ec = class {
8584
8598
  case "datetime-local":
8585
8599
  case "month":
8586
8600
  case "week": return e.value || "";
8587
- case "file": return e.value && e.value.split("\\").pop() || "";
8601
+ case "file": return "";
8588
8602
  default: return e.value || "";
8589
8603
  }
8590
8604
  }
@@ -8672,7 +8686,7 @@ var ec = class {
8672
8686
  }
8673
8687
  }
8674
8688
  validateFieldValue(e, t, n) {
8675
- let r = Ys(e, {
8689
+ let r = Xs(e, {
8676
8690
  type: t,
8677
8691
  required: n?.required,
8678
8692
  pattern: n?.pattern,
@@ -8717,9 +8731,9 @@ var ec = class {
8717
8731
  default: return "text";
8718
8732
  }
8719
8733
  }
8720
- }, nc = class {
8734
+ }, rc = class {
8721
8735
  constructor() {
8722
- this.fieldRegistry = {}, this.syncLock = !1, this.fieldProcessor = new tc();
8736
+ this.fieldRegistry = {}, this.syncLock = !1, this.fieldProcessor = new nc();
8723
8737
  }
8724
8738
  bindFieldToElement(e, t) {
8725
8739
  return this.fieldRegistry[e] || (this.fieldRegistry[e] = /* @__PURE__ */ new Set()), this.fieldRegistry[e].add(t), {
@@ -8798,7 +8812,7 @@ var ec = class {
8798
8812
  }
8799
8813
  }), n;
8800
8814
  }
8801
- }, rc = class {
8815
+ }, ic = class {
8802
8816
  constructor() {
8803
8817
  this.customValidators = /* @__PURE__ */ new Map(), this.validationCache = /* @__PURE__ */ new Map(), this.asyncValidationTimers = /* @__PURE__ */ new Map();
8804
8818
  }
@@ -8881,7 +8895,7 @@ var ec = class {
8881
8895
  if (t.push({
8882
8896
  name: "constraints",
8883
8897
  validator: (t) => {
8884
- let n = Ys(t, {
8898
+ let n = Xs(t, {
8885
8899
  name: e.fieldName,
8886
8900
  type: e.fieldType,
8887
8901
  label: typeof e.schema.label == "string" ? e.schema.label : void 0,
@@ -9010,7 +9024,7 @@ var ec = class {
9010
9024
  EXTENSION_ERROR: "formdown:extension:error",
9011
9025
  SCHEMA_CHANGE: "formdown:schema:change",
9012
9026
  SCHEMA_VALIDATED: "formdown:schema:validated"
9013
- }, ic = class {
9027
+ }, ac = class {
9014
9028
  constructor(e = {}) {
9015
9029
  this.eventBuses = /* @__PURE__ */ new Map(), this.eventBridges = /* @__PURE__ */ new Map(), this.globalEventConfig = {
9016
9030
  enableFormEvents: !0,
@@ -9198,7 +9212,7 @@ var ec = class {
9198
9212
  activeBridges: this.getActiveBridges().length
9199
9213
  };
9200
9214
  }
9201
- }, ac = class e {
9215
+ }, oc = class e {
9202
9216
  constructor(e = {}) {
9203
9217
  this.options = e, this.content = "", this.parsedContent = null, this.schema = null, this.dataBinding = null, this.eventListeners = /* @__PURE__ */ new Map(), this._pendingDefaults = null, this.fieldProcessor = null, this.domBinder = null, this.validationManager = null, this.eventOrchestrator = null, this.parser = new on({
9204
9218
  frontMatter: Is,
@@ -9208,7 +9222,7 @@ var ec = class {
9208
9222
  });
9209
9223
  }
9210
9224
  parse(e) {
9211
- return this.content = e, this.parsedContent = this.parser.parseFormdown(e), this.schema = Rs(this.parsedContent), this.dataBinding = new ec(this.schema), this._pendingDefaults &&= (this.dataBinding.applyDefaults(this._pendingDefaults.defaults, this._pendingDefaults.options), null), this.setupDataBindingEvents(), this.parsedContent;
9225
+ return this.content = e, this.parsedContent = this.parser.parseFormdown(e), this.schema = Rs(this.parsedContent), this.dataBinding = new tc(this.schema), this._pendingDefaults &&= (this.dataBinding.applyDefaults(this._pendingDefaults.defaults, this._pendingDefaults.options), null), this.setupDataBindingEvents(), this.parsedContent;
9212
9226
  }
9213
9227
  render(e = {}) {
9214
9228
  if (!this.parsedContent) throw Error("No content parsed. Call parse() first.");
@@ -9220,6 +9234,9 @@ var ec = class {
9220
9234
  getData() {
9221
9235
  return this.dataBinding ? this.dataBinding.getAll() : {};
9222
9236
  }
9237
+ getConditionStates() {
9238
+ return this.schema ? Hs(this.schema, this.getData()) : {};
9239
+ }
9223
9240
  setFieldValue(e, t) {
9224
9241
  this.dataBinding && this.dataBinding.set(e, t);
9225
9242
  }
@@ -9323,16 +9340,16 @@ var ec = class {
9323
9340
  })), this.parse(e.content), e.data && this.updateData(e.data);
9324
9341
  }
9325
9342
  createFieldProcessor() {
9326
- return this.fieldProcessor ||= new tc(), this.fieldProcessor;
9343
+ return this.fieldProcessor ||= new nc(), this.fieldProcessor;
9327
9344
  }
9328
9345
  createDOMBinder() {
9329
- return this.domBinder ||= new nc(), this.domBinder;
9346
+ return this.domBinder ||= new rc(), this.domBinder;
9330
9347
  }
9331
9348
  createValidationManager() {
9332
- return this.validationManager ||= new rc(), this.validationManager;
9349
+ return this.validationManager ||= new ic(), this.validationManager;
9333
9350
  }
9334
9351
  createEventOrchestrator() {
9335
- return this.eventOrchestrator ||= new ic(), this.eventOrchestrator;
9352
+ return this.eventOrchestrator ||= new ac(), this.eventOrchestrator;
9336
9353
  }
9337
9354
  processFieldValue(e, t) {
9338
9355
  let n = this.createFieldProcessor(), r = this.getField(e);
@@ -9401,7 +9418,9 @@ var ec = class {
9401
9418
  t ||= this.createDOMBinder();
9402
9419
  let n = e.target, r = n?.name || n?.id;
9403
9420
  if (r && e.type === "change") {
9404
- let e = this.createFieldProcessor(), t = e.getFieldType(n), i = e.extractFieldValue(n, t);
9421
+ let e = this.createFieldProcessor(), t = e.getFieldType(n);
9422
+ if (t === "file") return;
9423
+ let i = e.extractFieldValue(n, t);
9405
9424
  this.setFieldValue(r, i);
9406
9425
  }
9407
9426
  }
@@ -9440,36 +9459,36 @@ var ec = class {
9440
9459
  }
9441
9460
  };
9442
9461
  // node_modules/@formdown/ui/dist/index.es.js
9443
- function oc(e) {
9444
- return e.localName.includes("-") ? customElements.get(e.localName) : void 0;
9445
- }
9446
9462
  function sc(e) {
9447
- return e.hasAttribute("name") && oc(e)?.formAssociated === !0;
9463
+ return e.localName.includes("-") ? customElements.get(e.localName) : void 0;
9448
9464
  }
9449
9465
  function cc(e) {
9450
- return Array.from(e.querySelectorAll("[name]")).filter((e) => sc(e));
9466
+ return e.hasAttribute("name") && sc(e)?.formAssociated === !0;
9451
9467
  }
9452
9468
  function lc(e) {
9469
+ return Array.from(e.querySelectorAll("[name]")).filter((e) => cc(e));
9470
+ }
9471
+ function uc(e) {
9453
9472
  let t = Array.from(e.querySelectorAll("[name]")).filter((e) => e.localName.includes("-") && !customElements.get(e.localName)).map((e) => e.localName);
9454
9473
  return [...new Set(t)];
9455
9474
  }
9456
- function uc(e) {
9475
+ function dc(e) {
9457
9476
  let t = e.value;
9458
9477
  return t == null ? "" : typeof t == "boolean" || typeof t == "string" ? t : Array.isArray(t) ? t.map(String) : String(t);
9459
9478
  }
9460
- function dc(e, t) {
9479
+ function fc(e, t) {
9461
9480
  e.value = t ?? "";
9462
9481
  }
9463
- function fc(e, t, n) {
9482
+ function pc(e, t, n) {
9464
9483
  e.toggleAttribute("disabled", !t), e.toggleAttribute("required", n);
9465
9484
  }
9466
- function pc(e) {
9485
+ function mc(e) {
9467
9486
  return e === !0 || typeof e == "string" && e.toLowerCase() === "true";
9468
9487
  }
9469
- function mc(e, t, n) {
9470
- sc(e) ? dc(e, t) : e instanceof HTMLInputElement ? n === "checkbox" || e.type === "checkbox" ? e.checked = Array.isArray(t) ? t.map(String).includes(e.value) : e.value === "true" ? pc(t) : t != null && String(t) === e.value : n === "radio" || e.type === "radio" ? e.checked = t != null && e.value === String(t) : e.value = String(t ?? "") : e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.hasAttribute("contenteditable") && (e.textContent = String(t ?? ""));
9488
+ function hc(e, t, n) {
9489
+ cc(e) ? fc(e, t) : e instanceof HTMLInputElement ? n === "checkbox" || e.type === "checkbox" ? e.checked = Array.isArray(t) ? t.map(String).includes(e.value) : e.value === "true" ? mc(t) : t != null && String(t) === e.value : n === "radio" || e.type === "radio" ? e.checked = t != null && e.value === String(t) : e.value = String(t ?? "") : e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.hasAttribute("contenteditable") && (e.textContent = String(t ?? ""));
9471
9490
  }
9472
- function hc(e, t) {
9491
+ function gc(e, t) {
9473
9492
  let n = [];
9474
9493
  for (let [r, i] of Object.entries(t)) {
9475
9494
  let t = (Array.isArray(i) ? i : [i]).filter((e) => e != null && typeof e != "boolean").map(String).filter((e) => e !== "");
@@ -9499,7 +9518,7 @@ function hc(e, t) {
9499
9518
  }
9500
9519
  return n;
9501
9520
  }
9502
- var gc = /* @__PURE__ */ new Set([
9521
+ var _c = /* @__PURE__ */ new Set([
9503
9522
  "date",
9504
9523
  "time",
9505
9524
  "datetime-local",
@@ -9508,43 +9527,43 @@ var gc = /* @__PURE__ */ new Set([
9508
9527
  "number",
9509
9528
  "range",
9510
9529
  "color"
9511
- ]), _c = "data-formdown-unread", vc = "formdown-unread";
9512
- function yc(e, t) {
9530
+ ]), vc = "data-formdown-unread", yc = "formdown-unread";
9531
+ function bc(e, t) {
9513
9532
  return e.type === "color" ? e.value === t.toLowerCase() : e.value === t;
9514
9533
  }
9515
- function bc(e, t, n) {
9534
+ function xc(e, t, n) {
9516
9535
  let r = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((e) => e && e !== t);
9517
9536
  n && r.push(t), r.length > 0 ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby");
9518
9537
  }
9519
- function xc(e, t) {
9538
+ function Sc(e, t) {
9520
9539
  for (let n of Array.from(e.querySelectorAll("input"))) {
9521
- if (!gc.has(n.type)) continue;
9522
- let e = t[n.name], r = typeof e == "string" || typeof e == "number" ? String(e) : "", i = r !== "" && !yc(n, r), a = `${n.id || n.name}_unread`, o = n.nextElementSibling?.classList.contains(vc) ? n.nextElementSibling : null;
9540
+ if (!_c.has(n.type)) continue;
9541
+ let e = t[n.name], r = typeof e == "string" || typeof e == "number" ? String(e) : "", i = r !== "" && !bc(n, r), a = `${n.id || n.name}_unread`, o = n.nextElementSibling?.classList.contains(yc) ? n.nextElementSibling : null;
9523
9542
  if (!i) {
9524
- o && o.remove(), n.hasAttribute(_c) && (n.removeAttribute(_c), bc(n, a, !1));
9543
+ o && o.remove(), n.hasAttribute(vc) && (n.removeAttribute(vc), xc(n, a, !1));
9525
9544
  continue;
9526
9545
  }
9527
- n.setAttribute(_c, "true");
9546
+ n.setAttribute(vc, "true");
9528
9547
  let s = o ?? n.ownerDocument.createElement("span");
9529
- s.className = vc, s.id = a, s.setAttribute("part", "unread-value"), s.setAttribute(_c, n.name), s.textContent = r, o || n.after(s), bc(n, a, !0);
9548
+ s.className = yc, s.id = a, s.setAttribute("part", "unread-value"), s.setAttribute(vc, n.name), s.textContent = r, o || n.after(s), xc(n, a, !0);
9530
9549
  }
9531
9550
  }
9532
- var Sc = "data-formdown-choice", Cc = "data-formdown-unlisted", wc = (e) => e.label ?? e.value;
9533
- function Tc(e, t) {
9551
+ var Cc = "data-formdown-choice", wc = "data-formdown-unlisted", Tc = (e) => e.label ?? e.value;
9552
+ function Ec(e, t) {
9534
9553
  let n = [];
9535
9554
  for (let n of Array.from(e.querySelectorAll("select"))) {
9536
9555
  if (n.hasAttribute("data-formdown-has-other")) continue;
9537
9556
  let e = t[n.name] ?? [];
9538
- for (let t of Array.from(n.options)) t.hasAttribute(Sc) && !e.some((e) => e.value === t.value) && t.remove();
9557
+ for (let t of Array.from(n.options)) t.hasAttribute(Cc) && !e.some((e) => e.value === t.value) && t.remove();
9539
9558
  for (let t of e) {
9540
9559
  let e = Array.from(n.options).find((e) => e.value === t.value);
9541
9560
  if (e) {
9542
- (e.hasAttribute(Cc) || e.hasAttribute(Sc)) && Ec(e, t);
9561
+ (e.hasAttribute(wc) || e.hasAttribute(Cc)) && Dc(e, t);
9543
9562
  continue;
9544
9563
  }
9545
9564
  let r = n.ownerDocument.createElement("option");
9546
- r.value = t.value, Ec(r, t);
9547
- let i = Array.from(n.options).find((e) => e.hasAttribute(Cc));
9565
+ r.value = t.value, Dc(r, t);
9566
+ let i = Array.from(n.options).find((e) => e.hasAttribute(wc));
9548
9567
  n.insertBefore(r, i ?? null);
9549
9568
  }
9550
9569
  }
@@ -9552,21 +9571,21 @@ function Tc(e, t) {
9552
9571
  for (let t of Array.from(e.querySelectorAll("input[type=\"radio\"], input[type=\"checkbox\"]"))) r.set(t.name, [...r.get(t.name) ?? [], t]);
9553
9572
  for (let [e, i] of r) {
9554
9573
  if (i.every((e) => e.type === "checkbox" && e.value === "true") || i.some((e) => e.hasAttribute("data-formdown-other-radio") || e.hasAttribute("data-formdown-other-checkbox"))) continue;
9555
- let r = t[e] ?? [], a = i.filter((e) => e.hasAttribute(Sc) && !r.some((t) => t.value === e.value)), o = [...i];
9574
+ let r = t[e] ?? [], a = i.filter((e) => e.hasAttribute(Cc) && !r.some((t) => t.value === e.value)), o = [...i];
9556
9575
  for (let t of r) {
9557
9576
  let r = o.find((e) => e.value === t.value);
9558
9577
  if (r) {
9559
- if (r.hasAttribute(Cc) || r.hasAttribute(Sc)) {
9560
- r.removeAttribute(Cc), r.setAttribute(Sc, "true");
9578
+ if (r.hasAttribute(wc) || r.hasAttribute(Cc)) {
9579
+ r.removeAttribute(wc), r.setAttribute(Cc, "true");
9561
9580
  let e = r.closest("label")?.querySelector("span");
9562
- e && (e.textContent = wc(t));
9581
+ e && (e.textContent = Tc(t));
9563
9582
  }
9564
9583
  continue;
9565
9584
  }
9566
- let i = o.filter((e) => !e.hasAttribute(Cc)), a = i[i.length - 1] ?? o[o.length - 1], s = a.closest("label"), c = a.ownerDocument, l = c.createElement("input");
9567
- l.type = a.type, l.name = e, l.value = t.value, l.id = `${e}_choice_${n.length}_${o.length}`, l.setAttribute(Sc, "true");
9585
+ let i = o.filter((e) => !e.hasAttribute(wc)), a = i[i.length - 1] ?? o[o.length - 1], s = a.closest("label"), c = a.ownerDocument, l = c.createElement("input");
9586
+ l.type = a.type, l.name = e, l.value = t.value, l.id = `${e}_choice_${n.length}_${o.length}`, l.setAttribute(Cc, "true");
9568
9587
  let u = c.createElement("span");
9569
- u.textContent = wc(t);
9588
+ u.textContent = Tc(t);
9570
9589
  let d = c.createElement("label");
9571
9590
  d.className = s?.className || "formdown-option-label", d.setAttribute("part", s?.getAttribute("part") || "option-label"), d.htmlFor = l.id, d.append(l, u), (s ?? a).after(d), o.splice(o.indexOf(a) + 1, 0, l), n.push(l);
9572
9591
  }
@@ -9592,25 +9611,25 @@ function Tc(e, t) {
9592
9611
  let o = a ?? n.ownerDocument.createElement("datalist");
9593
9612
  o.id = r, o.replaceChildren(...i.map((e) => {
9594
9613
  let t = n.ownerDocument.createElement("option");
9595
- return t.value = e.value, t.label = wc(e), t;
9614
+ return t.value = e.value, t.label = Tc(e), t;
9596
9615
  })), a || n.after(o), n.setAttribute("list", r);
9597
9616
  }
9598
9617
  return n;
9599
9618
  }
9600
- function Ec(e, t) {
9601
- e.removeAttribute(Cc), e.setAttribute(Sc, "true"), e.textContent = wc(t);
9619
+ function Dc(e, t) {
9620
+ e.removeAttribute(wc), e.setAttribute(Cc, "true"), e.textContent = Tc(t);
9602
9621
  }
9603
- var Dc = "data-formdown-note", Oc = "data-formdown-value", kc = "data-formdown-placeholder", Ac = "formdown-ghost", jc = "formdown-suggested";
9604
- function Mc(e, t) {
9622
+ var Oc = "data-formdown-note", kc = "data-formdown-value", Ac = "data-formdown-placeholder", jc = "formdown-ghost", Mc = "formdown-suggested";
9623
+ function Nc(e, t) {
9605
9624
  let n = Array.from(e.querySelectorAll("[name]")).filter((e) => e.getAttribute("name") === t);
9606
9625
  if (n.length > 0) return n;
9607
9626
  let r = Array.from(e.querySelectorAll("[data-field-name]")).find((e) => e.dataset.fieldName === t);
9608
9627
  return r ? [r] : [];
9609
9628
  }
9610
- function Nc(e) {
9629
+ function Pc(e) {
9611
9630
  return e.isContentEditable || e.getAttribute("contenteditable") === "true";
9612
9631
  }
9613
- function Pc(e) {
9632
+ function Fc(e) {
9614
9633
  return e instanceof HTMLTextAreaElement || e instanceof HTMLInputElement && ![
9615
9634
  "radio",
9616
9635
  "checkbox",
@@ -9623,45 +9642,45 @@ function Pc(e) {
9623
9642
  "reset"
9624
9643
  ].includes(e.type);
9625
9644
  }
9626
- function Fc(e, t) {
9627
- e.classList.remove(t), e.classList.length === 0 && e.removeAttribute("class");
9628
- }
9629
9645
  function Ic(e, t) {
9630
- let n = Nc(e) ? "data-placeholder" : Pc(e) ? "placeholder" : null;
9631
- n && (e.hasAttribute(kc) || e.setAttribute(kc, e.getAttribute(n) ?? ""), e.setAttribute(n, t), e.classList.add(Ac));
9646
+ e.classList.remove(t), e.classList.length === 0 && e.removeAttribute("class");
9632
9647
  }
9633
9648
  function Lc(e, t) {
9649
+ let n = Pc(e) ? "data-placeholder" : Fc(e) ? "placeholder" : null;
9650
+ n && (e.hasAttribute(Ac) || e.setAttribute(Ac, e.getAttribute(n) ?? ""), e.setAttribute(n, t), e.classList.add(jc));
9651
+ }
9652
+ function Rc(e, t) {
9634
9653
  let [n] = e;
9635
9654
  return n instanceof HTMLSelectElement ? Array.from(n.options).find((e) => e.value === t)?.textContent?.trim() || t : e.find((e) => e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && e.value === t)?.closest("label")?.textContent?.trim() || t;
9636
9655
  }
9637
- function Rc(e) {
9656
+ function zc(e) {
9638
9657
  let [t] = e;
9639
9658
  if (t instanceof HTMLSelectElement) return Array.from(t.selectedOptions).map((e) => e.value).filter(Boolean);
9640
9659
  if (t instanceof HTMLInputElement && (t.type === "radio" || t.type === "checkbox")) return e.filter((e) => e instanceof HTMLInputElement && e.checked).map((e) => e.value);
9641
9660
  let n;
9642
- return n = sc(t) ? uc(t) : t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value : Nc(t) ? (t.textContent ?? "").trim() : "", (Array.isArray(n) ? n : [String(n)]).filter((e) => e !== "");
9661
+ return n = cc(t) ? dc(t) : t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value : Pc(t) ? (t.textContent ?? "").trim() : "", (Array.isArray(n) ? n : [String(n)]).filter((e) => e !== "");
9643
9662
  }
9644
- function zc(e, t) {
9663
+ function Bc(e, t) {
9645
9664
  let n = e[0].closest(".formdown-field")?.querySelector("[part~=\"label\"], [part~=\"legend\"]")?.textContent?.trim();
9646
9665
  return n ? n.replace(/\s*\*$/, "") : t;
9647
9666
  }
9648
- function Bc(e) {
9649
- for (let t of Array.from(e.querySelectorAll(`[${Dc}]`))) {
9650
- let n = Mc(e, t.getAttribute(Dc)), r = n.length > 0 ? Rc(n) : [];
9651
- for (let e of Array.from(t.querySelectorAll(`[${Oc}]`))) e.setAttribute("aria-pressed", String(r.includes(e.getAttribute(Oc))));
9667
+ function Vc(e) {
9668
+ for (let t of Array.from(e.querySelectorAll(`[${Oc}]`))) {
9669
+ let n = Nc(e, t.getAttribute(Oc)), r = n.length > 0 ? zc(n) : [];
9670
+ for (let e of Array.from(t.querySelectorAll(`[${kc}]`))) e.setAttribute("aria-pressed", String(r.includes(e.getAttribute(kc))));
9652
9671
  }
9653
9672
  }
9654
- function Vc(e, t, n, r, i, a) {
9673
+ function Hc(e, t, n, r, i, a) {
9655
9674
  let o = n.suggestions ?? [];
9656
9675
  if (!n.note && o.length === 0) return;
9657
9676
  let s = e.createElement(r ? "span" : "div");
9658
- if (s.className = "formdown-field-note", s.setAttribute("part", "field-note"), s.setAttribute(Dc, t), o.length > 0 && (s.setAttribute("role", "group"), s.setAttribute("aria-label", n.label ?? `Suggestions for ${zc(a, t)}`)), n.note) {
9677
+ if (s.className = "formdown-field-note", s.setAttribute("part", "field-note"), s.setAttribute(Oc, t), o.length > 0 && (s.setAttribute("role", "group"), s.setAttribute("aria-label", n.label ?? `Suggestions for ${Bc(a, t)}`)), n.note) {
9659
9678
  let t = e.createElement("span");
9660
9679
  t.className = "formdown-field-note-text", t.textContent = n.note, s.append(t);
9661
9680
  }
9662
9681
  for (let n of o) {
9663
9682
  let r = e.createElement("button");
9664
- r.type = "button", r.className = "formdown-suggestion", r.setAttribute("part", "suggestion"), r.setAttribute(Oc, n), r.textContent = Lc(a, n), r.addEventListener("click", () => i.onPick(t, n)), s.append(r);
9683
+ r.type = "button", r.className = "formdown-suggestion", r.setAttribute("part", "suggestion"), r.setAttribute(kc, n), r.textContent = Rc(a, n), r.addEventListener("click", () => i.onPick(t, n)), s.append(r);
9665
9684
  }
9666
9685
  if (n.decline && o.length > 0) {
9667
9686
  let r = e.createElement("button");
@@ -9669,52 +9688,52 @@ function Vc(e, t, n, r, i, a) {
9669
9688
  }
9670
9689
  return s;
9671
9690
  }
9672
- function Hc(e) {
9673
- for (let t of Array.from(e.querySelectorAll(`[${Dc}]`))) t.remove();
9674
- for (let t of Array.from(e.querySelectorAll(`[${kc}]`))) {
9675
- let e = Nc(t) ? "data-placeholder" : "placeholder", n = t.getAttribute(kc) ?? "";
9676
- n ? t.setAttribute(e, n) : t.removeAttribute(e), t.removeAttribute(kc), Fc(t, Ac);
9691
+ function Uc(e) {
9692
+ for (let t of Array.from(e.querySelectorAll(`[${Oc}]`))) t.remove();
9693
+ for (let t of Array.from(e.querySelectorAll(`[${Ac}]`))) {
9694
+ let e = Pc(t) ? "data-placeholder" : "placeholder", n = t.getAttribute(Ac) ?? "";
9695
+ n ? t.setAttribute(e, n) : t.removeAttribute(e), t.removeAttribute(Ac), Ic(t, jc);
9677
9696
  }
9678
- for (let t of Array.from(e.querySelectorAll(`.${jc}`))) Fc(t, jc);
9697
+ for (let t of Array.from(e.querySelectorAll(`.${Mc}`))) Ic(t, Mc);
9679
9698
  }
9680
- function Uc(e, t, n) {
9681
- let r = Gc(e);
9682
- Hc(e);
9699
+ function Wc(e, t, n) {
9700
+ let r = Kc(e);
9701
+ Uc(e);
9683
9702
  let i = e.ownerDocument ?? e;
9684
9703
  for (let [r, a] of Object.entries(t)) {
9685
- let t = Mc(e, r);
9704
+ let t = Nc(e, r);
9686
9705
  if (t.length === 0) continue;
9687
9706
  let [o] = t, s = a.suggestions ?? [];
9688
- s.length > 0 && Ic(o, s[0]);
9689
- for (let e of t) e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && s.includes(e.value) && e.closest("label")?.classList.add(jc);
9690
- let c = Nc(o), l = Vc(i, r, a, c, n, t);
9707
+ s.length > 0 && Lc(o, s[0]);
9708
+ for (let e of t) e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && s.includes(e.value) && e.closest("label")?.classList.add(Mc);
9709
+ let c = Pc(o), l = Hc(i, r, a, c, n, t);
9691
9710
  l && (c ? o.after(l) : (o.closest(".formdown-field") ?? o.parentElement ?? o).append(l));
9692
9711
  }
9693
- Bc(e), r !== null && Kc(e, r);
9712
+ Vc(e), r !== null && qc(e, r);
9694
9713
  }
9695
- function Wc(e) {
9714
+ function Gc(e) {
9696
9715
  let t = e.getRootNode?.();
9697
9716
  return t && "activeElement" in t ? t : null;
9698
9717
  }
9699
- function Gc(e) {
9700
- let t = Wc(e)?.activeElement;
9701
- return !t || !e.contains(t) ? null : t.closest(`[${Dc}]`)?.getAttribute(Dc) ?? null;
9718
+ function Kc(e) {
9719
+ let t = Gc(e)?.activeElement;
9720
+ return !t || !e.contains(t) ? null : t.closest(`[${Oc}]`)?.getAttribute(Oc) ?? null;
9702
9721
  }
9703
- function Kc(e, t) {
9704
- let n = Wc(e)?.activeElement;
9722
+ function qc(e, t) {
9723
+ let n = Gc(e)?.activeElement;
9705
9724
  if (n && e.contains(n)) return;
9706
- let r = qc(e, t);
9707
- r && Qc(r);
9725
+ let r = Jc(e, t);
9726
+ r && $c(r);
9708
9727
  }
9709
- function qc(e, t) {
9710
- let n = Mc(e, t), r = n.find((e) => e instanceof HTMLInputElement && e.checked) ?? n[0];
9711
- return (r && nl(r)) ?? r;
9728
+ function Jc(e, t) {
9729
+ let n = Nc(e, t), r = n.find((e) => e instanceof HTMLInputElement && e.checked) ?? n[0];
9730
+ return (r && rl(r)) ?? r;
9712
9731
  }
9713
- function Jc(e) {
9714
- return e.closest("[hidden]") || e instanceof HTMLInputElement && e.type === "hidden" || "disabled" in e && e.disabled || sc(e) && e.hasAttribute("disabled") ? !1 : !Nc(e) || e.getAttribute("contenteditable") !== "false";
9732
+ function Yc(e) {
9733
+ return e.closest("[hidden]") || e instanceof HTMLInputElement && e.type === "hidden" || "disabled" in e && e.disabled || cc(e) && e.hasAttribute("disabled") ? !1 : !Pc(e) || e.getAttribute("contenteditable") !== "false";
9715
9734
  }
9716
- var Yc = /* @__PURE__ */ new WeakSet();
9717
- function Xc(e) {
9735
+ var Xc = /* @__PURE__ */ new WeakSet();
9736
+ function Zc(e) {
9718
9737
  if (e.isContentEditable) {
9719
9738
  let t = e.getRootNode().getSelection?.() ?? window.getSelection();
9720
9739
  if (!t) return;
@@ -9724,34 +9743,34 @@ function Xc(e) {
9724
9743
  e.setSelectionRange(e.value.length, e.value.length);
9725
9744
  } catch {}
9726
9745
  }
9727
- function Zc(e, t) {
9746
+ function Qc(e, t) {
9728
9747
  let n;
9729
- if (t !== void 0) n = qc(e, t), n && !Jc(n) && (n = void 0);
9748
+ if (t !== void 0) n = Jc(e, t), n && !Yc(n) && (n = void 0);
9730
9749
  else {
9731
- let t = Array.from(e.querySelectorAll("[name], [data-field-name]")).find(Jc), r = t?.getAttribute("name") ?? t?.dataset.fieldName;
9732
- n = r == null ? void 0 : qc(e, r);
9750
+ let t = Array.from(e.querySelectorAll("[name], [data-field-name]")).find(Yc), r = t?.getAttribute("name") ?? t?.dataset.fieldName;
9751
+ n = r == null ? void 0 : Jc(e, r);
9733
9752
  }
9734
- return n && Qc(n), !!n && Wc(e)?.activeElement === n;
9753
+ return n && $c(n), !!n && Gc(e)?.activeElement === n;
9735
9754
  }
9736
- function Qc(e) {
9737
- Yc.add(e), e.focus(), e.getRootNode().activeElement !== e && Yc.delete(e), Xc(e);
9755
+ function $c(e) {
9756
+ Xc.add(e), e.focus(), e.getRootNode().activeElement !== e && Xc.delete(e), Zc(e);
9738
9757
  }
9739
- var $c = "data-formdown-filtered", el = /* @__PURE__ */ new WeakMap(), tl = 0;
9740
- function nl(e) {
9741
- return e instanceof HTMLSelectElement ? el.get(e)?.input : void 0;
9758
+ var el = "data-formdown-filtered", tl = /* @__PURE__ */ new WeakMap(), nl = 0;
9759
+ function rl(e) {
9760
+ return e instanceof HTMLSelectElement ? tl.get(e)?.input : void 0;
9742
9761
  }
9743
- function rl(e, t) {
9762
+ function il(e, t) {
9744
9763
  for (let n of Array.from(e.querySelectorAll("select"))) {
9745
- let e = el.get(n);
9746
- !n.multiple && !n.hasAttribute("data-formdown-has-other") && il(n).length > t ? ll(e ?? sl(n)) : e && cl(e);
9764
+ let e = tl.get(n);
9765
+ !n.multiple && !n.hasAttribute("data-formdown-has-other") && al(n).length > t ? ul(e ?? cl(n)) : e && ll(e);
9747
9766
  }
9748
9767
  }
9749
- function il(e) {
9768
+ function al(e) {
9750
9769
  return Array.from(e.options).filter((e) => !e.disabled && !e.hidden);
9751
9770
  }
9752
- var al = (e) => e.label || e.textContent || e.value, ol = (e) => e.normalize("NFC").toLocaleLowerCase();
9753
- function sl(e) {
9754
- let t = e.ownerDocument, n = ++tl, r = t.createElement("span");
9771
+ var ol = (e) => e.label || e.textContent || e.value, sl = (e) => e.normalize("NFC").toLocaleLowerCase();
9772
+ function cl(e) {
9773
+ let t = e.ownerDocument, n = ++nl, r = t.createElement("span");
9755
9774
  r.className = "formdown-select-filter";
9756
9775
  let i = t.createElement("input");
9757
9776
  i.type = "text", i.className = "formdown-select-filter-input", i.id = `formdown-filter-${n}`, i.setAttribute("role", "combobox"), i.setAttribute("aria-autocomplete", "list"), i.setAttribute("aria-expanded", "false"), i.autocomplete = "off", i.spellcheck = !1;
@@ -9760,7 +9779,7 @@ function sl(e) {
9760
9779
  let o = t.createElement("ul");
9761
9780
  o.id = `formdown-filter-list-${n}`, o.className = "formdown-select-filter-list", o.setAttribute("role", "listbox"), o.hidden = !0, i.setAttribute("aria-controls", o.id);
9762
9781
  let s = e.id ? Array.from(e.getRootNode().querySelectorAll("label")).find((t) => t.htmlFor === e.id) : void 0;
9763
- s && (s.id ||= `formdown-filter-label-${n}`, i.setAttribute("aria-labelledby", s.id)), e.setAttribute($c, "true"), e.tabIndex = -1, e.setAttribute("aria-hidden", "true"), e.before(r), r.append(i, o, e);
9782
+ s && (s.id ||= `formdown-filter-label-${n}`, i.setAttribute("aria-labelledby", s.id)), e.setAttribute(el, "true"), e.tabIndex = -1, e.setAttribute("aria-hidden", "true"), e.before(r), r.append(i, o, e);
9764
9783
  let c = {
9765
9784
  select: e,
9766
9785
  wrapper: r,
@@ -9769,22 +9788,22 @@ function sl(e) {
9769
9788
  shown: [],
9770
9789
  active: -1
9771
9790
  };
9772
- el.set(e, c);
9791
+ tl.set(e, c);
9773
9792
  let l = () => i.focus();
9774
9793
  return e.addEventListener("focus", l), c.off = () => e.removeEventListener("focus", l), i.addEventListener("focus", () => {
9775
- Yc.delete(i) || setTimeout(() => i.select(), 0);
9776
- }), i.addEventListener("click", () => o.hidden ? dl(c, "") : fl(c)), i.addEventListener("input", () => dl(c, i.value)), i.addEventListener("blur", () => {
9777
- fl(c), i.value = ul(e);
9778
- }), i.addEventListener("keydown", (e) => hl(c, e)), o.addEventListener("mousedown", (e) => e.preventDefault()), o.addEventListener("click", (e) => {
9794
+ Xc.delete(i) || setTimeout(() => i.select(), 0);
9795
+ }), i.addEventListener("click", () => o.hidden ? fl(c, "") : pl(c)), i.addEventListener("input", () => fl(c, i.value)), i.addEventListener("blur", () => {
9796
+ pl(c), i.value = dl(e);
9797
+ }), i.addEventListener("keydown", (e) => gl(c, e)), o.addEventListener("mousedown", (e) => e.preventDefault()), o.addEventListener("click", (e) => {
9779
9798
  let t = e.target.closest("[role=\"option\"]");
9780
- t && ml(c, c.shown[Number(t.getAttribute("data-index"))]);
9799
+ t && hl(c, c.shown[Number(t.getAttribute("data-index"))]);
9781
9800
  }), c;
9782
9801
  }
9783
- function cl(e) {
9802
+ function ll(e) {
9784
9803
  let { select: t, wrapper: n } = e;
9785
- e.off?.(), t.removeAttribute($c), t.removeAttribute("tabindex"), t.removeAttribute("aria-hidden"), n.before(t), n.remove(), el.delete(t);
9804
+ e.off?.(), t.removeAttribute(el), t.removeAttribute("tabindex"), t.removeAttribute("aria-hidden"), n.before(t), n.remove(), tl.delete(t);
9786
9805
  }
9787
- function ll(e) {
9806
+ function ul(e) {
9788
9807
  let { select: t, input: n } = e;
9789
9808
  n.disabled = t.disabled, n.required = t.required;
9790
9809
  for (let e of [
@@ -9796,27 +9815,27 @@ function ll(e) {
9796
9815
  let r = t.getAttribute(e);
9797
9816
  r === null ? n.removeAttribute(e) : n.setAttribute(e, r);
9798
9817
  }
9799
- t.ownerDocument && n.getRootNode().activeElement !== n && (n.value = ul(t)), e.list.hidden || dl(e, n.value === ul(t) ? "" : n.value);
9818
+ t.ownerDocument && n.getRootNode().activeElement !== n && (n.value = dl(t)), e.list.hidden || fl(e, n.value === dl(t) ? "" : n.value);
9800
9819
  }
9801
- function ul(e) {
9820
+ function dl(e) {
9802
9821
  let t = e.selectedIndex >= 0 ? e.options[e.selectedIndex] : void 0;
9803
- return t ? al(t) : "";
9822
+ return t ? ol(t) : "";
9804
9823
  }
9805
- function dl(e, t) {
9806
- let { select: n, input: r, list: i } = e, a = ol(t.trim());
9807
- e.shown = il(n).filter((e) => !a || ol(al(e)).includes(a));
9824
+ function fl(e, t) {
9825
+ let { select: n, input: r, list: i } = e, a = sl(t.trim());
9826
+ e.shown = al(n).filter((e) => !a || sl(ol(e)).includes(a));
9808
9827
  let o = n.ownerDocument;
9809
9828
  i.replaceChildren(...e.shown.map((e, t) => {
9810
9829
  let n = o.createElement("li");
9811
- return n.id = `${i.id}-${t}`, n.setAttribute("role", "option"), n.setAttribute("data-index", String(t)), n.setAttribute("aria-selected", String(e.selected)), n.textContent = al(e), n;
9830
+ return n.id = `${i.id}-${t}`, n.setAttribute("role", "option"), n.setAttribute("data-index", String(t)), n.setAttribute("aria-selected", String(e.selected)), n.textContent = ol(e), n;
9812
9831
  })), i.hidden = e.shown.length === 0, r.setAttribute("aria-expanded", String(!i.hidden));
9813
9832
  let s = e.shown.findIndex((e) => e.selected);
9814
- pl(e, a ? e.shown.length ? 0 : -1 : s);
9833
+ ml(e, a ? e.shown.length ? 0 : -1 : s);
9815
9834
  }
9816
- function fl(e) {
9835
+ function pl(e) {
9817
9836
  e.list.hidden = !0, e.list.replaceChildren(), e.shown = [], e.active = -1, e.input.setAttribute("aria-expanded", "false"), e.input.removeAttribute("aria-activedescendant");
9818
9837
  }
9819
- function pl(e, t) {
9838
+ function ml(e, t) {
9820
9839
  let n = e.list.children;
9821
9840
  if (e.active >= 0 && n[e.active]?.classList.remove("active"), e.active = t, t < 0) {
9822
9841
  e.input.removeAttribute("aria-activedescendant");
@@ -9825,47 +9844,47 @@ function pl(e, t) {
9825
9844
  let r = n[t];
9826
9845
  r && (r.classList.add("active"), e.input.setAttribute("aria-activedescendant", r.id), r.scrollIntoView?.({ block: "nearest" }));
9827
9846
  }
9828
- function ml(e, t) {
9847
+ function hl(e, t) {
9829
9848
  let { select: n, input: r } = e;
9830
9849
  if (!t) return;
9831
9850
  let i = n.value !== t.value;
9832
- n.value = t.value, r.value = al(t), fl(e), i && (n.dispatchEvent(new Event("input", {
9851
+ n.value = t.value, r.value = ol(t), pl(e), i && (n.dispatchEvent(new Event("input", {
9833
9852
  bubbles: !0,
9834
9853
  composed: !0
9835
9854
  })), n.dispatchEvent(new Event("change", { bubbles: !0 })));
9836
9855
  }
9837
- function hl(e, t) {
9856
+ function gl(e, t) {
9838
9857
  if (t.isComposing) return;
9839
9858
  let n = !e.list.hidden;
9840
9859
  switch (t.key) {
9841
9860
  case "ArrowDown":
9842
- t.preventDefault(), n ? e.shown.length && pl(e, Math.min(e.active + 1, e.shown.length - 1)) : dl(e, "");
9861
+ t.preventDefault(), n ? e.shown.length && ml(e, Math.min(e.active + 1, e.shown.length - 1)) : fl(e, "");
9843
9862
  break;
9844
9863
  case "ArrowUp":
9845
- t.preventDefault(), n ? e.shown.length && pl(e, Math.max(e.active - 1, 0)) : dl(e, "");
9864
+ t.preventDefault(), n ? e.shown.length && ml(e, Math.max(e.active - 1, 0)) : fl(e, "");
9846
9865
  break;
9847
9866
  case "Enter":
9848
- n && (t.preventDefault(), t.stopImmediatePropagation(), e.active >= 0 ? ml(e, e.shown[e.active]) : fl(e));
9867
+ n && (t.preventDefault(), t.stopImmediatePropagation(), e.active >= 0 ? hl(e, e.shown[e.active]) : pl(e));
9849
9868
  break;
9850
9869
  case "Escape":
9851
- n && (t.preventDefault(), t.stopPropagation(), fl(e)), e.input.value = ul(e.select), e.input.select();
9870
+ n && (t.preventDefault(), t.stopPropagation(), pl(e)), e.input.value = dl(e.select), e.input.select();
9852
9871
  break;
9853
- case "Tab": n && fl(e);
9872
+ case "Tab": n && pl(e);
9854
9873
  }
9855
9874
  }
9856
- function gl(e, t, n) {
9875
+ function _l(e, t, n) {
9857
9876
  for (let [r, i] of Object.entries(t)) {
9858
9877
  if (!i.conditions) continue;
9859
- let t = Vs(i.conditions, n), a = Array.from(e.querySelectorAll("input, select, textarea, [data-field-name]")).concat(cc(e)).filter((e) => (e.getAttribute("name") ?? e.getAttribute("data-field-name")) === r);
9878
+ let t = Vs(i.conditions, n), a = Array.from(e.querySelectorAll("input, select, textarea, [data-field-name]")).concat(lc(e)).filter((e) => (e.getAttribute("name") ?? e.getAttribute("data-field-name")) === r);
9860
9879
  for (let e of a) {
9861
9880
  let n = e.closest(".formdown-field") ?? e;
9862
9881
  n.hidden = !t.visible;
9863
9882
  let r = !!i.required || t.required;
9864
- e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? (e.disabled = !t.enabled, e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") || (e.required = r)) : sc(e) ? fc(e, t.enabled, r) : e.setAttribute("contenteditable", t.enabled ? "true" : "false"), e.setAttribute("aria-disabled", String(!t.enabled)), e.setAttribute("aria-required", String(r));
9883
+ e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? (e.disabled = !t.enabled, e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") || (e.required = r)) : cc(e) ? pc(e, t.enabled, r) : e.setAttribute("contenteditable", t.enabled ? "true" : "false"), e.setAttribute("aria-disabled", String(!t.enabled)), e.setAttribute("aria-required", String(r));
9865
9884
  }
9866
9885
  }
9867
9886
  }
9868
- function _l(e) {
9887
+ function vl(e) {
9869
9888
  let t = /* @__PURE__ */ new Map();
9870
9889
  for (let [n, r] of Object.entries(e ?? {})) {
9871
9890
  if (!r.compute) continue;
@@ -9874,7 +9893,7 @@ function _l(e) {
9874
9893
  }
9875
9894
  return t;
9876
9895
  }
9877
- function vl(e, t) {
9896
+ function yl(e, t) {
9878
9897
  let n = { ...t }, r = {};
9879
9898
  for (let [t, i] of e) {
9880
9899
  let e = i.evaluate(n), a = e === void 0 ? "" : String(e);
@@ -9882,7 +9901,7 @@ function vl(e, t) {
9882
9901
  }
9883
9902
  return r;
9884
9903
  }
9885
- var yl = h`
9904
+ var bl = h`
9886
9905
  :host {
9887
9906
  display: block;
9888
9907
  font-family: var(--formdown-font-family, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
@@ -10714,11 +10733,11 @@ var yl = h`
10714
10733
  }
10715
10734
  }
10716
10735
  `;
10717
- function bl(e) {
10736
+ function xl(e) {
10718
10737
  let t = [...new Set(Object.values(e ?? {}).map((e) => e.type))];
10719
10738
  return j().getFieldTypeRegistry().getStylesForTypes(t);
10720
10739
  }
10721
- var xl = class {
10740
+ var Sl = class {
10722
10741
  constructor(e) {
10723
10742
  this.css = "", this.root = e;
10724
10743
  }
@@ -10734,17 +10753,17 @@ var xl = class {
10734
10753
  adoptable() {
10735
10754
  return "adoptedStyleSheets" in this.root && typeof CSSStyleSheet < "u" && "replaceSync" in CSSStyleSheet.prototype;
10736
10755
  }
10737
- }, Sl = "data-formdown-error-for", Cl = "data-formdown-described-by", wl = "field-error";
10738
- function Tl(e, t) {
10756
+ }, Cl = "data-formdown-error-for", wl = "data-formdown-described-by", Tl = "field-error";
10757
+ function El(e, t) {
10739
10758
  let n = Array.from(e.querySelectorAll("[name]")).filter((e) => e.getAttribute("name") === t);
10740
10759
  if (n.length > 0) return n;
10741
10760
  let r = Array.from(e.querySelectorAll("[data-field-name]")).find((e) => e.dataset.fieldName === t);
10742
10761
  return r ? [r] : [];
10743
10762
  }
10744
- function El(e) {
10763
+ function Dl(e) {
10745
10764
  return e.isContentEditable || e.getAttribute("contenteditable") === "true";
10746
10765
  }
10747
- function Dl(e) {
10766
+ function Ol(e) {
10748
10767
  let t = /* @__PURE__ */ new Map();
10749
10768
  for (let { field: n, message: r } of e) {
10750
10769
  let e = t.get(n) ?? [];
@@ -10752,37 +10771,37 @@ function Dl(e) {
10752
10771
  }
10753
10772
  return t;
10754
10773
  }
10755
- function Ol(e, t) {
10756
- for (let n of Array.from(e.querySelectorAll(`[${Sl}]`))) (t === void 0 || n.getAttribute(Sl) === t) && n.remove();
10757
- let n = Array.from(e.querySelectorAll(`[${Cl}]`));
10774
+ function kl(e, t) {
10775
+ for (let n of Array.from(e.querySelectorAll(`[${Cl}]`))) (t === void 0 || n.getAttribute(Cl) === t) && n.remove();
10776
+ let n = Array.from(e.querySelectorAll(`[${wl}]`));
10758
10777
  for (let e of n) {
10759
10778
  if (t !== void 0 && (e.getAttribute("name") ?? e.dataset.fieldName) !== t) continue;
10760
- let n = e.getAttribute(Cl);
10761
- n ? e.setAttribute("aria-describedby", n) : e.removeAttribute("aria-describedby"), e.removeAttribute(Cl), e.removeAttribute("aria-invalid"), e.classList.remove(wl), e.classList.length === 0 && e.removeAttribute("class");
10779
+ let n = e.getAttribute(wl);
10780
+ n ? e.setAttribute("aria-describedby", n) : e.removeAttribute("aria-describedby"), e.removeAttribute(wl), e.removeAttribute("aria-invalid"), e.classList.remove(Tl), e.classList.length === 0 && e.removeAttribute("class");
10762
10781
  }
10763
10782
  }
10764
- function kl(e, t, n) {
10765
- Ol(e, t);
10766
- let r = Tl(e, t), i = r[0];
10783
+ function Al(e, t, n) {
10784
+ kl(e, t);
10785
+ let r = El(e, t), i = r[0];
10767
10786
  if (!i || n.length === 0) return;
10768
- let a = El(i), o = i.ownerDocument.createElement(a ? "span" : "div");
10769
- o.className = "validation-error-message", o.setAttribute("part", "field-error"), o.setAttribute(Sl, t), o.id = `${i.id || `formdown-${t}`}-validation`, o.textContent = n.join("\n");
10770
- for (let e of r) e.setAttribute(Cl, e.getAttribute("aria-describedby") ?? ""), e.setAttribute("aria-describedby", [e.getAttribute("aria-describedby"), o.id].filter(Boolean).join(" ")), e.setAttribute("aria-invalid", "true"), e.classList.add(wl);
10787
+ let a = Dl(i), o = i.ownerDocument.createElement(a ? "span" : "div");
10788
+ o.className = "validation-error-message", o.setAttribute("part", "field-error"), o.setAttribute(Cl, t), o.id = `${i.id || `formdown-${t}`}-validation`, o.textContent = n.join("\n");
10789
+ for (let e of r) e.setAttribute(wl, e.getAttribute("aria-describedby") ?? ""), e.setAttribute("aria-describedby", [e.getAttribute("aria-describedby"), o.id].filter(Boolean).join(" ")), e.setAttribute("aria-invalid", "true"), e.classList.add(Tl);
10771
10790
  a ? i.after(o) : (i.closest(".formdown-field") ?? i.parentElement ?? i).append(o);
10772
10791
  }
10773
- function Al(e, t) {
10774
- Ol(e);
10775
- for (let [n, r] of t) kl(e, n, r);
10792
+ function jl(e, t) {
10793
+ kl(e);
10794
+ for (let [n, r] of t) Al(e, n, r);
10776
10795
  }
10777
- function jl(e, t, n, r) {
10796
+ function Ml(e, t, n, r) {
10778
10797
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
10779
10798
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
10780
10799
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
10781
10800
  return i > 3 && a && Object.defineProperty(t, n, a), a;
10782
10801
  }
10783
- var Ml = class extends Ge {
10802
+ var Nl = class extends Ge {
10784
10803
  static {
10785
- this.styles = yl;
10804
+ this.styles = bl;
10786
10805
  }
10787
10806
  get data() {
10788
10807
  return this._data;
@@ -10797,7 +10816,7 @@ var Ml = class extends Ge {
10797
10816
  }
10798
10817
  focusField(e) {
10799
10818
  let t = this.shadowRoot?.querySelector("#content-container");
10800
- return t ? Zc(t, e) : !1;
10819
+ return t ? Qc(t, e) : !1;
10801
10820
  }
10802
10821
  updateField(e, t) {
10803
10822
  this.data = {
@@ -10809,7 +10828,7 @@ var Ml = class extends Ge {
10809
10828
  await this.extensionsReady, super.scheduleUpdate();
10810
10829
  }
10811
10830
  constructor() {
10812
- super(), this.content = "", this.bodyHtml = "trust", this.fieldStates = {}, this.choices = {}, this.filterSelectAbove = 20, this.messages = {}, this.shownErrors = /* @__PURE__ */ new Set(), this._data = {}, this.fieldRegistry = /* @__PURE__ */ new Map(), this._isUpdatingUI = !1, this._schema = null, this.computed = /* @__PURE__ */ new Map(), this.formManager = new ac(), this.domBinder = this.formManager.createDOMBinder(), this.setupCoreUIBridge(), this.setupFormManagerEvents();
10831
+ super(), this.content = "", this.bodyHtml = "trust", this.fieldStates = {}, this.choices = {}, this.filterSelectAbove = 20, this.messages = {}, this.shownErrors = /* @__PURE__ */ new Set(), this._data = {}, this.fieldRegistry = /* @__PURE__ */ new Map(), this._isUpdatingUI = !1, this._schema = null, this.computed = /* @__PURE__ */ new Map(), this.formManager = new oc(), this.domBinder = this.formManager.createDOMBinder(), this.setupCoreUIBridge(), this.setupFormManagerEvents();
10813
10832
  }
10814
10833
  setupCoreUIBridge() {
10815
10834
  this.formManager.setupComponentBridge({
@@ -10845,15 +10864,15 @@ var Ml = class extends Ge {
10845
10864
  isValid: !0,
10846
10865
  errors: []
10847
10866
  };
10848
- let e = this.formManager.validate({ messages: this.messages }), t = Dl(e.errors), n = this.shadowRoot?.querySelector("#content-container");
10849
- return n && Al(n, t), this.shownErrors = new Set(t.keys()), e;
10867
+ let e = this.formManager.validate({ messages: this.messages }), t = Ol(e.errors), n = this.shadowRoot?.querySelector("#content-container");
10868
+ return n && jl(n, t), this.shownErrors = new Set(t.keys()), e;
10850
10869
  }
10851
10870
  recheckShownErrors() {
10852
10871
  if (this.shownErrors.size === 0 || !this._schema) return;
10853
10872
  let e = this.shadowRoot?.querySelector("#content-container");
10854
10873
  if (!e) return;
10855
- let t = Dl($s(this.formManager.getData(), this._schema, { messages: this.messages }).errors), n = new Map([...t].filter(([e]) => this.shownErrors.has(e)));
10856
- Al(e, n), this.shownErrors = new Set(n.keys());
10874
+ let t = Ol(ec(this.formManager.getData(), this._schema, { messages: this.messages }).errors), n = new Map([...t].filter(([e]) => this.shownErrors.has(e)));
10875
+ jl(e, n), this.shownErrors = new Set(n.keys());
10857
10876
  }
10858
10877
  getSchema() {
10859
10878
  return this._schema;
@@ -10870,7 +10889,7 @@ var Ml = class extends Ge {
10870
10889
  render() {
10871
10890
  if (!this.content || !this.content.trim()) return De`<div class="error">No Formdown content provided</div>`;
10872
10891
  try {
10873
- this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = _l(this._schema), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10892
+ this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = vl(this._schema), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10874
10893
  let e = this.formManager.renderToTemplate({
10875
10894
  container: this,
10876
10895
  html: this.bodyHtml
@@ -10890,12 +10909,12 @@ var Ml = class extends Ge {
10890
10909
  this.syncUIFromData();
10891
10910
  }, 0)), e.has("data") && this.syncUIFromData(), (e.has("data") || e.has("messages")) && !e.has("content") && this.recheckShownErrors(), e.has("fieldStates") && !e.has("content") && this.drawFieldStates(), e.has("choices") && !e.has("content") && !e.has("data") && this.syncUIFromData(), e.has("filterSelectAbove") && !e.has("content")) {
10892
10911
  let e = this.shadowRoot?.querySelector("#content-container");
10893
- e && rl(e, this.filterSelectAbove);
10912
+ e && il(e, this.filterSelectAbove);
10894
10913
  }
10895
10914
  }
10896
10915
  drawFieldStates() {
10897
10916
  let e = this.shadowRoot?.querySelector("#content-container");
10898
- e && Uc(e, this.fieldStates ?? {}, {
10917
+ e && Wc(e, this.fieldStates ?? {}, {
10899
10918
  onPick: (e, t) => this.dispatchEvent(new CustomEvent("formdown-suggestion-pick", {
10900
10919
  detail: {
10901
10920
  field: e,
@@ -10915,7 +10934,7 @@ var Ml = class extends Ge {
10915
10934
  if (this.content && this.content.trim()) try {
10916
10935
  let e = this.shadowRoot?.querySelector("#content-container");
10917
10936
  if (!e) return;
10918
- this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = _l(this._schema), this.fieldTypeSheet ??= new xl(this.shadowRoot), this.fieldTypeSheet.set(bl(this._schema)), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10937
+ this.formManager.parse(this.content), this._schema = this.formManager.getSchema(), this.computed = vl(this._schema), this.fieldTypeSheet ??= new Sl(this.shadowRoot), this.fieldTypeSheet.set(xl(this._schema)), this.data && Object.keys(this.data).length > 0 && this.formManager.updateData(this.data);
10919
10938
  let t = this.formManager.renderToTemplate({
10920
10939
  container: this,
10921
10940
  html: this.bodyHtml
@@ -10944,14 +10963,14 @@ var Ml = class extends Ge {
10944
10963
  let t = e, n = this.getFieldName(t);
10945
10964
  n && (this.registerField(n, t), this.setupFieldEventHandlers(t, n));
10946
10965
  }), this.setupCustomControls(e);
10947
- for (let t of lc(e)) customElements.whenDefined(t).then(() => {
10966
+ for (let t of uc(e)) customElements.whenDefined(t).then(() => {
10948
10967
  e.isConnected && (this.setupCustomControls(e), this.syncUIFromData());
10949
10968
  });
10950
10969
  let t = e.querySelectorAll("input:not([type=\"radio\"]):not([type=\"checkbox\"]), [contenteditable=\"true\"]");
10951
10970
  this.setupBasicKeyboardNavigation(t);
10952
10971
  }
10953
10972
  setupCustomControls(e) {
10954
- for (let t of cc(e)) {
10973
+ for (let t of lc(e)) {
10955
10974
  let e = t.getAttribute("name");
10956
10975
  this.fieldRegistry.get(e)?.has(t) || (this.registerField(e, t), this.setupFieldEventHandlers(t, e));
10957
10976
  }
@@ -10971,14 +10990,28 @@ var Ml = class extends Ge {
10971
10990
  setupFieldEventHandlers(e, t) {
10972
10991
  this.domBinder.bindFieldToElement(t, e);
10973
10992
  let n = (n) => {
10993
+ if (e instanceof HTMLInputElement && e.type === "file") {
10994
+ if (n.type === "change") {
10995
+ let n = Array.from(e.files ?? []);
10996
+ this.dispatchEvent(new CustomEvent("formdown-file-pick", {
10997
+ detail: {
10998
+ field: t,
10999
+ files: n
11000
+ },
11001
+ bubbles: !0,
11002
+ composed: !0
11003
+ }));
11004
+ }
11005
+ return;
11006
+ }
10974
11007
  let r = this.data[t];
10975
11008
  this.formManager.handleUIEvent(n, this.domBinder);
10976
11009
  let i = this.getFieldValueFromElement(e);
10977
- Nl(r, i) || this.updateDataReactively(t, i);
11010
+ Pl(r, i) || this.updateDataReactively(t, i);
10978
11011
  };
10979
11012
  e.addEventListener("input", n), e.addEventListener("change", n), e.addEventListener("focus", (e) => {
10980
11013
  let t = e.target;
10981
- Yc.delete(t) || (t.hasAttribute("contenteditable") && setTimeout(() => {
11014
+ Xc.delete(t) || (t.hasAttribute("contenteditable") && setTimeout(() => {
10982
11015
  let e = document.createRange(), n = window.getSelection();
10983
11016
  n && t.textContent && (e.selectNodeContents(t), n.removeAllRanges(), n.addRange(e));
10984
11017
  }, 0), t instanceof HTMLInputElement && t.type !== "file" && t.type !== "checkbox" && t.type !== "radio" && setTimeout(() => {
@@ -10996,7 +11029,7 @@ var Ml = class extends Ge {
10996
11029
  }, this.emitFieldEvents(e, t));
10997
11030
  }
10998
11031
  followComputed() {
10999
- let e = vl(this.computed, this.formManager.getData());
11032
+ let e = yl(this.computed, this.formManager.getData());
11000
11033
  for (let [t, n] of Object.entries(e)) this.formManager.setFieldValue(t, n);
11001
11034
  return e;
11002
11035
  }
@@ -11005,11 +11038,11 @@ var Ml = class extends Ge {
11005
11038
  this._isUpdatingUI = !0;
11006
11039
  try {
11007
11040
  let e = this.shadowRoot?.activeElement, t = this.shadowRoot?.querySelector("#content-container");
11008
- if (t) for (let e of [...Tc(t, this.choices ?? {}), ...hc(t, this.data)]) this.registerField(e.name, e), this.setupFieldEventHandlers(e, e.name);
11041
+ if (t) for (let e of [...Ec(t, this.choices ?? {}), ...gc(t, this.data)]) this.registerField(e.name, e), this.setupFieldEventHandlers(e, e.name);
11009
11042
  this.domBinder.getValueAssignments(this.data).forEach(({ element: t, value: n, fieldType: r }) => {
11010
11043
  let i = t;
11011
- i !== e && mc(i, n, r);
11012
- }), t && xc(t, this.data), t && this._schema && gl(t, this._schema, this.data), t && rl(t, this.filterSelectAbove), t && Bc(t);
11044
+ i !== e && hc(i, n, r);
11045
+ }), t && Sc(t, this.data), t && this._schema && _l(t, this._schema, this.data), t && il(t, this.filterSelectAbove), t && Vc(t);
11013
11046
  } finally {
11014
11047
  this._isUpdatingUI = !1, this.domBinder.releaseSyncLock();
11015
11048
  }
@@ -11019,7 +11052,7 @@ var Ml = class extends Ge {
11019
11052
  return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.name || e.id || null : e.dataset.fieldName || e.id || null;
11020
11053
  }
11021
11054
  getFieldValueFromElement(e) {
11022
- if (sc(e)) return uc(e);
11055
+ if (cc(e)) return dc(e);
11023
11056
  if (e instanceof HTMLInputElement) {
11024
11057
  if (e.type === "checkbox") {
11025
11058
  let t = e.name, n = this.formManager.createFieldProcessor().processCheckboxGroup(t, {
@@ -11058,12 +11091,15 @@ var Ml = class extends Ge {
11058
11091
  getFormData() {
11059
11092
  return this.formManager.getData();
11060
11093
  }
11094
+ getConditionStates() {
11095
+ return this.formManager.getConditionStates();
11096
+ }
11061
11097
  getDefaultValues() {
11062
11098
  return this.formManager.getDefaultValues();
11063
11099
  }
11064
11100
  clearValidationStates() {
11065
11101
  let e = this.shadowRoot?.querySelector("#content-container");
11066
- e && (Ol(e), this.shownErrors.clear());
11102
+ e && (kl(e), this.shownErrors.clear());
11067
11103
  }
11068
11104
  resetForm() {
11069
11105
  this.formManager.reset(), this.data = this.formManager.getData(), this.clearValidationStates();
@@ -11077,33 +11113,33 @@ var Ml = class extends Ge {
11077
11113
  let n = t.querySelector(`[data-field-name="${CSS.escape(e)}"]`) ?? t.querySelector(`#${CSS.escape(e)}`);
11078
11114
  r = n ? [n] : [];
11079
11115
  }
11080
- for (let e of r) mc(e, n, e instanceof HTMLInputElement ? e.type : e.dataset.fieldType ?? "text"), e.dispatchEvent(new Event("input", { bubbles: !0 }));
11116
+ for (let e of r) hc(e, n, e instanceof HTMLInputElement ? e.type : e.dataset.fieldType ?? "text"), e.dispatchEvent(new Event("input", { bubbles: !0 }));
11081
11117
  }), this.data = { ...e });
11082
11118
  }
11083
11119
  };
11084
- jl([O()], Ml.prototype, "content", void 0), jl([O({ attribute: "body-html" })], Ml.prototype, "bodyHtml", void 0), jl([O({ attribute: !1 })], Ml.prototype, "fieldStates", void 0), jl([O({ attribute: !1 })], Ml.prototype, "choices", void 0), jl([O({
11120
+ Ml([O()], Nl.prototype, "content", void 0), Ml([O({ attribute: "body-html" })], Nl.prototype, "bodyHtml", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "fieldStates", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "choices", void 0), Ml([O({
11085
11121
  attribute: "filter-select-above",
11086
11122
  type: Number
11087
- })], Ml.prototype, "filterSelectAbove", void 0), jl([O({ attribute: !1 })], Ml.prototype, "messages", void 0), jl([O({ type: Object })], Ml.prototype, "data", null), Ml = jl([qe("formdown-ui")], Ml);
11088
- function Nl(e, t) {
11123
+ })], Nl.prototype, "filterSelectAbove", void 0), Ml([O({ attribute: !1 })], Nl.prototype, "messages", void 0), Ml([O({ type: Object })], Nl.prototype, "data", null), Nl = Ml([qe("formdown-ui")], Nl);
11124
+ function Pl(e, t) {
11089
11125
  if (Array.isArray(t)) {
11090
11126
  let n = Array.isArray(e) ? e.map(String) : e == null ? [] : [String(e)];
11091
11127
  return n.length === t.length && n.every((e, n) => e === t[n]);
11092
11128
  }
11093
- return e == null ? t === "" || t === !1 : typeof t == "boolean" ? pc(e) === t : String(e) === t;
11129
+ return e == null ? t === "" || t === !1 : typeof t == "boolean" ? mc(e) === t : String(e) === t;
11094
11130
  }
11095
11131
  // \0@oxc-project+runtime@0.155.0/helpers/esm/decorate.js
11096
- function Pl(e, t, n, r) {
11132
+ function Fl(e, t, n, r) {
11097
11133
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
11098
11134
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
11099
11135
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
11100
11136
  return i > 3 && a && Object.defineProperty(t, n, a), a;
11101
11137
  }
11102
11138
  // src/lowline-form.ts
11103
- var Fl = 300, $ = class extends Ge {
11139
+ var Il = 300, $ = class extends Ge {
11104
11140
  constructor(...e) {
11105
11141
  super(...e), this.src = "/lowline", this.form = "", this.record = "", this.content = "", this.data = {}, this.rate = .05, this.strings = i, this.client = new c(this.src), this.fieldStates = {}, this.canJudge = !0, this.changed = () => {
11106
- clearTimeout(this.asking), this.asking = setTimeout(() => void this.ask(), Fl);
11142
+ clearTimeout(this.asking), this.asking = setTimeout(() => void this.ask(), Il);
11107
11143
  }, this.picked = (e) => {
11108
11144
  let { field: t, value: n } = e.detail;
11109
11145
  this.session?.picked(t);
@@ -11207,5 +11243,5 @@ var Fl = 300, $ = class extends Ge {
11207
11243
  super.disconnectedCallback(), clearTimeout(this.asking);
11208
11244
  }
11209
11245
  };
11210
- Pl([O()], $.prototype, "src", void 0), Pl([O()], $.prototype, "form", void 0), Pl([O()], $.prototype, "record", void 0), Pl([O()], $.prototype, "content", void 0), Pl([O({ attribute: !1 })], $.prototype, "data", void 0), Pl([O({ type: Number })], $.prototype, "rate", void 0), Pl([O({ attribute: !1 })], $.prototype, "strings", void 0), Pl([Ze("formdown-ui")], $.prototype, "formdown", void 0), $ = Pl([qe("lowline-form")], $);
11246
+ Fl([O()], $.prototype, "src", void 0), Fl([O()], $.prototype, "form", void 0), Fl([O()], $.prototype, "record", void 0), Fl([O()], $.prototype, "content", void 0), Fl([O({ attribute: !1 })], $.prototype, "data", void 0), Fl([O({ type: Number })], $.prototype, "rate", void 0), Fl([O({ attribute: !1 })], $.prototype, "strings", void 0), Fl([Ze("formdown-ui")], $.prototype, "formdown", void 0), $ = Fl([qe("lowline-form")], $);
11211
11247
  export { e as Draft, c as LowlineClient, s as LowlineError, $ as LowlineForm, a as Session, i as englishStrings, r as valuesOf };