@dmitryvim/form-builder 0.5.4 → 0.6.4

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.
@@ -0,0 +1,1472 @@
1
+ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){var r,o;const i=t.config.locale||"en",a=t.config.translations[i],l=t.config.translations.en;let s=(o=(r=a==null?void 0:a[e])!=null?r:l==null?void 0:l[e])!=null?o:e;if(n)for(const[d,c]of Object.entries(n))s=s.replace(new RegExp(`\\{${d}\\}`,"g"),()=>String(c));return s}function se(e,t,n){return e.readonly===!0||t.config.readonly===!0||(n==null?void 0:n.inheritedReadonly)===!0}function Xe(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 Et(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 Oe(e,t){return e?`${e}.${t}`:t}function rt(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 Ce(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Lr(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Gt(e){return e===void 0?"":JSON.stringify(e)}function Zt(e){if(e==="")return null;try{return JSON.parse(e)}catch(t){return e}}function Qt(e){if(e instanceof HTMLInputElement){if(e.type==="checkbox")return e.checked;if(e.dataset.hiddenField)return Zt(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 kt(e,t){const n=document.createElement("input");return n.type="hidden",n.name=e,n.setAttribute("data-hidden-field","true"),n.value=Gt(t),n}function Tr(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 Ar(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 Fr(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 zr(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 Mr(e,t,n){e.pattern&&t.push(k("hintPattern",n,{pattern:e.pattern}))}function Te(e,t){const n=[];return Tr(e,n,t),e.type!=="slider"&&Ar(e,n,t),Fr(e,n,t),zr(e,n,t),Mr(e,n,t),n.join(" \u2022 ")}function $t(e){const t=[];if(!e||typeof e!="object")return t.push("Schema must be an object"),t;if(!Array.isArray(e.elements))return t.push("Schema missing elements array"),t;if("columns"in e&&e.columns!==void 0){const l=e.columns,s=[1,2,3,4];(!Number.isInteger(l)||!s.includes(l))&&t.push(`schema.columns must be 1, 2, 3, or 4 (got ${l})`)}if("prefillHints"in e&&e.prefillHints){const l=e.prefillHints;Array.isArray(l)&&l.forEach((s,d)=>{if((!s.label||typeof s.label!="string")&&t.push(`schema.prefillHints[${d}] must have a 'label' property of type string`),!s.values||typeof s.values!="object")t.push(`schema.prefillHints[${d}] must have a 'values' property of type object`);else for(const c in s.values)e.elements.some(u=>u.key===c)||t.push(`schema.prefillHints[${d}] references non-existent field "${c}"`)})}function n(l,s,d){if("columns"in l&&l.columns!==void 0){const c=l.columns,u=[1,2,3,4];(!Number.isInteger(c)||!u.includes(c))&&d.push(`${s}: columns must be 1, 2, 3, or 4 (got ${c})`)}if("displayMode"in l&&l.displayMode!==void 0){const c=l.displayMode;c!=="stack"&&c!=="slides"&&d.push(`${s}: displayMode must be "stack" or "slides" (got ${JSON.stringify(c)})`)}}function r(l,s){var d,c;const u=new Set;for(const f of l)if(f.type==="richinput"&&f.flatOutput){const m=f,p=(d=m.textKey)!=null?d:"text",b=(c=m.filesKey)!=null?c:"files";for(const v of l)v!==f&&(v.key===p&&t.push(`${s}: RichInput "${f.key}" flatOutput textKey "${p}" collides with element key "${v.key}"`),v.key===b&&t.push(`${s}: RichInput "${f.key}" flatOutput filesKey "${b}" collides with element key "${v.key}"`));u.has(p)&&t.push(`${s}: RichInput "${f.key}" flatOutput textKey "${p}" collides with another flatOutput key`),u.has(b)&&t.push(`${s}: RichInput "${f.key}" flatOutput filesKey "${b}" collides with another flatOutput key`),u.add(p),u.add(b)}else f.key&&(u.has(f.key)&&t.push(`${s}: Element key "${f.key}" collides with a flatOutput richinput key`),u.add(f.key))}function o(l,s,d){var c,u;const f=l;if(f.type==="group"){if(!Xe(f.repeat))return;i(s,(c=f.repeat)==null?void 0:c.min,(u=f.repeat)==null?void 0:u.max,"repeat.min","repeat.max",f.required===!0,d);return}(f.multiple===!0||f.type==="files")&&i(s,f.minCount,f.maxCount,"minCount","maxCount",f.required===!0,d)}function i(l,s,d,c,u,f,m){for(const[$,h]of[[c,s],[u,d]])h!==void 0&&typeof h!="number"&&m.push(`${l}: ${$} must be a number (got ${typeof h})`);const p=typeof s=="number"?s:void 0,b=typeof d=="number"?d:void 0;b!==void 0&&(b<0||Number.isNaN(b))&&m.push(`${l}: ${u} must be a non-negative number or Infinity (got ${b})`),p!==void 0&&(p<0||!Number.isFinite(p))&&m.push(`${l}: ${c} must be a finite non-negative number (got ${p})`);const v=p!=null?p:f?1:void 0;if(v!==void 0&&b!==void 0&&v>b){const $=p!==void 0?`${c} (${p})`:`required: true (implies ${c} 1)`;m.push(`${l}: ${$} cannot be greater than ${u} (${b})`)}}function a(l,s){const d=new Set;l.forEach((c,u)=>{c.key&&(d.has(c.key)&&t.push(`${s}[${u}]: duplicate key "${c.key}"`),d.add(c.key))}),l.forEach((c,u)=>{const f=`${s}[${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 m=c.decimals;m!==void 0&&(!Number.isInteger(m)||m<0)&&t.push(`${f}: decimals must be a non-negative integer (got ${JSON.stringify(m)})`)}if(c.type==="markdown"){const m=c.content;typeof m!="string"&&t.push(`${f}: markdown element requires "content" to be a string (got ${m===null?"null":typeof m})`)}if(c.enableIf){const m=c.enableIf;(!m.key||typeof m.key!="string")&&t.push(`${f}: enableIf must have a 'key' property of type string`),"equals"in m||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 m=c.prefillHints;Array.isArray(m)&&m.forEach((p,b)=>{if((!p.label||typeof p.label!="string")&&t.push(`${f}: prefillHints[${b}] must have a 'label' property of type string`),!p.values||typeof p.values!="object")t.push(`${f}: prefillHints[${b}] must have a 'values' property of type object`);else for(const v in p.values)c.elements.some($=>$.key===v)||t.push(`container "${c.key}": prefillHints[${b}] references non-existent field "${v}"`)})}a(c.elements,`${f}.elements`),r(c.elements,`${f}.elements`)}if(c.type==="select"&&c.options){const m=c.default;m!=null&&m!==""&&(c.options.some(p=>p.value===m)||t.push(`${f}: default "${m}" not in options`))}})}return Array.isArray(e.elements)&&(a(e.elements,"elements"),r(e.elements,"elements")),t}function ot(e,t){if(!e||typeof e!="object")return;const n=t.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return;let r=e;for(const o of n){if(r==null)return;if(o.startsWith("[")&&o.endsWith("]")){const i=parseInt(o.slice(1,-1),10);if(!Array.isArray(r)||isNaN(i))return;r=r[i]}else r=r[o]}return r}function 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 i;if(o==="relative")i=n!=null?n:t;else if(o==="absolute")i=t;else throw new Error(`Invalid enableIf scope: must be "relative" or "absolute" (got "${o}")`);const a=ot(i,e.key);if("equals"in e)return Rr(a,e.equals);throw new Error("Invalid enableIf condition: no recognized operator (equals, etc.)")}function Rr(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 en(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 lt(e){const t=en(e),n=e.getAttribute("name"),r=t.parentElement;if(n&&r){for(const i of Array.from(r.children))if(i.classList.contains("error-message")&&i.getAttribute("data-error-for")===n)return i}const o=t.nextElementSibling;return o&&o.classList.contains("error-message")?o:null}function ne(e,t){var n,r,o,i;if(!e)return;if(t==null){e.classList.remove("invalid"),e.title="",(n=lt(e))==null||n.remove();return}if(e.classList.add("invalid"),e.title=t,t===""){(r=lt(e))==null||r.remove();return}let a=lt(e);if(!a){const l=en(e);a=document.createElement("div"),a.className="error-message",a.style.cssText=`
2
+ color: var(--fb-error-color);
3
+ font-size: var(--fb-font-size-small);
4
+ margin-top: 0.25rem;
5
+ `,(o=l.parentNode)==null||o.insertBefore(a,l.nextSibling)}a.setAttribute("data-error-for",(i=e.getAttribute("name"))!=null?i:""),a.textContent=t,a.style.display="block"}function Ee(e){var t;(t=lt(e))==null||t.remove()}const tn='<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 Ir(e){if(e.head.querySelector("[data-fb-theming-hooks]"))return;const t=e.createElement("style");t.setAttribute("data-fb-theming-hooks",""),t.textContent=`
6
+ [data-fb-slide-card] {
7
+ background: var(--fb-slide-card-bg);
8
+ box-shadow: var(--fb-slide-card-shadow);
9
+ border-radius: var(--fb-slide-card-radius);
10
+ min-height: var(--fb-slide-card-min-height);
11
+ padding: var(--fb-slide-card-padding);
12
+ }
13
+ /* Slides-mode outer grid. Responsive by design \u2014 column count derives from
14
+ container width and --fb-slide-min-width, not from a schema "columns" prop.
15
+ min(100%, ...) prevents the card from overflowing a narrow container.
16
+ Override per-form: set --fb-slide-min-width / --fb-slides-gap on any
17
+ ancestor (theme, host CSS, or the form root). */
18
+ .fb-container-slides {
19
+ display: grid;
20
+ gap: var(--fb-slides-gap, 14px);
21
+ align-items: stretch;
22
+ grid-template-columns: repeat(
23
+ auto-fit,
24
+ minmax(min(100%, var(--fb-slide-min-width, 280px)), 1fr)
25
+ );
26
+ }
27
+ [data-fb-label-row] > label {
28
+ font-size: var(--fb-label-section-font-size);
29
+ letter-spacing: var(--fb-label-section-letter-spacing);
30
+ text-transform: var(--fb-label-section-text-transform);
31
+ }
32
+ /* Per-item remove (trash) button used by multi-container items. Shares the
33
+ same faint-on-rest, error-on-hover palette as .fb-chip-remove. */
34
+ .fb-item-remove {
35
+ color: var(--fb-text-faint-color, #94a3b8);
36
+ background-color: transparent;
37
+ transition: color var(--fb-transition-duration), background-color var(--fb-transition-duration);
38
+ }
39
+ .fb-item-remove:hover {
40
+ color: var(--fb-error-color);
41
+ background-color: var(--fb-background-hover-color);
42
+ }
43
+ .fb-item-remove:disabled {
44
+ opacity: 0.35;
45
+ cursor: not-allowed;
46
+ }
47
+ /* Cards carrying a row-level remove button reserve a right-hand lane for it
48
+ (24px button + inset + gap) so it never sits on top of the first field's
49
+ control. A class rather than an inline style, so host CSS can override the
50
+ gutter without !important; the compound selector keeps it ahead of the
51
+ card's own p-2 utility regardless of stylesheet order. Its own token, not
52
+ --fb-slide-card-padding, which is slides-only and always resolves. */
53
+ .containerItem.fb-row-removable {
54
+ padding-right: var(--fb-row-remove-gutter, 40px);
55
+ }
56
+ /* Prefill-suggestion pills rendered by createPrefillHints. Outline pill at rest,
57
+ soft-fill on hover, solid-fill when selected. All colors flow from the active
58
+ theme \u2014 consumers don't need to ship their own CSS. */
59
+ .fb-prefill-hint {
60
+ padding: 0.25rem 0.625rem;
61
+ border: var(--fb-border-width) solid var(--fb-primary-color);
62
+ border-radius: 9999px;
63
+ background: var(--fb-background-color);
64
+ color: var(--fb-primary-color);
65
+ font-size: var(--fb-font-size-small);
66
+ font-weight: var(--fb-font-weight-medium);
67
+ font-family: var(--fb-font-family);
68
+ cursor: pointer;
69
+ transition: background-color var(--fb-transition-duration), border-color var(--fb-transition-duration), color var(--fb-transition-duration);
70
+ }
71
+ .fb-prefill-hint:hover {
72
+ background: var(--fb-primary-soft-color);
73
+ border-color: var(--fb-primary-hover-color);
74
+ color: var(--fb-primary-hover-color);
75
+ }
76
+ .fb-prefill-hint:focus-visible {
77
+ outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
78
+ outline-offset: 2px;
79
+ }
80
+ .fb-prefill-hint[aria-pressed="true"],
81
+ .fb-prefill-hint.active {
82
+ background: var(--fb-primary-color);
83
+ color: #ffffff;
84
+ border-color: var(--fb-primary-color);
85
+ }
86
+ /* \u2500\u2500\u2500 Row layout: flex-wrap container with per-child width tokens \u2500\u2500\u2500
87
+ Replaces the older Tailwind \`space-y-2\` class. Children without
88
+ data-fb-width (or width="full") take 100% basis \u2192 forced wrap \u2192 behaves
89
+ like a vertical stack. Mixed widths sit side-by-side in the same row. */
90
+ .fb-row {
91
+ display: flex;
92
+ flex-wrap: wrap;
93
+ gap: var(--fb-row-gap, 0.25rem);
94
+ align-items: flex-start;
95
+ }
96
+ .fb-row > [data-fb-width="full"],
97
+ .fb-row > :not([data-fb-width]) { flex: 0 0 100%; min-width: 0; }
98
+ .fb-row > [data-fb-width="1/2"] { flex: 0 0 calc(50% - var(--fb-row-gap, 0.25rem) / 2); min-width: 0; }
99
+ .fb-row > [data-fb-width="1/3"] { flex: 0 0 calc(33.333% - var(--fb-row-gap, 0.25rem) * 2 / 3); min-width: 0; }
100
+ .fb-row > [data-fb-width="2/3"] { flex: 0 0 calc(66.666% - var(--fb-row-gap, 0.25rem) / 3); min-width: 0; }
101
+ /* \u2500\u2500\u2500 Density tokens: re-bind --fb-input-padding-* and --fb-font-size at
102
+ the wrapper level so every component that reads those vars (text, textarea,
103
+ select, number, colour, switcher, file) picks the size up via cascade. md
104
+ uses the defaults set in theme.ts (2px / 8px / 14px). The scale primarily
105
+ varies font-size; vertical padding stays close to md so an "lg" heading
106
+ field does not visually break the form's row rhythm \u2014 only the typography
107
+ announces "this is bigger". Picaz theme overrides padding directly for
108
+ its own density, independent of this scale. */
109
+ /* size-token side-effects on file tiles: --fb-file-wide-min controls the
110
+ single-file empty dropzone height, --fb-file-zone-min controls the inner
111
+ upload/library zones. Both read in src/components/file/styles.ts. */
112
+ .fb-size-xs { --fb-input-padding-y: 1px; --fb-input-padding-x: 6px; --fb-font-size: 12px; --fb-font-size-small: 10px; --fb-line-height: 1.25; --fb-file-wide-min: 64px; --fb-file-zone-min: 48px; --fb-file-zone-padding: 6px; }
113
+ .fb-size-sm { --fb-input-padding-y: 2px; --fb-input-padding-x: 6px; --fb-font-size: 13px; --fb-font-size-small: 11px; --fb-line-height: 1.35; --fb-file-wide-min: 80px; --fb-file-zone-min: 60px; --fb-file-zone-padding: 7px; }
114
+ /* .fb-size-md uses defaults \u2014 no override needed */
115
+ .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; }
116
+ .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; }
117
+ `,e.head.appendChild(t)}function it(e,t){var n,r;e.style.overflow="hidden",e.style.resize="none";const o=Math.max(1,(n=t.minRows)!=null?n:1),i=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(o,i);const a=()=>{if(!e.isConnected)return;e.style.height="";const d=getComputedStyle(e),c=parseFloat(d.borderTopWidth||"0")+parseFloat(d.borderBottomWidth||"0"),u=parseFloat(d.lineHeight||"0")||parseFloat(d.fontSize||"0")*1.5||20,f=parseFloat(d.paddingTop||"0")+parseFloat(d.paddingBottom||"0"),m=u*o+f+c;if(e.value===""){e.style.height=`${m}px`;return}const p=e.scrollHeight+c;e.style.height=`${Math.max(p,m)}px`};if(e.addEventListener("input",a),setTimeout(()=>{e.isConnected&&a()},0),typeof ResizeObserver=="undefined")return;let l=-1;const s=new ResizeObserver(d=>{var c,u,f,m,p,b;if(!e.isConnected){s.disconnect(),(c=t.observers)==null||c.delete(s);return}const v=d[0],$=(b=(p=(f=(u=v==null?void 0:v.contentBoxSize)==null?void 0:u[0])==null?void 0:f.inlineSize)!=null?p:(m=v==null?void 0:v.contentRect)==null?void 0:m.width)!=null?b:0;$!==l&&(l=$,a())});s.observe(e),(r=t.observers)==null||r.add(s)}function nn(e){e.addEventListener("keydown",t=>{t.key==="Enter"&&t.preventDefault()}),e.addEventListener("paste",t=>{var n,r,o,i;const a=(r=(n=t.clipboardData)==null?void 0:n.getData("text"))!=null?r:"";if(!/[\r\n]/.test(a))return;t.preventDefault();const l=a.replace(/[\r\n]+/g," "),s=(o=e.selectionStart)!=null?o:e.value.length,d=(i=e.selectionEnd)!=null?i:e.value.length,c=e.value.slice(0,s),u=e.value.slice(d);e.value=c+l+u;const f=s+l.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:"",i=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 l=document.createElement("button");l.type="button",l.className=`add-${e}-btn`,l.style.cssText=`
118
+ flex: 1 1 auto;
119
+ display: inline-flex;
120
+ align-items: center;
121
+ justify-content: center;
122
+ gap: 4px;
123
+ padding: 3px 10px;
124
+ border: 1px dashed var(--fb-primary-color);
125
+ border-radius: var(--fb-border-radius);
126
+ background: transparent;
127
+ color: var(--fb-primary-color);
128
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
129
+ font-weight: 500;
130
+ font-family: var(--fb-font-family);
131
+ cursor: pointer;
132
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
133
+ `,l.textContent=o?`+ ${o}`:"+",l.addEventListener("mouseenter",()=>{l.disabled||(l.style.borderStyle="solid",l.style.backgroundColor="var(--fb-background-hover-color)")}),l.addEventListener("mouseleave",()=>{l.style.borderStyle="dashed",l.style.backgroundColor="transparent"}),l.onclick=t;const s=document.createElement("span");return s.className="fb-add-counter",s.style.cssText=`
134
+ margin-left: auto;
135
+ font-size: var(--fb-font-size-small, 0.875rem);
136
+ color: var(--fb-text-secondary-color);
137
+ font-weight: 400;
138
+ `,i||(s.style.display="none"),a.appendChild(l),{row:a,button:l,counter:s,update:(d,c)=>{const u=d>=c;a.style.display=u?"none":"flex",l.style.display=u?"none":"inline-flex",l.disabled=u,i&&(s.textContent=`${d}/${c===1/0?"\u221E":c}`)}}}function Nr(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=`
139
+ display: flex;
140
+ flex-direction: column;
141
+ align-items: center;
142
+ justify-content: center;
143
+ gap: 12px;
144
+ width: 100%;
145
+ min-height: 180px;
146
+ align-self: stretch;
147
+ padding: 24px 16px;
148
+ border: 1.5px dashed var(--fb-primary-color);
149
+ border-radius: var(--fb-border-radius);
150
+ background: transparent;
151
+ color: var(--fb-primary-color);
152
+ font-size: var(--fb-font-size-small, var(--fb-font-size));
153
+ font-weight: 500;
154
+ font-family: var(--fb-font-family);
155
+ cursor: pointer;
156
+ transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
157
+ `;const i=document.createElement("span");if(i.className="fb-slide-add-circle",i.style.cssText=`
158
+ display: inline-flex;
159
+ align-items: center;
160
+ justify-content: center;
161
+ width: 36px;
162
+ height: 36px;
163
+ border: 1px solid var(--fb-primary-color);
164
+ border-radius: 50%;
165
+ background: var(--fb-background-color);
166
+ font-size: 20px;
167
+ line-height: 1;
168
+ color: inherit;
169
+ transition: inherit;
170
+ `,i.textContent="+",o.appendChild(i),r){const l=document.createElement("span");l.textContent=r,o.appendChild(l)}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=`
171
+ margin-left: auto;
172
+ font-size: var(--fb-font-size-small, 0.875rem);
173
+ color: var(--fb-text-secondary-color);
174
+ font-weight: 400;
175
+ `,{tile:o,counter:a,update:(l,s)=>{const d=l>=s;o.style.display=d?"none":"flex",o.disabled=d,a.textContent=`${l}/${s===1/0?"\u221E":s}`}}}function rn(e,t=!1){e.style.cssText=`
176
+ background-color: var(--fb-action-bg-color);
177
+ color: var(--fb-action-text-color);
178
+ border: var(--fb-border-width) solid var(--fb-action-border-color);
179
+ padding: ${t?"0.5rem 1rem":"0.5rem 0.75rem"};
180
+ font-size: var(--fb-font-size);
181
+ font-weight: var(--fb-font-weight-medium);
182
+ border-radius: var(--fb-border-radius);
183
+ transition: all var(--fb-transition-duration);
184
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
185
+ `,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 qr(e){if(e.head.querySelector("[data-fb-chip-styles]"))return;const t=e.createElement("style");t.setAttribute("data-fb-chip-styles",""),t.textContent=`
186
+ .fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
187
+ .fb-chip {
188
+ display: flex;
189
+ align-items: center;
190
+ gap: 6px;
191
+ padding: 3px 6px 3px 8px;
192
+ background: var(--fb-chip-bg, var(--fb-background-color, #fff));
193
+ border: 1px solid var(--fb-chip-border, var(--fb-border-color, #e2e8f0));
194
+ border-radius: 6px;
195
+ position: relative;
196
+ transition: border-color var(--fb-transition-duration, 0.15s);
197
+ }
198
+ .fb-chip:hover { border-color: var(--fb-border-hover-color, var(--fb-border-color, #cbd5e1)); }
199
+ .fb-chip:focus-within { border-color: var(--fb-border-focus-color, var(--fb-primary-color, #2f5bea)); }
200
+ .fb-chip-dot {
201
+ flex: 0 0 6px;
202
+ width: 6px;
203
+ height: 6px;
204
+ border-radius: 50%;
205
+ background: var(--fb-chip-dot, var(--fb-primary-color, #2f5bea));
206
+ }
207
+ .fb-chip-input {
208
+ flex: 1;
209
+ min-width: 0;
210
+ padding: 2px 0;
211
+ border: 0;
212
+ outline: none;
213
+ background: transparent;
214
+ color: var(--fb-chip-text, var(--fb-text-color, inherit));
215
+ font-size: var(--fb-font-size, 14px);
216
+ font-family: var(--fb-font-family, inherit);
217
+ line-height: var(--fb-line-height, 1.4);
218
+ /* Soft-wrap support (v0.4.0): chip-input is now a <textarea rows=1> that
219
+ grows vertically when content overflows the chip width. */
220
+ resize: none;
221
+ overflow: hidden;
222
+ word-break: break-word;
223
+ overflow-wrap: anywhere;
224
+ }
225
+ .fb-chip-input::placeholder { color: var(--fb-text-placeholder-color, #94a3b8); }
226
+ .fb-chip-input:read-only { color: var(--fb-text-secondary-color, #475569); }
227
+ .fb-chip-remove {
228
+ flex: 0 0 auto;
229
+ width: 22px;
230
+ height: 22px;
231
+ display: inline-flex;
232
+ align-items: center;
233
+ justify-content: center;
234
+ padding: 0;
235
+ border: 0;
236
+ border-radius: 4px;
237
+ background: transparent;
238
+ color: var(--fb-text-faint-color, #94a3b8);
239
+ cursor: pointer;
240
+ opacity: 0;
241
+ transition: opacity 0.12s, color 0.12s, background-color 0.12s;
242
+ }
243
+ .fb-chip:hover .fb-chip-remove,
244
+ .fb-chip-remove:focus-visible { opacity: 1; }
245
+ .fb-chip-remove:hover {
246
+ color: var(--fb-error-color, #dc2626);
247
+ background: var(--fb-background-hover-color, #f1f5f9);
248
+ }
249
+ .fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
250
+ `,e.head.appendChild(t)}function at(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
251
+ margin-top: 4px;
252
+ padding-right: 12px;
253
+ text-align: right;
254
+ font-size: var(--fb-font-size-small);
255
+ line-height: 1;
256
+ color: var(--fb-error-color);
257
+ pointer-events: none;
258
+ display: none;
259
+ `;const r=()=>{const o=t.value.length,i=e.maxLength;i!=null&&o>i?(n.textContent=`${o}/${i}`,n.style.display="block"):(n.textContent="",n.style.display="none")};return t.addEventListener("input",r),r(),n}function Hr(e,t,n,r){var o,i,a;const l=t.state,s=se(e,l,t),d=document.createElement("div");d.style.cssText="position: relative;";const c=!s&&(e.minLength!=null||e.maxLength!=null),u=document.createElement("textarea");if(u.rows=1,u.className="w-full rounded-lg",u.style.cssText=`
260
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
261
+ border: var(--fb-border-width) solid var(--fb-border-color);
262
+ border-radius: var(--fb-border-radius);
263
+ background-color: ${s?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
264
+ color: var(--fb-text-color);
265
+ font-size: var(--fb-font-size);
266
+ font-family: var(--fb-font-family);
267
+ line-height: var(--fb-line-height, 1.5);
268
+ transition: all var(--fb-transition-duration) ease-in-out;
269
+ width: 100%;
270
+ box-sizing: border-box;
271
+ resize: none;
272
+ overflow: hidden;
273
+ word-break: break-word;
274
+ overflow-wrap: anywhere;
275
+ `,u.name=r,u.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",l),u.value=(a=(i=t.prefill[e.key])!=null?i:e.default)!=null?a:"",u.readOnly=s,nn(u),it(u,{observers:l.autoExpandObservers}),s||(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)")})),!s&&t.instance){const f=()=>{const m=u.value===""?null:u.value;t.instance.triggerOnChange(r,m)};u.addEventListener("blur",f),u.addEventListener("input",f)}if(d.appendChild(u),c){const f=at(e,u);d.appendChild(f)}n.appendChild(d)}function Br(e,t,n,r){var o,i;const a=t.state,l=se(e,a,t),s=t.prefill[e.key]||[],d=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(i=e.maxCount)!=null?i:1/0;for(;d.length<c;)d.push(e.default||"");qr(document);const f=document.createElement("div");f.className="fb-chip-list",n.appendChild(f);function m(){f.querySelectorAll(".fb-chip-input").forEach((h,g)=>{h.name=`${r}[${g}]`;const x=h.closest(".fb-chip"),E=x==null?void 0:x.nextElementSibling;E&&E.classList.contains("error-message")&&E.setAttribute("data-error-for",h.name)})}function p(h=""){var g;const x=document.createElement("div");x.className="fb-chip";const E=document.createElement("span");E.className="fb-chip-dot",E.setAttribute("aria-hidden","true"),x.appendChild(E);const y=document.createElement("textarea");if(y.rows=1,y.className="fb-chip-input",y.value=h,y.placeholder=(g=e.placeholder)!=null?g:k("placeholderText",a),y.readOnly=l,x.appendChild(y),!l&&t.instance){const C=()=>{t.instance.triggerOnChange(y.name,y.value===""?null:y.value)};y.addEventListener("blur",C),y.addEventListener("input",C)}if(nn(y),it(y,{observers:a.autoExpandObservers}),!l){const C=document.createElement("button");C.type="button",C.className="fb-chip-remove",C.setAttribute("aria-label",k("removeElement",a)),C.innerHTML=tn,C.onclick=()=>{var w;const R=f.querySelectorAll(".fb-chip"),G=Array.prototype.indexOf.call(R,x);if(G<0||R.length<=c)return;d.splice(G,1);const K=x.nextElementSibling;K&&K.classList.contains("error-message")&&K.remove(),x.remove(),m(),$(),b(),(w=t.instance)==null||w.triggerOnChange(r)},x.appendChild(C)}return f.appendChild(x),m(),x}function b(){if(l)return;const h=f.querySelectorAll(".fb-chip").length<=c;f.querySelectorAll(".fb-chip-remove").forEach(g=>{g.disabled=h})}let v=null;if(!l){const h=ze("text",()=>{var g;d.push(e.default||""),p(e.default||""),$(),b(),(g=t.instance)==null||g.triggerOnChange(r)},{label:e.addLabel});v=h.update,Ae(n,h.counter),n.appendChild(h.row)}function $(){v&&v(d.length,u)}d.forEach(h=>p(h)),$(),b()}function on(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n,d=(c,u,f)=>{let m=!1;const{state:p}=n;if(!s&&u){if(e.minLength!==void 0&&e.minLength!==null&&u.length<e.minLength){const b=k("minLength",p,{min:e.minLength});a.push(`${f}: ${b}`),ne(c,b),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&u.length>e.maxLength){const b=k("maxLength",p,{max:e.maxLength});a.push(`${f}: ${b}`),ne(c,b),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(u)){const b=k("patternMismatch",p);a.push(`${f}: ${b}`),ne(c,b),m=!0}}catch(b){const v=k("invalidPattern",p);a.push(`${f}: ${v}`),ne(c,v),m=!0}}m||ne(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["]`),u=[],f=[];if(c.forEach((m,p)=>{var b;const v=(b=m==null?void 0:m.value)!=null?b:"";f.push(v),u.push(v===""?null:v),d(m,v,`${t}[${p}]`)}),!s){const{state:m}=n,p=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,v=f.filter($=>$.trim()!=="");e.required&&v.length===0&&a.push(`${t}: ${k("required",m)}`),v.length<p&&a.push(`${t}: ${k("minItems",m,{min:p})}`),v.length>b&&a.push(`${t}: ${k("maxItems",m,{max:b})}`)}return{value:u,errors:a}}else{const c=l.querySelector(`[name="${t}"]`),u=(i=c==null?void 0:c.value)!=null?i:"";if(!s&&e.required&&u===""){const f=k("required",n.state);return a.push(`${t}: ${f}`),ne(c,f),{value:null,errors:a}}return c&&d(c,u,t),{value:u===""?null:u,errors:a}}}function ln(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",Ee(a),a.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==i.length&&console.warn(`updateTextField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",Ee(i),i instanceof HTMLTextAreaElement&&i.dispatchEvent(new Event("input",{bubbles:!0})))}}function Dr(e,t,n,r){var o,i,a,l;const s=t.state,d=se(e,s,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
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
277
+ font-size: var(--fb-font-size);
278
+ font-family: var(--fb-font-family);
279
+ line-height: var(--fb-line-height, 1.5);
280
+ `,u.name=r,u.placeholder=(o=e.placeholder)!=null?o:k("placeholderText",s),u.value=(a=(i=t.prefill[e.key])!=null?i:e.default)!=null?a:"",u.readOnly=d,!d&&t.instance){const f=()=>{const m=u.value===""?null:u.value;t.instance.triggerOnChange(r,m)};u.addEventListener("blur",f),u.addEventListener("input",f)}if(it(u,{minRows:(l=e.rows)!=null?l:1,observers:s.autoExpandObservers}),c.appendChild(u),!d&&(e.minLength!=null||e.maxLength!=null)){const f=at(e,u);c.appendChild(f)}n.appendChild(c)}function Or(e,t,n,r){var o,i;const a=t.state,l=se(e,a,t),s=t.prefill[e.key]||[],d=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(i=e.maxCount)!=null?i:1/0;for(;d.length<c;)d.push(e.default||"");const f=document.createElement("div");f.className="fb-row",n.appendChild(f);function m(){f.querySelectorAll(".multiple-textarea-item").forEach((h,g)=>{const x=h.querySelector("textarea");x&&(x.name=`${r}[${g}]`)})}function p(h="",g=-1){var x,E;const y=document.createElement("div");y.className="multiple-textarea-item";const C=document.createElement("div");C.style.cssText="position: relative;";const w=document.createElement("textarea");if(w.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",w.style.cssText=`
281
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
282
+ font-size: var(--fb-font-size);
283
+ font-family: var(--fb-font-family);
284
+ line-height: var(--fb-line-height, 1.5);
285
+ `,w.placeholder=(x=e.placeholder)!=null?x:k("placeholderText",a),w.value=h,w.readOnly=l,!l&&t.instance){const R=()=>{const G=w.value===""?null:w.value;t.instance.triggerOnChange(w.name,G)};w.addEventListener("blur",R),w.addEventListener("input",R)}if(it(w,{minRows:(E=e.rows)!=null?E:1,observers:a.autoExpandObservers}),C.appendChild(w),!l&&(e.minLength!=null||e.maxLength!=null)){const R=at(e,w);C.appendChild(R)}return y.appendChild(C),g===-1?f.appendChild(y):f.insertBefore(y,f.children[g]),m(),y}function b(){if(l)return;const h=f.querySelectorAll(".multiple-textarea-item"),g=h.length;h.forEach(x=>{let E=x.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 w=Array.from(f.children).indexOf(x);f.children.length>c&&(d.splice(w,1),x.remove(),m(),$(),b(),(C=t.instance)==null||C.triggerOnChange(r))},x.appendChild(E));const y=g<=c;E.disabled=y,E.style.opacity=y?"0.5":"1",E.style.pointerEvents=y?"none":"auto"})}let v=null;if(!l){const h=ze("textarea",()=>{var g;d.push(e.default||""),p(e.default||""),$(),b(),(g=t.instance)==null||g.triggerOnChange(r)},{label:e.addLabel});v=h.update,Ae(n,h.counter),n.appendChild(h.row)}function $(){v&&v(d.length,u)}d.forEach(h=>p(h)),$(),b()}function jr(e,t,n){return on(e,t,n)}function Ur(e,t,n,r){ln(e,t,n,r);const{scopeRoot:o}=r;if(e.multiple)o.querySelectorAll(`textarea[name^="${t}["]`).forEach(i=>{i.dispatchEvent(new Event("input"))});else{const i=o.querySelector(`textarea[name="${t}"]`);i&&i.dispatchEvent(new Event("input"))}}function Pr(e){const t="fb-number-stepper-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
286
+ .fb-stepper-input::-webkit-outer-spin-button,
287
+ .fb-stepper-input::-webkit-inner-spin-button {
288
+ -webkit-appearance: none;
289
+ margin: 0;
290
+ }
291
+ .fb-stepper-input { -moz-appearance: textfield; }
292
+ `,e.head.appendChild(n)}function Wr(e,t,n){var r;Pr(e.ownerDocument);const o=(r=t.step)!=null?r:1,i=t.min,a=t.max,l=document.createElement("div");l.className="fb-stepper",l.style.cssText=`
293
+ display: inline-flex;
294
+ align-items: stretch;
295
+ border: var(--fb-border-width) solid var(--fb-border-color);
296
+ border-radius: var(--fb-border-radius);
297
+ overflow: hidden;
298
+ background: var(--fb-background-color);
299
+ `;const s=(d,c)=>{const u=document.createElement("button");return u.type="button",u.textContent=d,u.tabIndex=-1,u.style.cssText=`
300
+ width: 32px;
301
+ border: none;
302
+ background: transparent;
303
+ color: var(--fb-text-color);
304
+ font-size: var(--fb-font-size);
305
+ font-family: var(--fb-font-family);
306
+ cursor: ${n?"default":"pointer"};
307
+ user-select: none;
308
+ `,n?(u.disabled=!0,u.style.opacity="0.5"):u.addEventListener("click",f=>{var m;f.preventDefault();const p=parseFloat(e.value),b=Number.isFinite(p)?p:(m=i!=null?i:t.default)!=null?m:0;let v=parseFloat((b+c*o).toPrecision(12));i!=null&&(v=Math.max(i,v)),a!=null&&(v=Math.min(a,v)),e.value=String(v),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
+ width: 56px;
310
+ border: none;
311
+ border-left: var(--fb-border-width) solid var(--fb-border-color);
312
+ border-right: var(--fb-border-width) solid var(--fb-border-color);
313
+ padding: var(--fb-input-padding-y) 0;
314
+ font-size: var(--fb-font-size);
315
+ font-family: var(--fb-font-family);
316
+ text-align: center;
317
+ background: transparent;
318
+ color: var(--fb-text-color);
319
+ -moz-appearance: textfield;
320
+ box-sizing: border-box;
321
+ `,l.appendChild(s("\u2212",-1)),l.appendChild(e),l.appendChild(s("+",1)),l}function an(e,t){const n=document.createElement("span");n.className="number-range-hint",n.style.cssText=`
322
+ position: absolute;
323
+ top: 50%;
324
+ transform: translateY(-50%);
325
+ right: 10px;
326
+ font-size: var(--fb-font-size-small);
327
+ color: var(--fb-text-secondary-color);
328
+ pointer-events: none;
329
+ background: var(--fb-background-color);
330
+ padding: 0 4px;
331
+ `;const r=e.min,o=e.max;let i="";r!=null&&o!=null?i=`${r} \u2013 ${o}`:o!=null?i=`\u2264${o}`:r!=null&&(i=`\u2265${r}`),n.textContent=i;const a=()=>{const l=t.value?parseFloat(t.value):null;if(l!=null){const s=r!=null&&l<r,d=o!=null&&l>o;n.style.color=s||d?"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 dn(e,t){t.decimals!==void 0&&e.setAttribute("data-decimals",String(t.decimals))}function Vr(e,t,n,r){var o,i,a;const l=t.state,s=se(e,l,t),d=document.createElement("div");d.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),dn(c,e),c.value=(a=(i=t.prefill[e.key])!=null?i:e.default)!=null?a:"",c.readOnly=s,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
+ padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
333
+ font-size: var(--fb-font-size);
334
+ font-family: var(--fb-font-family);
335
+ width: 100%;
336
+ box-sizing: border-box;
337
+ `),!s&&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)d.appendChild(Wr(c,e,s));else if(d.appendChild(c),!s&&(e.min!=null||e.max!=null)){const u=an(e,c);d.appendChild(u)}n.appendChild(d)}function Kr(e,t,n,r){var o,i,a;const l=t.state,s=se(e,l,t),d=t.prefill[e.key]||[],c=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function p(){m.querySelectorAll(".multiple-number-item").forEach((g,x)=>{const E=g.querySelector("input");E&&(E.name=`${r}[${x}]`)})}function b(g="",x=-1){var E;const y=document.createElement("div");y.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=`
338
+ padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
339
+ font-size: var(--fb-font-size);
340
+ font-family: var(--fb-font-family);
341
+ width: 100%;
342
+ box-sizing: border-box;
343
+ `,w.placeholder=(E=e.placeholder)!=null?E:"0",e.min!==void 0&&(w.min=e.min.toString()),e.max!==void 0&&(w.max=e.max.toString()),w.step=sn(e),dn(w,e),w.value=g.toString(),w.readOnly=s,!s&&t.instance){const R=()=>{const G=w.value?parseFloat(w.value):null;t.instance.triggerOnChange(w.name,G)};w.addEventListener("blur",R),w.addEventListener("input",R)}if(C.appendChild(w),!s&&(e.min!=null||e.max!=null)){const R=an(e,w);C.appendChild(R)}return y.appendChild(C),x===-1?m.appendChild(y):m.insertBefore(y,m.children[x]),p(),y}function v(){if(s)return;const g=m.querySelectorAll(".multiple-number-item"),x=g.length;g.forEach(E=>{let y=E.querySelector(".remove-item-btn");y||(y=document.createElement("button"),y.type="button",y.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",y.innerHTML="\u2715",y.onclick=()=>{var w;const R=Array.from(m.children).indexOf(E);m.children.length>u&&(c.splice(R,1),E.remove(),p(),h(),v(),(w=t.instance)==null||w.triggerOnChange(r))},E.appendChild(y));const C=x<=u;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"})}let $=null;if(!s){const g=ze("number",()=>{var x,E,y;c.push((x=e.default)!=null?x:""),b((E=e.default)!=null?E:""),h(),v(),(y=t.instance)==null||y.triggerOnChange(r)},{label:e.addLabel});$=g.update,Ae(n,g.counter),n.appendChild(g.row)}function h(){$&&$(c.length,f)}c.forEach(g=>b(g)),h(),v()}function _r(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n,d=(c,u,f)=>{let m=!1;const{state:p}=n;if(!s&&e.min!==void 0&&e.min!==null&&u<e.min){const b=k("minValue",p,{min:e.min});a.push(`${f}: ${b}`),ne(c,b),m=!0}else if(!s&&e.max!==void 0&&e.max!==null&&u>e.max){const b=k("maxValue",p,{max:e.max});a.push(`${f}: ${b}`),ne(c,b),m=!0}m||ne(c,null)};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["]`),u=[];if(c.forEach((f,m)=>{var p;const b=(p=f==null?void 0:f.value)!=null?p:"";if(b===""){u.push(null),ne(f,null);return}const v=parseFloat(b);if(!s&&!Number.isFinite(v)){const $=k("notANumber",n.state);a.push(`${t}[${m}]: ${$}`),ne(f,$),u.push(null);return}d(f,v,`${t}[${m}]`),u.push(un(v,e.decimals))}),!s){const{state:f}=n,m=(r=e.minCount)!=null?r:0,p=(o=e.maxCount)!=null?o:1/0,b=u.filter(v=>v!==null);e.required&&b.length===0&&a.push(`${t}: ${k("required",f)}`),b.length<m&&a.push(`${t}: ${k("minItems",f,{min:m})}`),b.length>p&&a.push(`${t}: ${k("maxItems",f,{max:p})}`)}return{value:u,errors:a}}else{const c=l.querySelector(`[name="${t}"]`),u=(i=c==null?void 0:c.value)!=null?i:"",{state:f}=n;if(!s&&e.required&&u===""){const p=k("required",f);return a.push(`${t}: ${p}`),ne(c,p),{value:null,errors:a}}if(u==="")return ne(c,null),{value:null,errors:a};const m=parseFloat(u);if(!s&&!Number.isFinite(m)){const p=k("notANumber",f);return a.push(`${t}: ${p}`),ne(c,p),{value:null,errors:a}}return d(c,m,t),{value:un(m,e.decimals),errors:a}}}function un(e,t){return!Number.isInteger(t)||t<0?e:Number(e.toFixed(t))}function Jr(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{l<n.length&&(a.value=n[l]!=null?String(n[l]):"",a.classList.remove("invalid"),a.title="",Ee(a))}),n.length!==i.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);i&&(i.value=n!=null?String(n):"",i.classList.remove("invalid"),i.title="",Ee(i))}}function cn(e,t,n,r){var o;const i=t.options||[];if(!i.some(s=>s.value==="")){const s=document.createElement("option");s.value="",s.textContent=(o=t.placeholder)!=null?o:k("selectPlaceholder",r),e.appendChild(s)}const a=n==null?null:String(n);let l=!1;if(i.forEach(s=>{const d=document.createElement("option");d.value=s.value,d.textContent=s.label,a===s.value&&(d.selected=!0,l=!0),e.appendChild(d)}),!l&&a!==null&&a!==""&&console.warn(`select "${t.key}": prefill value "${a}" is not among the options; leaving the field unselected`),!l){const s=Array.from(e.options).find(d=>d.value==="");s&&(s.selected=!0)}}function Xr(e,t,n,r){var o;const i=t.state,a=se(e,i,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=`
344
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
345
+ font-size: var(--fb-font-size);
346
+ font-family: var(--fb-font-family);
347
+ `,l.name=r,l.disabled=a,cn(l,e,(o=t.prefill[e.key])!=null?o:e.default,i),!a&&t.instance){const s=()=>{t.instance.triggerOnChange(r,l.value===""?null:l.value)};l.addEventListener("change",s)}if(n.appendChild(l),!a){const s=document.createElement("p");s.className="text-xs text-gray-500 mt-1",s.textContent=Te(e,i),n.appendChild(s)}}function Yr(e,t,n,r){var o,i,a;const l=t.state,s=se(e,l,t),d=t.prefill[e.key]||[],c=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function p(){m.querySelectorAll(".multiple-select-item").forEach((g,x)=>{const E=g.querySelector("select");E&&(E.name=`${r}[${x}]`)})}function b(g="",x=-1){const E=document.createElement("div");E.className="multiple-select-item flex items-center gap-2";const y=document.createElement("select");if(y.className="flex-1 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",y.style.cssText=`
348
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
349
+ font-size: var(--fb-font-size);
350
+ font-family: var(--fb-font-family);
351
+ `,y.disabled=s,cn(y,e,g,l),!s&&t.instance){const C=()=>{t.instance.triggerOnChange(y.name,y.value)};y.addEventListener("change",C)}return E.appendChild(y),x===-1?m.appendChild(E):m.insertBefore(E,m.children[x]),p(),E}function v(){if(s)return;const g=m.querySelectorAll(".multiple-select-item"),x=g.length;g.forEach(E=>{let y=E.querySelector(".remove-item-btn");y||(y=document.createElement("button"),y.type="button",y.className="remove-item-btn px-2 py-1 text-red-600 hover:bg-red-50 rounded",y.innerHTML="\u2715",y.onclick=()=>{var w;const R=Array.from(m.children).indexOf(E);m.children.length>u&&(c.splice(R,1),E.remove(),p(),h(),v(),(w=t.instance)==null||w.triggerOnChange(r))},E.appendChild(y));const C=x<=u;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"})}let $=null;if(!s){const g=ze("select",()=>{var x,E;const y=(x=e.default)!=null?x:"";c.push(y),b(y),h(),v(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});$=g.update,Ae(n,g.counter),n.appendChild(g.row)}function h(){$&&$(c.length,f)}if(c.forEach(g=>b(g)),h(),v(),!s){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Te(e,l),n.appendChild(g)}}function Gr(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(s,d,c,u)=>{var f,m;if(a)return;const{state:p}=n,b=d.filter(u),v="minCount"in c&&(f=c.minCount)!=null?f:0,$="maxCount"in c&&(m=c.maxCount)!=null?m:1/0;c.required&&b.length===0&&o.push(`${s}: ${k("required",p)}`),b.length<v&&o.push(`${s}: ${k("minItems",p,{min:v})}`),b.length>$&&o.push(`${s}: ${k("maxItems",p,{max:$})}`)};if("multiple"in e&&e.multiple){const s=i.querySelectorAll(`[name^="${t}\\["]`),d=[];return s.forEach(c=>{var u;const f=(u=c==null?void 0:c.value)!=null?u:"";d.push(f===""?null:f),ne(c,null)}),l(t,d,e,c=>c!=null),{value:d,errors:o}}else{const s=i.querySelector(`[name="${t}"]`),d=(r=s==null?void 0:s.value)!=null?r:"";if(!a&&e.required&&d===""){const c=k("required",n.state);return o.push(`${t}: ${c}`),ne(s,c),{value:null,errors:o}}else ne(s,null);return{value:d===""?null:d,errors:o}}}function fn(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 Zr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["]`);i.forEach((a,l)=>{if(l<n.length){const s=n[l]!=null?String(n[l]):"";fn(a,s,`${t}[${l}]`)}}),i.forEach((a,l)=>{if(l<n.length){const s=n[l]!=null?String(n[l]):"";a.value=s,a.querySelectorAll("option").forEach(d=>{d.selected=d.value===s}),a.classList.remove("invalid"),a.title="",Ee(a)}}),n.length!==i.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${i.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"]`);if(i){const a=n!=null?String(n):"";fn(i,a,t),i.value=a,i.querySelectorAll("option").forEach(l=>{l.selected=l.value===a}),i.classList.remove("invalid"),i.title="",Ee(i)}}}function st(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 dt(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 pn(e){return e.classList.contains("fb-switcher-preset")}function Qr(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=`
352
+ display: inline-flex;
353
+ align-items: center;
354
+ gap: 8px;
355
+ padding: 7px 12px 7px 10px;
356
+ border-width: var(--fb-border-width);
357
+ border-style: solid;
358
+ border-radius: 999px;
359
+ background: var(--fb-background-color);
360
+ font-size: var(--fb-font-size);
361
+ font-family: var(--fb-font-family);
362
+ line-height: 1.25;
363
+ cursor: ${t?"default":"pointer"};
364
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
365
+ outline: none;
366
+ `,e.iconUrl){const o=document.createElement("img");o.className="fb-switcher-icon",o.src=e.iconUrl,o.alt="",o.setAttribute("aria-hidden","true"),o.style.cssText=`
367
+ display: block;
368
+ flex: 0 0 auto;
369
+ width: 20px;
370
+ height: 20px;
371
+ object-fit: contain;
372
+ `,n.appendChild(o)}const r=document.createElement("span");if(r.className="fb-switcher-name",r.textContent=e.label,r.style.cssText="font-weight: 600;",n.appendChild(r),e.subtitle){const o=document.createElement("span");o.className="fb-switcher-subtitle",o.textContent=e.subtitle,o.style.cssText=`
373
+ font-size: var(--fb-font-size-small);
374
+ opacity: 0.7;
375
+ font-variant-numeric: tabular-nums;
376
+ `,n.appendChild(o)}return n}function mn(e,t,n,r,o){const i=e.options||[],a=i.some(d=>d.subtitle||d.iconUrl),l=document.createElement("div");l.className="fb-switcher-group",l.style.cssText=a?`
377
+ display: flex;
378
+ flex-direction: row;
379
+ flex-wrap: wrap;
380
+ gap: 6px;
381
+ `:`
382
+ display: inline-flex;
383
+ flex-direction: row;
384
+ flex-wrap: nowrap;
385
+ `;const s=[];return i.forEach((d,c)=>{let u;a?u=Qr(d,r):(u=document.createElement("button"),u.type="button",u.className="fb-switcher-btn",u.dataset.value=d.value,u.textContent=d.label,u.style.cssText=`
386
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
387
+ font-size: var(--fb-font-size);
388
+ border-width: var(--fb-border-width);
389
+ border-style: solid;
390
+ cursor: ${r?"default":"pointer"};
391
+ transition: background-color var(--fb-transition-duration), color var(--fb-transition-duration), border-color var(--fb-transition-duration);
392
+ white-space: nowrap;
393
+ line-height: 1.25;
394
+ outline: none;
395
+ `,i.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===i.length-1?u.style.borderRadius="0 var(--fb-border-radius) var(--fb-border-radius) 0":(u.style.borderRadius="0",u.style.borderRightWidth="0")),d.value===t?st(u,a):dt(u,a),r||(u.addEventListener("click",()=>{n.value=d.value,s.forEach(f=>{f.dataset.value===d.value?st(f,a):dt(f,a)}),o&&o(d.value)}),u.addEventListener("mouseenter",()=>{n.value!==d.value&&(u.style.backgroundColor="var(--fb-background-hover-color)")}),u.addEventListener("mouseleave",()=>{n.value!==d.value&&(u.style.backgroundColor=a?"var(--fb-background-color)":"transparent")})),s.push(u),l.appendChild(u)}),l}function eo(e,t,n,r){var o,i;const a=t.state,l=String((i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:""),s=document.createElement("input");s.type="hidden",s.name=r,s.value=l;const d=se(e,a,t),c=!d&&t.instance?f=>{t.instance.triggerOnChange(r,f)}:null,u=mn(e,l,s,d,c);if(n.appendChild(s),n.appendChild(u),!d){const f=document.createElement("p");f.className="text-xs text-gray-500 mt-1",f.textContent=Te(e,a),n.appendChild(f)}}function to(e,t,n,r){var o,i,a;const l=t.state,s=t.prefill[e.key]||[],d=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(i=e.maxCount)!=null?i:1/0;for(;d.length<c;)d.push((a=e.default)!=null?a:"");const f=se(e,l,t),m=document.createElement("div");m.className="fb-row",n.appendChild(m);function p(){m.querySelectorAll(".multiple-switcher-item").forEach((g,x)=>{const E=g.querySelector("input[type=hidden]");E&&(E.name=`${r}[${x}]`)})}function b(g="",x=-1){const E=x===-1?m.children.length:x,y=`${r}[${E}]`,C=document.createElement("div");C.className="multiple-switcher-item flex items-center gap-2";const w=document.createElement("input");w.type="hidden",w.name=y,w.value=g,C.appendChild(w);const R=!f&&t.instance?K=>{t.instance.triggerOnChange(w.name,K)}:null,G=mn(e,g,w,f,R);return C.appendChild(G),x===-1?m.appendChild(C):m.insertBefore(C,m.children[x]),p(),C}function v(){if(f)return;const g=m.querySelectorAll(".multiple-switcher-item"),x=g.length;g.forEach(E=>{let y=E.querySelector(".remove-item-btn");y||(y=document.createElement("button"),y.type="button",y.className="remove-item-btn px-2 py-1 rounded",y.style.cssText=`
396
+ color: var(--fb-error-color);
397
+ background-color: transparent;
398
+ transition: background-color var(--fb-transition-duration);
399
+ `,y.innerHTML="\u2715",y.addEventListener("mouseenter",()=>{y.style.backgroundColor="var(--fb-background-hover-color)"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="transparent"}),y.onclick=()=>{var w;const R=Array.from(m.children).indexOf(E);m.children.length>c&&(d.splice(R,1),E.remove(),p(),h(),v(),(w=t.instance)==null||w.triggerOnChange(r))},E.appendChild(y));const C=x<=c;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"})}let $=null;if(!f){const g=ze("switcher",()=>{var x,E;const y=(x=e.default)!=null?x:"";d.push(y),b(y),h(),v(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});$=g.update,Ae(n,g.counter),n.appendChild(g.row)}function h(){$&&$(d.length,u)}if(d.forEach(g=>b(g)),h(),v(),!f){const g=document.createElement("p");g.className="text-xs text-gray-500 mt-1",g.textContent=Te(e,l),n.appendChild(g)}}function no(e,t,n){var r;const o=[],{scopeRoot:i,skipValidation:a}=n,l=(d,c,u,f)=>{var m,p;if(a)return;const{state:b}=n,v=c.filter(f),$="minCount"in u&&(m=u.minCount)!=null?m:0,h="maxCount"in u&&(p=u.maxCount)!=null?p:1/0;u.required&&v.length===0&&o.push(`${d}: ${k("required",b)}`),v.length<$&&o.push(`${d}: ${k("minItems",b,{min:$})}`),v.length>h&&o.push(`${d}: ${k("maxItems",b,{max:h})}`)},s=new Set("options"in e?e.options.map(d=>d.value):[]);if("multiple"in e&&e.multiple){const d=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),c=[];return d.forEach(u=>{var f;const m=(f=u==null?void 0:u.value)!=null?f:"";if(c.push(m===""?null:m),!a&&m!==""&&!s.has(m)){const p=k("invalidOption",n.state);ne(u,p),o.push(`${t}: ${p}`)}else ne(u,null)}),l(t,c,e,u=>u!=null),{value:c,errors:o}}else{const d=i.querySelector(`input[type="hidden"][name="${t}"]`),c=(r=d==null?void 0:d.value)!=null?r:"";if(!a&&e.required&&c===""){const u=k("required",n.state);return o.push(`${t}: ${u}`),ne(d,u),{value:null,errors:o}}if(!a&&c!==""&&!s.has(c)){const u=k("invalidOption",n.state);return o.push(`${t}: ${u}`),ne(d,u),{value:null,errors:o}}return ne(d,null),{value:c===""?null:c,errors:o}}}function ro(e,t,n,r){var o;const{scopeRoot:i}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=i.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);a.forEach((l,s)=>{var d;if(s<n.length){const c=n[s]!=null?String(n[s]):"";l.value=c;const u=(d=l.parentElement)==null?void 0:d.querySelector(".fb-switcher-group");u&&u.querySelectorAll(".fb-switcher-btn").forEach(f=>{const m=pn(f);f.dataset.value===c?st(f,m):dt(f,m)}),l.classList.remove("invalid"),l.title="",Ee(l)}}),n.length!==a.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(a){const l=n!=null?String(n):"";a.value=l;const s=(o=a.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");s&&s.querySelectorAll(".fb-switcher-btn").forEach(d=>{const c=pn(d);d.dataset.value===l?st(d,c):dt(d,c)}),a.classList.remove("invalid"),a.title="",Ee(a)}}}const hn=36,Ye=20,Ue=16;function oo(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
400
+ .fb-toggle {
401
+ position: relative;
402
+ display: inline-block;
403
+ width: ${hn}px;
404
+ height: ${Ye}px;
405
+ border-radius: ${Ye}px;
406
+ background: var(--fb-border-color);
407
+ transition: background-color var(--fb-transition-duration);
408
+ flex-shrink: 0;
409
+ }
410
+ .fb-toggle::after {
411
+ content: "";
412
+ position: absolute;
413
+ top: ${(Ye-Ue)/2}px;
414
+ left: ${(Ye-Ue)/2}px;
415
+ width: ${Ue}px;
416
+ height: ${Ue}px;
417
+ border-radius: 50%;
418
+ background: #ffffff;
419
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
420
+ transition: transform var(--fb-transition-duration);
421
+ }
422
+ .fb-toggle.fb-on {
423
+ background: var(--fb-primary-color);
424
+ }
425
+ .fb-toggle.fb-on::after {
426
+ transform: translateX(${hn-Ue-(Ye-Ue)}px);
427
+ }
428
+ .fb-toggle-row {
429
+ display: flex;
430
+ align-items: center;
431
+ gap: 12px;
432
+ padding: 12px 14px;
433
+ background: var(--fb-surface-soft-color);
434
+ border: var(--fb-border-width) solid var(--fb-border-color);
435
+ border-radius: var(--fb-border-radius);
436
+ cursor: pointer;
437
+ user-select: none;
438
+ }
439
+ .fb-toggle-row[aria-disabled="true"] {
440
+ cursor: default;
441
+ opacity: 0.7;
442
+ }
443
+ .fb-toggle-row:focus-visible {
444
+ outline: var(--fb-focus-ring-width) solid var(--fb-focus-ring-color);
445
+ outline-offset: var(--fb-focus-ring-offset);
446
+ }
447
+ .fb-toggle-text { flex: 1; min-width: 0; }
448
+ .fb-toggle-title {
449
+ display: flex;
450
+ align-items: center;
451
+ gap: 4px;
452
+ font-size: var(--fb-font-size);
453
+ font-weight: 500;
454
+ color: var(--fb-text-color);
455
+ line-height: 1.3;
456
+ }
457
+ .fb-toggle-subtitle {
458
+ font-size: var(--fb-font-size-small);
459
+ color: var(--fb-text-secondary-color);
460
+ margin-top: 2px;
461
+ line-height: 1.35;
462
+ }
463
+ .fb-toggle-info {
464
+ flex: 0 0 14px;
465
+ display: inline-flex;
466
+ align-items: center;
467
+ justify-content: center;
468
+ width: 14px;
469
+ height: 14px;
470
+ border-radius: 50%;
471
+ background: var(--fb-border-color);
472
+ color: #fff;
473
+ font-size: 10px;
474
+ font-weight: 700;
475
+ font-style: italic;
476
+ font-family: serif;
477
+ cursor: help;
478
+ }
479
+ `,e.head.appendChild(n)}function St(e){return typeof e=="boolean"?e:typeof e=="string"?e==="true"||e==="on"||e==="1":!1}function lo(e,t,n,r){var o;oo(document);const i=t.state,a=se(e,i,t),l=t.prefill[e.key],s=St(l!==void 0?l:e.default),d=document.createElement("input");d.type="hidden",d.name=r,d.setAttribute("data-boolean-field","true"),d.value=s?"true":"false";const c=document.createElement("div");c.className="fb-toggle-row",c.setAttribute("role","switch"),c.setAttribute("aria-checked",s?"true":"false"),a?c.setAttribute("aria-disabled","true"):c.tabIndex=0;const u=document.createElement("span");u.className="fb-toggle"+(s?" fb-on":""),u.setAttribute("aria-hidden","true"),c.appendChild(u);const f=document.createElement("div");f.className="fb-toggle-text";const m=document.createElement("div");if(m.className="fb-toggle-title",m.appendChild(document.createTextNode((o=e.label)!=null?o:"")),e.description){const p=document.createElement("span");p.className="fb-toggle-info",p.textContent="i",p.title=e.description,m.appendChild(p)}if(f.appendChild(m),e.hint){const p=document.createElement("div");p.className="fb-toggle-subtitle",p.textContent=e.hint,f.appendChild(p)}if(c.appendChild(f),!a){const p=()=>{const b=d.value!=="true";d.value=b?"true":"false",u.classList.toggle("fb-on",b),c.setAttribute("aria-checked",b?"true":"false"),t.instance&&t.instance.triggerOnChange(r,b)};c.addEventListener("click",b=>{var v;(v=b.target)!=null&&v.classList.contains("fb-toggle-info")||p()}),c.addEventListener("keydown",b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),p())})}n.appendChild(d),n.appendChild(c)}function io(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][name="${t}"]`),a=(r=i==null?void 0:i.value)!=null?r:"";return{value:St(a),errors:[]}}function ao(e,t,n,r){var o;const{scopeRoot:i}=r,a=i.querySelector(`input[type="hidden"][name="${t}"]`);if(!a)return;const l=St(n);a.value=l?"true":"false";const s=(o=a.parentElement)==null?void 0:o.querySelector(".fb-toggle-row");if(s){s.setAttribute("aria-checked",l?"true":"false");const d=s.querySelector(".fb-toggle");d&&d.classList.toggle("fb-on",l)}}function Ne(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 Pe(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 bn(e,t){return t===1/0?!0:e<=t*1024*1024}function ut(e,t){return bn(e.size,t)}function Ge(e){return e?typeof e=="string"?[]:Array.isArray(e.mime)?e.mime.map(t=>t.toLowerCase()):[]:[]}function Ze(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 so(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:so(e),size:0,uploadedAt:new Date,file:void 0,inferredFromExtension:!0})}function Lt(e,t){for(const n of e)ct(n,t)}const gn="fb-file-styles";function Se(){if(typeof document=="undefined"||document.getElementById(gn))return;const e=document.createElement("style");if(e.id=gn,e.setAttribute("data-fb-file-styles","true"),e.textContent=`
480
+ @keyframes fb-spin { to { transform: rotate(360deg); } }
481
+
482
+ /* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
483
+ /* Neutral diagonal-stripe background for image previews (never crops) */
484
+ .fb-checker {
485
+ background-image: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
486
+ }
487
+
488
+ /* \u2500\u2500\u2500 Spinner \u2500\u2500\u2500 */
489
+ .fb-spinner {
490
+ width: 36px;
491
+ height: 36px;
492
+ border: 3px solid rgba(0,0,0,0.12);
493
+ border-top-color: var(--fb-text-secondary-color, #6b7280);
494
+ border-radius: 50%;
495
+ animation: fb-spin 0.7s linear infinite;
496
+ flex-shrink: 0;
497
+ }
498
+
499
+ /* \u2500\u2500\u2500 Wide single-file add tile (empty state) \u2500\u2500\u2500 */
500
+ /* Flex-wraps: side-by-side when wide enough, stacks upload/library
501
+ vertically when narrow (e.g. inside a 50/50 container column). */
502
+ .fb-wide-tile {
503
+ width: 100%;
504
+ box-sizing: border-box;
505
+ border-radius: 0.75rem;
506
+ border: 1px dashed #60a5fa;
507
+ background: rgba(239,246,255,0.5);
508
+ display: flex;
509
+ flex-wrap: wrap;
510
+ align-items: stretch;
511
+ gap: 0;
512
+ overflow: hidden;
513
+ /* min-height driven by --fb-file-wide-min so size-tokens (.fb-size-{xs|sm|lg|xl})
514
+ can override per-field. Default 96px matches v0.4.0 compact density. */
515
+ min-height: var(--fb-file-wide-min, 96px);
516
+ transition: border-color 150ms, background 150ms, box-shadow 150ms;
517
+ cursor: pointer;
518
+ }
519
+ .fb-wide-tile:hover {
520
+ background: #eff6ff;
521
+ }
522
+ .fb-wide-tile.fb-drag-over {
523
+ border-color: #3b82f6;
524
+ border-width: 2px;
525
+ background: #eff6ff;
526
+ box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
527
+ }
528
+
529
+ /* Upload zone inside wide tile.
530
+ flex: 1 1 220px \u2014 wants at least 220px; if the container can't fit
531
+ upload + library on one row (~220 + 176), library wraps below. */
532
+ .fb-wide-tile-upload {
533
+ flex: 1 1 220px;
534
+ /* min-height theme-driven; default 72px matches v0.4.0 compact density. */
535
+ min-height: var(--fb-file-zone-min, 72px);
536
+ display: flex;
537
+ flex-direction: column;
538
+ align-items: center;
539
+ justify-content: center;
540
+ gap: 4px;
541
+ color: #2563eb;
542
+ padding: var(--fb-file-zone-padding, 8px);
543
+ transition: background 150ms;
544
+ cursor: pointer;
545
+ background: transparent;
546
+ border: none;
547
+ font-family: inherit;
548
+ /* Dashed separator from library: right side when in a row, bottom when
549
+ wrapped (the line then sits between the two stacked cards). */
550
+ border-right: 1px dashed rgba(96,165,250,0.5);
551
+ }
552
+ .fb-wide-tile-upload:hover {
553
+ background: rgba(191,219,254,0.25);
554
+ }
555
+ /* Library zone inside wide tile.
556
+ flex: 0 0 176px \u2014 fixed 176px, never grows. Upload fills the rest in
557
+ row layout. When the tile wraps to two rows on narrow containers,
558
+ library stays 176px wide on its own row (left-aligned), preserving the
559
+ visual hierarchy "upload > library" in both layouts. */
560
+ .fb-wide-tile-library {
561
+ flex: 0 0 176px;
562
+ /* Shares --fb-file-zone-min with the upload zone so size-tokens scale both
563
+ uniformly. Default 72px matches v0.4.0 compact density. */
564
+ min-height: var(--fb-file-zone-min, 72px);
565
+ display: flex;
566
+ flex-direction: column;
567
+ align-items: center;
568
+ justify-content: center;
569
+ gap: 4px;
570
+ color: #2563eb;
571
+ padding: var(--fb-file-zone-padding, 8px);
572
+ transition: background 150ms;
573
+ cursor: pointer;
574
+ background: transparent;
575
+ border: none;
576
+ font-family: inherit;
577
+ }
578
+ .fb-wide-tile-library:hover {
579
+ background: rgba(191,219,254,0.25);
580
+ }
581
+ /* Narrow-tile mode lives in a separate <style> tag (see below) \u2014 the
582
+ @container rule is appended only when the runtime actually supports
583
+ container queries, so jsdom (which doesn't) never sees it and stays
584
+ quiet in test logs. */
585
+
586
+ /* \u2500\u2500\u2500 Multi-file outer grid container \u2500\u2500\u2500 */
587
+ .fb-multi-outer {
588
+ border-radius: 0.75rem;
589
+ border: 1px dashed #cbd5e1;
590
+ background: rgba(248,250,252,0.4);
591
+ padding: 12px;
592
+ transition: border-color 150ms, background 150ms, box-shadow 150ms;
593
+ }
594
+ .fb-multi-outer.fb-drag-over {
595
+ border-width: 2px;
596
+ border-color: #3b82f6;
597
+ background: rgba(239,246,255,0.4);
598
+ box-shadow: 0 0 0 4px rgba(191,219,254,0.7);
599
+ }
600
+
601
+ /* With files present: white solid border */
602
+ .fb-multi-outer.fb-multi-has-files {
603
+ border-style: solid;
604
+ border-color: #e2e8f0;
605
+ background: #fff;
606
+ }
607
+
608
+ /* The CSS grid inside */
609
+ .fb-multi-grid {
610
+ display: grid;
611
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
612
+ gap: 10px;
613
+ }
614
+
615
+ /* \u2500\u2500\u2500 Multi square add-tile (combined upload + library) \u2500\u2500\u2500 */
616
+ .fb-multi-add-tile {
617
+ aspect-ratio: 1 / 1;
618
+ border-radius: 0.5rem;
619
+ border: 1px dashed #60a5fa;
620
+ background: rgba(239,246,255,0.5);
621
+ display: flex;
622
+ flex-direction: column;
623
+ overflow: hidden;
624
+ transition: background 150ms;
625
+ }
626
+ .fb-multi-add-tile:hover {
627
+ background: #eff6ff;
628
+ }
629
+ .fb-multi-add-tile.fb-drag-over-tile {
630
+ border-width: 2px;
631
+ border-color: #3b82f6;
632
+ background: rgba(255,255,255,0.8);
633
+ }
634
+
635
+ /* Upload half of add-tile */
636
+ .fb-multi-add-upload {
637
+ flex: 1;
638
+ display: flex;
639
+ flex-direction: column;
640
+ align-items: center;
641
+ justify-content: center;
642
+ gap: 4px;
643
+ color: #2563eb;
644
+ cursor: pointer;
645
+ background: transparent;
646
+ border: none;
647
+ font-family: inherit;
648
+ width: 100%;
649
+ transition: background 150ms;
650
+ }
651
+ .fb-multi-add-upload:hover {
652
+ background: rgba(191,219,254,0.35);
653
+ }
654
+
655
+ /* Horizontal dashed divider inside add-tile */
656
+ .fb-multi-add-divider {
657
+ border-top: 1px dashed rgba(96,165,250,0.5);
658
+ margin: 0;
659
+ flex-shrink: 0;
660
+ }
661
+
662
+ /* Library strip at bottom of add-tile */
663
+ .fb-multi-add-library {
664
+ padding: 6px 0;
665
+ display: flex;
666
+ align-items: center;
667
+ justify-content: center;
668
+ gap: 4px;
669
+ color: #2563eb;
670
+ font-size: 11px;
671
+ font-weight: 500;
672
+ cursor: pointer;
673
+ background: transparent;
674
+ border: none;
675
+ font-family: inherit;
676
+ width: 100%;
677
+ transition: background 150ms;
678
+ flex-shrink: 0;
679
+ }
680
+ .fb-multi-add-library:hover {
681
+ background: rgba(191,219,254,0.35);
682
+ }
683
+
684
+ /* \u2500\u2500\u2500 Capacity placeholder squares \u2500\u2500\u2500 */
685
+ .fb-multi-placeholder {
686
+ aspect-ratio: 1 / 1;
687
+ border-radius: 0.5rem;
688
+ border: 1px solid #e2e8f0;
689
+ }
690
+ .fb-multi-placeholder.fb-drag-over {
691
+ border-width: 2px;
692
+ border-style: dashed;
693
+ border-color: #93c5fd;
694
+ background: rgba(219,234,254,0.6);
695
+ }
696
+
697
+ /* \u2500\u2500\u2500 Filled preview tile \u2500\u2500\u2500 */
698
+ .fb-preview-tile {
699
+ aspect-ratio: 1 / 1;
700
+ border-radius: 0.5rem;
701
+ border: 1px solid #e2e8f0;
702
+ overflow: hidden;
703
+ position: relative;
704
+ cursor: pointer;
705
+ }
706
+ .fb-preview-tile img {
707
+ width: 100%;
708
+ height: 100%;
709
+ object-fit: contain;
710
+ display: block;
711
+ }
712
+
713
+ /* \u2500\u2500\u2500 Uploading placeholder tile \u2500\u2500\u2500 */
714
+ .fb-uploading-tile {
715
+ aspect-ratio: 1 / 1;
716
+ border-radius: 0.5rem;
717
+ border: 2px dashed #d1d5db;
718
+ display: flex;
719
+ flex-direction: column;
720
+ align-items: center;
721
+ justify-content: center;
722
+ gap: 6px;
723
+ padding: 6px;
724
+ }
725
+
726
+ /* \u2500\u2500\u2500 Clear-all row below multi grid \u2500\u2500\u2500 */
727
+ .fb-clear-all-row {
728
+ margin-top: 10px;
729
+ display: flex;
730
+ align-items: center;
731
+ justify-content: flex-end;
732
+ }
733
+ .fb-clear-all-btn {
734
+ font-size: 12px;
735
+ color: #94a3b8;
736
+ background: none;
737
+ border: none;
738
+ cursor: pointer;
739
+ padding: 0;
740
+ font-family: inherit;
741
+ transition: color 150ms;
742
+ white-space: nowrap;
743
+ flex-shrink: 0;
744
+ }
745
+ .fb-clear-all-btn:hover {
746
+ color: #dc2626;
747
+ }
748
+
749
+ /* \u2500\u2500\u2500 Empty text (readonly) \u2500\u2500\u2500 */
750
+ .fb-tile-empty-text {
751
+ font-size: 11px;
752
+ color: var(--fb-text-secondary-color, #6b7280);
753
+ padding: 4px 0;
754
+ }
755
+
756
+ /* \u2500\u2500\u2500 Tile action buttons (for zoom popup, compat) \u2500\u2500\u2500 */
757
+ .fb-tile-actions {
758
+ position: absolute;
759
+ top: 3px;
760
+ right: 3px;
761
+ display: flex;
762
+ flex-direction: row;
763
+ gap: 3px;
764
+ opacity: 0;
765
+ transition: opacity var(--fb-transition-duration, 200ms);
766
+ z-index: 10;
767
+ }
768
+ .fb-preview-tile:hover .fb-tile-actions {
769
+ opacity: 1;
770
+ }
771
+ .fb-tile-action-btn {
772
+ width: 24px;
773
+ height: 24px;
774
+ display: flex;
775
+ align-items: center;
776
+ justify-content: center;
777
+ border: 1px solid rgba(15,23,42,0.08);
778
+ border-radius: 0.375rem;
779
+ cursor: pointer;
780
+ background: rgba(255,255,255,0.92);
781
+ color: #374151;
782
+ padding: 0;
783
+ flex-shrink: 0;
784
+ box-shadow: 0 1px 2px rgba(0,0,0,0.06);
785
+ transition: background var(--fb-transition-duration, 200ms),
786
+ color var(--fb-transition-duration, 200ms);
787
+ }
788
+ .fb-tile-action-btn:hover {
789
+ background: #ffffff;
790
+ color: #0f172a;
791
+ }
792
+ .fb-tile-action-remove:hover {
793
+ color: #dc2626;
794
+ }
795
+
796
+ /* Zoom popup action buttons always visible */
797
+ .fb-tile-zoom-preview .fb-tile-actions {
798
+ position: absolute;
799
+ top: 6px;
800
+ right: 6px;
801
+ opacity: 1;
802
+ z-index: 10000;
803
+ }
804
+
805
+ /* \u2500\u2500\u2500 Hover zoom preview popup \u2500\u2500\u2500 */
806
+ .fb-tile-zoom-preview {
807
+ position: fixed;
808
+ z-index: 9999;
809
+ background: var(--fb-background-color, #fff);
810
+ border: 1px solid #e2e8f0;
811
+ border-radius: 0.5rem;
812
+ box-shadow: 0 4px 16px rgba(0,0,0,0.18);
813
+ padding: 4px;
814
+ width: 350px;
815
+ height: 350px;
816
+ pointer-events: none;
817
+ opacity: 0;
818
+ transition: opacity 150ms ease;
819
+ }
820
+ .fb-tile-zoom-preview.fb-tile-zoom-preview--visible {
821
+ opacity: 1;
822
+ }
823
+ .fb-tile-zoom-preview-img {
824
+ width: 100%;
825
+ height: 100%;
826
+ object-fit: contain;
827
+ display: block;
828
+ border-radius: calc(0.5rem - 2px);
829
+ }
830
+
831
+ /* \u2500\u2500\u2500 Single-file uploading state \u2500\u2500\u2500 */
832
+ .fb-single-uploading {
833
+ height: 180px;
834
+ border-radius: 0.75rem;
835
+ border: 1px dashed #60a5fa;
836
+ background: rgba(239,246,255,0.5);
837
+ display: flex;
838
+ flex-direction: column;
839
+ align-items: center;
840
+ justify-content: center;
841
+ gap: 8px;
842
+ }
843
+
844
+ /* \u2500\u2500\u2500 Video overlays \u2500\u2500\u2500 */
845
+ .fb-video-overlay {
846
+ position: absolute;
847
+ inset: 0;
848
+ display: flex;
849
+ align-items: center;
850
+ justify-content: center;
851
+ background: rgba(0,0,0,0.25);
852
+ }
853
+ .fb-play-btn {
854
+ background: rgba(255,255,255,0.9);
855
+ border-radius: 50%;
856
+ display: flex;
857
+ align-items: center;
858
+ justify-content: center;
859
+ }
860
+ .fb-video-preview-wrap {
861
+ position: relative;
862
+ width: 100%;
863
+ height: 100%;
864
+ }
865
+ .fb-video-btn-overlay {
866
+ position: absolute;
867
+ top: 8px;
868
+ right: 8px;
869
+ z-index: 10;
870
+ display: flex;
871
+ gap: 4px;
872
+ opacity: 0;
873
+ transition: opacity 150ms;
874
+ pointer-events: none;
875
+ }
876
+ .fb-video-preview-wrap:hover .fb-video-btn-overlay {
877
+ opacity: 1;
878
+ pointer-events: auto;
879
+ }
880
+ .fb-video-btn {
881
+ border: none;
882
+ border-radius: 4px;
883
+ font-size: 11px;
884
+ padding: 4px 8px;
885
+ cursor: pointer;
886
+ color: #fff;
887
+ line-height: 1.2;
888
+ }
889
+ .fb-video-btn-delete { background: rgba(220,38,38,0.85); }
890
+ .fb-video-btn-delete:hover { background: rgba(185,28,28,0.95); }
891
+ .fb-video-btn-change { background: rgba(31,41,55,0.85); }
892
+ .fb-video-btn-change:hover { background: rgba(17,24,39,0.95); }
893
+
894
+ /* \u2500\u2500\u2500 Readonly readonly tile \u2500\u2500\u2500 */
895
+ .fb-readonly-tile {
896
+ aspect-ratio: 1 / 1;
897
+ border-radius: 0.5rem;
898
+ border: 1px solid #e2e8f0;
899
+ overflow: hidden;
900
+ position: relative;
901
+ cursor: pointer;
902
+ }
903
+ .fb-readonly-tile img {
904
+ width: 100%;
905
+ height: 100%;
906
+ object-fit: contain;
907
+ display: block;
908
+ }
909
+ .fb-readonly-tile .fb-tile-actions {
910
+ opacity: 0;
911
+ }
912
+ .fb-readonly-tile:hover .fb-tile-actions {
913
+ opacity: 1;
914
+ }
915
+
916
+ /* \u2500\u2500\u2500 Readonly single-file filled \u2500\u2500\u2500 */
917
+ .fb-single-readonly-filled {
918
+ position: relative;
919
+ border-radius: 0.75rem;
920
+ border: 1px solid #e2e8f0;
921
+ overflow: hidden;
922
+ height: 220px;
923
+ display: block;
924
+ cursor: pointer;
925
+ }
926
+ .fb-single-readonly-filled img {
927
+ width: 100%;
928
+ height: 100%;
929
+ object-fit: contain;
930
+ display: block;
931
+ }
932
+
933
+ /* \u2500\u2500\u2500 Readonly multi grid \u2500\u2500\u2500 */
934
+ .fb-multi-readonly-grid {
935
+ display: grid;
936
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
937
+ gap: 10px;
938
+ }
939
+ `,document.head.appendChild(e),typeof CSS!="undefined"&&typeof CSS.supports=="function"&&CSS.supports("container-type","inline-size")){const t=document.createElement("style");t.setAttribute("data-fb-file-styles-cq","true"),t.textContent=`
940
+ .fb-wide-tile { container-type: inline-size; }
941
+ @container (max-width: 408px) {
942
+ .fb-wide-tile-upload {
943
+ border-right: none;
944
+ border-bottom: 1px dashed rgba(96,165,250,0.5);
945
+ }
946
+ .fb-wide-tile-library {
947
+ flex: 1 0 100%;
948
+ min-height: 0;
949
+ flex-direction: row;
950
+ gap: 6px;
951
+ padding: 8px 12px;
952
+ font-size: 12px;
953
+ }
954
+ .fb-wide-tile-library .fb-wide-tile-library-icon {
955
+ width: 16px;
956
+ height: 16px;
957
+ }
958
+ .fb-wide-tile-library .fb-wide-tile-library-label {
959
+ font-size: 12px;
960
+ font-weight: 500;
961
+ }
962
+ .fb-wide-tile-library .fb-wide-tile-library-hint {
963
+ display: none;
964
+ }
965
+ }
966
+ `,document.head.appendChild(t)}}function vn(){Se();const e=document.createElement("div");return e.className="fb-tile",e}function Le(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 i=document.createElement("div");i.className="file-error-message error-message",i.style.cssText=`
967
+ color: var(--fb-error-color);
968
+ font-size: var(--fb-font-size-small);
969
+ margin-top: 0.25rem;
970
+ `,i.textContent=t,(r=e.closest("[data-files-wrapper]"))==null||r.appendChild(i)}function Qe(e){var t;const n=(t=e.closest("[data-files-wrapper]"))==null?void 0:t.querySelector(".file-error-message");n&&n.remove()}function uo(e,t,n){const r=e.querySelector(".delete-overlay");r&&r.remove();const o=document.createElement("div");o.className="delete-overlay absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center";const i=document.createElement("button");i.className="bg-red-600 text-white px-3 py-1 rounded text-sm hover:bg-red-700 transition-colors",i.textContent=k("removeElement",t),i.onclick=a=>{a.stopPropagation(),n()},o.appendChild(i),e.appendChild(o)}function co(e,t){Se();const n=vn();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=`
971
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
972
+ <div class="fb-spinner"></div>
973
+ <div class="fb-tile-label">${de(r)}</div>
974
+ <div class="fb-tile-uploading-text">${de(k("uploadingFile",t))}</div>
975
+ </div>`,n}function Tt(e){var t,n,r;const o=e.querySelector(".fb-multi-grid");if(o)return o;const i=e.querySelector(".fb-tiles-wrap");if(i)return i;(t=e.querySelector(".fb-file-dropzone"))==null||t.remove(),(n=e.querySelector(".fb-wide-tile"))==null||n.remove(),(r=e.querySelector(".fb-multi-outer"))==null||r.remove();const a=document.createElement("div");a.className="fb-tiles-wrap",a.style.cssText="display:flex;flex-wrap:wrap;gap:6px;align-items:flex-start;";const l=document.createElement("div");return l.className="fb-tile fb-tile-add",l.innerHTML="+",a.appendChild(l),e.appendChild(a),a}function At(e,t,n){e.innerHTML=`
976
+ <div class="flex flex-col items-center justify-center h-full text-gray-400">
977
+ <svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
978
+ <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"/>
979
+ </svg>
980
+ <div class="text-sm text-center">${de(k("clickDragText",t))}</div>
981
+
982
+ </div>
983
+ `}const yn=new WeakMap;function ft(e,t){const n=yn.get(e);n&&(e.removeEventListener("dragover",n.dragover),e.removeEventListener("dragleave",n.dragleave),e.removeEventListener("drop",n.drop));const r=a=>{a.preventDefault(),e.classList.add("border-blue-500","bg-blue-50")},o=a=>{a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50")},i=a=>{var l;a.preventDefault(),e.classList.remove("border-blue-500","bg-blue-50");const s=(l=a.dataTransfer)==null?void 0:l.files;s&&t(s)};e.addEventListener("dragover",r),e.addEventListener("dragleave",o),e.addEventListener("drop",i),yn.set(e,{dragover:r,dragleave:o,drop:i})}const fo='<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>',po='<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>',mo='<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>',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="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',bo='<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 go(e,t){return!!(e.config.downloadFile||e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function vo(e,t){return!!(e.config.getDownloadUrl||e.config.getThumbnail||t!=null&&t.file)}function Ft(e){const{canRemove:t,removeHandler:n,state:r,resourceId:o,fileName:i,meta:a,replaceHandler:l,libraryHandler:s}=e,d=document.createElement("div");d.className="fb-tile-actions";const c=(u,f,m)=>{const p=document.createElement("button");return p.type="button",p.className=`fb-tile-action-btn ${m}`,p.innerHTML=u,p.title=f,p.setAttribute("aria-label",f),p.addEventListener("click",b=>{b.stopPropagation()}),p};if(l){const u=c(ho,k("replaceFile",r),"fb-tile-action-replace");u.addEventListener("click",()=>l()),d.appendChild(u)}if(s){const u=c(bo,k("fromLibrary",r),"fb-tile-action-library");u.addEventListener("click",()=>s()),d.appendChild(u)}if(go(r,a)){const u=c(fo,k("downloadFile",r),"fb-tile-action-download");u.addEventListener("click",()=>{yo(o,i,r,a)}),d.appendChild(u)}if(vo(r,a)){const u=c(po,k("openInNewTab",r),"fb-tile-action-open");u.addEventListener("click",()=>{xo(o,r,a).catch(f=>{console.error("Open failed:",f)})}),d.appendChild(u)}if(t&&n){const u=c(mo,k("removeElement",r),"fb-tile-action-remove");u.addEventListener("click",()=>{n()}),d.appendChild(u)}return d}const pt=new WeakMap;function zt(e){let t=pt.get(e);return t||(t=URL.createObjectURL(e),pt.set(e,t)),t}function qe(e){if(!e)return;const t=pt.get(e);t&&(URL.revokeObjectURL(t),pt.delete(e))}function yo(e,t,n,r){if(n.config.downloadFile){n.config.downloadFile(e,t);return}if((r==null?void 0:r.file)instanceof File){Sn(r.file,t||r.file.name);return}$n(e,t,n).catch(o=>{console.error("Download failed:",o)})}async function xo(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=zt(n.file)),r&&window.open(r,"_blank")}let ke=null,Me=null,He=null,mt=null;function wo(){if(!ke){ke=document.createElement("div"),ke.className="fb-tile-zoom-preview";const e=document.createElement("img");e.className="fb-tile-zoom-preview-img",ke.appendChild(e),ke.addEventListener("mouseenter",wn),ke.addEventListener("mouseleave",xn)}return ke}function Co(e,t){const n=t.getBoundingClientRect(),r=350,o=6,i=8;let a;n.top-r-o>=i?a=n.top-r-o:n.bottom+o+r+i<=window.innerHeight?a=n.bottom+o:a=Math.max(i,Math.min(window.innerHeight-r-i,n.top));let l=n.left+n.width/2-r/2;l=Math.max(i,Math.min(window.innerWidth-r-i,l)),e.style.top=`${a}px`,e.style.left=`${l}px`}function xn(){He!==null&&clearTimeout(He),He=setTimeout(()=>{He=null,Cn()},100)}function wn(){He!==null&&(clearTimeout(He),He=null)}function Cn(){Me!==null&&(clearTimeout(Me),Me=null),ke&&ke.parentNode&&(ke.classList.remove("fb-tile-zoom-preview--visible"),ke.parentNode.removeChild(ke)),mt=null}function Mt(e,t,n,r){e.dataset.zoomSrc=t,e.dataset.zoomAlt=n,e.addEventListener("mouseenter",()=>{wn(),mt!==e&&Cn(),mt=e,Me=setTimeout(()=>{Me=null;const o=wo(),i=o.querySelector(".fb-tile-actions");i&&i.remove();const a=o.querySelector(".fb-tile-zoom-preview-img");a.src=t,a.alt=n,r&&(o.appendChild(r.cloneNode(!0)),Eo(o.querySelector(".fb-tile-actions"),r)),o.style.pointerEvents="auto",Co(o,e),document.body.appendChild(o),o.getBoundingClientRect(),o.classList.add("fb-tile-zoom-preview--visible")},200)}),e.addEventListener("mouseleave",()=>{Me!==null?(clearTimeout(Me),Me=null,mt=null):xn()})}function Eo(e,t){const n=Array.from(t.querySelectorAll(".fb-tile-action-btn"));Array.from(e.querySelectorAll(".fb-tile-action-btn")).forEach((r,o)=>{const i=n[o];i&&r.addEventListener("click",a=>{a.stopPropagation(),i.click()})})}function ko(e,t,n,r){const o=document.createElement("img");o.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",o.alt=n||k("previewAlt",r);const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(t),e.appendChild(o)}function $o(e,t){e.onclick=null;const n=e.cloneNode(!1);return e.parentNode&&e.parentNode.replaceChild(n,e),n}function So(e,t,n,r,o,i){const a=URL.createObjectURL(t),l=$o(e);return l.innerHTML=`
984
+ <div class="fb-video-preview-wrap">
985
+ <video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
986
+ ${de(k("videoNotSupported",o))}
987
+ </video>
988
+ <div class="fb-video-btn-overlay">
989
+ <button class="fb-video-btn fb-video-btn-delete delete-file-btn">
990
+ ${de(k("removeElement",o))}
991
+ </button>
992
+ <button class="fb-video-btn fb-video-btn-change change-file-btn">
993
+ ${de(k("changeButton",o))}
994
+ </button>
995
+ </div>
996
+ </div>
997
+ `,Lo(l,r,o,i),l}function Lo(e,t,n,r){const o=e.querySelector(".change-file-btn");o&&(o.onclick=a=>{var l;a.stopPropagation(),(l=r==null?void 0:r.picker)==null||l.click()});const i=e.querySelector(".delete-file-btn");i&&(i.onclick=a=>{a.stopPropagation(),To(e,t,n,r)})}function To(e,t,n,r){var o;n.resourceIndex.delete(t);const i=(o=e.parentElement)==null?void 0:o.querySelector('input[type="hidden"]');i&&(i.value=""),r!=null&&r.fileUploadHandler&&(e.onclick=r.fileUploadHandler),e.innerHTML=`
998
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
999
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1000
+ <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"/>
1001
+ </svg>
1002
+ <div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
1003
+ </div>
1004
+ `,r!=null&&r.setupDrop&&r.setupDrop(e)}function En(e,t,n){uo(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=`
1005
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1006
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1007
+ <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"/>
1008
+ </svg>
1009
+ <div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
1010
+ </div>
1011
+ `})}async function Ao(e,t,n,r,o,i,a){var l,s,d;!t.file||!(t.file instanceof File)||((l=t.type)!=null&&l.startsWith("image/")?ko(e,t.file,n,i):(s=t.type)!=null&&s.startsWith("video/")?e=So(e,t.file,t.type,r,i,a):e.innerHTML=`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);"><div style="font-size:36px;margin-bottom:0.5rem;">\u{1F4C1}</div><div style="font-size:0.875rem;">${de(n)}</div></div>`,!o&&!((d=t.type)!=null&&d.startsWith("video/"))&&En(e,r,i))}function Fo(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 zo(e,t,n,r,o){var i;if(!o.config.getThumbnail){At(e,o);return}try{const a=await o.config.getThumbnail(t);if(a)if(Ce(e),(i=r==null?void 0:r.type)!=null&&i.startsWith("video/"))Fo(e,a,o);else{const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n||k("previewAlt",o),l.src=a,e.appendChild(l)}else At(e,o)}catch(a){console.error("Failed to get thumbnail:",a),e.innerHTML=`
1012
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
1013
+ <svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
1014
+ <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"/>
1015
+ </svg>
1016
+ <div style="font-size:0.875rem;text-align:center;">${de(n||k("previewUnavailable",o))}</div>
1017
+ </div>
1018
+ `}}async function Rt(e,t,n,r={}){var o;const{fileName:i="",isReadonly:a=!1,deps:l=null}=r;if(!a&&l&&(!l.picker||!l.fileUploadHandler||!l.dragHandler))throw new Error("renderFilePreview: missing deps {picker, fileUploadHandler, dragHandler}");Ce(e);const s=n.resourceIndex.get(t);if(s&&s.file&&s.file instanceof File)await Ao(e,s,i,t,a,n,l);else{await zo(e,t,i,s,n);const d=(o=s==null?void 0:s.type)==null?void 0:o.startsWith("video/");!a&&!d&&En(e,t,n)}}function Mo(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 It(e,t,n,r={}){var o,i;const a=t.resourceIndex.get(e),l=Mo(e,a,n),{canRemove:s=!1,removeHandler:d=null}=r,c=((o=a==null?void 0:a.type)==null?void 0:o.startsWith("image/"))||!!l.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/),u=((i=a==null?void 0:a.type)==null?void 0:i.startsWith("video/"))||!!l.toLowerCase().match(/\.(mp4|webm|avi|mov)$/),f=vn();f.classList.add("fb-tile-resource"),f.style.cursor="pointer",l&&(f.title=l);const m=(a==null?void 0:a.file)instanceof File?zt(a.file):null,p=async()=>t.config.getDownloadUrl?t.config.getDownloadUrl(e):t.config.getThumbnail?t.config.getThumbnail(e):m;f.onclick=async()=>{const h=await p();h?window.open(h,"_blank"):t.config.downloadFile?t.config.downloadFile(e,l):$n(e,l,t).catch(g=>{console.error("Download failed:",g)})};const b=Ft({canRemove:s,removeHandler:d,state:t,resourceId:e,fileName:l,meta:a}),v=async()=>{if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);if(h)return h}catch(h){}return m},$=()=>{f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>',f.appendChild(b)};if(c){const h=await v();if(h){const g=document.createElement("img");g.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",g.alt=l,g.src=h,f.appendChild(g),f.appendChild(b),Mt(f,h,l,b)}else $()}else if(u)if(t.config.getThumbnail)try{const h=await t.config.getThumbnail(e);h?(f.innerHTML=`
1019
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${de(l)}" src="${h}">
1020
+ <div class="fb-video-overlay">
1021
+ <div class="fb-play-btn" style="width:22px;height:22px;">
1022
+ <svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
1023
+ </div>
1024
+ </div>`,f.appendChild(b)):(f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b))}catch(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(b)}else f.innerHTML='<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>',f.appendChild(b);else{if(t.config.getThumbnail)try{const g=await t.config.getThumbnail(e);if(g){const x=document.createElement("img");return x.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",x.alt=l||e,x.src=g,f.appendChild(x),f.appendChild(b),f}}catch(g){}const h=l?`<div class="fb-tile-label">${de(l.length>10?l.substring(0,8)+"\u2026":l)}</div>
1025
+ <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=`
1026
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1027
+ <div style="font-size:36px;">\u{1F4C1}</div>
1028
+ ${h}
1029
+ </div>`,f.appendChild(b)}return f}async function Ro(e,t,n,r){var o,i,a;const l=n.resourceIndex.get(t),s=(i=(o=l==null?void 0:l.name)!=null?o:t.split("/").pop())!=null?i:"",d=(a=r.onRemove)!=null?a:null,c=await It(t,n,s,{canRemove:!0,removeHandler:d});e.className="file-preview-container",e.removeAttribute("style"),Ce(e),e.appendChild(c)}async function kn(e,t,n,r,o){var i,a;if((i=n==null?void 0:n.type)!=null&&i.startsWith("image/")){if(n.file&&n.file instanceof File){const l=document.createElement("img");l.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",l.alt=n.name,l.src=zt(n.file),e.appendChild(l),Mt(e,l.src,n.name,o!=null?o:null)}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);if(l){const s=document.createElement("img");s.style.cssText="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);",s.alt=n.name,s.src=l,e.appendChild(s),Mt(e,l,n.name,o!=null?o:null)}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(s,t),e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:16px;color:var(--fb-error-color,#ef4444);">\u2715</div>'}else e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F5BC}\uFE0F</div>';o&&e.appendChild(o)}else if((a=n==null?void 0:n.type)!=null&&a.startsWith("video/")){if(n.file&&n.file instanceof File){const l=URL.createObjectURL(n.file);e.innerHTML=`
1030
+ <video style="width:100%;height:100%;" preload="metadata" muted src="${l}"></video>
1031
+ <div class="fb-video-overlay">
1032
+ <div class="fb-play-btn" style="width:20px;height:20px;">
1033
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1034
+ </div>
1035
+ </div>`}else if(r.config.getThumbnail)try{const l=await r.config.getThumbnail(t);l?e.innerHTML=`
1036
+ <img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${de(n.name)}" src="${l}">
1037
+ <div class="fb-video-overlay">
1038
+ <div class="fb-play-btn" style="width:20px;height:20px;">
1039
+ <svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
1040
+ </div>
1041
+ </div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(l){const s=l instanceof Error?l:new Error(String(l));r.config.onThumbnailError&&r.config.onThumbnailError(s,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 Io(e,t,n,o)}function Io(e,t,n,r){var o,i;const a=(i=(o=n==null?void 0:n.name)!=null?o:t.split("/").pop())!=null?i:"";a&&(e.title=a);const l=a?`<div style="font-size:11px;line-height:1.2;text-align:center;color:var(--fb-text-secondary-color,#6b7280);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${de(a)}</div>`:"";e.innerHTML=`
1042
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
1043
+ <div style="font-size:36px;">\u{1F4C1}</div>
1044
+ ${l}
1045
+ </div>`,r&&e.appendChild(r)}async function $n(e,t,n){try{let r=null;if(n.config.getDownloadUrl?r=n.config.getDownloadUrl(e):n.config.getThumbnail&&(r=await n.config.getThumbnail(e)),r){const o=r.startsWith("http")?r:new URL(r,window.location.href).href,i=await fetch(o);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const a=await i.blob();Sn(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 Sn(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 Ln(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 No(e){var t,n,r;const{file:o,container:i,fieldName:a,state:l,deps:s=null,instance:d=null,allowedExtensions:c=[],allowedMimes:u=[],maxSizeMB:f=1/0}=e;if(!Pe(o.name,c)){const h=c.join(", ");Le(i,k("invalidFileExtension",l,{name:o.name,formats:h}));return}if(!Ze(o.type,u)){const h=u.join(", ");Le(i,k("invalidFileMime",l,{name:o.name,type:o.type,mimes:h}));return}if(!ut(o,f)){Le(i,k("fileTooLarge",l,{name:o.name,maxSize:f}));return}Qe(i);const m=(t=i.parentElement)==null?void 0:t.querySelector('input[type="hidden"]'),p=(m==null?void 0:m.value)||null;Se(),i.innerHTML=`
1046
+ <div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
1047
+ <div class="fb-spinner"></div>
1048
+ <div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${de(k("uploadingFile",l))}</div>
1049
+ </div>`;let b;try{b=await Ln(o,l)}catch(h){throw p&&s!=null&&s.onAfterUpload?s.onAfterUpload(i,p):s!=null&&s.onRemove?s.onRemove():At(i,l),h}l.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),p&&p!==b&&qe((n=l.resourceIndex.get(p))==null?void 0:n.file);let v=m;v||(v=document.createElement("input"),v.type="hidden",v.name=a,(r=i.parentElement)==null||r.appendChild(v)),v.value=b;const $=o.type.startsWith("video/");!$&&s!=null&&s.onAfterUpload?s.onAfterUpload(i,b):!$&&s?Ro(i,b,l,s).catch(console.error):Rt(i,b,l,{fileName:o.name,isReadonly:!1,deps:s}).catch(console.error),d&&!l.config.readonly&&d.triggerOnChange(a,b)}function qo(e,t,n,r){const o=e.filter(p=>!Pe(p.name,n.allowedExtensions)),i=e.filter(p=>Pe(p.name,n.allowedExtensions)),a=i.filter(p=>!Ze(p.type,n.allowedMimes)),l=i.filter(p=>Ze(p.type,n.allowedMimes)),s=l.filter(p=>!ut(p,n.maxSize)),d=l.filter(p=>ut(p,n.maxSize)),c=n.maxCount===1/0?d.length:Math.max(0,n.maxCount-t),u=d.slice(0,c),f=d.length-u.length,m=[];if(o.length>0){const p=n.allowedExtensions.join(", "),b=o.map(v=>v.name).join(", ");m.push(k("invalidFileExtension",r,{name:b,formats:p}))}if(a.length>0){const p=n.allowedMimes.join(", "),b=a.map(v=>v.name).join(", ");m.push(k("invalidFileMime",r,{name:b,type:a.map(v=>v.type).join(", "),mimes:p}))}if(s.length>0){const p=s.map(b=>b.name).join(", ");m.push(k("fileTooLarge",r,{name:p,maxSize:n.maxSize}))}return f>0&&m.push(k("filesLimitExceeded",r,{skipped:f,max:n.maxCount})),{accepted:u,errorMessage:m.join(" \u2022 ")}}async function Ho(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:i,buildSuccessTile:a,prepareForUpload:l}=e;if(r&&i){const c=Tt(r),u=(t=c.querySelector(".fb-multi-add-tile-js"))!=null?t:c.querySelector(".fb-tile-add");u&&(u.style.display="none")}l==null||l();const s=new Array(n.length).fill(null),d=[];return await Promise.allSettled(n.map(async(c,u)=>{const f=co(c.name,o);r&&Tt(r).appendChild(f);try{const m=await Ln(c,o);o.resourceIndex.set(m,{name:c.name,type:c.type,size:c.size,uploadedAt:new Date,file:c}),s[u]=m,a&&f.parentNode?f.replaceWith(a(m)):f.remove()}catch(m){const p=m instanceof Error?m:new Error(String(m)),b=p.cause,v=b instanceof Error?b:b!==void 0?new Error(String(b)):p;d.push({file:c,error:v}),f.remove()}})),{failures:d,orderedIds:s}}function Bo(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 Tn(e,t,n,r){const{resourceIds:o,state:i,updateCallback:a,constraints:l,pathKey:s,instance:d,buildSuccessTile:c,prepareForUpload:u,coordinator:f}=e,{accepted:m,errorMessage:p}=qo(t,f.getOccupiedCount(),l,i);r&&(p?Le(r,p):Qe(r));const b=f.beginBatch(m.length),v=f.getOccupiedCount()>=l.maxCount,{failures:$,orderedIds:h}=await Ho({accepted:m,listEl:n,state:i,shouldHideAddTile:v,buildSuccessTile:c,prepareForUpload:u});b.setResults(h),d&&s&&!i.config.readonly&&d.triggerOnChange(s,o);const{wasLast:g}=b.end();if(g&&a(),r){const x=Bo(p,$,i);x?Le(r,x):Qe(r)}}function Do(e){const{filesContainer:t}=e;ft(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Tn(e,Array.from(n),o,t)})}function Oo(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,i=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Tn(e,Array.from(t.files),i,o),t.value=""}}function An(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const l=Ne(e.accept);return l.length>0?{extensions:l}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],i=r.map(l=>l.toLowerCase());if(i.length===0&&o.length===0)return;const a={};return i.length>0&&(a.extensions=i),o.length>0&&(a.mime=o),a}function Fn(e,t,n,r,o){if(!Pe(e.name,t)){const i=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:i})}if(!Ze(e.type,n)){const i=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:i})}return bn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function zn(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 Mn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function jo(e){var t;const{state:n,element:r,wrapper:o,fieldPath:i,resourceIds:a,maxCount:l,updateCallback:s,instance:d,coordinator:c,list:u,buildSuccessTile:f}=e;if(!n.config.pickExistingFiles)return;const m=Ne(r.accept),p=Ge(r.accept),b=(t=r.maxSize)!=null?t:1/0,v=c.getAllKnownRids(),$=new Set(v),h=l===1/0?1/0:Math.max(0,l-c.getOccupiedCount());let g;try{g=await n.config.pickExistingFiles({fieldPath:i,mode:"multiple",accept:An(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:v})}catch(P){Le(o,Mn(P,n));return}if(g.length===0)return;const x=new Set,E=g.filter(P=>$.has(P.resourceId)||x.has(P.resourceId)?!1:(x.add(P.resourceId),!0)).filter(P=>Fn(P,m,p,b,n)===null),y=l===1/0?E.length:Math.max(0,l-c.getOccupiedCount()),C=E.slice(0,y),w=E.length-C.length;if(C.length===0){w>0&&Le(o,k("filesLimitExceeded",n,{skipped:w,max:l}));return}Qe(o),w>0&&Le(o,k("filesLimitExceeded",n,{skipped:w,max:l}));for(const P of C)zn(P,n);const R=C.map(P=>P.resourceId),G=c.beginBatch(C.length);G.setResults(R),n.config.readonly||d.triggerOnChange(i,a);const{wasLast:K}=G.end();if(K)s();else{const P=Tt(u);for(const H of R)P.appendChild(f(H))}}async function Uo(e,t,n,r,o,i,a,l){var s,d;if(!e.config.pickExistingFiles)return;const c=Ne(t.accept),u=Ge(t.accept),f=(s=t.maxSize)!=null?s:1/0;let m;try{m=await e.config.pickExistingFiles({fieldPath:i,mode:"single",accept:An(t),maxSizeMB:f===1/0?void 0:f,selectedResourceIds:[]})}catch(h){Le(n,Mn(h,e));return}if(m.length===0)return;const p=m[0],b=Fn(p,c,u,f,e);if(b!==null){Le(n,b);return}Qe(n),zn(p,e);let v=r.querySelector('input[type="hidden"]');v||(v=document.createElement("input"),v.type="hidden",v.name=o,r.appendChild(v));const $=v.value||null;$&&$!==p.resourceId&&qe((d=e.resourceIndex.get($))==null?void 0:d.file),v.value=p.resourceId,await a(p.resourceId),e.config.readonly||l.triggerOnChange(i,p.resourceId)}const Rn='<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>',In='<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 Po(e,t,n,r,o,i,a){var l;ct(e,o.resourceIndex);const s=o.resourceIndex.get(e);(l=s==null?void 0:s.type)!=null&&l.startsWith("video/")?Rt(t,e,o,{fileName:e,isReadonly:!1,deps:i}).catch(console.error):Nt(t,e,o,i,a);const d=document.createElement("input");d.type="hidden",d.name=n,d.value=e,r.appendChild(d)}function Wo(e,t,n,r,o=!1,i=""){Se();const a=document.createElement("div");a.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const l=document.createElement("button");l.type="button",l.className="fb-wide-tile-upload fb-file-dropzone";const s=document.createElement("span");s.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",s.innerHTML=Rn,l.appendChild(s);const d=document.createElement("div");if(d.className="fb-wide-tile-label",d.style.cssText="font-size:14px;font-weight:600;",d.textContent=k(o?"dropToUpload":"clickDragText",e),l.appendChild(d),i){const c=document.createElement("div");c.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",c.textContent=i,l.appendChild(c)}if(l.onclick=c=>{c.stopPropagation(),n()},a.appendChild(l),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=In,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 m=document.createElement("div");m.className="fb-wide-tile-library-hint",m.style.cssText="font-size:11px;opacity:0.75;text-align:center;",m.textContent=k("libraryHint",e),c.appendChild(m),c.onclick=p=>{p.stopPropagation(),r()},a.appendChild(c)}return Nn(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 Nn(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function Nt(e,t,n,r,o){var i,a;const l=n.resourceIndex.get(t);if((i=l==null?void 0:l.type)!=null&&i.startsWith("video/")){Rt(e,t,n,{fileName:(a=l==null?void 0:l.name)!=null?a:"",isReadonly:!1,deps:r}).catch(console.error);return}Se();const s=document.createElement("div");s.className="fb-multi-outer fb-multi-has-files";const d=document.createElement("div");d.className="fb-multi-grid fb-tiles-wrap",s.appendChild(d);const c=qt(t,n,!!r.onRemove,r.onRemove?()=>{var u;return(u=r.onRemove)==null?void 0:u.call(r)}:null,o);for(d.appendChild(c),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s)}function Vo(e,t,n,r,o=!1){const i=document.createElement("div");i.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const a=document.createElement("button");a.type="button",a.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const l=document.createElement("span");l.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",l.innerHTML=Rn,a.appendChild(l);const s=document.createElement("span");if(s.className="fb-multi-add-label",s.style.cssText="font-size:11px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),a.appendChild(s),a.onclick=d=>{d.stopPropagation(),n()},i.appendChild(a),t&&r){const d=document.createElement("div");d.className="fb-multi-add-divider",i.appendChild(d);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=In,c.appendChild(u),c.appendChild(document.createTextNode(k("fromLibrary",e))),c.onclick=f=>{f.stopPropagation(),r()},i.appendChild(c)}return i}function qt(e,t,n,r,o){var i,a,l;Se();const s=t.resourceIndex.get(e),d=document.createElement("div");d.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",d.dataset.resourceId=e;const c=Ft({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(i=s==null?void 0:s.name)!=null?i:"",meta:s,replaceHandler:(a=o==null?void 0:o.replaceHandler)!=null?a:null,libraryHandler:(l=o==null?void 0:o.libraryHandler)!=null?l:null});return kn(d,e,s,t,c).catch(u=>{console.error("Failed to render tile:",u)}),d}function qn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Ko(e,t,n){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=i=>{i.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const et=new WeakMap,Ht=new WeakMap;function Hn(e){const t=Ht.get(e);t!==void 0&&(cancelAnimationFrame(t),Ht.delete(e))}function _o(e){const t=et.get(e);t&&(t.disconnect(),et.delete(e)),Hn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Jo(e){var t;const{container:n,rids:r,state:o,onRemove:i,maxCount:a,isReadonly:l=!1,onLibraryPick:s,onClearAll:d,openPicker:c}=e;Se();const u=n.closest("[data-files-wrapper]");u&&(u.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const f=et.get(n);for(f&&(f.disconnect(),et.delete(n)),Hn(n);n.firstChild;)n.removeChild(n.firstChild);const m=r!=null?r:[],p=a!=null?a:1/0,b=p!==1/0&&m.length>=p,v=!l&&typeof s=="function",$=c!=null?c:(()=>{var y;const C=(y=n.closest("[data-files-wrapper]"))==null?void 0:y.querySelector('input[type="file"]');C&&C.click()});if(l){if(m.length===0){const y=document.createElement("div");y.className="fb-tile-empty-text",y.textContent=k("noFilesSelected",o),n.appendChild(y)}else{const y=document.createElement("div");y.className="fb-multi-readonly-grid",n.appendChild(y);for(const C of m){const w=o.resourceIndex.get(C),R=document.createElement("div");R.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",R.dataset.resourceId=C;const G=Ft({canRemove:!1,removeHandler:null,state:o,resourceId:C,fileName:(t=w==null?void 0:w.name)!=null?t:"",meta:w});kn(R,C,w,o,G).catch(console.error),R.onclick=async()=>{var K;let P=null;o.config.getDownloadUrl?P=o.config.getDownloadUrl(C):o.config.getThumbnail?P=await o.config.getThumbnail(C):(w==null?void 0:w.file)instanceof File&&(P=URL.createObjectURL(w.file)),P?window.open(P,"_blank"):o.config.downloadFile&&o.config.downloadFile(C,(K=w==null?void 0:w.name)!=null?K:"")},y.appendChild(R)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${m.length>0?" fb-multi-has-files":""}`;const g=document.createElement("div");g.className="fb-multi-grid fb-tiles-wrap",h.appendChild(g),n.appendChild(h);for(let y=0;y<m.length;y++){const C=m[y],w=qt(C,o,i!==null,i?()=>i(C):null);g.appendChild(w)}if(!b){const y=Vo(o,v,$,s!=null?s:null);g.appendChild(y)}const x=m.length+(b?0:1),E=()=>{const y=getComputedStyle(g).gridTemplateColumns,C=y?y.split(" ").filter(Boolean).length:0;if(!C)return;const w=x%C,R=w===0?0:C-w,G=p===1/0?R:Math.max(0,p-x),K=Math.min(R,G),P=g.querySelectorAll(".fb-multi-placeholder");if(P.length>K)for(let H=P.length-1;H>=K;H--)P[H].remove();else if(P.length<K)for(let H=P.length;H<K;H++)g.appendChild(qn())};if((p===1/0||p>x)&&g.appendChild(qn()),Ht.set(n,requestAnimationFrame(E)),typeof ResizeObserver!="undefined"){const y=new ResizeObserver(()=>E());y.observe(g),et.set(n,y)}if(Nn(h,{activeClass:"fb-drag-over",onEnter:()=>{g.querySelectorAll(".fb-multi-placeholder").forEach(C=>{C.classList.add("fb-drag-over")});const y=g.querySelector(".fb-multi-add-tile-js");if(y){y.classList.add("fb-drag-over-tile");const C=y.querySelector(".fb-multi-add-label");C&&(C.textContent=k("dropToUpload",o))}},onLeave:()=>{g.querySelectorAll(".fb-multi-placeholder").forEach(C=>{C.classList.remove("fb-drag-over")});const y=g.querySelector(".fb-multi-add-tile-js");if(y){y.classList.remove("fb-drag-over-tile");const C=y.querySelector(".fb-multi-add-label");C&&(C.textContent=k("clickDragTextMultiple",o))}}}),d){const y=Ko(o,m.length,d);y&&n.appendChild(y)}}function Xo(e,t,n,r){var o,i;const a=t.state,l=document.createElement("div");l.className="fb-row",l.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.style.display="none",s.accept=Bn(e.accept);const d=document.createElement("div");d.className="file-preview-container";const c=t.prefill[e.key],u=Ne(e.accept),f=Ge(e.accept),m=(o=e.maxSize)!=null?o:1/0,p={fileUploadHandler(){s.click()},dragHandler(h){h.length>0&&No({file:h[0],container:d,fieldName:r,state:a,deps:v(),instance:t.instance,allowedExtensions:u,allowedMimes:f,maxSizeMB:m})},setupDrop(h){ft(h,p.dragHandler)},onRemove(){var h;const g=l.querySelector('input[type="hidden"]'),x=g==null?void 0:g.value;x&&qe((h=a.resourceIndex.get(x))==null?void 0:h.file),g&&(g.value=""),$()}},b=()=>{const h=!!(a.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:a.config.uploadFile?()=>s.click():null,libraryHandler:h?()=>{Uo(a,e,d,l,r,r,async g=>{Nt(d,g,a,v(),b())},t.instance).catch(g=>{console.error("Library pick failed:",g)})}:null}},v=()=>({picker:s,fileUploadHandler:p.fileUploadHandler,dragHandler:p.dragHandler,setupDrop:p.setupDrop,onRemove:p.onRemove,onAfterUpload:(h,g)=>{Nt(h,g,a,v(),b())}}),$=()=>{for(Se(),d.className="file-preview-container",d.removeAttribute("style");d.firstChild;)d.removeChild(d.firstChild);const h=b().libraryHandler,g=Wo(a,h!==null,p.fileUploadHandler,h,!1,Te(e,a));d.appendChild(g),ft(d,p.dragHandler)};if(c){Po(c,d,r,l,a,v(),b());const h=a.resourceIndex.get(c);(i=h==null?void 0:h.type)!=null&&i.startsWith("video/")&&ft(d,p.dragHandler)}else $();s.onchange=()=>{s.files&&s.files.length>0&&p.dragHandler(s.files)},l.appendChild(d),l.appendChild(s),n.appendChild(l)}function Bn(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 Dn(e,t,n,r,o){var i,a;const l=t.state,s=document.createElement("div");s.className="fb-row",s.dataset.filesWrapper=r;const d=document.createElement("input");d.type="file",d.name=r,d.multiple=!0,d.style.display="none",d.accept=Bn(e.accept);const c=document.createElement("div");c.className="files-list-wrapper";const u=document.createElement("div");u.className="files-list",s.appendChild(d),s.appendChild(c),c.appendChild(u);const f=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];Lt(f,l.resourceIndex),s.dataset.resourceIds=JSON.stringify(f);const m={maxCount:o,allowedExtensions:Ne(e.accept),allowedMimes:Ge(e.accept),maxSize:(a=(i=e.maxSize)!=null?i:e.maxSizeMB)!=null?a:1/0},p=()=>{d.click()},b=l.config.pickExistingFiles&&!e.disableLibrary?()=>{jo({state:l,element:e,wrapper:s,fieldPath:r,resourceIds:f,maxCount:o,updateCallback:v,instance:t.instance,coordinator:R,list:u,buildSuccessTile:G}).catch(H=>{console.error("Library pick failed:",H)})}:null;function v(){const H=se(e,l);Jo({container:u,rids:f,state:l,onRemove:H?null:Q=>{var N,X;qe((N=l.resourceIndex.get(Q))==null?void 0:N.file);const ae=f.indexOf(Q);ae>-1&&f.splice(ae,1),R.hasInFlightBatches()?(C.add(Q),(X=u.querySelector(`[data-resource-id="${Q}"]`))==null||X.remove(),s.dataset.resourceIds=JSON.stringify(f)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},maxCount:o<1/0?o:void 0,isReadonly:H,onLibraryPick:H?null:b,onClearAll:H?void 0:()=>{var Q,N;for(const X of f)qe((Q=l.resourceIndex.get(X))==null?void 0:Q.file);if(f.splice(0),R.hasInFlightBatches()){const X=u.querySelectorAll("[data-resource-id]");for(const ae of X){const pe=ae.dataset.resourceId;pe&&(qe((N=l.resourceIndex.get(pe))==null?void 0:N.file),C.add(pe)),ae.remove()}s.dataset.resourceIds=JSON.stringify(f)}else v();t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)},openPicker:p})}let $=0,h=0,g=0,x=0;const E=new Map,y=new Map,C=new Set,w=()=>{for(var H;E.has(x);){const Q=x,N=E.get(Q);E.delete(Q),x+=1;const X=(H=y.get(Q))!=null?H:0;y.delete(Q),$-=X;for(const ae of N)if(ae!==null){if(C.has(ae)){C.delete(ae);continue}f.push(ae)}}s.dataset.resourceIds=JSON.stringify(f)},R={getOccupiedCount:()=>f.length+$,getAllKnownRids:()=>{const H=[...f];for(const Q of E.values())for(const N of Q)N!==null&&H.push(N);return H},hasInFlightBatches:()=>h>0||y.size>0,wasRemovedDuringBatch:H=>C.has(H),beginBatch:H=>{$+=H,h+=1;const Q=g++;return y.set(Q,H),{setResults:N=>{E.set(Q,N),w()},end:()=>{h-=1;const N=h===0&&y.size===0;return N&&C.clear(),{wasLast:N}}}}},G=H=>{const Q=se(e,l);return qt(H,l,!Q,Q?null:()=>{var N,X,ae;qe((N=l.resourceIndex.get(H))==null?void 0:N.file);const pe=f.indexOf(H);if(pe>-1){f.splice(pe,1),R.hasInFlightBatches()?(C.add(H),(X=u.querySelector(`[data-resource-id="${H}"]`))==null||X.remove(),s.dataset.resourceIds=JSON.stringify(f)):v(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f);return}C.add(H),(ae=u.querySelector(`[data-resource-id="${H}"]`))==null||ae.remove(),t.instance&&r&&!l.config.readonly&&t.instance.triggerOnChange(r,f)})},K=()=>_o(u),P={resourceIds:f,state:l,updateCallback:v,constraints:m,pathKey:r,instance:t.instance,buildSuccessTile:G,prepareForUpload:K,coordinator:R};Do({...P,filesContainer:c}),Oo({...P,filesPicker:d}),v(),n.appendChild(s)}function Yo(e,t,n,r){Dn(e,t,n,r,1/0)}function Go(e,t,n,r){var o;Dn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Zo(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 Qo(e,t,n,r,o){var i,a;const l="minCount"in n&&(i=n.minCount)!=null?i:0,s="maxCount"in n&&(a=n.maxCount)!=null?a:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<l&&o.push(`${e}: ${k("minFiles",r,{min:l})}`),t.length>s&&o.push(`${e}: ${k("maxFiles",r,{max:s})}`)}function On(e,t,n,r,o){var i,a;const l="accept"in n?n.accept:void 0,s=Ne(l),d=Ge(l);if(s.length===0&&d.length===0)return;const c=s.join(", "),u=d.join(", ");for(const f of t){const m=r.resourceIndex.get(f),p=(i=m==null?void 0:m.name)!=null?i:f;if(s.length>0&&!Pe(p,s)){o.push(`${e}: ${k("invalidFileExtension",r,{name:p,formats:c})}`);continue}if(d.length>0&&!(m!=null&&m.inferredFromExtension)){const b=(a=m==null?void 0:m.type)!=null?a:"";Ze(b,d)||o.push(`${e}: ${k("invalidFileMime",r,{name:p,type:b,mimes:u})}`)}}}function jn(e,t,n,r,o){var i;const a="maxSize"in n&&(i=n.maxSize)!=null?i:1/0;if(a!==1/0)for(const l of t){const s=r.resourceIndex.get(l);s&&s.size>a*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:s.name,maxSize:a})}`)}}function el(e,t,n){const{scopeRoot:r,skipValidation:o,path:i,state:a}=n,l=[],s=Oe(i,t),d=Zo(r,s);return o||(Qo(t,d,e,a,l),On(t,d,e,a,l),jn(t,d,e,a,l)),{value:d,errors:l}}function tl(e,t,n){var r;const{scopeRoot:o,skipValidation:i,state:a}=n,l=[],s=o.querySelector(`input[name="${t}"][type="hidden"]`),d=(r=s==null?void 0:s.value)!=null?r:"";return!i&&e.required&&d===""?(l.push(`${t}: ${k("required",a)}`),{value:null,errors:l}):(!i&&d!==""&&(On(t,[d],e,a,l),jn(t,[d],e,a,l)),{value:d||null,errors:l})}function Un(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?el(e,t,n):tl(e,t,n)}function nl(e,t,n,r){const o=t.state,i=t.prefill[e.key],a=typeof i=="string"?i:"";if(a){Lt([a],o.resourceIndex);const l=document.createElement("input");l.type="hidden",l.name=r,l.value=a,n.appendChild(l),It(a,o).then(s=>{s.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(s)}).catch(console.error)}else n.appendChild(rl(o))}function rl(e){Se();const t=document.createElement("div");return t.style.cssText=`
1050
+ height: 220px;
1051
+ display:flex;
1052
+ align-items:center;
1053
+ justify-content:center;
1054
+ background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
1055
+ border-radius:0.75rem;
1056
+ border:1px solid #e2e8f0;
1057
+ `,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${de(k("noFileSelected",e))}</div>`,t}function Pn(e,t,n,r,o){Lt(e,t.resourceIndex),Se();const i=document.createElement("div");if(i.dataset.filesWrapper=r,i.dataset.resourceIds=JSON.stringify(e),n.appendChild(i),e.length===0){const s=document.createElement("div");s.className="fb-tile-empty-text",s.textContent=k("noFilesSelected",t),i.appendChild(s);return}const a=document.createElement("div");a.className="fb-multi-readonly-grid",i.appendChild(a);const l=e.map(()=>{const s=document.createElement("div");return s.className="fb-readonly-tile fb-checker fb-tile",a.appendChild(s),s});for(let s=0;s<e.length;s++){const d=e[s],c=l[s],u=t.resourceIndex.get(d);It(d,t,u==null?void 0:u.name).then(f=>{f.classList.add("fb-readonly-tile","fb-checker","fb-tile-resource"),f.dataset.resourceId=d,c.replaceWith(f)}).catch(()=>{const f=document.createElement("div");f.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",f.dataset.resourceId=d,c.replaceWith(f)})}}function ol(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Pn(i,t.state,n,r)}function ll(e,t,n,r){const o=t.prefill[e.key],i=Array.isArray(o)?o:[];Pn(i,t.state,n,r)}function il(e,t,n,r){se(e,t.state,t)?nl(e,t,n,r):Xo(e,t,n,r)}function al(e,t,n,r){se(e,t.state,t)?ol(e,t,n,r):Yo(e,t,n,r)}function sl(e,t,n,r){se(e,t.state,t)?ll(e,t,n,r):Go(e,t,n,r)}function Wn(e,t,n,r){const{scopeRoot:o,state:i}=r;if(e.type==="files"||"multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateFileField: Expected array for multiple file field "${t}", got ${typeof n}`);return}n.forEach(l=>{l&&typeof l=="string"&&ct(l,i.resourceIndex)});const a=o.querySelector(`[data-files-wrapper="${t}"]`);a?a.dataset.resourceIds=JSON.stringify(n):console.warn(`updateFileField: [data-files-wrapper="${t}"] not found in DOM; data-resource-ids not updated`)}else{const a=o.querySelector(`input[name="${t}"][type="hidden"]`);if(!a){console.warn(`updateFileField: Hidden input not found for file field "${t}"`);return}a.value=n!=null?String(n):"",n&&typeof n=="string"&&(ct(n,i.resourceIndex),console.info(`updateFileField: File field "${t}" updated. Preview update requires re-render.`))}}function We(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 Vn(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 Kn(e){const t=document.createElement("div");t.className="flex items-center gap-2";const n=We(e),r=document.createElement("div");r.style.cssText=`
1058
+ width: 32px;
1059
+ height: 32px;
1060
+ border-radius: var(--fb-border-radius);
1061
+ border: var(--fb-border-width) solid var(--fb-border-color);
1062
+ background-color: ${n};
1063
+ `;const o=document.createElement("span");return o.style.cssText=`
1064
+ font-size: var(--fb-font-size);
1065
+ color: var(--fb-text-color);
1066
+ font-family: var(--fb-font-family-mono, monospace);
1067
+ `,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function _n(e,t,n,r){const o=We(e),i=document.createElement("div");i.className="colour-picker-wrapper",i.style.cssText=`
1068
+ display: flex;
1069
+ align-items: center;
1070
+ gap: 8px;
1071
+ `;const a=document.createElement("div");a.className="colour-swatch",a.style.cssText=`
1072
+ width: 40px;
1073
+ height: 40px;
1074
+ border-radius: var(--fb-border-radius);
1075
+ border: var(--fb-border-width) solid var(--fb-border-color);
1076
+ background-color: ${o};
1077
+ cursor: pointer;
1078
+ transition: border-color var(--fb-transition-duration) ease-in-out;
1079
+ flex-shrink: 0;
1080
+ `;const l=document.createElement("input");l.type="text",l.className="colour-hex-input",l.setAttribute("data-colour-field","true"),l.name=t,l.value=o,l.placeholder=r!=null?r:"#000000",l.style.cssText=`
1081
+ width: 100px;
1082
+ padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
1083
+ border: var(--fb-border-width) solid var(--fb-border-color);
1084
+ border-radius: var(--fb-border-radius);
1085
+ background-color: var(--fb-background-color);
1086
+ color: var(--fb-text-color);
1087
+ font-size: var(--fb-font-size);
1088
+ font-family: var(--fb-font-family-mono, monospace);
1089
+ transition: all var(--fb-transition-duration) ease-in-out;
1090
+ `;const s=document.createElement("input");return s.type="color",s.className="colour-picker-hidden",s.value=o.toLowerCase(),s.style.cssText=`
1091
+ position: absolute;
1092
+ opacity: 0;
1093
+ pointer-events: none;
1094
+ `,l.addEventListener("input",()=>{const d=l.value.trim();if(Bt(d)){const c=Vn(d);a.style.backgroundColor=c,s.value=c.toLowerCase(),l.classList.remove("invalid"),n.instance&&n.instance.triggerOnChange(t,c)}else l.classList.add("invalid")}),l.addEventListener("blur",()=>{const d=l.value.trim();if(Bt(d)){const c=Vn(d);l.value=c,a.style.backgroundColor=c,s.value=c.toLowerCase(),l.classList.remove("invalid")}}),s.addEventListener("change",()=>{const d=We(s.value);l.value=d,a.style.backgroundColor=d,n.instance&&n.instance.triggerOnChange(t,d)}),a.addEventListener("click",()=>{s.click()}),a.addEventListener("mouseenter",()=>{a.style.borderColor="var(--fb-border-hover-color)"}),a.addEventListener("mouseleave",()=>{a.style.borderColor="var(--fb-border-color)"}),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)")}),i.appendChild(a),i.appendChild(l),i.appendChild(s),i}function dl(e,t,n,r){var o,i;const a=t.state,l=se(e,a,t),s=(i=(o=t.prefill[e.key])!=null?o:e.default)!=null?i:"#000000";if(l){const d=Kn(s);n.appendChild(d)}else{const d=_n(s,r,t,e.placeholder);n.appendChild(d)}if(!l){const d=document.createElement("p");d.className="mt-1",d.style.cssText=`
1095
+ font-size: var(--fb-font-size-small);
1096
+ color: var(--fb-text-secondary-color);
1097
+ `,d.textContent=Te(e,a),n.appendChild(d)}}function ul(e,t,n,r){var o,i,a;const l=t.state,s=se(e,l,t),d=t.prefill[e.key]||[],c=Array.isArray(d)?[...d]:[],u=(o=e.minCount)!=null?o:e.required?1:0,f=(i=e.maxCount)!=null?i:1/0;for(;c.length<u;)c.push((a=e.default)!=null?a:"#000000");const m=document.createElement("div");m.className="fb-row",n.appendChild(m);function p(){m.querySelectorAll(".multiple-colour-item").forEach((g,x)=>{const E=g.querySelector("input");E&&(E.name=`${r}[${x}]`)})}function b(g="#000000",x=-1){const E=document.createElement("div");if(E.className="multiple-colour-item flex items-center gap-2",s){const y=Kn(g);for(;y.firstChild;)E.appendChild(y.firstChild)}else{const y=`${r}[${m.children.length}]`,C=_n(g,y,t,e.placeholder);C.style.flex="1",E.appendChild(C)}return x===-1?m.appendChild(E):m.insertBefore(E,m.children[x]),p(),E}function v(){if(s)return;const g=m.querySelectorAll(".multiple-colour-item"),x=g.length;g.forEach(E=>{let y=E.querySelector(".remove-item-btn");y||(y=document.createElement("button"),y.type="button",y.className="remove-item-btn px-2 py-1 rounded",y.style.cssText=`
1098
+ color: var(--fb-error-color);
1099
+ background-color: transparent;
1100
+ transition: background-color var(--fb-transition-duration);
1101
+ `,y.innerHTML="\u2715",y.addEventListener("mouseenter",()=>{y.style.backgroundColor="var(--fb-background-hover-color)"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="transparent"}),y.onclick=()=>{var w;const R=Array.from(m.children).indexOf(E);m.children.length>u&&(c.splice(R,1),E.remove(),p(),h(),v(),(w=t.instance)==null||w.triggerOnChange(r))},E.appendChild(y));const C=x<=u;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"})}let $=null;if(!s){const g=ze("colour",()=>{var x,E;const y=(x=e.default)!=null?x:"#000000";c.push(y),b(y),h(),v(),(E=t.instance)==null||E.triggerOnChange(r)},{label:e.addLabel});$=g.update,Ae(n,g.counter),n.appendChild(g.row)}function h(){$&&$(c.length,f)}if(c.forEach(g=>b(g)),h(),v(),!s){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
1102
+ font-size: var(--fb-font-size-small);
1103
+ color: var(--fb-text-secondary-color);
1104
+ `,g.textContent=Te(e,l),n.appendChild(g)}}function cl(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n,d=(c,u,f)=>{const{state:m}=n;if(!u){if(!s&&e.required){const b=k("required",m);return a.push(`${f}: ${b}`),ne(c,b),""}return ne(c,null),""}const p=We(u);if(!s&&!Bt(p)){const b=k("invalidHexColour",m);return a.push(`${f}: ${b}`),ne(c,b),u}return ne(c,null),p};if(e.multiple){const c=l.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),u=[];if(c.forEach((f,m)=>{var p;const b=(p=f==null?void 0:f.value)!=null?p:"",v=d(f,b,`${t}[${m}]`);u.push(v)}),!s){const{state:f}=n,m=(r=e.minCount)!=null?r:0,p=(o=e.maxCount)!=null?o:1/0,b=u.filter(v=>v!=="");e.required&&b.length===0&&a.push(`${t}: ${k("required",f)}`),b.length<m&&a.push(`${t}: ${k("minItems",f,{min:m})}`),b.length>p&&a.push(`${t}: ${k("maxItems",f,{max:p})}`)}return{value:u,errors:a}}else{const c=l.querySelector(`[name="${t}"].colour-hex-input`),u=(i=c==null?void 0:c.value)!=null?i:"";if(!s&&e.required&&u===""){const f=k("required",n.state);return a.push(`${t}: ${f}`),ne(c,f),{value:"",errors:a}}return{value:d(c,u,t),errors:a}}}function fl(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const i=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);i.forEach((a,l)=>{if(l<n.length){const s=We(n[l]);a.value=s,a.classList.remove("invalid"),a.title="",Ee(a);const d=a.closest(".colour-picker-wrapper");if(d){const c=d.querySelector(".colour-swatch"),u=d.querySelector(".colour-picker-hidden");c&&(c.style.backgroundColor=s),u&&(u.value=s.toLowerCase())}}}),n.length!==i.length&&console.warn(`updateColourField: Multiple field "${t}" has ${i.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const i=o.querySelector(`[name="${t}"].colour-hex-input`);if(i){const a=We(n);i.value=a,i.classList.remove("invalid"),i.title="",Ee(i);const l=i.closest(".colour-picker-wrapper");if(l){const s=l.querySelector(".colour-swatch"),d=l.querySelector(".colour-picker-hidden");s&&(s.style.backgroundColor=a),d&&(d.value=a.toLowerCase())}}}}function Jn(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 Dt(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 ht(e,t){return Math.round(e/t)*t}function Xn(e,t,n,r,o){var i;const a=document.createElement("div");a.className="slider-container";const l=document.createElement("div");l.className="flex items-start gap-3";const s=document.createElement("div");s.className="flex-1";const d=document.createElement("input");d.type="range",d.name=t,d.className="slider-input w-full",d.disabled=o;const c=n.scale||"linear",u=n.min,f=n.max,m=(i=n.step)!=null?i:1;if(c==="exponential"){if(u<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${u})`);d.min="0",d.max="1000",d.step="1";const h=Dt(e,u,f);d.value=(h*1e3).toString()}else d.min=u.toString(),d.max=f.toString(),d.step=m.toString(),d.value=e.toString();d.style.cssText=`
1105
+ height: 6px;
1106
+ border-radius: 3px;
1107
+ background: linear-gradient(
1108
+ to right,
1109
+ var(--fb-primary-color) 0%,
1110
+ var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
1111
+ var(--fb-border-color) ${(e-u)/(f-u)*100}%,
1112
+ var(--fb-border-color) 100%
1113
+ );
1114
+ outline: none;
1115
+ transition: background 0.1s ease-in-out;
1116
+ cursor: ${o?"not-allowed":"pointer"};
1117
+ opacity: ${o?"0.6":"1"};
1118
+ `,s.appendChild(d);const p=document.createElement("div");p.className="flex justify-between",p.style.cssText=`
1119
+ font-size: var(--fb-font-size-small);
1120
+ color: var(--fb-text-secondary-color);
1121
+ margin-top: 4px;
1122
+ `;const b=document.createElement("span");b.textContent=u.toString();const v=document.createElement("span");v.textContent=f.toString(),p.appendChild(b),p.appendChild(v),s.appendChild(p);const $=document.createElement("span");if($.className="slider-value",$.style.cssText=`
1123
+ min-width: 60px;
1124
+ text-align: right;
1125
+ font-size: var(--fb-font-size);
1126
+ color: var(--fb-text-color);
1127
+ font-family: var(--fb-font-family-mono, monospace);
1128
+ font-weight: 500;
1129
+ padding-top: 2px;
1130
+ `,$.textContent=e.toFixed(m<1?2:0),l.appendChild(s),l.appendChild($),a.appendChild(l),!o){const h=()=>{let g;if(c==="exponential"){const E=parseFloat(d.value)/1e3;g=Jn(E,u,f),g=ht(g,m),g=Math.max(u,Math.min(f,g))}else g=parseFloat(d.value),g=ht(g,m);$.textContent=g.toFixed(m<1?2:0);const x=(g-u)/(f-u)*100;d.style.background=`linear-gradient(
1131
+ to right,
1132
+ var(--fb-primary-color) 0%,
1133
+ var(--fb-primary-color) ${x}%,
1134
+ var(--fb-border-color) ${x}%,
1135
+ var(--fb-border-color) 100%
1136
+ )`,r.instance&&r.instance.triggerOnChange(t,g)};d.addEventListener("input",h),d.addEventListener("change",h)}return a}function pl(e,t,n,r){var o;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const i=t.state,a=se(e,i,t),l=e.default!==void 0?e.default:(e.min+e.max)/2,s=(o=t.prefill[e.key])!=null?o:l,d=Xn(s,r,e,t,a);if(n.appendChild(d),!a){const c=document.createElement("p");c.className="mt-1",c.style.cssText=`
1137
+ font-size: var(--fb-font-size-small);
1138
+ color: var(--fb-text-secondary-color);
1139
+ `,c.textContent=Te(e,i),n.appendChild(c)}}function ml(e,t,n,r){var o,i;if(e.min===void 0||e.min===null)throw new Error(`Slider field "${e.key}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider field "${e.key}" requires "max" property`);if(e.min>=e.max)throw new Error(`Slider field "${e.key}": min (${e.min}) must be less than max (${e.max})`);const a=t.state,l=se(e,a,t),s=t.prefill[e.key]||[],d=Array.isArray(s)?[...s]:[],c=(o=e.minCount)!=null?o:e.required?1:0,u=(i=e.maxCount)!=null?i:1/0,f=e.default!==void 0?e.default:(e.min+e.max)/2;for(;d.length<c;)d.push(f);const m=document.createElement("div");m.className="space-y-3",n.appendChild(m);function p(){m.querySelectorAll(".multiple-slider-item").forEach((g,x)=>{const E=g.querySelector("input[type=range]");E&&E.setAttribute("name",`${r}[${x}]`)})}function b(g=f,x=-1){const E=document.createElement("div");E.className="multiple-slider-item flex items-start gap-2";const y=`${r}[${m.children.length}]`,C=Xn(g,y,e,t,l);return C.style.flex="1",E.appendChild(C),x===-1?m.appendChild(E):m.insertBefore(E,m.children[x]),p(),E}function v(){if(l)return;const g=m.querySelectorAll(".multiple-slider-item"),x=g.length;g.forEach(E=>{let y=E.querySelector(".remove-item-btn");y||(y=document.createElement("button"),y.type="button",y.className="remove-item-btn px-2 py-1 rounded",y.style.cssText=`
1140
+ color: var(--fb-error-color);
1141
+ background-color: transparent;
1142
+ transition: background-color var(--fb-transition-duration);
1143
+ margin-top: 8px;
1144
+ `,y.innerHTML="\u2715",y.addEventListener("mouseenter",()=>{y.style.backgroundColor="var(--fb-background-hover-color)"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="transparent"}),y.onclick=()=>{var w;const R=Array.from(m.children).indexOf(E);m.children.length>c&&(d.splice(R,1),E.remove(),p(),h(),v(),(w=t.instance)==null||w.triggerOnChange(r))},E.appendChild(y));const C=x<=c;y.disabled=C,y.style.opacity=C?"0.5":"1",y.style.pointerEvents=C?"none":"auto"})}let $=null;if(!l){const g=ze("slider",()=>{var x;d.push(f),b(f),h(),v(),(x=t.instance)==null||x.triggerOnChange(r)},{label:e.addLabel});$=g.update,Ae(n,g.counter),n.appendChild(g.row)}function h(){$&&$(d.length,u)}if(d.forEach(g=>b(g)),h(),v(),!l){const g=document.createElement("p");g.className="mt-1",g.style.cssText=`
1145
+ font-size: var(--fb-font-size-small);
1146
+ color: var(--fb-text-secondary-color);
1147
+ `,g.textContent=Te(e,a),n.appendChild(g)}}function hl(e,t,n){var r,o,i;const a=[],{scopeRoot:l,skipValidation:s}=n;if(e.min===void 0||e.min===null)throw new Error(`Slider validation: field "${t}" requires "min" property`);if(e.max===void 0||e.max===null)throw new Error(`Slider validation: field "${t}" requires "max" property`);const d=e.min,c=e.max,u=(r=e.step)!=null?r:1,f=e.scale||"linear",m=(p,b)=>{const{state:v}=n,$=p.value;if(!$){if(!s&&e.required){const g=k("required",v);return a.push(`${b}: ${g}`),ne(p,g),null}return ne(p,null),null}let h;if(f==="exponential"){const g=parseFloat($)/1e3;h=Jn(g,d,c),h=ht(h,u)}else h=parseFloat($),h=ht(h,u);if(!s){if(h<d){const g=k("minValue",v,{min:d});return a.push(`${b}: ${g}`),ne(p,g),h}if(h>c){const g=k("maxValue",v,{max:c});return a.push(`${b}: ${g}`),ne(p,g),h}}return ne(p,null),h};if(e.multiple){const p=l.querySelectorAll(`input[type="range"][name^="${t}\\["]`),b=[];if(p.forEach((v,$)=>{const h=m(v,`${t}[${$}]`);b.push(h)}),!s){const{state:v}=n,$=(o=e.minCount)!=null?o:0,h=(i=e.maxCount)!=null?i:1/0,g=b.filter(x=>x!==null);e.required&&g.length===0&&a.push(`${t}: ${k("required",v)}`),g.length<$&&a.push(`${t}: ${k("minItems",v,{min:$})}`),g.length>h&&a.push(`${t}: ${k("maxItems",v,{max:h})}`)}return{value:b,errors:a}}else{const p=l.querySelector(`input[type="range"][name="${t}"]`);return p?{value:m(p,t),errors:a}:(!s&&e.required&&a.push(`${t}: ${k("required",n.state)}`),{value:null,errors:a})}}function bl(e,t,n,r){var o;const{scopeRoot:i}=r,a=e.min,l=e.max,s=(o=e.step)!=null?o:1,d=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=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`);c.forEach((u,f)=>{if(f<n.length&&n[f]!==null){const m=Number(n[f]);if(d==="exponential"){const b=Dt(m,a,l);u.value=(b*1e3).toString()}else u.value=m.toString();const p=u.closest(".slider-container");if(p){const b=p.querySelector(".slider-value");b&&(b.textContent=m.toFixed(s<1?2:0));const v=(m-a)/(l-a)*100;u.style.background=`linear-gradient(
1148
+ to right,
1149
+ var(--fb-primary-color) 0%,
1150
+ var(--fb-primary-color) ${v}%,
1151
+ var(--fb-border-color) ${v}%,
1152
+ var(--fb-border-color) 100%
1153
+ )`}u.classList.remove("invalid"),u.title="",Ee(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=i.querySelector(`input[type="range"][name="${t}"]`);if(c&&n!==null&&n!==void 0){const u=Number(n);if(d==="exponential"){const m=Dt(u,a,l);c.value=(m*1e3).toString()}else c.value=u.toString();const f=c.closest(".slider-container");if(f){const m=f.querySelector(".slider-value");m&&(m.textContent=u.toFixed(s<1?2:0));const p=(u-a)/(l-a)*100;c.style.background=`linear-gradient(
1154
+ to right,
1155
+ var(--fb-primary-color) 0%,
1156
+ var(--fb-primary-color) ${p}%,
1157
+ var(--fb-border-color) ${p}%,
1158
+ var(--fb-border-color) 100%
1159
+ )`}c.classList.remove("invalid"),c.title="",Ee(c)}}}function Yn(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 Gn(e,t){return{...t,...e}}function Ot(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]=Qt(n))}),t}let jt=null;function gl(e){jt=e}function Zn(e,t){if(!jt)throw new Error("renderElement not initialized. Import from components/index.ts");return jt(e,t)}function Qn(e,t){if(!e.prefillHints||e.prefillHints.length===0)return null;const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",e.prefillHints.forEach((r,o)=>{const i=document.createElement("button");i.type="button",i.className="fb-prefill-hint",i.textContent=r.label,i.setAttribute("data-hint-values",JSON.stringify(r.values)),i.setAttribute("data-container-key",t),i.setAttribute("data-hint-index",String(o)),n.appendChild(i)}),n}function er(e,t,n,r){var o,i;const a=document.createElement("div");a.className="border border-gray-200 rounded-lg p-2 bg-gray-50",a.setAttribute("data-container",r);const l=document.createElement("div"),s=e.columns||1;s===1?l.className="fb-row":l.className=`grid grid-cols-${s} gap-2`;const d=se(e,t.state,t);if(!d){const p=Qn(e,r);p&&a.appendChild(p)}const c=Yn(e.elements),u=((o=t.prefill)==null?void 0:o[e.key])||{},f=Gn(u,c),m={path:Oe(t.path,e.key),prefill:f,formData:(i=t.formData)!=null?i:t.prefill,state:t.state,instance:t.instance,inheritedReadonly:d||t.inheritedReadonly};e.elements.forEach(p=>{var b;if(p.type!=="markdown"&&(p.hidden||p.type==="hidden")){const v=p.key in u?u[p.key]:(b="default"in p?p.default:null)!=null?b:null;l.appendChild(kt(Oe(m.path,p.key),v))}else l.appendChild(Zn(p,m))}),a.appendChild(l),n.appendChild(a)}function vl(e){const t=e||1;return t===1?"fb-row":`grid grid-cols-${t} gap-2`}function yl(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=`
1160
+ width: 24px;
1161
+ height: 24px;
1162
+ display: inline-flex;
1163
+ align-items: center;
1164
+ justify-content: center;
1165
+ padding: 0;
1166
+ border: 0;
1167
+ border-radius: 4px;
1168
+ cursor: pointer;
1169
+ flex-shrink: 0;
1170
+ `,o.innerHTML=tn,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 tr(e,t,n,r){var o,i,a,l;const s=t.state,d=se(e,s,t),c=d||t.inheritedReadonly,u=document.createElement("div");u.className="border border-gray-200 rounded-lg p-2 bg-gray-50";const f=document.createElement("div"),m=e.displayMode==="slides";if(m?f.className="fb-container-slides":f.className="fb-row",!d){const N=Qn(e,e.key);N&&u.appendChild(N)}const p=(o=e.minCount)!=null?o:0,b=(i=e.maxCount)!=null?i:1/0,v=Array.isArray((a=t.prefill)==null?void 0:a[e.key])?t.prefill[e.key]:null,$=Yn(e.elements);let h=0;const g=()=>h++,x=()=>Array.from(f.children).filter(N=>N.classList.contains("containerItem")),E=()=>x().length,y=N=>{var X;E()<=p||(N.remove(),Q(),(X=t.instance)==null||X.triggerOnChange(r))},C=(N,X,ae)=>{const pe={state:s,instance:t.instance,path:Oe(t.path,`${e.key}[${N}]`),prefill:Gn(X!=null?X:{},$),formData:ae,inheritedReadonly:c},xe=document.createElement("div");xe.className="containerItem border border-gray-300 rounded-lg p-2 bg-white",xe.setAttribute("data-container-item",pe.path),m&&xe.setAttribute("data-fb-slide-card","");const we=document.createElement("div");return we.className=vl(m?void 0:e.columns),e.elements.forEach(ge=>{var Be;if(ge.type!=="markdown"&&(ge.hidden||ge.type==="hidden")){const S=X&&ge.key in X?X[ge.key]:(Be="default"in ge?ge.default:null)!=null?Be:null;we.appendChild(kt(Oe(pe.path,ge.key),S))}else we.appendChild(Zn(ge,pe))}),xe.appendChild(we),d||yl(xe,()=>y(xe),s,e.label),xe},w=()=>{var N;if(E()>=b)return;const X=C(g(),null,s.formRoot?Ot(s.formRoot):{});R&&R.parentElement===f?f.insertBefore(X,R):f.appendChild(X),Q(),(N=t.instance)==null||N.triggerOnChange(r)};let R=null,G=null,K=null;const P=()=>{if(!R)return;const N=x()[0];N&&N.offsetHeight>0&&(R.style.minHeight=`${N.offsetHeight}px`)},H=()=>{const N=E()<=p;x().forEach(X=>{const ae=Array.from(X.children).find(pe=>pe.classList.contains("fb-item-remove"));ae&&(ae.disabled=N)})},Q=()=>{const N=E();G&&G(N,b),K&&K(N,b),R&&P(),H()};if(v&&v.forEach(N=>{var X;f.appendChild(C(g(),N!=null?N:{},(X=t.formData)!=null?X:t.prefill))}),!d)for(;E()<p;)f.appendChild(C(g(),null,(l=t.formData)!=null?l:t.prefill));if(u.appendChild(f),!d)if(m){const N=Nr(w,{label:e.addLabel});R=N.tile,G=N.update,Ae(n,N.counter),f.appendChild(N.tile)}else{const N=ze("container",w,{label:e.addLabel});K=N.update,Ae(n,N.counter),u.appendChild(N.row)}Q(),n.appendChild(u),R&&(typeof requestAnimationFrame=="function"?requestAnimationFrame(P):P())}function xl(e){if(!e.validateElement)throw new Error("validateContainerElement: context.validateElement missing \u2014 container validation requires the instance validator");return e.validateElement}function nr(e,t,n){const r=xl(n),o=[],{scopeRoot:i,skipValidation:a,path:l}=n;if(!("elements"in e))return{value:null,errors:o};const s=(d,c,u)=>{var f,m;if(a)return;const{state:p}=n,b="minCount"in u&&(f=u.minCount)!=null?f:0,v="maxCount"in u&&(m=u.maxCount)!=null?m:1/0;u.required&&c.length===0&&o.push(`${d}: ${k("required",p)}`),c.length<b&&o.push(`${d}: ${k("minItems",p,{min:b})}`),c.length>v&&o.push(`${d}: ${k("maxItems",p,{max:v})}`)};if("multiple"in e&&e.multiple){const d=[];return rt(i,t).forEach(c=>{const u={},f=(c.getAttribute("data-container-item")||"").match(/\[(\d+)\]$/),m=f?parseInt(f[1],10):0;e.elements.forEach(p=>{var b;if(p.enableIf)try{const h=(b=n.instance)!=null&&b.getState().formRoot?Ot(n.instance.getState().formRoot):{};if(!je(p.enableIf,h,u))return}catch(h){console.error(`Error evaluating enableIf for field "${p.key}" in container "${t}[${m}]":`,h)}const v=`${t}[${m}].${p.key}`,$=r({...p,key:v},{path:l},c);$.spread&&$.value!==null&&typeof $.value=="object"?Object.assign(u,$.value):!$.skip&&p.key&&(u[p.key]=$.value)}),d.push(u)}),s(t,d,e),{value:d,errors:o}}else{const d={},c=i.querySelector(`[data-container="${t}"]`)||i;return e.elements.forEach(u=>{var f;if(u.enableIf)try{const m=(f=n.instance)!=null&&f.getState().formRoot?Ot(n.instance.getState().formRoot):{};if(!je(u.enableIf,m,d))return}catch(m){console.error(`Error evaluating enableIf for field "${u.key}" in container "${t}":`,m)}{const m=`${t}.${u.key}`,p=r({...u,key:m},{path:l},c);p.spread&&p.value!==null&&typeof p.value=="object"?Object.assign(d,p.value):!p.skip&&u.key&&(d[u.key]=p.value)}}),{value:d,errors:o}}}function rr(e,t,n,r){const{instance:o,scopeRoot:i}=r;if("elements"in e)if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateContainerField: Expected array for multiple container field "${t}", got ${typeof n}`);return}const a=rt(i,t);n.forEach((l,s)=>{var d;const c=(d=a[s])==null?void 0:d.getAttribute("data-container-item");Xe(l)&&c&&e.elements.forEach(u=>{var f,m;if(u.type==="markdown"||!u.key)return;const p=`${c}.${u.key}`;if(u.type==="richinput"&&u.flatOutput){const b=u,v=(f=b.textKey)!=null?f:"text",$=(m=b.filesKey)!=null?m:"files",h=l,g={};v in h&&(g[v]=h[v]),$ in h&&(g[$]=h[$]),Object.keys(g).length>0&&o.updateField(p,g)}else{const b=l[u.key];b!==void 0&&o.updateField(p,b)}})}),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(!Xe(n)){console.warn(`updateContainerField: Expected object for container field "${t}", got ${typeof n}`);return}e.elements.forEach(a=>{var l,s;if(a.type==="markdown"||!a.key)return;const d=`${t}.${a.key}`;if(a.type==="richinput"&&a.flatOutput){const c=a,u=(l=c.textKey)!=null?l:"text",f=(s=c.filesKey)!=null?s:"files",m=n,p={};u in m&&(p[u]=m[u]),f in m&&(p[f]=m[f]),Object.keys(p).length>0&&o.updateField(d,p)}else{const c=n[a.key];c!==void 0&&o.updateField(d,c)}})}}function wl(e,t,n,r){var o,i;typeof console!="undefined"&&console.warn&&console.warn(`[Form Builder] The "group" field type is deprecated and will be removed in a future version. Please use type: "container" with multiple: true instead. Field key: "${e.key}"`);const a={key:e.key,label:e.label,description:e.description,hint:e.hint,required:e.required,hidden:e.hidden,default:e.default,actions:e.actions,elements:e.elements,multiple:!!(e.repeat&&Xe(e.repeat)),minCount:(o=e.repeat)==null?void 0:o.min,maxCount:(i=e.repeat)==null?void 0:i.max};a.multiple?tr(a,t,n,r):er(a,t,n,r)}function or(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&&Xe(r.repeat)),minCount:(t=r.repeat)==null?void 0:t.min,maxCount:(n=r.repeat)==null?void 0:n.max}}function Cl(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=or(e);return nr(r,t,n)}function El(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=or(e);return rr(o,t,n,r)}function kl(e){return e!==null&&typeof e=="object"&&"row"in e&&"col"in e&&"rowspan"in e&&"colspan"in e}function $l(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 Sl(e){return kl(e)?{top:e.row,left:e.col,bottom:e.row+e.rowspan-1,right:e.col+e.colspan-1}:$l(e)?e:null}function Ve(e){return e.map(Sl).filter(t=>t!==null)}function lr(e,t){return Array.from({length:e},()=>Array.from({length:t},()=>""))}function Ut(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(o.top<0||o.left<0||o.bottom>=t||o.right>=n||o.top>o.bottom||o.left>o.right)return`Merge ${r} out of bounds`;for(let i=r+1;i<e.length;i++){const a=e[i];if(o.top<=a.bottom&&o.bottom>=a.top&&o.left<=a.right&&o.right>=a.left)return`Merges ${r} and ${i} overlap`}}return null}function ir(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 bt(e,t,n){var r;return(r=n.find(o=>o.top===e&&o.left===t))!=null?r:null}function Re(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 Ke(e){const t=document.createElement("button");return t.type="button",t.textContent=e.label,t.title=e.title,t.style.cssText=`
1171
+ position: absolute;
1172
+ width: ${e.size}px;
1173
+ height: ${e.size}px;
1174
+ border-radius: 50%;
1175
+ border: none;
1176
+ background: ${e.color};
1177
+ color: ${e.textColor};
1178
+ font-size: ${Math.floor(e.size*.6)}px;
1179
+ line-height: ${e.size}px;
1180
+ text-align: center;
1181
+ cursor: pointer;
1182
+ z-index: 10;
1183
+ padding: 0;
1184
+ display: flex;
1185
+ align-items: center;
1186
+ justify-content: center;
1187
+ box-shadow: 0 1px 4px rgba(0,0,0,0.2);
1188
+ transition: transform 0.1s, opacity 0.1s;
1189
+ pointer-events: all;
1190
+ `,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 Ll(e,t){const{cells:n,merges:r=[]}=e;if(n.length===0)return;const o=n[0].length,i=document.createElement("table");i.style.cssText=`
1191
+ width: 100%;
1192
+ border-collapse: collapse;
1193
+ border: var(--fb-border-width) solid var(--fb-border-color);
1194
+ border-radius: var(--fb-border-radius);
1195
+ font-size: var(--fb-font-size);
1196
+ font-family: var(--fb-font-family);
1197
+ color: var(--fb-text-color);
1198
+ `,n.forEach((l,s)=>{var d,c;const u=(s===0?i.createTHead():(d=i.tBodies[0])!=null?d:i.createTBody()).insertRow();for(let f=0;f<o;f++){if(ir(s,f,r))continue;const m=bt(s,f,r),p=document.createElement(s===0?"th":"td");if(m){const b=m.bottom-m.top+1,v=m.right-m.left+1;b>1&&(p.rowSpan=b),v>1&&(p.colSpan=v)}p.textContent=(c=l[f])!=null?c:"",p.style.cssText=`
1199
+ padding: 6px 10px;
1200
+ border: var(--fb-border-width) solid var(--fb-border-color);
1201
+ text-align: left;
1202
+ vertical-align: top;
1203
+ ${s===0?"background-color: var(--fb-background-hover-color); font-weight: 600;":""}
1204
+ `,u.appendChild(p)}});const a=document.createElement("div");a.style.cssText="overflow-x: auto; max-width: 100%;",a.appendChild(i),t.appendChild(a)}function Tl(e,t,n,r,o,i){if(e.contentEditable==="true")return;e.contentEditable="true",e.focus();const a=document.createRange(),l=window.getSelection();a.selectNodeContents(e),a.collapse(!1),l==null||l.removeAllRanges(),l==null||l.addRange(a);function s(){var u;e.contentEditable="inherit";const f=r();f[t]&&(f[t][n]=(u=e.textContent)!=null?u:""),o()}function d(u){var f,m,p,b;const v=r(),$=(m=(f=v[0])==null?void 0:f.length)!=null?m:0;if(u.key==="Escape"){e.contentEditable="inherit",e.textContent=(b=(p=v[t])==null?void 0:p[n])!=null?b:"",e.removeEventListener("keydown",d),e.removeEventListener("blur",c);return}if(u.key==="Enter"&&!u.shiftKey){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",d),e.removeEventListener("blur",c);const h=t+1<v.length?t+1:t;i(h,n);return}if(u.key==="Tab"){u.preventDefault(),u.stopPropagation(),s(),e.removeEventListener("keydown",d),e.removeEventListener("blur",c);let h=t,g=u.shiftKey?n-1:n+1;g<0&&(g=$-1,h=Math.max(0,t-1)),g>=$&&(g=0,h=Math.min(v.length-1,t+1)),i(h,g)}}function c(){e.contentEditable==="true"&&(s(),e.removeEventListener("keydown",d),e.removeEventListener("blur",c))}e.addEventListener("keydown",d),e.addEventListener("blur",c)}function Al(){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 Fl(e,t){Al();const n=document.createElement("div");n.className="fb-table-loading-overlay",n.style.cssText=`
1205
+ position: absolute; top: 0; left: 0; right: 0; bottom: 0;
1206
+ background: rgba(255,255,255,0.8); display: flex;
1207
+ align-items: center; justify-content: center; flex-direction: column;
1208
+ gap: 8px; z-index: 100;
1209
+ `;const r=document.createElement("div");r.style.cssText=`
1210
+ width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
1211
+ border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
1212
+ animation: fb-spin 0.8s linear infinite;
1213
+ `;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 zl(e,t,n,r,o){var i,a,l,s,d,c,u,f;const m=r.state,p=r.instance,b=e.mergeAllowed!==!1,v=(a=(i=e.fieldNames)==null?void 0:i.cells)!=null?a:"cells",$=(s=(l=e.fieldNames)==null?void 0:l.merges)!=null?s:"merges",h=t.cells.length>0?t.cells.map(T=>[...T]):lr((d=e.rows)!=null?d:3,(c=e.columns)!=null?c:3);let g=t.merges?[...t.merges]:[];const x={anchor:null,focus:null,dragging:!1},E=document.createElement("input");E.type="hidden",E.name=n,E.value=JSON.stringify({[v]:h,[$]:g}),o.appendChild(E);function y(){E.value=JSON.stringify({[v]:h,[$]:g}),p&&p.triggerOnChange(n,{[v]:h,[$]:g})}E._applyExternalUpdate=T=>{h.length=0,T.cells.forEach(A=>h.push([...A])),g.length=0,T.merges&&T.merges.forEach(A=>g.push({...A})),x.anchor=null,x.focus=null,y(),z()};const C=document.createElement("div");C.style.cssText="position: relative; padding: 20px 20px 20px 24px; overflow-x: auto; max-width: 100%;";const w=document.createElement("table");w.style.cssText=`
1214
+ border-collapse: collapse;
1215
+ font-size: var(--fb-font-size);
1216
+ font-family: var(--fb-font-family);
1217
+ color: var(--fb-text-color);
1218
+ table-layout: fixed;
1219
+ `,C.appendChild(w);const R=(f=(u=e.importAccept)==null?void 0:u.map(T=>`.${T.toLowerCase()}`))!=null?f:[];async function G(T){var A,L,B;if(!m.config.parseTableFile)return;if(R.length>0){const F=T.name.toLowerCase().replace(/^.*(\.[^.]+)$/,"$1");if(!R.includes(F))return}const D=Fl(C,k("tableImporting",m));try{const F=await m.config.parseTableFile(T),oe=F.cells,j=(A=F.merges)!=null?A:[];if(j.length>0){const U=Ut(j,oe.length,(B=(L=oe[0])==null?void 0:L.length)!=null?B:0);if(U)throw new Error(U)}h.length=0,oe.forEach(U=>h.push([...U])),g.length=0,j.forEach(U=>g.push({...U})),x.anchor=null,x.focus=null,y(),z()}catch(F){const oe=F instanceof Error?F.message:String(F);console.error(k("tableImportError",m,{error:oe}))}finally{D.remove()}}if(e.importAccept&&m.config.parseTableFile){const T=document.createElement("button");T.type="button",T.title=k("tableImportFile",m),T.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>',T.style.cssText=`
1220
+ position: absolute; top: 2px; left: 2px;
1221
+ width: 20px; height: 20px;
1222
+ padding: 0;
1223
+ display: flex; align-items: center; justify-content: center;
1224
+ color: var(--fb-text-color, #999);
1225
+ border: none;
1226
+ background: transparent;
1227
+ cursor: pointer;
1228
+ z-index: 2;
1229
+ `,T.addEventListener("mouseenter",()=>{T.style.color="var(--fb-primary-color, #0066cc)"}),T.addEventListener("mouseleave",()=>{T.style.color="var(--fb-text-color, #999)"});const A=document.createElement("input");A.type="file",A.accept=R.join(","),A.style.display="none",C.appendChild(A),T.addEventListener("click",()=>{A.click()}),A.addEventListener("change",()=>{var B;const D=(B=A.files)==null?void 0:B[0];D&&G(D),A.value=""}),C.appendChild(T);let L=0;C.addEventListener("dragenter",B=>{B.preventDefault(),L++,L===1&&(C.style.outline="2px dashed var(--fb-primary-color, #0066cc)",C.style.outlineOffset="-2px")}),C.addEventListener("dragover",B=>{B.preventDefault(),B.dataTransfer&&(B.dataTransfer.dropEffect="copy")}),C.addEventListener("dragleave",B=>{B.preventDefault(),L--,L<=0&&(L=0,C.style.outline="",C.style.outlineOffset="")}),C.addEventListener("drop",B=>{var D,F;B.preventDefault(),L=0,C.style.outline="",C.style.outlineOffset="";const oe=(F=(D=B.dataTransfer)==null?void 0:D.files)==null?void 0:F[0];oe&&G(oe)})}o.appendChild(C);const K=document.createElement("div");K.style.cssText=`
1230
+ position: fixed;
1231
+ display: none;
1232
+ background: white;
1233
+ border: 1px solid var(--fb-border-color);
1234
+ border-radius: var(--fb-border-radius);
1235
+ box-shadow: 0 2px 8px rgba(0,0,0,0.15);
1236
+ padding: 4px;
1237
+ z-index: 1000;
1238
+ gap: 4px;
1239
+ flex-direction: column;
1240
+ `,o.appendChild(K);function P(T,A){const L=document.createElement("button");return L.type="button",L.textContent=T,L.style.cssText=`
1241
+ padding: 4px 10px;
1242
+ font-size: var(--fb-font-size-small);
1243
+ color: var(--fb-text-color);
1244
+ border: 1px solid var(--fb-border-color);
1245
+ border-radius: var(--fb-border-radius);
1246
+ background: transparent;
1247
+ cursor: pointer;
1248
+ white-space: nowrap;
1249
+ text-align: left;
1250
+ `,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{Q(),A()}),L}function H(T,A){if(!b)return;K.innerHTML="",K.style.display="flex";const L=Re(x),B=L&&(L.r1!==L.r2||L.c1!==L.c2),D=x.anchor&&bt(x.anchor.row,x.anchor.col,g);if(B&&K.appendChild(P(k("tableMergeCells",m),S)),D&&K.appendChild(P(k("tableSplitCell",m),I)),!K.firstChild){Q();return}const F=140,oe=K.children.length*32+8,j=window.innerWidth,U=window.innerHeight,_=T+F>j?T-F:T,Z=A+oe>U?A-oe:A;K.style.left=`${_}px`,K.style.top=`${Z}px`}function Q(){K.style.display="none"}const N=new AbortController;document.addEventListener("mousedown",T=>{if(!o.isConnected){N.abort();return}K.contains(T.target)||Q()},{signal:N.signal});function X(){const T=Re(x);w.querySelectorAll("td[data-row]").forEach(A=>{const L=parseInt(A.getAttribute("data-row")||"0",10),B=parseInt(A.getAttribute("data-col")||"0",10),D=x.anchor!==null&&x.anchor.row===L&&x.anchor.col===B,F=T!==null&&L>=T.r1&&L<=T.r2&&B>=T.c1&&B<=T.c2;A.style.outline=D?"2px solid var(--fb-primary-color, #0066cc)":"",A.style.outlineOffset=D?"-2px":"",L===0?A.style.backgroundColor="var(--fb-background-hover-color)":A.style.backgroundColor=F&&!D?"rgba(0,102,204,0.08)":""})}function ae(T,A){x.anchor={row:T,col:A},x.focus=null,X(),w.focus()}function pe(T,A){const L=w.querySelector(`td[data-row="${T}"][data-col="${A}"]`);if(!L)return;const B=L.querySelector("span");B&&(x.anchor={row:T,col:A},x.focus=null,X(),Tl(B,T,A,()=>h,y,ae))}function xe(T){var A;const L=h.length>0?h[0].length:(A=e.columns)!=null?A:3,B=Array(L).fill(""),D=T!==void 0?T+1:h.length;h.splice(D,0,B),g=g.map(F=>F.top>=D?{...F,top:F.top+1,bottom:F.bottom+1}:F.top<D&&F.bottom>=D?{...F,bottom:F.bottom+1}:F),y(),z()}function we(T){if(h.length<=1)return;const A=T!==void 0?T:x.anchor?x.anchor.row:h.length-1;g=g.map(L=>L.top===A&&L.bottom===A?null:L.top===A?{...L,bottom:L.bottom-1}:L.bottom===A?{...L,bottom:L.bottom-1}:L.top<A&&L.bottom>A?{...L,bottom:L.bottom-1}:L.top>A?{...L,top:L.top-1,bottom:L.bottom-1}:L).filter(L=>L!==null),h.splice(A,1),x.anchor&&x.anchor.row>=h.length&&(x.anchor={row:h.length-1,col:x.anchor.col}),y(),z()}function ge(T){var A,L;const B=T!==void 0?T+1:(L=(A=h[0])==null?void 0:A.length)!=null?L:0;h.forEach(D=>D.splice(B,0,"")),g=g.map(D=>D.left>=B?{...D,left:D.left+1,right:D.right+1}:D.left<B&&D.right>=B?{...D,right:D.right+1}:D),y(),z()}function Be(T){if(h.length===0||h[0].length<=1)return;const A=T!==void 0?T:x.anchor?x.anchor.col:h[0].length-1;g=g.map(L=>L.left===A&&L.right===A?null:L.left===A?{...L,right:L.right-1}:L.right===A?{...L,right:L.right-1}:L.left<A&&L.right>A?{...L,right:L.right-1}:L.left>A?{...L,left:L.left-1,right:L.right-1}:L).filter(L=>L!==null),h.forEach(L=>L.splice(A,1)),x.anchor&&x.anchor.col>=h[0].length&&(x.anchor={row:x.anchor.row,col:h[0].length-1}),y(),z()}function S(){var T,A;if(!b)return;const L=Re(x);if(!L)return;const{r1:B,c1:D,r2:F,c2:oe}=L;if(B===F&&D===oe)return;g=g.filter(O=>!(O.top<=F&&O.bottom>=B&&O.left<=oe&&O.right>=D));const j=h[B][D];for(let O=B;O<=F;O++)for(let ee=D;ee<=oe;ee++)(O!==B||ee!==D)&&(h[O][ee]="");h[B][D]=j;const U={top:B,left:D,bottom:F,right:oe},_=[...g,U],Z=Ut(_,h.length,(A=(T=h[0])==null?void 0:T.length)!=null?A:0);if(Z){console.warn("Merge validation failed:",Z);return}g.push(U),x.anchor={row:B,col:D},x.focus=null,y(),z()}function I(){if(!b||!x.anchor)return;const{row:T,col:A}=x.anchor,L=g.findIndex(B=>B.top===T&&B.left===A);L!==-1&&(g.splice(L,1),x.focus=null,y(),z())}function z(){var T,A;w.innerHTML="";const L=h.length,B=L>0?h[0].length:0,D=Re(x);for(let F=0;F<L;F++){const oe=(F===0?(T=w.tHead)!=null?T:w.createTHead():(A=w.tBodies[0])!=null?A:w.createTBody()).insertRow();for(let j=0;j<B;j++){if(ir(F,j,g))continue;const U=bt(F,j,g),_=document.createElement("td");if(_.setAttribute("data-row",String(F)),_.setAttribute("data-col",String(j)),U){const te=U.bottom-U.top+1,J=U.right-U.left+1;te>1&&(_.rowSpan=te),J>1&&(_.colSpan=J)}const Z=D!==null&&F>=D.r1&&F<=D.r2&&j>=D.c1&&j<=D.c2,O=x.anchor!==null&&x.anchor.row===F&&x.anchor.col===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&&!O?"background-color: rgba(0,102,204,0.08);":"",O?"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;",_.appendChild(ee);const Y=F,ie=j;_.addEventListener("mousedown",te=>{if(te.target.tagName!=="BUTTON"&&te.target.contentEditable!=="true"){if(te.button===2){const J=Re(x);if(J&&Y>=J.r1&&Y<=J.r2&&ie>=J.c1&&ie<=J.c2)return}te.shiftKey&&x.anchor?(te.preventDefault(),x.focus={row:Y,col:ie},x.dragging=!1,X()):(x.anchor={row:Y,col:ie},x.focus=null,x.dragging=!0,X())}}),_.addEventListener("mouseup",te=>{if(te.target.tagName!=="BUTTON"&&x.dragging){x.dragging=!1;const J=Re(x);(!J||J.r1===J.r2&&J.c1===J.c2)&&pe(Y,ie)}}),_.addEventListener("mousemove",te=>{if(x.dragging&&te.buttons===1){const J=x.anchor;J&&(J.row!==Y||J.col!==ie)&&(x.focus={row:Y,col:ie},X())}}),_.addEventListener("contextmenu",te=>{if(!b)return;const J=Re(x),he=J&&(J.r1!==J.r2||J.c1!==J.c2),fe=x.anchor&&bt(x.anchor.row,x.anchor.col,g);(he||fe)&&(te.preventDefault(),H(te.clientX,te.clientY))}),oe.appendChild(_)}}me(),w.setAttribute("tabindex","0"),w.onkeydown=F=>{var oe,j;if(w.querySelector("[contenteditable='true']"))return;const U=x.anchor;if(!U)return;const _=h.length,Z=_>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[ee,Y]=O[F.key],ie=Math.max(0,Math.min(_-1,U.row+ee)),te=Math.max(0,Math.min(Z-1,U.col+Y));F.shiftKey?(x.focus={row:ie,col:te},X()):ae(ie,te);return}if(F.key==="Enter"){F.preventDefault(),pe(U.row,U.col);return}if(F.key==="Tab"){F.preventDefault();const ee=(j=(oe=h[0])==null?void 0:oe.length)!=null?j:0;let Y=U.row,ie=F.shiftKey?U.col-1:U.col+1;ie<0&&(ie=ee-1,Y=Math.max(0,Y-1)),ie>=ee&&(ie=0,Y=Math.min(h.length-1,Y+1)),ae(Y,ie);return}if(b&&F.key==="m"&&F.ctrlKey&&!F.shiftKey){F.preventDefault(),S();return}b&&F.key==="M"&&F.ctrlKey&&F.shiftKey&&(F.preventDefault(),I())},w.oncopy=F=>{var oe,j,U,_;const Z=Re(x);if(!Z)return;F.preventDefault();const{r1:O,c1:ee,r2:Y,c2:ie}=Z,te=[],J=[];for(let V=O;V<=Y;V++){const ce=[],ve=[];for(let ye=ee;ye<=ie;ye++){const $e=(j=(oe=h[V])==null?void 0:oe[ye])!=null?j:"";ce.push($e);const De=$e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ve.push(`<td>${De}</td>`)}te.push(ce.join(" ")),J.push(`<tr>${ve.join("")}</tr>`)}const he=te.join(`
1251
+ `),fe=`<table>${J.join("")}</table>`;(U=F.clipboardData)==null||U.setData("text/plain",he),(_=F.clipboardData)==null||_.setData("text/html",fe)},w.onpaste=F=>{var oe,j,U,_,Z,O,ee,Y,ie;const te=x.anchor;if(!te)return;const J=(j=(oe=F.clipboardData)==null?void 0:oe.getData("text/plain"))!=null?j:"",he=J.includes(" ")||J.split(/\r?\n/).filter(be=>be).length>1,fe=w.querySelector("[contenteditable='true']");if(fe&&!he)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const be=parseInt((_=(U=fe.closest("td"))==null?void 0:U.getAttribute("data-row"))!=null?_:"0",10),Ie=parseInt((O=(Z=fe.closest("td"))==null?void 0:Z.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(ee=fe.textContent)!=null?ee:"")}if(!J.trim())return;const V=J.split(/\r?\n/).map(be=>be.split(" "));V.length>1&&V[V.length-1].length===1&&V[V.length-1][0]===""&&V.pop();const ce=te.row,ve=te.col,ye=ce+V.length;for(;h.length<ye;)h.push(Array((ie=(Y=h[0])==null?void 0:Y.length)!=null?ie:1).fill(""));const $e=Math.max(...V.map(be=>be.length)),De=ve+$e;if(h[0]&&De>h[0].length){const be=De-h[0].length;h.forEach(Ie=>{for(let nt=0;nt<be;nt++)Ie.push("")})}for(let be=0;be<V.length;be++)for(let Ie=0;Ie<V[be].length;Ie++){const nt=ce+be,vi=ve+Ie;h[nt]&&(h[nt][vi]=V[be][Ie])}y(),z()}}const M=Ke({label:"+",title:k("tableAddColumn",m),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var T;const A=parseInt((T=M.dataset.afterCol)!=null?T:"0",10);ge(A)}});M.style.position="absolute",M.style.display="none",C.appendChild(M);const q=Ke({label:"+",title:k("tableAddRow",m),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var T;const A=parseInt((T=q.dataset.afterRow)!=null?T:"0",10);xe(A)}});q.style.position="absolute",q.style.display="none",C.appendChild(q);let W=[],le=[];const re=Ke({label:"+",title:k("tableAddColumn",m),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>ge()});re.style.position="absolute",re.style.display="none",C.appendChild(re);const ue=Ke({label:"+",title:k("tableAddRow",m),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});ue.style.position="absolute",ue.style.display="none",C.appendChild(ue);function me(){var T,A;W.forEach(j=>j.remove()),W=[],le.forEach(j=>j.remove()),le=[];const L=h.length>0?h[0].length:0,B=h.length;if(L>1){const j=Array.from(w.querySelectorAll("thead td[data-col]"));for(const U of j){const _=parseInt((T=U.getAttribute("data-col"))!=null?T:"0",10),Z=Ke({label:"\xD7",title:k("tableRemoveColumn",m),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Be(_)});Z.setAttribute("data-action","remove-col"),Z.setAttribute("data-col",String(_)),Z.style.position="absolute",Z.style.display="none",C.appendChild(Z),W.push(Z)}}if(B>1){const j=[...w.tHead?Array.from(w.tHead.rows):[],...w.tBodies[0]?Array.from(w.tBodies[0].rows):[]].filter(U=>U.querySelector("td[data-row]"));for(const U of j){const _=U.querySelector("td[data-row]");if(!_)continue;const Z=parseInt((A=_.getAttribute("data-row"))!=null?A:"0",10),O=Ke({label:"\xD7",title:k("tableRemoveRow",m),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>we(Z)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(Z)),O.style.position="absolute",O.style.display="none",C.appendChild(O),le.push(O)}}function D(j,U,_,Z,O){var ee;const Y=O?Array.from(w.querySelectorAll("thead td[data-col]")):[];let ie=-1,te=1/0,J=-1,he=-1,fe=1/0;for(let V=0;V<Y.length;V++){const ce=Y[V].getBoundingClientRect(),ve=(ce.left+ce.right)/2,ye=Math.abs(j-ve);ye<te&&(te=ye,ie=V);const $e=Math.abs(j-ce.right);$e<fe&&$e<20&&(fe=$e,J=ce.right-U.left+Z,he=parseInt((ee=Y[V].getAttribute("data-col"))!=null?ee:"0",10))}W.forEach((V,ce)=>{if(!O||ce!==ie){V.style.display="none";return}const ve=Y[ce].getBoundingClientRect(),ye=(ve.left+ve.right)/2-U.left+Z;V.style.left=`${ye-8}px`,V.style.top="2px",V.style.display="flex"}),O&&he>=0?(M.style.display="flex",M.style.left=`${J-10}px`,M.style.top=`${_.top-U.top-10}px`,M.dataset.afterCol=String(he)):M.style.display="none"}function F(j,U,_,Z,O){var ee;const Y=[];if(O){if(w.tHead)for(const V of Array.from(w.tHead.rows))V.querySelector("td[data-row]")&&Y.push(V);if(w.tBodies[0])for(const V of Array.from(w.tBodies[0].rows))V.querySelector("td[data-row]")&&Y.push(V)}let ie=-1,te=1/0,J=-1,he=-1,fe=1/0;for(let V=0;V<Y.length;V++){const ce=Y[V].getBoundingClientRect(),ve=(ce.top+ce.bottom)/2,ye=Math.abs(j-ve);ye<te&&(te=ye,ie=V);const $e=Math.abs(j-ce.bottom);if($e<fe&&$e<14){fe=$e,J=ce.bottom-U.top;const De=Y[V].querySelector("td[data-row]");he=parseInt((ee=De==null?void 0:De.getAttribute("data-row"))!=null?ee:"0",10)}}le.forEach((V,ce)=>{if(!O||ce!==ie){V.style.display="none";return}const ve=Y[ce].getBoundingClientRect(),ye=(ve.top+ve.bottom)/2-U.top;V.style.left="4px",V.style.top=`${ye-8}px`,V.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.top=`${J-10}px`,q.style.left=`${_.left-U.left+Z-10}px`,q.dataset.afterRow=String(he)):q.style.display="none"}let oe=!1;C.onmousemove=j=>{const U=j.target;if(U.tagName==="BUTTON"&&U.parentElement===C||oe)return;oe=!0;const _=j.clientX,Z=j.clientY;requestAnimationFrame(()=>{oe=!1;const O=C.getBoundingClientRect(),ee=w.getBoundingClientRect(),Y=C.scrollLeft,ie=Z>=O.top&&Z<ee.top+4,te=_>=O.left&&_<ee.left+4,J=Math.min(ee.right,O.right),he=_>J-20&&_<=O.right,fe=Z>ee.bottom-4&&Z<=O.bottom+20;if(D(_,O,ee,Y,ie),F(Z,O,ee,Y,te),re.style.display=he?"flex":"none",he&&(re.style.left=`${O.right-O.left+Y-20}px`,re.style.top=`${(ee.top+ee.bottom)/2-O.top-10}px`),ue.style.display=fe?"flex":"none",fe){const V=(O.left+O.right)/2-O.left+Y;ue.style.left=`${V-10}px`,ue.style.top=`${ee.bottom-O.top-10}px`}})},C.onmouseleave=()=>{W.forEach(j=>{j.style.display="none"}),le.forEach(j=>{j.style.display="none"}),M.style.display="none",q.style.display="none",re.style.display="none",ue.style.display="none"}}z()}function Ml(e){var t,n;return{cells:lr((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 Rl(e,t,n,r){var o,i,a,l;const s=t.state,d=se(e,s,t),c=t.prefill[e.key],u=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",f=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges";let m;if(Pt(c))m={cells:c.cells,merges:c.merges?Ve(c.merges):[]};else if(c&&Wt(c,u)){const p=c[f];m={cells:c[u],merges:p?Ve(p):[]}}else if(Pt(e.default))m={cells:e.default.cells,merges:e.default.merges?Ve(e.default.merges):[]};else if(e.default&&Wt(e.default,u)){const p=e.default[f];m={cells:e.default[u],merges:p?Ve(p):[]}}else m=Ml(e);if(m.merges&&m.merges.length>0){const p=m.cells.length,b=p>0?m.cells[0].length:0,v=Ut(m.merges,p,b);v&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${v})`),m={...m,merges:[]})}d?Ll(m,n):zl(e,m,r,t,n)}function Il(e,t,n){var r,o;const{scopeRoot:i,skipValidation:a}=n,l=[],s=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",d=i.querySelector(`[name="${t}"]`);if(!d)return{value:null,errors:l};let c;try{c=JSON.parse(d.value)}catch(u){return l.push(`${t}: invalid table data`),{value:null,errors:l}}if(!a&&e.required){const u=c[s];u!=null&&u.some(f=>f.some(m=>m.trim()!==""))||l.push(`${t}: ${k("required",n.state)}`)}return{value:c,errors:l}}function Nl(e,t,n,r){var o,i,a,l;const{scopeRoot:s}=r,d=(i=(o=e.fieldNames)==null?void 0:o.cells)!=null?i:"cells",c=(l=(a=e.fieldNames)==null?void 0:a.merges)!=null?l:"merges",u=s.querySelector(`[name="${t}"]`);if(!u){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let f=null;if(Pt(n))f={cells:n.cells,merges:n.merges?Ve(n.merges):[]};else if(n&&Wt(n,d)){const m=n[c];f={cells:n[d],merges:m?Ve(m):[]}}f&&u._applyExternalUpdate?u._applyExternalUpdate(f):u.value=JSON.stringify(n)}function ql(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 i=-1;const a=new ResizeObserver(l=>{var s,d,c,u,f;if(!e.isConnected){a.disconnect(),n.delete(a);return}const m=l[0],p=(f=(u=(d=(s=m==null?void 0:m.contentBoxSize)==null?void 0:s[0])==null?void 0:d.inlineSize)!=null?u:(c=m==null?void 0:m.contentRect)==null?void 0:c.width)!=null?f:0;p!==i&&(i=p,o())});a.observe(e),n.add(a)}function Vt(e,t){var n,r,o,i;const a=new Map,l=new Map;for(const s of e){const d=t.resourceIndex.get(s),c=(n=d==null?void 0:d.name)!=null?n:s;l.set(c,((r=l.get(c))!=null?r:0)+1)}for(const s of e){const d=t.resourceIndex.get(s),c=(o=d==null?void 0:d.name)!=null?o:s;((i=l.get(c))!=null?i:1)>1&&d?a.set(s,`${c} (${Lr(d.size)})`):a.set(s,c)}return a}function Kt(e){return e?e.type.startsWith("image/"):!1}function ar(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const i=n.get(o);i&&r.set(i,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function gt(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let i="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(i+=e[r+1],r+=2):(i+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:i}))}else if(r<n&&!/\s/.test(e[r])){const i=r;for(;r<n&&!/\s/.test(e[r]);)r++;const a=e.slice(i,r);t.push({start:o,end:r,raw:e.slice(o,r),name:a})}}else r++;return t}function Hl(e,t){if(t.size===0)return[];const n=gt(e),r=[];for(const o of n){const i=t.get(o.name);i&&r.push({start:o.start,end:o.end,name:o.name,rid:i})}return r}function Bl(e,t){const n=Hl(e,t);if(n.length===0)return e;let r="",o=0;for(const i of n)r+=e.slice(o,i.start),r+=`@${i.rid}`,o=i.end;return r+=e.slice(o),r}function sr(e,t,n){const r=Vt(t,n),o=new Map;for(const s of t){const d=r.get(s);d&&o.set(s,d)}const i=gt(e);if(i.length===0)return e;let a="",l=0;for(const s of i){a+=e.slice(l,s.start);const d=o.get(s.name);d?a+=_t(d):a+=s.raw,l=s.end}return a+=e.slice(l),a}function dr(e,t,n,r){if(Ce(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(i=>{var a;if(!i||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=i,l.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",Ce(e),e.appendChild(l)}).catch(i=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,i,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const i=document.createElement("span");i.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",i.textContent=n.name,o.appendChild(i)}e.appendChild(o)}}function ur(e,t,n,r){if(Ce(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const i=new FileReader;i.onload=a=>{var l;o.src=((l=a.target)==null?void 0:l.result)||""},i.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var i;if(!o||!e.isConnected)return;const a=document.createElement("img");a.alt=(i=n==null?void 0:n.name)!=null?i:t,a.src=o,a.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",Ce(e),e.appendChild(a)}).catch(o=>{var i,a;(a=(i=r.config).onThumbnailError)==null||a.call(i,o,t)})}function cr(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),i=n.top-r.height-8,a=n.bottom+8,l=i>=4?i:a;e.style.left=`${o}px`,e.style.top=`${Math.max(4,l)}px`}function fr(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=`
1252
+ position: fixed;
1253
+ z-index: 99999;
1254
+ background: #fff;
1255
+ border: 1px solid var(--fb-border-color, #d1d5db);
1256
+ border-radius: 8px;
1257
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1258
+ padding: 4px;
1259
+ pointer-events: none;
1260
+ min-width: 60px;
1261
+ max-width: 140px;
1262
+ `;const i=document.createElement("div");return i.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",ur(i,t,r,n),o.appendChild(i),document.body.appendChild(o),cr(o,e),o}function pr(e,t){var n,r;const{rid:o,state:i,isReadonly:a,onMention:l,onRemove:s}=t,d=i.resourceIndex.get(o),c=(n=d==null?void 0:d.name)!=null?n:o,u=document.createElement("div");u.className="fb-richinput-portal-tooltip fb-richinput-file-tooltip",u.style.cssText=`
1263
+ position: fixed;
1264
+ z-index: 99999;
1265
+ background: #fff;
1266
+ border: 1px solid var(--fb-border-color, #d1d5db);
1267
+ border-radius: 8px;
1268
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1269
+ padding: 4px;
1270
+ pointer-events: auto;
1271
+ min-width: 80px;
1272
+ max-width: 260px;
1273
+ `;const f=document.createElement("div");f.style.cssText="min-height: 60px; max-height: 120px; display: flex; align-items: center; justify-content: center;",ur(f,o,d,i),u.appendChild(f);const m=document.createElement("div");m.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);",m.textContent=c,u.appendChild(m);const p=document.createElement("div");p.style.cssText="display: flex; align-items: center; gap: 2px; padding: 3px 4px 2px; border-top: 1px solid var(--fb-border-color, #d1d5db); justify-content: center;";const b="background: none; border: none; cursor: pointer; padding: 3px 5px; border-radius: 4px; color: var(--fb-text-muted-color, #6b7280); display: flex; align-items: center; transition: background 0.1s, color 0.1s;",v=h=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-text-color, #111827)"},$=h=>{h.style.background="none",h.style.color="var(--fb-text-muted-color, #6b7280)"};if(!a&&l){const h=document.createElement("button");h.type="button",h.title="Mention",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>$(h)),h.addEventListener("click",g=>{g.stopPropagation(),l(),u.remove()}),p.appendChild(h)}if(i.config.downloadFile){const h=document.createElement("button");h.type="button",h.title="Download",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>$(h)),h.addEventListener("click",g=>{var x,E;g.stopPropagation(),(E=(x=i.config).downloadFile)==null||E.call(x,o,c)}),p.appendChild(h)}if((r=i.config.getDownloadUrl)!=null?r:i.config.getThumbnail){const h=document.createElement("button");h.type="button",h.title="Open in new window",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',h.addEventListener("mouseenter",()=>v(h)),h.addEventListener("mouseleave",()=>$(h)),h.addEventListener("click",g=>{var x,E,y,C;if(g.stopPropagation(),i.config.getDownloadUrl){const w=i.config.getDownloadUrl(o);w?window.open(w,"_blank"):(E=(x=i.config).getThumbnail)==null||E.call(x,o).then(R=>{R&&window.open(R,"_blank")}).catch(()=>{})}else(C=(y=i.config).getThumbnail)==null||C.call(y,o).then(w=>{w&&window.open(w,"_blank")}).catch(()=>{})}),p.appendChild(h)}if(!a&&s){const h=document.createElement("button");h.type="button",h.title="Remove",h.style.cssText=b,h.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',h.addEventListener("mouseenter",()=>{h.style.background="var(--fb-background-hover-color, #f3f4f6)",h.style.color="var(--fb-error-color, #ef4444)"}),h.addEventListener("mouseleave",()=>$(h)),h.addEventListener("click",g=>{g.stopPropagation(),u.remove(),s()}),p.appendChild(h)}return p.children.length>0&&u.appendChild(p),document.body.appendChild(u),cr(u,e),u}function mr(){return{element:null,hideTimer:null}}function vt(e,t=150){e.hideTimer===null&&(e.hideTimer=setTimeout(()=>{e.hideTimer=null,e.element&&(e.element.remove(),e.element=null)},t))}function yt(e){e.hideTimer!==null&&(clearTimeout(e.hideTimer),e.hideTimer=null)}function _e(e){return e&&e.remove(),null}function Dl(e){var t;const n=(t=e.selectionStart)!=null?t:0,r=e.value.slice(0,n);for(let o=r.length-1;o>=0;o--)if(r[o]==="@"){if(o===0||/\s/.test(r[o-1])){let i=r.slice(o+1);return i.startsWith('"')&&(i=i.slice(1)),{query:i,pos:o}}return null}return null}function hr(e,t,n){const r=e.toLowerCase();return t.filter(o=>{var i;return((i=n.get(o))!=null?i:o).toLowerCase().includes(r)})}const xt="font-size: var(--fb-font-size, 14px); font-family: var(--fb-font-family, inherit); line-height: 1.6;",br="padding: 8px 40px 8px 10px;";function Ol(e,t,n,r,o){var i,a;const l=t.state,s=[...o.files],d={open:!1,query:"",triggerPos:-1,selectedIndex:0},c=new AbortController,u=document.createElement("input");u.type="hidden",u.name=r;function f(){var S,I;const z=w.value,M=ar(s,l),q=z?Bl(z,M):null,W=(S=e.textKey)!=null?S:"text",le=(I=e.filesKey)!=null?I:"files";return{[W]:z===""?null:q,[le]:[...s]}}function m(){u.value=JSON.stringify(f())}const p=document.createElement("div");p.className="fb-richinput-wrapper",p.style.cssText=`
1274
+ position: relative;
1275
+ border: 1px solid var(--fb-border-color, #d1d5db);
1276
+ border-radius: 16px;
1277
+ background: var(--fb-background-color, #f9fafb);
1278
+ transition: box-shadow 0.15s, border-color 0.15s;
1279
+ `,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 b=document.createElement("div");b.className="fb-richinput-error",b.style.cssText="display: none; color: var(--fb-error-color, #ef4444); font-size: var(--fb-font-size-small, 12px); padding: 4px 10px 6px;";let v=null;function $(S){b.textContent=S,b.style.display="block",v&&clearTimeout(v),v=setTimeout(()=>{b.style.display="none",b.textContent="",v=null},5e3)}function h(S){var I;const z=Ne(e.accept);if(!Pe(S.name,z)){const q=z.join(", ");return $(k("invalidFileExtension",l,{name:S.name,formats:q})),!1}const M=(I=e.maxSize)!=null?I:1/0;return ut(S,M)?!0:($(k("fileTooLarge",l,{name:S.name,maxSize:M})),!1)}let g=0;p.addEventListener("dragenter",S=>{S.preventDefault(),g++,p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("dragover",S=>{S.preventDefault()}),p.addEventListener("dragleave",S=>{S.preventDefault(),g--,g<=0&&(g=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none")}),p.addEventListener("drop",S=>{var I,z;S.preventDefault(),g=0,p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none";const M=(I=S.dataTransfer)==null?void 0:I.files;if(!M||!l.config.uploadFile)return;const q=(z=e.maxFiles)!=null?z:1/0;for(let W=0;W<M.length;W++){if(s.length>=q){$(k("filesLimitExceeded",l,{skipped:M.length-W,max:q}));break}h(M[W])&&ge(M[W])}});const x=document.createElement("div");x.className="fb-richinput-files",x.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(S=>S.startsWith(".")?S:`.${S}`).join(","));const y=document.createElement("div");y.style.cssText="position: relative;";const C=document.createElement("div");C.className="fb-richinput-backdrop",C.style.cssText=`
1280
+ position: absolute;
1281
+ top: 0; left: 0; right: 0; bottom: 0;
1282
+ ${br}
1283
+ ${xt}
1284
+ white-space: pre-wrap;
1285
+ word-break: break-word;
1286
+ color: transparent;
1287
+ pointer-events: none;
1288
+ overflow: hidden;
1289
+ border-radius: inherit;
1290
+ box-sizing: border-box;
1291
+ z-index: 2;
1292
+ `;const w=document.createElement("textarea");w.name=`${r}__text`,w.placeholder=(i=e.placeholder)!=null?i:k("richinputPlaceholder",l);const R=(a=o.text)!=null?a:"";w.value=R?sr(R,s,l):"",w.style.cssText=`
1293
+ width: 100%;
1294
+ ${br}
1295
+ ${xt}
1296
+ background: transparent;
1297
+ border: none;
1298
+ outline: none;
1299
+ resize: none;
1300
+ color: var(--fb-text-color, #111827);
1301
+ box-sizing: border-box;
1302
+ position: relative;
1303
+ z-index: 1;
1304
+ caret-color: var(--fb-text-color, #111827);
1305
+ `,ql(w,C,t.state.autoExpandObservers),w.addEventListener("scroll",()=>{C.scrollTop=w.scrollTop});let G=null;C.addEventListener("mouseover",S=>{var I,z;const M=(z=(I=S.target).closest)==null?void 0:z.call(I,"mark");M!=null&&M.dataset.rid&&(G=_e(G),G=fr(M,M.dataset.rid,l))}),C.addEventListener("mouseout",S=>{var I,z,M;if(!((z=(I=S.target).closest)!=null&&z.call(I,"mark")))return;const q=S.relatedTarget;(M=q==null?void 0:q.closest)!=null&&M.call(q,"mark")||(G=_e(G))}),C.addEventListener("mousedown",S=>{var I,z;if(!((z=(I=S.target).closest)!=null&&z.call(I,"mark")))return;G=_e(G);const M=C.querySelectorAll("mark");M.forEach(W=>W.style.pointerEvents="none");const q=document.elementFromPoint(S.clientX,S.clientY);q&&q.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,clientX:S.clientX,clientY:S.clientY,button:S.button,buttons:S.buttons,detail:S.detail})),document.addEventListener("mouseup",()=>{M.forEach(W=>W.style.pointerEvents="auto")},{once:!0})});function K(){const S=w.value,I=ar(s,l),z=gt(S);if(z.length===0){C.innerHTML=de(S)+`
1306
+ `;return}let M="",q=0;for(const W of z){M+=de(S.slice(q,W.start));const le=I.get(W.name);le?M+=`<mark data-rid="${de(le)}" 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(S.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(S.slice(W.start,W.end))}</mark>`,q=W.end}M+=de(S.slice(q)),C.innerHTML=M+`
1307
+ `}const P=document.createElement("button");P.type="button",P.title=k("richinputAttachFile",l),P.style.cssText=`
1308
+ position: absolute;
1309
+ right: 6px;
1310
+ bottom: 6px;
1311
+ z-index: 2;
1312
+ width: 28px;
1313
+ height: 28px;
1314
+ border: none;
1315
+ border-radius: 6px;
1316
+ background: transparent;
1317
+ cursor: pointer;
1318
+ display: flex;
1319
+ align-items: center;
1320
+ justify-content: center;
1321
+ color: var(--fb-text-muted-color, #9ca3af);
1322
+ transition: color 0.15s, background 0.15s;
1323
+ `,P.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>',P.addEventListener("mouseenter",()=>{P.style.color="var(--fb-primary-color, #0066cc)",P.style.background="var(--fb-background-hover-color, #f3f4f6)"}),P.addEventListener("mouseleave",()=>{P.style.color="var(--fb-text-muted-color, #9ca3af)",P.style.background="transparent"}),P.addEventListener("click",()=>{var S;const I=(S=e.maxFiles)!=null?S:1/0;if(s.length>=I){$(k("filesLimitExceeded",l,{skipped:1,max:I}));return}E.click()});const H=document.createElement("div");H.className="fb-richinput-dropdown",H.style.cssText=`
1324
+ display: none;
1325
+ position: absolute;
1326
+ bottom: 100%;
1327
+ left: 0;
1328
+ z-index: 1000;
1329
+ background: #fff;
1330
+ border: 1px solid var(--fb-border-color, #d1d5db);
1331
+ border-radius: var(--fb-border-radius, 6px);
1332
+ box-shadow: 0 4px 12px rgba(0,0,0,0.12);
1333
+ min-width: 180px;
1334
+ max-width: 320px;
1335
+ max-height: 200px;
1336
+ overflow-y: auto;
1337
+ margin-bottom: 4px;
1338
+ ${xt}
1339
+ `;function Q(){return Vt(s,l)}function N(S){Ce(H);const I=Q();if(S.length===0){H.style.display="none",d.open=!1;return}S.forEach((z,M)=>{var q;const W=l.resourceIndex.get(z),le=document.createElement("div");le.className="fb-richinput-dropdown-item",le.dataset.rid=z,le.style.cssText=`
1340
+ padding: 5px 10px;
1341
+ cursor: pointer;
1342
+ color: var(--fb-text-color, #111827);
1343
+ background: ${M===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
1344
+ display: flex;
1345
+ align-items: center;
1346
+ gap: 8px;
1347
+ `;const re=document.createElement("div");if(re.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&&Kt(W)){const me=document.createElement("img");me.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const T=new FileReader;T.onload=A=>{var L;me.src=((L=A.target)==null?void 0:L.result)||""},T.readAsDataURL(W.file),re.appendChild(me)}else l.config.getThumbnail&&l.config.getThumbnail(z).then(me=>{if(!me||!re.isConnected)return;const T=document.createElement("img");T.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",T.src=me,Ce(re),re.appendChild(T)}).catch(()=>{}),re.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>';le.appendChild(re);const ue=document.createElement("span");ue.style.cssText="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",ue.textContent=(q=I.get(z))!=null?q:z,le.appendChild(ue),H.appendChild(le)}),H.onmousemove=z=>{var M,q,W;const le=(q=(M=z.target).closest)==null?void 0:q.call(M,".fb-richinput-dropdown-item");if(!le)return;const re=S.indexOf((W=le.dataset.rid)!=null?W:"");re===-1||re===d.selectedIndex||(H.querySelectorAll(".fb-richinput-dropdown-item").forEach((ue,me)=>{ue.style.background=me===re?"var(--fb-background-hover-color, #f3f4f6)":"transparent"}),d.selectedIndex=re)},H.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&&pe(W.dataset.rid)},H.style.display="block",d.open=!0}function X(){const S=Dl(w);if(!S){ae();return}d.query=S.query,d.triggerPos=S.pos,d.selectedIndex=0;const I=Q(),z=hr(S.query,s,I);N(z)}function ae(){H.style.display="none",d.open=!1}function pe(S){var I,z,M,q;const W=(M=(z=Q().get(S))!=null?z:(I=l.resourceIndex.get(S))==null?void 0:I.name)!=null?M:S,le=(q=w.selectionStart)!=null?q:0,re=w.value.slice(0,d.triggerPos),ue=w.value.slice(le),me=`${_t(W)} `;w.value=`${re}${me}${ue}`;const T=re.length+me.length;w.setSelectionRange(T,T),w.dispatchEvent(new Event("input")),ae()}w.addEventListener("input",()=>{var S;K(),m(),(S=t.instance)==null||S.triggerOnChange(r,f()),s.length>0?X():ae()});function xe(){H.querySelectorAll(".fb-richinput-dropdown-item").forEach((S,I)=>{S.style.background=I===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"})}w.addEventListener("keydown",S=>{if(!d.open)return;const I=Q(),z=hr(d.query,s,I);S.key==="ArrowDown"?(S.preventDefault(),d.selectedIndex=Math.min(d.selectedIndex+1,z.length-1),xe()):S.key==="ArrowUp"?(S.preventDefault(),d.selectedIndex=Math.max(d.selectedIndex-1,0),xe()):S.key==="Enter"&&z.length>0?(S.preventDefault(),pe(z[d.selectedIndex])):S.key==="Escape"&&ae()}),document.addEventListener("click",S=>{!p.contains(S.target)&&!H.contains(S.target)&&ae()},{signal:c.signal});function we(){if(Ce(x),s.length===0){x.style.display="none";return}x.style.display="flex",s.forEach(S=>{const I=l.resourceIndex.get(S),z=document.createElement("div");z.className="fb-richinput-file-thumb",z.style.cssText=`
1348
+ position: relative;
1349
+ width: 48px;
1350
+ height: 48px;
1351
+ border: 1px solid var(--fb-border-color, #d1d5db);
1352
+ border-radius: 8px;
1353
+ overflow: hidden;
1354
+ flex-shrink: 0;
1355
+ cursor: pointer;
1356
+ background: #fff;
1357
+ `;const M=document.createElement("div");M.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",dr(M,S,I,l),z.appendChild(M);const q=mr(),W=()=>{var re,ue,me;const T=(re=w.selectionStart)!=null?re:w.value.length,A=(me=(ue=Q().get(S))!=null?ue:I==null?void 0:I.name)!=null?me:S,L=w.value.slice(0,T),B=w.value.slice(T),D=`${L.length>0&&!/[\s\n]$/.test(L)?`
1358
+ `:""}${_t(A)} `;w.value=`${L}${D}${B}`;const F=T+D.length;w.setSelectionRange(F,F),w.focus(),w.dispatchEvent(new Event("input"))},le=()=>{var re;const ue=s.indexOf(S);ue!==-1&&s.splice(ue,1),we(),K(),m(),(re=t.instance)==null||re.triggerOnChange(r,f())};z.addEventListener("mouseenter",()=>{yt(q),q.element||(q.element=pr(z,{rid:S,state:l,isReadonly:!1,onMention:W,onRemove:le}),q.element.addEventListener("mouseenter",()=>{yt(q)}),q.element.addEventListener("mouseleave",()=>{vt(q)}))}),z.addEventListener("mouseleave",()=>{vt(q)}),x.appendChild(z)})}function ge(S){if(!l.config.uploadFile)return;const I=`temp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;l.resourceIndex.set(I,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),s.push(I),we();const z=x.querySelectorAll(".fb-richinput-file-thumb"),M=z[z.length-1];M&&(M.style.opacity="0.5"),l.config.uploadFile(S).then(q=>{var W;const le=s.indexOf(I);le!==-1&&(s[le]=q),l.resourceIndex.delete(I),l.resourceIndex.set(q,{name:S.name,type:S.type,size:S.size,uploadedAt:new Date,file:S}),we(),K(),m(),(W=t.instance)==null||W.triggerOnChange(r,f())}).catch(q=>{var W,le;const re=s.indexOf(I);re!==-1&&s.splice(re,1),l.resourceIndex.delete(I),we(),(le=(W=l.config).onUploadError)==null||le.call(W,q,S)})}if(E.addEventListener("change",()=>{var S;const I=E.files;if(!I||I.length===0)return;const z=(S=e.maxFiles)!=null?S:1/0;for(let M=0;M<I.length;M++){if(s.length>=z){$(k("filesLimitExceeded",l,{skipped:I.length-M,max:z}));break}h(I[M])&&ge(I[M])}E.value=""}),y.appendChild(C),y.appendChild(w),y.appendChild(P),y.appendChild(H),p.appendChild(x),p.appendChild(y),p.appendChild(b),e.minLength!=null||e.maxLength!=null){const S=document.createElement("div");S.style.cssText="position: relative; padding: 2px 10px 4px; text-align: right;";const I=at(e,w);I.style.cssText=`
1359
+ position: static;
1360
+ display: inline-block;
1361
+ font-size: var(--fb-font-size-small);
1362
+ color: var(--fb-text-secondary-color);
1363
+ pointer-events: none;
1364
+ `,S.appendChild(I),p.appendChild(S)}p.appendChild(u),p.appendChild(E),m(),K(),u._applyExternalUpdate=S=>{var I;const z=(I=S.text)!=null?I:"";w.value=z?sr(z,s,l):"",w.dispatchEvent(new Event("input")),s.length=0;for(const M of S.files)s.push(M);we(),K(),m()},n.appendChild(p),we();const Be=new MutationObserver(()=>{p.isConnected||(c.abort(),G=_e(G),Be.disconnect())});p.parentElement&&Be.observe(p.parentElement,{childList:!0})}function jl(e,t,n,r,o){var i,a;const l=t.state,{text:s,files:d}=o,c=new Map;for(const u of d){const f=l.resourceIndex.get(u);f!=null&&f.name&&c.set(u,f.name)}if(d.length>0){const u=document.createElement("div");u.style.cssText="display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px;",d.forEach(f=>{const m=l.resourceIndex.get(f),p=document.createElement("div");p.style.cssText=`
1365
+ position: relative;
1366
+ width: 48px; height: 48px;
1367
+ border: 1px solid var(--fb-border-color, #d1d5db);
1368
+ border-radius: 8px;
1369
+ overflow: hidden;
1370
+ flex-shrink: 0;
1371
+ background: #fff;
1372
+ cursor: default;
1373
+ `;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",dr(b,f,m,l),p.appendChild(b);const v=mr();p.addEventListener("mouseenter",()=>{yt(v),v.element||(v.element=pr(p,{rid:f,state:l,isReadonly:!0}),v.element.addEventListener("mouseenter",()=>{yt(v)}),v.element.addEventListener("mouseleave",()=>{vt(v)}))}),p.addEventListener("mouseleave",()=>{vt(v)}),u.appendChild(p)}),n.appendChild(u)}if(s){const u=document.createElement("div");u.style.cssText=`
1374
+ ${xt}
1375
+ color: var(--fb-text-color, #111827);
1376
+ white-space: pre-wrap;
1377
+ word-break: break-word;
1378
+ `;const f=gt(s).filter(m=>c.has(m.name)||[...c.values()].includes(m.name));if(f.length===0)u.textContent=s;else{let m=0;for(const p of f){p.start>m&&u.appendChild(document.createTextNode(s.slice(m,p.start)));const b=document.createElement("span");b.style.cssText=`
1379
+ display: inline;
1380
+ background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
1381
+ color: var(--fb-primary-color, #0066cc);
1382
+ border-radius: 8px;
1383
+ padding: 1px 6px;
1384
+ font-weight: 500;
1385
+ cursor: default;
1386
+ `;const v=c.has(p.name)?p.name:(i=[...c.entries()].find(([,h])=>h===p.name))==null?void 0:i[0],$=(a=c.get(p.name))!=null?a:p.name;if(b.textContent=`@${$}`,v){let h=null;const g=v;b.addEventListener("mouseenter",()=>{h=_e(h),h=fr(b,g,l)}),b.addEventListener("mouseleave",()=>{h=_e(h)})}u.appendChild(b),m=p.end}m<s.length&&u.appendChild(document.createTextNode(s.slice(m)))}n.appendChild(u)}if(!s&&d.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 Ul(e,t,n,r){var o,i,a,l;const s=t.state,d=se(e,s,t),c=(o=e.textKey)!=null?o:"text",u=(i=e.filesKey)!=null?i:"files";let f;if(e.flatOutput){const m=t.prefill[c],p=t.prefill[u];f={text:typeof m=="string"?m:null,files:Array.isArray(p)?p:[]}}else{const m=t.prefill[e.key];if(m&&typeof m=="object"&&!Array.isArray(m)){const p=m,b=(a=p[c])!=null?a:p.text,v=(l=p[u])!=null?l:p.files;f={text:typeof b=="string"?b:null,files:Array.isArray(v)?v:[]}}else typeof m=="string"?f={text:m||null,files:[]}:f={text:null,files:[]}}for(const m of f.files)s.resourceIndex.has(m)||s.resourceIndex.set(m,{name:m,type:"application/octet-stream",size:0,uploadedAt:new Date,file:void 0});if(d)jl(e,t,n,r,f);else{if(!s.config.uploadFile)throw new Error(`RichInput field "${e.key}" requires uploadFile handler in config`);Ol(e,t,n,r,f)}}function Pl(e,t,n){var r,o;const{scopeRoot:i,state:a,skipValidation:l}=n,s=[],d=(r=e.textKey)!=null?r:"text",c=(o=e.filesKey)!=null?o:"files",u=i.querySelector(`[name="${t}"]`);if(!u)return{value:null,errors:s};let f;try{const h=JSON.parse(u.value);if(h&&typeof h=="object"&&!Array.isArray(h))f=h;else return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}catch(h){return s.push(`${t}: invalid richinput data`),{value:null,errors:s}}const m=f[d],p=f[c],b=m===null||typeof m=="string"?m:null,v=Array.isArray(p)?p:[],$={[d]:b!=null?b:null,[c]:v};if(!l){const h=!b||b.trim()==="",g=v.length===0;e.required&&h&&g&&s.push(`${t}: ${k("required",a)}`),!h&&b&&(e.minLength!=null&&b.length<e.minLength&&s.push(`${t}: ${k("minLength",a,{min:e.minLength})}`),e.maxLength!=null&&b.length>e.maxLength&&s.push(`${t}: ${k("maxLength",a,{max:e.maxLength})}`)),e.maxFiles!=null&&v.length>e.maxFiles&&s.push(`${t}: ${k("maxFiles",a,{max:e.maxFiles})}`)}return{value:$,errors:s,spread:!!e.flatOutput}}function Wl(e,t,n,r){var o,i,a,l;const{scopeRoot:s}=r,d=s.querySelector(`[name="${t}"]`);if(!d){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",m=(i=e.filesKey)!=null?i:"files",p=(a=u[f])!=null?a:u.text,b=(l=u[m])!=null?l:u.files;(p!==void 0||b!==void 0)&&(c={text:typeof p=="string"?p:null,files:Array.isArray(b)?b:[]})}c&&d._applyExternalUpdate?d._applyExternalUpdate(c):c&&(d.value=JSON.stringify(c))}const Vl={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function gr(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function tt(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jt(e,t){const n=/((?:^|\n+)(?:\n---+|\*[ ]\*(?:[ ]\*)+)\n)|(?:^```[ ]*(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t|[ ]{2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|([ ]{2}\n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,r=[];let o="";const i=t||{};let a=0,l,s,d,c,u;function f(p){const b=Vl[p[1]||""],v=r[r.length-1]===p;return b?b[1]?(v?r.pop():r.push(p),b[v?1:0]):b[0]:p}function m(){let p="";for(;r.length;)p+=f(r[r.length-1]);return p}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,(p,b,v)=>(i[b.toLowerCase()]=v,"")).replace(/^\n+|\n+$/g,"");d=n.exec(e);)s=e.substring(a,d.index),a=n.lastIndex,l=d[0],s.match(/[^\\](\\\\)*\\$/)||((u=d[3]||d[4])?l='<pre class="code '+(d[4]?"poetry":d[2].toLowerCase())+'"><code'+(d[2]?` class="language-${d[2].toLowerCase()}"`:"")+">"+gr(tt(u).replace(/^\n+|\n+$/g,""))+"</code></pre>":(u=d[6])?(u.match(/\./)&&(d[5]=d[5].replace(/^\d+/gm,"")),c=Jt(gr(d[5].replace(/^\s*[>*+.-]/gm,""))),u===">"?u="blockquote":(u=u.match(/\./)?"ol":"ul",c=c.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),l="<"+u+">"+c+"</"+u+">"):d[8]?l=`<img src="${tt(d[8])}" alt="${tt(d[7])}">`:d[10]?(o=o.replace("<a>",`<a href="${tt(d[11]||i[s.toLowerCase()])}">`),l=m()+"</a>"):d[9]?l="<a>":d[12]||d[14]?(u="h"+(d[14]?d[14].length:d[13]>"="?1:2),l="<"+u+">"+Jt(d[12]||d[15],i)+"</"+u+">"):d[16]?l="<code>"+tt(d[16])+"</code>":(d[17]||d[1])&&(l=f(d[17]||"--"))),o+=s,o+=l;return(o+e.substring(a)+m()).replace(/^\n+|\n+$/g,"")}const vr="fb-markdown-styles";function Kl(){if(typeof document=="undefined"||document.getElementById(vr))return;const e=document.createElement("style");e.id=vr,e.setAttribute("data-fb-markdown-styles","true"),e.textContent=`
1387
+ .fb-markdown {
1388
+ font-family: var(--fb-font-family, inherit);
1389
+ font-size: var(--fb-font-size, 1rem);
1390
+ color: var(--fb-text-color, #1f2937);
1391
+ line-height: 1.6;
1392
+ }
1393
+ .fb-markdown h1,
1394
+ .fb-markdown h2,
1395
+ .fb-markdown h3,
1396
+ .fb-markdown h4,
1397
+ .fb-markdown h5,
1398
+ .fb-markdown h6 {
1399
+ font-weight: var(--fb-font-weight-medium, 600);
1400
+ color: var(--fb-text-color, #1f2937);
1401
+ margin-top: 0.75em;
1402
+ margin-bottom: 0.25em;
1403
+ }
1404
+ .fb-markdown h1 { font-size: 1.5rem; }
1405
+ .fb-markdown h2 { font-size: 1.25rem; }
1406
+ .fb-markdown h3 { font-size: 1.1rem; }
1407
+ .fb-markdown h4,
1408
+ .fb-markdown h5,
1409
+ .fb-markdown h6 { font-size: 1rem; }
1410
+ .fb-markdown p {
1411
+ margin-top: 0;
1412
+ margin-bottom: 0.5em;
1413
+ }
1414
+ .fb-markdown ul,
1415
+ .fb-markdown ol {
1416
+ margin: 0.25em 0 0.5em 1.5em;
1417
+ padding: 0;
1418
+ }
1419
+ .fb-markdown li {
1420
+ margin-bottom: 0.15em;
1421
+ }
1422
+ .fb-markdown a {
1423
+ color: var(--fb-primary-color, #2563eb);
1424
+ text-decoration: underline;
1425
+ }
1426
+ .fb-markdown a:hover {
1427
+ opacity: 0.8;
1428
+ }
1429
+ .fb-markdown code {
1430
+ background: var(--fb-input-background-color, #f3f4f6);
1431
+ border-radius: 3px;
1432
+ padding: 0.1em 0.35em;
1433
+ font-size: 0.9em;
1434
+ font-family: monospace;
1435
+ }
1436
+ .fb-markdown pre {
1437
+ background: var(--fb-input-background-color, #f3f4f6);
1438
+ border-radius: var(--fb-border-radius, 0.375rem);
1439
+ padding: 0.75em 1em;
1440
+ overflow-x: auto;
1441
+ margin: 0.5em 0;
1442
+ }
1443
+ .fb-markdown pre code {
1444
+ background: none;
1445
+ padding: 0;
1446
+ border-radius: 0;
1447
+ font-size: inherit;
1448
+ }
1449
+ .fb-markdown blockquote {
1450
+ border-left: 3px solid var(--fb-border-color, #d1d5db);
1451
+ margin: 0.5em 0;
1452
+ padding-left: 1em;
1453
+ color: var(--fb-text-secondary-color, #6b7280);
1454
+ }
1455
+ .fb-markdown hr {
1456
+ border: none;
1457
+ border-top: 1px solid var(--fb-border-color, #d1d5db);
1458
+ margin: 0.75em 0;
1459
+ }
1460
+ .fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
1461
+ .fb-markdown em { font-style: italic; }
1462
+ .fb-markdown s { text-decoration: line-through; }
1463
+ `,document.head.appendChild(e)}const _l=["javascript:","data:","vbscript:","blob:"],Jl=["javascript:","vbscript:","blob:"];function Xl(e){return!!(Jl.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Yl(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Gl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();_l.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();Xl(r)&&t.setAttribute("src","")})}function Zl(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})`);Kl();const r=document.createElement("div");r.className="fb-markdown";const o=Yl(e.content);return r.innerHTML=Jt(o),Gl(r),n.appendChild(r),r}function Ql(e,t,n){return{value:void 0,errors:[],skip:!0}}function ei(e,t,n,r){}function ti(e,t,n){var r;const{scopeRoot:o}=n,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);return{value:Zt((r=i==null?void 0:i.value)!=null?r:""),errors:[]}}function ni(e,t,n,r){const{scopeRoot:o}=r,i=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);i&&(i.value=Gt(n))}const yr={text:{validate:on,update:ln},textarea:{validate:jr,update:Ur},number:{validate:_r,update:Jr},select:{validate:Gr,update:Zr},switcher:{validate:no,update:ro},boolean:{validate:io,update:ao,ownsLabel:!0},file:{validate:Un,update:Wn},files:{validate:Un,update:Wn},colour:{validate:cl,update:fl},slider:{validate:hl,update:bl},container:{validate:nr,update:rr},group:{validate:Cl,update:El},table:{validate:Il,update:Nl},richinput:{validate:Pl,update:Wl},hidden:{validate:ti,update:ni},markdown:{validate:Ql,update:ei}};function xr(e){return yr[e]||null}function wr(e){return e.type!=="markdown"&&(e.type==="hidden"||e.hidden)?yr.hidden:xr(e.type)}function ri(e,t,n){const r=wr(e);return r&&r.validate?r.validate(e,t,n):null}function oi(e,t,n,r){const o=wr(e);return o&&o.update?(o.update(e,t,n,r),!0):!1}function li(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(),i=window.innerWidth,a=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const l=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let s=o.left,d=o.bottom+5;s+l.width>i&&(s=o.right-l.width),d+l.height>a&&(d=o.top-l.height-5),s<10&&(s=10),d<10&&(d=o.bottom+5),n.style.left=`${s}px`,n.style.top=`${d}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 Cr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const i=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},a=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!je(e.enableIf,i,a)}catch(i){console.error(`Error evaluating enableIf for field "${e.key}":`,i)}return!1}function ii(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 Qt(n)}}function ai(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let a=0;a<n.length-1;a++){const l=n[a],s=n[a+1],d=s.startsWith("[")&&s.endsWith("]")?[]:{};if(l.startsWith("[")&&l.endsWith("]")){const c=parseInt(l.slice(1,-1),10);o[c]=d}else o[l]=d;o=d}const i=n[n.length-1];return i.startsWith("[")&&i.endsWith("]")?o[parseInt(i.slice(1,-1),10)]=t:o[i]=t,r}function wt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=!n.path||n.path===""?"absolute":a,s=i.key,d=l==="relative"&&n.path?`${n.path}.${s}`:s,c=ii(d,o),u=ai(s,c),f=l==="relative"?{}:u,m=l==="relative"?u:void 0;try{je(i,f,m)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(p){console.error(`Error re-evaluating enableIf for field "${t.key}":`,p)}}function Er(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const i=t.enableIf,a=(r=i.scope)!=null?r:"relative",l=i.key;let s;a==="relative"&&n.path?s=`${n.path}.${l}`:s=l;const d=o.querySelector(`[name="${s}"]`);if(!d){const c=new MutationObserver(()=>{const u=o.querySelector(`[name="${s}"]`);u&&(u.addEventListener("change",()=>{wt(e,t,n)}),u.addEventListener("input",()=>{wt(e,t,n)}),c.disconnect(),n.state.enableIfObservers.delete(c))});n.state.enableIfObservers.add(c),c.observe(o,{childList:!0,subtree:!0});return}d.addEventListener("change",()=>{wt(e,t,n)}),d.addEventListener("input",()=>{wt(e,t,n)})}function si(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 di(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 ui(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>',di(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=i=>{i.preventDefault(),i.stopPropagation(),li(r,n)},n}function ci(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=si(e);if(n.appendChild(r),e.description||e.hint){const o=ui(e,t);n.appendChild(o)}return n}function fi(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?Br(e,t,n,r):Hr(e,t,n,r);break;case"textarea":o?Or(e,t,n,r):Dr(e,t,n,r);break;case"number":o?Kr(e,t,n,r):Vr(e,t,n,r);break;case"select":o?Yr(e,t,n,r):Xr(e,t,n,r);break;case"switcher":o?to(e,t,n,r):eo(e,t,n,r);break;case"boolean":lo(e,t,n,r);break;case"file":o?sl(e,t,n,r):il(e,t,n,r);break;case"files":al(e,t,n,r);break;case"colour":o?ul(e,t,n,r):dl(e,t,n,r);break;case"slider":o?ml(e,t,n,r):pl(e,t,n,r);break;case"group":wl(e,t,n,r);break;case"container":o?tr(e,t,n,r):er(e,t,n,r);break;case"table":Rl(e,t,n,r);break;case"richinput":Ul(e,t,n,r);break;default:{const i=document.createElement("div");i.className="text-red-500 text-sm",i.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(i)}}}function Xt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const s=document.createElement("div");return s.style.display="none",s.setAttribute("data-fb-hidden-markdown","true"),s}const a=Cr(e,t),l=document.createElement("div");return l.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,l.setAttribute("data-field-key",Et(e,t.state)),l.setAttribute("data-fb-width",e.width||"full"),Zl(e,t,l),a&&(l.style.display="none",l.classList.add("fb-field-wrapper-disabled"),l.setAttribute("data-conditionally-disabled","true")),Er(l,e,t),l}const n=Cr(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=xr(e.type);if(!(o!=null&&o.ownsLabel)){const a=ci(e,t.state);r.appendChild(a)}const i=Oe(t.path,e.key);return fi(e,t,r,i),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),Er(r,e,t),r}gl(Xt);const kr={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 $r(e,t){const n={...e};if(t)for(const[r,o]of Object.entries(t))n[r]={...e[r]||{},...o};return n}function pi(e){const t=$r(kr.translations,e==null?void 0:e.translations);return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...kr,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set,autoExpandObservers:new Set,tooltipElements:new Set}}function mi(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const Je={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 hi(e){const t={...Je,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const i=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${i}: ${o};`)}),n.join(`
1464
+ `)}function bi(e,t){Ir(e.ownerDocument||document);const n=hi(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=`
1465
+ [data-fb-root="true"] {
1466
+ ${n}
1467
+ }
1468
+ `}const gi={default:Je,dark:{...Je,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:{...Je,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:{...Je,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 Yt(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 Ct{constructor(t){this.prefillHintHandler=null,this.instanceId=mi(),this.state=pi(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){const n=$r(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 i of n.split(".")){if(r==null)return;const a=i.match(/^(.+)\[(\d+)\]$/);if(!a){o=o?`${o}.${i}`:i,r=r[i];continue}const l=a[1];o=o?`${o}.${l}`:l;const s=r[l];if(!Array.isArray(s))return;const d=this.state.formRoot?rt(this.state.formRoot,o):[];o=`${o}[${a[2]}]`;const c=d.findIndex(u=>u.getAttribute("data-container-item")===o);r=c>=0?s[c]:s[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 i of o){const a=r.label||r.key,l=i.querySelector("label");if(l&&(l.textContent===a||l.textContent===`${a}*`)){let s=i.querySelector(".field-placeholder");return s||(s=document.createElement("div"),s.className="field-placeholder",s.style.display="none",i.appendChild(s)),s}}return null}findSchemaElement(t){if(!this.state.schema||!this.state.schema.elements)return null;let n=this.state.schema.elements,r=null;const o=t.replace(/\[\d+\]/g,"").split(".").filter(Boolean);for(const i of o){if(r=n.find(a=>a.key===i)||null,!r)return null;"elements"in r&&r.elements&&(n=r.elements)}return r}resolveActionLabel(t,n,r,o=!1){if(r&&"actions"in r&&r.actions){const i=r.actions.find(a=>a.key===t);if(i&&i.label)return i.label}if(o&&this.state.schema&&"actions"in this.state.schema&&this.state.schema.actions){const i=this.state.schema.actions.find(a=>a.key===t);if(i&&i.label)return i.label}return n||t}renderFormLevelActions(t,n=[]){if(!this.state.formRoot)return;const r=this.state.formRoot.querySelector(".form-level-actions-container");r&&r.remove();const o=document.createElement("div");o.className="form-level-actions-container mt-3 pt-2 flex flex-wrap gap-2 justify-center",o.style.cssText=`
1469
+ border-top: var(--fb-border-width) solid var(--fb-border-color);
1470
+ `,t.forEach(i=>{const a=document.createElement("button");a.type="button",rn(a,!0);const l=n.includes(i),s=this.resolveActionLabel(i.key,i.label,null,l);a.textContent=s,a.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(i.value,i.key,null)}),o.appendChild(a)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(i=>{!i.key||!i.value||(i.related_field?(t.has(i.related_field)||t.set(i.related_field,[]),t.get(i.related_field).push(i)):n.push(i))}),t.forEach((i,a)=>{const l=this.findFormElementByFieldPath(a);if(!l){console.warn(`External action: Could not find form element for field "${a}", treating as form-level actions`),r.push(...i);return}let s=l.closest(".fb-field-wrapper");if(s||(s=l.parentElement),!s){console.warn(`External action: Could not find wrapper for field "${a}"`);return}const d=s.querySelector(".external-actions-container");d&&d.remove();const c=document.createElement("div");c.className="external-actions-container mt-3 flex flex-wrap gap-2";const u=this.findSchemaElement(a);i.forEach(f=>{const m=document.createElement("button");m.type="button",rn(m,!1);const p=this.resolveActionLabel(f.key,f.label,u);m.textContent=p,m.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(f.value,f.key,f.related_field)}),c.appendChild(m)}),s.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",i=n.getAttribute("data-container-key");if(!r||!o&&!i){console.warn("Prefill hint missing required data attributes");return}try{const a=JSON.parse(r);for(const s in a){const d=o?s:`${i}.${s}`,c=a[s];this.updateField(d,c)}const l=n.closest(".fb-prefill-hints");l&&l.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(s=>s.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(a){console.error("Error parsing prefill hint values:",a)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const i=$t(n);if(i.length>0)throw new Error(`renderForm: invalid schema:
1471
+ - ${i.join(`
1472
+ - `)}`);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||{},Ce(t),t.setAttribute("data-fb-root","true"),bi(t,this.state.config.theme);const a=document.createElement("div");if(a.className="fb-row",n.prefillHints&&!this.state.config.readonly){const d=this.createRootPrefillHints(n.prefillHints);a.appendChild(d)}const l=document.createElement("div"),s=n.columns||1;s===1?l.className="fb-row":l.className=`grid grid-cols-${s} gap-2`,n.elements.forEach(d=>{var c;if(d.type!=="markdown"&&(d.hidden||d.type==="hidden")){const f=r&&d.key in r?r[d.key]:(c=d.default)!=null?c:null;l.appendChild(kt(d.key,f));return}const u=Xt(d,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});l.appendChild(u)}),a.appendChild(l),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){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(i,a,l=null)=>{var s;const d=(s=i.key)!=null?s:"",c={scopeRoot:l||this.state.formRoot,state:this.state,instance:this,path:a.path,skipValidation:t,validateElement:o},u=ri(i,d,c);return u!==null?(n.push(...u.errors),{value:u.value,spread:!!u.spread,skip:!!u.skip}):(console.warn(`Unknown field type "${i.type}" for key "${d}"`),{value:null,spread:!1})};return this.state.schema.elements.forEach(i=>{if(i.enableIf)try{if(!je(i.enableIf,r))return}catch(l){console.error(`Error evaluating enableIf for field "${i.key}" during validation:`,l)}if(i.type==="markdown")return;const a=o(i,{path:""});a.skip||(a.spread&&a.value!==null&&typeof a.value=="object"?Object.assign(r,a.value):i.key&&(r[i.key]=a.value))}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&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 i=r,a=this.buildHiddenFieldsData(i.elements);Object.keys(a).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...a}):n[o]=a)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const i of t)if(i.type==="richinput"&&i.flatOutput){const a=i,l=(n=a.textKey)!=null?n:"text",s=(r=a.filesKey)!=null?r:"files";o.set(l,{schemaKey:i.key,role:"text"}),o.set(s,{schemaKey:i.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const i=n.get(o);i?(r.has(i.schemaKey)||r.set(i.schemaKey,{}),r.get(i.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,i]of r)this.updateField(o,i)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const i={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};oi(n,r,o,i)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=Et(t,this.state);if(!n)return Yt(r,o,null);const i=n.match(/^(.+)\[(\d+)\]$/);if(i){const l=r.querySelector(`[data-container-item="${i[1]}[${i[2]}]"]`);return l?Yt(l,o,l):null}const a=r.querySelector(`[data-container="${n}"]`);return a?Yt(a,o,a):null}applyEnableIfVisibility(t,n,r,o,i,a){var l,s,d,c;try{const u=((l=t.enableIf.scope)!=null?l:"relative")==="relative"&&o?ot(a,o):void 0,f=je(t.enableIf,a,u),m=n.getAttribute("data-conditionally-disabled")==="true";if(f&&m){const p=o?ot(a,o):a,b=Xt(t,{path:r,prefill:p&&typeof p=="object"?p:{},formData:a,state:this.state,instance:this});(s=n.parentNode)==null||s.replaceChild(b,n)}else if(!f&&!m){const p=document.createElement("div");p.className="fb-field-wrapper-disabled",p.style.display="none",p.setAttribute("data-field-key",Et(t,this.state)),p.setAttribute("data-conditionally-disabled","true"),(d=n.parentNode)==null||d.replaceChild(p,n)}}catch(u){console.error(`Error re-evaluating enableIf for field "${(c=t.key)!=null?c:"<no key>"}" at path "${i}":`,u)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,i)=>{r.forEach(a=>{var l;const s=(l=a.key)!=null?l:"",d=o?`${o}.${s}`:s,c=i?`${i}.${s}`:s;if(a.enableIf){const u=this.findFieldWrapper(a,o);u&&this.applyEnableIfVisibility(a,u,o,i,d,t)}if((a.type==="container"||a.type==="group")&&"elements"in a&&a.elements){const u=a.key?ot(t,c):void 0;Array.isArray(u)?rt(this.state.formRoot,d).forEach((f,m)=>{const p=f.getAttribute("data-container-item")||"";n(a.elements,p,`${c}[${m}]`)}):n(a.elements,d,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&&Ce(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 Sr(e){return new Ct(e)}return typeof window!="undefined"&&(window.FormBuilder=Ct,window.createFormBuilder=Sr,window.validateSchema=$t),Fe.FormBuilderInstance=Ct,Fe.createFormBuilder=Sr,Fe.default=Ct,Fe.defaultTheme=Je,Fe.exampleThemes=gi,Fe.validateSchema=$t,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});