@dmitryvim/form-builder 0.5.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,9 @@
1
- var FormBuilder=(function(Fe){"use strict";function k(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 ae(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 se(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function wt(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function De(e,t){return e?`${e}.${t}`:t}function nt(e,t){if(!t)return[];const n=e.querySelectorAll("[data-container-item]");return Array.from(n).filter(r=>{const o=r.getAttribute("data-container-item")||"";return o.startsWith(`${t}[`)?/^\[\d+\]$/.test(o.slice(t.length)):!1})}function we(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function xr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Zt(e){return e==null?"":JSON.stringify(e)}function Ct(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Et(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Zt(t),n}function wr(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(k("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(k("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(k("hintMinLength",n,{min:e.minLength})))}function Cr(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(k("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(k("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(k("hintMinValue",n,{min:e.min})))}function Er(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(k("hintMaxSize",n,{size:o}))}function kr(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function $r(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Le(e,t){const n=[];return wr(e,n,t),e.type!=="slider"&&Cr(e,n,t),Er(e,n,t),kr(e,n,t),$r(e,n,t),n.join(" \u2022 ")}function kt(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,c=[1,2,3,4];(!Number.isInteger(i)||!c.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((c,s)=>{if((!c.label||typeof c.label!="string")&&t.push(`schema.prefillHints[${s}] must have a 'label' property of type string`),!c.values||typeof c.values!="object")t.push(`schema.prefillHints[${s}] must have a 'values' property of type object`);else for(const f in c.values)e.elements.some(d=>d.key===f)||t.push(`schema.prefillHints[${s}] references non-existent field "${f}"`)})}function n(i,c,s){if("columns"in i&&i.columns!==void 0){const f=i.columns,d=[1,2,3,4];(!Number.isInteger(f)||!d.includes(f))&&s.push(`${c}: columns must be 1, 2, 3, or 4 (got ${f})`)}if("displayMode"in i&&i.displayMode!==void 0){const f=i.displayMode;f!=="stack"&&f!=="slides"&&s.push(`${c}: displayMode must be "stack" or "slides" (got ${JSON.stringify(f)})`)}}function r(i,c){var s,f;const d=new Set;for(const u of i)if(u.type==="richinput"&&u.flatOutput){const p=u,m=(s=p.textKey)!=null?s:"text",b=(f=p.filesKey)!=null?f:"files";for(const g of i)g!==u&&(g.key===m&&t.push(`${c}: RichInput "${u.key}" flatOutput textKey "${m}" collides with element key "${g.key}"`),g.key===b&&t.push(`${c}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with element key "${g.key}"`));d.has(m)&&t.push(`${c}: RichInput "${u.key}" flatOutput textKey "${m}" collides with another flatOutput key`),d.has(b)&&t.push(`${c}: RichInput "${u.key}" flatOutput filesKey "${b}" collides with another flatOutput key`),d.add(m),d.add(b)}else u.key&&(d.has(u.key)&&t.push(`${c}: Element key "${u.key}" collides with a flatOutput richinput key`),d.add(u.key))}function o(i,c,s){var f,d;const u=i;if(u.type==="group"){if(!Je(u.repeat))return;a(c,(f=u.repeat)==null?void 0:f.min,(d=u.repeat)==null?void 0:d.max,"repeat.min","repeat.max",u.required===!0,s);return}(u.multiple===!0||u.type==="files")&&a(c,u.minCount,u.maxCount,"minCount","maxCount",u.required===!0,s)}function a(i,c,s,f,d,u,p){for(const[E,h]of[[f,c],[d,s]])h!==void 0&&typeof h!="number"&&p.push(`${i}: ${E} must be a number (got ${typeof h})`);const m=typeof c=="number"?c:void 0,b=typeof s=="number"?s:void 0;b!==void 0&&(b<0||Number.isNaN(b))&&p.push(`${i}: ${d} must be a non-negative number or Infinity (got ${b})`),m!==void 0&&(m<0||!Number.isFinite(m))&&p.push(`${i}: ${f} must be a finite non-negative number (got ${m})`);const g=m!=null?m:u?1:void 0;if(g!==void 0&&b!==void 0&&g>b){const E=m!==void 0?`${f} (${m})`:`required: true (implies ${f} 1)`;p.push(`${i}: ${E} cannot be greater than ${d} (${b})`)}}function l(i,c){i.forEach((s,f)=>{const d=`${c}[${f}]`;if(s.type||t.push(`${d}: missing type`),!s.key&&s.type!=="markdown"&&t.push(`${d}: missing key`),o(s,d,t),s.type==="number"&&"decimals"in s){const u=s.decimals;u!==void 0&&(!Number.isInteger(u)||u<0)&&t.push(`${d}: decimals must be a non-negative integer (got ${JSON.stringify(u)})`)}if(s.type==="markdown"){const u=s.content;typeof u!="string"&&t.push(`${d}: markdown element requires "content" to be a string (got ${u===null?"null":typeof u})`)}if(s.enableIf){const u=s.enableIf;(!u.key||typeof u.key!="string")&&t.push(`${d}: enableIf must have a 'key' property of type string`),"equals"in u||t.push(`${d}: enableIf must have at least one operator (equals, etc.)`)}if(s.type==="group"&&"elements"in s&&s.elements&&l(s.elements,`${d}.elements`),s.type==="container"&&s.elements){if(n(s,d,t),"prefillHints"in s&&s.prefillHints){const u=s.prefillHints;Array.isArray(u)&&u.forEach((p,m)=>{if((!p.label||typeof p.label!="string")&&t.push(`${d}: prefillHints[${m}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${d}: prefillHints[${m}] must have a 'values' property of type object`);else for(const b in p.values)s.elements.some(g=>g.key===b)||t.push(`container "${s.key}": prefillHints[${m}] references non-existent field "${b}"`)})}l(s.elements,`${d}.elements`),r(s.elements,`${d}.elements`)}if(s.type==="select"&&s.options){const u=s.default;u!=null&&u!==""&&(s.options.some(p=>p.value===u)||t.push(`${d}: default "${u}" not in options`))}})}return Array.isArray(e.elements)&&(l(e.elements,"elements"),r(e.elements,"elements")),t}function rt(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 je(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=rt(a,e.key);if("equals"in e)return Sr(l,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Sr(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 Ce(e){const t=e.getAttribute("name");if(!t)return;const n=(e.ownerDocument||document).getElementById(`error-${t}`);n&&n.remove()}const Qt='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Lr(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
1
+ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){var r,o;const l=t.config.locale||"en",a=t.config.translations[l],i=t.config.translations.en;let d=(o=(r=a==null?void 0:a[e])!=null?r:i==null?void 0:i[e])!=null?o:e;if(n)for(const[s,c]of Object.entries(n))d=d.replace(new RegExp(`\\{${s}\\}`,"g"),()=>String(c));return d}function ae(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Ge(e){return e&&typeof e=="object"&&e.constructor===Object}function de(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Lt(e,t){if(e.key)return e.key;const n=t.syntheticElementIds.get(e);if(n!==void 0)return n;const r=`fb-synthetic-${t.syntheticElementIdCounter++}`;return t.syntheticElementIds.set(e,r),r}function Ue(e,t){return e?`${e}.${t}`:t}function at(e,t){if(!t)return[];const n=e.querySelectorAll("[data-container-item]");return Array.from(n).filter(r=>{const o=r.getAttribute("data-container-item")||"";return o.startsWith(`${t}[`)?/^\[\d+\]$/.test(o.slice(t.length)):!1})}function Ee(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Kr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function dn(e){return e===void 0?"":JSON.stringify(e)}function cn(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function un(e){if(e instanceof HTMLInputElement){if(e.type==="checkbox")return e.checked;if(e.dataset.hiddenField)return cn(e.value);if(e.dataset.booleanField)return e.value==="true";if(e.type==="number"||e.type==="range"){if(e.value==="")return null;const t=parseFloat(e.value),n=e.dataset.decimals;return n!==void 0?Number(t.toFixed(parseInt(n,10))):t}if(e.dataset.colourField)return e.value.toUpperCase()}return e.value===""?null:e.value}function At(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=dn(t),n}function fn(e){var t,n,r,o;return(o=(r=(t=e.closest)==null?void 0:t.call(e,".fb-chip"))!=null?r:(n=e.closest)==null?void 0:n.call(e,".slider-container"))!=null?o:e}function pn(e){const t=fn(e),n=e.getAttribute("name"),r=t.parentElement;if(n&&r){for(const l of Array.from(r.children))if(mn(l)&&l.getAttribute("data-error-for")===n)return l}const o=t.nextElementSibling;return o&&mn(o)?o:null}function mn(e){return e.classList.contains("error-message")&&!e.classList.contains("fb-field-error")}function Tt(e,t,n){const r=n.state.reportedInvalid;if(t===null||n.readonly)return r.delete(e),null;if(!(n.draftMarks&&!r.has(e)))return r.add(e),t}function Ft(e){return e.length>0?e.join(" \u2022 "):null}function zt(e,t){const n=document.createElement("div");return n.className=t,n.id=hn(e,"error"),n.style.cssText=`
2
+ display: block;
3
+ color: var(--fb-error-color);
4
+ font-size: var(--fb-font-size-small);
5
+ margin-top: 0.25rem;
6
+ `,n}function Ze(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function hn(e,t){return`${e.instanceId}-${t}-${++e.domIdCounter}`}function Mt(e){var t;return((t=e.getAttribute("aria-describedby"))!=null?t:"").split(/\s+/).filter(Boolean)}const _r="input, select, textarea, button",st="data-fb-mark-added";function Jr(e){var t;const n=e.closest(".fb-field-wrapper"),r=n?Array.from(n.children).find(o=>o.hasAttribute("data-fb-label-row")):void 0;return(t=r==null?void 0:r.querySelector("label"))!=null?t:null}function Xr(e,t){if(e.matches(_r)||e.hasAttribute(st))return;const n=[];e.hasAttribute("tabindex")||(e.tabIndex=-1,n.push("tabindex")),e.hasAttribute("role")||(e.setAttribute("role","group"),n.push("role"));const r=Jr(e);r&&!e.hasAttribute("aria-labelledby")&&(r.id||(r.id=hn(t,"label")),e.setAttribute("aria-labelledby",r.id),n.push("aria-labelledby")),e.setAttribute(st,n.join(" "))}function bn(e,t){Mt(e).includes(t.id)||e.setAttribute("aria-describedby",[...Mt(e),t.id].join(" "))}function Rt(e,t,n){Ze(e,"aria-invalid","true"),Xr(e,n),t&&bn(e,t)}function gn(e){e.removeAttribute("aria-invalid");const t=e.getAttribute(st);if(t!==null){for(const n of t.split(" ").filter(Boolean))e.removeAttribute(n);e.removeAttribute(st)}}function Qe(e,t){if(gn(e),t){const n=Mt(e).filter(r=>r!==t.id);n.length>0?Ze(e,"aria-describedby",n.join(" ")):e.removeAttribute("aria-describedby"),t.remove()}}function vn(e,t,n,r,o){if(t===""){n&&Qe(e,n),Rt(e,null,o);return}const l=n!=null?n:r();l.textContent!==t&&(l.textContent=t),Rt(e,l,o)}function xe(e,t,n){var r;if(!e)return;const o=Tt(e,t,n);if(o===void 0)return;if(o===null){we(e);return}e.classList.contains("invalid")||e.classList.add("invalid"),e.title!==o&&(e.title=o);const l=(r=e.getAttribute("name"))!=null?r:"",a=pn(e);a&&Ze(a,"data-error-for",l),vn(e,o,a,()=>{var i;const d=zt(n.state,"error-message");d.setAttribute("data-error-for",l);const s=fn(e);return(i=s.parentNode)==null||i.insertBefore(d,s.nextSibling),d},n.state)}function we(e){e.classList.contains("invalid")&&e.classList.remove("invalid"),e.title!==""&&(e.title=""),Qe(e,pn(e))}function et(e,t,n,r){var o;const l=e.querySelector(`[data-field-path="${t}"]`);if(!l)throw new Error(`markFieldGroupValidity: no [data-field-path="${t}"] in scope`);if(l.getAttribute("data-conditionally-disabled")==="true")return;const a=Tt(l,n,r);if(a===void 0)return;const i=(o=Array.from(l.children).find(d=>d instanceof HTMLElement&&d.classList.contains("fb-field-error")))!=null?o:null;if(a===null){Qe(l,i);return}vn(l,a,i,()=>{const d=zt(r.state,"error-message fb-field-error");return d.setAttribute("data-error-for",t),l.appendChild(d),d},r.state)}const yn='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';function Yr(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
2
7
  [data-fb-slide-card] {
3
8
  background: var(--fb-slide-card-bg);
4
9
  box-shadow: var(--fb-slide-card-shadow);
@@ -110,7 +115,14 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
110
115
  /* .fb-size-md uses defaults \u2014 no override needed */
111
116
  .fb-size-lg { --fb-input-padding-y: 2px; --fb-input-padding-x: 8px; --fb-font-size: 16px; --fb-font-size-small: 13px; --fb-file-wide-min: 128px; --fb-file-zone-min: 96px; --fb-file-zone-padding: 12px; }
112
117
  .fb-size-xl { --fb-input-padding-y: 3px; --fb-input-padding-x: 8px; --fb-font-size: 18px; --fb-font-size-small: 14px; --fb-file-wide-min: 160px; --fb-file-zone-min: 120px; --fb-file-zone-padding: 14px; }
113
- `,e.head.appendChild(t)}function ot(e,t={}){var n;e.style.overflow="hidden",e.style.resize="none";const r=Math.max(1,(n=t.minRows)!=null?n:1),o=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(r,o);const a=()=>{if(!e.isConnected)return;e.style.height="";const c=getComputedStyle(e),s=parseFloat(c.borderTopWidth||"0")+parseFloat(c.borderBottomWidth||"0"),f=parseFloat(c.lineHeight||"0")||parseFloat(c.fontSize||"0")*1.5||20,d=parseFloat(c.paddingTop||"0")+parseFloat(c.paddingBottom||"0"),u=f*r+d+s;if(e.value===""){e.style.height=`${u}px`;return}const p=e.scrollHeight+s;e.style.height=`${Math.max(p,u)}px`};if(e.addEventListener("input",a),setTimeout(()=>{e.isConnected&&a()},0),typeof ResizeObserver=="undefined")return;let l=-1;const i=new ResizeObserver(c=>{var s,f,d,u,p;if(!e.isConnected){i.disconnect();return}const m=c[0],b=(p=(u=(f=(s=m==null?void 0:m.contentBoxSize)==null?void 0:s[0])==null?void 0:f.inlineSize)!=null?u:(d=m==null?void 0:m.contentRect)==null?void 0:d.width)!=null?p:0;b!==l&&(l=b,a())});i.observe(e)}function en(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,a;const l=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(l))return;t.preventDefault();const i=l.replace(/[\r\n]+/g," "),c=(o=e.selectionStart)!=null?o:e.value.length,s=(a=e.selectionEnd)!=null?a:e.value.length,f=e.value.slice(0,c),d=e.value.slice(s);e.value=f+i+d;const u=c+i.length;e.setSelectionRange(u,u),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Te(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function ze(e,t,n={}){var r;const o=(r=n.label)!=null?r:"",a=n.showCounter!==!1,l=document.createElement("div");l.className="fb-add-row",l.style.cssText="display:flex;align-items:stretch;width:100%;margin-top:4px;";const i=document.createElement("button");i.type="button",i.className=`add-${e}-btn`,i.style.cssText=`
118
+ /* !important: controls carry their border inline and JS focus/hover
119
+ handlers rewrite it, so no weaker rule would ever show the mark. */
120
+ [data-fb-root] input[aria-invalid="true"],
121
+ [data-fb-root] select[aria-invalid="true"],
122
+ [data-fb-root] textarea[aria-invalid="true"] {
123
+ border-color: var(--fb-error-color) !important;
124
+ }
125
+ `,e.head.appendChild(t)}function dt(e,t){var n,r;e.style.overflow="hidden",e.style.resize="none";const o=Math.max(1,(n=t.minRows)!=null?n:1),l=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(o,l);const a=()=>{if(!e.isConnected)return;e.style.height="";const s=getComputedStyle(e),c=parseFloat(s.borderTopWidth||"0")+parseFloat(s.borderBottomWidth||"0"),u=parseFloat(s.lineHeight||"0")||parseFloat(s.fontSize||"0")*1.5||20,f=parseFloat(s.paddingTop||"0")+parseFloat(s.paddingBottom||"0"),p=u*o+f+c;if(e.value===""){e.style.height=`${p}px`;return}const m=e.scrollHeight+c;e.style.height=`${Math.max(m,p)}px`};if(e.addEventListener("input",a),setTimeout(()=>{e.isConnected&&a()},0),typeof ResizeObserver=="undefined")return;let i=-1;const d=new ResizeObserver(s=>{var c,u,f,p,m,g;if(!e.isConnected){d.disconnect(),(c=t.observers)==null||c.delete(d);return}const x=s[0],S=(g=(m=(f=(u=x==null?void 0:x.contentBoxSize)==null?void 0:u[0])==null?void 0:f.inlineSize)!=null?m:(p=x==null?void 0:x.contentRect)==null?void 0:p.width)!=null?g:0;S!==i&&(i=S,a())});d.observe(e),(r=t.observers)==null||r.add(d)}function xn(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,l;const a=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(a))return;t.preventDefault();const i=a.replace(/[\r\n]+/g," "),d=(o=e.selectionStart)!=null?o:e.value.length,s=(l=e.selectionEnd)!=null?l:e.value.length,c=e.value.slice(0,d),u=e.value.slice(s);e.value=c+i+u;const f=d+i.length;e.setSelectionRange(f,f),e.dispatchEvent(new Event("input",{bubbles:!0}))})}function Ae(e,t){const n=e.querySelector(":scope > [data-fb-label-row]");n&&n.appendChild(t)}function ze(e,t,n={}){var r;const o=(r=n.label)!=null?r:"",l=n.showCounter!==!1,a=document.createElement("div");a.className="fb-add-row",a.style.cssText="display:flex;align-items:stretch;width:100%;margin-top:4px;";const i=document.createElement("button");i.type="button",i.className=`add-${e}-btn`,i.style.cssText=`
114
126
  flex: 1 1 auto;
115
127
  display: inline-flex;
116
128
  align-items: center;
@@ -126,12 +138,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
126
138
  font-family: var(--fb-font-family);
127
139
  cursor: pointer;
128
140
  transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
129
- `,i.textContent=o?`+ ${o}`:"+",i.addEventListener("mouseenter",()=>{i.disabled||(i.style.borderStyle="solid",i.style.backgroundColor="var(--fb-background-hover-color)")}),i.addEventListener("mouseleave",()=>{i.style.borderStyle="dashed",i.style.backgroundColor="transparent"}),i.onclick=t;const c=document.createElement("span");return c.className="fb-add-counter",c.style.cssText=`
141
+ `,i.textContent=o?`+ ${o}`:"+",i.addEventListener("mouseenter",()=>{i.disabled||(i.style.borderStyle="solid",i.style.backgroundColor="var(--fb-background-hover-color)")}),i.addEventListener("mouseleave",()=>{i.style.borderStyle="dashed",i.style.backgroundColor="transparent"}),i.onclick=t;const d=document.createElement("span");return d.className="fb-add-counter",d.style.cssText=`
130
142
  margin-left: auto;
131
143
  font-size: var(--fb-font-size-small, 0.875rem);
132
144
  color: var(--fb-text-secondary-color);
133
145
  font-weight: 400;
134
- `,a||(c.style.display="none"),l.appendChild(i),{row:l,button:i,counter:c,update:(s,f)=>{const d=s>=f;l.style.display=d?"none":"flex",i.style.display=d?"none":"inline-flex",i.disabled=d,a&&(c.textContent=`${s}/${f===1/0?"\u221E":f}`)}}}function Tr(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
146
+ `,l||(d.style.display="none"),a.appendChild(i),{row:a,button:i,counter:d,update:(s,c)=>{const u=s>=c;a.style.display=u?"none":"flex",i.style.display=u?"none":"inline-flex",i.disabled=u,l&&(d.textContent=`${s}/${c===1/0?"\u221E":c}`)}}}function Gr(e,t={}){var n;const r=(n=t.label)!=null?n:"",o=document.createElement("button");o.type="button",o.className="add-container-btn fb-slide-add",o.style.cssText=`
135
147
  display: flex;
136
148
  flex-direction: column;
137
149
  align-items: center;
@@ -150,7 +162,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
150
162
  font-family: var(--fb-font-family);
151
163
  cursor: pointer;
152
164
  transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
153
- `;const a=document.createElement("span");if(a.className="fb-slide-add-circle",a.style.cssText=`
165
+ `;const l=document.createElement("span");if(l.className="fb-slide-add-circle",l.style.cssText=`
154
166
  display: inline-flex;
155
167
  align-items: center;
156
168
  justify-content: center;
@@ -163,12 +175,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
163
175
  line-height: 1;
164
176
  color: inherit;
165
177
  transition: inherit;
166
- `,a.textContent="+",o.appendChild(a),r){const i=document.createElement("span");i.textContent=r,o.appendChild(i)}o.addEventListener("mouseenter",()=>{o.disabled||(o.style.borderStyle="solid",o.style.backgroundColor="var(--fb-background-hover-color)")}),o.addEventListener("mouseleave",()=>{o.style.borderStyle="dashed",o.style.backgroundColor="transparent"}),o.onclick=e;const l=document.createElement("span");return l.className="fb-add-counter",l.style.cssText=`
178
+ `,l.textContent="+",o.appendChild(l),r){const i=document.createElement("span");i.textContent=r,o.appendChild(i)}o.addEventListener("mouseenter",()=>{o.disabled||(o.style.borderStyle="solid",o.style.backgroundColor="var(--fb-background-hover-color)")}),o.addEventListener("mouseleave",()=>{o.style.borderStyle="dashed",o.style.backgroundColor="transparent"}),o.onclick=e;const a=document.createElement("span");return a.className="fb-add-counter",a.style.cssText=`
167
179
  margin-left: auto;
168
180
  font-size: var(--fb-font-size-small, 0.875rem);
169
181
  color: var(--fb-text-secondary-color);
170
182
  font-weight: 400;
171
- `,{tile:o,counter:l,update:(i,c)=>{const s=i>=c;o.style.display=s?"none":"flex",o.disabled=s,l.textContent=`${i}/${c===1/0?"\u221E":c}`}}}function tn(e,t=!1){e.style.cssText=`
183
+ `,{tile:o,counter:a,update:(i,d)=>{const s=i>=d;o.style.display=s?"none":"flex",o.disabled=s,a.textContent=`${i}/${d===1/0?"\u221E":d}`}}}function wn(e,t=!1){e.style.cssText=`
172
184
  background-color: var(--fb-action-bg-color);
173
185
  color: var(--fb-action-text-color);
174
186
  border: var(--fb-border-width) solid var(--fb-action-border-color);
@@ -178,7 +190,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
178
190
  border-radius: var(--fb-border-radius);
179
191
  transition: all var(--fb-transition-duration);
180
192
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
181
- `,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 Ar(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
193
+ `,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 Cn(e,t,n,r={min:"minItems",max:"maxItems"}){var o,l;const a="minCount"in e&&(o=e.minCount)!=null?o:0,i="maxCount"in e&&(l=e.maxCount)!=null?l:1/0,d=[];return e.required&&t===0&&d.push(k("required",n)),t<a&&d.push(k(r.min,n,{min:a})),t>i&&d.push(k(r.max,n,{max:i})),d}function qe(e,t,n,r,o){const l=Cn(e,n,r.state);o.push(...l.map(a=>`${t}: ${a}`)),et(r.scopeRoot,t,Ft(l),r)}function Zr(e,t,n){(e.minLength!=null||e.maxLength!=null)&&(e.minLength!=null&&e.maxLength!=null?t.push(k("hintLengthRange",n,{min:e.minLength,max:e.maxLength})):e.maxLength!=null?t.push(k("hintMaxLength",n,{max:e.maxLength})):e.minLength!=null&&t.push(k("hintMinLength",n,{min:e.minLength})))}function Qr(e,t,n){(e.min!=null||e.max!=null)&&(e.min!=null&&e.max!=null?t.push(k("hintValueRange",n,{min:e.min,max:e.max})):e.max!=null?t.push(k("hintMaxValue",n,{max:e.max})):e.min!=null&&t.push(k("hintMinValue",n,{min:e.min})))}function eo(e,t,n){var r;const o=(r=e.maxSize)!=null?r:e.maxSizeMB;o&&o!==1/0&&t.push(k("hintMaxSize",n,{size:o}))}function to(e,t,n){var r;(r=e.accept)!=null&&r.extensions&&t.push(k("hintFormats",n,{formats:e.accept.extensions.map(o=>o.toUpperCase()).join(",")}))}function no(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Te(e,t){const n=[];return Zr(e,n,t),e.type!=="slider"&&Qr(e,n,t),eo(e,n,t),to(e,n,t),no(e,n,t),n.join(" \u2022 ")}function It(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const i=e.columns,d=[1,2,3,4];(!Number.isInteger(i)||!d.includes(i))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${i})`)}if("prefillHints"in e&&e.prefillHints){const i=e.prefillHints;Array.isArray(i)&&i.forEach((d,s)=>{if((!d.label||typeof d.label!="string")&&t.push(`schema.prefillHints[${s}] must have a 'label' property of type string`),!d.values||typeof d.values!="object")t.push(`schema.prefillHints[${s}] must have a 'values' property of type object`);else for(const c in d.values)e.elements.some(u=>u.key===c)||t.push(`schema.prefillHints[${s}] references non-existent field "${c}"`)})}function n(i,d,s){if("columns"in i&&i.columns!==void 0){const c=i.columns,u=[1,2,3,4];(!Number.isInteger(c)||!u.includes(c))&&s.push(`${d}: columns must be 1, 2, 3, or 4 (got ${c})`)}if("displayMode"in i&&i.displayMode!==void 0){const c=i.displayMode;c!=="stack"&&c!=="slides"&&s.push(`${d}: displayMode must be "stack" or "slides" (got ${JSON.stringify(c)})`)}}function r(i,d){var s,c;const u=new Set;for(const f of i)if(f.type==="richinput"&&f.flatOutput){const p=f,m=(s=p.textKey)!=null?s:"text",g=(c=p.filesKey)!=null?c:"files";for(const x of i)x!==f&&(x.key===m&&t.push(`${d}: RichInput "${f.key}" flatOutput textKey "${m}" collides with element key "${x.key}"`),x.key===g&&t.push(`${d}: RichInput "${f.key}" flatOutput filesKey "${g}" collides with element key "${x.key}"`));u.has(m)&&t.push(`${d}: RichInput "${f.key}" flatOutput textKey "${m}" collides with another flatOutput key`),u.has(g)&&t.push(`${d}: RichInput "${f.key}" flatOutput filesKey "${g}" collides with another flatOutput key`),u.add(m),u.add(g)}else f.key&&(u.has(f.key)&&t.push(`${d}: Element key "${f.key}" collides with a flatOutput richinput key`),u.add(f.key))}function o(i,d,s){var c,u;const f=i;if(f.type==="group"){if(!Ge(f.repeat))return;l(d,(c=f.repeat)==null?void 0:c.min,(u=f.repeat)==null?void 0:u.max,"repeat.min","repeat.max",f.required===!0,s);return}(f.multiple===!0||f.type==="files")&&l(d,f.minCount,f.maxCount,"minCount","maxCount",f.required===!0,s)}function l(i,d,s,c,u,f,p){for(const[S,h]of[[c,d],[u,s]])h!==void 0&&typeof h!="number"&&p.push(`${i}: ${S} must be a number (got ${typeof h})`);const m=typeof d=="number"?d:void 0,g=typeof s=="number"?s:void 0;g!==void 0&&(g<0||Number.isNaN(g))&&p.push(`${i}: ${u} must be a non-negative number or Infinity (got ${g})`),m!==void 0&&(m<0||!Number.isFinite(m))&&p.push(`${i}: ${c} must be a finite non-negative number (got ${m})`);const x=m!=null?m:f?1:void 0;if(x!==void 0&&g!==void 0&&x>g){const S=m!==void 0?`${c} (${m})`:`required: true (implies ${c} 1)`;p.push(`${i}: ${S} cannot be greater than ${u} (${g})`)}}function a(i,d){const s=new Set;i.forEach((c,u)=>{c.key&&(s.has(c.key)&&t.push(`${d}[${u}]: duplicate key "${c.key}"`),s.add(c.key))}),i.forEach((c,u)=>{const f=`${d}[${u}]`;if(c.type||t.push(`${f}: missing type`),!c.key&&c.type!=="markdown"&&t.push(`${f}: missing key`),o(c,f,t),c.type==="number"&&"decimals"in c){const p=c.decimals;p!==void 0&&(!Number.isInteger(p)||p<0)&&t.push(`${f}: decimals must be a non-negative integer (got ${JSON.stringify(p)})`)}if(c.type==="markdown"){const p=c.content;typeof p!="string"&&t.push(`${f}: markdown element requires "content" to be a string (got ${p===null?"null":typeof p})`)}if(c.enableIf){const p=c.enableIf;(!p.key||typeof p.key!="string")&&t.push(`${f}: enableIf must have a 'key' property of type string`),"equals"in p||t.push(`${f}: enableIf must have at least one operator (equals, etc.)`)}if(c.type==="group"&&"elements"in c&&c.elements&&a(c.elements,`${f}.elements`),c.type==="container"&&c.elements){if(n(c,f,t),"prefillHints"in c&&c.prefillHints){const p=c.prefillHints;Array.isArray(p)&&p.forEach((m,g)=>{if((!m.label||typeof m.label!="string")&&t.push(`${f}: prefillHints[${g}] must have a 'label' property of type string`),!m.values||typeof m.values!="object")t.push(`${f}: prefillHints[${g}] must have a 'values' property of type object`);else for(const x in m.values)c.elements.some(S=>S.key===x)||t.push(`container "${c.key}": prefillHints[${g}] references non-existent field "${x}"`)})}a(c.elements,`${f}.elements`),r(c.elements,`${f}.elements`)}if(c.type==="select"&&c.options){const p=c.default;p!=null&&p!==""&&(c.options.some(m=>m.value===p)||t.push(`${f}: default "${p}" not in options`))}})}return Array.isArray(e.elements)&&(a(e.elements,"elements"),r(e.elements,"elements")),t}function ct(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 l=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(l))return;r=r[l]}else r=r[o]}return r}function Pe(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 l;if(o==="relative")l=n!=null?n:t;else if(o==="absolute")l=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const a=ct(l,e.key);if("equals"in e)return ro(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function ro(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 oo(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
182
194
  .fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
183
195
  .fb-chip {
184
196
  display: flex;
@@ -243,7 +255,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
243
255
  background: var(--fb-background-hover-color, #f1f5f9);
244
256
  }
245
257
  .fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
246
- `,e.head.appendChild(t)}function lt(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
258
+ `,e.head.appendChild(t)}function ut(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
247
259
  margin-top: 4px;
248
260
  padding-right: 12px;
249
261
  text-align: right;
@@ -252,11 +264,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
252
264
  color: var(--fb-error-color);
253
265
  pointer-events: none;
254
266
  display: none;
255
- `;const r=()=>{const o=t.value.length,a=e.maxLength;a!=null&&o>a?(n.textContent=`${o}/${a}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function Fr(e,t,n,r){var o;const a=t.state,l=ae(e,a,t),i=document.createElement("div");i.style.cssText="position: relative;";const c=!l&&(e.minLength!=null||e.maxLength!=null),s=document.createElement("textarea");if(s.rows=1,s.className="w-full rounded-lg",s.style.cssText=`
267
+ `;const r=()=>{const o=t.value.length,l=e.maxLength;l!=null&&o>l?(n.textContent=`${o}/${l}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function lo(e,t,n,r){var o,l,a;const i=t.state,d=ae(e,i,t),s=document.createElement("div");s.style.cssText="position: relative;";const c=!d&&(e.minLength!=null||e.maxLength!=null),u=document.createElement("textarea");if(u.rows=1,u.className="w-full rounded-lg",u.style.cssText=`
256
268
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
257
269
  border: var(--fb-border-width) solid var(--fb-border-color);
258
270
  border-radius: var(--fb-border-radius);
259
- background-color: ${l?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
271
+ background-color: ${d?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
260
272
  color: var(--fb-text-color);
261
273
  font-size: var(--fb-font-size);
262
274
  font-family: var(--fb-font-family);
@@ -268,35 +280,31 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
268
280
  overflow: hidden;
269
281
  word-break: break-word;
270
282
  overflow-wrap: anywhere;
271
- `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",a),s.value=t.prefill[e.key]||e.default||"",s.readOnly=l,en(s),ot(s),l||(s.addEventListener("focus",()=>{s.style.borderColor="var(--fb-border-focus-color)",s.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",s.style.outlineOffset="0"}),s.addEventListener("blur",()=>{s.style.borderColor="var(--fb-border-color)",s.style.outline="none"}),s.addEventListener("mouseenter",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-hover-color)")}),s.addEventListener("mouseleave",()=>{document.activeElement!==s&&(s.style.borderColor="var(--fb-border-color)")})),!l&&t.instance){const f=()=>{const d=s.value===""?null:s.value;t.instance.triggerOnChange(r,d)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(i.appendChild(s),c){const f=lt(e,s);i.appendChild(f)}n.appendChild(i)}function zr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");Ar(document);const u=document.createElement("div");u.className="fb-chip-list",n.appendChild(u);function p(){u.querySelectorAll(".fb-chip-input").forEach((h,y)=>{h.name=`${r}[${y}]`;const v=h.closest(".fb-chip"),C=v==null?void 0:v.nextElementSibling;C&&C.classList.contains("error-message")&&(C.id=`error-${h.name}`)})}function m(h=""){const y=document.createElement("div");y.className="fb-chip";const v=document.createElement("span");v.className="fb-chip-dot",v.setAttribute("aria-hidden","true"),y.appendChild(v);const C=document.createElement("textarea");if(C.rows=1,C.className="fb-chip-input",C.value=h,C.placeholder=e.placeholder||k("placeholderText",l),C.readOnly=i,y.appendChild(C),!i&&t.instance){const w=()=>{t.instance.triggerOnChange(C.name,C.value===""?null:C.value)};C.addEventListener("blur",w),C.addEventListener("input",w)}if(en(C),ot(C),!i){const w=document.createElement("button");w.type="button",w.className="fb-chip-remove",w.setAttribute("aria-label",k("removeElement",l)),w.innerHTML=Qt,w.onclick=()=>{var x;const S=u.querySelectorAll(".fb-chip"),z=Array.prototype.indexOf.call(S,y);if(z<0||S.length<=f)return;s.splice(z,1);const ee=y.nextElementSibling;ee&&ee.classList.contains("error-message")&&ee.remove(),y.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r)},y.appendChild(w)}return u.appendChild(y),p(),y}function b(){if(i)return;const h=u.querySelectorAll(".fb-chip").length<=f;u.querySelectorAll(".fb-chip-remove").forEach(y=>{y.disabled=h})}let g=null;if(!i){const h=ze("text",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function nn(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m,b;if(!d)return;const g=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let E=document.getElementById(g);if(u){if(d.classList.add("invalid"),d.title=u,!E){E=document.createElement("div"),E.id=g,E.className="error-message",E.style.cssText=`
272
- color: var(--fb-error-color);
273
- font-size: var(--fb-font-size-small);
274
- margin-top: 0.25rem;
275
- `;const h=((p=d.closest)==null?void 0:p.call(d,".fb-chip"))||d;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(E,h.nextSibling):(b=h.parentNode)==null||b.appendChild(E)}E.textContent=u,E.style.display="block"}else d.classList.remove("invalid"),d.title="",E&&E.remove()},f=(d,u,p)=>{let m=!1;const{state:b}=n;if(!c&&u){if(e.minLength!==void 0&&e.minLength!==null&&u.length<e.minLength){const g=k("minLength",b,{min:e.minLength});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&u.length>e.maxLength){const g=k("maxLength",b,{max:e.maxLength});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(u)){const g=k("patternMismatch",b);l.push(`${p}: ${g}`),s(d,g),m=!0}}catch(g){const E=k("invalidPattern",b);l.push(`${p}: ${E}`),s(d,E),m=!0}}m||s(d,null)};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["]`),u=[],p=[];if(d.forEach((m,b)=>{var g;const E=(g=m==null?void 0:m.value)!=null?g:"";p.push(E),u.push(E===""?null:E),f(m,E,`${t}[${b}]`)}),!c){const{state:m}=n,b=(r=e.minCount)!=null?r:0,g=(o=e.maxCount)!=null?o:1/0,E=p.filter(h=>h.trim()!=="");e.required&&E.length===0&&l.push(`${t}: ${k("required",m)}`),E.length<b&&l.push(`${t}: ${k("minItems",m,{min:b})}`),E.length>g&&l.push(`${t}: ${k("maxItems",m,{max:g})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"]`),u=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&u===""){const p=k("required",n.state);return l.push(`${t}: ${p}`),s(d,p),{value:null,errors:l}}return d&&f(d,u,t),{value:u===""?null:u,errors:l}}}function rn(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="",Ce(l),l.dispatchEvent(new Event("input",{bubbles:!0})))}),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="",Ce(a),a instanceof HTMLTextAreaElement&&a.dispatchEvent(new Event("input",{bubbles:!0})))}}function Mr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=document.createElement("div");c.style.cssText="position: relative;";const s=document.createElement("textarea");if(s.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",s.style.cssText=`
283
+ `,u.name=r,u.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",i),u.value=(a=(l=t.prefill[e.key])!=null?l:e.default)!=null?a:"",u.readOnly=d,xn(u),dt(u,{observers:i.autoExpandObservers}),d||(u.addEventListener("focus",()=>{u.style.borderColor="var(--fb-border-focus-color)",u.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",u.style.outlineOffset="0"}),u.addEventListener("blur",()=>{u.style.borderColor="var(--fb-border-color)",u.style.outline="none"}),u.addEventListener("mouseenter",()=>{document.activeElement!==u&&(u.style.borderColor="var(--fb-border-hover-color)")}),u.addEventListener("mouseleave",()=>{document.activeElement!==u&&(u.style.borderColor="var(--fb-border-color)")})),!d&&t.instance){const f=()=>{const p=u.value===""?null:u.value;t.instance.triggerOnChange(r,p)};u.addEventListener("blur",f),u.addEventListener("input",f)}if(s.appendChild(u),c){const f=ut(e,u);s.appendChild(f)}n.appendChild(s)}function io(e,t,n,r){var o,l;const a=t.state,i=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(l=e.maxCount)!=null?l:1/0;for(;s.length<c;)s.push(e.default||"");oo(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function p(){f.querySelectorAll(".fb-chip-input").forEach((h,b)=>{h.name=`${r}[${b}]`;const v=h.closest(".fb-chip"),E=v==null?void 0:v.nextElementSibling;E&&E.classList.contains("error-message")&&E.setAttribute("data-error-for",h.name)})}function m(h=""){var b;const v=document.createElement("div");v.className="fb-chip";const E=document.createElement("span");E.className="fb-chip-dot",E.setAttribute("aria-hidden","true"),v.appendChild(E);const w=document.createElement("textarea");if(w.rows=1,w.className="fb-chip-input",w.value=h,w.placeholder=(b=e.placeholder)!=null?b:k("placeholderText",a),w.readOnly=i,v.appendChild(w),!i&&t.instance){const C=()=>{t.instance.triggerOnChange(w.name,w.value===""?null:w.value)};w.addEventListener("blur",C),w.addEventListener("input",C)}if(xn(w),dt(w,{observers:a.autoExpandObservers}),!i){const C=document.createElement("button");C.type="button",C.className="fb-chip-remove",C.setAttribute("aria-label",k("removeElement",a)),C.innerHTML=yn,C.onclick=()=>{var y;const R=f.querySelectorAll(".fb-chip"),K=Array.prototype.indexOf.call(R,v);if(K<0||R.length<=c)return;s.splice(K,1);const Y=v.nextElementSibling;Y&&Y.classList.contains("error-message")&&Y.remove(),v.remove(),p(),S(),g(),(y=t.instance)==null||y.triggerOnChange(r)},v.appendChild(C)}return f.appendChild(v),p(),v}function g(){if(i)return;const h=f.querySelectorAll(".fb-chip").length<=c;f.querySelectorAll(".fb-chip-remove").forEach(b=>{b.disabled=h})}let x=null;if(!i){const h=ze("text",()=>{var b;s.push(e.default||""),m(e.default||""),S(),g(),(b=t.instance)==null||b.triggerOnChange(r)},{label:e.addLabel});x=h.update,Ae(n,h.counter),n.appendChild(h.row)}function S(){x&&x(s.length,u)}s.forEach(h=>m(h)),S(),g()}function En(e,t,n){var r;const o=[],{scopeRoot:l,state:a}=n,i=s=>{if(!s)return null;if(e.minLength!=null&&s.length<e.minLength)return k("minLength",a,{min:e.minLength});if(e.maxLength!=null&&s.length>e.maxLength)return k("maxLength",a,{max:e.maxLength});if(e.pattern)try{if(!new RegExp(e.pattern).test(s))return k("patternMismatch",a)}catch(c){return k("invalidPattern",a)}return null},d=(s,c,u)=>{const f=i(c);f!==null&&o.push(`${u}: ${f}`),xe(s,f,n)};if(e.multiple){const s=l.querySelectorAll(`[name^="${t}\\["]`),c=[];let u=0;return s.forEach((f,p)=>{var m;const g=(m=f==null?void 0:f.value)!=null?m:"";c.push(g===""?null:g),g.trim()!==""&&u++,d(f,g,`${t}[${p}]`)}),qe(e,t,u,n,o),{value:c,errors:o}}else{const s=l.querySelector(`[name="${t}"]`),c=(r=s==null?void 0:s.value)!=null?r:"";if(e.required&&c===""){const u=k("required",a);return o.push(`${t}: ${u}`),xe(s,u,n),{value:null,errors:o}}return s&&d(s,c,t),{value:c===""?null:c,errors:o}}}function kn(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 l=o.querySelectorAll(`[name^="${t}\\["]`);l.forEach((a,i)=>{i<n.length&&(a.value=n[i]!=null?String(n[i]):"",we(a),a.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==l.length&&console.warn(`updateTextField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=o.querySelector(`[name="${t}"]`);l&&(l.value=n!=null?String(n):"",we(l),l instanceof HTMLTextAreaElement&&l.dispatchEvent(new Event("input",{bubbles:!0})))}}function ao(e,t,n,r){var o,l,a,i;const d=t.state,s=ae(e,d,t),c=document.createElement("div");c.style.cssText="position: relative;";const u=document.createElement("textarea");if(u.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",u.style.cssText=`
276
284
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
277
285
  font-size: var(--fb-font-size);
278
286
  font-family: var(--fb-font-family);
279
287
  line-height: var(--fb-line-height, 1.5);
280
- `,s.name=r,s.placeholder=(o=e.placeholder)!=null?o:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",s.value=t.prefill[e.key]||e.default||"",s.readOnly=i,!i&&t.instance){const f=()=>{const d=s.value===""?null:s.value;t.instance.triggerOnChange(r,d)};s.addEventListener("blur",f),s.addEventListener("input",f)}if(ot(s,{minRows:(a=e.rows)!=null?a:1}),c.appendChild(s),!i&&(e.minLength!=null||e.maxLength!=null)){const f=lt(e,s);c.appendChild(f)}n.appendChild(c)}function Nr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-textarea-item").forEach((h,y)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){var v;const C=document.createElement("div");C.className="multiple-textarea-item";const w=document.createElement("div");w.style.cssText="position: relative;";const x=document.createElement("textarea");if(x.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",x.style.cssText=`
288
+ `,u.name=r,u.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",d),u.value=(a=(l=t.prefill[e.key])!=null?l:e.default)!=null?a:"",u.readOnly=s,!s&&t.instance){const f=()=>{const p=u.value===""?null:u.value;t.instance.triggerOnChange(r,p)};u.addEventListener("blur",f),u.addEventListener("input",f)}if(dt(u,{minRows:(i=e.rows)!=null?i:1,observers:d.autoExpandObservers}),c.appendChild(u),!s&&(e.minLength!=null||e.maxLength!=null)){const f=ut(e,u);c.appendChild(f)}n.appendChild(c)}function so(e,t,n,r){var o,l;const a=t.state,i=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(l=e.maxCount)!=null?l:1/0;for(;s.length<c;)s.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function p(){f.querySelectorAll(".multiple-textarea-item").forEach((h,b)=>{const v=h.querySelector("textarea");v&&(v.name=`${r}[${b}]`)})}function m(h="",b=-1){var v,E;const w=document.createElement("div");w.className="multiple-textarea-item";const C=document.createElement("div");C.style.cssText="position: relative;";const y=document.createElement("textarea");if(y.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",y.style.cssText=`
281
289
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
282
290
  font-size: var(--fb-font-size);
283
291
  font-family: var(--fb-font-family);
284
292
  line-height: var(--fb-line-height, 1.5);
285
- `,x.placeholder=e.placeholder||k("placeholderText",l),x.value=h,x.readOnly=i,!i&&t.instance){const S=()=>{const z=x.value===""?null:x.value;t.instance.triggerOnChange(x.name,z)};x.addEventListener("blur",S),x.addEventListener("input",S)}if(ot(x,{minRows:(v=e.rows)!=null?v:1}),w.appendChild(x),!i&&(e.minLength!=null||e.maxLength!=null)){const S=lt(e,x);w.appendChild(S)}return C.appendChild(w),y===-1?u.appendChild(C):u.insertBefore(C,u.children[y]),p(),C}function b(){if(i)return;const h=u.querySelectorAll(".multiple-textarea-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",C.innerHTML="\u2715",C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("textarea",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function Ir(e,t,n){return nn(e,t,n)}function Rr(e,t,n,r){rn(e,t,n,r);const{scopeRoot:o}=r;if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(a=>{a.dispatchEvent(new Event("input"))});else{const a=o.querySelector(`textarea[name="${t}"]`);a&&a.dispatchEvent(new Event("input"))}}function qr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
293
+ `,y.placeholder=(v=e.placeholder)!=null?v:k("placeholderText",a),y.value=h,y.readOnly=i,!i&&t.instance){const R=()=>{const K=y.value===""?null:y.value;t.instance.triggerOnChange(y.name,K)};y.addEventListener("blur",R),y.addEventListener("input",R)}if(dt(y,{minRows:(E=e.rows)!=null?E:1,observers:a.autoExpandObservers}),C.appendChild(y),!i&&(e.minLength!=null||e.maxLength!=null)){const R=ut(e,y);C.appendChild(R)}return w.appendChild(C),b===-1?f.appendChild(w):f.insertBefore(w,f.children[b]),p(),w}function g(){if(i)return;const h=f.querySelectorAll(".multiple-textarea-item"),b=h.length;h.forEach(v=>{let E=v.querySelector(".remove-item-btn");E||(E=document.createElement("button"),E.type="button",E.className="remove-item-btn mt-1 px-2 py-1 text-red-600 hover:bg-red-50 rounded text-sm",E.innerHTML="\u2715",E.onclick=()=>{var C;const y=Array.from(f.children).indexOf(v);f.children.length>c&&(s.splice(y,1),v.remove(),p(),S(),g(),(C=t.instance)==null||C.triggerOnChange(r))},v.appendChild(E));const w=b<=c;E.disabled=w,E.style.opacity=w?"0.5":"1",E.style.pointerEvents=w?"none":"auto"})}let x=null;if(!i){const h=ze("textarea",()=>{var b;s.push(e.default||""),m(e.default||""),S(),g(),(b=t.instance)==null||b.triggerOnChange(r)},{label:e.addLabel});x=h.update,Ae(n,h.counter),n.appendChild(h.row)}function S(){x&&x(s.length,u)}s.forEach(h=>m(h)),S(),g()}function co(e,t,n){return En(e,t,n)}function uo(e,t,n,r){kn(e,t,n,r);const{scopeRoot:o}=r;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 fo(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
286
294
  .fb-stepper-input::-webkit-outer-spin-button,
287
295
  .fb-stepper-input::-webkit-inner-spin-button {
288
296
  -webkit-appearance: none;
289
297
  margin: 0;
290
298
  }
291
299
  .fb-stepper-input { -moz-appearance: textfield; }
292
- `,e.head.appendChild(n)}function Br(e,t,n){var r;qr(e.ownerDocument);const o=(r=t.step)!=null?r:1,a=t.min,l=t.max,i=document.createElement("div");i.className="fb-stepper",i.style.cssText=`
300
+ `,e.head.appendChild(n)}function po(e,t,n){var r;fo(e.ownerDocument);const o=(r=t.step)!=null?r:1,l=t.min,a=t.max,i=document.createElement("div");i.className="fb-stepper",i.style.cssText=`
293
301
  display: inline-flex;
294
302
  align-items: stretch;
295
303
  border: var(--fb-border-width) solid var(--fb-border-color);
296
304
  border-radius: var(--fb-border-radius);
297
305
  overflow: hidden;
298
306
  background: var(--fb-background-color);
299
- `;const c=(s,f)=>{const d=document.createElement("button");return d.type="button",d.textContent=s,d.tabIndex=-1,d.style.cssText=`
307
+ `;const d=(s,c)=>{const u=document.createElement("button");return u.type="button",u.textContent=s,u.tabIndex=-1,u.style.cssText=`
300
308
  width: 32px;
301
309
  border: none;
302
310
  background: transparent;
@@ -305,7 +313,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
305
313
  font-family: var(--fb-font-family);
306
314
  cursor: ${n?"default":"pointer"};
307
315
  user-select: none;
308
- `,n?(d.disabled=!0,d.style.opacity="0.5"):d.addEventListener("click",u=>{var p;u.preventDefault();const m=parseFloat(e.value),b=Number.isFinite(m)?m:(p=a!=null?a:t.default)!=null?p:0;let g=parseFloat((b+f*o).toPrecision(12));a!=null&&(g=Math.max(a,g)),l!=null&&(g=Math.min(l,g)),e.value=String(g),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),d};return e.classList.add("fb-stepper-input"),e.style.cssText=`
316
+ `,n?(u.disabled=!0,u.style.opacity="0.5"):u.addEventListener("click",f=>{var p;f.preventDefault();const m=parseFloat(e.value),g=Number.isFinite(m)?m:(p=l!=null?l:t.default)!=null?p:0;let x=parseFloat((g+c*o).toPrecision(12));l!=null&&(x=Math.max(l,x)),a!=null&&(x=Math.min(a,x)),e.value=String(x),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}),u};return e.classList.add("fb-stepper-input"),e.style.cssText=`
309
317
  width: 56px;
310
318
  border: none;
311
319
  border-left: var(--fb-border-width) solid var(--fb-border-color);
@@ -318,7 +326,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
318
326
  color: var(--fb-text-color);
319
327
  -moz-appearance: textfield;
320
328
  box-sizing: border-box;
321
- `,i.appendChild(c("\u2212",-1)),i.appendChild(e),i.appendChild(c("+",1)),i}function on(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
329
+ `,i.appendChild(d("\u2212",-1)),i.appendChild(e),i.appendChild(d("+",1)),i}function $n(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
322
330
  position: absolute;
323
331
  top: 50%;
324
332
  transform: translateY(-50%);
@@ -328,35 +336,27 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
328
336
  pointer-events: none;
329
337
  background: var(--fb-background-color);
330
338
  padding: 0 4px;
331
- `;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 Hr(e,t,n,r){const o=t.state,a=ae(e,o,t),l=document.createElement("div");l.style.cssText="position: relative;";const i=document.createElement("input");if(i.type="number",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,e.stepper||(i.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",i.style.cssText=`
339
+ `;const r=e.min,o=e.max;let l="";r!=null&&o!=null?l=`${r} \u2013 ${o}`:o!=null?l=`\u2264${o}`:r!=null&&(l=`\u2265${r}`),n.textContent=l;const a=()=>{const i=t.value?parseFloat(t.value):null;if(i!=null){const d=r!=null&&i<r,s=o!=null&&i>o;n.style.color=d||s?"var(--fb-error-color)":"var(--fb-text-secondary-color)"}else n.style.color="var(--fb-text-secondary-color)"};return t.addEventListener("input",a),a(),n}function Sn(e){return e.step!==void 0?e.step.toString():e.decimals!==void 0?(10**-e.decimals).toString():"any"}function Ln(e,t){t.decimals!==void 0&&e.setAttribute("data-decimals",String(t.decimals))}function mo(e,t,n,r){var o,l,a;const i=t.state,d=ae(e,i,t),s=document.createElement("div");s.style.cssText="position: relative;";const c=document.createElement("input");if(c.type="number",c.name=r,c.placeholder=(o=e.placeholder)!=null?o:"0",e.min!==void 0&&(c.min=e.min.toString()),e.max!==void 0&&(c.max=e.max.toString()),c.step=Sn(e),Ln(c,e),c.value=(a=(l=t.prefill[e.key])!=null?l:e.default)!=null?a:"",c.readOnly=d,e.stepper||(c.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",c.style.cssText=`
332
340
  padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
333
341
  font-size: var(--fb-font-size);
334
342
  font-family: var(--fb-font-family);
335
343
  width: 100%;
336
344
  box-sizing: border-box;
337
- `),!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(e.stepper)l.appendChild(Br(i,e,a));else if(l.appendChild(i),!a&&(e.min!=null||e.max!=null)){const c=on(e,i);l.appendChild(c)}n.appendChild(l)}function Dr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-number-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="",y=-1){const v=document.createElement("div");v.className="multiple-number-item flex items-center gap-2";const C=document.createElement("div");C.style.cssText="position: relative; flex: 1;";const w=document.createElement("input");if(w.type="number",w.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
345
+ `),!d&&t.instance){const u=()=>{const f=c.value?parseFloat(c.value):null;t.instance.triggerOnChange(r,f)};c.addEventListener("blur",u),c.addEventListener("input",u)}if(e.stepper)s.appendChild(po(c,e,d));else if(s.appendChild(c),!d&&(e.min!=null||e.max!=null)){const u=$n(e,c);s.appendChild(u)}n.appendChild(s)}function ho(e,t,n,r){var o,l,a;const i=t.state,d=ae(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(l=e.maxCount)!=null?l:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"");const p=document.createElement("div");p.className="fb-row",n.appendChild(p);function m(){p.querySelectorAll(".multiple-number-item").forEach((b,v)=>{const E=b.querySelector("input");E&&(E.name=`${r}[${v}]`)})}function g(b="",v=-1){var E;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 y=document.createElement("input");if(y.type="number",y.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",y.style.cssText=`
338
346
  padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
339
347
  font-size: var(--fb-font-size);
340
348
  font-family: var(--fb-font-family);
341
349
  width: 100%;
342
350
  box-sizing: border-box;
343
- `,w.placeholder=e.placeholder||"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),e.step!==void 0&&(w.step=e.step.toString()),w.value=h.toString(),w.readOnly=i,!i&&t.instance){const x=()=>{const S=w.value?parseFloat(w.value):null;t.instance.triggerOnChange(w.name,S)};w.addEventListener("blur",x),w.addEventListener("input",x)}if(C.appendChild(w),!i&&(e.min!=null||e.max!=null)){const x=on(e,w);C.appendChild(x)}return v.appendChild(C),y===-1?u.appendChild(v):u.insertBefore(v,u.children[y]),p(),v}function b(){if(i)return;const h=u.querySelectorAll(".multiple-number-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",C.innerHTML="\u2715",C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("number",()=>{var y;s.push(e.default||""),m(e.default||""),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}s.forEach(h=>m(h)),E(),b()}function jr(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m;if(!d)return;const b=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);u?(d.classList.add("invalid"),d.title=u,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
344
- color: var(--fb-error-color);
345
- font-size: var(--fb-font-size-small);
346
- margin-top: 0.25rem;
347
- `,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=u,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,u,p)=>{let m=!1;const{state:b}=n;if(!c&&e.min!==void 0&&e.min!==null&&u<e.min){const g=k("minValue",b,{min:e.min});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(!c&&e.max!==void 0&&e.max!==null&&u>e.max){const g=k("maxValue",b,{max:e.max});l.push(`${p}: ${g}`),s(d,g),m=!0}m||s(d,null)};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["]`),u=[];if(d.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"";if(g===""){u.push(null),s(p,null);return}const E=parseFloat(g);if(!c&&!Number.isFinite(E)){const h=k("notANumber",n.state);l.push(`${t}[${m}]: ${h}`),s(p,h),u.push(null);return}f(p,E,`${t}[${m}]`),u.push(ln(E,e.decimals))}),!c){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=u.filter(E=>E!==null);e.required&&g.length===0&&l.push(`${t}: ${k("required",p)}`),g.length<m&&l.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&l.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"]`),u=(a=d==null?void 0:d.value)!=null?a:"",{state:p}=n;if(!c&&e.required&&u===""){const b=k("required",p);return l.push(`${t}: ${b}`),s(d,b),{value:null,errors:l}}if(u==="")return s(d,null),{value:null,errors:l};const m=parseFloat(u);if(!c&&!Number.isFinite(m)){const b=k("notANumber",p);return l.push(`${t}: ${b}`),s(d,b),{value:null,errors:l}}return f(d,m,t),{value:ln(m,e.decimals),errors:l}}}function ln(e,t){return!Number.isInteger(t)||t<0?e:Number(e.toFixed(t))}function Or(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="",Ce(l))}),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="",Ce(a))}}function Ur(e,t,n,r){const o=t.state,a=ae(e,o,t),l=document.createElement("select");if(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
351
+ `,y.placeholder=(E=e.placeholder)!=null?E:"0",e.min!==void 0&&(y.min=e.min.toString()),e.max!==void 0&&(y.max=e.max.toString()),y.step=Sn(e),Ln(y,e),y.value=b.toString(),y.readOnly=d,!d&&t.instance){const R=()=>{const K=y.value?parseFloat(y.value):null;t.instance.triggerOnChange(y.name,K)};y.addEventListener("blur",R),y.addEventListener("input",R)}if(C.appendChild(y),!d&&(e.min!=null||e.max!=null)){const R=$n(e,y);C.appendChild(R)}return w.appendChild(C),v===-1?p.appendChild(w):p.insertBefore(w,p.children[v]),m(),w}function x(){if(d)return;const b=p.querySelectorAll(".multiple-number-item"),v=b.length;b.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",w.innerHTML="\u2715",w.onclick=()=>{var y;const R=Array.from(p.children).indexOf(E);p.children.length>u&&(c.splice(R,1),E.remove(),m(),h(),x(),(y=t.instance)==null||y.triggerOnChange(r))},E.appendChild(w));const C=v<=u;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"})}let S=null;if(!d){const b=ze("number",()=>{var v,E,w;c.push((v=e.default)!=null?v:""),g((E=e.default)!=null?E:""),h(),x(),(w=t.instance)==null||w.triggerOnChange(r)},{label:e.addLabel});S=b.update,Ae(n,b.counter),n.appendChild(b.row)}function h(){S&&S(c.length,f)}c.forEach(b=>g(b)),h(),x()}function bo(e,t,n){var r;const o=[],{scopeRoot:l,state:a}=n,i=s=>e.min!=null&&s<e.min?k("minValue",a,{min:e.min}):e.max!=null&&s>e.max?k("maxValue",a,{max:e.max}):null,d=(s,c)=>{const u=s.value;if(u==="")return xe(s,null,n),null;const f=parseFloat(u),p=Number.isFinite(f)?i(f):k("notANumber",a);return p!==null&&o.push(`${c}: ${p}`),xe(s,p,n),Number.isFinite(f)?go(f,e.decimals):null};if(e.multiple){const s=l.querySelectorAll(`[name^="${t}\\["]`),c=[];s.forEach((f,p)=>{c.push(d(f,`${t}[${p}]`))});const u=c.filter(f=>f!==null).length;return qe(e,t,u,n,o),{value:c,errors:o}}else{const s=l.querySelector(`[name="${t}"]`);if(e.required&&((r=s==null?void 0:s.value)!=null?r:"")===""){const c=k("required",a);return o.push(`${t}: ${c}`),xe(s,c,n),{value:null,errors:o}}return s?{value:d(s,t),errors:o}:{value:null,errors:o}}}function go(e,t){return!Number.isInteger(t)||t<0?e:Number(e.toFixed(t))}function vo(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 l=o.querySelectorAll(`[name^="${t}\\["]`);l.forEach((a,i)=>{i<n.length&&(a.value=n[i]!=null?String(n[i]):"",we(a))}),n.length!==l.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=o.querySelector(`[name="${t}"]`);l&&(l.value=n!=null?String(n):"",we(l))}}function An(e,t,n,r){var o;const l=t.options||[];if(!l.some(d=>d.value==="")){const d=document.createElement("option");d.value="",d.textContent=(o=t.placeholder)!=null?o:k("selectPlaceholder",r),e.appendChild(d)}const a=n==null?null:String(n);let i=!1;if(l.forEach(d=>{const s=document.createElement("option");s.value=d.value,s.textContent=d.label,a===d.value&&(s.selected=!0,i=!0),e.appendChild(s)}),!i&&a!==null&&a!==""&&console.warn(`select "${t.key}": prefill value "${a}" is not among the options; leaving the field unselected`),!i){const d=Array.from(e.options).find(s=>s.value==="");d&&(d.selected=!0)}}function yo(e,t,n,r){var o;const l=t.state,a=ae(e,l,t),i=document.createElement("select");if(i.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",i.style.cssText=`
348
352
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
349
353
  font-size: var(--fb-font-size);
350
354
  font-family: var(--fb-font-family);
351
- `,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=Le(e,o),n.appendChild(i)}}function Pr(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=t.prefill[e.key]||[],d=Array.isArray(f)?[...f]:[],u=(o=e.minCount)!=null?o:e.required?1:0,p=(a=e.maxCount)!=null?a:1/0;for(;d.length<u;)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="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-select-item").forEach((v,C)=>{const w=v.querySelector("select");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=document.createElement("div");w.className="multiple-select-item flex items-center gap-2";const x=document.createElement("select");if(x.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",x.style.cssText=`
355
+ `,i.name=r,i.disabled=a,An(i,e,(o=t.prefill[e.key])!=null?o:e.default,l),!a&&t.instance){const d=()=>{t.instance.triggerOnChange(r,i.value===""?null:i.value)};i.addEventListener("change",d)}if(n.appendChild(i),!a){const d=document.createElement("p");d.className="text-xs text-gray-500 mt-1",d.textContent=Te(e,l),n.appendChild(d)}}function xo(e,t,n,r){var o,l,a;const i=t.state,d=ae(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(l=e.maxCount)!=null?l:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"");const p=document.createElement("div");p.className="fb-row",n.appendChild(p);function m(){p.querySelectorAll(".multiple-select-item").forEach((b,v)=>{const E=b.querySelector("select");E&&(E.name=`${r}[${v}]`)})}function g(b="",v=-1){const E=document.createElement("div");E.className="multiple-select-item flex items-center gap-2";const w=document.createElement("select");if(w.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",w.style.cssText=`
352
356
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
353
357
  font-size: var(--fb-font-size);
354
358
  font-family: var(--fb-font-family);
355
- `,x.disabled=s,(e.options||[]).forEach(S=>{const z=document.createElement("option");z.value=S.value,z.textContent=S.label,v===S.value&&(z.selected=!0),x.appendChild(z)}),!s&&t.instance){const S=()=>{t.instance.triggerOnChange(x.name,x.value)};x.addEventListener("change",S)}return w.appendChild(x),C===-1?m.appendChild(w):m.insertBefore(w,m.children[C]),b(),w}function E(){if(s)return;const v=m.querySelectorAll(".multiple-select-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",x.innerHTML="\u2715",x.onclick=()=>{var z;const ee=Array.from(m.children).indexOf(w);m.children.length>u&&(d.splice(ee,1),w.remove(),b(),y(),E(),(z=t.instance)==null||z.triggerOnChange(r))},w.appendChild(x));const S=C<=u;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!s){const v=ze("select",()=>{var C,w,x;const S=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";d.push(S),g(S),y(),E(),(x=t.instance)==null||x.triggerOnChange(r)},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(d.length,p)}if(d.forEach(v=>g(v)),y(),E(),!s){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,c),n.appendChild(v)}}function Wr(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(s,f)=>{var d,u;if(!s)return;const p=`error-${s.getAttribute("name")||Math.random().toString(36).substring(7)}`;let m=document.getElementById(p);f?(s.classList.add("invalid"),s.title=f,m||(m=document.createElement("div"),m.id=p,m.className="error-message",m.style.cssText=`
356
- color: var(--fb-error-color);
357
- font-size: var(--fb-font-size-small);
358
- margin-top: 0.25rem;
359
- `,s.nextSibling?(d=s.parentNode)==null||d.insertBefore(m,s.nextSibling):(u=s.parentNode)==null||u.appendChild(m)),m.textContent=f,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},c=(s,f,d,u)=>{var p,m;if(l)return;const{state:b}=n,g=f.filter(u),E="minCount"in d&&(p=d.minCount)!=null?p:0,h="maxCount"in d&&(m=d.maxCount)!=null?m:1/0;d.required&&g.length===0&&o.push(`${s}: ${k("required",b)}`),g.length<E&&o.push(`${s}: ${k("minItems",b,{min:E})}`),g.length>h&&o.push(`${s}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const s=a.querySelectorAll(`[name^="${t}\\["]`),f=[];return s.forEach(d=>{var u;const p=(u=d==null?void 0:d.value)!=null?u:"";f.push(p),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=k("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 Vr(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="",Ce(l))}),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="",Ce(a))}}function it(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function at(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function an(e){return e.classList.contains("fb-switcher-preset")}function Kr(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
359
+ `,w.disabled=d,An(w,e,b,i),!d&&t.instance){const C=()=>{t.instance.triggerOnChange(w.name,w.value)};w.addEventListener("change",C)}return E.appendChild(w),v===-1?p.appendChild(E):p.insertBefore(E,p.children[v]),m(),E}function x(){if(d)return;const b=p.querySelectorAll(".multiple-select-item"),v=b.length;b.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",w.innerHTML="\u2715",w.onclick=()=>{var y;const R=Array.from(p.children).indexOf(E);p.children.length>u&&(c.splice(R,1),E.remove(),m(),h(),x(),(y=t.instance)==null||y.triggerOnChange(r))},E.appendChild(w));const C=v<=u;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"})}let S=null;if(!d){const b=ze("select",()=>{var v,E;const w=(v=e.default)!=null?v:"";c.push(w),g(w),h(),x(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});S=b.update,Ae(n,b.counter),n.appendChild(b.row)}function h(){S&&S(c.length,f)}if(c.forEach(b=>g(b)),h(),x(),!d){const b=document.createElement("p");b.className="text-xs text-gray-500 mt-1",b.textContent=Te(e,i),n.appendChild(b)}}function wo(e,t,n){var r;const o=[],{scopeRoot:l}=n;if("multiple"in e&&e.multiple){const a=l.querySelectorAll(`[name^="${t}\\["]`),i=[];a.forEach(s=>{var c;const u=(c=s==null?void 0:s.value)!=null?c:"";i.push(u===""?null:u),xe(s,null,n)});const d=i.filter(s=>s!=null).length;return qe(e,t,d,n,o),{value:i,errors:o}}else{const a=l.querySelector(`[name="${t}"]`),i=(r=a==null?void 0:a.value)!=null?r:"";if(e.required&&i===""){const d=k("required",n.state);return o.push(`${t}: ${d}`),xe(a,d,n),{value:null,errors:o}}return xe(a,null,n),{value:i===""?null:i,errors:o}}}function Tn(e,t,n){if(t!==""&&!Array.from(e.options).some(r=>r.value===t))throw new Error(`updateSelectField: value "${t}" is not among the options of "${n}"`)}function Co(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 l=o.querySelectorAll(`[name^="${t}\\["]`);l.forEach((a,i)=>{if(i<n.length){const d=n[i]!=null?String(n[i]):"";Tn(a,d,`${t}[${i}]`)}}),l.forEach((a,i)=>{if(i<n.length){const d=n[i]!=null?String(n[i]):"";a.value=d,a.querySelectorAll("option").forEach(s=>{s.selected=s.value===d}),we(a)}}),n.length!==l.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${l.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=o.querySelector(`[name="${t}"]`);if(l){const a=n!=null?String(n):"";Tn(l,a,t),l.value=a,l.querySelectorAll("option").forEach(i=>{i.selected=i.value===a}),we(l)}}}function ft(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function pt(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function Fn(e){return e.classList.contains("fb-switcher-preset")}function Eo(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
360
360
  display: inline-flex;
361
361
  align-items: center;
362
362
  gap: 8px;
@@ -381,7 +381,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
381
381
  font-size: var(--fb-font-size-small);
382
382
  opacity: 0.7;
383
383
  font-variant-numeric: tabular-nums;
384
- `,n.appendChild(o)}return n}function sn(e,t,n,r,o){const a=e.options||[],l=a.some(s=>s.subtitle||s.iconUrl),i=document.createElement("div");i.className="fb-switcher-group",i.style.cssText=l?`
384
+ `,n.appendChild(o)}return n}function zn(e,t,n,r,o){const l=e.options||[],a=l.some(s=>s.subtitle||s.iconUrl),i=document.createElement("div");i.className="fb-switcher-group",i.style.cssText=a?`
385
385
  display: flex;
386
386
  flex-direction: row;
387
387
  flex-wrap: wrap;
@@ -390,7 +390,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
390
390
  display: inline-flex;
391
391
  flex-direction: row;
392
392
  flex-wrap: nowrap;
393
- `;const c=[];return a.forEach((s,f)=>{let d;l?d=Kr(s,r):(d=document.createElement("button"),d.type="button",d.className="fb-switcher-btn",d.dataset.value=s.value,d.textContent=s.label,d.style.cssText=`
393
+ `;const d=[];return l.forEach((s,c)=>{let u;a?u=Eo(s,r):(u=document.createElement("button"),u.type="button",u.className="fb-switcher-btn",u.dataset.value=s.value,u.textContent=s.label,u.style.cssText=`
394
394
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
395
395
  font-size: var(--fb-font-size);
396
396
  border-width: var(--fb-border-width);
@@ -400,21 +400,17 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
400
400
  white-space: nowrap;
401
401
  line-height: 1.25;
402
402
  outline: none;
403
- `,a.length===1?d.style.borderRadius="var(--fb-border-radius)":f===0?(d.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",d.style.borderRightWidth="0"):f===a.length-1?d.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(d.style.borderRadius="0",d.style.borderRightWidth="0")),s.value===t?it(d,l):at(d,l),r||(d.addEventListener("click",()=>{n.value=s.value,c.forEach(u=>{u.dataset.value===s.value?it(u,l):at(u,l)}),o&&o(s.value)}),d.addEventListener("mouseenter",()=>{n.value!==s.value&&(d.style.backgroundColor="var(--fb-background-hover-color)")}),d.addEventListener("mouseleave",()=>{n.value!==s.value&&(d.style.backgroundColor=l?"var(--fb-background-color)":"transparent")})),c.push(d),i.appendChild(d)}),i}function _r(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=ae(e,l,t),f=!s&&t.instance?u=>{t.instance.triggerOnChange(r,u)}:null,d=sn(e,i,c,s,f);if(n.appendChild(c),n.appendChild(d),!s){const u=document.createElement("p");u.className="text-xs text-gray-500 mt-1",u.textContent=Le(e,l),n.appendChild(u)}}function Jr(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:e.required?1:0,u=(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 p=ae(e,c,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function b(){m.querySelectorAll(".multiple-switcher-item").forEach((v,C)=>{const w=v.querySelector("input[type=hidden]");w&&(w.name=`${r}[${C}]`)})}function g(v="",C=-1){const w=C===-1?m.children.length:C,x=`${r}[${w}]`,S=document.createElement("div");S.className="multiple-switcher-item flex items-center gap-2";const z=document.createElement("input");z.type="hidden",z.name=x,z.value=v,S.appendChild(z);const ee=!p&&t.instance?H=>{t.instance.triggerOnChange(z.name,H)}:null,K=sn(e,v,z,p,ee);return S.appendChild(K),C===-1?m.appendChild(S):m.insertBefore(S,m.children[C]),b(),S}function E(){if(p)return;const v=m.querySelectorAll(".multiple-switcher-item"),C=v.length;v.forEach(w=>{let x=w.querySelector(".remove-item-btn");x||(x=document.createElement("button"),x.type="button",x.className="remove-item-btn px-2 py-1 rounded",x.style.cssText=`
403
+ `,l.length===1?u.style.borderRadius="var(--fb-border-radius)":c===0?(u.style.borderRadius="var(--fb-border-radius) 0 0 var(--fb-border-radius)",u.style.borderRightWidth="0"):c===l.length-1?u.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(u.style.borderRadius="0",u.style.borderRightWidth="0")),s.value===t?ft(u,a):pt(u,a),r||(u.addEventListener("click",()=>{n.value=s.value,d.forEach(f=>{f.dataset.value===s.value?ft(f,a):pt(f,a)}),o&&o(s.value)}),u.addEventListener("mouseenter",()=>{n.value!==s.value&&(u.style.backgroundColor="var(--fb-background-hover-color)")}),u.addEventListener("mouseleave",()=>{n.value!==s.value&&(u.style.backgroundColor=a?"var(--fb-background-color)":"transparent")})),d.push(u),i.appendChild(u)}),i}function ko(e,t,n,r){var o,l;const a=t.state,i=String((l=(o=t.prefill[e.key])!=null?o:e.default)!=null?l:""),d=document.createElement("input");d.type="hidden",d.name=r,d.value=i;const s=ae(e,a,t),c=!s&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,u=zn(e,i,d,s,c);if(n.appendChild(d),n.appendChild(u),!s){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Te(e,a),n.appendChild(f)}}function $o(e,t,n,r){var o,l,a;const i=t.state,d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(l=e.maxCount)!=null?l:1/0;for(;s.length<c;)s.push((a=e.default)!=null?a:"");const f=ae(e,i,t),p=document.createElement("div");p.className="fb-row",n.appendChild(p);function m(){p.querySelectorAll(".multiple-switcher-item").forEach((b,v)=>{const E=b.querySelector("input[type=hidden]");E&&(E.name=`${r}[${v}]`)})}function g(b="",v=-1){const E=v===-1?p.children.length:v,w=`${r}[${E}]`,C=document.createElement("div");C.className="multiple-switcher-item flex items-center gap-2";const y=document.createElement("input");y.type="hidden",y.name=w,y.value=b,C.appendChild(y);const R=!f&&t.instance?Y=>{t.instance.triggerOnChange(y.name,Y)}:null,K=zn(e,b,y,f,R);return C.appendChild(K),v===-1?p.appendChild(C):p.insertBefore(C,p.children[v]),m(),C}function x(){if(f)return;const b=p.querySelectorAll(".multiple-switcher-item"),v=b.length;b.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
404
404
  color: var(--fb-error-color);
405
405
  background-color: transparent;
406
406
  transition: background-color var(--fb-transition-duration);
407
- `,x.innerHTML="\u2715",x.addEventListener("mouseenter",()=>{x.style.backgroundColor="var(--fb-background-hover-color)"}),x.addEventListener("mouseleave",()=>{x.style.backgroundColor="transparent"}),x.onclick=()=>{var z;const ee=Array.from(m.children).indexOf(w);m.children.length>d&&(f.splice(ee,1),w.remove(),b(),y(),E(),(z=t.instance)==null||z.triggerOnChange(r))},w.appendChild(x));const S=C<=d;x.disabled=S,x.style.opacity=S?"0.5":"1",x.style.pointerEvents=S?"none":"auto"})}let h=null;if(!p){const v=ze("switcher",()=>{var C,w,x;const S=e.default||((w=(C=e.options)==null?void 0:C[0])==null?void 0:w.value)||"";f.push(S),g(S),y(),E(),(x=t.instance)==null||x.triggerOnChange(r)},{label:e.addLabel});h=v.update,Te(n,v.counter),n.appendChild(v.row)}function y(){h&&h(f.length,u)}if(f.forEach(v=>g(v)),y(),E(),!p){const v=document.createElement("p");v.className="text-xs text-gray-500 mt-1",v.textContent=Le(e,c),n.appendChild(v)}}function Xr(e,t,n){var r;const o=[],{scopeRoot:a,skipValidation:l}=n,i=(f,d)=>{var u,p;if(!f)return;const m=`error-${f.getAttribute("name")||Math.random().toString(36).substring(7)}`;let b=document.getElementById(m);d?(f.classList.add("invalid"),f.title=d,b||(b=document.createElement("div"),b.id=m,b.className="error-message",b.style.cssText=`
408
- color: var(--fb-error-color);
409
- font-size: var(--fb-font-size-small);
410
- margin-top: 0.25rem;
411
- `,f.nextSibling?(u=f.parentNode)==null||u.insertBefore(b,f.nextSibling):(p=f.parentNode)==null||p.appendChild(b)),b.textContent=d,b.style.display="block"):(f.classList.remove("invalid"),f.title="",b&&b.remove())},c=(f,d,u,p)=>{var m,b;if(l)return;const{state:g}=n,E=d.filter(p),h="minCount"in u&&(m=u.minCount)!=null?m:0,y="maxCount"in u&&(b=u.maxCount)!=null?b:1/0;u.required&&E.length===0&&o.push(`${f}: ${k("required",g)}`),E.length<h&&o.push(`${f}: ${k("minItems",g,{min:h})}`),E.length>y&&o.push(`${f}: ${k("maxItems",g,{max:y})}`)},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(u=>{var p;const m=(p=u==null?void 0:u.value)!=null?p:"";if(d.push(m),!l&&m!==""&&!s.has(m)){const b=k("invalidOption",n.state);i(u,b),o.push(`${t}: ${b}`)}else i(u,null)}),c(t,d,e,u=>u!==""),{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 u=k("required",n.state);return o.push(`${t}: ${u}`),i(f,u),{value:null,errors:o}}if(!l&&d!==""&&!s.has(d)){const u=k("invalidOption",n.state);return o.push(`${t}: ${u}`),i(f,u),{value:null,errors:o}}return i(f,null),{value:d===""?null:d,errors:o}}}function Yr(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(u=>{const p=an(u);u.dataset.value===f?it(u,p):at(u,p)}),i.classList.remove("invalid"),i.title="",Ce(i)}}),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=>{const f=an(s);s.dataset.value===i?it(s,f):at(s,f)}),l.classList.remove("invalid"),l.title="",Ce(l)}}}const cn=36,Xe=20,Oe=16;function Gr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
407
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var y;const R=Array.from(p.children).indexOf(E);p.children.length>c&&(s.splice(R,1),E.remove(),m(),h(),x(),(y=t.instance)==null||y.triggerOnChange(r))},E.appendChild(w));const C=v<=c;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"})}let S=null;if(!f){const b=ze("switcher",()=>{var v,E;const w=(v=e.default)!=null?v:"";s.push(w),g(w),h(),x(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});S=b.update,Ae(n,b.counter),n.appendChild(b.row)}function h(){S&&S(s.length,u)}if(s.forEach(b=>g(b)),h(),x(),!f){const b=document.createElement("p");b.className="text-xs text-gray-500 mt-1",b.textContent=Te(e,i),n.appendChild(b)}}function So(e,t,n){var r;const o=[],{scopeRoot:l,state:a}=n,i=new Set("options"in e?e.options.map(s=>s.value):[]),d=s=>s!==""&&!i.has(s)?k("invalidOption",a):null;if("multiple"in e&&e.multiple){const s=l.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),c=[];s.forEach(f=>{var p;const m=(p=f==null?void 0:f.value)!=null?p:"";c.push(m===""?null:m);const g=d(m);g!==null&&o.push(`${t}: ${g}`),xe(mt(f),g,n)});const u=c.filter(f=>f!=null).length;return qe(e,t,u,n,o),{value:c,errors:o}}else{const s=l.querySelector(`input[type="hidden"][name="${t}"]`),c=(r=s==null?void 0:s.value)!=null?r:"",u=e.required&&c===""?k("required",a):d(c);return s&&xe(mt(s),u,n),u!==null?(o.push(`${t}: ${u}`),{value:null,errors:o}):{value:c===""?null:c,errors:o}}}function mt(e){var t;const n=(t=e.parentElement)==null?void 0:t.querySelector(".fb-switcher-group");if(!n)throw new Error(`switcher "${e.name}": no .fb-switcher-group next to its hidden input`);return n}function Lo(e,t,n,r){var o;const{scopeRoot:l}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=l.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);a.forEach((i,d)=>{var s;if(d<n.length){const c=n[d]!=null?String(n[d]):"";i.value=c;const u=(s=i.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(f=>{const p=Fn(f);f.dataset.value===c?ft(f,p):pt(f,p)}),we(mt(i))}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=l.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const i=n!=null?String(n):"";a.value=i;const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(s=>{const c=Fn(s);s.dataset.value===i?ft(s,c):pt(s,c)}),we(mt(a))}}}const Mn=36,tt=20,We=16;function Ao(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
412
408
  .fb-toggle {
413
409
  position: relative;
414
410
  display: inline-block;
415
- width: ${cn}px;
416
- height: ${Xe}px;
417
- border-radius: ${Xe}px;
411
+ width: ${Mn}px;
412
+ height: ${tt}px;
413
+ border-radius: ${tt}px;
418
414
  background: var(--fb-border-color);
419
415
  transition: background-color var(--fb-transition-duration);
420
416
  flex-shrink: 0;
@@ -422,10 +418,10 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
422
418
  .fb-toggle::after {
423
419
  content: "";
424
420
  position: absolute;
425
- top: ${(Xe-Oe)/2}px;
426
- left: ${(Xe-Oe)/2}px;
427
- width: ${Oe}px;
428
- height: ${Oe}px;
421
+ top: ${(tt-We)/2}px;
422
+ left: ${(tt-We)/2}px;
423
+ width: ${We}px;
424
+ height: ${We}px;
429
425
  border-radius: 50%;
430
426
  background: #ffffff;
431
427
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
@@ -435,7 +431,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
435
431
  background: var(--fb-primary-color);
436
432
  }
437
433
  .fb-toggle.fb-on::after {
438
- transform: translateX(${cn-Oe-(Xe-Oe)}px);
434
+ transform: translateX(${Mn-We-(tt-We)}px);
439
435
  }
440
436
  .fb-toggle-row {
441
437
  display: flex;
@@ -488,7 +484,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
488
484
  font-family: serif;
489
485
  cursor: help;
490
486
  }
491
- `,e.head.appendChild(n)}function $t(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function Zr(e,t,n,r){var o;Gr(document);const a=t.state,l=ae(e,a,t),i=t.prefill[e.key],c=$t(i!==void 0?i:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.value=c?"true":"false";const f=document.createElement("div");f.className="fb-toggle-row",f.setAttribute("role","switch"),f.setAttribute("aria-checked",c?"true":"false"),l?f.setAttribute("aria-disabled","true"):f.tabIndex=0;const d=document.createElement("span");d.className="fb-toggle"+(c?" fb-on":""),d.setAttribute("aria-hidden","true"),f.appendChild(d);const u=document.createElement("div");u.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(u.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,u.appendChild(m)}if(f.appendChild(u),!l){const m=()=>{const b=s.value!=="true";s.value=b?"true":"false",d.classList.toggle("fb-on",b),f.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};f.addEventListener("click",b=>{var g;(g=b.target)!=null&&g.classList.contains("fb-toggle-info")||m()}),f.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),m())})}n.appendChild(s),n.appendChild(f)}function Qr(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][name="${t}"]`),l=(r=a==null?void 0:a.value)!=null?r:"";return{value:$t(l),errors:[]}}function eo(e,t,n,r){var o;const{scopeRoot:a}=r,l=a.querySelector(`input[type="hidden"][name="${t}"]`);if(!l)return;const i=$t(n);l.value=i?"true":"false";const c=(o=l.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(c){c.setAttribute("aria-checked",i?"true":"false");const s=c.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",i)}}function Re(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 Ue(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 dn(e,t){return t===1/0?!0:e<=t*1024*1024}function st(e,t){return dn(e.size,t)}function Ye(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Ge(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 to(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 ct(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:to(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function St(e,t){for(const n of e)ct(n,t)}const un="fb-file-styles";function $e(){if(typeof document=="undefined"||document.getElementById(un))return;const e=document.createElement("style");if(e.id=un,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
487
+ `,e.head.appendChild(n)}function Nt(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function To(e,t,n,r){var o;Ao(document);const l=t.state,a=ae(e,l,t),i=t.prefill[e.key],d=Nt(i!==void 0?i:e.default),s=document.createElement("input");s.type="hidden",s.name=r,s.setAttribute("data-boolean-field","true"),s.value=d?"true":"false";const c=document.createElement("div");c.className="fb-toggle-row",c.setAttribute("role","switch"),c.setAttribute("aria-checked",d?"true":"false"),a?c.setAttribute("aria-disabled","true"):c.tabIndex=0;const u=document.createElement("span");u.className="fb-toggle"+(d?" fb-on":""),u.setAttribute("aria-hidden","true"),c.appendChild(u);const f=document.createElement("div");f.className="fb-toggle-text";const p=document.createElement("div");if(p.className="fb-toggle-title",p.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const m=document.createElement("span");m.className="fb-toggle-info",m.textContent="i",m.title=e.description,p.appendChild(m)}if(f.appendChild(p),e.hint){const m=document.createElement("div");m.className="fb-toggle-subtitle",m.textContent=e.hint,f.appendChild(m)}if(c.appendChild(f),!a){const m=()=>{const g=s.value!=="true";s.value=g?"true":"false",u.classList.toggle("fb-on",g),c.setAttribute("aria-checked",g?"true":"false"),t.instance&&t.instance.triggerOnChange(r,g)};c.addEventListener("click",g=>{var x;(x=g.target)!=null&&x.classList.contains("fb-toggle-info")||m()}),c.addEventListener("keydown",g=>{(g.key===" "||g.key==="Enter")&&(g.preventDefault(),m())})}n.appendChild(s),n.appendChild(c)}function Fo(e,t,n){var r;const{scopeRoot:o}=n,l=o.querySelector(`input[type="hidden"][name="${t}"]`),a=(r=l==null?void 0:l.value)!=null?r:"";return{value:Nt(a),errors:[]}}function zo(e,t,n,r){var o;const{scopeRoot:l}=r,a=l.querySelector(`input[type="hidden"][name="${t}"]`);if(!a)return;const i=Nt(n);a.value=i?"true":"false";const d=(o=a.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(d){d.setAttribute("aria-checked",i?"true":"false");const s=d.querySelector(".fb-toggle");s&&s.classList.toggle("fb-on",i)}}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 Ve(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 Rn(e,t){return t===1/0?!0:e<=t*1024*1024}function ht(e,t){return Rn(e.size,t)}function nt(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function rt(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 Mo(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 bt(e,t){if(t.has(e))return;const n=e.split("/").pop()||"file";t.set(e,{name:n,type:Mo(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function qt(e,t){for(const n of e)bt(n,t)}const In="fb-file-styles";function Le(){if(typeof document=="undefined"||document.getElementById(In))return;const e=document.createElement("style");if(e.id=In,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
492
488
  @keyframes fb-spin { to { transform: rotate(360deg); } }
493
489
 
494
490
  /* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
@@ -735,14 +731,20 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
735
731
  padding: 6px;
736
732
  }
737
733
 
738
- /* \u2500\u2500\u2500 Clear-all row below multi grid \u2500\u2500\u2500 */
739
- .fb-clear-all-row {
734
+ /* \u2500\u2500\u2500 Footer row below multi grid: N/max counter + clear-all \u2500\u2500\u2500 */
735
+ .fb-multi-footer {
740
736
  margin-top: 10px;
741
737
  display: flex;
742
738
  align-items: center;
743
- justify-content: flex-end;
739
+ gap: 8px;
740
+ }
741
+ .fb-files-counter {
742
+ font-size: var(--fb-font-size-small, 12px);
743
+ color: var(--fb-text-secondary-color, #6b7280);
744
+ font-variant-numeric: tabular-nums;
744
745
  }
745
746
  .fb-clear-all-btn {
747
+ margin-left: auto;
746
748
  font-size: 12px;
747
749
  color: #94a3b8;
748
750
  background: none;
@@ -975,90 +977,86 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
975
977
  display: none;
976
978
  }
977
979
  }
978
- `,document.head.appendChild(t)}}function fn(){$e();const e=document.createElement("div");return e.className="fb-tile",e}function Se(e,t){var n,r;const o=(n=e.closest("[data-files-wrapper]"))==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=`
979
- color: var(--fb-error-color);
980
- font-size: var(--fb-font-size-small);
981
- margin-top: 0.25rem;
982
- `,a.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(a)}function Ze(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function no(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=k("removeElement",t),a.onclick=l=>{l.stopPropagation(),n()},o.appendChild(a),e.appendChild(o)}function ro(e,t){$e();const n=fn();n.classList.add("fb-tile-uploading"),n.className+=" fb-uploading-tile";const r=e.length>10?e.substring(0,8)+"\u2026":e;return n.innerHTML=`
980
+ `,document.head.appendChild(t)}}function Nn(){Le();const e=document.createElement("div");return e.className="fb-tile",e}function Ht(e){var t;const n=e.closest("[data-files-wrapper]"),r=n&&(t=Array.from(n.children).find(o=>o instanceof HTMLElement&&o.classList.contains("file-error-message")))!=null?t:null;return{wrapper:n,node:r}}function ke(e,t,n,r="action"){const{wrapper:o,node:l}=Ht(e);if(!o)return;let a=l;a||(a=zt(n,"file-error-message error-message"),o.appendChild(a)),Ze(a,"data-error-kind",r),a.textContent!==t&&(a.textContent=t),r==="action"?(Ze(a,"role","alert"),gn(o),bn(o,a)):(a.removeAttribute("role"),Rt(o,a,n))}function Be(e,t="action"){const{wrapper:n,node:r}=Ht(e);n&&(r==null?void 0:r.dataset.errorKind)===t&&Qe(n,r)}function Ro(e,t,n){const r=Tt(e,t,n);if(r===void 0)return;const{node:o}=Ht(e);if(n.readonly){Qe(e,o);return}if(r===null){Be(e,"validation");return}n.draftMarks&&o&&o.dataset.errorKind!=="validation"||ke(e,r,n.state,"validation")}function Io(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 l=document.createElement("button");l.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",l.textContent=k("removeElement",t),l.onclick=a=>{a.stopPropagation(),n()},o.appendChild(l),e.appendChild(o)}function No(e,t){Le();const n=Nn();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=`
983
981
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
984
982
  <div class="fb-spinner"></div>
985
- <div class="fb-tile-label">${se(r)}</div>
986
- <div class="fb-tile-uploading-text">${se(k("uploadingFile",t))}</div>
987
- </div>`,n}function Lt(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const a=e.querySelector(".fb-tiles-wrap");if(a)return a;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const l=document.createElement("div");l.className="fb-tiles-wrap",l.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const i=document.createElement("div");return i.className="fb-tile fb-tile-add",i.innerHTML="+",l.appendChild(i),e.appendChild(l),l}function Tt(e,t,n){e.innerHTML=`
983
+ <div class="fb-tile-label">${de(r)}</div>
984
+ <div class="fb-tile-uploading-text">${de(k("uploadingFile",t))}</div>
985
+ </div>`,n}function Bt(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const l=e.querySelector(".fb-tiles-wrap");if(l)return l;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const a=document.createElement("div");a.className="fb-tiles-wrap",a.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const i=document.createElement("div");return i.className="fb-tile fb-tile-add",i.innerHTML="+",a.appendChild(i),e.appendChild(a),a}function Dt(e,t,n){e.innerHTML=`
988
986
  <div class="flex flex-col items-center justify-center h-full text-gray-400">
989
987
  <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
990
988
  <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"/>
991
989
  </svg>
992
- <div class="text-sm text-center">${se(k("clickDragText",t))}</div>
990
+ <div class="text-sm text-center">${de(k("clickDragText",t))}</div>
993
991
 
994
992
  </div>
995
- `}const pn=new WeakMap;function dt(e,t){const n=pn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=l=>{l.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=l=>{l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},a=l=>{var i;l.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const c=(i=l.dataTransfer)==null?void 0:i.files;c&&t(c)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",a),pn.set(e,{dragover:r,dragleave:o,drop:a})}const oo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',lo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',io='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',ao='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',so='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function co(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function uo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function At(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:a,meta:l,replaceHandler:i,libraryHandler:c}=e,s=document.createElement("div");s.className="fb-tile-actions";const f=(d,u,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=d,m.title=u,m.setAttribute("aria-label",u),m.addEventListener("click",b=>{b.stopPropagation()}),m};if(i){const d=f(ao,k("replaceFile",r),"fb-tile-action-replace");d.addEventListener("click",()=>i()),s.appendChild(d)}if(c){const d=f(so,k("fromLibrary",r),"fb-tile-action-library");d.addEventListener("click",()=>c()),s.appendChild(d)}if(co(r,l)){const d=f(oo,k("downloadFile",r),"fb-tile-action-download");d.addEventListener("click",()=>{fo(o,a,r,l)}),s.appendChild(d)}if(uo(r,l)){const d=f(lo,k("openInNewTab",r),"fb-tile-action-open");d.addEventListener("click",()=>{po(o,r,l).catch(u=>{console.error("Open failed:",u)})}),s.appendChild(d)}if(t&&n){const d=f(io,k("removeElement",r),"fb-tile-action-remove");d.addEventListener("click",()=>{n()}),s.appendChild(d)}return s}const ut=new WeakMap;function Ft(e){let t=ut.get(e);return t||(t=URL.createObjectURL(e),ut.set(e,t)),t}function qe(e){if(!e)return;const t=ut.get(e);t&&(URL.revokeObjectURL(t),ut.delete(e))}function fo(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){xn(r.file,t||r.file.name);return}yn(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function po(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=Ft(n.file)),r&&window.open(r,"_blank")}let Ee=null,Me=null,Be=null,ft=null;function mo(){if(!Ee){Ee=document.createElement("div"),Ee.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",Ee.appendChild(e),Ee.addEventListener("mouseenter",hn),Ee.addEventListener("mouseleave",mn)}return Ee}function ho(e,t){const n=t.getBoundingClientRect(),r=350,o=6,a=8;let l;n.top-r-o>=a?l=n.top-r-o:n.bottom+o+r+a<=window.innerHeight?l=n.bottom+o:l=Math.max(a,Math.min(window.innerHeight-r-a,n.top));let i=n.left+n.width/2-r/2;i=Math.max(a,Math.min(window.innerWidth-r-a,i)),e.style.top=`${l}px`,e.style.left=`${i}px`}function mn(){Be!==null&&clearTimeout(Be),Be=setTimeout(()=>{Be=null,bn()},100)}function hn(){Be!==null&&(clearTimeout(Be),Be=null)}function bn(){Me!==null&&(clearTimeout(Me),Me=null),Ee&&Ee.parentNode&&(Ee.classList.remove("fb-tile-zoom-preview--visible"),Ee.parentNode.removeChild(Ee)),ft=null}function zt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{hn(),ft!==e&&bn(),ft=e,Me=setTimeout(()=>{Me=null;const o=mo(),a=o.querySelector(".fb-tile-actions");a&&a.remove();const l=o.querySelector(".fb-tile-zoom-preview-img");l.src=t,l.alt=n,r&&(o.appendChild(r.cloneNode(!0)),bo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",ho(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Me!==null?(clearTimeout(Me),Me=null,ft=null):mn()})}function bo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const a=n[o];a&&r.addEventListener("click",l=>{l.stopPropagation(),a.click()})})}function go(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const 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 vo(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function yo(e,t,n,r,o,a){const l=URL.createObjectURL(t),i=vo(e);return i.innerHTML=`
993
+ `}const qn=new WeakMap;function gt(e,t){const n=qn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},l=a=>{var i;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const d=(i=a.dataTransfer)==null?void 0:i.files;d&&t(d)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",l),qn.set(e,{dragover:r,dragleave:o,drop:l})}const qo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',Ho='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',Bo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',Do='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Oo='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function jo(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Uo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Ot(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:l,meta:a,replaceHandler:i,libraryHandler:d}=e,s=document.createElement("div");s.className="fb-tile-actions";const c=(u,f,p)=>{const m=document.createElement("button");return m.type="button",m.className=`fb-tile-action-btn ${p}`,m.innerHTML=u,m.title=f,m.setAttribute("aria-label",f),m.addEventListener("click",g=>{g.stopPropagation()}),m};if(i){const u=c(Do,k("replaceFile",r),"fb-tile-action-replace");u.addEventListener("click",()=>i()),s.appendChild(u)}if(d){const u=c(Oo,k("fromLibrary",r),"fb-tile-action-library");u.addEventListener("click",()=>d()),s.appendChild(u)}if(jo(r,a)){const u=c(qo,k("downloadFile",r),"fb-tile-action-download");u.addEventListener("click",()=>{Po(o,l,r,a)}),s.appendChild(u)}if(Uo(r,a)){const u=c(Ho,k("openInNewTab",r),"fb-tile-action-open");u.addEventListener("click",()=>{Wo(o,r,a).catch(f=>{console.error("Open failed:",f)})}),s.appendChild(u)}if(t&&n){const u=c(Bo,k("removeElement",r),"fb-tile-action-remove");u.addEventListener("click",()=>{n()}),s.appendChild(u)}return s}const vt=new WeakMap;function jt(e){let t=vt.get(e);return t||(t=URL.createObjectURL(e),vt.set(e,t)),t}function Me(e){if(!e)return;const t=vt.get(e);t&&(URL.revokeObjectURL(t),vt.delete(e))}function Po(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){Pn(r.file,t||r.file.name);return}Un(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function Wo(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=jt(n.file)),r&&window.open(r,"_blank")}let $e=null,Re=null,De=null,yt=null;function Vo(){if(!$e){$e=document.createElement("div"),$e.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",$e.appendChild(e),$e.addEventListener("mouseenter",Bn),$e.addEventListener("mouseleave",Hn)}return $e}function Ko(e,t){const n=t.getBoundingClientRect(),r=350,o=6,l=8;let a;n.top-r-o>=l?a=n.top-r-o:n.bottom+o+r+l<=window.innerHeight?a=n.bottom+o:a=Math.max(l,Math.min(window.innerHeight-r-l,n.top));let i=n.left+n.width/2-r/2;i=Math.max(l,Math.min(window.innerWidth-r-l,i)),e.style.top=`${a}px`,e.style.left=`${i}px`}function Hn(){De!==null&&clearTimeout(De),De=setTimeout(()=>{De=null,Dn()},100)}function Bn(){De!==null&&(clearTimeout(De),De=null)}function Dn(){Re!==null&&(clearTimeout(Re),Re=null),$e&&$e.parentNode&&($e.classList.remove("fb-tile-zoom-preview--visible"),$e.parentNode.removeChild($e)),yt=null}function Ut(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{Bn(),yt!==e&&Dn(),yt=e,Re=setTimeout(()=>{Re=null;const o=Vo(),l=o.querySelector(".fb-tile-actions");l&&l.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),_o(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",Ko(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Re!==null?(clearTimeout(Re),Re=null,yt=null):Hn()})}function _o(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const l=n[o];l&&r.addEventListener("click",a=>{a.stopPropagation(),l.click()})})}function Jo(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const l=new FileReader;l.onload=a=>{var i;o.src=((i=a.target)==null?void 0:i.result)||""},l.readAsDataURL(t),e.appendChild(o)}function Xo(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function Yo(e,t,n,r,o,l){const a=URL.createObjectURL(t),i=Xo(e);return i.innerHTML=`
996
994
  <div class="fb-video-preview-wrap">
997
- <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${l}">
998
- ${se(k("videoNotSupported",o))}
995
+ <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
996
+ ${de(k("videoNotSupported",o))}
999
997
  </video>
1000
998
  <div class="fb-video-btn-overlay">
1001
999
  <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
1002
- ${se(k("removeElement",o))}
1000
+ ${de(k("removeElement",o))}
1003
1001
  </button>
1004
1002
  <button class="fb-video-btn fb-video-btn-change change-file-btn">
1005
- ${se(k("changeButton",o))}
1003
+ ${de(k("changeButton",o))}
1006
1004
  </button>
1007
1005
  </div>
1008
1006
  </div>
1009
- `,xo(i,r,o,a),i}function xo(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=l=>{var i;l.stopPropagation(),(i=r==null?void 0:r.picker)==null||i.click()});const a=e.querySelector(".delete-file-btn");a&&(a.onclick=l=>{l.stopPropagation(),wo(e,t,n,r)})}function wo(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),e.innerHTML=`
1007
+ `,Go(i,r,o,l),i}function Go(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var i;a.stopPropagation(),(i=r==null?void 0:r.picker)==null||i.click()});const l=e.querySelector(".delete-file-btn");l&&(l.onclick=a=>{a.stopPropagation(),Zo(e,t,n,r)})}function Zo(e,t,n,r){var o;n.resourceIndex.delete(t);const l=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');l&&(l.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
1010
1008
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1011
1009
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1012
1010
  <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"/>
1013
1011
  </svg>
1014
- <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1012
+ <div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
1015
1013
  </div>
1016
- `,r!=null&&r.setupDrop&&r.setupDrop(e)}function gn(e,t,n){no(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=`
1014
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function On(e,t,n){Io(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=`
1017
1015
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1018
1016
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1019
1017
  <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"/>
1020
1018
  </svg>
1021
- <div style="font-size:0.875rem;text-align:center;">${se(k("clickDragText",n))}</div>
1019
+ <div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
1022
1020
  </div>
1023
- `})}async function Co(e,t,n,r,o,a,l){var i,c,s;!t.file||!(t.file instanceof File)||((i=t.type)!=null&&i.startsWith("image/")?go(e,t.file,n,a):(c=t.type)!=null&&c.startsWith("video/")?e=yo(e,t.file,t.type,r,a,l):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${se(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&gn(e,r,a))}function Eo(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(k("videoNotSupported",n))),e.appendChild(r)}async function ko(e,t,n,r,o){var a;if(!o.config.getThumbnail){Tt(e,o);return}try{const l=await o.config.getThumbnail(t);if(l)if(we(e),(a=r==null?void 0:r.type)!=null&&a.startsWith("video/"))Eo(e,l,o);else{const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n||k("previewAlt",o),i.src=l,e.appendChild(i)}else Tt(e,o)}catch(l){console.error("Failed to get thumbnail:",l),e.innerHTML=`
1021
+ `})}async function Qo(e,t,n,r,o,l,a){var i,d,s;!t.file||!(t.file instanceof File)||((i=t.type)!=null&&i.startsWith("image/")?Jo(e,t.file,n,l):(d=t.type)!=null&&d.startsWith("video/")?e=Yo(e,t.file,t.type,r,l,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${de(n)}</div></div>`,!o&&!((s=t.type)!=null&&s.startsWith("video/"))&&On(e,r,l))}function el(e,t,n){const r=document.createElement("video");r.style.cssText="width:100%;height:100%;object-fit:contain;",r.controls=!0,r.preload="metadata",r.muted=!0,r.src=t,r.appendChild(document.createTextNode(k("videoNotSupported",n))),e.appendChild(r)}async function tl(e,t,n,r,o){var l;if(!o.config.getThumbnail){Dt(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(Ee(e),(l=r==null?void 0:r.type)!=null&&l.startsWith("video/"))el(e,a,o);else{const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n||k("previewAlt",o),i.src=a,e.appendChild(i)}else Dt(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
1024
1022
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1025
1023
  <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1026
1024
  <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"/>
1027
1025
  </svg>
1028
- <div style="font-size:0.875rem;text-align:center;">${se(n||k("previewUnavailable",o))}</div>
1026
+ <div style="font-size:0.875rem;text-align:center;">${de(n||k("previewUnavailable",o))}</div>
1029
1027
  </div>
1030
- `}}async function Mt(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}");we(e);const c=n.resourceIndex.get(t);if(c&&c.file&&c.file instanceof File)await Co(e,c,a,t,l,n,i);else{await ko(e,t,a,c,n);const s=(o=c==null?void 0:c.type)==null?void 0:o.startsWith("video/");!l&&!s&&gn(e,t,n)}}function $o(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 Nt(e,t,n,r={}){var o,a;const l=t.resourceIndex.get(e),i=$o(e,l,n),{canRemove:c=!1,removeHandler:s=null}=r,f=((o=l==null?void 0:l.type)==null?void 0:o.startsWith("image/"))||!!i.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),d=((a=l==null?void 0:l.type)==null?void 0:a.startsWith("video/"))||!!i.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),u=fn();u.classList.add("fb-tile-resource"),u.style.cursor="pointer",i&&(u.title=i);const p=(l==null?void 0:l.file)instanceof File?Ft(l.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;u.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,i):yn(e,i,t).catch(y=>{console.error("Download failed:",y)})};const b=At({canRemove:c,removeHandler:s,state:t,resourceId:e,fileName:i,meta:l}),g=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},E=()=>{u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',u.appendChild(b)};if(f){const h=await g();if(h){const y=document.createElement("img");y.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",y.alt=i,y.src=h,u.appendChild(y),u.appendChild(b),zt(u,h,i,b)}else E()}else if(d)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(u.innerHTML=`
1031
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(i)}" src="${h}">
1028
+ `}}async function Pt(e,t,n,r={}){var o;const{fileName:l="",isReadonly:a=!1,deps:i=null}=r;if(!a&&i&&(!i.picker||!i.fileUploadHandler||!i.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");Ee(e);const d=n.resourceIndex.get(t);if(d&&d.file&&d.file instanceof File)await Qo(e,d,l,t,a,n,i);else{await tl(e,t,l,d,n);const s=(o=d==null?void 0:d.type)==null?void 0:o.startsWith("video/");!a&&!s&&On(e,t,n)}}function nl(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 Wt(e,t,n,r={}){var o,l;const a=t.resourceIndex.get(e),i=nl(e,a,n),{canRemove:d=!1,removeHandler:s=null}=r,c=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!i.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((l=a==null?void 0:a.type)==null?void 0:l.startsWith("video/"))||!!i.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=Nn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",i&&(f.title=i);const p=(a==null?void 0:a.file)instanceof File?jt(a.file):null,m=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):p;f.onclick=async()=>{const h=await m();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,i):Un(e,i,t).catch(b=>{console.error("Download failed:",b)})};const g=Ot({canRemove:d,removeHandler:s,state:t,resourceId:e,fileName:i,meta:a}),x=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return p},S=()=>{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(g)};if(c){const h=await x();if(h){const b=document.createElement("img");b.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",b.alt=i,b.src=h,f.appendChild(b),f.appendChild(g),Ut(f,h,i,g)}else S()}else if(u)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
1029
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${de(i)}" src="${h}">
1032
1030
  <div class="fb-video-overlay">
1033
1031
  <div class="fb-play-btn" style="width:22px;height:22px;">
1034
1032
  <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
1035
1033
  </div>
1036
- </div>`,u.appendChild(b)):(u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b))}catch(h){u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b)}else u.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',u.appendChild(b);else{if(t.config.getThumbnail)try{const y=await t.config.getThumbnail(e);if(y){const v=document.createElement("img");return v.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",v.alt=i||e,v.src=y,u.appendChild(v),u.appendChild(b),u}}catch(y){}const h=i?`<div class="fb-tile-label">${se(i.length>10?i.substring(0,8)+"\u2026":i)}</div>
1037
- <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>`:"";u.innerHTML=`
1034
+ </div>`,f.appendChild(g)):(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(g))}catch(h){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(g)}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(g);else{if(t.config.getThumbnail)try{const b=await t.config.getThumbnail(e);if(b){const v=document.createElement("img");return v.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",v.alt=i||e,v.src=b,f.appendChild(v),f.appendChild(g),f}}catch(b){}const h=i?`<div class="fb-tile-label">${de(i.length>10?i.substring(0,8)+"\u2026":i)}</div>
1035
+ <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=`
1038
1036
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1039
1037
  <div style="font-size:36px;">\u{1F4C1}</div>
1040
1038
  ${h}
1041
- </div>`,u.appendChild(b)}return u}async function So(e,t,n,r){var o,a,l;const i=n.resourceIndex.get(t),c=(a=(o=i==null?void 0:i.name)!=null?o:t.split("/").pop())!=null?a:"",s=(l=r.onRemove)!=null?l:null,f=await Nt(t,n,c,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),we(e),e.appendChild(f)}async function vn(e,t,n,r,o){var a,l;if((a=n==null?void 0:n.type)!=null&&a.startsWith("image/")){if(n.file&&n.file instanceof File){const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n.name,i.src=Ft(n.file),e.appendChild(i),zt(e,i.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const i=await r.config.getThumbnail(t);if(i){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=i,e.appendChild(c),zt(e,i,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(i){const c=i instanceof Error?i:new Error(String(i));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 i=URL.createObjectURL(n.file);e.innerHTML=`
1039
+ </div>`,f.appendChild(g)}return f}async function rl(e,t,n,r){var o,l,a;const i=n.resourceIndex.get(t),d=(l=(o=i==null?void 0:i.name)!=null?o:t.split("/").pop())!=null?l:"",s=(a=r.onRemove)!=null?a:null,c=await Wt(t,n,d,{canRemove:!0,removeHandler:s});e.className="file-preview-container",e.removeAttribute("style"),Ee(e),e.appendChild(c)}async function jn(e,t,n,r,o){var l,a;if((l=n==null?void 0:n.type)!=null&&l.startsWith("image/")){if(n.file&&n.file instanceof File){const i=document.createElement("img");i.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",i.alt=n.name,i.src=jt(n.file),e.appendChild(i),Ut(e,i.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const i=await r.config.getThumbnail(t);if(i){const d=document.createElement("img");d.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",d.alt=n.name,d.src=i,e.appendChild(d),Ut(e,i,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(i){const d=i instanceof Error?i:new Error(String(i));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const i=URL.createObjectURL(n.file);e.innerHTML=`
1042
1040
  <video style="width:100%;height:100%;" preload="metadata" muted src="${i}"></video>
1043
1041
  <div class="fb-video-overlay">
1044
1042
  <div class="fb-play-btn" style="width:20px;height:20px;">
1045
1043
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1046
1044
  </div>
1047
1045
  </div>`}else if(r.config.getThumbnail)try{const i=await r.config.getThumbnail(t);i?e.innerHTML=`
1048
- <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${se(n.name)}" src="${i}">
1046
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${de(n.name)}" src="${i}">
1049
1047
  <div class="fb-video-overlay">
1050
1048
  <div class="fb-play-btn" style="width:20px;height:20px;">
1051
1049
  <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1052
1050
  </div>
1053
- </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(i){const c=i instanceof Error?i:new Error(String(i));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 Lo(e,t,n,o)}function Lo(e,t,n,r){var o,a;const l=(a=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?a:"";l&&(e.title=l);const i=l?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${se(l)}</div>`:"";e.innerHTML=`
1051
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(i){const d=i instanceof Error?i:new Error(String(i));r.config.onThumbnailError&&r.config.onThumbnailError(d,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>';o&&e.appendChild(o)}else ol(e,t,n,o)}function ol(e,t,n,r){var o,l;const a=(l=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?l:"";a&&(e.title=a);const i=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${de(a)}</div>`:"";e.innerHTML=`
1054
1052
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1055
1053
  <div style="font-size:36px;">\u{1F4C1}</div>
1056
1054
  ${i}
1057
- </div>`,r&&e.appendChild(r)}async function yn(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,a=await fetch(o);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const l=await a.blob();xn(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 xn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`,{cause:n})}}async function wn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function To(e){var t,n,r;const{file:o,container:a,fieldName:l,state:i,deps:c=null,instance:s=null,allowedExtensions:f=[],allowedMimes:d=[],maxSizeMB:u=1/0}=e;if(!Ue(o.name,f)){const h=f.join(", ");Se(a,k("invalidFileExtension",i,{name:o.name,formats:h}));return}if(!Ge(o.type,d)){const h=d.join(", ");Se(a,k("invalidFileMime",i,{name:o.name,type:o.type,mimes:h}));return}if(!st(o,u)){Se(a,k("fileTooLarge",i,{name:o.name,maxSize:u}));return}Ze(a);const p=(t=a.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;$e(),a.innerHTML=`
1055
+ </div>`,r&&e.appendChild(r)}async function Un(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,l=await fetch(o);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const a=await l.blob();Pn(a,t)}else throw new Error("No download URL available for resource")}catch(r){const o=r instanceof Error?r:new Error(String(r));throw n.config.onDownloadError&&n.config.onDownloadError(o,e,t),console.error(`File download failed for ${t}:`,o),o}}function Pn(e,t){try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>{URL.revokeObjectURL(n)},100)}catch(n){throw new Error(`Blob download failed: ${n.message}`,{cause:n})}}async function Wn(e,t){if(!t.config.uploadFile)throw new Error("No upload handler configured. Set uploadHandler via FormBuilder.setUploadHandler()");try{const n=await t.config.uploadFile(e);if(typeof n!="string")throw new Error("Upload handler must return a string resource ID");return n}catch(n){const r=n instanceof Error?n:new Error(String(n));t.config.onUploadError&&t.config.onUploadError(r,e);const o=new Error(`File upload failed: ${r.message}`);throw o.cause=r,o}}async function ll(e){var t,n,r;const{file:o,container:l,fieldName:a,state:i,deps:d=null,instance:s=null,allowedExtensions:c=[],allowedMimes:u=[],maxSizeMB:f=1/0}=e;if(!Ve(o.name,c)){const h=c.join(", ");ke(l,k("invalidFileExtension",i,{name:o.name,formats:h}),i);return}if(!rt(o.type,u)){const h=u.join(", ");ke(l,k("invalidFileMime",i,{name:o.name,type:o.type,mimes:h}),i);return}if(!ht(o,f)){ke(l,k("fileTooLarge",i,{name:o.name,maxSize:f}),i);return}Be(l);const p=(t=l.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),m=(p==null?void 0:p.value)||null;Le(),l.innerHTML=`
1058
1056
  <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
1059
1057
  <div class="fb-spinner"></div>
1060
- <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${se(k("uploadingFile",i))}</div>
1061
- </div>`;let b;try{b=await wn(o,i)}catch(h){throw m&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,m):c!=null&&c.onRemove?c.onRemove():Tt(a,i),h}i.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=i.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=l,(r=a.parentElement)==null||r.appendChild(g)),g.value=b;const E=o.type.startsWith("video/");!E&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,b):!E&&c?So(a,b,i,c).catch(console.error):Mt(a,b,i,{fileName:o.name,isReadonly:!1,deps:c}).catch(console.error),s&&!i.config.readonly&&s.triggerOnChange(l,b)}function Ao(e,t,n,r){const o=e.filter(m=>!Ue(m.name,n.allowedExtensions)),a=e.filter(m=>Ue(m.name,n.allowedExtensions)),l=a.filter(m=>!Ge(m.type,n.allowedMimes)),i=a.filter(m=>Ge(m.type,n.allowedMimes)),c=i.filter(m=>!st(m,n.maxSize)),s=i.filter(m=>st(m,n.maxSize)),f=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),d=s.slice(0,f),u=s.length-d.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),b=l.map(g=>g.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:l.map(g=>g.type).join(", "),mimes:m}))}if(c.length>0){const m=c.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return u>0&&p.push(k("filesLimitExceeded",r,{skipped:u,max:n.maxCount})),{accepted:d,errorMessage:p.join(" \u2022 ")}}async function Fo(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:a,buildSuccessTile:l,prepareForUpload:i}=e;if(r&&a){const f=Lt(r),d=(t=f.querySelector(".fb-multi-add-tile-js"))!=null?t:f.querySelector(".fb-tile-add");d&&(d.style.display="none")}i==null||i();const c=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(f,d)=>{const u=ro(f.name,o);r&&Lt(r).appendChild(u);try{const p=await wn(f,o);o.resourceIndex.set(p,{name:f.name,type:f.type,size:f.size,uploadedAt:new Date,file:f}),c[d]=p,l&&u.parentNode?u.replaceWith(l(p)):u.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,g=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:f,error:g}),u.remove()}})),{failures:s,orderedIds:c}}function zo(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Cn(e,t,n,r){const{resourceIds:o,state:a,updateCallback:l,constraints:i,pathKey:c,instance:s,buildSuccessTile:f,prepareForUpload:d,coordinator:u}=e,{accepted:p,errorMessage:m}=Ao(t,u.getOccupiedCount(),i,a);r&&(m?Se(r,m):Ze(r));const b=u.beginBatch(p.length),g=u.getOccupiedCount()>=i.maxCount,{failures:E,orderedIds:h}=await Fo({accepted:p,listEl:n,state:a,shouldHideAddTile:g,buildSuccessTile:f,prepareForUpload:d});b.setResults(h),s&&c&&!a.config.readonly&&s.triggerOnChange(c,o);const{wasLast:y}=b.end();if(y&&l(),r){const v=zo(m,E,a);v?Se(r,v):Ze(r)}}function Mo(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function No(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,a=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),a,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const i=Re(e.accept);return i.length>0?{extensions:i}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],a=r.map(i=>i.toLowerCase());if(a.length===0&&o.length===0)return;const l={};return a.length>0&&(l.extensions=a),o.length>0&&(l.mime=o),l}function kn(e,t,n,r,o){if(!Ue(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Ge(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return dn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function Sn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Io(e){var t;const{state:n,element:r,wrapper:o,fieldPath:a,resourceIds:l,maxCount:i,updateCallback:c,instance:s,coordinator:f,list:d,buildSuccessTile:u}=e;if(!n.config.pickExistingFiles)return;const p=Re(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,g=f.getAllKnownRids(),E=new Set(g),h=i===1/0?1/0:Math.max(0,i-f.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:a,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:g})}catch(H){Se(o,Sn(H,n));return}if(y.length===0)return;const v=new Set,C=y.filter(H=>E.has(H.resourceId)||v.has(H.resourceId)?!1:(v.add(H.resourceId),!0)).filter(H=>kn(H,p,m,b,n)===null),w=i===1/0?C.length:Math.max(0,i-f.getOccupiedCount()),x=C.slice(0,w),S=C.length-x.length;if(x.length===0){S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));return}Ze(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));for(const H of x)$n(H,n);const z=x.map(H=>H.resourceId),ee=f.beginBatch(x.length);ee.setResults(z),n.config.readonly||s.triggerOnChange(a,l);const{wasLast:K}=ee.end();if(K)c();else{const H=Lt(d);for(const V of z)H.appendChild(u(V))}}async function Ro(e,t,n,r,o,a,l,i){var c,s;if(!e.config.pickExistingFiles)return;const f=Re(t.accept),d=Ye(t.accept),u=(c=t.maxSize)!=null?c:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:En(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,f,d,u,e);if(b!==null){Se(n,b);return}Ze(n),$n(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const E=g.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),g.value=m.resourceId,await l(m.resourceId),e.config.readonly||i.triggerOnChange(a,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function qo(e,t,n,r,o,a,l){var i;ct(e,o.resourceIndex);const c=o.resourceIndex.get(e);(i=c==null?void 0:c.type)!=null&&i.startsWith("video/")?Mt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):It(t,e,o,a,l);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Bo(e,t,n,r,o=!1,a=""){$e();const l=document.createElement("div");l.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const i=document.createElement("button");i.type="button",i.className="fb-wide-tile-upload fb-file-dropzone";const c=document.createElement("span");c.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",c.innerHTML=Ln,i.appendChild(c);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),i.appendChild(s),a){const f=document.createElement("div");f.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",f.textContent=a,i.appendChild(f)}if(i.onclick=f=>{f.stopPropagation(),n()},l.appendChild(i),t&&r){const f=document.createElement("button");f.type="button",f.className="fb-wide-tile-library fb-file-library-card";const d=document.createElement("span");d.className="fb-wide-tile-library-icon",d.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d);const u=document.createElement("div");u.className="fb-wide-tile-library-label",u.style.cssText="font-size:13px;font-weight:600;text-align:center;",u.textContent=k("fromLibrary",e),f.appendChild(u);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),f.appendChild(p),f.onclick=m=>{m.stopPropagation(),r()},l.appendChild(f)}return An(l,{onEnter:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("dropToUpload",e))},onLeave:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),l}function An(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function It(e,t,n,r,o){var a,l;const i=n.resourceIndex.get(t);if((a=i==null?void 0:i.type)!=null&&a.startsWith("video/")){Mt(e,t,n,{fileName:(l=i==null?void 0:i.name)!=null?l:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const c=document.createElement("div");c.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",c.appendChild(s);const f=Rt(t,n,!!r.onRemove,r.onRemove?()=>{var d;return(d=r.onRemove)==null?void 0:d.call(r)}:null,o);for(s.appendChild(f),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(c)}function Ho(e,t,n,r,o=!1){const a=document.createElement("div");a.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const l=document.createElement("button");l.type="button",l.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const i=document.createElement("span");i.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",i.innerHTML=Ln,l.appendChild(i);const c=document.createElement("span");if(c.className="fb-multi-add-label",c.style.cssText="font-size:11px;font-weight:600;",c.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),l.appendChild(c),l.onclick=s=>{s.stopPropagation(),n()},a.appendChild(l),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",a.appendChild(s);const f=document.createElement("button");f.type="button",f.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",f.setAttribute("aria-label",k("fromLibrary",e));const d=document.createElement("span");d.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d),f.appendChild(document.createTextNode(k("fromLibrary",e))),f.onclick=u=>{u.stopPropagation(),r()},a.appendChild(f)}return a}function Rt(e,t,n,r,o){var a,l,i;$e();const c=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const f=At({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=c==null?void 0:c.name)!=null?a:"",meta:c,replaceHandler:(l=o==null?void 0:o.replaceHandler)!=null?l:null,libraryHandler:(i=o==null?void 0:o.libraryHandler)!=null?i:null});return vn(s,e,c,t,f).catch(d=>{console.error("Failed to render tile:",d)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Do(e,t,n){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=a=>{a.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const Qe=new WeakMap,qt=new WeakMap;function zn(e){const t=qt.get(e);t!==void 0&&(cancelAnimationFrame(t),qt.delete(e))}function jo(e){const t=Qe.get(e);t&&(t.disconnect(),Qe.delete(e)),zn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Oo(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:l,isReadonly:i=!1,onLibraryPick:c,onClearAll:s,openPicker:f}=e;$e();const d=n.closest("[data-files-wrapper]");d&&(d.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const u=Qe.get(n);for(u&&(u.disconnect(),Qe.delete(n)),zn(n);n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=l!=null?l:1/0,b=m!==1/0&&p.length>=m,g=!i&&typeof c=="function",E=f!=null?f:(()=>{var w;const x=(w=n.closest("[data-files-wrapper]"))==null?void 0:w.querySelector('input[type="file"]');x&&x.click()});if(i){if(p.length===0){const w=document.createElement("div");w.className="fb-tile-empty-text",w.textContent=k("noFilesSelected",o),n.appendChild(w)}else{const w=document.createElement("div");w.className="fb-multi-readonly-grid",n.appendChild(w);for(const x of p){const S=o.resourceIndex.get(x),z=document.createElement("div");z.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",z.dataset.resourceId=x;const ee=At({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});vn(z,x,S,o,ee).catch(console.error),z.onclick=async()=>{var K;let H=null;o.config.getDownloadUrl?H=o.config.getDownloadUrl(x):o.config.getThumbnail?H=await o.config.getThumbnail(x):(S==null?void 0:S.file)instanceof File&&(H=URL.createObjectURL(S.file)),H?window.open(H,"_blank"):o.config.downloadFile&&o.config.downloadFile(x,(K=S==null?void 0:S.name)!=null?K:"")},w.appendChild(z)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const y=document.createElement("div");y.className="fb-multi-grid fb-tiles-wrap",h.appendChild(y),n.appendChild(h);for(let w=0;w<p.length;w++){const x=p[w],S=Rt(x,o,a!==null,a?()=>a(x):null);y.appendChild(S)}if(!b){const w=Ho(o,g,E,c!=null?c:null);y.appendChild(w)}const v=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=v%x,z=S===0?0:x-S,ee=m===1/0?z:Math.max(0,m-v),K=Math.min(z,ee),H=y.querySelectorAll(".fb-multi-placeholder");if(H.length>K)for(let V=H.length-1;V>=K;V--)H[V].remove();else if(H.length<K)for(let V=H.length;V<K;V++)y.appendChild(Fn())};if((m===1/0||m>v)&&y.appendChild(Fn()),qt.set(n,requestAnimationFrame(C)),typeof ResizeObserver!="undefined"){const w=new ResizeObserver(()=>C());w.observe(y),Qe.set(n,w)}if(An(h,{activeClass:"fb-drag-over",onEnter:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.add("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.add("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("dropToUpload",o))}},onLeave:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.remove("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.remove("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("clickDragTextMultiple",o))}}}),s){const w=Do(o,p.length,s);w&&n.appendChild(w)}}function Uo(e,t,n,r){var o,a;const l=t.state,i=document.createElement("div");i.className="fb-row",i.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.style.display="none",c.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const f=t.prefill[e.key],d=Re(e.accept),u=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){c.click()},dragHandler(h){h.length>0&&To({file:h[0],container:s,fieldName:r,state:l,deps:g(),instance:t.instance,allowedExtensions:d,allowedMimes:u,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=i.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&qe((h=l.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(l.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:l.config.uploadFile?()=>c.click():null,libraryHandler:h?()=>{Ro(l,e,s,i,r,r,async y=>{It(s,y,l,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:c,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{It(h,y,l,g(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Bo(l,h!==null,m.fileUploadHandler,h,!1,Le(e,l));s.appendChild(y),dt(s,m.dragHandler)};if(f){qo(f,s,r,i,l,g(),b());const h=l.resourceIndex.get(f);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&dt(s,m.dragHandler)}else E();c.onchange=()=>{c.files&&c.files.length>0&&m.dragHandler(c.files)},i.appendChild(s),i.appendChild(c),n.appendChild(i)}function Mn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Nn(e,t,n,r,o){var a,l;const i=t.state,c=document.createElement("div");c.className="fb-row",c.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=Mn(e.accept);const f=document.createElement("div");f.className="files-list-wrapper";const d=document.createElement("div");d.className="files-list",c.appendChild(s),c.appendChild(f),f.appendChild(d);const u=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];St(u,i.resourceIndex),c.dataset.resourceIds=JSON.stringify(u);const p={maxCount:o,allowedExtensions:Re(e.accept),allowedMimes:Ye(e.accept),maxSize:(l=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?l:1/0},m=()=>{s.click()},b=i.config.pickExistingFiles&&!e.disableLibrary?()=>{Io({state:i,element:e,wrapper:c,fieldPath:r,resourceIds:u,maxCount:o,updateCallback:g,instance:t.instance,coordinator:z,list:d,buildSuccessTile:ee}).catch(V=>{console.error("Library pick failed:",V)})}:null;function g(){const V=ae(e,i);Oo({container:d,rids:u,state:i,onRemove:V?null:ne=>{var R,_;qe((R=i.resourceIndex.get(ne))==null?void 0:R.file);const ie=u.indexOf(ne);ie>-1&&u.splice(ie,1),z.hasInFlightBatches()?(x.add(ne),(_=d.querySelector(`[data-resource-id="${ne}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},maxCount:o<1/0?o:void 0,isReadonly:V,onLibraryPick:V?null:b,onClearAll:V?void 0:()=>{var ne,R;for(const _ of u)qe((ne=i.resourceIndex.get(_))==null?void 0:ne.file);if(u.splice(0),z.hasInFlightBatches()){const _=d.querySelectorAll("[data-resource-id]");for(const ie of _){const pe=ie.dataset.resourceId;pe&&(qe((R=i.resourceIndex.get(pe))==null?void 0:R.file),x.add(pe)),ie.remove()}c.dataset.resourceIds=JSON.stringify(u)}else g();t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},openPicker:m})}let E=0,h=0,y=0,v=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var V;C.has(v);){const ne=v,R=C.get(ne);C.delete(ne),v+=1;const _=(V=w.get(ne))!=null?V:0;w.delete(ne),E-=_;for(const ie of R)if(ie!==null){if(x.has(ie)){x.delete(ie);continue}u.push(ie)}}c.dataset.resourceIds=JSON.stringify(u)},z={getOccupiedCount:()=>u.length+E,getAllKnownRids:()=>{const V=[...u];for(const ne of C.values())for(const R of ne)R!==null&&V.push(R);return V},hasInFlightBatches:()=>h>0||w.size>0,wasRemovedDuringBatch:V=>x.has(V),beginBatch:V=>{E+=V,h+=1;const ne=y++;return w.set(ne,V),{setResults:R=>{C.set(ne,R),S()},end:()=>{h-=1;const R=h===0&&w.size===0;return R&&x.clear(),{wasLast:R}}}}},ee=V=>{const ne=ae(e,i);return Rt(V,i,!ne,ne?null:()=>{var R,_,ie;qe((R=i.resourceIndex.get(V))==null?void 0:R.file);const pe=u.indexOf(V);if(pe>-1){u.splice(pe,1),z.hasInFlightBatches()?(x.add(V),(_=d.querySelector(`[data-resource-id="${V}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u);return}x.add(V),(ie=d.querySelector(`[data-resource-id="${V}"]`))==null||ie.remove(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)})},K=()=>jo(d),H={resourceIds:u,state:i,updateCallback:g,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:ee,prepareForUpload:K,coordinator:z};Mo({...H,filesContainer:f}),No({...H,filesPicker:s}),g(),n.appendChild(c)}function Po(e,t,n,r){Nn(e,t,n,r,1/0)}function Wo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Vo(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 Ko(e,t,n,r,o){var a,l;const i="minCount"in n&&(a=n.minCount)!=null?a:0,c="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<i&&o.push(`${e}: ${k("minFiles",r,{min:i})}`),t.length>c&&o.push(`${e}: ${k("maxFiles",r,{max:c})}`)}function In(e,t,n,r,o){var a,l;const i="accept"in n?n.accept:void 0,c=Re(i),s=Ye(i);if(c.length===0&&s.length===0)return;const f=c.join(", "),d=s.join(", ");for(const u of t){const p=r.resourceIndex.get(u),m=(a=p==null?void 0:p.name)!=null?a:u;if(c.length>0&&!Ue(m,c)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:f})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(l=p==null?void 0:p.type)!=null?l:"";Ge(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:d})}`)}}}function Rn(e,t,n,r,o){var a;const l="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(l!==1/0)for(const i of t){const c=r.resourceIndex.get(i);c&&c.size>l*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:c.name,maxSize:l})}`)}}function _o(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:l}=n,i=[],c=De(a,t),s=Vo(r,c);return o||(Ko(t,s,e,l,i),In(t,s,e,l,i),Rn(t,s,e,l,i)),{value:s,errors:i}}function Jo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:l}=n,i=[],c=o.querySelector(`input[name="${t}"][type="hidden"]`),s=(r=c==null?void 0:c.value)!=null?r:"";return!a&&e.required&&s===""?(i.push(`${t}: ${k("required",l)}`),{value:null,errors:i}):(!a&&s!==""&&(In(t,[s],e,l,i),Rn(t,[s],e,l,i)),{value:s||null,errors:i})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?_o(e,t,n):Jo(e,t,n)}function Xo(e,t,n,r){const o=t.state,a=t.prefill[e.key],l=typeof a=="string"?a:"";if(l){St([l],o.resourceIndex);const i=document.createElement("input");i.type="hidden",i.name=r,i.value=l,n.appendChild(i),Nt(l,o).then(c=>{c.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(c)}).catch(console.error)}else n.appendChild(Yo(o))}function Yo(e){$e();const t=document.createElement("div");return t.style.cssText=`
1058
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${de(k("uploadingFile",i))}</div>
1059
+ </div>`;let g;try{g=await Wn(o,i)}catch(h){throw m&&d!=null&&d.onAfterUpload?d.onAfterUpload(l,m):d!=null&&d.onRemove?d.onRemove():Dt(l,i),h}i.resourceIndex.set(g,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==g&&Me((n=i.resourceIndex.get(m))==null?void 0:n.file);let x=p;x||(x=document.createElement("input"),x.type="hidden",x.name=a,(r=l.parentElement)==null||r.appendChild(x)),x.value=g;const S=o.type.startsWith("video/");!S&&d!=null&&d.onAfterUpload?d.onAfterUpload(l,g):!S&&d?rl(l,g,i,d).catch(console.error):Pt(l,g,i,{fileName:o.name,isReadonly:!1,deps:d}).catch(console.error),s&&!i.config.readonly&&s.triggerOnChange(a,g)}function il(e,t,n,r){const o=e.filter(m=>!Ve(m.name,n.allowedExtensions)),l=e.filter(m=>Ve(m.name,n.allowedExtensions)),a=l.filter(m=>!rt(m.type,n.allowedMimes)),i=l.filter(m=>rt(m.type,n.allowedMimes)),d=i.filter(m=>!ht(m,n.maxSize)),s=i.filter(m=>ht(m,n.maxSize)),c=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),u=s.slice(0,c),f=s.length-u.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),g=o.map(x=>x.name).join(", ");p.push(k("invalidFileExtension",r,{name:g,formats:m}))}if(a.length>0){const m=n.allowedMimes.join(", "),g=a.map(x=>x.name).join(", ");p.push(k("invalidFileMime",r,{name:g,type:a.map(x=>x.type).join(", "),mimes:m}))}if(d.length>0){const m=d.map(g=>g.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return f>0&&p.push(k("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:u,errorMessage:p.join(" \u2022 ")}}async function al(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:l,buildSuccessTile:a,prepareForUpload:i}=e;if(r&&l){const c=Bt(r),u=(t=c.querySelector(".fb-multi-add-tile-js"))!=null?t:c.querySelector(".fb-tile-add");u&&(u.style.display="none")}i==null||i();const d=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(c,u)=>{const f=No(c.name,o);r&&Bt(r).appendChild(f);try{const p=await Wn(c,o);o.resourceIndex.set(p,{name:c.name,type:c.type,size:c.size,uploadedAt:new Date,file:c}),d[u]=p,a&&f.parentNode?f.replaceWith(a(p)):f.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),g=m.cause,x=g instanceof Error?g:g!==void 0?new Error(String(g)):m;s.push({file:c,error:x}),f.remove()}})),{failures:s,orderedIds:d}}function sl(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Vn(e,t,n,r){const{resourceIds:o,state:l,updateCallback:a,constraints:i,pathKey:d,instance:s,buildSuccessTile:c,prepareForUpload:u,coordinator:f}=e,{accepted:p,errorMessage:m}=il(t,f.getOccupiedCount(),i,l);r&&(m?ke(r,m,l):Be(r));const g=f.beginBatch(p.length),x=f.getOccupiedCount()>=i.maxCount,{failures:S,orderedIds:h}=await al({accepted:p,listEl:n,state:l,shouldHideAddTile:x,buildSuccessTile:c,prepareForUpload:u});g.setResults(h),s&&d&&!l.config.readonly&&s.triggerOnChange(d,o);const{wasLast:b}=g.end();b&&a();const v=sl(m,S,l);r&&v&&ke(r,v,l)}function dl(e){const{filesContainer:t}=e;gt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Vn(e,Array.from(n),o,t)})}function cl(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,l=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Vn(e,Array.from(t.files),l,o),t.value=""}}function Kn(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const i=He(e.accept);return i.length>0?{extensions:i}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],l=r.map(i=>i.toLowerCase());if(l.length===0&&o.length===0)return;const a={};return l.length>0&&(a.extensions=l),o.length>0&&(a.mime=o),a}function _n(e,t,n,r,o){if(!Ve(e.name,t)){const l=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:l})}if(!rt(e.type,n)){const l=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:l})}return Rn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function Jn(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 Xn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function ul(e){var t;const{state:n,element:r,wrapper:o,fieldPath:l,resourceIds:a,maxCount:i,updateCallback:d,instance:s,coordinator:c,list:u,buildSuccessTile:f}=e;if(!n.config.pickExistingFiles)return;const p=He(r.accept),m=nt(r.accept),g=(t=r.maxSize)!=null?t:1/0,x=c.getAllKnownRids(),S=new Set(x),h=i===1/0?1/0:Math.max(0,i-c.getOccupiedCount());let b;try{b=await n.config.pickExistingFiles({fieldPath:l,mode:"multiple",accept:Kn(r),maxSizeMB:g===1/0?void 0:g,remainingSlots:h===1/0?void 0:h,selectedResourceIds:x})}catch(_){ke(o,Xn(_,n),n);return}if(b.length===0)return;const v=new Set,E=b.filter(_=>S.has(_.resourceId)||v.has(_.resourceId)?!1:(v.add(_.resourceId),!0)).filter(_=>_n(_,p,m,g,n)===null),w=i===1/0?E.length:Math.max(0,i-c.getOccupiedCount()),C=E.slice(0,w),y=E.length-C.length;if(C.length===0){y>0&&ke(o,k("filesLimitExceeded",n,{skipped:y,max:i}),n);return}Be(o),y>0&&ke(o,k("filesLimitExceeded",n,{skipped:y,max:i}),n);for(const _ of C)Jn(_,n);const R=C.map(_=>_.resourceId),K=c.beginBatch(C.length);K.setResults(R),n.config.readonly||s.triggerOnChange(l,a);const{wasLast:Y}=K.end();if(Y)d();else{const _=Bt(u);for(const Q of R)_.appendChild(f(Q))}}async function fl(e,t,n,r,o,l,a,i){var d,s;if(!e.config.pickExistingFiles)return;const c=He(t.accept),u=nt(t.accept),f=(d=t.maxSize)!=null?d:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:l,mode:"single",accept:Kn(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){ke(n,Xn(h,e),e);return}if(p.length===0)return;const m=p[0],g=_n(m,c,u,f,e);if(g!==null){ke(n,g,e);return}Be(n),Jn(m,e);let x=r.querySelector('input[type="hidden"]');x||(x=document.createElement("input"),x.type="hidden",x.name=o,r.appendChild(x));const S=x.value||null;S&&S!==m.resourceId&&Me((s=e.resourceIndex.get(S))==null?void 0:s.file),x.value=m.resourceId,await a(m.resourceId),e.config.readonly||i.triggerOnChange(l,m.resourceId)}const Yn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Gn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function pl(e,t,n,r,o,l,a){var i;bt(e,o.resourceIndex);const d=o.resourceIndex.get(e);(i=d==null?void 0:d.type)!=null&&i.startsWith("video/")?Pt(t,e,o,{fileName:e,isReadonly:!1,deps:l}).catch(console.error):Vt(t,e,o,l,a);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function ml(e,t,n,r,o=!1,l=""){Le();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const i=document.createElement("button");i.type="button",i.className="fb-wide-tile-upload fb-file-dropzone";const d=document.createElement("span");d.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",d.innerHTML=Yn,i.appendChild(d);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),i.appendChild(s),l){const c=document.createElement("div");c.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",c.textContent=l,i.appendChild(c)}if(i.onclick=c=>{c.stopPropagation(),n()},a.appendChild(i),t&&r){const c=document.createElement("button");c.type="button",c.className="fb-wide-tile-library fb-file-library-card";const u=document.createElement("span");u.className="fb-wide-tile-library-icon",u.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",u.innerHTML=Gn,c.appendChild(u);const f=document.createElement("div");f.className="fb-wide-tile-library-label",f.style.cssText="font-size:13px;font-weight:600;text-align:center;",f.textContent=k("fromLibrary",e),c.appendChild(f);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),c.appendChild(p),c.onclick=m=>{m.stopPropagation(),r()},a.appendChild(c)}return Zn(a,{onEnter:()=>{const c=a.querySelector(".fb-wide-tile-label");c&&(c.textContent=k("dropToUpload",e))},onLeave:()=>{const c=a.querySelector(".fb-wide-tile-label");c&&(c.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),a}function Zn(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Vt(e,t,n,r,o){var l,a;const i=n.resourceIndex.get(t);if((l=i==null?void 0:i.type)!=null&&l.startsWith("video/")){Pt(e,t,n,{fileName:(a=i==null?void 0:i.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}Le();const d=document.createElement("div");d.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",d.appendChild(s);const c=Kt(t,n,!!r.onRemove,r.onRemove?()=>{var u;return(u=r.onRemove)==null?void 0:u.call(r)}:null,o);for(s.appendChild(c),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(d)}function hl(e,t,n,r,o=!1){const l=document.createElement("div");l.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const i=document.createElement("span");i.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",i.innerHTML=Yn,a.appendChild(i);const d=document.createElement("span");if(d.className="fb-multi-add-label",d.style.cssText="font-size:11px;font-weight:600;",d.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(d),a.onclick=s=>{s.stopPropagation(),n()},l.appendChild(a),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",l.appendChild(s);const c=document.createElement("button");c.type="button",c.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",c.setAttribute("aria-label",k("fromLibrary",e));const u=document.createElement("span");u.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",u.innerHTML=Gn,c.appendChild(u),c.appendChild(document.createTextNode(k("fromLibrary",e))),c.onclick=f=>{f.stopPropagation(),r()},l.appendChild(c)}return l}function Kt(e,t,n,r,o){var l,a,i;Le();const d=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const c=Ot({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(l=d==null?void 0:d.name)!=null?l:"",meta:d,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(i=o==null?void 0:o.libraryHandler)!=null?i:null});return jn(s,e,d,t,c).catch(u=>{console.error("Failed to render tile:",u)}),s}function Qn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function bl(e,t){const n=document.createElement("button");return n.type="button",n.className="fb-clear-all-btn",n.textContent=k("clearAll",e),n.onclick=r=>{r.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&t()},n}function gl(e,t,n,r){const o=n!==1/0,l=r!==void 0&&t>1;if(!o&&!l)return null;const a=document.createElement("div");if(a.className="fb-multi-footer",o){const i=document.createElement("span");i.className="fb-files-counter",i.textContent=k("filesCounter",e,{count:t,max:n}),a.appendChild(i)}return l&&a.appendChild(bl(e,r)),a}function vl(e,t,n,r){t>n?ke(e,k("maxFiles",r,{max:n}),r,"limit"):Be(e,"limit")}const ot=new WeakMap,_t=new WeakMap;function er(e){const t=_t.get(e);t!==void 0&&(cancelAnimationFrame(t),_t.delete(e))}function yl(e){const t=ot.get(e);t&&(t.disconnect(),ot.delete(e)),er(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function xl(e){var t;const{container:n,rids:r,state:o,onRemove:l,maxCount:a,isReadonly:i=!1,onLibraryPick:d,onClearAll:s,openPicker:c}=e;Le();const u=n.closest("[data-files-wrapper]");u&&(u.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const f=ot.get(n);for(f&&(f.disconnect(),ot.delete(n)),er(n);n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=a!=null?a:1/0,g=m!==1/0&&p.length>=m,x=!i&&typeof d=="function",S=c!=null?c:(()=>{var C;const y=(C=n.closest("[data-files-wrapper]"))==null?void 0:C.querySelector('input[type="file"]');y&&y.click()});if(i){if(p.length===0){const C=document.createElement("div");C.className="fb-tile-empty-text",C.textContent=k("noFilesSelected",o),n.appendChild(C)}else{const C=document.createElement("div");C.className="fb-multi-readonly-grid",n.appendChild(C);for(const y of p){const R=o.resourceIndex.get(y),K=document.createElement("div");K.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",K.dataset.resourceId=y;const Y=Ot({canRemove:!1,removeHandler:null,state:o,resourceId:y,fileName:(t=R==null?void 0:R.name)!=null?t:"",meta:R});jn(K,y,R,o,Y).catch(console.error),K.onclick=async()=>{var _;let Q=null;o.config.getDownloadUrl?Q=o.config.getDownloadUrl(y):o.config.getThumbnail?Q=await o.config.getThumbnail(y):(R==null?void 0:R.file)instanceof File&&(Q=URL.createObjectURL(R.file)),Q?window.open(Q,"_blank"):o.config.downloadFile&&o.config.downloadFile(y,(_=R==null?void 0:R.name)!=null?_:"")},C.appendChild(K)}}Be(n,"limit");return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const b=document.createElement("div");b.className="fb-multi-grid fb-tiles-wrap",h.appendChild(b),n.appendChild(h);for(let C=0;C<p.length;C++){const y=p[C],R=Kt(y,o,l!==null,l?()=>l(y):null);b.appendChild(R)}if(!g){const C=hl(o,x,S,d!=null?d:null);b.appendChild(C)}const v=p.length+(g?0:1),E=()=>{const C=getComputedStyle(b).gridTemplateColumns,y=C?C.split(" ").filter(Boolean).length:0;if(!y)return;const R=v%y,K=R===0?0:y-R,Y=m===1/0?K:Math.max(0,m-v),_=Math.min(K,Y),Q=b.querySelectorAll(".fb-multi-placeholder");if(Q.length>_)for(let O=Q.length-1;O>=_;O--)Q[O].remove();else if(Q.length<_)for(let O=Q.length;O<_;O++)b.appendChild(Qn())};if((m===1/0||m>v)&&b.appendChild(Qn()),_t.set(n,requestAnimationFrame(E)),typeof ResizeObserver!="undefined"){const C=new ResizeObserver(()=>E());C.observe(b),ot.set(n,C)}Zn(h,{activeClass:"fb-drag-over",onEnter:()=>{b.querySelectorAll(".fb-multi-placeholder").forEach(y=>{y.classList.add("fb-drag-over")});const C=b.querySelector(".fb-multi-add-tile-js");if(C){C.classList.add("fb-drag-over-tile");const y=C.querySelector(".fb-multi-add-label");y&&(y.textContent=k("dropToUpload",o))}},onLeave:()=>{b.querySelectorAll(".fb-multi-placeholder").forEach(y=>{y.classList.remove("fb-drag-over")});const C=b.querySelector(".fb-multi-add-tile-js");if(C){C.classList.remove("fb-drag-over-tile");const y=C.querySelector(".fb-multi-add-label");y&&(y.textContent=k("clickDragTextMultiple",o))}}});const w=gl(o,p.length,m,s);w&&n.appendChild(w),vl(n,p.length,m,o)}function wl(e,t,n,r){var o,l;const a=t.state,i=document.createElement("div");i.className="fb-row",i.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.style.display="none",d.accept=tr(e.accept);const s=document.createElement("div");s.className="file-preview-container";const c=t.prefill[e.key],u=He(e.accept),f=nt(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){d.click()},dragHandler(h){h.length>0&&ll({file:h[0],container:s,fieldName:r,state:a,deps:x(),instance:t.instance,allowedExtensions:u,allowedMimes:f,maxSizeMB:p})},setupDrop(h){gt(h,m.dragHandler)},onRemove(){var h;const b=i.querySelector('input[type="hidden"]'),v=b==null?void 0:b.value;v&&Me((h=a.resourceIndex.get(v))==null?void 0:h.file),b&&(b.value=""),S()}},g=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>d.click():null,libraryHandler:h?()=>{fl(a,e,s,i,r,r,async b=>{Vt(s,b,a,x(),g())},t.instance).catch(b=>{console.error("Library pick failed:",b)})}:null}},x=()=>({picker:d,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,b)=>{Vt(h,b,a,x(),g())}}),S=()=>{for(Le(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=g().libraryHandler,b=ml(a,h!==null,m.fileUploadHandler,h,!1,Te(e,a));s.appendChild(b),gt(s,m.dragHandler)};if(c){pl(c,s,r,i,a,x(),g());const h=a.resourceIndex.get(c);(l=h==null?void 0:h.type)!=null&&l.startsWith("video/")&&gt(s,m.dragHandler)}else S();d.onchange=()=>{d.files&&d.files.length>0&&m.dragHandler(d.files)},i.appendChild(s),i.appendChild(d),n.appendChild(i)}function tr(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function nr(e,t,n,r){var o,l,a;const i=t.state,d=(o=e.maxCount)!=null?o:1/0,s=document.createElement("div");s.className="fb-row",s.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.multiple=!0,c.style.display="none",c.accept=tr(e.accept);const u=document.createElement("div");u.className="files-list-wrapper";const f=document.createElement("div");f.className="files-list",s.appendChild(c),s.appendChild(u),u.appendChild(f);const p=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];qt(p,i.resourceIndex),s.dataset.resourceIds=JSON.stringify(p);const m={maxCount:d,allowedExtensions:He(e.accept),allowedMimes:nt(e.accept),maxSize:(a=(l=e.maxSize)!=null?l:e.maxSizeMB)!=null?a:1/0},g=()=>{c.click()},x=i.config.pickExistingFiles&&!e.disableLibrary?()=>{ul({state:i,element:e,wrapper:s,fieldPath:r,resourceIds:p,maxCount:d,updateCallback:S,instance:t.instance,coordinator:K,list:f,buildSuccessTile:Y}).catch(O=>{console.error("Library pick failed:",O)})}:null;function S(){const O=ae(e,i);xl({container:f,rids:p,state:i,onRemove:O?null:I=>{var P,ie;Me((P=i.resourceIndex.get(I))==null?void 0:P.file);const se=p.indexOf(I);se>-1&&p.splice(se,1),K.hasInFlightBatches()?(y.add(I),(ie=f.querySelector(`[data-resource-id="${I}"]`))==null||ie.remove(),s.dataset.resourceIds=JSON.stringify(p)):S(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,p)},maxCount:d<1/0?d:void 0,isReadonly:O,onLibraryPick:O?null:x,onClearAll:O?void 0:()=>{var I,P;for(const ie of p)Me((I=i.resourceIndex.get(ie))==null?void 0:I.file);if(p.splice(0),K.hasInFlightBatches()){const ie=f.querySelectorAll("[data-resource-id]");for(const se of ie){const fe=se.dataset.resourceId;fe&&(Me((P=i.resourceIndex.get(fe))==null?void 0:P.file),y.add(fe)),se.remove()}s.dataset.resourceIds=JSON.stringify(p)}else S();t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,p)},openPicker:g})}let h=0,b=0,v=0,E=0;const w=new Map,C=new Map,y=new Set,R=()=>{for(var O;w.has(E);){const I=E,P=w.get(I);w.delete(I),E+=1;const ie=(O=C.get(I))!=null?O:0;C.delete(I),h-=ie;for(const se of P)if(se!==null){if(y.has(se)){y.delete(se);continue}p.push(se)}}s.dataset.resourceIds=JSON.stringify(p)},K={getOccupiedCount:()=>p.length+h,getAllKnownRids:()=>{const O=[...p];for(const I of w.values())for(const P of I)P!==null&&O.push(P);return O},hasInFlightBatches:()=>b>0||C.size>0,wasRemovedDuringBatch:O=>y.has(O),beginBatch:O=>{h+=O,b+=1;const I=v++;return C.set(I,O),{setResults:P=>{w.set(I,P),R()},end:()=>{b-=1;const P=b===0&&C.size===0;return P&&y.clear(),{wasLast:P}}}}},Y=O=>{const I=ae(e,i);return Kt(O,i,!I,I?null:()=>{var P,ie,se;Me((P=i.resourceIndex.get(O))==null?void 0:P.file);const fe=p.indexOf(O);if(fe>-1){p.splice(fe,1),K.hasInFlightBatches()?(y.add(O),(ie=f.querySelector(`[data-resource-id="${O}"]`))==null||ie.remove(),s.dataset.resourceIds=JSON.stringify(p)):S(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,p);return}y.add(O),(se=f.querySelector(`[data-resource-id="${O}"]`))==null||se.remove(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,p)})},_=()=>yl(f),Q={resourceIds:p,state:i,updateCallback:S,constraints:m,pathKey:r,instance:t.instance,buildSuccessTile:Y,prepareForUpload:_,coordinator:K};dl({...Q,filesContainer:u}),cl({...Q,filesPicker:c}),i.multiFileSetters.set(s,O=>{var I;if(K.hasInFlightBatches())throw new Error(`setFormData/updateField: file field "${r}" has uploads in flight; set its value after they settle`);for(const P of p)O.includes(P)||Me((I=i.resourceIndex.get(P))==null?void 0:I.file);p.splice(0,p.length,...O),S()}),S(),n.appendChild(s)}function Cl(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 rr(e,t,n){var r,o;const l=[],a="accept"in t?t.accept:void 0,i=He(a),d=nt(a);if(i.length===0&&d.length===0)return l;const s=i.join(", "),c=d.join(", ");for(const u of e){const f=n.resourceIndex.get(u),p=(r=f==null?void 0:f.name)!=null?r:u;if(i.length>0&&!Ve(p,i)){l.push(k("invalidFileExtension",n,{name:p,formats:s}));continue}if(d.length>0&&!(f!=null&&f.inferredFromExtension)){const m=(o=f==null?void 0:f.type)!=null?o:"";rt(m,d)||l.push(k("invalidFileMime",n,{name:p,type:m,mimes:c}))}}return l}function or(e,t,n){var r;const o=[],l="maxSize"in t&&(r=t.maxSize)!=null?r:1/0;if(l===1/0)return o;for(const a of e){const i=n.resourceIndex.get(a);i&&i.size>l*1024*1024&&o.push(k("fileTooLarge",n,{name:i.name,maxSize:l}))}return o}function lr(e,t,n,r,o){const l=e.querySelector(`[data-files-wrapper="${t}"]`);return l&&Ro(l,Ft(r),o),r.map(a=>`${n}: ${a}`)}function El(e,t,n){const{scopeRoot:r,path:o,state:l}=n,a=Ue(o,t),i=Cl(r,a),d=[...Cn(e,i.length,l,{min:"minFiles",max:"maxFiles"}),...rr(i,e,l),...or(i,e,l)];return{value:i,errors:lr(r,a,t,d,n)}}function kl(e,t,n){var r;const{scopeRoot:o,state:l}=n,a=o.querySelector(`input[name="${t}"][type="hidden"]`),i=(r=a==null?void 0:a.value)!=null?r:"";let d=[];return e.required&&i===""?d=[k("required",l)]:i!==""&&(d=[...rr([i],e,l),...or([i],e,l)]),{value:i||null,errors:lr(o,t,t,d,n)}}function ir(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?El(e,t,n):kl(e,t,n)}function $l(e,t,n,r){const o=t.state,l=t.prefill[e.key],a=typeof l=="string"?l:"";if(a){qt([a],o.resourceIndex);const i=document.createElement("input");i.type="hidden",i.name=r,i.value=a,n.appendChild(i),Wt(a,o).then(d=>{d.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(d)}).catch(console.error)}else n.appendChild(Sl(o))}function Sl(e){Le();const t=document.createElement("div");return t.style.cssText=`
1062
1060
  height: 220px;
1063
1061
  display:flex;
1064
1062
  align-items:center;
@@ -1066,7 +1064,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1066
1064
  background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
1067
1065
  border-radius:0.75rem;
1068
1066
  border:1px solid #e2e8f0;
1069
- `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${se(k("noFileSelected",e))}</div>`,t}function Bn(e,t,n,r,o){St(e,t.resourceIndex),$e();const a=document.createElement("div");if(a.dataset.filesWrapper=r,a.dataset.resourceIds=JSON.stringify(e),n.appendChild(a),e.length===0){const c=document.createElement("div");c.className="fb-tile-empty-text",c.textContent=k("noFilesSelected",t),a.appendChild(c);return}const l=document.createElement("div");l.className="fb-multi-readonly-grid",a.appendChild(l);const i=e.map(()=>{const c=document.createElement("div");return c.className="fb-readonly-tile fb-checker fb-tile",l.appendChild(c),c});for(let c=0;c<e.length;c++){const s=e[c],f=i[c],d=t.resourceIndex.get(s);Nt(s,t,d==null?void 0:d.name).then(u=>{u.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),u.dataset.resourceId=s,f.replaceWith(u)}).catch(()=>{const u=document.createElement("div");u.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",u.dataset.resourceId=s,f.replaceWith(u)})}}function Go(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Zo(e,t,n,r){const o=t.prefill[e.key],a=Array.isArray(o)?o:[];Bn(a,t.state,n,r)}function Qo(e,t,n,r){ae(e,t.state,t)?Xo(e,t,n,r):Uo(e,t,n,r)}function el(e,t,n,r){ae(e,t.state,t)?Go(e,t,n,r):Po(e,t,n,r)}function tl(e,t,n,r){ae(e,t.state,t)?Zo(e,t,n,r):Wo(e,t,n,r)}function Hn(e,t,n,r){const{scopeRoot:o,state:a}=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(i=>{i&&typeof i=="string"&&ct(i,a.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"&&(ct(n,a.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Pe(e){return e?e.toUpperCase():"#000000"}function Bt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function Dn(e){if(/^#[0-9A-F]{3}$/i.test(e)){const t=e[1],n=e[2],r=e[3];return`#${t}${t}${n}${n}${r}${r}`.toUpperCase()}return e.toUpperCase()}function jn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Pe(e),r=document.createElement("div");r.style.cssText=`
1067
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${de(k("noFileSelected",e))}</div>`,t}function ar(e,t,n,r,o){const l=document.createElement("div");l.dataset.filesWrapper=r,n.appendChild(l),t.multiFileSetters.set(l,a=>sr(a,t,l)),sr(e,t,l)}function sr(e,t,n){if(qt(e,t.resourceIndex),Le(),n.dataset.resourceIds=JSON.stringify(e),n.replaceChildren(),e.length===0){const l=document.createElement("div");l.className="fb-tile-empty-text",l.textContent=k("noFilesSelected",t),n.appendChild(l);return}const r=document.createElement("div");r.className="fb-multi-readonly-grid",n.appendChild(r);const o=e.map(()=>{const l=document.createElement("div");return l.className="fb-readonly-tile fb-checker fb-tile",r.appendChild(l),l});for(let l=0;l<e.length;l++){const a=e[l],i=o[l],d=t.resourceIndex.get(a);Wt(a,t,d==null?void 0:d.name).then(s=>{s.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),s.dataset.resourceId=a,i.replaceWith(s)}).catch(()=>{const s=document.createElement("div");s.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",s.dataset.resourceId=a,i.replaceWith(s)})}}function Ll(e,t,n,r){const o=t.prefill[e.key],l=Array.isArray(o)?o:[];ar(l,t.state,n,r)}function Al(e,t,n,r){const o=t.prefill[e.key],l=Array.isArray(o)?o:[];ar(l,t.state,n,r)}function Tl(e,t,n,r){ae(e,t.state,t)?$l(e,t,n,r):wl(e,t,n,r)}function Fl(e,t,n,r){ae(e,t.state,t)?Ll(e,t,n,r):nr(e,t,n,r)}function zl(e,t,n,r){ae(e,t.state,t)?Al(e,t,n,r):nr(e,t,n,r)}function dr(e,t,n,r){const{scopeRoot:o,state:l}=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(d=>{d&&typeof d=="string"&&bt(d,l.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);if(!a){console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`);return}const i=l.multiFileSetters.get(a);if(!i)throw new Error(`updateFileField: [data-files-wrapper="${t}"] has no registered setter; this is a render bug`);i(n)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.value=n!=null?String(n):"",n&&typeof n=="string"&&(bt(n,l.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function Ke(e){return e?e.toUpperCase():"#000000"}function Jt(e){return/^#[0-9A-F]{6}$/i.test(e)||/^#[0-9A-F]{3}$/i.test(e)}function cr(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 ur(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=Ke(e),r=document.createElement("div");r.style.cssText=`
1070
1068
  width: 32px;
1071
1069
  height: 32px;
1072
1070
  border-radius: var(--fb-border-radius);
@@ -1076,7 +1074,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1076
1074
  font-size: var(--fb-font-size);
1077
1075
  color: var(--fb-text-color);
1078
1076
  font-family: var(--fb-font-family-mono, monospace);
1079
- `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function On(e,t,n){const r=Pe(e),o=document.createElement("div");o.className="colour-picker-wrapper",o.style.cssText=`
1077
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function fr(e,t,n,r){const o=Ke(e),l=document.createElement("div");l.className="colour-picker-wrapper",l.style.cssText=`
1080
1078
  display: flex;
1081
1079
  align-items: center;
1082
1080
  gap: 8px;
@@ -1085,11 +1083,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1085
1083
  height: 40px;
1086
1084
  border-radius: var(--fb-border-radius);
1087
1085
  border: var(--fb-border-width) solid var(--fb-border-color);
1088
- background-color: ${r};
1086
+ background-color: ${o};
1089
1087
  cursor: pointer;
1090
1088
  transition: border-color var(--fb-transition-duration) ease-in-out;
1091
1089
  flex-shrink: 0;
1092
- `;const l=document.createElement("input");l.type="text",l.className="colour-hex-input",l.name=t,l.value=r,l.placeholder="#000000",l.style.cssText=`
1090
+ `;const i=document.createElement("input");i.type="text",i.className="colour-hex-input",i.setAttribute("data-colour-field","true"),i.name=t,i.value=o,i.placeholder=r!=null?r:"#000000",i.style.cssText=`
1093
1091
  width: 100px;
1094
1092
  padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
1095
1093
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -1099,43 +1097,39 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1099
1097
  font-size: var(--fb-font-size);
1100
1098
  font-family: var(--fb-font-family-mono, monospace);
1101
1099
  transition: all var(--fb-transition-duration) ease-in-out;
1102
- `;const i=document.createElement("input");return i.type="color",i.className="colour-picker-hidden",i.value=r.toLowerCase(),i.style.cssText=`
1100
+ `;const d=document.createElement("input");return d.type="color",d.className="colour-picker-hidden",d.value=o.toLowerCase(),d.style.cssText=`
1103
1101
  position: absolute;
1104
1102
  opacity: 0;
1105
1103
  pointer-events: none;
1106
- `,l.addEventListener("input",()=>{const c=l.value.trim();if(Bt(c)){const s=Dn(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(Bt(c)){const s=Dn(c);l.value=s,a.style.backgroundColor=s,i.value=s.toLowerCase(),l.classList.remove("invalid")}}),i.addEventListener("change",()=>{const c=Pe(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 nl(e,t,n,r){const o=t.state,a=ae(e,o,t),l=t.prefill[e.key]||e.default||"#000000";if(a){const i=jn(l);n.appendChild(i)}else{const i=On(l,r,t);n.appendChild(i)}if(!a){const i=document.createElement("p");i.className="mt-1",i.style.cssText=`
1104
+ `,i.addEventListener("input",()=>{const s=i.value.trim();if(Jt(s)){const c=cr(s);a.style.backgroundColor=c,d.value=c.toLowerCase(),i.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else i.classList.add("invalid")}),i.addEventListener("blur",()=>{const s=i.value.trim();if(Jt(s)){const c=cr(s);i.value=c,a.style.backgroundColor=c,d.value=c.toLowerCase(),i.classList.remove("invalid")}}),d.addEventListener("change",()=>{const s=Ke(d.value);i.value=s,a.style.backgroundColor=s,n.instance&&n.instance.triggerOnChange(t,s)}),a.addEventListener("click",()=>{d.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),i.addEventListener("focus",()=>{i.style.borderColor="var(--fb-border-focus-color)",i.style.outline="var(--fb-focus-ring-width) solid var(--fb-focus-ring-color)",i.style.outlineOffset="0"}),i.addEventListener("blur",()=>{i.style.borderColor="var(--fb-border-color)",i.style.outline="none"}),i.addEventListener("mouseenter",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-hover-color)")}),i.addEventListener("mouseleave",()=>{document.activeElement!==i&&(i.style.borderColor="var(--fb-border-color)")}),l.appendChild(a),l.appendChild(i),l.appendChild(d),l}function Ml(e,t,n,r){var o,l;const a=t.state,i=ae(e,a,t),d=(l=(o=t.prefill[e.key])!=null?o:e.default)!=null?l:"#000000";if(i){const s=ur(d);n.appendChild(s)}else{const s=fr(d,r,t,e.placeholder);n.appendChild(s)}if(!i){const s=document.createElement("p");s.className="mt-1",s.style.cssText=`
1107
1105
  font-size: var(--fb-font-size-small);
1108
1106
  color: var(--fb-text-secondary-color);
1109
- `,i.textContent=Le(e,o),n.appendChild(i)}}function rl(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0;for(;s.length<f;)s.push(e.default||"#000000");const u=document.createElement("div");u.className="fb-row",n.appendChild(u);function p(){u.querySelectorAll(".multiple-colour-item").forEach((h,y)=>{const v=h.querySelector("input");v&&(v.name=`${r}[${y}]`)})}function m(h="#000000",y=-1){const v=document.createElement("div");if(v.className="multiple-colour-item flex items-center gap-2",i){const C=jn(h);for(;C.firstChild;)v.appendChild(C.firstChild)}else{const C=`${r}[${u.children.length}]`,w=On(h,C,t);w.style.flex="1",v.appendChild(w)}return y===-1?u.appendChild(v):u.insertBefore(v,u.children[y]),p(),v}function b(){if(i)return;const h=u.querySelectorAll(".multiple-colour-item"),y=h.length;h.forEach(v=>{let C=v.querySelector(".remove-item-btn");C||(C=document.createElement("button"),C.type="button",C.className="remove-item-btn px-2 py-1 rounded",C.style.cssText=`
1107
+ `,s.textContent=Te(e,a),n.appendChild(s)}}function Rl(e,t,n,r){var o,l,a;const i=t.state,d=ae(e,i,t),s=t.prefill[e.key]||[],c=Array.isArray(s)?[...s]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(l=e.maxCount)!=null?l:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"#000000");const p=document.createElement("div");p.className="fb-row",n.appendChild(p);function m(){p.querySelectorAll(".multiple-colour-item").forEach((b,v)=>{const E=b.querySelector("input");E&&(E.name=`${r}[${v}]`)})}function g(b="#000000",v=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",d){const w=ur(b);for(;w.firstChild;)E.appendChild(w.firstChild)}else{const w=`${r}[${p.children.length}]`,C=fr(b,w,t,e.placeholder);C.style.flex="1",E.appendChild(C)}return v===-1?p.appendChild(E):p.insertBefore(E,p.children[v]),m(),E}function x(){if(d)return;const b=p.querySelectorAll(".multiple-colour-item"),v=b.length;b.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
1110
1108
  color: var(--fb-error-color);
1111
1109
  background-color: transparent;
1112
1110
  transition: background-color var(--fb-transition-duration);
1113
- `,C.innerHTML="\u2715",C.addEventListener("mouseenter",()=>{C.style.backgroundColor="var(--fb-background-hover-color)"}),C.addEventListener("mouseleave",()=>{C.style.backgroundColor="transparent"}),C.onclick=()=>{var x;const S=Array.from(u.children).indexOf(v);u.children.length>f&&(s.splice(S,1),v.remove(),p(),E(),b(),(x=t.instance)==null||x.triggerOnChange(r))},v.appendChild(C));const w=y<=f;C.disabled=w,C.style.opacity=w?"0.5":"1",C.style.pointerEvents=w?"none":"auto"})}let g=null;if(!i){const h=ze("colour",()=>{var y;const v=e.default||"#000000";s.push(v),m(v),E(),b(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});g=h.update,Te(n,h.counter),n.appendChild(h.row)}function E(){g&&g(s.length,d)}if(s.forEach(h=>m(h)),E(),b(),!i){const h=document.createElement("p");h.className="mt-1",h.style.cssText=`
1111
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var y;const R=Array.from(p.children).indexOf(E);p.children.length>u&&(c.splice(R,1),E.remove(),m(),h(),x(),(y=t.instance)==null||y.triggerOnChange(r))},E.appendChild(w));const C=v<=u;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"})}let S=null;if(!d){const b=ze("colour",()=>{var v,E;const w=(v=e.default)!=null?v:"#000000";c.push(w),g(w),h(),x(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});S=b.update,Ae(n,b.counter),n.appendChild(b.row)}function h(){S&&S(c.length,f)}if(c.forEach(b=>g(b)),h(),x(),!d){const b=document.createElement("p");b.className="mt-1",b.style.cssText=`
1114
1112
  font-size: var(--fb-font-size-small);
1115
1113
  color: var(--fb-text-secondary-color);
1116
- `,h.textContent=Le(e,l),n.appendChild(h)}}function ol(e,t,n){var r,o,a;const l=[],{scopeRoot:i,skipValidation:c}=n,s=(d,u)=>{var p,m;if(!d)return;const b=`error-${d.getAttribute("name")||Math.random().toString(36).substring(7)}`;let g=document.getElementById(b);u?(d.classList.add("invalid"),d.title=u,g||(g=document.createElement("div"),g.id=b,g.className="error-message",g.style.cssText=`
1117
- color: var(--fb-error-color);
1118
- font-size: var(--fb-font-size-small);
1119
- margin-top: 0.25rem;
1120
- `,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=u,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,u,p)=>{const{state:m}=n;if(!u){if(!c&&e.required){const g=k("required",m);return l.push(`${p}: ${g}`),s(d,g),""}return s(d,null),""}const b=Pe(u);if(!c&&!Bt(b)){const g=k("invalidHexColour",m);return l.push(`${p}: ${g}`),s(d,g),u}return s(d,null),b};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),u=[];if(d.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"",E=f(p,g,`${t}[${m}]`);u.push(E)}),!c){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=u.filter(E=>E!=="");e.required&&g.length===0&&l.push(`${t}: ${k("required",p)}`),g.length<m&&l.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&l.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"].colour-hex-input`),u=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&u===""){const p=k("required",n.state);return l.push(`${t}: ${p}`),s(d,p),{value:"",errors:l}}return{value:f(d,u,t),errors:l}}}function ll(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=Pe(n[i]);l.value=c,l.classList.remove("invalid"),l.title="",Ce(l);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=Pe(n);a.value=l,a.classList.remove("invalid"),a.title="",Ce(a);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 Un(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function Ht(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 pt(e,t){return Math.round(e/t)*t}function Pn(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,u=n.max,p=(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=Ht(e,d,u);s.value=(h*1e3).toString()}else s.min=d.toString(),s.max=u.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
1114
+ `,b.textContent=Te(e,i),n.appendChild(b)}}function Il(e,t,n){var r;const o=[],{scopeRoot:l,state:a}=n,i=(d,s,c)=>{const u=s?Ke(s):"";let f=null;return s?Jt(u)||(f=k("invalidHexColour",a)):e.required&&(f=k("required",a)),f!==null&&o.push(`${c}: ${f}`),xe(d,f,n),s&&f!==null?s:u};if(e.multiple){const d=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),s=[];d.forEach((u,f)=>{var p;const m=(p=u==null?void 0:u.value)!=null?p:"";s.push(i(u,m,`${t}[${f}]`))});const c=s.filter(u=>u!=="").length;return qe(e,t,c,n,o),{value:s,errors:o}}else{const d=l.querySelector(`[name="${t}"].colour-hex-input`),s=(r=d==null?void 0:d.value)!=null?r:"";return{value:i(d,s,t),errors:o}}}function Nl(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 l=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);l.forEach((a,i)=>{if(i<n.length){const d=Ke(n[i]);a.value=d,we(a);const s=a.closest(".colour-picker-wrapper");if(s){const c=s.querySelector(".colour-swatch"),u=s.querySelector(".colour-picker-hidden");c&&(c.style.backgroundColor=d),u&&(u.value=d.toLowerCase())}}}),n.length!==l.length&&console.warn(`updateColourField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=o.querySelector(`[name="${t}"].colour-hex-input`);if(l){const a=Ke(n);l.value=a,we(l);const i=l.closest(".colour-picker-wrapper");if(i){const d=i.querySelector(".colour-swatch"),s=i.querySelector(".colour-picker-hidden");d&&(d.style.backgroundColor=a),s&&(s.value=a.toLowerCase())}}}}function pr(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 Xt(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 Yt(e,t){return Math.round(e/t)*t}function mr(e,t,n,r,o){var l;const a=document.createElement("div");a.className="slider-container";const i=document.createElement("div");i.className="flex items-start gap-3";const d=document.createElement("div");d.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const c=n.scale||"linear",u=n.min,f=n.max,p=(l=n.step)!=null?l:1;if(c==="exponential"){if(u<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${u})`);s.min="0",s.max="1000",s.step="1";const h=Xt(e,u,f);s.value=(h*1e3).toString()}else s.min=u.toString(),s.max=f.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
1121
1115
  height: 6px;
1122
1116
  border-radius: 3px;
1123
1117
  background: linear-gradient(
1124
1118
  to right,
1125
1119
  var(--fb-primary-color) 0%,
1126
- var(--fb-primary-color) ${(e-d)/(u-d)*100}%,
1127
- var(--fb-border-color) ${(e-d)/(u-d)*100}%,
1120
+ var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
1121
+ var(--fb-border-color) ${(e-u)/(f-u)*100}%,
1128
1122
  var(--fb-border-color) 100%
1129
1123
  );
1130
1124
  outline: none;
1131
1125
  transition: background 0.1s ease-in-out;
1132
1126
  cursor: ${o?"not-allowed":"pointer"};
1133
1127
  opacity: ${o?"0.6":"1"};
1134
- `,c.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
1128
+ `,d.appendChild(s);const m=document.createElement("div");m.className="flex justify-between",m.style.cssText=`
1135
1129
  font-size: var(--fb-font-size-small);
1136
1130
  color: var(--fb-text-secondary-color);
1137
1131
  margin-top: 4px;
1138
- `;const b=document.createElement("span");b.textContent=d.toString();const g=document.createElement("span");g.textContent=u.toString(),m.appendChild(b),m.appendChild(g),c.appendChild(m);const E=document.createElement("span");if(E.className="slider-value",E.style.cssText=`
1132
+ `;const g=document.createElement("span");g.textContent=u.toString();const x=document.createElement("span");x.textContent=f.toString(),m.appendChild(g),m.appendChild(x),d.appendChild(m);const S=document.createElement("span");if(S.className="slider-value",S.style.cssText=`
1139
1133
  min-width: 60px;
1140
1134
  text-align: right;
1141
1135
  font-size: var(--fb-font-size);
@@ -1143,40 +1137,36 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1143
1137
  font-family: var(--fb-font-family-mono, monospace);
1144
1138
  font-weight: 500;
1145
1139
  padding-top: 2px;
1146
- `,E.textContent=e.toFixed(p<1?2:0),i.appendChild(c),i.appendChild(E),l.appendChild(i),!o){const h=()=>{let y;if(f==="exponential"){const C=parseFloat(s.value)/1e3;y=Un(C,d,u),y=pt(y,p),y=Math.max(d,Math.min(u,y))}else y=parseFloat(s.value),y=pt(y,p);E.textContent=y.toFixed(p<1?2:0);const v=(y-d)/(u-d)*100;s.style.background=`linear-gradient(
1140
+ `,S.textContent=e.toFixed(p<1?2:0),i.appendChild(d),i.appendChild(S),a.appendChild(i),!o){const h=()=>{let b;if(c==="exponential"){const E=parseFloat(s.value)/1e3;b=pr(E,u,f),b=Yt(b,p),b=Math.max(u,Math.min(f,b))}else b=parseFloat(s.value),b=Yt(b,p);S.textContent=b.toFixed(p<1?2:0);const v=(b-u)/(f-u)*100;s.style.background=`linear-gradient(
1147
1141
  to right,
1148
1142
  var(--fb-primary-color) 0%,
1149
1143
  var(--fb-primary-color) ${v}%,
1150
1144
  var(--fb-border-color) ${v}%,
1151
1145
  var(--fb-border-color) 100%
1152
- )`,r.instance&&r.instance.triggerOnChange(t,y)};s.addEventListener("input",h),s.addEventListener("change",h)}return l}function il(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=ae(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=Pn(c,r,e,t,l);if(n.appendChild(s),!l){const f=document.createElement("p");f.className="mt-1",f.style.cssText=`
1146
+ )`,r.instance&&r.instance.triggerOnChange(t,b)};s.addEventListener("input",h),s.addEventListener("change",h)}return a}function ql(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 l=t.state,a=ae(e,l,t),i=e.default!==void 0?e.default:(e.min+e.max)/2,d=(o=t.prefill[e.key])!=null?o:i,s=mr(d,r,e,t,a);if(n.appendChild(s),!a){const c=document.createElement("p");c.className="mt-1",c.style.cssText=`
1153
1147
  font-size: var(--fb-font-size-small);
1154
1148
  color: var(--fb-text-secondary-color);
1155
- `,f.textContent=Le(e,a),n.appendChild(f)}}function al(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=ae(e,l,t),c=t.prefill[e.key]||[],s=Array.isArray(c)?[...c]:[],f=(o=e.minCount)!=null?o:e.required?1:0,d=(a=e.maxCount)!=null?a:1/0,u=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<f;)s.push(u);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((y,v)=>{const C=y.querySelector("input[type=range]");C&&C.setAttribute("name",`${r}[${v}]`)})}function b(y=u,v=-1){const C=document.createElement("div");C.className="multiple-slider-item flex items-start gap-2";const w=`${r}[${p.children.length}]`,x=Pn(y,w,e,t,i);return x.style.flex="1",C.appendChild(x),v===-1?p.appendChild(C):p.insertBefore(C,p.children[v]),m(),C}function g(){if(i)return;const y=p.querySelectorAll(".multiple-slider-item"),v=y.length;y.forEach(C=>{let w=C.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
1149
+ `,c.textContent=Te(e,l),n.appendChild(c)}}function Hl(e,t,n,r){var o,l;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,i=ae(e,a,t),d=t.prefill[e.key]||[],s=Array.isArray(d)?[...d]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(l=e.maxCount)!=null?l:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;s.length<c;)s.push(f);const p=document.createElement("div");p.className="space-y-3",n.appendChild(p);function m(){p.querySelectorAll(".multiple-slider-item").forEach((b,v)=>{const E=b.querySelector("input[type=range]");E&&E.setAttribute("name",`${r}[${v}]`)})}function g(b=f,v=-1){const E=document.createElement("div");E.className="multiple-slider-item flex items-start gap-2";const w=`${r}[${p.children.length}]`,C=mr(b,w,e,t,i);return C.style.flex="1",E.appendChild(C),v===-1?p.appendChild(E):p.insertBefore(E,p.children[v]),m(),E}function x(){if(i)return;const b=p.querySelectorAll(".multiple-slider-item"),v=b.length;b.forEach(E=>{let w=E.querySelector(".remove-item-btn");w||(w=document.createElement("button"),w.type="button",w.className="remove-item-btn px-2 py-1 rounded",w.style.cssText=`
1156
1150
  color: var(--fb-error-color);
1157
1151
  background-color: transparent;
1158
1152
  transition: background-color var(--fb-transition-duration);
1159
1153
  margin-top: 8px;
1160
- `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var S;const z=Array.from(p.children).indexOf(C);p.children.length>f&&(s.splice(z,1),C.remove(),m(),h(),g(),(S=t.instance)==null||S.triggerOnChange(r))},C.appendChild(w));const x=v<=f;w.disabled=x,w.style.opacity=x?"0.5":"1",w.style.pointerEvents=x?"none":"auto"})}let E=null;if(!i){const y=ze("slider",()=>{var v;s.push(u),b(u),h(),g(),(v=t.instance)==null||v.triggerOnChange(r)},{label:e.addLabel});E=y.update,Te(n,y.counter),n.appendChild(y.row)}function h(){E&&E(s.length,d)}if(s.forEach(y=>b(y)),h(),g(),!i){const y=document.createElement("p");y.className="mt-1",y.style.cssText=`
1154
+ `,w.innerHTML="\u2715",w.addEventListener("mouseenter",()=>{w.style.backgroundColor="var(--fb-background-hover-color)"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="transparent"}),w.onclick=()=>{var y;const R=Array.from(p.children).indexOf(E);p.children.length>c&&(s.splice(R,1),E.remove(),m(),h(),x(),(y=t.instance)==null||y.triggerOnChange(r))},E.appendChild(w));const C=v<=c;w.disabled=C,w.style.opacity=C?"0.5":"1",w.style.pointerEvents=C?"none":"auto"})}let S=null;if(!i){const b=ze("slider",()=>{var v;s.push(f),g(f),h(),x(),(v=t.instance)==null||v.triggerOnChange(r)},{label:e.addLabel});S=b.update,Ae(n,b.counter),n.appendChild(b.row)}function h(){S&&S(s.length,u)}if(s.forEach(b=>g(b)),h(),x(),!i){const b=document.createElement("p");b.className="mt-1",b.style.cssText=`
1161
1155
  font-size: var(--fb-font-size-small);
1162
1156
  color: var(--fb-text-secondary-color);
1163
- `,y.textContent=Le(e,l),n.appendChild(y)}}function sl(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,u=e.scale||"linear",p=(b,g)=>{var E,h;if(!b)return;const y=`error-${b.getAttribute("name")||Math.random().toString(36).substring(7)}`;let v=document.getElementById(y);if(g){if(b.classList.add("invalid"),b.title=g,!v){v=document.createElement("div"),v.id=y,v.className="error-message",v.style.cssText=`
1164
- color: var(--fb-error-color);
1165
- font-size: var(--fb-font-size-small);
1166
- margin-top: 0.25rem;
1167
- `;const C=b.closest(".slider-container");C&&C.nextSibling?(E=C.parentNode)==null||E.insertBefore(v,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(v))}v.textContent=g,v.style.display="block"}else b.classList.remove("invalid"),b.title="",v&&v.remove()},m=(b,g)=>{const{state:E}=n,h=b.value;if(!h){if(!c&&e.required){const v=k("required",E);return l.push(`${g}: ${v}`),p(b,v),null}return p(b,null),null}let y;if(u==="exponential"){const v=parseFloat(h)/1e3;y=Un(v,s,f),y=pt(y,d)}else y=parseFloat(h),y=pt(y,d);if(!c){if(y<s){const v=k("minValue",E,{min:s});return l.push(`${g}: ${v}`),p(b,v),y}if(y>f){const v=k("maxValue",E,{max:f});return l.push(`${g}: ${v}`),p(b,v),y}}return p(b,null),y};if(e.multiple){const b=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`),g=[];if(b.forEach((E,h)=>{const y=m(E,`${t}[${h}]`);g.push(y)}),!c){const{state:E}=n,h=(o=e.minCount)!=null?o:0,y=(a=e.maxCount)!=null?a:1/0,v=g.filter(C=>C!==null);e.required&&v.length===0&&l.push(`${t}: ${k("required",E)}`),v.length<h&&l.push(`${t}: ${k("minItems",E,{min:h})}`),v.length>y&&l.push(`${t}: ${k("maxItems",E,{max:y})}`)}return{value:g,errors:l}}else{const b=i.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:l}:(!c&&e.required&&l.push(`${t}: ${k("required",n.state)}`),{value:null,errors:l})}}function cl(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,u)=>{if(u<n.length&&n[u]!==null){const p=Number(n[u]);if(s==="exponential"){const b=Ht(p,l,i);d.value=(b*1e3).toString()}else d.value=p.toString();const m=d.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(c<1?2:0));const g=(p-l)/(i-l)*100;d.style.background=`linear-gradient(
1157
+ `,b.textContent=Te(e,a),n.appendChild(b)}}function Bl(e,t,n){var r;const o=[],{scopeRoot:l}=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 a=e.min,i=e.max,d=(r=e.step)!=null?r:1,s=e.scale||"linear",c=(u,f)=>{const{state:p}=n,m=u.value;if(!m){const S=e.required?k("required",p):null;return S!==null&&o.push(`${f}: ${S}`),xe(u,S,n),null}const g=Yt(s==="exponential"?pr(parseFloat(m)/1e3,a,i):parseFloat(m),d);let x=null;return g<a?x=k("minValue",p,{min:a}):g>i&&(x=k("maxValue",p,{max:i})),x!==null&&o.push(`${f}: ${x}`),xe(u,x,n),g};if(e.multiple){const u=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),f=[];u.forEach((m,g)=>{f.push(c(m,`${t}[${g}]`))});const p=f.filter(m=>m!==null).length;return qe(e,t,p,n,o),{value:f,errors:o}}else{const u=l.querySelector(`input[type="range"][name="${t}"]`);return u?{value:c(u,t),errors:o}:(e.required&&o.push(`${t}: ${k("required",n.state)}`),{value:null,errors:o})}}function Dl(e,t,n,r){var o;const{scopeRoot:l}=r,a=e.min,i=e.max,d=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const c=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`);c.forEach((u,f)=>{if(f<n.length&&n[f]!==null){const p=Number(n[f]);if(s==="exponential"){const g=Xt(p,a,i);u.value=(g*1e3).toString()}else u.value=p.toString();const m=u.closest(".slider-container");if(m){const g=m.querySelector(".slider-value");g&&(g.textContent=p.toFixed(d<1?2:0));const x=(p-a)/(i-a)*100;u.style.background=`linear-gradient(
1168
1158
  to right,
1169
1159
  var(--fb-primary-color) 0%,
1170
- var(--fb-primary-color) ${g}%,
1171
- var(--fb-border-color) ${g}%,
1160
+ var(--fb-primary-color) ${x}%,
1161
+ var(--fb-border-color) ${x}%,
1172
1162
  var(--fb-border-color) 100%
1173
- )`}d.classList.remove("invalid"),d.title="",Ce(d)}}),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 p=Ht(d,l,i);f.value=(p*1e3).toString()}else f.value=d.toString();const u=f.closest(".slider-container");if(u){const p=u.querySelector(".slider-value");p&&(p.textContent=d.toFixed(c<1?2:0));const m=(d-l)/(i-l)*100;f.style.background=`linear-gradient(
1163
+ )`}we(u)}}),n.length!==c.length&&console.warn(`updateSliderField: Multiple field "${t}" has ${c.length} sliders but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const c=l.querySelector(`input[type="range"][name="${t}"]`);if(c&&n!==null&&n!==void 0){const u=Number(n);if(s==="exponential"){const p=Xt(u,a,i);c.value=(p*1e3).toString()}else c.value=u.toString();const f=c.closest(".slider-container");if(f){const p=f.querySelector(".slider-value");p&&(p.textContent=u.toFixed(d<1?2:0));const m=(u-a)/(i-a)*100;c.style.background=`linear-gradient(
1174
1164
  to right,
1175
1165
  var(--fb-primary-color) 0%,
1176
1166
  var(--fb-primary-color) ${m}%,
1177
1167
  var(--fb-border-color) ${m}%,
1178
1168
  var(--fb-border-color) 100%
1179
- )`}f.classList.remove("invalid"),f.title="",Ce(f)}}}function Wn(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function Vn(e,t){return{...t,...e}}function Dt(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):n.dataset.hiddenField?t[r]=Ct(n.value):t[r]=n.value:n instanceof HTMLTextAreaElement&&(t[r]=n.value))}),t}let jt=null;function dl(e){jt=e}function Kn(e,t){if(!jt)throw new Error("renderElement not initialized. Import from components/index.ts");return jt(e,t)}function _n(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const 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 Jn(e,t,n,r){var o,a;const l=document.createElement("div");l.className="border border-gray-200 rounded-lg p-2 bg-gray-50",l.setAttribute("data-container",r);const i=document.createElement("div"),c=e.columns||1;c===1?i.className="fb-row":i.className=`grid grid-cols-${c} gap-2`;const s=ae(e,t.state,t);if(!s){const m=_n(e,r);m&&l.appendChild(m)}const f=Wn(e.elements),d=((o=t.prefill)==null?void 0:o[e.key])||{},u=Vn(d,f),p={path:De(t.path,e.key),prefill:u,formData:(a=t.formData)!=null?a:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var b,g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const E=(g=(b=d[m.key])!=null?b:"default"in m?m.default:null)!=null?g:null;i.appendChild(Et(De(p.path,m.key),E))}else i.appendChild(Kn(m,p))}),l.appendChild(i),n.appendChild(l)}function ul(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function fl(e,t,n,r){const o=document.createElement("button");o.type="button",o.className="fb-item-remove",o.setAttribute("aria-label",r?k("removeRowFrom",n,{label:r}):k("removeRow",n)),o.style.cssText=`
1169
+ )`}we(c)}}}function hr(e){const t={};for(const n of e)n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default);return t}function br(e,t){return{...t,...e}}function Gt(e){const t={};return e.querySelectorAll("input, select, textarea").forEach(n=>{const r=n.getAttribute("name");r&&!r.includes("[")&&!r.includes(".")&&(n instanceof HTMLInputElement&&n.type==="radio"?n.checked&&(t[r]=n.value):t[r]=un(n))}),t}let Zt=null;function Ol(e){Zt=e}function gr(e,t){if(!Zt)throw new Error("renderElement not initialized. Import from components/index.ts");return Zt(e,t)}function vr(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const l=document.createElement("button");l.type="button",l.className="fb-prefill-hint",l.textContent=r.label,l.setAttribute("data-hint-values",JSON.stringify(r.values)),l.setAttribute("data-container-key",t),l.setAttribute("data-hint-index",String(o)),n.appendChild(l)}),n}function yr(e,t,n,r){var o,l;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const i=document.createElement("div"),d=e.columns||1;d===1?i.className="fb-row":i.className=`grid grid-cols-${d} gap-2`;const s=ae(e,t.state,t);if(!s){const m=vr(e,r);m&&a.appendChild(m)}const c=hr(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},f=br(u,c),p={path:Ue(t.path,e.key),prefill:f,formData:(l=t.formData)!=null?l:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:s||t.inheritedReadonly};e.elements.forEach(m=>{var g;if(m.type!=="markdown"&&(m.hidden||m.type==="hidden")){const x=m.key in u?u[m.key]:(g="default"in m?m.default:null)!=null?g:null;i.appendChild(At(Ue(p.path,m.key),x))}else i.appendChild(gr(m,p))}),a.appendChild(i),n.appendChild(a)}function jl(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function Ul(e,t,n,r){const o=document.createElement("button");o.type="button",o.className="fb-item-remove",o.setAttribute("aria-label",r?k("removeRowFrom",n,{label:r}):k("removeRow",n)),o.style.cssText=`
1180
1170
  width: 24px;
1181
1171
  height: 24px;
1182
1172
  display: inline-flex;
@@ -1187,7 +1177,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1187
1177
  border-radius: 4px;
1188
1178
  cursor: pointer;
1189
1179
  flex-shrink: 0;
1190
- `,o.innerHTML=Qt,o.onclick=t,o.style.position="absolute",o.style.top="var(--fb-row-remove-inset, 8px)",o.style.right="var(--fb-row-remove-inset, 8px)",o.style.zIndex="1",e.style.position="relative",e.classList.add("fb-row-removable"),e.insertBefore(o,e.firstChild)}function Xn(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=s||t.inheritedReadonly,d=document.createElement("div");d.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const u=document.createElement("div"),p=e.displayMode==="slides";if(p?u.className="fb-container-slides":u.className="fb-row",!s){const R=_n(e,e.key);R&&d.appendChild(R)}const m=(o=e.minCount)!=null?o:0,b=(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=Wn(e.elements);let h=0;const y=()=>h++,v=()=>Array.from(u.children).filter(R=>R.classList.contains("containerItem")),C=()=>v().length,w=R=>{var _;C()<=m||(R.remove(),ne(),(_=t.instance)==null||_.triggerOnChange(r))},x=(R,_,ie)=>{const pe={state:c,instance:t.instance,path:De(t.path,`${e.key}[${R}]`),prefill:Vn(_!=null?_:{},E),formData:ie,inheritedReadonly:f},me=document.createElement("div");me.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",me.setAttribute("data-container-item",pe.path),p&&me.setAttribute("data-fb-slide-card","");const Ae=document.createElement("div");return Ae.className=ul(p?void 0:e.columns),e.elements.forEach(xe=>{var $,I;if(xe.type!=="markdown"&&(xe.hidden||xe.type==="hidden")){const M=(I=($=_==null?void 0:_[xe.key])!=null?$:"default"in xe?xe.default:null)!=null?I:null;Ae.appendChild(Et(De(pe.path,xe.key),M))}else Ae.appendChild(Kn(xe,pe))}),me.appendChild(Ae),s||fl(me,()=>w(me),c,e.label),me},S=()=>{var R;if(C()>=b)return;const _=x(y(),null,c.formRoot?Dt(c.formRoot):{});z&&z.parentElement===u?u.insertBefore(_,z):u.appendChild(_),ne(),(R=t.instance)==null||R.triggerOnChange(r)};let z=null,ee=null,K=null;const H=()=>{if(!z)return;const R=v()[0];R&&R.offsetHeight>0&&(z.style.minHeight=`${R.offsetHeight}px`)},V=()=>{const R=C()<=m;v().forEach(_=>{const ie=Array.from(_.children).find(pe=>pe.classList.contains("fb-item-remove"));ie&&(ie.disabled=R)})},ne=()=>{const R=C();ee&&ee(R,b),K&&K(R,b),z&&H(),V()};if(g&&g.forEach(R=>{var _;u.appendChild(x(y(),R!=null?R:{},(_=t.formData)!=null?_:t.prefill))}),!s)for(;C()<m;)u.appendChild(x(y(),null,(i=t.formData)!=null?i:t.prefill));if(d.appendChild(u),!s)if(p){const R=Tr(S,{label:e.addLabel});z=R.tile,ee=R.update,Te(n,R.counter),u.appendChild(R.tile)}else{const R=ze("container",S,{label:e.addLabel});K=R.update,Te(n,R.counter),d.appendChild(R.row)}ne(),n.appendChild(d),z&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(H):H())}let Ot=null;function pl(e){Ot=e}function Yn(e,t,n){if(!Ot)throw new Error("validateElement not initialized. Should be set from FormBuilderInstance");return Ot(e,t,n)}function Gn(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,u;if(a)return;const{state:p}=n,m="minCount"in f&&(d=f.minCount)!=null?d:0,b="maxCount"in f&&(u=f.maxCount)!=null?u:1/0;f.required&&s.length===0&&r.push(`${c}: ${k("required",p)}`),s.length<m&&r.push(`${c}: ${k("minItems",p,{min:m})}`),s.length>b&&r.push(`${c}: ${k("maxItems",p,{max:b})}`)};if("multiple"in e&&e.multiple){const c=[];return nt(o,t).forEach(s=>{const f={},d=(s.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),u=d?parseInt(d[1],10):0;e.elements.forEach(p=>{var m;if(p.enableIf)try{const E=(m=n.instance)!=null&&m.getState().formRoot?Dt(n.instance.getState().formRoot):{};if(!je(p.enableIf,E,f))return}catch(E){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}[${u}]":`,E)}const b=`${t}[${u}].${p.key}`,g=Yn({...p,key:b},{path:l},s);g.spread&&g.value!==null&&typeof g.value=="object"?Object.assign(f,g.value):!g.skip&&p.key&&(f[p.key]=g.value)}),c.push(f)}),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 u=(d=n.instance)!=null&&d.getState().formRoot?Dt(n.instance.getState().formRoot):{};if(!je(f.enableIf,u,c))return}catch(u){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}":`,u)}{const u=`${t}.${f.key}`,p=Yn({...f,key:u},{path:l},s);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(c,p.value):!p.skip&&f.key&&(c[f.key]=p.value)}}),{value:c,errors:r}}}function Zn(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}const l=nt(a,t);n.forEach((i,c)=>{var s;const f=(s=l[c])==null?void 0:s.getAttribute("data-container-item");Je(i)&&f&&e.elements.forEach(d=>{var u,p;if(d.type==="markdown"||!d.key)return;const m=`${f}.${d.key}`;if(d.type==="richinput"&&d.flatOutput){const b=d,g=(u=b.textKey)!=null?u:"text",E=(p=b.filesKey)!=null?p:"files",h=i,y={};g in h&&(y[g]=h[g]),E in h&&(y[E]=h[E]),Object.keys(y).length>0&&o.updateField(m,y)}else{const b=i[d.key];b!==void 0&&o.updateField(m,b)}})}),n.length!==l.length&&console.warn(`updateContainerField: Multiple container field "${t}" received ${n.length} items for ${l.length} rendered rows. Rows are not added or removed here \u2014 re-render 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 i,c;if(l.type==="markdown"||!l.key)return;const s=`${t}.${l.key}`;if(l.type==="richinput"&&l.flatOutput){const f=l,d=(i=f.textKey)!=null?i:"text",u=(c=f.filesKey)!=null?c:"files",p=n,m={};d in p&&(m[d]=p[d]),u in p&&(m[u]=p[u]),Object.keys(m).length>0&&o.updateField(s,m)}else{const f=n[l.key];f!==void 0&&o.updateField(s,f)}})}}function ml(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&&Je(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(a=e.repeat)==null?void 0:a.max};l.multiple?Xn(l,t,n,r):Jn(l,t,n,r)}function Qn(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 hl(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=Qn(e);return Gn(r,t,n)}function bl(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=Qn(e);return Zn(o,t,n,r)}function gl(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function vl(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 yl(e){return gl(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:vl(e)?e:null}function We(e){return e.map(yl).filter(t=>t!==null)}function er(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ut(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let 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 tr(e,t,n){for(const r of n){if(r.top===e&&r.left===t)return null;if(e>=r.top&&e<=r.bottom&&t>=r.left&&t<=r.right)return r}return null}function mt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ne(e){var t;if(!e.anchor)return null;const n=(t=e.focus)!=null?t:e.anchor;return{r1:Math.min(e.anchor.row,n.row),c1:Math.min(e.anchor.col,n.col),r2:Math.max(e.anchor.row,n.row),c2:Math.max(e.anchor.col,n.col)}}function Ve(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1180
+ `,o.innerHTML=yn,o.onclick=t,o.style.position="absolute",o.style.top="var(--fb-row-remove-inset, 8px)",o.style.right="var(--fb-row-remove-inset, 8px)",o.style.zIndex="1",e.style.position="relative",e.classList.add("fb-row-removable"),e.insertBefore(o,e.firstChild)}function xr(e,t,n,r){var o,l,a,i;const d=t.state,s=ae(e,d,t),c=s||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),p=e.displayMode==="slides";if(p?f.className="fb-container-slides":f.className="fb-row",!s){const I=vr(e,e.key);I&&u.appendChild(I)}const m=(o=e.minCount)!=null?o:0,g=(l=e.maxCount)!=null?l:1/0,x=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,S=hr(e.elements);let h=0;const b=()=>h++,v=()=>Array.from(f.children).filter(I=>I.classList.contains("containerItem")),E=()=>v().length,w=I=>{var P;E()<=m||(I.remove(),O(),(P=t.instance)==null||P.triggerOnChange(r))},C=(I,P,ie)=>{const se={state:d,instance:t.instance,path:Ue(t.path,`${e.key}[${I}]`),prefill:br(P!=null?P:{},S),formData:ie,inheritedReadonly:c},fe=document.createElement("div");fe.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",fe.setAttribute("data-container-item",se.path),p&&fe.setAttribute("data-fb-slide-card","");const Ce=document.createElement("div");return Ce.className=jl(p?void 0:e.columns),e.elements.forEach(ge=>{var Oe;if(ge.type!=="markdown"&&(ge.hidden||ge.type==="hidden")){const $=P&&ge.key in P?P[ge.key]:(Oe="default"in ge?ge.default:null)!=null?Oe:null;Ce.appendChild(At(Ue(se.path,ge.key),$))}else Ce.appendChild(gr(ge,se))}),fe.appendChild(Ce),s||Ul(fe,()=>w(fe),d,e.label),fe},y=()=>{var I;if(E()>=g)return;const P=C(b(),null,d.formRoot?Gt(d.formRoot):{});R&&R.parentElement===f?f.insertBefore(P,R):f.appendChild(P),O(),(I=t.instance)==null||I.triggerOnChange(r)};let R=null,K=null,Y=null;const _=()=>{if(!R)return;const I=v()[0];I&&I.offsetHeight>0&&(R.style.minHeight=`${I.offsetHeight}px`)},Q=()=>{const I=E()<=m;v().forEach(P=>{const ie=Array.from(P.children).find(se=>se.classList.contains("fb-item-remove"));ie&&(ie.disabled=I)})},O=()=>{const I=E();K&&K(I,g),Y&&Y(I,g),R&&_(),Q()};if(x&&x.forEach(I=>{var P;f.appendChild(C(b(),I!=null?I:{},(P=t.formData)!=null?P:t.prefill))}),!s)for(;E()<m;)f.appendChild(C(b(),null,(i=t.formData)!=null?i:t.prefill));if(u.appendChild(f),!s)if(p){const I=Gr(y,{label:e.addLabel});R=I.tile,K=I.update,Ae(n,I.counter),f.appendChild(I.tile)}else{const I=ze("container",y,{label:e.addLabel});Y=I.update,Ae(n,I.counter),u.appendChild(I.row)}O(),n.appendChild(u),R&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(_):_())}function Pl(e){if(!e.validateElement)throw new Error("validateContainerElement: context.validateElement missing \u2014 container validation requires the instance validator");return e.validateElement}function wr(e,t,n){const r=Pl(n),o=[],{scopeRoot:l,path:a}=n;if(!("elements"in e))return{value:null,errors:o};if("multiple"in e&&e.multiple){const i=[];return at(l,t).forEach(d=>{const s={},c=(d.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),u=c?parseInt(c[1],10):0;e.elements.forEach(f=>{var p;if(f.enableIf)try{const x=(p=n.instance)!=null&&p.getState().formRoot?Gt(n.instance.getState().formRoot):{};if(!Pe(f.enableIf,x,s))return}catch(x){console.error(`Error evaluating enableIf for field "${f.key}" in container "${t}[${u}]":`,x)}const m=`${t}[${u}].${f.key}`,g=r({...f,key:m},{path:a,inheritedReadonly:n.readonly},d);g.spread&&g.value!==null&&typeof g.value=="object"?Object.assign(s,g.value):!g.skip&&f.key&&(s[f.key]=g.value)}),i.push(s)}),qe(e,t,i.length,n,o),{value:i,errors:o}}else{const i={},d=l.querySelector(`[data-container="${t}"]`)||l;return e.elements.forEach(s=>{var c;if(s.enableIf)try{const u=(c=n.instance)!=null&&c.getState().formRoot?Gt(n.instance.getState().formRoot):{};if(!Pe(s.enableIf,u,i))return}catch(u){console.error(`Error evaluating enableIf for field "${s.key}" in container "${t}":`,u)}{const u=`${t}.${s.key}`,f=r({...s,key:u},{path:a,inheritedReadonly:n.readonly},d);f.spread&&f.value!==null&&typeof f.value=="object"?Object.assign(i,f.value):!f.skip&&s.key&&(i[s.key]=f.value)}}),{value:i,errors:o}}}function Cr(e,t,n,r){const{instance:o,scopeRoot:l}=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}const a=at(l,t);n.forEach((i,d)=>{var s;const c=(s=a[d])==null?void 0:s.getAttribute("data-container-item");Ge(i)&&c&&e.elements.forEach(u=>{var f,p;if(u.type==="markdown"||!u.key)return;const m=`${c}.${u.key}`;if(u.type==="richinput"&&u.flatOutput){const g=u,x=(f=g.textKey)!=null?f:"text",S=(p=g.filesKey)!=null?p:"files",h=i,b={};x in h&&(b[x]=h[x]),S in h&&(b[S]=h[S]),Object.keys(b).length>0&&o.updateField(m,b)}else{const g=i[u.key];g!==void 0&&o.updateField(m,g)}})}),n.length!==a.length&&console.warn(`updateContainerField: Multiple container field "${t}" received ${n.length} items for ${a.length} rendered rows. Rows are not added or removed here \u2014 re-render for add/remove.`)}else{if(!Ge(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(a=>{var i,d;if(a.type==="markdown"||!a.key)return;const s=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const c=a,u=(i=c.textKey)!=null?i:"text",f=(d=c.filesKey)!=null?d:"files",p=n,m={};u in p&&(m[u]=p[u]),f in p&&(m[f]=p[f]),Object.keys(m).length>0&&o.updateField(s,m)}else{const c=n[a.key];c!==void 0&&o.updateField(s,c)}})}}function Wl(e,t,n,r){var o,l;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const a={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Ge(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(l=e.repeat)==null?void 0:l.max};a.multiple?xr(a,t,n,r):yr(a,t,n,r)}function Er(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&&Ge(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function Vl(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=Er(e);return wr(r,t,n)}function Kl(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=Er(e);return Cr(o,t,n,r)}function _l(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function Jl(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 Xl(e){return _l(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:Jl(e)?e:null}function _e(e){return e.map(Xl).filter(t=>t!==null)}function kr(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Qt(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 l=r+1;l<e.length;l++){const a=e[l];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${l} overlap`}}return null}function $r(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 xt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Ie(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 Je(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1191
1181
  position: absolute;
1192
1182
  width: ${e.size}px;
1193
1183
  height: ${e.size}px;
@@ -1207,7 +1197,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1207
1197
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
1208
1198
  transition: transform 0.1s, opacity 0.1s;
1209
1199
  pointer-events: all;
1210
- `,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 xl(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=`
1200
+ `,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 Yl(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,l=document.createElement("table");l.style.cssText=`
1211
1201
  width: 100%;
1212
1202
  border-collapse: collapse;
1213
1203
  border: var(--fb-border-width) solid var(--fb-border-color);
@@ -1215,13 +1205,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1215
1205
  font-size: var(--fb-font-size);
1216
1206
  font-family: var(--fb-font-family);
1217
1207
  color: var(--fb-text-color);
1218
- `,n.forEach((i,c)=>{var s,f;const d=(c===0?a.createTHead():(s=a.tBodies[0])!=null?s:a.createTBody()).insertRow();for(let u=0;u<o;u++){if(tr(c,u,r))continue;const p=mt(c,u,r),m=document.createElement(c===0?"th":"td");if(p){const b=p.bottom-p.top+1,g=p.right-p.left+1;b>1&&(m.rowSpan=b),g>1&&(m.colSpan=g)}m.textContent=(f=i[u])!=null?f:"",m.style.cssText=`
1208
+ `,n.forEach((i,d)=>{var s,c;const u=(d===0?l.createTHead():(s=l.tBodies[0])!=null?s:l.createTBody()).insertRow();for(let f=0;f<o;f++){if($r(d,f,r))continue;const p=xt(d,f,r),m=document.createElement(d===0?"th":"td");if(p){const g=p.bottom-p.top+1,x=p.right-p.left+1;g>1&&(m.rowSpan=g),x>1&&(m.colSpan=x)}m.textContent=(c=i[f])!=null?c:"",m.style.cssText=`
1219
1209
  padding: 6px 10px;
1220
1210
  border: var(--fb-border-width) solid var(--fb-border-color);
1221
1211
  text-align: left;
1222
1212
  vertical-align: top;
1223
- ${c===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1224
- `,d.appendChild(m)}});const l=document.createElement("div");l.style.cssText="overflow-x: auto; max-width: 100%;",l.appendChild(a),t.appendChild(l)}function wl(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 u=r();u[t]&&(u[t][n]=(d=e.textContent)!=null?d:""),o()}function s(d){var u,p,m,b;const g=r(),E=(p=(u=g[0])==null?void 0:u.length)!=null?p:0;if(d.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(m=g[t])==null?void 0:m[n])!=null?b:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",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,y=d.shiftKey?n-1:n+1;y<0&&(y=E-1,h=Math.max(0,t-1)),y>=E&&(y=0,h=Math.min(g.length-1,t+1)),a(h,y)}}function f(){e.contentEditable==="true"&&(c(),e.removeEventListener("keydown",s),e.removeEventListener("blur",f))}e.addEventListener("keydown",s),e.addEventListener("blur",f)}function Cl(){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 El(e,t){Cl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1213
+ ${d===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1214
+ `,u.appendChild(m)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(l),t.appendChild(a)}function Gl(e,t,n,r,o,l){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),i=window.getSelection();a.selectNodeContents(e),a.collapse(!1),i==null||i.removeAllRanges(),i==null||i.addRange(a);function d(){var u;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(u=e.textContent)!=null?u:""),o()}function s(u){var f,p,m,g;const x=r(),S=(p=(f=x[0])==null?void 0:f.length)!=null?p:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(g=(m=x[t])==null?void 0:m[n])!=null?g:"",e.removeEventListener("keydown",s),e.removeEventListener("blur",c);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",c);const h=t+1<x.length?t+1:t;l(h,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",c);let h=t,b=u.shiftKey?n-1:n+1;b<0&&(b=S-1,h=Math.max(0,t-1)),b>=S&&(b=0,h=Math.min(x.length-1,t+1)),l(h,b)}}function c(){e.contentEditable==="true"&&(d(),e.removeEventListener("keydown",s),e.removeEventListener("blur",c))}e.addEventListener("keydown",s),e.addEventListener("blur",c)}function Zl(){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 Ql(e,t){Zl();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1225
1215
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
1226
1216
  background: rgba(255,255,255,0.8); display: flex;
1227
1217
  align-items: center; justify-content: center; flex-direction: column;
@@ -1230,13 +1220,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1230
1220
  width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
1231
1221
  border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
1232
1222
  animation: fb-spin 0.8s linear infinite;
1233
- `;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 kl(e,t,n,r,o){var a,l,i,c,s,f,d,u;const p=r.state,m=r.instance,b=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]):er((s=e.rows)!=null?s:3,(f=e.columns)!=null?f:3);let y=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},C=document.createElement("input");C.type="hidden",C.name=n,C.value=JSON.stringify({[g]:h,[E]:y}),o.appendChild(C);function w(){C.value=JSON.stringify({[g]:h,[E]:y}),m&&m.triggerOnChange(n,{[g]:h,[E]:y})}C._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),y.length=0,A.merges&&A.merges.forEach(T=>y.push({...T})),v.anchor=null,v.focus=null,w(),N()};const x=document.createElement("div");x.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const S=document.createElement("table");S.style.cssText=`
1223
+ `;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 ei(e,t,n,r,o){var l,a,i,d,s,c,u,f;const p=r.state,m=r.instance,g=e.mergeAllowed!==!1,x=(a=(l=e.fieldNames)==null?void 0:l.cells)!=null?a:"cells",S=(d=(i=e.fieldNames)==null?void 0:i.merges)!=null?d:"merges",h=t.cells.length>0?t.cells.map(A=>[...A]):kr((s=e.rows)!=null?s:3,(c=e.columns)!=null?c:3);let b=t.merges?[...t.merges]:[];const v={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[x]:h,[S]:b}),o.appendChild(E);function w(){E.value=JSON.stringify({[x]:h,[S]:b}),m&&m.triggerOnChange(n,{[x]:h,[S]:b})}E._applyExternalUpdate=A=>{h.length=0,A.cells.forEach(T=>h.push([...T])),b.length=0,A.merges&&A.merges.forEach(T=>b.push({...T})),v.anchor=null,v.focus=null,w(),z()};const C=document.createElement("div");C.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const y=document.createElement("table");y.style.cssText=`
1234
1224
  border-collapse: collapse;
1235
1225
  font-size: var(--fb-font-size);
1236
1226
  font-family: var(--fb-font-family);
1237
1227
  color: var(--fb-text-color);
1238
1228
  table-layout: fixed;
1239
- `,x.appendChild(S);const z=(u=(d=e.importAccept)==null?void 0:d.map(A=>`.${A.toLowerCase()}`))!=null?u:[];async function ee(A){var T,L,D;if(!p.config.parseTableFile)return;if(z.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!z.includes(F))return}const j=El(x,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),te=F.cells,U=(T=F.merges)!=null?T:[];if(U.length>0){const P=Ut(U,te.length,(D=(L=te[0])==null?void 0:L.length)!=null?D:0);if(P)throw new Error(P)}h.length=0,te.forEach(P=>h.push([...P])),y.length=0,U.forEach(P=>y.push({...P})),v.anchor=null,v.focus=null,w(),N()}catch(F){const te=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p).replace("{error}",te))}finally{j.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=k("tableImportFile",p),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
1229
+ `,C.appendChild(y);const R=(f=(u=e.importAccept)==null?void 0:u.map(A=>`.${A.toLowerCase()}`))!=null?f:[];async function K(A){var T,L,H;if(!p.config.parseTableFile)return;if(R.length>0){const F=A.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!R.includes(F))return}const B=Ql(C,k("tableImporting",p));try{const F=await p.config.parseTableFile(A),re=F.cells,j=(T=F.merges)!=null?T:[];if(j.length>0){const U=Qt(j,re.length,(H=(L=re[0])==null?void 0:L.length)!=null?H:0);if(U)throw new Error(U)}h.length=0,re.forEach(U=>h.push([...U])),b.length=0,j.forEach(U=>b.push({...U})),v.anchor=null,v.focus=null,w(),z()}catch(F){const re=F instanceof Error?F.message:String(F);console.error(k("tableImportError",p,{error:re}))}finally{B.remove()}}if(e.importAccept&&p.config.parseTableFile){const A=document.createElement("button");A.type="button",A.title=k("tableImportFile",p),A.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/></svg>',A.style.cssText=`
1240
1230
  position: absolute; top: 2px; left: 2px;
1241
1231
  width: 20px; height: 20px;
1242
1232
  padding: 0;
@@ -1246,7 +1236,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1246
1236
  background: transparent;
1247
1237
  cursor: pointer;
1248
1238
  z-index: 2;
1249
- `,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 D;const j=(D=T.files)==null?void 0:D[0];j&&ee(j),T.value=""}),x.appendChild(A);let L=0;x.addEventListener("dragenter",D=>{D.preventDefault(),L++,L===1&&(x.style.outline="2px dashed var(--fb-primary-color, #0066cc)",x.style.outlineOffset="-2px")}),x.addEventListener("dragover",D=>{D.preventDefault(),D.dataTransfer&&(D.dataTransfer.dropEffect="copy")}),x.addEventListener("dragleave",D=>{D.preventDefault(),L--,L<=0&&(L=0,x.style.outline="",x.style.outlineOffset="")}),x.addEventListener("drop",D=>{var j,F;D.preventDefault(),L=0,x.style.outline="",x.style.outlineOffset="";const te=(F=(j=D.dataTransfer)==null?void 0:j.files)==null?void 0:F[0];te&&ee(te)})}o.appendChild(x);const K=document.createElement("div");K.style.cssText=`
1239
+ `,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=R.join(","),T.style.display="none",C.appendChild(T),A.addEventListener("click",()=>{T.click()}),T.addEventListener("change",()=>{var H;const B=(H=T.files)==null?void 0:H[0];B&&K(B),T.value=""}),C.appendChild(A);let L=0;C.addEventListener("dragenter",H=>{H.preventDefault(),L++,L===1&&(C.style.outline="2px dashed var(--fb-primary-color, #0066cc)",C.style.outlineOffset="-2px")}),C.addEventListener("dragover",H=>{H.preventDefault(),H.dataTransfer&&(H.dataTransfer.dropEffect="copy")}),C.addEventListener("dragleave",H=>{H.preventDefault(),L--,L<=0&&(L=0,C.style.outline="",C.style.outlineOffset="")}),C.addEventListener("drop",H=>{var B,F;H.preventDefault(),L=0,C.style.outline="",C.style.outlineOffset="";const re=(F=(B=H.dataTransfer)==null?void 0:B.files)==null?void 0:F[0];re&&K(re)})}o.appendChild(C);const Y=document.createElement("div");Y.style.cssText=`
1250
1240
  position: fixed;
1251
1241
  display: none;
1252
1242
  background: white;
@@ -1257,7 +1247,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1257
1247
  z-index: 1000;
1258
1248
  gap: 4px;
1259
1249
  flex-direction: column;
1260
- `,o.appendChild(K);function H(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
1250
+ `,o.appendChild(Y);function _(A,T){const L=document.createElement("button");return L.type="button",L.textContent=A,L.style.cssText=`
1261
1251
  padding: 4px 10px;
1262
1252
  font-size: var(--fb-font-size-small);
1263
1253
  color: var(--fb-text-color);
@@ -1267,8 +1257,8 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1267
1257
  cursor: pointer;
1268
1258
  white-space: nowrap;
1269
1259
  text-align: left;
1270
- `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{ne(),T()}),L}function V(A,T){if(!b)return;K.innerHTML="",K.style.display="flex";const L=Ne(v),D=L&&(L.r1!==L.r2||L.c1!==L.c2),j=v.anchor&&mt(v.anchor.row,v.anchor.col,y);if(D&&K.appendChild(H(k("tableMergeCells",p),I)),j&&K.appendChild(H(k("tableSplitCell",p),M)),!K.firstChild){ne();return}const F=140,te=K.children.length*32+8,U=window.innerWidth,P=window.innerHeight,J=A+F>U?A-F:A,G=T+te>P?T-te:T;K.style.left=`${J}px`,K.style.top=`${G}px`}function ne(){K.style.display="none"}const R=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){R.abort();return}K.contains(A.target)||ne()},{signal:R.signal});function _(){const A=Ne(v);S.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),D=parseInt(T.getAttribute("data-col")||"0",10),j=v.anchor!==null&&v.anchor.row===L&&v.anchor.col===D,F=A!==null&&L>=A.r1&&L<=A.r2&&D>=A.c1&&D<=A.c2;T.style.outline=j?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=j?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!j?"rgba(0,102,204,0.08)":""})}function ie(A,T){v.anchor={row:A,col:T},v.focus=null,_(),S.focus()}function pe(A,T){const L=S.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const D=L.querySelector("span");D&&(v.anchor={row:A,col:T},v.focus=null,_(),wl(D,A,T,()=>h,w,ie))}function me(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,D=Array(L).fill(""),j=A!==void 0?A+1:h.length;h.splice(j,0,D),y=y.map(F=>F.top>=j?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<j&&F.bottom>=j?{...F,bottom:F.bottom+1}:F),w(),N()}function Ae(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;y=y.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),w(),N()}function xe(A){var T,L;const D=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(j=>j.splice(D,0,"")),y=y.map(j=>j.left>=D?{...j,left:j.left+1,right:j.right+1}:j.left<D&&j.right>=D?{...j,right:j.right+1}:j),w(),N()}function $(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;y=y.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),w(),N()}function I(){var A,T;if(!b)return;const L=Ne(v);if(!L)return;const{r1:D,c1:j,r2:F,c2:te}=L;if(D===F&&j===te)return;y=y.filter(O=>!(O.top<=F&&O.bottom>=D&&O.left<=te&&O.right>=j));const U=h[D][j];for(let O=D;O<=F;O++)for(let Z=j;Z<=te;Z++)(O!==D||Z!==j)&&(h[O][Z]="");h[D][j]=U;const P={top:D,left:j,bottom:F,right:te},J=[...y,P],G=Ut(J,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(G){console.warn("Merge validation failed:",G);return}y.push(P),v.anchor={row:D,col:j},v.focus=null,w(),N()}function M(){if(!b||!v.anchor)return;const{row:A,col:T}=v.anchor,L=y.findIndex(D=>D.top===A&&D.left===T);L!==-1&&(y.splice(L,1),v.focus=null,w(),N())}function N(){var A,T;S.innerHTML="";const L=h.length,D=L>0?h[0].length:0,j=Ne(v);for(let F=0;F<L;F++){const te=(F===0?(A=S.tHead)!=null?A:S.createTHead():(T=S.tBodies[0])!=null?T:S.createTBody()).insertRow();for(let U=0;U<D;U++){if(tr(F,U,y))continue;const P=mt(F,U,y),J=document.createElement("td");if(J.setAttribute("data-row",String(F)),J.setAttribute("data-col",String(U)),P){const Q=P.bottom-P.top+1,X=P.right-P.left+1;Q>1&&(J.rowSpan=Q),X>1&&(J.colSpan=X)}const G=j!==null&&F>=j.r1&&F<=j.r2&&U>=j.c1&&U<=j.c2,O=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===U;J.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;":"",G&&!O?"background-color: rgba(0,102,204,0.08);":"",O?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const Z=document.createElement("span");Z.textContent=h[F][U],Z.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",J.appendChild(Z);const Y=F,le=U;J.addEventListener("mousedown",Q=>{if(Q.target.tagName!=="BUTTON"&&Q.target.contentEditable!=="true"){if(Q.button===2){const X=Ne(v);if(X&&Y>=X.r1&&Y<=X.r2&&le>=X.c1&&le<=X.c2)return}Q.shiftKey&&v.anchor?(Q.preventDefault(),v.focus={row:Y,col:le},v.dragging=!1,_()):(v.anchor={row:Y,col:le},v.focus=null,v.dragging=!0,_())}}),J.addEventListener("mouseup",Q=>{if(Q.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const X=Ne(v);(!X||X.r1===X.r2&&X.c1===X.c2)&&pe(Y,le)}}),J.addEventListener("mousemove",Q=>{if(v.dragging&&Q.buttons===1){const X=v.anchor;X&&(X.row!==Y||X.col!==le)&&(v.focus={row:Y,col:le},_())}}),J.addEventListener("contextmenu",Q=>{if(!b)return;const X=Ne(v),he=X&&(X.r1!==X.r2||X.c1!==X.c2),fe=v.anchor&&mt(v.anchor.row,v.anchor.col,y);(he||fe)&&(Q.preventDefault(),V(Q.clientX,Q.clientY))}),te.appendChild(J)}}ge(),S.setAttribute("tabindex","0"),S.onkeydown=F=>{var te,U;if(S.querySelector("[contenteditable='true']"))return;const P=v.anchor;if(!P)return;const J=h.length,G=J>0?h[0].length:0,O={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(O[F.key]){F.preventDefault();const[Z,Y]=O[F.key],le=Math.max(0,Math.min(J-1,P.row+Z)),Q=Math.max(0,Math.min(G-1,P.col+Y));F.shiftKey?(v.focus={row:le,col:Q},_()):ie(le,Q);return}if(F.key==="Enter"){F.preventDefault(),pe(P.row,P.col);return}if(F.key==="Tab"){F.preventDefault();const Z=(U=(te=h[0])==null?void 0:te.length)!=null?U:0;let Y=P.row,le=F.shiftKey?P.col-1:P.col+1;le<0&&(le=Z-1,Y=Math.max(0,Y-1)),le>=Z&&(le=0,Y=Math.min(h.length-1,Y+1)),ie(Y,le);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),I();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),M())},S.oncopy=F=>{var te,U,P,J;const G=Ne(v);if(!G)return;F.preventDefault();const{r1:O,c1:Z,r2:Y,c2:le}=G,Q=[],X=[];for(let W=O;W<=Y;W++){const ue=[],ve=[];for(let ye=Z;ye<=le;ye++){const ke=(U=(te=h[W])==null?void 0:te[ye])!=null?U:"";ue.push(ke);const He=ke.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ve.push(`<td>${He}</td>`)}Q.push(ue.join(" ")),X.push(`<tr>${ve.join("")}</tr>`)}const he=Q.join(`
1271
- `),fe=`<table>${X.join("")}</table>`;(P=F.clipboardData)==null||P.setData("text/plain",he),(J=F.clipboardData)==null||J.setData("text/html",fe)},S.onpaste=F=>{var te,U,P,J,G,O,Z,Y,le;const Q=v.anchor;if(!Q)return;const X=(U=(te=F.clipboardData)==null?void 0:te.getData("text/plain"))!=null?U:"",he=X.includes(" ")||X.split(/\r?\n/).filter(be=>be).length>1,fe=S.querySelector("[contenteditable='true']");if(fe&&!he)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const be=parseInt((J=(P=fe.closest("td"))==null?void 0:P.getAttribute("data-row"))!=null?J:"0",10),Ie=parseInt((O=(G=fe.closest("td"))==null?void 0:G.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(Z=fe.textContent)!=null?Z:"")}if(!X.trim())return;const W=X.split(/\r?\n/).map(be=>be.split(" "));W.length>1&&W[W.length-1].length===1&&W[W.length-1][0]===""&&W.pop();const ue=Q.row,ve=Q.col,ye=ue+W.length;for(;h.length<ye;)h.push(Array((le=(Y=h[0])==null?void 0:Y.length)!=null?le:1).fill(""));const ke=Math.max(...W.map(be=>be.length)),He=ve+ke;if(h[0]&&He>h[0].length){const be=He-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<be;tt++)Ie.push("")})}for(let be=0;be<W.length;be++)for(let Ie=0;Ie<W[be].length;Ie++){const tt=ue+be,di=ve+Ie;h[tt]&&(h[tt][di]=W[be][Ie])}w(),N()}}const q=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterCol)!=null?A:"0",10);xe(T)}});q.style.position="absolute",q.style.display="none",x.appendChild(q);const B=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=B.dataset.afterRow)!=null?A:"0",10);me(T)}});B.style.position="absolute",B.style.display="none",x.appendChild(B);let re=[],oe=[];const de=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});de.style.position="absolute",de.style.display="none",x.appendChild(de);const ce=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>me()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);function ge(){var A,T;re.forEach(U=>U.remove()),re=[],oe.forEach(U=>U.remove()),oe=[];const L=h.length>0?h[0].length:0,D=h.length;if(L>1){const U=Array.from(S.querySelectorAll("thead td[data-col]"));for(const P of U){const J=parseInt((A=P.getAttribute("data-col"))!=null?A:"0",10),G=Ve({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(J)});G.setAttribute("data-action","remove-col"),G.setAttribute("data-col",String(J)),G.style.position="absolute",G.style.display="none",x.appendChild(G),re.push(G)}}if(D>1){const U=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(P=>P.querySelector("td[data-row]"));for(const P of U){const J=P.querySelector("td[data-row]");if(!J)continue;const G=parseInt((T=J.getAttribute("data-row"))!=null?T:"0",10),O=Ve({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ae(G)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(G)),O.style.position="absolute",O.style.display="none",x.appendChild(O),oe.push(O)}}function j(U,P,J,G,O){var Z;const Y=O?Array.from(S.querySelectorAll("thead td[data-col]")):[];let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.right);ke<fe&&ke<20&&(fe=ke,X=ue.right-P.left+G,he=parseInt((Z=Y[W].getAttribute("data-col"))!=null?Z:"0",10))}re.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.left+ve.right)/2-P.left+G;W.style.left=`${ye-8}px`,W.style.top="2px",W.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.left=`${X-10}px`,q.style.top=`${J.top-P.top-10}px`,q.dataset.afterCol=String(he)):q.style.display="none"}function F(U,P,J,G,O){var Z;const Y=[];if(O){if(S.tHead)for(const W of Array.from(S.tHead.rows))W.querySelector("td[data-row]")&&Y.push(W);if(S.tBodies[0])for(const W of Array.from(S.tBodies[0].rows))W.querySelector("td[data-row]")&&Y.push(W)}let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.bottom);if(ke<fe&&ke<14){fe=ke,X=ue.bottom-P.top;const He=Y[W].querySelector("td[data-row]");he=parseInt((Z=He==null?void 0:He.getAttribute("data-row"))!=null?Z:"0",10)}}oe.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.top+ve.bottom)/2-P.top;W.style.left="4px",W.style.top=`${ye-8}px`,W.style.display="flex"}),O&&he>=0?(B.style.display="flex",B.style.top=`${X-10}px`,B.style.left=`${J.left-P.left+G-10}px`,B.dataset.afterRow=String(he)):B.style.display="none"}let te=!1;x.onmousemove=U=>{const P=U.target;if(P.tagName==="BUTTON"&&P.parentElement===x||te)return;te=!0;const J=U.clientX,G=U.clientY;requestAnimationFrame(()=>{te=!1;const O=x.getBoundingClientRect(),Z=S.getBoundingClientRect(),Y=x.scrollLeft,le=G>=O.top&&G<Z.top+4,Q=J>=O.left&&J<Z.left+4,X=Math.min(Z.right,O.right),he=J>X-20&&J<=O.right,fe=G>Z.bottom-4&&G<=O.bottom+20;if(j(J,O,Z,Y,le),F(G,O,Z,Y,Q),de.style.display=he?"flex":"none",he&&(de.style.left=`${O.right-O.left+Y-20}px`,de.style.top=`${(Z.top+Z.bottom)/2-O.top-10}px`),ce.style.display=fe?"flex":"none",fe){const W=(O.left+O.right)/2-O.left+Y;ce.style.left=`${W-10}px`,ce.style.top=`${Z.bottom-O.top-10}px`}})},x.onmouseleave=()=>{re.forEach(U=>{U.style.display="none"}),oe.forEach(U=>{U.style.display="none"}),q.style.display="none",B.style.display="none",de.style.display="none",ce.style.display="none"}}N()}function $l(e){var t,n;return{cells:er((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Pt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Wt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Sl(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=t.prefill[e.key],d=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",u=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges";let p;if(Pt(f))p={cells:f.cells,merges:f.merges?We(f.merges):[]};else if(f&&Wt(f,d)){const m=f[u];p={cells:f[d],merges:m?We(m):[]}}else if(Pt(e.default))p={cells:e.default.cells,merges:e.default.merges?We(e.default.merges):[]};else if(e.default&&Wt(e.default,d)){const m=e.default[u];p={cells:e.default[d],merges:m?We(m):[]}}else p=$l(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Ut(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}s?xl(p,n):kl(e,p,r,t,n)}function Ll(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;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(u=>u.some(p=>p.trim()!==""))||i.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:i}}function Tl(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 u=null;if(Pt(n))u={cells:n.cells,merges:n.merges?We(n.merges):[]};else if(n&&Wt(n,s)){const p=n[f];u={cells:n[s],merges:p?We(p):[]}}u&&d._applyExternalUpdate?d._applyExternalUpdate(u):d.value=JSON.stringify(n)}function Al(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const a=new ResizeObserver(l=>{var i,c,s,f,d;if(!e.isConnected){a.disconnect();return}const u=l[0],p=(d=(f=(c=(i=u==null?void 0:u.contentBoxSize)==null?void 0:i[0])==null?void 0:c.inlineSize)!=null?f:(s=u==null?void 0:u.contentRect)==null?void 0:s.width)!=null?d:0;p!==o&&(o=p,r())});a.observe(e)}function Vt(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} (${xr(s.size)})`):l.set(c,f)}return l}function Kt(e){return e?e.type.startsWith("image/"):!1}function nr(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ht(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let 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 Fl(e,t){if(t.size===0)return[];const n=ht(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 zl(e,t){const n=Fl(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 rr(e,t,n){const r=Vt(t,n),o=new Map;for(const c of t){const s=r.get(c);s&&o.set(c,s)}const a=ht(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+=_t(s):l+=c.raw,i=c.end}return l+=e.slice(i),l}function or(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const 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;",we(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 lr(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const 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;",we(e),e.appendChild(l)}).catch(o=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,o,t)})}function ir(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 ar(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=`
1260
+ `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{O(),T()}),L}function Q(A,T){if(!g)return;Y.innerHTML="",Y.style.display="flex";const L=Ie(v),H=L&&(L.r1!==L.r2||L.c1!==L.c2),B=v.anchor&&xt(v.anchor.row,v.anchor.col,b);if(H&&Y.appendChild(_(k("tableMergeCells",p),$)),B&&Y.appendChild(_(k("tableSplitCell",p),N)),!Y.firstChild){O();return}const F=140,re=Y.children.length*32+8,j=window.innerWidth,U=window.innerHeight,J=A+F>j?A-F:A,Z=T+re>U?T-re:T;Y.style.left=`${J}px`,Y.style.top=`${Z}px`}function O(){Y.style.display="none"}const I=new AbortController;document.addEventListener("mousedown",A=>{if(!o.isConnected){I.abort();return}Y.contains(A.target)||O()},{signal:I.signal});function P(){const A=Ie(v);y.querySelectorAll("td[data-row]").forEach(T=>{const L=parseInt(T.getAttribute("data-row")||"0",10),H=parseInt(T.getAttribute("data-col")||"0",10),B=v.anchor!==null&&v.anchor.row===L&&v.anchor.col===H,F=A!==null&&L>=A.r1&&L<=A.r2&&H>=A.c1&&H<=A.c2;T.style.outline=B?"2px solid var(--fb-primary-color, #0066cc)":"",T.style.outlineOffset=B?"-2px":"",L===0?T.style.backgroundColor="var(--fb-background-hover-color)":T.style.backgroundColor=F&&!B?"rgba(0,102,204,0.08)":""})}function ie(A,T){v.anchor={row:A,col:T},v.focus=null,P(),y.focus()}function se(A,T){const L=y.querySelector(`td[data-row="${A}"][data-col="${T}"]`);if(!L)return;const H=L.querySelector("span");H&&(v.anchor={row:A,col:T},v.focus=null,P(),Gl(H,A,T,()=>h,w,ie))}function fe(A){var T;const L=h.length>0?h[0].length:(T=e.columns)!=null?T:3,H=Array(L).fill(""),B=A!==void 0?A+1:h.length;h.splice(B,0,H),b=b.map(F=>F.top>=B?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<B&&F.bottom>=B?{...F,bottom:F.bottom+1}:F),w(),z()}function Ce(A){if(h.length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.row:h.length-1;b=b.map(L=>L.top===T&&L.bottom===T?null:L.top===T?{...L,bottom:L.bottom-1}:L.bottom===T?{...L,bottom:L.bottom-1}:L.top<T&&L.bottom>T?{...L,bottom:L.bottom-1}:L.top>T?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(T,1),v.anchor&&v.anchor.row>=h.length&&(v.anchor={row:h.length-1,col:v.anchor.col}),w(),z()}function ge(A){var T,L;const H=A!==void 0?A+1:(L=(T=h[0])==null?void 0:T.length)!=null?L:0;h.forEach(B=>B.splice(H,0,"")),b=b.map(B=>B.left>=H?{...B,left:B.left+1,right:B.right+1}:B.left<H&&B.right>=H?{...B,right:B.right+1}:B),w(),z()}function Oe(A){if(h.length===0||h[0].length<=1)return;const T=A!==void 0?A:v.anchor?v.anchor.col:h[0].length-1;b=b.map(L=>L.left===T&&L.right===T?null:L.left===T?{...L,right:L.right-1}:L.right===T?{...L,right:L.right-1}:L.left<T&&L.right>T?{...L,right:L.right-1}:L.left>T?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(T,1)),v.anchor&&v.anchor.col>=h[0].length&&(v.anchor={row:v.anchor.row,col:h[0].length-1}),w(),z()}function $(){var A,T;if(!g)return;const L=Ie(v);if(!L)return;const{r1:H,c1:B,r2:F,c2:re}=L;if(H===F&&B===re)return;b=b.filter(D=>!(D.top<=F&&D.bottom>=H&&D.left<=re&&D.right>=B));const j=h[H][B];for(let D=H;D<=F;D++)for(let ee=B;ee<=re;ee++)(D!==H||ee!==B)&&(h[D][ee]="");h[H][B]=j;const U={top:H,left:B,bottom:F,right:re},J=[...b,U],Z=Qt(J,h.length,(T=(A=h[0])==null?void 0:A.length)!=null?T:0);if(Z){console.warn("Merge validation failed:",Z);return}b.push(U),v.anchor={row:H,col:B},v.focus=null,w(),z()}function N(){if(!g||!v.anchor)return;const{row:A,col:T}=v.anchor,L=b.findIndex(H=>H.top===A&&H.left===T);L!==-1&&(b.splice(L,1),v.focus=null,w(),z())}function z(){var A,T;y.innerHTML="";const L=h.length,H=L>0?h[0].length:0,B=Ie(v);for(let F=0;F<L;F++){const re=(F===0?(A=y.tHead)!=null?A:y.createTHead():(T=y.tBodies[0])!=null?T:y.createTBody()).insertRow();for(let j=0;j<H;j++){if($r(F,j,b))continue;const U=xt(F,j,b),J=document.createElement("td");if(J.setAttribute("data-row",String(F)),J.setAttribute("data-col",String(j)),U){const te=U.bottom-U.top+1,X=U.right-U.left+1;te>1&&(J.rowSpan=te),X>1&&(J.colSpan=X)}const Z=B!==null&&F>=B.r1&&F<=B.r2&&j>=B.c1&&j<=B.c2,D=v.anchor!==null&&v.anchor.row===F&&v.anchor.col===j;J.style.cssText=["border: var(--fb-border-width) solid var(--fb-border-color);","padding: 4px 8px;","min-width: 80px;","vertical-align: top;","cursor: text;","position: relative;",F===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":"",Z&&!D?"background-color: rgba(0,102,204,0.08);":"",D?"outline: 2px solid var(--fb-primary-color, #0066cc); outline-offset: -2px;":""].join(" ");const ee=document.createElement("span");ee.textContent=h[F][j],ee.style.cssText="display: block; min-height: 1.4em; white-space: pre-wrap; word-break: break-word; outline: none;",J.appendChild(ee);const G=F,le=j;J.addEventListener("mousedown",te=>{if(te.target.tagName!=="BUTTON"&&te.target.contentEditable!=="true"){if(te.button===2){const X=Ie(v);if(X&&G>=X.r1&&G<=X.r2&&le>=X.c1&&le<=X.c2)return}te.shiftKey&&v.anchor?(te.preventDefault(),v.focus={row:G,col:le},v.dragging=!1,P()):(v.anchor={row:G,col:le},v.focus=null,v.dragging=!0,P())}}),J.addEventListener("mouseup",te=>{if(te.target.tagName!=="BUTTON"&&v.dragging){v.dragging=!1;const X=Ie(v);(!X||X.r1===X.r2&&X.c1===X.c2)&&se(G,le)}}),J.addEventListener("mousemove",te=>{if(v.dragging&&te.buttons===1){const X=v.anchor;X&&(X.row!==G||X.col!==le)&&(v.focus={row:G,col:le},P())}}),J.addEventListener("contextmenu",te=>{if(!g)return;const X=Ie(v),he=X&&(X.r1!==X.r2||X.c1!==X.c2),pe=v.anchor&&xt(v.anchor.row,v.anchor.col,b);(he||pe)&&(te.preventDefault(),Q(te.clientX,te.clientY))}),re.appendChild(J)}}me(),y.setAttribute("tabindex","0"),y.onkeydown=F=>{var re,j;if(y.querySelector("[contenteditable='true']"))return;const U=v.anchor;if(!U)return;const J=h.length,Z=J>0?h[0].length:0,D={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]};if(D[F.key]){F.preventDefault();const[ee,G]=D[F.key],le=Math.max(0,Math.min(J-1,U.row+ee)),te=Math.max(0,Math.min(Z-1,U.col+G));F.shiftKey?(v.focus={row:le,col:te},P()):ie(le,te);return}if(F.key==="Enter"){F.preventDefault(),se(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const ee=(j=(re=h[0])==null?void 0:re.length)!=null?j:0;let G=U.row,le=F.shiftKey?U.col-1:U.col+1;le<0&&(le=ee-1,G=Math.max(0,G-1)),le>=ee&&(le=0,G=Math.min(h.length-1,G+1)),ie(G,le);return}if(g&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),$();return}g&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),N())},y.oncopy=F=>{var re,j,U,J;const Z=Ie(v);if(!Z)return;F.preventDefault();const{r1:D,c1:ee,r2:G,c2:le}=Z,te=[],X=[];for(let V=D;V<=G;V++){const ue=[],ve=[];for(let ye=ee;ye<=le;ye++){const Se=(j=(re=h[V])==null?void 0:re[ye])!=null?j:"";ue.push(Se);const je=Se.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ve.push(`<td>${je}</td>`)}te.push(ue.join(" ")),X.push(`<tr>${ve.join("")}</tr>`)}const he=te.join(`
1261
+ `),pe=`<table>${X.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",he),(J=F.clipboardData)==null||J.setData("text/html",pe)},y.onpaste=F=>{var re,j,U,J,Z,D,ee,G,le;const te=v.anchor;if(!te)return;const X=(j=(re=F.clipboardData)==null?void 0:re.getData("text/plain"))!=null?j:"",he=X.includes(" ")||X.split(/\r?\n/).filter(be=>be).length>1,pe=y.querySelector("[contenteditable='true']");if(pe&&!he)return;if(F.preventDefault(),pe){pe.contentEditable="inherit";const be=parseInt((J=(U=pe.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?J:"0",10),Ne=parseInt((D=(Z=pe.closest("td"))==null?void 0:Z.getAttribute("data-col"))!=null?D:"0",10);h[be]&&(h[be][Ne]=(ee=pe.textContent)!=null?ee:"")}if(!X.trim())return;const V=X.split(/\r?\n/).map(be=>be.split(" "));V.length>1&&V[V.length-1].length===1&&V[V.length-1][0]===""&&V.pop();const ue=te.row,ve=te.col,ye=ue+V.length;for(;h.length<ye;)h.push(Array((le=(G=h[0])==null?void 0:G.length)!=null?le:1).fill(""));const Se=Math.max(...V.map(be=>be.length)),je=ve+Se;if(h[0]&&je>h[0].length){const be=je-h[0].length;h.forEach(Ne=>{for(let it=0;it<be;it++)Ne.push("")})}for(let be=0;be<V.length;be++)for(let Ne=0;Ne<V[be].length;Ne++){const it=ue+be,Pi=ve+Ne;h[it]&&(h[it][Pi]=V[be][Ne])}w(),z()}}const M=Je({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=M.dataset.afterCol)!=null?A:"0",10);ge(T)}});M.style.position="absolute",M.style.display="none",C.appendChild(M);const q=Je({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterRow)!=null?A:"0",10);fe(T)}});q.style.position="absolute",q.style.display="none",C.appendChild(q);let W=[],oe=[];const ne=Je({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>ge()});ne.style.position="absolute",ne.style.display="none",C.appendChild(ne);const ce=Je({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>fe()});ce.style.position="absolute",ce.style.display="none",C.appendChild(ce);function me(){var A,T;W.forEach(j=>j.remove()),W=[],oe.forEach(j=>j.remove()),oe=[];const L=h.length>0?h[0].length:0,H=h.length;if(L>1){const j=Array.from(y.querySelectorAll("thead td[data-col]"));for(const U of j){const J=parseInt((A=U.getAttribute("data-col"))!=null?A:"0",10),Z=Je({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Oe(J)});Z.setAttribute("data-action","remove-col"),Z.setAttribute("data-col",String(J)),Z.style.position="absolute",Z.style.display="none",C.appendChild(Z),W.push(Z)}}if(H>1){const j=[...y.tHead?Array.from(y.tHead.rows):[],...y.tBodies[0]?Array.from(y.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of j){const J=U.querySelector("td[data-row]");if(!J)continue;const Z=parseInt((T=J.getAttribute("data-row"))!=null?T:"0",10),D=Je({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ce(Z)});D.setAttribute("data-action","remove-row"),D.setAttribute("data-row",String(Z)),D.style.position="absolute",D.style.display="none",C.appendChild(D),oe.push(D)}}function B(j,U,J,Z,D){var ee;const G=D?Array.from(y.querySelectorAll("thead td[data-col]")):[];let le=-1,te=1/0,X=-1,he=-1,pe=1/0;for(let V=0;V<G.length;V++){const ue=G[V].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ye=Math.abs(j-ve);ye<te&&(te=ye,le=V);const Se=Math.abs(j-ue.right);Se<pe&&Se<20&&(pe=Se,X=ue.right-U.left+Z,he=parseInt((ee=G[V].getAttribute("data-col"))!=null?ee:"0",10))}W.forEach((V,ue)=>{if(!D||ue!==le){V.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ye=(ve.left+ve.right)/2-U.left+Z;V.style.left=`${ye-8}px`,V.style.top="2px",V.style.display="flex"}),D&&he>=0?(M.style.display="flex",M.style.left=`${X-10}px`,M.style.top=`${J.top-U.top-10}px`,M.dataset.afterCol=String(he)):M.style.display="none"}function F(j,U,J,Z,D){var ee;const G=[];if(D){if(y.tHead)for(const V of Array.from(y.tHead.rows))V.querySelector("td[data-row]")&&G.push(V);if(y.tBodies[0])for(const V of Array.from(y.tBodies[0].rows))V.querySelector("td[data-row]")&&G.push(V)}let le=-1,te=1/0,X=-1,he=-1,pe=1/0;for(let V=0;V<G.length;V++){const ue=G[V].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ye=Math.abs(j-ve);ye<te&&(te=ye,le=V);const Se=Math.abs(j-ue.bottom);if(Se<pe&&Se<14){pe=Se,X=ue.bottom-U.top;const je=G[V].querySelector("td[data-row]");he=parseInt((ee=je==null?void 0:je.getAttribute("data-row"))!=null?ee:"0",10)}}oe.forEach((V,ue)=>{if(!D||ue!==le){V.style.display="none";return}const ve=G[ue].getBoundingClientRect(),ye=(ve.top+ve.bottom)/2-U.top;V.style.left="4px",V.style.top=`${ye-8}px`,V.style.display="flex"}),D&&he>=0?(q.style.display="flex",q.style.top=`${X-10}px`,q.style.left=`${J.left-U.left+Z-10}px`,q.dataset.afterRow=String(he)):q.style.display="none"}let re=!1;C.onmousemove=j=>{const U=j.target;if(U.tagName==="BUTTON"&&U.parentElement===C||re)return;re=!0;const J=j.clientX,Z=j.clientY;requestAnimationFrame(()=>{re=!1;const D=C.getBoundingClientRect(),ee=y.getBoundingClientRect(),G=C.scrollLeft,le=Z>=D.top&&Z<ee.top+4,te=J>=D.left&&J<ee.left+4,X=Math.min(ee.right,D.right),he=J>X-20&&J<=D.right,pe=Z>ee.bottom-4&&Z<=D.bottom+20;if(B(J,D,ee,G,le),F(Z,D,ee,G,te),ne.style.display=he?"flex":"none",he&&(ne.style.left=`${D.right-D.left+G-20}px`,ne.style.top=`${(ee.top+ee.bottom)/2-D.top-10}px`),ce.style.display=pe?"flex":"none",pe){const V=(D.left+D.right)/2-D.left+G;ce.style.left=`${V-10}px`,ce.style.top=`${ee.bottom-D.top-10}px`}})},C.onmouseleave=()=>{W.forEach(j=>{j.style.display="none"}),oe.forEach(j=>{j.style.display="none"}),M.style.display="none",q.style.display="none",ne.style.display="none",ce.style.display="none"}}z()}function ti(e){var t,n;return{cells:kr((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function en(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function tn(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function ni(e,t,n,r){var o,l,a,i;const d=t.state,s=ae(e,d,t),c=t.prefill[e.key],u=(l=(o=e.fieldNames)==null?void 0:o.cells)!=null?l:"cells",f=(i=(a=e.fieldNames)==null?void 0:a.merges)!=null?i:"merges";let p;if(en(c))p={cells:c.cells,merges:c.merges?_e(c.merges):[]};else if(c&&tn(c,u)){const m=c[f];p={cells:c[u],merges:m?_e(m):[]}}else if(en(e.default))p={cells:e.default.cells,merges:e.default.merges?_e(e.default.merges):[]};else if(e.default&&tn(e.default,u)){const m=e.default[f];p={cells:e.default[u],merges:m?_e(m):[]}}else p=ti(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,g=m>0?p.cells[0].length:0,x=Qt(p.merges,m,g);x&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${x})`),p={...p,merges:[]})}s?Yl(p,n):ei(e,p,r,t,n)}function ri(e,t){let n;try{n=JSON.parse(e)}catch(o){return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n[t];return Array.isArray(r)&&r.every(o=>Array.isArray(o)&&o.every(l=>typeof l=="string"))?n:null}function oi(e,t,n){var r,o;const{scopeRoot:l}=n,a=[],i=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",d=l.querySelector(`[name="${t}"]`);if(!d)return{value:null,errors:a};const s=ri(d.value,i);if(s===null){const f="invalid table data";return a.push(`${t}: ${f}`),et(l,t,f,n),{value:null,errors:a}}const c=s[i].some(f=>f.some(p=>p.trim()!=="")),u=e.required&&!c?k("required",n.state):null;return u!==null&&a.push(`${t}: ${u}`),et(l,t,u,n),{value:s,errors:a}}function li(e,t,n,r){var o,l,a,i;const{scopeRoot:d}=r,s=(l=(o=e.fieldNames)==null?void 0:o.cells)!=null?l:"cells",c=(i=(a=e.fieldNames)==null?void 0:a.merges)!=null?i:"merges",u=d.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(en(n))f={cells:n.cells,merges:n.merges?_e(n.merges):[]};else if(n&&tn(n,s)){const p=n[c];f={cells:n[s],merges:p?_e(p):[]}}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):u.value=JSON.stringify(n)}function ii(e,t,n){e.style.overflow="hidden",e.style.resize="none";const r=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,r);const o=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",o),setTimeout(()=>{e.isConnected&&o()},0),typeof ResizeObserver=="undefined")return;let l=-1;const a=new ResizeObserver(i=>{var d,s,c,u,f;if(!e.isConnected){a.disconnect(),n.delete(a);return}const p=i[0],m=(f=(u=(s=(d=p==null?void 0:p.contentBoxSize)==null?void 0:d[0])==null?void 0:s.inlineSize)!=null?u:(c=p==null?void 0:p.contentRect)==null?void 0:c.width)!=null?f:0;m!==l&&(l=m,o())});a.observe(e),n.add(a)}function nn(e,t){var n,r,o,l;const a=new Map,i=new Map;for(const d of e){const s=t.resourceIndex.get(d),c=(n=s==null?void 0:s.name)!=null?n:d;i.set(c,((r=i.get(c))!=null?r:0)+1)}for(const d of e){const s=t.resourceIndex.get(d),c=(o=s==null?void 0:s.name)!=null?o:d;((l=i.get(c))!=null?l:1)>1&&s?a.set(d,`${c} (${Kr(s.size)})`):a.set(d,c)}return a}function rn(e){return e?e.type.startsWith("image/"):!1}function Sr(e,t){const n=nn(e,t),r=new Map;for(const o of e){const l=n.get(o);l&&r.set(l,o)}return r}function on(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function wt(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 l="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(l+=e[r+1],r+=2):(l+=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:l}))}else if(r<n&&!/\s/.test(e[r])){const l=r;for(;r<n&&!/\s/.test(e[r]);)r++;const a=e.slice(l,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function ai(e,t){if(t.size===0)return[];const n=wt(e),r=[];for(const o of n){const l=t.get(o.name);l&&r.push({start:o.start,end:o.end,name:o.name,rid:l})}return r}function si(e,t){const n=ai(e,t);if(n.length===0)return e;let r="",o=0;for(const l of n)r+=e.slice(o,l.start),r+=`@${l.rid}`,o=l.end;return r+=e.slice(o),r}function Lr(e,t,n){const r=nn(t,n),o=new Map;for(const d of t){const s=r.get(d);s&&o.set(d,s)}const l=wt(e);if(l.length===0)return e;let a="",i=0;for(const d of l){a+=e.slice(i,d.start);const s=o.get(d.name);s?a+=on(s):a+=d.raw,i=d.end}return a+=e.slice(i),a}function Ar(e,t,n,r){if(Ee(e),n!=null&&n.file&&rn(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const l=new FileReader;l.onload=a=>{var i;o.src=((i=a.target)==null?void 0:i.result)||""},l.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(l=>{var a;if(!l||!e.isConnected)return;const i=document.createElement("img");i.alt=(a=n==null?void 0:n.name)!=null?a:t,i.src=l,i.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",Ee(e),e.appendChild(i)}).catch(l=>{var a,i;(i=(a=r.config).onThumbnailError)==null||i.call(a,l,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 l=document.createElement("span");l.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",l.textContent=n.name,o.appendChild(l)}e.appendChild(o)}}function Tr(e,t,n,r){if(Ee(e),n!=null&&n.file&&rn(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 l=new FileReader;l.onload=a=>{var i;o.src=((i=a.target)==null?void 0:i.result)||""},l.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var l;if(!o||!e.isConnected)return;const a=document.createElement("img");a.alt=(l=n==null?void 0:n.name)!=null?l:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",Ee(e),e.appendChild(a)}).catch(o=>{var l,a;(a=(l=r.config).onThumbnailError)==null||a.call(l,o,t)})}function Fr(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)),l=n.top-r.height-8,a=n.bottom+8,i=l>=4?l:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,i)}px`}function zr(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=`
1272
1262
  position: fixed;
1273
1263
  z-index: 99999;
1274
1264
  background: #fff;
@@ -1279,7 +1269,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1279
1269
  pointer-events: none;
1280
1270
  min-width: 60px;
1281
1271
  max-width: 140px;
1282
- `;const a=document.createElement("div");return a.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(a,t,r,n),o.appendChild(a),document.body.appendChild(o),ir(o,e),o}function sr(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=`
1272
+ `;const l=document.createElement("div");return l.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Tr(l,t,r,n),o.appendChild(l),document.body.appendChild(o),Fr(o,e),o}function Mr(e,t){var n,r;const{rid:o,state:l,isReadonly:a,onMention:i,onRemove:d}=t,s=l.resourceIndex.get(o),c=(n=s==null?void 0:s.name)!=null?n:o,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
1283
1273
  position: fixed;
1284
1274
  z-index: 99999;
1285
1275
  background: #fff;
@@ -1290,17 +1280,17 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1290
1280
  pointer-events: auto;
1291
1281
  min-width: 80px;
1292
1282
  max-width: 260px;
1293
- `;const u=document.createElement("div");u.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",lr(u,o,s,a),d.appendChild(u);const p=document.createElement("div");p.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",p.textContent=f,d.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",g=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},E=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!l&&i){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),i(),d.remove()}),m.appendChild(h)}if(a.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C;y.stopPropagation(),(C=(v=a.config).downloadFile)==null||C.call(v,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=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>g(h)),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{var v,C,w,x;if(y.stopPropagation(),a.config.getDownloadUrl){const S=a.config.getDownloadUrl(o);S?window.open(S,"_blank"):(C=(v=a.config).getThumbnail)==null||C.call(v,o).then(z=>{z&&window.open(z,"_blank")}).catch(()=>{})}else(x=(w=a.config).getThumbnail)==null||x.call(w,o).then(S=>{S&&window.open(S,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!l&&c){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>E(h)),h.addEventListener("click",y=>{y.stopPropagation(),d.remove(),c()}),m.appendChild(h)}return m.children.length>0&&d.appendChild(m),document.body.appendChild(d),ir(d,e),d}function cr(){return{element:null,hideTimer:null}}function bt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function gt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Ke(e){return e&&e.remove(),null}function Ml(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 dr(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 vt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",ur="padding: 8px 40px 8px 10px;";function Nl(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 $,I;const M=x.value,N=nr(i,l),q=M?zl(M,N):null,B=($=e.textKey)!=null?$:"text",re=(I=e.filesKey)!=null?I:"files";return{[B]:M===""?null:q,[re]:[...i]}}function u(){f.value=JSON.stringify(d())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
1283
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",Tr(f,o,s,l),u.appendChild(f);const p=document.createElement("div");p.style.cssText="padding: 4px 6px 2px; font-size: 12px; color: var(--fb-text-color, #111827); word-break: break-word; border-top: 1px solid var(--fb-border-color, #d1d5db);",p.textContent=c,u.appendChild(p);const m=document.createElement("div");m.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const g="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;",x=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},S=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&i){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=g,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",()=>x(h)),h.addEventListener("mouseleave",()=>S(h)),h.addEventListener("click",b=>{b.stopPropagation(),i(),u.remove()}),m.appendChild(h)}if(l.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=g,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",()=>x(h)),h.addEventListener("mouseleave",()=>S(h)),h.addEventListener("click",b=>{var v,E;b.stopPropagation(),(E=(v=l.config).downloadFile)==null||E.call(v,o,c)}),m.appendChild(h)}if((r=l.config.getDownloadUrl)!=null?r:l.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=g,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",()=>x(h)),h.addEventListener("mouseleave",()=>S(h)),h.addEventListener("click",b=>{var v,E,w,C;if(b.stopPropagation(),l.config.getDownloadUrl){const y=l.config.getDownloadUrl(o);y?window.open(y,"_blank"):(E=(v=l.config).getThumbnail)==null||E.call(v,o).then(R=>{R&&window.open(R,"_blank")}).catch(()=>{})}else(C=(w=l.config).getThumbnail)==null||C.call(w,o).then(y=>{y&&window.open(y,"_blank")}).catch(()=>{})}),m.appendChild(h)}if(!a&&d){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=g,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",()=>S(h)),h.addEventListener("click",b=>{b.stopPropagation(),u.remove(),d()}),m.appendChild(h)}return m.children.length>0&&u.appendChild(m),document.body.appendChild(u),Fr(u,e),u}function Rr(){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 Et(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function Xe(e){return e&&e.remove(),null}function di(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 l=r.slice(o+1);return l.startsWith('"')&&(l=l.slice(1)),{query:l,pos:o}}return null}return null}function Ir(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var l;return((l=n.get(o))!=null?l:o).toLowerCase().includes(r)})}const kt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",Nr="padding: 8px 40px 8px 10px;";function ci(e,t,n,r,o){var l,a;const i=t.state,d=[...o.files],s={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,u=document.createElement("input");u.type="hidden",u.name=r;function f(){var $,N;const z=y.value,M=Sr(d,i),q=z?si(z,M):null,W=($=e.textKey)!=null?$:"text",oe=(N=e.filesKey)!=null?N:"files";return{[W]:z===""?null:q,[oe]:[...d]}}function p(){u.value=JSON.stringify(f())}const m=document.createElement("div");m.className="fb-richinput-wrapper",m.style.cssText=`
1294
1284
  position: relative;
1295
1285
  border: 1px solid var(--fb-border-color, #d1d5db);
1296
1286
  border-radius: 16px;
1297
1287
  background: var(--fb-background-color, #f9fafb);
1298
1288
  transition: box-shadow 0.15s, border-color 0.15s;
1299
- `,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const m=document.createElement("div");m.className="fb-richinput-error",m.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let b=null;function g($){m.textContent=$,m.style.display="block",b&&clearTimeout(b),b=setTimeout(()=>{m.style.display="none",m.textContent="",b=null},5e3)}function E($){var I;const M=Re(e.accept);if(!Ue($.name,M)){const q=M.join(", ");return g(k("invalidFileExtension",l,{name:$.name,formats:q})),!1}const N=(I=e.maxSize)!=null?I:1/0;return st($,N)?!0:(g(k("fileTooLarge",l,{name:$.name,maxSize:N})),!1)}let h=0;p.addEventListener("dragenter",$=>{$.preventDefault(),h++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",$=>{$.preventDefault()}),p.addEventListener("dragleave",$=>{$.preventDefault(),h--,h<=0&&(h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",$=>{var I,M;$.preventDefault(),h=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const N=(I=$.dataTransfer)==null?void 0:I.files;if(!N||!l.config.uploadFile)return;const q=(M=e.maxFiles)!=null?M:1/0;for(let B=0;B<N.length;B++){if(i.length>=q){g(k("filesLimitExceeded",l,{skipped:N.length-B,max:q}));break}E(N[B])&&Ae(N[B])}});const y=document.createElement("div");y.className="fb-richinput-files",y.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const v=document.createElement("input");v.type="file",v.multiple=!0,v.style.display="none",e.accept&&(typeof e.accept=="string"?v.accept=e.accept:v.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const C=document.createElement("div");C.style.cssText="position: relative;";const w=document.createElement("div");w.className="fb-richinput-backdrop",w.style.cssText=`
1289
+ `,m.addEventListener("focusin",()=>{m.style.borderColor="var(--fb-primary-color, #0066cc)",m.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),m.addEventListener("focusout",()=>{m.style.borderColor="var(--fb-border-color, #d1d5db)",m.style.boxShadow="none"});const g=document.createElement("div");g.className="fb-richinput-error",g.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let x=null;function S($){g.textContent=$,g.style.display="block",x&&clearTimeout(x),x=setTimeout(()=>{g.style.display="none",g.textContent="",x=null},5e3)}function h($){var N;const z=He(e.accept);if(!Ve($.name,z)){const q=z.join(", ");return S(k("invalidFileExtension",i,{name:$.name,formats:q})),!1}const M=(N=e.maxSize)!=null?N:1/0;return ht($,M)?!0:(S(k("fileTooLarge",i,{name:$.name,maxSize:M})),!1)}let b=0;m.addEventListener("dragenter",$=>{$.preventDefault(),b++,m.style.borderColor="var(--fb-primary-color, #0066cc)",m.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),m.addEventListener("dragover",$=>{$.preventDefault()}),m.addEventListener("dragleave",$=>{$.preventDefault(),b--,b<=0&&(b=0,m.style.borderColor="var(--fb-border-color, #d1d5db)",m.style.boxShadow="none")}),m.addEventListener("drop",$=>{var N,z;$.preventDefault(),b=0,m.style.borderColor="var(--fb-border-color, #d1d5db)",m.style.boxShadow="none";const M=(N=$.dataTransfer)==null?void 0:N.files;if(!M||!i.config.uploadFile)return;const q=(z=e.maxFiles)!=null?z:1/0;for(let W=0;W<M.length;W++){if(d.length>=q){S(k("filesLimitExceeded",i,{skipped:M.length-W,max:q}));break}h(M[W])&&ge(M[W])}});const v=document.createElement("div");v.className="fb-richinput-files",v.style.cssText="display: none; flex-wrap: wrap; gap: 4px; padding: 6px 10px 0; align-items: center;";const E=document.createElement("input");E.type="file",E.multiple=!0,E.style.display="none",e.accept&&(typeof e.accept=="string"?E.accept=e.accept:E.accept=e.accept.extensions.map($=>$.startsWith(".")?$:`.${$}`).join(","));const w=document.createElement("div");w.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
1300
1290
  position: absolute;
1301
1291
  top: 0; left: 0; right: 0; bottom: 0;
1302
- ${ur}
1303
- ${vt}
1292
+ ${Nr}
1293
+ ${kt}
1304
1294
  white-space: pre-wrap;
1305
1295
  word-break: break-word;
1306
1296
  color: transparent;
@@ -1309,10 +1299,10 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1309
1299
  border-radius: inherit;
1310
1300
  box-sizing: border-box;
1311
1301
  z-index: 2;
1312
- `;const x=document.createElement("textarea");x.name=`${r}__text`,x.placeholder=e.placeholder||k("richinputPlaceholder",l);const S=(a=o.text)!=null?a:"";x.value=S?rr(S,i,l):"",x.style.cssText=`
1302
+ `;const y=document.createElement("textarea");y.name=`${r}__text`,y.placeholder=(l=e.placeholder)!=null?l:k("richinputPlaceholder",i);const R=(a=o.text)!=null?a:"";y.value=R?Lr(R,d,i):"",y.style.cssText=`
1313
1303
  width: 100%;
1314
- ${ur}
1315
- ${vt}
1304
+ ${Nr}
1305
+ ${kt}
1316
1306
  background: transparent;
1317
1307
  border: none;
1318
1308
  outline: none;
@@ -1322,9 +1312,9 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1322
1312
  position: relative;
1323
1313
  z-index: 1;
1324
1314
  caret-color: var(--fb-text-color, #111827);
1325
- `,Al(x,w),x.addEventListener("scroll",()=>{w.scrollTop=x.scrollTop});let z=null;w.addEventListener("mouseover",$=>{var I,M;const N=(M=(I=$.target).closest)==null?void 0:M.call(I,"mark");N!=null&&N.dataset.rid&&(z=Ke(z),z=ar(N,N.dataset.rid,l))}),w.addEventListener("mouseout",$=>{var I,M,N;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;const q=$.relatedTarget;(N=q==null?void 0:q.closest)!=null&&N.call(q,"mark")||(z=Ke(z))}),w.addEventListener("mousedown",$=>{var I,M;if(!((M=(I=$.target).closest)!=null&&M.call(I,"mark")))return;z=Ke(z);const N=w.querySelectorAll("mark");N.forEach(B=>B.style.pointerEvents="none");const q=document.elementFromPoint($.clientX,$.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{N.forEach(B=>B.style.pointerEvents="auto")},{once:!0})});function ee(){const $=x.value,I=nr(i,l),M=ht($);if(M.length===0){w.innerHTML=se($)+`
1326
- `;return}let N="",q=0;for(const B of M){N+=se($.slice(q,B.start));const re=I.get(B.name);re?N+=`<mark data-rid="${se(re)}" style="background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent); color: transparent; border-radius: 8px; padding: 0; border: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent), 0 0 0 3px color-mix(in srgb, var(--fb-primary-color, #0066cc) 30%, transparent); box-decoration-break: clone; -webkit-box-decoration-break: clone; pointer-events: auto; cursor: text;">${se($.slice(B.start,B.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;">${se($.slice(B.start,B.end))}</mark>`,q=B.end}N+=se($.slice(q)),w.innerHTML=N+`
1327
- `}const K=document.createElement("button");K.type="button",K.title=k("richinputAttachFile",l),K.style.cssText=`
1315
+ `,ii(y,C,t.state.autoExpandObservers),y.addEventListener("scroll",()=>{C.scrollTop=y.scrollTop});let K=null;C.addEventListener("mouseover",$=>{var N,z;const M=(z=(N=$.target).closest)==null?void 0:z.call(N,"mark");M!=null&&M.dataset.rid&&(K=Xe(K),K=zr(M,M.dataset.rid,i))}),C.addEventListener("mouseout",$=>{var N,z,M;if(!((z=(N=$.target).closest)!=null&&z.call(N,"mark")))return;const q=$.relatedTarget;(M=q==null?void 0:q.closest)!=null&&M.call(q,"mark")||(K=Xe(K))}),C.addEventListener("mousedown",$=>{var N,z;if(!((z=(N=$.target).closest)!=null&&z.call(N,"mark")))return;K=Xe(K);const M=C.querySelectorAll("mark");M.forEach(W=>W.style.pointerEvents="none");const q=document.elementFromPoint($.clientX,$.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:$.clientX,clientY:$.clientY,button:$.button,buttons:$.buttons,detail:$.detail})),document.addEventListener("mouseup",()=>{M.forEach(W=>W.style.pointerEvents="auto")},{once:!0})});function Y(){const $=y.value,N=Sr(d,i),z=wt($);if(z.length===0){C.innerHTML=de($)+`
1316
+ `;return}let M="",q=0;for(const W of z){M+=de($.slice(q,W.start));const oe=N.get(W.name);oe?M+=`<mark data-rid="${de(oe)}" 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;">${de($.slice(W.start,W.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;">${de($.slice(W.start,W.end))}</mark>`,q=W.end}M+=de($.slice(q)),C.innerHTML=M+`
1317
+ `}const _=document.createElement("button");_.type="button",_.title=k("richinputAttachFile",i),_.style.cssText=`
1328
1318
  position: absolute;
1329
1319
  right: 6px;
1330
1320
  bottom: 6px;
@@ -1340,7 +1330,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1340
1330
  justify-content: center;
1341
1331
  color: var(--fb-text-muted-color, #9ca3af);
1342
1332
  transition: color 0.15s, background 0.15s;
1343
- `,K.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>',K.addEventListener("mouseenter",()=>{K.style.color="var(--fb-primary-color, #0066cc)",K.style.background="var(--fb-background-hover-color, #f3f4f6)"}),K.addEventListener("mouseleave",()=>{K.style.color="var(--fb-text-muted-color, #9ca3af)",K.style.background="transparent"}),K.addEventListener("click",()=>{var $;const I=($=e.maxFiles)!=null?$:1/0;if(i.length>=I){g(k("filesLimitExceeded",l,{skipped:1,max:I}));return}v.click()});const H=document.createElement("div");H.className="fb-richinput-dropdown",H.style.cssText=`
1333
+ `,_.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>',_.addEventListener("mouseenter",()=>{_.style.color="var(--fb-primary-color, #0066cc)",_.style.background="var(--fb-background-hover-color, #f3f4f6)"}),_.addEventListener("mouseleave",()=>{_.style.color="var(--fb-text-muted-color, #9ca3af)",_.style.background="transparent"}),_.addEventListener("click",()=>{var $;const N=($=e.maxFiles)!=null?$:1/0;if(d.length>=N){S(k("filesLimitExceeded",i,{skipped:1,max:N}));return}E.click()});const Q=document.createElement("div");Q.className="fb-richinput-dropdown",Q.style.cssText=`
1344
1334
  display: none;
1345
1335
  position: absolute;
1346
1336
  bottom: 100%;
@@ -1355,16 +1345,16 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1355
1345
  max-height: 200px;
1356
1346
  overflow-y: auto;
1357
1347
  margin-bottom: 4px;
1358
- ${vt}
1359
- `;function V(){return Vt(i,l)}function ne($){we(H);const I=V();if($.length===0){H.style.display="none",c.open=!1;return}$.forEach((M,N)=>{var q;const B=l.resourceIndex.get(M),re=document.createElement("div");re.className="fb-richinput-dropdown-item",re.dataset.rid=M,re.style.cssText=`
1348
+ ${kt}
1349
+ `;function O(){return nn(d,i)}function I($){Ee(Q);const N=O();if($.length===0){Q.style.display="none",s.open=!1;return}$.forEach((z,M)=>{var q;const W=i.resourceIndex.get(z),oe=document.createElement("div");oe.className="fb-richinput-dropdown-item",oe.dataset.rid=z,oe.style.cssText=`
1360
1350
  padding: 5px 10px;
1361
1351
  cursor: pointer;
1362
1352
  color: var(--fb-text-color, #111827);
1363
- background: ${N===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1353
+ background: ${M===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1364
1354
  display: flex;
1365
1355
  align-items: center;
1366
1356
  gap: 8px;
1367
- `;const oe=document.createElement("div");if(oe.style.cssText="width: 24px; height: 24px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",B!=null&&B.file&&Kt(B)){const ce=document.createElement("img");ce.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const ge=new FileReader;ge.onload=A=>{var T;ce.src=((T=A.target)==null?void 0:T.result)||""},ge.readAsDataURL(B.file),oe.appendChild(ce)}else l.config.getThumbnail&&l.config.getThumbnail(M).then(ce=>{if(!ce||!oe.isConnected)return;const ge=document.createElement("img");ge.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",ge.src=ce,we(oe),oe.appendChild(ge)}).catch(()=>{}),oe.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>';re.appendChild(oe);const de=document.createElement("span");de.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",de.textContent=(q=I.get(M))!=null?q:M,re.appendChild(de),H.appendChild(re)}),H.onmousemove=M=>{var N,q,B;const re=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");if(!re)return;const oe=$.indexOf((B=re.dataset.rid)!=null?B:"");oe===-1||oe===c.selectedIndex||(H.querySelectorAll(".fb-richinput-dropdown-item").forEach((de,ce)=>{de.style.background=ce===oe?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),c.selectedIndex=oe)},H.onmousedown=M=>{var N,q;M.preventDefault(),M.stopPropagation();const B=(q=(N=M.target).closest)==null?void 0:q.call(N,".fb-richinput-dropdown-item");B!=null&&B.dataset.rid&&ie(B.dataset.rid)},H.style.display="block",c.open=!0}function R(){const $=Ml(x);if(!$){_();return}c.query=$.query,c.triggerPos=$.pos,c.selectedIndex=0;const I=V(),M=dr($.query,i,I);ne(M)}function _(){H.style.display="none",c.open=!1}function ie($){var I,M,N,q;const B=(N=(M=V().get($))!=null?M:(I=l.resourceIndex.get($))==null?void 0:I.name)!=null?N:$,re=(q=x.selectionStart)!=null?q:0,oe=x.value.slice(0,c.triggerPos),de=x.value.slice(re),ce=`${_t(B)} `;x.value=`${oe}${ce}${de}`;const ge=oe.length+ce.length;x.setSelectionRange(ge,ge),x.dispatchEvent(new Event("input")),_()}x.addEventListener("input",()=>{var $;ee(),u(),($=t.instance)==null||$.triggerOnChange(r,d()),i.length>0?R():_()});function pe(){H.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,I)=>{$.style.background=I===c.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}x.addEventListener("keydown",$=>{if(!c.open)return;const I=V(),M=dr(c.query,i,I);$.key==="ArrowDown"?($.preventDefault(),c.selectedIndex=Math.min(c.selectedIndex+1,M.length-1),pe()):$.key==="ArrowUp"?($.preventDefault(),c.selectedIndex=Math.max(c.selectedIndex-1,0),pe()):$.key==="Enter"&&M.length>0?($.preventDefault(),ie(M[c.selectedIndex])):$.key==="Escape"&&_()}),document.addEventListener("click",$=>{!p.contains($.target)&&!H.contains($.target)&&_()},{signal:s.signal});function me(){if(we(y),i.length===0){y.style.display="none";return}y.style.display="flex",i.forEach($=>{const I=l.resourceIndex.get($),M=document.createElement("div");M.className="fb-richinput-file-thumb",M.style.cssText=`
1357
+ `;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;",W!=null&&W.file&&rn(W)){const me=document.createElement("img");me.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const A=new FileReader;A.onload=T=>{var L;me.src=((L=T.target)==null?void 0:L.result)||""},A.readAsDataURL(W.file),ne.appendChild(me)}else i.config.getThumbnail&&i.config.getThumbnail(z).then(me=>{if(!me||!ne.isConnected)return;const A=document.createElement("img");A.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",A.src=me,Ee(ne),ne.appendChild(A)}).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>';oe.appendChild(ne);const ce=document.createElement("span");ce.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ce.textContent=(q=N.get(z))!=null?q:z,oe.appendChild(ce),Q.appendChild(oe)}),Q.onmousemove=z=>{var M,q,W;const oe=(q=(M=z.target).closest)==null?void 0:q.call(M,".fb-richinput-dropdown-item");if(!oe)return;const ne=$.indexOf((W=oe.dataset.rid)!=null?W:"");ne===-1||ne===s.selectedIndex||(Q.querySelectorAll(".fb-richinput-dropdown-item").forEach((ce,me)=>{ce.style.background=me===ne?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),s.selectedIndex=ne)},Q.onmousedown=z=>{var M,q;z.preventDefault(),z.stopPropagation();const W=(q=(M=z.target).closest)==null?void 0:q.call(M,".fb-richinput-dropdown-item");W!=null&&W.dataset.rid&&se(W.dataset.rid)},Q.style.display="block",s.open=!0}function P(){const $=di(y);if(!$){ie();return}s.query=$.query,s.triggerPos=$.pos,s.selectedIndex=0;const N=O(),z=Ir($.query,d,N);I(z)}function ie(){Q.style.display="none",s.open=!1}function se($){var N,z,M,q;const W=(M=(z=O().get($))!=null?z:(N=i.resourceIndex.get($))==null?void 0:N.name)!=null?M:$,oe=(q=y.selectionStart)!=null?q:0,ne=y.value.slice(0,s.triggerPos),ce=y.value.slice(oe),me=`${on(W)} `;y.value=`${ne}${me}${ce}`;const A=ne.length+me.length;y.setSelectionRange(A,A),y.dispatchEvent(new Event("input")),ie()}y.addEventListener("input",()=>{var $;Y(),p(),($=t.instance)==null||$.triggerOnChange(r,f()),d.length>0?P():ie()});function fe(){Q.querySelectorAll(".fb-richinput-dropdown-item").forEach(($,N)=>{$.style.background=N===s.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}y.addEventListener("keydown",$=>{if(!s.open)return;const N=O(),z=Ir(s.query,d,N);$.key==="ArrowDown"?($.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,z.length-1),fe()):$.key==="ArrowUp"?($.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0),fe()):$.key==="Enter"&&z.length>0?($.preventDefault(),se(z[s.selectedIndex])):$.key==="Escape"&&ie()}),document.addEventListener("click",$=>{!m.contains($.target)&&!Q.contains($.target)&&ie()},{signal:c.signal});function Ce(){if(Ee(v),d.length===0){v.style.display="none";return}v.style.display="flex",d.forEach($=>{const N=i.resourceIndex.get($),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
1368
1358
  position: relative;
1369
1359
  width: 48px;
1370
1360
  height: 48px;
@@ -1374,14 +1364,14 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1374
1364
  flex-shrink: 0;
1375
1365
  cursor: pointer;
1376
1366
  background: #fff;
1377
- `;const N=document.createElement("div");N.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(N,$,I,l),M.appendChild(N);const q=cr(),B=()=>{var oe,de,ce;const ge=(oe=x.selectionStart)!=null?oe:x.value.length,A=(ce=(de=V().get($))!=null?de:I==null?void 0:I.name)!=null?ce:$,T=x.value.slice(0,ge),L=x.value.slice(ge),D=`${T.length>0&&!/[\s\n]$/.test(T)?`
1378
- `:""}${_t(A)} `;x.value=`${T}${D}${L}`;const j=ge+D.length;x.setSelectionRange(j,j),x.focus(),x.dispatchEvent(new Event("input"))},re=()=>{var oe;const de=i.indexOf($);de!==-1&&i.splice(de,1),me(),ee(),u(),(oe=t.instance)==null||oe.triggerOnChange(r,d())};M.addEventListener("mouseenter",()=>{gt(q),q.element||(q.element=sr(M,{rid:$,state:l,isReadonly:!1,onMention:B,onRemove:re}),q.element.addEventListener("mouseenter",()=>{gt(q)}),q.element.addEventListener("mouseleave",()=>{bt(q)}))}),M.addEventListener("mouseleave",()=>{bt(q)}),y.appendChild(M)})}function Ae($){if(!l.config.uploadFile)return;const I=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(I,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),i.push(I),me();const M=y.querySelectorAll(".fb-richinput-file-thumb"),N=M[M.length-1];N&&(N.style.opacity="0.5"),l.config.uploadFile($).then(q=>{var B;const re=i.indexOf(I);re!==-1&&(i[re]=q),l.resourceIndex.delete(I),l.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),me(),ee(),u(),(B=t.instance)==null||B.triggerOnChange(r,d())}).catch(q=>{var B,re;const oe=i.indexOf(I);oe!==-1&&i.splice(oe,1),l.resourceIndex.delete(I),me(),(re=(B=l.config).onUploadError)==null||re.call(B,q,$)})}if(v.addEventListener("change",()=>{var $;const I=v.files;if(!I||I.length===0)return;const M=($=e.maxFiles)!=null?$:1/0;for(let N=0;N<I.length;N++){if(i.length>=M){g(k("filesLimitExceeded",l,{skipped:I.length-N,max:M}));break}E(I[N])&&Ae(I[N])}v.value=""}),C.appendChild(w),C.appendChild(x),C.appendChild(K),C.appendChild(H),p.appendChild(y),p.appendChild(C),p.appendChild(m),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const I=lt(e,x);I.style.cssText=`
1367
+ `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Ar(M,$,N,i),z.appendChild(M);const q=Rr(),W=()=>{var ne,ce,me;const A=(ne=y.selectionStart)!=null?ne:y.value.length,T=(me=(ce=O().get($))!=null?ce:N==null?void 0:N.name)!=null?me:$,L=y.value.slice(0,A),H=y.value.slice(A),B=`${L.length>0&&!/[\s\n]$/.test(L)?`
1368
+ `:""}${on(T)} `;y.value=`${L}${B}${H}`;const F=A+B.length;y.setSelectionRange(F,F),y.focus(),y.dispatchEvent(new Event("input"))},oe=()=>{var ne;const ce=d.indexOf($);ce!==-1&&d.splice(ce,1),Ce(),Y(),p(),(ne=t.instance)==null||ne.triggerOnChange(r,f())};z.addEventListener("mouseenter",()=>{Et(q),q.element||(q.element=Mr(z,{rid:$,state:i,isReadonly:!1,onMention:W,onRemove:oe}),q.element.addEventListener("mouseenter",()=>{Et(q)}),q.element.addEventListener("mouseleave",()=>{Ct(q)}))}),z.addEventListener("mouseleave",()=>{Ct(q)}),v.appendChild(z)})}function ge($){if(!i.config.uploadFile)return;const N=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;i.resourceIndex.set(N,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),d.push(N),Ce();const z=v.querySelectorAll(".fb-richinput-file-thumb"),M=z[z.length-1];M&&(M.style.opacity="0.5"),i.config.uploadFile($).then(q=>{var W;const oe=d.indexOf(N);oe!==-1&&(d[oe]=q),i.resourceIndex.delete(N),i.resourceIndex.set(q,{name:$.name,type:$.type,size:$.size,uploadedAt:new Date,file:$}),Ce(),Y(),p(),(W=t.instance)==null||W.triggerOnChange(r,f())}).catch(q=>{var W,oe;const ne=d.indexOf(N);ne!==-1&&d.splice(ne,1),i.resourceIndex.delete(N),Ce(),(oe=(W=i.config).onUploadError)==null||oe.call(W,q,$)})}if(E.addEventListener("change",()=>{var $;const N=E.files;if(!N||N.length===0)return;const z=($=e.maxFiles)!=null?$:1/0;for(let M=0;M<N.length;M++){if(d.length>=z){S(k("filesLimitExceeded",i,{skipped:N.length-M,max:z}));break}h(N[M])&&ge(N[M])}E.value=""}),w.appendChild(C),w.appendChild(y),w.appendChild(_),w.appendChild(Q),m.appendChild(v),m.appendChild(w),m.appendChild(g),e.minLength!=null||e.maxLength!=null){const $=document.createElement("div");$.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const N=ut(e,y);N.style.cssText=`
1379
1369
  position: static;
1380
1370
  display: inline-block;
1381
1371
  font-size: var(--fb-font-size-small);
1382
1372
  color: var(--fb-text-secondary-color);
1383
1373
  pointer-events: none;
1384
- `,$.appendChild(I),p.appendChild($)}p.appendChild(f),p.appendChild(v),u(),ee(),f._applyExternalUpdate=$=>{var I;const M=(I=$.text)!=null?I:"";x.value=M?rr(M,i,l):"",x.dispatchEvent(new Event("input")),i.length=0;for(const N of $.files)i.push(N);me(),ee(),u()},n.appendChild(p),me();const xe=new MutationObserver(()=>{p.isConnected||(s.abort(),z=Ke(z),xe.disconnect())});p.parentElement&&xe.observe(p.parentElement,{childList:!0})}function Il(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 u=i.resourceIndex.get(d);u!=null&&u.name&&f.set(d,u.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(u=>{const p=i.resourceIndex.get(u),m=document.createElement("div");m.style.cssText=`
1374
+ `,$.appendChild(N),m.appendChild($)}m.appendChild(u),m.appendChild(E),p(),Y(),u._applyExternalUpdate=$=>{var N;const z=(N=$.text)!=null?N:"";y.value=z?Lr(z,d,i):"",y.dispatchEvent(new Event("input")),d.length=0;for(const M of $.files)d.push(M);Ce(),Y(),p()},n.appendChild(m),Ce();const Oe=new MutationObserver(()=>{m.isConnected||(c.abort(),K=Xe(K),Oe.disconnect())});m.parentElement&&Oe.observe(m.parentElement,{childList:!0})}function ui(e,t,n,r,o){var l,a;const i=t.state,{text:d,files:s}=o,c=new Map;for(const u of s){const f=i.resourceIndex.get(u);f!=null&&f.name&&c.set(u,f.name)}if(s.length>0){const u=document.createElement("div");u.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",s.forEach(f=>{const p=i.resourceIndex.get(f),m=document.createElement("div");m.style.cssText=`
1385
1375
  position: relative;
1386
1376
  width: 48px; height: 48px;
1387
1377
  border: 1px solid var(--fb-border-color, #d1d5db);
@@ -1390,12 +1380,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1390
1380
  flex-shrink: 0;
1391
1381
  background: #fff;
1392
1382
  cursor: default;
1393
- `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",or(b,u,p,i),m.appendChild(b);const g=cr();m.addEventListener("mouseenter",()=>{gt(g),g.element||(g.element=sr(m,{rid:u,state:i,isReadonly:!0}),g.element.addEventListener("mouseenter",()=>{gt(g)}),g.element.addEventListener("mouseleave",()=>{bt(g)}))}),m.addEventListener("mouseleave",()=>{bt(g)}),d.appendChild(m)}),n.appendChild(d)}if(c){const d=document.createElement("div");d.style.cssText=`
1394
- ${vt}
1383
+ `;const g=document.createElement("div");g.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",Ar(g,f,p,i),m.appendChild(g);const x=Rr();m.addEventListener("mouseenter",()=>{Et(x),x.element||(x.element=Mr(m,{rid:f,state:i,isReadonly:!0}),x.element.addEventListener("mouseenter",()=>{Et(x)}),x.element.addEventListener("mouseleave",()=>{Ct(x)}))}),m.addEventListener("mouseleave",()=>{Ct(x)}),u.appendChild(m)}),n.appendChild(u)}if(d){const u=document.createElement("div");u.style.cssText=`
1384
+ ${kt}
1395
1385
  color: var(--fb-text-color, #111827);
1396
1386
  white-space: pre-wrap;
1397
1387
  word-break: break-word;
1398
- `;const u=ht(c).filter(p=>f.has(p.name)||[...f.values()].includes(p.name));if(u.length===0)d.textContent=c;else{let p=0;for(const m of u){m.start>p&&d.appendChild(document.createTextNode(c.slice(p,m.start)));const b=document.createElement("span");b.style.cssText=`
1388
+ `;const f=wt(d).filter(p=>c.has(p.name)||[...c.values()].includes(p.name));if(f.length===0)u.textContent=d;else{let p=0;for(const m of f){m.start>p&&u.appendChild(document.createTextNode(d.slice(p,m.start)));const g=document.createElement("span");g.style.cssText=`
1399
1389
  display: inline;
1400
1390
  background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
1401
1391
  color: var(--fb-primary-color, #0066cc);
@@ -1403,7 +1393,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1403
1393
  padding: 1px 6px;
1404
1394
  font-weight: 500;
1405
1395
  cursor: default;
1406
- `;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(b.textContent=`@${E}`,g){let h=null;const y=g;b.addEventListener("mouseenter",()=>{h=Ke(h),h=ar(b,y,i)}),b.addEventListener("mouseleave",()=>{h=Ke(h)})}d.appendChild(b),p=m.end}p<c.length&&d.appendChild(document.createTextNode(c.slice(p)))}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 Rl(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=(o=e.textKey)!=null?o:"text",d=(a=e.filesKey)!=null?a:"files";let u;if(e.flatOutput){const p=t.prefill[f],m=t.prefill[d];u={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,b=(l=m[f])!=null?l:m.text,g=(i=m[d])!=null?i:m.files;u={text:typeof b=="string"?b:null,files:Array.isArray(g)?g:[]}}else typeof p=="string"?u={text:p||null,files:[]}:u={text:null,files:[]}}for(const p of u.files)c.resourceIndex.has(p)||c.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)Il(e,t,n,r,u);else{if(!c.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Nl(e,t,n,r,u)}}function ql(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 u;try{const h=JSON.parse(d.value);if(h&&typeof h=="object"&&!Array.isArray(h))u=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 p=u[s],m=u[f],b=p===null||typeof p=="string"?p:null,g=Array.isArray(m)?m:[],E={[s]:b!=null?b:null,[f]:g};if(!i){const h=!b||b.trim()==="",y=g.length===0;e.required&&h&&y&&c.push(`${t}: ${k("required",l)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&c.push(`${t}: ${k("minLength",l,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&c.push(`${t}: ${k("maxLength",l,{max:e.maxLength})}`)),e.maxFiles!=null&&g.length>e.maxFiles&&c.push(`${t}: ${k("maxFiles",l,{max:e.maxFiles})}`)}return{value:E,errors:c,spread:!!e.flatOutput}}function Bl(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,u=(o=e.textKey)!=null?o:"text",p=(a=e.filesKey)!=null?a:"files",m=(l=d[u])!=null?l:d.text,b=(i=d[p])!=null?i:d.files;(m!==void 0||b!==void 0)&&(f={text:typeof m=="string"?m:null,files:Array.isArray(b)?b:[]})}f&&s._applyExternalUpdate?s._applyExternalUpdate(f):f&&(s.value=JSON.stringify(f))}const Hl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function fr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function et(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jt(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const a=t||{};let l=0,i,c,s,f,d;function u(m){const b=Hl[m[1]||""],g=r[r.length-1]===m;return b?b[1]?(g?r.pop():r.push(m),b[g?1:0]):b[0]:m}function p(){let m="";for(;r.length;)m+=u(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,b,g)=>(a[b.toLowerCase()]=g,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)c=e.substring(l,s.index),l=n.lastIndex,i=s[0],c.match(/[^\\](\\\\)*\\$/)||((d=s[3]||s[4])?i='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+fr(et(d).replace(/^\n+|\n+$/g,""))+"</code></pre>":(d=s[6])?(d.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),f=Jt(fr(s[5].replace(/^\s*[>*+.-]/gm,""))),d===">"?d="blockquote":(d=d.match(/\./)?"ol":"ul",f=f.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),i="<"+d+">"+f+"</"+d+">"):s[8]?i=`<img src="${et(s[8])}" alt="${et(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${et(s[11]||a[c.toLowerCase()])}">`),i=p()+"</a>"):s[9]?i="<a>":s[12]||s[14]?(d="h"+(s[14]?s[14].length:s[13]>"="?1:2),i="<"+d+">"+Jt(s[12]||s[15],a)+"</"+d+">"):s[16]?i="<code>"+et(s[16])+"</code>":(s[17]||s[1])&&(i=u(s[17]||"--"))),o+=c,o+=i;return(o+e.substring(l)+p()).replace(/^\n+|\n+$/g,"")}const pr="fb-markdown-styles";function Dl(){if(typeof document=="undefined"||document.getElementById(pr))return;const e=document.createElement("style");e.id=pr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1396
+ `;const x=c.has(m.name)?m.name:(l=[...c.entries()].find(([,h])=>h===m.name))==null?void 0:l[0],S=(a=c.get(m.name))!=null?a:m.name;if(g.textContent=`@${S}`,x){let h=null;const b=x;g.addEventListener("mouseenter",()=>{h=Xe(h),h=zr(g,b,i)}),g.addEventListener("mouseleave",()=>{h=Xe(h)})}u.appendChild(g),p=m.end}p<d.length&&u.appendChild(document.createTextNode(d.slice(p)))}n.appendChild(u)}if(!d&&s.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 fi(e,t,n,r){var o,l,a,i;const d=t.state,s=ae(e,d,t),c=(o=e.textKey)!=null?o:"text",u=(l=e.filesKey)!=null?l:"files";let f;if(e.flatOutput){const p=t.prefill[c],m=t.prefill[u];f={text:typeof p=="string"?p:null,files:Array.isArray(m)?m:[]}}else{const p=t.prefill[e.key];if(p&&typeof p=="object"&&!Array.isArray(p)){const m=p,g=(a=m[c])!=null?a:m.text,x=(i=m[u])!=null?i:m.files;f={text:typeof g=="string"?g:null,files:Array.isArray(x)?x:[]}}else typeof p=="string"?f={text:p||null,files:[]}:f={text:null,files:[]}}for(const p of f.files)d.resourceIndex.has(p)||d.resourceIndex.set(p,{name:p,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(s)ui(e,t,n,r,f);else{if(!d.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);ci(e,t,n,r,f)}}function pi(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch(t){return null}}function mi(e,t,n){var r,o;const{scopeRoot:l,state:a}=n,i=[],d=(r=e.textKey)!=null?r:"text",s=(o=e.filesKey)!=null?o:"files",c=l.querySelector(`[name="${t}"]`);if(!c)return{value:null,errors:i};const u=pi(c.value);if(u===null){const b="invalid richinput data";return i.push(`${t}: ${b}`),et(l,t,b,n),{value:null,errors:i}}const f=u[d],p=u[s],m=f===null||typeof f=="string"?f:null,g=Array.isArray(p)?p:[],x={[d]:m!=null?m:null,[s]:g},S=!m||m.trim()==="",h=[];return e.required&&S&&g.length===0&&h.push(k("required",a)),!S&&m&&(e.minLength!=null&&m.length<e.minLength&&h.push(k("minLength",a,{min:e.minLength})),e.maxLength!=null&&m.length>e.maxLength&&h.push(k("maxLength",a,{max:e.maxLength}))),e.maxFiles!=null&&g.length>e.maxFiles&&h.push(k("maxFiles",a,{max:e.maxFiles})),i.push(...h.map(b=>`${t}: ${b}`)),et(l,t,Ft(h),n),{value:x,errors:i,spread:!!e.flatOutput}}function hi(e,t,n,r){var o,l,a,i;const{scopeRoot:d}=r,s=d.querySelector(`[name="${t}"]`);if(!s){console.warn(`updateRichInputField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let c=null;if(n&&typeof n=="object"&&!Array.isArray(n)){const u=n,f=(o=e.textKey)!=null?o:"text",p=(l=e.filesKey)!=null?l:"files",m=(a=u[f])!=null?a:u.text,g=(i=u[p])!=null?i:u.files;(m!==void 0||g!==void 0)&&(c={text:typeof m=="string"?m:null,files:Array.isArray(g)?g:[]})}c&&s._applyExternalUpdate?s._applyExternalUpdate(c):c&&(s.value=JSON.stringify(c))}const bi={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function qr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function lt(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ln(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const l=t||{};let a=0,i,d,s,c,u;function f(m){const g=bi[m[1]||""],x=r[r.length-1]===m;return g?g[1]?(x?r.pop():r.push(m),g[x?1:0]):g[0]:m}function p(){let m="";for(;r.length;)m+=f(r[r.length-1]);return m}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(m,g,x)=>(l[g.toLowerCase()]=x,"")).replace(/^\n+|\n+$/g,"");s=n.exec(e);)d=e.substring(a,s.index),a=n.lastIndex,i=s[0],d.match(/[^\\](\\\\)*\\$/)||((u=s[3]||s[4])?i='<pre class="code '+(s[4]?"poetry":s[2].toLowerCase())+'"><code'+(s[2]?` class="language-${s[2].toLowerCase()}"`:"")+">"+qr(lt(u).replace(/^\n+|\n+$/g,""))+"</code></pre>":(u=s[6])?(u.match(/\./)&&(s[5]=s[5].replace(/^\d+/gm,"")),c=ln(qr(s[5].replace(/^\s*[>*+.-]/gm,""))),u===">"?u="blockquote":(u=u.match(/\./)?"ol":"ul",c=c.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),i="<"+u+">"+c+"</"+u+">"):s[8]?i=`<img src="${lt(s[8])}" alt="${lt(s[7])}">`:s[10]?(o=o.replace("<a>",`<a href="${lt(s[11]||l[d.toLowerCase()])}">`),i=p()+"</a>"):s[9]?i="<a>":s[12]||s[14]?(u="h"+(s[14]?s[14].length:s[13]>"="?1:2),i="<"+u+">"+ln(s[12]||s[15],l)+"</"+u+">"):s[16]?i="<code>"+lt(s[16])+"</code>":(s[17]||s[1])&&(i=f(s[17]||"--"))),o+=d,o+=i;return(o+e.substring(a)+p()).replace(/^\n+|\n+$/g,"")}const Hr="fb-markdown-styles";function gi(){if(typeof document=="undefined"||document.getElementById(Hr))return;const e=document.createElement("style");e.id=Hr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1407
1397
  .fb-markdown {
1408
1398
  font-family: var(--fb-font-family, inherit);
1409
1399
  font-size: var(--fb-font-size, 1rem);
@@ -1480,11 +1470,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
1480
1470
  .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1481
1471
  .fb-markdown em { font-style: italic; }
1482
1472
  .fb-markdown s { text-decoration: line-through; }
1483
- `,document.head.appendChild(e)}const jl=["javascript:","data:","vbscript:","blob:"],Ol=["javascript:","vbscript:","blob:"];function Ul(e){return!!(Ol.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Pl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Wl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();jl.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();Ul(r)&&t.setAttribute("src","")})}function Vl(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);Dl();const r=document.createElement("div");r.className="fb-markdown";const o=Pl(e.content);return r.innerHTML=Jt(o),Wl(r),n.appendChild(r),r}function Kl(e,t,n){return{value:void 0,errors:[],skip:!0}}function _l(e,t,n,r){}function Jl(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:Ct(l),errors:[]}}function Xl(e,t,n,r){const{scopeRoot:o}=r,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=Zt(n))}const mr={text:{validate:nn,update:rn},textarea:{validate:Ir,update:Rr},number:{validate:jr,update:Or},select:{validate:Wr,update:Vr},switcher:{validate:Xr,update:Yr},boolean:{validate:Qr,update:eo,ownsLabel:!0},file:{validate:qn,update:Hn},files:{validate:qn,update:Hn},colour:{validate:ol,update:ll},slider:{validate:sl,update:cl},container:{validate:Gn,update:Zn},group:{validate:hl,update:bl},table:{validate:Ll,update:Tl},richinput:{validate:ql,update:Bl},hidden:{validate:Jl,update:Xl},markdown:{validate:Kl,update:_l}};function hr(e){return mr[e]||null}function br(e){return e.type!=="markdown"&&(e.type==="hidden"||e.hidden)?mr.hidden:hr(e.type)}function Yl(e,t,n){const r=br(e);return r&&r.validate?r.validate(e,t,n):null}function Gl(e,t,n,r){const o=br(e);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Zl(e,t){const n=document.getElementById(e);if(!n)return;if(!t.isConnected){n.remove();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 gr(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!je(e.enableIf,a,l)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Ql(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.dataset.hiddenField?Ct(n.value):n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function ei(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let l=0;l<n.length-1;l++){const i=n[l],c=n[l+1],s=c.startsWith("[")&&c.endsWith("]")?[]:{};if(i.startsWith("[")&&i.endsWith("]")){const f=parseInt(i.slice(1,-1),10);o[f]=s}else o[i]=s;o=s}const a=n[n.length-1];return a.startsWith("[")&&a.endsWith("]")?o[parseInt(a.slice(1,-1),10)]=t:o[a]=t,r}function yt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const a=t.enableIf,l=(r=a.scope)!=null?r:"relative",i=!n.path||n.path===""?"absolute":l,c=a.key,s=i==="relative"&&n.path?`${n.path}.${c}`:c,f=Ql(s,o),d=ei(c,f),u=i==="relative"?{}:d,p=i==="relative"?d:void 0;try{je(a,u,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function vr(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",()=>{yt(e,t,n)}),d.addEventListener("input",()=>{yt(e,t,n)}),f.disconnect(),n.state.enableIfObservers.delete(f))});n.state.enableIfObservers.add(f),f.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{yt(e,t,n)}),s.addEventListener("input",()=>{yt(e,t,n)})}function ti(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function ni(e,t){const n=document.createElement("button");n.type="button",n.className="ml-2 text-gray-400 hover:text-gray-600",n.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 r=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,o=document.createElement("div");return o.id=r,o.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",o.style.position="fixed",o.textContent=e.description||e.hint||"Field information",document.body.appendChild(o),t.tooltipElements.add(o),n.onclick=a=>{a.preventDefault(),a.stopPropagation(),Zl(r,n)},n}function ri(e,t){const n=document.createElement("div");n.className="flex items-center",n.style.marginBottom="var(--fb-label-margin-bottom, 2px)",n.dataset.fbLabelRow="";const r=ti(e);if(n.appendChild(r),e.description||e.hint){const o=ni(e,t);n.appendChild(o)}return n}function oi(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?zr(e,t,n,r):Fr(e,t,n,r);break;case"textarea":o?Nr(e,t,n,r):Mr(e,t,n,r);break;case"number":o?Dr(e,t,n,r):Hr(e,t,n,r);break;case"select":o?Pr(e,t,n,r):Ur(e,t,n,r);break;case"switcher":o?Jr(e,t,n,r):_r(e,t,n,r);break;case"boolean":Zr(e,t,n,r);break;case"file":o?tl(e,t,n,r):Qo(e,t,n,r);break;case"files":el(e,t,n,r);break;case"colour":o?rl(e,t,n,r):nl(e,t,n,r);break;case"slider":o?al(e,t,n,r):il(e,t,n,r);break;case"group":ml(e,t,n,r);break;case"container":o?Xn(e,t,n,r):Jn(e,t,n,r);break;case"table":Sl(e,t,n,r);break;case"richinput":Rl(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function Xt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const c=document.createElement("div");return c.style.display="none",c.setAttribute("data-fb-hidden-markdown","true"),c}const l=gr(e,t),i=document.createElement("div");return i.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,i.setAttribute("data-field-key",wt(e,t.state)),i.setAttribute("data-fb-width",e.width||"full"),Vl(e,t,i),l&&(i.style.display="none",i.classList.add("fb-field-wrapper-disabled"),i.setAttribute("data-conditionally-disabled","true")),vr(i,e,t),i}const n=gr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=hr(e.type);if(!(o!=null&&o.ownsLabel)){const l=ri(e,t.state);r.appendChild(l)}const a=De(t.path,e.key);return oi(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),vr(r,e,t),r}dl(Xt);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,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",removeRow:"Remove row",removeRowFrom:"Remove row from {label}",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",removeRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",removeRowFrom:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0438\u0437 \xAB{label}\xBB",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function li(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:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set,tooltipElements:new Set}}function ii(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const _e={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.125rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function ai(e){const t={..._e,...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(`
1484
- `)}function si(e,t){Lr(e.ownerDocument||document);const n=ai(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=`
1473
+ `,document.head.appendChild(e)}const vi=["javascript:","data:","vbscript:","blob:"],yi=["javascript:","vbscript:","blob:"];function xi(e){return!!(yi.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function wi(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ci(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();vi.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();xi(r)&&t.setAttribute("src","")})}function Ei(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);gi();const r=document.createElement("div");r.className="fb-markdown";const o=wi(e.content);return r.innerHTML=ln(o),Ci(r),n.appendChild(r),r}function ki(e,t,n){return{value:void 0,errors:[],skip:!0}}function $i(e,t,n,r){}function Si(e,t,n){var r;const{scopeRoot:o}=n,l=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);return{value:cn((r=l==null?void 0:l.value)!=null?r:""),errors:[]}}function Li(e,t,n,r){const{scopeRoot:o}=r,l=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);l&&(l.value=dn(n))}const Br={text:{validate:En,update:kn},textarea:{validate:co,update:uo},number:{validate:bo,update:vo},select:{validate:wo,update:Co},switcher:{validate:So,update:Lo},boolean:{validate:Fo,update:zo,ownsLabel:!0},file:{validate:ir,update:dr},files:{validate:ir,update:dr},colour:{validate:Il,update:Nl},slider:{validate:Bl,update:Dl},container:{validate:wr,update:Cr},group:{validate:Vl,update:Kl},table:{validate:oi,update:li},richinput:{validate:mi,update:hi},hidden:{validate:Si,update:Li},markdown:{validate:ki,update:$i}};function Dr(e){return Br[e]||null}function Or(e){return e.type!=="markdown"&&(e.type==="hidden"||e.hidden)?Br.hidden:Dr(e.type)}function Ai(e,t,n){const r=Or(e);return r&&r.validate?r.validate(e,t,n):null}function Ti(e,t,n,r){const o=Or(e);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Fi(e,t){const n=document.getElementById(e);if(!n)return;if(!t.isConnected){n.remove();return}const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(c=>{c.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),l=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const i=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let d=o.left,s=o.bottom+5;d+i.width>l&&(d=o.right-i.width),s+i.height>a&&(s=o.top-i.height-5),d<10&&(d=10),s<10&&(s=o.bottom+5),n.style.left=`${d}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function jr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const l=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!Pe(e.enableIf,l,a)}catch(l){console.error(`Error evaluating enableIf for field "${e.key}":`,l)}return!1}function zi(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLInputElement&&n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}return un(n)}}function Mi(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const i=n[a],d=n[a+1],s=d.startsWith("[")&&d.endsWith("]")?[]:{};if(i.startsWith("[")&&i.endsWith("]")){const c=parseInt(i.slice(1,-1),10);o[c]=s}else o[i]=s;o=s}const l=n[n.length-1];return l.startsWith("[")&&l.endsWith("]")?o[parseInt(l.slice(1,-1),10)]=t:o[l]=t,r}function $t(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const l=t.enableIf,a=(r=l.scope)!=null?r:"relative",i=!n.path||n.path===""?"absolute":a,d=l.key,s=i==="relative"&&n.path?`${n.path}.${d}`:d,c=zi(s,o),u=Mi(d,c),f=i==="relative"?{}:u,p=i==="relative"?u:void 0;try{Pe(l,f,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function Ur(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 l=t.enableIf,a=(r=l.scope)!=null?r:"relative",i=l.key;let d;a==="relative"&&n.path?d=`${n.path}.${i}`:d=i;const s=o.querySelector(`[name="${d}"]`);if(!s){const c=new MutationObserver(()=>{const u=o.querySelector(`[name="${d}"]`);u&&(u.addEventListener("change",()=>{$t(e,t,n)}),u.addEventListener("input",()=>{$t(e,t,n)}),c.disconnect(),n.state.enableIfObservers.delete(c))});n.state.enableIfObservers.add(c),c.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{$t(e,t,n)}),s.addEventListener("input",()=>{$t(e,t,n)})}function Ri(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function Ii(e){if(e.head.querySelector("[data-fb-tooltip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-tooltip-styles",""),t.textContent='[id^="tooltip-"].hidden { display: none; }',e.head.appendChild(t)}function Ni(e,t){const n=document.createElement("button");n.type="button",n.className="ml-2 text-gray-400 hover:text-gray-600",n.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>',Ii(document);const r=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,o=document.createElement("div");return o.id=r,o.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",o.style.position="fixed",o.textContent=e.description||e.hint||"Field information",document.body.appendChild(o),t.tooltipElements.add(o),n.onclick=l=>{l.preventDefault(),l.stopPropagation(),Fi(r,n)},n}function qi(e,t){const n=document.createElement("div");n.className="flex items-center",n.style.marginBottom="var(--fb-label-margin-bottom, 2px)",n.dataset.fbLabelRow="";const r=Ri(e);if(n.appendChild(r),e.description||e.hint){const o=Ni(e,t);n.appendChild(o)}return n}function Hi(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?io(e,t,n,r):lo(e,t,n,r);break;case"textarea":o?so(e,t,n,r):ao(e,t,n,r);break;case"number":o?ho(e,t,n,r):mo(e,t,n,r);break;case"select":o?xo(e,t,n,r):yo(e,t,n,r);break;case"switcher":o?$o(e,t,n,r):ko(e,t,n,r);break;case"boolean":To(e,t,n,r);break;case"file":o?zl(e,t,n,r):Tl(e,t,n,r);break;case"files":Fl(e,t,n,r);break;case"colour":o?Rl(e,t,n,r):Ml(e,t,n,r);break;case"slider":o?Hl(e,t,n,r):ql(e,t,n,r);break;case"group":Wl(e,t,n,r);break;case"container":o?xr(e,t,n,r):yr(e,t,n,r);break;case"table":ni(e,t,n,r);break;case"richinput":fi(e,t,n,r);break;default:{const l=document.createElement("div");l.className="text-red-500 text-sm",l.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(l)}}}function an(e,t){if(e.type==="markdown"){if(e.hidden===!0){const d=document.createElement("div");return d.style.display="none",d.setAttribute("data-fb-hidden-markdown","true"),d}const a=jr(e,t),i=document.createElement("div");return i.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,i.setAttribute("data-field-key",Lt(e,t.state)),i.setAttribute("data-fb-width",e.width||"full"),Ei(e,t,i),a&&(i.style.display="none",i.classList.add("fb-field-wrapper-disabled"),i.setAttribute("data-conditionally-disabled","true")),Ur(i,e,t),i}const n=jr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=Ue(t.path,e.key);r.setAttribute("data-field-path",o);const l=Dr(e.type);if(!(l!=null&&l.ownsLabel)){const a=qi(e,t.state);r.appendChild(a)}return Hi(e,t,r,o),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Ur(r,e,t),r}Ol(an);const Pr={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,postMessageTarget:null,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",removeRow:"Remove row",removeRowFrom:"Remove row from {label}",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",selectPlaceholder:"Select\u2026",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",removeRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",removeRowFrom:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0438\u0437 \xAB{label}\xBB",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",selectPlaceholder:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435\u2026",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function Wr(e,t){const n={...e};if(t)for(const[r,o]of Object.entries(t))n[r]={...e[r]||{},...o};return n}function Bi(e){const t=Wr(Pr.translations,e==null?void 0:e.translations);return{instanceId:Di(),domIdCounter:0,reportedInvalid:new WeakSet,schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Pr,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,multiFileSetters:new WeakMap,enableIfObservers:new Set,autoExpandObservers:new Set,tooltipElements:new Set}}function Di(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Ye={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.125rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function Oi(e){const t={...Ye,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const l=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${l}: ${o};`)}),n.join(`
1474
+ `)}function ji(e,t){Yr(e.ownerDocument||document);const n=Oi(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=`
1485
1475
  [data-fb-root="true"] {
1486
1476
  ${n}
1487
1477
  }
1488
- `}const ci={default:_e,dark:{..._e,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:{..._e,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{..._e,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",inputPaddingX:"14px",inputPaddingY:"11px",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};function Gt(e,t,n){const r=e.querySelectorAll(`[data-field-key="${t}"]`);for(const o of Array.from(r))if(o.closest("[data-container-item], [data-container]")===n)return o;return null}class xt{constructor(t){this.instanceId=ii(),this.state=li(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);if(this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0){const o=n!==void 0?n:this.resolveDomPathValue(r.data,t);this.state.config.onFieldChange(t,o,r)}this.state.debounceTimer=null},this.state.config.debounceMs))}resolveDomPathValue(t,n){let r=t,o="";for(const a of n.split(".")){if(r==null)return;const l=a.match(/^(.+)\[(\d+)\]$/);if(!l){o=o?`${o}.${a}`:a,r=r[a];continue}const i=l[1];o=o?`${o}.${i}`:i;const c=r[i];if(!Array.isArray(c))return;const s=this.state.formRoot?nt(this.state.formRoot,o):[];o=`${o}[${l[2]}]`;const f=s.findIndex(d=>d.getAttribute("data-container-item")===o);r=f>=0?c[f]:c[parseInt(l[2],10)]}return r}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;const n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=this.findSchemaElement(t);if(!r)return null;const o=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const a of o){const l=r.label||r.key,i=a.querySelector("label");if(i&&(i.textContent===l||i.textContent===`${l}*`)){let c=a.querySelector(".field-placeholder");return c||(c=document.createElement("div"),c.className="field-placeholder",c.style.display="none",a.appendChild(c)),c}}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-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1478
+ `}const Ui={default:Ye,dark:{...Ye,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:{...Ye,primaryColor:"#0066cc",primaryHoverColor:"#0052a3",errorColor:"#d32f2f",errorHoverColor:"#c62828",successColor:"#388e3c",borderColor:"#e0e0e0",borderHoverColor:"#bdbdbd",borderFocusColor:"#0066cc",borderRadius:"4px",fontSize:"16px",fontSizeSmall:"14px",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif'},picaz:{...Ye,primaryColor:"#2f5bea",primaryHoverColor:"#2349c8",primarySoftColor:"#eaf0ff",primarySoftHoverColor:"#d6e0ff",errorColor:"#ef4444",successColor:"#16a34a",accentColor:"#ffb020",accentSoftColor:"#fff7e6",accentBorderColor:"#fde7b5",accentTextColor:"#92400e",borderColor:"#e3e8f0",borderHoverColor:"#cdd6e3",borderFocusColor:"#2f5bea",borderStrongColor:"#cdd6e3",backgroundColor:"#ffffff",backgroundHoverColor:"#f3f7ff",pageBackgroundColor:"#f6f8fb",surfaceSoftColor:"#eef4ff",surfaceTintColor:"#f3f7ff",textColor:"#0f172a",textSecondaryColor:"#334155",textMutedColor:"#64748b",textFaintColor:"#94a3b8",textPlaceholderColor:"#94a3b8",buttonBgColor:"#2f5bea",buttonHoverBgColor:"#2349c8",fileUploadBgColor:"#fafcff",fileUploadBorderColor:"#cdd6e3",fileUploadHoverBorderColor:"#2f5bea",inputPaddingX:"14px",inputPaddingY:"11px",borderRadius:"12px",borderRadiusSmall:"8px",borderRadiusLarge:"16px",borderRadiusXLarge:"22px",fontFamily:'"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingColor:"#2f5bea",slideCardBg:"linear-gradient(180deg, #f7f9fc 0%, #dde3ee 100%)",slideCardShadow:"none",slideCardRadius:"16px",labelSectionFontSize:"0.625rem",labelSectionLetterSpacing:"0.07em",labelSectionTextTransform:"uppercase"}};function sn(e,t,n){const r=e.querySelectorAll(`[data-field-key="${t}"]`);for(const o of Array.from(r))if(o.closest("[data-container-item], [data-container]")===n)return o;return null}class St{constructor(t){this.prefillHintHandler=null,this.state=Bi(t),this.instanceId=this.state.instanceId,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){const n=Wr(this.state.config.translations,t.translations);if(t.locale!==void 0&&!n[t.locale])throw new Error(`configure: no translations configured for locale "${t.locale}"`);Object.assign(this.state.config,t,{translations:n})}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){if(!this.state.config.translations[t])throw new Error(`setLocale: no translations configured for locale "${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);if(this.reevaluateConditionalFields(),this.state.config.onChange&&this.state.config.onChange(r),this.state.config.onFieldChange&&t!==void 0){const o=n!==void 0?n:this.resolveDomPathValue(r.data,t);this.state.config.onFieldChange(t,o,r)}this.state.debounceTimer=null},this.state.config.debounceMs))}resolveDomPathValue(t,n){let r=t,o="";for(const l of n.split(".")){if(r==null)return;const a=l.match(/^(.+)\[(\d+)\]$/);if(!a){o=o?`${o}.${l}`:l,r=r[l];continue}const i=a[1];o=o?`${o}.${i}`:i;const d=r[i];if(!Array.isArray(d))return;const s=this.state.formRoot?at(this.state.formRoot,o):[];o=`${o}[${a[2]}]`;const c=s.findIndex(u=>u.getAttribute("data-container-item")===o);r=c>=0?d[c]:d[parseInt(a[2],10)]}return r}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;const n=this.state.formRoot.querySelector(`[name="${t}"]`);if(n)return n;const r=this.findSchemaElement(t);if(!r)return null;const o=this.state.formRoot.querySelectorAll(".fb-field-wrapper");for(const l of o){const a=r.label||r.key,i=l.querySelector("label");if(i&&(i.textContent===a||i.textContent===`${a}*`)){let d=l.querySelector(".field-placeholder");return d||(d=document.createElement("div"),d.className="field-placeholder",d.style.display="none",l.appendChild(d)),d}}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 l of o){if(r=n.find(a=>a.key===l)||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 l=r.actions.find(a=>a.key===t);if(l&&l.label)return l.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const l=this.state.schema.actions.find(a=>a.key===t);if(l&&l.label)return l.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1489
1479
  border-top: var(--fb-border-width) solid var(--fb-border-color);
1490
- `,t.forEach(a=>{const l=document.createElement("button");l.type="button",tn(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(u=>{const p=document.createElement("button");p.type="button",tn(p,!1);const m=this.resolveActionLabel(u.key,u.label,d);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(u.value,u.key,u.related_field)}),f.appendChild(p)}),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 c in l){const s=o?c:`${a}.${c}`,f=l[c];this.updateField(s,f)}const i=n.closest(".fb-prefill-hints");i&&i.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(c=>c.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}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-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const a=kt(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.disconnectEnableIfObservers(),this.removeTooltipElements(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},we(t),t.setAttribute("data-fb-root","true"),si(t,this.state.config.theme);const l=document.createElement("div");if(l.className="fb-row",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="fb-row":i.className=`grid grid-cols-${c} gap-2`,n.elements.forEach(s=>{var f,d;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(d=(f=r==null?void 0:r[s.key])!=null?f:s.default)!=null?d:null;i.appendChild(Et(s.key,p));return}const u=Xt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});i.appendChild(u)}),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)=>{var c;const s=(c=a.key)!=null?c:"",f={scopeRoot:i||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},d=Yl(a,s,f);return d!==null?(n.push(...d.errors),{value:d.value,spread:!!d.spread,skip:!!d.skip}):(console.warn(`Unknown field type "${a.type}" for key "${s}"`),{value:null,spread:!1})};return pl(o),this.state.schema.elements.forEach(a=>{if(a.enableIf)try{if(!je(a.enableIf,r))return}catch(i){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,i)}if(a.type==="markdown")return;const l=o(a,{path:""});l.skip||(l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):a.key&&(r[a.key]=l.value))}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const 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:""};Gl(n,r,o,a)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=wt(t,this.state);if(!n)return Gt(r,o,null);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const i=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return i?Gt(i,o,i):null}const l=r.querySelector(`[data-container="${n}"]`);return l?Gt(l,o,l):null}applyEnableIfVisibility(t,n,r,o,a,l){var i,c,s,f;try{const d=((i=t.enableIf.scope)!=null?i:"relative")==="relative"&&o?rt(l,o):void 0,u=je(t.enableIf,l,d),p=n.getAttribute("data-conditionally-disabled")==="true";if(u&&p){const m=o?rt(l,o):l,b=Xt(t,{path:r,prefill:m&&typeof m=="object"?m:{},formData:l,state:this.state,instance:this});(c=n.parentNode)==null||c.replaceChild(b,n)}else if(!u&&!p){const m=document.createElement("div");m.className="fb-field-wrapper-disabled",m.style.display="none",m.setAttribute("data-field-key",wt(t,this.state)),m.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(m,n)}}catch(d){console.error(`Error re-evaluating enableIf for field "${(f=t.key)!=null?f:"<no key>"}" at path "${a}":`,d)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,a)=>{r.forEach(l=>{var i;const c=(i=l.key)!=null?i:"",s=o?`${o}.${c}`:c,f=a?`${a}.${c}`:c;if(l.enableIf){const d=this.findFieldWrapper(l,o);d&&this.applyEnableIfVisibility(l,d,o,a,s,t)}if((l.type==="container"||l.type==="group")&&"elements"in l&&l.elements){const d=l.key?rt(t,f):void 0;Array.isArray(d)?nt(this.state.formRoot,s).forEach((u,p)=>{const m=u.getAttribute("data-container-item")||"";n(l.elements,m,`${f}[${p}]`)}):n(l.elements,s,f)}})};n(this.state.schema.elements,"","")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.removeTooltipElements(),this.state.resourceIndex.clear(),this.state.formRoot&&we(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}removeTooltipElements(){for(const t of this.state.tooltipElements)t.remove();this.state.tooltipElements.clear()}}function yr(e){return new xt(e)}return typeof window!="undefined"&&(window.FormBuilder=xt,window.createFormBuilder=yr,window.validateSchema=kt),Fe.FormBuilderInstance=xt,Fe.createFormBuilder=yr,Fe.default=xt,Fe.defaultTheme=_e,Fe.exampleThemes=ci,Fe.validateSchema=kt,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});
1480
+ `,t.forEach(l=>{const a=document.createElement("button");a.type="button",wn(a,!0);const i=n.includes(l),d=this.resolveActionLabel(l.key,l.label,null,i);a.textContent=d,a.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(l.value,l.key,null)}),o.appendChild(a)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(l=>{!l.key||!l.value||(l.related_field?(t.has(l.related_field)||t.set(l.related_field,[]),t.get(l.related_field).push(l)):n.push(l))}),t.forEach((l,a)=>{const i=this.findFormElementByFieldPath(a);if(!i){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...l);return}let d=i.closest(".fb-field-wrapper");if(d||(d=i.parentElement),!d){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const s=d.querySelector(".external-actions-container");s&&s.remove();const c=document.createElement("div");c.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(a);l.forEach(f=>{const p=document.createElement("button");p.type="button",wn(p,!1);const m=this.resolveActionLabel(f.key,f.label,u);p.textContent=m,p.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),c.appendChild(p)}),d.appendChild(c)});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",l=n.getAttribute("data-container-key");if(!r||!o&&!l){console.warn("Prefill hint missing required data attributes");return}try{const a=JSON.parse(r);for(const d in a){const s=o?d:`${l}.${d}`,c=a[d];this.updateField(s,c)}const i=n.closest(".fb-prefill-hints");i&&i.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(d=>d.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(a){console.error("Error parsing prefill hint values:",a)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const l=It(n);if(l.length>0)throw new Error(`renderForm: invalid schema:
1481
+ - ${l.join(`
1482
+ - `)}`);this.disconnectEnableIfObservers(),this.disconnectAutoExpandObservers(),this.removeTooltipElements(),this.removePrefillHintListener(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},Ee(t),t.setAttribute("data-fb-root","true"),ji(t,this.state.config.theme);const a=document.createElement("div");if(a.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);a.appendChild(s)}const i=document.createElement("div"),d=n.columns||1;d===1?i.className="fb-row":i.className=`grid grid-cols-${d} gap-2`,n.elements.forEach(s=>{var c;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const f=r&&s.key in r?r[s.key]:(c=s.default)!=null?c:null;i.appendChild(At(s.key,f));return}const u=an(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});i.appendChild(u)}),a.appendChild(i),t.appendChild(a),this.state.config.readonly||(this.prefillHintHandler=this.handlePrefillHintClick.bind(this),t.addEventListener("click",this.prefillHintHandler)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){return t?{...this.runValidation("draft"),valid:!0,errors:[]}:this.runValidation("full")}runValidation(t){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(l,a,i=null)=>{var d;const s=(d=l.key)!=null?d:"",c={scopeRoot:i||this.state.formRoot,state:this.state,instance:this,path:a.path,draftMarks:t==="draft",readonly:ae(l,this.state,a),validateElement:o},u=Ai(l,s,c);return u!==null?(n.push(...u.errors),{value:u.value,spread:!!u.spread,skip:!!u.skip}):(console.warn(`Unknown field type "${l.type}" for key "${s}"`),{value:null,spread:!1})};return this.state.schema.elements.forEach(l=>{if(l.enableIf)try{if(!Pe(l.enableIf,r))return}catch(i){console.error(`Error evaluating enableIf for field "${l.key}" during validation:`,i)}if(l.type==="markdown")return;const a=o(l,{path:""});a.skip||(a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(r,a.value):l.key&&(r[l.key]=a.value))}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.runValidation("draft")}showErrors(){return this.runValidation("full")}focusFirstError(){const t=this.state.formRoot;if(!t)return!1;const n=t.querySelectorAll('[aria-invalid="true"]');for(const r of Array.from(n)){if(r.closest('[data-conditionally-disabled="true"]'))continue;const o=r.matches("input, select, textarea, button")?[r]:[...Array.from(r.querySelectorAll("input, select, textarea, button, [tabindex]")),r];for(const l of o)if(l.focus({preventScroll:!0}),document.activeElement===l)return l.scrollIntoView({block:"center"}),!0}return!1}submitForm(){const t=this.validateForm(!1);return t.valid&&this.postToParent("formSubmit",t.data),t}saveDraft(){const t=this.validateForm(!0);return this.postToParent("formDraft",t.data),t}postToParent(t,n){const r=this.state.config.postMessageTarget;if(r==="")throw new Error('postMessageTarget: "" is not a valid target origin \u2014 use null to disable posting or "*" to knowingly broadcast');!r||typeof window=="undefined"||!window.parent||window.parent.postMessage({type:t,data:n,schema:this.state.schema},r)}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const l=r,a=this.buildHiddenFieldsData(l.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const l of t)if(l.type==="richinput"&&l.flatOutput){const a=l,i=(n=a.textKey)!=null?n:"text",d=(r=a.filesKey)!=null?r:"files";o.set(i,{schemaKey:l.key,role:"text"}),o.set(d,{schemaKey:l.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 l=n.get(o);l?(r.has(l.schemaKey)||r.set(l.schemaKey,{}),r.get(l.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,l]of r)this.updateField(o,l)}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 l={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Ti(n,r,o,l)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=Lt(t,this.state);if(!n)return sn(r,o,null);const l=n.match(/^(.+)\[(\d+)\]$/);if(l){const i=r.querySelector(`[data-container-item="${l[1]}[${l[2]}]"]`);return i?sn(i,o,i):null}const a=r.querySelector(`[data-container="${n}"]`);return a?sn(a,o,a):null}applyEnableIfVisibility(t,n,r,o,l,a){var i,d,s,c;try{const u=((i=t.enableIf.scope)!=null?i:"relative")==="relative"&&o?ct(a,o):void 0,f=Pe(t.enableIf,a,u),p=n.getAttribute("data-conditionally-disabled")==="true";if(f&&p){const m=o?ct(a,o):a,g=an(t,{path:r,prefill:m&&typeof m=="object"?m:{},formData:a,state:this.state,instance:this});(d=n.parentNode)==null||d.replaceChild(g,n)}else if(!f&&!p){const m=document.createElement("div");m.className="fb-field-wrapper-disabled",m.style.display="none",m.setAttribute("data-field-key",Lt(t,this.state)),m.setAttribute("data-conditionally-disabled","true"),m.setAttribute("data-field-path",l),(s=n.parentNode)==null||s.replaceChild(m,n)}}catch(u){console.error(`Error re-evaluating enableIf for field "${(c=t.key)!=null?c:"<no key>"}" at path "${l}":`,u)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,l)=>{r.forEach(a=>{var i;const d=(i=a.key)!=null?i:"",s=o?`${o}.${d}`:d,c=l?`${l}.${d}`:d;if(a.enableIf){const u=this.findFieldWrapper(a,o);u&&this.applyEnableIfVisibility(a,u,o,l,s,t)}if((a.type==="container"||a.type==="group")&&"elements"in a&&a.elements){const u=a.key?ct(t,c):void 0;Array.isArray(u)?at(this.state.formRoot,s).forEach((f,p)=>{const m=f.getAttribute("data-container-item")||"";n(a.elements,m,`${c}[${p}]`)}):n(a.elements,s,c)}})};n(this.state.schema.elements,"","")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.disconnectAutoExpandObservers(),this.removeTooltipElements(),this.removePrefillHintListener(),this.state.resourceIndex.clear(),this.state.formRoot&&Ee(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}disconnectAutoExpandObservers(){for(const t of this.state.autoExpandObservers)t.disconnect();this.state.autoExpandObservers.clear()}removePrefillHintListener(){this.prefillHintHandler&&this.state.formRoot&&this.state.formRoot.removeEventListener("click",this.prefillHintHandler),this.prefillHintHandler=null}removeTooltipElements(){for(const t of this.state.tooltipElements)t.remove();this.state.tooltipElements.clear()}}function Vr(e){return new St(e)}return typeof window!="undefined"&&(window.FormBuilder=St,window.createFormBuilder=Vr,window.validateSchema=It),Fe.FormBuilderInstance=St,Fe.createFormBuilder=Vr,Fe.default=St,Fe.defaultTheme=Ye,Fe.exampleThemes=Ui,Fe.validateSchema=It,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});