@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.
- package/README.md +7 -1
- package/dist/browser/formbuilder.min.js +136 -154
- package/dist/browser/formbuilder.v0.6.4.min.js +1472 -0
- package/dist/cjs/index.cjs +423 -445
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +368 -394
- package/dist/esm/index.js.map +1 -1
- package/dist/form-builder.js +136 -154
- package/dist/types/components/container.d.ts +0 -7
- package/dist/types/components/index.d.ts +1 -2
- package/dist/types/instance/FormBuilderInstance.d.ts +17 -4
- package/dist/types/instance/state.d.ts +8 -0
- package/dist/types/types/component-operations.d.ts +15 -0
- package/dist/types/types/config.d.ts +2 -0
- package/dist/types/types/state.d.ts +8 -0
- package/dist/types/utils/helpers.d.ts +18 -1
- package/dist/types/utils/styles.d.ts +13 -7
- package/package.json +1 -1
- package/dist/browser/formbuilder.v0.5.4.min.js +0 -1490
package/dist/form-builder.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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=`
|
|
2
6
|
[data-fb-slide-card] {
|
|
3
7
|
background: var(--fb-slide-card-bg);
|
|
4
8
|
box-shadow: var(--fb-slide-card-shadow);
|
|
@@ -110,7 +114,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
110
114
|
/* .fb-size-md uses defaults \u2014 no override needed */
|
|
111
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; }
|
|
112
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; }
|
|
113
|
-
`,e.head.appendChild(t)}function
|
|
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=`
|
|
114
118
|
flex: 1 1 auto;
|
|
115
119
|
display: inline-flex;
|
|
116
120
|
align-items: center;
|
|
@@ -126,12 +130,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
126
130
|
font-family: var(--fb-font-family);
|
|
127
131
|
cursor: pointer;
|
|
128
132
|
transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
|
|
129
|
-
`,
|
|
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=`
|
|
130
134
|
margin-left: auto;
|
|
131
135
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
132
136
|
color: var(--fb-text-secondary-color);
|
|
133
137
|
font-weight: 400;
|
|
134
|
-
`,
|
|
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=`
|
|
135
139
|
display: flex;
|
|
136
140
|
flex-direction: column;
|
|
137
141
|
align-items: center;
|
|
@@ -150,7 +154,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
150
154
|
font-family: var(--fb-font-family);
|
|
151
155
|
cursor: pointer;
|
|
152
156
|
transition: border-color var(--fb-transition-duration), color var(--fb-transition-duration), background-color var(--fb-transition-duration);
|
|
153
|
-
`;const
|
|
157
|
+
`;const i=document.createElement("span");if(i.className="fb-slide-add-circle",i.style.cssText=`
|
|
154
158
|
display: inline-flex;
|
|
155
159
|
align-items: center;
|
|
156
160
|
justify-content: center;
|
|
@@ -163,12 +167,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
163
167
|
line-height: 1;
|
|
164
168
|
color: inherit;
|
|
165
169
|
transition: inherit;
|
|
166
|
-
`,
|
|
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=`
|
|
167
171
|
margin-left: auto;
|
|
168
172
|
font-size: var(--fb-font-size-small, 0.875rem);
|
|
169
173
|
color: var(--fb-text-secondary-color);
|
|
170
174
|
font-weight: 400;
|
|
171
|
-
`,{tile:o,counter:
|
|
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=`
|
|
172
176
|
background-color: var(--fb-action-bg-color);
|
|
173
177
|
color: var(--fb-action-text-color);
|
|
174
178
|
border: var(--fb-border-width) solid var(--fb-action-border-color);
|
|
@@ -178,7 +182,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
178
182
|
border-radius: var(--fb-border-radius);
|
|
179
183
|
transition: all var(--fb-transition-duration);
|
|
180
184
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
181
|
-
`,e.addEventListener("mouseenter",()=>{e.style.backgroundColor="var(--fb-action-hover-bg-color)",e.style.borderColor="var(--fb-action-hover-border-color)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="var(--fb-action-bg-color)",e.style.borderColor="var(--fb-action-border-color)"})}function
|
|
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=`
|
|
182
186
|
.fb-chip-list { display: flex; flex-direction: column; gap: 2px; }
|
|
183
187
|
.fb-chip {
|
|
184
188
|
display: flex;
|
|
@@ -243,7 +247,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
243
247
|
background: var(--fb-background-hover-color, #f1f5f9);
|
|
244
248
|
}
|
|
245
249
|
.fb-chip-remove:disabled { opacity: 0 !important; pointer-events: none; }
|
|
246
|
-
`,e.head.appendChild(t)}function
|
|
250
|
+
`,e.head.appendChild(t)}function at(e,t){const n=document.createElement("span");n.className="char-counter",n.style.cssText=`
|
|
247
251
|
margin-top: 4px;
|
|
248
252
|
padding-right: 12px;
|
|
249
253
|
text-align: right;
|
|
@@ -252,11 +256,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
252
256
|
color: var(--fb-error-color);
|
|
253
257
|
pointer-events: none;
|
|
254
258
|
display: none;
|
|
255
|
-
`;const r=()=>{const o=t.value.length,
|
|
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=`
|
|
256
260
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
257
261
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
258
262
|
border-radius: var(--fb-border-radius);
|
|
259
|
-
background-color: ${
|
|
263
|
+
background-color: ${s?"var(--fb-background-readonly-color)":"var(--fb-background-color)"};
|
|
260
264
|
color: var(--fb-text-color);
|
|
261
265
|
font-size: var(--fb-font-size);
|
|
262
266
|
font-family: var(--fb-font-family);
|
|
@@ -268,35 +272,31 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
268
272
|
overflow: hidden;
|
|
269
273
|
word-break: break-word;
|
|
270
274
|
overflow-wrap: anywhere;
|
|
271
|
-
`,
|
|
272
|
-
color: var(--fb-error-color);
|
|
273
|
-
font-size: var(--fb-font-size-small);
|
|
274
|
-
margin-top: 0.25rem;
|
|
275
|
-
`;const h=((p=d.closest)==null?void 0:p.call(d,".fb-chip"))||d;h.nextSibling?(m=h.parentNode)==null||m.insertBefore(E,h.nextSibling):(b=h.parentNode)==null||b.appendChild(E)}E.textContent=u,E.style.display="block"}else d.classList.remove("invalid"),d.title="",E&&E.remove()},f=(d,u,p)=>{let m=!1;const{state:b}=n;if(!c&&u){if(e.minLength!==void 0&&e.minLength!==null&&u.length<e.minLength){const g=k("minLength",b,{min:e.minLength});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(e.maxLength!==void 0&&e.maxLength!==null&&u.length>e.maxLength){const g=k("maxLength",b,{max:e.maxLength});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(e.pattern)try{if(!new RegExp(e.pattern).test(u)){const g=k("patternMismatch",b);l.push(`${p}: ${g}`),s(d,g),m=!0}}catch(g){const E=k("invalidPattern",b);l.push(`${p}: ${E}`),s(d,E),m=!0}}m||s(d,null)};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["]`),u=[],p=[];if(d.forEach((m,b)=>{var g;const E=(g=m==null?void 0:m.value)!=null?g:"";p.push(E),u.push(E===""?null:E),f(m,E,`${t}[${b}]`)}),!c){const{state:m}=n,b=(r=e.minCount)!=null?r:0,g=(o=e.maxCount)!=null?o:1/0,E=p.filter(h=>h.trim()!=="");e.required&&E.length===0&&l.push(`${t}: ${k("required",m)}`),E.length<b&&l.push(`${t}: ${k("minItems",m,{min:b})}`),E.length>g&&l.push(`${t}: ${k("maxItems",m,{max:g})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"]`),u=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&u===""){const p=k("required",n.state);return l.push(`${t}: ${p}`),s(d,p),{value:null,errors:l}}return d&&f(d,u,t),{value:u===""?null:u,errors:l}}}function rn(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateTextField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.classList.remove("invalid"),l.title="",Ce(l),l.dispatchEvent(new Event("input",{bubbles:!0})))}),n.length!==a.length&&console.warn(`updateTextField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="",Ce(a),a instanceof HTMLTextAreaElement&&a.dispatchEvent(new Event("input",{bubbles:!0})))}}function Mr(e,t,n,r){var o,a;const l=t.state,i=ae(e,l,t),c=document.createElement("div");c.style.cssText="position: relative;";const s=document.createElement("textarea");if(s.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",s.style.cssText=`
|
|
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
276
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
277
277
|
font-size: var(--fb-font-size);
|
|
278
278
|
font-family: var(--fb-font-family);
|
|
279
279
|
line-height: var(--fb-line-height, 1.5);
|
|
280
|
-
`,
|
|
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
281
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
282
282
|
font-size: var(--fb-font-size);
|
|
283
283
|
font-family: var(--fb-font-family);
|
|
284
284
|
line-height: var(--fb-line-height, 1.5);
|
|
285
|
-
`,
|
|
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
286
|
.fb-stepper-input::-webkit-outer-spin-button,
|
|
287
287
|
.fb-stepper-input::-webkit-inner-spin-button {
|
|
288
288
|
-webkit-appearance: none;
|
|
289
289
|
margin: 0;
|
|
290
290
|
}
|
|
291
291
|
.fb-stepper-input { -moz-appearance: textfield; }
|
|
292
|
-
`,e.head.appendChild(n)}function
|
|
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
293
|
display: inline-flex;
|
|
294
294
|
align-items: stretch;
|
|
295
295
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
296
296
|
border-radius: var(--fb-border-radius);
|
|
297
297
|
overflow: hidden;
|
|
298
298
|
background: var(--fb-background-color);
|
|
299
|
-
`;const
|
|
299
|
+
`;const s=(d,c)=>{const u=document.createElement("button");return u.type="button",u.textContent=d,u.tabIndex=-1,u.style.cssText=`
|
|
300
300
|
width: 32px;
|
|
301
301
|
border: none;
|
|
302
302
|
background: transparent;
|
|
@@ -305,7 +305,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
305
305
|
font-family: var(--fb-font-family);
|
|
306
306
|
cursor: ${n?"default":"pointer"};
|
|
307
307
|
user-select: none;
|
|
308
|
-
`,n?(
|
|
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
309
|
width: 56px;
|
|
310
310
|
border: none;
|
|
311
311
|
border-left: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -318,7 +318,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
318
318
|
color: var(--fb-text-color);
|
|
319
319
|
-moz-appearance: textfield;
|
|
320
320
|
box-sizing: border-box;
|
|
321
|
-
`,
|
|
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
322
|
position: absolute;
|
|
323
323
|
top: 50%;
|
|
324
324
|
transform: translateY(-50%);
|
|
@@ -328,35 +328,27 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
328
328
|
pointer-events: none;
|
|
329
329
|
background: var(--fb-background-color);
|
|
330
330
|
padding: 0 4px;
|
|
331
|
-
`;const r=e.min,o=e.max;let
|
|
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
332
|
padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
333
333
|
font-size: var(--fb-font-size);
|
|
334
334
|
font-family: var(--fb-font-family);
|
|
335
335
|
width: 100%;
|
|
336
336
|
box-sizing: border-box;
|
|
337
|
-
`),!
|
|
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
338
|
padding: var(--fb-input-padding-y) 60px var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
339
339
|
font-size: var(--fb-font-size);
|
|
340
340
|
font-family: var(--fb-font-family);
|
|
341
341
|
width: 100%;
|
|
342
342
|
box-sizing: border-box;
|
|
343
|
-
`,w.placeholder=e.placeholder
|
|
344
|
-
color: var(--fb-error-color);
|
|
345
|
-
font-size: var(--fb-font-size-small);
|
|
346
|
-
margin-top: 0.25rem;
|
|
347
|
-
`,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=u,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,u,p)=>{let m=!1;const{state:b}=n;if(!c&&e.min!==void 0&&e.min!==null&&u<e.min){const g=k("minValue",b,{min:e.min});l.push(`${p}: ${g}`),s(d,g),m=!0}else if(!c&&e.max!==void 0&&e.max!==null&&u>e.max){const g=k("maxValue",b,{max:e.max});l.push(`${p}: ${g}`),s(d,g),m=!0}m||s(d,null)};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["]`),u=[];if(d.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"";if(g===""){u.push(null),s(p,null);return}const E=parseFloat(g);if(!c&&!Number.isFinite(E)){const h=k("notANumber",n.state);l.push(`${t}[${m}]: ${h}`),s(p,h),u.push(null);return}f(p,E,`${t}[${m}]`),u.push(ln(E,e.decimals))}),!c){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=u.filter(E=>E!==null);e.required&&g.length===0&&l.push(`${t}: ${k("required",p)}`),g.length<m&&l.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&l.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"]`),u=(a=d==null?void 0:d.value)!=null?a:"",{state:p}=n;if(!c&&e.required&&u===""){const b=k("required",p);return l.push(`${t}: ${b}`),s(d,b),{value:null,errors:l}}if(u==="")return s(d,null),{value:null,errors:l};const m=parseFloat(u);if(!c&&!Number.isFinite(m)){const b=k("notANumber",p);return l.push(`${t}: ${b}`),s(d,b),{value:null,errors:l}}return f(d,m,t),{value:ln(m,e.decimals),errors:l}}}function ln(e,t){return!Number.isInteger(t)||t<0?e:Number(e.toFixed(t))}function Or(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateNumberField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.classList.remove("invalid"),l.title="",Ce(l))}),n.length!==a.length&&console.warn(`updateNumberField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.classList.remove("invalid"),a.title="",Ce(a))}}function Ur(e,t,n,r){const o=t.state,a=ae(e,o,t),l=document.createElement("select");if(l.className="w-full border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",l.style.cssText=`
|
|
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=`
|
|
348
344
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
349
345
|
font-size: var(--fb-font-size);
|
|
350
346
|
font-family: var(--fb-font-family);
|
|
351
|
-
`,l.name=r,l.disabled=a,(e
|
|
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=`
|
|
352
348
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
353
349
|
font-size: var(--fb-font-size);
|
|
354
350
|
font-family: var(--fb-font-family);
|
|
355
|
-
`,
|
|
356
|
-
color: var(--fb-error-color);
|
|
357
|
-
font-size: var(--fb-font-size-small);
|
|
358
|
-
margin-top: 0.25rem;
|
|
359
|
-
`,s.nextSibling?(d=s.parentNode)==null||d.insertBefore(m,s.nextSibling):(u=s.parentNode)==null||u.appendChild(m)),m.textContent=f,m.style.display="block"):(s.classList.remove("invalid"),s.title="",m&&m.remove())},c=(s,f,d,u)=>{var p,m;if(l)return;const{state:b}=n,g=f.filter(u),E="minCount"in d&&(p=d.minCount)!=null?p:0,h="maxCount"in d&&(m=d.maxCount)!=null?m:1/0;d.required&&g.length===0&&o.push(`${s}: ${k("required",b)}`),g.length<E&&o.push(`${s}: ${k("minItems",b,{min:E})}`),g.length>h&&o.push(`${s}: ${k("maxItems",b,{max:h})}`)};if("multiple"in e&&e.multiple){const s=a.querySelectorAll(`[name^="${t}\\["]`),f=[];return s.forEach(d=>{var u;const p=(u=d==null?void 0:d.value)!=null?u:"";f.push(p),i(d,null)}),c(t,f,e,d=>d!==""),{value:f,errors:o}}else{const s=a.querySelector(`[name="${t}"]`),f=(r=s==null?void 0:s.value)!=null?r:"";if(!l&&e.required&&f===""){const d=k("required",n.state);return o.push(`${t}: ${d}`),i(s,d),{value:null,errors:o}}else i(s,null);return{value:f===""?null:f,errors:o}}}function Vr(e,t,n,r){const{scopeRoot:o}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSelectField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}\\["]`);a.forEach((l,i)=>{i<n.length&&(l.value=n[i]!=null?String(n[i]):"",l.querySelectorAll("option").forEach(c=>{c.selected=c.value===String(n[i])}),l.classList.remove("invalid"),l.title="",Ce(l))}),n.length!==a.length&&console.warn(`updateSelectField: Multiple field "${t}" has ${a.length} selects but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"]`);a&&(a.value=n!=null?String(n):"",a.querySelectorAll("option").forEach(l=>{l.selected=l.value===String(n)}),a.classList.remove("invalid"),a.title="",Ce(a))}}function it(e,t){t?(e.style.backgroundColor="var(--fb-primary-soft-color)",e.style.color="var(--fb-primary-color)",e.style.borderColor="var(--fb-primary-color)"):(e.style.backgroundColor="var(--fb-primary-color)",e.style.color="#ffffff",e.style.borderColor="var(--fb-primary-color)")}function at(e,t){e.style.backgroundColor=t?"var(--fb-background-color)":"transparent",e.style.color="var(--fb-text-color)",e.style.borderColor="var(--fb-border-color)"}function an(e){return e.classList.contains("fb-switcher-preset")}function Kr(e,t){const n=document.createElement("button");if(n.type="button",n.className="fb-switcher-btn fb-switcher-preset",n.dataset.value=e.value,n.style.cssText=`
|
|
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=`
|
|
360
352
|
display: inline-flex;
|
|
361
353
|
align-items: center;
|
|
362
354
|
gap: 8px;
|
|
@@ -381,7 +373,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
381
373
|
font-size: var(--fb-font-size-small);
|
|
382
374
|
opacity: 0.7;
|
|
383
375
|
font-variant-numeric: tabular-nums;
|
|
384
|
-
`,n.appendChild(o)}return n}function
|
|
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?`
|
|
385
377
|
display: flex;
|
|
386
378
|
flex-direction: row;
|
|
387
379
|
flex-wrap: wrap;
|
|
@@ -390,7 +382,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
390
382
|
display: inline-flex;
|
|
391
383
|
flex-direction: row;
|
|
392
384
|
flex-wrap: nowrap;
|
|
393
|
-
`;const
|
|
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=`
|
|
394
386
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
395
387
|
font-size: var(--fb-font-size);
|
|
396
388
|
border-width: var(--fb-border-width);
|
|
@@ -400,21 +392,17 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
400
392
|
white-space: nowrap;
|
|
401
393
|
line-height: 1.25;
|
|
402
394
|
outline: none;
|
|
403
|
-
`,
|
|
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=`
|
|
404
396
|
color: var(--fb-error-color);
|
|
405
397
|
background-color: transparent;
|
|
406
398
|
transition: background-color var(--fb-transition-duration);
|
|
407
|
-
`,
|
|
408
|
-
color: var(--fb-error-color);
|
|
409
|
-
font-size: var(--fb-font-size-small);
|
|
410
|
-
margin-top: 0.25rem;
|
|
411
|
-
`,f.nextSibling?(u=f.parentNode)==null||u.insertBefore(b,f.nextSibling):(p=f.parentNode)==null||p.appendChild(b)),b.textContent=d,b.style.display="block"):(f.classList.remove("invalid"),f.title="",b&&b.remove())},c=(f,d,u,p)=>{var m,b;if(l)return;const{state:g}=n,E=d.filter(p),h="minCount"in u&&(m=u.minCount)!=null?m:0,y="maxCount"in u&&(b=u.maxCount)!=null?b:1/0;u.required&&E.length===0&&o.push(`${f}: ${k("required",g)}`),E.length<h&&o.push(`${f}: ${k("minItems",g,{min:h})}`),E.length>y&&o.push(`${f}: ${k("maxItems",g,{max:y})}`)},s=new Set("options"in e?e.options.map(f=>f.value):[]);if("multiple"in e&&e.multiple){const f=a.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`),d=[];return f.forEach(u=>{var p;const m=(p=u==null?void 0:u.value)!=null?p:"";if(d.push(m),!l&&m!==""&&!s.has(m)){const b=k("invalidOption",n.state);i(u,b),o.push(`${t}: ${b}`)}else i(u,null)}),c(t,d,e,u=>u!==""),{value:d,errors:o}}else{const f=a.querySelector(`input[type="hidden"][name="${t}"]`),d=(r=f==null?void 0:f.value)!=null?r:"";if(!l&&e.required&&d===""){const u=k("required",n.state);return o.push(`${t}: ${u}`),i(f,u),{value:null,errors:o}}if(!l&&d!==""&&!s.has(d)){const u=k("invalidOption",n.state);return o.push(`${t}: ${u}`),i(f,u),{value:null,errors:o}}return i(f,null),{value:d===""?null:d,errors:o}}}function Yr(e,t,n,r){var o;const{scopeRoot:a}=r;if("multiple"in e&&e.multiple){if(!Array.isArray(n)){console.warn(`updateSwitcherField: Expected array for multiple field "${t}", got ${typeof n}`);return}const l=a.querySelectorAll(`input[type="hidden"][name^="${t}\\["]`);l.forEach((i,c)=>{var s;if(c<n.length){const f=n[c]!=null?String(n[c]):"";i.value=f;const d=(s=i.parentElement)==null?void 0:s.querySelector(".fb-switcher-group");d&&d.querySelectorAll(".fb-switcher-btn").forEach(u=>{const p=an(u);u.dataset.value===f?it(u,p):at(u,p)}),i.classList.remove("invalid"),i.title="",Ce(i)}}),n.length!==l.length&&console.warn(`updateSwitcherField: Multiple field "${t}" has ${l.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const l=a.querySelector(`input[type="hidden"][name="${t}"]`);if(l){const i=n!=null?String(n):"";l.value=i;const c=(o=l.parentElement)==null?void 0:o.querySelector(".fb-switcher-group");c&&c.querySelectorAll(".fb-switcher-btn").forEach(s=>{const f=an(s);s.dataset.value===i?it(s,f):at(s,f)}),l.classList.remove("invalid"),l.title="",Ce(l)}}}const cn=36,Xe=20,Oe=16;function Gr(e){const t="fb-boolean-styles";if(e.getElementById(t))return;const n=e.createElement("style");n.id=t,n.textContent=`
|
|
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=`
|
|
412
400
|
.fb-toggle {
|
|
413
401
|
position: relative;
|
|
414
402
|
display: inline-block;
|
|
415
|
-
width: ${
|
|
416
|
-
height: ${
|
|
417
|
-
border-radius: ${
|
|
403
|
+
width: ${hn}px;
|
|
404
|
+
height: ${Ye}px;
|
|
405
|
+
border-radius: ${Ye}px;
|
|
418
406
|
background: var(--fb-border-color);
|
|
419
407
|
transition: background-color var(--fb-transition-duration);
|
|
420
408
|
flex-shrink: 0;
|
|
@@ -422,10 +410,10 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
422
410
|
.fb-toggle::after {
|
|
423
411
|
content: "";
|
|
424
412
|
position: absolute;
|
|
425
|
-
top: ${(
|
|
426
|
-
left: ${(
|
|
427
|
-
width: ${
|
|
428
|
-
height: ${
|
|
413
|
+
top: ${(Ye-Ue)/2}px;
|
|
414
|
+
left: ${(Ye-Ue)/2}px;
|
|
415
|
+
width: ${Ue}px;
|
|
416
|
+
height: ${Ue}px;
|
|
429
417
|
border-radius: 50%;
|
|
430
418
|
background: #ffffff;
|
|
431
419
|
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
|
@@ -435,7 +423,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
435
423
|
background: var(--fb-primary-color);
|
|
436
424
|
}
|
|
437
425
|
.fb-toggle.fb-on::after {
|
|
438
|
-
transform: translateX(${
|
|
426
|
+
transform: translateX(${hn-Ue-(Ye-Ue)}px);
|
|
439
427
|
}
|
|
440
428
|
.fb-toggle-row {
|
|
441
429
|
display: flex;
|
|
@@ -488,7 +476,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
488
476
|
font-family: serif;
|
|
489
477
|
cursor: help;
|
|
490
478
|
}
|
|
491
|
-
`,e.head.appendChild(n)}function
|
|
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=`
|
|
492
480
|
@keyframes fb-spin { to { transform: rotate(360deg); } }
|
|
493
481
|
|
|
494
482
|
/* \u2500\u2500\u2500 Checker background utility \u2500\u2500\u2500 */
|
|
@@ -975,90 +963,90 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
975
963
|
display: none;
|
|
976
964
|
}
|
|
977
965
|
}
|
|
978
|
-
`,document.head.appendChild(t)}}function
|
|
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=`
|
|
979
967
|
color: var(--fb-error-color);
|
|
980
968
|
font-size: var(--fb-font-size-small);
|
|
981
969
|
margin-top: 0.25rem;
|
|
982
|
-
`,
|
|
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=`
|
|
983
971
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:4px;">
|
|
984
972
|
<div class="fb-spinner"></div>
|
|
985
|
-
<div class="fb-tile-label">${
|
|
986
|
-
<div class="fb-tile-uploading-text">${
|
|
987
|
-
</div>`,n}function
|
|
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=`
|
|
988
976
|
<div class="flex flex-col items-center justify-center h-full text-gray-400">
|
|
989
977
|
<svg class="w-6 h-6 mb-2" fill="currentColor" viewBox="0 0 24 24">
|
|
990
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"/>
|
|
991
979
|
</svg>
|
|
992
|
-
<div class="text-sm text-center">${
|
|
980
|
+
<div class="text-sm text-center">${de(k("clickDragText",t))}</div>
|
|
993
981
|
|
|
994
982
|
</div>
|
|
995
|
-
`}const
|
|
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=`
|
|
996
984
|
<div class="fb-video-preview-wrap">
|
|
997
|
-
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${
|
|
998
|
-
${
|
|
985
|
+
<video style="width:100%;height:100%;object-fit:contain;" controls preload="auto" muted src="${a}">
|
|
986
|
+
${de(k("videoNotSupported",o))}
|
|
999
987
|
</video>
|
|
1000
988
|
<div class="fb-video-btn-overlay">
|
|
1001
989
|
<button class="fb-video-btn fb-video-btn-delete delete-file-btn">
|
|
1002
|
-
${
|
|
990
|
+
${de(k("removeElement",o))}
|
|
1003
991
|
</button>
|
|
1004
992
|
<button class="fb-video-btn fb-video-btn-change change-file-btn">
|
|
1005
|
-
${
|
|
993
|
+
${de(k("changeButton",o))}
|
|
1006
994
|
</button>
|
|
1007
995
|
</div>
|
|
1008
996
|
</div>
|
|
1009
|
-
`,
|
|
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=`
|
|
1010
998
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1011
999
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1012
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"/>
|
|
1013
1001
|
</svg>
|
|
1014
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
1002
|
+
<div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
|
|
1015
1003
|
</div>
|
|
1016
|
-
`,r!=null&&r.setupDrop&&r.setupDrop(e)}function
|
|
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=`
|
|
1017
1005
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1018
1006
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1019
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"/>
|
|
1020
1008
|
</svg>
|
|
1021
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
1009
|
+
<div style="font-size:0.875rem;text-align:center;">${de(k("clickDragText",n))}</div>
|
|
1022
1010
|
</div>
|
|
1023
|
-
`})}async function
|
|
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=`
|
|
1024
1012
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--fb-text-secondary-color,#9ca3af);">
|
|
1025
1013
|
<svg style="width:1.5rem;height:1.5rem;margin-bottom:0.5rem;" fill="currentColor" viewBox="0 0 24 24">
|
|
1026
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"/>
|
|
1027
1015
|
</svg>
|
|
1028
|
-
<div style="font-size:0.875rem;text-align:center;">${
|
|
1016
|
+
<div style="font-size:0.875rem;text-align:center;">${de(n||k("previewUnavailable",o))}</div>
|
|
1029
1017
|
</div>
|
|
1030
|
-
`}}async function
|
|
1031
|
-
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${
|
|
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}">
|
|
1032
1020
|
<div class="fb-video-overlay">
|
|
1033
1021
|
<div class="fb-play-btn" style="width:22px;height:22px;">
|
|
1034
1022
|
<svg width="10" height="12" viewBox="0 0 10 12" fill="currentColor"><path d="M0 0l10 6-10 6z"/></svg>
|
|
1035
1023
|
</div>
|
|
1036
|
-
</div>`,
|
|
1037
|
-
<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M19 9h-4V3H9v6H5l7 7 7-7zm-7 9H5v2h14v-2h-7z"/></svg>`:"";
|
|
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=`
|
|
1038
1026
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
1039
1027
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
1040
1028
|
${h}
|
|
1041
|
-
</div>`,
|
|
1042
|
-
<video style="width:100%;height:100%;" preload="metadata" muted src="${
|
|
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>
|
|
1043
1031
|
<div class="fb-video-overlay">
|
|
1044
1032
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
1045
1033
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
1046
1034
|
</div>
|
|
1047
|
-
</div>`}else if(r.config.getThumbnail)try{const
|
|
1048
|
-
<img style="width:100%;height:100%;object-fit:contain;background:var(--fb-file-upload-bg-color,#f3f4f6);" alt="${
|
|
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}">
|
|
1049
1037
|
<div class="fb-video-overlay">
|
|
1050
1038
|
<div class="fb-play-btn" style="width:20px;height:20px;">
|
|
1051
1039
|
<svg width="8" height="10" viewBox="0 0 8 10" fill="currentColor"><path d="M0 0l8 5-8 5z"/></svg>
|
|
1052
1040
|
</div>
|
|
1053
|
-
</div>`:e.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;font-size:36px;">\u{1F3A5}</div>'}catch(
|
|
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=`
|
|
1054
1042
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:6px;gap:4px;">
|
|
1055
1043
|
<div style="font-size:36px;">\u{1F4C1}</div>
|
|
1056
|
-
${
|
|
1057
|
-
</div>`,r&&e.appendChild(r)}async function
|
|
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=`
|
|
1058
1046
|
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:6px;padding:6px;">
|
|
1059
1047
|
<div class="fb-spinner"></div>
|
|
1060
|
-
<div style="font-size:11px;color:var(--fb-text-secondary-color,#6b7280);text-align:center;">${
|
|
1061
|
-
</div>`;let b;try{b=await wn(o,i)}catch(h){throw m&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,m):c!=null&&c.onRemove?c.onRemove():Tt(a,i),h}i.resourceIndex.set(b,{name:o.name,type:o.type,size:o.size,uploadedAt:new Date,file:o}),m&&m!==b&&qe((n=i.resourceIndex.get(m))==null?void 0:n.file);let g=p;g||(g=document.createElement("input"),g.type="hidden",g.name=l,(r=a.parentElement)==null||r.appendChild(g)),g.value=b;const E=o.type.startsWith("video/");!E&&c!=null&&c.onAfterUpload?c.onAfterUpload(a,b):!E&&c?So(a,b,i,c).catch(console.error):Mt(a,b,i,{fileName:o.name,isReadonly:!1,deps:c}).catch(console.error),s&&!i.config.readonly&&s.triggerOnChange(l,b)}function Ao(e,t,n,r){const o=e.filter(m=>!Ue(m.name,n.allowedExtensions)),a=e.filter(m=>Ue(m.name,n.allowedExtensions)),l=a.filter(m=>!Ge(m.type,n.allowedMimes)),i=a.filter(m=>Ge(m.type,n.allowedMimes)),c=i.filter(m=>!st(m,n.maxSize)),s=i.filter(m=>st(m,n.maxSize)),f=n.maxCount===1/0?s.length:Math.max(0,n.maxCount-t),d=s.slice(0,f),u=s.length-d.length,p=[];if(o.length>0){const m=n.allowedExtensions.join(", "),b=o.map(g=>g.name).join(", ");p.push(k("invalidFileExtension",r,{name:b,formats:m}))}if(l.length>0){const m=n.allowedMimes.join(", "),b=l.map(g=>g.name).join(", ");p.push(k("invalidFileMime",r,{name:b,type:l.map(g=>g.type).join(", "),mimes:m}))}if(c.length>0){const m=c.map(b=>b.name).join(", ");p.push(k("fileTooLarge",r,{name:m,maxSize:n.maxSize}))}return u>0&&p.push(k("filesLimitExceeded",r,{skipped:u,max:n.maxCount})),{accepted:d,errorMessage:p.join(" \u2022 ")}}async function Fo(e){var t;const{accepted:n,listEl:r,state:o,shouldHideAddTile:a,buildSuccessTile:l,prepareForUpload:i}=e;if(r&&a){const f=Lt(r),d=(t=f.querySelector(".fb-multi-add-tile-js"))!=null?t:f.querySelector(".fb-tile-add");d&&(d.style.display="none")}i==null||i();const c=new Array(n.length).fill(null),s=[];return await Promise.allSettled(n.map(async(f,d)=>{const u=ro(f.name,o);r&&Lt(r).appendChild(u);try{const p=await wn(f,o);o.resourceIndex.set(p,{name:f.name,type:f.type,size:f.size,uploadedAt:new Date,file:f}),c[d]=p,l&&u.parentNode?u.replaceWith(l(p)):u.remove()}catch(p){const m=p instanceof Error?p:new Error(String(p)),b=m.cause,g=b instanceof Error?b:b!==void 0?new Error(String(b)):m;s.push({file:f,error:g}),u.remove()}})),{failures:s,orderedIds:c}}function zo(e,t,n){if(t.length===0)return e;const r=t.map(o=>k("uploadFailed",n,{name:o.file.name,error:o.error.message})).join(" \u2022 ");return e?`${e} \u2022 ${r}`:r}async function Cn(e,t,n,r){const{resourceIds:o,state:a,updateCallback:l,constraints:i,pathKey:c,instance:s,buildSuccessTile:f,prepareForUpload:d,coordinator:u}=e,{accepted:p,errorMessage:m}=Ao(t,u.getOccupiedCount(),i,a);r&&(m?Se(r,m):Ze(r));const b=u.beginBatch(p.length),g=u.getOccupiedCount()>=i.maxCount,{failures:E,orderedIds:h}=await Fo({accepted:p,listEl:n,state:a,shouldHideAddTile:g,buildSuccessTile:f,prepareForUpload:d});b.setResults(h),s&&c&&!a.config.readonly&&s.triggerOnChange(c,o);const{wasLast:y}=b.end();if(y&&l(),r){const v=zo(m,E,a);v?Se(r,v):Ze(r)}}function Mo(e){const{filesContainer:t}=e;dt(t,async n=>{var r;const o=(r=t.querySelector(".files-list"))!=null?r:t;await Cn(e,Array.from(n),o,t)})}function No(e){const{filesPicker:t}=e;t.onchange=async()=>{var n,r;if(!t.files)return;const o=(n=t.closest("[data-files-wrapper]"))!=null?n:t.parentElement,a=(r=o==null?void 0:o.querySelector(".files-list"))!=null?r:null;await Cn(e,Array.from(t.files),a,o),t.value=""}}function En(e){var t,n;if(!e.accept)return;if(typeof e.accept=="string"){const i=Re(e.accept);return i.length>0?{extensions:i}:void 0}const r=(t=e.accept.extensions)!=null?t:[],o=(n=e.accept.mime)!=null?n:[],a=r.map(i=>i.toLowerCase());if(a.length===0&&o.length===0)return;const l={};return a.length>0&&(l.extensions=a),o.length>0&&(l.mime=o),l}function kn(e,t,n,r,o){if(!Ue(e.name,t)){const a=t.join(", ");return k("invalidFileExtension",o,{name:e.name,formats:a})}if(!Ge(e.type,n)){const a=n.join(", ");return k("invalidFileMime",o,{name:e.name,type:e.type,mimes:a})}return dn(e.size,r)?null:k("fileTooLarge",o,{name:e.name,maxSize:r})}function $n(e,t){var n;const r=t.resourceIndex.get(e.resourceId);t.resourceIndex.set(e.resourceId,{name:e.name,type:e.type,size:e.size,uploadedAt:(n=r==null?void 0:r.uploadedAt)!=null?n:new Date,file:r==null?void 0:r.file})}function Sn(e,t){return e instanceof Error&&e.message?e.message:k("pickerError",t)}async function Io(e){var t;const{state:n,element:r,wrapper:o,fieldPath:a,resourceIds:l,maxCount:i,updateCallback:c,instance:s,coordinator:f,list:d,buildSuccessTile:u}=e;if(!n.config.pickExistingFiles)return;const p=Re(r.accept),m=Ye(r.accept),b=(t=r.maxSize)!=null?t:1/0,g=f.getAllKnownRids(),E=new Set(g),h=i===1/0?1/0:Math.max(0,i-f.getOccupiedCount());let y;try{y=await n.config.pickExistingFiles({fieldPath:a,mode:"multiple",accept:En(r),maxSizeMB:b===1/0?void 0:b,remainingSlots:h===1/0?void 0:h,selectedResourceIds:g})}catch(H){Se(o,Sn(H,n));return}if(y.length===0)return;const v=new Set,C=y.filter(H=>E.has(H.resourceId)||v.has(H.resourceId)?!1:(v.add(H.resourceId),!0)).filter(H=>kn(H,p,m,b,n)===null),w=i===1/0?C.length:Math.max(0,i-f.getOccupiedCount()),x=C.slice(0,w),S=C.length-x.length;if(x.length===0){S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));return}Ze(o),S>0&&Se(o,k("filesLimitExceeded",n,{skipped:S,max:i}));for(const H of x)$n(H,n);const z=x.map(H=>H.resourceId),ee=f.beginBatch(x.length);ee.setResults(z),n.config.readonly||s.triggerOnChange(a,l);const{wasLast:K}=ee.end();if(K)c();else{const H=Lt(d);for(const V of z)H.appendChild(u(V))}}async function Ro(e,t,n,r,o,a,l,i){var c,s;if(!e.config.pickExistingFiles)return;const f=Re(t.accept),d=Ye(t.accept),u=(c=t.maxSize)!=null?c:1/0;let p;try{p=await e.config.pickExistingFiles({fieldPath:a,mode:"single",accept:En(t),maxSizeMB:u===1/0?void 0:u,selectedResourceIds:[]})}catch(h){Se(n,Sn(h,e));return}if(p.length===0)return;const m=p[0],b=kn(m,f,d,u,e);if(b!==null){Se(n,b);return}Ze(n),$n(m,e);let g=r.querySelector('input[type="hidden"]');g||(g=document.createElement("input"),g.type="hidden",g.name=o,r.appendChild(g));const E=g.value||null;E&&E!==m.resourceId&&qe((s=e.resourceIndex.get(E))==null?void 0:s.file),g.value=m.resourceId,await l(m.resourceId),e.config.readonly||i.triggerOnChange(a,m.resourceId)}const Ln='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 18a4 4 0 000-8 6 6 0 00-11.5 2A4 4 0 006 20h11M12 12v7M12 12l-3 3M12 12l3 3"/></svg>',Tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h4v16H4z"/><path d="M10 4h4v16h-4z"/><path d="M16 5l3.5 1-3 14L13 19"/></svg>';function qo(e,t,n,r,o,a,l){var i;ct(e,o.resourceIndex);const c=o.resourceIndex.get(e);(i=c==null?void 0:c.type)!=null&&i.startsWith("video/")?Mt(t,e,o,{fileName:e,isReadonly:!1,deps:a}).catch(console.error):It(t,e,o,a,l);const s=document.createElement("input");s.type="hidden",s.name=n,s.value=e,r.appendChild(s)}function Bo(e,t,n,r,o=!1,a=""){$e();const l=document.createElement("div");l.className=`fb-wide-tile${t?" fb-file-card-row":""}${o?" fb-drag-over":""}`;const i=document.createElement("button");i.type="button",i.className="fb-wide-tile-upload fb-file-dropzone";const c=document.createElement("span");c.style.cssText="width:36px;height:36px;display:block;flex-shrink:0;",c.innerHTML=Ln,i.appendChild(c);const s=document.createElement("div");if(s.className="fb-wide-tile-label",s.style.cssText="font-size:14px;font-weight:600;",s.textContent=k(o?"dropToUpload":"clickDragText",e),i.appendChild(s),a){const f=document.createElement("div");f.style.cssText="font-size:11px;opacity:0.65;margin-top:2px;",f.textContent=a,i.appendChild(f)}if(i.onclick=f=>{f.stopPropagation(),n()},l.appendChild(i),t&&r){const f=document.createElement("button");f.type="button",f.className="fb-wide-tile-library fb-file-library-card";const d=document.createElement("span");d.className="fb-wide-tile-library-icon",d.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d);const u=document.createElement("div");u.className="fb-wide-tile-library-label",u.style.cssText="font-size:13px;font-weight:600;text-align:center;",u.textContent=k("fromLibrary",e),f.appendChild(u);const p=document.createElement("div");p.className="fb-wide-tile-library-hint",p.style.cssText="font-size:11px;opacity:0.75;text-align:center;",p.textContent=k("libraryHint",e),f.appendChild(p),f.onclick=m=>{m.stopPropagation(),r()},l.appendChild(f)}return An(l,{onEnter:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("dropToUpload",e))},onLeave:()=>{const f=l.querySelector(".fb-wide-tile-label");f&&(f.textContent=k("clickDragText",e))},activeClass:"fb-drag-over"}),l}function An(e,t){let n=0;e.addEventListener("dragover",r=>{r.preventDefault()}),e.addEventListener("dragenter",r=>{r.preventDefault(),n++,n===1&&(e.classList.add(t.activeClass),t.onEnter())}),e.addEventListener("dragleave",r=>{r.preventDefault(),n=Math.max(0,n-1),n===0&&(e.classList.remove(t.activeClass),t.onLeave())}),e.addEventListener("drop",()=>{n=0,e.classList.remove(t.activeClass),t.onLeave()})}function It(e,t,n,r,o){var a,l;const i=n.resourceIndex.get(t);if((a=i==null?void 0:i.type)!=null&&a.startsWith("video/")){Mt(e,t,n,{fileName:(l=i==null?void 0:i.name)!=null?l:"",isReadonly:!1,deps:r}).catch(console.error);return}$e();const c=document.createElement("div");c.className="fb-multi-outer fb-multi-has-files";const s=document.createElement("div");s.className="fb-multi-grid fb-tiles-wrap",c.appendChild(s);const f=Rt(t,n,!!r.onRemove,r.onRemove?()=>{var d;return(d=r.onRemove)==null?void 0:d.call(r)}:null,o);for(s.appendChild(f),e.className="file-preview-container",e.removeAttribute("style");e.firstChild;)e.removeChild(e.firstChild);e.appendChild(c)}function Ho(e,t,n,r,o=!1){const a=document.createElement("div");a.className=`fb-multi-add-tile fb-multi-add-tile-js${o?" fb-drag-over-tile":""}`;const l=document.createElement("button");l.type="button",l.className="fb-multi-add-upload fb-tile-add fb-file-dropzone";const i=document.createElement("span");i.style.cssText="width:28px;height:28px;display:block;flex-shrink:0;",i.innerHTML=Ln,l.appendChild(i);const c=document.createElement("span");if(c.className="fb-multi-add-label",c.style.cssText="font-size:11px;font-weight:600;",c.textContent=k(o?"dropToUpload":"clickDragTextMultiple",e),l.appendChild(c),l.onclick=s=>{s.stopPropagation(),n()},a.appendChild(l),t&&r){const s=document.createElement("div");s.className="fb-multi-add-divider",a.appendChild(s);const f=document.createElement("button");f.type="button",f.className="fb-multi-add-library fb-tile-add-library fb-file-library-card",f.setAttribute("aria-label",k("fromLibrary",e));const d=document.createElement("span");d.style.cssText="width:14px;height:14px;display:block;flex-shrink:0;",d.innerHTML=Tn,f.appendChild(d),f.appendChild(document.createTextNode(k("fromLibrary",e))),f.onclick=u=>{u.stopPropagation(),r()},a.appendChild(f)}return a}function Rt(e,t,n,r,o){var a,l,i;$e();const c=t.resourceIndex.get(e),s=document.createElement("div");s.className="fb-preview-tile fb-checker fb-tile-resource resource-pill",s.dataset.resourceId=e;const f=At({canRemove:n&&r!==null,removeHandler:r,state:t,resourceId:e,fileName:(a=c==null?void 0:c.name)!=null?a:"",meta:c,replaceHandler:(l=o==null?void 0:o.replaceHandler)!=null?l:null,libraryHandler:(i=o==null?void 0:o.libraryHandler)!=null?i:null});return vn(s,e,c,t,f).catch(d=>{console.error("Failed to render tile:",d)}),s}function Fn(e=!1){const t=document.createElement("div");return t.className=`fb-multi-placeholder fb-checker${e?" fb-drag-over":""}`,t}function Do(e,t,n){if(t<=1)return null;const r=document.createElement("div");r.className="fb-clear-all-row";const o=document.createElement("button");return o.type="button",o.className="fb-clear-all-btn",o.textContent=k("clearAll",e),o.onclick=a=>{a.stopPropagation(),window.confirm(k("clearAll",e)+"?")&&n()},r.appendChild(o),r}const Qe=new WeakMap,qt=new WeakMap;function zn(e){const t=qt.get(e);t!==void 0&&(cancelAnimationFrame(t),qt.delete(e))}function jo(e){const t=Qe.get(e);t&&(t.disconnect(),Qe.delete(e)),zn(e),e.querySelectorAll(".fb-multi-placeholder").forEach(n=>n.remove())}function Oo(e){var t;const{container:n,rids:r,state:o,onRemove:a,maxCount:l,isReadonly:i=!1,onLibraryPick:c,onClearAll:s,openPicker:f}=e;$e();const d=n.closest("[data-files-wrapper]");d&&(d.dataset.resourceIds=JSON.stringify(r!=null?r:[]));const u=Qe.get(n);for(u&&(u.disconnect(),Qe.delete(n)),zn(n);n.firstChild;)n.removeChild(n.firstChild);const p=r!=null?r:[],m=l!=null?l:1/0,b=m!==1/0&&p.length>=m,g=!i&&typeof c=="function",E=f!=null?f:(()=>{var w;const x=(w=n.closest("[data-files-wrapper]"))==null?void 0:w.querySelector('input[type="file"]');x&&x.click()});if(i){if(p.length===0){const w=document.createElement("div");w.className="fb-tile-empty-text",w.textContent=k("noFilesSelected",o),n.appendChild(w)}else{const w=document.createElement("div");w.className="fb-multi-readonly-grid",n.appendChild(w);for(const x of p){const S=o.resourceIndex.get(x),z=document.createElement("div");z.className="fb-readonly-tile fb-checker fb-tile fb-tile-resource",z.dataset.resourceId=x;const ee=At({canRemove:!1,removeHandler:null,state:o,resourceId:x,fileName:(t=S==null?void 0:S.name)!=null?t:"",meta:S});vn(z,x,S,o,ee).catch(console.error),z.onclick=async()=>{var K;let H=null;o.config.getDownloadUrl?H=o.config.getDownloadUrl(x):o.config.getThumbnail?H=await o.config.getThumbnail(x):(S==null?void 0:S.file)instanceof File&&(H=URL.createObjectURL(S.file)),H?window.open(H,"_blank"):o.config.downloadFile&&o.config.downloadFile(x,(K=S==null?void 0:S.name)!=null?K:"")},w.appendChild(z)}}return}const h=document.createElement("div");h.className=`fb-multi-outer${p.length>0?" fb-multi-has-files":""}`;const y=document.createElement("div");y.className="fb-multi-grid fb-tiles-wrap",h.appendChild(y),n.appendChild(h);for(let w=0;w<p.length;w++){const x=p[w],S=Rt(x,o,a!==null,a?()=>a(x):null);y.appendChild(S)}if(!b){const w=Ho(o,g,E,c!=null?c:null);y.appendChild(w)}const v=p.length+(b?0:1),C=()=>{const w=getComputedStyle(y).gridTemplateColumns,x=w?w.split(" ").filter(Boolean).length:0;if(!x)return;const S=v%x,z=S===0?0:x-S,ee=m===1/0?z:Math.max(0,m-v),K=Math.min(z,ee),H=y.querySelectorAll(".fb-multi-placeholder");if(H.length>K)for(let V=H.length-1;V>=K;V--)H[V].remove();else if(H.length<K)for(let V=H.length;V<K;V++)y.appendChild(Fn())};if((m===1/0||m>v)&&y.appendChild(Fn()),qt.set(n,requestAnimationFrame(C)),typeof ResizeObserver!="undefined"){const w=new ResizeObserver(()=>C());w.observe(y),Qe.set(n,w)}if(An(h,{activeClass:"fb-drag-over",onEnter:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.add("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.add("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("dropToUpload",o))}},onLeave:()=>{y.querySelectorAll(".fb-multi-placeholder").forEach(x=>{x.classList.remove("fb-drag-over")});const w=y.querySelector(".fb-multi-add-tile-js");if(w){w.classList.remove("fb-drag-over-tile");const x=w.querySelector(".fb-multi-add-label");x&&(x.textContent=k("clickDragTextMultiple",o))}}}),s){const w=Do(o,p.length,s);w&&n.appendChild(w)}}function Uo(e,t,n,r){var o,a;const l=t.state,i=document.createElement("div");i.className="fb-row",i.dataset.filesWrapper=r;const c=document.createElement("input");c.type="file",c.name=r,c.style.display="none",c.accept=Mn(e.accept);const s=document.createElement("div");s.className="file-preview-container";const f=t.prefill[e.key],d=Re(e.accept),u=Ye(e.accept),p=(o=e.maxSize)!=null?o:1/0,m={fileUploadHandler(){c.click()},dragHandler(h){h.length>0&&To({file:h[0],container:s,fieldName:r,state:l,deps:g(),instance:t.instance,allowedExtensions:d,allowedMimes:u,maxSizeMB:p})},setupDrop(h){dt(h,m.dragHandler)},onRemove(){var h;const y=i.querySelector('input[type="hidden"]'),v=y==null?void 0:y.value;v&&qe((h=l.resourceIndex.get(v))==null?void 0:h.file),y&&(y.value=""),E()}},b=()=>{const h=!!(l.config.pickExistingFiles&&!e.disableLibrary);return{replaceHandler:l.config.uploadFile?()=>c.click():null,libraryHandler:h?()=>{Ro(l,e,s,i,r,r,async y=>{It(s,y,l,g(),b())},t.instance).catch(y=>{console.error("Library pick failed:",y)})}:null}},g=()=>({picker:c,fileUploadHandler:m.fileUploadHandler,dragHandler:m.dragHandler,setupDrop:m.setupDrop,onRemove:m.onRemove,onAfterUpload:(h,y)=>{It(h,y,l,g(),b())}}),E=()=>{for($e(),s.className="file-preview-container",s.removeAttribute("style");s.firstChild;)s.removeChild(s.firstChild);const h=b().libraryHandler,y=Bo(l,h!==null,m.fileUploadHandler,h,!1,Le(e,l));s.appendChild(y),dt(s,m.dragHandler)};if(f){qo(f,s,r,i,l,g(),b());const h=l.resourceIndex.get(f);(a=h==null?void 0:h.type)!=null&&a.startsWith("video/")&&dt(s,m.dragHandler)}else E();c.onchange=()=>{c.files&&c.files.length>0&&m.dragHandler(c.files)},i.appendChild(s),i.appendChild(c),n.appendChild(i)}function Mn(e){var t,n,r;return e?typeof e=="string"?e:[...(n=(t=e.extensions)==null?void 0:t.map(o=>`.${o}`))!=null?n:[],...(r=e.mime)!=null?r:[]].join(","):""}function Nn(e,t,n,r,o){var a,l;const i=t.state,c=document.createElement("div");c.className="fb-row",c.dataset.filesWrapper=r;const s=document.createElement("input");s.type="file",s.name=r,s.multiple=!0,s.style.display="none",s.accept=Mn(e.accept);const f=document.createElement("div");f.className="files-list-wrapper";const d=document.createElement("div");d.className="files-list",c.appendChild(s),c.appendChild(f),f.appendChild(d);const u=Array.isArray(t.prefill[e.key])?[...t.prefill[e.key]]:[];St(u,i.resourceIndex),c.dataset.resourceIds=JSON.stringify(u);const p={maxCount:o,allowedExtensions:Re(e.accept),allowedMimes:Ye(e.accept),maxSize:(l=(a=e.maxSize)!=null?a:e.maxSizeMB)!=null?l:1/0},m=()=>{s.click()},b=i.config.pickExistingFiles&&!e.disableLibrary?()=>{Io({state:i,element:e,wrapper:c,fieldPath:r,resourceIds:u,maxCount:o,updateCallback:g,instance:t.instance,coordinator:z,list:d,buildSuccessTile:ee}).catch(V=>{console.error("Library pick failed:",V)})}:null;function g(){const V=ae(e,i);Oo({container:d,rids:u,state:i,onRemove:V?null:ne=>{var R,_;qe((R=i.resourceIndex.get(ne))==null?void 0:R.file);const ie=u.indexOf(ne);ie>-1&&u.splice(ie,1),z.hasInFlightBatches()?(x.add(ne),(_=d.querySelector(`[data-resource-id="${ne}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},maxCount:o<1/0?o:void 0,isReadonly:V,onLibraryPick:V?null:b,onClearAll:V?void 0:()=>{var ne,R;for(const _ of u)qe((ne=i.resourceIndex.get(_))==null?void 0:ne.file);if(u.splice(0),z.hasInFlightBatches()){const _=d.querySelectorAll("[data-resource-id]");for(const ie of _){const pe=ie.dataset.resourceId;pe&&(qe((R=i.resourceIndex.get(pe))==null?void 0:R.file),x.add(pe)),ie.remove()}c.dataset.resourceIds=JSON.stringify(u)}else g();t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)},openPicker:m})}let E=0,h=0,y=0,v=0;const C=new Map,w=new Map,x=new Set,S=()=>{for(var V;C.has(v);){const ne=v,R=C.get(ne);C.delete(ne),v+=1;const _=(V=w.get(ne))!=null?V:0;w.delete(ne),E-=_;for(const ie of R)if(ie!==null){if(x.has(ie)){x.delete(ie);continue}u.push(ie)}}c.dataset.resourceIds=JSON.stringify(u)},z={getOccupiedCount:()=>u.length+E,getAllKnownRids:()=>{const V=[...u];for(const ne of C.values())for(const R of ne)R!==null&&V.push(R);return V},hasInFlightBatches:()=>h>0||w.size>0,wasRemovedDuringBatch:V=>x.has(V),beginBatch:V=>{E+=V,h+=1;const ne=y++;return w.set(ne,V),{setResults:R=>{C.set(ne,R),S()},end:()=>{h-=1;const R=h===0&&w.size===0;return R&&x.clear(),{wasLast:R}}}}},ee=V=>{const ne=ae(e,i);return Rt(V,i,!ne,ne?null:()=>{var R,_,ie;qe((R=i.resourceIndex.get(V))==null?void 0:R.file);const pe=u.indexOf(V);if(pe>-1){u.splice(pe,1),z.hasInFlightBatches()?(x.add(V),(_=d.querySelector(`[data-resource-id="${V}"]`))==null||_.remove(),c.dataset.resourceIds=JSON.stringify(u)):g(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u);return}x.add(V),(ie=d.querySelector(`[data-resource-id="${V}"]`))==null||ie.remove(),t.instance&&r&&!i.config.readonly&&t.instance.triggerOnChange(r,u)})},K=()=>jo(d),H={resourceIds:u,state:i,updateCallback:g,constraints:p,pathKey:r,instance:t.instance,buildSuccessTile:ee,prepareForUpload:K,coordinator:z};Mo({...H,filesContainer:f}),No({...H,filesPicker:s}),g(),n.appendChild(c)}function Po(e,t,n,r){Nn(e,t,n,r,1/0)}function Wo(e,t,n,r){var o;Nn(e,t,n,r,(o=e.maxCount)!=null?o:1/0)}function Vo(e,t){const n=e.querySelector(`[data-files-wrapper="${t}"]`);if(!n)return[];const r=n.dataset.resourceIds;if(r===void 0)throw new Error(`readMultiFileResourceIds: [data-files-wrapper="${t}"] is missing data-resource-ids attribute. This is a render bug.`);const o=JSON.parse(r);if(!Array.isArray(o))throw new Error(`readMultiFileResourceIds: data-resource-ids on [data-files-wrapper="${t}"] is not a JSON array. Got: ${r}`);return o}function Ko(e,t,n,r,o){var a,l;const i="minCount"in n&&(a=n.minCount)!=null?a:0,c="maxCount"in n&&(l=n.maxCount)!=null?l:1/0;n.required&&t.length===0&&o.push(`${e}: ${k("required",r)}`),t.length<i&&o.push(`${e}: ${k("minFiles",r,{min:i})}`),t.length>c&&o.push(`${e}: ${k("maxFiles",r,{max:c})}`)}function In(e,t,n,r,o){var a,l;const i="accept"in n?n.accept:void 0,c=Re(i),s=Ye(i);if(c.length===0&&s.length===0)return;const f=c.join(", "),d=s.join(", ");for(const u of t){const p=r.resourceIndex.get(u),m=(a=p==null?void 0:p.name)!=null?a:u;if(c.length>0&&!Ue(m,c)){o.push(`${e}: ${k("invalidFileExtension",r,{name:m,formats:f})}`);continue}if(s.length>0&&!(p!=null&&p.inferredFromExtension)){const b=(l=p==null?void 0:p.type)!=null?l:"";Ge(b,s)||o.push(`${e}: ${k("invalidFileMime",r,{name:m,type:b,mimes:d})}`)}}}function Rn(e,t,n,r,o){var a;const l="maxSize"in n&&(a=n.maxSize)!=null?a:1/0;if(l!==1/0)for(const i of t){const c=r.resourceIndex.get(i);c&&c.size>l*1024*1024&&o.push(`${e}: ${k("fileTooLarge",r,{name:c.name,maxSize:l})}`)}}function _o(e,t,n){const{scopeRoot:r,skipValidation:o,path:a,state:l}=n,i=[],c=De(a,t),s=Vo(r,c);return o||(Ko(t,s,e,l,i),In(t,s,e,l,i),Rn(t,s,e,l,i)),{value:s,errors:i}}function Jo(e,t,n){var r;const{scopeRoot:o,skipValidation:a,state:l}=n,i=[],c=o.querySelector(`input[name="${t}"][type="hidden"]`),s=(r=c==null?void 0:c.value)!=null?r:"";return!a&&e.required&&s===""?(i.push(`${t}: ${k("required",l)}`),{value:null,errors:i}):(!a&&s!==""&&(In(t,[s],e,l,i),Rn(t,[s],e,l,i)),{value:s||null,errors:i})}function qn(e,t,n){return e.type==="files"||"multiple"in e&&e.multiple?_o(e,t,n):Jo(e,t,n)}function Xo(e,t,n,r){const o=t.state,a=t.prefill[e.key],l=typeof a=="string"?a:"";if(l){St([l],o.resourceIndex);const i=document.createElement("input");i.type="hidden",i.name=r,i.value=l,n.appendChild(i),Nt(l,o).then(c=>{c.classList.add("fb-single-readonly-filled","fb-readonly-tile","fb-checker"),n.appendChild(c)}).catch(console.error)}else n.appendChild(Yo(o))}function Yo(e){$e();const t=document.createElement("div");return t.style.cssText=`
|
|
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=`
|
|
1062
1050
|
height: 220px;
|
|
1063
1051
|
display:flex;
|
|
1064
1052
|
align-items:center;
|
|
@@ -1066,7 +1054,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1066
1054
|
background: repeating-linear-gradient(45deg, #fafafa 0 6px, #f3f4f6 6px 12px);
|
|
1067
1055
|
border-radius:0.75rem;
|
|
1068
1056
|
border:1px solid #e2e8f0;
|
|
1069
|
-
`,t.innerHTML=`<div style="font-size:11px;text-align:center;color:var(--fb-text-secondary-color,#6b7280);">${
|
|
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=`
|
|
1070
1058
|
width: 32px;
|
|
1071
1059
|
height: 32px;
|
|
1072
1060
|
border-radius: var(--fb-border-radius);
|
|
@@ -1076,7 +1064,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1076
1064
|
font-size: var(--fb-font-size);
|
|
1077
1065
|
color: var(--fb-text-color);
|
|
1078
1066
|
font-family: var(--fb-font-family-mono, monospace);
|
|
1079
|
-
`,o.textContent=n,t.appendChild(r),t.appendChild(o),t}function
|
|
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=`
|
|
1080
1068
|
display: flex;
|
|
1081
1069
|
align-items: center;
|
|
1082
1070
|
gap: 8px;
|
|
@@ -1085,11 +1073,11 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1085
1073
|
height: 40px;
|
|
1086
1074
|
border-radius: var(--fb-border-radius);
|
|
1087
1075
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
1088
|
-
background-color: ${
|
|
1076
|
+
background-color: ${o};
|
|
1089
1077
|
cursor: pointer;
|
|
1090
1078
|
transition: border-color var(--fb-transition-duration) ease-in-out;
|
|
1091
1079
|
flex-shrink: 0;
|
|
1092
|
-
`;const l=document.createElement("input");l.type="text",l.className="colour-hex-input",l.name=t,l.value=
|
|
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=`
|
|
1093
1081
|
width: 100px;
|
|
1094
1082
|
padding: var(--fb-input-padding-y) var(--fb-input-padding-x);
|
|
1095
1083
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -1099,43 +1087,39 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1099
1087
|
font-size: var(--fb-font-size);
|
|
1100
1088
|
font-family: var(--fb-font-family-mono, monospace);
|
|
1101
1089
|
transition: all var(--fb-transition-duration) ease-in-out;
|
|
1102
|
-
`;const
|
|
1090
|
+
`;const s=document.createElement("input");return s.type="color",s.className="colour-picker-hidden",s.value=o.toLowerCase(),s.style.cssText=`
|
|
1103
1091
|
position: absolute;
|
|
1104
1092
|
opacity: 0;
|
|
1105
1093
|
pointer-events: none;
|
|
1106
|
-
`,l.addEventListener("input",()=>{const
|
|
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=`
|
|
1107
1095
|
font-size: var(--fb-font-size-small);
|
|
1108
1096
|
color: var(--fb-text-secondary-color);
|
|
1109
|
-
`,
|
|
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=`
|
|
1110
1098
|
color: var(--fb-error-color);
|
|
1111
1099
|
background-color: transparent;
|
|
1112
1100
|
transition: background-color var(--fb-transition-duration);
|
|
1113
|
-
`,
|
|
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=`
|
|
1114
1102
|
font-size: var(--fb-font-size-small);
|
|
1115
1103
|
color: var(--fb-text-secondary-color);
|
|
1116
|
-
`,
|
|
1117
|
-
color: var(--fb-error-color);
|
|
1118
|
-
font-size: var(--fb-font-size-small);
|
|
1119
|
-
margin-top: 0.25rem;
|
|
1120
|
-
`,d.nextSibling?(p=d.parentNode)==null||p.insertBefore(g,d.nextSibling):(m=d.parentNode)==null||m.appendChild(g)),g.textContent=u,g.style.display="block"):(d.classList.remove("invalid"),d.title="",g&&g.remove())},f=(d,u,p)=>{const{state:m}=n;if(!u){if(!c&&e.required){const g=k("required",m);return l.push(`${p}: ${g}`),s(d,g),""}return s(d,null),""}const b=Pe(u);if(!c&&!Bt(b)){const g=k("invalidHexColour",m);return l.push(`${p}: ${g}`),s(d,g),u}return s(d,null),b};if(e.multiple){const d=i.querySelectorAll(`[name^="${t}\\["].colour-hex-input`),u=[];if(d.forEach((p,m)=>{var b;const g=(b=p==null?void 0:p.value)!=null?b:"",E=f(p,g,`${t}[${m}]`);u.push(E)}),!c){const{state:p}=n,m=(r=e.minCount)!=null?r:0,b=(o=e.maxCount)!=null?o:1/0,g=u.filter(E=>E!=="");e.required&&g.length===0&&l.push(`${t}: ${k("required",p)}`),g.length<m&&l.push(`${t}: ${k("minItems",p,{min:m})}`),g.length>b&&l.push(`${t}: ${k("maxItems",p,{max:b})}`)}return{value:u,errors:l}}else{const d=i.querySelector(`[name="${t}"].colour-hex-input`),u=(a=d==null?void 0:d.value)!=null?a:"";if(!c&&e.required&&u===""){const p=k("required",n.state);return l.push(`${t}: ${p}`),s(d,p),{value:"",errors:l}}return{value:f(d,u,t),errors:l}}}function ll(e,t,n,r){const{scopeRoot:o}=r;if(e.multiple){if(!Array.isArray(n)){console.warn(`updateColourField: Expected array for multiple field "${t}", got ${typeof n}`);return}const a=o.querySelectorAll(`[name^="${t}\\["].colour-hex-input`);a.forEach((l,i)=>{if(i<n.length){const c=Pe(n[i]);l.value=c,l.classList.remove("invalid"),l.title="",Ce(l);const s=l.closest(".colour-picker-wrapper");if(s){const f=s.querySelector(".colour-swatch"),d=s.querySelector(".colour-picker-hidden");f&&(f.style.backgroundColor=c),d&&(d.value=c.toLowerCase())}}}),n.length!==a.length&&console.warn(`updateColourField: Multiple field "${t}" has ${a.length} inputs but received ${n.length} values. Consider re-rendering for add/remove.`)}else{const a=o.querySelector(`[name="${t}"].colour-hex-input`);if(a){const l=Pe(n);a.value=l,a.classList.remove("invalid"),a.title="",Ce(a);const i=a.closest(".colour-picker-wrapper");if(i){const c=i.querySelector(".colour-swatch"),s=i.querySelector(".colour-picker-hidden");c&&(c.style.backgroundColor=l),s&&(s.value=l.toLowerCase())}}}}function Un(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return Math.exp(r+e*(o-r))}function Ht(e,t,n){if(t<=0)throw new Error("Exponential scale requires min > 0");const r=Math.log(t),o=Math.log(n);return(Math.log(e)-r)/(o-r)}function pt(e,t){return Math.round(e/t)*t}function Pn(e,t,n,r,o){var a;const l=document.createElement("div");l.className="slider-container";const i=document.createElement("div");i.className="flex items-start gap-3";const c=document.createElement("div");c.className="flex-1";const s=document.createElement("input");s.type="range",s.name=t,s.className="slider-input w-full",s.disabled=o;const f=n.scale||"linear",d=n.min,u=n.max,p=(a=n.step)!=null?a:1;if(f==="exponential"){if(d<=0)throw new Error(`Slider "${n.key}": exponential scale requires min > 0 (got ${d})`);s.min="0",s.max="1000",s.step="1";const h=Ht(e,d,u);s.value=(h*1e3).toString()}else s.min=d.toString(),s.max=u.toString(),s.step=p.toString(),s.value=e.toString();s.style.cssText=`
|
|
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=`
|
|
1121
1105
|
height: 6px;
|
|
1122
1106
|
border-radius: 3px;
|
|
1123
1107
|
background: linear-gradient(
|
|
1124
1108
|
to right,
|
|
1125
1109
|
var(--fb-primary-color) 0%,
|
|
1126
|
-
var(--fb-primary-color) ${(e-
|
|
1127
|
-
var(--fb-border-color) ${(e-
|
|
1110
|
+
var(--fb-primary-color) ${(e-u)/(f-u)*100}%,
|
|
1111
|
+
var(--fb-border-color) ${(e-u)/(f-u)*100}%,
|
|
1128
1112
|
var(--fb-border-color) 100%
|
|
1129
1113
|
);
|
|
1130
1114
|
outline: none;
|
|
1131
1115
|
transition: background 0.1s ease-in-out;
|
|
1132
1116
|
cursor: ${o?"not-allowed":"pointer"};
|
|
1133
1117
|
opacity: ${o?"0.6":"1"};
|
|
1134
|
-
`,
|
|
1118
|
+
`,s.appendChild(d);const p=document.createElement("div");p.className="flex justify-between",p.style.cssText=`
|
|
1135
1119
|
font-size: var(--fb-font-size-small);
|
|
1136
1120
|
color: var(--fb-text-secondary-color);
|
|
1137
1121
|
margin-top: 4px;
|
|
1138
|
-
`;const b=document.createElement("span");b.textContent=
|
|
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=`
|
|
1139
1123
|
min-width: 60px;
|
|
1140
1124
|
text-align: right;
|
|
1141
1125
|
font-size: var(--fb-font-size);
|
|
@@ -1143,40 +1127,36 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1143
1127
|
font-family: var(--fb-font-family-mono, monospace);
|
|
1144
1128
|
font-weight: 500;
|
|
1145
1129
|
padding-top: 2px;
|
|
1146
|
-
|
|
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(
|
|
1147
1131
|
to right,
|
|
1148
1132
|
var(--fb-primary-color) 0%,
|
|
1149
|
-
var(--fb-primary-color) ${
|
|
1150
|
-
var(--fb-border-color) ${
|
|
1133
|
+
var(--fb-primary-color) ${x}%,
|
|
1134
|
+
var(--fb-border-color) ${x}%,
|
|
1151
1135
|
var(--fb-border-color) 100%
|
|
1152
|
-
)`,r.instance&&r.instance.triggerOnChange(t,
|
|
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=`
|
|
1153
1137
|
font-size: var(--fb-font-size-small);
|
|
1154
1138
|
color: var(--fb-text-secondary-color);
|
|
1155
|
-
`,
|
|
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=`
|
|
1156
1140
|
color: var(--fb-error-color);
|
|
1157
1141
|
background-color: transparent;
|
|
1158
1142
|
transition: background-color var(--fb-transition-duration);
|
|
1159
1143
|
margin-top: 8px;
|
|
1160
|
-
`,
|
|
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=`
|
|
1161
1145
|
font-size: var(--fb-font-size-small);
|
|
1162
1146
|
color: var(--fb-text-secondary-color);
|
|
1163
|
-
`,
|
|
1164
|
-
color: var(--fb-error-color);
|
|
1165
|
-
font-size: var(--fb-font-size-small);
|
|
1166
|
-
margin-top: 0.25rem;
|
|
1167
|
-
`;const C=b.closest(".slider-container");C&&C.nextSibling?(E=C.parentNode)==null||E.insertBefore(v,C.nextSibling):C&&((h=C.parentNode)==null||h.appendChild(v))}v.textContent=g,v.style.display="block"}else b.classList.remove("invalid"),b.title="",v&&v.remove()},m=(b,g)=>{const{state:E}=n,h=b.value;if(!h){if(!c&&e.required){const v=k("required",E);return l.push(`${g}: ${v}`),p(b,v),null}return p(b,null),null}let y;if(u==="exponential"){const v=parseFloat(h)/1e3;y=Un(v,s,f),y=pt(y,d)}else y=parseFloat(h),y=pt(y,d);if(!c){if(y<s){const v=k("minValue",E,{min:s});return l.push(`${g}: ${v}`),p(b,v),y}if(y>f){const v=k("maxValue",E,{max:f});return l.push(`${g}: ${v}`),p(b,v),y}}return p(b,null),y};if(e.multiple){const b=i.querySelectorAll(`input[type="range"][name^="${t}\\["]`),g=[];if(b.forEach((E,h)=>{const y=m(E,`${t}[${h}]`);g.push(y)}),!c){const{state:E}=n,h=(o=e.minCount)!=null?o:0,y=(a=e.maxCount)!=null?a:1/0,v=g.filter(C=>C!==null);e.required&&v.length===0&&l.push(`${t}: ${k("required",E)}`),v.length<h&&l.push(`${t}: ${k("minItems",E,{min:h})}`),v.length>y&&l.push(`${t}: ${k("maxItems",E,{max:y})}`)}return{value:g,errors:l}}else{const b=i.querySelector(`input[type="range"][name="${t}"]`);return b?{value:m(b,t),errors:l}:(!c&&e.required&&l.push(`${t}: ${k("required",n.state)}`),{value:null,errors:l})}}function cl(e,t,n,r){var o;const{scopeRoot:a}=r,l=e.min,i=e.max,c=(o=e.step)!=null?o:1,s=e.scale||"linear";if(e.multiple){if(!Array.isArray(n)){console.warn(`updateSliderField: Expected array for multiple field "${t}", got ${typeof n}`);return}const f=a.querySelectorAll(`input[type="range"][name^="${t}\\["]`);f.forEach((d,u)=>{if(u<n.length&&n[u]!==null){const p=Number(n[u]);if(s==="exponential"){const b=Ht(p,l,i);d.value=(b*1e3).toString()}else d.value=p.toString();const m=d.closest(".slider-container");if(m){const b=m.querySelector(".slider-value");b&&(b.textContent=p.toFixed(c<1?2:0));const g=(p-l)/(i-l)*100;d.style.background=`linear-gradient(
|
|
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(
|
|
1168
1148
|
to right,
|
|
1169
1149
|
var(--fb-primary-color) 0%,
|
|
1170
|
-
var(--fb-primary-color) ${
|
|
1171
|
-
var(--fb-border-color) ${
|
|
1150
|
+
var(--fb-primary-color) ${v}%,
|
|
1151
|
+
var(--fb-border-color) ${v}%,
|
|
1172
1152
|
var(--fb-border-color) 100%
|
|
1173
|
-
)`}
|
|
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(
|
|
1174
1154
|
to right,
|
|
1175
1155
|
var(--fb-primary-color) 0%,
|
|
1176
|
-
var(--fb-primary-color) ${
|
|
1177
|
-
var(--fb-border-color) ${
|
|
1156
|
+
var(--fb-primary-color) ${p}%,
|
|
1157
|
+
var(--fb-border-color) ${p}%,
|
|
1178
1158
|
var(--fb-border-color) 100%
|
|
1179
|
-
)`}
|
|
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=`
|
|
1180
1160
|
width: 24px;
|
|
1181
1161
|
height: 24px;
|
|
1182
1162
|
display: inline-flex;
|
|
@@ -1187,7 +1167,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1187
1167
|
border-radius: 4px;
|
|
1188
1168
|
cursor: pointer;
|
|
1189
1169
|
flex-shrink: 0;
|
|
1190
|
-
`,o.innerHTML=
|
|
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=`
|
|
1191
1171
|
position: absolute;
|
|
1192
1172
|
width: ${e.size}px;
|
|
1193
1173
|
height: ${e.size}px;
|
|
@@ -1207,7 +1187,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1207
1187
|
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
|
|
1208
1188
|
transition: transform 0.1s, opacity 0.1s;
|
|
1209
1189
|
pointer-events: all;
|
|
1210
|
-
`,t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.15)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),t.addEventListener("click",n=>{n.stopPropagation(),e.onClick(n)}),t}function
|
|
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=`
|
|
1211
1191
|
width: 100%;
|
|
1212
1192
|
border-collapse: collapse;
|
|
1213
1193
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
@@ -1215,13 +1195,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1215
1195
|
font-size: var(--fb-font-size);
|
|
1216
1196
|
font-family: var(--fb-font-family);
|
|
1217
1197
|
color: var(--fb-text-color);
|
|
1218
|
-
`,n.forEach((
|
|
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=`
|
|
1219
1199
|
padding: 6px 10px;
|
|
1220
1200
|
border: var(--fb-border-width) solid var(--fb-border-color);
|
|
1221
1201
|
text-align: left;
|
|
1222
1202
|
vertical-align: top;
|
|
1223
|
-
${
|
|
1224
|
-
`,
|
|
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=`
|
|
1225
1205
|
position: absolute; top: 0; left: 0; right: 0; bottom: 0;
|
|
1226
1206
|
background: rgba(255,255,255,0.8); display: flex;
|
|
1227
1207
|
align-items: center; justify-content: center; flex-direction: column;
|
|
@@ -1230,13 +1210,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1230
1210
|
width: 24px; height: 24px; border: 3px solid var(--fb-border-color, #ccc);
|
|
1231
1211
|
border-top-color: var(--fb-primary-color, #0066cc); border-radius: 50%;
|
|
1232
1212
|
animation: fb-spin 0.8s linear infinite;
|
|
1233
|
-
`;const o=document.createElement("span");return o.textContent=t,o.style.cssText="font-size: var(--fb-font-size-small, 12px); color: var(--fb-text-color, #333);",n.appendChild(r),n.appendChild(o),e.appendChild(n),n}function
|
|
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=`
|
|
1234
1214
|
border-collapse: collapse;
|
|
1235
1215
|
font-size: var(--fb-font-size);
|
|
1236
1216
|
font-family: var(--fb-font-family);
|
|
1237
1217
|
color: var(--fb-text-color);
|
|
1238
1218
|
table-layout: fixed;
|
|
1239
|
-
`,
|
|
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=`
|
|
1240
1220
|
position: absolute; top: 2px; left: 2px;
|
|
1241
1221
|
width: 20px; height: 20px;
|
|
1242
1222
|
padding: 0;
|
|
@@ -1246,7 +1226,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1246
1226
|
background: transparent;
|
|
1247
1227
|
cursor: pointer;
|
|
1248
1228
|
z-index: 2;
|
|
1249
|
-
`,
|
|
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=`
|
|
1250
1230
|
position: fixed;
|
|
1251
1231
|
display: none;
|
|
1252
1232
|
background: white;
|
|
@@ -1257,7 +1237,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1257
1237
|
z-index: 1000;
|
|
1258
1238
|
gap: 4px;
|
|
1259
1239
|
flex-direction: column;
|
|
1260
|
-
`,o.appendChild(K);function
|
|
1240
|
+
`,o.appendChild(K);function P(T,A){const L=document.createElement("button");return L.type="button",L.textContent=T,L.style.cssText=`
|
|
1261
1241
|
padding: 4px 10px;
|
|
1262
1242
|
font-size: var(--fb-font-size-small);
|
|
1263
1243
|
color: var(--fb-text-color);
|
|
@@ -1267,8 +1247,8 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1267
1247
|
cursor: pointer;
|
|
1268
1248
|
white-space: nowrap;
|
|
1269
1249
|
text-align: left;
|
|
1270
|
-
`,L.addEventListener("mouseenter",()=>{L.style.background="var(--fb-background-hover-color)"}),L.addEventListener("mouseleave",()=>{L.style.background="transparent"}),L.addEventListener("click",()=>{
|
|
1271
|
-
`),fe=`<table>${X.join("")}</table>`;(P=F.clipboardData)==null||P.setData("text/plain",he),(J=F.clipboardData)==null||J.setData("text/html",fe)},S.onpaste=F=>{var te,U,P,J,G,O,Z,Y,le;const Q=v.anchor;if(!Q)return;const X=(U=(te=F.clipboardData)==null?void 0:te.getData("text/plain"))!=null?U:"",he=X.includes(" ")||X.split(/\r?\n/).filter(be=>be).length>1,fe=S.querySelector("[contenteditable='true']");if(fe&&!he)return;if(F.preventDefault(),fe){fe.contentEditable="inherit";const be=parseInt((J=(P=fe.closest("td"))==null?void 0:P.getAttribute("data-row"))!=null?J:"0",10),Ie=parseInt((O=(G=fe.closest("td"))==null?void 0:G.getAttribute("data-col"))!=null?O:"0",10);h[be]&&(h[be][Ie]=(Z=fe.textContent)!=null?Z:"")}if(!X.trim())return;const W=X.split(/\r?\n/).map(be=>be.split(" "));W.length>1&&W[W.length-1].length===1&&W[W.length-1][0]===""&&W.pop();const ue=Q.row,ve=Q.col,ye=ue+W.length;for(;h.length<ye;)h.push(Array((le=(Y=h[0])==null?void 0:Y.length)!=null?le:1).fill(""));const ke=Math.max(...W.map(be=>be.length)),He=ve+ke;if(h[0]&&He>h[0].length){const be=He-h[0].length;h.forEach(Ie=>{for(let tt=0;tt<be;tt++)Ie.push("")})}for(let be=0;be<W.length;be++)for(let Ie=0;Ie<W[be].length;Ie++){const tt=ue+be,di=ve+Ie;h[tt]&&(h[tt][di]=W[be][Ie])}w(),N()}}const q=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=q.dataset.afterCol)!=null?A:"0",10);xe(T)}});q.style.position="absolute",q.style.display="none",x.appendChild(q);const B=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>{var A;const T=parseInt((A=B.dataset.afterRow)!=null?A:"0",10);me(T)}});B.style.position="absolute",B.style.display="none",x.appendChild(B);let re=[],oe=[];const de=Ve({label:"+",title:k("tableAddColumn",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>xe()});de.style.position="absolute",de.style.display="none",x.appendChild(de);const ce=Ve({label:"+",title:k("tableAddRow",p),size:20,color:"var(--fb-primary-color, #0066cc)",textColor:"white",onClick:()=>me()});ce.style.position="absolute",ce.style.display="none",x.appendChild(ce);function ge(){var A,T;re.forEach(U=>U.remove()),re=[],oe.forEach(U=>U.remove()),oe=[];const L=h.length>0?h[0].length:0,D=h.length;if(L>1){const U=Array.from(S.querySelectorAll("thead td[data-col]"));for(const P of U){const J=parseInt((A=P.getAttribute("data-col"))!=null?A:"0",10),G=Ve({label:"\xD7",title:k("tableRemoveColumn",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>$(J)});G.setAttribute("data-action","remove-col"),G.setAttribute("data-col",String(J)),G.style.position="absolute",G.style.display="none",x.appendChild(G),re.push(G)}}if(D>1){const U=[...S.tHead?Array.from(S.tHead.rows):[],...S.tBodies[0]?Array.from(S.tBodies[0].rows):[]].filter(P=>P.querySelector("td[data-row]"));for(const P of U){const J=P.querySelector("td[data-row]");if(!J)continue;const G=parseInt((T=J.getAttribute("data-row"))!=null?T:"0",10),O=Ve({label:"\xD7",title:k("tableRemoveRow",p),size:16,color:"var(--fb-error-color, #dc3545)",textColor:"white",onClick:()=>Ae(G)});O.setAttribute("data-action","remove-row"),O.setAttribute("data-row",String(G)),O.style.position="absolute",O.style.display="none",x.appendChild(O),oe.push(O)}}function j(U,P,J,G,O){var Z;const Y=O?Array.from(S.querySelectorAll("thead td[data-col]")):[];let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.left+ue.right)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.right);ke<fe&&ke<20&&(fe=ke,X=ue.right-P.left+G,he=parseInt((Z=Y[W].getAttribute("data-col"))!=null?Z:"0",10))}re.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.left+ve.right)/2-P.left+G;W.style.left=`${ye-8}px`,W.style.top="2px",W.style.display="flex"}),O&&he>=0?(q.style.display="flex",q.style.left=`${X-10}px`,q.style.top=`${J.top-P.top-10}px`,q.dataset.afterCol=String(he)):q.style.display="none"}function F(U,P,J,G,O){var Z;const Y=[];if(O){if(S.tHead)for(const W of Array.from(S.tHead.rows))W.querySelector("td[data-row]")&&Y.push(W);if(S.tBodies[0])for(const W of Array.from(S.tBodies[0].rows))W.querySelector("td[data-row]")&&Y.push(W)}let le=-1,Q=1/0,X=-1,he=-1,fe=1/0;for(let W=0;W<Y.length;W++){const ue=Y[W].getBoundingClientRect(),ve=(ue.top+ue.bottom)/2,ye=Math.abs(U-ve);ye<Q&&(Q=ye,le=W);const ke=Math.abs(U-ue.bottom);if(ke<fe&&ke<14){fe=ke,X=ue.bottom-P.top;const He=Y[W].querySelector("td[data-row]");he=parseInt((Z=He==null?void 0:He.getAttribute("data-row"))!=null?Z:"0",10)}}oe.forEach((W,ue)=>{if(!O||ue!==le){W.style.display="none";return}const ve=Y[ue].getBoundingClientRect(),ye=(ve.top+ve.bottom)/2-P.top;W.style.left="4px",W.style.top=`${ye-8}px`,W.style.display="flex"}),O&&he>=0?(B.style.display="flex",B.style.top=`${X-10}px`,B.style.left=`${J.left-P.left+G-10}px`,B.dataset.afterRow=String(he)):B.style.display="none"}let te=!1;x.onmousemove=U=>{const P=U.target;if(P.tagName==="BUTTON"&&P.parentElement===x||te)return;te=!0;const J=U.clientX,G=U.clientY;requestAnimationFrame(()=>{te=!1;const O=x.getBoundingClientRect(),Z=S.getBoundingClientRect(),Y=x.scrollLeft,le=G>=O.top&&G<Z.top+4,Q=J>=O.left&&J<Z.left+4,X=Math.min(Z.right,O.right),he=J>X-20&&J<=O.right,fe=G>Z.bottom-4&&G<=O.bottom+20;if(j(J,O,Z,Y,le),F(G,O,Z,Y,Q),de.style.display=he?"flex":"none",he&&(de.style.left=`${O.right-O.left+Y-20}px`,de.style.top=`${(Z.top+Z.bottom)/2-O.top-10}px`),ce.style.display=fe?"flex":"none",fe){const W=(O.left+O.right)/2-O.left+Y;ce.style.left=`${W-10}px`,ce.style.top=`${Z.bottom-O.top-10}px`}})},x.onmouseleave=()=>{re.forEach(U=>{U.style.display="none"}),oe.forEach(U=>{U.style.display="none"}),q.style.display="none",B.style.display="none",de.style.display="none",ce.style.display="none"}}N()}function $l(e){var t,n;return{cells:er((t=e.rows)!=null?t:3,(n=e.columns)!=null?n:3),merges:[]}}function Pt(e){return e!==null&&typeof e=="object"&&"cells"in e&&Array.isArray(e.cells)}function Wt(e,t){return e!==null&&typeof e=="object"&&t in e&&Array.isArray(e[t])}function Sl(e,t,n,r){var o,a,l,i;const c=t.state,s=ae(e,c,t),f=t.prefill[e.key],d=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",u=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges";let p;if(Pt(f))p={cells:f.cells,merges:f.merges?We(f.merges):[]};else if(f&&Wt(f,d)){const m=f[u];p={cells:f[d],merges:m?We(m):[]}}else if(Pt(e.default))p={cells:e.default.cells,merges:e.default.merges?We(e.default.merges):[]};else if(e.default&&Wt(e.default,d)){const m=e.default[u];p={cells:e.default[d],merges:m?We(m):[]}}else p=$l(e);if(p.merges&&p.merges.length>0){const m=p.cells.length,b=m>0?p.cells[0].length:0,g=Ut(p.merges,m,b);g&&(console.warn(`Table "${e.key}": invalid prefill merges stripped (${g})`),p={...p,merges:[]})}s?xl(p,n):kl(e,p,r,t,n)}function Ll(e,t,n){var r,o;const{scopeRoot:a,skipValidation:l}=n,i=[],c=(o=(r=e.fieldNames)==null?void 0:r.cells)!=null?o:"cells",s=a.querySelector(`[name="${t}"]`);if(!s)return{value:null,errors:i};let f;try{f=JSON.parse(s.value)}catch(d){return i.push(`${t}: invalid table data`),{value:null,errors:i}}if(!l&&e.required){const d=f[c];d!=null&&d.some(u=>u.some(p=>p.trim()!==""))||i.push(`${t}: ${k("required",n.state)}`)}return{value:f,errors:i}}function Tl(e,t,n,r){var o,a,l,i;const{scopeRoot:c}=r,s=(a=(o=e.fieldNames)==null?void 0:o.cells)!=null?a:"cells",f=(i=(l=e.fieldNames)==null?void 0:l.merges)!=null?i:"merges",d=c.querySelector(`[name="${t}"]`);if(!d){console.warn(`updateTableField: no hidden input found for "${t}". Re-render to reflect new data.`);return}let u=null;if(Pt(n))u={cells:n.cells,merges:n.merges?We(n.merges):[]};else if(n&&Wt(n,s)){const p=n[f];u={cells:n[s],merges:p?We(p):[]}}u&&d._applyExternalUpdate?d._applyExternalUpdate(u):d.value=JSON.stringify(n)}function Al(e,t){e.style.overflow="hidden",e.style.resize="none";const n=(e.value.match(/\n/g)||[]).length+1;e.rows=Math.max(3,n);const r=()=>{e.isConnected&&(e.style.height="0",e.style.height=`${e.scrollHeight}px`,t&&(t.style.height=`${e.scrollHeight}px`))};if(e.addEventListener("input",r),setTimeout(()=>{e.isConnected&&r()},0),typeof ResizeObserver=="undefined")return;let o=-1;const a=new ResizeObserver(l=>{var i,c,s,f,d;if(!e.isConnected){a.disconnect();return}const u=l[0],p=(d=(f=(c=(i=u==null?void 0:u.contentBoxSize)==null?void 0:i[0])==null?void 0:c.inlineSize)!=null?f:(s=u==null?void 0:u.contentRect)==null?void 0:s.width)!=null?d:0;p!==o&&(o=p,r())});a.observe(e)}function Vt(e,t){var n,r,o,a;const l=new Map,i=new Map;for(const c of e){const s=t.resourceIndex.get(c),f=(n=s==null?void 0:s.name)!=null?n:c;i.set(f,((r=i.get(f))!=null?r:0)+1)}for(const c of e){const s=t.resourceIndex.get(c),f=(o=s==null?void 0:s.name)!=null?o:c;((a=i.get(f))!=null?a:1)>1&&s?l.set(c,`${f} (${xr(s.size)})`):l.set(c,f)}return l}function Kt(e){return e?e.type.startsWith("image/"):!1}function nr(e,t){const n=Vt(e,t),r=new Map;for(const o of e){const a=n.get(o);a&&r.set(a,o)}return r}function _t(e){return/\s/.test(e)||e.includes('"')?`@"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`@${e}`}function ht(e){const t=[],n=e.length;let r=0;for(;r<n;)if(e[r]==="@"){if(r>0&&!/\s/.test(e[r-1])){r++;continue}const o=r;if(r++,r<n&&e[r]==='"'){r++;let a="";for(;r<n&&e[r]!=='"';)e[r]==="\\"&&r+1<n?(a+=e[r+1],r+=2):(a+=e[r],r++);r<n&&e[r]==='"'&&(r++,(r>=n||/\s/.test(e[r]))&&t.push({start:o,end:r,raw:e.slice(o,r),name:a}))}else if(r<n&&!/\s/.test(e[r])){const a=r;for(;r<n&&!/\s/.test(e[r]);)r++;const l=e.slice(a,r);t.push({start:o,end:r,raw:e.slice(o,r),name:l})}}else r++;return t}function Fl(e,t){if(t.size===0)return[];const n=ht(e),r=[];for(const o of n){const a=t.get(o.name);a&&r.push({start:o.start,end:o.end,name:o.name,rid:a})}return r}function zl(e,t){const n=Fl(e,t);if(n.length===0)return e;let r="",o=0;for(const a of n)r+=e.slice(o,a.start),r+=`@${a.rid}`,o=a.end;return r+=e.slice(o),r}function rr(e,t,n){const r=Vt(t,n),o=new Map;for(const c of t){const s=r.get(c);s&&o.set(c,s)}const a=ht(e);if(a.length===0)return e;let l="",i=0;for(const c of a){l+=e.slice(i,c.start);const s=o.get(c.name);s?l+=_t(s):l+=c.raw,i=c.end}return l+=e.slice(i),l}function or(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else if(r.config.getThumbnail){r.config.getThumbnail(t).then(a=>{var l;if(!a||!e.isConnected)return;const i=document.createElement("img");i.alt=(l=n==null?void 0:n.name)!=null?l:t,i.src=a,i.style.cssText="width: 100%; height: 100%; object-fit: cover; display: block;",we(e),e.appendChild(i)}).catch(a=>{var l,i;(i=(l=r.config).onThumbnailError)==null||i.call(l,a,t)});const o=document.createElement("div");o.style.cssText="width: 100%; height: 100%; background: var(--fb-background-hover-color, #f3f4f6); display: flex; align-items: center; justify-content: center;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',e.appendChild(o)}else{const o=document.createElement("div");if(o.style.cssText="width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; box-sizing: border-box;",o.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',n!=null&&n.name){const a=document.createElement("span");a.style.cssText="font-size: 9px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44px; color: var(--fb-text-color, #111827);",a.textContent=n.name,o.appendChild(a)}e.appendChild(o)}}function lr(e,t,n,r){if(we(e),n!=null&&n.file&&Kt(n)){const o=document.createElement("img");o.alt=n.name,o.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;";const a=new FileReader;a.onload=l=>{var i;o.src=((i=l.target)==null?void 0:i.result)||""},a.readAsDataURL(n.file),e.appendChild(o)}else r.config.getThumbnail&&r.config.getThumbnail(t).then(o=>{var a;if(!o||!e.isConnected)return;const l=document.createElement("img");l.alt=(a=n==null?void 0:n.name)!=null?a:t,l.src=o,l.style.cssText="max-width: 120px; max-height: 120px; object-fit: contain; display: block;",we(e),e.appendChild(l)}).catch(o=>{var a,l;(l=(a=r.config).onThumbnailError)==null||l.call(a,o,t)})}function ir(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(4,Math.min(n.left+n.width/2-r.width/2,window.innerWidth-r.width-4)),a=n.top-r.height-8,l=n.bottom+8,i=a>=4?a:l;e.style.left=`${o}px`,e.style.top=`${Math.max(4,i)}px`}function ar(e,t,n){const r=n.resourceIndex.get(t),o=document.createElement("div");o.className="fb-richinput-portal-tooltip fb-richinput-mention-tooltip",o.style.cssText=`
|
|
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,"&").replace(/</g,"<").replace(/>/g,">");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=`
|
|
1272
1252
|
position: fixed;
|
|
1273
1253
|
z-index: 99999;
|
|
1274
1254
|
background: #fff;
|
|
@@ -1279,7 +1259,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1279
1259
|
pointer-events: none;
|
|
1280
1260
|
min-width: 60px;
|
|
1281
1261
|
max-width: 140px;
|
|
1282
|
-
`;const
|
|
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=`
|
|
1283
1263
|
position: fixed;
|
|
1284
1264
|
z-index: 99999;
|
|
1285
1265
|
background: #fff;
|
|
@@ -1290,17 +1270,17 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1290
1270
|
pointer-events: auto;
|
|
1291
1271
|
min-width: 80px;
|
|
1292
1272
|
max-width: 260px;
|
|
1293
|
-
`;const
|
|
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=`
|
|
1294
1274
|
position: relative;
|
|
1295
1275
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
1296
1276
|
border-radius: 16px;
|
|
1297
1277
|
background: var(--fb-background-color, #f9fafb);
|
|
1298
1278
|
transition: box-shadow 0.15s, border-color 0.15s;
|
|
1299
|
-
`,p.addEventListener("focusin",()=>{p.style.borderColor="var(--fb-primary-color, #0066cc)",p.style.boxShadow="0 0 0 2px color-mix(in srgb, var(--fb-primary-color, #0066cc) 25%, transparent)"}),p.addEventListener("focusout",()=>{p.style.borderColor="var(--fb-border-color, #d1d5db)",p.style.boxShadow="none"});const
|
|
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=`
|
|
1300
1280
|
position: absolute;
|
|
1301
1281
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
1302
|
-
${
|
|
1303
|
-
${
|
|
1282
|
+
${br}
|
|
1283
|
+
${xt}
|
|
1304
1284
|
white-space: pre-wrap;
|
|
1305
1285
|
word-break: break-word;
|
|
1306
1286
|
color: transparent;
|
|
@@ -1309,10 +1289,10 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1309
1289
|
border-radius: inherit;
|
|
1310
1290
|
box-sizing: border-box;
|
|
1311
1291
|
z-index: 2;
|
|
1312
|
-
`;const
|
|
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=`
|
|
1313
1293
|
width: 100%;
|
|
1314
|
-
${
|
|
1315
|
-
${
|
|
1294
|
+
${br}
|
|
1295
|
+
${xt}
|
|
1316
1296
|
background: transparent;
|
|
1317
1297
|
border: none;
|
|
1318
1298
|
outline: none;
|
|
@@ -1322,9 +1302,9 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1322
1302
|
position: relative;
|
|
1323
1303
|
z-index: 1;
|
|
1324
1304
|
caret-color: var(--fb-text-color, #111827);
|
|
1325
|
-
`,
|
|
1326
|
-
`;return}let
|
|
1327
|
-
`}const
|
|
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=`
|
|
1328
1308
|
position: absolute;
|
|
1329
1309
|
right: 6px;
|
|
1330
1310
|
bottom: 6px;
|
|
@@ -1340,7 +1320,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1340
1320
|
justify-content: center;
|
|
1341
1321
|
color: var(--fb-text-muted-color, #9ca3af);
|
|
1342
1322
|
transition: color 0.15s, background 0.15s;
|
|
1343
|
-
`,
|
|
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=`
|
|
1344
1324
|
display: none;
|
|
1345
1325
|
position: absolute;
|
|
1346
1326
|
bottom: 100%;
|
|
@@ -1355,16 +1335,16 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1355
1335
|
max-height: 200px;
|
|
1356
1336
|
overflow-y: auto;
|
|
1357
1337
|
margin-bottom: 4px;
|
|
1358
|
-
${
|
|
1359
|
-
`;function
|
|
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=`
|
|
1360
1340
|
padding: 5px 10px;
|
|
1361
1341
|
cursor: pointer;
|
|
1362
1342
|
color: var(--fb-text-color, #111827);
|
|
1363
|
-
background: ${
|
|
1343
|
+
background: ${M===d.selectedIndex?"var(--fb-background-hover-color, #f3f4f6)":"transparent"};
|
|
1364
1344
|
display: flex;
|
|
1365
1345
|
align-items: center;
|
|
1366
1346
|
gap: 8px;
|
|
1367
|
-
`;const
|
|
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=`
|
|
1368
1348
|
position: relative;
|
|
1369
1349
|
width: 48px;
|
|
1370
1350
|
height: 48px;
|
|
@@ -1374,14 +1354,14 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1374
1354
|
flex-shrink: 0;
|
|
1375
1355
|
cursor: pointer;
|
|
1376
1356
|
background: #fff;
|
|
1377
|
-
`;const
|
|
1378
|
-
`:""}${_t(A)} `;
|
|
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=`
|
|
1379
1359
|
position: static;
|
|
1380
1360
|
display: inline-block;
|
|
1381
1361
|
font-size: var(--fb-font-size-small);
|
|
1382
1362
|
color: var(--fb-text-secondary-color);
|
|
1383
1363
|
pointer-events: none;
|
|
1384
|
-
|
|
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=`
|
|
1385
1365
|
position: relative;
|
|
1386
1366
|
width: 48px; height: 48px;
|
|
1387
1367
|
border: 1px solid var(--fb-border-color, #d1d5db);
|
|
@@ -1390,12 +1370,12 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1390
1370
|
flex-shrink: 0;
|
|
1391
1371
|
background: #fff;
|
|
1392
1372
|
cursor: default;
|
|
1393
|
-
`;const b=document.createElement("div");b.style.cssText="width: 48px; height: 48px; border-radius: inherit; overflow: hidden;",
|
|
1394
|
-
${
|
|
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}
|
|
1395
1375
|
color: var(--fb-text-color, #111827);
|
|
1396
1376
|
white-space: pre-wrap;
|
|
1397
1377
|
word-break: break-word;
|
|
1398
|
-
`;const
|
|
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=`
|
|
1399
1379
|
display: inline;
|
|
1400
1380
|
background: color-mix(in srgb, var(--fb-primary-color, #0066cc) 15%, transparent);
|
|
1401
1381
|
color: var(--fb-primary-color, #0066cc);
|
|
@@ -1403,7 +1383,7 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1403
1383
|
padding: 1px 6px;
|
|
1404
1384
|
font-weight: 500;
|
|
1405
1385
|
cursor: default;
|
|
1406
|
-
`;const
|
|
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,""").replace(/</g,"<").replace(/>/g,">")}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=`
|
|
1407
1387
|
.fb-markdown {
|
|
1408
1388
|
font-family: var(--fb-font-family, inherit);
|
|
1409
1389
|
font-size: var(--fb-font-size, 1rem);
|
|
@@ -1480,11 +1460,13 @@ var FormBuilder=(function(Fe){"use strict";function k(e,t,n){const r=t.config.lo
|
|
|
1480
1460
|
.fb-markdown strong { font-weight: var(--fb-font-weight-medium, 600); }
|
|
1481
1461
|
.fb-markdown em { font-style: italic; }
|
|
1482
1462
|
.fb-markdown s { text-decoration: line-through; }
|
|
1483
|
-
`,document.head.appendChild(e)}const jl=["javascript:","data:","vbscript:","blob:"],Ol=["javascript:","vbscript:","blob:"];function Ul(e){return!!(Ol.some(t=>e.startsWith(t))||e.startsWith("data:")&&!e.startsWith("data:image/"))}function Pl(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Wl(e){e.querySelectorAll("a[href]").forEach(t=>{var n;const r=((n=t.getAttribute("href"))!=null?n:"").trim().toLowerCase();jl.some(o=>r.startsWith(o))&&t.setAttribute("href","#"),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")}),e.querySelectorAll("img[src]").forEach(t=>{var n;const r=((n=t.getAttribute("src"))!=null?n:"").trim().toLowerCase();Ul(r)&&t.setAttribute("src","")})}function Vl(e,t,n){if(typeof e.content!="string")throw new Error(`renderMarkdown: markdown element${e.key?` "${e.key}"`:""} requires "content" to be a string (got ${e.content===null?"null":typeof e.content})`);Dl();const r=document.createElement("div");r.className="fb-markdown";const o=Pl(e.content);return r.innerHTML=Jt(o),Wl(r),n.appendChild(r),r}function Kl(e,t,n){return{value:void 0,errors:[],skip:!0}}function _l(e,t,n,r){}function Jl(e,t,n){var r;const{scopeRoot:o}=n,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`),l=(r=a==null?void 0:a.value)!=null?r:"";if(l===""){const i="default"in e?e.default:null;return{value:i!==void 0?i:null,errors:[]}}return{value:Ct(l),errors:[]}}function Xl(e,t,n,r){const{scopeRoot:o}=r,a=o.querySelector(`input[type="hidden"][data-hidden-field="true"][name="${t}"]`);a&&(a.value=Zt(n))}const mr={text:{validate:nn,update:rn},textarea:{validate:Ir,update:Rr},number:{validate:jr,update:Or},select:{validate:Wr,update:Vr},switcher:{validate:Xr,update:Yr},boolean:{validate:Qr,update:eo,ownsLabel:!0},file:{validate:qn,update:Hn},files:{validate:qn,update:Hn},colour:{validate:ol,update:ll},slider:{validate:sl,update:cl},container:{validate:Gn,update:Zn},group:{validate:hl,update:bl},table:{validate:Ll,update:Tl},richinput:{validate:ql,update:Bl},hidden:{validate:Jl,update:Xl},markdown:{validate:Kl,update:_l}};function hr(e){return mr[e]||null}function br(e){return e.type!=="markdown"&&(e.type==="hidden"||e.hidden)?mr.hidden:hr(e.type)}function Yl(e,t,n){const r=br(e);return r&&r.validate?r.validate(e,t,n):null}function Gl(e,t,n,r){const o=br(e);return o&&o.update?(o.update(e,t,n,r),!0):!1}function Zl(e,t){const n=document.getElementById(e);if(!n)return;if(!t.isConnected){n.remove();return}const r=!n.classList.contains("hidden");if(document.querySelectorAll('[id^="tooltip-"]').forEach(f=>{f.classList.add("hidden")}),r)return;const o=t.getBoundingClientRect(),a=window.innerWidth,l=window.innerHeight;n&&n.parentElement!==document.body&&document.body.appendChild(n),n.style.visibility="hidden",n.style.position="fixed",n.classList.remove("hidden");const i=n.getBoundingClientRect();n.classList.add("hidden"),n.style.visibility="visible";let c=o.left,s=o.bottom+5;c+i.width>a&&(c=o.right-i.width),s+i.height>l&&(s=o.top-i.height-5),c<10&&(c=10),s<10&&(s=o.bottom+5),n.style.left=`${c}px`,n.style.top=`${s}px`,n.classList.remove("hidden"),setTimeout(()=>{n.classList.add("hidden")},25e3)}typeof document!="undefined"&&document.addEventListener("click",e=>{const t=e.target,n=t.closest("button")&&t.closest("button").onclick,r=t.closest('[id^="tooltip-"]');!n&&!r&&document.querySelectorAll('[id^="tooltip-"]').forEach(o=>{o.classList.add("hidden")})});function gr(e,t){var n,r,o;if(!e.enableIf)return!1;try{const a=(r=(n=t.formData)!=null?n:t.prefill)!=null?r:{},l=((o=e.enableIf.scope)!=null?o:"relative")==="relative"&&t.path?t.prefill:void 0;return!je(e.enableIf,a,l)}catch(a){console.error(`Error evaluating enableIf for field "${e.key}":`,a)}return!1}function Ql(e,t){const n=t.querySelector(`[name="${e}"]`);if(n){if(n instanceof HTMLSelectElement)return n.value;if(n instanceof HTMLInputElement){if(n.type==="checkbox")return n.checked;if(n.type==="radio"){const r=t.querySelector(`[name="${e}"]:checked`);return r?r.value:void 0}else return n.dataset.hiddenField?Ct(n.value):n.value}else if(n instanceof HTMLTextAreaElement)return n.value}}function ei(e,t){const n=e.match(/[^.[\]]+|\[\d+\]/g);if(!n||n.length===0)return{};const r={};let o=r;for(let l=0;l<n.length-1;l++){const i=n[l],c=n[l+1],s=c.startsWith("[")&&c.endsWith("]")?[]:{};if(i.startsWith("[")&&i.endsWith("]")){const f=parseInt(i.slice(1,-1),10);o[f]=s}else o[i]=s;o=s}const a=n[n.length-1];return a.startsWith("[")&&a.endsWith("]")?o[parseInt(a.slice(1,-1),10)]=t:o[a]=t,r}function yt(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot re-evaluate enableIf: formRoot is null");return}const a=t.enableIf,l=(r=a.scope)!=null?r:"relative",i=!n.path||n.path===""?"absolute":l,c=a.key,s=i==="relative"&&n.path?`${n.path}.${c}`:c,f=Ql(s,o),d=ei(c,f),u=i==="relative"?{}:d,p=i==="relative"?d:void 0;try{je(a,u,p)?(e.style.display="",e.classList.remove("fb-field-wrapper-disabled"),e.removeAttribute("data-conditionally-disabled")):(e.style.display="none",e.classList.add("fb-field-wrapper-disabled"),e.setAttribute("data-conditionally-disabled","true"))}catch(m){console.error(`Error re-evaluating enableIf for field "${t.key}":`,m)}}function vr(e,t,n){var r;if(!t.enableIf)return;const o=n.state.formRoot;if(!o){console.error("Cannot setup enableIf listeners: formRoot is null");return}const a=t.enableIf,l=(r=a.scope)!=null?r:"relative",i=a.key;let c;l==="relative"&&n.path?c=`${n.path}.${i}`:c=i;const s=o.querySelector(`[name="${c}"]`);if(!s){const f=new MutationObserver(()=>{const d=o.querySelector(`[name="${c}"]`);d&&(d.addEventListener("change",()=>{yt(e,t,n)}),d.addEventListener("input",()=>{yt(e,t,n)}),f.disconnect(),n.state.enableIfObservers.delete(f))});n.state.enableIfObservers.add(f),f.observe(o,{childList:!0,subtree:!0});return}s.addEventListener("change",()=>{yt(e,t,n)}),s.addEventListener("input",()=>{yt(e,t,n)})}function ti(e){var t,n;const r=document.createElement("label");if(r.className="font-medium text-gray-900",r.style.cssText="font-size: var(--fb-label-font-size, 0.75rem); line-height: var(--fb-label-line-height, 1.2);",r.textContent=(n=(t=e.label)!=null?t:e.key)!=null?n:"",e.required){const o=document.createElement("span");o.className="text-red-500 ml-1",o.textContent="*",r.appendChild(o)}return r}function ni(e,t){const n=document.createElement("button");n.type="button",n.className="ml-2 text-gray-400 hover:text-gray-600",n.innerHTML='<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>';const r=`tooltip-${e.key}-${Math.random().toString(36).substr(2,9)}`,o=document.createElement("div");return o.id=r,o.className="hidden absolute z-50 bg-gray-200 text-gray-900 text-sm rounded-lg p-3 max-w-sm border border-gray-300 shadow-lg",o.style.position="fixed",o.textContent=e.description||e.hint||"Field information",document.body.appendChild(o),t.tooltipElements.add(o),n.onclick=a=>{a.preventDefault(),a.stopPropagation(),Zl(r,n)},n}function ri(e,t){const n=document.createElement("div");n.className="flex items-center",n.style.marginBottom="var(--fb-label-margin-bottom, 2px)",n.dataset.fbLabelRow="";const r=ti(e);if(n.appendChild(r),e.description||e.hint){const o=ni(e,t);n.appendChild(o)}return n}function oi(e,t,n,r){const o="multiple"in e&&e.multiple;switch(e.type){case"text":o?zr(e,t,n,r):Fr(e,t,n,r);break;case"textarea":o?Nr(e,t,n,r):Mr(e,t,n,r);break;case"number":o?Dr(e,t,n,r):Hr(e,t,n,r);break;case"select":o?Pr(e,t,n,r):Ur(e,t,n,r);break;case"switcher":o?Jr(e,t,n,r):_r(e,t,n,r);break;case"boolean":Zr(e,t,n,r);break;case"file":o?tl(e,t,n,r):Qo(e,t,n,r);break;case"files":el(e,t,n,r);break;case"colour":o?rl(e,t,n,r):nl(e,t,n,r);break;case"slider":o?al(e,t,n,r):il(e,t,n,r);break;case"group":ml(e,t,n,r);break;case"container":o?Xn(e,t,n,r):Jn(e,t,n,r);break;case"table":Sl(e,t,n,r);break;case"richinput":Rl(e,t,n,r);break;default:{const a=document.createElement("div");a.className="text-red-500 text-sm",a.textContent=k("unsupportedFieldType",t.state,{type:e.type}),n.appendChild(a)}}}function Xt(e,t){if(e.type==="markdown"){if(e.hidden===!0){const c=document.createElement("div");return c.style.display="none",c.setAttribute("data-fb-hidden-markdown","true"),c}const l=gr(e,t),i=document.createElement("div");return i.className=`fb-field-wrapper fb-markdown-wrapper fb-size-${e.size||"md"}`,i.setAttribute("data-field-key",wt(e,t.state)),i.setAttribute("data-fb-width",e.width||"full"),Vl(e,t,i),l&&(i.style.display="none",i.classList.add("fb-field-wrapper-disabled"),i.setAttribute("data-conditionally-disabled","true")),vr(i,e,t),i}const n=gr(e,t),r=document.createElement("div");r.className=`fb-field-wrapper fb-size-${e.size||"md"}`,r.setAttribute("data-field-key",e.key),r.setAttribute("data-fb-width",e.width||"full");const o=hr(e.type);if(!(o!=null&&o.ownsLabel)){const l=ri(e,t.state);r.appendChild(l)}const a=De(t.path,e.key);return oi(e,t,r,a),n&&(r.style.display="none",r.classList.add("fb-field-wrapper-disabled"),r.setAttribute("data-conditionally-disabled","true")),vr(r,e,t),r}dl(Xt);const Yt={uploadFile:null,downloadFile:null,getThumbnail:null,getDownloadUrl:null,actionHandler:null,onChange:null,onFieldChange:null,onThumbnailError:null,onUploadError:null,onDownloadError:null,debounceMs:300,verboseErrors:!1,enableFilePreview:!0,maxPreviewSize:"200px",readonly:!1,pickExistingFiles:null,parseTableFile:null,locale:"en",translations:{en:{removeElement:"Remove",removeRow:"Remove row",removeRowFrom:"Remove row from {label}",clickDragText:"Click or drag file",clickDragTextMultiple:"Click or drag files",noFileSelected:"No file selected",noFilesSelected:"No files selected",downloadButton:"Download",downloadFile:"Download",openInNewTab:"Open in new tab",changeButton:"Change",placeholderText:"Enter text",previewAlt:"Preview",previewUnavailable:"Preview unavailable",previewError:"Preview error",videoNotSupported:"Your browser does not support the video tag.",hintLengthRange:"{min}-{max} chars",hintMaxLength:"\u2264{max} chars",hintMinLength:"\u2265{min} chars",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}MB",hintFormats:"{formats}",hintRequired:"Required",hintOptional:"Optional",hintPattern:"Format: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"Uploading\u2026",filesCounter:"{count}/{max}",fromLibrary:"From library",libraryEmpty:"Library is empty",libraryHint:"Choose from previously uploaded files",dropToUpload:"Release to upload",replaceFile:"Replace",clearAll:"Clear all",pickerError:"Failed to load files from library",required:"Required",minItems:"Minimum {min} items required",maxItems:"Maximum {max} items allowed",minLength:"Minimum {min} characters",maxLength:"Maximum {max} characters",minValue:"Must be at least {min}",maxValue:"Must be at most {max}",patternMismatch:"Invalid format",invalidPattern:"Invalid pattern in schema",notANumber:"Must be a number",invalidHexColour:"Invalid hex color",minFiles:"Minimum {min} files required",maxFiles:"Maximum {max} files allowed",invalidFileExtension:'File "{name}" has unsupported format. Allowed: {formats}',invalidFileMime:'File "{name}": file type {type} not allowed (allowed: {mimes})',fileTooLarge:'File "{name}" exceeds maximum size of {maxSize}MB',uploadFailed:'Failed to upload "{name}": {error}',filesLimitExceeded:"{skipped} file(s) skipped: maximum {max} files allowed",unsupportedFieldType:"Unsupported field type: {type}",invalidOption:"Invalid option",tableAddRow:"Add row",tableAddColumn:"Add column",tableRemoveRow:"Remove row",tableRemoveColumn:"Remove column",tableMergeCells:"Merge cells (Ctrl+M)",tableSplitCell:"Split cell (Ctrl+Shift+M)",tableImportFile:"Import",tableImporting:"Importing...",tableImportError:"Import failed: {error}",richinputPlaceholder:"Type text...",richinputAttachFile:"Attach file",richinputMention:"Mention",richinputRemoveFile:"Remove"},ru:{removeElement:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",removeRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",removeRowFrom:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0438\u0437 \xAB{label}\xBB",clickDragText:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B",clickDragTextMultiple:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B",noFileSelected:"\u0424\u0430\u0439\u043B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D",noFilesSelected:"\u041D\u0435\u0442 \u0444\u0430\u0439\u043B\u043E\u0432",downloadButton:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",downloadFile:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C",openInNewTab:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435",changeButton:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",placeholderText:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442",previewAlt:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",previewUnavailable:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D",previewError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430",videoNotSupported:"\u0412\u0430\u0448 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043E.",hintLengthRange:"{min}-{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMaxLength:"\u2264{max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintMinLength:"\u2265{min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",hintValueRange:"{min}-{max}",hintMaxValue:"\u2264{max}",hintMinValue:"\u2265{min}",hintMaxSize:"\u2264{size}\u041C\u0411",hintFormats:"{formats}",hintRequired:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintOptional:"\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435",hintPattern:"\u0424\u043E\u0440\u043C\u0430\u0442: {pattern}",fileCountRange:"({min}-{max})",uploadingFile:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",filesCounter:"{count}/{max}",fromLibrary:"\u0418\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",libraryEmpty:"\u0411\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 \u043F\u0443\u0441\u0442\u0430",libraryHint:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0440\u0430\u043D\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0445 \u0444\u0430\u0439\u043B\u043E\u0432",dropToUpload:"\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",replaceFile:"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C",clearAll:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0432\u0441\u0435",pickerError:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0438",required:"\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u043F\u043E\u043B\u0435",minItems:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",maxItems:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432",minLength:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",maxLength:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",minValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u043C\u0435\u043D\u0435\u0435 {min}",maxValue:"\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {max}",patternMismatch:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442",invalidPattern:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0432 \u0441\u0445\u0435\u043C\u0435",notANumber:"\u0414\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u0447\u0438\u0441\u043B\u043E\u043C",invalidHexColour:"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0446\u0432\u0435\u0442\u0430",minFiles:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C {min} \u0444\u0430\u0439\u043B\u043E\u0432",maxFiles:"\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",invalidFileExtension:'\u0424\u0430\u0439\u043B "{name}" \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442. \u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0435: {formats}',invalidFileMime:'\u0424\u0430\u0439\u043B "{name}": \u0442\u0438\u043F \u0444\u0430\u0439\u043B\u0430 {type} \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u044B: {mimes})',fileTooLarge:'\u0424\u0430\u0439\u043B "{name}" \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 {maxSize}\u041C\u0411',uploadFailed:'\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C "{name}": {error}',filesLimitExceeded:"{skipped} \u0444\u0430\u0439\u043B(\u043E\u0432) \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E: \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C {max} \u0444\u0430\u0439\u043B\u043E\u0432",unsupportedFieldType:"\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043F\u043E\u043B\u044F: {type}",invalidOption:"\u041D\u0435\u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",tableAddRow:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableAddColumn:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableRemoveRow:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443",tableRemoveColumn:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446",tableMergeCells:"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438 (Ctrl+M)",tableSplitCell:"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443 (Ctrl+Shift+M)",tableImportFile:"\u0418\u043C\u043F\u043E\u0440\u0442",tableImporting:"\u0418\u043C\u043F\u043E\u0440\u0442...",tableImportError:"\u041E\u0448\u0438\u0431\u043A\u0430 \u0438\u043C\u043F\u043E\u0440\u0442\u0430: {error}",richinputPlaceholder:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442...",richinputAttachFile:"\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0444\u0430\u0439\u043B",richinputMention:"\u0423\u043F\u043E\u043C\u044F\u043D\u0443\u0442\u044C",richinputRemoveFile:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C"}},theme:{}};function li(e){const t={...Yt.translations};if(e!=null&&e.translations)for(const[n,r]of Object.entries(e.translations))t[n]={...Yt.translations[n]||{},...r};return{schema:null,formRoot:null,resourceIndex:new Map,externalActions:null,version:"1.0.0",config:{...Yt,...e,translations:t},debounceTimer:null,prefill:{},syntheticElementIds:new WeakMap,syntheticElementIdCounter:0,enableIfObservers:new Set,tooltipElements:new Set}}function ii(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,9);return`inst-${e}-${t}`}const _e={primaryColor:"#3b82f6",primaryHoverColor:"#2563eb",primarySoftColor:"#dbeafe",primarySoftHoverColor:"#bfdbfe",errorColor:"#ef4444",errorHoverColor:"#dc2626",successColor:"#10b981",accentColor:"#f59e0b",accentSoftColor:"#fef3c7",accentBorderColor:"#fde68a",accentTextColor:"#92400e",borderColor:"#d1d5db",borderHoverColor:"#9ca3af",borderFocusColor:"#3b82f6",borderStrongColor:"#9ca3af",backgroundColor:"#ffffff",backgroundHoverColor:"#f9fafb",backgroundReadonlyColor:"#f3f4f6",pageBackgroundColor:"#f9fafb",surfaceSoftColor:"#eff6ff",surfaceTintColor:"#f8fafc",textColor:"#1f2937",textSecondaryColor:"#6b7280",textMutedColor:"#9ca3af",textFaintColor:"#cbd5e1",textPlaceholderColor:"#9ca3af",textDisabledColor:"#d1d5db",buttonBgColor:"#3b82f6",buttonTextColor:"#ffffff",buttonBorderColor:"#2563eb",buttonHoverBgColor:"#2563eb",buttonHoverBorderColor:"#1d4ed8",actionBgColor:"#ffffff",actionTextColor:"#374151",actionBorderColor:"#e5e7eb",actionHoverBgColor:"#f9fafb",actionHoverBorderColor:"#d1d5db",fileUploadBgColor:"#f3f4f6",fileUploadBorderColor:"#d1d5db",fileUploadTextColor:"#9ca3af",fileUploadHoverBorderColor:"#3b82f6",inputPaddingX:"0.5rem",inputPaddingY:"0.125rem",borderRadius:"0.5rem",borderRadiusSmall:"0.375rem",borderRadiusLarge:"0.75rem",borderRadiusXLarge:"1rem",borderWidth:"1px",fontSize:"0.875rem",fontSizeSmall:"0.75rem",fontSizeExtraSmall:"0.625rem",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeightNormal:"400",fontWeightMedium:"500",lineHeight:"1.5",shadowCard:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",shadowPopover:"0 12px 32px -12px rgba(15,23,42,.18), 0 4px 12px -6px rgba(15,23,42,.08)",focusRingWidth:"2px",focusRingColor:"#3b82f6",focusRingOpacity:"0.5",transitionDuration:"200ms",slideCardBg:"#ffffff",slideCardShadow:"0 1px 2px rgba(15,23,42,.04), 0 1px 0 rgba(15,23,42,.02)",slideCardRadius:"0.5rem",slideCardMinHeight:"0",slideCardPadding:"8px",labelSectionFontSize:"0.875rem",labelSectionLetterSpacing:"normal",labelSectionTextTransform:"none",labelFontSize:"0.75rem",labelLineHeight:"1.2",labelMarginBottom:"2px"};function ai(e){const t={..._e,...e},n=[];return Object.entries(t).forEach(([r,o])=>{const a=r.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(` --fb-${a}: ${o};`)}),n.join(`
|
|
1484
|
-
`)}function
|
|
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,"&").replace(/</g,"<").replace(/>/g,">")}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=`
|
|
1485
1465
|
[data-fb-root="true"] {
|
|
1486
1466
|
${n}
|
|
1487
1467
|
}
|
|
1488
|
-
`}const
|
|
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=`
|
|
1489
1469
|
border-top: var(--fb-border-width) solid var(--fb-border-color);
|
|
1490
|
-
`,t.forEach(a=>{const l=document.createElement("button");l.type="button",tn(l,!0);const i=n.includes(a),c=this.resolveActionLabel(a.key,a.label,null,i);l.textContent=c,l.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(a.value,a.key,null)}),o.appendChild(l)}),this.state.formRoot.appendChild(o)}renderExternalActions(){if(!this.state.externalActions||!Array.isArray(this.state.externalActions))return;const t=new Map,n=[],r=[];this.state.externalActions.forEach(a=>{!a.key||!a.value||(a.related_field?(t.has(a.related_field)||t.set(a.related_field,[]),t.get(a.related_field).push(a)):n.push(a))}),t.forEach((a,l)=>{const i=this.findFormElementByFieldPath(l);if(!i){console.warn(`External action: Could not find form element for field "${l}", treating as form-level actions`),r.push(...a);return}let c=i.closest(".fb-field-wrapper");if(c||(c=i.parentElement),!c){console.warn(`External action: Could not find wrapper for field "${l}"`);return}const s=c.querySelector(".external-actions-container");s&&s.remove();const f=document.createElement("div");f.className="external-actions-container mt-3 flex flex-wrap gap-2";const d=this.findSchemaElement(l);a.forEach(u=>{const p=document.createElement("button");p.type="button",tn(p,!1);const m=this.resolveActionLabel(u.key,u.label,d);p.textContent=m,p.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),this.state.config.actionHandler&&typeof this.state.config.actionHandler=="function"&&this.state.config.actionHandler(u.value,u.key,u.related_field)}),f.appendChild(p)}),c.appendChild(f)});const o=[...n,...r];o.length>0&&this.renderFormLevelActions(o,n)}handlePrefillHintClick(t){const n=t.target;if(!n.classList.contains("fb-prefill-hint"))return;t.preventDefault(),t.stopPropagation();const r=n.getAttribute("data-hint-values"),o=n.getAttribute("data-root-hint")==="true",a=n.getAttribute("data-container-key");if(!r||!o&&!a){console.warn("Prefill hint missing required data attributes");return}try{const l=JSON.parse(r);for(const c in l){const s=o?c:`${a}.${c}`,f=l[c];this.updateField(s,f)}const i=n.closest(".fb-prefill-hints");i&&i.querySelectorAll('.fb-prefill-hint[aria-pressed="true"]').forEach(c=>c.removeAttribute("aria-pressed")),n.setAttribute("aria-pressed","true")}catch(l){console.error("Error parsing prefill hint values:",l)}}createRootPrefillHints(t){const n=document.createElement("div");return n.className="fb-prefill-hints flex flex-wrap gap-2 mb-2",t.forEach(r=>{const o=document.createElement("button");o.type="button",o.className="fb-prefill-hint",r.icon?o.textContent=`${r.icon} ${r.label}`:o.textContent=r.label,o.setAttribute("data-hint-values",JSON.stringify(r.values)),o.setAttribute("data-root-hint","true"),n.appendChild(o)}),n}renderForm(t,n,r,o){const a=kt(n);if(a.length>0){console.error("Schema validation errors:",a);return}this.disconnectEnableIfObservers(),this.removeTooltipElements(),this.state.formRoot=t,this.state.schema=n,this.state.externalActions=o||null,this.state.prefill=r||{},we(t),t.setAttribute("data-fb-root","true"),si(t,this.state.config.theme);const l=document.createElement("div");if(l.className="fb-row",n.prefillHints&&!this.state.config.readonly){const s=this.createRootPrefillHints(n.prefillHints);l.appendChild(s)}const i=document.createElement("div"),c=n.columns||1;c===1?i.className="fb-row":i.className=`grid grid-cols-${c} gap-2`,n.elements.forEach(s=>{var f,d;if(s.type!=="markdown"&&(s.hidden||s.type==="hidden")){const p=(d=(f=r==null?void 0:r[s.key])!=null?f:s.default)!=null?d:null;i.appendChild(Et(s.key,p));return}const u=Xt(s,{path:"",prefill:r||{},formData:r||{},state:this.state,instance:this});i.appendChild(u)}),l.appendChild(i),t.appendChild(l),this.state.config.readonly||t.addEventListener("click",this.handlePrefillHintClick.bind(this)),this.state.config.readonly&&this.state.externalActions&&Array.isArray(this.state.externalActions)&&this.renderExternalActions()}validateForm(t=!1){if(!this.state.schema||!this.state.formRoot)return{valid:!0,errors:[],data:{}};const n=[],r={},o=(a,l,i=null)=>{var c;const s=(c=a.key)!=null?c:"",f={scopeRoot:i||this.state.formRoot,state:this.state,instance:this,path:l.path,skipValidation:t},d=Yl(a,s,f);return d!==null?(n.push(...d.errors),{value:d.value,spread:!!d.spread,skip:!!d.skip}):(console.warn(`Unknown field type "${a.type}" for key "${s}"`),{value:null,spread:!1})};return pl(o),this.state.schema.elements.forEach(a=>{if(a.enableIf)try{if(!je(a.enableIf,r))return}catch(i){console.error(`Error evaluating enableIf for field "${a.key}" during validation:`,i)}if(a.type==="markdown")return;const l=o(a,{path:""});l.skip||(l.spread&&l.value!==null&&typeof l.value=="object"?Object.assign(r,l.value):a.key&&(r[a.key]=l.value))}),{valid:n.length===0,errors:n,data:r}}getFormData(){return this.validateForm(!1)}submitForm(){const t=this.validateForm(!1);return t.valid&&typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formSubmit",data:t.data,schema:this.state.schema},"*"),t}saveDraft(){const t=this.validateForm(!0);return typeof window!="undefined"&&window.parent&&window.parent.postMessage({type:"formDraft",data:t.data,schema:this.state.schema},"*"),t}clearForm(){if(!this.state.schema||!this.state.formRoot){console.warn("clearForm: Form not initialized. Call renderForm() first.");return}const t=this.state.schema,n=this.state.formRoot,r=this.state.externalActions,o=this.buildHiddenFieldsData(t.elements);this.renderForm(n,t,o,r||void 0)}buildHiddenFieldsData(t){const n={};for(const r of t){if(r.type==="markdown"||!r.key)continue;const o=r.key;if(r.hidden&&r.default!==void 0&&(n[o]=r.default),r.type==="container"||r.type==="group"){const a=r,l=this.buildHiddenFieldsData(a.elements);Object.keys(l).length>0&&(o in n?typeof n[o]=="object"&&n[o]!==null&&!Array.isArray(n[o])&&(n[o]={...n[o],...l}):n[o]=l)}}return n}buildFlatKeyMap(t){var n,r;const o=new Map;for(const a of t)if(a.type==="richinput"&&a.flatOutput){const l=a,i=(n=l.textKey)!=null?n:"text",c=(r=l.filesKey)!=null?r:"files";o.set(i,{schemaKey:a.key,role:"text"}),o.set(c,{schemaKey:a.key,role:"files"})}return o}setFormData(t){if(!this.state.schema||!this.state.formRoot){console.warn("setFormData: Form not initialized. Call renderForm() first.");return}const n=this.buildFlatKeyMap(this.state.schema.elements),r=new Map;for(const o in t){const a=n.get(o);a?(r.has(a.schemaKey)||r.set(a.schemaKey,{}),r.get(a.schemaKey)[o]=t[o]):this.updateField(o,t[o])}for(const[o,a]of r)this.updateField(o,a)}updateField(t,n){if(!this.state.schema||!this.state.formRoot){console.warn("updateField: Form not initialized. Call renderForm() first.");return}const r=this.findSchemaElement(t);if(!r){console.warn(`updateField: Schema element not found for path "${t}"`);return}const o=this.findFormElementByFieldPath(t);if(!o){console.warn(`updateField: DOM element not found for path "${t}"`);return}this.updateFieldValue(o,r,t,n),this.reevaluateConditionalFields(),(this.state.config.onChange||this.state.config.onFieldChange)&&this.triggerOnChange(t,n)}updateFieldValue(t,n,r,o){const a={scopeRoot:this.state.formRoot,state:this.state,instance:this,path:""};Gl(n,r,o,a)||console.warn(`updateField: No updater found for field type "${n.type}" at path "${r}"`)}findFieldWrapper(t,n){const r=this.state.formRoot,o=wt(t,this.state);if(!n)return Gt(r,o,null);const a=n.match(/^(.+)\[(\d+)\]$/);if(a){const i=r.querySelector(`[data-container-item="${a[1]}[${a[2]}]"]`);return i?Gt(i,o,i):null}const l=r.querySelector(`[data-container="${n}"]`);return l?Gt(l,o,l):null}applyEnableIfVisibility(t,n,r,o,a,l){var i,c,s,f;try{const d=((i=t.enableIf.scope)!=null?i:"relative")==="relative"&&o?rt(l,o):void 0,u=je(t.enableIf,l,d),p=n.getAttribute("data-conditionally-disabled")==="true";if(u&&p){const m=o?rt(l,o):l,b=Xt(t,{path:r,prefill:m&&typeof m=="object"?m:{},formData:l,state:this.state,instance:this});(c=n.parentNode)==null||c.replaceChild(b,n)}else if(!u&&!p){const m=document.createElement("div");m.className="fb-field-wrapper-disabled",m.style.display="none",m.setAttribute("data-field-key",wt(t,this.state)),m.setAttribute("data-conditionally-disabled","true"),(s=n.parentNode)==null||s.replaceChild(m,n)}}catch(d){console.error(`Error re-evaluating enableIf for field "${(f=t.key)!=null?f:"<no key>"}" at path "${a}":`,d)}}reevaluateConditionalFields(){if(!this.state.schema||!this.state.formRoot)return;const t=this.validateForm(!0).data,n=(r,o,a)=>{r.forEach(l=>{var i;const c=(i=l.key)!=null?i:"",s=o?`${o}.${c}`:c,f=a?`${a}.${c}`:c;if(l.enableIf){const d=this.findFieldWrapper(l,o);d&&this.applyEnableIfVisibility(l,d,o,a,s,t)}if((l.type==="container"||l.type==="group")&&"elements"in l&&l.elements){const d=l.key?rt(t,f):void 0;Array.isArray(d)?nt(this.state.formRoot,s).forEach((u,p)=>{const m=u.getAttribute("data-container-item")||"";n(l.elements,m,`${f}[${p}]`)}):n(l.elements,s,f)}})};n(this.state.schema.elements,"","")}destroy(){var t;this.state.debounceTimer!==null&&(clearTimeout(this.state.debounceTimer),this.state.debounceTimer=null),this.disconnectEnableIfObservers(),this.removeTooltipElements(),this.state.resourceIndex.clear(),this.state.formRoot&&we(this.state.formRoot),this.state.formRoot=null,this.state.schema=null,this.state.externalActions=null,this.state.config.verboseErrors&&((t=globalThis.__formBuilderInstances)==null||t.delete(this.instanceId))}disconnectEnableIfObservers(){for(const t of this.state.enableIfObservers)t.disconnect();this.state.enableIfObservers.clear()}removeTooltipElements(){for(const t of this.state.tooltipElements)t.remove();this.state.tooltipElements.clear()}}function yr(e){return new xt(e)}return typeof window!="undefined"&&(window.FormBuilder=xt,window.createFormBuilder=yr,window.validateSchema=kt),Fe.FormBuilderInstance=xt,Fe.createFormBuilder=yr,Fe.default=xt,Fe.defaultTheme=_e,Fe.exampleThemes=ci,Fe.validateSchema=kt,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe})({});
|
|
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})({});
|