@dmitryvim/form-builder 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let a=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[l,d]of Object.entries(n))a=a.replace(new RegExp(`\\{${l}\\}`,"g"),String(d));return a}function br(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(E("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(E("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(E("hintMinLength",n,{min:e.minLength})))}function vr(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(E("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(E("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(E("hintMinValue",n,{min:e.min})))}function gr(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(E("hintMaxSize",n,{size:o}))}function yr(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(E("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function xr(e,t,n){e.pattern&&t.push(E("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return br(e,n,t),e.type!=="slider"&&vr(e,n,t),gr(e,n,t),yr(e,n,t),xr(e,n,t),n.join(" \u2022 ")}function wt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,a=[1,2,3,4];(!Number.isInteger(i)||!a.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((a,l)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const d in a.values)e.elements.some(s=>s.key===d)||t.push(`schema.prefillHints[${l}] references non-existent field "${d}"`)})}function n(i,a,l){if("columns"in i&&i.columns!==void 0){const d=i.columns,s=[1,2,3,4];(!Number.isInteger(d)||!s.includes(d))&&l.push(`${a}: columns must be 1, 2, 3, or 4 (got ${d})`)}if("displayMode"in i&&i.displayMode!==void 0){const d=i.displayMode;d!=="stack"&&d!=="slides"&&l.push(`${a}: displayMode must be "stack" or "slides" (got ${JSON.stringify(d)})`)}}function r(i,a){var l,d;const s=new Set;for(const u of i)if(u.type==="richinput"&&u.flatOutput){const c=u,f=(l=c.textKey)!=null?l:"text",p=(d=c.filesKey)!=null?d:"files";for(const m of i)m!==u&&(m.key===f&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with element key "${m.key}"`),m.key===p&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with element key "${m.key}"`));s.has(f)&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with another flatOutput key`),s.has(p)&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),s.add(f),s.add(p)}else u.key&&(s.has(u.key)&&t.push(`${a}: Element key "${u.key}" collides with a flatOutput richinput key`),s.add(u.key))}function o(i,a){i.forEach((l,d)=>{const s=`${a}[${d}]`;if(l.type||t.push(`${s}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${s}: missing key`),l.type==="markdown"){const u=l.content;typeof u!="string"&&t.push(`${s}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(l.enableIf){const u=l.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${s}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${s}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&o(l.elements,`${s}.elements`),l.type==="container"&&l.elements){if(n(l,s,t),"prefillHints"in l&&l.prefillHints){const u=l.prefillHints;Array.isArray(u)&&u.forEach((c,f)=>{if((!c.label||typeof c.label!="string")&&t.push(`${s}: prefillHints[${f}] must have a 'label' property of type string`),!c.values||typeof c.values!="object")t.push(`${s}: prefillHints[${f}] must have a 'values' property of type object`);else for(const p in c.values)l.elements.some(m=>m.key===p)||t.push(`container "${l.key}": prefillHints[${f}] references non-existent field "${p}"`)})}o(l.elements,`${s}.elements`),r(l.elements,`${s}.elements`)}if(l.type==="select"&&l.options){const u=l.default;u!=null&&u!==""&&(l.options.some(c=>c.value===u)||t.push(`${s}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),r(e.elements,"elements")),t}function ae(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function nt(e){return e&&typeof e=="object"&&e.constructor===Object}function se(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Ct(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function ke(e,t){return e?`${e}.${t}`:t}function ye(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function wr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Qt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function _e(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Zt(t),n}function Et(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function He(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const a=Et(i,e.key);if("equals"in e)return Cr(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Cr(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e=="object"&&typeof t=="object")try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){if(n instanceof TypeError&&(n.message.includes("circular")||n.message.includes("cyclic")))return console.warn("deepEqual: Circular reference detected in enableIf comparison, using reference equality"),e===t;throw n}return e===t}function xe(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const en='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Er(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
1
+ var FormBuilder=(function(Ae){"use strict";function k(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let a=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[l,d]of Object.entries(n))a=a.replace(new RegExp(`\\{${l}\\}`,"g"),String(d));return a}function hr(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(k("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(k("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(k("hintMinLength",n,{min:e.minLength})))}function br(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(k("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(k("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(k("hintMinValue",n,{min:e.min})))}function vr(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(k("hintMaxSize",n,{size:o}))}function gr(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function yr(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return hr(e,n,t),e.type!=="slider"&&br(e,n,t),vr(e,n,t),gr(e,n,t),yr(e,n,t),n.join(" \u2022 ")}function wt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,a=[1,2,3,4];(!Number.isInteger(i)||!a.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((a,l)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const d in a.values)e.elements.some(s=>s.key===d)||t.push(`schema.prefillHints[${l}] references non-existent field "${d}"`)})}function n(i,a,l){if("columns"in i&&i.columns!==void 0){const d=i.columns,s=[1,2,3,4];(!Number.isInteger(d)||!s.includes(d))&&l.push(`${a}: columns must be 1, 2, 3, or 4 (got ${d})`)}if("displayMode"in i&&i.displayMode!==void 0){const d=i.displayMode;d!=="stack"&&d!=="slides"&&l.push(`${a}: displayMode must be "stack" or "slides" (got ${JSON.stringify(d)})`)}}function r(i,a){var l,d;const s=new Set;for(const u of i)if(u.type==="richinput"&&u.flatOutput){const c=u,f=(l=c.textKey)!=null?l:"text",p=(d=c.filesKey)!=null?d:"files";for(const m of i)m!==u&&(m.key===f&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with element key "${m.key}"`),m.key===p&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with element key "${m.key}"`));s.has(f)&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${f}" collides with another flatOutput key`),s.has(p)&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),s.add(f),s.add(p)}else u.key&&(s.has(u.key)&&t.push(`${a}: Element key "${u.key}" collides with a flatOutput richinput key`),s.add(u.key))}function o(i,a){i.forEach((l,d)=>{const s=`${a}[${d}]`;if(l.type||t.push(`${s}: missing type`),!l.key&&l.type!=="markdown"&&t.push(`${s}: missing key`),l.type==="markdown"){const u=l.content;typeof u!="string"&&t.push(`${s}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(l.enableIf){const u=l.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${s}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${s}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&o(l.elements,`${s}.elements`),l.type==="container"&&l.elements){if(n(l,s,t),"prefillHints"in l&&l.prefillHints){const u=l.prefillHints;Array.isArray(u)&&u.forEach((c,f)=>{if((!c.label||typeof c.label!="string")&&t.push(`${s}: prefillHints[${f}] must have a 'label' property of type string`),!c.values||typeof c.values!="object")t.push(`${s}: prefillHints[${f}] must have a 'values' property of type object`);else for(const p in c.values)l.elements.some(m=>m.key===p)||t.push(`container "${l.key}": prefillHints[${f}] references non-existent field "${p}"`)})}o(l.elements,`${s}.elements`),r(l.elements,`${s}.elements`)}if(l.type==="select"&&l.options){const u=l.default;u!=null&&u!==""&&(l.options.some(c=>c.value===u)||t.push(`${s}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),r(e.elements,"elements")),t}function ae(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function nt(e){return e&&typeof e=="object"&&e.constructor===Object}function se(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function Ct(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function ke(e,t){return e?`${e}.${t}`:t}function ye(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function xr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Qt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function _e(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Zt(t),n}function Et(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function He(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const a=Et(i,e.key);if("equals"in e)return wr(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function wr(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(typeof e=="object"&&typeof t=="object")try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){if(n instanceof TypeError&&(n.message.includes("circular")||n.message.includes("cyclic")))return console.warn("deepEqual: Circular reference detected in enableIf comparison, using reference equality"),e===t;throw n}return e===t}function xe(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const en='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Cr(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
2
2
  [data-fb-slide-card] {
3
3
  background: var(--fb-slide-card-bg);
4
4
  box-shadow: var(--fb-slide-card-shadow);
@@ -118,7 +118,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
118
118
  font-size: var(--fb-font-size-small, 0.875rem);
119
119
  color: var(--fb-text-secondary-color);
120
120
  font-weight: 400;
121
- `,i||(d.style.display="none"),a.appendChild(l),{row:a,button:l,counter:d,update:(s,u)=>{const c=s>=u;a.style.display=c?"none":"flex",l.style.display=c?"none":"inline-flex",l.disabled=c,i&&(d.textContent=`${s}/${u===1/0?"\u221E":u}`)}}}function kr(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
121
+ `,i||(d.style.display="none"),a.appendChild(l),{row:a,button:l,counter:d,update:(s,u)=>{const c=s>=u;a.style.display=c?"none":"flex",l.style.display=c?"none":"inline-flex",l.disabled=c,i&&(d.textContent=`${s}/${u===1/0?"\u221E":u}`)}}}function Er(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
122
122
  display: flex;
123
123
  flex-direction: column;
124
124
  align-items: center;
@@ -165,7 +165,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
165
165
  border-radius: var(--fb-border-radius);
166
166
  transition: all var(--fb-transition-duration);
167
167
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
168
- `,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function $r(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
168
+ `,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function kr(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
169
169
  .fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
170
170
  .fb-chip {
171
171
  display: flex;
@@ -239,7 +239,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
239
239
  color: var(--fb-error-color);
240
240
  pointer-events: none;
241
241
  display: none;
242
- `;const r=()=>{const o=t.value.length,i=e.maxLength;i!=null&&o>i?(n.textContent=`${o}/${i}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function Sr(e,t,n,r){var o;const i=t.state,a=ae(e,i,t),l=document.createElement("div");l.style.cssText="position: relative;";const d=!a&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
242
+ `;const r=()=>{const o=t.value.length,i=e.maxLength;i!=null&&o>i?(n.textContent=`${o}/${i}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function $r(e,t,n,r){var o;const i=t.state,a=ae(e,i,t),l=document.createElement("div");l.style.cssText="position: relative;";const d=!a&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
243
243
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
244
244
  border: var(--fb-border-width) solid var(--fb-border-color);
245
245
  border-radius: var(--fb-border-radius);
@@ -255,28 +255,28 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
255
255
  overflow: hidden;
256
256
  word-break: break-word;
257
257
  overflow-wrap: anywhere;
258
- `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=a,tn(s),rt(s),a||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const u=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",u),s.addEventListener("input",u)}if(l.appendChild(s),d){const u=ot(e,s);l.appendChild(u)}n.appendChild(l)}function Lr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");$r(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function p(){f.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const v=h.closest(".fb-chip"),w=v==null?void 0:v.nextElementSibling;w&&w.classList.contains("error-message")&&(w.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const v=document.createElement("span");v.className="fb-chip-dot",v.setAttribute("aria-hidden","true"),y.appendChild(v);const w=document.createElement("textarea");if(w.rows=1,w.className="fb-chip-input",w.value=h,w.placeholder=e.placeholder||E("placeholderText",a),w.readOnly=l,y.appendChild(w),!l&&t.instance){const k=()=>{t.instance.triggerOnChange(w.name,w.value===""?null:w.value)};w.addEventListener("blur",k),w.addEventListener("input",k)}if(tn(w),rt(w),!l){const k=document.createElement("button");k.type="button",k.className="fb-chip-remove",k.setAttribute("aria-label",E("removeElement",a)),k.innerHTML=en,k.onclick=()=>{const x=f.querySelectorAll(".fb-chip"),$=Array.prototype.indexOf.call(x,y);if($<0||x.length<=u)return;s.splice($,1);const z=y.nextElementSibling;z&&z.classList.contains("error-message")&&z.remove(),y.remove(),p(),C(),b()},y.appendChild(k)}return f.appendChild(y),p(),y}function b(){if(l)return;const h=f.querySelectorAll(".fb-chip").length<=u;f.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let g=null;if(!l){const h=Fe("text",()=>{s.push(e.default||""),m(e.default||""),C(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function C(){g&&g(s.length,c)}s.forEach(h=>m(h)),C(),b()}function rn(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n,s=(c,f)=>{var p,m,b;if(!c)return;const g=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let C=document.getElementById(g);if(f){if(c.classList.add("invalid"),c.title=f,!C){C=document.createElement("div"),C.id=g,C.className="error-message",C.style.cssText=`
258
+ `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=a,tn(s),rt(s),a||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const u=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",u),s.addEventListener("input",u)}if(l.appendChild(s),d){const u=ot(e,s);l.appendChild(u)}n.appendChild(l)}function Sr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");kr(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function p(){f.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const v=h.closest(".fb-chip"),C=v==null?void 0:v.nextElementSibling;C&&C.classList.contains("error-message")&&(C.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const v=document.createElement("span");v.className="fb-chip-dot",v.setAttribute("aria-hidden","true"),y.appendChild(v);const C=document.createElement("textarea");if(C.rows=1,C.className="fb-chip-input",C.value=h,C.placeholder=e.placeholder||k("placeholderText",a),C.readOnly=l,y.appendChild(C),!l&&t.instance){const w=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(tn(C),rt(C),!l){const w=document.createElement("button");w.type="button",w.className="fb-chip-remove",w.setAttribute("aria-label",k("removeElement",a)),w.innerHTML=en,w.onclick=()=>{const x=f.querySelectorAll(".fb-chip"),S=Array.prototype.indexOf.call(x,y);if(S<0||x.length<=u)return;s.splice(S,1);const I=y.nextElementSibling;I&&I.classList.contains("error-message")&&I.remove(),y.remove(),p(),E(),b()},y.appendChild(w)}return f.appendChild(y),p(),y}function b(){if(l)return;const h=f.querySelectorAll(".fb-chip").length<=u;f.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let g=null;if(!l){const h=Fe("text",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,c)}s.forEach(h=>m(h)),E(),b()}function rn(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n,s=(c,f)=>{var p,m,b;if(!c)return;const g=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let E=document.getElementById(g);if(f){if(c.classList.add("invalid"),c.title=f,!E){E=document.createElement("div"),E.id=g,E.className="error-message",E.style.cssText=`
259
259
  color: var(--fb-error-color);
260
260
  font-size: var(--fb-font-size-small);
261
261
  margin-top: 0.25rem;
262
- `;const h=((p=c.closest)==null?void 0:p.call(c,".fb-chip"))||c;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(C,h.nextSibling):(b=h.parentNode)==null||b.appendChild(C)}C.textContent=f,C.style.display="block"}else c.classList.remove("invalid"),c.title="",C&&C.remove()},u=(c,f,p)=>{let m=!1;const{state:b}=n;if(!d&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const g=E("minLength",b,{min:e.minLength});a.push(`${p}: ${g}`),s(c,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const g=E("maxLength",b,{max:e.maxLength});a.push(`${p}: ${g}`),s(c,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const g=E("patternMismatch",b);a.push(`${p}: ${g}`),s(c,g),m=!0}}catch(g){const C=E("invalidPattern",b);a.push(`${p}: ${C}`),s(c,C),m=!0}}m||s(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["]`),f=[],p=[];if(c.forEach((m,b)=>{var g;const C=(g=m==null?void 0:m.value)!=null?g:"";p.push(C),f.push(C===""?null:C),u(m,C,`${t}[${b}]`)}),!d){const{state:m}=n,b=(r=e.minCount)!=null?r:0,g=(o=e.maxCount)!=null?o:1/0,C=p.filter(h=>h.trim()!=="");e.required&&C.length===0&&a.push(`${t}: ${E("required",m)}`),C.length<b&&a.push(`${t}: ${E("minItems",m,{min:b})}`),C.length>g&&a.push(`${t}: ${E("maxItems",m,{max:g})}`)}return{value:f,errors:a}}else{const c=l.querySelector(`[name$="${t}"]`),f=(i=c==null?void 0:c.value)!=null?i:"";if(!d&&e.required&&f===""){const p=E("required",n.state);return a.push(`${t}: ${p}`),s(c,p),{value:null,errors:a}}return c&&u(c,f,t),{value:f===""?null:f,errors:a}}}function on(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a),a.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i),i instanceof HTMLTextAreaElement&&i.dispatchEvent(new Event("input",{bubbles:!0})))}}function Tr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=document.createElement("div");d.style.cssText="position: relative;";const s=document.createElement("textarea");if(s.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",s.style.cssText=`
262
+ `;const h=((p=c.closest)==null?void 0:p.call(c,".fb-chip"))||c;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(E,h.nextSibling):(b=h.parentNode)==null||b.appendChild(E)}E.textContent=f,E.style.display="block"}else c.classList.remove("invalid"),c.title="",E&&E.remove()},u=(c,f,p)=>{let m=!1;const{state:b}=n;if(!d&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const g=k("minLength",b,{min:e.minLength});a.push(`${p}: ${g}`),s(c,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const g=k("maxLength",b,{max:e.maxLength});a.push(`${p}: ${g}`),s(c,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const g=k("patternMismatch",b);a.push(`${p}: ${g}`),s(c,g),m=!0}}catch(g){const E=k("invalidPattern",b);a.push(`${p}: ${E}`),s(c,E),m=!0}}m||s(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["]`),f=[],p=[];if(c.forEach((m,b)=>{var g;const E=(g=m==null?void 0:m.value)!=null?g:"";p.push(E),f.push(E===""?null:E),u(m,E,`${t}[${b}]`)}),!d){const{state:m}=n,b=(r=e.minCount)!=null?r:0,g=(o=e.maxCount)!=null?o:1/0,E=p.filter(h=>h.trim()!=="");e.required&&E.length===0&&a.push(`${t}: ${k("required",m)}`),E.length<b&&a.push(`${t}: ${k("minItems",m,{min:b})}`),E.length>g&&a.push(`${t}: ${k("maxItems",m,{max:g})}`)}return{value:f,errors:a}}else{const c=l.querySelector(`[name$="${t}"]`),f=(i=c==null?void 0:c.value)!=null?i:"";if(!d&&e.required&&f===""){const p=k("required",n.state);return a.push(`${t}: ${p}`),s(c,p),{value:null,errors:a}}return c&&u(c,f,t),{value:f===""?null:f,errors:a}}}function on(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a),a.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i),i instanceof HTMLTextAreaElement&&i.dispatchEvent(new Event("input",{bubbles:!0})))}}function Lr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=document.createElement("div");d.style.cssText="position: relative;";const s=document.createElement("textarea");if(s.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",s.style.cssText=`
263
263
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
264
264
  font-size: var(--fb-font-size);
265
265
  font-family: var(--fb-font-family);
266
266
  line-height: var(--fb-line-height, 1.5);
267
- `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=l,!l&&t.instance){const u=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",u),s.addEventListener("input",u)}if(rt(s,{minRows:(i=e.rows)!=null?i:1}),d.appendChild(s),!l&&(e.minLength!=null||e.maxLength!=null)){const u=ot(e,s);d.appendChild(u)}n.appendChild(d)}function Ar(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){var v;const w=document.createElement("div");w.className="multiple-textarea-item";const k=document.createElement("div");k.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText=`
267
+ `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=l,!l&&t.instance){const u=()=>{const c=s.value===""?null:s.value;t.instance.triggerOnChange(r,c)};s.addEventListener("blur",u),s.addEventListener("input",u)}if(rt(s,{minRows:(i=e.rows)!=null?i:1}),d.appendChild(s),!l&&(e.minLength!=null||e.maxLength!=null)){const u=ot(e,s);d.appendChild(u)}n.appendChild(d)}function Tr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){var v;const C=document.createElement("div");C.className="multiple-textarea-item";const w=document.createElement("div");w.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText=`
268
268
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
269
269
  font-size: var(--fb-font-size);
270
270
  font-family: var(--fb-font-family);
271
271
  line-height: var(--fb-line-height, 1.5);
272
- `,x.placeholder=e.placeholder||E("placeholderText",a),x.value=h,x.readOnly=l,!l&&t.instance){const $=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",$),x.addEventListener("input",$)}if(rt(x,{minRows:(v=e.rows)!=null?v:1}),k.appendChild(x),!l&&(e.minLength!=null||e.maxLength!=null)){const $=ot(e,x);k.appendChild($)}return w.appendChild(k),y===-1?f.appendChild(w):f.insertBefore(w,f.children[y]),p(),w}function b(){if(l)return;const h=f.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(v=>{let w=v.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",w.innerHTML="\u2715",w.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),C(),b())},v.appendChild(w));const k=y<=u;w.disabled=k,w.style.opacity=k?"0.5":"1",w.style.pointerEvents=k?"none":"auto"})}let g=null;if(!l){const h=Fe("textarea",()=>{s.push(e.default||""),m(e.default||""),C(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function C(){g&&g(s.length,c)}s.forEach(h=>m(h)),C(),b()}function Fr(e,t,n){return rn(e,t,n)}function zr(e,t,n,r){on(e,t,n,r);const{scopeRoot:o}=r;if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(i=>{i.dispatchEvent(new Event("input"))});else{const i=o.querySelector(`textarea[name="${t}"]`);i&&i.dispatchEvent(new Event("input"))}}function Mr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
272
+ `,x.placeholder=e.placeholder||k("placeholderText",a),x.value=h,x.readOnly=l,!l&&t.instance){const S=()=>{const I=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,I)};x.addEventListener("blur",S),x.addEventListener("input",S)}if(rt(x,{minRows:(v=e.rows)!=null?v:1}),w.appendChild(x),!l&&(e.minLength!=null||e.maxLength!=null)){const S=ot(e,x);w.appendChild(S)}return C.appendChild(w),y===-1?f.appendChild(C):f.insertBefore(C,f.children[y]),p(),C}function b(){if(l)return;const h=f.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),E(),b())},v.appendChild(C));const w=y<=u;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!l){const h=Fe("textarea",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,c)}s.forEach(h=>m(h)),E(),b()}function Ar(e,t,n){return rn(e,t,n)}function Fr(e,t,n,r){on(e,t,n,r);const{scopeRoot:o}=r;if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(i=>{i.dispatchEvent(new Event("input"))});else{const i=o.querySelector(`textarea[name="${t}"]`);i&&i.dispatchEvent(new Event("input"))}}function zr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
273
273
  .fb-stepper-input::-webkit-outer-spin-button,
274
274
  .fb-stepper-input::-webkit-inner-spin-button {
275
275
  -webkit-appearance: none;
276
276
  margin: 0;
277
277
  }
278
278
  .fb-stepper-input { -moz-appearance: textfield; }
279
- `,e.head.appendChild(n)}function Nr(e,t,n){var r;Mr(e.ownerDocument);const o=(r=t.step)!=null?r:1,i=t.min,a=t.max,l=document.createElement("div");l.className="fb-stepper",l.style.cssText=`
279
+ `,e.head.appendChild(n)}function Mr(e,t,n){var r;zr(e.ownerDocument);const o=(r=t.step)!=null?r:1,i=t.min,a=t.max,l=document.createElement("div");l.className="fb-stepper",l.style.cssText=`
280
280
  display: inline-flex;
281
281
  align-items: stretch;
282
282
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -315,35 +315,35 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
315
315
  pointer-events: none;
316
316
  background: var(--fb-background-color);
317
317
  padding: 0 4px;
318
- `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const a=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const d=r!=null&&l<r,s=o!=null&&l>o;n.style.color=d||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",a),a(),n}function Ir(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="number",l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,e.stepper||(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
318
+ `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const a=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const d=r!=null&&l<r,s=o!=null&&l>o;n.style.color=d||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",a),a(),n}function Nr(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("div");a.style.cssText="position: relative;";const l=document.createElement("input");if(l.type="number",l.name=r,l.placeholder=e.placeholder||"0",e.min!==void 0&&(l.min=e.min.toString()),e.max!==void 0&&(l.max=e.max.toString()),e.step!==void 0&&(l.step=e.step.toString()),l.value=t.prefill[e.key]||e.default||"",l.readOnly=i,e.stepper||(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
319
319
  padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
320
320
  font-size: var(--fb-font-size);
321
321
  font-family: var(--fb-font-family);
322
322
  width: 100%;
323
323
  box-sizing: border-box;
324
- `),!i&&t.instance){const d=()=>{const s=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",d),l.addEventListener("input",d)}if(e.stepper)a.appendChild(Nr(l,e,i));else if(a.appendChild(l),!i&&(e.min!=null||e.max!=null)){const d=ln(e,l);a.appendChild(d)}n.appendChild(a)}function qr(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const w=document.createElement("div");w.style.cssText="position: relative; flex: 1;";const k=document.createElement("input");if(k.type="number",k.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",k.style.cssText=`
324
+ `),!i&&t.instance){const d=()=>{const s=l.value?parseFloat(l.value):null;t.instance.triggerOnChange(r,s)};l.addEventListener("blur",d),l.addEventListener("input",d)}if(e.stepper)a.appendChild(Mr(l,e,i));else if(a.appendChild(l),!i&&(e.min!=null||e.max!=null)){const d=ln(e,l);a.appendChild(d)}n.appendChild(a)}function Ir(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const w=document.createElement("input");if(w.type="number",w.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
325
325
  padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
326
326
  font-size: var(--fb-font-size);
327
327
  font-family: var(--fb-font-family);
328
328
  width: 100%;
329
329
  box-sizing: border-box;
330
- `,k.placeholder=e.placeholder||"0",e.min!==void 0&&(k.min=e.min.toString()),e.max!==void 0&&(k.max=e.max.toString()),e.step!==void 0&&(k.step=e.step.toString()),k.value=h.toString(),k.readOnly=l,!l&&t.instance){const x=()=>{const $=k.value?parseFloat(k.value):null;t.instance.triggerOnChange(k.name,$)};k.addEventListener("blur",x),k.addEventListener("input",x)}if(w.appendChild(k),!l&&(e.min!=null||e.max!=null)){const x=ln(e,k);w.appendChild(x)}return v.appendChild(w),y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(v=>{let w=v.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",w.innerHTML="\u2715",w.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),C(),b())},v.appendChild(w));const k=y<=u;w.disabled=k,w.style.opacity=k?"0.5":"1",w.style.pointerEvents=k?"none":"auto"})}let g=null;if(!l){const h=Fe("number",()=>{s.push(e.default||""),m(e.default||""),C(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function C(){g&&g(s.length,c)}s.forEach(h=>m(h)),C(),b()}function Rr(e,t,n){var r,o,i,a,l;const d=[],{scopeRoot:s,skipValidation:u}=n,c=(p,m)=>{var b,g;if(!p)return;const C=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(C);m?(p.classList.add("invalid"),p.title=m,h||(h=document.createElement("div"),h.id=C,h.className="error-message",h.style.cssText=`
330
+ `,w.placeholder=e.placeholder||"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),e.step!==void 0&&(w.step=e.step.toString()),w.value=h.toString(),w.readOnly=l,!l&&t.instance){const x=()=>{const S=w.value?parseFloat(w.value):null;t.instance.triggerOnChange(w.name,S)};w.addEventListener("blur",x),w.addEventListener("input",x)}if(C.appendChild(w),!l&&(e.min!=null||e.max!=null)){const x=ln(e,w);C.appendChild(x)}return v.appendChild(C),y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),E(),b())},v.appendChild(C));const w=y<=u;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!l){const h=Fe("number",()=>{s.push(e.default||""),m(e.default||""),E(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,c)}s.forEach(h=>m(h)),E(),b()}function qr(e,t,n){var r,o,i,a,l;const d=[],{scopeRoot:s,skipValidation:u}=n,c=(p,m)=>{var b,g;if(!p)return;const E=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(E);m?(p.classList.add("invalid"),p.title=m,h||(h=document.createElement("div"),h.id=E,h.className="error-message",h.style.cssText=`
331
331
  color: var(--fb-error-color);
332
332
  font-size: var(--fb-font-size-small);
333
333
  margin-top: 0.25rem;
334
- `,p.nextSibling?(b=p.parentNode)==null||b.insertBefore(h,p.nextSibling):(g=p.parentNode)==null||g.appendChild(h)),h.textContent=m,h.style.display="block"):(p.classList.remove("invalid"),p.title="",h&&h.remove())},f=(p,m,b)=>{let g=!1;const{state:C}=n;if(!u&&e.min!==void 0&&e.min!==null&&m<e.min){const h=E("minValue",C,{min:e.min});d.push(`${b}: ${h}`),c(p,h),g=!0}else if(!u&&e.max!==void 0&&e.max!==null&&m>e.max){const h=E("maxValue",C,{max:e.max});d.push(`${b}: ${h}`),c(p,h),g=!0}g||c(p,null)};if(e.multiple){const p=s.querySelectorAll(`[name^="${t}\\["]`),m=[];if(p.forEach((b,g)=>{var C,h,y;const v=(C=b==null?void 0:b.value)!=null?C:"";if(v===""){m.push(null),c(b,null);return}const w=parseFloat(v);if(!u&&!Number.isFinite(w)){const x=E("notANumber",n.state);d.push(`${t}[${g}]: ${x}`),c(b,x),m.push(null);return}f(b,w,`${t}[${g}]`);const k=Number.isInteger((h=e.decimals)!=null?h:0)&&(y=e.decimals)!=null?y:0;m.push(Number(w.toFixed(k)))}),!u){const{state:b}=n,g=(r=e.minCount)!=null?r:0,C=(o=e.maxCount)!=null?o:1/0,h=m.filter(y=>y!==null);e.required&&h.length===0&&d.push(`${t}: ${E("required",b)}`),h.length<g&&d.push(`${t}: ${E("minItems",b,{min:g})}`),h.length>C&&d.push(`${t}: ${E("maxItems",b,{max:C})}`)}return{value:m,errors:d}}else{const p=s.querySelector(`[name$="${t}"]`),m=(i=p==null?void 0:p.value)!=null?i:"",{state:b}=n;if(!u&&e.required&&m===""){const h=E("required",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}if(m==="")return c(p,null),{value:null,errors:d};const g=parseFloat(m);if(!u&&!Number.isFinite(g)){const h=E("notANumber",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}f(p,g,t);const C=Number.isInteger((a=e.decimals)!=null?a:0)&&(l=e.decimals)!=null?l:0;return{value:Number(g.toFixed(C)),errors:d}}}function Br(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i))}}function Hr(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("select");if(a.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText=`
334
+ `,p.nextSibling?(b=p.parentNode)==null||b.insertBefore(h,p.nextSibling):(g=p.parentNode)==null||g.appendChild(h)),h.textContent=m,h.style.display="block"):(p.classList.remove("invalid"),p.title="",h&&h.remove())},f=(p,m,b)=>{let g=!1;const{state:E}=n;if(!u&&e.min!==void 0&&e.min!==null&&m<e.min){const h=k("minValue",E,{min:e.min});d.push(`${b}: ${h}`),c(p,h),g=!0}else if(!u&&e.max!==void 0&&e.max!==null&&m>e.max){const h=k("maxValue",E,{max:e.max});d.push(`${b}: ${h}`),c(p,h),g=!0}g||c(p,null)};if(e.multiple){const p=s.querySelectorAll(`[name^="${t}\\["]`),m=[];if(p.forEach((b,g)=>{var E,h,y;const v=(E=b==null?void 0:b.value)!=null?E:"";if(v===""){m.push(null),c(b,null);return}const C=parseFloat(v);if(!u&&!Number.isFinite(C)){const x=k("notANumber",n.state);d.push(`${t}[${g}]: ${x}`),c(b,x),m.push(null);return}f(b,C,`${t}[${g}]`);const w=Number.isInteger((h=e.decimals)!=null?h:0)&&(y=e.decimals)!=null?y:0;m.push(Number(C.toFixed(w)))}),!u){const{state:b}=n,g=(r=e.minCount)!=null?r:0,E=(o=e.maxCount)!=null?o:1/0,h=m.filter(y=>y!==null);e.required&&h.length===0&&d.push(`${t}: ${k("required",b)}`),h.length<g&&d.push(`${t}: ${k("minItems",b,{min:g})}`),h.length>E&&d.push(`${t}: ${k("maxItems",b,{max:E})}`)}return{value:m,errors:d}}else{const p=s.querySelector(`[name$="${t}"]`),m=(i=p==null?void 0:p.value)!=null?i:"",{state:b}=n;if(!u&&e.required&&m===""){const h=k("required",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}if(m==="")return c(p,null),{value:null,errors:d};const g=parseFloat(m);if(!u&&!Number.isFinite(g)){const h=k("notANumber",b);return d.push(`${t}: ${h}`),c(p,h),{value:null,errors:d}}f(p,g,t);const E=Number.isInteger((a=e.decimals)!=null?a:0)&&(l=e.decimals)!=null?l:0;return{value:Number(g.toFixed(E)),errors:d}}}function Rr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",xe(i))}}function Br(e,t,n,r){const o=t.state,i=ae(e,o,t),a=document.createElement("select");if(a.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText=`
335
335
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
336
336
  font-size: var(--fb-font-size);
337
337
  font-family: var(--fb-font-family);
338
- `,a.name=r,a.disabled=i,(e.options||[]).forEach(l=>{const d=document.createElement("option");d.value=l.value,d.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(d.selected=!0),a.appendChild(d)}),!i&&t.instance){const l=()=>{t.instance.triggerOnChange(r,a.value)};a.addEventListener("change",l)}if(n.appendChild(a),!i){const l=document.createElement("p");l.className="text-xs text-gray-500 mt-1",l.textContent=Le(e,o),n.appendChild(l)}}function Dr(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=t.prefill[e.key]||[],c=Array.isArray(u)?[...u]:[],f=(o=e.minCount)!=null?o:e.required?1:0,p=(i=e.maxCount)!=null?i:1/0;for(;c.length<f;)c.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((v,w)=>{const k=v.querySelector("select");k&&(k.name=`${r}[${w}]`)})}function g(v="",w=-1){const k=document.createElement("div");k.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
338
+ `,a.name=r,a.disabled=i,(e.options||[]).forEach(l=>{const d=document.createElement("option");d.value=l.value,d.textContent=l.label,(t.prefill[e.key]||e.default)===l.value&&(d.selected=!0),a.appendChild(d)}),!i&&t.instance){const l=()=>{t.instance.triggerOnChange(r,a.value)};a.addEventListener("change",l)}if(n.appendChild(a),!i){const l=document.createElement("p");l.className="text-xs text-gray-500 mt-1",l.textContent=Le(e,o),n.appendChild(l)}}function Hr(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=t.prefill[e.key]||[],c=Array.isArray(u)?[...u]:[],f=(o=e.minCount)!=null?o:e.required?1:0,p=(i=e.maxCount)!=null?i:1/0;for(;c.length<f;)c.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((v,C)=>{const w=v.querySelector("select");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=document.createElement("div");w.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
339
339
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
340
340
  font-size: var(--fb-font-size);
341
341
  font-family: var(--fb-font-family);
342
- `,x.disabled=s,(e.options||[]).forEach($=>{const z=document.createElement("option");z.value=$.value,z.textContent=$.label,v===$.value&&(z.selected=!0),x.appendChild(z)}),!s&&t.instance){const $=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",$)}return k.appendChild(x),w===-1?m.appendChild(k):m.insertBefore(k,m.children[w]),b(),k}function C(){if(s)return;const v=m.querySelectorAll(".multiple-select-item"),w=v.length;v.forEach(k=>{let x=k.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{const z=Array.from(m.children).indexOf(k);m.children.length>f&&(c.splice(z,1),k.remove(),b(),y(),C())},k.appendChild(x));const $=w<=f;x.disabled=$,x.style.opacity=$?"0.5":"1",x.style.pointerEvents=$?"none":"auto"})}let h=null;if(!s){const v=Fe("select",()=>{var w,k;const x=e.default||((k=(w=e.options)==null?void 0:w[0])==null?void 0:k.value)||"";c.push(x),g(x),y(),C()},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(c.length,p)}if(c.forEach(v=>g(v)),y(),C(),!s){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,d),n.appendChild(v)}}function jr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(s,u)=>{var c,f;if(!s)return;const p=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);u?(s.classList.add("invalid"),s.title=u,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
342
+ `,x.disabled=s,(e.options||[]).forEach(S=>{const I=document.createElement("option");I.value=S.value,I.textContent=S.label,v===S.value&&(I.selected=!0),x.appendChild(I)}),!s&&t.instance){const S=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",S)}return w.appendChild(x),C===-1?m.appendChild(w):m.insertBefore(w,m.children[C]),b(),w}function E(){if(s)return;const v=m.querySelectorAll(".multiple-select-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{const I=Array.from(m.children).indexOf(w);m.children.length>f&&(c.splice(I,1),w.remove(),b(),y(),E())},w.appendChild(x));const S=C<=f;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!s){const v=Fe("select",()=>{var C,w;const x=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";c.push(x),g(x),y(),E()},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(c.length,p)}if(c.forEach(v=>g(v)),y(),E(),!s){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,d),n.appendChild(v)}}function Dr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(s,u)=>{var c,f;if(!s)return;const p=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);u?(s.classList.add("invalid"),s.title=u,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
343
343
  color: var(--fb-error-color);
344
344
  font-size: var(--fb-font-size-small);
345
345
  margin-top: 0.25rem;
346
- `,s.nextSibling?(c=s.parentNode)==null||c.insertBefore(m,s.nextSibling):(f=s.parentNode)==null||f.appendChild(m)),m.textContent=u,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},d=(s,u,c,f)=>{var p,m;if(a)return;const{state:b}=n,g=u.filter(f),C="minCount"in c&&(p=c.minCount)!=null?p:0,h="maxCount"in c&&(m=c.maxCount)!=null?m:1/0;c.required&&g.length===0&&o.push(`${s}: ${E("required",b)}`),g.length<C&&o.push(`${s}: ${E("minItems",b,{min:C})}`),g.length>h&&o.push(`${s}: ${E("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const s=i.querySelectorAll(`[name^="${t}\\["]`),u=[];return s.forEach(c=>{var f;const p=(f=c==null?void 0:c.value)!=null?f:"";u.push(p),l(c,null)}),d(t,u,e,c=>c!==""),{value:u,errors:o}}else{const s=i.querySelector(`[name$="${t}"]`),u=(r=s==null?void 0:s.value)!=null?r:"";if(!a&&e.required&&u===""){const c=E("required",n.state);return o.push(`${t}: ${c}`),l(s,c),{value:null,errors:o}}else l(s,null);return{value:u===""?null:u,errors:o}}}function Or(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.querySelectorAll("option").forEach(d=>{d.selected=d.value===String(n[l])}),a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(a=>{a.selected=a.value===String(n)}),i.classList.remove("invalid"),i.title="",xe(i))}}function lt(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function it(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function an(e){return e.classList.contains("fb-switcher-preset")}function Ur(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
346
+ `,s.nextSibling?(c=s.parentNode)==null||c.insertBefore(m,s.nextSibling):(f=s.parentNode)==null||f.appendChild(m)),m.textContent=u,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},d=(s,u,c,f)=>{var p,m;if(a)return;const{state:b}=n,g=u.filter(f),E="minCount"in c&&(p=c.minCount)!=null?p:0,h="maxCount"in c&&(m=c.maxCount)!=null?m:1/0;c.required&&g.length===0&&o.push(`${s}: ${k("required",b)}`),g.length<E&&o.push(`${s}: ${k("minItems",b,{min:E})}`),g.length>h&&o.push(`${s}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const s=i.querySelectorAll(`[name^="${t}\\["]`),u=[];return s.forEach(c=>{var f;const p=(f=c==null?void 0:c.value)!=null?f:"";u.push(p),l(c,null)}),d(t,u,e,c=>c!==""),{value:u,errors:o}}else{const s=i.querySelector(`[name$="${t}"]`),u=(r=s==null?void 0:s.value)!=null?r:"";if(!a&&e.required&&u===""){const c=k("required",n.state);return o.push(`${t}: ${c}`),l(s,c),{value:null,errors:o}}else l(s,null);return{value:u===""?null:u,errors:o}}}function jr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.querySelectorAll("option").forEach(d=>{d.selected=d.value===String(n[l])}),a.classList.remove("invalid"),a.title="",xe(a))}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(a=>{a.selected=a.value===String(n)}),i.classList.remove("invalid"),i.title="",xe(i))}}function lt(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function it(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function an(e){return e.classList.contains("fb-switcher-preset")}function Or(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
347
347
  display: inline-flex;
348
348
  align-items: center;
349
349
  gap: 8px;
@@ -377,7 +377,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
377
377
  display: inline-flex;
378
378
  flex-direction: row;
379
379
  flex-wrap: nowrap;
380
- `;const d=[];return i.forEach((s,u)=>{let c;a?c=Ur(s,r):(c=document.createElement("button"),c.type="button",c.className="fb-switcher-btn",c.dataset.value=s.value,c.textContent=s.label,c.style.cssText=`
380
+ `;const d=[];return i.forEach((s,u)=>{let c;a?c=Or(s,r):(c=document.createElement("button"),c.type="button",c.className="fb-switcher-btn",c.dataset.value=s.value,c.textContent=s.label,c.style.cssText=`
381
381
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
382
382
  font-size: var(--fb-font-size);
383
383
  border-width: var(--fb-border-width);
@@ -387,15 +387,15 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
387
387
  white-space: nowrap;
388
388
  line-height: 1.25;
389
389
  outline: none;
390
- `,i.length===1?c.style.borderRadius="var(--fb-border-radius)":u===0?(c.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",c.style.borderRightWidth="0"):u===i.length-1?c.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(c.style.borderRadius="0",c.style.borderRightWidth="0")),s.value===t?lt(c,a):it(c,a),r||(c.addEventListener("click",()=>{n.value=s.value,d.forEach(f=>{f.dataset.value===s.value?lt(f,a):it(f,a)}),o&&o(s.value)}),c.addEventListener("mouseenter",()=>{n.value!==s.value&&(c.style.backgroundColor="var(--fb-background-hover-color)")}),c.addEventListener("mouseleave",()=>{n.value!==s.value&&(c.style.backgroundColor=a?"var(--fb-background-color)":"transparent")})),d.push(c),l.appendChild(c)}),l}function Pr(e,t,n,r){var o,i;const a=t.state,l=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),d=document.createElement("input");d.type="hidden",d.name=r,d.value=l;const s=ae(e,a,t),u=!s&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,c=sn(e,l,d,s,u);if(n.appendChild(d),n.appendChild(c),!s){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Le(e,a),n.appendChild(f)}}function Wr(e,t,n,r){var o,i,a,l;const d=t.state,s=t.prefill[e.key]||[],u=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,f=(i=e.maxCount)!=null?i:1/0;for(;u.length<c;)u.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const p=ae(e,d,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((v,w)=>{const k=v.querySelector("input[type=hidden]");k&&(k.name=`${r}[${w}]`)})}function g(v="",w=-1){const k=w===-1?m.children.length:w,x=`${r}[${k}]`,$=document.createElement("div");$.className="multiple-switcher-item flex items-center gap-2";const z=document.createElement("input");z.type="hidden",z.name=x,z.value=v,$.appendChild(z);const B=!p&&t.instance?R=>{t.instance.triggerOnChange(z.name,R)}:null,_=sn(e,v,z,p,B);return $.appendChild(_),w===-1?m.appendChild($):m.insertBefore($,m.children[w]),b(),$}function C(){if(p)return;const v=m.querySelectorAll(".multiple-switcher-item"),w=v.length;v.forEach(k=>{let x=k.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
390
+ `,i.length===1?c.style.borderRadius="var(--fb-border-radius)":u===0?(c.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",c.style.borderRightWidth="0"):u===i.length-1?c.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(c.style.borderRadius="0",c.style.borderRightWidth="0")),s.value===t?lt(c,a):it(c,a),r||(c.addEventListener("click",()=>{n.value=s.value,d.forEach(f=>{f.dataset.value===s.value?lt(f,a):it(f,a)}),o&&o(s.value)}),c.addEventListener("mouseenter",()=>{n.value!==s.value&&(c.style.backgroundColor="var(--fb-background-hover-color)")}),c.addEventListener("mouseleave",()=>{n.value!==s.value&&(c.style.backgroundColor=a?"var(--fb-background-color)":"transparent")})),d.push(c),l.appendChild(c)}),l}function Ur(e,t,n,r){var o,i;const a=t.state,l=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),d=document.createElement("input");d.type="hidden",d.name=r,d.value=l;const s=ae(e,a,t),u=!s&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,c=sn(e,l,d,s,u);if(n.appendChild(d),n.appendChild(c),!s){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Le(e,a),n.appendChild(f)}}function Pr(e,t,n,r){var o,i,a,l;const d=t.state,s=t.prefill[e.key]||[],u=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,f=(i=e.maxCount)!=null?i:1/0;for(;u.length<c;)u.push(e.default||((l=(a=e.options)==null?void 0:a[0])==null?void 0:l.value)||"");const p=ae(e,d,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((v,C)=>{const w=v.querySelector("input[type=hidden]");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=C===-1?m.children.length:C,x=`${r}[${w}]`,S=document.createElement("div");S.className="multiple-switcher-item flex items-center gap-2";const I=document.createElement("input");I.type="hidden",I.name=x,I.value=v,S.appendChild(I);const D=!p&&t.instance?N=>{t.instance.triggerOnChange(I.name,N)}:null,V=sn(e,v,I,p,D);return S.appendChild(V),C===-1?m.appendChild(S):m.insertBefore(S,m.children[C]),b(),S}function E(){if(p)return;const v=m.querySelectorAll(".multiple-switcher-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
391
391
  color: var(--fb-error-color);
392
392
  background-color: transparent;
393
393
  transition: background-color var(--fb-transition-duration);
394
- `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const z=Array.from(m.children).indexOf(k);m.children.length>c&&(u.splice(z,1),k.remove(),b(),y(),C())},k.appendChild(x));const $=w<=c;x.disabled=$,x.style.opacity=$?"0.5":"1",x.style.pointerEvents=$?"none":"auto"})}let h=null;if(!p){const v=Fe("switcher",()=>{var w,k;const x=e.default||((k=(w=e.options)==null?void 0:w[0])==null?void 0:k.value)||"";u.push(x),g(x),y(),C()},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(u.length,f)}if(u.forEach(v=>g(v)),y(),C(),!p){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,d),n.appendChild(v)}}function Vr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(u,c)=>{var f,p;if(!u)return;const m=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);c?(u.classList.add("invalid"),u.title=c,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
394
+ `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const I=Array.from(m.children).indexOf(w);m.children.length>c&&(u.splice(I,1),w.remove(),b(),y(),E())},w.appendChild(x));const S=C<=c;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!p){const v=Fe("switcher",()=>{var C,w;const x=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";u.push(x),g(x),y(),E()},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(u.length,f)}if(u.forEach(v=>g(v)),y(),E(),!p){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,d),n.appendChild(v)}}function Wr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(u,c)=>{var f,p;if(!u)return;const m=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);c?(u.classList.add("invalid"),u.title=c,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
395
395
  color: var(--fb-error-color);
396
396
  font-size: var(--fb-font-size-small);
397
397
  margin-top: 0.25rem;
398
- `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(b,u.nextSibling):(p=u.parentNode)==null||p.appendChild(b)),b.textContent=c,b.style.display="block"):(u.classList.remove("invalid"),u.title="",b&&b.remove())},d=(u,c,f,p)=>{var m,b;if(a)return;const{state:g}=n,C=c.filter(p),h="minCount"in f&&(m=f.minCount)!=null?m:0,y="maxCount"in f&&(b=f.maxCount)!=null?b:1/0;f.required&&C.length===0&&o.push(`${u}: ${E("required",g)}`),C.length<h&&o.push(`${u}: ${E("minItems",g,{min:h})}`),C.length>y&&o.push(`${u}: ${E("maxItems",g,{max:y})}`)},s=new Set("options"in e?e.options.map(u=>u.value):[]);if("multiple"in e&&e.multiple){const u=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),c=[];return u.forEach(f=>{var p;const m=(p=f==null?void 0:f.value)!=null?p:"";if(c.push(m),!a&&m!==""&&!s.has(m)){const b=E("invalidOption",n.state);l(f,b),o.push(`${t}: ${b}`)}else l(f,null)}),d(t,c,e,f=>f!==""),{value:c,errors:o}}else{const u=i.querySelector(`input[type="hidden"][name$="${t}"]`),c=(r=u==null?void 0:u.value)!=null?r:"";if(!a&&e.required&&c===""){const f=E("required",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}if(!a&&c!==""&&!s.has(c)){const f=E("invalidOption",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}return l(u,null),{value:c===""?null:c,errors:o}}}function Kr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);a.forEach((l,d)=>{var s;if(d<n.length){const u=n[d]!=null?String(n[d]):"";l.value=u;const c=(s=l.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(f=>{const p=an(f);f.dataset.value===u?lt(f,p):it(f,p)}),l.classList.remove("invalid"),l.title="",xe(l)}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const l=n!=null?String(n):"";a.value=l;const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(s=>{const u=an(s);s.dataset.value===l?lt(s,u):it(s,u)}),a.classList.remove("invalid"),a.title="",xe(a)}}}const dn=36,Je=20,De=16;function _r(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
398
+ `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(b,u.nextSibling):(p=u.parentNode)==null||p.appendChild(b)),b.textContent=c,b.style.display="block"):(u.classList.remove("invalid"),u.title="",b&&b.remove())},d=(u,c,f,p)=>{var m,b;if(a)return;const{state:g}=n,E=c.filter(p),h="minCount"in f&&(m=f.minCount)!=null?m:0,y="maxCount"in f&&(b=f.maxCount)!=null?b:1/0;f.required&&E.length===0&&o.push(`${u}: ${k("required",g)}`),E.length<h&&o.push(`${u}: ${k("minItems",g,{min:h})}`),E.length>y&&o.push(`${u}: ${k("maxItems",g,{max:y})}`)},s=new Set("options"in e?e.options.map(u=>u.value):[]);if("multiple"in e&&e.multiple){const u=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),c=[];return u.forEach(f=>{var p;const m=(p=f==null?void 0:f.value)!=null?p:"";if(c.push(m),!a&&m!==""&&!s.has(m)){const b=k("invalidOption",n.state);l(f,b),o.push(`${t}: ${b}`)}else l(f,null)}),d(t,c,e,f=>f!==""),{value:c,errors:o}}else{const u=i.querySelector(`input[type="hidden"][name$="${t}"]`),c=(r=u==null?void 0:u.value)!=null?r:"";if(!a&&e.required&&c===""){const f=k("required",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}if(!a&&c!==""&&!s.has(c)){const f=k("invalidOption",n.state);return o.push(`${t}: ${f}`),l(u,f),{value:null,errors:o}}return l(u,null),{value:c===""?null:c,errors:o}}}function Vr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);a.forEach((l,d)=>{var s;if(d<n.length){const u=n[d]!=null?String(n[d]):"";l.value=u;const c=(s=l.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(f=>{const p=an(f);f.dataset.value===u?lt(f,p):it(f,p)}),l.classList.remove("invalid"),l.title="",xe(l)}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const l=n!=null?String(n):"";a.value=l;const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(s=>{const u=an(s);s.dataset.value===l?lt(s,u):it(s,u)}),a.classList.remove("invalid"),a.title="",xe(a)}}}const dn=36,Je=20,De=16;function Kr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
399
399
  .fb-toggle {
400
400
  position: relative;
401
401
  display: inline-block;
@@ -475,7 +475,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
475
475
  font-family: serif;
476
476
  cursor: help;
477
477
  }
478
- `,e.head.appendChild(n)}function kt(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function Jr(e,t,n,r){var o;_r(document);const i=t.state,a=ae(e,i,t),l=t.prefill[e.key],d=kt(l!==void 0?l:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.value=d?"true":"false";const u=document.createElement("div");u.className="fb-toggle-row",u.setAttribute("role","switch"),u.setAttribute("aria-checked",d?"true":"false"),a?u.setAttribute("aria-disabled","true"):u.tabIndex=0;const c=document.createElement("span");c.className="fb-toggle"+(d?" fb-on":""),c.setAttribute("aria-hidden","true"),u.appendChild(c);const f=document.createElement("div");f.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(f.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,f.appendChild(m)}if(u.appendChild(f),!a){const m=()=>{const b=s.value!=="true";s.value=b?"true":"false",c.classList.toggle("fb-on",b),u.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};u.addEventListener("click",b=>{var g;(g=b.target)!=null&&g.classList.contains("fb-toggle-info")||m()}),u.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(s),n.appendChild(u)}function Yr(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";return{value:kt(a),errors:[]}}function Xr(e,t,n,r){var o;const{scopeRoot:i}=r,a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(!a)return;const l=kt(n);a.value=l?"true":"false";const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(d){d.setAttribute("aria-checked",l?"true":"false");const s=d.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",l)}}function ze(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function je(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function cn(e,t){return t===1/0?!0:e<=t*1024*1024}function at(e,t){return cn(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Xe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function Gr(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function st(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Gr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function $t(e,t){for(const n of e)st(n,t)}const un="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(un))return;const e=document.createElement("style");if(e.id=un,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
478
+ `,e.head.appendChild(n)}function kt(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function _r(e,t,n,r){var o;Kr(document);const i=t.state,a=ae(e,i,t),l=t.prefill[e.key],d=kt(l!==void 0?l:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.value=d?"true":"false";const u=document.createElement("div");u.className="fb-toggle-row",u.setAttribute("role","switch"),u.setAttribute("aria-checked",d?"true":"false"),a?u.setAttribute("aria-disabled","true"):u.tabIndex=0;const c=document.createElement("span");c.className="fb-toggle"+(d?" fb-on":""),c.setAttribute("aria-hidden","true"),u.appendChild(c);const f=document.createElement("div");f.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(f.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,f.appendChild(m)}if(u.appendChild(f),!a){const m=()=>{const b=s.value!=="true";s.value=b?"true":"false",c.classList.toggle("fb-on",b),u.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};u.addEventListener("click",b=>{var g;(g=b.target)!=null&&g.classList.contains("fb-toggle-info")||m()}),u.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(s),n.appendChild(u)}function Jr(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";return{value:kt(a),errors:[]}}function Yr(e,t,n,r){var o;const{scopeRoot:i}=r,a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(!a)return;const l=kt(n);a.value=l?"true":"false";const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(d){d.setAttribute("aria-checked",l?"true":"false");const s=d.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",l)}}function Ie(e){return e?typeof e=="object"&&Array.isArray(e.extensions)?e.extensions.map(t=>t.toLowerCase()):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(t=>t.startsWith(".")).map(t=>t.substring(1).toLowerCase()):[]:[]}function je(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function cn(e,t){return t===1/0?!0:e<=t*1024*1024}function at(e,t){return cn(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Xe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function Xr(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function st(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Xr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function $t(e,t){for(const n of e)st(n,t)}const un="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(un))return;const e=document.createElement("style");if(e.id=un,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
479
479
  @keyframes fb-spin { to { transform: rotate(360deg); } }
480
480
 
481
481
  /* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
@@ -722,34 +722,12 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
722
722
  padding: 6px;
723
723
  }
724
724
 
725
- /* \u2500\u2500\u2500 Meta line below multi grid \u2500\u2500\u2500 */
726
- .fb-meta-line {
725
+ /* \u2500\u2500\u2500 Clear-all row below multi grid \u2500\u2500\u2500 */
726
+ .fb-clear-all-row {
727
727
  margin-top: 10px;
728
728
  display: flex;
729
729
  align-items: center;
730
- justify-content: space-between;
731
- gap: 8px;
732
- flex-wrap: wrap;
733
- }
734
- .fb-meta-text {
735
- font-size: 12px;
736
- color: #94a3b8;
737
- display: flex;
738
- align-items: center;
739
- gap: 8px;
740
- flex-wrap: wrap;
741
- }
742
- .fb-meta-dot {
743
- width: 4px;
744
- height: 4px;
745
- border-radius: 50%;
746
- background: #cbd5e1;
747
- flex-shrink: 0;
748
- }
749
- .fb-meta-mono {
750
- font-family: ui-monospace, 'JetBrains Mono', monospace;
751
- font-size: 11px;
752
- letter-spacing: -0.02em;
730
+ justify-content: flex-end;
753
731
  }
754
732
  .fb-clear-all-btn {
755
733
  font-size: 12px;
@@ -988,55 +966,55 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
988
966
  color: var(--fb-error-color);
989
967
  font-size: var(--fb-font-size-small);
990
968
  margin-top: 0.25rem;
991
- `,i.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(i)}function Ge(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Zr(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=E("removeElement",t),i.onclick=a=>{a.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Qr(e,t){$e();const n=fn();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
969
+ `,i.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(i)}function Ge(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Gr(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=k("removeElement",t),i.onclick=a=>{a.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Zr(e,t){$e();const n=fn();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
992
970
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
993
971
  <div class="fb-spinner"></div>
994
972
  <div class="fb-tile-label">${se(r)}</div>
995
- <div class="fb-tile-uploading-text">${se(E("uploadingFile",t))}</div>
973
+ <div class="fb-tile-uploading-text">${se(k("uploadingFile",t))}</div>
996
974
  </div>`,n}function St(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const i=e.querySelector(".fb-tiles-wrap");if(i)return i;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const a=document.createElement("div");a.className="fb-tiles-wrap",a.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const l=document.createElement("div");return l.className="fb-tile fb-tile-add",l.innerHTML="+",a.appendChild(l),e.appendChild(a),a}function Lt(e,t,n){e.innerHTML=`
997
975
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
998
976
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
999
977
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
1000
978
  </svg>
1001
- <div class="text-sm text-center">${se(E("clickDragText",t))}</div>
979
+ <div class="text-sm text-center">${se(k("clickDragText",t))}</div>
1002
980
 
1003
981
  </div>
1004
- `}const pn=new WeakMap;function dt(e,t){const n=pn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=a=>{var l;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const d=(l=a.dataTransfer)==null?void 0:l.files;d&&t(d)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),pn.set(e,{dragover:r,dragleave:o,drop:i})}const eo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',to='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',no='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',ro='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',oo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function lo(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function io(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Tt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:a,replaceHandler:l,libraryHandler:d}=e,s=document.createElement("div");s.className="fb-tile-actions";const u=(c,f,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=c,m.title=f,m.setAttribute("aria-label",f),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(l){const c=u(ro,E("replaceFile",r),"fb-tile-action-replace");c.addEventListener("click",()=>l()),s.appendChild(c)}if(d){const c=u(oo,E("fromLibrary",r),"fb-tile-action-library");c.addEventListener("click",()=>d()),s.appendChild(c)}if(lo(r,a)){const c=u(eo,E("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{ao(o,i,r,a)}),s.appendChild(c)}if(io(r,a)){const c=u(to,E("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{so(o,r,a).catch(f=>{console.error("Open failed:",f)})}),s.appendChild(c)}if(t&&n){const c=u(no,E("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),s.appendChild(c)}return s}const ct=new WeakMap;function At(e){let t=ct.get(e);return t||(t=URL.createObjectURL(e),ct.set(e,t)),t}function qe(e){if(!e)return;const t=ct.get(e);t&&(URL.revokeObjectURL(t),ct.delete(e))}function ao(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){xn(r.file,t||r.file.name);return}yn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function so(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=At(n.file)),r&&window.open(r,"_blank")}let we=null,Me=null,Re=null,ut=null;function co(){if(!we){we=document.createElement("div"),we.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",we.appendChild(e),we.addEventListener("mouseenter",hn),we.addEventListener("mouseleave",mn)}return we}function uo(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let a;n.top-r-o>=i?a=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?a=n.bottom+o:a=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let l=n.left+n.width/2-r/2;l=Math.max(i,Math.min(window.innerWidth-r-i,l)),e.style.top=`${a}px`,e.style.left=`${l}px`}function mn(){Re!==null&&clearTimeout(Re),Re=setTimeout(()=>{Re=null,bn()},100)}function hn(){Re!==null&&(clearTimeout(Re),Re=null)}function bn(){Me!==null&&(clearTimeout(Me),Me=null),we&&we.parentNode&&(we.classList.remove("fb-tile-zoom-preview--visible"),we.parentNode.removeChild(we)),ut=null}function Ft(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{hn(),ut!==e&&bn(),ut=e,Me=setTimeout(()=>{Me=null;const o=co(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),fo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",uo(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Me!==null?(clearTimeout(Me),Me=null,ut=null):mn()})}function fo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",a=>{a.stopPropagation(),i.click()})})}function po(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||E("previewAlt",r);const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(t),e.appendChild(o)}function mo(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function ho(e,t,n,r,o,i){const a=URL.createObjectURL(t),l=mo(e);return l.innerHTML=`
982
+ `}const pn=new WeakMap;function dt(e,t){const n=pn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=a=>{var l;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const d=(l=a.dataTransfer)==null?void 0:l.files;d&&t(d)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),pn.set(e,{dragover:r,dragleave:o,drop:i})}const Qr='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',eo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',to='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',no='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',ro='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function oo(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function lo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Tt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:a,replaceHandler:l,libraryHandler:d}=e,s=document.createElement("div");s.className="fb-tile-actions";const u=(c,f,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=c,m.title=f,m.setAttribute("aria-label",f),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(l){const c=u(no,k("replaceFile",r),"fb-tile-action-replace");c.addEventListener("click",()=>l()),s.appendChild(c)}if(d){const c=u(ro,k("fromLibrary",r),"fb-tile-action-library");c.addEventListener("click",()=>d()),s.appendChild(c)}if(oo(r,a)){const c=u(Qr,k("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{io(o,i,r,a)}),s.appendChild(c)}if(lo(r,a)){const c=u(eo,k("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{ao(o,r,a).catch(f=>{console.error("Open failed:",f)})}),s.appendChild(c)}if(t&&n){const c=u(to,k("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),s.appendChild(c)}return s}const ct=new WeakMap;function At(e){let t=ct.get(e);return t||(t=URL.createObjectURL(e),ct.set(e,t)),t}function qe(e){if(!e)return;const t=ct.get(e);t&&(URL.revokeObjectURL(t),ct.delete(e))}function io(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){xn(r.file,t||r.file.name);return}yn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function ao(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=At(n.file)),r&&window.open(r,"_blank")}let we=null,ze=null,Re=null,ut=null;function so(){if(!we){we=document.createElement("div"),we.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",we.appendChild(e),we.addEventListener("mouseenter",hn),we.addEventListener("mouseleave",mn)}return we}function co(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let a;n.top-r-o>=i?a=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?a=n.bottom+o:a=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let l=n.left+n.width/2-r/2;l=Math.max(i,Math.min(window.innerWidth-r-i,l)),e.style.top=`${a}px`,e.style.left=`${l}px`}function mn(){Re!==null&&clearTimeout(Re),Re=setTimeout(()=>{Re=null,bn()},100)}function hn(){Re!==null&&(clearTimeout(Re),Re=null)}function bn(){ze!==null&&(clearTimeout(ze),ze=null),we&&we.parentNode&&(we.classList.remove("fb-tile-zoom-preview--visible"),we.parentNode.removeChild(we)),ut=null}function Ft(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{hn(),ut!==e&&bn(),ut=e,ze=setTimeout(()=>{ze=null;const o=so(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),uo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",co(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{ze!==null?(clearTimeout(ze),ze=null,ut=null):mn()})}function uo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",a=>{a.stopPropagation(),i.click()})})}function fo(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(t),e.appendChild(o)}function po(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function mo(e,t,n,r,o,i){const a=URL.createObjectURL(t),l=po(e);return l.innerHTML=`
1005
983
  <div class="fb-video-preview-wrap">
1006
984
  <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
1007
- ${se(E("videoNotSupported",o))}
985
+ ${se(k("videoNotSupported",o))}
1008
986
  </video>
1009
987
  <div class="fb-video-btn-overlay">
1010
988
  <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
1011
- ${se(E("removeElement",o))}
989
+ ${se(k("removeElement",o))}
1012
990
  </button>
1013
991
  <button class="fb-video-btn fb-video-btn-change change-file-btn">
1014
- ${se(E("changeButton",o))}
992
+ ${se(k("changeButton",o))}
1015
993
  </button>
1016
994
  </div>
1017
995
  </div>
1018
- `,bo(l,r,o,i),l}function bo(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var l;a.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=a=>{a.stopPropagation(),vo(e,t,n,r)})}function vo(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
996
+ `,ho(l,r,o,i),l}function ho(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var l;a.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=a=>{a.stopPropagation(),bo(e,t,n,r)})}function bo(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
1019
997
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1020
998
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1021
999
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
1022
1000
  </svg>
1023
- <div style="font-size:0.875rem;text-align:center;">${se(E("clickDragText",n))}</div>
1001
+ <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1024
1002
  </div>
1025
- `,r!=null&&r.setupDrop&&r.setupDrop(e)}function vn(e,t,n){Zr(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
1003
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function vn(e,t,n){Gr(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
1026
1004
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1027
1005
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1028
1006
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
1029
1007
  </svg>
1030
- <div style="font-size:0.875rem;text-align:center;">${se(E("clickDragText",n))}</div>
1008
+ <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1031
1009
  </div>
1032
- `})}async function go(e,t,n,r,o,i,a){var l,d,s;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?po(e,t.file,n,i):(d=t.type)!=null&&d.startsWith("video/")?e=ho(e,t.file,t.type,r,i,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${se(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&vn(e,r,i))}function yo(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(E("videoNotSupported",n))),e.appendChild(r)}async function xo(e,t,n,r,o){var i;if(!o.config.getThumbnail){Lt(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(ye(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))yo(e,a,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||E("previewAlt",o),l.src=a,e.appendChild(l)}else Lt(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
1010
+ `})}async function vo(e,t,n,r,o,i,a){var l,d,s;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?fo(e,t.file,n,i):(d=t.type)!=null&&d.startsWith("video/")?e=mo(e,t.file,t.type,r,i,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${se(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&vn(e,r,i))}function go(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(k("videoNotSupported",n))),e.appendChild(r)}async function yo(e,t,n,r,o){var i;if(!o.config.getThumbnail){Lt(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(ye(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))go(e,a,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||k("previewAlt",o),l.src=a,e.appendChild(l)}else Lt(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
1033
1011
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1034
1012
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1035
1013
  <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
1036
1014
  </svg>
1037
- <div style="font-size:0.875rem;text-align:center;">${se(n||E("previewUnavailable",o))}</div>
1015
+ <div style="font-size:0.875rem;text-align:center;">${se(n||k("previewUnavailable",o))}</div>
1038
1016
  </div>
1039
- `}}async function zt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:a=!1,deps:l=null}=r;if(!a&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ye(e);const d=n.resourceIndex.get(t);if(d&&d.file&&d.file instanceof File)await go(e,d,i,t,a,n,l);else{await xo(e,t,i,d,n);const s=(o=d==null?void 0:d.type)==null?void 0:o.startsWith("video/");!a&&!s&&vn(e,t,n)}}function wo(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function Mt(e,t,n,r={}){var o,i;const a=t.resourceIndex.get(e),l=wo(e,a,n),{canRemove:d=!1,removeHandler:s=null}=r,u=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),c=((i=a==null?void 0:a.type)==null?void 0:i.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=fn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",l&&(f.title=l);const p=(a==null?void 0:a.file)instanceof File?At(a.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;f.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):yn(e,l,t).catch(y=>{console.error("Download failed:",y)})};const b=Tt({canRemove:d,removeHandler:s,state:t,resourceId:e,fileName:l,meta:a}),g=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},C=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(b)};if(u){const h=await g();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=l,y.src=h,f.appendChild(y),f.appendChild(b),Ft(f,h,l,b)}else C()}else if(c)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
1017
+ `}}async function zt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:a=!1,deps:l=null}=r;if(!a&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ye(e);const d=n.resourceIndex.get(t);if(d&&d.file&&d.file instanceof File)await vo(e,d,i,t,a,n,l);else{await yo(e,t,i,d,n);const s=(o=d==null?void 0:d.type)==null?void 0:o.startsWith("video/");!a&&!s&&vn(e,t,n)}}function xo(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function Mt(e,t,n,r={}){var o,i;const a=t.resourceIndex.get(e),l=xo(e,a,n),{canRemove:d=!1,removeHandler:s=null}=r,u=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),c=((i=a==null?void 0:a.type)==null?void 0:i.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=fn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",l&&(f.title=l);const p=(a==null?void 0:a.file)instanceof File?At(a.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;f.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):yn(e,l,t).catch(y=>{console.error("Download failed:",y)})};const b=Tt({canRemove:d,removeHandler:s,state:t,resourceId:e,fileName:l,meta:a}),g=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},E=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(b)};if(u){const h=await g();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=l,y.src=h,f.appendChild(y),f.appendChild(b),Ft(f,h,l,b)}else E()}else if(c)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
1040
1018
  <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(l)}" src="${h}">
1041
1019
  <div class="fb-video-overlay">
1042
1020
  <div class="fb-play-btn" style="width:22px;height:22px;">
@@ -1047,7 +1025,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1047
1025
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1048
1026
  <div style="font-size:36px;">\u{1F4C1}</div>
1049
1027
  ${h}
1050
- </div>`,f.appendChild(b)}return f}async function Co(e,t,n,r){var o,i,a;const l=n.resourceIndex.get(t),d=(i=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?i:"",s=(a=r.onRemove)!=null?a:null,u=await Mt(t,n,d,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),ye(e),e.appendChild(u)}async function gn(e,t,n,r,o){var i,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=At(n.file),e.appendChild(l),Ft(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const d=document.createElement("img");d.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",d.alt=n.name,d.src=l,e.appendChild(d),Ft(e,l,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(l){const d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
1028
+ </div>`,f.appendChild(b)}return f}async function wo(e,t,n,r){var o,i,a;const l=n.resourceIndex.get(t),d=(i=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?i:"",s=(a=r.onRemove)!=null?a:null,u=await Mt(t,n,d,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),ye(e),e.appendChild(u)}async function gn(e,t,n,r,o){var i,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=At(n.file),e.appendChild(l),Ft(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const d=document.createElement("img");d.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",d.alt=n.name,d.src=l,e.appendChild(d),Ft(e,l,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(l){const d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
1051
1029
  <video style="width:100%;height:100%;" preload="metadata" muted src="${l}"></video>
1052
1030
  <div class="fb-video-overlay">
1053
1031
  <div class="fb-play-btn" style="width:20px;height:20px;">
@@ -1059,15 +1037,15 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1059
1037
  <div class="fb-play-btn" style="width:20px;height:20px;">
1060
1038
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1061
1039
  </div>
1062
- </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else Eo(e,t,n,o)}function Eo(e,t,n,r){var o,i;const a=(i=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?i:"";a&&(e.title=a);const l=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${se(a)}</div>`:"";e.innerHTML=`
1040
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const d=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else Co(e,t,n,o)}function Co(e,t,n,r){var o,i;const a=(i=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?i:"";a&&(e.title=a);const l=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${se(a)}</div>`:"";e.innerHTML=`
1063
1041
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1064
1042
  <div style="font-size:36px;">\u{1F4C1}</div>
1065
1043
  ${l}
1066
- </div>`,r&&e.appendChild(r)}async function yn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const a=await i.blob();xn(a,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function xn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`,{cause:n})}}async function wn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function ko(e){var t,n,r;const{file:o,container:i,fieldName:a,state:l,deps:d=null,instance:s=null,allowedExtensions:u=[],allowedMimes:c=[],maxSizeMB:f=1/0}=e;if(!je(o.name,u)){const h=u.join(", ");Se(i,E("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Xe(o.type,c)){const h=c.join(", ");Se(i,E("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!at(o,f)){Se(i,E("fileTooLarge",l,{name:o.name,maxSize:f}));return}Ge(i);const p=(t=i.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),i.innerHTML=`
1044
+ </div>`,r&&e.appendChild(r)}async function yn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const a=await i.blob();xn(a,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function xn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`,{cause:n})}}async function wn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function Eo(e){var t,n,r;const{file:o,container:i,fieldName:a,state:l,deps:d=null,instance:s=null,allowedExtensions:u=[],allowedMimes:c=[],maxSizeMB:f=1/0}=e;if(!je(o.name,u)){const h=u.join(", ");Se(i,k("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Xe(o.type,c)){const h=c.join(", ");Se(i,k("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!at(o,f)){Se(i,k("fileTooLarge",l,{name:o.name,maxSize:f}));return}Ge(i);const p=(t=i.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),i.innerHTML=`
1067
1045
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
1068
1046
  <div class="fb-spinner"></div>
1069
- <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(E("uploadingFile",l))}</div>
1070
- </div>`;let b;try{b=await wn(o,l)}catch(h){throw m&&d!=null&&d.onAfterUpload?d.onAfterUpload(i,m):d!=null&&d.onRemove?d.onRemove():Lt(i,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=l.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=a,(r=i.parentElement)==null||r.appendChild(g)),g.value=b;const C=o.type.startsWith("video/");!C&&d!=null&&d.onAfterUpload?d.onAfterUpload(i,b):!C&&d?Co(i,b,l,d).catch(console.error):zt(i,b,l,{fileName:o.name,isReadonly:!1,deps:d}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(a,b)}function $o(e,t,n,r){const o=e.filter(m=>!je(m.name,n.allowedExtensions)),i=e.filter(m=>je(m.name,n.allowedExtensions)),a=i.filter(m=>!Xe(m.type,n.allowedMimes)),l=i.filter(m=>Xe(m.type,n.allowedMimes)),d=l.filter(m=>!at(m,n.maxSize)),s=l.filter(m=>at(m,n.maxSize)),u=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),c=s.slice(0,u),f=s.length-c.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(E("invalidFileExtension",r,{name:b,formats:m}))}if(a.length>0){const m=n.allowedMimes.join(", "),b=a.map(g=>g.name).join(", ");p.push(E("invalidFileMime",r,{name:b,type:a.map(g=>g.type).join(", "),mimes:m}))}if(d.length>0){const m=d.map(b=>b.name).join(", ");p.push(E("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&p.push(E("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:c,errorMessage:p.join(" \u2022 ")}}async function So(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:i,buildSuccessTile:a,prepareForUpload:l}=e;if(r&&i){const u=St(r),c=(t=u.querySelector(".fb-multi-add-tile-js"))!=null?t:u.querySelector(".fb-tile-add");c&&(c.style.display="none")}l==null||l();const d=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(u,c)=>{const f=Qr(u.name,o);r&&St(r).appendChild(f);try{const p=await wn(u,o);o.resourceIndex.set(p,{name:u.name,type:u.type,size:u.size,uploadedAt:new Date,file:u}),d[c]=p,a&&f.parentNode?f.replaceWith(a(p)):f.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,g=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:u,error:g}),f.remove()}})),{failures:s,orderedIds:d}}function Lo(e,t,n){if(t.length===0)return e;const r=t.map(o=>E("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Cn(e,t,n,r){const{resourceIds:o,state:i,updateCallback:a,constraints:l,pathKey:d,instance:s,buildSuccessTile:u,prepareForUpload:c,coordinator:f}=e,{accepted:p,errorMessage:m}=$o(t,f.getOccupiedCount(),l,i);r&&(m?Se(r,m):Ge(r));const b=f.beginBatch(p.length),g=f.getOccupiedCount()>=l.maxCount,{failures:C,orderedIds:h}=await So({accepted:p,listEl:n,state:i,shouldHideAddTile:g,buildSuccessTile:u,prepareForUpload:c});b.setResults(h),s&&d&&!i.config.readonly&&s.triggerOnChange(d,o);const{wasLast:y}=b.end();if(y&&a(),r){const v=Lo(m,C,i);v?Se(r,v):Ge(r)}}function To(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function Ao(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,i=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),i,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=ze(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(l=>l.toLowerCase());if(i.length===0&&o.length===0)return;const a={};return i.length>0&&(a.extensions=i),o.length>0&&(a.mime=o),a}function kn(e,t,n,r,o){if(!je(e.name,t)){const i=t.join(", ");return E("invalidFileExtension",o,{name:e.name,formats:i})}if(!Xe(e.type,n)){const i=n.join(", ");return E("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return cn(e.size,r)?null:E("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function Sn(e,t){return e instanceof Error&&e.message?e.message:E("pickerError",t)}async function Fo(e){var t;const{state:n,element:r,wrapper:o,fieldPath:i,resourceIds:a,maxCount:l,updateCallback:d,instance:s,coordinator:u,list:c,buildSuccessTile:f}=e;if(!n.config.pickExistingFiles)return;const p=ze(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,g=u.getAllKnownRids(),C=new Set(g),h=l===1/0?1/0:Math.max(0,l-u.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:i,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:g})}catch(R){Se(o,Sn(R,n));return}if(y.length===0)return;const v=new Set,w=y.filter(R=>C.has(R.resourceId)||v.has(R.resourceId)?!1:(v.add(R.resourceId),!0)).filter(R=>kn(R,p,m,b,n)===null),k=l===1/0?w.length:Math.max(0,l-u.getOccupiedCount()),x=w.slice(0,k),$=w.length-x.length;if(x.length===0){$>0&&Se(o,E("filesLimitExceeded",n,{skipped:$,max:l}));return}Ge(o),$>0&&Se(o,E("filesLimitExceeded",n,{skipped:$,max:l}));for(const R of x)$n(R,n);const z=x.map(R=>R.resourceId),B=u.beginBatch(x.length);B.setResults(z),n.config.readonly||s.triggerOnChange(i,a);const{wasLast:_}=B.end();if(_)d();else{const R=St(c);for(const N of z)R.appendChild(f(N))}}async function zo(e,t,n,r,o,i,a,l){var d,s;if(!e.config.pickExistingFiles)return;const u=ze(t.accept),c=Ye(t.accept),f=(d=t.maxSize)!=null?d:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:En(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,u,c,f,e);if(b!==null){Se(n,b);return}Ge(n),$n(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const C=g.value||null;C&&C!==m.resourceId&&qe((s=e.resourceIndex.get(C))==null?void 0:s.file),g.value=m.resourceId,await a(m.resourceId),e.config.readonly||l.triggerOnChange(i,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function Mo(e,t,n,r,o,i,a){var l;st(e,o.resourceIndex);const d=o.resourceIndex.get(e);(l=d==null?void 0:d.type)!=null&&l.startsWith("video/")?zt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Nt(t,e,o,i,a);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function No(e,t,n,r,o=!1,i=""){$e();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const d=document.createElement("span");d.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",d.innerHTML=Ln,l.appendChild(d);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=E(o?"dropToUpload":"clickDragText",e),l.appendChild(s),i){const u=document.createElement("div");u.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",u.textContent=i,l.appendChild(u)}if(l.onclick=u=>{u.stopPropagation(),n()},a.appendChild(l),t&&r){const u=document.createElement("button");u.type="button",u.className="fb-wide-tile-library fb-file-library-card";const c=document.createElement("span");c.className="fb-wide-tile-library-icon",c.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",c.innerHTML=Tn,u.appendChild(c);const f=document.createElement("div");f.className="fb-wide-tile-library-label",f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=E("fromLibrary",e),u.appendChild(f);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=E("libraryHint",e),u.appendChild(p),u.onclick=m=>{m.stopPropagation(),r()},a.appendChild(u)}return An(a,{onEnter:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=E("dropToUpload",e))},onLeave:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=E("clickDragText",e))},activeClass:"fb-drag-over"}),a}function An(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Nt(e,t,n,r,o){var i,a;const l=n.resourceIndex.get(t);if((i=l==null?void 0:l.type)!=null&&i.startsWith("video/")){zt(e,t,n,{fileName:(a=l==null?void 0:l.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const d=document.createElement("div");d.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",d.appendChild(s);const u=It(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(s.appendChild(u),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(d)}function Io(e,t,n,r,o=!1){const i=document.createElement("div");i.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=Ln,a.appendChild(l);const d=document.createElement("span");if(d.className="fb-multi-add-label",d.style.cssText="font-size:11px;font-weight:600;",d.textContent=E(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(d),a.onclick=s=>{s.stopPropagation(),n()},i.appendChild(a),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",i.appendChild(s);const u=document.createElement("button");u.type="button",u.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",u.setAttribute("aria-label",E("fromLibrary",e));const c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=Tn,u.appendChild(c),u.appendChild(document.createTextNode(E("fromLibrary",e))),u.onclick=f=>{f.stopPropagation(),r()},i.appendChild(u)}return i}function It(e,t,n,r,o){var i,a,l;$e();const d=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const u=Tt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(i=d==null?void 0:d.name)!=null?i:"",meta:d,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return gn(s,e,d,t,u).catch(c=>{console.error("Failed to render tile:",c)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function qo(e,t,n,r,o,i){const a=document.createElement("div");a.className="fb-meta-line";const l=document.createElement("div");if(l.className="fb-meta-text",t.maxSize&&t.maxSize!==1/0){const u=document.createElement("span");u.textContent=E("hintMaxSize",e,{size:t.maxSize}),l.appendChild(u),l.appendChild(zn())}const d=ze(t.accept);if(d.length>0){const u=document.createElement("span");u.className="fb-meta-mono",u.textContent=d.map(c=>c.toUpperCase()).join(", "),l.appendChild(u),l.appendChild(zn())}const s=document.createElement("span");if(r<1/0)s.textContent=E("fileCountWithMax",e,{count:n,max:r});else{const u=n===1?"fileCountSingle":"fileCountPlural";s.textContent=E(u,e,{count:n})}if(l.appendChild(s),a.appendChild(l),o&&n>1){const u=document.createElement("button");u.type="button",u.className="fb-clear-all-btn",u.textContent=E("clearAll",e),u.onclick=c=>{c.stopPropagation(),window.confirm(E("clearAll",e)+"?")&&i()},a.appendChild(u)}return a}function zn(){const e=document.createElement("span");return e.className="fb-meta-dot",e}const Ze=new WeakMap;function Ro(e){const t=Ze.get(e);t&&(t.disconnect(),Ze.delete(e)),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Bo(e){var t;const{container:n,rids:r,state:o,onRemove:i,maxCount:a,isReadonly:l=!1,onLibraryPick:d,element:s,onClearAll:u,openPicker:c}=e;$e();const f=n.closest("[data-files-wrapper]");f&&(f.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const p=Ze.get(n);for(p&&(p.disconnect(),Ze.delete(n));n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],b=a!=null?a:1/0,g=b!==1/0&&m.length>=b,C=!l&&typeof d=="function",h=c!=null?c:(()=>{var x;const $=(x=n.closest("[data-files-wrapper]"))==null?void 0:x.querySelector('input[type="file"]');$&&$.click()});if(l){if(m.length===0){const x=document.createElement("div");x.className="fb-tile-empty-text",x.textContent=E("noFilesSelected",o),n.appendChild(x)}else{const x=document.createElement("div");x.className="fb-multi-readonly-grid",n.appendChild(x);for(const $ of m){const z=o.resourceIndex.get($),B=document.createElement("div");B.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",B.dataset.resourceId=$;const _=Tt({canRemove:!1,removeHandler:null,state:o,resourceId:$,fileName:(t=z==null?void 0:z.name)!=null?t:"",meta:z});gn(B,$,z,o,_).catch(console.error),B.onclick=async()=>{var R;let N=null;o.config.getDownloadUrl?N=o.config.getDownloadUrl($):o.config.getThumbnail?N=await o.config.getThumbnail($):(z==null?void 0:z.file)instanceof File&&(N=URL.createObjectURL(z.file)),N?window.open(N,"_blank"):o.config.downloadFile&&o.config.downloadFile($,(R=z==null?void 0:z.name)!=null?R:"")},x.appendChild(B)}}return}const y=document.createElement("div");y.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const v=document.createElement("div");v.className="fb-multi-grid fb-tiles-wrap",y.appendChild(v),n.appendChild(y);for(let x=0;x<m.length;x++){const $=m[x],z=It($,o,i!==null,i?()=>i($):null);v.appendChild(z)}if(!g){const x=Io(o,C,h,d!=null?d:null);v.appendChild(x)}const w=m.length+(g?0:1),k=()=>{const x=getComputedStyle(v).gridTemplateColumns,$=x?x.split(" ").filter(Boolean).length:0;if(!$)return;const z=w%$,B=z===0?0:$-z,_=b===1/0?B:Math.max(0,b-w),R=Math.min(B,_),N=v.querySelectorAll(".fb-multi-placeholder");if(N.length>R)for(let P=N.length-1;P>=R;P--)N[P].remove();else if(N.length<R)for(let P=N.length;P<R;P++)v.appendChild(Fn())};if((b===1/0||b>w)&&v.appendChild(Fn()),requestAnimationFrame(k),typeof ResizeObserver!="undefined"){const x=new ResizeObserver(()=>k());x.observe(v),Ze.set(n,x)}if(An(y,{activeClass:"fb-drag-over",onEnter:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach($=>{$.classList.add("fb-drag-over")});const x=v.querySelector(".fb-multi-add-tile-js");if(x){x.classList.add("fb-drag-over-tile");const $=x.querySelector(".fb-multi-add-label");$&&($.textContent=E("dropToUpload",o))}},onLeave:()=>{v.querySelectorAll(".fb-multi-placeholder").forEach($=>{$.classList.remove("fb-drag-over")});const x=v.querySelector(".fb-multi-add-tile-js");if(x){x.classList.remove("fb-drag-over-tile");const $=x.querySelector(".fb-multi-add-label");$&&($.textContent=E("clickDragTextMultiple",o))}}}),s){const x=qo(o,s,m.length,b,!!u,u!=null?u:(()=>{}));n.appendChild(x)}}function Ho(e,t,n,r){var o,i;const a=t.state,l=document.createElement("div");l.className="fb-row",l.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.style.display="none",d.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const u=t.prefill[e.key],c=ze(e.accept),f=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){d.click()},dragHandler(h){h.length>0&&ko({file:h[0],container:s,fieldName:r,state:a,deps:g(),instance:t.instance,allowedExtensions:c,allowedMimes:f,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&qe((h=a.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),C()}},b=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>d.click():null,libraryHandler:h?()=>{zo(a,e,s,l,r,r,async y=>{Nt(s,y,a,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:d,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Nt(h,y,a,g(),b())}}),C=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=No(a,h!==null,m.fileUploadHandler,h,!1,Le(e,a));s.appendChild(y),dt(s,m.dragHandler)};if(u){Mo(u,s,r,l,a,g(),b());const h=a.resourceIndex.get(u);(i=h==null?void 0:h.type)!=null&&i.startsWith("video/")&&dt(s,m.dragHandler)}else C();d.onchange=()=>{d.files&&d.files.length>0&&m.dragHandler(d.files)},l.appendChild(s),l.appendChild(d),n.appendChild(l)}function Mn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Nn(e,t,n,r,o){var i,a;const l=t.state,d=document.createElement("div");d.className="fb-row",d.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=Mn(e.accept);const u=document.createElement("div");u.className="files-list-wrapper";const c=document.createElement("div");c.className="files-list",d.appendChild(s),d.appendChild(u),u.appendChild(c);const f=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];$t(f,l.resourceIndex),d.dataset.resourceIds=JSON.stringify(f);const p={maxCount:o,allowedExtensions:ze(e.accept),allowedMimes:Ye(e.accept),maxSize:(a=(i=e.maxSize)!=null?i:e.maxSizeMB)!=null?a:1/0},m=()=>{s.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{Fo({state:l,element:e,wrapper:d,fieldPath:r,resourceIds:f,maxCount:o,updateCallback:g,instance:t.instance,coordinator:z,list:c,buildSuccessTile:B}).catch(N=>{console.error("Library pick failed:",N)})}:null;function g(){const N=ae(e,l);Bo({container:c,rids:f,state:l,onRemove:N?null:P=>{var J,te;qe((J=l.resourceIndex.get(P))==null?void 0:J.file);const le=f.indexOf(P);le>-1&&f.splice(le,1),z.hasInFlightBatches()?(x.add(P),(te=c.querySelector(`[data-resource-id="${P}"]`))==null||te.remove(),d.dataset.resourceIds=JSON.stringify(f)):g(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},maxCount:o<1/0?o:void 0,isReadonly:N,onLibraryPick:N?null:b,element:e,onClearAll:N?void 0:()=>{var P,J;for(const te of f)qe((P=l.resourceIndex.get(te))==null?void 0:P.file);if(f.splice(0),z.hasInFlightBatches()){const te=c.querySelectorAll("[data-resource-id]");for(const le of te){const he=le.dataset.resourceId;he&&(qe((J=l.resourceIndex.get(he))==null?void 0:J.file),x.add(he)),le.remove()}d.dataset.resourceIds=JSON.stringify(f)}else g();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},openPicker:m})}let C=0,h=0,y=0,v=0;const w=new Map,k=new Map,x=new Set,$=()=>{for(var N;w.has(v);){const P=v,J=w.get(P);w.delete(P),v+=1;const te=(N=k.get(P))!=null?N:0;k.delete(P),C-=te;for(const le of J)if(le!==null){if(x.has(le)){x.delete(le);continue}f.push(le)}}d.dataset.resourceIds=JSON.stringify(f)},z={getOccupiedCount:()=>f.length+C,getAllKnownRids:()=>{const N=[...f];for(const P of w.values())for(const J of P)J!==null&&N.push(J);return N},hasInFlightBatches:()=>h>0||k.size>0,wasRemovedDuringBatch:N=>x.has(N),beginBatch:N=>{C+=N,h+=1;const P=y++;return k.set(P,N),{setResults:J=>{w.set(P,J),$()},end:()=>{h-=1;const J=h===0&&k.size===0;return J&&x.clear(),{wasLast:J}}}}},B=N=>{const P=ae(e,l);return It(N,l,!P,P?null:()=>{var J,te,le;qe((J=l.resourceIndex.get(N))==null?void 0:J.file);const he=f.indexOf(N);if(he>-1){f.splice(he,1),z.hasInFlightBatches()?(x.add(N),(te=c.querySelector(`[data-resource-id="${N}"]`))==null||te.remove(),d.dataset.resourceIds=JSON.stringify(f)):g(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f);return}x.add(N),(le=c.querySelector(`[data-resource-id="${N}"]`))==null||le.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)})},_=()=>Ro(c),R={resourceIds:f,state:l,updateCallback:g,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:B,prepareForUpload:_,coordinator:z};To({...R,filesContainer:u}),Ao({...R,filesPicker:s}),g(),n.appendChild(d)}function Do(e,t,n,r){Nn(e,t,n,r,1/0)}function jo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Oo(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function Uo(e,t,n,r,o){var i,a;const l="minCount"in n&&(i=n.minCount)!=null?i:0,d="maxCount"in n&&(a=n.maxCount)!=null?a:1/0;n.required&&t.length===0&&o.push(`${e}: ${E("required",r)}`),t.length<l&&o.push(`${e}: ${E("minFiles",r,{min:l})}`),t.length>d&&o.push(`${e}: ${E("maxFiles",r,{max:d})}`)}function In(e,t,n,r,o){var i,a;const l="accept"in n?n.accept:void 0,d=ze(l),s=Ye(l);if(d.length===0&&s.length===0)return;const u=d.join(", "),c=s.join(", ");for(const f of t){const p=r.resourceIndex.get(f),m=(i=p==null?void 0:p.name)!=null?i:f;if(d.length>0&&!je(m,d)){o.push(`${e}: ${E("invalidFileExtension",r,{name:m,formats:u})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(a=p==null?void 0:p.type)!=null?a:"";Xe(b,s)||o.push(`${e}: ${E("invalidFileMime",r,{name:m,type:b,mimes:c})}`)}}}function qn(e,t,n,r,o){var i;const a="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(a!==1/0)for(const l of t){const d=r.resourceIndex.get(l);d&&d.size>a*1024*1024&&o.push(`${e}: ${E("fileTooLarge",r,{name:d.name,maxSize:a})}`)}}function Po(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:a}=n,l=[],d=ke(i,t),s=Oo(r,d);return o||(Uo(t,s,e,a,l),In(t,s,e,a,l),qn(t,s,e,a,l)),{value:s,errors:l}}function Wo(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:a}=n,l=[],d=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=d==null?void 0:d.value)!=null?r:"";return!i&&e.required&&s===""?(l.push(`${t}: ${E("required",a)}`),{value:null,errors:l}):(!i&&s!==""&&(In(t,[s],e,a,l),qn(t,[s],e,a,l)),{value:s||null,errors:l})}function Rn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Po(e,t,n):Wo(e,t,n)}function Vo(e,t,n,r){const o=t.state,i=t.prefill[e.key],a=typeof i=="string"?i:"";if(a){$t([a],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=a,n.appendChild(l),Mt(a,o).then(d=>{d.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(d)}).catch(console.error)}else n.appendChild(Ko(o))}function Ko(e){$e();const t=document.createElement("div");return t.style.cssText=`
1047
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",l))}</div>
1048
+ </div>`;let b;try{b=await wn(o,l)}catch(h){throw m&&d!=null&&d.onAfterUpload?d.onAfterUpload(i,m):d!=null&&d.onRemove?d.onRemove():Lt(i,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=l.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=a,(r=i.parentElement)==null||r.appendChild(g)),g.value=b;const E=o.type.startsWith("video/");!E&&d!=null&&d.onAfterUpload?d.onAfterUpload(i,b):!E&&d?wo(i,b,l,d).catch(console.error):zt(i,b,l,{fileName:o.name,isReadonly:!1,deps:d}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(a,b)}function ko(e,t,n,r){const o=e.filter(m=>!je(m.name,n.allowedExtensions)),i=e.filter(m=>je(m.name,n.allowedExtensions)),a=i.filter(m=>!Xe(m.type,n.allowedMimes)),l=i.filter(m=>Xe(m.type,n.allowedMimes)),d=l.filter(m=>!at(m,n.maxSize)),s=l.filter(m=>at(m,n.maxSize)),u=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),c=s.slice(0,u),f=s.length-c.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(a.length>0){const m=n.allowedMimes.join(", "),b=a.map(g=>g.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:a.map(g=>g.type).join(", "),mimes:m}))}if(d.length>0){const m=d.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&p.push(k("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:c,errorMessage:p.join(" \u2022 ")}}async function $o(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:i,buildSuccessTile:a,prepareForUpload:l}=e;if(r&&i){const u=St(r),c=(t=u.querySelector(".fb-multi-add-tile-js"))!=null?t:u.querySelector(".fb-tile-add");c&&(c.style.display="none")}l==null||l();const d=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(u,c)=>{const f=Zr(u.name,o);r&&St(r).appendChild(f);try{const p=await wn(u,o);o.resourceIndex.set(p,{name:u.name,type:u.type,size:u.size,uploadedAt:new Date,file:u}),d[c]=p,a&&f.parentNode?f.replaceWith(a(p)):f.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,g=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:u,error:g}),f.remove()}})),{failures:s,orderedIds:d}}function So(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Cn(e,t,n,r){const{resourceIds:o,state:i,updateCallback:a,constraints:l,pathKey:d,instance:s,buildSuccessTile:u,prepareForUpload:c,coordinator:f}=e,{accepted:p,errorMessage:m}=ko(t,f.getOccupiedCount(),l,i);r&&(m?Se(r,m):Ge(r));const b=f.beginBatch(p.length),g=f.getOccupiedCount()>=l.maxCount,{failures:E,orderedIds:h}=await $o({accepted:p,listEl:n,state:i,shouldHideAddTile:g,buildSuccessTile:u,prepareForUpload:c});b.setResults(h),s&&d&&!i.config.readonly&&s.triggerOnChange(d,o);const{wasLast:y}=b.end();if(y&&a(),r){const v=So(m,E,i);v?Se(r,v):Ge(r)}}function Lo(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function To(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,i=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),i,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Ie(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(l=>l.toLowerCase());if(i.length===0&&o.length===0)return;const a={};return i.length>0&&(a.extensions=i),o.length>0&&(a.mime=o),a}function kn(e,t,n,r,o){if(!je(e.name,t)){const i=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:i})}if(!Xe(e.type,n)){const i=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return cn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function Sn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Ao(e){var t;const{state:n,element:r,wrapper:o,fieldPath:i,resourceIds:a,maxCount:l,updateCallback:d,instance:s,coordinator:u,list:c,buildSuccessTile:f}=e;if(!n.config.pickExistingFiles)return;const p=Ie(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,g=u.getAllKnownRids(),E=new Set(g),h=l===1/0?1/0:Math.max(0,l-u.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:i,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:g})}catch(N){Se(o,Sn(N,n));return}if(y.length===0)return;const v=new Set,C=y.filter(N=>E.has(N.resourceId)||v.has(N.resourceId)?!1:(v.add(N.resourceId),!0)).filter(N=>kn(N,p,m,b,n)===null),w=l===1/0?C.length:Math.max(0,l-u.getOccupiedCount()),x=C.slice(0,w),S=C.length-x.length;if(x.length===0){S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:l}));return}Ge(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:l}));for(const N of x)$n(N,n);const I=x.map(N=>N.resourceId),D=u.beginBatch(x.length);D.setResults(I),n.config.readonly||s.triggerOnChange(i,a);const{wasLast:V}=D.end();if(V)d();else{const N=St(c);for(const R of I)N.appendChild(f(R))}}async function Fo(e,t,n,r,o,i,a,l){var d,s;if(!e.config.pickExistingFiles)return;const u=Ie(t.accept),c=Ye(t.accept),f=(d=t.maxSize)!=null?d:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:En(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,u,c,f,e);if(b!==null){Se(n,b);return}Ge(n),$n(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const E=g.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),g.value=m.resourceId,await a(m.resourceId),e.config.readonly||l.triggerOnChange(i,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function zo(e,t,n,r,o,i,a){var l;st(e,o.resourceIndex);const d=o.resourceIndex.get(e);(l=d==null?void 0:d.type)!=null&&l.startsWith("video/")?zt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Nt(t,e,o,i,a);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Mo(e,t,n,r,o=!1,i=""){$e();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const d=document.createElement("span");d.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",d.innerHTML=Ln,l.appendChild(d);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(s),i){const u=document.createElement("div");u.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",u.textContent=i,l.appendChild(u)}if(l.onclick=u=>{u.stopPropagation(),n()},a.appendChild(l),t&&r){const u=document.createElement("button");u.type="button",u.className="fb-wide-tile-library fb-file-library-card";const c=document.createElement("span");c.className="fb-wide-tile-library-icon",c.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",c.innerHTML=Tn,u.appendChild(c);const f=document.createElement("div");f.className="fb-wide-tile-library-label",f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=k("fromLibrary",e),u.appendChild(f);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),u.appendChild(p),u.onclick=m=>{m.stopPropagation(),r()},a.appendChild(u)}return An(a,{onEnter:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=k("dropToUpload",e))},onLeave:()=>{const u=a.querySelector(".fb-wide-tile-label");u&&(u.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),a}function An(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Nt(e,t,n,r,o){var i,a;const l=n.resourceIndex.get(t);if((i=l==null?void 0:l.type)!=null&&i.startsWith("video/")){zt(e,t,n,{fileName:(a=l==null?void 0:l.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const d=document.createElement("div");d.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",d.appendChild(s);const u=It(t,n,!!r.onRemove,r.onRemove?()=>{var c;return(c=r.onRemove)==null?void 0:c.call(r)}:null,o);for(s.appendChild(u),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(d)}function No(e,t,n,r,o=!1){const i=document.createElement("div");i.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=Ln,a.appendChild(l);const d=document.createElement("span");if(d.className="fb-multi-add-label",d.style.cssText="font-size:11px;font-weight:600;",d.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(d),a.onclick=s=>{s.stopPropagation(),n()},i.appendChild(a),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",i.appendChild(s);const u=document.createElement("button");u.type="button",u.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",u.setAttribute("aria-label",k("fromLibrary",e));const c=document.createElement("span");c.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",c.innerHTML=Tn,u.appendChild(c),u.appendChild(document.createTextNode(k("fromLibrary",e))),u.onclick=f=>{f.stopPropagation(),r()},i.appendChild(u)}return i}function It(e,t,n,r,o){var i,a,l;$e();const d=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const u=Tt({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(i=d==null?void 0:d.name)!=null?i:"",meta:d,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return gn(s,e,d,t,u).catch(c=>{console.error("Failed to render tile:",c)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Io(e,t,n){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=i=>{i.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const Ze=new WeakMap;function qo(e){const t=Ze.get(e);t&&(t.disconnect(),Ze.delete(e)),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Ro(e){var t;const{container:n,rids:r,state:o,onRemove:i,maxCount:a,isReadonly:l=!1,onLibraryPick:d,onClearAll:s,openPicker:u}=e;$e();const c=n.closest("[data-files-wrapper]");c&&(c.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const f=Ze.get(n);for(f&&(f.disconnect(),Ze.delete(n));n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=a!=null?a:1/0,b=m!==1/0&&p.length>=m,g=!l&&typeof d=="function",E=u!=null?u:(()=>{var w;const x=(w=n.closest("[data-files-wrapper]"))==null?void 0:w.querySelector('input[type="file"]');x&&x.click()});if(l){if(p.length===0){const w=document.createElement("div");w.className="fb-tile-empty-text",w.textContent=k("noFilesSelected",o),n.appendChild(w)}else{const w=document.createElement("div");w.className="fb-multi-readonly-grid",n.appendChild(w);for(const x of p){const S=o.resourceIndex.get(x),I=document.createElement("div");I.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",I.dataset.resourceId=x;const D=Tt({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});gn(I,x,S,o,D).catch(console.error),I.onclick=async()=>{var V;let N=null;o.config.getDownloadUrl?N=o.config.getDownloadUrl(x):o.config.getThumbnail?N=await o.config.getThumbnail(x):(S==null?void 0:S.file)instanceof File&&(N=URL.createObjectURL(S.file)),N?window.open(N,"_blank"):o.config.downloadFile&&o.config.downloadFile(x,(V=S==null?void 0:S.name)!=null?V:"")},w.appendChild(I)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const y=document.createElement("div");y.className="fb-multi-grid fb-tiles-wrap",h.appendChild(y),n.appendChild(h);for(let w=0;w<p.length;w++){const x=p[w],S=It(x,o,i!==null,i?()=>i(x):null);y.appendChild(S)}if(!b){const w=No(o,g,E,d!=null?d:null);y.appendChild(w)}const v=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=v%x,I=S===0?0:x-S,D=m===1/0?I:Math.max(0,m-v),V=Math.min(I,D),N=y.querySelectorAll(".fb-multi-placeholder");if(N.length>V)for(let R=N.length-1;R>=V;R--)N[R].remove();else if(N.length<V)for(let R=N.length;R<V;R++)y.appendChild(Fn())};if((m===1/0||m>v)&&y.appendChild(Fn()),requestAnimationFrame(C),typeof ResizeObserver!="undefined"){const w=new ResizeObserver(()=>C());w.observe(y),Ze.set(n,w)}if(An(h,{activeClass:"fb-drag-over",onEnter:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.add("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.add("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("dropToUpload",o))}},onLeave:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.remove("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.remove("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("clickDragTextMultiple",o))}}}),s){const w=Io(o,p.length,s);w&&n.appendChild(w)}}function Bo(e,t,n,r){var o,i;const a=t.state,l=document.createElement("div");l.className="fb-row",l.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.style.display="none",d.accept=zn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const u=t.prefill[e.key],c=Ie(e.accept),f=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){d.click()},dragHandler(h){h.length>0&&Eo({file:h[0],container:s,fieldName:r,state:a,deps:g(),instance:t.instance,allowedExtensions:c,allowedMimes:f,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=l.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&qe((h=a.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>d.click():null,libraryHandler:h?()=>{Fo(a,e,s,l,r,r,async y=>{Nt(s,y,a,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:d,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{Nt(h,y,a,g(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Mo(a,h!==null,m.fileUploadHandler,h,!1,Le(e,a));s.appendChild(y),dt(s,m.dragHandler)};if(u){zo(u,s,r,l,a,g(),b());const h=a.resourceIndex.get(u);(i=h==null?void 0:h.type)!=null&&i.startsWith("video/")&&dt(s,m.dragHandler)}else E();d.onchange=()=>{d.files&&d.files.length>0&&m.dragHandler(d.files)},l.appendChild(s),l.appendChild(d),n.appendChild(l)}function zn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Mn(e,t,n,r,o){var i,a;const l=t.state,d=document.createElement("div");d.className="fb-row",d.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=zn(e.accept);const u=document.createElement("div");u.className="files-list-wrapper";const c=document.createElement("div");c.className="files-list",d.appendChild(s),d.appendChild(u),u.appendChild(c);const f=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];$t(f,l.resourceIndex),d.dataset.resourceIds=JSON.stringify(f);const p={maxCount:o,allowedExtensions:Ie(e.accept),allowedMimes:Ye(e.accept),maxSize:(a=(i=e.maxSize)!=null?i:e.maxSizeMB)!=null?a:1/0},m=()=>{s.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{Ao({state:l,element:e,wrapper:d,fieldPath:r,resourceIds:f,maxCount:o,updateCallback:g,instance:t.instance,coordinator:I,list:c,buildSuccessTile:D}).catch(R=>{console.error("Library pick failed:",R)})}:null;function g(){const R=ae(e,l);Ro({container:c,rids:f,state:l,onRemove:R?null:_=>{var J,te;qe((J=l.resourceIndex.get(_))==null?void 0:J.file);const le=f.indexOf(_);le>-1&&f.splice(le,1),I.hasInFlightBatches()?(x.add(_),(te=c.querySelector(`[data-resource-id="${_}"]`))==null||te.remove(),d.dataset.resourceIds=JSON.stringify(f)):g(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},maxCount:o<1/0?o:void 0,isReadonly:R,onLibraryPick:R?null:b,onClearAll:R?void 0:()=>{var _,J;for(const te of f)qe((_=l.resourceIndex.get(te))==null?void 0:_.file);if(f.splice(0),I.hasInFlightBatches()){const te=c.querySelectorAll("[data-resource-id]");for(const le of te){const he=le.dataset.resourceId;he&&(qe((J=l.resourceIndex.get(he))==null?void 0:J.file),x.add(he)),le.remove()}d.dataset.resourceIds=JSON.stringify(f)}else g();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},openPicker:m})}let E=0,h=0,y=0,v=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var R;C.has(v);){const _=v,J=C.get(_);C.delete(_),v+=1;const te=(R=w.get(_))!=null?R:0;w.delete(_),E-=te;for(const le of J)if(le!==null){if(x.has(le)){x.delete(le);continue}f.push(le)}}d.dataset.resourceIds=JSON.stringify(f)},I={getOccupiedCount:()=>f.length+E,getAllKnownRids:()=>{const R=[...f];for(const _ of C.values())for(const J of _)J!==null&&R.push(J);return R},hasInFlightBatches:()=>h>0||w.size>0,wasRemovedDuringBatch:R=>x.has(R),beginBatch:R=>{E+=R,h+=1;const _=y++;return w.set(_,R),{setResults:J=>{C.set(_,J),S()},end:()=>{h-=1;const J=h===0&&w.size===0;return J&&x.clear(),{wasLast:J}}}}},D=R=>{const _=ae(e,l);return It(R,l,!_,_?null:()=>{var J,te,le;qe((J=l.resourceIndex.get(R))==null?void 0:J.file);const he=f.indexOf(R);if(he>-1){f.splice(he,1),I.hasInFlightBatches()?(x.add(R),(te=c.querySelector(`[data-resource-id="${R}"]`))==null||te.remove(),d.dataset.resourceIds=JSON.stringify(f)):g(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f);return}x.add(R),(le=c.querySelector(`[data-resource-id="${R}"]`))==null||le.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)})},V=()=>qo(c),N={resourceIds:f,state:l,updateCallback:g,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:D,prepareForUpload:V,coordinator:I};Lo({...N,filesContainer:u}),To({...N,filesPicker:s}),g(),n.appendChild(d)}function Ho(e,t,n,r){Mn(e,t,n,r,1/0)}function Do(e,t,n,r){var o;Mn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function jo(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function Oo(e,t,n,r,o){var i,a;const l="minCount"in n&&(i=n.minCount)!=null?i:0,d="maxCount"in n&&(a=n.maxCount)!=null?a:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<l&&o.push(`${e}: ${k("minFiles",r,{min:l})}`),t.length>d&&o.push(`${e}: ${k("maxFiles",r,{max:d})}`)}function Nn(e,t,n,r,o){var i,a;const l="accept"in n?n.accept:void 0,d=Ie(l),s=Ye(l);if(d.length===0&&s.length===0)return;const u=d.join(", "),c=s.join(", ");for(const f of t){const p=r.resourceIndex.get(f),m=(i=p==null?void 0:p.name)!=null?i:f;if(d.length>0&&!je(m,d)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:u})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(a=p==null?void 0:p.type)!=null?a:"";Xe(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:c})}`)}}}function In(e,t,n,r,o){var i;const a="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(a!==1/0)for(const l of t){const d=r.resourceIndex.get(l);d&&d.size>a*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:d.name,maxSize:a})}`)}}function Uo(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:a}=n,l=[],d=ke(i,t),s=jo(r,d);return o||(Oo(t,s,e,a,l),Nn(t,s,e,a,l),In(t,s,e,a,l)),{value:s,errors:l}}function Po(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:a}=n,l=[],d=o.querySelector(`input[name$="${t}"][type="hidden"]`),s=(r=d==null?void 0:d.value)!=null?r:"";return!i&&e.required&&s===""?(l.push(`${t}: ${k("required",a)}`),{value:null,errors:l}):(!i&&s!==""&&(Nn(t,[s],e,a,l),In(t,[s],e,a,l)),{value:s||null,errors:l})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Uo(e,t,n):Po(e,t,n)}function Wo(e,t,n,r){const o=t.state,i=t.prefill[e.key],a=typeof i=="string"?i:"";if(a){$t([a],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=a,n.appendChild(l),Mt(a,o).then(d=>{d.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(d)}).catch(console.error)}else n.appendChild(Vo(o))}function Vo(e){$e();const t=document.createElement("div");return t.style.cssText=`
1071
1049
  height: 220px;
1072
1050
  display:flex;
1073
1051
  align-items:center;
@@ -1075,7 +1053,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1075
1053
  background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
1076
1054
  border-radius:0.75rem;
1077
1055
  border:1px solid #e2e8f0;
1078
- `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(E("noFileSelected",e))}</div>`,t}function Bn(e,t,n,r,o){$t(e,t.resourceIndex),$e();const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const d=document.createElement("div");d.className="fb-tile-empty-text",d.textContent=E("noFilesSelected",t),i.appendChild(d);return}const a=document.createElement("div");a.className="fb-multi-readonly-grid",i.appendChild(a);const l=e.map(()=>{const d=document.createElement("div");return d.className="fb-readonly-tile fb-checker fb-tile",a.appendChild(d),d});for(let d=0;d<e.length;d++){const s=e[d],u=l[d],c=t.resourceIndex.get(s);Mt(s,t,c==null?void 0:c.name).then(f=>{f.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),f.dataset.resourceId=s,u.replaceWith(f)}).catch(()=>{const f=document.createElement("div");f.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",f.dataset.resourceId=s,u.replaceWith(f)})}}function _o(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Bn(i,t.state,n,r)}function Jo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Bn(i,t.state,n,r)}function Yo(e,t,n,r){ae(e,t.state,t)?Vo(e,t,n,r):Ho(e,t,n,r)}function Xo(e,t,n,r){ae(e,t.state,t)?_o(e,t,n,r):Do(e,t,n,r)}function Go(e,t,n,r){ae(e,t.state,t)?Jo(e,t,n,r):jo(e,t,n,r)}function Hn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(l=>{l&&typeof l=="string"&&st(l,i.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);a?a.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.value=n!=null?String(n):"",n&&typeof n=="string"&&(st(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Oe(e){return e?e.toUpperCase():"#000000"}function qt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Dn(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function jn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Oe(e),r=document.createElement("div");r.style.cssText=`
1056
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function Rn(e,t,n,r,o){$t(e,t.resourceIndex),$e();const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const d=document.createElement("div");d.className="fb-tile-empty-text",d.textContent=k("noFilesSelected",t),i.appendChild(d);return}const a=document.createElement("div");a.className="fb-multi-readonly-grid",i.appendChild(a);const l=e.map(()=>{const d=document.createElement("div");return d.className="fb-readonly-tile fb-checker fb-tile",a.appendChild(d),d});for(let d=0;d<e.length;d++){const s=e[d],u=l[d],c=t.resourceIndex.get(s);Mt(s,t,c==null?void 0:c.name).then(f=>{f.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),f.dataset.resourceId=s,u.replaceWith(f)}).catch(()=>{const f=document.createElement("div");f.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",f.dataset.resourceId=s,u.replaceWith(f)})}}function Ko(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Rn(i,t.state,n,r)}function _o(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Rn(i,t.state,n,r)}function Jo(e,t,n,r){ae(e,t.state,t)?Wo(e,t,n,r):Bo(e,t,n,r)}function Yo(e,t,n,r){ae(e,t.state,t)?Ko(e,t,n,r):Ho(e,t,n,r)}function Xo(e,t,n,r){ae(e,t.state,t)?_o(e,t,n,r):Do(e,t,n,r)}function Bn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(l=>{l&&typeof l=="string"&&st(l,i.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);a?a.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.value=n!=null?String(n):"",n&&typeof n=="string"&&(st(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Oe(e){return e?e.toUpperCase():"#000000"}function qt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Hn(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function Dn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Oe(e),r=document.createElement("div");r.style.cssText=`
1079
1057
  width: 32px;
1080
1058
  height: 32px;
1081
1059
  border-radius: var(--fb-border-radius);
@@ -1085,7 +1063,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1085
1063
  font-size: var(--fb-font-size);
1086
1064
  color: var(--fb-text-color);
1087
1065
  font-family: var(--fb-font-family-mono, monospace);
1088
- `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function On(e,t,n){const r=Oe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
1066
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function jn(e,t,n){const r=Oe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
1089
1067
  display: flex;
1090
1068
  align-items: center;
1091
1069
  gap: 8px;
@@ -1112,21 +1090,21 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1112
1090
  position: absolute;
1113
1091
  opacity: 0;
1114
1092
  pointer-events: none;
1115
- `,a.addEventListener("input",()=>{const d=a.value.trim();if(qt(d)){const s=Dn(d);i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else a.classList.add("invalid")}),a.addEventListener("blur",()=>{const d=a.value.trim();if(qt(d)){const s=Dn(d);a.value=s,i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid")}}),l.addEventListener("change",()=>{const d=Oe(l.value);a.value=d,i.style.backgroundColor=d,n.instance&&n.instance.triggerOnChange(t,d)}),i.addEventListener("click",()=>{l.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),a.addEventListener("focus",()=>{a.style.borderColor="var(--fb-border-focus-color)",a.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",a.style.outlineOffset="0"}),a.addEventListener("blur",()=>{a.style.borderColor="var(--fb-border-color)",a.style.outline="none"}),a.addEventListener("mouseenter",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-hover-color)")}),a.addEventListener("mouseleave",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(a),o.appendChild(l),o}function Zo(e,t,n,r){const o=t.state,i=ae(e,o,t),a=t.prefill[e.key]||e.default||"#000000";if(i){const l=jn(a);n.appendChild(l)}else{const l=On(a,r,t);n.appendChild(l)}if(!i){const l=document.createElement("p");l.className="mt-1",l.style.cssText=`
1093
+ `,a.addEventListener("input",()=>{const d=a.value.trim();if(qt(d)){const s=Hn(d);i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else a.classList.add("invalid")}),a.addEventListener("blur",()=>{const d=a.value.trim();if(qt(d)){const s=Hn(d);a.value=s,i.style.backgroundColor=s,l.value=s.toLowerCase(),a.classList.remove("invalid")}}),l.addEventListener("change",()=>{const d=Oe(l.value);a.value=d,i.style.backgroundColor=d,n.instance&&n.instance.triggerOnChange(t,d)}),i.addEventListener("click",()=>{l.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),a.addEventListener("focus",()=>{a.style.borderColor="var(--fb-border-focus-color)",a.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",a.style.outlineOffset="0"}),a.addEventListener("blur",()=>{a.style.borderColor="var(--fb-border-color)",a.style.outline="none"}),a.addEventListener("mouseenter",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-hover-color)")}),a.addEventListener("mouseleave",()=>{document.activeElement!==a&&(a.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(a),o.appendChild(l),o}function Go(e,t,n,r){const o=t.state,i=ae(e,o,t),a=t.prefill[e.key]||e.default||"#000000";if(i){const l=Dn(a);n.appendChild(l)}else{const l=jn(a,r,t);n.appendChild(l)}if(!i){const l=document.createElement("p");l.className="mt-1",l.style.cssText=`
1116
1094
  font-size: var(--fb-font-size-small);
1117
1095
  color: var(--fb-text-secondary-color);
1118
- `,l.textContent=Le(e,o),n.appendChild(l)}}function Qo(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"#000000");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const v=document.createElement("div");if(v.className="multiple-colour-item flex items-center gap-2",l){const w=jn(h);for(;w.firstChild;)v.appendChild(w.firstChild)}else{const w=`${r}[${f.children.length}]`,k=On(h,w,t);k.style.flex="1",v.appendChild(k)}return y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(v=>{let w=v.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
1096
+ `,l.textContent=Le(e,o),n.appendChild(l)}}function Zo(e,t,n,r){var o,i;const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0;for(;s.length<u;)s.push(e.default||"#000000");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const v=document.createElement("div");if(v.className="multiple-colour-item flex items-center gap-2",l){const C=Dn(h);for(;C.firstChild;)v.appendChild(C.firstChild)}else{const C=`${r}[${f.children.length}]`,w=jn(h,C,t);w.style.flex="1",v.appendChild(w)}return y===-1?f.appendChild(v):f.insertBefore(v,f.children[y]),p(),v}function b(){if(l)return;const h=f.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
1119
1097
  color: var(--fb-error-color);
1120
1098
  background-color: transparent;
1121
1099
  transition: background-color var(--fb-transition-duration);
1122
- `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),C(),b())},v.appendChild(w));const k=y<=u;w.disabled=k,w.style.opacity=k?"0.5":"1",w.style.pointerEvents=k?"none":"auto"})}let g=null;if(!l){const h=Fe("colour",()=>{const y=e.default||"#000000";s.push(y),m(y),C(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function C(){g&&g(s.length,c)}if(s.forEach(h=>m(h)),C(),b(),!l){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
1100
+ `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const x=Array.from(f.children).indexOf(v);f.children.length>u&&(s.splice(x,1),v.remove(),p(),E(),b())},v.appendChild(C));const w=y<=u;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!l){const h=Fe("colour",()=>{const y=e.default||"#000000";s.push(y),m(y),E(),b()},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,c)}if(s.forEach(h=>m(h)),E(),b(),!l){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
1123
1101
  font-size: var(--fb-font-size-small);
1124
1102
  color: var(--fb-text-secondary-color);
1125
- `,h.textContent=Le(e,a),n.appendChild(h)}}function el(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n,s=(c,f)=>{var p,m;if(!c)return;const b=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);f?(c.classList.add("invalid"),c.title=f,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
1103
+ `,h.textContent=Le(e,a),n.appendChild(h)}}function Qo(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n,s=(c,f)=>{var p,m;if(!c)return;const b=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);f?(c.classList.add("invalid"),c.title=f,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
1126
1104
  color: var(--fb-error-color);
1127
1105
  font-size: var(--fb-font-size-small);
1128
1106
  margin-top: 0.25rem;
1129
- `,c.nextSibling?(p=c.parentNode)==null||p.insertBefore(g,c.nextSibling):(m=c.parentNode)==null||m.appendChild(g)),g.textContent=f,g.style.display="block"):(c.classList.remove("invalid"),c.title="",g&&g.remove())},u=(c,f,p)=>{const{state:m}=n;if(!f){if(!d&&e.required){const g=E("required",m);return a.push(`${p}: ${g}`),s(c,g),""}return s(c,null),""}const b=Oe(f);if(!d&&!qt(b)){const g=E("invalidHexColour",m);return a.push(`${p}: ${g}`),s(c,g),f}return s(c,null),b};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),f=[];if(c.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"",C=u(p,g,`${t}[${m}]`);f.push(C)}),!d){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=f.filter(C=>C!=="");e.required&&g.length===0&&a.push(`${t}: ${E("required",p)}`),g.length<m&&a.push(`${t}: ${E("minItems",p,{min:m})}`),g.length>b&&a.push(`${t}: ${E("maxItems",p,{max:b})}`)}return{value:f,errors:a}}else{const c=l.querySelector(`[name="${t}"].colour-hex-input`),f=(i=c==null?void 0:c.value)!=null?i:"";if(!d&&e.required&&f===""){const p=E("required",n.state);return a.push(`${t}: ${p}`),s(c,p),{value:"",errors:a}}return{value:u(c,f,t),errors:a}}}function tl(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);i.forEach((a,l)=>{if(l<n.length){const d=Oe(n[l]);a.value=d,a.classList.remove("invalid"),a.title="",xe(a);const s=a.closest(".colour-picker-wrapper");if(s){const u=s.querySelector(".colour-swatch"),c=s.querySelector(".colour-picker-hidden");u&&(u.style.backgroundColor=d),c&&(c.value=d.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const a=Oe(n);i.value=a,i.classList.remove("invalid"),i.title="",xe(i);const l=i.closest(".colour-picker-wrapper");if(l){const d=l.querySelector(".colour-swatch"),s=l.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=a),s&&(s.value=a.toLowerCase())}}}}function Un(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function Rt(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function ft(e,t){return Math.round(e/t)*t}function Pn(e,t,n,r,o){var i;const a=document.createElement("div");a.className="slider-container";const l=document.createElement("div");l.className="flex items-start gap-3";const d=document.createElement("div");d.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const u=n.scale||"linear",c=n.min,f=n.max,p=(i=n.step)!=null?i:1;if(u==="exponential"){if(c<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${c})`);s.min="0",s.max="1000",s.step="1";const h=Rt(e,c,f);s.value=(h*1e3).toString()}else s.min=c.toString(),s.max=f.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
1107
+ `,c.nextSibling?(p=c.parentNode)==null||p.insertBefore(g,c.nextSibling):(m=c.parentNode)==null||m.appendChild(g)),g.textContent=f,g.style.display="block"):(c.classList.remove("invalid"),c.title="",g&&g.remove())},u=(c,f,p)=>{const{state:m}=n;if(!f){if(!d&&e.required){const g=k("required",m);return a.push(`${p}: ${g}`),s(c,g),""}return s(c,null),""}const b=Oe(f);if(!d&&!qt(b)){const g=k("invalidHexColour",m);return a.push(`${p}: ${g}`),s(c,g),f}return s(c,null),b};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),f=[];if(c.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"",E=u(p,g,`${t}[${m}]`);f.push(E)}),!d){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=f.filter(E=>E!=="");e.required&&g.length===0&&a.push(`${t}: ${k("required",p)}`),g.length<m&&a.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&a.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:f,errors:a}}else{const c=l.querySelector(`[name="${t}"].colour-hex-input`),f=(i=c==null?void 0:c.value)!=null?i:"";if(!d&&e.required&&f===""){const p=k("required",n.state);return a.push(`${t}: ${p}`),s(c,p),{value:"",errors:a}}return{value:u(c,f,t),errors:a}}}function el(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);i.forEach((a,l)=>{if(l<n.length){const d=Oe(n[l]);a.value=d,a.classList.remove("invalid"),a.title="",xe(a);const s=a.closest(".colour-picker-wrapper");if(s){const u=s.querySelector(".colour-swatch"),c=s.querySelector(".colour-picker-hidden");u&&(u.style.backgroundColor=d),c&&(c.value=d.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const a=Oe(n);i.value=a,i.classList.remove("invalid"),i.title="",xe(i);const l=i.closest(".colour-picker-wrapper");if(l){const d=l.querySelector(".colour-swatch"),s=l.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=a),s&&(s.value=a.toLowerCase())}}}}function On(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function Rt(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function ft(e,t){return Math.round(e/t)*t}function Un(e,t,n,r,o){var i;const a=document.createElement("div");a.className="slider-container";const l=document.createElement("div");l.className="flex items-start gap-3";const d=document.createElement("div");d.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const u=n.scale||"linear",c=n.min,f=n.max,p=(i=n.step)!=null?i:1;if(u==="exponential"){if(c<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${c})`);s.min="0",s.max="1000",s.step="1";const h=Rt(e,c,f);s.value=(h*1e3).toString()}else s.min=c.toString(),s.max=f.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
1130
1108
  height: 6px;
1131
1109
  border-radius: 3px;
1132
1110
  background: linear-gradient(
@@ -1144,7 +1122,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1144
1122
  font-size: var(--fb-font-size-small);
1145
1123
  color: var(--fb-text-secondary-color);
1146
1124
  margin-top: 4px;
1147
- `;const b=document.createElement("span");b.textContent=c.toString();const g=document.createElement("span");g.textContent=f.toString(),m.appendChild(b),m.appendChild(g),d.appendChild(m);const C=document.createElement("span");if(C.className="slider-value",C.style.cssText=`
1125
+ `;const b=document.createElement("span");b.textContent=c.toString();const g=document.createElement("span");g.textContent=f.toString(),m.appendChild(b),m.appendChild(g),d.appendChild(m);const E=document.createElement("span");if(E.className="slider-value",E.style.cssText=`
1148
1126
  min-width: 60px;
1149
1127
  text-align: right;
1150
1128
  font-size: var(--fb-font-size);
@@ -1152,28 +1130,28 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1152
1130
  font-family: var(--fb-font-family-mono, monospace);
1153
1131
  font-weight: 500;
1154
1132
  padding-top: 2px;
1155
- `,C.textContent=e.toFixed(p<1?2:0),l.appendChild(d),l.appendChild(C),a.appendChild(l),!o){const h=()=>{let y;if(u==="exponential"){const w=parseFloat(s.value)/1e3;y=Un(w,c,f),y=ft(y,p),y=Math.max(c,Math.min(f,y))}else y=parseFloat(s.value),y=ft(y,p);C.textContent=y.toFixed(p<1?2:0);const v=(y-c)/(f-c)*100;s.style.background=`linear-gradient(
1133
+ `,E.textContent=e.toFixed(p<1?2:0),l.appendChild(d),l.appendChild(E),a.appendChild(l),!o){const h=()=>{let y;if(u==="exponential"){const C=parseFloat(s.value)/1e3;y=On(C,c,f),y=ft(y,p),y=Math.max(c,Math.min(f,y))}else y=parseFloat(s.value),y=ft(y,p);E.textContent=y.toFixed(p<1?2:0);const v=(y-c)/(f-c)*100;s.style.background=`linear-gradient(
1156
1134
  to right,
1157
1135
  var(--fb-primary-color) 0%,
1158
1136
  var(--fb-primary-color) ${v}%,
1159
1137
  var(--fb-border-color) ${v}%,
1160
1138
  var(--fb-border-color) 100%
1161
- )`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return a}function nl(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,a=ae(e,i,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,d=(o=t.prefill[e.key])!=null?o:l,s=Pn(d,r,e,t,a);if(n.appendChild(s),!a){const u=document.createElement("p");u.className="mt-1",u.style.cssText=`
1139
+ )`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return a}function tl(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,a=ae(e,i,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,d=(o=t.prefill[e.key])!=null?o:l,s=Un(d,r,e,t,a);if(n.appendChild(s),!a){const u=document.createElement("p");u.className="mt-1",u.style.cssText=`
1162
1140
  font-size: var(--fb-font-size-small);
1163
1141
  color: var(--fb-text-secondary-color);
1164
- `,u.textContent=Le(e,i),n.appendChild(u)}}function rl(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<u;)s.push(f);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,v)=>{const w=y.querySelector("input[type=range]");w&&w.setAttribute("name",`${r}[${v}]`)})}function b(y=f,v=-1){const w=document.createElement("div");w.className="multiple-slider-item flex items-start gap-2";const k=`${r}[${p.children.length}]`,x=Pn(y,k,e,t,l);return x.style.flex="1",w.appendChild(x),v===-1?p.appendChild(w):p.insertBefore(w,p.children[v]),m(),w}function g(){if(l)return;const y=p.querySelectorAll(".multiple-slider-item"),v=y.length;y.forEach(w=>{let k=w.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 rounded",k.style.cssText=`
1142
+ `,u.textContent=Le(e,i),n.appendChild(u)}}function nl(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,c=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<u;)s.push(f);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,v)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${v}]`)})}function b(y=f,v=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const w=`${r}[${p.children.length}]`,x=Un(y,w,e,t,l);return x.style.flex="1",C.appendChild(x),v===-1?p.appendChild(C):p.insertBefore(C,p.children[v]),m(),C}function g(){if(l)return;const y=p.querySelectorAll(".multiple-slider-item"),v=y.length;y.forEach(C=>{let w=C.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
1165
1143
  color: var(--fb-error-color);
1166
1144
  background-color: transparent;
1167
1145
  transition: background-color var(--fb-transition-duration);
1168
1146
  margin-top: 8px;
1169
- `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const $=Array.from(p.children).indexOf(w);p.children.length>u&&(s.splice($,1),w.remove(),m(),h(),g())},w.appendChild(k));const x=v<=u;k.disabled=x,k.style.opacity=x?"0.5":"1",k.style.pointerEvents=x?"none":"auto"})}let C=null;if(!l){const y=Fe("slider",()=>{s.push(f),b(f),h(),g()},{label:e.addLabel});C=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){C&&C(s.length,c)}if(s.forEach(y=>b(y)),h(),g(),!l){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
1147
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{const S=Array.from(p.children).indexOf(C);p.children.length>u&&(s.splice(S,1),C.remove(),m(),h(),g())},C.appendChild(w));const x=v<=u;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let E=null;if(!l){const y=Fe("slider",()=>{s.push(f),b(f),h(),g()},{label:e.addLabel});E=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){E&&E(s.length,c)}if(s.forEach(y=>b(y)),h(),g(),!l){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
1170
1148
  font-size: var(--fb-font-size-small);
1171
1149
  color: var(--fb-text-secondary-color);
1172
- `,y.textContent=Le(e,a),n.appendChild(y)}}function ol(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const s=e.min,u=e.max,c=(r=e.step)!=null?r:1,f=e.scale||"linear",p=(b,g)=>{var C,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(y);if(g){if(b.classList.add("invalid"),b.title=g,!v){v=document.createElement("div"),v.id=y,v.className="error-message",v.style.cssText=`
1150
+ `,y.textContent=Le(e,a),n.appendChild(y)}}function rl(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:d}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const s=e.min,u=e.max,c=(r=e.step)!=null?r:1,f=e.scale||"linear",p=(b,g)=>{var E,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(y);if(g){if(b.classList.add("invalid"),b.title=g,!v){v=document.createElement("div"),v.id=y,v.className="error-message",v.style.cssText=`
1173
1151
  color: var(--fb-error-color);
1174
1152
  font-size: var(--fb-font-size-small);
1175
1153
  margin-top: 0.25rem;
1176
- `;const w=b.closest(".slider-container");w&&w.nextSibling?(C=w.parentNode)==null||C.insertBefore(v,w.nextSibling):w&&((h=w.parentNode)==null||h.appendChild(v))}v.textContent=g,v.style.display="block"}else b.classList.remove("invalid"),b.title="",v&&v.remove()},m=(b,g)=>{const{state:C}=n,h=b.value;if(!h){if(!d&&e.required){const v=E("required",C);return a.push(`${g}: ${v}`),p(b,v),null}return p(b,null),null}let y;if(f==="exponential"){const v=parseFloat(h)/1e3;y=Un(v,s,u),y=ft(y,c)}else y=parseFloat(h),y=ft(y,c);if(!d){if(y<s){const v=E("minValue",C,{min:s});return a.push(`${g}: ${v}`),p(b,v),y}if(y>u){const v=E("maxValue",C,{max:u});return a.push(`${g}: ${v}`),p(b,v),y}}return p(b,null),y};if(e.multiple){const b=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),g=[];if(b.forEach((C,h)=>{const y=m(C,`${t}[${h}]`);g.push(y)}),!d){const{state:C}=n,h=(o=e.minCount)!=null?o:0,y=(i=e.maxCount)!=null?i:1/0,v=g.filter(w=>w!==null);e.required&&v.length===0&&a.push(`${t}: ${E("required",C)}`),v.length<h&&a.push(`${t}: ${E("minItems",C,{min:h})}`),v.length>y&&a.push(`${t}: ${E("maxItems",C,{max:y})}`)}return{value:g,errors:a}}else{const b=l.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:a}:(!d&&e.required&&a.push(`${t}: ${E("required",n.state)}`),{value:null,errors:a})}}function ll(e,t,n,r){var o;const{scopeRoot:i}=r,a=e.min,l=e.max,d=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const u=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`);u.forEach((c,f)=>{if(f<n.length&&n[f]!==null){const p=Number(n[f]);if(s==="exponential"){const b=Rt(p,a,l);c.value=(b*1e3).toString()}else c.value=p.toString();const m=c.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(d<1?2:0));const g=(p-a)/(l-a)*100;c.style.background=`linear-gradient(
1154
+ `;const C=b.closest(".slider-container");C&&C.nextSibling?(E=C.parentNode)==null||E.insertBefore(v,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(v))}v.textContent=g,v.style.display="block"}else b.classList.remove("invalid"),b.title="",v&&v.remove()},m=(b,g)=>{const{state:E}=n,h=b.value;if(!h){if(!d&&e.required){const v=k("required",E);return a.push(`${g}: ${v}`),p(b,v),null}return p(b,null),null}let y;if(f==="exponential"){const v=parseFloat(h)/1e3;y=On(v,s,u),y=ft(y,c)}else y=parseFloat(h),y=ft(y,c);if(!d){if(y<s){const v=k("minValue",E,{min:s});return a.push(`${g}: ${v}`),p(b,v),y}if(y>u){const v=k("maxValue",E,{max:u});return a.push(`${g}: ${v}`),p(b,v),y}}return p(b,null),y};if(e.multiple){const b=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),g=[];if(b.forEach((E,h)=>{const y=m(E,`${t}[${h}]`);g.push(y)}),!d){const{state:E}=n,h=(o=e.minCount)!=null?o:0,y=(i=e.maxCount)!=null?i:1/0,v=g.filter(C=>C!==null);e.required&&v.length===0&&a.push(`${t}: ${k("required",E)}`),v.length<h&&a.push(`${t}: ${k("minItems",E,{min:h})}`),v.length>y&&a.push(`${t}: ${k("maxItems",E,{max:y})}`)}return{value:g,errors:a}}else{const b=l.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:a}:(!d&&e.required&&a.push(`${t}: ${k("required",n.state)}`),{value:null,errors:a})}}function ol(e,t,n,r){var o;const{scopeRoot:i}=r,a=e.min,l=e.max,d=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const u=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`);u.forEach((c,f)=>{if(f<n.length&&n[f]!==null){const p=Number(n[f]);if(s==="exponential"){const b=Rt(p,a,l);c.value=(b*1e3).toString()}else c.value=p.toString();const m=c.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(d<1?2:0));const g=(p-a)/(l-a)*100;c.style.background=`linear-gradient(
1177
1155
  to right,
1178
1156
  var(--fb-primary-color) 0%,
1179
1157
  var(--fb-primary-color) ${g}%,
@@ -1185,7 +1163,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1185
1163
  var(--fb-primary-color) ${m}%,
1186
1164
  var(--fb-border-color) ${m}%,
1187
1165
  var(--fb-border-color) 100%
1188
- )`}u.classList.remove("invalid"),u.title="",xe(u)}}}function Wn(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Vn(e,t){return{...t,...e}}function Bt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let Ht=null;function il(e){Ht=e}function pt(e,t){if(!Ht)throw new Error("renderElement not initialized. Import from components/index.ts");return Ht(e,t)}function Kn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function _n(e,t,n,r){var o,i;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const l=document.createElement("div"),d=e.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`;const s=ae(e,t.state,t);if(!s){const m=Kn(e,r);m&&a.appendChild(m)}const u=Wn(e.elements),c=((o=t.prefill)==null?void 0:o[e.key])||{},f=Vn(c,u),p={path:ke(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var b,g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const C=(g=(b=c[m.key])!=null?b:"default"in m?m.default:null)!=null?g:null;l.appendChild(_e(ke(p.path,m.key),C))}else l.appendChild(pt(m,p))}),a.appendChild(l),n.appendChild(a)}function Dt(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function jt(e,t,n){const r=document.createElement("button");r.type="button",r.className="fb-item-remove",r.setAttribute("aria-label",E("removeElement",n)),r.style.cssText=`
1166
+ )`}u.classList.remove("invalid"),u.title="",xe(u)}}}function Pn(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Wn(e,t){return{...t,...e}}function Bt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLSelectElement?t[r]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[r]=n.checked:n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let Ht=null;function ll(e){Ht=e}function pt(e,t){if(!Ht)throw new Error("renderElement not initialized. Import from components/index.ts");return Ht(e,t)}function Vn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function Kn(e,t,n,r){var o,i;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const l=document.createElement("div"),d=e.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`;const s=ae(e,t.state,t);if(!s){const m=Vn(e,r);m&&a.appendChild(m)}const u=Pn(e.elements),c=((o=t.prefill)==null?void 0:o[e.key])||{},f=Wn(c,u),p={path:ke(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var b,g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const E=(g=(b=c[m.key])!=null?b:"default"in m?m.default:null)!=null?g:null;l.appendChild(_e(ke(p.path,m.key),E))}else l.appendChild(pt(m,p))}),a.appendChild(l),n.appendChild(a)}function Dt(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function jt(e,t,n){const r=document.createElement("button");r.type="button",r.className="fb-item-remove",r.setAttribute("aria-label",k("removeElement",n)),r.style.cssText=`
1189
1167
  width: 24px;
1190
1168
  height: 24px;
1191
1169
  display: inline-flex;
@@ -1196,7 +1174,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1196
1174
  border-radius: 4px;
1197
1175
  cursor: pointer;
1198
1176
  flex-shrink: 0;
1199
- `,r.innerHTML=en,r.onclick=t;const o=e.querySelector("[data-fb-label-row]");if(o){r.style.marginLeft="auto",o.appendChild(r);return}r.style.position="absolute",r.style.top="8px",r.style.right="8px",e.style.position="relative",e.appendChild(r)}function Jn(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=s||t.inheritedReadonly,c=document.createElement("div");c.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),p=e.displayMode==="slides";if(p?f.className="fb-container-slides":f.className="fb-row",!s){const B=Kn(e,e.key);B&&c.appendChild(B)}const m=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,g=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,C=Wn(e.elements),h=()=>f.querySelectorAll(":scope > .containerItem").length,y=()=>{if(h()>=b)return;const B=h(),_=d.formRoot?Bt(d.formRoot):{},R={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${B}]`),prefill:C,formData:_,inheritedReadonly:u},N=document.createElement("div");N.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",N.setAttribute("data-container-item",`${e.key}[${B}]`),p&&N.setAttribute("data-fb-slide-card","");const P=document.createElement("div");P.className=Dt(p?void 0:e.columns),e.elements.forEach(J=>{var te;J.type!=="markdown"&&(J.hidden||J.type==="hidden")?P.appendChild(_e(ke(R.path,J.key),(te="default"in J?J.default:null)!=null?te:null)):P.appendChild(pt(J,R))}),N.appendChild(P),s||jt(N,()=>z(N),d),v&&v.parentElement===f?f.insertBefore(N,v):f.appendChild(N),$()};let v=null,w=null,k=null;const x=()=>{if(!v)return;const B=f.querySelector(":scope > .containerItem");B&&B.offsetHeight>0&&(v.style.minHeight=`${B.offsetHeight}px`)},$=()=>{const B=h();w&&w(B,b),k&&k(B,b),v&&x()},z=B=>{B.remove(),$()};if(g&&Array.isArray(g)&&g.forEach((B,_)=>{var R;const N=Vn(B||{},C),P={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${_}]`),prefill:N,formData:(R=t.formData)!=null?R:t.prefill,inheritedReadonly:u},J=document.createElement("div");J.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",J.setAttribute("data-container-item",`${e.key}[${_}]`),p&&J.setAttribute("data-fb-slide-card","");const te=document.createElement("div");te.className=Dt(p?void 0:e.columns),e.elements.forEach(le=>{var he,Ce;if(le.type!=="markdown"&&(le.hidden||le.type==="hidden")){const Ke=(Ce=(he=B==null?void 0:B[le.key])!=null?he:"default"in le?le.default:null)!=null?Ce:null;te.appendChild(_e(ke(P.path,le.key),Ke))}else te.appendChild(pt(le,P))}),J.appendChild(te),s||jt(J,()=>z(J),t.state),f.appendChild(J)}),!s)for(;h()<m;){const B=h(),_={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${B}]`),prefill:C,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:u},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",R.setAttribute("data-container-item",`${e.key}[${B}]`),p&&R.setAttribute("data-fb-slide-card","");const N=document.createElement("div");N.className=Dt(p?void 0:e.columns),e.elements.forEach(P=>{var J;P.type!=="markdown"&&(P.hidden||P.type==="hidden")?N.appendChild(_e(ke(_.path,P.key),(J="default"in P?P.default:null)!=null?J:null)):N.appendChild(pt(P,_))}),R.appendChild(N),jt(R,()=>{h()>m&&z(R)},t.state),f.appendChild(R)}if(c.appendChild(f),!s)if(p){const B=kr(y,{label:e.addLabel});v=B.tile,w=B.update,Te(n,B.counter),f.appendChild(B.tile)}else{const B=Fe("container",y,{label:e.addLabel});k=B.update,Te(n,B.counter),c.appendChild(B.row)}$(),n.appendChild(c),v&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(x):x())}let Ot=null;function al(e){Ot=e}function Yn(e,t,n){if(!Ot)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ot(e,t,n)}function Xn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:a}=n;if(!("elements"in e))return{value:null,errors:r};const l=(d,s,u)=>{var c,f;if(i)return;const{state:p}=n,m="minCount"in u&&(c=u.minCount)!=null?c:0,b="maxCount"in u&&(f=u.maxCount)!=null?f:1/0;u.required&&s.length===0&&r.push(`${d}: ${E("required",p)}`),s.length<m&&r.push(`${d}: ${E("minItems",p,{min:m})}`),s.length>b&&r.push(`${d}: ${E("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const d=[],s=o.querySelectorAll("[data-container-item]");return Array.from(s).filter(u=>{const c=u.getAttribute("data-container-item")||"";if(!c.startsWith(`${t}[`))return!1;const f=c.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(u=>{const c={},f=(u.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),p=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(m.enableIf,h,c))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${p}]":`,h)}const g=`${t}[${p}].${m.key}`,C=Yn({...m,key:g},{path:a},u);C.spread&&C.value!==null&&typeof C.value=="object"?Object.assign(c,C.value):c[m.key]=C.value}),d.push(c)}),l(t,d,e),{value:d,errors:r}}else{const d={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(u=>{var c;if(u.enableIf)try{const f=(c=n.instance)!=null&&c.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(u.enableIf,f,d))return}catch(f){console.error(`Error evaluating enableIf for field "${u.key}" in container "${t}":`,f)}{const f=`${t}.${u.key}`,p=Yn({...u,key:f},{path:a},s);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(d,p.value):d[u.key]=p.value}}),{value:d,errors:r}}}function Gn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((l,d)=>{nt(l)&&e.elements.forEach(s=>{var u,c;if(s.type==="markdown"||!s.key)return;const f=`${t}[${d}].${s.key}`;if(s.type==="richinput"&&s.flatOutput){const p=s,m=(u=p.textKey)!=null?u:"text",b=(c=p.filesKey)!=null?c:"files",g=l,C={};m in g&&(C[m]=g[m]),b in g&&(C[b]=g[b]),Object.keys(C).length>0&&o.updateField(f,C)}else{const p=l[s.key];p!==void 0&&o.updateField(f,p)}})});const a=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==a.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!nt(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(a=>{var l,d;if(a.type==="markdown"||!a.key)return;const s=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const u=a,c=(l=u.textKey)!=null?l:"text",f=(d=u.filesKey)!=null?d:"files",p=n,m={};c in p&&(m[c]=p[c]),f in p&&(m[f]=p[f]),Object.keys(m).length>0&&o.updateField(s,m)}else{const u=n[a.key];u!==void 0&&o.updateField(s,u)}})}}function sl(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const a={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&nt(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};a.multiple?Jn(a,t,n):_n(a,t,n,r)}function Zn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&nt(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function dl(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=Zn(e);return Xn(r,t,n)}function cl(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Zn(e);return Gn(o,t,n,r)}function ul(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function fl(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.top=="number"&&typeof t.left=="number"&&typeof t.bottom=="number"&&typeof t.right=="number"}function pl(e){return ul(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:fl(e)?e:null}function Ue(e){return e.map(pl).filter(t=>t!==null)}function Qn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ut(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const a=e[i];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${i} overlap`}}return null}function er(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function mt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ne(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function Pe(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1177
+ `,r.innerHTML=en,r.onclick=t;const o=e.querySelector("[data-fb-label-row]");if(o){r.style.marginLeft="auto",o.appendChild(r);return}r.style.position="absolute",r.style.top="8px",r.style.right="8px",e.style.position="relative",e.appendChild(r)}function _n(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=s||t.inheritedReadonly,c=document.createElement("div");c.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),p=e.displayMode==="slides";if(p?f.className="fb-container-slides":f.className="fb-row",!s){const D=Vn(e,e.key);D&&c.appendChild(D)}const m=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,g=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,E=Pn(e.elements),h=()=>f.querySelectorAll(":scope > .containerItem").length,y=()=>{if(h()>=b)return;const D=h(),V=d.formRoot?Bt(d.formRoot):{},N={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${D}]`),prefill:E,formData:V,inheritedReadonly:u},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",R.setAttribute("data-container-item",`${e.key}[${D}]`),p&&R.setAttribute("data-fb-slide-card","");const _=document.createElement("div");_.className=Dt(p?void 0:e.columns),e.elements.forEach(J=>{var te;J.type!=="markdown"&&(J.hidden||J.type==="hidden")?_.appendChild(_e(ke(N.path,J.key),(te="default"in J?J.default:null)!=null?te:null)):_.appendChild(pt(J,N))}),R.appendChild(_),s||jt(R,()=>I(R),d),v&&v.parentElement===f?f.insertBefore(R,v):f.appendChild(R),S()};let v=null,C=null,w=null;const x=()=>{if(!v)return;const D=f.querySelector(":scope > .containerItem");D&&D.offsetHeight>0&&(v.style.minHeight=`${D.offsetHeight}px`)},S=()=>{const D=h();C&&C(D,b),w&&w(D,b),v&&x()},I=D=>{D.remove(),S()};if(g&&Array.isArray(g)&&g.forEach((D,V)=>{var N;const R=Wn(D||{},E),_={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${V}]`),prefill:R,formData:(N=t.formData)!=null?N:t.prefill,inheritedReadonly:u},J=document.createElement("div");J.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",J.setAttribute("data-container-item",`${e.key}[${V}]`),p&&J.setAttribute("data-fb-slide-card","");const te=document.createElement("div");te.className=Dt(p?void 0:e.columns),e.elements.forEach(le=>{var he,Ce;if(le.type!=="markdown"&&(le.hidden||le.type==="hidden")){const Ke=(Ce=(he=D==null?void 0:D[le.key])!=null?he:"default"in le?le.default:null)!=null?Ce:null;te.appendChild(_e(ke(_.path,le.key),Ke))}else te.appendChild(pt(le,_))}),J.appendChild(te),s||jt(J,()=>I(J),t.state),f.appendChild(J)}),!s)for(;h()<m;){const D=h(),V={state:t.state,instance:t.instance,path:ke(t.path,`${e.key}[${D}]`),prefill:E,formData:(l=t.formData)!=null?l:t.prefill,inheritedReadonly:u},N=document.createElement("div");N.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",N.setAttribute("data-container-item",`${e.key}[${D}]`),p&&N.setAttribute("data-fb-slide-card","");const R=document.createElement("div");R.className=Dt(p?void 0:e.columns),e.elements.forEach(_=>{var J;_.type!=="markdown"&&(_.hidden||_.type==="hidden")?R.appendChild(_e(ke(V.path,_.key),(J="default"in _?_.default:null)!=null?J:null)):R.appendChild(pt(_,V))}),N.appendChild(R),jt(N,()=>{h()>m&&I(N)},t.state),f.appendChild(N)}if(c.appendChild(f),!s)if(p){const D=Er(y,{label:e.addLabel});v=D.tile,C=D.update,Te(n,D.counter),f.appendChild(D.tile)}else{const D=Fe("container",y,{label:e.addLabel});w=D.update,Te(n,D.counter),c.appendChild(D.row)}S(),n.appendChild(c),v&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(x):x())}let Ot=null;function il(e){Ot=e}function Jn(e,t,n){if(!Ot)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ot(e,t,n)}function Yn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:a}=n;if(!("elements"in e))return{value:null,errors:r};const l=(d,s,u)=>{var c,f;if(i)return;const{state:p}=n,m="minCount"in u&&(c=u.minCount)!=null?c:0,b="maxCount"in u&&(f=u.maxCount)!=null?f:1/0;u.required&&s.length===0&&r.push(`${d}: ${k("required",p)}`),s.length<m&&r.push(`${d}: ${k("minItems",p,{min:m})}`),s.length>b&&r.push(`${d}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const d=[],s=o.querySelectorAll("[data-container-item]");return Array.from(s).filter(u=>{const c=u.getAttribute("data-container-item")||"";if(!c.startsWith(`${t}[`))return!1;const f=c.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(u=>{const c={},f=(u.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),p=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(m.enableIf,h,c))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${p}]":`,h)}const g=`${t}[${p}].${m.key}`,E=Jn({...m,key:g},{path:a},u);E.spread&&E.value!==null&&typeof E.value=="object"?Object.assign(c,E.value):c[m.key]=E.value}),d.push(c)}),l(t,d,e),{value:d,errors:r}}else{const d={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(u=>{var c;if(u.enableIf)try{const f=(c=n.instance)!=null&&c.getState().formRoot?Bt(n.instance.getState().formRoot):{};if(!He(u.enableIf,f,d))return}catch(f){console.error(`Error evaluating enableIf for field "${u.key}" in container "${t}":`,f)}{const f=`${t}.${u.key}`,p=Jn({...u,key:f},{path:a},s);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(d,p.value):d[u.key]=p.value}}),{value:d,errors:r}}}function Xn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((l,d)=>{nt(l)&&e.elements.forEach(s=>{var u,c;if(s.type==="markdown"||!s.key)return;const f=`${t}[${d}].${s.key}`;if(s.type==="richinput"&&s.flatOutput){const p=s,m=(u=p.textKey)!=null?u:"text",b=(c=p.filesKey)!=null?c:"files",g=l,E={};m in g&&(E[m]=g[m]),b in g&&(E[b]=g[b]),Object.keys(E).length>0&&o.updateField(f,E)}else{const p=l[s.key];p!==void 0&&o.updateField(f,p)}})});const a=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==a.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!nt(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(a=>{var l,d;if(a.type==="markdown"||!a.key)return;const s=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const u=a,c=(l=u.textKey)!=null?l:"text",f=(d=u.filesKey)!=null?d:"files",p=n,m={};c in p&&(m[c]=p[c]),f in p&&(m[f]=p[f]),Object.keys(m).length>0&&o.updateField(s,m)}else{const u=n[a.key];u!==void 0&&o.updateField(s,u)}})}}function al(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const a={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&nt(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};a.multiple?_n(a,t,n):Kn(a,t,n,r)}function Gn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&nt(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function sl(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=Gn(e);return Yn(r,t,n)}function dl(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Gn(e);return Xn(o,t,n,r)}function cl(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function ul(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.top=="number"&&typeof t.left=="number"&&typeof t.bottom=="number"&&typeof t.right=="number"}function fl(e){return cl(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:ul(e)?e:null}function Ue(e){return e.map(fl).filter(t=>t!==null)}function Zn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ut(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const a=e[i];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${i} overlap`}}return null}function Qn(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function mt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Me(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function Pe(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1200
1178
  position: absolute;
1201
1179
  width: ${e.size}px;
1202
1180
  height: ${e.size}px;
@@ -1216,7 +1194,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1216
1194
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
1217
1195
  transition: transform 0.1s, opacity 0.1s;
1218
1196
  pointer-events: all;
1219
- `,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function ml(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
1197
+ `,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function pl(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
1220
1198
  width: 100%;
1221
1199
  border-collapse: collapse;
1222
1200
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -1224,13 +1202,13 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1224
1202
  font-size: var(--fb-font-size);
1225
1203
  font-family: var(--fb-font-family);
1226
1204
  color: var(--fb-text-color);
1227
- `,n.forEach((l,d)=>{var s,u;const c=(d===0?i.createTHead():(s=i.tBodies[0])!=null?s:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(er(d,f,r))continue;const p=mt(d,f,r),m=document.createElement(d===0?"th":"td");if(p){const b=p.bottom-p.top+1,g=p.right-p.left+1;b>1&&(m.rowSpan=b),g>1&&(m.colSpan=g)}m.textContent=(u=l[f])!=null?u:"",m.style.cssText=`
1205
+ `,n.forEach((l,d)=>{var s,u;const c=(d===0?i.createTHead():(s=i.tBodies[0])!=null?s:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(Qn(d,f,r))continue;const p=mt(d,f,r),m=document.createElement(d===0?"th":"td");if(p){const b=p.bottom-p.top+1,g=p.right-p.left+1;b>1&&(m.rowSpan=b),g>1&&(m.colSpan=g)}m.textContent=(u=l[f])!=null?u:"",m.style.cssText=`
1228
1206
  padding: 6px 10px;
1229
1207
  border: var(--fb-border-width) solid var(--fb-border-color);
1230
1208
  text-align: left;
1231
1209
  vertical-align: top;
1232
1210
  ${d===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1233
- `,c.appendChild(m)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(i),t.appendChild(a)}function hl(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),l=window.getSelection();a.selectNodeContents(e),a.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(a);function d(){var c;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(c=e.textContent)!=null?c:""),o()}function s(c){var f,p,m,b;const g=r(),C=(p=(f=g[0])==null?void 0:f.length)!=null?p:0;if(c.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=g[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",u);return}if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u);const h=t+1<g.length?t+1:t;i(h,n);return}if(c.key==="Tab"){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u);let h=t,y=c.shiftKey?n-1:n+1;y<0&&(y=C-1,h=Math.max(0,t-1)),y>=C&&(y=0,h=Math.min(g.length-1,t+1)),i(h,y)}}function u(){e.contentEditable==="true"&&(d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u))}e.addEventListener("keydown",s),e.addEventListener("blur",u)}function bl(){if(document.getElementById("fb-spin-keyframes"))return;const e=document.createElement("style");e.id="fb-spin-keyframes",e.textContent="@keyframes fb-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}function vl(e,t){bl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1211
+ `,c.appendChild(m)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(i),t.appendChild(a)}function ml(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),l=window.getSelection();a.selectNodeContents(e),a.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(a);function d(){var c;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(c=e.textContent)!=null?c:""),o()}function s(c){var f,p,m,b;const g=r(),E=(p=(f=g[0])==null?void 0:f.length)!=null?p:0;if(c.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=g[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",u);return}if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u);const h=t+1<g.length?t+1:t;i(h,n);return}if(c.key==="Tab"){c.preventDefault(),c.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u);let h=t,y=c.shiftKey?n-1:n+1;y<0&&(y=E-1,h=Math.max(0,t-1)),y>=E&&(y=0,h=Math.min(g.length-1,t+1)),i(h,y)}}function u(){e.contentEditable==="true"&&(d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",u))}e.addEventListener("keydown",s),e.addEventListener("blur",u)}function hl(){if(document.getElementById("fb-spin-keyframes"))return;const e=document.createElement("style");e.id="fb-spin-keyframes",e.textContent="@keyframes fb-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}function bl(e,t){hl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1234
1212
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
1235
1213
  background: rgba(255,255,255,0.8); display: flex;
1236
1214
  align-items: center; justify-content: center; flex-direction: column;
@@ -1239,13 +1217,13 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1239
1217
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
1240
1218
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
1241
1219
  animation: fb-spin 0.8s linear infinite;
1242
- `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function gl(e,t,n,r,o){var i,a,l,d,s,u,c,f;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,g=(a=(i=e.fieldNames)==null?void 0:i.cells)!=null?a:"cells",C=(d=(l=e.fieldNames)==null?void 0:l.merges)!=null?d:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):Qn((s=e.rows)!=null?s:3,(u=e.columns)!=null?u:3);let y=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},w=document.createElement("input");w.type="hidden",w.name=n,w.value=JSON.stringify({[g]:h,[C]:y}),o.appendChild(w);function k(){w.value=JSON.stringify({[g]:h,[C]:y}),m&&m.triggerOnChange(n,{[g]:h,[C]:y})}w._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),v.anchor=null,v.focus=null,k(),M()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const $=document.createElement("table");$.style.cssText=`
1220
+ `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function vl(e,t,n,r,o){var i,a,l,d,s,u,c,f;const p=r.state,m=r.instance,b=e.mergeAllowed!==!1,g=(a=(i=e.fieldNames)==null?void 0:i.cells)!=null?a:"cells",E=(d=(l=e.fieldNames)==null?void 0:l.merges)!=null?d:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):Zn((s=e.rows)!=null?s:3,(u=e.columns)!=null?u:3);let y=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[g]:h,[E]:y}),o.appendChild(C);function w(){C.value=JSON.stringify({[g]:h,[E]:y}),m&&m.triggerOnChange(n,{[g]:h,[E]:y})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),v.anchor=null,v.focus=null,w(),z()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const S=document.createElement("table");S.style.cssText=`
1243
1221
  border-collapse: collapse;
1244
1222
  font-size: var(--fb-font-size);
1245
1223
  font-family: var(--fb-font-family);
1246
1224
  color: var(--fb-text-color);
1247
1225
  table-layout: fixed;
1248
- `,x.appendChild($);const z=(f=(c=e.importAccept)==null?void 0:c.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function B(A){var T,L,j;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const O=vl(x,E("tableImporting",p));try{const F=await p.config.parseTableFile(A),ne=F.cells,W=(T=F.merges)!=null?T:[];if(W.length>0){const V=Ut(W,ne.length,(j=(L=ne[0])==null?void 0:L.length)!=null?j:0);if(V)throw new Error(V)}h.length=0,ne.forEach(V=>h.push([...V])),y.length=0,W.forEach(V=>y.push({...V})),v.anchor=null,v.focus=null,k(),M()}catch(F){const ne=F instanceof Error?F.message:String(F);console.error(E("tableImportError",p).replace("{error}",ne))}finally{O.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=E("tableImportFile",p),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
1226
+ `,x.appendChild(S);const I=(f=(c=e.importAccept)==null?void 0:c.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function D(A){var T,L,j;if(!p.config.parseTableFile)return;if(I.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!I.includes(F))return}const O=bl(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),ne=F.cells,P=(T=F.merges)!=null?T:[];if(P.length>0){const W=Ut(P,ne.length,(j=(L=ne[0])==null?void 0:L.length)!=null?j:0);if(W)throw new Error(W)}h.length=0,ne.forEach(W=>h.push([...W])),y.length=0,P.forEach(W=>y.push({...W})),v.anchor=null,v.focus=null,w(),z()}catch(F){const ne=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",ne))}finally{O.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=k("tableImportFile",p),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
1249
1227
  position: absolute; top: 2px; left: 2px;
1250
1228
  width: 20px; height: 20px;
1251
1229
  padding: 0;
@@ -1255,7 +1233,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1255
1233
  background: transparent;
1256
1234
  cursor: pointer;
1257
1235
  z-index: 2;
1258
- `,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=z.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var j;const O=(j=T.files)==null?void 0:j[0];O&&B(O),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",j=>{j.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",j=>{j.preventDefault(),j.dataTransfer&&(j.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",j=>{j.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",j=>{var O,F;j.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const ne=(F=(O=j.dataTransfer)==null?void 0:O.files)==null?void 0:F[0];ne&&B(ne)})}o.appendChild(x);const _=document.createElement("div");_.style.cssText=`
1236
+ `,A.addEventListener("mouseenter",()=>{A.style.color="var(--fb-primary-color, #0066cc)"}),A.addEventListener("mouseleave",()=>{A.style.color="var(--fb-text-color, #999)"});const T=document.createElement("input");T.type="file",T.accept=I.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var j;const O=(j=T.files)==null?void 0:j[0];O&&D(O),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",j=>{j.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",j=>{j.preventDefault(),j.dataTransfer&&(j.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",j=>{j.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",j=>{var O,F;j.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const ne=(F=(O=j.dataTransfer)==null?void 0:O.files)==null?void 0:F[0];ne&&D(ne)})}o.appendChild(x);const V=document.createElement("div");V.style.cssText=`
1259
1237
  position: fixed;
1260
1238
  display: none;
1261
1239
  background: white;
@@ -1266,7 +1244,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1266
1244
  z-index: 1000;
1267
1245
  gap: 4px;
1268
1246
  flex-direction: column;
1269
- `,o.appendChild(_);function R(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
1247
+ `,o.appendChild(V);function N(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
1270
1248
  padding: 4px 10px;
1271
1249
  font-size: var(--fb-font-size-small);
1272
1250
  color: var(--fb-text-color);
@@ -1276,8 +1254,8 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1276
1254
  cursor: pointer;
1277
1255
  white-space: nowrap;
1278
1256
  text-align: left;
1279
- `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{P(),T()}),L}function N(A,T){if(!b)return;_.innerHTML="",_.style.display="flex";const L=Ne(v),j=L&&(L.r1!==L.r2||L.c1!==L.c2),O=v.anchor&&mt(v.anchor.row,v.anchor.col,y);if(j&&_.appendChild(R(E("tableMergeCells",p),q)),O&&_.appendChild(R(E("tableSplitCell",p),I)),!_.firstChild){P();return}const F=140,ne=_.children.length*32+8,W=window.innerWidth,V=window.innerHeight,Y=A+F>W?A-F:A,Z=T+ne>V?T-ne:T;_.style.left=`${Y}px`,_.style.top=`${Z}px`}function P(){_.style.display="none"}const J=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){J.abort();return}_.contains(A.target)||P()},{signal:J.signal});function te(){const A=Ne(v);$.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),j=parseInt(T.getAttribute("data-col")||"0",10),O=v.anchor!==null&&v.anchor.row===L&&v.anchor.col===j,F=A!==null&&L>=A.r1&&L<=A.r2&&j>=A.c1&&j<=A.c2;T.style.outline=O?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=O?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!O?"rgba(0,102,204,0.08)":""})}function le(A,T){v.anchor={row:A,col:T},v.focus=null,te(),$.focus()}function he(A,T){const L=$.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const j=L.querySelector("span");j&&(v.anchor={row:A,col:T},v.focus=null,te(),hl(j,A,T,()=>h,k,le))}function Ce(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,j=Array(L).fill(""),O=A!==void 0?A+1:h.length;h.splice(O,0,j),y=y.map(F=>F.top>=O?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<O&&F.bottom>=O?{...F,bottom:F.bottom+1}:F),k(),M()}function Ke(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),k(),M()}function et(A){var T,L;const j=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(O=>O.splice(j,0,"")),y=y.map(O=>O.left>=j?{...O,left:O.left+1,right:O.right+1}:O.left<j&&O.right>=j?{...O,right:O.right+1}:O),k(),M()}function S(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),k(),M()}function q(){var A,T;if(!b)return;const L=Ne(v);if(!L)return;const{r1:j,c1:O,r2:F,c2:ne}=L;if(j===F&&O===ne)return;y=y.filter(U=>!(U.top<=F&&U.bottom>=j&&U.left<=ne&&U.right>=O));const W=h[j][O];for(let U=j;U<=F;U++)for(let Q=O;Q<=ne;Q++)(U!==j||Q!==O)&&(h[U][Q]="");h[j][O]=W;const V={top:j,left:O,bottom:F,right:ne},Y=[...y,V],Z=Ut(Y,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(Z){console.warn("Merge validation failed:",Z);return}y.push(V),v.anchor={row:j,col:O},v.focus=null,k(),M()}function I(){if(!b||!v.anchor)return;const{row:A,col:T}=v.anchor,L=y.findIndex(j=>j.top===A&&j.left===T);L!==-1&&(y.splice(L,1),v.focus=null,k(),M())}function M(){var A,T;$.innerHTML="";const L=h.length,j=L>0?h[0].length:0,O=Ne(v);for(let F=0;F<L;F++){const ne=(F===0?(A=$.tHead)!=null?A:$.createTHead():(T=$.tBodies[0])!=null?T:$.createTBody()).insertRow();for(let W=0;W<j;W++){if(er(F,W,y))continue;const V=mt(F,W,y),Y=document.createElement("td");if(Y.setAttribute("data-row",String(F)),Y.setAttribute("data-col",String(W)),V){const ee=V.bottom-V.top+1,X=V.right-V.left+1;ee>1&&(Y.rowSpan=ee),X>1&&(Y.colSpan=X)}const Z=O!==null&&F>=O.r1&&F<=O.r2&&W>=O.c1&&W<=O.c2,U=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===W;Y.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",F===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",Z&&!U?"background-color: rgba(0,102,204,0.08);":"",U?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Q=document.createElement("span");Q.textContent=h[F][W],Q.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",Y.appendChild(Q);const G=F,ie=W;Y.addEventListener("mousedown",ee=>{if(ee.target.tagName!=="BUTTON"&&ee.target.contentEditable!=="true"){if(ee.button===2){const X=Ne(v);if(X&&G>=X.r1&&G<=X.r2&&ie>=X.c1&&ie<=X.c2)return}ee.shiftKey&&v.anchor?(ee.preventDefault(),v.focus={row:G,col:ie},v.dragging=!1,te()):(v.anchor={row:G,col:ie},v.focus=null,v.dragging=!0,te())}}),Y.addEventListener("mouseup",ee=>{if(ee.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const X=Ne(v);(!X||X.r1===X.r2&&X.c1===X.c2)&&he(G,ie)}}),Y.addEventListener("mousemove",ee=>{if(v.dragging&&ee.buttons===1){const X=v.anchor;X&&(X.row!==G||X.col!==ie)&&(v.focus={row:G,col:ie},te())}}),Y.addEventListener("contextmenu",ee=>{if(!b)return;const X=Ne(v),pe=X&&(X.r1!==X.r2||X.c1!==X.c2),fe=v.anchor&&mt(v.anchor.row,v.anchor.col,y);(pe||fe)&&(ee.preventDefault(),N(ee.clientX,ee.clientY))}),ne.appendChild(Y)}}be(),$.setAttribute("tabindex","0"),$.onkeydown=F=>{var ne,W;if($.querySelector("[contenteditable='true']"))return;const V=v.anchor;if(!V)return;const Y=h.length,Z=Y>0?h[0].length:0,U={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(U[F.key]){F.preventDefault();const[Q,G]=U[F.key],ie=Math.max(0,Math.min(Y-1,V.row+Q)),ee=Math.max(0,Math.min(Z-1,V.col+G));F.shiftKey?(v.focus={row:ie,col:ee},te()):le(ie,ee);return}if(F.key==="Enter"){F.preventDefault(),he(V.row,V.col);return}if(F.key==="Tab"){F.preventDefault();const Q=(W=(ne=h[0])==null?void 0:ne.length)!=null?W:0;let G=V.row,ie=F.shiftKey?V.col-1:V.col+1;ie<0&&(ie=Q-1,G=Math.max(0,G-1)),ie>=Q&&(ie=0,G=Math.min(h.length-1,G+1)),le(G,ie);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),q();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),I())},$.oncopy=F=>{var ne,W,V,Y;const Z=Ne(v);if(!Z)return;F.preventDefault();const{r1:U,c1:Q,r2:G,c2:ie}=Z,ee=[],X=[];for(let K=U;K<=G;K++){const ue=[],ve=[];for(let ge=Q;ge<=ie;ge++){const Ee=(W=(ne=h[K])==null?void 0:ne[ge])!=null?W:"";ue.push(Ee);const Be=Ee.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ve.push(`<td>${Be}</td>`)}ee.push(ue.join(" ")),X.push(`<tr>${ve.join("")}</tr>`)}const pe=ee.join(`
1280
- `),fe=`<table>${X.join("")}</table>`;(V=F.clipboardData)==null||V.setData("text/plain",pe),(Y=F.clipboardData)==null||Y.setData("text/html",fe)},$.onpaste=F=>{var ne,W,V,Y,Z,U,Q,G,ie;const ee=v.anchor;if(!ee)return;const X=(W=(ne=F.clipboardData)==null?void 0:ne.getData("text/plain"))!=null?W:"",pe=X.includes(" ")||X.split(/\r?\n/).filter(me=>me).length>1,fe=$.querySelector("[contenteditable='true']");if(fe&&!pe)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const me=parseInt((Y=(V=fe.closest("td"))==null?void 0:V.getAttribute("data-row"))!=null?Y:"0",10),Ie=parseInt((U=(Z=fe.closest("td"))==null?void 0:Z.getAttribute("data-col"))!=null?U:"0",10);h[me]&&(h[me][Ie]=(Q=fe.textContent)!=null?Q:"")}if(!X.trim())return;const K=X.split(/\r?\n/).map(me=>me.split(" "));K.length>1&&K[K.length-1].length===1&&K[K.length-1][0]===""&&K.pop();const ue=ee.row,ve=ee.col,ge=ue+K.length;for(;h.length<ge;)h.push(Array((ie=(G=h[0])==null?void 0:G.length)!=null?ie:1).fill(""));const Ee=Math.max(...K.map(me=>me.length)),Be=ve+Ee;if(h[0]&&Be>h[0].length){const me=Be-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<me;tt++)Ie.push("")})}for(let me=0;me<K.length;me++)for(let Ie=0;Ie<K[me].length;Ie++){const tt=ue+me,li=ve+Ie;h[tt]&&(h[tt][li]=K[me][Ie])}k(),M()}}const H=Pe({label:"+",title:E("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterCol)!=null?A:"0",10);et(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);const D=Pe({label:"+",title:E("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=D.dataset.afterRow)!=null?A:"0",10);Ce(T)}});D.style.position="absolute",D.style.display="none",x.appendChild(D);let re=[],oe=[];const ce=Pe({label:"+",title:E("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>et()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);const de=Pe({label:"+",title:E("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ce()});de.style.position="absolute",de.style.display="none",x.appendChild(de);function be(){var A,T;re.forEach(W=>W.remove()),re=[],oe.forEach(W=>W.remove()),oe=[];const L=h.length>0?h[0].length:0,j=h.length;if(L>1){const W=Array.from($.querySelectorAll("thead td[data-col]"));for(const V of W){const Y=parseInt((A=V.getAttribute("data-col"))!=null?A:"0",10),Z=Pe({label:"\xD7",title:E("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>S(Y)});Z.setAttribute("data-action","remove-col"),Z.setAttribute("data-col",String(Y)),Z.style.position="absolute",Z.style.display="none",x.appendChild(Z),re.push(Z)}}if(j>1){const W=[...$.tHead?Array.from($.tHead.rows):[],...$.tBodies[0]?Array.from($.tBodies[0].rows):[]].filter(V=>V.querySelector("td[data-row]"));for(const V of W){const Y=V.querySelector("td[data-row]");if(!Y)continue;const Z=parseInt((T=Y.getAttribute("data-row"))!=null?T:"0",10),U=Pe({label:"\xD7",title:E("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ke(Z)});U.setAttribute("data-action","remove-row"),U.setAttribute("data-row",String(Z)),U.style.position="absolute",U.style.display="none",x.appendChild(U),oe.push(U)}}function O(W,V,Y,Z,U){var Q;const G=U?Array.from($.querySelectorAll("thead td[data-col]")):[];let ie=-1,ee=1/0,X=-1,pe=-1,fe=1/0;for(let K=0;K<G.length;K++){const ue=G[K].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ge=Math.abs(W-ve);ge<ee&&(ee=ge,ie=K);const Ee=Math.abs(W-ue.right);Ee<fe&&Ee<20&&(fe=Ee,X=ue.right-V.left+Z,pe=parseInt((Q=G[K].getAttribute("data-col"))!=null?Q:"0",10))}re.forEach((K,ue)=>{if(!U||ue!==ie){K.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ge=(ve.left+ve.right)/2-V.left+Z;K.style.left=`${ge-8}px`,K.style.top="2px",K.style.display="flex"}),U&&pe>=0?(H.style.display="flex",H.style.left=`${X-10}px`,H.style.top=`${Y.top-V.top-10}px`,H.dataset.afterCol=String(pe)):H.style.display="none"}function F(W,V,Y,Z,U){var Q;const G=[];if(U){if($.tHead)for(const K of Array.from($.tHead.rows))K.querySelector("td[data-row]")&&G.push(K);if($.tBodies[0])for(const K of Array.from($.tBodies[0].rows))K.querySelector("td[data-row]")&&G.push(K)}let ie=-1,ee=1/0,X=-1,pe=-1,fe=1/0;for(let K=0;K<G.length;K++){const ue=G[K].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ge=Math.abs(W-ve);ge<ee&&(ee=ge,ie=K);const Ee=Math.abs(W-ue.bottom);if(Ee<fe&&Ee<14){fe=Ee,X=ue.bottom-V.top;const Be=G[K].querySelector("td[data-row]");pe=parseInt((Q=Be==null?void 0:Be.getAttribute("data-row"))!=null?Q:"0",10)}}oe.forEach((K,ue)=>{if(!U||ue!==ie){K.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ge=(ve.top+ve.bottom)/2-V.top;K.style.left="4px",K.style.top=`${ge-8}px`,K.style.display="flex"}),U&&pe>=0?(D.style.display="flex",D.style.top=`${X-10}px`,D.style.left=`${Y.left-V.left+Z-10}px`,D.dataset.afterRow=String(pe)):D.style.display="none"}let ne=!1;x.onmousemove=W=>{const V=W.target;if(V.tagName==="BUTTON"&&V.parentElement===x||ne)return;ne=!0;const Y=W.clientX,Z=W.clientY;requestAnimationFrame(()=>{ne=!1;const U=x.getBoundingClientRect(),Q=$.getBoundingClientRect(),G=x.scrollLeft,ie=Z>=U.top&&Z<Q.top+4,ee=Y>=U.left&&Y<Q.left+4,X=Math.min(Q.right,U.right),pe=Y>X-20&&Y<=U.right,fe=Z>Q.bottom-4&&Z<=U.bottom+20;if(O(Y,U,Q,G,ie),F(Z,U,Q,G,ee),ce.style.display=pe?"flex":"none",pe&&(ce.style.left=`${U.right-U.left+G-20}px`,ce.style.top=`${(Q.top+Q.bottom)/2-U.top-10}px`),de.style.display=fe?"flex":"none",fe){const K=(U.left+U.right)/2-U.left+G;de.style.left=`${K-10}px`,de.style.top=`${Q.bottom-U.top-10}px`}})},x.onmouseleave=()=>{re.forEach(W=>{W.style.display="none"}),oe.forEach(W=>{W.style.display="none"}),H.style.display="none",D.style.display="none",ce.style.display="none",de.style.display="none"}}M()}function yl(e){var t,n;return{cells:Qn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Pt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Wt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function xl(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=t.prefill[e.key],c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges";let p;if(Pt(u))p={cells:u.cells,merges:u.merges?Ue(u.merges):[]};else if(u&&Wt(u,c)){const m=u[f];p={cells:u[c],merges:m?Ue(m):[]}}else if(Pt(e.default))p={cells:e.default.cells,merges:e.default.merges?Ue(e.default.merges):[]};else if(e.default&&Wt(e.default,c)){const m=e.default[f];p={cells:e.default[c],merges:m?Ue(m):[]}}else p=yl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Ut(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}s?ml(p,n):gl(e,p,r,t,n)}function wl(e,t,n){var r,o;const{scopeRoot:i,skipValidation:a}=n,l=[],d=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=i.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:l};let u;try{u=JSON.parse(s.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!a&&e.required){const c=u[d];c!=null&&c.some(f=>f.some(p=>p.trim()!==""))||l.push(`${t}: ${E("required",n.state)}`)}return{value:u,errors:l}}function Cl(e,t,n,r){var o,i,a,l;const{scopeRoot:d}=r,s=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",u=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges",c=d.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(Pt(n))f={cells:n.cells,merges:n.merges?Ue(n.merges):[]};else if(n&&Wt(n,s)){const p=n[u];f={cells:n[s],merges:p?Ue(p):[]}}f&&c._applyExternalUpdate?c._applyExternalUpdate(f):c.value=JSON.stringify(n)}function El(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const i=new ResizeObserver(a=>{var l,d,s,u,c;if(!e.isConnected){i.disconnect();return}const f=a[0],p=(c=(u=(d=(l=f==null?void 0:f.contentBoxSize)==null?void 0:l[0])==null?void 0:d.inlineSize)!=null?u:(s=f==null?void 0:f.contentRect)==null?void 0:s.width)!=null?c:0;p!==o&&(o=p,r())});i.observe(e)}function Vt(e,t){var n,r,o,i;const a=new Map,l=new Map;for(const d of e){const s=t.resourceIndex.get(d),u=(n=s==null?void 0:s.name)!=null?n:d;l.set(u,((r=l.get(u))!=null?r:0)+1)}for(const d of e){const s=t.resourceIndex.get(d),u=(o=s==null?void 0:s.name)!=null?o:d;((i=l.get(u))!=null?i:1)>1&&s?a.set(d,`${u} (${wr(s.size)})`):a.set(d,u)}return a}function Kt(e){return e?e.type.startsWith("image/"):!1}function tr(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ht(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const a=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function kl(e,t){if(t.size===0)return[];const n=ht(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function $l(e,t){const n=kl(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function nr(e,t,n){const r=Vt(t,n),o=new Map;for(const d of t){const s=r.get(d);s&&o.set(d,s)}const i=ht(e);if(i.length===0)return e;let a="",l=0;for(const d of i){a+=e.slice(l,d.start);const s=o.get(d.name);s?a+=_t(s):a+=d.raw,l=d.end}return a+=e.slice(l),a}function rr(e,t,n,r){if(ye(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var a;if(!i||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=i,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ye(e),e.appendChild(l)}).catch(i=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function or(e,t,n,r){if(ye(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ye(e),e.appendChild(a)}).catch(o=>{var i,a;(a=(i=r.config).onThumbnailError)==null||a.call(i,o,t)})}function lr(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,a=n.bottom+8,l=i>=4?i:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function ir(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
1257
+ `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{_(),T()}),L}function R(A,T){if(!b)return;V.innerHTML="",V.style.display="flex";const L=Me(v),j=L&&(L.r1!==L.r2||L.c1!==L.c2),O=v.anchor&&mt(v.anchor.row,v.anchor.col,y);if(j&&V.appendChild(N(k("tableMergeCells",p),q)),O&&V.appendChild(N(k("tableSplitCell",p),M)),!V.firstChild){_();return}const F=140,ne=V.children.length*32+8,P=window.innerWidth,W=window.innerHeight,Y=A+F>P?A-F:A,Z=T+ne>W?T-ne:T;V.style.left=`${Y}px`,V.style.top=`${Z}px`}function _(){V.style.display="none"}const J=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){J.abort();return}V.contains(A.target)||_()},{signal:J.signal});function te(){const A=Me(v);S.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),j=parseInt(T.getAttribute("data-col")||"0",10),O=v.anchor!==null&&v.anchor.row===L&&v.anchor.col===j,F=A!==null&&L>=A.r1&&L<=A.r2&&j>=A.c1&&j<=A.c2;T.style.outline=O?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=O?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!O?"rgba(0,102,204,0.08)":""})}function le(A,T){v.anchor={row:A,col:T},v.focus=null,te(),S.focus()}function he(A,T){const L=S.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const j=L.querySelector("span");j&&(v.anchor={row:A,col:T},v.focus=null,te(),ml(j,A,T,()=>h,w,le))}function Ce(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,j=Array(L).fill(""),O=A!==void 0?A+1:h.length;h.splice(O,0,j),y=y.map(F=>F.top>=O?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<O&&F.bottom>=O?{...F,bottom:F.bottom+1}:F),w(),z()}function Ke(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),w(),z()}function et(A){var T,L;const j=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(O=>O.splice(j,0,"")),y=y.map(O=>O.left>=j?{...O,left:O.left+1,right:O.right+1}:O.left<j&&O.right>=j?{...O,right:O.right+1}:O),w(),z()}function $(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),w(),z()}function q(){var A,T;if(!b)return;const L=Me(v);if(!L)return;const{r1:j,c1:O,r2:F,c2:ne}=L;if(j===F&&O===ne)return;y=y.filter(U=>!(U.top<=F&&U.bottom>=j&&U.left<=ne&&U.right>=O));const P=h[j][O];for(let U=j;U<=F;U++)for(let Q=O;Q<=ne;Q++)(U!==j||Q!==O)&&(h[U][Q]="");h[j][O]=P;const W={top:j,left:O,bottom:F,right:ne},Y=[...y,W],Z=Ut(Y,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(Z){console.warn("Merge validation failed:",Z);return}y.push(W),v.anchor={row:j,col:O},v.focus=null,w(),z()}function M(){if(!b||!v.anchor)return;const{row:A,col:T}=v.anchor,L=y.findIndex(j=>j.top===A&&j.left===T);L!==-1&&(y.splice(L,1),v.focus=null,w(),z())}function z(){var A,T;S.innerHTML="";const L=h.length,j=L>0?h[0].length:0,O=Me(v);for(let F=0;F<L;F++){const ne=(F===0?(A=S.tHead)!=null?A:S.createTHead():(T=S.tBodies[0])!=null?T:S.createTBody()).insertRow();for(let P=0;P<j;P++){if(Qn(F,P,y))continue;const W=mt(F,P,y),Y=document.createElement("td");if(Y.setAttribute("data-row",String(F)),Y.setAttribute("data-col",String(P)),W){const ee=W.bottom-W.top+1,X=W.right-W.left+1;ee>1&&(Y.rowSpan=ee),X>1&&(Y.colSpan=X)}const Z=O!==null&&F>=O.r1&&F<=O.r2&&P>=O.c1&&P<=O.c2,U=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===P;Y.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",F===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",Z&&!U?"background-color: rgba(0,102,204,0.08);":"",U?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Q=document.createElement("span");Q.textContent=h[F][P],Q.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",Y.appendChild(Q);const G=F,ie=P;Y.addEventListener("mousedown",ee=>{if(ee.target.tagName!=="BUTTON"&&ee.target.contentEditable!=="true"){if(ee.button===2){const X=Me(v);if(X&&G>=X.r1&&G<=X.r2&&ie>=X.c1&&ie<=X.c2)return}ee.shiftKey&&v.anchor?(ee.preventDefault(),v.focus={row:G,col:ie},v.dragging=!1,te()):(v.anchor={row:G,col:ie},v.focus=null,v.dragging=!0,te())}}),Y.addEventListener("mouseup",ee=>{if(ee.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const X=Me(v);(!X||X.r1===X.r2&&X.c1===X.c2)&&he(G,ie)}}),Y.addEventListener("mousemove",ee=>{if(v.dragging&&ee.buttons===1){const X=v.anchor;X&&(X.row!==G||X.col!==ie)&&(v.focus={row:G,col:ie},te())}}),Y.addEventListener("contextmenu",ee=>{if(!b)return;const X=Me(v),pe=X&&(X.r1!==X.r2||X.c1!==X.c2),fe=v.anchor&&mt(v.anchor.row,v.anchor.col,y);(pe||fe)&&(ee.preventDefault(),R(ee.clientX,ee.clientY))}),ne.appendChild(Y)}}be(),S.setAttribute("tabindex","0"),S.onkeydown=F=>{var ne,P;if(S.querySelector("[contenteditable='true']"))return;const W=v.anchor;if(!W)return;const Y=h.length,Z=Y>0?h[0].length:0,U={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(U[F.key]){F.preventDefault();const[Q,G]=U[F.key],ie=Math.max(0,Math.min(Y-1,W.row+Q)),ee=Math.max(0,Math.min(Z-1,W.col+G));F.shiftKey?(v.focus={row:ie,col:ee},te()):le(ie,ee);return}if(F.key==="Enter"){F.preventDefault(),he(W.row,W.col);return}if(F.key==="Tab"){F.preventDefault();const Q=(P=(ne=h[0])==null?void 0:ne.length)!=null?P:0;let G=W.row,ie=F.shiftKey?W.col-1:W.col+1;ie<0&&(ie=Q-1,G=Math.max(0,G-1)),ie>=Q&&(ie=0,G=Math.min(h.length-1,G+1)),le(G,ie);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),q();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),M())},S.oncopy=F=>{var ne,P,W,Y;const Z=Me(v);if(!Z)return;F.preventDefault();const{r1:U,c1:Q,r2:G,c2:ie}=Z,ee=[],X=[];for(let K=U;K<=G;K++){const ue=[],ve=[];for(let ge=Q;ge<=ie;ge++){const Ee=(P=(ne=h[K])==null?void 0:ne[ge])!=null?P:"";ue.push(Ee);const Be=Ee.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ve.push(`<td>${Be}</td>`)}ee.push(ue.join(" ")),X.push(`<tr>${ve.join("")}</tr>`)}const pe=ee.join(`
1258
+ `),fe=`<table>${X.join("")}</table>`;(W=F.clipboardData)==null||W.setData("text/plain",pe),(Y=F.clipboardData)==null||Y.setData("text/html",fe)},S.onpaste=F=>{var ne,P,W,Y,Z,U,Q,G,ie;const ee=v.anchor;if(!ee)return;const X=(P=(ne=F.clipboardData)==null?void 0:ne.getData("text/plain"))!=null?P:"",pe=X.includes(" ")||X.split(/\r?\n/).filter(me=>me).length>1,fe=S.querySelector("[contenteditable='true']");if(fe&&!pe)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const me=parseInt((Y=(W=fe.closest("td"))==null?void 0:W.getAttribute("data-row"))!=null?Y:"0",10),Ne=parseInt((U=(Z=fe.closest("td"))==null?void 0:Z.getAttribute("data-col"))!=null?U:"0",10);h[me]&&(h[me][Ne]=(Q=fe.textContent)!=null?Q:"")}if(!X.trim())return;const K=X.split(/\r?\n/).map(me=>me.split(" "));K.length>1&&K[K.length-1].length===1&&K[K.length-1][0]===""&&K.pop();const ue=ee.row,ve=ee.col,ge=ue+K.length;for(;h.length<ge;)h.push(Array((ie=(G=h[0])==null?void 0:G.length)!=null?ie:1).fill(""));const Ee=Math.max(...K.map(me=>me.length)),Be=ve+Ee;if(h[0]&&Be>h[0].length){const me=Be-h[0].length;h.forEach(Ne=>{for(let tt=0;tt<me;tt++)Ne.push("")})}for(let me=0;me<K.length;me++)for(let Ne=0;Ne<K[me].length;Ne++){const tt=ue+me,oi=ve+Ne;h[tt]&&(h[tt][oi]=K[me][Ne])}w(),z()}}const B=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=B.dataset.afterCol)!=null?A:"0",10);et(T)}});B.style.position="absolute",B.style.display="none",x.appendChild(B);const H=Pe({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterRow)!=null?A:"0",10);Ce(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);let re=[],oe=[];const ce=Pe({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>et()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);const de=Pe({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ce()});de.style.position="absolute",de.style.display="none",x.appendChild(de);function be(){var A,T;re.forEach(P=>P.remove()),re=[],oe.forEach(P=>P.remove()),oe=[];const L=h.length>0?h[0].length:0,j=h.length;if(L>1){const P=Array.from(S.querySelectorAll("thead td[data-col]"));for(const W of P){const Y=parseInt((A=W.getAttribute("data-col"))!=null?A:"0",10),Z=Pe({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(Y)});Z.setAttribute("data-action","remove-col"),Z.setAttribute("data-col",String(Y)),Z.style.position="absolute",Z.style.display="none",x.appendChild(Z),re.push(Z)}}if(j>1){const P=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(W=>W.querySelector("td[data-row]"));for(const W of P){const Y=W.querySelector("td[data-row]");if(!Y)continue;const Z=parseInt((T=Y.getAttribute("data-row"))!=null?T:"0",10),U=Pe({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ke(Z)});U.setAttribute("data-action","remove-row"),U.setAttribute("data-row",String(Z)),U.style.position="absolute",U.style.display="none",x.appendChild(U),oe.push(U)}}function O(P,W,Y,Z,U){var Q;const G=U?Array.from(S.querySelectorAll("thead td[data-col]")):[];let ie=-1,ee=1/0,X=-1,pe=-1,fe=1/0;for(let K=0;K<G.length;K++){const ue=G[K].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ge=Math.abs(P-ve);ge<ee&&(ee=ge,ie=K);const Ee=Math.abs(P-ue.right);Ee<fe&&Ee<20&&(fe=Ee,X=ue.right-W.left+Z,pe=parseInt((Q=G[K].getAttribute("data-col"))!=null?Q:"0",10))}re.forEach((K,ue)=>{if(!U||ue!==ie){K.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ge=(ve.left+ve.right)/2-W.left+Z;K.style.left=`${ge-8}px`,K.style.top="2px",K.style.display="flex"}),U&&pe>=0?(B.style.display="flex",B.style.left=`${X-10}px`,B.style.top=`${Y.top-W.top-10}px`,B.dataset.afterCol=String(pe)):B.style.display="none"}function F(P,W,Y,Z,U){var Q;const G=[];if(U){if(S.tHead)for(const K of Array.from(S.tHead.rows))K.querySelector("td[data-row]")&&G.push(K);if(S.tBodies[0])for(const K of Array.from(S.tBodies[0].rows))K.querySelector("td[data-row]")&&G.push(K)}let ie=-1,ee=1/0,X=-1,pe=-1,fe=1/0;for(let K=0;K<G.length;K++){const ue=G[K].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ge=Math.abs(P-ve);ge<ee&&(ee=ge,ie=K);const Ee=Math.abs(P-ue.bottom);if(Ee<fe&&Ee<14){fe=Ee,X=ue.bottom-W.top;const Be=G[K].querySelector("td[data-row]");pe=parseInt((Q=Be==null?void 0:Be.getAttribute("data-row"))!=null?Q:"0",10)}}oe.forEach((K,ue)=>{if(!U||ue!==ie){K.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ge=(ve.top+ve.bottom)/2-W.top;K.style.left="4px",K.style.top=`${ge-8}px`,K.style.display="flex"}),U&&pe>=0?(H.style.display="flex",H.style.top=`${X-10}px`,H.style.left=`${Y.left-W.left+Z-10}px`,H.dataset.afterRow=String(pe)):H.style.display="none"}let ne=!1;x.onmousemove=P=>{const W=P.target;if(W.tagName==="BUTTON"&&W.parentElement===x||ne)return;ne=!0;const Y=P.clientX,Z=P.clientY;requestAnimationFrame(()=>{ne=!1;const U=x.getBoundingClientRect(),Q=S.getBoundingClientRect(),G=x.scrollLeft,ie=Z>=U.top&&Z<Q.top+4,ee=Y>=U.left&&Y<Q.left+4,X=Math.min(Q.right,U.right),pe=Y>X-20&&Y<=U.right,fe=Z>Q.bottom-4&&Z<=U.bottom+20;if(O(Y,U,Q,G,ie),F(Z,U,Q,G,ee),ce.style.display=pe?"flex":"none",pe&&(ce.style.left=`${U.right-U.left+G-20}px`,ce.style.top=`${(Q.top+Q.bottom)/2-U.top-10}px`),de.style.display=fe?"flex":"none",fe){const K=(U.left+U.right)/2-U.left+G;de.style.left=`${K-10}px`,de.style.top=`${Q.bottom-U.top-10}px`}})},x.onmouseleave=()=>{re.forEach(P=>{P.style.display="none"}),oe.forEach(P=>{P.style.display="none"}),B.style.display="none",H.style.display="none",ce.style.display="none",de.style.display="none"}}z()}function gl(e){var t,n;return{cells:Zn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Pt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Wt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function yl(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=t.prefill[e.key],c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges";let p;if(Pt(u))p={cells:u.cells,merges:u.merges?Ue(u.merges):[]};else if(u&&Wt(u,c)){const m=u[f];p={cells:u[c],merges:m?Ue(m):[]}}else if(Pt(e.default))p={cells:e.default.cells,merges:e.default.merges?Ue(e.default.merges):[]};else if(e.default&&Wt(e.default,c)){const m=e.default[f];p={cells:e.default[c],merges:m?Ue(m):[]}}else p=gl(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Ut(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}s?pl(p,n):vl(e,p,r,t,n)}function xl(e,t,n){var r,o;const{scopeRoot:i,skipValidation:a}=n,l=[],d=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=i.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:l};let u;try{u=JSON.parse(s.value)}catch(c){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!a&&e.required){const c=u[d];c!=null&&c.some(f=>f.some(p=>p.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:u,errors:l}}function wl(e,t,n,r){var o,i,a,l;const{scopeRoot:d}=r,s=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",u=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges",c=d.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(Pt(n))f={cells:n.cells,merges:n.merges?Ue(n.merges):[]};else if(n&&Wt(n,s)){const p=n[u];f={cells:n[s],merges:p?Ue(p):[]}}f&&c._applyExternalUpdate?c._applyExternalUpdate(f):c.value=JSON.stringify(n)}function Cl(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const i=new ResizeObserver(a=>{var l,d,s,u,c;if(!e.isConnected){i.disconnect();return}const f=a[0],p=(c=(u=(d=(l=f==null?void 0:f.contentBoxSize)==null?void 0:l[0])==null?void 0:d.inlineSize)!=null?u:(s=f==null?void 0:f.contentRect)==null?void 0:s.width)!=null?c:0;p!==o&&(o=p,r())});i.observe(e)}function Vt(e,t){var n,r,o,i;const a=new Map,l=new Map;for(const d of e){const s=t.resourceIndex.get(d),u=(n=s==null?void 0:s.name)!=null?n:d;l.set(u,((r=l.get(u))!=null?r:0)+1)}for(const d of e){const s=t.resourceIndex.get(d),u=(o=s==null?void 0:s.name)!=null?o:d;((i=l.get(u))!=null?i:1)>1&&s?a.set(d,`${u} (${xr(s.size)})`):a.set(d,u)}return a}function Kt(e){return e?e.type.startsWith("image/"):!1}function er(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ht(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const a=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function El(e,t){if(t.size===0)return[];const n=ht(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function kl(e,t){const n=El(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function tr(e,t,n){const r=Vt(t,n),o=new Map;for(const d of t){const s=r.get(d);s&&o.set(d,s)}const i=ht(e);if(i.length===0)return e;let a="",l=0;for(const d of i){a+=e.slice(l,d.start);const s=o.get(d.name);s?a+=_t(s):a+=d.raw,l=d.end}return a+=e.slice(l),a}function nr(e,t,n,r){if(ye(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var a;if(!i||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=i,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ye(e),e.appendChild(l)}).catch(i=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function rr(e,t,n,r){if(ye(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ye(e),e.appendChild(a)}).catch(o=>{var i,a;(a=(i=r.config).onThumbnailError)==null||a.call(i,o,t)})}function or(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,a=n.bottom+8,l=i>=4?i:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function lr(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
1281
1259
  position: fixed;
1282
1260
  z-index: 99999;
1283
1261
  background: #fff;
@@ -1288,7 +1266,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1288
1266
  pointer-events: none;
1289
1267
  min-width: 60px;
1290
1268
  max-width: 140px;
1291
- `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",or(i,t,r,n),o.appendChild(i),document.body.appendChild(o),lr(o,e),o}function ar(e,t){var n,r;const{rid:o,state:i,isReadonly:a,onMention:l,onRemove:d}=t,s=i.resourceIndex.get(o),u=(n=s==null?void 0:s.name)!=null?n:o,c=document.createElement("div");c.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",c.style.cssText=`
1269
+ `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",rr(i,t,r,n),o.appendChild(i),document.body.appendChild(o),or(o,e),o}function ir(e,t){var n,r;const{rid:o,state:i,isReadonly:a,onMention:l,onRemove:d}=t,s=i.resourceIndex.get(o),u=(n=s==null?void 0:s.name)!=null?n:o,c=document.createElement("div");c.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",c.style.cssText=`
1292
1270
  position: fixed;
1293
1271
  z-index: 99999;
1294
1272
  background: #fff;
@@ -1299,16 +1277,16 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1299
1277
  pointer-events: auto;
1300
1278
  min-width: 80px;
1301
1279
  max-width: 260px;
1302
- `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",or(f,o,s,i),c.appendChild(f);const p=document.createElement("div");p.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",p.textContent=u,c.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},C=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",y=>{y.stopPropagation(),l(),c.remove()}),m.appendChild(h)}if(i.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",y=>{var v,w;y.stopPropagation(),(w=(v=i.config).downloadFile)==null||w.call(v,o,u)}),m.appendChild(h)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",y=>{var v,w,k,x;if(y.stopPropagation(),i.config.getDownloadUrl){const $=i.config.getDownloadUrl(o);$?window.open($,"_blank"):(w=(v=i.config).getThumbnail)==null||w.call(v,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(k=i.config).getThumbnail)==null||x.call(k,o).then($=>{$&&window.open($,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!a&&d){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>C(h)),h.addEventListener("click",y=>{y.stopPropagation(),c.remove(),d()}),m.appendChild(h)}return m.children.length>0&&c.appendChild(m),document.body.appendChild(c),lr(c,e),c}function sr(){return{element:null,hideTimer:null}}function bt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function vt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function We(e){return e&&e.remove(),null}function Sl(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function dr(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const gt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",cr="padding: 8px 40px 8px 10px;";function Ll(e,t,n,r,o){var i;const a=t.state,l=[...o.files],d={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,u=document.createElement("input");u.type="hidden",u.name=r;function c(){var S,q;const I=x.value,M=tr(l,a),H=I?$l(I,M):null,D=(S=e.textKey)!=null?S:"text",re=(q=e.filesKey)!=null?q:"files";return{[D]:I===""?null:H,[re]:[...l]}}function f(){u.value=JSON.stringify(c())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
1280
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",rr(f,o,s,i),c.appendChild(f);const p=document.createElement("div");p.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",p.textContent=u,c.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},E=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),l(),c.remove()}),m.appendChild(h)}if(i.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C;y.stopPropagation(),(C=(v=i.config).downloadFile)==null||C.call(v,o,u)}),m.appendChild(h)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C,w,x;if(y.stopPropagation(),i.config.getDownloadUrl){const S=i.config.getDownloadUrl(o);S?window.open(S,"_blank"):(C=(v=i.config).getThumbnail)==null||C.call(v,o).then(I=>{I&&window.open(I,"_blank")}).catch(()=>{})}else(x=(w=i.config).getThumbnail)==null||x.call(w,o).then(S=>{S&&window.open(S,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!a&&d){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),c.remove(),d()}),m.appendChild(h)}return m.children.length>0&&c.appendChild(m),document.body.appendChild(c),or(c,e),c}function ar(){return{element:null,hideTimer:null}}function bt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function vt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function We(e){return e&&e.remove(),null}function $l(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function sr(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const gt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",dr="padding: 8px 40px 8px 10px;";function Sl(e,t,n,r,o){var i;const a=t.state,l=[...o.files],d={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,u=document.createElement("input");u.type="hidden",u.name=r;function c(){var $,q;const M=x.value,z=er(l,a),B=M?kl(M,z):null,H=($=e.textKey)!=null?$:"text",re=(q=e.filesKey)!=null?q:"files";return{[H]:M===""?null:B,[re]:[...l]}}function f(){u.value=JSON.stringify(c())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
1303
1281
  position: relative;
1304
1282
  border: 1px solid var(--fb-border-color, #d1d5db);
1305
1283
  border-radius: 16px;
1306
1284
  background: var(--fb-background-color, #f9fafb);
1307
1285
  transition: box-shadow 0.15s, border-color 0.15s;
1308
- `,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function g(S){m.textContent=S,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function C(S){var q;const I=ze(e.accept);if(!je(S.name,I)){const H=I.join(", ");return g(E("invalidFileExtension",a,{name:S.name,formats:H})),!1}const M=(q=e.maxSize)!=null?q:1/0;return at(S,M)?!0:(g(E("fileTooLarge",a,{name:S.name,maxSize:M})),!1)}let h=0;p.addEventListener("dragenter",S=>{S.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",S=>{S.preventDefault()}),p.addEventListener("dragleave",S=>{S.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",S=>{var q,I;S.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const M=(q=S.dataTransfer)==null?void 0:q.files;if(!M||!a.config.uploadFile)return;const H=(I=e.maxFiles)!=null?I:1/0;for(let D=0;D<M.length;D++){if(l.length>=H){g(E("filesLimitExceeded",a,{skipped:M.length-D,max:H}));break}C(M[D])&&Ke(M[D])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const v=document.createElement("input");v.type="file",v.multiple=!0,v.style.display="none",e.accept&&(typeof e.accept=="string"?v.accept=e.accept:v.accept=e.accept.extensions.map(S=>S.startsWith(".")?S:`.${S}`).join(","));const w=document.createElement("div");w.style.cssText="position: relative;";const k=document.createElement("div");k.className="fb-richinput-backdrop",k.style.cssText=`
1286
+ `,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function g($){m.textContent=$,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function E($){var q;const M=Ie(e.accept);if(!je($.name,M)){const B=M.join(", ");return g(k("invalidFileExtension",a,{name:$.name,formats:B})),!1}const z=(q=e.maxSize)!=null?q:1/0;return at($,z)?!0:(g(k("fileTooLarge",a,{name:$.name,maxSize:z})),!1)}let h=0;p.addEventListener("dragenter",$=>{$.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",$=>{$.preventDefault()}),p.addEventListener("dragleave",$=>{$.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",$=>{var q,M;$.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const z=(q=$.dataTransfer)==null?void 0:q.files;if(!z||!a.config.uploadFile)return;const B=(M=e.maxFiles)!=null?M:1/0;for(let H=0;H<z.length;H++){if(l.length>=B){g(k("filesLimitExceeded",a,{skipped:z.length-H,max:B}));break}E(z[H])&&Ke(z[H])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const v=document.createElement("input");v.type="file",v.multiple=!0,v.style.display="none",e.accept&&(typeof e.accept=="string"?v.accept=e.accept:v.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const w=document.createElement("div");w.className="fb-richinput-backdrop",w.style.cssText=`
1309
1287
  position: absolute;
1310
1288
  top: 0; left: 0; right: 0; bottom: 0;
1311
- ${cr}
1289
+ ${dr}
1312
1290
  ${gt}
1313
1291
  white-space: pre-wrap;
1314
1292
  word-break: break-word;
@@ -1318,9 +1296,9 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1318
1296
  border-radius: inherit;
1319
1297
  box-sizing: border-box;
1320
1298
  z-index: 2;
1321
- `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||E("richinputPlaceholder",a);const $=(i=o.text)!=null?i:"";x.value=$?nr($,l,a):"",x.style.cssText=`
1299
+ `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",a);const S=(i=o.text)!=null?i:"";x.value=S?tr(S,l,a):"",x.style.cssText=`
1322
1300
  width: 100%;
1323
- ${cr}
1301
+ ${dr}
1324
1302
  ${gt}
1325
1303
  background: transparent;
1326
1304
  border: none;
@@ -1331,9 +1309,9 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1331
1309
  position: relative;
1332
1310
  z-index: 1;
1333
1311
  caret-color: var(--fb-text-color, #111827);
1334
- `,El(x,k),x.addEventListener("scroll",()=>{k.scrollTop=x.scrollTop});let z=null;k.addEventListener("mouseover",S=>{var q,I;const M=(I=(q=S.target).closest)==null?void 0:I.call(q,"mark");M!=null&&M.dataset.rid&&(z=We(z),z=ir(M,M.dataset.rid,a))}),k.addEventListener("mouseout",S=>{var q,I,M;if(!((I=(q=S.target).closest)!=null&&I.call(q,"mark")))return;const H=S.relatedTarget;(M=H==null?void 0:H.closest)!=null&&M.call(H,"mark")||(z=We(z))}),k.addEventListener("mousedown",S=>{var q,I;if(!((I=(q=S.target).closest)!=null&&I.call(q,"mark")))return;z=We(z);const M=k.querySelectorAll("mark");M.forEach(D=>D.style.pointerEvents="none");const H=document.elementFromPoint(S.clientX,S.clientY);H&&H.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:S.clientX,clientY:S.clientY,button:S.button,buttons:S.buttons,detail:S.detail})),document.addEventListener("mouseup",()=>{M.forEach(D=>D.style.pointerEvents="auto")},{once:!0})});function B(){const S=x.value,q=tr(l,a),I=ht(S);if(I.length===0){k.innerHTML=se(S)+`
1335
- `;return}let M="",H=0;for(const D of I){M+=se(S.slice(H,D.start));const re=q.get(D.name);re?M+=`<mark data-rid="${se(re)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${se(S.slice(D.start,D.end))}</mark>`:M+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${se(S.slice(D.start,D.end))}</mark>`,H=D.end}M+=se(S.slice(H)),k.innerHTML=M+`
1336
- `}const _=document.createElement("button");_.type="button",_.title=E("richinputAttachFile",a),_.style.cssText=`
1312
+ `,Cl(x,w),x.addEventListener("scroll",()=>{w.scrollTop=x.scrollTop});let I=null;w.addEventListener("mouseover",$=>{var q,M;const z=(M=(q=$.target).closest)==null?void 0:M.call(q,"mark");z!=null&&z.dataset.rid&&(I=We(I),I=lr(z,z.dataset.rid,a))}),w.addEventListener("mouseout",$=>{var q,M,z;if(!((M=(q=$.target).closest)!=null&&M.call(q,"mark")))return;const B=$.relatedTarget;(z=B==null?void 0:B.closest)!=null&&z.call(B,"mark")||(I=We(I))}),w.addEventListener("mousedown",$=>{var q,M;if(!((M=(q=$.target).closest)!=null&&M.call(q,"mark")))return;I=We(I);const z=w.querySelectorAll("mark");z.forEach(H=>H.style.pointerEvents="none");const B=document.elementFromPoint($.clientX,$.clientY);B&&B.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{z.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function D(){const $=x.value,q=er(l,a),M=ht($);if(M.length===0){w.innerHTML=se($)+`
1313
+ `;return}let z="",B=0;for(const H of M){z+=se($.slice(B,H.start));const re=q.get(H.name);re?z+=`<mark data-rid="${se(re)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${se($.slice(H.start,H.end))}</mark>`:z+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${se($.slice(H.start,H.end))}</mark>`,B=H.end}z+=se($.slice(B)),w.innerHTML=z+`
1314
+ `}const V=document.createElement("button");V.type="button",V.title=k("richinputAttachFile",a),V.style.cssText=`
1337
1315
  position: absolute;
1338
1316
  right: 6px;
1339
1317
  bottom: 6px;
@@ -1349,7 +1327,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1349
1327
  justify-content: center;
1350
1328
  color: var(--fb-text-muted-color, #9ca3af);
1351
1329
  transition: color 0.15s, background 0.15s;
1352
- `,_.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',_.addEventListener("mouseenter",()=>{_.style.color="var(--fb-primary-color, #0066cc)",_.style.background="var(--fb-background-hover-color, #f3f4f6)"}),_.addEventListener("mouseleave",()=>{_.style.color="var(--fb-text-muted-color, #9ca3af)",_.style.background="transparent"}),_.addEventListener("click",()=>{var S;const q=(S=e.maxFiles)!=null?S:1/0;if(l.length>=q){g(E("filesLimitExceeded",a,{skipped:1,max:q}));return}v.click()});const R=document.createElement("div");R.className="fb-richinput-dropdown",R.style.cssText=`
1330
+ `,V.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',V.addEventListener("mouseenter",()=>{V.style.color="var(--fb-primary-color, #0066cc)",V.style.background="var(--fb-background-hover-color, #f3f4f6)"}),V.addEventListener("mouseleave",()=>{V.style.color="var(--fb-text-muted-color, #9ca3af)",V.style.background="transparent"}),V.addEventListener("click",()=>{var $;const q=($=e.maxFiles)!=null?$:1/0;if(l.length>=q){g(k("filesLimitExceeded",a,{skipped:1,max:q}));return}v.click()});const N=document.createElement("div");N.className="fb-richinput-dropdown",N.style.cssText=`
1353
1331
  display: none;
1354
1332
  position: absolute;
1355
1333
  bottom: 100%;
@@ -1365,15 +1343,15 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1365
1343
  overflow-y: auto;
1366
1344
  margin-bottom: 4px;
1367
1345
  ${gt}
1368
- `;function N(){return Vt(l,a)}function P(S){ye(R);const q=N();if(S.length===0){R.style.display="none",d.open=!1;return}S.forEach((I,M)=>{var H;const D=a.resourceIndex.get(I),re=document.createElement("div");re.className="fb-richinput-dropdown-item",re.dataset.rid=I,re.style.cssText=`
1346
+ `;function R(){return Vt(l,a)}function _($){ye(N);const q=R();if($.length===0){N.style.display="none",d.open=!1;return}$.forEach((M,z)=>{var B;const H=a.resourceIndex.get(M),re=document.createElement("div");re.className="fb-richinput-dropdown-item",re.dataset.rid=M,re.style.cssText=`
1369
1347
  padding: 5px 10px;
1370
1348
  cursor: pointer;
1371
1349
  color: var(--fb-text-color, #111827);
1372
- background: ${M===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1350
+ background: ${z===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1373
1351
  display: flex;
1374
1352
  align-items: center;
1375
1353
  gap: 8px;
1376
- `;const oe=document.createElement("div");if(oe.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",D!=null&&D.file&&Kt(D)){const de=document.createElement("img");de.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const be=new FileReader;be.onload=A=>{var T;de.src=((T=A.target)==null?void 0:T.result)||""},be.readAsDataURL(D.file),oe.appendChild(de)}else a.config.getThumbnail&&a.config.getThumbnail(I).then(de=>{if(!de||!oe.isConnected)return;const be=document.createElement("img");be.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be.src=de,ye(oe),oe.appendChild(be)}).catch(()=>{}),oe.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';re.appendChild(oe);const ce=document.createElement("span");ce.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ce.textContent=(H=q.get(I))!=null?H:I,re.appendChild(ce),R.appendChild(re)}),R.onmousemove=I=>{var M,H,D;const re=(H=(M=I.target).closest)==null?void 0:H.call(M,".fb-richinput-dropdown-item");if(!re)return;const oe=S.indexOf((D=re.dataset.rid)!=null?D:"");oe===-1||oe===d.selectedIndex||(R.querySelectorAll(".fb-richinput-dropdown-item").forEach((ce,de)=>{ce.style.background=de===oe?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),d.selectedIndex=oe)},R.onmousedown=I=>{var M,H;I.preventDefault(),I.stopPropagation();const D=(H=(M=I.target).closest)==null?void 0:H.call(M,".fb-richinput-dropdown-item");D!=null&&D.dataset.rid&&le(D.dataset.rid)},R.style.display="block",d.open=!0}function J(){const S=Sl(x);if(!S){te();return}d.query=S.query,d.triggerPos=S.pos,d.selectedIndex=0;const q=N(),I=dr(S.query,l,q);P(I)}function te(){R.style.display="none",d.open=!1}function le(S){var q,I,M,H;const D=(M=(I=N().get(S))!=null?I:(q=a.resourceIndex.get(S))==null?void 0:q.name)!=null?M:S,re=(H=x.selectionStart)!=null?H:0,oe=x.value.slice(0,d.triggerPos),ce=x.value.slice(re),de=`${_t(D)} `;x.value=`${oe}${de}${ce}`;const be=oe.length+de.length;x.setSelectionRange(be,be),x.dispatchEvent(new Event("input")),te()}x.addEventListener("input",()=>{var S;B(),f(),(S=t.instance)==null||S.triggerOnChange(r,c()),l.length>0?J():te()});function he(){R.querySelectorAll(".fb-richinput-dropdown-item").forEach((S,q)=>{S.style.background=q===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",S=>{if(!d.open)return;const q=N(),I=dr(d.query,l,q);S.key==="ArrowDown"?(S.preventDefault(),d.selectedIndex=Math.min(d.selectedIndex+1,I.length-1),he()):S.key==="ArrowUp"?(S.preventDefault(),d.selectedIndex=Math.max(d.selectedIndex-1,0),he()):S.key==="Enter"&&I.length>0?(S.preventDefault(),le(I[d.selectedIndex])):S.key==="Escape"&&te()}),document.addEventListener("click",S=>{!p.contains(S.target)&&!R.contains(S.target)&&te()},{signal:s.signal});function Ce(){if(ye(y),l.length===0){y.style.display="none";return}y.style.display="flex",l.forEach(S=>{const q=a.resourceIndex.get(S),I=document.createElement("div");I.className="fb-richinput-file-thumb",I.style.cssText=`
1354
+ `;const oe=document.createElement("div");if(oe.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",H!=null&&H.file&&Kt(H)){const de=document.createElement("img");de.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const be=new FileReader;be.onload=A=>{var T;de.src=((T=A.target)==null?void 0:T.result)||""},be.readAsDataURL(H.file),oe.appendChild(de)}else a.config.getThumbnail&&a.config.getThumbnail(M).then(de=>{if(!de||!oe.isConnected)return;const be=document.createElement("img");be.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be.src=de,ye(oe),oe.appendChild(be)}).catch(()=>{}),oe.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';re.appendChild(oe);const ce=document.createElement("span");ce.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ce.textContent=(B=q.get(M))!=null?B:M,re.appendChild(ce),N.appendChild(re)}),N.onmousemove=M=>{var z,B,H;const re=(B=(z=M.target).closest)==null?void 0:B.call(z,".fb-richinput-dropdown-item");if(!re)return;const oe=$.indexOf((H=re.dataset.rid)!=null?H:"");oe===-1||oe===d.selectedIndex||(N.querySelectorAll(".fb-richinput-dropdown-item").forEach((ce,de)=>{ce.style.background=de===oe?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),d.selectedIndex=oe)},N.onmousedown=M=>{var z,B;M.preventDefault(),M.stopPropagation();const H=(B=(z=M.target).closest)==null?void 0:B.call(z,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&le(H.dataset.rid)},N.style.display="block",d.open=!0}function J(){const $=$l(x);if(!$){te();return}d.query=$.query,d.triggerPos=$.pos,d.selectedIndex=0;const q=R(),M=sr($.query,l,q);_(M)}function te(){N.style.display="none",d.open=!1}function le($){var q,M,z,B;const H=(z=(M=R().get($))!=null?M:(q=a.resourceIndex.get($))==null?void 0:q.name)!=null?z:$,re=(B=x.selectionStart)!=null?B:0,oe=x.value.slice(0,d.triggerPos),ce=x.value.slice(re),de=`${_t(H)} `;x.value=`${oe}${de}${ce}`;const be=oe.length+de.length;x.setSelectionRange(be,be),x.dispatchEvent(new Event("input")),te()}x.addEventListener("input",()=>{var $;D(),f(),($=t.instance)==null||$.triggerOnChange(r,c()),l.length>0?J():te()});function he(){N.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,q)=>{$.style.background=q===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",$=>{if(!d.open)return;const q=R(),M=sr(d.query,l,q);$.key==="ArrowDown"?($.preventDefault(),d.selectedIndex=Math.min(d.selectedIndex+1,M.length-1),he()):$.key==="ArrowUp"?($.preventDefault(),d.selectedIndex=Math.max(d.selectedIndex-1,0),he()):$.key==="Enter"&&M.length>0?($.preventDefault(),le(M[d.selectedIndex])):$.key==="Escape"&&te()}),document.addEventListener("click",$=>{!p.contains($.target)&&!N.contains($.target)&&te()},{signal:s.signal});function Ce(){if(ye(y),l.length===0){y.style.display="none";return}y.style.display="flex",l.forEach($=>{const q=a.resourceIndex.get($),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
1377
1355
  position: relative;
1378
1356
  width: 48px;
1379
1357
  height: 48px;
@@ -1383,14 +1361,14 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1383
1361
  flex-shrink: 0;
1384
1362
  cursor: pointer;
1385
1363
  background: #fff;
1386
- `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",rr(M,S,q,a),I.appendChild(M);const H=sr(),D=()=>{var oe,ce,de;const be=(oe=x.selectionStart)!=null?oe:x.value.length,A=(de=(ce=N().get(S))!=null?ce:q==null?void 0:q.name)!=null?de:S,T=x.value.slice(0,be),L=x.value.slice(be),j=`${T.length>0&&!/[\s\n]$/.test(T)?`
1387
- `:""}${_t(A)} `;x.value=`${T}${j}${L}`;const O=be+j.length;x.setSelectionRange(O,O),x.focus(),x.dispatchEvent(new Event("input"))},re=()=>{var oe;const ce=l.indexOf(S);ce!==-1&&l.splice(ce,1),Ce(),B(),f(),(oe=t.instance)==null||oe.triggerOnChange(r,c())};I.addEventListener("mouseenter",()=>{vt(H),H.element||(H.element=ar(I,{rid:S,state:a,isReadonly:!1,onMention:D,onRemove:re}),H.element.addEventListener("mouseenter",()=>{vt(H)}),H.element.addEventListener("mouseleave",()=>{bt(H)}))}),I.addEventListener("mouseleave",()=>{bt(H)}),y.appendChild(I)})}function Ke(S){if(!a.config.uploadFile)return;const q=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;a.resourceIndex.set(q,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),l.push(q),Ce();const I=y.querySelectorAll(".fb-richinput-file-thumb"),M=I[I.length-1];M&&(M.style.opacity="0.5"),a.config.uploadFile(S).then(H=>{var D;const re=l.indexOf(q);re!==-1&&(l[re]=H),a.resourceIndex.delete(q),a.resourceIndex.set(H,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),Ce(),B(),f(),(D=t.instance)==null||D.triggerOnChange(r,c())}).catch(H=>{var D,re;const oe=l.indexOf(q);oe!==-1&&l.splice(oe,1),a.resourceIndex.delete(q),Ce(),(re=(D=a.config).onUploadError)==null||re.call(D,H,S)})}if(v.addEventListener("change",()=>{var S;const q=v.files;if(!q||q.length===0)return;const I=(S=e.maxFiles)!=null?S:1/0;for(let M=0;M<q.length;M++){if(l.length>=I){g(E("filesLimitExceeded",a,{skipped:q.length-M,max:I}));break}C(q[M])&&Ke(q[M])}v.value=""}),w.appendChild(k),w.appendChild(x),w.appendChild(_),w.appendChild(R),p.appendChild(y),p.appendChild(w),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const S=document.createElement("div");S.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const q=ot(e,x);q.style.cssText=`
1364
+ `;const z=document.createElement("div");z.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",nr(z,$,q,a),M.appendChild(z);const B=ar(),H=()=>{var oe,ce,de;const be=(oe=x.selectionStart)!=null?oe:x.value.length,A=(de=(ce=R().get($))!=null?ce:q==null?void 0:q.name)!=null?de:$,T=x.value.slice(0,be),L=x.value.slice(be),j=`${T.length>0&&!/[\s\n]$/.test(T)?`
1365
+ `:""}${_t(A)} `;x.value=`${T}${j}${L}`;const O=be+j.length;x.setSelectionRange(O,O),x.focus(),x.dispatchEvent(new Event("input"))},re=()=>{var oe;const ce=l.indexOf($);ce!==-1&&l.splice(ce,1),Ce(),D(),f(),(oe=t.instance)==null||oe.triggerOnChange(r,c())};M.addEventListener("mouseenter",()=>{vt(B),B.element||(B.element=ir(M,{rid:$,state:a,isReadonly:!1,onMention:H,onRemove:re}),B.element.addEventListener("mouseenter",()=>{vt(B)}),B.element.addEventListener("mouseleave",()=>{bt(B)}))}),M.addEventListener("mouseleave",()=>{bt(B)}),y.appendChild(M)})}function Ke($){if(!a.config.uploadFile)return;const q=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;a.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),l.push(q),Ce();const M=y.querySelectorAll(".fb-richinput-file-thumb"),z=M[M.length-1];z&&(z.style.opacity="0.5"),a.config.uploadFile($).then(B=>{var H;const re=l.indexOf(q);re!==-1&&(l[re]=B),a.resourceIndex.delete(q),a.resourceIndex.set(B,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),Ce(),D(),f(),(H=t.instance)==null||H.triggerOnChange(r,c())}).catch(B=>{var H,re;const oe=l.indexOf(q);oe!==-1&&l.splice(oe,1),a.resourceIndex.delete(q),Ce(),(re=(H=a.config).onUploadError)==null||re.call(H,B,$)})}if(v.addEventListener("change",()=>{var $;const q=v.files;if(!q||q.length===0)return;const M=($=e.maxFiles)!=null?$:1/0;for(let z=0;z<q.length;z++){if(l.length>=M){g(k("filesLimitExceeded",a,{skipped:q.length-z,max:M}));break}E(q[z])&&Ke(q[z])}v.value=""}),C.appendChild(w),C.appendChild(x),C.appendChild(V),C.appendChild(N),p.appendChild(y),p.appendChild(C),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const q=ot(e,x);q.style.cssText=`
1388
1366
  position: static;
1389
1367
  display: inline-block;
1390
1368
  font-size: var(--fb-font-size-small);
1391
1369
  color: var(--fb-text-secondary-color);
1392
1370
  pointer-events: none;
1393
- `,S.appendChild(q),p.appendChild(S)}p.appendChild(u),p.appendChild(v),f(),B(),u._applyExternalUpdate=S=>{var q;const I=(q=S.text)!=null?q:"";x.value=I?nr(I,l,a):"",x.dispatchEvent(new Event("input")),l.length=0;for(const M of S.files)l.push(M);Ce(),B(),f()},n.appendChild(p),Ce();const et=new MutationObserver(()=>{p.isConnected||(s.abort(),z=We(z),et.disconnect())});p.parentElement&&et.observe(p.parentElement,{childList:!0})}function Tl(e,t,n,r,o){var i,a;const l=t.state,{text:d,files:s}=o,u=new Map;for(const c of s){const f=l.resourceIndex.get(c);f!=null&&f.name&&u.set(c,f.name)}if(s.length>0){const c=document.createElement("div");c.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(f=>{const p=l.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
1371
+ `,$.appendChild(q),p.appendChild($)}p.appendChild(u),p.appendChild(v),f(),D(),u._applyExternalUpdate=$=>{var q;const M=(q=$.text)!=null?q:"";x.value=M?tr(M,l,a):"",x.dispatchEvent(new Event("input")),l.length=0;for(const z of $.files)l.push(z);Ce(),D(),f()},n.appendChild(p),Ce();const et=new MutationObserver(()=>{p.isConnected||(s.abort(),I=We(I),et.disconnect())});p.parentElement&&et.observe(p.parentElement,{childList:!0})}function Ll(e,t,n,r,o){var i,a;const l=t.state,{text:d,files:s}=o,u=new Map;for(const c of s){const f=l.resourceIndex.get(c);f!=null&&f.name&&u.set(c,f.name)}if(s.length>0){const c=document.createElement("div");c.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(f=>{const p=l.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
1394
1372
  position: relative;
1395
1373
  width: 48px; height: 48px;
1396
1374
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -1399,7 +1377,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1399
1377
  flex-shrink: 0;
1400
1378
  background: #fff;
1401
1379
  cursor: default;
1402
- `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",rr(b,f,p,l),m.appendChild(b);const g=sr();m.addEventListener("mouseenter",()=>{vt(g),g.element||(g.element=ar(m,{rid:f,state:l,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{vt(g)}),g.element.addEventListener("mouseleave",()=>{bt(g)}))}),m.addEventListener("mouseleave",()=>{bt(g)}),c.appendChild(m)}),n.appendChild(c)}if(d){const c=document.createElement("div");c.style.cssText=`
1380
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",nr(b,f,p,l),m.appendChild(b);const g=ar();m.addEventListener("mouseenter",()=>{vt(g),g.element||(g.element=ir(m,{rid:f,state:l,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{vt(g)}),g.element.addEventListener("mouseleave",()=>{bt(g)}))}),m.addEventListener("mouseleave",()=>{bt(g)}),c.appendChild(m)}),n.appendChild(c)}if(d){const c=document.createElement("div");c.style.cssText=`
1403
1381
  ${gt}
1404
1382
  color: var(--fb-text-color, #111827);
1405
1383
  white-space: pre-wrap;
@@ -1412,7 +1390,7 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1412
1390
  padding: 1px 6px;
1413
1391
  font-weight: 500;
1414
1392
  cursor: default;
1415
- `;const g=u.has(m.name)?m.name:(i=[...u.entries()].find(([,h])=>h===m.name))==null?void 0:i[0],C=(a=u.get(m.name))!=null?a:m.name;if(b.textContent=`@${C}`,g){let h=null;const y=g;b.addEventListener("mouseenter",()=>{h=We(h),h=ir(b,y,l)}),b.addEventListener("mouseleave",()=>{h=We(h)})}c.appendChild(b),p=m.end}p<d.length&&c.appendChild(document.createTextNode(d.slice(p)))}n.appendChild(c)}if(!d&&s.length===0){const c=document.createElement("div");c.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",c.textContent="\u2014",n.appendChild(c)}}function Al(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=(o=e.textKey)!=null?o:"text",c=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const p=t.prefill[u],m=t.prefill[c];f={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(a=m[u])!=null?a:m.text,g=(l=m[c])!=null?l:m.files;f={text:typeof b=="string"?b:null,files:Array.isArray(g)?g:[]}}else typeof p=="string"?f={text:p||null,files:[]}:f={text:null,files:[]}}for(const p of f.files)d.resourceIndex.has(p)||d.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)Tl(e,t,n,r,f);else{if(!d.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ll(e,t,n,r,f)}}function Fl(e,t,n){var r,o;const{scopeRoot:i,state:a,skipValidation:l}=n,d=[],s=(r=e.textKey)!=null?r:"text",u=(o=e.filesKey)!=null?o:"files",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:d};let f;try{const h=JSON.parse(c.value);if(h&&typeof h=="object"&&!Array.isArray(h))f=h;else return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}catch(h){return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}const p=f[s],m=f[u],b=p===null||typeof p=="string"?p:null,g=Array.isArray(m)?m:[],C={[s]:b!=null?b:null,[u]:g};if(!l){const h=!b||b.trim()==="",y=g.length===0;e.required&&h&&y&&d.push(`${t}: ${E("required",a)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&d.push(`${t}: ${E("minLength",a,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&d.push(`${t}: ${E("maxLength",a,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&d.push(`${t}: ${E("maxFiles",a,{max:e.maxFiles})}`)}return{value:C,errors:d,spread:!!e.flatOutput}}function zl(e,t,n,r){var o,i,a,l;const{scopeRoot:d}=r,s=d.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const c=n,f=(o=e.textKey)!=null?o:"text",p=(i=e.filesKey)!=null?i:"files",m=(a=c[f])!=null?a:c.text,b=(l=c[p])!=null?l:c.files;(m!==void 0||b!==void 0)&&(u={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}u&&s._applyExternalUpdate?s._applyExternalUpdate(u):u&&(s.value=JSON.stringify(u))}const Ml={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function ur(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Qe(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jt(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const i=t||{};let a=0,l,d,s,u,c;function f(m){const b=Ml[m[1]||""],g=r[r.length-1]===m;return b?b[1]?(g?r.pop():r.push(m),b[g?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,g)=>(i[b.toLowerCase()]=g,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)d=e.substring(a,s.index),a=n.lastIndex,l=s[0],d.match(/[^\\](\\\\)*\\$/)||((c=s[3]||s[4])?l='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+ur(Qe(c).replace(/^\n+|\n+$/g,""))+"</code></pre>":(c=s[6])?(c.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),u=Jt(ur(s[5].replace(/^\s*[>*+.-]/gm,""))),c===">"?c="blockquote":(c=c.match(/\./)?"ol":"ul",u=u.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+c+">"+u+"</"+c+">"):s[8]?l=`<img src="${Qe(s[8])}" alt="${Qe(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${Qe(s[11]||i[d.toLowerCase()])}">`),l=p()+"</a>"):s[9]?l="<a>":s[12]||s[14]?(c="h"+(s[14]?s[14].length:s[13]>"="?1:2),l="<"+c+">"+Jt(s[12]||s[15],i)+"</"+c+">"):s[16]?l="<code>"+Qe(s[16])+"</code>":(s[17]||s[1])&&(l=f(s[17]||"--"))),o+=d,o+=l;return(o+e.substring(a)+p()).replace(/^\n+|\n+$/g,"")}const fr="fb-markdown-styles";function Nl(){if(typeof document=="undefined"||document.getElementById(fr))return;const e=document.createElement("style");e.id=fr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1393
+ `;const g=u.has(m.name)?m.name:(i=[...u.entries()].find(([,h])=>h===m.name))==null?void 0:i[0],E=(a=u.get(m.name))!=null?a:m.name;if(b.textContent=`@${E}`,g){let h=null;const y=g;b.addEventListener("mouseenter",()=>{h=We(h),h=lr(b,y,l)}),b.addEventListener("mouseleave",()=>{h=We(h)})}c.appendChild(b),p=m.end}p<d.length&&c.appendChild(document.createTextNode(d.slice(p)))}n.appendChild(c)}if(!d&&s.length===0){const c=document.createElement("div");c.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",c.textContent="\u2014",n.appendChild(c)}}function Tl(e,t,n,r){var o,i,a,l;const d=t.state,s=ae(e,d,t),u=(o=e.textKey)!=null?o:"text",c=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const p=t.prefill[u],m=t.prefill[c];f={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(a=m[u])!=null?a:m.text,g=(l=m[c])!=null?l:m.files;f={text:typeof b=="string"?b:null,files:Array.isArray(g)?g:[]}}else typeof p=="string"?f={text:p||null,files:[]}:f={text:null,files:[]}}for(const p of f.files)d.resourceIndex.has(p)||d.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)Ll(e,t,n,r,f);else{if(!d.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Sl(e,t,n,r,f)}}function Al(e,t,n){var r,o;const{scopeRoot:i,state:a,skipValidation:l}=n,d=[],s=(r=e.textKey)!=null?r:"text",u=(o=e.filesKey)!=null?o:"files",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:d};let f;try{const h=JSON.parse(c.value);if(h&&typeof h=="object"&&!Array.isArray(h))f=h;else return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}catch(h){return d.push(`${t}: invalid richinput data`),{value:null,errors:d}}const p=f[s],m=f[u],b=p===null||typeof p=="string"?p:null,g=Array.isArray(m)?m:[],E={[s]:b!=null?b:null,[u]:g};if(!l){const h=!b||b.trim()==="",y=g.length===0;e.required&&h&&y&&d.push(`${t}: ${k("required",a)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&d.push(`${t}: ${k("minLength",a,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&d.push(`${t}: ${k("maxLength",a,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&d.push(`${t}: ${k("maxFiles",a,{max:e.maxFiles})}`)}return{value:E,errors:d,spread:!!e.flatOutput}}function Fl(e,t,n,r){var o,i,a,l;const{scopeRoot:d}=r,s=d.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const c=n,f=(o=e.textKey)!=null?o:"text",p=(i=e.filesKey)!=null?i:"files",m=(a=c[f])!=null?a:c.text,b=(l=c[p])!=null?l:c.files;(m!==void 0||b!==void 0)&&(u={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}u&&s._applyExternalUpdate?s._applyExternalUpdate(u):u&&(s.value=JSON.stringify(u))}const zl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function cr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function Qe(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jt(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const i=t||{};let a=0,l,d,s,u,c;function f(m){const b=zl[m[1]||""],g=r[r.length-1]===m;return b?b[1]?(g?r.pop():r.push(m),b[g?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,g)=>(i[b.toLowerCase()]=g,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)d=e.substring(a,s.index),a=n.lastIndex,l=s[0],d.match(/[^\\](\\\\)*\\$/)||((c=s[3]||s[4])?l='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+cr(Qe(c).replace(/^\n+|\n+$/g,""))+"</code></pre>":(c=s[6])?(c.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),u=Jt(cr(s[5].replace(/^\s*[>*+.-]/gm,""))),c===">"?c="blockquote":(c=c.match(/\./)?"ol":"ul",u=u.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+c+">"+u+"</"+c+">"):s[8]?l=`<img src="${Qe(s[8])}" alt="${Qe(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${Qe(s[11]||i[d.toLowerCase()])}">`),l=p()+"</a>"):s[9]?l="<a>":s[12]||s[14]?(c="h"+(s[14]?s[14].length:s[13]>"="?1:2),l="<"+c+">"+Jt(s[12]||s[15],i)+"</"+c+">"):s[16]?l="<code>"+Qe(s[16])+"</code>":(s[17]||s[1])&&(l=f(s[17]||"--"))),o+=d,o+=l;return(o+e.substring(a)+p()).replace(/^\n+|\n+$/g,"")}const ur="fb-markdown-styles";function Ml(){if(typeof document=="undefined"||document.getElementById(ur))return;const e=document.createElement("style");e.id=ur,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1416
1394
  .fb-markdown {
1417
1395
  font-family: var(--fb-font-family, inherit);
1418
1396
  font-size: var(--fb-font-size, 1rem);
@@ -1489,11 +1467,11 @@ var FormBuilder=(function(Ae){"use strict";function E(e,t,n){const r=t.config.lo
1489
1467
  .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1490
1468
  .fb-markdown em { font-style: italic; }
1491
1469
  .fb-markdown s { text-decoration: line-through; }
1492
- `,document.head.appendChild(e)}const Il=["javascript:","data:","vbscript:","blob:"],ql=["javascript:","vbscript:","blob:"];function Rl(e){return!!(ql.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Bl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Hl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Il.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();Rl(r)&&t.setAttribute("src","")})}function Dl(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);Nl();const r=document.createElement("div");r.className="fb-markdown";const o=Bl(e.content);return r.innerHTML=Jt(o),Hl(r),n.appendChild(r),r}function jl(e,t,n){return{value:void 0,errors:[],skip:!0}}function Ol(e,t,n,r){}function Ul(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";if(a===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Qt(a),errors:[]}}function Pl(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Zt(n))}const Wl={text:{validate:rn,update:on},textarea:{validate:Fr,update:zr},number:{validate:Rr,update:Br},select:{validate:jr,update:Or},switcher:{validate:Vr,update:Kr},boolean:{validate:Yr,update:Xr,ownsLabel:!0},file:{validate:Rn,update:Hn},files:{validate:Rn,update:Hn},colour:{validate:el,update:tl},slider:{validate:ol,update:ll},container:{validate:Xn,update:Gn},group:{validate:dl,update:cl},table:{validate:wl,update:Cl},richinput:{validate:Fl,update:zl},hidden:{validate:Ul,update:Pl},markdown:{validate:jl,update:Ol}};function Yt(e){return Wl[e]||null}function Vl(e,t,n){const r=Yt(e.type);return r&&r.validate?r.validate(e,t,n):null}function Kl(e,t,n,r){const o=Yt(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function _l(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(u=>{u.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let d=o.left,s=o.bottom+5;d+l.width>i&&(d=o.right-l.width),s+l.height>a&&(s=o.top-l.height-5),d<10&&(d=10),s<10&&(s=o.bottom+5),n.style.left=`${d}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function pr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!He(e.enableIf,i,a)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function Jl(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function Yl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],d=n[a+1],s=d.startsWith("[")&&d.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=s}else o[l]=s;o=s}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function yt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,d=i.key,s=l==="relative"&&n.path?`${n.path}.${d}`:d,u=Jl(s,o),c=Yl(d,u),f=l==="relative"?{}:c,p=l==="relative"?c:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function mr(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=i.key;let d;a==="relative"&&n.path?d=`${n.path}.${l}`:d=l;const s=o.querySelector(`[name="${d}"]`);if(!s){const u=new MutationObserver(()=>{const c=o.querySelector(`[name="${d}"]`);c&&(c.addEventListener("change",()=>{yt(e,t,n)}),c.addEventListener("input",()=>{yt(e,t,n)}),u.disconnect(),n.state.enableIfObservers.delete(u))});n.state.enableIfObservers.add(u),u.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{yt(e,t,n)}),s.addEventListener("input",()=>{yt(e,t,n)})}function Xl(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function Gl(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),_l(n,t)},t}function Zl(e){const t=document.createElement("div");t.className="flex items-center",t.style.marginBottom="var(--fb-label-margin-bottom, 2px)",t.dataset.fbLabelRow="";const n=Xl(e);if(t.appendChild(n),e.description||e.hint){const r=Gl(e);t.appendChild(r)}return t}function Ql(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Lr(e,t,n,r):Sr(e,t,n,r);break;case"textarea":o?Ar(e,t,n,r):Tr(e,t,n,r);break;case"number":o?qr(e,t,n,r):Ir(e,t,n,r);break;case"select":o?Dr(e,t,n,r):Hr(e,t,n,r);break;case"switcher":o?Wr(e,t,n,r):Pr(e,t,n,r);break;case"boolean":Jr(e,t,n,r);break;case"file":o?Go(e,t,n,r):Yo(e,t,n,r);break;case"files":Xo(e,t,n,r);break;case"colour":o?Qo(e,t,n,r):Zo(e,t,n,r);break;case"slider":o?rl(e,t,n,r):nl(e,t,n,r);break;case"group":sl(e,t,n,r);break;case"container":o?Jn(e,t,n):_n(e,t,n,r);break;case"table":xl(e,t,n,r);break;case"richinput":Al(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=E("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function Xt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const d=document.createElement("div");return d.style.display="none",d.setAttribute("data-fb-hidden-markdown","true"),d}const a=pr(e,t),l=document.createElement("div");return l.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,l.setAttribute("data-field-key",Ct(e,t.state)),l.setAttribute("data-fb-width",e.width||"full"),Dl(e,t,l),a&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),mr(l,e,t),l}const n=pr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=Yt(e.type);if(!(o!=null&&o.ownsLabel)){const a=Zl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Ql(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),mr(r,e,t),r}il(Xt);const Gt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountWithMax:"{count} / {max} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountSingle:"{count} \u0444\u0430\u0439\u043B",fileCountPlural:"{count} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountWithMax:"{count} / {max} \u0444\u0430\u0439\u043B\u043E\u0432",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function ei(e){const t={...Gt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Gt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Gt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function ti(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.125rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function ni(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
1493
- `)}function ri(e,t){Er(e.ownerDocument||document);const n=ni(t);let r=e.querySelector("style[data-fb-theme]");r||(r=document.createElement("style"),r.setAttribute("data-fb-theme","true"),e.appendChild(r)),r.textContent=`
1470
+ `,document.head.appendChild(e)}const Nl=["javascript:","data:","vbscript:","blob:"],Il=["javascript:","vbscript:","blob:"];function ql(e){return!!(Il.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Rl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Bl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();Nl.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();ql(r)&&t.setAttribute("src","")})}function Hl(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);Ml();const r=document.createElement("div");r.className="fb-markdown";const o=Rl(e.content);return r.innerHTML=Jt(o),Bl(r),n.appendChild(r),r}function Dl(e,t,n){return{value:void 0,errors:[],skip:!0}}function jl(e,t,n,r){}function Ol(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";if(a===""){const l="default"in e?e.default:null;return{value:l!==void 0?l:null,errors:[]}}return{value:Qt(a),errors:[]}}function Ul(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Zt(n))}const Pl={text:{validate:rn,update:on},textarea:{validate:Ar,update:Fr},number:{validate:qr,update:Rr},select:{validate:Dr,update:jr},switcher:{validate:Wr,update:Vr},boolean:{validate:Jr,update:Yr,ownsLabel:!0},file:{validate:qn,update:Bn},files:{validate:qn,update:Bn},colour:{validate:Qo,update:el},slider:{validate:rl,update:ol},container:{validate:Yn,update:Xn},group:{validate:sl,update:dl},table:{validate:xl,update:wl},richinput:{validate:Al,update:Fl},hidden:{validate:Ol,update:Ul},markdown:{validate:Dl,update:jl}};function Yt(e){return Pl[e]||null}function Wl(e,t,n){const r=Yt(e.type);return r&&r.validate?r.validate(e,t,n):null}function Vl(e,t,n,r){const o=Yt(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Kl(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(u=>{u.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let d=o.left,s=o.bottom+5;d+l.width>i&&(d=o.right-l.width),s+l.height>a&&(s=o.top-l.height-5),d<10&&(d=10),s<10&&(s=o.bottom+5),n.style.left=`${d}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function fr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!He(e.enableIf,i,a)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function _l(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function Jl(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],d=n[a+1],s=d.startsWith("[")&&d.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const u=parseInt(l.slice(1,-1),10);o[u]=s}else o[l]=s;o=s}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function yt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,d=i.key,s=l==="relative"&&n.path?`${n.path}.${d}`:d,u=_l(s,o),c=Jl(d,u),f=l==="relative"?{}:c,p=l==="relative"?c:void 0;try{He(i,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function pr(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=i.key;let d;a==="relative"&&n.path?d=`${n.path}.${l}`:d=l;const s=o.querySelector(`[name="${d}"]`);if(!s){const u=new MutationObserver(()=>{const c=o.querySelector(`[name="${d}"]`);c&&(c.addEventListener("change",()=>{yt(e,t,n)}),c.addEventListener("input",()=>{yt(e,t,n)}),u.disconnect(),n.state.enableIfObservers.delete(u))});n.state.enableIfObservers.add(u),u.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{yt(e,t,n)}),s.addEventListener("input",()=>{yt(e,t,n)})}function Yl(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function Xl(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),Kl(n,t)},t}function Gl(e){const t=document.createElement("div");t.className="flex items-center",t.style.marginBottom="var(--fb-label-margin-bottom, 2px)",t.dataset.fbLabelRow="";const n=Yl(e);if(t.appendChild(n),e.description||e.hint){const r=Xl(e);t.appendChild(r)}return t}function Zl(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Sr(e,t,n,r):$r(e,t,n,r);break;case"textarea":o?Tr(e,t,n,r):Lr(e,t,n,r);break;case"number":o?Ir(e,t,n,r):Nr(e,t,n,r);break;case"select":o?Hr(e,t,n,r):Br(e,t,n,r);break;case"switcher":o?Pr(e,t,n,r):Ur(e,t,n,r);break;case"boolean":_r(e,t,n,r);break;case"file":o?Xo(e,t,n,r):Jo(e,t,n,r);break;case"files":Yo(e,t,n,r);break;case"colour":o?Zo(e,t,n,r):Go(e,t,n,r);break;case"slider":o?nl(e,t,n,r):tl(e,t,n,r);break;case"group":al(e,t,n,r);break;case"container":o?_n(e,t,n):Kn(e,t,n,r);break;case"table":yl(e,t,n,r);break;case"richinput":Tl(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function Xt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const d=document.createElement("div");return d.style.display="none",d.setAttribute("data-fb-hidden-markdown","true"),d}const a=fr(e,t),l=document.createElement("div");return l.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,l.setAttribute("data-field-key",Ct(e,t.state)),l.setAttribute("data-fb-width",e.width||"full"),Hl(e,t,l),a&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),pr(l,e,t),l}const n=fr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=Yt(e.type);if(!(o!=null&&o.ownsLabel)){const a=Gl(e);r.appendChild(a)}const i=ke(t.path,e.key);return Zl(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),pr(r,e,t),r}ll(Xt);const Gt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function Ql(e){const t={...Gt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Gt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Gt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set}}function ei(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.125rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function ti(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
1471
+ `)}function ni(e,t){Cr(e.ownerDocument||document);const n=ti(t);let r=e.querySelector("style[data-fb-theme]");r||(r=document.createElement("style"),r.setAttribute("data-fb-theme","true"),e.appendChild(r)),r.textContent=`
1494
1472
  [data-fb-root="true"] {
1495
1473
  ${n}
1496
1474
  }
1497
- `}const oi={default:Ve,dark:{...Ve,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...Ve,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{...Ve,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",inputPaddingX:"14px",inputPaddingY:"11px",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};class xt{constructor(t){this.instanceId=ti(),this.state=ei(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,r),this.state.debounceTimer=null},this.state.config.debounceMs))}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;let n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const a of r)if(n=this.state.formRoot.querySelector(`[name="${a}"]`),n)return n;const o=this.findSchemaElement(t);if(!o)return null;const i=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const a of i){const l=o.label||o.key,d=a.querySelector("label");if(d&&(d.textContent===l||d.textContent===`${l}*`)){let s=a.querySelector(".field-placeholder");return s||(s=document.createElement("div"),s.className="field-placeholder",s.style.display="none",a.appendChild(s)),s}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(a=>a.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(a=>a.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(a=>a.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1475
+ `}const ri={default:Ve,dark:{...Ve,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...Ve,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{...Ve,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",inputPaddingX:"14px",inputPaddingY:"11px",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};class xt{constructor(t){this.instanceId=ei(),this.state=Ql(t),this.state.config.verboseErrors&&(globalThis.__formBuilderInstances||(globalThis.__formBuilderInstances=new Set),globalThis.__formBuilderInstances.add(this.instanceId),globalThis.__formBuilderInstances.size>10&&console.warn(`[form-builder] ${globalThis.__formBuilderInstances.size} instances active. Possible memory leak - ensure you call destroy() when done.`))}getInstanceId(){return this.instanceId}getState(){return this.state}setFormRoot(t){this.state.formRoot=t}configure(t){Object.assign(this.state.config,t)}setUploadHandler(t){this.state.config.uploadFile=t}setDownloadHandler(t){this.state.config.downloadFile=t}setThumbnailHandler(t){this.state.config.getThumbnail=t}setActionHandler(t){this.state.config.actionHandler=t}setMode(t){this.state.config.readonly=t==="readonly"}setLocale(t){this.state.config.translations[t]&&(this.state.config.locale=t)}triggerOnChange(t,n){this.state.config.readonly||(this.state.debounceTimer!==null&&clearTimeout(this.state.debounceTimer),this.state.debounceTimer=setTimeout(()=>{const r=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,r),this.state.debounceTimer=null},this.state.config.debounceMs))}registerAction(t){if(!t||!t.value)throw new Error("Action must have a value property");this.state.externalActions||(this.state.externalActions=[]);const n=this.state.externalActions.findIndex(r=>r.value===t.value&&r.related_field===t.related_field);n>=0?this.state.externalActions[n]=t:this.state.externalActions.push(t)}findFormElementByFieldPath(t){if(!this.state.formRoot)return null;let n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const a of r)if(n=this.state.formRoot.querySelector(`[name="${a}"]`),n)return n;const o=this.findSchemaElement(t);if(!o)return null;const i=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const a of i){const l=o.label||o.key,d=a.querySelector("label");if(d&&(d.textContent===l||d.textContent===`${l}*`)){let s=a.querySelector(".field-placeholder");return s||(s=document.createElement("div"),s.className="field-placeholder",s.style.display="none",a.appendChild(s)),s}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(a=>a.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(a=>a.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(a=>a.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1498
1476
  border-top: var(--fb-border-width) solid var(--fb-border-color);
1499
- `,t.forEach(i=>{const a=document.createElement("button");a.type="button",nn(a,!0);const l=n.includes(i),d=this.resolveActionLabel(i.key,i.label,null,l);a.textContent=d,a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(a)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,a)=>{const l=this.findFormElementByFieldPath(a);if(!l){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...i);return}let d=l.closest(".fb-field-wrapper");if(d||(d=l.parentElement),!d){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const s=d.querySelector(".external-actions-container");s&&s.remove();const u=document.createElement("div");u.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(a);i.forEach(f=>{const p=document.createElement("button");p.type="button",nn(p,!1);const m=this.resolveActionLabel(f.key,f.label,c);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),u.appendChild(p)}),d.appendChild(u)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const a=JSON.parse(r);for(const d in a){const s=o?d:`${i}.${d}`,u=a[d];this.updateField(s,u)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(d=>d.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(a){console.error("Error parsing prefill hint values:",a)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=wt(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.disconnectEnableIfObservers(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ye(t),t.setAttribute("data-fb-root","true"),ri(t,this.state.config.theme);const a=document.createElement("div");if(a.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);a.appendChild(s)}const l=document.createElement("div"),d=n.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`,n.elements.forEach(s=>{var u,c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(c=(u=r==null?void 0:r[s.key])!=null?u:s.default)!=null?c:null;l.appendChild(_e(s.key,p));return}const f=Xt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(f)}),a.appendChild(l),t.appendChild(a),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,a,l=null)=>{var d;const s=(d=i.key)!=null?d:"",u={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:a.path,skipValidation:t},c=Vl(i,s,u);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return al(o),this.state.schema.elements.forEach(i=>{var a;if(i.enableIf)try{if(!He(i.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,l)}if(i.type!=="markdown")if(i.hidden||i.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),d=(a=l==null?void 0:l.value)!=null?a:"";d!==""?r[i.key]=Qt(d):r[i.key]=i.default!==void 0?i.default:null}else{const l=o(i,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):i.key&&(r[i.key]=l.value)}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,a=this.buildHiddenFieldsData(i.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const a=i,l=(n=a.textKey)!=null?n:"text",d=(r=a.filesKey)!=null?r:"files";o.set(l,{schemaKey:i.key,role:"text"}),o.set(d,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Kl(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=Ct(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const l=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const a=r.querySelector(`[data-container="${n}"]`);return a?a.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,i){var a,l,d,s;try{const u=((a=t.enableIf.scope)!=null?a:"relative")==="relative"&&r?Et(i,r):void 0,c=He(t.enableIf,i,u),f=n.getAttribute("data-conditionally-disabled")==="true";if(c&&f){const p=r?Et(i,r):i,m=Xt(t,{path:r,prefill:p&&typeof p=="object"?p:{},formData:i,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!c&&!f){const p=document.createElement("div");p.className="fb-field-wrapper-disabled",p.style.display="none",p.setAttribute("data-field-key",Ct(t,this.state)),p.setAttribute("data-conditionally-disabled","true"),(d=n.parentNode)==null||d.replaceChild(p,n)}}catch(u){console.error(`Error re-evaluating enableIf for field "${(s=t.key)!=null?s:"<no key>"}" at path "${o}":`,u)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var a,l;const d=o?`${o}.${(a=i.key)!=null?a:""}`:(l=i.key)!=null?l:"";if(i.enableIf){const s=this.findFieldWrapper(i,o);s&&this.applyEnableIfVisibility(i,s,o,d,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const s=i.key?t==null?void 0:t[i.key]:void 0;if(Array.isArray(s)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");(d?Array.from(u).filter(c=>{const f=c.getAttribute("data-container-item")||"";if(!f.startsWith(`${d}[`))return!1;const p=f.slice(d.length);return/^\[\d+\]$/.test(p)}):[]).forEach(c=>{const f=c.getAttribute("data-container-item")||"";n(i.elements,f)})}else n(i.elements,d)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.state.resourceIndex.clear(),this.state.formRoot&&ye(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}}function hr(e){return new xt(e)}return typeof window!="undefined"&&(window.FormBuilder=xt,window.createFormBuilder=hr,window.validateSchema=wt),Ae.FormBuilderInstance=xt,Ae.createFormBuilder=hr,Ae.default=xt,Ae.defaultTheme=Ve,Ae.exampleThemes=oi,Ae.validateSchema=wt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});
1477
+ `,t.forEach(i=>{const a=document.createElement("button");a.type="button",nn(a,!0);const l=n.includes(i),d=this.resolveActionLabel(i.key,i.label,null,l);a.textContent=d,a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(a)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,a)=>{const l=this.findFormElementByFieldPath(a);if(!l){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...i);return}let d=l.closest(".fb-field-wrapper");if(d||(d=l.parentElement),!d){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const s=d.querySelector(".external-actions-container");s&&s.remove();const u=document.createElement("div");u.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(a);i.forEach(f=>{const p=document.createElement("button");p.type="button",nn(p,!1);const m=this.resolveActionLabel(f.key,f.label,c);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),u.appendChild(p)}),d.appendChild(u)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const a=JSON.parse(r);for(const d in a){const s=o?d:`${i}.${d}`,u=a[d];this.updateField(s,u)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(d=>d.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(a){console.error("Error parsing prefill hint values:",a)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=wt(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.disconnectEnableIfObservers(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ye(t),t.setAttribute("data-fb-root","true"),ni(t,this.state.config.theme);const a=document.createElement("div");if(a.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);a.appendChild(s)}const l=document.createElement("div"),d=n.columns||1;d===1?l.className="fb-row":l.className=`grid grid-cols-${d} gap-2`,n.elements.forEach(s=>{var u,c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(c=(u=r==null?void 0:r[s.key])!=null?u:s.default)!=null?c:null;l.appendChild(_e(s.key,p));return}const f=Xt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(f)}),a.appendChild(l),t.appendChild(a),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,a,l=null)=>{var d;const s=(d=i.key)!=null?d:"",u={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:a.path,skipValidation:t},c=Wl(i,s,u);return c!==null?(n.push(...c.errors),{value:c.value,spread:!!c.spread,skip:!!c.skip}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return il(o),this.state.schema.elements.forEach(i=>{var a;if(i.enableIf)try{if(!He(i.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,l)}if(i.type!=="markdown")if(i.hidden||i.type==="hidden"){const l=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),d=(a=l==null?void 0:l.value)!=null?a:"";d!==""?r[i.key]=Qt(d):r[i.key]=i.default!==void 0?i.default:null}else{const l=o(i,{path:""});if(l.skip)return;l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):i.key&&(r[i.key]=l.value)}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,a=this.buildHiddenFieldsData(i.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const a=i,l=(n=a.textKey)!=null?n:"text",d=(r=a.filesKey)!=null?r:"files";o.set(l,{schemaKey:i.key,role:"text"}),o.set(d,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Vl(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=Ct(t,this.state);if(!n)return r.querySelector(`[data-field-key="${o}"]`);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const l=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return l?l.querySelector(`[data-field-key="${o}"]`):null}const a=r.querySelector(`[data-container="${n}"]`);return a?a.querySelector(`[data-field-key="${o}"]`):null}applyEnableIfVisibility(t,n,r,o,i){var a,l,d,s;try{const u=((a=t.enableIf.scope)!=null?a:"relative")==="relative"&&r?Et(i,r):void 0,c=He(t.enableIf,i,u),f=n.getAttribute("data-conditionally-disabled")==="true";if(c&&f){const p=r?Et(i,r):i,m=Xt(t,{path:r,prefill:p&&typeof p=="object"?p:{},formData:i,state:this.state,instance:this});(l=n.parentNode)==null||l.replaceChild(m,n)}else if(!c&&!f){const p=document.createElement("div");p.className="fb-field-wrapper-disabled",p.style.display="none",p.setAttribute("data-field-key",Ct(t,this.state)),p.setAttribute("data-conditionally-disabled","true"),(d=n.parentNode)==null||d.replaceChild(p,n)}}catch(u){console.error(`Error re-evaluating enableIf for field "${(s=t.key)!=null?s:"<no key>"}" at path "${o}":`,u)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o)=>{r.forEach(i=>{var a,l;const d=o?`${o}.${(a=i.key)!=null?a:""}`:(l=i.key)!=null?l:"";if(i.enableIf){const s=this.findFieldWrapper(i,o);s&&this.applyEnableIfVisibility(i,s,o,d,t)}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const s=i.key?t==null?void 0:t[i.key]:void 0;if(Array.isArray(s)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");(d?Array.from(u).filter(c=>{const f=c.getAttribute("data-container-item")||"";if(!f.startsWith(`${d}[`))return!1;const p=f.slice(d.length);return/^\[\d+\]$/.test(p)}):[]).forEach(c=>{const f=c.getAttribute("data-container-item")||"";n(i.elements,f)})}else n(i.elements,d)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.state.resourceIndex.clear(),this.state.formRoot&&ye(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}}function mr(e){return new xt(e)}return typeof window!="undefined"&&(window.FormBuilder=xt,window.createFormBuilder=mr,window.validateSchema=wt),Ae.FormBuilderInstance=xt,Ae.createFormBuilder=mr,Ae.default=xt,Ae.defaultTheme=Ve,Ae.exampleThemes=ri,Ae.validateSchema=wt,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae})({});