@dmitryvim/form-builder 0.2.25 → 0.2.27

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(ye){"use strict";function k(e,t,n){const r=t.config.locale||"en",l=t.config.translations[r],a=t.config.translations.en;let o=(l==null?void 0:l[e])||(a==null?void 0:a[e])||e;if(n)for(const[s,i]of Object.entries(n))o=o.replace(new RegExp(`\\{${s}\\}`,"g"),String(i));return o}function fn(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 mn(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 hn(e,t,n){e.maxSizeMB&&t.push(k("hintMaxSize",n,{size:e.maxSizeMB}))}function vn(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(l=>l.toUpperCase()).join(",")}))}function gn(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function ve(e,t){const n=[];return fn(e,n,t),e.type!=="slider"&&mn(e,n,t),hn(e,n,t),vn(e,n,t),gn(e,n,t),n.join(" \u2022 ")}function et(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 l=e.columns,a=[1,2,3,4];(!Number.isInteger(l)||!a.includes(l))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${l})`)}if("prefillHints"in e&&e.prefillHints){const l=e.prefillHints;Array.isArray(l)&&l.forEach((a,o)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${o}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${o}] must have a 'values' property of type object`);else for(const s in a.values)e.elements.some(i=>i.key===s)||t.push(`schema.prefillHints[${o}] references non-existent field "${s}"`)})}function n(l,a){var o,s;const i=new Set;for(const u of l)if(u.type==="richinput"&&u.flatOutput){const f=u,c=(o=f.textKey)!=null?o:"text",m=(s=f.filesKey)!=null?s:"files";for(const p of l)p!==u&&(p.key===c&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${c}" collides with element key "${p.key}"`),p.key===m&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${m}" collides with element key "${p.key}"`));i.has(c)&&t.push(`${a}: RichInput "${u.key}" flatOutput textKey "${c}" collides with another flatOutput key`),i.has(m)&&t.push(`${a}: RichInput "${u.key}" flatOutput filesKey "${m}" collides with another flatOutput key`),i.add(c),i.add(m)}else i.has(u.key)&&t.push(`${a}: Element key "${u.key}" collides with a flatOutput richinput key`),i.add(u.key)}function r(l,a){l.forEach((o,s)=>{const i=`${a}[${s}]`;if(o.type||t.push(`${i}: missing type`),o.key||t.push(`${i}: missing key`),o.enableIf){const u=o.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${i}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${i}: enableIf must have at least one operator (equals, etc.)`)}if(o.type==="group"&&"elements"in o&&o.elements&&r(o.elements,`${i}.elements`),o.type==="container"&&o.elements){if("columns"in o&&o.columns!==void 0){const u=o.columns,f=[1,2,3,4];(!Number.isInteger(u)||!f.includes(u))&&t.push(`${i}: columns must be 1, 2, 3, or 4 (got ${u})`)}if("prefillHints"in o&&o.prefillHints){const u=o.prefillHints;Array.isArray(u)&&u.forEach((f,c)=>{if((!f.label||typeof f.label!="string")&&t.push(`${i}: prefillHints[${c}] must have a 'label' property of type string`),!f.values||typeof f.values!="object")t.push(`${i}: prefillHints[${c}] must have a 'values' property of type object`);else for(const m in f.values)o.elements.some(p=>p.key===m)||t.push(`container "${o.key}": prefillHints[${c}] references non-existent field "${m}"`)})}r(o.elements,`${i}.elements`),n(o.elements,`${i}.elements`)}if(o.type==="select"&&o.options){const u=o.default;u!=null&&u!==""&&(o.options.some(f=>f.value===u)||t.push(`${i}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(r(e.elements,"elements"),n(e.elements,"elements")),t}function je(e){return e&&typeof e=="object"&&e.constructor===Object}function J(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function ge(e,t){return e?`${e}.${t}`:t}function pe(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function bn(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function yt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function xt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function qe(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=yt(t),n}function tt(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 l of n){if(r==null)return;if(l.startsWith("[")&&l.endsWith("]")){const a=parseInt(l.slice(1,-1),10);if(!Array.isArray(r)||isNaN(a))return;r=r[a]}else r=r[l]}return r}function $e(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const l=(r=e.scope)!=null?r:"relative";let a;if(l==="relative")a=n!=null?n:t;else if(l==="absolute")a=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${l}")`);const o=tt(a,e.key);if("equals"in e)return yn(o,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function yn(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 ze(e,t,n=!1){const r=document.createElement("span");r.className="char-counter",r.style.cssText=`
1
+ var FormBuilder=(function(Ce){"use strict";function $(e,t,n){const o=t.config.locale||"en",r=t.config.translations[o],l=t.config.translations.en;let i=(r==null?void 0:r[e])||(l==null?void 0:l[e])||e;if(n)for(const[a,s]of Object.entries(n))i=i.replace(new RegExp(`\\{${a}\\}`,"g"),String(s));return i}function Dn(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push($("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push($("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push($("hintMinLength",n,{min:e.minLength})))}function jn(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push($("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push($("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push($("hintMinValue",n,{min:e.min})))}function On(e,t,n){e.maxSizeMB&&t.push($("hintMaxSize",n,{size:e.maxSizeMB}))}function Un(e,t,n){var o;(o=e.accept)!=null&&o.extensions&&t.push($("hintFormats",n,{formats:e.accept.extensions.map(r=>r.toUpperCase()).join(",")}))}function Pn(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function ye(e,t){const n=[];return Dn(e,n,t),e.type!=="slider"&&jn(e,n,t),On(e,n,t),Un(e,n,t),Pn(e,n,t),n.join(" \u2022 ")}function dt(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 r=e.columns,l=[1,2,3,4];(!Number.isInteger(r)||!l.includes(r))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${r})`)}if("prefillHints"in e&&e.prefillHints){const r=e.prefillHints;Array.isArray(r)&&r.forEach((l,i)=>{if((!l.label||typeof l.label!="string")&&t.push(`schema.prefillHints[${i}] must have a 'label' property of type string`),!l.values||typeof l.values!="object")t.push(`schema.prefillHints[${i}] must have a 'values' property of type object`);else for(const a in l.values)e.elements.some(s=>s.key===a)||t.push(`schema.prefillHints[${i}] references non-existent field "${a}"`)})}function n(r,l){var i,a;const s=new Set;for(const c of r)if(c.type==="richinput"&&c.flatOutput){const d=c,u=(i=d.textKey)!=null?i:"text",p=(a=d.filesKey)!=null?a:"files";for(const f of r)f!==c&&(f.key===u&&t.push(`${l}: RichInput "${c.key}" flatOutput textKey "${u}" collides with element key "${f.key}"`),f.key===p&&t.push(`${l}: RichInput "${c.key}" flatOutput filesKey "${p}" collides with element key "${f.key}"`));s.has(u)&&t.push(`${l}: RichInput "${c.key}" flatOutput textKey "${u}" collides with another flatOutput key`),s.has(p)&&t.push(`${l}: RichInput "${c.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),s.add(u),s.add(p)}else s.has(c.key)&&t.push(`${l}: Element key "${c.key}" collides with a flatOutput richinput key`),s.add(c.key)}function o(r,l){r.forEach((i,a)=>{const s=`${l}[${a}]`;if(i.type||t.push(`${s}: missing type`),i.key||t.push(`${s}: missing key`),i.enableIf){const c=i.enableIf;(!c.key||typeof c.key!="string")&&t.push(`${s}: enableIf must have a 'key' property of type string`),"equals"in c||t.push(`${s}: enableIf must have at least one operator (equals, etc.)`)}if(i.type==="group"&&"elements"in i&&i.elements&&o(i.elements,`${s}.elements`),i.type==="container"&&i.elements){if("columns"in i&&i.columns!==void 0){const c=i.columns,d=[1,2,3,4];(!Number.isInteger(c)||!d.includes(c))&&t.push(`${s}: columns must be 1, 2, 3, or 4 (got ${c})`)}if("prefillHints"in i&&i.prefillHints){const c=i.prefillHints;Array.isArray(c)&&c.forEach((d,u)=>{if((!d.label||typeof d.label!="string")&&t.push(`${s}: prefillHints[${u}] must have a 'label' property of type string`),!d.values||typeof d.values!="object")t.push(`${s}: prefillHints[${u}] must have a 'values' property of type object`);else for(const p in d.values)i.elements.some(f=>f.key===p)||t.push(`container "${i.key}": prefillHints[${u}] references non-existent field "${p}"`)})}o(i.elements,`${s}.elements`),n(i.elements,`${s}.elements`)}if(i.type==="select"&&i.options){const c=i.default;c!=null&&c!==""&&(i.options.some(d=>d.value===c)||t.push(`${s}: default "${c}" not in options`))}})}return Array.isArray(e.elements)&&(o(e.elements,"elements"),n(e.elements,"elements")),t}function le(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Pe(e){return e&&typeof e=="object"&&e.constructor===Object}function re(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function xe(e,t){return e?`${e}.${t}`:t}function ve(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Vn(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Nt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function zt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Re(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Nt(t),n}function pt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let o=e;for(const r of n){if(o==null)return;if(r.startsWith("[")&&r.endsWith("]")){const l=parseInt(r.slice(1,-1),10);if(!Array.isArray(o)||isNaN(l))return;o=o[l]}else o=o[r]}return o}function Fe(e,t,n){var o;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const r=(o=e.scope)!=null?o:"relative";let l;if(r==="relative")l=n!=null?n:t;else if(r==="absolute")l=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${r}")`);const i=pt(l,e.key);if("equals"in e)return Wn(i,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Wn(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 Ie(e,t,n=!1){const o=document.createElement("span");o.className="char-counter",o.style.cssText=`
2
2
  position: absolute;
3
3
  ${n?"bottom: 8px":"top: 50%; transform: translateY(-50%)"};
4
4
  right: 10px;
@@ -7,51 +7,51 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
7
7
  pointer-events: none;
8
8
  background: var(--fb-background-color);
9
9
  padding: 0 4px;
10
- `;const l=()=>{const a=t.value.length,o=e.minLength,s=e.maxLength;if(o==null&&s==null){r.textContent="";return}a===0||o!=null&&a<o?(o!=null&&s!=null?r.textContent=`${o}-${s}`:s!=null?r.textContent=`\u2264${s}`:o!=null&&(r.textContent=`\u2265${o}`),r.style.color="var(--fb-text-secondary-color)"):s!=null&&a>s?(r.textContent=`${a}/${s}`,r.style.color="var(--fb-error-color)"):(s!=null?r.textContent=`${a}/${s}`:r.textContent=`${a}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",l),l(),r}function xn(e,t,n,r){const l=t.state,a=document.createElement("div");a.style.cssText="position: relative;";const o=document.createElement("input");if(o.type="text",o.className="w-full rounded-lg",o.style.cssText=`
10
+ `;const r=()=>{const l=t.value.length,i=e.minLength,a=e.maxLength;if(i==null&&a==null){o.textContent="";return}l===0||i!=null&&l<i?(i!=null&&a!=null?o.textContent=`${i}-${a}`:a!=null?o.textContent=`\u2264${a}`:i!=null&&(o.textContent=`\u2265${i}`),o.style.color="var(--fb-text-secondary-color)"):a!=null&&l>a?(o.textContent=`${l}/${a}`,o.style.color="var(--fb-error-color)"):(a!=null?o.textContent=`${l}/${a}`:o.textContent=`${l}`,o.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",r),r(),o}function Kn(e,t,n,o){const r=t.state,l=le(e,r,t),i=document.createElement("div");i.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="text",a.className="w-full rounded-lg",a.style.cssText=`
11
11
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
12
12
  padding-right: 60px;
13
13
  border: var(--fb-border-width) solid var(--fb-border-color);
14
14
  border-radius: var(--fb-border-radius);
15
- background-color: ${l.config.readonly?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
15
+ background-color: ${l?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
16
16
  color: var(--fb-text-color);
17
17
  font-size: var(--fb-font-size);
18
18
  font-family: var(--fb-font-family);
19
19
  transition: all var(--fb-transition-duration) ease-in-out;
20
20
  width: 100%;
21
21
  box-sizing: border-box;
22
- `,o.name=r,o.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",o.value=t.prefill[e.key]||e.default||"",o.readOnly=l.config.readonly,l.config.readonly||(o.addEventListener("focus",()=>{o.style.borderColor="var(--fb-border-focus-color)",o.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",o.style.outlineOffset="0"}),o.addEventListener("blur",()=>{o.style.borderColor="var(--fb-border-color)",o.style.outline="none"}),o.addEventListener("mouseenter",()=>{document.activeElement!==o&&(o.style.borderColor="var(--fb-border-hover-color)")}),o.addEventListener("mouseleave",()=>{document.activeElement!==o&&(o.style.borderColor="var(--fb-border-color)")})),!l.config.readonly&&t.instance){const s=()=>{const i=o.value===""?null:o.value;t.instance.triggerOnChange(r,i)};o.addEventListener("blur",s),o.addEventListener("input",s)}if(a.appendChild(o),!l.config.readonly&&(e.minLength!=null||e.maxLength!=null)){const s=ze(e,o,!1);a.appendChild(s)}n.appendChild(a)}function En(e,t,n,r){var l,a;const o=t.state,s=t.prefill[e.key]||[],i=Array.isArray(s)?[...s]:[],u=(l=e.minCount)!=null?l:1,f=(a=e.maxCount)!=null?a:1/0;for(;i.length<u;)i.push(e.default||"");const c=document.createElement("div");c.className="space-y-2",n.appendChild(c);function m(){c.querySelectorAll(".multiple-text-item").forEach((d,y)=>{const g=d.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function p(d="",y=-1){const g=document.createElement("div");g.className="multiple-text-item flex items-center gap-2";const E=document.createElement("div");E.style.cssText="position: relative; flex: 1;";const C=document.createElement("input");if(C.type="text",C.style.cssText=`
22
+ `,a.name=o,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.value=t.prefill[e.key]||e.default||"",a.readOnly=l,l||(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)")})),!l&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(o,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(i.appendChild(a),!l&&(e.minLength!=null||e.maxLength!=null)){const s=Ie(e,a,!1);i.appendChild(s)}n.appendChild(i)}function _n(e,t,n,o){var r,l;const i=t.state,a=le(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(r=e.minCount)!=null?r:1,u=(l=e.maxCount)!=null?l:1/0;for(;c.length<d;)c.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-text-item").forEach((g,y)=>{const C=g.querySelector("input");C&&(C.name=`${o}[${y}]`)})}function m(g="",y=-1){const C=document.createElement("div");C.className="multiple-text-item flex items-center gap-2";const E=document.createElement("div");E.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="text",x.style.cssText=`
23
23
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
24
24
  padding-right: 60px;
25
25
  border: var(--fb-border-width) solid var(--fb-border-color);
26
26
  border-radius: var(--fb-border-radius);
27
- background-color: ${o.config.readonly?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
27
+ background-color: ${a?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
28
28
  color: var(--fb-text-color);
29
29
  font-size: var(--fb-font-size);
30
30
  font-family: var(--fb-font-family);
31
31
  transition: all var(--fb-transition-duration) ease-in-out;
32
32
  width: 100%;
33
33
  box-sizing: border-box;
34
- `,C.placeholder=e.placeholder||k("placeholderText",o),C.value=d,C.readOnly=o.config.readonly,o.config.readonly||(C.addEventListener("focus",()=>{C.style.borderColor="var(--fb-border-focus-color)",C.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",C.style.outlineOffset="0"}),C.addEventListener("blur",()=>{C.style.borderColor="var(--fb-border-color)",C.style.outline="none"}),C.addEventListener("mouseenter",()=>{document.activeElement!==C&&(C.style.borderColor="var(--fb-border-hover-color)")}),C.addEventListener("mouseleave",()=>{document.activeElement!==C&&(C.style.borderColor="var(--fb-border-color)")})),!o.config.readonly&&t.instance){const w=()=>{const S=C.value===""?null:C.value;t.instance.triggerOnChange(C.name,S)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(E.appendChild(C),!o.config.readonly&&(e.minLength!=null||e.maxLength!=null)){const w=ze(e,C,!1);E.appendChild(w)}return g.appendChild(E),y===-1?c.appendChild(g):c.insertBefore(g,c.children[y]),m(),g}function h(){if(o.config.readonly)return;const d=c.querySelectorAll(".multiple-text-item"),y=d.length;d.forEach(g=>{let E=g.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
34
+ `,x.placeholder=e.placeholder||$("placeholderText",i),x.value=g,x.readOnly=a,a||(x.addEventListener("focus",()=>{x.style.borderColor="var(--fb-border-focus-color)",x.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",x.style.outlineOffset="0"}),x.addEventListener("blur",()=>{x.style.borderColor="var(--fb-border-color)",x.style.outline="none"}),x.addEventListener("mouseenter",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-hover-color)")}),x.addEventListener("mouseleave",()=>{document.activeElement!==x&&(x.style.borderColor="var(--fb-border-color)")})),!a&&t.instance){const k=()=>{const q=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(E.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=Ie(e,x,!1);E.appendChild(k)}return C.appendChild(E),y===-1?p.appendChild(C):p.insertBefore(C,p.children[y]),f(),C}function b(){if(a)return;const g=p.querySelectorAll(".multiple-text-item"),y=g.length;g.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
35
35
  color: var(--fb-error-color);
36
36
  background-color: transparent;
37
37
  transition: background-color var(--fb-transition-duration);
38
- `,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const w=Array.from(c.children).indexOf(g);c.children.length>u&&(i.splice(w,1),g.remove(),m(),x(),h())},g.appendChild(E));const C=y<=u;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"})}let v=null,b=null;if(!o.config.readonly){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const d=document.createElement("button");d.type="button",d.className="add-text-btn px-3 py-1 rounded",d.style.cssText=`
38
+ `,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const k=Array.from(p.children).indexOf(C);p.children.length>d&&(c.splice(k,1),C.remove(),f(),h(),b())},C.appendChild(E));const x=y<=d;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let v=null,w=null;if(!a){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-text-btn px-3 py-1 rounded",g.style.cssText=`
39
39
  color: var(--fb-primary-color);
40
40
  border: var(--fb-border-width) solid var(--fb-primary-color);
41
41
  background-color: transparent;
42
42
  font-size: var(--fb-font-size);
43
43
  transition: all var(--fb-transition-duration);
44
- `,d.textContent="+",d.addEventListener("mouseenter",()=>{d.style.backgroundColor="var(--fb-background-hover-color)"}),d.addEventListener("mouseleave",()=>{d.style.backgroundColor="transparent"}),d.onclick=()=>{i.push(e.default||""),p(e.default||""),x(),h()},b=document.createElement("span"),b.className="text-sm text-gray-500",v.appendChild(d),v.appendChild(b),n.appendChild(v)}function x(){if(!v||!b)return;const d=v.querySelector(".add-text-btn");if(d){const y=i.length>=f;d.disabled=y,d.style.opacity=y?"0.5":"1",d.style.pointerEvents=y?"none":"auto"}b.textContent=`${i.length}/${f===1/0?"\u221E":f}`}i.forEach(d=>p(d)),x(),h()}function Et(e,t,n){var r,l,a;const o=[],{scopeRoot:s,skipValidation:i}=n,u=(c,m)=>{var p,h;if(!c)return;const v=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(v);m?(c.classList.add("invalid"),c.title=m,b||(b=document.createElement("div"),b.id=v,b.className="error-message",b.style.cssText=`
44
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{c.push(e.default||""),m(e.default||""),h(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",v.appendChild(g),v.appendChild(w),n.appendChild(v)}function h(){if(!v||!w)return;const g=v.querySelector(".add-text-btn");if(g){const y=c.length>=u;g.disabled=y,g.style.opacity=y?"0.5":"1",g.style.pointerEvents=y?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(g=>m(g)),h(),b()}function Mt(e,t,n){var o,r,l;const i=[],{scopeRoot:a,skipValidation:s}=n,c=(u,p)=>{var f,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(b);p?(u.classList.add("invalid"),u.title=p,v||(v=document.createElement("div"),v.id=b,v.className="error-message",v.style.cssText=`
45
45
  color: var(--fb-error-color);
46
46
  font-size: var(--fb-font-size-small);
47
47
  margin-top: 0.25rem;
48
- `,c.nextSibling?(p=c.parentNode)==null||p.insertBefore(b,c.nextSibling):(h=c.parentNode)==null||h.appendChild(b)),b.textContent=m,b.style.display="block"):(c.classList.remove("invalid"),c.title="",b&&b.remove())},f=(c,m,p)=>{let h=!1;const{state:v}=n;if(!i&&m){if(e.minLength!==void 0&&e.minLength!==null&&m.length<e.minLength){const b=k("minLength",v,{min:e.minLength});o.push(`${p}: ${b}`),u(c,b),h=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&m.length>e.maxLength){const b=k("maxLength",v,{max:e.maxLength});o.push(`${p}: ${b}`),u(c,b),h=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(m)){const b=k("patternMismatch",v);o.push(`${p}: ${b}`),u(c,b),h=!0}}catch(b){const x=k("invalidPattern",v);o.push(`${p}: ${x}`),u(c,x),h=!0}}h||u(c,null)};if(e.multiple){const c=s.querySelectorAll(`[name^="${t}["]`),m=[],p=[];if(c.forEach((h,v)=>{var b;const x=(b=h==null?void 0:h.value)!=null?b:"";p.push(x),m.push(x===""?null:x),f(h,x,`${t}[${v}]`)}),!i){const{state:h}=n,v=(r=e.minCount)!=null?r:1,b=(l=e.maxCount)!=null?l:1/0,x=p.filter(d=>d.trim()!=="");e.required&&x.length===0&&o.push(`${t}: ${k("required",h)}`),x.length<v&&o.push(`${t}: ${k("minItems",h,{min:v})}`),x.length>b&&o.push(`${t}: ${k("maxItems",h,{max:b})}`)}return{value:m,errors:o}}else{const c=s.querySelector(`[name$="${t}"]`),m=(a=c==null?void 0:c.value)!=null?a:"";if(!i&&e.required&&m===""){const p=k("required",n.state);return o.push(`${t}: ${p}`),u(c,p),{value:null,errors:o}}return c&&f(c,m,t),{value:m===""?null:m,errors:o}}}function Ct(e,t,n,r){const{scopeRoot:l}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=l.querySelectorAll(`[name^="${t}["]`);a.forEach((o,s)=>{s<n.length&&(o.value=n[s]!=null?String(n[s]):"",o.classList.remove("invalid"),o.title="")}),n.length!==a.length&&console.warn(`updateTextField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=l.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="")}}function wt(e){e.style.overflow="hidden",e.style.resize="none";const t=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(1,t);const n=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`)};e.addEventListener("input",n),setTimeout(()=>{e.isConnected&&n()},0)}function Cn(e,t,n,r){const l=t.state,a=document.createElement("div");a.style.cssText="position: relative;";const o=document.createElement("textarea");if(o.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",o.style.cssText="padding-bottom: 24px;",o.name=r,o.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",o.rows=e.rows||4,o.value=t.prefill[e.key]||e.default||"",o.readOnly=l.config.readonly,!l.config.readonly&&t.instance){const s=()=>{const i=o.value===""?null:o.value;t.instance.triggerOnChange(r,i)};o.addEventListener("blur",s),o.addEventListener("input",s)}if((e.autoExpand||l.config.readonly)&&wt(o),a.appendChild(o),!l.config.readonly&&(e.minLength!=null||e.maxLength!=null)){const s=ze(e,o,!0);a.appendChild(s)}n.appendChild(a)}function wn(e,t,n,r){var l,a;const o=t.state,s=t.prefill[e.key]||[],i=Array.isArray(s)?[...s]:[],u=(l=e.minCount)!=null?l:1,f=(a=e.maxCount)!=null?a:1/0;for(;i.length<u;)i.push(e.default||"");const c=document.createElement("div");c.className="space-y-2",n.appendChild(c);function m(){c.querySelectorAll(".multiple-textarea-item").forEach((d,y)=>{const g=d.querySelector("textarea");g&&(g.name=`${r}[${y}]`)})}function p(d="",y=-1){const g=document.createElement("div");g.className="multiple-textarea-item";const E=document.createElement("div");E.style.cssText="position: relative;";const C=document.createElement("textarea");if(C.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",C.style.cssText="padding-bottom: 24px;",C.placeholder=e.placeholder||k("placeholderText",o),C.rows=e.rows||4,C.value=d,C.readOnly=o.config.readonly,!o.config.readonly&&t.instance){const w=()=>{const S=C.value===""?null:C.value;t.instance.triggerOnChange(C.name,S)};C.addEventListener("blur",w),C.addEventListener("input",w)}if((e.autoExpand||o.config.readonly)&&wt(C),E.appendChild(C),!o.config.readonly&&(e.minLength!=null||e.maxLength!=null)){const w=ze(e,C,!0);E.appendChild(w)}return g.appendChild(E),y===-1?c.appendChild(g):c.insertBefore(g,c.children[y]),m(),g}function h(){if(o.config.readonly)return;const d=c.querySelectorAll(".multiple-textarea-item"),y=d.length;d.forEach(g=>{let E=g.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",E.innerHTML="\u2715",E.onclick=()=>{const w=Array.from(c.children).indexOf(g);c.children.length>u&&(i.splice(w,1),g.remove(),m(),x(),h())},g.appendChild(E));const C=y<=u;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"})}let v=null,b=null;if(!o.config.readonly){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const d=document.createElement("button");d.type="button",d.className="add-textarea-btn px-3 py-1 rounded",d.style.cssText=`
48
+ `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(v,u.nextSibling):(m=u.parentNode)==null||m.appendChild(v)),v.textContent=p,v.style.display="block"):(u.classList.remove("invalid"),u.title="",v&&v.remove())},d=(u,p,f)=>{let m=!1;const{state:b}=n;if(!s&&p){if(e.minLength!==void 0&&e.minLength!==null&&p.length<e.minLength){const v=$("minLength",b,{min:e.minLength});i.push(`${f}: ${v}`),c(u,v),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&p.length>e.maxLength){const v=$("maxLength",b,{max:e.maxLength});i.push(`${f}: ${v}`),c(u,v),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(p)){const v=$("patternMismatch",b);i.push(`${f}: ${v}`),c(u,v),m=!0}}catch(v){const w=$("invalidPattern",b);i.push(`${f}: ${w}`),c(u,w),m=!0}}m||c(u,null)};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["]`),p=[],f=[];if(u.forEach((m,b)=>{var v;const w=(v=m==null?void 0:m.value)!=null?v:"";f.push(w),p.push(w===""?null:w),d(m,w,`${t}[${b}]`)}),!s){const{state:m}=n,b=(o=e.minCount)!=null?o:1,v=(r=e.maxCount)!=null?r:1/0,w=f.filter(h=>h.trim()!=="");e.required&&w.length===0&&i.push(`${t}: ${$("required",m)}`),w.length<b&&i.push(`${t}: ${$("minItems",m,{min:b})}`),w.length>v&&i.push(`${t}: ${$("maxItems",m,{max:v})}`)}return{value:p,errors:i}}else{const u=a.querySelector(`[name$="${t}"]`),p=(l=u==null?void 0:u.value)!=null?l:"";if(!s&&e.required&&p===""){const f=$("required",n.state);return i.push(`${t}: ${f}`),c(u,f),{value:null,errors:i}}return u&&d(u,p,t),{value:p===""?null:p,errors:i}}}function qt(e,t,n,o){const{scopeRoot:r}=o;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=r.querySelectorAll(`[name^="${t}["]`);l.forEach((i,a)=>{a<n.length&&(i.value=n[a]!=null?String(n[a]):"",i.classList.remove("invalid"),i.title="")}),n.length!==l.length&&console.warn(`updateTextField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=r.querySelector(`[name="${t}"]`);l&&(l.value=n!=null?String(n):"",l.classList.remove("invalid"),l.title="")}}function Rt(e){e.style.overflow="hidden",e.style.resize="none";const t=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(1,t);const n=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`)};e.addEventListener("input",n),setTimeout(()=>{e.isConnected&&n()},0)}function Jn(e,t,n,o){const r=t.state,l=le(e,r,t),i=document.createElement("div");i.style.cssText="position: relative;";const a=document.createElement("textarea");if(a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",a.style.cssText="padding-bottom: 24px;",a.name=o,a.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",a.rows=e.rows||4,a.value=t.prefill[e.key]||e.default||"",a.readOnly=l,!l&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(o,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if((e.autoExpand||l)&&Rt(a),i.appendChild(a),!l&&(e.minLength!=null||e.maxLength!=null)){const s=Ie(e,a,!0);i.appendChild(s)}n.appendChild(i)}function Yn(e,t,n,o){var r,l;const i=t.state,a=le(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(r=e.minCount)!=null?r:1,u=(l=e.maxCount)!=null?l:1/0;for(;c.length<d;)c.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-textarea-item").forEach((g,y)=>{const C=g.querySelector("textarea");C&&(C.name=`${o}[${y}]`)})}function m(g="",y=-1){const C=document.createElement("div");C.className="multiple-textarea-item";const E=document.createElement("div");E.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText="padding-bottom: 24px;",x.placeholder=e.placeholder||$("placeholderText",i),x.rows=e.rows||4,x.value=g,x.readOnly=a,!a&&t.instance){const k=()=>{const q=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if((e.autoExpand||a)&&Rt(x),E.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=Ie(e,x,!0);E.appendChild(k)}return C.appendChild(E),y===-1?p.appendChild(C):p.insertBefore(C,p.children[y]),f(),C}function b(){if(a)return;const g=p.querySelectorAll(".multiple-textarea-item"),y=g.length;g.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",E.innerHTML="\u2715",E.onclick=()=>{const k=Array.from(p.children).indexOf(C);p.children.length>d&&(c.splice(k,1),C.remove(),f(),h(),b())},C.appendChild(E));const x=y<=d;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let v=null,w=null;if(!a){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-textarea-btn px-3 py-1 rounded",g.style.cssText=`
49
49
  color: var(--fb-primary-color);
50
50
  border: var(--fb-border-width) solid var(--fb-primary-color);
51
51
  background-color: transparent;
52
52
  font-size: var(--fb-font-size);
53
53
  transition: all var(--fb-transition-duration);
54
- `,d.textContent="+",d.addEventListener("mouseenter",()=>{d.style.backgroundColor="var(--fb-background-hover-color)"}),d.addEventListener("mouseleave",()=>{d.style.backgroundColor="transparent"}),d.onclick=()=>{i.push(e.default||""),p(e.default||""),x(),h()},b=document.createElement("span"),b.className="text-sm text-gray-500",v.appendChild(d),v.appendChild(b),n.appendChild(v)}function x(){if(!v||!b)return;const d=v.querySelector(".add-textarea-btn");if(d){const y=i.length>=f;d.disabled=y,d.style.opacity=y?"0.5":"1",d.style.pointerEvents=y?"none":"auto"}b.textContent=`${i.length}/${f===1/0?"\u221E":f}`}i.forEach(d=>p(d)),x(),h()}function kn(e,t,n){return Et(e,t,n)}function $n(e,t,n,r){Ct(e,t,n,r);const{scopeRoot:l,state:a}=r;if(e.autoExpand||a.config.readonly)if(e.multiple)l.querySelectorAll(`textarea[name^="${t}["]`).forEach(o=>{o.dispatchEvent(new Event("input"))});else{const o=l.querySelector(`textarea[name="${t}"]`);o&&o.dispatchEvent(new Event("input"))}}function kt(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
54
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{c.push(e.default||""),m(e.default||""),h(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",v.appendChild(g),v.appendChild(w),n.appendChild(v)}function h(){if(!v||!w)return;const g=v.querySelector(".add-textarea-btn");if(g){const y=c.length>=u;g.disabled=y,g.style.opacity=y?"0.5":"1",g.style.pointerEvents=y?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(g=>m(g)),h(),b()}function Xn(e,t,n){return Mt(e,t,n)}function Gn(e,t,n,o){qt(e,t,n,o);const{scopeRoot:r,state:l}=o;if(e.autoExpand||le(e,l))if(e.multiple)r.querySelectorAll(`textarea[name^="${t}["]`).forEach(i=>{i.dispatchEvent(new Event("input"))});else{const i=r.querySelector(`textarea[name="${t}"]`);i&&i.dispatchEvent(new Event("input"))}}function It(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
55
55
  position: absolute;
56
56
  top: 50%;
57
57
  transform: translateY(-50%);
@@ -61,199 +61,467 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
61
61
  pointer-events: none;
62
62
  background: var(--fb-background-color);
63
63
  padding: 0 4px;
64
- `;const r=e.min,l=e.max;let a="";r!=null&&l!=null?a=`${r} \u2013 ${l}`:l!=null?a=`\u2264${l}`:r!=null&&(a=`\u2265${r}`),n.textContent=a;const o=()=>{const s=t.value?parseFloat(t.value):null;if(s!=null){const i=r!=null&&s<r,u=l!=null&&s>l;n.style.color=i||u?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",o),o(),n}function Ln(e,t,n,r){const l=t.state,a=document.createElement("div");a.style.cssText="position: relative;";const o=document.createElement("input");if(o.type="number",o.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",o.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",o.name=r,o.placeholder=e.placeholder||"0",e.min!==void 0&&(o.min=e.min.toString()),e.max!==void 0&&(o.max=e.max.toString()),e.step!==void 0&&(o.step=e.step.toString()),o.value=t.prefill[e.key]||e.default||"",o.readOnly=l.config.readonly,!l.config.readonly&&t.instance){const s=()=>{const i=o.value?parseFloat(o.value):null;t.instance.triggerOnChange(r,i)};o.addEventListener("blur",s),o.addEventListener("input",s)}if(a.appendChild(o),!l.config.readonly&&(e.min!=null||e.max!=null)){const s=kt(e,o);a.appendChild(s)}n.appendChild(a)}function Sn(e,t,n,r){var l,a;const o=t.state,s=t.prefill[e.key]||[],i=Array.isArray(s)?[...s]:[],u=(l=e.minCount)!=null?l:1,f=(a=e.maxCount)!=null?a:1/0;for(;i.length<u;)i.push(e.default||"");const c=document.createElement("div");c.className="space-y-2",n.appendChild(c);function m(){c.querySelectorAll(".multiple-number-item").forEach((d,y)=>{const g=d.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function p(d="",y=-1){const g=document.createElement("div");g.className="multiple-number-item flex items-center gap-2";const E=document.createElement("div");E.style.cssText="position: relative; flex: 1;";const C=document.createElement("input");if(C.type="number",C.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",C.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",C.placeholder=e.placeholder||"0",e.min!==void 0&&(C.min=e.min.toString()),e.max!==void 0&&(C.max=e.max.toString()),e.step!==void 0&&(C.step=e.step.toString()),C.value=d.toString(),C.readOnly=o.config.readonly,!o.config.readonly&&t.instance){const w=()=>{const S=C.value?parseFloat(C.value):null;t.instance.triggerOnChange(C.name,S)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(E.appendChild(C),!o.config.readonly&&(e.min!=null||e.max!=null)){const w=kt(e,C);E.appendChild(w)}return g.appendChild(E),y===-1?c.appendChild(g):c.insertBefore(g,c.children[y]),m(),g}function h(){if(o.config.readonly)return;const d=c.querySelectorAll(".multiple-number-item"),y=d.length;d.forEach(g=>{let E=g.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",E.innerHTML="\u2715",E.onclick=()=>{const w=Array.from(c.children).indexOf(g);c.children.length>u&&(i.splice(w,1),g.remove(),m(),x(),h())},g.appendChild(E));const C=y<=u;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"})}let v=null,b=null;if(!o.config.readonly){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const d=document.createElement("button");d.type="button",d.className="add-number-btn px-3 py-1 rounded",d.style.cssText=`
64
+ `;const o=e.min,r=e.max;let l="";o!=null&&r!=null?l=`${o} \u2013 ${r}`:r!=null?l=`\u2264${r}`:o!=null&&(l=`\u2265${o}`),n.textContent=l;const i=()=>{const a=t.value?parseFloat(t.value):null;if(a!=null){const s=o!=null&&a<o,c=r!=null&&a>r;n.style.color=s||c?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",i),i(),n}function Zn(e,t,n,o){const r=t.state,l=le(e,r,t),i=document.createElement("div");i.style.cssText="position: relative;";const a=document.createElement("input");if(a.type="number",a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",a.name=o,a.placeholder=e.placeholder||"0",e.min!==void 0&&(a.min=e.min.toString()),e.max!==void 0&&(a.max=e.max.toString()),e.step!==void 0&&(a.step=e.step.toString()),a.value=t.prefill[e.key]||e.default||"",a.readOnly=l,!l&&t.instance){const s=()=>{const c=a.value?parseFloat(a.value):null;t.instance.triggerOnChange(o,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(i.appendChild(a),!l&&(e.min!=null||e.max!=null)){const s=It(e,a);i.appendChild(s)}n.appendChild(i)}function Qn(e,t,n,o){var r,l;const i=t.state,a=le(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(r=e.minCount)!=null?r:1,u=(l=e.maxCount)!=null?l:1/0;for(;c.length<d;)c.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-number-item").forEach((g,y)=>{const C=g.querySelector("input");C&&(C.name=`${o}[${y}]`)})}function m(g="",y=-1){const C=document.createElement("div");C.className="multiple-number-item flex items-center gap-2";const E=document.createElement("div");E.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="number",x.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",x.placeholder=e.placeholder||"0",e.min!==void 0&&(x.min=e.min.toString()),e.max!==void 0&&(x.max=e.max.toString()),e.step!==void 0&&(x.step=e.step.toString()),x.value=g.toString(),x.readOnly=a,!a&&t.instance){const k=()=>{const q=x.value?parseFloat(x.value):null;t.instance.triggerOnChange(x.name,q)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(E.appendChild(x),!a&&(e.min!=null||e.max!=null)){const k=It(e,x);E.appendChild(k)}return C.appendChild(E),y===-1?p.appendChild(C):p.insertBefore(C,p.children[y]),f(),C}function b(){if(a)return;const g=p.querySelectorAll(".multiple-number-item"),y=g.length;g.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",E.innerHTML="\u2715",E.onclick=()=>{const k=Array.from(p.children).indexOf(C);p.children.length>d&&(c.splice(k,1),C.remove(),f(),h(),b())},C.appendChild(E));const x=y<=d;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let v=null,w=null;if(!a){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-number-btn px-3 py-1 rounded",g.style.cssText=`
65
65
  color: var(--fb-primary-color);
66
66
  border: var(--fb-border-width) solid var(--fb-primary-color);
67
67
  background-color: transparent;
68
68
  font-size: var(--fb-font-size);
69
69
  transition: all var(--fb-transition-duration);
70
- `,d.textContent="+",d.addEventListener("mouseenter",()=>{d.style.backgroundColor="var(--fb-background-hover-color)"}),d.addEventListener("mouseleave",()=>{d.style.backgroundColor="transparent"}),d.onclick=()=>{i.push(e.default||""),p(e.default||""),x(),h()},b=document.createElement("span"),b.className="text-sm text-gray-500",v.appendChild(d),v.appendChild(b),n.appendChild(v)}function x(){if(!v||!b)return;const d=v.querySelector(".add-number-btn");if(d){const y=i.length>=f;d.disabled=y,d.style.opacity=y?"0.5":"1",d.style.pointerEvents=y?"none":"auto"}b.textContent=`${i.length}/${f===1/0?"\u221E":f}`}i.forEach(d=>p(d)),x(),h()}function Tn(e,t,n){var r,l,a,o,s;const i=[],{scopeRoot:u,skipValidation:f}=n,c=(p,h)=>{var v,b;if(!p)return;const x=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let d=document.getElementById(x);h?(p.classList.add("invalid"),p.title=h,d||(d=document.createElement("div"),d.id=x,d.className="error-message",d.style.cssText=`
70
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{c.push(e.default||""),m(e.default||""),h(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",v.appendChild(g),v.appendChild(w),n.appendChild(v)}function h(){if(!v||!w)return;const g=v.querySelector(".add-number-btn");if(g){const y=c.length>=u;g.disabled=y,g.style.opacity=y?"0.5":"1",g.style.pointerEvents=y?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(g=>m(g)),h(),b()}function eo(e,t,n){var o,r,l,i,a;const s=[],{scopeRoot:c,skipValidation:d}=n,u=(f,m)=>{var b,v;if(!f)return;const w=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(w);m?(f.classList.add("invalid"),f.title=m,h||(h=document.createElement("div"),h.id=w,h.className="error-message",h.style.cssText=`
71
71
  color: var(--fb-error-color);
72
72
  font-size: var(--fb-font-size-small);
73
73
  margin-top: 0.25rem;
74
- `,p.nextSibling?(v=p.parentNode)==null||v.insertBefore(d,p.nextSibling):(b=p.parentNode)==null||b.appendChild(d)),d.textContent=h,d.style.display="block"):(p.classList.remove("invalid"),p.title="",d&&d.remove())},m=(p,h,v)=>{let b=!1;const{state:x}=n;if(!f&&e.min!==void 0&&e.min!==null&&h<e.min){const d=k("minValue",x,{min:e.min});i.push(`${v}: ${d}`),c(p,d),b=!0}else if(!f&&e.max!==void 0&&e.max!==null&&h>e.max){const d=k("maxValue",x,{max:e.max});i.push(`${v}: ${d}`),c(p,d),b=!0}b||c(p,null)};if(e.multiple){const p=u.querySelectorAll(`[name^="${t}["]`),h=[];if(p.forEach((v,b)=>{var x,d,y;const g=(x=v==null?void 0:v.value)!=null?x:"";if(g===""){h.push(null),c(v,null);return}const E=parseFloat(g);if(!f&&!Number.isFinite(E)){const w=k("notANumber",n.state);i.push(`${t}[${b}]: ${w}`),c(v,w),h.push(null);return}m(v,E,`${t}[${b}]`);const C=Number.isInteger((d=e.decimals)!=null?d:0)&&(y=e.decimals)!=null?y:0;h.push(Number(E.toFixed(C)))}),!f){const{state:v}=n,b=(r=e.minCount)!=null?r:1,x=(l=e.maxCount)!=null?l:1/0,d=h.filter(y=>y!==null);e.required&&d.length===0&&i.push(`${t}: ${k("required",v)}`),d.length<b&&i.push(`${t}: ${k("minItems",v,{min:b})}`),d.length>x&&i.push(`${t}: ${k("maxItems",v,{max:x})}`)}return{value:h,errors:i}}else{const p=u.querySelector(`[name$="${t}"]`),h=(a=p==null?void 0:p.value)!=null?a:"",{state:v}=n;if(!f&&e.required&&h===""){const d=k("required",v);return i.push(`${t}: ${d}`),c(p,d),{value:null,errors:i}}if(h==="")return c(p,null),{value:null,errors:i};const b=parseFloat(h);if(!f&&!Number.isFinite(b)){const d=k("notANumber",v);return i.push(`${t}: ${d}`),c(p,d),{value:null,errors:i}}m(p,b,t);const x=Number.isInteger((o=e.decimals)!=null?o:0)&&(s=e.decimals)!=null?s:0;return{value:Number(b.toFixed(x)),errors:i}}}function An(e,t,n,r){const{scopeRoot:l}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=l.querySelectorAll(`[name^="${t}["]`);a.forEach((o,s)=>{s<n.length&&(o.value=n[s]!=null?String(n[s]):"",o.classList.remove("invalid"),o.title="")}),n.length!==a.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=l.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="")}}function Fn(e,t,n,r){const l=t.state,a=document.createElement("select");if(a.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",a.name=r,a.disabled=l.config.readonly,(e.options||[]).forEach(o=>{const s=document.createElement("option");s.value=o.value,s.textContent=o.label,(t.prefill[e.key]||e.default)===o.value&&(s.selected=!0),a.appendChild(s)}),!l.config.readonly&&t.instance){const o=()=>{t.instance.triggerOnChange(r,a.value)};a.addEventListener("change",o)}if(n.appendChild(a),!l.config.readonly){const o=document.createElement("p");o.className="text-xs text-gray-500 mt-1",o.textContent=ve(e,l),n.appendChild(o)}}function Nn(e,t,n,r){var l,a,o,s;const i=t.state,u=t.prefill[e.key]||[],f=Array.isArray(u)?[...u]:[],c=(l=e.minCount)!=null?l:1,m=(a=e.maxCount)!=null?a:1/0;for(;f.length<c;)f.push(e.default||((s=(o=e.options)==null?void 0:o[0])==null?void 0:s.value)||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function h(){p.querySelectorAll(".multiple-select-item").forEach((g,E)=>{const C=g.querySelector("select");C&&(C.name=`${r}[${E}]`)})}function v(g="",E=-1){const C=document.createElement("div");C.className="multiple-select-item flex items-center gap-2";const w=document.createElement("select");if(w.className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.disabled=i.config.readonly,(e.options||[]).forEach(S=>{const z=document.createElement("option");z.value=S.value,z.textContent=S.label,g===S.value&&(z.selected=!0),w.appendChild(z)}),!i.config.readonly&&t.instance){const S=()=>{t.instance.triggerOnChange(w.name,w.value)};w.addEventListener("change",S)}return C.appendChild(w),E===-1?p.appendChild(C):p.insertBefore(C,p.children[E]),h(),C}function b(){if(i.config.readonly)return;const g=p.querySelectorAll(".multiple-select-item"),E=g.length;g.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 text-red-600 hover:bg-red-50 rounded",w.innerHTML="\u2715",w.onclick=()=>{const z=Array.from(p.children).indexOf(C);p.children.length>c&&(f.splice(z,1),C.remove(),h(),y(),b())},C.appendChild(w));const S=E<=c;w.disabled=S,w.style.opacity=S?"0.5":"1",w.style.pointerEvents=S?"none":"auto"})}let x=null,d=null;if(!i.config.readonly){x=document.createElement("div"),x.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-select-btn px-3 py-1 rounded",g.style.cssText=`
74
+ `,f.nextSibling?(b=f.parentNode)==null||b.insertBefore(h,f.nextSibling):(v=f.parentNode)==null||v.appendChild(h)),h.textContent=m,h.style.display="block"):(f.classList.remove("invalid"),f.title="",h&&h.remove())},p=(f,m,b)=>{let v=!1;const{state:w}=n;if(!d&&e.min!==void 0&&e.min!==null&&m<e.min){const h=$("minValue",w,{min:e.min});s.push(`${b}: ${h}`),u(f,h),v=!0}else if(!d&&e.max!==void 0&&e.max!==null&&m>e.max){const h=$("maxValue",w,{max:e.max});s.push(`${b}: ${h}`),u(f,h),v=!0}v||u(f,null)};if(e.multiple){const f=c.querySelectorAll(`[name^="${t}["]`),m=[];if(f.forEach((b,v)=>{var w,h,g;const y=(w=b==null?void 0:b.value)!=null?w:"";if(y===""){m.push(null),u(b,null);return}const C=parseFloat(y);if(!d&&!Number.isFinite(C)){const x=$("notANumber",n.state);s.push(`${t}[${v}]: ${x}`),u(b,x),m.push(null);return}p(b,C,`${t}[${v}]`);const E=Number.isInteger((h=e.decimals)!=null?h:0)&&(g=e.decimals)!=null?g:0;m.push(Number(C.toFixed(E)))}),!d){const{state:b}=n,v=(o=e.minCount)!=null?o:1,w=(r=e.maxCount)!=null?r:1/0,h=m.filter(g=>g!==null);e.required&&h.length===0&&s.push(`${t}: ${$("required",b)}`),h.length<v&&s.push(`${t}: ${$("minItems",b,{min:v})}`),h.length>w&&s.push(`${t}: ${$("maxItems",b,{max:w})}`)}return{value:m,errors:s}}else{const f=c.querySelector(`[name$="${t}"]`),m=(l=f==null?void 0:f.value)!=null?l:"",{state:b}=n;if(!d&&e.required&&m===""){const h=$("required",b);return s.push(`${t}: ${h}`),u(f,h),{value:null,errors:s}}if(m==="")return u(f,null),{value:null,errors:s};const v=parseFloat(m);if(!d&&!Number.isFinite(v)){const h=$("notANumber",b);return s.push(`${t}: ${h}`),u(f,h),{value:null,errors:s}}p(f,v,t);const w=Number.isInteger((i=e.decimals)!=null?i:0)&&(a=e.decimals)!=null?a:0;return{value:Number(v.toFixed(w)),errors:s}}}function to(e,t,n,o){const{scopeRoot:r}=o;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=r.querySelectorAll(`[name^="${t}["]`);l.forEach((i,a)=>{a<n.length&&(i.value=n[a]!=null?String(n[a]):"",i.classList.remove("invalid"),i.title="")}),n.length!==l.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=r.querySelector(`[name="${t}"]`);l&&(l.value=n!=null?String(n):"",l.classList.remove("invalid"),l.title="")}}function no(e,t,n,o){const r=t.state,l=le(e,r,t),i=document.createElement("select");if(i.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",i.name=o,i.disabled=l,(e.options||[]).forEach(a=>{const s=document.createElement("option");s.value=a.value,s.textContent=a.label,(t.prefill[e.key]||e.default)===a.value&&(s.selected=!0),i.appendChild(s)}),!l&&t.instance){const a=()=>{t.instance.triggerOnChange(o,i.value)};i.addEventListener("change",a)}if(n.appendChild(i),!l){const a=document.createElement("p");a.className="text-xs text-gray-500 mt-1",a.textContent=ye(e,r),n.appendChild(a)}}function oo(e,t,n,o){var r,l,i,a;const s=t.state,c=le(e,s,t),d=t.prefill[e.key]||[],u=Array.isArray(d)?[...d]:[],p=(r=e.minCount)!=null?r:1,f=(l=e.maxCount)!=null?l:1/0;for(;u.length<p;)u.push(e.default||((a=(i=e.options)==null?void 0:i[0])==null?void 0:a.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((C,E)=>{const x=C.querySelector("select");x&&(x.name=`${o}[${E}]`)})}function v(C="",E=-1){const x=document.createElement("div");x.className="multiple-select-item flex items-center gap-2";const k=document.createElement("select");if(k.className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",k.disabled=c,(e.options||[]).forEach(q=>{const K=document.createElement("option");K.value=q.value,K.textContent=q.label,C===q.value&&(K.selected=!0),k.appendChild(K)}),!c&&t.instance){const q=()=>{t.instance.triggerOnChange(k.name,k.value)};k.addEventListener("change",q)}return x.appendChild(k),E===-1?m.appendChild(x):m.insertBefore(x,m.children[E]),b(),x}function w(){if(c)return;const C=m.querySelectorAll(".multiple-select-item"),E=C.length;C.forEach(x=>{let k=x.querySelector(".remove-item-btn");k||(k=document.createElement("button"),k.type="button",k.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",k.innerHTML="\u2715",k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>p&&(u.splice(K,1),x.remove(),b(),y(),w())},x.appendChild(k));const q=E<=p;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let h=null,g=null;if(!c){h=document.createElement("div"),h.className="flex items-center gap-3 mt-2";const C=document.createElement("button");C.type="button",C.className="add-select-btn px-3 py-1 rounded",C.style.cssText=`
75
75
  color: var(--fb-primary-color);
76
76
  border: var(--fb-border-width) solid var(--fb-primary-color);
77
77
  background-color: transparent;
78
78
  font-size: var(--fb-font-size);
79
79
  transition: all var(--fb-transition-duration);
80
- `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{var E,C;const w=e.default||((C=(E=e.options)==null?void 0:E[0])==null?void 0:C.value)||"";f.push(w),v(w),y(),b()},d=document.createElement("span"),d.className="text-sm text-gray-500",x.appendChild(g),x.appendChild(d),n.appendChild(x)}function y(){if(!x||!d)return;const g=x.querySelector(".add-select-btn");if(g){const E=f.length>=m;g.disabled=E,g.style.opacity=E?"0.5":"1",g.style.pointerEvents=E?"none":"auto"}d.textContent=`${f.length}/${m===1/0?"\u221E":m}`}if(f.forEach(g=>v(g)),y(),b(),!i.config.readonly){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=ve(e,i),n.appendChild(g)}}function Mn(e,t,n){var r;const l=[],{scopeRoot:a,skipValidation:o}=n,s=(u,f)=>{var c,m;if(!u)return;const p=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(p);f?(u.classList.add("invalid"),u.title=f,h||(h=document.createElement("div"),h.id=p,h.className="error-message",h.style.cssText=`
80
+ `,C.textContent="+",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{var E,x;const k=e.default||((x=(E=e.options)==null?void 0:E[0])==null?void 0:x.value)||"";u.push(k),v(k),y(),w()},g=document.createElement("span"),g.className="text-sm text-gray-500",h.appendChild(C),h.appendChild(g),n.appendChild(h)}function y(){if(!h||!g)return;const C=h.querySelector(".add-select-btn");if(C){const E=u.length>=f;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"}g.textContent=`${u.length}/${f===1/0?"\u221E":f}`}if(u.forEach(C=>v(C)),y(),w(),!c){const C=document.createElement("p");C.className="text-xs text-gray-500 mt-1",C.textContent=ye(e,s),n.appendChild(C)}}function ro(e,t,n){var o;const r=[],{scopeRoot:l,skipValidation:i}=n,a=(c,d)=>{var u,p;if(!c)return;const f=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(f);d?(c.classList.add("invalid"),c.title=d,m||(m=document.createElement("div"),m.id=f,m.className="error-message",m.style.cssText=`
81
81
  color: var(--fb-error-color);
82
82
  font-size: var(--fb-font-size-small);
83
83
  margin-top: 0.25rem;
84
- `,u.nextSibling?(c=u.parentNode)==null||c.insertBefore(h,u.nextSibling):(m=u.parentNode)==null||m.appendChild(h)),h.textContent=f,h.style.display="block"):(u.classList.remove("invalid"),u.title="",h&&h.remove())},i=(u,f,c,m)=>{var p,h;if(o)return;const{state:v}=n,b=f.filter(m),x="minCount"in c&&(p=c.minCount)!=null?p:1,d="maxCount"in c&&(h=c.maxCount)!=null?h:1/0;c.required&&b.length===0&&l.push(`${u}: ${k("required",v)}`),b.length<x&&l.push(`${u}: ${k("minItems",v,{min:x})}`),b.length>d&&l.push(`${u}: ${k("maxItems",v,{max:d})}`)};if("multiple"in e&&e.multiple){const u=a.querySelectorAll(`[name^="${t}["]`),f=[];return u.forEach(c=>{var m;const p=(m=c==null?void 0:c.value)!=null?m:"";f.push(p),s(c,null)}),i(t,f,e,c=>c!==""),{value:f,errors:l}}else{const u=a.querySelector(`[name$="${t}"]`),f=(r=u==null?void 0:u.value)!=null?r:"";if(!o&&e.required&&f===""){const c=k("required",n.state);return l.push(`${t}: ${c}`),s(u,c),{value:null,errors:l}}else s(u,null);return{value:f===""?null:f,errors:l}}}function qn(e,t,n,r){const{scopeRoot:l}=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 a=l.querySelectorAll(`[name^="${t}["]`);a.forEach((o,s)=>{s<n.length&&(o.value=n[s]!=null?String(n[s]):"",o.querySelectorAll("option").forEach(i=>{i.selected=i.value===String(n[s])}),o.classList.remove("invalid"),o.title="")}),n.length!==a.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${a.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=l.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.querySelectorAll("option").forEach(o=>{o.selected=o.value===String(n)}),a.classList.remove("invalid"),a.title="")}}function Oe(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function Ue(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function $t(e,t,n,r,l){const a=e.options||[],o=document.createElement("div");o.className="fb-switcher-group",o.style.cssText=`
84
+ `,c.nextSibling?(u=c.parentNode)==null||u.insertBefore(m,c.nextSibling):(p=c.parentNode)==null||p.appendChild(m)),m.textContent=d,m.style.display="block"):(c.classList.remove("invalid"),c.title="",m&&m.remove())},s=(c,d,u,p)=>{var f,m;if(i)return;const{state:b}=n,v=d.filter(p),w="minCount"in u&&(f=u.minCount)!=null?f:1,h="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&v.length===0&&r.push(`${c}: ${$("required",b)}`),v.length<w&&r.push(`${c}: ${$("minItems",b,{min:w})}`),v.length>h&&r.push(`${c}: ${$("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const c=l.querySelectorAll(`[name^="${t}["]`),d=[];return c.forEach(u=>{var p;const f=(p=u==null?void 0:u.value)!=null?p:"";d.push(f),a(u,null)}),s(t,d,e,u=>u!==""),{value:d,errors:r}}else{const c=l.querySelector(`[name$="${t}"]`),d=(o=c==null?void 0:c.value)!=null?o:"";if(!i&&e.required&&d===""){const u=$("required",n.state);return r.push(`${t}: ${u}`),a(c,u),{value:null,errors:r}}else a(c,null);return{value:d===""?null:d,errors:r}}}function lo(e,t,n,o){const{scopeRoot:r}=o;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=r.querySelectorAll(`[name^="${t}["]`);l.forEach((i,a)=>{a<n.length&&(i.value=n[a]!=null?String(n[a]):"",i.querySelectorAll("option").forEach(s=>{s.selected=s.value===String(n[a])}),i.classList.remove("invalid"),i.title="")}),n.length!==l.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${l.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=r.querySelector(`[name="${t}"]`);l&&(l.value=n!=null?String(n):"",l.querySelectorAll("option").forEach(i=>{i.selected=i.value===String(n)}),l.classList.remove("invalid"),l.title="")}}function Ve(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function We(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Ht(e,t,n,o,r){const l=e.options||[],i=document.createElement("div");i.className="fb-switcher-group",i.style.cssText=`
85
85
  display: inline-flex;
86
86
  flex-direction: row;
87
87
  flex-wrap: nowrap;
88
- `;const s=[];return a.forEach((i,u)=>{const f=document.createElement("button");f.type="button",f.className="fb-switcher-btn",f.dataset.value=i.value,f.textContent=i.label,f.style.cssText=`
88
+ `;const a=[];return l.forEach((s,c)=>{const d=document.createElement("button");d.type="button",d.className="fb-switcher-btn",d.dataset.value=s.value,d.textContent=s.label,d.style.cssText=`
89
89
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
90
90
  font-size: var(--fb-font-size);
91
91
  border-width: var(--fb-border-width);
92
92
  border-style: solid;
93
- cursor: ${r?"default":"pointer"};
93
+ cursor: ${o?"default":"pointer"};
94
94
  transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
95
95
  white-space: nowrap;
96
96
  line-height: 1.25;
97
97
  outline: none;
98
- `,a.length===1?f.style.borderRadius="var(--fb-border-radius)":u===0?(f.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",f.style.borderRightWidth="0"):u===a.length-1?f.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(f.style.borderRadius="0",f.style.borderRightWidth="0"),i.value===t?Oe(f):Ue(f),r||(f.addEventListener("click",()=>{n.value=i.value,s.forEach(c=>{c.dataset.value===i.value?Oe(c):Ue(c)}),l&&l(i.value)}),f.addEventListener("mouseenter",()=>{n.value!==i.value&&(f.style.backgroundColor="var(--fb-background-hover-color)")}),f.addEventListener("mouseleave",()=>{n.value!==i.value&&(f.style.backgroundColor="transparent")})),s.push(f),o.appendChild(f)}),o}function zn(e,t,n,r){var l,a;const o=t.state,s=String((a=(l=t.prefill[e.key])!=null?l:e.default)!=null?a:""),i=document.createElement("input");i.type="hidden",i.name=r,i.value=s;const u=o.config.readonly,f=!u&&t.instance?m=>{t.instance.triggerOnChange(r,m)}:null,c=$t(e,s,i,u,f);if(n.appendChild(i),n.appendChild(c),!u){const m=document.createElement("p");m.className="text-xs text-gray-500 mt-1",m.textContent=ve(e,o),n.appendChild(m)}}function Hn(e,t,n,r){var l,a,o,s;const i=t.state,u=t.prefill[e.key]||[],f=Array.isArray(u)?[...u]:[],c=(l=e.minCount)!=null?l:1,m=(a=e.maxCount)!=null?a:1/0;for(;f.length<c;)f.push(e.default||((s=(o=e.options)==null?void 0:o[0])==null?void 0:s.value)||"");const p=i.config.readonly,h=document.createElement("div");h.className="space-y-2",n.appendChild(h);function v(){h.querySelectorAll(".multiple-switcher-item").forEach((E,C)=>{const w=E.querySelector("input[type=hidden]");w&&(w.name=`${r}[${C}]`)})}function b(E="",C=-1){const w=C===-1?h.children.length:C,S=`${r}[${w}]`,z=document.createElement("div");z.className="multiple-switcher-item flex items-center gap-2";const Z=document.createElement("input");Z.type="hidden",Z.name=S,Z.value=E,z.appendChild(Z);const R=!p&&t.instance?fe=>{t.instance.triggerOnChange(Z.name,fe)}:null,_=$t(e,E,Z,p,R);return z.appendChild(_),C===-1?h.appendChild(z):h.insertBefore(z,h.children[C]),v(),z}function x(){if(p)return;const E=h.querySelectorAll(".multiple-switcher-item"),C=E.length;E.forEach(w=>{let S=w.querySelector(".remove-item-btn");S||(S=document.createElement("button"),S.type="button",S.className="remove-item-btn px-2 py-1 rounded",S.style.cssText=`
98
+ `,l.length===1?d.style.borderRadius="var(--fb-border-radius)":c===0?(d.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",d.style.borderRightWidth="0"):c===l.length-1?d.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(d.style.borderRadius="0",d.style.borderRightWidth="0"),s.value===t?Ve(d):We(d),o||(d.addEventListener("click",()=>{n.value=s.value,a.forEach(u=>{u.dataset.value===s.value?Ve(u):We(u)}),r&&r(s.value)}),d.addEventListener("mouseenter",()=>{n.value!==s.value&&(d.style.backgroundColor="var(--fb-background-hover-color)")}),d.addEventListener("mouseleave",()=>{n.value!==s.value&&(d.style.backgroundColor="transparent")})),a.push(d),i.appendChild(d)}),i}function io(e,t,n,o){var r,l;const i=t.state,a=String((l=(r=t.prefill[e.key])!=null?r:e.default)!=null?l:""),s=document.createElement("input");s.type="hidden",s.name=o,s.value=a;const c=le(e,i,t),d=!c&&t.instance?p=>{t.instance.triggerOnChange(o,p)}:null,u=Ht(e,a,s,c,d);if(n.appendChild(s),n.appendChild(u),!c){const p=document.createElement("p");p.className="text-xs text-gray-500 mt-1",p.textContent=ye(e,i),n.appendChild(p)}}function ao(e,t,n,o){var r,l,i,a;const s=t.state,c=t.prefill[e.key]||[],d=Array.isArray(c)?[...c]:[],u=(r=e.minCount)!=null?r:1,p=(l=e.maxCount)!=null?l:1/0;for(;d.length<u;)d.push(e.default||((a=(i=e.options)==null?void 0:i[0])==null?void 0:a.value)||"");const f=le(e,s,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((C,E)=>{const x=C.querySelector("input[type=hidden]");x&&(x.name=`${o}[${E}]`)})}function v(C="",E=-1){const x=E===-1?m.children.length:E,k=`${o}[${x}]`,q=document.createElement("div");q.className="multiple-switcher-item flex items-center gap-2";const K=document.createElement("input");K.type="hidden",K.name=k,K.value=C,q.appendChild(K);const I=!f&&t.instance?Z=>{t.instance.triggerOnChange(K.name,Z)}:null,G=Ht(e,C,K,f,I);return q.appendChild(G),E===-1?m.appendChild(q):m.insertBefore(q,m.children[E]),b(),q}function w(){if(f)return;const C=m.querySelectorAll(".multiple-switcher-item"),E=C.length;C.forEach(x=>{let k=x.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=`
99
99
  color: var(--fb-error-color);
100
100
  background-color: transparent;
101
101
  transition: background-color var(--fb-transition-duration);
102
- `,S.innerHTML="\u2715",S.addEventListener("mouseenter",()=>{S.style.backgroundColor="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.backgroundColor="transparent"}),S.onclick=()=>{const Z=Array.from(h.children).indexOf(w);h.children.length>c&&(f.splice(Z,1),w.remove(),v(),g(),x())},w.appendChild(S));const z=C<=c;S.disabled=z,S.style.opacity=z?"0.5":"1",S.style.pointerEvents=z?"none":"auto"})}let d=null,y=null;if(!p){d=document.createElement("div"),d.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-switcher-btn px-3 py-1 rounded",E.style.cssText=`
102
+ `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const K=Array.from(m.children).indexOf(x);m.children.length>u&&(d.splice(K,1),x.remove(),b(),y(),w())},x.appendChild(k));const q=E<=u;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let h=null,g=null;if(!f){h=document.createElement("div"),h.className="flex items-center gap-3 mt-2";const C=document.createElement("button");C.type="button",C.className="add-switcher-btn px-3 py-1 rounded",C.style.cssText=`
103
103
  color: var(--fb-primary-color);
104
104
  border: var(--fb-border-width) solid var(--fb-primary-color);
105
105
  background-color: transparent;
106
106
  font-size: var(--fb-font-size);
107
107
  transition: all var(--fb-transition-duration);
108
- `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var C,w;const S=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";f.push(S),b(S),g(),x()},y=document.createElement("span"),y.className="text-sm text-gray-500",d.appendChild(E),d.appendChild(y),n.appendChild(d)}function g(){if(!d||!y)return;const E=d.querySelector(".add-switcher-btn");if(E){const C=f.length>=m;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"}y.textContent=`${f.length}/${m===1/0?"\u221E":m}`}if(f.forEach(E=>b(E)),g(),x(),!p){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=ve(e,i),n.appendChild(E)}}function In(e,t,n){var r;const l=[],{scopeRoot:a,skipValidation:o}=n,s=(f,c)=>{var m,p;if(!f)return;const h=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(h);c?(f.classList.add("invalid"),f.title=c,v||(v=document.createElement("div"),v.id=h,v.className="error-message",v.style.cssText=`
108
+ `,C.textContent="+",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{var E,x;const k=e.default||((x=(E=e.options)==null?void 0:E[0])==null?void 0:x.value)||"";d.push(k),v(k),y(),w()},g=document.createElement("span"),g.className="text-sm text-gray-500",h.appendChild(C),h.appendChild(g),n.appendChild(h)}function y(){if(!h||!g)return;const C=h.querySelector(".add-switcher-btn");if(C){const E=d.length>=p;C.disabled=E,C.style.opacity=E?"0.5":"1",C.style.pointerEvents=E?"none":"auto"}g.textContent=`${d.length}/${p===1/0?"\u221E":p}`}if(d.forEach(C=>v(C)),y(),w(),!f){const C=document.createElement("p");C.className="text-xs text-gray-500 mt-1",C.textContent=ye(e,s),n.appendChild(C)}}function so(e,t,n){var o;const r=[],{scopeRoot:l,skipValidation:i}=n,a=(d,u)=>{var p,f;if(!d)return;const m=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);u?(d.classList.add("invalid"),d.title=u,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
109
109
  color: var(--fb-error-color);
110
110
  font-size: var(--fb-font-size-small);
111
111
  margin-top: 0.25rem;
112
- `,f.nextSibling?(m=f.parentNode)==null||m.insertBefore(v,f.nextSibling):(p=f.parentNode)==null||p.appendChild(v)),v.textContent=c,v.style.display="block"):(f.classList.remove("invalid"),f.title="",v&&v.remove())},i=(f,c,m,p)=>{var h,v;if(o)return;const{state:b}=n,x=c.filter(p),d="minCount"in m&&(h=m.minCount)!=null?h:1,y="maxCount"in m&&(v=m.maxCount)!=null?v:1/0;m.required&&x.length===0&&l.push(`${f}: ${k("required",b)}`),x.length<d&&l.push(`${f}: ${k("minItems",b,{min:d})}`),x.length>y&&l.push(`${f}: ${k("maxItems",b,{max:y})}`)},u=new Set("options"in e?e.options.map(f=>f.value):[]);if("multiple"in e&&e.multiple){const f=a.querySelectorAll(`input[type="hidden"][name^="${t}["]`),c=[];return f.forEach(m=>{var p;const h=(p=m==null?void 0:m.value)!=null?p:"";if(c.push(h),!o&&h!==""&&!u.has(h)){const v=k("invalidOption",n.state);s(m,v),l.push(`${t}: ${v}`)}else s(m,null)}),i(t,c,e,m=>m!==""),{value:c,errors:l}}else{const f=a.querySelector(`input[type="hidden"][name$="${t}"]`),c=(r=f==null?void 0:f.value)!=null?r:"";if(!o&&e.required&&c===""){const m=k("required",n.state);return l.push(`${t}: ${m}`),s(f,m),{value:null,errors:l}}if(!o&&c!==""&&!u.has(c)){const m=k("invalidOption",n.state);return l.push(`${t}: ${m}`),s(f,m),{value:null,errors:l}}return s(f,null),{value:c===""?null:c,errors:l}}}function Bn(e,t,n,r){var l;const{scopeRoot:a}=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 o=a.querySelectorAll(`input[type="hidden"][name^="${t}["]`);o.forEach((s,i)=>{var u;if(i<n.length){const f=n[i]!=null?String(n[i]):"";s.value=f;const c=(u=s.parentElement)==null?void 0:u.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(m=>{m.dataset.value===f?Oe(m):Ue(m)}),s.classList.remove("invalid"),s.title=""}}),n.length!==o.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${o.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const o=a.querySelector(`input[type="hidden"][name="${t}"]`);if(o){const s=n!=null?String(n):"";o.value=s;const i=(l=o.parentElement)==null?void 0:l.querySelector(".fb-switcher-group");i&&i.querySelectorAll(".fb-switcher-btn").forEach(u=>{u.dataset.value===s?Oe(u):Ue(u)}),o.classList.remove("invalid"),o.title=""}}}function He(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 we(e,t){var n;if(t.length===0)return!0;const r=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"";return t.includes(r)}function Le(e,t){return t===1/0?!0:e.size<=t*1024*1024}function Rn(e,t,n,r){const l=document.createElement("img");l.className="w-full h-full object-contain",l.alt=n||k("previewAlt",r);const a=new FileReader;a.onload=o=>{var s;l.src=((s=o.target)==null?void 0:s.result)||""},a.readAsDataURL(t),e.appendChild(l)}function Dn(e,t,n,r,l,a){const o=URL.createObjectURL(t);e.onclick=null;const s=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(s,e),s.innerHTML=`
113
- <div class="relative group h-full">
114
- <video class="w-full h-full object-contain" controls preload="auto" muted src="${o}">
115
- ${J(k("videoNotSupported",l))}
112
+ `,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(b,d.nextSibling):(f=d.parentNode)==null||f.appendChild(b)),b.textContent=u,b.style.display="block"):(d.classList.remove("invalid"),d.title="",b&&b.remove())},s=(d,u,p,f)=>{var m,b;if(i)return;const{state:v}=n,w=u.filter(f),h="minCount"in p&&(m=p.minCount)!=null?m:1,g="maxCount"in p&&(b=p.maxCount)!=null?b:1/0;p.required&&w.length===0&&r.push(`${d}: ${$("required",v)}`),w.length<h&&r.push(`${d}: ${$("minItems",v,{min:h})}`),w.length>g&&r.push(`${d}: ${$("maxItems",v,{max:g})}`)},c=new Set("options"in e?e.options.map(d=>d.value):[]);if("multiple"in e&&e.multiple){const d=l.querySelectorAll(`input[type="hidden"][name^="${t}["]`),u=[];return d.forEach(p=>{var f;const m=(f=p==null?void 0:p.value)!=null?f:"";if(u.push(m),!i&&m!==""&&!c.has(m)){const b=$("invalidOption",n.state);a(p,b),r.push(`${t}: ${b}`)}else a(p,null)}),s(t,u,e,p=>p!==""),{value:u,errors:r}}else{const d=l.querySelector(`input[type="hidden"][name$="${t}"]`),u=(o=d==null?void 0:d.value)!=null?o:"";if(!i&&e.required&&u===""){const p=$("required",n.state);return r.push(`${t}: ${p}`),a(d,p),{value:null,errors:r}}if(!i&&u!==""&&!c.has(u)){const p=$("invalidOption",n.state);return r.push(`${t}: ${p}`),a(d,p),{value:null,errors:r}}return a(d,null),{value:u===""?null:u,errors:r}}}function co(e,t,n,o){var r;const{scopeRoot:l}=o;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=l.querySelectorAll(`input[type="hidden"][name^="${t}["]`);i.forEach((a,s)=>{var c;if(s<n.length){const d=n[s]!=null?String(n[s]):"";a.value=d;const u=(c=a.parentElement)==null?void 0:c.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(p=>{p.dataset.value===d?Ve(p):We(p)}),a.classList.remove("invalid"),a.title=""}}),n.length!==i.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=l.querySelector(`input[type="hidden"][name="${t}"]`);if(i){const a=n!=null?String(n):"";i.value=a;const s=(r=i.parentElement)==null?void 0:r.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(c=>{c.dataset.value===a?Ve(c):We(c)}),i.classList.remove("invalid"),i.title=""}}}function He(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 Be(e,t){var n,o;if(t.length===0)return!0;const r=(o=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?o:"";return t.includes(r)}function Ke(e,t){return t===1/0?!0:e.size<=t*1024*1024}function _e(e,t){var n;for(const o of e){if(t.has(o))continue;const r=o.split("/").pop()||"file",l=(n=r.split(".").pop())==null?void 0:n.toLowerCase();let i="application/octet-stream";l&&(["jpg","jpeg","png","gif","webp"].includes(l)?i=`image/${l==="jpg"?"jpeg":l}`:["mp4","webm","mov","avi"].includes(l)&&(i=`video/${l==="mov"?"quicktime":l}`)),t.set(o,{name:r,type:i,size:0,uploadedAt:new Date,file:void 0})}}const Bt="fb-file-styles";function Je(){if(typeof document=="undefined"||document.getElementById(Bt))return;const e=document.createElement("style");e.id=Bt,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
113
+ @keyframes fb-spin { to { transform: rotate(360deg); } }
114
+
115
+ /* Spinner used during single-file and multi-file upload */
116
+ .fb-spinner {
117
+ width: 36px;
118
+ height: 36px;
119
+ border: 3px solid rgba(0,0,0,0.12);
120
+ border-top-color: var(--fb-text-secondary-color, #6b7280);
121
+ border-radius: 50%;
122
+ animation: fb-spin 0.7s linear infinite;
123
+ flex-shrink: 0;
124
+ }
125
+
126
+ /* Base tile: fixed 160\xD7160 square, theme-aware background */
127
+ .fb-tile {
128
+ width: var(--fb-tile-size, 160px);
129
+ height: var(--fb-tile-size, 160px);
130
+ flex-shrink: 0;
131
+ position: relative;
132
+ overflow: hidden;
133
+ border-radius: var(--fb-border-radius, 0.5rem);
134
+ background: var(--fb-file-upload-bg-color, #f3f4f6);
135
+ }
136
+
137
+ /* Uploaded resource tile \u2014 adds a visible border */
138
+ .fb-tile-resource {
139
+ border: 1px solid var(--fb-file-upload-border-color, #d1d5db);
140
+ }
141
+
142
+ /* Uploading placeholder tile \u2014 dashed border, uploading indicator */
143
+ .fb-tile-uploading {
144
+ border: 2px dashed var(--fb-file-upload-border-color, #d1d5db);
145
+ }
146
+
147
+ /* "+" add-more tile */
148
+ .fb-tile-add {
149
+ border: 2px dashed var(--fb-file-upload-border-color, #d1d5db);
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: center;
153
+ cursor: pointer;
154
+ font-size: 32px;
155
+ color: var(--fb-file-upload-text-color, #9ca3af);
156
+ transition:
157
+ border-color var(--fb-transition-duration, 200ms),
158
+ color var(--fb-transition-duration, 200ms);
159
+ }
160
+ .fb-tile-add:hover {
161
+ border-color: var(--fb-file-upload-hover-border-color, #3b82f6);
162
+ color: var(--fb-text-color, #1f2937);
163
+ }
164
+
165
+ /* Count chip shown when at maxCount */
166
+ .fb-tile-counter {
167
+ font-size: 11px;
168
+ color: var(--fb-text-secondary-color, #6b7280);
169
+ background: var(--fb-file-upload-bg-color, #f3f4f6);
170
+ border: 1px solid var(--fb-file-upload-border-color, #d1d5db);
171
+ border-radius: 4px;
172
+ padding: 2px 6px;
173
+ align-self: flex-end;
174
+ margin-bottom: 4px;
175
+ }
176
+
177
+ /* Empty-state dropzone */
178
+ .fb-file-dropzone {
179
+ width: 100%;
180
+ height: 128px;
181
+ border: 2px dashed var(--fb-file-upload-border-color, #d1d5db);
182
+ border-radius: var(--fb-border-radius, 0.5rem);
183
+ display: flex;
184
+ flex-direction: column;
185
+ align-items: center;
186
+ justify-content: center;
187
+ gap: 4px;
188
+ cursor: pointer;
189
+ transition:
190
+ border-color var(--fb-transition-duration, 200ms),
191
+ background var(--fb-transition-duration, 200ms);
192
+ }
193
+ .fb-file-dropzone:hover {
194
+ border-color: var(--fb-file-upload-hover-border-color, #3b82f6);
195
+ background: var(--fb-background-hover-color, #f9fafb);
196
+ }
197
+
198
+ /* Inline text inside tiles */
199
+ .fb-tile-label {
200
+ font-size: 9px;
201
+ color: var(--fb-text-secondary-color, #6b7280);
202
+ text-align: center;
203
+ overflow: hidden;
204
+ word-break: break-all;
205
+ max-height: 28px;
206
+ }
207
+ .fb-tile-uploading-text {
208
+ font-size: 8px;
209
+ color: var(--fb-file-upload-text-color, #9ca3af);
210
+ }
211
+ .fb-tile-hint {
212
+ font-size: 11px;
213
+ color: var(--fb-file-upload-text-color, #9ca3af);
214
+ margin-top: 4px;
215
+ }
216
+ .fb-tile-empty-text {
217
+ font-size: 12px;
218
+ color: var(--fb-text-secondary-color, #6b7280);
219
+ padding: 4px 0;
220
+ }
221
+ .fb-dropzone-primary-text {
222
+ font-size: 13px;
223
+ color: var(--fb-text-secondary-color, #6b7280);
224
+ }
225
+ .fb-dropzone-hint-text {
226
+ font-size: 11px;
227
+ color: var(--fb-file-upload-text-color, #9ca3af);
228
+ }
229
+
230
+ /* Hover overlay + X-button on resource tiles */
231
+ .fb-tile-overlay {
232
+ position: absolute;
233
+ inset: 0;
234
+ background: transparent;
235
+ transition: background var(--fb-transition-duration, 200ms);
236
+ display: flex;
237
+ align-items: flex-start;
238
+ justify-content: flex-end;
239
+ }
240
+ .fb-tile-resource:hover .fb-tile-overlay {
241
+ background: var(--fb-tile-hover-overlay-color, rgba(0,0,0,0.4));
242
+ }
243
+ .fb-tile-x-btn {
244
+ margin: 3px;
245
+ width: 18px;
246
+ height: 18px;
247
+ background: var(--fb-error-color, #ef4444);
248
+ color: var(--fb-file-bg-color, #fff);
249
+ border: none;
250
+ border-radius: 50%;
251
+ font-size: 11px;
252
+ line-height: 1;
253
+ cursor: pointer;
254
+ display: flex;
255
+ align-items: center;
256
+ justify-content: center;
257
+ opacity: 0;
258
+ transition: opacity var(--fb-transition-duration, 200ms);
259
+ }
260
+ .fb-tile-resource:hover .fb-tile-x-btn {
261
+ opacity: 1;
262
+ }
263
+
264
+ /* Video play button overlay (readonly tiles with video thumbnails) */
265
+ .fb-video-overlay {
266
+ position: absolute;
267
+ inset: 0;
268
+ display: flex;
269
+ align-items: center;
270
+ justify-content: center;
271
+ background: var(--fb-tile-hover-overlay-color, rgba(0,0,0,0.25));
272
+ }
273
+ .fb-play-btn {
274
+ background: var(--fb-file-bg-color, rgba(255,255,255,0.9));
275
+ border-radius: 50%;
276
+ display: flex;
277
+ align-items: center;
278
+ justify-content: center;
279
+ }
280
+
281
+ /* Edit-mode local video preview wrapper */
282
+ .fb-video-preview-wrap {
283
+ position: relative;
284
+ width: 100%;
285
+ height: 100%;
286
+ }
287
+
288
+ /* Hover overlay for edit-mode local video (Remove / Change buttons) */
289
+ .fb-video-btn-overlay {
290
+ position: absolute;
291
+ top: 8px;
292
+ right: 8px;
293
+ z-index: 10;
294
+ display: flex;
295
+ gap: 4px;
296
+ opacity: 0;
297
+ transition: opacity var(--fb-transition-duration, 200ms);
298
+ pointer-events: none;
299
+ }
300
+ .fb-video-preview-wrap:hover .fb-video-btn-overlay {
301
+ opacity: 1;
302
+ pointer-events: auto;
303
+ }
304
+ .fb-video-btn {
305
+ border: none;
306
+ border-radius: var(--fb-border-radius, 4px);
307
+ font-size: 11px;
308
+ padding: 4px 8px;
309
+ cursor: pointer;
310
+ color: #fff;
311
+ line-height: 1.2;
312
+ }
313
+ .fb-video-btn-delete {
314
+ background: rgba(220, 38, 38, 0.85);
315
+ }
316
+ .fb-video-btn-delete:hover {
317
+ background: rgba(185, 28, 28, 0.95);
318
+ }
319
+ .fb-video-btn-change {
320
+ background: rgba(31, 41, 55, 0.85);
321
+ }
322
+ .fb-video-btn-change:hover {
323
+ background: rgba(17, 24, 39, 0.95);
324
+ }
325
+
326
+ /* Tile action icon buttons (download / open / remove) \u2014 shown on tile hover */
327
+ .fb-tile-actions {
328
+ position: absolute;
329
+ top: 3px;
330
+ right: 3px;
331
+ display: flex;
332
+ flex-direction: row;
333
+ gap: 3px;
334
+ opacity: 0;
335
+ transition: opacity var(--fb-transition-duration, 200ms);
336
+ z-index: 10;
337
+ }
338
+ .fb-tile-resource:hover .fb-tile-actions {
339
+ opacity: 1;
340
+ }
341
+ .fb-tile-action-btn {
342
+ width: 28px;
343
+ height: 28px;
344
+ display: flex;
345
+ align-items: center;
346
+ justify-content: center;
347
+ border: none;
348
+ border-radius: 50%;
349
+ cursor: pointer;
350
+ background: rgba(31, 41, 55, 0.75);
351
+ color: #fff;
352
+ padding: 0;
353
+ flex-shrink: 0;
354
+ transition:
355
+ background var(--fb-transition-duration, 200ms),
356
+ opacity var(--fb-transition-duration, 200ms);
357
+ }
358
+ .fb-tile-action-btn:hover {
359
+ background: rgba(17, 24, 39, 0.95);
360
+ }
361
+ .fb-tile-action-remove {
362
+ background: rgba(220, 38, 38, 0.8);
363
+ }
364
+ .fb-tile-action-remove:hover {
365
+ background: rgba(185, 28, 28, 0.95);
366
+ }
367
+
368
+ /* Actions row inside zoom popup \u2014 always visible while popup is shown */
369
+ .fb-tile-zoom-preview .fb-tile-actions {
370
+ position: absolute;
371
+ top: 6px;
372
+ right: 6px;
373
+ opacity: 1;
374
+ z-index: 10000;
375
+ }
376
+
377
+ /* Hover zoom preview popup for image tiles \u2014 appended to document.body (fixed) */
378
+ .fb-tile-zoom-preview {
379
+ position: fixed;
380
+ z-index: 9999;
381
+ background: var(--fb-background-color, #fff);
382
+ border: 1px solid var(--fb-file-upload-border-color, #d1d5db);
383
+ border-radius: var(--fb-border-radius, 0.5rem);
384
+ box-shadow: 0 4px 16px rgba(0,0,0,0.18);
385
+ padding: 4px;
386
+ width: 350px;
387
+ height: 350px;
388
+ pointer-events: none;
389
+ opacity: 0;
390
+ transition: opacity 150ms ease;
391
+ }
392
+ .fb-tile-zoom-preview.fb-tile-zoom-preview--visible {
393
+ opacity: 1;
394
+ }
395
+ .fb-tile-zoom-preview-img {
396
+ width: 100%;
397
+ height: 100%;
398
+ object-fit: contain;
399
+ display: block;
400
+ background: var(--fb-file-upload-bg-color, #f3f4f6);
401
+ border-radius: calc(var(--fb-border-radius, 0.5rem) - 2px);
402
+ }
403
+ `,document.head.appendChild(e)}const Ye="160px";function ft(){Je();const e=document.createElement("div");return e.className="fb-tile",e}function Xe(e,t){var n,o;const r=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");r&&r.remove();const l=document.createElement("div");l.className="file-error-message error-message",l.style.cssText=`
404
+ color: var(--fb-error-color);
405
+ font-size: var(--fb-font-size-small);
406
+ margin-top: 0.25rem;
407
+ `,l.textContent=t,(o=e.closest(".space-y-2"))==null||o.appendChild(l)}function mt(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function uo(e,t,n){const o=e.querySelector(".delete-overlay");o&&o.remove();const r=document.createElement("div");r.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 l=document.createElement("button");l.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",l.textContent=$("removeElement",t),l.onclick=i=>{i.stopPropagation(),n()},r.appendChild(l),e.appendChild(r)}function po(e){var t;let n=e.parentElement;for(;n&&!n.dataset.filesWrapper;)n=n.parentElement;return(t=n==null?void 0:n.querySelector('input[type="file"]'))!=null?t:null}function fo(e,t){Je();const n=ft();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const o=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
408
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
409
+ <div class="fb-spinner"></div>
410
+ <div class="fb-tile-label">${re(o)}</div>
411
+ <div class="fb-tile-uploading-text">${re($("uploadingFile",t))}</div>
412
+ </div>`,n}function mo(e){const t=e.querySelector(".fb-tiles-wrap");if(t)return t;const n=e.querySelector(".fb-file-dropzone");n&&n.remove();const o=document.createElement("div");o.className="fb-tiles-wrap",o.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const r=document.createElement("div");return r.className="fb-tile fb-tile-add",r.innerHTML="+",o.appendChild(r),e.appendChild(o),o}function Ge(e,t,n){const o=n?`<div class="text-xs text-gray-500 mt-1">${re(n)}</div>`:"";e.innerHTML=`
413
+ <div class="flex flex-col items-center justify-center h-full text-gray-400">
414
+ <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
415
+ <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"/>
416
+ </svg>
417
+ <div class="text-sm text-center">${re($("clickDragText",t))}</div>
418
+ ${o}
419
+ </div>
420
+ `}function Ze(e,t){e.addEventListener("dragover",n=>{n.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")}),e.addEventListener("dragleave",n=>{n.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")}),e.addEventListener("drop",n=>{var o;n.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50"),(o=n.dataTransfer)!=null&&o.files&&t(n.dataTransfer.files)})}const ho='<svg width="20" height="20" 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>',vo='<svg width="20" height="20" 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>',bo='<svg width="20" height="20" 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>';function go(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function yo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Dt(e){const{canRemove:t,removeHandler:n,state:o,resourceId:r,fileName:l,meta:i}=e,a=document.createElement("div");a.className="fb-tile-actions";const s=(c,d,u)=>{const p=document.createElement("button");return p.type="button",p.className=`fb-tile-action-btn ${u}`,p.innerHTML=c,p.title=d,p.setAttribute("aria-label",d),p.addEventListener("click",f=>{f.stopPropagation()}),p};if(go(o,i)){const c=s(ho,$("downloadFile",o),"fb-tile-action-download");c.addEventListener("click",()=>{xo(r,l,o,i)}),a.appendChild(c)}if(yo(o,i)){const c=s(vo,$("openInNewTab",o),"fb-tile-action-open");c.addEventListener("click",()=>{Eo(r,o,i).catch(d=>{console.error("Open failed:",d)})}),a.appendChild(c)}if(t&&n){const c=s(bo,$("removeElement",o),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),a.appendChild(c)}return a}const Qe=new WeakMap;function jt(e){let t=Qe.get(e);return t||(t=URL.createObjectURL(e),Qe.set(e,t)),t}function ht(e){if(!e)return;const t=Qe.get(e);t&&(URL.revokeObjectURL(t),Qe.delete(e))}function xo(e,t,n,o){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((o==null?void 0:o.file)instanceof File){Jt(o.file,t||o.file.name);return}_t(e,t,n).catch(r=>{console.error("Download failed:",r)})}async function Eo(e,t,n){let o=null;t.config.getDownloadUrl?o=t.config.getDownloadUrl(e):t.config.getThumbnail?o=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(o=jt(n.file)),o&&window.open(o,"_blank")}let be=null,we=null,Se=null,et=null;function Co(){if(!be){be=document.createElement("div"),be.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",be.appendChild(e),be.addEventListener("mouseenter",Ut),be.addEventListener("mouseleave",Ot)}return be}function wo(e,t){const n=t.getBoundingClientRect(),o=350,r=6,l=8;let i;n.top-o-r>=l?i=n.top-o-r:n.bottom+r+o+l<=window.innerHeight?i=n.bottom+r:i=Math.max(l,Math.min(window.innerHeight-o-l,n.top));let a=n.left+n.width/2-o/2;a=Math.max(l,Math.min(window.innerWidth-o-l,a)),e.style.top=`${i}px`,e.style.left=`${a}px`}function Ot(){Se!==null&&clearTimeout(Se),Se=setTimeout(()=>{Se=null,Pt()},100)}function Ut(){Se!==null&&(clearTimeout(Se),Se=null)}function Pt(){we!==null&&(clearTimeout(we),we=null),be&&be.parentNode&&(be.classList.remove("fb-tile-zoom-preview--visible"),be.parentNode.removeChild(be)),et=null}function vt(e,t,n,o){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Ut(),et!==e&&Pt(),et=e,we=setTimeout(()=>{we=null;const r=Co(),l=r.querySelector(".fb-tile-actions");l&&l.remove();const i=r.querySelector(".fb-tile-zoom-preview-img");i.src=t,i.alt=n,o&&(r.appendChild(o.cloneNode(!0)),ko(r.querySelector(".fb-tile-actions"),o)),r.style.pointerEvents="auto",wo(r,e),document.body.appendChild(r),r.getBoundingClientRect(),r.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{we!==null?(clearTimeout(we),we=null,et=null):Ot()})}function ko(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((o,r)=>{const l=n[r];l&&o.addEventListener("click",i=>{i.stopPropagation(),l.click()})})}function $o(e,t,n,o){const r=document.createElement("img");r.className="w-full h-full object-contain",r.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",r.alt=n||$("previewAlt",o);const l=new FileReader;l.onload=i=>{var a;r.src=((a=i.target)==null?void 0:a.result)||""},l.readAsDataURL(t),e.appendChild(r)}function Lo(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function So(e,t,n,o,r,l){const i=URL.createObjectURL(t),a=Lo(e);return a.innerHTML=`
421
+ <div class="fb-video-preview-wrap">
422
+ <video class="w-full h-full object-contain" controls preload="auto" muted src="${i}">
423
+ ${re($("videoNotSupported",r))}
116
424
  </video>
117
- <div class="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity z-10 flex gap-1">
118
- <button class="bg-red-600 bg-opacity-75 hover:bg-opacity-90 text-white p-1 rounded text-xs delete-file-btn">
119
- ${J(k("removeElement",l))}
425
+ <div class="fb-video-btn-overlay">
426
+ <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
427
+ ${re($("removeElement",r))}
120
428
  </button>
121
- <button class="bg-gray-800 bg-opacity-75 hover:bg-opacity-90 text-white p-1 rounded text-xs change-file-btn">
122
- ${J(k("changeButton",l))}
429
+ <button class="fb-video-btn fb-video-btn-change change-file-btn">
430
+ ${re($("changeButton",r))}
123
431
  </button>
124
432
  </div>
125
433
  </div>
126
- `,jn(s,r,l,a),s}function jn(e,t,n,r){const l=e.querySelector(".change-file-btn");l&&(l.onclick=o=>{o.stopPropagation(),r!=null&&r.picker&&r.picker.click()});const a=e.querySelector(".delete-file-btn");a&&(a.onclick=o=>{o.stopPropagation(),On(e,t,n,r)})}function On(e,t,n,r){var l;n.resourceIndex.delete(t);const a=(l=e.parentElement)==null?void 0:l.querySelector('input[type="hidden"]');a&&(a.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),r!=null&&r.dragHandler&&lt(e,r.dragHandler),e.innerHTML=`
434
+ `,To(a,o,r,l),a}function To(e,t,n,o){const r=e.querySelector(".change-file-btn");r&&(r.onclick=i=>{var a;i.stopPropagation(),(a=o==null?void 0:o.picker)==null||a.click()});const l=e.querySelector(".delete-file-btn");l&&(l.onclick=i=>{i.stopPropagation(),Ao(e,t,n,o)})}function Ao(e,t,n,o){var r;n.resourceIndex.delete(t);const l=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');l&&(l.value=""),o!=null&&o.fileUploadHandler&&(e.onclick=o.fileUploadHandler),e.innerHTML=`
127
435
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
128
436
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
129
437
  <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"/>
130
438
  </svg>
131
- <div class="text-sm text-center">${J(k("clickDragText",n))}</div>
439
+ <div class="text-sm text-center">${re($("clickDragText",n))}</div>
132
440
  </div>
133
- `}function Un(e,t,n,r){const l=document.createElement("video");l.className="w-full h-full object-contain",l.controls=!0,l.preload="metadata",l.muted=!0,l.src=t,l.appendChild(document.createTextNode(k("videoNotSupported",r))),e.appendChild(l)}function Lt(e,t,n){_n(e,n,()=>{var r;n.resourceIndex.delete(t);const l=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');l&&(l.value=""),e.innerHTML=`
441
+ `,o!=null&&o.setupDrop&&o.setupDrop(e)}function Vt(e,t,n){uo(e,n,()=>{var o;n.resourceIndex.delete(t);const r=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');r&&(r.value=""),e.innerHTML=`
134
442
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
135
443
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
136
444
  <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"/>
137
445
  </svg>
138
- <div class="text-sm text-center">${J(k("clickDragText",n))}</div>
446
+ <div class="text-sm text-center">${re($("clickDragText",n))}</div>
139
447
  </div>
140
- `})}async function Pn(e,t,n,r,l,a,o){!t.file||!(t.file instanceof File)||(t.type&&t.type.startsWith("image/")?Rn(e,t.file,n,a):t.type&&t.type.startsWith("video/")?e=Dn(e,t.file,t.type,r,a,o):e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400"><div class="text-2xl mb-2">\u{1F4C1}</div><div class="text-sm">${J(n)}</div></div>`,!l&&!(t.type&&t.type.startsWith("video/"))&&Lt(e,r,a))}async function Vn(e,t,n,r,l){if(!l.config.getThumbnail){ot(e,l);return}try{const a=await l.config.getThumbnail(t);if(a)if(pe(e),r&&r.type&&r.type.startsWith("video/"))Un(e,a,r.type,l);else{const o=document.createElement("img");o.className="w-full h-full object-contain",o.alt=n||k("previewAlt",l),o.src=a,e.appendChild(o)}else ot(e,l)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
448
+ `})}async function Fo(e,t,n,o,r,l,i){var a,s,c;!t.file||!(t.file instanceof File)||((a=t.type)!=null&&a.startsWith("image/")?$o(e,t.file,n,l):(s=t.type)!=null&&s.startsWith("video/")?e=So(e,t.file,t.type,o,l,i):e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400"><div style="font-size:36px;" class="mb-2">\u{1F4C1}</div><div class="text-sm">${re(n)}</div></div>`,!r&&!((c=t.type)!=null&&c.startsWith("video/"))&&Vt(e,o,l))}function No(e,t,n){const o=document.createElement("video");o.className="w-full h-full object-contain",o.controls=!0,o.preload="metadata",o.muted=!0,o.src=t,o.appendChild(document.createTextNode($("videoNotSupported",n))),e.appendChild(o)}async function zo(e,t,n,o,r){var l;if(!r.config.getThumbnail){Ge(e,r);return}try{const i=await r.config.getThumbnail(t);if(i)if(ve(e),(l=o==null?void 0:o.type)!=null&&l.startsWith("video/"))No(e,i,r);else{const a=document.createElement("img");a.className="w-full h-full object-contain",a.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",a.alt=n||$("previewAlt",r),a.src=i,e.appendChild(a)}else Ge(e,r)}catch(i){console.error("Failed to get thumbnail:",i),e.innerHTML=`
141
449
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
142
450
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
143
451
  <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"/>
144
452
  </svg>
145
- <div class="text-sm text-center">${J(n||k("previewUnavailable",l))}</div>
453
+ <div class="text-sm text-center">${re(n||$("previewUnavailable",r))}</div>
146
454
  </div>
147
- `}}async function St(e,t,n,r={}){var l;const{fileName:a="",isReadonly:o=!1,deps:s=null}=r;if(!o&&s&&(!s.picker||!s.fileUploadHandler||!s.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");pe(e),o&&e.classList.add("cursor-pointer");const i=n.resourceIndex.get(t);if(i&&i.file&&i.file instanceof File)await Pn(e,i,a,t,o,n,s);else{await Vn(e,t,a,i,n);const u=(l=i==null?void 0:i.type)==null?void 0:l.startsWith("video/");!o&&!u&&Lt(e,t,n)}}async function nt(e,t,n){var r,l;const a=t.resourceIndex.get(e),o=(a==null?void 0:a.name)||e.split("/").pop()||"file",s=o.toLowerCase().match(/\.psd$/),i=document.createElement("div");i.className=s?"space-y-2":"space-y-3";const u=document.createElement("div");s?u.className="bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity flex items-center p-3 max-w-sm":u.className="bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity";const f=!s&&(((r=a==null?void 0:a.type)==null?void 0:r.startsWith("image/"))||o.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)),c=((l=a==null?void 0:a.type)==null?void 0:l.startsWith("video/"))||o.toLowerCase().match(/\.(mp4|webm|avi|mov)$/);if(f)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?u.innerHTML=`<img src="${h}" alt="${J(o)}" class="w-full h-auto">`:u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F5BC}\uFE0F</div><div class="text-sm">${J(o)}</div></div></div>`}catch(h){console.warn("getThumbnail failed for",e,h),u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F5BC}\uFE0F</div><div class="text-sm">${J(o)}</div></div></div>`}else u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F5BC}\uFE0F</div><div class="text-sm">${J(o)}</div></div></div>`;else if(c)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?u.innerHTML=`
148
- <div class="relative group">
149
- <video class="w-full h-auto" controls preload="auto" muted src="${h}">
150
- ${J(k("videoNotSupported",t))}
151
- </video>
152
- <div class="absolute inset-0 bg-black bg-opacity-20 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none">
153
- <div class="bg-white bg-opacity-90 rounded-full p-3">
154
- <svg class="w-8 h-8 text-gray-800" fill="currentColor" viewBox="0 0 24 24">
155
- <path d="M8 5v14l11-7z"/>
156
- </svg>
157
- </div>
455
+ `}}async function Wt(e,t,n,o={}){var r;const{fileName:l="",isReadonly:i=!1,deps:a=null}=o;if(!i&&a&&(!a.picker||!a.fileUploadHandler||!a.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ve(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await Fo(e,s,l,t,i,n,a);else{await zo(e,t,l,s,n);const c=(r=s==null?void 0:s.type)==null?void 0:r.startsWith("video/");!i&&!c&&Vt(e,t,n)}}function Mo(e,t,n){var o;if(n)return n;if((o=t==null?void 0:t.name)!=null&&o.includes("."))return t.name;const r=e.includes("/")?e.split("/").pop():e;return r!=null&&r.includes(".")?r:""}async function bt(e,t,n,o={}){var r,l;const i=t.resourceIndex.get(e),a=Mo(e,i,n),{canRemove:s=!1,removeHandler:c=null}=o,d=((r=i==null?void 0:i.type)==null?void 0:r.startsWith("image/"))||!!a.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((l=i==null?void 0:i.type)==null?void 0:l.startsWith("video/"))||!!a.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),p=ft();p.classList.add("fb-tile-resource"),p.style.cursor="pointer",a&&(p.title=a);const f=(i==null?void 0:i.file)instanceof File?jt(i.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):f;p.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,a):_t(e,a,t).catch(g=>{console.error("Download failed:",g)})};const b=Dt({canRemove:s,removeHandler:c,state:t,resourceId:e,fileName:a,meta:i}),v=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return f},w=()=>{p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',p.appendChild(b)};if(d){const h=await v();if(h){const g=document.createElement("img");g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=a,g.src=h,p.appendChild(g),p.appendChild(b),vt(p,h,a,b)}else w()}else if(u)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(p.innerHTML=`
456
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(a)}" src="${h}">
457
+ <div class="fb-video-overlay">
458
+ <div class="fb-play-btn" style="width:22px;height:22px;">
459
+ <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
158
460
  </div>
159
- </div>
160
- `:u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F3A5}</div><div class="text-sm">${J(o)}</div></div></div>`}catch(h){console.warn("getThumbnail failed for video",e,h),u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F3A5}</div><div class="text-sm">${J(o)}</div></div></div>`}else u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">\u{1F3A5}</div><div class="text-sm">${J(o)}</div></div></div>`;else{const h=s?"\u{1F3A8}":"\u{1F4C1}",v=s?"PSD File":"Document";s?u.innerHTML=`
161
- <div class="flex items-center space-x-3">
162
- <div class="text-3xl text-gray-400">${h}</div>
163
- <div class="flex-1 min-w-0">
164
- <div class="text-sm font-medium text-gray-900 truncate">${J(o)}</div>
165
- <div class="text-xs text-gray-500">${v}</div>
461
+ </div>`,p.appendChild(b)):(p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(b))}catch(h){p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(b)}else p.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',p.appendChild(b);else{if(t.config.getThumbnail)try{const g=await t.config.getThumbnail(e);if(g){const y=document.createElement("img");return y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=a||e,y.src=g,p.appendChild(y),p.appendChild(b),p}}catch(g){}const h=a?`<div class="fb-tile-label">${re(a.length>10?a.substring(0,8)+"\u2026":a)}</div>
462
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zm-7 9H5v2h14v-2h-7z"/></svg>`:"";p.innerHTML=`
463
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
464
+ <div style="font-size:36px;">\u{1F4C1}</div>
465
+ ${h}
466
+ </div>`,p.appendChild(b)}return p}async function Kt(e,t,n,o){var r,l,i;const a=n.resourceIndex.get(t),s=(l=(r=a==null?void 0:a.name)!=null?r:t.split("/").pop())!=null?l:"",c=(i=o.onRemove)!=null?i:null,d=await bt(t,n,s,{canRemove:!0,removeHandler:c});e.className="file-preview-container",e.removeAttribute("style"),ve(e),e.appendChild(d)}async function qo(e,t,n,o,r){var l,i,a;if((l=n==null?void 0:n.type)!=null&&l.startsWith("image/")){if(n.file&&n.file instanceof File){const s=document.createElement("img");s.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",s.alt=n.name;const c=new FileReader;c.onload=d=>{var u;s.src=((u=d.target)==null?void 0:u.result)||"",vt(e,s.src,n.name,r!=null?r:null)},c.readAsDataURL(n.file),e.appendChild(s)}else if(o.config.getThumbnail)try{const s=await o.config.getThumbnail(t);if(s){const c=document.createElement("img");c.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",c.alt=n.name,c.src=s,e.appendChild(c),vt(e,s,n.name,r!=null?r:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(s){const c=s instanceof Error?s:new Error(String(s));o.config.onThumbnailError&&o.config.onThumbnailError(c,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>';r&&e.appendChild(r)}else if((i=n==null?void 0:n.type)!=null&&i.startsWith("video/")){if(n.file&&n.file instanceof File){const s=URL.createObjectURL(n.file);e.innerHTML=`
467
+ <video style="width:100%;height:100%;" preload="metadata" muted src="${s}"></video>
468
+ <div class="fb-video-overlay">
469
+ <div class="fb-play-btn" style="width:20px;height:20px;">
470
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
166
471
  </div>
167
- </div>
168
- `:u.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">${h}</div><div class="text-sm">${J(o)}</div><div class="text-xs text-gray-500 mt-1">${v}</div></div></div>`}const m=document.createElement("p");m.className=s?"hidden":"text-sm font-medium text-gray-900 text-center",m.textContent=o;const p=document.createElement("button");return p.className="w-full px-3 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",p.textContent=k("downloadButton",t),p.onclick=h=>{h.preventDefault(),h.stopPropagation(),t.config.downloadFile?t.config.downloadFile(e,o):Wn(e,o,t)},i.appendChild(u),i.appendChild(m),i.appendChild(p),i}function Tt(e,t,n,r,l,a){pe(e);const o=()=>{const m=[k("clickDragTextMultiple",n)];return l&&m.push(l),a&&m.push(a),m.join(" \u2022 ")},s=!e.classList.contains("grid");if((!t||t.length===0)&&s){const m=document.createElement("div");m.className="grid grid-cols-4 gap-3 mb-3";for(let h=0;h<4;h++){const v=document.createElement("div");v.className="aspect-square bg-gray-100 border-2 border-dashed border-gray-300 rounded flex items-center justify-center cursor-pointer hover:border-gray-400 transition-colors";const b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("class","w-12 h-12 text-gray-400"),b.setAttribute("fill","currentColor"),b.setAttribute("viewBox","0 0 24 24");const x=document.createElementNS("http://www.w3.org/2000/svg","path");x.setAttribute("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"),b.appendChild(x),v.appendChild(b),v.onclick=()=>{let d=e.parentElement;for(;d&&!d.classList.contains("space-y-2");)d=d.parentElement;!d&&e.classList.contains("space-y-2")&&(d=e);const y=d==null?void 0:d.querySelector('input[type="file"]');y&&y.click()},m.appendChild(v)}const p=document.createElement("div");p.className="text-center text-xs text-gray-500 mt-2",p.textContent=o(),e.appendChild(m),e.appendChild(p);return}const i=document.createElement("div");i.className="files-list grid grid-cols-4 gap-3";const u=t?t.length:0,f=(Math.floor(u/4)+1)*4;for(let m=0;m<f;m++){const p=document.createElement("div");if(t&&m<t.length){const h=t[m],v=n.resourceIndex.get(h);if(p.className="resource-pill aspect-square bg-gray-100 rounded-lg overflow-hidden relative group border border-gray-300",p.dataset.resourceId=h,Kn(p,h,v,n).catch(b=>{console.error("Failed to render thumbnail:",b),p.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
169
- <div class="text-2xl mb-1">\u{1F4C1}</div>
170
- <div class="text-xs">${J(k("previewError",n))}</div>
171
- </div>`}),r){const b=document.createElement("div");b.className="absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const x=document.createElement("button");x.className="bg-red-600 text-white px-2 py-1 rounded text-xs",x.textContent=k("removeElement",n),x.onclick=d=>{d.stopPropagation(),r(h)},b.appendChild(x),p.appendChild(b)}}else p.className="aspect-square bg-gray-100 border-2 border-dashed border-gray-300 rounded-lg flex items-center justify-center cursor-pointer hover:border-gray-400 transition-colors",p.innerHTML='<svg class="w-12 h-12 text-gray-400" fill="currentColor" viewBox="0 0 24 24"><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"/></svg>',p.onclick=()=>{let h=e.parentElement;for(;h&&!h.classList.contains("space-y-2");)h=h.parentElement;!h&&e.classList.contains("space-y-2")&&(h=e);const v=h==null?void 0:h.querySelector('input[type="file"]');v&&v.click()};i.appendChild(p)}e.appendChild(i);const c=document.createElement("div");c.className="text-center text-xs text-gray-500 mt-2",c.textContent=o(),e.appendChild(c)}function At(e,t,n="w-12 h-12"){e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
172
- <svg class="${J(n)} text-red-400" fill="currentColor" viewBox="0 0 24 24">
173
- <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-2h2v2zm0-4h-2V7h2v6z"/>
174
- </svg>
175
- <div class="text-xs mt-1 text-red-600">${J(k("previewError",t))}</div>
176
- </div>`}async function Kn(e,t,n,r){var l,a;if(n&&(l=n.type)!=null&&l.startsWith("image/"))if(n.file&&n.file instanceof File){const o=document.createElement("img");o.className="w-full h-full object-contain",o.alt=n.name;const s=new FileReader;s.onload=i=>{var u;o.src=((u=i.target)==null?void 0:u.result)||""},s.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail)try{const o=await r.config.getThumbnail(t);if(o){const s=document.createElement("img");s.className="w-full h-full object-contain",s.alt=n.name,s.src=o,e.appendChild(s)}else e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
177
- <svg class="w-12 h-12" fill="currentColor" viewBox="0 0 24 24">
178
- <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"/>
179
- </svg>
180
- </div>`}catch(o){const s=o instanceof Error?o:new Error(String(o));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),At(e,r)}else e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
181
- <svg class="w-12 h-12" fill="currentColor" viewBox="0 0 24 24">
182
- <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"/>
183
- </svg>
184
- </div>`;else if(n&&(a=n.type)!=null&&a.startsWith("video/"))if(n.file&&n.file instanceof File){const o=URL.createObjectURL(n.file);e.innerHTML=`
185
- <div class="relative group h-full w-full">
186
- <video class="w-full h-full object-contain" preload="metadata" muted src="${o}">
187
- </video>
188
- <div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
189
- <div class="bg-white bg-opacity-90 rounded-full p-1">
190
- <svg class="w-4 h-4 text-gray-800" fill="currentColor" viewBox="0 0 24 24">
191
- <path d="M8 5v14l11-7z"/>
192
- </svg>
193
- </div>
194
- </div>
195
- </div>
196
- `}else if(r.config.getThumbnail)try{const o=await r.config.getThumbnail(t);o?e.innerHTML=`
197
- <div class="relative group h-full w-full">
198
- <video class="w-full h-full object-contain" preload="metadata" muted src="${o}">
199
- </video>
200
- <div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center">
201
- <div class="bg-white bg-opacity-90 rounded-full p-1">
202
- <svg class="w-4 h-4 text-gray-800" fill="currentColor" viewBox="0 0 24 24">
203
- <path d="M8 5v14l11-7z"/>
204
- </svg>
205
- </div>
472
+ </div>`}else if(o.config.getThumbnail)try{const s=await o.config.getThumbnail(t);s?e.innerHTML=`
473
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(n.name)}" src="${s}">
474
+ <div class="fb-video-overlay">
475
+ <div class="fb-play-btn" style="width:20px;height:20px;">
476
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
206
477
  </div>
207
- </div>
208
- `:e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
209
- <svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24">
210
- <path d="M8 5v14l11-7z"/>
211
- </svg>
212
- <div class="text-xs mt-1">${J((n==null?void 0:n.name)||"Video")}</div>
213
- </div>`}catch(o){const s=o instanceof Error?o:new Error(String(o));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),At(e,r,"w-8 h-8")}else e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
214
- <svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24">
215
- <path d="M8 5v14l11-7z"/>
478
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(s){const c=s instanceof Error?s:new Error(String(s));o.config.onThumbnailError&&o.config.onThumbnailError(c,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>';r&&e.appendChild(r)}else{const s=(a=n==null?void 0:n.name)!=null?a:"",c=s.includes(".")?`<div class="fb-tile-label">${re(s.length>10?s.substring(0,8)+"\u2026":s)}</div>`:"";e.innerHTML=`
479
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
480
+ <div style="font-size:36px;">\u{1F4C1}</div>
481
+ ${c}
482
+ </div>`,r&&e.appendChild(r)}}async function _t(e,t,n){try{let o=null;if(n.config.getDownloadUrl?o=n.config.getDownloadUrl(e):n.config.getThumbnail&&(o=await n.config.getThumbnail(e)),o){const r=o.startsWith("http")?o:new URL(o,window.location.href).href,l=await fetch(r);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const i=await l.blob();Jt(i,t)}else throw new Error("No download URL available for resource")}catch(o){const r=o instanceof Error?o:new Error(String(o));throw n.config.onDownloadError&&n.config.onDownloadError(r,e,t),console.error(`File download failed for ${t}:`,r),r}}function Jt(e,t){try{const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`)}}async function Yt(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 o=n instanceof Error?n:new Error(String(n));throw t.config.onUploadError&&t.config.onUploadError(o,e),new Error(`File upload failed: ${o.message}`)}}async function Xt(e,t,n,o,r=null,l,i=[],a=1/0){var s,c;if(!Be(e.name,i)){const p=i.join(", ");Xe(t,$("invalidFileExtension",o,{name:e.name,formats:p}));return}if(!Ke(e,a)){Xe(t,$("fileTooLarge",o,{name:e.name,maxSize:a}));return}mt(t),Je(),t.innerHTML=`
483
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
484
+ <div class="fb-spinner"></div>
485
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${re($("uploadingFile",o))}</div>
486
+ </div>`;let d;try{d=await Yt(e,o)}catch(p){throw Ge(t,o),p}o.resourceIndex.set(d,{name:e.name,type:e.type,size:e.size,uploadedAt:new Date,file:e});let u=(s=t.parentElement)==null?void 0:s.querySelector('input[type="hidden"]');u||(u=document.createElement("input"),u.type="hidden",u.name=n,(c=t.parentElement)==null||c.appendChild(u)),u.value=d,!e.type.startsWith("video/")&&r?Kt(t,d,o,r).catch(console.error):Wt(t,d,o,{fileName:e.name,isReadonly:!1,deps:r}).catch(console.error),l&&!o.config.readonly&&l.triggerOnChange(n,d)}function Gt(e,t,n,o){const r=e.filter(p=>!Be(p.name,n.allowedExtensions)),l=e.filter(p=>Be(p.name,n.allowedExtensions)),i=l.filter(p=>!Ke(p,n.maxSize)),a=l.filter(p=>Ke(p,n.maxSize)),s=n.maxCount===1/0?a.length:Math.max(0,n.maxCount-t),c=a.slice(0,s),d=a.length-c.length,u=[];if(r.length>0){const p=n.allowedExtensions.join(", "),f=r.map(m=>m.name).join(", ");u.push($("invalidFileExtension",o,{name:f,formats:p}))}if(i.length>0){const p=i.map(f=>f.name).join(", ");u.push($("fileTooLarge",o,{name:p,maxSize:n.maxSize}))}return d>0&&u.push($("filesLimitExceeded",o,{skipped:d,max:n.maxCount})),{accepted:c,errorMessage:u.join(" \u2022 ")}}async function Zt(e,t,n,o){await Promise.all(e.map(async r=>{const l=fo(r.name,o);if(n){const i=mo(n),a=i.querySelector(".fb-tile-add");a?i.insertBefore(l,a):i.appendChild(l)}try{const i=await Yt(r,o);o.resourceIndex.set(i,{name:r.name,type:r.type,size:r.size,uploadedAt:new Date,file:void 0}),t.push(i)}finally{l.remove()}}))}function Qt(e,t,n,o,r,l,i){Ze(e,async a=>{var s;const{accepted:c,errorMessage:d}=Gt(Array.from(a),t.length,r,n);d?Xe(e,d):mt(e);const u=(s=e.querySelector(".files-list"))!=null?s:e;await Zt(c,t,u,n),o(),i&&l&&!n.config.readonly&&i.triggerOnChange(l,t)})}function en(e,t,n,o,r,l,i){e.onchange=async()=>{if(!e.files)return;const a=e.closest(".space-y-2")||e.parentElement,{accepted:s,errorMessage:c}=Gt(Array.from(e.files),t.length,r,n);c&&a?Xe(a,c):a&&mt(a);const d=a==null?void 0:a.querySelector(".files-list");await Zt(s,t,d!=null?d:null,n),o(),e.value="",i&&l&&!n.config.readonly&&i.triggerOnChange(l,t)}}function Ro(e,t,n,o,r,l){var i,a;if(!r.resourceIndex.has(e)){const d=e.split("/").pop()||"file",u=(i=d.split(".").pop())==null?void 0:i.toLowerCase();let p="application/octet-stream";u&&(["jpg","jpeg","png","gif","webp"].includes(u)?p=`image/${u==="jpg"?"jpeg":u}`:["mp4","webm","mov","avi"].includes(u)&&(p=`video/${u==="mov"?"quicktime":u}`)),r.resourceIndex.set(e,{name:d,type:p,size:0,uploadedAt:new Date,file:void 0})}const s=r.resourceIndex.get(e);(a=s==null?void 0:s.type)!=null&&a.startsWith("video/")?Wt(t,e,r,{fileName:e,isReadonly:!1,deps:l}).catch(console.error):Kt(t,e,r,l).catch(console.error);const c=document.createElement("input");c.type="hidden",c.name=n,c.value=e,o.appendChild(c)}function tn(e,t,n,o,r,l,i,a=!1){var s;Je();const c=e.closest("[data-files-wrapper]");for(c&&(c.dataset.resourceIds=JSON.stringify(t!=null?t:[]));e.firstChild;)e.removeChild(e.firstChild);const d=t!=null?t:[],u=i!==void 0&&d.length>=i,p=()=>{const v=[];return r&&v.push(r),l&&v.push(l),v.join(" \u2022 ")},f=()=>{const v=po(e);v&&v.click()};if(d.length===0){if(a){const v=document.createElement("div");v.className="fb-tile-empty-text",v.textContent=$("noFilesSelected",n),e.appendChild(v)}else{const v=document.createElement("div");v.className="fb-file-dropzone";const w=p();v.innerHTML=`
487
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" style="flex-shrink:0;color:var(--fb-file-upload-text-color,#9ca3af);">
488
+ <path d="M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"/>
216
489
  </svg>
217
- <div class="text-xs mt-1">${J((n==null?void 0:n.name)||"Video")}</div>
218
- </div>`;else e.innerHTML=`<div class="flex flex-col items-center justify-center h-full text-gray-400">
219
- <div class="text-2xl mb-1">\u{1F4C1}</div>
220
- <div class="text-xs">${J((n==null?void 0:n.name)||"File")}</div>
221
- </div>`}function ot(e,t,n){const r=n?`<div class="text-xs text-gray-500 mt-1">${J(n)}</div>`:"";e.innerHTML=`
222
- <div class="flex flex-col items-center justify-center h-full text-gray-400">
223
- <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
224
- <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"/>
225
- </svg>
226
- <div class="text-sm text-center">${J(k("clickDragText",t))}</div>
227
- ${r}
228
- </div>
229
- `}function Pe(e,t){var n,r;const l=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");l&&l.remove();const a=document.createElement("div");a.className="file-error-message error-message",a.style.cssText=`
230
- color: var(--fb-error-color);
231
- font-size: var(--fb-font-size-small);
232
- margin-top: 0.25rem;
233
- `,a.textContent=t,(r=e.closest(".space-y-2"))==null||r.appendChild(a)}function rt(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}async function Ft(e,t,n,r,l=null,a,o=[],s=1/0){var i,u;if(!we(e.name,o)){const m=o.join(", ");Pe(t,k("invalidFileExtension",r,{name:e.name,formats:m}));return}if(!Le(e,s)){Pe(t,k("fileTooLarge",r,{name:e.name,maxSize:s}));return}rt(t);let f;if(r.config.uploadFile)try{if(f=await r.config.uploadFile(e),typeof f!="string")throw new Error("Upload handler must return a string resource ID")}catch(m){const p=m instanceof Error?m:new Error(String(m));throw r.config.onUploadError&&r.config.onUploadError(p,e),new Error(`File upload failed: ${p.message}`)}else throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");r.resourceIndex.set(f,{name:e.name,type:e.type,size:e.size,uploadedAt:new Date,file:e});let c=(i=t.parentElement)==null?void 0:i.querySelector('input[type="hidden"]');c||(c=document.createElement("input"),c.type="hidden",c.name=n,(u=t.parentElement)==null||u.appendChild(c)),c.value=f,St(t,f,r,{fileName:e.name,isReadonly:!1,deps:l}).catch(console.error),a&&!r.config.readonly&&a.triggerOnChange(n,f)}function lt(e,t){e.addEventListener("dragover",n=>{n.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")}),e.addEventListener("dragleave",n=>{n.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")}),e.addEventListener("drop",n=>{var r;n.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50"),(r=n.dataTransfer)!=null&&r.files&&t(n.dataTransfer.files)})}function _n(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const l=document.createElement("div");l.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 a=document.createElement("button");a.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",a.textContent=k("removeElement",t),a.onclick=o=>{o.stopPropagation(),n()},l.appendChild(a),e.appendChild(l)}async function Nt(e,t){if(t.config.uploadFile)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));throw t.config.onUploadError&&t.config.onUploadError(r,e),new Error(`File upload failed: ${r.message}`)}else throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()")}async function Wn(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 l=r.startsWith("http")?r:new URL(r,window.location.href).href,a=await fetch(l);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const o=await a.blob();Jn(o,t)}else throw new Error("No download URL available for resource")}catch(r){const l=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(l,e,t),console.error(`File download failed for ${t}:`,l),l}}function Jn(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}`)}}function Mt(e,t){e.length>0&&e.forEach(n=>{var r;if(!t.resourceIndex.has(n)){const l=n.split("/").pop()||"file",a=(r=l.split(".").pop())==null?void 0:r.toLowerCase();let o="application/octet-stream";a&&(["jpg","jpeg","png","gif","webp"].includes(a)?o=`image/${a==="jpg"?"jpeg":a}`:["mp4","webm","mov","avi"].includes(a)&&(o=`video/${a==="mov"?"quicktime":a}`)),t.resourceIndex.set(n,{name:l,type:o,size:0,uploadedAt:new Date,file:void 0})}})}function Yn(e,t,n,r,l,a){var o;if(!l.resourceIndex.has(e)){const i=e.split("/").pop()||"file",u=(o=i.split(".").pop())==null?void 0:o.toLowerCase();let f="application/octet-stream";u&&(["jpg","jpeg","png","gif","webp"].includes(u)?f=`image/${u==="jpg"?"jpeg":u}`:["mp4","webm","mov","avi"].includes(u)&&(f=`video/${u==="mov"?"quicktime":u}`)),l.resourceIndex.set(e,{name:i,type:f,size:0,uploadedAt:new Date,file:void 0})}St(t,e,l,{fileName:e,isReadonly:!1,deps:a}).catch(console.error);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function qt(e,t,n,r,l,a,o){lt(e,async s=>{const i=Array.from(s),u=i.filter(x=>!we(x.name,l.allowedExtensions)),f=i.filter(x=>we(x.name,l.allowedExtensions)),c=f.filter(x=>!Le(x,l.maxSize)),m=f.filter(x=>Le(x,l.maxSize)),p=l.maxCount===1/0?m.length:Math.max(0,l.maxCount-t.length),h=m.slice(0,p),v=m.length-h.length,b=[];if(u.length>0){const x=l.allowedExtensions.join(", "),d=u.map(y=>y.name).join(", ");b.push(k("invalidFileExtension",n,{name:d,formats:x}))}if(c.length>0){const x=c.map(d=>d.name).join(", ");b.push(k("fileTooLarge",n,{name:x,maxSize:l.maxSize}))}v>0&&b.push(k("filesLimitExceeded",n,{skipped:v,max:l.maxCount})),b.length>0?Pe(e,b.join(" \u2022 ")):rt(e);for(const x of h){const d=await Nt(x,n);n.resourceIndex.set(d,{name:x.name,type:x.type,size:x.size,uploadedAt:new Date,file:void 0}),t.push(d)}r(),o&&a&&!n.config.readonly&&o.triggerOnChange(a,t)})}function zt(e,t,n,r,l,a,o){e.onchange=async()=>{if(e.files){const s=Array.from(e.files),i=s.filter(x=>!we(x.name,l.allowedExtensions)),u=s.filter(x=>we(x.name,l.allowedExtensions)),f=u.filter(x=>!Le(x,l.maxSize)),c=u.filter(x=>Le(x,l.maxSize)),m=l.maxCount===1/0?c.length:Math.max(0,l.maxCount-t.length),p=c.slice(0,m),h=c.length-p.length,v=[];if(i.length>0){const x=l.allowedExtensions.join(", "),d=i.map(y=>y.name).join(", ");v.push(k("invalidFileExtension",n,{name:d,formats:x}))}if(f.length>0){const x=f.map(d=>d.name).join(", ");v.push(k("fileTooLarge",n,{name:x,maxSize:l.maxSize}))}h>0&&v.push(k("filesLimitExceeded",n,{skipped:h,max:l.maxCount}));const b=e.closest(".space-y-2")||e.parentElement;v.length>0&&b?Pe(b,v.join(" \u2022 ")):b&&rt(b);for(const x of p){const d=await Nt(x,n);n.resourceIndex.set(d,{name:x.name,type:x.type,size:x.size,uploadedAt:new Date,file:void 0}),t.push(d)}}r(),e.value="",o&&a&&!n.config.readonly&&o.triggerOnChange(a,t)}}function Xn(e,t,n,r){var l,a;const o=t.state;if(o.config.readonly){const s=t.prefill[e.key];if(s)nt(s,o).then(i=>{n.appendChild(i)}).catch(i=>{console.error("Failed to render file preview:",i);const u=document.createElement("div");u.className="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500",u.innerHTML=`<div class="text-center">${J(k("previewUnavailable",o))}</div>`,n.appendChild(u)});else{const i=document.createElement("div");i.className="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500",i.innerHTML=`<div class="text-center">${J(k("noFileSelected",o))}</div>`,n.appendChild(i)}}else{const s=document.createElement("div");s.className="space-y-2";const i=document.createElement("input");i.type="file",i.name=r,i.style.display="none",e.accept&&(i.accept=typeof e.accept=="string"?e.accept:((l=e.accept.extensions)==null?void 0:l.map(v=>`.${v}`).join(","))||"");const u=document.createElement("div");u.className="file-preview-container w-full aspect-square max-w-xs bg-gray-100 rounded-lg overflow-hidden relative group cursor-pointer";const f=t.prefill[e.key],c=He(e.accept),m=(a=e.maxSize)!=null?a:1/0,p=()=>i.click(),h=v=>{if(v.length>0){const b={picker:i,fileUploadHandler:p,dragHandler:h};Ft(v[0],u,r,o,b,t.instance,c,m)}};if(f)Yn(f,u,r,s,o,{picker:i,fileUploadHandler:p,dragHandler:h});else{const v=ve(e,o);ot(u,o,v)}u.onclick=p,lt(u,h),i.onchange=()=>{if(i.files&&i.files.length>0){const v={picker:i,fileUploadHandler:p,dragHandler:h};Ft(i.files[0],u,r,o,v,t.instance,c,m)}},s.appendChild(u),s.appendChild(i),n.appendChild(s)}}function Gn(e,t,n,r){var l,a;const o=t.state;if(o.config.readonly){const s=document.createElement("div");s.className="space-y-4";const i=t.prefill[e.key]||[];i.length>0?i.forEach(u=>{nt(u,o).then(f=>{s.appendChild(f)}).catch(f=>{console.error("Failed to render file preview:",f)})}):s.innerHTML=`<div class="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500"><div class="text-center">${J(k("noFilesSelected",o))}</div></div>`,n.appendChild(s)}else{let s=function(){Tt(c,m,o,v=>{const b=m.indexOf(v);b>-1&&m.splice(b,1),s()},p)};const i=document.createElement("div");i.className="space-y-2";const u=document.createElement("input");u.type="file",u.name=r,u.multiple=!0,u.style.display="none",e.accept&&(u.accept=typeof e.accept=="string"?e.accept:((l=e.accept.extensions)==null?void 0:l.map(v=>`.${v}`).join(","))||"");const f=document.createElement("div");f.className="border-2 border-dashed border-gray-300 rounded-lg p-3 hover:border-gray-400 transition-colors";const c=document.createElement("div");c.className="files-list";const m=t.prefill[e.key]||[];Mt(m,o);const p=ve(e,o),h={maxCount:1/0,allowedExtensions:He(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0};s(),qt(f,m,o,s,h,r,t.instance),zt(u,m,o,s,h,r,t.instance),f.appendChild(c),i.appendChild(f),i.appendChild(u),n.appendChild(i)}}function Zn(e,t,n,r){var l,a,o,s;const i=t.state,u=(l=e.minCount)!=null?l:0,f=(a=e.maxCount)!=null?a:1/0;if(i.config.readonly){const c=document.createElement("div");c.className="space-y-4";const m=t.prefill[e.key]||[];m.length>0?m.forEach(p=>{nt(p,i).then(h=>{c.appendChild(h)}).catch(h=>{console.error("Failed to render file preview:",h)})}):c.innerHTML=`<div class="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500"><div class="text-center">${J(k("noFilesSelected",i))}</div></div>`,n.appendChild(c)}else{const c=document.createElement("div");c.className="space-y-2";const m=document.createElement("input");m.type="file",m.name=r,m.multiple=!0,m.style.display="none",e.accept&&(m.accept=typeof e.accept=="string"?e.accept:((o=e.accept.extensions)==null?void 0:o.map(y=>`.${y}`).join(","))||"");const p=document.createElement("div");p.className="files-list space-y-2",c.appendChild(m),c.appendChild(p);const h=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];Mt(h,i);const v=ve(e,i),b={maxCount:f,allowedExtensions:He(e.accept),maxSize:(s=e.maxSize)!=null?s:1/0},x=()=>{const y=h.length===1?k("fileCountSingle",i,{count:h.length}):k("fileCountPlural",i,{count:h.length}),g=u>0||f<1/0?` ${k("fileCountRange",i,{min:u,max:f})}`:"";return y+g},d=()=>{Tt(p,h,i,y=>{h.splice(h.indexOf(y),1),d()},v,x())};qt(p,h,i,d,b,r,t.instance),zt(m,h,i,d,b,r,t.instance),d(),n.appendChild(c)}}function Ht(e,t,n){var r;const l=[],{scopeRoot:a,skipValidation:o,path:s}=n,i=e.type==="files"||"multiple"in e&&!!e.multiple,u=(m,p,h)=>{var v,b;if(o)return;const{state:x}=n,d="minCount"in h&&(v=h.minCount)!=null?v:0,y="maxCount"in h&&(b=h.maxCount)!=null?b:1/0;h.required&&p.length===0&&l.push(`${m}: ${k("required",x)}`),p.length<d&&l.push(`${m}: ${k("minFiles",x,{min:d})}`),p.length>y&&l.push(`${m}: ${k("maxFiles",x,{max:y})}`)},f=(m,p,h)=>{var v;if(o)return;const{state:b}=n,x="accept"in h?h.accept:void 0,d=He(x);if(d.length===0)return;const y=d.join(", ");for(const g of p){const E=b.resourceIndex.get(g),C=(v=E==null?void 0:E.name)!=null?v:g;we(C,d)||l.push(`${m}: ${k("invalidFileExtension",b,{name:C,formats:y})}`)}},c=(m,p,h)=>{var v;if(o)return;const{state:b}=n,x="maxSize"in h&&(v=h.maxSize)!=null?v:1/0;if(x!==1/0)for(const d of p){const y=b.resourceIndex.get(d);y&&y.size>x*1024*1024&&l.push(`${m}: ${k("fileTooLarge",b,{name:y.name,maxSize:x})}`)}};if(i){const m=ge(s,t),p=a.querySelector(`input[type="file"][name="${m}"]`),h=p==null?void 0:p.closest(".space-y-2"),v=(h==null?void 0:h.querySelector(".files-list"))||null,b=[];return v&&v.querySelectorAll(".resource-pill").forEach(x=>{const d=x.dataset.resourceId;d&&b.push(d)}),u(t,b,e),f(t,b,e),c(t,b,e),{value:b,errors:l}}else{const m=a.querySelector(`input[name$="${t}"][type="hidden"]`),p=(r=m==null?void 0:m.value)!=null?r:"";return!o&&e.required&&p===""?(l.push(`${t}: ${k("required",n.state)}`),{value:null,errors:l}):(!o&&p!==""&&(f(t,[p],e),c(t,[p],e)),{value:p||null,errors:l})}}function It(e,t,n,r){var l;const{scopeRoot:a,state:o}=r;if("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(s=>{var i;if(s&&typeof s=="string"&&!o.resourceIndex.has(s)){const u=s.split("/").pop()||"file",f=(i=u.split(".").pop())==null?void 0:i.toLowerCase();let c="application/octet-stream";f&&(["jpg","jpeg","png","gif","webp"].includes(f)?c=`image/${f==="jpg"?"jpeg":f}`:["mp4","webm","mov","avi"].includes(f)&&(c=`video/${f==="mov"?"quicktime":f}`)),o.resourceIndex.set(s,{name:u,type:c,size:0,uploadedAt:new Date,file:void 0})}}),console.info(`updateFileField: Multiple file field "${t}" updated. Preview update requires re-render.`)}else{const s=a.querySelector(`input[name="${t}"][type="hidden"]`);if(!s){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}if(s.value=n!=null?String(n):"",n&&typeof n=="string"){if(!o.resourceIndex.has(n)){const i=n.split("/").pop()||"file",u=(l=i.split(".").pop())==null?void 0:l.toLowerCase();let f="application/octet-stream";u&&(["jpg","jpeg","png","gif","webp"].includes(u)?f=`image/${u==="jpg"?"jpeg":u}`:["mp4","webm","mov","avi"].includes(u)&&(f=`video/${u==="mov"?"quicktime":u}`)),o.resourceIndex.set(n,{name:i,type:f,size:0,uploadedAt:new Date,file:void 0})}console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`)}}}function Se(e){return e?e.toUpperCase():"#000000"}function at(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Bt(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 Rt(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Se(e),r=document.createElement("div");r.style.cssText=`
490
+ <div class="fb-dropzone-primary-text">${re($("clickDragTextMultiple",n))}</div>
491
+ ${w?`<div class="fb-dropzone-hint-text">${re(w)}</div>`:""}
492
+ `,v.onclick=f,e.appendChild(v)}return}const m=document.createElement("div");m.className="fb-tiles-wrap",m.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";for(const v of d){const w=n.resourceIndex.get(v),h=ft();h.classList.add("fb-tile-resource","resource-pill"),h.dataset.resourceId=v;const g=Dt({canRemove:!a&&o!==null,removeHandler:o?()=>o(v):null,state:n,resourceId:v,fileName:(s=w==null?void 0:w.name)!=null?s:""});qo(h,v,w,n,g).catch(y=>{console.error("Failed to render tile:",y)}),m.appendChild(h)}if(!a&&!u){const v=document.createElement("div");v.className="fb-tile fb-tile-add",v.innerHTML="+",v.onclick=f,m.appendChild(v)}else if(!a&&u){const v=document.createElement("div");v.className="fb-tile-counter",v.textContent=$("filesCounter",n,{count:d.length,max:i}),m.appendChild(v)}e.appendChild(m);const b=p();if(b){const v=document.createElement("div");v.className="fb-tile-hint",v.textContent=b,e.appendChild(v)}}function Io(e,t,n,o){var r,l,i;const a=t.state,s=document.createElement("div");s.className="space-y-2";const c=document.createElement("input");c.type="file",c.name=o,c.style.display="none",e.accept&&(c.accept=typeof e.accept=="string"?e.accept:((r=e.accept.extensions)==null?void 0:r.map(v=>`.${v}`).join(","))||"");const d=document.createElement("div");d.className="file-preview-container";const u=t.prefill[e.key],p=He(e.accept),f=(l=e.maxSize)!=null?l:1/0,m={fileUploadHandler(){c.click()},dragHandler(v){v.length>0&&Xt(v[0],d,o,a,b(),t.instance,p,f)},setupDrop(v){Ze(v,m.dragHandler)},restoreDropzone(){const v=ye(e,a);d.className="file-preview-container w-full max-w-md bg-gray-100 rounded-lg overflow-hidden relative group cursor-pointer",d.style.height="128px",Ge(d,a,v),d.onclick=m.fileUploadHandler,Ze(d,m.dragHandler)},onRemove(){var v;const w=s.querySelector('input[type="hidden"]'),h=w==null?void 0:w.value;h&&ht((v=a.resourceIndex.get(h))==null?void 0:v.file),w&&(w.value=""),m.restoreDropzone()}},b=()=>({picker:c,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove});if(u){Ro(u,d,o,s,a,b());const v=a.resourceIndex.get(u);(i=v==null?void 0:v.type)!=null&&i.startsWith("video/")&&(d.onclick=m.fileUploadHandler,Ze(d,m.dragHandler))}else m.restoreDropzone();c.onchange=()=>{c.files&&c.files.length>0&&Xt(c.files[0],d,o,a,b(),t.instance,p,f)},s.appendChild(d),s.appendChild(c),n.appendChild(s)}function Ho(e,t,n,o){var r,l;const i=t.state,a=document.createElement("div");a.className="space-y-2",a.dataset.filesWrapper=o;const s=document.createElement("input");s.type="file",s.name=o,s.multiple=!0,s.style.display="none",e.accept&&(s.accept=typeof e.accept=="string"?e.accept:((r=e.accept.extensions)==null?void 0:r.map(b=>`.${b}`).join(","))||"");const c=document.createElement("div");c.className="files-list-wrapper",c.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const d=document.createElement("div");d.className="files-list";const u=t.prefill[e.key]||[];_e(u,i.resourceIndex),a.dataset.resourceIds=JSON.stringify(u);const p=ye(e,i),f={maxCount:1/0,allowedExtensions:He(e.accept),maxSize:(l=e.maxSize)!=null?l:1/0};c.appendChild(d),a.appendChild(s),a.appendChild(c),n.appendChild(a);function m(){const b=le(e,i);tn(d,u,i,b?null:v=>{var w;ht((w=i.resourceIndex.get(v))==null?void 0:w.file);const h=u.indexOf(v);h>-1&&u.splice(h,1),m()},p,void 0,void 0,b)}m(),Qt(c,u,i,m,f,o,t.instance),en(s,u,i,m,f,o,t.instance)}function Bo(e,t,n,o){var r,l,i,a;const s=t.state,c=(r=e.minCount)!=null?r:0,d=(l=e.maxCount)!=null?l:1/0,u=document.createElement("div");u.className="space-y-2",u.dataset.filesWrapper=o;const p=document.createElement("input");p.type="file",p.name=o,p.multiple=!0,p.style.display="none",e.accept&&(p.accept=typeof e.accept=="string"?e.accept:((i=e.accept.extensions)==null?void 0:i.map(y=>`.${y}`).join(","))||"");const f=document.createElement("div");f.className="files-list-wrapper",f.style.cssText="border:2px dashed var(--fb-file-upload-border-color,#d1d5db);border-radius:var(--fb-border-radius,0.5rem);padding:8px;transition:border-color var(--fb-transition-duration,200ms),background var(--fb-transition-duration,200ms);";const m=document.createElement("div");m.className="files-list",u.appendChild(p),u.appendChild(f),f.appendChild(m);const b=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];_e(b,s.resourceIndex),u.dataset.resourceIds=JSON.stringify(b);const v=ye(e,s),w={maxCount:d,allowedExtensions:He(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0},h=()=>{const y=b.length===1?$("fileCountSingle",s,{count:b.length}):$("fileCountPlural",s,{count:b.length}),C=c>0||d<1/0?` ${$("fileCountRange",s,{min:c,max:d})}`:"";return y+C},g=()=>{const y=le(e,s);tn(m,b,s,y?null:C=>{var E;ht((E=s.resourceIndex.get(C))==null?void 0:E.file),b.splice(b.indexOf(C),1),g()},v,h(),d<1/0?d:void 0,y)};Qt(f,b,s,g,w,o,t.instance),en(p,b,s,g,w,o,t.instance),g(),n.appendChild(u)}function Do(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const o=n.dataset.resourceIds;if(o===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const r=JSON.parse(o);if(!Array.isArray(r))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${o}`);return r}function jo(e,t,n,o,r){var l,i;const a="minCount"in n&&(l=n.minCount)!=null?l:0,s="maxCount"in n&&(i=n.maxCount)!=null?i:1/0;n.required&&t.length===0&&r.push(`${e}: ${$("required",o)}`),t.length<a&&r.push(`${e}: ${$("minFiles",o,{min:a})}`),t.length>s&&r.push(`${e}: ${$("maxFiles",o,{max:s})}`)}function nn(e,t,n,o,r){var l;const i="accept"in n?n.accept:void 0,a=He(i);if(a.length===0)return;const s=a.join(", ");for(const c of t){const d=o.resourceIndex.get(c),u=(l=d==null?void 0:d.name)!=null?l:c;Be(u,a)||r.push(`${e}: ${$("invalidFileExtension",o,{name:u,formats:s})}`)}}function on(e,t,n,o,r){var l;const i="maxSize"in n&&(l=n.maxSize)!=null?l:1/0;if(i!==1/0)for(const a of t){const s=o.resourceIndex.get(a);s&&s.size>i*1024*1024&&r.push(`${e}: ${$("fileTooLarge",o,{name:s.name,maxSize:i})}`)}}function Oo(e,t,n){const{scopeRoot:o,skipValidation:r,path:l,state:i}=n,a=[],s=xe(l,t),c=Do(o,s);return r||(jo(t,c,e,i,a),nn(t,c,e,i,a),on(t,c,e,i,a)),{value:c,errors:a}}function Uo(e,t,n){var o;const{scopeRoot:r,skipValidation:l,state:i}=n,a=[],s=r.querySelector(`input[name$="${t}"][type="hidden"]`),c=(o=s==null?void 0:s.value)!=null?o:"";return!l&&e.required&&c===""?(a.push(`${t}: ${$("required",i)}`),{value:null,errors:a}):(!l&&c!==""&&(nn(t,[c],e,i,a),on(t,[c],e,i,a)),{value:c||null,errors:a})}function rn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?Oo(e,t,n):Uo(e,t,n)}function Po(e,t,n,o){const r=t.state,l=t.prefill[e.key],i=typeof l=="string"?l:"";if(i){_e([i],r.resourceIndex);const a=document.createElement("input");a.type="hidden",a.name=o,a.value=i,n.appendChild(a),bt(i,r).then(s=>{n.appendChild(s)}).catch(s=>{console.error("Failed to render file preview:",s),n.appendChild(ln(r))})}else n.appendChild(ln(r))}function ln(e){const t=document.createElement("div");return t.style.cssText=`
493
+ width:${Ye};
494
+ height:${Ye};
495
+ display:flex;
496
+ align-items:center;
497
+ justify-content:center;
498
+ background:var(--fb-file-upload-bg-color,#f3f4f6);
499
+ border-radius:var(--fb-border-radius,0.5rem);
500
+ border:1px solid var(--fb-file-upload-border-color,#d1d5db);
501
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${re($("noFileSelected",e))}</div>`,t}function an(e,t,n,o,r){_e(e,t.resourceIndex);const l=document.createElement("div");if(l.dataset.filesWrapper=o,l.dataset.resourceIds=JSON.stringify(e),n.appendChild(l),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=$("noFilesSelected",t),l.appendChild(s);return}const i=document.createElement("div");i.style.cssText=`display:flex;flex-wrap:wrap;gap:6px;${r?`margin-top:${r};`:""}`,l.appendChild(i);const a=e.map(()=>{const s=document.createElement("div");return s.style.cssText=`width:${Ye};height:${Ye};`,i.appendChild(s),s});for(let s=0;s<e.length;s++){const c=e[s],d=a[s];bt(c,t).then(u=>{d.replaceWith(u)}).catch(u=>{console.error("Failed to render readonly tile:",u)})}}function Vo(e,t,n,o){const r=t.prefill[e.key],l=Array.isArray(r)?r:[];an(l,t.state,n,o)}function Wo(e,t,n,o){const r=t.prefill[e.key],l=Array.isArray(r)?r:[];an(l,t.state,n,o,"4px")}function Ko(e,t,n,o){le(e,t.state,t)?Po(e,t,n,o):Io(e,t,n,o)}function _o(e,t,n,o){le(e,t.state,t)?Vo(e,t,n,o):Ho(e,t,n,o)}function Jo(e,t,n,o){le(e,t.state,t)?Wo(e,t,n,o):Bo(e,t,n,o)}function sn(e,t,n,o){const{scopeRoot:r,state:l}=o;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(a=>{a&&typeof a=="string"&&(l.resourceIndex.has(a)||cn(a,l))});const i=r.querySelector(`[data-files-wrapper="${t}"]`);i?i.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const i=r.querySelector(`input[name="${t}"][type="hidden"]`);if(!i){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}i.value=n!=null?String(n):"",n&&typeof n=="string"&&(l.resourceIndex.has(n)||cn(n,l),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function cn(e,t){var n;const o=e.split("/").pop()||"file",r=(n=o.split(".").pop())==null?void 0:n.toLowerCase();let l="application/octet-stream";r&&(["jpg","jpeg","png","gif","webp"].includes(r)?l=`image/${r==="jpg"?"jpeg":r}`:["mp4","webm","mov","avi"].includes(r)&&(l=`video/${r==="mov"?"quicktime":r}`)),t.resourceIndex.set(e,{name:o,type:l,size:0,uploadedAt:new Date,file:void 0})}function Ne(e){return e?e.toUpperCase():"#000000"}function gt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function un(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],o=e[3];return`#${t}${t}${n}${n}${o}${o}`.toUpperCase()}return e.toUpperCase()}function dn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Ne(e),o=document.createElement("div");o.style.cssText=`
234
502
  width: 32px;
235
503
  height: 32px;
236
504
  border-radius: var(--fb-border-radius);
237
505
  border: var(--fb-border-width) solid var(--fb-border-color);
238
506
  background-color: ${n};
239
- `;const l=document.createElement("span");return l.style.cssText=`
507
+ `;const r=document.createElement("span");return r.style.cssText=`
240
508
  font-size: var(--fb-font-size);
241
509
  color: var(--fb-text-color);
242
510
  font-family: var(--fb-font-family-mono, monospace);
243
- `,l.textContent=n,t.appendChild(r),t.appendChild(l),t}function Dt(e,t,n){const r=Se(e),l=document.createElement("div");l.className="colour-picker-wrapper",l.style.cssText=`
511
+ `,r.textContent=n,t.appendChild(o),t.appendChild(r),t}function pn(e,t,n){const o=Ne(e),r=document.createElement("div");r.className="colour-picker-wrapper",r.style.cssText=`
244
512
  display: flex;
245
513
  align-items: center;
246
514
  gap: 8px;
247
- `;const a=document.createElement("div");a.className="colour-swatch",a.style.cssText=`
515
+ `;const l=document.createElement("div");l.className="colour-swatch",l.style.cssText=`
248
516
  width: 40px;
249
517
  height: 40px;
250
518
  border-radius: var(--fb-border-radius);
251
519
  border: var(--fb-border-width) solid var(--fb-border-color);
252
- background-color: ${r};
520
+ background-color: ${o};
253
521
  cursor: pointer;
254
522
  transition: border-color var(--fb-transition-duration) ease-in-out;
255
523
  flex-shrink: 0;
256
- `;const o=document.createElement("input");o.type="text",o.className="colour-hex-input",o.name=t,o.value=r,o.placeholder="#000000",o.style.cssText=`
524
+ `;const i=document.createElement("input");i.type="text",i.className="colour-hex-input",i.name=t,i.value=o,i.placeholder="#000000",i.style.cssText=`
257
525
  width: 100px;
258
526
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
259
527
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -263,49 +531,49 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
263
531
  font-size: var(--fb-font-size);
264
532
  font-family: var(--fb-font-family-mono, monospace);
265
533
  transition: all var(--fb-transition-duration) ease-in-out;
266
- `;const s=document.createElement("input");return s.type="color",s.className="colour-picker-hidden",s.value=r.toLowerCase(),s.style.cssText=`
534
+ `;const a=document.createElement("input");return a.type="color",a.className="colour-picker-hidden",a.value=o.toLowerCase(),a.style.cssText=`
267
535
  position: absolute;
268
536
  opacity: 0;
269
537
  pointer-events: none;
270
- `,o.addEventListener("input",()=>{const i=o.value.trim();if(at(i)){const u=Bt(i);a.style.backgroundColor=u,s.value=u.toLowerCase(),o.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,u)}else o.classList.add("invalid")}),o.addEventListener("blur",()=>{const i=o.value.trim();if(at(i)){const u=Bt(i);o.value=u,a.style.backgroundColor=u,s.value=u.toLowerCase(),o.classList.remove("invalid")}}),s.addEventListener("change",()=>{const i=Se(s.value);o.value=i,a.style.backgroundColor=i,n.instance&&n.instance.triggerOnChange(t,i)}),a.addEventListener("click",()=>{s.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),o.addEventListener("focus",()=>{o.style.borderColor="var(--fb-border-focus-color)",o.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",o.style.outlineOffset="0"}),o.addEventListener("blur",()=>{o.style.borderColor="var(--fb-border-color)",o.style.outline="none"}),o.addEventListener("mouseenter",()=>{document.activeElement!==o&&(o.style.borderColor="var(--fb-border-hover-color)")}),o.addEventListener("mouseleave",()=>{document.activeElement!==o&&(o.style.borderColor="var(--fb-border-color)")}),l.appendChild(a),l.appendChild(o),l.appendChild(s),l}function Qn(e,t,n,r){const l=t.state,a=t.prefill[e.key]||e.default||"#000000";if(l.config.readonly){const o=Rt(a);n.appendChild(o)}else{const o=Dt(a,r,t);n.appendChild(o)}if(!l.config.readonly){const o=document.createElement("p");o.className="mt-1",o.style.cssText=`
538
+ `,i.addEventListener("input",()=>{const s=i.value.trim();if(gt(s)){const c=un(s);l.style.backgroundColor=c,a.value=c.toLowerCase(),i.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else i.classList.add("invalid")}),i.addEventListener("blur",()=>{const s=i.value.trim();if(gt(s)){const c=un(s);i.value=c,l.style.backgroundColor=c,a.value=c.toLowerCase(),i.classList.remove("invalid")}}),a.addEventListener("change",()=>{const s=Ne(a.value);i.value=s,l.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),l.addEventListener("click",()=>{a.click()}),l.addEventListener("mouseenter",()=>{l.style.borderColor="var(--fb-border-hover-color)"}),l.addEventListener("mouseleave",()=>{l.style.borderColor="var(--fb-border-color)"}),i.addEventListener("focus",()=>{i.style.borderColor="var(--fb-border-focus-color)",i.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",i.style.outlineOffset="0"}),i.addEventListener("blur",()=>{i.style.borderColor="var(--fb-border-color)",i.style.outline="none"}),i.addEventListener("mouseenter",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-hover-color)")}),i.addEventListener("mouseleave",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-color)")}),r.appendChild(l),r.appendChild(i),r.appendChild(a),r}function Yo(e,t,n,o){const r=t.state,l=le(e,r,t),i=t.prefill[e.key]||e.default||"#000000";if(l){const a=dn(i);n.appendChild(a)}else{const a=pn(i,o,t);n.appendChild(a)}if(!l){const a=document.createElement("p");a.className="mt-1",a.style.cssText=`
271
539
  font-size: var(--fb-font-size-small);
272
540
  color: var(--fb-text-secondary-color);
273
- `,o.textContent=ve(e,l),n.appendChild(o)}}function eo(e,t,n,r){var l,a;const o=t.state,s=t.prefill[e.key]||[],i=Array.isArray(s)?[...s]:[],u=(l=e.minCount)!=null?l:1,f=(a=e.maxCount)!=null?a:1/0;for(;i.length<u;)i.push(e.default||"#000000");const c=document.createElement("div");c.className="space-y-2",n.appendChild(c);function m(){c.querySelectorAll(".multiple-colour-item").forEach((d,y)=>{const g=d.querySelector("input");g&&(g.name=`${r}[${y}]`)})}function p(d="#000000",y=-1){const g=document.createElement("div");if(g.className="multiple-colour-item flex items-center gap-2",o.config.readonly){const E=Rt(d);for(;E.firstChild;)g.appendChild(E.firstChild)}else{const E=`${r}[${c.children.length}]`,C=Dt(d,E,t);C.style.flex="1",g.appendChild(C)}return y===-1?c.appendChild(g):c.insertBefore(g,c.children[y]),m(),g}function h(){if(o.config.readonly)return;const d=c.querySelectorAll(".multiple-colour-item"),y=d.length;d.forEach(g=>{let E=g.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
541
+ `,a.textContent=ye(e,r),n.appendChild(a)}}function Xo(e,t,n,o){var r,l;const i=t.state,a=le(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(r=e.minCount)!=null?r:1,u=(l=e.maxCount)!=null?l:1/0;for(;c.length<d;)c.push(e.default||"#000000");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function f(){p.querySelectorAll(".multiple-colour-item").forEach((g,y)=>{const C=g.querySelector("input");C&&(C.name=`${o}[${y}]`)})}function m(g="#000000",y=-1){const C=document.createElement("div");if(C.className="multiple-colour-item flex items-center gap-2",a){const E=dn(g);for(;E.firstChild;)C.appendChild(E.firstChild)}else{const E=`${o}[${p.children.length}]`,x=pn(g,E,t);x.style.flex="1",C.appendChild(x)}return y===-1?p.appendChild(C):p.insertBefore(C,p.children[y]),f(),C}function b(){if(a)return;const g=p.querySelectorAll(".multiple-colour-item"),y=g.length;g.forEach(C=>{let E=C.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn px-2 py-1 rounded",E.style.cssText=`
274
542
  color: var(--fb-error-color);
275
543
  background-color: transparent;
276
544
  transition: background-color var(--fb-transition-duration);
277
- `,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const w=Array.from(c.children).indexOf(g);c.children.length>u&&(i.splice(w,1),g.remove(),m(),x(),h())},g.appendChild(E));const C=y<=u;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"})}let v=null,b=null;if(!o.config.readonly){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const d=document.createElement("button");d.type="button",d.className="add-colour-btn px-3 py-1 rounded",d.style.cssText=`
545
+ `,E.innerHTML="\u2715",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{const k=Array.from(p.children).indexOf(C);p.children.length>d&&(c.splice(k,1),C.remove(),f(),h(),b())},C.appendChild(E));const x=y<=d;E.disabled=x,E.style.opacity=x?"0.5":"1",E.style.pointerEvents=x?"none":"auto"})}let v=null,w=null;if(!a){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-colour-btn px-3 py-1 rounded",g.style.cssText=`
278
546
  color: var(--fb-primary-color);
279
547
  border: var(--fb-border-width) solid var(--fb-primary-color);
280
548
  background-color: transparent;
281
549
  font-size: var(--fb-font-size);
282
550
  transition: all var(--fb-transition-duration);
283
- `,d.textContent="+",d.addEventListener("mouseenter",()=>{d.style.backgroundColor="var(--fb-background-hover-color)"}),d.addEventListener("mouseleave",()=>{d.style.backgroundColor="transparent"}),d.onclick=()=>{const y=e.default||"#000000";i.push(y),p(y),x(),h()},b=document.createElement("span"),b.className="text-sm text-gray-500",v.appendChild(d),v.appendChild(b),n.appendChild(v)}function x(){if(!v||!b)return;const d=v.querySelector(".add-colour-btn");if(d){const y=i.length>=f;d.disabled=y,d.style.opacity=y?"0.5":"1",d.style.pointerEvents=y?"none":"auto"}b.textContent=`${i.length}/${f===1/0?"\u221E":f}`}if(i.forEach(d=>p(d)),x(),h(),!o.config.readonly){const d=document.createElement("p");d.className="mt-1",d.style.cssText=`
551
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{const y=e.default||"#000000";c.push(y),m(y),h(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",v.appendChild(g),v.appendChild(w),n.appendChild(v)}function h(){if(!v||!w)return;const g=v.querySelector(".add-colour-btn");if(g){const y=c.length>=u;g.disabled=y,g.style.opacity=y?"0.5":"1",g.style.pointerEvents=y?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(g=>m(g)),h(),b(),!a){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
284
552
  font-size: var(--fb-font-size-small);
285
553
  color: var(--fb-text-secondary-color);
286
- `,d.textContent=ve(e,o),n.appendChild(d)}}function to(e,t,n){var r,l,a;const o=[],{scopeRoot:s,skipValidation:i}=n,u=(c,m)=>{var p,h;if(!c)return;const v=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(v);m?(c.classList.add("invalid"),c.title=m,b||(b=document.createElement("div"),b.id=v,b.className="error-message",b.style.cssText=`
554
+ `,g.textContent=ye(e,i),n.appendChild(g)}}function Go(e,t,n){var o,r,l;const i=[],{scopeRoot:a,skipValidation:s}=n,c=(u,p)=>{var f,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(b);p?(u.classList.add("invalid"),u.title=p,v||(v=document.createElement("div"),v.id=b,v.className="error-message",v.style.cssText=`
287
555
  color: var(--fb-error-color);
288
556
  font-size: var(--fb-font-size-small);
289
557
  margin-top: 0.25rem;
290
- `,c.nextSibling?(p=c.parentNode)==null||p.insertBefore(b,c.nextSibling):(h=c.parentNode)==null||h.appendChild(b)),b.textContent=m,b.style.display="block"):(c.classList.remove("invalid"),c.title="",b&&b.remove())},f=(c,m,p)=>{const{state:h}=n;if(!m){if(!i&&e.required){const b=k("required",h);return o.push(`${p}: ${b}`),u(c,b),""}return u(c,null),""}const v=Se(m);if(!i&&!at(v)){const b=k("invalidHexColour",h);return o.push(`${p}: ${b}`),u(c,b),m}return u(c,null),v};if(e.multiple){const c=s.querySelectorAll(`[name^="${t}["].colour-hex-input`),m=[];if(c.forEach((p,h)=>{var v;const b=(v=p==null?void 0:p.value)!=null?v:"",x=f(p,b,`${t}[${h}]`);m.push(x)}),!i){const{state:p}=n,h=(r=e.minCount)!=null?r:1,v=(l=e.maxCount)!=null?l:1/0,b=m.filter(x=>x!=="");e.required&&b.length===0&&o.push(`${t}: ${k("required",p)}`),b.length<h&&o.push(`${t}: ${k("minItems",p,{min:h})}`),b.length>v&&o.push(`${t}: ${k("maxItems",p,{max:v})}`)}return{value:m,errors:o}}else{const c=s.querySelector(`[name="${t}"].colour-hex-input`),m=(a=c==null?void 0:c.value)!=null?a:"";if(!i&&e.required&&m===""){const p=k("required",n.state);return o.push(`${t}: ${p}`),u(c,p),{value:"",errors:o}}return{value:f(c,m,t),errors:o}}}function no(e,t,n,r){const{scopeRoot:l}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=l.querySelectorAll(`[name^="${t}["].colour-hex-input`);a.forEach((o,s)=>{if(s<n.length){const i=Se(n[s]);o.value=i,o.classList.remove("invalid"),o.title="";const u=o.closest(".colour-picker-wrapper");if(u){const f=u.querySelector(".colour-swatch"),c=u.querySelector(".colour-picker-hidden");f&&(f.style.backgroundColor=i),c&&(c.value=i.toLowerCase())}}}),n.length!==a.length&&console.warn(`updateColourField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=l.querySelector(`[name="${t}"].colour-hex-input`);if(a){const o=Se(n);a.value=o,a.classList.remove("invalid"),a.title="";const s=a.closest(".colour-picker-wrapper");if(s){const i=s.querySelector(".colour-swatch"),u=s.querySelector(".colour-picker-hidden");i&&(i.style.backgroundColor=o),u&&(u.value=o.toLowerCase())}}}}function jt(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),l=Math.log(n);return Math.exp(r+e*(l-r))}function it(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),l=Math.log(n);return(Math.log(e)-r)/(l-r)}function Ve(e,t){return Math.round(e/t)*t}function Ot(e,t,n,r,l){var a;const o=document.createElement("div");o.className="slider-container";const s=document.createElement("div");s.className="flex items-start gap-3";const i=document.createElement("div");i.className="flex-1";const u=document.createElement("input");u.type="range",u.name=t,u.className="slider-input w-full",u.disabled=l;const f=n.scale||"linear",c=n.min,m=n.max,p=(a=n.step)!=null?a:1;if(f==="exponential"){if(c<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${c})`);u.min="0",u.max="1000",u.step="1";const d=it(e,c,m);u.value=(d*1e3).toString()}else u.min=c.toString(),u.max=m.toString(),u.step=p.toString(),u.value=e.toString();u.style.cssText=`
558
+ `,u.nextSibling?(f=u.parentNode)==null||f.insertBefore(v,u.nextSibling):(m=u.parentNode)==null||m.appendChild(v)),v.textContent=p,v.style.display="block"):(u.classList.remove("invalid"),u.title="",v&&v.remove())},d=(u,p,f)=>{const{state:m}=n;if(!p){if(!s&&e.required){const v=$("required",m);return i.push(`${f}: ${v}`),c(u,v),""}return c(u,null),""}const b=Ne(p);if(!s&&!gt(b)){const v=$("invalidHexColour",m);return i.push(`${f}: ${v}`),c(u,v),p}return c(u,null),b};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["].colour-hex-input`),p=[];if(u.forEach((f,m)=>{var b;const v=(b=f==null?void 0:f.value)!=null?b:"",w=d(f,v,`${t}[${m}]`);p.push(w)}),!s){const{state:f}=n,m=(o=e.minCount)!=null?o:1,b=(r=e.maxCount)!=null?r:1/0,v=p.filter(w=>w!=="");e.required&&v.length===0&&i.push(`${t}: ${$("required",f)}`),v.length<m&&i.push(`${t}: ${$("minItems",f,{min:m})}`),v.length>b&&i.push(`${t}: ${$("maxItems",f,{max:b})}`)}return{value:p,errors:i}}else{const u=a.querySelector(`[name="${t}"].colour-hex-input`),p=(l=u==null?void 0:u.value)!=null?l:"";if(!s&&e.required&&p===""){const f=$("required",n.state);return i.push(`${t}: ${f}`),c(u,f),{value:"",errors:i}}return{value:d(u,p,t),errors:i}}}function Zo(e,t,n,o){const{scopeRoot:r}=o;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=r.querySelectorAll(`[name^="${t}["].colour-hex-input`);l.forEach((i,a)=>{if(a<n.length){const s=Ne(n[a]);i.value=s,i.classList.remove("invalid"),i.title="";const c=i.closest(".colour-picker-wrapper");if(c){const d=c.querySelector(".colour-swatch"),u=c.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=s),u&&(u.value=s.toLowerCase())}}}),n.length!==l.length&&console.warn(`updateColourField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=r.querySelector(`[name="${t}"].colour-hex-input`);if(l){const i=Ne(n);l.value=i,l.classList.remove("invalid"),l.title="";const a=l.closest(".colour-picker-wrapper");if(a){const s=a.querySelector(".colour-swatch"),c=a.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=i),c&&(c.value=i.toLowerCase())}}}}function fn(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const o=Math.log(t),r=Math.log(n);return Math.exp(o+e*(r-o))}function yt(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const o=Math.log(t),r=Math.log(n);return(Math.log(e)-o)/(r-o)}function tt(e,t){return Math.round(e/t)*t}function mn(e,t,n,o,r){var l;const i=document.createElement("div");i.className="slider-container";const a=document.createElement("div");a.className="flex items-start gap-3";const s=document.createElement("div");s.className="flex-1";const c=document.createElement("input");c.type="range",c.name=t,c.className="slider-input w-full",c.disabled=r;const d=n.scale||"linear",u=n.min,p=n.max,f=(l=n.step)!=null?l:1;if(d==="exponential"){if(u<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${u})`);c.min="0",c.max="1000",c.step="1";const h=yt(e,u,p);c.value=(h*1e3).toString()}else c.min=u.toString(),c.max=p.toString(),c.step=f.toString(),c.value=e.toString();c.style.cssText=`
291
559
  height: 6px;
292
560
  border-radius: 3px;
293
561
  background: linear-gradient(
294
562
  to right,
295
563
  var(--fb-primary-color) 0%,
296
- var(--fb-primary-color) ${(e-c)/(m-c)*100}%,
297
- var(--fb-border-color) ${(e-c)/(m-c)*100}%,
564
+ var(--fb-primary-color) ${(e-u)/(p-u)*100}%,
565
+ var(--fb-border-color) ${(e-u)/(p-u)*100}%,
298
566
  var(--fb-border-color) 100%
299
567
  );
300
568
  outline: none;
301
569
  transition: background 0.1s ease-in-out;
302
- cursor: ${l?"not-allowed":"pointer"};
303
- opacity: ${l?"0.6":"1"};
304
- `,i.appendChild(u);const h=document.createElement("div");h.className="flex justify-between",h.style.cssText=`
570
+ cursor: ${r?"not-allowed":"pointer"};
571
+ opacity: ${r?"0.6":"1"};
572
+ `,s.appendChild(c);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
305
573
  font-size: var(--fb-font-size-small);
306
574
  color: var(--fb-text-secondary-color);
307
575
  margin-top: 4px;
308
- `;const v=document.createElement("span");v.textContent=c.toString();const b=document.createElement("span");b.textContent=m.toString(),h.appendChild(v),h.appendChild(b),i.appendChild(h);const x=document.createElement("span");if(x.className="slider-value",x.style.cssText=`
576
+ `;const b=document.createElement("span");b.textContent=u.toString();const v=document.createElement("span");v.textContent=p.toString(),m.appendChild(b),m.appendChild(v),s.appendChild(m);const w=document.createElement("span");if(w.className="slider-value",w.style.cssText=`
309
577
  min-width: 60px;
310
578
  text-align: right;
311
579
  font-size: var(--fb-font-size);
@@ -313,64 +581,64 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
313
581
  font-family: var(--fb-font-family-mono, monospace);
314
582
  font-weight: 500;
315
583
  padding-top: 2px;
316
- `,x.textContent=e.toFixed(p<1?2:0),s.appendChild(i),s.appendChild(x),o.appendChild(s),!l){const d=()=>{let y;if(f==="exponential"){const E=parseFloat(u.value)/1e3;y=jt(E,c,m),y=Ve(y,p),y=Math.max(c,Math.min(m,y))}else y=parseFloat(u.value),y=Ve(y,p);x.textContent=y.toFixed(p<1?2:0);const g=(y-c)/(m-c)*100;u.style.background=`linear-gradient(
584
+ `,w.textContent=e.toFixed(f<1?2:0),a.appendChild(s),a.appendChild(w),i.appendChild(a),!r){const h=()=>{let g;if(d==="exponential"){const C=parseFloat(c.value)/1e3;g=fn(C,u,p),g=tt(g,f),g=Math.max(u,Math.min(p,g))}else g=parseFloat(c.value),g=tt(g,f);w.textContent=g.toFixed(f<1?2:0);const y=(g-u)/(p-u)*100;c.style.background=`linear-gradient(
317
585
  to right,
318
586
  var(--fb-primary-color) 0%,
319
- var(--fb-primary-color) ${g}%,
320
- var(--fb-border-color) ${g}%,
587
+ var(--fb-primary-color) ${y}%,
588
+ var(--fb-border-color) ${y}%,
321
589
  var(--fb-border-color) 100%
322
- )`,r.instance&&r.instance.triggerOnChange(t,y)};u.addEventListener("input",d),u.addEventListener("change",d)}return o}function oo(e,t,n,r){var l;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,o=e.default!==void 0?e.default:(e.min+e.max)/2,s=(l=t.prefill[e.key])!=null?l:o,i=Ot(s,r,e,t,a.config.readonly);if(n.appendChild(i),!a.config.readonly){const u=document.createElement("p");u.className="mt-1",u.style.cssText=`
590
+ )`,o.instance&&o.instance.triggerOnChange(t,g)};c.addEventListener("input",h),c.addEventListener("change",h)}return i}function Qo(e,t,n,o){var r;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 l=t.state,i=le(e,l,t),a=e.default!==void 0?e.default:(e.min+e.max)/2,s=(r=t.prefill[e.key])!=null?r:a,c=mn(s,o,e,t,i);if(n.appendChild(c),!i){const d=document.createElement("p");d.className="mt-1",d.style.cssText=`
323
591
  font-size: var(--fb-font-size-small);
324
592
  color: var(--fb-text-secondary-color);
325
- `,u.textContent=ve(e,a),n.appendChild(u)}}function ro(e,t,n,r){var l,a;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 o=t.state,s=t.prefill[e.key]||[],i=Array.isArray(s)?[...s]:[],u=(l=e.minCount)!=null?l:1,f=(a=e.maxCount)!=null?a:1/0,c=e.default!==void 0?e.default:(e.min+e.max)/2;for(;i.length<u;)i.push(c);const m=document.createElement("div");m.className="space-y-3",n.appendChild(m);function p(){m.querySelectorAll(".multiple-slider-item").forEach((y,g)=>{const E=y.querySelector("input[type=range]");E&&E.setAttribute("name",`${r}[${g}]`)})}function h(y=c,g=-1){const E=document.createElement("div");E.className="multiple-slider-item flex items-start gap-2";const C=`${r}[${m.children.length}]`,w=Ot(y,C,e,t,o.config.readonly);return w.style.flex="1",E.appendChild(w),g===-1?m.appendChild(E):m.insertBefore(E,m.children[g]),p(),E}function v(){if(o.config.readonly)return;const y=m.querySelectorAll(".multiple-slider-item"),g=y.length;y.forEach(E=>{let C=E.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=`
593
+ `,d.textContent=ye(e,l),n.appendChild(d)}}function er(e,t,n,o){var r,l;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=le(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],d=(r=e.minCount)!=null?r:1,u=(l=e.maxCount)!=null?l:1/0,p=e.default!==void 0?e.default:(e.min+e.max)/2;for(;c.length<d;)c.push(p);const f=document.createElement("div");f.className="space-y-3",n.appendChild(f);function m(){f.querySelectorAll(".multiple-slider-item").forEach((y,C)=>{const E=y.querySelector("input[type=range]");E&&E.setAttribute("name",`${o}[${C}]`)})}function b(y=p,C=-1){const E=document.createElement("div");E.className="multiple-slider-item flex items-start gap-2";const x=`${o}[${f.children.length}]`,k=mn(y,x,e,t,a);return k.style.flex="1",E.appendChild(k),C===-1?f.appendChild(E):f.insertBefore(E,f.children[C]),m(),E}function v(){if(a)return;const y=f.querySelectorAll(".multiple-slider-item"),C=y.length;y.forEach(E=>{let x=E.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=`
326
594
  color: var(--fb-error-color);
327
595
  background-color: transparent;
328
596
  transition: background-color var(--fb-transition-duration);
329
597
  margin-top: 8px;
330
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const S=Array.from(m.children).indexOf(E);m.children.length>u&&(i.splice(S,1),E.remove(),p(),d(),v())},E.appendChild(C));const w=g<=u;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let b=null,x=null;if(!o.config.readonly){b=document.createElement("div"),b.className="flex items-center gap-3 mt-2";const y=document.createElement("button");y.type="button",y.className="add-slider-btn px-3 py-1 rounded",y.style.cssText=`
598
+ `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const q=Array.from(f.children).indexOf(E);f.children.length>d&&(c.splice(q,1),E.remove(),m(),g(),v())},E.appendChild(x));const k=C<=d;x.disabled=k,x.style.opacity=k?"0.5":"1",x.style.pointerEvents=k?"none":"auto"})}let w=null,h=null;if(!a){w=document.createElement("div"),w.className="flex items-center gap-3 mt-2";const y=document.createElement("button");y.type="button",y.className="add-slider-btn px-3 py-1 rounded",y.style.cssText=`
331
599
  color: var(--fb-primary-color);
332
600
  border: var(--fb-border-width) solid var(--fb-primary-color);
333
601
  background-color: transparent;
334
602
  font-size: var(--fb-font-size);
335
603
  transition: all var(--fb-transition-duration);
336
- `,y.textContent="+",y.addEventListener("mouseenter",()=>{y.style.backgroundColor="var(--fb-background-hover-color)"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="transparent"}),y.onclick=()=>{i.push(c),h(c),d(),v()},x=document.createElement("span"),x.className="text-sm text-gray-500",b.appendChild(y),b.appendChild(x),n.appendChild(b)}function d(){if(!b||!x)return;const y=b.querySelector(".add-slider-btn");if(y){const g=i.length>=f;y.disabled=g,y.style.opacity=g?"0.5":"1",y.style.pointerEvents=g?"none":"auto"}x.textContent=`${i.length}/${f===1/0?"\u221E":f}`}if(i.forEach(y=>h(y)),d(),v(),!o.config.readonly){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
604
+ `,y.textContent="+",y.addEventListener("mouseenter",()=>{y.style.backgroundColor="var(--fb-background-hover-color)"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="transparent"}),y.onclick=()=>{c.push(p),b(p),g(),v()},h=document.createElement("span"),h.className="text-sm text-gray-500",w.appendChild(y),w.appendChild(h),n.appendChild(w)}function g(){if(!w||!h)return;const y=w.querySelector(".add-slider-btn");if(y){const C=c.length>=u;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"}h.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(y=>b(y)),g(),v(),!a){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
337
605
  font-size: var(--fb-font-size-small);
338
606
  color: var(--fb-text-secondary-color);
339
- `,y.textContent=ve(e,o),n.appendChild(y)}}function lo(e,t,n){var r,l,a;const o=[],{scopeRoot:s,skipValidation:i}=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 u=e.min,f=e.max,c=(r=e.step)!=null?r:1,m=e.scale||"linear",p=(v,b)=>{var x,d;if(!v)return;const y=`error-${v.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(y);if(b){if(v.classList.add("invalid"),v.title=b,!g){g=document.createElement("div"),g.id=y,g.className="error-message",g.style.cssText=`
607
+ `,y.textContent=ye(e,i),n.appendChild(y)}}function tr(e,t,n){var o,r,l;const i=[],{scopeRoot:a,skipValidation:s}=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 c=e.min,d=e.max,u=(o=e.step)!=null?o:1,p=e.scale||"linear",f=(b,v)=>{var w,h;if(!b)return;const g=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(g);if(v){if(b.classList.add("invalid"),b.title=v,!y){y=document.createElement("div"),y.id=g,y.className="error-message",y.style.cssText=`
340
608
  color: var(--fb-error-color);
341
609
  font-size: var(--fb-font-size-small);
342
610
  margin-top: 0.25rem;
343
- `;const E=v.closest(".slider-container");E&&E.nextSibling?(x=E.parentNode)==null||x.insertBefore(g,E.nextSibling):E&&((d=E.parentNode)==null||d.appendChild(g))}g.textContent=b,g.style.display="block"}else v.classList.remove("invalid"),v.title="",g&&g.remove()},h=(v,b)=>{const{state:x}=n,d=v.value;if(!d){if(!i&&e.required){const g=k("required",x);return o.push(`${b}: ${g}`),p(v,g),null}return p(v,null),null}let y;if(m==="exponential"){const g=parseFloat(d)/1e3;y=jt(g,u,f),y=Ve(y,c)}else y=parseFloat(d),y=Ve(y,c);if(!i){if(y<u){const g=k("minValue",x,{min:u});return o.push(`${b}: ${g}`),p(v,g),y}if(y>f){const g=k("maxValue",x,{max:f});return o.push(`${b}: ${g}`),p(v,g),y}}return p(v,null),y};if(e.multiple){const v=s.querySelectorAll(`input[type="range"][name^="${t}["]`),b=[];if(v.forEach((x,d)=>{const y=h(x,`${t}[${d}]`);b.push(y)}),!i){const{state:x}=n,d=(l=e.minCount)!=null?l:1,y=(a=e.maxCount)!=null?a:1/0,g=b.filter(E=>E!==null);e.required&&g.length===0&&o.push(`${t}: ${k("required",x)}`),g.length<d&&o.push(`${t}: ${k("minItems",x,{min:d})}`),g.length>y&&o.push(`${t}: ${k("maxItems",x,{max:y})}`)}return{value:b,errors:o}}else{const v=s.querySelector(`input[type="range"][name="${t}"]`);return v?{value:h(v,t),errors:o}:(!i&&e.required&&o.push(`${t}: ${k("required",n.state)}`),{value:null,errors:o})}}function ao(e,t,n,r){var l;const{scopeRoot:a}=r,o=e.min,s=e.max,i=(l=e.step)!=null?l:1,u=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const f=a.querySelectorAll(`input[type="range"][name^="${t}["]`);f.forEach((c,m)=>{if(m<n.length&&n[m]!==null){const p=Number(n[m]);if(u==="exponential"){const v=it(p,o,s);c.value=(v*1e3).toString()}else c.value=p.toString();const h=c.closest(".slider-container");if(h){const v=h.querySelector(".slider-value");v&&(v.textContent=p.toFixed(i<1?2:0));const b=(p-o)/(s-o)*100;c.style.background=`linear-gradient(
611
+ `;const C=b.closest(".slider-container");C&&C.nextSibling?(w=C.parentNode)==null||w.insertBefore(y,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(y))}y.textContent=v,y.style.display="block"}else b.classList.remove("invalid"),b.title="",y&&y.remove()},m=(b,v)=>{const{state:w}=n,h=b.value;if(!h){if(!s&&e.required){const y=$("required",w);return i.push(`${v}: ${y}`),f(b,y),null}return f(b,null),null}let g;if(p==="exponential"){const y=parseFloat(h)/1e3;g=fn(y,c,d),g=tt(g,u)}else g=parseFloat(h),g=tt(g,u);if(!s){if(g<c){const y=$("minValue",w,{min:c});return i.push(`${v}: ${y}`),f(b,y),g}if(g>d){const y=$("maxValue",w,{max:d});return i.push(`${v}: ${y}`),f(b,y),g}}return f(b,null),g};if(e.multiple){const b=a.querySelectorAll(`input[type="range"][name^="${t}["]`),v=[];if(b.forEach((w,h)=>{const g=m(w,`${t}[${h}]`);v.push(g)}),!s){const{state:w}=n,h=(r=e.minCount)!=null?r:1,g=(l=e.maxCount)!=null?l:1/0,y=v.filter(C=>C!==null);e.required&&y.length===0&&i.push(`${t}: ${$("required",w)}`),y.length<h&&i.push(`${t}: ${$("minItems",w,{min:h})}`),y.length>g&&i.push(`${t}: ${$("maxItems",w,{max:g})}`)}return{value:v,errors:i}}else{const b=a.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:i}:(!s&&e.required&&i.push(`${t}: ${$("required",n.state)}`),{value:null,errors:i})}}function nr(e,t,n,o){var r;const{scopeRoot:l}=o,i=e.min,a=e.max,s=(r=e.step)!=null?r:1,c=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const d=l.querySelectorAll(`input[type="range"][name^="${t}["]`);d.forEach((u,p)=>{if(p<n.length&&n[p]!==null){const f=Number(n[p]);if(c==="exponential"){const b=yt(f,i,a);u.value=(b*1e3).toString()}else u.value=f.toString();const m=u.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=f.toFixed(s<1?2:0));const v=(f-i)/(a-i)*100;u.style.background=`linear-gradient(
344
612
  to right,
345
613
  var(--fb-primary-color) 0%,
346
- var(--fb-primary-color) ${b}%,
347
- var(--fb-border-color) ${b}%,
614
+ var(--fb-primary-color) ${v}%,
615
+ var(--fb-border-color) ${v}%,
348
616
  var(--fb-border-color) 100%
349
- )`}c.classList.remove("invalid"),c.title=""}}),n.length!==f.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${f.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const f=a.querySelector(`input[type="range"][name="${t}"]`);if(f&&n!==null&&n!==void 0){const c=Number(n);if(u==="exponential"){const p=it(c,o,s);f.value=(p*1e3).toString()}else f.value=c.toString();const m=f.closest(".slider-container");if(m){const p=m.querySelector(".slider-value");p&&(p.textContent=c.toFixed(i<1?2:0));const h=(c-o)/(s-o)*100;f.style.background=`linear-gradient(
617
+ )`}u.classList.remove("invalid"),u.title=""}}),n.length!==d.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${d.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const d=l.querySelector(`input[type="range"][name="${t}"]`);if(d&&n!==null&&n!==void 0){const u=Number(n);if(c==="exponential"){const f=yt(u,i,a);d.value=(f*1e3).toString()}else d.value=u.toString();const p=d.closest(".slider-container");if(p){const f=p.querySelector(".slider-value");f&&(f.textContent=u.toFixed(s<1?2:0));const m=(u-i)/(a-i)*100;d.style.background=`linear-gradient(
350
618
  to right,
351
619
  var(--fb-primary-color) 0%,
352
- var(--fb-primary-color) ${h}%,
353
- var(--fb-border-color) ${h}%,
620
+ var(--fb-primary-color) ${m}%,
621
+ var(--fb-border-color) ${m}%,
354
622
  var(--fb-border-color) 100%
355
- )`}f.classList.remove("invalid"),f.title=""}}}function Ut(e){const t={};for(const n of e)"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Pt(e,t){return{...t,...e}}function st(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 ct=null;function io(e){ct=e}function Ke(e,t){if(!ct)throw new Error("renderElement not initialized. Import from components/index.ts");return ct(e,t)}function Vt(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-4",e.prefillHints.forEach((r,l)=>{const a=document.createElement("button");a.type="button",a.className="fb-prefill-hint",a.textContent=r.label,a.setAttribute("data-hint-values",JSON.stringify(r.values)),a.setAttribute("data-container-key",t),a.setAttribute("data-hint-index",String(l)),n.appendChild(a)}),n}function Kt(e,t,n,r){var l,a;const o=document.createElement("div");o.className="border border-gray-200 rounded-lg p-4 bg-gray-50",o.setAttribute("data-container",r);const s=document.createElement("div"),i=e.columns||1;if(i===1?s.className="space-y-4":s.className=`grid grid-cols-${i} gap-4`,!t.state.config.readonly){const p=Vt(e,r);p&&o.appendChild(p)}const u=Ut(e.elements),f=((l=t.prefill)==null?void 0:l[e.key])||{},c=Pt(f,u),m={path:ge(t.path,e.key),prefill:c,formData:(a=t.formData)!=null?a:t.prefill,state:t.state};e.elements.forEach(p=>{var h,v;if(p.hidden||p.type==="hidden"){const b=(v=(h=f[p.key])!=null?h:p.default)!=null?v:null;s.appendChild(qe(ge(m.path,p.key),b))}else s.appendChild(Ke(p,m))}),o.appendChild(s),n.appendChild(o)}function _t(e,t,n,r){var l,a,o,s;const i=t.state,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-4 bg-gray-50";const f=document.createElement("span");f.className="text-sm text-gray-500";const c=document.createElement("div");if(c.className="space-y-4",!t.state.config.readonly){const g=Vt(e,e.key);g&&u.appendChild(g)}const m=(l=e.minCount)!=null?l:0,p=(a=e.maxCount)!=null?a:1/0,h=Array.isArray((o=t.prefill)==null?void 0:o[e.key])?t.prefill[e.key]:null,v=Ut(e.elements),b=()=>c.querySelectorAll(":scope > .containerItem").length,x=()=>{const g=document.createElement("button");return g.type="button",g.className="add-container-btn px-3 py-1 rounded",g.style.cssText=`
623
+ )`}d.classList.remove("invalid"),d.title=""}}}function hn(e){const t={};for(const n of e)"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function vn(e,t){return{...t,...e}}function xt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const o=n.getAttribute("name");o&&!o.includes("[")&&!o.includes(".")&&(n instanceof HTMLSelectElement?t[o]=n.value:n instanceof HTMLInputElement?n.type==="checkbox"?t[o]=n.checked:n.type==="radio"?n.checked&&(t[o]=n.value):t[o]=n.value:n instanceof HTMLTextAreaElement&&(t[o]=n.value))}),t}let Et=null;function or(e){Et=e}function nt(e,t){if(!Et)throw new Error("renderElement not initialized. Import from components/index.ts");return Et(e,t)}function bn(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-4",e.prefillHints.forEach((o,r)=>{const l=document.createElement("button");l.type="button",l.className="fb-prefill-hint",l.textContent=o.label,l.setAttribute("data-hint-values",JSON.stringify(o.values)),l.setAttribute("data-container-key",t),l.setAttribute("data-hint-index",String(r)),n.appendChild(l)}),n}function gn(e,t,n,o){var r,l;const i=document.createElement("div");i.className="border border-gray-200 rounded-lg p-4 bg-gray-50",i.setAttribute("data-container",o);const a=document.createElement("div"),s=e.columns||1;s===1?a.className="space-y-4":a.className=`grid grid-cols-${s} gap-4`;const c=le(e,t.state,t);if(!c){const m=bn(e,o);m&&i.appendChild(m)}const d=hn(e.elements),u=((r=t.prefill)==null?void 0:r[e.key])||{},p=vn(u,d),f={path:xe(t.path,e.key),prefill:p,formData:(l=t.formData)!=null?l:t.prefill,state:t.state,inheritedReadonly:c||t.inheritedReadonly};e.elements.forEach(m=>{var b,v;if(m.hidden||m.type==="hidden"){const w=(v=(b=u[m.key])!=null?b:m.default)!=null?v:null;a.appendChild(Re(xe(f.path,m.key),w))}else a.appendChild(nt(m,f))}),i.appendChild(a),n.appendChild(i)}function yn(e,t,n,o){var r,l,i,a;const s=t.state,c=le(e,s,t),d=c||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-4 bg-gray-50";const p=document.createElement("span");p.className="text-sm text-gray-500";const f=document.createElement("div");if(f.className="space-y-4",!c){const E=bn(e,e.key);E&&u.appendChild(E)}const m=(r=e.minCount)!=null?r:0,b=(l=e.maxCount)!=null?l:1/0,v=Array.isArray((i=t.prefill)==null?void 0:i[e.key])?t.prefill[e.key]:null,w=hn(e.elements),h=()=>f.querySelectorAll(":scope > .containerItem").length,g=()=>{const E=document.createElement("button");return E.type="button",E.className="add-container-btn px-3 py-1 rounded",E.style.cssText=`
356
624
  color: var(--fb-primary-color);
357
625
  border: var(--fb-border-width) solid var(--fb-primary-color);
358
626
  background-color: transparent;
359
627
  font-size: var(--fb-font-size);
360
628
  transition: all var(--fb-transition-duration);
361
- `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{if(b()<p){const E=b(),C=i.formRoot?st(i.formRoot):{},w={state:t.state,path:ge(t.path,`${e.key}[${E}]`),prefill:v,formData:C},S=document.createElement("div");S.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",S.setAttribute("data-container-item",`${e.key}[${E}]`);const z=document.createElement("div"),Z=e.columns||1;if(Z===1?z.className="space-y-4":z.className=`grid grid-cols-${Z} gap-4`,e.elements.forEach(R=>{var _;R.hidden||R.type==="hidden"?z.appendChild(qe(ge(w.path,R.key),(_=R.default)!=null?_:null)):z.appendChild(Ke(R,w))}),S.appendChild(z),!i.config.readonly){const R=document.createElement("button");R.type="button",R.className="absolute top-2 right-2 px-2 py-1 rounded",R.style.cssText=`
629
+ `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{if(h()<b){const x=h(),k=s.formRoot?xt(s.formRoot):{},q={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:w,formData:k,inheritedReadonly:d},K=document.createElement("div");K.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",K.setAttribute("data-container-item",`${e.key}[${x}]`);const I=document.createElement("div"),G=e.columns||1;if(G===1?I.className="space-y-4":I.className=`grid grid-cols-${G} gap-4`,e.elements.forEach(Z=>{var oe;Z.hidden||Z.type==="hidden"?I.appendChild(Re(xe(q.path,Z.key),(oe=Z.default)!=null?oe:null)):I.appendChild(nt(Z,q))}),K.appendChild(I),!c){const Z=document.createElement("button");Z.type="button",Z.className="absolute top-2 right-2 px-2 py-1 rounded",Z.style.cssText=`
362
630
  color: var(--fb-error-color);
363
631
  background-color: transparent;
364
632
  transition: background-color var(--fb-transition-duration);
365
- `,R.textContent="\u2715",R.addEventListener("mouseenter",()=>{R.style.backgroundColor="var(--fb-background-hover-color)"}),R.addEventListener("mouseleave",()=>{R.style.backgroundColor="transparent"}),R.onclick=()=>y(S),S.style.position="relative",S.appendChild(R)}c.appendChild(S),d()}},g},d=()=>{const g=b(),E=u.querySelector(".add-container-btn");E&&(E.disabled=g>=p,E.style.opacity=g>=p?"0.5":"1",E.style.pointerEvents=g>=p?"none":"auto"),f.textContent=`${g}/${p===1/0?"\u221E":p}`},y=g=>{g.remove(),d()};if(h&&Array.isArray(h)&&h.forEach((g,E)=>{var C;const w=Pt(g||{},v),S={state:t.state,path:ge(t.path,`${e.key}[${E}]`),prefill:w,formData:(C=t.formData)!=null?C:t.prefill},z=document.createElement("div");z.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",z.setAttribute("data-container-item",`${e.key}[${E}]`);const Z=document.createElement("div"),R=e.columns||1;if(R===1?Z.className="space-y-4":Z.className=`grid grid-cols-${R} gap-4`,e.elements.forEach(_=>{var fe,Ee;if(_.hidden||_.type==="hidden"){const Ne=(Ee=(fe=g==null?void 0:g[_.key])!=null?fe:_.default)!=null?Ee:null;Z.appendChild(qe(ge(S.path,_.key),Ne))}else Z.appendChild(Ke(_,S))}),z.appendChild(Z),!i.config.readonly){const _=document.createElement("button");_.type="button",_.className="absolute top-2 right-2 px-2 py-1 rounded",_.style.cssText=`
633
+ `,Z.textContent="\u2715",Z.addEventListener("mouseenter",()=>{Z.style.backgroundColor="var(--fb-background-hover-color)"}),Z.addEventListener("mouseleave",()=>{Z.style.backgroundColor="transparent"}),Z.onclick=()=>C(K),K.style.position="relative",K.appendChild(Z)}f.appendChild(K),y()}},E},y=()=>{const E=h(),x=u.querySelector(".add-container-btn");x&&(x.disabled=E>=b,x.style.opacity=E>=b?"0.5":"1",x.style.pointerEvents=E>=b?"none":"auto"),p.textContent=`${E}/${b===1/0?"\u221E":b}`},C=E=>{E.remove(),y()};if(v&&Array.isArray(v)&&v.forEach((E,x)=>{var k;const q=vn(E||{},w),K={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:q,formData:(k=t.formData)!=null?k:t.prefill,inheritedReadonly:d},I=document.createElement("div");I.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",I.setAttribute("data-container-item",`${e.key}[${x}]`);const G=document.createElement("div"),Z=e.columns||1;if(Z===1?G.className="space-y-4":G.className=`grid grid-cols-${Z} gap-4`,e.elements.forEach(oe=>{var Te,pe;if(oe.hidden||oe.type==="hidden"){const $e=(pe=(Te=E==null?void 0:E[oe.key])!=null?Te:oe.default)!=null?pe:null;G.appendChild(Re(xe(K.path,oe.key),$e))}else G.appendChild(nt(oe,K))}),I.appendChild(G),!c){const oe=document.createElement("button");oe.type="button",oe.className="absolute top-2 right-2 px-2 py-1 rounded",oe.style.cssText=`
366
634
  color: var(--fb-error-color);
367
635
  background-color: transparent;
368
636
  transition: background-color var(--fb-transition-duration);
369
- `,_.textContent="\u2715",_.addEventListener("mouseenter",()=>{_.style.backgroundColor="var(--fb-background-hover-color)"}),_.addEventListener("mouseleave",()=>{_.style.backgroundColor="transparent"}),_.onclick=()=>y(z),z.style.position="relative",z.appendChild(_)}c.appendChild(z)}),!i.config.readonly)for(;b()<m;){const g=b(),E={state:t.state,path:ge(t.path,`${e.key}[${g}]`),prefill:v,formData:(s=t.formData)!=null?s:t.prefill},C=document.createElement("div");C.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",C.setAttribute("data-container-item",`${e.key}[${g}]`);const w=document.createElement("div"),S=e.columns||1;S===1?w.className="space-y-4":w.className=`grid grid-cols-${S} gap-4`,e.elements.forEach(Z=>{var R;Z.hidden||Z.type==="hidden"?w.appendChild(qe(ge(E.path,Z.key),(R=Z.default)!=null?R:null)):w.appendChild(Ke(Z,E))}),C.appendChild(w);const z=document.createElement("button");z.type="button",z.className="absolute top-2 right-2 px-2 py-1 rounded",z.style.cssText=`
637
+ `,oe.textContent="\u2715",oe.addEventListener("mouseenter",()=>{oe.style.backgroundColor="var(--fb-background-hover-color)"}),oe.addEventListener("mouseleave",()=>{oe.style.backgroundColor="transparent"}),oe.onclick=()=>C(I),I.style.position="relative",I.appendChild(oe)}f.appendChild(I)}),!c)for(;h()<m;){const E=h(),x={state:t.state,path:xe(t.path,`${e.key}[${E}]`),prefill:w,formData:(a=t.formData)!=null?a:t.prefill,inheritedReadonly:d},k=document.createElement("div");k.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",k.setAttribute("data-container-item",`${e.key}[${E}]`);const q=document.createElement("div"),K=e.columns||1;K===1?q.className="space-y-4":q.className=`grid grid-cols-${K} gap-4`,e.elements.forEach(G=>{var Z;G.hidden||G.type==="hidden"?q.appendChild(Re(xe(x.path,G.key),(Z=G.default)!=null?Z:null)):q.appendChild(nt(G,x))}),k.appendChild(q);const I=document.createElement("button");I.type="button",I.className="absolute top-2 right-2 px-2 py-1 rounded",I.style.cssText=`
370
638
  color: var(--fb-error-color);
371
639
  background-color: transparent;
372
640
  transition: background-color var(--fb-transition-duration);
373
- `,z.textContent="\u2715",z.addEventListener("mouseenter",()=>{z.style.backgroundColor="var(--fb-background-hover-color)"}),z.addEventListener("mouseleave",()=>{z.style.backgroundColor="transparent"}),z.onclick=()=>{b()>m&&y(C)},C.style.position="relative",C.appendChild(z),c.appendChild(C)}if(u.appendChild(c),!i.config.readonly){const g=document.createElement("div");g.className="flex items-center gap-3 mt-2",g.appendChild(x()),g.appendChild(f),u.appendChild(g)}d(),n.appendChild(u)}let ut=null;function so(e){ut=e}function Wt(e,t,n){if(!ut)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return ut(e,t,n)}function Jt(e,t,n){const r=[],{scopeRoot:l,skipValidation:a,path:o}=n;if(!("elements"in e))return{value:null,errors:r};const s=(i,u,f)=>{var c,m;if(a)return;const{state:p}=n,h="minCount"in f&&(c=f.minCount)!=null?c:0,v="maxCount"in f&&(m=f.maxCount)!=null?m:1/0;f.required&&u.length===0&&r.push(`${i}: ${k("required",p)}`),u.length<h&&r.push(`${i}: ${k("minItems",p,{min:h})}`),u.length>v&&r.push(`${i}: ${k("maxItems",p,{max:v})}`)};if("multiple"in e&&e.multiple){const i=[],u=l.querySelectorAll("[data-container-item]");return Array.from(u).filter(f=>{const c=f.getAttribute("data-container-item")||"";if(!c.startsWith(`${t}[`))return!1;const m=c.slice(t.length);return/^\[\d+\]$/.test(m)}).forEach(f=>{const c={},m=(f.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),p=m?parseInt(m[1],10):0;e.elements.forEach(h=>{var v;if(h.enableIf)try{const d=(v=n.instance)!=null&&v.getState().formRoot?st(n.instance.getState().formRoot):{};if(!$e(h.enableIf,d,c))return}catch(d){console.error(`Error evaluating enableIf for field "${h.key}" in container "${t}[${p}]":`,d)}const b=`${t}[${p}].${h.key}`,x=Wt({...h,key:b},{path:o},f);x.spread&&x.value!==null&&typeof x.value=="object"?Object.assign(c,x.value):c[h.key]=x.value}),i.push(c)}),s(t,i,e),{value:i,errors:r}}else{const i={},u=l.querySelector(`[data-container="${t}"]`)||l;return e.elements.forEach(f=>{var c;if(f.enableIf)try{const m=(c=n.instance)!=null&&c.getState().formRoot?st(n.instance.getState().formRoot):{};if(!$e(f.enableIf,m,i))return}catch(m){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}":`,m)}{const m=`${t}.${f.key}`,p=Wt({...f,key:m},{path:o},u);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(i,p.value):i[f.key]=p.value}}),{value:i,errors:r}}}function Yt(e,t,n,r){const{instance:l,scopeRoot:a}=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((s,i)=>{je(s)&&e.elements.forEach(u=>{var f,c;const m=`${t}[${i}].${u.key}`;if(u.type==="richinput"&&u.flatOutput){const p=u,h=(f=p.textKey)!=null?f:"text",v=(c=p.filesKey)!=null?c:"files",b=s,x={};h in b&&(x[h]=b[h]),v in b&&(x[v]=b[v]),Object.keys(x).length>0&&l.updateField(m,x)}else{const p=s[u.key];p!==void 0&&l.updateField(m,p)}})});const o=a.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==o.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!je(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(o=>{var s,i;const u=`${t}.${o.key}`;if(o.type==="richinput"&&o.flatOutput){const f=o,c=(s=f.textKey)!=null?s:"text",m=(i=f.filesKey)!=null?i:"files",p=n,h={};c in p&&(h[c]=p[c]),m in p&&(h[m]=p[m]),Object.keys(h).length>0&&l.updateField(u,h)}else{const f=n[o.key];f!==void 0&&l.updateField(u,f)}})}}function co(e,t,n,r){var l,a;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 o={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&&je(e.repeat)),minCount:(l=e.repeat)==null?void 0:l.min,maxCount:(a=e.repeat)==null?void 0:a.max};o.multiple?_t(o,t,n):Kt(o,t,n,r)}function Xt(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&&je(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function uo(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=Xt(e);return Jt(r,t,n)}function po(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 l=Xt(e);return Yt(l,t,n,r)}function fo(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function mo(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 ho(e){return fo(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:mo(e)?e:null}function Te(e){return e.map(ho).filter(t=>t!==null)}function Gt(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function dt(e,t,n){for(let r=0;r<e.length;r++){const l=e[r];if(l.top<0||l.left<0||l.bottom>=t||l.right>=n||l.top>l.bottom||l.left>l.right)return`Merge ${r} out of bounds`;for(let a=r+1;a<e.length;a++){const o=e[a];if(l.top<=o.bottom&&l.bottom>=o.top&&l.left<=o.right&&l.right>=o.left)return`Merges ${r} and ${a} overlap`}}return null}function Zt(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 _e(e,t,n){var r;return(r=n.find(l=>l.top===e&&l.left===t))!=null?r:null}function xe(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 Ae(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
641
+ `,I.textContent="\u2715",I.addEventListener("mouseenter",()=>{I.style.backgroundColor="var(--fb-background-hover-color)"}),I.addEventListener("mouseleave",()=>{I.style.backgroundColor="transparent"}),I.onclick=()=>{h()>m&&C(k)},k.style.position="relative",k.appendChild(I),f.appendChild(k)}if(u.appendChild(f),!c){const E=document.createElement("div");E.className="flex items-center gap-3 mt-2",E.appendChild(g()),E.appendChild(p),u.appendChild(E)}y(),n.appendChild(u)}let Ct=null;function rr(e){Ct=e}function xn(e,t,n){if(!Ct)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ct(e,t,n)}function En(e,t,n){const o=[],{scopeRoot:r,skipValidation:l,path:i}=n;if(!("elements"in e))return{value:null,errors:o};const a=(s,c,d)=>{var u,p;if(l)return;const{state:f}=n,m="minCount"in d&&(u=d.minCount)!=null?u:0,b="maxCount"in d&&(p=d.maxCount)!=null?p:1/0;d.required&&c.length===0&&o.push(`${s}: ${$("required",f)}`),c.length<m&&o.push(`${s}: ${$("minItems",f,{min:m})}`),c.length>b&&o.push(`${s}: ${$("maxItems",f,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],c=r.querySelectorAll("[data-container-item]");return Array.from(c).filter(d=>{const u=d.getAttribute("data-container-item")||"";if(!u.startsWith(`${t}[`))return!1;const p=u.slice(t.length);return/^\[\d+\]$/.test(p)}).forEach(d=>{const u={},p=(d.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),f=p?parseInt(p[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?xt(n.instance.getState().formRoot):{};if(!Fe(m.enableIf,h,u))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${f}]":`,h)}const v=`${t}[${f}].${m.key}`,w=xn({...m,key:v},{path:i},d);w.spread&&w.value!==null&&typeof w.value=="object"?Object.assign(u,w.value):u[m.key]=w.value}),s.push(u)}),a(t,s,e),{value:s,errors:o}}else{const s={},c=r.querySelector(`[data-container="${t}"]`)||r;return e.elements.forEach(d=>{var u;if(d.enableIf)try{const p=(u=n.instance)!=null&&u.getState().formRoot?xt(n.instance.getState().formRoot):{};if(!Fe(d.enableIf,p,s))return}catch(p){console.error(`Error evaluating enableIf for field "${d.key}" in container "${t}":`,p)}{const p=`${t}.${d.key}`,f=xn({...d,key:p},{path:i},c);f.spread&&f.value!==null&&typeof f.value=="object"?Object.assign(s,f.value):s[d.key]=f.value}}),{value:s,errors:o}}}function Cn(e,t,n,o){const{instance:r,scopeRoot:l}=o;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((a,s)=>{Pe(a)&&e.elements.forEach(c=>{var d,u;const p=`${t}[${s}].${c.key}`;if(c.type==="richinput"&&c.flatOutput){const f=c,m=(d=f.textKey)!=null?d:"text",b=(u=f.filesKey)!=null?u:"files",v=a,w={};m in v&&(w[m]=v[m]),b in v&&(w[b]=v[b]),Object.keys(w).length>0&&r.updateField(p,w)}else{const f=a[c.key];f!==void 0&&r.updateField(p,f)}})});const i=l.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==i.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!Pe(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(i=>{var a,s;const c=`${t}.${i.key}`;if(i.type==="richinput"&&i.flatOutput){const d=i,u=(a=d.textKey)!=null?a:"text",p=(s=d.filesKey)!=null?s:"files",f=n,m={};u in f&&(m[u]=f[u]),p in f&&(m[p]=f[p]),Object.keys(m).length>0&&r.updateField(c,m)}else{const d=n[i.key];d!==void 0&&r.updateField(c,d)}})}}function lr(e,t,n,o){var r,l;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 i={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&&Pe(e.repeat)),minCount:(r=e.repeat)==null?void 0:r.min,maxCount:(l=e.repeat)==null?void 0:l.max};i.multiple?yn(i,t,n):gn(i,t,n,o)}function wn(e){var t,n;const o=e;return{type:"container",key:o.key,label:o.label,description:o.description,hint:o.hint,required:o.required,hidden:o.hidden,default:o.default,actions:o.actions,elements:o.elements,multiple:!!(o.repeat&&Pe(o.repeat)),minCount:(t=o.repeat)==null?void 0:t.min,maxCount:(n=o.repeat)==null?void 0:n.max}}function ir(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 o=wn(e);return En(o,t,n)}function ar(e,t,n,o){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const r=wn(e);return Cn(r,t,n,o)}function sr(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function cr(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 ur(e){return sr(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:cr(e)?e:null}function ze(e){return e.map(ur).filter(t=>t!==null)}function kn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function wt(e,t,n){for(let o=0;o<e.length;o++){const r=e[o];if(r.top<0||r.left<0||r.bottom>=t||r.right>=n||r.top>r.bottom||r.left>r.right)return`Merge ${o} out of bounds`;for(let l=o+1;l<e.length;l++){const i=e[l];if(r.top<=i.bottom&&r.bottom>=i.top&&r.left<=i.right&&r.right>=i.left)return`Merges ${o} and ${l} overlap`}}return null}function $n(e,t,n){for(const o of n){if(o.top===e&&o.left===t)return null;if(e>=o.top&&e<=o.bottom&&t>=o.left&&t<=o.right)return o}return null}function ot(e,t,n){var o;return(o=n.find(r=>r.top===e&&r.left===t))!=null?o:null}function ke(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 Me(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
374
642
  position: absolute;
375
643
  width: ${e.size}px;
376
644
  height: ${e.size}px;
@@ -390,7 +658,7 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
390
658
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
391
659
  transition: transform 0.1s, opacity 0.1s;
392
660
  pointer-events: all;
393
- `,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 vo(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const l=n[0].length,a=document.createElement("table");a.style.cssText=`
661
+ `,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 dr(e,t){const{cells:n,merges:o=[]}=e;if(n.length===0)return;const r=n[0].length,l=document.createElement("table");l.style.cssText=`
394
662
  width: 100%;
395
663
  border-collapse: collapse;
396
664
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -398,28 +666,28 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
398
666
  font-size: var(--fb-font-size);
399
667
  font-family: var(--fb-font-family);
400
668
  color: var(--fb-text-color);
401
- `,n.forEach((s,i)=>{var u,f;const c=(i===0?a.createTHead():(u=a.tBodies[0])!=null?u:a.createTBody()).insertRow();for(let m=0;m<l;m++){if(Zt(i,m,r))continue;const p=_e(i,m,r),h=document.createElement(i===0?"th":"td");if(p){const v=p.bottom-p.top+1,b=p.right-p.left+1;v>1&&(h.rowSpan=v),b>1&&(h.colSpan=b)}h.textContent=(f=s[m])!=null?f:"",h.style.cssText=`
669
+ `,n.forEach((a,s)=>{var c,d;const u=(s===0?l.createTHead():(c=l.tBodies[0])!=null?c:l.createTBody()).insertRow();for(let p=0;p<r;p++){if($n(s,p,o))continue;const f=ot(s,p,o),m=document.createElement(s===0?"th":"td");if(f){const b=f.bottom-f.top+1,v=f.right-f.left+1;b>1&&(m.rowSpan=b),v>1&&(m.colSpan=v)}m.textContent=(d=a[p])!=null?d:"",m.style.cssText=`
402
670
  padding: 6px 10px;
403
671
  border: var(--fb-border-width) solid var(--fb-border-color);
404
672
  text-align: left;
405
673
  vertical-align: top;
406
- ${i===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
407
- `,c.appendChild(h)}});const o=document.createElement("div");o.style.cssText="overflow-x: auto; max-width: 100%;",o.appendChild(a),t.appendChild(o)}function go(e,t,n,r,l,a){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const o=document.createRange(),s=window.getSelection();o.selectNodeContents(e),o.collapse(!1),s==null||s.removeAllRanges(),s==null||s.addRange(o);function i(){var c;e.contentEditable="inherit";const m=r();m[t]&&(m[t][n]=(c=e.textContent)!=null?c:""),l()}function u(c){var m,p,h,v;const b=r(),x=(p=(m=b[0])==null?void 0:m.length)!=null?p:0;if(c.key==="Escape"){e.contentEditable="inherit",e.textContent=(v=(h=b[t])==null?void 0:h[n])!=null?v:"",e.removeEventListener("keydown",u),e.removeEventListener("blur",f);return}if(c.key==="Enter"&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),i(),e.removeEventListener("keydown",u),e.removeEventListener("blur",f);const d=t+1<b.length?t+1:t;a(d,n);return}if(c.key==="Tab"){c.preventDefault(),c.stopPropagation(),i(),e.removeEventListener("keydown",u),e.removeEventListener("blur",f);let d=t,y=c.shiftKey?n-1:n+1;y<0&&(y=x-1,d=Math.max(0,t-1)),y>=x&&(y=0,d=Math.min(b.length-1,t+1)),a(d,y)}}function f(){e.contentEditable==="true"&&(i(),e.removeEventListener("keydown",u),e.removeEventListener("blur",f))}e.addEventListener("keydown",u),e.addEventListener("blur",f)}function bo(){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 yo(e,t){bo();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
674
+ ${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
675
+ `,u.appendChild(m)}});const i=document.createElement("div");i.style.cssText="overflow-x: auto; max-width: 100%;",i.appendChild(l),t.appendChild(i)}function pr(e,t,n,o,r,l){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const i=document.createRange(),a=window.getSelection();i.selectNodeContents(e),i.collapse(!1),a==null||a.removeAllRanges(),a==null||a.addRange(i);function s(){var u;e.contentEditable="inherit";const p=o();p[t]&&(p[t][n]=(u=e.textContent)!=null?u:""),r()}function c(u){var p,f,m,b;const v=o(),w=(f=(p=v[0])==null?void 0:p.length)!=null?f:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=v[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",c),e.removeEventListener("blur",d);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d);const h=t+1<v.length?t+1:t;l(h,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d);let h=t,g=u.shiftKey?n-1:n+1;g<0&&(g=w-1,h=Math.max(0,t-1)),g>=w&&(g=0,h=Math.min(v.length-1,t+1)),l(h,g)}}function d(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",d))}e.addEventListener("keydown",c),e.addEventListener("blur",d)}function fr(){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 mr(e,t){fr();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
408
676
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
409
677
  background: rgba(255,255,255,0.8); display: flex;
410
678
  align-items: center; justify-content: center; flex-direction: column;
411
679
  gap: 8px; z-index: 100;
412
- `;const r=document.createElement("div");r.style.cssText=`
680
+ `;const o=document.createElement("div");o.style.cssText=`
413
681
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
414
682
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
415
683
  animation: fb-spin 0.8s linear infinite;
416
- `;const l=document.createElement("span");return l.textContent=t,l.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(l),e.appendChild(n),n}function xo(e,t,n,r,l){var a,o,s,i,u,f,c,m;const p=r.state,h=r.instance,v=e.mergeAllowed!==!1,b=(o=(a=e.fieldNames)==null?void 0:a.cells)!=null?o:"cells",x=(i=(s=e.fieldNames)==null?void 0:s.merges)!=null?i:"merges",d=t.cells.length>0?t.cells.map(A=>[...A]):Gt((u=e.rows)!=null?u:3,(f=e.columns)!=null?f:3);let y=t.merges?[...t.merges]:[];const g={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[b]:d,[x]:y}),l.appendChild(E);function C(){E.value=JSON.stringify({[b]:d,[x]:y}),h&&h.triggerOnChange(n,{[b]:d,[x]:y})}E._applyExternalUpdate=A=>{d.length=0,A.cells.forEach(T=>d.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),g.anchor=null,g.focus=null,C(),N()};const w=document.createElement("div");w.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const S=document.createElement("table");S.style.cssText=`
684
+ `;const r=document.createElement("span");return r.textContent=t,r.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(o),n.appendChild(r),e.appendChild(n),n}function hr(e,t,n,o,r){var l,i,a,s,c,d,u,p;const f=o.state,m=o.instance,b=e.mergeAllowed!==!1,v=(i=(l=e.fieldNames)==null?void 0:l.cells)!=null?i:"cells",w=(s=(a=e.fieldNames)==null?void 0:a.merges)!=null?s:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):kn((c=e.rows)!=null?c:3,(d=e.columns)!=null?d:3);let g=t.merges?[...t.merges]:[];const y={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[v]:h,[w]:g}),r.appendChild(C);function E(){C.value=JSON.stringify({[v]:h,[w]:g}),m&&m.triggerOnChange(n,{[v]:h,[w]:g})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),g.length=0,A.merges&&A.merges.forEach(T=>g.push({...T})),y.anchor=null,y.focus=null,E(),N()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const k=document.createElement("table");k.style.cssText=`
417
685
  border-collapse: collapse;
418
686
  font-size: var(--fb-font-size);
419
687
  font-family: var(--fb-font-family);
420
688
  color: var(--fb-text-color);
421
689
  table-layout: fixed;
422
- `,w.appendChild(S);const z=(m=(c=e.importAccept)==null?void 0:c.map(A=>`.${A.toLowerCase()}`))!=null?m:[];async function Z(A){var T,L,B;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const D=yo(w,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),Q=F.cells,O=(T=F.merges)!=null?T:[];if(O.length>0){const U=dt(O,Q.length,(B=(L=Q[0])==null?void 0:L.length)!=null?B:0);if(U)throw new Error(U)}d.length=0,Q.forEach(U=>d.push([...U])),y.length=0,O.forEach(U=>y.push({...U})),g.anchor=null,g.focus=null,C(),N()}catch(F){const Q=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",Q))}finally{D.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=`
690
+ `,x.appendChild(k);const q=(p=(u=e.importAccept)==null?void 0:u.map(A=>`.${A.toLowerCase()}`))!=null?p:[];async function K(A){var T,S,B;if(!f.config.parseTableFile)return;if(q.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!q.includes(F))return}const D=mr(x,$("tableImporting",f));try{const F=await f.config.parseTableFile(A),Q=F.cells,O=(T=F.merges)!=null?T:[];if(O.length>0){const U=wt(O,Q.length,(B=(S=Q[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}h.length=0,Q.forEach(U=>h.push([...U])),g.length=0,O.forEach(U=>g.push({...U})),y.anchor=null,y.focus=null,E(),N()}catch(F){const Q=F instanceof Error?F.message:String(F);console.error($("tableImportError",f).replace("{error}",Q))}finally{D.remove()}}if(e.importAccept&&f.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=$("tableImportFile",f),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=`
423
691
  position: absolute; top: 2px; left: 2px;
424
692
  width: 20px; height: 20px;
425
693
  padding: 0;
@@ -429,7 +697,7 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
429
697
  background: transparent;
430
698
  cursor: pointer;
431
699
  z-index: 2;
432
- `,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",w.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const D=(B=T.files)==null?void 0:B[0];D&&Z(D),T.value=""}),w.appendChild(A);let L=0;w.addEventListener("dragenter",B=>{B.preventDefault(),L++,L===1&&(w.style.outline="2px dashed var(--fb-primary-color, #0066cc)",w.style.outlineOffset="-2px")}),w.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),w.addEventListener("dragleave",B=>{B.preventDefault(),L--,L<=0&&(L=0,w.style.outline="",w.style.outlineOffset="")}),w.addEventListener("drop",B=>{var D,F;B.preventDefault(),L=0,w.style.outline="",w.style.outlineOffset="";const Q=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];Q&&Z(Q)})}l.appendChild(w);const R=document.createElement("div");R.style.cssText=`
700
+ `,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=q.join(","),T.style.display="none",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const D=(B=T.files)==null?void 0:B[0];D&&K(D),T.value=""}),x.appendChild(A);let S=0;x.addEventListener("dragenter",B=>{B.preventDefault(),S++,S===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",B=>{B.preventDefault(),S--,S<=0&&(S=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",B=>{var D,F;B.preventDefault(),S=0,x.style.outline="",x.style.outlineOffset="";const Q=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];Q&&K(Q)})}r.appendChild(x);const I=document.createElement("div");I.style.cssText=`
433
701
  position: fixed;
434
702
  display: none;
435
703
  background: white;
@@ -440,7 +708,7 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
440
708
  z-index: 1000;
441
709
  gap: 4px;
442
710
  flex-direction: column;
443
- `,l.appendChild(R);function _(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
711
+ `,r.appendChild(I);function G(A,T){const S=document.createElement("button");return S.type="button",S.textContent=A,S.style.cssText=`
444
712
  padding: 4px 10px;
445
713
  font-size: var(--fb-font-size-small);
446
714
  color: var(--fb-text-color);
@@ -450,8 +718,8 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
450
718
  cursor: pointer;
451
719
  white-space: nowrap;
452
720
  text-align: left;
453
- `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{Ee(),T()}),L}function fe(A,T){if(!v)return;R.innerHTML="",R.style.display="flex";const L=xe(g),B=L&&(L.r1!==L.r2||L.c1!==L.c2),D=g.anchor&&_e(g.anchor.row,g.anchor.col,y);if(B&&R.appendChild(_(k("tableMergeCells",p),q)),D&&R.appendChild(_(k("tableSplitCell",p),M)),!R.firstChild){Ee();return}const F=140,Q=R.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=A+F>O?A-F:A,Y=T+Q>U?T-Q:T;R.style.left=`${V}px`,R.style.top=`${Y}px`}function Ee(){R.style.display="none"}const Ne=new AbortController;document.addEventListener("mousedown",A=>{if(!l.isConnected){Ne.abort();return}R.contains(A.target)||Ee()},{signal:Ne.signal});function me(){const A=xe(g);S.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),D=g.anchor!==null&&g.anchor.row===L&&g.anchor.col===B,F=A!==null&&L>=A.r1&&L<=A.r2&&B>=A.c1&&B<=A.c2;T.style.outline=D?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=D?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!D?"rgba(0,102,204,0.08)":""})}function Me(A,T){g.anchor={row:A,col:T},g.focus=null,me(),S.focus()}function Be(A,T){const L=S.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const B=L.querySelector("span");B&&(g.anchor={row:A,col:T},g.focus=null,me(),go(B,A,T,()=>d,C,Me))}function be(A){var T;const L=d.length>0?d[0].length:(T=e.columns)!=null?T:3,B=Array(L).fill(""),D=A!==void 0?A+1:d.length;d.splice(D,0,B),y=y.map(F=>F.top>=D?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<D&&F.bottom>=D?{...F,bottom:F.bottom+1}:F),C(),N()}function Qe(A){if(d.length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.row:d.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),d.splice(T,1),g.anchor&&g.anchor.row>=d.length&&(g.anchor={row:d.length-1,col:g.anchor.col}),C(),N()}function Re(A){var T,L;const B=A!==void 0?A+1:(L=(T=d[0])==null?void 0:T.length)!=null?L:0;d.forEach(D=>D.splice(B,0,"")),y=y.map(D=>D.left>=B?{...D,left:D.left+1,right:D.right+1}:D.left<B&&D.right>=B?{...D,right:D.right+1}:D),C(),N()}function $(A){if(d.length===0||d[0].length<=1)return;const T=A!==void 0?A:g.anchor?g.anchor.col:d[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),d.forEach(L=>L.splice(T,1)),g.anchor&&g.anchor.col>=d[0].length&&(g.anchor={row:g.anchor.row,col:d[0].length-1}),C(),N()}function q(){var A,T;if(!v)return;const L=xe(g);if(!L)return;const{r1:B,c1:D,r2:F,c2:Q}=L;if(B===F&&D===Q)return;y=y.filter(j=>!(j.top<=F&&j.bottom>=B&&j.left<=Q&&j.right>=D));const O=d[B][D];for(let j=B;j<=F;j++)for(let X=D;X<=Q;X++)(j!==B||X!==D)&&(d[j][X]="");d[B][D]=O;const U={top:B,left:D,bottom:F,right:Q},V=[...y,U],Y=dt(V,d.length,(T=(A=d[0])==null?void 0:A.length)!=null?T:0);if(Y){console.warn("Merge validation failed:",Y);return}y.push(U),g.anchor={row:B,col:D},g.focus=null,C(),N()}function M(){if(!v||!g.anchor)return;const{row:A,col:T}=g.anchor,L=y.findIndex(B=>B.top===A&&B.left===T);L!==-1&&(y.splice(L,1),g.focus=null,C(),N())}function N(){var A,T;S.innerHTML="";const L=d.length,B=L>0?d[0].length:0,D=xe(g);for(let F=0;F<L;F++){const Q=(F===0?(A=S.tHead)!=null?A:S.createTHead():(T=S.tBodies[0])!=null?T:S.createTBody()).insertRow();for(let O=0;O<B;O++){if(Zt(F,O,y))continue;const U=_e(F,O,y),V=document.createElement("td");if(V.setAttribute("data-row",String(F)),V.setAttribute("data-col",String(O)),U){const G=U.bottom-U.top+1,K=U.right-U.left+1;G>1&&(V.rowSpan=G),K>1&&(V.colSpan=K)}const Y=D!==null&&F>=D.r1&&F<=D.r2&&O>=D.c1&&O<=D.c2,j=g.anchor!==null&&g.anchor.row===F&&g.anchor.col===O;V.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;":"",Y&&!j?"background-color: rgba(0,102,204,0.08);":"",j?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const X=document.createElement("span");X.textContent=d[F][O],X.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",V.appendChild(X);const W=F,ne=O;V.addEventListener("mousedown",G=>{if(G.target.tagName!=="BUTTON"&&G.target.contentEditable!=="true"){if(G.button===2){const K=xe(g);if(K&&W>=K.r1&&W<=K.r2&&ne>=K.c1&&ne<=K.c2)return}G.shiftKey&&g.anchor?(G.preventDefault(),g.focus={row:W,col:ne},g.dragging=!1,me()):(g.anchor={row:W,col:ne},g.focus=null,g.dragging=!0,me())}}),V.addEventListener("mouseup",G=>{if(G.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const K=xe(g);(!K||K.r1===K.r2&&K.c1===K.c2)&&Be(W,ne)}}),V.addEventListener("mousemove",G=>{if(g.dragging&&G.buttons===1){const K=g.anchor;K&&(K.row!==W||K.col!==ne)&&(g.focus={row:W,col:ne},me())}}),V.addEventListener("contextmenu",G=>{if(!v)return;const K=xe(g),ie=K&&(K.r1!==K.r2||K.c1!==K.c2),ae=g.anchor&&_e(g.anchor.row,g.anchor.col,y);(ie||ae)&&(G.preventDefault(),fe(G.clientX,G.clientY))}),Q.appendChild(V)}}ce(),S.setAttribute("tabindex","0"),S.onkeydown=F=>{var Q,O;if(S.querySelector("[contenteditable='true']"))return;const U=g.anchor;if(!U)return;const V=d.length,Y=V>0?d[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[F.key]){F.preventDefault();const[X,W]=j[F.key],ne=Math.max(0,Math.min(V-1,U.row+X)),G=Math.max(0,Math.min(Y-1,U.col+W));F.shiftKey?(g.focus={row:ne,col:G},me()):Me(ne,G);return}if(F.key==="Enter"){F.preventDefault(),Be(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const X=(O=(Q=d[0])==null?void 0:Q.length)!=null?O:0;let W=U.row,ne=F.shiftKey?U.col-1:U.col+1;ne<0&&(ne=X-1,W=Math.max(0,W-1)),ne>=X&&(ne=0,W=Math.min(d.length-1,W+1)),Me(W,ne);return}if(v&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),q();return}v&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),M())},S.oncopy=F=>{var Q,O,U,V;const Y=xe(g);if(!Y)return;F.preventDefault();const{r1:j,c1:X,r2:W,c2:ne}=Y,G=[],K=[];for(let P=j;P<=W;P++){const le=[],ue=[];for(let de=X;de<=ne;de++){const he=(O=(Q=d[P])==null?void 0:Q[de])!=null?O:"";le.push(he);const ke=he.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ue.push(`<td>${ke}</td>`)}G.push(le.join(" ")),K.push(`<tr>${ue.join("")}</tr>`)}const ie=G.join(`
454
- `),ae=`<table>${K.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",ie),(V=F.clipboardData)==null||V.setData("text/html",ae)},S.onpaste=F=>{var Q,O,U,V,Y,j,X,W,ne;const G=g.anchor;if(!G)return;const K=(O=(Q=F.clipboardData)==null?void 0:Q.getData("text/plain"))!=null?O:"",ie=K.includes(" ")||K.split(/\r?\n/).filter(se=>se).length>1,ae=S.querySelector("[contenteditable='true']");if(ae&&!ie)return;if(F.preventDefault(),ae){ae.contentEditable="inherit";const se=parseInt((V=(U=ae.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Ce=parseInt((j=(Y=ae.closest("td"))==null?void 0:Y.getAttribute("data-col"))!=null?j:"0",10);d[se]&&(d[se][Ce]=(X=ae.textContent)!=null?X:"")}if(!K.trim())return;const P=K.split(/\r?\n/).map(se=>se.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const le=G.row,ue=G.col,de=le+P.length;for(;d.length<de;)d.push(Array((ne=(W=d[0])==null?void 0:W.length)!=null?ne:1).fill(""));const he=Math.max(...P.map(se=>se.length)),ke=ue+he;if(d[0]&&ke>d[0].length){const se=ke-d[0].length;d.forEach(Ce=>{for(let De=0;De<se;De++)Ce.push("")})}for(let se=0;se<P.length;se++)for(let Ce=0;Ce<P[se].length;Ce++){const De=le+se,Zo=ue+Ce;d[De]&&(d[De][Zo]=P[se][Ce])}C(),N()}}const H=Ae({label:"+",title:k("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);Re(T)}});H.style.position="absolute",H.style.display="none",w.appendChild(H);const I=Ae({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=I.dataset.afterRow)!=null?A:"0",10);be(T)}});I.style.position="absolute",I.style.display="none",w.appendChild(I);let ee=[],te=[];const re=Ae({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Re()});re.style.position="absolute",re.style.display="none",w.appendChild(re);const oe=Ae({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>be()});oe.style.position="absolute",oe.style.display="none",w.appendChild(oe);function ce(){var A,T;ee.forEach(O=>O.remove()),ee=[],te.forEach(O=>O.remove()),te=[];const L=d.length>0?d[0].length:0,B=d.length;if(L>1){const O=Array.from(S.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),Y=Ae({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(V)});Y.setAttribute("data-action","remove-col"),Y.setAttribute("data-col",String(V)),Y.style.position="absolute",Y.style.display="none",w.appendChild(Y),ee.push(Y)}}if(B>1){const O=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const V=U.querySelector("td[data-row]");if(!V)continue;const Y=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=Ae({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Qe(Y)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(Y)),j.style.position="absolute",j.style.display="none",w.appendChild(j),te.push(j)}}function D(O,U,V,Y,j){var X;const W=j?Array.from(S.querySelectorAll("thead td[data-col]")):[];let ne=-1,G=1/0,K=-1,ie=-1,ae=1/0;for(let P=0;P<W.length;P++){const le=W[P].getBoundingClientRect(),ue=(le.left+le.right)/2,de=Math.abs(O-ue);de<G&&(G=de,ne=P);const he=Math.abs(O-le.right);he<ae&&he<20&&(ae=he,K=le.right-U.left+Y,ie=parseInt((X=W[P].getAttribute("data-col"))!=null?X:"0",10))}ee.forEach((P,le)=>{if(!j||le!==ne){P.style.display="none";return}const ue=W[le].getBoundingClientRect(),de=(ue.left+ue.right)/2-U.left+Y;P.style.left=`${de-8}px`,P.style.top="2px",P.style.display="flex"}),j&&ie>=0?(H.style.display="flex",H.style.left=`${K-10}px`,H.style.top=`${V.top-U.top-10}px`,H.dataset.afterCol=String(ie)):H.style.display="none"}function F(O,U,V,Y,j){var X;const W=[];if(j){if(S.tHead)for(const P of Array.from(S.tHead.rows))P.querySelector("td[data-row]")&&W.push(P);if(S.tBodies[0])for(const P of Array.from(S.tBodies[0].rows))P.querySelector("td[data-row]")&&W.push(P)}let ne=-1,G=1/0,K=-1,ie=-1,ae=1/0;for(let P=0;P<W.length;P++){const le=W[P].getBoundingClientRect(),ue=(le.top+le.bottom)/2,de=Math.abs(O-ue);de<G&&(G=de,ne=P);const he=Math.abs(O-le.bottom);if(he<ae&&he<14){ae=he,K=le.bottom-U.top;const ke=W[P].querySelector("td[data-row]");ie=parseInt((X=ke==null?void 0:ke.getAttribute("data-row"))!=null?X:"0",10)}}te.forEach((P,le)=>{if(!j||le!==ne){P.style.display="none";return}const ue=W[le].getBoundingClientRect(),de=(ue.top+ue.bottom)/2-U.top;P.style.left="4px",P.style.top=`${de-8}px`,P.style.display="flex"}),j&&ie>=0?(I.style.display="flex",I.style.top=`${K-10}px`,I.style.left=`${V.left-U.left+Y-10}px`,I.dataset.afterRow=String(ie)):I.style.display="none"}let Q=!1;w.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===w||Q)return;Q=!0;const V=O.clientX,Y=O.clientY;requestAnimationFrame(()=>{Q=!1;const j=w.getBoundingClientRect(),X=S.getBoundingClientRect(),W=w.scrollLeft,ne=Y>=j.top&&Y<X.top+4,G=V>=j.left&&V<X.left+4,K=Math.min(X.right,j.right),ie=V>K-20&&V<=j.right,ae=Y>X.bottom-4&&Y<=j.bottom+20;if(D(V,j,X,W,ne),F(Y,j,X,W,G),re.style.display=ie?"flex":"none",ie&&(re.style.left=`${j.right-j.left+W-20}px`,re.style.top=`${(X.top+X.bottom)/2-j.top-10}px`),oe.style.display=ae?"flex":"none",ae){const P=(j.left+j.right)/2-j.left+W;oe.style.left=`${P-10}px`,oe.style.top=`${X.bottom-j.top-10}px`}})},w.onmouseleave=()=>{ee.forEach(O=>{O.style.display="none"}),te.forEach(O=>{O.style.display="none"}),H.style.display="none",I.style.display="none",re.style.display="none",oe.style.display="none"}}N()}function Eo(e){var t,n;return{cells:Gt((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 ft(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Co(e,t,n,r){var l,a,o,s;const i=t.state,u=t.prefill[e.key],f=(a=(l=e.fieldNames)==null?void 0:l.cells)!=null?a:"cells",c=(s=(o=e.fieldNames)==null?void 0:o.merges)!=null?s:"merges";let m;if(pt(u))m={cells:u.cells,merges:u.merges?Te(u.merges):[]};else if(u&&ft(u,f)){const p=u[c];m={cells:u[f],merges:p?Te(p):[]}}else if(pt(e.default))m={cells:e.default.cells,merges:e.default.merges?Te(e.default.merges):[]};else if(e.default&&ft(e.default,f)){const p=e.default[c];m={cells:e.default[f],merges:p?Te(p):[]}}else m=Eo(e);if(m.merges&&m.merges.length>0){const p=m.cells.length,h=p>0?m.cells[0].length:0,v=dt(m.merges,p,h);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),m={...m,merges:[]})}i.config.readonly?vo(m,n):xo(e,m,r,t,n)}function wo(e,t,n){var r,l;const{scopeRoot:a,skipValidation:o}=n,s=[],i=(l=(r=e.fieldNames)==null?void 0:r.cells)!=null?l:"cells",u=a.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let f=null;try{f=JSON.parse(u.value)}catch(c){return s.push(`${t}: invalid table data`),{value:null,errors:s}}if(!o&&e.required){const c=f[i];c!=null&&c.some(m=>m.some(p=>p.trim()!==""))||s.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:s}}function ko(e,t,n,r){var l,a,o,s;const{scopeRoot:i}=r,u=(a=(l=e.fieldNames)==null?void 0:l.cells)!=null?a:"cells",f=(s=(o=e.fieldNames)==null?void 0:o.merges)!=null?s:"merges",c=i.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let m=null;if(pt(n))m={cells:n.cells,merges:n.merges?Te(n.merges):[]};else if(n&&ft(n,u)){const p=n[f];m={cells:n[u],merges:p?Te(p):[]}}m&&c._applyExternalUpdate?c._applyExternalUpdate(m):c.value=JSON.stringify(n)}function $o(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`))};e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0)}function mt(e,t){var n,r,l,a;const o=new Map,s=new Map;for(const i of e){const u=t.resourceIndex.get(i),f=(n=u==null?void 0:u.name)!=null?n:i;s.set(f,((r=s.get(f))!=null?r:0)+1)}for(const i of e){const u=t.resourceIndex.get(i),f=(l=u==null?void 0:u.name)!=null?l:i;((a=s.get(f))!=null?a:1)>1&&u?o.set(i,`${f} (${bn(u.size)})`):o.set(i,f)}return o}function ht(e){return e?e.type.startsWith("image/"):!1}function Qt(e,t){const n=mt(e,t),r=new Map;for(const l of e){const a=n.get(l);a&&r.set(a,l)}return r}function vt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function We(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 l=r;if(r++,r<n&&e[r]==='"'){r++;let a="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(a+=e[r+1],r+=2):(a+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:l,end:r,raw:e.slice(l,r),name:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const o=e.slice(a,r);t.push({start:l,end:r,raw:e.slice(l,r),name:o})}}else r++;return t}function Lo(e,t){if(t.size===0)return[];const n=We(e),r=[];for(const l of n){const a=t.get(l.name);a&&r.push({start:l.start,end:l.end,name:l.name,rid:a})}return r}function So(e,t){const n=Lo(e,t);if(n.length===0)return e;let r="",l=0;for(const a of n)r+=e.slice(l,a.start),r+=`@${a.rid}`,l=a.end;return r+=e.slice(l),r}function en(e,t,n){const r=mt(t,n),l=new Map;for(const i of t){const u=r.get(i);u&&l.set(i,u)}const a=We(e);if(a.length===0)return e;let o="",s=0;for(const i of a){o+=e.slice(s,i.start);const u=l.get(i.name);u?o+=vt(u):o+=i.raw,s=i.end}return o+=e.slice(s),o}function tn(e,t,n,r){if(pe(e),n!=null&&n.file&&ht(n)){const l=document.createElement("img");l.alt=n.name,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=o=>{var s;l.src=((s=o.target)==null?void 0:s.result)||""},a.readAsDataURL(n.file),e.appendChild(l)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var o;if(!a||!e.isConnected)return;const s=document.createElement("img");s.alt=(o=n==null?void 0:n.name)!=null?o:t,s.src=a,s.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",pe(e),e.appendChild(s)}).catch(a=>{var o,s;(s=(o=r.config).onThumbnailError)==null||s.call(o,a,t)});const l=document.createElement("div");l.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",l.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(l)}else{const l=document.createElement("div");if(l.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;",l.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 a=document.createElement("span");a.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);",a.textContent=n.name,l.appendChild(a)}e.appendChild(l)}}function nn(e,t,n,r){if(pe(e),n!=null&&n.file&&ht(n)){const l=document.createElement("img");l.alt=n.name,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=o=>{var s;l.src=((s=o.target)==null?void 0:s.result)||""},a.readAsDataURL(n.file),e.appendChild(l)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(l=>{var a;if(!l||!e.isConnected)return;const o=document.createElement("img");o.alt=(a=n==null?void 0:n.name)!=null?a:t,o.src=l,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",pe(e),e.appendChild(o)}).catch(l=>{var a,o;(o=(a=r.config).onThumbnailError)==null||o.call(a,l,t)})}function on(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),l=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),a=n.top-r.height-8,o=n.bottom+8,s=a>=4?a:o;e.style.left=`${l}px`,e.style.top=`${Math.max(4,s)}px`}function rn(e,t,n){const r=n.resourceIndex.get(t),l=document.createElement("div");l.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",l.style.cssText=`
721
+ `,S.addEventListener("mouseenter",()=>{S.style.background="var(--fb-background-hover-color)"}),S.addEventListener("mouseleave",()=>{S.style.background="transparent"}),S.addEventListener("click",()=>{oe(),T()}),S}function Z(A,T){if(!b)return;I.innerHTML="",I.style.display="flex";const S=ke(y),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=y.anchor&&ot(y.anchor.row,y.anchor.col,g);if(B&&I.appendChild(G($("tableMergeCells",f),M)),D&&I.appendChild(G($("tableSplitCell",f),z)),!I.firstChild){oe();return}const F=140,Q=I.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=A+F>O?A-F:A,J=T+Q>U?T-Q:T;I.style.left=`${V}px`,I.style.top=`${J}px`}function oe(){I.style.display="none"}const Te=new AbortController;document.addEventListener("mousedown",A=>{if(!r.isConnected){Te.abort();return}I.contains(A.target)||oe()},{signal:Te.signal});function pe(){const A=ke(y);k.querySelectorAll("td[data-row]").forEach(T=>{const S=parseInt(T.getAttribute("data-row")||"0",10),B=parseInt(T.getAttribute("data-col")||"0",10),D=y.anchor!==null&&y.anchor.row===S&&y.anchor.col===B,F=A!==null&&S>=A.r1&&S<=A.r2&&B>=A.c1&&B<=A.c2;T.style.outline=D?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=D?"-2px":"",S===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!D?"rgba(0,102,204,0.08)":""})}function $e(A,T){y.anchor={row:A,col:T},y.focus=null,pe(),k.focus()}function je(A,T){const S=k.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(y.anchor={row:A,col:T},y.focus=null,pe(),pr(B,A,T,()=>h,E,$e))}function Ee(A){var T;const S=h.length>0?h[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),D=A!==void 0?A+1:h.length;h.splice(D,0,B),g=g.map(F=>F.top>=D?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<D&&F.bottom>=D?{...F,bottom:F.bottom+1}:F),E(),N()}function ut(A){if(h.length<=1)return;const T=A!==void 0?A:y.anchor?y.anchor.row:h.length-1;g=g.map(S=>S.top===T&&S.bottom===T?null:S.top===T?{...S,bottom:S.bottom-1}:S.bottom===T?{...S,bottom:S.bottom-1}:S.top<T&&S.bottom>T?{...S,bottom:S.bottom-1}:S.top>T?{...S,top:S.top-1,bottom:S.bottom-1}:S).filter(S=>S!==null),h.splice(T,1),y.anchor&&y.anchor.row>=h.length&&(y.anchor={row:h.length-1,col:y.anchor.col}),E(),N()}function Oe(A){var T,S;const B=A!==void 0?A+1:(S=(T=h[0])==null?void 0:T.length)!=null?S:0;h.forEach(D=>D.splice(B,0,"")),g=g.map(D=>D.left>=B?{...D,left:D.left+1,right:D.right+1}:D.left<B&&D.right>=B?{...D,right:D.right+1}:D),E(),N()}function L(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:y.anchor?y.anchor.col:h[0].length-1;g=g.map(S=>S.left===T&&S.right===T?null:S.left===T?{...S,right:S.right-1}:S.right===T?{...S,right:S.right-1}:S.left<T&&S.right>T?{...S,right:S.right-1}:S.left>T?{...S,left:S.left-1,right:S.right-1}:S).filter(S=>S!==null),h.forEach(S=>S.splice(T,1)),y.anchor&&y.anchor.col>=h[0].length&&(y.anchor={row:y.anchor.row,col:h[0].length-1}),E(),N()}function M(){var A,T;if(!b)return;const S=ke(y);if(!S)return;const{r1:B,c1:D,r2:F,c2:Q}=S;if(B===F&&D===Q)return;g=g.filter(j=>!(j.top<=F&&j.bottom>=B&&j.left<=Q&&j.right>=D));const O=h[B][D];for(let j=B;j<=F;j++)for(let Y=D;Y<=Q;Y++)(j!==B||Y!==D)&&(h[j][Y]="");h[B][D]=O;const U={top:B,left:D,bottom:F,right:Q},V=[...g,U],J=wt(V,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(J){console.warn("Merge validation failed:",J);return}g.push(U),y.anchor={row:B,col:D},y.focus=null,E(),N()}function z(){if(!b||!y.anchor)return;const{row:A,col:T}=y.anchor,S=g.findIndex(B=>B.top===A&&B.left===T);S!==-1&&(g.splice(S,1),y.focus=null,E(),N())}function N(){var A,T;k.innerHTML="";const S=h.length,B=S>0?h[0].length:0,D=ke(y);for(let F=0;F<S;F++){const Q=(F===0?(A=k.tHead)!=null?A:k.createTHead():(T=k.tBodies[0])!=null?T:k.createTBody()).insertRow();for(let O=0;O<B;O++){if($n(F,O,g))continue;const U=ot(F,O,g),V=document.createElement("td");if(V.setAttribute("data-row",String(F)),V.setAttribute("data-col",String(O)),U){const X=U.bottom-U.top+1,W=U.right-U.left+1;X>1&&(V.rowSpan=X),W>1&&(V.colSpan=W)}const J=D!==null&&F>=D.r1&&F<=D.r2&&O>=D.c1&&O<=D.c2,j=y.anchor!==null&&y.anchor.row===F&&y.anchor.col===O;V.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;":"",J&&!j?"background-color: rgba(0,102,204,0.08);":"",j?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Y=document.createElement("span");Y.textContent=h[F][O],Y.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",V.appendChild(Y);const _=F,ne=O;V.addEventListener("mousedown",X=>{if(X.target.tagName!=="BUTTON"&&X.target.contentEditable!=="true"){if(X.button===2){const W=ke(y);if(W&&_>=W.r1&&_<=W.r2&&ne>=W.c1&&ne<=W.c2)return}X.shiftKey&&y.anchor?(X.preventDefault(),y.focus={row:_,col:ne},y.dragging=!1,pe()):(y.anchor={row:_,col:ne},y.focus=null,y.dragging=!0,pe())}}),V.addEventListener("mouseup",X=>{if(X.target.tagName!=="BUTTON"&&y.dragging){y.dragging=!1;const W=ke(y);(!W||W.r1===W.r2&&W.c1===W.c2)&&je(_,ne)}}),V.addEventListener("mousemove",X=>{if(y.dragging&&X.buttons===1){const W=y.anchor;W&&(W.row!==_||W.col!==ne)&&(y.focus={row:_,col:ne},pe())}}),V.addEventListener("contextmenu",X=>{if(!b)return;const W=ke(y),ue=W&&(W.r1!==W.r2||W.c1!==W.c2),ce=y.anchor&&ot(y.anchor.row,y.anchor.col,g);(ue||ce)&&(X.preventDefault(),Z(X.clientX,X.clientY))}),Q.appendChild(V)}}fe(),k.setAttribute("tabindex","0"),k.onkeydown=F=>{var Q,O;if(k.querySelector("[contenteditable='true']"))return;const U=y.anchor;if(!U)return;const V=h.length,J=V>0?h[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[F.key]){F.preventDefault();const[Y,_]=j[F.key],ne=Math.max(0,Math.min(V-1,U.row+Y)),X=Math.max(0,Math.min(J-1,U.col+_));F.shiftKey?(y.focus={row:ne,col:X},pe()):$e(ne,X);return}if(F.key==="Enter"){F.preventDefault(),je(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const Y=(O=(Q=h[0])==null?void 0:Q.length)!=null?O:0;let _=U.row,ne=F.shiftKey?U.col-1:U.col+1;ne<0&&(ne=Y-1,_=Math.max(0,_-1)),ne>=Y&&(ne=0,_=Math.min(h.length-1,_+1)),$e(_,ne);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),M();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),z())},k.oncopy=F=>{var Q,O,U,V;const J=ke(y);if(!J)return;F.preventDefault();const{r1:j,c1:Y,r2:_,c2:ne}=J,X=[],W=[];for(let P=j;P<=_;P++){const se=[],me=[];for(let he=Y;he<=ne;he++){const ge=(O=(Q=h[P])==null?void 0:Q[he])!=null?O:"";se.push(ge);const Ae=ge.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Ae}</td>`)}X.push(se.join(" ")),W.push(`<tr>${me.join("")}</tr>`)}const ue=X.join(`
722
+ `),ce=`<table>${W.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",ue),(V=F.clipboardData)==null||V.setData("text/html",ce)},k.onpaste=F=>{var Q,O,U,V,J,j,Y,_,ne;const X=y.anchor;if(!X)return;const W=(O=(Q=F.clipboardData)==null?void 0:Q.getData("text/plain"))!=null?O:"",ue=W.includes(" ")||W.split(/\r?\n/).filter(de=>de).length>1,ce=k.querySelector("[contenteditable='true']");if(ce&&!ue)return;if(F.preventDefault(),ce){ce.contentEditable="inherit";const de=parseInt((V=(U=ce.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Le=parseInt((j=(J=ce.closest("td"))==null?void 0:J.getAttribute("data-col"))!=null?j:"0",10);h[de]&&(h[de][Le]=(Y=ce.textContent)!=null?Y:"")}if(!W.trim())return;const P=W.split(/\r?\n/).map(de=>de.split(" "));P.length>1&&P[P.length-1].length===1&&P[P.length-1][0]===""&&P.pop();const se=X.row,me=X.col,he=se+P.length;for(;h.length<he;)h.push(Array((ne=(_=h[0])==null?void 0:_.length)!=null?ne:1).fill(""));const ge=Math.max(...P.map(de=>de.length)),Ae=me+ge;if(h[0]&&Ae>h[0].length){const de=Ae-h[0].length;h.forEach(Le=>{for(let Ue=0;Ue<de;Ue++)Le.push("")})}for(let de=0;de<P.length;de++)for(let Le=0;Le<P[de].length;Le++){const Ue=se+de,_r=me+Le;h[Ue]&&(h[Ue][_r]=P[de][Le])}E(),N()}}const R=Me({label:"+",title:$("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=R.dataset.afterCol)!=null?A:"0",10);Oe(T)}});R.style.position="absolute",R.style.display="none",x.appendChild(R);const H=Me({label:"+",title:$("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=H.dataset.afterRow)!=null?A:"0",10);Ee(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);let ee=[],te=[];const ae=Me({label:"+",title:$("tableAddColumn",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Oe()});ae.style.position="absolute",ae.style.display="none",x.appendChild(ae);const ie=Me({label:"+",title:$("tableAddRow",f),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ee()});ie.style.position="absolute",ie.style.display="none",x.appendChild(ie);function fe(){var A,T;ee.forEach(O=>O.remove()),ee=[],te.forEach(O=>O.remove()),te=[];const S=h.length>0?h[0].length:0,B=h.length;if(S>1){const O=Array.from(k.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),J=Me({label:"\xD7",title:$("tableRemoveColumn",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>L(V)});J.setAttribute("data-action","remove-col"),J.setAttribute("data-col",String(V)),J.style.position="absolute",J.style.display="none",x.appendChild(J),ee.push(J)}}if(B>1){const O=[...k.tHead?Array.from(k.tHead.rows):[],...k.tBodies[0]?Array.from(k.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of O){const V=U.querySelector("td[data-row]");if(!V)continue;const J=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=Me({label:"\xD7",title:$("tableRemoveRow",f),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>ut(J)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(J)),j.style.position="absolute",j.style.display="none",x.appendChild(j),te.push(j)}}function D(O,U,V,J,j){var Y;const _=j?Array.from(k.querySelectorAll("thead td[data-col]")):[];let ne=-1,X=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.left+se.right)/2,he=Math.abs(O-me);he<X&&(X=he,ne=P);const ge=Math.abs(O-se.right);ge<ce&&ge<20&&(ce=ge,W=se.right-U.left+J,ue=parseInt((Y=_[P].getAttribute("data-col"))!=null?Y:"0",10))}ee.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.left+me.right)/2-U.left+J;P.style.left=`${he-8}px`,P.style.top="2px",P.style.display="flex"}),j&&ue>=0?(R.style.display="flex",R.style.left=`${W-10}px`,R.style.top=`${V.top-U.top-10}px`,R.dataset.afterCol=String(ue)):R.style.display="none"}function F(O,U,V,J,j){var Y;const _=[];if(j){if(k.tHead)for(const P of Array.from(k.tHead.rows))P.querySelector("td[data-row]")&&_.push(P);if(k.tBodies[0])for(const P of Array.from(k.tBodies[0].rows))P.querySelector("td[data-row]")&&_.push(P)}let ne=-1,X=1/0,W=-1,ue=-1,ce=1/0;for(let P=0;P<_.length;P++){const se=_[P].getBoundingClientRect(),me=(se.top+se.bottom)/2,he=Math.abs(O-me);he<X&&(X=he,ne=P);const ge=Math.abs(O-se.bottom);if(ge<ce&&ge<14){ce=ge,W=se.bottom-U.top;const Ae=_[P].querySelector("td[data-row]");ue=parseInt((Y=Ae==null?void 0:Ae.getAttribute("data-row"))!=null?Y:"0",10)}}te.forEach((P,se)=>{if(!j||se!==ne){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.top+me.bottom)/2-U.top;P.style.left="4px",P.style.top=`${he-8}px`,P.style.display="flex"}),j&&ue>=0?(H.style.display="flex",H.style.top=`${W-10}px`,H.style.left=`${V.left-U.left+J-10}px`,H.dataset.afterRow=String(ue)):H.style.display="none"}let Q=!1;x.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===x||Q)return;Q=!0;const V=O.clientX,J=O.clientY;requestAnimationFrame(()=>{Q=!1;const j=x.getBoundingClientRect(),Y=k.getBoundingClientRect(),_=x.scrollLeft,ne=J>=j.top&&J<Y.top+4,X=V>=j.left&&V<Y.left+4,W=Math.min(Y.right,j.right),ue=V>W-20&&V<=j.right,ce=J>Y.bottom-4&&J<=j.bottom+20;if(D(V,j,Y,_,ne),F(J,j,Y,_,X),ae.style.display=ue?"flex":"none",ue&&(ae.style.left=`${j.right-j.left+_-20}px`,ae.style.top=`${(Y.top+Y.bottom)/2-j.top-10}px`),ie.style.display=ce?"flex":"none",ce){const P=(j.left+j.right)/2-j.left+_;ie.style.left=`${P-10}px`,ie.style.top=`${Y.bottom-j.top-10}px`}})},x.onmouseleave=()=>{ee.forEach(O=>{O.style.display="none"}),te.forEach(O=>{O.style.display="none"}),R.style.display="none",H.style.display="none",ae.style.display="none",ie.style.display="none"}}N()}function vr(e){var t,n;return{cells:kn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function kt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function $t(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function br(e,t,n,o){var r,l,i,a;const s=t.state,c=le(e,s,t),d=t.prefill[e.key],u=(l=(r=e.fieldNames)==null?void 0:r.cells)!=null?l:"cells",p=(a=(i=e.fieldNames)==null?void 0:i.merges)!=null?a:"merges";let f;if(kt(d))f={cells:d.cells,merges:d.merges?ze(d.merges):[]};else if(d&&$t(d,u)){const m=d[p];f={cells:d[u],merges:m?ze(m):[]}}else if(kt(e.default))f={cells:e.default.cells,merges:e.default.merges?ze(e.default.merges):[]};else if(e.default&&$t(e.default,u)){const m=e.default[p];f={cells:e.default[u],merges:m?ze(m):[]}}else f=vr(e);if(f.merges&&f.merges.length>0){const m=f.cells.length,b=m>0?f.cells[0].length:0,v=wt(f.merges,m,b);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),f={...f,merges:[]})}c?dr(f,n):hr(e,f,o,t,n)}function gr(e,t,n){var o,r;const{scopeRoot:l,skipValidation:i}=n,a=[],s=(r=(o=e.fieldNames)==null?void 0:o.cells)!=null?r:"cells",c=l.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:a};let d=null;try{d=JSON.parse(c.value)}catch(u){return a.push(`${t}: invalid table data`),{value:null,errors:a}}if(!i&&e.required){const u=d[s];u!=null&&u.some(p=>p.some(f=>f.trim()!==""))||a.push(`${t}: ${$("required",n.state)}`)}return{value:d,errors:a}}function yr(e,t,n,o){var r,l,i,a;const{scopeRoot:s}=o,c=(l=(r=e.fieldNames)==null?void 0:r.cells)!=null?l:"cells",d=(a=(i=e.fieldNames)==null?void 0:i.merges)!=null?a:"merges",u=s.querySelector(`[name="${t}"]`);if(!u){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(kt(n))p={cells:n.cells,merges:n.merges?ze(n.merges):[]};else if(n&&$t(n,c)){const f=n[d];p={cells:n[c],merges:f?ze(f):[]}}p&&u._applyExternalUpdate?u._applyExternalUpdate(p):u.value=JSON.stringify(n)}function xr(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 o=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};e.addEventListener("input",o),setTimeout(()=>{e.isConnected&&o()},0)}function Lt(e,t){var n,o,r,l;const i=new Map,a=new Map;for(const s of e){const c=t.resourceIndex.get(s),d=(n=c==null?void 0:c.name)!=null?n:s;a.set(d,((o=a.get(d))!=null?o:0)+1)}for(const s of e){const c=t.resourceIndex.get(s),d=(r=c==null?void 0:c.name)!=null?r:s;((l=a.get(d))!=null?l:1)>1&&c?i.set(s,`${d} (${Vn(c.size)})`):i.set(s,d)}return i}function St(e){return e?e.type.startsWith("image/"):!1}function Ln(e,t){const n=Lt(e,t),o=new Map;for(const r of e){const l=n.get(r);l&&o.set(l,r)}return o}function Tt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function rt(e){const t=[],n=e.length;let o=0;for(;o<n;)if(e[o]==="@"){if(o>0&&!/\s/.test(e[o-1])){o++;continue}const r=o;if(o++,o<n&&e[o]==='"'){o++;let l="";for(;o<n&&e[o]!=='"';)e[o]==="\\"&&o+1<n?(l+=e[o+1],o+=2):(l+=e[o],o++);o<n&&e[o]==='"'&&(o++,(o>=n||/\s/.test(e[o]))&&t.push({start:r,end:o,raw:e.slice(r,o),name:l}))}else if(o<n&&!/\s/.test(e[o])){const l=o;for(;o<n&&!/\s/.test(e[o]);)o++;const i=e.slice(l,o);t.push({start:r,end:o,raw:e.slice(r,o),name:i})}}else o++;return t}function Er(e,t){if(t.size===0)return[];const n=rt(e),o=[];for(const r of n){const l=t.get(r.name);l&&o.push({start:r.start,end:r.end,name:r.name,rid:l})}return o}function Cr(e,t){const n=Er(e,t);if(n.length===0)return e;let o="",r=0;for(const l of n)o+=e.slice(r,l.start),o+=`@${l.rid}`,r=l.end;return o+=e.slice(r),o}function Sn(e,t,n){const o=Lt(t,n),r=new Map;for(const s of t){const c=o.get(s);c&&r.set(s,c)}const l=rt(e);if(l.length===0)return e;let i="",a=0;for(const s of l){i+=e.slice(a,s.start);const c=r.get(s.name);c?i+=Tt(c):i+=s.raw,a=s.end}return i+=e.slice(a),i}function Tn(e,t,n,o){if(ve(e),n!=null&&n.file&&St(n)){const r=document.createElement("img");r.alt=n.name,r.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const l=new FileReader;l.onload=i=>{var a;r.src=((a=i.target)==null?void 0:a.result)||""},l.readAsDataURL(n.file),e.appendChild(r)}else if(o.config.getThumbnail){o.config.getThumbnail(t).then(l=>{var i;if(!l||!e.isConnected)return;const a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=l,a.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ve(e),e.appendChild(a)}).catch(l=>{var i,a;(a=(i=o.config).onThumbnailError)==null||a.call(i,l,t)});const r=document.createElement("div");r.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",r.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(r)}else{const r=document.createElement("div");if(r.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;",r.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 l=document.createElement("span");l.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);",l.textContent=n.name,r.appendChild(l)}e.appendChild(r)}}function An(e,t,n,o){if(ve(e),n!=null&&n.file&&St(n)){const r=document.createElement("img");r.alt=n.name,r.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const l=new FileReader;l.onload=i=>{var a;r.src=((a=i.target)==null?void 0:a.result)||""},l.readAsDataURL(n.file),e.appendChild(r)}else o.config.getThumbnail&&o.config.getThumbnail(t).then(r=>{var l;if(!r||!e.isConnected)return;const i=document.createElement("img");i.alt=(l=n==null?void 0:n.name)!=null?l:t,i.src=r,i.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ve(e),e.appendChild(i)}).catch(r=>{var l,i;(i=(l=o.config).onThumbnailError)==null||i.call(l,r,t)})}function Fn(e,t){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect(),r=Math.max(4,Math.min(n.left+n.width/2-o.width/2,window.innerWidth-o.width-4)),l=n.top-o.height-8,i=n.bottom+8,a=l>=4?l:i;e.style.left=`${r}px`,e.style.top=`${Math.max(4,a)}px`}function Nn(e,t,n){const o=n.resourceIndex.get(t),r=document.createElement("div");r.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",r.style.cssText=`
455
723
  position: fixed;
456
724
  z-index: 99999;
457
725
  background: #fff;
@@ -462,7 +730,7 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
462
730
  pointer-events: none;
463
731
  min-width: 60px;
464
732
  max-width: 140px;
465
- `;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",nn(a,t,r,n),l.appendChild(a),document.body.appendChild(l),on(l,e),l}function ln(e,t){var n,r;const{rid:l,state:a,isReadonly:o,onMention:s,onRemove:i}=t,u=a.resourceIndex.get(l),f=(n=u==null?void 0:u.name)!=null?n:l,c=document.createElement("div");c.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",c.style.cssText=`
733
+ `;const l=document.createElement("div");return l.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",An(l,t,o,n),r.appendChild(l),document.body.appendChild(r),Fn(r,e),r}function zn(e,t){var n,o;const{rid:r,state:l,isReadonly:i,onMention:a,onRemove:s}=t,c=l.resourceIndex.get(r),d=(n=c==null?void 0:c.name)!=null?n:r,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
466
734
  position: fixed;
467
735
  z-index: 99999;
468
736
  background: #fff;
@@ -473,17 +741,17 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
473
741
  pointer-events: auto;
474
742
  min-width: 80px;
475
743
  max-width: 260px;
476
- `;const m=document.createElement("div");m.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",nn(m,l,u,a),c.appendChild(m);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=f,c.appendChild(p);const h=document.createElement("div");h.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 v="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;",b=d=>{d.style.background="var(--fb-background-hover-color, #f3f4f6)",d.style.color="var(--fb-text-color, #111827)"},x=d=>{d.style.background="none",d.style.color="var(--fb-text-muted-color, #6b7280)"};if(!o&&s){const d=document.createElement("button");d.type="button",d.title="Mention",d.style.cssText=v,d.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>',d.addEventListener("mouseenter",()=>b(d)),d.addEventListener("mouseleave",()=>x(d)),d.addEventListener("click",y=>{y.stopPropagation(),s(),c.remove()}),h.appendChild(d)}if(a.config.downloadFile){const d=document.createElement("button");d.type="button",d.title="Download",d.style.cssText=v,d.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>',d.addEventListener("mouseenter",()=>b(d)),d.addEventListener("mouseleave",()=>x(d)),d.addEventListener("click",y=>{var g,E;y.stopPropagation(),(E=(g=a.config).downloadFile)==null||E.call(g,l,f)}),h.appendChild(d)}if((r=a.config.getDownloadUrl)!=null?r:a.config.getThumbnail){const d=document.createElement("button");d.type="button",d.title="Open in new window",d.style.cssText=v,d.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>',d.addEventListener("mouseenter",()=>b(d)),d.addEventListener("mouseleave",()=>x(d)),d.addEventListener("click",y=>{var g,E,C,w;if(y.stopPropagation(),a.config.getDownloadUrl){const S=a.config.getDownloadUrl(l);S?window.open(S,"_blank"):(E=(g=a.config).getThumbnail)==null||E.call(g,l).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(w=(C=a.config).getThumbnail)==null||w.call(C,l).then(S=>{S&&window.open(S,"_blank")}).catch(()=>{})}),h.appendChild(d)}if(!o&&i){const d=document.createElement("button");d.type="button",d.title="Remove",d.style.cssText=v,d.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>',d.addEventListener("mouseenter",()=>{d.style.background="var(--fb-background-hover-color, #f3f4f6)",d.style.color="var(--fb-error-color, #ef4444)"}),d.addEventListener("mouseleave",()=>x(d)),d.addEventListener("click",y=>{y.stopPropagation(),c.remove(),i()}),h.appendChild(d)}return h.children.length>0&&c.appendChild(h),document.body.appendChild(c),on(c,e),c}function an(){return{element:null,hideTimer:null}}function Je(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function Ye(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Fe(e){return e&&e.remove(),null}function To(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let l=r.length-1;l>=0;l--)if(r[l]==="@"){if(l===0||/\s/.test(r[l-1])){let a=r.slice(l+1);return a.startsWith('"')&&(a=a.slice(1)),{query:a,pos:l}}return null}return null}function sn(e,t,n){const r=e.toLowerCase();return t.filter(l=>{var a;return((a=n.get(l))!=null?a:l).toLowerCase().includes(r)})}const Xe="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",cn="padding: 12px 52px 12px 14px;";function Ao(e,t,n,r,l){var a;const o=t.state,s=[...l.files],i={open:!1,query:"",triggerPos:-1,selectedIndex:0},u=new AbortController,f=document.createElement("input");f.type="hidden",f.name=r;function c(){var $,q;const M=w.value,N=Qt(s,o),H=M?So(M,N):null,I=($=e.textKey)!=null?$:"text",ee=(q=e.filesKey)!=null?q:"files";return{[I]:M===""?null:H,[ee]:[...s]}}function m(){f.value=JSON.stringify(c())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
744
+ `;const p=document.createElement("div");p.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",An(p,r,c,l),u.appendChild(p);const f=document.createElement("div");f.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);",f.textContent=d,u.appendChild(f);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;",v=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},w=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!i&&a){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",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",g=>{g.stopPropagation(),a(),u.remove()}),m.appendChild(h)}if(l.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",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",g=>{var y,C;g.stopPropagation(),(C=(y=l.config).downloadFile)==null||C.call(y,r,d)}),m.appendChild(h)}if((o=l.config.getDownloadUrl)!=null?o:l.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",()=>v(h)),h.addEventListener("mouseleave",()=>w(h)),h.addEventListener("click",g=>{var y,C,E,x;if(g.stopPropagation(),l.config.getDownloadUrl){const k=l.config.getDownloadUrl(r);k?window.open(k,"_blank"):(C=(y=l.config).getThumbnail)==null||C.call(y,r).then(q=>{q&&window.open(q,"_blank")}).catch(()=>{})}else(x=(E=l.config).getThumbnail)==null||x.call(E,r).then(k=>{k&&window.open(k,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!i&&s){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",()=>w(h)),h.addEventListener("click",g=>{g.stopPropagation(),u.remove(),s()}),m.appendChild(h)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),Fn(u,e),u}function Mn(){return{element:null,hideTimer:null}}function lt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function it(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function qe(e){return e&&e.remove(),null}function wr(e){var t;const n=(t=e.selectionStart)!=null?t:0,o=e.value.slice(0,n);for(let r=o.length-1;r>=0;r--)if(o[r]==="@"){if(r===0||/\s/.test(o[r-1])){let l=o.slice(r+1);return l.startsWith('"')&&(l=l.slice(1)),{query:l,pos:r}}return null}return null}function qn(e,t,n){const o=e.toLowerCase();return t.filter(r=>{var l;return((l=n.get(r))!=null?l:r).toLowerCase().includes(o)})}const at="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Rn="padding: 12px 52px 12px 14px;";function kr(e,t,n,o,r){var l;const i=t.state,a=[...r.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,d=document.createElement("input");d.type="hidden",d.name=o;function u(){var L,M;const z=x.value,N=Ln(a,i),R=z?Cr(z,N):null,H=(L=e.textKey)!=null?L:"text",ee=(M=e.filesKey)!=null?M:"files";return{[H]:z===""?null:R,[ee]:[...a]}}function p(){d.value=JSON.stringify(u())}const f=document.createElement("div");f.className="fb-richinput-wrapper",f.style.cssText=`
477
745
  position: relative;
478
746
  border: 1px solid var(--fb-border-color, #d1d5db);
479
747
  border-radius: 16px;
480
748
  background: var(--fb-background-color, #f9fafb);
481
749
  transition: box-shadow 0.15s, border-color 0.15s;
482
- `,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 h=document.createElement("div");h.className="fb-richinput-error",h.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 14px 8px;";let v=null;function b($){h.textContent=$,h.style.display="block",v&&clearTimeout(v),v=setTimeout(()=>{h.style.display="none",h.textContent="",v=null},5e3)}function x($){var q;const M=He(e.accept);if(!we($.name,M)){const H=M.join(", ");return b(k("invalidFileExtension",o,{name:$.name,formats:H})),!1}const N=(q=e.maxSize)!=null?q:1/0;return Le($,N)?!0:(b(k("fileTooLarge",o,{name:$.name,maxSize:N})),!1)}let d=0;p.addEventListener("dragenter",$=>{$.preventDefault(),d++,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(),d--,d<=0&&(d=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",$=>{var q,M;$.preventDefault(),d=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const N=(q=$.dataTransfer)==null?void 0:q.files;if(!N||!o.config.uploadFile)return;const H=(M=e.maxFiles)!=null?M:1/0;for(let I=0;I<N.length;I++){if(s.length>=H){b(k("filesLimitExceeded",o,{skipped:N.length-I,max:H}));break}x(N[I])&&Qe(N[I])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; align-items: center;";const g=document.createElement("input");g.type="file",g.multiple=!0,g.style.display="none",e.accept&&(typeof e.accept=="string"?g.accept=e.accept:g.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const E=document.createElement("div");E.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
750
+ `,f.addEventListener("focusin",()=>{f.style.borderColor="var(--fb-primary-color, #0066cc)",f.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),f.addEventListener("focusout",()=>{f.style.borderColor="var(--fb-border-color, #d1d5db)",f.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 14px 8px;";let b=null;function v(L){m.textContent=L,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function w(L){var M;const z=He(e.accept);if(!Be(L.name,z)){const R=z.join(", ");return v($("invalidFileExtension",i,{name:L.name,formats:R})),!1}const N=(M=e.maxSize)!=null?M:1/0;return Ke(L,N)?!0:(v($("fileTooLarge",i,{name:L.name,maxSize:N})),!1)}let h=0;f.addEventListener("dragenter",L=>{L.preventDefault(),h++,f.style.borderColor="var(--fb-primary-color, #0066cc)",f.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),f.addEventListener("dragover",L=>{L.preventDefault()}),f.addEventListener("dragleave",L=>{L.preventDefault(),h--,h<=0&&(h=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none")}),f.addEventListener("drop",L=>{var M,z;L.preventDefault(),h=0,f.style.borderColor="var(--fb-border-color, #d1d5db)",f.style.boxShadow="none";const N=(M=L.dataTransfer)==null?void 0:M.files;if(!N||!i.config.uploadFile)return;const R=(z=e.maxFiles)!=null?z:1/0;for(let H=0;H<N.length;H++){if(a.length>=R){v($("filesLimitExceeded",i,{skipped:N.length-H,max:R}));break}w(N[H])&&ut(N[H])}});const g=document.createElement("div");g.className="fb-richinput-files",g.style.cssText="display: none; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; align-items: center;";const y=document.createElement("input");y.type="file",y.multiple=!0,y.style.display="none",e.accept&&(typeof e.accept=="string"?y.accept=e.accept:y.accept=e.accept.extensions.map(L=>L.startsWith(".")?L:`.${L}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const E=document.createElement("div");E.className="fb-richinput-backdrop",E.style.cssText=`
483
751
  position: absolute;
484
752
  top: 0; left: 0; right: 0; bottom: 0;
485
- ${cn}
486
- ${Xe}
753
+ ${Rn}
754
+ ${at}
487
755
  white-space: pre-wrap;
488
756
  word-break: break-word;
489
757
  color: transparent;
@@ -492,10 +760,10 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
492
760
  border-radius: inherit;
493
761
  box-sizing: border-box;
494
762
  z-index: 2;
495
- `;const w=document.createElement("textarea");w.name=`${r}__text`,w.placeholder=e.placeholder||k("richinputPlaceholder",o);const S=(a=l.text)!=null?a:"";w.value=S?en(S,s,o):"",w.style.cssText=`
763
+ `;const x=document.createElement("textarea");x.name=`${o}__text`,x.placeholder=e.placeholder||$("richinputPlaceholder",i);const k=(l=r.text)!=null?l:"";x.value=k?Sn(k,a,i):"",x.style.cssText=`
496
764
  width: 100%;
497
- ${cn}
498
- ${Xe}
765
+ ${Rn}
766
+ ${at}
499
767
  background: transparent;
500
768
  border: none;
501
769
  outline: none;
@@ -505,9 +773,9 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
505
773
  position: relative;
506
774
  z-index: 1;
507
775
  caret-color: var(--fb-text-color, #111827);
508
- `,$o(w,C),w.addEventListener("scroll",()=>{C.scrollTop=w.scrollTop});let z=null;C.addEventListener("mouseover",$=>{var q,M;const N=(M=(q=$.target).closest)==null?void 0:M.call(q,"mark");N!=null&&N.dataset.rid&&(z=Fe(z),z=rn(N,N.dataset.rid,o))}),C.addEventListener("mouseout",$=>{var q,M,N;if(!((M=(q=$.target).closest)!=null&&M.call(q,"mark")))return;const H=$.relatedTarget;(N=H==null?void 0:H.closest)!=null&&N.call(H,"mark")||(z=Fe(z))}),C.addEventListener("mousedown",$=>{var q,M;if(!((M=(q=$.target).closest)!=null&&M.call(q,"mark")))return;z=Fe(z);const N=C.querySelectorAll("mark");N.forEach(I=>I.style.pointerEvents="none");const H=document.elementFromPoint($.clientX,$.clientY);H&&H.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{N.forEach(I=>I.style.pointerEvents="auto")},{once:!0})});function Z(){const $=w.value,q=Qt(s,o),M=We($);if(M.length===0){C.innerHTML=J($)+`
509
- `;return}let N="",H=0;for(const I of M){N+=J($.slice(H,I.start));const ee=q.get(I.name);ee?N+=`<mark data-rid="${J(ee)}" 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;">${J($.slice(I.start,I.end))}</mark>`:N+=`<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;">${J($.slice(I.start,I.end))}</mark>`,H=I.end}N+=J($.slice(H)),C.innerHTML=N+`
510
- `}const R=document.createElement("button");R.type="button",R.title=k("richinputAttachFile",o),R.style.cssText=`
776
+ `,xr(x,E),x.addEventListener("scroll",()=>{E.scrollTop=x.scrollTop});let q=null;E.addEventListener("mouseover",L=>{var M,z;const N=(z=(M=L.target).closest)==null?void 0:z.call(M,"mark");N!=null&&N.dataset.rid&&(q=qe(q),q=Nn(N,N.dataset.rid,i))}),E.addEventListener("mouseout",L=>{var M,z,N;if(!((z=(M=L.target).closest)!=null&&z.call(M,"mark")))return;const R=L.relatedTarget;(N=R==null?void 0:R.closest)!=null&&N.call(R,"mark")||(q=qe(q))}),E.addEventListener("mousedown",L=>{var M,z;if(!((z=(M=L.target).closest)!=null&&z.call(M,"mark")))return;q=qe(q);const N=E.querySelectorAll("mark");N.forEach(H=>H.style.pointerEvents="none");const R=document.elementFromPoint(L.clientX,L.clientY);R&&R.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:L.clientX,clientY:L.clientY,button:L.button,buttons:L.buttons,detail:L.detail})),document.addEventListener("mouseup",()=>{N.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function K(){const L=x.value,M=Ln(a,i),z=rt(L);if(z.length===0){E.innerHTML=re(L)+`
777
+ `;return}let N="",R=0;for(const H of z){N+=re(L.slice(R,H.start));const ee=M.get(H.name);ee?N+=`<mark data-rid="${re(ee)}" 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;">${re(L.slice(H.start,H.end))}</mark>`:N+=`<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;">${re(L.slice(H.start,H.end))}</mark>`,R=H.end}N+=re(L.slice(R)),E.innerHTML=N+`
778
+ `}const I=document.createElement("button");I.type="button",I.title=$("richinputAttachFile",i),I.style.cssText=`
511
779
  position: absolute;
512
780
  right: 10px;
513
781
  bottom: 10px;
@@ -523,7 +791,7 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
523
791
  justify-content: center;
524
792
  color: var(--fb-text-muted-color, #9ca3af);
525
793
  transition: color 0.15s, background 0.15s;
526
- `,R.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>',R.addEventListener("mouseenter",()=>{R.style.color="var(--fb-primary-color, #0066cc)",R.style.background="var(--fb-background-hover-color, #f3f4f6)"}),R.addEventListener("mouseleave",()=>{R.style.color="var(--fb-text-muted-color, #9ca3af)",R.style.background="transparent"}),R.addEventListener("click",()=>{var $;const q=($=e.maxFiles)!=null?$:1/0;if(s.length>=q){b(k("filesLimitExceeded",o,{skipped:1,max:q}));return}g.click()});const _=document.createElement("div");_.className="fb-richinput-dropdown",_.style.cssText=`
794
+ `,I.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>',I.addEventListener("mouseenter",()=>{I.style.color="var(--fb-primary-color, #0066cc)",I.style.background="var(--fb-background-hover-color, #f3f4f6)"}),I.addEventListener("mouseleave",()=>{I.style.color="var(--fb-text-muted-color, #9ca3af)",I.style.background="transparent"}),I.addEventListener("click",()=>{var L;const M=(L=e.maxFiles)!=null?L:1/0;if(a.length>=M){v($("filesLimitExceeded",i,{skipped:1,max:M}));return}y.click()});const G=document.createElement("div");G.className="fb-richinput-dropdown",G.style.cssText=`
527
795
  display: none;
528
796
  position: absolute;
529
797
  bottom: 100%;
@@ -538,16 +806,16 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
538
806
  max-height: 200px;
539
807
  overflow-y: auto;
540
808
  margin-bottom: 4px;
541
- ${Xe}
542
- `;function fe(){return mt(s,o)}function Ee($){pe(_);const q=fe();if($.length===0){_.style.display="none",i.open=!1;return}$.forEach((M,N)=>{var H;const I=o.resourceIndex.get(M),ee=document.createElement("div");ee.className="fb-richinput-dropdown-item",ee.dataset.rid=M,ee.style.cssText=`
809
+ ${at}
810
+ `;function Z(){return Lt(a,i)}function oe(L){ve(G);const M=Z();if(L.length===0){G.style.display="none",s.open=!1;return}L.forEach((z,N)=>{var R;const H=i.resourceIndex.get(z),ee=document.createElement("div");ee.className="fb-richinput-dropdown-item",ee.dataset.rid=z,ee.style.cssText=`
543
811
  padding: 5px 10px;
544
812
  cursor: pointer;
545
813
  color: var(--fb-text-color, #111827);
546
- background: ${N===i.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
814
+ background: ${N===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
547
815
  display: flex;
548
816
  align-items: center;
549
817
  gap: 8px;
550
- `;const te=document.createElement("div");if(te.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;",I!=null&&I.file&&ht(I)){const oe=document.createElement("img");oe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const ce=new FileReader;ce.onload=A=>{var T;oe.src=((T=A.target)==null?void 0:T.result)||""},ce.readAsDataURL(I.file),te.appendChild(oe)}else o.config.getThumbnail&&o.config.getThumbnail(M).then(oe=>{if(!oe||!te.isConnected)return;const ce=document.createElement("img");ce.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ce.src=oe,pe(te),te.appendChild(ce)}).catch(()=>{}),te.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>';ee.appendChild(te);const re=document.createElement("span");re.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",re.textContent=(H=q.get(M))!=null?H:M,ee.appendChild(re),_.appendChild(ee)}),_.onmousemove=M=>{var N,H,I;const ee=(H=(N=M.target).closest)==null?void 0:H.call(N,".fb-richinput-dropdown-item");if(!ee)return;const te=$.indexOf((I=ee.dataset.rid)!=null?I:"");te===-1||te===i.selectedIndex||(_.querySelectorAll(".fb-richinput-dropdown-item").forEach((re,oe)=>{re.style.background=oe===te?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),i.selectedIndex=te)},_.onmousedown=M=>{var N,H;M.preventDefault(),M.stopPropagation();const I=(H=(N=M.target).closest)==null?void 0:H.call(N,".fb-richinput-dropdown-item");I!=null&&I.dataset.rid&&Me(I.dataset.rid)},_.style.display="block",i.open=!0}function Ne(){const $=To(w);if(!$){me();return}i.query=$.query,i.triggerPos=$.pos,i.selectedIndex=0;const q=fe(),M=sn($.query,s,q);Ee(M)}function me(){_.style.display="none",i.open=!1}function Me($){var q,M,N,H;const I=(N=(M=fe().get($))!=null?M:(q=o.resourceIndex.get($))==null?void 0:q.name)!=null?N:$,ee=(H=w.selectionStart)!=null?H:0,te=w.value.slice(0,i.triggerPos),re=w.value.slice(ee),oe=`${vt(I)} `;w.value=`${te}${oe}${re}`;const ce=te.length+oe.length;w.setSelectionRange(ce,ce),w.dispatchEvent(new Event("input")),me()}w.addEventListener("input",()=>{var $;Z(),m(),($=t.instance)==null||$.triggerOnChange(r,c()),s.length>0?Ne():me()});function Be(){_.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,q)=>{$.style.background=q===i.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}w.addEventListener("keydown",$=>{if(!i.open)return;const q=fe(),M=sn(i.query,s,q);$.key==="ArrowDown"?($.preventDefault(),i.selectedIndex=Math.min(i.selectedIndex+1,M.length-1),Be()):$.key==="ArrowUp"?($.preventDefault(),i.selectedIndex=Math.max(i.selectedIndex-1,0),Be()):$.key==="Enter"&&M.length>0?($.preventDefault(),Me(M[i.selectedIndex])):$.key==="Escape"&&me()}),document.addEventListener("click",$=>{!p.contains($.target)&&!_.contains($.target)&&me()},{signal:u.signal});function be(){if(pe(y),s.length===0){y.style.display="none";return}y.style.display="flex",s.forEach($=>{const q=o.resourceIndex.get($),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
818
+ `;const te=document.createElement("div");if(te.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&&St(H)){const ie=document.createElement("img");ie.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const fe=new FileReader;fe.onload=A=>{var T;ie.src=((T=A.target)==null?void 0:T.result)||""},fe.readAsDataURL(H.file),te.appendChild(ie)}else i.config.getThumbnail&&i.config.getThumbnail(z).then(ie=>{if(!ie||!te.isConnected)return;const fe=document.createElement("img");fe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",fe.src=ie,ve(te),te.appendChild(fe)}).catch(()=>{}),te.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>';ee.appendChild(te);const ae=document.createElement("span");ae.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ae.textContent=(R=M.get(z))!=null?R:z,ee.appendChild(ae),G.appendChild(ee)}),G.onmousemove=z=>{var N,R,H;const ee=(R=(N=z.target).closest)==null?void 0:R.call(N,".fb-richinput-dropdown-item");if(!ee)return;const te=L.indexOf((H=ee.dataset.rid)!=null?H:"");te===-1||te===s.selectedIndex||(G.querySelectorAll(".fb-richinput-dropdown-item").forEach((ae,ie)=>{ae.style.background=ie===te?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),s.selectedIndex=te)},G.onmousedown=z=>{var N,R;z.preventDefault(),z.stopPropagation();const H=(R=(N=z.target).closest)==null?void 0:R.call(N,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&$e(H.dataset.rid)},G.style.display="block",s.open=!0}function Te(){const L=wr(x);if(!L){pe();return}s.query=L.query,s.triggerPos=L.pos,s.selectedIndex=0;const M=Z(),z=qn(L.query,a,M);oe(z)}function pe(){G.style.display="none",s.open=!1}function $e(L){var M,z,N,R;const H=(N=(z=Z().get(L))!=null?z:(M=i.resourceIndex.get(L))==null?void 0:M.name)!=null?N:L,ee=(R=x.selectionStart)!=null?R:0,te=x.value.slice(0,s.triggerPos),ae=x.value.slice(ee),ie=`${Tt(H)} `;x.value=`${te}${ie}${ae}`;const fe=te.length+ie.length;x.setSelectionRange(fe,fe),x.dispatchEvent(new Event("input")),pe()}x.addEventListener("input",()=>{var L;K(),p(),(L=t.instance)==null||L.triggerOnChange(o,u()),a.length>0?Te():pe()});function je(){G.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,M)=>{L.style.background=M===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",L=>{if(!s.open)return;const M=Z(),z=qn(s.query,a,M);L.key==="ArrowDown"?(L.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,z.length-1),je()):L.key==="ArrowUp"?(L.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),je()):L.key==="Enter"&&z.length>0?(L.preventDefault(),$e(z[s.selectedIndex])):L.key==="Escape"&&pe()}),document.addEventListener("click",L=>{!f.contains(L.target)&&!G.contains(L.target)&&pe()},{signal:c.signal});function Ee(){if(ve(g),a.length===0){g.style.display="none";return}g.style.display="flex",a.forEach(L=>{const M=i.resourceIndex.get(L),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
551
819
  position: relative;
552
820
  width: 48px;
553
821
  height: 48px;
@@ -557,14 +825,14 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
557
825
  flex-shrink: 0;
558
826
  cursor: pointer;
559
827
  background: #fff;
560
- `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",tn(N,$,q,o),M.appendChild(N);const H=an(),I=()=>{var te,re,oe;const ce=(te=w.selectionStart)!=null?te:w.value.length,A=(oe=(re=fe().get($))!=null?re:q==null?void 0:q.name)!=null?oe:$,T=w.value.slice(0,ce),L=w.value.slice(ce),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
561
- `:""}${vt(A)} `;w.value=`${T}${B}${L}`;const D=ce+B.length;w.setSelectionRange(D,D),w.focus(),w.dispatchEvent(new Event("input"))},ee=()=>{var te;const re=s.indexOf($);re!==-1&&s.splice(re,1),be(),Z(),m(),(te=t.instance)==null||te.triggerOnChange(r,c())};M.addEventListener("mouseenter",()=>{Ye(H),H.element||(H.element=ln(M,{rid:$,state:o,isReadonly:!1,onMention:I,onRemove:ee}),H.element.addEventListener("mouseenter",()=>{Ye(H)}),H.element.addEventListener("mouseleave",()=>{Je(H)}))}),M.addEventListener("mouseleave",()=>{Je(H)}),y.appendChild(M)})}function Qe($){if(!o.config.uploadFile)return;const q=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;o.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),s.push(q),be();const M=y.querySelectorAll(".fb-richinput-file-thumb"),N=M[M.length-1];N&&(N.style.opacity="0.5"),o.config.uploadFile($).then(H=>{var I;const ee=s.indexOf(q);ee!==-1&&(s[ee]=H),o.resourceIndex.delete(q),o.resourceIndex.set(H,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),be(),Z(),m(),(I=t.instance)==null||I.triggerOnChange(r,c())}).catch(H=>{var I,ee;const te=s.indexOf(q);te!==-1&&s.splice(te,1),o.resourceIndex.delete(q),be(),(ee=(I=o.config).onUploadError)==null||ee.call(I,H,$)})}if(g.addEventListener("change",()=>{var $;const q=g.files;if(!q||q.length===0)return;const M=($=e.maxFiles)!=null?$:1/0;for(let N=0;N<q.length;N++){if(s.length>=M){b(k("filesLimitExceeded",o,{skipped:q.length-N,max:M}));break}x(q[N])&&Qe(q[N])}g.value=""}),E.appendChild(C),E.appendChild(w),E.appendChild(R),E.appendChild(_),p.appendChild(y),p.appendChild(E),p.appendChild(h),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 14px 6px; text-align: right;";const q=ze(e,w,!1);q.style.cssText=`
828
+ `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Tn(N,L,M,i),z.appendChild(N);const R=Mn(),H=()=>{var te,ae,ie;const fe=(te=x.selectionStart)!=null?te:x.value.length,A=(ie=(ae=Z().get(L))!=null?ae:M==null?void 0:M.name)!=null?ie:L,T=x.value.slice(0,fe),S=x.value.slice(fe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
829
+ `:""}${Tt(A)} `;x.value=`${T}${B}${S}`;const D=fe+B.length;x.setSelectionRange(D,D),x.focus(),x.dispatchEvent(new Event("input"))},ee=()=>{var te;const ae=a.indexOf(L);ae!==-1&&a.splice(ae,1),Ee(),K(),p(),(te=t.instance)==null||te.triggerOnChange(o,u())};z.addEventListener("mouseenter",()=>{it(R),R.element||(R.element=zn(z,{rid:L,state:i,isReadonly:!1,onMention:H,onRemove:ee}),R.element.addEventListener("mouseenter",()=>{it(R)}),R.element.addEventListener("mouseleave",()=>{lt(R)}))}),z.addEventListener("mouseleave",()=>{lt(R)}),g.appendChild(z)})}function ut(L){if(!i.config.uploadFile)return;const M=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i.resourceIndex.set(M,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),a.push(M),Ee();const z=g.querySelectorAll(".fb-richinput-file-thumb"),N=z[z.length-1];N&&(N.style.opacity="0.5"),i.config.uploadFile(L).then(R=>{var H;const ee=a.indexOf(M);ee!==-1&&(a[ee]=R),i.resourceIndex.delete(M),i.resourceIndex.set(R,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),Ee(),K(),p(),(H=t.instance)==null||H.triggerOnChange(o,u())}).catch(R=>{var H,ee;const te=a.indexOf(M);te!==-1&&a.splice(te,1),i.resourceIndex.delete(M),Ee(),(ee=(H=i.config).onUploadError)==null||ee.call(H,R,L)})}if(y.addEventListener("change",()=>{var L;const M=y.files;if(!M||M.length===0)return;const z=(L=e.maxFiles)!=null?L:1/0;for(let N=0;N<M.length;N++){if(a.length>=z){v($("filesLimitExceeded",i,{skipped:M.length-N,max:z}));break}w(M[N])&&ut(M[N])}y.value=""}),C.appendChild(E),C.appendChild(x),C.appendChild(I),C.appendChild(G),f.appendChild(g),f.appendChild(C),f.appendChild(m),e.minLength!=null||e.maxLength!=null){const L=document.createElement("div");L.style.cssText="position: relative; padding: 2px 14px 6px; text-align: right;";const M=Ie(e,x,!1);M.style.cssText=`
562
830
  position: static;
563
831
  display: inline-block;
564
832
  font-size: var(--fb-font-size-small);
565
833
  color: var(--fb-text-secondary-color);
566
834
  pointer-events: none;
567
- `,$.appendChild(q),p.appendChild($)}p.appendChild(f),p.appendChild(g),m(),Z(),f._applyExternalUpdate=$=>{var q;const M=(q=$.text)!=null?q:"";w.value=M?en(M,s,o):"",w.dispatchEvent(new Event("input")),s.length=0;for(const N of $.files)s.push(N);be(),Z(),m()},n.appendChild(p),be();const Re=new MutationObserver(()=>{p.isConnected||(u.abort(),z=Fe(z),Re.disconnect())});p.parentElement&&Re.observe(p.parentElement,{childList:!0})}function Fo(e,t,n,r,l){var a,o;const s=t.state,{text:i,files:u}=l,f=new Map;for(const c of u){const m=s.resourceIndex.get(c);m!=null&&m.name&&f.set(c,m.name)}if(u.length>0){const c=document.createElement("div");c.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",u.forEach(m=>{const p=s.resourceIndex.get(m),h=document.createElement("div");h.style.cssText=`
835
+ `,L.appendChild(M),f.appendChild(L)}f.appendChild(d),f.appendChild(y),p(),K(),d._applyExternalUpdate=L=>{var M;const z=(M=L.text)!=null?M:"";x.value=z?Sn(z,a,i):"",x.dispatchEvent(new Event("input")),a.length=0;for(const N of L.files)a.push(N);Ee(),K(),p()},n.appendChild(f),Ee();const Oe=new MutationObserver(()=>{f.isConnected||(c.abort(),q=qe(q),Oe.disconnect())});f.parentElement&&Oe.observe(f.parentElement,{childList:!0})}function $r(e,t,n,o,r){var l,i;const a=t.state,{text:s,files:c}=r,d=new Map;for(const u of c){const p=a.resourceIndex.get(u);p!=null&&p.name&&d.set(u,p.name)}if(c.length>0){const u=document.createElement("div");u.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",c.forEach(p=>{const f=a.resourceIndex.get(p),m=document.createElement("div");m.style.cssText=`
568
836
  position: relative;
569
837
  width: 48px; height: 48px;
570
838
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -573,12 +841,12 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
573
841
  flex-shrink: 0;
574
842
  background: #fff;
575
843
  cursor: default;
576
- `;const v=document.createElement("div");v.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",tn(v,m,p,s),h.appendChild(v);const b=an();h.addEventListener("mouseenter",()=>{Ye(b),b.element||(b.element=ln(h,{rid:m,state:s,isReadonly:!0}),b.element.addEventListener("mouseenter",()=>{Ye(b)}),b.element.addEventListener("mouseleave",()=>{Je(b)}))}),h.addEventListener("mouseleave",()=>{Je(b)}),c.appendChild(h)}),n.appendChild(c)}if(i){const c=document.createElement("div");c.style.cssText=`
577
- ${Xe}
844
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Tn(b,p,f,a),m.appendChild(b);const v=Mn();m.addEventListener("mouseenter",()=>{it(v),v.element||(v.element=zn(m,{rid:p,state:a,isReadonly:!0}),v.element.addEventListener("mouseenter",()=>{it(v)}),v.element.addEventListener("mouseleave",()=>{lt(v)}))}),m.addEventListener("mouseleave",()=>{lt(v)}),u.appendChild(m)}),n.appendChild(u)}if(s){const u=document.createElement("div");u.style.cssText=`
845
+ ${at}
578
846
  color: var(--fb-text-color, #111827);
579
847
  white-space: pre-wrap;
580
848
  word-break: break-word;
581
- `;const m=We(i).filter(p=>f.has(p.name)||[...f.values()].includes(p.name));if(m.length===0)c.textContent=i;else{let p=0;for(const h of m){h.start>p&&c.appendChild(document.createTextNode(i.slice(p,h.start)));const v=document.createElement("span");v.style.cssText=`
849
+ `;const p=rt(s).filter(f=>d.has(f.name)||[...d.values()].includes(f.name));if(p.length===0)u.textContent=s;else{let f=0;for(const m of p){m.start>f&&u.appendChild(document.createTextNode(s.slice(f,m.start)));const b=document.createElement("span");b.style.cssText=`
582
850
  display: inline;
583
851
  background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
584
852
  color: var(--fb-primary-color, #0066cc);
@@ -586,12 +854,12 @@ var FormBuilder=(function(ye){"use strict";function k(e,t,n){const r=t.config.lo
586
854
  padding: 1px 6px;
587
855
  font-weight: 500;
588
856
  cursor: default;
589
- `;const b=f.has(h.name)?h.name:(a=[...f.entries()].find(([,d])=>d===h.name))==null?void 0:a[0],x=(o=f.get(h.name))!=null?o:h.name;if(v.textContent=`@${x}`,b){let d=null;const y=b;v.addEventListener("mouseenter",()=>{d=Fe(d),d=rn(v,y,s)}),v.addEventListener("mouseleave",()=>{d=Fe(d)})}c.appendChild(v),p=h.end}p<i.length&&c.appendChild(document.createTextNode(i.slice(p)))}n.appendChild(c)}if(!i&&u.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 No(e,t,n,r){var l,a,o,s;const i=t.state,u=(l=e.textKey)!=null?l:"text",f=(a=e.filesKey)!=null?a:"files";let c;if(e.flatOutput){const m=t.prefill[u],p=t.prefill[f];c={text:typeof m=="string"?m:null,files:Array.isArray(p)?p:[]}}else{const m=t.prefill[e.key];if(m&&typeof m=="object"&&!Array.isArray(m)){const p=m,h=(o=p[u])!=null?o:p.text,v=(s=p[f])!=null?s:p.files;c={text:typeof h=="string"?h:null,files:Array.isArray(v)?v:[]}}else typeof m=="string"?c={text:m||null,files:[]}:c={text:null,files:[]}}for(const m of c.files)i.resourceIndex.has(m)||i.resourceIndex.set(m,{name:m,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(i.config.readonly)Fo(e,t,n,r,c);else{if(!i.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ao(e,t,n,r,c)}}function Mo(e,t,n){var r,l;const{scopeRoot:a,state:o,skipValidation:s}=n,i=[],u=(r=e.textKey)!=null?r:"text",f=(l=e.filesKey)!=null?l:"files",c=a.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:i};let m={};try{const d=JSON.parse(c.value);if(d&&typeof d=="object"&&!Array.isArray(d))m=d;else return i.push(`${t}: invalid richinput data`),{value:null,errors:i}}catch(d){return i.push(`${t}: invalid richinput data`),{value:null,errors:i}}const p=m[u],h=m[f],v=p===null||typeof p=="string"?p:null,b=Array.isArray(h)?h:[],x={[u]:v!=null?v:null,[f]:b};if(!s){const d=!v||v.trim()==="",y=b.length===0;e.required&&d&&y&&i.push(`${t}: ${k("required",o)}`),!d&&v&&(e.minLength!=null&&v.length<e.minLength&&i.push(`${t}: ${k("minLength",o,{min:e.minLength})}`),e.maxLength!=null&&v.length>e.maxLength&&i.push(`${t}: ${k("maxLength",o,{max:e.maxLength})}`)),e.maxFiles!=null&&b.length>e.maxFiles&&i.push(`${t}: ${k("maxFiles",o,{max:e.maxFiles})}`)}return{value:x,errors:i,spread:!!e.flatOutput}}function qo(e,t,n,r){var l,a,o,s;const{scopeRoot:i}=r,u=i.querySelector(`[name="${t}"]`);if(!u){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const c=n,m=(l=e.textKey)!=null?l:"text",p=(a=e.filesKey)!=null?a:"files",h=(o=c[m])!=null?o:c.text,v=(s=c[p])!=null?s:c.files;(h!==void 0||v!==void 0)&&(f={text:typeof h=="string"?h:null,files:Array.isArray(v)?v:[]})}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):f&&(u.value=JSON.stringify(f))}function zo(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(f=>{f.classList.add("hidden")}),r)return;const l=t.getBoundingClientRect(),a=window.innerWidth,o=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const s=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let i=l.left,u=l.bottom+5;i+s.width>a&&(i=l.right-s.width),u+s.height>o&&(u=l.top-s.height-5),i<10&&(i=10),u<10&&(u=l.bottom+5),n.style.left=`${i}px`,n.style.top=`${u}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(l=>{l.classList.add("hidden")})});function Ho(e,t){var n,r,l;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},o=((l=e.enableIf.scope)!=null?l:"relative")==="relative"&&t.path?t.prefill:void 0;return!$e(e.enableIf,a,o)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Io(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 Ge(e,t,n){var r,l;if(!t.enableIf)return;const a=n.state.formRoot;if(!a){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const o=t.enableIf,s=(r=o.scope)!=null?r:"relative";let i={};const u={};if((!n.path||n.path===""?"absolute":s)==="relative"&&n.path){const f=n.path.match(/^(.+)\[(\d+)\]$/);if(f){const c=f[1],m=parseInt(f[2],10),p=a.querySelector(`[data-container-item="${c}[${m}]"]`);p&&p.querySelectorAll("input, select, textarea").forEach(h=>{const v=h.getAttribute("name");if(v){const b=v.match(/\.([^.[\]]+)$/);if(b){const x=b[1];h instanceof HTMLSelectElement?u[x]=h.value:h instanceof HTMLInputElement?h.type==="checkbox"?u[x]=h.checked:h.type==="radio"?h.checked&&(u[x]=h.value):u[x]=h.value:h instanceof HTMLTextAreaElement&&(u[x]=h.value)}}})}}else{const f=o.key,c=Io(f,a);c!==void 0?i[f]=c:i=(l=n.formData)!=null?l:n.prefill}try{$e(o,i,u)?(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(f){console.error(`Error re-evaluating enableIf for field "${t.key}":`,f)}}function Bo(e,t,n){var r;if(!t.enableIf)return;const l=n.state.formRoot;if(!l){console.error("Cannot setup enableIf listeners: formRoot is null");return}const a=t.enableIf,o=(r=a.scope)!=null?r:"relative",s=a.key;let i;o==="relative"&&n.path?i=`${n.path}.${s}`:i=s;const u=l.querySelector(`[name="${i}"]`);if(!u){const f=new MutationObserver(()=>{const c=l.querySelector(`[name="${i}"]`);c&&(c.addEventListener("change",()=>{Ge(e,t,n)}),c.addEventListener("input",()=>{Ge(e,t,n)}),f.disconnect())});f.observe(l,{childList:!0,subtree:!0});return}u.addEventListener("change",()=>{Ge(e,t,n)}),u.addEventListener("input",()=>{Ge(e,t,n)})}function Ro(e){const t=document.createElement("label");if(t.className="text-sm font-medium text-gray-900",t.textContent=e.label||e.key,e.required){const n=document.createElement("span");n.className="text-red-500 ml-1",n.textContent="*",t.appendChild(n)}return t}function Do(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=l=>{l.preventDefault(),l.stopPropagation(),zo(n,t)},t}function jo(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=Ro(e);if(t.appendChild(n),e.description||e.hint){const r=Do(e);t.appendChild(r)}return t}function Oo(e,t,n,r){const l="multiple"in e&&e.multiple;switch(e.type){case"text":l?En(e,t,n,r):xn(e,t,n,r);break;case"textarea":l?wn(e,t,n,r):Cn(e,t,n,r);break;case"number":l?Sn(e,t,n,r):Ln(e,t,n,r);break;case"select":l?Nn(e,t,n,r):Fn(e,t,n,r);break;case"switcher":l?Hn(e,t,n,r):zn(e,t,n,r);break;case"file":l?Zn(e,t,n,r):Xn(e,t,n,r);break;case"files":Gn(e,t,n,r);break;case"colour":l?eo(e,t,n,r):Qn(e,t,n,r);break;case"slider":l?ro(e,t,n,r):oo(e,t,n,r);break;case"group":co(e,t,n,r);break;case"container":l?_t(e,t,n):Kt(e,t,n,r);break;case"table":Co(e,t,n,r);break;case"richinput":No(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function gt(e,t){const n=Ho(e,t),r=document.createElement("div");r.className="mb-6 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const l=jo(e);r.appendChild(l);const a=ge(t.path,e.key);return Oo(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Bo(r,e,t),r}io(gt);const bt={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,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",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",fileCountRange:"({min}-{max})",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}',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',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",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",fileCountRange:"({min}-{max})",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}',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',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 Uo(e){const t={...bt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...bt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...bt,...e,translations:t},debounceTimer:null,prefill:{}}}function Po(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ie={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",textColor:"#1f2937",textSecondaryColor:"#6b7280",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.75rem",inputPaddingY:"0.5rem",borderRadius:"0.5rem",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",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms"};function Vo(e){const t={...Ie,...e},n=[];return Object.entries(t).forEach(([r,l])=>{const a=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${a}: ${l};`)}),n.join(`
590
- `)}function Ko(e,t){const n=Vo(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=`
857
+ `;const v=d.has(m.name)?m.name:(l=[...d.entries()].find(([,h])=>h===m.name))==null?void 0:l[0],w=(i=d.get(m.name))!=null?i:m.name;if(b.textContent=`@${w}`,v){let h=null;const g=v;b.addEventListener("mouseenter",()=>{h=qe(h),h=Nn(b,g,a)}),b.addEventListener("mouseleave",()=>{h=qe(h)})}u.appendChild(b),f=m.end}f<s.length&&u.appendChild(document.createTextNode(s.slice(f)))}n.appendChild(u)}if(!s&&c.length===0){const u=document.createElement("div");u.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",u.textContent="\u2014",n.appendChild(u)}}function Lr(e,t,n,o){var r,l,i,a;const s=t.state,c=le(e,s,t),d=(r=e.textKey)!=null?r:"text",u=(l=e.filesKey)!=null?l:"files";let p;if(e.flatOutput){const f=t.prefill[d],m=t.prefill[u];p={text:typeof f=="string"?f:null,files:Array.isArray(m)?m:[]}}else{const f=t.prefill[e.key];if(f&&typeof f=="object"&&!Array.isArray(f)){const m=f,b=(i=m[d])!=null?i:m.text,v=(a=m[u])!=null?a:m.files;p={text:typeof b=="string"?b:null,files:Array.isArray(v)?v:[]}}else typeof f=="string"?p={text:f||null,files:[]}:p={text:null,files:[]}}for(const f of p.files)s.resourceIndex.has(f)||s.resourceIndex.set(f,{name:f,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(c)$r(e,t,n,o,p);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);kr(e,t,n,o,p)}}function Sr(e,t,n){var o,r;const{scopeRoot:l,state:i,skipValidation:a}=n,s=[],c=(o=e.textKey)!=null?o:"text",d=(r=e.filesKey)!=null?r:"files",u=l.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let p={};try{const h=JSON.parse(u.value);if(h&&typeof h=="object"&&!Array.isArray(h))p=h;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(h){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const f=p[c],m=p[d],b=f===null||typeof f=="string"?f:null,v=Array.isArray(m)?m:[],w={[c]:b!=null?b:null,[d]:v};if(!a){const h=!b||b.trim()==="",g=v.length===0;e.required&&h&&g&&s.push(`${t}: ${$("required",i)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${$("minLength",i,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${$("maxLength",i,{max:e.maxLength})}`)),e.maxFiles!=null&&v.length>e.maxFiles&&s.push(`${t}: ${$("maxFiles",i,{max:e.maxFiles})}`)}return{value:w,errors:s,spread:!!e.flatOutput}}function Tr(e,t,n,o){var r,l,i,a;const{scopeRoot:s}=o,c=s.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let d=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,p=(r=e.textKey)!=null?r:"text",f=(l=e.filesKey)!=null?l:"files",m=(i=u[p])!=null?i:u.text,b=(a=u[f])!=null?a:u.files;(m!==void 0||b!==void 0)&&(d={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}d&&c._applyExternalUpdate?c._applyExternalUpdate(d):d&&(c.value=JSON.stringify(d))}function Ar(e,t){const n=document.getElementById(e);if(!n)return;const o=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(d=>{d.classList.add("hidden")}),o)return;const r=t.getBoundingClientRect(),l=window.innerWidth,i=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const a=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=r.left,c=r.bottom+5;s+a.width>l&&(s=r.right-a.width),c+a.height>i&&(c=r.top-a.height-5),s<10&&(s=10),c<10&&(c=r.bottom+5),n.style.left=`${s}px`,n.style.top=`${c}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,o=t.closest('[id^="tooltip-"]');!n&&!o&&document.querySelectorAll('[id^="tooltip-"]').forEach(r=>{r.classList.add("hidden")})});function Fr(e,t){var n,o,r;if(!e.enableIf)return!1;try{const l=(o=(n=t.formData)!=null?n:t.prefill)!=null?o:{},i=((r=e.enableIf.scope)!=null?r:"relative")==="relative"&&t.path?t.prefill:void 0;return!Fe(e.enableIf,l,i)}catch(l){console.error(`Error evaluating enableIf for field "${e.key}":`,l)}return!1}function Nr(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 o=t.querySelector(`[name="${e}"]:checked`);return o?o.value:void 0}else return n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function st(e,t,n){var o,r;if(!t.enableIf)return;const l=n.state.formRoot;if(!l){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(o=i.scope)!=null?o:"relative";let s={};const c={};if((!n.path||n.path===""?"absolute":a)==="relative"&&n.path){const d=n.path.match(/^(.+)\[(\d+)\]$/);if(d){const u=d[1],p=parseInt(d[2],10),f=l.querySelector(`[data-container-item="${u}[${p}]"]`);f&&f.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const v=b.match(/\.([^.[\]]+)$/);if(v){const w=v[1];m instanceof HTMLSelectElement?c[w]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?c[w]=m.checked:m.type==="radio"?m.checked&&(c[w]=m.value):c[w]=m.value:m instanceof HTMLTextAreaElement&&(c[w]=m.value)}}})}}else{const d=i.key,u=Nr(d,l);u!==void 0?s[d]=u:s=(r=n.formData)!=null?r:n.prefill}try{Fe(i,s,c)?(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(d){console.error(`Error re-evaluating enableIf for field "${t.key}":`,d)}}function zr(e,t,n){var o;if(!t.enableIf)return;const r=n.state.formRoot;if(!r){console.error("Cannot setup enableIf listeners: formRoot is null");return}const l=t.enableIf,i=(o=l.scope)!=null?o:"relative",a=l.key;let s;i==="relative"&&n.path?s=`${n.path}.${a}`:s=a;const c=r.querySelector(`[name="${s}"]`);if(!c){const d=new MutationObserver(()=>{const u=r.querySelector(`[name="${s}"]`);u&&(u.addEventListener("change",()=>{st(e,t,n)}),u.addEventListener("input",()=>{st(e,t,n)}),d.disconnect())});d.observe(r,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{st(e,t,n)}),c.addEventListener("input",()=>{st(e,t,n)})}function Mr(e){const t=document.createElement("label");if(t.className="text-sm font-medium text-gray-900",t.textContent=e.label||e.key,e.required){const n=document.createElement("span");n.className="text-red-500 ml-1",n.textContent="*",t.appendChild(n)}return t}function qr(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)}`,o=document.createElement("div");return o.id=n,o.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",o.style.position="fixed",o.textContent=e.description||e.hint||"Field information",document.body.appendChild(o),t.onclick=r=>{r.preventDefault(),r.stopPropagation(),Ar(n,t)},t}function Rr(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=Mr(e);if(t.appendChild(n),e.description||e.hint){const o=qr(e);t.appendChild(o)}return t}function Ir(e,t,n,o){const r="multiple"in e&&e.multiple;switch(e.type){case"text":r?_n(e,t,n,o):Kn(e,t,n,o);break;case"textarea":r?Yn(e,t,n,o):Jn(e,t,n,o);break;case"number":r?Qn(e,t,n,o):Zn(e,t,n,o);break;case"select":r?oo(e,t,n,o):no(e,t,n,o);break;case"switcher":r?ao(e,t,n,o):io(e,t,n,o);break;case"file":r?Jo(e,t,n,o):Ko(e,t,n,o);break;case"files":_o(e,t,n,o);break;case"colour":r?Xo(e,t,n,o):Yo(e,t,n,o);break;case"slider":r?er(e,t,n,o):Qo(e,t,n,o);break;case"group":lr(e,t,n,o);break;case"container":r?yn(e,t,n):gn(e,t,n,o);break;case"table":br(e,t,n,o);break;case"richinput":Lr(e,t,n,o);break;default:{const l=document.createElement("div");l.className="text-red-500 text-sm",l.textContent=$("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(l)}}}function At(e,t){const n=Fr(e,t),o=document.createElement("div");o.className="mb-6 fb-field-wrapper",o.setAttribute("data-field-key",e.key);const r=Rr(e);o.appendChild(r);const l=xe(t.path,e.key);return Ir(e,t,o,l),n&&(o.style.display="none",o.classList.add("fb-field-wrapper-disabled"),o.setAttribute("data-conditionally-disabled","true")),zr(o,e,t),o}or(At);const Ft={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,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",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",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}',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',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",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",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}',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',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 Hr(e){const t={...Ft.translations};if(e!=null&&e.translations)for(const[n,o]of Object.entries(e.translations))t[n]={...Ft.translations[n]||{},...o};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Ft,...e,translations:t},debounceTimer:null,prefill:{}}}function Br(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const De={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",textColor:"#1f2937",textSecondaryColor:"#6b7280",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.75rem",inputPaddingY:"0.5rem",borderRadius:"0.5rem",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",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms"};function Dr(e){const t={...De,...e},n=[];return Object.entries(t).forEach(([o,r])=>{const l=o.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${l}: ${r};`)}),n.join(`
858
+ `)}function jr(e,t){const n=Dr(t);let o=e.querySelector("style[data-fb-theme]");o||(o=document.createElement("style"),o.setAttribute("data-fb-theme","true"),e.appendChild(o)),o.textContent=`
591
859
  [data-fb-root="true"] {
592
860
  ${n}
593
861
  }
594
- `}const _o={default:Ie,dark:{...Ie,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:{...Ie,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'}};function un(e,t=!1){e.style.cssText=`
862
+ `}const Or={default:De,dark:{...De,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:{...De,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'}};function In(e,t=!1){e.style.cssText=`
595
863
  background-color: var(--fb-action-bg-color);
596
864
  color: var(--fb-action-text-color);
597
865
  border: var(--fb-border-width) solid var(--fb-action-border-color);
@@ -601,6 +869,6 @@ ${n}
601
869
  border-radius: var(--fb-border-radius);
602
870
  transition: all var(--fb-transition-duration);
603
871
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
604
- `,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 Wo(e,t,n){var r;const{scopeRoot:l}=n,a=l.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),o=(r=a==null?void 0:a.value)!=null?r:"";if(o===""){const s="default"in e?e.default:null;return{value:s!==void 0?s:null,errors:[]}}return{value:xt(o),errors:[]}}function Jo(e,t,n,r){const{scopeRoot:l}=r,a=l.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=yt(n))}const Yo={text:{validate:Et,update:Ct},textarea:{validate:kn,update:$n},number:{validate:Tn,update:An},select:{validate:Mn,update:qn},switcher:{validate:In,update:Bn},file:{validate:Ht,update:It},files:{validate:Ht,update:It},colour:{validate:to,update:no},slider:{validate:lo,update:ao},container:{validate:Jt,update:Yt},group:{validate:uo,update:po},table:{validate:wo,update:ko},richinput:{validate:Mo,update:qo},hidden:{validate:Wo,update:Jo}};function dn(e){return Yo[e]||null}function Xo(e,t,n){const r=dn(e.type);return r&&r.validate?r.validate(e,t,n):null}function Go(e,t,n,r){const l=dn(e.type);return l&&l.update?(l.update(e,t,n,r),!0):!1}class Ze{constructor(t){this.instanceId=Po(),this.state=Uo(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;if(!this.state.config.readonly){let l=this.state.formRoot.querySelector(`[name="${t}"]`);if(l)return l;const a=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const o of a)if(l=this.state.formRoot.querySelector(`[name="${o}"]`),l)return l}const n=this.findSchemaElement(t);if(!n)return null;const r=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const l of r){const a=n.label||n.key,o=l.querySelector("label");if(o&&(o.textContent===a||o.textContent===`${a}*`)){let s=l.querySelector(".field-placeholder");return s||(s=document.createElement("div"),s.className="field-placeholder",s.style.display="none",l.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 l=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const a of l){if(r=n.find(o=>o.key===a)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,l=!1){if(r&&"actions"in r&&r.actions){const a=r.actions.find(o=>o.key===t);if(a&&a.label)return a.label}if(l&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const a=this.state.schema.actions.find(o=>o.key===t);if(a&&a.label)return a.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 l=document.createElement("div");l.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",l.style.cssText=`
872
+ `,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 Ur(e,t,n){var o;const{scopeRoot:r}=n,l=r.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),i=(o=l==null?void 0:l.value)!=null?o:"";if(i===""){const a="default"in e?e.default:null;return{value:a!==void 0?a:null,errors:[]}}return{value:zt(i),errors:[]}}function Pr(e,t,n,o){const{scopeRoot:r}=o,l=r.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);l&&(l.value=Nt(n))}const Vr={text:{validate:Mt,update:qt},textarea:{validate:Xn,update:Gn},number:{validate:eo,update:to},select:{validate:ro,update:lo},switcher:{validate:so,update:co},file:{validate:rn,update:sn},files:{validate:rn,update:sn},colour:{validate:Go,update:Zo},slider:{validate:tr,update:nr},container:{validate:En,update:Cn},group:{validate:ir,update:ar},table:{validate:gr,update:yr},richinput:{validate:Sr,update:Tr},hidden:{validate:Ur,update:Pr}};function Hn(e){return Vr[e]||null}function Wr(e,t,n){const o=Hn(e.type);return o&&o.validate?o.validate(e,t,n):null}function Kr(e,t,n,o){const r=Hn(e.type);return r&&r.update?(r.update(e,t,n,o),!0):!1}class ct{constructor(t){this.instanceId=Br(),this.state=Hr(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 o=this.validateForm(!0);this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(o),this.state.config.onFieldChange&&t!==void 0&&n!==void 0&&this.state.config.onFieldChange(t,n,o),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(o=>o.value===t.value&&o.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;if(!this.state.config.readonly){let r=this.state.formRoot.querySelector(`[name="${t}"]`);if(r)return r;const l=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const i of l)if(r=this.state.formRoot.querySelector(`[name="${i}"]`),r)return r}const n=this.findSchemaElement(t);if(!n)return null;const o=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const r of o){const l=n.label||n.key,i=r.querySelector("label");if(i&&(i.textContent===l||i.textContent===`${l}*`)){let a=r.querySelector(".field-placeholder");return a||(a=document.createElement("div"),a.className="field-placeholder",a.style.display="none",r.appendChild(a)),a}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,o=null;const r=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const l of r){if(o=n.find(i=>i.key===l)||null,!o)return null;"elements"in o&&o.elements&&(n=o.elements)}return o}resolveActionLabel(t,n,o,r=!1){if(o&&"actions"in o&&o.actions){const l=o.actions.find(i=>i.key===t);if(l&&l.label)return l.label}if(r&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const l=this.state.schema.actions.find(i=>i.key===t);if(l&&l.label)return l.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const o=this.state.formRoot.querySelector(".form-level-actions-container");o&&o.remove();const r=document.createElement("div");r.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",r.style.cssText=`
605
873
  border-top: var(--fb-border-width) solid var(--fb-border-color);
606
- `,t.forEach(a=>{const o=document.createElement("button");o.type="button",un(o,!0);const s=n.includes(a),i=this.resolveActionLabel(a.key,a.label,null,s);o.textContent=i,o.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(a.value,a.key,null)}),l.appendChild(o)}),this.state.formRoot.appendChild(l)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(a=>{!a.key||!a.value||(a.related_field?(t.has(a.related_field)||t.set(a.related_field,[]),t.get(a.related_field).push(a)):n.push(a))}),t.forEach((a,o)=>{const s=this.findFormElementByFieldPath(o);if(!s){console.warn(`External action: Could not find form element for field "${o}", treating as form-level actions`),r.push(...a);return}let i=s.closest(".fb-field-wrapper");if(i||(i=s.parentElement),!i){console.warn(`External action: Could not find wrapper for field "${o}"`);return}const u=i.querySelector(".external-actions-container");u&&u.remove();const f=document.createElement("div");f.className="external-actions-container mt-3 flex flex-wrap gap-2";const c=this.findSchemaElement(o);a.forEach(m=>{const p=document.createElement("button");p.type="button",un(p,!1);const h=this.resolveActionLabel(m.key,m.label,c);p.textContent=h,p.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(m.value,m.key,m.related_field)}),f.appendChild(p)}),i.appendChild(f)});const l=[...n,...r];l.length>0&&this.renderFormLevelActions(l,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"),l=n.getAttribute("data-root-hint")==="true",a=n.getAttribute("data-container-key");if(!r||!l&&!a){console.warn("Prefill hint missing required data attributes");return}try{const o=JSON.parse(r);for(const s in o){const i=l?s:`${a}.${s}`,u=o[s];this.updateField(i,u)}}catch(o){console.error("Error parsing prefill hint values:",o)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(r=>{const l=document.createElement("button");l.type="button",l.className="fb-prefill-hint",r.icon?l.textContent=`${r.icon} ${r.label}`:l.textContent=r.label,l.setAttribute("data-hint-values",JSON.stringify(r.values)),l.setAttribute("data-root-hint","true"),n.appendChild(l)}),n}renderForm(t,n,r,l){const a=et(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=l||null,this.state.prefill=r||{},pe(t),t.setAttribute("data-fb-root","true"),Ko(t,this.state.config.theme);const o=document.createElement("div");if(o.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const u=this.createRootPrefillHints(n.prefillHints);o.appendChild(u)}const s=document.createElement("div"),i=n.columns||1;i===1?s.className="space-y-4":s.className=`grid grid-cols-${i} gap-4`,n.elements.forEach(u=>{var f,c;if(u.hidden||u.type==="hidden"){const p=(c=(f=r==null?void 0:r[u.key])!=null?f:u.default)!=null?c:null;s.appendChild(qe(u.key,p));return}const m=gt(u,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});s.appendChild(m)}),o.appendChild(s),t.appendChild(o),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={},l=(a,o,s=null)=>{const i=a.key,u={scopeRoot:s||this.state.formRoot,state:this.state,instance:this,path:o.path,skipValidation:t},f=Xo(a,i,u);return f!==null?(n.push(...f.errors),{value:f.value,spread:!!f.spread}):(console.warn(`Unknown field type "${a.type}" for key "${i}"`),{value:null,spread:!1})};return so(l),this.state.schema.elements.forEach(a=>{var o;if(a.enableIf)try{if(!$e(a.enableIf,r))return}catch(s){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,s)}if(a.hidden||a.type==="hidden"){const s=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${a.key}"]`),i=(o=s==null?void 0:s.value)!=null?o:"";i!==""?r[a.key]=xt(i):r[a.key]=a.default!==void 0?a.default:null}else{const s=l(a,{path:""});s.spread&&s.value!==null&&typeof s.value=="object"?Object.assign(r,s.value):r[a.key]=s.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,l=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,l,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){const l=r.key;if(r.hidden&&r.default!==void 0&&(n[l]=r.default),r.type==="container"||r.type==="group"){const a=r,o=this.buildHiddenFieldsData(a.elements);Object.keys(o).length>0&&(l in n?typeof n[l]=="object"&&n[l]!==null&&!Array.isArray(n[l])&&(n[l]={...n[l],...o}):n[l]=o)}}return n}buildFlatKeyMap(t){var n,r;const l=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const o=a,s=(n=o.textKey)!=null?n:"text",i=(r=o.filesKey)!=null?r:"files";l.set(s,{schemaKey:a.key,role:"text"}),l.set(i,{schemaKey:a.key,role:"files"})}return l}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 l in t){const a=n.get(l);a?(r.has(a.schemaKey)||r.set(a.schemaKey,{}),r.get(a.schemaKey)[l]=t[l]):this.updateField(l,t[l])}for(const[l,a]of r)this.updateField(l,a)}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 l=this.findFormElementByFieldPath(t);if(!l){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(l,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,l){const a={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Go(n,r,l,a)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,l)=>{r.forEach(a=>{var o,s,i;const u=l?`${l}.${a.key}`:a.key;if(a.enableIf){let f=null;if(l){const c=l.match(/^(.+)\[(\d+)\]$/);if(c){const m=c[1],p=c[2],h=this.state.formRoot.querySelector(`[data-container-item="${m}[${p}]"]`);h&&(f=h.querySelector(`[data-field-key="${a.key}"]`))}else{const m=this.state.formRoot.querySelector(`[data-container="${l}"]`);m&&(f=m.querySelector(`[data-field-key="${a.key}"]`))}}else f=this.state.formRoot.querySelector(`[data-field-key="${a.key}"]`);if(f){const c=f;try{let m;((o=a.enableIf.scope)!=null?o:"relative")==="relative"&&l&&(m=tt(t,l));const p=$e(a.enableIf,t,m),h=c.getAttribute("data-conditionally-disabled")==="true";if(p&&h){const v=l?tt(t,l):t,b=gt(a,{path:l,prefill:v&&typeof v=="object"?v:{},formData:t,state:this.state,instance:this});(s=c.parentNode)==null||s.replaceChild(b,c)}else if(!p&&!h){const v=document.createElement("div");v.className="fb-field-wrapper-disabled",v.style.display="none",v.setAttribute("data-field-key",a.key),v.setAttribute("data-conditionally-disabled","true"),(i=c.parentNode)==null||i.replaceChild(v,c)}}catch(m){console.error(`Error re-evaluating enableIf for field "${a.key}" at path "${u}":`,m)}}}if((a.type==="container"||a.type==="group")&&"elements"in a&&a.elements){const f=t==null?void 0:t[a.key];if(Array.isArray(f)){const c=this.state.formRoot.querySelectorAll("[data-container-item]");Array.from(c).filter(m=>{const p=m.getAttribute("data-container-item")||"";if(!p.startsWith(`${u}[`))return!1;const h=p.slice(u.length);return/^\[\d+\]$/.test(h)}).forEach(m=>{const p=m.getAttribute("data-container-item")||"";n(a.elements,p)})}else n(a.elements,u)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&pe(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))}}function pn(e){return new Ze(e)}return typeof window!="undefined"&&(window.FormBuilder=Ze,window.createFormBuilder=pn,window.validateSchema=et),ye.FormBuilderInstance=Ze,ye.createFormBuilder=pn,ye.default=Ze,ye.defaultTheme=Ie,ye.exampleThemes=_o,ye.validateSchema=et,Object.defineProperty(ye,"__esModule",{value:!0}),ye})({});
874
+ `,t.forEach(l=>{const i=document.createElement("button");i.type="button",In(i,!0);const a=n.includes(l),s=this.resolveActionLabel(l.key,l.label,null,a);i.textContent=s,i.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(l.value,l.key,null)}),r.appendChild(i)}),this.state.formRoot.appendChild(r)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],o=[];this.state.externalActions.forEach(l=>{!l.key||!l.value||(l.related_field?(t.has(l.related_field)||t.set(l.related_field,[]),t.get(l.related_field).push(l)):n.push(l))}),t.forEach((l,i)=>{const a=this.findFormElementByFieldPath(i);if(!a){console.warn(`External action: Could not find form element for field "${i}", treating as form-level actions`),o.push(...l);return}let s=a.closest(".fb-field-wrapper");if(s||(s=a.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${i}"`);return}const c=s.querySelector(".external-actions-container");c&&c.remove();const d=document.createElement("div");d.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(i);l.forEach(p=>{const f=document.createElement("button");f.type="button",In(f,!1);const m=this.resolveActionLabel(p.key,p.label,u);f.textContent=m,f.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(p.value,p.key,p.related_field)}),d.appendChild(f)}),s.appendChild(d)});const r=[...n,...o];r.length>0&&this.renderFormLevelActions(r,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const o=n.getAttribute("data-hint-values"),r=n.getAttribute("data-root-hint")==="true",l=n.getAttribute("data-container-key");if(!o||!r&&!l){console.warn("Prefill hint missing required data attributes");return}try{const i=JSON.parse(o);for(const a in i){const s=r?a:`${l}.${a}`,c=i[a];this.updateField(s,c)}}catch(i){console.error("Error parsing prefill hint values:",i)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(o=>{const r=document.createElement("button");r.type="button",r.className="fb-prefill-hint",o.icon?r.textContent=`${o.icon} ${o.label}`:r.textContent=o.label,r.setAttribute("data-hint-values",JSON.stringify(o.values)),r.setAttribute("data-root-hint","true"),n.appendChild(r)}),n}renderForm(t,n,o,r){const l=dt(n);if(l.length>0){console.error("Schema validation errors:",l);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=r||null,this.state.prefill=o||{},ve(t),t.setAttribute("data-fb-root","true"),jr(t,this.state.config.theme);const i=document.createElement("div");if(i.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const c=this.createRootPrefillHints(n.prefillHints);i.appendChild(c)}const a=document.createElement("div"),s=n.columns||1;s===1?a.className="space-y-4":a.className=`grid grid-cols-${s} gap-4`,n.elements.forEach(c=>{var d,u;if(c.hidden||c.type==="hidden"){const f=(u=(d=o==null?void 0:o[c.key])!=null?d:c.default)!=null?u:null;a.appendChild(Re(c.key,f));return}const p=At(c,{path:"",prefill:o||{},formData:o||{},state:this.state,instance:this});a.appendChild(p)}),i.appendChild(a),t.appendChild(i),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=[],o={},r=(l,i,a=null)=>{const s=l.key,c={scopeRoot:a||this.state.formRoot,state:this.state,instance:this,path:i.path,skipValidation:t},d=Wr(l,s,c);return d!==null?(n.push(...d.errors),{value:d.value,spread:!!d.spread}):(console.warn(`Unknown field type "${l.type}" for key "${s}"`),{value:null,spread:!1})};return rr(r),this.state.schema.elements.forEach(l=>{var i;if(l.enableIf)try{if(!Fe(l.enableIf,o))return}catch(a){console.error(`Error evaluating enableIf for field "${l.key}" during validation:`,a)}if(l.hidden||l.type==="hidden"){const a=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${l.key}"]`),s=(i=a==null?void 0:a.value)!=null?i:"";s!==""?o[l.key]=zt(s):o[l.key]=l.default!==void 0?l.default:null}else{const a=r(l,{path:""});a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(o,a.value):o[l.key]=a.value}}),{valid:n.length===0,errors:n,data:o}}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,o=this.state.externalActions,r=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,r,o||void 0)}buildHiddenFieldsData(t){const n={};for(const o of t){const r=o.key;if(o.hidden&&o.default!==void 0&&(n[r]=o.default),o.type==="container"||o.type==="group"){const l=o,i=this.buildHiddenFieldsData(l.elements);Object.keys(i).length>0&&(r in n?typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])&&(n[r]={...n[r],...i}):n[r]=i)}}return n}buildFlatKeyMap(t){var n,o;const r=new Map;for(const l of t)if(l.type==="richinput"&&l.flatOutput){const i=l,a=(n=i.textKey)!=null?n:"text",s=(o=i.filesKey)!=null?o:"files";r.set(a,{schemaKey:l.key,role:"text"}),r.set(s,{schemaKey:l.key,role:"files"})}return r}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),o=new Map;for(const r in t){const l=n.get(r);l?(o.has(l.schemaKey)||o.set(l.schemaKey,{}),o.get(l.schemaKey)[r]=t[r]):this.updateField(r,t[r])}for(const[r,l]of o)this.updateField(r,l)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const o=this.findSchemaElement(t);if(!o){console.warn(`updateField: Schema element not found for path "${t}"`);return}const r=this.findFormElementByFieldPath(t);if(!r){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(r,o,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,o,r){const l={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Kr(n,o,r,l)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${o}"`)}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(o,r)=>{o.forEach(l=>{var i,a,s;const c=r?`${r}.${l.key}`:l.key;if(l.enableIf){let d=null;if(r){const u=r.match(/^(.+)\[(\d+)\]$/);if(u){const p=u[1],f=u[2],m=this.state.formRoot.querySelector(`[data-container-item="${p}[${f}]"]`);m&&(d=m.querySelector(`[data-field-key="${l.key}"]`))}else{const p=this.state.formRoot.querySelector(`[data-container="${r}"]`);p&&(d=p.querySelector(`[data-field-key="${l.key}"]`))}}else d=this.state.formRoot.querySelector(`[data-field-key="${l.key}"]`);if(d){const u=d;try{let p;((i=l.enableIf.scope)!=null?i:"relative")==="relative"&&r&&(p=pt(t,r));const f=Fe(l.enableIf,t,p),m=u.getAttribute("data-conditionally-disabled")==="true";if(f&&m){const b=r?pt(t,r):t,v=At(l,{path:r,prefill:b&&typeof b=="object"?b:{},formData:t,state:this.state,instance:this});(a=u.parentNode)==null||a.replaceChild(v,u)}else if(!f&&!m){const b=document.createElement("div");b.className="fb-field-wrapper-disabled",b.style.display="none",b.setAttribute("data-field-key",l.key),b.setAttribute("data-conditionally-disabled","true"),(s=u.parentNode)==null||s.replaceChild(b,u)}}catch(p){console.error(`Error re-evaluating enableIf for field "${l.key}" at path "${c}":`,p)}}}if((l.type==="container"||l.type==="group")&&"elements"in l&&l.elements){const d=t==null?void 0:t[l.key];if(Array.isArray(d)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");Array.from(u).filter(p=>{const f=p.getAttribute("data-container-item")||"";if(!f.startsWith(`${c}[`))return!1;const m=f.slice(c.length);return/^\[\d+\]$/.test(m)}).forEach(p=>{const f=p.getAttribute("data-container-item")||"";n(l.elements,f)})}else n(l.elements,c)}})};n(this.state.schema.elements,"")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.state.resourceIndex.clear(),this.state.formRoot&&ve(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))}}function Bn(e){return new ct(e)}return typeof window!="undefined"&&(window.FormBuilder=ct,window.createFormBuilder=Bn,window.validateSchema=dt),Ce.FormBuilderInstance=ct,Ce.createFormBuilder=Bn,Ce.default=ct,Ce.defaultTheme=De,Ce.exampleThemes=Or,Ce.validateSchema=dt,Object.defineProperty(Ce,"__esModule",{value:!0}),Ce})({});