@dmitryvim/form-builder 0.2.26 → 0.2.28

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(Ee){"use strict";function $(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],a=t.config.translations.en;let l=(o==null?void 0:o[e])||(a==null?void 0:a[e])||e;if(n)for(const[i,c]of Object.entries(n))l=l.replace(new RegExp(`\\{${i}\\}`,"g"),String(c));return l}function mn(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 hn(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 vn(e,t,n){e.maxSizeMB&&t.push($("hintMaxSize",n,{size:e.maxSizeMB}))}function gn(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push($("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function bn(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function be(e,t){const n=[];return mn(e,n,t),e.type!=="slider"&&hn(e,n,t),vn(e,n,t),gn(e,n,t),bn(e,n,t),n.join(" \u2022 ")}function tt(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 o=e.columns,a=[1,2,3,4];(!Number.isInteger(o)||!a.includes(o))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${o})`)}if("prefillHints"in e&&e.prefillHints){const o=e.prefillHints;Array.isArray(o)&&o.forEach((a,l)=>{if((!a.label||typeof a.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!a.values||typeof a.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const i in a.values)e.elements.some(c=>c.key===i)||t.push(`schema.prefillHints[${l}] references non-existent field "${i}"`)})}function n(o,a){var l,i;const c=new Set;for(const s of o)if(s.type==="richinput"&&s.flatOutput){const f=s,d=(l=f.textKey)!=null?l:"text",p=(i=f.filesKey)!=null?i:"files";for(const u of o)u!==s&&(u.key===d&&t.push(`${a}: RichInput "${s.key}" flatOutput textKey "${d}" collides with element key "${u.key}"`),u.key===p&&t.push(`${a}: RichInput "${s.key}" flatOutput filesKey "${p}" collides with element key "${u.key}"`));c.has(d)&&t.push(`${a}: RichInput "${s.key}" flatOutput textKey "${d}" collides with another flatOutput key`),c.has(p)&&t.push(`${a}: RichInput "${s.key}" flatOutput filesKey "${p}" collides with another flatOutput key`),c.add(d),c.add(p)}else c.has(s.key)&&t.push(`${a}: Element key "${s.key}" collides with a flatOutput richinput key`),c.add(s.key)}function r(o,a){o.forEach((l,i)=>{const c=`${a}[${i}]`;if(l.type||t.push(`${c}: missing type`),l.key||t.push(`${c}: missing key`),l.enableIf){const s=l.enableIf;(!s.key||typeof s.key!="string")&&t.push(`${c}: enableIf must have a 'key' property of type string`),"equals"in s||t.push(`${c}: enableIf must have at least one operator (equals, etc.)`)}if(l.type==="group"&&"elements"in l&&l.elements&&r(l.elements,`${c}.elements`),l.type==="container"&&l.elements){if("columns"in l&&l.columns!==void 0){const s=l.columns,f=[1,2,3,4];(!Number.isInteger(s)||!f.includes(s))&&t.push(`${c}: columns must be 1, 2, 3, or 4 (got ${s})`)}if("prefillHints"in l&&l.prefillHints){const s=l.prefillHints;Array.isArray(s)&&s.forEach((f,d)=>{if((!f.label||typeof f.label!="string")&&t.push(`${c}: prefillHints[${d}] must have a 'label' property of type string`),!f.values||typeof f.values!="object")t.push(`${c}: prefillHints[${d}] must have a 'values' property of type object`);else for(const p in f.values)l.elements.some(u=>u.key===p)||t.push(`container "${l.key}": prefillHints[${d}] references non-existent field "${p}"`)})}r(l.elements,`${c}.elements`),n(l.elements,`${c}.elements`)}if(l.type==="select"&&l.options){const s=l.default;s!=null&&s!==""&&(l.options.some(f=>f.value===s)||t.push(`${c}: default "${s}" not in options`))}})}return Array.isArray(e.elements)&&(r(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 Oe(e){return e&&typeof e=="object"&&e.constructor===Object}function J(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function ye(e,t){return e?`${e}.${t}`:t}function ve(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function yn(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function xt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Et(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function ze(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=xt(t),n}function nt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const a=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(a))return;r=r[a]}else r=r[o]}return r}function Te(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let a;if(o==="relative")a=n!=null?n:t;else if(o==="absolute")a=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const l=nt(a,e.key);if("equals"in e)return xn(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function xn(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 r=document.createElement("span");r.className="char-counter",r.style.cssText=`
1
+ var FormBuilder=(function(we){"use strict";function $(e,t,n){const r=t.config.locale||"en",o=t.config.translations[r],i=t.config.translations.en;let l=(o==null?void 0:o[e])||(i==null?void 0:i[e])||e;if(n)for(const[a,s]of Object.entries(n))l=l.replace(new RegExp(`\\{${a}\\}`,"g"),String(s));return l}function Yn(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 Xn(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 Gn(e,t,n){e.maxSizeMB&&t.push($("hintMaxSize",n,{size:e.maxSizeMB}))}function Zn(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push($("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function Qn(e,t,n){e.pattern&&t.push($("hintPattern",n,{pattern:e.pattern}))}function ve(e,t){const n=[];return Yn(e,n,t),e.type!=="slider"&&Xn(e,n,t),Gn(e,n,t),Zn(e,n,t),Qn(e,n,t),n.join(" \u2022 ")}function ht(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 o=e.columns,i=[1,2,3,4];(!Number.isInteger(o)||!i.includes(o))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${o})`)}if("prefillHints"in e&&e.prefillHints){const o=e.prefillHints;Array.isArray(o)&&o.forEach((i,l)=>{if((!i.label||typeof i.label!="string")&&t.push(`schema.prefillHints[${l}] must have a 'label' property of type string`),!i.values||typeof i.values!="object")t.push(`schema.prefillHints[${l}] must have a 'values' property of type object`);else for(const a in i.values)e.elements.some(s=>s.key===a)||t.push(`schema.prefillHints[${l}] references non-existent field "${a}"`)})}function n(o,i){var l,a;const s=new Set;for(const c of o)if(c.type==="richinput"&&c.flatOutput){const p=c,u=(l=p.textKey)!=null?l:"text",f=(a=p.filesKey)!=null?a:"files";for(const d of o)d!==c&&(d.key===u&&t.push(`${i}: RichInput "${c.key}" flatOutput textKey "${u}" collides with element key "${d.key}"`),d.key===f&&t.push(`${i}: RichInput "${c.key}" flatOutput filesKey "${f}" collides with element key "${d.key}"`));s.has(u)&&t.push(`${i}: RichInput "${c.key}" flatOutput textKey "${u}" collides with another flatOutput key`),s.has(f)&&t.push(`${i}: RichInput "${c.key}" flatOutput filesKey "${f}" collides with another flatOutput key`),s.add(u),s.add(f)}else s.has(c.key)&&t.push(`${i}: Element key "${c.key}" collides with a flatOutput richinput key`),s.add(c.key)}function r(o,i){o.forEach((l,a)=>{const s=`${i}[${a}]`;if(l.type||t.push(`${s}: missing type`),l.key||t.push(`${s}: missing key`),l.enableIf){const c=l.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(l.type==="group"&&"elements"in l&&l.elements&&r(l.elements,`${s}.elements`),l.type==="container"&&l.elements){if("columns"in l&&l.columns!==void 0){const c=l.columns,p=[1,2,3,4];(!Number.isInteger(c)||!p.includes(c))&&t.push(`${s}: columns must be 1, 2, 3, or 4 (got ${c})`)}if("prefillHints"in l&&l.prefillHints){const c=l.prefillHints;Array.isArray(c)&&c.forEach((p,u)=>{if((!p.label||typeof p.label!="string")&&t.push(`${s}: prefillHints[${u}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${s}: prefillHints[${u}] must have a 'values' property of type object`);else for(const f in p.values)l.elements.some(d=>d.key===f)||t.push(`container "${l.key}": prefillHints[${u}] references non-existent field "${f}"`)})}r(l.elements,`${s}.elements`),n(l.elements,`${s}.elements`)}if(l.type==="select"&&l.options){const c=l.default;c!=null&&c!==""&&(l.options.some(p=>p.value===c)||t.push(`${s}: default "${c}" not in options`))}})}return Array.isArray(e.elements)&&(r(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 Je(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 be(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function er(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ht(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function Bt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function De(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Ht(t),n}function vt(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function Ne(e,t,n){var r;if(!e||!e.key)throw new Error("Invalid enableIf condition: must have a 'key' property");const o=(r=e.scope)!=null?r:"relative";let i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const l=vt(i,e.key);if("equals"in e)return tr(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function tr(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 je(e,t,n=!1){const r=document.createElement("span");r.className="char-counter",r.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(Ee){"use strict";function $(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 o=()=>{const a=t.value.length,l=e.minLength,i=e.maxLength;if(l==null&&i==null){r.textContent="";return}a===0||l!=null&&a<l?(l!=null&&i!=null?r.textContent=`${l}-${i}`:i!=null?r.textContent=`\u2264${i}`:l!=null&&(r.textContent=`\u2265${l}`),r.style.color="var(--fb-text-secondary-color)"):i!=null&&a>i?(r.textContent=`${a}/${i}`,r.style.color="var(--fb-error-color)"):(i!=null?r.textContent=`${a}/${i}`:r.textContent=`${a}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function En(e,t,n,r){const o=t.state,a=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const i=document.createElement("input");if(i.type="text",i.className="w-full rounded-lg",i.style.cssText=`
10
+ `;const o=()=>{const i=t.value.length,l=e.minLength,a=e.maxLength;if(l==null&&a==null){r.textContent="";return}i===0||l!=null&&i<l?(l!=null&&a!=null?r.textContent=`${l}-${a}`:a!=null?r.textContent=`\u2264${a}`:l!=null&&(r.textContent=`\u2265${l}`),r.style.color="var(--fb-text-secondary-color)"):a!=null&&i>a?(r.textContent=`${i}/${a}`,r.style.color="var(--fb-error-color)"):(a!=null?r.textContent=`${i}/${a}`:r.textContent=`${i}`,r.style.color="var(--fb-text-secondary-color)")};return t.addEventListener("input",o),o(),r}function nr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.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: ${a?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
15
+ background-color: ${i?"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
- `,i.name=r,i.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",i.value=t.prefill[e.key]||e.default||"",i.readOnly=a,a||(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)")})),!a&&t.instance){const c=()=>{const s=i.value===""?null:i.value;t.instance.triggerOnChange(r,s)};i.addEventListener("blur",c),i.addEventListener("input",c)}if(l.appendChild(i),!a&&(e.minLength!=null||e.maxLength!=null)){const c=Ie(e,i,!1);l.appendChild(c)}n.appendChild(l)}function Cn(e,t,n,r){var o,a;const l=t.state,i=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:1,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function u(){p.querySelectorAll(".multiple-text-item").forEach((b,y)=>{const w=b.querySelector("input");w&&(w.name=`${r}[${y}]`)})}function m(b="",y=-1){const w=document.createElement("div");w.className="multiple-text-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const x=document.createElement("input");if(x.type="text",x.style.cssText=`
22
+ `,a.name=r,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=i,i||(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)")})),!i&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const s=je(e,a,!1);l.appendChild(s)}n.appendChild(l)}function rr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-text-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-text-item flex items-center gap-2";const C=document.createElement("div");C.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: ${i?"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
- `,x.placeholder=e.placeholder||$("placeholderText",l),x.value=b,x.readOnly=i,i||(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)")})),!i&&t.instance){const k=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(C.appendChild(x),!i&&(e.minLength!=null||e.maxLength!=null)){const k=Ie(e,x,!1);C.appendChild(k)}return w.appendChild(C),y===-1?p.appendChild(w):p.insertBefore(w,p.children[y]),u(),w}function v(){if(i)return;const b=p.querySelectorAll(".multiple-text-item"),y=b.length;b.forEach(w=>{let C=w.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=`
34
+ `,x.placeholder=e.placeholder||$("placeholderText",l),x.value=h,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(C.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!1);C.appendChild(k)}return E.appendChild(C),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function b(){if(a)return;const h=f.querySelectorAll(".multiple-text-item"),g=h.length;h.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=`
35
35
  color: var(--fb-error-color);
36
36
  background-color: transparent;
37
37
  transition: background-color var(--fb-transition-duration);
38
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(p.children).indexOf(w);p.children.length>f&&(s.splice(k,1),w.remove(),u(),h(),v())},w.appendChild(C));const x=y<=f;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let g=null,E=null;if(!i){g=document.createElement("div"),g.className="flex items-center gap-3 mt-2";const b=document.createElement("button");b.type="button",b.className="add-text-btn px-3 py-1 rounded",b.style.cssText=`
38
+ `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(c.splice(k,1),E.remove(),d(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-text-btn px-3 py-1 rounded",h.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
- `,b.textContent="+",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),v()},E=document.createElement("span"),E.className="text-sm text-gray-500",g.appendChild(b),g.appendChild(E),n.appendChild(g)}function h(){if(!g||!E)return;const b=g.querySelector(".add-text-btn");if(b){const y=s.length>=d;b.disabled=y,b.style.opacity=y?"0.5":"1",b.style.pointerEvents=y?"none":"auto"}E.textContent=`${s.length}/${d===1/0?"\u221E":d}`}s.forEach(b=>m(b)),h(),v()}function Ct(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,p)=>{var u,m;if(!d)return;const v=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(v);p?(d.classList.add("invalid"),d.title=p,g||(g=document.createElement("div"),g.id=v,g.className="error-message",g.style.cssText=`
44
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-text-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function Dt(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:s}=n,c=(u,f)=>{var d,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(b);f?(u.classList.add("invalid"),u.title=f,y||(y=document.createElement("div"),y.id=b,y.className="error-message",y.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
- `,d.nextSibling?(u=d.parentNode)==null||u.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=p,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,p,u)=>{let m=!1;const{state:v}=n;if(!c&&p){if(e.minLength!==void 0&&e.minLength!==null&&p.length<e.minLength){const g=$("minLength",v,{min:e.minLength});l.push(`${u}: ${g}`),s(d,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&p.length>e.maxLength){const g=$("maxLength",v,{max:e.maxLength});l.push(`${u}: ${g}`),s(d,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(p)){const g=$("patternMismatch",v);l.push(`${u}: ${g}`),s(d,g),m=!0}}catch(g){const E=$("invalidPattern",v);l.push(`${u}: ${E}`),s(d,E),m=!0}}m||s(d,null)};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}["]`),p=[],u=[];if(d.forEach((m,v)=>{var g;const E=(g=m==null?void 0:m.value)!=null?g:"";u.push(E),p.push(E===""?null:E),f(m,E,`${t}[${v}]`)}),!c){const{state:m}=n,v=(r=e.minCount)!=null?r:1,g=(o=e.maxCount)!=null?o:1/0,E=u.filter(h=>h.trim()!=="");e.required&&E.length===0&&l.push(`${t}: ${$("required",m)}`),E.length<v&&l.push(`${t}: ${$("minItems",m,{min:v})}`),E.length>g&&l.push(`${t}: ${$("maxItems",m,{max:g})}`)}return{value:p,errors:l}}else{const d=i.querySelector(`[name$="${t}"]`),p=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&p===""){const u=$("required",n.state);return l.push(`${t}: ${u}`),s(d,u),{value:null,errors:l}}return d&&f(d,p,t),{value:p===""?null:p,errors:l}}}function wt(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.classList.remove("invalid"),l.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=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="")}}function kt(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 wn(e,t,n,r){const o=t.state,a=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const i=document.createElement("textarea");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 resize-none",i.style.cssText="padding-bottom: 24px;",i.name=r,i.placeholder=e.placeholder||"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",i.rows=e.rows||4,i.value=t.prefill[e.key]||e.default||"",i.readOnly=a,!a&&t.instance){const c=()=>{const s=i.value===""?null:i.value;t.instance.triggerOnChange(r,s)};i.addEventListener("blur",c),i.addEventListener("input",c)}if((e.autoExpand||a)&&kt(i),l.appendChild(i),!a&&(e.minLength!=null||e.maxLength!=null)){const c=Ie(e,i,!0);l.appendChild(c)}n.appendChild(l)}function kn(e,t,n,r){var o,a;const l=t.state,i=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:1,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function u(){p.querySelectorAll(".multiple-textarea-item").forEach((b,y)=>{const w=b.querySelector("textarea");w&&(w.name=`${r}[${y}]`)})}function m(b="",y=-1){const w=document.createElement("div");w.className="multiple-textarea-item";const C=document.createElement("div");C.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",l),x.rows=e.rows||4,x.value=b,x.readOnly=i,!i&&t.instance){const k=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",k),x.addEventListener("input",k)}if((e.autoExpand||i)&&kt(x),C.appendChild(x),!i&&(e.minLength!=null||e.maxLength!=null)){const k=Ie(e,x,!0);C.appendChild(k)}return w.appendChild(C),y===-1?p.appendChild(w):p.insertBefore(w,p.children[y]),u(),w}function v(){if(i)return;const b=p.querySelectorAll(".multiple-textarea-item"),y=b.length;b.forEach(w=>{let C=w.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(p.children).indexOf(w);p.children.length>f&&(s.splice(k,1),w.remove(),u(),h(),v())},w.appendChild(C));const x=y<=f;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let g=null,E=null;if(!i){g=document.createElement("div"),g.className="flex items-center gap-3 mt-2";const b=document.createElement("button");b.type="button",b.className="add-textarea-btn px-3 py-1 rounded",b.style.cssText=`
48
+ `,u.nextSibling?(d=u.parentNode)==null||d.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=f,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,f,d)=>{let m=!1;const{state:b}=n;if(!s&&f){if(e.minLength!==void 0&&e.minLength!==null&&f.length<e.minLength){const y=$("minLength",b,{min:e.minLength});l.push(`${d}: ${y}`),c(u,y),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&f.length>e.maxLength){const y=$("maxLength",b,{max:e.maxLength});l.push(`${d}: ${y}`),c(u,y),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(f)){const y=$("patternMismatch",b);l.push(`${d}: ${y}`),c(u,y),m=!0}}catch(y){const w=$("invalidPattern",b);l.push(`${d}: ${w}`),c(u,w),m=!0}}m||c(u,null)};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["]`),f=[],d=[];if(u.forEach((m,b)=>{var y;const w=(y=m==null?void 0:m.value)!=null?y:"";d.push(w),f.push(w===""?null:w),p(m,w,`${t}[${b}]`)}),!s){const{state:m}=n,b=(r=e.minCount)!=null?r:1,y=(o=e.maxCount)!=null?o:1/0,w=d.filter(v=>v.trim()!=="");e.required&&w.length===0&&l.push(`${t}: ${$("required",m)}`),w.length<b&&l.push(`${t}: ${$("minItems",m,{min:b})}`),w.length>y&&l.push(`${t}: ${$("maxItems",m,{max:y})}`)}return{value:f,errors:l}}else{const u=a.querySelector(`[name$="${t}"]`),f=(i=u==null?void 0:u.value)!=null?i:"";if(!s&&e.required&&f===""){const d=$("required",n.state);return l.push(`${t}: ${d}`),c(u,d),{value:null,errors:l}}return u&&p(u,f,t),{value:f===""?null:f,errors:l}}}function jt(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function Ot(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 or(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.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=r,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=i,!i&&t.instance){const s=()=>{const c=a.value===""?null:a.value;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if((e.autoExpand||i)&&Ot(a),l.appendChild(a),!i&&(e.minLength!=null||e.maxLength!=null)){const s=je(e,a,!0);l.appendChild(s)}n.appendChild(l)}function lr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-textarea-item").forEach((h,g)=>{const E=h.querySelector("textarea");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-textarea-item";const C=document.createElement("div");C.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",l),x.rows=e.rows||4,x.value=h,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)&&Ot(x),C.appendChild(x),!a&&(e.minLength!=null||e.maxLength!=null)){const k=je(e,x,!0);C.appendChild(k)}return E.appendChild(C),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function b(){if(a)return;const h=f.querySelectorAll(".multiple-textarea-item"),g=h.length;h.forEach(E=>{let C=E.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(c.splice(k,1),E.remove(),d(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-textarea-btn px-3 py-1 rounded",h.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
- `,b.textContent="+",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),v()},E=document.createElement("span"),E.className="text-sm text-gray-500",g.appendChild(b),g.appendChild(E),n.appendChild(g)}function h(){if(!g||!E)return;const b=g.querySelector(".add-textarea-btn");if(b){const y=s.length>=d;b.disabled=y,b.style.opacity=y?"0.5":"1",b.style.pointerEvents=y?"none":"auto"}E.textContent=`${s.length}/${d===1/0?"\u221E":d}`}s.forEach(b=>m(b)),h(),v()}function $n(e,t,n){return Ct(e,t,n)}function Ln(e,t,n,r){wt(e,t,n,r);const{scopeRoot:o,state:a}=r;if(e.autoExpand||le(e,a))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(l=>{l.dispatchEvent(new Event("input"))});else{const l=o.querySelector(`textarea[name="${t}"]`);l&&l.dispatchEvent(new Event("input"))}}function $t(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
54
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-textarea-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function ir(e,t,n){return Dt(e,t,n)}function ar(e,t,n,r){jt(e,t,n,r);const{scopeRoot:o,state:i}=r;if(e.autoExpand||le(e,i))if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(l=>{l.dispatchEvent(new Event("input"))});else{const l=o.querySelector(`textarea[name="${t}"]`);l&&l.dispatchEvent(new Event("input"))}}function Ut(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,31 +61,31 @@ var FormBuilder=(function(Ee){"use strict";function $(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,o=e.max;let a="";r!=null&&o!=null?a=`${r} \u2013 ${o}`:o!=null?a=`\u2264${o}`:r!=null&&(a=`\u2265${r}`),n.textContent=a;const l=()=>{const i=t.value?parseFloat(t.value):null;if(i!=null){const c=r!=null&&i<r,s=o!=null&&i>o;n.style.color=c||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",l),l(),n}function Sn(e,t,n,r){const o=t.state,a=le(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const i=document.createElement("input");if(i.type="number",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.style.cssText="padding-right: 60px; width: 100%; box-sizing: border-box;",i.name=r,i.placeholder=e.placeholder||"0",e.min!==void 0&&(i.min=e.min.toString()),e.max!==void 0&&(i.max=e.max.toString()),e.step!==void 0&&(i.step=e.step.toString()),i.value=t.prefill[e.key]||e.default||"",i.readOnly=a,!a&&t.instance){const c=()=>{const s=i.value?parseFloat(i.value):null;t.instance.triggerOnChange(r,s)};i.addEventListener("blur",c),i.addEventListener("input",c)}if(l.appendChild(i),!a&&(e.min!=null||e.max!=null)){const c=$t(e,i);l.appendChild(c)}n.appendChild(l)}function Tn(e,t,n,r){var o,a;const l=t.state,i=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:1,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function u(){p.querySelectorAll(".multiple-number-item").forEach((b,y)=>{const w=b.querySelector("input");w&&(w.name=`${r}[${y}]`)})}function m(b="",y=-1){const w=document.createElement("div");w.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.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=b.toString(),x.readOnly=i,!i&&t.instance){const k=()=>{const z=x.value?parseFloat(x.value):null;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",k),x.addEventListener("input",k)}if(C.appendChild(x),!i&&(e.min!=null||e.max!=null)){const k=$t(e,x);C.appendChild(k)}return w.appendChild(C),y===-1?p.appendChild(w):p.insertBefore(w,p.children[y]),u(),w}function v(){if(i)return;const b=p.querySelectorAll(".multiple-number-item"),y=b.length;b.forEach(w=>{let C=w.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(p.children).indexOf(w);p.children.length>f&&(s.splice(k,1),w.remove(),u(),h(),v())},w.appendChild(C));const x=y<=f;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let g=null,E=null;if(!i){g=document.createElement("div"),g.className="flex items-center gap-3 mt-2";const b=document.createElement("button");b.type="button",b.className="add-number-btn px-3 py-1 rounded",b.style.cssText=`
64
+ `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const l=()=>{const a=t.value?parseFloat(t.value):null;if(a!=null){const s=r!=null&&a<r,c=o!=null&&a>o;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",l),l(),n}function sr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("div");l.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=r,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=i,!i&&t.instance){const s=()=>{const c=a.value?parseFloat(a.value):null;t.instance.triggerOnChange(r,c)};a.addEventListener("blur",s),a.addEventListener("input",s)}if(l.appendChild(a),!i&&(e.min!=null||e.max!=null)){const s=Ut(e,a);l.appendChild(s)}n.appendChild(l)}function cr(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-number-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="",g=-1){const E=document.createElement("div");E.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.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=h.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(C.appendChild(x),!a&&(e.min!=null||e.max!=null)){const k=Ut(e,x);C.appendChild(k)}return E.appendChild(C),g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function b(){if(a)return;const h=f.querySelectorAll(".multiple-number-item"),g=h.length;h.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 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(c.splice(k,1),E.remove(),d(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-number-btn px-3 py-1 rounded",h.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
- `,b.textContent="+",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{s.push(e.default||""),m(e.default||""),h(),v()},E=document.createElement("span"),E.className="text-sm text-gray-500",g.appendChild(b),g.appendChild(E),n.appendChild(g)}function h(){if(!g||!E)return;const b=g.querySelector(".add-number-btn");if(b){const y=s.length>=d;b.disabled=y,b.style.opacity=y?"0.5":"1",b.style.pointerEvents=y?"none":"auto"}E.textContent=`${s.length}/${d===1/0?"\u221E":d}`}s.forEach(b=>m(b)),h(),v()}function An(e,t,n){var r,o,a,l,i;const c=[],{scopeRoot:s,skipValidation:f}=n,d=(u,m)=>{var v,g;if(!u)return;const E=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let h=document.getElementById(E);m?(u.classList.add("invalid"),u.title=m,h||(h=document.createElement("div"),h.id=E,h.className="error-message",h.style.cssText=`
70
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{c.push(e.default||""),m(e.default||""),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-number-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}c.forEach(h=>m(h)),v(),b()}function ur(e,t,n){var r,o,i,l,a;const s=[],{scopeRoot:c,skipValidation:p}=n,u=(d,m)=>{var b,y;if(!d)return;const w=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(w);m?(d.classList.add("invalid"),d.title=m,v||(v=document.createElement("div"),v.id=w,v.className="error-message",v.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
- `,u.nextSibling?(v=u.parentNode)==null||v.insertBefore(h,u.nextSibling):(g=u.parentNode)==null||g.appendChild(h)),h.textContent=m,h.style.display="block"):(u.classList.remove("invalid"),u.title="",h&&h.remove())},p=(u,m,v)=>{let g=!1;const{state:E}=n;if(!f&&e.min!==void 0&&e.min!==null&&m<e.min){const h=$("minValue",E,{min:e.min});c.push(`${v}: ${h}`),d(u,h),g=!0}else if(!f&&e.max!==void 0&&e.max!==null&&m>e.max){const h=$("maxValue",E,{max:e.max});c.push(`${v}: ${h}`),d(u,h),g=!0}g||d(u,null)};if(e.multiple){const u=s.querySelectorAll(`[name^="${t}["]`),m=[];if(u.forEach((v,g)=>{var E,h,b;const y=(E=v==null?void 0:v.value)!=null?E:"";if(y===""){m.push(null),d(v,null);return}const w=parseFloat(y);if(!f&&!Number.isFinite(w)){const x=$("notANumber",n.state);c.push(`${t}[${g}]: ${x}`),d(v,x),m.push(null);return}p(v,w,`${t}[${g}]`);const C=Number.isInteger((h=e.decimals)!=null?h:0)&&(b=e.decimals)!=null?b:0;m.push(Number(w.toFixed(C)))}),!f){const{state:v}=n,g=(r=e.minCount)!=null?r:1,E=(o=e.maxCount)!=null?o:1/0,h=m.filter(b=>b!==null);e.required&&h.length===0&&c.push(`${t}: ${$("required",v)}`),h.length<g&&c.push(`${t}: ${$("minItems",v,{min:g})}`),h.length>E&&c.push(`${t}: ${$("maxItems",v,{max:E})}`)}return{value:m,errors:c}}else{const u=s.querySelector(`[name$="${t}"]`),m=(a=u==null?void 0:u.value)!=null?a:"",{state:v}=n;if(!f&&e.required&&m===""){const h=$("required",v);return c.push(`${t}: ${h}`),d(u,h),{value:null,errors:c}}if(m==="")return d(u,null),{value:null,errors:c};const g=parseFloat(m);if(!f&&!Number.isFinite(g)){const h=$("notANumber",v);return c.push(`${t}: ${h}`),d(u,h),{value:null,errors:c}}p(u,g,t);const E=Number.isInteger((l=e.decimals)!=null?l:0)&&(i=e.decimals)!=null?i:0;return{value:Number(g.toFixed(E)),errors:c}}}function Fn(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.classList.remove("invalid"),l.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=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="")}}function Nn(e,t,n,r){const o=t.state,a=le(e,o,t),l=document.createElement("select");if(l.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.name=r,l.disabled=a,(e.options||[]).forEach(i=>{const c=document.createElement("option");c.value=i.value,c.textContent=i.label,(t.prefill[e.key]||e.default)===i.value&&(c.selected=!0),l.appendChild(c)}),!a&&t.instance){const i=()=>{t.instance.triggerOnChange(r,l.value)};l.addEventListener("change",i)}if(n.appendChild(l),!a){const i=document.createElement("p");i.className="text-xs text-gray-500 mt-1",i.textContent=be(e,o),n.appendChild(i)}}function Mn(e,t,n,r){var o,a,l,i;const c=t.state,s=le(e,c,t),f=t.prefill[e.key]||[],d=Array.isArray(f)?[...f]:[],p=(o=e.minCount)!=null?o:1,u=(a=e.maxCount)!=null?a:1/0;for(;d.length<p;)d.push(e.default||((i=(l=e.options)==null?void 0:l[0])==null?void 0:i.value)||"");const m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function v(){m.querySelectorAll(".multiple-select-item").forEach((w,C)=>{const x=w.querySelector("select");x&&(x.name=`${r}[${C}]`)})}function g(w="",C=-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=s,(e.options||[]).forEach(z=>{const W=document.createElement("option");W.value=z.value,W.textContent=z.label,w===z.value&&(W.selected=!0),k.appendChild(W)}),!s&&t.instance){const z=()=>{t.instance.triggerOnChange(k.name,k.value)};k.addEventListener("change",z)}return x.appendChild(k),C===-1?m.appendChild(x):m.insertBefore(x,m.children[C]),v(),x}function E(){if(s)return;const w=m.querySelectorAll(".multiple-select-item"),C=w.length;w.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 W=Array.from(m.children).indexOf(x);m.children.length>p&&(d.splice(W,1),x.remove(),v(),y(),E())},x.appendChild(k));const z=C<=p;k.disabled=z,k.style.opacity=z?"0.5":"1",k.style.pointerEvents=z?"none":"auto"})}let h=null,b=null;if(!s){h=document.createElement("div"),h.className="flex items-center gap-3 mt-2";const w=document.createElement("button");w.type="button",w.className="add-select-btn px-3 py-1 rounded",w.style.cssText=`
74
+ `,d.nextSibling?(b=d.parentNode)==null||b.insertBefore(v,d.nextSibling):(y=d.parentNode)==null||y.appendChild(v)),v.textContent=m,v.style.display="block"):(d.classList.remove("invalid"),d.title="",v&&v.remove())},f=(d,m,b)=>{let y=!1;const{state:w}=n;if(!p&&e.min!==void 0&&e.min!==null&&m<e.min){const v=$("minValue",w,{min:e.min});s.push(`${b}: ${v}`),u(d,v),y=!0}else if(!p&&e.max!==void 0&&e.max!==null&&m>e.max){const v=$("maxValue",w,{max:e.max});s.push(`${b}: ${v}`),u(d,v),y=!0}y||u(d,null)};if(e.multiple){const d=c.querySelectorAll(`[name^="${t}["]`),m=[];if(d.forEach((b,y)=>{var w,v,h;const g=(w=b==null?void 0:b.value)!=null?w:"";if(g===""){m.push(null),u(b,null);return}const E=parseFloat(g);if(!p&&!Number.isFinite(E)){const x=$("notANumber",n.state);s.push(`${t}[${y}]: ${x}`),u(b,x),m.push(null);return}f(b,E,`${t}[${y}]`);const C=Number.isInteger((v=e.decimals)!=null?v:0)&&(h=e.decimals)!=null?h:0;m.push(Number(E.toFixed(C)))}),!p){const{state:b}=n,y=(r=e.minCount)!=null?r:1,w=(o=e.maxCount)!=null?o:1/0,v=m.filter(h=>h!==null);e.required&&v.length===0&&s.push(`${t}: ${$("required",b)}`),v.length<y&&s.push(`${t}: ${$("minItems",b,{min:y})}`),v.length>w&&s.push(`${t}: ${$("maxItems",b,{max:w})}`)}return{value:m,errors:s}}else{const d=c.querySelector(`[name$="${t}"]`),m=(i=d==null?void 0:d.value)!=null?i:"",{state:b}=n;if(!p&&e.required&&m===""){const v=$("required",b);return s.push(`${t}: ${v}`),u(d,v),{value:null,errors:s}}if(m==="")return u(d,null),{value:null,errors:s};const y=parseFloat(m);if(!p&&!Number.isFinite(y)){const v=$("notANumber",b);return s.push(`${t}: ${v}`),u(d,v),{value:null,errors:s}}f(d,y,t);const w=Number.isInteger((l=e.decimals)!=null?l:0)&&(a=e.decimals)!=null?a:0;return{value:Number(y.toFixed(w)),errors:s}}}function dr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="")}}function fr(e,t,n,r){const o=t.state,i=le(e,o,t),l=document.createElement("select");if(l.className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.name=r,l.disabled=i,(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),l.appendChild(s)}),!i&&t.instance){const a=()=>{t.instance.triggerOnChange(r,l.value)};l.addEventListener("change",a)}if(n.appendChild(l),!i){const a=document.createElement("p");a.className="text-xs text-gray-500 mt-1",a.textContent=ve(e,o),n.appendChild(a)}}function pr(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=t.prefill[e.key]||[],u=Array.isArray(p)?[...p]:[],f=(o=e.minCount)!=null?o:1,d=(i=e.maxCount)!=null?i:1/0;for(;u.length<f;)u.push(e.default||((a=(l=e.options)==null?void 0:l[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((E,C)=>{const x=E.querySelector("select");x&&(x.name=`${r}[${C}]`)})}function y(E="",C=-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,E===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),C===-1?m.appendChild(x):m.insertBefore(x,m.children[C]),b(),x}function w(){if(c)return;const E=m.querySelectorAll(".multiple-select-item"),C=E.length;E.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>f&&(u.splice(K,1),x.remove(),b(),g(),w())},x.appendChild(k));const q=C<=f;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let v=null,h=null;if(!c){v=document.createElement("div"),v.className="flex items-center gap-3 mt-2";const E=document.createElement("button");E.type="button",E.className="add-select-btn px-3 py-1 rounded",E.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
- `,w.textContent="+",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var C,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";d.push(k),g(k),y(),E()},b=document.createElement("span"),b.className="text-sm text-gray-500",h.appendChild(w),h.appendChild(b),n.appendChild(h)}function y(){if(!h||!b)return;const w=h.querySelector(".add-select-btn");if(w){const C=d.length>=u;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"}b.textContent=`${d.length}/${u===1/0?"\u221E":u}`}if(d.forEach(w=>g(w)),y(),E(),!s){const w=document.createElement("p");w.className="text-xs text-gray-500 mt-1",w.textContent=be(e,c),n.appendChild(w)}}function qn(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(s,f)=>{var d,p;if(!s)return;const u=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(u);f?(s.classList.add("invalid"),s.title=f,m||(m=document.createElement("div"),m.id=u,m.className="error-message",m.style.cssText=`
80
+ `,E.textContent="+",E.addEventListener("mouseenter",()=>{E.style.backgroundColor="var(--fb-background-hover-color)"}),E.addEventListener("mouseleave",()=>{E.style.backgroundColor="transparent"}),E.onclick=()=>{var C,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";u.push(k),y(k),g(),w()},h=document.createElement("span"),h.className="text-sm text-gray-500",v.appendChild(E),v.appendChild(h),n.appendChild(v)}function g(){if(!v||!h)return;const E=v.querySelector(".add-select-btn");if(E){const C=u.length>=d;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"}h.textContent=`${u.length}/${d===1/0?"\u221E":d}`}if(u.forEach(E=>y(E)),g(),w(),!c){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=ve(e,s),n.appendChild(E)}}function mr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(c,p)=>{var u,f;if(!c)return;const d=`error-${c.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(d);p?(c.classList.add("invalid"),c.title=p,m||(m=document.createElement("div"),m.id=d,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
- `,s.nextSibling?(d=s.parentNode)==null||d.insertBefore(m,s.nextSibling):(p=s.parentNode)==null||p.appendChild(m)),m.textContent=f,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},c=(s,f,d,p)=>{var u,m;if(l)return;const{state:v}=n,g=f.filter(p),E="minCount"in d&&(u=d.minCount)!=null?u:1,h="maxCount"in d&&(m=d.maxCount)!=null?m:1/0;d.required&&g.length===0&&o.push(`${s}: ${$("required",v)}`),g.length<E&&o.push(`${s}: ${$("minItems",v,{min:E})}`),g.length>h&&o.push(`${s}: ${$("maxItems",v,{max:h})}`)};if("multiple"in e&&e.multiple){const s=a.querySelectorAll(`[name^="${t}["]`),f=[];return s.forEach(d=>{var p;const u=(p=d==null?void 0:d.value)!=null?p:"";f.push(u),i(d,null)}),c(t,f,e,d=>d!==""),{value:f,errors:o}}else{const s=a.querySelector(`[name$="${t}"]`),f=(r=s==null?void 0:s.value)!=null?r:"";if(!l&&e.required&&f===""){const d=$("required",n.state);return o.push(`${t}: ${d}`),i(s,d),{value:null,errors:o}}else i(s,null);return{value:f===""?null:f,errors:o}}}function zn(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.querySelectorAll("option").forEach(c=>{c.selected=c.value===String(n[i])}),l.classList.remove("invalid"),l.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=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.querySelectorAll("option").forEach(l=>{l.selected=l.value===String(n)}),a.classList.remove("invalid"),a.title="")}}function Ue(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function Pe(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Lt(e,t,n,r,o){const a=e.options||[],l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=`
84
+ `,c.nextSibling?(u=c.parentNode)==null||u.insertBefore(m,c.nextSibling):(f=c.parentNode)==null||f.appendChild(m)),m.textContent=p,m.style.display="block"):(c.classList.remove("invalid"),c.title="",m&&m.remove())},s=(c,p,u,f)=>{var d,m;if(l)return;const{state:b}=n,y=p.filter(f),w="minCount"in u&&(d=u.minCount)!=null?d:1,v="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&y.length===0&&o.push(`${c}: ${$("required",b)}`),y.length<w&&o.push(`${c}: ${$("minItems",b,{min:w})}`),y.length>v&&o.push(`${c}: ${$("maxItems",b,{max:v})}`)};if("multiple"in e&&e.multiple){const c=i.querySelectorAll(`[name^="${t}["]`),p=[];return c.forEach(u=>{var f;const d=(f=u==null?void 0:u.value)!=null?f:"";p.push(d),a(u,null)}),s(t,p,e,u=>u!==""),{value:p,errors:o}}else{const c=i.querySelector(`[name$="${t}"]`),p=(r=c==null?void 0:c.value)!=null?r:"";if(!l&&e.required&&p===""){const u=$("required",n.state);return o.push(`${t}: ${u}`),a(c,u),{value:null,errors:o}}else a(c,null);return{value:p===""?null:p,errors:o}}}function hr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["]`);i.forEach((l,a)=>{a<n.length&&(l.value=n[a]!=null?String(n[a]):"",l.querySelectorAll("option").forEach(s=>{s.selected=s.value===String(n[a])}),l.classList.remove("invalid"),l.title="")}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.querySelectorAll("option").forEach(l=>{l.selected=l.value===String(n)}),i.classList.remove("invalid"),i.title="")}}function Ye(e){e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)"}function Xe(e){e.style.backgroundColor="transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Pt(e,t,n,r,o){const i=e.options||[],l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=`
85
85
  display: inline-flex;
86
86
  flex-direction: row;
87
87
  flex-wrap: nowrap;
88
- `;const i=[];return a.forEach((c,s)=>{const f=document.createElement("button");f.type="button",f.className="fb-switcher-btn",f.dataset.value=c.value,f.textContent=c.label,f.style.cssText=`
88
+ `;const a=[];return i.forEach((s,c)=>{const p=document.createElement("button");p.type="button",p.className="fb-switcher-btn",p.dataset.value=s.value,p.textContent=s.label,p.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);
@@ -95,142 +95,492 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
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)":s===0?(f.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",f.style.borderRightWidth="0"):s===a.length-1?f.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(f.style.borderRadius="0",f.style.borderRightWidth="0"),c.value===t?Ue(f):Pe(f),r||(f.addEventListener("click",()=>{n.value=c.value,i.forEach(d=>{d.dataset.value===c.value?Ue(d):Pe(d)}),o&&o(c.value)}),f.addEventListener("mouseenter",()=>{n.value!==c.value&&(f.style.backgroundColor="var(--fb-background-hover-color)")}),f.addEventListener("mouseleave",()=>{n.value!==c.value&&(f.style.backgroundColor="transparent")})),i.push(f),l.appendChild(f)}),l}function In(e,t,n,r){var o,a;const l=t.state,i=String((a=(o=t.prefill[e.key])!=null?o:e.default)!=null?a:""),c=document.createElement("input");c.type="hidden",c.name=r,c.value=i;const s=le(e,l,t),f=!s&&t.instance?p=>{t.instance.triggerOnChange(r,p)}:null,d=Lt(e,i,c,s,f);if(n.appendChild(c),n.appendChild(d),!s){const p=document.createElement("p");p.className="text-xs text-gray-500 mt-1",p.textContent=be(e,l),n.appendChild(p)}}function Hn(e,t,n,r){var o,a,l,i;const c=t.state,s=t.prefill[e.key]||[],f=Array.isArray(s)?[...s]:[],d=(o=e.minCount)!=null?o:1,p=(a=e.maxCount)!=null?a:1/0;for(;f.length<d;)f.push(e.default||((i=(l=e.options)==null?void 0:l[0])==null?void 0:i.value)||"");const u=le(e,c,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function v(){m.querySelectorAll(".multiple-switcher-item").forEach((w,C)=>{const x=w.querySelector("input[type=hidden]");x&&(x.name=`${r}[${C}]`)})}function g(w="",C=-1){const x=C===-1?m.children.length:C,k=`${r}[${x}]`,z=document.createElement("div");z.className="multiple-switcher-item flex items-center gap-2";const W=document.createElement("input");W.type="hidden",W.name=k,W.value=w,z.appendChild(W);const H=!u&&t.instance?Q=>{t.instance.triggerOnChange(W.name,Q)}:null,Z=Lt(e,w,W,u,H);return z.appendChild(Z),C===-1?m.appendChild(z):m.insertBefore(z,m.children[C]),v(),z}function E(){if(u)return;const w=m.querySelectorAll(".multiple-switcher-item"),C=w.length;w.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=`
98
+ `,i.length===1?p.style.borderRadius="var(--fb-border-radius)":c===0?(p.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",p.style.borderRightWidth="0"):c===i.length-1?p.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(p.style.borderRadius="0",p.style.borderRightWidth="0"),s.value===t?Ye(p):Xe(p),r||(p.addEventListener("click",()=>{n.value=s.value,a.forEach(u=>{u.dataset.value===s.value?Ye(u):Xe(u)}),o&&o(s.value)}),p.addEventListener("mouseenter",()=>{n.value!==s.value&&(p.style.backgroundColor="var(--fb-background-hover-color)")}),p.addEventListener("mouseleave",()=>{n.value!==s.value&&(p.style.backgroundColor="transparent")})),a.push(p),l.appendChild(p)}),l}function vr(e,t,n,r){var o,i;const l=t.state,a=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),s=document.createElement("input");s.type="hidden",s.name=r,s.value=a;const c=le(e,l,t),p=!c&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,u=Pt(e,a,s,c,p);if(n.appendChild(s),n.appendChild(u),!c){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=ve(e,l),n.appendChild(f)}}function br(e,t,n,r){var o,i,l,a;const s=t.state,c=t.prefill[e.key]||[],p=Array.isArray(c)?[...c]:[],u=(o=e.minCount)!=null?o:1,f=(i=e.maxCount)!=null?i:1/0;for(;p.length<u;)p.push(e.default||((a=(l=e.options)==null?void 0:l[0])==null?void 0:a.value)||"");const d=le(e,s,t),m=document.createElement("div");m.className="space-y-2",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((E,C)=>{const x=E.querySelector("input[type=hidden]");x&&(x.name=`${r}[${C}]`)})}function y(E="",C=-1){const x=C===-1?m.children.length:C,k=`${r}[${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=E,q.appendChild(K);const R=!d&&t.instance?Z=>{t.instance.triggerOnChange(K.name,Z)}:null,G=Pt(e,E,K,d,R);return q.appendChild(G),C===-1?m.appendChild(q):m.insertBefore(q,m.children[C]),b(),q}function w(){if(d)return;const E=m.querySelectorAll(".multiple-switcher-item"),C=E.length;E.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
- `,k.innerHTML="\u2715",k.addEventListener("mouseenter",()=>{k.style.backgroundColor="var(--fb-background-hover-color)"}),k.addEventListener("mouseleave",()=>{k.style.backgroundColor="transparent"}),k.onclick=()=>{const W=Array.from(m.children).indexOf(x);m.children.length>d&&(f.splice(W,1),x.remove(),v(),y(),E())},x.appendChild(k));const z=C<=d;k.disabled=z,k.style.opacity=z?"0.5":"1",k.style.pointerEvents=z?"none":"auto"})}let h=null,b=null;if(!u){h=document.createElement("div"),h.className="flex items-center gap-3 mt-2";const w=document.createElement("button");w.type="button",w.className="add-switcher-btn px-3 py-1 rounded",w.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&&(p.splice(K,1),x.remove(),b(),g(),w())},x.appendChild(k));const q=C<=u;k.disabled=q,k.style.opacity=q?"0.5":"1",k.style.pointerEvents=q?"none":"auto"})}let v=null,h=null;if(!d){v=document.createElement("div"),v.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=`
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
- `,w.textContent="+",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var C,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";f.push(k),g(k),y(),E()},b=document.createElement("span"),b.className="text-sm text-gray-500",h.appendChild(w),h.appendChild(b),n.appendChild(h)}function y(){if(!h||!b)return;const w=h.querySelector(".add-switcher-btn");if(w){const C=f.length>=p;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"}b.textContent=`${f.length}/${p===1/0?"\u221E":p}`}if(f.forEach(w=>g(w)),y(),E(),!u){const w=document.createElement("p");w.className="text-xs text-gray-500 mt-1",w.textContent=be(e,c),n.appendChild(w)}}function Rn(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(f,d)=>{var p,u;if(!f)return;const m=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(m);d?(f.classList.add("invalid"),f.title=d,v||(v=document.createElement("div"),v.id=m,v.className="error-message",v.style.cssText=`
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,x;const k=e.default||((x=(C=e.options)==null?void 0:C[0])==null?void 0:x.value)||"";p.push(k),y(k),g(),w()},h=document.createElement("span"),h.className="text-sm text-gray-500",v.appendChild(E),v.appendChild(h),n.appendChild(v)}function g(){if(!v||!h)return;const E=v.querySelector(".add-switcher-btn");if(E){const C=p.length>=f;E.disabled=C,E.style.opacity=C?"0.5":"1",E.style.pointerEvents=C?"none":"auto"}h.textContent=`${p.length}/${f===1/0?"\u221E":f}`}if(p.forEach(E=>y(E)),g(),w(),!d){const E=document.createElement("p");E.className="text-xs text-gray-500 mt-1",E.textContent=ve(e,s),n.appendChild(E)}}function gr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:l}=n,a=(p,u)=>{var f,d;if(!p)return;const m=`error-${p.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);u?(p.classList.add("invalid"),p.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?(p=f.parentNode)==null||p.insertBefore(v,f.nextSibling):(u=f.parentNode)==null||u.appendChild(v)),v.textContent=d,v.style.display="block"):(f.classList.remove("invalid"),f.title="",v&&v.remove())},c=(f,d,p,u)=>{var m,v;if(l)return;const{state:g}=n,E=d.filter(u),h="minCount"in p&&(m=p.minCount)!=null?m:1,b="maxCount"in p&&(v=p.maxCount)!=null?v:1/0;p.required&&E.length===0&&o.push(`${f}: ${$("required",g)}`),E.length<h&&o.push(`${f}: ${$("minItems",g,{min:h})}`),E.length>b&&o.push(`${f}: ${$("maxItems",g,{max:b})}`)},s=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}["]`),d=[];return f.forEach(p=>{var u;const m=(u=p==null?void 0:p.value)!=null?u:"";if(d.push(m),!l&&m!==""&&!s.has(m)){const v=$("invalidOption",n.state);i(p,v),o.push(`${t}: ${v}`)}else i(p,null)}),c(t,d,e,p=>p!==""),{value:d,errors:o}}else{const f=a.querySelector(`input[type="hidden"][name$="${t}"]`),d=(r=f==null?void 0:f.value)!=null?r:"";if(!l&&e.required&&d===""){const p=$("required",n.state);return o.push(`${t}: ${p}`),i(f,p),{value:null,errors:o}}if(!l&&d!==""&&!s.has(d)){const p=$("invalidOption",n.state);return o.push(`${t}: ${p}`),i(f,p),{value:null,errors:o}}return i(f,null),{value:d===""?null:d,errors:o}}}function Bn(e,t,n,r){var o;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 l=a.querySelectorAll(`input[type="hidden"][name^="${t}["]`);l.forEach((i,c)=>{var s;if(c<n.length){const f=n[c]!=null?String(n[c]):"";i.value=f;const d=(s=i.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(p=>{p.dataset.value===f?Ue(p):Pe(p)}),i.classList.remove("invalid"),i.title=""}}),n.length!==l.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=a.querySelector(`input[type="hidden"][name="${t}"]`);if(l){const i=n!=null?String(n):"";l.value=i;const c=(o=l.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(s=>{s.dataset.value===i?Ue(s):Pe(s)}),l.classList.remove("invalid"),l.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 $e(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 Ae(e,t){return t===1/0?!0:e.size<=t*1024*1024}function Dn(e,t,n,r){const o=document.createElement("img");o.className="w-full h-full object-contain",o.alt=n||$("previewAlt",r);const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(t),e.appendChild(o)}function jn(e,t,n,r,o,a){const l=URL.createObjectURL(t);e.onclick=null;const i=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(i,e),i.innerHTML=`
113
- <div class="relative group h-full">
112
+ `,p.nextSibling?(f=p.parentNode)==null||f.insertBefore(b,p.nextSibling):(d=p.parentNode)==null||d.appendChild(b)),b.textContent=u,b.style.display="block"):(p.classList.remove("invalid"),p.title="",b&&b.remove())},s=(p,u,f,d)=>{var m,b;if(l)return;const{state:y}=n,w=u.filter(d),v="minCount"in f&&(m=f.minCount)!=null?m:1,h="maxCount"in f&&(b=f.maxCount)!=null?b:1/0;f.required&&w.length===0&&o.push(`${p}: ${$("required",y)}`),w.length<v&&o.push(`${p}: ${$("minItems",y,{min:v})}`),w.length>h&&o.push(`${p}: ${$("maxItems",y,{max:h})}`)},c=new Set("options"in e?e.options.map(p=>p.value):[]);if("multiple"in e&&e.multiple){const p=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`),u=[];return p.forEach(f=>{var d;const m=(d=f==null?void 0:f.value)!=null?d:"";if(u.push(m),!l&&m!==""&&!c.has(m)){const b=$("invalidOption",n.state);a(f,b),o.push(`${t}: ${b}`)}else a(f,null)}),s(t,u,e,f=>f!==""),{value:u,errors:o}}else{const p=i.querySelector(`input[type="hidden"][name$="${t}"]`),u=(r=p==null?void 0:p.value)!=null?r:"";if(!l&&e.required&&u===""){const f=$("required",n.state);return o.push(`${t}: ${f}`),a(p,f),{value:null,errors:o}}if(!l&&u!==""&&!c.has(u)){const f=$("invalidOption",n.state);return o.push(`${t}: ${f}`),a(p,f),{value:null,errors:o}}return a(p,null),{value:u===""?null:u,errors:o}}}function yr(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=i.querySelectorAll(`input[type="hidden"][name^="${t}["]`);l.forEach((a,s)=>{var c;if(s<n.length){const p=n[s]!=null?String(n[s]):"";a.value=p;const u=(c=a.parentElement)==null?void 0:c.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(f=>{f.dataset.value===p?Ye(f):Xe(f)}),a.classList.remove("invalid"),a.title=""}}),n.length!==l.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=i.querySelector(`input[type="hidden"][name="${t}"]`);if(l){const a=n!=null?String(n):"";l.value=a;const s=(o=l.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(c=>{c.dataset.value===a?Ye(c):Xe(c)}),l.classList.remove("invalid"),l.title=""}}}function ke(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 ze(e,t){var n,r;if(t.length===0)return!0;const o=(r=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?r:"";return t.includes(o)}function Vt(e,t){return t===1/0?!0:e<=t*1024*1024}function Ge(e,t){return Vt(e.size,t)}function qe(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Oe(e,t){if(t.length===0)return!0;const n=e.toLowerCase();return t.some(r=>{if(r.endsWith("/*")){const o=r.slice(0,-1);return n.startsWith(o)}return n===r})}function xr(e){var t;const n=(t=(e.split("/").pop()||"file").split(".").pop())==null?void 0:t.toLowerCase();if(n){if(["jpg","jpeg","png","gif","webp"].includes(n))return`image/${n==="jpg"?"jpeg":n}`;if(["mp4","webm","mov","avi"].includes(n))return`video/${n==="mov"?"quicktime":n}`}return"application/octet-stream"}function Ze(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:xr(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function Qe(e,t){for(const n of e)Ze(n,t)}const Wt="fb-file-styles";function et(){if(typeof document=="undefined"||document.getElementById(Wt))return;const e=document.createElement("style");e.id=Wt,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
+ /* Two-card empty-state layout (upload card + library card) */
378
+ .fb-file-card-row {
379
+ display: flex;
380
+ gap: 8px;
381
+ align-items: stretch;
382
+ }
383
+ .fb-file-card-row .fb-file-dropzone,
384
+ .fb-file-card-row .fb-file-library-card {
385
+ flex: 1;
386
+ min-width: 0;
387
+ }
388
+
389
+ /* Library picker card \u2014 mirrors .fb-file-dropzone styling */
390
+ .fb-file-library-card {
391
+ height: 128px;
392
+ border: 2px dashed var(--fb-file-upload-border-color, #d1d5db);
393
+ border-radius: var(--fb-border-radius, 0.5rem);
394
+ display: flex;
395
+ flex-direction: column;
396
+ align-items: center;
397
+ justify-content: center;
398
+ gap: 4px;
399
+ cursor: pointer;
400
+ background: none;
401
+ padding: 0;
402
+ transition:
403
+ border-color var(--fb-transition-duration, 200ms),
404
+ background var(--fb-transition-duration, 200ms);
405
+ width: 100%;
406
+ }
407
+ .fb-file-library-card:hover,
408
+ .fb-file-library-card:focus-visible {
409
+ border-color: var(--fb-file-upload-hover-border-color, #3b82f6);
410
+ background: var(--fb-background-hover-color, #f9fafb);
411
+ outline: none;
412
+ }
413
+ .fb-file-library-card-icon {
414
+ font-size: 24px;
415
+ line-height: 1;
416
+ flex-shrink: 0;
417
+ }
418
+ .fb-file-library-card-label {
419
+ font-size: 13px;
420
+ color: var(--fb-text-secondary-color, #6b7280);
421
+ }
422
+ .fb-file-library-card-hint {
423
+ font-size: 11px;
424
+ color: var(--fb-file-upload-text-color, #9ca3af);
425
+ }
426
+
427
+ /* Library "\u{1F4DA}" add-tile \u2014 same size/style as the "+" add tile */
428
+ .fb-tile-add-library {
429
+ border: 2px dashed var(--fb-file-upload-border-color, #d1d5db);
430
+ display: flex;
431
+ align-items: center;
432
+ justify-content: center;
433
+ cursor: pointer;
434
+ font-size: 24px;
435
+ color: var(--fb-file-upload-text-color, #9ca3af);
436
+ transition:
437
+ border-color var(--fb-transition-duration, 200ms),
438
+ color var(--fb-transition-duration, 200ms);
439
+ background: none;
440
+ padding: 0;
441
+ width: var(--fb-tile-size, 160px);
442
+ height: var(--fb-tile-size, 160px);
443
+ flex-shrink: 0;
444
+ position: relative;
445
+ overflow: hidden;
446
+ border-radius: var(--fb-border-radius, 0.5rem);
447
+ }
448
+ .fb-tile-add-library:hover,
449
+ .fb-tile-add-library:focus-visible {
450
+ border-color: var(--fb-file-upload-hover-border-color, #3b82f6);
451
+ color: var(--fb-text-color, #1f2937);
452
+ outline: none;
453
+ }
454
+
455
+ /* Hover zoom preview popup for image tiles \u2014 appended to document.body (fixed) */
456
+ .fb-tile-zoom-preview {
457
+ position: fixed;
458
+ z-index: 9999;
459
+ background: var(--fb-background-color, #fff);
460
+ border: 1px solid var(--fb-file-upload-border-color, #d1d5db);
461
+ border-radius: var(--fb-border-radius, 0.5rem);
462
+ box-shadow: 0 4px 16px rgba(0,0,0,0.18);
463
+ padding: 4px;
464
+ width: 350px;
465
+ height: 350px;
466
+ pointer-events: none;
467
+ opacity: 0;
468
+ transition: opacity 150ms ease;
469
+ }
470
+ .fb-tile-zoom-preview.fb-tile-zoom-preview--visible {
471
+ opacity: 1;
472
+ }
473
+ .fb-tile-zoom-preview-img {
474
+ width: 100%;
475
+ height: 100%;
476
+ object-fit: contain;
477
+ display: block;
478
+ background: var(--fb-file-upload-bg-color, #f3f4f6);
479
+ border-radius: calc(var(--fb-border-radius, 0.5rem) - 2px);
480
+ }
481
+ `,document.head.appendChild(e)}const tt="160px";function bt(){et();const e=document.createElement("div");return e.className="fb-tile",e}function Ee(e,t){var n,r;const o=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");o&&o.remove();const i=document.createElement("div");i.className="file-error-message error-message",i.style.cssText=`
482
+ color: var(--fb-error-color);
483
+ font-size: var(--fb-font-size-small);
484
+ margin-top: 0.25rem;
485
+ `,i.textContent=t,(r=e.closest(".space-y-2"))==null||r.appendChild(i)}function Ue(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function Er(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=$("removeElement",t),i.onclick=l=>{l.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function Cr(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 wr(e,t){et();const n=bt();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
486
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
487
+ <div class="fb-spinner"></div>
488
+ <div class="fb-tile-label">${re(r)}</div>
489
+ <div class="fb-tile-uploading-text">${re($("uploadingFile",t))}</div>
490
+ </div>`,n}function kr(e){const t=e.querySelector(".fb-tiles-wrap");if(t)return t;const n=e.querySelector(".fb-file-dropzone");n&&n.remove();const r=document.createElement("div");r.className="fb-tiles-wrap",r.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const o=document.createElement("div");return o.className="fb-tile fb-tile-add",o.innerHTML="+",r.appendChild(o),e.appendChild(r),r}function nt(e,t,n){const r=n?`<div class="text-xs text-gray-500 mt-1">${re(n)}</div>`:"";e.innerHTML=`
491
+ <div class="flex flex-col items-center justify-center h-full text-gray-400">
492
+ <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
493
+ <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"/>
494
+ </svg>
495
+ <div class="text-sm text-center">${re($("clickDragText",t))}</div>
496
+ ${r}
497
+ </div>
498
+ `}function Pe(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)})}const $r='<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>',Lr='<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>',Sr='<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 Tr(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Fr(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Kt(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:l}=e,a=document.createElement("div");a.className="fb-tile-actions";const s=(c,p,u)=>{const f=document.createElement("button");return f.type="button",f.className=`fb-tile-action-btn ${u}`,f.innerHTML=c,f.title=p,f.setAttribute("aria-label",p),f.addEventListener("click",d=>{d.stopPropagation()}),f};if(Tr(r,l)){const c=s($r,$("downloadFile",r),"fb-tile-action-download");c.addEventListener("click",()=>{Ar(o,i,r,l)}),a.appendChild(c)}if(Fr(r,l)){const c=s(Lr,$("openInNewTab",r),"fb-tile-action-open");c.addEventListener("click",()=>{Mr(o,r,l).catch(p=>{console.error("Open failed:",p)})}),a.appendChild(c)}if(t&&n){const c=s(Sr,$("removeElement",r),"fb-tile-action-remove");c.addEventListener("click",()=>{n()}),a.appendChild(c)}return a}const rt=new WeakMap;function _t(e){let t=rt.get(e);return t||(t=URL.createObjectURL(e),rt.set(e,t)),t}function gt(e){if(!e)return;const t=rt.get(e);t&&(URL.revokeObjectURL(t),rt.delete(e))}function Ar(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){en(r.file,t||r.file.name);return}Qt(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function Mr(e,t,n){let r=null;t.config.getDownloadUrl?r=t.config.getDownloadUrl(e):t.config.getThumbnail?r=await t.config.getThumbnail(e):(n==null?void 0:n.file)instanceof File&&(r=_t(n.file)),r&&window.open(r,"_blank")}let ge=null,$e=null,Fe=null,ot=null;function Nr(){if(!ge){ge=document.createElement("div"),ge.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",ge.appendChild(e),ge.addEventListener("mouseenter",Yt),ge.addEventListener("mouseleave",Jt)}return ge}function zr(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let l;n.top-r-o>=i?l=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?l=n.bottom+o:l=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let a=n.left+n.width/2-r/2;a=Math.max(i,Math.min(window.innerWidth-r-i,a)),e.style.top=`${l}px`,e.style.left=`${a}px`}function Jt(){Fe!==null&&clearTimeout(Fe),Fe=setTimeout(()=>{Fe=null,Xt()},100)}function Yt(){Fe!==null&&(clearTimeout(Fe),Fe=null)}function Xt(){$e!==null&&(clearTimeout($e),$e=null),ge&&ge.parentNode&&(ge.classList.remove("fb-tile-zoom-preview--visible"),ge.parentNode.removeChild(ge)),ot=null}function yt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Yt(),ot!==e&&Xt(),ot=e,$e=setTimeout(()=>{$e=null;const o=Nr(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const l=o.querySelector(".fb-tile-zoom-preview-img");l.src=t,l.alt=n,r&&(o.appendChild(r.cloneNode(!0)),qr(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",zr(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{$e!==null?(clearTimeout($e),$e=null,ot=null):Jt()})}function qr(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",l=>{l.stopPropagation(),i.click()})})}function Ir(e,t,n,r){const o=document.createElement("img");o.className="w-full h-full object-contain",o.style.background="var(--fb-file-upload-bg-color,#f3f4f6)",o.alt=n||$("previewAlt",r);const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(t),e.appendChild(o)}function Rr(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function Hr(e,t,n,r,o,i){const l=URL.createObjectURL(t),a=Rr(e);return a.innerHTML=`
499
+ <div class="fb-video-preview-wrap">
114
500
  <video class="w-full h-full object-contain" controls preload="auto" muted src="${l}">
115
- ${J($("videoNotSupported",o))}
501
+ ${re($("videoNotSupported",o))}
116
502
  </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($("removeElement",o))}
503
+ <div class="fb-video-btn-overlay">
504
+ <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
505
+ ${re($("removeElement",o))}
120
506
  </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($("changeButton",o))}
507
+ <button class="fb-video-btn fb-video-btn-change change-file-btn">
508
+ ${re($("changeButton",o))}
123
509
  </button>
124
510
  </div>
125
511
  </div>
126
- `,On(i,r,o,a),i}function On(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{l.stopPropagation(),r!=null&&r.picker&&r.picker.click()});const a=e.querySelector(".delete-file-btn");a&&(a.onclick=l=>{l.stopPropagation(),Un(e,t,n,r)})}function Un(e,t,n,r){var o;n.resourceIndex.delete(t);const a=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');a&&(a.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),r!=null&&r.dragHandler&&at(e,r.dragHandler),e.innerHTML=`
512
+ `,Br(a,r,o,i),a}function Br(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{var a;l.stopPropagation(),(a=r==null?void 0:r.picker)==null||a.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=l=>{l.stopPropagation(),Dr(e,t,n,r)})}function Dr(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
127
513
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
128
514
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
129
515
  <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
516
  </svg>
131
- <div class="text-sm text-center">${J($("clickDragText",n))}</div>
517
+ <div class="text-sm text-center">${re($("clickDragText",n))}</div>
132
518
  </div>
133
- `}function Pn(e,t,n,r){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",r))),e.appendChild(o)}function St(e,t,n){_n(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
519
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function Gt(e,t,n){Er(e,n,()=>{var r;n.resourceIndex.delete(t);const o=(r=e.parentElement)==null?void 0:r.querySelector('input[type="hidden"]');o&&(o.value=""),e.innerHTML=`
134
520
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
135
521
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
136
522
  <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
523
  </svg>
138
- <div class="text-sm text-center">${J($("clickDragText",n))}</div>
524
+ <div class="text-sm text-center">${re($("clickDragText",n))}</div>
139
525
  </div>
140
- `})}async function Vn(e,t,n,r,o,a,l){!t.file||!(t.file instanceof File)||(t.type&&t.type.startsWith("image/")?Dn(e,t.file,n,a):t.type&&t.type.startsWith("video/")?e=jn(e,t.file,t.type,r,a,l):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>`,!o&&!(t.type&&t.type.startsWith("video/"))&&St(e,r,a))}async function Kn(e,t,n,r,o){if(!o.config.getThumbnail){ot(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(ve(e),r&&r.type&&r.type.startsWith("video/"))Pn(e,a,r.type,o);else{const l=document.createElement("img");l.className="w-full h-full object-contain",l.alt=n||$("previewAlt",o),l.src=a,e.appendChild(l)}else ot(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
526
+ `})}async function jr(e,t,n,r,o,i,l){var a,s,c;!t.file||!(t.file instanceof File)||((a=t.type)!=null&&a.startsWith("image/")?Ir(e,t.file,n,i):(s=t.type)!=null&&s.startsWith("video/")?e=Hr(e,t.file,t.type,r,i,l):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>`,!o&&!((c=t.type)!=null&&c.startsWith("video/"))&&Gt(e,r,i))}function Or(e,t,n){const r=document.createElement("video");r.className="w-full h-full object-contain",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode($("videoNotSupported",n))),e.appendChild(r)}async function Ur(e,t,n,r,o){var i;if(!o.config.getThumbnail){nt(e,o);return}try{const l=await o.config.getThumbnail(t);if(l)if(be(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))Or(e,l,o);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",o),a.src=l,e.appendChild(a)}else nt(e,o)}catch(l){console.error("Failed to get thumbnail:",l),e.innerHTML=`
141
527
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
142
528
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
143
529
  <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
530
  </svg>
145
- <div class="text-sm text-center">${J(n||$("previewUnavailable",o))}</div>
531
+ <div class="text-sm text-center">${re(n||$("previewUnavailable",o))}</div>
146
532
  </div>
147
- `}}async function Tt(e,t,n,r={}){var o;const{fileName:a="",isReadonly:l=!1,deps:i=null}=r;if(!l&&i&&(!i.picker||!i.fileUploadHandler||!i.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");ve(e),l&&e.classList.add("cursor-pointer");const c=n.resourceIndex.get(t);if(c&&c.file&&c.file instanceof File)await Vn(e,c,a,t,l,n,i);else{await Kn(e,t,a,c,n);const s=(o=c==null?void 0:c.type)==null?void 0:o.startsWith("video/");!l&&!s&&St(e,t,n)}}async function rt(e,t,n){var r,o;const a=t.resourceIndex.get(e),l=(a==null?void 0:a.name)||e.split("/").pop()||"file",i=l.toLowerCase().match(/\.psd$/),c=document.createElement("div");c.className=i?"space-y-2":"space-y-3";const s=document.createElement("div");i?s.className="bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity flex items-center p-3 max-w-sm":s.className="bg-gray-100 rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity";const f=!i&&(((r=a==null?void 0:a.type)==null?void 0:r.startsWith("image/"))||l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)),d=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("video/"))||l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/);if(f)if(t.config.getThumbnail)try{const m=await t.config.getThumbnail(e);m?s.innerHTML=`<img src="${m}" alt="${J(l)}" class="w-full h-auto">`:s.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(l)}</div></div></div>`}catch(m){console.warn("getThumbnail failed for",e,m),s.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(l)}</div></div></div>`}else s.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(l)}</div></div></div>`;else if(d)if(t.config.getThumbnail)try{const m=await t.config.getThumbnail(e);m?s.innerHTML=`
148
- <div class="relative group">
149
- <video class="w-full h-auto" controls preload="auto" muted src="${m}">
150
- ${J($("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>
533
+ `}}async function Zt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:l=!1,deps:a=null}=r;if(!l&&a&&(!a.picker||!a.fileUploadHandler||!a.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");be(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await jr(e,s,i,t,l,n,a);else{await Ur(e,t,i,s,n);const c=(o=s==null?void 0:s.type)==null?void 0:o.startsWith("video/");!l&&!c&&Gt(e,t,n)}}function Pr(e,t,n){var r;if(n)return n;if((r=t==null?void 0:t.name)!=null&&r.includes("."))return t.name;const o=e.includes("/")?e.split("/").pop():e;return o!=null&&o.includes(".")?o:""}async function xt(e,t,n,r={}){var o,i;const l=t.resourceIndex.get(e),a=Pr(e,l,n),{canRemove:s=!1,removeHandler:c=null}=r,p=((o=l==null?void 0:l.type)==null?void 0:o.startsWith("image/"))||!!a.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((i=l==null?void 0:l.type)==null?void 0:i.startsWith("video/"))||!!a.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=bt();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",a&&(f.title=a);const d=(l==null?void 0:l.file)instanceof File?_t(l.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):d;f.onclick=async()=>{const v=await m();v?window.open(v,"_blank"):t.config.downloadFile?t.config.downloadFile(e,a):Qt(e,a,t).catch(h=>{console.error("Download failed:",h)})};const b=Kt({canRemove:s,removeHandler:c,state:t,resourceId:e,fileName:a,meta:l}),y=async()=>{if(t.config.getThumbnail)try{const v=await t.config.getThumbnail(e);if(v)return v}catch(v){}return d},w=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(b)};if(p){const v=await y();if(v){const h=document.createElement("img");h.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",h.alt=a,h.src=v,f.appendChild(h),f.appendChild(b),yt(f,v,a,b)}else w()}else if(u)if(t.config.getThumbnail)try{const v=await t.config.getThumbnail(e);v?(f.innerHTML=`
534
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(a)}" src="${v}">
535
+ <div class="fb-video-overlay">
536
+ <div class="fb-play-btn" style="width:22px;height:22px;">
537
+ <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
158
538
  </div>
159
- </div>
160
- `:s.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(l)}</div></div></div>`}catch(m){console.warn("getThumbnail failed for video",e,m),s.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(l)}</div></div></div>`}else s.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(l)}</div></div></div>`;else{const m=i?"\u{1F3A8}":"\u{1F4C1}",v=i?"PSD File":"Document";i?s.innerHTML=`
161
- <div class="flex items-center space-x-3">
162
- <div class="text-3xl text-gray-400">${m}</div>
163
- <div class="flex-1 min-w-0">
164
- <div class="text-sm font-medium text-gray-900 truncate">${J(l)}</div>
165
- <div class="text-xs text-gray-500">${v}</div>
166
- </div>
167
- </div>
168
- `:s.innerHTML=`<div class="aspect-video flex items-center justify-center text-gray-400"><div class="text-center"><div class="text-4xl mb-2">${m}</div><div class="text-sm">${J(l)}</div><div class="text-xs text-gray-500 mt-1">${v}</div></div></div>`}const p=document.createElement("p");p.className=i?"hidden":"text-sm font-medium text-gray-900 text-center",p.textContent=l;const u=document.createElement("button");return u.className="w-full px-3 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",u.textContent=$("downloadButton",t),u.onclick=m=>{m.preventDefault(),m.stopPropagation(),t.config.downloadFile?t.config.downloadFile(e,l):Jn(e,l,t)},c.appendChild(s),c.appendChild(p),c.appendChild(u),c}function At(e,t,n,r,o,a){ve(e);const l=()=>{const p=[$("clickDragTextMultiple",n)];return o&&p.push(o),a&&p.push(a),p.join(" \u2022 ")},i=!e.classList.contains("grid");if((!t||t.length===0)&&i){const p=document.createElement("div");p.className="grid grid-cols-4 gap-3 mb-3";for(let m=0;m<4;m++){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 g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("class","w-12 h-12 text-gray-400"),g.setAttribute("fill","currentColor"),g.setAttribute("viewBox","0 0 24 24");const E=document.createElementNS("http://www.w3.org/2000/svg","path");E.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"),g.appendChild(E),v.appendChild(g),v.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 b=h==null?void 0:h.querySelector('input[type="file"]');b&&b.click()},p.appendChild(v)}const u=document.createElement("div");u.className="text-center text-xs text-gray-500 mt-2",u.textContent=l(),e.appendChild(p),e.appendChild(u);return}const c=document.createElement("div");c.className="files-list grid grid-cols-4 gap-3";const s=t?t.length:0,f=(Math.floor(s/4)+1)*4;for(let p=0;p<f;p++){const u=document.createElement("div");if(t&&p<t.length){const m=t[p],v=n.resourceIndex.get(m);if(u.className="resource-pill aspect-square bg-gray-100 rounded-lg overflow-hidden relative group border border-gray-300",u.dataset.resourceId=m,Wn(u,m,v,n).catch(g=>{console.error("Failed to render thumbnail:",g),u.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($("previewError",n))}</div>
171
- </div>`}),r){const g=document.createElement("div");g.className="absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const E=document.createElement("button");E.className="bg-red-600 text-white px-2 py-1 rounded text-xs",E.textContent=$("removeElement",n),E.onclick=h=>{h.stopPropagation(),r(m)},g.appendChild(E),u.appendChild(g)}}else u.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",u.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>',u.onclick=()=>{let m=e.parentElement;for(;m&&!m.classList.contains("space-y-2");)m=m.parentElement;!m&&e.classList.contains("space-y-2")&&(m=e);const v=m==null?void 0:m.querySelector('input[type="file"]');v&&v.click()};c.appendChild(u)}e.appendChild(c);const d=document.createElement("div");d.className="text-center text-xs text-gray-500 mt-2",d.textContent=l(),e.appendChild(d)}function Ft(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($("previewError",t))}</div>
176
- </div>`}async function Wn(e,t,n,r){var o,a;if(n&&(o=n.type)!=null&&o.startsWith("image/"))if(n.file&&n.file instanceof File){const l=document.createElement("img");l.className="w-full h-full object-contain",l.alt=n.name;const i=new FileReader;i.onload=c=>{var s;l.src=((s=c.target)==null?void 0:s.result)||""},i.readAsDataURL(n.file),e.appendChild(l)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const i=document.createElement("img");i.className="w-full h-full object-contain",i.alt=n.name,i.src=l,e.appendChild(i)}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(l){const i=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(i,t),Ft(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 l=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="${l}">
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>
539
+ </div>`,f.appendChild(b)):(f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b))}catch(v){f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b)}else f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b);else{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h){const g=document.createElement("img");return g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=a||e,g.src=h,f.appendChild(g),f.appendChild(b),f}}catch(h){}const v=a?`<div class="fb-tile-label">${re(a.length>10?a.substring(0,8)+"\u2026":a)}</div>
540
+ <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>`:"";f.innerHTML=`
541
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
542
+ <div style="font-size:36px;">\u{1F4C1}</div>
543
+ ${v}
544
+ </div>`,f.appendChild(b)}return f}async function Et(e,t,n,r){var o,i,l;const a=n.resourceIndex.get(t),s=(i=(o=a==null?void 0:a.name)!=null?o:t.split("/").pop())!=null?i:"",c=(l=r.onRemove)!=null?l:null,p=await xt(t,n,s,{canRemove:!0,removeHandler:c});e.className="file-preview-container",e.removeAttribute("style"),be(e),e.appendChild(p)}async function Vr(e,t,n,r,o){var i,l,a;if((i=n==null?void 0:n.type)!=null&&i.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=p=>{var u;s.src=((u=p.target)==null?void 0:u.result)||"",yt(e,s.src,n.name,o!=null?o:null)},c.readAsDataURL(n.file),e.appendChild(s)}else if(r.config.getThumbnail)try{const s=await r.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),yt(e,s,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(s){const c=s instanceof Error?s:new Error(String(s));r.config.onThumbnailError&&r.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>';o&&e.appendChild(o)}else if((l=n==null?void 0:n.type)!=null&&l.startsWith("video/")){if(n.file&&n.file instanceof File){const s=URL.createObjectURL(n.file);e.innerHTML=`
545
+ <video style="width:100%;height:100%;" preload="metadata" muted src="${s}"></video>
546
+ <div class="fb-video-overlay">
547
+ <div class="fb-play-btn" style="width:20px;height:20px;">
548
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
194
549
  </div>
195
- </div>
196
- `}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);l?e.innerHTML=`
197
- <div class="relative group h-full w-full">
198
- <video class="w-full h-full object-contain" preload="metadata" muted src="${l}">
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>
550
+ </div>`}else if(r.config.getThumbnail)try{const s=await r.config.getThumbnail(t);s?e.innerHTML=`
551
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${re(n.name)}" src="${s}">
552
+ <div class="fb-video-overlay">
553
+ <div class="fb-play-btn" style="width:20px;height:20px;">
554
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
206
555
  </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(l){const i=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(i,t),Ft(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"/>
216
- </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($("clickDragText",t))}</div>
227
- ${r}
228
- </div>
229
- `}function Ve(e,t){var n,r;const o=(n=e.closest(".space-y-2"))==null?void 0:n.querySelector(".file-error-message");o&&o.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 lt(e){var t;const n=(t=e.closest(".space-y-2"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}async function Nt(e,t,n,r,o=null,a,l=[],i=1/0){var c,s;if(!$e(e.name,l)){const p=l.join(", ");Ve(t,$("invalidFileExtension",r,{name:e.name,formats:p}));return}if(!Ae(e,i)){Ve(t,$("fileTooLarge",r,{name:e.name,maxSize:i}));return}lt(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(p){const u=p instanceof Error?p:new Error(String(p));throw r.config.onUploadError&&r.config.onUploadError(u,e),new Error(`File upload failed: ${u.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 d=(c=t.parentElement)==null?void 0:c.querySelector('input[type="hidden"]');d||(d=document.createElement("input"),d.type="hidden",d.name=n,(s=t.parentElement)==null||s.appendChild(d)),d.value=f,Tt(t,f,r,{fileName:e.name,isReadonly:!1,deps:o}).catch(console.error),a&&!r.config.readonly&&a.triggerOnChange(n,f)}function at(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 o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const 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=$("removeElement",t),a.onclick=l=>{l.stopPropagation(),n()},o.appendChild(a),e.appendChild(o)}async function Mt(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 Jn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,a=await fetch(o);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const l=await a.blob();Yn(l,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function Yn(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 qt(e,t){e.length>0&&e.forEach(n=>{var r;if(!t.resourceIndex.has(n)){const o=n.split("/").pop()||"file",a=(r=o.split(".").pop())==null?void 0:r.toLowerCase();let l="application/octet-stream";a&&(["jpg","jpeg","png","gif","webp"].includes(a)?l=`image/${a==="jpg"?"jpeg":a}`:["mp4","webm","mov","avi"].includes(a)&&(l=`video/${a==="mov"?"quicktime":a}`)),t.resourceIndex.set(n,{name:o,type:l,size:0,uploadedAt:new Date,file:void 0})}})}function Xn(e,t,n,r,o,a){var l;if(!o.resourceIndex.has(e)){const c=e.split("/").pop()||"file",s=(l=c.split(".").pop())==null?void 0:l.toLowerCase();let f="application/octet-stream";s&&(["jpg","jpeg","png","gif","webp"].includes(s)?f=`image/${s==="jpg"?"jpeg":s}`:["mp4","webm","mov","avi"].includes(s)&&(f=`video/${s==="mov"?"quicktime":s}`)),o.resourceIndex.set(e,{name:c,type:f,size:0,uploadedAt:new Date,file:void 0})}Tt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error);const i=document.createElement("input");i.type="hidden",i.name=n,i.value=e,r.appendChild(i)}function zt(e,t,n,r,o,a,l){at(e,async i=>{const c=Array.from(i),s=c.filter(E=>!$e(E.name,o.allowedExtensions)),f=c.filter(E=>$e(E.name,o.allowedExtensions)),d=f.filter(E=>!Ae(E,o.maxSize)),p=f.filter(E=>Ae(E,o.maxSize)),u=o.maxCount===1/0?p.length:Math.max(0,o.maxCount-t.length),m=p.slice(0,u),v=p.length-m.length,g=[];if(s.length>0){const E=o.allowedExtensions.join(", "),h=s.map(b=>b.name).join(", ");g.push($("invalidFileExtension",n,{name:h,formats:E}))}if(d.length>0){const E=d.map(h=>h.name).join(", ");g.push($("fileTooLarge",n,{name:E,maxSize:o.maxSize}))}v>0&&g.push($("filesLimitExceeded",n,{skipped:v,max:o.maxCount})),g.length>0?Ve(e,g.join(" \u2022 ")):lt(e);for(const E of m){const h=await Mt(E,n);n.resourceIndex.set(h,{name:E.name,type:E.type,size:E.size,uploadedAt:new Date,file:void 0}),t.push(h)}r(),l&&a&&!n.config.readonly&&l.triggerOnChange(a,t)})}function It(e,t,n,r,o,a,l){e.onchange=async()=>{if(e.files){const i=Array.from(e.files),c=i.filter(E=>!$e(E.name,o.allowedExtensions)),s=i.filter(E=>$e(E.name,o.allowedExtensions)),f=s.filter(E=>!Ae(E,o.maxSize)),d=s.filter(E=>Ae(E,o.maxSize)),p=o.maxCount===1/0?d.length:Math.max(0,o.maxCount-t.length),u=d.slice(0,p),m=d.length-u.length,v=[];if(c.length>0){const E=o.allowedExtensions.join(", "),h=c.map(b=>b.name).join(", ");v.push($("invalidFileExtension",n,{name:h,formats:E}))}if(f.length>0){const E=f.map(h=>h.name).join(", ");v.push($("fileTooLarge",n,{name:E,maxSize:o.maxSize}))}m>0&&v.push($("filesLimitExceeded",n,{skipped:m,max:o.maxCount}));const g=e.closest(".space-y-2")||e.parentElement;v.length>0&&g?Ve(g,v.join(" \u2022 ")):g&&lt(g);for(const E of u){const h=await Mt(E,n);n.resourceIndex.set(h,{name:E.name,type:E.type,size:E.size,uploadedAt:new Date,file:void 0}),t.push(h)}}r(),e.value="",l&&a&&!n.config.readonly&&l.triggerOnChange(a,t)}}function Gn(e,t,n,r){var o,a;const l=t.state;if(le(e,l,t)){const i=t.prefill[e.key],c=typeof i=="string"?i:"";if(c){const s=document.createElement("input");s.type="hidden",s.name=r,s.value=c,n.appendChild(s),rt(c,l).then(f=>{n.appendChild(f)}).catch(f=>{console.error("Failed to render file preview:",f);const d=document.createElement("div");d.className="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500",d.innerHTML=`<div class="text-center">${J($("previewUnavailable",l))}</div>`,n.appendChild(d)})}else{const s=document.createElement("div");s.className="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500",s.innerHTML=`<div class="text-center">${J($("noFileSelected",l))}</div>`,n.appendChild(s)}}else{const i=document.createElement("div");i.className="space-y-2";const c=document.createElement("input");c.type="file",c.name=r,c.style.display="none",e.accept&&(c.accept=typeof e.accept=="string"?e.accept:((o=e.accept.extensions)==null?void 0:o.map(v=>`.${v}`).join(","))||"");const s=document.createElement("div");s.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],d=He(e.accept),p=(a=e.maxSize)!=null?a:1/0,u=()=>c.click(),m=v=>{if(v.length>0){const g={picker:c,fileUploadHandler:u,dragHandler:m};Nt(v[0],s,r,l,g,t.instance,d,p)}};if(f)Xn(f,s,r,i,l,{picker:c,fileUploadHandler:u,dragHandler:m});else{const v=be(e,l);ot(s,l,v)}s.onclick=u,at(s,m),c.onchange=()=>{if(c.files&&c.files.length>0){const v={picker:c,fileUploadHandler:u,dragHandler:m};Nt(c.files[0],s,r,l,v,t.instance,d,p)}},i.appendChild(s),i.appendChild(c),n.appendChild(i)}}function Zn(e,t,n,r){var o,a;const l=t.state;if(le(e,l,t)){const i=t.prefill[e.key],c=Array.isArray(i)?i:[],s=document.createElement("div");s.className="space-y-2",s.dataset.filesWrapper=r;const f=document.createElement("div");f.className="files-list",c.forEach(p=>{const u=document.createElement("div");u.className="resource-pill",u.dataset.resourceId=p,f.appendChild(u)}),s.appendChild(f),n.appendChild(s);const d=document.createElement("div");d.className="space-y-4",c.length>0?c.forEach(p=>{rt(p,l).then(u=>{d.appendChild(u)}).catch(u=>{console.error("Failed to render file preview:",u)})}):d.innerHTML=`<div class="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500"><div class="text-center">${J($("noFilesSelected",l))}</div></div>`,n.appendChild(d)}else{let i=function(){At(d,p,l,v=>{const g=p.indexOf(v);g>-1&&p.splice(g,1),i()},u)};const c=document.createElement("div");c.className="space-y-2",c.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",e.accept&&(s.accept=typeof e.accept=="string"?e.accept:((o=e.accept.extensions)==null?void 0:o.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 d=document.createElement("div");d.className="files-list";const p=t.prefill[e.key]||[];qt(p,l);const u=be(e,l),m={maxCount:1/0,allowedExtensions:He(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0};i(),zt(f,p,l,i,m,r,t.instance),It(s,p,l,i,m,r,t.instance),f.appendChild(d),c.appendChild(f),c.appendChild(s),n.appendChild(c)}}function Qn(e,t,n,r){var o,a,l,i;const c=t.state,s=(o=e.minCount)!=null?o:0,f=(a=e.maxCount)!=null?a:1/0;if(le(e,c,t)){const d=t.prefill[e.key],p=Array.isArray(d)?d:[],u=document.createElement("div");u.className="space-y-2",u.dataset.filesWrapper=r;const m=document.createElement("div");m.className="files-list",p.forEach(g=>{const E=document.createElement("div");E.className="resource-pill",E.dataset.resourceId=g,m.appendChild(E)}),u.appendChild(m),n.appendChild(u);const v=document.createElement("div");v.className="space-y-4",p.length>0?p.forEach(g=>{rt(g,c).then(E=>{v.appendChild(E)}).catch(E=>{console.error("Failed to render file preview:",E)})}):v.innerHTML=`<div class="aspect-video bg-gray-100 rounded-lg flex items-center justify-center text-gray-500"><div class="text-center">${J($("noFilesSelected",c))}</div></div>`,n.appendChild(v)}else{const d=document.createElement("div");d.className="space-y-2",d.dataset.filesWrapper=r;const p=document.createElement("input");p.type="file",p.name=r,p.multiple=!0,p.style.display="none",e.accept&&(p.accept=typeof e.accept=="string"?e.accept:((l=e.accept.extensions)==null?void 0:l.map(b=>`.${b}`).join(","))||"");const u=document.createElement("div");u.className="files-list space-y-2",d.appendChild(p),d.appendChild(u);const m=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];qt(m,c);const v=be(e,c),g={maxCount:f,allowedExtensions:He(e.accept),maxSize:(i=e.maxSize)!=null?i:1/0},E=()=>{const b=m.length===1?$("fileCountSingle",c,{count:m.length}):$("fileCountPlural",c,{count:m.length}),y=s>0||f<1/0?` ${$("fileCountRange",c,{min:s,max:f})}`:"";return b+y},h=()=>{At(u,m,c,b=>{m.splice(m.indexOf(b),1),h()},v,E())};zt(u,m,c,h,g,r,t.instance),It(p,m,c,h,g,r,t.instance),h(),n.appendChild(d)}}function Ht(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l,path:i}=n,c=e.type==="files"||"multiple"in e&&!!e.multiple,s=(p,u,m)=>{var v,g;if(l)return;const{state:E}=n,h="minCount"in m&&(v=m.minCount)!=null?v:0,b="maxCount"in m&&(g=m.maxCount)!=null?g:1/0;m.required&&u.length===0&&o.push(`${p}: ${$("required",E)}`),u.length<h&&o.push(`${p}: ${$("minFiles",E,{min:h})}`),u.length>b&&o.push(`${p}: ${$("maxFiles",E,{max:b})}`)},f=(p,u,m)=>{var v;if(l)return;const{state:g}=n,E="accept"in m?m.accept:void 0,h=He(E);if(h.length===0)return;const b=h.join(", ");for(const y of u){const w=g.resourceIndex.get(y),C=(v=w==null?void 0:w.name)!=null?v:y;$e(C,h)||o.push(`${p}: ${$("invalidFileExtension",g,{name:C,formats:b})}`)}},d=(p,u,m)=>{var v;if(l)return;const{state:g}=n,E="maxSize"in m&&(v=m.maxSize)!=null?v:1/0;if(E!==1/0)for(const h of u){const b=g.resourceIndex.get(h);b&&b.size>E*1024*1024&&o.push(`${p}: ${$("fileTooLarge",g,{name:b.name,maxSize:E})}`)}};if(c){const p=ye(i,t),u=a.querySelector(`[data-files-wrapper="${p}"]`),m=(u==null?void 0:u.querySelector(".files-list"))||null,v=[];return m&&m.querySelectorAll(".resource-pill").forEach(g=>{const E=g.dataset.resourceId;E&&v.push(E)}),s(t,v,e),f(t,v,e),d(t,v,e),{value:v,errors:o}}else{const p=a.querySelector(`input[name$="${t}"][type="hidden"]`),u=(r=p==null?void 0:p.value)!=null?r:"";return!l&&e.required&&u===""?(o.push(`${t}: ${$("required",n.state)}`),{value:null,errors:o}):(!l&&u!==""&&(f(t,[u],e),d(t,[u],e)),{value:u||null,errors:o})}}function Rt(e,t,n,r){var o;const{scopeRoot:a,state:l}=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(i=>{var c;if(i&&typeof i=="string"&&!l.resourceIndex.has(i)){const s=i.split("/").pop()||"file",f=(c=s.split(".").pop())==null?void 0:c.toLowerCase();let d="application/octet-stream";f&&(["jpg","jpeg","png","gif","webp"].includes(f)?d=`image/${f==="jpg"?"jpeg":f}`:["mp4","webm","mov","avi"].includes(f)&&(d=`video/${f==="mov"?"quicktime":f}`)),l.resourceIndex.set(i,{name:s,type:d,size:0,uploadedAt:new Date,file:void 0})}}),console.info(`updateFileField: Multiple file field "${t}" updated. Preview update requires re-render.`)}else{const i=a.querySelector(`input[name="${t}"][type="hidden"]`);if(!i){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}if(i.value=n!=null?String(n):"",n&&typeof n=="string"){if(!l.resourceIndex.has(n)){const c=n.split("/").pop()||"file",s=(o=c.split(".").pop())==null?void 0:o.toLowerCase();let f="application/octet-stream";s&&(["jpg","jpeg","png","gif","webp"].includes(s)?f=`image/${s==="jpg"?"jpeg":s}`:["mp4","webm","mov","avi"].includes(s)&&(f=`video/${s==="mov"?"quicktime":s}`)),l.resourceIndex.set(n,{name:c,type:f,size:0,uploadedAt:new Date,file:void 0})}console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`)}}}function Fe(e){return e?e.toUpperCase():"#000000"}function it(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 Dt(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Fe(e),r=document.createElement("div");r.style.cssText=`
556
+ </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));r.config.onThumbnailError&&r.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>';o&&e.appendChild(o)}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=`
557
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
558
+ <div style="font-size:36px;">\u{1F4C1}</div>
559
+ ${c}
560
+ </div>`,o&&e.appendChild(o)}}async function Qt(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const l=await i.blob();en(l,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function en(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}`)}}async function tn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));throw t.config.onUploadError&&t.config.onUploadError(r,e),new Error(`File upload failed: ${r.message}`)}}async function nn(e){var t,n;const{file:r,container:o,fieldName:i,state:l,deps:a=null,instance:s=null,allowedExtensions:c=[],allowedMimes:p=[],maxSizeMB:u=1/0}=e;if(!ze(r.name,c)){const m=c.join(", ");Ee(o,$("invalidFileExtension",l,{name:r.name,formats:m}));return}if(!Oe(r.type,p)){const m=p.join(", ");Ee(o,$("invalidFileMime",l,{name:r.name,type:r.type,mimes:m}));return}if(!Ge(r,u)){Ee(o,$("fileTooLarge",l,{name:r.name,maxSize:u}));return}Ue(o),et(),o.innerHTML=`
561
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
562
+ <div class="fb-spinner"></div>
563
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${re($("uploadingFile",l))}</div>
564
+ </div>`;let f;try{f=await tn(r,l)}catch(m){throw nt(o,l),m}l.resourceIndex.set(f,{name:r.name,type:r.type,size:r.size,uploadedAt:new Date,file:r});let d=(t=o.parentElement)==null?void 0:t.querySelector('input[type="hidden"]');d||(d=document.createElement("input"),d.type="hidden",d.name=i,(n=o.parentElement)==null||n.appendChild(d)),d.value=f,!r.type.startsWith("video/")&&a?Et(o,f,l,a).catch(console.error):Zt(o,f,l,{fileName:r.name,isReadonly:!1,deps:a}).catch(console.error),s&&!l.config.readonly&&s.triggerOnChange(i,f)}function rn(e,t,n,r){const o=e.filter(m=>!ze(m.name,n.allowedExtensions)),i=e.filter(m=>ze(m.name,n.allowedExtensions)),l=i.filter(m=>!Oe(m.type,n.allowedMimes)),a=i.filter(m=>Oe(m.type,n.allowedMimes)),s=a.filter(m=>!Ge(m,n.maxSize)),c=a.filter(m=>Ge(m,n.maxSize)),p=n.maxCount===1/0?c.length:Math.max(0,n.maxCount-t),u=c.slice(0,p),f=c.length-u.length,d=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(y=>y.name).join(", ");d.push($("invalidFileExtension",r,{name:b,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),b=l.map(y=>y.name).join(", ");d.push($("invalidFileMime",r,{name:b,type:l.map(y=>y.type).join(", "),mimes:m}))}if(s.length>0){const m=s.map(b=>b.name).join(", ");d.push($("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&d.push($("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:u,errorMessage:d.join(" \u2022 ")}}async function on(e,t,n,r){await Promise.all(e.map(async o=>{const i=wr(o.name,r);if(n){const l=kr(n),a=l.querySelector(".fb-tile-add");a?l.insertBefore(i,a):l.appendChild(i)}try{const l=await tn(o,r);r.resourceIndex.set(l,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:void 0}),t.push(l)}finally{i.remove()}}))}function ln(e,t,n,r,o,i,l){Pe(e,async a=>{var s;const{accepted:c,errorMessage:p}=rn(Array.from(a),t.length,o,n);p?Ee(e,p):Ue(e);const u=(s=e.querySelector(".files-list"))!=null?s:e;await on(c,t,u,n),r(),l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)})}function an(e,t,n,r,o,i,l){e.onchange=async()=>{if(!e.files)return;const a=e.closest(".space-y-2")||e.parentElement,{accepted:s,errorMessage:c}=rn(Array.from(e.files),t.length,o,n);c&&a?Ee(a,c):a&&Ue(a);const p=a==null?void 0:a.querySelector(".files-list");await on(s,t,p!=null?p:null,n),r(),e.value="",l&&i&&!n.config.readonly&&l.triggerOnChange(i,t)}}function sn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const a=ke(e.accept);return a.length>0?{extensions:a}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(a=>a.toLowerCase());if(i.length===0&&o.length===0)return;const l={};return i.length>0&&(l.extensions=i),o.length>0&&(l.mime=o),l}function cn(e,t,n,r,o){if(!ze(e.name,t)){const i=t.join(", ");return $("invalidFileExtension",o,{name:e.name,formats:i})}if(!Oe(e.type,n)){const i=n.join(", ");return $("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return Vt(e.size,r)?null:$("fileTooLarge",o,{name:e.name,maxSize:r})}function Wr(e){const t=e.dataset.resourceIds;if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch(n){return[]}}function un(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function dn(e,t){return e instanceof Error&&e.message?e.message:$("pickerError",t)}async function fn(e,t,n,r,o,i,l,a){var s;if(!e.config.pickExistingFiles)return;const c=ke(t.accept),p=qe(t.accept),u=(s=t.maxSize)!=null?s:1/0,f=Wr(n),d=i===1/0?1/0:Math.max(0,i-f.length);let m;try{m=await e.config.pickExistingFiles({fieldPath:r,mode:"multiple",accept:sn(t),maxSizeMB:u===1/0?void 0:u,remainingSlots:d===1/0?void 0:d,selectedResourceIds:[...f]})}catch(E){Ee(n,dn(E,e));return}if(m.length===0)return;const b=new Set(f),y=new Set,w=m.filter(E=>b.has(E.resourceId)||y.has(E.resourceId)?!1:(y.add(E.resourceId),!0)).filter(E=>cn(E,c,p,u,e)===null),v=i===1/0?w.length:Math.max(0,i-o.length),h=w.slice(0,v),g=w.length-h.length;if(h.length!==0){Ue(n),g>0&&Ee(n,$("filesLimitExceeded",e,{skipped:g,max:i}));for(const E of h)un(E,e),o.push(E.resourceId);n.dataset.resourceIds=JSON.stringify(o),l(),e.config.readonly||a.triggerOnChange(r,o)}}async function Kr(e,t,n,r,o,i,l,a){var s;if(!e.config.pickExistingFiles)return;const c=ke(t.accept),p=qe(t.accept),u=(s=t.maxSize)!=null?s:1/0;let f;try{f=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:sn(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(y){Ee(n,dn(y,e));return}if(f.length===0)return;const d=f[0],m=cn(d,c,p,u,e);if(m!==null){Ee(n,m);return}Ue(n),un(d,e);let b=r.querySelector('input[type="hidden"]');b||(b=document.createElement("input"),b.type="hidden",b.name=o,r.appendChild(b)),b.value=d.resourceId,await l(d.resourceId),e.config.readonly||a.triggerOnChange(i,d.resourceId)}function _r(e,t,n,r,o,i){var l;Ze(e,o.resourceIndex);const a=o.resourceIndex.get(e);(l=a==null?void 0:a.type)!=null&&l.startsWith("video/")?Zt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Et(t,e,o,i).catch(console.error);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}const Jr=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" style="flex-shrink:0;color:var(--fb-file-upload-text-color,#9ca3af);">
565
+ <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"/>
566
+ </svg>`;function Ct(e,t,n,r){const o=document.createElement("div");return o.className="fb-file-dropzone",o.innerHTML=`
567
+ ${Jr}
568
+ <div class="fb-dropzone-primary-text">${re(t)}</div>
569
+ ${n?`<div class="fb-dropzone-hint-text">${re(n)}</div>`:""}
570
+ `,o.onclick=r,o}function wt(e,t,n){const r=document.createElement("button");return r.type="button",r.className=e==="card"?"fb-file-library-card":"fb-tile fb-tile-add-library",e==="card"?r.innerHTML=`
571
+ <span class="fb-file-library-card-icon" aria-hidden="true">\u{1F4DA}</span>
572
+ <span class="fb-file-library-card-label">${re($("fromLibrary",t))}</span>
573
+ <span class="fb-file-library-card-hint">${re($("libraryHint",t))}</span>
574
+ `:(r.innerHTML='<span aria-hidden="true">\u{1F4DA}</span>',r.title=$("fromLibrary",t),r.setAttribute("aria-label",$("fromLibrary",t))),r.addEventListener("click",n),r}function pn(e){var t;const{container:n,rids:r,state:o,onRemove:i,hint:l,countInfo:a,maxCount:s,isReadonly:c=!1,onLibraryPick:p}=e;et();const u=n.closest("[data-files-wrapper]");for(u&&(u.dataset.resourceIds=JSON.stringify(r!=null?r:[]));n.firstChild;)n.removeChild(n.firstChild);const f=r!=null?r:[],d=s!==void 0&&f.length>=s,m=!c&&typeof p=="function",b=()=>{const h=[];return l&&h.push(l),a&&h.push(a),h.join(" \u2022 ")},y=()=>{const h=Cr(n);h&&h.click()};if(f.length===0){if(c){const h=document.createElement("div");h.className="fb-tile-empty-text",h.textContent=$("noFilesSelected",o),n.appendChild(h)}else if(m){const h=document.createElement("div");h.className="fb-file-card-row";const g=Ct(o,$("clickDragTextMultiple",o),b(),y),E=wt("card",o,p);h.appendChild(g),h.appendChild(E),n.appendChild(h)}else{const h=Ct(o,$("clickDragTextMultiple",o),b(),y);n.appendChild(h)}return}const w=document.createElement("div");w.className="fb-tiles-wrap",w.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";for(const h of f){const g=o.resourceIndex.get(h),E=bt();E.classList.add("fb-tile-resource","resource-pill"),E.dataset.resourceId=h;const C=Kt({canRemove:!c&&i!==null,removeHandler:i?()=>i(h):null,state:o,resourceId:h,fileName:(t=g==null?void 0:g.name)!=null?t:""});Vr(E,h,g,o,C).catch(x=>{console.error("Failed to render tile:",x)}),w.appendChild(E)}if(!c&&!d){const h=document.createElement("div");if(h.className="fb-tile fb-tile-add",h.innerHTML="+",h.onclick=y,w.appendChild(h),m){const g=wt("tile",o,p);w.appendChild(g)}}else if(!c&&d){const h=document.createElement("div");h.className="fb-tile-counter",h.textContent=$("filesCounter",o,{count:f.length,max:s}),w.appendChild(h)}n.appendChild(w);const v=b();if(v){const h=document.createElement("div");h.className="fb-tile-hint",h.textContent=v,n.appendChild(h)}}function Yr(e,t,n,r){var o,i,l,a,s;const c=t.state,p=document.createElement("div");p.className="space-y-2";const u=document.createElement("input");u.type="file",u.name=r,u.style.display="none",e.accept&&(u.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(g=>`.${g}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const f=document.createElement("div");f.className="file-preview-container";const d=t.prefill[e.key],m=ke(e.accept),b=qe(e.accept),y=(a=e.maxSize)!=null?a:1/0,w={fileUploadHandler(){u.click()},dragHandler(g){g.length>0&&nn({file:g[0],container:f,fieldName:r,state:c,deps:v(),instance:t.instance,allowedExtensions:m,allowedMimes:b,maxSizeMB:y})},setupDrop(g){Pe(g,w.dragHandler)},restoreDropzone(){const g=ve(e,c);f.className="file-preview-container w-full max-w-md bg-gray-100 rounded-lg overflow-hidden relative group cursor-pointer",f.style.height="128px",nt(f,c,g),f.onclick=w.fileUploadHandler,Pe(f,w.dragHandler)},onRemove(){var g;const E=p.querySelector('input[type="hidden"]'),C=E==null?void 0:E.value;C&&gt((g=c.resourceIndex.get(C))==null?void 0:g.file),E&&(E.value=""),w.restoreDropzone()}},v=()=>({picker:u,fileUploadHandler:w.fileUploadHandler,dragHandler:w.dragHandler,setupDrop:w.setupDrop,onRemove:w.onRemove}),h=()=>{if(c.config.pickExistingFiles&&!e.disableLibrary){f.className="file-preview-container",f.removeAttribute("style"),f.onclick=null;const g=document.createElement("div");g.className="fb-file-card-row",g.style.cssText="display:flex;gap:8px;align-items:stretch;";const E=ve(e,c),C=Ct(c,$("clickDragText",c),E,w.fileUploadHandler);C.style.cssText="flex:1;min-width:0;height:128px;",Pe(C,w.dragHandler);const x=wt("card",c,()=>{Kr(c,e,f,p,r,r,async k=>{await Et(f,k,c,v())},t.instance).catch(k=>{console.error("Library pick failed:",k)})});x.style.cssText="flex:1;min-width:0;",g.appendChild(C),g.appendChild(x),f.appendChild(g)}else w.restoreDropzone()};if(d){_r(d,f,r,p,c,v());const g=c.resourceIndex.get(d);(s=g==null?void 0:g.type)!=null&&s.startsWith("video/")&&(f.onclick=w.fileUploadHandler,Pe(f,w.dragHandler))}else h();u.onchange=()=>{u.files&&u.files.length>0&&nn({file:u.files[0],container:f,fieldName:r,state:c,deps:v(),instance:t.instance,allowedExtensions:m,allowedMimes:b,maxSizeMB:y})},p.appendChild(f),p.appendChild(u),n.appendChild(p)}function Xr(e,t,n,r){var o,i,l,a;const s=t.state,c=document.createElement("div");c.className="space-y-2",c.dataset.filesWrapper=r;const p=document.createElement("input");p.type="file",p.name=r,p.multiple=!0,p.style.display="none",e.accept&&(p.accept=typeof e.accept=="string"?e.accept:[...(i=(o=e.accept.extensions)==null?void 0:o.map(v=>`.${v}`))!=null?i:[],...(l=e.accept.mime)!=null?l:[]].join(",")||"");const u=document.createElement("div");u.className="files-list-wrapper",u.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 f=document.createElement("div");f.className="files-list";const d=t.prefill[e.key]||[];Qe(d,s.resourceIndex),c.dataset.resourceIds=JSON.stringify(d);const m=ve(e,s),b={maxCount:1/0,allowedExtensions:ke(e.accept),allowedMimes:qe(e.accept),maxSize:(a=e.maxSize)!=null?a:1/0};u.appendChild(f),c.appendChild(p),c.appendChild(u),n.appendChild(c);const y=s.config.pickExistingFiles&&!e.disableLibrary?()=>{fn(s,e,c,r,d,1/0,w,t.instance).catch(v=>{console.error("Library pick failed:",v)})}:null;function w(){const v=le(e,s);pn({container:f,rids:d,state:s,onRemove:v?null:h=>{var g;gt((g=s.resourceIndex.get(h))==null?void 0:g.file);const E=d.indexOf(h);E>-1&&d.splice(E,1),w()},hint:m,isReadonly:v,onLibraryPick:v?null:y})}w(),ln(u,d,s,w,b,r,t.instance),an(p,d,s,w,b,r,t.instance)}function Gr(e,t,n,r){var o,i,l,a,s,c;const p=t.state,u=(o=e.minCount)!=null?o:0,f=(i=e.maxCount)!=null?i:1/0,d=document.createElement("div");d.className="space-y-2",d.dataset.filesWrapper=r;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:[...(a=(l=e.accept.extensions)==null?void 0:l.map(x=>`.${x}`))!=null?a:[],...(s=e.accept.mime)!=null?s:[]].join(",")||"");const b=document.createElement("div");b.className="files-list-wrapper",b.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 y=document.createElement("div");y.className="files-list",d.appendChild(m),d.appendChild(b),b.appendChild(y);const w=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];Qe(w,p.resourceIndex),d.dataset.resourceIds=JSON.stringify(w);const v=ve(e,p),h={maxCount:f,allowedExtensions:ke(e.accept),allowedMimes:qe(e.accept),maxSize:(c=e.maxSize)!=null?c:1/0},g=()=>{const x=w.length===1?$("fileCountSingle",p,{count:w.length}):$("fileCountPlural",p,{count:w.length}),k=u>0||f<1/0?` ${$("fileCountRange",p,{min:u,max:f})}`:"";return x+k},E=p.config.pickExistingFiles&&!e.disableLibrary?()=>{fn(p,e,d,r,w,f,C,t.instance).catch(x=>{console.error("Library pick failed:",x)})}:null,C=()=>{const x=le(e,p);pn({container:y,rids:w,state:p,onRemove:x?null:k=>{var q;gt((q=p.resourceIndex.get(k))==null?void 0:q.file),w.splice(w.indexOf(k),1),C()},hint:v,countInfo:g(),maxCount:f<1/0?f:void 0,isReadonly:x,onLibraryPick:x?null:E})};ln(b,w,p,C,h,r,t.instance),an(m,w,p,C,h,r,t.instance),C(),n.appendChild(d)}function Zr(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function Qr(e,t,n,r,o){var i,l;const a="minCount"in n&&(i=n.minCount)!=null?i:0,s="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${$("required",r)}`),t.length<a&&o.push(`${e}: ${$("minFiles",r,{min:a})}`),t.length>s&&o.push(`${e}: ${$("maxFiles",r,{max:s})}`)}function mn(e,t,n,r,o){var i,l;const a="accept"in n?n.accept:void 0,s=ke(a),c=qe(a);if(s.length===0&&c.length===0)return;const p=s.join(", "),u=c.join(", ");for(const f of t){const d=r.resourceIndex.get(f),m=(i=d==null?void 0:d.name)!=null?i:f;if(s.length>0&&!ze(m,s)){o.push(`${e}: ${$("invalidFileExtension",r,{name:m,formats:p})}`);continue}if(c.length>0&&!(d!=null&&d.inferredFromExtension)){const b=(l=d==null?void 0:d.type)!=null?l:"";Oe(b,c)||o.push(`${e}: ${$("invalidFileMime",r,{name:m,type:b,mimes:u})}`)}}}function hn(e,t,n,r,o){var i;const l="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(l!==1/0)for(const a of t){const s=r.resourceIndex.get(a);s&&s.size>l*1024*1024&&o.push(`${e}: ${$("fileTooLarge",r,{name:s.name,maxSize:l})}`)}}function eo(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:l}=n,a=[],s=xe(i,t),c=Zr(r,s);return o||(Qr(t,c,e,l,a),mn(t,c,e,l,a),hn(t,c,e,l,a)),{value:c,errors:a}}function to(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:l}=n,a=[],s=o.querySelector(`input[name$="${t}"][type="hidden"]`),c=(r=s==null?void 0:s.value)!=null?r:"";return!i&&e.required&&c===""?(a.push(`${t}: ${$("required",l)}`),{value:null,errors:a}):(!i&&c!==""&&(mn(t,[c],e,l,a),hn(t,[c],e,l,a)),{value:c||null,errors:a})}function vn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?eo(e,t,n):to(e,t,n)}function no(e,t,n,r){const o=t.state,i=t.prefill[e.key],l=typeof i=="string"?i:"";if(l){Qe([l],o.resourceIndex);const a=document.createElement("input");a.type="hidden",a.name=r,a.value=l,n.appendChild(a),xt(l,o).then(s=>{n.appendChild(s)}).catch(s=>{console.error("Failed to render file preview:",s),n.appendChild(bn(o))})}else n.appendChild(bn(o))}function bn(e){const t=document.createElement("div");return t.style.cssText=`
575
+ width:${tt};
576
+ height:${tt};
577
+ display:flex;
578
+ align-items:center;
579
+ justify-content:center;
580
+ background:var(--fb-file-upload-bg-color,#f3f4f6);
581
+ border-radius:var(--fb-border-radius,0.5rem);
582
+ border:1px solid var(--fb-file-upload-border-color,#d1d5db);
583
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${re($("noFileSelected",e))}</div>`,t}function gn(e,t,n,r,o){Qe(e,t.resourceIndex);const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=$("noFilesSelected",t),i.appendChild(s);return}const l=document.createElement("div");l.style.cssText=`display:flex;flex-wrap:wrap;gap:6px;${o?`margin-top:${o};`:""}`,i.appendChild(l);const a=e.map(()=>{const s=document.createElement("div");return s.style.cssText=`width:${tt};height:${tt};`,l.appendChild(s),s});for(let s=0;s<e.length;s++){const c=e[s],p=a[s];xt(c,t).then(u=>{p.replaceWith(u)}).catch(u=>{console.error("Failed to render readonly tile:",u)})}}function ro(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];gn(i,t.state,n,r)}function oo(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];gn(i,t.state,n,r,"4px")}function lo(e,t,n,r){le(e,t.state,t)?no(e,t,n,r):Yr(e,t,n,r)}function io(e,t,n,r){le(e,t.state,t)?ro(e,t,n,r):Xr(e,t,n,r)}function ao(e,t,n,r){le(e,t.state,t)?oo(e,t,n,r):Gr(e,t,n,r)}function yn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(a=>{a&&typeof a=="string"&&Ze(a,i.resourceIndex)});const l=o.querySelector(`[data-files-wrapper="${t}"]`);l?l.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const l=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!l){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}l.value=n!=null?String(n):"",n&&typeof n=="string"&&(Ze(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Ie(e){return e?e.toUpperCase():"#000000"}function kt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function xn(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 En(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Ie(e),r=document.createElement("div");r.style.cssText=`
234
584
  width: 32px;
235
585
  height: 32px;
236
586
  border-radius: var(--fb-border-radius);
@@ -240,11 +590,11 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
240
590
  font-size: var(--fb-font-size);
241
591
  color: var(--fb-text-color);
242
592
  font-family: var(--fb-font-family-mono, monospace);
243
- `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function jt(e,t,n){const r=Fe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
593
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function Cn(e,t,n){const r=Ie(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
244
594
  display: flex;
245
595
  align-items: center;
246
596
  gap: 8px;
247
- `;const a=document.createElement("div");a.className="colour-swatch",a.style.cssText=`
597
+ `;const i=document.createElement("div");i.className="colour-swatch",i.style.cssText=`
248
598
  width: 40px;
249
599
  height: 40px;
250
600
  border-radius: var(--fb-border-radius);
@@ -263,49 +613,49 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
263
613
  font-size: var(--fb-font-size);
264
614
  font-family: var(--fb-font-family-mono, monospace);
265
615
  transition: all var(--fb-transition-duration) ease-in-out;
266
- `;const i=document.createElement("input");return i.type="color",i.className="colour-picker-hidden",i.value=r.toLowerCase(),i.style.cssText=`
616
+ `;const a=document.createElement("input");return a.type="color",a.className="colour-picker-hidden",a.value=r.toLowerCase(),a.style.cssText=`
267
617
  position: absolute;
268
618
  opacity: 0;
269
619
  pointer-events: none;
270
- `,l.addEventListener("input",()=>{const c=l.value.trim();if(it(c)){const s=Bt(c);a.style.backgroundColor=s,i.value=s.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,s)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const c=l.value.trim();if(it(c)){const s=Bt(c);l.value=s,a.style.backgroundColor=s,i.value=s.toLowerCase(),l.classList.remove("invalid")}}),i.addEventListener("change",()=>{const c=Fe(i.value);l.value=c,a.style.backgroundColor=c,n.instance&&n.instance.triggerOnChange(t,c)}),a.addEventListener("click",()=>{i.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),l.addEventListener("focus",()=>{l.style.borderColor="var(--fb-border-focus-color)",l.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",l.style.outlineOffset="0"}),l.addEventListener("blur",()=>{l.style.borderColor="var(--fb-border-color)",l.style.outline="none"}),l.addEventListener("mouseenter",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-hover-color)")}),l.addEventListener("mouseleave",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-color)")}),o.appendChild(a),o.appendChild(l),o.appendChild(i),o}function er(e,t,n,r){const o=t.state,a=le(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(a){const i=Dt(l);n.appendChild(i)}else{const i=jt(l,r,t);n.appendChild(i)}if(!a){const i=document.createElement("p");i.className="mt-1",i.style.cssText=`
620
+ `,l.addEventListener("input",()=>{const s=l.value.trim();if(kt(s)){const c=xn(s);i.style.backgroundColor=c,a.value=c.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const s=l.value.trim();if(kt(s)){const c=xn(s);l.value=c,i.style.backgroundColor=c,a.value=c.toLowerCase(),l.classList.remove("invalid")}}),a.addEventListener("change",()=>{const s=Ie(a.value);l.value=s,i.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),i.addEventListener("click",()=>{a.click()}),i.addEventListener("mouseenter",()=>{i.style.borderColor="var(--fb-border-hover-color)"}),i.addEventListener("mouseleave",()=>{i.style.borderColor="var(--fb-border-color)"}),l.addEventListener("focus",()=>{l.style.borderColor="var(--fb-border-focus-color)",l.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",l.style.outlineOffset="0"}),l.addEventListener("blur",()=>{l.style.borderColor="var(--fb-border-color)",l.style.outline="none"}),l.addEventListener("mouseenter",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-hover-color)")}),l.addEventListener("mouseleave",()=>{document.activeElement!==l&&(l.style.borderColor="var(--fb-border-color)")}),o.appendChild(i),o.appendChild(l),o.appendChild(a),o}function so(e,t,n,r){const o=t.state,i=le(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(i){const a=En(l);n.appendChild(a)}else{const a=Cn(l,r,t);n.appendChild(a)}if(!i){const a=document.createElement("p");a.className="mt-1",a.style.cssText=`
271
621
  font-size: var(--fb-font-size-small);
272
622
  color: var(--fb-text-secondary-color);
273
- `,i.textContent=be(e,o),n.appendChild(i)}}function tr(e,t,n,r){var o,a;const l=t.state,i=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:1,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"#000000");const p=document.createElement("div");p.className="space-y-2",n.appendChild(p);function u(){p.querySelectorAll(".multiple-colour-item").forEach((b,y)=>{const w=b.querySelector("input");w&&(w.name=`${r}[${y}]`)})}function m(b="#000000",y=-1){const w=document.createElement("div");if(w.className="multiple-colour-item flex items-center gap-2",i){const C=Dt(b);for(;C.firstChild;)w.appendChild(C.firstChild)}else{const C=`${r}[${p.children.length}]`,x=jt(b,C,t);x.style.flex="1",w.appendChild(x)}return y===-1?p.appendChild(w):p.insertBefore(w,p.children[y]),u(),w}function v(){if(i)return;const b=p.querySelectorAll(".multiple-colour-item"),y=b.length;b.forEach(w=>{let C=w.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=`
623
+ `,a.textContent=ve(e,o),n.appendChild(a)}}function co(e,t,n,r){var o,i;const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0;for(;c.length<p;)c.push(e.default||"#000000");const f=document.createElement("div");f.className="space-y-2",n.appendChild(f);function d(){f.querySelectorAll(".multiple-colour-item").forEach((h,g)=>{const E=h.querySelector("input");E&&(E.name=`${r}[${g}]`)})}function m(h="#000000",g=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",a){const C=En(h);for(;C.firstChild;)E.appendChild(C.firstChild)}else{const C=`${r}[${f.children.length}]`,x=Cn(h,C,t);x.style.flex="1",E.appendChild(x)}return g===-1?f.appendChild(E):f.insertBefore(E,f.children[g]),d(),E}function b(){if(a)return;const h=f.querySelectorAll(".multiple-colour-item"),g=h.length;h.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=`
274
624
  color: var(--fb-error-color);
275
625
  background-color: transparent;
276
626
  transition: background-color var(--fb-transition-duration);
277
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(p.children).indexOf(w);p.children.length>f&&(s.splice(k,1),w.remove(),u(),h(),v())},w.appendChild(C));const x=y<=f;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let g=null,E=null;if(!i){g=document.createElement("div"),g.className="flex items-center gap-3 mt-2";const b=document.createElement("button");b.type="button",b.className="add-colour-btn px-3 py-1 rounded",b.style.cssText=`
627
+ `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{const k=Array.from(f.children).indexOf(E);f.children.length>p&&(c.splice(k,1),E.remove(),d(),v(),b())},E.appendChild(C));const x=g<=p;C.disabled=x,C.style.opacity=x?"0.5":"1",C.style.pointerEvents=x?"none":"auto"})}let y=null,w=null;if(!a){y=document.createElement("div"),y.className="flex items-center gap-3 mt-2";const h=document.createElement("button");h.type="button",h.className="add-colour-btn px-3 py-1 rounded",h.style.cssText=`
278
628
  color: var(--fb-primary-color);
279
629
  border: var(--fb-border-width) solid var(--fb-primary-color);
280
630
  background-color: transparent;
281
631
  font-size: var(--fb-font-size);
282
632
  transition: all var(--fb-transition-duration);
283
- `,b.textContent="+",b.addEventListener("mouseenter",()=>{b.style.backgroundColor="var(--fb-background-hover-color)"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor="transparent"}),b.onclick=()=>{const y=e.default||"#000000";s.push(y),m(y),h(),v()},E=document.createElement("span"),E.className="text-sm text-gray-500",g.appendChild(b),g.appendChild(E),n.appendChild(g)}function h(){if(!g||!E)return;const b=g.querySelector(".add-colour-btn");if(b){const y=s.length>=d;b.disabled=y,b.style.opacity=y?"0.5":"1",b.style.pointerEvents=y?"none":"auto"}E.textContent=`${s.length}/${d===1/0?"\u221E":d}`}if(s.forEach(b=>m(b)),h(),v(),!i){const b=document.createElement("p");b.className="mt-1",b.style.cssText=`
633
+ `,h.textContent="+",h.addEventListener("mouseenter",()=>{h.style.backgroundColor="var(--fb-background-hover-color)"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="transparent"}),h.onclick=()=>{const g=e.default||"#000000";c.push(g),m(g),v(),b()},w=document.createElement("span"),w.className="text-sm text-gray-500",y.appendChild(h),y.appendChild(w),n.appendChild(y)}function v(){if(!y||!w)return;const h=y.querySelector(".add-colour-btn");if(h){const g=c.length>=u;h.disabled=g,h.style.opacity=g?"0.5":"1",h.style.pointerEvents=g?"none":"auto"}w.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(h=>m(h)),v(),b(),!a){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
284
634
  font-size: var(--fb-font-size-small);
285
635
  color: var(--fb-text-secondary-color);
286
- `,b.textContent=be(e,l),n.appendChild(b)}}function nr(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,p)=>{var u,m;if(!d)return;const v=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(v);p?(d.classList.add("invalid"),d.title=p,g||(g=document.createElement("div"),g.id=v,g.className="error-message",g.style.cssText=`
636
+ `,h.textContent=ve(e,l),n.appendChild(h)}}function uo(e,t,n){var r,o,i;const l=[],{scopeRoot:a,skipValidation:s}=n,c=(u,f)=>{var d,m;if(!u)return;const b=`error-${u.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(b);f?(u.classList.add("invalid"),u.title=f,y||(y=document.createElement("div"),y.id=b,y.className="error-message",y.style.cssText=`
287
637
  color: var(--fb-error-color);
288
638
  font-size: var(--fb-font-size-small);
289
639
  margin-top: 0.25rem;
290
- `,d.nextSibling?(u=d.parentNode)==null||u.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=p,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,p,u)=>{const{state:m}=n;if(!p){if(!c&&e.required){const g=$("required",m);return l.push(`${u}: ${g}`),s(d,g),""}return s(d,null),""}const v=Fe(p);if(!c&&!it(v)){const g=$("invalidHexColour",m);return l.push(`${u}: ${g}`),s(d,g),p}return s(d,null),v};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}["].colour-hex-input`),p=[];if(d.forEach((u,m)=>{var v;const g=(v=u==null?void 0:u.value)!=null?v:"",E=f(u,g,`${t}[${m}]`);p.push(E)}),!c){const{state:u}=n,m=(r=e.minCount)!=null?r:1,v=(o=e.maxCount)!=null?o:1/0,g=p.filter(E=>E!=="");e.required&&g.length===0&&l.push(`${t}: ${$("required",u)}`),g.length<m&&l.push(`${t}: ${$("minItems",u,{min:m})}`),g.length>v&&l.push(`${t}: ${$("maxItems",u,{max:v})}`)}return{value:p,errors:l}}else{const d=i.querySelector(`[name="${t}"].colour-hex-input`),p=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&p===""){const u=$("required",n.state);return l.push(`${t}: ${u}`),s(d,u),{value:"",errors:l}}return{value:f(d,p,t),errors:l}}}function rr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}["].colour-hex-input`);a.forEach((l,i)=>{if(i<n.length){const c=Fe(n[i]);l.value=c,l.classList.remove("invalid"),l.title="";const s=l.closest(".colour-picker-wrapper");if(s){const f=s.querySelector(".colour-swatch"),d=s.querySelector(".colour-picker-hidden");f&&(f.style.backgroundColor=c),d&&(d.value=c.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=o.querySelector(`[name="${t}"].colour-hex-input`);if(a){const l=Fe(n);a.value=l,a.classList.remove("invalid"),a.title="";const i=a.closest(".colour-picker-wrapper");if(i){const c=i.querySelector(".colour-swatch"),s=i.querySelector(".colour-picker-hidden");c&&(c.style.backgroundColor=l),s&&(s.value=l.toLowerCase())}}}}function Ot(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function st(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function Ke(e,t){return Math.round(e/t)*t}function Ut(e,t,n,r,o){var a;const l=document.createElement("div");l.className="slider-container";const i=document.createElement("div");i.className="flex items-start gap-3";const c=document.createElement("div");c.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const f=n.scale||"linear",d=n.min,p=n.max,u=(a=n.step)!=null?a:1;if(f==="exponential"){if(d<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${d})`);s.min="0",s.max="1000",s.step="1";const h=st(e,d,p);s.value=(h*1e3).toString()}else s.min=d.toString(),s.max=p.toString(),s.step=u.toString(),s.value=e.toString();s.style.cssText=`
640
+ `,u.nextSibling?(d=u.parentNode)==null||d.insertBefore(y,u.nextSibling):(m=u.parentNode)==null||m.appendChild(y)),y.textContent=f,y.style.display="block"):(u.classList.remove("invalid"),u.title="",y&&y.remove())},p=(u,f,d)=>{const{state:m}=n;if(!f){if(!s&&e.required){const y=$("required",m);return l.push(`${d}: ${y}`),c(u,y),""}return c(u,null),""}const b=Ie(f);if(!s&&!kt(b)){const y=$("invalidHexColour",m);return l.push(`${d}: ${y}`),c(u,y),f}return c(u,null),b};if(e.multiple){const u=a.querySelectorAll(`[name^="${t}["].colour-hex-input`),f=[];if(u.forEach((d,m)=>{var b;const y=(b=d==null?void 0:d.value)!=null?b:"",w=p(d,y,`${t}[${m}]`);f.push(w)}),!s){const{state:d}=n,m=(r=e.minCount)!=null?r:1,b=(o=e.maxCount)!=null?o:1/0,y=f.filter(w=>w!=="");e.required&&y.length===0&&l.push(`${t}: ${$("required",d)}`),y.length<m&&l.push(`${t}: ${$("minItems",d,{min:m})}`),y.length>b&&l.push(`${t}: ${$("maxItems",d,{max:b})}`)}return{value:f,errors:l}}else{const u=a.querySelector(`[name="${t}"].colour-hex-input`),f=(i=u==null?void 0:u.value)!=null?i:"";if(!s&&e.required&&f===""){const d=$("required",n.state);return l.push(`${t}: ${d}`),c(u,d),{value:"",errors:l}}return{value:p(u,f,t),errors:l}}}function fo(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}["].colour-hex-input`);i.forEach((l,a)=>{if(a<n.length){const s=Ie(n[a]);l.value=s,l.classList.remove("invalid"),l.title="";const c=l.closest(".colour-picker-wrapper");if(c){const p=c.querySelector(".colour-swatch"),u=c.querySelector(".colour-picker-hidden");p&&(p.style.backgroundColor=s),u&&(u.value=s.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const l=Ie(n);i.value=l,i.classList.remove("invalid"),i.title="";const a=i.closest(".colour-picker-wrapper");if(a){const s=a.querySelector(".colour-swatch"),c=a.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=l),c&&(c.value=l.toLowerCase())}}}}function wn(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function $t(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function lt(e,t){return Math.round(e/t)*t}function kn(e,t,n,r,o){var i;const l=document.createElement("div");l.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=o;const p=n.scale||"linear",u=n.min,f=n.max,d=(i=n.step)!=null?i:1;if(p==="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 v=$t(e,u,f);c.value=(v*1e3).toString()}else c.min=u.toString(),c.max=f.toString(),c.step=d.toString(),c.value=e.toString();c.style.cssText=`
291
641
  height: 6px;
292
642
  border-radius: 3px;
293
643
  background: linear-gradient(
294
644
  to right,
295
645
  var(--fb-primary-color) 0%,
296
- var(--fb-primary-color) ${(e-d)/(p-d)*100}%,
297
- var(--fb-border-color) ${(e-d)/(p-d)*100}%,
646
+ var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
647
+ var(--fb-border-color) ${(e-u)/(f-u)*100}%,
298
648
  var(--fb-border-color) 100%
299
649
  );
300
650
  outline: none;
301
651
  transition: background 0.1s ease-in-out;
302
652
  cursor: ${o?"not-allowed":"pointer"};
303
653
  opacity: ${o?"0.6":"1"};
304
- `,c.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
654
+ `,s.appendChild(c);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
305
655
  font-size: var(--fb-font-size-small);
306
656
  color: var(--fb-text-secondary-color);
307
657
  margin-top: 4px;
308
- `;const v=document.createElement("span");v.textContent=d.toString();const g=document.createElement("span");g.textContent=p.toString(),m.appendChild(v),m.appendChild(g),c.appendChild(m);const E=document.createElement("span");if(E.className="slider-value",E.style.cssText=`
658
+ `;const b=document.createElement("span");b.textContent=u.toString();const y=document.createElement("span");y.textContent=f.toString(),m.appendChild(b),m.appendChild(y),s.appendChild(m);const w=document.createElement("span");if(w.className="slider-value",w.style.cssText=`
309
659
  min-width: 60px;
310
660
  text-align: right;
311
661
  font-size: var(--fb-font-size);
@@ -313,64 +663,64 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
313
663
  font-family: var(--fb-font-family-mono, monospace);
314
664
  font-weight: 500;
315
665
  padding-top: 2px;
316
- `,E.textContent=e.toFixed(u<1?2:0),i.appendChild(c),i.appendChild(E),l.appendChild(i),!o){const h=()=>{let b;if(f==="exponential"){const w=parseFloat(s.value)/1e3;b=Ot(w,d,p),b=Ke(b,u),b=Math.max(d,Math.min(p,b))}else b=parseFloat(s.value),b=Ke(b,u);E.textContent=b.toFixed(u<1?2:0);const y=(b-d)/(p-d)*100;s.style.background=`linear-gradient(
666
+ `,w.textContent=e.toFixed(d<1?2:0),a.appendChild(s),a.appendChild(w),l.appendChild(a),!o){const v=()=>{let h;if(p==="exponential"){const E=parseFloat(c.value)/1e3;h=wn(E,u,f),h=lt(h,d),h=Math.max(u,Math.min(f,h))}else h=parseFloat(c.value),h=lt(h,d);w.textContent=h.toFixed(d<1?2:0);const g=(h-u)/(f-u)*100;c.style.background=`linear-gradient(
317
667
  to right,
318
668
  var(--fb-primary-color) 0%,
319
- var(--fb-primary-color) ${y}%,
320
- var(--fb-border-color) ${y}%,
669
+ var(--fb-primary-color) ${g}%,
670
+ var(--fb-border-color) ${g}%,
321
671
  var(--fb-border-color) 100%
322
- )`,r.instance&&r.instance.triggerOnChange(t,b)};s.addEventListener("input",h),s.addEventListener("change",h)}return l}function or(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=le(e,a,t),i=e.default!==void 0?e.default:(e.min+e.max)/2,c=(o=t.prefill[e.key])!=null?o:i,s=Ut(c,r,e,t,l);if(n.appendChild(s),!l){const f=document.createElement("p");f.className="mt-1",f.style.cssText=`
672
+ )`,r.instance&&r.instance.triggerOnChange(t,h)};c.addEventListener("input",v),c.addEventListener("change",v)}return l}function po(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,l=le(e,i,t),a=e.default!==void 0?e.default:(e.min+e.max)/2,s=(o=t.prefill[e.key])!=null?o:a,c=kn(s,r,e,t,l);if(n.appendChild(c),!l){const p=document.createElement("p");p.className="mt-1",p.style.cssText=`
323
673
  font-size: var(--fb-font-size-small);
324
674
  color: var(--fb-text-secondary-color);
325
- `,f.textContent=be(e,a),n.appendChild(f)}}function lr(e,t,n,r){var o,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 l=t.state,i=le(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:1,d=(a=e.maxCount)!=null?a:1/0,p=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<f;)s.push(p);const u=document.createElement("div");u.className="space-y-3",n.appendChild(u);function m(){u.querySelectorAll(".multiple-slider-item").forEach((y,w)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${w}]`)})}function v(y=p,w=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const x=`${r}[${u.children.length}]`,k=Ut(y,x,e,t,i);return k.style.flex="1",C.appendChild(k),w===-1?u.appendChild(C):u.insertBefore(C,u.children[w]),m(),C}function g(){if(i)return;const y=u.querySelectorAll(".multiple-slider-item"),w=y.length;y.forEach(C=>{let x=C.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=`
675
+ `,p.textContent=ve(e,i),n.appendChild(p)}}function mo(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const l=t.state,a=le(e,l,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],p=(o=e.minCount)!=null?o:1,u=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;c.length<p;)c.push(f);const d=document.createElement("div");d.className="space-y-3",n.appendChild(d);function m(){d.querySelectorAll(".multiple-slider-item").forEach((g,E)=>{const C=g.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${E}]`)})}function b(g=f,E=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const x=`${r}[${d.children.length}]`,k=kn(g,x,e,t,a);return k.style.flex="1",C.appendChild(k),E===-1?d.appendChild(C):d.insertBefore(C,d.children[E]),m(),C}function y(){if(a)return;const g=d.querySelectorAll(".multiple-slider-item"),E=g.length;g.forEach(C=>{let x=C.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
676
  color: var(--fb-error-color);
327
677
  background-color: transparent;
328
678
  transition: background-color var(--fb-transition-duration);
329
679
  margin-top: 8px;
330
- `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{const z=Array.from(u.children).indexOf(C);u.children.length>f&&(s.splice(z,1),C.remove(),m(),b(),g())},C.appendChild(x));const k=w<=f;x.disabled=k,x.style.opacity=k?"0.5":"1",x.style.pointerEvents=k?"none":"auto"})}let E=null,h=null;if(!i){E=document.createElement("div"),E.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=`
680
+ `,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(d.children).indexOf(C);d.children.length>p&&(c.splice(q,1),C.remove(),m(),h(),y())},C.appendChild(x));const k=E<=p;x.disabled=k,x.style.opacity=k?"0.5":"1",x.style.pointerEvents=k?"none":"auto"})}let w=null,v=null;if(!a){w=document.createElement("div"),w.className="flex items-center gap-3 mt-2";const g=document.createElement("button");g.type="button",g.className="add-slider-btn px-3 py-1 rounded",g.style.cssText=`
331
681
  color: var(--fb-primary-color);
332
682
  border: var(--fb-border-width) solid var(--fb-primary-color);
333
683
  background-color: transparent;
334
684
  font-size: var(--fb-font-size);
335
685
  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=()=>{s.push(p),v(p),b(),g()},h=document.createElement("span"),h.className="text-sm text-gray-500",E.appendChild(y),E.appendChild(h),n.appendChild(E)}function b(){if(!E||!h)return;const y=E.querySelector(".add-slider-btn");if(y){const w=s.length>=d;y.disabled=w,y.style.opacity=w?"0.5":"1",y.style.pointerEvents=w?"none":"auto"}h.textContent=`${s.length}/${d===1/0?"\u221E":d}`}if(s.forEach(y=>v(y)),b(),g(),!i){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
686
+ `,g.textContent="+",g.addEventListener("mouseenter",()=>{g.style.backgroundColor="var(--fb-background-hover-color)"}),g.addEventListener("mouseleave",()=>{g.style.backgroundColor="transparent"}),g.onclick=()=>{c.push(f),b(f),h(),y()},v=document.createElement("span"),v.className="text-sm text-gray-500",w.appendChild(g),w.appendChild(v),n.appendChild(w)}function h(){if(!w||!v)return;const g=w.querySelector(".add-slider-btn");if(g){const E=c.length>=u;g.disabled=E,g.style.opacity=E?"0.5":"1",g.style.pointerEvents=E?"none":"auto"}v.textContent=`${c.length}/${u===1/0?"\u221E":u}`}if(c.forEach(g=>b(g)),h(),y(),!a){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
337
687
  font-size: var(--fb-font-size-small);
338
688
  color: var(--fb-text-secondary-color);
339
- `,y.textContent=be(e,l),n.appendChild(y)}}function ar(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const s=e.min,f=e.max,d=(r=e.step)!=null?r:1,p=e.scale||"linear",u=(v,g)=>{var E,h;if(!v)return;const b=`error-${v.getAttribute("name")||Math.random().toString(36).substring(7)}`;let y=document.getElementById(b);if(g){if(v.classList.add("invalid"),v.title=g,!y){y=document.createElement("div"),y.id=b,y.className="error-message",y.style.cssText=`
689
+ `,g.textContent=ve(e,l),n.appendChild(g)}}function ho(e,t,n){var r,o,i;const l=[],{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,p=e.max,u=(r=e.step)!=null?r:1,f=e.scale||"linear",d=(b,y)=>{var w,v;if(!b)return;const h=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(h);if(y){if(b.classList.add("invalid"),b.title=y,!g){g=document.createElement("div"),g.id=h,g.className="error-message",g.style.cssText=`
340
690
  color: var(--fb-error-color);
341
691
  font-size: var(--fb-font-size-small);
342
692
  margin-top: 0.25rem;
343
- `;const w=v.closest(".slider-container");w&&w.nextSibling?(E=w.parentNode)==null||E.insertBefore(y,w.nextSibling):w&&((h=w.parentNode)==null||h.appendChild(y))}y.textContent=g,y.style.display="block"}else v.classList.remove("invalid"),v.title="",y&&y.remove()},m=(v,g)=>{const{state:E}=n,h=v.value;if(!h){if(!c&&e.required){const y=$("required",E);return l.push(`${g}: ${y}`),u(v,y),null}return u(v,null),null}let b;if(p==="exponential"){const y=parseFloat(h)/1e3;b=Ot(y,s,f),b=Ke(b,d)}else b=parseFloat(h),b=Ke(b,d);if(!c){if(b<s){const y=$("minValue",E,{min:s});return l.push(`${g}: ${y}`),u(v,y),b}if(b>f){const y=$("maxValue",E,{max:f});return l.push(`${g}: ${y}`),u(v,y),b}}return u(v,null),b};if(e.multiple){const v=i.querySelectorAll(`input[type="range"][name^="${t}["]`),g=[];if(v.forEach((E,h)=>{const b=m(E,`${t}[${h}]`);g.push(b)}),!c){const{state:E}=n,h=(o=e.minCount)!=null?o:1,b=(a=e.maxCount)!=null?a:1/0,y=g.filter(w=>w!==null);e.required&&y.length===0&&l.push(`${t}: ${$("required",E)}`),y.length<h&&l.push(`${t}: ${$("minItems",E,{min:h})}`),y.length>b&&l.push(`${t}: ${$("maxItems",E,{max:b})}`)}return{value:g,errors:l}}else{const v=i.querySelector(`input[type="range"][name="${t}"]`);return v?{value:m(v,t),errors:l}:(!c&&e.required&&l.push(`${t}: ${$("required",n.state)}`),{value:null,errors:l})}}function ir(e,t,n,r){var o;const{scopeRoot:a}=r,l=e.min,i=e.max,c=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const f=a.querySelectorAll(`input[type="range"][name^="${t}["]`);f.forEach((d,p)=>{if(p<n.length&&n[p]!==null){const u=Number(n[p]);if(s==="exponential"){const v=st(u,l,i);d.value=(v*1e3).toString()}else d.value=u.toString();const m=d.closest(".slider-container");if(m){const v=m.querySelector(".slider-value");v&&(v.textContent=u.toFixed(c<1?2:0));const g=(u-l)/(i-l)*100;d.style.background=`linear-gradient(
693
+ `;const E=b.closest(".slider-container");E&&E.nextSibling?(w=E.parentNode)==null||w.insertBefore(g,E.nextSibling):E&&((v=E.parentNode)==null||v.appendChild(g))}g.textContent=y,g.style.display="block"}else b.classList.remove("invalid"),b.title="",g&&g.remove()},m=(b,y)=>{const{state:w}=n,v=b.value;if(!v){if(!s&&e.required){const g=$("required",w);return l.push(`${y}: ${g}`),d(b,g),null}return d(b,null),null}let h;if(f==="exponential"){const g=parseFloat(v)/1e3;h=wn(g,c,p),h=lt(h,u)}else h=parseFloat(v),h=lt(h,u);if(!s){if(h<c){const g=$("minValue",w,{min:c});return l.push(`${y}: ${g}`),d(b,g),h}if(h>p){const g=$("maxValue",w,{max:p});return l.push(`${y}: ${g}`),d(b,g),h}}return d(b,null),h};if(e.multiple){const b=a.querySelectorAll(`input[type="range"][name^="${t}["]`),y=[];if(b.forEach((w,v)=>{const h=m(w,`${t}[${v}]`);y.push(h)}),!s){const{state:w}=n,v=(o=e.minCount)!=null?o:1,h=(i=e.maxCount)!=null?i:1/0,g=y.filter(E=>E!==null);e.required&&g.length===0&&l.push(`${t}: ${$("required",w)}`),g.length<v&&l.push(`${t}: ${$("minItems",w,{min:v})}`),g.length>h&&l.push(`${t}: ${$("maxItems",w,{max:h})}`)}return{value:y,errors:l}}else{const b=a.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:l}:(!s&&e.required&&l.push(`${t}: ${$("required",n.state)}`),{value:null,errors:l})}}function vo(e,t,n,r){var o;const{scopeRoot:i}=r,l=e.min,a=e.max,s=(o=e.step)!=null?o: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 p=i.querySelectorAll(`input[type="range"][name^="${t}["]`);p.forEach((u,f)=>{if(f<n.length&&n[f]!==null){const d=Number(n[f]);if(c==="exponential"){const b=$t(d,l,a);u.value=(b*1e3).toString()}else u.value=d.toString();const m=u.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=d.toFixed(s<1?2:0));const y=(d-l)/(a-l)*100;u.style.background=`linear-gradient(
344
694
  to right,
345
695
  var(--fb-primary-color) 0%,
346
- var(--fb-primary-color) ${g}%,
347
- var(--fb-border-color) ${g}%,
696
+ var(--fb-primary-color) ${y}%,
697
+ var(--fb-border-color) ${y}%,
348
698
  var(--fb-border-color) 100%
349
- )`}d.classList.remove("invalid"),d.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 d=Number(n);if(s==="exponential"){const u=st(d,l,i);f.value=(u*1e3).toString()}else f.value=d.toString();const p=f.closest(".slider-container");if(p){const u=p.querySelector(".slider-value");u&&(u.textContent=d.toFixed(c<1?2:0));const m=(d-l)/(i-l)*100;f.style.background=`linear-gradient(
699
+ )`}u.classList.remove("invalid"),u.title=""}}),n.length!==p.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${p.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const p=i.querySelector(`input[type="range"][name="${t}"]`);if(p&&n!==null&&n!==void 0){const u=Number(n);if(c==="exponential"){const d=$t(u,l,a);p.value=(d*1e3).toString()}else p.value=u.toString();const f=p.closest(".slider-container");if(f){const d=f.querySelector(".slider-value");d&&(d.textContent=u.toFixed(s<1?2:0));const m=(u-l)/(a-l)*100;p.style.background=`linear-gradient(
350
700
  to right,
351
701
  var(--fb-primary-color) 0%,
352
702
  var(--fb-primary-color) ${m}%,
353
703
  var(--fb-border-color) ${m}%,
354
704
  var(--fb-border-color) 100%
355
- )`}f.classList.remove("invalid"),f.title=""}}}function Pt(e){const t={};for(const n of e)"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Vt(e,t){return{...t,...e}}function ct(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 ut=null;function sr(e){ut=e}function We(e,t){if(!ut)throw new Error("renderElement not initialized. Import from components/index.ts");return ut(e,t)}function Kt(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,o)=>{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(o)),n.appendChild(a)}),n}function Wt(e,t,n,r){var o,a;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-4 bg-gray-50",l.setAttribute("data-container",r);const i=document.createElement("div"),c=e.columns||1;c===1?i.className="space-y-4":i.className=`grid grid-cols-${c} gap-4`;const s=le(e,t.state,t);if(!s){const m=Kt(e,r);m&&l.appendChild(m)}const f=Pt(e.elements),d=((o=t.prefill)==null?void 0:o[e.key])||{},p=Vt(d,f),u={path:ye(t.path,e.key),prefill:p,formData:(a=t.formData)!=null?a:t.prefill,state:t.state,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var v,g;if(m.hidden||m.type==="hidden"){const E=(g=(v=d[m.key])!=null?v:m.default)!=null?g:null;i.appendChild(ze(ye(u.path,m.key),E))}else i.appendChild(We(m,u))}),l.appendChild(i),n.appendChild(l)}function _t(e,t,n,r){var o,a,l,i;const c=t.state,s=le(e,c,t),f=s||t.inheritedReadonly,d=document.createElement("div");d.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 u=document.createElement("div");if(u.className="space-y-4",!s){const C=Kt(e,e.key);C&&d.appendChild(C)}const m=(o=e.minCount)!=null?o:0,v=(a=e.maxCount)!=null?a:1/0,g=Array.isArray((l=t.prefill)==null?void 0:l[e.key])?t.prefill[e.key]:null,E=Pt(e.elements),h=()=>u.querySelectorAll(":scope > .containerItem").length,b=()=>{const C=document.createElement("button");return C.type="button",C.className="add-container-btn px-3 py-1 rounded",C.style.cssText=`
705
+ )`}p.classList.remove("invalid"),p.title=""}}}function $n(e){const t={};for(const n of e)"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Ln(e,t){return{...t,...e}}function Lt(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 St=null;function bo(e){St=e}function it(e,t){if(!St)throw new Error("renderElement not initialized. Import from components/index.ts");return St(e,t)}function Sn(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,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function Tn(e,t,n,r){var o,i;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-4 bg-gray-50",l.setAttribute("data-container",r);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=Sn(e,r);m&&l.appendChild(m)}const p=$n(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},f=Ln(u,p),d={path:xe(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,inheritedReadonly:c||t.inheritedReadonly};e.elements.forEach(m=>{var b,y;if(m.hidden||m.type==="hidden"){const w=(y=(b=u[m.key])!=null?b:m.default)!=null?y:null;a.appendChild(De(xe(d.path,m.key),w))}else a.appendChild(it(m,d))}),l.appendChild(a),n.appendChild(l)}function Fn(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=c||t.inheritedReadonly,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 d=document.createElement("div");if(d.className="space-y-4",!c){const C=Sn(e,e.key);C&&u.appendChild(C)}const m=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,y=Array.isArray((l=t.prefill)==null?void 0:l[e.key])?t.prefill[e.key]:null,w=$n(e.elements),v=()=>d.querySelectorAll(":scope > .containerItem").length,h=()=>{const C=document.createElement("button");return C.type="button",C.className="add-container-btn px-3 py-1 rounded",C.style.cssText=`
356
706
  color: var(--fb-primary-color);
357
707
  border: var(--fb-border-width) solid var(--fb-primary-color);
358
708
  background-color: transparent;
359
709
  font-size: var(--fb-font-size);
360
710
  transition: all var(--fb-transition-duration);
361
- `,C.textContent="+",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{if(h()<v){const x=h(),k=c.formRoot?ct(c.formRoot):{},z={state:t.state,path:ye(t.path,`${e.key}[${x}]`),prefill:E,formData:k,inheritedReadonly:f},W=document.createElement("div");W.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",W.setAttribute("data-container-item",`${e.key}[${x}]`);const H=document.createElement("div"),Z=e.columns||1;if(Z===1?H.className="space-y-4":H.className=`grid grid-cols-${Z} gap-4`,e.elements.forEach(Q=>{var oe;Q.hidden||Q.type==="hidden"?H.appendChild(ze(ye(z.path,Q.key),(oe=Q.default)!=null?oe:null)):H.appendChild(We(Q,z))}),W.appendChild(H),!s){const Q=document.createElement("button");Q.type="button",Q.className="absolute top-2 right-2 px-2 py-1 rounded",Q.style.cssText=`
711
+ `,C.textContent="+",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{if(v()<b){const x=v(),k=s.formRoot?Lt(s.formRoot):{},q={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:w,formData:k,inheritedReadonly:p},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 R=document.createElement("div"),G=e.columns||1;if(G===1?R.className="space-y-4":R.className=`grid grid-cols-${G} gap-4`,e.elements.forEach(Z=>{var oe;Z.hidden||Z.type==="hidden"?R.appendChild(De(xe(q.path,Z.key),(oe=Z.default)!=null?oe:null)):R.appendChild(it(Z,q))}),K.appendChild(R),!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
712
  color: var(--fb-error-color);
363
713
  background-color: transparent;
364
714
  transition: background-color var(--fb-transition-duration);
365
- `,Q.textContent="\u2715",Q.addEventListener("mouseenter",()=>{Q.style.backgroundColor="var(--fb-background-hover-color)"}),Q.addEventListener("mouseleave",()=>{Q.style.backgroundColor="transparent"}),Q.onclick=()=>w(W),W.style.position="relative",W.appendChild(Q)}u.appendChild(W),y()}},C},y=()=>{const C=h(),x=d.querySelector(".add-container-btn");x&&(x.disabled=C>=v,x.style.opacity=C>=v?"0.5":"1",x.style.pointerEvents=C>=v?"none":"auto"),p.textContent=`${C}/${v===1/0?"\u221E":v}`},w=C=>{C.remove(),y()};if(g&&Array.isArray(g)&&g.forEach((C,x)=>{var k;const z=Vt(C||{},E),W={state:t.state,path:ye(t.path,`${e.key}[${x}]`),prefill:z,formData:(k=t.formData)!=null?k:t.prefill,inheritedReadonly:f},H=document.createElement("div");H.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",H.setAttribute("data-container-item",`${e.key}[${x}]`);const Z=document.createElement("div"),Q=e.columns||1;if(Q===1?Z.className="space-y-4":Z.className=`grid grid-cols-${Q} gap-4`,e.elements.forEach(oe=>{var Le,pe;if(oe.hidden||oe.type==="hidden"){const we=(pe=(Le=C==null?void 0:C[oe.key])!=null?Le:oe.default)!=null?pe:null;Z.appendChild(ze(ye(W.path,oe.key),we))}else Z.appendChild(We(oe,W))}),H.appendChild(Z),!s){const oe=document.createElement("button");oe.type="button",oe.className="absolute top-2 right-2 px-2 py-1 rounded",oe.style.cssText=`
715
+ `,Z.textContent="\u2715",Z.addEventListener("mouseenter",()=>{Z.style.backgroundColor="var(--fb-background-hover-color)"}),Z.addEventListener("mouseleave",()=>{Z.style.backgroundColor="transparent"}),Z.onclick=()=>E(K),K.style.position="relative",K.appendChild(Z)}d.appendChild(K),g()}},C},g=()=>{const C=v(),x=u.querySelector(".add-container-btn");x&&(x.disabled=C>=b,x.style.opacity=C>=b?"0.5":"1",x.style.pointerEvents=C>=b?"none":"auto"),f.textContent=`${C}/${b===1/0?"\u221E":b}`},E=C=>{C.remove(),g()};if(y&&Array.isArray(y)&&y.forEach((C,x)=>{var k;const q=Ln(C||{},w),K={state:t.state,path:xe(t.path,`${e.key}[${x}]`),prefill:q,formData:(k=t.formData)!=null?k:t.prefill,inheritedReadonly:p},R=document.createElement("div");R.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",R.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 Ae,fe;if(oe.hidden||oe.type==="hidden"){const Se=(fe=(Ae=C==null?void 0:C[oe.key])!=null?Ae:oe.default)!=null?fe:null;G.appendChild(De(xe(K.path,oe.key),Se))}else G.appendChild(it(oe,K))}),R.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
716
  color: var(--fb-error-color);
367
717
  background-color: transparent;
368
718
  transition: background-color var(--fb-transition-duration);
369
- `,oe.textContent="\u2715",oe.addEventListener("mouseenter",()=>{oe.style.backgroundColor="var(--fb-background-hover-color)"}),oe.addEventListener("mouseleave",()=>{oe.style.backgroundColor="transparent"}),oe.onclick=()=>w(H),H.style.position="relative",H.appendChild(oe)}u.appendChild(H)}),!s)for(;h()<m;){const C=h(),x={state:t.state,path:ye(t.path,`${e.key}[${C}]`),prefill:E,formData:(i=t.formData)!=null?i:t.prefill,inheritedReadonly:f},k=document.createElement("div");k.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",k.setAttribute("data-container-item",`${e.key}[${C}]`);const z=document.createElement("div"),W=e.columns||1;W===1?z.className="space-y-4":z.className=`grid grid-cols-${W} gap-4`,e.elements.forEach(Z=>{var Q;Z.hidden||Z.type==="hidden"?z.appendChild(ze(ye(x.path,Z.key),(Q=Z.default)!=null?Q:null)):z.appendChild(We(Z,x))}),k.appendChild(z);const H=document.createElement("button");H.type="button",H.className="absolute top-2 right-2 px-2 py-1 rounded",H.style.cssText=`
719
+ `,oe.textContent="\u2715",oe.addEventListener("mouseenter",()=>{oe.style.backgroundColor="var(--fb-background-hover-color)"}),oe.addEventListener("mouseleave",()=>{oe.style.backgroundColor="transparent"}),oe.onclick=()=>E(R),R.style.position="relative",R.appendChild(oe)}d.appendChild(R)}),!c)for(;v()<m;){const C=v(),x={state:t.state,path:xe(t.path,`${e.key}[${C}]`),prefill:w,formData:(a=t.formData)!=null?a:t.prefill,inheritedReadonly:p},k=document.createElement("div");k.className="containerItem border border-gray-300 rounded-lg p-4 bg-white",k.setAttribute("data-container-item",`${e.key}[${C}]`);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(De(xe(x.path,G.key),(Z=G.default)!=null?Z:null)):q.appendChild(it(G,x))}),k.appendChild(q);const R=document.createElement("button");R.type="button",R.className="absolute top-2 right-2 px-2 py-1 rounded",R.style.cssText=`
370
720
  color: var(--fb-error-color);
371
721
  background-color: transparent;
372
722
  transition: background-color var(--fb-transition-duration);
373
- `,H.textContent="\u2715",H.addEventListener("mouseenter",()=>{H.style.backgroundColor="var(--fb-background-hover-color)"}),H.addEventListener("mouseleave",()=>{H.style.backgroundColor="transparent"}),H.onclick=()=>{h()>m&&w(k)},k.style.position="relative",k.appendChild(H),u.appendChild(k)}if(d.appendChild(u),!s){const C=document.createElement("div");C.className="flex items-center gap-3 mt-2",C.appendChild(b()),C.appendChild(p),d.appendChild(C)}y(),n.appendChild(d)}let dt=null;function cr(e){dt=e}function Jt(e,t,n){if(!dt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return dt(e,t,n)}function Yt(e,t,n){const r=[],{scopeRoot:o,skipValidation:a,path:l}=n;if(!("elements"in e))return{value:null,errors:r};const i=(c,s,f)=>{var d,p;if(a)return;const{state:u}=n,m="minCount"in f&&(d=f.minCount)!=null?d:0,v="maxCount"in f&&(p=f.maxCount)!=null?p:1/0;f.required&&s.length===0&&r.push(`${c}: ${$("required",u)}`),s.length<m&&r.push(`${c}: ${$("minItems",u,{min:m})}`),s.length>v&&r.push(`${c}: ${$("maxItems",u,{max:v})}`)};if("multiple"in e&&e.multiple){const c=[],s=o.querySelectorAll("[data-container-item]");return Array.from(s).filter(f=>{const d=f.getAttribute("data-container-item")||"";if(!d.startsWith(`${t}[`))return!1;const p=d.slice(t.length);return/^\[\d+\]$/.test(p)}).forEach(f=>{const d={},p=(f.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),u=p?parseInt(p[1],10):0;e.elements.forEach(m=>{var v;if(m.enableIf)try{const h=(v=n.instance)!=null&&v.getState().formRoot?ct(n.instance.getState().formRoot):{};if(!Te(m.enableIf,h,d))return}catch(h){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${u}]":`,h)}const g=`${t}[${u}].${m.key}`,E=Jt({...m,key:g},{path:l},f);E.spread&&E.value!==null&&typeof E.value=="object"?Object.assign(d,E.value):d[m.key]=E.value}),c.push(d)}),i(t,c,e),{value:c,errors:r}}else{const c={},s=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(f=>{var d;if(f.enableIf)try{const p=(d=n.instance)!=null&&d.getState().formRoot?ct(n.instance.getState().formRoot):{};if(!Te(f.enableIf,p,c))return}catch(p){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}":`,p)}{const p=`${t}.${f.key}`,u=Jt({...f,key:p},{path:l},s);u.spread&&u.value!==null&&typeof u.value=="object"?Object.assign(c,u.value):c[f.key]=u.value}}),{value:c,errors:r}}}function Xt(e,t,n,r){const{instance:o,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((i,c)=>{Oe(i)&&e.elements.forEach(s=>{var f,d;const p=`${t}[${c}].${s.key}`;if(s.type==="richinput"&&s.flatOutput){const u=s,m=(f=u.textKey)!=null?f:"text",v=(d=u.filesKey)!=null?d:"files",g=i,E={};m in g&&(E[m]=g[m]),v in g&&(E[v]=g[v]),Object.keys(E).length>0&&o.updateField(p,E)}else{const u=i[s.key];u!==void 0&&o.updateField(p,u)}})});const l=a.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==l.length&&console.warn(`updateContainerField: Multiple container field "${t}" item count mismatch. Consider re-rendering for add/remove.`)}else{if(!Oe(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(l=>{var i,c;const s=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const f=l,d=(i=f.textKey)!=null?i:"text",p=(c=f.filesKey)!=null?c:"files",u=n,m={};d in u&&(m[d]=u[d]),p in u&&(m[p]=u[p]),Object.keys(m).length>0&&o.updateField(s,m)}else{const f=n[l.key];f!==void 0&&o.updateField(s,f)}})}}function ur(e,t,n,r){var o,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 l={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&&Oe(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};l.multiple?_t(l,t,n):Wt(l,t,n,r)}function Gt(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&&Oe(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function dr(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=Gt(e);return Yt(r,t,n)}function pr(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=Gt(e);return Xt(o,t,n,r)}function fr(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function mr(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 hr(e){return fr(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:mr(e)?e:null}function Ne(e){return e.map(hr).filter(t=>t!==null)}function Zt(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function pt(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let a=r+1;a<e.length;a++){const l=e[a];if(o.top<=l.bottom&&o.bottom>=l.top&&o.left<=l.right&&o.right>=l.left)return`Merges ${r} and ${a} overlap`}}return null}function Qt(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(o=>o.top===e&&o.left===t))!=null?r:null}function Ce(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=`
723
+ `,R.textContent="\u2715",R.addEventListener("mouseenter",()=>{R.style.backgroundColor="var(--fb-background-hover-color)"}),R.addEventListener("mouseleave",()=>{R.style.backgroundColor="transparent"}),R.onclick=()=>{v()>m&&E(k)},k.style.position="relative",k.appendChild(R),d.appendChild(k)}if(u.appendChild(d),!c){const C=document.createElement("div");C.className="flex items-center gap-3 mt-2",C.appendChild(h()),C.appendChild(f),u.appendChild(C)}g(),n.appendChild(u)}let Tt=null;function go(e){Tt=e}function An(e,t,n){if(!Tt)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Tt(e,t,n)}function Mn(e,t,n){const r=[],{scopeRoot:o,skipValidation:i,path:l}=n;if(!("elements"in e))return{value:null,errors:r};const a=(s,c,p)=>{var u,f;if(i)return;const{state:d}=n,m="minCount"in p&&(u=p.minCount)!=null?u:0,b="maxCount"in p&&(f=p.maxCount)!=null?f:1/0;p.required&&c.length===0&&r.push(`${s}: ${$("required",d)}`),c.length<m&&r.push(`${s}: ${$("minItems",d,{min:m})}`),c.length>b&&r.push(`${s}: ${$("maxItems",d,{max:b})}`)};if("multiple"in e&&e.multiple){const s=[],c=o.querySelectorAll("[data-container-item]");return Array.from(c).filter(p=>{const u=p.getAttribute("data-container-item")||"";if(!u.startsWith(`${t}[`))return!1;const f=u.slice(t.length);return/^\[\d+\]$/.test(f)}).forEach(p=>{const u={},f=(p.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),d=f?parseInt(f[1],10):0;e.elements.forEach(m=>{var b;if(m.enableIf)try{const v=(b=n.instance)!=null&&b.getState().formRoot?Lt(n.instance.getState().formRoot):{};if(!Ne(m.enableIf,v,u))return}catch(v){console.error(`Error evaluating enableIf for field "${m.key}" in container "${t}[${d}]":`,v)}const y=`${t}[${d}].${m.key}`,w=An({...m,key:y},{path:l},p);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:r}}else{const s={},c=o.querySelector(`[data-container="${t}"]`)||o;return e.elements.forEach(p=>{var u;if(p.enableIf)try{const f=(u=n.instance)!=null&&u.getState().formRoot?Lt(n.instance.getState().formRoot):{};if(!Ne(p.enableIf,f,s))return}catch(f){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}":`,f)}{const f=`${t}.${p.key}`,d=An({...p,key:f},{path:l},c);d.spread&&d.value!==null&&typeof d.value=="object"?Object.assign(s,d.value):s[p.key]=d.value}}),{value:s,errors:r}}}function Nn(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}n.forEach((a,s)=>{Je(a)&&e.elements.forEach(c=>{var p,u;const f=`${t}[${s}].${c.key}`;if(c.type==="richinput"&&c.flatOutput){const d=c,m=(p=d.textKey)!=null?p:"text",b=(u=d.filesKey)!=null?u:"files",y=a,w={};m in y&&(w[m]=y[m]),b in y&&(w[b]=y[b]),Object.keys(w).length>0&&o.updateField(f,w)}else{const d=a[c.key];d!==void 0&&o.updateField(f,d)}})});const l=i.querySelectorAll(`[data-container-item^="${t}["]`);n.length!==l.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(l=>{var a,s;const c=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const p=l,u=(a=p.textKey)!=null?a:"text",f=(s=p.filesKey)!=null?s:"files",d=n,m={};u in d&&(m[u]=d[u]),f in d&&(m[f]=d[f]),Object.keys(m).length>0&&o.updateField(c,m)}else{const p=n[l.key];p!==void 0&&o.updateField(c,p)}})}}function yo(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const l={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:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};l.multiple?Fn(l,t,n):Tn(l,t,n,r)}function zn(e){var t,n;const r=e;return{type:"container",key:r.key,label:r.label,description:r.description,hint:r.hint,required:r.required,hidden:r.hidden,default:r.default,actions:r.actions,elements:r.elements,multiple:!!(r.repeat&&Je(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function xo(e,t,n){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field key: "${t}"`);const r=zn(e);return Mn(r,t,n)}function Eo(e,t,n,r){typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated. Please use type: "container" instead. Field path: "${t}"`);const o=zn(e);return Nn(o,t,n,r)}function Co(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function wo(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 ko(e){return Co(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:wo(e)?e:null}function Re(e){return e.map(ko).filter(t=>t!==null)}function qn(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ft(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const l=e[i];if(o.top<=l.bottom&&o.bottom>=l.top&&o.left<=l.right&&o.right>=l.left)return`Merges ${r} and ${i} overlap`}}return null}function In(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 at(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Le(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 He(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
374
724
  position: absolute;
375
725
  width: ${e.size}px;
376
726
  height: ${e.size}px;
@@ -390,7 +740,7 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
390
740
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
391
741
  transition: transform 0.1s, opacity 0.1s;
392
742
  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 vr(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,a=document.createElement("table");a.style.cssText=`
743
+ `,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 $o(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
394
744
  width: 100%;
395
745
  border-collapse: collapse;
396
746
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -398,13 +748,13 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
398
748
  font-size: var(--fb-font-size);
399
749
  font-family: var(--fb-font-family);
400
750
  color: var(--fb-text-color);
401
- `,n.forEach((i,c)=>{var s,f;const d=(c===0?a.createTHead():(s=a.tBodies[0])!=null?s:a.createTBody()).insertRow();for(let p=0;p<o;p++){if(Qt(c,p,r))continue;const u=_e(c,p,r),m=document.createElement(c===0?"th":"td");if(u){const v=u.bottom-u.top+1,g=u.right-u.left+1;v>1&&(m.rowSpan=v),g>1&&(m.colSpan=g)}m.textContent=(f=i[p])!=null?f:"",m.style.cssText=`
751
+ `,n.forEach((a,s)=>{var c,p;const u=(s===0?i.createTHead():(c=i.tBodies[0])!=null?c:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(In(s,f,r))continue;const d=at(s,f,r),m=document.createElement(s===0?"th":"td");if(d){const b=d.bottom-d.top+1,y=d.right-d.left+1;b>1&&(m.rowSpan=b),y>1&&(m.colSpan=y)}m.textContent=(p=a[f])!=null?p:"",m.style.cssText=`
402
752
  padding: 6px 10px;
403
753
  border: var(--fb-border-width) solid var(--fb-border-color);
404
754
  text-align: left;
405
755
  vertical-align: top;
406
- ${c===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
407
- `,d.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(a),t.appendChild(l)}function gr(e,t,n,r,o,a){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const l=document.createRange(),i=window.getSelection();l.selectNodeContents(e),l.collapse(!1),i==null||i.removeAllRanges(),i==null||i.addRange(l);function c(){var d;e.contentEditable="inherit";const p=r();p[t]&&(p[t][n]=(d=e.textContent)!=null?d:""),o()}function s(d){var p,u,m,v;const g=r(),E=(u=(p=g[0])==null?void 0:p.length)!=null?u:0;if(d.key==="Escape"){e.contentEditable="inherit",e.textContent=(v=(m=g[t])==null?void 0:m[n])!=null?v:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",f);return}if(d.key==="Enter"&&!d.shiftKey){d.preventDefault(),d.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);const h=t+1<g.length?t+1:t;a(h,n);return}if(d.key==="Tab"){d.preventDefault(),d.stopPropagation(),c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f);let h=t,b=d.shiftKey?n-1:n+1;b<0&&(b=E-1,h=Math.max(0,t-1)),b>=E&&(b=0,h=Math.min(g.length-1,t+1)),a(h,b)}}function f(){e.contentEditable==="true"&&(c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f))}e.addEventListener("keydown",s),e.addEventListener("blur",f)}function br(){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 yr(e,t){br();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
756
+ ${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
757
+ `,u.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(i),t.appendChild(l)}function Lo(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const l=document.createRange(),a=window.getSelection();l.selectNodeContents(e),l.collapse(!1),a==null||a.removeAllRanges(),a==null||a.addRange(l);function s(){var u;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(u=e.textContent)!=null?u:""),o()}function c(u){var f,d,m,b;const y=r(),w=(d=(f=y[0])==null?void 0:f.length)!=null?d:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=y[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",c),e.removeEventListener("blur",p);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p);const v=t+1<y.length?t+1:t;i(v,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p);let v=t,h=u.shiftKey?n-1:n+1;h<0&&(h=w-1,v=Math.max(0,t-1)),h>=w&&(h=0,v=Math.min(y.length-1,t+1)),i(v,h)}}function p(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",c),e.removeEventListener("blur",p))}e.addEventListener("keydown",c),e.addEventListener("blur",p)}function So(){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 To(e,t){So();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
408
758
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
409
759
  background: rgba(255,255,255,0.8); display: flex;
410
760
  align-items: center; justify-content: center; flex-direction: column;
@@ -413,13 +763,13 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
413
763
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
414
764
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
415
765
  animation: fb-spin 0.8s linear infinite;
416
- `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function xr(e,t,n,r,o){var a,l,i,c,s,f,d,p;const u=r.state,m=r.instance,v=e.mergeAllowed!==!1,g=(l=(a=e.fieldNames)==null?void 0:a.cells)!=null?l:"cells",E=(c=(i=e.fieldNames)==null?void 0:i.merges)!=null?c:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):Zt((s=e.rows)!=null?s:3,(f=e.columns)!=null?f:3);let b=t.merges?[...t.merges]:[];const y={anchor:null,focus:null,dragging:!1},w=document.createElement("input");w.type="hidden",w.name=n,w.value=JSON.stringify({[g]:h,[E]:b}),o.appendChild(w);function C(){w.value=JSON.stringify({[g]:h,[E]:b}),m&&m.triggerOnChange(n,{[g]:h,[E]:b})}w._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),b.length=0,A.merges&&A.merges.forEach(T=>b.push({...T})),y.anchor=null,y.focus=null,C(),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=`
766
+ `;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function Fo(e,t,n,r,o){var i,l,a,s,c,p,u,f;const d=r.state,m=r.instance,b=e.mergeAllowed!==!1,y=(l=(i=e.fieldNames)==null?void 0:i.cells)!=null?l:"cells",w=(s=(a=e.fieldNames)==null?void 0:a.merges)!=null?s:"merges",v=t.cells.length>0?t.cells.map(F=>[...F]):qn((c=e.rows)!=null?c:3,(p=e.columns)!=null?p:3);let h=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({[y]:v,[w]:h}),o.appendChild(E);function C(){E.value=JSON.stringify({[y]:v,[w]:h}),m&&m.triggerOnChange(n,{[y]:v,[w]:h})}E._applyExternalUpdate=F=>{v.length=0,F.cells.forEach(T=>v.push([...T])),h.length=0,F.merges&&F.merges.forEach(T=>h.push({...T})),g.anchor=null,g.focus=null,C(),M()};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
767
  border-collapse: collapse;
418
768
  font-size: var(--fb-font-size);
419
769
  font-family: var(--fb-font-family);
420
770
  color: var(--fb-text-color);
421
771
  table-layout: fixed;
422
- `,x.appendChild(k);const z=(p=(d=e.importAccept)==null?void 0:d.map(A=>`.${A.toLowerCase()}`))!=null?p:[];async function W(A){var T,S,B;if(!u.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const D=yr(x,$("tableImporting",u));try{const F=await u.config.parseTableFile(A),ee=F.cells,O=(T=F.merges)!=null?T:[];if(O.length>0){const U=pt(O,ee.length,(B=(S=ee[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}h.length=0,ee.forEach(U=>h.push([...U])),b.length=0,O.forEach(U=>b.push({...U})),y.anchor=null,y.focus=null,C(),N()}catch(F){const ee=F instanceof Error?F.message:String(F);console.error($("tableImportError",u).replace("{error}",ee))}finally{D.remove()}}if(e.importAccept&&u.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=$("tableImportFile",u),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=`
772
+ `,x.appendChild(k);const q=(f=(u=e.importAccept)==null?void 0:u.map(F=>`.${F.toLowerCase()}`))!=null?f:[];async function K(F){var T,S,B;if(!d.config.parseTableFile)return;if(q.length>0){const A=F.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!q.includes(A))return}const D=To(x,$("tableImporting",d));try{const A=await d.config.parseTableFile(F),Q=A.cells,O=(T=A.merges)!=null?T:[];if(O.length>0){const U=Ft(O,Q.length,(B=(S=Q[0])==null?void 0:S.length)!=null?B:0);if(U)throw new Error(U)}v.length=0,Q.forEach(U=>v.push([...U])),h.length=0,O.forEach(U=>h.push({...U})),g.anchor=null,g.focus=null,C(),M()}catch(A){const Q=A instanceof Error?A.message:String(A);console.error($("tableImportError",d).replace("{error}",Q))}finally{D.remove()}}if(e.importAccept&&d.config.parseTableFile){const F=document.createElement("button");F.type="button",F.title=$("tableImportFile",d),F.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>',F.style.cssText=`
423
773
  position: absolute; top: 2px; left: 2px;
424
774
  width: 20px; height: 20px;
425
775
  padding: 0;
@@ -429,7 +779,7 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
429
779
  background: transparent;
430
780
  cursor: pointer;
431
781
  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",x.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var B;const D=(B=T.files)==null?void 0:B[0];D&&W(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 ee=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];ee&&W(ee)})}o.appendChild(x);const H=document.createElement("div");H.style.cssText=`
782
+ `,F.addEventListener("mouseenter",()=>{F.style.color="var(--fb-primary-color, #0066cc)"}),F.addEventListener("mouseleave",()=>{F.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),F.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(F);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,A;B.preventDefault(),S=0,x.style.outline="",x.style.outlineOffset="";const Q=(A=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:A[0];Q&&K(Q)})}o.appendChild(x);const R=document.createElement("div");R.style.cssText=`
433
783
  position: fixed;
434
784
  display: none;
435
785
  background: white;
@@ -440,7 +790,7 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
440
790
  z-index: 1000;
441
791
  gap: 4px;
442
792
  flex-direction: column;
443
- `,o.appendChild(H);function Z(A,T){const S=document.createElement("button");return S.type="button",S.textContent=A,S.style.cssText=`
793
+ `,o.appendChild(R);function G(F,T){const S=document.createElement("button");return S.type="button",S.textContent=F,S.style.cssText=`
444
794
  padding: 4px 10px;
445
795
  font-size: var(--fb-font-size-small);
446
796
  color: var(--fb-text-color);
@@ -450,8 +800,8 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
450
800
  cursor: pointer;
451
801
  white-space: nowrap;
452
802
  text-align: left;
453
- `,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 Q(A,T){if(!v)return;H.innerHTML="",H.style.display="flex";const S=Ce(y),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=y.anchor&&_e(y.anchor.row,y.anchor.col,b);if(B&&H.appendChild(Z($("tableMergeCells",u),q)),D&&H.appendChild(Z($("tableSplitCell",u),M)),!H.firstChild){oe();return}const F=140,ee=H.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=A+F>O?A-F:A,Y=T+ee>U?T-ee:T;H.style.left=`${V}px`,H.style.top=`${Y}px`}function oe(){H.style.display="none"}const Le=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){Le.abort();return}H.contains(A.target)||oe()},{signal:Le.signal});function pe(){const A=Ce(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 we(A,T){y.anchor={row:A,col:T},y.focus=null,pe(),k.focus()}function Be(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(),gr(B,A,T,()=>h,C,we))}function xe(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),b=b.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 et(A){if(h.length<=1)return;const T=A!==void 0?A:y.anchor?y.anchor.row:h.length-1;b=b.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}),C(),N()}function De(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,"")),b=b.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 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;b=b.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}),C(),N()}function q(){var A,T;if(!v)return;const S=Ce(y);if(!S)return;const{r1:B,c1:D,r2:F,c2:ee}=S;if(B===F&&D===ee)return;b=b.filter(j=>!(j.top<=F&&j.bottom>=B&&j.left<=ee&&j.right>=D));const O=h[B][D];for(let j=B;j<=F;j++)for(let X=D;X<=ee;X++)(j!==B||X!==D)&&(h[j][X]="");h[B][D]=O;const U={top:B,left:D,bottom:F,right:ee},V=[...b,U],Y=pt(V,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(Y){console.warn("Merge validation failed:",Y);return}b.push(U),y.anchor={row:B,col:D},y.focus=null,C(),N()}function M(){if(!v||!y.anchor)return;const{row:A,col:T}=y.anchor,S=b.findIndex(B=>B.top===A&&B.left===T);S!==-1&&(b.splice(S,1),y.focus=null,C(),N())}function N(){var A,T;k.innerHTML="";const S=h.length,B=S>0?h[0].length:0,D=Ce(y);for(let F=0;F<S;F++){const ee=(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(Qt(F,O,b))continue;const U=_e(F,O,b),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=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;":"",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=h[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 _=F,re=O;V.addEventListener("mousedown",G=>{if(G.target.tagName!=="BUTTON"&&G.target.contentEditable!=="true"){if(G.button===2){const K=Ce(y);if(K&&_>=K.r1&&_<=K.r2&&re>=K.c1&&re<=K.c2)return}G.shiftKey&&y.anchor?(G.preventDefault(),y.focus={row:_,col:re},y.dragging=!1,pe()):(y.anchor={row:_,col:re},y.focus=null,y.dragging=!0,pe())}}),V.addEventListener("mouseup",G=>{if(G.target.tagName!=="BUTTON"&&y.dragging){y.dragging=!1;const K=Ce(y);(!K||K.r1===K.r2&&K.c1===K.c2)&&Be(_,re)}}),V.addEventListener("mousemove",G=>{if(y.dragging&&G.buttons===1){const K=y.anchor;K&&(K.row!==_||K.col!==re)&&(y.focus={row:_,col:re},pe())}}),V.addEventListener("contextmenu",G=>{if(!v)return;const K=Ce(y),ue=K&&(K.r1!==K.r2||K.c1!==K.c2),ce=y.anchor&&_e(y.anchor.row,y.anchor.col,b);(ue||ce)&&(G.preventDefault(),Q(G.clientX,G.clientY))}),ee.appendChild(V)}}fe(),k.setAttribute("tabindex","0"),k.onkeydown=F=>{var ee,O;if(k.querySelector("[contenteditable='true']"))return;const U=y.anchor;if(!U)return;const V=h.length,Y=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[X,_]=j[F.key],re=Math.max(0,Math.min(V-1,U.row+X)),G=Math.max(0,Math.min(Y-1,U.col+_));F.shiftKey?(y.focus={row:re,col:G},pe()):we(re,G);return}if(F.key==="Enter"){F.preventDefault(),Be(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const X=(O=(ee=h[0])==null?void 0:ee.length)!=null?O:0;let _=U.row,re=F.shiftKey?U.col-1:U.col+1;re<0&&(re=X-1,_=Math.max(0,_-1)),re>=X&&(re=0,_=Math.min(h.length-1,_+1)),we(_,re);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())},k.oncopy=F=>{var ee,O,U,V;const Y=Ce(y);if(!Y)return;F.preventDefault();const{r1:j,c1:X,r2:_,c2:re}=Y,G=[],K=[];for(let P=j;P<=_;P++){const se=[],me=[];for(let he=X;he<=re;he++){const ge=(O=(ee=h[P])==null?void 0:ee[he])!=null?O:"";se.push(ge);const Se=ge.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Se}</td>`)}G.push(se.join(" ")),K.push(`<tr>${me.join("")}</tr>`)}const ue=G.join(`
454
- `),ce=`<table>${K.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",ue),(V=F.clipboardData)==null||V.setData("text/html",ce)},k.onpaste=F=>{var ee,O,U,V,Y,j,X,_,re;const G=y.anchor;if(!G)return;const K=(O=(ee=F.clipboardData)==null?void 0:ee.getData("text/plain"))!=null?O:"",ue=K.includes(" ")||K.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),ke=parseInt((j=(Y=ce.closest("td"))==null?void 0:Y.getAttribute("data-col"))!=null?j:"0",10);h[de]&&(h[de][ke]=(X=ce.textContent)!=null?X:"")}if(!K.trim())return;const P=K.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=G.row,me=G.col,he=se+P.length;for(;h.length<he;)h.push(Array((re=(_=h[0])==null?void 0:_.length)!=null?re:1).fill(""));const ge=Math.max(...P.map(de=>de.length)),Se=me+ge;if(h[0]&&Se>h[0].length){const de=Se-h[0].length;h.forEach(ke=>{for(let je=0;je<de;je++)ke.push("")})}for(let de=0;de<P.length;de++)for(let ke=0;ke<P[de].length;ke++){const je=se+de,Zr=me+ke;h[je]&&(h[je][Zr]=P[de][ke])}C(),N()}}const I=Me({label:"+",title:$("tableAddColumn",u),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=I.dataset.afterCol)!=null?A:"0",10);De(T)}});I.style.position="absolute",I.style.display="none",x.appendChild(I);const R=Me({label:"+",title:$("tableAddRow",u),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=R.dataset.afterRow)!=null?A:"0",10);xe(T)}});R.style.position="absolute",R.style.display="none",x.appendChild(R);let te=[],ne=[];const ie=Me({label:"+",title:$("tableAddColumn",u),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>De()});ie.style.position="absolute",ie.style.display="none",x.appendChild(ie);const ae=Me({label:"+",title:$("tableAddRow",u),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});ae.style.position="absolute",ae.style.display="none",x.appendChild(ae);function fe(){var A,T;te.forEach(O=>O.remove()),te=[],ne.forEach(O=>O.remove()),ne=[];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),Y=Me({label:"\xD7",title:$("tableRemoveColumn",u),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>L(V)});Y.setAttribute("data-action","remove-col"),Y.setAttribute("data-col",String(V)),Y.style.position="absolute",Y.style.display="none",x.appendChild(Y),te.push(Y)}}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 Y=parseInt((T=V.getAttribute("data-row"))!=null?T:"0",10),j=Me({label:"\xD7",title:$("tableRemoveRow",u),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>et(Y)});j.setAttribute("data-action","remove-row"),j.setAttribute("data-row",String(Y)),j.style.position="absolute",j.style.display="none",x.appendChild(j),ne.push(j)}}function D(O,U,V,Y,j){var X;const _=j?Array.from(k.querySelectorAll("thead td[data-col]")):[];let re=-1,G=1/0,K=-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<G&&(G=he,re=P);const ge=Math.abs(O-se.right);ge<ce&&ge<20&&(ce=ge,K=se.right-U.left+Y,ue=parseInt((X=_[P].getAttribute("data-col"))!=null?X:"0",10))}te.forEach((P,se)=>{if(!j||se!==re){P.style.display="none";return}const me=_[se].getBoundingClientRect(),he=(me.left+me.right)/2-U.left+Y;P.style.left=`${he-8}px`,P.style.top="2px",P.style.display="flex"}),j&&ue>=0?(I.style.display="flex",I.style.left=`${K-10}px`,I.style.top=`${V.top-U.top-10}px`,I.dataset.afterCol=String(ue)):I.style.display="none"}function F(O,U,V,Y,j){var X;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 re=-1,G=1/0,K=-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<G&&(G=he,re=P);const ge=Math.abs(O-se.bottom);if(ge<ce&&ge<14){ce=ge,K=se.bottom-U.top;const Se=_[P].querySelector("td[data-row]");ue=parseInt((X=Se==null?void 0:Se.getAttribute("data-row"))!=null?X:"0",10)}}ne.forEach((P,se)=>{if(!j||se!==re){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?(R.style.display="flex",R.style.top=`${K-10}px`,R.style.left=`${V.left-U.left+Y-10}px`,R.dataset.afterRow=String(ue)):R.style.display="none"}let ee=!1;x.onmousemove=O=>{const U=O.target;if(U.tagName==="BUTTON"&&U.parentElement===x||ee)return;ee=!0;const V=O.clientX,Y=O.clientY;requestAnimationFrame(()=>{ee=!1;const j=x.getBoundingClientRect(),X=k.getBoundingClientRect(),_=x.scrollLeft,re=Y>=j.top&&Y<X.top+4,G=V>=j.left&&V<X.left+4,K=Math.min(X.right,j.right),ue=V>K-20&&V<=j.right,ce=Y>X.bottom-4&&Y<=j.bottom+20;if(D(V,j,X,_,re),F(Y,j,X,_,G),ie.style.display=ue?"flex":"none",ue&&(ie.style.left=`${j.right-j.left+_-20}px`,ie.style.top=`${(X.top+X.bottom)/2-j.top-10}px`),ae.style.display=ce?"flex":"none",ce){const P=(j.left+j.right)/2-j.left+_;ae.style.left=`${P-10}px`,ae.style.top=`${X.bottom-j.top-10}px`}})},x.onmouseleave=()=>{te.forEach(O=>{O.style.display="none"}),ne.forEach(O=>{O.style.display="none"}),I.style.display="none",R.style.display="none",ie.style.display="none",ae.style.display="none"}}N()}function Er(e){var t,n;return{cells:Zt((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function ft(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function mt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Cr(e,t,n,r){var o,a,l,i;const c=t.state,s=le(e,c,t),f=t.prefill[e.key],d=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",p=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges";let u;if(ft(f))u={cells:f.cells,merges:f.merges?Ne(f.merges):[]};else if(f&&mt(f,d)){const m=f[p];u={cells:f[d],merges:m?Ne(m):[]}}else if(ft(e.default))u={cells:e.default.cells,merges:e.default.merges?Ne(e.default.merges):[]};else if(e.default&&mt(e.default,d)){const m=e.default[p];u={cells:e.default[d],merges:m?Ne(m):[]}}else u=Er(e);if(u.merges&&u.merges.length>0){const m=u.cells.length,v=m>0?u.cells[0].length:0,g=pt(u.merges,m,v);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),u={...u,merges:[]})}s?vr(u,n):xr(e,u,r,t,n)}function wr(e,t,n){var r,o;const{scopeRoot:a,skipValidation:l}=n,i=[],c=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=a.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:i};let f=null;try{f=JSON.parse(s.value)}catch(d){return i.push(`${t}: invalid table data`),{value:null,errors:i}}if(!l&&e.required){const d=f[c];d!=null&&d.some(p=>p.some(u=>u.trim()!==""))||i.push(`${t}: ${$("required",n.state)}`)}return{value:f,errors:i}}function kr(e,t,n,r){var o,a,l,i;const{scopeRoot:c}=r,s=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",f=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges",d=c.querySelector(`[name="${t}"]`);if(!d){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(ft(n))p={cells:n.cells,merges:n.merges?Ne(n.merges):[]};else if(n&&mt(n,s)){const u=n[f];p={cells:n[s],merges:u?Ne(u):[]}}p&&d._applyExternalUpdate?d._applyExternalUpdate(p):d.value=JSON.stringify(n)}function $r(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 ht(e,t){var n,r,o,a;const l=new Map,i=new Map;for(const c of e){const s=t.resourceIndex.get(c),f=(n=s==null?void 0:s.name)!=null?n:c;i.set(f,((r=i.get(f))!=null?r:0)+1)}for(const c of e){const s=t.resourceIndex.get(c),f=(o=s==null?void 0:s.name)!=null?o:c;((a=i.get(f))!=null?a:1)>1&&s?l.set(c,`${f} (${yn(s.size)})`):l.set(c,f)}return l}function vt(e){return e?e.type.startsWith("image/"):!1}function en(e,t){const n=ht(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function gt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function Je(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let 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:o,end:r,raw:e.slice(o,r),name:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Lr(e,t){if(t.size===0)return[];const n=Je(e),r=[];for(const o of n){const a=t.get(o.name);a&&r.push({start:o.start,end:o.end,name:o.name,rid:a})}return r}function Sr(e,t){const n=Lr(e,t);if(n.length===0)return e;let r="",o=0;for(const a of n)r+=e.slice(o,a.start),r+=`@${a.rid}`,o=a.end;return r+=e.slice(o),r}function tn(e,t,n){const r=ht(t,n),o=new Map;for(const c of t){const s=r.get(c);s&&o.set(c,s)}const a=Je(e);if(a.length===0)return e;let l="",i=0;for(const c of a){l+=e.slice(i,c.start);const s=o.get(c.name);s?l+=gt(s):l+=c.raw,i=c.end}return l+=e.slice(i),l}function nn(e,t,n,r){if(ve(e),n!=null&&n.file&&vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var l;if(!a||!e.isConnected)return;const i=document.createElement("img");i.alt=(l=n==null?void 0:n.name)!=null?l:t,i.src=a,i.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ve(e),e.appendChild(i)}).catch(a=>{var l,i;(i=(l=r.config).onThumbnailError)==null||i.call(l,a,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const 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,o.appendChild(a)}e.appendChild(o)}}function rn(e,t,n,r){if(ve(e),n!=null&&n.file&&vt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var a;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",ve(e),e.appendChild(l)}).catch(o=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,o,t)})}function on(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),a=n.top-r.height-8,l=n.bottom+8,i=a>=4?a:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,i)}px`}function ln(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
803
+ `,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(F,T){if(!b)return;R.innerHTML="",R.style.display="flex";const S=Le(g),B=S&&(S.r1!==S.r2||S.c1!==S.c2),D=g.anchor&&at(g.anchor.row,g.anchor.col,h);if(B&&R.appendChild(G($("tableMergeCells",d),z)),D&&R.appendChild(G($("tableSplitCell",d),N)),!R.firstChild){oe();return}const A=140,Q=R.children.length*32+8,O=window.innerWidth,U=window.innerHeight,V=F+A>O?F-A:F,J=T+Q>U?T-Q:T;R.style.left=`${V}px`,R.style.top=`${J}px`}function oe(){R.style.display="none"}const Ae=new AbortController;document.addEventListener("mousedown",F=>{if(!o.isConnected){Ae.abort();return}R.contains(F.target)||oe()},{signal:Ae.signal});function fe(){const F=Le(g);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=g.anchor!==null&&g.anchor.row===S&&g.anchor.col===B,A=F!==null&&S>=F.r1&&S<=F.r2&&B>=F.c1&&B<=F.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=A&&!D?"rgba(0,102,204,0.08)":""})}function Se(F,T){g.anchor={row:F,col:T},g.focus=null,fe(),k.focus()}function We(F,T){const S=k.querySelector(`td[data-row="${F}"][data-col="${T}"]`);if(!S)return;const B=S.querySelector("span");B&&(g.anchor={row:F,col:T},g.focus=null,fe(),Lo(B,F,T,()=>v,C,Se))}function Ce(F){var T;const S=v.length>0?v[0].length:(T=e.columns)!=null?T:3,B=Array(S).fill(""),D=F!==void 0?F+1:v.length;v.splice(D,0,B),h=h.map(A=>A.top>=D?{...A,top:A.top+1,bottom:A.bottom+1}:A.top<D&&A.bottom>=D?{...A,bottom:A.bottom+1}:A),C(),M()}function mt(F){if(v.length<=1)return;const T=F!==void 0?F:g.anchor?g.anchor.row:v.length-1;h=h.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),v.splice(T,1),g.anchor&&g.anchor.row>=v.length&&(g.anchor={row:v.length-1,col:g.anchor.col}),C(),M()}function Ke(F){var T,S;const B=F!==void 0?F+1:(S=(T=v[0])==null?void 0:T.length)!=null?S:0;v.forEach(D=>D.splice(B,0,"")),h=h.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(),M()}function L(F){if(v.length===0||v[0].length<=1)return;const T=F!==void 0?F:g.anchor?g.anchor.col:v[0].length-1;h=h.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),v.forEach(S=>S.splice(T,1)),g.anchor&&g.anchor.col>=v[0].length&&(g.anchor={row:g.anchor.row,col:v[0].length-1}),C(),M()}function z(){var F,T;if(!b)return;const S=Le(g);if(!S)return;const{r1:B,c1:D,r2:A,c2:Q}=S;if(B===A&&D===Q)return;h=h.filter(j=>!(j.top<=A&&j.bottom>=B&&j.left<=Q&&j.right>=D));const O=v[B][D];for(let j=B;j<=A;j++)for(let Y=D;Y<=Q;Y++)(j!==B||Y!==D)&&(v[j][Y]="");v[B][D]=O;const U={top:B,left:D,bottom:A,right:Q},V=[...h,U],J=Ft(V,v.length,(T=(F=v[0])==null?void 0:F.length)!=null?T:0);if(J){console.warn("Merge validation failed:",J);return}h.push(U),g.anchor={row:B,col:D},g.focus=null,C(),M()}function N(){if(!b||!g.anchor)return;const{row:F,col:T}=g.anchor,S=h.findIndex(B=>B.top===F&&B.left===T);S!==-1&&(h.splice(S,1),g.focus=null,C(),M())}function M(){var F,T;k.innerHTML="";const S=v.length,B=S>0?v[0].length:0,D=Le(g);for(let A=0;A<S;A++){const Q=(A===0?(F=k.tHead)!=null?F:k.createTHead():(T=k.tBodies[0])!=null?T:k.createTBody()).insertRow();for(let O=0;O<B;O++){if(In(A,O,h))continue;const U=at(A,O,h),V=document.createElement("td");if(V.setAttribute("data-row",String(A)),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&&A>=D.r1&&A<=D.r2&&O>=D.c1&&O<=D.c2,j=g.anchor!==null&&g.anchor.row===A&&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;",A===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=v[A][O],Y.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",V.appendChild(Y);const _=A,ne=O;V.addEventListener("mousedown",X=>{if(X.target.tagName!=="BUTTON"&&X.target.contentEditable!=="true"){if(X.button===2){const W=Le(g);if(W&&_>=W.r1&&_<=W.r2&&ne>=W.c1&&ne<=W.c2)return}X.shiftKey&&g.anchor?(X.preventDefault(),g.focus={row:_,col:ne},g.dragging=!1,fe()):(g.anchor={row:_,col:ne},g.focus=null,g.dragging=!0,fe())}}),V.addEventListener("mouseup",X=>{if(X.target.tagName!=="BUTTON"&&g.dragging){g.dragging=!1;const W=Le(g);(!W||W.r1===W.r2&&W.c1===W.c2)&&We(_,ne)}}),V.addEventListener("mousemove",X=>{if(g.dragging&&X.buttons===1){const W=g.anchor;W&&(W.row!==_||W.col!==ne)&&(g.focus={row:_,col:ne},fe())}}),V.addEventListener("contextmenu",X=>{if(!b)return;const W=Le(g),ue=W&&(W.r1!==W.r2||W.c1!==W.c2),ce=g.anchor&&at(g.anchor.row,g.anchor.col,h);(ue||ce)&&(X.preventDefault(),Z(X.clientX,X.clientY))}),Q.appendChild(V)}}pe(),k.setAttribute("tabindex","0"),k.onkeydown=A=>{var Q,O;if(k.querySelector("[contenteditable='true']"))return;const U=g.anchor;if(!U)return;const V=v.length,J=V>0?v[0].length:0,j={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(j[A.key]){A.preventDefault();const[Y,_]=j[A.key],ne=Math.max(0,Math.min(V-1,U.row+Y)),X=Math.max(0,Math.min(J-1,U.col+_));A.shiftKey?(g.focus={row:ne,col:X},fe()):Se(ne,X);return}if(A.key==="Enter"){A.preventDefault(),We(U.row,U.col);return}if(A.key==="Tab"){A.preventDefault();const Y=(O=(Q=v[0])==null?void 0:Q.length)!=null?O:0;let _=U.row,ne=A.shiftKey?U.col-1:U.col+1;ne<0&&(ne=Y-1,_=Math.max(0,_-1)),ne>=Y&&(ne=0,_=Math.min(v.length-1,_+1)),Se(_,ne);return}if(b&&A.key==="m"&&A.ctrlKey&&!A.shiftKey){A.preventDefault(),z();return}b&&A.key==="M"&&A.ctrlKey&&A.shiftKey&&(A.preventDefault(),N())},k.oncopy=A=>{var Q,O,U,V;const J=Le(g);if(!J)return;A.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 ye=(O=(Q=v[P])==null?void 0:Q[he])!=null?O:"";se.push(ye);const Me=ye.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");me.push(`<td>${Me}</td>`)}X.push(se.join(" ")),W.push(`<tr>${me.join("")}</tr>`)}const ue=X.join(`
804
+ `),ce=`<table>${W.join("")}</table>`;(U=A.clipboardData)==null||U.setData("text/plain",ue),(V=A.clipboardData)==null||V.setData("text/html",ce)},k.onpaste=A=>{var Q,O,U,V,J,j,Y,_,ne;const X=g.anchor;if(!X)return;const W=(O=(Q=A.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(A.preventDefault(),ce){ce.contentEditable="inherit";const de=parseInt((V=(U=ce.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?V:"0",10),Te=parseInt((j=(J=ce.closest("td"))==null?void 0:J.getAttribute("data-col"))!=null?j:"0",10);v[de]&&(v[de][Te]=(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(;v.length<he;)v.push(Array((ne=(_=v[0])==null?void 0:_.length)!=null?ne:1).fill(""));const ye=Math.max(...P.map(de=>de.length)),Me=me+ye;if(v[0]&&Me>v[0].length){const de=Me-v[0].length;v.forEach(Te=>{for(let _e=0;_e<de;_e++)Te.push("")})}for(let de=0;de<P.length;de++)for(let Te=0;Te<P[de].length;Te++){const _e=se+de,al=me+Te;v[_e]&&(v[_e][al]=P[de][Te])}C(),M()}}const I=He({label:"+",title:$("tableAddColumn",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var F;const T=parseInt((F=I.dataset.afterCol)!=null?F:"0",10);Ke(T)}});I.style.position="absolute",I.style.display="none",x.appendChild(I);const H=He({label:"+",title:$("tableAddRow",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var F;const T=parseInt((F=H.dataset.afterRow)!=null?F:"0",10);Ce(T)}});H.style.position="absolute",H.style.display="none",x.appendChild(H);let ee=[],te=[];const ae=He({label:"+",title:$("tableAddColumn",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ke()});ae.style.position="absolute",ae.style.display="none",x.appendChild(ae);const ie=He({label:"+",title:$("tableAddRow",d),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>Ce()});ie.style.position="absolute",ie.style.display="none",x.appendChild(ie);function pe(){var F,T;ee.forEach(O=>O.remove()),ee=[],te.forEach(O=>O.remove()),te=[];const S=v.length>0?v[0].length:0,B=v.length;if(S>1){const O=Array.from(k.querySelectorAll("thead td[data-col]"));for(const U of O){const V=parseInt((F=U.getAttribute("data-col"))!=null?F:"0",10),J=He({label:"\xD7",title:$("tableRemoveColumn",d),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=He({label:"\xD7",title:$("tableRemoveRow",d),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>mt(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 ye=Math.abs(O-se.right);ye<ce&&ye<20&&(ce=ye,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?(I.style.display="flex",I.style.left=`${W-10}px`,I.style.top=`${V.top-U.top-10}px`,I.dataset.afterCol=String(ue)):I.style.display="none"}function A(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 ye=Math.abs(O-se.bottom);if(ye<ce&&ye<14){ce=ye,W=se.bottom-U.top;const Me=_[P].querySelector("td[data-row]");ue=parseInt((Y=Me==null?void 0:Me.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),A(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"}),I.style.display="none",H.style.display="none",ae.style.display="none",ie.style.display="none"}}M()}function Ao(e){var t,n;return{cells:qn((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function At(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Mt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Mo(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=t.prefill[e.key],u=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(a=(l=e.fieldNames)==null?void 0:l.merges)!=null?a:"merges";let d;if(At(p))d={cells:p.cells,merges:p.merges?Re(p.merges):[]};else if(p&&Mt(p,u)){const m=p[f];d={cells:p[u],merges:m?Re(m):[]}}else if(At(e.default))d={cells:e.default.cells,merges:e.default.merges?Re(e.default.merges):[]};else if(e.default&&Mt(e.default,u)){const m=e.default[f];d={cells:e.default[u],merges:m?Re(m):[]}}else d=Ao(e);if(d.merges&&d.merges.length>0){const m=d.cells.length,b=m>0?d.cells[0].length:0,y=Ft(d.merges,m,b);y&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${y})`),d={...d,merges:[]})}c?$o(d,n):Fo(e,d,r,t,n)}function No(e,t,n){var r,o;const{scopeRoot:i,skipValidation:l}=n,a=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",c=i.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:a};let p=null;try{p=JSON.parse(c.value)}catch(u){return a.push(`${t}: invalid table data`),{value:null,errors:a}}if(!l&&e.required){const u=p[s];u!=null&&u.some(f=>f.some(d=>d.trim()!==""))||a.push(`${t}: ${$("required",n.state)}`)}return{value:p,errors:a}}function zo(e,t,n,r){var o,i,l,a;const{scopeRoot:s}=r,c=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",p=(a=(l=e.fieldNames)==null?void 0:l.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 f=null;if(At(n))f={cells:n.cells,merges:n.merges?Re(n.merges):[]};else if(n&&Mt(n,c)){const d=n[p];f={cells:n[c],merges:d?Re(d):[]}}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):u.value=JSON.stringify(n)}function qo(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 Nt(e,t){var n,r,o,i;const l=new Map,a=new Map;for(const s of e){const c=t.resourceIndex.get(s),p=(n=c==null?void 0:c.name)!=null?n:s;a.set(p,((r=a.get(p))!=null?r:0)+1)}for(const s of e){const c=t.resourceIndex.get(s),p=(o=c==null?void 0:c.name)!=null?o:s;((i=a.get(p))!=null?i:1)>1&&c?l.set(s,`${p} (${er(c.size)})`):l.set(s,p)}return l}function zt(e){return e?e.type.startsWith("image/"):!1}function Rn(e,t){const n=Nt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function qt(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function st(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Io(e,t){if(t.size===0)return[];const n=st(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function Ro(e,t){const n=Io(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function Hn(e,t,n){const r=Nt(t,n),o=new Map;for(const s of t){const c=r.get(s);c&&o.set(s,c)}const i=st(e);if(i.length===0)return e;let l="",a=0;for(const s of i){l+=e.slice(a,s.start);const c=o.get(s.name);c?l+=qt(c):l+=s.raw,a=s.end}return l+=e.slice(a),l}function Bn(e,t,n,r){if(be(e),n!=null&&n.file&&zt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var l;if(!i||!e.isConnected)return;const a=document.createElement("img");a.alt=(l=n==null?void 0:n.name)!=null?l:t,a.src=i,a.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",be(e),e.appendChild(a)}).catch(i=>{var l,a;(a=(l=r.config).onThumbnailError)==null||a.call(l,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function Dn(e,t,n,r){if(be(e),n!=null&&n.file&&zt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=l=>{var a;o.src=((a=l.target)==null?void 0:a.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(i=n==null?void 0:n.name)!=null?i:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",be(e),e.appendChild(l)}).catch(o=>{var i,l;(l=(i=r.config).onThumbnailError)==null||l.call(i,o,t)})}function jn(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,l=n.bottom+8,a=i>=4?i:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,a)}px`}function On(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
455
805
  position: fixed;
456
806
  z-index: 99999;
457
807
  background: #fff;
@@ -462,7 +812,7 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
462
812
  pointer-events: none;
463
813
  min-width: 60px;
464
814
  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;",rn(a,t,r,n),o.appendChild(a),document.body.appendChild(o),on(o,e),o}function an(e,t){var n,r;const{rid:o,state:a,isReadonly:l,onMention:i,onRemove:c}=t,s=a.resourceIndex.get(o),f=(n=s==null?void 0:s.name)!=null?n:o,d=document.createElement("div");d.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",d.style.cssText=`
815
+ `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Dn(i,t,r,n),o.appendChild(i),document.body.appendChild(o),jn(o,e),o}function Un(e,t){var n,r;const{rid:o,state:i,isReadonly:l,onMention:a,onRemove:s}=t,c=i.resourceIndex.get(o),p=(n=c==null?void 0:c.name)!=null?n:o,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
466
816
  position: fixed;
467
817
  z-index: 99999;
468
818
  background: #fff;
@@ -473,17 +823,17 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
473
823
  pointer-events: auto;
474
824
  min-width: 80px;
475
825
  max-width: 260px;
476
- `;const p=document.createElement("div");p.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",rn(p,o,s,a),d.appendChild(p);const u=document.createElement("div");u.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);",u.textContent=f,d.appendChild(u);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 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;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},E=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&i){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=v,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",b=>{b.stopPropagation(),i(),d.remove()}),m.appendChild(h)}if(a.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=v,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",b=>{var y,w;b.stopPropagation(),(w=(y=a.config).downloadFile)==null||w.call(y,o,f)}),m.appendChild(h)}if((r=a.config.getDownloadUrl)!=null?r:a.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=v,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",b=>{var y,w,C,x;if(b.stopPropagation(),a.config.getDownloadUrl){const k=a.config.getDownloadUrl(o);k?window.open(k,"_blank"):(w=(y=a.config).getThumbnail)==null||w.call(y,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(C=a.config).getThumbnail)==null||x.call(C,o).then(k=>{k&&window.open(k,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!l&&c){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=v,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",b=>{b.stopPropagation(),d.remove(),c()}),m.appendChild(h)}return m.children.length>0&&d.appendChild(m),document.body.appendChild(d),on(d,e),d}function sn(){return{element:null,hideTimer:null}}function Ye(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function Xe(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function qe(e){return e&&e.remove(),null}function Tr(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let a=r.slice(o+1);return a.startsWith('"')&&(a=a.slice(1)),{query:a,pos:o}}return null}return null}function cn(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var a;return((a=n.get(o))!=null?a:o).toLowerCase().includes(r)})}const Ge="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",un="padding: 12px 52px 12px 14px;";function Ar(e,t,n,r,o){var a;const l=t.state,i=[...o.files],c={open:!1,query:"",triggerPos:-1,selectedIndex:0},s=new AbortController,f=document.createElement("input");f.type="hidden",f.name=r;function d(){var L,q;const M=x.value,N=en(i,l),I=M?Sr(M,N):null,R=(L=e.textKey)!=null?L:"text",te=(q=e.filesKey)!=null?q:"files";return{[R]:M===""?null:I,[te]:[...i]}}function p(){f.value=JSON.stringify(d())}const u=document.createElement("div");u.className="fb-richinput-wrapper",u.style.cssText=`
826
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Dn(f,o,c,i),u.appendChild(f);const d=document.createElement("div");d.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);",d.textContent=p,u.appendChild(d);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;",y=v=>{v.style.background="var(--fb-background-hover-color, #f3f4f6)",v.style.color="var(--fb-text-color, #111827)"},w=v=>{v.style.background="none",v.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&a){const v=document.createElement("button");v.type="button",v.title="Mention",v.style.cssText=b,v.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>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{h.stopPropagation(),a(),u.remove()}),m.appendChild(v)}if(i.config.downloadFile){const v=document.createElement("button");v.type="button",v.title="Download",v.style.cssText=b,v.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>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{var g,E;h.stopPropagation(),(E=(g=i.config).downloadFile)==null||E.call(g,o,p)}),m.appendChild(v)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const v=document.createElement("button");v.type="button",v.title="Open in new window",v.style.cssText=b,v.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>',v.addEventListener("mouseenter",()=>y(v)),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{var g,E,C,x;if(h.stopPropagation(),i.config.getDownloadUrl){const k=i.config.getDownloadUrl(o);k?window.open(k,"_blank"):(E=(g=i.config).getThumbnail)==null||E.call(g,o).then(q=>{q&&window.open(q,"_blank")}).catch(()=>{})}else(x=(C=i.config).getThumbnail)==null||x.call(C,o).then(k=>{k&&window.open(k,"_blank")}).catch(()=>{})}),m.appendChild(v)}if(!l&&s){const v=document.createElement("button");v.type="button",v.title="Remove",v.style.cssText=b,v.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>',v.addEventListener("mouseenter",()=>{v.style.background="var(--fb-background-hover-color, #f3f4f6)",v.style.color="var(--fb-error-color, #ef4444)"}),v.addEventListener("mouseleave",()=>w(v)),v.addEventListener("click",h=>{h.stopPropagation(),u.remove(),s()}),m.appendChild(v)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),jn(u,e),u}function Pn(){return{element:null,hideTimer:null}}function ct(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function ut(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Be(e){return e&&e.remove(),null}function Ho(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function Vn(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const dt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Wn="padding: 12px 52px 12px 14px;";function Bo(e,t,n,r,o){var i;const l=t.state,a=[...o.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,p=document.createElement("input");p.type="hidden",p.name=r;function u(){var L,z;const N=x.value,M=Rn(a,l),I=N?Ro(N,M):null,H=(L=e.textKey)!=null?L:"text",ee=(z=e.filesKey)!=null?z:"files";return{[H]:N===""?null:I,[ee]:[...a]}}function f(){p.value=JSON.stringify(u())}const d=document.createElement("div");d.className="fb-richinput-wrapper",d.style.cssText=`
477
827
  position: relative;
478
828
  border: 1px solid var(--fb-border-color, #d1d5db);
479
829
  border-radius: 16px;
480
830
  background: var(--fb-background-color, #f9fafb);
481
831
  transition: box-shadow 0.15s, border-color 0.15s;
482
- `,u.addEventListener("focusin",()=>{u.style.borderColor="var(--fb-primary-color, #0066cc)",u.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),u.addEventListener("focusout",()=>{u.style.borderColor="var(--fb-border-color, #d1d5db)",u.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 v=null;function g(L){m.textContent=L,m.style.display="block",v&&clearTimeout(v),v=setTimeout(()=>{m.style.display="none",m.textContent="",v=null},5e3)}function E(L){var q;const M=He(e.accept);if(!$e(L.name,M)){const I=M.join(", ");return g($("invalidFileExtension",l,{name:L.name,formats:I})),!1}const N=(q=e.maxSize)!=null?q:1/0;return Ae(L,N)?!0:(g($("fileTooLarge",l,{name:L.name,maxSize:N})),!1)}let h=0;u.addEventListener("dragenter",L=>{L.preventDefault(),h++,u.style.borderColor="var(--fb-primary-color, #0066cc)",u.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),u.addEventListener("dragover",L=>{L.preventDefault()}),u.addEventListener("dragleave",L=>{L.preventDefault(),h--,h<=0&&(h=0,u.style.borderColor="var(--fb-border-color, #d1d5db)",u.style.boxShadow="none")}),u.addEventListener("drop",L=>{var q,M;L.preventDefault(),h=0,u.style.borderColor="var(--fb-border-color, #d1d5db)",u.style.boxShadow="none";const N=(q=L.dataTransfer)==null?void 0:q.files;if(!N||!l.config.uploadFile)return;const I=(M=e.maxFiles)!=null?M:1/0;for(let R=0;R<N.length;R++){if(i.length>=I){g($("filesLimitExceeded",l,{skipped:N.length-R,max:I}));break}E(N[R])&&et(N[R])}});const b=document.createElement("div");b.className="fb-richinput-files",b.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 w=document.createElement("div");w.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
832
+ `,d.addEventListener("focusin",()=>{d.style.borderColor="var(--fb-primary-color, #0066cc)",d.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),d.addEventListener("focusout",()=>{d.style.borderColor="var(--fb-border-color, #d1d5db)",d.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 y(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 z;const N=ke(e.accept);if(!ze(L.name,N)){const I=N.join(", ");return y($("invalidFileExtension",l,{name:L.name,formats:I})),!1}const M=(z=e.maxSize)!=null?z:1/0;return Ge(L,M)?!0:(y($("fileTooLarge",l,{name:L.name,maxSize:M})),!1)}let v=0;d.addEventListener("dragenter",L=>{L.preventDefault(),v++,d.style.borderColor="var(--fb-primary-color, #0066cc)",d.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),d.addEventListener("dragover",L=>{L.preventDefault()}),d.addEventListener("dragleave",L=>{L.preventDefault(),v--,v<=0&&(v=0,d.style.borderColor="var(--fb-border-color, #d1d5db)",d.style.boxShadow="none")}),d.addEventListener("drop",L=>{var z,N;L.preventDefault(),v=0,d.style.borderColor="var(--fb-border-color, #d1d5db)",d.style.boxShadow="none";const M=(z=L.dataTransfer)==null?void 0:z.files;if(!M||!l.config.uploadFile)return;const I=(N=e.maxFiles)!=null?N:1/0;for(let H=0;H<M.length;H++){if(a.length>=I){y($("filesLimitExceeded",l,{skipped:M.length-H,max:I}));break}w(M[H])&&mt(M[H])}});const h=document.createElement("div");h.className="fb-richinput-files",h.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(L=>L.startsWith(".")?L:`.${L}`).join(","));const E=document.createElement("div");E.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
483
833
  position: absolute;
484
834
  top: 0; left: 0; right: 0; bottom: 0;
485
- ${un}
486
- ${Ge}
835
+ ${Wn}
836
+ ${dt}
487
837
  white-space: pre-wrap;
488
838
  word-break: break-word;
489
839
  color: transparent;
@@ -492,10 +842,10 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
492
842
  border-radius: inherit;
493
843
  box-sizing: border-box;
494
844
  z-index: 2;
495
- `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||$("richinputPlaceholder",l);const k=(a=o.text)!=null?a:"";x.value=k?tn(k,i,l):"",x.style.cssText=`
845
+ `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||$("richinputPlaceholder",l);const k=(i=o.text)!=null?i:"";x.value=k?Hn(k,a,l):"",x.style.cssText=`
496
846
  width: 100%;
497
- ${un}
498
- ${Ge}
847
+ ${Wn}
848
+ ${dt}
499
849
  background: transparent;
500
850
  border: none;
501
851
  outline: none;
@@ -505,9 +855,9 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
505
855
  position: relative;
506
856
  z-index: 1;
507
857
  caret-color: var(--fb-text-color, #111827);
508
- `,$r(x,C),x.addEventListener("scroll",()=>{C.scrollTop=x.scrollTop});let z=null;C.addEventListener("mouseover",L=>{var q,M;const N=(M=(q=L.target).closest)==null?void 0:M.call(q,"mark");N!=null&&N.dataset.rid&&(z=qe(z),z=ln(N,N.dataset.rid,l))}),C.addEventListener("mouseout",L=>{var q,M,N;if(!((M=(q=L.target).closest)!=null&&M.call(q,"mark")))return;const I=L.relatedTarget;(N=I==null?void 0:I.closest)!=null&&N.call(I,"mark")||(z=qe(z))}),C.addEventListener("mousedown",L=>{var q,M;if(!((M=(q=L.target).closest)!=null&&M.call(q,"mark")))return;z=qe(z);const N=C.querySelectorAll("mark");N.forEach(R=>R.style.pointerEvents="none");const I=document.elementFromPoint(L.clientX,L.clientY);I&&I.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(R=>R.style.pointerEvents="auto")},{once:!0})});function W(){const L=x.value,q=en(i,l),M=Je(L);if(M.length===0){C.innerHTML=J(L)+`
509
- `;return}let N="",I=0;for(const R of M){N+=J(L.slice(I,R.start));const te=q.get(R.name);te?N+=`<mark data-rid="${J(te)}" 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(L.slice(R.start,R.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(L.slice(R.start,R.end))}</mark>`,I=R.end}N+=J(L.slice(I)),C.innerHTML=N+`
510
- `}const H=document.createElement("button");H.type="button",H.title=$("richinputAttachFile",l),H.style.cssText=`
858
+ `,qo(x,C),x.addEventListener("scroll",()=>{C.scrollTop=x.scrollTop});let q=null;C.addEventListener("mouseover",L=>{var z,N;const M=(N=(z=L.target).closest)==null?void 0:N.call(z,"mark");M!=null&&M.dataset.rid&&(q=Be(q),q=On(M,M.dataset.rid,l))}),C.addEventListener("mouseout",L=>{var z,N,M;if(!((N=(z=L.target).closest)!=null&&N.call(z,"mark")))return;const I=L.relatedTarget;(M=I==null?void 0:I.closest)!=null&&M.call(I,"mark")||(q=Be(q))}),C.addEventListener("mousedown",L=>{var z,N;if(!((N=(z=L.target).closest)!=null&&N.call(z,"mark")))return;q=Be(q);const M=C.querySelectorAll("mark");M.forEach(H=>H.style.pointerEvents="none");const I=document.elementFromPoint(L.clientX,L.clientY);I&&I.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",()=>{M.forEach(H=>H.style.pointerEvents="auto")},{once:!0})});function K(){const L=x.value,z=Rn(a,l),N=st(L);if(N.length===0){C.innerHTML=re(L)+`
859
+ `;return}let M="",I=0;for(const H of N){M+=re(L.slice(I,H.start));const ee=z.get(H.name);ee?M+=`<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>`:M+=`<mark style="color: transparent; background: none; padding: 0; border: none; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: rgba(239, 68, 68, 0.45); text-underline-offset: 2px;">${re(L.slice(H.start,H.end))}</mark>`,I=H.end}M+=re(L.slice(I)),C.innerHTML=M+`
860
+ `}const R=document.createElement("button");R.type="button",R.title=$("richinputAttachFile",l),R.style.cssText=`
511
861
  position: absolute;
512
862
  right: 10px;
513
863
  bottom: 10px;
@@ -523,7 +873,7 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
523
873
  justify-content: center;
524
874
  color: var(--fb-text-muted-color, #9ca3af);
525
875
  transition: color 0.15s, background 0.15s;
526
- `,H.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>',H.addEventListener("mouseenter",()=>{H.style.color="var(--fb-primary-color, #0066cc)",H.style.background="var(--fb-background-hover-color, #f3f4f6)"}),H.addEventListener("mouseleave",()=>{H.style.color="var(--fb-text-muted-color, #9ca3af)",H.style.background="transparent"}),H.addEventListener("click",()=>{var L;const q=(L=e.maxFiles)!=null?L:1/0;if(i.length>=q){g($("filesLimitExceeded",l,{skipped:1,max:q}));return}y.click()});const Z=document.createElement("div");Z.className="fb-richinput-dropdown",Z.style.cssText=`
876
+ `,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 L;const z=(L=e.maxFiles)!=null?L:1/0;if(a.length>=z){y($("filesLimitExceeded",l,{skipped:1,max:z}));return}g.click()});const G=document.createElement("div");G.className="fb-richinput-dropdown",G.style.cssText=`
527
877
  display: none;
528
878
  position: absolute;
529
879
  bottom: 100%;
@@ -538,16 +888,16 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
538
888
  max-height: 200px;
539
889
  overflow-y: auto;
540
890
  margin-bottom: 4px;
541
- ${Ge}
542
- `;function Q(){return ht(i,l)}function oe(L){ve(Z);const q=Q();if(L.length===0){Z.style.display="none",c.open=!1;return}L.forEach((M,N)=>{var I;const R=l.resourceIndex.get(M),te=document.createElement("div");te.className="fb-richinput-dropdown-item",te.dataset.rid=M,te.style.cssText=`
891
+ ${dt}
892
+ `;function Z(){return Nt(a,l)}function oe(L){be(G);const z=Z();if(L.length===0){G.style.display="none",s.open=!1;return}L.forEach((N,M)=>{var I;const H=l.resourceIndex.get(N),ee=document.createElement("div");ee.className="fb-richinput-dropdown-item",ee.dataset.rid=N,ee.style.cssText=`
543
893
  padding: 5px 10px;
544
894
  cursor: pointer;
545
895
  color: var(--fb-text-color, #111827);
546
- background: ${N===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
896
+ background: ${M===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
547
897
  display: flex;
548
898
  align-items: center;
549
899
  gap: 8px;
550
- `;const ne=document.createElement("div");if(ne.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;",R!=null&&R.file&&vt(R)){const ae=document.createElement("img");ae.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const fe=new FileReader;fe.onload=A=>{var T;ae.src=((T=A.target)==null?void 0:T.result)||""},fe.readAsDataURL(R.file),ne.appendChild(ae)}else l.config.getThumbnail&&l.config.getThumbnail(M).then(ae=>{if(!ae||!ne.isConnected)return;const fe=document.createElement("img");fe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",fe.src=ae,ve(ne),ne.appendChild(fe)}).catch(()=>{}),ne.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>';te.appendChild(ne);const ie=document.createElement("span");ie.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ie.textContent=(I=q.get(M))!=null?I:M,te.appendChild(ie),Z.appendChild(te)}),Z.onmousemove=M=>{var N,I,R;const te=(I=(N=M.target).closest)==null?void 0:I.call(N,".fb-richinput-dropdown-item");if(!te)return;const ne=L.indexOf((R=te.dataset.rid)!=null?R:"");ne===-1||ne===c.selectedIndex||(Z.querySelectorAll(".fb-richinput-dropdown-item").forEach((ie,ae)=>{ie.style.background=ae===ne?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),c.selectedIndex=ne)},Z.onmousedown=M=>{var N,I;M.preventDefault(),M.stopPropagation();const R=(I=(N=M.target).closest)==null?void 0:I.call(N,".fb-richinput-dropdown-item");R!=null&&R.dataset.rid&&we(R.dataset.rid)},Z.style.display="block",c.open=!0}function Le(){const L=Tr(x);if(!L){pe();return}c.query=L.query,c.triggerPos=L.pos,c.selectedIndex=0;const q=Q(),M=cn(L.query,i,q);oe(M)}function pe(){Z.style.display="none",c.open=!1}function we(L){var q,M,N,I;const R=(N=(M=Q().get(L))!=null?M:(q=l.resourceIndex.get(L))==null?void 0:q.name)!=null?N:L,te=(I=x.selectionStart)!=null?I:0,ne=x.value.slice(0,c.triggerPos),ie=x.value.slice(te),ae=`${gt(R)} `;x.value=`${ne}${ae}${ie}`;const fe=ne.length+ae.length;x.setSelectionRange(fe,fe),x.dispatchEvent(new Event("input")),pe()}x.addEventListener("input",()=>{var L;W(),p(),(L=t.instance)==null||L.triggerOnChange(r,d()),i.length>0?Le():pe()});function Be(){Z.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,q)=>{L.style.background=q===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",L=>{if(!c.open)return;const q=Q(),M=cn(c.query,i,q);L.key==="ArrowDown"?(L.preventDefault(),c.selectedIndex=Math.min(c.selectedIndex+1,M.length-1),Be()):L.key==="ArrowUp"?(L.preventDefault(),c.selectedIndex=Math.max(c.selectedIndex-1,0),Be()):L.key==="Enter"&&M.length>0?(L.preventDefault(),we(M[c.selectedIndex])):L.key==="Escape"&&pe()}),document.addEventListener("click",L=>{!u.contains(L.target)&&!Z.contains(L.target)&&pe()},{signal:s.signal});function xe(){if(ve(b),i.length===0){b.style.display="none";return}b.style.display="flex",i.forEach(L=>{const q=l.resourceIndex.get(L),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
900
+ `;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&&zt(H)){const ie=document.createElement("img");ie.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const pe=new FileReader;pe.onload=F=>{var T;ie.src=((T=F.target)==null?void 0:T.result)||""},pe.readAsDataURL(H.file),te.appendChild(ie)}else l.config.getThumbnail&&l.config.getThumbnail(N).then(ie=>{if(!ie||!te.isConnected)return;const pe=document.createElement("img");pe.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",pe.src=ie,be(te),te.appendChild(pe)}).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=(I=z.get(N))!=null?I:N,ee.appendChild(ae),G.appendChild(ee)}),G.onmousemove=N=>{var M,I,H;const ee=(I=(M=N.target).closest)==null?void 0:I.call(M,".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=N=>{var M,I;N.preventDefault(),N.stopPropagation();const H=(I=(M=N.target).closest)==null?void 0:I.call(M,".fb-richinput-dropdown-item");H!=null&&H.dataset.rid&&Se(H.dataset.rid)},G.style.display="block",s.open=!0}function Ae(){const L=Ho(x);if(!L){fe();return}s.query=L.query,s.triggerPos=L.pos,s.selectedIndex=0;const z=Z(),N=Vn(L.query,a,z);oe(N)}function fe(){G.style.display="none",s.open=!1}function Se(L){var z,N,M,I;const H=(M=(N=Z().get(L))!=null?N:(z=l.resourceIndex.get(L))==null?void 0:z.name)!=null?M:L,ee=(I=x.selectionStart)!=null?I:0,te=x.value.slice(0,s.triggerPos),ae=x.value.slice(ee),ie=`${qt(H)} `;x.value=`${te}${ie}${ae}`;const pe=te.length+ie.length;x.setSelectionRange(pe,pe),x.dispatchEvent(new Event("input")),fe()}x.addEventListener("input",()=>{var L;K(),f(),(L=t.instance)==null||L.triggerOnChange(r,u()),a.length>0?Ae():fe()});function We(){G.querySelectorAll(".fb-richinput-dropdown-item").forEach((L,z)=>{L.style.background=z===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",L=>{if(!s.open)return;const z=Z(),N=Vn(s.query,a,z);L.key==="ArrowDown"?(L.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,N.length-1),We()):L.key==="ArrowUp"?(L.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),We()):L.key==="Enter"&&N.length>0?(L.preventDefault(),Se(N[s.selectedIndex])):L.key==="Escape"&&fe()}),document.addEventListener("click",L=>{!d.contains(L.target)&&!G.contains(L.target)&&fe()},{signal:c.signal});function Ce(){if(be(h),a.length===0){h.style.display="none";return}h.style.display="flex",a.forEach(L=>{const z=l.resourceIndex.get(L),N=document.createElement("div");N.className="fb-richinput-file-thumb",N.style.cssText=`
551
901
  position: relative;
552
902
  width: 48px;
553
903
  height: 48px;
@@ -557,14 +907,14 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
557
907
  flex-shrink: 0;
558
908
  cursor: pointer;
559
909
  background: #fff;
560
- `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",nn(N,L,q,l),M.appendChild(N);const I=sn(),R=()=>{var ne,ie,ae;const fe=(ne=x.selectionStart)!=null?ne:x.value.length,A=(ae=(ie=Q().get(L))!=null?ie:q==null?void 0:q.name)!=null?ae:L,T=x.value.slice(0,fe),S=x.value.slice(fe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
561
- `:""}${gt(A)} `;x.value=`${T}${B}${S}`;const D=fe+B.length;x.setSelectionRange(D,D),x.focus(),x.dispatchEvent(new Event("input"))},te=()=>{var ne;const ie=i.indexOf(L);ie!==-1&&i.splice(ie,1),xe(),W(),p(),(ne=t.instance)==null||ne.triggerOnChange(r,d())};M.addEventListener("mouseenter",()=>{Xe(I),I.element||(I.element=an(M,{rid:L,state:l,isReadonly:!1,onMention:R,onRemove:te}),I.element.addEventListener("mouseenter",()=>{Xe(I)}),I.element.addEventListener("mouseleave",()=>{Ye(I)}))}),M.addEventListener("mouseleave",()=>{Ye(I)}),b.appendChild(M)})}function et(L){if(!l.config.uploadFile)return;const q=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(q,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),i.push(q),xe();const M=b.querySelectorAll(".fb-richinput-file-thumb"),N=M[M.length-1];N&&(N.style.opacity="0.5"),l.config.uploadFile(L).then(I=>{var R;const te=i.indexOf(q);te!==-1&&(i[te]=I),l.resourceIndex.delete(q),l.resourceIndex.set(I,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),xe(),W(),p(),(R=t.instance)==null||R.triggerOnChange(r,d())}).catch(I=>{var R,te;const ne=i.indexOf(q);ne!==-1&&i.splice(ne,1),l.resourceIndex.delete(q),xe(),(te=(R=l.config).onUploadError)==null||te.call(R,I,L)})}if(y.addEventListener("change",()=>{var L;const q=y.files;if(!q||q.length===0)return;const M=(L=e.maxFiles)!=null?L:1/0;for(let N=0;N<q.length;N++){if(i.length>=M){g($("filesLimitExceeded",l,{skipped:q.length-N,max:M}));break}E(q[N])&&et(q[N])}y.value=""}),w.appendChild(C),w.appendChild(x),w.appendChild(H),w.appendChild(Z),u.appendChild(b),u.appendChild(w),u.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 q=Ie(e,x,!1);q.style.cssText=`
910
+ `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Bn(M,L,z,l),N.appendChild(M);const I=Pn(),H=()=>{var te,ae,ie;const pe=(te=x.selectionStart)!=null?te:x.value.length,F=(ie=(ae=Z().get(L))!=null?ae:z==null?void 0:z.name)!=null?ie:L,T=x.value.slice(0,pe),S=x.value.slice(pe),B=`${T.length>0&&!/[\s\n]$/.test(T)?`
911
+ `:""}${qt(F)} `;x.value=`${T}${B}${S}`;const D=pe+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),Ce(),K(),f(),(te=t.instance)==null||te.triggerOnChange(r,u())};N.addEventListener("mouseenter",()=>{ut(I),I.element||(I.element=Un(N,{rid:L,state:l,isReadonly:!1,onMention:H,onRemove:ee}),I.element.addEventListener("mouseenter",()=>{ut(I)}),I.element.addEventListener("mouseleave",()=>{ct(I)}))}),N.addEventListener("mouseleave",()=>{ct(I)}),h.appendChild(N)})}function mt(L){if(!l.config.uploadFile)return;const z=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(z,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),a.push(z),Ce();const N=h.querySelectorAll(".fb-richinput-file-thumb"),M=N[N.length-1];M&&(M.style.opacity="0.5"),l.config.uploadFile(L).then(I=>{var H;const ee=a.indexOf(z);ee!==-1&&(a[ee]=I),l.resourceIndex.delete(z),l.resourceIndex.set(I,{name:L.name,type:L.type,size:L.size,uploadedAt:new Date,file:L}),Ce(),K(),f(),(H=t.instance)==null||H.triggerOnChange(r,u())}).catch(I=>{var H,ee;const te=a.indexOf(z);te!==-1&&a.splice(te,1),l.resourceIndex.delete(z),Ce(),(ee=(H=l.config).onUploadError)==null||ee.call(H,I,L)})}if(g.addEventListener("change",()=>{var L;const z=g.files;if(!z||z.length===0)return;const N=(L=e.maxFiles)!=null?L:1/0;for(let M=0;M<z.length;M++){if(a.length>=N){y($("filesLimitExceeded",l,{skipped:z.length-M,max:N}));break}w(z[M])&&mt(z[M])}g.value=""}),E.appendChild(C),E.appendChild(x),E.appendChild(R),E.appendChild(G),d.appendChild(h),d.appendChild(E),d.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 z=je(e,x,!1);z.style.cssText=`
562
912
  position: static;
563
913
  display: inline-block;
564
914
  font-size: var(--fb-font-size-small);
565
915
  color: var(--fb-text-secondary-color);
566
916
  pointer-events: none;
567
- `,L.appendChild(q),u.appendChild(L)}u.appendChild(f),u.appendChild(y),p(),W(),f._applyExternalUpdate=L=>{var q;const M=(q=L.text)!=null?q:"";x.value=M?tn(M,i,l):"",x.dispatchEvent(new Event("input")),i.length=0;for(const N of L.files)i.push(N);xe(),W(),p()},n.appendChild(u),xe();const De=new MutationObserver(()=>{u.isConnected||(s.abort(),z=qe(z),De.disconnect())});u.parentElement&&De.observe(u.parentElement,{childList:!0})}function Fr(e,t,n,r,o){var a,l;const i=t.state,{text:c,files:s}=o,f=new Map;for(const d of s){const p=i.resourceIndex.get(d);p!=null&&p.name&&f.set(d,p.name)}if(s.length>0){const d=document.createElement("div");d.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(p=>{const u=i.resourceIndex.get(p),m=document.createElement("div");m.style.cssText=`
917
+ `,L.appendChild(z),d.appendChild(L)}d.appendChild(p),d.appendChild(g),f(),K(),p._applyExternalUpdate=L=>{var z;const N=(z=L.text)!=null?z:"";x.value=N?Hn(N,a,l):"",x.dispatchEvent(new Event("input")),a.length=0;for(const M of L.files)a.push(M);Ce(),K(),f()},n.appendChild(d),Ce();const Ke=new MutationObserver(()=>{d.isConnected||(c.abort(),q=Be(q),Ke.disconnect())});d.parentElement&&Ke.observe(d.parentElement,{childList:!0})}function Do(e,t,n,r,o){var i,l;const a=t.state,{text:s,files:c}=o,p=new Map;for(const u of c){const f=a.resourceIndex.get(u);f!=null&&f.name&&p.set(u,f.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(f=>{const d=a.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
568
918
  position: relative;
569
919
  width: 48px; height: 48px;
570
920
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -573,12 +923,12 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
573
923
  flex-shrink: 0;
574
924
  background: #fff;
575
925
  cursor: default;
576
- `;const v=document.createElement("div");v.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",nn(v,p,u,i),m.appendChild(v);const g=sn();m.addEventListener("mouseenter",()=>{Xe(g),g.element||(g.element=an(m,{rid:p,state:i,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{Xe(g)}),g.element.addEventListener("mouseleave",()=>{Ye(g)}))}),m.addEventListener("mouseleave",()=>{Ye(g)}),d.appendChild(m)}),n.appendChild(d)}if(c){const d=document.createElement("div");d.style.cssText=`
577
- ${Ge}
926
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Bn(b,f,d,a),m.appendChild(b);const y=Pn();m.addEventListener("mouseenter",()=>{ut(y),y.element||(y.element=Un(m,{rid:f,state:a,isReadonly:!0}),y.element.addEventListener("mouseenter",()=>{ut(y)}),y.element.addEventListener("mouseleave",()=>{ct(y)}))}),m.addEventListener("mouseleave",()=>{ct(y)}),u.appendChild(m)}),n.appendChild(u)}if(s){const u=document.createElement("div");u.style.cssText=`
927
+ ${dt}
578
928
  color: var(--fb-text-color, #111827);
579
929
  white-space: pre-wrap;
580
930
  word-break: break-word;
581
- `;const p=Je(c).filter(u=>f.has(u.name)||[...f.values()].includes(u.name));if(p.length===0)d.textContent=c;else{let u=0;for(const m of p){m.start>u&&d.appendChild(document.createTextNode(c.slice(u,m.start)));const v=document.createElement("span");v.style.cssText=`
931
+ `;const f=st(s).filter(d=>p.has(d.name)||[...p.values()].includes(d.name));if(f.length===0)u.textContent=s;else{let d=0;for(const m of f){m.start>d&&u.appendChild(document.createTextNode(s.slice(d,m.start)));const b=document.createElement("span");b.style.cssText=`
582
932
  display: inline;
583
933
  background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
584
934
  color: var(--fb-primary-color, #0066cc);
@@ -586,12 +936,12 @@ var FormBuilder=(function(Ee){"use strict";function $(e,t,n){const r=t.config.lo
586
936
  padding: 1px 6px;
587
937
  font-weight: 500;
588
938
  cursor: default;
589
- `;const g=f.has(m.name)?m.name:(a=[...f.entries()].find(([,h])=>h===m.name))==null?void 0:a[0],E=(l=f.get(m.name))!=null?l:m.name;if(v.textContent=`@${E}`,g){let h=null;const b=g;v.addEventListener("mouseenter",()=>{h=qe(h),h=ln(v,b,i)}),v.addEventListener("mouseleave",()=>{h=qe(h)})}d.appendChild(v),u=m.end}u<c.length&&d.appendChild(document.createTextNode(c.slice(u)))}n.appendChild(d)}if(!c&&s.length===0){const d=document.createElement("div");d.style.cssText="color: var(--fb-text-muted-color, #6b7280); font-size: var(--fb-font-size, 14px);",d.textContent="\u2014",n.appendChild(d)}}function Nr(e,t,n,r){var o,a,l,i;const c=t.state,s=le(e,c,t),f=(o=e.textKey)!=null?o:"text",d=(a=e.filesKey)!=null?a:"files";let p;if(e.flatOutput){const u=t.prefill[f],m=t.prefill[d];p={text:typeof u=="string"?u:null,files:Array.isArray(m)?m:[]}}else{const u=t.prefill[e.key];if(u&&typeof u=="object"&&!Array.isArray(u)){const m=u,v=(l=m[f])!=null?l:m.text,g=(i=m[d])!=null?i:m.files;p={text:typeof v=="string"?v:null,files:Array.isArray(g)?g:[]}}else typeof u=="string"?p={text:u||null,files:[]}:p={text:null,files:[]}}for(const u of p.files)c.resourceIndex.has(u)||c.resourceIndex.set(u,{name:u,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)Fr(e,t,n,r,p);else{if(!c.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ar(e,t,n,r,p)}}function Mr(e,t,n){var r,o;const{scopeRoot:a,state:l,skipValidation:i}=n,c=[],s=(r=e.textKey)!=null?r:"text",f=(o=e.filesKey)!=null?o:"files",d=a.querySelector(`[name="${t}"]`);if(!d)return{value:null,errors:c};let p={};try{const h=JSON.parse(d.value);if(h&&typeof h=="object"&&!Array.isArray(h))p=h;else return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}catch(h){return c.push(`${t}: invalid richinput data`),{value:null,errors:c}}const u=p[s],m=p[f],v=u===null||typeof u=="string"?u:null,g=Array.isArray(m)?m:[],E={[s]:v!=null?v:null,[f]:g};if(!i){const h=!v||v.trim()==="",b=g.length===0;e.required&&h&&b&&c.push(`${t}: ${$("required",l)}`),!h&&v&&(e.minLength!=null&&v.length<e.minLength&&c.push(`${t}: ${$("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&v.length>e.maxLength&&c.push(`${t}: ${$("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&c.push(`${t}: ${$("maxFiles",l,{max:e.maxFiles})}`)}return{value:E,errors:c,spread:!!e.flatOutput}}function qr(e,t,n,r){var o,a,l,i;const{scopeRoot:c}=r,s=c.querySelector(`[name="${t}"]`);if(!s){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 d=n,p=(o=e.textKey)!=null?o:"text",u=(a=e.filesKey)!=null?a:"files",m=(l=d[p])!=null?l:d.text,v=(i=d[u])!=null?i:d.files;(m!==void 0||v!==void 0)&&(f={text:typeof m=="string"?m:null,files:Array.isArray(v)?v:[]})}f&&s._applyExternalUpdate?s._applyExternalUpdate(f):f&&(s.value=JSON.stringify(f))}function zr(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 o=t.getBoundingClientRect(),a=window.innerWidth,l=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const i=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let c=o.left,s=o.bottom+5;c+i.width>a&&(c=o.right-i.width),s+i.height>l&&(s=o.top-i.height-5),c<10&&(c=10),s<10&&(s=o.bottom+5),n.style.left=`${c}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function Ir(e,t){var n,r,o;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},l=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!Te(e.enableIf,a,l)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Hr(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 Ze(e,t,n){var r,o;if(!t.enableIf)return;const a=n.state.formRoot;if(!a){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const l=t.enableIf,i=(r=l.scope)!=null?r:"relative";let c={};const s={};if((!n.path||n.path===""?"absolute":i)==="relative"&&n.path){const f=n.path.match(/^(.+)\[(\d+)\]$/);if(f){const d=f[1],p=parseInt(f[2],10),u=a.querySelector(`[data-container-item="${d}[${p}]"]`);u&&u.querySelectorAll("input, select, textarea").forEach(m=>{const v=m.getAttribute("name");if(v){const g=v.match(/\.([^.[\]]+)$/);if(g){const E=g[1];m instanceof HTMLSelectElement?s[E]=m.value:m instanceof HTMLInputElement?m.type==="checkbox"?s[E]=m.checked:m.type==="radio"?m.checked&&(s[E]=m.value):s[E]=m.value:m instanceof HTMLTextAreaElement&&(s[E]=m.value)}}})}}else{const f=l.key,d=Hr(f,a);d!==void 0?c[f]=d:c=(o=n.formData)!=null?o:n.prefill}try{Te(l,c,s)?(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 Rr(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const a=t.enableIf,l=(r=a.scope)!=null?r:"relative",i=a.key;let c;l==="relative"&&n.path?c=`${n.path}.${i}`:c=i;const s=o.querySelector(`[name="${c}"]`);if(!s){const f=new MutationObserver(()=>{const d=o.querySelector(`[name="${c}"]`);d&&(d.addEventListener("change",()=>{Ze(e,t,n)}),d.addEventListener("input",()=>{Ze(e,t,n)}),f.disconnect())});f.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{Ze(e,t,n)}),s.addEventListener("input",()=>{Ze(e,t,n)})}function Br(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 Dr(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),zr(n,t)},t}function jr(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=Br(e);if(t.appendChild(n),e.description||e.hint){const r=Dr(e);t.appendChild(r)}return t}function Or(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Cn(e,t,n,r):En(e,t,n,r);break;case"textarea":o?kn(e,t,n,r):wn(e,t,n,r);break;case"number":o?Tn(e,t,n,r):Sn(e,t,n,r);break;case"select":o?Mn(e,t,n,r):Nn(e,t,n,r);break;case"switcher":o?Hn(e,t,n,r):In(e,t,n,r);break;case"file":o?Qn(e,t,n,r):Gn(e,t,n,r);break;case"files":Zn(e,t,n,r);break;case"colour":o?tr(e,t,n,r):er(e,t,n,r);break;case"slider":o?lr(e,t,n,r):or(e,t,n,r);break;case"group":ur(e,t,n,r);break;case"container":o?_t(e,t,n):Wt(e,t,n,r);break;case"table":Cr(e,t,n,r);break;case"richinput":Nr(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=$("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function bt(e,t){const n=Ir(e,t),r=document.createElement("div");r.className="mb-6 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=jr(e);r.appendChild(o);const a=ye(t.path,e.key);return Or(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Rr(r,e,t),r}sr(bt);const yt={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 Ur(e){const t={...yt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...yt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...yt,...e,translations:t},debounceTimer:null,prefill:{}}}function Pr(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Re={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 Vr(e){const t={...Re,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const a=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${a}: ${o};`)}),n.join(`
590
- `)}function Kr(e,t){const n=Vr(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=`
939
+ `;const y=p.has(m.name)?m.name:(i=[...p.entries()].find(([,v])=>v===m.name))==null?void 0:i[0],w=(l=p.get(m.name))!=null?l:m.name;if(b.textContent=`@${w}`,y){let v=null;const h=y;b.addEventListener("mouseenter",()=>{v=Be(v),v=On(b,h,a)}),b.addEventListener("mouseleave",()=>{v=Be(v)})}u.appendChild(b),d=m.end}d<s.length&&u.appendChild(document.createTextNode(s.slice(d)))}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 jo(e,t,n,r){var o,i,l,a;const s=t.state,c=le(e,s,t),p=(o=e.textKey)!=null?o:"text",u=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const d=t.prefill[p],m=t.prefill[u];f={text:typeof d=="string"?d:null,files:Array.isArray(m)?m:[]}}else{const d=t.prefill[e.key];if(d&&typeof d=="object"&&!Array.isArray(d)){const m=d,b=(l=m[p])!=null?l:m.text,y=(a=m[u])!=null?a:m.files;f={text:typeof b=="string"?b:null,files:Array.isArray(y)?y:[]}}else typeof d=="string"?f={text:d||null,files:[]}:f={text:null,files:[]}}for(const d of f.files)s.resourceIndex.has(d)||s.resourceIndex.set(d,{name:d,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(c)Do(e,t,n,r,f);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Bo(e,t,n,r,f)}}function Oo(e,t,n){var r,o;const{scopeRoot:i,state:l,skipValidation:a}=n,s=[],c=(r=e.textKey)!=null?r:"text",p=(o=e.filesKey)!=null?o:"files",u=i.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let f={};try{const v=JSON.parse(u.value);if(v&&typeof v=="object"&&!Array.isArray(v))f=v;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(v){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const d=f[c],m=f[p],b=d===null||typeof d=="string"?d:null,y=Array.isArray(m)?m:[],w={[c]:b!=null?b:null,[p]:y};if(!a){const v=!b||b.trim()==="",h=y.length===0;e.required&&v&&h&&s.push(`${t}: ${$("required",l)}`),!v&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${$("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${$("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&y.length>e.maxFiles&&s.push(`${t}: ${$("maxFiles",l,{max:e.maxFiles})}`)}return{value:w,errors:s,spread:!!e.flatOutput}}function Uo(e,t,n,r){var o,i,l,a;const{scopeRoot:s}=r,c=s.querySelector(`[name="${t}"]`);if(!c){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let p=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,f=(o=e.textKey)!=null?o:"text",d=(i=e.filesKey)!=null?i:"files",m=(l=u[f])!=null?l:u.text,b=(a=u[d])!=null?a:u.files;(m!==void 0||b!==void 0)&&(p={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}p&&c._applyExternalUpdate?c._applyExternalUpdate(p):p&&(c.value=JSON.stringify(p))}function Po(e,t){const n=document.getElementById(e);if(!n)return;const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(p=>{p.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),i=window.innerWidth,l=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=o.left,c=o.bottom+5;s+a.width>i&&(s=o.right-a.width),c+a.height>l&&(c=o.top-a.height-5),s<10&&(s=10),c<10&&(c=o.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,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function Vo(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},l=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!Ne(e.enableIf,i,l)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function Wo(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 ft(e,t,n){var r,o;if(!t.enableIf)return;const i=n.state.formRoot;if(!i){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const l=t.enableIf,a=(r=l.scope)!=null?r:"relative";let s={};const c={};if((!n.path||n.path===""?"absolute":a)==="relative"&&n.path){const p=n.path.match(/^(.+)\[(\d+)\]$/);if(p){const u=p[1],f=parseInt(p[2],10),d=i.querySelector(`[data-container-item="${u}[${f}]"]`);d&&d.querySelectorAll("input, select, textarea").forEach(m=>{const b=m.getAttribute("name");if(b){const y=b.match(/\.([^.[\]]+)$/);if(y){const w=y[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 p=l.key,u=Wo(p,i);u!==void 0?s[p]=u:s=(o=n.formData)!=null?o:n.prefill}try{Ne(l,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(p){console.error(`Error re-evaluating enableIf for field "${t.key}":`,p)}}function Ko(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,l=(r=i.scope)!=null?r:"relative",a=i.key;let s;l==="relative"&&n.path?s=`${n.path}.${a}`:s=a;const c=o.querySelector(`[name="${s}"]`);if(!c){const p=new MutationObserver(()=>{const u=o.querySelector(`[name="${s}"]`);u&&(u.addEventListener("change",()=>{ft(e,t,n)}),u.addEventListener("input",()=>{ft(e,t,n)}),p.disconnect())});p.observe(o,{childList:!0,subtree:!0});return}c.addEventListener("change",()=>{ft(e,t,n)}),c.addEventListener("input",()=>{ft(e,t,n)})}function _o(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 Jo(e){const t=document.createElement("button");t.type="button",t.className="ml-2 text-gray-400 hover:text-gray-600",t.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const n=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,r=document.createElement("div");return r.id=n,r.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",r.style.position="fixed",r.textContent=e.description||e.hint||"Field information",document.body.appendChild(r),t.onclick=o=>{o.preventDefault(),o.stopPropagation(),Po(n,t)},t}function Yo(e){const t=document.createElement("div");t.className="flex items-center mb-2";const n=_o(e);if(t.appendChild(n),e.description||e.hint){const r=Jo(e);t.appendChild(r)}return t}function Xo(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?rr(e,t,n,r):nr(e,t,n,r);break;case"textarea":o?lr(e,t,n,r):or(e,t,n,r);break;case"number":o?cr(e,t,n,r):sr(e,t,n,r);break;case"select":o?pr(e,t,n,r):fr(e,t,n,r);break;case"switcher":o?br(e,t,n,r):vr(e,t,n,r);break;case"file":o?ao(e,t,n,r):lo(e,t,n,r);break;case"files":io(e,t,n,r);break;case"colour":o?co(e,t,n,r):so(e,t,n,r);break;case"slider":o?mo(e,t,n,r):po(e,t,n,r);break;case"group":yo(e,t,n,r);break;case"container":o?Fn(e,t,n):Tn(e,t,n,r);break;case"table":Mo(e,t,n,r);break;case"richinput":jo(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=$("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function It(e,t){const n=Vo(e,t),r=document.createElement("div");r.className="mb-6 fb-field-wrapper",r.setAttribute("data-field-key",e.key);const o=Yo(e);r.appendChild(o);const i=xe(t.path,e.key);return Xo(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Ko(r,e,t),r}bo(It);const Rt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountSingle:"{count} file",fileCountPlural:"{count} files",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',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}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',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 Go(e){const t={...Rt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Rt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Rt,...e,translations:t},debounceTimer:null,prefill:{}}}function Zo(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ve={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 Qo(e){const t={...Ve,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
940
+ `)}function el(e,t){const n=Qo(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=`
591
941
  [data-fb-root="true"] {
592
942
  ${n}
593
943
  }
594
- `}const Wr={default:Re,dark:{...Re,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:{...Re,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 dn(e,t=!1){e.style.cssText=`
944
+ `}const tl={default:Ve,dark:{...Ve,primaryColor:"#60a5fa",primaryHoverColor:"#3b82f6",borderColor:"#4b5563",borderHoverColor:"#6b7280",borderFocusColor:"#60a5fa",backgroundColor:"#1f2937",backgroundHoverColor:"#374151",backgroundReadonlyColor:"#111827",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",textPlaceholderColor:"#6b7280",fileUploadBgColor:"#374151",fileUploadBorderColor:"#4b5563",fileUploadTextColor:"#9ca3af"},klein:{...Ve,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'}};function Kn(e,t=!1){e.style.cssText=`
595
945
  background-color: var(--fb-action-bg-color);
596
946
  color: var(--fb-action-text-color);
597
947
  border: var(--fb-border-width) solid var(--fb-action-border-color);
@@ -601,6 +951,6 @@ ${n}
601
951
  border-radius: var(--fb-border-radius);
602
952
  transition: all var(--fb-transition-duration);
603
953
  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 _r(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),l=(r=a==null?void 0:a.value)!=null?r:"";if(l===""){const i="default"in e?e.default:null;return{value:i!==void 0?i:null,errors:[]}}return{value:Et(l),errors:[]}}function Jr(e,t,n,r){const{scopeRoot:o}=r,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=xt(n))}const Yr={text:{validate:Ct,update:wt},textarea:{validate:$n,update:Ln},number:{validate:An,update:Fn},select:{validate:qn,update:zn},switcher:{validate:Rn,update:Bn},file:{validate:Ht,update:Rt},files:{validate:Ht,update:Rt},colour:{validate:nr,update:rr},slider:{validate:ar,update:ir},container:{validate:Yt,update:Xt},group:{validate:dr,update:pr},table:{validate:wr,update:kr},richinput:{validate:Mr,update:qr},hidden:{validate:_r,update:Jr}};function pn(e){return Yr[e]||null}function Xr(e,t,n){const r=pn(e.type);return r&&r.validate?r.validate(e,t,n):null}function Gr(e,t,n,r){const o=pn(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}class Qe{constructor(t){this.instanceId=Pr(),this.state=Ur(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 o=this.state.formRoot.querySelector(`[name="${t}"]`);if(o)return o;const a=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const l of a)if(o=this.state.formRoot.querySelector(`[name="${l}"]`),o)return o}const n=this.findSchemaElement(t);if(!n)return null;const r=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const o of r){const a=n.label||n.key,l=o.querySelector("label");if(l&&(l.textContent===a||l.textContent===`${a}*`)){let i=o.querySelector(".field-placeholder");return i||(i=document.createElement("div"),i.className="field-placeholder",i.style.display="none",o.appendChild(i)),i}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const a of o){if(r=n.find(l=>l.key===a)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const a=r.actions.find(l=>l.key===t);if(a&&a.label)return a.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const a=this.state.schema.actions.find(l=>l.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 o=document.createElement("div");o.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",o.style.cssText=`
954
+ `,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 nl(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),l=(r=i==null?void 0:i.value)!=null?r:"";if(l===""){const a="default"in e?e.default:null;return{value:a!==void 0?a:null,errors:[]}}return{value:Bt(l),errors:[]}}function rl(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Ht(n))}const ol={text:{validate:Dt,update:jt},textarea:{validate:ir,update:ar},number:{validate:ur,update:dr},select:{validate:mr,update:hr},switcher:{validate:gr,update:yr},file:{validate:vn,update:yn},files:{validate:vn,update:yn},colour:{validate:uo,update:fo},slider:{validate:ho,update:vo},container:{validate:Mn,update:Nn},group:{validate:xo,update:Eo},table:{validate:No,update:zo},richinput:{validate:Oo,update:Uo},hidden:{validate:nl,update:rl}};function _n(e){return ol[e]||null}function ll(e,t,n){const r=_n(e.type);return r&&r.validate?r.validate(e,t,n):null}function il(e,t,n,r){const o=_n(e.type);return o&&o.update?(o.update(e,t,n,r),!0):!1}class pt{constructor(t){this.instanceId=Zo(),this.state=Go(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 o=this.state.formRoot.querySelector(`[name="${t}"]`);if(o)return o;const i=[t,t.replace(/\[(\d+)\]/g,"[$1]"),t.replace(/\./g,"[")+"]".repeat((t.match(/\./g)||[]).length)];for(const l of i)if(o=this.state.formRoot.querySelector(`[name="${l}"]`),o)return o}const n=this.findSchemaElement(t);if(!n)return null;const r=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const o of r){const i=n.label||n.key,l=o.querySelector("label");if(l&&(l.textContent===i||l.textContent===`${i}*`)){let a=o.querySelector(".field-placeholder");return a||(a=document.createElement("div"),a.className="field-placeholder",a.style.display="none",o.appendChild(a)),a}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(l=>l.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(l=>l.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(l=>l.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-6 pt-4 flex flex-wrap gap-3 justify-center",o.style.cssText=`
605
955
  border-top: var(--fb-border-width) solid var(--fb-border-color);
606
- `,t.forEach(a=>{const l=document.createElement("button");l.type="button",dn(l,!0);const i=n.includes(a),c=this.resolveActionLabel(a.key,a.label,null,i);l.textContent=c,l.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(a.value,a.key,null)}),o.appendChild(l)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(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,l)=>{const i=this.findFormElementByFieldPath(l);if(!i){console.warn(`External action: Could not find form element for field "${l}", treating as form-level actions`),r.push(...a);return}let c=i.closest(".fb-field-wrapper");if(c||(c=i.parentElement),!c){console.warn(`External action: Could not find wrapper for field "${l}"`);return}const s=c.querySelector(".external-actions-container");s&&s.remove();const f=document.createElement("div");f.className="external-actions-container mt-3 flex flex-wrap gap-2";const d=this.findSchemaElement(l);a.forEach(p=>{const u=document.createElement("button");u.type="button",dn(u,!1);const m=this.resolveActionLabel(p.key,p.label,d);u.textContent=m,u.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(p.value,p.key,p.related_field)}),f.appendChild(u)}),c.appendChild(f)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",a=n.getAttribute("data-container-key");if(!r||!o&&!a){console.warn("Prefill hint missing required data attributes");return}try{const l=JSON.parse(r);for(const i in l){const c=o?i:`${a}.${i}`,s=l[i];this.updateField(c,s)}}catch(l){console.error("Error parsing prefill hint values:",l)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const a=tt(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},ve(t),t.setAttribute("data-fb-root","true"),Kr(t,this.state.config.theme);const l=document.createElement("div");if(l.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);l.appendChild(s)}const i=document.createElement("div"),c=n.columns||1;c===1?i.className="space-y-4":i.className=`grid grid-cols-${c} gap-4`,n.elements.forEach(s=>{var f,d;if(s.hidden||s.type==="hidden"){const u=(d=(f=r==null?void 0:r[s.key])!=null?f:s.default)!=null?d:null;i.appendChild(ze(s.key,u));return}const p=bt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});i.appendChild(p)}),l.appendChild(i),t.appendChild(l),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(a,l,i=null)=>{const c=a.key,s={scopeRoot:i||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},f=Xr(a,c,s);return f!==null?(n.push(...f.errors),{value:f.value,spread:!!f.spread}):(console.warn(`Unknown field type "${a.type}" for key "${c}"`),{value:null,spread:!1})};return cr(o),this.state.schema.elements.forEach(a=>{var l;if(a.enableIf)try{if(!Te(a.enableIf,r))return}catch(i){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,i)}if(a.hidden||a.type==="hidden"){const i=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${a.key}"]`),c=(l=i==null?void 0:i.value)!=null?l:"";c!==""?r[a.key]=Et(c):r[a.key]=a.default!==void 0?a.default:null}else{const i=o(a,{path:""});i.spread&&i.value!==null&&typeof i.value=="object"?Object.assign(r,i.value):r[a.key]=i.value}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const a=r,l=this.buildHiddenFieldsData(a.elements);Object.keys(l).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...l}):n[o]=l)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const l=a,i=(n=l.textKey)!=null?n:"text",c=(r=l.filesKey)!=null?r:"files";o.set(i,{schemaKey:a.key,role:"text"}),o.set(c,{schemaKey:a.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const a=n.get(o);a?(r.has(a.schemaKey)||r.set(a.schemaKey,{}),r.get(a.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,a]of r)this.updateField(o,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 o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const a={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Gr(n,r,o,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,o)=>{r.forEach(a=>{var l,i,c;const s=o?`${o}.${a.key}`:a.key;if(a.enableIf){let f=null;if(o){const d=o.match(/^(.+)\[(\d+)\]$/);if(d){const p=d[1],u=d[2],m=this.state.formRoot.querySelector(`[data-container-item="${p}[${u}]"]`);m&&(f=m.querySelector(`[data-field-key="${a.key}"]`))}else{const p=this.state.formRoot.querySelector(`[data-container="${o}"]`);p&&(f=p.querySelector(`[data-field-key="${a.key}"]`))}}else f=this.state.formRoot.querySelector(`[data-field-key="${a.key}"]`);if(f){const d=f;try{let p;((l=a.enableIf.scope)!=null?l:"relative")==="relative"&&o&&(p=nt(t,o));const u=Te(a.enableIf,t,p),m=d.getAttribute("data-conditionally-disabled")==="true";if(u&&m){const v=o?nt(t,o):t,g=bt(a,{path:o,prefill:v&&typeof v=="object"?v:{},formData:t,state:this.state,instance:this});(i=d.parentNode)==null||i.replaceChild(g,d)}else if(!u&&!m){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"),(c=d.parentNode)==null||c.replaceChild(v,d)}}catch(p){console.error(`Error re-evaluating enableIf for field "${a.key}" at path "${s}":`,p)}}}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 d=this.state.formRoot.querySelectorAll("[data-container-item]");Array.from(d).filter(p=>{const u=p.getAttribute("data-container-item")||"";if(!u.startsWith(`${s}[`))return!1;const m=u.slice(s.length);return/^\[\d+\]$/.test(m)}).forEach(p=>{const u=p.getAttribute("data-container-item")||"";n(a.elements,u)})}else n(a.elements,s)}})};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 fn(e){return new Qe(e)}return typeof window!="undefined"&&(window.FormBuilder=Qe,window.createFormBuilder=fn,window.validateSchema=tt),Ee.FormBuilderInstance=Qe,Ee.createFormBuilder=fn,Ee.default=Qe,Ee.defaultTheme=Re,Ee.exampleThemes=Wr,Ee.validateSchema=tt,Object.defineProperty(Ee,"__esModule",{value:!0}),Ee})({});
956
+ `,t.forEach(i=>{const l=document.createElement("button");l.type="button",Kn(l,!0);const a=n.includes(i),s=this.resolveActionLabel(i.key,i.label,null,a);l.textContent=s,l.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(l)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,l)=>{const a=this.findFormElementByFieldPath(l);if(!a){console.warn(`External action: Could not find form element for field "${l}", treating as form-level actions`),r.push(...i);return}let s=a.closest(".fb-field-wrapper");if(s||(s=a.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${l}"`);return}const c=s.querySelector(".external-actions-container");c&&c.remove();const p=document.createElement("div");p.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(l);i.forEach(f=>{const d=document.createElement("button");d.type="button",Kn(d,!1);const m=this.resolveActionLabel(f.key,f.label,u);d.textContent=m,d.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),p.appendChild(d)}),s.appendChild(p)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const l=JSON.parse(r);for(const a in l){const s=o?a:`${i}.${a}`,c=l[a];this.updateField(s,c)}}catch(l){console.error("Error parsing prefill hint values:",l)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-4",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=ht(n);if(i.length>0){console.error("Schema validation errors:",i);return}this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},be(t),t.setAttribute("data-fb-root","true"),el(t,this.state.config.theme);const l=document.createElement("div");if(l.className="space-y-6",n.prefillHints&&!this.state.config.readonly){const c=this.createRootPrefillHints(n.prefillHints);l.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 p,u;if(c.hidden||c.type==="hidden"){const d=(u=(p=r==null?void 0:r[c.key])!=null?p:c.default)!=null?u:null;a.appendChild(De(c.key,d));return}const f=It(c,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});a.appendChild(f)}),l.appendChild(a),t.appendChild(l),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,l,a=null)=>{const s=i.key,c={scopeRoot:a||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},p=ll(i,s,c);return p!==null?(n.push(...p.errors),{value:p.value,spread:!!p.spread}):(console.warn(`Unknown field type "${i.type}" for key "${s}"`),{value:null,spread:!1})};return go(o),this.state.schema.elements.forEach(i=>{var l;if(i.enableIf)try{if(!Ne(i.enableIf,r))return}catch(a){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,a)}if(i.hidden||i.type==="hidden"){const a=this.state.formRoot.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${i.key}"]`),s=(l=a==null?void 0:a.value)!=null?l:"";s!==""?r[i.key]=Bt(s):r[i.key]=i.default!==void 0?i.default:null}else{const a=o(i,{path:""});a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(r,a.value):r[i.key]=a.value}}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const i=r,l=this.buildHiddenFieldsData(i.elements);Object.keys(l).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...l}):n[o]=l)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const l=i,a=(n=l.textKey)!=null?n:"text",s=(r=l.filesKey)!=null?r:"files";o.set(a,{schemaKey:i.key,role:"text"}),o.set(s,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};il(n,r,o,i)||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,o)=>{r.forEach(i=>{var l,a,s;const c=o?`${o}.${i.key}`:i.key;if(i.enableIf){let p=null;if(o){const u=o.match(/^(.+)\[(\d+)\]$/);if(u){const f=u[1],d=u[2],m=this.state.formRoot.querySelector(`[data-container-item="${f}[${d}]"]`);m&&(p=m.querySelector(`[data-field-key="${i.key}"]`))}else{const f=this.state.formRoot.querySelector(`[data-container="${o}"]`);f&&(p=f.querySelector(`[data-field-key="${i.key}"]`))}}else p=this.state.formRoot.querySelector(`[data-field-key="${i.key}"]`);if(p){const u=p;try{let f;((l=i.enableIf.scope)!=null?l:"relative")==="relative"&&o&&(f=vt(t,o));const d=Ne(i.enableIf,t,f),m=u.getAttribute("data-conditionally-disabled")==="true";if(d&&m){const b=o?vt(t,o):t,y=It(i,{path:o,prefill:b&&typeof b=="object"?b:{},formData:t,state:this.state,instance:this});(a=u.parentNode)==null||a.replaceChild(y,u)}else if(!d&&!m){const b=document.createElement("div");b.className="fb-field-wrapper-disabled",b.style.display="none",b.setAttribute("data-field-key",i.key),b.setAttribute("data-conditionally-disabled","true"),(s=u.parentNode)==null||s.replaceChild(b,u)}}catch(f){console.error(`Error re-evaluating enableIf for field "${i.key}" at path "${c}":`,f)}}}if((i.type==="container"||i.type==="group")&&"elements"in i&&i.elements){const p=t==null?void 0:t[i.key];if(Array.isArray(p)){const u=this.state.formRoot.querySelectorAll("[data-container-item]");Array.from(u).filter(f=>{const d=f.getAttribute("data-container-item")||"";if(!d.startsWith(`${c}[`))return!1;const m=d.slice(c.length);return/^\[\d+\]$/.test(m)}).forEach(f=>{const d=f.getAttribute("data-container-item")||"";n(i.elements,d)})}else n(i.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&&be(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 Jn(e){return new pt(e)}return typeof window!="undefined"&&(window.FormBuilder=pt,window.createFormBuilder=Jn,window.validateSchema=ht),we.FormBuilderInstance=pt,we.createFormBuilder=Jn,we.default=pt,we.defaultTheme=Ve,we.exampleThemes=tl,we.validateSchema=ht,Object.defineProperty(we,"__esModule",{value:!0}),we})({});